Commit 7148f92c authored by Alex Villacís Lasso's avatar Alex Villacís Lasso Committed by Alexandre Julliard

riched20: Implement ignoring of last \par for EM_STREAMIN.

parent 663bfb77
......@@ -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;
......
......@@ -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,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment