Added patches to implement ITextRange, ITextPara and ITextFont (by Jactry Zeng).

This commit is contained in:
Sebastian Lackner 2014-08-09 05:49:54 +02:00
parent f837eb03f6
commit b2db6dedde
12 changed files with 3718 additions and 0 deletions

View File

@ -25,6 +25,7 @@ Wine-Compholio contains fixes for the following Wine bugs:
* Fix for ConnectNamedPort return value in overlapped mode ([Wine Bug #16550](http://bugs.winehq.org/show_bug.cgi?id=16550 "ConnectNamedPort should never return OK in overlapped mode (affects chromium ui_tests.exe)"))
* Fix for programs leaking wndproc slots ([Wine Bug #32451](http://bugs.winehq.org/show_bug.cgi?id=32451 "Multiple GOG.com installer bundles show a broken/unresponsive dialog window during installation (installer process running out of wndproc slots)"))
* GetSecurityInfo returns NULL DACL for process object ([Wine Bug #15980](http://bugs.winehq.org/show_bug.cgi?id=15980 "Rhapsody 2 crashes on startup (GetSecurityInfo returns NULL DACL for process object)"))
* Implement ITextDocument_fnRange function ([Wine Bug #12458](http://bugs.winehq.org/show_bug.cgi?id=12458 "Multiple apps fail due to RichEdit ITextDocument_fnRange stub (MySQL Workbench, BlitzMaxDemo137)"))
* Implement LoadIconMetric function ([Wine Bug #35375](http://bugs.winehq.org/show_bug.cgi?id=35375 "Multiple applications need Vista+ API COMCTL32.dll.380 a.k.a. 'LoadIconMetric' (Solidworks 2013 systray monitor, Microsoft One/SkyDrive)"))
* Implement a Microsoft Yahei replacement font ([Wine Bug #13829](http://bugs.winehq.org/show_bug.cgi?id=13829 "Wine does not have CJK fonts"))
* Implement an Arial replacement font ([Wine Bug #32323](http://bugs.winehq.org/show_bug.cgi?id=32323 "Netflix (Silverlight 4.x) and several .NET Framework 3.x/4.0 WPF apps require either Arial or Verdana to be installed"))
@ -35,6 +36,7 @@ Wine-Compholio contains fixes for the following Wine bugs:
* Set ldr.EntryPoint for main executable ([Wine Bug #33034](http://bugs.winehq.org/show_bug.cgi?id=33034 "Many GFWL (Games For Windows Live) 1.x/2.x/3.x games crash or exit silently on startup (DiRT 2/3, GTA IV Steam)"))
* Support for AllocateAndGetTcpExTableFromStack ([Wine Bug #34372](http://bugs.winehq.org/show_bug.cgi?id=34372 "Add missing function AllocateAndGetTcpExTableFromStack() to iphlpapi.dll"))
* Support for GetSystemTimes ([Wine Bug #19813](http://bugs.winehq.org/show_bug.cgi?id=19813 "Voddler needs GetSystemTimes to run"))
* Support for ITextRange, ITextFont and ITextPara ([Wine Bug #18303](http://bugs.winehq.org/show_bug.cgi?id=18303 "Adobe Acrobat Pro 7: Crashes when selecting the \"edit\" menu while having a file open."))
* Support for Junction Points ([Wine Bug #12401](http://bugs.winehq.org/show_bug.cgi?id=12401 "Support junction points, i.e. DeviceIoCtl(FSCTL_SET_REPARSE_POINT/FSCTL_GET_REPARSE_POINT)"))
* Support for NtSetInformationFile class FileDispositionInformation ([Wine Bug #30397](http://bugs.winehq.org/show_bug.cgi?id=30397 "Multiple applications need support for NtSetInformationFile class FileDispositionInformation (Cygwin installer, Stylizer 5.x Visual CSS editor, Spoon Studio 2011 (ex Xenocode) application sandboxing scheme)"))
* Support for PulseAudio backend for audio ([Wine Bug #10495](http://bugs.winehq.org/show_bug.cgi?id=10495 "Wine should support PulseAudio"))

1
debian/changelog vendored
View File

@ -21,6 +21,7 @@ wine-compholio (1.7.24) UNRELEASED; urgency=low
* Added patch to use a linear resampler when there a large number of dsound mixing buffers.
* Added patch to fix comparison of punctuation characters in lstrcmp.
* Added patch to workaround programs leaking wndproc splots.
* Added patch to implement ITextRange, ITextFont and ITextPara.
* Removed patch to create Vista directories (accepted upstream).
* Removed strmbase/quartz locking fix patches (accepted upstream).
* Removed windowscodecs/PropertyBag patch (accepted upstream).

View File

@ -29,6 +29,7 @@ PATCHLIST := \
ntdll-Pipe_SpecialCharacters.ok \
ntdll-loader_EntryPoint.ok \
quartz-MediaSeeking_Positions.ok \
riched20-IText_Interface.ok \
server-ACL_Compat.ok \
server-Address_Change_Notification.ok \
server-CreateProcess_ACLs.ok \
@ -478,6 +479,38 @@ quartz-MediaSeeking_Positions.ok:
echo '+ { "quartz-MediaSeeking_Positions", "Erich E. Hoover", "Return correct IMediaSeeking stream positions in quartz." },'; \
) > quartz-MediaSeeking_Positions.ok
# Patchset riched20-IText_Interface
# |
# | Included patches:
# | * Implement Stubs for ITextRange interface. [by Jactry Zeng]
# | * Implement IText{Range,Selection}::{GetChar,GetStart,GetEnd,GetDuplicate,Collapse,SetStart,SetEnd}. [by Jactry Zeng]
# | * Implement Stubs for ITextFont interface. [by Jactry Zeng]
# | * Implement Stubs for ITextPara interface. [by Jactry Zeng]
# |
# | This patchset fixes the following Wine bugs:
# | * [#12458] Multiple apps fail due to RichEdit ITextDocument_fnRange stub (MySQL Workbench, BlitzMaxDemo137)
# | * [#18303] Adobe Acrobat Pro 7: Crashes when selecting the "edit" menu while having a file open.
# |
# | Modified files:
# | * dlls/riched20/richole.c, dlls/riched20/tests/richole.c
# |
.INTERMEDIATE: riched20-IText_Interface.ok
riched20-IText_Interface.ok:
$(call APPLY_FILE,riched20-IText_Interface/0001-riched20-Stub-for-ITextRange-interface-and-implement.patch)
$(call APPLY_FILE,riched20-IText_Interface/0002-riched20-Implement-ITextSelection-GetChar-and-ITextR.patch)
$(call APPLY_FILE,riched20-IText_Interface/0003-riched20-Implement-IText-Selection-Range-Get-Start-E.patch)
$(call APPLY_FILE,riched20-IText_Interface/0004-riched20-Implement-ITextRange-GetDuplicate.patch)
$(call APPLY_FILE,riched20-IText_Interface/0005-riched20-Implement-ITextRange-Collapse-and-ITextSele.patch)
$(call APPLY_FILE,riched20-IText_Interface/0006-riched20-Implement-IText-Selection-Range-Set-Start-E.patch)
$(call APPLY_FILE,riched20-IText_Interface/0007-riched20-Stub-for-ITextFont-interface-and-implement-.patch)
$(call APPLY_FILE,riched20-IText_Interface/0008-riched20-Stub-for-ITextPara-interface-and-implement-.patch)
@( \
echo '+ { "riched20-IText_Interface", "Jactry Zeng", "Implement Stubs for ITextRange interface." },'; \
echo '+ { "riched20-IText_Interface", "Jactry Zeng", "Implement IText{Range,Selection}::{GetChar,GetStart,GetEnd,GetDuplicate,Collapse,SetStart,SetEnd}." },'; \
echo '+ { "riched20-IText_Interface", "Jactry Zeng", "Implement Stubs for ITextFont interface." },'; \
echo '+ { "riched20-IText_Interface", "Jactry Zeng", "Implement Stubs for ITextPara interface." },'; \
) > riched20-IText_Interface.ok
# Patchset server-ACL_Compat
# |
# | Included patches:

View File

@ -0,0 +1,154 @@
From e62c0def4ec23fcbc74f217fe1f12458b2eb5225 Mon Sep 17 00:00:00 2001
From: Jactry Zeng <wine@jactry.com>
Date: Thu, 7 Aug 2014 13:50:08 +0800
Subject: riched20: Implement ITextSelection::GetChar and ITextRange::GetChar.
---
dlls/riched20/richole.c | 28 ++++++++++++++---
dlls/riched20/tests/richole.c | 69 +++++++++++++++++++++++++++++++++++++++++
2 files changed, 93 insertions(+), 4 deletions(-)
diff --git a/dlls/riched20/richole.c b/dlls/riched20/richole.c
index 314bc1e..e93070a 100644
--- a/dlls/riched20/richole.c
+++ b/dlls/riched20/richole.c
@@ -568,14 +568,29 @@ static HRESULT WINAPI ITextRange_fnSetText(ITextRange *me, BSTR bstr)
return E_NOTIMPL;
}
+static HRESULT range_GetChar(ME_TextEditor *editor, ME_Cursor *cursor, LONG *pch)
+{
+ WCHAR wch[2];
+
+ ME_GetTextW(editor, wch, 1, cursor, 1, FALSE, cursor->pRun->next->type == diTextEnd);
+ *pch = wch[0];
+
+ return S_OK;
+}
+
static HRESULT WINAPI ITextRange_fnGetChar(ITextRange *me, LONG *pch)
{
ITextRangeImpl *This = impl_from_ITextRange(me);
+ ME_Cursor cursor;
+
if (!This->reOle)
return CO_E_RELEASED;
+ TRACE("%p\n", pch);
+ if (!pch)
+ return E_INVALIDARG;
- FIXME("not implemented %p\n", This);
- return E_NOTIMPL;
+ ME_CursorFromCharOfs(This->reOle->editor, This->start, &cursor);
+ return range_GetChar(This->reOle->editor, &cursor, pch);
}
static HRESULT WINAPI ITextRange_fnSetChar(ITextRange *me, LONG ch)
@@ -1552,11 +1567,16 @@ static HRESULT WINAPI ITextSelection_fnSetText(ITextSelection *me, BSTR bstr)
static HRESULT WINAPI ITextSelection_fnGetChar(ITextSelection *me, LONG *pch)
{
ITextSelectionImpl *This = impl_from_ITextSelection(me);
+ ME_Cursor *start = NULL, *end = NULL;
+
if (!This->reOle)
return CO_E_RELEASED;
+ TRACE("%p\n", pch);
+ if (!pch)
+ return E_INVALIDARG;
- FIXME("not implemented\n");
- return E_NOTIMPL;
+ ME_GetSelection(This->reOle->editor, &start, &end);
+ return range_GetChar(This->reOle->editor, start, pch);
}
static HRESULT WINAPI ITextSelection_fnSetChar(ITextSelection *me, LONG ch)
diff --git a/dlls/riched20/tests/richole.c b/dlls/riched20/tests/richole.c
index 417b68f..152d144 100644
--- a/dlls/riched20/tests/richole.c
+++ b/dlls/riched20/tests/richole.c
@@ -518,6 +518,73 @@ static void test_ITextDocument_Range(void)
ITextRange_Release(txtRge);
}
+static void test_ITextSelection_GetChar(void)
+{
+ HWND w;
+ IRichEditOle *reOle = NULL;
+ ITextDocument *txtDoc = NULL;
+ ITextSelection *txtSel = NULL;
+ HRESULT hres;
+ LONG pch = 0xdeadbeef;
+ static const CHAR test_text1[] = "TestSomeText";
+
+ create_interfaces(&w, &reOle, &txtDoc, &txtSel);
+ SendMessageA(w, WM_SETTEXT, 0, (LPARAM)test_text1);
+
+#define TEST_TXTSEL_GETCHAR(first, lim, expected_char) \
+ SendMessageA(w, EM_SETSEL, first, lim); \
+ pch = 0xdeadbeef; \
+ hres = ITextSelection_GetChar(txtSel, &pch); \
+ ok(hres == S_OK, "ITextSelection_GetChar\n"); \
+ ok(pch == expected_char, "got wrong char: %c\n", pch);
+
+ TEST_TXTSEL_GETCHAR(0, 4, 'T')
+ TEST_TXTSEL_GETCHAR(0, 0, 'T')
+ TEST_TXTSEL_GETCHAR(12, 12, '\r')
+ TEST_TXTSEL_GETCHAR(13, 13, '\r')
+
+ hres = ITextSelection_GetChar(txtSel, NULL);
+ ok(hres == E_INVALIDARG, "ITextSelection_GetChar\n");
+
+ release_interfaces(&w, &reOle, &txtDoc, &txtSel);
+}
+
+static void test_ITextRange_GetChar(void)
+{
+ HWND w;
+ IRichEditOle *reOle = NULL;
+ ITextDocument *txtDoc = NULL;
+ ITextRange *txtRge = NULL;
+ HRESULT hres;
+ LONG pch = 0xdeadbeef;
+ int first, lim;
+ static const CHAR test_text1[] = "TestSomeText";
+
+#define TEST_TXTRGE_GETCHAR(first, lim, expected_char) \
+ create_interfaces(&w, &reOle, &txtDoc, NULL); \
+ SendMessageA(w, WM_SETTEXT, 0, (LPARAM)test_text1); \
+ ITextDocument_Range(txtDoc, first, lim, &txtRge); \
+ pch = 0xdeadbeef; \
+ hres = ITextRange_GetChar(txtRge, &pch); \
+ ok(hres == S_OK, "ITextRange_GetChar\n"); \
+ ok(pch == expected_char, "got wrong char: %c\n", pch); \
+ ITextRange_Release(txtRge); \
+ release_interfaces(&w, &reOle, &txtDoc, NULL);
+
+ TEST_TXTRGE_GETCHAR(0, 4, 'T')
+ TEST_TXTRGE_GETCHAR(0, 0, 'T')
+ TEST_TXTRGE_GETCHAR(12, 12, '\r')
+ TEST_TXTRGE_GETCHAR(13, 13, '\r')
+
+ create_interfaces(&w, &reOle, &txtDoc, NULL);
+ SendMessageA(w, WM_SETTEXT, 0, (LPARAM)test_text1);
+ first = 12, lim = 12;
+ ITextDocument_Range(txtDoc, first, lim, &txtRge);
+ hres = ITextRange_GetChar(txtRge, NULL);
+ ok(hres == E_INVALIDARG, "ITextRange_GetChar\n");
+ ITextRange_Release(txtRge);
+ release_interfaces(&w, &reOle, &txtDoc, NULL);
+}
START_TEST(richole)
{
@@ -529,5 +596,7 @@ START_TEST(richole)
test_Interfaces();
test_ITextDocument_Open();
test_ITextSelection_GetText();
+ test_ITextSelection_GetChar();
test_ITextDocument_Range();
+ test_ITextRange_GetChar();
}
--
1.7.9.5

View File

@ -0,0 +1,147 @@
From 2ac5a6bc7f97a2179fcf566183d7a5f989ebe401 Mon Sep 17 00:00:00 2001
From: Jactry Zeng <wine@jactry.com>
Date: Thu, 7 Aug 2014 14:59:13 +0800
Subject: riched20: Implement IText{Selection, Range}::Get{Start, End}.
---
dlls/riched20/richole.c | 30 ++++++++++++++++++-------
dlls/riched20/tests/richole.c | 50 +++++++++++++++++++++++++++++++++++++++++
2 files changed, 72 insertions(+), 8 deletions(-)
diff --git a/dlls/riched20/richole.c b/dlls/riched20/richole.c
index e93070a..bd3dee8 100644
--- a/dlls/riched20/richole.c
+++ b/dlls/riched20/richole.c
@@ -639,8 +639,11 @@ static HRESULT WINAPI ITextRange_fnGetStart(ITextRange *me, LONG *pcpFirst)
if (!This->reOle)
return CO_E_RELEASED;
- FIXME("not implemented %p\n", This);
- return E_NOTIMPL;
+ if (!pcpFirst)
+ return E_INVALIDARG;
+ *pcpFirst = This->start;
+ TRACE("%d\n", *pcpFirst);
+ return S_OK;
}
static HRESULT WINAPI ITextRange_fnSetStart(ITextRange *me, LONG cpFirst)
@@ -659,8 +662,11 @@ static HRESULT WINAPI ITextRange_fnGetEnd(ITextRange *me, LONG *pcpLim)
if (!This->reOle)
return CO_E_RELEASED;
- FIXME("not implemented %p\n", This);
- return E_NOTIMPL;
+ if (!pcpLim)
+ return E_INVALIDARG;
+ *pcpLim = This->end;
+ TRACE("%d\n", *pcpLim);
+ return S_OK;
}
static HRESULT WINAPI ITextRange_fnSetEnd(ITextRange *me, LONG cpLim)
@@ -1622,11 +1628,15 @@ static HRESULT WINAPI ITextSelection_fnSetFormattedText(ITextSelection *me, ITex
static HRESULT WINAPI ITextSelection_fnGetStart(ITextSelection *me, LONG *pcpFirst)
{
ITextSelectionImpl *This = impl_from_ITextSelection(me);
+ int lim;
if (!This->reOle)
return CO_E_RELEASED;
- FIXME("not implemented\n");
- return E_NOTIMPL;
+ if (!pcpFirst)
+ return E_INVALIDARG;
+ ME_GetSelectionOfs(This->reOle->editor, pcpFirst, &lim);
+ TRACE("%d\n", *pcpFirst);
+ return S_OK;
}
static HRESULT WINAPI ITextSelection_fnSetStart(ITextSelection *me, LONG cpFirst)
@@ -1642,11 +1652,15 @@ static HRESULT WINAPI ITextSelection_fnSetStart(ITextSelection *me, LONG cpFirst
static HRESULT WINAPI ITextSelection_fnGetEnd(ITextSelection *me, LONG *pcpLim)
{
ITextSelectionImpl *This = impl_from_ITextSelection(me);
+ int first;
if (!This->reOle)
return CO_E_RELEASED;
- FIXME("not implemented\n");
- return E_NOTIMPL;
+ if (!pcpLim)
+ return E_INVALIDARG;
+ ME_GetSelectionOfs(This->reOle->editor, &first, pcpLim);
+ TRACE("%d\n", *pcpLim);
+ return S_OK;
}
static HRESULT WINAPI ITextSelection_fnSetEnd(ITextSelection *me, LONG cpLim)
diff --git a/dlls/riched20/tests/richole.c b/dlls/riched20/tests/richole.c
index 152d144..22ee4b5 100644
--- a/dlls/riched20/tests/richole.c
+++ b/dlls/riched20/tests/richole.c
@@ -586,6 +586,55 @@ static void test_ITextRange_GetChar(void)
release_interfaces(&w, &reOle, &txtDoc, NULL);
}
+static void test_GetStart_GetEnd(void)
+{
+ HWND w;
+ IRichEditOle *reOle = NULL;
+ ITextDocument *txtDoc = NULL;
+ ITextRange *txtRge = NULL;
+ ITextSelection *txtSel = NULL;
+ HRESULT hres;
+ int start, end;
+ static const CHAR test_text1[] = "TestSomeText";
+
+ create_interfaces(&w, &reOle, &txtDoc, &txtSel);
+ SendMessageA(w, WM_SETTEXT, 0, (LPARAM)test_text1);
+
+ /* tests for ITextRange::Get{Start, End} */
+#define TEST_TXTRGE_GETSTARTEND(first, lim, expected_start, expected_end) \
+ ITextDocument_Range(txtDoc, first, lim, &txtRge); \
+ start = 0xdeadbeef; \
+ hres = ITextRange_GetStart(txtRge, &start); \
+ ok(hres == S_OK, "ITextRange_GetStart\n"); \
+ ok(start == expected_start, "got wrong start value: %d\n", start); \
+ end = 0xdeadbeef; \
+ hres = ITextRange_GetEnd(txtRge, &end); \
+ ok(hres == S_OK, "ITextRange_GetEnd\n"); \
+ ok(end == expected_end, "got wrong end value: %d\n", end); \
+ ITextRange_Release(txtRge);
+
+ TEST_TXTRGE_GETSTARTEND(1, 6, 1, 6);
+ TEST_TXTRGE_GETSTARTEND(6, 1, 1, 6);
+ TEST_TXTRGE_GETSTARTEND(-1, 13, 0, 13);
+
+ /* tests for ITextSelection::Get{Start, End} */
+#define TEST_TXTSEL_GETSTARTEND(first, lim, expected_start, expected_end) \
+ SendMessageA(w, EM_SETSEL, first, lim); \
+ start = 0xdeadbeef; \
+ hres = ITextSelection_GetStart(txtSel, &start); \
+ ok(hres == S_OK, "ITextSelection_GetStart\n"); \
+ ok(start == expected_start, "got wrong start value: %d\n", start); \
+ end = 0xdeadbeef; \
+ hres = ITextSelection_GetEnd(txtSel, &end); \
+ ok(end == expected_end, "got wrong end value: %d\n", end);
+
+ TEST_TXTSEL_GETSTARTEND(2, 5, 2, 5)
+ TEST_TXTSEL_GETSTARTEND(5, 2, 2, 5)
+ TEST_TXTSEL_GETSTARTEND(0, -1, 0, strlen(test_text1)+1)
+
+ release_interfaces(&w, &reOle, &txtDoc, &txtSel);
+}
+
START_TEST(richole)
{
/* Must explicitly LoadLibrary(). The test has no references to functions in
@@ -599,4 +648,5 @@ START_TEST(richole)
test_ITextSelection_GetChar();
test_ITextDocument_Range();
test_ITextRange_GetChar();
+ test_GetStart_GetEnd();
}
--
1.7.9.5

View File

@ -0,0 +1,102 @@
From 3cc40358e08460d01b43647844f260eafc670e28 Mon Sep 17 00:00:00 2001
From: Jactry Zeng <wine@jactry.com>
Date: Thu, 7 Aug 2014 15:11:07 +0800
Subject: riched20: Implement ITextRange::GetDuplicate.
---
dlls/riched20/richole.c | 23 +++++++++++++++++++++--
dlls/riched20/tests/richole.c | 35 +++++++++++++++++++++++++++++++++++
2 files changed, 56 insertions(+), 2 deletions(-)
diff --git a/dlls/riched20/richole.c b/dlls/riched20/richole.c
index bd3dee8..229fb5d 100644
--- a/dlls/riched20/richole.c
+++ b/dlls/riched20/richole.c
@@ -606,11 +606,30 @@ static HRESULT WINAPI ITextRange_fnSetChar(ITextRange *me, LONG ch)
static HRESULT WINAPI ITextRange_fnGetDuplicate(ITextRange *me, ITextRange **ppRange)
{
ITextRangeImpl *This = impl_from_ITextRange(me);
+ ITextRangeImpl *txtRge = NULL;
if (!This->reOle)
return CO_E_RELEASED;
- FIXME("not implemented %p\n", This);
- return E_NOTIMPL;
+ TRACE("%p %p\n", This, ppRange);
+ if (!ppRange)
+ return E_INVALIDARG;
+
+ txtRge = heap_alloc(sizeof *txtRge);
+ if (!txtRge)
+ return E_FAIL;
+
+ txtRge->ITextRange_iface.lpVtbl = This->ITextRange_iface.lpVtbl;
+ txtRge->ref = 1;
+ txtRge->reOle = This->reOle;
+ txtRge->start = This->start;
+ txtRge->end = This->end;
+ txtRge->next = This->reOle->txtRgehead->next;
+ This->reOle->txtRgehead->next->prev = txtRge;
+ This->reOle->txtRgehead->next = txtRge;
+ txtRge->prev = This->reOle->txtRgehead;
+ *ppRange = &txtRge->ITextRange_iface;
+
+ return S_OK;
}
static HRESULT WINAPI ITextRange_fnGetFormattedText(ITextRange *me, ITextRange **ppRange)
diff --git a/dlls/riched20/tests/richole.c b/dlls/riched20/tests/richole.c
index 22ee4b5..bc04c84 100644
--- a/dlls/riched20/tests/richole.c
+++ b/dlls/riched20/tests/richole.c
@@ -635,6 +635,40 @@ static void test_GetStart_GetEnd(void)
release_interfaces(&w, &reOle, &txtDoc, &txtSel);
}
+static void test_ITextRange_GetDuplicate(void)
+{
+ HWND w;
+ IRichEditOle *reOle = NULL;
+ ITextDocument *txtDoc = NULL;
+ ITextRange *txtRge = NULL;
+ ITextRange *txtRgeDup = NULL;
+ HRESULT hres;
+ LONG first, lim, start, end;
+ static const CHAR test_text1[] = "TestSomeText";
+
+ create_interfaces(&w, &reOle, &txtDoc, NULL);
+ SendMessageA(w, WM_SETTEXT, 0, (LPARAM)test_text1);
+ first = 0, lim = 4;
+ hres = ITextDocument_Range(txtDoc, first, lim, &txtRge);
+ ok(hres == S_OK, "ITextDocument_Range fails 0x%x.\n", hres);
+
+ hres = ITextRange_GetDuplicate(txtRge, &txtRgeDup);
+ ok(hres == S_OK, "ITextRange_GetDuplicate\n");
+ ok(txtRgeDup != txtRge, "A new pointer should be returned\n");
+ ITextRange_GetStart(txtRgeDup, &start);
+ ok(start == first, "got wrong value: %d\n", start);
+ ITextRange_GetEnd(txtRgeDup, &end);
+ ok(end == lim, "got wrong value: %d\n", end);
+
+ ITextRange_Release(txtRgeDup);
+
+ hres = ITextRange_GetDuplicate(txtRge, NULL);
+ ok(hres == E_INVALIDARG, "ITextRange_GetDuplicate\n");
+
+ ITextRange_Release(txtRge);
+ release_interfaces(&w, &reOle, &txtDoc, NULL);
+}
+
START_TEST(richole)
{
/* Must explicitly LoadLibrary(). The test has no references to functions in
@@ -648,5 +682,6 @@ START_TEST(richole)
test_ITextSelection_GetChar();
test_ITextDocument_Range();
test_ITextRange_GetChar();
+ test_ITextRange_GetDuplicate();
test_GetStart_GetEnd();
}
--
1.7.9.5

View File

@ -0,0 +1,167 @@
From a1d0978ce36f81b0bc547e3a357bd985c3b16abe Mon Sep 17 00:00:00 2001
From: Jactry Zeng <wine@jactry.com>
Date: Sat, 9 Aug 2014 00:40:17 +0800
Subject: riched20: Implement ITextRange::Collapse and
ITextSelection::Collapse.
---
dlls/riched20/richole.c | 26 +++++++++++---
dlls/riched20/tests/richole.c | 80 +++++++++++++++++++++++++++++++++++++++++
2 files changed, 101 insertions(+), 5 deletions(-)
diff --git a/dlls/riched20/richole.c b/dlls/riched20/richole.c
index 229fb5d..9a7e690 100644
--- a/dlls/riched20/richole.c
+++ b/dlls/riched20/richole.c
@@ -757,15 +757,26 @@ static HRESULT WINAPI ITextRange_fnGetStoryType(ITextRange *me, LONG *pValue)
FIXME("not implemented %p\n", This);
return E_NOTIMPL;
}
+static HRESULT range_Collapse(LONG bStart, LONG *start, LONG *end)
+{
+ BOOL isdege = !(*end - *start);
+
+ if (isdege)
+ return S_FALSE;
+
+ if (bStart == tomEnd || bStart == tomFalse)
+ *start = *end;
+ else
+ *end = *start;
+ return S_OK;
+}
static HRESULT WINAPI ITextRange_fnCollapse(ITextRange *me, LONG bStart)
{
ITextRangeImpl *This = impl_from_ITextRange(me);
if (!This->reOle)
return CO_E_RELEASED;
-
- FIXME("not implemented %p\n", This);
- return E_NOTIMPL;
+ return range_Collapse(bStart, &This->start, &This->end);
}
static HRESULT WINAPI ITextRange_fnExpand(ITextRange *me, LONG Unit, LONG *pDelta)
@@ -1755,11 +1766,16 @@ static HRESULT WINAPI ITextSelection_fnGetStoryType(ITextSelection *me, LONG *pV
static HRESULT WINAPI ITextSelection_fnCollapse(ITextSelection *me, LONG bStart)
{
ITextSelectionImpl *This = impl_from_ITextSelection(me);
+ int start, end;
+ HRESULT hres;
if (!This->reOle)
return CO_E_RELEASED;
- FIXME("not implemented\n");
- return E_NOTIMPL;
+ ME_GetSelectionOfs(This->reOle->editor, &start, &end);
+ hres = range_Collapse(bStart, &start, &end);
+ if (!hres)
+ ME_SetSelection(This->reOle->editor, start, end);
+ return hres;
}
static HRESULT WINAPI ITextSelection_fnExpand(ITextSelection *me, LONG Unit, LONG *pDelta)
diff --git a/dlls/riched20/tests/richole.c b/dlls/riched20/tests/richole.c
index bc04c84..7effc3d 100644
--- a/dlls/riched20/tests/richole.c
+++ b/dlls/riched20/tests/richole.c
@@ -669,6 +669,84 @@ static void test_ITextRange_GetDuplicate(void)
release_interfaces(&w, &reOle, &txtDoc, NULL);
}
+static void test_ITextRange_Collapse(void)
+{
+ HWND w;
+ IRichEditOle *reOle = NULL;
+ ITextDocument *txtDoc = NULL;
+ ITextRange *txtRge = NULL;
+ HRESULT hres;
+ LONG first, lim, start, end;
+ static const CHAR test_text1[] = "TestSomeText";
+
+ create_interfaces(&w, &reOle, &txtDoc, NULL);
+ SendMessageA(w, WM_SETTEXT, 0, (LPARAM)test_text1);
+
+#define TEST_TXTRGE_COLLAPSE(bStart, expected_start, expected_end, expected_return) \
+ ITextDocument_Range(txtDoc, first, lim, &txtRge); \
+ hres = ITextRange_Collapse(txtRge, bStart); \
+ ok(hres == expected_return, "ITextRange_Collapse\n"); \
+ ITextRange_GetStart(txtRge, &start); \
+ ok(start == expected_start, "got wrong start value: %d\n", start); \
+ ITextRange_GetEnd(txtRge, &end); \
+ ok(end == expected_end, "got wrong end value: %d\n", end); \
+ ITextRange_Release(txtRge);
+
+ first = 4, lim = 8;
+ TEST_TXTRGE_COLLAPSE(tomTrue, 4, 4, S_OK)
+ TEST_TXTRGE_COLLAPSE(tomStart, 4, 4, S_OK)
+ TEST_TXTRGE_COLLAPSE(tomFalse, 8, 8, S_OK)
+ TEST_TXTRGE_COLLAPSE(tomEnd, 8, 8, S_OK)
+ /* tomStart is the default */
+ TEST_TXTRGE_COLLAPSE(256, 4, 4, S_OK)
+
+ first = 6, lim = 6;
+ TEST_TXTRGE_COLLAPSE(tomEnd, 6, 6, S_FALSE)
+
+ first = 8, lim = 8;
+ TEST_TXTRGE_COLLAPSE(tomStart, 8, 8, S_FALSE)
+
+ release_interfaces(&w, &reOle, &txtDoc, NULL);
+}
+
+static void test_ITextSelection_Collapse(void)
+{
+ HWND w;
+ IRichEditOle *reOle = NULL;
+ ITextDocument *txtDoc = NULL;
+ ITextSelection *txtSel = NULL;
+ HRESULT hres;
+ LONG first, lim, start, end;
+ static const CHAR test_text1[] = "TestSomeText";
+
+ create_interfaces(&w, &reOle, &txtDoc, &txtSel);
+ SendMessageA(w, WM_SETTEXT, 0, (LPARAM)test_text1);
+
+#define TEST_TXTSEL_COLLAPSE(bStart, expected_start, expected_end, expected_return) \
+ SendMessageA(w, EM_SETSEL, first, lim); \
+ hres = ITextSelection_Collapse(txtSel, bStart); \
+ ok(hres == expected_return, "ITextSelection_Collapse\n"); \
+ SendMessageA(w, EM_GETSEL, (LPARAM)&start, (WPARAM)&end); \
+ ok(start == expected_start, "got wrong start value: %d\n", start); \
+ ok(end == expected_end, "got wrong end value: %d\n", end);
+
+ first = 4, lim = 8;
+ TEST_TXTSEL_COLLAPSE(tomTrue, 4, 4, S_OK)
+ TEST_TXTSEL_COLLAPSE(tomStart, 4, 4, S_OK)
+ TEST_TXTSEL_COLLAPSE(tomFalse, 8, 8, S_OK)
+ TEST_TXTSEL_COLLAPSE(tomEnd, 8, 8, S_OK)
+ /* tomStart is the default */
+ TEST_TXTSEL_COLLAPSE(256, 4, 4, S_OK)
+
+ first = 6, lim = 6;
+ TEST_TXTSEL_COLLAPSE(tomEnd, 6, 6, S_FALSE)
+
+ first = 8, lim = 8;
+ TEST_TXTSEL_COLLAPSE(tomStart, 8, 8, S_FALSE)
+
+ release_interfaces(&w, &reOle, &txtDoc, &txtSel);
+}
+
START_TEST(richole)
{
/* Must explicitly LoadLibrary(). The test has no references to functions in
@@ -680,8 +758,10 @@ START_TEST(richole)
test_ITextDocument_Open();
test_ITextSelection_GetText();
test_ITextSelection_GetChar();
+ test_ITextSelection_Collapse();
test_ITextDocument_Range();
test_ITextRange_GetChar();
test_ITextRange_GetDuplicate();
test_GetStart_GetEnd();
+ test_ITextRange_Collapse();
}
--
1.7.9.5

View File

@ -0,0 +1,272 @@
From e6d0113506679fc705bfd65f9ae759fce0152159 Mon Sep 17 00:00:00 2001
From: Jactry Zeng <wine@jactry.com>
Date: Fri, 8 Aug 2014 21:32:57 +0800
Subject: riched20: Implement IText{Selection, Range}::Set{Start, End}.
---
dlls/riched20/richole.c | 52 +++++++++++++---
dlls/riched20/tests/richole.c | 135 +++++++++++++++++++++++++++++++++++++++++
2 files changed, 179 insertions(+), 8 deletions(-)
diff --git a/dlls/riched20/richole.c b/dlls/riched20/richole.c
index 9a7e690..5a16d6d 100644
--- a/dlls/riched20/richole.c
+++ b/dlls/riched20/richole.c
@@ -665,14 +665,27 @@ static HRESULT WINAPI ITextRange_fnGetStart(ITextRange *me, LONG *pcpFirst)
return S_OK;
}
+static HRESULT range_SetStart(ME_TextEditor *editor, LONG cpFirst, LONG *start, LONG *end)
+{
+ int len = ME_GetTextLength(editor);
+
+ TRACE("%d\n", cpFirst);
+ if (cpFirst == *start)
+ return S_FALSE;
+ cpFirst = min(cpFirst, len);
+ cpFirst = max(cpFirst, 0);
+ *end = max(*end, cpFirst);
+ *start = cpFirst;
+ return S_OK;
+}
+
static HRESULT WINAPI ITextRange_fnSetStart(ITextRange *me, LONG cpFirst)
{
ITextRangeImpl *This = impl_from_ITextRange(me);
if (!This->reOle)
return CO_E_RELEASED;
- FIXME("not implemented %p\n", This);
- return E_NOTIMPL;
+ return range_SetStart(This->reOle->editor, cpFirst, &This->start, &This->end);
}
static HRESULT WINAPI ITextRange_fnGetEnd(ITextRange *me, LONG *pcpLim)
@@ -688,14 +701,27 @@ static HRESULT WINAPI ITextRange_fnGetEnd(ITextRange *me, LONG *pcpLim)
return S_OK;
}
+static HRESULT range_SetEnd(ME_TextEditor *editor, LONG cpLim, LONG *start, LONG *end)
+{
+ int len = ME_GetTextLength(editor) + 1;
+
+ TRACE("%d\n", cpLim);
+ if (cpLim == *end)
+ return S_FALSE;
+ cpLim = min(cpLim, len);
+ cpLim = max(cpLim, 0);
+ *start = min(*start, cpLim);
+ *end = cpLim;
+ return S_OK;
+}
+
static HRESULT WINAPI ITextRange_fnSetEnd(ITextRange *me, LONG cpLim)
{
ITextRangeImpl *This = impl_from_ITextRange(me);
if (!This->reOle)
return CO_E_RELEASED;
- FIXME("not implemented %p\n", This);
- return E_NOTIMPL;
+ return range_SetEnd(This->reOle->editor, cpLim, &This->start, &This->end);
}
static HRESULT WINAPI ITextRange_fnGetFont(ITextRange *me, ITextFont **pFont)
@@ -1672,11 +1698,16 @@ static HRESULT WINAPI ITextSelection_fnGetStart(ITextSelection *me, LONG *pcpFir
static HRESULT WINAPI ITextSelection_fnSetStart(ITextSelection *me, LONG cpFirst)
{
ITextSelectionImpl *This = impl_from_ITextSelection(me);
+ int start, end;
+ HRESULT hres;
if (!This->reOle)
return CO_E_RELEASED;
- FIXME("not implemented\n");
- return E_NOTIMPL;
+ ME_GetSelectionOfs(This->reOle->editor, &start, &end);
+ hres = range_SetStart(This->reOle->editor, cpFirst, &start, &end);
+ if (!hres)
+ ME_SetSelection(This->reOle->editor, start, end);
+ return hres;
}
static HRESULT WINAPI ITextSelection_fnGetEnd(ITextSelection *me, LONG *pcpLim)
@@ -1696,11 +1727,16 @@ static HRESULT WINAPI ITextSelection_fnGetEnd(ITextSelection *me, LONG *pcpLim)
static HRESULT WINAPI ITextSelection_fnSetEnd(ITextSelection *me, LONG cpLim)
{
ITextSelectionImpl *This = impl_from_ITextSelection(me);
+ int start, end;
+ HRESULT hres;
if (!This->reOle)
return CO_E_RELEASED;
- FIXME("not implemented\n");
- return E_NOTIMPL;
+ ME_GetSelectionOfs(This->reOle->editor, &start, &end);
+ hres = range_SetEnd(This->reOle->editor, cpLim, &start, &end);
+ if (!hres)
+ ME_SetSelection(This->reOle->editor, start, end);
+ return hres;
}
static HRESULT WINAPI ITextSelection_fnGetFont(ITextSelection *me, ITextFont **pFont)
diff --git a/dlls/riched20/tests/richole.c b/dlls/riched20/tests/richole.c
index 7effc3d..2916bc5 100644
--- a/dlls/riched20/tests/richole.c
+++ b/dlls/riched20/tests/richole.c
@@ -747,6 +747,137 @@ static void test_ITextSelection_Collapse(void)
release_interfaces(&w, &reOle, &txtDoc, &txtSel);
}
+static void test_ITextRange_SetStart(void)
+{
+ HWND w;
+ IRichEditOle *reOle = NULL;
+ ITextDocument *txtDoc = NULL;
+ ITextRange *txtRge = NULL;
+ HRESULT hres;
+ LONG first, lim, start, end;
+ static const CHAR test_text1[] = "TestSomeText";
+
+ create_interfaces(&w, &reOle, &txtDoc, NULL);
+ SendMessageA(w, WM_SETTEXT, 0, (LPARAM)test_text1);
+
+ first = 4, lim = 8;
+ ITextDocument_Range(txtDoc, first, lim, &txtRge);
+ hres = ITextRange_SetStart(txtRge, first);
+ ok(hres == S_FALSE, "ITextRange_SetStart\n");
+
+#define TEST_TXTRGE_SETSTART(cp, expected_start, expected_end) \
+ hres = ITextRange_SetStart(txtRge, cp); \
+ ok(hres == S_OK, "ITextRange_SetStart\n"); \
+ ITextRange_GetStart(txtRge, &start); \
+ ITextRange_GetEnd(txtRge, &end); \
+ ok(start == expected_start, "got wrong start value: %d\n", start); \
+ ok(end == expected_end, "got wrong end value: %d\n", end);
+
+ TEST_TXTRGE_SETSTART(2, 2, 8)
+ TEST_TXTRGE_SETSTART(-1, 0, 8)
+ TEST_TXTRGE_SETSTART(13, 12, 12)
+
+ release_interfaces(&w, &reOle, &txtDoc, NULL);
+}
+
+static void test_ITextRange_SetEnd(void)
+{
+ HWND w;
+ IRichEditOle *reOle = NULL;
+ ITextDocument *txtDoc = NULL;
+ ITextRange *txtRge = NULL;
+ HRESULT hres;
+ LONG first, lim, start, end;
+ static const CHAR test_text1[] = "TestSomeText";
+
+ create_interfaces(&w, &reOle, &txtDoc, NULL);
+ SendMessageA(w, WM_SETTEXT, 0, (LPARAM)test_text1);
+
+ first = 4, lim = 8;
+ ITextDocument_Range(txtDoc, first, lim, &txtRge);
+ hres = ITextRange_SetEnd(txtRge, lim);
+ ok(hres == S_FALSE, "ITextRange_SetEnd\n");
+
+#define TEST_TXTRGE_SETEND(cp, expected_start, expected_end) \
+ hres = ITextRange_SetEnd(txtRge, cp); \
+ ok(hres == S_OK, "ITextRange_SetEnd\n"); \
+ ITextRange_GetStart(txtRge, &start); \
+ ITextRange_GetEnd(txtRge, &end); \
+ ok(start == expected_start, "got wrong start value: %d\n", start); \
+ ok(end == expected_end, "got wrong end value: %d\n", end);
+
+ TEST_TXTRGE_SETEND(6, 4, 6)
+ TEST_TXTRGE_SETEND(14, 4, 13)
+ TEST_TXTRGE_SETEND(-1, 0, 0)
+
+ ITextRange_Release(txtRge);
+ release_interfaces(&w, &reOle, &txtDoc, NULL);
+}
+
+static void test_ITextSelection_SetStart(void)
+{
+ HWND w;
+ IRichEditOle *reOle = NULL;
+ ITextDocument *txtDoc = NULL;
+ ITextSelection *txtSel = NULL;
+ HRESULT hres;
+ LONG first, lim, start, end;
+ static const CHAR test_text1[] = "TestSomeText";
+
+ create_interfaces(&w, &reOle, &txtDoc, &txtSel);
+ SendMessageA(w, WM_SETTEXT, 0, (LPARAM)test_text1);
+
+ first = 4, lim = 8;
+ SendMessageA(w, EM_SETSEL, first, lim);
+ hres = ITextSelection_SetStart(txtSel, first);
+ ok(hres == S_FALSE, "ITextSelection_SetStart\n");
+
+#define TEST_TXTSEL_SETSTART(cp, expected_start, expected_end) \
+ hres = ITextSelection_SetStart(txtSel, cp); \
+ ok(hres == S_OK, "ITextSelection_SetStart\n"); \
+ SendMessageA(w, EM_GETSEL, (LPARAM)&start, (WPARAM)&end); \
+ ok(start == expected_start, "got wrong start value: %d\n", start); \
+ ok(end == expected_end, "got wrong end value: %d\n", end);
+
+ TEST_TXTSEL_SETSTART(2, 2, 8)
+ TEST_TXTSEL_SETSTART(-1, 0, 8)
+ TEST_TXTSEL_SETSTART(13, 12, 12)
+
+ release_interfaces(&w, &reOle, &txtDoc, &txtSel);
+}
+
+static void test_ITextSelection_SetEnd(void)
+{
+ HWND w;
+ IRichEditOle *reOle = NULL;
+ ITextDocument *txtDoc = NULL;
+ ITextSelection *txtSel = NULL;
+ HRESULT hres;
+ LONG first, lim, start, end;
+ static const CHAR test_text1[] = "TestSomeText";
+
+ create_interfaces(&w, &reOle, &txtDoc, &txtSel);
+ SendMessageA(w, WM_SETTEXT, 0, (LPARAM)test_text1);
+
+ first = 4, lim = 8;
+ SendMessageA(w, EM_SETSEL, first, lim);
+ hres = ITextSelection_SetEnd(txtSel, lim);
+ ok(hres == S_FALSE, "ITextSelection_SetEnd\n");
+
+#define TEST_TXTSEL_SETEND(cp, expected_start, expected_end) \
+ hres = ITextSelection_SetEnd(txtSel, cp); \
+ ok(hres == S_OK, "ITextSelection_SetEnd\n"); \
+ SendMessageA(w, EM_GETSEL, (LPARAM)&start, (WPARAM)&end); \
+ ok(start == expected_start, "got wrong start value: %d\n", start); \
+ ok(end == expected_end, "got wrong end value: %d\n", end);
+
+ TEST_TXTSEL_SETEND(6, 4, 6)
+ TEST_TXTSEL_SETEND(14, 4, 13)
+ TEST_TXTSEL_SETEND(-1, 0, 0)
+
+ release_interfaces(&w, &reOle, &txtDoc, &txtSel);
+}
+
START_TEST(richole)
{
/* Must explicitly LoadLibrary(). The test has no references to functions in
@@ -758,10 +889,14 @@ START_TEST(richole)
test_ITextDocument_Open();
test_ITextSelection_GetText();
test_ITextSelection_GetChar();
+ test_ITextSelection_SetStart();
+ test_ITextSelection_SetEnd();
test_ITextSelection_Collapse();
test_ITextDocument_Range();
test_ITextRange_GetChar();
test_ITextRange_GetDuplicate();
test_GetStart_GetEnd();
test_ITextRange_Collapse();
+ test_ITextRange_SetStart();
+ test_ITextRange_SetEnd();
}
--
1.7.9.5

View File

@ -0,0 +1,18 @@
Author: Jactry Zeng
Subject: Implement Stubs for ITextRange interface.
Revision: 1
Author: Jactry Zeng
Subject: Implement IText{Range,Selection}::{GetChar,GetStart,GetEnd,GetDuplicate,Collapse,SetStart,SetEnd}.
Revision: 1
Author: Jactry Zeng
Subject: Implement Stubs for ITextFont interface.
Revision: 1
Author: Jactry Zeng
Subject: Implement Stubs for ITextPara interface.
Revision: 1
Fixes: [12458] Implement ITextDocument_fnRange function
Fixes: [18303] Support for ITextRange, ITextFont and ITextPara