riched20: Remove the text services structure's typedef.

Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Huw Davies 2021-03-03 11:29:39 +00:00 committed by Alexandre Julliard
parent d188686b16
commit 83254bb318
1 changed files with 157 additions and 169 deletions

View File

@ -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);
struct text_services *services = impl_from_IUnknown( iface );
TRACE("(%p)->(%s, %p)\n", iface, debugstr_guid(riid), ppv);
TRACE( "(%p)->(%s, %p)\n", iface, debugstr_guid( iid ), obj );
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)))
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;
}
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*)*ppv);
return S_OK;
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);
struct text_services *services = impl_from_IUnknown( iface );
LONG ref = InterlockedDecrement( &services->ref );
TRACE("(%p) ref=%d\n", This, ref);
TRACE( "(%p) ref = %d\n", services, ref );
if (!ref)
{
ME_DestroyEditor(This->editor);
This->csTxtSrv.DebugInfo->Spare[0] = 0;
DeleteCriticalSection(&This->csTxtSrv);
CoTaskMemFree(This);
}
return 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);
struct text_services *services = 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;
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);
struct text_services *services = 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;
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;
struct text_services *services = 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;
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( This->editor, 0, &start );
ME_GetTextW(This->editor, bstr, length, &start, INT_MAX, FALSE, FALSE);
*pbstrText = bstr;
} else {
*pbstrText = NULL;
}
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;
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;
struct text_services *services = 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);
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;
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)