* Sync up to trunk head (r64921).
[reactos.git] / dll / win32 / riched20 / richole.c
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 "editor.h"
23
24 #include <tom.h>
25
26 WINE_DEFAULT_DEBUG_CHANNEL(richedit);
27
28 /* there is no way to be consistent across different sets of headers - mingw, Wine, Win32 SDK*/
29
30 #include <initguid.h>
31 DEFINE_GUID(IID_ITextServices, 0x8d33f740, 0xcf58, 0x11ce, 0xa8, 0x9d, 0x00, 0xaa, 0x00, 0x6c, 0xad, 0xc5);
32 DEFINE_GUID(IID_ITextHost, 0x13e670f4,0x1a5a,0x11cf,0xab,0xeb,0x00,0xaa,0x00,0xb6,0x5e,0xa1);
33 DEFINE_GUID(IID_ITextHost2, 0x13e670f5,0x1a5a,0x11cf,0xab,0xeb,0x00,0xaa,0x00,0xb6,0x5e,0xa1);
34 DEFINE_GUID(IID_ITextDocument, 0x8cc497c0, 0xa1df, 0x11ce, 0x80, 0x98, 0x00, 0xaa, 0x00, 0x47, 0xbe, 0x5d);
35 DEFINE_GUID(IID_ITextRange, 0x8cc497c2, 0xa1df, 0x11ce, 0x80, 0x98, 0x00, 0xaa, 0x00, 0x47, 0xbe, 0x5d);
36 DEFINE_GUID(IID_ITextSelection, 0x8cc497c1, 0xa1df, 0x11ce, 0x80, 0x98, 0x00, 0xaa, 0x00, 0x47, 0xbe, 0x5d);
37
38 typedef struct ITextSelectionImpl ITextSelectionImpl;
39 typedef struct IOleClientSiteImpl IOleClientSiteImpl;
40 typedef struct ITextRangeImpl ITextRangeImpl;
41
42 typedef struct IRichEditOleImpl {
43 IRichEditOle IRichEditOle_iface;
44 ITextDocument ITextDocument_iface;
45 LONG ref;
46
47 ME_TextEditor *editor;
48 ITextSelectionImpl *txtSel;
49 IOleClientSiteImpl *clientSite;
50 struct list rangelist;
51 } IRichEditOleImpl;
52
53 struct ITextRangeImpl {
54 ITextRange ITextRange_iface;
55 LONG ref;
56 LONG start, end;
57 struct list entry;
58
59 IRichEditOleImpl *reOle;
60 };
61
62 struct ITextSelectionImpl {
63 ITextSelection ITextSelection_iface;
64 LONG ref;
65
66 IRichEditOleImpl *reOle;
67 };
68
69 struct IOleClientSiteImpl {
70 IOleClientSite IOleClientSite_iface;
71 LONG ref;
72
73 IRichEditOleImpl *reOle;
74 };
75
76 static inline IRichEditOleImpl *impl_from_IRichEditOle(IRichEditOle *iface)
77 {
78 return CONTAINING_RECORD(iface, IRichEditOleImpl, IRichEditOle_iface);
79 }
80
81 static inline IRichEditOleImpl *impl_from_ITextDocument(ITextDocument *iface)
82 {
83 return CONTAINING_RECORD(iface, IRichEditOleImpl, ITextDocument_iface);
84 }
85
86 static HRESULT WINAPI
87 IRichEditOle_fnQueryInterface(IRichEditOle *me, REFIID riid, LPVOID *ppvObj)
88 {
89 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
90
91 TRACE("%p %s\n", This, debugstr_guid(riid) );
92
93 *ppvObj = NULL;
94 if (IsEqualGUID(riid, &IID_IUnknown) ||
95 IsEqualGUID(riid, &IID_IRichEditOle))
96 *ppvObj = &This->IRichEditOle_iface;
97 else if (IsEqualGUID(riid, &IID_ITextDocument))
98 *ppvObj = &This->ITextDocument_iface;
99 if (*ppvObj)
100 {
101 IRichEditOle_AddRef(me);
102 return S_OK;
103 }
104 FIXME("%p: unhandled interface %s\n", This, debugstr_guid(riid) );
105
106 return E_NOINTERFACE;
107 }
108
109 static ULONG WINAPI
110 IRichEditOle_fnAddRef(IRichEditOle *me)
111 {
112 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
113 ULONG ref = InterlockedIncrement( &This->ref );
114
115 TRACE("%p ref = %u\n", This, ref);
116
117 return ref;
118 }
119
120 static ULONG WINAPI
121 IRichEditOle_fnRelease(IRichEditOle *me)
122 {
123 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
124 ULONG ref = InterlockedDecrement(&This->ref);
125
126 TRACE ("%p ref=%u\n", This, ref);
127
128 if (!ref)
129 {
130 ITextRangeImpl *txtRge;
131 TRACE ("Destroying %p\n", This);
132 This->txtSel->reOle = NULL;
133 ITextSelection_Release(&This->txtSel->ITextSelection_iface);
134 IOleClientSite_Release(&This->clientSite->IOleClientSite_iface);
135 LIST_FOR_EACH_ENTRY(txtRge, &This->rangelist, ITextRangeImpl, entry)
136 txtRge->reOle = NULL;
137 heap_free(This);
138 }
139 return ref;
140 }
141
142 static HRESULT WINAPI
143 IRichEditOle_fnActivateAs(IRichEditOle *me, REFCLSID rclsid, REFCLSID rclsidAs)
144 {
145 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
146 FIXME("stub %p\n",This);
147 return E_NOTIMPL;
148 }
149
150 static HRESULT WINAPI
151 IRichEditOle_fnContextSensitiveHelp(IRichEditOle *me, BOOL fEnterMode)
152 {
153 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
154 FIXME("stub %p\n",This);
155 return E_NOTIMPL;
156 }
157
158 static HRESULT WINAPI
159 IRichEditOle_fnConvertObject(IRichEditOle *me, LONG iob,
160 REFCLSID rclsidNew, LPCSTR lpstrUserTypeNew)
161 {
162 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
163 FIXME("stub %p\n",This);
164 return E_NOTIMPL;
165 }
166
167 static inline IOleClientSiteImpl *impl_from_IOleClientSite(IOleClientSite *iface)
168 {
169 return CONTAINING_RECORD(iface, IOleClientSiteImpl, IOleClientSite_iface);
170 }
171
172 static HRESULT WINAPI
173 IOleClientSite_fnQueryInterface(IOleClientSite *me, REFIID riid, LPVOID *ppvObj)
174 {
175 TRACE("%p %s\n", me, debugstr_guid(riid) );
176
177 *ppvObj = NULL;
178 if (IsEqualGUID(riid, &IID_IUnknown) ||
179 IsEqualGUID(riid, &IID_IOleClientSite))
180 *ppvObj = me;
181 if (*ppvObj)
182 {
183 IOleClientSite_AddRef(me);
184 return S_OK;
185 }
186 FIXME("%p: unhandled interface %s\n", me, debugstr_guid(riid) );
187
188 return E_NOINTERFACE;
189 }
190
191 static ULONG WINAPI IOleClientSite_fnAddRef(IOleClientSite *iface)
192 {
193 IOleClientSiteImpl *This = impl_from_IOleClientSite(iface);
194 return InterlockedIncrement(&This->ref);
195 }
196
197 static ULONG WINAPI IOleClientSite_fnRelease(IOleClientSite *iface)
198 {
199 IOleClientSiteImpl *This = impl_from_IOleClientSite(iface);
200 ULONG ref = InterlockedDecrement(&This->ref);
201 if (ref == 0)
202 heap_free(This);
203 return ref;
204 }
205
206 static HRESULT WINAPI IOleClientSite_fnSaveObject(IOleClientSite *iface)
207 {
208 IOleClientSiteImpl *This = impl_from_IOleClientSite(iface);
209 if (!This->reOle)
210 return CO_E_RELEASED;
211
212 FIXME("stub %p\n", iface);
213 return E_NOTIMPL;
214 }
215
216
217 static HRESULT WINAPI IOleClientSite_fnGetMoniker(IOleClientSite *iface, DWORD dwAssign,
218 DWORD dwWhichMoniker, IMoniker **ppmk)
219 {
220 IOleClientSiteImpl *This = impl_from_IOleClientSite(iface);
221 if (!This->reOle)
222 return CO_E_RELEASED;
223
224 FIXME("stub %p\n", iface);
225 return E_NOTIMPL;
226 }
227
228 static HRESULT WINAPI IOleClientSite_fnGetContainer(IOleClientSite *iface,
229 IOleContainer **ppContainer)
230 {
231 IOleClientSiteImpl *This = impl_from_IOleClientSite(iface);
232 if (!This->reOle)
233 return CO_E_RELEASED;
234
235 FIXME("stub %p\n", iface);
236 return E_NOTIMPL;
237 }
238
239 static HRESULT WINAPI IOleClientSite_fnShowObject(IOleClientSite *iface)
240 {
241 IOleClientSiteImpl *This = impl_from_IOleClientSite(iface);
242 if (!This->reOle)
243 return CO_E_RELEASED;
244
245 FIXME("stub %p\n", iface);
246 return E_NOTIMPL;
247 }
248
249 static HRESULT WINAPI IOleClientSite_fnOnShowWindow(IOleClientSite *iface, BOOL fShow)
250 {
251 IOleClientSiteImpl *This = impl_from_IOleClientSite(iface);
252 if (!This->reOle)
253 return CO_E_RELEASED;
254
255 FIXME("stub %p\n", iface);
256 return E_NOTIMPL;
257 }
258
259 static HRESULT WINAPI IOleClientSite_fnRequestNewObjectLayout(IOleClientSite *iface)
260 {
261 IOleClientSiteImpl *This = impl_from_IOleClientSite(iface);
262 if (!This->reOle)
263 return CO_E_RELEASED;
264
265 FIXME("stub %p\n", iface);
266 return E_NOTIMPL;
267 }
268
269 static const IOleClientSiteVtbl ocst = {
270 IOleClientSite_fnQueryInterface,
271 IOleClientSite_fnAddRef,
272 IOleClientSite_fnRelease,
273 IOleClientSite_fnSaveObject,
274 IOleClientSite_fnGetMoniker,
275 IOleClientSite_fnGetContainer,
276 IOleClientSite_fnShowObject,
277 IOleClientSite_fnOnShowWindow,
278 IOleClientSite_fnRequestNewObjectLayout
279 };
280
281 static IOleClientSiteImpl *
282 CreateOleClientSite(IRichEditOleImpl *reOle)
283 {
284 IOleClientSiteImpl *clientSite = heap_alloc(sizeof *clientSite);
285 if (!clientSite)
286 return NULL;
287
288 clientSite->IOleClientSite_iface.lpVtbl = &ocst;
289 clientSite->ref = 1;
290 clientSite->reOle = reOle;
291 return clientSite;
292 }
293
294 static HRESULT WINAPI
295 IRichEditOle_fnGetClientSite(IRichEditOle *me,
296 LPOLECLIENTSITE *lplpolesite)
297 {
298 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
299
300 TRACE("%p,%p\n",This, lplpolesite);
301
302 if(!lplpolesite)
303 return E_INVALIDARG;
304 *lplpolesite = &This->clientSite->IOleClientSite_iface;
305 IOleClientSite_AddRef(*lplpolesite);
306 return S_OK;
307 }
308
309 static HRESULT WINAPI
310 IRichEditOle_fnGetClipboardData(IRichEditOle *me, CHARRANGE *lpchrg,
311 DWORD reco, LPDATAOBJECT *lplpdataobj)
312 {
313 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
314 ME_Cursor start;
315 int nChars;
316
317 TRACE("(%p,%p,%d)\n",This, lpchrg, reco);
318 if(!lplpdataobj)
319 return E_INVALIDARG;
320 if(!lpchrg) {
321 int nFrom, nTo, nStartCur = ME_GetSelectionOfs(This->editor, &nFrom, &nTo);
322 start = This->editor->pCursors[nStartCur];
323 nChars = nTo - nFrom;
324 } else {
325 ME_CursorFromCharOfs(This->editor, lpchrg->cpMin, &start);
326 nChars = lpchrg->cpMax - lpchrg->cpMin;
327 }
328 return ME_GetDataObject(This->editor, &start, nChars, lplpdataobj);
329 }
330
331 static LONG WINAPI IRichEditOle_fnGetLinkCount(IRichEditOle *me)
332 {
333 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
334 FIXME("stub %p\n",This);
335 return E_NOTIMPL;
336 }
337
338 static HRESULT WINAPI
339 IRichEditOle_fnGetObject(IRichEditOle *me, LONG iob,
340 REOBJECT *lpreobject, DWORD dwFlags)
341 {
342 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
343 FIXME("stub %p\n",This);
344 return E_NOTIMPL;
345 }
346
347 static LONG WINAPI
348 IRichEditOle_fnGetObjectCount(IRichEditOle *me)
349 {
350 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
351 FIXME("stub %p\n",This);
352 return 0;
353 }
354
355 static HRESULT WINAPI
356 IRichEditOle_fnHandsOffStorage(IRichEditOle *me, LONG iob)
357 {
358 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
359 FIXME("stub %p\n",This);
360 return E_NOTIMPL;
361 }
362
363 static HRESULT WINAPI
364 IRichEditOle_fnImportDataObject(IRichEditOle *me, LPDATAOBJECT lpdataobj,
365 CLIPFORMAT cf, HGLOBAL hMetaPict)
366 {
367 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
368 FIXME("stub %p\n",This);
369 return E_NOTIMPL;
370 }
371
372 static HRESULT WINAPI
373 IRichEditOle_fnInPlaceDeactivate(IRichEditOle *me)
374 {
375 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
376 FIXME("stub %p\n",This);
377 return E_NOTIMPL;
378 }
379
380 static HRESULT WINAPI
381 IRichEditOle_fnInsertObject(IRichEditOle *me, REOBJECT *reo)
382 {
383 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
384 TRACE("(%p,%p)\n", This, reo);
385
386 if (reo->cbStruct < sizeof(*reo)) return STG_E_INVALIDPARAMETER;
387
388 ME_InsertOLEFromCursor(This->editor, reo, 0);
389 ME_CommitUndo(This->editor);
390 ME_UpdateRepaint(This->editor, FALSE);
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 /* ITextRange interface */
449 static inline ITextRangeImpl *impl_from_ITextRange(ITextRange *iface)
450 {
451 return CONTAINING_RECORD(iface, ITextRangeImpl, ITextRange_iface);
452 }
453
454 static HRESULT WINAPI ITextRange_fnQueryInterface(ITextRange *me, REFIID riid, void **ppvObj)
455 {
456 *ppvObj = NULL;
457 if (IsEqualGUID(riid, &IID_IUnknown)
458 || IsEqualGUID(riid, &IID_IDispatch)
459 || IsEqualGUID(riid, &IID_ITextRange))
460 {
461 *ppvObj = me;
462 ITextRange_AddRef(me);
463 return S_OK;
464 }
465
466 return E_NOINTERFACE;
467 }
468
469 static ULONG WINAPI ITextRange_fnAddRef(ITextRange *me)
470 {
471 ITextRangeImpl *This = impl_from_ITextRange(me);
472 return InterlockedIncrement(&This->ref);
473 }
474
475 static ULONG WINAPI ITextRange_fnRelease(ITextRange *me)
476 {
477 ITextRangeImpl *This = impl_from_ITextRange(me);
478 ULONG ref = InterlockedDecrement(&This->ref);
479
480 TRACE ("%p ref=%u\n", This, ref);
481 if (ref == 0)
482 {
483 if (This->reOle)
484 {
485 list_remove(&This->entry);
486 This->reOle = NULL;
487 }
488 heap_free(This);
489 }
490 return ref;
491 }
492
493 static HRESULT WINAPI ITextRange_fnGetTypeInfoCount(ITextRange *me, UINT *pctinfo)
494 {
495 ITextRangeImpl *This = impl_from_ITextRange(me);
496 if (!This->reOle)
497 return CO_E_RELEASED;
498
499 FIXME("not implemented %p\n", This);
500 return E_NOTIMPL;
501 }
502
503 static HRESULT WINAPI ITextRange_fnGetTypeInfo(ITextRange *me, UINT iTInfo, LCID lcid,
504 ITypeInfo **ppTInfo)
505 {
506 ITextRangeImpl *This = impl_from_ITextRange(me);
507 if (!This->reOle)
508 return CO_E_RELEASED;
509
510 FIXME("not implemented %p\n", This);
511 return E_NOTIMPL;
512 }
513
514 static HRESULT WINAPI ITextRange_fnGetIDsOfNames(ITextRange *me, REFIID riid, LPOLESTR *rgszNames,
515 UINT cNames, LCID lcid, DISPID *rgDispId)
516 {
517 ITextRangeImpl *This = impl_from_ITextRange(me);
518 if (!This->reOle)
519 return CO_E_RELEASED;
520
521 FIXME("not implemented %p\n", This);
522 return E_NOTIMPL;
523 }
524
525 static HRESULT WINAPI ITextRange_fnInvoke(ITextRange *me, DISPID dispIdMember, REFIID riid,
526 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
527 VARIANT *pVarResult, EXCEPINFO *pExcepInfo,
528 UINT *puArgErr)
529 {
530 ITextRangeImpl *This = impl_from_ITextRange(me);
531 if (!This->reOle)
532 return CO_E_RELEASED;
533
534 FIXME("not implemented %p\n", This);
535 return E_NOTIMPL;
536 }
537
538 static HRESULT WINAPI ITextRange_fnGetText(ITextRange *me, BSTR *pbstr)
539 {
540 ITextRangeImpl *This = impl_from_ITextRange(me);
541 if (!This->reOle)
542 return CO_E_RELEASED;
543
544 FIXME("not implemented %p\n", This);
545 return E_NOTIMPL;
546 }
547
548 static HRESULT WINAPI ITextRange_fnSetText(ITextRange *me, BSTR bstr)
549 {
550 ITextRangeImpl *This = impl_from_ITextRange(me);
551 if (!This->reOle)
552 return CO_E_RELEASED;
553
554 FIXME("not implemented %p\n", This);
555 return E_NOTIMPL;
556 }
557
558 static HRESULT range_GetChar(ME_TextEditor *editor, ME_Cursor *cursor, LONG *pch)
559 {
560 WCHAR wch[2];
561
562 ME_GetTextW(editor, wch, 1, cursor, 1, FALSE, cursor->pRun->next->type == diTextEnd);
563 *pch = wch[0];
564
565 return S_OK;
566 }
567
568 static HRESULT WINAPI ITextRange_fnGetChar(ITextRange *me, LONG *pch)
569 {
570 ITextRangeImpl *This = impl_from_ITextRange(me);
571 ME_Cursor cursor;
572
573 if (!This->reOle)
574 return CO_E_RELEASED;
575 TRACE("%p\n", pch);
576 if (!pch)
577 return E_INVALIDARG;
578
579 ME_CursorFromCharOfs(This->reOle->editor, This->start, &cursor);
580 return range_GetChar(This->reOle->editor, &cursor, pch);
581 }
582
583 static HRESULT WINAPI ITextRange_fnSetChar(ITextRange *me, LONG ch)
584 {
585 ITextRangeImpl *This = impl_from_ITextRange(me);
586 if (!This->reOle)
587 return CO_E_RELEASED;
588
589 FIXME("not implemented %p\n", This);
590 return E_NOTIMPL;
591 }
592
593 static HRESULT CreateITextRange(IRichEditOleImpl *reOle, LONG start, LONG end, ITextRange** ppRange);
594
595 static HRESULT WINAPI ITextRange_fnGetDuplicate(ITextRange *me, ITextRange **ppRange)
596 {
597 ITextRangeImpl *This = impl_from_ITextRange(me);
598 if (!This->reOle)
599 return CO_E_RELEASED;
600
601 TRACE("%p %p\n", This, ppRange);
602 if (!ppRange)
603 return E_INVALIDARG;
604
605 return CreateITextRange(This->reOle, This->start, This->end, ppRange);
606 }
607
608 static HRESULT WINAPI ITextRange_fnGetFormattedText(ITextRange *me, ITextRange **ppRange)
609 {
610 ITextRangeImpl *This = impl_from_ITextRange(me);
611 if (!This->reOle)
612 return CO_E_RELEASED;
613
614 FIXME("not implemented %p\n", This);
615 return E_NOTIMPL;
616 }
617
618 static HRESULT WINAPI ITextRange_fnSetFormattedText(ITextRange *me, ITextRange *pRange)
619 {
620 ITextRangeImpl *This = impl_from_ITextRange(me);
621 if (!This->reOle)
622 return CO_E_RELEASED;
623
624 FIXME("not implemented %p\n", This);
625 return E_NOTIMPL;
626 }
627
628 static HRESULT WINAPI ITextRange_fnGetStart(ITextRange *me, LONG *pcpFirst)
629 {
630 ITextRangeImpl *This = impl_from_ITextRange(me);
631 if (!This->reOle)
632 return CO_E_RELEASED;
633
634 if (!pcpFirst)
635 return E_INVALIDARG;
636 *pcpFirst = This->start;
637 TRACE("%d\n", *pcpFirst);
638 return S_OK;
639 }
640
641 static HRESULT WINAPI ITextRange_fnSetStart(ITextRange *me, LONG cpFirst)
642 {
643 ITextRangeImpl *This = impl_from_ITextRange(me);
644 if (!This->reOle)
645 return CO_E_RELEASED;
646
647 FIXME("not implemented %p\n", This);
648 return E_NOTIMPL;
649 }
650
651 static HRESULT WINAPI ITextRange_fnGetEnd(ITextRange *me, LONG *pcpLim)
652 {
653 ITextRangeImpl *This = impl_from_ITextRange(me);
654 if (!This->reOle)
655 return CO_E_RELEASED;
656
657 if (!pcpLim)
658 return E_INVALIDARG;
659 *pcpLim = This->end;
660 TRACE("%d\n", *pcpLim);
661 return S_OK;
662 }
663
664 static HRESULT WINAPI ITextRange_fnSetEnd(ITextRange *me, LONG cpLim)
665 {
666 ITextRangeImpl *This = impl_from_ITextRange(me);
667 if (!This->reOle)
668 return CO_E_RELEASED;
669
670 FIXME("not implemented %p\n", This);
671 return E_NOTIMPL;
672 }
673
674 static HRESULT WINAPI ITextRange_fnGetFont(ITextRange *me, ITextFont **pFont)
675 {
676 ITextRangeImpl *This = impl_from_ITextRange(me);
677 if (!This->reOle)
678 return CO_E_RELEASED;
679
680 FIXME("not implemented %p\n", This);
681 return E_NOTIMPL;
682 }
683
684 static HRESULT WINAPI ITextRange_fnSetFont(ITextRange *me, ITextFont *pFont)
685 {
686 ITextRangeImpl *This = impl_from_ITextRange(me);
687 if (!This->reOle)
688 return CO_E_RELEASED;
689
690 FIXME("not implemented %p\n", This);
691 return E_NOTIMPL;
692 }
693
694 static HRESULT WINAPI ITextRange_fnGetPara(ITextRange *me, ITextPara **ppPara)
695 {
696 ITextRangeImpl *This = impl_from_ITextRange(me);
697 if (!This->reOle)
698 return CO_E_RELEASED;
699
700 FIXME("not implemented %p\n", This);
701 return E_NOTIMPL;
702 }
703
704 static HRESULT WINAPI ITextRange_fnSetPara(ITextRange *me, ITextPara *pPara)
705 {
706 ITextRangeImpl *This = impl_from_ITextRange(me);
707 if (!This->reOle)
708 return CO_E_RELEASED;
709
710 FIXME("not implemented %p\n", This);
711 return E_NOTIMPL;
712 }
713
714 static HRESULT WINAPI ITextRange_fnGetStoryLength(ITextRange *me, LONG *pcch)
715 {
716 ITextRangeImpl *This = impl_from_ITextRange(me);
717 if (!This->reOle)
718 return CO_E_RELEASED;
719
720 FIXME("not implemented %p\n", This);
721 return E_NOTIMPL;
722 }
723
724 static HRESULT WINAPI ITextRange_fnGetStoryType(ITextRange *me, LONG *pValue)
725 {
726 ITextRangeImpl *This = impl_from_ITextRange(me);
727 if (!This->reOle)
728 return CO_E_RELEASED;
729
730 FIXME("not implemented %p\n", This);
731 return E_NOTIMPL;
732 }
733
734 static HRESULT range_Collapse(LONG bStart, LONG *start, LONG *end)
735 {
736 if (*end == *start)
737 return S_FALSE;
738
739 if (bStart == tomEnd || bStart == tomFalse)
740 *start = *end;
741 else
742 *end = *start;
743 return S_OK;
744 }
745
746 static HRESULT WINAPI ITextRange_fnCollapse(ITextRange *me, LONG bStart)
747 {
748 ITextRangeImpl *This = impl_from_ITextRange(me);
749 if (!This->reOle)
750 return CO_E_RELEASED;
751
752 return range_Collapse(bStart, &This->start, &This->end);
753 }
754
755 static HRESULT WINAPI ITextRange_fnExpand(ITextRange *me, LONG Unit, LONG *pDelta)
756 {
757 ITextRangeImpl *This = impl_from_ITextRange(me);
758 if (!This->reOle)
759 return CO_E_RELEASED;
760
761 FIXME("not implemented %p\n", This);
762 return E_NOTIMPL;
763 }
764
765 static HRESULT WINAPI ITextRange_fnGetIndex(ITextRange *me, LONG Unit, LONG *pIndex)
766 {
767 ITextRangeImpl *This = impl_from_ITextRange(me);
768 if (!This->reOle)
769 return CO_E_RELEASED;
770
771 FIXME("not implemented %p\n", This);
772 return E_NOTIMPL;
773 }
774
775 static HRESULT WINAPI ITextRange_fnSetIndex(ITextRange *me, LONG Unit, LONG Index,
776 LONG Extend)
777 {
778 ITextRangeImpl *This = impl_from_ITextRange(me);
779 if (!This->reOle)
780 return CO_E_RELEASED;
781
782 FIXME("not implemented %p\n", This);
783 return E_NOTIMPL;
784 }
785
786 static HRESULT WINAPI ITextRange_fnSetRange(ITextRange *me, LONG cpActive, LONG cpOther)
787 {
788 ITextRangeImpl *This = impl_from_ITextRange(me);
789 if (!This->reOle)
790 return CO_E_RELEASED;
791
792 FIXME("not implemented %p\n", This);
793 return E_NOTIMPL;
794 }
795
796 static HRESULT WINAPI ITextRange_fnInRange(ITextRange *me, ITextRange *pRange, LONG *pb)
797 {
798 ITextRangeImpl *This = impl_from_ITextRange(me);
799 if (!This->reOle)
800 return CO_E_RELEASED;
801
802 FIXME("not implemented %p\n", This);
803 return E_NOTIMPL;
804 }
805
806 static HRESULT WINAPI ITextRange_fnInStory(ITextRange *me, ITextRange *pRange, LONG *pb)
807 {
808 ITextRangeImpl *This = impl_from_ITextRange(me);
809 if (!This->reOle)
810 return CO_E_RELEASED;
811
812 FIXME("not implemented %p\n", This);
813 return E_NOTIMPL;
814 }
815
816 static HRESULT WINAPI ITextRange_fnIsEqual(ITextRange *me, ITextRange *pRange, LONG *pb)
817 {
818 ITextRangeImpl *This = impl_from_ITextRange(me);
819 if (!This->reOle)
820 return CO_E_RELEASED;
821
822 FIXME("not implemented %p\n", This);
823 return E_NOTIMPL;
824 }
825
826 static HRESULT WINAPI ITextRange_fnSelect(ITextRange *me)
827 {
828 ITextRangeImpl *This = impl_from_ITextRange(me);
829 if (!This->reOle)
830 return CO_E_RELEASED;
831
832 FIXME("not implemented %p\n", This);
833 return E_NOTIMPL;
834 }
835
836 static HRESULT WINAPI ITextRange_fnStartOf(ITextRange *me, LONG Unit, LONG Extend,
837 LONG *pDelta)
838 {
839 ITextRangeImpl *This = impl_from_ITextRange(me);
840 if (!This->reOle)
841 return CO_E_RELEASED;
842
843 FIXME("not implemented %p\n", This);
844 return E_NOTIMPL;
845 }
846
847 static HRESULT WINAPI ITextRange_fnEndOf(ITextRange *me, LONG Unit, LONG Extend,
848 LONG *pDelta)
849 {
850 ITextRangeImpl *This = impl_from_ITextRange(me);
851 if (!This->reOle)
852 return CO_E_RELEASED;
853
854 FIXME("not implemented %p\n", This);
855 return E_NOTIMPL;
856 }
857
858 static HRESULT WINAPI ITextRange_fnMove(ITextRange *me, LONG Unit, LONG Count, LONG *pDelta)
859 {
860 ITextRangeImpl *This = impl_from_ITextRange(me);
861 if (!This->reOle)
862 return CO_E_RELEASED;
863
864 FIXME("not implemented %p\n", This);
865 return E_NOTIMPL;
866 }
867
868 static HRESULT WINAPI ITextRange_fnMoveStart(ITextRange *me, LONG Unit, LONG Count,
869 LONG *pDelta)
870 {
871 ITextRangeImpl *This = impl_from_ITextRange(me);
872 if (!This->reOle)
873 return CO_E_RELEASED;
874
875 FIXME("not implemented %p\n", This);
876 return E_NOTIMPL;
877 }
878
879 static HRESULT WINAPI ITextRange_fnMoveEnd(ITextRange *me, LONG Unit, LONG Count,
880 LONG *pDelta)
881 {
882 ITextRangeImpl *This = impl_from_ITextRange(me);
883 if (!This->reOle)
884 return CO_E_RELEASED;
885
886 FIXME("not implemented %p\n", This);
887 return E_NOTIMPL;
888 }
889
890 static HRESULT WINAPI ITextRange_fnMoveWhile(ITextRange *me, VARIANT *Cset, LONG Count,
891 LONG *pDelta)
892 {
893 ITextRangeImpl *This = impl_from_ITextRange(me);
894 if (!This->reOle)
895 return CO_E_RELEASED;
896
897 FIXME("not implemented %p\n", This);
898 return E_NOTIMPL;
899 }
900
901 static HRESULT WINAPI ITextRange_fnMoveStartWhile(ITextRange *me, VARIANT *Cset, LONG Count,
902 LONG *pDelta)
903 {
904 ITextRangeImpl *This = impl_from_ITextRange(me);
905 if (!This->reOle)
906 return CO_E_RELEASED;
907
908 FIXME("not implemented %p\n", This);
909 return E_NOTIMPL;
910 }
911
912 static HRESULT WINAPI ITextRange_fnMoveEndWhile(ITextRange *me, VARIANT *Cset, LONG Count,
913 LONG *pDelta)
914 {
915 ITextRangeImpl *This = impl_from_ITextRange(me);
916 if (!This->reOle)
917 return CO_E_RELEASED;
918
919 FIXME("not implemented %p\n", This);
920 return E_NOTIMPL;
921 }
922
923 static HRESULT WINAPI ITextRange_fnMoveUntil(ITextRange *me, VARIANT *Cset, LONG Count,
924 LONG *pDelta)
925 {
926 ITextRangeImpl *This = impl_from_ITextRange(me);
927 if (!This->reOle)
928 return CO_E_RELEASED;
929
930 FIXME("not implemented %p\n", This);
931 return E_NOTIMPL;
932 }
933
934 static HRESULT WINAPI ITextRange_fnMoveStartUntil(ITextRange *me, VARIANT *Cset, LONG Count,
935 LONG *pDelta)
936 {
937 ITextRangeImpl *This = impl_from_ITextRange(me);
938 if (!This->reOle)
939 return CO_E_RELEASED;
940
941 FIXME("not implemented %p\n", This);
942 return E_NOTIMPL;
943 }
944
945 static HRESULT WINAPI ITextRange_fnMoveEndUntil(ITextRange *me, VARIANT *Cset, LONG Count,
946 LONG *pDelta)
947 {
948 ITextRangeImpl *This = impl_from_ITextRange(me);
949 if (!This->reOle)
950 return CO_E_RELEASED;
951
952 FIXME("not implemented %p\n", This);
953 return E_NOTIMPL;
954 }
955
956 static HRESULT WINAPI ITextRange_fnFindText(ITextRange *me, BSTR bstr, LONG cch, LONG Flags,
957 LONG *pLength)
958 {
959 ITextRangeImpl *This = impl_from_ITextRange(me);
960 if (!This->reOle)
961 return CO_E_RELEASED;
962
963 FIXME("not implemented %p\n", This);
964 return E_NOTIMPL;
965 }
966
967 static HRESULT WINAPI ITextRange_fnFindTextStart(ITextRange *me, BSTR bstr, LONG cch,
968 LONG Flags, LONG *pLength)
969 {
970 ITextRangeImpl *This = impl_from_ITextRange(me);
971 if (!This->reOle)
972 return CO_E_RELEASED;
973
974 FIXME("not implemented %p\n", This);
975 return E_NOTIMPL;
976 }
977
978 static HRESULT WINAPI ITextRange_fnFindTextEnd(ITextRange *me, BSTR bstr, LONG cch,
979 LONG Flags, LONG *pLength)
980 {
981 ITextRangeImpl *This = impl_from_ITextRange(me);
982 if (!This->reOle)
983 return CO_E_RELEASED;
984
985 FIXME("not implemented %p\n", This);
986 return E_NOTIMPL;
987 }
988
989 static HRESULT WINAPI ITextRange_fnDelete(ITextRange *me, LONG Unit, LONG Count,
990 LONG *pDelta)
991 {
992 ITextRangeImpl *This = impl_from_ITextRange(me);
993 if (!This->reOle)
994 return CO_E_RELEASED;
995
996 FIXME("not implemented %p\n", This);
997 return E_NOTIMPL;
998 }
999
1000 static HRESULT WINAPI ITextRange_fnCut(ITextRange *me, VARIANT *pVar)
1001 {
1002 ITextRangeImpl *This = impl_from_ITextRange(me);
1003 if (!This->reOle)
1004 return CO_E_RELEASED;
1005
1006 FIXME("not implemented %p\n", This);
1007 return E_NOTIMPL;
1008 }
1009
1010 static HRESULT WINAPI ITextRange_fnCopy(ITextRange *me, VARIANT *pVar)
1011 {
1012 ITextRangeImpl *This = impl_from_ITextRange(me);
1013 if (!This->reOle)
1014 return CO_E_RELEASED;
1015
1016 FIXME("not implemented %p\n", This);
1017 return E_NOTIMPL;
1018 }
1019
1020 static HRESULT WINAPI ITextRange_fnPaste(ITextRange *me, VARIANT *pVar, LONG Format)
1021 {
1022 ITextRangeImpl *This = impl_from_ITextRange(me);
1023 if (!This->reOle)
1024 return CO_E_RELEASED;
1025
1026 FIXME("not implemented %p\n", This);
1027 return E_NOTIMPL;
1028 }
1029
1030 static HRESULT WINAPI ITextRange_fnCanPaste(ITextRange *me, VARIANT *pVar, LONG Format,
1031 LONG *pb)
1032 {
1033 ITextRangeImpl *This = impl_from_ITextRange(me);
1034 if (!This->reOle)
1035 return CO_E_RELEASED;
1036
1037 FIXME("not implemented %p\n", This);
1038 return E_NOTIMPL;
1039 }
1040
1041 static HRESULT WINAPI ITextRange_fnCanEdit(ITextRange *me, LONG *pb)
1042 {
1043 ITextRangeImpl *This = impl_from_ITextRange(me);
1044 if (!This->reOle)
1045 return CO_E_RELEASED;
1046
1047 FIXME("not implemented %p\n", This);
1048 return E_NOTIMPL;
1049 }
1050
1051 static HRESULT WINAPI ITextRange_fnChangeCase(ITextRange *me, LONG Type)
1052 {
1053 ITextRangeImpl *This = impl_from_ITextRange(me);
1054 if (!This->reOle)
1055 return CO_E_RELEASED;
1056
1057 FIXME("not implemented %p\n", This);
1058 return E_NOTIMPL;
1059 }
1060
1061 static HRESULT WINAPI ITextRange_fnGetPoint(ITextRange *me, LONG Type, LONG *cx, LONG *cy)
1062 {
1063 ITextRangeImpl *This = impl_from_ITextRange(me);
1064 if (!This->reOle)
1065 return CO_E_RELEASED;
1066
1067 FIXME("not implemented %p\n", This);
1068 return E_NOTIMPL;
1069 }
1070
1071 static HRESULT WINAPI ITextRange_fnSetPoint(ITextRange *me, LONG x, LONG y, LONG Type,
1072 LONG Extend)
1073 {
1074 ITextRangeImpl *This = impl_from_ITextRange(me);
1075 if (!This->reOle)
1076 return CO_E_RELEASED;
1077
1078 FIXME("not implemented %p\n", This);
1079 return E_NOTIMPL;
1080 }
1081
1082 static HRESULT WINAPI ITextRange_fnScrollIntoView(ITextRange *me, LONG Value)
1083 {
1084 ITextRangeImpl *This = impl_from_ITextRange(me);
1085 if (!This->reOle)
1086 return CO_E_RELEASED;
1087
1088 FIXME("not implemented %p\n", This);
1089 return E_NOTIMPL;
1090 }
1091
1092 static HRESULT WINAPI ITextRange_fnGetEmbeddedObject(ITextRange *me, IUnknown **ppv)
1093 {
1094 ITextRangeImpl *This = impl_from_ITextRange(me);
1095 if (!This->reOle)
1096 return CO_E_RELEASED;
1097
1098 FIXME("not implemented %p\n", This);
1099 return E_NOTIMPL;
1100 }
1101
1102 static const ITextRangeVtbl trvt = {
1103 ITextRange_fnQueryInterface,
1104 ITextRange_fnAddRef,
1105 ITextRange_fnRelease,
1106 ITextRange_fnGetTypeInfoCount,
1107 ITextRange_fnGetTypeInfo,
1108 ITextRange_fnGetIDsOfNames,
1109 ITextRange_fnInvoke,
1110 ITextRange_fnGetText,
1111 ITextRange_fnSetText,
1112 ITextRange_fnGetChar,
1113 ITextRange_fnSetChar,
1114 ITextRange_fnGetDuplicate,
1115 ITextRange_fnGetFormattedText,
1116 ITextRange_fnSetFormattedText,
1117 ITextRange_fnGetStart,
1118 ITextRange_fnSetStart,
1119 ITextRange_fnGetEnd,
1120 ITextRange_fnSetEnd,
1121 ITextRange_fnGetFont,
1122 ITextRange_fnSetFont,
1123 ITextRange_fnGetPara,
1124 ITextRange_fnSetPara,
1125 ITextRange_fnGetStoryLength,
1126 ITextRange_fnGetStoryType,
1127 ITextRange_fnCollapse,
1128 ITextRange_fnExpand,
1129 ITextRange_fnGetIndex,
1130 ITextRange_fnSetIndex,
1131 ITextRange_fnSetRange,
1132 ITextRange_fnInRange,
1133 ITextRange_fnInStory,
1134 ITextRange_fnIsEqual,
1135 ITextRange_fnSelect,
1136 ITextRange_fnStartOf,
1137 ITextRange_fnEndOf,
1138 ITextRange_fnMove,
1139 ITextRange_fnMoveStart,
1140 ITextRange_fnMoveEnd,
1141 ITextRange_fnMoveWhile,
1142 ITextRange_fnMoveStartWhile,
1143 ITextRange_fnMoveEndWhile,
1144 ITextRange_fnMoveUntil,
1145 ITextRange_fnMoveStartUntil,
1146 ITextRange_fnMoveEndUntil,
1147 ITextRange_fnFindText,
1148 ITextRange_fnFindTextStart,
1149 ITextRange_fnFindTextEnd,
1150 ITextRange_fnDelete,
1151 ITextRange_fnCut,
1152 ITextRange_fnCopy,
1153 ITextRange_fnPaste,
1154 ITextRange_fnCanPaste,
1155 ITextRange_fnCanEdit,
1156 ITextRange_fnChangeCase,
1157 ITextRange_fnGetPoint,
1158 ITextRange_fnSetPoint,
1159 ITextRange_fnScrollIntoView,
1160 ITextRange_fnGetEmbeddedObject
1161 };
1162 /* ITextRange interface */
1163
1164 static HRESULT WINAPI
1165 ITextDocument_fnQueryInterface(ITextDocument* me, REFIID riid,
1166 void** ppvObject)
1167 {
1168 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1169 return IRichEditOle_QueryInterface(&This->IRichEditOle_iface, riid, ppvObject);
1170 }
1171
1172 static ULONG WINAPI
1173 ITextDocument_fnAddRef(ITextDocument* me)
1174 {
1175 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1176 return IRichEditOle_AddRef(&This->IRichEditOle_iface);
1177 }
1178
1179 static ULONG WINAPI
1180 ITextDocument_fnRelease(ITextDocument* me)
1181 {
1182 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1183 return IRichEditOle_Release(&This->IRichEditOle_iface);
1184 }
1185
1186 static HRESULT WINAPI
1187 ITextDocument_fnGetTypeInfoCount(ITextDocument* me,
1188 UINT* pctinfo)
1189 {
1190 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1191 FIXME("stub %p\n",This);
1192 return E_NOTIMPL;
1193 }
1194
1195 static HRESULT WINAPI
1196 ITextDocument_fnGetTypeInfo(ITextDocument* me, UINT iTInfo, LCID lcid,
1197 ITypeInfo** ppTInfo)
1198 {
1199 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1200 FIXME("stub %p\n",This);
1201 return E_NOTIMPL;
1202 }
1203
1204 static HRESULT WINAPI
1205 ITextDocument_fnGetIDsOfNames(ITextDocument* me, REFIID riid,
1206 LPOLESTR* rgszNames, UINT cNames, LCID lcid, DISPID* rgDispId)
1207 {
1208 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1209 FIXME("stub %p\n",This);
1210 return E_NOTIMPL;
1211 }
1212
1213 static HRESULT WINAPI
1214 ITextDocument_fnInvoke(ITextDocument* me, DISPID dispIdMember,
1215 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS* pDispParams,
1216 VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr)
1217 {
1218 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1219 FIXME("stub %p\n",This);
1220 return E_NOTIMPL;
1221 }
1222
1223 static HRESULT WINAPI
1224 ITextDocument_fnGetName(ITextDocument* me, BSTR* pName)
1225 {
1226 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1227 FIXME("stub %p\n",This);
1228 return E_NOTIMPL;
1229 }
1230
1231 static HRESULT WINAPI
1232 ITextDocument_fnGetSelection(ITextDocument* me, ITextSelection** ppSel)
1233 {
1234 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1235 TRACE("(%p)\n", me);
1236
1237 if(!ppSel)
1238 return E_INVALIDARG;
1239 *ppSel = &This->txtSel->ITextSelection_iface;
1240 ITextSelection_AddRef(*ppSel);
1241 return S_OK;
1242 }
1243
1244 static HRESULT WINAPI
1245 ITextDocument_fnGetStoryCount(ITextDocument* me, LONG* pCount)
1246 {
1247 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1248 FIXME("stub %p\n",This);
1249 return E_NOTIMPL;
1250 }
1251
1252 static HRESULT WINAPI
1253 ITextDocument_fnGetStoryRanges(ITextDocument* me,
1254 ITextStoryRanges** ppStories)
1255 {
1256 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1257 FIXME("stub %p\n",This);
1258 return E_NOTIMPL;
1259 }
1260
1261 static HRESULT WINAPI
1262 ITextDocument_fnGetSaved(ITextDocument* me, LONG* pValue)
1263 {
1264 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1265 FIXME("stub %p\n",This);
1266 return E_NOTIMPL;
1267 }
1268
1269 static HRESULT WINAPI
1270 ITextDocument_fnSetSaved(ITextDocument* me, LONG Value)
1271 {
1272 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1273 FIXME("stub %p\n",This);
1274 return E_NOTIMPL;
1275 }
1276
1277 static HRESULT WINAPI
1278 ITextDocument_fnGetDefaultTabStop(ITextDocument* me, float* pValue)
1279 {
1280 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1281 FIXME("stub %p\n",This);
1282 return E_NOTIMPL;
1283 }
1284
1285 static HRESULT WINAPI
1286 ITextDocument_fnSetDefaultTabStop(ITextDocument* me, float Value)
1287 {
1288 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1289 FIXME("stub %p\n",This);
1290 return E_NOTIMPL;
1291 }
1292
1293 static HRESULT WINAPI
1294 ITextDocument_fnNew(ITextDocument* me)
1295 {
1296 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1297 FIXME("stub %p\n",This);
1298 return E_NOTIMPL;
1299 }
1300
1301 static HRESULT WINAPI
1302 ITextDocument_fnOpen(ITextDocument* me, VARIANT* pVar, LONG Flags,
1303 LONG CodePage)
1304 {
1305 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1306 FIXME("stub %p\n",This);
1307 return E_NOTIMPL;
1308 }
1309
1310 static HRESULT WINAPI
1311 ITextDocument_fnSave(ITextDocument* me, VARIANT* pVar, LONG Flags,
1312 LONG CodePage)
1313 {
1314 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1315 FIXME("stub %p\n",This);
1316 return E_NOTIMPL;
1317 }
1318
1319 static HRESULT WINAPI
1320 ITextDocument_fnFreeze(ITextDocument* me, LONG* pCount)
1321 {
1322 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1323 FIXME("stub %p\n",This);
1324 return E_NOTIMPL;
1325 }
1326
1327 static HRESULT WINAPI
1328 ITextDocument_fnUnfreeze(ITextDocument* me, LONG* pCount)
1329 {
1330 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1331 FIXME("stub %p\n",This);
1332 return E_NOTIMPL;
1333 }
1334
1335 static HRESULT WINAPI
1336 ITextDocument_fnBeginEditCollection(ITextDocument* me)
1337 {
1338 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1339 FIXME("stub %p\n",This);
1340 return E_NOTIMPL;
1341 }
1342
1343 static HRESULT WINAPI
1344 ITextDocument_fnEndEditCollection(ITextDocument* me)
1345 {
1346 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1347 FIXME("stub %p\n",This);
1348 return E_NOTIMPL;
1349 }
1350
1351 static HRESULT WINAPI
1352 ITextDocument_fnUndo(ITextDocument* me, LONG Count, LONG* prop)
1353 {
1354 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1355 FIXME("stub %p\n",This);
1356 return E_NOTIMPL;
1357 }
1358
1359 static HRESULT WINAPI
1360 ITextDocument_fnRedo(ITextDocument* me, LONG Count, LONG* prop)
1361 {
1362 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1363 FIXME("stub %p\n",This);
1364 return E_NOTIMPL;
1365 }
1366
1367 static HRESULT CreateITextRange(IRichEditOleImpl *reOle, LONG start, LONG end, ITextRange** ppRange)
1368 {
1369 ITextRangeImpl *txtRge = heap_alloc(sizeof(ITextRangeImpl));
1370
1371 if (!txtRge)
1372 return E_OUTOFMEMORY;
1373 txtRge->ITextRange_iface.lpVtbl = &trvt;
1374 txtRge->ref = 1;
1375 txtRge->reOle = reOle;
1376 txtRge->start = start;
1377 txtRge->end = end;
1378 list_add_head(&reOle->rangelist, &txtRge->entry);
1379 *ppRange = &txtRge->ITextRange_iface;
1380 return S_OK;
1381 }
1382
1383 static HRESULT WINAPI
1384 ITextDocument_fnRange(ITextDocument* me, LONG cp1, LONG cp2,
1385 ITextRange** ppRange)
1386 {
1387 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1388 const int len = ME_GetTextLength(This->editor) + 1;
1389
1390 TRACE("%p %p %d %d\n", This, ppRange, cp1, cp2);
1391 if (!ppRange)
1392 return E_INVALIDARG;
1393
1394 cp1 = max(cp1, 0);
1395 cp2 = max(cp2, 0);
1396 cp1 = min(cp1, len);
1397 cp2 = min(cp2, len);
1398 if (cp1 > cp2)
1399 {
1400 LONG tmp;
1401 tmp = cp1;
1402 cp1 = cp2;
1403 cp2 = tmp;
1404 }
1405 if (cp1 == len)
1406 cp1 = cp2 = len - 1;
1407
1408 return CreateITextRange(This, cp1, cp2, ppRange);
1409 }
1410
1411 static HRESULT WINAPI
1412 ITextDocument_fnRangeFromPoint(ITextDocument* me, LONG x, LONG y,
1413 ITextRange** ppRange)
1414 {
1415 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1416 FIXME("stub %p\n",This);
1417 return E_NOTIMPL;
1418 }
1419
1420 static const ITextDocumentVtbl tdvt = {
1421 ITextDocument_fnQueryInterface,
1422 ITextDocument_fnAddRef,
1423 ITextDocument_fnRelease,
1424 ITextDocument_fnGetTypeInfoCount,
1425 ITextDocument_fnGetTypeInfo,
1426 ITextDocument_fnGetIDsOfNames,
1427 ITextDocument_fnInvoke,
1428 ITextDocument_fnGetName,
1429 ITextDocument_fnGetSelection,
1430 ITextDocument_fnGetStoryCount,
1431 ITextDocument_fnGetStoryRanges,
1432 ITextDocument_fnGetSaved,
1433 ITextDocument_fnSetSaved,
1434 ITextDocument_fnGetDefaultTabStop,
1435 ITextDocument_fnSetDefaultTabStop,
1436 ITextDocument_fnNew,
1437 ITextDocument_fnOpen,
1438 ITextDocument_fnSave,
1439 ITextDocument_fnFreeze,
1440 ITextDocument_fnUnfreeze,
1441 ITextDocument_fnBeginEditCollection,
1442 ITextDocument_fnEndEditCollection,
1443 ITextDocument_fnUndo,
1444 ITextDocument_fnRedo,
1445 ITextDocument_fnRange,
1446 ITextDocument_fnRangeFromPoint
1447 };
1448
1449 static inline ITextSelectionImpl *impl_from_ITextSelection(ITextSelection *iface)
1450 {
1451 return CONTAINING_RECORD(iface, ITextSelectionImpl, ITextSelection_iface);
1452 }
1453
1454 static HRESULT WINAPI ITextSelection_fnQueryInterface(
1455 ITextSelection *me,
1456 REFIID riid,
1457 void **ppvObj)
1458 {
1459 *ppvObj = NULL;
1460 if (IsEqualGUID(riid, &IID_IUnknown)
1461 || IsEqualGUID(riid, &IID_IDispatch)
1462 || IsEqualGUID(riid, &IID_ITextRange)
1463 || IsEqualGUID(riid, &IID_ITextSelection))
1464 {
1465 *ppvObj = me;
1466 ITextSelection_AddRef(me);
1467 return S_OK;
1468 }
1469
1470 return E_NOINTERFACE;
1471 }
1472
1473 static ULONG WINAPI ITextSelection_fnAddRef(ITextSelection *me)
1474 {
1475 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1476 return InterlockedIncrement(&This->ref);
1477 }
1478
1479 static ULONG WINAPI ITextSelection_fnRelease(ITextSelection *me)
1480 {
1481 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1482 ULONG ref = InterlockedDecrement(&This->ref);
1483 if (ref == 0)
1484 heap_free(This);
1485 return ref;
1486 }
1487
1488 static HRESULT WINAPI ITextSelection_fnGetTypeInfoCount(ITextSelection *me, UINT *pctinfo)
1489 {
1490 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1491 if (!This->reOle)
1492 return CO_E_RELEASED;
1493
1494 FIXME("not implemented\n");
1495 return E_NOTIMPL;
1496 }
1497
1498 static HRESULT WINAPI ITextSelection_fnGetTypeInfo(ITextSelection *me, UINT iTInfo, LCID lcid,
1499 ITypeInfo **ppTInfo)
1500 {
1501 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1502 if (!This->reOle)
1503 return CO_E_RELEASED;
1504
1505 FIXME("not implemented\n");
1506 return E_NOTIMPL;
1507 }
1508
1509 static HRESULT WINAPI ITextSelection_fnGetIDsOfNames(ITextSelection *me, REFIID riid,
1510 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
1511 {
1512 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1513 if (!This->reOle)
1514 return CO_E_RELEASED;
1515
1516 FIXME("not implemented\n");
1517 return E_NOTIMPL;
1518 }
1519
1520 static HRESULT WINAPI ITextSelection_fnInvoke(
1521 ITextSelection *me,
1522 DISPID dispIdMember,
1523 REFIID riid,
1524 LCID lcid,
1525 WORD wFlags,
1526 DISPPARAMS *pDispParams,
1527 VARIANT *pVarResult,
1528 EXCEPINFO *pExcepInfo,
1529 UINT *puArgErr)
1530 {
1531 FIXME("not implemented\n");
1532 return E_NOTIMPL;
1533 }
1534
1535 /*** ITextRange methods ***/
1536 static HRESULT WINAPI ITextSelection_fnGetText(ITextSelection *me, BSTR *pbstr)
1537 {
1538 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1539 ME_Cursor *start = NULL, *end = NULL;
1540 int nChars, endOfs;
1541 BOOL bEOP;
1542
1543 if (!This->reOle)
1544 return CO_E_RELEASED;
1545 TRACE("%p\n", pbstr);
1546 if (!pbstr)
1547 return E_INVALIDARG;
1548
1549 ME_GetSelection(This->reOle->editor, &start, &end);
1550 endOfs = ME_GetCursorOfs(end);
1551 nChars = endOfs - ME_GetCursorOfs(start);
1552 if (!nChars)
1553 {
1554 *pbstr = NULL;
1555 return S_OK;
1556 }
1557
1558 *pbstr = SysAllocStringLen(NULL, nChars);
1559 if (!*pbstr)
1560 return E_OUTOFMEMORY;
1561
1562 bEOP = (end->pRun->next->type == diTextEnd && endOfs > ME_GetTextLength(This->reOle->editor));
1563 ME_GetTextW(This->reOle->editor, *pbstr, nChars, start, nChars, FALSE, bEOP);
1564 TRACE("%s\n", wine_dbgstr_w(*pbstr));
1565
1566 return S_OK;
1567 }
1568
1569 static HRESULT WINAPI ITextSelection_fnSetText(ITextSelection *me, BSTR bstr)
1570 {
1571 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1572 if (!This->reOle)
1573 return CO_E_RELEASED;
1574
1575 FIXME("not implemented\n");
1576 return E_NOTIMPL;
1577 }
1578
1579 static HRESULT WINAPI ITextSelection_fnGetChar(ITextSelection *me, LONG *pch)
1580 {
1581 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1582 ME_Cursor *start = NULL, *end = NULL;
1583
1584 if (!This->reOle)
1585 return CO_E_RELEASED;
1586 TRACE("%p\n", pch);
1587 if (!pch)
1588 return E_INVALIDARG;
1589
1590 ME_GetSelection(This->reOle->editor, &start, &end);
1591 return range_GetChar(This->reOle->editor, start, pch);
1592 }
1593
1594 static HRESULT WINAPI ITextSelection_fnSetChar(ITextSelection *me, LONG ch)
1595 {
1596 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1597 if (!This->reOle)
1598 return CO_E_RELEASED;
1599
1600 FIXME("not implemented\n");
1601 return E_NOTIMPL;
1602 }
1603
1604 static HRESULT WINAPI ITextSelection_fnGetDuplicate(ITextSelection *me, ITextRange **ppRange)
1605 {
1606 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1607 if (!This->reOle)
1608 return CO_E_RELEASED;
1609
1610 FIXME("not implemented\n");
1611 return E_NOTIMPL;
1612 }
1613
1614 static HRESULT WINAPI ITextSelection_fnGetFormattedText(ITextSelection *me, ITextRange **ppRange)
1615 {
1616 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1617 if (!This->reOle)
1618 return CO_E_RELEASED;
1619
1620 FIXME("not implemented\n");
1621 return E_NOTIMPL;
1622 }
1623
1624 static HRESULT WINAPI ITextSelection_fnSetFormattedText(ITextSelection *me, ITextRange *pRange)
1625 {
1626 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1627 if (!This->reOle)
1628 return CO_E_RELEASED;
1629
1630 FIXME("not implemented\n");
1631 return E_NOTIMPL;
1632 }
1633
1634 static HRESULT WINAPI ITextSelection_fnGetStart(ITextSelection *me, LONG *pcpFirst)
1635 {
1636 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1637 LONG lim;
1638 if (!This->reOle)
1639 return CO_E_RELEASED;
1640
1641 if (!pcpFirst)
1642 return E_INVALIDARG;
1643 ME_GetSelectionOfs(This->reOle->editor, pcpFirst, &lim);
1644 TRACE("%d\n", *pcpFirst);
1645 return S_OK;
1646 }
1647
1648 static HRESULT WINAPI ITextSelection_fnSetStart(ITextSelection *me, LONG cpFirst)
1649 {
1650 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1651 if (!This->reOle)
1652 return CO_E_RELEASED;
1653
1654 FIXME("not implemented\n");
1655 return E_NOTIMPL;
1656 }
1657
1658 static HRESULT WINAPI ITextSelection_fnGetEnd(ITextSelection *me, LONG *pcpLim)
1659 {
1660 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1661 LONG first;
1662 if (!This->reOle)
1663 return CO_E_RELEASED;
1664
1665 if (!pcpLim)
1666 return E_INVALIDARG;
1667 ME_GetSelectionOfs(This->reOle->editor, &first, pcpLim);
1668 TRACE("%d\n", *pcpLim);
1669 return S_OK;
1670 }
1671
1672 static HRESULT WINAPI ITextSelection_fnSetEnd(ITextSelection *me, LONG cpLim)
1673 {
1674 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1675 if (!This->reOle)
1676 return CO_E_RELEASED;
1677
1678 FIXME("not implemented\n");
1679 return E_NOTIMPL;
1680 }
1681
1682 static HRESULT WINAPI ITextSelection_fnGetFont(ITextSelection *me, ITextFont **pFont)
1683 {
1684 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1685 if (!This->reOle)
1686 return CO_E_RELEASED;
1687
1688 FIXME("not implemented\n");
1689 return E_NOTIMPL;
1690 }
1691
1692 static HRESULT WINAPI ITextSelection_fnSetFont(ITextSelection *me, ITextFont *pFont)
1693 {
1694 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1695 if (!This->reOle)
1696 return CO_E_RELEASED;
1697
1698 FIXME("not implemented\n");
1699 return E_NOTIMPL;
1700 }
1701
1702 static HRESULT WINAPI ITextSelection_fnGetPara(ITextSelection *me, ITextPara **ppPara)
1703 {
1704 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1705 if (!This->reOle)
1706 return CO_E_RELEASED;
1707
1708 FIXME("not implemented\n");
1709 return E_NOTIMPL;
1710 }
1711
1712 static HRESULT WINAPI ITextSelection_fnSetPara(ITextSelection *me, ITextPara *pPara)
1713 {
1714 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1715 if (!This->reOle)
1716 return CO_E_RELEASED;
1717
1718 FIXME("not implemented\n");
1719 return E_NOTIMPL;
1720 }
1721
1722 static HRESULT WINAPI ITextSelection_fnGetStoryLength(ITextSelection *me, LONG *pcch)
1723 {
1724 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1725 if (!This->reOle)
1726 return CO_E_RELEASED;
1727
1728 FIXME("not implemented\n");
1729 return E_NOTIMPL;
1730 }
1731
1732 static HRESULT WINAPI ITextSelection_fnGetStoryType(ITextSelection *me, LONG *pValue)
1733 {
1734 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1735 if (!This->reOle)
1736 return CO_E_RELEASED;
1737
1738 FIXME("not implemented\n");
1739 return E_NOTIMPL;
1740 }
1741
1742 static HRESULT WINAPI ITextSelection_fnCollapse(ITextSelection *me, LONG bStart)
1743 {
1744 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1745 LONG start, end;
1746 HRESULT hres;
1747 if (!This->reOle)
1748 return CO_E_RELEASED;
1749
1750 ME_GetSelectionOfs(This->reOle->editor, &start, &end);
1751 hres = range_Collapse(bStart, &start, &end);
1752 if (SUCCEEDED(hres))
1753 ME_SetSelection(This->reOle->editor, start, end);
1754 return hres;
1755 }
1756
1757 static HRESULT WINAPI ITextSelection_fnExpand(ITextSelection *me, LONG Unit, LONG *pDelta)
1758 {
1759 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1760 if (!This->reOle)
1761 return CO_E_RELEASED;
1762
1763 FIXME("not implemented\n");
1764 return E_NOTIMPL;
1765 }
1766
1767 static HRESULT WINAPI ITextSelection_fnGetIndex(ITextSelection *me, LONG Unit, LONG *pIndex)
1768 {
1769 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1770 if (!This->reOle)
1771 return CO_E_RELEASED;
1772
1773 FIXME("not implemented\n");
1774 return E_NOTIMPL;
1775 }
1776
1777 static HRESULT WINAPI ITextSelection_fnSetIndex(ITextSelection *me, LONG Unit, LONG Index,
1778 LONG Extend)
1779 {
1780 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1781 if (!This->reOle)
1782 return CO_E_RELEASED;
1783
1784 FIXME("not implemented\n");
1785 return E_NOTIMPL;
1786 }
1787
1788 static HRESULT WINAPI ITextSelection_fnSetRange(ITextSelection *me, LONG cpActive, LONG cpOther)
1789 {
1790 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1791 if (!This->reOle)
1792 return CO_E_RELEASED;
1793
1794 FIXME("not implemented\n");
1795 return E_NOTIMPL;
1796 }
1797
1798 static HRESULT WINAPI ITextSelection_fnInRange(ITextSelection *me, ITextRange *pRange, LONG *pb)
1799 {
1800 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1801 if (!This->reOle)
1802 return CO_E_RELEASED;
1803
1804 FIXME("not implemented\n");
1805 return E_NOTIMPL;
1806 }
1807
1808 static HRESULT WINAPI ITextSelection_fnInStory(ITextSelection *me, ITextRange *pRange, LONG *pb)
1809 {
1810 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1811 if (!This->reOle)
1812 return CO_E_RELEASED;
1813
1814 FIXME("not implemented\n");
1815 return E_NOTIMPL;
1816 }
1817
1818 static HRESULT WINAPI ITextSelection_fnIsEqual(ITextSelection *me, ITextRange *pRange, LONG *pb)
1819 {
1820 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1821 if (!This->reOle)
1822 return CO_E_RELEASED;
1823
1824 FIXME("not implemented\n");
1825 return E_NOTIMPL;
1826 }
1827
1828 static HRESULT WINAPI ITextSelection_fnSelect(ITextSelection *me)
1829 {
1830 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1831 if (!This->reOle)
1832 return CO_E_RELEASED;
1833
1834 FIXME("not implemented\n");
1835 return E_NOTIMPL;
1836 }
1837
1838 static HRESULT WINAPI ITextSelection_fnStartOf(ITextSelection *me, LONG Unit, LONG Extend,
1839 LONG *pDelta)
1840 {
1841 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1842 if (!This->reOle)
1843 return CO_E_RELEASED;
1844
1845 FIXME("not implemented\n");
1846 return E_NOTIMPL;
1847 }
1848
1849 static HRESULT WINAPI ITextSelection_fnEndOf(ITextSelection *me, LONG Unit, LONG Extend,
1850 LONG *pDelta)
1851 {
1852 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1853 if (!This->reOle)
1854 return CO_E_RELEASED;
1855
1856 FIXME("not implemented\n");
1857 return E_NOTIMPL;
1858 }
1859
1860 static HRESULT WINAPI ITextSelection_fnMove(ITextSelection *me, LONG Unit, LONG Count, LONG *pDelta)
1861 {
1862 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1863 if (!This->reOle)
1864 return CO_E_RELEASED;
1865
1866 FIXME("not implemented\n");
1867 return E_NOTIMPL;
1868 }
1869
1870 static HRESULT WINAPI ITextSelection_fnMoveStart(ITextSelection *me, LONG Unit, LONG Count,
1871 LONG *pDelta)
1872 {
1873 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1874 if (!This->reOle)
1875 return CO_E_RELEASED;
1876
1877 FIXME("not implemented\n");
1878 return E_NOTIMPL;
1879 }
1880
1881 static HRESULT WINAPI ITextSelection_fnMoveEnd(ITextSelection *me, LONG Unit, LONG Count,
1882 LONG *pDelta)
1883 {
1884 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1885 if (!This->reOle)
1886 return CO_E_RELEASED;
1887
1888 FIXME("not implemented\n");
1889 return E_NOTIMPL;
1890 }
1891
1892 static HRESULT WINAPI ITextSelection_fnMoveWhile(ITextSelection *me, VARIANT *Cset, LONG Count,
1893 LONG *pDelta)
1894 {
1895 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1896 if (!This->reOle)
1897 return CO_E_RELEASED;
1898
1899 FIXME("not implemented\n");
1900 return E_NOTIMPL;
1901 }
1902
1903 static HRESULT WINAPI ITextSelection_fnMoveStartWhile(ITextSelection *me, VARIANT *Cset, LONG Count,
1904 LONG *pDelta)
1905 {
1906 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1907 if (!This->reOle)
1908 return CO_E_RELEASED;
1909
1910 FIXME("not implemented\n");
1911 return E_NOTIMPL;
1912 }
1913
1914 static HRESULT WINAPI ITextSelection_fnMoveEndWhile(ITextSelection *me, VARIANT *Cset, LONG Count,
1915 LONG *pDelta)
1916 {
1917 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1918 if (!This->reOle)
1919 return CO_E_RELEASED;
1920
1921 FIXME("not implemented\n");
1922 return E_NOTIMPL;
1923 }
1924
1925 static HRESULT WINAPI ITextSelection_fnMoveUntil(ITextSelection *me, VARIANT *Cset, LONG Count,
1926 LONG *pDelta)
1927 {
1928 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1929 if (!This->reOle)
1930 return CO_E_RELEASED;
1931
1932 FIXME("not implemented\n");
1933 return E_NOTIMPL;
1934 }
1935
1936 static HRESULT WINAPI ITextSelection_fnMoveStartUntil(ITextSelection *me, VARIANT *Cset, LONG Count,
1937 LONG *pDelta)
1938 {
1939 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1940 if (!This->reOle)
1941 return CO_E_RELEASED;
1942
1943 FIXME("not implemented\n");
1944 return E_NOTIMPL;
1945 }
1946
1947 static HRESULT WINAPI ITextSelection_fnMoveEndUntil(ITextSelection *me, VARIANT *Cset, LONG Count,
1948 LONG *pDelta)
1949 {
1950 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1951 if (!This->reOle)
1952 return CO_E_RELEASED;
1953
1954 FIXME("not implemented\n");
1955 return E_NOTIMPL;
1956 }
1957
1958 static HRESULT WINAPI ITextSelection_fnFindText(ITextSelection *me, BSTR bstr, LONG cch, LONG Flags,
1959 LONG *pLength)
1960 {
1961 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1962 if (!This->reOle)
1963 return CO_E_RELEASED;
1964
1965 FIXME("not implemented\n");
1966 return E_NOTIMPL;
1967 }
1968
1969 static HRESULT WINAPI ITextSelection_fnFindTextStart(ITextSelection *me, BSTR bstr, LONG cch,
1970 LONG Flags, LONG *pLength)
1971 {
1972 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1973 if (!This->reOle)
1974 return CO_E_RELEASED;
1975
1976 FIXME("not implemented\n");
1977 return E_NOTIMPL;
1978 }
1979
1980 static HRESULT WINAPI ITextSelection_fnFindTextEnd(ITextSelection *me, BSTR bstr, LONG cch,
1981 LONG Flags, LONG *pLength)
1982 {
1983 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1984 if (!This->reOle)
1985 return CO_E_RELEASED;
1986
1987 FIXME("not implemented\n");
1988 return E_NOTIMPL;
1989 }
1990
1991 static HRESULT WINAPI ITextSelection_fnDelete(ITextSelection *me, LONG Unit, LONG Count,
1992 LONG *pDelta)
1993 {
1994 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1995 if (!This->reOle)
1996 return CO_E_RELEASED;
1997
1998 FIXME("not implemented\n");
1999 return E_NOTIMPL;
2000 }
2001
2002 static HRESULT WINAPI ITextSelection_fnCut(ITextSelection *me, VARIANT *pVar)
2003 {
2004 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2005 if (!This->reOle)
2006 return CO_E_RELEASED;
2007
2008 FIXME("not implemented\n");
2009 return E_NOTIMPL;
2010 }
2011
2012 static HRESULT WINAPI ITextSelection_fnCopy(ITextSelection *me, VARIANT *pVar)
2013 {
2014 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2015 if (!This->reOle)
2016 return CO_E_RELEASED;
2017
2018 FIXME("not implemented\n");
2019 return E_NOTIMPL;
2020 }
2021
2022 static HRESULT WINAPI ITextSelection_fnPaste(ITextSelection *me, VARIANT *pVar, LONG Format)
2023 {
2024 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2025 if (!This->reOle)
2026 return CO_E_RELEASED;
2027
2028 FIXME("not implemented\n");
2029 return E_NOTIMPL;
2030 }
2031
2032 static HRESULT WINAPI ITextSelection_fnCanPaste(ITextSelection *me, VARIANT *pVar, LONG Format,
2033 LONG *pb)
2034 {
2035 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2036 if (!This->reOle)
2037 return CO_E_RELEASED;
2038
2039 FIXME("not implemented\n");
2040 return E_NOTIMPL;
2041 }
2042
2043 static HRESULT WINAPI ITextSelection_fnCanEdit(ITextSelection *me, LONG *pb)
2044 {
2045 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2046 if (!This->reOle)
2047 return CO_E_RELEASED;
2048
2049 FIXME("not implemented\n");
2050 return E_NOTIMPL;
2051 }
2052
2053 static HRESULT WINAPI ITextSelection_fnChangeCase(ITextSelection *me, LONG Type)
2054 {
2055 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2056 if (!This->reOle)
2057 return CO_E_RELEASED;
2058
2059 FIXME("not implemented\n");
2060 return E_NOTIMPL;
2061 }
2062
2063 static HRESULT WINAPI ITextSelection_fnGetPoint(ITextSelection *me, LONG Type, LONG *cx, LONG *cy)
2064 {
2065 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2066 if (!This->reOle)
2067 return CO_E_RELEASED;
2068
2069 FIXME("not implemented\n");
2070 return E_NOTIMPL;
2071 }
2072
2073 static HRESULT WINAPI ITextSelection_fnSetPoint(ITextSelection *me, LONG x, LONG y, LONG Type,
2074 LONG Extend)
2075 {
2076 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2077 if (!This->reOle)
2078 return CO_E_RELEASED;
2079
2080 FIXME("not implemented\n");
2081 return E_NOTIMPL;
2082 }
2083
2084 static HRESULT WINAPI ITextSelection_fnScrollIntoView(ITextSelection *me, LONG Value)
2085 {
2086 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2087 if (!This->reOle)
2088 return CO_E_RELEASED;
2089
2090 FIXME("not implemented\n");
2091 return E_NOTIMPL;
2092 }
2093
2094 static HRESULT WINAPI ITextSelection_fnGetEmbeddedObject(ITextSelection *me, IUnknown **ppv)
2095 {
2096 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2097 if (!This->reOle)
2098 return CO_E_RELEASED;
2099
2100 FIXME("not implemented\n");
2101 return E_NOTIMPL;
2102 }
2103
2104 /*** ITextSelection methods ***/
2105 static HRESULT WINAPI ITextSelection_fnGetFlags(ITextSelection *me, LONG *pFlags)
2106 {
2107 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2108 if (!This->reOle)
2109 return CO_E_RELEASED;
2110
2111 FIXME("not implemented\n");
2112 return E_NOTIMPL;
2113 }
2114
2115 static HRESULT WINAPI ITextSelection_fnSetFlags(ITextSelection *me, LONG Flags)
2116 {
2117 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2118 if (!This->reOle)
2119 return CO_E_RELEASED;
2120
2121 FIXME("not implemented\n");
2122 return E_NOTIMPL;
2123 }
2124
2125 static HRESULT WINAPI ITextSelection_fnGetType(ITextSelection *me, LONG *pType)
2126 {
2127 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2128 if (!This->reOle)
2129 return CO_E_RELEASED;
2130
2131 FIXME("not implemented\n");
2132 return E_NOTIMPL;
2133 }
2134
2135 static HRESULT WINAPI ITextSelection_fnMoveLeft(ITextSelection *me, LONG Unit, LONG Count,
2136 LONG Extend, LONG *pDelta)
2137 {
2138 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2139 if (!This->reOle)
2140 return CO_E_RELEASED;
2141
2142 FIXME("not implemented\n");
2143 return E_NOTIMPL;
2144 }
2145
2146 static HRESULT WINAPI ITextSelection_fnMoveRight(ITextSelection *me, LONG Unit, LONG Count,
2147 LONG Extend, LONG *pDelta)
2148 {
2149 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2150 if (!This->reOle)
2151 return CO_E_RELEASED;
2152
2153 FIXME("not implemented\n");
2154 return E_NOTIMPL;
2155 }
2156
2157 static HRESULT WINAPI ITextSelection_fnMoveUp(ITextSelection *me, LONG Unit, LONG Count,
2158 LONG Extend, LONG *pDelta)
2159 {
2160 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2161 if (!This->reOle)
2162 return CO_E_RELEASED;
2163
2164 FIXME("not implemented\n");
2165 return E_NOTIMPL;
2166 }
2167
2168 static HRESULT WINAPI ITextSelection_fnMoveDown(ITextSelection *me, LONG Unit, LONG Count,
2169 LONG Extend, LONG *pDelta)
2170 {
2171 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2172 if (!This->reOle)
2173 return CO_E_RELEASED;
2174
2175 FIXME("not implemented\n");
2176 return E_NOTIMPL;
2177 }
2178
2179 static HRESULT WINAPI ITextSelection_fnHomeKey(ITextSelection *me, LONG Unit, LONG Extend,
2180 LONG *pDelta)
2181 {
2182 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2183 if (!This->reOle)
2184 return CO_E_RELEASED;
2185
2186 FIXME("not implemented\n");
2187 return E_NOTIMPL;
2188 }
2189
2190 static HRESULT WINAPI ITextSelection_fnEndKey(ITextSelection *me, LONG Unit, LONG Extend,
2191 LONG *pDelta)
2192 {
2193 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2194 if (!This->reOle)
2195 return CO_E_RELEASED;
2196
2197 FIXME("not implemented\n");
2198 return E_NOTIMPL;
2199 }
2200
2201 static HRESULT WINAPI ITextSelection_fnTypeText(ITextSelection *me, BSTR bstr)
2202 {
2203 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2204 if (!This->reOle)
2205 return CO_E_RELEASED;
2206
2207 FIXME("not implemented\n");
2208 return E_NOTIMPL;
2209 }
2210
2211 static const ITextSelectionVtbl tsvt = {
2212 ITextSelection_fnQueryInterface,
2213 ITextSelection_fnAddRef,
2214 ITextSelection_fnRelease,
2215 ITextSelection_fnGetTypeInfoCount,
2216 ITextSelection_fnGetTypeInfo,
2217 ITextSelection_fnGetIDsOfNames,
2218 ITextSelection_fnInvoke,
2219 ITextSelection_fnGetText,
2220 ITextSelection_fnSetText,
2221 ITextSelection_fnGetChar,
2222 ITextSelection_fnSetChar,
2223 ITextSelection_fnGetDuplicate,
2224 ITextSelection_fnGetFormattedText,
2225 ITextSelection_fnSetFormattedText,
2226 ITextSelection_fnGetStart,
2227 ITextSelection_fnSetStart,
2228 ITextSelection_fnGetEnd,
2229 ITextSelection_fnSetEnd,
2230 ITextSelection_fnGetFont,
2231 ITextSelection_fnSetFont,
2232 ITextSelection_fnGetPara,
2233 ITextSelection_fnSetPara,
2234 ITextSelection_fnGetStoryLength,
2235 ITextSelection_fnGetStoryType,
2236 ITextSelection_fnCollapse,
2237 ITextSelection_fnExpand,
2238 ITextSelection_fnGetIndex,
2239 ITextSelection_fnSetIndex,
2240 ITextSelection_fnSetRange,
2241 ITextSelection_fnInRange,
2242 ITextSelection_fnInStory,
2243 ITextSelection_fnIsEqual,
2244 ITextSelection_fnSelect,
2245 ITextSelection_fnStartOf,
2246 ITextSelection_fnEndOf,
2247 ITextSelection_fnMove,
2248 ITextSelection_fnMoveStart,
2249 ITextSelection_fnMoveEnd,
2250 ITextSelection_fnMoveWhile,
2251 ITextSelection_fnMoveStartWhile,
2252 ITextSelection_fnMoveEndWhile,
2253 ITextSelection_fnMoveUntil,
2254 ITextSelection_fnMoveStartUntil,
2255 ITextSelection_fnMoveEndUntil,
2256 ITextSelection_fnFindText,
2257 ITextSelection_fnFindTextStart,
2258 ITextSelection_fnFindTextEnd,
2259 ITextSelection_fnDelete,
2260 ITextSelection_fnCut,
2261 ITextSelection_fnCopy,
2262 ITextSelection_fnPaste,
2263 ITextSelection_fnCanPaste,
2264 ITextSelection_fnCanEdit,
2265 ITextSelection_fnChangeCase,
2266 ITextSelection_fnGetPoint,
2267 ITextSelection_fnSetPoint,
2268 ITextSelection_fnScrollIntoView,
2269 ITextSelection_fnGetEmbeddedObject,
2270 ITextSelection_fnGetFlags,
2271 ITextSelection_fnSetFlags,
2272 ITextSelection_fnGetType,
2273 ITextSelection_fnMoveLeft,
2274 ITextSelection_fnMoveRight,
2275 ITextSelection_fnMoveUp,
2276 ITextSelection_fnMoveDown,
2277 ITextSelection_fnHomeKey,
2278 ITextSelection_fnEndKey,
2279 ITextSelection_fnTypeText
2280 };
2281
2282 static ITextSelectionImpl *
2283 CreateTextSelection(IRichEditOleImpl *reOle)
2284 {
2285 ITextSelectionImpl *txtSel = heap_alloc(sizeof *txtSel);
2286 if (!txtSel)
2287 return NULL;
2288
2289 txtSel->ITextSelection_iface.lpVtbl = &tsvt;
2290 txtSel->ref = 1;
2291 txtSel->reOle = reOle;
2292 return txtSel;
2293 }
2294
2295 LRESULT CreateIRichEditOle(ME_TextEditor *editor, LPVOID *ppObj)
2296 {
2297 IRichEditOleImpl *reo;
2298
2299 reo = heap_alloc(sizeof(IRichEditOleImpl));
2300 if (!reo)
2301 return 0;
2302
2303 reo->IRichEditOle_iface.lpVtbl = &revt;
2304 reo->ITextDocument_iface.lpVtbl = &tdvt;
2305 reo->ref = 1;
2306 reo->editor = editor;
2307 reo->txtSel = CreateTextSelection(reo);
2308 if (!reo->txtSel)
2309 {
2310 heap_free(reo);
2311 return 0;
2312 }
2313 reo->clientSite = CreateOleClientSite(reo);
2314 if (!reo->clientSite)
2315 {
2316 ITextSelection_Release(&reo->txtSel->ITextSelection_iface);
2317 heap_free(reo);
2318 return 0;
2319 }
2320 TRACE("Created %p\n",reo);
2321 *ppObj = reo;
2322 list_init(&reo->rangelist);
2323
2324 return 1;
2325 }
2326
2327 static void convert_sizel(const ME_Context *c, const SIZEL* szl, SIZE* sz)
2328 {
2329 /* sizel is in .01 millimeters, sz in pixels */
2330 sz->cx = MulDiv(szl->cx, c->dpi.cx, 2540);
2331 sz->cy = MulDiv(szl->cy, c->dpi.cy, 2540);
2332 }
2333
2334 /******************************************************************************
2335 * ME_GetOLEObjectSize
2336 *
2337 * Sets run extent for OLE objects.
2338 */
2339 void ME_GetOLEObjectSize(const ME_Context *c, ME_Run *run, SIZE *pSize)
2340 {
2341 IDataObject* ido;
2342 FORMATETC fmt;
2343 STGMEDIUM stgm;
2344 DIBSECTION dibsect;
2345 ENHMETAHEADER emh;
2346
2347 assert(run->nFlags & MERF_GRAPHICS);
2348 assert(run->ole_obj);
2349
2350 if (run->ole_obj->sizel.cx != 0 || run->ole_obj->sizel.cy != 0)
2351 {
2352 convert_sizel(c, &run->ole_obj->sizel, pSize);
2353 if (c->editor->nZoomNumerator != 0)
2354 {
2355 pSize->cx = MulDiv(pSize->cx, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
2356 pSize->cy = MulDiv(pSize->cy, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
2357 }
2358 return;
2359 }
2360
2361 if (IOleObject_QueryInterface(run->ole_obj->poleobj, &IID_IDataObject, (void**)&ido) != S_OK)
2362 {
2363 FIXME("Query Interface IID_IDataObject failed!\n");
2364 pSize->cx = pSize->cy = 0;
2365 return;
2366 }
2367 fmt.cfFormat = CF_BITMAP;
2368 fmt.ptd = NULL;
2369 fmt.dwAspect = DVASPECT_CONTENT;
2370 fmt.lindex = -1;
2371 fmt.tymed = TYMED_GDI;
2372 if (IDataObject_GetData(ido, &fmt, &stgm) != S_OK)
2373 {
2374 fmt.cfFormat = CF_ENHMETAFILE;
2375 fmt.tymed = TYMED_ENHMF;
2376 if (IDataObject_GetData(ido, &fmt, &stgm) != S_OK)
2377 {
2378 FIXME("unsupported format\n");
2379 pSize->cx = pSize->cy = 0;
2380 IDataObject_Release(ido);
2381 return;
2382 }
2383 }
2384
2385 switch (stgm.tymed)
2386 {
2387 case TYMED_GDI:
2388 GetObjectW(stgm.u.hBitmap, sizeof(dibsect), &dibsect);
2389 pSize->cx = dibsect.dsBm.bmWidth;
2390 pSize->cy = dibsect.dsBm.bmHeight;
2391 if (!stgm.pUnkForRelease) DeleteObject(stgm.u.hBitmap);
2392 break;
2393 case TYMED_ENHMF:
2394 GetEnhMetaFileHeader(stgm.u.hEnhMetaFile, sizeof(emh), &emh);
2395 pSize->cx = emh.rclBounds.right - emh.rclBounds.left;
2396 pSize->cy = emh.rclBounds.bottom - emh.rclBounds.top;
2397 if (!stgm.pUnkForRelease) DeleteEnhMetaFile(stgm.u.hEnhMetaFile);
2398 break;
2399 default:
2400 FIXME("Unsupported tymed %d\n", stgm.tymed);
2401 break;
2402 }
2403 IDataObject_Release(ido);
2404 if (c->editor->nZoomNumerator != 0)
2405 {
2406 pSize->cx = MulDiv(pSize->cx, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
2407 pSize->cy = MulDiv(pSize->cy, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
2408 }
2409 }
2410
2411 void ME_DrawOLE(ME_Context *c, int x, int y, ME_Run *run,
2412 ME_Paragraph *para, BOOL selected)
2413 {
2414 IDataObject* ido;
2415 FORMATETC fmt;
2416 STGMEDIUM stgm;
2417 DIBSECTION dibsect;
2418 ENHMETAHEADER emh;
2419 HDC hMemDC;
2420 SIZE sz;
2421 BOOL has_size;
2422
2423 assert(run->nFlags & MERF_GRAPHICS);
2424 assert(run->ole_obj);
2425 if (IOleObject_QueryInterface(run->ole_obj->poleobj, &IID_IDataObject, (void**)&ido) != S_OK)
2426 {
2427 FIXME("Couldn't get interface\n");
2428 return;
2429 }
2430 has_size = run->ole_obj->sizel.cx != 0 || run->ole_obj->sizel.cy != 0;
2431 fmt.cfFormat = CF_BITMAP;
2432 fmt.ptd = NULL;
2433 fmt.dwAspect = DVASPECT_CONTENT;
2434 fmt.lindex = -1;
2435 fmt.tymed = TYMED_GDI;
2436 if (IDataObject_GetData(ido, &fmt, &stgm) != S_OK)
2437 {
2438 fmt.cfFormat = CF_ENHMETAFILE;
2439 fmt.tymed = TYMED_ENHMF;
2440 if (IDataObject_GetData(ido, &fmt, &stgm) != S_OK)
2441 {
2442 FIXME("Couldn't get storage medium\n");
2443 IDataObject_Release(ido);
2444 return;
2445 }
2446 }
2447 switch (stgm.tymed)
2448 {
2449 case TYMED_GDI:
2450 GetObjectW(stgm.u.hBitmap, sizeof(dibsect), &dibsect);
2451 hMemDC = CreateCompatibleDC(c->hDC);
2452 SelectObject(hMemDC, stgm.u.hBitmap);
2453 if (has_size)
2454 {
2455 convert_sizel(c, &run->ole_obj->sizel, &sz);
2456 } else {
2457 sz.cx = MulDiv(dibsect.dsBm.bmWidth, c->dpi.cx, 96);
2458 sz.cy = MulDiv(dibsect.dsBm.bmHeight, c->dpi.cy, 96);
2459 }
2460 if (c->editor->nZoomNumerator != 0)
2461 {
2462 sz.cx = MulDiv(sz.cx, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
2463 sz.cy = MulDiv(sz.cy, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
2464 }
2465 if (sz.cx == dibsect.dsBm.bmWidth && sz.cy == dibsect.dsBm.bmHeight)
2466 {
2467 BitBlt(c->hDC, x, y - sz.cy,
2468 dibsect.dsBm.bmWidth, dibsect.dsBm.bmHeight,
2469 hMemDC, 0, 0, SRCCOPY);
2470 } else {
2471 StretchBlt(c->hDC, x, y - sz.cy, sz.cx, sz.cy,
2472 hMemDC, 0, 0, dibsect.dsBm.bmWidth,
2473 dibsect.dsBm.bmHeight, SRCCOPY);
2474 }
2475 DeleteDC(hMemDC);
2476 if (!stgm.pUnkForRelease) DeleteObject(stgm.u.hBitmap);
2477 break;
2478 case TYMED_ENHMF:
2479 GetEnhMetaFileHeader(stgm.u.hEnhMetaFile, sizeof(emh), &emh);
2480 if (has_size)
2481 {
2482 convert_sizel(c, &run->ole_obj->sizel, &sz);
2483 } else {
2484 sz.cy = MulDiv(emh.rclBounds.bottom - emh.rclBounds.top, c->dpi.cx, 96);
2485 sz.cx = MulDiv(emh.rclBounds.right - emh.rclBounds.left, c->dpi.cy, 96);
2486 }
2487 if (c->editor->nZoomNumerator != 0)
2488 {
2489 sz.cx = MulDiv(sz.cx, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
2490 sz.cy = MulDiv(sz.cy, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
2491 }
2492
2493 {
2494 RECT rc;
2495
2496 rc.left = x;
2497 rc.top = y - sz.cy;
2498 rc.right = x + sz.cx;
2499 rc.bottom = y;
2500 PlayEnhMetaFile(c->hDC, stgm.u.hEnhMetaFile, &rc);
2501 }
2502 if (!stgm.pUnkForRelease) DeleteEnhMetaFile(stgm.u.hEnhMetaFile);
2503 break;
2504 default:
2505 FIXME("Unsupported tymed %d\n", stgm.tymed);
2506 selected = FALSE;
2507 break;
2508 }
2509 if (selected && !c->editor->bHideSelection)
2510 PatBlt(c->hDC, x, y - sz.cy, sz.cx, sz.cy, DSTINVERT);
2511 IDataObject_Release(ido);
2512 }
2513
2514 void ME_DeleteReObject(REOBJECT* reo)
2515 {
2516 if (reo->poleobj) IOleObject_Release(reo->poleobj);
2517 if (reo->pstg) IStorage_Release(reo->pstg);
2518 if (reo->polesite) IOleClientSite_Release(reo->polesite);
2519 FREE_OBJ(reo);
2520 }
2521
2522 void ME_CopyReObject(REOBJECT* dst, const REOBJECT* src)
2523 {
2524 *dst = *src;
2525
2526 if (dst->poleobj) IOleObject_AddRef(dst->poleobj);
2527 if (dst->pstg) IStorage_AddRef(dst->pstg);
2528 if (dst->polesite) IOleClientSite_AddRef(dst->polesite);
2529 }