push 07a2b33f792746135ccf34a3b3e1dfb2a3c1e823
[wine/hacks.git] / dlls / riched20 / txtsrv.c
blobd4679f78313e56a4f7e182844789acaf6cf3e9e9
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 #include "config.h"
22 #include "wine/port.h"
24 #define NONAMELESSSTRUCT
25 #define NONAMELESSUNION
26 #define COBJMACROS
28 #include "editor.h"
29 #include "ole2.h"
30 #include "richole.h"
31 #include "imm.h"
32 #include "textserv.h"
33 #include "wine/debug.h"
34 #include "editstr.h"
36 #ifdef __i386__ /* thiscall functions are i386-specific */
38 #define THISCALL(func) __thiscall_ ## func
39 #define DEFINE_THISCALL_WRAPPER(func) \
40 extern typeof(func) THISCALL(func); \
41 __ASM_GLOBAL_FUNC(__thiscall_ ## func, \
42 "popl %eax\n\t" \
43 "pushl %ecx\n\t" \
44 "pushl %eax\n\t" \
45 "jmp " __ASM_NAME(#func) )
46 #else /* __i386__ */
48 #define THISCALL(func) func
49 #define DEFINE_THISCALL_WRAPPER(func) /* nothing */
51 #endif /* __i386__ */
53 WINE_DEFAULT_DEBUG_CHANNEL(richedit);
55 typedef struct ITextServicesImpl {
56 const ITextServicesVtbl *lpVtbl;
57 ITextHost *pMyHost;
58 LONG ref;
59 CRITICAL_SECTION csTxtSrv;
60 char spare[256];
61 } ITextServicesImpl;
63 static const ITextServicesVtbl textservices_Vtbl;
65 /******************************************************************
66 * CreateTextServices (RICHED20.4)
68 HRESULT WINAPI CreateTextServices(IUnknown * pUnkOuter,
69 ITextHost * pITextHost,
70 IUnknown **ppUnk)
72 ITextServicesImpl *ITextImpl;
73 TRACE("%p %p --> %p\n", pUnkOuter, pITextHost, ppUnk);
74 if (pITextHost == NULL)
75 return E_POINTER;
77 ITextImpl = CoTaskMemAlloc(sizeof(*ITextImpl));
78 if (ITextImpl == NULL)
79 return E_OUTOFMEMORY;
80 InitializeCriticalSection(&ITextImpl->csTxtSrv);
81 ITextImpl->csTxtSrv.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": ITextServicesImpl.csTxtSrv");
82 ITextImpl->ref = 1;
83 ITextHost_AddRef(pITextHost);
84 ITextImpl->pMyHost = pITextHost;
85 ITextImpl->lpVtbl = &textservices_Vtbl;
87 if (pUnkOuter)
89 FIXME("Support aggregation\n");
90 return CLASS_E_NOAGGREGATION;
93 *ppUnk = (IUnknown *)ITextImpl;
94 return S_OK;
97 #define ICOM_THIS_MULTI(impl,field,iface) \
98 impl* const This=(impl*)((char*)(iface) - offsetof(impl,field))
100 static HRESULT WINAPI fnTextSrv_QueryInterface(ITextServices * iface,
101 REFIID riid,
102 LPVOID * ppv)
104 ICOM_THIS_MULTI(ITextServicesImpl, lpVtbl, iface);
105 TRACE("(%p/%p)->(%s, %p)\n", This, iface, debugstr_guid(riid), ppv);
106 *ppv = NULL;
107 if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_ITextServices))
108 *ppv = (LPVOID)This;
110 if (*ppv)
112 IUnknown_AddRef((IUnknown *)(*ppv));
113 TRACE ("-- Interface = %p\n", *ppv);
114 return S_OK;
116 FIXME("Unknown interface: %s\n", debugstr_guid(riid));
117 return E_NOINTERFACE;
120 static ULONG WINAPI fnTextSrv_AddRef(ITextServices *iface)
122 ICOM_THIS_MULTI(ITextServicesImpl, lpVtbl, iface);
123 DWORD ref = InterlockedIncrement(&This->ref);
125 TRACE("(%p/%p)->() AddRef from %d\n", This, iface, ref - 1);
126 return ref;
129 static ULONG WINAPI fnTextSrv_Release(ITextServices *iface)
131 ICOM_THIS_MULTI(ITextServicesImpl, lpVtbl, iface);
132 DWORD ref = InterlockedDecrement(&This->ref);
134 TRACE("(%p/%p)->() Release from %d\n", This, iface, ref + 1);
136 if (!ref)
138 ITextHost_Release(This->pMyHost);
139 This->csTxtSrv.DebugInfo->Spare[0] = 0;
140 DeleteCriticalSection(&This->csTxtSrv);
141 CoTaskMemFree(This);
143 return ref;
146 HRESULT WINAPI fnTextSrv_TxSendMessage(ITextServices *iface,
147 UINT msg,
148 WPARAM wparam,
149 LPARAM lparam,
150 LRESULT* plresult)
152 ICOM_THIS_MULTI(ITextServicesImpl, lpVtbl, iface);
154 FIXME("%p: STUB\n", This);
155 return E_NOTIMPL;
158 HRESULT WINAPI fnTextSrv_TxDraw(ITextServices *iface,
159 DWORD dwDrawAspect,
160 LONG lindex,
161 void* pvAspect,
162 DVTARGETDEVICE* ptd,
163 HDC hdcDraw,
164 HDC hdcTargetDev,
165 LPCRECTL lprcBounds,
166 LPCRECTL lprcWBounds,
167 LPRECT lprcUpdate,
168 BOOL (CALLBACK * pfnContinue)(DWORD),
169 DWORD dwContinue,
170 LONG lViewId)
172 ICOM_THIS_MULTI(ITextServicesImpl, lpVtbl, iface);
174 FIXME("%p: STUB\n", This);
175 return E_NOTIMPL;
178 HRESULT WINAPI fnTextSrv_TxGetHScroll(ITextServices *iface,
179 LONG* plMin,
180 LONG* plMax,
181 LONG* plPos,
182 LONG* plPage,
183 BOOL* pfEnabled)
185 ICOM_THIS_MULTI(ITextServicesImpl, lpVtbl, iface);
187 FIXME("%p: STUB\n", This);
188 return E_NOTIMPL;
191 HRESULT WINAPI fnTextSrv_TxGetVScroll(ITextServices *iface,
192 LONG* plMin,
193 LONG* plMax,
194 LONG* plPos,
195 LONG* plPage,
196 BOOL* pfEnabled)
198 ICOM_THIS_MULTI(ITextServicesImpl, lpVtbl, iface);
200 FIXME("%p: STUB\n", This);
201 return E_NOTIMPL;
204 HRESULT WINAPI fnTextSrv_OnTxSetCursor(ITextServices *iface,
205 DWORD dwDrawAspect,
206 LONG lindex,
207 void* pvAspect,
208 DVTARGETDEVICE* ptd,
209 HDC hdcDraw,
210 HDC hicTargetDev,
211 LPCRECT lprcClient,
212 INT x, INT y)
214 ICOM_THIS_MULTI(ITextServicesImpl, lpVtbl, iface);
216 FIXME("%p: STUB\n", This);
217 return E_NOTIMPL;
220 HRESULT WINAPI fnTextSrv_TxQueryHitPoint(ITextServices *iface,
221 DWORD dwDrawAspect,
222 LONG lindex,
223 void* pvAspect,
224 DVTARGETDEVICE* ptd,
225 HDC hdcDraw,
226 HDC hicTargetDev,
227 LPCRECT lprcClient,
228 INT x, INT y,
229 DWORD* pHitResult)
231 ICOM_THIS_MULTI(ITextServicesImpl, lpVtbl, iface);
233 FIXME("%p: STUB\n", This);
234 return E_NOTIMPL;
237 HRESULT WINAPI fnTextSrv_OnTxInplaceActivate(ITextServices *iface,
238 LPCRECT prcClient)
240 ICOM_THIS_MULTI(ITextServicesImpl, lpVtbl, iface);
242 FIXME("%p: STUB\n", This);
243 return E_NOTIMPL;
246 HRESULT WINAPI fnTextSrv_OnTxInplaceDeactivate(ITextServices *iface)
248 ICOM_THIS_MULTI(ITextServicesImpl, lpVtbl, iface);
250 FIXME("%p: STUB\n", This);
251 return E_NOTIMPL;
254 HRESULT WINAPI fnTextSrv_OnTxUIActivate(ITextServices *iface)
256 ICOM_THIS_MULTI(ITextServicesImpl, lpVtbl, iface);
258 FIXME("%p: STUB\n", This);
259 return E_NOTIMPL;
262 HRESULT WINAPI fnTextSrv_OnTxUIDeactivate(ITextServices *iface)
264 ICOM_THIS_MULTI(ITextServicesImpl, lpVtbl, iface);
266 FIXME("%p: STUB\n", This);
267 return E_NOTIMPL;
270 HRESULT WINAPI fnTextSrv_TxGetText(ITextServices *iface,
271 BSTR* pbstrText)
273 ICOM_THIS_MULTI(ITextServicesImpl, lpVtbl, iface);
275 FIXME("%p: STUB\n", This);
276 return E_NOTIMPL;
279 HRESULT WINAPI fnTextSrv_TxSetText(ITextServices *iface,
280 LPCWSTR pszText)
282 ICOM_THIS_MULTI(ITextServicesImpl, lpVtbl, iface);
284 FIXME("%p: STUB\n", This);
285 return E_NOTIMPL;
288 HRESULT WINAPI fnTextSrv_TxGetCurrentTargetX(ITextServices *iface,
289 LONG* x)
291 ICOM_THIS_MULTI(ITextServicesImpl, lpVtbl, iface);
293 FIXME("%p: STUB\n", This);
294 return E_NOTIMPL;
297 HRESULT WINAPI fnTextSrv_TxGetBaseLinePos(ITextServices *iface,
298 LONG* x)
300 ICOM_THIS_MULTI(ITextServicesImpl, lpVtbl, iface);
302 FIXME("%p: STUB\n", This);
303 return E_NOTIMPL;
306 HRESULT WINAPI fnTextSrv_TxGetNaturalSize(ITextServices *iface,
307 DWORD dwAspect,
308 HDC hdcDraw,
309 HDC hicTargetDev,
310 DVTARGETDEVICE* ptd,
311 DWORD dwMode,
312 const SIZEL* psizelExtent,
313 LONG* pwidth,
314 LONG* pheight)
316 ICOM_THIS_MULTI(ITextServicesImpl, lpVtbl, iface);
318 FIXME("%p: STUB\n", This);
319 return E_NOTIMPL;
322 HRESULT WINAPI fnTextSrv_TxGetDropTarget(ITextServices *iface,
323 IDropTarget** ppDropTarget)
325 ICOM_THIS_MULTI(ITextServicesImpl, lpVtbl, iface);
327 FIXME("%p: STUB\n", This);
328 return E_NOTIMPL;
331 HRESULT WINAPI fnTextSrv_OnTxPropertyBitsChange(ITextServices *iface,
332 DWORD dwMask,
333 DWORD dwBits)
335 ICOM_THIS_MULTI(ITextServicesImpl, lpVtbl, iface);
337 FIXME("%p: STUB\n", This);
338 return E_NOTIMPL;
341 HRESULT WINAPI fnTextSrv_TxGetCachedSize(ITextServices *iface,
342 DWORD* pdwWidth,
343 DWORD* pdwHeight)
345 ICOM_THIS_MULTI(ITextServicesImpl, lpVtbl, iface);
347 FIXME("%p: STUB\n", This);
348 return E_NOTIMPL;
351 DEFINE_THISCALL_WRAPPER(fnTextSrv_TxSendMessage)
352 DEFINE_THISCALL_WRAPPER(fnTextSrv_TxDraw)
353 DEFINE_THISCALL_WRAPPER(fnTextSrv_TxGetHScroll)
354 DEFINE_THISCALL_WRAPPER(fnTextSrv_TxGetVScroll)
355 DEFINE_THISCALL_WRAPPER(fnTextSrv_OnTxSetCursor)
356 DEFINE_THISCALL_WRAPPER(fnTextSrv_TxQueryHitPoint)
357 DEFINE_THISCALL_WRAPPER(fnTextSrv_OnTxInplaceActivate)
358 DEFINE_THISCALL_WRAPPER(fnTextSrv_OnTxInplaceDeactivate)
359 DEFINE_THISCALL_WRAPPER(fnTextSrv_OnTxUIActivate)
360 DEFINE_THISCALL_WRAPPER(fnTextSrv_OnTxUIDeactivate)
361 DEFINE_THISCALL_WRAPPER(fnTextSrv_TxGetText)
362 DEFINE_THISCALL_WRAPPER(fnTextSrv_TxSetText)
363 DEFINE_THISCALL_WRAPPER(fnTextSrv_TxGetCurrentTargetX)
364 DEFINE_THISCALL_WRAPPER(fnTextSrv_TxGetBaseLinePos)
365 DEFINE_THISCALL_WRAPPER(fnTextSrv_TxGetNaturalSize)
366 DEFINE_THISCALL_WRAPPER(fnTextSrv_TxGetDropTarget)
367 DEFINE_THISCALL_WRAPPER(fnTextSrv_OnTxPropertyBitsChange)
368 DEFINE_THISCALL_WRAPPER(fnTextSrv_TxGetCachedSize)
370 static const ITextServicesVtbl textservices_Vtbl =
372 fnTextSrv_QueryInterface,
373 fnTextSrv_AddRef,
374 fnTextSrv_Release,
375 THISCALL(fnTextSrv_TxSendMessage),
376 THISCALL(fnTextSrv_TxDraw),
377 THISCALL(fnTextSrv_TxGetHScroll),
378 THISCALL(fnTextSrv_TxGetVScroll),
379 THISCALL(fnTextSrv_OnTxSetCursor),
380 THISCALL(fnTextSrv_TxQueryHitPoint),
381 THISCALL(fnTextSrv_OnTxInplaceActivate),
382 THISCALL(fnTextSrv_OnTxInplaceDeactivate),
383 THISCALL(fnTextSrv_OnTxUIActivate),
384 THISCALL(fnTextSrv_OnTxUIDeactivate),
385 THISCALL(fnTextSrv_TxGetText),
386 THISCALL(fnTextSrv_TxSetText),
387 THISCALL(fnTextSrv_TxGetCurrentTargetX),
388 THISCALL(fnTextSrv_TxGetBaseLinePos),
389 THISCALL(fnTextSrv_TxGetNaturalSize),
390 THISCALL(fnTextSrv_TxGetDropTarget),
391 THISCALL(fnTextSrv_OnTxPropertyBitsChange),
392 THISCALL(fnTextSrv_TxGetCachedSize)