diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c index b5a69f7..3df5486 100644 --- a/dlls/riched20/editor.c +++ b/dlls/riched20/editor.c @@ -83,7 +83,7 @@ + EM_LINEINDEX + EM_LINELENGTH + EM_LINESCROLL - - EM_PASTESPECIAL + + EM_PASTESPECIAL (partially done -- ANSI treated as unicode with warning) + EM_POSFROMCHAR + EM_REDO 2.0 + EM_REQUESTRESIZE @@ -2046,11 +2046,55 @@ static DWORD CALLBACK ME_ReadFromHGLOBALRTF(DWORD_PTR dwCookie, LPBYTE lpBuff, L return 0; } + +/* Sends data currently stored in the clipboard_format clipboard to the editor */ +static BOOL ME_PasteFormat(ME_TextEditor *editor, UINT clipboard_format, DWORD dwFormat) +{ + ME_GlobalDestStruct gds; + EDITSTREAM es; + + if (!OpenClipboard(editor->hWnd)) + return FALSE; + gds.hData = GetClipboardData(clipboard_format); + gds.nLength = 0; + es.dwCookie = (DWORD_PTR)&gds; + es.pfnCallback = dwFormat == SF_RTF ? ME_ReadFromHGLOBALRTF : ME_ReadFromHGLOBALUnicode; + ME_StreamIn(editor, dwFormat|SFF_SELECTION, &es, FALSE); + + CloseClipboard(); + return TRUE; +} + +/* Implements EM_PASTESPECIAL, which pastes a specific clipboard format (wParam) + to a richedit control. There is no ASCII implementation of this yet. */ +static BOOL ME_PasteSpecial(ME_TextEditor *editor, UINT msg, WPARAM wParam, LPARAM lParam) +{ + REPASTESPECIAL *rps; + + /* FIXME: There is currently no support for ANSI formats such as CF_TEXT. When + implemented, this "if" block should be removed. */ + if (wParam == CF_TEXT) + { + FIXME("EM_PASTESPECIAL: CF_TEXT format not implemented yet! Trying as CF_UNICODETEXT.\n"); + wParam = CF_UNICODETEXT; + } + + /* FIXME: Properly process the lParam */ + rps = (REPASTESPECIAL*)lParam; + if (rps != NULL && rps->dwAspect != 0) + FIXME("EM_PASTESPECIAL: lParam specified but not yet implemented\n"); + + if (!IsClipboardFormatAvailable(wParam)) + return FALSE; + + return ME_PasteFormat(editor, wParam, SF_TEXT|SF_UNICODE); +} + +/* Pastes the contents of the RTF clipboard to the editor. If no RTF clipboard + is available, tries the unicode. */ static BOOL ME_Paste(ME_TextEditor *editor) { DWORD dwFormat = 0; - EDITSTREAM es; - ME_GlobalDestStruct gds; UINT nRTFFormat = RegisterClipboardFormatA("Rich Text Format"); UINT cf = 0; @@ -2061,16 +2105,7 @@ static BOOL ME_Paste(ME_TextEditor *editor) else return FALSE; - if (!OpenClipboard(editor->hWnd)) - return FALSE; - gds.hData = GetClipboardData(cf); - gds.nLength = 0; - es.dwCookie = (DWORD_PTR)&gds; - es.pfnCallback = dwFormat == SF_RTF ? ME_ReadFromHGLOBALRTF : ME_ReadFromHGLOBALUnicode; - ME_StreamIn(editor, dwFormat|SFF_SELECTION, &es, FALSE); - - CloseClipboard(); - return TRUE; + return ME_PasteFormat(editor, cf, dwFormat); } static BOOL ME_Copy(ME_TextEditor *editor, CHARRANGE *range) @@ -2934,7 +2969,6 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam, UNSUPPORTED_MSG(EM_GETTYPOGRAPHYOPTIONS) UNSUPPORTED_MSG(EM_GETUNDONAME) UNSUPPORTED_MSG(EM_GETWORDBREAKPROCEX) - UNSUPPORTED_MSG(EM_PASTESPECIAL) UNSUPPORTED_MSG(EM_SELECTIONTYPE) UNSUPPORTED_MSG(EM_SETBIDIOPTIONS) UNSUPPORTED_MSG(EM_SETEDITSTYLE) @@ -3443,6 +3477,9 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam, return TRUE; return FALSE; } + case EM_PASTESPECIAL: + ME_PasteSpecial(editor, msg, wParam, lParam); + return 0; case WM_PASTE: ME_Paste(editor); return 0;