richedit: Use RTF reader for text starting with {\urtf.

This commit is contained in:
Dylan Smith 2008-10-03 04:08:34 -04:00 committed by Alexandre Julliard
parent 44be6c7cbf
commit bdf181b4d3
2 changed files with 28 additions and 4 deletions

View File

@ -2741,7 +2741,8 @@ static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam,
ME_GetSelection(editor, &from, &to);
style = ME_GetSelectionInsertStyle(editor);
ME_InternalDeleteText(editor, from, to - from, FALSE);
if (pStruct->codepage != 1200 && lParam && !strncmp((char *)lParam, "{\\rtf", 5))
if (pStruct->codepage != 1200 && lParam &&
(!strncmp((char *)lParam, "{\\rtf", 5) || !strncmp((char *)lParam, "{\\urtf}", 6)))
ME_StreamInRTFString(editor, 1, (char *)lParam);
else ME_InsertTextFromCursor(editor, 0, wszText, len, style);
ME_ReleaseStyle(style);
@ -2750,7 +2751,8 @@ static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam,
}
else {
ME_InternalDeleteText(editor, 0, ME_GetTextLength(editor), FALSE);
if (pStruct->codepage != 1200 && lParam && !strncmp((char *)lParam, "{\\rtf", 5))
if (pStruct->codepage != 1200 && lParam &&
(!strncmp((char *)lParam, "{\\rtf", 5) || !strncmp((char *)lParam, "{\\urtf}", 6)))
ME_StreamInRTFString(editor, 0, (char *)lParam);
else ME_InsertTextFromCursor(editor, 0, wszText, len, editor->pBuffer->pDefaultStyle);
len = 1;

View File

@ -3522,6 +3522,28 @@ static void test_EM_SETTEXTEX(void)
"EM_GETTEXTEX results not what was set by EM_SETTEXTEX when"
" using ST_SELECTION and non-Unicode\n");
/* Test setting text using rich text format */
setText.flags = 0;
setText.codepage = CP_ACP;
SendMessage(hwndRichEdit, EM_SETTEXTEX, (WPARAM)&setText, (LPARAM)"{\\rtf richtext}");
getText.codepage = CP_ACP;
getText.cb = MAX_BUF_LEN;
getText.flags = GT_DEFAULT;
getText.lpDefaultChar = NULL;
getText.lpUsedDefChar = NULL;
SendMessage(hwndRichEdit, EM_GETTEXTEX, (WPARAM)&getText, (LPARAM) bufACP);
ok(!strcmp(bufACP, "richtext"), "expected 'richtext' but got '%s'\n", bufACP);
setText.flags = 0;
setText.codepage = CP_ACP;
SendMessage(hwndRichEdit, EM_SETTEXTEX, (WPARAM)&setText, (LPARAM)"{\\urtf morerichtext}");
getText.codepage = CP_ACP;
getText.cb = MAX_BUF_LEN;
getText.flags = GT_DEFAULT;
getText.lpDefaultChar = NULL;
getText.lpUsedDefChar = NULL;
SendMessage(hwndRichEdit, EM_GETTEXTEX, (WPARAM)&getText, (LPARAM) bufACP);
ok(!strcmp(bufACP, "morerichtext"), "expected 'morerichtext' but got '%s'\n", bufACP);
DestroyWindow(hwndRichEdit);
}