[prev in list] [next in list] [prev in thread] [next in thread] 

List:       wine-devel
Subject:    [PATCH] riched20: Mask out extended flags introduced by CHARFORMAT2 when converting to CHARFORMAT.
From:       Sergio Gómez Del Real <sdelreal () codeweavers ! com>
Date:       2019-01-31 16:09:16
Message-ID: 20190131160916.24014-1-sdelreal () codeweavers ! com
[Download RAW message or body]

Signed-off-by: Sergio Gómez Del Real <sdelreal@codeweavers.com>
---
 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 c3f3fc3f9a..3b9d7717eb 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 932c8a1d32..9349629601 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);
 
+  /* Wine converts between CHARFORMAT(A/W) and CHARFORMAT2W internally. Test that. \
*/ +  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);
 }
 
-- 
2.17.1


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic