ReactOS  0.4.15-dev-449-g64abd9f
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 static HDC WINAPI ITextHostImpl_TxGetDC(ITextHost *iface)
133 {
135  TRACECALL("Call to TxGetDC(%p)\n", This);
136  return NULL;
137 }
138 
139 static INT WINAPI ITextHostImpl_TxReleaseDC(ITextHost *iface,
140  HDC hdc)
141 {
143  TRACECALL("Call to TxReleaseDC(%p)\n", This);
144  return 0;
145 }
146 
147 static BOOL WINAPI ITextHostImpl_TxShowScrollBar(ITextHost *iface,
148  INT fnBar,
149  BOOL fShow)
150 {
152  TRACECALL("Call to TxShowScrollBar(%p, fnBar=%d, fShow=%d)\n",
153  This, fnBar, fShow);
154  return FALSE;
155 }
156 
158  INT fuSBFlags,
159  INT fuArrowflags)
160 {
162  TRACECALL("Call to TxEnableScrollBar(%p, fuSBFlags=%d, fuArrowflags=%d)\n",
163  This, fuSBFlags, fuArrowflags);
164  return FALSE;
165 }
166 
168  INT fnBar,
169  LONG nMinPos,
170  INT nMaxPos,
171  BOOL fRedraw)
172 {
174  TRACECALL("Call to TxSetScrollRange(%p, fnBar=%d, nMinPos=%d, nMaxPos=%d, fRedraw=%d)\n",
175  This, fnBar, nMinPos, nMaxPos, fRedraw);
176  return FALSE;
177 }
178 
179 static BOOL WINAPI ITextHostImpl_TxSetScrollPos(ITextHost *iface,
180  INT fnBar,
181  INT nPos,
182  BOOL fRedraw)
183 {
185  TRACECALL("Call to TxSetScrollPos(%p, fnBar=%d, nPos=%d, fRedraw=%d)\n",
186  This, fnBar, nPos, fRedraw);
187  return FALSE;
188 }
189 
190 static void WINAPI ITextHostImpl_TxInvalidateRect(ITextHost *iface,
191  LPCRECT prc,
192  BOOL fMode)
193 {
195  TRACECALL("Call to TxInvalidateRect(%p, prc=%p, fMode=%d)\n",
196  This, prc, fMode);
197 }
198 
199 static void WINAPI ITextHostImpl_TxViewChange(ITextHost *iface, BOOL fUpdate)
200 {
202  TRACECALL("Call to TxViewChange(%p, fUpdate=%d)\n",
203  This, fUpdate);
204 }
205 
206 static BOOL WINAPI ITextHostImpl_TxCreateCaret(ITextHost *iface,
207  HBITMAP hbmp,
208  INT xWidth, INT yHeight)
209 {
211  TRACECALL("Call to TxCreateCaret(%p, nbmp=%p, xWidth=%d, yHeight=%d)\n",
212  This, hbmp, xWidth, yHeight);
213  return FALSE;
214 }
215 
216 static BOOL WINAPI ITextHostImpl_TxShowCaret(ITextHost *iface, BOOL fShow)
217 {
219  TRACECALL("Call to TxShowCaret(%p, fShow=%d)\n",
220  This, fShow);
221  return FALSE;
222 }
223 
224 static BOOL WINAPI ITextHostImpl_TxSetCaretPos(ITextHost *iface,
225  INT x, INT y)
226 {
228  TRACECALL("Call to TxSetCaretPos(%p, x=%d, y=%d)\n", This, x, y);
229  return FALSE;
230 }
231 
232 static BOOL WINAPI ITextHostImpl_TxSetTimer(ITextHost *iface,
233  UINT idTimer, UINT uTimeout)
234 {
236  TRACECALL("Call to TxSetTimer(%p, idTimer=%u, uTimeout=%u)\n",
237  This, idTimer, uTimeout);
238  return FALSE;
239 }
240 
241 static void WINAPI ITextHostImpl_TxKillTimer(ITextHost *iface, UINT idTimer)
242 {
244  TRACECALL("Call to TxKillTimer(%p, idTimer=%u)\n", This, idTimer);
245 }
246 
247 static void WINAPI ITextHostImpl_TxScrollWindowEx(ITextHost *iface,
248  INT dx, INT dy,
249  LPCRECT lprcScroll,
250  LPCRECT lprcClip,
251  HRGN hRgnUpdate,
252  LPRECT lprcUpdate,
253  UINT fuScroll)
254 {
256  TRACECALL("Call to TxScrollWindowEx(%p, %d, %d, %p, %p, %p, %p, %d)\n",
257  This, dx, dy, lprcScroll, lprcClip, hRgnUpdate, lprcUpdate, fuScroll);
258 }
259 
260 static void WINAPI ITextHostImpl_TxSetCapture(ITextHost *iface, BOOL fCapture)
261 {
263  TRACECALL("Call to TxSetCapture(%p, fCapture=%d)\n", This, fCapture);
264 }
265 
266 static void WINAPI ITextHostImpl_TxSetFocus(ITextHost *iface)
267 {
269  TRACECALL("Call to TxSetFocus(%p)\n", This);
270 }
271 
272 static void WINAPI ITextHostImpl_TxSetCursor(ITextHost *iface,
273  HCURSOR hcur,
274  BOOL fText)
275 {
277  TRACECALL("Call to TxSetCursor(%p, hcur=%p, fText=%d)\n",
278  This, hcur, fText);
279 }
280 
282  LPPOINT lppt)
283 {
285  TRACECALL("Call to TxScreenToClient(%p, lppt=%p)\n", This, lppt);
286  return FALSE;
287 }
288 
290  LPPOINT lppt)
291 {
293  TRACECALL("Call to TxClientToScreen(%p, lppt=%p)\n", This, lppt);
294  return FALSE;
295 }
296 
297 static HRESULT WINAPI ITextHostImpl_TxActivate(ITextHost *iface,
298  LONG *plOldState)
299 {
301  TRACECALL("Call to TxActivate(%p, plOldState=%p)\n", This, plOldState);
302  return E_NOTIMPL;
303 }
304 
305 static HRESULT WINAPI ITextHostImpl_TxDeactivate(ITextHost *iface,
306  LONG lNewState)
307 {
309  TRACECALL("Call to TxDeactivate(%p, lNewState=%d)\n", This, lNewState);
310  return E_NOTIMPL;
311 }
312 
314  LPRECT prc)
315 {
317  TRACECALL("Call to TxGetClientRect(%p, prc=%p)\n", This, prc);
318  return E_NOTIMPL;
319 }
320 
322  LPRECT prc)
323 {
325  TRACECALL("Call to TxGetViewInset(%p, prc=%p)\n", This, prc);
326  return E_NOTIMPL;
327 }
328 
330  const CHARFORMATW **ppCF)
331 {
333  TRACECALL("Call to TxGetCharFormat(%p, ppCF=%p)\n", This, ppCF);
334  return E_NOTIMPL;
335 }
336 
338  const PARAFORMAT **ppPF)
339 {
341  TRACECALL("Call to TxGetParaFormat(%p, ppPF=%p)\n", This, ppPF);
342  return E_NOTIMPL;
343 }
344 
346  int nIndex)
347 {
349  TRACECALL("Call to TxGetSysColor(%p, nIndex=%d)\n", This, nIndex);
350  return E_NOTIMPL;
351 }
352 
354  TXTBACKSTYLE *pStyle)
355 {
357  TRACECALL("Call to TxGetBackStyle(%p, pStyle=%p)\n", This, pStyle);
358  return E_NOTIMPL;
359 }
360 
362  DWORD *pLength)
363 {
365  TRACECALL("Call to TxGetMaxLength(%p, pLength=%p)\n", This, pLength);
366  return E_NOTIMPL;
367 }
368 
370  DWORD *pdwScrollBar)
371 {
373  TRACECALL("Call to TxGetScrollBars(%p, pdwScrollBar=%p)\n",
374  This, pdwScrollBar);
375  return E_NOTIMPL;
376 }
377 
379  WCHAR *pch)
380 {
382  TRACECALL("Call to TxGetPasswordChar(%p, pch=%p)\n", This, pch);
383  return E_NOTIMPL;
384 }
385 
387  LONG *pch)
388 {
390  TRACECALL("Call to TxGetAcceleratorPos(%p, pch=%p)\n", This, pch);
391  return E_NOTIMPL;
392 }
393 
394 static HRESULT WINAPI ITextHostImpl_TxGetExtent(ITextHost *iface,
395  LPSIZEL lpExtent)
396 {
398  TRACECALL("Call to TxGetExtent(%p, lpExtent=%p)\n", This, lpExtent);
399  return E_NOTIMPL;
400 }
401 
403  const CHARFORMATW *pcf)
404 {
406  TRACECALL("Call to OnTxCharFormatChange(%p, pcf=%p)\n", This, pcf);
407  return E_NOTIMPL;
408 }
409 
411  const PARAFORMAT *ppf)
412 {
414  TRACECALL("Call to OnTxParaFormatChange(%p, ppf=%p)\n", This, ppf);
415  return E_NOTIMPL;
416 }
417 
418 /* This must return S_OK for the native ITextServices object to
419  initialize. */
421  DWORD dwMask,
422  DWORD *pdwBits)
423 {
425  TRACECALL("Call to TxGetPropertyBits(%p, dwMask=0x%08x, pdwBits=%p)\n",
426  This, dwMask, pdwBits);
427  *pdwBits = 0;
428  return S_OK;
429 }
430 
431 static HRESULT WINAPI ITextHostImpl_TxNotify(ITextHost *iface, DWORD iNotify,
432  void *pv)
433 {
435  TRACECALL("Call to TxNotify(%p, iNotify=%d, pv=%p)\n", This, iNotify, pv);
436  return E_NOTIMPL;
437 }
438 
439 static HIMC WINAPI ITextHostImpl_TxImmGetContext(ITextHost *iface)
440 {
442  TRACECALL("Call to TxImmGetContext(%p)\n", This);
443  return 0;
444 }
445 
446 static void WINAPI ITextHostImpl_TxImmReleaseContext(ITextHost *iface, HIMC himc)
447 {
449  TRACECALL("Call to TxImmReleaseContext(%p, himc=%p)\n", This, himc);
450 }
451 
452 /* This function must set the variable pointed to by *lSelBarWidth.
453  Otherwise an uninitialized value will be used to calculate
454  positions and sizes even if E_NOTIMPL is returned. */
456  LONG *lSelBarWidth)
457 {
459  TRACECALL("Call to TxGetSelectionBarWidth(%p, lSelBarWidth=%p)\n",
460  This, lSelBarWidth);
461  *lSelBarWidth = 0;
462  return E_NOTIMPL;
463 }
464 
465 static ITextHostVtbl itextHostVtbl = {
508 };
509 
510 static void *wrapperCodeMem = NULL;
511 
512 #include "pshpack1.h"
513 
514 /* Code structure for x86 byte code */
515 typedef struct
516 {
517  BYTE pop_eax; /* popl %eax */
518  BYTE push_ecx; /* pushl %ecx */
519  BYTE push_eax; /* pushl %eax */
520  BYTE jmp_func; /* jmp $func */
523 
524 typedef struct
525 {
526  BYTE pop_eax; /* popl %eax */
527  BYTE pop_ecx; /* popl %ecx */
528  BYTE push_eax; /* pushl %eax */
529  BYTE mov_vtable_eax[2]; /* movl (%ecx), %eax */
530  BYTE jmp_eax[2]; /* jmp *$vtablefunc_offset(%eax) */
533 
534 #include "poppack.h"
535 
536 static void setup_thiscall_wrappers(void)
537 {
538 #if defined(__i386__) && !defined(__MINGW32__)
539  void** pVtable;
540  void** pVtableEnd;
543 
545  (sizeof(ITextHostVtbl)/sizeof(void*) - 3)
546  * sizeof(THISCALL_TO_STDCALL_THUNK)
547  +(sizeof(ITextServicesVtbl)/sizeof(void*) - 3)
548  * sizeof(STDCALL_TO_THISCALL_THUNK),
551 
552  /* Wrap all ITextHostImpl methods with code to perform a thiscall to
553  * stdcall conversion. The thiscall calling convention places the This
554  * pointer in ecx on the x86 platform, and the stdcall calling convention
555  * pushes the This pointer on the stack as the first argument.
556  *
557  * The byte code does the conversion then jumps to the real function.
558  *
559  * Each wrapper needs to be modified so that the function to jump to is
560  * modified in the byte code. */
561 
562  /* Skip QueryInterface, AddRef, and Release native actually
563  * defined them with the stdcall calling convention. */
564  pVtable = (void**)&itextHostVtbl + 3;
565  pVtableEnd = (void**)(&itextHostVtbl + 1);
566  while (pVtable != pVtableEnd) {
567  /* write byte code to executable memory */
568  thunk->pop_eax = 0x58; /* popl %eax */
569  thunk->push_ecx = 0x51; /* pushl %ecx */
570  thunk->push_eax = 0x50; /* pushl %eax */
571  thunk->jmp_func = 0xe9; /* jmp $func */
572  /* The address needs to be relative to the end of the jump instructions. */
573  thunk->func = (char*)*pVtable - (char*)(&thunk->func + 1);
574  *pVtable = thunk;
575  pVtable++;
576  thunk++;
577  }
578 
579  /* Setup an ITextServices standard call vtable that will call the
580  * native thiscall vtable when the methods are called. */
581 
582  /* QueryInterface, AddRef, and Release should be called directly on the
583  * real vtable since they use the stdcall calling convention. */
584  thunk2 = (STDCALL_TO_THISCALL_THUNK *)thunk;
585  pVtable = (void**)&itextServicesStdcallVtbl + 3;
586  pVtableEnd = (void**)(&itextServicesStdcallVtbl + 1);
587  while (pVtable != pVtableEnd) {
588  /* write byte code to executable memory */
589  thunk2->pop_eax = 0x58; /* popl %eax */
590  thunk2->pop_ecx = 0x59; /* popl %ecx */
591  thunk2->push_eax = 0x50; /* pushl %eax */
592  thunk2->mov_vtable_eax[0] = 0x8b; /* movl (%ecx), %eax */
593  thunk2->mov_vtable_eax[1] = 0x01;
594  thunk2->jmp_eax[0] = 0xff; /* jmp *$vtablefunc_offset(%eax) */
595  thunk2->jmp_eax[1] = 0xa0;
596  thunk2->vtablefunc_offset = (char*)pVtable - (char*)&itextServicesStdcallVtbl;
597  *pVtable = thunk2;
598  pVtable++;
599  thunk2++;
600  }
601 #endif /* __i386__ */
602 }
603 
604 static void hf_to_cf(HFONT hf, CHARFORMAT2W *cf)
605 {
606  LOGFONTW lf;
607 
608  GetObjectW(hf, sizeof(lf), &lf);
609  lstrcpyW(cf->szFaceName, lf.lfFaceName);
610  cf->yHeight = MulDiv(abs(lf.lfHeight), 1440, GetDeviceCaps(GetDC(NULL), LOGPIXELSY));
611  if (lf.lfWeight > FW_NORMAL) cf->dwEffects |= CFE_BOLD;
612  if (lf.lfItalic) cf->dwEffects |= CFE_ITALIC;
613  if (lf.lfUnderline) cf->dwEffects |= CFE_UNDERLINE;
614  if (lf.lfStrikeOut) cf->dwEffects |= CFE_SUBSCRIPT;
615  cf->bPitchAndFamily = lf.lfPitchAndFamily;
616  cf->bCharSet = lf.lfCharSet;
617 }
618 
619 /*************************************************************************/
620 /* Conformance test functions. */
621 
622 /* Initialize the test texthost structure */
623 static BOOL init_texthost(ITextServices **txtserv, ITextHost **ret)
624 {
625  ITextHostTestImpl *dummyTextHost;
626  IUnknown *init;
627  HRESULT result;
628  HFONT hf;
629 
630  dummyTextHost = CoTaskMemAlloc(sizeof(*dummyTextHost));
631  if (dummyTextHost == NULL) {
632  win_skip("Insufficient memory to create ITextHost interface\n");
633  return FALSE;
634  }
635  dummyTextHost->ITextHost_iface.lpVtbl = &itextHostVtbl;
636  dummyTextHost->refCount = 1;
637  memset(&dummyTextHost->char_format, 0, sizeof(dummyTextHost->char_format));
638  dummyTextHost->char_format.cbSize = sizeof(dummyTextHost->char_format);
639  dummyTextHost->char_format.dwMask = CFM_ALL2;
641  hf_to_cf(hf, &dummyTextHost->char_format);
642 
643  /* MSDN states that an IUnknown object is returned by
644  CreateTextServices which is then queried to obtain a
645  ITextServices object. */
646  result = pCreateTextServices(NULL, &dummyTextHost->ITextHost_iface, &init);
647  ok(result == S_OK, "Did not return S_OK when created (result = %x)\n", result);
648  if (result != S_OK) {
649  CoTaskMemFree(dummyTextHost);
650  win_skip("CreateTextServices failed.\n");
651  return FALSE;
652  }
653 
654  result = IUnknown_QueryInterface(init, pIID_ITextServices, (void**)txtserv);
655  ok((result == S_OK) && (*txtserv != NULL), "Querying interface failed (result = %x, txtserv = %p)\n", result, *txtserv);
656  IUnknown_Release(init);
657  if (!((result == S_OK) && (*txtserv != NULL))) {
658  CoTaskMemFree(dummyTextHost);
659  win_skip("Could not retrieve ITextServices interface\n");
660  return FALSE;
661  }
662 
663  *ret = &dummyTextHost->ITextHost_iface;
664  return TRUE;
665 }
666 
667 static void test_TxGetText(void)
668 {
669  ITextServices *txtserv;
670  ITextHost *host;
671  HRESULT hres;
672  BSTR rettext;
673 
674  if (!init_texthost(&txtserv, &host))
675  return;
676 
677  hres = ITextServices_TxGetText(txtserv, &rettext);
678  ok(hres == S_OK, "ITextServices_TxGetText failed (result = %x)\n", hres);
679  SysFreeString(rettext);
680 
681  ITextServices_Release(txtserv);
682  ITextHost_Release(host);
683 }
684 
685 static void test_TxSetText(void)
686 {
687  ITextServices *txtserv;
688  ITextHost *host;
689  HRESULT hres;
690  BSTR rettext;
691  WCHAR settext[] = {'T','e','s','t',0};
692 
693  if (!init_texthost(&txtserv, &host))
694  return;
695 
696  hres = ITextServices_TxSetText(txtserv, settext);
697  ok(hres == S_OK, "ITextServices_TxSetText failed (result = %x)\n", hres);
698 
699  hres = ITextServices_TxGetText(txtserv, &rettext);
700  ok(hres == S_OK, "ITextServices_TxGetText failed (result = %x)\n", hres);
701 
702  ok(SysStringLen(rettext) == 4,
703  "String returned of wrong length (expected 4, got %d)\n", SysStringLen(rettext));
704  ok(memcmp(rettext,settext,SysStringByteLen(rettext)) == 0,
705  "String returned differs\n");
706 
707  SysFreeString(rettext);
708 
709  /* Null-pointer should behave the same as empty-string */
710 
711  hres = ITextServices_TxSetText(txtserv, 0);
712  ok(hres == S_OK, "ITextServices_TxSetText failed (result = %x)\n", hres);
713 
714  hres = ITextServices_TxGetText(txtserv, &rettext);
715  ok(hres == S_OK, "ITextServices_TxGetText failed (result = %x)\n", hres);
716  ok(SysStringLen(rettext) == 0,
717  "String returned of wrong length (expected 0, got %d)\n", SysStringLen(rettext));
718 
719  SysFreeString(rettext);
720  ITextServices_Release(txtserv);
721  ITextHost_Release(host);
722 }
723 
724 #define CHECK_TXGETNATURALSIZE(res,width,height,hdc,rect,string) \
725  _check_txgetnaturalsize(res, width, height, hdc, rect, string, __LINE__)
727 {
729  LONG expected_width, expected_height;
730 
732  expected_width = expected_rect.right - expected_rect.left;
733  expected_height = expected_rect.bottom - expected_rect.top;
734  ok_(__FILE__,line)(res == S_OK, "ITextServices_TxGetNaturalSize failed: 0x%08x.\n", res);
735  ok_(__FILE__,line)(width >= expected_width && width <= expected_width + 1,
736  "got wrong width: %d, expected: %d {+1}.\n", width, expected_width);
737  ok_(__FILE__,line)(height == expected_height, "got wrong height: %d, expected: %d.\n",
738  height, expected_height);
739 }
740 
741 static void test_TxGetNaturalSize(void)
742 {
743  ITextServices *txtserv;
744  ITextHost *host;
745  HRESULT result;
746  SIZEL extent;
747  static const WCHAR test_text[] = {'T','e','s','t','S','o','m','e','T','e','x','t',0};
748  LONG width, height;
749  HDC hdcDraw;
750  HWND hwnd;
751  RECT rect;
753  LRESULT lresult;
754  HFONT hf;
755 
756  if (!init_texthost(&txtserv, &host))
757  return;
758 
759  hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP | WS_VISIBLE,
760  0, 0, 100, 100, 0, 0, 0, NULL);
761  hdcDraw = GetDC(hwnd);
762  SetMapMode(hdcDraw,MM_TEXT);
764 
765  memset(&cf, 0, sizeof(cf));
766  cf.cbSize = sizeof(cf);
767  cf.dwMask = CFM_ALL2;
769  hf_to_cf(hf, &cf);
771  ok(result == S_OK, "ITextServices_TxSendMessage failed: 0x%08x.\n", result);
772  SelectObject(hdcDraw, hf);
773 
774  result = ITextServices_TxSetText(txtserv, test_text);
775  ok(result == S_OK, "ITextServices_TxSetText failed: 0x%08x.\n", result);
776 
777  extent.cx = -1; extent.cy = -1;
778  width = rect.right - rect.left;
779  height = 0;
780  result = ITextServices_TxGetNaturalSize(txtserv, DVASPECT_CONTENT, hdcDraw, NULL, NULL,
782  todo_wine CHECK_TXGETNATURALSIZE(result, width, height, hdcDraw, rect, test_text);
783 
784  ReleaseDC(hwnd, hdcDraw);
786  ITextServices_Release(txtserv);
787  ITextHost_Release(host);
788 }
789 
790 static void test_TxDraw(void)
791 {
792  ITextServices *txtserv;
793  ITextHost *host;
794  HDC tmphdc = GetDC(NULL);
795  DWORD dwAspect = DVASPECT_CONTENT;
796  HDC hicTargetDev = NULL; /* Means "default" device */
797  DVTARGETDEVICE *ptd = NULL;
798  void *pvAspect = NULL;
799  HRESULT result;
800  RECTL client = {0,0,100,100};
801 
802 
803  if (!init_texthost(&txtserv, &host))
804  return;
805 
806  todo_wine {
807  result = ITextServices_TxDraw(txtserv, dwAspect, 0, pvAspect, ptd,
808  tmphdc, hicTargetDev, &client, NULL,
809  NULL, NULL, 0, 0);
810  ok(result == S_OK, "TxDraw failed (result = %x)\n", result);
811  }
812 
813  ITextServices_Release(txtserv);
814  ITextHost_Release(host);
815 }
816 
817 DEFINE_GUID(expected_iid_itextservices, 0x8d33f740, 0xcf58, 0x11ce, 0xa8, 0x9d, 0x00, 0xaa, 0x00, 0x6c, 0xad, 0xc5);
818 DEFINE_GUID(expected_iid_itexthost, 0x13e670f4,0x1a5a,0x11cf,0xab,0xeb,0x00,0xaa,0x00,0xb6,0x5e,0xa1);
819 DEFINE_GUID(expected_iid_itexthost2, 0x13e670f5,0x1a5a,0x11cf,0xab,0xeb,0x00,0xaa,0x00,0xb6,0x5e,0xa1);
820 
821 static void test_IIDs(void)
822 {
823  ok(IsEqualIID(pIID_ITextServices, &expected_iid_itextservices),
824  "unexpected value for IID_ITextServices: %s\n", wine_dbgstr_guid(pIID_ITextServices));
825  ok(IsEqualIID(pIID_ITextHost, &expected_iid_itexthost),
826  "unexpected value for IID_ITextHost: %s\n", wine_dbgstr_guid(pIID_ITextHost));
827  ok(IsEqualIID(pIID_ITextHost2, &expected_iid_itexthost2),
828  "unexpected value for IID_ITextHost2: %s\n", wine_dbgstr_guid(pIID_ITextHost2));
829 }
830 
831 /* Outer IUnknown for COM aggregation tests */
832 struct unk_impl {
834  LONG ref;
836 };
837 
838 static inline struct unk_impl *impl_from_IUnknown(IUnknown *iface)
839 {
840  return CONTAINING_RECORD(iface, struct unk_impl, IUnknown_iface);
841 }
842 
844 {
845  struct unk_impl *This = impl_from_IUnknown(iface);
846 
847  return IUnknown_QueryInterface(This->inner_unk, riid, ppv);
848 }
849 
851 {
852  struct unk_impl *This = impl_from_IUnknown(iface);
853 
854  return InterlockedIncrement(&This->ref);
855 }
856 
858 {
859  struct unk_impl *This = impl_from_IUnknown(iface);
860 
861  return InterlockedDecrement(&This->ref);
862 }
863 
864 static const IUnknownVtbl unk_vtbl =
865 {
867  unk_AddRef,
869 };
870 
871 static void test_COM(void)
872 {
873  struct unk_impl unk_obj = {{&unk_vtbl}, 19, NULL};
874  struct ITextHostTestImpl texthost = {{&itextHostVtbl}, 1};
875  ITextServices *textsrv;
876  ULONG refcount;
877  HRESULT hr;
878 
879  /* COM aggregation */
881  &unk_obj.inner_unk);
882  ok(hr == S_OK, "CreateTextServices failed: %08x\n", hr);
883  hr = IUnknown_QueryInterface(unk_obj.inner_unk, pIID_ITextServices, (void**)&textsrv);
884  ok(hr == S_OK, "QueryInterface for IID_ITextServices failed: %08x\n", hr);
885  refcount = ITextServices_AddRef(textsrv);
886  ok(refcount == unk_obj.ref, "CreateTextServices just pretends to support COM aggregation\n");
887  refcount = ITextServices_Release(textsrv);
888  ok(refcount == unk_obj.ref, "CreateTextServices just pretends to support COM aggregation\n");
889  refcount = ITextServices_Release(textsrv);
890  ok(refcount == 19, "Refcount should be back at 19 but is %u\n", refcount);
891 
892  IUnknown_Release(unk_obj.inner_unk);
893 }
894 
896 {
897  IUnknown_AddRef(iface);
898  return IUnknown_Release(iface);
899 }
900 
901 static void test_QueryInterface(void)
902 {
903  ITextServices *txtserv;
904  ITextHost *host;
905  HRESULT hres;
906  IRichEditOle *reole, *txtsrv_reole;
907  ITextDocument *txtdoc, *txtsrv_txtdoc;
908  ITextDocument2Old *txtdoc2old, *txtsrv_txtdoc2old;
909  ULONG refcount;
910 
911  if(!init_texthost(&txtserv, &host))
912  return;
913 
914  refcount = get_refcount((IUnknown *)txtserv);
915  ok(refcount == 1, "got wrong ref count: %d\n", refcount);
916 
917  /* IID_IRichEditOle */
918  hres = ITextServices_QueryInterface(txtserv, &IID_IRichEditOle, (void **)&txtsrv_reole);
919  ok(hres == S_OK, "ITextServices_QueryInterface: 0x%08x\n", hres);
920  refcount = get_refcount((IUnknown *)txtserv);
921  ok(refcount == 2, "got wrong ref count: %d\n", refcount);
922  refcount = get_refcount((IUnknown *)txtsrv_reole);
923  ok(refcount == 2, "got wrong ref count: %d\n", refcount);
924 
925  hres = IRichEditOle_QueryInterface(txtsrv_reole, &IID_ITextDocument, (void **)&txtdoc);
926  ok(hres == S_OK, "IRichEditOle_QueryInterface: 0x%08x\n", hres);
927  refcount = get_refcount((IUnknown *)txtserv);
928  ok(refcount == 3, "got wrong ref count: %d\n", refcount);
929  refcount = get_refcount((IUnknown *)txtsrv_reole);
930  ok(refcount == 3, "got wrong ref count: %d\n", refcount);
931 
932  ITextDocument_Release(txtdoc);
933  refcount = get_refcount((IUnknown *)txtserv);
934  ok(refcount == 2, "got wrong ref count: %d\n", refcount);
935 
936  hres = IRichEditOle_QueryInterface(txtsrv_reole, &IID_ITextDocument2Old, (void **)&txtdoc2old);
937  ok(hres == S_OK, "IRichEditOle_QueryInterface: 0x%08x\n", hres);
938  refcount = get_refcount((IUnknown *)txtserv);
939  ok(refcount == 3, "got wrong ref count: %d\n", refcount);
940  refcount = get_refcount((IUnknown *)txtsrv_reole);
941  ok(refcount == 3, "got wrong ref count: %d\n", refcount);
942 
943  ITextDocument2Old_Release(txtdoc2old);
944  refcount = get_refcount((IUnknown *)txtserv);
945  ok(refcount == 2, "got wrong ref count: %d\n", refcount);
946  IRichEditOle_Release(txtsrv_reole);
947  refcount = get_refcount((IUnknown *)txtserv);
948  ok(refcount == 1, "got wrong ref count: %d\n", refcount);
949 
950  /* IID_ITextDocument */
951  hres = ITextServices_QueryInterface(txtserv, &IID_ITextDocument, (void **)&txtsrv_txtdoc);
952  ok(hres == S_OK, "ITextServices_QueryInterface: 0x%08x\n", hres);
953  refcount = get_refcount((IUnknown *)txtserv);
954  ok(refcount == 2, "got wrong ref count: %d\n", refcount);
955  refcount = get_refcount((IUnknown *)txtsrv_txtdoc);
956  ok(refcount == 2, "got wrong ref count: %d\n", refcount);
957 
958  hres = ITextDocument_QueryInterface(txtsrv_txtdoc, &IID_IRichEditOle, (void **)&reole);
959  ok(hres == S_OK, "ITextDocument_QueryInterface: 0x%08x\n", hres);
960  refcount = get_refcount((IUnknown *)txtserv);
961  ok(refcount == 3, "got wrong ref count: %d\n", refcount);
962  refcount = get_refcount((IUnknown *)txtsrv_txtdoc);
963  ok(refcount == 3, "got wrong ref count: %d\n", refcount);
964 
965  IRichEditOle_Release(reole);
966  refcount = get_refcount((IUnknown *)txtserv);
967  ok(refcount == 2, "got wrong ref count: %d\n", refcount);
968  ITextDocument_Release(txtsrv_txtdoc);
969  refcount = get_refcount((IUnknown *)txtserv);
970  ok(refcount == 1, "got wrong ref count: %d\n", refcount);
971 
972  /* ITextDocument2Old */
973  hres = ITextServices_QueryInterface(txtserv, &IID_ITextDocument2Old, (void **)&txtsrv_txtdoc2old);
974  ok(hres == S_OK, "ITextServices_QueryInterface: 0x%08x\n", hres);
975  refcount = get_refcount((IUnknown *)txtserv);
976  ok(refcount == 2, "got wrong ref count: %d\n", refcount);
977  refcount = get_refcount((IUnknown *)txtsrv_txtdoc2old);
978  ok(refcount == 2, "got wrong ref count: %d\n", refcount);
979 
980  hres = ITextDocument2Old_QueryInterface(txtsrv_txtdoc2old, &IID_IRichEditOle, (void **)&reole);
981  ok(hres == S_OK, "ITextDocument2Old_QueryInterface: 0x%08x\n", hres);
982  refcount = get_refcount((IUnknown *)txtserv);
983  ok(refcount == 3, "got wrong ref count: %d\n", refcount);
984  refcount = get_refcount((IUnknown *)txtsrv_txtdoc2old);
985  ok(refcount == 3, "got wrong ref count: %d\n", refcount);
986 
987  IRichEditOle_Release(reole);
988  refcount = get_refcount((IUnknown *)txtserv);
989  ok(refcount == 2, "got wrong ref count: %d\n", refcount);
990  ITextDocument2Old_Release(txtsrv_txtdoc2old);
991  refcount = get_refcount((IUnknown *)txtserv);
992  ok(refcount == 1, "got wrong ref count: %d\n", refcount);
993 
994  ITextServices_Release(txtserv);
995  ITextHost_Release(host);
996 }
997 
998 static void test_default_format(void)
999 {
1000  ITextServices *txtserv;
1001  ITextHost *host;
1002  HRESULT result;
1003  LRESULT lresult;
1004  CHARFORMAT2W cf2;
1005  const CHARFORMATW *host_cf;
1006  DWORD expected_effects;
1007 
1008  if (!init_texthost(&txtserv, &host))
1009  return;
1010 
1011  cf2.cbSize = sizeof(CHARFORMAT2W);
1013  ok(result == S_OK, "ITextServices_TxSendMessage failed: 0x%08x.\n", result);
1014 
1016  ok(!lstrcmpW(host_cf->szFaceName, cf2.szFaceName), "got wrong font name: %s.\n", wine_dbgstr_w(cf2.szFaceName));
1017  ok(cf2.yHeight == host_cf->yHeight, "got wrong yHeight: %d, expected %d.\n", cf2.yHeight, host_cf->yHeight);
1018  expected_effects = (cf2.dwEffects & ~(CFE_AUTOCOLOR | CFE_AUTOBACKCOLOR));
1019  ok(host_cf->dwEffects == expected_effects, "got wrong dwEffects: %x, expected %x.\n", cf2.dwEffects, expected_effects);
1020  ok(cf2.bPitchAndFamily == host_cf->bPitchAndFamily, "got wrong bPitchAndFamily: %x, expected %x.\n",
1021  cf2.bPitchAndFamily, host_cf->bPitchAndFamily);
1022  ok(cf2.bCharSet == host_cf->bCharSet, "got wrong bCharSet: %x, expected %x.\n", cf2.bCharSet, host_cf->bCharSet);
1023 
1024  ITextServices_Release(txtserv);
1025  ITextHost_Release(host);
1026 }
1027 
1028 static void test_TxGetScroll(void)
1029 {
1030  ITextServices *txtserv;
1031  ITextHost *host;
1032  HRESULT ret;
1033 
1034  if (!init_texthost(&txtserv, &host))
1035  return;
1036 
1038  ok(ret == S_OK, "ITextSerHices_GetVScroll failed: 0x%08x.\n", ret);
1039 
1041  ok(ret == S_OK, "ITextServices_GetVScroll failed: 0x%08x.\n", ret);
1042 
1043  ITextServices_Release(txtserv);
1044  ITextHost_Release(host);
1045 }
1046 
1047 START_TEST( txtsrv )
1048 {
1049  ITextServices *txtserv;
1050  ITextHost *host;
1051 
1053 
1054  /* Must explicitly LoadLibrary(). The test has no references to functions in
1055  * RICHED20.DLL, so the linker doesn't actually link to it. */
1056  hmoduleRichEdit = LoadLibraryA("riched20.dll");
1057  ok(hmoduleRichEdit != NULL, "error: %d\n", (int) GetLastError());
1058 
1059  pIID_ITextServices = (IID*)GetProcAddress(hmoduleRichEdit, "IID_ITextServices");
1060  pIID_ITextHost = (IID*)GetProcAddress(hmoduleRichEdit, "IID_ITextHost");
1061  pIID_ITextHost2 = (IID*)GetProcAddress(hmoduleRichEdit, "IID_ITextHost2");
1062  pCreateTextServices = (void*)GetProcAddress(hmoduleRichEdit, "CreateTextServices");
1063 
1064  test_IIDs();
1065  test_COM();
1066 
1067  if (init_texthost(&txtserv, &host))
1068  {
1069  ITextServices_Release(txtserv);
1070  ITextHost_Release(host);
1071 
1072  test_TxGetText();
1073  test_TxSetText();
1075  test_TxDraw();
1078  test_TxGetScroll();
1079  }
1081 }
HGDIOBJ WINAPI GetStockObject(_In_ int)
static IClassFactory * cf
static void WINAPI ITextHostImpl_TxInvalidateRect(ITextHost *iface, LPCRECT prc, BOOL fMode)
Definition: txtsrv.c:190
static void test_TxGetText(void)
Definition: txtsrv.c:667
#define CFE_AUTOCOLOR
Definition: richedit.h:414
static void hf_to_cf(HFONT hf, CHARFORMAT2W *cf)
Definition: txtsrv.c:604
#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
GLint GLint GLsizei width
Definition: gl.h:1546
#define REFIID
Definition: guiddef.h:118
#define TRUE
Definition: types.h:120
BYTE lfPitchAndFamily
Definition: dimm.idl:71
#define E_NOINTERFACE
Definition: winerror.h:2364
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
#define CFE_UNDERLINE
Definition: richedit.h:408
static void test_TxGetScroll(void)
Definition: txtsrv.c:1028
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
LONG yHeight
Definition: richedit.h:271
Definition: cproxy.c:247
static COLORREF WINAPI ITextHostImpl_TxGetSysColor(ITextHost *iface, int nIndex)
Definition: txtsrv.c:345
HDC WINAPI GetDC(_In_opt_ HWND)
IUnknown IUnknown_iface
Definition: api.c:545
static BOOL WINAPI ITextHostImpl_TxSetScrollPos(ITextHost *iface, INT fnBar, INT nPos, BOOL fRedraw)
Definition: txtsrv.c:179
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:871
static void test_TxGetNaturalSize(void)
Definition: txtsrv.c:741
#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:838
static HDC
Definition: imagelist.c:92
#define CFE_SUBSCRIPT
Definition: richedit.h:412
static HRESULT WINAPI ITextHostImpl_TxGetViewInset(ITextHost *iface, LPRECT prc)
Definition: txtsrv.c:321
REFIID LPVOID * ppv
Definition: atlbase.h:39
static HIMC WINAPI ITextHostImpl_TxImmGetContext(ITextHost *iface)
Definition: txtsrv.c:439
LONG top
Definition: windef.h:307
CHARFORMAT2W char_format
Definition: txtsrv.c:88
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
const char * wine_dbgstr_guid(const GUID *guid)
static ULONG WINAPI unk_AddRef(IUnknown *iface)
Definition: txtsrv.c:850
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
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:1943
LONG left
Definition: windef.h:306
HICON HCURSOR
Definition: windef.h:299
static HRESULT WINAPI ITextHostImpl_TxGetAcceleratorPos(ITextHost *iface, LONG *pch)
Definition: txtsrv.c:386
static BOOL WINAPI ITextHostImpl_TxSetScrollRange(ITextHost *iface, INT fnBar, LONG nMinPos, INT nMaxPos, BOOL fRedraw)
Definition: txtsrv.c:167
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:57
& rect
Definition: startmenu.cpp:1413
static int init
Definition: wintirpc.c:33
#define pch(ap)
Definition: match.c:418
#define CFE_BOLD
Definition: richedit.h:406
LPVOID NTAPI VirtualAlloc(IN LPVOID lpAddress, IN SIZE_T dwSize, IN DWORD flAllocationType, IN DWORD flProtect)
Definition: virtmem.c:74
#define DT_LEFT
Definition: winuser.h:534
#define DT_CALCRECT
Definition: winuser.h:526
static IID * pIID_ITextHost2
Definition: txtsrv.c:44
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
int WINAPI SetMapMode(_In_ HDC, _In_ int)
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
static BOOL WINAPI ITextHostImpl_TxShowCaret(ITextHost *iface, BOOL fShow)
Definition: txtsrv.c:216
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
static HRESULT WINAPI ITextHostImpl_TxGetClientRect(ITextHost *iface, LPRECT prc)
Definition: txtsrv.c:313
static HMODULE hmoduleRichEdit
Definition: txtsrv.c:41
static void test_TxDraw(void)
Definition: txtsrv.c:790
#define EM_SETCHARFORMAT
Definition: richedit.h:101
START_TEST(txtsrv)
Definition: txtsrv.c:1047
smooth NULL
Definition: ftsmooth.c:416
static BOOL WINAPI ITextHostImpl_TxScreenToClient(ITextHost *iface, LPPOINT lppt)
Definition: txtsrv.c:281
static HDC WINAPI ITextHostImpl_TxGetDC(ITextHost *iface)
Definition: txtsrv.c:132
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
static BOOL WINAPI ITextHostImpl_TxSetTimer(ITextHost *iface, UINT idTimer, UINT uTimeout)
Definition: txtsrv.c:232
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:895
static ULONG WINAPI unk_Release(IUnknown *iface)
Definition: txtsrv.c:857
#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:998
HBITMAP hbmp
static IID * pIID_ITextHost
Definition: txtsrv.c:43
static void test_QueryInterface(void)
Definition: txtsrv.c:901
static HRESULT WINAPI ITextHostImpl_TxActivate(ITextHost *iface, LONG *plOldState)
Definition: txtsrv.c:297
static void * wrapperCodeMem
Definition: txtsrv.c:510
static HRESULT WINAPI ITextHostImpl_TxGetPropertyBits(ITextHost *iface, DWORD dwMask, DWORD *pdwBits)
Definition: txtsrv.c:420
static void WINAPI ITextHostImpl_TxSetCursor(ITextHost *iface, HCURSOR hcur, BOOL fText)
Definition: txtsrv.c:272
HRESULT hres
Definition: protocol.c:465
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:78
DWORD COLORREF
Definition: windef.h:300
#define CHECK_TXGETNATURALSIZE(res, width, height, hdc, rect, string)
Definition: txtsrv.c:724
const GUID IID_IUnknown
static void WINAPI ITextHostImpl_TxImmReleaseContext(ITextHost *iface, HIMC himc)
Definition: txtsrv.c:446
static ITextHostVtbl itextHostVtbl
Definition: txtsrv.c:465
#define WINAPI
Definition: msvc.h:6
static RECT expected_rect
Definition: win.c:5822
static FILE * client
Definition: client.c:41
unsigned long DWORD
Definition: ntddk_ex.h:95
static void WINAPI ITextHostImpl_TxKillTimer(ITextHost *iface, UINT idTimer)
Definition: txtsrv.c:241
DEFINE_GUID(expected_iid_itextservices, 0x8d33f740, 0xcf58, 0x11ce, 0xa8, 0x9d, 0x00, 0xaa, 0x00, 0x6c, 0xad, 0xc5)
static HRESULT WINAPI ITextHostImpl_OnTxParaFormatChange(ITextHost *iface, const PARAFORMAT *ppf)
Definition: txtsrv.c:410
static INT WINAPI ITextHostImpl_TxReleaseDC(ITextHost *iface, HDC hdc)
Definition: txtsrv.c:139
Definition: api.c:544
#define DEFAULT_GUI_FONT
Definition: wingdi.h:908
static HRESULT WINAPI ITextHostImpl_TxGetCharFormat(ITextHost *iface, const CHARFORMATW **ppCF)
Definition: txtsrv.c:329
int ret
#define todo_wine
Definition: test.h:162
#define InterlockedDecrement
Definition: armddk.h:52
HDC hdc
Definition: main.c:9
#define CFE_ITALIC
Definition: richedit.h:407
static IID * pIID_ITextServices
Definition: txtsrv.c:42
static void test_TxSetText(void)
Definition: txtsrv.c:685
int WINAPI GetDeviceCaps(_In_opt_ HDC, _In_ int)
static HRESULT WINAPI ITextHostImpl_TxGetMaxLength(ITextHost *iface, DWORD *pLength)
Definition: txtsrv.c:361
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:864
static BOOL WINAPI ITextHostImpl_TxCreateCaret(ITextHost *iface, HBITMAP hbmp, INT xWidth, INT yHeight)
Definition: txtsrv.c:206
#define ITextServices_TxSendMessage(This, a, b, c, d)
Definition: txtsrv.c:58
unsigned char BYTE
Definition: xxhash.c:193
static HRESULT WINAPI ITextHostImpl_OnTxCharFormatChange(ITextHost *iface, const CHARFORMATW *pcf)
Definition: txtsrv.c:402
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 HRESULT WINAPI ITextHostImpl_TxNotify(ITextHost *iface, DWORD iNotify, void *pv)
Definition: txtsrv.c:431
static BOOL WINAPI ITextHostImpl_TxSetCaretPos(ITextHost *iface, INT x, INT y)
Definition: txtsrv.c:224
#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:59
static BOOL WINAPI ITextHostImpl_TxClientToScreen(ITextHost *iface, LPPOINT lppt)
Definition: txtsrv.c:289
#define InterlockedIncrement
Definition: armddk.h:53
#define ITextServices_TxSetText(This, a)
Definition: txtsrv.c:69
#define lstrcpyW
Definition: compat.h:415
static void WINAPI ITextHostImpl_TxSetCapture(ITextHost *iface, BOOL fCapture)
Definition: txtsrv.c:260
#define EM_GETCHARFORMAT
Definition: richedit.h:91
static BOOL init_texthost(ITextServices **txtserv, ITextHost **ret)
Definition: txtsrv.c:623
BYTE lfStrikeOut
Definition: dimm.idl:66
static HRESULT WINAPI unk_QueryInterface(IUnknown *iface, REFIID riid, void **ppv)
Definition: txtsrv.c:843
#define ok(value,...)
Definition: atltest.h:57
#define E_NOTIMPL
Definition: ddrawi.h:99
static HRESULT WINAPI ITextHostImpl_TxDeactivate(ITextHost *iface, LONG lNewState)
Definition: txtsrv.c:305
BYTE lfItalic
Definition: dimm.idl:64
DWORD dwMask
Definition: richedit.h:306
static HRESULT WINAPI ITextHostImpl_TxGetScrollBars(ITextHost *iface, DWORD *pdwScrollBar)
Definition: txtsrv.c:369
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
static HRESULT WINAPI ITextHostImpl_TxGetExtent(ITextHost *iface, LPSIZEL lpExtent)
Definition: txtsrv.c:394
static HRESULT WINAPI ITextHostImpl_TxGetParaFormat(ITextHost *iface, const PARAFORMAT **ppPF)
Definition: txtsrv.c:337
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 WINAPI ITextHostImpl_TxScrollWindowEx(ITextHost *iface, INT dx, INT dy, LPCRECT lprcScroll, LPCRECT lprcClip, HRGN hRgnUpdate, LPRECT lprcUpdate, UINT fuScroll)
Definition: txtsrv.c:247
static void setup_thiscall_wrappers(void)
Definition: txtsrv.c:536
ITextHost ITextHost_iface
Definition: txtsrv.c:86
#define FW_NORMAL
Definition: wingdi.h:372
#define TRACECALL
Definition: txtsrv.c:79
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
static HRESULT WINAPI ITextHostImpl_TxGetBackStyle(ITextHost *iface, TXTBACKSTYLE *pStyle)
Definition: txtsrv.c:353
#define MEM_RELEASE
Definition: nt_native.h:1316
#define MM_TEXT
Definition: wingdi.h:872
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)
static BOOL WINAPI ITextHostImpl_TxEnableScrollBar(ITextHost *iface, INT fuSBFlags, INT fuArrowflags)
Definition: txtsrv.c:157
WCHAR lfFaceName[LF_FACESIZE]
Definition: dimm.idl:72
static BOOL WINAPI ITextHostImpl_TxShowScrollBar(ITextHost *iface, INT fnBar, BOOL fShow)
Definition: txtsrv.c:147
unsigned int ULONG
Definition: retypes.h:1
LONG bottom
Definition: windef.h:309
static void _check_txgetnaturalsize(HRESULT res, LONG width, LONG height, HDC hdc, RECT rect, LPCWSTR string, int line)
Definition: txtsrv.c:726
#define GetProcAddress(x, y)
Definition: compat.h:419
#define LOGPIXELSY
Definition: wingdi.h:718
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
static HRESULT WINAPI ITextHostImpl_TxGetSelectionBarWidth(ITextHost *iface, LONG *lSelBarWidth)
Definition: txtsrv.c:455
_Out_ LPRECT prc
Definition: ntgdi.h:1658
#define WS_VISIBLE
Definition: pedump.c:620
static void test_IIDs(void)
Definition: txtsrv.c:821
BYTE lfUnderline
Definition: dimm.idl:65
static void WINAPI ITextHostImpl_TxViewChange(ITextHost *iface, BOOL fUpdate)
Definition: txtsrv.c:199
GLuint64EXT * result
Definition: glext.h:11304
#define memset(x, y, z)
Definition: compat.h:39
#define CFM_ALL2
Definition: richedit.h:393
#define win_skip
Definition: test.h:149
LPVOID WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: ifs.c:426
static void WINAPI ITextHostImpl_TxSetFocus(ITextHost *iface)
Definition: txtsrv.c:266
static ULONG WINAPI ITextHostImpl_Release(ITextHost *iface)
Definition: txtsrv.c:118
#define MulDiv(x, y, z)
Definition: gdifloat.h:86
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95
IUnknown * inner_unk
Definition: api.c:547
#define DT_EDITCONTROL
Definition: winuser.h:528
static HRESULT WINAPI ITextHostImpl_TxGetPasswordChar(ITextHost *iface, WCHAR *pch)
Definition: txtsrv.c:378
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