Dylan Smith : richedit: EM_[SG]ETPARAFORMAT returned the wrong value.
Alexandre Julliard
julliard at winehq.org
Mon Aug 18 10:47:05 CDT 2008
Module: wine
Branch: master
Commit: a382e356001b9fac1b223fdd126f4909a3cc6215
URL: http://source.winehq.org/git/wine.git/?a=commit;h=a382e356001b9fac1b223fdd126f4909a3cc6215
Author: Dylan Smith <dylan.ah.smith at gmail.com>
Date: Tue Aug 12 23:15:15 2008 -0400
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 44af5a4..8c235a8 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 85dbd18..b123a2d 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 3c20ee1..b8676d1 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 15cef75..765e8e2 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.
More information about the wine-cvs
mailing list