[PATCH 1/2] riched20: Generalise ME_GetTextW to accept GT_* flags instead of bCRLF.

Jinoh Kang jinoh.kang.kr at gmail.com
Sun Mar 27 10:40:12 CDT 2022


Signed-off-by: Jinoh Kang <jinoh.kang.kr at 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;
-- 
2.34.1




More information about the wine-devel mailing list