ReactOS 0.4.16-dev-981-g80eb313
richole.c
Go to the documentation of this file.
1/*
2 * Tests for IRichEditOle and friends.
3 *
4 * Copyright 2008 Google (Dan Hipschman)
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 */
20
21#define COBJMACROS
22
23#include <stdarg.h>
24
25#include <windef.h>
26#include <winbase.h>
27#include <wingdi.h>
28#include <winuser.h>
29#include <initguid.h>
30#include <ole2.h>
31#include <richedit.h>
32#include <richole.h>
33#include <tom.h>
34#include <wine/test.h>
35
37
38DEFINE_GUID(GUID_NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
39
40static const WCHAR sysW[] = {'S','y','s','t','e','m',0};
41
42#define EXPECT_REF(obj,ref) _expect_ref((IUnknown*)obj, ref, __LINE__)
43static void _expect_ref(IUnknown* obj, ULONG ref, int line)
44{
45 ULONG rc;
46 IUnknown_AddRef(obj);
47 rc = IUnknown_Release(obj);
48 ok_(__FILE__,line)(rc == ref, "expected refcount %d, got %d\n", ref, rc);
49}
50
51static HWND new_window(LPCSTR lpClassName, DWORD dwStyle, HWND parent)
52{
53 HWND hwnd = CreateWindowA(lpClassName, NULL,
55 0, 0, 200, 60, parent, NULL, hmoduleRichEdit, NULL);
56 ok(hwnd != NULL, "class: %s, error: %d\n", lpClassName, (int) GetLastError());
57 return hwnd;
58}
59
61{
63}
64
66{
68
71
73 return FALSE;
75 return TRUE;
76}
77
79{
81
85 return FALSE;
87 return TRUE;
88}
89
90static void create_interfaces(HWND *w, IRichEditOle **reOle, ITextDocument **txtDoc,
91 ITextSelection **txtSel)
92{
95 IRichEditOle_QueryInterface(*reOle, &IID_ITextDocument,
96 (void **) txtDoc);
97 ITextDocument_GetSelection(*txtDoc, txtSel);
98}
99
100static void release_interfaces(HWND *w, IRichEditOle **reOle, ITextDocument **txtDoc,
101 ITextSelection **txtSel)
102{
103 if(txtSel)
104 ITextSelection_Release(*txtSel);
105 ITextDocument_Release(*txtDoc);
106 IRichEditOle_Release(*reOle);
108}
109
111{
112 IUnknown_AddRef(iface);
113 return IUnknown_Release(iface);
114}
115
116#define CHECK_TYPEINFO(disp,expected_riid) _check_typeinfo((IDispatch *)disp, expected_riid, __LINE__)
117static void _check_typeinfo(IDispatch* disp, REFIID expected_riid, int line)
118{
120 TYPEATTR *typeattr;
121 UINT count;
122 HRESULT hr;
123
124 count = 10;
125 hr = IDispatch_GetTypeInfoCount(disp, &count);
126 ok_(__FILE__,line)(hr == S_OK, "IDispatch_GetTypeInfoCount failed: 0x%08x.\n", hr);
127 ok_(__FILE__,line)(count == 1, "got wrong count: %u.\n", count);
128
129 hr = IDispatch_GetTypeInfo(disp, 0, LOCALE_SYSTEM_DEFAULT, &typeinfo);
130 ok_(__FILE__,line)(hr == S_OK, "IDispatch_GetTypeInfo failed: 0x%08x.\n", hr);
131
132 hr = ITypeInfo_GetTypeAttr(typeinfo, &typeattr);
133 ok_(__FILE__,line)(hr == S_OK, "ITypeInfo_GetTypeAttr failed: 0x%08x.\n", hr);
134 ok_(__FILE__,line)(IsEqualGUID(&typeattr->guid, expected_riid),
135 "Unexpected type guid: %s.\n", wine_dbgstr_guid(&typeattr->guid));
136
137 ITypeInfo_ReleaseTypeAttr(typeinfo, typeattr);
138 ITypeInfo_Release(typeinfo);
139}
140
141static void test_Interfaces(void)
142{
143 IRichEditOle *reOle = NULL, *reOle1 = NULL;
144 ITextDocument *txtDoc = NULL;
145 ITextDocument2Old *txtDoc2Old = NULL;
146 ITextSelection *txtSel = NULL, *txtSel2;
147 IUnknown *punk;
149 LRESULT res;
150 HWND w;
151 ULONG refcount;
152 IUnknown *unk, *unk2;
153
155 if (!w) {
156 skip("Couldn't create window\n");
157 return;
158 }
159
161 ok(res, "SendMessage\n");
162 ok(reOle != NULL, "EM_GETOLEINTERFACE\n");
163 EXPECT_REF(reOle, 2);
164
165 res = SendMessageA(w, EM_GETOLEINTERFACE, 0, (LPARAM)&reOle1);
166 ok(res == 1, "SendMessage\n");
167 ok(reOle1 == reOle, "Should not return a new IRichEditOle interface\n");
168 EXPECT_REF(reOle, 3);
169
170 hres = IRichEditOle_QueryInterface(reOle, &IID_ITextDocument,
171 (void **) &txtDoc);
172 ok(hres == S_OK, "IRichEditOle_QueryInterface\n");
173 ok(txtDoc != NULL, "IRichEditOle_QueryInterface\n");
174 CHECK_TYPEINFO(txtDoc, &IID_ITextDocument);
175
176 hres = ITextDocument_GetSelection(txtDoc, NULL);
177 ok(hres == E_INVALIDARG, "ITextDocument_GetSelection: 0x%x\n", hres);
178
179 EXPECT_REF(txtDoc, 4);
180
181 hres = ITextDocument_GetSelection(txtDoc, &txtSel);
182 ok(hres == S_OK, "got 0x%08x\n", hres);
183
184 hres = ITextDocument_QueryInterface(txtDoc, &IID_IUnknown, (void **)&unk);
185 ok(hres == S_OK, "got 0x%08x\n", hres);
186 hres = ITextSelection_QueryInterface(txtSel, &IID_IUnknown, (void **)&unk2);
187 ok(hres == S_OK, "got 0x%08x\n", hres);
188 ok(unk != unk2, "unknowns are the same\n");
189 IUnknown_Release(unk2);
190 IUnknown_Release(unk);
191
192 EXPECT_REF(txtDoc, 4);
193 EXPECT_REF(txtSel, 2);
194
195 hres = ITextDocument_GetSelection(txtDoc, &txtSel2);
196 ok(hres == S_OK, "got 0x%08x\n", hres);
197 ok(txtSel2 == txtSel, "got %p, %p\n", txtSel, txtSel2);
198
199 EXPECT_REF(txtDoc, 4);
200 EXPECT_REF(txtSel, 3);
201
202 ITextSelection_Release(txtSel2);
203
204 punk = NULL;
205 hres = ITextSelection_QueryInterface(txtSel, &IID_ITextSelection, (void **) &punk);
206 ok(hres == S_OK, "ITextSelection_QueryInterface\n");
207 ok(punk != NULL, "ITextSelection_QueryInterface\n");
208 IUnknown_Release(punk);
209
210 punk = NULL;
211 hres = ITextSelection_QueryInterface(txtSel, &IID_ITextRange, (void **) &punk);
212 ok(hres == S_OK, "ITextSelection_QueryInterface\n");
213 ok(punk != NULL, "ITextSelection_QueryInterface\n");
214 IUnknown_Release(punk);
215
216 punk = NULL;
217 hres = ITextSelection_QueryInterface(txtSel, &IID_IDispatch, (void **) &punk);
218 ok(hres == S_OK, "ITextSelection_QueryInterface\n");
219 ok(punk != NULL, "ITextSelection_QueryInterface\n");
220 IUnknown_Release(punk);
221
222 punk = NULL;
223 hres = IRichEditOle_QueryInterface(reOle, &IID_IOleClientSite, (void **) &punk);
224 ok(hres == E_NOINTERFACE, "IRichEditOle_QueryInterface\n");
225
226 punk = NULL;
227 hres = IRichEditOle_QueryInterface(reOle, &IID_IOleWindow, (void **) &punk);
228 ok(hres == E_NOINTERFACE, "IRichEditOle_QueryInterface\n");
229
230 punk = NULL;
231 hres = IRichEditOle_QueryInterface(reOle, &IID_IOleInPlaceSite, (void **) &punk);
232 ok(hres == E_NOINTERFACE, "IRichEditOle_QueryInterface\n");
233
234 hres = IRichEditOle_QueryInterface(reOle, &IID_ITextDocument2Old, (void **)&txtDoc2Old);
235 ok(hres == S_OK, "IRichEditOle_QueryInterface\n");
236 ok(txtDoc2Old != NULL, "IRichEditOle_QueryInterface\n");
237 ok((ITextDocument *)txtDoc2Old == txtDoc, "interface pointer isn't equal.\n");
238 EXPECT_REF(txtDoc2Old, 5);
239 EXPECT_REF(reOle, 5);
240 CHECK_TYPEINFO(txtDoc2Old, &IID_ITextDocument);
241
242 ITextDocument2Old_Release(txtDoc2Old);
243
244 ITextDocument_Release(txtDoc);
245 IRichEditOle_Release(reOle);
246 refcount = IRichEditOle_Release(reOle);
247 ok(refcount == 1, "got wrong ref count: %d\n", refcount);
249
250 /* Methods should return CO_E_RELEASED if the backing document has
251 been released. One test should suffice. */
252 hres = ITextSelection_CanEdit(txtSel, NULL);
253 ok(hres == CO_E_RELEASED, "ITextSelection after ITextDocument destroyed\n");
254
255 ITextSelection_Release(txtSel);
256
259 ok(res, "SendMessage\n");
260 ok(reOle != NULL, "EM_GETOLEINTERFACE\n");
261
262 hres = IRichEditOle_QueryInterface(reOle, &IID_ITextDocument2Old, (void **)&txtDoc2Old);
263 ok(hres == S_OK, "IRichEditOle_QueryInterface failed: 0x%08x.\n", hres);
264 ok(txtDoc2Old != NULL, "IRichEditOle_QueryInterface\n");
265 CHECK_TYPEINFO(txtDoc2Old, &IID_ITextDocument);
266 ITextDocument2Old_Release(txtDoc2Old);
267 IRichEditOle_Release(reOle);
269}
270
271static void test_ITextDocument_Open(void)
272{
273 IRichEditOle *reOle = NULL;
274 ITextDocument *txtDoc = NULL;
275 ITextSelection *txtSel = NULL;
277 HWND w;
279 VARIANT testfile;
280 WCHAR filename[] = {'t', 'e', 's', 't','.','t','x','t', 0};
281 int result;
282 DWORD dw;
283 static const CHAR chACP[] = "TestSomeText";
284 static const CHAR chUTF8[] = "\xef\xbb\xbfTextWithUTF8BOM";
285 static const WCHAR chUTF16[] = {0xfeff, 'T', 'e', 's', 't', 'S', 'o', 'm',
286 'e', 'T', 'e', 'x', 't', 0};
287
288#define MAX_BUF_LEN 1024
289 CHAR bufACP[MAX_BUF_LEN];
290 WCHAR bufUnicode[MAX_BUF_LEN];
291
292 static const int tomConstantsSingle[] =
293 {
297 };
298
299 static const int tomConstantsMulti[] =
300 {
307 };
308
309 int tomNumSingle = ARRAY_SIZE(tomConstantsSingle);
310 int tomNumMulti = ARRAY_SIZE(tomConstantsMulti);
311 int i;
312
313 V_VT(&testfile) = VT_BSTR;
314 V_BSTR(&testfile) = SysAllocString(filename);
315
316 for(i=0; i < tomNumSingle; i++)
317 {
319 create_interfaces(&w, &reOle, &txtDoc, &txtSel);
320 hres = ITextDocument_Open(txtDoc, &testfile, tomConstantsSingle[i], CP_ACP);
321 todo_wine ok(hres == S_OK, "ITextDocument_Open: Filename:test.txt Flags:0x%x Codepage:CP_ACP hres:0x%x\n",
322 tomConstantsSingle[i], hres);
323 release_interfaces(&w, &reOle, &txtDoc, &txtSel);
325
327 create_interfaces(&w, &reOle, &txtDoc, &txtSel);
328 hres = ITextDocument_Open(txtDoc, &testfile, tomConstantsSingle[i], CP_UTF8);
329 todo_wine ok(hres == S_OK, "ITextDocument_Open: Filename:test.txt Flags:0x%x Codepage:CP_UTF8 hres:0x%x\n",
330 tomConstantsSingle[i], hres);
331 release_interfaces(&w, &reOle, &txtDoc, &txtSel);
333 }
334
335 for(i=0; i < tomNumMulti; i++)
336 {
338 create_interfaces(&w, &reOle, &txtDoc, &txtSel);
339 hres = ITextDocument_Open(txtDoc, &testfile, tomConstantsMulti[i], CP_ACP);
340 todo_wine ok(hres == S_OK, "ITextDocument_Open: Filename:test.txt Flags:0x%x Codepage:CP_ACP hres:0x%x\n",
341 tomConstantsMulti[i], hres);
342 release_interfaces(&w, &reOle, &txtDoc, &txtSel);
344
346 create_interfaces(&w, &reOle, &txtDoc, &txtSel);
347 hres = ITextDocument_Open(txtDoc, &testfile, tomConstantsMulti[i], CP_UTF8);
348 todo_wine ok(hres == S_OK, "ITextDocument_Open: Filename:test.txt Flags:0x%x Codepage:CP_UTF8 hres:0x%x\n",
349 tomConstantsMulti[i], hres);
350 release_interfaces(&w, &reOle, &txtDoc, &txtSel);
352 }
353
354 create_interfaces(&w, &reOle, &txtDoc, &txtSel);
355 hres = ITextDocument_Open(txtDoc, &testfile, tomCreateAlways, CP_ACP);
356 todo_wine ok(hres == S_OK, "ITextDocument_Open should success Codepage:CP_ACP\n");
357 todo_wine ok(is_existing_file(filename), "ITextDocument_Open should create a file\n");
358 release_interfaces(&w, &reOle, &txtDoc, &txtSel);
360
361 create_interfaces(&w, &reOle, &txtDoc, &txtSel);
362 hres = ITextDocument_Open(txtDoc, &testfile, tomCreateAlways, CP_UTF8);
363 todo_wine ok(hres == S_OK, "ITextDocument_Open should success Codepage:CP_UTF8\n");
364 todo_wine ok(is_existing_file(filename), "ITextDocument_Open should create a file\n");
365 release_interfaces(&w, &reOle, &txtDoc, &txtSel);
367
368 create_interfaces(&w, &reOle, &txtDoc, &txtSel);
369 hres = ITextDocument_Open(txtDoc, &testfile, tomOpenAlways, CP_ACP);
370 todo_wine ok(hres == S_OK, "ITextDocument_Open should success Codepage:CP_ACP\n");
371 todo_wine ok(is_existing_file(filename), "ITextDocument_Open should create a file\n");
372 release_interfaces(&w, &reOle, &txtDoc, &txtSel);
374
375 create_interfaces(&w, &reOle, &txtDoc, &txtSel);
376 hres = ITextDocument_Open(txtDoc, &testfile, tomOpenAlways, CP_UTF8);
377 todo_wine ok(hres == S_OK, "ITextDocument_Open should success Codepage:CP_UTF8\n");
378 todo_wine ok(is_existing_file(filename), "ITextDocument_Open should create a file\n");
379 release_interfaces(&w, &reOle, &txtDoc, &txtSel);
381
382 create_interfaces(&w, &reOle, &txtDoc, &txtSel);
383 hres = ITextDocument_Open(txtDoc, &testfile, tomCreateNew, CP_ACP);
384 todo_wine ok(hres == S_OK, "ITextDocument_Open should success Codepage:CP_ACP\n");
385 todo_wine ok(is_existing_file(filename), "ITextDocument_Open should create a file\n");
386 release_interfaces(&w, &reOle, &txtDoc, &txtSel);
388
389 create_interfaces(&w, &reOle, &txtDoc, &txtSel);
390 hres = ITextDocument_Open(txtDoc, &testfile, tomCreateNew, CP_UTF8);
391 todo_wine ok(hres == S_OK, "ITextDocument_Open should success Codepage:CP_UTF8\n");
392 todo_wine ok(is_existing_file(filename), "ITextDocument_Open should create a file\n");
393 release_interfaces(&w, &reOle, &txtDoc, &txtSel);
395
396 create_interfaces(&w, &reOle, &txtDoc, &txtSel);
398 hres = ITextDocument_Open(txtDoc, &testfile, tomCreateNew, CP_ACP);
399 todo_wine ok(hres == HRESULT_FROM_WIN32(ERROR_FILE_EXISTS), "ITextDocument_Open should fail Codepage:CP_ACP\n");
400 release_interfaces(&w, &reOle, &txtDoc, &txtSel);
402
403 create_interfaces(&w, &reOle, &txtDoc, &txtSel);
405 hres = ITextDocument_Open(txtDoc, &testfile, tomCreateNew, CP_UTF8);
406 todo_wine ok(hres == HRESULT_FROM_WIN32(ERROR_FILE_EXISTS), "ITextDocument_Open should fail Codepage:CP_UTF8\n");
407 release_interfaces(&w, &reOle, &txtDoc, &txtSel);
409
410 create_interfaces(&w, &reOle, &txtDoc, &txtSel);
411 hres = ITextDocument_Open(txtDoc, &testfile, tomOpenExisting, CP_ACP);
412 todo_wine ok(hres == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), "ITextDocument_Open should fail Codepage:CP_ACP\n");
413 release_interfaces(&w, &reOle, &txtDoc, &txtSel);
414
415 create_interfaces(&w, &reOle, &txtDoc, &txtSel);
416 hres = ITextDocument_Open(txtDoc, &testfile, tomOpenExisting, CP_UTF8);
417 todo_wine ok(hres == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), "ITextDocument_Open should fail Codepage:CP_UTF8\n");
418 release_interfaces(&w, &reOle, &txtDoc, &txtSel);
419
420 create_interfaces(&w, &reOle, &txtDoc, &txtSel);
422 hres = ITextDocument_Open(txtDoc, &testfile, tomText, CP_ACP);
423todo_wine {
424 ok(hres == S_OK, "got 0x%08x\n", hres);
425 ok(is_existing_file(filename) == TRUE, "a file should be created default\n");
426}
427 release_interfaces(&w, &reOle, &txtDoc, &txtSel);
429
430 /* test of share mode */
432 create_interfaces(&w, &reOle, &txtDoc, &txtSel);
433 hres = ITextDocument_Open(txtDoc, &testfile, tomShareDenyRead, CP_ACP);
435 ok(hres == S_OK, "got 0x%08x\n", hres);
436 SetLastError(0xdeadbeef);
439 todo_wine ok(GetLastError() == ERROR_SHARING_VIOLATION, "ITextDocument_Open should fail\n");
441 release_interfaces(&w, &reOle, &txtDoc, &txtSel);
443
445 create_interfaces(&w, &reOle, &txtDoc, &txtSel);
446 hres = ITextDocument_Open(txtDoc, &testfile, tomShareDenyWrite, CP_ACP);
448 ok(hres == S_OK, "got 0x%08x\n", hres);
449 SetLastError(0xdeadbeef);
452 todo_wine ok(GetLastError() == ERROR_SHARING_VIOLATION, "ITextDocument_Open should fail\n");
454 release_interfaces(&w, &reOle, &txtDoc, &txtSel);
456
458 create_interfaces(&w, &reOle, &txtDoc, &txtSel);
459 SetLastError(0xdeadbeef);
460 hres = ITextDocument_Open(txtDoc, &testfile, tomShareDenyWrite|tomShareDenyRead, CP_ACP);
462 ok(hres == S_OK, "got 0x%08x\n", hres);
465 todo_wine ok(GetLastError() == ERROR_SHARING_VIOLATION, "ITextDocument_Open should fail\n");
467 release_interfaces(&w, &reOle, &txtDoc, &txtSel);
469
470 /* tests to check the content */
473 WriteFile(hFile, chACP, sizeof(chACP)-sizeof(CHAR), &dw, NULL);
475 create_interfaces(&w, &reOle, &txtDoc, &txtSel);
476 hres = ITextDocument_Open(txtDoc, &testfile, tomReadOnly, CP_ACP);
478 ok(hres == S_OK, "got 0x%08x\n", hres);
479 result = SendMessageA(w, WM_GETTEXT, 1024, (LPARAM)bufACP);
480 todo_wine ok(result == 12, "ITextDocument_Open: Test ASCII returned %d, expected 12\n", result);
481 result = strcmp(bufACP, chACP);
482 todo_wine ok(result == 0, "ITextDocument_Open: Test ASCII set wrong text: Result: %s\n", bufACP);
483 release_interfaces(&w, &reOle, &txtDoc, &txtSel);
485
488 WriteFile(hFile, chUTF8, sizeof(chUTF8)-sizeof(CHAR), &dw, NULL);
490 create_interfaces(&w, &reOle, &txtDoc, &txtSel);
491 hres = ITextDocument_Open(txtDoc, &testfile, tomReadOnly, CP_UTF8);
493 ok(hres == S_OK, "got 0x%08x\n", hres);
494 result = SendMessageA(w, WM_GETTEXT, 1024, (LPARAM)bufACP);
495 todo_wine ok(result == 15, "ITextDocument_Open: Test UTF-8 returned %d, expected 15\n", result);
496 result = strcmp(bufACP, &chUTF8[3]);
497 todo_wine ok(result == 0, "ITextDocument_Open: Test UTF-8 set wrong text: Result: %s\n", bufACP);
498 release_interfaces(&w, &reOle, &txtDoc, &txtSel);
500
503 WriteFile(hFile, chUTF16, sizeof(chUTF16)-sizeof(WCHAR), &dw, NULL);
505 create_interfaces(&w, &reOle, &txtDoc, &txtSel);
506 hres = ITextDocument_Open(txtDoc, &testfile, tomReadOnly, 1200);
508 ok(hres == S_OK, "got 0x%08x\n", hres);
509 result = SendMessageW(w, WM_GETTEXT, 1024, (LPARAM)bufUnicode);
510 todo_wine ok(result == 12, "ITextDocument_Open: Test UTF-16 returned %d, expected 12\n", result);
511 result = lstrcmpW(bufUnicode, &chUTF16[1]);
512 todo_wine ok(result == 0, "ITextDocument_Open: Test UTF-16 set wrong text: Result: %s\n", wine_dbgstr_w(bufUnicode));
513 release_interfaces(&w, &reOle, &txtDoc, &txtSel);
515
516 VariantClear(&testfile);
517}
518
519static void test_GetText(void)
520{
521 HWND w;
522 IRichEditOle *reOle = NULL;
523 ITextDocument *txtDoc = NULL;
524 ITextSelection *txtSel = NULL;
526 BSTR bstr = NULL;
527 int first, lim;
528 static const CHAR test_text1[] = "TestSomeText";
529 static const WCHAR bufW1[] = {'T', 'e', 's', 't', 0};
530 static const WCHAR bufW2[] = {'T', 'e', 'x', 't', '\r', 0};
531 static const WCHAR bufW3[] = {'T', 'e', 'x', 't', 0};
532 static const WCHAR bufW4[] = {'T', 'e', 's', 't', 'S', 'o', 'm',
533 'e', 'T', 'e', 'x', 't', '\r', 0};
534 static const WCHAR bufW5[] = {'\r', 0};
535 static const WCHAR bufW6[] = {'T','e','s','t','S','o','m','e','T',0};
536 BOOL is64bit = sizeof(void *) > sizeof(int);
538
539 create_interfaces(&w, &reOle, &txtDoc, &txtSel);
540 SendMessageA(w, WM_SETTEXT, 0, (LPARAM)test_text1);
541
542 /* ITextSelection */
543 first = 0; lim = 4;
545 hres = ITextSelection_GetText(txtSel, &bstr);
546 ok(hres == S_OK, "ITextSelection_GetText\n");
547 ok(!lstrcmpW(bstr, bufW1), "got wrong text: %s\n", wine_dbgstr_w(bstr));
548 SysFreeString(bstr);
549
550 first = 4; lim = 0;
552 hres = ITextSelection_GetText(txtSel, &bstr);
553 ok(hres == S_OK, "ITextSelection_GetText\n");
554 ok(!lstrcmpW(bstr, bufW1), "got wrong text: %s\n", wine_dbgstr_w(bstr));
555 SysFreeString(bstr);
556
557 first = 1; lim = 1;
559 hres = ITextSelection_GetText(txtSel, &bstr);
560 ok(hres == S_OK, "ITextSelection_GetText\n");
561 ok(!bstr, "got wrong text: %s\n", wine_dbgstr_w(bstr));
562
563 if (!is64bit)
564 {
565 hres = ITextSelection_GetText(txtSel, NULL);
566 ok(hres == E_INVALIDARG, "ITextSelection_GetText\n");
567 }
568
569 first = 8; lim = 12;
571 hres = ITextSelection_GetText(txtSel, &bstr);
572 ok(hres == S_OK, "ITextSelection_GetText\n");
573 ok(!lstrcmpW(bstr, bufW3), "got wrong text: %s\n", wine_dbgstr_w(bstr));
574 SysFreeString(bstr);
575
576 first = 8; lim = 13;
578 hres = ITextSelection_GetText(txtSel, &bstr);
579 ok(hres == S_OK, "ITextSelection_GetText\n");
580 ok(!lstrcmpW(bstr, bufW2), "got wrong text: %s\n", wine_dbgstr_w(bstr));
581 SysFreeString(bstr);
582
583 first = 12; lim = 13;
585 hres = ITextSelection_GetText(txtSel, &bstr);
586 ok(hres == S_OK, "ITextSelection_GetText\n");
587 ok(!lstrcmpW(bstr, bufW5), "got wrong text: %s\n", wine_dbgstr_w(bstr));
588 SysFreeString(bstr);
589
590 first = 0; lim = -1;
592 hres = ITextSelection_GetText(txtSel, &bstr);
593 ok(hres == S_OK, "ITextSelection_GetText\n");
594 ok(!lstrcmpW(bstr, bufW4), "got wrong text: %s\n", wine_dbgstr_w(bstr));
595 SysFreeString(bstr);
596
597 first = -1; lim = 9;
599 hres = ITextSelection_GetText(txtSel, &bstr);
600 ok(hres == S_OK, "ITextSelection_GetText\n");
601 ok(!bstr, "got wrong text: %s\n", wine_dbgstr_w(bstr));
602
603 /* ITextRange */
604 hres = ITextDocument_Range(txtDoc, 0, 4, &range);
605 ok(hres == S_OK, "got 0x%08x\n", hres);
606 hres = ITextRange_GetText(range, &bstr);
607 ok(hres == S_OK, "got 0x%08x\n", hres);
608 ok(!lstrcmpW(bstr, bufW1), "got wrong text: %s\n", wine_dbgstr_w(bstr));
609
610 SysFreeString(bstr);
611 ITextRange_Release(range);
612
613 hres = ITextDocument_Range(txtDoc, 4, 0, &range);
614 ok(hres == S_OK, "got 0x%08x\n", hres);
615 hres = ITextRange_GetText(range, &bstr);
616 ok(hres == S_OK, "got 0x%08x\n", hres);
617 ok(!lstrcmpW(bstr, bufW1), "got wrong text: %s\n", wine_dbgstr_w(bstr));
618
619 SysFreeString(bstr);
620 ITextRange_Release(range);
621
622 hres = ITextDocument_Range(txtDoc, 1, 1, &range);
623 ok(hres == S_OK, "got 0x%08x\n", hres);
624 hres = ITextRange_GetText(range, &bstr);
625 ok(hres == S_OK, "got 0x%08x\n", hres);
626 ok(!bstr, "got wrong text: %s\n", wine_dbgstr_w(bstr));
627 if (!is64bit)
628 {
629 hres = ITextRange_GetText(range, NULL);
630 ok(hres == E_INVALIDARG, "got 0x%08x\n", hres);
631 }
632 ITextRange_Release(range);
633
634 hres = ITextDocument_Range(txtDoc, 8, 12, &range);
635 ok(hres == S_OK, "got 0x%08x\n", hres);
636 hres = ITextRange_GetText(range, &bstr);
637 ok(hres == S_OK, "got 0x%08x\n", hres);
638 ok(!lstrcmpW(bstr, bufW3), "got wrong text: %s\n", wine_dbgstr_w(bstr));
639
640 SysFreeString(bstr);
641 ITextRange_Release(range);
642
643 hres = ITextDocument_Range(txtDoc, 8, 13, &range);
644 ok(hres == S_OK, "got 0x%08x\n", hres);
645 hres = ITextRange_GetText(range, &bstr);
646 ok(hres == S_OK, "got 0x%08x\n", hres);
647 ok(!lstrcmpW(bstr, bufW2), "got wrong text: %s\n", wine_dbgstr_w(bstr));
648
649 SysFreeString(bstr);
650 ITextRange_Release(range);
651
652 hres = ITextDocument_Range(txtDoc, 12, 13, &range);
653 ok(hres == S_OK, "got 0x%08x\n", hres);
654 hres = ITextRange_GetText(range, &bstr);
655 ok(hres == S_OK, "got 0x%08x\n", hres);
656 ok(!lstrcmpW(bstr, bufW5), "got wrong text: %s\n", wine_dbgstr_w(bstr));
657
658 SysFreeString(bstr);
659 ITextRange_Release(range);
660
661 hres = ITextDocument_Range(txtDoc, 0, -1, &range);
662 ok(hres == S_OK, "got 0x%08x\n", hres);
663 hres = ITextRange_GetText(range, &bstr);
664 ok(hres == S_OK, "got 0x%08x\n", hres);
665 ok(!bstr, "got wrong text: %s\n", wine_dbgstr_w(bstr));
666 ITextRange_Release(range);
667
668 hres = ITextDocument_Range(txtDoc, -1, 9, &range);
669 ok(hres == S_OK, "got 0x%08x\n", hres);
670 hres = ITextRange_GetText(range, &bstr);
671 ok(hres == S_OK, "got 0x%08x\n", hres);
672 ok(!lstrcmpW(bstr, bufW6), "got wrong text: %s\n", wine_dbgstr_w(bstr));
673
674 SysFreeString(bstr);
675
676 release_interfaces(&w, &reOle, &txtDoc, NULL);
677
678 /* detached selection/range */
679 if (is64bit) {
680 bstr = (void*)0xdeadbeef;
681 hres = ITextSelection_GetText(txtSel, &bstr);
682 ok(hres == CO_E_RELEASED, "got 0x%08x\n", hres);
684 ok(bstr == NULL, "got %p\n", bstr);
685
686 bstr = (void*)0xdeadbeef;
687 hres = ITextRange_GetText(range, &bstr);
688 ok(hres == CO_E_RELEASED, "got 0x%08x\n", hres);
690 ok(bstr == NULL, "got %p\n", bstr);
691 }
692 else {
693 hres = ITextSelection_GetText(txtSel, NULL);
694 ok(hres == CO_E_RELEASED, "got 0x%08x\n", hres);
695
696 hres = ITextRange_GetText(range, NULL);
697 ok(hres == CO_E_RELEASED, "got 0x%08x\n", hres);
698 }
699
700 ITextRange_Release(range);
701 ITextSelection_Release(txtSel);
702}
703
705{
706 static const CHAR test_text1[] = "TestSomeText";
707 HWND w;
708 IRichEditOle *reOle = NULL;
709 ITextDocument *txtDoc = NULL;
710 ITextRange *txtRge, *range2;
712 LONG value;
713
714 create_interfaces(&w, &reOle, &txtDoc, NULL);
715 hres = ITextDocument_Range(txtDoc, 0, 0, &txtRge);
716 ok(hres == S_OK, "ITextDocument_Range fails 0x%x.\n", hres);
717 EXPECT_REF(txtRge, 1);
718
719 hres = ITextDocument_Range(txtDoc, 0, 0, &range2);
720 ok(hres == S_OK, "ITextDocument_Range fails 0x%x.\n", hres);
721 ok(range2 != txtRge, "A new pointer should be returned\n");
722 ITextRange_Release(range2);
723
724 hres = ITextDocument_Range(txtDoc, 0, 0, NULL);
725 ok(hres == E_INVALIDARG, "ITextDocument_Range should fail 0x%x.\n", hres);
726
727 SendMessageA(w, WM_SETTEXT, 0, (LPARAM)test_text1);
728
729 hres = ITextDocument_Range(txtDoc, 8, 30, &range2);
730 ok(hres == S_OK, "ITextDocument_Range fails 0x%x.\n", hres);
731 hres = ITextRange_GetStart(range2, &value);
732 ok(hres == S_OK, "got 0x%08x\n", hres);
733 ok(value == 8, "got %d\n", value);
734
735 hres = ITextRange_GetEnd(range2, &value);
736 ok(hres == S_OK, "got 0x%08x\n", hres);
737 ok(value == 13, "got %d\n", value);
738 ITextRange_Release(range2);
739
740 release_interfaces(&w, &reOle, &txtDoc, NULL);
741 hres = ITextRange_CanEdit(txtRge, NULL);
742 ok(hres == CO_E_RELEASED, "ITextRange after ITextDocument destroyed\n");
743 ITextRange_Release(txtRge);
744}
745
746static void test_ITextRange_GetChar(void)
747{
748 HWND w;
749 IRichEditOle *reOle = NULL;
750 ITextDocument *txtDoc = NULL;
751 ITextRange *txtRge = NULL;
753 LONG pch;
754 int first, lim;
755 static const CHAR test_text1[] = "TestSomeText";
756
757 first = 0, lim = 4;
758 create_interfaces(&w, &reOle, &txtDoc, NULL);
759 SendMessageA(w, WM_SETTEXT, 0, (LPARAM)test_text1);
760 hres = ITextDocument_Range(txtDoc, first, lim, &txtRge);
761 ok(hres == S_OK, "got 0x%08x\n", hres);
762 pch = 0xdeadbeef;
763 hres = ITextRange_GetChar(txtRge, &pch);
764 ok(hres == S_OK, "ITextRange_GetChar\n");
765 ok(pch == 'T', "got wrong char: %c\n", pch);
766 ITextRange_Release(txtRge);
767 release_interfaces(&w, &reOle, &txtDoc, NULL);
768
769 first = 0; lim = 0;
770 create_interfaces(&w, &reOle, &txtDoc, NULL);
771 SendMessageA(w, WM_SETTEXT, 0, (LPARAM)test_text1);
772 hres = ITextDocument_Range(txtDoc, first, lim, &txtRge);
773 ok(hres == S_OK, "got 0x%08x\n", hres);
774 pch = 0xdeadbeef;
775 hres = ITextRange_GetChar(txtRge, &pch);
776 ok(hres == S_OK, "ITextRange_GetChar\n");
777 ok(pch == 'T', "got wrong char: %c\n", pch);
778 ITextRange_Release(txtRge);
779 release_interfaces(&w, &reOle, &txtDoc, NULL);
780
781 first = 12; lim = 12;
782 create_interfaces(&w, &reOle, &txtDoc, NULL);
783 SendMessageA(w, WM_SETTEXT, 0, (LPARAM)test_text1);
784 hres = ITextDocument_Range(txtDoc, first, lim, &txtRge);
785 ok(hres == S_OK, "got 0x%08x\n", hres);
786 pch = 0xdeadbeef;
787 hres = ITextRange_GetChar(txtRge, &pch);
788 ok(hres == S_OK, "ITextRange_GetChar\n");
789 ok(pch == '\r', "got wrong char: %c\n", pch);
790 ITextRange_Release(txtRge);
791 release_interfaces(&w, &reOle, &txtDoc, NULL);
792
793 first = 13; lim = 13;
794 create_interfaces(&w, &reOle, &txtDoc, NULL);
795 SendMessageA(w, WM_SETTEXT, 0, (LPARAM)test_text1);
796 hres = ITextDocument_Range(txtDoc, first, lim, &txtRge);
797 ok(hres == S_OK, "got 0x%08x\n", hres);
798 pch = 0xdeadbeef;
799 hres = ITextRange_GetChar(txtRge, &pch);
800 ok(hres == S_OK, "ITextRange_GetChar\n");
801 ok(pch == '\r', "got wrong char: %c\n", pch);
802 ITextRange_Release(txtRge);
803 release_interfaces(&w, &reOle, &txtDoc, NULL);
804
805 create_interfaces(&w, &reOle, &txtDoc, NULL);
806 SendMessageA(w, WM_SETTEXT, 0, (LPARAM)test_text1);
807 first = 12; lim = 12;
808 hres = ITextDocument_Range(txtDoc, first, lim, &txtRge);
809 ok(hres == S_OK, "got 0x%08x\n", hres);
810 hres = ITextRange_GetChar(txtRge, NULL);
811 ok(hres == E_INVALIDARG, "ITextRange_GetChar\n");
812
813 release_interfaces(&w, &reOle, &txtDoc, NULL);
814
815 hres = ITextRange_GetChar(txtRge, NULL);
816 ok(hres == CO_E_RELEASED, "got 0x%08x\n", hres);
817
818 hres = ITextRange_GetChar(txtRge, &pch);
819 ok(hres == CO_E_RELEASED, "got 0x%08x\n", hres);
820
821 ITextRange_Release(txtRge);
822}
823
824/* Helper function for testing ITextRange_ScrollIntoView */
825static void check_range(HWND w, ITextDocument* doc, int first, int lim,
826 LONG bStart, int expected_nonzero)
827{
828 SCROLLINFO si;
829 ITextRange *txtRge = NULL;
831
832 si.cbSize = sizeof(SCROLLINFO);
833 si.fMask = SIF_POS | SIF_RANGE;
834
835 hres = ITextDocument_Range(doc, first, lim, &txtRge);
836 ok(hres == S_OK, "got 0x%08x\n", hres);
837 hres = ITextRange_ScrollIntoView(txtRge, bStart);
838 ok(hres == S_OK, "got 0x%08x\n", hres);
839 GetScrollInfo(w, SB_VERT, &si);
840 if (expected_nonzero) {
841 ok(si.nPos != 0,
842 "Scrollbar at 0, should be >0. (TextRange %d-%d, scroll range %d-%d.)\n",
843 first, lim, si.nMin, si.nMax);
844 } else {
845 ok(si.nPos == 0,
846 "Scrollbar at %d, should be 0. (TextRange %d-%d, scroll range %d-%d.)\n",
847 si.nPos, first, lim, si.nMin, si.nMax);
848 }
849}
850
852{
853 HWND w;
854 IRichEditOle *reOle = NULL;
855 ITextDocument *txtDoc = NULL;
856 ITextRange *txtRge = NULL;
858 static const CHAR test_text1[] = "1\n2\n3\n4\n5\n6\n7\n8\n9\n10";
859
860 create_interfaces(&w, &reOle, &txtDoc, NULL);
861 SendMessageA(w, WM_SETTEXT, 0, (LPARAM)test_text1);
862
863 /* Scroll to the top. */
864 check_range(w, txtDoc, 0, 1, tomStart, 0);
865 check_range(w, txtDoc, 0, 1, tomEnd, 0);
866
867 /* Scroll to the bottom. */
868 check_range(w, txtDoc, 19, 20, tomStart, 1);
869 check_range(w, txtDoc, 19, 20, tomEnd, 1);
870
871 /* Back up to the top. */
872 check_range(w, txtDoc, 0, 1, tomStart, 0);
873 check_range(w, txtDoc, 0, 1, tomEnd, 0);
874
875 /* Large range */
876 check_range(w, txtDoc, 0, 20, tomStart, 0);
877 check_range(w, txtDoc, 0, 20, tomEnd, 1);
878
879 hres = ITextDocument_Range(txtDoc, 0, 0, &txtRge);
880 ok(hres == S_OK, "got 0x%08x\n", hres);
881 release_interfaces(&w, &reOle, &txtDoc, NULL);
882 hres = ITextRange_ScrollIntoView(txtRge, tomStart);
883 ok(hres == CO_E_RELEASED, "got 0x%08x\n", hres);
884 ITextRange_Release(txtRge);
885}
886
888{
889 HWND w;
890 IRichEditOle *reOle = NULL;
891 ITextDocument *txtDoc = NULL;
892 ITextSelection *txtSel = NULL;
894 LONG pch;
895 int first, lim;
896 static const CHAR test_text1[] = "TestSomeText";
897
898 create_interfaces(&w, &reOle, &txtDoc, &txtSel);
899 SendMessageA(w, WM_SETTEXT, 0, (LPARAM)test_text1);
900
901 first = 0; lim = 4;
903 pch = 0xdeadbeef;
904 hres = ITextSelection_GetChar(txtSel, &pch);
905 ok(hres == S_OK, "ITextSelection_GetChar\n");
906 ok(pch == 'T', "got wrong char: %c\n", pch);
907
908 first = 0; lim = 0;
910 pch = 0xdeadbeef;
911 hres = ITextSelection_GetChar(txtSel, &pch);
912 ok(hres == S_OK, "ITextSelection_GetChar\n");
913 ok(pch == 'T', "got wrong char: %c\n", pch);
914
915 first = 12; lim = 12;
917 pch = 0xdeadbeef;
918 hres = ITextSelection_GetChar(txtSel, &pch);
919 ok(hres == S_OK, "ITextSelection_GetChar\n");
920 ok(pch == '\r', "got wrong char: %c\n", pch);
921
922 first = 13; lim = 13;
924 pch = 0xdeadbeef;
925 hres = ITextSelection_GetChar(txtSel, &pch);
926 ok(hres == S_OK, "ITextSelection_GetChar\n");
927 ok(pch == '\r', "got wrong char: %c\n", pch);
928
929 hres = ITextSelection_GetChar(txtSel, NULL);
930 ok(hres == E_INVALIDARG, "ITextSelection_GetChar\n");
931
932 release_interfaces(&w, &reOle, &txtDoc, NULL);
933
934 hres = ITextSelection_GetChar(txtSel, NULL);
935 ok(hres == CO_E_RELEASED, "got 0x%08x\n", hres);
936
937 hres = ITextSelection_GetChar(txtSel, &pch);
938 ok(hres == CO_E_RELEASED, "got 0x%08x\n", hres);
939
940 ITextSelection_Release(txtSel);
941}
942
944{
945 HWND w;
946 IRichEditOle *reOle = NULL;
947 ITextDocument *txtDoc = NULL;
948 ITextRange *txtRge = NULL;
950 int first, lim, start, end;
951 static const CHAR test_text1[] = "TestSomeText";
952
953 create_interfaces(&w, &reOle, &txtDoc, NULL);
954 SendMessageA(w, WM_SETTEXT, 0, (LPARAM)test_text1);
955
956 first = 1; lim = 6;
957 hres = ITextDocument_Range(txtDoc, first, lim, &txtRge);
958 ok(hres == S_OK, "got 0x%08x\n", hres);
959 start = 0xdeadbeef;
960 hres = ITextRange_GetStart(txtRge, &start);
961 ok(hres == S_OK, "ITextRange_GetStart\n");
962 ok(start == 1, "got wrong start value: %d\n", start);
963 end = 0xdeadbeef;
964 hres = ITextRange_GetEnd(txtRge, &end);
965 ok(hres == S_OK, "ITextRange_GetEnd\n");
966 ok(end == 6, "got wrong end value: %d\n", end);
967 ITextRange_Release(txtRge);
968
969 first = 6; lim = 1;
970 hres = ITextDocument_Range(txtDoc, first, lim, &txtRge);
971 ok(hres == S_OK, "got 0x%08x\n", hres);
972 start = 0xdeadbeef;
973 hres = ITextRange_GetStart(txtRge, &start);
974 ok(hres == S_OK, "ITextRange_GetStart\n");
975 ok(start == 1, "got wrong start value: %d\n", start);
976 end = 0xdeadbeef;
977 hres = ITextRange_GetEnd(txtRge, &end);
978 ok(hres == S_OK, "ITextRange_GetEnd\n");
979 ok(end == 6, "got wrong end value: %d\n", end);
980 ITextRange_Release(txtRge);
981
982 first = -1; lim = 13;
983 hres = ITextDocument_Range(txtDoc, first, lim, &txtRge);
984 ok(hres == S_OK, "got 0x%08x\n", hres);
985 start = 0xdeadbeef;
986 hres = ITextRange_GetStart(txtRge, &start);
987 ok(hres == S_OK, "ITextRange_GetStart\n");
988 ok(start == 0, "got wrong start value: %d\n", start);
989 end = 0xdeadbeef;
990 hres = ITextRange_GetEnd(txtRge, &end);
991 ok(hres == S_OK, "ITextRange_GetEnd\n");
992 ok(end == 13, "got wrong end value: %d\n", end);
993 ITextRange_Release(txtRge);
994
995 first = 13; lim = 13;
996 hres = ITextDocument_Range(txtDoc, first, lim, &txtRge);
997 ok(hres == S_OK, "got 0x%08x\n", hres);
998 start = 0xdeadbeef;
999 hres = ITextRange_GetStart(txtRge, &start);
1000 ok(hres == S_OK, "ITextRange_GetStart\n");
1001 ok(start == 12, "got wrong start value: %d\n", start);
1002 end = 0xdeadbeef;
1003 hres = ITextRange_GetEnd(txtRge, &end);
1004 ok(hres == S_OK, "ITextRange_GetEnd\n");
1005 ok(end == 12, "got wrong end value: %d\n", end);
1006
1007 /* SetStart */
1008 hres = ITextRange_SetStart(txtRge, 0);
1009 ok(hres == S_OK, "got 0x%08x\n", hres);
1010
1011 /* same value */
1012 hres = ITextRange_SetStart(txtRge, 0);
1013 ok(hres == S_FALSE, "got 0x%08x\n", hres);
1014
1015 hres = ITextRange_SetStart(txtRge, 1);
1016 ok(hres == S_OK, "got 0x%08x\n", hres);
1017
1018 /* negative resets to 0, return value is S_FALSE when
1019 position wasn't changed */
1020 hres = ITextRange_SetStart(txtRge, -1);
1021 ok(hres == S_OK, "got 0x%08x\n", hres);
1022
1023 hres = ITextRange_SetStart(txtRge, -1);
1024 ok(hres == S_FALSE, "got 0x%08x\n", hres);
1025
1026 hres = ITextRange_SetStart(txtRge, 0);
1027 ok(hres == S_FALSE, "got 0x%08x\n", hres);
1028
1029 start = -1;
1030 hres = ITextRange_GetStart(txtRge, &start);
1031 ok(hres == S_OK, "got 0x%08x\n", hres);
1032 ok(start == 0, "got %d\n", start);
1033
1034 /* greater than initial end, but less than total char count */
1035 hres = ITextRange_SetStart(txtRge, 1);
1036 ok(hres == S_OK, "got 0x%08x\n", hres);
1037
1038 hres = ITextRange_SetEnd(txtRge, 3);
1039 ok(hres == S_OK, "got 0x%08x\n", hres);
1040
1041 hres = ITextRange_SetStart(txtRge, 10);
1042 ok(hres == S_OK, "got 0x%08x\n", hres);
1043
1044 start = 0;
1045 hres = ITextRange_GetStart(txtRge, &start);
1046 ok(hres == S_OK, "got 0x%08x\n", hres);
1047 ok(start == 10, "got %d\n", start);
1048
1049 end = 0;
1050 hres = ITextRange_GetEnd(txtRge, &end);
1051 ok(hres == S_OK, "got 0x%08x\n", hres);
1052 ok(end == 10, "got %d\n", end);
1053
1054 /* more that total text length */
1055 hres = ITextRange_SetStart(txtRge, 50);
1056 ok(hres == S_OK, "got 0x%08x\n", hres);
1057
1058 start = 0;
1059 hres = ITextRange_GetStart(txtRge, &start);
1060 ok(hres == S_OK, "got 0x%08x\n", hres);
1061 ok(start == 12, "got %d\n", start);
1062
1063 end = 0;
1064 hres = ITextRange_GetEnd(txtRge, &end);
1065 ok(hres == S_OK, "got 0x%08x\n", hres);
1066 ok(end == 12, "got %d\n", end);
1067
1068 /* SetEnd */
1069 hres = ITextRange_SetStart(txtRge, 0);
1070 ok(hres == S_OK, "got 0x%08x\n", hres);
1071
1072 /* same value */
1073 hres = ITextRange_SetEnd(txtRge, 5);
1074 ok(hres == S_OK, "got 0x%08x\n", hres);
1075
1076 hres = ITextRange_SetEnd(txtRge, 5);
1077 ok(hres == S_FALSE, "got 0x%08x\n", hres);
1078
1079 /* negative resets to 0 */
1080 hres = ITextRange_SetEnd(txtRge, -1);
1081 ok(hres == S_OK, "got 0x%08x\n", hres);
1082
1083 end = -1;
1084 hres = ITextRange_GetEnd(txtRge, &end);
1085 ok(hres == S_OK, "got 0x%08x\n", hres);
1086 ok(end == 0, "got %d\n", end);
1087
1088 start = -1;
1089 hres = ITextRange_GetStart(txtRge, &start);
1090 ok(hres == S_OK, "got 0x%08x\n", hres);
1091 ok(start == 0, "got %d\n", start);
1092
1093 /* greater than initial end, but less than total char count */
1094 hres = ITextRange_SetStart(txtRge, 3);
1095 ok(hres == S_OK, "got 0x%08x\n", hres);
1096
1097 hres = ITextRange_SetEnd(txtRge, 1);
1098 ok(hres == S_OK, "got 0x%08x\n", hres);
1099
1100 start = 0;
1101 hres = ITextRange_GetStart(txtRge, &start);
1102 ok(hres == S_OK, "got 0x%08x\n", hres);
1103 ok(start == 1, "got %d\n", start);
1104
1105 end = 0;
1106 hres = ITextRange_GetEnd(txtRge, &end);
1107 ok(hres == S_OK, "got 0x%08x\n", hres);
1108 ok(end == 1, "got %d\n", end);
1109
1110 /* more than total count */
1111 hres = ITextRange_SetEnd(txtRge, 50);
1112 ok(hres == S_OK, "got 0x%08x\n", hres);
1113
1114 start = 0;
1115 hres = ITextRange_GetStart(txtRge, &start);
1116 ok(hres == S_OK, "got 0x%08x\n", hres);
1117 ok(start == 1, "got %d\n", start);
1118
1119 end = 0;
1120 hres = ITextRange_GetEnd(txtRge, &end);
1121 ok(hres == S_OK, "got 0x%08x\n", hres);
1122 ok(end == 13, "got %d\n", end);
1123
1124 /* zero */
1125 hres = ITextRange_SetEnd(txtRge, 0);
1126 ok(hres == S_OK, "got 0x%08x\n", hres);
1127
1128 start = 0;
1129 hres = ITextRange_GetStart(txtRge, &start);
1130 ok(hres == S_OK, "got 0x%08x\n", hres);
1131 ok(start == 0, "got %d\n", start);
1132
1133 end = 0;
1134 hres = ITextRange_GetEnd(txtRge, &end);
1135 ok(hres == S_OK, "got 0x%08x\n", hres);
1136 ok(end == 0, "got %d\n", end);
1137
1138 release_interfaces(&w, &reOle, &txtDoc, NULL);
1139
1140 /* detached range */
1141 hres = ITextRange_SetStart(txtRge, 0);
1142 ok(hres == CO_E_RELEASED, "got 0x%08x\n", hres);
1143
1144 hres = ITextRange_SetEnd(txtRge, 3);
1145 ok(hres == CO_E_RELEASED, "got 0x%08x\n", hres);
1146
1147 hres = ITextRange_GetStart(txtRge, &start);
1148 ok(hres == CO_E_RELEASED, "got 0x%08x\n", hres);
1149
1150 hres = ITextRange_GetStart(txtRge, NULL);
1151 ok(hres == CO_E_RELEASED, "got 0x%08x\n", hres);
1152
1153 hres = ITextRange_GetEnd(txtRge, &end);
1154 ok(hres == CO_E_RELEASED, "got 0x%08x\n", hres);
1155
1156 hres = ITextRange_GetEnd(txtRge, NULL);
1157 ok(hres == CO_E_RELEASED, "got 0x%08x\n", hres);
1158
1159 ITextRange_Release(txtRge);
1160}
1161
1163{
1164 HWND w;
1165 IRichEditOle *reOle = NULL;
1166 ITextDocument *txtDoc = NULL;
1167 ITextSelection *txtSel = NULL;
1168 HRESULT hres;
1169 int first, lim, start, end;
1170 static const CHAR test_text1[] = "TestSomeText";
1171
1172 create_interfaces(&w, &reOle, &txtDoc, &txtSel);
1173 SendMessageA(w, WM_SETTEXT, 0, (LPARAM)test_text1);
1174
1175 first = 2; lim = 5;
1176 SendMessageA(w, EM_SETSEL, first, lim);
1177 start = 0xdeadbeef;
1178 hres = ITextSelection_GetStart(txtSel, &start);
1179 ok(hres == S_OK, "ITextSelection_GetStart\n");
1180 ok(start == 2, "got wrong start value: %d\n", start);
1181 end = 0xdeadbeef;
1182 hres = ITextSelection_GetEnd(txtSel, &end);
1183 ok(hres == S_OK, "ITextSelection_GetEnd\n");
1184 ok(end == 5, "got wrong end value: %d\n", end);
1185
1186 first = 5; lim = 2;
1187 SendMessageA(w, EM_SETSEL, first, lim);
1188 start = 0xdeadbeef;
1189 hres = ITextSelection_GetStart(txtSel, &start);
1190 ok(hres == S_OK, "ITextSelection_GetStart\n");
1191 ok(start == 2, "got wrong start value: %d\n", start);
1192 end = 0xdeadbeef;
1193 hres = ITextSelection_GetEnd(txtSel, &end);
1194 ok(hres == S_OK, "ITextSelection_GetEnd\n");
1195 ok(end == 5, "got wrong end value: %d\n", end);
1196
1197 first = 0; lim = -1;
1198 SendMessageA(w, EM_SETSEL, first, lim);
1199 start = 0xdeadbeef;
1200 hres = ITextSelection_GetStart(txtSel, &start);
1201 ok(hres == S_OK, "ITextSelection_GetStart\n");
1202 ok(start == 0, "got wrong start value: %d\n", start);
1203 end = 0xdeadbeef;
1204 hres = ITextSelection_GetEnd(txtSel, &end);
1205 ok(hres == S_OK, "ITextSelection_GetEnd\n");
1206 ok(end == 13, "got wrong end value: %d\n", end);
1207
1208 first = 13; lim = 13;
1209 SendMessageA(w, EM_SETSEL, first, lim);
1210 start = 0xdeadbeef;
1211 hres = ITextSelection_GetStart(txtSel, &start);
1212 ok(hres == S_OK, "ITextSelection_GetStart\n");
1213 ok(start == 12, "got wrong start value: %d\n", start);
1214 end = 0xdeadbeef;
1215 hres = ITextSelection_GetEnd(txtSel, &end);
1216 ok(hres == S_OK, "ITextSelection_GetEnd\n");
1217 ok(end == 12, "got wrong end value: %d\n", end);
1218
1219 /* SetStart/SetEnd */
1220 hres = ITextSelection_SetStart(txtSel, 0);
1221 ok(hres == S_OK, "got 0x%08x\n", hres);
1222
1223 /* same value */
1224 hres = ITextSelection_SetStart(txtSel, 0);
1225 ok(hres == S_FALSE, "got 0x%08x\n", hres);
1226
1227 hres = ITextSelection_SetStart(txtSel, 1);
1228 ok(hres == S_OK, "got 0x%08x\n", hres);
1229
1230 /* negative resets to 0, return value is S_FALSE when
1231 position wasn't changed */
1232 hres = ITextSelection_SetStart(txtSel, -1);
1233 ok(hres == S_OK, "got 0x%08x\n", hres);
1234
1235 hres = ITextSelection_SetStart(txtSel, -1);
1236 ok(hres == S_FALSE, "got 0x%08x\n", hres);
1237
1238 hres = ITextSelection_SetStart(txtSel, 0);
1239 ok(hres == S_FALSE, "got 0x%08x\n", hres);
1240
1241 start = -1;
1242 hres = ITextSelection_GetStart(txtSel, &start);
1243 ok(hres == S_OK, "got 0x%08x\n", hres);
1244 ok(start == 0, "got %d\n", start);
1245
1246 /* greater than initial end, but less than total char count */
1247 hres = ITextSelection_SetStart(txtSel, 1);
1248 ok(hres == S_OK, "got 0x%08x\n", hres);
1249
1250 hres = ITextSelection_SetEnd(txtSel, 3);
1251 ok(hres == S_OK, "got 0x%08x\n", hres);
1252
1253 hres = ITextSelection_SetStart(txtSel, 10);
1254 ok(hres == S_OK, "got 0x%08x\n", hres);
1255
1256 start = 0;
1257 hres = ITextSelection_GetStart(txtSel, &start);
1258 ok(hres == S_OK, "got 0x%08x\n", hres);
1259 ok(start == 10, "got %d\n", start);
1260
1261 end = 0;
1262 hres = ITextSelection_GetEnd(txtSel, &end);
1263 ok(hres == S_OK, "got 0x%08x\n", hres);
1264 ok(end == 10, "got %d\n", end);
1265
1266 /* more that total text length */
1267 hres = ITextSelection_SetStart(txtSel, 50);
1268 ok(hres == S_OK, "got 0x%08x\n", hres);
1269
1270 start = 0;
1271 hres = ITextSelection_GetStart(txtSel, &start);
1272 ok(hres == S_OK, "got 0x%08x\n", hres);
1273 ok(start == 12, "got %d\n", start);
1274
1275 end = 0;
1276 hres = ITextSelection_GetEnd(txtSel, &end);
1277 ok(hres == S_OK, "got 0x%08x\n", hres);
1278 ok(end == 12, "got %d\n", end);
1279
1280 /* SetEnd */
1281 hres = ITextSelection_SetStart(txtSel, 0);
1282 ok(hres == S_OK, "got 0x%08x\n", hres);
1283
1284 /* same value */
1285 hres = ITextSelection_SetEnd(txtSel, 5);
1286 ok(hres == S_OK, "got 0x%08x\n", hres);
1287
1288 hres = ITextSelection_SetEnd(txtSel, 5);
1289 ok(hres == S_FALSE, "got 0x%08x\n", hres);
1290
1291 /* negative resets to 0 */
1292 hres = ITextSelection_SetEnd(txtSel, -1);
1293 ok(hres == S_OK, "got 0x%08x\n", hres);
1294
1295 end = -1;
1296 hres = ITextSelection_GetEnd(txtSel, &end);
1297 ok(hres == S_OK, "got 0x%08x\n", hres);
1298 ok(end == 0, "got %d\n", end);
1299
1300 start = -1;
1301 hres = ITextSelection_GetStart(txtSel, &start);
1302 ok(hres == S_OK, "got 0x%08x\n", hres);
1303 ok(start == 0, "got %d\n", start);
1304
1305 /* greater than initial end, but less than total char count */
1306 hres = ITextSelection_SetStart(txtSel, 3);
1307 ok(hres == S_OK, "got 0x%08x\n", hres);
1308
1309 hres = ITextSelection_SetEnd(txtSel, 1);
1310 ok(hres == S_OK, "got 0x%08x\n", hres);
1311
1312 start = 0;
1313 hres = ITextSelection_GetStart(txtSel, &start);
1314 ok(hres == S_OK, "got 0x%08x\n", hres);
1315 ok(start == 1, "got %d\n", start);
1316
1317 end = 0;
1318 hres = ITextSelection_GetEnd(txtSel, &end);
1319 ok(hres == S_OK, "got 0x%08x\n", hres);
1320 ok(end == 1, "got %d\n", end);
1321
1322 /* more than total count */
1323 hres = ITextSelection_SetEnd(txtSel, 50);
1324 ok(hres == S_OK, "got 0x%08x\n", hres);
1325
1326 start = 0;
1327 hres = ITextSelection_GetStart(txtSel, &start);
1328 ok(hres == S_OK, "got 0x%08x\n", hres);
1329 ok(start == 1, "got %d\n", start);
1330
1331 end = 0;
1332 hres = ITextSelection_GetEnd(txtSel, &end);
1333 ok(hres == S_OK, "got 0x%08x\n", hres);
1334 ok(end == 13, "got %d\n", end);
1335
1336 /* zero */
1337 hres = ITextSelection_SetEnd(txtSel, 0);
1338 ok(hres == S_OK, "got 0x%08x\n", hres);
1339
1340 start = 0;
1341 hres = ITextSelection_GetStart(txtSel, &start);
1342 ok(hres == S_OK, "got 0x%08x\n", hres);
1343 ok(start == 0, "got %d\n", start);
1344
1345 end = 0;
1346 hres = ITextSelection_GetEnd(txtSel, &end);
1347 ok(hres == S_OK, "got 0x%08x\n", hres);
1348 ok(end == 0, "got %d\n", end);
1349
1350 release_interfaces(&w, &reOle, &txtDoc, NULL);
1351
1352 /* detached selection */
1353 hres = ITextSelection_GetStart(txtSel, NULL);
1354 ok(hres == CO_E_RELEASED, "got 0x%08x\n", hres);
1355
1356 hres = ITextSelection_GetStart(txtSel, &start);
1357 ok(hres == CO_E_RELEASED, "got 0x%08x\n", hres);
1358
1359 hres = ITextSelection_GetEnd(txtSel, NULL);
1360 ok(hres == CO_E_RELEASED, "got 0x%08x\n", hres);
1361
1362 hres = ITextSelection_GetEnd(txtSel, &end);
1363 ok(hres == CO_E_RELEASED, "got 0x%08x\n", hres);
1364
1365 ITextSelection_Release(txtSel);
1366}
1367
1369{
1370 HWND w;
1371 IRichEditOle *reOle = NULL;
1372 ITextDocument *txtDoc = NULL;
1373 ITextRange *txtRge = NULL;
1374 ITextRange *txtRgeDup = NULL;
1375 HRESULT hres;
1376 LONG first, lim, start, end;
1377 static const CHAR test_text1[] = "TestSomeText";
1378
1379 create_interfaces(&w, &reOle, &txtDoc, NULL);
1380 SendMessageA(w, WM_SETTEXT, 0, (LPARAM)test_text1);
1381 first = 0; lim = 4;
1382 hres = ITextDocument_Range(txtDoc, first, lim, &txtRge);
1383 ok(hres == S_OK, "ITextDocument_Range fails 0x%x.\n", hres);
1384
1385 hres = ITextRange_GetDuplicate(txtRge, &txtRgeDup);
1386 ok(hres == S_OK, "ITextRange_GetDuplicate\n");
1387 ok(txtRgeDup != txtRge, "A new pointer should be returned\n");
1388 hres = ITextRange_GetStart(txtRgeDup, &start);
1389 ok(hres == S_OK, "got 0x%08x\n", hres);
1390 ok(start == first, "got wrong value: %d\n", start);
1391 hres = ITextRange_GetEnd(txtRgeDup, &end);
1392 ok(hres == S_OK, "got 0x%08x\n", hres);
1393 ok(end == lim, "got wrong value: %d\n", end);
1394
1395 ITextRange_Release(txtRgeDup);
1396
1397 hres = ITextRange_GetDuplicate(txtRge, NULL);
1398 ok(hres == E_INVALIDARG, "ITextRange_GetDuplicate\n");
1399
1400 release_interfaces(&w, &reOle, &txtDoc, NULL);
1401
1402 hres = ITextRange_GetDuplicate(txtRge, NULL);
1403 ok(hres == CO_E_RELEASED, "got 0x%08x\n", hres);
1404
1405 hres = ITextRange_GetDuplicate(txtRge, &txtRgeDup);
1406 ok(hres == CO_E_RELEASED, "got 0x%08x\n", hres);
1407
1408 ITextRange_Release(txtRge);
1409}
1410
1412{
1413 HWND w;
1414 IRichEditOle *reOle = NULL;
1415 ITextDocument *txtDoc = NULL;
1416 ITextRange *txtRge = NULL;
1417 HRESULT hres;
1418 LONG first, lim, start, end;
1419 static const CHAR test_text1[] = "TestSomeText";
1420
1421 create_interfaces(&w, &reOle, &txtDoc, NULL);
1422 SendMessageA(w, WM_SETTEXT, 0, (LPARAM)test_text1);
1423
1424 first = 4; lim = 8;
1425 hres = ITextDocument_Range(txtDoc, first, lim, &txtRge);
1426 ok(hres == S_OK, "got 0x%08x\n", hres);
1427 hres = ITextRange_Collapse(txtRge, tomTrue);
1428 ok(hres == S_OK, "ITextRange_Collapse\n");
1429 hres = ITextRange_GetStart(txtRge, &start);
1430 ok(hres == S_OK, "got 0x%08x\n", hres);
1431 ok(start == 4, "got wrong start value: %d\n", start);
1432 hres = ITextRange_GetEnd(txtRge, &end);
1433 ok(hres == S_OK, "got 0x%08x\n", hres);
1434 ok(end == 4, "got wrong end value: %d\n", end);
1435 ITextRange_Release(txtRge);
1436
1437 hres = ITextDocument_Range(txtDoc, first, lim, &txtRge);
1438 ok(hres == S_OK, "got 0x%08x\n", hres);
1439 hres = ITextRange_Collapse(txtRge, tomStart);
1440 ok(hres == S_OK, "ITextRange_Collapse\n");
1441 hres = ITextRange_GetStart(txtRge, &start);
1442 ok(hres == S_OK, "got 0x%08x\n", hres);
1443 ok(start == 4, "got wrong start value: %d\n", start);
1444 hres = ITextRange_GetEnd(txtRge, &end);
1445 ok(hres == S_OK, "got 0x%08x\n", hres);
1446 ok(end == 4, "got wrong end value: %d\n", end);
1447 ITextRange_Release(txtRge);
1448
1449 hres = ITextDocument_Range(txtDoc, first, lim, &txtRge);
1450 ok(hres == S_OK, "got 0x%08x\n", hres);
1451 hres = ITextRange_Collapse(txtRge, tomFalse);
1452 ok(hres == S_OK, "ITextRange_Collapse\n");
1453 hres = ITextRange_GetStart(txtRge, &start);
1454 ok(hres == S_OK, "got 0x%08x\n", hres);
1455 ok(start == 8, "got wrong start value: %d\n", start);
1456 hres = ITextRange_GetEnd(txtRge, &end);
1457 ok(hres == S_OK, "got 0x%08x\n", hres);
1458 ok(end == 8, "got wrong end value: %d\n", end);
1459 ITextRange_Release(txtRge);
1460
1461 hres = ITextDocument_Range(txtDoc, first, lim, &txtRge);
1462 ok(hres == S_OK, "got 0x%08x\n", hres);
1463 hres = ITextRange_Collapse(txtRge, tomEnd);
1464 ok(hres == S_OK, "ITextRange_Collapse\n");
1465 hres = ITextRange_GetStart(txtRge, &start);
1466 ok(hres == S_OK, "got 0x%08x\n", hres);
1467 ok(start == 8, "got wrong start value: %d\n", start);
1468 hres = ITextRange_GetEnd(txtRge, &end);
1469 ok(hres == S_OK, "got 0x%08x\n", hres);
1470 ok(end == 8, "got wrong end value: %d\n", end);
1471 ITextRange_Release(txtRge);
1472
1473 /* tomStart is the default */
1474 hres = ITextDocument_Range(txtDoc, first, lim, &txtRge);
1475 ok(hres == S_OK, "got 0x%08x\n", hres);
1476 hres = ITextRange_Collapse(txtRge, 256);
1477 ok(hres == S_OK, "ITextRange_Collapse\n");
1478 hres = ITextRange_GetStart(txtRge, &start);
1479 ok(hres == S_OK, "got 0x%08x\n", hres);
1480 ok(start == 4, "got wrong start value: %d\n", start);
1481 hres = ITextRange_GetEnd(txtRge, &end);
1482 ok(hres == S_OK, "got 0x%08x\n", hres);
1483 ok(end == 4, "got wrong end value: %d\n", end);
1484 ITextRange_Release(txtRge);
1485
1486 first = 6; lim = 6;
1487 hres = ITextDocument_Range(txtDoc, first, lim, &txtRge);
1488 ok(hres == S_OK, "got 0x%08x\n", hres);
1489 hres = ITextRange_Collapse(txtRge, tomEnd);
1490 ok(hres == S_FALSE, "ITextRange_Collapse\n");
1491 hres = ITextRange_GetStart(txtRge, &start);
1492 ok(hres == S_OK, "got 0x%08x\n", hres);
1493 ok(start == 6, "got wrong start value: %d\n", start);
1494 hres = ITextRange_GetEnd(txtRge, &end);
1495 ok(hres == S_OK, "got 0x%08x\n", hres);
1496 ok(end == 6, "got wrong end value: %d\n", end);
1497 ITextRange_Release(txtRge);
1498
1499 first = 8; lim = 8;
1500 hres = ITextDocument_Range(txtDoc, first, lim, &txtRge);
1501 ok(hres == S_OK, "got 0x%08x\n", hres);
1502 hres = ITextRange_Collapse(txtRge, tomStart);
1503 ok(hres == S_FALSE, "ITextRange_Collapse\n");
1504 hres = ITextRange_GetStart(txtRge, &start);
1505 ok(hres == S_OK, "got 0x%08x\n", hres);
1506 ok(start == 8, "got wrong start value: %d\n", start);
1507 hres = ITextRange_GetEnd(txtRge, &end);
1508 ok(hres == S_OK, "got 0x%08x\n", hres);
1509 ok(end == 8, "got wrong end value: %d\n", end);
1510
1511 release_interfaces(&w, &reOle, &txtDoc, NULL);
1512
1513 hres = ITextRange_Collapse(txtRge, tomStart);
1514 ok(hres == CO_E_RELEASED, "got 0x%08x\n", hres);
1515
1516 hres = ITextRange_Collapse(txtRge, tomUndefined);
1517 ok(hres == CO_E_RELEASED, "got 0x%08x\n", hres);
1518
1519 ITextRange_Release(txtRge);
1520}
1521
1523{
1524 HWND w;
1525 IRichEditOle *reOle = NULL;
1526 ITextDocument *txtDoc = NULL;
1527 ITextSelection *txtSel = NULL;
1528 HRESULT hres;
1529 LONG first, lim, start, end;
1530 static const CHAR test_text1[] = "TestSomeText";
1531
1532 create_interfaces(&w, &reOle, &txtDoc, &txtSel);
1533 SendMessageA(w, WM_SETTEXT, 0, (LPARAM)test_text1);
1534
1535 first = 4; lim = 8;
1536 SendMessageA(w, EM_SETSEL, first, lim);
1537 hres = ITextSelection_Collapse(txtSel, tomTrue);
1538 ok(hres == S_OK, "ITextSelection_Collapse\n");
1540 ok(start == 4, "got wrong start value: %d\n", start);
1541 ok(end == 4, "got wrong end value: %d\n", end);
1542
1543 SendMessageA(w, EM_SETSEL, first, lim);
1544 hres = ITextSelection_Collapse(txtSel, tomStart);
1545 ok(hres == S_OK, "ITextSelection_Collapse\n");
1547 ok(start == 4, "got wrong start value: %d\n", start);
1548 ok(end == 4, "got wrong end value: %d\n", end);
1549
1550 SendMessageA(w, EM_SETSEL, first, lim);
1551 hres = ITextSelection_Collapse(txtSel, tomFalse);
1552 ok(hres == S_OK, "ITextSelection_Collapse\n");
1554 ok(start == 8, "got wrong start value: %d\n", start);
1555 ok(end == 8, "got wrong end value: %d\n", end);
1556
1557 SendMessageA(w, EM_SETSEL, first, lim);
1558 hres = ITextSelection_Collapse(txtSel, tomEnd);
1559 ok(hres == S_OK, "ITextSelection_Collapse\n");
1561 ok(start == 8, "got wrong start value: %d\n", start);
1562 ok(end == 8, "got wrong end value: %d\n", end);
1563
1564 /* tomStart is the default */
1565 SendMessageA(w, EM_SETSEL, first, lim);
1566 hres = ITextSelection_Collapse(txtSel, 256);
1567 ok(hres == S_OK, "ITextSelection_Collapse\n");
1569 ok(start == 4, "got wrong start value: %d\n", start);
1570 ok(end == 4, "got wrong end value: %d\n", end);
1571
1572 first = 6; lim = 6;
1573 SendMessageA(w, EM_SETSEL, first, lim);
1574 hres = ITextSelection_Collapse(txtSel, tomEnd);
1575 ok(hres == S_FALSE, "ITextSelection_Collapse\n");
1577 ok(start == 6, "got wrong start value: %d\n", start);
1578 ok(end == 6, "got wrong end value: %d\n", end);
1579
1580 first = 8; lim = 8;
1581 SendMessageA(w, EM_SETSEL, first, lim);
1582 hres = ITextSelection_Collapse(txtSel, tomStart);
1583 ok(hres == S_FALSE, "ITextSelection_Collapse\n");
1585 ok(start == 8, "got wrong start value: %d\n", start);
1586 ok(end == 8, "got wrong end value: %d\n", end);
1587
1588 release_interfaces(&w, &reOle, &txtDoc, NULL);
1589
1590 hres = ITextSelection_Collapse(txtSel, tomStart);
1591 ok(hres == CO_E_RELEASED, "got 0x%08x\n", hres);
1592
1593 hres = ITextSelection_Collapse(txtSel, tomUndefined);
1594 ok(hres == CO_E_RELEASED, "got 0x%08x\n", hres);
1595
1596 ITextSelection_Release(txtSel);
1597}
1598
1599static void test_GetClientSite(void)
1600{
1601 HWND w;
1602 IRichEditOle *reOle = NULL, *reOle1 = NULL;
1603 ITextDocument *txtDoc = NULL;
1604 IOleClientSite *clientSite = NULL, *clientSite1 = NULL, *clientSite2 = NULL;
1605 IOleWindow *oleWin = NULL, *oleWin1 = NULL;
1606 IOleInPlaceSite *olePlace = NULL, *olePlace1 = NULL;
1607 HRESULT hres;
1608 LONG refcount1, refcount2;
1609
1610 create_interfaces(&w, &reOle, &txtDoc, NULL);
1611 hres = IRichEditOle_GetClientSite(reOle, &clientSite);
1612 ok(hres == S_OK, "IRichEditOle_QueryInterface: 0x%08x\n", hres);
1613 EXPECT_REF(clientSite, 1);
1614
1615 hres = IOleClientSite_QueryInterface(clientSite, &IID_IRichEditOle, (void **)&reOle1);
1616 ok(hres == E_NOINTERFACE, "IOleClientSite_QueryInterface: %x\n", hres);
1617
1618 hres = IRichEditOle_GetClientSite(reOle, &clientSite1);
1619 ok(hres == S_OK, "got 0x%08x\n", hres);
1620 ok(clientSite != clientSite1, "got %p, %p\n", clientSite, clientSite1);
1621 IOleClientSite_Release(clientSite1);
1622
1623 hres = IOleClientSite_QueryInterface(clientSite, &IID_IOleClientSite, (void **)&clientSite1);
1624 ok(hres == S_OK, "IOleClientSite_QueryInterface: 0x%08x\n", hres);
1625 ok(clientSite == clientSite1, "Should not return a new pointer.\n");
1626 EXPECT_REF(clientSite, 2);
1627
1628 /* IOleWindow interface */
1629 hres = IOleClientSite_QueryInterface(clientSite, &IID_IOleWindow, (void **)&oleWin);
1630 ok(hres == S_OK, "IOleClientSite_QueryInterface: 0x%08x\n", hres);
1631 refcount1 = get_refcount((IUnknown *)clientSite);
1632 refcount2 = get_refcount((IUnknown *)oleWin);
1633 ok(refcount1 == refcount2, "got wrong ref count.\n");
1634
1635 hres = IOleClientSite_QueryInterface(clientSite, &IID_IOleWindow, (void **)&oleWin1);
1636 ok(hres == S_OK, "IOleClientSite_QueryInterface: 0x%08x\n", hres);
1637 ok(oleWin == oleWin1, "Should not return a new pointer.\n");
1638 refcount1 = get_refcount((IUnknown *)clientSite);
1639 refcount2 = get_refcount((IUnknown *)oleWin);
1640 ok(refcount1 == refcount2, "got wrong ref count.\n");
1641
1642 hres = IOleWindow_QueryInterface(oleWin, &IID_IOleClientSite, (void **)&clientSite2);
1643 ok(hres == S_OK, "IOleWindow_QueryInterface: 0x%08x\n", hres);
1644 ok(clientSite2 == clientSite1, "got wrong pointer\n");
1645
1646 /* IOleInPlaceSite interface */
1647 hres = IOleClientSite_QueryInterface(clientSite, &IID_IOleInPlaceSite, (void **)&olePlace);
1648 ok(hres == S_OK, "IOleClientSite_QueryInterface: 0x%08x\n", hres);
1649 refcount1 = get_refcount((IUnknown *)olePlace);
1650 refcount2 = get_refcount((IUnknown *)clientSite);
1651 ok(refcount1 == refcount2, "got wrong ref count.\n");
1652
1653 hres = IOleClientSite_QueryInterface(clientSite, &IID_IOleInPlaceSite, (void **)&olePlace1);
1654 ok(hres == S_OK, "IOleClientSite_QueryInterface: 0x%08x\n", hres);
1655 ok(olePlace == olePlace1, "Should not return a new pointer.\n");
1656 IOleInPlaceSite_Release(olePlace1);
1657
1658 hres = IOleWindow_QueryInterface(oleWin, &IID_IOleInPlaceSite, (void **)&olePlace1);
1659 ok(hres == S_OK, "IOleWindow_QueryInterface: 0x%08x\n", hres);
1660 refcount1 = get_refcount((IUnknown *)olePlace1);
1661 refcount2 = get_refcount((IUnknown *)oleWin);
1662 ok(refcount1 == refcount2, "got wrong ref count.\n");
1663
1664 IOleInPlaceSite_Release(olePlace1);
1665 IOleInPlaceSite_Release(olePlace);
1666 IOleWindow_Release(oleWin1);
1667 IOleWindow_Release(oleWin);
1668 IOleClientSite_Release(clientSite2);
1669 IOleClientSite_Release(clientSite1);
1670 IOleClientSite_Release(clientSite);
1671 release_interfaces(&w, &reOle, &txtDoc, NULL);
1672}
1673
1675{
1676 HWND w;
1677 IRichEditOle *reOle = NULL;
1678 ITextDocument *txtDoc = NULL;
1679 IOleClientSite *clientSite = NULL;
1680 IOleWindow *oleWin = NULL;
1681 HRESULT hres;
1682 HWND hwnd;
1683
1684 create_interfaces(&w, &reOle, &txtDoc, NULL);
1685 hres = IRichEditOle_GetClientSite(reOle, &clientSite);
1686 ok(hres == S_OK, "IRichEditOle_QueryInterface: 0x%08x\n", hres);
1687
1688 hres = IOleClientSite_QueryInterface(clientSite, &IID_IOleWindow, (void **)&oleWin);
1689 ok(hres == S_OK, "IOleClientSite_QueryInterface: 0x%08x\n", hres);
1690 hres = IOleWindow_GetWindow(oleWin, &hwnd);
1691 ok(hres == S_OK, "IOleClientSite_GetWindow: 0x%08x\n", hres);
1692 ok(w == hwnd, "got wrong pointer\n");
1693
1694 hres = IOleWindow_GetWindow(oleWin, NULL);
1695 ok(hres == E_INVALIDARG, "IOleClientSite_GetWindow: 0x%08x\n", hres);
1696
1697 IOleWindow_Release(oleWin);
1698 IOleClientSite_Release(clientSite);
1699 release_interfaces(&w, &reOle, &txtDoc, NULL);
1700}
1701
1703{
1704 HWND w;
1705 IRichEditOle *reOle = NULL;
1706 ITextDocument *txtDoc = NULL;
1707 IOleClientSite *clientSite = NULL;
1708 IOleInPlaceSite *olePlace = NULL;
1709 HRESULT hres;
1710 HWND hwnd;
1711
1712 create_interfaces(&w, &reOle, &txtDoc, NULL);
1713 hres = IRichEditOle_GetClientSite(reOle, &clientSite);
1714 ok(hres == S_OK, "IRichEditOle_QueryInterface: 0x%08x\n", hres);
1715
1716 hres = IOleClientSite_QueryInterface(clientSite, &IID_IOleInPlaceSite, (void **)&olePlace);
1717 ok(hres == S_OK, "IOleClientSite_QueryInterface: 0x%08x\n", hres);
1718 hres = IOleInPlaceSite_GetWindow(olePlace, &hwnd);
1719 ok(hres == S_OK, "IOleInPlaceSite_GetWindow: 0x%08x\n", hres);
1720 ok(w == hwnd, "got wrong pointer.\n");
1721
1722 hres = IOleInPlaceSite_GetWindow(olePlace, NULL);
1723 ok(hres == E_INVALIDARG, "IOleInPlaceSite_GetWindow: 0x%08x\n", hres);
1724
1725 IOleInPlaceSite_Release(olePlace);
1726 IOleClientSite_Release(clientSite);
1727 release_interfaces(&w, &reOle, &txtDoc, NULL);
1728}
1729
1730static void test_GetFont(void)
1731{
1732 static const CHAR test_text1[] = "TestSomeText";
1733 IRichEditOle *reOle = NULL;
1734 ITextDocument *doc = NULL;
1737 ITextFont *font, *font2;
1739 LONG value;
1740 float size;
1741 HRESULT hr;
1742 HWND hwnd;
1743 BOOL ret;
1744
1745 create_interfaces(&hwnd, &reOle, &doc, NULL);
1746 SendMessageA(hwnd, WM_SETTEXT, 0, (LPARAM)test_text1);
1747
1748 hr = ITextDocument_GetSelection(doc, &selection);
1749 ok(hr == S_OK, "got 0x%08x\n", hr);
1750 hr = ITextSelection_GetFont(selection, &font);
1751 ok(hr == S_OK, "got 0x%08x\n", hr);
1752 hr = ITextSelection_GetFont(selection, &font2);
1753 ok(hr == S_OK, "got 0x%08x\n", hr);
1754 ok(font != font2, "got %p, %p\n", font, font2);
1755 ITextFont_Release(font2);
1756 ITextFont_Release(font);
1757 ITextSelection_Release(selection);
1758
1759 EXPECT_REF(reOle, 3);
1760 EXPECT_REF(doc, 3);
1761
1762 hr = ITextDocument_Range(doc, 0, 4, &range);
1763 ok(hr == S_OK, "got 0x%08x\n", hr);
1764
1765 EXPECT_REF(reOle, 3);
1766 EXPECT_REF(doc, 3);
1767 EXPECT_REF(range, 1);
1768
1769 hr = ITextRange_GetFont(range, NULL);
1770 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
1771
1772 hr = ITextRange_GetFont(range, &font);
1773 ok(hr == S_OK, "got 0x%08x\n", hr);
1774
1775 EXPECT_REF(reOle, 3);
1776 EXPECT_REF(doc, 3);
1777 EXPECT_REF(range, 2);
1778 EXPECT_REF(font, 1);
1779
1780 hr = ITextRange_GetFont(range, &font2);
1781 ok(hr == S_OK, "got 0x%08x\n", hr);
1782 ok(font != font2, "got %p, %p\n", font, font2);
1783
1784 EXPECT_REF(reOle, 3);
1785 EXPECT_REF(doc, 3);
1786 EXPECT_REF(range, 3);
1787 EXPECT_REF(font, 1);
1788 EXPECT_REF(font2, 1);
1789
1790 ITextFont_Release(font2);
1791
1792 /* set different font style within a range */
1793 hr = ITextFont_GetItalic(font, NULL);
1794 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
1795
1796 hr = ITextFont_GetSize(font, NULL);
1797 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
1798
1799 size = 0.0;
1800 hr = ITextFont_GetSize(font, &size);
1801 ok(hr == S_OK, "got 0x%08x\n", hr);
1802 ok(size > 0.0, "size %.2f\n", size);
1803
1804 value = 0;
1805 hr = ITextFont_GetLanguageID(font, &value);
1806 ok(hr == S_OK, "got 0x%08x\n", hr);
1807 ok(value == GetSystemDefaultLCID(), "got lcid %x, user lcid %x\n", value,
1809
1810 /* range is non-italic */
1811 value = tomTrue;
1812 hr = ITextFont_GetItalic(font, &value);
1813 ok(hr == S_OK, "got 0x%08x\n", hr);
1814 ok(value == tomFalse, "got %d\n", value);
1815
1816 cf.cbSize = sizeof(CHARFORMAT2A);
1817 cf.dwMask = CFM_ITALIC|CFM_SIZE;
1818 cf.dwEffects = CFE_ITALIC;
1819 cf.yHeight = 24.0;
1820
1821 SendMessageA(hwnd, EM_SETSEL, 2, 3);
1823 ok(ret, "got %d\n", ret);
1824
1825 /* now range is partially italicized */
1826 value = tomFalse;
1827 hr = ITextFont_GetItalic(font, &value);
1828 ok(hr == S_OK, "got 0x%08x\n", hr);
1829 ok(value == tomUndefined, "got %d\n", value);
1830
1831 size = 0.0;
1832 hr = ITextFont_GetSize(font, &size);
1833 ok(hr == S_OK, "got 0x%08x\n", hr);
1834 ok(size == tomUndefined, "size %.2f\n", size);
1835
1836 ITextFont_Release(font);
1837 release_interfaces(&hwnd, &reOle, &doc, NULL);
1838
1839 hr = ITextRange_GetFont(range, NULL);
1840 ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
1841
1842 hr = ITextRange_GetFont(range, &font2);
1843 ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
1844
1845 ITextRange_Release(range);
1846}
1847
1848static void test_GetPara(void)
1849{
1850 static const CHAR test_text1[] = "TestSomeText";
1851 IRichEditOle *reOle = NULL;
1852 ITextDocument *doc = NULL;
1855 ITextPara *para, *para2;
1856 HRESULT hr;
1857 HWND hwnd;
1858
1859 create_interfaces(&hwnd, &reOle, &doc, &selection);
1860 SendMessageA(hwnd, WM_SETTEXT, 0, (LPARAM)test_text1);
1861
1862 EXPECT_REF(reOle, 3);
1863 EXPECT_REF(doc, 3);
1864
1865 hr = ITextDocument_Range(doc, 0, 4, &range);
1866 ok(hr == S_OK, "got 0x%08x\n", hr);
1867
1868 EXPECT_REF(reOle, 3);
1869 EXPECT_REF(doc, 3);
1870 EXPECT_REF(range, 1);
1871
1872 hr = ITextRange_GetPara(range, NULL);
1873 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
1874
1875 hr = ITextRange_GetPara(range, &para);
1876 ok(hr == S_OK, "got 0x%08x\n", hr);
1877
1878 EXPECT_REF(reOle, 3);
1879 EXPECT_REF(doc, 3);
1880 EXPECT_REF(range, 2);
1881 EXPECT_REF(para, 1);
1882
1883 hr = ITextRange_GetPara(range, &para2);
1884 ok(hr == S_OK, "got 0x%08x\n", hr);
1885 ok(para != para2, "got %p, %p\n", para, para2);
1886
1887 EXPECT_REF(reOle, 3);
1888 EXPECT_REF(doc, 3);
1889 EXPECT_REF(range, 3);
1890 EXPECT_REF(para, 1);
1891 EXPECT_REF(para2, 1);
1892
1893 ITextPara_Release(para);
1894 ITextPara_Release(para2);
1895
1896 EXPECT_REF(reOle, 3);
1897 EXPECT_REF(doc, 3);
1899
1900 hr = ITextSelection_GetPara(selection, &para);
1901 ok(hr == S_OK, "got 0x%08x\n", hr);
1902
1903 EXPECT_REF(reOle, 3);
1904 EXPECT_REF(doc, 3);
1906 EXPECT_REF(para, 1);
1907
1908 hr = ITextSelection_GetPara(selection, &para2);
1909 ok(hr == S_OK, "got 0x%08x\n", hr);
1910 ok(para != para2, "got %p, %p\n", para, para2);
1911
1912 ITextPara_Release(para);
1913 ITextPara_Release(para2);
1914 release_interfaces(&hwnd, &reOle, &doc, NULL);
1915
1916 hr = ITextRange_GetPara(range, NULL);
1917 ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
1918
1919 hr = ITextRange_GetPara(range, &para);
1920 ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
1921
1922 hr = ITextSelection_GetPara(selection, NULL);
1923 ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
1924
1925 hr = ITextSelection_GetPara(selection, &para);
1926 ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
1927
1928 ITextSelection_Release(selection);
1929 ITextRange_Release(range);
1930}
1931
1932static void test_dispatch(void)
1933{
1934 static const WCHAR testnameW[] = {'G','e','t','T','e','x','t',0};
1935 static const WCHAR testname2W[] = {'T','e','x','t',0};
1936 IRichEditOle *reOle = NULL;
1937 ITextDocument *doc = NULL;
1939 WCHAR *nameW;
1940 DISPID dispid;
1941 HRESULT hr;
1942 UINT count;
1943 HWND hwnd;
1944
1945 create_interfaces(&hwnd, &reOle, &doc, NULL);
1946
1947 range = NULL;
1948 hr = ITextDocument_Range(doc, 0, 0, &range);
1949 ok(hr == S_OK, "got 0x%08x\n", hr);
1950 ok(range != NULL, "got %p\n", range);
1951
1952 dispid = 123;
1953 nameW = (WCHAR*)testnameW;
1954 hr = ITextRange_GetIDsOfNames(range, &IID_NULL, &nameW, 1, LOCALE_USER_DEFAULT, &dispid);
1955 ok(hr == DISP_E_UNKNOWNNAME, "got 0x%08x\n", hr);
1956 ok(dispid == DISPID_UNKNOWN, "got %d\n", dispid);
1957
1958 dispid = 123;
1959 nameW = (WCHAR*)testname2W;
1960 hr = ITextRange_GetIDsOfNames(range, &IID_NULL, &nameW, 1, LOCALE_USER_DEFAULT, &dispid);
1961 ok(hr == S_OK, "got 0x%08x\n", hr);
1962 ok(dispid == DISPID_VALUE, "got %d\n", dispid);
1963
1964 release_interfaces(&hwnd, &reOle, &doc, NULL);
1965
1966 /* try dispatch methods on detached range */
1967 hr = ITextRange_GetTypeInfoCount(range, &count);
1968 ok(hr == S_OK, "got 0x%08x\n", hr);
1969
1970 dispid = 123;
1971 nameW = (WCHAR*)testname2W;
1972 hr = ITextRange_GetIDsOfNames(range, &IID_NULL, &nameW, 1, LOCALE_USER_DEFAULT, &dispid);
1973 ok(hr == S_OK, "got 0x%08x\n", hr);
1974 ok(dispid == DISPID_VALUE, "got %d\n", dispid);
1975
1976 ITextRange_Release(range);
1977}
1978
1980{
1981 HRESULT hr, hrexp = duplicate ? S_OK : CO_E_RELEASED;
1982 LONG value;
1983 float size;
1984 BSTR str;
1985
1986 hr = ITextFont_GetBold(font, NULL);
1987 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
1988
1989 hr = ITextFont_GetBold(font, &value);
1990 ok(hr == hrexp, "got 0x%08x\n", hr);
1991
1992 hr = ITextFont_GetForeColor(font, NULL);
1993 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
1994
1995 hr = ITextFont_GetForeColor(font, &value);
1996 ok(hr == hrexp, "got 0x%08x\n", hr);
1997
1998 hr = ITextFont_GetItalic(font, NULL);
1999 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
2000
2001 hr = ITextFont_GetItalic(font, &value);
2002 ok(hr == hrexp, "got 0x%08x\n", hr);
2003
2004 hr = ITextFont_GetLanguageID(font, NULL);
2005 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
2006
2007 hr = ITextFont_GetLanguageID(font, &value);
2008 ok(hr == hrexp, "got 0x%08x\n", hr);
2009
2010 hr = ITextFont_GetName(font, NULL);
2011 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
2012
2013 hr = ITextFont_GetName(font, &str);
2014 ok(hr == hrexp, "got 0x%08x\n", hr);
2015
2016 hr = ITextFont_GetSize(font, NULL);
2017 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
2018
2019 hr = ITextFont_GetSize(font, &size);
2020 ok(hr == hrexp, "got 0x%08x\n", hr);
2021
2022 hr = ITextFont_GetStrikeThrough(font, NULL);
2023 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
2024
2025 hr = ITextFont_GetStrikeThrough(font, &value);
2026 ok(hr == hrexp, "got 0x%08x\n", hr);
2027
2028 hr = ITextFont_GetSubscript(font, NULL);
2029 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
2030
2031 hr = ITextFont_GetSubscript(font, &value);
2032 ok(hr == hrexp, "got 0x%08x\n", hr);
2033
2034 hr = ITextFont_GetSuperscript(font, NULL);
2035 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
2036
2037 hr = ITextFont_GetSuperscript(font, &value);
2038 ok(hr == hrexp, "got 0x%08x\n", hr);
2039
2040 hr = ITextFont_GetUnderline(font, NULL);
2041 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
2042
2043 hr = ITextFont_GetUnderline(font, &value);
2044 ok(hr == hrexp, "got 0x%08x\n", hr);
2045}
2046
2048{
2049 float valuef;
2050 LONG value;
2051 HRESULT hr;
2052 BSTR str;
2053
2055 hr = ITextFont_GetAllCaps(font, &value);
2056 ok(hr == S_OK, "got 0x%08x\n", hr);
2057 ok(value == tomFalse, "got %d\n", value);
2058
2060 hr = ITextFont_GetAnimation(font, &value);
2061 ok(hr == S_OK, "got 0x%08x\n", hr);
2062 ok(value == tomFalse, "got %d\n", value);
2063
2065 hr = ITextFont_GetBackColor(font, &value);
2066 ok(hr == S_OK, "got 0x%08x\n", hr);
2067 ok(value == tomAutoColor, "got %d\n", value);
2068
2070 hr = ITextFont_GetBold(font, &value);
2071 ok(hr == S_OK, "got 0x%08x\n", hr);
2072 ok(value == tomFalse || value == tomTrue, "got %d\n", value);
2073
2075 hr = ITextFont_GetEmboss(font, &value);
2076 ok(hr == S_OK, "got 0x%08x\n", hr);
2077 ok(value == tomFalse, "got %d\n", value);
2078
2080 hr = ITextFont_GetForeColor(font, &value);
2081 ok(hr == S_OK, "got 0x%08x\n", hr);
2082 ok(value == tomAutoColor, "got %d\n", value);
2083
2085 hr = ITextFont_GetHidden(font, &value);
2086 ok(hr == S_OK, "got 0x%08x\n", hr);
2087 ok(value == tomFalse, "got %d\n", value);
2088
2090 hr = ITextFont_GetEngrave(font, &value);
2091 ok(hr == S_OK, "got 0x%08x\n", hr);
2092 ok(value == tomFalse, "got %d\n", value);
2093
2095 hr = ITextFont_GetItalic(font, &value);
2096 ok(hr == S_OK, "got 0x%08x\n", hr);
2097 ok(value == tomFalse, "got %d\n", value);
2098
2099 valuef = 1.0;
2100 hr = ITextFont_GetKerning(font, &valuef);
2101 ok(hr == S_OK, "got 0x%08x\n", hr);
2102 ok(valuef == 0.0, "got %.2f\n", valuef);
2103
2105 hr = ITextFont_GetLanguageID(font, &value);
2106 ok(hr == S_OK, "got 0x%08x\n", hr);
2107 ok(value == GetSystemDefaultLCID(), "got %d\n", value);
2108
2109 str = NULL;
2110 hr = ITextFont_GetName(font, &str);
2111 ok(hr == S_OK, "got 0x%08x\n", hr);
2112 ok(!lstrcmpW(sysW, str), "%s\n", wine_dbgstr_w(str));
2114
2116 hr = ITextFont_GetOutline(font, &value);
2117 ok(hr == S_OK, "got 0x%08x\n", hr);
2118 ok(value == tomFalse, "got %d\n", value);
2119
2120 valuef = 1.0;
2121 hr = ITextFont_GetPosition(font, &valuef);
2122 ok(hr == S_OK, "got 0x%08x\n", hr);
2123 ok(valuef == 0.0, "got %.2f\n", valuef);
2124
2126 hr = ITextFont_GetProtected(font, &value);
2127 ok(hr == S_OK, "got 0x%08x\n", hr);
2128 ok(value == tomFalse, "got %d\n", value);
2129
2131 hr = ITextFont_GetShadow(font, &value);
2132 ok(hr == S_OK, "got 0x%08x\n", hr);
2133 ok(value == tomFalse, "got %d\n", value);
2134
2135 valuef = 0.0;
2136 hr = ITextFont_GetSize(font, &valuef);
2137 ok(hr == S_OK, "got 0x%08x\n", hr);
2138 ok(valuef >= 0.0, "got %.2f\n", valuef);
2139
2141 hr = ITextFont_GetSmallCaps(font, &value);
2142 ok(hr == S_OK, "got 0x%08x\n", hr);
2143 ok(value == tomFalse, "got %d\n", value);
2144
2145 valuef = 1.0;
2146 hr = ITextFont_GetSpacing(font, &valuef);
2147 ok(hr == S_OK, "got 0x%08x\n", hr);
2148 ok(valuef == 0.0, "got %.2f\n", valuef);
2149
2151 hr = ITextFont_GetStrikeThrough(font, &value);
2152 ok(hr == S_OK, "got 0x%08x\n", hr);
2153 ok(value == tomFalse, "got %d\n", value);
2154
2156 hr = ITextFont_GetSubscript(font, &value);
2157 ok(hr == S_OK, "got 0x%08x\n", hr);
2158 ok(value == tomFalse, "got %d\n", value);
2159
2161 hr = ITextFont_GetSuperscript(font, &value);
2162 ok(hr == S_OK, "got 0x%08x\n", hr);
2163 ok(value == tomFalse, "got %d\n", value);
2164
2166 hr = ITextFont_GetUnderline(font, &value);
2167 ok(hr == S_OK, "got 0x%08x\n", hr);
2168 ok(value == tomFalse, "got %d\n", value);
2169
2171 hr = ITextFont_GetWeight(font, &value);
2172 ok(hr == S_OK, "got 0x%08x\n", hr);
2173 ok(value == FW_NORMAL || value == FW_BOLD, "got %d\n", value);
2174}
2175
2177{
2178 float valuef;
2179 LONG value;
2180 HRESULT hr;
2181
2182 value = tomFalse;
2183 hr = ITextFont_GetAllCaps(font, &value);
2184 ok(hr == S_OK, "got 0x%08x\n", hr);
2185 ok(value == tomUndefined, "got %d\n", value);
2186
2187 value = tomFalse;
2188 hr = ITextFont_GetAnimation(font, &value);
2189 ok(hr == S_OK, "got 0x%08x\n", hr);
2190 ok(value == tomUndefined, "got %d\n", value);
2191
2192 value = tomFalse;
2193 hr = ITextFont_GetBackColor(font, &value);
2194 ok(hr == S_OK, "got 0x%08x\n", hr);
2195 ok(value == tomUndefined, "got %d\n", value);
2196
2197 value = tomFalse;
2198 hr = ITextFont_GetBold(font, &value);
2199 ok(hr == S_OK, "got 0x%08x\n", hr);
2200 ok(value == tomUndefined, "got %d\n", value);
2201
2202 value = tomFalse;
2203 hr = ITextFont_GetEmboss(font, &value);
2204 ok(hr == S_OK, "got 0x%08x\n", hr);
2205 ok(value == tomUndefined, "got %d\n", value);
2206
2207 value = tomFalse;
2208 hr = ITextFont_GetForeColor(font, &value);
2209 ok(hr == S_OK, "got 0x%08x\n", hr);
2210 ok(value == tomUndefined, "got %d\n", value);
2211
2212 value = tomFalse;
2213 hr = ITextFont_GetHidden(font, &value);
2214 ok(hr == S_OK, "got 0x%08x\n", hr);
2215 ok(value == tomUndefined, "got %d\n", value);
2216
2217 value = tomFalse;
2218 hr = ITextFont_GetEngrave(font, &value);
2219 ok(hr == S_OK, "got 0x%08x\n", hr);
2220 ok(value == tomUndefined, "got %d\n", value);
2221
2222 value = tomFalse;
2223 hr = ITextFont_GetItalic(font, &value);
2224 ok(hr == S_OK, "got 0x%08x\n", hr);
2225 ok(value == tomUndefined, "got %d\n", value);
2226
2227 valuef = 0.0;
2228 hr = ITextFont_GetKerning(font, &valuef);
2229 ok(hr == S_OK, "got 0x%08x\n", hr);
2230 ok(valuef == tomUndefined, "got %.2f\n", valuef);
2231
2232 value = tomFalse;
2233 hr = ITextFont_GetLanguageID(font, &value);
2234 ok(hr == S_OK, "got 0x%08x\n", hr);
2235 ok(value == tomUndefined, "got %d\n", value);
2236
2237 value = tomFalse;
2238 hr = ITextFont_GetOutline(font, &value);
2239 ok(hr == S_OK, "got 0x%08x\n", hr);
2240 ok(value == tomUndefined, "got %d\n", value);
2241
2242 valuef = 0.0;
2243 hr = ITextFont_GetPosition(font, &valuef);
2244 ok(hr == S_OK, "got 0x%08x\n", hr);
2245 ok(valuef == tomUndefined, "got %.2f\n", valuef);
2246
2247 value = tomFalse;
2248 hr = ITextFont_GetProtected(font, &value);
2249 ok(hr == S_OK, "got 0x%08x\n", hr);
2250 ok(value == tomUndefined, "got %d\n", value);
2251
2252 value = tomFalse;
2253 hr = ITextFont_GetShadow(font, &value);
2254 ok(hr == S_OK, "got 0x%08x\n", hr);
2255 ok(value == tomUndefined, "got %d\n", value);
2256
2257 valuef = 0.0;
2258 hr = ITextFont_GetSize(font, &valuef);
2259 ok(hr == S_OK, "got 0x%08x\n", hr);
2260 ok(valuef == tomUndefined, "got %.2f\n", valuef);
2261
2262 value = tomFalse;
2263 hr = ITextFont_GetSmallCaps(font, &value);
2264 ok(hr == S_OK, "got 0x%08x\n", hr);
2265 ok(value == tomUndefined, "got %d\n", value);
2266
2267 valuef = 0.0;
2268 hr = ITextFont_GetSpacing(font, &valuef);
2269 ok(hr == S_OK, "got 0x%08x\n", hr);
2270 ok(valuef == tomUndefined, "got %.2f\n", valuef);
2271
2272 value = tomFalse;
2273 hr = ITextFont_GetStrikeThrough(font, &value);
2274 ok(hr == S_OK, "got 0x%08x\n", hr);
2275 ok(value == tomUndefined, "got %d\n", value);
2276
2277 value = tomFalse;
2278 hr = ITextFont_GetSubscript(font, &value);
2279 ok(hr == S_OK, "got 0x%08x\n", hr);
2280 ok(value == tomUndefined, "got %d\n", value);
2281
2282 value = tomFalse;
2283 hr = ITextFont_GetSuperscript(font, &value);
2284 ok(hr == S_OK, "got 0x%08x\n", hr);
2285 ok(value == tomUndefined, "got %d\n", value);
2286
2287 value = tomFalse;
2288 hr = ITextFont_GetUnderline(font, &value);
2289 ok(hr == S_OK, "got 0x%08x\n", hr);
2290 ok(value == tomUndefined, "got %d\n", value);
2291
2292 value = tomFalse;
2293 hr = ITextFont_GetWeight(font, &value);
2294 ok(hr == S_OK, "got 0x%08x\n", hr);
2295 ok(value == tomUndefined, "got %d\n", value);
2296}
2297
2299{
2300 return value * 72.0 / 1440;
2301}
2302
2303static void test_ITextFont(void)
2304{
2305 static const WCHAR arialW[] = {'A','r','i','a','l',0};
2306 static const CHAR test_text1[] = "TestSomeText";
2307 ITextFont *font, *font2, *font3;
2308 FLOAT size, position, kerning;
2309 IRichEditOle *reOle = NULL;
2310 ITextDocument *doc = NULL;
2313 LONG value;
2314 HRESULT hr;
2315 HWND hwnd;
2316 BOOL ret;
2317 BSTR str;
2318
2319 create_interfaces(&hwnd, &reOle, &doc, NULL);
2320 SendMessageA(hwnd, WM_SETTEXT, 0, (LPARAM)test_text1);
2321
2322 hr = ITextDocument_Range(doc, 0, 10, &range);
2323 ok(hr == S_OK, "got 0x%08x\n", hr);
2324
2325 hr = ITextRange_GetFont(range, &font);
2326 ok(hr == S_OK, "got 0x%08x\n", hr);
2327
2328 hr = ITextFont_Reset(font, tomUseTwips);
2329 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
2330
2331 hr = ITextFont_Reset(font, tomUsePoints);
2332 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
2333
2334 hr = ITextFont_GetName(font, NULL);
2335 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
2336
2337 /* default font size unit is point */
2338 size = 0.0;
2339 hr = ITextFont_GetSize(font, &size);
2340 ok(hr == S_OK, "got 0x%08x\n", hr);
2341
2342 /* set to some non-zero values */
2343 hr = ITextFont_SetPosition(font, 20.0);
2344 ok(hr == S_OK, "got 0x%08x\n", hr);
2345
2346 hr = ITextFont_SetKerning(font, 10.0);
2347 ok(hr == S_OK, "got 0x%08x\n", hr);
2348
2349 position = 0.0;
2350 hr = ITextFont_GetPosition(font, &position);
2351 ok(hr == S_OK, "got 0x%08x\n", hr);
2352
2353 kerning = 0.0;
2354 hr = ITextFont_GetKerning(font, &kerning);
2355 ok(hr == S_OK, "got 0x%08x\n", hr);
2356
2357 memset(&cf, 0, sizeof(cf));
2358 cf.cbSize = sizeof(cf);
2360
2361 /* CHARFORMAT members are in twips */
2362 SendMessageA(hwnd, EM_SETSEL, 0, 10);
2364 ok(ret, "got %d\n", ret);
2365 ok(size == twips_to_points(cf.yHeight), "got yHeight %d, size %.2f\n", cf.yHeight, size);
2366 ok(position == twips_to_points(cf.yOffset), "got yOffset %d, position %.2f\n", cf.yOffset, position);
2367 ok(kerning == twips_to_points(cf.wKerning), "got wKerning %d, kerning %.2f\n", cf.wKerning, kerning);
2368
2369 hr = ITextFont_Reset(font, tomUseTwips);
2370 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
2371
2372 hr = ITextFont_Reset(font, tomUsePoints);
2373 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
2374
2375 hr = ITextFont_GetDuplicate(font, &font2);
2376 ok(hr == S_OK, "got 0x%08x\n", hr);
2377
2378 hr = ITextFont_Reset(font2, tomUseTwips);
2379 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
2380
2381 hr = ITextFont_Reset(font2, tomUsePoints);
2382 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
2383
2384 ITextFont_Release(font2);
2385
2386 /* default font name */
2387 str = NULL;
2388 hr = ITextFont_GetName(font, &str);
2389 ok(hr == S_OK, "got 0x%08x\n", hr);
2390 ok(!lstrcmpW(str, sysW), "got %s\n", wine_dbgstr_w(str));
2392
2393 /* change font name for an inner subrange */
2394 memset(&cf, 0, sizeof(cf));
2395 cf.cbSize = sizeof(cf);
2396 cf.dwMask = CFM_FACE;
2397 strcpy(cf.szFaceName, "Arial");
2398
2399 SendMessageA(hwnd, EM_SETSEL, 3, 4);
2401 ok(ret, "got %d\n", ret);
2402
2403 /* still original name */
2404 str = NULL;
2405 hr = ITextFont_GetName(font, &str);
2406 ok(hr == S_OK, "got 0x%08x\n", hr);
2407 ok(!lstrcmpW(str, sysW), "got %s\n", wine_dbgstr_w(str));
2409
2410 SendMessageA(hwnd, EM_SETSEL, 1, 2);
2412 ok(ret, "got %d\n", ret);
2413
2414 str = NULL;
2415 hr = ITextFont_GetName(font, &str);
2416 ok(hr == S_OK, "got 0x%08x\n", hr);
2417 ok(!lstrcmpW(str, sysW), "got %s\n", wine_dbgstr_w(str));
2419
2420 /* name is returned for first position within a range */
2421 SendMessageA(hwnd, EM_SETSEL, 0, 1);
2423 ok(ret, "got %d\n", ret);
2424
2425 str = NULL;
2426 hr = ITextFont_GetName(font, &str);
2427 ok(hr == S_OK, "got 0x%08x\n", hr);
2428 ok(!lstrcmpW(str, arialW), "got %s\n", wine_dbgstr_w(str));
2430
2431 /* GetDuplicate() */
2432 hr = ITextFont_GetDuplicate(font, NULL);
2433 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
2434
2435 EXPECT_REF(range, 2);
2436 font2 = NULL;
2437 hr = ITextFont_GetDuplicate(font, &font2);
2438 ok(hr == S_OK, "got 0x%08x\n", hr);
2439 EXPECT_REF(range, 2);
2440
2441 /* set whole range to italic */
2442 cf.cbSize = sizeof(CHARFORMAT2A);
2443 cf.dwMask = CFM_ITALIC;
2444 cf.dwEffects = CFE_ITALIC;
2445
2446 SendMessageA(hwnd, EM_SETSEL, 0, 10);
2448 ok(ret, "got %d\n", ret);
2449
2450 value = tomFalse;
2451 hr = ITextFont_GetItalic(font, &value);
2452 ok(hr == S_OK, "got 0x%08x\n", hr);
2453 ok(value == tomTrue, "got %d\n", value);
2454
2455 /* duplicate retains original value */
2456 value = tomTrue;
2457 hr = ITextFont_GetItalic(font2, &value);
2458 ok(hr == S_OK, "got 0x%08x\n", hr);
2459 ok(value == tomFalse, "got %d\n", value);
2460
2461 /* get a duplicate from a cloned font */
2462 hr = ITextFont_GetDuplicate(font2, &font3);
2463 ok(hr == S_OK, "got 0x%08x\n", hr);
2464 ITextFont_Release(font3);
2465
2466 ITextRange_Release(range);
2467 release_interfaces(&hwnd, &reOle, &doc, NULL);
2468
2469 hr = ITextFont_GetDuplicate(font, NULL);
2470 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
2471
2474
2475 /* get a duplicate of detached font */
2476 hr = ITextFont_GetDuplicate(font2, &font3);
2477 ok(hr == S_OK, "got 0x%08x\n", hr);
2478 ITextFont_Release(font3);
2479
2480 /* reset detached font to undefined */
2482 hr = ITextFont_GetBold(font2, &value);
2483 ok(hr == S_OK, "got 0x%08x\n", hr);
2484 ok(value != tomUndefined, "got %d\n", value);
2485
2486 /* reset to undefined for detached font */
2487 hr = ITextFont_Reset(font2, tomUndefined);
2488 ok(hr == S_OK, "got 0x%08x\n", hr);
2490
2491 /* font is detached, default means global TOM defaults */
2492 hr = ITextFont_Reset(font2, tomDefault);
2493 ok(hr == S_OK, "got 0x%08x\n", hr);
2495
2496 hr = ITextFont_GetDuplicate(font2, &font3);
2497 ok(hr == S_OK, "got 0x%08x\n", hr);
2499
2500 hr = ITextFont_Reset(font2, tomApplyNow);
2501 ok(hr == S_OK, "got 0x%08x\n", hr);
2503
2504 hr = ITextFont_Reset(font2, tomApplyLater);
2505 ok(hr == S_OK, "got 0x%08x\n", hr);
2507
2508 hr = ITextFont_Reset(font2, tomTrackParms);
2509 ok(hr == S_OK, "got 0x%08x\n", hr);
2511
2512 hr = ITextFont_SetItalic(font2, tomUndefined);
2513 ok(hr == S_OK, "got 0x%08x\n", hr);
2514
2515 hr = ITextFont_GetItalic(font2, &value);
2516 ok(hr == S_OK, "got 0x%08x\n", hr);
2517 ok(value == tomFalse, "got %d\n", value);
2518
2519 hr = ITextFont_Reset(font2, tomCacheParms);
2520 ok(hr == S_OK, "got 0x%08x\n", hr);
2522
2523 ITextFont_Release(font3);
2524 ITextFont_Release(font2);
2525
2526 font2 = (void*)0xdeadbeef;
2527 hr = ITextFont_GetDuplicate(font, &font2);
2528 ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
2529 ok(font2 == NULL, "got %p\n", font2);
2530
2531 hr = ITextFont_Reset(font, tomDefault);
2532 ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
2533
2534 ITextFont_Release(font);
2535
2536 /* Reset() */
2537 create_interfaces(&hwnd, &reOle, &doc, NULL);
2538 SendMessageA(hwnd, WM_SETTEXT, 0, (LPARAM)test_text1);
2539
2540 hr = ITextDocument_Range(doc, 0, 10, &range);
2541 ok(hr == S_OK, "got 0x%08x\n", hr);
2542
2543 hr = ITextRange_GetFont(range, &font);
2544 ok(hr == S_OK, "got 0x%08x\n", hr);
2545
2547 hr = ITextFont_GetBold(font, &value);
2548 ok(hr == S_OK, "got 0x%08x\n", hr);
2549 ok(value != tomUndefined, "got %d\n", value);
2550
2551 /* reset to undefined for attached font */
2552 hr = ITextFont_Reset(font, tomUndefined);
2553 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
2554
2556 hr = ITextFont_GetBold(font, &value);
2557 ok(hr == S_OK, "got 0x%08x\n", hr);
2558 ok(value != tomUndefined, "got %d\n", value);
2559
2560 /* tomCacheParms/tomTrackParms */
2561 hr = ITextFont_Reset(font, tomCacheParms);
2562 ok(hr == S_OK, "got 0x%08x\n", hr);
2563
2564 hr = ITextFont_GetItalic(font, &value);
2565 ok(hr == S_OK, "got 0x%08x\n", hr);
2566 ok(value == tomFalse, "got %d\n", value);
2567
2568 memset(&cf, 0, sizeof(cf));
2569 cf.cbSize = sizeof(CHARFORMAT2A);
2570 cf.dwMask = CFM_ITALIC;
2571
2572 cf.dwEffects = CFE_ITALIC;
2573 SendMessageA(hwnd, EM_SETSEL, 0, 10);
2575 ok(ret, "got %d\n", ret);
2576
2577 /* still cached value */
2578 hr = ITextFont_GetItalic(font, &value);
2579 ok(hr == S_OK, "got 0x%08x\n", hr);
2580 ok(value == tomFalse, "got %d\n", value);
2581
2582 hr = ITextFont_Reset(font, tomTrackParms);
2583 ok(hr == S_OK, "got 0x%08x\n", hr);
2584
2585 hr = ITextFont_GetItalic(font, &value);
2586 ok(hr == S_OK, "got 0x%08x\n", hr);
2587 ok(value == tomTrue, "got %d\n", value);
2588
2589 /* switch back to cache - value retained */
2590 hr = ITextFont_Reset(font, tomCacheParms);
2591 ok(hr == S_OK, "got 0x%08x\n", hr);
2592
2593 hr = ITextFont_GetItalic(font, &value);
2594 ok(hr == S_OK, "got 0x%08x\n", hr);
2595 ok(value == tomTrue, "got %d\n", value);
2596
2597 /* tomApplyLater */
2598 hr = ITextFont_Reset(font, tomApplyLater);
2599 ok(hr == S_OK, "got 0x%08x\n", hr);
2600
2601 hr = ITextFont_SetItalic(font, tomFalse);
2602 ok(hr == S_OK, "got 0x%08x\n", hr);
2603
2604 hr = ITextFont_GetItalic(font, &value);
2605 ok(hr == S_OK, "got 0x%08x\n", hr);
2606 ok(value == tomFalse, "got %d\n", value);
2607
2608 cf.dwEffects = 0;
2609 SendMessageA(hwnd, EM_SETSEL, 0, 10);
2611 ok(ret, "got %d\n", ret);
2612 ok((cf.dwEffects & CFE_ITALIC) == CFE_ITALIC, "got 0x%08x\n", cf.dwEffects);
2613
2614 hr = ITextFont_Reset(font, tomApplyNow);
2615 ok(hr == S_OK, "got 0x%08x\n", hr);
2616
2617 cf.dwEffects = 0;
2618 SendMessageA(hwnd, EM_SETSEL, 0, 10);
2620 ok(ret, "got %d\n", ret);
2621 ok((cf.dwEffects & CFE_ITALIC) == 0, "got 0x%08x\n", cf.dwEffects);
2622
2623 hr = ITextFont_SetItalic(font, tomUndefined);
2624 ok(hr == S_OK, "got 0x%08x\n", hr);
2625
2626 hr = ITextFont_GetItalic(font, &value);
2627 ok(hr == S_OK, "got 0x%08x\n", hr);
2628 ok(value == tomFalse, "got %d\n", value);
2629
2630 hr = ITextFont_SetItalic(font, tomAutoColor);
2631 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
2632
2633 cf.dwEffects = 0;
2634 SendMessageA(hwnd, EM_SETSEL, 0, 10);
2636 ok(ret, "got %d\n", ret);
2637 ok((cf.dwEffects & CFE_ITALIC) == 0, "got 0x%08x\n", cf.dwEffects);
2638
2639 ITextRange_Release(range);
2640 ITextFont_Release(font);
2641 release_interfaces(&hwnd, &reOle, &doc, NULL);
2642}
2643
2644static void test_Delete(void)
2645{
2646 static const CHAR test_text1[] = "TestSomeText";
2647 IRichEditOle *reOle = NULL;
2648 ITextDocument *doc = NULL;
2649 ITextRange *range, *range2;
2650 LONG value;
2651 HRESULT hr;
2652 HWND hwnd;
2653
2654 create_interfaces(&hwnd, &reOle, &doc, NULL);
2655 SendMessageA(hwnd, WM_SETTEXT, 0, (LPARAM)test_text1);
2656
2657 hr = ITextDocument_Range(doc, 0, 4, &range);
2658 ok(hr == S_OK, "got 0x%08x\n", hr);
2659
2660 hr = ITextDocument_Range(doc, 1, 2, &range2);
2661 ok(hr == S_OK, "got 0x%08x\n", hr);
2662
2663 hr = ITextRange_GetEnd(range, &value);
2664 ok(hr == S_OK, "got 0x%08x\n", hr);
2665 ok(value == 4, "got %d\n", value);
2666
2667 /* unit type doesn't matter is count is 0 */
2668 value = 0;
2669 hr = ITextRange_Delete(range2, tomSentence, 0, &value);
2670todo_wine {
2671 ok(hr == S_OK, "got 0x%08x\n", hr);
2672 ok(value == 1, "got %d\n", value);
2673}
2674 value = 1;
2675 hr = ITextRange_Delete(range2, tomCharacter, 0, &value);
2676todo_wine {
2677 ok(hr == S_FALSE, "got 0x%08x\n", hr);
2678 ok(value == 0, "got %d\n", value);
2679}
2680 hr = ITextRange_GetEnd(range, &value);
2681 ok(hr == S_OK, "got 0x%08x\n", hr);
2683 ok(value == 3, "got %d\n", value);
2684
2685 hr = ITextRange_GetStart(range2, &value);
2686 ok(hr == S_OK, "got 0x%08x\n", hr);
2687 ok(value == 1, "got %d\n", value);
2688
2689 hr = ITextRange_GetEnd(range2, &value);
2690 ok(hr == S_OK, "got 0x%08x\n", hr);
2692 ok(value == 1, "got %d\n", value);
2693
2694 ITextRange_Release(range);
2695 ITextRange_Release(range2);
2696 release_interfaces(&hwnd, &reOle, &doc, NULL);
2697}
2698
2699static void test_SetText(void)
2700{
2701 static const CHAR test_text1[] = "TestSomeText";
2702 static const WCHAR textW[] = {'a','b','c','d','e','f','g','h','i',0};
2703 IRichEditOle *reOle = NULL;
2704 ITextDocument *doc = NULL;
2705 ITextRange *range, *range2;
2706 LONG value;
2707 HRESULT hr;
2708 HWND hwnd;
2709 BSTR str;
2710
2711 create_interfaces(&hwnd, &reOle, &doc, NULL);
2712 SendMessageA(hwnd, WM_SETTEXT, 0, (LPARAM)test_text1);
2713
2714 hr = ITextDocument_Range(doc, 0, 4, &range);
2715 ok(hr == S_OK, "got 0x%08x\n", hr);
2716
2717 hr = ITextDocument_Range(doc, 0, 4, &range2);
2718 ok(hr == S_OK, "got 0x%08x\n", hr);
2719
2720 value = 1;
2721 hr = ITextRange_GetStart(range2, &value);
2722 ok(hr == S_OK, "got 0x%08x\n", hr);
2723 ok(value == 0, "got %d\n", value);
2724
2725 value = 0;
2726 hr = ITextRange_GetEnd(range2, &value);
2727 ok(hr == S_OK, "got 0x%08x\n", hr);
2728 ok(value == 4, "got %d\n", value);
2729
2730 hr = ITextRange_SetText(range, NULL);
2731 ok(hr == S_OK, "got 0x%08x\n", hr);
2732
2733 value = 1;
2734 hr = ITextRange_GetEnd(range2, &value);
2735 ok(hr == S_OK, "got 0x%08x\n", hr);
2736 ok(value == 0, "got %d\n", value);
2737
2739 hr = ITextRange_SetText(range, str);
2740 ok(hr == S_OK, "got 0x%08x\n", hr);
2742
2743 value = 1;
2744 hr = ITextRange_GetStart(range, &value);
2745 ok(hr == S_OK, "got 0x%08x\n", hr);
2746 ok(value == 0, "got %d\n", value);
2747
2748 value = 0;
2749 hr = ITextRange_GetEnd(range, &value);
2750 ok(hr == S_OK, "got 0x%08x\n", hr);
2751 ok(value == 9, "got %d\n", value);
2752
2753 value = 1;
2754 hr = ITextRange_GetStart(range2, &value);
2755 ok(hr == S_OK, "got 0x%08x\n", hr);
2756 ok(value == 0, "got %d\n", value);
2757
2758 value = 0;
2759 hr = ITextRange_GetEnd(range2, &value);
2760 ok(hr == S_OK, "got 0x%08x\n", hr);
2761 ok(value == 0, "got %d\n", value);
2762
2764 hr = ITextRange_SetText(range, str);
2765 ok(hr == S_OK, "got 0x%08x\n", hr);
2766 value = 1;
2767 hr = ITextRange_GetEnd(range, &value);
2768 ok(hr == S_OK, "got 0x%08x\n", hr);
2769 ok(value == 0, "got %d\n", value);
2771
2772 ITextRange_Release(range2);
2773 release_interfaces(&hwnd, &reOle, &doc, NULL);
2774
2775 hr = ITextRange_SetText(range, NULL);
2776 ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
2777
2779 hr = ITextRange_SetText(range, str);
2780 ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
2782
2783 ITextRange_Release(range);
2784}
2785
2786static void test_InRange(void)
2787{
2788 static const CHAR test_text1[] = "TestSomeText";
2789 ITextRange *range, *range2, *range3;
2790 IRichEditOle *reOle = NULL;
2791 ITextDocument *doc = NULL;
2793 LONG value;
2794 HRESULT hr;
2795 HWND hwnd;
2796
2797 create_interfaces(&hwnd, &reOle, &doc, &selection);
2798 SendMessageA(hwnd, WM_SETTEXT, 0, (LPARAM)test_text1);
2799 SendMessageA(hwnd, EM_SETSEL, 1, 2);
2800
2801 hr = ITextDocument_Range(doc, 0, 4, &range);
2802 ok(hr == S_OK, "got 0x%08x\n", hr);
2803
2804 hr = ITextDocument_Range(doc, 0, 4, &range2);
2805 ok(hr == S_OK, "got 0x%08x\n", hr);
2806
2807 /* matches selection */
2808 hr = ITextDocument_Range(doc, 1, 2, &range3);
2809 ok(hr == S_OK, "got 0x%08x\n", hr);
2810
2811 hr = ITextRange_InRange(range, NULL, NULL);
2812 ok(hr == S_FALSE, "got 0x%08x\n", hr);
2813
2814 value = tomTrue;
2815 hr = ITextRange_InRange(range, NULL, &value);
2816 ok(hr == S_FALSE, "got 0x%08x\n", hr);
2817 ok(value == tomFalse, "got %d\n", value);
2818
2819 hr = ITextRange_InRange(range, range2, NULL);
2820 ok(hr == S_OK, "got 0x%08x\n", hr);
2821
2822 value = tomFalse;
2823 hr = ITextRange_InRange(range, range2, &value);
2824 ok(hr == S_OK, "got 0x%08x\n", hr);
2825 ok(value == tomTrue, "got %d\n", value);
2826
2827 /* selection */
2828 hr = ITextSelection_InRange(selection, NULL, NULL);
2829 ok(hr == S_FALSE, "got 0x%08x\n", hr);
2830
2831 value = tomTrue;
2832 hr = ITextSelection_InRange(selection, NULL, &value);
2833 ok(hr == S_FALSE, "got 0x%08x\n", hr);
2834 ok(value == tomFalse, "got %d\n", value);
2835
2836 hr = ITextSelection_InRange(selection, range2, NULL);
2837 ok(hr == S_FALSE, "got 0x%08x\n", hr);
2838
2839 value = tomTrue;
2840 hr = ITextSelection_InRange(selection, range2, &value);
2841 ok(hr == S_FALSE, "got 0x%08x\n", hr);
2842 ok(value == tomFalse, "got %d\n", value);
2843
2844 value = tomTrue;
2845 hr = ITextSelection_InRange(selection, range3, &value);
2846 ok(hr == S_FALSE, "got 0x%08x\n", hr);
2847 ok(value == tomFalse, "got %d\n", value);
2848
2849 /* seems to work on ITextSelection ranges only */
2850 value = tomFalse;
2851 hr = ITextSelection_InRange(selection, (ITextRange*)selection, &value);
2852 ok(hr == S_OK, "got 0x%08x\n", hr);
2853 ok(value == tomTrue, "got %d\n", value);
2854
2855 release_interfaces(&hwnd, &reOle, &doc, NULL);
2856
2857 hr = ITextRange_InRange(range, NULL, NULL);
2858 ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
2859
2860 value = tomTrue;
2861 hr = ITextRange_InRange(range, NULL, &value);
2862 ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
2863 ok(value == tomFalse, "got %d\n", value);
2864
2865 hr = ITextRange_InRange(range, range2, NULL);
2866 ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
2867
2868 value = tomTrue;
2869 hr = ITextRange_InRange(range, range2, &value);
2870 ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
2871 ok(value == tomFalse, "got %d\n", value);
2872
2873 /* selection */
2874 hr = ITextSelection_InRange(selection, NULL, NULL);
2875 ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
2876
2877 value = tomTrue;
2878 hr = ITextSelection_InRange(selection, NULL, &value);
2879 ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
2880 ok(value == tomFalse, "got %d\n", value);
2881
2882 hr = ITextSelection_InRange(selection, range2, NULL);
2883 ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
2884
2885 value = tomTrue;
2886 hr = ITextSelection_InRange(selection, range2, &value);
2887 ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
2888 ok(value == tomFalse, "got %d\n", value);
2889
2890 ITextRange_Release(range);
2891 ITextRange_Release(range2);
2892 ITextRange_Release(range3);
2893 ITextSelection_Release(selection);
2894}
2895
2897{
2898 static const CHAR test_text1[] = "TestSomeText";
2899 ITextRange *range, *range2, *range3;
2900 IRichEditOle *reOle = NULL;
2901 ITextDocument *doc = NULL;
2903 LONG value;
2904 HRESULT hr;
2905 HWND hwnd;
2906
2907 create_interfaces(&hwnd, &reOle, &doc, &selection);
2908 SendMessageA(hwnd, WM_SETTEXT, 0, (LPARAM)test_text1);
2909 SendMessageA(hwnd, EM_SETSEL, 1, 2);
2910
2911 hr = ITextDocument_Range(doc, 0, 4, &range);
2912 ok(hr == S_OK, "got 0x%08x\n", hr);
2913
2914 hr = ITextDocument_Range(doc, 0, 4, &range2);
2915 ok(hr == S_OK, "got 0x%08x\n", hr);
2916
2917 /* matches selection */
2918 hr = ITextDocument_Range(doc, 1, 2, &range3);
2919 ok(hr == S_OK, "got 0x%08x\n", hr);
2920
2921 hr = ITextRange_IsEqual(range, NULL, NULL);
2922 ok(hr == S_FALSE, "got 0x%08x\n", hr);
2923
2924 value = tomTrue;
2925 hr = ITextRange_IsEqual(range, NULL, &value);
2926 ok(hr == S_FALSE, "got 0x%08x\n", hr);
2927 ok(value == tomFalse, "got %d\n", value);
2928
2929 hr = ITextRange_IsEqual(range, range2, NULL);
2930 ok(hr == S_OK, "got 0x%08x\n", hr);
2931
2932 value = tomFalse;
2933 hr = ITextRange_IsEqual(range, range2, &value);
2934 ok(hr == S_OK, "got 0x%08x\n", hr);
2935 ok(value == tomTrue, "got %d\n", value);
2936
2937 value = tomTrue;
2938 hr = ITextRange_IsEqual(range, range3, &value);
2939 ok(hr == S_FALSE, "got 0x%08x\n", hr);
2940 ok(value == tomFalse, "got %d\n", value);
2941
2942 /* selection */
2943 hr = ITextSelection_IsEqual(selection, NULL, NULL);
2944 ok(hr == S_FALSE, "got 0x%08x\n", hr);
2945
2946 value = tomTrue;
2947 hr = ITextSelection_IsEqual(selection, NULL, &value);
2948 ok(hr == S_FALSE, "got 0x%08x\n", hr);
2949 ok(value == tomFalse, "got %d\n", value);
2950
2951 hr = ITextSelection_IsEqual(selection, range2, NULL);
2952 ok(hr == S_FALSE, "got 0x%08x\n", hr);
2953
2954 value = tomTrue;
2955 hr = ITextSelection_IsEqual(selection, range2, &value);
2956 ok(hr == S_FALSE, "got 0x%08x\n", hr);
2957 ok(value == tomFalse, "got %d\n", value);
2958
2959 value = tomTrue;
2960 hr = ITextSelection_IsEqual(selection, range3, &value);
2961 ok(hr == S_FALSE, "got 0x%08x\n", hr);
2962 ok(value == tomFalse, "got %d\n", value);
2963
2964 /* seems to work on ITextSelection ranges only */
2965 value = tomFalse;
2966 hr = ITextSelection_IsEqual(selection, (ITextRange*)selection, &value);
2967 ok(hr == S_OK, "got 0x%08x\n", hr);
2968 ok(value == tomTrue, "got %d\n", value);
2969
2970 release_interfaces(&hwnd, &reOle, &doc, NULL);
2971
2972 hr = ITextRange_IsEqual(range, NULL, NULL);
2973 ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
2974
2975 value = tomTrue;
2976 hr = ITextRange_IsEqual(range, NULL, &value);
2977 ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
2978 ok(value == tomFalse, "got %d\n", value);
2979
2980 hr = ITextRange_IsEqual(range, range2, NULL);
2981 ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
2982
2983 value = tomTrue;
2984 hr = ITextRange_IsEqual(range, range2, &value);
2985 ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
2986 ok(value == tomFalse, "got %d\n", value);
2987
2988 /* selection */
2989 hr = ITextSelection_IsEqual(selection, NULL, NULL);
2990 ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
2991
2992 value = tomTrue;
2993 hr = ITextSelection_IsEqual(selection, NULL, &value);
2994 ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
2995 ok(value == tomFalse, "got %d\n", value);
2996
2997 hr = ITextSelection_IsEqual(selection, range2, NULL);
2998 ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
2999
3000 value = tomTrue;
3001 hr = ITextSelection_IsEqual(selection, range2, &value);
3002 ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
3003 ok(value == tomFalse, "got %d\n", value);
3004
3005 ITextRange_Release(range);
3006 ITextRange_Release(range2);
3007 ITextRange_Release(range3);
3008 ITextSelection_Release(selection);
3009}
3010
3011static void test_Select(void)
3012{
3013 static const CHAR test_text1[] = "TestSomeText";
3014 IRichEditOle *reOle = NULL;
3015 ITextDocument *doc = NULL;
3018 LONG value;
3019 HRESULT hr;
3020 HWND hwnd;
3021
3022 create_interfaces(&hwnd, &reOle, &doc, &selection);
3023 SendMessageA(hwnd, WM_SETTEXT, 0, (LPARAM)test_text1);
3024 SendMessageA(hwnd, EM_SETSEL, 1, 2);
3025
3026 hr = ITextDocument_Range(doc, 0, 4, &range);
3027 ok(hr == S_OK, "got 0x%08x\n", hr);
3028
3029 hr = ITextRange_Select(range);
3030 ok(hr == S_OK, "got 0x%08x\n", hr);
3031
3032 value = 1;
3033 hr = ITextSelection_GetStart(selection, &value);
3034 ok(hr == S_OK, "got 0x%08x\n", hr);
3035 ok(value == 0, "got %d\n", value);
3036
3037 hr = ITextRange_Select(range);
3038 ok(hr == S_OK, "got 0x%08x\n", hr);
3039
3040 hr = ITextSelection_Select(selection);
3041 ok(hr == S_OK, "got 0x%08x\n", hr);
3042
3043 release_interfaces(&hwnd, &reOle, &doc, NULL);
3044
3045 hr = ITextRange_Select(range);
3046 ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
3047
3048 hr = ITextSelection_Select(selection);
3049 ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
3050
3051 ITextRange_Release(range);
3052 ITextSelection_Release(selection);
3053}
3054
3055static void test_GetStoryType(void)
3056{
3057 static const CHAR test_text1[] = "TestSomeText";
3058 IRichEditOle *reOle = NULL;
3059 ITextDocument *doc = NULL;
3062 LONG value;
3063 HRESULT hr;
3064 HWND hwnd;
3065
3066 create_interfaces(&hwnd, &reOle, &doc, &selection);
3067 SendMessageA(hwnd, WM_SETTEXT, 0, (LPARAM)test_text1);
3068 SendMessageA(hwnd, EM_SETSEL, 1, 2);
3069
3070 hr = ITextDocument_Range(doc, 0, 4, &range);
3071 ok(hr == S_OK, "got 0x%08x\n", hr);
3072
3073 hr = ITextRange_GetStoryType(range, NULL);
3074 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
3075
3077 hr = ITextRange_GetStoryType(range, &value);
3078 ok(hr == S_OK, "got 0x%08x\n", hr);
3079 ok(value == tomUnknownStory, "got %d\n", value);
3080
3081 hr = ITextSelection_GetStoryType(selection, NULL);
3082 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
3083
3085 hr = ITextSelection_GetStoryType(selection, &value);
3086 ok(hr == S_OK, "got 0x%08x\n", hr);
3087 ok(value == tomUnknownStory, "got %d\n", value);
3088
3089 release_interfaces(&hwnd, &reOle, &doc, NULL);
3090
3091 hr = ITextRange_GetStoryType(range, NULL);
3092 ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
3093
3094 value = 123;
3095 hr = ITextRange_GetStoryType(range, &value);
3096 ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
3097 ok(value == 123, "got %d\n", value);
3098
3099 hr = ITextSelection_GetStoryType(selection, NULL);
3100 ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
3101
3102 value = 123;
3103 hr = ITextSelection_GetStoryType(selection, &value);
3104 ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
3105 ok(value == 123, "got %d\n", value);
3106
3107 ITextRange_Release(range);
3108 ITextSelection_Release(selection);
3109}
3110
3111static void test_SetFont(void)
3112{
3113 static const CHAR test_text1[] = "TestSomeText";
3114 IRichEditOle *reOle = NULL;
3115 ITextDocument *doc = NULL;
3117 ITextRange *range, *range2;
3118 ITextFont *font, *font2;
3119 LONG value;
3120 HRESULT hr;
3121 HWND hwnd;
3122
3123 create_interfaces(&hwnd, &reOle, &doc, &selection);
3124 SendMessageA(hwnd, WM_SETTEXT, 0, (LPARAM)test_text1);
3125 SendMessageA(hwnd, EM_SETSEL, 1, 2);
3126
3127 hr = ITextDocument_Range(doc, 0, 4, &range);
3128 ok(hr == S_OK, "got 0x%08x\n", hr);
3129
3130 hr = ITextDocument_Range(doc, 5, 2, &range2);
3131 ok(hr == S_OK, "got 0x%08x\n", hr);
3132
3133 EXPECT_REF(range, 1);
3134 hr = ITextRange_GetFont(range, &font);
3135 ok(hr == S_OK, "got 0x%08x\n", hr);
3136 EXPECT_REF(range, 2);
3137
3138 EXPECT_REF(range2, 1);
3139 hr = ITextRange_GetFont(range2, &font2);
3140 ok(hr == S_OK, "got 0x%08x\n", hr);
3141 EXPECT_REF(range2, 2);
3142
3143 hr = ITextRange_SetFont(range, NULL);
3144 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
3145
3146 /* setting same font, no-op */
3147 EXPECT_REF(range, 2);
3148 hr = ITextRange_SetFont(range, font);
3149 ok(hr == S_OK, "got 0x%08x\n", hr);
3150 EXPECT_REF(range, 2);
3151
3152 EXPECT_REF(range2, 2);
3153 EXPECT_REF(range, 2);
3154 hr = ITextRange_SetFont(range, font2);
3155 ok(hr == S_OK, "got 0x%08x\n", hr);
3156 EXPECT_REF(range2, 2);
3157 EXPECT_REF(range, 2);
3158
3159 /* originally range 0-4 is non-italic */
3160 value = tomTrue;
3161 hr = ITextFont_GetItalic(font, &value);
3162 ok(hr == S_OK, "got 0x%08x\n", hr);
3163 ok(value == tomFalse, "got %d\n", value);
3164
3165 /* set range 5-2 to italic, then set this font to range 0-4 */
3166 hr = ITextFont_SetItalic(font2, tomTrue);
3167 ok(hr == S_OK, "got 0x%08x\n", hr);
3168
3169 hr = ITextRange_SetFont(range, font2);
3170 ok(hr == S_OK, "got 0x%08x\n", hr);
3171
3172 value = tomFalse;
3173 hr = ITextFont_GetItalic(font, &value);
3174 ok(hr == S_OK, "got 0x%08x\n", hr);
3175 ok(value == tomTrue, "got %d\n", value);
3176
3177 release_interfaces(&hwnd, &reOle, &doc, NULL);
3178
3179 hr = ITextRange_SetFont(range, NULL);
3180 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
3181
3182 hr = ITextRange_SetFont(range, font);
3183 ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
3184
3185 hr = ITextSelection_SetFont(selection, NULL);
3186 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
3187
3188 hr = ITextSelection_SetFont(selection, font);
3189 ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
3190
3191 ITextFont_Release(font);
3192 ITextFont_Release(font2);
3193 ITextRange_Release(range);
3194 ITextRange_Release(range2);
3195 ITextSelection_Release(selection);
3196}
3197
3198static void fill_reobject_struct(REOBJECT *reobj, LONG cp, LPOLEOBJECT poleobj,
3199 LPSTORAGE pstg, LPOLECLIENTSITE polesite, LONG sizel_cx,
3200 LONG sizel_cy, DWORD aspect, DWORD flags, DWORD user)
3201{
3202 reobj->cbStruct = sizeof(*reobj);
3203 reobj->clsid = CLSID_NULL;
3204 reobj->cp = cp;
3205 reobj->poleobj = poleobj;
3206 reobj->pstg = pstg;
3207 reobj->polesite = polesite;
3208 reobj->sizel.cx = sizel_cx;
3209 reobj->sizel.cy = sizel_cy;
3210 reobj->dvaspect = aspect;
3211 reobj->dwFlags = flags;
3212 reobj->dwUser = user;
3213}
3214
3215#define CHECK_REOBJECT_STRUCT(reole,index,flags,cp,poleobj,pstg,polesite,user) \
3216 _check_reobject_struct(reole, index, flags, cp, poleobj, pstg, polesite, user, __LINE__)
3218 LPOLEOBJECT poleobj, LPSTORAGE pstg, LPOLECLIENTSITE polesite, DWORD user, int line)
3219{
3220 REOBJECT reobj;
3221 HRESULT hr;
3222
3223 reobj.cbStruct = sizeof(reobj);
3224 reobj.cp = cp;
3225 hr = IRichEditOle_GetObject(reole, index, &reobj, flags);
3226 ok(hr == S_OK, "IRichEditOle_GetObject failed: %#x.\n", hr);
3227 ok_(__FILE__,line)(reobj.poleobj == poleobj, "got wrong object interface.\n");
3228 ok_(__FILE__,line)(reobj.pstg == pstg, "got wrong storage interface.\n");
3229 ok_(__FILE__,line)(reobj.polesite == polesite, "got wrong site interface.\n");
3230 ok_(__FILE__,line)(reobj.dwUser == user, "got wrong user-defined value.\n");
3231}
3232
3233#define INSERT_REOBJECT(reole,reobj,cp,user) \
3234 _insert_reobject(reole, reobj, cp, user, __LINE__)
3235static void _insert_reobject(IRichEditOle *reole, REOBJECT *reobj, LONG cp, DWORD user, int line)
3236{
3237 IOleClientSite *clientsite;
3238 HRESULT hr;
3239 hr = IRichEditOle_GetClientSite(reole, &clientsite);
3240 ok_(__FILE__,line)(hr == S_OK, "IRichEditOle_GetClientSite got hr %#x.\n", hr);
3241 fill_reobject_struct(reobj, cp, NULL, NULL, clientsite, 10, 10, DVASPECT_CONTENT, 0, user);
3242 hr = IRichEditOle_InsertObject(reole, reobj);
3243 ok_(__FILE__,line)(hr == S_OK, "IRichEditOle_InsertObject got hr %#x.\n", hr);
3244 IOleClientSite_Release(clientsite);
3245}
3246
3247static void test_InsertObject(void)
3248{
3249 static CHAR test_text1[] = "abcdefg";
3250 IRichEditOle *reole = NULL;
3251 ITextDocument *doc = NULL;
3252 REOBJECT reo1, reo2, reo3, received_reo;
3253 HRESULT hr;
3254 HWND hwnd;
3255 const WCHAR *expected_string;
3256 const CHAR *expected_stringA;
3258 IDataObject *dataobject;
3259 TEXTRANGEA textrange;
3260 FORMATETC formatetc;
3261 CHARRANGE charrange;
3262 GETTEXTEX gettextex;
3263 STGMEDIUM stgmedium;
3264 WCHAR buffer[1024];
3265 CHAR bufferA[1024];
3266 LONG count, result;
3268 BSTR bstr;
3269
3270 create_interfaces(&hwnd, &reole, &doc, &selection);
3271 SendMessageA(hwnd, WM_SETTEXT, 0, (LPARAM)test_text1);
3272
3273 hr = IRichEditOle_InsertObject(reole, NULL);
3274 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
3275
3276 /* insert object1 in (0, 1)*/
3277 SendMessageA(hwnd, EM_SETSEL, 0, 1);
3278 INSERT_REOBJECT(reole, &reo1, REO_CP_SELECTION, 1);
3279 count = IRichEditOle_GetObjectCount(reole);
3280 ok(count == 1, "got wrong object count: %d\n", count);
3281
3282 /* insert object2 in (2, 3)*/
3283 SendMessageA(hwnd, EM_SETSEL, 2, 3);
3284 INSERT_REOBJECT(reole, &reo2, REO_CP_SELECTION, 2);
3285 count = IRichEditOle_GetObjectCount(reole);
3286 ok(count == 2, "got wrong object count: %d\n", count);
3287
3288 /* insert object3 in (1, 2)*/
3289 SendMessageA(hwnd, EM_SETSEL, 1, 2);
3290 INSERT_REOBJECT(reole, &reo3, REO_CP_SELECTION, 3);
3291 count = IRichEditOle_GetObjectCount(reole);
3292 ok(count == 3, "got wrong object count: %d\n", count);
3293
3294 /* tests below show that order of rebject (from 0 to 2) is: reo1,reo3,reo2 */
3295 CHECK_REOBJECT_STRUCT(reole, 0, REO_GETOBJ_ALL_INTERFACES, 0, NULL, NULL, reo1.polesite, 1);
3296 CHECK_REOBJECT_STRUCT(reole, 1, REO_GETOBJ_ALL_INTERFACES, 0, NULL, NULL, reo3.polesite, 3);
3297 CHECK_REOBJECT_STRUCT(reole, 2, REO_GETOBJ_ALL_INTERFACES, 0, NULL, NULL, reo2.polesite, 2);
3298
3299 hr = IRichEditOle_GetObject(reole, 2, NULL, REO_GETOBJ_ALL_INTERFACES);
3300 ok(hr == E_INVALIDARG, "IRichEditOle_GetObject should fail: 0x%08x\n", hr);
3301
3302 received_reo.cbStruct = 0;
3303 hr = IRichEditOle_GetObject(reole, 2, &received_reo, REO_GETOBJ_ALL_INTERFACES);
3304 ok(hr == E_INVALIDARG, "IRichEditOle_GetObject should fail: 0x%08x\n", hr);
3305
3306 CHECK_REOBJECT_STRUCT(reole, 2, REO_GETOBJ_PSTG, 0, NULL, NULL, NULL, 2);
3307 CHECK_REOBJECT_STRUCT(reole, 2, REO_GETOBJ_POLESITE, 0, NULL, NULL, reo2.polesite, 2);
3308
3309 hr = IRichEditOle_GetObject(reole, 3, &received_reo, REO_GETOBJ_POLESITE);
3310 ok(hr == E_INVALIDARG, "IRichEditOle_GetObject should fail: 0x%08x\n", hr);
3311
3312 hr = IRichEditOle_GetObject(reole, 4, &received_reo, REO_GETOBJ_POLESITE);
3313 ok(hr == E_INVALIDARG, "IRichEditOle_GetObject should fail: 0x%08x\n", hr);
3314
3315 hr = IRichEditOle_GetObject(reole, 1024, &received_reo, REO_GETOBJ_POLESITE);
3316 ok(hr == E_INVALIDARG, "IRichEditOle_GetObject should fail: 0x%08x\n", hr);
3317
3318 hr = IRichEditOle_GetObject(reole, -10, &received_reo, REO_GETOBJ_POLESITE);
3319 ok(hr == E_INVALIDARG, "IRichEditOle_GetObject should fail: 0x%08x\n", hr);
3320
3321 /* received_reo will be zeroed before be used */
3322 received_reo.cbStruct = sizeof(received_reo);
3323 received_reo.polesite = (IOleClientSite *)0xdeadbeef;
3324 hr = IRichEditOle_GetObject(reole, 2, &received_reo, REO_GETOBJ_NO_INTERFACES);
3325 ok(hr == S_OK, "IRichEditOle_GetObject failed: 0x%08x\n", hr);
3326 ok(received_reo.polesite == (IOleClientSite *)NULL, "Got wrong site interface.\n");
3327
3328 CHECK_REOBJECT_STRUCT(reole, REO_IOB_USE_CP, REO_GETOBJ_ALL_INTERFACES, 0, NULL, NULL, reo1.polesite, 1);
3329 CHECK_REOBJECT_STRUCT(reole, REO_IOB_USE_CP, REO_GETOBJ_ALL_INTERFACES, 1, NULL, NULL, reo3.polesite, 3);
3330 CHECK_REOBJECT_STRUCT(reole, REO_IOB_USE_CP, REO_GETOBJ_ALL_INTERFACES, 2, NULL, NULL, reo2.polesite, 2);
3331
3332 received_reo.cbStruct = sizeof(received_reo);
3333 received_reo.polesite = (IOleClientSite *)0xdeadbeef;
3334 received_reo.dwUser = 4;
3335 received_reo.cp = 4;
3336 hr = IRichEditOle_GetObject(reole, REO_IOB_USE_CP, &received_reo, REO_GETOBJ_ALL_INTERFACES);
3337 ok(hr == E_INVALIDARG, "IRichEditOle_GetObject should fail: 0x%08x\n", hr);
3338 ok(received_reo.polesite == (IOleClientSite *)0xdeadbeef, "Got wrong site interface.\n");
3339 ok(received_reo.dwUser == 4, "Got wrong user-defined value: %d.\n", received_reo.dwUser);
3340
3341 SendMessageA(hwnd, EM_SETSEL, 0, 1);
3342 CHECK_REOBJECT_STRUCT(reole, REO_IOB_SELECTION, REO_GETOBJ_ALL_INTERFACES, 0, NULL, NULL, reo1.polesite, 1);
3343
3344 SendMessageA(hwnd, EM_SETSEL, 1, 2);
3345 CHECK_REOBJECT_STRUCT(reole, REO_IOB_SELECTION, REO_GETOBJ_ALL_INTERFACES, 0, NULL, NULL, reo3.polesite, 3);
3346
3347 SendMessageA(hwnd, EM_SETSEL, 2, 3);
3348 CHECK_REOBJECT_STRUCT(reole, REO_IOB_SELECTION, REO_GETOBJ_ALL_INTERFACES, 0, NULL, NULL, reo2.polesite, 2);
3349
3350 SendMessageA(hwnd, EM_SETSEL, 0, 2);
3351 CHECK_REOBJECT_STRUCT(reole, REO_IOB_SELECTION, REO_GETOBJ_ALL_INTERFACES, 0, NULL, NULL, reo1.polesite, 1);
3352
3353 SendMessageA(hwnd, EM_SETSEL, 1, 3);
3354 CHECK_REOBJECT_STRUCT(reole, REO_IOB_SELECTION, REO_GETOBJ_ALL_INTERFACES, 0, NULL, NULL, reo3.polesite, 3);
3355
3356 SendMessageA(hwnd, EM_SETSEL, 2, 0);
3357 CHECK_REOBJECT_STRUCT(reole, REO_IOB_SELECTION, REO_GETOBJ_ALL_INTERFACES, 0, NULL, NULL, reo1.polesite, 1);
3358
3359 SendMessageA(hwnd, EM_SETSEL, 0, 6);
3360 CHECK_REOBJECT_STRUCT(reole, REO_IOB_SELECTION, REO_GETOBJ_ALL_INTERFACES, 0, NULL, NULL, reo1.polesite, 1);
3361
3362 SendMessageA(hwnd, EM_SETSEL, 4, 5);
3363 received_reo.cbStruct = sizeof(received_reo);
3364 received_reo.cp = 0;
3365 hr = IRichEditOle_GetObject(reole, REO_IOB_SELECTION, &received_reo, REO_GETOBJ_ALL_INTERFACES);
3366 ok(hr == E_INVALIDARG, "IRichEditOle_GetObject should fail: 0x%08x\n", hr);
3367
3368 SendMessageA(hwnd, WM_SETTEXT, 0, (LPARAM)test_text1);
3369
3370 /* "abc|d|efg" */
3371 INSERT_REOBJECT(reole, &reo1, 3, 1);
3372 INSERT_REOBJECT(reole, &reo2, 5, 2);
3373
3374 SendMessageW(hwnd, EM_SETSEL, 2, 3);
3376 ok(result == SEL_TEXT, "Got selection type: %x.\n", result);
3377
3378 SendMessageW(hwnd, EM_SETSEL, 3, 4);
3380 todo_wine ok(result == SEL_OBJECT, "Got selection type: %x.\n", result);
3381 todo_wine CHECK_REOBJECT_STRUCT(reole, REO_IOB_SELECTION, REO_GETOBJ_ALL_INTERFACES, 1, NULL, NULL, reo1.polesite, 1);
3382
3383 SendMessageW(hwnd, EM_SETSEL, 2, 4);
3385 todo_wine ok(result == (SEL_TEXT | SEL_OBJECT), "Got selection type: %x.\n", result);
3386
3387 SendMessageW(hwnd, EM_SETSEL, 5, 6);
3388 todo_wine CHECK_REOBJECT_STRUCT(reole, REO_IOB_SELECTION, REO_GETOBJ_ALL_INTERFACES, 1, NULL, NULL, reo2.polesite, 2);
3389
3390#ifdef __REACTOS__
3391 expected_string = L"abc\xfffc"L"d\xfffc"L"efg";
3392#else
3393 expected_string = L"abc\xfffc""d\xfffc""efg";
3394#endif
3395
3396 gettextex.cb = sizeof(buffer);
3397 gettextex.flags = GT_DEFAULT;
3398 gettextex.codepage = 1200;
3399 gettextex.lpDefaultChar = NULL;
3400 gettextex.lpUsedDefChar = NULL;
3402 ok(result == lstrlenW(expected_string), "Got wrong length: %d.\n", result);
3403 todo_wine ok(!lstrcmpW(buffer, expected_string), "Got wrong content: %s.\n", debugstr_w(buffer));
3404
3405 gettextex.flags = GT_RAWTEXT;
3406 memset(buffer, 0, sizeof(buffer));
3408 ok(result == lstrlenW(expected_string), "Got wrong length: %d.\n", result);
3409 todo_wine ok(!lstrcmpW(buffer, expected_string), "Got wrong content: %s.\n", debugstr_w(buffer));
3410
3411 expected_stringA = "abc d efg";
3412 memset(bufferA, 0, sizeof(bufferA));
3413 SendMessageA(hwnd, EM_SETSEL, 0, -1);
3414 result = SendMessageA(hwnd, EM_GETSELTEXT, (WPARAM)sizeof(bufferA), (LPARAM)bufferA);
3415 ok(result == strlen(expected_stringA), "Got wrong length: %d.\n", result);
3416 todo_wine ok(!strcmp(bufferA, expected_stringA), "Got wrong content: %s.\n", bufferA);
3417
3418 memset(bufferA, 0, sizeof(bufferA));
3419 textrange.lpstrText = bufferA;
3420 textrange.chrg.cpMin = 0;
3421 textrange.chrg.cpMax = 11;
3422 result = SendMessageA(hwnd, EM_GETTEXTRANGE, 0, (LPARAM)&textrange);
3423 ok(result == strlen(expected_stringA), "Got wrong length: %d.\n", result);
3424 todo_wine ok(!strcmp(bufferA, expected_stringA), "Got wrong content: %s.\n", bufferA);
3425
3426#ifdef __REACTOS__
3427 expected_string = L"abc\xfffc"L"d\xfffc"L"efg\r";
3428#else
3429 expected_string = L"abc\xfffc""d\xfffc""efg\r";
3430#endif
3431
3432 hr = ITextDocument_Range(doc, 0, 11, &range);
3433 ok(hr == S_OK, "Got hr %#x.\n", hr);
3434 hr = ITextRange_GetText(range, &bstr);
3435 ok(hr == S_OK, "Got hr %#x.\n", hr);
3436 ok(lstrlenW(bstr) == lstrlenW(expected_string), "Got wrong length: %d.\n", lstrlenW(bstr));
3437 todo_wine ok(!lstrcmpW(bstr, expected_string), "Got text: %s.\n", wine_dbgstr_w(bstr));
3438 SysFreeString(bstr);
3439 hr = ITextRange_SetRange(range, 3, 4);
3440 ok(hr == S_OK, "Got hr %#x.\n", hr);
3441 hr = ITextRange_GetChar(range, &result);
3442 ok(hr == S_OK, "Got hr %#x.\n", hr);
3443 todo_wine ok(result == 0xfffc, "Got char: %c\n", result);
3444 ITextRange_Release(range);
3445
3446 SendMessageW(hwnd, EM_SETSEL, 0, -1);
3447 hr = ITextSelection_GetText(selection, &bstr);
3448 ok(hr == S_OK, "Got hr %#x.\n", hr);
3449 ok(lstrlenW(bstr) == lstrlenW(expected_string), "Got wrong length: %d.\n", lstrlenW(bstr));
3450 todo_wine ok(!lstrcmpW(bstr, expected_string), "Got text: %s.\n", wine_dbgstr_w(bstr));
3451 SysFreeString(bstr);
3452 SendMessageW(hwnd, EM_SETSEL, 3, 4);
3453 result = 0;
3454 hr = ITextSelection_GetChar(selection, &result);
3455 ok(hr == S_OK, "Got hr %#x.\n", hr);
3456 todo_wine ok(result == 0xfffc, "Got char: %c\n", result);
3457
3460 ok(!result, "Got result %x.\n", result);
3461 /* "abc|d|efg" */
3462 SendMessageA(hwnd, WM_SETTEXT, 0, (LPARAM)test_text1);
3463 INSERT_REOBJECT(reole, &reo1, 3, 1);
3464 INSERT_REOBJECT(reole, &reo2, 5, 2);
3465
3466 expected_string = L"abc d efg";
3467 charrange.cpMin = 0;
3468 charrange.cpMax = 11;
3469 hr = IRichEditOle_GetClipboardData(reole, &charrange, 1, &dataobject);
3470 ok(hr == S_OK, "Got hr %#x.\n", hr);
3471 formatetc.cfFormat = CF_UNICODETEXT;
3472 formatetc.dwAspect = DVASPECT_CONTENT;
3473 formatetc.ptd = NULL;
3474 formatetc.tymed = TYMED_HGLOBAL;
3475 formatetc.lindex = -1;
3476 hr = IDataObject_GetData(dataobject, &formatetc, &stgmedium);
3477 ok(hr == S_OK, "Got hr %#x.\n", hr);
3478 todo_wine ok(lstrlenW(stgmedium.hGlobal) == lstrlenW(expected_string), "Got wrong length: %d.\n", result);
3479 todo_wine ok(!lstrcmpW(stgmedium.hGlobal, expected_string), "Got wrong content: %s.\n", debugstr_w(stgmedium.hGlobal));
3480
3481#ifdef __REACTOS__
3482 expected_string = L"abc\xfffc"L"d\xfffc"L"efg";
3483#else
3484 expected_string = L"abc\xfffc""d\xfffc""efg";
3485#endif
3486
3487 gettextex.cb = sizeof(buffer);
3488 gettextex.flags = GT_DEFAULT;
3489 gettextex.codepage = 1200;
3490 gettextex.lpDefaultChar = NULL;
3491 gettextex.lpUsedDefChar = NULL;
3493 ok(result == lstrlenW(expected_string), "Got wrong length: %d.\n", result);
3494 todo_wine ok(!lstrcmpW(buffer, expected_string), "Got wrong content: %s.\n", debugstr_w(buffer));
3495
3496 gettextex.flags = GT_RAWTEXT;
3497 memset(buffer, 0, sizeof(buffer));
3499 ok(result == lstrlenW(expected_string), "Got wrong length: %d.\n", result);
3500 todo_wine ok(!lstrcmpW(buffer, expected_string), "Got wrong content: %s.\n", debugstr_w(buffer));
3501
3502 expected_stringA = "abc d efg";
3503 memset(bufferA, 0, sizeof(bufferA));
3504 SendMessageA(hwnd, EM_SETSEL, 0, -1);
3505 result = SendMessageA(hwnd, EM_GETSELTEXT, (WPARAM)sizeof(bufferA), (LPARAM)bufferA);
3506 ok(result == strlen(expected_stringA), "Got wrong length: %d.\n", result);
3507 todo_wine ok(!strcmp(bufferA, expected_stringA), "Got wrong content: %s.\n", bufferA);
3508
3509 memset(bufferA, 0, sizeof(bufferA));
3510 textrange.lpstrText = bufferA;
3511 textrange.chrg.cpMin = 0;
3512 textrange.chrg.cpMax = 11;
3513 result = SendMessageA(hwnd, EM_GETTEXTRANGE, 0, (LPARAM)&textrange);
3514 ok(result == strlen(expected_stringA), "Got wrong length: %d.\n", result);
3515 todo_wine ok(!strcmp(bufferA, expected_stringA), "Got wrong content: %s.\n", bufferA);
3516
3517#ifdef __REACTOS__
3518 expected_string = L"abc\xfffc"L"d\xfffc"L"efg";
3519#else
3520 expected_string = L"abc\xfffc""d\xfffc""efg";
3521#endif
3522
3523 hr = ITextDocument_Range(doc, 0, 11, &range);
3524 ok(hr == S_OK, "Got hr %#x.\n", hr);
3525 hr = ITextRange_GetText(range, &bstr);
3526 ok(hr == S_OK, "Got hr %#x.\n", hr);
3527 todo_wine ok(lstrlenW(bstr) == lstrlenW(expected_string), "Got wrong length: %d.\n", lstrlenW(bstr));
3528 todo_wine ok(!lstrcmpW(bstr, expected_string), "Got text: %s.\n", wine_dbgstr_w(bstr));
3529 SysFreeString(bstr);
3530 hr = ITextRange_SetRange(range, 3, 4);
3531 ok(hr == S_OK, "Got hr %#x.\n", hr);
3532 hr = ITextRange_GetChar(range, &result);
3533 ok(hr == S_OK, "Got hr %#x.\n", hr);
3534 todo_wine ok(result == 0xfffc, "Got char: %c\n", result);
3535 ITextRange_Release(range);
3536
3537 SendMessageW(hwnd, EM_SETSEL, 0, -1);
3538 hr = ITextSelection_GetText(selection, &bstr);
3539 ok(hr == S_OK, "Got hr %#x.\n", hr);
3540 todo_wine ok(lstrlenW(bstr) == lstrlenW(expected_string), "Got wrong length: %d.\n", lstrlenW(bstr));
3541 todo_wine ok(!lstrcmpW(bstr, expected_string), "Got text: %s.\n", wine_dbgstr_w(bstr));
3542 SysFreeString(bstr);
3543 SendMessageW(hwnd, EM_SETSEL, 3, 4);
3544 result = 0;
3545 hr = ITextSelection_GetChar(selection, &result);
3546 ok(hr == S_OK, "Got hr %#x.\n", hr);
3547 todo_wine ok(result == 0xfffc, "Got char: %c\n", result);
3548
3549 release_interfaces(&hwnd, &reole, &doc, &selection);
3550}
3551
3552static void test_GetStoryLength(void)
3553{
3554 static const CHAR test_text1[] = "TestSomeText";
3555 IRichEditOle *reOle = NULL;
3556 ITextDocument *doc = NULL;
3559 LONG value;
3560 HRESULT hr;
3561 HWND hwnd;
3562
3563 create_interfaces(&hwnd, &reOle, &doc, &selection);
3564 SendMessageA(hwnd, WM_SETTEXT, 0, (LPARAM)test_text1);
3565 SendMessageA(hwnd, EM_SETSEL, 1, 2);
3566
3567 hr = ITextDocument_Range(doc, 0, 4, &range);
3568 ok(hr == S_OK, "got 0x%08x\n", hr);
3569
3570 hr = ITextRange_GetStoryLength(range, NULL);
3571 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
3572
3573 value = 0;
3574 hr = ITextRange_GetStoryLength(range, &value);
3575 ok(hr == S_OK, "got 0x%08x\n", hr);
3576 ok(value == 13, "got %d\n", value);
3577
3578 hr = ITextSelection_GetStoryLength(selection, NULL);
3579 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
3580
3581 value = 0;
3582 hr = ITextSelection_GetStoryLength(selection, &value);
3583 ok(hr == S_OK, "got 0x%08x\n", hr);
3584 ok(value == 13, "got %d\n", value);
3585
3587
3588 value = 0;
3589 hr = ITextRange_GetStoryLength(range, &value);
3590 ok(hr == S_OK, "got 0x%08x\n", hr);
3591 ok(value == 1, "got %d\n", value);
3592
3593 value = 0;
3594 hr = ITextSelection_GetStoryLength(selection, &value);
3595 ok(hr == S_OK, "got 0x%08x\n", hr);
3596 ok(value == 1, "got %d\n", value);
3597
3598 release_interfaces(&hwnd, &reOle, &doc, NULL);
3599
3600 hr = ITextRange_GetStoryLength(range, NULL);
3601 ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
3602
3603 value = 100;
3604 hr = ITextRange_GetStoryLength(range, &value);
3605 ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
3606 ok(value == 100, "got %d\n", value);
3607
3608 hr = ITextSelection_GetStoryLength(selection, NULL);
3609 ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
3610
3611 value = 100;
3612 hr = ITextSelection_GetStoryLength(selection, &value);
3613 ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
3614 ok(value == 100, "got %d\n", value);
3615
3616 ITextSelection_Release(selection);
3617 ITextRange_Release(range);
3618}
3619
3621{
3622 static const CHAR test_text1[] = "TestSomeText";
3623 IRichEditOle *reOle = NULL;
3624 ITextDocument *doc = NULL;
3625 ITextSelection *selection, *sel2;
3626 ITextRange *range, *range2;
3627 ITextFont *font;
3628 LONG value;
3629 HRESULT hr;
3630 HWND hwnd;
3631
3632 create_interfaces(&hwnd, &reOle, &doc, &selection);
3633 SendMessageA(hwnd, WM_SETTEXT, 0, (LPARAM)test_text1);
3634 SendMessageA(hwnd, EM_SETSEL, 1, 2);
3635
3636 hr = ITextSelection_GetDuplicate(selection, NULL);
3637 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
3638
3640
3641 hr = ITextSelection_GetDuplicate(selection, &range);
3642 ok(hr == S_OK, "got 0x%08x\n", hr);
3643
3644 hr = ITextSelection_GetDuplicate(selection, &range2);
3645 ok(hr == S_OK, "got 0x%08x\n", hr);
3646 ok(range != range2, "got %p, %p\n", range, range2);
3647
3649 EXPECT_REF(range, 1);
3650 EXPECT_REF(range2, 1);
3651
3652 ITextRange_Release(range2);
3653
3654 value = 0;
3655 hr = ITextRange_GetStart(range, &value);
3656 ok(hr == S_OK, "got 0x%08x\n", hr);
3657 ok(value == 1, "got %d\n", value);
3658
3659 value = 0;
3660 hr = ITextRange_GetEnd(range, &value);
3661 ok(hr == S_OK, "got 0x%08x\n", hr);
3662 ok(value == 2, "got %d\n", value);
3663
3664 SendMessageA(hwnd, EM_SETSEL, 2, 3);
3665
3666 value = 0;
3667 hr = ITextRange_GetStart(range, &value);
3668 ok(hr == S_OK, "got 0x%08x\n", hr);
3669 ok(value == 1, "got %d\n", value);
3670
3671 value = 0;
3672 hr = ITextRange_GetEnd(range, &value);
3673 ok(hr == S_OK, "got 0x%08x\n", hr);
3674 ok(value == 2, "got %d\n", value);
3675
3676 hr = ITextRange_QueryInterface(range, &IID_ITextSelection, (void**)&sel2);
3677 ok(hr == E_NOINTERFACE, "got 0x%08x\n", hr);
3678
3679 release_interfaces(&hwnd, &reOle, &doc, NULL);
3680
3681 hr = ITextSelection_GetDuplicate(selection, NULL);
3682 ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
3683
3684 hr = ITextSelection_GetDuplicate(selection, &range);
3685 ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
3686
3687 hr = ITextRange_GetFont(range, &font);
3688 ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
3689
3690 ITextSelection_Release(selection);
3691 ITextRange_Release(range);
3692}
3693
3694#define RESET_RANGE(range,start,end) \
3695 _reset_range(range, start, end, __LINE__)
3697{
3698 HRESULT hr;
3699
3700 hr = ITextRange_SetStart(range, start);
3701 ok_(__FILE__,line)(hr == S_OK, "SetStart failed: 0x%08x\n", hr);
3702 hr = ITextRange_SetEnd(range, end);
3703 ok_(__FILE__,line)(hr == S_OK, "SetEnd failed: 0x%08x\n", hr);
3704}
3705
3706#define CHECK_RANGE(range,expected_start,expected_end) \
3707 _check_range(range, expected_start, expected_end, __LINE__)
3708static void _check_range(ITextRange* range, LONG expected_start, LONG expected_end, int line)
3709{
3710 HRESULT hr;
3711 LONG value;
3712
3713 hr = ITextRange_GetStart(range, &value);
3714 ok_(__FILE__,line)(hr == S_OK, "GetStart failed: 0x%08x\n", hr);
3715 ok_(__FILE__,line)(value == expected_start, "Expected start %d got %d\n",
3716 expected_start, value);
3717 hr = ITextRange_GetEnd(range, &value);
3718 ok_(__FILE__,line)(hr == S_OK, "GetEnd failed: 0x%08x\n", hr);
3719 ok_(__FILE__,line)(value == expected_end, "Expected end %d got %d\n",
3720 expected_end, value);
3721}
3722
3723#define RESET_SELECTION(selection,start,end) \
3724 _reset_selection(selection, start, end, __LINE__)
3726{
3727 HRESULT hr;
3728
3729 hr = ITextSelection_SetStart(selection, start);
3730 ok_(__FILE__,line)(hr == S_OK, "SetStart failed: 0x%08x\n", hr);
3731 hr = ITextSelection_SetEnd(selection, end);
3732 ok_(__FILE__,line)(hr == S_OK, "SetEnd failed: 0x%08x\n", hr);
3733}
3734
3735#define CHECK_SELECTION(selection,expected_start,expected_end) \
3736 _check_selection(selection, expected_start, expected_end, __LINE__)
3737static void _check_selection(ITextSelection *selection, LONG expected_start, LONG expected_end, int line)
3738{
3739 HRESULT hr;
3740 LONG value;
3741
3742 hr = ITextSelection_GetStart(selection, &value);
3743 ok_(__FILE__,line)(hr == S_OK, "GetStart failed: 0x%08x\n", hr);
3744 ok_(__FILE__,line)(value == expected_start, "Expected start %d got %d\n",
3745 expected_start, value);
3746 hr = ITextSelection_GetEnd(selection, &value);
3747 ok_(__FILE__,line)(hr == S_OK, "GetEnd failed: 0x%08x\n", hr);
3748 ok_(__FILE__,line)(value == expected_end, "Expected end %d got %d\n",
3749 expected_end, value);
3750}
3751
3753{
3754 static const CHAR test_text1[] = "TestSomeText";
3755 ITextDocument *txtDoc = NULL;
3756 IRichEditOle *reOle = NULL;
3757 ITextRange *txtRge = NULL;
3758 HRESULT hr;
3759 HWND w;
3760
3761 create_interfaces(&w, &reOle, &txtDoc, NULL);
3762 SendMessageA(w, WM_SETTEXT, 0, (LPARAM)test_text1);
3763 ITextDocument_Range(txtDoc, 0, 0, &txtRge);
3764
3765 hr = ITextRange_SetRange(txtRge, 2, 4);
3766 ok(hr == S_OK, "got 0x%08x.\n", hr);
3767 CHECK_RANGE(txtRge, 2, 4);
3768
3769 hr = ITextRange_SetRange(txtRge, 2, 4);
3770 ok(hr == S_FALSE, "got 0x%08x.\n", hr);
3771 CHECK_RANGE(txtRge, 2, 4);
3772
3773 hr = ITextRange_SetRange(txtRge, 4, 2);
3774 ok(hr == S_FALSE, "got 0x%08x.\n", hr);
3775 CHECK_RANGE(txtRge, 2, 4);
3776
3777 hr = ITextRange_SetRange(txtRge, 14, 14);
3778 ok(hr == S_OK, "got 0x%08x.\n", hr);
3779 CHECK_RANGE(txtRge, 12, 12);
3780
3781 hr = ITextRange_SetRange(txtRge, 15, 15);
3782 ok(hr == S_FALSE, "got 0x%08x.\n", hr);
3783 CHECK_RANGE(txtRge, 12, 12);
3784
3785 hr = ITextRange_SetRange(txtRge, 14, 1);
3786 ok(hr == S_OK, "got 0x%08x.\n", hr);
3787 CHECK_RANGE(txtRge, 1, 13);
3788
3789 hr = ITextRange_SetRange(txtRge, -1, 4);
3790 ok(hr == S_OK, "got 0x%08x.\n", hr);
3791 CHECK_RANGE(txtRge, 0, 4);
3792
3793 ITextRange_Release(txtRge);
3794 release_interfaces(&w, &reOle, &txtDoc, NULL);
3795}
3796
3797static void test_Expand(void)
3798{
3799 static const char test_text1[] = "TestSomeText";
3800 IRichEditOle *reole = NULL;
3801 ITextDocument *doc = NULL;
3804 LONG value;
3805 HRESULT hr;
3806 HWND hwnd;
3807
3808 create_interfaces(&hwnd, &reole, &doc, &selection);
3809 SendMessageA(hwnd, WM_SETTEXT, 0, (LPARAM)test_text1);
3810 SendMessageA(hwnd, EM_SETSEL, 1, 2);
3811
3812 hr = ITextDocument_Range(doc, 0, 4, &range);
3813 ok(hr == S_OK, "got 0x%08x\n", hr);
3814
3815 hr = ITextRange_Expand(range, tomStory, NULL);
3816 ok(hr == S_OK, "got 0x%08x\n", hr);
3817 CHECK_RANGE(range, 0, 13);
3818
3819 hr = ITextSelection_Expand(selection, tomStory, NULL);
3820 ok(hr == S_OK, "got 0x%08x\n", hr);
3821 CHECK_SELECTION(selection, 0, 13);
3822
3823 RESET_RANGE(range, 1, 2);
3825
3826 value = 0;
3827 hr = ITextRange_Expand(range, tomStory, &value);
3828 ok(hr == S_OK, "got 0x%08x\n", hr);
3829 ok(value == 12, "got %d\n", value);
3830 CHECK_RANGE(range, 0, 13);
3831
3832 value = 0;
3833 hr = ITextSelection_Expand(selection, tomStory, &value);
3834 ok(hr == S_OK, "got 0x%08x\n", hr);
3835 ok(value == 12, "got %d\n", value);
3836 CHECK_SELECTION(selection, 0, 13);
3837
3838 release_interfaces(&hwnd, &reole, &doc, NULL);
3839
3840 hr = ITextRange_Expand(range, tomStory, NULL);
3841 ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
3842
3843 hr = ITextRange_Expand(range, tomStory, &value);
3844 ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
3845
3846 hr = ITextSelection_Expand(selection, tomStory, NULL);
3847 ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
3848
3849 hr = ITextSelection_Expand(selection, tomStory, &value);
3850 ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
3851
3852 ITextSelection_Release(selection);
3853 ITextRange_Release(range);
3854}
3855
3856static void test_MoveEnd_story(void)
3857{
3858 static const char test_text1[] = "Word1 Word2";
3859 IRichEditOle *reole = NULL;
3860 ITextDocument *doc = NULL;
3863 LONG delta;
3864 HRESULT hr;
3865 HWND hwnd;
3866
3867 create_interfaces(&hwnd, &reole, &doc, &selection);
3868 SendMessageA(hwnd, WM_SETTEXT, 0, (LPARAM)test_text1);
3869 SendMessageA(hwnd, EM_SETSEL, 1, 2);
3870
3871 hr = ITextDocument_Range(doc, 1, 2, &range);
3872 ok(hr == S_OK, "got 0x%08x\n", hr);
3873
3874 hr = ITextRange_MoveEnd(range, tomStory, 0, &delta);
3875 ok(hr == S_FALSE, "got 0x%08x\n", hr);
3876 ok(delta == 0, "got %d\n", delta);
3877 CHECK_RANGE(range, 1, 2);
3878
3879 hr = ITextRange_MoveEnd(range, tomStory, -1, &delta);
3880 ok(hr == S_OK, "got 0x%08x\n", hr);
3881 ok(delta == -1, "got %d\n", delta);
3882 CHECK_RANGE(range, 0, 0);
3883
3884 hr = ITextRange_MoveEnd(range, tomStory, 1, &delta);
3885 ok(hr == S_OK, "got 0x%08x\n", hr);
3886 ok(delta == 1, "got %d\n", delta);
3887 CHECK_RANGE(range, 0, 12);
3888
3889 hr = ITextRange_MoveEnd(range, tomStory, 1, &delta);
3890 ok(hr == S_FALSE, "got 0x%08x\n", hr);
3891 ok(delta == 0, "got %d\n", delta);
3892 CHECK_RANGE(range, 0, 12);
3893
3894 RESET_RANGE(range, 1, 2);
3895
3896 hr = ITextRange_MoveEnd(range, tomStory, 3, &delta);
3897 ok(hr == S_OK, "got 0x%08x\n", hr);
3898 ok(delta == 1, "got %d\n", delta);
3899 CHECK_RANGE(range, 1, 12);
3900
3901 RESET_RANGE(range, 2, 3);
3902
3903 hr = ITextRange_MoveEnd(range, tomStory, -3, &delta);
3904 ok(hr == S_OK, "got 0x%08x\n", hr);
3905 ok(delta == -1, "got %d\n", delta);
3906 CHECK_RANGE(range, 0, 0);
3907
3908 hr = ITextRange_MoveEnd(range, tomStory, -1, &delta);
3909 ok(hr == S_FALSE, "got 0x%08x\n", hr);
3910 ok(delta == 0, "got %d\n", delta);
3911 CHECK_RANGE(range, 0, 0);
3912
3913 hr = ITextSelection_MoveEnd(selection, tomStory, 0, &delta);
3914 ok(hr == S_FALSE, "got 0x%08x\n", hr);
3915 ok(delta == 0, "got %d\n", delta);
3917
3918 hr = ITextSelection_MoveEnd(selection, tomStory, -1, &delta);
3919 ok(hr == S_OK, "got 0x%08x\n", hr);
3920 ok(delta == -1, "got %d\n", delta);
3922
3923 hr = ITextSelection_MoveEnd(selection, tomStory, 1, &delta);
3924 ok(hr == S_OK, "got 0x%08x\n", hr);
3925 ok(delta == 1, "got %d\n", delta);
3926 CHECK_SELECTION(selection, 0, 12);
3927
3928 hr = ITextSelection_MoveEnd(selection, tomStory, 1, &delta);
3929 ok(hr == S_FALSE, "got 0x%08x\n", hr);
3930 ok(delta == 0, "got %d\n", delta);
3931 CHECK_SELECTION(selection, 0, 12);
3932
3934
3935 hr = ITextSelection_MoveEnd(selection, tomStory, 3, &delta);
3936 ok(hr == S_OK, "got 0x%08x\n", hr);
3937 ok(delta == 1, "got %d\n", delta);
3938 CHECK_SELECTION(selection, 1, 12);
3939
3941
3942 hr = ITextSelection_MoveEnd(selection, tomStory, -3, &delta);
3943 ok(hr == S_OK, "got 0x%08x\n", hr);
3944 ok(delta == -1, "got %d\n", delta);
3946
3947 hr = ITextSelection_MoveEnd(selection, tomStory, -1, &delta);
3948 ok(hr == S_FALSE, "got 0x%08x\n", hr);
3949 ok(delta == 0, "got %d\n", delta);
3951
3952 release_interfaces(&hwnd, &reole, &doc, NULL);
3953
3954 hr = ITextRange_MoveEnd(range, tomStory, 1, NULL);
3955 ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
3956
3957 hr = ITextRange_MoveEnd(range, tomStory, 1, &delta);
3958 ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
3959
3960 hr = ITextSelection_MoveEnd(selection, tomStory, 1, NULL);
3961 ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
3962
3963 hr = ITextSelection_MoveEnd(selection, tomStory, 1, &delta);
3964 ok(hr == CO_E_RELEASED, "got 0x%08x\n", hr);
3965
3966 ITextSelection_Release(selection);
3967 ITextRange_Release(range);
3968}
3969
3970static void test_character_movestart(ITextRange *range, int textlen, int i, int j, LONG target)
3971{
3972 HRESULT hr;
3973 LONG delta = 0;
3974 LONG expected_delta;
3975 LONG expected_start = target;
3976
3977 if (expected_start < 0)
3978 expected_start = 0;
3979 else if (expected_start > textlen)
3980 expected_start = textlen;
3981 expected_delta = expected_start - i;
3982 hr = ITextRange_SetRange(range, i, j);
3983 ok(SUCCEEDED(hr), "got 0x%08x\n", hr);
3984 hr = ITextRange_MoveStart(range, tomCharacter, target - i, &delta);
3985 if (expected_start == i) {
3986 ok(hr == S_FALSE, "(%d,%d) move by %d got hr=0x%08x\n", i, j, target - i, hr);
3987 ok(delta == 0, "(%d,%d) move by %d got delta %d\n", i, j, target - i, delta);
3988 CHECK_RANGE(range, i, j);
3989 } else {
3990 ok(hr == S_OK, "(%d,%d) move by %d got hr=0x%08x\n", i, j, target - i, hr);
3991 ok(delta == expected_delta, "(%d,%d) move by %d got delta %d\n", i, j, target - i, delta);
3992 if (expected_start <= j)
3993 CHECK_RANGE(range, expected_start, j);
3994 else
3995 CHECK_RANGE(range, expected_start, expected_start);
3996 }
3997}
3998
3999static void test_character_moveend(ITextRange *range, int textlen, int i, int j, LONG target)
4000{
4001 HRESULT hr;
4002 LONG delta;
4003 LONG expected_delta;
4004 LONG expected_end = target;
4005
4006 if (expected_end < 0)
4007 expected_end = 0;
4008 else if (expected_end > textlen + 1)
4009 expected_end = textlen + 1;
4010 expected_delta = expected_end - j;
4011 hr = ITextRange_SetRange(range, i, j);
4012 ok(SUCCEEDED(hr), "got 0x%08x\n", hr);
4013 hr = ITextRange_MoveEnd(range, tomCharacter, target - j, &delta);
4014 if (expected_end == j) {
4015 ok(hr == S_FALSE, "(%d,%d) move by %d got hr=0x%08x\n", i, j, target - j, hr);
4016 ok(delta == 0, "(%d,%d) move by %d got delta %d\n", i, j, target - j, delta);
4017 CHECK_RANGE(range, i, j);
4018 } else {
4019 ok(hr == S_OK, "(%d,%d) move by %d got hr=0x%08x\n", i, j, target - j, hr);
4020 ok(delta == expected_delta, "(%d,%d) move by %d got delta %d\n", i, j, target - j, delta);
4021 if (i <= expected_end)
4022 CHECK_RANGE(range, i, expected_end);
4023 else
4024 CHECK_RANGE(range, expected_end, expected_end);
4025 }
4026}
4027
4028static void test_character_move(ITextRange *range, int textlen, int i, int j, LONG target)
4029{
4030 HRESULT hr;
4031 LONG move_by;
4032 LONG delta = 0;
4033 LONG expected_delta;
4034 LONG expected_location = target;
4035
4036 if (expected_location < 0)
4037 expected_location = 0;
4038 else if (expected_location > textlen)
4039 expected_location = textlen;
4040
4041 if (target <= i) {
4042 move_by = target - i;
4043 expected_delta = expected_location - i;
4044 if (i != j) {
4045 --move_by;
4046 --expected_delta;
4047 }
4048 } else if (j <= target) {
4049 move_by = target - j;
4050 expected_delta = expected_location - j;
4051 if (i != j) {
4052 ++move_by;
4053 ++expected_delta;
4054 }
4055 } else {
4056 /* There's no way to move to a point between start and end: */
4057 return;
4058 }
4059
4060 hr = ITextRange_SetRange(range, i, j);
4061 ok(SUCCEEDED(hr), "got 0x%08x\n", hr);
4062 hr = ITextRange_Move(range, tomCharacter, move_by, &delta);
4063 if (expected_delta == 0) {
4064 ok(hr == S_FALSE, "(%d,%d) move by %d got hr=0x%08x\n", i, j, move_by, hr);
4065 ok(delta == 0, "(%d,%d) move by %d got delta %d\n", i, j, move_by, delta);
4066 CHECK_RANGE(range, expected_location, expected_location);
4067 } else {
4068 ok(hr == S_OK, "(%d,%d) move by %d got hr=0x%08x\n", i, j, move_by, hr);
4069 ok(delta == expected_delta, "(%d,%d) move by %d got delta %d\n", i, j, move_by, delta);
4070 CHECK_RANGE(range, expected_location, expected_location);
4071 }
4072}
4073
4074static void test_character_startof(ITextRange *range, int textlen, int i, int j)
4075{
4076 HRESULT hr;
4077 LONG delta;
4078
4079 hr = ITextRange_SetRange(range, i, j);
4080 ok(SUCCEEDED(hr), "got 0x%08x\n", hr);
4081 hr = ITextRange_StartOf(range, tomCharacter, tomMove, &delta);
4082 if (i == j) {
4083 ok(hr == S_FALSE, "(%d,%d) tomMove got hr=0x%08x\n", i, j, hr);
4084 ok(delta == 0, "(%d,%d) tomMove got delta %d\n", i, j, delta);
4085 } else {
4086 ok(hr == S_OK, "(%d,%d) tomMove got hr=0x%08x\n", i, j, hr);
4087 ok(delta == -1, "(%d,%d) tomMove got delta %d\n", i, j, delta);
4088 }
4089 CHECK_RANGE(range, i, i);
4090
4091 hr = ITextRange_SetRange(range, i, j);
4092 ok(SUCCEEDED(hr), "got 0x%08x\n", hr);
4093 hr = ITextRange_StartOf(range, tomCharacter, tomExtend, &delta);
4094 ok(hr == S_FALSE, "(%d,%d) tomExtend got hr=0x%08x\n", i, j, hr);
4095 ok(delta == 0, "(%d,%d) tomExtend got delta %d\n", i, j, delta);
4096 CHECK_RANGE(range, i, j);
4097}
4098
4099static void test_character_endof(ITextRange *range, int textlen, int i, int j)
4100{
4101 HRESULT hr;
4102 LONG end;
4103 LONG delta;
4104
4105 hr = ITextRange_SetRange(range, i, j);
4106 ok(SUCCEEDED(hr), "got 0x%08x\n", hr);
4107 hr = ITextRange_EndOf(range, tomCharacter, tomMove, &delta);
4108
4109 /* A character "end", apparently cannot be before the very first character */
4110 end = j;
4111 if (j == 0)
4112 ++end;
4113
4114 if (i == end) {
4115 ok(hr == S_FALSE, "(%d,%d) tomMove got hr=0x%08x\n", i, j, hr);
4116 ok(delta == 0, "(%d,%d) tomMove got delta %d\n", i, j, delta);
4117 } else {
4118 ok(hr == S_OK, "(%d,%d) tomMove got hr=0x%08x\n", i, j, hr);
4119 ok(delta == 1, "(%d,%d) tomMove got delta %d\n", i, j, delta);
4120 }
4122
4123 hr = ITextRange_SetRange(range, i, j);
4124 ok(SUCCEEDED(hr), "got 0x%08x\n", hr);
4125 hr = ITextRange_EndOf(range, tomCharacter, tomExtend, &delta);
4126 if (0 < j) {
4127 ok(hr == S_FALSE, "(%d,%d) tomExtend got hr=0x%08x\n", i, j, hr);
4128 ok(delta == 0, "(%d,%d) tomExtend got delta %d\n", i, j, delta);
4129 } else {
4130 ok(hr == S_OK, "(%d,%d) tomExtend got hr=0x%08x\n", i, j, hr);
4131 ok(delta == 1, "(%d,%d) tomExtend got delta %d\n", i, j, delta);
4132 }
4134}
4135
4137{
4138 static const char test_text1[] = "ab\n c";
4139 IRichEditOle *reole = NULL;
4140 ITextDocument *doc = NULL;
4143 HRESULT hr;
4144 HWND hwnd;
4145 int i, j;
4146 const int textlen = strlen(test_text1);
4147
4148 create_interfaces(&hwnd, &reole, &doc, &selection);
4149 SendMessageA(hwnd, WM_SETTEXT, 0, (LPARAM)test_text1);
4150
4151 hr = ITextDocument_Range(doc, 0, 0, &range);
4152 ok(hr == S_OK, "got 0x%08x\n", hr);
4153
4154 /* Exhaustive test of every possible combination of (start,end) locations,
4155 * against every possible target location to move to. */
4156 for (i = 0; i <= textlen; i++) {
4157 for (j = i; j <= textlen; j++) {
4158 LONG target;
4159 for (target = -2; target <= textlen + 3; target++) {
4160 test_character_moveend(range, textlen, i, j, target);
4162 test_character_move(range, textlen, i, j, target);
4163 }
4164 test_character_startof(range, textlen, i, j);
4165 test_character_endof(range, textlen, i, j);
4166 }
4167 }
4168
4169 release_interfaces(&hwnd, &reole, &doc, NULL);
4170 ITextSelection_Release(selection);
4171 ITextRange_Release(range);
4172}
4173
4174#define CLIPBOARD_RANGE_CONTAINS(range, start, end, expected) _clipboard_range_contains(range, start, end, expected, __LINE__, 0);
4175#define TODO_CLIPBOARD_RANGE_CONTAINS(range, start, end, expected) _clipboard_range_contains(range, start, end, expected, __LINE__, 1);
4177{
4178 HRESULT hr;
4179 BOOL clipboard_open;
4181 const char *clipboard_text;
4182
4183 hr = ITextRange_SetRange(range, start, end);
4184 ok_(__FILE__,line)(SUCCEEDED(hr), "SetRange failed: 0x%08x\n", hr);
4185 hr = ITextRange_Copy(range, NULL);
4186 ok_(__FILE__,line)(hr == S_OK, "Copy failed: 0x%08x\n", hr);
4187
4188 clipboard_open = OpenClipboard(NULL);
4189 ok_(__FILE__,line)(clipboard_open, "OpenClipboard failed: %d\n", GetLastError());
4191 ok_(__FILE__,line)(global != NULL, "GetClipboardData failed: %p\n", global);
4192 clipboard_text = GlobalLock(global);
4193 ok_(__FILE__,line)(clipboard_text != NULL, "GlobalLock failed: %p\n", clipboard_text);
4194#ifdef __REACTOS__
4195 if (expected != NULL && clipboard_text != NULL)
4196 todo_wine_if(todo) ok_(__FILE__,line)(!strcmp(expected, clipboard_text), "unexpected contents: %s\n", wine_dbgstr_a(clipboard_text));
4197 else
4198 todo_wine_if(todo) ok_(__FILE__,line)(FALSE, "Either 'expected' or 'clipboard_text' was NULL\n");
4199#else
4200 todo_wine_if(todo) ok_(__FILE__,line)(!strcmp(expected, clipboard_text), "unexpected contents: %s\n", wine_dbgstr_a(clipboard_text));
4201#endif
4204}
4205
4206static void test_clipboard(void)
4207{
4208 static const char text_in[] = "ab\n c";
4209 IRichEditOle *reole = NULL;
4210 ITextDocument *doc = NULL;
4213 HRESULT hr;
4214 HWND hwnd;
4215
4216 create_interfaces(&hwnd, &reole, &doc, &selection);
4217 SendMessageA(hwnd, WM_SETTEXT, 0, (LPARAM)text_in);
4218
4219 hr = ITextDocument_Range(doc, 0, 0, &range);
4220 ok(hr == S_OK, "got 0x%08x\n", hr);
4221
4222 CLIPBOARD_RANGE_CONTAINS(range, 0, 5, "ab\r\n c")
4223 CLIPBOARD_RANGE_CONTAINS(range, 0, 0, "ab\r\n c")
4224 CLIPBOARD_RANGE_CONTAINS(range, 1, 1, "ab\r\n c")
4227
4228 /* Setting password char does not stop Copy */
4231
4232 /* Cut can be undone */
4233 hr = ITextRange_SetRange(range, 0, 1);
4234 ok(SUCCEEDED(hr), "SetRange failed: 0x%08x\n", hr);
4235 hr = ITextRange_Cut(range, NULL);
4236 ok(hr == S_OK, "Cut failed: 0x%08x\n", hr);
4237 CLIPBOARD_RANGE_CONTAINS(range, 0, 4, "b\r\n c");
4238 hr = ITextDocument_Undo(doc, 1, NULL);
4239 todo_wine ok(hr == S_OK, "Undo failed: 0x%08x\n", hr);
4240 TODO_CLIPBOARD_RANGE_CONTAINS(range, 0, 5, "ab\r\n c");
4241
4242 /* Cannot cut when read-only */
4244 hr = ITextRange_SetRange(range, 0, 1);
4245 ok(SUCCEEDED(hr), "SetRange failed: 0x%08x\n", hr);
4246 hr = ITextRange_Cut(range, NULL);
4247 ok(hr == E_ACCESSDENIED, "got 0x%08x\n", hr);
4248
4249 release_interfaces(&hwnd, &reole, &doc, NULL);
4250 ITextSelection_Release(selection);
4251 ITextRange_Release(range);
4252}
4253
4255{
4256 /* Must explicitly LoadLibrary(). The test has no references to functions in
4257 * RICHED20.DLL, so the linker doesn't actually link to it. */
4258 hmoduleRichEdit = LoadLibraryA("riched20.dll");
4259 ok(hmoduleRichEdit != NULL, "error: %d\n", (int) GetLastError());
4260
4263 test_GetText();
4277 test_GetFont();
4278 test_GetPara();
4279 test_dispatch();
4281 test_Delete();
4282 test_SetText();
4283 test_InRange();
4285 test_Select();
4287 test_SetFont();
4291 test_Expand();
4295}
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define ok(value,...)
Definition: atltest.h:57
#define skip(...)
Definition: atltest.h:64
#define START_TEST(x)
Definition: atltest.h:75
#define ok_(x1, x2)
Definition: atltest.h:61
static const WCHAR nameW[]
Definition: main.c:49
#define CF_UNICODETEXT
Definition: constants.h:408
#define CF_TEXT
Definition: constants.h:396
void user(int argc, const char *argv[])
Definition: cmds.c:1350
#define ARRAY_SIZE(A)
Definition: main.h:20
const GUID IID_IUnknown
int selection
Definition: ctm.c:92
#define E_INVALIDARG
Definition: ddrawi.h:101
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define CloseHandle
Definition: compat.h:739
#define CP_ACP
Definition: compat.h:109
#define OPEN_EXISTING
Definition: compat.h:775
#define SetLastError(x)
Definition: compat.h:752
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
OLECHAR * BSTR
Definition: compat.h:2293
#define GENERIC_READ
Definition: compat.h:135
#define CreateFileW
Definition: compat.h:741
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
#define FILE_SHARE_READ
Definition: compat.h:136
@ VT_BSTR
Definition: compat.h:2303
#define lstrlenW
Definition: compat.h:750
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
Definition: delete.c:39
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
int WINAPI lstrcmpW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4243
LCID WINAPI GetSystemDefaultLCID(void)
Definition: locale.c:1230
static FLOAT twips_to_points(LONG value)
Definition: richole.c:400
r parent
Definition: btrfs.c:3010
int global
Definition: ehframes.cpp:22
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint start
Definition: gl.h:1545
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLuint GLuint end
Definition: gl.h:1545
GLuint res
Definition: glext.h:9613
GLuint buffer
Definition: glext.h:5915
GLsizeiptr size
Definition: glext.h:5919
GLuint index
Definition: glext.h:6031
GLenum GLint * range
Definition: glext.h:7539
GLbitfield flags
Definition: glext.h:7161
const GLint * first
Definition: glext.h:5794
GLuint64EXT * result
Definition: glext.h:11304
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
GLenum target
Definition: glext.h:7315
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
REFIID LPVOID DWORD_PTR dw
Definition: atlbase.h:40
#define S_OK
Definition: intsafe.h:52
#define SUCCEEDED(hr)
Definition: intsafe.h:50
const char * filename
Definition: ioapi.h:137
#define debugstr_w
Definition: kernel32.h:32
#define wine_dbgstr_w
Definition: kernel32.h:34
#define GUID_NULL
Definition: ks.h:106
POINT cp
Definition: magnifier.c:59
#define pch(ap)
Definition: match.c:418
#define CREATE_ALWAYS
Definition: disk.h:72
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
BOOL todo
Definition: filedlg.c:313
static const WCHAR textW[]
Definition: itemdlg.c:1559
BOOL expected
Definition: store.c:2063
HRESULT hres
Definition: protocol.c:465
#define todo_wine_if(is_todo)
Definition: custom.c:86
#define todo_wine
Definition: custom.c:89
static void _check_selection(ITextSelection *selection, LONG expected_start, LONG expected_end, int line)
Definition: richole.c:3737
static void test_Interfaces(void)
Definition: richole.c:141
static void test_Expand(void)
Definition: richole.c:3797
static void _reset_range(ITextRange *range, LONG start, LONG end, int line)
Definition: richole.c:3696
static void test_SetText(void)
Definition: richole.c:2699
static void test_character_movement(void)
Definition: richole.c:4136
static void test_ITextSelection_GetDuplicate(void)
Definition: richole.c:3620
static void _insert_reobject(IRichEditOle *reole, REOBJECT *reobj, LONG cp, DWORD user, int line)
Definition: richole.c:3235
static void test_character_moveend(ITextRange *range, int textlen, int i, int j, LONG target)
Definition: richole.c:3999
static void fill_reobject_struct(REOBJECT *reobj, LONG cp, LPOLEOBJECT poleobj, LPSTORAGE pstg, LPOLECLIENTSITE polesite, LONG sizel_cx, LONG sizel_cy, DWORD aspect, DWORD flags, DWORD user)
Definition: richole.c:3198
static void test_character_startof(ITextRange *range, int textlen, int i, int j)
Definition: richole.c:4074
static void test_ITextSelection_GetStart_GetEnd(void)
Definition: richole.c:1162
static void test_GetPara(void)
Definition: richole.c:1848
static void test_detached_font_getters(ITextFont *font, BOOL duplicate)
Definition: richole.c:1979
#define CLIPBOARD_RANGE_CONTAINS(range, start, end, expected)
Definition: richole.c:4174
static void test_character_endof(ITextRange *range, int textlen, int i, int j)
Definition: richole.c:4099
static void test_GetClientSite(void)
Definition: richole.c:1599
static void test_GetStoryLength(void)
Definition: richole.c:3552
static HMODULE hmoduleRichEdit
Definition: richole.c:36
static void test_textfont_undefined(ITextFont *font)
Definition: richole.c:2176
static void test_IOleInPlaceSite_GetWindow(void)
Definition: richole.c:1702
#define TODO_CLIPBOARD_RANGE_CONTAINS(range, start, end, expected)
Definition: richole.c:4175
static HWND new_richedit(HWND parent)
Definition: richole.c:60
static void test_ITextRange_GetDuplicate(void)
Definition: richole.c:1368
static void test_character_move(ITextRange *range, int textlen, int i, int j, LONG target)
Definition: richole.c:4028
static void test_Delete(void)
Definition: richole.c:2644
static void test_ITextSelection_GetChar(void)
Definition: richole.c:887
#define CHECK_TYPEINFO(disp, expected_riid)
Definition: richole.c:116
static void test_clipboard(void)
Definition: richole.c:4206
static void _expect_ref(IUnknown *obj, ULONG ref, int line)
Definition: richole.c:43
static void test_InRange(void)
Definition: richole.c:2786
static void test_GetStoryType(void)
Definition: richole.c:3055
#define RESET_RANGE(range, start, end)
Definition: richole.c:3694
static BOOL touch_file(LPCWSTR filename)
Definition: richole.c:65
static void test_ITextRange_GetStart_GetEnd(void)
Definition: richole.c:943
static void test_ITextRange_IsEqual(void)
Definition: richole.c:2896
static void test_ITextDocument_Open(void)
Definition: richole.c:271
static void test_ITextRange_Collapse(void)
Definition: richole.c:1411
static void create_interfaces(HWND *w, IRichEditOle **reOle, ITextDocument **txtDoc, ITextSelection **txtSel)
Definition: richole.c:90
static BOOL is_existing_file(LPCWSTR filename)
Definition: richole.c:78
#define CHECK_REOBJECT_STRUCT(reole, index, flags, cp, poleobj, pstg, polesite, user)
Definition: richole.c:3215
#define CHECK_SELECTION(selection, expected_start, expected_end)
Definition: richole.c:3735
static void test_IOleWindow_GetWindow(void)
Definition: richole.c:1674
static void test_ITextRange_ScrollIntoView(void)
Definition: richole.c:851
static void _check_reobject_struct(IRichEditOle *reole, LONG index, DWORD flags, LONG cp, LPOLEOBJECT poleobj, LPSTORAGE pstg, LPOLECLIENTSITE polesite, DWORD user, int line)
Definition: richole.c:3217
static void test_dispatch(void)
Definition: richole.c:1932
static void test_textfont_global_defaults(ITextFont *font)
Definition: richole.c:2047
#define MAX_BUF_LEN
static void _reset_selection(ITextSelection *selection, LONG start, LONG end, int line)
Definition: richole.c:3725
#define EXPECT_REF(obj, ref)
Definition: richole.c:42
#define INSERT_REOBJECT(reole, reobj, cp, user)
Definition: richole.c:3233
static void test_ITextSelection_Collapse(void)
Definition: richole.c:1522
static void test_Select(void)
Definition: richole.c:3011
static void test_ITextRange_SetRange(void)
Definition: richole.c:3752
static const WCHAR sysW[]
Definition: richole.c:40
static void release_interfaces(HWND *w, IRichEditOle **reOle, ITextDocument **txtDoc, ITextSelection **txtSel)
Definition: richole.c:100
static void test_GetFont(void)
Definition: richole.c:1730
#define CHECK_RANGE(range, expected_start, expected_end)
Definition: richole.c:3706
static void test_character_movestart(ITextRange *range, int textlen, int i, int j, LONG target)
Definition: richole.c:3970
static void test_ITextFont(void)
Definition: richole.c:2303
#define RESET_SELECTION(selection, start, end)
Definition: richole.c:3723
static void test_ITextRange_GetChar(void)
Definition: richole.c:746
static void _check_range(ITextRange *range, LONG expected_start, LONG expected_end, int line)
Definition: richole.c:3708
static void check_range(HWND w, ITextDocument *doc, int first, int lim, LONG bStart, int expected_nonzero)
Definition: richole.c:825
static HWND new_window(LPCSTR lpClassName, DWORD dwStyle, HWND parent)
Definition: richole.c:51
static void _check_typeinfo(IDispatch *disp, REFIID expected_riid, int line)
Definition: richole.c:117
static void test_GetText(void)
Definition: richole.c:519
static void _clipboard_range_contains(ITextRange *range, LONG start, LONG end, const char *expected, int line, int todo)
Definition: richole.c:4176
static void test_InsertObject(void)
Definition: richole.c:3247
static void test_MoveEnd_story(void)
Definition: richole.c:3856
static ULONG get_refcount(IUnknown *iface)
Definition: richole.c:110
static void test_SetFont(void)
Definition: richole.c:3111
static void test_ITextDocument_Range(void)
Definition: richole.c:704
static VARIANTARG static DISPID
Definition: ordinal.c:52
_In_ HANDLE hFile
Definition: mswsock.h:90
Definition: mk_font.cpp:20
unsigned int UINT
Definition: ndis.h:50
#define GENERIC_WRITE
Definition: nt_native.h:90
#define LOCALE_USER_DEFAULT
#define LOCALE_SYSTEM_DEFAULT
#define L(x)
Definition: ntvdm.h:50
interface IStorage * LPSTORAGE
Definition: objfwd.h:30
BSTR WINAPI SysAllocString(LPCOLESTR str)
Definition: oleaut.c:238
void WINAPI DECLSPEC_HOTPATCH SysFreeString(BSTR str)
Definition: oleaut.c:271
BSTR WINAPI SysAllocStringLen(const OLECHAR *str, unsigned int len)
Definition: oleaut.c:339
#define V_VT(A)
Definition: oleauto.h:211
#define V_BSTR(A)
Definition: oleauto.h:226
const GUID IID_IOleInPlaceSite
const GUID IID_IOleWindow
const GUID IID_IOleClientSite
const GUID IID_IDispatch
#define WS_POPUP
Definition: pedump.c:616
#define WS_VSCROLL
Definition: pedump.c:627
#define WS_VISIBLE
Definition: pedump.c:620
long LONG
Definition: pedump.c:60
#define WS_HSCROLL
Definition: pedump.c:628
#define ES_MULTILINE
Definition: pedump.c:667
#define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8)
Definition: guiddef.h:68
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define CLSID_NULL
Definition: guiddef.h:99
#define REFIID
Definition: guiddef.h:118
#define IID_NULL
Definition: guiddef.h:98
#define GT_DEFAULT
Definition: richedit.h:1036
#define SEL_OBJECT
Definition: richedit.h:824
#define EM_GETSELTEXT
Definition: richedit.h:95
#define CFM_OFFSET
Definition: richedit.h:359
#define CFE_ITALIC
Definition: richedit.h:407
#define SCF_SELECTION
Definition: richedit.h:235
#define EM_GETCHARFORMAT
Definition: richedit.h:91
#define SEL_TEXT
Definition: richedit.h:823
#define EM_SETCHARFORMAT
Definition: richedit.h:101
#define RICHEDIT_CLASS20A
Definition: richedit.h:43
#define CFM_KERNING
Definition: richedit.h:352
#define CFM_ITALIC
Definition: richedit.h:333
#define EM_GETTEXTRANGE
Definition: richedit.h:108
#define EM_SETTEXTMODE
Definition: richedit.h:123
#define CFM_SIZE
Definition: richedit.h:362
#define GT_RAWTEXT
Definition: richedit.h:1039
struct _charformat2a CHARFORMAT2A
#define EM_SELECTIONTYPE
Definition: richedit.h:99
#define TM_PLAINTEXT
Definition: richedit.h:1028
#define CFM_FACE
Definition: richedit.h:360
#define EM_GETOLEINTERFACE
Definition: richedit.h:93
#define EM_GETTEXTEX
Definition: richedit.h:128
const WCHAR * str
#define CP_UTF8
Definition: nls.h:20
const char int int int static __inline const char * wine_dbgstr_a(const char *s)
Definition: debug.h:187
static __inline const char * wine_dbgstr_guid(const GUID *id)
Definition: debug.h:197
strcpy
Definition: string.h:131
#define memset(x, y, z)
Definition: compat.h:39
HRESULT hr
Definition: shlfolder.c:183
LONG cx
Definition: kdterminal.h:27
LONG cy
Definition: kdterminal.h:28
LONG cpMax
Definition: richedit.h:501
LONG cpMin
Definition: richedit.h:500
DWORD cb
Definition: richedit.h:706
DWORD flags
Definition: richedit.h:707
LPCSTR lpDefaultChar
Definition: richedit.h:709
LPBOOL lpUsedDefChar
Definition: richedit.h:710
UINT codepage
Definition: richedit.h:708
DWORD dwUser
Definition: richole.idl:67
CLSID clsid
Definition: richole.idl:60
DWORD dwFlags
Definition: richole.idl:66
LPSTORAGE pstg
Definition: richole.idl:62
LPOLEOBJECT poleobj
Definition: richole.idl:61
DWORD dvaspect
Definition: richole.idl:65
LPOLECLIENTSITE polesite
Definition: richole.idl:63
DWORD cbStruct
Definition: richole.idl:58
LONG cp
Definition: richole.idl:59
SIZEL sizel
Definition: richole.idl:64
CHARRANGE chrg
Definition: richedit.h:508
LPSTR lpstrText
Definition: richedit.h:509
Definition: fci.c:127
Definition: parser.c:49
Definition: send.c:48
@ tomUseTwips
Definition: tom.idl:46
@ tomAutoColor
Definition: tom.idl:32
@ tomRTF
Definition: tom.idl:178
@ tomApplyNow
Definition: tom.idl:38
@ tomPasteFile
Definition: tom.idl:172
@ tomSentence
Definition: tom.idl:120
@ tomEnd
Definition: tom.idl:66
@ tomText
Definition: tom.idl:179
@ tomOpenExisting
Definition: tom.idl:175
@ tomUnknownStory
Definition: tom.idl:139
@ tomStory
Definition: tom.idl:123
@ tomUsePoints
Definition: tom.idl:45
@ tomDefault
Definition: tom.idl:33
@ tomExtend
Definition: tom.idl:51
@ tomCreateAlways
Definition: tom.idl:174
@ tomApplyLater
Definition: tom.idl:39
@ tomReadOnly
Definition: tom.idl:169
@ tomCharacter
Definition: tom.idl:118
@ tomTextFrameStory
Definition: tom.idl:144
@ tomShareDenyWrite
Definition: tom.idl:171
@ tomMove
Definition: tom.idl:50
@ tomTruncateExisting
Definition: tom.idl:177
@ tomStart
Definition: tom.idl:67
@ tomCacheParms
Definition: tom.idl:41
@ tomShareDenyRead
Definition: tom.idl:170
@ tomTrue
Definition: tom.idl:29
@ tomOpenAlways
Definition: tom.idl:176
@ tomFalse
Definition: tom.idl:28
@ tomCreateNew
Definition: tom.idl:173
@ tomTrackParms
Definition: tom.idl:40
@ tomUndefined
Definition: tom.idl:30
FT_UInt FT_UInt FT_Vector * kerning
Definition: ttdriver.c:207
float FLOAT
Definition: typedefs.h:69
uint32_t ULONG
Definition: typedefs.h:59
Definition: pdh_main.c:96
HRESULT WINAPI DECLSPEC_HOTPATCH VariantClear(VARIANTARG *pVarg)
Definition: variant.c:648
int ret
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
LONG_PTR LPARAM
Definition: windef.h:208
LONG_PTR LRESULT
Definition: windef.h:209
UINT_PTR WPARAM
Definition: windef.h:207
#define S_FALSE
Definition: winerror.h:2357
#define ERROR_SHARING_VIOLATION
Definition: winerror.h:135
#define E_NOINTERFACE
Definition: winerror.h:2364
#define E_ACCESSDENIED
Definition: winerror.h:2849
#define ERROR_FILE_EXISTS
Definition: winerror.h:165
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
#define DISP_E_UNKNOWNNAME
Definition: winerror.h:2515
#define CO_E_RELEASED
Definition: winerror.h:2818
#define FW_BOLD
Definition: wingdi.h:378
#define FW_NORMAL
Definition: wingdi.h:373
#define EM_SETREADONLY
Definition: winuser.h:2026
struct tagSCROLLINFO SCROLLINFO
#define CreateWindowA(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4326
#define SIF_RANGE
Definition: winuser.h:1246
#define EM_GETSEL
Definition: winuser.h:2008
#define EM_SETPASSWORDCHAR
Definition: winuser.h:2025
#define SB_VERT
Definition: winuser.h:553
BOOL WINAPI CloseClipboard(void)
Definition: ntwrapper.h:178
LRESULT WINAPI SendMessageA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_GETTEXT
Definition: winuser.h:1629
BOOL WINAPI OpenClipboard(_In_opt_ HWND)
HANDLE WINAPI GetClipboardData(_In_ UINT)
#define WM_SETTEXT
Definition: winuser.h:1628
#define EM_SETSEL
Definition: winuser.h:2029
#define SIF_POS
Definition: winuser.h:1245
BOOL WINAPI GetScrollInfo(_In_ HWND, _In_ int, _Inout_ LPSCROLLINFO)
BOOL WINAPI DestroyWindow(_In_ HWND)
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
const char * LPCSTR
Definition: xmlstorage.h:183
__wchar_t WCHAR
Definition: xmlstorage.h:180
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
char CHAR
Definition: xmlstorage.h:175