d2d1: Implement d2d_d3d_render_target_CreateBitmap().
[wine/multimedia.git] / dlls / riched20 / richole.c
blob963368f269e3eaff7579cba8eec57ad846772b11
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 IRichEditOle IRichEditOle_iface;
56 ITextDocument ITextDocument_iface;
57 LONG ref;
59 ME_TextEditor *editor;
60 ITextSelectionImpl *txtSel;
61 IOleClientSiteImpl *clientSite;
62 struct list rangelist;
63 } IRichEditOleImpl;
65 struct ITextRangeImpl {
66 ITextRange ITextRange_iface;
67 LONG ref;
68 LONG start, end;
69 struct list entry;
71 IRichEditOleImpl *reOle;
74 struct ITextSelectionImpl {
75 ITextSelection ITextSelection_iface;
76 LONG ref;
78 IRichEditOleImpl *reOle;
81 struct IOleClientSiteImpl {
82 IOleClientSite IOleClientSite_iface;
83 LONG ref;
85 IRichEditOleImpl *reOle;
88 static inline IRichEditOleImpl *impl_from_IRichEditOle(IRichEditOle *iface)
90 return CONTAINING_RECORD(iface, IRichEditOleImpl, IRichEditOle_iface);
93 static inline IRichEditOleImpl *impl_from_ITextDocument(ITextDocument *iface)
95 return CONTAINING_RECORD(iface, IRichEditOleImpl, ITextDocument_iface);
98 static HRESULT WINAPI
99 IRichEditOle_fnQueryInterface(IRichEditOle *me, REFIID riid, LPVOID *ppvObj)
101 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
103 TRACE("%p %s\n", This, debugstr_guid(riid) );
105 *ppvObj = NULL;
106 if (IsEqualGUID(riid, &IID_IUnknown) ||
107 IsEqualGUID(riid, &IID_IRichEditOle))
108 *ppvObj = &This->IRichEditOle_iface;
109 else if (IsEqualGUID(riid, &IID_ITextDocument))
110 *ppvObj = &This->ITextDocument_iface;
111 if (*ppvObj)
113 IRichEditOle_AddRef(me);
114 return S_OK;
116 FIXME("%p: unhandled interface %s\n", This, debugstr_guid(riid) );
118 return E_NOINTERFACE;
121 static ULONG WINAPI
122 IRichEditOle_fnAddRef(IRichEditOle *me)
124 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
125 ULONG ref = InterlockedIncrement( &This->ref );
127 TRACE("%p ref = %u\n", This, ref);
129 return ref;
132 static ULONG WINAPI
133 IRichEditOle_fnRelease(IRichEditOle *me)
135 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
136 ULONG ref = InterlockedDecrement(&This->ref);
138 TRACE ("%p ref=%u\n", This, ref);
140 if (!ref)
142 ITextRangeImpl *txtRge;
143 TRACE ("Destroying %p\n", This);
144 This->txtSel->reOle = NULL;
145 ITextSelection_Release(&This->txtSel->ITextSelection_iface);
146 IOleClientSite_Release(&This->clientSite->IOleClientSite_iface);
147 LIST_FOR_EACH_ENTRY(txtRge, &This->rangelist, ITextRangeImpl, entry)
148 txtRge->reOle = NULL;
149 heap_free(This);
151 return ref;
154 static HRESULT WINAPI
155 IRichEditOle_fnActivateAs(IRichEditOle *me, REFCLSID rclsid, REFCLSID rclsidAs)
157 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
158 FIXME("stub %p\n",This);
159 return E_NOTIMPL;
162 static HRESULT WINAPI
163 IRichEditOle_fnContextSensitiveHelp(IRichEditOle *me, BOOL fEnterMode)
165 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
166 FIXME("stub %p\n",This);
167 return E_NOTIMPL;
170 static HRESULT WINAPI
171 IRichEditOle_fnConvertObject(IRichEditOle *me, LONG iob,
172 REFCLSID rclsidNew, LPCSTR lpstrUserTypeNew)
174 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
175 FIXME("stub %p\n",This);
176 return E_NOTIMPL;
179 static inline IOleClientSiteImpl *impl_from_IOleClientSite(IOleClientSite *iface)
181 return CONTAINING_RECORD(iface, IOleClientSiteImpl, IOleClientSite_iface);
184 static HRESULT WINAPI
185 IOleClientSite_fnQueryInterface(IOleClientSite *me, REFIID riid, LPVOID *ppvObj)
187 TRACE("%p %s\n", me, debugstr_guid(riid) );
189 *ppvObj = NULL;
190 if (IsEqualGUID(riid, &IID_IUnknown) ||
191 IsEqualGUID(riid, &IID_IOleClientSite))
192 *ppvObj = me;
193 if (*ppvObj)
195 IOleClientSite_AddRef(me);
196 return S_OK;
198 FIXME("%p: unhandled interface %s\n", me, debugstr_guid(riid) );
200 return E_NOINTERFACE;
203 static ULONG WINAPI IOleClientSite_fnAddRef(IOleClientSite *iface)
205 IOleClientSiteImpl *This = impl_from_IOleClientSite(iface);
206 return InterlockedIncrement(&This->ref);
209 static ULONG WINAPI IOleClientSite_fnRelease(IOleClientSite *iface)
211 IOleClientSiteImpl *This = impl_from_IOleClientSite(iface);
212 ULONG ref = InterlockedDecrement(&This->ref);
213 if (ref == 0)
214 heap_free(This);
215 return ref;
218 static HRESULT WINAPI IOleClientSite_fnSaveObject(IOleClientSite *iface)
220 IOleClientSiteImpl *This = impl_from_IOleClientSite(iface);
221 if (!This->reOle)
222 return CO_E_RELEASED;
224 FIXME("stub %p\n", iface);
225 return E_NOTIMPL;
229 static HRESULT WINAPI IOleClientSite_fnGetMoniker(IOleClientSite *iface, DWORD dwAssign,
230 DWORD dwWhichMoniker, IMoniker **ppmk)
232 IOleClientSiteImpl *This = impl_from_IOleClientSite(iface);
233 if (!This->reOle)
234 return CO_E_RELEASED;
236 FIXME("stub %p\n", iface);
237 return E_NOTIMPL;
240 static HRESULT WINAPI IOleClientSite_fnGetContainer(IOleClientSite *iface,
241 IOleContainer **ppContainer)
243 IOleClientSiteImpl *This = impl_from_IOleClientSite(iface);
244 if (!This->reOle)
245 return CO_E_RELEASED;
247 FIXME("stub %p\n", iface);
248 return E_NOTIMPL;
251 static HRESULT WINAPI IOleClientSite_fnShowObject(IOleClientSite *iface)
253 IOleClientSiteImpl *This = impl_from_IOleClientSite(iface);
254 if (!This->reOle)
255 return CO_E_RELEASED;
257 FIXME("stub %p\n", iface);
258 return E_NOTIMPL;
261 static HRESULT WINAPI IOleClientSite_fnOnShowWindow(IOleClientSite *iface, BOOL fShow)
263 IOleClientSiteImpl *This = impl_from_IOleClientSite(iface);
264 if (!This->reOle)
265 return CO_E_RELEASED;
267 FIXME("stub %p\n", iface);
268 return E_NOTIMPL;
271 static HRESULT WINAPI IOleClientSite_fnRequestNewObjectLayout(IOleClientSite *iface)
273 IOleClientSiteImpl *This = impl_from_IOleClientSite(iface);
274 if (!This->reOle)
275 return CO_E_RELEASED;
277 FIXME("stub %p\n", iface);
278 return E_NOTIMPL;
281 static const IOleClientSiteVtbl ocst = {
282 IOleClientSite_fnQueryInterface,
283 IOleClientSite_fnAddRef,
284 IOleClientSite_fnRelease,
285 IOleClientSite_fnSaveObject,
286 IOleClientSite_fnGetMoniker,
287 IOleClientSite_fnGetContainer,
288 IOleClientSite_fnShowObject,
289 IOleClientSite_fnOnShowWindow,
290 IOleClientSite_fnRequestNewObjectLayout
293 static IOleClientSiteImpl *
294 CreateOleClientSite(IRichEditOleImpl *reOle)
296 IOleClientSiteImpl *clientSite = heap_alloc(sizeof *clientSite);
297 if (!clientSite)
298 return NULL;
300 clientSite->IOleClientSite_iface.lpVtbl = &ocst;
301 clientSite->ref = 1;
302 clientSite->reOle = reOle;
303 return clientSite;
306 static HRESULT WINAPI
307 IRichEditOle_fnGetClientSite(IRichEditOle *me,
308 LPOLECLIENTSITE *lplpolesite)
310 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
312 TRACE("%p,%p\n",This, lplpolesite);
314 if(!lplpolesite)
315 return E_INVALIDARG;
316 *lplpolesite = &This->clientSite->IOleClientSite_iface;
317 IOleClientSite_AddRef(*lplpolesite);
318 return S_OK;
321 static HRESULT WINAPI
322 IRichEditOle_fnGetClipboardData(IRichEditOle *me, CHARRANGE *lpchrg,
323 DWORD reco, LPDATAOBJECT *lplpdataobj)
325 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
326 ME_Cursor start;
327 int nChars;
329 TRACE("(%p,%p,%d)\n",This, lpchrg, reco);
330 if(!lplpdataobj)
331 return E_INVALIDARG;
332 if(!lpchrg) {
333 int nFrom, nTo, nStartCur = ME_GetSelectionOfs(This->editor, &nFrom, &nTo);
334 start = This->editor->pCursors[nStartCur];
335 nChars = nTo - nFrom;
336 } else {
337 ME_CursorFromCharOfs(This->editor, lpchrg->cpMin, &start);
338 nChars = lpchrg->cpMax - lpchrg->cpMin;
340 return ME_GetDataObject(This->editor, &start, nChars, lplpdataobj);
343 static LONG WINAPI IRichEditOle_fnGetLinkCount(IRichEditOle *me)
345 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
346 FIXME("stub %p\n",This);
347 return E_NOTIMPL;
350 static HRESULT WINAPI
351 IRichEditOle_fnGetObject(IRichEditOle *me, LONG iob,
352 REOBJECT *lpreobject, DWORD dwFlags)
354 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
355 FIXME("stub %p\n",This);
356 return E_NOTIMPL;
359 static LONG WINAPI
360 IRichEditOle_fnGetObjectCount(IRichEditOle *me)
362 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
363 FIXME("stub %p\n",This);
364 return 0;
367 static HRESULT WINAPI
368 IRichEditOle_fnHandsOffStorage(IRichEditOle *me, LONG iob)
370 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
371 FIXME("stub %p\n",This);
372 return E_NOTIMPL;
375 static HRESULT WINAPI
376 IRichEditOle_fnImportDataObject(IRichEditOle *me, LPDATAOBJECT lpdataobj,
377 CLIPFORMAT cf, HGLOBAL hMetaPict)
379 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
380 FIXME("stub %p\n",This);
381 return E_NOTIMPL;
384 static HRESULT WINAPI
385 IRichEditOle_fnInPlaceDeactivate(IRichEditOle *me)
387 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
388 FIXME("stub %p\n",This);
389 return E_NOTIMPL;
392 static HRESULT WINAPI
393 IRichEditOle_fnInsertObject(IRichEditOle *me, REOBJECT *reo)
395 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
396 TRACE("(%p,%p)\n", This, reo);
398 if (reo->cbStruct < sizeof(*reo)) return STG_E_INVALIDPARAMETER;
400 ME_InsertOLEFromCursor(This->editor, reo, 0);
401 ME_CommitUndo(This->editor);
402 ME_UpdateRepaint(This->editor, FALSE);
403 return S_OK;
406 static HRESULT WINAPI IRichEditOle_fnSaveCompleted(IRichEditOle *me, LONG iob,
407 LPSTORAGE lpstg)
409 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
410 FIXME("stub %p\n",This);
411 return E_NOTIMPL;
414 static HRESULT WINAPI
415 IRichEditOle_fnSetDvaspect(IRichEditOle *me, LONG iob, DWORD dvaspect)
417 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
418 FIXME("stub %p\n",This);
419 return E_NOTIMPL;
422 static HRESULT WINAPI IRichEditOle_fnSetHostNames(IRichEditOle *me,
423 LPCSTR lpstrContainerApp, LPCSTR lpstrContainerObj)
425 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
426 FIXME("stub %p %s %s\n",This, lpstrContainerApp, lpstrContainerObj);
427 return E_NOTIMPL;
430 static HRESULT WINAPI
431 IRichEditOle_fnSetLinkAvailable(IRichEditOle *me, LONG iob, BOOL fAvailable)
433 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
434 FIXME("stub %p\n",This);
435 return E_NOTIMPL;
438 static const IRichEditOleVtbl revt = {
439 IRichEditOle_fnQueryInterface,
440 IRichEditOle_fnAddRef,
441 IRichEditOle_fnRelease,
442 IRichEditOle_fnGetClientSite,
443 IRichEditOle_fnGetObjectCount,
444 IRichEditOle_fnGetLinkCount,
445 IRichEditOle_fnGetObject,
446 IRichEditOle_fnInsertObject,
447 IRichEditOle_fnConvertObject,
448 IRichEditOle_fnActivateAs,
449 IRichEditOle_fnSetHostNames,
450 IRichEditOle_fnSetLinkAvailable,
451 IRichEditOle_fnSetDvaspect,
452 IRichEditOle_fnHandsOffStorage,
453 IRichEditOle_fnSaveCompleted,
454 IRichEditOle_fnInPlaceDeactivate,
455 IRichEditOle_fnContextSensitiveHelp,
456 IRichEditOle_fnGetClipboardData,
457 IRichEditOle_fnImportDataObject
460 /* ITextRange interface */
461 static inline ITextRangeImpl *impl_from_ITextRange(ITextRange *iface)
463 return CONTAINING_RECORD(iface, ITextRangeImpl, ITextRange_iface);
466 static HRESULT WINAPI ITextRange_fnQueryInterface(ITextRange *me, REFIID riid, void **ppvObj)
468 *ppvObj = NULL;
469 if (IsEqualGUID(riid, &IID_IUnknown)
470 || IsEqualGUID(riid, &IID_IDispatch)
471 || IsEqualGUID(riid, &IID_ITextRange))
473 *ppvObj = me;
474 ITextRange_AddRef(me);
475 return S_OK;
478 return E_NOINTERFACE;
481 static ULONG WINAPI ITextRange_fnAddRef(ITextRange *me)
483 ITextRangeImpl *This = impl_from_ITextRange(me);
484 return InterlockedIncrement(&This->ref);
487 static ULONG WINAPI ITextRange_fnRelease(ITextRange *me)
489 ITextRangeImpl *This = impl_from_ITextRange(me);
490 ULONG ref = InterlockedDecrement(&This->ref);
492 TRACE ("%p ref=%u\n", This, ref);
493 if (ref == 0)
495 if (This->reOle)
497 list_remove(&This->entry);
498 This->reOle = NULL;
500 heap_free(This);
502 return ref;
505 static HRESULT WINAPI ITextRange_fnGetTypeInfoCount(ITextRange *me, UINT *pctinfo)
507 ITextRangeImpl *This = impl_from_ITextRange(me);
508 if (!This->reOle)
509 return CO_E_RELEASED;
511 FIXME("not implemented %p\n", This);
512 return E_NOTIMPL;
515 static HRESULT WINAPI ITextRange_fnGetTypeInfo(ITextRange *me, UINT iTInfo, LCID lcid,
516 ITypeInfo **ppTInfo)
518 ITextRangeImpl *This = impl_from_ITextRange(me);
519 if (!This->reOle)
520 return CO_E_RELEASED;
522 FIXME("not implemented %p\n", This);
523 return E_NOTIMPL;
526 static HRESULT WINAPI ITextRange_fnGetIDsOfNames(ITextRange *me, REFIID riid, LPOLESTR *rgszNames,
527 UINT cNames, LCID lcid, DISPID *rgDispId)
529 ITextRangeImpl *This = impl_from_ITextRange(me);
530 if (!This->reOle)
531 return CO_E_RELEASED;
533 FIXME("not implemented %p\n", This);
534 return E_NOTIMPL;
537 static HRESULT WINAPI ITextRange_fnInvoke(ITextRange *me, DISPID dispIdMember, REFIID riid,
538 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
539 VARIANT *pVarResult, EXCEPINFO *pExcepInfo,
540 UINT *puArgErr)
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_fnGetText(ITextRange *me, BSTR *pbstr)
552 ITextRangeImpl *This = impl_from_ITextRange(me);
553 if (!This->reOle)
554 return CO_E_RELEASED;
556 FIXME("not implemented %p\n", This);
557 return E_NOTIMPL;
560 static HRESULT WINAPI ITextRange_fnSetText(ITextRange *me, BSTR bstr)
562 ITextRangeImpl *This = impl_from_ITextRange(me);
563 if (!This->reOle)
564 return CO_E_RELEASED;
566 FIXME("not implemented %p\n", This);
567 return E_NOTIMPL;
570 static HRESULT range_GetChar(ME_TextEditor *editor, ME_Cursor *cursor, LONG *pch)
572 WCHAR wch[2];
574 ME_GetTextW(editor, wch, 1, cursor, 1, FALSE, cursor->pRun->next->type == diTextEnd);
575 *pch = wch[0];
577 return S_OK;
580 static HRESULT WINAPI ITextRange_fnGetChar(ITextRange *me, LONG *pch)
582 ITextRangeImpl *This = impl_from_ITextRange(me);
583 ME_Cursor cursor;
585 if (!This->reOle)
586 return CO_E_RELEASED;
587 TRACE("%p\n", pch);
588 if (!pch)
589 return E_INVALIDARG;
591 ME_CursorFromCharOfs(This->reOle->editor, This->start, &cursor);
592 return range_GetChar(This->reOle->editor, &cursor, pch);
595 static HRESULT WINAPI ITextRange_fnSetChar(ITextRange *me, LONG ch)
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 WINAPI ITextRange_fnGetDuplicate(ITextRange *me, ITextRange **ppRange)
607 ITextRangeImpl *This = impl_from_ITextRange(me);
608 if (!This->reOle)
609 return CO_E_RELEASED;
611 FIXME("not implemented %p\n", This);
612 return E_NOTIMPL;
615 static HRESULT WINAPI ITextRange_fnGetFormattedText(ITextRange *me, ITextRange **ppRange)
617 ITextRangeImpl *This = impl_from_ITextRange(me);
618 if (!This->reOle)
619 return CO_E_RELEASED;
621 FIXME("not implemented %p\n", This);
622 return E_NOTIMPL;
625 static HRESULT WINAPI ITextRange_fnSetFormattedText(ITextRange *me, ITextRange *pRange)
627 ITextRangeImpl *This = impl_from_ITextRange(me);
628 if (!This->reOle)
629 return CO_E_RELEASED;
631 FIXME("not implemented %p\n", This);
632 return E_NOTIMPL;
635 static HRESULT WINAPI ITextRange_fnGetStart(ITextRange *me, LONG *pcpFirst)
637 ITextRangeImpl *This = impl_from_ITextRange(me);
638 if (!This->reOle)
639 return CO_E_RELEASED;
641 FIXME("not implemented %p\n", This);
642 return E_NOTIMPL;
645 static HRESULT WINAPI ITextRange_fnSetStart(ITextRange *me, LONG cpFirst)
647 ITextRangeImpl *This = impl_from_ITextRange(me);
648 if (!This->reOle)
649 return CO_E_RELEASED;
651 FIXME("not implemented %p\n", This);
652 return E_NOTIMPL;
655 static HRESULT WINAPI ITextRange_fnGetEnd(ITextRange *me, LONG *pcpLim)
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_fnSetEnd(ITextRange *me, LONG cpLim)
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_fnGetFont(ITextRange *me, ITextFont **pFont)
677 ITextRangeImpl *This = impl_from_ITextRange(me);
678 if (!This->reOle)
679 return CO_E_RELEASED;
681 FIXME("not implemented %p\n", This);
682 return E_NOTIMPL;
685 static HRESULT WINAPI ITextRange_fnSetFont(ITextRange *me, ITextFont *pFont)
687 ITextRangeImpl *This = impl_from_ITextRange(me);
688 if (!This->reOle)
689 return CO_E_RELEASED;
691 FIXME("not implemented %p\n", This);
692 return E_NOTIMPL;
695 static HRESULT WINAPI ITextRange_fnGetPara(ITextRange *me, ITextPara **ppPara)
697 ITextRangeImpl *This = impl_from_ITextRange(me);
698 if (!This->reOle)
699 return CO_E_RELEASED;
701 FIXME("not implemented %p\n", This);
702 return E_NOTIMPL;
705 static HRESULT WINAPI ITextRange_fnSetPara(ITextRange *me, ITextPara *pPara)
707 ITextRangeImpl *This = impl_from_ITextRange(me);
708 if (!This->reOle)
709 return CO_E_RELEASED;
711 FIXME("not implemented %p\n", This);
712 return E_NOTIMPL;
715 static HRESULT WINAPI ITextRange_fnGetStoryLength(ITextRange *me, LONG *pcch)
717 ITextRangeImpl *This = impl_from_ITextRange(me);
718 if (!This->reOle)
719 return CO_E_RELEASED;
721 FIXME("not implemented %p\n", This);
722 return E_NOTIMPL;
725 static HRESULT WINAPI ITextRange_fnGetStoryType(ITextRange *me, LONG *pValue)
727 ITextRangeImpl *This = impl_from_ITextRange(me);
728 if (!This->reOle)
729 return CO_E_RELEASED;
731 FIXME("not implemented %p\n", This);
732 return E_NOTIMPL;
735 static HRESULT WINAPI ITextRange_fnCollapse(ITextRange *me, LONG bStart)
737 ITextRangeImpl *This = impl_from_ITextRange(me);
738 if (!This->reOle)
739 return CO_E_RELEASED;
741 FIXME("not implemented %p\n", This);
742 return E_NOTIMPL;
745 static HRESULT WINAPI ITextRange_fnExpand(ITextRange *me, LONG Unit, LONG *pDelta)
747 ITextRangeImpl *This = impl_from_ITextRange(me);
748 if (!This->reOle)
749 return CO_E_RELEASED;
751 FIXME("not implemented %p\n", This);
752 return E_NOTIMPL;
755 static HRESULT WINAPI ITextRange_fnGetIndex(ITextRange *me, LONG Unit, LONG *pIndex)
757 ITextRangeImpl *This = impl_from_ITextRange(me);
758 if (!This->reOle)
759 return CO_E_RELEASED;
761 FIXME("not implemented %p\n", This);
762 return E_NOTIMPL;
765 static HRESULT WINAPI ITextRange_fnSetIndex(ITextRange *me, LONG Unit, LONG Index,
766 LONG Extend)
768 ITextRangeImpl *This = impl_from_ITextRange(me);
769 if (!This->reOle)
770 return CO_E_RELEASED;
772 FIXME("not implemented %p\n", This);
773 return E_NOTIMPL;
776 static HRESULT WINAPI ITextRange_fnSetRange(ITextRange *me, LONG cpActive, LONG cpOther)
778 ITextRangeImpl *This = impl_from_ITextRange(me);
779 if (!This->reOle)
780 return CO_E_RELEASED;
782 FIXME("not implemented %p\n", This);
783 return E_NOTIMPL;
786 static HRESULT WINAPI ITextRange_fnInRange(ITextRange *me, ITextRange *pRange, LONG *pb)
788 ITextRangeImpl *This = impl_from_ITextRange(me);
789 if (!This->reOle)
790 return CO_E_RELEASED;
792 FIXME("not implemented %p\n", This);
793 return E_NOTIMPL;
796 static HRESULT WINAPI ITextRange_fnInStory(ITextRange *me, ITextRange *pRange, LONG *pb)
798 ITextRangeImpl *This = impl_from_ITextRange(me);
799 if (!This->reOle)
800 return CO_E_RELEASED;
802 FIXME("not implemented %p\n", This);
803 return E_NOTIMPL;
806 static HRESULT WINAPI ITextRange_fnIsEqual(ITextRange *me, ITextRange *pRange, LONG *pb)
808 ITextRangeImpl *This = impl_from_ITextRange(me);
809 if (!This->reOle)
810 return CO_E_RELEASED;
812 FIXME("not implemented %p\n", This);
813 return E_NOTIMPL;
816 static HRESULT WINAPI ITextRange_fnSelect(ITextRange *me)
818 ITextRangeImpl *This = impl_from_ITextRange(me);
819 if (!This->reOle)
820 return CO_E_RELEASED;
822 FIXME("not implemented %p\n", This);
823 return E_NOTIMPL;
826 static HRESULT WINAPI ITextRange_fnStartOf(ITextRange *me, LONG Unit, LONG Extend,
827 LONG *pDelta)
829 ITextRangeImpl *This = impl_from_ITextRange(me);
830 if (!This->reOle)
831 return CO_E_RELEASED;
833 FIXME("not implemented %p\n", This);
834 return E_NOTIMPL;
837 static HRESULT WINAPI ITextRange_fnEndOf(ITextRange *me, LONG Unit, LONG Extend,
838 LONG *pDelta)
840 ITextRangeImpl *This = impl_from_ITextRange(me);
841 if (!This->reOle)
842 return CO_E_RELEASED;
844 FIXME("not implemented %p\n", This);
845 return E_NOTIMPL;
848 static HRESULT WINAPI ITextRange_fnMove(ITextRange *me, LONG Unit, LONG Count, LONG *pDelta)
850 ITextRangeImpl *This = impl_from_ITextRange(me);
851 if (!This->reOle)
852 return CO_E_RELEASED;
854 FIXME("not implemented %p\n", This);
855 return E_NOTIMPL;
858 static HRESULT WINAPI ITextRange_fnMoveStart(ITextRange *me, LONG Unit, LONG Count,
859 LONG *pDelta)
861 ITextRangeImpl *This = impl_from_ITextRange(me);
862 if (!This->reOle)
863 return CO_E_RELEASED;
865 FIXME("not implemented %p\n", This);
866 return E_NOTIMPL;
869 static HRESULT WINAPI ITextRange_fnMoveEnd(ITextRange *me, LONG Unit, LONG Count,
870 LONG *pDelta)
872 ITextRangeImpl *This = impl_from_ITextRange(me);
873 if (!This->reOle)
874 return CO_E_RELEASED;
876 FIXME("not implemented %p\n", This);
877 return E_NOTIMPL;
880 static HRESULT WINAPI ITextRange_fnMoveWhile(ITextRange *me, VARIANT *Cset, LONG Count,
881 LONG *pDelta)
883 ITextRangeImpl *This = impl_from_ITextRange(me);
884 if (!This->reOle)
885 return CO_E_RELEASED;
887 FIXME("not implemented %p\n", This);
888 return E_NOTIMPL;
891 static HRESULT WINAPI ITextRange_fnMoveStartWhile(ITextRange *me, VARIANT *Cset, LONG Count,
892 LONG *pDelta)
894 ITextRangeImpl *This = impl_from_ITextRange(me);
895 if (!This->reOle)
896 return CO_E_RELEASED;
898 FIXME("not implemented %p\n", This);
899 return E_NOTIMPL;
902 static HRESULT WINAPI ITextRange_fnMoveEndWhile(ITextRange *me, VARIANT *Cset, LONG Count,
903 LONG *pDelta)
905 ITextRangeImpl *This = impl_from_ITextRange(me);
906 if (!This->reOle)
907 return CO_E_RELEASED;
909 FIXME("not implemented %p\n", This);
910 return E_NOTIMPL;
913 static HRESULT WINAPI ITextRange_fnMoveUntil(ITextRange *me, VARIANT *Cset, LONG Count,
914 LONG *pDelta)
916 ITextRangeImpl *This = impl_from_ITextRange(me);
917 if (!This->reOle)
918 return CO_E_RELEASED;
920 FIXME("not implemented %p\n", This);
921 return E_NOTIMPL;
924 static HRESULT WINAPI ITextRange_fnMoveStartUntil(ITextRange *me, VARIANT *Cset, LONG Count,
925 LONG *pDelta)
927 ITextRangeImpl *This = impl_from_ITextRange(me);
928 if (!This->reOle)
929 return CO_E_RELEASED;
931 FIXME("not implemented %p\n", This);
932 return E_NOTIMPL;
935 static HRESULT WINAPI ITextRange_fnMoveEndUntil(ITextRange *me, VARIANT *Cset, LONG Count,
936 LONG *pDelta)
938 ITextRangeImpl *This = impl_from_ITextRange(me);
939 if (!This->reOle)
940 return CO_E_RELEASED;
942 FIXME("not implemented %p\n", This);
943 return E_NOTIMPL;
946 static HRESULT WINAPI ITextRange_fnFindText(ITextRange *me, BSTR bstr, LONG cch, LONG Flags,
947 LONG *pLength)
949 ITextRangeImpl *This = impl_from_ITextRange(me);
950 if (!This->reOle)
951 return CO_E_RELEASED;
953 FIXME("not implemented %p\n", This);
954 return E_NOTIMPL;
957 static HRESULT WINAPI ITextRange_fnFindTextStart(ITextRange *me, BSTR bstr, LONG cch,
958 LONG Flags, LONG *pLength)
960 ITextRangeImpl *This = impl_from_ITextRange(me);
961 if (!This->reOle)
962 return CO_E_RELEASED;
964 FIXME("not implemented %p\n", This);
965 return E_NOTIMPL;
968 static HRESULT WINAPI ITextRange_fnFindTextEnd(ITextRange *me, BSTR bstr, LONG cch,
969 LONG Flags, LONG *pLength)
971 ITextRangeImpl *This = impl_from_ITextRange(me);
972 if (!This->reOle)
973 return CO_E_RELEASED;
975 FIXME("not implemented %p\n", This);
976 return E_NOTIMPL;
979 static HRESULT WINAPI ITextRange_fnDelete(ITextRange *me, LONG Unit, LONG Count,
980 LONG *pDelta)
982 ITextRangeImpl *This = impl_from_ITextRange(me);
983 if (!This->reOle)
984 return CO_E_RELEASED;
986 FIXME("not implemented %p\n", This);
987 return E_NOTIMPL;
990 static HRESULT WINAPI ITextRange_fnCut(ITextRange *me, VARIANT *pVar)
992 ITextRangeImpl *This = impl_from_ITextRange(me);
993 if (!This->reOle)
994 return CO_E_RELEASED;
996 FIXME("not implemented %p\n", This);
997 return E_NOTIMPL;
1000 static HRESULT WINAPI ITextRange_fnCopy(ITextRange *me, VARIANT *pVar)
1002 ITextRangeImpl *This = impl_from_ITextRange(me);
1003 if (!This->reOle)
1004 return CO_E_RELEASED;
1006 FIXME("not implemented %p\n", This);
1007 return E_NOTIMPL;
1010 static HRESULT WINAPI ITextRange_fnPaste(ITextRange *me, VARIANT *pVar, LONG Format)
1012 ITextRangeImpl *This = impl_from_ITextRange(me);
1013 if (!This->reOle)
1014 return CO_E_RELEASED;
1016 FIXME("not implemented %p\n", This);
1017 return E_NOTIMPL;
1020 static HRESULT WINAPI ITextRange_fnCanPaste(ITextRange *me, VARIANT *pVar, LONG Format,
1021 LONG *pb)
1023 ITextRangeImpl *This = impl_from_ITextRange(me);
1024 if (!This->reOle)
1025 return CO_E_RELEASED;
1027 FIXME("not implemented %p\n", This);
1028 return E_NOTIMPL;
1031 static HRESULT WINAPI ITextRange_fnCanEdit(ITextRange *me, LONG *pb)
1033 ITextRangeImpl *This = impl_from_ITextRange(me);
1034 if (!This->reOle)
1035 return CO_E_RELEASED;
1037 FIXME("not implemented %p\n", This);
1038 return E_NOTIMPL;
1041 static HRESULT WINAPI ITextRange_fnChangeCase(ITextRange *me, LONG Type)
1043 ITextRangeImpl *This = impl_from_ITextRange(me);
1044 if (!This->reOle)
1045 return CO_E_RELEASED;
1047 FIXME("not implemented %p\n", This);
1048 return E_NOTIMPL;
1051 static HRESULT WINAPI ITextRange_fnGetPoint(ITextRange *me, LONG Type, LONG *cx, LONG *cy)
1053 ITextRangeImpl *This = impl_from_ITextRange(me);
1054 if (!This->reOle)
1055 return CO_E_RELEASED;
1057 FIXME("not implemented %p\n", This);
1058 return E_NOTIMPL;
1061 static HRESULT WINAPI ITextRange_fnSetPoint(ITextRange *me, LONG x, LONG y, LONG Type,
1062 LONG Extend)
1064 ITextRangeImpl *This = impl_from_ITextRange(me);
1065 if (!This->reOle)
1066 return CO_E_RELEASED;
1068 FIXME("not implemented %p\n", This);
1069 return E_NOTIMPL;
1072 static HRESULT WINAPI ITextRange_fnScrollIntoView(ITextRange *me, LONG Value)
1074 ITextRangeImpl *This = impl_from_ITextRange(me);
1075 if (!This->reOle)
1076 return CO_E_RELEASED;
1078 FIXME("not implemented %p\n", This);
1079 return E_NOTIMPL;
1082 static HRESULT WINAPI ITextRange_fnGetEmbeddedObject(ITextRange *me, IUnknown **ppv)
1084 ITextRangeImpl *This = impl_from_ITextRange(me);
1085 if (!This->reOle)
1086 return CO_E_RELEASED;
1088 FIXME("not implemented %p\n", This);
1089 return E_NOTIMPL;
1092 static const ITextRangeVtbl trvt = {
1093 ITextRange_fnQueryInterface,
1094 ITextRange_fnAddRef,
1095 ITextRange_fnRelease,
1096 ITextRange_fnGetTypeInfoCount,
1097 ITextRange_fnGetTypeInfo,
1098 ITextRange_fnGetIDsOfNames,
1099 ITextRange_fnInvoke,
1100 ITextRange_fnGetText,
1101 ITextRange_fnSetText,
1102 ITextRange_fnGetChar,
1103 ITextRange_fnSetChar,
1104 ITextRange_fnGetDuplicate,
1105 ITextRange_fnGetFormattedText,
1106 ITextRange_fnSetFormattedText,
1107 ITextRange_fnGetStart,
1108 ITextRange_fnSetStart,
1109 ITextRange_fnGetEnd,
1110 ITextRange_fnSetEnd,
1111 ITextRange_fnGetFont,
1112 ITextRange_fnSetFont,
1113 ITextRange_fnGetPara,
1114 ITextRange_fnSetPara,
1115 ITextRange_fnGetStoryLength,
1116 ITextRange_fnGetStoryType,
1117 ITextRange_fnCollapse,
1118 ITextRange_fnExpand,
1119 ITextRange_fnGetIndex,
1120 ITextRange_fnSetIndex,
1121 ITextRange_fnSetRange,
1122 ITextRange_fnInRange,
1123 ITextRange_fnInStory,
1124 ITextRange_fnIsEqual,
1125 ITextRange_fnSelect,
1126 ITextRange_fnStartOf,
1127 ITextRange_fnEndOf,
1128 ITextRange_fnMove,
1129 ITextRange_fnMoveStart,
1130 ITextRange_fnMoveEnd,
1131 ITextRange_fnMoveWhile,
1132 ITextRange_fnMoveStartWhile,
1133 ITextRange_fnMoveEndWhile,
1134 ITextRange_fnMoveUntil,
1135 ITextRange_fnMoveStartUntil,
1136 ITextRange_fnMoveEndUntil,
1137 ITextRange_fnFindText,
1138 ITextRange_fnFindTextStart,
1139 ITextRange_fnFindTextEnd,
1140 ITextRange_fnDelete,
1141 ITextRange_fnCut,
1142 ITextRange_fnCopy,
1143 ITextRange_fnPaste,
1144 ITextRange_fnCanPaste,
1145 ITextRange_fnCanEdit,
1146 ITextRange_fnChangeCase,
1147 ITextRange_fnGetPoint,
1148 ITextRange_fnSetPoint,
1149 ITextRange_fnScrollIntoView,
1150 ITextRange_fnGetEmbeddedObject
1152 /* ITextRange interface */
1154 static HRESULT WINAPI
1155 ITextDocument_fnQueryInterface(ITextDocument* me, REFIID riid,
1156 void** ppvObject)
1158 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1159 return IRichEditOle_QueryInterface(&This->IRichEditOle_iface, riid, ppvObject);
1162 static ULONG WINAPI
1163 ITextDocument_fnAddRef(ITextDocument* me)
1165 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1166 return IRichEditOle_AddRef(&This->IRichEditOle_iface);
1169 static ULONG WINAPI
1170 ITextDocument_fnRelease(ITextDocument* me)
1172 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1173 return IRichEditOle_Release(&This->IRichEditOle_iface);
1176 static HRESULT WINAPI
1177 ITextDocument_fnGetTypeInfoCount(ITextDocument* me,
1178 UINT* pctinfo)
1180 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1181 FIXME("stub %p\n",This);
1182 return E_NOTIMPL;
1185 static HRESULT WINAPI
1186 ITextDocument_fnGetTypeInfo(ITextDocument* me, UINT iTInfo, LCID lcid,
1187 ITypeInfo** ppTInfo)
1189 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1190 FIXME("stub %p\n",This);
1191 return E_NOTIMPL;
1194 static HRESULT WINAPI
1195 ITextDocument_fnGetIDsOfNames(ITextDocument* me, REFIID riid,
1196 LPOLESTR* rgszNames, UINT cNames, LCID lcid, DISPID* rgDispId)
1198 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1199 FIXME("stub %p\n",This);
1200 return E_NOTIMPL;
1203 static HRESULT WINAPI
1204 ITextDocument_fnInvoke(ITextDocument* me, DISPID dispIdMember,
1205 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS* pDispParams,
1206 VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr)
1208 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1209 FIXME("stub %p\n",This);
1210 return E_NOTIMPL;
1213 static HRESULT WINAPI
1214 ITextDocument_fnGetName(ITextDocument* me, BSTR* pName)
1216 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1217 FIXME("stub %p\n",This);
1218 return E_NOTIMPL;
1221 static HRESULT WINAPI
1222 ITextDocument_fnGetSelection(ITextDocument* me, ITextSelection** ppSel)
1224 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1225 TRACE("(%p)\n", me);
1227 if(!ppSel)
1228 return E_INVALIDARG;
1229 *ppSel = &This->txtSel->ITextSelection_iface;
1230 ITextSelection_AddRef(*ppSel);
1231 return S_OK;
1234 static HRESULT WINAPI
1235 ITextDocument_fnGetStoryCount(ITextDocument* me, LONG* pCount)
1237 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1238 FIXME("stub %p\n",This);
1239 return E_NOTIMPL;
1242 static HRESULT WINAPI
1243 ITextDocument_fnGetStoryRanges(ITextDocument* me,
1244 ITextStoryRanges** ppStories)
1246 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1247 FIXME("stub %p\n",This);
1248 return E_NOTIMPL;
1251 static HRESULT WINAPI
1252 ITextDocument_fnGetSaved(ITextDocument* me, LONG* pValue)
1254 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1255 FIXME("stub %p\n",This);
1256 return E_NOTIMPL;
1259 static HRESULT WINAPI
1260 ITextDocument_fnSetSaved(ITextDocument* me, LONG Value)
1262 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1263 FIXME("stub %p\n",This);
1264 return E_NOTIMPL;
1267 static HRESULT WINAPI
1268 ITextDocument_fnGetDefaultTabStop(ITextDocument* me, float* pValue)
1270 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1271 FIXME("stub %p\n",This);
1272 return E_NOTIMPL;
1275 static HRESULT WINAPI
1276 ITextDocument_fnSetDefaultTabStop(ITextDocument* me, float Value)
1278 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1279 FIXME("stub %p\n",This);
1280 return E_NOTIMPL;
1283 static HRESULT WINAPI
1284 ITextDocument_fnNew(ITextDocument* me)
1286 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1287 FIXME("stub %p\n",This);
1288 return E_NOTIMPL;
1291 static HRESULT WINAPI
1292 ITextDocument_fnOpen(ITextDocument* me, VARIANT* pVar, LONG Flags,
1293 LONG CodePage)
1295 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1296 FIXME("stub %p\n",This);
1297 return E_NOTIMPL;
1300 static HRESULT WINAPI
1301 ITextDocument_fnSave(ITextDocument* me, VARIANT* pVar, LONG Flags,
1302 LONG CodePage)
1304 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1305 FIXME("stub %p\n",This);
1306 return E_NOTIMPL;
1309 static HRESULT WINAPI
1310 ITextDocument_fnFreeze(ITextDocument* me, LONG* pCount)
1312 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1313 FIXME("stub %p\n",This);
1314 return E_NOTIMPL;
1317 static HRESULT WINAPI
1318 ITextDocument_fnUnfreeze(ITextDocument* me, LONG* pCount)
1320 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1321 FIXME("stub %p\n",This);
1322 return E_NOTIMPL;
1325 static HRESULT WINAPI
1326 ITextDocument_fnBeginEditCollection(ITextDocument* me)
1328 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1329 FIXME("stub %p\n",This);
1330 return E_NOTIMPL;
1333 static HRESULT WINAPI
1334 ITextDocument_fnEndEditCollection(ITextDocument* me)
1336 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1337 FIXME("stub %p\n",This);
1338 return E_NOTIMPL;
1341 static HRESULT WINAPI
1342 ITextDocument_fnUndo(ITextDocument* me, LONG Count, LONG* prop)
1344 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1345 FIXME("stub %p\n",This);
1346 return E_NOTIMPL;
1349 static HRESULT WINAPI
1350 ITextDocument_fnRedo(ITextDocument* me, LONG Count, LONG* prop)
1352 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1353 FIXME("stub %p\n",This);
1354 return E_NOTIMPL;
1357 static HRESULT CreateITextRange(IRichEditOleImpl *reOle, LONG start, LONG end, ITextRange** ppRange)
1359 ITextRangeImpl *txtRge = heap_alloc(sizeof(ITextRangeImpl));
1361 if (!txtRge)
1362 return E_OUTOFMEMORY;
1363 txtRge->ITextRange_iface.lpVtbl = &trvt;
1364 txtRge->ref = 1;
1365 txtRge->reOle = reOle;
1366 txtRge->start = start;
1367 txtRge->end = end;
1368 list_add_head(&reOle->rangelist, &txtRge->entry);
1369 *ppRange = &txtRge->ITextRange_iface;
1370 return S_OK;
1373 static HRESULT WINAPI
1374 ITextDocument_fnRange(ITextDocument* me, LONG cp1, LONG cp2,
1375 ITextRange** ppRange)
1377 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1378 const int len = ME_GetTextLength(This->editor) + 1;
1380 TRACE("%p %p %d %d\n", This, ppRange, cp1, cp2);
1381 if (!ppRange)
1382 return E_INVALIDARG;
1384 cp1 = max(cp1, 0);
1385 cp2 = max(cp2, 0);
1386 cp1 = min(cp1, len);
1387 cp2 = min(cp2, len);
1388 if (cp1 > cp2)
1390 LONG tmp;
1391 tmp = cp1;
1392 cp1 = cp2;
1393 cp2 = tmp;
1395 if (cp1 == len)
1396 cp1 = cp2 = len - 1;
1398 return CreateITextRange(This, cp1, cp2, ppRange);
1401 static HRESULT WINAPI
1402 ITextDocument_fnRangeFromPoint(ITextDocument* me, LONG x, LONG y,
1403 ITextRange** ppRange)
1405 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1406 FIXME("stub %p\n",This);
1407 return E_NOTIMPL;
1410 static const ITextDocumentVtbl tdvt = {
1411 ITextDocument_fnQueryInterface,
1412 ITextDocument_fnAddRef,
1413 ITextDocument_fnRelease,
1414 ITextDocument_fnGetTypeInfoCount,
1415 ITextDocument_fnGetTypeInfo,
1416 ITextDocument_fnGetIDsOfNames,
1417 ITextDocument_fnInvoke,
1418 ITextDocument_fnGetName,
1419 ITextDocument_fnGetSelection,
1420 ITextDocument_fnGetStoryCount,
1421 ITextDocument_fnGetStoryRanges,
1422 ITextDocument_fnGetSaved,
1423 ITextDocument_fnSetSaved,
1424 ITextDocument_fnGetDefaultTabStop,
1425 ITextDocument_fnSetDefaultTabStop,
1426 ITextDocument_fnNew,
1427 ITextDocument_fnOpen,
1428 ITextDocument_fnSave,
1429 ITextDocument_fnFreeze,
1430 ITextDocument_fnUnfreeze,
1431 ITextDocument_fnBeginEditCollection,
1432 ITextDocument_fnEndEditCollection,
1433 ITextDocument_fnUndo,
1434 ITextDocument_fnRedo,
1435 ITextDocument_fnRange,
1436 ITextDocument_fnRangeFromPoint
1439 static inline ITextSelectionImpl *impl_from_ITextSelection(ITextSelection *iface)
1441 return CONTAINING_RECORD(iface, ITextSelectionImpl, ITextSelection_iface);
1444 static HRESULT WINAPI ITextSelection_fnQueryInterface(
1445 ITextSelection *me,
1446 REFIID riid,
1447 void **ppvObj)
1449 *ppvObj = NULL;
1450 if (IsEqualGUID(riid, &IID_IUnknown)
1451 || IsEqualGUID(riid, &IID_IDispatch)
1452 || IsEqualGUID(riid, &IID_ITextRange)
1453 || IsEqualGUID(riid, &IID_ITextSelection))
1455 *ppvObj = me;
1456 ITextSelection_AddRef(me);
1457 return S_OK;
1460 return E_NOINTERFACE;
1463 static ULONG WINAPI ITextSelection_fnAddRef(ITextSelection *me)
1465 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1466 return InterlockedIncrement(&This->ref);
1469 static ULONG WINAPI ITextSelection_fnRelease(ITextSelection *me)
1471 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1472 ULONG ref = InterlockedDecrement(&This->ref);
1473 if (ref == 0)
1474 heap_free(This);
1475 return ref;
1478 static HRESULT WINAPI ITextSelection_fnGetTypeInfoCount(ITextSelection *me, UINT *pctinfo)
1480 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1481 if (!This->reOle)
1482 return CO_E_RELEASED;
1484 FIXME("not implemented\n");
1485 return E_NOTIMPL;
1488 static HRESULT WINAPI ITextSelection_fnGetTypeInfo(ITextSelection *me, UINT iTInfo, LCID lcid,
1489 ITypeInfo **ppTInfo)
1491 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1492 if (!This->reOle)
1493 return CO_E_RELEASED;
1495 FIXME("not implemented\n");
1496 return E_NOTIMPL;
1499 static HRESULT WINAPI ITextSelection_fnGetIDsOfNames(ITextSelection *me, REFIID riid,
1500 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
1502 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1503 if (!This->reOle)
1504 return CO_E_RELEASED;
1506 FIXME("not implemented\n");
1507 return E_NOTIMPL;
1510 static HRESULT WINAPI ITextSelection_fnInvoke(
1511 ITextSelection *me,
1512 DISPID dispIdMember,
1513 REFIID riid,
1514 LCID lcid,
1515 WORD wFlags,
1516 DISPPARAMS *pDispParams,
1517 VARIANT *pVarResult,
1518 EXCEPINFO *pExcepInfo,
1519 UINT *puArgErr)
1521 FIXME("not implemented\n");
1522 return E_NOTIMPL;
1525 /*** ITextRange methods ***/
1526 static HRESULT WINAPI ITextSelection_fnGetText(ITextSelection *me, BSTR *pbstr)
1528 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1529 ME_Cursor *start = NULL, *end = NULL;
1530 int nChars, endOfs;
1531 BOOL bEOP;
1533 if (!This->reOle)
1534 return CO_E_RELEASED;
1535 TRACE("%p\n", pbstr);
1536 if (!pbstr)
1537 return E_INVALIDARG;
1539 ME_GetSelection(This->reOle->editor, &start, &end);
1540 endOfs = ME_GetCursorOfs(end);
1541 nChars = endOfs - ME_GetCursorOfs(start);
1542 if (!nChars)
1544 *pbstr = NULL;
1545 return S_OK;
1548 *pbstr = SysAllocStringLen(NULL, nChars);
1549 if (!*pbstr)
1550 return E_OUTOFMEMORY;
1552 bEOP = (end->pRun->next->type == diTextEnd && endOfs > ME_GetTextLength(This->reOle->editor));
1553 ME_GetTextW(This->reOle->editor, *pbstr, nChars, start, nChars, FALSE, bEOP);
1554 TRACE("%s\n", wine_dbgstr_w(*pbstr));
1556 return S_OK;
1559 static HRESULT WINAPI ITextSelection_fnSetText(ITextSelection *me, BSTR bstr)
1561 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1562 if (!This->reOle)
1563 return CO_E_RELEASED;
1565 FIXME("not implemented\n");
1566 return E_NOTIMPL;
1569 static HRESULT WINAPI ITextSelection_fnGetChar(ITextSelection *me, LONG *pch)
1571 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1572 ME_Cursor *start = NULL, *end = NULL;
1574 if (!This->reOle)
1575 return CO_E_RELEASED;
1576 TRACE("%p\n", pch);
1577 if (!pch)
1578 return E_INVALIDARG;
1580 ME_GetSelection(This->reOle->editor, &start, &end);
1581 return range_GetChar(This->reOle->editor, start, pch);
1584 static HRESULT WINAPI ITextSelection_fnSetChar(ITextSelection *me, LONG ch)
1586 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1587 if (!This->reOle)
1588 return CO_E_RELEASED;
1590 FIXME("not implemented\n");
1591 return E_NOTIMPL;
1594 static HRESULT WINAPI ITextSelection_fnGetDuplicate(ITextSelection *me, ITextRange **ppRange)
1596 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1597 if (!This->reOle)
1598 return CO_E_RELEASED;
1600 FIXME("not implemented\n");
1601 return E_NOTIMPL;
1604 static HRESULT WINAPI ITextSelection_fnGetFormattedText(ITextSelection *me, ITextRange **ppRange)
1606 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1607 if (!This->reOle)
1608 return CO_E_RELEASED;
1610 FIXME("not implemented\n");
1611 return E_NOTIMPL;
1614 static HRESULT WINAPI ITextSelection_fnSetFormattedText(ITextSelection *me, ITextRange *pRange)
1616 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1617 if (!This->reOle)
1618 return CO_E_RELEASED;
1620 FIXME("not implemented\n");
1621 return E_NOTIMPL;
1624 static HRESULT WINAPI ITextSelection_fnGetStart(ITextSelection *me, LONG *pcpFirst)
1626 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1627 if (!This->reOle)
1628 return CO_E_RELEASED;
1630 FIXME("not implemented\n");
1631 return E_NOTIMPL;
1634 static HRESULT WINAPI ITextSelection_fnSetStart(ITextSelection *me, LONG cpFirst)
1636 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1637 if (!This->reOle)
1638 return CO_E_RELEASED;
1640 FIXME("not implemented\n");
1641 return E_NOTIMPL;
1644 static HRESULT WINAPI ITextSelection_fnGetEnd(ITextSelection *me, LONG *pcpLim)
1646 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1647 if (!This->reOle)
1648 return CO_E_RELEASED;
1650 FIXME("not implemented\n");
1651 return E_NOTIMPL;
1654 static HRESULT WINAPI ITextSelection_fnSetEnd(ITextSelection *me, LONG cpLim)
1656 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1657 if (!This->reOle)
1658 return CO_E_RELEASED;
1660 FIXME("not implemented\n");
1661 return E_NOTIMPL;
1664 static HRESULT WINAPI ITextSelection_fnGetFont(ITextSelection *me, ITextFont **pFont)
1666 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1667 if (!This->reOle)
1668 return CO_E_RELEASED;
1670 FIXME("not implemented\n");
1671 return E_NOTIMPL;
1674 static HRESULT WINAPI ITextSelection_fnSetFont(ITextSelection *me, ITextFont *pFont)
1676 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1677 if (!This->reOle)
1678 return CO_E_RELEASED;
1680 FIXME("not implemented\n");
1681 return E_NOTIMPL;
1684 static HRESULT WINAPI ITextSelection_fnGetPara(ITextSelection *me, ITextPara **ppPara)
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_fnSetPara(ITextSelection *me, ITextPara *pPara)
1696 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1697 if (!This->reOle)
1698 return CO_E_RELEASED;
1700 FIXME("not implemented\n");
1701 return E_NOTIMPL;
1704 static HRESULT WINAPI ITextSelection_fnGetStoryLength(ITextSelection *me, LONG *pcch)
1706 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1707 if (!This->reOle)
1708 return CO_E_RELEASED;
1710 FIXME("not implemented\n");
1711 return E_NOTIMPL;
1714 static HRESULT WINAPI ITextSelection_fnGetStoryType(ITextSelection *me, LONG *pValue)
1716 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1717 if (!This->reOle)
1718 return CO_E_RELEASED;
1720 FIXME("not implemented\n");
1721 return E_NOTIMPL;
1724 static HRESULT WINAPI ITextSelection_fnCollapse(ITextSelection *me, LONG bStart)
1726 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1727 if (!This->reOle)
1728 return CO_E_RELEASED;
1730 FIXME("not implemented\n");
1731 return E_NOTIMPL;
1734 static HRESULT WINAPI ITextSelection_fnExpand(ITextSelection *me, LONG Unit, LONG *pDelta)
1736 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1737 if (!This->reOle)
1738 return CO_E_RELEASED;
1740 FIXME("not implemented\n");
1741 return E_NOTIMPL;
1744 static HRESULT WINAPI ITextSelection_fnGetIndex(ITextSelection *me, LONG Unit, LONG *pIndex)
1746 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1747 if (!This->reOle)
1748 return CO_E_RELEASED;
1750 FIXME("not implemented\n");
1751 return E_NOTIMPL;
1754 static HRESULT WINAPI ITextSelection_fnSetIndex(ITextSelection *me, LONG Unit, LONG Index,
1755 LONG Extend)
1757 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1758 if (!This->reOle)
1759 return CO_E_RELEASED;
1761 FIXME("not implemented\n");
1762 return E_NOTIMPL;
1765 static HRESULT WINAPI ITextSelection_fnSetRange(ITextSelection *me, LONG cpActive, LONG cpOther)
1767 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1768 if (!This->reOle)
1769 return CO_E_RELEASED;
1771 FIXME("not implemented\n");
1772 return E_NOTIMPL;
1775 static HRESULT WINAPI ITextSelection_fnInRange(ITextSelection *me, ITextRange *pRange, LONG *pb)
1777 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1778 if (!This->reOle)
1779 return CO_E_RELEASED;
1781 FIXME("not implemented\n");
1782 return E_NOTIMPL;
1785 static HRESULT WINAPI ITextSelection_fnInStory(ITextSelection *me, ITextRange *pRange, LONG *pb)
1787 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1788 if (!This->reOle)
1789 return CO_E_RELEASED;
1791 FIXME("not implemented\n");
1792 return E_NOTIMPL;
1795 static HRESULT WINAPI ITextSelection_fnIsEqual(ITextSelection *me, ITextRange *pRange, LONG *pb)
1797 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1798 if (!This->reOle)
1799 return CO_E_RELEASED;
1801 FIXME("not implemented\n");
1802 return E_NOTIMPL;
1805 static HRESULT WINAPI ITextSelection_fnSelect(ITextSelection *me)
1807 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1808 if (!This->reOle)
1809 return CO_E_RELEASED;
1811 FIXME("not implemented\n");
1812 return E_NOTIMPL;
1815 static HRESULT WINAPI ITextSelection_fnStartOf(ITextSelection *me, LONG Unit, LONG Extend,
1816 LONG *pDelta)
1818 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1819 if (!This->reOle)
1820 return CO_E_RELEASED;
1822 FIXME("not implemented\n");
1823 return E_NOTIMPL;
1826 static HRESULT WINAPI ITextSelection_fnEndOf(ITextSelection *me, LONG Unit, LONG Extend,
1827 LONG *pDelta)
1829 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1830 if (!This->reOle)
1831 return CO_E_RELEASED;
1833 FIXME("not implemented\n");
1834 return E_NOTIMPL;
1837 static HRESULT WINAPI ITextSelection_fnMove(ITextSelection *me, LONG Unit, LONG Count, LONG *pDelta)
1839 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1840 if (!This->reOle)
1841 return CO_E_RELEASED;
1843 FIXME("not implemented\n");
1844 return E_NOTIMPL;
1847 static HRESULT WINAPI ITextSelection_fnMoveStart(ITextSelection *me, LONG Unit, LONG Count,
1848 LONG *pDelta)
1850 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1851 if (!This->reOle)
1852 return CO_E_RELEASED;
1854 FIXME("not implemented\n");
1855 return E_NOTIMPL;
1858 static HRESULT WINAPI ITextSelection_fnMoveEnd(ITextSelection *me, LONG Unit, LONG Count,
1859 LONG *pDelta)
1861 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1862 if (!This->reOle)
1863 return CO_E_RELEASED;
1865 FIXME("not implemented\n");
1866 return E_NOTIMPL;
1869 static HRESULT WINAPI ITextSelection_fnMoveWhile(ITextSelection *me, VARIANT *Cset, LONG Count,
1870 LONG *pDelta)
1872 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1873 if (!This->reOle)
1874 return CO_E_RELEASED;
1876 FIXME("not implemented\n");
1877 return E_NOTIMPL;
1880 static HRESULT WINAPI ITextSelection_fnMoveStartWhile(ITextSelection *me, VARIANT *Cset, LONG Count,
1881 LONG *pDelta)
1883 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1884 if (!This->reOle)
1885 return CO_E_RELEASED;
1887 FIXME("not implemented\n");
1888 return E_NOTIMPL;
1891 static HRESULT WINAPI ITextSelection_fnMoveEndWhile(ITextSelection *me, VARIANT *Cset, LONG Count,
1892 LONG *pDelta)
1894 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1895 if (!This->reOle)
1896 return CO_E_RELEASED;
1898 FIXME("not implemented\n");
1899 return E_NOTIMPL;
1902 static HRESULT WINAPI ITextSelection_fnMoveUntil(ITextSelection *me, VARIANT *Cset, LONG Count,
1903 LONG *pDelta)
1905 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1906 if (!This->reOle)
1907 return CO_E_RELEASED;
1909 FIXME("not implemented\n");
1910 return E_NOTIMPL;
1913 static HRESULT WINAPI ITextSelection_fnMoveStartUntil(ITextSelection *me, VARIANT *Cset, LONG Count,
1914 LONG *pDelta)
1916 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1917 if (!This->reOle)
1918 return CO_E_RELEASED;
1920 FIXME("not implemented\n");
1921 return E_NOTIMPL;
1924 static HRESULT WINAPI ITextSelection_fnMoveEndUntil(ITextSelection *me, VARIANT *Cset, LONG Count,
1925 LONG *pDelta)
1927 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1928 if (!This->reOle)
1929 return CO_E_RELEASED;
1931 FIXME("not implemented\n");
1932 return E_NOTIMPL;
1935 static HRESULT WINAPI ITextSelection_fnFindText(ITextSelection *me, BSTR bstr, LONG cch, LONG Flags,
1936 LONG *pLength)
1938 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1939 if (!This->reOle)
1940 return CO_E_RELEASED;
1942 FIXME("not implemented\n");
1943 return E_NOTIMPL;
1946 static HRESULT WINAPI ITextSelection_fnFindTextStart(ITextSelection *me, BSTR bstr, LONG cch,
1947 LONG Flags, LONG *pLength)
1949 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1950 if (!This->reOle)
1951 return CO_E_RELEASED;
1953 FIXME("not implemented\n");
1954 return E_NOTIMPL;
1957 static HRESULT WINAPI ITextSelection_fnFindTextEnd(ITextSelection *me, BSTR bstr, LONG cch,
1958 LONG Flags, LONG *pLength)
1960 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1961 if (!This->reOle)
1962 return CO_E_RELEASED;
1964 FIXME("not implemented\n");
1965 return E_NOTIMPL;
1968 static HRESULT WINAPI ITextSelection_fnDelete(ITextSelection *me, LONG Unit, LONG Count,
1969 LONG *pDelta)
1971 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1972 if (!This->reOle)
1973 return CO_E_RELEASED;
1975 FIXME("not implemented\n");
1976 return E_NOTIMPL;
1979 static HRESULT WINAPI ITextSelection_fnCut(ITextSelection *me, VARIANT *pVar)
1981 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1982 if (!This->reOle)
1983 return CO_E_RELEASED;
1985 FIXME("not implemented\n");
1986 return E_NOTIMPL;
1989 static HRESULT WINAPI ITextSelection_fnCopy(ITextSelection *me, VARIANT *pVar)
1991 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1992 if (!This->reOle)
1993 return CO_E_RELEASED;
1995 FIXME("not implemented\n");
1996 return E_NOTIMPL;
1999 static HRESULT WINAPI ITextSelection_fnPaste(ITextSelection *me, VARIANT *pVar, LONG Format)
2001 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2002 if (!This->reOle)
2003 return CO_E_RELEASED;
2005 FIXME("not implemented\n");
2006 return E_NOTIMPL;
2009 static HRESULT WINAPI ITextSelection_fnCanPaste(ITextSelection *me, VARIANT *pVar, LONG Format,
2010 LONG *pb)
2012 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2013 if (!This->reOle)
2014 return CO_E_RELEASED;
2016 FIXME("not implemented\n");
2017 return E_NOTIMPL;
2020 static HRESULT WINAPI ITextSelection_fnCanEdit(ITextSelection *me, LONG *pb)
2022 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2023 if (!This->reOle)
2024 return CO_E_RELEASED;
2026 FIXME("not implemented\n");
2027 return E_NOTIMPL;
2030 static HRESULT WINAPI ITextSelection_fnChangeCase(ITextSelection *me, LONG Type)
2032 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2033 if (!This->reOle)
2034 return CO_E_RELEASED;
2036 FIXME("not implemented\n");
2037 return E_NOTIMPL;
2040 static HRESULT WINAPI ITextSelection_fnGetPoint(ITextSelection *me, LONG Type, LONG *cx, LONG *cy)
2042 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2043 if (!This->reOle)
2044 return CO_E_RELEASED;
2046 FIXME("not implemented\n");
2047 return E_NOTIMPL;
2050 static HRESULT WINAPI ITextSelection_fnSetPoint(ITextSelection *me, LONG x, LONG y, LONG Type,
2051 LONG Extend)
2053 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2054 if (!This->reOle)
2055 return CO_E_RELEASED;
2057 FIXME("not implemented\n");
2058 return E_NOTIMPL;
2061 static HRESULT WINAPI ITextSelection_fnScrollIntoView(ITextSelection *me, LONG Value)
2063 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2064 if (!This->reOle)
2065 return CO_E_RELEASED;
2067 FIXME("not implemented\n");
2068 return E_NOTIMPL;
2071 static HRESULT WINAPI ITextSelection_fnGetEmbeddedObject(ITextSelection *me, IUnknown **ppv)
2073 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2074 if (!This->reOle)
2075 return CO_E_RELEASED;
2077 FIXME("not implemented\n");
2078 return E_NOTIMPL;
2081 /*** ITextSelection methods ***/
2082 static HRESULT WINAPI ITextSelection_fnGetFlags(ITextSelection *me, LONG *pFlags)
2084 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2085 if (!This->reOle)
2086 return CO_E_RELEASED;
2088 FIXME("not implemented\n");
2089 return E_NOTIMPL;
2092 static HRESULT WINAPI ITextSelection_fnSetFlags(ITextSelection *me, LONG Flags)
2094 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2095 if (!This->reOle)
2096 return CO_E_RELEASED;
2098 FIXME("not implemented\n");
2099 return E_NOTIMPL;
2102 static HRESULT WINAPI ITextSelection_fnGetType(ITextSelection *me, LONG *pType)
2104 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2105 if (!This->reOle)
2106 return CO_E_RELEASED;
2108 FIXME("not implemented\n");
2109 return E_NOTIMPL;
2112 static HRESULT WINAPI ITextSelection_fnMoveLeft(ITextSelection *me, LONG Unit, LONG Count,
2113 LONG Extend, LONG *pDelta)
2115 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2116 if (!This->reOle)
2117 return CO_E_RELEASED;
2119 FIXME("not implemented\n");
2120 return E_NOTIMPL;
2123 static HRESULT WINAPI ITextSelection_fnMoveRight(ITextSelection *me, LONG Unit, LONG Count,
2124 LONG Extend, LONG *pDelta)
2126 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2127 if (!This->reOle)
2128 return CO_E_RELEASED;
2130 FIXME("not implemented\n");
2131 return E_NOTIMPL;
2134 static HRESULT WINAPI ITextSelection_fnMoveUp(ITextSelection *me, LONG Unit, LONG Count,
2135 LONG Extend, LONG *pDelta)
2137 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2138 if (!This->reOle)
2139 return CO_E_RELEASED;
2141 FIXME("not implemented\n");
2142 return E_NOTIMPL;
2145 static HRESULT WINAPI ITextSelection_fnMoveDown(ITextSelection *me, LONG Unit, LONG Count,
2146 LONG Extend, LONG *pDelta)
2148 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2149 if (!This->reOle)
2150 return CO_E_RELEASED;
2152 FIXME("not implemented\n");
2153 return E_NOTIMPL;
2156 static HRESULT WINAPI ITextSelection_fnHomeKey(ITextSelection *me, LONG Unit, LONG Extend,
2157 LONG *pDelta)
2159 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2160 if (!This->reOle)
2161 return CO_E_RELEASED;
2163 FIXME("not implemented\n");
2164 return E_NOTIMPL;
2167 static HRESULT WINAPI ITextSelection_fnEndKey(ITextSelection *me, LONG Unit, LONG Extend,
2168 LONG *pDelta)
2170 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2171 if (!This->reOle)
2172 return CO_E_RELEASED;
2174 FIXME("not implemented\n");
2175 return E_NOTIMPL;
2178 static HRESULT WINAPI ITextSelection_fnTypeText(ITextSelection *me, BSTR bstr)
2180 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2181 if (!This->reOle)
2182 return CO_E_RELEASED;
2184 FIXME("not implemented\n");
2185 return E_NOTIMPL;
2188 static const ITextSelectionVtbl tsvt = {
2189 ITextSelection_fnQueryInterface,
2190 ITextSelection_fnAddRef,
2191 ITextSelection_fnRelease,
2192 ITextSelection_fnGetTypeInfoCount,
2193 ITextSelection_fnGetTypeInfo,
2194 ITextSelection_fnGetIDsOfNames,
2195 ITextSelection_fnInvoke,
2196 ITextSelection_fnGetText,
2197 ITextSelection_fnSetText,
2198 ITextSelection_fnGetChar,
2199 ITextSelection_fnSetChar,
2200 ITextSelection_fnGetDuplicate,
2201 ITextSelection_fnGetFormattedText,
2202 ITextSelection_fnSetFormattedText,
2203 ITextSelection_fnGetStart,
2204 ITextSelection_fnSetStart,
2205 ITextSelection_fnGetEnd,
2206 ITextSelection_fnSetEnd,
2207 ITextSelection_fnGetFont,
2208 ITextSelection_fnSetFont,
2209 ITextSelection_fnGetPara,
2210 ITextSelection_fnSetPara,
2211 ITextSelection_fnGetStoryLength,
2212 ITextSelection_fnGetStoryType,
2213 ITextSelection_fnCollapse,
2214 ITextSelection_fnExpand,
2215 ITextSelection_fnGetIndex,
2216 ITextSelection_fnSetIndex,
2217 ITextSelection_fnSetRange,
2218 ITextSelection_fnInRange,
2219 ITextSelection_fnInStory,
2220 ITextSelection_fnIsEqual,
2221 ITextSelection_fnSelect,
2222 ITextSelection_fnStartOf,
2223 ITextSelection_fnEndOf,
2224 ITextSelection_fnMove,
2225 ITextSelection_fnMoveStart,
2226 ITextSelection_fnMoveEnd,
2227 ITextSelection_fnMoveWhile,
2228 ITextSelection_fnMoveStartWhile,
2229 ITextSelection_fnMoveEndWhile,
2230 ITextSelection_fnMoveUntil,
2231 ITextSelection_fnMoveStartUntil,
2232 ITextSelection_fnMoveEndUntil,
2233 ITextSelection_fnFindText,
2234 ITextSelection_fnFindTextStart,
2235 ITextSelection_fnFindTextEnd,
2236 ITextSelection_fnDelete,
2237 ITextSelection_fnCut,
2238 ITextSelection_fnCopy,
2239 ITextSelection_fnPaste,
2240 ITextSelection_fnCanPaste,
2241 ITextSelection_fnCanEdit,
2242 ITextSelection_fnChangeCase,
2243 ITextSelection_fnGetPoint,
2244 ITextSelection_fnSetPoint,
2245 ITextSelection_fnScrollIntoView,
2246 ITextSelection_fnGetEmbeddedObject,
2247 ITextSelection_fnGetFlags,
2248 ITextSelection_fnSetFlags,
2249 ITextSelection_fnGetType,
2250 ITextSelection_fnMoveLeft,
2251 ITextSelection_fnMoveRight,
2252 ITextSelection_fnMoveUp,
2253 ITextSelection_fnMoveDown,
2254 ITextSelection_fnHomeKey,
2255 ITextSelection_fnEndKey,
2256 ITextSelection_fnTypeText
2259 static ITextSelectionImpl *
2260 CreateTextSelection(IRichEditOleImpl *reOle)
2262 ITextSelectionImpl *txtSel = heap_alloc(sizeof *txtSel);
2263 if (!txtSel)
2264 return NULL;
2266 txtSel->ITextSelection_iface.lpVtbl = &tsvt;
2267 txtSel->ref = 1;
2268 txtSel->reOle = reOle;
2269 return txtSel;
2272 LRESULT CreateIRichEditOle(ME_TextEditor *editor, LPVOID *ppObj)
2274 IRichEditOleImpl *reo;
2276 reo = heap_alloc(sizeof(IRichEditOleImpl));
2277 if (!reo)
2278 return 0;
2280 reo->IRichEditOle_iface.lpVtbl = &revt;
2281 reo->ITextDocument_iface.lpVtbl = &tdvt;
2282 reo->ref = 1;
2283 reo->editor = editor;
2284 reo->txtSel = CreateTextSelection(reo);
2285 if (!reo->txtSel)
2287 heap_free(reo);
2288 return 0;
2290 reo->clientSite = CreateOleClientSite(reo);
2291 if (!reo->clientSite)
2293 ITextSelection_Release(&reo->txtSel->ITextSelection_iface);
2294 heap_free(reo);
2295 return 0;
2297 TRACE("Created %p\n",reo);
2298 *ppObj = reo;
2299 list_init(&reo->rangelist);
2301 return 1;
2304 static void convert_sizel(const ME_Context *c, const SIZEL* szl, SIZE* sz)
2306 /* sizel is in .01 millimeters, sz in pixels */
2307 sz->cx = MulDiv(szl->cx, c->dpi.cx, 2540);
2308 sz->cy = MulDiv(szl->cy, c->dpi.cy, 2540);
2311 /******************************************************************************
2312 * ME_GetOLEObjectSize
2314 * Sets run extent for OLE objects.
2316 void ME_GetOLEObjectSize(const ME_Context *c, ME_Run *run, SIZE *pSize)
2318 IDataObject* ido;
2319 FORMATETC fmt;
2320 STGMEDIUM stgm;
2321 DIBSECTION dibsect;
2322 ENHMETAHEADER emh;
2324 assert(run->nFlags & MERF_GRAPHICS);
2325 assert(run->ole_obj);
2327 if (run->ole_obj->sizel.cx != 0 || run->ole_obj->sizel.cy != 0)
2329 convert_sizel(c, &run->ole_obj->sizel, pSize);
2330 if (c->editor->nZoomNumerator != 0)
2332 pSize->cx = MulDiv(pSize->cx, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
2333 pSize->cy = MulDiv(pSize->cy, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
2335 return;
2338 if (IOleObject_QueryInterface(run->ole_obj->poleobj, &IID_IDataObject, (void**)&ido) != S_OK)
2340 FIXME("Query Interface IID_IDataObject failed!\n");
2341 pSize->cx = pSize->cy = 0;
2342 return;
2344 fmt.cfFormat = CF_BITMAP;
2345 fmt.ptd = NULL;
2346 fmt.dwAspect = DVASPECT_CONTENT;
2347 fmt.lindex = -1;
2348 fmt.tymed = TYMED_GDI;
2349 if (IDataObject_GetData(ido, &fmt, &stgm) != S_OK)
2351 fmt.cfFormat = CF_ENHMETAFILE;
2352 fmt.tymed = TYMED_ENHMF;
2353 if (IDataObject_GetData(ido, &fmt, &stgm) != S_OK)
2355 FIXME("unsupported format\n");
2356 pSize->cx = pSize->cy = 0;
2357 IDataObject_Release(ido);
2358 return;
2362 switch (stgm.tymed)
2364 case TYMED_GDI:
2365 GetObjectW(stgm.u.hBitmap, sizeof(dibsect), &dibsect);
2366 pSize->cx = dibsect.dsBm.bmWidth;
2367 pSize->cy = dibsect.dsBm.bmHeight;
2368 if (!stgm.pUnkForRelease) DeleteObject(stgm.u.hBitmap);
2369 break;
2370 case TYMED_ENHMF:
2371 GetEnhMetaFileHeader(stgm.u.hEnhMetaFile, sizeof(emh), &emh);
2372 pSize->cx = emh.rclBounds.right - emh.rclBounds.left;
2373 pSize->cy = emh.rclBounds.bottom - emh.rclBounds.top;
2374 if (!stgm.pUnkForRelease) DeleteEnhMetaFile(stgm.u.hEnhMetaFile);
2375 break;
2376 default:
2377 FIXME("Unsupported tymed %d\n", stgm.tymed);
2378 break;
2380 IDataObject_Release(ido);
2381 if (c->editor->nZoomNumerator != 0)
2383 pSize->cx = MulDiv(pSize->cx, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
2384 pSize->cy = MulDiv(pSize->cy, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
2388 void ME_DrawOLE(ME_Context *c, int x, int y, ME_Run *run,
2389 ME_Paragraph *para, BOOL selected)
2391 IDataObject* ido;
2392 FORMATETC fmt;
2393 STGMEDIUM stgm;
2394 DIBSECTION dibsect;
2395 ENHMETAHEADER emh;
2396 HDC hMemDC;
2397 SIZE sz;
2398 BOOL has_size;
2400 assert(run->nFlags & MERF_GRAPHICS);
2401 assert(run->ole_obj);
2402 if (IOleObject_QueryInterface(run->ole_obj->poleobj, &IID_IDataObject, (void**)&ido) != S_OK)
2404 FIXME("Couldn't get interface\n");
2405 return;
2407 has_size = run->ole_obj->sizel.cx != 0 || run->ole_obj->sizel.cy != 0;
2408 fmt.cfFormat = CF_BITMAP;
2409 fmt.ptd = NULL;
2410 fmt.dwAspect = DVASPECT_CONTENT;
2411 fmt.lindex = -1;
2412 fmt.tymed = TYMED_GDI;
2413 if (IDataObject_GetData(ido, &fmt, &stgm) != S_OK)
2415 fmt.cfFormat = CF_ENHMETAFILE;
2416 fmt.tymed = TYMED_ENHMF;
2417 if (IDataObject_GetData(ido, &fmt, &stgm) != S_OK)
2419 FIXME("Couldn't get storage medium\n");
2420 IDataObject_Release(ido);
2421 return;
2424 switch (stgm.tymed)
2426 case TYMED_GDI:
2427 GetObjectW(stgm.u.hBitmap, sizeof(dibsect), &dibsect);
2428 hMemDC = CreateCompatibleDC(c->hDC);
2429 SelectObject(hMemDC, stgm.u.hBitmap);
2430 if (has_size)
2432 convert_sizel(c, &run->ole_obj->sizel, &sz);
2433 } else {
2434 sz.cx = MulDiv(dibsect.dsBm.bmWidth, c->dpi.cx, 96);
2435 sz.cy = MulDiv(dibsect.dsBm.bmHeight, c->dpi.cy, 96);
2437 if (c->editor->nZoomNumerator != 0)
2439 sz.cx = MulDiv(sz.cx, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
2440 sz.cy = MulDiv(sz.cy, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
2442 if (sz.cx == dibsect.dsBm.bmWidth && sz.cy == dibsect.dsBm.bmHeight)
2444 BitBlt(c->hDC, x, y - sz.cy,
2445 dibsect.dsBm.bmWidth, dibsect.dsBm.bmHeight,
2446 hMemDC, 0, 0, SRCCOPY);
2447 } else {
2448 StretchBlt(c->hDC, x, y - sz.cy, sz.cx, sz.cy,
2449 hMemDC, 0, 0, dibsect.dsBm.bmWidth,
2450 dibsect.dsBm.bmHeight, SRCCOPY);
2452 DeleteDC(hMemDC);
2453 if (!stgm.pUnkForRelease) DeleteObject(stgm.u.hBitmap);
2454 break;
2455 case TYMED_ENHMF:
2456 GetEnhMetaFileHeader(stgm.u.hEnhMetaFile, sizeof(emh), &emh);
2457 if (has_size)
2459 convert_sizel(c, &run->ole_obj->sizel, &sz);
2460 } else {
2461 sz.cy = MulDiv(emh.rclBounds.bottom - emh.rclBounds.top, c->dpi.cx, 96);
2462 sz.cx = MulDiv(emh.rclBounds.right - emh.rclBounds.left, c->dpi.cy, 96);
2464 if (c->editor->nZoomNumerator != 0)
2466 sz.cx = MulDiv(sz.cx, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
2467 sz.cy = MulDiv(sz.cy, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
2471 RECT rc;
2473 rc.left = x;
2474 rc.top = y - sz.cy;
2475 rc.right = x + sz.cx;
2476 rc.bottom = y;
2477 PlayEnhMetaFile(c->hDC, stgm.u.hEnhMetaFile, &rc);
2479 if (!stgm.pUnkForRelease) DeleteEnhMetaFile(stgm.u.hEnhMetaFile);
2480 break;
2481 default:
2482 FIXME("Unsupported tymed %d\n", stgm.tymed);
2483 selected = FALSE;
2484 break;
2486 if (selected && !c->editor->bHideSelection)
2487 PatBlt(c->hDC, x, y - sz.cy, sz.cx, sz.cy, DSTINVERT);
2488 IDataObject_Release(ido);
2491 void ME_DeleteReObject(REOBJECT* reo)
2493 if (reo->poleobj) IOleObject_Release(reo->poleobj);
2494 if (reo->pstg) IStorage_Release(reo->pstg);
2495 if (reo->polesite) IOleClientSite_Release(reo->polesite);
2496 FREE_OBJ(reo);
2499 void ME_CopyReObject(REOBJECT* dst, const REOBJECT* src)
2501 *dst = *src;
2503 if (dst->poleobj) IOleObject_AddRef(dst->poleobj);
2504 if (dst->pstg) IStorage_AddRef(dst->pstg);
2505 if (dst->polesite) IOleClientSite_AddRef(dst->polesite);