Nikolay Sivov : riched20: Implement GetStoryLength().
Alexandre Julliard
julliard at wine.codeweavers.com
Mon Jun 8 07:49:55 CDT 2015
Module: wine
Branch: master
Commit: 9c6bcec5090ca0c021e5791de4f40d12ce30ef92
URL: http://source.winehq.org/git/wine.git/?a=commit;h=9c6bcec5090ca0c021e5791de4f40d12ce30ef92
Author: Nikolay Sivov <nsivov at codeweavers.com>
Date: Sat Jun 6 19:34:56 2015 +0300
riched20: Implement GetStoryLength().
---
dlls/riched20/richole.c | 25 ++++++++++++----
dlls/riched20/tests/richole.c | 69 +++++++++++++++++++++++++++++++++++++++++++
2 files changed, 88 insertions(+), 6 deletions(-)
diff --git a/dlls/riched20/richole.c b/dlls/riched20/richole.c
index 7af3ae2..019a25f 100644
--- a/dlls/riched20/richole.c
+++ b/dlls/riched20/richole.c
@@ -312,6 +312,15 @@ static HRESULT create_textfont(ITextRange*, const ITextFontImpl*, ITextFont**);
static HRESULT create_textpara(ITextRange*, ITextPara**);
static ITextSelectionImpl *CreateTextSelection(IRichEditOleImpl*);
+static HRESULT textrange_get_storylength(ME_TextEditor *editor, LONG *length)
+{
+ if (!length)
+ return E_INVALIDARG;
+
+ *length = ME_GetTextLength(editor) + 1;
+ return S_OK;
+}
+
static void textranges_update_ranges(IRichEditOleImpl *reole, LONG start, LONG end, enum range_update_op op)
{
ITextRangeImpl *range;
@@ -1897,14 +1906,16 @@ static HRESULT WINAPI ITextRange_fnSetPara(ITextRange *me, ITextPara *pPara)
return E_NOTIMPL;
}
-static HRESULT WINAPI ITextRange_fnGetStoryLength(ITextRange *me, LONG *pcch)
+static HRESULT WINAPI ITextRange_fnGetStoryLength(ITextRange *me, LONG *length)
{
ITextRangeImpl *This = impl_from_ITextRange(me);
+
+ TRACE("(%p)->(%p)\n", This, length);
+
if (!This->child.reole)
return CO_E_RELEASED;
- FIXME("not implemented %p\n", This);
- return E_NOTIMPL;
+ return textrange_get_storylength(This->child.reole->editor, length);
}
static HRESULT WINAPI ITextRange_fnGetStoryType(ITextRange *me, LONG *value)
@@ -4364,14 +4375,16 @@ static HRESULT WINAPI ITextSelection_fnSetPara(ITextSelection *me, ITextPara *pP
return E_NOTIMPL;
}
-static HRESULT WINAPI ITextSelection_fnGetStoryLength(ITextSelection *me, LONG *pcch)
+static HRESULT WINAPI ITextSelection_fnGetStoryLength(ITextSelection *me, LONG *length)
{
ITextSelectionImpl *This = impl_from_ITextSelection(me);
+
+ TRACE("(%p)->(%p)\n", This, length);
+
if (!This->reOle)
return CO_E_RELEASED;
- FIXME("not implemented\n");
- return E_NOTIMPL;
+ return textrange_get_storylength(This->reOle->editor, length);
}
static HRESULT WINAPI ITextSelection_fnGetStoryType(ITextSelection *me, LONG *value)
diff --git a/dlls/riched20/tests/richole.c b/dlls/riched20/tests/richole.c
index da92e6c..515b9ad 100644
--- a/dlls/riched20/tests/richole.c
+++ b/dlls/riched20/tests/richole.c
@@ -3109,6 +3109,74 @@ static void test_InsertObject(void)
release_interfaces(&hwnd, &reole, &doc, NULL);
}
+static void test_GetStoryLength(void)
+{
+ static const CHAR test_text1[] = "TestSomeText";
+ IRichEditOle *reOle = NULL;
+ ITextDocument *doc = NULL;
+ ITextSelection *selection;
+ ITextRange *range;
+ LONG value;
+ HRESULT hr;
+ HWND hwnd;
+
+ create_interfaces(&hwnd, &reOle, &doc, &selection);
+ SendMessageA(hwnd, WM_SETTEXT, 0, (LPARAM)test_text1);
+ SendMessageA(hwnd, EM_SETSEL, 1, 2);
+
+ hr = ITextDocument_Range(doc, 0, 4, &range);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+
+ hr = ITextRange_GetStoryLength(range, NULL);
+ ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
+
+ value = 0;
+ hr = ITextRange_GetStoryLength(range, &value);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+ ok(value == 13, "got %d\n", value);
+
+ hr = ITextSelection_GetStoryLength(selection, NULL);
+ ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
+
+ value = 0;
+ hr = ITextSelection_GetStoryLength(selection, &value);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+ ok(value == 13, "got %d\n", value);
+
+ SendMessageA(hwnd, WM_SETTEXT, 0, (LPARAM)"");
+
+ value = 0;
+ hr = ITextRange_GetStoryLength(range, &value);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+ ok(value == 1, "got %d\n", value);
+
+ value = 0;
+ hr = ITextSelection_GetStoryLength(selection, &value);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+ ok(value == 1, "got %d\n", value);
+
+ release_interfaces(&hwnd, &reOle, &doc, NULL);
+
+ hr = ITextRange_GetStoryLength(range, NULL);
+ ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
+
+ value = 100;
+ hr = ITextRange_GetStoryLength(range, &value);
+ ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
+ ok(value == 100, "got %d\n", value);
+
+ hr = ITextSelection_GetStoryLength(selection, NULL);
+ ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
+
+ value = 100;
+ hr = ITextSelection_GetStoryLength(selection, &value);
+ ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
+ ok(value == 100, "got %d\n", value);
+
+ ITextSelection_Release(selection);
+ ITextRange_Release(range);
+}
+
START_TEST(richole)
{
/* Must explicitly LoadLibrary(). The test has no references to functions in
@@ -3142,4 +3210,5 @@ START_TEST(richole)
test_GetStoryType();
test_SetFont();
test_InsertObject();
+ test_GetStoryLength();
}
More information about the wine-cvs
mailing list