riched20: Move DestroyIRichEditOle() into IRichEditOle:Release().
[wine.git] / dlls / riched20 / richole.c
blob1280016b242934aaf0ce1d0b0fbe7e2233072d48
1 /*
2 * RichEdit GUIDs and OLE interface
4 * Copyright 2004 by Krzysztof Foltman
5 * Copyright 2004 Aric Stewart
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.
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.
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
22 #include <stdarg.h>
24 #define NONAMELESSUNION
25 #define NONAMELESSSTRUCT
26 #define COBJMACROS
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"
38 WINE_DEFAULT_DEBUG_CHANNEL(richedit);
40 /* there is no way to be consistent across different sets of headers - mingw, Wine, Win32 SDK*/
42 #include "initguid.h"
43 DEFINE_GUID(IID_ITextServices, 0x8d33f740, 0xcf58, 0x11ce, 0xa8, 0x9d, 0x00, 0xaa, 0x00, 0x6c, 0xad, 0xc5);
44 DEFINE_GUID(IID_ITextHost, 0x13e670f4,0x1a5a,0x11cf,0xab,0xeb,0x00,0xaa,0x00,0xb6,0x5e,0xa1);
45 DEFINE_GUID(IID_ITextHost2, 0x13e670f5,0x1a5a,0x11cf,0xab,0xeb,0x00,0xaa,0x00,0xb6,0x5e,0xa1);
46 DEFINE_GUID(IID_ITextDocument, 0x8cc497c0, 0xa1df, 0x11ce, 0x80, 0x98, 0x00, 0xaa, 0x00, 0x47, 0xbe, 0x5d);
47 DEFINE_GUID(IID_ITextRange, 0x8cc497c2, 0xa1df, 0x11ce, 0x80, 0x98, 0x00, 0xaa, 0x00, 0x47, 0xbe, 0x5d);
48 DEFINE_GUID(IID_ITextSelection, 0x8cc497c1, 0xa1df, 0x11ce, 0x80, 0x98, 0x00, 0xaa, 0x00, 0x47, 0xbe, 0x5d);
50 typedef struct ITextSelectionImpl ITextSelectionImpl;
51 typedef struct IOleClientSiteImpl IOleClientSiteImpl;
52 typedef struct ITextRangeImpl ITextRangeImpl;
54 typedef struct IRichEditOleImpl {
55 IUnknown IUnknown_inner;
56 IRichEditOle IRichEditOle_iface;
57 ITextDocument ITextDocument_iface;
58 IUnknown *outer_unk;
59 LONG ref;
61 ME_TextEditor *editor;
62 ITextSelectionImpl *txtSel;
63 IOleClientSiteImpl *clientSite;
64 struct list rangelist;
65 } IRichEditOleImpl;
67 struct ITextRangeImpl {
68 ITextRange ITextRange_iface;
69 LONG ref;
70 LONG start, end;
71 struct list entry;
73 IRichEditOleImpl *reOle;
76 struct ITextSelectionImpl {
77 ITextSelection ITextSelection_iface;
78 LONG ref;
80 IRichEditOleImpl *reOle;
83 struct IOleClientSiteImpl {
84 IOleClientSite IOleClientSite_iface;
85 LONG ref;
87 IRichEditOleImpl *reOle;
90 static inline IRichEditOleImpl *impl_from_IRichEditOle(IRichEditOle *iface)
92 return CONTAINING_RECORD(iface, IRichEditOleImpl, IRichEditOle_iface);
95 static inline IRichEditOleImpl *impl_from_ITextDocument(ITextDocument *iface)
97 return CONTAINING_RECORD(iface, IRichEditOleImpl, ITextDocument_iface);
100 static inline IRichEditOleImpl *impl_from_IUnknown(IUnknown *iface)
102 return CONTAINING_RECORD(iface, IRichEditOleImpl, IUnknown_inner);
105 static HRESULT WINAPI IRichEditOleImpl_inner_fnQueryInterface(IUnknown *iface, REFIID riid, LPVOID *ppvObj)
107 IRichEditOleImpl *This = impl_from_IUnknown(iface);
109 TRACE("%p %s\n", This, debugstr_guid(riid));
111 *ppvObj = NULL;
112 if (IsEqualGUID(riid, &IID_IUnknown))
113 *ppvObj = &This->IUnknown_inner;
114 else if (IsEqualGUID(riid, &IID_IRichEditOle))
115 *ppvObj = &This->IRichEditOle_iface;
116 else if (IsEqualGUID(riid, &IID_ITextDocument))
117 *ppvObj = &This->ITextDocument_iface;
118 if (*ppvObj)
120 IUnknown_AddRef((IUnknown *)*ppvObj);
121 return S_OK;
123 FIXME("%p: unhandled interface %s\n", This, debugstr_guid(riid));
125 return E_NOINTERFACE;
128 static ULONG WINAPI IRichEditOleImpl_inner_fnAddRef(IUnknown *iface)
130 IRichEditOleImpl *This = impl_from_IUnknown(iface);
131 ULONG ref = InterlockedIncrement(&This->ref);
133 TRACE("%p ref = %u\n", This, ref);
135 return ref;
138 static ULONG WINAPI IRichEditOleImpl_inner_fnRelease(IUnknown *iface)
140 IRichEditOleImpl *This = impl_from_IUnknown(iface);
141 ULONG ref = InterlockedDecrement(&This->ref);
143 TRACE ("%p ref=%u\n", This, ref);
145 if (!ref)
147 ITextRangeImpl *txtRge;
149 TRACE("Destroying %p\n", This);
150 This->txtSel->reOle = NULL;
151 This->editor->reOle = NULL;
152 ITextSelection_Release(&This->txtSel->ITextSelection_iface);
153 IOleClientSite_Release(&This->clientSite->IOleClientSite_iface);
154 LIST_FOR_EACH_ENTRY(txtRge, &This->rangelist, ITextRangeImpl, entry)
155 txtRge->reOle = NULL;
156 heap_free(This);
158 return ref;
161 static const IUnknownVtbl reo_unk_vtbl =
163 IRichEditOleImpl_inner_fnQueryInterface,
164 IRichEditOleImpl_inner_fnAddRef,
165 IRichEditOleImpl_inner_fnRelease
168 static HRESULT WINAPI
169 IRichEditOle_fnQueryInterface(IRichEditOle *me, REFIID riid, LPVOID *ppvObj)
171 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
172 return IUnknown_QueryInterface(This->outer_unk, riid, ppvObj);
175 static ULONG WINAPI
176 IRichEditOle_fnAddRef(IRichEditOle *me)
178 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
179 return IUnknown_AddRef(This->outer_unk);
182 static ULONG WINAPI
183 IRichEditOle_fnRelease(IRichEditOle *me)
185 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
186 return IUnknown_Release(This->outer_unk);
189 static HRESULT WINAPI
190 IRichEditOle_fnActivateAs(IRichEditOle *me, REFCLSID rclsid, REFCLSID rclsidAs)
192 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
193 FIXME("stub %p\n",This);
194 return E_NOTIMPL;
197 static HRESULT WINAPI
198 IRichEditOle_fnContextSensitiveHelp(IRichEditOle *me, BOOL fEnterMode)
200 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
201 FIXME("stub %p\n",This);
202 return E_NOTIMPL;
205 static HRESULT WINAPI
206 IRichEditOle_fnConvertObject(IRichEditOle *me, LONG iob,
207 REFCLSID rclsidNew, LPCSTR lpstrUserTypeNew)
209 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
210 FIXME("stub %p\n",This);
211 return E_NOTIMPL;
214 static inline IOleClientSiteImpl *impl_from_IOleClientSite(IOleClientSite *iface)
216 return CONTAINING_RECORD(iface, IOleClientSiteImpl, IOleClientSite_iface);
219 static HRESULT WINAPI
220 IOleClientSite_fnQueryInterface(IOleClientSite *me, REFIID riid, LPVOID *ppvObj)
222 TRACE("%p %s\n", me, debugstr_guid(riid) );
224 *ppvObj = NULL;
225 if (IsEqualGUID(riid, &IID_IUnknown) ||
226 IsEqualGUID(riid, &IID_IOleClientSite))
227 *ppvObj = me;
228 if (*ppvObj)
230 IOleClientSite_AddRef(me);
231 return S_OK;
233 FIXME("%p: unhandled interface %s\n", me, debugstr_guid(riid) );
235 return E_NOINTERFACE;
238 static ULONG WINAPI IOleClientSite_fnAddRef(IOleClientSite *iface)
240 IOleClientSiteImpl *This = impl_from_IOleClientSite(iface);
241 return InterlockedIncrement(&This->ref);
244 static ULONG WINAPI IOleClientSite_fnRelease(IOleClientSite *iface)
246 IOleClientSiteImpl *This = impl_from_IOleClientSite(iface);
247 ULONG ref = InterlockedDecrement(&This->ref);
248 if (ref == 0)
249 heap_free(This);
250 return ref;
253 static HRESULT WINAPI IOleClientSite_fnSaveObject(IOleClientSite *iface)
255 IOleClientSiteImpl *This = impl_from_IOleClientSite(iface);
256 if (!This->reOle)
257 return CO_E_RELEASED;
259 FIXME("stub %p\n", iface);
260 return E_NOTIMPL;
264 static HRESULT WINAPI IOleClientSite_fnGetMoniker(IOleClientSite *iface, DWORD dwAssign,
265 DWORD dwWhichMoniker, IMoniker **ppmk)
267 IOleClientSiteImpl *This = impl_from_IOleClientSite(iface);
268 if (!This->reOle)
269 return CO_E_RELEASED;
271 FIXME("stub %p\n", iface);
272 return E_NOTIMPL;
275 static HRESULT WINAPI IOleClientSite_fnGetContainer(IOleClientSite *iface,
276 IOleContainer **ppContainer)
278 IOleClientSiteImpl *This = impl_from_IOleClientSite(iface);
279 if (!This->reOle)
280 return CO_E_RELEASED;
282 FIXME("stub %p\n", iface);
283 return E_NOTIMPL;
286 static HRESULT WINAPI IOleClientSite_fnShowObject(IOleClientSite *iface)
288 IOleClientSiteImpl *This = impl_from_IOleClientSite(iface);
289 if (!This->reOle)
290 return CO_E_RELEASED;
292 FIXME("stub %p\n", iface);
293 return E_NOTIMPL;
296 static HRESULT WINAPI IOleClientSite_fnOnShowWindow(IOleClientSite *iface, BOOL fShow)
298 IOleClientSiteImpl *This = impl_from_IOleClientSite(iface);
299 if (!This->reOle)
300 return CO_E_RELEASED;
302 FIXME("stub %p\n", iface);
303 return E_NOTIMPL;
306 static HRESULT WINAPI IOleClientSite_fnRequestNewObjectLayout(IOleClientSite *iface)
308 IOleClientSiteImpl *This = impl_from_IOleClientSite(iface);
309 if (!This->reOle)
310 return CO_E_RELEASED;
312 FIXME("stub %p\n", iface);
313 return E_NOTIMPL;
316 static const IOleClientSiteVtbl ocst = {
317 IOleClientSite_fnQueryInterface,
318 IOleClientSite_fnAddRef,
319 IOleClientSite_fnRelease,
320 IOleClientSite_fnSaveObject,
321 IOleClientSite_fnGetMoniker,
322 IOleClientSite_fnGetContainer,
323 IOleClientSite_fnShowObject,
324 IOleClientSite_fnOnShowWindow,
325 IOleClientSite_fnRequestNewObjectLayout
328 static IOleClientSiteImpl *
329 CreateOleClientSite(IRichEditOleImpl *reOle)
331 IOleClientSiteImpl *clientSite = heap_alloc(sizeof *clientSite);
332 if (!clientSite)
333 return NULL;
335 clientSite->IOleClientSite_iface.lpVtbl = &ocst;
336 clientSite->ref = 1;
337 clientSite->reOle = reOle;
338 return clientSite;
341 static HRESULT WINAPI
342 IRichEditOle_fnGetClientSite(IRichEditOle *me,
343 LPOLECLIENTSITE *lplpolesite)
345 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
347 TRACE("%p,%p\n",This, lplpolesite);
349 if(!lplpolesite)
350 return E_INVALIDARG;
351 *lplpolesite = &This->clientSite->IOleClientSite_iface;
352 IOleClientSite_AddRef(*lplpolesite);
353 return S_OK;
356 static HRESULT WINAPI
357 IRichEditOle_fnGetClipboardData(IRichEditOle *me, CHARRANGE *lpchrg,
358 DWORD reco, LPDATAOBJECT *lplpdataobj)
360 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
361 ME_Cursor start;
362 int nChars;
364 TRACE("(%p,%p,%d)\n",This, lpchrg, reco);
365 if(!lplpdataobj)
366 return E_INVALIDARG;
367 if(!lpchrg) {
368 int nFrom, nTo, nStartCur = ME_GetSelectionOfs(This->editor, &nFrom, &nTo);
369 start = This->editor->pCursors[nStartCur];
370 nChars = nTo - nFrom;
371 } else {
372 ME_CursorFromCharOfs(This->editor, lpchrg->cpMin, &start);
373 nChars = lpchrg->cpMax - lpchrg->cpMin;
375 return ME_GetDataObject(This->editor, &start, nChars, lplpdataobj);
378 static LONG WINAPI IRichEditOle_fnGetLinkCount(IRichEditOle *me)
380 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
381 FIXME("stub %p\n",This);
382 return E_NOTIMPL;
385 static HRESULT WINAPI
386 IRichEditOle_fnGetObject(IRichEditOle *me, LONG iob,
387 REOBJECT *lpreobject, DWORD dwFlags)
389 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
390 FIXME("stub %p\n",This);
391 return E_NOTIMPL;
394 static LONG WINAPI
395 IRichEditOle_fnGetObjectCount(IRichEditOle *me)
397 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
398 FIXME("stub %p\n",This);
399 return 0;
402 static HRESULT WINAPI
403 IRichEditOle_fnHandsOffStorage(IRichEditOle *me, LONG iob)
405 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
406 FIXME("stub %p\n",This);
407 return E_NOTIMPL;
410 static HRESULT WINAPI
411 IRichEditOle_fnImportDataObject(IRichEditOle *me, LPDATAOBJECT lpdataobj,
412 CLIPFORMAT cf, HGLOBAL hMetaPict)
414 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
415 FIXME("stub %p\n",This);
416 return E_NOTIMPL;
419 static HRESULT WINAPI
420 IRichEditOle_fnInPlaceDeactivate(IRichEditOle *me)
422 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
423 FIXME("stub %p\n",This);
424 return E_NOTIMPL;
427 static HRESULT WINAPI
428 IRichEditOle_fnInsertObject(IRichEditOle *me, REOBJECT *reo)
430 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
431 TRACE("(%p,%p)\n", This, reo);
433 if (reo->cbStruct < sizeof(*reo)) return STG_E_INVALIDPARAMETER;
435 ME_InsertOLEFromCursor(This->editor, reo, 0);
436 ME_CommitUndo(This->editor);
437 ME_UpdateRepaint(This->editor, FALSE);
438 return S_OK;
441 static HRESULT WINAPI IRichEditOle_fnSaveCompleted(IRichEditOle *me, LONG iob,
442 LPSTORAGE lpstg)
444 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
445 FIXME("stub %p\n",This);
446 return E_NOTIMPL;
449 static HRESULT WINAPI
450 IRichEditOle_fnSetDvaspect(IRichEditOle *me, LONG iob, DWORD dvaspect)
452 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
453 FIXME("stub %p\n",This);
454 return E_NOTIMPL;
457 static HRESULT WINAPI IRichEditOle_fnSetHostNames(IRichEditOle *me,
458 LPCSTR lpstrContainerApp, LPCSTR lpstrContainerObj)
460 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
461 FIXME("stub %p %s %s\n",This, lpstrContainerApp, lpstrContainerObj);
462 return E_NOTIMPL;
465 static HRESULT WINAPI
466 IRichEditOle_fnSetLinkAvailable(IRichEditOle *me, LONG iob, BOOL fAvailable)
468 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
469 FIXME("stub %p\n",This);
470 return E_NOTIMPL;
473 static const IRichEditOleVtbl revt = {
474 IRichEditOle_fnQueryInterface,
475 IRichEditOle_fnAddRef,
476 IRichEditOle_fnRelease,
477 IRichEditOle_fnGetClientSite,
478 IRichEditOle_fnGetObjectCount,
479 IRichEditOle_fnGetLinkCount,
480 IRichEditOle_fnGetObject,
481 IRichEditOle_fnInsertObject,
482 IRichEditOle_fnConvertObject,
483 IRichEditOle_fnActivateAs,
484 IRichEditOle_fnSetHostNames,
485 IRichEditOle_fnSetLinkAvailable,
486 IRichEditOle_fnSetDvaspect,
487 IRichEditOle_fnHandsOffStorage,
488 IRichEditOle_fnSaveCompleted,
489 IRichEditOle_fnInPlaceDeactivate,
490 IRichEditOle_fnContextSensitiveHelp,
491 IRichEditOle_fnGetClipboardData,
492 IRichEditOle_fnImportDataObject
495 /* ITextRange interface */
496 static inline ITextRangeImpl *impl_from_ITextRange(ITextRange *iface)
498 return CONTAINING_RECORD(iface, ITextRangeImpl, ITextRange_iface);
501 static HRESULT WINAPI ITextRange_fnQueryInterface(ITextRange *me, REFIID riid, void **ppvObj)
503 *ppvObj = NULL;
504 if (IsEqualGUID(riid, &IID_IUnknown)
505 || IsEqualGUID(riid, &IID_IDispatch)
506 || IsEqualGUID(riid, &IID_ITextRange))
508 *ppvObj = me;
509 ITextRange_AddRef(me);
510 return S_OK;
513 return E_NOINTERFACE;
516 static ULONG WINAPI ITextRange_fnAddRef(ITextRange *me)
518 ITextRangeImpl *This = impl_from_ITextRange(me);
519 return InterlockedIncrement(&This->ref);
522 static ULONG WINAPI ITextRange_fnRelease(ITextRange *me)
524 ITextRangeImpl *This = impl_from_ITextRange(me);
525 ULONG ref = InterlockedDecrement(&This->ref);
527 TRACE ("%p ref=%u\n", This, ref);
528 if (ref == 0)
530 if (This->reOle)
532 list_remove(&This->entry);
533 This->reOle = NULL;
535 heap_free(This);
537 return ref;
540 static HRESULT WINAPI ITextRange_fnGetTypeInfoCount(ITextRange *me, UINT *pctinfo)
542 ITextRangeImpl *This = impl_from_ITextRange(me);
543 if (!This->reOle)
544 return CO_E_RELEASED;
546 FIXME("not implemented %p\n", This);
547 return E_NOTIMPL;
550 static HRESULT WINAPI ITextRange_fnGetTypeInfo(ITextRange *me, UINT iTInfo, LCID lcid,
551 ITypeInfo **ppTInfo)
553 ITextRangeImpl *This = impl_from_ITextRange(me);
554 if (!This->reOle)
555 return CO_E_RELEASED;
557 FIXME("not implemented %p\n", This);
558 return E_NOTIMPL;
561 static HRESULT WINAPI ITextRange_fnGetIDsOfNames(ITextRange *me, REFIID riid, LPOLESTR *rgszNames,
562 UINT cNames, LCID lcid, DISPID *rgDispId)
564 ITextRangeImpl *This = impl_from_ITextRange(me);
565 if (!This->reOle)
566 return CO_E_RELEASED;
568 FIXME("not implemented %p\n", This);
569 return E_NOTIMPL;
572 static HRESULT WINAPI ITextRange_fnInvoke(ITextRange *me, DISPID dispIdMember, REFIID riid,
573 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
574 VARIANT *pVarResult, EXCEPINFO *pExcepInfo,
575 UINT *puArgErr)
577 ITextRangeImpl *This = impl_from_ITextRange(me);
578 if (!This->reOle)
579 return CO_E_RELEASED;
581 FIXME("not implemented %p\n", This);
582 return E_NOTIMPL;
585 static HRESULT WINAPI ITextRange_fnGetText(ITextRange *me, BSTR *pbstr)
587 ITextRangeImpl *This = impl_from_ITextRange(me);
588 if (!This->reOle)
589 return CO_E_RELEASED;
591 FIXME("not implemented %p\n", This);
592 return E_NOTIMPL;
595 static HRESULT WINAPI ITextRange_fnSetText(ITextRange *me, BSTR bstr)
597 ITextRangeImpl *This = impl_from_ITextRange(me);
598 if (!This->reOle)
599 return CO_E_RELEASED;
601 FIXME("not implemented %p\n", This);
602 return E_NOTIMPL;
605 static HRESULT range_GetChar(ME_TextEditor *editor, ME_Cursor *cursor, LONG *pch)
607 WCHAR wch[2];
609 ME_GetTextW(editor, wch, 1, cursor, 1, FALSE, cursor->pRun->next->type == diTextEnd);
610 *pch = wch[0];
612 return S_OK;
615 static HRESULT WINAPI ITextRange_fnGetChar(ITextRange *me, LONG *pch)
617 ITextRangeImpl *This = impl_from_ITextRange(me);
618 ME_Cursor cursor;
620 if (!This->reOle)
621 return CO_E_RELEASED;
622 TRACE("%p\n", pch);
623 if (!pch)
624 return E_INVALIDARG;
626 ME_CursorFromCharOfs(This->reOle->editor, This->start, &cursor);
627 return range_GetChar(This->reOle->editor, &cursor, pch);
630 static HRESULT WINAPI ITextRange_fnSetChar(ITextRange *me, LONG ch)
632 ITextRangeImpl *This = impl_from_ITextRange(me);
633 if (!This->reOle)
634 return CO_E_RELEASED;
636 FIXME("not implemented %p\n", This);
637 return E_NOTIMPL;
640 static HRESULT CreateITextRange(IRichEditOleImpl *reOle, LONG start, LONG end, ITextRange** ppRange);
642 static HRESULT WINAPI ITextRange_fnGetDuplicate(ITextRange *me, ITextRange **ppRange)
644 ITextRangeImpl *This = impl_from_ITextRange(me);
645 if (!This->reOle)
646 return CO_E_RELEASED;
648 TRACE("%p %p\n", This, ppRange);
649 if (!ppRange)
650 return E_INVALIDARG;
652 return CreateITextRange(This->reOle, This->start, This->end, ppRange);
655 static HRESULT WINAPI ITextRange_fnGetFormattedText(ITextRange *me, ITextRange **ppRange)
657 ITextRangeImpl *This = impl_from_ITextRange(me);
658 if (!This->reOle)
659 return CO_E_RELEASED;
661 FIXME("not implemented %p\n", This);
662 return E_NOTIMPL;
665 static HRESULT WINAPI ITextRange_fnSetFormattedText(ITextRange *me, ITextRange *pRange)
667 ITextRangeImpl *This = impl_from_ITextRange(me);
668 if (!This->reOle)
669 return CO_E_RELEASED;
671 FIXME("not implemented %p\n", This);
672 return E_NOTIMPL;
675 static HRESULT WINAPI ITextRange_fnGetStart(ITextRange *me, LONG *pcpFirst)
677 ITextRangeImpl *This = impl_from_ITextRange(me);
678 if (!This->reOle)
679 return CO_E_RELEASED;
681 if (!pcpFirst)
682 return E_INVALIDARG;
683 *pcpFirst = This->start;
684 TRACE("%d\n", *pcpFirst);
685 return S_OK;
688 static HRESULT WINAPI ITextRange_fnSetStart(ITextRange *me, LONG cpFirst)
690 ITextRangeImpl *This = impl_from_ITextRange(me);
691 if (!This->reOle)
692 return CO_E_RELEASED;
694 FIXME("not implemented %p\n", This);
695 return E_NOTIMPL;
698 static HRESULT WINAPI ITextRange_fnGetEnd(ITextRange *me, LONG *pcpLim)
700 ITextRangeImpl *This = impl_from_ITextRange(me);
701 if (!This->reOle)
702 return CO_E_RELEASED;
704 if (!pcpLim)
705 return E_INVALIDARG;
706 *pcpLim = This->end;
707 TRACE("%d\n", *pcpLim);
708 return S_OK;
711 static HRESULT WINAPI ITextRange_fnSetEnd(ITextRange *me, LONG cpLim)
713 ITextRangeImpl *This = impl_from_ITextRange(me);
714 if (!This->reOle)
715 return CO_E_RELEASED;
717 FIXME("not implemented %p\n", This);
718 return E_NOTIMPL;
721 static HRESULT WINAPI ITextRange_fnGetFont(ITextRange *me, ITextFont **pFont)
723 ITextRangeImpl *This = impl_from_ITextRange(me);
724 if (!This->reOle)
725 return CO_E_RELEASED;
727 FIXME("not implemented %p\n", This);
728 return E_NOTIMPL;
731 static HRESULT WINAPI ITextRange_fnSetFont(ITextRange *me, ITextFont *pFont)
733 ITextRangeImpl *This = impl_from_ITextRange(me);
734 if (!This->reOle)
735 return CO_E_RELEASED;
737 FIXME("not implemented %p\n", This);
738 return E_NOTIMPL;
741 static HRESULT WINAPI ITextRange_fnGetPara(ITextRange *me, ITextPara **ppPara)
743 ITextRangeImpl *This = impl_from_ITextRange(me);
744 if (!This->reOle)
745 return CO_E_RELEASED;
747 FIXME("not implemented %p\n", This);
748 return E_NOTIMPL;
751 static HRESULT WINAPI ITextRange_fnSetPara(ITextRange *me, ITextPara *pPara)
753 ITextRangeImpl *This = impl_from_ITextRange(me);
754 if (!This->reOle)
755 return CO_E_RELEASED;
757 FIXME("not implemented %p\n", This);
758 return E_NOTIMPL;
761 static HRESULT WINAPI ITextRange_fnGetStoryLength(ITextRange *me, LONG *pcch)
763 ITextRangeImpl *This = impl_from_ITextRange(me);
764 if (!This->reOle)
765 return CO_E_RELEASED;
767 FIXME("not implemented %p\n", This);
768 return E_NOTIMPL;
771 static HRESULT WINAPI ITextRange_fnGetStoryType(ITextRange *me, LONG *pValue)
773 ITextRangeImpl *This = impl_from_ITextRange(me);
774 if (!This->reOle)
775 return CO_E_RELEASED;
777 FIXME("not implemented %p\n", This);
778 return E_NOTIMPL;
781 static HRESULT range_Collapse(LONG bStart, LONG *start, LONG *end)
783 if (*end == *start)
784 return S_FALSE;
786 if (bStart == tomEnd || bStart == tomFalse)
787 *start = *end;
788 else
789 *end = *start;
790 return S_OK;
793 static HRESULT WINAPI ITextRange_fnCollapse(ITextRange *me, LONG bStart)
795 ITextRangeImpl *This = impl_from_ITextRange(me);
796 if (!This->reOle)
797 return CO_E_RELEASED;
799 return range_Collapse(bStart, &This->start, &This->end);
802 static HRESULT WINAPI ITextRange_fnExpand(ITextRange *me, LONG Unit, LONG *pDelta)
804 ITextRangeImpl *This = impl_from_ITextRange(me);
805 if (!This->reOle)
806 return CO_E_RELEASED;
808 FIXME("not implemented %p\n", This);
809 return E_NOTIMPL;
812 static HRESULT WINAPI ITextRange_fnGetIndex(ITextRange *me, LONG Unit, LONG *pIndex)
814 ITextRangeImpl *This = impl_from_ITextRange(me);
815 if (!This->reOle)
816 return CO_E_RELEASED;
818 FIXME("not implemented %p\n", This);
819 return E_NOTIMPL;
822 static HRESULT WINAPI ITextRange_fnSetIndex(ITextRange *me, LONG Unit, LONG Index,
823 LONG Extend)
825 ITextRangeImpl *This = impl_from_ITextRange(me);
826 if (!This->reOle)
827 return CO_E_RELEASED;
829 FIXME("not implemented %p\n", This);
830 return E_NOTIMPL;
833 static HRESULT WINAPI ITextRange_fnSetRange(ITextRange *me, LONG cpActive, LONG cpOther)
835 ITextRangeImpl *This = impl_from_ITextRange(me);
836 if (!This->reOle)
837 return CO_E_RELEASED;
839 FIXME("not implemented %p\n", This);
840 return E_NOTIMPL;
843 static HRESULT WINAPI ITextRange_fnInRange(ITextRange *me, ITextRange *pRange, LONG *pb)
845 ITextRangeImpl *This = impl_from_ITextRange(me);
846 if (!This->reOle)
847 return CO_E_RELEASED;
849 FIXME("not implemented %p\n", This);
850 return E_NOTIMPL;
853 static HRESULT WINAPI ITextRange_fnInStory(ITextRange *me, ITextRange *pRange, LONG *pb)
855 ITextRangeImpl *This = impl_from_ITextRange(me);
856 if (!This->reOle)
857 return CO_E_RELEASED;
859 FIXME("not implemented %p\n", This);
860 return E_NOTIMPL;
863 static HRESULT WINAPI ITextRange_fnIsEqual(ITextRange *me, ITextRange *pRange, LONG *pb)
865 ITextRangeImpl *This = impl_from_ITextRange(me);
866 if (!This->reOle)
867 return CO_E_RELEASED;
869 FIXME("not implemented %p\n", This);
870 return E_NOTIMPL;
873 static HRESULT WINAPI ITextRange_fnSelect(ITextRange *me)
875 ITextRangeImpl *This = impl_from_ITextRange(me);
876 if (!This->reOle)
877 return CO_E_RELEASED;
879 FIXME("not implemented %p\n", This);
880 return E_NOTIMPL;
883 static HRESULT WINAPI ITextRange_fnStartOf(ITextRange *me, LONG Unit, LONG Extend,
884 LONG *pDelta)
886 ITextRangeImpl *This = impl_from_ITextRange(me);
887 if (!This->reOle)
888 return CO_E_RELEASED;
890 FIXME("not implemented %p\n", This);
891 return E_NOTIMPL;
894 static HRESULT WINAPI ITextRange_fnEndOf(ITextRange *me, LONG Unit, LONG Extend,
895 LONG *pDelta)
897 ITextRangeImpl *This = impl_from_ITextRange(me);
898 if (!This->reOle)
899 return CO_E_RELEASED;
901 FIXME("not implemented %p\n", This);
902 return E_NOTIMPL;
905 static HRESULT WINAPI ITextRange_fnMove(ITextRange *me, LONG Unit, LONG Count, LONG *pDelta)
907 ITextRangeImpl *This = impl_from_ITextRange(me);
908 if (!This->reOle)
909 return CO_E_RELEASED;
911 FIXME("not implemented %p\n", This);
912 return E_NOTIMPL;
915 static HRESULT WINAPI ITextRange_fnMoveStart(ITextRange *me, LONG Unit, LONG Count,
916 LONG *pDelta)
918 ITextRangeImpl *This = impl_from_ITextRange(me);
919 if (!This->reOle)
920 return CO_E_RELEASED;
922 FIXME("not implemented %p\n", This);
923 return E_NOTIMPL;
926 static HRESULT WINAPI ITextRange_fnMoveEnd(ITextRange *me, LONG Unit, LONG Count,
927 LONG *pDelta)
929 ITextRangeImpl *This = impl_from_ITextRange(me);
930 if (!This->reOle)
931 return CO_E_RELEASED;
933 FIXME("not implemented %p\n", This);
934 return E_NOTIMPL;
937 static HRESULT WINAPI ITextRange_fnMoveWhile(ITextRange *me, VARIANT *Cset, LONG Count,
938 LONG *pDelta)
940 ITextRangeImpl *This = impl_from_ITextRange(me);
941 if (!This->reOle)
942 return CO_E_RELEASED;
944 FIXME("not implemented %p\n", This);
945 return E_NOTIMPL;
948 static HRESULT WINAPI ITextRange_fnMoveStartWhile(ITextRange *me, VARIANT *Cset, LONG Count,
949 LONG *pDelta)
951 ITextRangeImpl *This = impl_from_ITextRange(me);
952 if (!This->reOle)
953 return CO_E_RELEASED;
955 FIXME("not implemented %p\n", This);
956 return E_NOTIMPL;
959 static HRESULT WINAPI ITextRange_fnMoveEndWhile(ITextRange *me, VARIANT *Cset, LONG Count,
960 LONG *pDelta)
962 ITextRangeImpl *This = impl_from_ITextRange(me);
963 if (!This->reOle)
964 return CO_E_RELEASED;
966 FIXME("not implemented %p\n", This);
967 return E_NOTIMPL;
970 static HRESULT WINAPI ITextRange_fnMoveUntil(ITextRange *me, VARIANT *Cset, LONG Count,
971 LONG *pDelta)
973 ITextRangeImpl *This = impl_from_ITextRange(me);
974 if (!This->reOle)
975 return CO_E_RELEASED;
977 FIXME("not implemented %p\n", This);
978 return E_NOTIMPL;
981 static HRESULT WINAPI ITextRange_fnMoveStartUntil(ITextRange *me, VARIANT *Cset, LONG Count,
982 LONG *pDelta)
984 ITextRangeImpl *This = impl_from_ITextRange(me);
985 if (!This->reOle)
986 return CO_E_RELEASED;
988 FIXME("not implemented %p\n", This);
989 return E_NOTIMPL;
992 static HRESULT WINAPI ITextRange_fnMoveEndUntil(ITextRange *me, VARIANT *Cset, LONG Count,
993 LONG *pDelta)
995 ITextRangeImpl *This = impl_from_ITextRange(me);
996 if (!This->reOle)
997 return CO_E_RELEASED;
999 FIXME("not implemented %p\n", This);
1000 return E_NOTIMPL;
1003 static HRESULT WINAPI ITextRange_fnFindText(ITextRange *me, BSTR bstr, LONG cch, LONG Flags,
1004 LONG *pLength)
1006 ITextRangeImpl *This = impl_from_ITextRange(me);
1007 if (!This->reOle)
1008 return CO_E_RELEASED;
1010 FIXME("not implemented %p\n", This);
1011 return E_NOTIMPL;
1014 static HRESULT WINAPI ITextRange_fnFindTextStart(ITextRange *me, BSTR bstr, LONG cch,
1015 LONG Flags, LONG *pLength)
1017 ITextRangeImpl *This = impl_from_ITextRange(me);
1018 if (!This->reOle)
1019 return CO_E_RELEASED;
1021 FIXME("not implemented %p\n", This);
1022 return E_NOTIMPL;
1025 static HRESULT WINAPI ITextRange_fnFindTextEnd(ITextRange *me, BSTR bstr, LONG cch,
1026 LONG Flags, LONG *pLength)
1028 ITextRangeImpl *This = impl_from_ITextRange(me);
1029 if (!This->reOle)
1030 return CO_E_RELEASED;
1032 FIXME("not implemented %p\n", This);
1033 return E_NOTIMPL;
1036 static HRESULT WINAPI ITextRange_fnDelete(ITextRange *me, LONG Unit, LONG Count,
1037 LONG *pDelta)
1039 ITextRangeImpl *This = impl_from_ITextRange(me);
1040 if (!This->reOle)
1041 return CO_E_RELEASED;
1043 FIXME("not implemented %p\n", This);
1044 return E_NOTIMPL;
1047 static HRESULT WINAPI ITextRange_fnCut(ITextRange *me, VARIANT *pVar)
1049 ITextRangeImpl *This = impl_from_ITextRange(me);
1050 if (!This->reOle)
1051 return CO_E_RELEASED;
1053 FIXME("not implemented %p\n", This);
1054 return E_NOTIMPL;
1057 static HRESULT WINAPI ITextRange_fnCopy(ITextRange *me, VARIANT *pVar)
1059 ITextRangeImpl *This = impl_from_ITextRange(me);
1060 if (!This->reOle)
1061 return CO_E_RELEASED;
1063 FIXME("not implemented %p\n", This);
1064 return E_NOTIMPL;
1067 static HRESULT WINAPI ITextRange_fnPaste(ITextRange *me, VARIANT *pVar, LONG Format)
1069 ITextRangeImpl *This = impl_from_ITextRange(me);
1070 if (!This->reOle)
1071 return CO_E_RELEASED;
1073 FIXME("not implemented %p\n", This);
1074 return E_NOTIMPL;
1077 static HRESULT WINAPI ITextRange_fnCanPaste(ITextRange *me, VARIANT *pVar, LONG Format,
1078 LONG *pb)
1080 ITextRangeImpl *This = impl_from_ITextRange(me);
1081 if (!This->reOle)
1082 return CO_E_RELEASED;
1084 FIXME("not implemented %p\n", This);
1085 return E_NOTIMPL;
1088 static HRESULT WINAPI ITextRange_fnCanEdit(ITextRange *me, LONG *pb)
1090 ITextRangeImpl *This = impl_from_ITextRange(me);
1091 if (!This->reOle)
1092 return CO_E_RELEASED;
1094 FIXME("not implemented %p\n", This);
1095 return E_NOTIMPL;
1098 static HRESULT WINAPI ITextRange_fnChangeCase(ITextRange *me, LONG Type)
1100 ITextRangeImpl *This = impl_from_ITextRange(me);
1101 if (!This->reOle)
1102 return CO_E_RELEASED;
1104 FIXME("not implemented %p\n", This);
1105 return E_NOTIMPL;
1108 static HRESULT WINAPI ITextRange_fnGetPoint(ITextRange *me, LONG Type, LONG *cx, LONG *cy)
1110 ITextRangeImpl *This = impl_from_ITextRange(me);
1111 if (!This->reOle)
1112 return CO_E_RELEASED;
1114 FIXME("not implemented %p\n", This);
1115 return E_NOTIMPL;
1118 static HRESULT WINAPI ITextRange_fnSetPoint(ITextRange *me, LONG x, LONG y, LONG Type,
1119 LONG Extend)
1121 ITextRangeImpl *This = impl_from_ITextRange(me);
1122 if (!This->reOle)
1123 return CO_E_RELEASED;
1125 FIXME("not implemented %p\n", This);
1126 return E_NOTIMPL;
1129 static HRESULT WINAPI ITextRange_fnScrollIntoView(ITextRange *me, LONG Value)
1131 ITextRangeImpl *This = impl_from_ITextRange(me);
1132 if (!This->reOle)
1133 return CO_E_RELEASED;
1135 FIXME("not implemented %p\n", This);
1136 return E_NOTIMPL;
1139 static HRESULT WINAPI ITextRange_fnGetEmbeddedObject(ITextRange *me, IUnknown **ppv)
1141 ITextRangeImpl *This = impl_from_ITextRange(me);
1142 if (!This->reOle)
1143 return CO_E_RELEASED;
1145 FIXME("not implemented %p\n", This);
1146 return E_NOTIMPL;
1149 static const ITextRangeVtbl trvt = {
1150 ITextRange_fnQueryInterface,
1151 ITextRange_fnAddRef,
1152 ITextRange_fnRelease,
1153 ITextRange_fnGetTypeInfoCount,
1154 ITextRange_fnGetTypeInfo,
1155 ITextRange_fnGetIDsOfNames,
1156 ITextRange_fnInvoke,
1157 ITextRange_fnGetText,
1158 ITextRange_fnSetText,
1159 ITextRange_fnGetChar,
1160 ITextRange_fnSetChar,
1161 ITextRange_fnGetDuplicate,
1162 ITextRange_fnGetFormattedText,
1163 ITextRange_fnSetFormattedText,
1164 ITextRange_fnGetStart,
1165 ITextRange_fnSetStart,
1166 ITextRange_fnGetEnd,
1167 ITextRange_fnSetEnd,
1168 ITextRange_fnGetFont,
1169 ITextRange_fnSetFont,
1170 ITextRange_fnGetPara,
1171 ITextRange_fnSetPara,
1172 ITextRange_fnGetStoryLength,
1173 ITextRange_fnGetStoryType,
1174 ITextRange_fnCollapse,
1175 ITextRange_fnExpand,
1176 ITextRange_fnGetIndex,
1177 ITextRange_fnSetIndex,
1178 ITextRange_fnSetRange,
1179 ITextRange_fnInRange,
1180 ITextRange_fnInStory,
1181 ITextRange_fnIsEqual,
1182 ITextRange_fnSelect,
1183 ITextRange_fnStartOf,
1184 ITextRange_fnEndOf,
1185 ITextRange_fnMove,
1186 ITextRange_fnMoveStart,
1187 ITextRange_fnMoveEnd,
1188 ITextRange_fnMoveWhile,
1189 ITextRange_fnMoveStartWhile,
1190 ITextRange_fnMoveEndWhile,
1191 ITextRange_fnMoveUntil,
1192 ITextRange_fnMoveStartUntil,
1193 ITextRange_fnMoveEndUntil,
1194 ITextRange_fnFindText,
1195 ITextRange_fnFindTextStart,
1196 ITextRange_fnFindTextEnd,
1197 ITextRange_fnDelete,
1198 ITextRange_fnCut,
1199 ITextRange_fnCopy,
1200 ITextRange_fnPaste,
1201 ITextRange_fnCanPaste,
1202 ITextRange_fnCanEdit,
1203 ITextRange_fnChangeCase,
1204 ITextRange_fnGetPoint,
1205 ITextRange_fnSetPoint,
1206 ITextRange_fnScrollIntoView,
1207 ITextRange_fnGetEmbeddedObject
1209 /* ITextRange interface */
1211 static HRESULT WINAPI
1212 ITextDocument_fnQueryInterface(ITextDocument* me, REFIID riid,
1213 void** ppvObject)
1215 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1216 return IRichEditOle_QueryInterface(&This->IRichEditOle_iface, riid, ppvObject);
1219 static ULONG WINAPI
1220 ITextDocument_fnAddRef(ITextDocument* me)
1222 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1223 return IRichEditOle_AddRef(&This->IRichEditOle_iface);
1226 static ULONG WINAPI
1227 ITextDocument_fnRelease(ITextDocument* me)
1229 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1230 return IRichEditOle_Release(&This->IRichEditOle_iface);
1233 static HRESULT WINAPI
1234 ITextDocument_fnGetTypeInfoCount(ITextDocument* me,
1235 UINT* pctinfo)
1237 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1238 FIXME("stub %p\n",This);
1239 return E_NOTIMPL;
1242 static HRESULT WINAPI
1243 ITextDocument_fnGetTypeInfo(ITextDocument* me, UINT iTInfo, LCID lcid,
1244 ITypeInfo** ppTInfo)
1246 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1247 FIXME("stub %p\n",This);
1248 return E_NOTIMPL;
1251 static HRESULT WINAPI
1252 ITextDocument_fnGetIDsOfNames(ITextDocument* me, REFIID riid,
1253 LPOLESTR* rgszNames, UINT cNames, LCID lcid, DISPID* rgDispId)
1255 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1256 FIXME("stub %p\n",This);
1257 return E_NOTIMPL;
1260 static HRESULT WINAPI
1261 ITextDocument_fnInvoke(ITextDocument* me, DISPID dispIdMember,
1262 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS* pDispParams,
1263 VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr)
1265 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1266 FIXME("stub %p\n",This);
1267 return E_NOTIMPL;
1270 static HRESULT WINAPI
1271 ITextDocument_fnGetName(ITextDocument* me, BSTR* pName)
1273 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1274 FIXME("stub %p\n",This);
1275 return E_NOTIMPL;
1278 static HRESULT WINAPI
1279 ITextDocument_fnGetSelection(ITextDocument* me, ITextSelection** ppSel)
1281 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1282 TRACE("(%p)\n", me);
1284 if(!ppSel)
1285 return E_INVALIDARG;
1286 *ppSel = &This->txtSel->ITextSelection_iface;
1287 ITextSelection_AddRef(*ppSel);
1288 return S_OK;
1291 static HRESULT WINAPI
1292 ITextDocument_fnGetStoryCount(ITextDocument* me, LONG* pCount)
1294 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1295 FIXME("stub %p\n",This);
1296 return E_NOTIMPL;
1299 static HRESULT WINAPI
1300 ITextDocument_fnGetStoryRanges(ITextDocument* me,
1301 ITextStoryRanges** ppStories)
1303 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1304 FIXME("stub %p\n",This);
1305 return E_NOTIMPL;
1308 static HRESULT WINAPI
1309 ITextDocument_fnGetSaved(ITextDocument* me, LONG* pValue)
1311 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1312 FIXME("stub %p\n",This);
1313 return E_NOTIMPL;
1316 static HRESULT WINAPI
1317 ITextDocument_fnSetSaved(ITextDocument* me, LONG Value)
1319 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1320 FIXME("stub %p\n",This);
1321 return E_NOTIMPL;
1324 static HRESULT WINAPI
1325 ITextDocument_fnGetDefaultTabStop(ITextDocument* me, float* pValue)
1327 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1328 FIXME("stub %p\n",This);
1329 return E_NOTIMPL;
1332 static HRESULT WINAPI
1333 ITextDocument_fnSetDefaultTabStop(ITextDocument* me, float Value)
1335 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1336 FIXME("stub %p\n",This);
1337 return E_NOTIMPL;
1340 static HRESULT WINAPI
1341 ITextDocument_fnNew(ITextDocument* me)
1343 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1344 FIXME("stub %p\n",This);
1345 return E_NOTIMPL;
1348 static HRESULT WINAPI
1349 ITextDocument_fnOpen(ITextDocument* me, VARIANT* pVar, LONG Flags,
1350 LONG CodePage)
1352 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1353 FIXME("stub %p\n",This);
1354 return E_NOTIMPL;
1357 static HRESULT WINAPI
1358 ITextDocument_fnSave(ITextDocument* me, VARIANT* pVar, LONG Flags,
1359 LONG CodePage)
1361 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1362 FIXME("stub %p\n",This);
1363 return E_NOTIMPL;
1366 static HRESULT WINAPI
1367 ITextDocument_fnFreeze(ITextDocument* me, LONG* pCount)
1369 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1370 FIXME("stub %p\n",This);
1371 return E_NOTIMPL;
1374 static HRESULT WINAPI
1375 ITextDocument_fnUnfreeze(ITextDocument* me, LONG* pCount)
1377 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1378 FIXME("stub %p\n",This);
1379 return E_NOTIMPL;
1382 static HRESULT WINAPI
1383 ITextDocument_fnBeginEditCollection(ITextDocument* me)
1385 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1386 FIXME("stub %p\n",This);
1387 return E_NOTIMPL;
1390 static HRESULT WINAPI
1391 ITextDocument_fnEndEditCollection(ITextDocument* me)
1393 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1394 FIXME("stub %p\n",This);
1395 return E_NOTIMPL;
1398 static HRESULT WINAPI
1399 ITextDocument_fnUndo(ITextDocument* me, LONG Count, LONG* prop)
1401 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1402 FIXME("stub %p\n",This);
1403 return E_NOTIMPL;
1406 static HRESULT WINAPI
1407 ITextDocument_fnRedo(ITextDocument* me, LONG Count, LONG* prop)
1409 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1410 FIXME("stub %p\n",This);
1411 return E_NOTIMPL;
1414 static HRESULT CreateITextRange(IRichEditOleImpl *reOle, LONG start, LONG end, ITextRange** ppRange)
1416 ITextRangeImpl *txtRge = heap_alloc(sizeof(ITextRangeImpl));
1418 if (!txtRge)
1419 return E_OUTOFMEMORY;
1420 txtRge->ITextRange_iface.lpVtbl = &trvt;
1421 txtRge->ref = 1;
1422 txtRge->reOle = reOle;
1423 txtRge->start = start;
1424 txtRge->end = end;
1425 list_add_head(&reOle->rangelist, &txtRge->entry);
1426 *ppRange = &txtRge->ITextRange_iface;
1427 return S_OK;
1430 static HRESULT WINAPI
1431 ITextDocument_fnRange(ITextDocument* me, LONG cp1, LONG cp2,
1432 ITextRange** ppRange)
1434 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1435 const int len = ME_GetTextLength(This->editor) + 1;
1437 TRACE("%p %p %d %d\n", This, ppRange, cp1, cp2);
1438 if (!ppRange)
1439 return E_INVALIDARG;
1441 cp1 = max(cp1, 0);
1442 cp2 = max(cp2, 0);
1443 cp1 = min(cp1, len);
1444 cp2 = min(cp2, len);
1445 if (cp1 > cp2)
1447 LONG tmp;
1448 tmp = cp1;
1449 cp1 = cp2;
1450 cp2 = tmp;
1452 if (cp1 == len)
1453 cp1 = cp2 = len - 1;
1455 return CreateITextRange(This, cp1, cp2, ppRange);
1458 static HRESULT WINAPI
1459 ITextDocument_fnRangeFromPoint(ITextDocument* me, LONG x, LONG y,
1460 ITextRange** ppRange)
1462 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1463 FIXME("stub %p\n",This);
1464 return E_NOTIMPL;
1467 static const ITextDocumentVtbl tdvt = {
1468 ITextDocument_fnQueryInterface,
1469 ITextDocument_fnAddRef,
1470 ITextDocument_fnRelease,
1471 ITextDocument_fnGetTypeInfoCount,
1472 ITextDocument_fnGetTypeInfo,
1473 ITextDocument_fnGetIDsOfNames,
1474 ITextDocument_fnInvoke,
1475 ITextDocument_fnGetName,
1476 ITextDocument_fnGetSelection,
1477 ITextDocument_fnGetStoryCount,
1478 ITextDocument_fnGetStoryRanges,
1479 ITextDocument_fnGetSaved,
1480 ITextDocument_fnSetSaved,
1481 ITextDocument_fnGetDefaultTabStop,
1482 ITextDocument_fnSetDefaultTabStop,
1483 ITextDocument_fnNew,
1484 ITextDocument_fnOpen,
1485 ITextDocument_fnSave,
1486 ITextDocument_fnFreeze,
1487 ITextDocument_fnUnfreeze,
1488 ITextDocument_fnBeginEditCollection,
1489 ITextDocument_fnEndEditCollection,
1490 ITextDocument_fnUndo,
1491 ITextDocument_fnRedo,
1492 ITextDocument_fnRange,
1493 ITextDocument_fnRangeFromPoint
1496 static inline ITextSelectionImpl *impl_from_ITextSelection(ITextSelection *iface)
1498 return CONTAINING_RECORD(iface, ITextSelectionImpl, ITextSelection_iface);
1501 static HRESULT WINAPI ITextSelection_fnQueryInterface(
1502 ITextSelection *me,
1503 REFIID riid,
1504 void **ppvObj)
1506 *ppvObj = NULL;
1507 if (IsEqualGUID(riid, &IID_IUnknown)
1508 || IsEqualGUID(riid, &IID_IDispatch)
1509 || IsEqualGUID(riid, &IID_ITextRange)
1510 || IsEqualGUID(riid, &IID_ITextSelection))
1512 *ppvObj = me;
1513 ITextSelection_AddRef(me);
1514 return S_OK;
1517 return E_NOINTERFACE;
1520 static ULONG WINAPI ITextSelection_fnAddRef(ITextSelection *me)
1522 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1523 return InterlockedIncrement(&This->ref);
1526 static ULONG WINAPI ITextSelection_fnRelease(ITextSelection *me)
1528 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1529 ULONG ref = InterlockedDecrement(&This->ref);
1530 if (ref == 0)
1531 heap_free(This);
1532 return ref;
1535 static HRESULT WINAPI ITextSelection_fnGetTypeInfoCount(ITextSelection *me, UINT *pctinfo)
1537 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1538 if (!This->reOle)
1539 return CO_E_RELEASED;
1541 FIXME("not implemented\n");
1542 return E_NOTIMPL;
1545 static HRESULT WINAPI ITextSelection_fnGetTypeInfo(ITextSelection *me, UINT iTInfo, LCID lcid,
1546 ITypeInfo **ppTInfo)
1548 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1549 if (!This->reOle)
1550 return CO_E_RELEASED;
1552 FIXME("not implemented\n");
1553 return E_NOTIMPL;
1556 static HRESULT WINAPI ITextSelection_fnGetIDsOfNames(ITextSelection *me, REFIID riid,
1557 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
1559 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1560 if (!This->reOle)
1561 return CO_E_RELEASED;
1563 FIXME("not implemented\n");
1564 return E_NOTIMPL;
1567 static HRESULT WINAPI ITextSelection_fnInvoke(
1568 ITextSelection *me,
1569 DISPID dispIdMember,
1570 REFIID riid,
1571 LCID lcid,
1572 WORD wFlags,
1573 DISPPARAMS *pDispParams,
1574 VARIANT *pVarResult,
1575 EXCEPINFO *pExcepInfo,
1576 UINT *puArgErr)
1578 FIXME("not implemented\n");
1579 return E_NOTIMPL;
1582 /*** ITextRange methods ***/
1583 static HRESULT WINAPI ITextSelection_fnGetText(ITextSelection *me, BSTR *pbstr)
1585 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1586 ME_Cursor *start = NULL, *end = NULL;
1587 int nChars, endOfs;
1588 BOOL bEOP;
1590 if (!This->reOle)
1591 return CO_E_RELEASED;
1592 TRACE("%p\n", pbstr);
1593 if (!pbstr)
1594 return E_INVALIDARG;
1596 ME_GetSelection(This->reOle->editor, &start, &end);
1597 endOfs = ME_GetCursorOfs(end);
1598 nChars = endOfs - ME_GetCursorOfs(start);
1599 if (!nChars)
1601 *pbstr = NULL;
1602 return S_OK;
1605 *pbstr = SysAllocStringLen(NULL, nChars);
1606 if (!*pbstr)
1607 return E_OUTOFMEMORY;
1609 bEOP = (end->pRun->next->type == diTextEnd && endOfs > ME_GetTextLength(This->reOle->editor));
1610 ME_GetTextW(This->reOle->editor, *pbstr, nChars, start, nChars, FALSE, bEOP);
1611 TRACE("%s\n", wine_dbgstr_w(*pbstr));
1613 return S_OK;
1616 static HRESULT WINAPI ITextSelection_fnSetText(ITextSelection *me, BSTR bstr)
1618 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1619 if (!This->reOle)
1620 return CO_E_RELEASED;
1622 FIXME("not implemented\n");
1623 return E_NOTIMPL;
1626 static HRESULT WINAPI ITextSelection_fnGetChar(ITextSelection *me, LONG *pch)
1628 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1629 ME_Cursor *start = NULL, *end = NULL;
1631 if (!This->reOle)
1632 return CO_E_RELEASED;
1633 TRACE("%p\n", pch);
1634 if (!pch)
1635 return E_INVALIDARG;
1637 ME_GetSelection(This->reOle->editor, &start, &end);
1638 return range_GetChar(This->reOle->editor, start, pch);
1641 static HRESULT WINAPI ITextSelection_fnSetChar(ITextSelection *me, LONG ch)
1643 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1644 if (!This->reOle)
1645 return CO_E_RELEASED;
1647 FIXME("not implemented\n");
1648 return E_NOTIMPL;
1651 static HRESULT WINAPI ITextSelection_fnGetDuplicate(ITextSelection *me, ITextRange **ppRange)
1653 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1654 if (!This->reOle)
1655 return CO_E_RELEASED;
1657 FIXME("not implemented\n");
1658 return E_NOTIMPL;
1661 static HRESULT WINAPI ITextSelection_fnGetFormattedText(ITextSelection *me, ITextRange **ppRange)
1663 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1664 if (!This->reOle)
1665 return CO_E_RELEASED;
1667 FIXME("not implemented\n");
1668 return E_NOTIMPL;
1671 static HRESULT WINAPI ITextSelection_fnSetFormattedText(ITextSelection *me, ITextRange *pRange)
1673 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1674 if (!This->reOle)
1675 return CO_E_RELEASED;
1677 FIXME("not implemented\n");
1678 return E_NOTIMPL;
1681 static HRESULT WINAPI ITextSelection_fnGetStart(ITextSelection *me, LONG *pcpFirst)
1683 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1684 LONG lim;
1685 if (!This->reOle)
1686 return CO_E_RELEASED;
1688 if (!pcpFirst)
1689 return E_INVALIDARG;
1690 ME_GetSelectionOfs(This->reOle->editor, pcpFirst, &lim);
1691 TRACE("%d\n", *pcpFirst);
1692 return S_OK;
1695 static HRESULT WINAPI ITextSelection_fnSetStart(ITextSelection *me, LONG cpFirst)
1697 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1698 if (!This->reOle)
1699 return CO_E_RELEASED;
1701 FIXME("not implemented\n");
1702 return E_NOTIMPL;
1705 static HRESULT WINAPI ITextSelection_fnGetEnd(ITextSelection *me, LONG *pcpLim)
1707 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1708 LONG first;
1709 if (!This->reOle)
1710 return CO_E_RELEASED;
1712 if (!pcpLim)
1713 return E_INVALIDARG;
1714 ME_GetSelectionOfs(This->reOle->editor, &first, pcpLim);
1715 TRACE("%d\n", *pcpLim);
1716 return S_OK;
1719 static HRESULT WINAPI ITextSelection_fnSetEnd(ITextSelection *me, LONG cpLim)
1721 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1722 if (!This->reOle)
1723 return CO_E_RELEASED;
1725 FIXME("not implemented\n");
1726 return E_NOTIMPL;
1729 static HRESULT WINAPI ITextSelection_fnGetFont(ITextSelection *me, ITextFont **pFont)
1731 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1732 if (!This->reOle)
1733 return CO_E_RELEASED;
1735 FIXME("not implemented\n");
1736 return E_NOTIMPL;
1739 static HRESULT WINAPI ITextSelection_fnSetFont(ITextSelection *me, ITextFont *pFont)
1741 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1742 if (!This->reOle)
1743 return CO_E_RELEASED;
1745 FIXME("not implemented\n");
1746 return E_NOTIMPL;
1749 static HRESULT WINAPI ITextSelection_fnGetPara(ITextSelection *me, ITextPara **ppPara)
1751 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1752 if (!This->reOle)
1753 return CO_E_RELEASED;
1755 FIXME("not implemented\n");
1756 return E_NOTIMPL;
1759 static HRESULT WINAPI ITextSelection_fnSetPara(ITextSelection *me, ITextPara *pPara)
1761 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1762 if (!This->reOle)
1763 return CO_E_RELEASED;
1765 FIXME("not implemented\n");
1766 return E_NOTIMPL;
1769 static HRESULT WINAPI ITextSelection_fnGetStoryLength(ITextSelection *me, LONG *pcch)
1771 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1772 if (!This->reOle)
1773 return CO_E_RELEASED;
1775 FIXME("not implemented\n");
1776 return E_NOTIMPL;
1779 static HRESULT WINAPI ITextSelection_fnGetStoryType(ITextSelection *me, LONG *pValue)
1781 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1782 if (!This->reOle)
1783 return CO_E_RELEASED;
1785 FIXME("not implemented\n");
1786 return E_NOTIMPL;
1789 static HRESULT WINAPI ITextSelection_fnCollapse(ITextSelection *me, LONG bStart)
1791 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1792 LONG start, end;
1793 HRESULT hres;
1794 if (!This->reOle)
1795 return CO_E_RELEASED;
1797 ME_GetSelectionOfs(This->reOle->editor, &start, &end);
1798 hres = range_Collapse(bStart, &start, &end);
1799 if (SUCCEEDED(hres))
1800 ME_SetSelection(This->reOle->editor, start, end);
1801 return hres;
1804 static HRESULT WINAPI ITextSelection_fnExpand(ITextSelection *me, LONG Unit, LONG *pDelta)
1806 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1807 if (!This->reOle)
1808 return CO_E_RELEASED;
1810 FIXME("not implemented\n");
1811 return E_NOTIMPL;
1814 static HRESULT WINAPI ITextSelection_fnGetIndex(ITextSelection *me, LONG Unit, LONG *pIndex)
1816 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1817 if (!This->reOle)
1818 return CO_E_RELEASED;
1820 FIXME("not implemented\n");
1821 return E_NOTIMPL;
1824 static HRESULT WINAPI ITextSelection_fnSetIndex(ITextSelection *me, LONG Unit, LONG Index,
1825 LONG Extend)
1827 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1828 if (!This->reOle)
1829 return CO_E_RELEASED;
1831 FIXME("not implemented\n");
1832 return E_NOTIMPL;
1835 static HRESULT WINAPI ITextSelection_fnSetRange(ITextSelection *me, LONG cpActive, LONG cpOther)
1837 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1838 if (!This->reOle)
1839 return CO_E_RELEASED;
1841 FIXME("not implemented\n");
1842 return E_NOTIMPL;
1845 static HRESULT WINAPI ITextSelection_fnInRange(ITextSelection *me, ITextRange *pRange, LONG *pb)
1847 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1848 if (!This->reOle)
1849 return CO_E_RELEASED;
1851 FIXME("not implemented\n");
1852 return E_NOTIMPL;
1855 static HRESULT WINAPI ITextSelection_fnInStory(ITextSelection *me, ITextRange *pRange, LONG *pb)
1857 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1858 if (!This->reOle)
1859 return CO_E_RELEASED;
1861 FIXME("not implemented\n");
1862 return E_NOTIMPL;
1865 static HRESULT WINAPI ITextSelection_fnIsEqual(ITextSelection *me, ITextRange *pRange, LONG *pb)
1867 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1868 if (!This->reOle)
1869 return CO_E_RELEASED;
1871 FIXME("not implemented\n");
1872 return E_NOTIMPL;
1875 static HRESULT WINAPI ITextSelection_fnSelect(ITextSelection *me)
1877 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1878 if (!This->reOle)
1879 return CO_E_RELEASED;
1881 FIXME("not implemented\n");
1882 return E_NOTIMPL;
1885 static HRESULT WINAPI ITextSelection_fnStartOf(ITextSelection *me, LONG Unit, LONG Extend,
1886 LONG *pDelta)
1888 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1889 if (!This->reOle)
1890 return CO_E_RELEASED;
1892 FIXME("not implemented\n");
1893 return E_NOTIMPL;
1896 static HRESULT WINAPI ITextSelection_fnEndOf(ITextSelection *me, LONG Unit, LONG Extend,
1897 LONG *pDelta)
1899 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1900 if (!This->reOle)
1901 return CO_E_RELEASED;
1903 FIXME("not implemented\n");
1904 return E_NOTIMPL;
1907 static HRESULT WINAPI ITextSelection_fnMove(ITextSelection *me, LONG Unit, LONG Count, LONG *pDelta)
1909 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1910 if (!This->reOle)
1911 return CO_E_RELEASED;
1913 FIXME("not implemented\n");
1914 return E_NOTIMPL;
1917 static HRESULT WINAPI ITextSelection_fnMoveStart(ITextSelection *me, LONG Unit, LONG Count,
1918 LONG *pDelta)
1920 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1921 if (!This->reOle)
1922 return CO_E_RELEASED;
1924 FIXME("not implemented\n");
1925 return E_NOTIMPL;
1928 static HRESULT WINAPI ITextSelection_fnMoveEnd(ITextSelection *me, LONG Unit, LONG Count,
1929 LONG *pDelta)
1931 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1932 if (!This->reOle)
1933 return CO_E_RELEASED;
1935 FIXME("not implemented\n");
1936 return E_NOTIMPL;
1939 static HRESULT WINAPI ITextSelection_fnMoveWhile(ITextSelection *me, VARIANT *Cset, LONG Count,
1940 LONG *pDelta)
1942 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1943 if (!This->reOle)
1944 return CO_E_RELEASED;
1946 FIXME("not implemented\n");
1947 return E_NOTIMPL;
1950 static HRESULT WINAPI ITextSelection_fnMoveStartWhile(ITextSelection *me, VARIANT *Cset, LONG Count,
1951 LONG *pDelta)
1953 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1954 if (!This->reOle)
1955 return CO_E_RELEASED;
1957 FIXME("not implemented\n");
1958 return E_NOTIMPL;
1961 static HRESULT WINAPI ITextSelection_fnMoveEndWhile(ITextSelection *me, VARIANT *Cset, LONG Count,
1962 LONG *pDelta)
1964 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1965 if (!This->reOle)
1966 return CO_E_RELEASED;
1968 FIXME("not implemented\n");
1969 return E_NOTIMPL;
1972 static HRESULT WINAPI ITextSelection_fnMoveUntil(ITextSelection *me, VARIANT *Cset, LONG Count,
1973 LONG *pDelta)
1975 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1976 if (!This->reOle)
1977 return CO_E_RELEASED;
1979 FIXME("not implemented\n");
1980 return E_NOTIMPL;
1983 static HRESULT WINAPI ITextSelection_fnMoveStartUntil(ITextSelection *me, VARIANT *Cset, LONG Count,
1984 LONG *pDelta)
1986 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1987 if (!This->reOle)
1988 return CO_E_RELEASED;
1990 FIXME("not implemented\n");
1991 return E_NOTIMPL;
1994 static HRESULT WINAPI ITextSelection_fnMoveEndUntil(ITextSelection *me, VARIANT *Cset, LONG Count,
1995 LONG *pDelta)
1997 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1998 if (!This->reOle)
1999 return CO_E_RELEASED;
2001 FIXME("not implemented\n");
2002 return E_NOTIMPL;
2005 static HRESULT WINAPI ITextSelection_fnFindText(ITextSelection *me, BSTR bstr, LONG cch, LONG Flags,
2006 LONG *pLength)
2008 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2009 if (!This->reOle)
2010 return CO_E_RELEASED;
2012 FIXME("not implemented\n");
2013 return E_NOTIMPL;
2016 static HRESULT WINAPI ITextSelection_fnFindTextStart(ITextSelection *me, BSTR bstr, LONG cch,
2017 LONG Flags, LONG *pLength)
2019 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2020 if (!This->reOle)
2021 return CO_E_RELEASED;
2023 FIXME("not implemented\n");
2024 return E_NOTIMPL;
2027 static HRESULT WINAPI ITextSelection_fnFindTextEnd(ITextSelection *me, BSTR bstr, LONG cch,
2028 LONG Flags, LONG *pLength)
2030 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2031 if (!This->reOle)
2032 return CO_E_RELEASED;
2034 FIXME("not implemented\n");
2035 return E_NOTIMPL;
2038 static HRESULT WINAPI ITextSelection_fnDelete(ITextSelection *me, LONG Unit, LONG Count,
2039 LONG *pDelta)
2041 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2042 if (!This->reOle)
2043 return CO_E_RELEASED;
2045 FIXME("not implemented\n");
2046 return E_NOTIMPL;
2049 static HRESULT WINAPI ITextSelection_fnCut(ITextSelection *me, VARIANT *pVar)
2051 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2052 if (!This->reOle)
2053 return CO_E_RELEASED;
2055 FIXME("not implemented\n");
2056 return E_NOTIMPL;
2059 static HRESULT WINAPI ITextSelection_fnCopy(ITextSelection *me, VARIANT *pVar)
2061 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2062 if (!This->reOle)
2063 return CO_E_RELEASED;
2065 FIXME("not implemented\n");
2066 return E_NOTIMPL;
2069 static HRESULT WINAPI ITextSelection_fnPaste(ITextSelection *me, VARIANT *pVar, LONG Format)
2071 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2072 if (!This->reOle)
2073 return CO_E_RELEASED;
2075 FIXME("not implemented\n");
2076 return E_NOTIMPL;
2079 static HRESULT WINAPI ITextSelection_fnCanPaste(ITextSelection *me, VARIANT *pVar, LONG Format,
2080 LONG *pb)
2082 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2083 if (!This->reOle)
2084 return CO_E_RELEASED;
2086 FIXME("not implemented\n");
2087 return E_NOTIMPL;
2090 static HRESULT WINAPI ITextSelection_fnCanEdit(ITextSelection *me, LONG *pb)
2092 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2093 if (!This->reOle)
2094 return CO_E_RELEASED;
2096 FIXME("not implemented\n");
2097 return E_NOTIMPL;
2100 static HRESULT WINAPI ITextSelection_fnChangeCase(ITextSelection *me, LONG Type)
2102 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2103 if (!This->reOle)
2104 return CO_E_RELEASED;
2106 FIXME("not implemented\n");
2107 return E_NOTIMPL;
2110 static HRESULT WINAPI ITextSelection_fnGetPoint(ITextSelection *me, LONG Type, LONG *cx, LONG *cy)
2112 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2113 if (!This->reOle)
2114 return CO_E_RELEASED;
2116 FIXME("not implemented\n");
2117 return E_NOTIMPL;
2120 static HRESULT WINAPI ITextSelection_fnSetPoint(ITextSelection *me, LONG x, LONG y, LONG Type,
2121 LONG Extend)
2123 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2124 if (!This->reOle)
2125 return CO_E_RELEASED;
2127 FIXME("not implemented\n");
2128 return E_NOTIMPL;
2131 static HRESULT WINAPI ITextSelection_fnScrollIntoView(ITextSelection *me, LONG Value)
2133 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2134 if (!This->reOle)
2135 return CO_E_RELEASED;
2137 FIXME("not implemented\n");
2138 return E_NOTIMPL;
2141 static HRESULT WINAPI ITextSelection_fnGetEmbeddedObject(ITextSelection *me, IUnknown **ppv)
2143 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2144 if (!This->reOle)
2145 return CO_E_RELEASED;
2147 FIXME("not implemented\n");
2148 return E_NOTIMPL;
2151 /*** ITextSelection methods ***/
2152 static HRESULT WINAPI ITextSelection_fnGetFlags(ITextSelection *me, LONG *pFlags)
2154 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2155 if (!This->reOle)
2156 return CO_E_RELEASED;
2158 FIXME("not implemented\n");
2159 return E_NOTIMPL;
2162 static HRESULT WINAPI ITextSelection_fnSetFlags(ITextSelection *me, LONG Flags)
2164 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2165 if (!This->reOle)
2166 return CO_E_RELEASED;
2168 FIXME("not implemented\n");
2169 return E_NOTIMPL;
2172 static HRESULT WINAPI ITextSelection_fnGetType(ITextSelection *me, LONG *pType)
2174 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2175 if (!This->reOle)
2176 return CO_E_RELEASED;
2178 FIXME("not implemented\n");
2179 return E_NOTIMPL;
2182 static HRESULT WINAPI ITextSelection_fnMoveLeft(ITextSelection *me, LONG Unit, LONG Count,
2183 LONG Extend, LONG *pDelta)
2185 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2186 if (!This->reOle)
2187 return CO_E_RELEASED;
2189 FIXME("not implemented\n");
2190 return E_NOTIMPL;
2193 static HRESULT WINAPI ITextSelection_fnMoveRight(ITextSelection *me, LONG Unit, LONG Count,
2194 LONG Extend, LONG *pDelta)
2196 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2197 if (!This->reOle)
2198 return CO_E_RELEASED;
2200 FIXME("not implemented\n");
2201 return E_NOTIMPL;
2204 static HRESULT WINAPI ITextSelection_fnMoveUp(ITextSelection *me, LONG Unit, LONG Count,
2205 LONG Extend, LONG *pDelta)
2207 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2208 if (!This->reOle)
2209 return CO_E_RELEASED;
2211 FIXME("not implemented\n");
2212 return E_NOTIMPL;
2215 static HRESULT WINAPI ITextSelection_fnMoveDown(ITextSelection *me, LONG Unit, LONG Count,
2216 LONG Extend, LONG *pDelta)
2218 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2219 if (!This->reOle)
2220 return CO_E_RELEASED;
2222 FIXME("not implemented\n");
2223 return E_NOTIMPL;
2226 static HRESULT WINAPI ITextSelection_fnHomeKey(ITextSelection *me, LONG Unit, LONG Extend,
2227 LONG *pDelta)
2229 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2230 if (!This->reOle)
2231 return CO_E_RELEASED;
2233 FIXME("not implemented\n");
2234 return E_NOTIMPL;
2237 static HRESULT WINAPI ITextSelection_fnEndKey(ITextSelection *me, LONG Unit, LONG Extend,
2238 LONG *pDelta)
2240 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2241 if (!This->reOle)
2242 return CO_E_RELEASED;
2244 FIXME("not implemented\n");
2245 return E_NOTIMPL;
2248 static HRESULT WINAPI ITextSelection_fnTypeText(ITextSelection *me, BSTR bstr)
2250 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2251 if (!This->reOle)
2252 return CO_E_RELEASED;
2254 FIXME("not implemented\n");
2255 return E_NOTIMPL;
2258 static const ITextSelectionVtbl tsvt = {
2259 ITextSelection_fnQueryInterface,
2260 ITextSelection_fnAddRef,
2261 ITextSelection_fnRelease,
2262 ITextSelection_fnGetTypeInfoCount,
2263 ITextSelection_fnGetTypeInfo,
2264 ITextSelection_fnGetIDsOfNames,
2265 ITextSelection_fnInvoke,
2266 ITextSelection_fnGetText,
2267 ITextSelection_fnSetText,
2268 ITextSelection_fnGetChar,
2269 ITextSelection_fnSetChar,
2270 ITextSelection_fnGetDuplicate,
2271 ITextSelection_fnGetFormattedText,
2272 ITextSelection_fnSetFormattedText,
2273 ITextSelection_fnGetStart,
2274 ITextSelection_fnSetStart,
2275 ITextSelection_fnGetEnd,
2276 ITextSelection_fnSetEnd,
2277 ITextSelection_fnGetFont,
2278 ITextSelection_fnSetFont,
2279 ITextSelection_fnGetPara,
2280 ITextSelection_fnSetPara,
2281 ITextSelection_fnGetStoryLength,
2282 ITextSelection_fnGetStoryType,
2283 ITextSelection_fnCollapse,
2284 ITextSelection_fnExpand,
2285 ITextSelection_fnGetIndex,
2286 ITextSelection_fnSetIndex,
2287 ITextSelection_fnSetRange,
2288 ITextSelection_fnInRange,
2289 ITextSelection_fnInStory,
2290 ITextSelection_fnIsEqual,
2291 ITextSelection_fnSelect,
2292 ITextSelection_fnStartOf,
2293 ITextSelection_fnEndOf,
2294 ITextSelection_fnMove,
2295 ITextSelection_fnMoveStart,
2296 ITextSelection_fnMoveEnd,
2297 ITextSelection_fnMoveWhile,
2298 ITextSelection_fnMoveStartWhile,
2299 ITextSelection_fnMoveEndWhile,
2300 ITextSelection_fnMoveUntil,
2301 ITextSelection_fnMoveStartUntil,
2302 ITextSelection_fnMoveEndUntil,
2303 ITextSelection_fnFindText,
2304 ITextSelection_fnFindTextStart,
2305 ITextSelection_fnFindTextEnd,
2306 ITextSelection_fnDelete,
2307 ITextSelection_fnCut,
2308 ITextSelection_fnCopy,
2309 ITextSelection_fnPaste,
2310 ITextSelection_fnCanPaste,
2311 ITextSelection_fnCanEdit,
2312 ITextSelection_fnChangeCase,
2313 ITextSelection_fnGetPoint,
2314 ITextSelection_fnSetPoint,
2315 ITextSelection_fnScrollIntoView,
2316 ITextSelection_fnGetEmbeddedObject,
2317 ITextSelection_fnGetFlags,
2318 ITextSelection_fnSetFlags,
2319 ITextSelection_fnGetType,
2320 ITextSelection_fnMoveLeft,
2321 ITextSelection_fnMoveRight,
2322 ITextSelection_fnMoveUp,
2323 ITextSelection_fnMoveDown,
2324 ITextSelection_fnHomeKey,
2325 ITextSelection_fnEndKey,
2326 ITextSelection_fnTypeText
2329 static ITextSelectionImpl *
2330 CreateTextSelection(IRichEditOleImpl *reOle)
2332 ITextSelectionImpl *txtSel = heap_alloc(sizeof *txtSel);
2333 if (!txtSel)
2334 return NULL;
2336 txtSel->ITextSelection_iface.lpVtbl = &tsvt;
2337 txtSel->ref = 1;
2338 txtSel->reOle = reOle;
2339 return txtSel;
2342 LRESULT CreateIRichEditOle(IUnknown *outer_unk, ME_TextEditor *editor, LPVOID *ppvObj)
2344 IRichEditOleImpl *reo;
2346 reo = heap_alloc(sizeof(IRichEditOleImpl));
2347 if (!reo)
2348 return 0;
2350 reo->IUnknown_inner.lpVtbl = &reo_unk_vtbl;
2351 reo->IRichEditOle_iface.lpVtbl = &revt;
2352 reo->ITextDocument_iface.lpVtbl = &tdvt;
2353 reo->ref = 1;
2354 reo->editor = editor;
2355 reo->txtSel = CreateTextSelection(reo);
2356 if (!reo->txtSel)
2358 heap_free(reo);
2359 return 0;
2361 reo->clientSite = CreateOleClientSite(reo);
2362 if (!reo->clientSite)
2364 ITextSelection_Release(&reo->txtSel->ITextSelection_iface);
2365 heap_free(reo);
2366 return 0;
2368 TRACE("Created %p\n",reo);
2369 list_init(&reo->rangelist);
2370 if (outer_unk)
2371 reo->outer_unk = outer_unk;
2372 else
2373 reo->outer_unk = &reo->IUnknown_inner;
2374 *ppvObj = &reo->IRichEditOle_iface;
2376 return 1;
2379 static void convert_sizel(const ME_Context *c, const SIZEL* szl, SIZE* sz)
2381 /* sizel is in .01 millimeters, sz in pixels */
2382 sz->cx = MulDiv(szl->cx, c->dpi.cx, 2540);
2383 sz->cy = MulDiv(szl->cy, c->dpi.cy, 2540);
2386 /******************************************************************************
2387 * ME_GetOLEObjectSize
2389 * Sets run extent for OLE objects.
2391 void ME_GetOLEObjectSize(const ME_Context *c, ME_Run *run, SIZE *pSize)
2393 IDataObject* ido;
2394 FORMATETC fmt;
2395 STGMEDIUM stgm;
2396 DIBSECTION dibsect;
2397 ENHMETAHEADER emh;
2399 assert(run->nFlags & MERF_GRAPHICS);
2400 assert(run->ole_obj);
2402 if (run->ole_obj->sizel.cx != 0 || run->ole_obj->sizel.cy != 0)
2404 convert_sizel(c, &run->ole_obj->sizel, pSize);
2405 if (c->editor->nZoomNumerator != 0)
2407 pSize->cx = MulDiv(pSize->cx, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
2408 pSize->cy = MulDiv(pSize->cy, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
2410 return;
2413 if (IOleObject_QueryInterface(run->ole_obj->poleobj, &IID_IDataObject, (void**)&ido) != S_OK)
2415 FIXME("Query Interface IID_IDataObject failed!\n");
2416 pSize->cx = pSize->cy = 0;
2417 return;
2419 fmt.cfFormat = CF_BITMAP;
2420 fmt.ptd = NULL;
2421 fmt.dwAspect = DVASPECT_CONTENT;
2422 fmt.lindex = -1;
2423 fmt.tymed = TYMED_GDI;
2424 if (IDataObject_GetData(ido, &fmt, &stgm) != S_OK)
2426 fmt.cfFormat = CF_ENHMETAFILE;
2427 fmt.tymed = TYMED_ENHMF;
2428 if (IDataObject_GetData(ido, &fmt, &stgm) != S_OK)
2430 FIXME("unsupported format\n");
2431 pSize->cx = pSize->cy = 0;
2432 IDataObject_Release(ido);
2433 return;
2437 switch (stgm.tymed)
2439 case TYMED_GDI:
2440 GetObjectW(stgm.u.hBitmap, sizeof(dibsect), &dibsect);
2441 pSize->cx = dibsect.dsBm.bmWidth;
2442 pSize->cy = dibsect.dsBm.bmHeight;
2443 if (!stgm.pUnkForRelease) DeleteObject(stgm.u.hBitmap);
2444 break;
2445 case TYMED_ENHMF:
2446 GetEnhMetaFileHeader(stgm.u.hEnhMetaFile, sizeof(emh), &emh);
2447 pSize->cx = emh.rclBounds.right - emh.rclBounds.left;
2448 pSize->cy = emh.rclBounds.bottom - emh.rclBounds.top;
2449 if (!stgm.pUnkForRelease) DeleteEnhMetaFile(stgm.u.hEnhMetaFile);
2450 break;
2451 default:
2452 FIXME("Unsupported tymed %d\n", stgm.tymed);
2453 break;
2455 IDataObject_Release(ido);
2456 if (c->editor->nZoomNumerator != 0)
2458 pSize->cx = MulDiv(pSize->cx, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
2459 pSize->cy = MulDiv(pSize->cy, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
2463 void ME_DrawOLE(ME_Context *c, int x, int y, ME_Run *run,
2464 ME_Paragraph *para, BOOL selected)
2466 IDataObject* ido;
2467 FORMATETC fmt;
2468 STGMEDIUM stgm;
2469 DIBSECTION dibsect;
2470 ENHMETAHEADER emh;
2471 HDC hMemDC;
2472 SIZE sz;
2473 BOOL has_size;
2475 assert(run->nFlags & MERF_GRAPHICS);
2476 assert(run->ole_obj);
2477 if (IOleObject_QueryInterface(run->ole_obj->poleobj, &IID_IDataObject, (void**)&ido) != S_OK)
2479 FIXME("Couldn't get interface\n");
2480 return;
2482 has_size = run->ole_obj->sizel.cx != 0 || run->ole_obj->sizel.cy != 0;
2483 fmt.cfFormat = CF_BITMAP;
2484 fmt.ptd = NULL;
2485 fmt.dwAspect = DVASPECT_CONTENT;
2486 fmt.lindex = -1;
2487 fmt.tymed = TYMED_GDI;
2488 if (IDataObject_GetData(ido, &fmt, &stgm) != S_OK)
2490 fmt.cfFormat = CF_ENHMETAFILE;
2491 fmt.tymed = TYMED_ENHMF;
2492 if (IDataObject_GetData(ido, &fmt, &stgm) != S_OK)
2494 FIXME("Couldn't get storage medium\n");
2495 IDataObject_Release(ido);
2496 return;
2499 switch (stgm.tymed)
2501 case TYMED_GDI:
2502 GetObjectW(stgm.u.hBitmap, sizeof(dibsect), &dibsect);
2503 hMemDC = CreateCompatibleDC(c->hDC);
2504 SelectObject(hMemDC, stgm.u.hBitmap);
2505 if (has_size)
2507 convert_sizel(c, &run->ole_obj->sizel, &sz);
2508 } else {
2509 sz.cx = MulDiv(dibsect.dsBm.bmWidth, c->dpi.cx, 96);
2510 sz.cy = MulDiv(dibsect.dsBm.bmHeight, c->dpi.cy, 96);
2512 if (c->editor->nZoomNumerator != 0)
2514 sz.cx = MulDiv(sz.cx, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
2515 sz.cy = MulDiv(sz.cy, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
2517 if (sz.cx == dibsect.dsBm.bmWidth && sz.cy == dibsect.dsBm.bmHeight)
2519 BitBlt(c->hDC, x, y - sz.cy,
2520 dibsect.dsBm.bmWidth, dibsect.dsBm.bmHeight,
2521 hMemDC, 0, 0, SRCCOPY);
2522 } else {
2523 StretchBlt(c->hDC, x, y - sz.cy, sz.cx, sz.cy,
2524 hMemDC, 0, 0, dibsect.dsBm.bmWidth,
2525 dibsect.dsBm.bmHeight, SRCCOPY);
2527 DeleteDC(hMemDC);
2528 if (!stgm.pUnkForRelease) DeleteObject(stgm.u.hBitmap);
2529 break;
2530 case TYMED_ENHMF:
2531 GetEnhMetaFileHeader(stgm.u.hEnhMetaFile, sizeof(emh), &emh);
2532 if (has_size)
2534 convert_sizel(c, &run->ole_obj->sizel, &sz);
2535 } else {
2536 sz.cy = MulDiv(emh.rclBounds.bottom - emh.rclBounds.top, c->dpi.cx, 96);
2537 sz.cx = MulDiv(emh.rclBounds.right - emh.rclBounds.left, c->dpi.cy, 96);
2539 if (c->editor->nZoomNumerator != 0)
2541 sz.cx = MulDiv(sz.cx, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
2542 sz.cy = MulDiv(sz.cy, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
2546 RECT rc;
2548 rc.left = x;
2549 rc.top = y - sz.cy;
2550 rc.right = x + sz.cx;
2551 rc.bottom = y;
2552 PlayEnhMetaFile(c->hDC, stgm.u.hEnhMetaFile, &rc);
2554 if (!stgm.pUnkForRelease) DeleteEnhMetaFile(stgm.u.hEnhMetaFile);
2555 break;
2556 default:
2557 FIXME("Unsupported tymed %d\n", stgm.tymed);
2558 selected = FALSE;
2559 break;
2561 if (selected && !c->editor->bHideSelection)
2562 PatBlt(c->hDC, x, y - sz.cy, sz.cx, sz.cy, DSTINVERT);
2563 IDataObject_Release(ido);
2566 void ME_DeleteReObject(REOBJECT* reo)
2568 if (reo->poleobj) IOleObject_Release(reo->poleobj);
2569 if (reo->pstg) IStorage_Release(reo->pstg);
2570 if (reo->polesite) IOleClientSite_Release(reo->polesite);
2571 FREE_OBJ(reo);
2574 void ME_CopyReObject(REOBJECT* dst, const REOBJECT* src)
2576 *dst = *src;
2578 if (dst->poleobj) IOleObject_AddRef(dst->poleobj);
2579 if (dst->pstg) IStorage_AddRef(dst->pstg);
2580 if (dst->polesite) IOleClientSite_AddRef(dst->polesite);
2583 void ME_GetITextDocumentInterface(IRichEditOle *iface, LPVOID *ppvObj)
2585 IRichEditOleImpl *This = impl_from_IRichEditOle(iface);
2586 *ppvObj = &This->ITextDocument_iface;