Alex Villacís Lasso : richedit: Fix modify step setting in EM_SETCHARFORMAT.

Alexandre Julliard julliard at winehq.org
Tue Apr 29 08:54:47 CDT 2008


Module: wine
Branch: master
Commit: 3cad256d54eb7071a3693102ee683bdbbd087227
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=3cad256d54eb7071a3693102ee683bdbbd087227

Author: Alex Villacís Lasso <a_villacis at palosanto.com>
Date:   Sun Apr 27 13:17:28 2008 -0500

richedit: Fix modify step setting in EM_SETCHARFORMAT.

EM_SETCHARFORMAT with wParam==0 sets default char format and does NOT set modify step flag.
EM_SETCHARFORMAT with wParam==SCF_SELECTION only sets modify step flag when selection is nonempty.
EM_GETMODIFY returns -1, not 1, when modify flag is set.
Tests for the above behavior.

---

 dlls/riched20/editor.c       |    8 +++--
 dlls/riched20/tests/editor.c |   58 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 63 insertions(+), 3 deletions(-)

diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c
index 660942f..84c8d36 100644
--- a/dlls/riched20/editor.c
+++ b/dlls/riched20/editor.c
@@ -2206,7 +2206,7 @@ static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam,
     return lColor;
   }
   case EM_GETMODIFY:
-    return editor->nModifyStep == 0 ? 0 : 1;
+    return editor->nModifyStep == 0 ? 0 : -1;
   case EM_SETMODIFY:
   {
     if (wParam)
@@ -2249,8 +2249,10 @@ static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam,
     } else if (wParam == SCF_ALL) {
       if (editor->mode & TM_PLAINTEXT)
         ME_SetDefaultCharFormat(editor, p);
-      else
+      else {
         ME_SetCharFormat(editor, 0, ME_GetTextLength(editor), p);
+        editor->nModifyStep = 1;
+      }
     } else if (editor->mode & TM_PLAINTEXT) {
       return 0;
     } else {
@@ -2258,8 +2260,8 @@ static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam,
       ME_GetSelection(editor, &from, &to);
       bRepaint = (from != to);
       ME_SetSelectionCharFormat(editor, p);
+      if (from != to) editor->nModifyStep = 1;
     }
-    editor->nModifyStep = 1;
     ME_CommitUndo(editor);
     if (bRepaint)
       ME_RewrapRepaint(editor);
diff --git a/dlls/riched20/tests/editor.c b/dlls/riched20/tests/editor.c
index b365965..05db7f8 100644
--- a/dlls/riched20/tests/editor.c
+++ b/dlls/riched20/tests/editor.c
@@ -438,6 +438,57 @@ static void test_EM_SETCHARFORMAT(void)
              (LPARAM) &cf2);
   ok(rc == 1, "EM_SETCHARFORMAT returned %d instead of 1\n", rc);
 
+  cf2.cbSize = sizeof(CHARFORMAT2);
+  SendMessage(hwndRichEdit, EM_GETCHARFORMAT, (WPARAM) SCF_DEFAULT,
+             (LPARAM) &cf2);
+
+  /* Test state of modify flag before and after valid EM_SETCHARFORMAT */
+  cf2.cbSize = sizeof(CHARFORMAT2);
+  SendMessage(hwndRichEdit, EM_GETCHARFORMAT, (WPARAM) SCF_DEFAULT,
+             (LPARAM) &cf2);
+  cf2.dwMask = CFM_ITALIC | cf2.dwMask;
+  cf2.dwEffects = CFE_ITALIC ^ cf2.dwEffects;
+
+  /* wParam==0 is default char format, does not set modify */
+  SendMessage(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)NULL);
+  rc = SendMessage(hwndRichEdit, EM_GETMODIFY, 0, 0);
+  ok(rc == 0, "Text marked as modified, expected not modified!\n");
+  rc = SendMessage(hwndRichEdit, EM_SETCHARFORMAT, 0, (LPARAM) &cf2);
+  ok(rc == 1, "EM_SETCHARFORMAT returned %d instead of 1\n", rc);
+  rc = SendMessage(hwndRichEdit, EM_GETMODIFY, 0, 0);
+  ok(rc == 0, "Text marked as modified, expected not modified!\n");
+
+  /* wParam==SCF_SELECTION sets modify if nonempty selection */
+  SendMessage(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)NULL);
+  rc = SendMessage(hwndRichEdit, EM_GETMODIFY, 0, 0);
+  ok(rc == 0, "Text marked as modified, expected not modified!\n");
+  rc = SendMessage(hwndRichEdit, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM) &cf2);
+  ok(rc == 1, "EM_SETCHARFORMAT returned %d instead of 1\n", rc);
+  rc = SendMessage(hwndRichEdit, EM_GETMODIFY, 0, 0);
+  ok(rc == 0, "Text marked as modified, expected not modified!\n");
+
+  SendMessage(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)"wine");
+  rc = SendMessage(hwndRichEdit, EM_GETMODIFY, 0, 0);
+  ok(rc == 0, "Text marked as modified, expected not modified!\n");
+  rc = SendMessage(hwndRichEdit, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM) &cf2);
+  ok(rc == 1, "EM_SETCHARFORMAT returned %d instead of 1\n", rc);
+  rc = SendMessage(hwndRichEdit, EM_GETMODIFY, 0, 0);
+  ok(rc == 0, "Text marked as modified, expected not modified!\n");
+  SendMessage(hwndRichEdit, EM_SETSEL, 0, 2);
+  rc = SendMessage(hwndRichEdit, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM) &cf2);
+  ok(rc == 1, "EM_SETCHARFORMAT returned %d instead of 1\n", rc);
+  rc = SendMessage(hwndRichEdit, EM_GETMODIFY, 0, 0);
+  ok(rc == -1, "Text not marked as modified, expected modified! (%d)\n", rc);
+
+  /* wParam==SCF_ALL sets modify regardless of whether text is present */
+  SendMessage(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)NULL);
+  rc = SendMessage(hwndRichEdit, EM_GETMODIFY, 0, 0);
+  ok(rc == 0, "Text marked as modified, expected not modified!\n");
+  rc = SendMessage(hwndRichEdit, EM_SETCHARFORMAT, (WPARAM) SCF_ALL, (LPARAM) &cf2);
+  ok(rc == 1, "EM_SETCHARFORMAT returned %d instead of 1\n", rc);
+  rc = SendMessage(hwndRichEdit, EM_GETMODIFY, 0, 0);
+  ok(rc == -1, "Text not marked as modified, expected modified! (%d)\n", rc);
+
   DestroyWindow(hwndRichEdit);
 }
 
@@ -472,10 +523,17 @@ static void test_EM_SETTEXTMODE(void)
   cf2.dwMask = CFM_ITALIC | cf2.dwMask;
   cf2.dwEffects = CFE_ITALIC ^ cf2.dwEffects;
 
+  rc = SendMessage(hwndRichEdit, EM_GETMODIFY, 0, 0);
+  ok(rc == 0, "Text marked as modified, expected not modified!\n");
+
   /*EM_SETCHARFORMAT is not yet fully implemented for all WPARAMs in wine;
   however, SCF_ALL has been implemented*/
   rc = SendMessage(hwndRichEdit, EM_SETCHARFORMAT, (WPARAM) SCF_ALL, (LPARAM) &cf2);
   ok(rc == 1, "EM_SETCHARFORMAT returned %d instead of 1\n", rc);
+
+  rc = SendMessage(hwndRichEdit, EM_GETMODIFY, 0, 0);
+  ok(rc == -1, "Text not marked as modified, expected modified! (%d)\n", rc);
+
   SendMessage(hwndRichEdit, WM_SETTEXT, 0, (LPARAM) "wine");
 
   /*Select the string "wine"*/




More information about the wine-cvs mailing list