Wine-Devel
Threads by month
- ----- 2026 -----
- May
- April
- March
- February
- January
- ----- 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
- 1 participants
- 84530 discussions
March 3, 2021
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
March 3, 2021
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
March 3, 2021
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
March 3, 2021
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 March 3, 2021
by Dmitry Timoshkov March 3, 2021
March 3, 2021
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 March 3, 2021
by Dmitry Timoshkov March 3, 2021
March 3, 2021
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
March 3, 2021
Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com>
---
dlls/wbemprox/services.c | 12 ++++++++----
dlls/wbemprox/tests/services.c | 24 ++++++++++++++++++++++++
dlls/wbemprox/wbemlocator.c | 6 +++---
dlls/wbemprox/wbemprox_private.h | 2 +-
4 files changed, 36 insertions(+), 8 deletions(-)
diff --git a/dlls/wbemprox/services.c b/dlls/wbemprox/services.c
index eff5148ef29..19e03fa152b 100644
--- a/dlls/wbemprox/services.c
+++ b/dlls/wbemprox/services.c
@@ -210,6 +210,7 @@ struct wbem_services
CRITICAL_SECTION cs;
WCHAR *namespace;
struct async_header *async;
+ IWbemContext *context;
};
static inline struct wbem_services *impl_from_IWbemServices( IWbemServices *iface )
@@ -243,6 +244,8 @@ static ULONG WINAPI wbem_services_Release(
}
ws->cs.DebugInfo->Spare[0] = 0;
DeleteCriticalSection( &ws->cs );
+ if (ws->context)
+ IWbemContext_Release( ws->context );
heap_free( ws->namespace );
heap_free( ws );
}
@@ -293,7 +296,7 @@ static HRESULT WINAPI wbem_services_OpenNamespace(
if ((wcsicmp( strNamespace, L"cimv2" ) && wcsicmp( strNamespace, L"default" )) || ws->namespace)
return WBEM_E_INVALID_NAMESPACE;
- return WbemServices_create( L"cimv2", (void **)ppWorkingNamespace );
+ return WbemServices_create( L"cimv2", NULL, (void **)ppWorkingNamespace );
}
static HRESULT WINAPI wbem_services_CancelAsyncCall(
@@ -933,21 +936,22 @@ static const IWbemServicesVtbl wbem_services_vtbl =
wbem_services_ExecMethodAsync
};
-HRESULT WbemServices_create( const WCHAR *namespace, LPVOID *ppObj )
+HRESULT WbemServices_create( const WCHAR *namespace, IWbemContext *context, LPVOID *ppObj )
{
struct wbem_services *ws;
TRACE("(%p)\n", ppObj);
- ws = heap_alloc( sizeof(*ws) );
+ ws = heap_alloc_zero( sizeof(*ws) );
if (!ws) return E_OUTOFMEMORY;
ws->IWbemServices_iface.lpVtbl = &wbem_services_vtbl;
ws->refs = 1;
ws->namespace = heap_strdupW( namespace );
- ws->async = NULL;
InitializeCriticalSection( &ws->cs );
ws->cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": wbemprox_services.cs");
+ if (context)
+ IWbemContext_Clone( context, &ws->context );
*ppObj = &ws->IWbemServices_iface;
diff --git a/dlls/wbemprox/tests/services.c b/dlls/wbemprox/tests/services.c
index c17a502f984..5ad73e7a8ec 100644
--- a/dlls/wbemprox/tests/services.c
+++ b/dlls/wbemprox/tests/services.c
@@ -24,6 +24,15 @@
#include "wbemcli.h"
#include "wine/test.h"
+#define EXPECT_REF(obj,ref) _expect_ref((IUnknown*)obj, ref, __LINE__)
+static void _expect_ref(IUnknown* obj, ULONG ref, int line)
+{
+ ULONG rc;
+ IUnknown_AddRef(obj);
+ rc = IUnknown_Release(obj);
+ ok_(__FILE__,line)(rc == ref, "expected refcount %d, got %d\n", ref, rc);
+}
+
static void test_IClientSecurity(void)
{
HRESULT hr;
@@ -124,6 +133,7 @@ static void test_IWbemLocator(void)
};
IWbemLocator *locator;
IWbemServices *services;
+ IWbemContext *context;
unsigned int i;
HRESULT hr;
BSTR resource;
@@ -146,6 +156,20 @@ static void test_IWbemLocator(void)
SysFreeString( resource );
if (hr == S_OK) IWbemServices_Release( services );
}
+
+ hr = CoCreateInstance( &CLSID_WbemContext, NULL, CLSCTX_INPROC_SERVER, &IID_IWbemContext, (void **)&context );
+ ok(hr == S_OK, "Failed to create context object, hr %#x.\n", hr);
+
+ EXPECT_REF(context, 1);
+ resource = SysAllocString( L"root\\default" );
+ hr = IWbemLocator_ConnectServer( locator, resource, NULL, NULL, NULL, 0, NULL, context, &services );
+ ok(hr == S_OK, "Failed to connect, hr %#x.\n", hr);
+ SysFreeString( resource );
+ EXPECT_REF(context, 1);
+ IWbemServices_Release( services );
+
+ IWbemContext_Release( context );
+
IWbemLocator_Release( locator );
}
diff --git a/dlls/wbemprox/wbemlocator.c b/dlls/wbemprox/wbemlocator.c
index 9b6f2cbc741..5e86f2be86d 100644
--- a/dlls/wbemprox/wbemlocator.c
+++ b/dlls/wbemprox/wbemlocator.c
@@ -161,14 +161,14 @@ static HRESULT WINAPI wbem_locator_ConnectServer(
const BSTR Locale,
LONG SecurityFlags,
const BSTR Authority,
- IWbemContext *pCtx,
+ IWbemContext *context,
IWbemServices **ppNamespace)
{
HRESULT hr;
WCHAR *server, *namespace;
TRACE("%p, %s, %s, %s, %s, 0x%08x, %s, %p, %p)\n", iface, debugstr_w(NetworkResource), debugstr_w(User),
- debugstr_w(Password), debugstr_w(Locale), SecurityFlags, debugstr_w(Authority), pCtx, ppNamespace);
+ debugstr_w(Password), debugstr_w(Locale), SecurityFlags, debugstr_w(Authority), context, ppNamespace);
hr = parse_resource( NetworkResource, &server, &namespace );
if (hr != S_OK) return hr;
@@ -187,7 +187,7 @@ static HRESULT WINAPI wbem_locator_ConnectServer(
if (SecurityFlags)
FIXME("unsupported flags\n");
- hr = WbemServices_create( namespace, (void **)ppNamespace );
+ hr = WbemServices_create( namespace, context, (void **)ppNamespace );
heap_free( namespace );
heap_free( server );
if (SUCCEEDED( hr ))
diff --git a/dlls/wbemprox/wbemprox_private.h b/dlls/wbemprox/wbemprox_private.h
index bae4b5d20c5..7e1efe65874 100644
--- a/dlls/wbemprox/wbemprox_private.h
+++ b/dlls/wbemprox/wbemprox_private.h
@@ -236,7 +236,7 @@ HRESULT create_signature( const WCHAR *, const WCHAR *, enum param_direction,
IWbemClassObject ** ) DECLSPEC_HIDDEN;
HRESULT WbemLocator_create(LPVOID *) DECLSPEC_HIDDEN;
-HRESULT WbemServices_create(const WCHAR *, LPVOID *) DECLSPEC_HIDDEN;
+HRESULT WbemServices_create(const WCHAR *, IWbemContext *, LPVOID *) DECLSPEC_HIDDEN;
HRESULT WbemContext_create(void **) DECLSPEC_HIDDEN;
HRESULT create_class_object(const WCHAR *, IEnumWbemClassObject *, UINT,
struct record *, IWbemClassObject **) DECLSPEC_HIDDEN;
--
2.30.1
2
21
Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com>
---
dlls/wbemdisp/locator.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/dlls/wbemdisp/locator.c b/dlls/wbemdisp/locator.c
index 0ef73bdbd56..dcec47faa6e 100644
--- a/dlls/wbemdisp/locator.c
+++ b/dlls/wbemdisp/locator.c
@@ -1534,11 +1534,14 @@ static HRESULT WINAPI object_Clone_(
static HRESULT WINAPI object_GetObjectText_(
ISWbemObject *iface,
- LONG iFlags,
- BSTR *strObjectText )
+ LONG flags,
+ BSTR *text )
{
- FIXME( "\n" );
- return E_NOTIMPL;
+ struct object *object = impl_from_ISWbemObject( iface );
+
+ TRACE( "%p, %#x, %p\n", object, flags, text );
+
+ return IWbemClassObject_GetObjectText( object->object, flags, text );
}
static HRESULT WINAPI object_SpawnDerivedClass_(
--
2.30.1
2
7
[PATCH tools] tools/winetest: Ensure sticky table header doesn't cover anchor-link target
by Hugh McMaster March 3, 2021
by Hugh McMaster March 3, 2021
March 3, 2021
Signed-off-by: Hugh McMaster <hugh.mcmaster(a)outlook.com>
---
winetest/summary.css | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/winetest/summary.css b/winetest/summary.css
index d01a227..2bc9b44 100644
--- a/winetest/summary.css
+++ b/winetest/summary.css
@@ -36,6 +36,12 @@ div.main, div.group {
width: 100%;
border: 1px solid #601919;
}
+div.main table.report td.test a {
+ scroll-margin-top: 4.25ex;
+}
+div.group table.report td.test a {
+ scroll-margin-top: 7.75ex;
+}
div.navbar {
padding: 0;
width: 100%;
--
2.30.1
1
0
From: Giovanni Mascellani <wine(a)mascellani.eu>
Signed-off-by: Giovanni Mascellani <gmascellani(a)codeweavers.com>
---
dlls/d2d1/d2d1.spec | 2 +-
dlls/d2d1/factory.c | 59 ++++++++++++++++++++++++++++
dlls/d2d1/tests/d2d1.c | 87 ++++++++++++++++++++++++++++++++++++++++++
include/d2d1_1.idl | 2 +
4 files changed, 149 insertions(+), 1 deletion(-)
diff --git a/dlls/d2d1/d2d1.spec b/dlls/d2d1/d2d1.spec
index 0ae894109fb..3fa85a93bae 100644
--- a/dlls/d2d1/d2d1.spec
+++ b/dlls/d2d1/d2d1.spec
@@ -3,7 +3,7 @@
@ stdcall D2D1MakeSkewMatrix(float float float float ptr)
@ stdcall D2D1IsMatrixInvertible(ptr)
@ stdcall D2D1InvertMatrix(ptr)
-@ stub D2D1ConvertColorSpace
+@ stdcall D2D1ConvertColorSpace(long long ptr)
@ stdcall D2D1CreateDevice(ptr ptr ptr)
@ stub D2D1CreateDeviceContext
@ stdcall D2D1SinCos(float ptr ptr)
diff --git a/dlls/d2d1/factory.c b/dlls/d2d1/factory.c
index 6b6eab766c7..fcc09f59672 100644
--- a/dlls/d2d1/factory.c
+++ b/dlls/d2d1/factory.c
@@ -735,6 +735,65 @@ float WINAPI D2D1Vec3Length(float x, float y, float z)
return sqrtf(x * x + y * y + z * z);
}
+/* Formulae taken from https://en.wikipedia.org/wiki/SRGB. */
+static float srgb_transfer_function(float x)
+{
+ if (x <= 0.0f)
+ return 0.0f;
+ else if (x >= 1.0f)
+ return 1.0f;
+ else if (x <= 0.0031308f)
+ return 12.92f * x;
+ else
+ return 1.055f * powf(x, 1.0f / 2.4f) - 0.055f;
+}
+
+static float srgb_inverse_transfer_function(float x)
+{
+ if (x <= 0.0f)
+ return 0.0f;
+ else if (x >= 1.0f)
+ return 1.0f;
+ else if (x <= 0.04045f)
+ return x / 12.92f;
+ else
+ return powf((x + 0.055f) / 1.055f, 2.4f);
+}
+
+D2D1_COLOR_F WINAPI D2D1ConvertColorSpace(D2D1_COLOR_SPACE sourceColorSpace,
+ D2D1_COLOR_SPACE destinationColorSpace, const D2D1_COLOR_F *color)
+{
+ D2D1_COLOR_F ret;
+
+ if (sourceColorSpace == D2D1_COLOR_SPACE_CUSTOM || destinationColorSpace == D2D1_COLOR_SPACE_CUSTOM) {
+ ret.r = 0.0f;
+ ret.g = 0.0f;
+ ret.b = 0.0f;
+ ret.a = 0.0f;
+ } else if (sourceColorSpace == destinationColorSpace) {
+ ret = *color;
+ } else if (sourceColorSpace == D2D1_COLOR_SPACE_SRGB && destinationColorSpace == D2D1_COLOR_SPACE_SCRGB) {
+ ret.r = srgb_inverse_transfer_function(color->r);
+ ret.g = srgb_inverse_transfer_function(color->g);
+ ret.b = srgb_inverse_transfer_function(color->b);
+ ret.a = color->a;
+ } else if (sourceColorSpace == D2D1_COLOR_SPACE_SCRGB && destinationColorSpace == D2D1_COLOR_SPACE_SRGB) {
+ ret.r = srgb_transfer_function(color->r);
+ ret.g = srgb_transfer_function(color->g);
+ ret.b = srgb_transfer_function(color->b);
+ ret.a = color->a;
+ } else {
+ FIXME("unknown combination sourceColorSpace %x, destinationColorSpace %x!\n",
+ sourceColorSpace, destinationColorSpace);
+ ret.r = 0.0f;
+ ret.g = 0.0f;
+ ret.b = 0.0f;
+ ret.a = 0.0f;
+ }
+
+ return ret;
+}
+
static BOOL get_config_key_dword(HKEY default_key, HKEY application_key, const char *name, DWORD *value)
{
DWORD type, data, size;
diff --git a/dlls/d2d1/tests/d2d1.c b/dlls/d2d1/tests/d2d1.c
index 8d584605819..b672765792a 100644
--- a/dlls/d2d1/tests/d2d1.c
+++ b/dlls/d2d1/tests/d2d1.c
@@ -34,6 +34,8 @@ static HRESULT (WINAPI *pD2D1CreateDevice)(IDXGIDevice *dxgi_device,
static void (WINAPI *pD2D1SinCos)(float angle, float *s, float *c);
static float (WINAPI *pD2D1Tan)(float angle);
static float (WINAPI *pD2D1Vec3Length)(float x, float y, float z);
+static D2D1_COLOR_F (WINAPI *pD2D1ConvertColorSpace)(D2D1_COLOR_SPACE sourceColorSpace,
+ D2D1_COLOR_SPACE destinationColorSpace, const D2D1_COLOR_F *color);
static BOOL use_mt = TRUE;
@@ -9466,6 +9468,89 @@ static void test_math(BOOL d3d11)
}
}
+static void test_color_space(BOOL d3d11)
+{
+ D2D1_COLOR_SPACE srcS, dstS;
+ int i, j;
+
+ static struct {
+ D2D1_COLOR_F srgb;
+ D2D1_COLOR_F scrgb;
+ } const test_data[] = {
+ {{0.0f, 0.0f, 0.0f, 0.0f}, {0.0f, 0.0f, 0.0f, 0.0f}},
+ {{0.0f, 0.0f, 0.0f, 1.0f}, {0.0f, 0.0f, 0.0f, 1.0f}},
+ {{1.0f, 1.0f, 1.0f, 1.0f}, {1.0f, 1.0f, 1.0f, 1.0f}},
+ /* Samples in the non-linear region. */
+ {{0.2f, 0.4f, 0.6f, 0.8f}, {0.0331047624f, 0.132868335f, 0.318546832f, 0.8f}},
+ {{0.3f, 0.5f, 0.7f, 0.9f}, {0.0732389688f, 0.214041144f, 0.447988421f, 0.9f}},
+ /* Samples in the linear region. */
+ {{0.0002f, 0.0004f, 0.0006f, 0.0008f}, {1.54798763e-005f, 3.09597526e-005f, 4.64396289e-005f, 0.0008f}},
+ {{0.0003f, 0.0005f, 0.0007f, 0.0009f}, {2.32198145e-005f, 3.86996908e-005f, 5.41795634e-005f, 0.0009f}},
+ };
+
+ if (!pD2D1ConvertColorSpace)
+ {
+ win_skip("D2D1ConvertColorSpace not available, skipping test.\n");
+ return;
+ }
+
+ for (srcS = 0; srcS < 3; srcS++)
+ for (dstS = 0; dstS < 3; dstS++)
+ for (i = 0; i < ARRAY_SIZE(test_data); i++)
+ for (j = 0; j < 3; j++)
+ {
+ D2D1_COLOR_F src = test_data[i].srgb, dst, expect;
+ BOOL change_expect = TRUE;
+
+ if (srcS == D2D1_COLOR_SPACE_SCRGB)
+ src = test_data[i].scrgb;
+ if (srcS == D2D1_COLOR_SPACE_CUSTOM || dstS == D2D1_COLOR_SPACE_CUSTOM)
+ {
+ expect.r = 0.0f;
+ expect.g = 0.0f;
+ expect.b = 0.0f;
+ expect.a = 0.0f;
+ change_expect = FALSE;
+ }
+ else if (srcS == dstS)
+ expect = src;
+ else if (dstS == D2D1_COLOR_SPACE_SRGB)
+ expect = test_data[i].srgb;
+ else if (dstS == D2D1_COLOR_SPACE_SCRGB)
+ expect = test_data[i].scrgb;
+ else
+ ok(0, "Should not arrive here.\n");
+
+ /* Test underflowing or overflowing some components. */
+ if (j == 1)
+ {
+ src.r = -0.5f;
+ src.a = -0.7f;
+ if (change_expect)
+ {
+ expect.r = srcS == dstS ? src.r : 0.0f;
+ expect.a = src.a;
+ }
+ }
+ else if (j == 2)
+ {
+ src.g = 1.5f;
+ src.a = 1.7f;
+ if (change_expect)
+ {
+ expect.g = srcS == dstS ? src.g : 1.0f;
+ expect.a = src.a;
+ }
+ }
+
+ dst = pD2D1ConvertColorSpace(srcS, dstS, &src);
+ ok(compare_float(dst.r, expect.r, 1) && compare_float(dst.g, expect.g, 1)
+ && compare_float(dst.b, expect.b, 1) && compare_float(dst.a, expect.a, 1),
+ "Unexpected value {%.8e, %.8e, %.8e, %.8e} -> {%.8e, %.8e, %.8e, %.8e}, expected {%.8e, %.8e, %.8e, %.8e}, while converting %d -> %d.\n",
+ src.r, src.g, src.b, src.a, dst.r, dst.g, dst.b, dst.a, expect.r, expect.g, expect.b, expect.a, srcS, dstS);
+ }
+}
+
START_TEST(d2d1)
{
HMODULE d2d1_dll = GetModuleHandleA("d2d1.dll");
@@ -9476,6 +9561,7 @@ START_TEST(d2d1)
pD2D1SinCos = (void *)GetProcAddress(d2d1_dll, "D2D1SinCos");
pD2D1Tan = (void *)GetProcAddress(d2d1_dll, "D2D1Tan");
pD2D1Vec3Length = (void *)GetProcAddress(d2d1_dll, "D2D1Vec3Length");
+ pD2D1ConvertColorSpace = (void *)GetProcAddress(d2d1_dll, "D2D1ConvertColorSpace");
use_mt = !getenv("WINETEST_NO_MT_D3D");
@@ -9523,6 +9609,7 @@ START_TEST(d2d1)
queue_test(test_dpi);
queue_test(test_wic_bitmap_format);
queue_d3d10_test(test_math);
+ queue_d3d10_test(test_color_space);
run_queued_tests();
}
diff --git a/include/d2d1_1.idl b/include/d2d1_1.idl
index 1bcadab01d5..e98262c035f 100644
--- a/include/d2d1_1.idl
+++ b/include/d2d1_1.idl
@@ -962,3 +962,5 @@ interface ID2D1Multithread : IUnknown
[local] void __stdcall D2D1SinCos(float angle, float *s, float *c);
[local] float __stdcall D2D1Tan(float angle);
[local] float __stdcall D2D1Vec3Length(float x, float y, float z);
+[local] D2D1_COLOR_F __stdcall D2D1ConvertColorSpace(D2D1_COLOR_SPACE sourceColorSpace,
+ D2D1_COLOR_SPACE destinationColorSpace, const D2D1_COLOR_F *color);
--
2.30.1
1
0