1 /*
2 * RichEdit GUIDs and OLE interface
3 *
4 * Copyright 2004 by Krzysztof Foltman
5 * Copyright 2004 Aric Stewart
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 */
21
22 #include <stdarg.h>
23
24 #define NONAMELESSUNION
25 #define NONAMELESSSTRUCT
26 #define COBJMACROS
27
28 #include "windef.h"
29 #include "winbase.h"
30 #include "wingdi.h"
31 #include "winuser.h"
32 #include "ole2.h"
33 #include "richole.h"
34 #include "editor.h"
35 #include "tom.h"
36 #include "wine/debug.h"
37
38 WINE_DEFAULT_DEBUG_CHANNEL(richedit);
39
40 /* there is no way to be consistent across different sets of headers - mingw, Wine, Win32 SDK*/
41
42 /* FIXME: the next 6 lines should be in textserv.h */
43 #include "initguid.h"
44 #define TEXTSERV_GUID(name, l, w1, w2, b1, b2) \
45 DEFINE_GUID(name, l, w1, w2, b1, b2, 0x00, 0xaa, 0x00, 0x6c, 0xad, 0xc5)
46
47 TEXTSERV_GUID(IID_ITextServices, 0x8d33f740, 0xcf58, 0x11ce, 0xa8, 0x9d);
48 TEXTSERV_GUID(IID_ITextHost, 0xc5bdd8d0, 0xd26e, 0x11ce, 0xa8, 0x9e);
49 TEXTSERV_GUID(IID_ITextHost2, 0xc5bdd8d0, 0xd26e, 0x11ce, 0xa8, 0x9e);
50 DEFINE_GUID(IID_ITextDocument, 0x8cc497c0, 0xa1df, 0x11ce, 0x80, 0x98, 0x00, 0xaa, 0x00, 0x47, 0xbe, 0x5d);
51 DEFINE_GUID(IID_ITextRange, 0x8cc497c2, 0xa1df, 0x11ce, 0x80, 0x98, 0x00, 0xaa, 0x00, 0x47, 0xbe, 0x5d);
52 DEFINE_GUID(IID_ITextSelection, 0x8cc497c1, 0xa1df, 0x11ce, 0x80, 0x98, 0x00, 0xaa, 0x00, 0x47, 0xbe, 0x5d);
53
54 typedef struct ITextSelectionImpl ITextSelectionImpl;
55 typedef struct IOleClientSiteImpl IOleClientSiteImpl;
56
57 typedef struct IRichEditOleImpl {
58 const IRichEditOleVtbl *lpRichEditOleVtbl;
59 const ITextDocumentVtbl *lpTextDocumentVtbl;
60 LONG ref;
61
62 ME_TextEditor *editor;
63 ITextSelectionImpl *txtSel;
64 IOleClientSiteImpl *clientSite;
65 } IRichEditOleImpl;
66
67 struct ITextSelectionImpl {
68 const ITextSelectionVtbl *lpVtbl;
69 LONG ref;
70
71 IRichEditOleImpl *reOle;
72 };
73
74 struct IOleClientSiteImpl {
75 const IOleClientSiteVtbl *lpVtbl;
76 LONG ref;
77
78 IRichEditOleImpl *reOle;
79 };
80
81 static inline IRichEditOleImpl *impl_from_IRichEditOle(IRichEditOle *iface)
82 {
83 return (IRichEditOleImpl *)((BYTE*)iface - FIELD_OFFSET(IRichEditOleImpl, lpRichEditOleVtbl));
84 }
85
86 static inline IRichEditOleImpl *impl_from_ITextDocument(ITextDocument *iface)
87 {
88 return (IRichEditOleImpl *)((BYTE*)iface - FIELD_OFFSET(IRichEditOleImpl, lpTextDocumentVtbl));
89 }
90
91 static HRESULT WINAPI
92 IRichEditOle_fnQueryInterface(IRichEditOle *me, REFIID riid, LPVOID *ppvObj)
93 {
94 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
95
96 TRACE("%p %s\n", This, debugstr_guid(riid) );
97
98 *ppvObj = NULL;
99 if (IsEqualGUID(riid, &IID_IUnknown) ||
100 IsEqualGUID(riid, &IID_IRichEditOle))
101 *ppvObj = &This->lpRichEditOleVtbl;
102 else if (IsEqualGUID(riid, &IID_ITextDocument))
103 *ppvObj = &This->lpTextDocumentVtbl;
104 if (*ppvObj)
105 {
106 IRichEditOle_AddRef(me);
107 return S_OK;
108 }
109 FIXME("%p: unhandled interface %s\n", This, debugstr_guid(riid) );
110
111 return E_NOINTERFACE;
112 }
113
114 static ULONG WINAPI
115 IRichEditOle_fnAddRef(IRichEditOle *me)
116 {
117 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
118 ULONG ref = InterlockedIncrement( &This->ref );
119
120 TRACE("%p ref = %u\n", This, ref);
121
122 return ref;
123 }
124
125 static ULONG WINAPI
126 IRichEditOle_fnRelease(IRichEditOle *me)
127 {
128 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
129 ULONG ref = InterlockedDecrement(&This->ref);
130
131 TRACE ("%p ref=%u\n", This, ref);
132
133 if (!ref)
134 {
135 TRACE ("Destroying %p\n", This);
136 This->txtSel->reOle = NULL;
137 ITextSelection_Release((ITextSelection *) This->txtSel);
138 IOleClientSite_Release((IOleClientSite *) This->clientSite);
139 heap_free(This);
140 }
141 return ref;
142 }
143
144 static HRESULT WINAPI
145 IRichEditOle_fnActivateAs(IRichEditOle *me, REFCLSID rclsid, REFCLSID rclsidAs)
146 {
147 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
148 FIXME("stub %p\n",This);
149 return E_NOTIMPL;
150 }
151
152 static HRESULT WINAPI
153 IRichEditOle_fnContextSensitiveHelp(IRichEditOle *me, BOOL fEnterMode)
154 {
155 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
156 FIXME("stub %p\n",This);
157 return E_NOTIMPL;
158 }
159
160 static HRESULT WINAPI
161 IRichEditOle_fnConvertObject(IRichEditOle *me, LONG iob,
162 REFCLSID rclsidNew, LPCSTR lpstrUserTypeNew)
163 {
164 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
165 FIXME("stub %p\n",This);
166 return E_NOTIMPL;
167 }
168
169 static HRESULT WINAPI
170 IOleClientSite_fnQueryInterface(IOleClientSite *me, REFIID riid, LPVOID *ppvObj)
171 {
172 TRACE("%p %s\n", me, debugstr_guid(riid) );
173
174 *ppvObj = NULL;
175 if (IsEqualGUID(riid, &IID_IUnknown) ||
176 IsEqualGUID(riid, &IID_IOleClientSite))
177 *ppvObj = me;
178 if (*ppvObj)
179 {
180 IOleClientSite_AddRef(me);
181 return S_OK;
182 }
183 FIXME("%p: unhandled interface %s\n", me, debugstr_guid(riid) );
184
185 return E_NOINTERFACE;
186 }
187
188 static ULONG WINAPI
189 IOleClientSite_fnAddRef(IOleClientSite *me)
190 {
191 IOleClientSiteImpl *This = (IOleClientSiteImpl *) me;
192 return InterlockedIncrement(&This->ref);
193 }
194
195 static ULONG WINAPI
196 IOleClientSite_fnRelease(IOleClientSite *me)
197 {
198 IOleClientSiteImpl *This = (IOleClientSiteImpl *) me;
199 ULONG ref = InterlockedDecrement(&This->ref);
200 if (ref == 0)
201 heap_free(This);
202 return ref;
203 }
204
205 static HRESULT WINAPI
206 IOleClientSite_fnSaveObject(IOleClientSite *me)
207 {
208 IOleClientSiteImpl *This = (IOleClientSiteImpl *) me;
209 if (!This->reOle)
210 return CO_E_RELEASED;
211
212 FIXME("stub %p\n",me);
213 return E_NOTIMPL;
214 }
215
216
217 static HRESULT WINAPI
218 IOleClientSite_fnGetMoniker(IOleClientSite *me, DWORD dwAssign, DWORD dwWhichMoniker,
219 IMoniker **ppmk)
220 {
221 IOleClientSiteImpl *This = (IOleClientSiteImpl *) me;
222 if (!This->reOle)
223 return CO_E_RELEASED;
224
225 FIXME("stub %p\n",me);
226 return E_NOTIMPL;
227 }
228
229 static HRESULT WINAPI
230 IOleClientSite_fnGetContainer(IOleClientSite *me, IOleContainer **ppContainer)
231 {
232 IOleClientSiteImpl *This = (IOleClientSiteImpl *) me;
233 if (!This->reOle)
234 return CO_E_RELEASED;
235
236 FIXME("stub %p\n",me);
237 return E_NOTIMPL;
238 }
239
240 static HRESULT WINAPI
241 IOleClientSite_fnShowObject(IOleClientSite *me)
242 {
243 IOleClientSiteImpl *This = (IOleClientSiteImpl *) me;
244 if (!This->reOle)
245 return CO_E_RELEASED;
246
247 FIXME("stub %p\n",me);
248 return E_NOTIMPL;
249 }
250
251 static HRESULT WINAPI
252 IOleClientSite_fnOnShowWindow(IOleClientSite *me, BOOL fShow)
253 {
254 IOleClientSiteImpl *This = (IOleClientSiteImpl *) me;
255 if (!This->reOle)
256 return CO_E_RELEASED;
257
258 FIXME("stub %p\n",me);
259 return E_NOTIMPL;
260 }
261
262 static HRESULT WINAPI
263 IOleClientSite_fnRequestNewObjectLayout(IOleClientSite *me)
264 {
265 IOleClientSiteImpl *This = (IOleClientSiteImpl *) me;
266 if (!This->reOle)
267 return CO_E_RELEASED;
268
269 FIXME("stub %p\n",me);
270 return E_NOTIMPL;
271 }
272
273 static const IOleClientSiteVtbl ocst = {
274 IOleClientSite_fnQueryInterface,
275 IOleClientSite_fnAddRef,
276 IOleClientSite_fnRelease,
277 IOleClientSite_fnSaveObject,
278 IOleClientSite_fnGetMoniker,
279 IOleClientSite_fnGetContainer,
280 IOleClientSite_fnShowObject,
281 IOleClientSite_fnOnShowWindow,
282 IOleClientSite_fnRequestNewObjectLayout
283 };
284
285 static IOleClientSiteImpl *
286 CreateOleClientSite(IRichEditOleImpl *reOle)
287 {
288 IOleClientSiteImpl *clientSite = heap_alloc(sizeof *clientSite);
289 if (!clientSite)
290 return NULL;
291
292 clientSite->lpVtbl = &ocst;
293 clientSite->ref = 1;
294 clientSite->reOle = reOle;
295 return clientSite;
296 }
297
298 static HRESULT WINAPI
299 IRichEditOle_fnGetClientSite(IRichEditOle *me,
300 LPOLECLIENTSITE *lplpolesite)
301 {
302 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
303
304 TRACE("%p,%p\n",This, lplpolesite);
305
306 if(!lplpolesite)
307 return E_INVALIDARG;
308 *lplpolesite = (IOleClientSite *) This->clientSite;
309 IOleClientSite_fnAddRef(*lplpolesite);
310 return S_OK;
311 }
312
313 static HRESULT WINAPI
314 IRichEditOle_fnGetClipboardData(IRichEditOle *me, CHARRANGE *lpchrg,
315 DWORD reco, LPDATAOBJECT *lplpdataobj)
316 {
317 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
318 CHARRANGE tmpchrg;
319
320 TRACE("(%p,%p,%d)\n",This, lpchrg, reco);
321 if(!lplpdataobj)
322 return E_INVALIDARG;
323 if(!lpchrg) {
324 ME_GetSelection(This->editor, &tmpchrg.cpMin, &tmpchrg.cpMax);
325 lpchrg = &tmpchrg;
326 }
327 return ME_GetDataObject(This->editor, lpchrg, lplpdataobj);
328 }
329
330 static LONG WINAPI IRichEditOle_fnGetLinkCount(IRichEditOle *me)
331 {
332 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
333 FIXME("stub %p\n",This);
334 return E_NOTIMPL;
335 }
336
337 static HRESULT WINAPI
338 IRichEditOle_fnGetObject(IRichEditOle *me, LONG iob,
339 REOBJECT *lpreobject, DWORD dwFlags)
340 {
341 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
342 FIXME("stub %p\n",This);
343 return E_NOTIMPL;
344 }
345
346 static LONG WINAPI
347 IRichEditOle_fnGetObjectCount(IRichEditOle *me)
348 {
349 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
350 FIXME("stub %p\n",This);
351 return 0;
352 }
353
354 static HRESULT WINAPI
355 IRichEditOle_fnHandsOffStorage(IRichEditOle *me, LONG iob)
356 {
357 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
358 FIXME("stub %p\n",This);
359 return E_NOTIMPL;
360 }
361
362 static HRESULT WINAPI
363 IRichEditOle_fnImportDataObject(IRichEditOle *me, LPDATAOBJECT lpdataobj,
364 CLIPFORMAT cf, HGLOBAL hMetaPict)
365 {
366 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
367 FIXME("stub %p\n",This);
368 return E_NOTIMPL;
369 }
370
371 static HRESULT WINAPI
372 IRichEditOle_fnInPlaceDeactivate(IRichEditOle *me)
373 {
374 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
375 FIXME("stub %p\n",This);
376 return E_NOTIMPL;
377 }
378
379 static HRESULT WINAPI
380 IRichEditOle_fnInsertObject(IRichEditOle *me, REOBJECT *reo)
381 {
382 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
383 TRACE("(%p,%p)\n", This, reo);
384
385 if (reo->cbStruct < sizeof(*reo)) return STG_E_INVALIDPARAMETER;
386 if (reo->poleobj) IOleObject_AddRef(reo->poleobj);
387 if (reo->pstg) IStorage_AddRef(reo->pstg);
388 if (reo->polesite) IOleClientSite_AddRef(reo->polesite);
389
390 ME_InsertOLEFromCursor(This->editor, reo, 0);
391 return S_OK;
392 }
393
394 static HRESULT WINAPI IRichEditOle_fnSaveCompleted(IRichEditOle *me, LONG iob,
395 LPSTORAGE lpstg)
396 {
397 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
398 FIXME("stub %p\n",This);
399 return E_NOTIMPL;
400 }
401
402 static HRESULT WINAPI
403 IRichEditOle_fnSetDvaspect(IRichEditOle *me, LONG iob, DWORD dvaspect)
404 {
405 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
406 FIXME("stub %p\n",This);
407 return E_NOTIMPL;
408 }
409
410 static HRESULT WINAPI IRichEditOle_fnSetHostNames(IRichEditOle *me,
411 LPCSTR lpstrContainerApp, LPCSTR lpstrContainerObj)
412 {
413 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
414 FIXME("stub %p %s %s\n",This, lpstrContainerApp, lpstrContainerObj);
415 return E_NOTIMPL;
416 }
417
418 static HRESULT WINAPI
419 IRichEditOle_fnSetLinkAvailable(IRichEditOle *me, LONG iob, BOOL fAvailable)
420 {
421 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
422 FIXME("stub %p\n",This);
423 return E_NOTIMPL;
424 }
425
426 static const IRichEditOleVtbl revt = {
427 IRichEditOle_fnQueryInterface,
428 IRichEditOle_fnAddRef,
429 IRichEditOle_fnRelease,
430 IRichEditOle_fnGetClientSite,
431 IRichEditOle_fnGetObjectCount,
432 IRichEditOle_fnGetLinkCount,
433 IRichEditOle_fnGetObject,
434 IRichEditOle_fnInsertObject,
435 IRichEditOle_fnConvertObject,
436 IRichEditOle_fnActivateAs,
437 IRichEditOle_fnSetHostNames,
438 IRichEditOle_fnSetLinkAvailable,
439 IRichEditOle_fnSetDvaspect,
440 IRichEditOle_fnHandsOffStorage,
441 IRichEditOle_fnSaveCompleted,
442 IRichEditOle_fnInPlaceDeactivate,
443 IRichEditOle_fnContextSensitiveHelp,
444 IRichEditOle_fnGetClipboardData,
445 IRichEditOle_fnImportDataObject
446 };
447
448 static HRESULT WINAPI
449 ITextDocument_fnQueryInterface(ITextDocument* me, REFIID riid,
450 void** ppvObject)
451 {
452 IRichEditOleImpl *This = impl_from_ITextDocument(me);
453 return IRichEditOle_fnQueryInterface((IRichEditOle*)&This->lpRichEditOleVtbl,
454 riid, ppvObject);
455 }
456
457 static ULONG WINAPI
458 ITextDocument_fnAddRef(ITextDocument* me)
459 {
460 IRichEditOleImpl *This = impl_from_ITextDocument(me);
461 return IRichEditOle_fnAddRef((IRichEditOle*)&This->lpRichEditOleVtbl);
462 }
463
464 static ULONG WINAPI
465 ITextDocument_fnRelease(ITextDocument* me)
466 {
467 IRichEditOleImpl *This = impl_from_ITextDocument(me);
468 return IRichEditOle_fnRelease((IRichEditOle*)&This->lpRichEditOleVtbl);
469 }
470
471 static HRESULT WINAPI
472 ITextDocument_fnGetTypeInfoCount(ITextDocument* me,
473 UINT* pctinfo)
474 {
475 IRichEditOleImpl *This = impl_from_ITextDocument(me);
476 FIXME("stub %p\n",This);
477 return E_NOTIMPL;
478 }
479
480 static HRESULT WINAPI
481 ITextDocument_fnGetTypeInfo(ITextDocument* me, UINT iTInfo, LCID lcid,
482 ITypeInfo** ppTInfo)
483 {
484 IRichEditOleImpl *This = impl_from_ITextDocument(me);
485 FIXME("stub %p\n",This);
486 return E_NOTIMPL;
487 }
488
489 static HRESULT WINAPI
490 ITextDocument_fnGetIDsOfNames(ITextDocument* me, REFIID riid,
491 LPOLESTR* rgszNames, UINT cNames, LCID lcid, DISPID* rgDispId)
492 {
493 IRichEditOleImpl *This = impl_from_ITextDocument(me);
494 FIXME("stub %p\n",This);
495 return E_NOTIMPL;
496 }
497
498 static HRESULT WINAPI
499 ITextDocument_fnInvoke(ITextDocument* me, DISPID dispIdMember,
500 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS* pDispParams,
501 VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr)
502 {
503 IRichEditOleImpl *This = impl_from_ITextDocument(me);
504 FIXME("stub %p\n",This);
505 return E_NOTIMPL;
506 }
507
508 static HRESULT WINAPI
509 ITextDocument_fnGetName(ITextDocument* me, BSTR* pName)
510 {
511 IRichEditOleImpl *This = impl_from_ITextDocument(me);
512 FIXME("stub %p\n",This);
513 return E_NOTIMPL;
514 }
515
516 static HRESULT WINAPI
517 ITextDocument_fnGetSelection(ITextDocument* me, ITextSelection** ppSel)
518 {
519 IRichEditOleImpl *This = impl_from_ITextDocument(me);
520 TRACE("(%p)\n", me);
521 *ppSel = (ITextSelection *) This->txtSel;
522 ITextSelection_AddRef(*ppSel);
523 return S_OK;
524 }
525
526 static HRESULT WINAPI
527 ITextDocument_fnGetStoryCount(ITextDocument* me, LONG* pCount)
528 {
529 IRichEditOleImpl *This = impl_from_ITextDocument(me);
530 FIXME("stub %p\n",This);
531 return E_NOTIMPL;
532 }
533
534 static HRESULT WINAPI
535 ITextDocument_fnGetStoryRanges(ITextDocument* me,
536 ITextStoryRanges** ppStories)
537 {
538 IRichEditOleImpl *This = impl_from_ITextDocument(me);
539 FIXME("stub %p\n",This);
540 return E_NOTIMPL;
541 }
542
543 static HRESULT WINAPI
544 ITextDocument_fnGetSaved(ITextDocument* me, LONG* pValue)
545 {
546 IRichEditOleImpl *This = impl_from_ITextDocument(me);
547 FIXME("stub %p\n",This);
548 return E_NOTIMPL;
549 }
550
551 static HRESULT WINAPI
552 ITextDocument_fnSetSaved(ITextDocument* me, LONG Value)
553 {
554 IRichEditOleImpl *This = impl_from_ITextDocument(me);
555 FIXME("stub %p\n",This);
556 return E_NOTIMPL;
557 }
558
559 static HRESULT WINAPI
560 ITextDocument_fnGetDefaultTabStop(ITextDocument* me, float* pValue)
561 {
562 IRichEditOleImpl *This = impl_from_ITextDocument(me);
563 FIXME("stub %p\n",This);
564 return E_NOTIMPL;
565 }
566
567 static HRESULT WINAPI
568 ITextDocument_fnSetDefaultTabStop(ITextDocument* me, float Value)
569 {
570 IRichEditOleImpl *This = impl_from_ITextDocument(me);
571 FIXME("stub %p\n",This);
572 return E_NOTIMPL;
573 }
574
575 static HRESULT WINAPI
576 ITextDocument_fnNew(ITextDocument* me)
577 {
578 IRichEditOleImpl *This = impl_from_ITextDocument(me);
579 FIXME("stub %p\n",This);
580 return E_NOTIMPL;
581 }
582
583 static HRESULT WINAPI
584 ITextDocument_fnOpen(ITextDocument* me, VARIANT* pVar, LONG Flags,
585 LONG CodePage)
586 {
587 IRichEditOleImpl *This = impl_from_ITextDocument(me);
588 FIXME("stub %p\n",This);
589 return E_NOTIMPL;
590 }
591
592 static HRESULT WINAPI
593 ITextDocument_fnSave(ITextDocument* me, VARIANT* pVar, LONG Flags,
594 LONG CodePage)
595 {
596 IRichEditOleImpl *This = impl_from_ITextDocument(me);
597 FIXME("stub %p\n",This);
598 return E_NOTIMPL;
599 }
600
601 static HRESULT WINAPI
602 ITextDocument_fnFreeze(ITextDocument* me, LONG* pCount)
603 {
604 IRichEditOleImpl *This = impl_from_ITextDocument(me);
605 FIXME("stub %p\n",This);
606 return E_NOTIMPL;
607 }
608
609 static HRESULT WINAPI
610 ITextDocument_fnUnfreeze(ITextDocument* me, LONG* pCount)
611 {
612 IRichEditOleImpl *This = impl_from_ITextDocument(me);
613 FIXME("stub %p\n",This);
614 return E_NOTIMPL;
615 }
616
617 static HRESULT WINAPI
618 ITextDocument_fnBeginEditCollection(ITextDocument* me)
619 {
620 IRichEditOleImpl *This = impl_from_ITextDocument(me);
621 FIXME("stub %p\n",This);
622 return E_NOTIMPL;
623 }
624
625 static HRESULT WINAPI
626 ITextDocument_fnEndEditCollection(ITextDocument* me)
627 {
628 IRichEditOleImpl *This = impl_from_ITextDocument(me);
629 FIXME("stub %p\n",This);
630 return E_NOTIMPL;
631 }
632
633 static HRESULT WINAPI
634 ITextDocument_fnUndo(ITextDocument* me, LONG Count, LONG* prop)
635 {
636 IRichEditOleImpl *This = impl_from_ITextDocument(me);
637 FIXME("stub %p\n",This);
638 return E_NOTIMPL;
639 }
640
641 static HRESULT WINAPI
642 ITextDocument_fnRedo(ITextDocument* me, LONG Count, LONG* prop)
643 {
644 IRichEditOleImpl *This = impl_from_ITextDocument(me);
645 FIXME("stub %p\n",This);
646 return E_NOTIMPL;
647 }
648
649 static HRESULT WINAPI
650 ITextDocument_fnRange(ITextDocument* me, LONG cp1, LONG cp2,
651 ITextRange** ppRange)
652 {
653 IRichEditOleImpl *This = impl_from_ITextDocument(me);
654 FIXME("stub %p\n",This);
655 return E_NOTIMPL;
656 }
657
658 static HRESULT WINAPI
659 ITextDocument_fnRangeFromPoint(ITextDocument* me, LONG x, LONG y,
660 ITextRange** ppRange)
661 {
662 IRichEditOleImpl *This = impl_from_ITextDocument(me);
663 FIXME("stub %p\n",This);
664 return E_NOTIMPL;
665 }
666
667 static const ITextDocumentVtbl tdvt = {
668 ITextDocument_fnQueryInterface,
669 ITextDocument_fnAddRef,
670 ITextDocument_fnRelease,
671 ITextDocument_fnGetTypeInfoCount,
672 ITextDocument_fnGetTypeInfo,
673 ITextDocument_fnGetIDsOfNames,
674 ITextDocument_fnInvoke,
675 ITextDocument_fnGetName,
676 ITextDocument_fnGetSelection,
677 ITextDocument_fnGetStoryCount,
678 ITextDocument_fnGetStoryRanges,
679 ITextDocument_fnGetSaved,
680 ITextDocument_fnSetSaved,
681 ITextDocument_fnGetDefaultTabStop,
682 ITextDocument_fnSetDefaultTabStop,
683 ITextDocument_fnNew,
684 ITextDocument_fnOpen,
685 ITextDocument_fnSave,
686 ITextDocument_fnFreeze,
687 ITextDocument_fnUnfreeze,
688 ITextDocument_fnBeginEditCollection,
689 ITextDocument_fnEndEditCollection,
690 ITextDocument_fnUndo,
691 ITextDocument_fnRedo,
692 ITextDocument_fnRange,
693 ITextDocument_fnRangeFromPoint
694 };
695
696 static HRESULT WINAPI ITextSelection_fnQueryInterface(
697 ITextSelection *me,
698 REFIID riid,
699 void **ppvObj)
700 {
701 *ppvObj = NULL;
702 if (IsEqualGUID(riid, &IID_IUnknown)
703 || IsEqualGUID(riid, &IID_IDispatch)
704 || IsEqualGUID(riid, &IID_ITextRange)
705 || IsEqualGUID(riid, &IID_ITextSelection))
706 {
707 *ppvObj = me;
708 ITextSelection_AddRef(me);
709 return S_OK;
710 }
711
712 return E_NOINTERFACE;
713 }
714
715 static ULONG WINAPI ITextSelection_fnAddRef(
716 ITextSelection *me)
717 {
718 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
719 return InterlockedIncrement(&This->ref);
720 }
721
722 static ULONG WINAPI ITextSelection_fnRelease(
723 ITextSelection *me)
724 {
725 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
726 ULONG ref = InterlockedDecrement(&This->ref);
727 if (ref == 0)
728 heap_free(This);
729 return ref;
730 }
731
732 static HRESULT WINAPI ITextSelection_fnGetTypeInfoCount(
733 ITextSelection *me,
734 UINT *pctinfo)
735 {
736 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
737 if (!This->reOle)
738 return CO_E_RELEASED;
739
740 FIXME("not implemented\n");
741 return E_NOTIMPL;
742 }
743
744 static HRESULT WINAPI ITextSelection_fnGetTypeInfo(
745 ITextSelection *me,
746 UINT iTInfo,
747 LCID lcid,
748 ITypeInfo **ppTInfo)
749 {
750 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
751 if (!This->reOle)
752 return CO_E_RELEASED;
753
754 FIXME("not implemented\n");
755 return E_NOTIMPL;
756 }
757
758 static HRESULT WINAPI ITextSelection_fnGetIDsOfNames(
759 ITextSelection *me,
760 REFIID riid,
761 LPOLESTR *rgszNames,
762 UINT cNames,
763 LCID lcid,
764 DISPID *rgDispId)
765 {
766 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
767 if (!This->reOle)
768 return CO_E_RELEASED;
769
770 FIXME("not implemented\n");
771 return E_NOTIMPL;
772 }
773
774 static HRESULT WINAPI ITextSelection_fnInvoke(
775 ITextSelection *me,
776 DISPID dispIdMember,
777 REFIID riid,
778 LCID lcid,
779 WORD wFlags,
780 DISPPARAMS *pDispParams,
781 VARIANT *pVarResult,
782 EXCEPINFO *pExcepInfo,
783 UINT *puArgErr)
784 {
785 FIXME("not implemented\n");
786 return E_NOTIMPL;
787 }
788
789 /*** ITextRange methods ***/
790 static HRESULT WINAPI ITextSelection_fnGetText(
791 ITextSelection *me,
792 BSTR *pbstr)
793 {
794 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
795 if (!This->reOle)
796 return CO_E_RELEASED;
797
798 FIXME("not implemented\n");
799 return E_NOTIMPL;
800 }
801
802 static HRESULT WINAPI ITextSelection_fnSetText(
803 ITextSelection *me,
804 BSTR bstr)
805 {
806 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
807 if (!This->reOle)
808 return CO_E_RELEASED;
809
810 FIXME("not implemented\n");
811 return E_NOTIMPL;
812 }
813
814 static HRESULT WINAPI ITextSelection_fnGetChar(
815 ITextSelection *me,
816 LONG *pch)
817 {
818 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
819 if (!This->reOle)
820 return CO_E_RELEASED;
821
822 FIXME("not implemented\n");
823 return E_NOTIMPL;
824 }
825
826 static HRESULT WINAPI ITextSelection_fnSetChar(
827 ITextSelection *me,
828 LONG ch)
829 {
830 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
831 if (!This->reOle)
832 return CO_E_RELEASED;
833
834 FIXME("not implemented\n");
835 return E_NOTIMPL;
836 }
837
838 static HRESULT WINAPI ITextSelection_fnGetDuplicate(
839 ITextSelection *me,
840 ITextRange **ppRange)
841 {
842 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
843 if (!This->reOle)
844 return CO_E_RELEASED;
845
846 FIXME("not implemented\n");
847 return E_NOTIMPL;
848 }
849
850 static HRESULT WINAPI ITextSelection_fnGetFormattedText(
851 ITextSelection *me,
852 ITextRange **ppRange)
853 {
854 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
855 if (!This->reOle)
856 return CO_E_RELEASED;
857
858 FIXME("not implemented\n");
859 return E_NOTIMPL;
860 }
861
862 static HRESULT WINAPI ITextSelection_fnSetFormattedText(
863 ITextSelection *me,
864 ITextRange *pRange)
865 {
866 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
867 if (!This->reOle)
868 return CO_E_RELEASED;
869
870 FIXME("not implemented\n");
871 return E_NOTIMPL;
872 }
873
874 static HRESULT WINAPI ITextSelection_fnGetStart(
875 ITextSelection *me,
876 LONG *pcpFirst)
877 {
878 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
879 if (!This->reOle)
880 return CO_E_RELEASED;
881
882 FIXME("not implemented\n");
883 return E_NOTIMPL;
884 }
885
886 static HRESULT WINAPI ITextSelection_fnSetStart(
887 ITextSelection *me,
888 LONG cpFirst)
889 {
890 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
891 if (!This->reOle)
892 return CO_E_RELEASED;
893
894 FIXME("not implemented\n");
895 return E_NOTIMPL;
896 }
897
898 static HRESULT WINAPI ITextSelection_fnGetEnd(
899 ITextSelection *me,
900 LONG *pcpLim)
901 {
902 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
903 if (!This->reOle)
904 return CO_E_RELEASED;
905
906 FIXME("not implemented\n");
907 return E_NOTIMPL;
908 }
909
910 static HRESULT WINAPI ITextSelection_fnSetEnd(
911 ITextSelection *me,
912 LONG cpLim)
913 {
914 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
915 if (!This->reOle)
916 return CO_E_RELEASED;
917
918 FIXME("not implemented\n");
919 return E_NOTIMPL;
920 }
921
922 static HRESULT WINAPI ITextSelection_fnGetFont(
923 ITextSelection *me,
924 ITextFont **pFont)
925 {
926 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
927 if (!This->reOle)
928 return CO_E_RELEASED;
929
930 FIXME("not implemented\n");
931 return E_NOTIMPL;
932 }
933
934 static HRESULT WINAPI ITextSelection_fnSetFont(
935 ITextSelection *me,
936 ITextFont *pFont)
937 {
938 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
939 if (!This->reOle)
940 return CO_E_RELEASED;
941
942 FIXME("not implemented\n");
943 return E_NOTIMPL;
944 }
945
946 static HRESULT WINAPI ITextSelection_fnGetPara(
947 ITextSelection *me,
948 ITextPara **ppPara)
949 {
950 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
951 if (!This->reOle)
952 return CO_E_RELEASED;
953
954 FIXME("not implemented\n");
955 return E_NOTIMPL;
956 }
957
958 static HRESULT WINAPI ITextSelection_fnSetPara(
959 ITextSelection *me,
960 ITextPara *pPara)
961 {
962 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
963 if (!This->reOle)
964 return CO_E_RELEASED;
965
966 FIXME("not implemented\n");
967 return E_NOTIMPL;
968 }
969
970 static HRESULT WINAPI ITextSelection_fnGetStoryLength(
971 ITextSelection *me,
972 LONG *pcch)
973 {
974 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
975 if (!This->reOle)
976 return CO_E_RELEASED;
977
978 FIXME("not implemented\n");
979 return E_NOTIMPL;
980 }
981
982 static HRESULT WINAPI ITextSelection_fnGetStoryType(
983 ITextSelection *me,
984 LONG *pValue)
985 {
986 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
987 if (!This->reOle)
988 return CO_E_RELEASED;
989
990 FIXME("not implemented\n");
991 return E_NOTIMPL;
992 }
993
994 static HRESULT WINAPI ITextSelection_fnCollapse(
995 ITextSelection *me,
996 LONG bStart)
997 {
998 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
999 if (!This->reOle)
1000 return CO_E_RELEASED;
1001
1002 FIXME("not implemented\n");
1003 return E_NOTIMPL;
1004 }
1005
1006 static HRESULT WINAPI ITextSelection_fnExpand(
1007 ITextSelection *me,
1008 LONG Unit,
1009 LONG *pDelta)
1010 {
1011 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1012 if (!This->reOle)
1013 return CO_E_RELEASED;
1014
1015 FIXME("not implemented\n");
1016 return E_NOTIMPL;
1017 }
1018
1019 static HRESULT WINAPI ITextSelection_fnGetIndex(
1020 ITextSelection *me,
1021 LONG Unit,
1022 LONG *pIndex)
1023 {
1024 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1025 if (!This->reOle)
1026 return CO_E_RELEASED;
1027
1028 FIXME("not implemented\n");
1029 return E_NOTIMPL;
1030 }
1031
1032 static HRESULT WINAPI ITextSelection_fnSetIndex(
1033 ITextSelection *me,
1034 LONG Unit,
1035 LONG Index,
1036 LONG Extend)
1037 {
1038 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1039 if (!This->reOle)
1040 return CO_E_RELEASED;
1041
1042 FIXME("not implemented\n");
1043 return E_NOTIMPL;
1044 }
1045
1046 static HRESULT WINAPI ITextSelection_fnSetRange(
1047 ITextSelection *me,
1048 LONG cpActive,
1049 LONG cpOther)
1050 {
1051 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1052 if (!This->reOle)
1053 return CO_E_RELEASED;
1054
1055 FIXME("not implemented\n");
1056 return E_NOTIMPL;
1057 }
1058
1059 static HRESULT WINAPI ITextSelection_fnInRange(
1060 ITextSelection *me,
1061 ITextRange *pRange,
1062 LONG *pb)
1063 {
1064 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1065 if (!This->reOle)
1066 return CO_E_RELEASED;
1067
1068 FIXME("not implemented\n");
1069 return E_NOTIMPL;
1070 }
1071
1072 static HRESULT WINAPI ITextSelection_fnInStory(
1073 ITextSelection *me,
1074 ITextRange *pRange,
1075 LONG *pb)
1076 {
1077 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1078 if (!This->reOle)
1079 return CO_E_RELEASED;
1080
1081 FIXME("not implemented\n");
1082 return E_NOTIMPL;
1083 }
1084
1085 static HRESULT WINAPI ITextSelection_fnIsEqual(
1086 ITextSelection *me,
1087 ITextRange *pRange,
1088 LONG *pb)
1089 {
1090 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1091 if (!This->reOle)
1092 return CO_E_RELEASED;
1093
1094 FIXME("not implemented\n");
1095 return E_NOTIMPL;
1096 }
1097
1098 static HRESULT WINAPI ITextSelection_fnSelect(
1099 ITextSelection *me)
1100 {
1101 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1102 if (!This->reOle)
1103 return CO_E_RELEASED;
1104
1105 FIXME("not implemented\n");
1106 return E_NOTIMPL;
1107 }
1108
1109 static HRESULT WINAPI ITextSelection_fnStartOf(
1110 ITextSelection *me,
1111 LONG Unit,
1112 LONG Extend,
1113 LONG *pDelta)
1114 {
1115 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1116 if (!This->reOle)
1117 return CO_E_RELEASED;
1118
1119 FIXME("not implemented\n");
1120 return E_NOTIMPL;
1121 }
1122
1123 static HRESULT WINAPI ITextSelection_fnEndOf(
1124 ITextSelection *me,
1125 LONG Unit,
1126 LONG Extend,
1127 LONG *pDelta)
1128 {
1129 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1130 if (!This->reOle)
1131 return CO_E_RELEASED;
1132
1133 FIXME("not implemented\n");
1134 return E_NOTIMPL;
1135 }
1136
1137 static HRESULT WINAPI ITextSelection_fnMove(
1138 ITextSelection *me,
1139 LONG Unit,
1140 LONG Count,
1141 LONG *pDelta)
1142 {
1143 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1144 if (!This->reOle)
1145 return CO_E_RELEASED;
1146
1147 FIXME("not implemented\n");
1148 return E_NOTIMPL;
1149 }
1150
1151 static HRESULT WINAPI ITextSelection_fnMoveStart(
1152 ITextSelection *me,
1153 LONG Unit,
1154 LONG Count,
1155 LONG *pDelta)
1156 {
1157 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1158 if (!This->reOle)
1159 return CO_E_RELEASED;
1160
1161 FIXME("not implemented\n");
1162 return E_NOTIMPL;
1163 }
1164
1165 static HRESULT WINAPI ITextSelection_fnMoveEnd(
1166 ITextSelection *me,
1167 LONG Unit,
1168 LONG Count,
1169 LONG *pDelta)
1170 {
1171 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1172 if (!This->reOle)
1173 return CO_E_RELEASED;
1174
1175 FIXME("not implemented\n");
1176 return E_NOTIMPL;
1177 }
1178
1179 static HRESULT WINAPI ITextSelection_fnMoveWhile(
1180 ITextSelection *me,
1181 VARIANT *Cset,
1182 LONG Count,
1183 LONG *pDelta)
1184 {
1185 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1186 if (!This->reOle)
1187 return CO_E_RELEASED;
1188
1189 FIXME("not implemented\n");
1190 return E_NOTIMPL;
1191 }
1192
1193 static HRESULT WINAPI ITextSelection_fnMoveStartWhile(
1194 ITextSelection *me,
1195 VARIANT *Cset,
1196 LONG Count,
1197 LONG *pDelta)
1198 {
1199 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1200 if (!This->reOle)
1201 return CO_E_RELEASED;
1202
1203 FIXME("not implemented\n");
1204 return E_NOTIMPL;
1205 }
1206
1207 static HRESULT WINAPI ITextSelection_fnMoveEndWhile(
1208 ITextSelection *me,
1209 VARIANT *Cset,
1210 LONG Count,
1211 LONG *pDelta)
1212 {
1213 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1214 if (!This->reOle)
1215 return CO_E_RELEASED;
1216
1217 FIXME("not implemented\n");
1218 return E_NOTIMPL;
1219 }
1220
1221 static HRESULT WINAPI ITextSelection_fnMoveUntil(
1222 ITextSelection *me,
1223 VARIANT *Cset,
1224 LONG Count,
1225 LONG *pDelta)
1226 {
1227 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1228 if (!This->reOle)
1229 return CO_E_RELEASED;
1230
1231 FIXME("not implemented\n");
1232 return E_NOTIMPL;
1233 }
1234
1235 static HRESULT WINAPI ITextSelection_fnMoveStartUntil(
1236 ITextSelection *me,
1237 VARIANT *Cset,
1238 LONG Count,
1239 LONG *pDelta)
1240 {
1241 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1242 if (!This->reOle)
1243 return CO_E_RELEASED;
1244
1245 FIXME("not implemented\n");
1246 return E_NOTIMPL;
1247 }
1248
1249 static HRESULT WINAPI ITextSelection_fnMoveEndUntil(
1250 ITextSelection *me,
1251 VARIANT *Cset,
1252 LONG Count,
1253 LONG *pDelta)
1254 {
1255 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1256 if (!This->reOle)
1257 return CO_E_RELEASED;
1258
1259 FIXME("not implemented\n");
1260 return E_NOTIMPL;
1261 }
1262
1263 static HRESULT WINAPI ITextSelection_fnFindText(
1264 ITextSelection *me,
1265 BSTR bstr,
1266 LONG cch,
1267 LONG Flags,
1268 LONG *pLength)
1269 {
1270 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1271 if (!This->reOle)
1272 return CO_E_RELEASED;
1273
1274 FIXME("not implemented\n");
1275 return E_NOTIMPL;
1276 }
1277
1278 static HRESULT WINAPI ITextSelection_fnFindTextStart(
1279 ITextSelection *me,
1280 BSTR bstr,
1281 LONG cch,
1282 LONG Flags,
1283 LONG *pLength)
1284 {
1285 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1286 if (!This->reOle)
1287 return CO_E_RELEASED;
1288
1289 FIXME("not implemented\n");
1290 return E_NOTIMPL;
1291 }
1292
1293 static HRESULT WINAPI ITextSelection_fnFindTextEnd(
1294 ITextSelection *me,
1295 BSTR bstr,
1296 LONG cch,
1297 LONG Flags,
1298 LONG *pLength)
1299 {
1300 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1301 if (!This->reOle)
1302 return CO_E_RELEASED;
1303
1304 FIXME("not implemented\n");
1305 return E_NOTIMPL;
1306 }
1307
1308 static HRESULT WINAPI ITextSelection_fnDelete(
1309 ITextSelection *me,
1310 LONG Unit,
1311 LONG Count,
1312 LONG *pDelta)
1313 {
1314 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1315 if (!This->reOle)
1316 return CO_E_RELEASED;
1317
1318 FIXME("not implemented\n");
1319 return E_NOTIMPL;
1320 }
1321
1322 static HRESULT WINAPI ITextSelection_fnCut(
1323 ITextSelection *me,
1324 VARIANT *pVar)
1325 {
1326 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1327 if (!This->reOle)
1328 return CO_E_RELEASED;
1329
1330 FIXME("not implemented\n");
1331 return E_NOTIMPL;
1332 }
1333
1334 static HRESULT WINAPI ITextSelection_fnCopy(
1335 ITextSelection *me,
1336 VARIANT *pVar)
1337 {
1338 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1339 if (!This->reOle)
1340 return CO_E_RELEASED;
1341
1342 FIXME("not implemented\n");
1343 return E_NOTIMPL;
1344 }
1345
1346 static HRESULT WINAPI ITextSelection_fnPaste(
1347 ITextSelection *me,
1348 VARIANT *pVar,
1349 LONG Format)
1350 {
1351 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1352 if (!This->reOle)
1353 return CO_E_RELEASED;
1354
1355 FIXME("not implemented\n");
1356 return E_NOTIMPL;
1357 }
1358
1359 static HRESULT WINAPI ITextSelection_fnCanPaste(
1360 ITextSelection *me,
1361 VARIANT *pVar,
1362 LONG Format,
1363 LONG *pb)
1364 {
1365 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1366 if (!This->reOle)
1367 return CO_E_RELEASED;
1368
1369 FIXME("not implemented\n");
1370 return E_NOTIMPL;
1371 }
1372
1373 static HRESULT WINAPI ITextSelection_fnCanEdit(
1374 ITextSelection *me,
1375 LONG *pb)
1376 {
1377 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1378 if (!This->reOle)
1379 return CO_E_RELEASED;
1380
1381 FIXME("not implemented\n");
1382 return E_NOTIMPL;
1383 }
1384
1385 static HRESULT WINAPI ITextSelection_fnChangeCase(
1386 ITextSelection *me,
1387 LONG Type)
1388 {
1389 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1390 if (!This->reOle)
1391 return CO_E_RELEASED;
1392
1393 FIXME("not implemented\n");
1394 return E_NOTIMPL;
1395 }
1396
1397 static HRESULT WINAPI ITextSelection_fnGetPoint(
1398 ITextSelection *me,
1399 LONG Type,
1400 LONG *cx,
1401 LONG *cy)
1402 {
1403 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1404 if (!This->reOle)
1405 return CO_E_RELEASED;
1406
1407 FIXME("not implemented\n");
1408 return E_NOTIMPL;
1409 }
1410
1411 static HRESULT WINAPI ITextSelection_fnSetPoint(
1412 ITextSelection *me,
1413 LONG x,
1414 LONG y,
1415 LONG Type,
1416 LONG Extend)
1417 {
1418 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1419 if (!This->reOle)
1420 return CO_E_RELEASED;
1421
1422 FIXME("not implemented\n");
1423 return E_NOTIMPL;
1424 }
1425
1426 static HRESULT WINAPI ITextSelection_fnScrollIntoView(
1427 ITextSelection *me,
1428 LONG Value)
1429 {
1430 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1431 if (!This->reOle)
1432 return CO_E_RELEASED;
1433
1434 FIXME("not implemented\n");
1435 return E_NOTIMPL;
1436 }
1437
1438 static HRESULT WINAPI ITextSelection_fnGetEmbeddedObject(
1439 ITextSelection *me,
1440 IUnknown **ppv)
1441 {
1442 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1443 if (!This->reOle)
1444 return CO_E_RELEASED;
1445
1446 FIXME("not implemented\n");
1447 return E_NOTIMPL;
1448 }
1449
1450 /*** ITextSelection methods ***/
1451 static HRESULT WINAPI ITextSelection_fnGetFlags(
1452 ITextSelection *me,
1453 LONG *pFlags)
1454 {
1455 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1456 if (!This->reOle)
1457 return CO_E_RELEASED;
1458
1459 FIXME("not implemented\n");
1460 return E_NOTIMPL;
1461 }
1462
1463 static HRESULT WINAPI ITextSelection_fnSetFlags(
1464 ITextSelection *me,
1465 LONG Flags)
1466 {
1467 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1468 if (!This->reOle)
1469 return CO_E_RELEASED;
1470
1471 FIXME("not implemented\n");
1472 return E_NOTIMPL;
1473 }
1474
1475 static HRESULT WINAPI ITextSelection_fnGetType(
1476 ITextSelection *me,
1477 LONG *pType)
1478 {
1479 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1480 if (!This->reOle)
1481 return CO_E_RELEASED;
1482
1483 FIXME("not implemented\n");
1484 return E_NOTIMPL;
1485 }
1486
1487 static HRESULT WINAPI ITextSelection_fnMoveLeft(
1488 ITextSelection *me,
1489 LONG Unit,
1490 LONG Count,
1491 LONG Extend,
1492 LONG *pDelta)
1493 {
1494 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1495 if (!This->reOle)
1496 return CO_E_RELEASED;
1497
1498 FIXME("not implemented\n");
1499 return E_NOTIMPL;
1500 }
1501
1502 static HRESULT WINAPI ITextSelection_fnMoveRight(
1503 ITextSelection *me,
1504 LONG Unit,
1505 LONG Count,
1506 LONG Extend,
1507 LONG *pDelta)
1508 {
1509 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1510 if (!This->reOle)
1511 return CO_E_RELEASED;
1512
1513 FIXME("not implemented\n");
1514 return E_NOTIMPL;
1515 }
1516
1517 static HRESULT WINAPI ITextSelection_fnMoveUp(
1518 ITextSelection *me,
1519 LONG Unit,
1520 LONG Count,
1521 LONG Extend,
1522 LONG *pDelta)
1523 {
1524 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1525 if (!This->reOle)
1526 return CO_E_RELEASED;
1527
1528 FIXME("not implemented\n");
1529 return E_NOTIMPL;
1530 }
1531
1532 static HRESULT WINAPI ITextSelection_fnMoveDown(
1533 ITextSelection *me,
1534 LONG Unit,
1535 LONG Count,
1536 LONG Extend,
1537 LONG *pDelta)
1538 {
1539 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1540 if (!This->reOle)
1541 return CO_E_RELEASED;
1542
1543 FIXME("not implemented\n");
1544 return E_NOTIMPL;
1545 }
1546
1547 static HRESULT WINAPI ITextSelection_fnHomeKey(
1548 ITextSelection *me,
1549 LONG Unit,
1550 LONG Extend,
1551 LONG *pDelta)
1552 {
1553 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1554 if (!This->reOle)
1555 return CO_E_RELEASED;
1556
1557 FIXME("not implemented\n");
1558 return E_NOTIMPL;
1559 }
1560
1561 static HRESULT WINAPI ITextSelection_fnEndKey(
1562 ITextSelection *me,
1563 LONG Unit,
1564 LONG Extend,
1565 LONG *pDelta)
1566 {
1567 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1568 if (!This->reOle)
1569 return CO_E_RELEASED;
1570
1571 FIXME("not implemented\n");
1572 return E_NOTIMPL;
1573 }
1574
1575 static HRESULT WINAPI ITextSelection_fnTypeText(
1576 ITextSelection *me,
1577 BSTR bstr)
1578 {
1579 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1580 if (!This->reOle)
1581 return CO_E_RELEASED;
1582
1583 FIXME("not implemented\n");
1584 return E_NOTIMPL;
1585 }
1586
1587 static const ITextSelectionVtbl tsvt = {
1588 ITextSelection_fnQueryInterface,
1589 ITextSelection_fnAddRef,
1590 ITextSelection_fnRelease,
1591 ITextSelection_fnGetTypeInfoCount,
1592 ITextSelection_fnGetTypeInfo,
1593 ITextSelection_fnGetIDsOfNames,
1594 ITextSelection_fnInvoke,
1595 ITextSelection_fnGetText,
1596 ITextSelection_fnSetText,
1597 ITextSelection_fnGetChar,
1598 ITextSelection_fnSetChar,
1599 ITextSelection_fnGetDuplicate,
1600 ITextSelection_fnGetFormattedText,
1601 ITextSelection_fnSetFormattedText,
1602 ITextSelection_fnGetStart,
1603 ITextSelection_fnSetStart,
1604 ITextSelection_fnGetEnd,
1605 ITextSelection_fnSetEnd,
1606 ITextSelection_fnGetFont,
1607 ITextSelection_fnSetFont,
1608 ITextSelection_fnGetPara,
1609 ITextSelection_fnSetPara,
1610 ITextSelection_fnGetStoryLength,
1611 ITextSelection_fnGetStoryType,
1612 ITextSelection_fnCollapse,
1613 ITextSelection_fnExpand,
1614 ITextSelection_fnGetIndex,
1615 ITextSelection_fnSetIndex,
1616 ITextSelection_fnSetRange,
1617 ITextSelection_fnInRange,
1618 ITextSelection_fnInStory,
1619 ITextSelection_fnIsEqual,
1620 ITextSelection_fnSelect,
1621 ITextSelection_fnStartOf,
1622 ITextSelection_fnEndOf,
1623 ITextSelection_fnMove,
1624 ITextSelection_fnMoveStart,
1625 ITextSelection_fnMoveEnd,
1626 ITextSelection_fnMoveWhile,
1627 ITextSelection_fnMoveStartWhile,
1628 ITextSelection_fnMoveEndWhile,
1629 ITextSelection_fnMoveUntil,
1630 ITextSelection_fnMoveStartUntil,
1631 ITextSelection_fnMoveEndUntil,
1632 ITextSelection_fnFindText,
1633 ITextSelection_fnFindTextStart,
1634 ITextSelection_fnFindTextEnd,
1635 ITextSelection_fnDelete,
1636 ITextSelection_fnCut,
1637 ITextSelection_fnCopy,
1638 ITextSelection_fnPaste,
1639 ITextSelection_fnCanPaste,
1640 ITextSelection_fnCanEdit,
1641 ITextSelection_fnChangeCase,
1642 ITextSelection_fnGetPoint,
1643 ITextSelection_fnSetPoint,
1644 ITextSelection_fnScrollIntoView,
1645 ITextSelection_fnGetEmbeddedObject,
1646 ITextSelection_fnGetFlags,
1647 ITextSelection_fnSetFlags,
1648 ITextSelection_fnGetType,
1649 ITextSelection_fnMoveLeft,
1650 ITextSelection_fnMoveRight,
1651 ITextSelection_fnMoveUp,
1652 ITextSelection_fnMoveDown,
1653 ITextSelection_fnHomeKey,
1654 ITextSelection_fnEndKey,
1655 ITextSelection_fnTypeText
1656 };
1657
1658 static ITextSelectionImpl *
1659 CreateTextSelection(IRichEditOleImpl *reOle)
1660 {
1661 ITextSelectionImpl *txtSel = heap_alloc(sizeof *txtSel);
1662 if (!txtSel)
1663 return NULL;
1664
1665 txtSel->lpVtbl = &tsvt;
1666 txtSel->ref = 1;
1667 txtSel->reOle = reOle;
1668 return txtSel;
1669 }
1670
1671 LRESULT CreateIRichEditOle(ME_TextEditor *editor, LPVOID *ppObj)
1672 {
1673 IRichEditOleImpl *reo;
1674
1675 reo = heap_alloc(sizeof(IRichEditOleImpl));
1676 if (!reo)
1677 return 0;
1678
1679 reo->lpRichEditOleVtbl = &revt;
1680 reo->lpTextDocumentVtbl = &tdvt;
1681 reo->ref = 1;
1682 reo->editor = editor;
1683 reo->txtSel = CreateTextSelection(reo);
1684 if (!reo->txtSel)
1685 {
1686 heap_free(reo);
1687 return 0;
1688 }
1689 reo->clientSite = CreateOleClientSite(reo);
1690 if (!reo->txtSel)
1691 {
1692 ITextSelection_Release((ITextSelection *) reo->txtSel);
1693 heap_free(reo);
1694 return 0;
1695 }
1696 TRACE("Created %p\n",reo);
1697 *ppObj = reo;
1698
1699 return 1;
1700 }
1701
1702 static void convert_sizel(ME_Context *c, const SIZEL* szl, SIZE* sz)
1703 {
1704 /* sizel is in .01 millimeters, sz in pixels */
1705 sz->cx = MulDiv(szl->cx, c->dpi.cx, 2540);
1706 sz->cy = MulDiv(szl->cy, c->dpi.cy, 2540);
1707 }
1708
1709 /******************************************************************************
1710 * ME_GetOLEObjectSize
1711 *
1712 * Sets run extent for OLE objects.
1713 */
1714 void ME_GetOLEObjectSize(ME_Context *c, ME_Run *run, SIZE *pSize)
1715 {
1716 IDataObject* ido;
1717 FORMATETC fmt;
1718 STGMEDIUM stgm;
1719 DIBSECTION dibsect;
1720 ENHMETAHEADER emh;
1721
1722 assert(run->nFlags & MERF_GRAPHICS);
1723 assert(run->ole_obj);
1724
1725 if (run->ole_obj->sizel.cx != 0 || run->ole_obj->sizel.cy != 0)
1726 {
1727 convert_sizel(c, &run->ole_obj->sizel, pSize);
1728 return;
1729 }
1730
1731 IOleObject_QueryInterface(run->ole_obj->poleobj, &IID_IDataObject, (void**)&ido);
1732 fmt.cfFormat = CF_BITMAP;
1733 fmt.ptd = NULL;
1734 fmt.dwAspect = DVASPECT_CONTENT;
1735 fmt.lindex = -1;
1736 fmt.tymed = TYMED_GDI;
1737 if (IDataObject_GetData(ido, &fmt, &stgm) != S_OK)
1738 {
1739 fmt.cfFormat = CF_ENHMETAFILE;
1740 fmt.tymed = TYMED_ENHMF;
1741 if (IDataObject_GetData(ido, &fmt, &stgm) != S_OK)
1742 {
1743 FIXME("unsupported format\n");
1744 pSize->cx = pSize->cy = 0;
1745 IDataObject_Release(ido);
1746 return;
1747 }
1748 }
1749
1750 switch (stgm.tymed)
1751 {
1752 case TYMED_GDI:
1753 GetObjectW(stgm.u.hBitmap, sizeof(dibsect), &dibsect);
1754 pSize->cx = dibsect.dsBm.bmWidth;
1755 pSize->cy = dibsect.dsBm.bmHeight;
1756 if (!stgm.pUnkForRelease) DeleteObject(stgm.u.hBitmap);
1757 break;
1758 case TYMED_ENHMF:
1759 GetEnhMetaFileHeader(stgm.u.hEnhMetaFile, sizeof(emh), &emh);
1760 pSize->cx = emh.rclBounds.right - emh.rclBounds.left;
1761 pSize->cy = emh.rclBounds.bottom - emh.rclBounds.top;
1762 if (!stgm.pUnkForRelease) DeleteEnhMetaFile(stgm.u.hEnhMetaFile);
1763 break;
1764 default:
1765 FIXME("Unsupported tymed %d\n", stgm.tymed);
1766 break;
1767 }
1768 IDataObject_Release(ido);
1769 if (c->editor->nZoomNumerator != 0)
1770 {
1771 pSize->cx = MulDiv(pSize->cx, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
1772 pSize->cy = MulDiv(pSize->cy, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
1773 }
1774 }
1775
1776 void ME_DrawOLE(ME_Context *c, int x, int y, ME_Run *run,
1777 ME_Paragraph *para, BOOL selected)
1778 {
1779 IDataObject* ido;
1780 FORMATETC fmt;
1781 STGMEDIUM stgm;
1782 DIBSECTION dibsect;
1783 ENHMETAHEADER emh;
1784 HDC hMemDC;
1785 SIZE sz;
1786 BOOL has_size;
1787
1788 assert(run->nFlags & MERF_GRAPHICS);
1789 assert(run->ole_obj);
1790 if (IOleObject_QueryInterface(run->ole_obj->poleobj, &IID_IDataObject, (void**)&ido) != S_OK)
1791 {
1792 FIXME("Couldn't get interface\n");
1793 return;
1794 }
1795 has_size = run->ole_obj->sizel.cx != 0 || run->ole_obj->sizel.cy != 0;
1796 fmt.cfFormat = CF_BITMAP;
1797 fmt.ptd = NULL;
1798 fmt.dwAspect = DVASPECT_CONTENT;
1799 fmt.lindex = -1;
1800 fmt.tymed = TYMED_GDI;
1801 if (IDataObject_GetData(ido, &fmt, &stgm) != S_OK)
1802 {
1803 fmt.cfFormat = CF_ENHMETAFILE;
1804 fmt.tymed = TYMED_ENHMF;
1805 if (IDataObject_GetData(ido, &fmt, &stgm) != S_OK)
1806 {
1807 FIXME("Couldn't get storage medium\n");
1808 IDataObject_Release(ido);
1809 return;
1810 }
1811 }
1812 switch (stgm.tymed)
1813 {
1814 case TYMED_GDI:
1815 GetObjectW(stgm.u.hBitmap, sizeof(dibsect), &dibsect);
1816 hMemDC = CreateCompatibleDC(c->hDC);
1817 SelectObject(hMemDC, stgm.u.hBitmap);
1818 if (!has_size && c->editor->nZoomNumerator == 0)
1819 {
1820 sz.cx = dibsect.dsBm.bmWidth;
1821 sz.cy = dibsect.dsBm.bmHeight;
1822 BitBlt(c->hDC, x, y - dibsect.dsBm.bmHeight,
1823 dibsect.dsBm.bmWidth, dibsect.dsBm.bmHeight,
1824 hMemDC, 0, 0, SRCCOPY);
1825 }
1826 else
1827 {
1828 if (has_size)
1829 {
1830 convert_sizel(c, &run->ole_obj->sizel, &sz);
1831 }
1832 else
1833 {
1834 sz.cx = MulDiv(dibsect.dsBm.bmWidth,
1835 c->editor->nZoomNumerator, c->editor->nZoomDenominator);
1836 sz.cy = MulDiv(dibsect.dsBm.bmHeight,
1837 c->editor->nZoomNumerator, c->editor->nZoomDenominator);
1838 }
1839 StretchBlt(c->hDC, x, y - sz.cy, sz.cx, sz.cy,
1840 hMemDC, 0, 0, dibsect.dsBm.bmWidth, dibsect.dsBm.bmHeight, SRCCOPY);
1841 }
1842 if (!stgm.pUnkForRelease) DeleteObject(stgm.u.hBitmap);
1843 break;
1844 case TYMED_ENHMF:
1845 GetEnhMetaFileHeader(stgm.u.hEnhMetaFile, sizeof(emh), &emh);
1846 if (!has_size && c->editor->nZoomNumerator == 0)
1847 {
1848 sz.cy = emh.rclBounds.bottom - emh.rclBounds.top;
1849 sz.cx = emh.rclBounds.right - emh.rclBounds.left;
1850 }
1851 else
1852 {
1853 if (has_size)
1854 {
1855 convert_sizel(c, &run->ole_obj->sizel, &sz);
1856 }
1857 else
1858 {
1859 sz.cy = MulDiv(emh.rclBounds.bottom - emh.rclBounds.top,
1860 c->editor->nZoomNumerator, c->editor->nZoomDenominator);
1861 sz.cx = MulDiv(emh.rclBounds.right - emh.rclBounds.left,
1862 c->editor->nZoomNumerator, c->editor->nZoomDenominator);
1863 }
1864 }
1865 {
1866 RECT rc;
1867
1868 rc.left = x;
1869 rc.top = y - sz.cy;
1870 rc.right = x + sz.cx;
1871 rc.bottom = y;
1872 PlayEnhMetaFile(c->hDC, stgm.u.hEnhMetaFile, &rc);
1873 }
1874 if (!stgm.pUnkForRelease) DeleteEnhMetaFile(stgm.u.hEnhMetaFile);
1875 break;
1876 default:
1877 FIXME("Unsupported tymed %d\n", stgm.tymed);
1878 selected = FALSE;
1879 break;
1880 }
1881 if (selected && !c->editor->bHideSelection)
1882 PatBlt(c->hDC, x, y - sz.cy, sz.cx, sz.cy, DSTINVERT);
1883 IDataObject_Release(ido);
1884 }
1885
1886 void ME_DeleteReObject(REOBJECT* reo)
1887 {
1888 if (reo->poleobj) IOleObject_Release(reo->poleobj);
1889 if (reo->pstg) IStorage_Release(reo->pstg);
1890 if (reo->polesite) IOleClientSite_Release(reo->polesite);
1891 FREE_OBJ(reo);
1892 }
1893
1894 void ME_CopyReObject(REOBJECT* dst, const REOBJECT* src)
1895 {
1896 *dst = *src;
1897
1898 if (dst->poleobj) IOleObject_AddRef(dst->poleobj);
1899 if (dst->pstg) IStorage_AddRef(dst->pstg);
1900 if (dst->polesite) IOleClientSite_AddRef(dst->polesite);
1901 }
1902
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.