urlmon: Implement TYMED_HGLOBAL case for CopyStgMedium.
[wine/multimedia.git] / dlls / riched20 / richole.c
blob9c74cfe474647e3fbc6ea4f98ac7b40208c4c2d9
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;
53 typedef struct IRichEditOleImpl {
54 IRichEditOle IRichEditOle_iface;
55 ITextDocument ITextDocument_iface;
56 LONG ref;
58 ME_TextEditor *editor;
59 ITextSelectionImpl *txtSel;
60 IOleClientSiteImpl *clientSite;
61 } IRichEditOleImpl;
63 struct ITextSelectionImpl {
64 ITextSelection ITextSelection_iface;
65 LONG ref;
67 IRichEditOleImpl *reOle;
70 struct IOleClientSiteImpl {
71 IOleClientSite IOleClientSite_iface;
72 LONG ref;
74 IRichEditOleImpl *reOle;
77 static inline IRichEditOleImpl *impl_from_IRichEditOle(IRichEditOle *iface)
79 return CONTAINING_RECORD(iface, IRichEditOleImpl, IRichEditOle_iface);
82 static inline IRichEditOleImpl *impl_from_ITextDocument(ITextDocument *iface)
84 return CONTAINING_RECORD(iface, IRichEditOleImpl, ITextDocument_iface);
87 static HRESULT WINAPI
88 IRichEditOle_fnQueryInterface(IRichEditOle *me, REFIID riid, LPVOID *ppvObj)
90 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
92 TRACE("%p %s\n", This, debugstr_guid(riid) );
94 *ppvObj = NULL;
95 if (IsEqualGUID(riid, &IID_IUnknown) ||
96 IsEqualGUID(riid, &IID_IRichEditOle))
97 *ppvObj = &This->IRichEditOle_iface;
98 else if (IsEqualGUID(riid, &IID_ITextDocument))
99 *ppvObj = &This->ITextDocument_iface;
100 if (*ppvObj)
102 IRichEditOle_AddRef(me);
103 return S_OK;
105 FIXME("%p: unhandled interface %s\n", This, debugstr_guid(riid) );
107 return E_NOINTERFACE;
110 static ULONG WINAPI
111 IRichEditOle_fnAddRef(IRichEditOle *me)
113 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
114 ULONG ref = InterlockedIncrement( &This->ref );
116 TRACE("%p ref = %u\n", This, ref);
118 return ref;
121 static ULONG WINAPI
122 IRichEditOle_fnRelease(IRichEditOle *me)
124 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
125 ULONG ref = InterlockedDecrement(&This->ref);
127 TRACE ("%p ref=%u\n", This, ref);
129 if (!ref)
131 TRACE ("Destroying %p\n", This);
132 This->txtSel->reOle = NULL;
133 ITextSelection_Release(&This->txtSel->ITextSelection_iface);
134 IOleClientSite_Release(&This->clientSite->IOleClientSite_iface);
135 heap_free(This);
137 return ref;
140 static HRESULT WINAPI
141 IRichEditOle_fnActivateAs(IRichEditOle *me, REFCLSID rclsid, REFCLSID rclsidAs)
143 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
144 FIXME("stub %p\n",This);
145 return E_NOTIMPL;
148 static HRESULT WINAPI
149 IRichEditOle_fnContextSensitiveHelp(IRichEditOle *me, BOOL fEnterMode)
151 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
152 FIXME("stub %p\n",This);
153 return E_NOTIMPL;
156 static HRESULT WINAPI
157 IRichEditOle_fnConvertObject(IRichEditOle *me, LONG iob,
158 REFCLSID rclsidNew, LPCSTR lpstrUserTypeNew)
160 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
161 FIXME("stub %p\n",This);
162 return E_NOTIMPL;
165 static inline IOleClientSiteImpl *impl_from_IOleClientSite(IOleClientSite *iface)
167 return CONTAINING_RECORD(iface, IOleClientSiteImpl, IOleClientSite_iface);
170 static HRESULT WINAPI
171 IOleClientSite_fnQueryInterface(IOleClientSite *me, REFIID riid, LPVOID *ppvObj)
173 TRACE("%p %s\n", me, debugstr_guid(riid) );
175 *ppvObj = NULL;
176 if (IsEqualGUID(riid, &IID_IUnknown) ||
177 IsEqualGUID(riid, &IID_IOleClientSite))
178 *ppvObj = me;
179 if (*ppvObj)
181 IOleClientSite_AddRef(me);
182 return S_OK;
184 FIXME("%p: unhandled interface %s\n", me, debugstr_guid(riid) );
186 return E_NOINTERFACE;
189 static ULONG WINAPI IOleClientSite_fnAddRef(IOleClientSite *iface)
191 IOleClientSiteImpl *This = impl_from_IOleClientSite(iface);
192 return InterlockedIncrement(&This->ref);
195 static ULONG WINAPI IOleClientSite_fnRelease(IOleClientSite *iface)
197 IOleClientSiteImpl *This = impl_from_IOleClientSite(iface);
198 ULONG ref = InterlockedDecrement(&This->ref);
199 if (ref == 0)
200 heap_free(This);
201 return ref;
204 static HRESULT WINAPI IOleClientSite_fnSaveObject(IOleClientSite *iface)
206 IOleClientSiteImpl *This = impl_from_IOleClientSite(iface);
207 if (!This->reOle)
208 return CO_E_RELEASED;
210 FIXME("stub %p\n", iface);
211 return E_NOTIMPL;
215 static HRESULT WINAPI IOleClientSite_fnGetMoniker(IOleClientSite *iface, DWORD dwAssign,
216 DWORD dwWhichMoniker, IMoniker **ppmk)
218 IOleClientSiteImpl *This = impl_from_IOleClientSite(iface);
219 if (!This->reOle)
220 return CO_E_RELEASED;
222 FIXME("stub %p\n", iface);
223 return E_NOTIMPL;
226 static HRESULT WINAPI IOleClientSite_fnGetContainer(IOleClientSite *iface,
227 IOleContainer **ppContainer)
229 IOleClientSiteImpl *This = impl_from_IOleClientSite(iface);
230 if (!This->reOle)
231 return CO_E_RELEASED;
233 FIXME("stub %p\n", iface);
234 return E_NOTIMPL;
237 static HRESULT WINAPI IOleClientSite_fnShowObject(IOleClientSite *iface)
239 IOleClientSiteImpl *This = impl_from_IOleClientSite(iface);
240 if (!This->reOle)
241 return CO_E_RELEASED;
243 FIXME("stub %p\n", iface);
244 return E_NOTIMPL;
247 static HRESULT WINAPI IOleClientSite_fnOnShowWindow(IOleClientSite *iface, BOOL fShow)
249 IOleClientSiteImpl *This = impl_from_IOleClientSite(iface);
250 if (!This->reOle)
251 return CO_E_RELEASED;
253 FIXME("stub %p\n", iface);
254 return E_NOTIMPL;
257 static HRESULT WINAPI IOleClientSite_fnRequestNewObjectLayout(IOleClientSite *iface)
259 IOleClientSiteImpl *This = impl_from_IOleClientSite(iface);
260 if (!This->reOle)
261 return CO_E_RELEASED;
263 FIXME("stub %p\n", iface);
264 return E_NOTIMPL;
267 static const IOleClientSiteVtbl ocst = {
268 IOleClientSite_fnQueryInterface,
269 IOleClientSite_fnAddRef,
270 IOleClientSite_fnRelease,
271 IOleClientSite_fnSaveObject,
272 IOleClientSite_fnGetMoniker,
273 IOleClientSite_fnGetContainer,
274 IOleClientSite_fnShowObject,
275 IOleClientSite_fnOnShowWindow,
276 IOleClientSite_fnRequestNewObjectLayout
279 static IOleClientSiteImpl *
280 CreateOleClientSite(IRichEditOleImpl *reOle)
282 IOleClientSiteImpl *clientSite = heap_alloc(sizeof *clientSite);
283 if (!clientSite)
284 return NULL;
286 clientSite->IOleClientSite_iface.lpVtbl = &ocst;
287 clientSite->ref = 1;
288 clientSite->reOle = reOle;
289 return clientSite;
292 static HRESULT WINAPI
293 IRichEditOle_fnGetClientSite(IRichEditOle *me,
294 LPOLECLIENTSITE *lplpolesite)
296 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
298 TRACE("%p,%p\n",This, lplpolesite);
300 if(!lplpolesite)
301 return E_INVALIDARG;
302 *lplpolesite = &This->clientSite->IOleClientSite_iface;
303 IOleClientSite_fnAddRef(*lplpolesite);
304 return S_OK;
307 static HRESULT WINAPI
308 IRichEditOle_fnGetClipboardData(IRichEditOle *me, CHARRANGE *lpchrg,
309 DWORD reco, LPDATAOBJECT *lplpdataobj)
311 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
312 ME_Cursor start;
313 int nChars;
315 TRACE("(%p,%p,%d)\n",This, lpchrg, reco);
316 if(!lplpdataobj)
317 return E_INVALIDARG;
318 if(!lpchrg) {
319 int nFrom, nTo, nStartCur = ME_GetSelectionOfs(This->editor, &nFrom, &nTo);
320 start = This->editor->pCursors[nStartCur];
321 nChars = nTo - nFrom;
322 } else {
323 ME_CursorFromCharOfs(This->editor, lpchrg->cpMin, &start);
324 nChars = lpchrg->cpMax - lpchrg->cpMin;
326 return ME_GetDataObject(This->editor, &start, nChars, lplpdataobj);
329 static LONG WINAPI IRichEditOle_fnGetLinkCount(IRichEditOle *me)
331 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
332 FIXME("stub %p\n",This);
333 return E_NOTIMPL;
336 static HRESULT WINAPI
337 IRichEditOle_fnGetObject(IRichEditOle *me, LONG iob,
338 REOBJECT *lpreobject, DWORD dwFlags)
340 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
341 FIXME("stub %p\n",This);
342 return E_NOTIMPL;
345 static LONG WINAPI
346 IRichEditOle_fnGetObjectCount(IRichEditOle *me)
348 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
349 FIXME("stub %p\n",This);
350 return 0;
353 static HRESULT WINAPI
354 IRichEditOle_fnHandsOffStorage(IRichEditOle *me, LONG iob)
356 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
357 FIXME("stub %p\n",This);
358 return E_NOTIMPL;
361 static HRESULT WINAPI
362 IRichEditOle_fnImportDataObject(IRichEditOle *me, LPDATAOBJECT lpdataobj,
363 CLIPFORMAT cf, HGLOBAL hMetaPict)
365 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
366 FIXME("stub %p\n",This);
367 return E_NOTIMPL;
370 static HRESULT WINAPI
371 IRichEditOle_fnInPlaceDeactivate(IRichEditOle *me)
373 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
374 FIXME("stub %p\n",This);
375 return E_NOTIMPL;
378 static HRESULT WINAPI
379 IRichEditOle_fnInsertObject(IRichEditOle *me, REOBJECT *reo)
381 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
382 TRACE("(%p,%p)\n", This, reo);
384 if (reo->cbStruct < sizeof(*reo)) return STG_E_INVALIDPARAMETER;
386 ME_InsertOLEFromCursor(This->editor, reo, 0);
387 ME_CommitUndo(This->editor);
388 ME_UpdateRepaint(This->editor, FALSE);
389 return S_OK;
392 static HRESULT WINAPI IRichEditOle_fnSaveCompleted(IRichEditOle *me, LONG iob,
393 LPSTORAGE lpstg)
395 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
396 FIXME("stub %p\n",This);
397 return E_NOTIMPL;
400 static HRESULT WINAPI
401 IRichEditOle_fnSetDvaspect(IRichEditOle *me, LONG iob, DWORD dvaspect)
403 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
404 FIXME("stub %p\n",This);
405 return E_NOTIMPL;
408 static HRESULT WINAPI IRichEditOle_fnSetHostNames(IRichEditOle *me,
409 LPCSTR lpstrContainerApp, LPCSTR lpstrContainerObj)
411 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
412 FIXME("stub %p %s %s\n",This, lpstrContainerApp, lpstrContainerObj);
413 return E_NOTIMPL;
416 static HRESULT WINAPI
417 IRichEditOle_fnSetLinkAvailable(IRichEditOle *me, LONG iob, BOOL fAvailable)
419 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
420 FIXME("stub %p\n",This);
421 return E_NOTIMPL;
424 static const IRichEditOleVtbl revt = {
425 IRichEditOle_fnQueryInterface,
426 IRichEditOle_fnAddRef,
427 IRichEditOle_fnRelease,
428 IRichEditOle_fnGetClientSite,
429 IRichEditOle_fnGetObjectCount,
430 IRichEditOle_fnGetLinkCount,
431 IRichEditOle_fnGetObject,
432 IRichEditOle_fnInsertObject,
433 IRichEditOle_fnConvertObject,
434 IRichEditOle_fnActivateAs,
435 IRichEditOle_fnSetHostNames,
436 IRichEditOle_fnSetLinkAvailable,
437 IRichEditOle_fnSetDvaspect,
438 IRichEditOle_fnHandsOffStorage,
439 IRichEditOle_fnSaveCompleted,
440 IRichEditOle_fnInPlaceDeactivate,
441 IRichEditOle_fnContextSensitiveHelp,
442 IRichEditOle_fnGetClipboardData,
443 IRichEditOle_fnImportDataObject
446 static HRESULT WINAPI
447 ITextDocument_fnQueryInterface(ITextDocument* me, REFIID riid,
448 void** ppvObject)
450 IRichEditOleImpl *This = impl_from_ITextDocument(me);
451 return IRichEditOle_fnQueryInterface(&This->IRichEditOle_iface, riid, ppvObject);
454 static ULONG WINAPI
455 ITextDocument_fnAddRef(ITextDocument* me)
457 IRichEditOleImpl *This = impl_from_ITextDocument(me);
458 return IRichEditOle_fnAddRef(&This->IRichEditOle_iface);
461 static ULONG WINAPI
462 ITextDocument_fnRelease(ITextDocument* me)
464 IRichEditOleImpl *This = impl_from_ITextDocument(me);
465 return IRichEditOle_fnRelease(&This->IRichEditOle_iface);
468 static HRESULT WINAPI
469 ITextDocument_fnGetTypeInfoCount(ITextDocument* me,
470 UINT* pctinfo)
472 IRichEditOleImpl *This = impl_from_ITextDocument(me);
473 FIXME("stub %p\n",This);
474 return E_NOTIMPL;
477 static HRESULT WINAPI
478 ITextDocument_fnGetTypeInfo(ITextDocument* me, UINT iTInfo, LCID lcid,
479 ITypeInfo** ppTInfo)
481 IRichEditOleImpl *This = impl_from_ITextDocument(me);
482 FIXME("stub %p\n",This);
483 return E_NOTIMPL;
486 static HRESULT WINAPI
487 ITextDocument_fnGetIDsOfNames(ITextDocument* me, REFIID riid,
488 LPOLESTR* rgszNames, UINT cNames, LCID lcid, DISPID* rgDispId)
490 IRichEditOleImpl *This = impl_from_ITextDocument(me);
491 FIXME("stub %p\n",This);
492 return E_NOTIMPL;
495 static HRESULT WINAPI
496 ITextDocument_fnInvoke(ITextDocument* me, DISPID dispIdMember,
497 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS* pDispParams,
498 VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr)
500 IRichEditOleImpl *This = impl_from_ITextDocument(me);
501 FIXME("stub %p\n",This);
502 return E_NOTIMPL;
505 static HRESULT WINAPI
506 ITextDocument_fnGetName(ITextDocument* me, BSTR* pName)
508 IRichEditOleImpl *This = impl_from_ITextDocument(me);
509 FIXME("stub %p\n",This);
510 return E_NOTIMPL;
513 static HRESULT WINAPI
514 ITextDocument_fnGetSelection(ITextDocument* me, ITextSelection** ppSel)
516 IRichEditOleImpl *This = impl_from_ITextDocument(me);
517 TRACE("(%p)\n", me);
518 *ppSel = &This->txtSel->ITextSelection_iface;
519 ITextSelection_AddRef(*ppSel);
520 return S_OK;
523 static HRESULT WINAPI
524 ITextDocument_fnGetStoryCount(ITextDocument* me, LONG* pCount)
526 IRichEditOleImpl *This = impl_from_ITextDocument(me);
527 FIXME("stub %p\n",This);
528 return E_NOTIMPL;
531 static HRESULT WINAPI
532 ITextDocument_fnGetStoryRanges(ITextDocument* me,
533 ITextStoryRanges** ppStories)
535 IRichEditOleImpl *This = impl_from_ITextDocument(me);
536 FIXME("stub %p\n",This);
537 return E_NOTIMPL;
540 static HRESULT WINAPI
541 ITextDocument_fnGetSaved(ITextDocument* me, LONG* pValue)
543 IRichEditOleImpl *This = impl_from_ITextDocument(me);
544 FIXME("stub %p\n",This);
545 return E_NOTIMPL;
548 static HRESULT WINAPI
549 ITextDocument_fnSetSaved(ITextDocument* me, LONG Value)
551 IRichEditOleImpl *This = impl_from_ITextDocument(me);
552 FIXME("stub %p\n",This);
553 return E_NOTIMPL;
556 static HRESULT WINAPI
557 ITextDocument_fnGetDefaultTabStop(ITextDocument* me, float* pValue)
559 IRichEditOleImpl *This = impl_from_ITextDocument(me);
560 FIXME("stub %p\n",This);
561 return E_NOTIMPL;
564 static HRESULT WINAPI
565 ITextDocument_fnSetDefaultTabStop(ITextDocument* me, float Value)
567 IRichEditOleImpl *This = impl_from_ITextDocument(me);
568 FIXME("stub %p\n",This);
569 return E_NOTIMPL;
572 static HRESULT WINAPI
573 ITextDocument_fnNew(ITextDocument* me)
575 IRichEditOleImpl *This = impl_from_ITextDocument(me);
576 FIXME("stub %p\n",This);
577 return E_NOTIMPL;
580 static HRESULT WINAPI
581 ITextDocument_fnOpen(ITextDocument* me, VARIANT* pVar, LONG Flags,
582 LONG CodePage)
584 IRichEditOleImpl *This = impl_from_ITextDocument(me);
585 FIXME("stub %p\n",This);
586 return E_NOTIMPL;
589 static HRESULT WINAPI
590 ITextDocument_fnSave(ITextDocument* me, VARIANT* pVar, LONG Flags,
591 LONG CodePage)
593 IRichEditOleImpl *This = impl_from_ITextDocument(me);
594 FIXME("stub %p\n",This);
595 return E_NOTIMPL;
598 static HRESULT WINAPI
599 ITextDocument_fnFreeze(ITextDocument* me, LONG* pCount)
601 IRichEditOleImpl *This = impl_from_ITextDocument(me);
602 FIXME("stub %p\n",This);
603 return E_NOTIMPL;
606 static HRESULT WINAPI
607 ITextDocument_fnUnfreeze(ITextDocument* me, LONG* pCount)
609 IRichEditOleImpl *This = impl_from_ITextDocument(me);
610 FIXME("stub %p\n",This);
611 return E_NOTIMPL;
614 static HRESULT WINAPI
615 ITextDocument_fnBeginEditCollection(ITextDocument* me)
617 IRichEditOleImpl *This = impl_from_ITextDocument(me);
618 FIXME("stub %p\n",This);
619 return E_NOTIMPL;
622 static HRESULT WINAPI
623 ITextDocument_fnEndEditCollection(ITextDocument* me)
625 IRichEditOleImpl *This = impl_from_ITextDocument(me);
626 FIXME("stub %p\n",This);
627 return E_NOTIMPL;
630 static HRESULT WINAPI
631 ITextDocument_fnUndo(ITextDocument* me, LONG Count, LONG* prop)
633 IRichEditOleImpl *This = impl_from_ITextDocument(me);
634 FIXME("stub %p\n",This);
635 return E_NOTIMPL;
638 static HRESULT WINAPI
639 ITextDocument_fnRedo(ITextDocument* me, LONG Count, LONG* prop)
641 IRichEditOleImpl *This = impl_from_ITextDocument(me);
642 FIXME("stub %p\n",This);
643 return E_NOTIMPL;
646 static HRESULT WINAPI
647 ITextDocument_fnRange(ITextDocument* me, LONG cp1, LONG cp2,
648 ITextRange** ppRange)
650 IRichEditOleImpl *This = impl_from_ITextDocument(me);
651 FIXME("stub %p\n",This);
652 return E_NOTIMPL;
655 static HRESULT WINAPI
656 ITextDocument_fnRangeFromPoint(ITextDocument* me, LONG x, LONG y,
657 ITextRange** ppRange)
659 IRichEditOleImpl *This = impl_from_ITextDocument(me);
660 FIXME("stub %p\n",This);
661 return E_NOTIMPL;
664 static const ITextDocumentVtbl tdvt = {
665 ITextDocument_fnQueryInterface,
666 ITextDocument_fnAddRef,
667 ITextDocument_fnRelease,
668 ITextDocument_fnGetTypeInfoCount,
669 ITextDocument_fnGetTypeInfo,
670 ITextDocument_fnGetIDsOfNames,
671 ITextDocument_fnInvoke,
672 ITextDocument_fnGetName,
673 ITextDocument_fnGetSelection,
674 ITextDocument_fnGetStoryCount,
675 ITextDocument_fnGetStoryRanges,
676 ITextDocument_fnGetSaved,
677 ITextDocument_fnSetSaved,
678 ITextDocument_fnGetDefaultTabStop,
679 ITextDocument_fnSetDefaultTabStop,
680 ITextDocument_fnNew,
681 ITextDocument_fnOpen,
682 ITextDocument_fnSave,
683 ITextDocument_fnFreeze,
684 ITextDocument_fnUnfreeze,
685 ITextDocument_fnBeginEditCollection,
686 ITextDocument_fnEndEditCollection,
687 ITextDocument_fnUndo,
688 ITextDocument_fnRedo,
689 ITextDocument_fnRange,
690 ITextDocument_fnRangeFromPoint
693 static inline ITextSelectionImpl *impl_from_ITextSelection(ITextSelection *iface)
695 return CONTAINING_RECORD(iface, ITextSelectionImpl, ITextSelection_iface);
698 static HRESULT WINAPI ITextSelection_fnQueryInterface(
699 ITextSelection *me,
700 REFIID riid,
701 void **ppvObj)
703 *ppvObj = NULL;
704 if (IsEqualGUID(riid, &IID_IUnknown)
705 || IsEqualGUID(riid, &IID_IDispatch)
706 || IsEqualGUID(riid, &IID_ITextRange)
707 || IsEqualGUID(riid, &IID_ITextSelection))
709 *ppvObj = me;
710 ITextSelection_AddRef(me);
711 return S_OK;
714 return E_NOINTERFACE;
717 static ULONG WINAPI ITextSelection_fnAddRef(ITextSelection *me)
719 ITextSelectionImpl *This = impl_from_ITextSelection(me);
720 return InterlockedIncrement(&This->ref);
723 static ULONG WINAPI ITextSelection_fnRelease(ITextSelection *me)
725 ITextSelectionImpl *This = impl_from_ITextSelection(me);
726 ULONG ref = InterlockedDecrement(&This->ref);
727 if (ref == 0)
728 heap_free(This);
729 return ref;
732 static HRESULT WINAPI ITextSelection_fnGetTypeInfoCount(ITextSelection *me, UINT *pctinfo)
734 ITextSelectionImpl *This = impl_from_ITextSelection(me);
735 if (!This->reOle)
736 return CO_E_RELEASED;
738 FIXME("not implemented\n");
739 return E_NOTIMPL;
742 static HRESULT WINAPI ITextSelection_fnGetTypeInfo(ITextSelection *me, UINT iTInfo, LCID lcid,
743 ITypeInfo **ppTInfo)
745 ITextSelectionImpl *This = impl_from_ITextSelection(me);
746 if (!This->reOle)
747 return CO_E_RELEASED;
749 FIXME("not implemented\n");
750 return E_NOTIMPL;
753 static HRESULT WINAPI ITextSelection_fnGetIDsOfNames(ITextSelection *me, REFIID riid,
754 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
756 ITextSelectionImpl *This = impl_from_ITextSelection(me);
757 if (!This->reOle)
758 return CO_E_RELEASED;
760 FIXME("not implemented\n");
761 return E_NOTIMPL;
764 static HRESULT WINAPI ITextSelection_fnInvoke(
765 ITextSelection *me,
766 DISPID dispIdMember,
767 REFIID riid,
768 LCID lcid,
769 WORD wFlags,
770 DISPPARAMS *pDispParams,
771 VARIANT *pVarResult,
772 EXCEPINFO *pExcepInfo,
773 UINT *puArgErr)
775 FIXME("not implemented\n");
776 return E_NOTIMPL;
779 /*** ITextRange methods ***/
780 static HRESULT WINAPI ITextSelection_fnGetText(ITextSelection *me, BSTR *pbstr)
782 ITextSelectionImpl *This = impl_from_ITextSelection(me);
783 if (!This->reOle)
784 return CO_E_RELEASED;
786 FIXME("not implemented\n");
787 return E_NOTIMPL;
790 static HRESULT WINAPI ITextSelection_fnSetText(ITextSelection *me, BSTR bstr)
792 ITextSelectionImpl *This = impl_from_ITextSelection(me);
793 if (!This->reOle)
794 return CO_E_RELEASED;
796 FIXME("not implemented\n");
797 return E_NOTIMPL;
800 static HRESULT WINAPI ITextSelection_fnGetChar(ITextSelection *me, LONG *pch)
802 ITextSelectionImpl *This = impl_from_ITextSelection(me);
803 if (!This->reOle)
804 return CO_E_RELEASED;
806 FIXME("not implemented\n");
807 return E_NOTIMPL;
810 static HRESULT WINAPI ITextSelection_fnSetChar(ITextSelection *me, LONG ch)
812 ITextSelectionImpl *This = impl_from_ITextSelection(me);
813 if (!This->reOle)
814 return CO_E_RELEASED;
816 FIXME("not implemented\n");
817 return E_NOTIMPL;
820 static HRESULT WINAPI ITextSelection_fnGetDuplicate(ITextSelection *me, ITextRange **ppRange)
822 ITextSelectionImpl *This = impl_from_ITextSelection(me);
823 if (!This->reOle)
824 return CO_E_RELEASED;
826 FIXME("not implemented\n");
827 return E_NOTIMPL;
830 static HRESULT WINAPI ITextSelection_fnGetFormattedText(ITextSelection *me, ITextRange **ppRange)
832 ITextSelectionImpl *This = impl_from_ITextSelection(me);
833 if (!This->reOle)
834 return CO_E_RELEASED;
836 FIXME("not implemented\n");
837 return E_NOTIMPL;
840 static HRESULT WINAPI ITextSelection_fnSetFormattedText(ITextSelection *me, ITextRange *pRange)
842 ITextSelectionImpl *This = impl_from_ITextSelection(me);
843 if (!This->reOle)
844 return CO_E_RELEASED;
846 FIXME("not implemented\n");
847 return E_NOTIMPL;
850 static HRESULT WINAPI ITextSelection_fnGetStart(ITextSelection *me, LONG *pcpFirst)
852 ITextSelectionImpl *This = impl_from_ITextSelection(me);
853 if (!This->reOle)
854 return CO_E_RELEASED;
856 FIXME("not implemented\n");
857 return E_NOTIMPL;
860 static HRESULT WINAPI ITextSelection_fnSetStart(ITextSelection *me, LONG cpFirst)
862 ITextSelectionImpl *This = impl_from_ITextSelection(me);
863 if (!This->reOle)
864 return CO_E_RELEASED;
866 FIXME("not implemented\n");
867 return E_NOTIMPL;
870 static HRESULT WINAPI ITextSelection_fnGetEnd(ITextSelection *me, LONG *pcpLim)
872 ITextSelectionImpl *This = impl_from_ITextSelection(me);
873 if (!This->reOle)
874 return CO_E_RELEASED;
876 FIXME("not implemented\n");
877 return E_NOTIMPL;
880 static HRESULT WINAPI ITextSelection_fnSetEnd(ITextSelection *me, LONG cpLim)
882 ITextSelectionImpl *This = impl_from_ITextSelection(me);
883 if (!This->reOle)
884 return CO_E_RELEASED;
886 FIXME("not implemented\n");
887 return E_NOTIMPL;
890 static HRESULT WINAPI ITextSelection_fnGetFont(ITextSelection *me, ITextFont **pFont)
892 ITextSelectionImpl *This = impl_from_ITextSelection(me);
893 if (!This->reOle)
894 return CO_E_RELEASED;
896 FIXME("not implemented\n");
897 return E_NOTIMPL;
900 static HRESULT WINAPI ITextSelection_fnSetFont(ITextSelection *me, ITextFont *pFont)
902 ITextSelectionImpl *This = impl_from_ITextSelection(me);
903 if (!This->reOle)
904 return CO_E_RELEASED;
906 FIXME("not implemented\n");
907 return E_NOTIMPL;
910 static HRESULT WINAPI ITextSelection_fnGetPara(ITextSelection *me, ITextPara **ppPara)
912 ITextSelectionImpl *This = impl_from_ITextSelection(me);
913 if (!This->reOle)
914 return CO_E_RELEASED;
916 FIXME("not implemented\n");
917 return E_NOTIMPL;
920 static HRESULT WINAPI ITextSelection_fnSetPara(ITextSelection *me, ITextPara *pPara)
922 ITextSelectionImpl *This = impl_from_ITextSelection(me);
923 if (!This->reOle)
924 return CO_E_RELEASED;
926 FIXME("not implemented\n");
927 return E_NOTIMPL;
930 static HRESULT WINAPI ITextSelection_fnGetStoryLength(ITextSelection *me, LONG *pcch)
932 ITextSelectionImpl *This = impl_from_ITextSelection(me);
933 if (!This->reOle)
934 return CO_E_RELEASED;
936 FIXME("not implemented\n");
937 return E_NOTIMPL;
940 static HRESULT WINAPI ITextSelection_fnGetStoryType(ITextSelection *me, LONG *pValue)
942 ITextSelectionImpl *This = impl_from_ITextSelection(me);
943 if (!This->reOle)
944 return CO_E_RELEASED;
946 FIXME("not implemented\n");
947 return E_NOTIMPL;
950 static HRESULT WINAPI ITextSelection_fnCollapse(ITextSelection *me, LONG bStart)
952 ITextSelectionImpl *This = impl_from_ITextSelection(me);
953 if (!This->reOle)
954 return CO_E_RELEASED;
956 FIXME("not implemented\n");
957 return E_NOTIMPL;
960 static HRESULT WINAPI ITextSelection_fnExpand(ITextSelection *me, LONG Unit, LONG *pDelta)
962 ITextSelectionImpl *This = impl_from_ITextSelection(me);
963 if (!This->reOle)
964 return CO_E_RELEASED;
966 FIXME("not implemented\n");
967 return E_NOTIMPL;
970 static HRESULT WINAPI ITextSelection_fnGetIndex(ITextSelection *me, LONG Unit, LONG *pIndex)
972 ITextSelectionImpl *This = impl_from_ITextSelection(me);
973 if (!This->reOle)
974 return CO_E_RELEASED;
976 FIXME("not implemented\n");
977 return E_NOTIMPL;
980 static HRESULT WINAPI ITextSelection_fnSetIndex(ITextSelection *me, LONG Unit, LONG Index,
981 LONG Extend)
983 ITextSelectionImpl *This = impl_from_ITextSelection(me);
984 if (!This->reOle)
985 return CO_E_RELEASED;
987 FIXME("not implemented\n");
988 return E_NOTIMPL;
991 static HRESULT WINAPI ITextSelection_fnSetRange(ITextSelection *me, LONG cpActive, LONG cpOther)
993 ITextSelectionImpl *This = impl_from_ITextSelection(me);
994 if (!This->reOle)
995 return CO_E_RELEASED;
997 FIXME("not implemented\n");
998 return E_NOTIMPL;
1001 static HRESULT WINAPI ITextSelection_fnInRange(ITextSelection *me, ITextRange *pRange, LONG *pb)
1003 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1004 if (!This->reOle)
1005 return CO_E_RELEASED;
1007 FIXME("not implemented\n");
1008 return E_NOTIMPL;
1011 static HRESULT WINAPI ITextSelection_fnInStory(ITextSelection *me, ITextRange *pRange, LONG *pb)
1013 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1014 if (!This->reOle)
1015 return CO_E_RELEASED;
1017 FIXME("not implemented\n");
1018 return E_NOTIMPL;
1021 static HRESULT WINAPI ITextSelection_fnIsEqual(ITextSelection *me, ITextRange *pRange, LONG *pb)
1023 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1024 if (!This->reOle)
1025 return CO_E_RELEASED;
1027 FIXME("not implemented\n");
1028 return E_NOTIMPL;
1031 static HRESULT WINAPI ITextSelection_fnSelect(ITextSelection *me)
1033 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1034 if (!This->reOle)
1035 return CO_E_RELEASED;
1037 FIXME("not implemented\n");
1038 return E_NOTIMPL;
1041 static HRESULT WINAPI ITextSelection_fnStartOf(ITextSelection *me, LONG Unit, LONG Extend,
1042 LONG *pDelta)
1044 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1045 if (!This->reOle)
1046 return CO_E_RELEASED;
1048 FIXME("not implemented\n");
1049 return E_NOTIMPL;
1052 static HRESULT WINAPI ITextSelection_fnEndOf(ITextSelection *me, LONG Unit, LONG Extend,
1053 LONG *pDelta)
1055 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1056 if (!This->reOle)
1057 return CO_E_RELEASED;
1059 FIXME("not implemented\n");
1060 return E_NOTIMPL;
1063 static HRESULT WINAPI ITextSelection_fnMove(ITextSelection *me, LONG Unit, LONG Count, LONG *pDelta)
1065 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1066 if (!This->reOle)
1067 return CO_E_RELEASED;
1069 FIXME("not implemented\n");
1070 return E_NOTIMPL;
1073 static HRESULT WINAPI ITextSelection_fnMoveStart(ITextSelection *me, LONG Unit, LONG Count,
1074 LONG *pDelta)
1076 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1077 if (!This->reOle)
1078 return CO_E_RELEASED;
1080 FIXME("not implemented\n");
1081 return E_NOTIMPL;
1084 static HRESULT WINAPI ITextSelection_fnMoveEnd(ITextSelection *me, LONG Unit, LONG Count,
1085 LONG *pDelta)
1087 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1088 if (!This->reOle)
1089 return CO_E_RELEASED;
1091 FIXME("not implemented\n");
1092 return E_NOTIMPL;
1095 static HRESULT WINAPI ITextSelection_fnMoveWhile(ITextSelection *me, VARIANT *Cset, LONG Count,
1096 LONG *pDelta)
1098 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1099 if (!This->reOle)
1100 return CO_E_RELEASED;
1102 FIXME("not implemented\n");
1103 return E_NOTIMPL;
1106 static HRESULT WINAPI ITextSelection_fnMoveStartWhile(ITextSelection *me, VARIANT *Cset, LONG Count,
1107 LONG *pDelta)
1109 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1110 if (!This->reOle)
1111 return CO_E_RELEASED;
1113 FIXME("not implemented\n");
1114 return E_NOTIMPL;
1117 static HRESULT WINAPI ITextSelection_fnMoveEndWhile(ITextSelection *me, VARIANT *Cset, LONG Count,
1118 LONG *pDelta)
1120 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1121 if (!This->reOle)
1122 return CO_E_RELEASED;
1124 FIXME("not implemented\n");
1125 return E_NOTIMPL;
1128 static HRESULT WINAPI ITextSelection_fnMoveUntil(ITextSelection *me, VARIANT *Cset, LONG Count,
1129 LONG *pDelta)
1131 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1132 if (!This->reOle)
1133 return CO_E_RELEASED;
1135 FIXME("not implemented\n");
1136 return E_NOTIMPL;
1139 static HRESULT WINAPI ITextSelection_fnMoveStartUntil(ITextSelection *me, VARIANT *Cset, LONG Count,
1140 LONG *pDelta)
1142 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1143 if (!This->reOle)
1144 return CO_E_RELEASED;
1146 FIXME("not implemented\n");
1147 return E_NOTIMPL;
1150 static HRESULT WINAPI ITextSelection_fnMoveEndUntil(ITextSelection *me, VARIANT *Cset, LONG Count,
1151 LONG *pDelta)
1153 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1154 if (!This->reOle)
1155 return CO_E_RELEASED;
1157 FIXME("not implemented\n");
1158 return E_NOTIMPL;
1161 static HRESULT WINAPI ITextSelection_fnFindText(ITextSelection *me, BSTR bstr, LONG cch, LONG Flags,
1162 LONG *pLength)
1164 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1165 if (!This->reOle)
1166 return CO_E_RELEASED;
1168 FIXME("not implemented\n");
1169 return E_NOTIMPL;
1172 static HRESULT WINAPI ITextSelection_fnFindTextStart(ITextSelection *me, BSTR bstr, LONG cch,
1173 LONG Flags, LONG *pLength)
1175 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1176 if (!This->reOle)
1177 return CO_E_RELEASED;
1179 FIXME("not implemented\n");
1180 return E_NOTIMPL;
1183 static HRESULT WINAPI ITextSelection_fnFindTextEnd(ITextSelection *me, BSTR bstr, LONG cch,
1184 LONG Flags, LONG *pLength)
1186 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1187 if (!This->reOle)
1188 return CO_E_RELEASED;
1190 FIXME("not implemented\n");
1191 return E_NOTIMPL;
1194 static HRESULT WINAPI ITextSelection_fnDelete(ITextSelection *me, LONG Unit, LONG Count,
1195 LONG *pDelta)
1197 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1198 if (!This->reOle)
1199 return CO_E_RELEASED;
1201 FIXME("not implemented\n");
1202 return E_NOTIMPL;
1205 static HRESULT WINAPI ITextSelection_fnCut(ITextSelection *me, VARIANT *pVar)
1207 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1208 if (!This->reOle)
1209 return CO_E_RELEASED;
1211 FIXME("not implemented\n");
1212 return E_NOTIMPL;
1215 static HRESULT WINAPI ITextSelection_fnCopy(ITextSelection *me, VARIANT *pVar)
1217 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1218 if (!This->reOle)
1219 return CO_E_RELEASED;
1221 FIXME("not implemented\n");
1222 return E_NOTIMPL;
1225 static HRESULT WINAPI ITextSelection_fnPaste(ITextSelection *me, VARIANT *pVar, LONG Format)
1227 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1228 if (!This->reOle)
1229 return CO_E_RELEASED;
1231 FIXME("not implemented\n");
1232 return E_NOTIMPL;
1235 static HRESULT WINAPI ITextSelection_fnCanPaste(ITextSelection *me, VARIANT *pVar, LONG Format,
1236 LONG *pb)
1238 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1239 if (!This->reOle)
1240 return CO_E_RELEASED;
1242 FIXME("not implemented\n");
1243 return E_NOTIMPL;
1246 static HRESULT WINAPI ITextSelection_fnCanEdit(ITextSelection *me, LONG *pb)
1248 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1249 if (!This->reOle)
1250 return CO_E_RELEASED;
1252 FIXME("not implemented\n");
1253 return E_NOTIMPL;
1256 static HRESULT WINAPI ITextSelection_fnChangeCase(ITextSelection *me, LONG Type)
1258 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1259 if (!This->reOle)
1260 return CO_E_RELEASED;
1262 FIXME("not implemented\n");
1263 return E_NOTIMPL;
1266 static HRESULT WINAPI ITextSelection_fnGetPoint(ITextSelection *me, LONG Type, LONG *cx, LONG *cy)
1268 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1269 if (!This->reOle)
1270 return CO_E_RELEASED;
1272 FIXME("not implemented\n");
1273 return E_NOTIMPL;
1276 static HRESULT WINAPI ITextSelection_fnSetPoint(ITextSelection *me, LONG x, LONG y, LONG Type,
1277 LONG Extend)
1279 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1280 if (!This->reOle)
1281 return CO_E_RELEASED;
1283 FIXME("not implemented\n");
1284 return E_NOTIMPL;
1287 static HRESULT WINAPI ITextSelection_fnScrollIntoView(ITextSelection *me, LONG Value)
1289 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1290 if (!This->reOle)
1291 return CO_E_RELEASED;
1293 FIXME("not implemented\n");
1294 return E_NOTIMPL;
1297 static HRESULT WINAPI ITextSelection_fnGetEmbeddedObject(ITextSelection *me, IUnknown **ppv)
1299 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1300 if (!This->reOle)
1301 return CO_E_RELEASED;
1303 FIXME("not implemented\n");
1304 return E_NOTIMPL;
1307 /*** ITextSelection methods ***/
1308 static HRESULT WINAPI ITextSelection_fnGetFlags(ITextSelection *me, LONG *pFlags)
1310 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1311 if (!This->reOle)
1312 return CO_E_RELEASED;
1314 FIXME("not implemented\n");
1315 return E_NOTIMPL;
1318 static HRESULT WINAPI ITextSelection_fnSetFlags(ITextSelection *me, LONG Flags)
1320 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1321 if (!This->reOle)
1322 return CO_E_RELEASED;
1324 FIXME("not implemented\n");
1325 return E_NOTIMPL;
1328 static HRESULT WINAPI ITextSelection_fnGetType(ITextSelection *me, LONG *pType)
1330 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1331 if (!This->reOle)
1332 return CO_E_RELEASED;
1334 FIXME("not implemented\n");
1335 return E_NOTIMPL;
1338 static HRESULT WINAPI ITextSelection_fnMoveLeft(ITextSelection *me, LONG Unit, LONG Count,
1339 LONG Extend, LONG *pDelta)
1341 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1342 if (!This->reOle)
1343 return CO_E_RELEASED;
1345 FIXME("not implemented\n");
1346 return E_NOTIMPL;
1349 static HRESULT WINAPI ITextSelection_fnMoveRight(ITextSelection *me, LONG Unit, LONG Count,
1350 LONG Extend, LONG *pDelta)
1352 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1353 if (!This->reOle)
1354 return CO_E_RELEASED;
1356 FIXME("not implemented\n");
1357 return E_NOTIMPL;
1360 static HRESULT WINAPI ITextSelection_fnMoveUp(ITextSelection *me, LONG Unit, LONG Count,
1361 LONG Extend, LONG *pDelta)
1363 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1364 if (!This->reOle)
1365 return CO_E_RELEASED;
1367 FIXME("not implemented\n");
1368 return E_NOTIMPL;
1371 static HRESULT WINAPI ITextSelection_fnMoveDown(ITextSelection *me, LONG Unit, LONG Count,
1372 LONG Extend, LONG *pDelta)
1374 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1375 if (!This->reOle)
1376 return CO_E_RELEASED;
1378 FIXME("not implemented\n");
1379 return E_NOTIMPL;
1382 static HRESULT WINAPI ITextSelection_fnHomeKey(ITextSelection *me, LONG Unit, LONG Extend,
1383 LONG *pDelta)
1385 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1386 if (!This->reOle)
1387 return CO_E_RELEASED;
1389 FIXME("not implemented\n");
1390 return E_NOTIMPL;
1393 static HRESULT WINAPI ITextSelection_fnEndKey(ITextSelection *me, LONG Unit, LONG Extend,
1394 LONG *pDelta)
1396 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1397 if (!This->reOle)
1398 return CO_E_RELEASED;
1400 FIXME("not implemented\n");
1401 return E_NOTIMPL;
1404 static HRESULT WINAPI ITextSelection_fnTypeText(ITextSelection *me, BSTR bstr)
1406 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1407 if (!This->reOle)
1408 return CO_E_RELEASED;
1410 FIXME("not implemented\n");
1411 return E_NOTIMPL;
1414 static const ITextSelectionVtbl tsvt = {
1415 ITextSelection_fnQueryInterface,
1416 ITextSelection_fnAddRef,
1417 ITextSelection_fnRelease,
1418 ITextSelection_fnGetTypeInfoCount,
1419 ITextSelection_fnGetTypeInfo,
1420 ITextSelection_fnGetIDsOfNames,
1421 ITextSelection_fnInvoke,
1422 ITextSelection_fnGetText,
1423 ITextSelection_fnSetText,
1424 ITextSelection_fnGetChar,
1425 ITextSelection_fnSetChar,
1426 ITextSelection_fnGetDuplicate,
1427 ITextSelection_fnGetFormattedText,
1428 ITextSelection_fnSetFormattedText,
1429 ITextSelection_fnGetStart,
1430 ITextSelection_fnSetStart,
1431 ITextSelection_fnGetEnd,
1432 ITextSelection_fnSetEnd,
1433 ITextSelection_fnGetFont,
1434 ITextSelection_fnSetFont,
1435 ITextSelection_fnGetPara,
1436 ITextSelection_fnSetPara,
1437 ITextSelection_fnGetStoryLength,
1438 ITextSelection_fnGetStoryType,
1439 ITextSelection_fnCollapse,
1440 ITextSelection_fnExpand,
1441 ITextSelection_fnGetIndex,
1442 ITextSelection_fnSetIndex,
1443 ITextSelection_fnSetRange,
1444 ITextSelection_fnInRange,
1445 ITextSelection_fnInStory,
1446 ITextSelection_fnIsEqual,
1447 ITextSelection_fnSelect,
1448 ITextSelection_fnStartOf,
1449 ITextSelection_fnEndOf,
1450 ITextSelection_fnMove,
1451 ITextSelection_fnMoveStart,
1452 ITextSelection_fnMoveEnd,
1453 ITextSelection_fnMoveWhile,
1454 ITextSelection_fnMoveStartWhile,
1455 ITextSelection_fnMoveEndWhile,
1456 ITextSelection_fnMoveUntil,
1457 ITextSelection_fnMoveStartUntil,
1458 ITextSelection_fnMoveEndUntil,
1459 ITextSelection_fnFindText,
1460 ITextSelection_fnFindTextStart,
1461 ITextSelection_fnFindTextEnd,
1462 ITextSelection_fnDelete,
1463 ITextSelection_fnCut,
1464 ITextSelection_fnCopy,
1465 ITextSelection_fnPaste,
1466 ITextSelection_fnCanPaste,
1467 ITextSelection_fnCanEdit,
1468 ITextSelection_fnChangeCase,
1469 ITextSelection_fnGetPoint,
1470 ITextSelection_fnSetPoint,
1471 ITextSelection_fnScrollIntoView,
1472 ITextSelection_fnGetEmbeddedObject,
1473 ITextSelection_fnGetFlags,
1474 ITextSelection_fnSetFlags,
1475 ITextSelection_fnGetType,
1476 ITextSelection_fnMoveLeft,
1477 ITextSelection_fnMoveRight,
1478 ITextSelection_fnMoveUp,
1479 ITextSelection_fnMoveDown,
1480 ITextSelection_fnHomeKey,
1481 ITextSelection_fnEndKey,
1482 ITextSelection_fnTypeText
1485 static ITextSelectionImpl *
1486 CreateTextSelection(IRichEditOleImpl *reOle)
1488 ITextSelectionImpl *txtSel = heap_alloc(sizeof *txtSel);
1489 if (!txtSel)
1490 return NULL;
1492 txtSel->ITextSelection_iface.lpVtbl = &tsvt;
1493 txtSel->ref = 1;
1494 txtSel->reOle = reOle;
1495 return txtSel;
1498 LRESULT CreateIRichEditOle(ME_TextEditor *editor, LPVOID *ppObj)
1500 IRichEditOleImpl *reo;
1502 reo = heap_alloc(sizeof(IRichEditOleImpl));
1503 if (!reo)
1504 return 0;
1506 reo->IRichEditOle_iface.lpVtbl = &revt;
1507 reo->ITextDocument_iface.lpVtbl = &tdvt;
1508 reo->ref = 1;
1509 reo->editor = editor;
1510 reo->txtSel = CreateTextSelection(reo);
1511 if (!reo->txtSel)
1513 heap_free(reo);
1514 return 0;
1516 reo->clientSite = CreateOleClientSite(reo);
1517 if (!reo->txtSel)
1519 ITextSelection_Release(&reo->txtSel->ITextSelection_iface);
1520 heap_free(reo);
1521 return 0;
1523 TRACE("Created %p\n",reo);
1524 *ppObj = reo;
1526 return 1;
1529 static void convert_sizel(const ME_Context *c, const SIZEL* szl, SIZE* sz)
1531 /* sizel is in .01 millimeters, sz in pixels */
1532 sz->cx = MulDiv(szl->cx, c->dpi.cx, 2540);
1533 sz->cy = MulDiv(szl->cy, c->dpi.cy, 2540);
1536 /******************************************************************************
1537 * ME_GetOLEObjectSize
1539 * Sets run extent for OLE objects.
1541 void ME_GetOLEObjectSize(const ME_Context *c, ME_Run *run, SIZE *pSize)
1543 IDataObject* ido;
1544 FORMATETC fmt;
1545 STGMEDIUM stgm;
1546 DIBSECTION dibsect;
1547 ENHMETAHEADER emh;
1549 assert(run->nFlags & MERF_GRAPHICS);
1550 assert(run->ole_obj);
1552 if (run->ole_obj->sizel.cx != 0 || run->ole_obj->sizel.cy != 0)
1554 convert_sizel(c, &run->ole_obj->sizel, pSize);
1555 if (c->editor->nZoomNumerator != 0)
1557 pSize->cx = MulDiv(pSize->cx, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
1558 pSize->cy = MulDiv(pSize->cy, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
1560 return;
1563 IOleObject_QueryInterface(run->ole_obj->poleobj, &IID_IDataObject, (void**)&ido);
1564 fmt.cfFormat = CF_BITMAP;
1565 fmt.ptd = NULL;
1566 fmt.dwAspect = DVASPECT_CONTENT;
1567 fmt.lindex = -1;
1568 fmt.tymed = TYMED_GDI;
1569 if (IDataObject_GetData(ido, &fmt, &stgm) != S_OK)
1571 fmt.cfFormat = CF_ENHMETAFILE;
1572 fmt.tymed = TYMED_ENHMF;
1573 if (IDataObject_GetData(ido, &fmt, &stgm) != S_OK)
1575 FIXME("unsupported format\n");
1576 pSize->cx = pSize->cy = 0;
1577 IDataObject_Release(ido);
1578 return;
1582 switch (stgm.tymed)
1584 case TYMED_GDI:
1585 GetObjectW(stgm.u.hBitmap, sizeof(dibsect), &dibsect);
1586 pSize->cx = dibsect.dsBm.bmWidth;
1587 pSize->cy = dibsect.dsBm.bmHeight;
1588 if (!stgm.pUnkForRelease) DeleteObject(stgm.u.hBitmap);
1589 break;
1590 case TYMED_ENHMF:
1591 GetEnhMetaFileHeader(stgm.u.hEnhMetaFile, sizeof(emh), &emh);
1592 pSize->cx = emh.rclBounds.right - emh.rclBounds.left;
1593 pSize->cy = emh.rclBounds.bottom - emh.rclBounds.top;
1594 if (!stgm.pUnkForRelease) DeleteEnhMetaFile(stgm.u.hEnhMetaFile);
1595 break;
1596 default:
1597 FIXME("Unsupported tymed %d\n", stgm.tymed);
1598 break;
1600 IDataObject_Release(ido);
1601 if (c->editor->nZoomNumerator != 0)
1603 pSize->cx = MulDiv(pSize->cx, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
1604 pSize->cy = MulDiv(pSize->cy, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
1608 void ME_DrawOLE(ME_Context *c, int x, int y, ME_Run *run,
1609 ME_Paragraph *para, BOOL selected)
1611 IDataObject* ido;
1612 FORMATETC fmt;
1613 STGMEDIUM stgm;
1614 DIBSECTION dibsect;
1615 ENHMETAHEADER emh;
1616 HDC hMemDC;
1617 SIZE sz;
1618 BOOL has_size;
1620 assert(run->nFlags & MERF_GRAPHICS);
1621 assert(run->ole_obj);
1622 if (IOleObject_QueryInterface(run->ole_obj->poleobj, &IID_IDataObject, (void**)&ido) != S_OK)
1624 FIXME("Couldn't get interface\n");
1625 return;
1627 has_size = run->ole_obj->sizel.cx != 0 || run->ole_obj->sizel.cy != 0;
1628 fmt.cfFormat = CF_BITMAP;
1629 fmt.ptd = NULL;
1630 fmt.dwAspect = DVASPECT_CONTENT;
1631 fmt.lindex = -1;
1632 fmt.tymed = TYMED_GDI;
1633 if (IDataObject_GetData(ido, &fmt, &stgm) != S_OK)
1635 fmt.cfFormat = CF_ENHMETAFILE;
1636 fmt.tymed = TYMED_ENHMF;
1637 if (IDataObject_GetData(ido, &fmt, &stgm) != S_OK)
1639 FIXME("Couldn't get storage medium\n");
1640 IDataObject_Release(ido);
1641 return;
1644 switch (stgm.tymed)
1646 case TYMED_GDI:
1647 GetObjectW(stgm.u.hBitmap, sizeof(dibsect), &dibsect);
1648 hMemDC = CreateCompatibleDC(c->hDC);
1649 SelectObject(hMemDC, stgm.u.hBitmap);
1650 if (has_size)
1652 convert_sizel(c, &run->ole_obj->sizel, &sz);
1653 } else {
1654 sz.cx = MulDiv(dibsect.dsBm.bmWidth, c->dpi.cx, 96);
1655 sz.cy = MulDiv(dibsect.dsBm.bmHeight, c->dpi.cy, 96);
1657 if (c->editor->nZoomNumerator != 0)
1659 sz.cx = MulDiv(sz.cx, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
1660 sz.cy = MulDiv(sz.cy, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
1662 if (sz.cx == dibsect.dsBm.bmWidth && sz.cy == dibsect.dsBm.bmHeight)
1664 BitBlt(c->hDC, x, y - sz.cy,
1665 dibsect.dsBm.bmWidth, dibsect.dsBm.bmHeight,
1666 hMemDC, 0, 0, SRCCOPY);
1667 } else {
1668 StretchBlt(c->hDC, x, y - sz.cy, sz.cx, sz.cy,
1669 hMemDC, 0, 0, dibsect.dsBm.bmWidth,
1670 dibsect.dsBm.bmHeight, SRCCOPY);
1672 DeleteDC(hMemDC);
1673 if (!stgm.pUnkForRelease) DeleteObject(stgm.u.hBitmap);
1674 break;
1675 case TYMED_ENHMF:
1676 GetEnhMetaFileHeader(stgm.u.hEnhMetaFile, sizeof(emh), &emh);
1677 if (has_size)
1679 convert_sizel(c, &run->ole_obj->sizel, &sz);
1680 } else {
1681 sz.cy = MulDiv(emh.rclBounds.bottom - emh.rclBounds.top, c->dpi.cx, 96);
1682 sz.cx = MulDiv(emh.rclBounds.right - emh.rclBounds.left, c->dpi.cy, 96);
1684 if (c->editor->nZoomNumerator != 0)
1686 sz.cx = MulDiv(sz.cx, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
1687 sz.cy = MulDiv(sz.cy, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
1691 RECT rc;
1693 rc.left = x;
1694 rc.top = y - sz.cy;
1695 rc.right = x + sz.cx;
1696 rc.bottom = y;
1697 PlayEnhMetaFile(c->hDC, stgm.u.hEnhMetaFile, &rc);
1699 if (!stgm.pUnkForRelease) DeleteEnhMetaFile(stgm.u.hEnhMetaFile);
1700 break;
1701 default:
1702 FIXME("Unsupported tymed %d\n", stgm.tymed);
1703 selected = FALSE;
1704 break;
1706 if (selected && !c->editor->bHideSelection)
1707 PatBlt(c->hDC, x, y - sz.cy, sz.cx, sz.cy, DSTINVERT);
1708 IDataObject_Release(ido);
1711 void ME_DeleteReObject(REOBJECT* reo)
1713 if (reo->poleobj) IOleObject_Release(reo->poleobj);
1714 if (reo->pstg) IStorage_Release(reo->pstg);
1715 if (reo->polesite) IOleClientSite_Release(reo->polesite);
1716 FREE_OBJ(reo);
1719 void ME_CopyReObject(REOBJECT* dst, const REOBJECT* src)
1721 *dst = *src;
1723 if (dst->poleobj) IOleObject_AddRef(dst->poleobj);
1724 if (dst->pstg) IStorage_AddRef(dst->pstg);
1725 if (dst->polesite) IOleClientSite_AddRef(dst->polesite);