[PATCH 5/6] riched20: Add tomText support for ITextDocument_fnOpen.

Jactry Zeng jactry92 at gmail.com
Tue Feb 11 12:06:22 CST 2014


-------------- next part --------------
From 4befb2b0c45600d39bf30229421365f30f5b4848 Mon Sep 17 00:00:00 2001
From: Jactry Zeng <jactry92 at gmail.com>
Date: Wed, 12 Feb 2014 00:05:01 +0800
Subject: [PATCH 5/6] riched20: Add tomText support for ITextDocument_fnOpen.

---
 dlls/riched20/richole.c | 29 +++++++++++++++++++++++++++--
 1 file changed, 27 insertions(+), 2 deletions(-)

diff --git a/dlls/riched20/richole.c b/dlls/riched20/richole.c
index 725862a..29d3a7b 100644
--- a/dlls/riched20/richole.c
+++ b/dlls/riched20/richole.c
@@ -613,6 +613,16 @@ static DWORD get_open_access_mode(LONG Flags)
     }
 }
 
+static DWORD CALLBACK stream_in(DWORD_PTR hFile, LPBYTE buffer, LONG cb, LONG *pcb)
+{
+  DWORD read;
+  if(!ReadFile((HANDLE)hFile, buffer, cb, &read, 0))
+    return 1;
+
+  *pcb = read;
+  return 0;
+}
+
 static HRESULT WINAPI
 ITextDocument_fnOpen(ITextDocument* me, VARIANT* pVar, LONG Flags,
     LONG CodePage)
@@ -664,7 +674,6 @@ ITextDocument_fnOpen(ITextDocument* me, VARIANT* pVar, LONG Flags,
         return HRESULT_FROM_WIN32(GetLastError());
       }
 
-    CloseHandle(hFile);
     size = dwReadsize;
 
     if(dwReadsize >= 2)
@@ -672,9 +681,25 @@ ITextDocument_fnOpen(ITextDocument* me, VARIANT* pVar, LONG Flags,
         if((BYTE)buf[0] == 0xff && (BYTE)buf[1] == 0xfe)
           settextex.codepage = 1200;
         else if(dwReadsize >= 5 && !memcmp(RTFheader, buf, 5) && ((Flags & 0xf) == tomText))
-          FIXME("Partial stub! Don't support RTF file with tomRTF\n");
+          {
+            EDITSTREAM editstream;
+
+            HeapFree(GetProcessHeap(), 0, buf);
+            SetFilePointer(hFile, 0, NULL, FILE_BEGIN);
+            editstream.dwCookie = (DWORD_PTR)hFile;
+            editstream.pfnCallback = stream_in;
+
+            if((Flags & 0xf000) == tomPasteFile)
+              SendMessageW(This->editor->hWnd, EM_STREAMIN, SF_TEXT|SFF_SELECTION, (LPARAM)&editstream);
+            else
+              SendMessageW(This->editor->hWnd, EM_STREAMIN, SF_TEXT, (LPARAM)&editstream);
+
+            CloseHandle(hFile);
+            return S_OK;
+          }
       }
 
+    CloseHandle(hFile);
     buf[size] = 0;
     buf[size+1] = 0;
 
-- 
1.8.3.2



More information about the wine-patches mailing list