riched20: Return E_INVALIDARG for empty ppSel in ITextDocument::GetSelection.
[wine/wine-gecko.git] / dlls / riched20 / richole.c
blobbec228e83a8ac68bc8f5caf776d63d31c5a80308
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_AddRef(*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_QueryInterface(&This->IRichEditOle_iface, riid, ppvObject);
454 static ULONG WINAPI
455 ITextDocument_fnAddRef(ITextDocument* me)
457 IRichEditOleImpl *This = impl_from_ITextDocument(me);
458 return IRichEditOle_AddRef(&This->IRichEditOle_iface);
461 static ULONG WINAPI
462 ITextDocument_fnRelease(ITextDocument* me)
464 IRichEditOleImpl *This = impl_from_ITextDocument(me);
465 return IRichEditOle_Release(&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);
519 if(!ppSel)
520 return E_INVALIDARG;
521 *ppSel = &This->txtSel->ITextSelection_iface;
522 ITextSelection_AddRef(*ppSel);
523 return S_OK;
526 static HRESULT WINAPI
527 ITextDocument_fnGetStoryCount(ITextDocument* me, LONG* pCount)
529 IRichEditOleImpl *This = impl_from_ITextDocument(me);
530 FIXME("stub %p\n",This);
531 return E_NOTIMPL;
534 static HRESULT WINAPI
535 ITextDocument_fnGetStoryRanges(ITextDocument* me,
536 ITextStoryRanges** ppStories)
538 IRichEditOleImpl *This = impl_from_ITextDocument(me);
539 FIXME("stub %p\n",This);
540 return E_NOTIMPL;
543 static HRESULT WINAPI
544 ITextDocument_fnGetSaved(ITextDocument* me, LONG* pValue)
546 IRichEditOleImpl *This = impl_from_ITextDocument(me);
547 FIXME("stub %p\n",This);
548 return E_NOTIMPL;
551 static HRESULT WINAPI
552 ITextDocument_fnSetSaved(ITextDocument* me, LONG Value)
554 IRichEditOleImpl *This = impl_from_ITextDocument(me);
555 FIXME("stub %p\n",This);
556 return E_NOTIMPL;
559 static HRESULT WINAPI
560 ITextDocument_fnGetDefaultTabStop(ITextDocument* me, float* pValue)
562 IRichEditOleImpl *This = impl_from_ITextDocument(me);
563 FIXME("stub %p\n",This);
564 return E_NOTIMPL;
567 static HRESULT WINAPI
568 ITextDocument_fnSetDefaultTabStop(ITextDocument* me, float Value)
570 IRichEditOleImpl *This = impl_from_ITextDocument(me);
571 FIXME("stub %p\n",This);
572 return E_NOTIMPL;
575 static HRESULT WINAPI
576 ITextDocument_fnNew(ITextDocument* me)
578 IRichEditOleImpl *This = impl_from_ITextDocument(me);
579 FIXME("stub %p\n",This);
580 return E_NOTIMPL;
583 static HRESULT WINAPI
584 ITextDocument_fnOpen(ITextDocument* me, VARIANT* pVar, LONG Flags,
585 LONG CodePage)
587 IRichEditOleImpl *This = impl_from_ITextDocument(me);
588 FIXME("stub %p\n",This);
589 return E_NOTIMPL;
592 static HRESULT WINAPI
593 ITextDocument_fnSave(ITextDocument* me, VARIANT* pVar, LONG Flags,
594 LONG CodePage)
596 IRichEditOleImpl *This = impl_from_ITextDocument(me);
597 FIXME("stub %p\n",This);
598 return E_NOTIMPL;
601 static HRESULT WINAPI
602 ITextDocument_fnFreeze(ITextDocument* me, LONG* pCount)
604 IRichEditOleImpl *This = impl_from_ITextDocument(me);
605 FIXME("stub %p\n",This);
606 return E_NOTIMPL;
609 static HRESULT WINAPI
610 ITextDocument_fnUnfreeze(ITextDocument* me, LONG* pCount)
612 IRichEditOleImpl *This = impl_from_ITextDocument(me);
613 FIXME("stub %p\n",This);
614 return E_NOTIMPL;
617 static HRESULT WINAPI
618 ITextDocument_fnBeginEditCollection(ITextDocument* me)
620 IRichEditOleImpl *This = impl_from_ITextDocument(me);
621 FIXME("stub %p\n",This);
622 return E_NOTIMPL;
625 static HRESULT WINAPI
626 ITextDocument_fnEndEditCollection(ITextDocument* me)
628 IRichEditOleImpl *This = impl_from_ITextDocument(me);
629 FIXME("stub %p\n",This);
630 return E_NOTIMPL;
633 static HRESULT WINAPI
634 ITextDocument_fnUndo(ITextDocument* me, LONG Count, LONG* prop)
636 IRichEditOleImpl *This = impl_from_ITextDocument(me);
637 FIXME("stub %p\n",This);
638 return E_NOTIMPL;
641 static HRESULT WINAPI
642 ITextDocument_fnRedo(ITextDocument* me, LONG Count, LONG* prop)
644 IRichEditOleImpl *This = impl_from_ITextDocument(me);
645 FIXME("stub %p\n",This);
646 return E_NOTIMPL;
649 static HRESULT WINAPI
650 ITextDocument_fnRange(ITextDocument* me, LONG cp1, LONG cp2,
651 ITextRange** ppRange)
653 IRichEditOleImpl *This = impl_from_ITextDocument(me);
654 FIXME("stub %p\n",This);
655 return E_NOTIMPL;
658 static HRESULT WINAPI
659 ITextDocument_fnRangeFromPoint(ITextDocument* me, LONG x, LONG y,
660 ITextRange** ppRange)
662 IRichEditOleImpl *This = impl_from_ITextDocument(me);
663 FIXME("stub %p\n",This);
664 return E_NOTIMPL;
667 static const ITextDocumentVtbl tdvt = {
668 ITextDocument_fnQueryInterface,
669 ITextDocument_fnAddRef,
670 ITextDocument_fnRelease,
671 ITextDocument_fnGetTypeInfoCount,
672 ITextDocument_fnGetTypeInfo,
673 ITextDocument_fnGetIDsOfNames,
674 ITextDocument_fnInvoke,
675 ITextDocument_fnGetName,
676 ITextDocument_fnGetSelection,
677 ITextDocument_fnGetStoryCount,
678 ITextDocument_fnGetStoryRanges,
679 ITextDocument_fnGetSaved,
680 ITextDocument_fnSetSaved,
681 ITextDocument_fnGetDefaultTabStop,
682 ITextDocument_fnSetDefaultTabStop,
683 ITextDocument_fnNew,
684 ITextDocument_fnOpen,
685 ITextDocument_fnSave,
686 ITextDocument_fnFreeze,
687 ITextDocument_fnUnfreeze,
688 ITextDocument_fnBeginEditCollection,
689 ITextDocument_fnEndEditCollection,
690 ITextDocument_fnUndo,
691 ITextDocument_fnRedo,
692 ITextDocument_fnRange,
693 ITextDocument_fnRangeFromPoint
696 static inline ITextSelectionImpl *impl_from_ITextSelection(ITextSelection *iface)
698 return CONTAINING_RECORD(iface, ITextSelectionImpl, ITextSelection_iface);
701 static HRESULT WINAPI ITextSelection_fnQueryInterface(
702 ITextSelection *me,
703 REFIID riid,
704 void **ppvObj)
706 *ppvObj = NULL;
707 if (IsEqualGUID(riid, &IID_IUnknown)
708 || IsEqualGUID(riid, &IID_IDispatch)
709 || IsEqualGUID(riid, &IID_ITextRange)
710 || IsEqualGUID(riid, &IID_ITextSelection))
712 *ppvObj = me;
713 ITextSelection_AddRef(me);
714 return S_OK;
717 return E_NOINTERFACE;
720 static ULONG WINAPI ITextSelection_fnAddRef(ITextSelection *me)
722 ITextSelectionImpl *This = impl_from_ITextSelection(me);
723 return InterlockedIncrement(&This->ref);
726 static ULONG WINAPI ITextSelection_fnRelease(ITextSelection *me)
728 ITextSelectionImpl *This = impl_from_ITextSelection(me);
729 ULONG ref = InterlockedDecrement(&This->ref);
730 if (ref == 0)
731 heap_free(This);
732 return ref;
735 static HRESULT WINAPI ITextSelection_fnGetTypeInfoCount(ITextSelection *me, UINT *pctinfo)
737 ITextSelectionImpl *This = impl_from_ITextSelection(me);
738 if (!This->reOle)
739 return CO_E_RELEASED;
741 FIXME("not implemented\n");
742 return E_NOTIMPL;
745 static HRESULT WINAPI ITextSelection_fnGetTypeInfo(ITextSelection *me, UINT iTInfo, LCID lcid,
746 ITypeInfo **ppTInfo)
748 ITextSelectionImpl *This = impl_from_ITextSelection(me);
749 if (!This->reOle)
750 return CO_E_RELEASED;
752 FIXME("not implemented\n");
753 return E_NOTIMPL;
756 static HRESULT WINAPI ITextSelection_fnGetIDsOfNames(ITextSelection *me, REFIID riid,
757 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
759 ITextSelectionImpl *This = impl_from_ITextSelection(me);
760 if (!This->reOle)
761 return CO_E_RELEASED;
763 FIXME("not implemented\n");
764 return E_NOTIMPL;
767 static HRESULT WINAPI ITextSelection_fnInvoke(
768 ITextSelection *me,
769 DISPID dispIdMember,
770 REFIID riid,
771 LCID lcid,
772 WORD wFlags,
773 DISPPARAMS *pDispParams,
774 VARIANT *pVarResult,
775 EXCEPINFO *pExcepInfo,
776 UINT *puArgErr)
778 FIXME("not implemented\n");
779 return E_NOTIMPL;
782 /*** ITextRange methods ***/
783 static HRESULT WINAPI ITextSelection_fnGetText(ITextSelection *me, BSTR *pbstr)
785 ITextSelectionImpl *This = impl_from_ITextSelection(me);
786 if (!This->reOle)
787 return CO_E_RELEASED;
789 FIXME("not implemented\n");
790 return E_NOTIMPL;
793 static HRESULT WINAPI ITextSelection_fnSetText(ITextSelection *me, BSTR bstr)
795 ITextSelectionImpl *This = impl_from_ITextSelection(me);
796 if (!This->reOle)
797 return CO_E_RELEASED;
799 FIXME("not implemented\n");
800 return E_NOTIMPL;
803 static HRESULT WINAPI ITextSelection_fnGetChar(ITextSelection *me, LONG *pch)
805 ITextSelectionImpl *This = impl_from_ITextSelection(me);
806 if (!This->reOle)
807 return CO_E_RELEASED;
809 FIXME("not implemented\n");
810 return E_NOTIMPL;
813 static HRESULT WINAPI ITextSelection_fnSetChar(ITextSelection *me, LONG ch)
815 ITextSelectionImpl *This = impl_from_ITextSelection(me);
816 if (!This->reOle)
817 return CO_E_RELEASED;
819 FIXME("not implemented\n");
820 return E_NOTIMPL;
823 static HRESULT WINAPI ITextSelection_fnGetDuplicate(ITextSelection *me, ITextRange **ppRange)
825 ITextSelectionImpl *This = impl_from_ITextSelection(me);
826 if (!This->reOle)
827 return CO_E_RELEASED;
829 FIXME("not implemented\n");
830 return E_NOTIMPL;
833 static HRESULT WINAPI ITextSelection_fnGetFormattedText(ITextSelection *me, ITextRange **ppRange)
835 ITextSelectionImpl *This = impl_from_ITextSelection(me);
836 if (!This->reOle)
837 return CO_E_RELEASED;
839 FIXME("not implemented\n");
840 return E_NOTIMPL;
843 static HRESULT WINAPI ITextSelection_fnSetFormattedText(ITextSelection *me, ITextRange *pRange)
845 ITextSelectionImpl *This = impl_from_ITextSelection(me);
846 if (!This->reOle)
847 return CO_E_RELEASED;
849 FIXME("not implemented\n");
850 return E_NOTIMPL;
853 static HRESULT WINAPI ITextSelection_fnGetStart(ITextSelection *me, LONG *pcpFirst)
855 ITextSelectionImpl *This = impl_from_ITextSelection(me);
856 if (!This->reOle)
857 return CO_E_RELEASED;
859 FIXME("not implemented\n");
860 return E_NOTIMPL;
863 static HRESULT WINAPI ITextSelection_fnSetStart(ITextSelection *me, LONG cpFirst)
865 ITextSelectionImpl *This = impl_from_ITextSelection(me);
866 if (!This->reOle)
867 return CO_E_RELEASED;
869 FIXME("not implemented\n");
870 return E_NOTIMPL;
873 static HRESULT WINAPI ITextSelection_fnGetEnd(ITextSelection *me, LONG *pcpLim)
875 ITextSelectionImpl *This = impl_from_ITextSelection(me);
876 if (!This->reOle)
877 return CO_E_RELEASED;
879 FIXME("not implemented\n");
880 return E_NOTIMPL;
883 static HRESULT WINAPI ITextSelection_fnSetEnd(ITextSelection *me, LONG cpLim)
885 ITextSelectionImpl *This = impl_from_ITextSelection(me);
886 if (!This->reOle)
887 return CO_E_RELEASED;
889 FIXME("not implemented\n");
890 return E_NOTIMPL;
893 static HRESULT WINAPI ITextSelection_fnGetFont(ITextSelection *me, ITextFont **pFont)
895 ITextSelectionImpl *This = impl_from_ITextSelection(me);
896 if (!This->reOle)
897 return CO_E_RELEASED;
899 FIXME("not implemented\n");
900 return E_NOTIMPL;
903 static HRESULT WINAPI ITextSelection_fnSetFont(ITextSelection *me, ITextFont *pFont)
905 ITextSelectionImpl *This = impl_from_ITextSelection(me);
906 if (!This->reOle)
907 return CO_E_RELEASED;
909 FIXME("not implemented\n");
910 return E_NOTIMPL;
913 static HRESULT WINAPI ITextSelection_fnGetPara(ITextSelection *me, ITextPara **ppPara)
915 ITextSelectionImpl *This = impl_from_ITextSelection(me);
916 if (!This->reOle)
917 return CO_E_RELEASED;
919 FIXME("not implemented\n");
920 return E_NOTIMPL;
923 static HRESULT WINAPI ITextSelection_fnSetPara(ITextSelection *me, ITextPara *pPara)
925 ITextSelectionImpl *This = impl_from_ITextSelection(me);
926 if (!This->reOle)
927 return CO_E_RELEASED;
929 FIXME("not implemented\n");
930 return E_NOTIMPL;
933 static HRESULT WINAPI ITextSelection_fnGetStoryLength(ITextSelection *me, LONG *pcch)
935 ITextSelectionImpl *This = impl_from_ITextSelection(me);
936 if (!This->reOle)
937 return CO_E_RELEASED;
939 FIXME("not implemented\n");
940 return E_NOTIMPL;
943 static HRESULT WINAPI ITextSelection_fnGetStoryType(ITextSelection *me, LONG *pValue)
945 ITextSelectionImpl *This = impl_from_ITextSelection(me);
946 if (!This->reOle)
947 return CO_E_RELEASED;
949 FIXME("not implemented\n");
950 return E_NOTIMPL;
953 static HRESULT WINAPI ITextSelection_fnCollapse(ITextSelection *me, LONG bStart)
955 ITextSelectionImpl *This = impl_from_ITextSelection(me);
956 if (!This->reOle)
957 return CO_E_RELEASED;
959 FIXME("not implemented\n");
960 return E_NOTIMPL;
963 static HRESULT WINAPI ITextSelection_fnExpand(ITextSelection *me, LONG Unit, LONG *pDelta)
965 ITextSelectionImpl *This = impl_from_ITextSelection(me);
966 if (!This->reOle)
967 return CO_E_RELEASED;
969 FIXME("not implemented\n");
970 return E_NOTIMPL;
973 static HRESULT WINAPI ITextSelection_fnGetIndex(ITextSelection *me, LONG Unit, LONG *pIndex)
975 ITextSelectionImpl *This = impl_from_ITextSelection(me);
976 if (!This->reOle)
977 return CO_E_RELEASED;
979 FIXME("not implemented\n");
980 return E_NOTIMPL;
983 static HRESULT WINAPI ITextSelection_fnSetIndex(ITextSelection *me, LONG Unit, LONG Index,
984 LONG Extend)
986 ITextSelectionImpl *This = impl_from_ITextSelection(me);
987 if (!This->reOle)
988 return CO_E_RELEASED;
990 FIXME("not implemented\n");
991 return E_NOTIMPL;
994 static HRESULT WINAPI ITextSelection_fnSetRange(ITextSelection *me, LONG cpActive, LONG cpOther)
996 ITextSelectionImpl *This = impl_from_ITextSelection(me);
997 if (!This->reOle)
998 return CO_E_RELEASED;
1000 FIXME("not implemented\n");
1001 return E_NOTIMPL;
1004 static HRESULT WINAPI ITextSelection_fnInRange(ITextSelection *me, ITextRange *pRange, LONG *pb)
1006 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1007 if (!This->reOle)
1008 return CO_E_RELEASED;
1010 FIXME("not implemented\n");
1011 return E_NOTIMPL;
1014 static HRESULT WINAPI ITextSelection_fnInStory(ITextSelection *me, ITextRange *pRange, LONG *pb)
1016 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1017 if (!This->reOle)
1018 return CO_E_RELEASED;
1020 FIXME("not implemented\n");
1021 return E_NOTIMPL;
1024 static HRESULT WINAPI ITextSelection_fnIsEqual(ITextSelection *me, ITextRange *pRange, LONG *pb)
1026 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1027 if (!This->reOle)
1028 return CO_E_RELEASED;
1030 FIXME("not implemented\n");
1031 return E_NOTIMPL;
1034 static HRESULT WINAPI ITextSelection_fnSelect(ITextSelection *me)
1036 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1037 if (!This->reOle)
1038 return CO_E_RELEASED;
1040 FIXME("not implemented\n");
1041 return E_NOTIMPL;
1044 static HRESULT WINAPI ITextSelection_fnStartOf(ITextSelection *me, LONG Unit, LONG Extend,
1045 LONG *pDelta)
1047 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1048 if (!This->reOle)
1049 return CO_E_RELEASED;
1051 FIXME("not implemented\n");
1052 return E_NOTIMPL;
1055 static HRESULT WINAPI ITextSelection_fnEndOf(ITextSelection *me, LONG Unit, LONG Extend,
1056 LONG *pDelta)
1058 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1059 if (!This->reOle)
1060 return CO_E_RELEASED;
1062 FIXME("not implemented\n");
1063 return E_NOTIMPL;
1066 static HRESULT WINAPI ITextSelection_fnMove(ITextSelection *me, LONG Unit, LONG Count, LONG *pDelta)
1068 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1069 if (!This->reOle)
1070 return CO_E_RELEASED;
1072 FIXME("not implemented\n");
1073 return E_NOTIMPL;
1076 static HRESULT WINAPI ITextSelection_fnMoveStart(ITextSelection *me, LONG Unit, LONG Count,
1077 LONG *pDelta)
1079 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1080 if (!This->reOle)
1081 return CO_E_RELEASED;
1083 FIXME("not implemented\n");
1084 return E_NOTIMPL;
1087 static HRESULT WINAPI ITextSelection_fnMoveEnd(ITextSelection *me, LONG Unit, LONG Count,
1088 LONG *pDelta)
1090 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1091 if (!This->reOle)
1092 return CO_E_RELEASED;
1094 FIXME("not implemented\n");
1095 return E_NOTIMPL;
1098 static HRESULT WINAPI ITextSelection_fnMoveWhile(ITextSelection *me, VARIANT *Cset, LONG Count,
1099 LONG *pDelta)
1101 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1102 if (!This->reOle)
1103 return CO_E_RELEASED;
1105 FIXME("not implemented\n");
1106 return E_NOTIMPL;
1109 static HRESULT WINAPI ITextSelection_fnMoveStartWhile(ITextSelection *me, VARIANT *Cset, LONG Count,
1110 LONG *pDelta)
1112 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1113 if (!This->reOle)
1114 return CO_E_RELEASED;
1116 FIXME("not implemented\n");
1117 return E_NOTIMPL;
1120 static HRESULT WINAPI ITextSelection_fnMoveEndWhile(ITextSelection *me, VARIANT *Cset, LONG Count,
1121 LONG *pDelta)
1123 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1124 if (!This->reOle)
1125 return CO_E_RELEASED;
1127 FIXME("not implemented\n");
1128 return E_NOTIMPL;
1131 static HRESULT WINAPI ITextSelection_fnMoveUntil(ITextSelection *me, VARIANT *Cset, LONG Count,
1132 LONG *pDelta)
1134 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1135 if (!This->reOle)
1136 return CO_E_RELEASED;
1138 FIXME("not implemented\n");
1139 return E_NOTIMPL;
1142 static HRESULT WINAPI ITextSelection_fnMoveStartUntil(ITextSelection *me, VARIANT *Cset, LONG Count,
1143 LONG *pDelta)
1145 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1146 if (!This->reOle)
1147 return CO_E_RELEASED;
1149 FIXME("not implemented\n");
1150 return E_NOTIMPL;
1153 static HRESULT WINAPI ITextSelection_fnMoveEndUntil(ITextSelection *me, VARIANT *Cset, LONG Count,
1154 LONG *pDelta)
1156 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1157 if (!This->reOle)
1158 return CO_E_RELEASED;
1160 FIXME("not implemented\n");
1161 return E_NOTIMPL;
1164 static HRESULT WINAPI ITextSelection_fnFindText(ITextSelection *me, BSTR bstr, LONG cch, LONG Flags,
1165 LONG *pLength)
1167 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1168 if (!This->reOle)
1169 return CO_E_RELEASED;
1171 FIXME("not implemented\n");
1172 return E_NOTIMPL;
1175 static HRESULT WINAPI ITextSelection_fnFindTextStart(ITextSelection *me, BSTR bstr, LONG cch,
1176 LONG Flags, LONG *pLength)
1178 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1179 if (!This->reOle)
1180 return CO_E_RELEASED;
1182 FIXME("not implemented\n");
1183 return E_NOTIMPL;
1186 static HRESULT WINAPI ITextSelection_fnFindTextEnd(ITextSelection *me, BSTR bstr, LONG cch,
1187 LONG Flags, LONG *pLength)
1189 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1190 if (!This->reOle)
1191 return CO_E_RELEASED;
1193 FIXME("not implemented\n");
1194 return E_NOTIMPL;
1197 static HRESULT WINAPI ITextSelection_fnDelete(ITextSelection *me, LONG Unit, LONG Count,
1198 LONG *pDelta)
1200 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1201 if (!This->reOle)
1202 return CO_E_RELEASED;
1204 FIXME("not implemented\n");
1205 return E_NOTIMPL;
1208 static HRESULT WINAPI ITextSelection_fnCut(ITextSelection *me, VARIANT *pVar)
1210 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1211 if (!This->reOle)
1212 return CO_E_RELEASED;
1214 FIXME("not implemented\n");
1215 return E_NOTIMPL;
1218 static HRESULT WINAPI ITextSelection_fnCopy(ITextSelection *me, VARIANT *pVar)
1220 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1221 if (!This->reOle)
1222 return CO_E_RELEASED;
1224 FIXME("not implemented\n");
1225 return E_NOTIMPL;
1228 static HRESULT WINAPI ITextSelection_fnPaste(ITextSelection *me, VARIANT *pVar, LONG Format)
1230 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1231 if (!This->reOle)
1232 return CO_E_RELEASED;
1234 FIXME("not implemented\n");
1235 return E_NOTIMPL;
1238 static HRESULT WINAPI ITextSelection_fnCanPaste(ITextSelection *me, VARIANT *pVar, LONG Format,
1239 LONG *pb)
1241 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1242 if (!This->reOle)
1243 return CO_E_RELEASED;
1245 FIXME("not implemented\n");
1246 return E_NOTIMPL;
1249 static HRESULT WINAPI ITextSelection_fnCanEdit(ITextSelection *me, LONG *pb)
1251 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1252 if (!This->reOle)
1253 return CO_E_RELEASED;
1255 FIXME("not implemented\n");
1256 return E_NOTIMPL;
1259 static HRESULT WINAPI ITextSelection_fnChangeCase(ITextSelection *me, LONG Type)
1261 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1262 if (!This->reOle)
1263 return CO_E_RELEASED;
1265 FIXME("not implemented\n");
1266 return E_NOTIMPL;
1269 static HRESULT WINAPI ITextSelection_fnGetPoint(ITextSelection *me, LONG Type, LONG *cx, LONG *cy)
1271 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1272 if (!This->reOle)
1273 return CO_E_RELEASED;
1275 FIXME("not implemented\n");
1276 return E_NOTIMPL;
1279 static HRESULT WINAPI ITextSelection_fnSetPoint(ITextSelection *me, LONG x, LONG y, LONG Type,
1280 LONG Extend)
1282 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1283 if (!This->reOle)
1284 return CO_E_RELEASED;
1286 FIXME("not implemented\n");
1287 return E_NOTIMPL;
1290 static HRESULT WINAPI ITextSelection_fnScrollIntoView(ITextSelection *me, LONG Value)
1292 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1293 if (!This->reOle)
1294 return CO_E_RELEASED;
1296 FIXME("not implemented\n");
1297 return E_NOTIMPL;
1300 static HRESULT WINAPI ITextSelection_fnGetEmbeddedObject(ITextSelection *me, IUnknown **ppv)
1302 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1303 if (!This->reOle)
1304 return CO_E_RELEASED;
1306 FIXME("not implemented\n");
1307 return E_NOTIMPL;
1310 /*** ITextSelection methods ***/
1311 static HRESULT WINAPI ITextSelection_fnGetFlags(ITextSelection *me, LONG *pFlags)
1313 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1314 if (!This->reOle)
1315 return CO_E_RELEASED;
1317 FIXME("not implemented\n");
1318 return E_NOTIMPL;
1321 static HRESULT WINAPI ITextSelection_fnSetFlags(ITextSelection *me, LONG Flags)
1323 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1324 if (!This->reOle)
1325 return CO_E_RELEASED;
1327 FIXME("not implemented\n");
1328 return E_NOTIMPL;
1331 static HRESULT WINAPI ITextSelection_fnGetType(ITextSelection *me, LONG *pType)
1333 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1334 if (!This->reOle)
1335 return CO_E_RELEASED;
1337 FIXME("not implemented\n");
1338 return E_NOTIMPL;
1341 static HRESULT WINAPI ITextSelection_fnMoveLeft(ITextSelection *me, LONG Unit, LONG Count,
1342 LONG Extend, LONG *pDelta)
1344 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1345 if (!This->reOle)
1346 return CO_E_RELEASED;
1348 FIXME("not implemented\n");
1349 return E_NOTIMPL;
1352 static HRESULT WINAPI ITextSelection_fnMoveRight(ITextSelection *me, LONG Unit, LONG Count,
1353 LONG Extend, LONG *pDelta)
1355 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1356 if (!This->reOle)
1357 return CO_E_RELEASED;
1359 FIXME("not implemented\n");
1360 return E_NOTIMPL;
1363 static HRESULT WINAPI ITextSelection_fnMoveUp(ITextSelection *me, LONG Unit, LONG Count,
1364 LONG Extend, LONG *pDelta)
1366 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1367 if (!This->reOle)
1368 return CO_E_RELEASED;
1370 FIXME("not implemented\n");
1371 return E_NOTIMPL;
1374 static HRESULT WINAPI ITextSelection_fnMoveDown(ITextSelection *me, LONG Unit, LONG Count,
1375 LONG Extend, LONG *pDelta)
1377 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1378 if (!This->reOle)
1379 return CO_E_RELEASED;
1381 FIXME("not implemented\n");
1382 return E_NOTIMPL;
1385 static HRESULT WINAPI ITextSelection_fnHomeKey(ITextSelection *me, LONG Unit, LONG Extend,
1386 LONG *pDelta)
1388 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1389 if (!This->reOle)
1390 return CO_E_RELEASED;
1392 FIXME("not implemented\n");
1393 return E_NOTIMPL;
1396 static HRESULT WINAPI ITextSelection_fnEndKey(ITextSelection *me, LONG Unit, LONG Extend,
1397 LONG *pDelta)
1399 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1400 if (!This->reOle)
1401 return CO_E_RELEASED;
1403 FIXME("not implemented\n");
1404 return E_NOTIMPL;
1407 static HRESULT WINAPI ITextSelection_fnTypeText(ITextSelection *me, BSTR bstr)
1409 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1410 if (!This->reOle)
1411 return CO_E_RELEASED;
1413 FIXME("not implemented\n");
1414 return E_NOTIMPL;
1417 static const ITextSelectionVtbl tsvt = {
1418 ITextSelection_fnQueryInterface,
1419 ITextSelection_fnAddRef,
1420 ITextSelection_fnRelease,
1421 ITextSelection_fnGetTypeInfoCount,
1422 ITextSelection_fnGetTypeInfo,
1423 ITextSelection_fnGetIDsOfNames,
1424 ITextSelection_fnInvoke,
1425 ITextSelection_fnGetText,
1426 ITextSelection_fnSetText,
1427 ITextSelection_fnGetChar,
1428 ITextSelection_fnSetChar,
1429 ITextSelection_fnGetDuplicate,
1430 ITextSelection_fnGetFormattedText,
1431 ITextSelection_fnSetFormattedText,
1432 ITextSelection_fnGetStart,
1433 ITextSelection_fnSetStart,
1434 ITextSelection_fnGetEnd,
1435 ITextSelection_fnSetEnd,
1436 ITextSelection_fnGetFont,
1437 ITextSelection_fnSetFont,
1438 ITextSelection_fnGetPara,
1439 ITextSelection_fnSetPara,
1440 ITextSelection_fnGetStoryLength,
1441 ITextSelection_fnGetStoryType,
1442 ITextSelection_fnCollapse,
1443 ITextSelection_fnExpand,
1444 ITextSelection_fnGetIndex,
1445 ITextSelection_fnSetIndex,
1446 ITextSelection_fnSetRange,
1447 ITextSelection_fnInRange,
1448 ITextSelection_fnInStory,
1449 ITextSelection_fnIsEqual,
1450 ITextSelection_fnSelect,
1451 ITextSelection_fnStartOf,
1452 ITextSelection_fnEndOf,
1453 ITextSelection_fnMove,
1454 ITextSelection_fnMoveStart,
1455 ITextSelection_fnMoveEnd,
1456 ITextSelection_fnMoveWhile,
1457 ITextSelection_fnMoveStartWhile,
1458 ITextSelection_fnMoveEndWhile,
1459 ITextSelection_fnMoveUntil,
1460 ITextSelection_fnMoveStartUntil,
1461 ITextSelection_fnMoveEndUntil,
1462 ITextSelection_fnFindText,
1463 ITextSelection_fnFindTextStart,
1464 ITextSelection_fnFindTextEnd,
1465 ITextSelection_fnDelete,
1466 ITextSelection_fnCut,
1467 ITextSelection_fnCopy,
1468 ITextSelection_fnPaste,
1469 ITextSelection_fnCanPaste,
1470 ITextSelection_fnCanEdit,
1471 ITextSelection_fnChangeCase,
1472 ITextSelection_fnGetPoint,
1473 ITextSelection_fnSetPoint,
1474 ITextSelection_fnScrollIntoView,
1475 ITextSelection_fnGetEmbeddedObject,
1476 ITextSelection_fnGetFlags,
1477 ITextSelection_fnSetFlags,
1478 ITextSelection_fnGetType,
1479 ITextSelection_fnMoveLeft,
1480 ITextSelection_fnMoveRight,
1481 ITextSelection_fnMoveUp,
1482 ITextSelection_fnMoveDown,
1483 ITextSelection_fnHomeKey,
1484 ITextSelection_fnEndKey,
1485 ITextSelection_fnTypeText
1488 static ITextSelectionImpl *
1489 CreateTextSelection(IRichEditOleImpl *reOle)
1491 ITextSelectionImpl *txtSel = heap_alloc(sizeof *txtSel);
1492 if (!txtSel)
1493 return NULL;
1495 txtSel->ITextSelection_iface.lpVtbl = &tsvt;
1496 txtSel->ref = 1;
1497 txtSel->reOle = reOle;
1498 return txtSel;
1501 LRESULT CreateIRichEditOle(ME_TextEditor *editor, LPVOID *ppObj)
1503 IRichEditOleImpl *reo;
1505 reo = heap_alloc(sizeof(IRichEditOleImpl));
1506 if (!reo)
1507 return 0;
1509 reo->IRichEditOle_iface.lpVtbl = &revt;
1510 reo->ITextDocument_iface.lpVtbl = &tdvt;
1511 reo->ref = 1;
1512 reo->editor = editor;
1513 reo->txtSel = CreateTextSelection(reo);
1514 if (!reo->txtSel)
1516 heap_free(reo);
1517 return 0;
1519 reo->clientSite = CreateOleClientSite(reo);
1520 if (!reo->txtSel)
1522 ITextSelection_Release(&reo->txtSel->ITextSelection_iface);
1523 heap_free(reo);
1524 return 0;
1526 TRACE("Created %p\n",reo);
1527 *ppObj = reo;
1529 return 1;
1532 static void convert_sizel(const ME_Context *c, const SIZEL* szl, SIZE* sz)
1534 /* sizel is in .01 millimeters, sz in pixels */
1535 sz->cx = MulDiv(szl->cx, c->dpi.cx, 2540);
1536 sz->cy = MulDiv(szl->cy, c->dpi.cy, 2540);
1539 /******************************************************************************
1540 * ME_GetOLEObjectSize
1542 * Sets run extent for OLE objects.
1544 void ME_GetOLEObjectSize(const ME_Context *c, ME_Run *run, SIZE *pSize)
1546 IDataObject* ido;
1547 FORMATETC fmt;
1548 STGMEDIUM stgm;
1549 DIBSECTION dibsect;
1550 ENHMETAHEADER emh;
1552 assert(run->nFlags & MERF_GRAPHICS);
1553 assert(run->ole_obj);
1555 if (run->ole_obj->sizel.cx != 0 || run->ole_obj->sizel.cy != 0)
1557 convert_sizel(c, &run->ole_obj->sizel, pSize);
1558 if (c->editor->nZoomNumerator != 0)
1560 pSize->cx = MulDiv(pSize->cx, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
1561 pSize->cy = MulDiv(pSize->cy, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
1563 return;
1566 IOleObject_QueryInterface(run->ole_obj->poleobj, &IID_IDataObject, (void**)&ido);
1567 fmt.cfFormat = CF_BITMAP;
1568 fmt.ptd = NULL;
1569 fmt.dwAspect = DVASPECT_CONTENT;
1570 fmt.lindex = -1;
1571 fmt.tymed = TYMED_GDI;
1572 if (IDataObject_GetData(ido, &fmt, &stgm) != S_OK)
1574 fmt.cfFormat = CF_ENHMETAFILE;
1575 fmt.tymed = TYMED_ENHMF;
1576 if (IDataObject_GetData(ido, &fmt, &stgm) != S_OK)
1578 FIXME("unsupported format\n");
1579 pSize->cx = pSize->cy = 0;
1580 IDataObject_Release(ido);
1581 return;
1585 switch (stgm.tymed)
1587 case TYMED_GDI:
1588 GetObjectW(stgm.u.hBitmap, sizeof(dibsect), &dibsect);
1589 pSize->cx = dibsect.dsBm.bmWidth;
1590 pSize->cy = dibsect.dsBm.bmHeight;
1591 if (!stgm.pUnkForRelease) DeleteObject(stgm.u.hBitmap);
1592 break;
1593 case TYMED_ENHMF:
1594 GetEnhMetaFileHeader(stgm.u.hEnhMetaFile, sizeof(emh), &emh);
1595 pSize->cx = emh.rclBounds.right - emh.rclBounds.left;
1596 pSize->cy = emh.rclBounds.bottom - emh.rclBounds.top;
1597 if (!stgm.pUnkForRelease) DeleteEnhMetaFile(stgm.u.hEnhMetaFile);
1598 break;
1599 default:
1600 FIXME("Unsupported tymed %d\n", stgm.tymed);
1601 break;
1603 IDataObject_Release(ido);
1604 if (c->editor->nZoomNumerator != 0)
1606 pSize->cx = MulDiv(pSize->cx, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
1607 pSize->cy = MulDiv(pSize->cy, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
1611 void ME_DrawOLE(ME_Context *c, int x, int y, ME_Run *run,
1612 ME_Paragraph *para, BOOL selected)
1614 IDataObject* ido;
1615 FORMATETC fmt;
1616 STGMEDIUM stgm;
1617 DIBSECTION dibsect;
1618 ENHMETAHEADER emh;
1619 HDC hMemDC;
1620 SIZE sz;
1621 BOOL has_size;
1623 assert(run->nFlags & MERF_GRAPHICS);
1624 assert(run->ole_obj);
1625 if (IOleObject_QueryInterface(run->ole_obj->poleobj, &IID_IDataObject, (void**)&ido) != S_OK)
1627 FIXME("Couldn't get interface\n");
1628 return;
1630 has_size = run->ole_obj->sizel.cx != 0 || run->ole_obj->sizel.cy != 0;
1631 fmt.cfFormat = CF_BITMAP;
1632 fmt.ptd = NULL;
1633 fmt.dwAspect = DVASPECT_CONTENT;
1634 fmt.lindex = -1;
1635 fmt.tymed = TYMED_GDI;
1636 if (IDataObject_GetData(ido, &fmt, &stgm) != S_OK)
1638 fmt.cfFormat = CF_ENHMETAFILE;
1639 fmt.tymed = TYMED_ENHMF;
1640 if (IDataObject_GetData(ido, &fmt, &stgm) != S_OK)
1642 FIXME("Couldn't get storage medium\n");
1643 IDataObject_Release(ido);
1644 return;
1647 switch (stgm.tymed)
1649 case TYMED_GDI:
1650 GetObjectW(stgm.u.hBitmap, sizeof(dibsect), &dibsect);
1651 hMemDC = CreateCompatibleDC(c->hDC);
1652 SelectObject(hMemDC, stgm.u.hBitmap);
1653 if (has_size)
1655 convert_sizel(c, &run->ole_obj->sizel, &sz);
1656 } else {
1657 sz.cx = MulDiv(dibsect.dsBm.bmWidth, c->dpi.cx, 96);
1658 sz.cy = MulDiv(dibsect.dsBm.bmHeight, c->dpi.cy, 96);
1660 if (c->editor->nZoomNumerator != 0)
1662 sz.cx = MulDiv(sz.cx, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
1663 sz.cy = MulDiv(sz.cy, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
1665 if (sz.cx == dibsect.dsBm.bmWidth && sz.cy == dibsect.dsBm.bmHeight)
1667 BitBlt(c->hDC, x, y - sz.cy,
1668 dibsect.dsBm.bmWidth, dibsect.dsBm.bmHeight,
1669 hMemDC, 0, 0, SRCCOPY);
1670 } else {
1671 StretchBlt(c->hDC, x, y - sz.cy, sz.cx, sz.cy,
1672 hMemDC, 0, 0, dibsect.dsBm.bmWidth,
1673 dibsect.dsBm.bmHeight, SRCCOPY);
1675 DeleteDC(hMemDC);
1676 if (!stgm.pUnkForRelease) DeleteObject(stgm.u.hBitmap);
1677 break;
1678 case TYMED_ENHMF:
1679 GetEnhMetaFileHeader(stgm.u.hEnhMetaFile, sizeof(emh), &emh);
1680 if (has_size)
1682 convert_sizel(c, &run->ole_obj->sizel, &sz);
1683 } else {
1684 sz.cy = MulDiv(emh.rclBounds.bottom - emh.rclBounds.top, c->dpi.cx, 96);
1685 sz.cx = MulDiv(emh.rclBounds.right - emh.rclBounds.left, c->dpi.cy, 96);
1687 if (c->editor->nZoomNumerator != 0)
1689 sz.cx = MulDiv(sz.cx, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
1690 sz.cy = MulDiv(sz.cy, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
1694 RECT rc;
1696 rc.left = x;
1697 rc.top = y - sz.cy;
1698 rc.right = x + sz.cx;
1699 rc.bottom = y;
1700 PlayEnhMetaFile(c->hDC, stgm.u.hEnhMetaFile, &rc);
1702 if (!stgm.pUnkForRelease) DeleteEnhMetaFile(stgm.u.hEnhMetaFile);
1703 break;
1704 default:
1705 FIXME("Unsupported tymed %d\n", stgm.tymed);
1706 selected = FALSE;
1707 break;
1709 if (selected && !c->editor->bHideSelection)
1710 PatBlt(c->hDC, x, y - sz.cy, sz.cx, sz.cy, DSTINVERT);
1711 IDataObject_Release(ido);
1714 void ME_DeleteReObject(REOBJECT* reo)
1716 if (reo->poleobj) IOleObject_Release(reo->poleobj);
1717 if (reo->pstg) IStorage_Release(reo->pstg);
1718 if (reo->polesite) IOleClientSite_Release(reo->polesite);
1719 FREE_OBJ(reo);
1722 void ME_CopyReObject(REOBJECT* dst, const REOBJECT* src)
1724 *dst = *src;
1726 if (dst->poleobj) IOleObject_AddRef(dst->poleobj);
1727 if (dst->pstg) IStorage_AddRef(dst->pstg);
1728 if (dst->polesite) IOleClientSite_AddRef(dst->polesite);