Signed-off-by: Jinoh Kang jinoh.kang.kr@gmail.com --- dlls/riched20/clipboard.c | 2 +- dlls/riched20/editor.c | 20 ++++++++++---------- dlls/riched20/editor.h | 2 +- dlls/riched20/richole.c | 6 +++--- dlls/riched20/txtsrv.c | 2 +- 5 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/dlls/riched20/clipboard.c b/dlls/riched20/clipboard.c index 3a8440ffcd6..51c00ca0dbb 100644 --- a/dlls/riched20/clipboard.c +++ b/dlls/riched20/clipboard.c @@ -354,7 +354,7 @@ static HGLOBAL get_unicode_text(ME_TextEditor *editor, const ME_Cursor *start, i
ret = GlobalAlloc(GMEM_MOVEABLE, sizeof(WCHAR) * (nChars + pars + 1)); data = GlobalLock(ret); - ME_GetTextW(editor, data, nChars + pars, start, nChars, TRUE, FALSE); + ME_GetTextW(editor, data, nChars + pars, start, nChars, GT_USECRLF, FALSE); GlobalUnlock(ret); return ret; } diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c index a8cf3175591..3d2d49af047 100644 --- a/dlls/riched20/editor.c +++ b/dlls/riched20/editor.c @@ -1750,7 +1750,7 @@ static LRESULT ME_StreamIn(ME_TextEditor *editor, DWORD format, EDITSTREAM *stre set_selection_cursors(editor, newto, newto);
ME_MoveCursorChars(editor, &linebreakCursor, -linebreakSize, FALSE); - ME_GetTextW(editor, lastchar, 2, &linebreakCursor, linebreakSize, FALSE, FALSE); + ME_GetTextW(editor, lastchar, 2, &linebreakCursor, linebreakSize, GT_DEFAULT, FALSE); if (lastchar[0] == '\r' && (lastchar[1] == '\n' || lastchar[1] == '\0')) { ME_InternalDeleteText(editor, &linebreakCursor, linebreakSize, FALSE); } @@ -2101,7 +2101,7 @@ static int ME_GetTextEx(ME_TextEditor *editor, GETTEXTEX *ex, LPARAM pText) if (ex->codepage == CP_UNICODE) { return ME_GetTextW(editor, (LPWSTR)pText, ex->cb / sizeof(WCHAR) - 1, - &start, nChars, ex->flags & GT_USECRLF, FALSE); + &start, nChars, ex->flags, FALSE); } else { @@ -2118,7 +2118,7 @@ static int ME_GetTextEx(ME_TextEditor *editor, GETTEXTEX *ex, LPARAM pText) buflen = min(crlfmul * nChars, ex->cb - 1); buffer = heap_alloc((buflen + 1) * sizeof(WCHAR));
- nChars = ME_GetTextW(editor, buffer, buflen, &start, nChars, ex->flags & GT_USECRLF, FALSE); + nChars = ME_GetTextW(editor, buffer, buflen, &start, nChars, ex->flags, FALSE); rc = WideCharToMultiByte(ex->codepage, 0, buffer, nChars + 1, (LPSTR)pText, ex->cb, ex->lpDefaultChar, ex->lpUsedDefChar); if (rc) rc--; /* do not count 0 terminator */ @@ -2132,7 +2132,7 @@ static int get_text_range( ME_TextEditor *editor, WCHAR *buffer, const ME_Cursor *start, int len ) { if (!buffer) return 0; - return ME_GetTextW( editor, buffer, INT_MAX, start, len, FALSE, FALSE ); + return ME_GetTextW( editor, buffer, INT_MAX, start, len, GT_DEFAULT, FALSE ); }
int set_selection( ME_TextEditor *editor, int to, int from ) @@ -4235,14 +4235,14 @@ LRESULT editor_handle_message( ME_TextEditor *editor, UINT msg, WPARAM wParam, * buflen: length of buffer in characters excluding the NULL terminator. * start: start of editor text to copy into buffer. * srcChars: Number of characters to use from the editor text. - * bCRLF: if true, replaces all end of lines with \r\n pairs. + * flags: GT_* flags * * returns the number of characters written excluding the NULL terminator. * * The written text is always NULL terminated. */ int ME_GetTextW(ME_TextEditor *editor, WCHAR *buffer, int buflen, - const ME_Cursor *start, int srcChars, BOOL bCRLF, + const ME_Cursor *start, int srcChars, DWORD flags, BOOL bEOP) { ME_Run *run, *next_run; @@ -4250,8 +4250,8 @@ int ME_GetTextW(ME_TextEditor *editor, WCHAR *buffer, int buflen, const WCHAR *str; int nLen;
- /* bCRLF flag is only honored in 2.0 and up. 1.0 must always return text verbatim */ - if (editor->bEmulateVersion10) bCRLF = FALSE; + /* GT_USECRLF flag is only honored in 2.0 and up. 1.0 must always return text verbatim */ + if (editor->bEmulateVersion10) flags &= ~GT_USECRLF;
run = start->run; next_run = run_next_all_paras( run ); @@ -4261,7 +4261,7 @@ int ME_GetTextW(ME_TextEditor *editor, WCHAR *buffer, int buflen,
while (srcChars && buflen && next_run) { - if (bCRLF && run->nFlags & MERF_ENDPARA && ~run->nFlags & MERF_ENDCELL) + if (flags & GT_USECRLF && run->nFlags & MERF_ENDPARA && ~run->nFlags & MERF_ENDCELL) { if (buflen == 1) break; /* FIXME: native fails to reduce srcChars here for WM_GETTEXT or @@ -4450,7 +4450,7 @@ static BOOL ME_IsCandidateAnURL(ME_TextEditor *editor, const ME_Cursor *start, i WCHAR bufferW[MAX_PREFIX_LEN + 1]; unsigned int i;
- ME_GetTextW(editor, bufferW, MAX_PREFIX_LEN, start, nChars, FALSE, FALSE); + ME_GetTextW(editor, bufferW, MAX_PREFIX_LEN, start, nChars, GT_DEFAULT, FALSE); for (i = 0; i < ARRAY_SIZE(prefixes); i++) { if (nChars < prefixes[i].length) continue; diff --git a/dlls/riched20/editor.h b/dlls/riched20/editor.h index e0df63ae92d..78be79659bc 100644 --- a/dlls/riched20/editor.h +++ b/dlls/riched20/editor.h @@ -276,7 +276,7 @@ void ME_DestroyEditor(ME_TextEditor *editor) DECLSPEC_HIDDEN; LRESULT editor_handle_message( ME_TextEditor *editor, UINT msg, WPARAM wParam, LPARAM lParam, HRESULT* phresult ) DECLSPEC_HIDDEN; int ME_GetTextW(ME_TextEditor *editor, WCHAR *buffer, int buflen, - const ME_Cursor *start, int srcChars, BOOL bCRLF, BOOL bEOP) DECLSPEC_HIDDEN; + const ME_Cursor *start, int srcChars, DWORD flags, BOOL bEOP) DECLSPEC_HIDDEN; void ME_RTFCharAttrHook(struct _RTF_Info *info) DECLSPEC_HIDDEN; void ME_RTFParAttrHook(struct _RTF_Info *info) DECLSPEC_HIDDEN; void ME_RTFTblAttrHook(struct _RTF_Info *info) DECLSPEC_HIDDEN; diff --git a/dlls/riched20/richole.c b/dlls/riched20/richole.c index a23f4c82730..2bf2139e089 100644 --- a/dlls/riched20/richole.c +++ b/dlls/riched20/richole.c @@ -1565,7 +1565,7 @@ static HRESULT WINAPI ITextRange_fnGetText(ITextRange *me, BSTR *str) return E_OUTOFMEMORY;
bEOP = (!para_next( para_next( end.para )) && This->end > ME_GetTextLength(editor)); - ME_GetTextW(editor, *str, length, &start, length, FALSE, bEOP); + ME_GetTextW(editor, *str, length, &start, length, GT_DEFAULT, bEOP); return S_OK; }
@@ -1619,7 +1619,7 @@ static HRESULT range_GetChar(ME_TextEditor *editor, ME_Cursor *cursor, LONG *pch { WCHAR wch[2];
- ME_GetTextW(editor, wch, 1, cursor, 1, FALSE, !para_next( para_next( cursor->para ) )); + ME_GetTextW(editor, wch, 1, cursor, 1, GT_DEFAULT, !para_next( para_next( cursor->para ) )); *pch = wch[0];
return S_OK; @@ -4653,7 +4653,7 @@ static HRESULT WINAPI ITextSelection_fnGetText(ITextSelection *me, BSTR *pbstr) return E_OUTOFMEMORY;
bEOP = (!para_next( para_next( end->para ) ) && endOfs > ME_GetTextLength(This->services->editor)); - ME_GetTextW(This->services->editor, *pbstr, nChars, start, nChars, FALSE, bEOP); + ME_GetTextW(This->services->editor, *pbstr, nChars, start, nChars, GT_DEFAULT, bEOP); TRACE("%s\n", wine_dbgstr_w(*pbstr));
return S_OK; diff --git a/dlls/riched20/txtsrv.c b/dlls/riched20/txtsrv.c index 809bb5ac3ae..d79276afc84 100644 --- a/dlls/riched20/txtsrv.c +++ b/dlls/riched20/txtsrv.c @@ -312,7 +312,7 @@ DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_TxGetText( ITextServices *iface, BS if (bstr == NULL) return E_OUTOFMEMORY;
cursor_from_char_ofs( services->editor, 0, &start ); - ME_GetTextW( services->editor, bstr, length, &start, INT_MAX, FALSE, FALSE ); + ME_GetTextW( services->editor, bstr, length, &start, INT_MAX, GT_DEFAULT, FALSE ); *text = bstr; } else *text = NULL;
Signed-off-by: Jinoh Kang jinoh.kang.kr@gmail.com --- dlls/riched20/editor.c | 6 ++++++ dlls/riched20/tests/richole.c | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c index 3d2d49af047..454a8bf5fc8 100644 --- a/dlls/riched20/editor.c +++ b/dlls/riched20/editor.c @@ -4271,6 +4271,12 @@ int ME_GetTextW(ME_TextEditor *editor, WCHAR *buffer, int buflen, nLen = 2; str = L"\r\n"; } + else if (flags & GT_RAWTEXT && run->nFlags & MERF_GRAPHICS) + { + srcChars -= min(nLen, srcChars); + nLen = 1; + str = L"\xfffc"; + } else { nLen = min(nLen, srcChars); diff --git a/dlls/riched20/tests/richole.c b/dlls/riched20/tests/richole.c index 24284a24484..dc0d7c4e1f1 100644 --- a/dlls/riched20/tests/richole.c +++ b/dlls/riched20/tests/richole.c @@ -3404,7 +3404,7 @@ static void test_InsertObject(void) memset(buffer, 0, sizeof(buffer)); result = SendMessageW(hwnd, EM_GETTEXTEX, (WPARAM)&gettextex, (LPARAM)buffer); ok(result == lstrlenW(expected_string), "Got wrong length: %ld.\n", result); - todo_wine ok(!lstrcmpW(buffer, expected_string), "Got wrong content: %s.\n", debugstr_w(buffer)); + ok(!lstrcmpW(buffer, expected_string), "Got wrong content: %s.\n", debugstr_w(buffer));
gettextex.flags = GT_NOHIDDENTEXT; memset(buffer, 0, sizeof(buffer)); @@ -3507,7 +3507,7 @@ static void test_InsertObject(void) memset(buffer, 0, sizeof(buffer)); result = SendMessageW(hwnd, EM_GETTEXTEX, (WPARAM)&gettextex, (LPARAM)buffer); ok(result == lstrlenW(expected_string), "Got wrong length: %ld.\n", result); - todo_wine ok(!lstrcmpW(buffer, expected_string), "Got wrong content: %s.\n", debugstr_w(buffer)); + ok(!lstrcmpW(buffer, expected_string), "Got wrong content: %s.\n", debugstr_w(buffer));
expected_stringA = "abc d efg"; memset(bufferA, 0, sizeof(bufferA));
On Mon, Mar 28, 2022 at 12:41:12AM +0900, Jinoh Kang wrote:
Signed-off-by: Jinoh Kang jinoh.kang.kr@gmail.com
dlls/riched20/editor.c | 6 ++++++ dlls/riched20/tests/richole.c | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c index 3d2d49af047..454a8bf5fc8 100644 --- a/dlls/riched20/editor.c +++ b/dlls/riched20/editor.c @@ -4271,6 +4271,12 @@ int ME_GetTextW(ME_TextEditor *editor, WCHAR *buffer, int buflen, nLen = 2; str = L"\r\n"; }
- else if (flags & GT_RAWTEXT && run->nFlags & MERF_GRAPHICS)
- {
srcChars -= min(nLen, srcChars);
nLen = 1;
str = L"\xfffc";
- } else { nLen = min(nLen, srcChars);
diff --git a/dlls/riched20/tests/richole.c b/dlls/riched20/tests/richole.c index 24284a24484..dc0d7c4e1f1 100644 --- a/dlls/riched20/tests/richole.c +++ b/dlls/riched20/tests/richole.c @@ -3404,7 +3404,7 @@ static void test_InsertObject(void) memset(buffer, 0, sizeof(buffer)); result = SendMessageW(hwnd, EM_GETTEXTEX, (WPARAM)&gettextex, (LPARAM)buffer); ok(result == lstrlenW(expected_string), "Got wrong length: %ld.\n", result);
- todo_wine ok(!lstrcmpW(buffer, expected_string), "Got wrong content: %s.\n", debugstr_w(buffer));
- ok(!lstrcmpW(buffer, expected_string), "Got wrong content: %s.\n", debugstr_w(buffer));
The tests just before this show that GT_DEFAULT behaves in the same way (which conflicts with the docs). Though it would be worth hacking new_richedit() to create a MSFTEDIT_CLASS window to see if that changes anything.
I think the right thing to do is to store 0xfffc in memory (see editor_insert_oleobj()) and fixup the other text getters that need to return a space (possibly introducing a custom GT_ flag so this can be done in ME_GetTextW()).
Huw.
On Mon, Mar 28, 2022, 4:10 PM Huw Davies huw@codeweavers.com wrote:
On Mon, Mar 28, 2022 at 12:41:12AM +0900, Jinoh Kang wrote:
Signed-off-by: Jinoh Kang jinoh.kang.kr@gmail.com
dlls/riched20/editor.c | 6 ++++++ dlls/riched20/tests/richole.c | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c index 3d2d49af047..454a8bf5fc8 100644 --- a/dlls/riched20/editor.c +++ b/dlls/riched20/editor.c @@ -4271,6 +4271,12 @@ int ME_GetTextW(ME_TextEditor *editor, WCHAR
*buffer, int buflen,
nLen = 2; str = L"\r\n"; }
- else if (flags & GT_RAWTEXT && run->nFlags & MERF_GRAPHICS)
- {
srcChars -= min(nLen, srcChars);
nLen = 1;
str = L"\xfffc";
- } else { nLen = min(nLen, srcChars);
diff --git a/dlls/riched20/tests/richole.c
b/dlls/riched20/tests/richole.c
index 24284a24484..dc0d7c4e1f1 100644 --- a/dlls/riched20/tests/richole.c +++ b/dlls/riched20/tests/richole.c @@ -3404,7 +3404,7 @@ static void test_InsertObject(void) memset(buffer, 0, sizeof(buffer)); result = SendMessageW(hwnd, EM_GETTEXTEX, (WPARAM)&gettextex,
(LPARAM)buffer);
ok(result == lstrlenW(expected_string), "Got wrong length: %ld.\n",
result);
- todo_wine ok(!lstrcmpW(buffer, expected_string), "Got wrong content:
%s.\n", debugstr_w(buffer));
- ok(!lstrcmpW(buffer, expected_string), "Got wrong content: %s.\n",
debugstr_w(buffer));
The tests just before this show that GT_DEFAULT behaves in the same way (which conflicts with the docs). Though it would be worth hacking new_richedit() to create a MSFTEDIT_CLASS window to see if that changes anything.
Test results show the following:
In riched20, U+FFFD is returned regardless of whether or not GT_RAWTEXT is specified. (maybe it didn't exist at all?) In msftedit, GT_RAWTEXT is honoured for objects (as specified in docs).
I think the right thing to do is to store 0xfffc in memory (see editor_insert_oleobj())
Great!
and fixup the other text getters that need to
return a space (possibly introducing a custom GT_ flag so this can be done in ME_GetTextW()).
The question is: do other getters care at all? Perhaps we can leave GT_DEFAULT as-is, instead forcing GT_RAWTEXT in message handler if the control is in riched20 compatibility mode. This could use some more testing, though.
Huw.