Commit 4f007da8 authored by Sergio Gómez Del Real's avatar Sergio Gómez Del Real Committed by Alexandre Julliard

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

parent 6fb00db5
......@@ -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))
......
......@@ -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);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment