Commit 20d6bc8a authored by Dylan Smith's avatar Dylan Smith Committed by Alexandre Julliard

richedit: Implemented ITextServices TxGetText and TxSetText.

parent e7b68a20
......@@ -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 \
......
......@@ -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);
......@@ -717,7 +717,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,
......
......@@ -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,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment