Alex Villacís Lasso : riched20: Implement ignoring of last \par for EM_STREAMIN.
Alexandre Julliard
julliard at winehq.org
Thu Apr 24 15:56:36 CDT 2008
Module: wine
Branch: master
Commit: 7148f92c4c2891373dc2f9512151a01180e09bbd
URL: http://source.winehq.org/git/wine.git/?a=commit;h=7148f92c4c2891373dc2f9512151a01180e09bbd
Author: Alex Villacís Lasso <a_villacis at palosanto.com>
Date: Thu Apr 24 10:00:29 2008 -0500
riched20: Implement ignoring of last \par for EM_STREAMIN.
---
dlls/riched20/editor.c | 22 ++++++++++++++++++----
dlls/riched20/tests/editor.c | 12 ------------
2 files changed, 18 insertions(+), 16 deletions(-)
diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c
index c5a7554..97fce4a 100644
--- a/dlls/riched20/editor.c
+++ b/dlls/riched20/editor.c
@@ -1022,7 +1022,7 @@ ME_StreamInFill(ME_InStream *stream)
stream->dwUsed = 0;
}
-static LRESULT ME_StreamIn(ME_TextEditor *editor, DWORD format, EDITSTREAM *stream)
+static LRESULT ME_StreamIn(ME_TextEditor *editor, DWORD format, EDITSTREAM *stream, BOOL stripLastCR)
{
RTF_Info parser;
ME_Style *style;
@@ -1101,6 +1101,20 @@ static LRESULT ME_StreamIn(ME_TextEditor *editor, DWORD format, EDITSTREAM *stre
if (parser.lpRichEditOle)
IRichEditOle_Release(parser.lpRichEditOle);
+ /* Remove last line break, as mandated by tests */
+ if (stripLastCR) {
+ int newfrom, newto;
+ ME_GetSelection(editor, &newfrom, &newto);
+ if (newto > to) {
+ WCHAR lastchar = '\0';
+
+ ME_GetTextW(editor, &lastchar, newto - 1, 1, 0);
+ if (lastchar == '\r') {
+ ME_InternalDeleteText(editor, newto - 1, 1);
+ }
+ }
+ }
+
style = parser.style;
}
else if (format & SF_TEXT)
@@ -1170,7 +1184,7 @@ ME_StreamInRTFString(ME_TextEditor *editor, BOOL selection, char *string)
data.pos = 0;
es.dwCookie = (DWORD)&data;
es.pfnCallback = ME_ReadFromRTFString;
- ME_StreamIn(editor, SF_RTF | (selection ? SFF_SELECTION : 0), &es);
+ ME_StreamIn(editor, SF_RTF | (selection ? SFF_SELECTION : 0), &es, FALSE);
}
@@ -1923,7 +1937,7 @@ static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam,
/* Messages specific to Richedit controls */
case EM_STREAMIN:
- return ME_StreamIn(editor, wParam, (EDITSTREAM*)lParam);
+ return ME_StreamIn(editor, wParam, (EDITSTREAM*)lParam, TRUE);
case EM_STREAMOUT:
return ME_StreamOut(editor, wParam, (EDITSTREAM *)lParam);
case WM_GETDLGCODE:
@@ -2435,7 +2449,7 @@ static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam,
gds.nLength = 0;
es.dwCookie = (DWORD)&gds;
es.pfnCallback = dwFormat == SF_RTF ? ME_ReadFromHGLOBALRTF : ME_ReadFromHGLOBALUnicode;
- ME_StreamIn(editor, dwFormat|SFF_SELECTION, &es);
+ ME_StreamIn(editor, dwFormat|SFF_SELECTION, &es, FALSE);
CloseClipboard();
return 0;
diff --git a/dlls/riched20/tests/editor.c b/dlls/riched20/tests/editor.c
index b6e9176..1593d09 100644
--- a/dlls/riched20/tests/editor.c
+++ b/dlls/riched20/tests/editor.c
@@ -2377,15 +2377,11 @@ static void test_EM_STREAMIN(void)
(WPARAM)(SF_RTF), (LPARAM)&es);
result = SendMessage(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM) buffer);
- todo_wine {
ok (result == 12,
"EM_STREAMIN: Test 0-a returned %ld, expected 12\n", result);
- }
result = strcmp (buffer,"TestSomeText");
- todo_wine {
ok (result == 0,
"EM_STREAMIN: Test 0-a set wrong text: Result: %s\n",buffer);
- }
/* Native richedit 2.0 ignores last \par, next-to-last \par appears */
es.dwCookie = (DWORD_PTR)&streamText0b;
@@ -2395,15 +2391,11 @@ static void test_EM_STREAMIN(void)
(WPARAM)(SF_RTF), (LPARAM)&es);
result = SendMessage(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM) buffer);
- todo_wine {
ok (result == 14,
"EM_STREAMIN: Test 0-b returned %ld, expected 14\n", result);
- }
result = strcmp (buffer,"TestSomeText\r\n");
- todo_wine {
ok (result == 0,
"EM_STREAMIN: Test 0-b set wrong text: Result: %s\n",buffer);
- }
es.dwCookie = (DWORD_PTR)&streamText1;
es.dwError = 0;
@@ -2412,15 +2404,11 @@ static void test_EM_STREAMIN(void)
(WPARAM)(SF_RTF), (LPARAM)&es);
result = SendMessage(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM) buffer);
- todo_wine {
ok (result == 12,
"EM_STREAMIN: Test 1 returned %ld, expected 12\n", result);
- }
result = strcmp (buffer,"TestSomeText");
- todo_wine {
ok (result == 0,
"EM_STREAMIN: Test 1 set wrong text: Result: %s\n",buffer);
- }
es.dwCookie = (DWORD_PTR)&streamText2;
SendMessage(hwndRichEdit, EM_STREAMIN,
More information about the wine-cvs
mailing list