wined3d: Reject raw blits between depth/stencil and colour resources in the GLSL...
[wine.git] / dlls / riched20 / txtsrv.c
blob73b8d3ea7e9070f06f8e4309afab7cca7c4855d5
1 /*
2 * RichEdit - functions and interfaces around CreateTextServices
4 * Copyright 2005, 2006, Maarten Lankhorst
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #define COBJMACROS
23 #include "editor.h"
24 #include "ole2.h"
25 #include "oleauto.h"
26 #include "richole.h"
27 #include "tom.h"
28 #include "imm.h"
29 #include "textserv.h"
30 #include "wine/debug.h"
31 #include "editstr.h"
33 WINE_DEFAULT_DEBUG_CHANNEL(richedit);
35 static inline struct text_services *impl_from_IUnknown( IUnknown *iface )
37 return CONTAINING_RECORD( iface, struct text_services, IUnknown_inner );
40 static HRESULT WINAPI ITextServicesImpl_QueryInterface( IUnknown *iface, REFIID iid, void **obj )
42 struct text_services *services = impl_from_IUnknown( iface );
44 TRACE( "(%p)->(%s, %p)\n", iface, debugstr_guid( iid ), obj );
46 if (IsEqualIID( iid, &IID_IUnknown )) *obj = &services->IUnknown_inner;
47 else if (IsEqualIID( iid, &IID_ITextServices )) *obj = &services->ITextServices_iface;
48 else if (IsEqualIID( iid, &IID_IRichEditOle )) *obj= &services->IRichEditOle_iface;
49 else if (IsEqualIID( iid, &IID_IDispatch ) ||
50 IsEqualIID( iid, &IID_ITextDocument ) ||
51 IsEqualIID( iid, &IID_ITextDocument2Old )) *obj = &services->ITextDocument2Old_iface;
52 else
54 *obj = NULL;
55 FIXME( "Unknown interface: %s\n", debugstr_guid( iid ) );
56 return E_NOINTERFACE;
59 IUnknown_AddRef( (IUnknown *)*obj );
60 return S_OK;
63 static ULONG WINAPI ITextServicesImpl_AddRef(IUnknown *iface)
65 struct text_services *services = impl_from_IUnknown( iface );
66 LONG ref = InterlockedIncrement( &services->ref );
68 TRACE( "(%p) ref = %d\n", services, ref );
70 return ref;
73 static ULONG WINAPI ITextServicesImpl_Release(IUnknown *iface)
75 struct text_services *services = impl_from_IUnknown( iface );
76 LONG ref = InterlockedDecrement( &services->ref );
78 TRACE( "(%p) ref = %d\n", services, ref );
80 if (!ref)
82 richole_release_children( services );
83 ME_DestroyEditor( services->editor );
84 CoTaskMemFree( services );
86 return ref;
89 static const IUnknownVtbl textservices_inner_vtbl =
91 ITextServicesImpl_QueryInterface,
92 ITextServicesImpl_AddRef,
93 ITextServicesImpl_Release
96 static inline struct text_services *impl_from_ITextServices( ITextServices *iface )
98 return CONTAINING_RECORD( iface, struct text_services, ITextServices_iface );
101 static HRESULT WINAPI fnTextSrv_QueryInterface( ITextServices *iface, REFIID iid, void **obj )
103 struct text_services *services = impl_from_ITextServices( iface );
104 return IUnknown_QueryInterface( services->outer_unk, iid, obj );
107 static ULONG WINAPI fnTextSrv_AddRef(ITextServices *iface)
109 struct text_services *services = impl_from_ITextServices( iface );
110 return IUnknown_AddRef( services->outer_unk );
113 static ULONG WINAPI fnTextSrv_Release(ITextServices *iface)
115 struct text_services *services = impl_from_ITextServices( iface );
116 return IUnknown_Release( services->outer_unk );
119 DEFINE_THISCALL_WRAPPER(fnTextSrv_TxSendMessage,20)
120 DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_TxSendMessage( ITextServices *iface, UINT msg, WPARAM wparam,
121 LPARAM lparam, LRESULT *result )
123 struct text_services *services = impl_from_ITextServices( iface );
124 HRESULT hr;
125 LRESULT res;
127 res = editor_handle_message( services->editor, msg, wparam, lparam, &hr );
128 if (result) *result = res;
129 return hr;
132 static HRESULT update_client_rect( struct text_services *services, const RECT *client )
134 RECT rect;
135 HRESULT hr;
137 if (!client)
139 if (!services->editor->in_place_active) return E_INVALIDARG;
140 hr = ITextHost_TxGetClientRect( services->editor->texthost, &rect );
141 if (FAILED( hr )) return hr;
143 else rect = *client;
145 rect.left += services->editor->selofs;
147 if (EqualRect( &rect, &services->editor->rcFormat )) return S_FALSE;
148 services->editor->rcFormat = rect;
149 return S_OK;
152 DEFINE_THISCALL_WRAPPER(fnTextSrv_TxDraw,52)
153 DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_TxDraw( ITextServices *iface, DWORD aspect, LONG index, void *aspect_info,
154 DVTARGETDEVICE *td, HDC draw, HDC target,
155 const RECTL *bounds, const RECTL *mf_bounds, RECT *update,
156 BOOL (CALLBACK *continue_fn)(DWORD), DWORD continue_param,
157 LONG view_id )
159 struct text_services *services = impl_from_ITextServices( iface );
160 HRESULT hr;
161 HDC dc = draw;
162 BOOL rewrap = FALSE;
164 TRACE( "%p: aspect %d, %d, %p, %p, draw %p, target %p, bounds %s, mf_bounds %s, update %s, %p, %d, view %d\n",
165 services, aspect, index, aspect_info, td, draw, target, wine_dbgstr_rect( (RECT *)bounds ),
166 wine_dbgstr_rect( (RECT *)mf_bounds ), wine_dbgstr_rect( update ), continue_fn, continue_param, view_id );
168 if (aspect != DVASPECT_CONTENT || aspect_info || td || target || mf_bounds || continue_fn )
169 FIXME( "Many arguments are ignored\n" );
171 hr = update_client_rect( services, (RECT *)bounds );
172 if (FAILED( hr )) return hr;
173 if (hr == S_OK) rewrap = TRUE;
175 if (!dc && services->editor->in_place_active)
176 dc = ITextHost_TxGetDC( services->editor->texthost );
177 if (!dc) return E_FAIL;
179 if (rewrap)
181 editor_mark_rewrap_all( services->editor );
182 wrap_marked_paras_dc( services->editor, dc, FALSE );
185 if (!services->editor->bEmulateVersion10 || services->editor->nEventMask & ENM_UPDATE)
186 ITextHost_TxNotify( services->editor->texthost, EN_UPDATE, NULL );
188 editor_draw( services->editor, dc, update );
190 if (!draw) ITextHost_TxReleaseDC( services->editor->texthost, dc );
191 return S_OK;
194 DEFINE_THISCALL_WRAPPER(fnTextSrv_TxGetHScroll,24)
195 DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_TxGetHScroll( ITextServices *iface, LONG *min_pos, LONG *max_pos, LONG *pos,
196 LONG *page, BOOL *enabled )
198 struct text_services *services = impl_from_ITextServices( iface );
200 if (min_pos) *min_pos = services->editor->horz_si.nMin;
201 if (max_pos) *max_pos = services->editor->horz_si.nMax;
202 if (pos) *pos = services->editor->horz_si.nPos;
203 if (page) *page = services->editor->horz_si.nPage;
204 if (enabled) *enabled = services->editor->horz_sb_enabled;
205 return S_OK;
208 DEFINE_THISCALL_WRAPPER(fnTextSrv_TxGetVScroll,24)
209 DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_TxGetVScroll( ITextServices *iface, LONG *min_pos, LONG *max_pos, LONG *pos,
210 LONG *page, BOOL *enabled )
212 struct text_services *services = impl_from_ITextServices( iface );
214 if (min_pos) *min_pos = services->editor->vert_si.nMin;
215 if (max_pos) *max_pos = services->editor->vert_si.nMax;
216 if (pos) *pos = services->editor->vert_si.nPos;
217 if (page) *page = services->editor->vert_si.nPage;
218 if (enabled) *enabled = services->editor->vert_sb_enabled;
219 return S_OK;
222 DEFINE_THISCALL_WRAPPER(fnTextSrv_OnTxSetCursor,40)
223 DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_OnTxSetCursor( ITextServices *iface, DWORD aspect, LONG index,
224 void *aspect_info, DVTARGETDEVICE *td, HDC draw,
225 HDC target, const RECT *client, INT x, INT y )
227 struct text_services *services = impl_from_ITextServices( iface );
229 TRACE( "%p: %d, %d, %p, %p, draw %p target %p client %s pos (%d, %d)\n", services, aspect, index, aspect_info, td, draw,
230 target, wine_dbgstr_rect( client ), x, y );
232 if (aspect != DVASPECT_CONTENT || index || aspect_info || td || draw || target || client)
233 FIXME( "Ignoring most params\n" );
235 link_notify( services->editor, WM_SETCURSOR, 0, MAKELPARAM( x, y ) );
236 editor_set_cursor( services->editor, x, y );
237 return S_OK;
240 DEFINE_THISCALL_WRAPPER(fnTextSrv_TxQueryHitPoint,44)
241 DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_TxQueryHitPoint(ITextServices *iface, DWORD dwDrawAspect, LONG lindex,
242 void *pvAspect, DVTARGETDEVICE *ptd, HDC hdcDraw,
243 HDC hicTargetDev, LPCRECT lprcClient, INT x, INT y,
244 DWORD *pHitResult)
246 struct text_services *services = impl_from_ITextServices( iface );
248 FIXME( "%p: STUB\n", services );
249 return E_NOTIMPL;
252 DEFINE_THISCALL_WRAPPER(fnTextSrv_OnTxInPlaceActivate,8)
253 DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_OnTxInPlaceActivate( ITextServices *iface, const RECT *client )
255 struct text_services *services = impl_from_ITextServices( iface );
256 HRESULT hr;
257 BOOL old_active = services->editor->in_place_active;
259 TRACE( "%p: %s\n", services, wine_dbgstr_rect( client ) );
261 services->editor->in_place_active = TRUE;
262 hr = update_client_rect( services, client );
263 if (FAILED( hr ))
265 services->editor->in_place_active = old_active;
266 return hr;
268 ME_RewrapRepaint( services->editor );
269 return S_OK;
272 DEFINE_THISCALL_WRAPPER(fnTextSrv_OnTxInPlaceDeactivate,4)
273 DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_OnTxInPlaceDeactivate(ITextServices *iface)
275 struct text_services *services = impl_from_ITextServices( iface );
277 TRACE( "%p\n", services );
278 services->editor->in_place_active = FALSE;
279 return S_OK;
282 DEFINE_THISCALL_WRAPPER(fnTextSrv_OnTxUIActivate,4)
283 DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_OnTxUIActivate(ITextServices *iface)
285 struct text_services *services = impl_from_ITextServices( iface );
287 FIXME( "%p: STUB\n", services );
288 return E_NOTIMPL;
291 DEFINE_THISCALL_WRAPPER(fnTextSrv_OnTxUIDeactivate,4)
292 DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_OnTxUIDeactivate(ITextServices *iface)
294 struct text_services *services = impl_from_ITextServices( iface );
296 FIXME( "%p: STUB\n", services );
297 return E_NOTIMPL;
300 DEFINE_THISCALL_WRAPPER(fnTextSrv_TxGetText,8)
301 DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_TxGetText( ITextServices *iface, BSTR *text )
303 struct text_services *services = impl_from_ITextServices( iface );
304 int length;
306 length = ME_GetTextLength( services->editor );
307 if (length)
309 ME_Cursor start;
310 BSTR bstr;
311 bstr = SysAllocStringByteLen( NULL, length * sizeof(WCHAR) );
312 if (bstr == NULL) return E_OUTOFMEMORY;
314 cursor_from_char_ofs( services->editor, 0, &start );
315 ME_GetTextW( services->editor, bstr, length, &start, INT_MAX, FALSE, FALSE );
316 *text = bstr;
318 else *text = NULL;
320 return S_OK;
323 DEFINE_THISCALL_WRAPPER(fnTextSrv_TxSetText,8)
324 DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_TxSetText( ITextServices *iface, const WCHAR *text )
326 struct text_services *services = impl_from_ITextServices( iface );
327 ME_Cursor cursor;
329 ME_SetCursorToStart( services->editor, &cursor );
330 ME_InternalDeleteText( services->editor, &cursor, ME_GetTextLength( services->editor ), FALSE );
331 if (text) ME_InsertTextFromCursor( services->editor, 0, text, -1, services->editor->pBuffer->pDefaultStyle );
332 set_selection_cursors( services->editor, 0, 0);
333 services->editor->nModifyStep = 0;
334 OleFlushClipboard();
335 ME_EmptyUndoStack( services->editor );
336 ME_UpdateRepaint( services->editor, FALSE );
338 return S_OK;
341 DEFINE_THISCALL_WRAPPER(fnTextSrv_TxGetCurTargetX,8)
342 DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_TxGetCurTargetX(ITextServices *iface, LONG *x)
344 struct text_services *services = impl_from_ITextServices( iface );
346 FIXME( "%p: STUB\n", services );
347 return E_NOTIMPL;
350 DEFINE_THISCALL_WRAPPER(fnTextSrv_TxGetBaseLinePos,8)
351 DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_TxGetBaseLinePos(ITextServices *iface, LONG *x)
353 struct text_services *services = impl_from_ITextServices( iface );
355 FIXME( "%p: STUB\n", services );
356 return E_NOTIMPL;
359 DEFINE_THISCALL_WRAPPER(fnTextSrv_TxGetNaturalSize,36)
360 DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_TxGetNaturalSize( ITextServices *iface, DWORD aspect, HDC draw,
361 HDC target, DVTARGETDEVICE *td, DWORD mode,
362 const SIZEL *extent, LONG *width, LONG *height )
364 struct text_services *services = impl_from_ITextServices( iface );
365 RECT rect;
366 HDC dc = draw;
367 BOOL rewrap = FALSE;
368 HRESULT hr;
370 TRACE( "%p: aspect %d, draw %p, target %p, td %p, mode %08x, extent %s, *width %d, *height %d\n", services,
371 aspect, draw, target, td, mode, wine_dbgstr_point( (POINT *)extent ), *width, *height );
373 if (aspect != DVASPECT_CONTENT || target || td || mode != TXTNS_FITTOCONTENT )
374 FIXME( "Many arguments are ignored\n" );
376 SetRect( &rect, 0, 0, *width, *height );
378 hr = update_client_rect( services, &rect );
379 if (FAILED( hr )) return hr;
380 if (hr == S_OK) rewrap = TRUE;
382 if (!dc && services->editor->in_place_active)
383 dc = ITextHost_TxGetDC( services->editor->texthost );
384 if (!dc) return E_FAIL;
386 if (rewrap)
388 editor_mark_rewrap_all( services->editor );
389 wrap_marked_paras_dc( services->editor, dc, FALSE );
392 *width = services->editor->nTotalWidth;
393 *height = services->editor->nTotalLength;
395 if (!draw) ITextHost_TxReleaseDC( services->editor->texthost, dc );
396 return S_OK;
399 DEFINE_THISCALL_WRAPPER(fnTextSrv_TxGetDropTarget,8)
400 DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_TxGetDropTarget(ITextServices *iface, IDropTarget **ppDropTarget)
402 struct text_services *services = impl_from_ITextServices( iface );
404 FIXME( "%p: STUB\n", services );
405 return E_NOTIMPL;
408 DEFINE_THISCALL_WRAPPER(fnTextSrv_OnTxPropertyBitsChange,12)
409 DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_OnTxPropertyBitsChange( ITextServices *iface, DWORD mask, DWORD bits )
411 struct text_services *services = impl_from_ITextServices( iface );
412 DWORD scrollbars;
413 HRESULT hr;
414 BOOL repaint = FALSE;
416 TRACE( "%p, mask %08x, bits %08x\n", services, mask, bits );
418 services->editor->props = (services->editor->props & ~mask) | (bits & mask);
419 if (mask & (TXTBIT_WORDWRAP | TXTBIT_MULTILINE))
420 services->editor->bWordWrap = (services->editor->props & TXTBIT_WORDWRAP) && (services->editor->props & TXTBIT_MULTILINE);
422 if (mask & TXTBIT_SCROLLBARCHANGE)
424 hr = ITextHost_TxGetScrollBars( services->editor->texthost, &scrollbars );
425 if (SUCCEEDED( hr ))
427 if ((services->editor->scrollbars ^ scrollbars) & WS_HSCROLL)
428 ITextHost_TxShowScrollBar( services->editor->texthost, SB_HORZ, (scrollbars & WS_HSCROLL) &&
429 services->editor->nTotalWidth > services->editor->sizeWindow.cx );
430 if ((services->editor->scrollbars ^ scrollbars) & WS_VSCROLL)
431 ITextHost_TxShowScrollBar( services->editor->texthost, SB_VERT, (scrollbars & WS_VSCROLL) &&
432 services->editor->nTotalLength > services->editor->sizeWindow.cy );
433 services->editor->scrollbars = scrollbars;
437 if ((mask & TXTBIT_HIDESELECTION) && !services->editor->bHaveFocus) ME_InvalidateSelection( services->editor );
439 if (mask & TXTBIT_SELBARCHANGE)
441 LONG width;
443 hr = ITextHost_TxGetSelectionBarWidth( services->editor->texthost, &width );
444 if (hr == S_OK)
446 ITextHost_TxInvalidateRect( services->editor->texthost, &services->editor->rcFormat, TRUE );
447 services->editor->rcFormat.left -= services->editor->selofs;
448 services->editor->selofs = width ? SELECTIONBAR_WIDTH : 0; /* FIXME: convert from HIMETRIC */
449 services->editor->rcFormat.left += services->editor->selofs;
450 repaint = TRUE;
454 if (mask & TXTBIT_CLIENTRECTCHANGE)
456 hr = update_client_rect( services, NULL );
457 if (SUCCEEDED( hr )) repaint = TRUE;
460 if (mask & TXTBIT_USEPASSWORD)
462 if (bits & TXTBIT_USEPASSWORD) ITextHost_TxGetPasswordChar( services->editor->texthost, &services->editor->password_char );
463 else services->editor->password_char = 0;
464 repaint = TRUE;
467 if (repaint) ME_RewrapRepaint( services->editor );
469 return S_OK;
472 DEFINE_THISCALL_WRAPPER(fnTextSrv_TxGetCachedSize,12)
473 DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_TxGetCachedSize(ITextServices *iface, DWORD *pdwWidth, DWORD *pdwHeight)
475 struct text_services *services = impl_from_ITextServices( iface );
477 FIXME( "%p: STUB\n", services );
478 return E_NOTIMPL;
481 #ifdef __ASM_USE_THISCALL_WRAPPER
483 #define STDCALL(func) (void *) __stdcall_ ## func
484 #ifdef _MSC_VER
485 #define DEFINE_STDCALL_WRAPPER(num,func) \
486 __declspec(naked) HRESULT __stdcall_##func(void) \
488 __asm pop eax \
489 __asm pop ecx \
490 __asm push eax \
491 __asm mov eax, [ecx] \
492 __asm jmp dword ptr [eax + 4*num] \
494 #else /* _MSC_VER */
495 #define DEFINE_STDCALL_WRAPPER(num,func) \
496 extern HRESULT __stdcall_ ## func(void); \
497 __ASM_GLOBAL_FUNC(__stdcall_ ## func, \
498 "popl %eax\n\t" \
499 "popl %ecx\n\t" \
500 "pushl %eax\n\t" \
501 "movl (%ecx), %eax\n\t" \
502 "jmp *(4*(" #num "))(%eax)" )
503 #endif /* _MSC_VER */
505 DEFINE_STDCALL_WRAPPER(3, ITextServices_TxSendMessage)
506 DEFINE_STDCALL_WRAPPER(4, ITextServices_TxDraw)
507 DEFINE_STDCALL_WRAPPER(5, ITextServices_TxGetHScroll)
508 DEFINE_STDCALL_WRAPPER(6, ITextServices_TxGetVScroll)
509 DEFINE_STDCALL_WRAPPER(7, ITextServices_OnTxSetCursor)
510 DEFINE_STDCALL_WRAPPER(8, ITextServices_TxQueryHitPoint)
511 DEFINE_STDCALL_WRAPPER(9, ITextServices_OnTxInPlaceActivate)
512 DEFINE_STDCALL_WRAPPER(10, ITextServices_OnTxInPlaceDeactivate)
513 DEFINE_STDCALL_WRAPPER(11, ITextServices_OnTxUIActivate)
514 DEFINE_STDCALL_WRAPPER(12, ITextServices_OnTxUIDeactivate)
515 DEFINE_STDCALL_WRAPPER(13, ITextServices_TxGetText)
516 DEFINE_STDCALL_WRAPPER(14, ITextServices_TxSetText)
517 DEFINE_STDCALL_WRAPPER(15, ITextServices_TxGetCurTargetX)
518 DEFINE_STDCALL_WRAPPER(16, ITextServices_TxGetBaseLinePos)
519 DEFINE_STDCALL_WRAPPER(17, ITextServices_TxGetNaturalSize)
520 DEFINE_STDCALL_WRAPPER(18, ITextServices_TxGetDropTarget)
521 DEFINE_STDCALL_WRAPPER(19, ITextServices_OnTxPropertyBitsChange)
522 DEFINE_STDCALL_WRAPPER(20, ITextServices_TxGetCachedSize)
524 const ITextServicesVtbl text_services_stdcall_vtbl =
526 NULL,
527 NULL,
528 NULL,
529 STDCALL(ITextServices_TxSendMessage),
530 STDCALL(ITextServices_TxDraw),
531 STDCALL(ITextServices_TxGetHScroll),
532 STDCALL(ITextServices_TxGetVScroll),
533 STDCALL(ITextServices_OnTxSetCursor),
534 STDCALL(ITextServices_TxQueryHitPoint),
535 STDCALL(ITextServices_OnTxInPlaceActivate),
536 STDCALL(ITextServices_OnTxInPlaceDeactivate),
537 STDCALL(ITextServices_OnTxUIActivate),
538 STDCALL(ITextServices_OnTxUIDeactivate),
539 STDCALL(ITextServices_TxGetText),
540 STDCALL(ITextServices_TxSetText),
541 STDCALL(ITextServices_TxGetCurTargetX),
542 STDCALL(ITextServices_TxGetBaseLinePos),
543 STDCALL(ITextServices_TxGetNaturalSize),
544 STDCALL(ITextServices_TxGetDropTarget),
545 STDCALL(ITextServices_OnTxPropertyBitsChange),
546 STDCALL(ITextServices_TxGetCachedSize),
549 #endif /* __ASM_USE_THISCALL_WRAPPER */
551 static const ITextServicesVtbl textservices_vtbl =
553 fnTextSrv_QueryInterface,
554 fnTextSrv_AddRef,
555 fnTextSrv_Release,
556 THISCALL(fnTextSrv_TxSendMessage),
557 THISCALL(fnTextSrv_TxDraw),
558 THISCALL(fnTextSrv_TxGetHScroll),
559 THISCALL(fnTextSrv_TxGetVScroll),
560 THISCALL(fnTextSrv_OnTxSetCursor),
561 THISCALL(fnTextSrv_TxQueryHitPoint),
562 THISCALL(fnTextSrv_OnTxInPlaceActivate),
563 THISCALL(fnTextSrv_OnTxInPlaceDeactivate),
564 THISCALL(fnTextSrv_OnTxUIActivate),
565 THISCALL(fnTextSrv_OnTxUIDeactivate),
566 THISCALL(fnTextSrv_TxGetText),
567 THISCALL(fnTextSrv_TxSetText),
568 THISCALL(fnTextSrv_TxGetCurTargetX),
569 THISCALL(fnTextSrv_TxGetBaseLinePos),
570 THISCALL(fnTextSrv_TxGetNaturalSize),
571 THISCALL(fnTextSrv_TxGetDropTarget),
572 THISCALL(fnTextSrv_OnTxPropertyBitsChange),
573 THISCALL(fnTextSrv_TxGetCachedSize)
576 HRESULT create_text_services( IUnknown *outer, ITextHost *text_host, IUnknown **unk, BOOL emulate_10 )
578 struct text_services *services;
580 TRACE( "%p %p --> %p\n", outer, text_host, unk );
581 if (text_host == NULL) return E_POINTER;
583 services = CoTaskMemAlloc( sizeof(*services) );
584 if (services == NULL) return E_OUTOFMEMORY;
585 services->ref = 1;
586 services->IUnknown_inner.lpVtbl = &textservices_inner_vtbl;
587 services->ITextServices_iface.lpVtbl = &textservices_vtbl;
588 services->IRichEditOle_iface.lpVtbl = &re_ole_vtbl;
589 services->ITextDocument2Old_iface.lpVtbl = &text_doc2old_vtbl;
590 services->editor = ME_MakeEditor( text_host, emulate_10 );
591 services->editor->richole = &services->IRichEditOle_iface;
593 if (outer) services->outer_unk = outer;
594 else services->outer_unk = &services->IUnknown_inner;
596 services->text_selection = NULL;
597 list_init( &services->rangelist );
598 list_init( &services->clientsites );
600 *unk = &services->IUnknown_inner;
601 return S_OK;
604 /******************************************************************
605 * CreateTextServices (RICHED20.4)
607 HRESULT WINAPI CreateTextServices( IUnknown *outer, ITextHost *text_host, IUnknown **unk )
609 return create_text_services( outer, text_host, unk, FALSE );