ReactOS  0.4.15-dev-3331-g8ebe441
txtsrv.c
Go to the documentation of this file.
1 /*
2  * Unit test suite for windowless rich edit controls
3  *
4  * Copyright 2008 Maarten Lankhorst
5  * Copyright 2008 Austin Lund
6  * Copyright 2008 Dylan Smith
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21  */
22 
23 #define COBJMACROS
24 #define CONST_VTABLE
25 
26 #include <stdio.h>
27 #include <stdarg.h>
28 #include <windef.h>
29 #include <winbase.h>
30 #include <objbase.h>
31 #include <richedit.h>
32 #include <tom.h>
33 #include <richole.h>
34 #include <initguid.h>
35 #include <imm.h>
36 #include <textserv.h>
37 #include <wine/test.h>
38 #include <oleauto.h>
39 #include <limits.h>
40 
46 
47 /* Define C Macros for ITextServices calls. */
48 
49 /* Use a special table for x86 machines to convert the thiscall
50  * calling convention. This isn't needed on other platforms. */
51 #if defined(__i386__) && !defined(__MINGW32__)
52 static ITextServicesVtbl itextServicesStdcallVtbl;
53 #define TXTSERV_VTABLE(This) (&itextServicesStdcallVtbl)
54 #else /* __i386__ */
55 #define TXTSERV_VTABLE(This) (This)->lpVtbl
56 #endif /* __i386__ */
57 
58 #define ITextServices_TxSendMessage(This,a,b,c,d) TXTSERV_VTABLE(This)->TxSendMessage(This,a,b,c,d)
59 #define ITextServices_TxDraw(This,a,b,c,d,e,f,g,h,i,j,k,l) TXTSERV_VTABLE(This)->TxDraw(This,a,b,c,d,e,f,g,h,i,j,k,l)
60 #define ITextServices_TxGetHScroll(This,a,b,c,d,e) TXTSERV_VTABLE(This)->TxGetHScroll(This,a,b,c,d,e)
61 #define ITextServices_TxGetVScroll(This,a,b,c,d,e) TXTSERV_VTABLE(This)->TxGetVScroll(This,a,b,c,d,e)
62 #define ITextServices_OnTxSetCursor(This,a,b,c,d,e,f,g,h,i) TXTSERV_VTABLE(This)->OnTxSetCursor(This,a,b,c,d,e,f,g,h,i)
63 #define ITextServices_TxQueryHitPoint(This,a,b,c,d,e,f,g,h,i,j) TXTSERV_VTABLE(This)->TxQueryHitPoint(This,a,b,c,d,e,f,g,h,i,j)
64 #define ITextServices_OnTxInplaceActivate(This,a) TXTSERV_VTABLE(This)->OnTxInplaceActivate(This,a)
65 #define ITextServices_OnTxInplaceDeactivate(This) TXTSERV_VTABLE(This)->OnTxInplaceDeactivate(This)
66 #define ITextServices_OnTxUIActivate(This) TXTSERV_VTABLE(This)->OnTxUIActivate(This)
67 #define ITextServices_OnTxUIDeactivate(This) TXTSERV_VTABLE(This)->OnTxUIDeactivate(This)
68 #define ITextServices_TxGetText(This,a) TXTSERV_VTABLE(This)->TxGetText(This,a)
69 #define ITextServices_TxSetText(This,a) TXTSERV_VTABLE(This)->TxSetText(This,a)
70 #define ITextServices_TxGetCurTargetX(This,a) TXTSERV_VTABLE(This)->TxGetCurTargetX(This,a)
71 #define ITextServices_TxGetBaseLinePos(This,a) TXTSERV_VTABLE(This)->TxGetBaseLinePos(This,a)
72 #define ITextServices_TxGetNaturalSize(This,a,b,c,d,e,f,g,h) TXTSERV_VTABLE(This)->TxGetNaturalSize(This,a,b,c,d,e,f,g,h)
73 #define ITextServices_TxGetDropTarget(This,a) TXTSERV_VTABLE(This)->TxGetDropTarget(This,a)
74 #define ITextServices_OnTxPropertyBitsChange(This,a,b) TXTSERV_VTABLE(This)->OnTxPropertyBitsChange(This,a,b)
75 #define ITextServices_TxGetCachedSize(This,a,b) TXTSERV_VTABLE(This)->TxGetCachedSize(This,a,b)
76 
77 /* Set the WINETEST_DEBUG environment variable to be greater than 1 for verbose
78  * function call traces of ITextHost. */
79 #define TRACECALL if(winetest_debug > 1) trace
80 
81 /************************************************************************/
82 /* ITextHost implementation for conformance testing. */
83 
84 typedef struct ITextHostTestImpl
85 {
86  ITextHost ITextHost_iface;
90 
91 static inline ITextHostTestImpl *impl_from_ITextHost(ITextHost *iface)
92 {
93  return CONTAINING_RECORD(iface, ITextHostTestImpl, ITextHost_iface);
94 }
95 
97  REFIID riid,
99 {
101 
103  *ppvObject = &This->ITextHost_iface;
104  ITextHost_AddRef((ITextHost *)*ppvObject);
105  return S_OK;
106  }
107 
108  return E_NOINTERFACE;
109 }
110 
111 static ULONG WINAPI ITextHostImpl_AddRef(ITextHost *iface)
112 {
114  ULONG refCount = InterlockedIncrement(&This->refCount);
115  return refCount;
116 }
117 
118 static ULONG WINAPI ITextHostImpl_Release(ITextHost *iface)
119 {
121  ULONG refCount = InterlockedDecrement(&This->refCount);
122 
123  if (!refCount)
124  {
126  return 0;
127  } else {
128  return refCount;
129  }
130 }
131 
132 #ifdef __REACTOS__
133 #undef __thiscall
134 #define __thiscall WINAPI
135 #endif /* __REACTOS__ */
136 
137 static HDC __thiscall ITextHostImpl_TxGetDC(ITextHost *iface)
138 {
140  TRACECALL("Call to TxGetDC(%p)\n", This);
141  return NULL;
142 }
143 
144 static INT __thiscall ITextHostImpl_TxReleaseDC(ITextHost *iface, HDC hdc)
145 {
147  TRACECALL("Call to TxReleaseDC(%p)\n", This);
148  return 0;
149 }
150 
151 static BOOL __thiscall ITextHostImpl_TxShowScrollBar(ITextHost *iface, INT fnBar, BOOL fShow)
152 {
154  TRACECALL("Call to TxShowScrollBar(%p, fnBar=%d, fShow=%d)\n",
155  This, fnBar, fShow);
156  return FALSE;
157 }
158 
159 static BOOL __thiscall ITextHostImpl_TxEnableScrollBar(ITextHost *iface, INT fuSBFlags, INT fuArrowflags)
160 {
162  TRACECALL("Call to TxEnableScrollBar(%p, fuSBFlags=%d, fuArrowflags=%d)\n",
163  This, fuSBFlags, fuArrowflags);
164  return FALSE;
165 }
166 
167 static BOOL __thiscall ITextHostImpl_TxSetScrollRange(ITextHost *iface, INT fnBar, LONG nMinPos,
168  INT nMaxPos, BOOL fRedraw)
169 {
171  TRACECALL("Call to TxSetScrollRange(%p, fnBar=%d, nMinPos=%d, nMaxPos=%d, fRedraw=%d)\n",
172  This, fnBar, nMinPos, nMaxPos, fRedraw);
173  return FALSE;
174 }
175 
176 static BOOL __thiscall ITextHostImpl_TxSetScrollPos(ITextHost *iface, INT fnBar, INT nPos, BOOL fRedraw)
177 {
179  TRACECALL("Call to TxSetScrollPos(%p, fnBar=%d, nPos=%d, fRedraw=%d)\n",
180  This, fnBar, nPos, fRedraw);
181  return FALSE;
182 }
183 
184 static void __thiscall ITextHostImpl_TxInvalidateRect(ITextHost *iface, LPCRECT prc, BOOL fMode)
185 {
187  TRACECALL("Call to TxInvalidateRect(%p, prc=%p, fMode=%d)\n",
188  This, prc, fMode);
189 }
190 
191 static void __thiscall ITextHostImpl_TxViewChange(ITextHost *iface, BOOL fUpdate)
192 {
194  TRACECALL("Call to TxViewChange(%p, fUpdate=%d)\n",
195  This, fUpdate);
196 }
197 
198 static BOOL __thiscall ITextHostImpl_TxCreateCaret(ITextHost *iface, HBITMAP hbmp, INT xWidth, INT yHeight)
199 {
201  TRACECALL("Call to TxCreateCaret(%p, nbmp=%p, xWidth=%d, yHeight=%d)\n",
202  This, hbmp, xWidth, yHeight);
203  return FALSE;
204 }
205 
206 static BOOL __thiscall ITextHostImpl_TxShowCaret(ITextHost *iface, BOOL fShow)
207 {
209  TRACECALL("Call to TxShowCaret(%p, fShow=%d)\n",
210  This, fShow);
211  return FALSE;
212 }
213 
215 {
217  TRACECALL("Call to TxSetCaretPos(%p, x=%d, y=%d)\n", This, x, y);
218  return FALSE;
219 }
220 
221 static BOOL __thiscall ITextHostImpl_TxSetTimer(ITextHost *iface, UINT idTimer, UINT uTimeout)
222 {
224  TRACECALL("Call to TxSetTimer(%p, idTimer=%u, uTimeout=%u)\n",
225  This, idTimer, uTimeout);
226  return FALSE;
227 }
228 
229 static void __thiscall ITextHostImpl_TxKillTimer(ITextHost *iface, UINT idTimer)
230 {
232  TRACECALL("Call to TxKillTimer(%p, idTimer=%u)\n", This, idTimer);
233 }
234 
235 static void __thiscall ITextHostImpl_TxScrollWindowEx(ITextHost *iface, INT dx, INT dy, LPCRECT lprcScroll,
236  LPCRECT lprcClip, HRGN hRgnUpdate, LPRECT lprcUpdate,
237  UINT fuScroll)
238 {
240  TRACECALL("Call to TxScrollWindowEx(%p, %d, %d, %p, %p, %p, %p, %d)\n",
241  This, dx, dy, lprcScroll, lprcClip, hRgnUpdate, lprcUpdate, fuScroll);
242 }
243 
244 static void __thiscall ITextHostImpl_TxSetCapture(ITextHost *iface, BOOL fCapture)
245 {
247  TRACECALL("Call to TxSetCapture(%p, fCapture=%d)\n", This, fCapture);
248 }
249 
250 static void __thiscall ITextHostImpl_TxSetFocus(ITextHost *iface)
251 {
253  TRACECALL("Call to TxSetFocus(%p)\n", This);
254 }
255 
256 static void __thiscall ITextHostImpl_TxSetCursor(ITextHost *iface, HCURSOR hcur, BOOL fText)
257 {
259  TRACECALL("Call to TxSetCursor(%p, hcur=%p, fText=%d)\n",
260  This, hcur, fText);
261 }
262 
264 {
266  TRACECALL("Call to TxScreenToClient(%p, lppt=%p)\n", This, lppt);
267  return FALSE;
268 }
269 
271 {
273  TRACECALL("Call to TxClientToScreen(%p, lppt=%p)\n", This, lppt);
274  return FALSE;
275 }
276 
277 static HRESULT __thiscall ITextHostImpl_TxActivate(ITextHost *iface, LONG *plOldState)
278 {
280  TRACECALL("Call to TxActivate(%p, plOldState=%p)\n", This, plOldState);
281  return E_NOTIMPL;
282 }
283 
284 static HRESULT __thiscall ITextHostImpl_TxDeactivate(ITextHost *iface, LONG lNewState)
285 {
287  TRACECALL("Call to TxDeactivate(%p, lNewState=%d)\n", This, lNewState);
288  return E_NOTIMPL;
289 }
290 
292 {
294  TRACECALL("Call to TxGetClientRect(%p, prc=%p)\n", This, prc);
295  return E_NOTIMPL;
296 }
297 
299 {
301  TRACECALL("Call to TxGetViewInset(%p, prc=%p)\n", This, prc);
302  return E_NOTIMPL;
303 }
304 
305 static HRESULT __thiscall ITextHostImpl_TxGetCharFormat(ITextHost *iface, const CHARFORMATW **ppCF)
306 {
308  TRACECALL("Call to TxGetCharFormat(%p, ppCF=%p)\n", This, ppCF);
309  *ppCF = (CHARFORMATW *)&This->char_format;
310  return S_OK;
311 }
312 
313 static HRESULT __thiscall ITextHostImpl_TxGetParaFormat(ITextHost *iface, const PARAFORMAT **ppPF)
314 {
316  TRACECALL("Call to TxGetParaFormat(%p, ppPF=%p)\n", This, ppPF);
317  return E_NOTIMPL;
318 }
319 
320 static COLORREF __thiscall ITextHostImpl_TxGetSysColor(ITextHost *iface, int nIndex)
321 {
323  TRACECALL("Call to TxGetSysColor(%p, nIndex=%d)\n", This, nIndex);
324  return E_NOTIMPL;
325 }
326 
328 {
330  TRACECALL("Call to TxGetBackStyle(%p, pStyle=%p)\n", This, pStyle);
331  return E_NOTIMPL;
332 }
333 
334 static HRESULT __thiscall ITextHostImpl_TxGetMaxLength(ITextHost *iface, DWORD *pLength)
335 {
337  TRACECALL("Call to TxGetMaxLength(%p, pLength=%p)\n", This, pLength);
338  return E_NOTIMPL;
339 }
340 
341 static HRESULT __thiscall ITextHostImpl_TxGetScrollBars(ITextHost *iface, DWORD *pdwScrollBar)
342 {
344  TRACECALL("Call to TxGetScrollBars(%p, pdwScrollBar=%p)\n",
345  This, pdwScrollBar);
346  return E_NOTIMPL;
347 }
348 
350 {
352  TRACECALL("Call to TxGetPasswordChar(%p, pch=%p)\n", This, pch);
353  return E_NOTIMPL;
354 }
355 
357 {
359  TRACECALL("Call to TxGetAcceleratorPos(%p, pch=%p)\n", This, pch);
360  return E_NOTIMPL;
361 }
362 
363 static HRESULT __thiscall ITextHostImpl_TxGetExtent(ITextHost *iface, LPSIZEL lpExtent)
364 {
366  TRACECALL("Call to TxGetExtent(%p, lpExtent=%p)\n", This, lpExtent);
367  return E_NOTIMPL;
368 }
369 
371 {
373  TRACECALL("Call to OnTxCharFormatChange(%p, pcf=%p)\n", This, pcf);
374  return E_NOTIMPL;
375 }
376 
378 {
380  TRACECALL("Call to OnTxParaFormatChange(%p, ppf=%p)\n", This, ppf);
381  return E_NOTIMPL;
382 }
383 
384 /* This must return S_OK for the native ITextServices object to
385  initialize. */
386 static HRESULT __thiscall ITextHostImpl_TxGetPropertyBits(ITextHost *iface, DWORD dwMask, DWORD *pdwBits)
387 {
389  TRACECALL("Call to TxGetPropertyBits(%p, dwMask=0x%08x, pdwBits=%p)\n",
390  This, dwMask, pdwBits);
391  *pdwBits = 0;
392  return S_OK;
393 }
394 
395 static HRESULT __thiscall ITextHostImpl_TxNotify(ITextHost *iface, DWORD iNotify, void *pv)
396 {
398  TRACECALL("Call to TxNotify(%p, iNotify=%d, pv=%p)\n", This, iNotify, pv);
399  return E_NOTIMPL;
400 }
401 
403 {
405  TRACECALL("Call to TxImmGetContext(%p)\n", This);
406  return 0;
407 }
408 
409 static void __thiscall ITextHostImpl_TxImmReleaseContext(ITextHost *iface, HIMC himc)
410 {
412  TRACECALL("Call to TxImmReleaseContext(%p, himc=%p)\n", This, himc);
413 }
414 
415 /* This function must set the variable pointed to by *lSelBarWidth.
416  Otherwise an uninitialized value will be used to calculate
417  positions and sizes even if E_NOTIMPL is returned. */
418 static HRESULT __thiscall ITextHostImpl_TxGetSelectionBarWidth(ITextHost *iface, LONG *lSelBarWidth)
419 {
421  TRACECALL("Call to TxGetSelectionBarWidth(%p, lSelBarWidth=%p)\n",
422  This, lSelBarWidth);
423  *lSelBarWidth = 0;
424  return E_NOTIMPL;
425 }
426 
427 #ifdef __REACTOS__
428 #undef __thiscall
429 #endif /* __REACTOS__ */
430 
431 static ITextHostVtbl itextHostVtbl = {
474 };
475 
476 static void *wrapperCodeMem = NULL;
477 
478 #include "pshpack1.h"
479 
480 /* Code structure for x86 byte code */
481 typedef struct
482 {
483  BYTE pop_eax; /* popl %eax */
484  BYTE push_ecx; /* pushl %ecx */
485  BYTE push_eax; /* pushl %eax */
486  BYTE jmp_func; /* jmp $func */
489 
490 typedef struct
491 {
492  BYTE pop_eax; /* popl %eax */
493  BYTE pop_ecx; /* popl %ecx */
494  BYTE push_eax; /* pushl %eax */
495  BYTE mov_vtable_eax[2]; /* movl (%ecx), %eax */
496  BYTE jmp_eax[2]; /* jmp *$vtablefunc_offset(%eax) */
499 
500 #include "poppack.h"
501 
502 static void setup_thiscall_wrappers(void)
503 {
504 #if defined(__i386__) && !defined(__MINGW32__)
505  void** pVtable;
506  void** pVtableEnd;
509 
511  (sizeof(ITextHostVtbl)/sizeof(void*) - 3)
512  * sizeof(THISCALL_TO_STDCALL_THUNK)
513  +(sizeof(ITextServicesVtbl)/sizeof(void*) - 3)
514  * sizeof(STDCALL_TO_THISCALL_THUNK),
517 
518  /* Wrap all ITextHostImpl methods with code to perform a thiscall to
519  * stdcall conversion. The thiscall calling convention places the This
520  * pointer in ecx on the x86 platform, and the stdcall calling convention
521  * pushes the This pointer on the stack as the first argument.
522  *
523  * The byte code does the conversion then jumps to the real function.
524  *
525  * Each wrapper needs to be modified so that the function to jump to is
526  * modified in the byte code. */
527 
528  /* Skip QueryInterface, AddRef, and Release native actually
529  * defined them with the stdcall calling convention. */
530  pVtable = (void**)&itextHostVtbl + 3;
531  pVtableEnd = (void**)(&itextHostVtbl + 1);
532  while (pVtable != pVtableEnd) {
533  /* write byte code to executable memory */
534  thunk->pop_eax = 0x58; /* popl %eax */
535  thunk->push_ecx = 0x51; /* pushl %ecx */
536  thunk->push_eax = 0x50; /* pushl %eax */
537  thunk->jmp_func = 0xe9; /* jmp $func */
538  /* The address needs to be relative to the end of the jump instructions. */
539  thunk->func = (char*)*pVtable - (char*)(&thunk->func + 1);
540  *pVtable = thunk;
541  pVtable++;
542  thunk++;
543  }
544 
545  /* Setup an ITextServices standard call vtable that will call the
546  * native thiscall vtable when the methods are called. */
547 
548  /* QueryInterface, AddRef, and Release should be called directly on the
549  * real vtable since they use the stdcall calling convention. */
550  thunk2 = (STDCALL_TO_THISCALL_THUNK *)thunk;
551  pVtable = (void**)&itextServicesStdcallVtbl + 3;
552  pVtableEnd = (void**)(&itextServicesStdcallVtbl + 1);
553  while (pVtable != pVtableEnd) {
554  /* write byte code to executable memory */
555  thunk2->pop_eax = 0x58; /* popl %eax */
556  thunk2->pop_ecx = 0x59; /* popl %ecx */
557  thunk2->push_eax = 0x50; /* pushl %eax */
558  thunk2->mov_vtable_eax[0] = 0x8b; /* movl (%ecx), %eax */
559  thunk2->mov_vtable_eax[1] = 0x01;
560  thunk2->jmp_eax[0] = 0xff; /* jmp *$vtablefunc_offset(%eax) */
561  thunk2->jmp_eax[1] = 0xa0;
562  thunk2->vtablefunc_offset = (char*)pVtable - (char*)&itextServicesStdcallVtbl;
563  *pVtable = thunk2;
564  pVtable++;
565  thunk2++;
566  }
567 #endif /* __i386__ */
568 }
569 
570 static void hf_to_cf(HFONT hf, CHARFORMAT2W *cf)
571 {
572  LOGFONTW lf;
573 
574  GetObjectW(hf, sizeof(lf), &lf);
575  lstrcpyW(cf->szFaceName, lf.lfFaceName);
576  cf->yHeight = MulDiv(abs(lf.lfHeight), 1440, GetDeviceCaps(GetDC(NULL), LOGPIXELSY));
577  if (lf.lfWeight > FW_NORMAL) cf->dwEffects |= CFE_BOLD;
578  if (lf.lfItalic) cf->dwEffects |= CFE_ITALIC;
579  if (lf.lfUnderline) cf->dwEffects |= CFE_UNDERLINE;
580  if (lf.lfStrikeOut) cf->dwEffects |= CFE_SUBSCRIPT;
581  cf->bPitchAndFamily = lf.lfPitchAndFamily;
582  cf->bCharSet = lf.lfCharSet;
583 }
584 
585 /*************************************************************************/
586 /* Conformance test functions. */
587 
588 /* Initialize the test texthost structure */
589 static BOOL init_texthost(ITextServices **txtserv, ITextHost **ret)
590 {
591  ITextHostTestImpl *dummyTextHost;
592  IUnknown *init;
593  HRESULT result;
594  HFONT hf;
595 
596  dummyTextHost = CoTaskMemAlloc(sizeof(*dummyTextHost));
597  if (dummyTextHost == NULL) {
598  win_skip("Insufficient memory to create ITextHost interface\n");
599  return FALSE;
600  }
601  dummyTextHost->ITextHost_iface.lpVtbl = &itextHostVtbl;
602  dummyTextHost->refCount = 1;
603  memset(&dummyTextHost->char_format, 0, sizeof(dummyTextHost->char_format));
604  dummyTextHost->char_format.cbSize = sizeof(dummyTextHost->char_format);
605  dummyTextHost->char_format.dwMask = CFM_ALL2;
607  hf_to_cf(hf, &dummyTextHost->char_format);
608 
609  /* MSDN states that an IUnknown object is returned by
610  CreateTextServices which is then queried to obtain a
611  ITextServices object. */
612  result = pCreateTextServices(NULL, &dummyTextHost->ITextHost_iface, &init);
613  ok(result == S_OK, "Did not return S_OK when created (result = %x)\n", result);
614  if (result != S_OK) {
615  CoTaskMemFree(dummyTextHost);
616  win_skip("CreateTextServices failed.\n");
617  return FALSE;
618  }
619 
620  result = IUnknown_QueryInterface(init, pIID_ITextServices, (void**)txtserv);
621  ok((result == S_OK) && (*txtserv != NULL), "Querying interface failed (result = %x, txtserv = %p)\n", result, *txtserv);
622  IUnknown_Release(init);
623  if (!((result == S_OK) && (*txtserv != NULL))) {
624  CoTaskMemFree(dummyTextHost);
625  win_skip("Could not retrieve ITextServices interface\n");
626  return FALSE;
627  }
628 
629  *ret = &dummyTextHost->ITextHost_iface;
630  return TRUE;
631 }
632 
633 static void test_TxGetText(void)
634 {
635  ITextServices *txtserv;
636  ITextHost *host;
637  HRESULT hres;
638  BSTR rettext;
639 
640  if (!init_texthost(&txtserv, &host))
641  return;
642 
643  hres = ITextServices_TxGetText(txtserv, &rettext);
644  ok(hres == S_OK, "ITextServices_TxGetText failed (result = %x)\n", hres);
645  SysFreeString(rettext);
646 
647  ITextServices_Release(txtserv);
648  ITextHost_Release(host);
649 }
650 
651 static void test_TxSetText(void)
652 {
653  ITextServices *txtserv;
654  ITextHost *host;
655  HRESULT hres;
656  BSTR rettext;
657  WCHAR settext[] = {'T','e','s','t',0};
658 
659  if (!init_texthost(&txtserv, &host))
660  return;
661 
662  hres = ITextServices_TxSetText(txtserv, settext);
663  ok(hres == S_OK, "ITextServices_TxSetText failed (result = %x)\n", hres);
664 
665  hres = ITextServices_TxGetText(txtserv, &rettext);
666  ok(hres == S_OK, "ITextServices_TxGetText failed (result = %x)\n", hres);
667 
668  ok(SysStringLen(rettext) == 4,
669  "String returned of wrong length (expected 4, got %d)\n", SysStringLen(rettext));
670  ok(memcmp(rettext,settext,SysStringByteLen(rettext)) == 0,
671  "String returned differs\n");
672 
673  SysFreeString(rettext);
674 
675  /* Null-pointer should behave the same as empty-string */
676 
677  hres = ITextServices_TxSetText(txtserv, 0);
678  ok(hres == S_OK, "ITextServices_TxSetText failed (result = %x)\n", hres);
679 
680  hres = ITextServices_TxGetText(txtserv, &rettext);
681  ok(hres == S_OK, "ITextServices_TxGetText failed (result = %x)\n", hres);
682  ok(SysStringLen(rettext) == 0,
683  "String returned of wrong length (expected 0, got %d)\n", SysStringLen(rettext));
684 
685  SysFreeString(rettext);
686  ITextServices_Release(txtserv);
687  ITextHost_Release(host);
688 }
689 
690 #define CHECK_TXGETNATURALSIZE(res,width,height,hdc,rect,string) \
691  _check_txgetnaturalsize(res, width, height, hdc, rect, string, __LINE__)
693 {
695  LONG expected_width, expected_height;
696 
698  expected_width = expected_rect.right - expected_rect.left;
699  expected_height = expected_rect.bottom - expected_rect.top;
700  ok_(__FILE__,line)(res == S_OK, "ITextServices_TxGetNaturalSize failed: 0x%08x.\n", res);
701  ok_(__FILE__,line)(width >= expected_width && width <= expected_width + 1,
702  "got wrong width: %d, expected: %d {+1}.\n", width, expected_width);
703  ok_(__FILE__,line)(height == expected_height, "got wrong height: %d, expected: %d.\n",
704  height, expected_height);
705 }
706 
707 static void test_TxGetNaturalSize(void)
708 {
709  ITextServices *txtserv;
710  ITextHost *host;
711  HRESULT result;
712  SIZEL extent;
713  static const WCHAR test_text[] = {'T','e','s','t','S','o','m','e','T','e','x','t',0};
714  LONG width, height;
715  HDC hdcDraw;
716  HWND hwnd;
717  RECT rect;
719  LRESULT lresult;
720  HFONT hf;
721 
722  if (!init_texthost(&txtserv, &host))
723  return;
724 
725  hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP | WS_VISIBLE,
726  0, 0, 100, 100, 0, 0, 0, NULL);
727  hdcDraw = GetDC(hwnd);
728  SetMapMode(hdcDraw,MM_TEXT);
730 
731  memset(&cf, 0, sizeof(cf));
732  cf.cbSize = sizeof(cf);
733  cf.dwMask = CFM_ALL2;
735  hf_to_cf(hf, &cf);
737  ok(result == S_OK, "ITextServices_TxSendMessage failed: 0x%08x.\n", result);
738  SelectObject(hdcDraw, hf);
739 
740  result = ITextServices_TxSetText(txtserv, test_text);
741  ok(result == S_OK, "ITextServices_TxSetText failed: 0x%08x.\n", result);
742 
743  extent.cx = -1; extent.cy = -1;
744  width = rect.right - rect.left;
745  height = 0;
746  result = ITextServices_TxGetNaturalSize(txtserv, DVASPECT_CONTENT, hdcDraw, NULL, NULL,
748  todo_wine CHECK_TXGETNATURALSIZE(result, width, height, hdcDraw, rect, test_text);
749 
750  ReleaseDC(hwnd, hdcDraw);
752  ITextServices_Release(txtserv);
753  ITextHost_Release(host);
754 }
755 
756 static void test_TxDraw(void)
757 {
758  ITextServices *txtserv;
759  ITextHost *host;
760  HDC tmphdc = GetDC(NULL);
761  DWORD dwAspect = DVASPECT_CONTENT;
762  HDC hicTargetDev = NULL; /* Means "default" device */
763  DVTARGETDEVICE *ptd = NULL;
764  void *pvAspect = NULL;
765  HRESULT result;
766  RECTL client = {0,0,100,100};
767 
768 
769  if (!init_texthost(&txtserv, &host))
770  return;
771 
772  todo_wine {
773  result = ITextServices_TxDraw(txtserv, dwAspect, 0, pvAspect, ptd,
774  tmphdc, hicTargetDev, &client, NULL,
775  NULL, NULL, 0, 0);
776  ok(result == S_OK, "TxDraw failed (result = %x)\n", result);
777  }
778 
779  ITextServices_Release(txtserv);
780  ITextHost_Release(host);
781 }
782 
783 DEFINE_GUID(expected_iid_itextservices, 0x8d33f740, 0xcf58, 0x11ce, 0xa8, 0x9d, 0x00, 0xaa, 0x00, 0x6c, 0xad, 0xc5);
784 DEFINE_GUID(expected_iid_itexthost, 0x13e670f4,0x1a5a,0x11cf,0xab,0xeb,0x00,0xaa,0x00,0xb6,0x5e,0xa1);
785 DEFINE_GUID(expected_iid_itexthost2, 0x13e670f5,0x1a5a,0x11cf,0xab,0xeb,0x00,0xaa,0x00,0xb6,0x5e,0xa1);
786 
787 static void test_IIDs(void)
788 {
789  ok(IsEqualIID(pIID_ITextServices, &expected_iid_itextservices),
790  "unexpected value for IID_ITextServices: %s\n", wine_dbgstr_guid(pIID_ITextServices));
791  ok(IsEqualIID(pIID_ITextHost, &expected_iid_itexthost),
792  "unexpected value for IID_ITextHost: %s\n", wine_dbgstr_guid(pIID_ITextHost));
793  ok(IsEqualIID(pIID_ITextHost2, &expected_iid_itexthost2),
794  "unexpected value for IID_ITextHost2: %s\n", wine_dbgstr_guid(pIID_ITextHost2));
795 }
796 
797 /* Outer IUnknown for COM aggregation tests */
798 struct unk_impl {
800  LONG ref;
802 };
803 
804 static inline struct unk_impl *impl_from_IUnknown(IUnknown *iface)
805 {
806  return CONTAINING_RECORD(iface, struct unk_impl, IUnknown_iface);
807 }
808 
810 {
811  struct unk_impl *This = impl_from_IUnknown(iface);
812 
813  return IUnknown_QueryInterface(This->inner_unk, riid, ppv);
814 }
815 
817 {
818  struct unk_impl *This = impl_from_IUnknown(iface);
819 
820  return InterlockedIncrement(&This->ref);
821 }
822 
824 {
825  struct unk_impl *This = impl_from_IUnknown(iface);
826 
827  return InterlockedDecrement(&This->ref);
828 }
829 
830 static const IUnknownVtbl unk_vtbl =
831 {
833  unk_AddRef,
835 };
836 
837 static void test_COM(void)
838 {
839  struct unk_impl unk_obj = {{&unk_vtbl}, 19, NULL};
840  struct ITextHostTestImpl texthost = {{&itextHostVtbl}, 1};
841  ITextServices *textsrv;
842  ULONG refcount;
843  HRESULT hr;
844 
845  /* COM aggregation */
847  &unk_obj.inner_unk);
848  ok(hr == S_OK, "CreateTextServices failed: %08x\n", hr);
849  hr = IUnknown_QueryInterface(unk_obj.inner_unk, pIID_ITextServices, (void**)&textsrv);
850  ok(hr == S_OK, "QueryInterface for IID_ITextServices failed: %08x\n", hr);
851  refcount = ITextServices_AddRef(textsrv);
852  ok(refcount == unk_obj.ref, "CreateTextServices just pretends to support COM aggregation\n");
853  refcount = ITextServices_Release(textsrv);
854  ok(refcount == unk_obj.ref, "CreateTextServices just pretends to support COM aggregation\n");
855  refcount = ITextServices_Release(textsrv);
856  ok(refcount == 19, "Refcount should be back at 19 but is %u\n", refcount);
857 
858  IUnknown_Release(unk_obj.inner_unk);
859 }
860 
862 {
863  IUnknown_AddRef(iface);
864  return IUnknown_Release(iface);
865 }
866 
867 static void test_QueryInterface(void)
868 {
869  ITextServices *txtserv;
870  ITextHost *host;
871  HRESULT hres;
872  IRichEditOle *reole, *txtsrv_reole;
873  ITextDocument *txtdoc, *txtsrv_txtdoc;
874  ITextDocument2Old *txtdoc2old, *txtsrv_txtdoc2old;
875  ULONG refcount;
876 
877  if(!init_texthost(&txtserv, &host))
878  return;
879 
880  refcount = get_refcount((IUnknown *)txtserv);
881  ok(refcount == 1, "got wrong ref count: %d\n", refcount);
882 
883  /* IID_IRichEditOle */
884  hres = ITextServices_QueryInterface(txtserv, &IID_IRichEditOle, (void **)&txtsrv_reole);
885  ok(hres == S_OK, "ITextServices_QueryInterface: 0x%08x\n", hres);
886  refcount = get_refcount((IUnknown *)txtserv);
887  ok(refcount == 2, "got wrong ref count: %d\n", refcount);
888  refcount = get_refcount((IUnknown *)txtsrv_reole);
889  ok(refcount == 2, "got wrong ref count: %d\n", refcount);
890 
891  hres = IRichEditOle_QueryInterface(txtsrv_reole, &IID_ITextDocument, (void **)&txtdoc);
892  ok(hres == S_OK, "IRichEditOle_QueryInterface: 0x%08x\n", hres);
893  refcount = get_refcount((IUnknown *)txtserv);
894  ok(refcount == 3, "got wrong ref count: %d\n", refcount);
895  refcount = get_refcount((IUnknown *)txtsrv_reole);
896  ok(refcount == 3, "got wrong ref count: %d\n", refcount);
897 
898  ITextDocument_Release(txtdoc);
899  refcount = get_refcount((IUnknown *)txtserv);
900  ok(refcount == 2, "got wrong ref count: %d\n", refcount);
901 
902  hres = IRichEditOle_QueryInterface(txtsrv_reole, &IID_ITextDocument2Old, (void **)&txtdoc2old);
903  ok(hres == S_OK, "IRichEditOle_QueryInterface: 0x%08x\n", hres);
904  refcount = get_refcount((IUnknown *)txtserv);
905  ok(refcount == 3, "got wrong ref count: %d\n", refcount);
906  refcount = get_refcount((IUnknown *)txtsrv_reole);
907  ok(refcount == 3, "got wrong ref count: %d\n", refcount);
908 
909  ITextDocument2Old_Release(txtdoc2old);
910  refcount = get_refcount((IUnknown *)txtserv);
911  ok(refcount == 2, "got wrong ref count: %d\n", refcount);
912  IRichEditOle_Release(txtsrv_reole);
913  refcount = get_refcount((IUnknown *)txtserv);
914  ok(refcount == 1, "got wrong ref count: %d\n", refcount);
915 
916  /* IID_ITextDocument */
917  hres = ITextServices_QueryInterface(txtserv, &IID_ITextDocument, (void **)&txtsrv_txtdoc);
918  ok(hres == S_OK, "ITextServices_QueryInterface: 0x%08x\n", hres);
919  refcount = get_refcount((IUnknown *)txtserv);
920  ok(refcount == 2, "got wrong ref count: %d\n", refcount);
921  refcount = get_refcount((IUnknown *)txtsrv_txtdoc);
922  ok(refcount == 2, "got wrong ref count: %d\n", refcount);
923 
924  hres = ITextDocument_QueryInterface(txtsrv_txtdoc, &IID_IRichEditOle, (void **)&reole);
925  ok(hres == S_OK, "ITextDocument_QueryInterface: 0x%08x\n", hres);
926  refcount = get_refcount((IUnknown *)txtserv);
927  ok(refcount == 3, "got wrong ref count: %d\n", refcount);
928  refcount = get_refcount((IUnknown *)txtsrv_txtdoc);
929  ok(refcount == 3, "got wrong ref count: %d\n", refcount);
930 
931  IRichEditOle_Release(reole);
932  refcount = get_refcount((IUnknown *)txtserv);
933  ok(refcount == 2, "got wrong ref count: %d\n", refcount);
934  ITextDocument_Release(txtsrv_txtdoc);
935  refcount = get_refcount((IUnknown *)txtserv);
936  ok(refcount == 1, "got wrong ref count: %d\n", refcount);
937 
938  /* ITextDocument2Old */
939  hres = ITextServices_QueryInterface(txtserv, &IID_ITextDocument2Old, (void **)&txtsrv_txtdoc2old);
940  ok(hres == S_OK, "ITextServices_QueryInterface: 0x%08x\n", hres);
941  refcount = get_refcount((IUnknown *)txtserv);
942  ok(refcount == 2, "got wrong ref count: %d\n", refcount);
943  refcount = get_refcount((IUnknown *)txtsrv_txtdoc2old);
944  ok(refcount == 2, "got wrong ref count: %d\n", refcount);
945 
946  hres = ITextDocument2Old_QueryInterface(txtsrv_txtdoc2old, &IID_IRichEditOle, (void **)&reole);
947  ok(hres == S_OK, "ITextDocument2Old_QueryInterface: 0x%08x\n", hres);
948  refcount = get_refcount((IUnknown *)txtserv);
949  ok(refcount == 3, "got wrong ref count: %d\n", refcount);
950  refcount = get_refcount((IUnknown *)txtsrv_txtdoc2old);
951  ok(refcount == 3, "got wrong ref count: %d\n", refcount);
952 
953  IRichEditOle_Release(reole);
954  refcount = get_refcount((IUnknown *)txtserv);
955  ok(refcount == 2, "got wrong ref count: %d\n", refcount);
956  ITextDocument2Old_Release(txtsrv_txtdoc2old);
957  refcount = get_refcount((IUnknown *)txtserv);
958  ok(refcount == 1, "got wrong ref count: %d\n", refcount);
959 
960  ITextServices_Release(txtserv);
961  ITextHost_Release(host);
962 }
963 
964 static void test_default_format(void)
965 {
966  ITextServices *txtserv;
967  ITextHost *host;
968  HRESULT result;
969  LRESULT lresult;
970  CHARFORMAT2W cf2;
971  const CHARFORMATW *host_cf;
972  DWORD expected_effects;
973 
974  if (!init_texthost(&txtserv, &host))
975  return;
976 
977  cf2.cbSize = sizeof(CHARFORMAT2W);
979  ok(result == S_OK, "ITextServices_TxSendMessage failed: 0x%08x.\n", result);
980 
982  ok(!lstrcmpW(host_cf->szFaceName, cf2.szFaceName), "got wrong font name: %s.\n", wine_dbgstr_w(cf2.szFaceName));
983  ok(cf2.yHeight == host_cf->yHeight, "got wrong yHeight: %d, expected %d.\n", cf2.yHeight, host_cf->yHeight);
984  expected_effects = (cf2.dwEffects & ~(CFE_AUTOCOLOR | CFE_AUTOBACKCOLOR));
985  ok(host_cf->dwEffects == expected_effects, "got wrong dwEffects: %x, expected %x.\n", cf2.dwEffects, expected_effects);
986  ok(cf2.bPitchAndFamily == host_cf->bPitchAndFamily, "got wrong bPitchAndFamily: %x, expected %x.\n",
987  cf2.bPitchAndFamily, host_cf->bPitchAndFamily);
988  ok(cf2.bCharSet == host_cf->bCharSet, "got wrong bCharSet: %x, expected %x.\n", cf2.bCharSet, host_cf->bCharSet);
989 
990  ITextServices_Release(txtserv);
991  ITextHost_Release(host);
992 }
993 
994 static void test_TxGetScroll(void)
995 {
996  ITextServices *txtserv;
997  ITextHost *host;
998  HRESULT ret;
999 
1000  if (!init_texthost(&txtserv, &host))
1001  return;
1002 
1004  ok(ret == S_OK, "ITextSerHices_GetVScroll failed: 0x%08x.\n", ret);
1005 
1007  ok(ret == S_OK, "ITextServices_GetVScroll failed: 0x%08x.\n", ret);
1008 
1009  ITextServices_Release(txtserv);
1010  ITextHost_Release(host);
1011 }
1012 
1013 START_TEST( txtsrv )
1014 {
1015  ITextServices *txtserv;
1016  ITextHost *host;
1017 
1019 
1020  /* Must explicitly LoadLibrary(). The test has no references to functions in
1021  * RICHED20.DLL, so the linker doesn't actually link to it. */
1022  hmoduleRichEdit = LoadLibraryA("riched20.dll");
1023  ok(hmoduleRichEdit != NULL, "error: %d\n", (int) GetLastError());
1024 
1025  pIID_ITextServices = (IID*)GetProcAddress(hmoduleRichEdit, "IID_ITextServices");
1026  pIID_ITextHost = (IID*)GetProcAddress(hmoduleRichEdit, "IID_ITextHost");
1027  pIID_ITextHost2 = (IID*)GetProcAddress(hmoduleRichEdit, "IID_ITextHost2");
1028  pCreateTextServices = (void*)GetProcAddress(hmoduleRichEdit, "CreateTextServices");
1029 
1030  test_IIDs();
1031  test_COM();
1032 
1033  if (init_texthost(&txtserv, &host))
1034  {
1035  ITextServices_Release(txtserv);
1036  ITextHost_Release(host);
1037 
1038  test_TxGetText();
1039  test_TxSetText();
1041  test_TxDraw();
1044  test_TxGetScroll();
1045  }
1047 }
HGDIOBJ WINAPI GetStockObject(_In_ int)
static IClassFactory * cf
static void test_TxGetText(void)
Definition: txtsrv.c:633
#define CFE_AUTOCOLOR
Definition: richedit.h:414
static void hf_to_cf(HFONT hf, CHARFORMAT2W *cf)
Definition: txtsrv.c:570
#define abs(i)
Definition: fconv.c:206
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
enum _TXTBACKSTYLE TXTBACKSTYLE
#define ITextServices_TxGetHScroll(This, a, b, c, d, e)
Definition: txtsrv.c:60
#define ITextServices_TxGetVScroll(This, a, b, c, d, e)
Definition: txtsrv.c:61
static HRESULT __thiscall ITextHostImpl_TxGetScrollBars(ITextHost *iface, DWORD *pdwScrollBar)
Definition: txtsrv.c:341
GLint GLint GLsizei width
Definition: gl.h:1546
static void __thiscall ITextHostImpl_TxKillTimer(ITextHost *iface, UINT idTimer)
Definition: txtsrv.c:229
static HRESULT __thiscall ITextHostImpl_TxGetPasswordChar(ITextHost *iface, WCHAR *pch)
Definition: txtsrv.c:349
#define REFIID
Definition: guiddef.h:118
BYTE lfPitchAndFamily
Definition: dimm.idl:71
#define E_NOINTERFACE
Definition: winerror.h:2364
static void __thiscall ITextHostImpl_TxSetCursor(ITextHost *iface, HCURSOR hcur, BOOL fText)
Definition: txtsrv.c:256
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:442
DWORD dwEffects
Definition: richedit.h:270
HRESULT hr
Definition: shlfolder.c:183
GLuint64EXT * result
Definition: glext.h:11304
#define CFE_UNDERLINE
Definition: richedit.h:408
static void test_TxGetScroll(void)
Definition: txtsrv.c:994
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
LONG yHeight
Definition: richedit.h:271
static HDC __thiscall ITextHostImpl_TxGetDC(ITextHost *iface)
Definition: txtsrv.c:137
Definition: cproxy.c:247
HDC WINAPI GetDC(_In_opt_ HWND)
IUnknown IUnknown_iface
Definition: api.c:545
#define TRUE
Definition: types.h:120
REFIID riid
Definition: precomp.h:44
WCHAR szFaceName[LF_FACESIZE]
Definition: richedit.h:276
char * wine_dbgstr_w(const wchar_t *wstr)
Definition: atltest.h:87
int WINAPI lstrcmpW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:170
GLint dy
Definition: linetemp.h:97
static void test_COM(void)
Definition: txtsrv.c:837
static BOOL __thiscall ITextHostImpl_TxShowCaret(ITextHost *iface, BOOL fShow)
Definition: txtsrv.c:206
static void test_TxGetNaturalSize(void)
Definition: txtsrv.c:707
#define DT_WORDBREAK
Definition: winuser.h:544
LONG lfHeight
Definition: dimm.idl:59
char * host
Definition: whois.c:55
BYTE lfCharSet
Definition: dimm.idl:67
static struct unk_impl * impl_from_IUnknown(IUnknown *iface)
Definition: txtsrv.c:804
static HDC
Definition: imagelist.c:92
#define CFE_SUBSCRIPT
Definition: richedit.h:412
static HRESULT __thiscall ITextHostImpl_TxActivate(ITextHost *iface, LONG *plOldState)
Definition: txtsrv.c:277
REFIID LPVOID * ppv
Definition: atlbase.h:39
LONG top
Definition: windef.h:307
CHARFORMAT2W char_format
Definition: txtsrv.c:88
static HRESULT __thiscall ITextHostImpl_TxGetAcceleratorPos(ITextHost *iface, LONG *pch)
Definition: txtsrv.c:356
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
const char * wine_dbgstr_guid(const GUID *guid)
static ULONG WINAPI unk_AddRef(IUnknown *iface)
Definition: txtsrv.c:816
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1040
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
LONG ref
Definition: api.c:546
UINT WINAPI SysStringByteLen(BSTR str)
Definition: oleaut.c:215
OLECHAR * BSTR
Definition: compat.h:2152
static HRESULT __thiscall ITextHostImpl_TxGetPropertyBits(ITextHost *iface, DWORD dwMask, DWORD *pdwBits)
Definition: txtsrv.c:386
LONG left
Definition: windef.h:306
HICON HCURSOR
Definition: windef.h:299
INT WINAPI MulDiv(INT nNumber, INT nNumerator, INT nDenominator)
Definition: muldiv.c:25
LONG right
Definition: windef.h:308
#define MEM_COMMIT
Definition: nt_native.h:1313
BOOL WINAPI DestroyWindow(_In_ HWND)
struct ITextHostTestImpl ITextHostTestImpl
int32_t INT
Definition: typedefs.h:58
static HRESULT __thiscall ITextHostImpl_TxGetParaFormat(ITextHost *iface, const PARAFORMAT **ppPF)
Definition: txtsrv.c:313
& rect
Definition: startmenu.cpp:1413
static int init
Definition: wintirpc.c:33
#define pch(ap)
Definition: match.c:418
static BOOL __thiscall ITextHostImpl_TxClientToScreen(ITextHost *iface, LPPOINT lppt)
Definition: txtsrv.c:270
#define CFE_BOLD
Definition: richedit.h:406
static HRESULT __thiscall ITextHostImpl_TxGetMaxLength(ITextHost *iface, DWORD *pLength)
Definition: txtsrv.c:334
static HRESULT __thiscall ITextHostImpl_TxGetCharFormat(ITextHost *iface, const CHARFORMATW **ppCF)
Definition: txtsrv.c:305
LPVOID NTAPI VirtualAlloc(IN LPVOID lpAddress, IN SIZE_T dwSize, IN DWORD flAllocationType, IN DWORD flProtect)
Definition: virtmem.c:74
#define FALSE
Definition: types.h:117
#define DT_LEFT
Definition: winuser.h:534
#define DT_CALCRECT
Definition: winuser.h:526
static IID * pIID_ITextHost2
Definition: txtsrv.c:44
static void __thiscall ITextHostImpl_TxSetCapture(ITextHost *iface, BOOL fCapture)
Definition: txtsrv.c:244
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
int WINAPI SetMapMode(_In_ HDC, _In_ int)
static INT __thiscall ITextHostImpl_TxReleaseDC(ITextHost *iface, HDC hdc)
Definition: txtsrv.c:144
static HRESULT __thiscall ITextHostImpl_TxGetExtent(ITextHost *iface, LPSIZEL lpExtent)
Definition: txtsrv.c:363
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
static BOOL __thiscall ITextHostImpl_TxScreenToClient(ITextHost *iface, LPPOINT lppt)
Definition: txtsrv.c:263
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
static HMODULE hmoduleRichEdit
Definition: txtsrv.c:41
static void test_TxDraw(void)
Definition: txtsrv.c:756
static HRESULT __thiscall ITextHostImpl_TxGetSelectionBarWidth(ITextHost *iface, LONG *lSelBarWidth)
Definition: txtsrv.c:418
#define EM_SETCHARFORMAT
Definition: richedit.h:101
START_TEST(txtsrv)
Definition: txtsrv.c:1013
static HRESULT __thiscall ITextHostImpl_TxGetViewInset(ITextHost *iface, LPRECT prc)
Definition: txtsrv.c:298
LONG_PTR LPARAM
Definition: windef.h:208
Definition: parser.c:48
static ITextHostTestImpl * impl_from_ITextHost(ITextHost *iface)
Definition: txtsrv.c:91
#define ITextServices_TxGetText(This, a)
Definition: txtsrv.c:68
static PCreateTextServices pCreateTextServices
Definition: txtsrv.c:45
BYTE bCharSet
Definition: richedit.h:274
DWORD HIMC
Definition: dimm.idl:75
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
static ULONG get_refcount(IUnknown *iface)
Definition: txtsrv.c:861
static ULONG WINAPI unk_Release(IUnknown *iface)
Definition: txtsrv.c:823
#define CFE_AUTOBACKCOLOR
Definition: richedit.h:425
static ULONG WINAPI ITextHostImpl_AddRef(ITextHost *iface)
Definition: txtsrv.c:111
BYTE bPitchAndFamily
Definition: richedit.h:275
static void test_default_format(void)
Definition: txtsrv.c:964
HBITMAP hbmp
static IID * pIID_ITextHost
Definition: txtsrv.c:43
static void test_QueryInterface(void)
Definition: txtsrv.c:867
static void * wrapperCodeMem
Definition: txtsrv.c:476
HRESULT hres
Definition: protocol.c:465
__wchar_t WCHAR
Definition: xmlstorage.h:180
static HRESULT __thiscall ITextHostImpl_TxGetClientRect(ITextHost *iface, LPRECT prc)
Definition: txtsrv.c:291
LONG HRESULT
Definition: typedefs.h:79
DWORD COLORREF
Definition: windef.h:300
#define CHECK_TXGETNATURALSIZE(res, width, height, hdc, rect, string)
Definition: txtsrv.c:690
const GUID IID_IUnknown
static ITextHostVtbl itextHostVtbl
Definition: txtsrv.c:431
#define WINAPI
Definition: msvc.h:6
static RECT expected_rect
Definition: win.c:5821
static FILE * client
Definition: client.c:41
unsigned long DWORD
Definition: ntddk_ex.h:95
DEFINE_GUID(expected_iid_itextservices, 0x8d33f740, 0xcf58, 0x11ce, 0xa8, 0x9d, 0x00, 0xaa, 0x00, 0x6c, 0xad, 0xc5)
static HRESULT __thiscall ITextHostImpl_OnTxParaFormatChange(ITextHost *iface, const PARAFORMAT *ppf)
Definition: txtsrv.c:377
Definition: api.c:544
#define DEFAULT_GUI_FONT
Definition: wingdi.h:909
static void __thiscall ITextHostImpl_TxViewChange(ITextHost *iface, BOOL fUpdate)
Definition: txtsrv.c:191
int ret
static BOOL __thiscall ITextHostImpl_TxCreateCaret(ITextHost *iface, HBITMAP hbmp, INT xWidth, INT yHeight)
Definition: txtsrv.c:198
#define todo_wine
Definition: test.h:164
#define InterlockedDecrement
Definition: armddk.h:52
HDC hdc
Definition: main.c:9
#define CFE_ITALIC
Definition: richedit.h:407
static void __thiscall ITextHostImpl_TxImmReleaseContext(ITextHost *iface, HIMC himc)
Definition: txtsrv.c:409
static IID * pIID_ITextServices
Definition: txtsrv.c:42
static void test_TxSetText(void)
Definition: txtsrv.c:651
static void __thiscall ITextHostImpl_TxInvalidateRect(ITextHost *iface, LPCRECT prc, BOOL fMode)
Definition: txtsrv.c:184
int WINAPI GetDeviceCaps(_In_opt_ HDC, _In_ int)
REFIID LPVOID * ppvObject
Definition: precomp.h:44
UINT WINAPI SysStringLen(BSTR str)
Definition: oleaut.c:196
#define ITextServices_TxGetNaturalSize(This, a, b, c, d, e, f, g, h)
Definition: txtsrv.c:72
static const IUnknownVtbl unk_vtbl
Definition: txtsrv.c:830
#define ITextServices_TxSendMessage(This, a, b, c, d)
Definition: txtsrv.c:58
unsigned char BYTE
Definition: xxhash.c:193
HRESULT(WINAPI * PCreateTextServices)(IUnknown *, ITextHost *, IUnknown **)
Definition: textserv.h:366
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
#define ITextServices_TxDraw(This, a, b, c, d, e, f, g, h, i, j, k, l)
Definition: txtsrv.c:59
static BOOL __thiscall ITextHostImpl_TxSetCaretPos(ITextHost *iface, INT x, INT y)
Definition: txtsrv.c:214
#define DT_NOCLIP
Definition: winuser.h:536
int WINAPI GetObjectW(_In_ HANDLE h, _In_ int c, _Out_writes_bytes_opt_(c) LPVOID pv)
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define S_OK
Definition: intsafe.h:52
static HRESULT __thiscall ITextHostImpl_TxNotify(ITextHost *iface, DWORD iNotify, void *pv)
Definition: txtsrv.c:395
static HRESULT __thiscall ITextHostImpl_OnTxCharFormatChange(ITextHost *iface, const CHARFORMATW *pcf)
Definition: txtsrv.c:370
#define InterlockedIncrement
Definition: armddk.h:53
#define ITextServices_TxSetText(This, a)
Definition: txtsrv.c:69
#define lstrcpyW
Definition: compat.h:608
#define EM_GETCHARFORMAT
Definition: richedit.h:91
static BOOL init_texthost(ITextServices **txtserv, ITextHost **ret)
Definition: txtsrv.c:589
static BOOL __thiscall ITextHostImpl_TxSetTimer(ITextHost *iface, UINT idTimer, UINT uTimeout)
Definition: txtsrv.c:221
BYTE lfStrikeOut
Definition: dimm.idl:66
static void __thiscall ITextHostImpl_TxSetFocus(ITextHost *iface)
Definition: txtsrv.c:250
static HRESULT WINAPI unk_QueryInterface(IUnknown *iface, REFIID riid, void **ppv)
Definition: txtsrv.c:809
#define ok(value,...)
Definition: atltest.h:57
#define E_NOTIMPL
Definition: ddrawi.h:99
BYTE lfItalic
Definition: dimm.idl:64
DWORD dwMask
Definition: richedit.h:306
void WINAPI DECLSPEC_HOTPATCH SysFreeString(BSTR str)
Definition: oleaut.c:271
#define WS_POPUP
Definition: pedump.c:616
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
static HIMC __thiscall ITextHostImpl_TxImmGetContext(ITextHost *iface)
Definition: txtsrv.c:402
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
#define SCF_DEFAULT
Definition: richedit.h:234
GLint dx
Definition: linetemp.h:97
static void setup_thiscall_wrappers(void)
Definition: txtsrv.c:502
ITextHost ITextHost_iface
Definition: txtsrv.c:86
#define FW_NORMAL
Definition: wingdi.h:373
static BOOL __thiscall ITextHostImpl_TxSetScrollRange(ITextHost *iface, INT fnBar, LONG nMinPos, INT nMaxPos, BOOL fRedraw)
Definition: txtsrv.c:167
#define TRACECALL
Definition: txtsrv.c:79
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
static COLORREF __thiscall ITextHostImpl_TxGetSysColor(ITextHost *iface, int nIndex)
Definition: txtsrv.c:320
#define MEM_RELEASE
Definition: nt_native.h:1316
#define MM_TEXT
Definition: wingdi.h:873
#define __thiscall
Definition: cpp.c:43
static HRESULT __thiscall ITextHostImpl_TxDeactivate(ITextHost *iface, LONG lNewState)
Definition: txtsrv.c:284
GLuint res
Definition: glext.h:9613
HWND WINAPI CreateWindowExA(_In_ DWORD dwExStyle, _In_opt_ LPCSTR lpClassName, _In_opt_ LPCSTR lpWindowName, _In_ DWORD dwStyle, _In_ int X, _In_ int Y, _In_ int nWidth, _In_ int nHeight, _In_opt_ HWND hWndParent, _In_opt_ HMENU hMenu, _In_opt_ HINSTANCE hInstance, _In_opt_ LPVOID lpParam)
WCHAR lfFaceName[LF_FACESIZE]
Definition: dimm.idl:72
unsigned int ULONG
Definition: retypes.h:1
LONG bottom
Definition: windef.h:309
static BOOL __thiscall ITextHostImpl_TxShowScrollBar(ITextHost *iface, INT fnBar, BOOL fShow)
Definition: txtsrv.c:151
static void _check_txgetnaturalsize(HRESULT res, LONG width, LONG height, HDC hdc, RECT rect, LPCWSTR string, int line)
Definition: txtsrv.c:692
#define GetProcAddress(x, y)
Definition: compat.h:612
#define LOGPIXELSY
Definition: wingdi.h:719
BOOL NTAPI VirtualFree(IN LPVOID lpAddress, IN SIZE_T dwSize, IN DWORD dwFreeType)
Definition: virtmem.c:128
static HBITMAP
Definition: button.c:44
#define PAGE_EXECUTE_READWRITE
Definition: nt_native.h:1308
LONG lfWeight
Definition: dimm.idl:63
struct _charformat2w CHARFORMAT2W
LONG_PTR LRESULT
Definition: windef.h:209
_Out_ LPRECT prc
Definition: ntgdi.h:1658
#define WS_VISIBLE
Definition: pedump.c:620
static HRESULT __thiscall ITextHostImpl_TxGetBackStyle(ITextHost *iface, TXTBACKSTYLE *pStyle)
Definition: txtsrv.c:327
static void test_IIDs(void)
Definition: txtsrv.c:787
BYTE lfUnderline
Definition: dimm.idl:65
#define memset(x, y, z)
Definition: compat.h:39
#define CFM_ALL2
Definition: richedit.h:393
static BOOL __thiscall ITextHostImpl_TxEnableScrollBar(ITextHost *iface, INT fuSBFlags, INT fuArrowflags)
Definition: txtsrv.c:159
#define win_skip
Definition: test.h:151
LPVOID WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: ifs.c:426
static ULONG WINAPI ITextHostImpl_Release(ITextHost *iface)
Definition: txtsrv.c:118
static void __thiscall ITextHostImpl_TxScrollWindowEx(ITextHost *iface, INT dx, INT dy, LPCRECT lprcScroll, LPCRECT lprcClip, HRGN hRgnUpdate, LPRECT lprcUpdate, UINT fuScroll)
Definition: txtsrv.c:235
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95
IUnknown * inner_unk
Definition: api.c:547
#define DT_EDITCONTROL
Definition: winuser.h:528
INT WINAPI DrawTextW(HDC hdc, LPCWSTR str, INT count, LPRECT rect, UINT flags)
Definition: defwnd.c:17
static HRESULT WINAPI ITextHostImpl_QueryInterface(ITextHost *iface, REFIID riid, LPVOID *ppvObject)
Definition: txtsrv.c:96
#define ok_(x1, x2)
Definition: atltest.h:61
static BOOL __thiscall ITextHostImpl_TxSetScrollPos(ITextHost *iface, INT fnBar, INT nPos, BOOL fRedraw)
Definition: txtsrv.c:176