riched20: The text host should create the text services object.
For now, we hold on to the editor too; this will eventually go away. Signed-off-by: Huw Davies <huw@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
68523af9b0
commit
9b7261d995
|
@ -377,6 +377,9 @@ BOOL ME_Undo(ME_TextEditor *editor) DECLSPEC_HIDDEN;
|
|||
BOOL ME_Redo(ME_TextEditor *editor) DECLSPEC_HIDDEN;
|
||||
void ME_EmptyUndoStack(ME_TextEditor *editor) DECLSPEC_HIDDEN;
|
||||
|
||||
/* txtsrv.c */
|
||||
HRESULT create_text_services( IUnknown *outer, ITextHost *text_host, IUnknown **unk, BOOL emulate_10, ME_TextEditor **editor ) DECLSPEC_HIDDEN;
|
||||
|
||||
/* writer.c */
|
||||
LRESULT ME_StreamOutRange(ME_TextEditor *editor, DWORD dwFormat, const ME_Cursor *start, int nChars, EDITSTREAM *stream) DECLSPEC_HIDDEN;
|
||||
LRESULT ME_StreamOut(ME_TextEditor *editor, DWORD dwFormat, EDITSTREAM *stream) DECLSPEC_HIDDEN;
|
||||
|
|
|
@ -36,6 +36,8 @@ struct host
|
|||
{
|
||||
ITextHost ITextHost_iface;
|
||||
LONG ref;
|
||||
ITextServices *text_srv;
|
||||
ME_TextEditor *editor; /* to be removed */
|
||||
HWND window;
|
||||
BOOL emulate_10;
|
||||
PARAFORMAT2 para_fmt;
|
||||
|
@ -46,7 +48,7 @@ static const ITextHostVtbl textHostVtbl;
|
|||
static BOOL listbox_registered;
|
||||
static BOOL combobox_registered;
|
||||
|
||||
static ITextHost *host_create( HWND hwnd, CREATESTRUCTW *cs, BOOL emulate_10 )
|
||||
struct host *host_create( HWND hwnd, CREATESTRUCTW *cs, BOOL emulate_10 )
|
||||
{
|
||||
struct host *texthost;
|
||||
|
||||
|
@ -66,7 +68,7 @@ static ITextHost *host_create( HWND hwnd, CREATESTRUCTW *cs, BOOL emulate_10 )
|
|||
if (cs->style & ES_CENTER)
|
||||
texthost->para_fmt.wAlignment = PFA_CENTER;
|
||||
|
||||
return &texthost->ITextHost_iface;
|
||||
return texthost;
|
||||
}
|
||||
|
||||
static inline struct host *impl_from_ITextHost( ITextHost *iface )
|
||||
|
@ -104,6 +106,7 @@ static ULONG WINAPI ITextHostImpl_Release(ITextHost *iface)
|
|||
if (!ref)
|
||||
{
|
||||
SetWindowLongPtrW( host->window, 0, 0 );
|
||||
ITextServices_Release( host->text_srv );
|
||||
CoTaskMemFree( host );
|
||||
}
|
||||
return ref;
|
||||
|
@ -723,24 +726,27 @@ static const char *get_msg_name( UINT msg )
|
|||
|
||||
static BOOL create_windowed_editor( HWND hwnd, CREATESTRUCTW *create, BOOL emulate_10 )
|
||||
{
|
||||
ITextHost *host = host_create( hwnd, create, emulate_10 );
|
||||
ME_TextEditor *editor;
|
||||
struct host *host = host_create( hwnd, create, emulate_10 );
|
||||
IUnknown *unk;
|
||||
HRESULT hr;
|
||||
|
||||
if (!host) return FALSE;
|
||||
|
||||
editor = ME_MakeEditor( host, emulate_10 );
|
||||
if (!editor)
|
||||
hr = create_text_services( NULL, &host->ITextHost_iface, &unk, emulate_10, &host->editor );
|
||||
if (FAILED( hr ))
|
||||
{
|
||||
ITextHost_Release( host );
|
||||
ITextHost_Release( &host->ITextHost_iface );
|
||||
return FALSE;
|
||||
}
|
||||
IUnknown_QueryInterface( unk, &IID_ITextServices, (void **)&host->text_srv );
|
||||
IUnknown_Release( unk );
|
||||
|
||||
editor->exStyleFlags = GetWindowLongW( hwnd, GWL_EXSTYLE );
|
||||
editor->styleFlags |= GetWindowLongW( hwnd, GWL_STYLE ) & ES_WANTRETURN;
|
||||
editor->hWnd = hwnd; /* FIXME: Remove editor's dependence on hWnd */
|
||||
editor->hwndParent = create->hwndParent;
|
||||
host->editor->exStyleFlags = GetWindowLongW( hwnd, GWL_EXSTYLE );
|
||||
host->editor->styleFlags |= GetWindowLongW( hwnd, GWL_STYLE ) & ES_WANTRETURN;
|
||||
host->editor->hWnd = hwnd; /* FIXME: Remove editor's dependence on hWnd */
|
||||
host->editor->hwndParent = create->hwndParent;
|
||||
|
||||
SetWindowLongPtrW( hwnd, 0, (LONG_PTR)editor );
|
||||
SetWindowLongPtrW( hwnd, 0, (LONG_PTR)host->editor );
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -368,33 +368,36 @@ static const ITextServicesVtbl textservices_vtbl =
|
|||
THISCALL(fnTextSrv_TxGetCachedSize)
|
||||
};
|
||||
|
||||
HRESULT create_text_services( IUnknown *outer, ITextHost *text_host, IUnknown **unk, BOOL emulate_10,
|
||||
ME_TextEditor **editor )
|
||||
{
|
||||
struct text_services *services;
|
||||
|
||||
TRACE( "%p %p --> %p\n", outer, text_host, unk );
|
||||
if (text_host == NULL) return E_POINTER;
|
||||
|
||||
services = CoTaskMemAlloc( sizeof(*services) );
|
||||
if (services == NULL) return E_OUTOFMEMORY;
|
||||
InitializeCriticalSection( &services->csTxtSrv );
|
||||
services->csTxtSrv.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": ITextServicesImpl.csTxtSrv");
|
||||
services->ref = 1;
|
||||
services->host = text_host; /* Don't take a ref of the host - this would lead to a mutual dependency */
|
||||
services->IUnknown_inner.lpVtbl = &textservices_inner_vtbl;
|
||||
services->ITextServices_iface.lpVtbl = &textservices_vtbl;
|
||||
services->editor = ME_MakeEditor( text_host, emulate_10 );
|
||||
if (editor) *editor = services->editor; /* To be removed */
|
||||
|
||||
if (outer) services->outer_unk = outer;
|
||||
else services->outer_unk = &services->IUnknown_inner;
|
||||
|
||||
*unk = &services->IUnknown_inner;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
/******************************************************************
|
||||
* CreateTextServices (RICHED20.4)
|
||||
*/
|
||||
HRESULT WINAPI CreateTextServices(IUnknown *pUnkOuter, ITextHost *pITextHost, IUnknown **ppUnk)
|
||||
HRESULT WINAPI CreateTextServices( IUnknown *outer, ITextHost *text_host, IUnknown **unk )
|
||||
{
|
||||
struct text_services *ITextImpl;
|
||||
|
||||
TRACE("%p %p --> %p\n", pUnkOuter, pITextHost, ppUnk);
|
||||
if (pITextHost == NULL)
|
||||
return E_POINTER;
|
||||
|
||||
ITextImpl = CoTaskMemAlloc(sizeof(*ITextImpl));
|
||||
if (ITextImpl == NULL)
|
||||
return E_OUTOFMEMORY;
|
||||
InitializeCriticalSection(&ITextImpl->csTxtSrv);
|
||||
ITextImpl->csTxtSrv.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": ITextServicesImpl.csTxtSrv");
|
||||
ITextImpl->ref = 1;
|
||||
ITextImpl->host = pITextHost; /* Don't take a ref of the host - this would lead to a mutual dependency */
|
||||
ITextImpl->IUnknown_inner.lpVtbl = &textservices_inner_vtbl;
|
||||
ITextImpl->ITextServices_iface.lpVtbl = &textservices_vtbl;
|
||||
ITextImpl->editor = ME_MakeEditor(pITextHost, FALSE);
|
||||
|
||||
if (pUnkOuter)
|
||||
ITextImpl->outer_unk = pUnkOuter;
|
||||
else
|
||||
ITextImpl->outer_unk = &ITextImpl->IUnknown_inner;
|
||||
|
||||
*ppUnk = &ITextImpl->IUnknown_inner;
|
||||
return S_OK;
|
||||
return create_text_services( outer, text_host, unk, FALSE, NULL );
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue