ntoskrnl.exe: Implemented a couple of time-related APIs.
[wine/dibdrv.git] / dlls / riched20 / txtsrv.c
blob95d6f7cb496dbadf1c5d40dfa5a83906d3ee02d3
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 } ITextServicesImpl;
62 static const ITextServicesVtbl textservices_Vtbl;
64 /******************************************************************
65 * CreateTextServices (RICHED20.4)
67 HRESULT WINAPI CreateTextServices(IUnknown * pUnkOuter,
68 ITextHost * pITextHost,
69 IUnknown **ppUnk)
71 ITextServicesImpl *ITextImpl;
72 TRACE("%p %p --> %p\n", pUnkOuter, pITextHost, ppUnk);
73 if (pITextHost == NULL)
74 return E_POINTER;
76 ITextImpl = CoTaskMemAlloc(sizeof(*ITextImpl));
77 if (ITextImpl == NULL)
78 return E_OUTOFMEMORY;
79 InitializeCriticalSection(&ITextImpl->csTxtSrv);
80 ITextImpl->csTxtSrv.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": ITextServicesImpl.csTxtSrv");
81 ITextImpl->ref = 1;
82 ITextHost_AddRef(pITextHost);
83 ITextImpl->pMyHost = pITextHost;
84 ITextImpl->lpVtbl = &textservices_Vtbl;
86 if (pUnkOuter)
88 FIXME("Support aggregation\n");
89 return CLASS_E_NOAGGREGATION;
92 *ppUnk = (IUnknown *)ITextImpl;
93 return S_OK;
96 #define ICOM_THIS_MULTI(impl,field,iface) \
97 impl* const This=(impl*)((char*)(iface) - offsetof(impl,field))
99 static HRESULT WINAPI fnTextSrv_QueryInterface(ITextServices * iface,
100 REFIID riid,
101 LPVOID * ppv)
103 ICOM_THIS_MULTI(ITextServicesImpl, lpVtbl, iface);
104 TRACE("(%p/%p)->(%s, %p)\n", This, iface, debugstr_guid(riid), ppv);
105 *ppv = NULL;
106 if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_ITextServices))
107 *ppv = (LPVOID)This;
109 if (*ppv)
111 IUnknown_AddRef((IUnknown *)(*ppv));
112 TRACE ("-- Interface = %p\n", *ppv);
113 return S_OK;
115 FIXME("Unknown interface: %s\n", debugstr_guid(riid));
116 return E_NOINTERFACE;
119 static ULONG WINAPI fnTextSrv_AddRef(ITextServices *iface)
121 ICOM_THIS_MULTI(ITextServicesImpl, lpVtbl, iface);
122 DWORD ref = InterlockedIncrement(&This->ref);
124 TRACE("(%p/%p)->() AddRef from %d\n", This, iface, ref - 1);
125 return ref;
128 static ULONG WINAPI fnTextSrv_Release(ITextServices *iface)
130 ICOM_THIS_MULTI(ITextServicesImpl, lpVtbl, iface);
131 DWORD ref = InterlockedDecrement(&This->ref);
133 TRACE("(%p/%p)->() Release from %d\n", This, iface, ref + 1);
135 if (!ref)
137 ITextHost_Release(This->pMyHost);
138 This->csTxtSrv.DebugInfo->Spare[0] = 0;
139 DeleteCriticalSection(&This->csTxtSrv);
140 CoTaskMemFree(This);
142 return ref;
145 HRESULT WINAPI fnTextSrv_TxSendMessage(ITextServices *iface,
146 UINT msg,
147 WPARAM wparam,
148 LPARAM lparam,
149 LRESULT* plresult)
151 ICOM_THIS_MULTI(ITextServicesImpl, lpVtbl, iface);
153 FIXME("%p: STUB\n", This);
154 return E_NOTIMPL;
157 HRESULT WINAPI fnTextSrv_TxDraw(ITextServices *iface,
158 DWORD dwDrawAspect,
159 LONG lindex,
160 void* pvAspect,
161 DVTARGETDEVICE* ptd,
162 HDC hdcDraw,
163 HDC hdcTargetDev,
164 LPCRECTL lprcBounds,
165 LPCRECTL lprcWBounds,
166 LPRECT lprcUpdate,
167 BOOL (CALLBACK * pfnContinue)(DWORD),
168 DWORD dwContinue,
169 LONG lViewId)
171 ICOM_THIS_MULTI(ITextServicesImpl, lpVtbl, iface);
173 FIXME("%p: STUB\n", This);
174 return E_NOTIMPL;
177 HRESULT WINAPI fnTextSrv_TxGetHScroll(ITextServices *iface,
178 LONG* plMin,
179 LONG* plMax,
180 LONG* plPos,
181 LONG* plPage,
182 BOOL* pfEnabled)
184 ICOM_THIS_MULTI(ITextServicesImpl, lpVtbl, iface);
186 FIXME("%p: STUB\n", This);
187 return E_NOTIMPL;
190 HRESULT WINAPI fnTextSrv_TxGetVScroll(ITextServices *iface,
191 LONG* plMin,
192 LONG* plMax,
193 LONG* plPos,
194 LONG* plPage,
195 BOOL* pfEnabled)
197 ICOM_THIS_MULTI(ITextServicesImpl, lpVtbl, iface);
199 FIXME("%p: STUB\n", This);
200 return E_NOTIMPL;
203 HRESULT WINAPI fnTextSrv_OnTxSetCursor(ITextServices *iface,
204 DWORD dwDrawAspect,
205 LONG lindex,
206 void* pvAspect,
207 DVTARGETDEVICE* ptd,
208 HDC hdcDraw,
209 HDC hicTargetDev,
210 LPCRECT lprcClient,
211 INT x, INT y)
213 ICOM_THIS_MULTI(ITextServicesImpl, lpVtbl, iface);
215 FIXME("%p: STUB\n", This);
216 return E_NOTIMPL;
219 HRESULT WINAPI fnTextSrv_TxQueryHitPoint(ITextServices *iface,
220 DWORD dwDrawAspect,
221 LONG lindex,
222 void* pvAspect,
223 DVTARGETDEVICE* ptd,
224 HDC hdcDraw,
225 HDC hicTargetDev,
226 LPCRECT lprcClient,
227 INT x, INT y,
228 DWORD* pHitResult)
230 ICOM_THIS_MULTI(ITextServicesImpl, lpVtbl, iface);
232 FIXME("%p: STUB\n", This);
233 return E_NOTIMPL;
236 HRESULT WINAPI fnTextSrv_OnTxInplaceActivate(ITextServices *iface,
237 LPCRECT prcClient)
239 ICOM_THIS_MULTI(ITextServicesImpl, lpVtbl, iface);
241 FIXME("%p: STUB\n", This);
242 return E_NOTIMPL;
245 HRESULT WINAPI fnTextSrv_OnTxInplaceDeactivate(ITextServices *iface)
247 ICOM_THIS_MULTI(ITextServicesImpl, lpVtbl, iface);
249 FIXME("%p: STUB\n", This);
250 return E_NOTIMPL;
253 HRESULT WINAPI fnTextSrv_OnTxUIActivate(ITextServices *iface)
255 ICOM_THIS_MULTI(ITextServicesImpl, lpVtbl, iface);
257 FIXME("%p: STUB\n", This);
258 return E_NOTIMPL;
261 HRESULT WINAPI fnTextSrv_OnTxUIDeactivate(ITextServices *iface)
263 ICOM_THIS_MULTI(ITextServicesImpl, lpVtbl, iface);
265 FIXME("%p: STUB\n", This);
266 return E_NOTIMPL;
269 HRESULT WINAPI fnTextSrv_TxGetText(ITextServices *iface,
270 BSTR* pbstrText)
272 ICOM_THIS_MULTI(ITextServicesImpl, lpVtbl, iface);
274 FIXME("%p: STUB\n", This);
275 return E_NOTIMPL;
278 HRESULT WINAPI fnTextSrv_TxSetText(ITextServices *iface,
279 LPCWSTR pszText)
281 ICOM_THIS_MULTI(ITextServicesImpl, lpVtbl, iface);
283 FIXME("%p: STUB\n", This);
284 return E_NOTIMPL;
287 HRESULT WINAPI fnTextSrv_TxGetCurrentTargetX(ITextServices *iface,
288 LONG* x)
290 ICOM_THIS_MULTI(ITextServicesImpl, lpVtbl, iface);
292 FIXME("%p: STUB\n", This);
293 return E_NOTIMPL;
296 HRESULT WINAPI fnTextSrv_TxGetBaseLinePos(ITextServices *iface,
297 LONG* x)
299 ICOM_THIS_MULTI(ITextServicesImpl, lpVtbl, iface);
301 FIXME("%p: STUB\n", This);
302 return E_NOTIMPL;
305 HRESULT WINAPI fnTextSrv_TxGetNaturalSize(ITextServices *iface,
306 DWORD dwAspect,
307 HDC hdcDraw,
308 HDC hicTargetDev,
309 DVTARGETDEVICE* ptd,
310 DWORD dwMode,
311 const SIZEL* psizelExtent,
312 LONG* pwidth,
313 LONG* pheight)
315 ICOM_THIS_MULTI(ITextServicesImpl, lpVtbl, iface);
317 FIXME("%p: STUB\n", This);
318 return E_NOTIMPL;
321 HRESULT WINAPI fnTextSrv_TxGetDropTarget(ITextServices *iface,
322 IDropTarget** ppDropTarget)
324 ICOM_THIS_MULTI(ITextServicesImpl, lpVtbl, iface);
326 FIXME("%p: STUB\n", This);
327 return E_NOTIMPL;
330 HRESULT WINAPI fnTextSrv_OnTxPropertyBitsChange(ITextServices *iface,
331 DWORD dwMask,
332 DWORD dwBits)
334 ICOM_THIS_MULTI(ITextServicesImpl, lpVtbl, iface);
336 FIXME("%p: STUB\n", This);
337 return E_NOTIMPL;
340 HRESULT WINAPI fnTextSrv_TxGetCachedSize(ITextServices *iface,
341 DWORD* pdwWidth,
342 DWORD* pdwHeight)
344 ICOM_THIS_MULTI(ITextServicesImpl, lpVtbl, iface);
346 FIXME("%p: STUB\n", This);
347 return E_NOTIMPL;
350 DEFINE_THISCALL_WRAPPER(fnTextSrv_TxSendMessage)
351 DEFINE_THISCALL_WRAPPER(fnTextSrv_TxDraw)
352 DEFINE_THISCALL_WRAPPER(fnTextSrv_TxGetHScroll)
353 DEFINE_THISCALL_WRAPPER(fnTextSrv_TxGetVScroll)
354 DEFINE_THISCALL_WRAPPER(fnTextSrv_OnTxSetCursor)
355 DEFINE_THISCALL_WRAPPER(fnTextSrv_TxQueryHitPoint)
356 DEFINE_THISCALL_WRAPPER(fnTextSrv_OnTxInplaceActivate)
357 DEFINE_THISCALL_WRAPPER(fnTextSrv_OnTxInplaceDeactivate)
358 DEFINE_THISCALL_WRAPPER(fnTextSrv_OnTxUIActivate)
359 DEFINE_THISCALL_WRAPPER(fnTextSrv_OnTxUIDeactivate)
360 DEFINE_THISCALL_WRAPPER(fnTextSrv_TxGetText)
361 DEFINE_THISCALL_WRAPPER(fnTextSrv_TxSetText)
362 DEFINE_THISCALL_WRAPPER(fnTextSrv_TxGetCurrentTargetX)
363 DEFINE_THISCALL_WRAPPER(fnTextSrv_TxGetBaseLinePos)
364 DEFINE_THISCALL_WRAPPER(fnTextSrv_TxGetNaturalSize)
365 DEFINE_THISCALL_WRAPPER(fnTextSrv_TxGetDropTarget)
366 DEFINE_THISCALL_WRAPPER(fnTextSrv_OnTxPropertyBitsChange)
367 DEFINE_THISCALL_WRAPPER(fnTextSrv_TxGetCachedSize)
369 static const ITextServicesVtbl textservices_Vtbl =
371 fnTextSrv_QueryInterface,
372 fnTextSrv_AddRef,
373 fnTextSrv_Release,
374 THISCALL(fnTextSrv_TxSendMessage),
375 THISCALL(fnTextSrv_TxDraw),
376 THISCALL(fnTextSrv_TxGetHScroll),
377 THISCALL(fnTextSrv_TxGetVScroll),
378 THISCALL(fnTextSrv_OnTxSetCursor),
379 THISCALL(fnTextSrv_TxQueryHitPoint),
380 THISCALL(fnTextSrv_OnTxInplaceActivate),
381 THISCALL(fnTextSrv_OnTxInplaceDeactivate),
382 THISCALL(fnTextSrv_OnTxUIActivate),
383 THISCALL(fnTextSrv_OnTxUIDeactivate),
384 THISCALL(fnTextSrv_TxGetText),
385 THISCALL(fnTextSrv_TxSetText),
386 THISCALL(fnTextSrv_TxGetCurrentTargetX),
387 THISCALL(fnTextSrv_TxGetBaseLinePos),
388 THISCALL(fnTextSrv_TxGetNaturalSize),
389 THISCALL(fnTextSrv_TxGetDropTarget),
390 THISCALL(fnTextSrv_OnTxPropertyBitsChange),
391 THISCALL(fnTextSrv_TxGetCachedSize)