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.
This commit is contained in:
Alex Villacís Lasso 2008-04-27 13:17:28 -05:00 committed by Alexandre Julliard
parent 1fa39b50c0
commit 3cad256d54
2 changed files with 63 additions and 3 deletions

View File

@ -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);

View File

@ -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"*/