Sergio Gómez Del Rea =?UTF-8?Q?l=20?=: riched20: Mask out extended flags introduced by CHARFORMAT2 when converting to CHARFORMAT.

Alexandre Julliard julliard at winehq.org
Wed Feb 6 15:32:28 CST 2019


Module: wine
Branch: master
Commit: 4f007da8d3af4ec3acf573e8aca2fd5b182a378a
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=4f007da8d3af4ec3acf573e8aca2fd5b182a378a

Author: Sergio Gómez Del Real <sdelreal at codeweavers.com>
Date:   Wed Feb  6 08:54:18 2019 +0000

riched20: Mask out extended flags introduced by CHARFORMAT2 when converting to CHARFORMAT.

Signed-off-by: Sergio Gómez Del Real <sdelreal at codeweavers.com>
Signed-off-by: Huw Davies <huw at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/riched20/style.c        |  4 ++++
 dlls/riched20/tests/editor.c | 19 +++++++++++++++++++
 2 files changed, 23 insertions(+)

diff --git a/dlls/riched20/style.c b/dlls/riched20/style.c
index c3f3fc3..3b9d771 100644
--- a/dlls/riched20/style.c
+++ b/dlls/riched20/style.c
@@ -85,6 +85,8 @@ BOOL cf2w_to_cfany(CHARFORMAT2W *to, const CHARFORMAT2W *from)
     CopyMemory(t, from, FIELD_OFFSET(CHARFORMATA, szFaceName));
     WideCharToMultiByte(CP_ACP, 0, from->szFaceName, -1, t->szFaceName, sizeof(t->szFaceName), NULL, NULL);
     t->cbSize = sizeof(*t); /* it was overwritten by CopyMemory */
+    t->dwMask &= CFM_ALL;
+    t->dwEffects &= CFM_EFFECTS;
     return TRUE;
   }
   if (to->cbSize == sizeof(CHARFORMATW))
@@ -92,6 +94,8 @@ BOOL cf2w_to_cfany(CHARFORMAT2W *to, const CHARFORMAT2W *from)
     CHARFORMATW *t = (CHARFORMATW *)to;
     CopyMemory(t, from, sizeof(*t));
     t->cbSize = sizeof(*t); /* it was overwritten by CopyMemory */
+    t->dwMask &= CFM_ALL;
+    t->dwEffects &= CFM_EFFECTS;
     return TRUE;
   }
   if (to->cbSize == sizeof(CHARFORMAT2A))
diff --git a/dlls/riched20/tests/editor.c b/dlls/riched20/tests/editor.c
index 932c8a1..ddb1018 100644
--- a/dlls/riched20/tests/editor.c
+++ b/dlls/riched20/tests/editor.c
@@ -751,6 +751,8 @@ static void test_EM_SETCHARFORMAT(void)
   HWND hwndRichEdit = new_richedit(NULL);
   CHARFORMAT2A cf2;
   CHARFORMAT2W cfW;
+  CHARFORMATA cf1a;
+  CHARFORMATW cf1w;
   int rc = 0;
   int tested_effects[] = {
     CFE_BOLD,
@@ -1338,6 +1340,23 @@ static void test_EM_SETCHARFORMAT(void)
   ok(cf2.dwEffects & CFE_UNDERLINE, "got %08x\n", cf2.dwEffects);
   ok(cf2.bUnderlineType == CFU_UNDERLINEDOUBLE, "got %x\n", cf2.bUnderlineType);
 
+  /* Check setting CFM_ALL2/CFM_EFFECTS2 in CHARFORMAT(A/W). */
+  memset(&cf1a, 0, sizeof(CHARFORMATA));
+  memset(&cf1w, 0, sizeof(CHARFORMATW));
+  cf1a.cbSize = sizeof(CHARFORMATA);
+  cf1w.cbSize = sizeof(CHARFORMATW);
+  cf1a.dwMask = cf1w.dwMask = CFM_ALL2;
+  cf1a.dwEffects = cf1w.dwEffects = CFM_EFFECTS2;
+  SendMessageA(hwndRichEdit, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf1a);
+  SendMessageA(hwndRichEdit, EM_GETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf1a);
+  /* flags only valid for CHARFORMAT2 should be masked out */
+  ok((cf1a.dwMask & (CFM_ALL2 & ~CFM_ALL)) == 0, "flags were not masked out\n");
+  ok((cf1a.dwEffects & (CFM_EFFECTS2 & ~CFM_EFFECTS)) == 0, "flags were not masked out\n");
+  SendMessageA(hwndRichEdit, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf1w);
+  SendMessageA(hwndRichEdit, EM_GETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf1w);
+  ok((cf1w.dwMask & (CFM_ALL2 & ~CFM_ALL)) == 0, "flags were not masked out\n");
+  ok((cf1w.dwEffects & (CFM_EFFECTS2 & ~CFM_EFFECTS)) == 0, "flags were not masked out\n");
+
   DestroyWindow(hwndRichEdit);
 }
 




More information about the wine-cvs mailing list