[PATCH 4/5] riched20: Set the format of the final eop to be that of the last char.
Huw Davies
huw at codeweavers.com
Wed Oct 5 04:08:27 CDT 2016
Signed-off-by: Huw Davies <huw at codeweavers.com>
---
dlls/riched20/editor.c | 12 +++++++++++-
dlls/riched20/tests/editor.c | 38 ++++++++++++++++++++++++++++++++++++++
2 files changed, 49 insertions(+), 1 deletion(-)
diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c
index 78cb50c..d7abaa2 100644
--- a/dlls/riched20/editor.c
+++ b/dlls/riched20/editor.c
@@ -1648,7 +1648,17 @@ static LRESULT ME_StreamIn(ME_TextEditor *editor, DWORD format, EDITSTREAM *stre
if (newto > to + (editor->bEmulateVersion10 ? 1 : 0)) {
WCHAR lastchar[3] = {'\0', '\0'};
int linebreakSize = editor->bEmulateVersion10 ? 2 : 1;
- ME_Cursor linebreakCursor = *selEnd;
+ ME_Cursor linebreakCursor = *selEnd, lastcharCursor = *selEnd;
+ CHARFORMAT2W cf;
+
+ /* Set the final eop to the char fmt of the last char */
+ cf.cbSize = sizeof(cf);
+ cf.dwMask = CFM_ALL2;
+ ME_MoveCursorChars(editor, &lastcharCursor, -1, FALSE);
+ ME_GetCharFormat(editor, &lastcharCursor, &linebreakCursor, &cf);
+ ME_SetSelection(editor, newto, -1);
+ ME_SetSelectionCharFormat(editor, &cf);
+ ME_SetSelection(editor, newto, newto);
ME_MoveCursorChars(editor, &linebreakCursor, -linebreakSize, FALSE);
ME_GetTextW(editor, lastchar, 2, &linebreakCursor, linebreakSize, FALSE, FALSE);
diff --git a/dlls/riched20/tests/editor.c b/dlls/riched20/tests/editor.c
index 218e20e..486291f 100644
--- a/dlls/riched20/tests/editor.c
+++ b/dlls/riched20/tests/editor.c
@@ -8372,6 +8372,43 @@ static void test_background(void)
DestroyWindow(hwndRichEdit);
}
+static void test_eop_char_fmt(void)
+{
+ HWND edit = new_richedit( NULL );
+ const char *rtf = "{\\rtf1{\\fonttbl{\\f0\\fswiss\\fprq2\\fcharset0 Arial;}{\\f1\\fnil\\fcharset2 Symbol;}}"
+ "{\\fs10{\\pard\\fs16\\fi200\\li360\\f0 First\\par"
+ "\\f0\\fs25 Second\\par"
+ "{\\f0\\fs26 Third}\\par"
+ "{\\f0\\fs22 Fourth}\\par}}}";
+ EDITSTREAM es;
+ LRESULT result;
+ CHARFORMAT2W cf;
+ int i, num, expect_height;
+
+ es.dwCookie = (DWORD_PTR)&rtf;
+ es.dwError = 0;
+ es.pfnCallback = test_EM_STREAMIN_esCallback;
+ num = SendMessageA( edit, EM_STREAMIN, SF_RTF, (LPARAM)&es );
+ ok( num == 25, "got %d\n", num );
+
+ for (i = 0; i <= num; i++)
+ {
+ SendMessageW( edit, EM_SETSEL, i, i + 1 );
+ cf.cbSize = sizeof(cf);
+ cf.dwMask = CFM_SIZE;
+ result = SendMessageW( edit, EM_GETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf );
+ ok( cf.dwMask & CFM_SIZE, "%d: got %08x\n", i, cf.dwMask );
+ if (i < 6) expect_height = 160;
+ else if (i < 13) expect_height = 250;
+ else if (i < 18) expect_height = 260;
+ else if (i == 18 || i == 25) expect_height = 250;
+ else expect_height = 220;
+ ok( cf.yHeight == expect_height, "%d: got %d\n", i, cf.yHeight );
+ }
+
+ DestroyWindow( edit );
+}
+
START_TEST( editor )
{
BOOL ret;
@@ -8443,6 +8480,7 @@ START_TEST( editor )
test_alignment_style();
test_rtf_specials();
test_background();
+ test_eop_char_fmt();
/* Set the environment variable WINETEST_RICHED20 to keep windows
* responsive and open for 30 seconds. This is useful for debugging.
--
2.8.2
More information about the wine-patches
mailing list