From a382e356001b9fac1b223fdd126f4909a3cc6215 Mon Sep 17 00:00:00 2001 From: Dylan Smith Date: Tue, 12 Aug 2008 23:15:15 -0400 Subject: [PATCH] richedit: EM_[SG]ETPARAFORMAT returned the wrong value. The values returned by EM_SETPARAFORMAT and EM_GETPARAFORMAT previously indicated an error, and the included tests shows that Windows behaves as documented. --- dlls/riched20/editor.c | 8 +++++--- dlls/riched20/editor.h | 4 ++-- dlls/riched20/para.c | 8 ++++++-- dlls/riched20/tests/editor.c | 22 ++++++++++++++++++++++ 4 files changed, 35 insertions(+), 7 deletions(-) diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c index 44af5a40d73..8c235a8e734 100644 --- a/dlls/riched20/editor.c +++ b/dlls/riched20/editor.c @@ -2728,13 +2728,15 @@ static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam, return tmp.dwMask; } case EM_SETPARAFORMAT: - ME_SetSelectionParaFormat(editor, (PARAFORMAT2 *)lParam); + { + BOOL result = ME_SetSelectionParaFormat(editor, (PARAFORMAT2 *)lParam); ME_RewrapRepaint(editor); ME_CommitUndo(editor); - return 0; + return result; + } case EM_GETPARAFORMAT: ME_GetSelectionParaFormat(editor, (PARAFORMAT2 *)lParam); - return 0; + return ((PARAFORMAT2 *)lParam)->dwMask; case EM_GETFIRSTVISIBLELINE: { ME_DisplayItem *p = editor->pBuffer->pFirst; diff --git a/dlls/riched20/editor.h b/dlls/riched20/editor.h index 85dbd180e56..b123a2d287a 100644 --- a/dlls/riched20/editor.h +++ b/dlls/riched20/editor.h @@ -222,8 +222,8 @@ ME_DisplayItem *ME_JoinParagraphs(ME_TextEditor *editor, ME_DisplayItem *tp, BOOL keepFirstParaFormat); void ME_DumpParaStyle(ME_Paragraph *s); void ME_DumpParaStyleToBuf(const PARAFORMAT2 *pFmt, char buf[2048]); -void ME_SetParaFormat(ME_TextEditor *editor, ME_DisplayItem *para, const PARAFORMAT2 *pFmt); -void ME_SetSelectionParaFormat(ME_TextEditor *editor, const PARAFORMAT2 *pFmt); +BOOL ME_SetParaFormat(ME_TextEditor *editor, ME_DisplayItem *para, const PARAFORMAT2 *pFmt); +BOOL ME_SetSelectionParaFormat(ME_TextEditor *editor, const PARAFORMAT2 *pFmt); void ME_GetParaFormat(ME_TextEditor *editor, const ME_DisplayItem *para, PARAFORMAT2 *pFmt); void ME_GetSelectionParaFormat(ME_TextEditor *editor, PARAFORMAT2 *pFmt); /* marks from first up to (but not including) last */ diff --git a/dlls/riched20/para.c b/dlls/riched20/para.c index 3c20ee15987..b8676d147e5 100644 --- a/dlls/riched20/para.c +++ b/dlls/riched20/para.c @@ -430,7 +430,7 @@ void ME_DumpParaStyleToBuf(const PARAFORMAT2 *pFmt, char buf[2048]) #undef DUMP_EFFECT } -void ME_SetParaFormat(ME_TextEditor *editor, ME_DisplayItem *para, const PARAFORMAT2 *pFmt) +BOOL ME_SetParaFormat(ME_TextEditor *editor, ME_DisplayItem *para, const PARAFORMAT2 *pFmt) { PARAFORMAT2 copy; assert(sizeof(*para->member.para.pFmt) == sizeof(PARAFORMAT2)); @@ -487,6 +487,8 @@ void ME_SetParaFormat(ME_TextEditor *editor, ME_DisplayItem *para, const PARAFOR if (memcmp(©, para->member.para.pFmt, sizeof(PARAFORMAT2))) para->member.para.nFlags |= MEPF_REWRAP; + + return TRUE; } @@ -514,7 +516,7 @@ ME_GetSelectionParas(ME_TextEditor *editor, ME_DisplayItem **para, ME_DisplayIte } -void ME_SetSelectionParaFormat(ME_TextEditor *editor, const PARAFORMAT2 *pFmt) +BOOL ME_SetSelectionParaFormat(ME_TextEditor *editor, const PARAFORMAT2 *pFmt) { ME_DisplayItem *para, *para_end; @@ -526,6 +528,8 @@ void ME_SetSelectionParaFormat(ME_TextEditor *editor, const PARAFORMAT2 *pFmt) break; para = para->member.para.next_para; } while(1); + + return TRUE; } void ME_GetParaFormat(ME_TextEditor *editor, const ME_DisplayItem *para, PARAFORMAT2 *pFmt) diff --git a/dlls/riched20/tests/editor.c b/dlls/riched20/tests/editor.c index 15cef753388..765e8e27d3f 100644 --- a/dlls/riched20/tests/editor.c +++ b/dlls/riched20/tests/editor.c @@ -1087,6 +1087,27 @@ static void test_EM_SETTEXTMODE(void) DestroyWindow(hwndRichEdit); } +static void test_SETPARAFORMAT(void) +{ + HWND hwndRichEdit = new_richedit(NULL); + PARAFORMAT2 fmt; + HRESULT ret; + fmt.cbSize = sizeof(PARAFORMAT2); + fmt.dwMask = PFM_ALIGNMENT; + fmt.wAlignment = PFA_LEFT; + + ret = SendMessage(hwndRichEdit, EM_SETPARAFORMAT, 0, (LPARAM) &fmt); + ok(ret != 0, "expected non-zero got %d\n", ret); + + fmt.cbSize = sizeof(PARAFORMAT2); + fmt.dwMask = -1; + ret = SendMessage(hwndRichEdit, EM_GETPARAFORMAT, 0, (LPARAM) &fmt); + ok(ret == PFM_ALL2, "expected %x got %x\n", PFM_ALL2, ret); + ok(fmt.dwMask == PFM_ALL2, "expected %x got %x\n", PFM_ALL2, fmt.dwMask); + + DestroyWindow(hwndRichEdit); +} + static void test_TM_PLAINTEXT(void) { /*Tests plain text properties*/ @@ -5396,6 +5417,7 @@ START_TEST( editor ) test_undo_coalescing(); test_word_movement(); test_EM_CHARFROMPOS(); + test_SETPARAFORMAT(); /* Set the environment variable WINETEST_RICHED20 to keep windows * responsive and open for 30 seconds. This is useful for debugging.