2006-02-01 12:31:40 +01:00
|
|
|
/*
|
|
|
|
* RichEdit - functions and interfaces around CreateTextServices
|
|
|
|
*
|
|
|
|
* Copyright 2005, 2006, Maarten Lankhorst
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2006-02-01 12:31:40 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#define COBJMACROS
|
|
|
|
|
|
|
|
#include "editor.h"
|
|
|
|
#include "ole2.h"
|
2009-01-20 07:41:44 +01:00
|
|
|
#include "oleauto.h"
|
2006-02-01 12:31:40 +01:00
|
|
|
#include "richole.h"
|
2014-10-28 13:10:46 +01:00
|
|
|
#include "tom.h"
|
2006-02-01 12:31:40 +01:00
|
|
|
#include "imm.h"
|
|
|
|
#include "textserv.h"
|
|
|
|
#include "wine/debug.h"
|
|
|
|
#include "editstr.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(richedit);
|
|
|
|
|
2021-03-03 12:29:39 +01:00
|
|
|
struct text_services
|
|
|
|
{
|
2021-03-08 14:45:48 +01:00
|
|
|
IUnknown IUnknown_inner;
|
|
|
|
ITextServices ITextServices_iface;
|
|
|
|
IUnknown *outer_unk;
|
|
|
|
LONG ref;
|
|
|
|
ITextHost *host;
|
|
|
|
ME_TextEditor *editor;
|
|
|
|
char spare[256]; /* for bug #12179 */
|
2021-03-03 12:29:39 +01:00
|
|
|
};
|
2006-02-01 12:31:40 +01:00
|
|
|
|
2021-03-03 12:29:39 +01:00
|
|
|
static inline struct text_services *impl_from_IUnknown( IUnknown *iface )
|
2011-04-10 21:44:44 +02:00
|
|
|
{
|
2021-03-03 12:29:39 +01:00
|
|
|
return CONTAINING_RECORD( iface, struct text_services, IUnknown_inner );
|
2011-04-10 21:44:44 +02:00
|
|
|
}
|
2006-02-01 12:31:40 +01:00
|
|
|
|
2021-03-03 12:29:39 +01:00
|
|
|
static HRESULT WINAPI ITextServicesImpl_QueryInterface( IUnknown *iface, REFIID iid, void **obj )
|
2006-02-01 12:31:40 +01:00
|
|
|
{
|
2021-03-03 12:29:39 +01:00
|
|
|
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 ))
|
2014-10-28 13:10:46 +01:00
|
|
|
return E_OUTOFMEMORY;
|
2021-03-03 12:29:39 +01:00
|
|
|
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;
|
2006-02-01 12:31:40 +01:00
|
|
|
}
|
|
|
|
|
2012-03-28 00:33:10 +02:00
|
|
|
static ULONG WINAPI ITextServicesImpl_AddRef(IUnknown *iface)
|
2006-02-01 12:31:40 +01:00
|
|
|
{
|
2021-03-03 12:29:39 +01:00
|
|
|
struct text_services *services = impl_from_IUnknown( iface );
|
|
|
|
LONG ref = InterlockedIncrement( &services->ref );
|
2012-03-28 00:33:10 +02:00
|
|
|
|
2021-03-03 12:29:39 +01:00
|
|
|
TRACE( "(%p) ref = %d\n", services, ref );
|
2006-02-01 12:31:40 +01:00
|
|
|
|
2021-03-03 12:29:39 +01:00
|
|
|
return ref;
|
2006-02-01 12:31:40 +01:00
|
|
|
}
|
|
|
|
|
2012-03-28 00:33:10 +02:00
|
|
|
static ULONG WINAPI ITextServicesImpl_Release(IUnknown *iface)
|
2006-02-01 12:31:40 +01:00
|
|
|
{
|
2021-03-03 12:29:39 +01:00
|
|
|
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 );
|
|
|
|
CoTaskMemFree( services );
|
|
|
|
}
|
|
|
|
return ref;
|
2006-02-01 12:31:40 +01:00
|
|
|
}
|
|
|
|
|
2012-03-28 00:33:10 +02:00
|
|
|
static const IUnknownVtbl textservices_inner_vtbl =
|
|
|
|
{
|
|
|
|
ITextServicesImpl_QueryInterface,
|
|
|
|
ITextServicesImpl_AddRef,
|
|
|
|
ITextServicesImpl_Release
|
|
|
|
};
|
|
|
|
|
2021-03-03 12:29:39 +01:00
|
|
|
static inline struct text_services *impl_from_ITextServices( ITextServices *iface )
|
2012-03-28 00:33:10 +02:00
|
|
|
{
|
2021-03-03 12:29:39 +01:00
|
|
|
return CONTAINING_RECORD( iface, struct text_services, ITextServices_iface );
|
2012-03-28 00:33:10 +02:00
|
|
|
}
|
|
|
|
|
2021-03-03 12:29:39 +01:00
|
|
|
static HRESULT WINAPI fnTextSrv_QueryInterface( ITextServices *iface, REFIID iid, void **obj )
|
2012-03-28 00:33:10 +02:00
|
|
|
{
|
2021-03-03 12:29:39 +01:00
|
|
|
struct text_services *services = impl_from_ITextServices( iface );
|
|
|
|
return IUnknown_QueryInterface( services->outer_unk, iid, obj );
|
2012-03-28 00:33:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI fnTextSrv_AddRef(ITextServices *iface)
|
|
|
|
{
|
2021-03-03 12:29:39 +01:00
|
|
|
struct text_services *services = impl_from_ITextServices( iface );
|
|
|
|
return IUnknown_AddRef( services->outer_unk );
|
2012-03-28 00:33:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI fnTextSrv_Release(ITextServices *iface)
|
|
|
|
{
|
2021-03-03 12:29:39 +01:00
|
|
|
struct text_services *services = impl_from_ITextServices( iface );
|
|
|
|
return IUnknown_Release( services->outer_unk );
|
2012-03-28 00:33:10 +02:00
|
|
|
}
|
|
|
|
|
2019-05-15 20:07:53 +02:00
|
|
|
DEFINE_THISCALL_WRAPPER(fnTextSrv_TxSendMessage,20)
|
2021-03-17 09:45:28 +01:00
|
|
|
DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_TxSendMessage( ITextServices *iface, UINT msg, WPARAM wparam,
|
|
|
|
LPARAM lparam, LRESULT *result )
|
2006-02-01 12:31:40 +01:00
|
|
|
{
|
2021-03-17 09:45:28 +01:00
|
|
|
struct text_services *services = impl_from_ITextServices( iface );
|
|
|
|
HRESULT hr;
|
|
|
|
LRESULT res;
|
2006-02-01 12:31:40 +01:00
|
|
|
|
2021-03-17 09:45:28 +01:00
|
|
|
res = editor_handle_message( services->editor, msg, wparam, lparam, &hr );
|
|
|
|
if (result) *result = res;
|
|
|
|
return hr;
|
2006-02-01 12:31:40 +01:00
|
|
|
}
|
|
|
|
|
2021-03-23 14:04:07 +01:00
|
|
|
static HRESULT update_client_rect( struct text_services *services, const RECT *client )
|
|
|
|
{
|
|
|
|
RECT rect;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
if (!client)
|
|
|
|
{
|
|
|
|
if (!services->editor->in_place_active) return E_INVALIDARG;
|
|
|
|
hr = ITextHost_TxGetClientRect( services->host, &rect );
|
|
|
|
if (FAILED( hr )) return hr;
|
|
|
|
}
|
|
|
|
else rect = *client;
|
|
|
|
|
|
|
|
rect.left += services->editor->selofs;
|
|
|
|
|
|
|
|
if (EqualRect( &rect, &services->editor->rcFormat )) return S_FALSE;
|
|
|
|
services->editor->rcFormat = rect;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2019-05-15 20:07:53 +02:00
|
|
|
DEFINE_THISCALL_WRAPPER(fnTextSrv_TxDraw,52)
|
2021-03-23 14:04:07 +01:00
|
|
|
DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_TxDraw( ITextServices *iface, DWORD aspect, LONG index, void *aspect_info,
|
|
|
|
DVTARGETDEVICE *td, HDC draw, HDC target,
|
|
|
|
const RECTL *bounds, const RECTL *mf_bounds, RECT *update,
|
|
|
|
BOOL (CALLBACK *continue_fn)(DWORD), DWORD continue_param,
|
|
|
|
LONG view_id )
|
2006-02-01 12:31:40 +01:00
|
|
|
{
|
2021-03-03 12:29:39 +01:00
|
|
|
struct text_services *services = impl_from_ITextServices( iface );
|
2021-03-23 14:04:07 +01:00
|
|
|
HRESULT hr;
|
|
|
|
HDC dc = draw;
|
|
|
|
BOOL rewrap = FALSE;
|
2006-02-01 12:31:40 +01:00
|
|
|
|
2021-03-23 14:04:07 +01:00
|
|
|
TRACE( "%p: aspect %d, %d, %p, %p, draw %p, target %p, bounds %s, mf_bounds %s, update %s, %p, %d, view %d\n",
|
|
|
|
services, aspect, index, aspect_info, td, draw, target, wine_dbgstr_rect( (RECT *)bounds ),
|
|
|
|
wine_dbgstr_rect( (RECT *)mf_bounds ), wine_dbgstr_rect( update ), continue_fn, continue_param, view_id );
|
|
|
|
|
|
|
|
if (aspect != DVASPECT_CONTENT || aspect_info || td || target || mf_bounds || continue_fn )
|
|
|
|
FIXME( "Many arguments are ignored\n" );
|
|
|
|
|
|
|
|
hr = update_client_rect( services, (RECT *)bounds );
|
|
|
|
if (FAILED( hr )) return hr;
|
|
|
|
if (hr == S_OK) rewrap = TRUE;
|
|
|
|
|
|
|
|
if (!dc && services->editor->in_place_active)
|
|
|
|
dc = ITextHost_TxGetDC( services->host );
|
|
|
|
if (!dc) return E_FAIL;
|
|
|
|
|
|
|
|
if (rewrap)
|
|
|
|
{
|
|
|
|
editor_mark_rewrap_all( services->editor );
|
2021-03-25 10:10:27 +01:00
|
|
|
wrap_marked_paras_dc( services->editor, dc, FALSE );
|
2021-03-23 14:04:07 +01:00
|
|
|
}
|
|
|
|
editor_draw( services->editor, dc, update );
|
|
|
|
|
|
|
|
if (!draw) ITextHost_TxReleaseDC( services->host, dc );
|
|
|
|
return S_OK;
|
2006-02-01 12:31:40 +01:00
|
|
|
}
|
|
|
|
|
2019-05-15 20:07:53 +02:00
|
|
|
DEFINE_THISCALL_WRAPPER(fnTextSrv_TxGetHScroll,24)
|
2021-03-03 12:29:39 +01:00
|
|
|
DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_TxGetHScroll( ITextServices *iface, LONG *min_pos, LONG *max_pos, LONG *pos,
|
|
|
|
LONG *page, BOOL *enabled )
|
2006-02-01 12:31:40 +01:00
|
|
|
{
|
2021-03-03 12:29:39 +01:00
|
|
|
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;
|
2021-03-22 09:55:50 +01:00
|
|
|
if (enabled) *enabled = services->editor->horz_sb_enabled;
|
2021-03-03 12:29:39 +01:00
|
|
|
return S_OK;
|
2006-02-01 12:31:40 +01:00
|
|
|
}
|
|
|
|
|
2019-05-15 20:07:53 +02:00
|
|
|
DEFINE_THISCALL_WRAPPER(fnTextSrv_TxGetVScroll,24)
|
2021-03-03 12:29:39 +01:00
|
|
|
DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_TxGetVScroll( ITextServices *iface, LONG *min_pos, LONG *max_pos, LONG *pos,
|
|
|
|
LONG *page, BOOL *enabled )
|
2006-02-01 12:31:40 +01:00
|
|
|
{
|
2021-03-03 12:29:39 +01:00
|
|
|
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;
|
2021-03-22 09:55:50 +01:00
|
|
|
if (enabled) *enabled = services->editor->vert_sb_enabled;
|
2021-03-03 12:29:39 +01:00
|
|
|
return S_OK;
|
2006-02-01 12:31:40 +01:00
|
|
|
}
|
|
|
|
|
2019-05-15 20:07:53 +02:00
|
|
|
DEFINE_THISCALL_WRAPPER(fnTextSrv_OnTxSetCursor,40)
|
2021-03-18 09:30:09 +01:00
|
|
|
DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_OnTxSetCursor( ITextServices *iface, DWORD aspect, LONG index,
|
|
|
|
void *aspect_info, DVTARGETDEVICE *td, HDC draw,
|
|
|
|
HDC target, const RECT *client, INT x, INT y )
|
2006-02-01 12:31:40 +01:00
|
|
|
{
|
2021-03-03 12:29:39 +01:00
|
|
|
struct text_services *services = impl_from_ITextServices( iface );
|
2006-02-01 12:31:40 +01:00
|
|
|
|
2021-03-18 09:30:09 +01:00
|
|
|
TRACE( "%p: %d, %d, %p, %p, draw %p target %p client %s pos (%d, %d)\n", services, aspect, index, aspect_info, td, draw,
|
|
|
|
target, wine_dbgstr_rect( client ), x, y );
|
|
|
|
|
|
|
|
if (aspect != DVASPECT_CONTENT || index || aspect_info || td || draw || target || client)
|
|
|
|
FIXME( "Ignoring most params\n" );
|
|
|
|
|
|
|
|
link_notify( services->editor, WM_SETCURSOR, 0, MAKELPARAM( x, y ) );
|
|
|
|
editor_set_cursor( services->editor, x, y );
|
|
|
|
return S_OK;
|
2006-02-01 12:31:40 +01:00
|
|
|
}
|
|
|
|
|
2019-05-15 20:07:53 +02:00
|
|
|
DEFINE_THISCALL_WRAPPER(fnTextSrv_TxQueryHitPoint,44)
|
|
|
|
DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_TxQueryHitPoint(ITextServices *iface, DWORD dwDrawAspect, LONG lindex,
|
|
|
|
void *pvAspect, DVTARGETDEVICE *ptd, HDC hdcDraw,
|
|
|
|
HDC hicTargetDev, LPCRECT lprcClient, INT x, INT y,
|
|
|
|
DWORD *pHitResult)
|
2006-02-01 12:31:40 +01:00
|
|
|
{
|
2021-03-03 12:29:39 +01:00
|
|
|
struct text_services *services = impl_from_ITextServices( iface );
|
2006-02-01 12:31:40 +01:00
|
|
|
|
2021-03-03 12:29:39 +01:00
|
|
|
FIXME( "%p: STUB\n", services );
|
|
|
|
return E_NOTIMPL;
|
2006-02-01 12:31:40 +01:00
|
|
|
}
|
|
|
|
|
2021-03-19 10:14:17 +01:00
|
|
|
DEFINE_THISCALL_WRAPPER(fnTextSrv_OnTxInPlaceActivate,8)
|
2021-03-22 09:55:49 +01:00
|
|
|
DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_OnTxInPlaceActivate( ITextServices *iface, const RECT *client )
|
2006-02-01 12:31:40 +01:00
|
|
|
{
|
2021-03-03 12:29:39 +01:00
|
|
|
struct text_services *services = impl_from_ITextServices( iface );
|
2021-03-22 09:55:49 +01:00
|
|
|
HRESULT hr;
|
|
|
|
BOOL old_active = services->editor->in_place_active;
|
2006-02-01 12:31:40 +01:00
|
|
|
|
2021-03-22 09:55:49 +01:00
|
|
|
TRACE( "%p: %s\n", services, wine_dbgstr_rect( client ) );
|
|
|
|
|
|
|
|
services->editor->in_place_active = TRUE;
|
|
|
|
hr = update_client_rect( services, client );
|
|
|
|
if (FAILED( hr ))
|
|
|
|
{
|
|
|
|
services->editor->in_place_active = old_active;
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
ME_RewrapRepaint( services->editor );
|
|
|
|
return S_OK;
|
2006-02-01 12:31:40 +01:00
|
|
|
}
|
|
|
|
|
2021-03-19 10:14:17 +01:00
|
|
|
DEFINE_THISCALL_WRAPPER(fnTextSrv_OnTxInPlaceDeactivate,4)
|
|
|
|
DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_OnTxInPlaceDeactivate(ITextServices *iface)
|
2006-02-01 12:31:40 +01:00
|
|
|
{
|
2021-03-03 12:29:39 +01:00
|
|
|
struct text_services *services = impl_from_ITextServices( iface );
|
2006-02-01 12:31:40 +01:00
|
|
|
|
2021-03-22 09:55:49 +01:00
|
|
|
TRACE( "%p\n", services );
|
|
|
|
services->editor->in_place_active = FALSE;
|
|
|
|
return S_OK;
|
2006-02-01 12:31:40 +01:00
|
|
|
}
|
|
|
|
|
2019-05-15 20:07:53 +02:00
|
|
|
DEFINE_THISCALL_WRAPPER(fnTextSrv_OnTxUIActivate,4)
|
|
|
|
DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_OnTxUIActivate(ITextServices *iface)
|
2006-02-01 12:31:40 +01:00
|
|
|
{
|
2021-03-03 12:29:39 +01:00
|
|
|
struct text_services *services = impl_from_ITextServices( iface );
|
2006-02-01 12:31:40 +01:00
|
|
|
|
2021-03-03 12:29:39 +01:00
|
|
|
FIXME( "%p: STUB\n", services );
|
|
|
|
return E_NOTIMPL;
|
2006-02-01 12:31:40 +01:00
|
|
|
}
|
|
|
|
|
2019-05-15 20:07:53 +02:00
|
|
|
DEFINE_THISCALL_WRAPPER(fnTextSrv_OnTxUIDeactivate,4)
|
|
|
|
DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_OnTxUIDeactivate(ITextServices *iface)
|
2006-02-01 12:31:40 +01:00
|
|
|
{
|
2021-03-03 12:29:39 +01:00
|
|
|
struct text_services *services = impl_from_ITextServices( iface );
|
2006-02-01 12:31:40 +01:00
|
|
|
|
2021-03-03 12:29:39 +01:00
|
|
|
FIXME( "%p: STUB\n", services );
|
|
|
|
return E_NOTIMPL;
|
2006-02-01 12:31:40 +01:00
|
|
|
}
|
|
|
|
|
2019-05-15 20:07:53 +02:00
|
|
|
DEFINE_THISCALL_WRAPPER(fnTextSrv_TxGetText,8)
|
2021-03-03 12:29:39 +01:00
|
|
|
DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_TxGetText( ITextServices *iface, BSTR *text )
|
2006-02-01 12:31:40 +01:00
|
|
|
{
|
2021-03-03 12:29:39 +01:00
|
|
|
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;
|
2006-02-01 12:31:40 +01:00
|
|
|
}
|
|
|
|
|
2019-05-15 20:07:53 +02:00
|
|
|
DEFINE_THISCALL_WRAPPER(fnTextSrv_TxSetText,8)
|
2021-03-03 12:29:39 +01:00
|
|
|
DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_TxSetText( ITextServices *iface, const WCHAR *text )
|
2006-02-01 12:31:40 +01:00
|
|
|
{
|
2021-03-03 12:29:39 +01:00
|
|
|
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;
|
2006-02-01 12:31:40 +01:00
|
|
|
}
|
|
|
|
|
2019-05-15 20:07:53 +02:00
|
|
|
DEFINE_THISCALL_WRAPPER(fnTextSrv_TxGetCurTargetX,8)
|
|
|
|
DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_TxGetCurTargetX(ITextServices *iface, LONG *x)
|
2006-02-01 12:31:40 +01:00
|
|
|
{
|
2021-03-03 12:29:39 +01:00
|
|
|
struct text_services *services = impl_from_ITextServices( iface );
|
2006-02-01 12:31:40 +01:00
|
|
|
|
2021-03-03 12:29:39 +01:00
|
|
|
FIXME( "%p: STUB\n", services );
|
|
|
|
return E_NOTIMPL;
|
2006-02-01 12:31:40 +01:00
|
|
|
}
|
|
|
|
|
2019-05-15 20:07:53 +02:00
|
|
|
DEFINE_THISCALL_WRAPPER(fnTextSrv_TxGetBaseLinePos,8)
|
|
|
|
DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_TxGetBaseLinePos(ITextServices *iface, LONG *x)
|
2006-02-01 12:31:40 +01:00
|
|
|
{
|
2021-03-03 12:29:39 +01:00
|
|
|
struct text_services *services = impl_from_ITextServices( iface );
|
2006-02-01 12:31:40 +01:00
|
|
|
|
2021-03-03 12:29:39 +01:00
|
|
|
FIXME( "%p: STUB\n", services );
|
|
|
|
return E_NOTIMPL;
|
2006-02-01 12:31:40 +01:00
|
|
|
}
|
|
|
|
|
2019-05-15 20:07:53 +02:00
|
|
|
DEFINE_THISCALL_WRAPPER(fnTextSrv_TxGetNaturalSize,36)
|
2021-03-25 10:10:28 +01:00
|
|
|
DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_TxGetNaturalSize( ITextServices *iface, DWORD aspect, HDC draw,
|
|
|
|
HDC target, DVTARGETDEVICE *td, DWORD mode,
|
|
|
|
const SIZEL *extent, LONG *width, LONG *height )
|
2006-02-01 12:31:40 +01:00
|
|
|
{
|
2021-03-03 12:29:39 +01:00
|
|
|
struct text_services *services = impl_from_ITextServices( iface );
|
2021-03-25 10:10:28 +01:00
|
|
|
RECT rect;
|
|
|
|
HDC dc = draw;
|
|
|
|
BOOL rewrap = FALSE;
|
|
|
|
HRESULT hr;
|
2006-02-01 12:31:40 +01:00
|
|
|
|
2021-03-25 10:10:28 +01:00
|
|
|
TRACE( "%p: aspect %d, draw %p, target %p, td %p, mode %08x, extent %s, *width %d, *height %d\n", services,
|
|
|
|
aspect, draw, target, td, mode, wine_dbgstr_point( (POINT *)extent ), *width, *height );
|
|
|
|
|
|
|
|
if (aspect != DVASPECT_CONTENT || target || td || mode != TXTNS_FITTOCONTENT )
|
|
|
|
FIXME( "Many arguments are ignored\n" );
|
|
|
|
|
|
|
|
SetRect( &rect, 0, 0, *width, *height );
|
|
|
|
|
|
|
|
hr = update_client_rect( services, &rect );
|
|
|
|
if (FAILED( hr )) return hr;
|
|
|
|
if (hr == S_OK) rewrap = TRUE;
|
|
|
|
|
|
|
|
if (!dc && services->editor->in_place_active)
|
|
|
|
dc = ITextHost_TxGetDC( services->host );
|
|
|
|
if (!dc) return E_FAIL;
|
|
|
|
|
|
|
|
if (rewrap)
|
|
|
|
{
|
|
|
|
editor_mark_rewrap_all( services->editor );
|
|
|
|
wrap_marked_paras_dc( services->editor, dc, FALSE );
|
|
|
|
}
|
|
|
|
|
|
|
|
*width = services->editor->nTotalWidth;
|
|
|
|
*height = services->editor->nTotalLength;
|
|
|
|
|
|
|
|
if (!draw) ITextHost_TxReleaseDC( services->host, dc );
|
|
|
|
return S_OK;
|
2006-02-01 12:31:40 +01:00
|
|
|
}
|
|
|
|
|
2019-05-15 20:07:53 +02:00
|
|
|
DEFINE_THISCALL_WRAPPER(fnTextSrv_TxGetDropTarget,8)
|
|
|
|
DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_TxGetDropTarget(ITextServices *iface, IDropTarget **ppDropTarget)
|
2006-02-01 12:31:40 +01:00
|
|
|
{
|
2021-03-03 12:29:39 +01:00
|
|
|
struct text_services *services = impl_from_ITextServices( iface );
|
2006-02-01 12:31:40 +01:00
|
|
|
|
2021-03-03 12:29:39 +01:00
|
|
|
FIXME( "%p: STUB\n", services );
|
|
|
|
return E_NOTIMPL;
|
2006-02-01 12:31:40 +01:00
|
|
|
}
|
|
|
|
|
2019-05-15 20:07:53 +02:00
|
|
|
DEFINE_THISCALL_WRAPPER(fnTextSrv_OnTxPropertyBitsChange,12)
|
2021-03-16 09:22:45 +01:00
|
|
|
DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_OnTxPropertyBitsChange( ITextServices *iface, DWORD mask, DWORD bits )
|
2006-02-01 12:31:40 +01:00
|
|
|
{
|
2021-03-03 12:29:39 +01:00
|
|
|
struct text_services *services = impl_from_ITextServices( iface );
|
2021-03-16 09:22:46 +01:00
|
|
|
DWORD scrollbars;
|
|
|
|
HRESULT hr;
|
2021-03-17 09:45:26 +01:00
|
|
|
BOOL repaint = FALSE;
|
2006-02-01 12:31:40 +01:00
|
|
|
|
2021-03-16 09:22:45 +01:00
|
|
|
TRACE( "%p, mask %08x, bits %08x\n", services, mask, bits );
|
|
|
|
|
|
|
|
services->editor->props = (services->editor->props & ~mask) | (bits & mask);
|
2021-03-19 10:14:16 +01:00
|
|
|
if (mask & (TXTBIT_WORDWRAP | TXTBIT_MULTILINE))
|
|
|
|
services->editor->bWordWrap = (services->editor->props & TXTBIT_WORDWRAP) && (services->editor->props & TXTBIT_MULTILINE);
|
2021-03-16 09:22:45 +01:00
|
|
|
|
2021-03-16 09:22:46 +01:00
|
|
|
if (mask & TXTBIT_SCROLLBARCHANGE)
|
|
|
|
{
|
|
|
|
hr = ITextHost_TxGetScrollBars( services->host, &scrollbars );
|
|
|
|
if (SUCCEEDED( hr ))
|
|
|
|
{
|
|
|
|
if ((services->editor->scrollbars ^ scrollbars) & WS_HSCROLL)
|
|
|
|
ITextHost_TxShowScrollBar( services->host, SB_HORZ, (scrollbars & WS_HSCROLL) &&
|
|
|
|
services->editor->nTotalWidth > services->editor->sizeWindow.cx );
|
|
|
|
if ((services->editor->scrollbars ^ scrollbars) & WS_VSCROLL)
|
|
|
|
ITextHost_TxShowScrollBar( services->host, SB_VERT, (scrollbars & WS_VSCROLL) &&
|
|
|
|
services->editor->nTotalLength > services->editor->sizeWindow.cy );
|
|
|
|
services->editor->scrollbars = scrollbars;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-16 09:22:47 +01:00
|
|
|
if ((mask & TXTBIT_HIDESELECTION) && !services->editor->bHaveFocus) ME_InvalidateSelection( services->editor );
|
|
|
|
|
2021-03-17 09:45:26 +01:00
|
|
|
if (mask & TXTBIT_SELBARCHANGE)
|
|
|
|
{
|
|
|
|
LONG width;
|
|
|
|
|
|
|
|
hr = ITextHost_TxGetSelectionBarWidth( services->host, &width );
|
|
|
|
if (hr == S_OK)
|
|
|
|
{
|
|
|
|
ITextHost_TxInvalidateRect( services->host, &services->editor->rcFormat, TRUE );
|
|
|
|
services->editor->rcFormat.left -= services->editor->selofs;
|
|
|
|
services->editor->selofs = width ? SELECTIONBAR_WIDTH : 0; /* FIXME: convert from HIMETRIC */
|
|
|
|
services->editor->rcFormat.left += services->editor->selofs;
|
|
|
|
repaint = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-17 09:45:27 +01:00
|
|
|
if (mask & TXTBIT_CLIENTRECTCHANGE)
|
|
|
|
{
|
|
|
|
hr = update_client_rect( services, NULL );
|
|
|
|
if (SUCCEEDED( hr )) repaint = TRUE;
|
|
|
|
}
|
|
|
|
|
2021-03-18 09:30:07 +01:00
|
|
|
if (mask & TXTBIT_USEPASSWORD)
|
|
|
|
{
|
|
|
|
if (bits & TXTBIT_USEPASSWORD) ITextHost_TxGetPasswordChar( services->host, &services->editor->password_char );
|
|
|
|
else services->editor->password_char = 0;
|
|
|
|
repaint = TRUE;
|
|
|
|
}
|
|
|
|
|
2021-03-17 09:45:26 +01:00
|
|
|
if (repaint) ME_RewrapRepaint( services->editor );
|
|
|
|
|
2021-03-16 09:22:45 +01:00
|
|
|
return S_OK;
|
2006-02-01 12:31:40 +01:00
|
|
|
}
|
|
|
|
|
2019-05-15 20:07:53 +02:00
|
|
|
DEFINE_THISCALL_WRAPPER(fnTextSrv_TxGetCachedSize,12)
|
|
|
|
DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_TxGetCachedSize(ITextServices *iface, DWORD *pdwWidth, DWORD *pdwHeight)
|
2006-02-01 12:31:40 +01:00
|
|
|
{
|
2021-03-03 12:29:39 +01:00
|
|
|
struct text_services *services = impl_from_ITextServices( iface );
|
2006-02-01 12:31:40 +01:00
|
|
|
|
2021-03-03 12:29:39 +01:00
|
|
|
FIXME( "%p: STUB\n", services );
|
|
|
|
return E_NOTIMPL;
|
2006-02-01 12:31:40 +01:00
|
|
|
}
|
|
|
|
|
2021-03-11 09:50:59 +01:00
|
|
|
#ifdef __ASM_USE_THISCALL_WRAPPER
|
|
|
|
|
|
|
|
#define STDCALL(func) (void *) __stdcall_ ## func
|
|
|
|
#ifdef _MSC_VER
|
|
|
|
#define DEFINE_STDCALL_WRAPPER(num,func) \
|
|
|
|
__declspec(naked) HRESULT __stdcall_##func(void) \
|
|
|
|
{ \
|
|
|
|
__asm pop eax \
|
|
|
|
__asm pop ecx \
|
|
|
|
__asm push eax \
|
|
|
|
__asm mov eax, [ecx] \
|
|
|
|
__asm jmp dword ptr [eax + 4*num] \
|
|
|
|
}
|
|
|
|
#else /* _MSC_VER */
|
|
|
|
#define DEFINE_STDCALL_WRAPPER(num,func) \
|
|
|
|
extern HRESULT __stdcall_ ## func(void); \
|
|
|
|
__ASM_GLOBAL_FUNC(__stdcall_ ## func, \
|
|
|
|
"popl %eax\n\t" \
|
|
|
|
"popl %ecx\n\t" \
|
|
|
|
"pushl %eax\n\t" \
|
|
|
|
"movl (%ecx), %eax\n\t" \
|
|
|
|
"jmp *(4*(" #num "))(%eax)" )
|
|
|
|
#endif /* _MSC_VER */
|
|
|
|
|
|
|
|
DEFINE_STDCALL_WRAPPER(3, ITextServices_TxSendMessage)
|
|
|
|
DEFINE_STDCALL_WRAPPER(4, ITextServices_TxDraw)
|
|
|
|
DEFINE_STDCALL_WRAPPER(5, ITextServices_TxGetHScroll)
|
|
|
|
DEFINE_STDCALL_WRAPPER(6, ITextServices_TxGetVScroll)
|
|
|
|
DEFINE_STDCALL_WRAPPER(7, ITextServices_OnTxSetCursor)
|
|
|
|
DEFINE_STDCALL_WRAPPER(8, ITextServices_TxQueryHitPoint)
|
2021-03-19 10:14:17 +01:00
|
|
|
DEFINE_STDCALL_WRAPPER(9, ITextServices_OnTxInPlaceActivate)
|
|
|
|
DEFINE_STDCALL_WRAPPER(10, ITextServices_OnTxInPlaceDeactivate)
|
2021-03-11 09:50:59 +01:00
|
|
|
DEFINE_STDCALL_WRAPPER(11, ITextServices_OnTxUIActivate)
|
|
|
|
DEFINE_STDCALL_WRAPPER(12, ITextServices_OnTxUIDeactivate)
|
|
|
|
DEFINE_STDCALL_WRAPPER(13, ITextServices_TxGetText)
|
|
|
|
DEFINE_STDCALL_WRAPPER(14, ITextServices_TxSetText)
|
|
|
|
DEFINE_STDCALL_WRAPPER(15, ITextServices_TxGetCurTargetX)
|
|
|
|
DEFINE_STDCALL_WRAPPER(16, ITextServices_TxGetBaseLinePos)
|
|
|
|
DEFINE_STDCALL_WRAPPER(17, ITextServices_TxGetNaturalSize)
|
|
|
|
DEFINE_STDCALL_WRAPPER(18, ITextServices_TxGetDropTarget)
|
|
|
|
DEFINE_STDCALL_WRAPPER(19, ITextServices_OnTxPropertyBitsChange)
|
|
|
|
DEFINE_STDCALL_WRAPPER(20, ITextServices_TxGetCachedSize)
|
|
|
|
|
|
|
|
const ITextServicesVtbl text_services_stdcall_vtbl =
|
|
|
|
{
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
STDCALL(ITextServices_TxSendMessage),
|
|
|
|
STDCALL(ITextServices_TxDraw),
|
|
|
|
STDCALL(ITextServices_TxGetHScroll),
|
|
|
|
STDCALL(ITextServices_TxGetVScroll),
|
|
|
|
STDCALL(ITextServices_OnTxSetCursor),
|
|
|
|
STDCALL(ITextServices_TxQueryHitPoint),
|
2021-03-19 10:14:17 +01:00
|
|
|
STDCALL(ITextServices_OnTxInPlaceActivate),
|
|
|
|
STDCALL(ITextServices_OnTxInPlaceDeactivate),
|
2021-03-11 09:50:59 +01:00
|
|
|
STDCALL(ITextServices_OnTxUIActivate),
|
|
|
|
STDCALL(ITextServices_OnTxUIDeactivate),
|
|
|
|
STDCALL(ITextServices_TxGetText),
|
|
|
|
STDCALL(ITextServices_TxSetText),
|
|
|
|
STDCALL(ITextServices_TxGetCurTargetX),
|
|
|
|
STDCALL(ITextServices_TxGetBaseLinePos),
|
|
|
|
STDCALL(ITextServices_TxGetNaturalSize),
|
|
|
|
STDCALL(ITextServices_TxGetDropTarget),
|
|
|
|
STDCALL(ITextServices_OnTxPropertyBitsChange),
|
|
|
|
STDCALL(ITextServices_TxGetCachedSize),
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* __ASM_USE_THISCALL_WRAPPER */
|
2006-02-01 12:31:40 +01:00
|
|
|
|
2012-03-28 00:31:45 +02:00
|
|
|
static const ITextServicesVtbl textservices_vtbl =
|
2006-02-01 12:31:40 +01:00
|
|
|
{
|
2021-03-03 12:29:39 +01:00
|
|
|
fnTextSrv_QueryInterface,
|
|
|
|
fnTextSrv_AddRef,
|
|
|
|
fnTextSrv_Release,
|
|
|
|
THISCALL(fnTextSrv_TxSendMessage),
|
|
|
|
THISCALL(fnTextSrv_TxDraw),
|
|
|
|
THISCALL(fnTextSrv_TxGetHScroll),
|
|
|
|
THISCALL(fnTextSrv_TxGetVScroll),
|
|
|
|
THISCALL(fnTextSrv_OnTxSetCursor),
|
|
|
|
THISCALL(fnTextSrv_TxQueryHitPoint),
|
2021-03-19 10:14:17 +01:00
|
|
|
THISCALL(fnTextSrv_OnTxInPlaceActivate),
|
|
|
|
THISCALL(fnTextSrv_OnTxInPlaceDeactivate),
|
2021-03-03 12:29:39 +01:00
|
|
|
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)
|
2006-02-01 12:31:40 +01:00
|
|
|
};
|
2012-03-28 00:31:45 +02:00
|
|
|
|
2021-03-03 12:29:41 +01:00
|
|
|
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;
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2012-03-28 00:31:45 +02:00
|
|
|
/******************************************************************
|
|
|
|
* CreateTextServices (RICHED20.4)
|
|
|
|
*/
|
2021-03-03 12:29:41 +01:00
|
|
|
HRESULT WINAPI CreateTextServices( IUnknown *outer, ITextHost *text_host, IUnknown **unk )
|
2012-03-28 00:31:45 +02:00
|
|
|
{
|
2021-03-03 12:29:41 +01:00
|
|
|
return create_text_services( outer, text_host, unk, FALSE, NULL );
|
2012-03-28 00:31:45 +02:00
|
|
|
}
|