~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Wine Cross Reference
wine/dlls/riched20/txtsrv.c

Version: ~ [ wine-1.5.30 ] ~ [ wine-1.5.29 ] ~ [ wine-1.5.28 ] ~ [ wine-1.5.27 ] ~ [ wine-1.5.26 ] ~ [ wine-1.5.25 ] ~ [ wine-1.5.24 ] ~ [ wine-1.5.23 ] ~ [ wine-1.5.22 ] ~ [ wine-1.5.21 ] ~ [ wine-1.5.20 ] ~ [ wine-1.5.19 ] ~ [ wine-1.5.18 ] ~ [ wine-1.5.17 ] ~ [ wine-1.5.16 ] ~ [ wine-1.5.15 ] ~ [ wine-1.5.14 ] ~ [ wine-1.5.13 ] ~ [ wine-1.5.12 ] ~ [ wine-1.5.11 ] ~ [ wine-1.5.10 ] ~ [ wine-1.5.9 ] ~ [ wine-1.5.8 ] ~ [ wine-1.5.7 ] ~ [ wine-1.4.1 ] ~ [ wine-1.5.6 ] ~ [ wine-1.5.5 ] ~ [ wine-1.5.4 ] ~ [ wine-1.5.3 ] ~ [ wine-1.5.2 ] ~ [ wine-1.5.1 ] ~ [ wine-1.5.0 ] ~ [ wine-1.4 ] ~ [ wine-1.4-rc6 ] ~ [ wine-1.4-rc5 ] ~ [ wine-1.4-rc4 ] ~ [ wine-1.4-rc3 ] ~ [ wine-1.4-rc2 ] ~ [ wine-1.4-rc1 ] ~ [ wine-1.3.37 ] ~ [ wine-1.3.36 ] ~ [ wine-1.3.35 ] ~ [ wine-1.3.34 ] ~ [ wine-1.3.33 ] ~ [ wine-1.3.32 ] ~ [ wine-1.3.31 ] ~ [ wine-1.3.30 ] ~ [ wine-1.3.29 ] ~ [ wine-1.3.28 ] ~ [ wine-1.3.27 ] ~ [ wine-1.3.26 ] ~ [ wine-1.3.25 ] ~ [ wine-1.3.24 ] ~ [ wine-1.3.23 ] ~ [ wine-1.3.22 ] ~ [ wine-1.3.21 ] ~ [ wine-1.3.20 ] ~ [ wine-1.3.19 ] ~ [ wine-1.3.18 ] ~ [ wine-1.2.3 ] ~ [ wine-1.3.17 ] ~ [ wine-1.3.16 ] ~ [ wine-1.3.15 ] ~ [ wine-1.3.14 ] ~ [ wine-1.3.13 ] ~ [ wine-1.3.12 ] ~ [ wine-1.3.11 ] ~ [ wine-1.3.10 ] ~ [ wine-1.3.9 ] ~ [ wine-1.2.2 ] ~ [ wine-1.3.8 ] ~ [ wine-1.3.7 ] ~ [ wine-1.3.6 ] ~ [ wine-1.3.5 ] ~ [ wine-1.2.1 ] ~ [ wine-1.3.4 ] ~ [ wine-1.3.3 ] ~ [ wine-1.3.2 ] ~ [ wine-1.3.1 ] ~ [ wine-1.3.0 ] ~ [ wine-1.2 ] ~ [ wine-1.2-rc7 ] ~ [ wine-1.2-rc6 ] ~ [ wine-1.2-rc5 ] ~ [ wine-1.2-rc4 ] ~ [ wine-1.2-rc3 ] ~ [ wine-1.2-rc2 ] ~ [ wine-1.2-rc1 ] ~ [ wine-1.1.44 ] ~ [ wine-1.1.43 ] ~ [ wine-1.1.42 ] ~ [ wine-1.1.41 ] ~ [ wine-1.1.40 ] ~ [ wine-1.1.39 ] ~ [ wine-1.1.38 ] ~ [ wine-1.1.37 ] ~ [ wine-1.1.36 ] ~ [ wine-1.1.35 ] ~ [ wine-1.1.34 ] ~ [ wine-1.1.33 ] ~ [ wine-1.1.32 ] ~ [ wine-1.1.31 ] ~ [ wine-1.1.30 ] ~ [ wine-1.1.29 ] ~ [ wine-1.1.28 ] ~ [ wine-1.1.27 ] ~ [ wine-1.1.26 ] ~ [ wine-1.1.25 ] ~ [ wine-1.1.24 ] ~ [ wine-1.1.23 ] ~ [ wine-1.1.22 ] ~ [ wine-1.1.21 ] ~ [ wine-1.1.20 ] ~ [ wine-1.1.19 ] ~ [ wine-1.1.18 ] ~ [ wine-1.1.17 ] ~ [ wine-1.1.16 ] ~ [ wine-1.1.15 ] ~ [ wine-1.1.14 ] ~ [ wine-1.1.13 ] ~ [ wine-1.1.12 ] ~ [ wine-1.1.11 ] ~ [ wine-1.1.10 ] ~ [ wine-1.1.9 ] ~ [ wine-1.1.8 ] ~ [ wine-1.1.7 ] ~ [ wine-1.0.1 ] ~ [ wine-1.1.6 ] ~ [ wine-1.1.5 ] ~ [ wine-1.1.4 ] ~ [ wine-1.1.3 ] ~ [ wine-1.1.2 ] ~ [ wine-1.1.1 ] ~ [ wine-1.1.0 ] ~ [ wine-1.0 ] ~

  1 /*
  2  * RichEdit - functions and interfaces around CreateTextServices
  3  *
  4  * Copyright 2005, 2006, Maarten Lankhorst
  5  *
  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.
 10  *
 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.
 15  *
 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
 19  */
 20 
 21 #include "config.h"
 22 #include "wine/port.h"
 23 
 24 #define NONAMELESSSTRUCT
 25 #define NONAMELESSUNION
 26 #define COBJMACROS
 27 
 28 #include "editor.h"
 29 #include "ole2.h"
 30 #include "oleauto.h"
 31 #include "richole.h"
 32 #include "imm.h"
 33 #include "textserv.h"
 34 #include "wine/debug.h"
 35 #include "editstr.h"
 36 
 37 #ifdef __i386__  /* thiscall functions are i386-specific */
 38 
 39 #define THISCALL(func) __thiscall_ ## func
 40 #define DEFINE_THISCALL_WRAPPER(func,args) \
 41    extern typeof(func) THISCALL(func); \
 42    __ASM_STDCALL_FUNC(__thiscall_ ## func, args, \
 43                    "popl %eax\n\t" \
 44                    "pushl %ecx\n\t" \
 45                    "pushl %eax\n\t" \
 46                    "jmp " __ASM_NAME(#func) __ASM_STDCALL(args) )
 47 #else /* __i386__ */
 48 
 49 #define THISCALL(func) func
 50 #define DEFINE_THISCALL_WRAPPER(func,args) /* nothing */
 51 
 52 #endif /* __i386__ */
 53 
 54 WINE_DEFAULT_DEBUG_CHANNEL(richedit);
 55 
 56 typedef struct ITextServicesImpl {
 57    ITextServices ITextServices_iface;
 58    ITextHost *pMyHost;
 59    LONG ref;
 60    CRITICAL_SECTION csTxtSrv;
 61    ME_TextEditor *editor;
 62    char spare[256];
 63 } ITextServicesImpl;
 64 
 65 static const ITextServicesVtbl textservices_Vtbl;
 66 
 67 /******************************************************************
 68  *        CreateTextServices (RICHED20.4)
 69  */
 70 HRESULT WINAPI CreateTextServices(IUnknown  * pUnkOuter,
 71                                   ITextHost * pITextHost,
 72                                   IUnknown  **ppUnk)
 73 {
 74    ITextServicesImpl *ITextImpl;
 75    HRESULT hres;
 76    TRACE("%p %p --> %p\n", pUnkOuter, pITextHost, ppUnk);
 77    if (pITextHost == NULL)
 78       return E_POINTER;
 79 
 80    ITextImpl = CoTaskMemAlloc(sizeof(*ITextImpl));
 81    if (ITextImpl == NULL)
 82       return E_OUTOFMEMORY;
 83    InitializeCriticalSection(&ITextImpl->csTxtSrv);
 84    ITextImpl->csTxtSrv.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": ITextServicesImpl.csTxtSrv");
 85    ITextImpl->ref = 1;
 86    ITextHost_AddRef(pITextHost);
 87    ITextImpl->pMyHost = pITextHost;
 88    ITextImpl->ITextServices_iface.lpVtbl = &textservices_Vtbl;
 89    ITextImpl->editor = ME_MakeEditor(pITextHost, FALSE);
 90    ITextImpl->editor->exStyleFlags = 0;
 91    ITextImpl->editor->rcFormat.left = 0;
 92    ITextImpl->editor->rcFormat.top = 0;
 93    ITextImpl->editor->rcFormat.right = 0;
 94    ITextImpl->editor->rcFormat.bottom = 0;
 95 
 96    ME_HandleMessage(ITextImpl->editor, WM_CREATE, 0, 0, TRUE, &hres);
 97 
 98    if (pUnkOuter)
 99    {
100       FIXME("Support aggregation\n");
101       return CLASS_E_NOAGGREGATION;
102    }
103 
104    *ppUnk = (IUnknown *)&ITextImpl->ITextServices_iface;
105    return S_OK;
106 }
107 
108 static inline ITextServicesImpl *impl_from_ITextServices(ITextServices *iface)
109 {
110    return CONTAINING_RECORD(iface, ITextServicesImpl, ITextServices_iface);
111 }
112 
113 static HRESULT WINAPI fnTextSrv_QueryInterface(ITextServices *iface, REFIID riid, void **ppv)
114 {
115    ITextServicesImpl *This = impl_from_ITextServices(iface);
116 
117    TRACE("(%p/%p)->(%s, %p)\n", This, iface, debugstr_guid(riid), ppv);
118    *ppv = NULL;
119    if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_ITextServices))
120       *ppv = This;
121 
122    if (*ppv)
123    {
124       IUnknown_AddRef((IUnknown *)(*ppv));
125       TRACE ("-- Interface = %p\n", *ppv);
126       return S_OK;
127    }
128    FIXME("Unknown interface: %s\n", debugstr_guid(riid));
129    return E_NOINTERFACE;
130 }
131 
132 static ULONG WINAPI fnTextSrv_AddRef(ITextServices *iface)
133 {
134    ITextServicesImpl *This = impl_from_ITextServices(iface);
135    DWORD ref = InterlockedIncrement(&This->ref);
136 
137    TRACE("(%p/%p)->() AddRef from %d\n", This, iface, ref - 1);
138    return ref;
139 }
140 
141 static ULONG WINAPI fnTextSrv_Release(ITextServices *iface)
142 {
143    ITextServicesImpl *This = impl_from_ITextServices(iface);
144    DWORD ref = InterlockedDecrement(&This->ref);
145 
146    TRACE("(%p/%p)->() Release from %d\n", This, iface, ref + 1);
147 
148    if (!ref)
149    {
150       ITextHost_Release(This->pMyHost);
151       This->csTxtSrv.DebugInfo->Spare[0] = 0;
152       DeleteCriticalSection(&This->csTxtSrv);
153       CoTaskMemFree(This);
154    }
155    return ref;
156 }
157 
158 DECLSPEC_HIDDEN HRESULT WINAPI fnTextSrv_TxSendMessage(ITextServices *iface, UINT msg, WPARAM wparam,
159                                        LPARAM lparam, LRESULT *plresult)
160 {
161    ITextServicesImpl *This = impl_from_ITextServices(iface);
162    HRESULT hresult;
163    LRESULT lresult;
164 
165    lresult = ME_HandleMessage(This->editor, msg, wparam, lparam, TRUE, &hresult);
166    if (plresult) *plresult = lresult;
167    return hresult;
168 }
169 
170 DECLSPEC_HIDDEN HRESULT WINAPI fnTextSrv_TxDraw(ITextServices *iface, DWORD dwDrawAspect, LONG lindex,
171                                 void *pvAspect, DVTARGETDEVICE *ptd, HDC hdcDraw, HDC hdcTargetDev,
172                                 LPCRECTL lprcBounds, LPCRECTL lprcWBounds, LPRECT lprcUpdate,
173                                 BOOL (CALLBACK * pfnContinue)(DWORD), DWORD dwContinue,
174                                 LONG lViewId)
175 {
176    ITextServicesImpl *This = impl_from_ITextServices(iface);
177 
178    FIXME("%p: STUB\n", This);
179    return E_NOTIMPL;
180 }
181 
182 DECLSPEC_HIDDEN HRESULT WINAPI fnTextSrv_TxGetHScroll(ITextServices *iface, LONG *plMin, LONG *plMax, LONG *plPos,
183                                       LONG *plPage, BOOL *pfEnabled)
184 {
185    ITextServicesImpl *This = impl_from_ITextServices(iface);
186 
187    *plMin = This->editor->horz_si.nMin;
188    *plMax = This->editor->horz_si.nMax;
189    *plPos = This->editor->horz_si.nPos;
190    *plPage = This->editor->horz_si.nPage;
191    *pfEnabled = (This->editor->styleFlags & WS_HSCROLL) != 0;
192    return S_OK;
193 }
194 
195 DECLSPEC_HIDDEN HRESULT WINAPI fnTextSrv_TxGetVScroll(ITextServices *iface, LONG *plMin, LONG *plMax, LONG *plPos,
196                                       LONG *plPage, BOOL *pfEnabled)
197 {
198    ITextServicesImpl *This = impl_from_ITextServices(iface);
199 
200    *plMin = This->editor->vert_si.nMin;
201    *plMax = This->editor->vert_si.nMax;
202    *plPos = This->editor->vert_si.nPos;
203    *plPage = This->editor->vert_si.nPage;
204    *pfEnabled = (This->editor->styleFlags & WS_VSCROLL) != 0;
205    return S_OK;
206 }
207 
208 DECLSPEC_HIDDEN HRESULT WINAPI fnTextSrv_OnTxSetCursor(ITextServices *iface, DWORD dwDrawAspect, LONG lindex,
209                                        void *pvAspect, DVTARGETDEVICE *ptd, HDC hdcDraw,
210                                        HDC hicTargetDev, LPCRECT lprcClient, INT x, INT y)
211 {
212    ITextServicesImpl *This = impl_from_ITextServices(iface);
213 
214    FIXME("%p: STUB\n", This);
215    return E_NOTIMPL;
216 }
217 
218 DECLSPEC_HIDDEN HRESULT WINAPI fnTextSrv_TxQueryHitPoint(ITextServices *iface, DWORD dwDrawAspect, LONG lindex,
219                                          void *pvAspect, DVTARGETDEVICE *ptd, HDC hdcDraw,
220                                          HDC hicTargetDev, LPCRECT lprcClient, INT x, INT y,
221                                          DWORD *pHitResult)
222 {
223    ITextServicesImpl *This = impl_from_ITextServices(iface);
224 
225    FIXME("%p: STUB\n", This);
226    return E_NOTIMPL;
227 }
228 
229 DECLSPEC_HIDDEN HRESULT WINAPI fnTextSrv_OnTxInplaceActivate(ITextServices *iface, LPCRECT prcClient)
230 {
231    ITextServicesImpl *This = impl_from_ITextServices(iface);
232 
233    FIXME("%p: STUB\n", This);
234    return E_NOTIMPL;
235 }
236 
237 DECLSPEC_HIDDEN HRESULT WINAPI fnTextSrv_OnTxInplaceDeactivate(ITextServices *iface)
238 {
239    ITextServicesImpl *This = impl_from_ITextServices(iface);
240 
241    FIXME("%p: STUB\n", This);
242    return E_NOTIMPL;
243 }
244 
245 DECLSPEC_HIDDEN HRESULT WINAPI fnTextSrv_OnTxUIActivate(ITextServices *iface)
246 {
247    ITextServicesImpl *This = impl_from_ITextServices(iface);
248 
249    FIXME("%p: STUB\n", This);
250    return E_NOTIMPL;
251 }
252 
253 DECLSPEC_HIDDEN HRESULT WINAPI fnTextSrv_OnTxUIDeactivate(ITextServices *iface)
254 {
255    ITextServicesImpl *This = impl_from_ITextServices(iface);
256 
257    FIXME("%p: STUB\n", This);
258    return E_NOTIMPL;
259 }
260 
261 DECLSPEC_HIDDEN HRESULT WINAPI fnTextSrv_TxGetText(ITextServices *iface, BSTR *pbstrText)
262 {
263    ITextServicesImpl *This = impl_from_ITextServices(iface);
264    int length;
265 
266    length = ME_GetTextLength(This->editor);
267    if (length)
268    {
269       ME_Cursor start;
270       BSTR bstr;
271       bstr = SysAllocStringByteLen(NULL, length * sizeof(WCHAR));
272       if (bstr == NULL)
273          return E_OUTOFMEMORY;
274 
275       ME_CursorFromCharOfs(This->editor, 0, &start);
276       ME_GetTextW(This->editor, bstr, length, &start, INT_MAX, FALSE);
277       *pbstrText = bstr;
278    } else {
279       *pbstrText = NULL;
280    }
281 
282    return S_OK;
283 }
284 
285 DECLSPEC_HIDDEN HRESULT WINAPI fnTextSrv_TxSetText(ITextServices *iface, LPCWSTR pszText)
286 {
287    ITextServicesImpl *This = impl_from_ITextServices(iface);
288    ME_Cursor cursor;
289 
290    ME_SetCursorToStart(This->editor, &cursor);
291    ME_InternalDeleteText(This->editor, &cursor,
292                          ME_GetTextLength(This->editor), FALSE);
293    ME_InsertTextFromCursor(This->editor, 0, pszText, -1,
294                            This->editor->pBuffer->pDefaultStyle);
295    ME_SetSelection(This->editor, 0, 0);
296    This->editor->nModifyStep = 0;
297    OleFlushClipboard();
298    ME_EmptyUndoStack(This->editor);
299    ME_UpdateRepaint(This->editor, FALSE);
300 
301    return S_OK;
302 }
303 
304 DECLSPEC_HIDDEN HRESULT WINAPI fnTextSrv_TxGetCurrentTargetX(ITextServices *iface, LONG *x)
305 {
306    ITextServicesImpl *This = impl_from_ITextServices(iface);
307 
308    FIXME("%p: STUB\n", This);
309    return E_NOTIMPL;
310 }
311 
312 DECLSPEC_HIDDEN HRESULT WINAPI fnTextSrv_TxGetBaseLinePos(ITextServices *iface, LONG *x)
313 {
314    ITextServicesImpl *This = impl_from_ITextServices(iface);
315 
316    FIXME("%p: STUB\n", This);
317    return E_NOTIMPL;
318 }
319 
320 DECLSPEC_HIDDEN HRESULT WINAPI fnTextSrv_TxGetNaturalSize(ITextServices *iface, DWORD dwAspect, HDC hdcDraw,
321                                           HDC hicTargetDev, DVTARGETDEVICE *ptd, DWORD dwMode,
322                                           const SIZEL *psizelExtent, LONG *pwidth, LONG *pheight)
323 {
324    ITextServicesImpl *This = impl_from_ITextServices(iface);
325 
326    FIXME("%p: STUB\n", This);
327    return E_NOTIMPL;
328 }
329 
330 DECLSPEC_HIDDEN HRESULT WINAPI fnTextSrv_TxGetDropTarget(ITextServices *iface, IDropTarget **ppDropTarget)
331 {
332    ITextServicesImpl *This = impl_from_ITextServices(iface);
333 
334    FIXME("%p: STUB\n", This);
335    return E_NOTIMPL;
336 }
337 
338 DECLSPEC_HIDDEN HRESULT WINAPI fnTextSrv_OnTxPropertyBitsChange(ITextServices *iface, DWORD dwMask, DWORD dwBits)
339 {
340    ITextServicesImpl *This = impl_from_ITextServices(iface);
341 
342    FIXME("%p: STUB\n", This);
343    return E_NOTIMPL;
344 }
345 
346 DECLSPEC_HIDDEN HRESULT WINAPI fnTextSrv_TxGetCachedSize(ITextServices *iface, DWORD *pdwWidth, DWORD *pdwHeight)
347 {
348    ITextServicesImpl *This = impl_from_ITextServices(iface);
349 
350    FIXME("%p: STUB\n", This);
351    return E_NOTIMPL;
352 }
353 
354 DEFINE_THISCALL_WRAPPER(fnTextSrv_TxSendMessage,20)
355 DEFINE_THISCALL_WRAPPER(fnTextSrv_TxDraw,52)
356 DEFINE_THISCALL_WRAPPER(fnTextSrv_TxGetHScroll,24)
357 DEFINE_THISCALL_WRAPPER(fnTextSrv_TxGetVScroll,24)
358 DEFINE_THISCALL_WRAPPER(fnTextSrv_OnTxSetCursor,40)
359 DEFINE_THISCALL_WRAPPER(fnTextSrv_TxQueryHitPoint,44)
360 DEFINE_THISCALL_WRAPPER(fnTextSrv_OnTxInplaceActivate,8)
361 DEFINE_THISCALL_WRAPPER(fnTextSrv_OnTxInplaceDeactivate,4)
362 DEFINE_THISCALL_WRAPPER(fnTextSrv_OnTxUIActivate,4)
363 DEFINE_THISCALL_WRAPPER(fnTextSrv_OnTxUIDeactivate,4)
364 DEFINE_THISCALL_WRAPPER(fnTextSrv_TxGetText,8)
365 DEFINE_THISCALL_WRAPPER(fnTextSrv_TxSetText,8)
366 DEFINE_THISCALL_WRAPPER(fnTextSrv_TxGetCurrentTargetX,8)
367 DEFINE_THISCALL_WRAPPER(fnTextSrv_TxGetBaseLinePos,8)
368 DEFINE_THISCALL_WRAPPER(fnTextSrv_TxGetNaturalSize,36)
369 DEFINE_THISCALL_WRAPPER(fnTextSrv_TxGetDropTarget,8)
370 DEFINE_THISCALL_WRAPPER(fnTextSrv_OnTxPropertyBitsChange,12)
371 DEFINE_THISCALL_WRAPPER(fnTextSrv_TxGetCachedSize,12)
372 
373 static const ITextServicesVtbl textservices_Vtbl =
374 {
375    fnTextSrv_QueryInterface,
376    fnTextSrv_AddRef,
377    fnTextSrv_Release,
378    THISCALL(fnTextSrv_TxSendMessage),
379    THISCALL(fnTextSrv_TxDraw),
380    THISCALL(fnTextSrv_TxGetHScroll),
381    THISCALL(fnTextSrv_TxGetVScroll),
382    THISCALL(fnTextSrv_OnTxSetCursor),
383    THISCALL(fnTextSrv_TxQueryHitPoint),
384    THISCALL(fnTextSrv_OnTxInplaceActivate),
385    THISCALL(fnTextSrv_OnTxInplaceDeactivate),
386    THISCALL(fnTextSrv_OnTxUIActivate),
387    THISCALL(fnTextSrv_OnTxUIDeactivate),
388    THISCALL(fnTextSrv_TxGetText),
389    THISCALL(fnTextSrv_TxSetText),
390    THISCALL(fnTextSrv_TxGetCurrentTargetX),
391    THISCALL(fnTextSrv_TxGetBaseLinePos),
392    THISCALL(fnTextSrv_TxGetNaturalSize),
393    THISCALL(fnTextSrv_TxGetDropTarget),
394    THISCALL(fnTextSrv_OnTxPropertyBitsChange),
395    THISCALL(fnTextSrv_TxGetCachedSize)
396 };
397 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.