[5/5] richedit: Implemented ITextServices TxGetText and TxSetText.

Dylan Smith dylan.ah.smith at gmail.com
Tue Jan 20 00:41:44 CST 2009


---
 dlls/riched20/Makefile.in    |    2 +-
 dlls/riched20/tests/txtsrv.c |   12 ++++++------
 dlls/riched20/txtsrv.c       |   32 ++++++++++++++++++++++++++++----
 3 files changed, 35 insertions(+), 11 deletions(-)
-------------- next part --------------
diff --git a/dlls/riched20/Makefile.in b/dlls/riched20/Makefile.in
index 7f85120..d56137e 100644
--- a/dlls/riched20/Makefile.in
+++ b/dlls/riched20/Makefile.in
@@ -4,7 +4,7 @@ SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = riched20.dll
 IMPORTLIB = riched20
-IMPORTS   = uuid ole32 imm32 user32 gdi32 kernel32
+IMPORTS   = uuid ole32 oleaut32 imm32 user32 gdi32 kernel32
 
 C_SRCS = \
 	caret.c \
diff --git a/dlls/riched20/tests/txtsrv.c b/dlls/riched20/tests/txtsrv.c
index cb11469..7ba38e9 100644
--- a/dlls/riched20/tests/txtsrv.c
+++ b/dlls/riched20/tests/txtsrv.c
@@ -641,7 +641,7 @@ static void test_TxGetText(void)
         return;
 
     hres = ITextServices_TxGetText(txtserv, &rettext);
-    todo_wine ok(hres == S_OK, "ITextServices_TxGetText failed\n");
+    ok(hres == S_OK, "ITextServices_TxGetText failed\n");
 
     IUnknown_Release(txtserv);
     CoTaskMemFree(dummyTextHost);
@@ -657,14 +657,14 @@ static void test_TxSetText(void)
         return;
 
     hres = ITextServices_TxSetText(txtserv, settext);
-    todo_wine ok(hres == S_OK, "ITextServices_TxSetText failed\n");
+    ok(hres == S_OK, "ITextServices_TxSetText failed\n");
 
     hres = ITextServices_TxGetText(txtserv, &rettext);
-    todo_wine ok(hres == S_OK, "ITextServices_TxGetText failed\n");
+    ok(hres == S_OK, "ITextServices_TxGetText failed\n");
 
-    todo_wine ok(SysStringLen(rettext) == 4,
+    ok(SysStringLen(rettext) == 4,
                  "String returned of wrong length\n");
-    todo_wine ok(memcmp(rettext,settext,SysStringByteLen(rettext)) == 0,
+    ok(memcmp(rettext,settext,SysStringByteLen(rettext)) == 0,
                  "String returned differs\n");
 
     IUnknown_Release(txtserv);
@@ -709,7 +709,7 @@ void test_TxGetNaturalSize() {
     xdim = 0; ydim = 0;
 
     result = ITextServices_TxSetText(txtserv, oneA);
-    todo_wine ok(result == S_OK, "ITextServices_TxSetText failed\n");
+    ok(result == S_OK, "ITextServices_TxSetText failed\n");
 
     result = ITextServices_TxGetNaturalSize(txtserv, DVASPECT_CONTENT,
                                             hdcDraw, NULL, NULL,
diff --git a/dlls/riched20/txtsrv.c b/dlls/riched20/txtsrv.c
index f05e721..2d5ff81 100644
--- a/dlls/riched20/txtsrv.c
+++ b/dlls/riched20/txtsrv.c
@@ -27,6 +27,7 @@
 
 #include "editor.h"
 #include "ole2.h"
+#include "oleauto.h"
 #include "richole.h"
 #include "imm.h"
 #include "textserv.h"
@@ -276,9 +277,23 @@ HRESULT WINAPI fnTextSrv_TxGetText(ITextServices *iface,
                                    BSTR* pbstrText)
 {
    ICOM_THIS_MULTI(ITextServicesImpl, lpVtbl, iface);
+   int length;
 
-   FIXME("%p: STUB\n", This);
-   return E_NOTIMPL;
+   length = ME_GetTextLength(This->editor);
+   if (length)
+   {
+      BSTR bstr;
+      bstr = SysAllocStringByteLen(NULL, length * sizeof(WCHAR));
+      if (bstr == NULL)
+         return E_OUTOFMEMORY;
+
+      ME_GetTextW(This->editor, bstr , 0, length, FALSE);
+      *pbstrText = bstr;
+   } else {
+      *pbstrText = NULL;
+   }
+
+   return S_OK;
 }
 
 HRESULT WINAPI fnTextSrv_TxSetText(ITextServices *iface,
@@ -286,8 +301,17 @@ HRESULT WINAPI fnTextSrv_TxSetText(ITextServices *iface,
 {
    ICOM_THIS_MULTI(ITextServicesImpl, lpVtbl, iface);
 
-   FIXME("%p: STUB\n", This);
-   return E_NOTIMPL;
+   ME_InternalDeleteText(This->editor, 0, ME_GetTextLength(This->editor),
+                         FALSE);
+   ME_InsertTextFromCursor(This->editor, 0, pszText, -1,
+                           This->editor->pBuffer->pDefaultStyle);
+   ME_SetSelection(This->editor, 0, 0);
+   This->editor->nModifyStep = 0;
+   OleFlushClipboard();
+   ME_EmptyUndoStack(This->editor);
+   ME_UpdateRepaint(This->editor);
+
+   return S_OK;
 }
 
 HRESULT WINAPI fnTextSrv_TxGetCurrentTargetX(ITextServices *iface,


More information about the wine-patches mailing list