fusion: Return interface pointer from QI instead of impl pointer.
[wine/multimedia.git] / dlls / riched20 / richole.c
blob3818cfa7ab279d17fd3a9c9ed8d04e5d0494a8fd
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 COBJMACROS
27 #include "windef.h"
28 #include "winbase.h"
29 #include "wingdi.h"
30 #include "winuser.h"
31 #include "ole2.h"
32 #include "richole.h"
33 #include "editor.h"
34 #include "tom.h"
35 #include "wine/debug.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(richedit);
39 /* there is no way to be consistent across different sets of headers - mingw, Wine, Win32 SDK*/
41 #include "initguid.h"
42 DEFINE_GUID(IID_ITextServices, 0x8d33f740, 0xcf58, 0x11ce, 0xa8, 0x9d, 0x00, 0xaa, 0x00, 0x6c, 0xad, 0xc5);
43 DEFINE_GUID(IID_ITextHost, 0x13e670f4,0x1a5a,0x11cf,0xab,0xeb,0x00,0xaa,0x00,0xb6,0x5e,0xa1);
44 DEFINE_GUID(IID_ITextHost2, 0x13e670f5,0x1a5a,0x11cf,0xab,0xeb,0x00,0xaa,0x00,0xb6,0x5e,0xa1);
45 DEFINE_GUID(IID_ITextDocument, 0x8cc497c0, 0xa1df, 0x11ce, 0x80, 0x98, 0x00, 0xaa, 0x00, 0x47, 0xbe, 0x5d);
46 DEFINE_GUID(IID_ITextRange, 0x8cc497c2, 0xa1df, 0x11ce, 0x80, 0x98, 0x00, 0xaa, 0x00, 0x47, 0xbe, 0x5d);
47 DEFINE_GUID(IID_ITextSelection, 0x8cc497c1, 0xa1df, 0x11ce, 0x80, 0x98, 0x00, 0xaa, 0x00, 0x47, 0xbe, 0x5d);
49 typedef struct ITextSelectionImpl ITextSelectionImpl;
50 typedef struct IOleClientSiteImpl IOleClientSiteImpl;
51 typedef struct ITextRangeImpl ITextRangeImpl;
53 typedef struct IRichEditOleImpl {
54 IUnknown IUnknown_inner;
55 IRichEditOle IRichEditOle_iface;
56 ITextDocument ITextDocument_iface;
57 IUnknown *outer_unk;
58 LONG ref;
60 ME_TextEditor *editor;
61 ITextSelectionImpl *txtSel;
62 IOleClientSiteImpl *clientSite;
63 struct list rangelist;
64 } IRichEditOleImpl;
66 struct ITextRangeImpl {
67 ITextRange ITextRange_iface;
68 LONG ref;
69 LONG start, end;
70 struct list entry;
72 IRichEditOleImpl *reOle;
75 struct ITextSelectionImpl {
76 ITextSelection ITextSelection_iface;
77 LONG ref;
79 IRichEditOleImpl *reOle;
82 struct IOleClientSiteImpl {
83 IOleClientSite IOleClientSite_iface;
84 IOleWindow IOleWindow_iface;
85 IOleInPlaceSite IOleInPlaceSite_iface;
86 LONG ref;
88 IRichEditOleImpl *reOle;
91 static inline IRichEditOleImpl *impl_from_IRichEditOle(IRichEditOle *iface)
93 return CONTAINING_RECORD(iface, IRichEditOleImpl, IRichEditOle_iface);
96 static inline IRichEditOleImpl *impl_from_ITextDocument(ITextDocument *iface)
98 return CONTAINING_RECORD(iface, IRichEditOleImpl, ITextDocument_iface);
101 static inline IRichEditOleImpl *impl_from_IUnknown(IUnknown *iface)
103 return CONTAINING_RECORD(iface, IRichEditOleImpl, IUnknown_inner);
106 static HRESULT WINAPI IRichEditOleImpl_inner_fnQueryInterface(IUnknown *iface, REFIID riid, LPVOID *ppvObj)
108 IRichEditOleImpl *This = impl_from_IUnknown(iface);
110 TRACE("%p %s\n", This, debugstr_guid(riid));
112 *ppvObj = NULL;
113 if (IsEqualGUID(riid, &IID_IUnknown))
114 *ppvObj = &This->IUnknown_inner;
115 else if (IsEqualGUID(riid, &IID_IRichEditOle))
116 *ppvObj = &This->IRichEditOle_iface;
117 else if (IsEqualGUID(riid, &IID_ITextDocument))
118 *ppvObj = &This->ITextDocument_iface;
119 if (*ppvObj)
121 IUnknown_AddRef((IUnknown *)*ppvObj);
122 return S_OK;
124 FIXME("%p: unhandled interface %s\n", This, debugstr_guid(riid));
126 return E_NOINTERFACE;
129 static ULONG WINAPI IRichEditOleImpl_inner_fnAddRef(IUnknown *iface)
131 IRichEditOleImpl *This = impl_from_IUnknown(iface);
132 ULONG ref = InterlockedIncrement(&This->ref);
134 TRACE("%p ref = %u\n", This, ref);
136 return ref;
139 static ULONG WINAPI IRichEditOleImpl_inner_fnRelease(IUnknown *iface)
141 IRichEditOleImpl *This = impl_from_IUnknown(iface);
142 ULONG ref = InterlockedDecrement(&This->ref);
144 TRACE ("%p ref=%u\n", This, ref);
146 if (!ref)
148 ITextRangeImpl *txtRge;
150 TRACE("Destroying %p\n", This);
151 This->txtSel->reOle = NULL;
152 This->editor->reOle = NULL;
153 ITextSelection_Release(&This->txtSel->ITextSelection_iface);
154 IOleClientSite_Release(&This->clientSite->IOleClientSite_iface);
155 LIST_FOR_EACH_ENTRY(txtRge, &This->rangelist, ITextRangeImpl, entry)
156 txtRge->reOle = NULL;
157 heap_free(This);
159 return ref;
162 static const IUnknownVtbl reo_unk_vtbl =
164 IRichEditOleImpl_inner_fnQueryInterface,
165 IRichEditOleImpl_inner_fnAddRef,
166 IRichEditOleImpl_inner_fnRelease
169 static HRESULT WINAPI
170 IRichEditOle_fnQueryInterface(IRichEditOle *me, REFIID riid, LPVOID *ppvObj)
172 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
173 return IUnknown_QueryInterface(This->outer_unk, riid, ppvObj);
176 static ULONG WINAPI
177 IRichEditOle_fnAddRef(IRichEditOle *me)
179 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
180 return IUnknown_AddRef(This->outer_unk);
183 static ULONG WINAPI
184 IRichEditOle_fnRelease(IRichEditOle *me)
186 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
187 return IUnknown_Release(This->outer_unk);
190 static HRESULT WINAPI
191 IRichEditOle_fnActivateAs(IRichEditOle *me, REFCLSID rclsid, REFCLSID rclsidAs)
193 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
194 FIXME("stub %p\n",This);
195 return E_NOTIMPL;
198 static HRESULT WINAPI
199 IRichEditOle_fnContextSensitiveHelp(IRichEditOle *me, BOOL fEnterMode)
201 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
202 FIXME("stub %p\n",This);
203 return E_NOTIMPL;
206 static HRESULT WINAPI
207 IRichEditOle_fnConvertObject(IRichEditOle *me, LONG iob,
208 REFCLSID rclsidNew, LPCSTR lpstrUserTypeNew)
210 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
211 FIXME("stub %p\n",This);
212 return E_NOTIMPL;
215 static inline IOleClientSiteImpl *impl_from_IOleClientSite(IOleClientSite *iface)
217 return CONTAINING_RECORD(iface, IOleClientSiteImpl, IOleClientSite_iface);
220 static HRESULT WINAPI
221 IOleClientSite_fnQueryInterface(IOleClientSite *me, REFIID riid, LPVOID *ppvObj)
223 IOleClientSiteImpl *This = impl_from_IOleClientSite(me);
224 TRACE("%p %s\n", me, debugstr_guid(riid) );
226 *ppvObj = NULL;
227 if (IsEqualGUID(riid, &IID_IUnknown) ||
228 IsEqualGUID(riid, &IID_IOleClientSite))
229 *ppvObj = me;
230 else if (IsEqualGUID(riid, &IID_IOleWindow))
231 *ppvObj = &This->IOleWindow_iface;
232 else if (IsEqualGUID(riid, &IID_IOleInPlaceSite))
233 *ppvObj = &This->IOleInPlaceSite_iface;
234 if (*ppvObj)
236 IOleClientSite_AddRef(me);
237 return S_OK;
239 FIXME("%p: unhandled interface %s\n", me, debugstr_guid(riid) );
241 return E_NOINTERFACE;
244 static ULONG WINAPI IOleClientSite_fnAddRef(IOleClientSite *iface)
246 IOleClientSiteImpl *This = impl_from_IOleClientSite(iface);
247 return InterlockedIncrement(&This->ref);
250 static ULONG WINAPI IOleClientSite_fnRelease(IOleClientSite *iface)
252 IOleClientSiteImpl *This = impl_from_IOleClientSite(iface);
253 ULONG ref = InterlockedDecrement(&This->ref);
254 if (ref == 0)
255 heap_free(This);
256 return ref;
259 static HRESULT WINAPI IOleClientSite_fnSaveObject(IOleClientSite *iface)
261 IOleClientSiteImpl *This = impl_from_IOleClientSite(iface);
262 if (!This->reOle)
263 return CO_E_RELEASED;
265 FIXME("stub %p\n", iface);
266 return E_NOTIMPL;
270 static HRESULT WINAPI IOleClientSite_fnGetMoniker(IOleClientSite *iface, DWORD dwAssign,
271 DWORD dwWhichMoniker, IMoniker **ppmk)
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 HRESULT WINAPI IOleClientSite_fnGetContainer(IOleClientSite *iface,
282 IOleContainer **ppContainer)
284 IOleClientSiteImpl *This = impl_from_IOleClientSite(iface);
285 if (!This->reOle)
286 return CO_E_RELEASED;
288 FIXME("stub %p\n", iface);
289 return E_NOTIMPL;
292 static HRESULT WINAPI IOleClientSite_fnShowObject(IOleClientSite *iface)
294 IOleClientSiteImpl *This = impl_from_IOleClientSite(iface);
295 if (!This->reOle)
296 return CO_E_RELEASED;
298 FIXME("stub %p\n", iface);
299 return E_NOTIMPL;
302 static HRESULT WINAPI IOleClientSite_fnOnShowWindow(IOleClientSite *iface, BOOL fShow)
304 IOleClientSiteImpl *This = impl_from_IOleClientSite(iface);
305 if (!This->reOle)
306 return CO_E_RELEASED;
308 FIXME("stub %p\n", iface);
309 return E_NOTIMPL;
312 static HRESULT WINAPI IOleClientSite_fnRequestNewObjectLayout(IOleClientSite *iface)
314 IOleClientSiteImpl *This = impl_from_IOleClientSite(iface);
315 if (!This->reOle)
316 return CO_E_RELEASED;
318 FIXME("stub %p\n", iface);
319 return E_NOTIMPL;
322 static const IOleClientSiteVtbl ocst = {
323 IOleClientSite_fnQueryInterface,
324 IOleClientSite_fnAddRef,
325 IOleClientSite_fnRelease,
326 IOleClientSite_fnSaveObject,
327 IOleClientSite_fnGetMoniker,
328 IOleClientSite_fnGetContainer,
329 IOleClientSite_fnShowObject,
330 IOleClientSite_fnOnShowWindow,
331 IOleClientSite_fnRequestNewObjectLayout
334 /* IOleWindow interface */
335 static inline IOleClientSiteImpl *impl_from_IOleWindow(IOleWindow *iface)
337 return CONTAINING_RECORD(iface, IOleClientSiteImpl, IOleWindow_iface);
340 static HRESULT WINAPI IOleWindow_fnQueryInterface(IOleWindow *iface, REFIID riid, void **ppvObj)
342 IOleClientSiteImpl *This = impl_from_IOleWindow(iface);
343 return IOleClientSite_QueryInterface(&This->IOleClientSite_iface, riid, ppvObj);
346 static ULONG WINAPI IOleWindow_fnAddRef(IOleWindow *iface)
348 IOleClientSiteImpl *This = impl_from_IOleWindow(iface);
349 return IOleClientSite_AddRef(&This->IOleClientSite_iface);
352 static ULONG WINAPI IOleWindow_fnRelease(IOleWindow *iface)
354 IOleClientSiteImpl *This = impl_from_IOleWindow(iface);
355 return IOleClientSite_Release(&This->IOleClientSite_iface);
358 static HRESULT WINAPI IOleWindow_fnContextSensitiveHelp(IOleWindow *iface, BOOL fEnterMode)
360 IOleClientSiteImpl *This = impl_from_IOleWindow(iface);
361 FIXME("not implemented: (%p)->(%d)\n", This, fEnterMode);
362 return E_NOTIMPL;
365 static HRESULT WINAPI IOleWindow_fnGetWindow(IOleWindow *iface, HWND *phwnd)
367 IOleClientSiteImpl *This = impl_from_IOleWindow(iface);
368 TRACE("(%p)->(%p)\n", This, phwnd);
370 if (!phwnd)
371 return E_INVALIDARG;
373 *phwnd = This->reOle->editor->hWnd;
374 return S_OK;
377 static const IOleWindowVtbl olewinvt = {
378 IOleWindow_fnQueryInterface,
379 IOleWindow_fnAddRef,
380 IOleWindow_fnRelease,
381 IOleWindow_fnGetWindow,
382 IOleWindow_fnContextSensitiveHelp
385 /* IOleInPlaceSite interface */
386 static inline IOleClientSiteImpl *impl_from_IOleInPlaceSite(IOleInPlaceSite *iface)
388 return CONTAINING_RECORD(iface, IOleClientSiteImpl, IOleInPlaceSite_iface);
391 static HRESULT STDMETHODCALLTYPE IOleInPlaceSite_fnQueryInterface(IOleInPlaceSite *iface, REFIID riid, void **ppvObj)
393 IOleClientSiteImpl *This = impl_from_IOleInPlaceSite(iface);
394 return IOleClientSite_QueryInterface(&This->IOleClientSite_iface, riid, ppvObj);
397 static ULONG STDMETHODCALLTYPE IOleInPlaceSite_fnAddRef(IOleInPlaceSite *iface)
399 IOleClientSiteImpl *This = impl_from_IOleInPlaceSite(iface);
400 return IOleClientSite_AddRef(&This->IOleClientSite_iface);
403 static ULONG STDMETHODCALLTYPE IOleInPlaceSite_fnRelease(IOleInPlaceSite *iface)
405 IOleClientSiteImpl *This = impl_from_IOleInPlaceSite(iface);
406 return IOleClientSite_Release(&This->IOleClientSite_iface);
409 static HRESULT STDMETHODCALLTYPE IOleInPlaceSite_fnGetWindow(IOleInPlaceSite *iface, HWND *phwnd)
411 IOleClientSiteImpl *This = impl_from_IOleInPlaceSite(iface);
412 return IOleWindow_GetWindow(&This->IOleWindow_iface, phwnd);
415 static HRESULT STDMETHODCALLTYPE IOleInPlaceSite_fnContextSensitiveHelp(IOleInPlaceSite *iface, BOOL fEnterMode)
417 IOleClientSiteImpl *This = impl_from_IOleInPlaceSite(iface);
418 return IOleWindow_ContextSensitiveHelp(&This->IOleWindow_iface, fEnterMode);
421 static HRESULT STDMETHODCALLTYPE IOleInPlaceSite_fnCanInPlaceActivate(IOleInPlaceSite *iface)
423 IOleClientSiteImpl *This = impl_from_IOleInPlaceSite(iface);
424 FIXME("not implemented: (%p)\n", This);
425 return E_NOTIMPL;
428 static HRESULT STDMETHODCALLTYPE IOleInPlaceSite_fnOnInPlaceActivate(IOleInPlaceSite *iface)
430 IOleClientSiteImpl *This = impl_from_IOleInPlaceSite(iface);
431 FIXME("not implemented: (%p)\n", This);
432 return E_NOTIMPL;
435 static HRESULT STDMETHODCALLTYPE IOleInPlaceSite_fnOnUIActivate(IOleInPlaceSite *iface)
437 IOleClientSiteImpl *This = impl_from_IOleInPlaceSite(iface);
438 FIXME("not implemented: (%p)\n", This);
439 return E_NOTIMPL;
442 static HRESULT STDMETHODCALLTYPE IOleInPlaceSite_fnGetWindowContext(IOleInPlaceSite *iface, IOleInPlaceFrame **ppFrame,
443 IOleInPlaceUIWindow **ppDoc, LPRECT lprcPosRect,
444 LPRECT lprcClipRect, LPOLEINPLACEFRAMEINFO lpFrameInfo)
446 IOleClientSiteImpl *This = impl_from_IOleInPlaceSite(iface);
447 FIXME("not implemented: (%p)->(%p %p %p %p %p\n)", This, ppFrame, ppDoc, lprcPosRect, lprcClipRect, lpFrameInfo);
448 return E_NOTIMPL;
451 static HRESULT STDMETHODCALLTYPE IOleInPlaceSite_fnScroll(IOleInPlaceSite *iface, SIZE scrollExtent)
453 IOleClientSiteImpl *This = impl_from_IOleInPlaceSite(iface);
454 FIXME("not implemented: (%p)\n", This);
455 return E_NOTIMPL;
458 static HRESULT STDMETHODCALLTYPE IOleInPlaceSite_fnOnUIDeactivate(IOleInPlaceSite *iface, BOOL fUndoable)
460 IOleClientSiteImpl *This = impl_from_IOleInPlaceSite(iface);
461 FIXME("not implemented: (%p)->(%d)\n", This, fUndoable);
462 return E_NOTIMPL;
465 static HRESULT STDMETHODCALLTYPE IOleInPlaceSite_fnOnInPlaceDeactivate(IOleInPlaceSite *iface)
467 IOleClientSiteImpl *This = impl_from_IOleInPlaceSite(iface);
468 FIXME("not implemented: (%p)\n", This);
469 return E_NOTIMPL;
472 static HRESULT STDMETHODCALLTYPE IOleInPlaceSite_fnDiscardUndoState(IOleInPlaceSite *iface)
474 IOleClientSiteImpl *This = impl_from_IOleInPlaceSite(iface);
475 FIXME("not implemented: (%p)\n", This);
476 return E_NOTIMPL;
479 static HRESULT STDMETHODCALLTYPE IOleInPlaceSite_fnDeactivateAndUndo(IOleInPlaceSite *iface)
481 IOleClientSiteImpl *This = impl_from_IOleInPlaceSite(iface);
482 FIXME("not implemented: (%p)\n", This);
483 return E_NOTIMPL;
486 static HRESULT STDMETHODCALLTYPE IOleInPlaceSite_fnOnPosRectChange(IOleInPlaceSite *iface, LPCRECT lprcPosRect)
488 IOleClientSiteImpl *This = impl_from_IOleInPlaceSite(iface);
489 FIXME("not implemented: (%p)->(%p)\n", This, lprcPosRect);
490 return E_NOTIMPL;
493 static const IOleInPlaceSiteVtbl olestvt =
495 IOleInPlaceSite_fnQueryInterface,
496 IOleInPlaceSite_fnAddRef,
497 IOleInPlaceSite_fnRelease,
498 IOleInPlaceSite_fnGetWindow,
499 IOleInPlaceSite_fnContextSensitiveHelp,
500 IOleInPlaceSite_fnCanInPlaceActivate,
501 IOleInPlaceSite_fnOnInPlaceActivate,
502 IOleInPlaceSite_fnOnUIActivate,
503 IOleInPlaceSite_fnGetWindowContext,
504 IOleInPlaceSite_fnScroll,
505 IOleInPlaceSite_fnOnUIDeactivate,
506 IOleInPlaceSite_fnOnInPlaceDeactivate,
507 IOleInPlaceSite_fnDiscardUndoState,
508 IOleInPlaceSite_fnDeactivateAndUndo,
509 IOleInPlaceSite_fnOnPosRectChange
512 static IOleClientSiteImpl *
513 CreateOleClientSite(IRichEditOleImpl *reOle)
515 IOleClientSiteImpl *clientSite = heap_alloc(sizeof *clientSite);
516 if (!clientSite)
517 return NULL;
519 clientSite->IOleClientSite_iface.lpVtbl = &ocst;
520 clientSite->IOleWindow_iface.lpVtbl = &olewinvt;
521 clientSite->IOleInPlaceSite_iface.lpVtbl = &olestvt;
522 clientSite->ref = 1;
523 clientSite->reOle = reOle;
524 return clientSite;
527 static HRESULT WINAPI
528 IRichEditOle_fnGetClientSite(IRichEditOle *me,
529 LPOLECLIENTSITE *lplpolesite)
531 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
533 TRACE("%p,%p\n",This, lplpolesite);
535 if(!lplpolesite)
536 return E_INVALIDARG;
537 *lplpolesite = &This->clientSite->IOleClientSite_iface;
538 IOleClientSite_AddRef(*lplpolesite);
539 return S_OK;
542 static HRESULT WINAPI
543 IRichEditOle_fnGetClipboardData(IRichEditOle *me, CHARRANGE *lpchrg,
544 DWORD reco, LPDATAOBJECT *lplpdataobj)
546 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
547 ME_Cursor start;
548 int nChars;
550 TRACE("(%p,%p,%d)\n",This, lpchrg, reco);
551 if(!lplpdataobj)
552 return E_INVALIDARG;
553 if(!lpchrg) {
554 int nFrom, nTo, nStartCur = ME_GetSelectionOfs(This->editor, &nFrom, &nTo);
555 start = This->editor->pCursors[nStartCur];
556 nChars = nTo - nFrom;
557 } else {
558 ME_CursorFromCharOfs(This->editor, lpchrg->cpMin, &start);
559 nChars = lpchrg->cpMax - lpchrg->cpMin;
561 return ME_GetDataObject(This->editor, &start, nChars, lplpdataobj);
564 static LONG WINAPI IRichEditOle_fnGetLinkCount(IRichEditOle *me)
566 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
567 FIXME("stub %p\n",This);
568 return E_NOTIMPL;
571 static HRESULT WINAPI
572 IRichEditOle_fnGetObject(IRichEditOle *me, LONG iob,
573 REOBJECT *lpreobject, DWORD dwFlags)
575 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
576 FIXME("stub %p\n",This);
577 return E_NOTIMPL;
580 static LONG WINAPI
581 IRichEditOle_fnGetObjectCount(IRichEditOle *me)
583 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
584 FIXME("stub %p\n",This);
585 return 0;
588 static HRESULT WINAPI
589 IRichEditOle_fnHandsOffStorage(IRichEditOle *me, LONG iob)
591 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
592 FIXME("stub %p\n",This);
593 return E_NOTIMPL;
596 static HRESULT WINAPI
597 IRichEditOle_fnImportDataObject(IRichEditOle *me, LPDATAOBJECT lpdataobj,
598 CLIPFORMAT cf, HGLOBAL hMetaPict)
600 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
601 FIXME("stub %p\n",This);
602 return E_NOTIMPL;
605 static HRESULT WINAPI
606 IRichEditOle_fnInPlaceDeactivate(IRichEditOle *me)
608 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
609 FIXME("stub %p\n",This);
610 return E_NOTIMPL;
613 static HRESULT WINAPI
614 IRichEditOle_fnInsertObject(IRichEditOle *me, REOBJECT *reo)
616 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
617 TRACE("(%p,%p)\n", This, reo);
619 if (reo->cbStruct < sizeof(*reo)) return STG_E_INVALIDPARAMETER;
621 ME_InsertOLEFromCursor(This->editor, reo, 0);
622 ME_CommitUndo(This->editor);
623 ME_UpdateRepaint(This->editor, FALSE);
624 return S_OK;
627 static HRESULT WINAPI IRichEditOle_fnSaveCompleted(IRichEditOle *me, LONG iob,
628 LPSTORAGE lpstg)
630 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
631 FIXME("stub %p\n",This);
632 return E_NOTIMPL;
635 static HRESULT WINAPI
636 IRichEditOle_fnSetDvaspect(IRichEditOle *me, LONG iob, DWORD dvaspect)
638 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
639 FIXME("stub %p\n",This);
640 return E_NOTIMPL;
643 static HRESULT WINAPI IRichEditOle_fnSetHostNames(IRichEditOle *me,
644 LPCSTR lpstrContainerApp, LPCSTR lpstrContainerObj)
646 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
647 FIXME("stub %p %s %s\n",This, lpstrContainerApp, lpstrContainerObj);
648 return E_NOTIMPL;
651 static HRESULT WINAPI
652 IRichEditOle_fnSetLinkAvailable(IRichEditOle *me, LONG iob, BOOL fAvailable)
654 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
655 FIXME("stub %p\n",This);
656 return E_NOTIMPL;
659 static const IRichEditOleVtbl revt = {
660 IRichEditOle_fnQueryInterface,
661 IRichEditOle_fnAddRef,
662 IRichEditOle_fnRelease,
663 IRichEditOle_fnGetClientSite,
664 IRichEditOle_fnGetObjectCount,
665 IRichEditOle_fnGetLinkCount,
666 IRichEditOle_fnGetObject,
667 IRichEditOle_fnInsertObject,
668 IRichEditOle_fnConvertObject,
669 IRichEditOle_fnActivateAs,
670 IRichEditOle_fnSetHostNames,
671 IRichEditOle_fnSetLinkAvailable,
672 IRichEditOle_fnSetDvaspect,
673 IRichEditOle_fnHandsOffStorage,
674 IRichEditOle_fnSaveCompleted,
675 IRichEditOle_fnInPlaceDeactivate,
676 IRichEditOle_fnContextSensitiveHelp,
677 IRichEditOle_fnGetClipboardData,
678 IRichEditOle_fnImportDataObject
681 /* ITextRange interface */
682 static inline ITextRangeImpl *impl_from_ITextRange(ITextRange *iface)
684 return CONTAINING_RECORD(iface, ITextRangeImpl, ITextRange_iface);
687 static HRESULT WINAPI ITextRange_fnQueryInterface(ITextRange *me, REFIID riid, void **ppvObj)
689 *ppvObj = NULL;
690 if (IsEqualGUID(riid, &IID_IUnknown)
691 || IsEqualGUID(riid, &IID_IDispatch)
692 || IsEqualGUID(riid, &IID_ITextRange))
694 *ppvObj = me;
695 ITextRange_AddRef(me);
696 return S_OK;
699 return E_NOINTERFACE;
702 static ULONG WINAPI ITextRange_fnAddRef(ITextRange *me)
704 ITextRangeImpl *This = impl_from_ITextRange(me);
705 return InterlockedIncrement(&This->ref);
708 static ULONG WINAPI ITextRange_fnRelease(ITextRange *me)
710 ITextRangeImpl *This = impl_from_ITextRange(me);
711 ULONG ref = InterlockedDecrement(&This->ref);
713 TRACE ("%p ref=%u\n", This, ref);
714 if (ref == 0)
716 if (This->reOle)
718 list_remove(&This->entry);
719 This->reOle = NULL;
721 heap_free(This);
723 return ref;
726 static HRESULT WINAPI ITextRange_fnGetTypeInfoCount(ITextRange *me, UINT *pctinfo)
728 ITextRangeImpl *This = impl_from_ITextRange(me);
729 if (!This->reOle)
730 return CO_E_RELEASED;
732 FIXME("not implemented %p\n", This);
733 return E_NOTIMPL;
736 static HRESULT WINAPI ITextRange_fnGetTypeInfo(ITextRange *me, UINT iTInfo, LCID lcid,
737 ITypeInfo **ppTInfo)
739 ITextRangeImpl *This = impl_from_ITextRange(me);
740 if (!This->reOle)
741 return CO_E_RELEASED;
743 FIXME("not implemented %p\n", This);
744 return E_NOTIMPL;
747 static HRESULT WINAPI ITextRange_fnGetIDsOfNames(ITextRange *me, REFIID riid, LPOLESTR *rgszNames,
748 UINT cNames, LCID lcid, DISPID *rgDispId)
750 ITextRangeImpl *This = impl_from_ITextRange(me);
751 if (!This->reOle)
752 return CO_E_RELEASED;
754 FIXME("not implemented %p\n", This);
755 return E_NOTIMPL;
758 static HRESULT WINAPI ITextRange_fnInvoke(ITextRange *me, DISPID dispIdMember, REFIID riid,
759 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
760 VARIANT *pVarResult, EXCEPINFO *pExcepInfo,
761 UINT *puArgErr)
763 ITextRangeImpl *This = impl_from_ITextRange(me);
764 if (!This->reOle)
765 return CO_E_RELEASED;
767 FIXME("not implemented %p\n", This);
768 return E_NOTIMPL;
771 static HRESULT WINAPI ITextRange_fnGetText(ITextRange *me, BSTR *pbstr)
773 ITextRangeImpl *This = impl_from_ITextRange(me);
774 if (!This->reOle)
775 return CO_E_RELEASED;
777 FIXME("not implemented %p\n", This);
778 return E_NOTIMPL;
781 static HRESULT WINAPI ITextRange_fnSetText(ITextRange *me, BSTR bstr)
783 ITextRangeImpl *This = impl_from_ITextRange(me);
784 if (!This->reOle)
785 return CO_E_RELEASED;
787 FIXME("not implemented %p\n", This);
788 return E_NOTIMPL;
791 static HRESULT range_GetChar(ME_TextEditor *editor, ME_Cursor *cursor, LONG *pch)
793 WCHAR wch[2];
795 ME_GetTextW(editor, wch, 1, cursor, 1, FALSE, cursor->pRun->next->type == diTextEnd);
796 *pch = wch[0];
798 return S_OK;
801 static HRESULT WINAPI ITextRange_fnGetChar(ITextRange *me, LONG *pch)
803 ITextRangeImpl *This = impl_from_ITextRange(me);
804 ME_Cursor cursor;
806 if (!This->reOle)
807 return CO_E_RELEASED;
808 TRACE("%p\n", pch);
809 if (!pch)
810 return E_INVALIDARG;
812 ME_CursorFromCharOfs(This->reOle->editor, This->start, &cursor);
813 return range_GetChar(This->reOle->editor, &cursor, pch);
816 static HRESULT WINAPI ITextRange_fnSetChar(ITextRange *me, LONG ch)
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 CreateITextRange(IRichEditOleImpl *reOle, LONG start, LONG end, ITextRange** ppRange);
828 static HRESULT WINAPI ITextRange_fnGetDuplicate(ITextRange *me, ITextRange **ppRange)
830 ITextRangeImpl *This = impl_from_ITextRange(me);
831 if (!This->reOle)
832 return CO_E_RELEASED;
834 TRACE("%p %p\n", This, ppRange);
835 if (!ppRange)
836 return E_INVALIDARG;
838 return CreateITextRange(This->reOle, This->start, This->end, ppRange);
841 static HRESULT WINAPI ITextRange_fnGetFormattedText(ITextRange *me, ITextRange **ppRange)
843 ITextRangeImpl *This = impl_from_ITextRange(me);
844 if (!This->reOle)
845 return CO_E_RELEASED;
847 FIXME("not implemented %p\n", This);
848 return E_NOTIMPL;
851 static HRESULT WINAPI ITextRange_fnSetFormattedText(ITextRange *me, ITextRange *pRange)
853 ITextRangeImpl *This = impl_from_ITextRange(me);
854 if (!This->reOle)
855 return CO_E_RELEASED;
857 FIXME("not implemented %p\n", This);
858 return E_NOTIMPL;
861 static HRESULT WINAPI ITextRange_fnGetStart(ITextRange *me, LONG *pcpFirst)
863 ITextRangeImpl *This = impl_from_ITextRange(me);
864 if (!This->reOle)
865 return CO_E_RELEASED;
867 if (!pcpFirst)
868 return E_INVALIDARG;
869 *pcpFirst = This->start;
870 TRACE("%d\n", *pcpFirst);
871 return S_OK;
874 static HRESULT WINAPI ITextRange_fnSetStart(ITextRange *me, LONG cpFirst)
876 ITextRangeImpl *This = impl_from_ITextRange(me);
877 if (!This->reOle)
878 return CO_E_RELEASED;
880 FIXME("not implemented %p\n", This);
881 return E_NOTIMPL;
884 static HRESULT WINAPI ITextRange_fnGetEnd(ITextRange *me, LONG *pcpLim)
886 ITextRangeImpl *This = impl_from_ITextRange(me);
887 if (!This->reOle)
888 return CO_E_RELEASED;
890 if (!pcpLim)
891 return E_INVALIDARG;
892 *pcpLim = This->end;
893 TRACE("%d\n", *pcpLim);
894 return S_OK;
897 static HRESULT WINAPI ITextRange_fnSetEnd(ITextRange *me, LONG cpLim)
899 ITextRangeImpl *This = impl_from_ITextRange(me);
900 if (!This->reOle)
901 return CO_E_RELEASED;
903 FIXME("not implemented %p\n", This);
904 return E_NOTIMPL;
907 static HRESULT WINAPI ITextRange_fnGetFont(ITextRange *me, ITextFont **pFont)
909 ITextRangeImpl *This = impl_from_ITextRange(me);
910 if (!This->reOle)
911 return CO_E_RELEASED;
913 FIXME("not implemented %p\n", This);
914 return E_NOTIMPL;
917 static HRESULT WINAPI ITextRange_fnSetFont(ITextRange *me, ITextFont *pFont)
919 ITextRangeImpl *This = impl_from_ITextRange(me);
920 if (!This->reOle)
921 return CO_E_RELEASED;
923 FIXME("not implemented %p\n", This);
924 return E_NOTIMPL;
927 static HRESULT WINAPI ITextRange_fnGetPara(ITextRange *me, ITextPara **ppPara)
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_fnSetPara(ITextRange *me, ITextPara *pPara)
939 ITextRangeImpl *This = impl_from_ITextRange(me);
940 if (!This->reOle)
941 return CO_E_RELEASED;
943 FIXME("not implemented %p\n", This);
944 return E_NOTIMPL;
947 static HRESULT WINAPI ITextRange_fnGetStoryLength(ITextRange *me, LONG *pcch)
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_fnGetStoryType(ITextRange *me, LONG *pValue)
959 ITextRangeImpl *This = impl_from_ITextRange(me);
960 if (!This->reOle)
961 return CO_E_RELEASED;
963 FIXME("not implemented %p\n", This);
964 return E_NOTIMPL;
967 static HRESULT range_Collapse(LONG bStart, LONG *start, LONG *end)
969 if (*end == *start)
970 return S_FALSE;
972 if (bStart == tomEnd || bStart == tomFalse)
973 *start = *end;
974 else
975 *end = *start;
976 return S_OK;
979 static HRESULT WINAPI ITextRange_fnCollapse(ITextRange *me, LONG bStart)
981 ITextRangeImpl *This = impl_from_ITextRange(me);
982 if (!This->reOle)
983 return CO_E_RELEASED;
985 return range_Collapse(bStart, &This->start, &This->end);
988 static HRESULT WINAPI ITextRange_fnExpand(ITextRange *me, LONG Unit, LONG *pDelta)
990 ITextRangeImpl *This = impl_from_ITextRange(me);
991 if (!This->reOle)
992 return CO_E_RELEASED;
994 FIXME("not implemented %p\n", This);
995 return E_NOTIMPL;
998 static HRESULT WINAPI ITextRange_fnGetIndex(ITextRange *me, LONG Unit, LONG *pIndex)
1000 ITextRangeImpl *This = impl_from_ITextRange(me);
1001 if (!This->reOle)
1002 return CO_E_RELEASED;
1004 FIXME("not implemented %p\n", This);
1005 return E_NOTIMPL;
1008 static HRESULT WINAPI ITextRange_fnSetIndex(ITextRange *me, LONG Unit, LONG Index,
1009 LONG Extend)
1011 ITextRangeImpl *This = impl_from_ITextRange(me);
1012 if (!This->reOle)
1013 return CO_E_RELEASED;
1015 FIXME("not implemented %p\n", This);
1016 return E_NOTIMPL;
1019 static HRESULT WINAPI ITextRange_fnSetRange(ITextRange *me, LONG cpActive, LONG cpOther)
1021 ITextRangeImpl *This = impl_from_ITextRange(me);
1022 if (!This->reOle)
1023 return CO_E_RELEASED;
1025 FIXME("not implemented %p\n", This);
1026 return E_NOTIMPL;
1029 static HRESULT WINAPI ITextRange_fnInRange(ITextRange *me, ITextRange *pRange, LONG *pb)
1031 ITextRangeImpl *This = impl_from_ITextRange(me);
1032 if (!This->reOle)
1033 return CO_E_RELEASED;
1035 FIXME("not implemented %p\n", This);
1036 return E_NOTIMPL;
1039 static HRESULT WINAPI ITextRange_fnInStory(ITextRange *me, ITextRange *pRange, LONG *pb)
1041 ITextRangeImpl *This = impl_from_ITextRange(me);
1042 if (!This->reOle)
1043 return CO_E_RELEASED;
1045 FIXME("not implemented %p\n", This);
1046 return E_NOTIMPL;
1049 static HRESULT WINAPI ITextRange_fnIsEqual(ITextRange *me, ITextRange *pRange, LONG *pb)
1051 ITextRangeImpl *This = impl_from_ITextRange(me);
1052 if (!This->reOle)
1053 return CO_E_RELEASED;
1055 FIXME("not implemented %p\n", This);
1056 return E_NOTIMPL;
1059 static HRESULT WINAPI ITextRange_fnSelect(ITextRange *me)
1061 ITextRangeImpl *This = impl_from_ITextRange(me);
1062 if (!This->reOle)
1063 return CO_E_RELEASED;
1065 FIXME("not implemented %p\n", This);
1066 return E_NOTIMPL;
1069 static HRESULT WINAPI ITextRange_fnStartOf(ITextRange *me, LONG Unit, LONG Extend,
1070 LONG *pDelta)
1072 ITextRangeImpl *This = impl_from_ITextRange(me);
1073 if (!This->reOle)
1074 return CO_E_RELEASED;
1076 FIXME("not implemented %p\n", This);
1077 return E_NOTIMPL;
1080 static HRESULT WINAPI ITextRange_fnEndOf(ITextRange *me, LONG Unit, LONG Extend,
1081 LONG *pDelta)
1083 ITextRangeImpl *This = impl_from_ITextRange(me);
1084 if (!This->reOle)
1085 return CO_E_RELEASED;
1087 FIXME("not implemented %p\n", This);
1088 return E_NOTIMPL;
1091 static HRESULT WINAPI ITextRange_fnMove(ITextRange *me, LONG Unit, LONG Count, LONG *pDelta)
1093 ITextRangeImpl *This = impl_from_ITextRange(me);
1094 if (!This->reOle)
1095 return CO_E_RELEASED;
1097 FIXME("not implemented %p\n", This);
1098 return E_NOTIMPL;
1101 static HRESULT WINAPI ITextRange_fnMoveStart(ITextRange *me, LONG Unit, LONG Count,
1102 LONG *pDelta)
1104 ITextRangeImpl *This = impl_from_ITextRange(me);
1105 if (!This->reOle)
1106 return CO_E_RELEASED;
1108 FIXME("not implemented %p\n", This);
1109 return E_NOTIMPL;
1112 static HRESULT WINAPI ITextRange_fnMoveEnd(ITextRange *me, LONG Unit, LONG Count,
1113 LONG *pDelta)
1115 ITextRangeImpl *This = impl_from_ITextRange(me);
1116 if (!This->reOle)
1117 return CO_E_RELEASED;
1119 FIXME("not implemented %p\n", This);
1120 return E_NOTIMPL;
1123 static HRESULT WINAPI ITextRange_fnMoveWhile(ITextRange *me, VARIANT *Cset, LONG Count,
1124 LONG *pDelta)
1126 ITextRangeImpl *This = impl_from_ITextRange(me);
1127 if (!This->reOle)
1128 return CO_E_RELEASED;
1130 FIXME("not implemented %p\n", This);
1131 return E_NOTIMPL;
1134 static HRESULT WINAPI ITextRange_fnMoveStartWhile(ITextRange *me, VARIANT *Cset, LONG Count,
1135 LONG *pDelta)
1137 ITextRangeImpl *This = impl_from_ITextRange(me);
1138 if (!This->reOle)
1139 return CO_E_RELEASED;
1141 FIXME("not implemented %p\n", This);
1142 return E_NOTIMPL;
1145 static HRESULT WINAPI ITextRange_fnMoveEndWhile(ITextRange *me, VARIANT *Cset, LONG Count,
1146 LONG *pDelta)
1148 ITextRangeImpl *This = impl_from_ITextRange(me);
1149 if (!This->reOle)
1150 return CO_E_RELEASED;
1152 FIXME("not implemented %p\n", This);
1153 return E_NOTIMPL;
1156 static HRESULT WINAPI ITextRange_fnMoveUntil(ITextRange *me, VARIANT *Cset, LONG Count,
1157 LONG *pDelta)
1159 ITextRangeImpl *This = impl_from_ITextRange(me);
1160 if (!This->reOle)
1161 return CO_E_RELEASED;
1163 FIXME("not implemented %p\n", This);
1164 return E_NOTIMPL;
1167 static HRESULT WINAPI ITextRange_fnMoveStartUntil(ITextRange *me, VARIANT *Cset, LONG Count,
1168 LONG *pDelta)
1170 ITextRangeImpl *This = impl_from_ITextRange(me);
1171 if (!This->reOle)
1172 return CO_E_RELEASED;
1174 FIXME("not implemented %p\n", This);
1175 return E_NOTIMPL;
1178 static HRESULT WINAPI ITextRange_fnMoveEndUntil(ITextRange *me, VARIANT *Cset, LONG Count,
1179 LONG *pDelta)
1181 ITextRangeImpl *This = impl_from_ITextRange(me);
1182 if (!This->reOle)
1183 return CO_E_RELEASED;
1185 FIXME("not implemented %p\n", This);
1186 return E_NOTIMPL;
1189 static HRESULT WINAPI ITextRange_fnFindText(ITextRange *me, BSTR bstr, LONG cch, LONG Flags,
1190 LONG *pLength)
1192 ITextRangeImpl *This = impl_from_ITextRange(me);
1193 if (!This->reOle)
1194 return CO_E_RELEASED;
1196 FIXME("not implemented %p\n", This);
1197 return E_NOTIMPL;
1200 static HRESULT WINAPI ITextRange_fnFindTextStart(ITextRange *me, BSTR bstr, LONG cch,
1201 LONG Flags, LONG *pLength)
1203 ITextRangeImpl *This = impl_from_ITextRange(me);
1204 if (!This->reOle)
1205 return CO_E_RELEASED;
1207 FIXME("not implemented %p\n", This);
1208 return E_NOTIMPL;
1211 static HRESULT WINAPI ITextRange_fnFindTextEnd(ITextRange *me, BSTR bstr, LONG cch,
1212 LONG Flags, LONG *pLength)
1214 ITextRangeImpl *This = impl_from_ITextRange(me);
1215 if (!This->reOle)
1216 return CO_E_RELEASED;
1218 FIXME("not implemented %p\n", This);
1219 return E_NOTIMPL;
1222 static HRESULT WINAPI ITextRange_fnDelete(ITextRange *me, LONG Unit, LONG Count,
1223 LONG *pDelta)
1225 ITextRangeImpl *This = impl_from_ITextRange(me);
1226 if (!This->reOle)
1227 return CO_E_RELEASED;
1229 FIXME("not implemented %p\n", This);
1230 return E_NOTIMPL;
1233 static HRESULT WINAPI ITextRange_fnCut(ITextRange *me, VARIANT *pVar)
1235 ITextRangeImpl *This = impl_from_ITextRange(me);
1236 if (!This->reOle)
1237 return CO_E_RELEASED;
1239 FIXME("not implemented %p\n", This);
1240 return E_NOTIMPL;
1243 static HRESULT WINAPI ITextRange_fnCopy(ITextRange *me, VARIANT *pVar)
1245 ITextRangeImpl *This = impl_from_ITextRange(me);
1246 if (!This->reOle)
1247 return CO_E_RELEASED;
1249 FIXME("not implemented %p\n", This);
1250 return E_NOTIMPL;
1253 static HRESULT WINAPI ITextRange_fnPaste(ITextRange *me, VARIANT *pVar, LONG Format)
1255 ITextRangeImpl *This = impl_from_ITextRange(me);
1256 if (!This->reOle)
1257 return CO_E_RELEASED;
1259 FIXME("not implemented %p\n", This);
1260 return E_NOTIMPL;
1263 static HRESULT WINAPI ITextRange_fnCanPaste(ITextRange *me, VARIANT *pVar, LONG Format,
1264 LONG *pb)
1266 ITextRangeImpl *This = impl_from_ITextRange(me);
1267 if (!This->reOle)
1268 return CO_E_RELEASED;
1270 FIXME("not implemented %p\n", This);
1271 return E_NOTIMPL;
1274 static HRESULT WINAPI ITextRange_fnCanEdit(ITextRange *me, LONG *pb)
1276 ITextRangeImpl *This = impl_from_ITextRange(me);
1277 if (!This->reOle)
1278 return CO_E_RELEASED;
1280 FIXME("not implemented %p\n", This);
1281 return E_NOTIMPL;
1284 static HRESULT WINAPI ITextRange_fnChangeCase(ITextRange *me, LONG Type)
1286 ITextRangeImpl *This = impl_from_ITextRange(me);
1287 if (!This->reOle)
1288 return CO_E_RELEASED;
1290 FIXME("not implemented %p\n", This);
1291 return E_NOTIMPL;
1294 static HRESULT WINAPI ITextRange_fnGetPoint(ITextRange *me, LONG Type, LONG *cx, LONG *cy)
1296 ITextRangeImpl *This = impl_from_ITextRange(me);
1297 if (!This->reOle)
1298 return CO_E_RELEASED;
1300 FIXME("not implemented %p\n", This);
1301 return E_NOTIMPL;
1304 static HRESULT WINAPI ITextRange_fnSetPoint(ITextRange *me, LONG x, LONG y, LONG Type,
1305 LONG Extend)
1307 ITextRangeImpl *This = impl_from_ITextRange(me);
1308 if (!This->reOle)
1309 return CO_E_RELEASED;
1311 FIXME("not implemented %p\n", This);
1312 return E_NOTIMPL;
1315 static HRESULT WINAPI ITextRange_fnScrollIntoView(ITextRange *me, LONG Value)
1317 ITextRangeImpl *This = impl_from_ITextRange(me);
1318 if (!This->reOle)
1319 return CO_E_RELEASED;
1321 FIXME("not implemented %p\n", This);
1322 return E_NOTIMPL;
1325 static HRESULT WINAPI ITextRange_fnGetEmbeddedObject(ITextRange *me, IUnknown **ppv)
1327 ITextRangeImpl *This = impl_from_ITextRange(me);
1328 if (!This->reOle)
1329 return CO_E_RELEASED;
1331 FIXME("not implemented %p\n", This);
1332 return E_NOTIMPL;
1335 static const ITextRangeVtbl trvt = {
1336 ITextRange_fnQueryInterface,
1337 ITextRange_fnAddRef,
1338 ITextRange_fnRelease,
1339 ITextRange_fnGetTypeInfoCount,
1340 ITextRange_fnGetTypeInfo,
1341 ITextRange_fnGetIDsOfNames,
1342 ITextRange_fnInvoke,
1343 ITextRange_fnGetText,
1344 ITextRange_fnSetText,
1345 ITextRange_fnGetChar,
1346 ITextRange_fnSetChar,
1347 ITextRange_fnGetDuplicate,
1348 ITextRange_fnGetFormattedText,
1349 ITextRange_fnSetFormattedText,
1350 ITextRange_fnGetStart,
1351 ITextRange_fnSetStart,
1352 ITextRange_fnGetEnd,
1353 ITextRange_fnSetEnd,
1354 ITextRange_fnGetFont,
1355 ITextRange_fnSetFont,
1356 ITextRange_fnGetPara,
1357 ITextRange_fnSetPara,
1358 ITextRange_fnGetStoryLength,
1359 ITextRange_fnGetStoryType,
1360 ITextRange_fnCollapse,
1361 ITextRange_fnExpand,
1362 ITextRange_fnGetIndex,
1363 ITextRange_fnSetIndex,
1364 ITextRange_fnSetRange,
1365 ITextRange_fnInRange,
1366 ITextRange_fnInStory,
1367 ITextRange_fnIsEqual,
1368 ITextRange_fnSelect,
1369 ITextRange_fnStartOf,
1370 ITextRange_fnEndOf,
1371 ITextRange_fnMove,
1372 ITextRange_fnMoveStart,
1373 ITextRange_fnMoveEnd,
1374 ITextRange_fnMoveWhile,
1375 ITextRange_fnMoveStartWhile,
1376 ITextRange_fnMoveEndWhile,
1377 ITextRange_fnMoveUntil,
1378 ITextRange_fnMoveStartUntil,
1379 ITextRange_fnMoveEndUntil,
1380 ITextRange_fnFindText,
1381 ITextRange_fnFindTextStart,
1382 ITextRange_fnFindTextEnd,
1383 ITextRange_fnDelete,
1384 ITextRange_fnCut,
1385 ITextRange_fnCopy,
1386 ITextRange_fnPaste,
1387 ITextRange_fnCanPaste,
1388 ITextRange_fnCanEdit,
1389 ITextRange_fnChangeCase,
1390 ITextRange_fnGetPoint,
1391 ITextRange_fnSetPoint,
1392 ITextRange_fnScrollIntoView,
1393 ITextRange_fnGetEmbeddedObject
1395 /* ITextRange interface */
1397 static HRESULT WINAPI
1398 ITextDocument_fnQueryInterface(ITextDocument* me, REFIID riid,
1399 void** ppvObject)
1401 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1402 return IRichEditOle_QueryInterface(&This->IRichEditOle_iface, riid, ppvObject);
1405 static ULONG WINAPI
1406 ITextDocument_fnAddRef(ITextDocument* me)
1408 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1409 return IRichEditOle_AddRef(&This->IRichEditOle_iface);
1412 static ULONG WINAPI
1413 ITextDocument_fnRelease(ITextDocument* me)
1415 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1416 return IRichEditOle_Release(&This->IRichEditOle_iface);
1419 static HRESULT WINAPI
1420 ITextDocument_fnGetTypeInfoCount(ITextDocument* me,
1421 UINT* pctinfo)
1423 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1424 FIXME("stub %p\n",This);
1425 return E_NOTIMPL;
1428 static HRESULT WINAPI
1429 ITextDocument_fnGetTypeInfo(ITextDocument* me, UINT iTInfo, LCID lcid,
1430 ITypeInfo** ppTInfo)
1432 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1433 FIXME("stub %p\n",This);
1434 return E_NOTIMPL;
1437 static HRESULT WINAPI
1438 ITextDocument_fnGetIDsOfNames(ITextDocument* me, REFIID riid,
1439 LPOLESTR* rgszNames, UINT cNames, LCID lcid, DISPID* rgDispId)
1441 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1442 FIXME("stub %p\n",This);
1443 return E_NOTIMPL;
1446 static HRESULT WINAPI
1447 ITextDocument_fnInvoke(ITextDocument* me, DISPID dispIdMember,
1448 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS* pDispParams,
1449 VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr)
1451 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1452 FIXME("stub %p\n",This);
1453 return E_NOTIMPL;
1456 static HRESULT WINAPI
1457 ITextDocument_fnGetName(ITextDocument* me, BSTR* pName)
1459 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1460 FIXME("stub %p\n",This);
1461 return E_NOTIMPL;
1464 static HRESULT WINAPI
1465 ITextDocument_fnGetSelection(ITextDocument* me, ITextSelection** ppSel)
1467 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1468 TRACE("(%p)\n", me);
1470 if(!ppSel)
1471 return E_INVALIDARG;
1472 *ppSel = &This->txtSel->ITextSelection_iface;
1473 ITextSelection_AddRef(*ppSel);
1474 return S_OK;
1477 static HRESULT WINAPI
1478 ITextDocument_fnGetStoryCount(ITextDocument* me, LONG* pCount)
1480 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1481 FIXME("stub %p\n",This);
1482 return E_NOTIMPL;
1485 static HRESULT WINAPI
1486 ITextDocument_fnGetStoryRanges(ITextDocument* me,
1487 ITextStoryRanges** ppStories)
1489 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1490 FIXME("stub %p\n",This);
1491 return E_NOTIMPL;
1494 static HRESULT WINAPI
1495 ITextDocument_fnGetSaved(ITextDocument* me, LONG* pValue)
1497 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1498 FIXME("stub %p\n",This);
1499 return E_NOTIMPL;
1502 static HRESULT WINAPI
1503 ITextDocument_fnSetSaved(ITextDocument* me, LONG Value)
1505 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1506 FIXME("stub %p\n",This);
1507 return E_NOTIMPL;
1510 static HRESULT WINAPI
1511 ITextDocument_fnGetDefaultTabStop(ITextDocument* me, float* pValue)
1513 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1514 FIXME("stub %p\n",This);
1515 return E_NOTIMPL;
1518 static HRESULT WINAPI
1519 ITextDocument_fnSetDefaultTabStop(ITextDocument* me, float Value)
1521 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1522 FIXME("stub %p\n",This);
1523 return E_NOTIMPL;
1526 static HRESULT WINAPI
1527 ITextDocument_fnNew(ITextDocument* me)
1529 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1530 FIXME("stub %p\n",This);
1531 return E_NOTIMPL;
1534 static HRESULT WINAPI
1535 ITextDocument_fnOpen(ITextDocument* me, VARIANT* pVar, LONG Flags,
1536 LONG CodePage)
1538 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1539 FIXME("stub %p\n",This);
1540 return E_NOTIMPL;
1543 static HRESULT WINAPI
1544 ITextDocument_fnSave(ITextDocument* me, VARIANT* pVar, LONG Flags,
1545 LONG CodePage)
1547 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1548 FIXME("stub %p\n",This);
1549 return E_NOTIMPL;
1552 static HRESULT WINAPI
1553 ITextDocument_fnFreeze(ITextDocument* me, LONG* pCount)
1555 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1556 FIXME("stub %p\n",This);
1557 return E_NOTIMPL;
1560 static HRESULT WINAPI
1561 ITextDocument_fnUnfreeze(ITextDocument* me, LONG* pCount)
1563 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1564 FIXME("stub %p\n",This);
1565 return E_NOTIMPL;
1568 static HRESULT WINAPI
1569 ITextDocument_fnBeginEditCollection(ITextDocument* me)
1571 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1572 FIXME("stub %p\n",This);
1573 return E_NOTIMPL;
1576 static HRESULT WINAPI
1577 ITextDocument_fnEndEditCollection(ITextDocument* me)
1579 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1580 FIXME("stub %p\n",This);
1581 return E_NOTIMPL;
1584 static HRESULT WINAPI
1585 ITextDocument_fnUndo(ITextDocument* me, LONG Count, LONG* prop)
1587 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1588 FIXME("stub %p\n",This);
1589 return E_NOTIMPL;
1592 static HRESULT WINAPI
1593 ITextDocument_fnRedo(ITextDocument* me, LONG Count, LONG* prop)
1595 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1596 FIXME("stub %p\n",This);
1597 return E_NOTIMPL;
1600 static HRESULT CreateITextRange(IRichEditOleImpl *reOle, LONG start, LONG end, ITextRange** ppRange)
1602 ITextRangeImpl *txtRge = heap_alloc(sizeof(ITextRangeImpl));
1604 if (!txtRge)
1605 return E_OUTOFMEMORY;
1606 txtRge->ITextRange_iface.lpVtbl = &trvt;
1607 txtRge->ref = 1;
1608 txtRge->reOle = reOle;
1609 txtRge->start = start;
1610 txtRge->end = end;
1611 list_add_head(&reOle->rangelist, &txtRge->entry);
1612 *ppRange = &txtRge->ITextRange_iface;
1613 return S_OK;
1616 static HRESULT WINAPI
1617 ITextDocument_fnRange(ITextDocument* me, LONG cp1, LONG cp2,
1618 ITextRange** ppRange)
1620 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1621 const int len = ME_GetTextLength(This->editor) + 1;
1623 TRACE("%p %p %d %d\n", This, ppRange, cp1, cp2);
1624 if (!ppRange)
1625 return E_INVALIDARG;
1627 cp1 = max(cp1, 0);
1628 cp2 = max(cp2, 0);
1629 cp1 = min(cp1, len);
1630 cp2 = min(cp2, len);
1631 if (cp1 > cp2)
1633 LONG tmp;
1634 tmp = cp1;
1635 cp1 = cp2;
1636 cp2 = tmp;
1638 if (cp1 == len)
1639 cp1 = cp2 = len - 1;
1641 return CreateITextRange(This, cp1, cp2, ppRange);
1644 static HRESULT WINAPI
1645 ITextDocument_fnRangeFromPoint(ITextDocument* me, LONG x, LONG y,
1646 ITextRange** ppRange)
1648 IRichEditOleImpl *This = impl_from_ITextDocument(me);
1649 FIXME("stub %p\n",This);
1650 return E_NOTIMPL;
1653 static const ITextDocumentVtbl tdvt = {
1654 ITextDocument_fnQueryInterface,
1655 ITextDocument_fnAddRef,
1656 ITextDocument_fnRelease,
1657 ITextDocument_fnGetTypeInfoCount,
1658 ITextDocument_fnGetTypeInfo,
1659 ITextDocument_fnGetIDsOfNames,
1660 ITextDocument_fnInvoke,
1661 ITextDocument_fnGetName,
1662 ITextDocument_fnGetSelection,
1663 ITextDocument_fnGetStoryCount,
1664 ITextDocument_fnGetStoryRanges,
1665 ITextDocument_fnGetSaved,
1666 ITextDocument_fnSetSaved,
1667 ITextDocument_fnGetDefaultTabStop,
1668 ITextDocument_fnSetDefaultTabStop,
1669 ITextDocument_fnNew,
1670 ITextDocument_fnOpen,
1671 ITextDocument_fnSave,
1672 ITextDocument_fnFreeze,
1673 ITextDocument_fnUnfreeze,
1674 ITextDocument_fnBeginEditCollection,
1675 ITextDocument_fnEndEditCollection,
1676 ITextDocument_fnUndo,
1677 ITextDocument_fnRedo,
1678 ITextDocument_fnRange,
1679 ITextDocument_fnRangeFromPoint
1682 static inline ITextSelectionImpl *impl_from_ITextSelection(ITextSelection *iface)
1684 return CONTAINING_RECORD(iface, ITextSelectionImpl, ITextSelection_iface);
1687 static HRESULT WINAPI ITextSelection_fnQueryInterface(
1688 ITextSelection *me,
1689 REFIID riid,
1690 void **ppvObj)
1692 *ppvObj = NULL;
1693 if (IsEqualGUID(riid, &IID_IUnknown)
1694 || IsEqualGUID(riid, &IID_IDispatch)
1695 || IsEqualGUID(riid, &IID_ITextRange)
1696 || IsEqualGUID(riid, &IID_ITextSelection))
1698 *ppvObj = me;
1699 ITextSelection_AddRef(me);
1700 return S_OK;
1703 return E_NOINTERFACE;
1706 static ULONG WINAPI ITextSelection_fnAddRef(ITextSelection *me)
1708 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1709 return InterlockedIncrement(&This->ref);
1712 static ULONG WINAPI ITextSelection_fnRelease(ITextSelection *me)
1714 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1715 ULONG ref = InterlockedDecrement(&This->ref);
1716 if (ref == 0)
1717 heap_free(This);
1718 return ref;
1721 static HRESULT WINAPI ITextSelection_fnGetTypeInfoCount(ITextSelection *me, UINT *pctinfo)
1723 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1724 if (!This->reOle)
1725 return CO_E_RELEASED;
1727 FIXME("not implemented\n");
1728 return E_NOTIMPL;
1731 static HRESULT WINAPI ITextSelection_fnGetTypeInfo(ITextSelection *me, UINT iTInfo, LCID lcid,
1732 ITypeInfo **ppTInfo)
1734 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1735 if (!This->reOle)
1736 return CO_E_RELEASED;
1738 FIXME("not implemented\n");
1739 return E_NOTIMPL;
1742 static HRESULT WINAPI ITextSelection_fnGetIDsOfNames(ITextSelection *me, REFIID riid,
1743 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
1745 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1746 if (!This->reOle)
1747 return CO_E_RELEASED;
1749 FIXME("not implemented\n");
1750 return E_NOTIMPL;
1753 static HRESULT WINAPI ITextSelection_fnInvoke(
1754 ITextSelection *me,
1755 DISPID dispIdMember,
1756 REFIID riid,
1757 LCID lcid,
1758 WORD wFlags,
1759 DISPPARAMS *pDispParams,
1760 VARIANT *pVarResult,
1761 EXCEPINFO *pExcepInfo,
1762 UINT *puArgErr)
1764 FIXME("not implemented\n");
1765 return E_NOTIMPL;
1768 /*** ITextRange methods ***/
1769 static HRESULT WINAPI ITextSelection_fnGetText(ITextSelection *me, BSTR *pbstr)
1771 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1772 ME_Cursor *start = NULL, *end = NULL;
1773 int nChars, endOfs;
1774 BOOL bEOP;
1776 if (!This->reOle)
1777 return CO_E_RELEASED;
1778 TRACE("%p\n", pbstr);
1779 if (!pbstr)
1780 return E_INVALIDARG;
1782 ME_GetSelection(This->reOle->editor, &start, &end);
1783 endOfs = ME_GetCursorOfs(end);
1784 nChars = endOfs - ME_GetCursorOfs(start);
1785 if (!nChars)
1787 *pbstr = NULL;
1788 return S_OK;
1791 *pbstr = SysAllocStringLen(NULL, nChars);
1792 if (!*pbstr)
1793 return E_OUTOFMEMORY;
1795 bEOP = (end->pRun->next->type == diTextEnd && endOfs > ME_GetTextLength(This->reOle->editor));
1796 ME_GetTextW(This->reOle->editor, *pbstr, nChars, start, nChars, FALSE, bEOP);
1797 TRACE("%s\n", wine_dbgstr_w(*pbstr));
1799 return S_OK;
1802 static HRESULT WINAPI ITextSelection_fnSetText(ITextSelection *me, BSTR bstr)
1804 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1805 if (!This->reOle)
1806 return CO_E_RELEASED;
1808 FIXME("not implemented\n");
1809 return E_NOTIMPL;
1812 static HRESULT WINAPI ITextSelection_fnGetChar(ITextSelection *me, LONG *pch)
1814 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1815 ME_Cursor *start = NULL, *end = NULL;
1817 if (!This->reOle)
1818 return CO_E_RELEASED;
1819 TRACE("%p\n", pch);
1820 if (!pch)
1821 return E_INVALIDARG;
1823 ME_GetSelection(This->reOle->editor, &start, &end);
1824 return range_GetChar(This->reOle->editor, start, pch);
1827 static HRESULT WINAPI ITextSelection_fnSetChar(ITextSelection *me, LONG ch)
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_fnGetDuplicate(ITextSelection *me, ITextRange **ppRange)
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_fnGetFormattedText(ITextSelection *me, ITextRange **ppRange)
1849 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1850 if (!This->reOle)
1851 return CO_E_RELEASED;
1853 FIXME("not implemented\n");
1854 return E_NOTIMPL;
1857 static HRESULT WINAPI ITextSelection_fnSetFormattedText(ITextSelection *me, ITextRange *pRange)
1859 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1860 if (!This->reOle)
1861 return CO_E_RELEASED;
1863 FIXME("not implemented\n");
1864 return E_NOTIMPL;
1867 static HRESULT WINAPI ITextSelection_fnGetStart(ITextSelection *me, LONG *pcpFirst)
1869 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1870 LONG lim;
1871 if (!This->reOle)
1872 return CO_E_RELEASED;
1874 if (!pcpFirst)
1875 return E_INVALIDARG;
1876 ME_GetSelectionOfs(This->reOle->editor, pcpFirst, &lim);
1877 TRACE("%d\n", *pcpFirst);
1878 return S_OK;
1881 static HRESULT WINAPI ITextSelection_fnSetStart(ITextSelection *me, LONG cpFirst)
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_fnGetEnd(ITextSelection *me, LONG *pcpLim)
1893 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1894 LONG first;
1895 if (!This->reOle)
1896 return CO_E_RELEASED;
1898 if (!pcpLim)
1899 return E_INVALIDARG;
1900 ME_GetSelectionOfs(This->reOle->editor, &first, pcpLim);
1901 TRACE("%d\n", *pcpLim);
1902 return S_OK;
1905 static HRESULT WINAPI ITextSelection_fnSetEnd(ITextSelection *me, LONG cpLim)
1907 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1908 if (!This->reOle)
1909 return CO_E_RELEASED;
1911 FIXME("not implemented\n");
1912 return E_NOTIMPL;
1915 static HRESULT WINAPI ITextSelection_fnGetFont(ITextSelection *me, ITextFont **pFont)
1917 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1918 if (!This->reOle)
1919 return CO_E_RELEASED;
1921 FIXME("not implemented\n");
1922 return E_NOTIMPL;
1925 static HRESULT WINAPI ITextSelection_fnSetFont(ITextSelection *me, ITextFont *pFont)
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_fnGetPara(ITextSelection *me, ITextPara **ppPara)
1937 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1938 if (!This->reOle)
1939 return CO_E_RELEASED;
1941 FIXME("not implemented\n");
1942 return E_NOTIMPL;
1945 static HRESULT WINAPI ITextSelection_fnSetPara(ITextSelection *me, ITextPara *pPara)
1947 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1948 if (!This->reOle)
1949 return CO_E_RELEASED;
1951 FIXME("not implemented\n");
1952 return E_NOTIMPL;
1955 static HRESULT WINAPI ITextSelection_fnGetStoryLength(ITextSelection *me, LONG *pcch)
1957 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1958 if (!This->reOle)
1959 return CO_E_RELEASED;
1961 FIXME("not implemented\n");
1962 return E_NOTIMPL;
1965 static HRESULT WINAPI ITextSelection_fnGetStoryType(ITextSelection *me, LONG *pValue)
1967 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1968 if (!This->reOle)
1969 return CO_E_RELEASED;
1971 FIXME("not implemented\n");
1972 return E_NOTIMPL;
1975 static HRESULT WINAPI ITextSelection_fnCollapse(ITextSelection *me, LONG bStart)
1977 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1978 LONG start, end;
1979 HRESULT hres;
1980 if (!This->reOle)
1981 return CO_E_RELEASED;
1983 ME_GetSelectionOfs(This->reOle->editor, &start, &end);
1984 hres = range_Collapse(bStart, &start, &end);
1985 if (SUCCEEDED(hres))
1986 ME_SetSelection(This->reOle->editor, start, end);
1987 return hres;
1990 static HRESULT WINAPI ITextSelection_fnExpand(ITextSelection *me, LONG Unit, LONG *pDelta)
1992 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1993 if (!This->reOle)
1994 return CO_E_RELEASED;
1996 FIXME("not implemented\n");
1997 return E_NOTIMPL;
2000 static HRESULT WINAPI ITextSelection_fnGetIndex(ITextSelection *me, LONG Unit, LONG *pIndex)
2002 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2003 if (!This->reOle)
2004 return CO_E_RELEASED;
2006 FIXME("not implemented\n");
2007 return E_NOTIMPL;
2010 static HRESULT WINAPI ITextSelection_fnSetIndex(ITextSelection *me, LONG Unit, LONG Index,
2011 LONG Extend)
2013 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2014 if (!This->reOle)
2015 return CO_E_RELEASED;
2017 FIXME("not implemented\n");
2018 return E_NOTIMPL;
2021 static HRESULT WINAPI ITextSelection_fnSetRange(ITextSelection *me, LONG cpActive, LONG cpOther)
2023 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2024 if (!This->reOle)
2025 return CO_E_RELEASED;
2027 FIXME("not implemented\n");
2028 return E_NOTIMPL;
2031 static HRESULT WINAPI ITextSelection_fnInRange(ITextSelection *me, ITextRange *pRange, LONG *pb)
2033 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2034 if (!This->reOle)
2035 return CO_E_RELEASED;
2037 FIXME("not implemented\n");
2038 return E_NOTIMPL;
2041 static HRESULT WINAPI ITextSelection_fnInStory(ITextSelection *me, ITextRange *pRange, LONG *pb)
2043 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2044 if (!This->reOle)
2045 return CO_E_RELEASED;
2047 FIXME("not implemented\n");
2048 return E_NOTIMPL;
2051 static HRESULT WINAPI ITextSelection_fnIsEqual(ITextSelection *me, ITextRange *pRange, LONG *pb)
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_fnSelect(ITextSelection *me)
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_fnStartOf(ITextSelection *me, LONG Unit, LONG Extend,
2072 LONG *pDelta)
2074 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2075 if (!This->reOle)
2076 return CO_E_RELEASED;
2078 FIXME("not implemented\n");
2079 return E_NOTIMPL;
2082 static HRESULT WINAPI ITextSelection_fnEndOf(ITextSelection *me, LONG Unit, LONG Extend,
2083 LONG *pDelta)
2085 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2086 if (!This->reOle)
2087 return CO_E_RELEASED;
2089 FIXME("not implemented\n");
2090 return E_NOTIMPL;
2093 static HRESULT WINAPI ITextSelection_fnMove(ITextSelection *me, LONG Unit, LONG Count, LONG *pDelta)
2095 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2096 if (!This->reOle)
2097 return CO_E_RELEASED;
2099 FIXME("not implemented\n");
2100 return E_NOTIMPL;
2103 static HRESULT WINAPI ITextSelection_fnMoveStart(ITextSelection *me, LONG Unit, LONG Count,
2104 LONG *pDelta)
2106 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2107 if (!This->reOle)
2108 return CO_E_RELEASED;
2110 FIXME("not implemented\n");
2111 return E_NOTIMPL;
2114 static HRESULT WINAPI ITextSelection_fnMoveEnd(ITextSelection *me, LONG Unit, LONG Count,
2115 LONG *pDelta)
2117 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2118 if (!This->reOle)
2119 return CO_E_RELEASED;
2121 FIXME("not implemented\n");
2122 return E_NOTIMPL;
2125 static HRESULT WINAPI ITextSelection_fnMoveWhile(ITextSelection *me, VARIANT *Cset, LONG Count,
2126 LONG *pDelta)
2128 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2129 if (!This->reOle)
2130 return CO_E_RELEASED;
2132 FIXME("not implemented\n");
2133 return E_NOTIMPL;
2136 static HRESULT WINAPI ITextSelection_fnMoveStartWhile(ITextSelection *me, VARIANT *Cset, LONG Count,
2137 LONG *pDelta)
2139 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2140 if (!This->reOle)
2141 return CO_E_RELEASED;
2143 FIXME("not implemented\n");
2144 return E_NOTIMPL;
2147 static HRESULT WINAPI ITextSelection_fnMoveEndWhile(ITextSelection *me, VARIANT *Cset, LONG Count,
2148 LONG *pDelta)
2150 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2151 if (!This->reOle)
2152 return CO_E_RELEASED;
2154 FIXME("not implemented\n");
2155 return E_NOTIMPL;
2158 static HRESULT WINAPI ITextSelection_fnMoveUntil(ITextSelection *me, VARIANT *Cset, LONG Count,
2159 LONG *pDelta)
2161 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2162 if (!This->reOle)
2163 return CO_E_RELEASED;
2165 FIXME("not implemented\n");
2166 return E_NOTIMPL;
2169 static HRESULT WINAPI ITextSelection_fnMoveStartUntil(ITextSelection *me, VARIANT *Cset, LONG Count,
2170 LONG *pDelta)
2172 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2173 if (!This->reOle)
2174 return CO_E_RELEASED;
2176 FIXME("not implemented\n");
2177 return E_NOTIMPL;
2180 static HRESULT WINAPI ITextSelection_fnMoveEndUntil(ITextSelection *me, VARIANT *Cset, LONG Count,
2181 LONG *pDelta)
2183 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2184 if (!This->reOle)
2185 return CO_E_RELEASED;
2187 FIXME("not implemented\n");
2188 return E_NOTIMPL;
2191 static HRESULT WINAPI ITextSelection_fnFindText(ITextSelection *me, BSTR bstr, LONG cch, LONG Flags,
2192 LONG *pLength)
2194 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2195 if (!This->reOle)
2196 return CO_E_RELEASED;
2198 FIXME("not implemented\n");
2199 return E_NOTIMPL;
2202 static HRESULT WINAPI ITextSelection_fnFindTextStart(ITextSelection *me, BSTR bstr, LONG cch,
2203 LONG Flags, LONG *pLength)
2205 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2206 if (!This->reOle)
2207 return CO_E_RELEASED;
2209 FIXME("not implemented\n");
2210 return E_NOTIMPL;
2213 static HRESULT WINAPI ITextSelection_fnFindTextEnd(ITextSelection *me, BSTR bstr, LONG cch,
2214 LONG Flags, LONG *pLength)
2216 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2217 if (!This->reOle)
2218 return CO_E_RELEASED;
2220 FIXME("not implemented\n");
2221 return E_NOTIMPL;
2224 static HRESULT WINAPI ITextSelection_fnDelete(ITextSelection *me, LONG Unit, LONG Count,
2225 LONG *pDelta)
2227 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2228 if (!This->reOle)
2229 return CO_E_RELEASED;
2231 FIXME("not implemented\n");
2232 return E_NOTIMPL;
2235 static HRESULT WINAPI ITextSelection_fnCut(ITextSelection *me, VARIANT *pVar)
2237 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2238 if (!This->reOle)
2239 return CO_E_RELEASED;
2241 FIXME("not implemented\n");
2242 return E_NOTIMPL;
2245 static HRESULT WINAPI ITextSelection_fnCopy(ITextSelection *me, VARIANT *pVar)
2247 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2248 if (!This->reOle)
2249 return CO_E_RELEASED;
2251 FIXME("not implemented\n");
2252 return E_NOTIMPL;
2255 static HRESULT WINAPI ITextSelection_fnPaste(ITextSelection *me, VARIANT *pVar, LONG Format)
2257 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2258 if (!This->reOle)
2259 return CO_E_RELEASED;
2261 FIXME("not implemented\n");
2262 return E_NOTIMPL;
2265 static HRESULT WINAPI ITextSelection_fnCanPaste(ITextSelection *me, VARIANT *pVar, LONG Format,
2266 LONG *pb)
2268 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2269 if (!This->reOle)
2270 return CO_E_RELEASED;
2272 FIXME("not implemented\n");
2273 return E_NOTIMPL;
2276 static HRESULT WINAPI ITextSelection_fnCanEdit(ITextSelection *me, LONG *pb)
2278 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2279 if (!This->reOle)
2280 return CO_E_RELEASED;
2282 FIXME("not implemented\n");
2283 return E_NOTIMPL;
2286 static HRESULT WINAPI ITextSelection_fnChangeCase(ITextSelection *me, LONG Type)
2288 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2289 if (!This->reOle)
2290 return CO_E_RELEASED;
2292 FIXME("not implemented\n");
2293 return E_NOTIMPL;
2296 static HRESULT WINAPI ITextSelection_fnGetPoint(ITextSelection *me, LONG Type, LONG *cx, LONG *cy)
2298 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2299 if (!This->reOle)
2300 return CO_E_RELEASED;
2302 FIXME("not implemented\n");
2303 return E_NOTIMPL;
2306 static HRESULT WINAPI ITextSelection_fnSetPoint(ITextSelection *me, LONG x, LONG y, LONG Type,
2307 LONG Extend)
2309 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2310 if (!This->reOle)
2311 return CO_E_RELEASED;
2313 FIXME("not implemented\n");
2314 return E_NOTIMPL;
2317 static HRESULT WINAPI ITextSelection_fnScrollIntoView(ITextSelection *me, LONG Value)
2319 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2320 if (!This->reOle)
2321 return CO_E_RELEASED;
2323 FIXME("not implemented\n");
2324 return E_NOTIMPL;
2327 static HRESULT WINAPI ITextSelection_fnGetEmbeddedObject(ITextSelection *me, IUnknown **ppv)
2329 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2330 if (!This->reOle)
2331 return CO_E_RELEASED;
2333 FIXME("not implemented\n");
2334 return E_NOTIMPL;
2337 /*** ITextSelection methods ***/
2338 static HRESULT WINAPI ITextSelection_fnGetFlags(ITextSelection *me, LONG *pFlags)
2340 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2341 if (!This->reOle)
2342 return CO_E_RELEASED;
2344 FIXME("not implemented\n");
2345 return E_NOTIMPL;
2348 static HRESULT WINAPI ITextSelection_fnSetFlags(ITextSelection *me, LONG Flags)
2350 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2351 if (!This->reOle)
2352 return CO_E_RELEASED;
2354 FIXME("not implemented\n");
2355 return E_NOTIMPL;
2358 static HRESULT WINAPI ITextSelection_fnGetType(ITextSelection *me, LONG *pType)
2360 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2361 if (!This->reOle)
2362 return CO_E_RELEASED;
2364 FIXME("not implemented\n");
2365 return E_NOTIMPL;
2368 static HRESULT WINAPI ITextSelection_fnMoveLeft(ITextSelection *me, LONG Unit, LONG Count,
2369 LONG Extend, LONG *pDelta)
2371 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2372 if (!This->reOle)
2373 return CO_E_RELEASED;
2375 FIXME("not implemented\n");
2376 return E_NOTIMPL;
2379 static HRESULT WINAPI ITextSelection_fnMoveRight(ITextSelection *me, LONG Unit, LONG Count,
2380 LONG Extend, LONG *pDelta)
2382 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2383 if (!This->reOle)
2384 return CO_E_RELEASED;
2386 FIXME("not implemented\n");
2387 return E_NOTIMPL;
2390 static HRESULT WINAPI ITextSelection_fnMoveUp(ITextSelection *me, LONG Unit, LONG Count,
2391 LONG Extend, LONG *pDelta)
2393 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2394 if (!This->reOle)
2395 return CO_E_RELEASED;
2397 FIXME("not implemented\n");
2398 return E_NOTIMPL;
2401 static HRESULT WINAPI ITextSelection_fnMoveDown(ITextSelection *me, LONG Unit, LONG Count,
2402 LONG Extend, LONG *pDelta)
2404 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2405 if (!This->reOle)
2406 return CO_E_RELEASED;
2408 FIXME("not implemented\n");
2409 return E_NOTIMPL;
2412 static HRESULT WINAPI ITextSelection_fnHomeKey(ITextSelection *me, LONG Unit, LONG Extend,
2413 LONG *pDelta)
2415 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2416 if (!This->reOle)
2417 return CO_E_RELEASED;
2419 FIXME("not implemented\n");
2420 return E_NOTIMPL;
2423 static HRESULT WINAPI ITextSelection_fnEndKey(ITextSelection *me, LONG Unit, LONG Extend,
2424 LONG *pDelta)
2426 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2427 if (!This->reOle)
2428 return CO_E_RELEASED;
2430 FIXME("not implemented\n");
2431 return E_NOTIMPL;
2434 static HRESULT WINAPI ITextSelection_fnTypeText(ITextSelection *me, BSTR bstr)
2436 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2437 if (!This->reOle)
2438 return CO_E_RELEASED;
2440 FIXME("not implemented\n");
2441 return E_NOTIMPL;
2444 static const ITextSelectionVtbl tsvt = {
2445 ITextSelection_fnQueryInterface,
2446 ITextSelection_fnAddRef,
2447 ITextSelection_fnRelease,
2448 ITextSelection_fnGetTypeInfoCount,
2449 ITextSelection_fnGetTypeInfo,
2450 ITextSelection_fnGetIDsOfNames,
2451 ITextSelection_fnInvoke,
2452 ITextSelection_fnGetText,
2453 ITextSelection_fnSetText,
2454 ITextSelection_fnGetChar,
2455 ITextSelection_fnSetChar,
2456 ITextSelection_fnGetDuplicate,
2457 ITextSelection_fnGetFormattedText,
2458 ITextSelection_fnSetFormattedText,
2459 ITextSelection_fnGetStart,
2460 ITextSelection_fnSetStart,
2461 ITextSelection_fnGetEnd,
2462 ITextSelection_fnSetEnd,
2463 ITextSelection_fnGetFont,
2464 ITextSelection_fnSetFont,
2465 ITextSelection_fnGetPara,
2466 ITextSelection_fnSetPara,
2467 ITextSelection_fnGetStoryLength,
2468 ITextSelection_fnGetStoryType,
2469 ITextSelection_fnCollapse,
2470 ITextSelection_fnExpand,
2471 ITextSelection_fnGetIndex,
2472 ITextSelection_fnSetIndex,
2473 ITextSelection_fnSetRange,
2474 ITextSelection_fnInRange,
2475 ITextSelection_fnInStory,
2476 ITextSelection_fnIsEqual,
2477 ITextSelection_fnSelect,
2478 ITextSelection_fnStartOf,
2479 ITextSelection_fnEndOf,
2480 ITextSelection_fnMove,
2481 ITextSelection_fnMoveStart,
2482 ITextSelection_fnMoveEnd,
2483 ITextSelection_fnMoveWhile,
2484 ITextSelection_fnMoveStartWhile,
2485 ITextSelection_fnMoveEndWhile,
2486 ITextSelection_fnMoveUntil,
2487 ITextSelection_fnMoveStartUntil,
2488 ITextSelection_fnMoveEndUntil,
2489 ITextSelection_fnFindText,
2490 ITextSelection_fnFindTextStart,
2491 ITextSelection_fnFindTextEnd,
2492 ITextSelection_fnDelete,
2493 ITextSelection_fnCut,
2494 ITextSelection_fnCopy,
2495 ITextSelection_fnPaste,
2496 ITextSelection_fnCanPaste,
2497 ITextSelection_fnCanEdit,
2498 ITextSelection_fnChangeCase,
2499 ITextSelection_fnGetPoint,
2500 ITextSelection_fnSetPoint,
2501 ITextSelection_fnScrollIntoView,
2502 ITextSelection_fnGetEmbeddedObject,
2503 ITextSelection_fnGetFlags,
2504 ITextSelection_fnSetFlags,
2505 ITextSelection_fnGetType,
2506 ITextSelection_fnMoveLeft,
2507 ITextSelection_fnMoveRight,
2508 ITextSelection_fnMoveUp,
2509 ITextSelection_fnMoveDown,
2510 ITextSelection_fnHomeKey,
2511 ITextSelection_fnEndKey,
2512 ITextSelection_fnTypeText
2515 static ITextSelectionImpl *
2516 CreateTextSelection(IRichEditOleImpl *reOle)
2518 ITextSelectionImpl *txtSel = heap_alloc(sizeof *txtSel);
2519 if (!txtSel)
2520 return NULL;
2522 txtSel->ITextSelection_iface.lpVtbl = &tsvt;
2523 txtSel->ref = 1;
2524 txtSel->reOle = reOle;
2525 return txtSel;
2528 LRESULT CreateIRichEditOle(IUnknown *outer_unk, ME_TextEditor *editor, LPVOID *ppvObj)
2530 IRichEditOleImpl *reo;
2532 reo = heap_alloc(sizeof(IRichEditOleImpl));
2533 if (!reo)
2534 return 0;
2536 reo->IUnknown_inner.lpVtbl = &reo_unk_vtbl;
2537 reo->IRichEditOle_iface.lpVtbl = &revt;
2538 reo->ITextDocument_iface.lpVtbl = &tdvt;
2539 reo->ref = 1;
2540 reo->editor = editor;
2541 reo->txtSel = CreateTextSelection(reo);
2542 if (!reo->txtSel)
2544 heap_free(reo);
2545 return 0;
2547 reo->clientSite = CreateOleClientSite(reo);
2548 if (!reo->clientSite)
2550 ITextSelection_Release(&reo->txtSel->ITextSelection_iface);
2551 heap_free(reo);
2552 return 0;
2554 TRACE("Created %p\n",reo);
2555 list_init(&reo->rangelist);
2556 if (outer_unk)
2557 reo->outer_unk = outer_unk;
2558 else
2559 reo->outer_unk = &reo->IUnknown_inner;
2560 *ppvObj = &reo->IRichEditOle_iface;
2562 return 1;
2565 static void convert_sizel(const ME_Context *c, const SIZEL* szl, SIZE* sz)
2567 /* sizel is in .01 millimeters, sz in pixels */
2568 sz->cx = MulDiv(szl->cx, c->dpi.cx, 2540);
2569 sz->cy = MulDiv(szl->cy, c->dpi.cy, 2540);
2572 /******************************************************************************
2573 * ME_GetOLEObjectSize
2575 * Sets run extent for OLE objects.
2577 void ME_GetOLEObjectSize(const ME_Context *c, ME_Run *run, SIZE *pSize)
2579 IDataObject* ido;
2580 FORMATETC fmt;
2581 STGMEDIUM stgm;
2582 DIBSECTION dibsect;
2583 ENHMETAHEADER emh;
2585 assert(run->nFlags & MERF_GRAPHICS);
2586 assert(run->ole_obj);
2588 if (run->ole_obj->sizel.cx != 0 || run->ole_obj->sizel.cy != 0)
2590 convert_sizel(c, &run->ole_obj->sizel, pSize);
2591 if (c->editor->nZoomNumerator != 0)
2593 pSize->cx = MulDiv(pSize->cx, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
2594 pSize->cy = MulDiv(pSize->cy, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
2596 return;
2599 if (IOleObject_QueryInterface(run->ole_obj->poleobj, &IID_IDataObject, (void**)&ido) != S_OK)
2601 FIXME("Query Interface IID_IDataObject failed!\n");
2602 pSize->cx = pSize->cy = 0;
2603 return;
2605 fmt.cfFormat = CF_BITMAP;
2606 fmt.ptd = NULL;
2607 fmt.dwAspect = DVASPECT_CONTENT;
2608 fmt.lindex = -1;
2609 fmt.tymed = TYMED_GDI;
2610 if (IDataObject_GetData(ido, &fmt, &stgm) != S_OK)
2612 fmt.cfFormat = CF_ENHMETAFILE;
2613 fmt.tymed = TYMED_ENHMF;
2614 if (IDataObject_GetData(ido, &fmt, &stgm) != S_OK)
2616 FIXME("unsupported format\n");
2617 pSize->cx = pSize->cy = 0;
2618 IDataObject_Release(ido);
2619 return;
2623 switch (stgm.tymed)
2625 case TYMED_GDI:
2626 GetObjectW(stgm.u.hBitmap, sizeof(dibsect), &dibsect);
2627 pSize->cx = dibsect.dsBm.bmWidth;
2628 pSize->cy = dibsect.dsBm.bmHeight;
2629 if (!stgm.pUnkForRelease) DeleteObject(stgm.u.hBitmap);
2630 break;
2631 case TYMED_ENHMF:
2632 GetEnhMetaFileHeader(stgm.u.hEnhMetaFile, sizeof(emh), &emh);
2633 pSize->cx = emh.rclBounds.right - emh.rclBounds.left;
2634 pSize->cy = emh.rclBounds.bottom - emh.rclBounds.top;
2635 if (!stgm.pUnkForRelease) DeleteEnhMetaFile(stgm.u.hEnhMetaFile);
2636 break;
2637 default:
2638 FIXME("Unsupported tymed %d\n", stgm.tymed);
2639 break;
2641 IDataObject_Release(ido);
2642 if (c->editor->nZoomNumerator != 0)
2644 pSize->cx = MulDiv(pSize->cx, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
2645 pSize->cy = MulDiv(pSize->cy, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
2649 void ME_DrawOLE(ME_Context *c, int x, int y, ME_Run *run,
2650 ME_Paragraph *para, BOOL selected)
2652 IDataObject* ido;
2653 FORMATETC fmt;
2654 STGMEDIUM stgm;
2655 DIBSECTION dibsect;
2656 ENHMETAHEADER emh;
2657 HDC hMemDC;
2658 SIZE sz;
2659 BOOL has_size;
2661 assert(run->nFlags & MERF_GRAPHICS);
2662 assert(run->ole_obj);
2663 if (IOleObject_QueryInterface(run->ole_obj->poleobj, &IID_IDataObject, (void**)&ido) != S_OK)
2665 FIXME("Couldn't get interface\n");
2666 return;
2668 has_size = run->ole_obj->sizel.cx != 0 || run->ole_obj->sizel.cy != 0;
2669 fmt.cfFormat = CF_BITMAP;
2670 fmt.ptd = NULL;
2671 fmt.dwAspect = DVASPECT_CONTENT;
2672 fmt.lindex = -1;
2673 fmt.tymed = TYMED_GDI;
2674 if (IDataObject_GetData(ido, &fmt, &stgm) != S_OK)
2676 fmt.cfFormat = CF_ENHMETAFILE;
2677 fmt.tymed = TYMED_ENHMF;
2678 if (IDataObject_GetData(ido, &fmt, &stgm) != S_OK)
2680 FIXME("Couldn't get storage medium\n");
2681 IDataObject_Release(ido);
2682 return;
2685 switch (stgm.tymed)
2687 case TYMED_GDI:
2688 GetObjectW(stgm.u.hBitmap, sizeof(dibsect), &dibsect);
2689 hMemDC = CreateCompatibleDC(c->hDC);
2690 SelectObject(hMemDC, stgm.u.hBitmap);
2691 if (has_size)
2693 convert_sizel(c, &run->ole_obj->sizel, &sz);
2694 } else {
2695 sz.cx = MulDiv(dibsect.dsBm.bmWidth, c->dpi.cx, 96);
2696 sz.cy = MulDiv(dibsect.dsBm.bmHeight, c->dpi.cy, 96);
2698 if (c->editor->nZoomNumerator != 0)
2700 sz.cx = MulDiv(sz.cx, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
2701 sz.cy = MulDiv(sz.cy, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
2703 if (sz.cx == dibsect.dsBm.bmWidth && sz.cy == dibsect.dsBm.bmHeight)
2705 BitBlt(c->hDC, x, y - sz.cy,
2706 dibsect.dsBm.bmWidth, dibsect.dsBm.bmHeight,
2707 hMemDC, 0, 0, SRCCOPY);
2708 } else {
2709 StretchBlt(c->hDC, x, y - sz.cy, sz.cx, sz.cy,
2710 hMemDC, 0, 0, dibsect.dsBm.bmWidth,
2711 dibsect.dsBm.bmHeight, SRCCOPY);
2713 DeleteDC(hMemDC);
2714 if (!stgm.pUnkForRelease) DeleteObject(stgm.u.hBitmap);
2715 break;
2716 case TYMED_ENHMF:
2717 GetEnhMetaFileHeader(stgm.u.hEnhMetaFile, sizeof(emh), &emh);
2718 if (has_size)
2720 convert_sizel(c, &run->ole_obj->sizel, &sz);
2721 } else {
2722 sz.cy = MulDiv(emh.rclBounds.bottom - emh.rclBounds.top, c->dpi.cx, 96);
2723 sz.cx = MulDiv(emh.rclBounds.right - emh.rclBounds.left, c->dpi.cy, 96);
2725 if (c->editor->nZoomNumerator != 0)
2727 sz.cx = MulDiv(sz.cx, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
2728 sz.cy = MulDiv(sz.cy, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
2732 RECT rc;
2734 rc.left = x;
2735 rc.top = y - sz.cy;
2736 rc.right = x + sz.cx;
2737 rc.bottom = y;
2738 PlayEnhMetaFile(c->hDC, stgm.u.hEnhMetaFile, &rc);
2740 if (!stgm.pUnkForRelease) DeleteEnhMetaFile(stgm.u.hEnhMetaFile);
2741 break;
2742 default:
2743 FIXME("Unsupported tymed %d\n", stgm.tymed);
2744 selected = FALSE;
2745 break;
2747 if (selected && !c->editor->bHideSelection)
2748 PatBlt(c->hDC, x, y - sz.cy, sz.cx, sz.cy, DSTINVERT);
2749 IDataObject_Release(ido);
2752 void ME_DeleteReObject(REOBJECT* reo)
2754 if (reo->poleobj) IOleObject_Release(reo->poleobj);
2755 if (reo->pstg) IStorage_Release(reo->pstg);
2756 if (reo->polesite) IOleClientSite_Release(reo->polesite);
2757 FREE_OBJ(reo);
2760 void ME_CopyReObject(REOBJECT* dst, const REOBJECT* src)
2762 *dst = *src;
2764 if (dst->poleobj) IOleObject_AddRef(dst->poleobj);
2765 if (dst->pstg) IStorage_AddRef(dst->pstg);
2766 if (dst->polesite) IOleClientSite_AddRef(dst->polesite);
2769 void ME_GetITextDocumentInterface(IRichEditOle *iface, LPVOID *ppvObj)
2771 IRichEditOleImpl *This = impl_from_IRichEditOle(iface);
2772 *ppvObj = &This->ITextDocument_iface;