user32: Add a stub implementation of IsTouchWindow.
[wine/multimedia.git] / dlls / riched20 / richole.c
blob0788125c1b7fd2c578389e6dc6d3957e0722235c
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)
146 DestroyIRichEditOle(&This->IRichEditOle_iface);
147 return ref;
150 static const IUnknownVtbl reo_unk_vtbl =
152 IRichEditOleImpl_inner_fnQueryInterface,
153 IRichEditOleImpl_inner_fnAddRef,
154 IRichEditOleImpl_inner_fnRelease
157 static HRESULT WINAPI
158 IRichEditOle_fnQueryInterface(IRichEditOle *me, REFIID riid, LPVOID *ppvObj)
160 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
161 return IUnknown_QueryInterface(This->outer_unk, riid, ppvObj);
164 static ULONG WINAPI
165 IRichEditOle_fnAddRef(IRichEditOle *me)
167 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
168 return IUnknown_AddRef(This->outer_unk);
171 static ULONG WINAPI
172 IRichEditOle_fnRelease(IRichEditOle *me)
174 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
175 return IUnknown_Release(This->outer_unk);
178 static HRESULT WINAPI
179 IRichEditOle_fnActivateAs(IRichEditOle *me, REFCLSID rclsid, REFCLSID rclsidAs)
181 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
182 FIXME("stub %p\n",This);
183 return E_NOTIMPL;
186 static HRESULT WINAPI
187 IRichEditOle_fnContextSensitiveHelp(IRichEditOle *me, BOOL fEnterMode)
189 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
190 FIXME("stub %p\n",This);
191 return E_NOTIMPL;
194 static HRESULT WINAPI
195 IRichEditOle_fnConvertObject(IRichEditOle *me, LONG iob,
196 REFCLSID rclsidNew, LPCSTR lpstrUserTypeNew)
198 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
199 FIXME("stub %p\n",This);
200 return E_NOTIMPL;
203 static inline IOleClientSiteImpl *impl_from_IOleClientSite(IOleClientSite *iface)
205 return CONTAINING_RECORD(iface, IOleClientSiteImpl, IOleClientSite_iface);
208 static HRESULT WINAPI
209 IOleClientSite_fnQueryInterface(IOleClientSite *me, REFIID riid, LPVOID *ppvObj)
211 TRACE("%p %s\n", me, debugstr_guid(riid) );
213 *ppvObj = NULL;
214 if (IsEqualGUID(riid, &IID_IUnknown) ||
215 IsEqualGUID(riid, &IID_IOleClientSite))
216 *ppvObj = me;
217 if (*ppvObj)
219 IOleClientSite_AddRef(me);
220 return S_OK;
222 FIXME("%p: unhandled interface %s\n", me, debugstr_guid(riid) );
224 return E_NOINTERFACE;
227 static ULONG WINAPI IOleClientSite_fnAddRef(IOleClientSite *iface)
229 IOleClientSiteImpl *This = impl_from_IOleClientSite(iface);
230 return InterlockedIncrement(&This->ref);
233 static ULONG WINAPI IOleClientSite_fnRelease(IOleClientSite *iface)
235 IOleClientSiteImpl *This = impl_from_IOleClientSite(iface);
236 ULONG ref = InterlockedDecrement(&This->ref);
237 if (ref == 0)
238 heap_free(This);
239 return ref;
242 static HRESULT WINAPI IOleClientSite_fnSaveObject(IOleClientSite *iface)
244 IOleClientSiteImpl *This = impl_from_IOleClientSite(iface);
245 if (!This->reOle)
246 return CO_E_RELEASED;
248 FIXME("stub %p\n", iface);
249 return E_NOTIMPL;
253 static HRESULT WINAPI IOleClientSite_fnGetMoniker(IOleClientSite *iface, DWORD dwAssign,
254 DWORD dwWhichMoniker, IMoniker **ppmk)
256 IOleClientSiteImpl *This = impl_from_IOleClientSite(iface);
257 if (!This->reOle)
258 return CO_E_RELEASED;
260 FIXME("stub %p\n", iface);
261 return E_NOTIMPL;
264 static HRESULT WINAPI IOleClientSite_fnGetContainer(IOleClientSite *iface,
265 IOleContainer **ppContainer)
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_fnShowObject(IOleClientSite *iface)
277 IOleClientSiteImpl *This = impl_from_IOleClientSite(iface);
278 if (!This->reOle)
279 return CO_E_RELEASED;
281 FIXME("stub %p\n", iface);
282 return E_NOTIMPL;
285 static HRESULT WINAPI IOleClientSite_fnOnShowWindow(IOleClientSite *iface, BOOL fShow)
287 IOleClientSiteImpl *This = impl_from_IOleClientSite(iface);
288 if (!This->reOle)
289 return CO_E_RELEASED;
291 FIXME("stub %p\n", iface);
292 return E_NOTIMPL;
295 static HRESULT WINAPI IOleClientSite_fnRequestNewObjectLayout(IOleClientSite *iface)
297 IOleClientSiteImpl *This = impl_from_IOleClientSite(iface);
298 if (!This->reOle)
299 return CO_E_RELEASED;
301 FIXME("stub %p\n", iface);
302 return E_NOTIMPL;
305 static const IOleClientSiteVtbl ocst = {
306 IOleClientSite_fnQueryInterface,
307 IOleClientSite_fnAddRef,
308 IOleClientSite_fnRelease,
309 IOleClientSite_fnSaveObject,
310 IOleClientSite_fnGetMoniker,
311 IOleClientSite_fnGetContainer,
312 IOleClientSite_fnShowObject,
313 IOleClientSite_fnOnShowWindow,
314 IOleClientSite_fnRequestNewObjectLayout
317 static IOleClientSiteImpl *
318 CreateOleClientSite(IRichEditOleImpl *reOle)
320 IOleClientSiteImpl *clientSite = heap_alloc(sizeof *clientSite);
321 if (!clientSite)
322 return NULL;
324 clientSite->IOleClientSite_iface.lpVtbl = &ocst;
325 clientSite->ref = 1;
326 clientSite->reOle = reOle;
327 return clientSite;
330 static HRESULT WINAPI
331 IRichEditOle_fnGetClientSite(IRichEditOle *me,
332 LPOLECLIENTSITE *lplpolesite)
334 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
336 TRACE("%p,%p\n",This, lplpolesite);
338 if(!lplpolesite)
339 return E_INVALIDARG;
340 *lplpolesite = &This->clientSite->IOleClientSite_iface;
341 IOleClientSite_AddRef(*lplpolesite);
342 return S_OK;
345 static HRESULT WINAPI
346 IRichEditOle_fnGetClipboardData(IRichEditOle *me, CHARRANGE *lpchrg,
347 DWORD reco, LPDATAOBJECT *lplpdataobj)
349 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
350 ME_Cursor start;
351 int nChars;
353 TRACE("(%p,%p,%d)\n",This, lpchrg, reco);
354 if(!lplpdataobj)
355 return E_INVALIDARG;
356 if(!lpchrg) {
357 int nFrom, nTo, nStartCur = ME_GetSelectionOfs(This->editor, &nFrom, &nTo);
358 start = This->editor->pCursors[nStartCur];
359 nChars = nTo - nFrom;
360 } else {
361 ME_CursorFromCharOfs(This->editor, lpchrg->cpMin, &start);
362 nChars = lpchrg->cpMax - lpchrg->cpMin;
364 return ME_GetDataObject(This->editor, &start, nChars, lplpdataobj);
367 static LONG WINAPI IRichEditOle_fnGetLinkCount(IRichEditOle *me)
369 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
370 FIXME("stub %p\n",This);
371 return E_NOTIMPL;
374 static HRESULT WINAPI
375 IRichEditOle_fnGetObject(IRichEditOle *me, LONG iob,
376 REOBJECT *lpreobject, DWORD dwFlags)
378 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
379 FIXME("stub %p\n",This);
380 return E_NOTIMPL;
383 static LONG WINAPI
384 IRichEditOle_fnGetObjectCount(IRichEditOle *me)
386 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
387 FIXME("stub %p\n",This);
388 return 0;
391 static HRESULT WINAPI
392 IRichEditOle_fnHandsOffStorage(IRichEditOle *me, LONG iob)
394 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
395 FIXME("stub %p\n",This);
396 return E_NOTIMPL;
399 static HRESULT WINAPI
400 IRichEditOle_fnImportDataObject(IRichEditOle *me, LPDATAOBJECT lpdataobj,
401 CLIPFORMAT cf, HGLOBAL hMetaPict)
403 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
404 FIXME("stub %p\n",This);
405 return E_NOTIMPL;
408 static HRESULT WINAPI
409 IRichEditOle_fnInPlaceDeactivate(IRichEditOle *me)
411 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
412 FIXME("stub %p\n",This);
413 return E_NOTIMPL;
416 static HRESULT WINAPI
417 IRichEditOle_fnInsertObject(IRichEditOle *me, REOBJECT *reo)
419 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
420 TRACE("(%p,%p)\n", This, reo);
422 if (reo->cbStruct < sizeof(*reo)) return STG_E_INVALIDPARAMETER;
424 ME_InsertOLEFromCursor(This->editor, reo, 0);
425 ME_CommitUndo(This->editor);
426 ME_UpdateRepaint(This->editor, FALSE);
427 return S_OK;
430 static HRESULT WINAPI IRichEditOle_fnSaveCompleted(IRichEditOle *me, LONG iob,
431 LPSTORAGE lpstg)
433 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
434 FIXME("stub %p\n",This);
435 return E_NOTIMPL;
438 static HRESULT WINAPI
439 IRichEditOle_fnSetDvaspect(IRichEditOle *me, LONG iob, DWORD dvaspect)
441 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
442 FIXME("stub %p\n",This);
443 return E_NOTIMPL;
446 static HRESULT WINAPI IRichEditOle_fnSetHostNames(IRichEditOle *me,
447 LPCSTR lpstrContainerApp, LPCSTR lpstrContainerObj)
449 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
450 FIXME("stub %p %s %s\n",This, lpstrContainerApp, lpstrContainerObj);
451 return E_NOTIMPL;
454 static HRESULT WINAPI
455 IRichEditOle_fnSetLinkAvailable(IRichEditOle *me, LONG iob, BOOL fAvailable)
457 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
458 FIXME("stub %p\n",This);
459 return E_NOTIMPL;
462 static const IRichEditOleVtbl revt = {
463 IRichEditOle_fnQueryInterface,
464 IRichEditOle_fnAddRef,
465 IRichEditOle_fnRelease,
466 IRichEditOle_fnGetClientSite,
467 IRichEditOle_fnGetObjectCount,
468 IRichEditOle_fnGetLinkCount,
469 IRichEditOle_fnGetObject,
470 IRichEditOle_fnInsertObject,
471 IRichEditOle_fnConvertObject,
472 IRichEditOle_fnActivateAs,
473 IRichEditOle_fnSetHostNames,
474 IRichEditOle_fnSetLinkAvailable,
475 IRichEditOle_fnSetDvaspect,
476 IRichEditOle_fnHandsOffStorage,
477 IRichEditOle_fnSaveCompleted,
478 IRichEditOle_fnInPlaceDeactivate,
479 IRichEditOle_fnContextSensitiveHelp,
480 IRichEditOle_fnGetClipboardData,
481 IRichEditOle_fnImportDataObject
484 /* ITextRange interface */
485 static inline ITextRangeImpl *impl_from_ITextRange(ITextRange *iface)
487 return CONTAINING_RECORD(iface, ITextRangeImpl, ITextRange_iface);
490 static HRESULT WINAPI ITextRange_fnQueryInterface(ITextRange *me, REFIID riid, void **ppvObj)
492 *ppvObj = NULL;
493 if (IsEqualGUID(riid, &IID_IUnknown)
494 || IsEqualGUID(riid, &IID_IDispatch)
495 || IsEqualGUID(riid, &IID_ITextRange))
497 *ppvObj = me;
498 ITextRange_AddRef(me);
499 return S_OK;
502 return E_NOINTERFACE;
505 static ULONG WINAPI ITextRange_fnAddRef(ITextRange *me)
507 ITextRangeImpl *This = impl_from_ITextRange(me);
508 return InterlockedIncrement(&This->ref);
511 static ULONG WINAPI ITextRange_fnRelease(ITextRange *me)
513 ITextRangeImpl *This = impl_from_ITextRange(me);
514 ULONG ref = InterlockedDecrement(&This->ref);
516 TRACE ("%p ref=%u\n", This, ref);
517 if (ref == 0)
519 if (This->reOle)
521 list_remove(&This->entry);
522 This->reOle = NULL;
524 heap_free(This);
526 return ref;
529 static HRESULT WINAPI ITextRange_fnGetTypeInfoCount(ITextRange *me, UINT *pctinfo)
531 ITextRangeImpl *This = impl_from_ITextRange(me);
532 if (!This->reOle)
533 return CO_E_RELEASED;
535 FIXME("not implemented %p\n", This);
536 return E_NOTIMPL;
539 static HRESULT WINAPI ITextRange_fnGetTypeInfo(ITextRange *me, UINT iTInfo, LCID lcid,
540 ITypeInfo **ppTInfo)
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_fnGetIDsOfNames(ITextRange *me, REFIID riid, LPOLESTR *rgszNames,
551 UINT cNames, LCID lcid, DISPID *rgDispId)
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_fnInvoke(ITextRange *me, DISPID dispIdMember, REFIID riid,
562 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
563 VARIANT *pVarResult, EXCEPINFO *pExcepInfo,
564 UINT *puArgErr)
566 ITextRangeImpl *This = impl_from_ITextRange(me);
567 if (!This->reOle)
568 return CO_E_RELEASED;
570 FIXME("not implemented %p\n", This);
571 return E_NOTIMPL;
574 static HRESULT WINAPI ITextRange_fnGetText(ITextRange *me, BSTR *pbstr)
576 ITextRangeImpl *This = impl_from_ITextRange(me);
577 if (!This->reOle)
578 return CO_E_RELEASED;
580 FIXME("not implemented %p\n", This);
581 return E_NOTIMPL;
584 static HRESULT WINAPI ITextRange_fnSetText(ITextRange *me, BSTR bstr)
586 ITextRangeImpl *This = impl_from_ITextRange(me);
587 if (!This->reOle)
588 return CO_E_RELEASED;
590 FIXME("not implemented %p\n", This);
591 return E_NOTIMPL;
594 static HRESULT range_GetChar(ME_TextEditor *editor, ME_Cursor *cursor, LONG *pch)
596 WCHAR wch[2];
598 ME_GetTextW(editor, wch, 1, cursor, 1, FALSE, cursor->pRun->next->type == diTextEnd);
599 *pch = wch[0];
601 return S_OK;
604 static HRESULT WINAPI ITextRange_fnGetChar(ITextRange *me, LONG *pch)
606 ITextRangeImpl *This = impl_from_ITextRange(me);
607 ME_Cursor cursor;
609 if (!This->reOle)
610 return CO_E_RELEASED;
611 TRACE("%p\n", pch);
612 if (!pch)
613 return E_INVALIDARG;
615 ME_CursorFromCharOfs(This->reOle->editor, This->start, &cursor);
616 return range_GetChar(This->reOle->editor, &cursor, pch);
619 static HRESULT WINAPI ITextRange_fnSetChar(ITextRange *me, LONG ch)
621 ITextRangeImpl *This = impl_from_ITextRange(me);
622 if (!This->reOle)
623 return CO_E_RELEASED;
625 FIXME("not implemented %p\n", This);
626 return E_NOTIMPL;
629 static HRESULT CreateITextRange(IRichEditOleImpl *reOle, LONG start, LONG end, ITextRange** ppRange);
631 static HRESULT WINAPI ITextRange_fnGetDuplicate(ITextRange *me, ITextRange **ppRange)
633 ITextRangeImpl *This = impl_from_ITextRange(me);
634 if (!This->reOle)
635 return CO_E_RELEASED;
637 TRACE("%p %p\n", This, ppRange);
638 if (!ppRange)
639 return E_INVALIDARG;
641 return CreateITextRange(This->reOle, This->start, This->end, ppRange);
644 static HRESULT WINAPI ITextRange_fnGetFormattedText(ITextRange *me, ITextRange **ppRange)
646 ITextRangeImpl *This = impl_from_ITextRange(me);
647 if (!This->reOle)
648 return CO_E_RELEASED;
650 FIXME("not implemented %p\n", This);
651 return E_NOTIMPL;
654 static HRESULT WINAPI ITextRange_fnSetFormattedText(ITextRange *me, ITextRange *pRange)
656 ITextRangeImpl *This = impl_from_ITextRange(me);
657 if (!This->reOle)
658 return CO_E_RELEASED;
660 FIXME("not implemented %p\n", This);
661 return E_NOTIMPL;
664 static HRESULT WINAPI ITextRange_fnGetStart(ITextRange *me, LONG *pcpFirst)
666 ITextRangeImpl *This = impl_from_ITextRange(me);
667 if (!This->reOle)
668 return CO_E_RELEASED;
670 if (!pcpFirst)
671 return E_INVALIDARG;
672 *pcpFirst = This->start;
673 TRACE("%d\n", *pcpFirst);
674 return S_OK;
677 static HRESULT WINAPI ITextRange_fnSetStart(ITextRange *me, LONG cpFirst)
679 ITextRangeImpl *This = impl_from_ITextRange(me);
680 if (!This->reOle)
681 return CO_E_RELEASED;
683 FIXME("not implemented %p\n", This);
684 return E_NOTIMPL;
687 static HRESULT WINAPI ITextRange_fnGetEnd(ITextRange *me, LONG *pcpLim)
689 ITextRangeImpl *This = impl_from_ITextRange(me);
690 if (!This->reOle)
691 return CO_E_RELEASED;
693 if (!pcpLim)
694 return E_INVALIDARG;
695 *pcpLim = This->end;
696 TRACE("%d\n", *pcpLim);
697 return S_OK;
700 static HRESULT WINAPI ITextRange_fnSetEnd(ITextRange *me, LONG cpLim)
702 ITextRangeImpl *This = impl_from_ITextRange(me);
703 if (!This->reOle)
704 return CO_E_RELEASED;
706 FIXME("not implemented %p\n", This);
707 return E_NOTIMPL;
710 static HRESULT WINAPI ITextRange_fnGetFont(ITextRange *me, ITextFont **pFont)
712 ITextRangeImpl *This = impl_from_ITextRange(me);
713 if (!This->reOle)
714 return CO_E_RELEASED;
716 FIXME("not implemented %p\n", This);
717 return E_NOTIMPL;
720 static HRESULT WINAPI ITextRange_fnSetFont(ITextRange *me, ITextFont *pFont)
722 ITextRangeImpl *This = impl_from_ITextRange(me);
723 if (!This->reOle)
724 return CO_E_RELEASED;
726 FIXME("not implemented %p\n", This);
727 return E_NOTIMPL;
730 static HRESULT WINAPI ITextRange_fnGetPara(ITextRange *me, ITextPara **ppPara)
732 ITextRangeImpl *This = impl_from_ITextRange(me);
733 if (!This->reOle)
734 return CO_E_RELEASED;
736 FIXME("not implemented %p\n", This);
737 return E_NOTIMPL;
740 static HRESULT WINAPI ITextRange_fnSetPara(ITextRange *me, ITextPara *pPara)
742 ITextRangeImpl *This = impl_from_ITextRange(me);
743 if (!This->reOle)
744 return CO_E_RELEASED;
746 FIXME("not implemented %p\n", This);
747 return E_NOTIMPL;
750 static HRESULT WINAPI ITextRange_fnGetStoryLength(ITextRange *me, LONG *pcch)
752 ITextRangeImpl *This = impl_from_ITextRange(me);
753 if (!This->reOle)
754 return CO_E_RELEASED;
756 FIXME("not implemented %p\n", This);
757 return E_NOTIMPL;
760 static HRESULT WINAPI ITextRange_fnGetStoryType(ITextRange *me, LONG *pValue)
762 ITextRangeImpl *This = impl_from_ITextRange(me);
763 if (!This->reOle)
764 return CO_E_RELEASED;
766 FIXME("not implemented %p\n", This);
767 return E_NOTIMPL;
770 static HRESULT range_Collapse(LONG bStart, LONG *start, LONG *end)
772 if (*end == *start)
773 return S_FALSE;
775 if (bStart == tomEnd || bStart == tomFalse)
776 *start = *end;
777 else
778 *end = *start;
779 return S_OK;
782 static HRESULT WINAPI ITextRange_fnCollapse(ITextRange *me, LONG bStart)
784 ITextRangeImpl *This = impl_from_ITextRange(me);
785 if (!This->reOle)
786 return CO_E_RELEASED;
788 return range_Collapse(bStart, &This->start, &This->end);
791 static HRESULT WINAPI ITextRange_fnExpand(ITextRange *me, LONG Unit, LONG *pDelta)
793 ITextRangeImpl *This = impl_from_ITextRange(me);
794 if (!This->reOle)
795 return CO_E_RELEASED;
797 FIXME("not implemented %p\n", This);
798 return E_NOTIMPL;
801 static HRESULT WINAPI ITextRange_fnGetIndex(ITextRange *me, LONG Unit, LONG *pIndex)
803 ITextRangeImpl *This = impl_from_ITextRange(me);
804 if (!This->reOle)
805 return CO_E_RELEASED;
807 FIXME("not implemented %p\n", This);
808 return E_NOTIMPL;
811 static HRESULT WINAPI ITextRange_fnSetIndex(ITextRange *me, LONG Unit, LONG Index,
812 LONG Extend)
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_fnSetRange(ITextRange *me, LONG cpActive, LONG cpOther)
824 ITextRangeImpl *This = impl_from_ITextRange(me);
825 if (!This->reOle)
826 return CO_E_RELEASED;
828 FIXME("not implemented %p\n", This);
829 return E_NOTIMPL;
832 static HRESULT WINAPI ITextRange_fnInRange(ITextRange *me, ITextRange *pRange, LONG *pb)
834 ITextRangeImpl *This = impl_from_ITextRange(me);
835 if (!This->reOle)
836 return CO_E_RELEASED;
838 FIXME("not implemented %p\n", This);
839 return E_NOTIMPL;
842 static HRESULT WINAPI ITextRange_fnInStory(ITextRange *me, ITextRange *pRange, LONG *pb)
844 ITextRangeImpl *This = impl_from_ITextRange(me);
845 if (!This->reOle)
846 return CO_E_RELEASED;
848 FIXME("not implemented %p\n", This);
849 return E_NOTIMPL;
852 static HRESULT WINAPI ITextRange_fnIsEqual(ITextRange *me, ITextRange *pRange, LONG *pb)
854 ITextRangeImpl *This = impl_from_ITextRange(me);
855 if (!This->reOle)
856 return CO_E_RELEASED;
858 FIXME("not implemented %p\n", This);
859 return E_NOTIMPL;
862 static HRESULT WINAPI ITextRange_fnSelect(ITextRange *me)
864 ITextRangeImpl *This = impl_from_ITextRange(me);
865 if (!This->reOle)
866 return CO_E_RELEASED;
868 FIXME("not implemented %p\n", This);
869 return E_NOTIMPL;
872 static HRESULT WINAPI ITextRange_fnStartOf(ITextRange *me, LONG Unit, LONG Extend,
873 LONG *pDelta)
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_fnEndOf(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_fnMove(ITextRange *me, LONG Unit, LONG Count, LONG *pDelta)
896 ITextRangeImpl *This = impl_from_ITextRange(me);
897 if (!This->reOle)
898 return CO_E_RELEASED;
900 FIXME("not implemented %p\n", This);
901 return E_NOTIMPL;
904 static HRESULT WINAPI ITextRange_fnMoveStart(ITextRange *me, LONG Unit, LONG Count,
905 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_fnMoveEnd(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_fnMoveWhile(ITextRange *me, VARIANT *Cset, 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_fnMoveStartWhile(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_fnMoveEndWhile(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_fnMoveUntil(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_fnMoveStartUntil(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_fnMoveEndUntil(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_fnFindText(ITextRange *me, BSTR bstr, LONG cch, LONG Flags,
993 LONG *pLength)
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_fnFindTextStart(ITextRange *me, BSTR bstr, LONG cch,
1004 LONG Flags, 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_fnFindTextEnd(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_fnDelete(ITextRange *me, LONG Unit, LONG Count,
1026 LONG *pDelta)
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_fnCut(ITextRange *me, VARIANT *pVar)
1038 ITextRangeImpl *This = impl_from_ITextRange(me);
1039 if (!This->reOle)
1040 return CO_E_RELEASED;
1042 FIXME("not implemented %p\n", This);
1043 return E_NOTIMPL;
1046 static HRESULT WINAPI ITextRange_fnCopy(ITextRange *me, VARIANT *pVar)
1048 ITextRangeImpl *This = impl_from_ITextRange(me);
1049 if (!This->reOle)
1050 return CO_E_RELEASED;
1052 FIXME("not implemented %p\n", This);
1053 return E_NOTIMPL;
1056 static HRESULT WINAPI ITextRange_fnPaste(ITextRange *me, VARIANT *pVar, LONG Format)
1058 ITextRangeImpl *This = impl_from_ITextRange(me);
1059 if (!This->reOle)
1060 return CO_E_RELEASED;
1062 FIXME("not implemented %p\n", This);
1063 return E_NOTIMPL;
1066 static HRESULT WINAPI ITextRange_fnCanPaste(ITextRange *me, VARIANT *pVar, LONG Format,
1067 LONG *pb)
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_fnCanEdit(ITextRange *me, LONG *pb)
1079 ITextRangeImpl *This = impl_from_ITextRange(me);
1080 if (!This->reOle)
1081 return CO_E_RELEASED;
1083 FIXME("not implemented %p\n", This);
1084 return E_NOTIMPL;
1087 static HRESULT WINAPI ITextRange_fnChangeCase(ITextRange *me, LONG Type)
1089 ITextRangeImpl *This = impl_from_ITextRange(me);
1090 if (!This->reOle)
1091 return CO_E_RELEASED;
1093 FIXME("not implemented %p\n", This);
1094 return E_NOTIMPL;
1097 static HRESULT WINAPI ITextRange_fnGetPoint(ITextRange *me, LONG Type, LONG *cx, LONG *cy)
1099 ITextRangeImpl *This = impl_from_ITextRange(me);
1100 if (!This->reOle)
1101 return CO_E_RELEASED;
1103 FIXME("not implemented %p\n", This);
1104 return E_NOTIMPL;
1107 static HRESULT WINAPI ITextRange_fnSetPoint(ITextRange *me, LONG x, LONG y, LONG Type,
1108 LONG Extend)
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_fnScrollIntoView(ITextRange *me, LONG Value)
1120 ITextRangeImpl *This = impl_from_ITextRange(me);
1121 if (!This->reOle)
1122 return CO_E_RELEASED;
1124 FIXME("not implemented %p\n", This);
1125 return E_NOTIMPL;
1128 static HRESULT WINAPI ITextRange_fnGetEmbeddedObject(ITextRange *me, IUnknown **ppv)
1130 ITextRangeImpl *This = impl_from_ITextRange(me);
1131 if (!This->reOle)
1132 return CO_E_RELEASED;
1134 FIXME("not implemented %p\n", This);
1135 return E_NOTIMPL;
1138 static const ITextRangeVtbl trvt = {
1139 ITextRange_fnQueryInterface,
1140 ITextRange_fnAddRef,
1141 ITextRange_fnRelease,
1142 ITextRange_fnGetTypeInfoCount,
1143 ITextRange_fnGetTypeInfo,
1144 ITextRange_fnGetIDsOfNames,
1145 ITextRange_fnInvoke,
1146 ITextRange_fnGetText,
1147 ITextRange_fnSetText,
1148 ITextRange_fnGetChar,
1149 ITextRange_fnSetChar,
1150 ITextRange_fnGetDuplicate,
1151 ITextRange_fnGetFormattedText,
1152 ITextRange_fnSetFormattedText,
1153 ITextRange_fnGetStart,
1154 ITextRange_fnSetStart,
1155 ITextRange_fnGetEnd,
1156 ITextRange_fnSetEnd,
1157 ITextRange_fnGetFont,
1158 ITextRange_fnSetFont,
1159 ITextRange_fnGetPara,
1160 ITextRange_fnSetPara,
1161 ITextRange_fnGetStoryLength,
1162 ITextRange_fnGetStoryType,
1163 ITextRange_fnCollapse,
1164 ITextRange_fnExpand,
1165 ITextRange_fnGetIndex,
1166 ITextRange_fnSetIndex,
1167 ITextRange_fnSetRange,
1168 ITextRange_fnInRange,
1169 ITextRange_fnInStory,
1170 ITextRange_fnIsEqual,
1171 ITextRange_fnSelect,
1172 ITextRange_fnStartOf,
1173 ITextRange_fnEndOf,
1174 ITextRange_fnMove,
1175 ITextRange_fnMoveStart,
1176 ITextRange_fnMoveEnd,
1177 ITextRange_fnMoveWhile,
1178 ITextRange_fnMoveStartWhile,
1179 ITextRange_fnMoveEndWhile,
1180 ITextRange_fnMoveUntil,
1181 ITextRange_fnMoveStartUntil,
1182 ITextRange_fnMoveEndUntil,
1183 ITextRange_fnFindText,
1184 ITextRange_fnFindTextStart,
1185 ITextRange_fnFindTextEnd,
1186 ITextRange_fnDelete,
1187 ITextRange_fnCut,
1188 ITextRange_fnCopy,
1189 ITextRange_fnPaste,
1190 ITextRange_fnCanPaste,
1191 ITextRange_fnCanEdit,
1192 ITextRange_fnChangeCase,
1193 ITextRange_fnGetPoint,
1194 ITextRange_fnSetPoint,
1195 ITextRange_fnScrollIntoView,
1196 ITextRange_fnGetEmbeddedObject
1198 /* ITextRange interface */
1200 static HRESULT WINAPI
1201 ITextDocument_fnQueryInterface(ITextDocument* me, REFIID riid,
1202 void** ppvObject)
1204 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1205 return IRichEditOle_QueryInterface(&This->IRichEditOle_iface, riid, ppvObject);
1208 static ULONG WINAPI
1209 ITextDocument_fnAddRef(ITextDocument* me)
1211 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1212 return IRichEditOle_AddRef(&This->IRichEditOle_iface);
1215 static ULONG WINAPI
1216 ITextDocument_fnRelease(ITextDocument* me)
1218 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1219 return IRichEditOle_Release(&This->IRichEditOle_iface);
1222 static HRESULT WINAPI
1223 ITextDocument_fnGetTypeInfoCount(ITextDocument* me,
1224 UINT* pctinfo)
1226 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1227 FIXME("stub %p\n",This);
1228 return E_NOTIMPL;
1231 static HRESULT WINAPI
1232 ITextDocument_fnGetTypeInfo(ITextDocument* me, UINT iTInfo, LCID lcid,
1233 ITypeInfo** ppTInfo)
1235 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1236 FIXME("stub %p\n",This);
1237 return E_NOTIMPL;
1240 static HRESULT WINAPI
1241 ITextDocument_fnGetIDsOfNames(ITextDocument* me, REFIID riid,
1242 LPOLESTR* rgszNames, UINT cNames, LCID lcid, DISPID* rgDispId)
1244 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1245 FIXME("stub %p\n",This);
1246 return E_NOTIMPL;
1249 static HRESULT WINAPI
1250 ITextDocument_fnInvoke(ITextDocument* me, DISPID dispIdMember,
1251 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS* pDispParams,
1252 VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr)
1254 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1255 FIXME("stub %p\n",This);
1256 return E_NOTIMPL;
1259 static HRESULT WINAPI
1260 ITextDocument_fnGetName(ITextDocument* me, BSTR* pName)
1262 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1263 FIXME("stub %p\n",This);
1264 return E_NOTIMPL;
1267 static HRESULT WINAPI
1268 ITextDocument_fnGetSelection(ITextDocument* me, ITextSelection** ppSel)
1270 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1271 TRACE("(%p)\n", me);
1273 if(!ppSel)
1274 return E_INVALIDARG;
1275 *ppSel = &This->txtSel->ITextSelection_iface;
1276 ITextSelection_AddRef(*ppSel);
1277 return S_OK;
1280 static HRESULT WINAPI
1281 ITextDocument_fnGetStoryCount(ITextDocument* me, LONG* pCount)
1283 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1284 FIXME("stub %p\n",This);
1285 return E_NOTIMPL;
1288 static HRESULT WINAPI
1289 ITextDocument_fnGetStoryRanges(ITextDocument* me,
1290 ITextStoryRanges** ppStories)
1292 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1293 FIXME("stub %p\n",This);
1294 return E_NOTIMPL;
1297 static HRESULT WINAPI
1298 ITextDocument_fnGetSaved(ITextDocument* me, LONG* pValue)
1300 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1301 FIXME("stub %p\n",This);
1302 return E_NOTIMPL;
1305 static HRESULT WINAPI
1306 ITextDocument_fnSetSaved(ITextDocument* me, LONG Value)
1308 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1309 FIXME("stub %p\n",This);
1310 return E_NOTIMPL;
1313 static HRESULT WINAPI
1314 ITextDocument_fnGetDefaultTabStop(ITextDocument* me, float* pValue)
1316 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1317 FIXME("stub %p\n",This);
1318 return E_NOTIMPL;
1321 static HRESULT WINAPI
1322 ITextDocument_fnSetDefaultTabStop(ITextDocument* me, float Value)
1324 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1325 FIXME("stub %p\n",This);
1326 return E_NOTIMPL;
1329 static HRESULT WINAPI
1330 ITextDocument_fnNew(ITextDocument* me)
1332 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1333 FIXME("stub %p\n",This);
1334 return E_NOTIMPL;
1337 static HRESULT WINAPI
1338 ITextDocument_fnOpen(ITextDocument* me, VARIANT* pVar, LONG Flags,
1339 LONG CodePage)
1341 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1342 FIXME("stub %p\n",This);
1343 return E_NOTIMPL;
1346 static HRESULT WINAPI
1347 ITextDocument_fnSave(ITextDocument* me, VARIANT* pVar, LONG Flags,
1348 LONG CodePage)
1350 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1351 FIXME("stub %p\n",This);
1352 return E_NOTIMPL;
1355 static HRESULT WINAPI
1356 ITextDocument_fnFreeze(ITextDocument* me, LONG* pCount)
1358 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1359 FIXME("stub %p\n",This);
1360 return E_NOTIMPL;
1363 static HRESULT WINAPI
1364 ITextDocument_fnUnfreeze(ITextDocument* me, LONG* pCount)
1366 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1367 FIXME("stub %p\n",This);
1368 return E_NOTIMPL;
1371 static HRESULT WINAPI
1372 ITextDocument_fnBeginEditCollection(ITextDocument* me)
1374 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1375 FIXME("stub %p\n",This);
1376 return E_NOTIMPL;
1379 static HRESULT WINAPI
1380 ITextDocument_fnEndEditCollection(ITextDocument* me)
1382 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1383 FIXME("stub %p\n",This);
1384 return E_NOTIMPL;
1387 static HRESULT WINAPI
1388 ITextDocument_fnUndo(ITextDocument* me, LONG Count, LONG* prop)
1390 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1391 FIXME("stub %p\n",This);
1392 return E_NOTIMPL;
1395 static HRESULT WINAPI
1396 ITextDocument_fnRedo(ITextDocument* me, LONG Count, LONG* prop)
1398 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1399 FIXME("stub %p\n",This);
1400 return E_NOTIMPL;
1403 static HRESULT CreateITextRange(IRichEditOleImpl *reOle, LONG start, LONG end, ITextRange** ppRange)
1405 ITextRangeImpl *txtRge = heap_alloc(sizeof(ITextRangeImpl));
1407 if (!txtRge)
1408 return E_OUTOFMEMORY;
1409 txtRge->ITextRange_iface.lpVtbl = &trvt;
1410 txtRge->ref = 1;
1411 txtRge->reOle = reOle;
1412 txtRge->start = start;
1413 txtRge->end = end;
1414 list_add_head(&reOle->rangelist, &txtRge->entry);
1415 *ppRange = &txtRge->ITextRange_iface;
1416 return S_OK;
1419 static HRESULT WINAPI
1420 ITextDocument_fnRange(ITextDocument* me, LONG cp1, LONG cp2,
1421 ITextRange** ppRange)
1423 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1424 const int len = ME_GetTextLength(This->editor) + 1;
1426 TRACE("%p %p %d %d\n", This, ppRange, cp1, cp2);
1427 if (!ppRange)
1428 return E_INVALIDARG;
1430 cp1 = max(cp1, 0);
1431 cp2 = max(cp2, 0);
1432 cp1 = min(cp1, len);
1433 cp2 = min(cp2, len);
1434 if (cp1 > cp2)
1436 LONG tmp;
1437 tmp = cp1;
1438 cp1 = cp2;
1439 cp2 = tmp;
1441 if (cp1 == len)
1442 cp1 = cp2 = len - 1;
1444 return CreateITextRange(This, cp1, cp2, ppRange);
1447 static HRESULT WINAPI
1448 ITextDocument_fnRangeFromPoint(ITextDocument* me, LONG x, LONG y,
1449 ITextRange** ppRange)
1451 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1452 FIXME("stub %p\n",This);
1453 return E_NOTIMPL;
1456 static const ITextDocumentVtbl tdvt = {
1457 ITextDocument_fnQueryInterface,
1458 ITextDocument_fnAddRef,
1459 ITextDocument_fnRelease,
1460 ITextDocument_fnGetTypeInfoCount,
1461 ITextDocument_fnGetTypeInfo,
1462 ITextDocument_fnGetIDsOfNames,
1463 ITextDocument_fnInvoke,
1464 ITextDocument_fnGetName,
1465 ITextDocument_fnGetSelection,
1466 ITextDocument_fnGetStoryCount,
1467 ITextDocument_fnGetStoryRanges,
1468 ITextDocument_fnGetSaved,
1469 ITextDocument_fnSetSaved,
1470 ITextDocument_fnGetDefaultTabStop,
1471 ITextDocument_fnSetDefaultTabStop,
1472 ITextDocument_fnNew,
1473 ITextDocument_fnOpen,
1474 ITextDocument_fnSave,
1475 ITextDocument_fnFreeze,
1476 ITextDocument_fnUnfreeze,
1477 ITextDocument_fnBeginEditCollection,
1478 ITextDocument_fnEndEditCollection,
1479 ITextDocument_fnUndo,
1480 ITextDocument_fnRedo,
1481 ITextDocument_fnRange,
1482 ITextDocument_fnRangeFromPoint
1485 static inline ITextSelectionImpl *impl_from_ITextSelection(ITextSelection *iface)
1487 return CONTAINING_RECORD(iface, ITextSelectionImpl, ITextSelection_iface);
1490 static HRESULT WINAPI ITextSelection_fnQueryInterface(
1491 ITextSelection *me,
1492 REFIID riid,
1493 void **ppvObj)
1495 *ppvObj = NULL;
1496 if (IsEqualGUID(riid, &IID_IUnknown)
1497 || IsEqualGUID(riid, &IID_IDispatch)
1498 || IsEqualGUID(riid, &IID_ITextRange)
1499 || IsEqualGUID(riid, &IID_ITextSelection))
1501 *ppvObj = me;
1502 ITextSelection_AddRef(me);
1503 return S_OK;
1506 return E_NOINTERFACE;
1509 static ULONG WINAPI ITextSelection_fnAddRef(ITextSelection *me)
1511 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1512 return InterlockedIncrement(&This->ref);
1515 static ULONG WINAPI ITextSelection_fnRelease(ITextSelection *me)
1517 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1518 ULONG ref = InterlockedDecrement(&This->ref);
1519 if (ref == 0)
1520 heap_free(This);
1521 return ref;
1524 static HRESULT WINAPI ITextSelection_fnGetTypeInfoCount(ITextSelection *me, UINT *pctinfo)
1526 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1527 if (!This->reOle)
1528 return CO_E_RELEASED;
1530 FIXME("not implemented\n");
1531 return E_NOTIMPL;
1534 static HRESULT WINAPI ITextSelection_fnGetTypeInfo(ITextSelection *me, UINT iTInfo, LCID lcid,
1535 ITypeInfo **ppTInfo)
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_fnGetIDsOfNames(ITextSelection *me, REFIID riid,
1546 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
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_fnInvoke(
1557 ITextSelection *me,
1558 DISPID dispIdMember,
1559 REFIID riid,
1560 LCID lcid,
1561 WORD wFlags,
1562 DISPPARAMS *pDispParams,
1563 VARIANT *pVarResult,
1564 EXCEPINFO *pExcepInfo,
1565 UINT *puArgErr)
1567 FIXME("not implemented\n");
1568 return E_NOTIMPL;
1571 /*** ITextRange methods ***/
1572 static HRESULT WINAPI ITextSelection_fnGetText(ITextSelection *me, BSTR *pbstr)
1574 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1575 ME_Cursor *start = NULL, *end = NULL;
1576 int nChars, endOfs;
1577 BOOL bEOP;
1579 if (!This->reOle)
1580 return CO_E_RELEASED;
1581 TRACE("%p\n", pbstr);
1582 if (!pbstr)
1583 return E_INVALIDARG;
1585 ME_GetSelection(This->reOle->editor, &start, &end);
1586 endOfs = ME_GetCursorOfs(end);
1587 nChars = endOfs - ME_GetCursorOfs(start);
1588 if (!nChars)
1590 *pbstr = NULL;
1591 return S_OK;
1594 *pbstr = SysAllocStringLen(NULL, nChars);
1595 if (!*pbstr)
1596 return E_OUTOFMEMORY;
1598 bEOP = (end->pRun->next->type == diTextEnd && endOfs > ME_GetTextLength(This->reOle->editor));
1599 ME_GetTextW(This->reOle->editor, *pbstr, nChars, start, nChars, FALSE, bEOP);
1600 TRACE("%s\n", wine_dbgstr_w(*pbstr));
1602 return S_OK;
1605 static HRESULT WINAPI ITextSelection_fnSetText(ITextSelection *me, BSTR bstr)
1607 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1608 if (!This->reOle)
1609 return CO_E_RELEASED;
1611 FIXME("not implemented\n");
1612 return E_NOTIMPL;
1615 static HRESULT WINAPI ITextSelection_fnGetChar(ITextSelection *me, LONG *pch)
1617 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1618 ME_Cursor *start = NULL, *end = NULL;
1620 if (!This->reOle)
1621 return CO_E_RELEASED;
1622 TRACE("%p\n", pch);
1623 if (!pch)
1624 return E_INVALIDARG;
1626 ME_GetSelection(This->reOle->editor, &start, &end);
1627 return range_GetChar(This->reOle->editor, start, pch);
1630 static HRESULT WINAPI ITextSelection_fnSetChar(ITextSelection *me, LONG ch)
1632 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1633 if (!This->reOle)
1634 return CO_E_RELEASED;
1636 FIXME("not implemented\n");
1637 return E_NOTIMPL;
1640 static HRESULT WINAPI ITextSelection_fnGetDuplicate(ITextSelection *me, ITextRange **ppRange)
1642 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1643 if (!This->reOle)
1644 return CO_E_RELEASED;
1646 FIXME("not implemented\n");
1647 return E_NOTIMPL;
1650 static HRESULT WINAPI ITextSelection_fnGetFormattedText(ITextSelection *me, ITextRange **ppRange)
1652 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1653 if (!This->reOle)
1654 return CO_E_RELEASED;
1656 FIXME("not implemented\n");
1657 return E_NOTIMPL;
1660 static HRESULT WINAPI ITextSelection_fnSetFormattedText(ITextSelection *me, ITextRange *pRange)
1662 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1663 if (!This->reOle)
1664 return CO_E_RELEASED;
1666 FIXME("not implemented\n");
1667 return E_NOTIMPL;
1670 static HRESULT WINAPI ITextSelection_fnGetStart(ITextSelection *me, LONG *pcpFirst)
1672 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1673 LONG lim;
1674 if (!This->reOle)
1675 return CO_E_RELEASED;
1677 if (!pcpFirst)
1678 return E_INVALIDARG;
1679 ME_GetSelectionOfs(This->reOle->editor, pcpFirst, &lim);
1680 TRACE("%d\n", *pcpFirst);
1681 return S_OK;
1684 static HRESULT WINAPI ITextSelection_fnSetStart(ITextSelection *me, LONG cpFirst)
1686 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1687 if (!This->reOle)
1688 return CO_E_RELEASED;
1690 FIXME("not implemented\n");
1691 return E_NOTIMPL;
1694 static HRESULT WINAPI ITextSelection_fnGetEnd(ITextSelection *me, LONG *pcpLim)
1696 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1697 LONG first;
1698 if (!This->reOle)
1699 return CO_E_RELEASED;
1701 if (!pcpLim)
1702 return E_INVALIDARG;
1703 ME_GetSelectionOfs(This->reOle->editor, &first, pcpLim);
1704 TRACE("%d\n", *pcpLim);
1705 return S_OK;
1708 static HRESULT WINAPI ITextSelection_fnSetEnd(ITextSelection *me, LONG cpLim)
1710 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1711 if (!This->reOle)
1712 return CO_E_RELEASED;
1714 FIXME("not implemented\n");
1715 return E_NOTIMPL;
1718 static HRESULT WINAPI ITextSelection_fnGetFont(ITextSelection *me, ITextFont **pFont)
1720 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1721 if (!This->reOle)
1722 return CO_E_RELEASED;
1724 FIXME("not implemented\n");
1725 return E_NOTIMPL;
1728 static HRESULT WINAPI ITextSelection_fnSetFont(ITextSelection *me, ITextFont *pFont)
1730 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1731 if (!This->reOle)
1732 return CO_E_RELEASED;
1734 FIXME("not implemented\n");
1735 return E_NOTIMPL;
1738 static HRESULT WINAPI ITextSelection_fnGetPara(ITextSelection *me, ITextPara **ppPara)
1740 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1741 if (!This->reOle)
1742 return CO_E_RELEASED;
1744 FIXME("not implemented\n");
1745 return E_NOTIMPL;
1748 static HRESULT WINAPI ITextSelection_fnSetPara(ITextSelection *me, ITextPara *pPara)
1750 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1751 if (!This->reOle)
1752 return CO_E_RELEASED;
1754 FIXME("not implemented\n");
1755 return E_NOTIMPL;
1758 static HRESULT WINAPI ITextSelection_fnGetStoryLength(ITextSelection *me, LONG *pcch)
1760 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1761 if (!This->reOle)
1762 return CO_E_RELEASED;
1764 FIXME("not implemented\n");
1765 return E_NOTIMPL;
1768 static HRESULT WINAPI ITextSelection_fnGetStoryType(ITextSelection *me, LONG *pValue)
1770 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1771 if (!This->reOle)
1772 return CO_E_RELEASED;
1774 FIXME("not implemented\n");
1775 return E_NOTIMPL;
1778 static HRESULT WINAPI ITextSelection_fnCollapse(ITextSelection *me, LONG bStart)
1780 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1781 LONG start, end;
1782 HRESULT hres;
1783 if (!This->reOle)
1784 return CO_E_RELEASED;
1786 ME_GetSelectionOfs(This->reOle->editor, &start, &end);
1787 hres = range_Collapse(bStart, &start, &end);
1788 if (SUCCEEDED(hres))
1789 ME_SetSelection(This->reOle->editor, start, end);
1790 return hres;
1793 static HRESULT WINAPI ITextSelection_fnExpand(ITextSelection *me, LONG Unit, LONG *pDelta)
1795 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1796 if (!This->reOle)
1797 return CO_E_RELEASED;
1799 FIXME("not implemented\n");
1800 return E_NOTIMPL;
1803 static HRESULT WINAPI ITextSelection_fnGetIndex(ITextSelection *me, LONG Unit, LONG *pIndex)
1805 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1806 if (!This->reOle)
1807 return CO_E_RELEASED;
1809 FIXME("not implemented\n");
1810 return E_NOTIMPL;
1813 static HRESULT WINAPI ITextSelection_fnSetIndex(ITextSelection *me, LONG Unit, LONG Index,
1814 LONG Extend)
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_fnSetRange(ITextSelection *me, LONG cpActive, LONG cpOther)
1826 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1827 if (!This->reOle)
1828 return CO_E_RELEASED;
1830 FIXME("not implemented\n");
1831 return E_NOTIMPL;
1834 static HRESULT WINAPI ITextSelection_fnInRange(ITextSelection *me, ITextRange *pRange, LONG *pb)
1836 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1837 if (!This->reOle)
1838 return CO_E_RELEASED;
1840 FIXME("not implemented\n");
1841 return E_NOTIMPL;
1844 static HRESULT WINAPI ITextSelection_fnInStory(ITextSelection *me, ITextRange *pRange, LONG *pb)
1846 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1847 if (!This->reOle)
1848 return CO_E_RELEASED;
1850 FIXME("not implemented\n");
1851 return E_NOTIMPL;
1854 static HRESULT WINAPI ITextSelection_fnIsEqual(ITextSelection *me, ITextRange *pRange, LONG *pb)
1856 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1857 if (!This->reOle)
1858 return CO_E_RELEASED;
1860 FIXME("not implemented\n");
1861 return E_NOTIMPL;
1864 static HRESULT WINAPI ITextSelection_fnSelect(ITextSelection *me)
1866 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1867 if (!This->reOle)
1868 return CO_E_RELEASED;
1870 FIXME("not implemented\n");
1871 return E_NOTIMPL;
1874 static HRESULT WINAPI ITextSelection_fnStartOf(ITextSelection *me, LONG Unit, LONG Extend,
1875 LONG *pDelta)
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_fnEndOf(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_fnMove(ITextSelection *me, LONG Unit, LONG Count, LONG *pDelta)
1898 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1899 if (!This->reOle)
1900 return CO_E_RELEASED;
1902 FIXME("not implemented\n");
1903 return E_NOTIMPL;
1906 static HRESULT WINAPI ITextSelection_fnMoveStart(ITextSelection *me, LONG Unit, LONG Count,
1907 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_fnMoveEnd(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_fnMoveWhile(ITextSelection *me, VARIANT *Cset, 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_fnMoveStartWhile(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_fnMoveEndWhile(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_fnMoveUntil(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_fnMoveStartUntil(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_fnMoveEndUntil(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_fnFindText(ITextSelection *me, BSTR bstr, LONG cch, LONG Flags,
1995 LONG *pLength)
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_fnFindTextStart(ITextSelection *me, BSTR bstr, LONG cch,
2006 LONG Flags, 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_fnFindTextEnd(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_fnDelete(ITextSelection *me, LONG Unit, LONG Count,
2028 LONG *pDelta)
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_fnCut(ITextSelection *me, VARIANT *pVar)
2040 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2041 if (!This->reOle)
2042 return CO_E_RELEASED;
2044 FIXME("not implemented\n");
2045 return E_NOTIMPL;
2048 static HRESULT WINAPI ITextSelection_fnCopy(ITextSelection *me, VARIANT *pVar)
2050 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2051 if (!This->reOle)
2052 return CO_E_RELEASED;
2054 FIXME("not implemented\n");
2055 return E_NOTIMPL;
2058 static HRESULT WINAPI ITextSelection_fnPaste(ITextSelection *me, VARIANT *pVar, LONG Format)
2060 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2061 if (!This->reOle)
2062 return CO_E_RELEASED;
2064 FIXME("not implemented\n");
2065 return E_NOTIMPL;
2068 static HRESULT WINAPI ITextSelection_fnCanPaste(ITextSelection *me, VARIANT *pVar, LONG Format,
2069 LONG *pb)
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_fnCanEdit(ITextSelection *me, LONG *pb)
2081 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2082 if (!This->reOle)
2083 return CO_E_RELEASED;
2085 FIXME("not implemented\n");
2086 return E_NOTIMPL;
2089 static HRESULT WINAPI ITextSelection_fnChangeCase(ITextSelection *me, LONG Type)
2091 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2092 if (!This->reOle)
2093 return CO_E_RELEASED;
2095 FIXME("not implemented\n");
2096 return E_NOTIMPL;
2099 static HRESULT WINAPI ITextSelection_fnGetPoint(ITextSelection *me, LONG Type, LONG *cx, LONG *cy)
2101 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2102 if (!This->reOle)
2103 return CO_E_RELEASED;
2105 FIXME("not implemented\n");
2106 return E_NOTIMPL;
2109 static HRESULT WINAPI ITextSelection_fnSetPoint(ITextSelection *me, LONG x, LONG y, LONG Type,
2110 LONG Extend)
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_fnScrollIntoView(ITextSelection *me, LONG Value)
2122 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2123 if (!This->reOle)
2124 return CO_E_RELEASED;
2126 FIXME("not implemented\n");
2127 return E_NOTIMPL;
2130 static HRESULT WINAPI ITextSelection_fnGetEmbeddedObject(ITextSelection *me, IUnknown **ppv)
2132 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2133 if (!This->reOle)
2134 return CO_E_RELEASED;
2136 FIXME("not implemented\n");
2137 return E_NOTIMPL;
2140 /*** ITextSelection methods ***/
2141 static HRESULT WINAPI ITextSelection_fnGetFlags(ITextSelection *me, LONG *pFlags)
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 static HRESULT WINAPI ITextSelection_fnSetFlags(ITextSelection *me, LONG Flags)
2153 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2154 if (!This->reOle)
2155 return CO_E_RELEASED;
2157 FIXME("not implemented\n");
2158 return E_NOTIMPL;
2161 static HRESULT WINAPI ITextSelection_fnGetType(ITextSelection *me, LONG *pType)
2163 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2164 if (!This->reOle)
2165 return CO_E_RELEASED;
2167 FIXME("not implemented\n");
2168 return E_NOTIMPL;
2171 static HRESULT WINAPI ITextSelection_fnMoveLeft(ITextSelection *me, LONG Unit, LONG Count,
2172 LONG Extend, LONG *pDelta)
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_fnMoveRight(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_fnMoveUp(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_fnMoveDown(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_fnHomeKey(ITextSelection *me, LONG Unit, LONG Extend,
2216 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_fnEndKey(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_fnTypeText(ITextSelection *me, BSTR bstr)
2239 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2240 if (!This->reOle)
2241 return CO_E_RELEASED;
2243 FIXME("not implemented\n");
2244 return E_NOTIMPL;
2247 static const ITextSelectionVtbl tsvt = {
2248 ITextSelection_fnQueryInterface,
2249 ITextSelection_fnAddRef,
2250 ITextSelection_fnRelease,
2251 ITextSelection_fnGetTypeInfoCount,
2252 ITextSelection_fnGetTypeInfo,
2253 ITextSelection_fnGetIDsOfNames,
2254 ITextSelection_fnInvoke,
2255 ITextSelection_fnGetText,
2256 ITextSelection_fnSetText,
2257 ITextSelection_fnGetChar,
2258 ITextSelection_fnSetChar,
2259 ITextSelection_fnGetDuplicate,
2260 ITextSelection_fnGetFormattedText,
2261 ITextSelection_fnSetFormattedText,
2262 ITextSelection_fnGetStart,
2263 ITextSelection_fnSetStart,
2264 ITextSelection_fnGetEnd,
2265 ITextSelection_fnSetEnd,
2266 ITextSelection_fnGetFont,
2267 ITextSelection_fnSetFont,
2268 ITextSelection_fnGetPara,
2269 ITextSelection_fnSetPara,
2270 ITextSelection_fnGetStoryLength,
2271 ITextSelection_fnGetStoryType,
2272 ITextSelection_fnCollapse,
2273 ITextSelection_fnExpand,
2274 ITextSelection_fnGetIndex,
2275 ITextSelection_fnSetIndex,
2276 ITextSelection_fnSetRange,
2277 ITextSelection_fnInRange,
2278 ITextSelection_fnInStory,
2279 ITextSelection_fnIsEqual,
2280 ITextSelection_fnSelect,
2281 ITextSelection_fnStartOf,
2282 ITextSelection_fnEndOf,
2283 ITextSelection_fnMove,
2284 ITextSelection_fnMoveStart,
2285 ITextSelection_fnMoveEnd,
2286 ITextSelection_fnMoveWhile,
2287 ITextSelection_fnMoveStartWhile,
2288 ITextSelection_fnMoveEndWhile,
2289 ITextSelection_fnMoveUntil,
2290 ITextSelection_fnMoveStartUntil,
2291 ITextSelection_fnMoveEndUntil,
2292 ITextSelection_fnFindText,
2293 ITextSelection_fnFindTextStart,
2294 ITextSelection_fnFindTextEnd,
2295 ITextSelection_fnDelete,
2296 ITextSelection_fnCut,
2297 ITextSelection_fnCopy,
2298 ITextSelection_fnPaste,
2299 ITextSelection_fnCanPaste,
2300 ITextSelection_fnCanEdit,
2301 ITextSelection_fnChangeCase,
2302 ITextSelection_fnGetPoint,
2303 ITextSelection_fnSetPoint,
2304 ITextSelection_fnScrollIntoView,
2305 ITextSelection_fnGetEmbeddedObject,
2306 ITextSelection_fnGetFlags,
2307 ITextSelection_fnSetFlags,
2308 ITextSelection_fnGetType,
2309 ITextSelection_fnMoveLeft,
2310 ITextSelection_fnMoveRight,
2311 ITextSelection_fnMoveUp,
2312 ITextSelection_fnMoveDown,
2313 ITextSelection_fnHomeKey,
2314 ITextSelection_fnEndKey,
2315 ITextSelection_fnTypeText
2318 static ITextSelectionImpl *
2319 CreateTextSelection(IRichEditOleImpl *reOle)
2321 ITextSelectionImpl *txtSel = heap_alloc(sizeof *txtSel);
2322 if (!txtSel)
2323 return NULL;
2325 txtSel->ITextSelection_iface.lpVtbl = &tsvt;
2326 txtSel->ref = 1;
2327 txtSel->reOle = reOle;
2328 return txtSel;
2331 LRESULT CreateIRichEditOle(IUnknown *outer_unk, ME_TextEditor *editor, LPVOID *ppvObj)
2333 IRichEditOleImpl *reo;
2335 reo = heap_alloc(sizeof(IRichEditOleImpl));
2336 if (!reo)
2337 return 0;
2339 reo->IUnknown_inner.lpVtbl = &reo_unk_vtbl;
2340 reo->IRichEditOle_iface.lpVtbl = &revt;
2341 reo->ITextDocument_iface.lpVtbl = &tdvt;
2342 reo->ref = 1;
2343 reo->editor = editor;
2344 reo->txtSel = CreateTextSelection(reo);
2345 if (!reo->txtSel)
2347 heap_free(reo);
2348 return 0;
2350 reo->clientSite = CreateOleClientSite(reo);
2351 if (!reo->clientSite)
2353 ITextSelection_Release(&reo->txtSel->ITextSelection_iface);
2354 heap_free(reo);
2355 return 0;
2357 TRACE("Created %p\n",reo);
2358 list_init(&reo->rangelist);
2359 if (outer_unk)
2360 reo->outer_unk = outer_unk;
2361 else
2362 reo->outer_unk = &reo->IUnknown_inner;
2363 *ppvObj = &reo->IRichEditOle_iface;
2365 return 1;
2368 void DestroyIRichEditOle(IRichEditOle *iface)
2370 IRichEditOleImpl *This = impl_from_IRichEditOle(iface);
2371 ITextRangeImpl *txtRge;
2373 TRACE("Destroying %p\n", This);
2374 This->txtSel->reOle = NULL;
2375 This->editor->reOle = NULL;
2376 ITextSelection_Release(&This->txtSel->ITextSelection_iface);
2377 IOleClientSite_Release(&This->clientSite->IOleClientSite_iface);
2378 LIST_FOR_EACH_ENTRY(txtRge, &This->rangelist, ITextRangeImpl, entry)
2379 txtRge->reOle = NULL;
2380 heap_free(This);
2383 static void convert_sizel(const ME_Context *c, const SIZEL* szl, SIZE* sz)
2385 /* sizel is in .01 millimeters, sz in pixels */
2386 sz->cx = MulDiv(szl->cx, c->dpi.cx, 2540);
2387 sz->cy = MulDiv(szl->cy, c->dpi.cy, 2540);
2390 /******************************************************************************
2391 * ME_GetOLEObjectSize
2393 * Sets run extent for OLE objects.
2395 void ME_GetOLEObjectSize(const ME_Context *c, ME_Run *run, SIZE *pSize)
2397 IDataObject* ido;
2398 FORMATETC fmt;
2399 STGMEDIUM stgm;
2400 DIBSECTION dibsect;
2401 ENHMETAHEADER emh;
2403 assert(run->nFlags & MERF_GRAPHICS);
2404 assert(run->ole_obj);
2406 if (run->ole_obj->sizel.cx != 0 || run->ole_obj->sizel.cy != 0)
2408 convert_sizel(c, &run->ole_obj->sizel, pSize);
2409 if (c->editor->nZoomNumerator != 0)
2411 pSize->cx = MulDiv(pSize->cx, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
2412 pSize->cy = MulDiv(pSize->cy, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
2414 return;
2417 if (IOleObject_QueryInterface(run->ole_obj->poleobj, &IID_IDataObject, (void**)&ido) != S_OK)
2419 FIXME("Query Interface IID_IDataObject failed!\n");
2420 pSize->cx = pSize->cy = 0;
2421 return;
2423 fmt.cfFormat = CF_BITMAP;
2424 fmt.ptd = NULL;
2425 fmt.dwAspect = DVASPECT_CONTENT;
2426 fmt.lindex = -1;
2427 fmt.tymed = TYMED_GDI;
2428 if (IDataObject_GetData(ido, &fmt, &stgm) != S_OK)
2430 fmt.cfFormat = CF_ENHMETAFILE;
2431 fmt.tymed = TYMED_ENHMF;
2432 if (IDataObject_GetData(ido, &fmt, &stgm) != S_OK)
2434 FIXME("unsupported format\n");
2435 pSize->cx = pSize->cy = 0;
2436 IDataObject_Release(ido);
2437 return;
2441 switch (stgm.tymed)
2443 case TYMED_GDI:
2444 GetObjectW(stgm.u.hBitmap, sizeof(dibsect), &dibsect);
2445 pSize->cx = dibsect.dsBm.bmWidth;
2446 pSize->cy = dibsect.dsBm.bmHeight;
2447 if (!stgm.pUnkForRelease) DeleteObject(stgm.u.hBitmap);
2448 break;
2449 case TYMED_ENHMF:
2450 GetEnhMetaFileHeader(stgm.u.hEnhMetaFile, sizeof(emh), &emh);
2451 pSize->cx = emh.rclBounds.right - emh.rclBounds.left;
2452 pSize->cy = emh.rclBounds.bottom - emh.rclBounds.top;
2453 if (!stgm.pUnkForRelease) DeleteEnhMetaFile(stgm.u.hEnhMetaFile);
2454 break;
2455 default:
2456 FIXME("Unsupported tymed %d\n", stgm.tymed);
2457 break;
2459 IDataObject_Release(ido);
2460 if (c->editor->nZoomNumerator != 0)
2462 pSize->cx = MulDiv(pSize->cx, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
2463 pSize->cy = MulDiv(pSize->cy, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
2467 void ME_DrawOLE(ME_Context *c, int x, int y, ME_Run *run,
2468 ME_Paragraph *para, BOOL selected)
2470 IDataObject* ido;
2471 FORMATETC fmt;
2472 STGMEDIUM stgm;
2473 DIBSECTION dibsect;
2474 ENHMETAHEADER emh;
2475 HDC hMemDC;
2476 SIZE sz;
2477 BOOL has_size;
2479 assert(run->nFlags & MERF_GRAPHICS);
2480 assert(run->ole_obj);
2481 if (IOleObject_QueryInterface(run->ole_obj->poleobj, &IID_IDataObject, (void**)&ido) != S_OK)
2483 FIXME("Couldn't get interface\n");
2484 return;
2486 has_size = run->ole_obj->sizel.cx != 0 || run->ole_obj->sizel.cy != 0;
2487 fmt.cfFormat = CF_BITMAP;
2488 fmt.ptd = NULL;
2489 fmt.dwAspect = DVASPECT_CONTENT;
2490 fmt.lindex = -1;
2491 fmt.tymed = TYMED_GDI;
2492 if (IDataObject_GetData(ido, &fmt, &stgm) != S_OK)
2494 fmt.cfFormat = CF_ENHMETAFILE;
2495 fmt.tymed = TYMED_ENHMF;
2496 if (IDataObject_GetData(ido, &fmt, &stgm) != S_OK)
2498 FIXME("Couldn't get storage medium\n");
2499 IDataObject_Release(ido);
2500 return;
2503 switch (stgm.tymed)
2505 case TYMED_GDI:
2506 GetObjectW(stgm.u.hBitmap, sizeof(dibsect), &dibsect);
2507 hMemDC = CreateCompatibleDC(c->hDC);
2508 SelectObject(hMemDC, stgm.u.hBitmap);
2509 if (has_size)
2511 convert_sizel(c, &run->ole_obj->sizel, &sz);
2512 } else {
2513 sz.cx = MulDiv(dibsect.dsBm.bmWidth, c->dpi.cx, 96);
2514 sz.cy = MulDiv(dibsect.dsBm.bmHeight, c->dpi.cy, 96);
2516 if (c->editor->nZoomNumerator != 0)
2518 sz.cx = MulDiv(sz.cx, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
2519 sz.cy = MulDiv(sz.cy, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
2521 if (sz.cx == dibsect.dsBm.bmWidth && sz.cy == dibsect.dsBm.bmHeight)
2523 BitBlt(c->hDC, x, y - sz.cy,
2524 dibsect.dsBm.bmWidth, dibsect.dsBm.bmHeight,
2525 hMemDC, 0, 0, SRCCOPY);
2526 } else {
2527 StretchBlt(c->hDC, x, y - sz.cy, sz.cx, sz.cy,
2528 hMemDC, 0, 0, dibsect.dsBm.bmWidth,
2529 dibsect.dsBm.bmHeight, SRCCOPY);
2531 DeleteDC(hMemDC);
2532 if (!stgm.pUnkForRelease) DeleteObject(stgm.u.hBitmap);
2533 break;
2534 case TYMED_ENHMF:
2535 GetEnhMetaFileHeader(stgm.u.hEnhMetaFile, sizeof(emh), &emh);
2536 if (has_size)
2538 convert_sizel(c, &run->ole_obj->sizel, &sz);
2539 } else {
2540 sz.cy = MulDiv(emh.rclBounds.bottom - emh.rclBounds.top, c->dpi.cx, 96);
2541 sz.cx = MulDiv(emh.rclBounds.right - emh.rclBounds.left, c->dpi.cy, 96);
2543 if (c->editor->nZoomNumerator != 0)
2545 sz.cx = MulDiv(sz.cx, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
2546 sz.cy = MulDiv(sz.cy, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
2550 RECT rc;
2552 rc.left = x;
2553 rc.top = y - sz.cy;
2554 rc.right = x + sz.cx;
2555 rc.bottom = y;
2556 PlayEnhMetaFile(c->hDC, stgm.u.hEnhMetaFile, &rc);
2558 if (!stgm.pUnkForRelease) DeleteEnhMetaFile(stgm.u.hEnhMetaFile);
2559 break;
2560 default:
2561 FIXME("Unsupported tymed %d\n", stgm.tymed);
2562 selected = FALSE;
2563 break;
2565 if (selected && !c->editor->bHideSelection)
2566 PatBlt(c->hDC, x, y - sz.cy, sz.cx, sz.cy, DSTINVERT);
2567 IDataObject_Release(ido);
2570 void ME_DeleteReObject(REOBJECT* reo)
2572 if (reo->poleobj) IOleObject_Release(reo->poleobj);
2573 if (reo->pstg) IStorage_Release(reo->pstg);
2574 if (reo->polesite) IOleClientSite_Release(reo->polesite);
2575 FREE_OBJ(reo);
2578 void ME_CopyReObject(REOBJECT* dst, const REOBJECT* src)
2580 *dst = *src;
2582 if (dst->poleobj) IOleObject_AddRef(dst->poleobj);
2583 if (dst->pstg) IStorage_AddRef(dst->pstg);
2584 if (dst->polesite) IOleClientSite_AddRef(dst->polesite);
2587 void ME_GetITextDocumentInterface(IRichEditOle *iface, LPVOID *ppvObj)
2589 IRichEditOleImpl *This = impl_from_IRichEditOle(iface);
2590 *ppvObj = &This->ITextDocument_iface;