Sorry, here is a new version which doesn't totally ignore the lvalue
(gives fixme).

2009/1/2 Arren Lex <arren...@gmail.com>:
> Hello, all;
>
> Attached is a patch that implements the EM_PASTESPECIAL riched20
> message, which pastes with a specified clipboard format --
> http://msdn.microsoft.com/en-us/library/bb774214(VS.85).aspx
>
> Because there is (apparently) no ANSI clipboard implemented, the
> CF_TEXT clipboard format pastes garbage, so I have put in a workaround
> which treats a CF_TEXT as a CF_UNICODETEXT call. It prints a fixme
> when it does this, and when the ANSI clipboard is implemented the "if"
> block can simply be taken out to start using it.
>
> This patch was written to fix bug 14530 --
> http://bugs.winehq.org/show_bug.cgi?id=14530
>
> It is made against git commit bf25837eb7c08dc7faf13b886f6aed79a02506b8
> (the tagging of 1.1.12) which is the latest at the time of writing.
>
> This is my first ever patch, and I am not familiar with wine or
> riched20 at all, so I would love to have some feedback about it before
> I submit it to the patches list. Can anyone suggest improvements?
>
> Thank you,
> - Alexander Dorokhine
>
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;


Reply via email to