Wine-devel
Threads by month
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2003 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2002 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2001 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
March 2021
- 75 participants
- 800 discussions
Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com>
---
dlls/dwrite/tests/font.c | 165 +++++++++++++++++++++++++++++++++++++--
1 file changed, 159 insertions(+), 6 deletions(-)
diff --git a/dlls/dwrite/tests/font.c b/dlls/dwrite/tests/font.c
index d7ced109a2f..24ad30bc845 100644
--- a/dlls/dwrite/tests/font.c
+++ b/dlls/dwrite/tests/font.c
@@ -124,7 +124,7 @@ static void _expect_ref_broken(IUnknown* obj, ULONG ref, ULONG brokenref, int li
static BOOL (WINAPI *pGetFontRealizationInfo)(HDC hdc, void *);
-static const WCHAR test_fontfile[] = {'w','i','n','e','_','t','e','s','t','_','f','o','n','t','.','t','t','f',0};
+static const WCHAR test_fontfile[] = L"wine_test_font.ttf";
/* PANOSE is 10 bytes in size, need to pack the structure properly */
#include "pshpack2.h"
@@ -9363,10 +9363,15 @@ static void test_AnalyzeContainerType(void)
static void test_fontsetbuilder(void)
{
+ IDWriteFontFaceReference *ref, *ref2, *ref3;
IDWriteFontCollection1 *collection;
+ IDWriteFontSetBuilder1 *builder1;
IDWriteFontSetBuilder *builder;
IDWriteFactory3 *factory;
- UINT32 count, i, ref;
+ UINT32 count, i, refcount;
+ IDWriteFontSet *fontset;
+ IDWriteFontFile *file;
+ WCHAR *path;
HRESULT hr;
factory = create_factory_iid(&IID_IDWriteFactory3);
@@ -9380,6 +9385,40 @@ static void test_fontsetbuilder(void)
hr = IDWriteFactory3_CreateFontSetBuilder(factory, &builder);
ok(hr == S_OK, "Failed to create font set builder, hr %#x.\n", hr);
EXPECT_REF(factory, 2);
+
+ if (SUCCEEDED(hr = IDWriteFontSetBuilder_QueryInterface(builder, &IID_IDWriteFontSetBuilder1, (void **)&builder1)))
+ {
+ path = create_testfontfile(test_fontfile);
+
+ hr = IDWriteFactory3_CreateFontFileReference(factory, path, NULL, &file);
+ ok(hr == S_OK, "Unexpected hr %#x.\n",hr);
+
+ hr = IDWriteFontSetBuilder1_AddFontFile(builder1, file);
+ todo_wine
+ ok(hr == S_OK, "Unexpected hr %#x.\n",hr);
+
+ hr = IDWriteFontSetBuilder1_AddFontFile(builder1, file);
+ todo_wine
+ ok(hr == S_OK, "Unexpected hr %#x.\n",hr);
+
+ hr = IDWriteFontSetBuilder1_CreateFontSet(builder1, &fontset);
+ todo_wine
+ ok(hr == S_OK, "Unexpected hr %#x.\n",hr);
+
+ if (SUCCEEDED(hr))
+ {
+ /* No attempt to eliminate duplicates. */
+ count = IDWriteFontSet_GetFontCount(fontset);
+ ok(count == 2, "Unexpected font count %u.\n", count);
+
+ IDWriteFontSet_Release(fontset);
+ }
+
+ IDWriteFontFile_Release(file);
+ IDWriteFontSetBuilder1_Release(builder1);
+ }
+ else
+ win_skip("IDWriteFontSetBuilder1 is not available.\n");
IDWriteFontSetBuilder_Release(builder);
hr = IDWriteFactory3_GetSystemFontCollection(factory, FALSE, &collection, FALSE);
@@ -9395,8 +9434,8 @@ static void test_fontsetbuilder(void)
ok(hr == S_OK, "Failed to get family, hr %#x.\n", hr);
fontcount = IDWriteFontFamily1_GetFontCount(family);
- for (j = 0; j < fontcount; j++) {
- IDWriteFontFaceReference *ref, *ref2;
+ for (j = 0; j < fontcount; ++j)
+ {
IDWriteFontSet *fontset;
UINT32 setcount, id;
@@ -9428,6 +9467,12 @@ static void test_fontsetbuilder(void)
hr = IDWriteFontSet_GetFontFaceReference(fontset, 0, &ref2);
ok(hr == S_OK, "Failed to get font face reference, hr %#x.\n", hr);
ok(ref2 != ref, "Unexpected reference.\n");
+
+ hr = IDWriteFontSet_GetFontFaceReference(fontset, 0, &ref3);
+ ok(hr == S_OK, "Failed to get font face reference, hr %#x.\n", hr);
+ ok(ref2 != ref3, "Unexpected reference.\n");
+
+ IDWriteFontFaceReference_Release(ref3);
IDWriteFontFaceReference_Release(ref2);
for (id = DWRITE_FONT_PROPERTY_ID_FAMILY_NAME; id < DWRITE_FONT_PROPERTY_ID_TOTAL; ++id)
@@ -9499,8 +9544,8 @@ static void test_fontsetbuilder(void)
IDWriteFontCollection1_Release(collection);
- ref = IDWriteFactory3_Release(factory);
- ok(ref == 0, "factory not released, %u\n", ref);
+ refcount = IDWriteFactory3_Release(factory);
+ ok(!refcount, "Factory not released, %u.\n", refcount);
}
static void test_font_resource(void)
@@ -9805,6 +9850,112 @@ static void test_GetVerticalGlyphVariants(void)
ok(!refcount, "Factory not released, refcount %u.\n", refcount);
}
+static HANDLE get_collection_expiration_event(IDWriteFontCollection *collection)
+{
+ IDWriteFontCollection3 *collection3;
+ HANDLE event;
+ HRESULT hr;
+
+ hr = IDWriteFontCollection_QueryInterface(collection, &IID_IDWriteFontCollection3, (void **)&collection3);
+ ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+ event = IDWriteFontCollection3_GetExpirationEvent(collection3);
+ IDWriteFontCollection3_Release(collection3);
+
+ return event;
+}
+
+static void test_expiration_event(void)
+{
+ IDWriteFontCollection *collection, *collection2;
+ IDWriteFontCollection3 *collection3;
+ IDWriteFactory *factory, *factory2;
+ unsigned int refcount;
+ HANDLE event, event2;
+ HRESULT hr;
+
+ factory = create_factory();
+
+ hr = IDWriteFactory_GetSystemFontCollection(factory, &collection, FALSE);
+ ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+
+ hr = IDWriteFontCollection_QueryInterface(collection, &IID_IDWriteFontCollection3, (void **)&collection3);
+ if (FAILED(hr))
+ {
+ win_skip("Expiration events are not supported.\n");
+ IDWriteFontCollection_Release(collection);
+ IDWriteFactory_Release(factory);
+ return;
+ }
+ IDWriteFontCollection3_Release(collection3);
+
+ event = get_collection_expiration_event(collection);
+todo_wine
+ ok(!!event, "Unexpected event handle.\n");
+
+ /* Compare handles with another isolated factory. */
+ factory2 = create_factory();
+
+ hr = IDWriteFactory_GetSystemFontCollection(factory2, &collection2, FALSE);
+ ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+ event2 = get_collection_expiration_event(collection2);
+todo_wine {
+ ok(!!event2, "Unexpected event handle.\n");
+ ok(event != event2, "Unexpected event handle.\n");
+}
+ IDWriteFontCollection_Release(collection2);
+
+ IDWriteFontCollection_Release(collection);
+
+ refcount = IDWriteFactory_Release(factory2);
+ ok(!refcount, "Unexpected factory refcount %u.\n", refcount);
+ refcount = IDWriteFactory_Release(factory);
+ ok(!refcount, "Unexpected factory refcount %u.\n", refcount);
+}
+
+static void test_family_font_set(void)
+{
+ IDWriteFontCollection *collection;
+ IDWriteFontFamily2 *family2;
+ IDWriteFontFamily *family;
+ IDWriteFactory *factory;
+ unsigned int refcount;
+ IDWriteFontSet1 *fontset, *fontset2;
+ HRESULT hr;
+
+ factory = create_factory();
+
+ hr = IDWriteFactory_GetSystemFontCollection(factory, &collection, FALSE);
+ ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+
+ hr = IDWriteFontCollection_GetFontFamily(collection, 0, &family);
+ ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+
+ if (SUCCEEDED(IDWriteFontFamily_QueryInterface(family, &IID_IDWriteFontFamily2, (void **)&family2)))
+ {
+ hr = IDWriteFontFamily2_GetFontSet(family2, &fontset);
+ todo_wine
+ ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+ hr = IDWriteFontFamily2_GetFontSet(family2, &fontset2);
+ todo_wine
+ ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+ if (SUCCEEDED(hr))
+ {
+ ok(fontset != fontset2, "Unexpected fontset instance.\n");
+ IDWriteFontSet1_Release(fontset2);
+ IDWriteFontSet1_Release(fontset);
+ }
+ IDWriteFontFamily2_Release(family2);
+ }
+ else
+ win_skip("IDWriteFontFamily2 is not supported.\n");
+
+ IDWriteFontFamily_Release(family);
+ IDWriteFontCollection_Release(collection);
+
+ refcount = IDWriteFactory_Release(factory);
+ ok(!refcount, "Unexpected factory refcount %u.\n", refcount);
+}
+
START_TEST(font)
{
IDWriteFactory *factory;
@@ -9875,6 +10026,8 @@ START_TEST(font)
test_font_resource();
test_IsColorFont();
test_GetVerticalGlyphVariants();
+ test_expiration_event();
+ test_family_font_set();
IDWriteFactory_Release(factory);
}
--
2.30.1
1
1
[PATCH] dwrite: Do not segfault if typographic features tag table is empty.
by Giovanni Mascellani 03 Mar '21
by Giovanni Mascellani 03 Mar '21
03 Mar '21
Signed-off-by: Giovanni Mascellani <gmascellani(a)codeweavers.com>
---
dlls/dwrite/shape.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/dwrite/shape.c b/dlls/dwrite/shape.c
index 6428bf6ceb0..d425c189a58 100644
--- a/dlls/dwrite/shape.c
+++ b/dlls/dwrite/shape.c
@@ -380,7 +380,7 @@ HRESULT shape_get_typographic_features(struct scriptshaping_context *context, co
if (t.tags[i] != t.tags[j])
t.tags[++j] = t.tags[i];
}
- t.count = j + 1;
+ t.count = t.count > 0 ? j + 1 : 0;
if (t.count <= max_tagcount)
memcpy(tags, t.tags, t.count * sizeof(*t.tags));
--
2.30.1
2
1
[PATCH 5/5] riched20: The text host should create the text services object.
by Huw Davies 03 Mar '21
by Huw Davies 03 Mar '21
03 Mar '21
For now, we hold on to the editor too; this will eventually go away.
Signed-off-by: Huw Davies <huw(a)codeweavers.com>
---
dlls/riched20/editor.h | 3 +++
dlls/riched20/txthost.c | 30 +++++++++++++----------
dlls/riched20/txtsrv.c | 53 ++++++++++++++++++++++-------------------
3 files changed, 49 insertions(+), 37 deletions(-)
diff --git a/dlls/riched20/editor.h b/dlls/riched20/editor.h
index e226bc02921..38d99f4351a 100644
--- a/dlls/riched20/editor.h
+++ b/dlls/riched20/editor.h
@@ -377,6 +377,9 @@ BOOL ME_Undo(ME_TextEditor *editor) DECLSPEC_HIDDEN;
BOOL ME_Redo(ME_TextEditor *editor) DECLSPEC_HIDDEN;
void ME_EmptyUndoStack(ME_TextEditor *editor) DECLSPEC_HIDDEN;
+/* txtsrv.c */
+HRESULT create_text_services( IUnknown *outer, ITextHost *text_host, IUnknown **unk, BOOL emulate_10, ME_TextEditor **editor ) DECLSPEC_HIDDEN;
+
/* writer.c */
LRESULT ME_StreamOutRange(ME_TextEditor *editor, DWORD dwFormat, const ME_Cursor *start, int nChars, EDITSTREAM *stream) DECLSPEC_HIDDEN;
LRESULT ME_StreamOut(ME_TextEditor *editor, DWORD dwFormat, EDITSTREAM *stream) DECLSPEC_HIDDEN;
diff --git a/dlls/riched20/txthost.c b/dlls/riched20/txthost.c
index d0b43add364..1da34555352 100644
--- a/dlls/riched20/txthost.c
+++ b/dlls/riched20/txthost.c
@@ -36,6 +36,8 @@ struct host
{
ITextHost ITextHost_iface;
LONG ref;
+ ITextServices *text_srv;
+ ME_TextEditor *editor; /* to be removed */
HWND window;
BOOL emulate_10;
PARAFORMAT2 para_fmt;
@@ -46,7 +48,7 @@ static const ITextHostVtbl textHostVtbl;
static BOOL listbox_registered;
static BOOL combobox_registered;
-static ITextHost *host_create( HWND hwnd, CREATESTRUCTW *cs, BOOL emulate_10 )
+struct host *host_create( HWND hwnd, CREATESTRUCTW *cs, BOOL emulate_10 )
{
struct host *texthost;
@@ -66,7 +68,7 @@ static ITextHost *host_create( HWND hwnd, CREATESTRUCTW *cs, BOOL emulate_10 )
if (cs->style & ES_CENTER)
texthost->para_fmt.wAlignment = PFA_CENTER;
- return &texthost->ITextHost_iface;
+ return texthost;
}
static inline struct host *impl_from_ITextHost( ITextHost *iface )
@@ -104,6 +106,7 @@ static ULONG WINAPI ITextHostImpl_Release(ITextHost *iface)
if (!ref)
{
SetWindowLongPtrW( host->window, 0, 0 );
+ ITextServices_Release( host->text_srv );
CoTaskMemFree( host );
}
return ref;
@@ -723,24 +726,27 @@ static const char *get_msg_name( UINT msg )
static BOOL create_windowed_editor( HWND hwnd, CREATESTRUCTW *create, BOOL emulate_10 )
{
- ITextHost *host = host_create( hwnd, create, emulate_10 );
- ME_TextEditor *editor;
+ struct host *host = host_create( hwnd, create, emulate_10 );
+ IUnknown *unk;
+ HRESULT hr;
if (!host) return FALSE;
- editor = ME_MakeEditor( host, emulate_10 );
- if (!editor)
+ hr = create_text_services( NULL, &host->ITextHost_iface, &unk, emulate_10, &host->editor );
+ if (FAILED( hr ))
{
- ITextHost_Release( host );
+ ITextHost_Release( &host->ITextHost_iface );
return FALSE;
}
+ IUnknown_QueryInterface( unk, &IID_ITextServices, (void **)&host->text_srv );
+ IUnknown_Release( unk );
- editor->exStyleFlags = GetWindowLongW( hwnd, GWL_EXSTYLE );
- editor->styleFlags |= GetWindowLongW( hwnd, GWL_STYLE ) & ES_WANTRETURN;
- editor->hWnd = hwnd; /* FIXME: Remove editor's dependence on hWnd */
- editor->hwndParent = create->hwndParent;
+ host->editor->exStyleFlags = GetWindowLongW( hwnd, GWL_EXSTYLE );
+ host->editor->styleFlags |= GetWindowLongW( hwnd, GWL_STYLE ) & ES_WANTRETURN;
+ host->editor->hWnd = hwnd; /* FIXME: Remove editor's dependence on hWnd */
+ host->editor->hwndParent = create->hwndParent;
- SetWindowLongPtrW( hwnd, 0, (LONG_PTR)editor );
+ SetWindowLongPtrW( hwnd, 0, (LONG_PTR)host->editor );
return TRUE;
}
diff --git a/dlls/riched20/txtsrv.c b/dlls/riched20/txtsrv.c
index fc8d6765424..3d0eec6f769 100644
--- a/dlls/riched20/txtsrv.c
+++ b/dlls/riched20/txtsrv.c
@@ -368,33 +368,36 @@ static const ITextServicesVtbl textservices_vtbl =
THISCALL(fnTextSrv_TxGetCachedSize)
};
+HRESULT create_text_services( IUnknown *outer, ITextHost *text_host, IUnknown **unk, BOOL emulate_10,
+ ME_TextEditor **editor )
+{
+ struct text_services *services;
+
+ TRACE( "%p %p --> %p\n", outer, text_host, unk );
+ if (text_host == NULL) return E_POINTER;
+
+ services = CoTaskMemAlloc( sizeof(*services) );
+ if (services == NULL) return E_OUTOFMEMORY;
+ InitializeCriticalSection( &services->csTxtSrv );
+ services->csTxtSrv.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": ITextServicesImpl.csTxtSrv");
+ services->ref = 1;
+ services->host = text_host; /* Don't take a ref of the host - this would lead to a mutual dependency */
+ services->IUnknown_inner.lpVtbl = &textservices_inner_vtbl;
+ services->ITextServices_iface.lpVtbl = &textservices_vtbl;
+ services->editor = ME_MakeEditor( text_host, emulate_10 );
+ if (editor) *editor = services->editor; /* To be removed */
+
+ if (outer) services->outer_unk = outer;
+ else services->outer_unk = &services->IUnknown_inner;
+
+ *unk = &services->IUnknown_inner;
+ return S_OK;
+}
+
/******************************************************************
* CreateTextServices (RICHED20.4)
*/
-HRESULT WINAPI CreateTextServices(IUnknown *pUnkOuter, ITextHost *pITextHost, IUnknown **ppUnk)
+HRESULT WINAPI CreateTextServices( IUnknown *outer, ITextHost *text_host, IUnknown **unk )
{
- struct text_services *ITextImpl;
-
- TRACE("%p %p --> %p\n", pUnkOuter, pITextHost, ppUnk);
- if (pITextHost == NULL)
- return E_POINTER;
-
- ITextImpl = CoTaskMemAlloc(sizeof(*ITextImpl));
- if (ITextImpl == NULL)
- return E_OUTOFMEMORY;
- InitializeCriticalSection(&ITextImpl->csTxtSrv);
- ITextImpl->csTxtSrv.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": ITextServicesImpl.csTxtSrv");
- ITextImpl->ref = 1;
- ITextImpl->host = pITextHost; /* Don't take a ref of the host - this would lead to a mutual dependency */
- ITextImpl->IUnknown_inner.lpVtbl = &textservices_inner_vtbl;
- ITextImpl->ITextServices_iface.lpVtbl = &textservices_vtbl;
- ITextImpl->editor = ME_MakeEditor(pITextHost, FALSE);
-
- if (pUnkOuter)
- ITextImpl->outer_unk = pUnkOuter;
- else
- ITextImpl->outer_unk = &ITextImpl->IUnknown_inner;
-
- *ppUnk = &ITextImpl->IUnknown_inner;
- return S_OK;
+ return create_text_services( outer, text_host, unk, FALSE, NULL );
}
--
2.23.0
1
0
This would result in the host and services objects holding
refs on each other.
Signed-off-by: Huw Davies <huw(a)codeweavers.com>
---
dlls/riched20/editor.c | 1 -
dlls/riched20/tests/txtsrv.c | 1 +
dlls/riched20/txtsrv.c | 5 ++---
3 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c
index 487d4137391..516cd104d31 100644
--- a/dlls/riched20/editor.c
+++ b/dlls/riched20/editor.c
@@ -3221,7 +3221,6 @@ void ME_DestroyEditor(ME_TextEditor *editor)
DeleteObject(editor->hbrBackground);
if(editor->lpOleCallback)
IRichEditOleCallback_Release(editor->lpOleCallback);
- ITextHost_Release(editor->texthost);
if (editor->reOle)
{
IUnknown_Release(editor->reOle);
diff --git a/dlls/riched20/tests/txtsrv.c b/dlls/riched20/tests/txtsrv.c
index 1528bef5238..f41375d871a 100644
--- a/dlls/riched20/tests/txtsrv.c
+++ b/dlls/riched20/tests/txtsrv.c
@@ -602,6 +602,7 @@ static BOOL init_texthost(ITextServices **txtserv, ITextHost **ret)
ITextServices object. */
result = pCreateTextServices(NULL, &dummyTextHost->ITextHost_iface, &init);
ok(result == S_OK, "Did not return S_OK when created (result = %x)\n", result);
+ ok(dummyTextHost->refCount == 1, "host ref %d\n", dummyTextHost->refCount);
if (result != S_OK) {
CoTaskMemFree(dummyTextHost);
win_skip("CreateTextServices failed.\n");
diff --git a/dlls/riched20/txtsrv.c b/dlls/riched20/txtsrv.c
index 6f8e3cd3fa3..fc8d6765424 100644
--- a/dlls/riched20/txtsrv.c
+++ b/dlls/riched20/txtsrv.c
@@ -38,7 +38,7 @@ struct text_services
ITextServices ITextServices_iface;
IUnknown *outer_unk;
LONG ref;
- ITextHost *pMyHost;
+ ITextHost *host;
CRITICAL_SECTION csTxtSrv;
ME_TextEditor *editor;
char spare[256];
@@ -385,8 +385,7 @@ HRESULT WINAPI CreateTextServices(IUnknown *pUnkOuter, ITextHost *pITextHost, I
InitializeCriticalSection(&ITextImpl->csTxtSrv);
ITextImpl->csTxtSrv.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": ITextServicesImpl.csTxtSrv");
ITextImpl->ref = 1;
- ITextHost_AddRef(pITextHost);
- ITextImpl->pMyHost = pITextHost;
+ ITextImpl->host = pITextHost; /* Don't take a ref of the host - this would lead to a mutual dependency */
ITextImpl->IUnknown_inner.lpVtbl = &textservices_inner_vtbl;
ITextImpl->ITextServices_iface.lpVtbl = &textservices_vtbl;
ITextImpl->editor = ME_MakeEditor(pITextHost, FALSE);
--
2.23.0
1
0
03 Mar '21
Signed-off-by: Huw Davies <huw(a)codeweavers.com>
---
dlls/riched20/txtsrv.c | 350 ++++++++++++++++++++---------------------
1 file changed, 169 insertions(+), 181 deletions(-)
diff --git a/dlls/riched20/txtsrv.c b/dlls/riched20/txtsrv.c
index 3fd4ae540c5..6f8e3cd3fa3 100644
--- a/dlls/riched20/txtsrv.c
+++ b/dlls/riched20/txtsrv.c
@@ -32,7 +32,8 @@
WINE_DEFAULT_DEBUG_CHANNEL(richedit);
-typedef struct ITextServicesImpl {
+struct text_services
+{
IUnknown IUnknown_inner;
ITextServices ITextServices_iface;
IUnknown *outer_unk;
@@ -41,64 +42,64 @@ typedef struct ITextServicesImpl {
CRITICAL_SECTION csTxtSrv;
ME_TextEditor *editor;
char spare[256];
-} ITextServicesImpl;
+};
-static inline ITextServicesImpl *impl_from_IUnknown(IUnknown *iface)
+static inline struct text_services *impl_from_IUnknown( IUnknown *iface )
{
- return CONTAINING_RECORD(iface, ITextServicesImpl, IUnknown_inner);
+ return CONTAINING_RECORD( iface, struct text_services, IUnknown_inner );
}
-static HRESULT WINAPI ITextServicesImpl_QueryInterface(IUnknown *iface, REFIID riid, void **ppv)
+static HRESULT WINAPI ITextServicesImpl_QueryInterface( IUnknown *iface, REFIID iid, void **obj )
{
- ITextServicesImpl *This = impl_from_IUnknown(iface);
-
- TRACE("(%p)->(%s, %p)\n", iface, debugstr_guid(riid), ppv);
-
- if (IsEqualIID(riid, &IID_IUnknown))
- *ppv = &This->IUnknown_inner;
- else if (IsEqualIID(riid, &IID_ITextServices))
- *ppv = &This->ITextServices_iface;
- else if (IsEqualIID(riid, &IID_IRichEditOle) || IsEqualIID(riid, &IID_ITextDocument) ||
- IsEqualIID(riid, &IID_ITextDocument2Old)) {
- if (!This->editor->reOle)
- if (!CreateIRichEditOle(This->outer_unk, This->editor, (void **)(&This->editor->reOle)))
+ struct text_services *services = impl_from_IUnknown( iface );
+
+ TRACE( "(%p)->(%s, %p)\n", iface, debugstr_guid( iid ), obj );
+
+ if (IsEqualIID( iid, &IID_IUnknown )) *obj = &services->IUnknown_inner;
+ else if (IsEqualIID( iid, &IID_ITextServices )) *obj = &services->ITextServices_iface;
+ else if (IsEqualIID( iid, &IID_IRichEditOle ) || IsEqualIID( iid, &IID_ITextDocument ) ||
+ IsEqualIID( iid, &IID_ITextDocument2Old ))
+ {
+ if (!services->editor->reOle && !CreateIRichEditOle( services->outer_unk, services->editor, (void **)&services->editor->reOle ))
return E_OUTOFMEMORY;
- return IUnknown_QueryInterface(This->editor->reOle, riid, ppv);
- } else {
- *ppv = NULL;
- FIXME("Unknown interface: %s\n", debugstr_guid(riid));
- return E_NOINTERFACE;
- }
-
- IUnknown_AddRef((IUnknown*)*ppv);
- return S_OK;
+ return IUnknown_QueryInterface( services->editor->reOle, iid, obj );
+ }
+ else
+ {
+ *obj = NULL;
+ FIXME( "Unknown interface: %s\n", debugstr_guid( iid ) );
+ return E_NOINTERFACE;
+ }
+
+ IUnknown_AddRef( (IUnknown *)*obj );
+ return S_OK;
}
static ULONG WINAPI ITextServicesImpl_AddRef(IUnknown *iface)
{
- ITextServicesImpl *This = impl_from_IUnknown(iface);
- LONG ref = InterlockedIncrement(&This->ref);
+ struct text_services *services = impl_from_IUnknown( iface );
+ LONG ref = InterlockedIncrement( &services->ref );
- TRACE("(%p) ref=%d\n", This, ref);
+ TRACE( "(%p) ref = %d\n", services, ref );
- return ref;
+ return ref;
}
static ULONG WINAPI ITextServicesImpl_Release(IUnknown *iface)
{
- ITextServicesImpl *This = impl_from_IUnknown(iface);
- LONG ref = InterlockedDecrement(&This->ref);
-
- TRACE("(%p) ref=%d\n", This, ref);
-
- if (!ref)
- {
- ME_DestroyEditor(This->editor);
- This->csTxtSrv.DebugInfo->Spare[0] = 0;
- DeleteCriticalSection(&This->csTxtSrv);
- CoTaskMemFree(This);
- }
- return ref;
+ struct text_services *services = impl_from_IUnknown( iface );
+ LONG ref = InterlockedDecrement( &services->ref );
+
+ TRACE( "(%p) ref = %d\n", services, ref );
+
+ if (!ref)
+ {
+ ME_DestroyEditor( services->editor );
+ services->csTxtSrv.DebugInfo->Spare[0] = 0;
+ DeleteCriticalSection( &services->csTxtSrv );
+ CoTaskMemFree( services );
+ }
+ return ref;
}
static const IUnknownVtbl textservices_inner_vtbl =
@@ -108,38 +109,38 @@ static const IUnknownVtbl textservices_inner_vtbl =
ITextServicesImpl_Release
};
-static inline ITextServicesImpl *impl_from_ITextServices(ITextServices *iface)
+static inline struct text_services *impl_from_ITextServices( ITextServices *iface )
{
- return CONTAINING_RECORD(iface, ITextServicesImpl, ITextServices_iface);
+ return CONTAINING_RECORD( iface, struct text_services, ITextServices_iface );
}
-static HRESULT WINAPI fnTextSrv_QueryInterface(ITextServices *iface, REFIID riid, void **ppv)
+static HRESULT WINAPI fnTextSrv_QueryInterface( ITextServices *iface, REFIID iid, void **obj )
{
- ITextServicesImpl *This = impl_from_ITextServices(iface);
- return IUnknown_QueryInterface(This->outer_unk, riid, ppv);
+ struct text_services *services = impl_from_ITextServices( iface );
+ return IUnknown_QueryInterface( services->outer_unk, iid, obj );
}
static ULONG WINAPI fnTextSrv_AddRef(ITextServices *iface)
{
- ITextServicesImpl *This = impl_from_ITextServices(iface);
- return IUnknown_AddRef(This->outer_unk);
+ struct text_services *services = impl_from_ITextServices( iface );
+ return IUnknown_AddRef( services->outer_unk );
}
static ULONG WINAPI fnTextSrv_Release(ITextServices *iface)
{
- ITextServicesImpl *This = impl_from_ITextServices(iface);
- return IUnknown_Release(This->outer_unk);
+ struct text_services *services = impl_from_ITextServices( iface );
+ return IUnknown_Release( services->outer_unk );
}
DEFINE_THISCALL_WRAPPER(fnTextSrv_TxSendMessage,20)
DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_TxSendMessage(ITextServices *iface, UINT msg, WPARAM wparam,
LPARAM lparam, LRESULT *plresult)
{
- ITextServicesImpl *This = impl_from_ITextServices(iface);
+ struct text_services *services = impl_from_ITextServices( iface );
HRESULT hresult;
LRESULT lresult;
- lresult = ME_HandleMessage(This->editor, msg, wparam, lparam, TRUE, &hresult);
+ lresult = ME_HandleMessage( services->editor, msg, wparam, lparam, TRUE, &hresult );
if (plresult) *plresult = lresult;
return hresult;
}
@@ -151,48 +152,38 @@ DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_TxDraw(ITextServices *iface, DWORD
BOOL (CALLBACK * pfnContinue)(DWORD), DWORD dwContinue,
LONG lViewId)
{
- ITextServicesImpl *This = impl_from_ITextServices(iface);
+ struct text_services *services = impl_from_ITextServices( iface );
- FIXME("%p: STUB\n", This);
- return E_NOTIMPL;
+ FIXME( "%p: STUB\n", services );
+ return E_NOTIMPL;
}
DEFINE_THISCALL_WRAPPER(fnTextSrv_TxGetHScroll,24)
-DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_TxGetHScroll(ITextServices *iface, LONG *plMin, LONG *plMax, LONG *plPos,
- LONG *plPage, BOOL *pfEnabled)
+DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_TxGetHScroll( ITextServices *iface, LONG *min_pos, LONG *max_pos, LONG *pos,
+ LONG *page, BOOL *enabled )
{
- ITextServicesImpl *This = impl_from_ITextServices(iface);
-
- if (plMin)
- *plMin = This->editor->horz_si.nMin;
- if (plMax)
- *plMax = This->editor->horz_si.nMax;
- if (plPos)
- *plPos = This->editor->horz_si.nPos;
- if (plPage)
- *plPage = This->editor->horz_si.nPage;
- if (pfEnabled)
- *pfEnabled = (This->editor->styleFlags & WS_HSCROLL) != 0;
- return S_OK;
+ struct text_services *services = impl_from_ITextServices( iface );
+
+ if (min_pos) *min_pos = services->editor->horz_si.nMin;
+ if (max_pos) *max_pos = services->editor->horz_si.nMax;
+ if (pos) *pos = services->editor->horz_si.nPos;
+ if (page) *page = services->editor->horz_si.nPage;
+ if (enabled) *enabled = (services->editor->styleFlags & WS_HSCROLL) != 0;
+ return S_OK;
}
DEFINE_THISCALL_WRAPPER(fnTextSrv_TxGetVScroll,24)
-DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_TxGetVScroll(ITextServices *iface, LONG *plMin, LONG *plMax, LONG *plPos,
- LONG *plPage, BOOL *pfEnabled)
+DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_TxGetVScroll( ITextServices *iface, LONG *min_pos, LONG *max_pos, LONG *pos,
+ LONG *page, BOOL *enabled )
{
- ITextServicesImpl *This = impl_from_ITextServices(iface);
-
- if (plMin)
- *plMin = This->editor->vert_si.nMin;
- if (plMax)
- *plMax = This->editor->vert_si.nMax;
- if (plPos)
- *plPos = This->editor->vert_si.nPos;
- if (plPage)
- *plPage = This->editor->vert_si.nPage;
- if (pfEnabled)
- *pfEnabled = (This->editor->styleFlags & WS_VSCROLL) != 0;
- return S_OK;
+ struct text_services *services = impl_from_ITextServices( iface );
+
+ if (min_pos) *min_pos = services->editor->vert_si.nMin;
+ if (max_pos) *max_pos = services->editor->vert_si.nMax;
+ if (pos) *pos = services->editor->vert_si.nPos;
+ if (page) *page = services->editor->vert_si.nPage;
+ if (enabled) *enabled = (services->editor->styleFlags & WS_VSCROLL) != 0;
+ return S_OK;
}
DEFINE_THISCALL_WRAPPER(fnTextSrv_OnTxSetCursor,40)
@@ -200,10 +191,10 @@ DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_OnTxSetCursor(ITextServices *iface,
void *pvAspect, DVTARGETDEVICE *ptd, HDC hdcDraw,
HDC hicTargetDev, LPCRECT lprcClient, INT x, INT y)
{
- ITextServicesImpl *This = impl_from_ITextServices(iface);
+ struct text_services *services = impl_from_ITextServices( iface );
- FIXME("%p: STUB\n", This);
- return E_NOTIMPL;
+ FIXME( "%p: STUB\n", services );
+ return E_NOTIMPL;
}
DEFINE_THISCALL_WRAPPER(fnTextSrv_TxQueryHitPoint,44)
@@ -212,108 +203,105 @@ DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_TxQueryHitPoint(ITextServices *ifac
HDC hicTargetDev, LPCRECT lprcClient, INT x, INT y,
DWORD *pHitResult)
{
- ITextServicesImpl *This = impl_from_ITextServices(iface);
+ struct text_services *services = impl_from_ITextServices( iface );
- FIXME("%p: STUB\n", This);
- return E_NOTIMPL;
+ FIXME( "%p: STUB\n", services );
+ return E_NOTIMPL;
}
DEFINE_THISCALL_WRAPPER(fnTextSrv_OnTxInplaceActivate,8)
DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_OnTxInplaceActivate(ITextServices *iface, LPCRECT prcClient)
{
- ITextServicesImpl *This = impl_from_ITextServices(iface);
+ struct text_services *services = impl_from_ITextServices( iface );
- FIXME("%p: STUB\n", This);
- return E_NOTIMPL;
+ FIXME( "%p: STUB\n", services );
+ return E_NOTIMPL;
}
DEFINE_THISCALL_WRAPPER(fnTextSrv_OnTxInplaceDeactivate,4)
DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_OnTxInplaceDeactivate(ITextServices *iface)
{
- ITextServicesImpl *This = impl_from_ITextServices(iface);
+ struct text_services *services = impl_from_ITextServices( iface );
- FIXME("%p: STUB\n", This);
- return E_NOTIMPL;
+ FIXME( "%p: STUB\n", services );
+ return E_NOTIMPL;
}
DEFINE_THISCALL_WRAPPER(fnTextSrv_OnTxUIActivate,4)
DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_OnTxUIActivate(ITextServices *iface)
{
- ITextServicesImpl *This = impl_from_ITextServices(iface);
+ struct text_services *services = impl_from_ITextServices( iface );
- FIXME("%p: STUB\n", This);
- return E_NOTIMPL;
+ FIXME( "%p: STUB\n", services );
+ return E_NOTIMPL;
}
DEFINE_THISCALL_WRAPPER(fnTextSrv_OnTxUIDeactivate,4)
DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_OnTxUIDeactivate(ITextServices *iface)
{
- ITextServicesImpl *This = impl_from_ITextServices(iface);
+ struct text_services *services = impl_from_ITextServices( iface );
- FIXME("%p: STUB\n", This);
- return E_NOTIMPL;
+ FIXME( "%p: STUB\n", services );
+ return E_NOTIMPL;
}
DEFINE_THISCALL_WRAPPER(fnTextSrv_TxGetText,8)
-DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_TxGetText(ITextServices *iface, BSTR *pbstrText)
+DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_TxGetText( ITextServices *iface, BSTR *text )
{
- ITextServicesImpl *This = impl_from_ITextServices(iface);
- int length;
-
- length = ME_GetTextLength(This->editor);
- if (length)
- {
- ME_Cursor start;
- BSTR bstr;
- bstr = SysAllocStringByteLen(NULL, length * sizeof(WCHAR));
- if (bstr == NULL)
- return E_OUTOFMEMORY;
-
- cursor_from_char_ofs( This->editor, 0, &start );
- ME_GetTextW(This->editor, bstr, length, &start, INT_MAX, FALSE, FALSE);
- *pbstrText = bstr;
- } else {
- *pbstrText = NULL;
- }
-
- return S_OK;
+ struct text_services *services = impl_from_ITextServices( iface );
+ int length;
+
+ length = ME_GetTextLength( services->editor );
+ if (length)
+ {
+ ME_Cursor start;
+ BSTR bstr;
+ bstr = SysAllocStringByteLen( NULL, length * sizeof(WCHAR) );
+ if (bstr == NULL) return E_OUTOFMEMORY;
+
+ cursor_from_char_ofs( services->editor, 0, &start );
+ ME_GetTextW( services->editor, bstr, length, &start, INT_MAX, FALSE, FALSE );
+ *text = bstr;
+ }
+ else *text = NULL;
+
+ return S_OK;
}
DEFINE_THISCALL_WRAPPER(fnTextSrv_TxSetText,8)
-DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_TxSetText(ITextServices *iface, LPCWSTR pszText)
+DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_TxSetText( ITextServices *iface, const WCHAR *text )
{
- ITextServicesImpl *This = impl_from_ITextServices(iface);
- ME_Cursor cursor;
-
- ME_SetCursorToStart(This->editor, &cursor);
- ME_InternalDeleteText(This->editor, &cursor, ME_GetTextLength(This->editor), FALSE);
- if(pszText)
- ME_InsertTextFromCursor(This->editor, 0, pszText, -1, This->editor->pBuffer->pDefaultStyle);
- set_selection_cursors(This->editor, 0, 0);
- This->editor->nModifyStep = 0;
- OleFlushClipboard();
- ME_EmptyUndoStack(This->editor);
- ME_UpdateRepaint(This->editor, FALSE);
-
- return S_OK;
+ struct text_services *services = impl_from_ITextServices( iface );
+ ME_Cursor cursor;
+
+ ME_SetCursorToStart( services->editor, &cursor );
+ ME_InternalDeleteText( services->editor, &cursor, ME_GetTextLength( services->editor ), FALSE );
+ if (text) ME_InsertTextFromCursor( services->editor, 0, text, -1, services->editor->pBuffer->pDefaultStyle );
+ set_selection_cursors( services->editor, 0, 0);
+ services->editor->nModifyStep = 0;
+ OleFlushClipboard();
+ ME_EmptyUndoStack( services->editor );
+ ME_UpdateRepaint( services->editor, FALSE );
+
+ return S_OK;
}
DEFINE_THISCALL_WRAPPER(fnTextSrv_TxGetCurTargetX,8)
DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_TxGetCurTargetX(ITextServices *iface, LONG *x)
{
- ITextServicesImpl *This = impl_from_ITextServices(iface);
+ struct text_services *services = impl_from_ITextServices( iface );
- FIXME("%p: STUB\n", This);
- return E_NOTIMPL;
+ FIXME( "%p: STUB\n", services );
+ return E_NOTIMPL;
}
DEFINE_THISCALL_WRAPPER(fnTextSrv_TxGetBaseLinePos,8)
DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_TxGetBaseLinePos(ITextServices *iface, LONG *x)
{
- ITextServicesImpl *This = impl_from_ITextServices(iface);
+ struct text_services *services = impl_from_ITextServices( iface );
- FIXME("%p: STUB\n", This);
- return E_NOTIMPL;
+ FIXME( "%p: STUB\n", services );
+ return E_NOTIMPL;
}
DEFINE_THISCALL_WRAPPER(fnTextSrv_TxGetNaturalSize,36)
@@ -321,63 +309,63 @@ DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_TxGetNaturalSize(ITextServices *ifa
HDC hicTargetDev, DVTARGETDEVICE *ptd, DWORD dwMode,
const SIZEL *psizelExtent, LONG *pwidth, LONG *pheight)
{
- ITextServicesImpl *This = impl_from_ITextServices(iface);
+ struct text_services *services = impl_from_ITextServices( iface );
- FIXME("%p: STUB\n", This);
- return E_NOTIMPL;
+ FIXME( "%p: STUB\n", services );
+ return E_NOTIMPL;
}
DEFINE_THISCALL_WRAPPER(fnTextSrv_TxGetDropTarget,8)
DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_TxGetDropTarget(ITextServices *iface, IDropTarget **ppDropTarget)
{
- ITextServicesImpl *This = impl_from_ITextServices(iface);
+ struct text_services *services = impl_from_ITextServices( iface );
- FIXME("%p: STUB\n", This);
- return E_NOTIMPL;
+ FIXME( "%p: STUB\n", services );
+ return E_NOTIMPL;
}
DEFINE_THISCALL_WRAPPER(fnTextSrv_OnTxPropertyBitsChange,12)
DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_OnTxPropertyBitsChange(ITextServices *iface, DWORD dwMask, DWORD dwBits)
{
- ITextServicesImpl *This = impl_from_ITextServices(iface);
+ struct text_services *services = impl_from_ITextServices( iface );
- FIXME("%p: STUB\n", This);
- return E_NOTIMPL;
+ FIXME( "%p: STUB\n", services );
+ return E_NOTIMPL;
}
DEFINE_THISCALL_WRAPPER(fnTextSrv_TxGetCachedSize,12)
DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_TxGetCachedSize(ITextServices *iface, DWORD *pdwWidth, DWORD *pdwHeight)
{
- ITextServicesImpl *This = impl_from_ITextServices(iface);
+ struct text_services *services = impl_from_ITextServices( iface );
- FIXME("%p: STUB\n", This);
- return E_NOTIMPL;
+ FIXME( "%p: STUB\n", services );
+ return E_NOTIMPL;
}
static const ITextServicesVtbl textservices_vtbl =
{
- fnTextSrv_QueryInterface,
- fnTextSrv_AddRef,
- fnTextSrv_Release,
- THISCALL(fnTextSrv_TxSendMessage),
- THISCALL(fnTextSrv_TxDraw),
- THISCALL(fnTextSrv_TxGetHScroll),
- THISCALL(fnTextSrv_TxGetVScroll),
- THISCALL(fnTextSrv_OnTxSetCursor),
- THISCALL(fnTextSrv_TxQueryHitPoint),
- THISCALL(fnTextSrv_OnTxInplaceActivate),
- THISCALL(fnTextSrv_OnTxInplaceDeactivate),
- THISCALL(fnTextSrv_OnTxUIActivate),
- THISCALL(fnTextSrv_OnTxUIDeactivate),
- THISCALL(fnTextSrv_TxGetText),
- THISCALL(fnTextSrv_TxSetText),
- THISCALL(fnTextSrv_TxGetCurTargetX),
- THISCALL(fnTextSrv_TxGetBaseLinePos),
- THISCALL(fnTextSrv_TxGetNaturalSize),
- THISCALL(fnTextSrv_TxGetDropTarget),
- THISCALL(fnTextSrv_OnTxPropertyBitsChange),
- THISCALL(fnTextSrv_TxGetCachedSize)
+ fnTextSrv_QueryInterface,
+ fnTextSrv_AddRef,
+ fnTextSrv_Release,
+ THISCALL(fnTextSrv_TxSendMessage),
+ THISCALL(fnTextSrv_TxDraw),
+ THISCALL(fnTextSrv_TxGetHScroll),
+ THISCALL(fnTextSrv_TxGetVScroll),
+ THISCALL(fnTextSrv_OnTxSetCursor),
+ THISCALL(fnTextSrv_TxQueryHitPoint),
+ THISCALL(fnTextSrv_OnTxInplaceActivate),
+ THISCALL(fnTextSrv_OnTxInplaceDeactivate),
+ THISCALL(fnTextSrv_OnTxUIActivate),
+ THISCALL(fnTextSrv_OnTxUIDeactivate),
+ THISCALL(fnTextSrv_TxGetText),
+ THISCALL(fnTextSrv_TxSetText),
+ THISCALL(fnTextSrv_TxGetCurTargetX),
+ THISCALL(fnTextSrv_TxGetBaseLinePos),
+ THISCALL(fnTextSrv_TxGetNaturalSize),
+ THISCALL(fnTextSrv_TxGetDropTarget),
+ THISCALL(fnTextSrv_OnTxPropertyBitsChange),
+ THISCALL(fnTextSrv_TxGetCachedSize)
};
/******************************************************************
@@ -385,7 +373,7 @@ static const ITextServicesVtbl textservices_vtbl =
*/
HRESULT WINAPI CreateTextServices(IUnknown *pUnkOuter, ITextHost *pITextHost, IUnknown **ppUnk)
{
- ITextServicesImpl *ITextImpl;
+ struct text_services *ITextImpl;
TRACE("%p %p --> %p\n", pUnkOuter, pITextHost, ppUnk);
if (pITextHost == NULL)
--
2.23.0
1
0
Signed-off-by: Huw Davies <huw(a)codeweavers.com>
---
dlls/riched20/txthost.c | 269 +++++++++++++++++++---------------------
1 file changed, 130 insertions(+), 139 deletions(-)
diff --git a/dlls/riched20/txthost.c b/dlls/riched20/txthost.c
index a193c7b0813..d0b43add364 100644
--- a/dlls/riched20/txthost.c
+++ b/dlls/riched20/txthost.c
@@ -32,30 +32,31 @@
WINE_DEFAULT_DEBUG_CHANNEL(richedit);
-typedef struct ITextHostImpl {
+struct host
+{
ITextHost ITextHost_iface;
LONG ref;
- HWND hWnd;
- BOOL bEmulateVersion10;
+ HWND window;
+ BOOL emulate_10;
PARAFORMAT2 para_fmt;
-} ITextHostImpl;
+};
static const ITextHostVtbl textHostVtbl;
static BOOL listbox_registered;
static BOOL combobox_registered;
-static ITextHost *host_create( HWND hwnd, CREATESTRUCTW *cs, BOOL bEmulateVersion10 )
+static ITextHost *host_create( HWND hwnd, CREATESTRUCTW *cs, BOOL emulate_10 )
{
- ITextHostImpl *texthost;
+ struct host *texthost;
texthost = CoTaskMemAlloc(sizeof(*texthost));
if (!texthost) return NULL;
texthost->ITextHost_iface.lpVtbl = &textHostVtbl;
texthost->ref = 1;
- texthost->hWnd = hwnd;
- texthost->bEmulateVersion10 = bEmulateVersion10;
+ texthost->window = hwnd;
+ texthost->emulate_10 = emulate_10;
memset( &texthost->para_fmt, 0, sizeof(texthost->para_fmt) );
texthost->para_fmt.cbSize = sizeof(texthost->para_fmt);
texthost->para_fmt.dwMask = PFM_ALIGNMENT;
@@ -68,18 +69,19 @@ static ITextHost *host_create( HWND hwnd, CREATESTRUCTW *cs, BOOL bEmulateVersio
return &texthost->ITextHost_iface;
}
-static inline ITextHostImpl *impl_from_ITextHost(ITextHost *iface)
+static inline struct host *impl_from_ITextHost( ITextHost *iface )
{
- return CONTAINING_RECORD(iface, ITextHostImpl, ITextHost_iface);
+ return CONTAINING_RECORD( iface, struct host, ITextHost_iface );
}
-static HRESULT WINAPI ITextHostImpl_QueryInterface(ITextHost *iface, REFIID riid, void **ppvObject)
+static HRESULT WINAPI ITextHostImpl_QueryInterface( ITextHost *iface, REFIID riid, void **obj )
{
- ITextHostImpl *This = impl_from_ITextHost(iface);
+ struct host *host = impl_from_ITextHost( iface );
- if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_ITextHost)) {
- *ppvObject = &This->ITextHost_iface;
- ITextHost_AddRef((ITextHost *)*ppvObject);
+ if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_ITextHost))
+ {
+ *obj = &host->ITextHost_iface;
+ ITextHost_AddRef( (ITextHost *)*obj );
return S_OK;
}
@@ -89,20 +91,20 @@ static HRESULT WINAPI ITextHostImpl_QueryInterface(ITextHost *iface, REFIID riid
static ULONG WINAPI ITextHostImpl_AddRef(ITextHost *iface)
{
- ITextHostImpl *This = impl_from_ITextHost(iface);
- ULONG ref = InterlockedIncrement(&This->ref);
+ struct host *host = impl_from_ITextHost( iface );
+ ULONG ref = InterlockedIncrement( &host->ref );
return ref;
}
static ULONG WINAPI ITextHostImpl_Release(ITextHost *iface)
{
- ITextHostImpl *This = impl_from_ITextHost(iface);
- ULONG ref = InterlockedDecrement(&This->ref);
+ struct host *host = impl_from_ITextHost( iface );
+ ULONG ref = InterlockedDecrement( &host->ref );
if (!ref)
{
- SetWindowLongPtrW(This->hWnd, 0, 0);
- CoTaskMemFree(This);
+ SetWindowLongPtrW( host->window, 0, 0 );
+ CoTaskMemFree( host );
}
return ref;
}
@@ -110,176 +112,165 @@ static ULONG WINAPI ITextHostImpl_Release(ITextHost *iface)
DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetDC,4)
DECLSPEC_HIDDEN HDC __thiscall ITextHostImpl_TxGetDC(ITextHost *iface)
{
- ITextHostImpl *This = impl_from_ITextHost(iface);
- return GetDC(This->hWnd);
+ struct host *host = impl_from_ITextHost( iface );
+ return GetDC( host->window );
}
DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxReleaseDC,8)
DECLSPEC_HIDDEN INT __thiscall ITextHostImpl_TxReleaseDC(ITextHost *iface, HDC hdc)
{
- ITextHostImpl *This = impl_from_ITextHost(iface);
- return ReleaseDC(This->hWnd, hdc);
+ struct host *host = impl_from_ITextHost( iface );
+ return ReleaseDC( host->window, hdc );
}
DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxShowScrollBar,12)
-DECLSPEC_HIDDEN BOOL __thiscall ITextHostImpl_TxShowScrollBar(ITextHost *iface, INT fnBar, BOOL fShow)
+DECLSPEC_HIDDEN BOOL __thiscall ITextHostImpl_TxShowScrollBar( ITextHost *iface, INT bar, BOOL show )
{
- ITextHostImpl *This = impl_from_ITextHost(iface);
- return ShowScrollBar(This->hWnd, fnBar, fShow);
+ struct host *host = impl_from_ITextHost( iface );
+ return ShowScrollBar( host->window, bar, show );
}
DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxEnableScrollBar,12)
-DECLSPEC_HIDDEN BOOL __thiscall ITextHostImpl_TxEnableScrollBar(ITextHost *iface, INT fuSBFlags, INT fuArrowflags)
+DECLSPEC_HIDDEN BOOL __thiscall ITextHostImpl_TxEnableScrollBar( ITextHost *iface, INT bar, INT arrows )
{
- ITextHostImpl *This = impl_from_ITextHost(iface);
- return EnableScrollBar(This->hWnd, fuSBFlags, fuArrowflags);
+ struct host *host = impl_from_ITextHost( iface );
+ return EnableScrollBar( host->window, bar, arrows );
}
DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxSetScrollRange,20)
-DECLSPEC_HIDDEN BOOL __thiscall ITextHostImpl_TxSetScrollRange(ITextHost *iface, INT fnBar, LONG nMinPos, INT nMaxPos,
- BOOL fRedraw)
+DECLSPEC_HIDDEN BOOL __thiscall ITextHostImpl_TxSetScrollRange( ITextHost *iface, INT bar, LONG min_pos, INT max_pos, BOOL redraw )
{
- ITextHostImpl *This = impl_from_ITextHost(iface);
- return SetScrollRange(This->hWnd, fnBar, nMinPos, nMaxPos, fRedraw);
+ struct host *host = impl_from_ITextHost( iface );
+ return SetScrollRange( host->window, bar, min_pos, max_pos, redraw );
}
DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxSetScrollPos,16)
-DECLSPEC_HIDDEN BOOL __thiscall ITextHostImpl_TxSetScrollPos(ITextHost *iface, INT fnBar, INT nPos, BOOL fRedraw)
+DECLSPEC_HIDDEN BOOL __thiscall ITextHostImpl_TxSetScrollPos( ITextHost *iface, INT bar, INT pos, BOOL redraw )
{
- ITextHostImpl *This = impl_from_ITextHost(iface);
- return SetScrollPos(This->hWnd, fnBar, nPos, fRedraw) != 0;
+ struct host *host = impl_from_ITextHost( iface );
+ return SetScrollPos( host->window, bar, pos, redraw ) != 0;
}
DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxInvalidateRect,12)
-DECLSPEC_HIDDEN void __thiscall ITextHostImpl_TxInvalidateRect(ITextHost *iface, LPCRECT prc, BOOL fMode)
+DECLSPEC_HIDDEN void __thiscall ITextHostImpl_TxInvalidateRect( ITextHost *iface, const RECT *rect, BOOL mode )
{
- ITextHostImpl *This = impl_from_ITextHost(iface);
- InvalidateRect(This->hWnd, prc, fMode);
+ struct host *host = impl_from_ITextHost( iface );
+ InvalidateRect( host->window, rect, mode );
}
DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxViewChange,8)
-DECLSPEC_HIDDEN void __thiscall ITextHostImpl_TxViewChange(ITextHost *iface, BOOL fUpdate)
+DECLSPEC_HIDDEN void __thiscall ITextHostImpl_TxViewChange( ITextHost *iface, BOOL update )
{
- ITextHostImpl *This = impl_from_ITextHost(iface);
- if (fUpdate)
- UpdateWindow(This->hWnd);
+ struct host *host = impl_from_ITextHost( iface );
+ if (update) UpdateWindow( host->window );
}
DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxCreateCaret,16)
-DECLSPEC_HIDDEN BOOL __thiscall ITextHostImpl_TxCreateCaret(ITextHost *iface, HBITMAP hbmp, INT xWidth, INT yHeight)
+DECLSPEC_HIDDEN BOOL __thiscall ITextHostImpl_TxCreateCaret( ITextHost *iface, HBITMAP bitmap, INT width, INT height )
{
- ITextHostImpl *This = impl_from_ITextHost(iface);
- return CreateCaret(This->hWnd, hbmp, xWidth, yHeight);
+ struct host *host = impl_from_ITextHost( iface );
+ return CreateCaret( host->window, bitmap, width, height );
}
DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxShowCaret,8)
-DECLSPEC_HIDDEN BOOL __thiscall ITextHostImpl_TxShowCaret(ITextHost *iface, BOOL fShow)
+DECLSPEC_HIDDEN BOOL __thiscall ITextHostImpl_TxShowCaret( ITextHost *iface, BOOL show )
{
- ITextHostImpl *This = impl_from_ITextHost(iface);
- if (fShow)
- return ShowCaret(This->hWnd);
- else
- return HideCaret(This->hWnd);
+ struct host *host = impl_from_ITextHost( iface );
+ if (show) return ShowCaret( host->window );
+ else return HideCaret( host->window );
}
DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxSetCaretPos,12)
-DECLSPEC_HIDDEN BOOL __thiscall ITextHostImpl_TxSetCaretPos(ITextHost *iface,
- INT x, INT y)
+DECLSPEC_HIDDEN BOOL __thiscall ITextHostImpl_TxSetCaretPos( ITextHost *iface, INT x, INT y )
{
return SetCaretPos(x, y);
}
DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxSetTimer,12)
-DECLSPEC_HIDDEN BOOL __thiscall ITextHostImpl_TxSetTimer(ITextHost *iface, UINT idTimer, UINT uTimeout)
+DECLSPEC_HIDDEN BOOL __thiscall ITextHostImpl_TxSetTimer( ITextHost *iface, UINT id, UINT timeout )
{
- ITextHostImpl *This = impl_from_ITextHost(iface);
- return SetTimer(This->hWnd, idTimer, uTimeout, NULL) != 0;
+ struct host *host = impl_from_ITextHost( iface );
+ return SetTimer( host->window, id, timeout, NULL ) != 0;
}
DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxKillTimer,8)
-DECLSPEC_HIDDEN void __thiscall ITextHostImpl_TxKillTimer(ITextHost *iface, UINT idTimer)
+DECLSPEC_HIDDEN void __thiscall ITextHostImpl_TxKillTimer( ITextHost *iface, UINT id )
{
- ITextHostImpl *This = impl_from_ITextHost(iface);
- KillTimer(This->hWnd, idTimer);
+ struct host *host = impl_from_ITextHost( iface );
+ KillTimer( host->window, id );
}
DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxScrollWindowEx,32)
-DECLSPEC_HIDDEN void __thiscall ITextHostImpl_TxScrollWindowEx(ITextHost *iface, INT dx, INT dy, LPCRECT lprcScroll,
- LPCRECT lprcClip, HRGN hRgnUpdate, LPRECT lprcUpdate,
- UINT fuScroll)
+DECLSPEC_HIDDEN void __thiscall ITextHostImpl_TxScrollWindowEx( ITextHost *iface, INT dx, INT dy, const RECT *scroll,
+ const RECT *clip, HRGN update_rgn, RECT *update_rect,
+ UINT flags )
{
- ITextHostImpl *This = impl_from_ITextHost(iface);
- ScrollWindowEx(This->hWnd, dx, dy, lprcScroll, lprcClip,
- hRgnUpdate, lprcUpdate, fuScroll);
+ struct host *host = impl_from_ITextHost( iface );
+ ScrollWindowEx( host->window, dx, dy, scroll, clip, update_rgn, update_rect, flags );
}
DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxSetCapture,8)
-DECLSPEC_HIDDEN void __thiscall ITextHostImpl_TxSetCapture(ITextHost *iface, BOOL fCapture)
+DECLSPEC_HIDDEN void __thiscall ITextHostImpl_TxSetCapture( ITextHost *iface, BOOL capture )
{
- ITextHostImpl *This = impl_from_ITextHost(iface);
- if (fCapture)
- SetCapture(This->hWnd);
- else
- ReleaseCapture();
+ struct host *host = impl_from_ITextHost( iface );
+ if (capture) SetCapture( host->window );
+ else ReleaseCapture();
}
DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxSetFocus,4)
DECLSPEC_HIDDEN void __thiscall ITextHostImpl_TxSetFocus(ITextHost *iface)
{
- ITextHostImpl *This = impl_from_ITextHost(iface);
- SetFocus(This->hWnd);
+ struct host *host = impl_from_ITextHost( iface );
+ SetFocus( host->window );
}
DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxSetCursor,12)
-DECLSPEC_HIDDEN void __thiscall ITextHostImpl_TxSetCursor(ITextHost *iface, HCURSOR hcur, BOOL fText)
+DECLSPEC_HIDDEN void __thiscall ITextHostImpl_TxSetCursor( ITextHost *iface, HCURSOR cursor, BOOL text )
{
- SetCursor(hcur);
+ SetCursor( cursor );
}
DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxScreenToClient,8)
-DECLSPEC_HIDDEN BOOL __thiscall ITextHostImpl_TxScreenToClient(ITextHost *iface, LPPOINT lppt)
+DECLSPEC_HIDDEN BOOL __thiscall ITextHostImpl_TxScreenToClient( ITextHost *iface, POINT *pt )
{
- ITextHostImpl *This = impl_from_ITextHost(iface);
- return ScreenToClient(This->hWnd, lppt);
+ struct host *host = impl_from_ITextHost( iface );
+ return ScreenToClient( host->window, pt );
}
DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxClientToScreen,8)
-DECLSPEC_HIDDEN BOOL __thiscall ITextHostImpl_TxClientToScreen(ITextHost *iface, LPPOINT lppt)
+DECLSPEC_HIDDEN BOOL __thiscall ITextHostImpl_TxClientToScreen( ITextHost *iface, POINT *pt )
{
- ITextHostImpl *This = impl_from_ITextHost(iface);
- return ClientToScreen(This->hWnd, lppt);
+ struct host *host = impl_from_ITextHost( iface );
+ return ClientToScreen( host->window, pt );
}
DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxActivate,8)
-DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxActivate(ITextHost *iface, LONG *plOldState)
+DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxActivate( ITextHost *iface, LONG *old_state )
{
- ITextHostImpl *This = impl_from_ITextHost(iface);
- *plOldState = HandleToLong(SetActiveWindow(This->hWnd));
- return (*plOldState ? S_OK : E_FAIL);
+ struct host *host = impl_from_ITextHost( iface );
+ *old_state = HandleToLong( SetActiveWindow( host->window ) );
+ return *old_state ? S_OK : E_FAIL;
}
DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxDeactivate,8)
-DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxDeactivate(ITextHost *iface, LONG lNewState)
+DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxDeactivate( ITextHost *iface, LONG new_state )
{
- HWND ret = SetActiveWindow(LongToHandle(lNewState));
- return (ret ? S_OK : E_FAIL);
+ HWND ret = SetActiveWindow( LongToHandle( new_state ) );
+ return ret ? S_OK : E_FAIL;
}
DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetClientRect,8)
-DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxGetClientRect(ITextHost *iface, LPRECT prc)
+DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxGetClientRect( ITextHost *iface, RECT *rect )
{
- ITextHostImpl *This = impl_from_ITextHost(iface);
- int ret = GetClientRect(This->hWnd, prc);
- return (ret ? S_OK : E_FAIL);
+ struct host *host = impl_from_ITextHost( iface );
+ int ret = GetClientRect( host->window, rect );
+ return ret ? S_OK : E_FAIL;
}
DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetViewInset,8)
-DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxGetViewInset(ITextHost *iface, LPRECT prc)
+DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxGetViewInset( ITextHost *iface, RECT *rect )
{
- prc->top = 0;
- prc->left = 0;
- prc->bottom = 0;
- prc->right = 0;
+ SetRectEmpty( rect );
return S_OK;
}
@@ -290,38 +281,38 @@ DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxGetCharFormat(ITextHost *ifac
}
DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetParaFormat,8)
-DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxGetParaFormat(ITextHost *iface, const PARAFORMAT **fmt)
+DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxGetParaFormat( ITextHost *iface, const PARAFORMAT **fmt )
{
- ITextHostImpl *This = impl_from_ITextHost(iface);
- *fmt = (const PARAFORMAT *)&This->para_fmt;
+ struct host *host = impl_from_ITextHost( iface );
+ *fmt = (const PARAFORMAT *)&host->para_fmt;
return S_OK;
}
DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetSysColor,8)
-DECLSPEC_HIDDEN COLORREF __thiscall ITextHostImpl_TxGetSysColor(ITextHost *iface, int nIndex)
+DECLSPEC_HIDDEN COLORREF __thiscall ITextHostImpl_TxGetSysColor( ITextHost *iface, int index )
{
- return GetSysColor(nIndex);
+ return GetSysColor( index );
}
DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetBackStyle,8)
-DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxGetBackStyle(ITextHost *iface, TXTBACKSTYLE *pStyle)
+DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxGetBackStyle( ITextHost *iface, TXTBACKSTYLE *style )
{
- *pStyle = TXTBACK_OPAQUE;
+ *style = TXTBACK_OPAQUE;
return S_OK;
}
DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetMaxLength,8)
-DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxGetMaxLength(ITextHost *iface, DWORD *pLength)
+DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxGetMaxLength( ITextHost *iface, DWORD *length )
{
- *pLength = INFINITE;
+ *length = INFINITE;
return S_OK;
}
DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetScrollBars,8)
-DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxGetScrollBars(ITextHost *iface, DWORD *pdwScrollBar)
+DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxGetScrollBars( ITextHost *iface, DWORD *scrollbar )
{
- ITextHostImpl *This = impl_from_ITextHost(iface);
- ME_TextEditor *editor = (ME_TextEditor*)GetWindowLongPtrW(This->hWnd, 0);
+ struct host *host = impl_from_ITextHost( iface );
+ ME_TextEditor *editor = (ME_TextEditor*)GetWindowLongPtrW( host->window, 0 );
const DWORD mask = WS_VSCROLL|
WS_HSCROLL|
ES_AUTOVSCROLL|
@@ -329,34 +320,34 @@ DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxGetScrollBars(ITextHost *ifac
ES_DISABLENOSCROLL;
if (editor)
{
- *pdwScrollBar = editor->styleFlags & mask;
+ *scrollbar = editor->styleFlags & mask;
} else {
- DWORD style = GetWindowLongW(This->hWnd, GWL_STYLE);
+ DWORD style = GetWindowLongW( host->window, GWL_STYLE );
if (style & WS_VSCROLL)
style |= ES_AUTOVSCROLL;
- if (!This->bEmulateVersion10 && (style & WS_HSCROLL))
+ if (!host->emulate_10 && (style & WS_HSCROLL))
style |= ES_AUTOHSCROLL;
- *pdwScrollBar = style & mask;
+ *scrollbar = style & mask;
}
return S_OK;
}
DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetPasswordChar,8)
-DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxGetPasswordChar(ITextHost *iface, WCHAR *pch)
+DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxGetPasswordChar( ITextHost *iface, WCHAR *c )
{
- *pch = '*';
+ *c = '*';
return S_OK;
}
DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetAcceleratorPos,8)
-DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxGetAcceleratorPos(ITextHost *iface, LONG *pch)
+DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxGetAcceleratorPos( ITextHost *iface, LONG *pos )
{
- *pch = -1;
+ *pos = -1;
return S_OK;
}
DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetExtent,8)
-DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxGetExtent(ITextHost *iface, LPSIZEL lpExtent)
+DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxGetExtent( ITextHost *iface, SIZEL *extent )
{
return E_NOTIMPL;
}
@@ -374,10 +365,10 @@ DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_OnTxParaFormatChange(ITextHost
}
DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetPropertyBits,12)
-DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxGetPropertyBits(ITextHost *iface, DWORD dwMask, DWORD *pdwBits)
+DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxGetPropertyBits( ITextHost *iface, DWORD mask, DWORD *bits )
{
- ITextHostImpl *This = impl_from_ITextHost(iface);
- ME_TextEditor *editor = (ME_TextEditor *)GetWindowLongPtrW(This->hWnd, 0);
+ struct host *host = impl_from_ITextHost( iface );
+ ME_TextEditor *editor = (ME_TextEditor *)GetWindowLongPtrW( host->window, 0 );
DWORD style;
DWORD dwBits = 0;
@@ -393,7 +384,7 @@ DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxGetPropertyBits(ITextHost *if
} else {
DWORD dwScrollBar;
- style = GetWindowLongW(This->hWnd, GWL_STYLE);
+ style = GetWindowLongW( host->window, GWL_STYLE );
ITextHostImpl_TxGetScrollBars(iface, &dwScrollBar);
dwBits |= TXTBIT_RICHTEXT|TXTBIT_AUTOWORDSEL;
@@ -436,16 +427,16 @@ DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxGetPropertyBits(ITextHost *if
* TXTBIT_USECURRENTBKG
*/
- *pdwBits = dwBits & dwMask;
+ *bits = dwBits & mask;
return S_OK;
}
DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxNotify,12)
DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxNotify(ITextHost *iface, DWORD iNotify, void *pv)
{
- ITextHostImpl *This = impl_from_ITextHost(iface);
- ME_TextEditor *editor = (ME_TextEditor*)GetWindowLongPtrW(This->hWnd, 0);
- HWND hwnd = This->hWnd;
+ struct host *host = impl_from_ITextHost( iface );
+ ME_TextEditor *editor = (ME_TextEditor*)GetWindowLongPtrW( host->window, 0 );
+ HWND hwnd = host->window;
UINT id;
if (!editor || !editor->hwndParent) return S_OK;
@@ -502,26 +493,26 @@ DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxNotify(ITextHost *iface, DWOR
DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxImmGetContext,4)
DECLSPEC_HIDDEN HIMC __thiscall ITextHostImpl_TxImmGetContext(ITextHost *iface)
{
- ITextHostImpl *This = impl_from_ITextHost(iface);
- return ImmGetContext(This->hWnd);
+ struct host *host = impl_from_ITextHost( iface );
+ return ImmGetContext( host->window );
}
DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxImmReleaseContext,8)
-DECLSPEC_HIDDEN void __thiscall ITextHostImpl_TxImmReleaseContext(ITextHost *iface, HIMC himc)
+DECLSPEC_HIDDEN void __thiscall ITextHostImpl_TxImmReleaseContext( ITextHost *iface, HIMC context )
{
- ITextHostImpl *This = impl_from_ITextHost(iface);
- ImmReleaseContext(This->hWnd, himc);
+ struct host *host = impl_from_ITextHost( iface );
+ ImmReleaseContext( host->window, context );
}
DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetSelectionBarWidth,8)
-DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxGetSelectionBarWidth(ITextHost *iface, LONG *lSelBarWidth)
+DECLSPEC_HIDDEN HRESULT __thiscall ITextHostImpl_TxGetSelectionBarWidth( ITextHost *iface, LONG *width )
{
- ITextHostImpl *This = impl_from_ITextHost(iface);
- ME_TextEditor *editor = (ME_TextEditor *)GetWindowLongPtrW(This->hWnd, 0);
+ struct host *host = impl_from_ITextHost( iface );
+ ME_TextEditor *editor = (ME_TextEditor *)GetWindowLongPtrW( host->window, 0 );
DWORD style = editor ? editor->styleFlags
- : GetWindowLongW(This->hWnd, GWL_STYLE);
- *lSelBarWidth = (style & ES_SELECTIONBAR) ? 225 : 0; /* in HIMETRIC */
+ : GetWindowLongW( host->window, GWL_STYLE );
+ *width = (style & ES_SELECTIONBAR) ? 225 : 0; /* in HIMETRIC */
return S_OK;
}
--
2.23.0
1
0
Signed-off-by: Huw Davies <huw(a)codeweavers.com>
---
dlls/riched20/editor.c | 477 +---------------------------------------
dlls/riched20/editor.h | 2 +-
dlls/riched20/txthost.c | 372 ++++++++++++++++++++++++++++++-
3 files changed, 378 insertions(+), 473 deletions(-)
diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c
index f0662682044..487d4137391 100644
--- a/dlls/riched20/editor.c
+++ b/dlls/riched20/editor.c
@@ -233,7 +233,6 @@
#include "shlwapi.h"
#include "rtf.h"
#include "imm.h"
-#include "res.h"
#define STACK_SIZE_DEFAULT 100
#define STACK_SIZE_MAX 1000
@@ -242,21 +241,12 @@
WINE_DEFAULT_DEBUG_CHANNEL(richedit);
-static BOOL ME_RegisterEditorClass(HINSTANCE);
static BOOL ME_UpdateLinkAttribute(ME_TextEditor *editor, ME_Cursor *start, int nChars);
-static HCURSOR hLeft;
+HCURSOR cursor_reverse = NULL;
BOOL me_debug = FALSE;
HANDLE me_heap = NULL;
-static BOOL ME_ListBoxRegistered = FALSE;
-static BOOL ME_ComboBoxRegistered = FALSE;
-
-static inline BOOL is_version_nt(void)
-{
- return !(GetVersion() & 0x80000000);
-}
-
static ME_TextBuffer *ME_MakeText(void) {
ME_TextBuffer *buf = heap_alloc(sizeof(*buf));
ME_DisplayItem *p1 = ME_MakeDI(diTextStart);
@@ -2939,15 +2929,16 @@ static BOOL ME_SetCursor(ME_TextEditor *editor)
}
ITextHost_TxScreenToClient(editor->texthost, &pt);
- if (editor->nSelectionType == stLine && editor->bMouseCaptured) {
- ITextHost_TxSetCursor(editor->texthost, hLeft, FALSE);
+ if (editor->nSelectionType == stLine && editor->bMouseCaptured)
+ {
+ ITextHost_TxSetCursor( editor->texthost, cursor_reverse, FALSE );
return TRUE;
}
if (!editor->bEmulateVersion10 /* v4.1 */ &&
pt.y < editor->rcFormat.top &&
pt.x < editor->rcFormat.left)
{
- ITextHost_TxSetCursor(editor->texthost, hLeft, FALSE);
+ ITextHost_TxSetCursor( editor->texthost, cursor_reverse, FALSE );
return TRUE;
}
if (pt.y < editor->rcFormat.top || pt.y > editor->rcFormat.bottom)
@@ -2962,7 +2953,7 @@ static BOOL ME_SetCursor(ME_TextEditor *editor)
}
if (pt.x < editor->rcFormat.left)
{
- ITextHost_TxSetCursor(editor->texthost, hLeft, FALSE);
+ ITextHost_TxSetCursor( editor->texthost, cursor_reverse, FALSE );
return TRUE;
}
ME_CharFromPos(editor, pt.x, pt.y, &cursor, &isExact);
@@ -3243,37 +3234,6 @@ void ME_DestroyEditor(ME_TextEditor *editor)
heap_free(editor);
}
-BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
-{
- TRACE("\n");
- switch (fdwReason)
- {
- case DLL_PROCESS_ATTACH:
- DisableThreadLibraryCalls(hinstDLL);
- me_heap = HeapCreate (0, 0x10000, 0);
- if (!ME_RegisterEditorClass(hinstDLL)) return FALSE;
- hLeft = LoadCursorW(hinstDLL, MAKEINTRESOURCEW(OCR_REVERSE));
- LookupInit();
- break;
-
- case DLL_PROCESS_DETACH:
- if (lpvReserved) break;
- UnregisterClassW(RICHEDIT_CLASS20W, 0);
- UnregisterClassW(MSFTEDIT_CLASS, 0);
- UnregisterClassA(RICHEDIT_CLASS20A, 0);
- UnregisterClassA("RichEdit50A", 0);
- if (ME_ListBoxRegistered)
- UnregisterClassW(L"REListBox20W", 0);
- if (ME_ComboBoxRegistered)
- UnregisterClassW(L"REComboBox20W", 0);
- LookupCleanup();
- HeapDestroy (me_heap);
- release_typelib();
- break;
- }
- return TRUE;
-}
-
static inline int get_default_line_height( ME_TextEditor *editor )
{
int height = 0;
@@ -3292,142 +3252,6 @@ static inline int calc_wheel_change( int *remain, int amount_per_click )
return change;
}
-static const char * const edit_messages[] = {
- "EM_GETSEL",
- "EM_SETSEL",
- "EM_GETRECT",
- "EM_SETRECT",
- "EM_SETRECTNP",
- "EM_SCROLL",
- "EM_LINESCROLL",
- "EM_SCROLLCARET",
- "EM_GETMODIFY",
- "EM_SETMODIFY",
- "EM_GETLINECOUNT",
- "EM_LINEINDEX",
- "EM_SETHANDLE",
- "EM_GETHANDLE",
- "EM_GETTHUMB",
- "EM_UNKNOWN_BF",
- "EM_UNKNOWN_C0",
- "EM_LINELENGTH",
- "EM_REPLACESEL",
- "EM_UNKNOWN_C3",
- "EM_GETLINE",
- "EM_LIMITTEXT",
- "EM_CANUNDO",
- "EM_UNDO",
- "EM_FMTLINES",
- "EM_LINEFROMCHAR",
- "EM_UNKNOWN_CA",
- "EM_SETTABSTOPS",
- "EM_SETPASSWORDCHAR",
- "EM_EMPTYUNDOBUFFER",
- "EM_GETFIRSTVISIBLELINE",
- "EM_SETREADONLY",
- "EM_SETWORDBREAKPROC",
- "EM_GETWORDBREAKPROC",
- "EM_GETPASSWORDCHAR",
- "EM_SETMARGINS",
- "EM_GETMARGINS",
- "EM_GETLIMITTEXT",
- "EM_POSFROMCHAR",
- "EM_CHARFROMPOS",
- "EM_SETIMESTATUS",
- "EM_GETIMESTATUS"
-};
-
-static const char * const richedit_messages[] = {
- "EM_CANPASTE",
- "EM_DISPLAYBAND",
- "EM_EXGETSEL",
- "EM_EXLIMITTEXT",
- "EM_EXLINEFROMCHAR",
- "EM_EXSETSEL",
- "EM_FINDTEXT",
- "EM_FORMATRANGE",
- "EM_GETCHARFORMAT",
- "EM_GETEVENTMASK",
- "EM_GETOLEINTERFACE",
- "EM_GETPARAFORMAT",
- "EM_GETSELTEXT",
- "EM_HIDESELECTION",
- "EM_PASTESPECIAL",
- "EM_REQUESTRESIZE",
- "EM_SELECTIONTYPE",
- "EM_SETBKGNDCOLOR",
- "EM_SETCHARFORMAT",
- "EM_SETEVENTMASK",
- "EM_SETOLECALLBACK",
- "EM_SETPARAFORMAT",
- "EM_SETTARGETDEVICE",
- "EM_STREAMIN",
- "EM_STREAMOUT",
- "EM_GETTEXTRANGE",
- "EM_FINDWORDBREAK",
- "EM_SETOPTIONS",
- "EM_GETOPTIONS",
- "EM_FINDTEXTEX",
- "EM_GETWORDBREAKPROCEX",
- "EM_SETWORDBREAKPROCEX",
- "EM_SETUNDOLIMIT",
- "EM_UNKNOWN_USER_83",
- "EM_REDO",
- "EM_CANREDO",
- "EM_GETUNDONAME",
- "EM_GETREDONAME",
- "EM_STOPGROUPTYPING",
- "EM_SETTEXTMODE",
- "EM_GETTEXTMODE",
- "EM_AUTOURLDETECT",
- "EM_GETAUTOURLDETECT",
- "EM_SETPALETTE",
- "EM_GETTEXTEX",
- "EM_GETTEXTLENGTHEX",
- "EM_SHOWSCROLLBAR",
- "EM_SETTEXTEX",
- "EM_UNKNOWN_USER_98",
- "EM_UNKNOWN_USER_99",
- "EM_SETPUNCTUATION",
- "EM_GETPUNCTUATION",
- "EM_SETWORDWRAPMODE",
- "EM_GETWORDWRAPMODE",
- "EM_SETIMECOLOR",
- "EM_GETIMECOLOR",
- "EM_SETIMEOPTIONS",
- "EM_GETIMEOPTIONS",
- "EM_CONVPOSITION",
- "EM_UNKNOWN_USER_109",
- "EM_UNKNOWN_USER_110",
- "EM_UNKNOWN_USER_111",
- "EM_UNKNOWN_USER_112",
- "EM_UNKNOWN_USER_113",
- "EM_UNKNOWN_USER_114",
- "EM_UNKNOWN_USER_115",
- "EM_UNKNOWN_USER_116",
- "EM_UNKNOWN_USER_117",
- "EM_UNKNOWN_USER_118",
- "EM_UNKNOWN_USER_119",
- "EM_SETLANGOPTIONS",
- "EM_GETLANGOPTIONS",
- "EM_GETIMECOMPMODE",
- "EM_FINDTEXTW",
- "EM_FINDTEXTEXW",
- "EM_RECONVERSION",
- "EM_SETIMEMODEBIAS",
- "EM_GETIMEMODEBIAS"
-};
-
-static const char *
-get_msg_name(UINT msg)
-{
- if (msg >= EM_GETSEL && msg <= EM_CHARFROMPOS)
- return edit_messages[msg - EM_GETSEL];
- if (msg >= EM_CANPASTE && msg <= EM_GETIMEMODEBIAS)
- return richedit_messages[msg - EM_CANPASTE];
- return "";
-}
-
static void ME_LinkNotify(ME_TextEditor *editor, UINT msg, WPARAM wParam, LPARAM lParam)
{
int x,y;
@@ -4935,187 +4759,6 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam,
return 0L;
}
-static BOOL create_windowed_editor(HWND hwnd, CREATESTRUCTW *create, BOOL emulate_10)
-{
- ITextHost *host = ME_CreateTextHost( hwnd, create, emulate_10 );
- ME_TextEditor *editor;
-
- if (!host) return FALSE;
-
- editor = ME_MakeEditor( host, emulate_10 );
- if (!editor)
- {
- ITextHost_Release( host );
- return FALSE;
- }
-
- editor->exStyleFlags = GetWindowLongW( hwnd, GWL_EXSTYLE );
- editor->styleFlags |= GetWindowLongW( hwnd, GWL_STYLE ) & ES_WANTRETURN;
- editor->hWnd = hwnd; /* FIXME: Remove editor's dependence on hWnd */
- editor->hwndParent = create->hwndParent;
-
- SetWindowLongPtrW( hwnd, 0, (LONG_PTR)editor );
-
- return TRUE;
-}
-
-static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam,
- LPARAM lParam, BOOL unicode)
-{
- ME_TextEditor *editor;
- HRESULT hresult;
- LRESULT lresult = 0;
-
- TRACE("enter hwnd %p msg %04x (%s) %lx %lx, unicode %d\n",
- hWnd, msg, get_msg_name(msg), wParam, lParam, unicode);
-
- editor = (ME_TextEditor *)GetWindowLongPtrW(hWnd, 0);
- if (!editor)
- {
- if (msg == WM_NCCREATE)
- {
- CREATESTRUCTW *pcs = (CREATESTRUCTW *)lParam;
-
- TRACE("WM_NCCREATE: hWnd %p style 0x%08x\n", hWnd, pcs->style);
- return create_windowed_editor( hWnd, pcs, FALSE );
- }
- else
- {
- return DefWindowProcW(hWnd, msg, wParam, lParam);
- }
- }
-
- switch (msg)
- {
- case WM_PAINT:
- {
- HDC hdc;
- RECT rc;
- PAINTSTRUCT ps;
- HBRUSH old_brush;
-
- update_caret(editor);
- hdc = BeginPaint(editor->hWnd, &ps);
- if (!editor->bEmulateVersion10 || (editor->nEventMask & ENM_UPDATE))
- ME_SendOldNotify(editor, EN_UPDATE);
- old_brush = SelectObject(hdc, editor->hbrBackground);
-
- /* Erase area outside of the formatting rectangle */
- if (ps.rcPaint.top < editor->rcFormat.top)
- {
- rc = ps.rcPaint;
- rc.bottom = editor->rcFormat.top;
- PatBlt(hdc, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, PATCOPY);
- ps.rcPaint.top = editor->rcFormat.top;
- }
- if (ps.rcPaint.bottom > editor->rcFormat.bottom) {
- rc = ps.rcPaint;
- rc.top = editor->rcFormat.bottom;
- PatBlt(hdc, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, PATCOPY);
- ps.rcPaint.bottom = editor->rcFormat.bottom;
- }
- if (ps.rcPaint.left < editor->rcFormat.left) {
- rc = ps.rcPaint;
- rc.right = editor->rcFormat.left;
- PatBlt(hdc, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, PATCOPY);
- ps.rcPaint.left = editor->rcFormat.left;
- }
- if (ps.rcPaint.right > editor->rcFormat.right) {
- rc = ps.rcPaint;
- rc.left = editor->rcFormat.right;
- PatBlt(hdc, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, PATCOPY);
- ps.rcPaint.right = editor->rcFormat.right;
- }
-
- ME_PaintContent(editor, hdc, &ps.rcPaint);
- SelectObject(hdc, old_brush);
- EndPaint(editor->hWnd, &ps);
- return 0;
- }
- case WM_ERASEBKGND:
- {
- HDC hDC = (HDC)wParam;
- RECT rc;
-
- if (GetUpdateRect(editor->hWnd, &rc, TRUE))
- FillRect(hDC, &rc, editor->hbrBackground);
- return 1;
- }
- case EM_SETOPTIONS:
- {
- DWORD dwStyle;
- const DWORD mask = ECO_VERTICAL | ECO_AUTOHSCROLL | ECO_AUTOVSCROLL |
- ECO_NOHIDESEL | ECO_READONLY | ECO_WANTRETURN |
- ECO_SELECTIONBAR;
- lresult = ME_HandleMessage(editor, msg, wParam, lParam, unicode, &hresult);
- dwStyle = GetWindowLongW(hWnd, GWL_STYLE);
- dwStyle = (dwStyle & ~mask) | (lresult & mask);
- SetWindowLongW(hWnd, GWL_STYLE, dwStyle);
- return lresult;
- }
- case EM_SETREADONLY:
- {
- DWORD dwStyle;
- lresult = ME_HandleMessage(editor, msg, wParam, lParam, unicode, &hresult);
- dwStyle = GetWindowLongW(hWnd, GWL_STYLE);
- dwStyle &= ~ES_READONLY;
- if (wParam)
- dwStyle |= ES_READONLY;
- SetWindowLongW(hWnd, GWL_STYLE, dwStyle);
- return lresult;
- }
- default:
- lresult = ME_HandleMessage(editor, msg, wParam, lParam, unicode, &hresult);
- }
-
- if (hresult == S_FALSE)
- lresult = DefWindowProcW(hWnd, msg, wParam, lParam);
-
- TRACE("exit hwnd %p msg %04x (%s) %lx %lx, unicode %d -> %lu\n",
- hWnd, msg, get_msg_name(msg), wParam, lParam, unicode, lresult);
-
- return lresult;
-}
-
-static LRESULT WINAPI RichEditWndProcW(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
-{
- BOOL unicode = TRUE;
-
- /* Under Win9x RichEdit20W returns ANSI strings, see the tests. */
- if (msg == WM_GETTEXT && (GetVersion() & 0x80000000))
- unicode = FALSE;
-
- return RichEditWndProc_common(hWnd, msg, wParam, lParam, unicode);
-}
-
-static LRESULT WINAPI RichEditWndProcA(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
-{
- return RichEditWndProc_common(hWnd, msg, wParam, lParam, FALSE);
-}
-
-/******************************************************************
- * RichEditANSIWndProc (RICHED20.10)
- */
-LRESULT WINAPI RichEditANSIWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
-{
- return RichEditWndProcA(hWnd, msg, wParam, lParam);
-}
-
-/******************************************************************
- * RichEdit10ANSIWndProc (RICHED20.9)
- */
-LRESULT WINAPI RichEdit10ANSIWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
-{
- if (msg == WM_NCCREATE && !GetWindowLongPtrW(hWnd, 0))
- {
- CREATESTRUCTW *pcs = (CREATESTRUCTW *)lParam;
-
- TRACE("WM_NCCREATE: hWnd %p style 0x%08x\n", hWnd, pcs->style);
- return create_windowed_editor( hWnd, pcs, TRUE );
- }
- return RichEditANSIWndProc(hWnd, msg, wParam, lParam);
-}
-
void ME_SendOldNotify(ME_TextEditor *editor, int nCode)
{
ITextHost_TxNotify(editor->texthost, nCode, NULL);
@@ -5192,114 +4835,6 @@ int ME_GetTextW(ME_TextEditor *editor, WCHAR *buffer, int buflen,
return buffer - pStart;
}
-static BOOL ME_RegisterEditorClass(HINSTANCE hInstance)
-{
- WNDCLASSW wcW;
- WNDCLASSA wcA;
-
- wcW.style = CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW | CS_GLOBALCLASS;
- wcW.lpfnWndProc = RichEditWndProcW;
- wcW.cbClsExtra = 0;
- wcW.cbWndExtra = sizeof(ME_TextEditor *);
- wcW.hInstance = NULL; /* hInstance would register DLL-local class */
- wcW.hIcon = NULL;
- wcW.hCursor = LoadCursorW(NULL, (LPWSTR)IDC_IBEAM);
- wcW.hbrBackground = GetStockObject(NULL_BRUSH);
- wcW.lpszMenuName = NULL;
-
- if (is_version_nt())
- {
- wcW.lpszClassName = RICHEDIT_CLASS20W;
- if (!RegisterClassW(&wcW)) return FALSE;
- wcW.lpszClassName = MSFTEDIT_CLASS;
- if (!RegisterClassW(&wcW)) return FALSE;
- }
- else
- {
- /* WNDCLASSA/W have the same layout */
- wcW.lpszClassName = (LPCWSTR)"RichEdit20W";
- if (!RegisterClassA((WNDCLASSA *)&wcW)) return FALSE;
- wcW.lpszClassName = (LPCWSTR)"RichEdit50W";
- if (!RegisterClassA((WNDCLASSA *)&wcW)) return FALSE;
- }
-
- wcA.style = CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW | CS_GLOBALCLASS;
- wcA.lpfnWndProc = RichEditWndProcA;
- wcA.cbClsExtra = 0;
- wcA.cbWndExtra = sizeof(ME_TextEditor *);
- wcA.hInstance = NULL; /* hInstance would register DLL-local class */
- wcA.hIcon = NULL;
- wcA.hCursor = LoadCursorW(NULL, (LPWSTR)IDC_IBEAM);
- wcA.hbrBackground = GetStockObject(NULL_BRUSH);
- wcA.lpszMenuName = NULL;
- wcA.lpszClassName = RICHEDIT_CLASS20A;
- if (!RegisterClassA(&wcA)) return FALSE;
- wcA.lpszClassName = "RichEdit50A";
- if (!RegisterClassA(&wcA)) return FALSE;
-
- return TRUE;
-}
-
-static LRESULT WINAPI REComboWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) {
- /* FIXME: Not implemented */
- TRACE("hWnd %p msg %04x (%s) %08lx %08lx\n",
- hWnd, msg, get_msg_name(msg), wParam, lParam);
- return DefWindowProcW(hWnd, msg, wParam, lParam);
-}
-
-static LRESULT WINAPI REListWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) {
- /* FIXME: Not implemented */
- TRACE("hWnd %p msg %04x (%s) %08lx %08lx\n",
- hWnd, msg, get_msg_name(msg), wParam, lParam);
- return DefWindowProcW(hWnd, msg, wParam, lParam);
-}
-
-/******************************************************************
- * REExtendedRegisterClass (RICHED20.8)
- *
- * FIXME undocumented
- * Need to check for errors and implement controls and callbacks
- */
-LRESULT WINAPI REExtendedRegisterClass(void)
-{
- WNDCLASSW wcW;
- UINT result;
-
- FIXME("semi stub\n");
-
- wcW.cbClsExtra = 0;
- wcW.cbWndExtra = 4;
- wcW.hInstance = NULL;
- wcW.hIcon = NULL;
- wcW.hCursor = NULL;
- wcW.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
- wcW.lpszMenuName = NULL;
-
- if (!ME_ListBoxRegistered)
- {
- wcW.style = CS_PARENTDC | CS_DBLCLKS | CS_GLOBALCLASS;
- wcW.lpfnWndProc = REListWndProc;
- wcW.lpszClassName = L"REListBox20W";
- if (RegisterClassW(&wcW)) ME_ListBoxRegistered = TRUE;
- }
-
- if (!ME_ComboBoxRegistered)
- {
- wcW.style = CS_PARENTDC | CS_DBLCLKS | CS_GLOBALCLASS | CS_VREDRAW | CS_HREDRAW;
- wcW.lpfnWndProc = REComboWndProc;
- wcW.lpszClassName = L"REComboBox20W";
- if (RegisterClassW(&wcW)) ME_ComboBoxRegistered = TRUE;
- }
-
- result = 0;
- if (ME_ListBoxRegistered)
- result += 1;
- if (ME_ComboBoxRegistered)
- result += 2;
-
- return result;
-}
-
static int __cdecl wchar_comp( const void *key, const void *elem )
{
return *(const WCHAR *)key - *(const WCHAR *)elem;
diff --git a/dlls/riched20/editor.h b/dlls/riched20/editor.h
index 7a9d445f98f..e226bc02921 100644
--- a/dlls/riched20/editor.h
+++ b/dlls/riched20/editor.h
@@ -23,6 +23,7 @@
struct _RTF_Info;
extern HANDLE me_heap DECLSPEC_HIDDEN;
+extern HCURSOR cursor_reverse DECLSPEC_HIDDEN;
#define RUN_IS_HIDDEN(run) ((run)->style->fmt.dwMask & CFM_HIDDEN \
&& (run)->style->fmt.dwEffects & CFE_HIDDEN)
@@ -316,7 +317,6 @@ static inline ME_DisplayItem *cell_get_di(ME_Cell *cell)
/* txthost.c */
-ITextHost *ME_CreateTextHost(HWND hwnd, CREATESTRUCTW *cs, BOOL bEmulateVersion10) DECLSPEC_HIDDEN;
#ifdef __ASM_USE_THISCALL_WRAPPER
#define TXTHOST_VTABLE(This) (&itextHostStdcallVtbl)
#else /* __i386__ */
diff --git a/dlls/riched20/txthost.c b/dlls/riched20/txthost.c
index 99f446e5812..a193c7b0813 100644
--- a/dlls/riched20/txthost.c
+++ b/dlls/riched20/txthost.c
@@ -27,6 +27,8 @@
#include "textserv.h"
#include "wine/debug.h"
#include "editstr.h"
+#include "rtf.h"
+#include "res.h"
WINE_DEFAULT_DEBUG_CHANNEL(richedit);
@@ -40,7 +42,10 @@ typedef struct ITextHostImpl {
static const ITextHostVtbl textHostVtbl;
-ITextHost *ME_CreateTextHost(HWND hwnd, CREATESTRUCTW *cs, BOOL bEmulateVersion10)
+static BOOL listbox_registered;
+static BOOL combobox_registered;
+
+static ITextHost *host_create( HWND hwnd, CREATESTRUCTW *cs, BOOL bEmulateVersion10 )
{
ITextHostImpl *texthost;
@@ -676,3 +681,368 @@ static const ITextHostVtbl textHostVtbl = {
THISCALL(ITextHostImpl_TxImmReleaseContext),
THISCALL(ITextHostImpl_TxGetSelectionBarWidth),
};
+
+static const char * const edit_messages[] =
+{
+ "EM_GETSEL", "EM_SETSEL", "EM_GETRECT", "EM_SETRECT",
+ "EM_SETRECTNP", "EM_SCROLL", "EM_LINESCROLL", "EM_SCROLLCARET",
+ "EM_GETMODIFY", "EM_SETMODIFY", "EM_GETLINECOUNT", "EM_LINEINDEX",
+ "EM_SETHANDLE", "EM_GETHANDLE", "EM_GETTHUMB", "EM_UNKNOWN_BF",
+ "EM_UNKNOWN_C0", "EM_LINELENGTH", "EM_REPLACESEL", "EM_UNKNOWN_C3",
+ "EM_GETLINE", "EM_LIMITTEXT", "EM_CANUNDO", "EM_UNDO",
+ "EM_FMTLINES", "EM_LINEFROMCHAR", "EM_UNKNOWN_CA", "EM_SETTABSTOPS",
+ "EM_SETPASSWORDCHAR", "EM_EMPTYUNDOBUFFER", "EM_GETFIRSTVISIBLELINE", "EM_SETREADONLY",
+ "EM_SETWORDBREAKPROC", "EM_GETWORDBREAKPROC", "EM_GETPASSWORDCHAR", "EM_SETMARGINS",
+ "EM_GETMARGINS", "EM_GETLIMITTEXT", "EM_POSFROMCHAR", "EM_CHARFROMPOS",
+ "EM_SETIMESTATUS", "EM_GETIMESTATUS"
+};
+
+static const char * const richedit_messages[] =
+{
+ "EM_CANPASTE", "EM_DISPLAYBAND", "EM_EXGETSEL", "EM_EXLIMITTEXT",
+ "EM_EXLINEFROMCHAR", "EM_EXSETSEL", "EM_FINDTEXT", "EM_FORMATRANGE",
+ "EM_GETCHARFORMAT", "EM_GETEVENTMASK", "EM_GETOLEINTERFACE", "EM_GETPARAFORMAT",
+ "EM_GETSELTEXT", "EM_HIDESELECTION", "EM_PASTESPECIAL", "EM_REQUESTRESIZE",
+ "EM_SELECTIONTYPE", "EM_SETBKGNDCOLOR", "EM_SETCHARFORMAT", "EM_SETEVENTMASK",
+ "EM_SETOLECALLBACK", "EM_SETPARAFORMAT", "EM_SETTARGETDEVICE", "EM_STREAMIN",
+ "EM_STREAMOUT", "EM_GETTEXTRANGE", "EM_FINDWORDBREAK", "EM_SETOPTIONS",
+ "EM_GETOPTIONS", "EM_FINDTEXTEX", "EM_GETWORDBREAKPROCEX", "EM_SETWORDBREAKPROCEX",
+ "EM_SETUNDOLIMIT", "EM_UNKNOWN_USER_83", "EM_REDO", "EM_CANREDO",
+ "EM_GETUNDONAME", "EM_GETREDONAME", "EM_STOPGROUPTYPING", "EM_SETTEXTMODE",
+ "EM_GETTEXTMODE", "EM_AUTOURLDETECT", "EM_GETAUTOURLDETECT", "EM_SETPALETTE",
+ "EM_GETTEXTEX", "EM_GETTEXTLENGTHEX", "EM_SHOWSCROLLBAR", "EM_SETTEXTEX",
+ "EM_UNKNOWN_USER_98", "EM_UNKNOWN_USER_99", "EM_SETPUNCTUATION", "EM_GETPUNCTUATION",
+ "EM_SETWORDWRAPMODE", "EM_GETWORDWRAPMODE", "EM_SETIMECOLOR", "EM_GETIMECOLOR",
+ "EM_SETIMEOPTIONS", "EM_GETIMEOPTIONS", "EM_CONVPOSITION", "EM_UNKNOWN_USER_109",
+ "EM_UNKNOWN_USER_110", "EM_UNKNOWN_USER_111", "EM_UNKNOWN_USER_112", "EM_UNKNOWN_USER_113",
+ "EM_UNKNOWN_USER_114", "EM_UNKNOWN_USER_115", "EM_UNKNOWN_USER_116", "EM_UNKNOWN_USER_117",
+ "EM_UNKNOWN_USER_118", "EM_UNKNOWN_USER_119", "EM_SETLANGOPTIONS", "EM_GETLANGOPTIONS",
+ "EM_GETIMECOMPMODE", "EM_FINDTEXTW", "EM_FINDTEXTEXW", "EM_RECONVERSION",
+ "EM_SETIMEMODEBIAS", "EM_GETIMEMODEBIAS"
+};
+
+static const char *get_msg_name( UINT msg )
+{
+ if (msg >= EM_GETSEL && msg <= EM_CHARFROMPOS)
+ return edit_messages[msg - EM_GETSEL];
+ if (msg >= EM_CANPASTE && msg <= EM_GETIMEMODEBIAS)
+ return richedit_messages[msg - EM_CANPASTE];
+ return "";
+}
+
+static BOOL create_windowed_editor( HWND hwnd, CREATESTRUCTW *create, BOOL emulate_10 )
+{
+ ITextHost *host = host_create( hwnd, create, emulate_10 );
+ ME_TextEditor *editor;
+
+ if (!host) return FALSE;
+
+ editor = ME_MakeEditor( host, emulate_10 );
+ if (!editor)
+ {
+ ITextHost_Release( host );
+ return FALSE;
+ }
+
+ editor->exStyleFlags = GetWindowLongW( hwnd, GWL_EXSTYLE );
+ editor->styleFlags |= GetWindowLongW( hwnd, GWL_STYLE ) & ES_WANTRETURN;
+ editor->hWnd = hwnd; /* FIXME: Remove editor's dependence on hWnd */
+ editor->hwndParent = create->hwndParent;
+
+ SetWindowLongPtrW( hwnd, 0, (LONG_PTR)editor );
+
+ return TRUE;
+}
+
+static LRESULT RichEditWndProc_common( HWND hwnd, UINT msg, WPARAM wparam,
+ LPARAM lparam, BOOL unicode )
+{
+ ME_TextEditor *editor;
+ HRESULT hr;
+ LRESULT res = 0;
+
+ TRACE( "enter hwnd %p msg %04x (%s) %lx %lx, unicode %d\n",
+ hwnd, msg, get_msg_name(msg), wparam, lparam, unicode );
+
+ editor = (ME_TextEditor *)GetWindowLongPtrW( hwnd, 0 );
+ if (!editor)
+ {
+ if (msg == WM_NCCREATE)
+ {
+ CREATESTRUCTW *pcs = (CREATESTRUCTW *)lparam;
+
+ TRACE( "WM_NCCREATE: hwnd %p style 0x%08x\n", hwnd, pcs->style );
+ return create_windowed_editor( hwnd, pcs, FALSE );
+ }
+ else return DefWindowProcW( hwnd, msg, wparam, lparam );
+ }
+
+ switch (msg)
+ {
+ case WM_ERASEBKGND:
+ {
+ HDC hdc = (HDC)wparam;
+ RECT rc;
+
+ if (GetUpdateRect( editor->hWnd, &rc, TRUE ))
+ FillRect( hdc, &rc, editor->hbrBackground );
+ return 1;
+ }
+ case WM_PAINT:
+ {
+ HDC hdc;
+ RECT rc;
+ PAINTSTRUCT ps;
+ HBRUSH old_brush;
+
+ update_caret( editor );
+ hdc = BeginPaint( editor->hWnd, &ps );
+ if (!editor->bEmulateVersion10 || (editor->nEventMask & ENM_UPDATE))
+ ME_SendOldNotify( editor, EN_UPDATE );
+ old_brush = SelectObject( hdc, editor->hbrBackground );
+
+ /* Erase area outside of the formatting rectangle */
+ if (ps.rcPaint.top < editor->rcFormat.top)
+ {
+ rc = ps.rcPaint;
+ rc.bottom = editor->rcFormat.top;
+ PatBlt( hdc, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, PATCOPY );
+ ps.rcPaint.top = editor->rcFormat.top;
+ }
+ if (ps.rcPaint.bottom > editor->rcFormat.bottom)
+ {
+ rc = ps.rcPaint;
+ rc.top = editor->rcFormat.bottom;
+ PatBlt( hdc, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, PATCOPY );
+ ps.rcPaint.bottom = editor->rcFormat.bottom;
+ }
+ if (ps.rcPaint.left < editor->rcFormat.left)
+ {
+ rc = ps.rcPaint;
+ rc.right = editor->rcFormat.left;
+ PatBlt( hdc, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, PATCOPY );
+ ps.rcPaint.left = editor->rcFormat.left;
+ }
+ if (ps.rcPaint.right > editor->rcFormat.right)
+ {
+ rc = ps.rcPaint;
+ rc.left = editor->rcFormat.right;
+ PatBlt( hdc, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, PATCOPY );
+ ps.rcPaint.right = editor->rcFormat.right;
+ }
+
+ ME_PaintContent( editor, hdc, &ps.rcPaint );
+ SelectObject( hdc, old_brush );
+ EndPaint( editor->hWnd, &ps );
+ return 0;
+ }
+ case EM_SETOPTIONS:
+ {
+ DWORD style;
+ const DWORD mask = ECO_VERTICAL | ECO_AUTOHSCROLL | ECO_AUTOVSCROLL |
+ ECO_NOHIDESEL | ECO_READONLY | ECO_WANTRETURN |
+ ECO_SELECTIONBAR;
+
+ res = ME_HandleMessage( editor, msg, wparam, lparam, unicode, &hr );
+ style = GetWindowLongW( hwnd, GWL_STYLE );
+ style = (style & ~mask) | (res & mask);
+ SetWindowLongW( hwnd, GWL_STYLE, style );
+ return res;
+ }
+ case EM_SETREADONLY:
+ {
+ DWORD style;
+
+ res = ME_HandleMessage( editor, msg, wparam, lparam, unicode, &hr );
+ style = GetWindowLongW( hwnd, GWL_STYLE );
+ style &= ~ES_READONLY;
+ if (wparam) style |= ES_READONLY;
+ SetWindowLongW( hwnd, GWL_STYLE, style );
+ return res;
+ }
+ default:
+ res = ME_HandleMessage( editor, msg, wparam, lparam, unicode, &hr );
+ }
+
+ if (hr == S_FALSE)
+ res = DefWindowProcW( hwnd, msg, wparam, lparam );
+
+ TRACE( "exit hwnd %p msg %04x (%s) %lx %lx, unicode %d -> %lu\n",
+ hwnd, msg, get_msg_name(msg), wparam, lparam, unicode, res );
+
+ return res;
+}
+
+static LRESULT WINAPI RichEditWndProcW( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam )
+{
+ BOOL unicode = TRUE;
+
+ /* Under Win9x RichEdit20W returns ANSI strings, see the tests. */
+ if (msg == WM_GETTEXT && (GetVersion() & 0x80000000))
+ unicode = FALSE;
+
+ return RichEditWndProc_common( hwnd, msg, wparam, lparam, unicode );
+}
+
+static LRESULT WINAPI RichEditWndProcA( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam )
+{
+ return RichEditWndProc_common( hwnd, msg, wparam, lparam, FALSE );
+}
+
+/******************************************************************
+ * RichEditANSIWndProc (RICHED20.10)
+ */
+LRESULT WINAPI RichEditANSIWndProc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam )
+{
+ return RichEditWndProcA( hwnd, msg, wparam, lparam );
+}
+
+/******************************************************************
+ * RichEdit10ANSIWndProc (RICHED20.9)
+ */
+LRESULT WINAPI RichEdit10ANSIWndProc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam )
+{
+ if (msg == WM_NCCREATE && !GetWindowLongPtrW( hwnd, 0 ))
+ {
+ CREATESTRUCTW *pcs = (CREATESTRUCTW *)lparam;
+
+ TRACE( "WM_NCCREATE: hwnd %p style 0x%08x\n", hwnd, pcs->style );
+ return create_windowed_editor( hwnd, pcs, TRUE );
+ }
+ return RichEditANSIWndProc( hwnd, msg, wparam, lparam );
+}
+
+static LRESULT WINAPI REComboWndProc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam )
+{
+ /* FIXME: Not implemented */
+ TRACE( "hwnd %p msg %04x (%s) %08lx %08lx\n",
+ hwnd, msg, get_msg_name( msg ), wparam, lparam );
+ return DefWindowProcW( hwnd, msg, wparam, lparam );
+}
+
+static LRESULT WINAPI REListWndProc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam )
+{
+ /* FIXME: Not implemented */
+ TRACE( "hwnd %p msg %04x (%s) %08lx %08lx\n",
+ hwnd, msg, get_msg_name( msg ), wparam, lparam );
+ return DefWindowProcW( hwnd, msg, wparam, lparam );
+}
+
+/******************************************************************
+ * REExtendedRegisterClass (RICHED20.8)
+ *
+ * FIXME undocumented
+ * Need to check for errors and implement controls and callbacks
+ */
+LRESULT WINAPI REExtendedRegisterClass( void )
+{
+ WNDCLASSW wc;
+ UINT result;
+
+ FIXME( "semi stub\n" );
+ wc.cbClsExtra = 0;
+ wc.cbWndExtra = 4;
+ wc.hInstance = NULL;
+ wc.hIcon = NULL;
+ wc.hCursor = NULL;
+ wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
+ wc.lpszMenuName = NULL;
+
+ if (!listbox_registered)
+ {
+ wc.style = CS_PARENTDC | CS_DBLCLKS | CS_GLOBALCLASS;
+ wc.lpfnWndProc = REListWndProc;
+ wc.lpszClassName = L"REListBox20W";
+ if (RegisterClassW( &wc )) listbox_registered = TRUE;
+ }
+
+ if (!combobox_registered)
+ {
+ wc.style = CS_PARENTDC | CS_DBLCLKS | CS_GLOBALCLASS | CS_VREDRAW | CS_HREDRAW;
+ wc.lpfnWndProc = REComboWndProc;
+ wc.lpszClassName = L"REComboBox20W";
+ if (RegisterClassW( &wc )) combobox_registered = TRUE;
+ }
+
+ result = 0;
+ if (listbox_registered) result += 1;
+ if (combobox_registered) result += 2;
+
+ return result;
+}
+
+static BOOL register_classes( HINSTANCE instance )
+{
+ WNDCLASSW wcW;
+ WNDCLASSA wcA;
+
+ wcW.style = CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW | CS_GLOBALCLASS;
+ wcW.lpfnWndProc = RichEditWndProcW;
+ wcW.cbClsExtra = 0;
+ wcW.cbWndExtra = sizeof(ME_TextEditor *);
+ wcW.hInstance = NULL; /* hInstance would register DLL-local class */
+ wcW.hIcon = NULL;
+ wcW.hCursor = LoadCursorW( NULL, (LPWSTR)IDC_IBEAM );
+ wcW.hbrBackground = GetStockObject( NULL_BRUSH );
+ wcW.lpszMenuName = NULL;
+
+ if (!(GetVersion() & 0x80000000))
+ {
+ wcW.lpszClassName = RICHEDIT_CLASS20W;
+ if (!RegisterClassW( &wcW )) return FALSE;
+ wcW.lpszClassName = MSFTEDIT_CLASS;
+ if (!RegisterClassW( &wcW )) return FALSE;
+ }
+ else
+ {
+ /* WNDCLASSA/W have the same layout */
+ wcW.lpszClassName = (LPCWSTR)"RichEdit20W";
+ if (!RegisterClassA( (WNDCLASSA *)&wcW )) return FALSE;
+ wcW.lpszClassName = (LPCWSTR)"RichEdit50W";
+ if (!RegisterClassA( (WNDCLASSA *)&wcW )) return FALSE;
+ }
+
+ wcA.style = CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW | CS_GLOBALCLASS;
+ wcA.lpfnWndProc = RichEditWndProcA;
+ wcA.cbClsExtra = 0;
+ wcA.cbWndExtra = sizeof(ME_TextEditor *);
+ wcA.hInstance = NULL; /* hInstance would register DLL-local class */
+ wcA.hIcon = NULL;
+ wcA.hCursor = LoadCursorW( NULL, (LPWSTR)IDC_IBEAM );
+ wcA.hbrBackground = GetStockObject(NULL_BRUSH);
+ wcA.lpszMenuName = NULL;
+ wcA.lpszClassName = RICHEDIT_CLASS20A;
+ if (!RegisterClassA( &wcA )) return FALSE;
+ wcA.lpszClassName = "RichEdit50A";
+ if (!RegisterClassA( &wcA )) return FALSE;
+
+ return TRUE;
+}
+
+BOOL WINAPI DllMain( HINSTANCE instance, DWORD reason, void *reserved )
+{
+ switch (reason)
+ {
+ case DLL_PROCESS_ATTACH:
+ DisableThreadLibraryCalls( instance );
+ me_heap = HeapCreate( 0, 0x10000, 0 );
+ if (!register_classes( instance )) return FALSE;
+ cursor_reverse = LoadCursorW( instance, MAKEINTRESOURCEW( OCR_REVERSE ) );
+ LookupInit();
+ break;
+
+ case DLL_PROCESS_DETACH:
+ if (reserved) break;
+ UnregisterClassW( RICHEDIT_CLASS20W, 0 );
+ UnregisterClassW( MSFTEDIT_CLASS, 0 );
+ UnregisterClassA( RICHEDIT_CLASS20A, 0 );
+ UnregisterClassA( "RichEdit50A", 0 );
+ if (listbox_registered) UnregisterClassW( L"REListBox20W", 0 );
+ if (combobox_registered) UnregisterClassW( L"REComboBox20W", 0 );
+ LookupCleanup();
+ HeapDestroy( me_heap );
+ release_typelib();
+ break;
+ }
+ return TRUE;
+}
--
2.23.0
1
0
Signed-off-by: Paul Gofman <pgofman(a)codeweavers.com>
---
Currently we are printing an ERR for every C++ exception.
dlls/ntdll/signal_arm.c | 4 ++--
dlls/ntdll/signal_arm64.c | 4 ++--
dlls/ntdll/signal_i386.c | 4 ++--
dlls/ntdll/signal_x86_64.c | 4 ++--
4 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/dlls/ntdll/signal_arm.c b/dlls/ntdll/signal_arm.c
index 7c1fceb2bf0..8b0004e0df0 100644
--- a/dlls/ntdll/signal_arm.c
+++ b/dlls/ntdll/signal_arm.c
@@ -174,8 +174,8 @@ NTSTATUS WINAPI KiUserExceptionDispatcher( EXCEPTION_RECORD *rec, CONTEXT *conte
}
else
{
- if (rec->ExceptionFlags & EH_NONCONTINUABLE)
- ERR( "Fatal %s exception (code=%x) raised\n", debugstr_exception_code(rec->ExceptionCode), rec->ExceptionCode );
+ if (rec->ExceptionCode == STATUS_ASSERTION_FAILURE)
+ ERR( "%s exception (code=%x) raised\n", debugstr_exception_code(rec->ExceptionCode), rec->ExceptionCode );
else
WARN( "%s exception (code=%x) raised\n", debugstr_exception_code(rec->ExceptionCode), rec->ExceptionCode );
diff --git a/dlls/ntdll/signal_arm64.c b/dlls/ntdll/signal_arm64.c
index 25bb407658f..dc6b072fa6c 100644
--- a/dlls/ntdll/signal_arm64.c
+++ b/dlls/ntdll/signal_arm64.c
@@ -515,8 +515,8 @@ NTSTATUS WINAPI KiUserExceptionDispatcher( EXCEPTION_RECORD *rec, CONTEXT *conte
}
else
{
- if (rec->ExceptionFlags & EH_NONCONTINUABLE)
- ERR( "Fatal %s exception (code=%x) raised\n", debugstr_exception_code(rec->ExceptionCode), rec->ExceptionCode );
+ if (rec->ExceptionCode == STATUS_ASSERTION_FAILURE)
+ ERR( "%s exception (code=%x) raised\n", debugstr_exception_code(rec->ExceptionCode), rec->ExceptionCode );
else
WARN( "%s exception (code=%x) raised\n", debugstr_exception_code(rec->ExceptionCode), rec->ExceptionCode );
diff --git a/dlls/ntdll/signal_i386.c b/dlls/ntdll/signal_i386.c
index 89ef938658c..635b8f4de81 100644
--- a/dlls/ntdll/signal_i386.c
+++ b/dlls/ntdll/signal_i386.c
@@ -206,8 +206,8 @@ NTSTATUS WINAPI dispatch_exception( EXCEPTION_RECORD *rec, CONTEXT *context )
}
else
{
- if (rec->ExceptionFlags & EH_NONCONTINUABLE)
- ERR( "Fatal %s exception (code=%x) raised\n", debugstr_exception_code(rec->ExceptionCode), rec->ExceptionCode );
+ if (rec->ExceptionCode == STATUS_ASSERTION_FAILURE)
+ ERR( "%s exception (code=%x) raised\n", debugstr_exception_code(rec->ExceptionCode), rec->ExceptionCode );
else
WARN( "%s exception (code=%x) raised\n", debugstr_exception_code(rec->ExceptionCode), rec->ExceptionCode );
diff --git a/dlls/ntdll/signal_x86_64.c b/dlls/ntdll/signal_x86_64.c
index 7e3387ba09e..b5be4f35758 100644
--- a/dlls/ntdll/signal_x86_64.c
+++ b/dlls/ntdll/signal_x86_64.c
@@ -552,8 +552,8 @@ NTSTATUS WINAPI dispatch_exception( EXCEPTION_RECORD *rec, CONTEXT *context )
}
else
{
- if (rec->ExceptionFlags & EH_NONCONTINUABLE)
- ERR( "Fatal %s exception (code=%x) raised\n", debugstr_exception_code(rec->ExceptionCode), rec->ExceptionCode );
+ if (rec->ExceptionCode == STATUS_ASSERTION_FAILURE)
+ ERR( "%s exception (code=%x) raised\n", debugstr_exception_code(rec->ExceptionCode), rec->ExceptionCode );
else
WARN( "%s exception (code=%x) raised\n", debugstr_exception_code(rec->ExceptionCode), rec->ExceptionCode );
--
2.29.2
1
0
[PATCH 2/2] server: Set error to STATUS_UNSUCCESSFUL when the server fails to queue APC for a thread.
by Dmitry Timoshkov 03 Mar '21
by Dmitry Timoshkov 03 Mar '21
03 Mar '21
I've left another case of returning STATUS_PROCESS_IS_TERMINATING since
that's not covered by the tests.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=50704
Signed-off-by: Dmitry Timoshkov <dmitry(a)baikal.ru>
---
dlls/kernel32/tests/sync.c | 2 --
server/thread.c | 2 +-
2 files changed, 1 insertion(+), 3 deletions(-)
diff --git a/dlls/kernel32/tests/sync.c b/dlls/kernel32/tests/sync.c
index 7d6ac030299..f1c5f01fa84 100644
--- a/dlls/kernel32/tests/sync.c
+++ b/dlls/kernel32/tests/sync.c
@@ -2737,13 +2737,11 @@ static void test_QueueUserAPC(void)
ok(ret == WAIT_OBJECT_0, "got %u\n", ret);
ret = pNtQueueApcThread(thread, call_user_apc, (ULONG_PTR)user_apc, 0, 0);
-todo_wine
ok(ret == STATUS_UNSUCCESSFUL, "got %#x\n", ret);
SetLastError(0xdeadbeef);
ret = QueueUserAPC(user_apc, thread, 0);
ok(!ret, "QueueUserAPC should fail\n");
-todo_wine
ok(GetLastError() == ERROR_GEN_FAILURE, "got %u\n", GetLastError());
CloseHandle(thread);
diff --git a/server/thread.c b/server/thread.c
index d544970f3c1..dc02a1a9de3 100644
--- a/server/thread.c
+++ b/server/thread.c
@@ -1763,7 +1763,7 @@ DECL_HANDLER(queue_apc)
if (thread)
{
- if (!queue_apc( NULL, thread, apc )) set_error( STATUS_THREAD_IS_TERMINATING );
+ if (!queue_apc( NULL, thread, apc )) set_error( STATUS_UNSUCCESSFUL );
release_object( thread );
}
else if (process)
--
2.30.1
1
0
[PATCH 1/2] kernel32/tests: Add a test for calling QueueUserAPC() on a terminated thread.
by Dmitry Timoshkov 03 Mar '21
by Dmitry Timoshkov 03 Mar '21
03 Mar '21
Signed-off-by: Dmitry Timoshkov <dmitry(a)baikal.ru>
---
dlls/kernel32/tests/sync.c | 50 ++++++++++++++++++++++++++++++++++++++
1 file changed, 50 insertions(+)
diff --git a/dlls/kernel32/tests/sync.c b/dlls/kernel32/tests/sync.c
index 2a47abf342c..7d6ac030299 100644
--- a/dlls/kernel32/tests/sync.c
+++ b/dlls/kernel32/tests/sync.c
@@ -21,6 +21,9 @@
#include <stdarg.h>
#include <stdlib.h>
#include <stdio.h>
+
+#include "ntstatus.h"
+#define WIN32_NO_STATUS
#include <windef.h>
#include <winbase.h>
#include <winternl.h>
@@ -60,6 +63,7 @@ static PSLIST_ENTRY (__fastcall *pRtlInterlockedPushListSList)(PSLIST_HEADER lis
PSLIST_ENTRY last, ULONG count);
static PSLIST_ENTRY (WINAPI *pRtlInterlockedPushListSListEx)(PSLIST_HEADER list, PSLIST_ENTRY first,
PSLIST_ENTRY last, ULONG count);
+static NTSTATUS (WINAPI *pNtQueueApcThread)(HANDLE,PNTAPCFUNC,ULONG_PTR,ULONG_PTR,ULONG_PTR);
#ifdef __i386__
@@ -2702,6 +2706,49 @@ static void test_crit_section(void)
ok(cs.DebugInfo == NULL, "Unexpected debug info pointer %p.\n", cs.DebugInfo);
}
+static DWORD WINAPI thread_proc(LPVOID unused)
+{
+ Sleep(INFINITE);
+ return 0;
+}
+
+static void CALLBACK user_apc(ULONG_PTR unused)
+{
+}
+
+static void CALLBACK call_user_apc(ULONG_PTR arg1, ULONG_PTR arg2, ULONG_PTR arg3)
+{
+ PAPCFUNC func = (PAPCFUNC)arg1;
+ func(arg2);
+}
+
+static void test_QueueUserAPC(void)
+{
+ HANDLE thread;
+ DWORD tid, ret;
+
+ thread = CreateThread(NULL, 0, thread_proc, NULL, CREATE_SUSPENDED, &tid);
+ ok(thread != NULL, "CreateThread error %u\n", GetLastError());
+
+ ret = TerminateThread(thread, 0xdeadbeef);
+ ok(ret, "TerminateThread error %u\n", GetLastError());
+
+ ret = WaitForSingleObject(thread, 1000);
+ ok(ret == WAIT_OBJECT_0, "got %u\n", ret);
+
+ ret = pNtQueueApcThread(thread, call_user_apc, (ULONG_PTR)user_apc, 0, 0);
+todo_wine
+ ok(ret == STATUS_UNSUCCESSFUL, "got %#x\n", ret);
+
+ SetLastError(0xdeadbeef);
+ ret = QueueUserAPC(user_apc, thread, 0);
+ ok(!ret, "QueueUserAPC should fail\n");
+todo_wine
+ ok(GetLastError() == ERROR_GEN_FAILURE, "got %u\n", GetLastError());
+
+ CloseHandle(thread);
+}
+
START_TEST(sync)
{
char **argv;
@@ -2732,6 +2779,7 @@ START_TEST(sync)
pNtWaitForMultipleObjects = (void *)GetProcAddress(hntdll, "NtWaitForMultipleObjects");
pRtlInterlockedPushListSList = (void *)GetProcAddress(hntdll, "RtlInterlockedPushListSList");
pRtlInterlockedPushListSListEx = (void *)GetProcAddress(hntdll, "RtlInterlockedPushListSListEx");
+ pNtQueueApcThread = (void *)GetProcAddress(hntdll, "NtQueueApcThread");
argc = winetest_get_mainargs( &argv );
if (argc >= 3)
@@ -2744,6 +2792,8 @@ START_TEST(sync)
}
init_fastcall_thunk();
+
+ test_QueueUserAPC();
test_signalandwait();
test_mutex();
test_slist();
--
2.30.1
1
0