From e3efa88c456890308c08d29a1ecca3409789e653 Mon Sep 17 00:00:00 2001 From: Dylan Smith Date: Fri, 11 Jul 2008 20:06:05 -0400 Subject: [PATCH] richedit: Cannot undo setting of default character format. This also reverts commit 2b52dd845097f16076c0185b02a003f63898dcab: 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. --- dlls/riched20/editstr.h | 3 +-- dlls/riched20/list.c | 3 +-- dlls/riched20/run.c | 9 --------- dlls/riched20/tests/editor.c | 2 +- dlls/riched20/undo.c | 6 ------ programs/wordpad/wordpad.c | 1 - 6 files changed, 3 insertions(+), 21 deletions(-) diff --git a/dlls/riched20/editstr.h b/dlls/riched20/editstr.h index f3e837ef549..81f4cc38ba3 100644 --- a/dlls/riched20/editstr.h +++ b/dlls/riched20/editstr.h @@ -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 diff --git a/dlls/riched20/list.c b/dlls/riched20/list.c index 60c49e3aa37..0b14aec0d69 100644 --- a/dlls/riched20/list.c +++ b/dlls/riched20/list.c @@ -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 "?"; } } diff --git a/dlls/riched20/run.c b/dlls/riched20/run.c index 00285365976..19ebf1b7cfd 100644 --- a/dlls/riched20/run.c +++ b/dlls/riched20/run.c @@ -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; diff --git a/dlls/riched20/tests/editor.c b/dlls/riched20/tests/editor.c index 6c8756c8d08..8d22e85e10b 100644 --- a/dlls/riched20/tests/editor.c +++ b/dlls/riched20/tests/editor.c @@ -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 */ diff --git a/dlls/riched20/undo.c b/dlls/riched20/undo.c index bf992ab20f7..eaf1791ed48 100644 --- a/dlls/riched20/undo.c +++ b/dlls/riched20/undo.c @@ -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); diff --git a/programs/wordpad/wordpad.c b/programs/wordpad/wordpad.c index 80638c81b09..6f3e41aa989 100644 --- a/programs/wordpad/wordpad.c +++ b/programs/wordpad/wordpad.c @@ -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)]);