Signed-off-by: Jactry Zeng jzeng@codeweavers.com --- Superseded patch 206432 to 206436. --- dlls/riched20/tests/richole.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/dlls/riched20/tests/richole.c b/dlls/riched20/tests/richole.c index c2457ae5146..a76f9fdaf2e 100644 --- a/dlls/riched20/tests/richole.c +++ b/dlls/riched20/tests/richole.c @@ -3252,7 +3252,7 @@ static void test_InsertObject(void) REOBJECT reo1, reo2, reo3, received_reo; HRESULT hr; HWND hwnd; - const WCHAR *expected_string; + const WCHAR *expected_string, *string; const CHAR *expected_stringA; ITextSelection *selection; IDataObject *dataobject; @@ -3465,8 +3465,10 @@ static void test_InsertObject(void) formatetc.lindex = -1; hr = IDataObject_GetData(dataobject, &formatetc, &stgmedium); ok(hr == S_OK, "Got hr %#x.\n", hr); - todo_wine ok(lstrlenW(stgmedium.hGlobal) == lstrlenW(expected_string), "Got wrong length: %d.\n", result); - todo_wine ok(!lstrcmpW(stgmedium.hGlobal, expected_string), "Got wrong content: %s.\n", debugstr_w(stgmedium.hGlobal)); + string = GlobalLock(stgmedium.hGlobal); + ok(lstrlenW(string) == lstrlenW(expected_string), "Got wrong length: %d.\n", lstrlenW(string)); + todo_wine ok(!lstrcmpW(string, expected_string), "Got wrong content: %s.\n", debugstr_w(string)); + GlobalUnlock(stgmedium.hGlobal);
expected_string = L"abc\xfffc""d\xfffc""efg"; gettextex.cb = sizeof(buffer);
Signed-off-by: Jactry Zeng jzeng@codeweavers.com --- dlls/riched20/caret.c | 14 +++++++++++--- dlls/riched20/tests/richole.c | 18 +++++++++--------- 2 files changed, 20 insertions(+), 12 deletions(-)
diff --git a/dlls/riched20/caret.c b/dlls/riched20/caret.c index 1f4c3903a38..3104178082a 100644 --- a/dlls/riched20/caret.c +++ b/dlls/riched20/caret.c @@ -460,10 +460,18 @@ void ME_InsertOLEFromCursor(ME_TextEditor *editor, const REOBJECT* reo, int nCur ME_Run *run, *prev; const WCHAR space = ' '; struct re_object *reobj_prev = NULL; - ME_Cursor *cursor = editor->pCursors + nCursor; - ME_Style *style = style_get_insert_style( editor, cursor ); + ME_Cursor *cursor, cursor_from_ofs; + ME_Style *style; + + if (reo->cp == REO_CP_SELECTION) + cursor = editor->pCursors + nCursor; + else + { + cursor_from_char_ofs( editor, reo->cp, &cursor_from_ofs ); + cursor = &cursor_from_ofs; + } + style = style_get_insert_style( editor, cursor );
- /* FIXME no no no */ if (ME_IsSelection(editor)) ME_DeleteSelection(editor);
diff --git a/dlls/riched20/tests/richole.c b/dlls/riched20/tests/richole.c index a76f9fdaf2e..a8c48994613 100644 --- a/dlls/riched20/tests/richole.c +++ b/dlls/riched20/tests/richole.c @@ -3377,15 +3377,15 @@ static void test_InsertObject(void)
SendMessageW(hwnd, EM_SETSEL, 3, 4); result = SendMessageW(hwnd, EM_SELECTIONTYPE, 0, 0); - todo_wine ok(result == SEL_OBJECT, "Got selection type: %x.\n", result); - todo_wine CHECK_REOBJECT_STRUCT(reole, REO_IOB_SELECTION, REO_GETOBJ_ALL_INTERFACES, 1, NULL, NULL, reo1.polesite, 1); + ok(result == SEL_OBJECT, "Got selection type: %x.\n", result); + CHECK_REOBJECT_STRUCT(reole, REO_IOB_SELECTION, REO_GETOBJ_ALL_INTERFACES, 1, NULL, NULL, reo1.polesite, 1);
SendMessageW(hwnd, EM_SETSEL, 2, 4); result = SendMessageW(hwnd, EM_SELECTIONTYPE, 0, 0); - todo_wine ok(result == (SEL_TEXT | SEL_OBJECT), "Got selection type: %x.\n", result); + ok(result == (SEL_TEXT | SEL_OBJECT), "Got selection type: %x.\n", result);
SendMessageW(hwnd, EM_SETSEL, 5, 6); - todo_wine CHECK_REOBJECT_STRUCT(reole, REO_IOB_SELECTION, REO_GETOBJ_ALL_INTERFACES, 1, NULL, NULL, reo2.polesite, 2); + CHECK_REOBJECT_STRUCT(reole, REO_IOB_SELECTION, REO_GETOBJ_ALL_INTERFACES, 1, NULL, NULL, reo2.polesite, 2);
expected_string = L"abc\xfffc""d\xfffc""efg"; gettextex.cb = sizeof(buffer); @@ -3408,7 +3408,7 @@ static void test_InsertObject(void) SendMessageA(hwnd, EM_SETSEL, 0, -1); result = SendMessageA(hwnd, EM_GETSELTEXT, (WPARAM)sizeof(bufferA), (LPARAM)bufferA); ok(result == strlen(expected_stringA), "Got wrong length: %d.\n", result); - todo_wine ok(!strcmp(bufferA, expected_stringA), "Got wrong content: %s.\n", bufferA); + ok(!strcmp(bufferA, expected_stringA), "Got wrong content: %s.\n", bufferA);
memset(bufferA, 0, sizeof(bufferA)); textrange.lpstrText = bufferA; @@ -3416,7 +3416,7 @@ static void test_InsertObject(void) textrange.chrg.cpMax = 11; result = SendMessageA(hwnd, EM_GETTEXTRANGE, 0, (LPARAM)&textrange); ok(result == strlen(expected_stringA), "Got wrong length: %d.\n", result); - todo_wine ok(!strcmp(bufferA, expected_stringA), "Got wrong content: %s.\n", bufferA); + ok(!strcmp(bufferA, expected_stringA), "Got wrong content: %s.\n", bufferA);
expected_string = L"abc\xfffc""d\xfffc""efg\r"; hr = ITextDocument_Range(doc, 0, 11, &range); @@ -3467,7 +3467,7 @@ static void test_InsertObject(void) ok(hr == S_OK, "Got hr %#x.\n", hr); string = GlobalLock(stgmedium.hGlobal); ok(lstrlenW(string) == lstrlenW(expected_string), "Got wrong length: %d.\n", lstrlenW(string)); - todo_wine ok(!lstrcmpW(string, expected_string), "Got wrong content: %s.\n", debugstr_w(string)); + ok(!lstrcmpW(string, expected_string), "Got wrong content: %s.\n", debugstr_w(string)); GlobalUnlock(stgmedium.hGlobal);
expected_string = L"abc\xfffc""d\xfffc""efg"; @@ -3491,7 +3491,7 @@ static void test_InsertObject(void) SendMessageA(hwnd, EM_SETSEL, 0, -1); result = SendMessageA(hwnd, EM_GETSELTEXT, (WPARAM)sizeof(bufferA), (LPARAM)bufferA); ok(result == strlen(expected_stringA), "Got wrong length: %d.\n", result); - todo_wine ok(!strcmp(bufferA, expected_stringA), "Got wrong content: %s.\n", bufferA); + ok(!strcmp(bufferA, expected_stringA), "Got wrong content: %s.\n", bufferA);
memset(bufferA, 0, sizeof(bufferA)); textrange.lpstrText = bufferA; @@ -3499,7 +3499,7 @@ static void test_InsertObject(void) textrange.chrg.cpMax = 11; result = SendMessageA(hwnd, EM_GETTEXTRANGE, 0, (LPARAM)&textrange); ok(result == strlen(expected_stringA), "Got wrong length: %d.\n", result); - todo_wine ok(!strcmp(bufferA, expected_stringA), "Got wrong content: %s.\n", bufferA); + ok(!strcmp(bufferA, expected_stringA), "Got wrong content: %s.\n", bufferA);
expected_string = L"abc\xfffc""d\xfffc""efg"; hr = ITextDocument_Range(doc, 0, 11, &range);
On Sat, May 29, 2021 at 10:01:38PM +0800, Jactry Zeng wrote:
Signed-off-by: Jactry Zeng jzeng@codeweavers.com
dlls/riched20/caret.c | 14 +++++++++++--- dlls/riched20/tests/richole.c | 18 +++++++++--------- 2 files changed, 20 insertions(+), 12 deletions(-)
diff --git a/dlls/riched20/caret.c b/dlls/riched20/caret.c index 1f4c3903a38..3104178082a 100644 --- a/dlls/riched20/caret.c +++ b/dlls/riched20/caret.c @@ -460,10 +460,18 @@ void ME_InsertOLEFromCursor(ME_TextEditor *editor, const REOBJECT* reo, int nCur
Since this is always called with nCursor == 0, let's remove the parameter. While we're at it, rename the function to editor_insert_oleobj().
Huw.
Signed-off-by: Jactry Zeng jzeng@codeweavers.com --- dlls/riched20/clipboard.c | 2 +- dlls/riched20/editor.c | 22 ++++++++++------------ dlls/riched20/editor.h | 2 +- dlls/riched20/editstr.h | 6 ++++++ dlls/riched20/richole.c | 6 +++--- dlls/riched20/txtsrv.c | 2 +- 6 files changed, 22 insertions(+), 18 deletions(-)
diff --git a/dlls/riched20/clipboard.c b/dlls/riched20/clipboard.c index 10a814214be..69041fb7580 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, MEGT_USECRLF); GlobalUnlock(ret); return ret; } diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c index d4aadc325f9..87f4c7a4e32 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, MEGT_DEFAULT); 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 & GT_USECRLF) ? MEGT_USECRLF : MEGT_DEFAULT); } 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 & GT_USECRLF) ? MEGT_USECRLF : MEGT_DEFAULT); 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, MEGT_DEFAULT ); }
int set_selection( ME_TextEditor *editor, int to, int from ) @@ -4239,23 +4239,21 @@ 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. * * 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, - BOOL bEOP) + const ME_Cursor *start, int srcChars, DWORD flags) { ME_Run *run, *next_run; const WCHAR *pStart = buffer; 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; + /* CR to CRLF is only supported in 2.0 and up. 1.0 must always return text verbatim. */ + if (editor->bEmulateVersion10) flags &= ~MEGT_USECRLF;
run = start->run; next_run = run_next_all_paras( run ); @@ -4265,7 +4263,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 & MEGT_USECRLF && run->nFlags & MERF_ENDPARA && ~run->nFlags & MERF_ENDCELL) { if (buflen == 1) break; /* FIXME: native fails to reduce srcChars here for WM_GETTEXT or @@ -4295,7 +4293,7 @@ int ME_GetTextW(ME_TextEditor *editor, WCHAR *buffer, int buflen, str = get_text( run, 0 ); } /* append '\r' to the last paragraph. */ - if (run == para_end_run( para_prev( editor_end_para( editor ) ) ) && bEOP) + if (flags & MEGT_USEEOP && run == para_end_run( para_prev( editor_end_para( editor ) ) )) { *buffer = '\r'; buffer ++; @@ -4454,7 +4452,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, MEGT_DEFAULT); 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 141e9034a6a..ee1b2e2b2e1 100644 --- a/dlls/riched20/editor.h +++ b/dlls/riched20/editor.h @@ -277,7 +277,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) 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/editstr.h b/dlls/riched20/editstr.h index 22cfd74722c..7ede0f6a207 100644 --- a/dlls/riched20/editstr.h +++ b/dlls/riched20/editstr.h @@ -98,6 +98,12 @@ typedef enum {
#define SELECTIONBAR_WIDTH 8
+/* Flags used in ME_GetTextW() */ +#define MEGT_DEFAULT 0x00000000 +#define MEGT_USECRLF 0x00000001 /* Translate each CR into a CR/LF. */ +#define MEGT_USEEOP 0x00000002 /* Append EOP. */ +#define MEGT_NOOLEOBJ 0x00000004 /* Replace OLE object mark with a space. */ + /******************************** run flags *************************/ #define MERF_STYLEFLAGS 0x0FFF /* run contains non-text content, which has its own rules for wrapping, sizing etc */ diff --git a/dlls/riched20/richole.c b/dlls/riched20/richole.c index 72840a4cafa..ccd97668338 100644 --- a/dlls/riched20/richole.c +++ b/dlls/riched20/richole.c @@ -1563,7 +1563,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, bEOP ? MEGT_USEEOP : MEGT_DEFAULT); return S_OK; }
@@ -1617,7 +1617,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, !para_next( para_next( cursor->para ) ) ? MEGT_USEEOP : MEGT_DEFAULT); *pch = wch[0];
return S_OK; @@ -4651,7 +4651,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, bEOP ? MEGT_USEEOP : MEGT_DEFAULT); TRACE("%s\n", wine_dbgstr_w(*pbstr));
return S_OK; diff --git a/dlls/riched20/txtsrv.c b/dlls/riched20/txtsrv.c index 73b8d3ea7e9..c82d14f8f26 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, MEGT_DEFAULT ); *text = bstr; } else *text = NULL;
On Sat, May 29, 2021 at 10:01:39PM +0800, Jactry Zeng wrote:
Signed-off-by: Jactry Zeng jzeng@codeweavers.com
dlls/riched20/clipboard.c | 2 +- dlls/riched20/editor.c | 22 ++++++++++------------ dlls/riched20/editor.h | 2 +- dlls/riched20/editstr.h | 6 ++++++ dlls/riched20/richole.c | 6 +++--- dlls/riched20/txtsrv.c | 2 +- 6 files changed, 22 insertions(+), 18 deletions(-)
@@ -277,7 +277,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) DECLSPEC_HIDDEN;
While we're at it, let's change the name to editor_get_text().
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/editstr.h b/dlls/riched20/editstr.h index 22cfd74722c..7ede0f6a207 100644 --- a/dlls/riched20/editstr.h +++ b/dlls/riched20/editstr.h @@ -98,6 +98,12 @@ typedef enum {
#define SELECTIONBAR_WIDTH 8
+/* Flags used in ME_GetTextW() */ +#define MEGT_DEFAULT 0x00000000 +#define MEGT_USECRLF 0x00000001 /* Translate each CR into a CR/LF. */
You can use the GT_ defines for these.
+#define MEGT_USEEOP 0x00000002 /* Append EOP. */
This could be WINE_GT_USEEOP
+#define MEGT_NOOLEOBJ 0x00000004 /* Replace OLE object mark with a space. */
Wouldn't GT_RAWTEXT do what we want here?
Huw.
Hi Huw,
On 6/7/21 8:47 PM, Huw Davies wrote:
+#define MEGT_NOOLEOBJ 0x00000004 /* Replace OLE object mark with a space. */
Wouldn't GT_RAWTEXT do what we want here?
I submitted more tests of EM_GETTEXTEX in https://source.winehq.org/patches/data/207366 . It exposed that EM_GETTEXTEX return content including OLE object mark for most of its mode, includes GT_DEFAULT and GT_RAWTEXT. The different between GT_DEFAULT and GT_RAWTEXT is that GT_DEFAULT doesn't includes tables and math objects. So we still need one more private flag likes WINE_GT_NOOLEOBJ for toggling it?
On Tue, Jun 08, 2021 at 01:56:09PM +0800, Jactry Zeng wrote:
Hi Huw, On 6/7/21 8:47 PM, Huw Davies wrote: +#define MEGT_NOOLEOBJ 0x00000004 /* Replace OLE object mark with a space. */ Wouldn't GT_RAWTEXT do what we want here? I submitted more tests of EM_GETTEXTEX in https://source.winehq.org/patches/ data/207366 . It exposed that EM_GETTEXTEX return content including OLE object mark for most of its mode, includes GT_DEFAULT and GT_RAWTEXT. The different between GT_DEFAULT and GT_RAWTEXT is that GT_DEFAULT doesn't includes tables and math objects. So we still need one more private flag likes WINE_GT_NOOLEOBJ for toggling it?
Ah, right, that's "interesting". I see you actually had a test for that in [6/6]. Could you extend that test and include a table too so that we can see whether GT_DEFAULT really does strip out the table markers? (obviously that would be marked todo_wine since we don't currently add the table markers in Wine).
Thanks, Huw.
Signed-off-by: Jactry Zeng jzeng@codeweavers.com
--- v3: Also return text without ole objects in clipboard.c:get_unicode_text(). --- dlls/riched20/caret.c | 4 ++-- dlls/riched20/clipboard.c | 2 +- dlls/riched20/editor.c | 7 ++++++- dlls/riched20/tests/richole.c | 20 ++++++++++---------- dlls/riched20/tests/txtsrv.c | 2 +- 5 files changed, 20 insertions(+), 15 deletions(-)
diff --git a/dlls/riched20/caret.c b/dlls/riched20/caret.c index 3104178082a..bd7f5dc0149 100644 --- a/dlls/riched20/caret.c +++ b/dlls/riched20/caret.c @@ -458,7 +458,7 @@ static struct re_object* create_re_object(const REOBJECT *reo) void ME_InsertOLEFromCursor(ME_TextEditor *editor, const REOBJECT* reo, int nCursor) { ME_Run *run, *prev; - const WCHAR space = ' '; + const WCHAR ole_object_mark = 0xfffc; struct re_object *reobj_prev = NULL; ME_Cursor *cursor, cursor_from_ofs; ME_Style *style; @@ -475,7 +475,7 @@ void ME_InsertOLEFromCursor(ME_TextEditor *editor, const REOBJECT* reo, int nCur if (ME_IsSelection(editor)) ME_DeleteSelection(editor);
- run = run_insert( editor, cursor, style, &space, 1, MERF_GRAPHICS ); + run = run_insert( editor, cursor, style, &ole_object_mark, 1, MERF_GRAPHICS );
run->reobj = create_re_object( reo );
diff --git a/dlls/riched20/clipboard.c b/dlls/riched20/clipboard.c index 69041fb7580..cad2a3e7e3e 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, MEGT_USECRLF); + ME_GetTextW(editor, data, nChars + pars, start, nChars, MEGT_USECRLF | MEGT_NOOLEOBJ); GlobalUnlock(ret); return ret; } diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c index 87f4c7a4e32..960d1401082 100644 --- a/dlls/riched20/editor.c +++ b/dlls/riched20/editor.c @@ -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, MEGT_DEFAULT ); + return ME_GetTextW( editor, buffer, INT_MAX, start, len, MEGT_NOOLEOBJ ); }
int set_selection( ME_TextEditor *editor, int to, int from ) @@ -4273,6 +4273,11 @@ int ME_GetTextW(ME_TextEditor *editor, WCHAR *buffer, int buflen, nLen = 2; str = L"\r\n"; } + else if (flags & MEGT_NOOLEOBJ && run->nFlags & MERF_GRAPHICS) + { + srcChars--; + str = L" "; + } else { nLen = min(nLen, srcChars); diff --git a/dlls/riched20/tests/richole.c b/dlls/riched20/tests/richole.c index a8c48994613..a0eaa2905bb 100644 --- a/dlls/riched20/tests/richole.c +++ b/dlls/riched20/tests/richole.c @@ -3395,13 +3395,13 @@ static void test_InsertObject(void) gettextex.lpUsedDefChar = NULL; result = SendMessageW(hwnd, EM_GETTEXTEX, (WPARAM)&gettextex, (LPARAM)buffer); ok(result == lstrlenW(expected_string), "Got wrong length: %d.\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_RAWTEXT; memset(buffer, 0, sizeof(buffer)); result = SendMessageW(hwnd, EM_GETTEXTEX, (WPARAM)&gettextex, (LPARAM)buffer); ok(result == lstrlenW(expected_string), "Got wrong length: %d.\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)); @@ -3424,26 +3424,26 @@ static void test_InsertObject(void) hr = ITextRange_GetText(range, &bstr); ok(hr == S_OK, "Got hr %#x.\n", hr); ok(lstrlenW(bstr) == lstrlenW(expected_string), "Got wrong length: %d.\n", lstrlenW(bstr)); - todo_wine ok(!lstrcmpW(bstr, expected_string), "Got text: %s.\n", wine_dbgstr_w(bstr)); + ok(!lstrcmpW(bstr, expected_string), "Got text: %s.\n", wine_dbgstr_w(bstr)); SysFreeString(bstr); hr = ITextRange_SetRange(range, 3, 4); ok(hr == S_OK, "Got hr %#x.\n", hr); hr = ITextRange_GetChar(range, &result); ok(hr == S_OK, "Got hr %#x.\n", hr); - todo_wine ok(result == 0xfffc, "Got char: %c\n", result); + ok(result == 0xfffc, "Got char: %c\n", result); ITextRange_Release(range);
SendMessageW(hwnd, EM_SETSEL, 0, -1); hr = ITextSelection_GetText(selection, &bstr); ok(hr == S_OK, "Got hr %#x.\n", hr); ok(lstrlenW(bstr) == lstrlenW(expected_string), "Got wrong length: %d.\n", lstrlenW(bstr)); - todo_wine ok(!lstrcmpW(bstr, expected_string), "Got text: %s.\n", wine_dbgstr_w(bstr)); + ok(!lstrcmpW(bstr, expected_string), "Got text: %s.\n", wine_dbgstr_w(bstr)); SysFreeString(bstr); SendMessageW(hwnd, EM_SETSEL, 3, 4); result = 0; hr = ITextSelection_GetChar(selection, &result); ok(hr == S_OK, "Got hr %#x.\n", hr); - todo_wine ok(result == 0xfffc, "Got char: %c\n", result); + ok(result == 0xfffc, "Got char: %c\n", result);
SendMessageA(hwnd, WM_SETTEXT, 0, (LPARAM)""); result = SendMessageW(hwnd, EM_SETTEXTMODE, (WPARAM)TM_PLAINTEXT, 0); @@ -3478,13 +3478,13 @@ static void test_InsertObject(void) gettextex.lpUsedDefChar = NULL; result = SendMessageW(hwnd, EM_GETTEXTEX, (WPARAM)&gettextex, (LPARAM)buffer); ok(result == lstrlenW(expected_string), "Got wrong length: %d.\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_RAWTEXT; memset(buffer, 0, sizeof(buffer)); result = SendMessageW(hwnd, EM_GETTEXTEX, (WPARAM)&gettextex, (LPARAM)buffer); ok(result == lstrlenW(expected_string), "Got wrong length: %d.\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)); @@ -3513,7 +3513,7 @@ static void test_InsertObject(void) ok(hr == S_OK, "Got hr %#x.\n", hr); hr = ITextRange_GetChar(range, &result); ok(hr == S_OK, "Got hr %#x.\n", hr); - todo_wine ok(result == 0xfffc, "Got char: %c\n", result); + ok(result == 0xfffc, "Got char: %c\n", result); ITextRange_Release(range);
SendMessageW(hwnd, EM_SETSEL, 0, -1); @@ -3526,7 +3526,7 @@ static void test_InsertObject(void) result = 0; hr = ITextSelection_GetChar(selection, &result); ok(hr == S_OK, "Got hr %#x.\n", hr); - todo_wine ok(result == 0xfffc, "Got char: %c\n", result); + ok(result == 0xfffc, "Got char: %c\n", result);
release_interfaces(&hwnd, &reole, &doc, &selection); } diff --git a/dlls/riched20/tests/txtsrv.c b/dlls/riched20/tests/txtsrv.c index 1f789da8a37..0f6fc44cee6 100644 --- a/dlls/riched20/tests/txtsrv.c +++ b/dlls/riched20/tests/txtsrv.c @@ -698,7 +698,7 @@ static void test_TxGetText(void) hres = ITextServices_TxGetText(txtserv, &rettext); ok(hres == S_OK, "Got hres: %#x.\n", hres); ok(lstrlenW(rettext) == lstrlenW(expected_string), "Got wrong length: %d.\n", lstrlenW(rettext)); - todo_wine ok(!lstrcmpW(rettext, expected_string), "Got wrong content: %s.\n", debugstr_w(rettext)); + ok(!lstrcmpW(rettext, expected_string), "Got wrong content: %s.\n", debugstr_w(rettext)); SysFreeString(rettext); IOleClientSite_Release(clientsite); IRichEditOle_Release(reole);
Signed-off-by: Jactry Zeng jzeng@codeweavers.com --- dlls/riched20/editor.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c index 960d1401082..9d24d97d820 100644 --- a/dlls/riched20/editor.c +++ b/dlls/riched20/editor.c @@ -2076,10 +2076,11 @@ ME_FindText(ME_TextEditor *editor, DWORD flags, const CHARRANGE *chrg, const WCH return -1; }
-static int ME_GetTextEx(ME_TextEditor *editor, GETTEXTEX *ex, LPARAM pText) +static int ME_GetTextEx(ME_TextEditor *editor, GETTEXTEX *ex, LPARAM pText, BOOL oleobj) { int nChars; ME_Cursor start; + DWORD flags;
if (!ex->cb || !pText) return 0;
@@ -2098,10 +2099,14 @@ static int ME_GetTextEx(ME_TextEditor *editor, GETTEXTEX *ex, LPARAM pText) ME_SetCursorToStart(editor, &start); nChars = INT_MAX; } + + flags = (ex->flags & GT_USECRLF) ? MEGT_USECRLF : MEGT_DEFAULT; + if (!oleobj) flags |= MEGT_NOOLEOBJ; + if (ex->codepage == CP_UNICODE) { return ME_GetTextW(editor, (LPWSTR)pText, ex->cb / sizeof(WCHAR) - 1, - &start, nChars, (ex->flags & GT_USECRLF) ? MEGT_USECRLF : MEGT_DEFAULT); + &start, nChars, flags); } else { @@ -2118,7 +2123,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) ? MEGT_USECRLF : MEGT_DEFAULT); + nChars = ME_GetTextW(editor, buffer, buflen, &start, nChars, flags); rc = WideCharToMultiByte(ex->codepage, 0, buffer, nChars + 1, (LPSTR)pText, ex->cb, ex->lpDefaultChar, ex->lpUsedDefChar); if (rc) rc--; /* do not count 0 terminator */ @@ -3662,10 +3667,10 @@ LRESULT editor_handle_message( ME_TextEditor *editor, UINT msg, WPARAM wParam, ex.codepage = CP_UNICODE; ex.lpDefaultChar = NULL; ex.lpUsedDefChar = NULL; - return ME_GetTextEx(editor, &ex, lParam); + return ME_GetTextEx(editor, &ex, lParam, FALSE); } case EM_GETTEXTEX: - return ME_GetTextEx(editor, (GETTEXTEX*)wParam, lParam); + return ME_GetTextEx(editor, (GETTEXTEX*)wParam, lParam, TRUE); case EM_GETSELTEXT: { int nFrom, nTo, nStartCur = ME_GetSelectionOfs(editor, &nFrom, &nTo);
On Sat, May 29, 2021 at 10:01:41PM +0800, Jactry Zeng wrote:
Signed-off-by: Jactry Zeng jzeng@codeweavers.com
dlls/riched20/editor.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c index 960d1401082..9d24d97d820 100644 --- a/dlls/riched20/editor.c +++ b/dlls/riched20/editor.c @@ -2076,10 +2076,11 @@ ME_FindText(ME_TextEditor *editor, DWORD flags, const CHARRANGE *chrg, const WCH return -1; }
-static int ME_GetTextEx(ME_TextEditor *editor, GETTEXTEX *ex, LPARAM pText) +static int ME_GetTextEx(ME_TextEditor *editor, GETTEXTEX *ex, LPARAM pText, BOOL oleobj)
You shouldn't need an extra param here. The behaviour should be toggled with GT_RAWTEXT.
It would make sense to rewrite ME_GetTextW() so that it calls ME_GetTextEx() and not the other way around.
Huw.
Signed-off-by: Jactry Zeng jzeng@codeweavers.com --- dlls/riched20/tests/txtsrv.c | 56 ++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+)
diff --git a/dlls/riched20/tests/txtsrv.c b/dlls/riched20/tests/txtsrv.c index 0f6fc44cee6..38d3c6b128d 100644 --- a/dlls/riched20/tests/txtsrv.c +++ b/dlls/riched20/tests/txtsrv.c @@ -1217,6 +1217,61 @@ static void test_notifications( void ) ITextHost_Release( host ); }
+static void test_TxSendMesssage_gettext(void) +{ + const WCHAR *expected_string; + IOleClientSite *clientsite; + ITextServices *txtserv; + IRichEditOle *reole; + GETTEXTEX gettextex; + WCHAR buffer[1024]; + REOBJECT reobject; + ITextHost *host; + LRESULT result; + HRESULT hr; + + init_texthost(&txtserv, &host); + + hr = ITextServices_TxSetText(txtserv, L"abcdefg"); + ok(hr == S_OK, "Got hr: %#x.\n", hr); + hr = ITextServices_QueryInterface(txtserv, &IID_IRichEditOle, (void **)&reole); + ok(hr == S_OK, "Got hr: %#x.\n", hr); + hr = IRichEditOle_GetClientSite(reole, &clientsite); + ok(hr == S_OK, "Got hr: %#x.\n", hr); + fill_reobject_struct(&reobject, 3, NULL, NULL, clientsite, 10, 10, DVASPECT_CONTENT, 0, 1); + hr = IRichEditOle_InsertObject(reole, &reobject); + ok(hr == S_OK, "Got hr: %#x.\n", hr); + + expected_string = L"abc defg"; + hr = ITextServices_TxSendMessage(txtserv, WM_GETTEXT, sizeof(buffer), (LPARAM)buffer, &result); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(result == lstrlenW(expected_string), "Got wrong length: %ld.\n", result); + ok(!lstrcmpW(buffer, expected_string), "Got wrong content: %s.\n", debugstr_w(buffer)); + + expected_string = L"abc\xfffc""defg"; + gettextex.cb = sizeof(buffer); + gettextex.flags = GT_DEFAULT; + gettextex.codepage = 1200; + gettextex.lpDefaultChar = NULL; + gettextex.lpUsedDefChar = NULL; + memset(buffer, 0, sizeof(buffer)); + hr = ITextServices_TxSendMessage(txtserv, EM_GETTEXTEX, (WPARAM)&gettextex, (LPARAM)buffer, &result); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(result == lstrlenW(expected_string), "Got wrong length: %ld.\n", result); + ok(!lstrcmpW(buffer, expected_string), "Got wrong content: %s.\n", debugstr_w(buffer)); + + gettextex.flags = GT_RAWTEXT; + memset(buffer, 0, sizeof(buffer)); + hr = ITextServices_TxSendMessage(txtserv, EM_GETTEXTEX, (WPARAM)&gettextex, (LPARAM)buffer, &result); + ok(result == lstrlenW(expected_string), "Got wrong length: %ld.\n", result); + ok(!lstrcmpW(buffer, expected_string), "Got wrong content: %s.\n", debugstr_w(buffer)); + + IOleClientSite_Release(clientsite); + IRichEditOle_Release(reole); + ITextServices_Release(txtserv); + ITextHost_Release(host); +} + START_TEST( txtsrv ) { ITextServices *txtserv; @@ -1250,6 +1305,7 @@ START_TEST( txtsrv ) test_default_format(); test_TxGetScroll(); test_notifications(); + test_TxSendMesssage_gettext(); } if (wrapperCodeMem) VirtualFree(wrapperCodeMem, 0, MEM_RELEASE); }