richedit: Cannot undo setting of default character format.

This also reverts commit 2b52dd8450:
wordpad: Empty the richedit undo buffer on creation.

The reverted commit I created to fix an issue that only applied to Wine,
but it just masked the issue which was in richedit controls.  The
default character format was set in two places while wordpad was
starting up, and caused wordpad to have two undo items at startup.
This commit is contained in:
Dylan Smith 2008-07-11 20:06:05 -04:00 committed by Alexandre Julliard
parent 43ad427a15
commit e3efa88c45
6 changed files with 3 additions and 21 deletions

View file

@ -86,8 +86,7 @@ typedef enum {
diUndoSetParagraphFormat, /* 15 */
diUndoSetCharFormat, /* 16 */
diUndoEndTransaction, /* 17 - marks the end of a group of changes for undo */
diUndoSetDefaultCharFormat, /* 18 */
diUndoPotentialEndTransaction, /* 19 - allows grouping typed chars for undo */
diUndoPotentialEndTransaction, /* 18 - allows grouping typed chars for undo */
} ME_DIType;
#define SELECTIONBAR_WIDTH 9

View file

@ -119,7 +119,7 @@ void ME_DestroyDisplayItem(ME_DisplayItem *item) {
ME_ReleaseStyle(item->member.run.style);
ME_DestroyString(item->member.run.strText);
}
if (item->type==diUndoSetCharFormat || item->type==diUndoSetDefaultCharFormat) {
if (item->type==diUndoSetCharFormat) {
ME_ReleaseStyle(item->member.ustyle);
}
if (item->type==diUndoSplitParagraph)
@ -175,7 +175,6 @@ const char *ME_GetDITypeName(ME_DIType type)
case diUndoDeleteRun: return "diUndoDeleteRun";
case diUndoJoinParagraphs: return "diJoinParagraphs";
case diUndoSplitParagraph: return "diSplitParagraph";
case diUndoSetDefaultCharFormat: return "diUndoSetDefaultCharFormat";
default: return "?";
}
}

View file

@ -832,17 +832,8 @@ void ME_SetCharFormat(ME_TextEditor *editor, int nOfs, int nChars, CHARFORMAT2W
void ME_SetDefaultCharFormat(ME_TextEditor *editor, CHARFORMAT2W *mod)
{
ME_Style *style;
ME_UndoItem *undo;
/* FIXME: Should this be removed? It breaks a test. */
assert(mod->cbSize == sizeof(CHARFORMAT2W));
undo = ME_AddUndoItem(editor, diUndoSetDefaultCharFormat, NULL);
if (undo) {
undo->nStart = -1;
undo->nLen = -1;
undo->di.member.ustyle = editor->pBuffer->pDefaultStyle;
ME_AddRefStyle(undo->di.member.ustyle);
}
style = ME_ApplyStyle(editor->pBuffer->pDefaultStyle, mod);
editor->pBuffer->pDefaultStyle->fmt = style->fmt;
editor->pBuffer->pDefaultStyle->tm = style->tm;

View file

@ -614,7 +614,7 @@ static void test_EM_SETCHARFORMAT(void)
(LPARAM) &cf2);
ok(rc == 1, "EM_SETCHARFORMAT returned %d instead of 1\n", rc);
rc = SendMessage(hwndRichEdit, EM_CANUNDO, 0, 0);
todo_wine ok(rc == FALSE, "Should not be able to undo here.\n");
ok(rc == FALSE, "Should not be able to undo here.\n");
SendMessage(hwndRichEdit, EM_EMPTYUNDOBUFFER, 0, 0);
/* A valid flag, CHARFORMAT2 structure minimally filled */

View file

@ -84,7 +84,6 @@ ME_UndoItem *ME_AddUndoItem(ME_TextEditor *editor, ME_DIType type, const ME_Disp
else pItem->member.run.ole_obj = NULL;
break;
case diUndoSetCharFormat:
case diUndoSetDefaultCharFormat:
break;
case diUndoDeleteRun:
case diUndoJoinParagraphs:
@ -292,11 +291,6 @@ static void ME_PlayUndoItem(ME_TextEditor *editor, ME_DisplayItem *pItem)
ME_SetCharFormat(editor, pUItem->nStart, pUItem->nLen, &pItem->member.ustyle->fmt);
break;
}
case diUndoSetDefaultCharFormat:
{
ME_SetDefaultCharFormat(editor, &pItem->member.ustyle->fmt);
break;
}
case diUndoInsertRun:
{
ME_InsertRun(editor, pItem->member.run.nCharOfs, pItem);

View file

@ -2532,7 +2532,6 @@ int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hOldInstance, LPSTR szCmdPar
set_caption(NULL);
set_bar_states();
set_fileformat(SF_RTF);
SendMessageW(hEditorWnd, EM_EMPTYUNDOBUFFER, 0, 0);
hPopupMenu = LoadMenuW(hInstance, MAKEINTRESOURCEW(IDM_POPUP));
get_default_printer_opts();
target_device(hMainWnd, wordWrap[reg_formatindex(fileFormat)]);