Release 1.1.37.
[wine/gsoc-2012-control.git] / dlls / riched20 / richole.c
blobc7eb5ffca96e643c8cc7dfe0acdfa6f4a72d719f
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 /* FIXME: the next 6 lines should be in textserv.h */
43 #include "initguid.h"
44 #define TEXTSERV_GUID(name, l, w1, w2, b1, b2) \
45 DEFINE_GUID(name, l, w1, w2, b1, b2, 0x00, 0xaa, 0x00, 0x6c, 0xad, 0xc5)
47 TEXTSERV_GUID(IID_ITextServices, 0x8d33f740, 0xcf58, 0x11ce, 0xa8, 0x9d);
48 TEXTSERV_GUID(IID_ITextHost, 0xc5bdd8d0, 0xd26e, 0x11ce, 0xa8, 0x9e);
49 TEXTSERV_GUID(IID_ITextHost2, 0xc5bdd8d0, 0xd26e, 0x11ce, 0xa8, 0x9e);
50 DEFINE_GUID(IID_ITextDocument, 0x8cc497c0, 0xa1df, 0x11ce, 0x80, 0x98, 0x00, 0xaa, 0x00, 0x47, 0xbe, 0x5d);
51 DEFINE_GUID(IID_ITextRange, 0x8cc497c2, 0xa1df, 0x11ce, 0x80, 0x98, 0x00, 0xaa, 0x00, 0x47, 0xbe, 0x5d);
52 DEFINE_GUID(IID_ITextSelection, 0x8cc497c1, 0xa1df, 0x11ce, 0x80, 0x98, 0x00, 0xaa, 0x00, 0x47, 0xbe, 0x5d);
54 typedef struct ITextSelectionImpl ITextSelectionImpl;
55 typedef struct IOleClientSiteImpl IOleClientSiteImpl;
57 typedef struct IRichEditOleImpl {
58 const IRichEditOleVtbl *lpRichEditOleVtbl;
59 const ITextDocumentVtbl *lpTextDocumentVtbl;
60 LONG ref;
62 ME_TextEditor *editor;
63 ITextSelectionImpl *txtSel;
64 IOleClientSiteImpl *clientSite;
65 } IRichEditOleImpl;
67 struct ITextSelectionImpl {
68 const ITextSelectionVtbl *lpVtbl;
69 LONG ref;
71 IRichEditOleImpl *reOle;
74 struct IOleClientSiteImpl {
75 const IOleClientSiteVtbl *lpVtbl;
76 LONG ref;
78 IRichEditOleImpl *reOle;
81 static inline IRichEditOleImpl *impl_from_IRichEditOle(IRichEditOle *iface)
83 return (IRichEditOleImpl *)((BYTE*)iface - FIELD_OFFSET(IRichEditOleImpl, lpRichEditOleVtbl));
86 static inline IRichEditOleImpl *impl_from_ITextDocument(ITextDocument *iface)
88 return (IRichEditOleImpl *)((BYTE*)iface - FIELD_OFFSET(IRichEditOleImpl, lpTextDocumentVtbl));
91 static HRESULT WINAPI
92 IRichEditOle_fnQueryInterface(IRichEditOle *me, REFIID riid, LPVOID *ppvObj)
94 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
96 TRACE("%p %s\n", This, debugstr_guid(riid) );
98 *ppvObj = NULL;
99 if (IsEqualGUID(riid, &IID_IUnknown) ||
100 IsEqualGUID(riid, &IID_IRichEditOle))
101 *ppvObj = &This->lpRichEditOleVtbl;
102 else if (IsEqualGUID(riid, &IID_ITextDocument))
103 *ppvObj = &This->lpTextDocumentVtbl;
104 if (*ppvObj)
106 IRichEditOle_AddRef(me);
107 return S_OK;
109 FIXME("%p: unhandled interface %s\n", This, debugstr_guid(riid) );
111 return E_NOINTERFACE;
114 static ULONG WINAPI
115 IRichEditOle_fnAddRef(IRichEditOle *me)
117 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
118 ULONG ref = InterlockedIncrement( &This->ref );
120 TRACE("%p ref = %u\n", This, ref);
122 return ref;
125 static ULONG WINAPI
126 IRichEditOle_fnRelease(IRichEditOle *me)
128 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
129 ULONG ref = InterlockedDecrement(&This->ref);
131 TRACE ("%p ref=%u\n", This, ref);
133 if (!ref)
135 TRACE ("Destroying %p\n", This);
136 This->txtSel->reOle = NULL;
137 ITextSelection_Release((ITextSelection *) This->txtSel);
138 IOleClientSite_Release((IOleClientSite *) This->clientSite);
139 heap_free(This);
141 return ref;
144 static HRESULT WINAPI
145 IRichEditOle_fnActivateAs(IRichEditOle *me, REFCLSID rclsid, REFCLSID rclsidAs)
147 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
148 FIXME("stub %p\n",This);
149 return E_NOTIMPL;
152 static HRESULT WINAPI
153 IRichEditOle_fnContextSensitiveHelp(IRichEditOle *me, BOOL fEnterMode)
155 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
156 FIXME("stub %p\n",This);
157 return E_NOTIMPL;
160 static HRESULT WINAPI
161 IRichEditOle_fnConvertObject(IRichEditOle *me, LONG iob,
162 REFCLSID rclsidNew, LPCSTR lpstrUserTypeNew)
164 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
165 FIXME("stub %p\n",This);
166 return E_NOTIMPL;
169 static HRESULT WINAPI
170 IOleClientSite_fnQueryInterface(IOleClientSite *me, REFIID riid, LPVOID *ppvObj)
172 TRACE("%p %s\n", me, debugstr_guid(riid) );
174 *ppvObj = NULL;
175 if (IsEqualGUID(riid, &IID_IUnknown) ||
176 IsEqualGUID(riid, &IID_IOleClientSite))
177 *ppvObj = me;
178 if (*ppvObj)
180 IOleClientSite_AddRef(me);
181 return S_OK;
183 FIXME("%p: unhandled interface %s\n", me, debugstr_guid(riid) );
185 return E_NOINTERFACE;
188 static ULONG WINAPI
189 IOleClientSite_fnAddRef(IOleClientSite *me)
191 IOleClientSiteImpl *This = (IOleClientSiteImpl *) me;
192 return InterlockedIncrement(&This->ref);
195 static ULONG WINAPI
196 IOleClientSite_fnRelease(IOleClientSite *me)
198 IOleClientSiteImpl *This = (IOleClientSiteImpl *) me;
199 ULONG ref = InterlockedDecrement(&This->ref);
200 if (ref == 0)
201 heap_free(This);
202 return ref;
205 static HRESULT WINAPI
206 IOleClientSite_fnSaveObject(IOleClientSite *me)
208 IOleClientSiteImpl *This = (IOleClientSiteImpl *) me;
209 if (!This->reOle)
210 return CO_E_RELEASED;
212 FIXME("stub %p\n",me);
213 return E_NOTIMPL;
217 static HRESULT WINAPI
218 IOleClientSite_fnGetMoniker(IOleClientSite *me, DWORD dwAssign, DWORD dwWhichMoniker,
219 IMoniker **ppmk)
221 IOleClientSiteImpl *This = (IOleClientSiteImpl *) me;
222 if (!This->reOle)
223 return CO_E_RELEASED;
225 FIXME("stub %p\n",me);
226 return E_NOTIMPL;
229 static HRESULT WINAPI
230 IOleClientSite_fnGetContainer(IOleClientSite *me, IOleContainer **ppContainer)
232 IOleClientSiteImpl *This = (IOleClientSiteImpl *) me;
233 if (!This->reOle)
234 return CO_E_RELEASED;
236 FIXME("stub %p\n",me);
237 return E_NOTIMPL;
240 static HRESULT WINAPI
241 IOleClientSite_fnShowObject(IOleClientSite *me)
243 IOleClientSiteImpl *This = (IOleClientSiteImpl *) me;
244 if (!This->reOle)
245 return CO_E_RELEASED;
247 FIXME("stub %p\n",me);
248 return E_NOTIMPL;
251 static HRESULT WINAPI
252 IOleClientSite_fnOnShowWindow(IOleClientSite *me, BOOL fShow)
254 IOleClientSiteImpl *This = (IOleClientSiteImpl *) me;
255 if (!This->reOle)
256 return CO_E_RELEASED;
258 FIXME("stub %p\n",me);
259 return E_NOTIMPL;
262 static HRESULT WINAPI
263 IOleClientSite_fnRequestNewObjectLayout(IOleClientSite *me)
265 IOleClientSiteImpl *This = (IOleClientSiteImpl *) me;
266 if (!This->reOle)
267 return CO_E_RELEASED;
269 FIXME("stub %p\n",me);
270 return E_NOTIMPL;
273 static const IOleClientSiteVtbl ocst = {
274 IOleClientSite_fnQueryInterface,
275 IOleClientSite_fnAddRef,
276 IOleClientSite_fnRelease,
277 IOleClientSite_fnSaveObject,
278 IOleClientSite_fnGetMoniker,
279 IOleClientSite_fnGetContainer,
280 IOleClientSite_fnShowObject,
281 IOleClientSite_fnOnShowWindow,
282 IOleClientSite_fnRequestNewObjectLayout
285 static IOleClientSiteImpl *
286 CreateOleClientSite(IRichEditOleImpl *reOle)
288 IOleClientSiteImpl *clientSite = heap_alloc(sizeof *clientSite);
289 if (!clientSite)
290 return NULL;
292 clientSite->lpVtbl = &ocst;
293 clientSite->ref = 1;
294 clientSite->reOle = reOle;
295 return clientSite;
298 static HRESULT WINAPI
299 IRichEditOle_fnGetClientSite(IRichEditOle *me,
300 LPOLECLIENTSITE *lplpolesite)
302 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
304 TRACE("%p,%p\n",This, lplpolesite);
306 if(!lplpolesite)
307 return E_INVALIDARG;
308 *lplpolesite = (IOleClientSite *) This->clientSite;
309 IOleClientSite_fnAddRef(*lplpolesite);
310 return S_OK;
313 static HRESULT WINAPI
314 IRichEditOle_fnGetClipboardData(IRichEditOle *me, CHARRANGE *lpchrg,
315 DWORD reco, LPDATAOBJECT *lplpdataobj)
317 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
318 ME_Cursor start;
319 int nChars;
321 TRACE("(%p,%p,%d)\n",This, lpchrg, reco);
322 if(!lplpdataobj)
323 return E_INVALIDARG;
324 if(!lpchrg) {
325 int nFrom, nTo, nStartCur = ME_GetSelectionOfs(This->editor, &nFrom, &nTo);
326 start = This->editor->pCursors[nStartCur];
327 nChars = nTo - nFrom;
328 } else {
329 ME_CursorFromCharOfs(This->editor, lpchrg->cpMin, &start);
330 nChars = lpchrg->cpMax - lpchrg->cpMin;
332 return ME_GetDataObject(This->editor, &start, nChars, lplpdataobj);
335 static LONG WINAPI IRichEditOle_fnGetLinkCount(IRichEditOle *me)
337 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
338 FIXME("stub %p\n",This);
339 return E_NOTIMPL;
342 static HRESULT WINAPI
343 IRichEditOle_fnGetObject(IRichEditOle *me, LONG iob,
344 REOBJECT *lpreobject, DWORD dwFlags)
346 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
347 FIXME("stub %p\n",This);
348 return E_NOTIMPL;
351 static LONG WINAPI
352 IRichEditOle_fnGetObjectCount(IRichEditOle *me)
354 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
355 FIXME("stub %p\n",This);
356 return 0;
359 static HRESULT WINAPI
360 IRichEditOle_fnHandsOffStorage(IRichEditOle *me, LONG iob)
362 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
363 FIXME("stub %p\n",This);
364 return E_NOTIMPL;
367 static HRESULT WINAPI
368 IRichEditOle_fnImportDataObject(IRichEditOle *me, LPDATAOBJECT lpdataobj,
369 CLIPFORMAT cf, HGLOBAL hMetaPict)
371 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
372 FIXME("stub %p\n",This);
373 return E_NOTIMPL;
376 static HRESULT WINAPI
377 IRichEditOle_fnInPlaceDeactivate(IRichEditOle *me)
379 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
380 FIXME("stub %p\n",This);
381 return E_NOTIMPL;
384 static HRESULT WINAPI
385 IRichEditOle_fnInsertObject(IRichEditOle *me, REOBJECT *reo)
387 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
388 TRACE("(%p,%p)\n", This, reo);
390 if (reo->cbStruct < sizeof(*reo)) return STG_E_INVALIDPARAMETER;
392 ME_InsertOLEFromCursor(This->editor, reo, 0);
393 ME_CommitUndo(This->editor);
394 ME_UpdateRepaint(This->editor);
395 return S_OK;
398 static HRESULT WINAPI IRichEditOle_fnSaveCompleted(IRichEditOle *me, LONG iob,
399 LPSTORAGE lpstg)
401 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
402 FIXME("stub %p\n",This);
403 return E_NOTIMPL;
406 static HRESULT WINAPI
407 IRichEditOle_fnSetDvaspect(IRichEditOle *me, LONG iob, DWORD dvaspect)
409 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
410 FIXME("stub %p\n",This);
411 return E_NOTIMPL;
414 static HRESULT WINAPI IRichEditOle_fnSetHostNames(IRichEditOle *me,
415 LPCSTR lpstrContainerApp, LPCSTR lpstrContainerObj)
417 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
418 FIXME("stub %p %s %s\n",This, lpstrContainerApp, lpstrContainerObj);
419 return E_NOTIMPL;
422 static HRESULT WINAPI
423 IRichEditOle_fnSetLinkAvailable(IRichEditOle *me, LONG iob, BOOL fAvailable)
425 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
426 FIXME("stub %p\n",This);
427 return E_NOTIMPL;
430 static const IRichEditOleVtbl revt = {
431 IRichEditOle_fnQueryInterface,
432 IRichEditOle_fnAddRef,
433 IRichEditOle_fnRelease,
434 IRichEditOle_fnGetClientSite,
435 IRichEditOle_fnGetObjectCount,
436 IRichEditOle_fnGetLinkCount,
437 IRichEditOle_fnGetObject,
438 IRichEditOle_fnInsertObject,
439 IRichEditOle_fnConvertObject,
440 IRichEditOle_fnActivateAs,
441 IRichEditOle_fnSetHostNames,
442 IRichEditOle_fnSetLinkAvailable,
443 IRichEditOle_fnSetDvaspect,
444 IRichEditOle_fnHandsOffStorage,
445 IRichEditOle_fnSaveCompleted,
446 IRichEditOle_fnInPlaceDeactivate,
447 IRichEditOle_fnContextSensitiveHelp,
448 IRichEditOle_fnGetClipboardData,
449 IRichEditOle_fnImportDataObject
452 static HRESULT WINAPI
453 ITextDocument_fnQueryInterface(ITextDocument* me, REFIID riid,
454 void** ppvObject)
456 IRichEditOleImpl *This = impl_from_ITextDocument(me);
457 return IRichEditOle_fnQueryInterface((IRichEditOle*)&This->lpRichEditOleVtbl,
458 riid, ppvObject);
461 static ULONG WINAPI
462 ITextDocument_fnAddRef(ITextDocument* me)
464 IRichEditOleImpl *This = impl_from_ITextDocument(me);
465 return IRichEditOle_fnAddRef((IRichEditOle*)&This->lpRichEditOleVtbl);
468 static ULONG WINAPI
469 ITextDocument_fnRelease(ITextDocument* me)
471 IRichEditOleImpl *This = impl_from_ITextDocument(me);
472 return IRichEditOle_fnRelease((IRichEditOle*)&This->lpRichEditOleVtbl);
475 static HRESULT WINAPI
476 ITextDocument_fnGetTypeInfoCount(ITextDocument* me,
477 UINT* pctinfo)
479 IRichEditOleImpl *This = impl_from_ITextDocument(me);
480 FIXME("stub %p\n",This);
481 return E_NOTIMPL;
484 static HRESULT WINAPI
485 ITextDocument_fnGetTypeInfo(ITextDocument* me, UINT iTInfo, LCID lcid,
486 ITypeInfo** ppTInfo)
488 IRichEditOleImpl *This = impl_from_ITextDocument(me);
489 FIXME("stub %p\n",This);
490 return E_NOTIMPL;
493 static HRESULT WINAPI
494 ITextDocument_fnGetIDsOfNames(ITextDocument* me, REFIID riid,
495 LPOLESTR* rgszNames, UINT cNames, LCID lcid, DISPID* rgDispId)
497 IRichEditOleImpl *This = impl_from_ITextDocument(me);
498 FIXME("stub %p\n",This);
499 return E_NOTIMPL;
502 static HRESULT WINAPI
503 ITextDocument_fnInvoke(ITextDocument* me, DISPID dispIdMember,
504 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS* pDispParams,
505 VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr)
507 IRichEditOleImpl *This = impl_from_ITextDocument(me);
508 FIXME("stub %p\n",This);
509 return E_NOTIMPL;
512 static HRESULT WINAPI
513 ITextDocument_fnGetName(ITextDocument* me, BSTR* pName)
515 IRichEditOleImpl *This = impl_from_ITextDocument(me);
516 FIXME("stub %p\n",This);
517 return E_NOTIMPL;
520 static HRESULT WINAPI
521 ITextDocument_fnGetSelection(ITextDocument* me, ITextSelection** ppSel)
523 IRichEditOleImpl *This = impl_from_ITextDocument(me);
524 TRACE("(%p)\n", me);
525 *ppSel = (ITextSelection *) This->txtSel;
526 ITextSelection_AddRef(*ppSel);
527 return S_OK;
530 static HRESULT WINAPI
531 ITextDocument_fnGetStoryCount(ITextDocument* me, LONG* pCount)
533 IRichEditOleImpl *This = impl_from_ITextDocument(me);
534 FIXME("stub %p\n",This);
535 return E_NOTIMPL;
538 static HRESULT WINAPI
539 ITextDocument_fnGetStoryRanges(ITextDocument* me,
540 ITextStoryRanges** ppStories)
542 IRichEditOleImpl *This = impl_from_ITextDocument(me);
543 FIXME("stub %p\n",This);
544 return E_NOTIMPL;
547 static HRESULT WINAPI
548 ITextDocument_fnGetSaved(ITextDocument* me, LONG* pValue)
550 IRichEditOleImpl *This = impl_from_ITextDocument(me);
551 FIXME("stub %p\n",This);
552 return E_NOTIMPL;
555 static HRESULT WINAPI
556 ITextDocument_fnSetSaved(ITextDocument* me, LONG Value)
558 IRichEditOleImpl *This = impl_from_ITextDocument(me);
559 FIXME("stub %p\n",This);
560 return E_NOTIMPL;
563 static HRESULT WINAPI
564 ITextDocument_fnGetDefaultTabStop(ITextDocument* me, float* pValue)
566 IRichEditOleImpl *This = impl_from_ITextDocument(me);
567 FIXME("stub %p\n",This);
568 return E_NOTIMPL;
571 static HRESULT WINAPI
572 ITextDocument_fnSetDefaultTabStop(ITextDocument* me, float Value)
574 IRichEditOleImpl *This = impl_from_ITextDocument(me);
575 FIXME("stub %p\n",This);
576 return E_NOTIMPL;
579 static HRESULT WINAPI
580 ITextDocument_fnNew(ITextDocument* me)
582 IRichEditOleImpl *This = impl_from_ITextDocument(me);
583 FIXME("stub %p\n",This);
584 return E_NOTIMPL;
587 static HRESULT WINAPI
588 ITextDocument_fnOpen(ITextDocument* me, VARIANT* pVar, LONG Flags,
589 LONG CodePage)
591 IRichEditOleImpl *This = impl_from_ITextDocument(me);
592 FIXME("stub %p\n",This);
593 return E_NOTIMPL;
596 static HRESULT WINAPI
597 ITextDocument_fnSave(ITextDocument* me, VARIANT* pVar, LONG Flags,
598 LONG CodePage)
600 IRichEditOleImpl *This = impl_from_ITextDocument(me);
601 FIXME("stub %p\n",This);
602 return E_NOTIMPL;
605 static HRESULT WINAPI
606 ITextDocument_fnFreeze(ITextDocument* me, LONG* pCount)
608 IRichEditOleImpl *This = impl_from_ITextDocument(me);
609 FIXME("stub %p\n",This);
610 return E_NOTIMPL;
613 static HRESULT WINAPI
614 ITextDocument_fnUnfreeze(ITextDocument* me, LONG* pCount)
616 IRichEditOleImpl *This = impl_from_ITextDocument(me);
617 FIXME("stub %p\n",This);
618 return E_NOTIMPL;
621 static HRESULT WINAPI
622 ITextDocument_fnBeginEditCollection(ITextDocument* me)
624 IRichEditOleImpl *This = impl_from_ITextDocument(me);
625 FIXME("stub %p\n",This);
626 return E_NOTIMPL;
629 static HRESULT WINAPI
630 ITextDocument_fnEndEditCollection(ITextDocument* me)
632 IRichEditOleImpl *This = impl_from_ITextDocument(me);
633 FIXME("stub %p\n",This);
634 return E_NOTIMPL;
637 static HRESULT WINAPI
638 ITextDocument_fnUndo(ITextDocument* me, LONG Count, LONG* prop)
640 IRichEditOleImpl *This = impl_from_ITextDocument(me);
641 FIXME("stub %p\n",This);
642 return E_NOTIMPL;
645 static HRESULT WINAPI
646 ITextDocument_fnRedo(ITextDocument* me, LONG Count, LONG* prop)
648 IRichEditOleImpl *This = impl_from_ITextDocument(me);
649 FIXME("stub %p\n",This);
650 return E_NOTIMPL;
653 static HRESULT WINAPI
654 ITextDocument_fnRange(ITextDocument* me, LONG cp1, LONG cp2,
655 ITextRange** ppRange)
657 IRichEditOleImpl *This = impl_from_ITextDocument(me);
658 FIXME("stub %p\n",This);
659 return E_NOTIMPL;
662 static HRESULT WINAPI
663 ITextDocument_fnRangeFromPoint(ITextDocument* me, LONG x, LONG y,
664 ITextRange** ppRange)
666 IRichEditOleImpl *This = impl_from_ITextDocument(me);
667 FIXME("stub %p\n",This);
668 return E_NOTIMPL;
671 static const ITextDocumentVtbl tdvt = {
672 ITextDocument_fnQueryInterface,
673 ITextDocument_fnAddRef,
674 ITextDocument_fnRelease,
675 ITextDocument_fnGetTypeInfoCount,
676 ITextDocument_fnGetTypeInfo,
677 ITextDocument_fnGetIDsOfNames,
678 ITextDocument_fnInvoke,
679 ITextDocument_fnGetName,
680 ITextDocument_fnGetSelection,
681 ITextDocument_fnGetStoryCount,
682 ITextDocument_fnGetStoryRanges,
683 ITextDocument_fnGetSaved,
684 ITextDocument_fnSetSaved,
685 ITextDocument_fnGetDefaultTabStop,
686 ITextDocument_fnSetDefaultTabStop,
687 ITextDocument_fnNew,
688 ITextDocument_fnOpen,
689 ITextDocument_fnSave,
690 ITextDocument_fnFreeze,
691 ITextDocument_fnUnfreeze,
692 ITextDocument_fnBeginEditCollection,
693 ITextDocument_fnEndEditCollection,
694 ITextDocument_fnUndo,
695 ITextDocument_fnRedo,
696 ITextDocument_fnRange,
697 ITextDocument_fnRangeFromPoint
700 static HRESULT WINAPI ITextSelection_fnQueryInterface(
701 ITextSelection *me,
702 REFIID riid,
703 void **ppvObj)
705 *ppvObj = NULL;
706 if (IsEqualGUID(riid, &IID_IUnknown)
707 || IsEqualGUID(riid, &IID_IDispatch)
708 || IsEqualGUID(riid, &IID_ITextRange)
709 || IsEqualGUID(riid, &IID_ITextSelection))
711 *ppvObj = me;
712 ITextSelection_AddRef(me);
713 return S_OK;
716 return E_NOINTERFACE;
719 static ULONG WINAPI ITextSelection_fnAddRef(
720 ITextSelection *me)
722 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
723 return InterlockedIncrement(&This->ref);
726 static ULONG WINAPI ITextSelection_fnRelease(
727 ITextSelection *me)
729 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
730 ULONG ref = InterlockedDecrement(&This->ref);
731 if (ref == 0)
732 heap_free(This);
733 return ref;
736 static HRESULT WINAPI ITextSelection_fnGetTypeInfoCount(
737 ITextSelection *me,
738 UINT *pctinfo)
740 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
741 if (!This->reOle)
742 return CO_E_RELEASED;
744 FIXME("not implemented\n");
745 return E_NOTIMPL;
748 static HRESULT WINAPI ITextSelection_fnGetTypeInfo(
749 ITextSelection *me,
750 UINT iTInfo,
751 LCID lcid,
752 ITypeInfo **ppTInfo)
754 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
755 if (!This->reOle)
756 return CO_E_RELEASED;
758 FIXME("not implemented\n");
759 return E_NOTIMPL;
762 static HRESULT WINAPI ITextSelection_fnGetIDsOfNames(
763 ITextSelection *me,
764 REFIID riid,
765 LPOLESTR *rgszNames,
766 UINT cNames,
767 LCID lcid,
768 DISPID *rgDispId)
770 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
771 if (!This->reOle)
772 return CO_E_RELEASED;
774 FIXME("not implemented\n");
775 return E_NOTIMPL;
778 static HRESULT WINAPI ITextSelection_fnInvoke(
779 ITextSelection *me,
780 DISPID dispIdMember,
781 REFIID riid,
782 LCID lcid,
783 WORD wFlags,
784 DISPPARAMS *pDispParams,
785 VARIANT *pVarResult,
786 EXCEPINFO *pExcepInfo,
787 UINT *puArgErr)
789 FIXME("not implemented\n");
790 return E_NOTIMPL;
793 /*** ITextRange methods ***/
794 static HRESULT WINAPI ITextSelection_fnGetText(
795 ITextSelection *me,
796 BSTR *pbstr)
798 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
799 if (!This->reOle)
800 return CO_E_RELEASED;
802 FIXME("not implemented\n");
803 return E_NOTIMPL;
806 static HRESULT WINAPI ITextSelection_fnSetText(
807 ITextSelection *me,
808 BSTR bstr)
810 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
811 if (!This->reOle)
812 return CO_E_RELEASED;
814 FIXME("not implemented\n");
815 return E_NOTIMPL;
818 static HRESULT WINAPI ITextSelection_fnGetChar(
819 ITextSelection *me,
820 LONG *pch)
822 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
823 if (!This->reOle)
824 return CO_E_RELEASED;
826 FIXME("not implemented\n");
827 return E_NOTIMPL;
830 static HRESULT WINAPI ITextSelection_fnSetChar(
831 ITextSelection *me,
832 LONG ch)
834 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
835 if (!This->reOle)
836 return CO_E_RELEASED;
838 FIXME("not implemented\n");
839 return E_NOTIMPL;
842 static HRESULT WINAPI ITextSelection_fnGetDuplicate(
843 ITextSelection *me,
844 ITextRange **ppRange)
846 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
847 if (!This->reOle)
848 return CO_E_RELEASED;
850 FIXME("not implemented\n");
851 return E_NOTIMPL;
854 static HRESULT WINAPI ITextSelection_fnGetFormattedText(
855 ITextSelection *me,
856 ITextRange **ppRange)
858 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
859 if (!This->reOle)
860 return CO_E_RELEASED;
862 FIXME("not implemented\n");
863 return E_NOTIMPL;
866 static HRESULT WINAPI ITextSelection_fnSetFormattedText(
867 ITextSelection *me,
868 ITextRange *pRange)
870 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
871 if (!This->reOle)
872 return CO_E_RELEASED;
874 FIXME("not implemented\n");
875 return E_NOTIMPL;
878 static HRESULT WINAPI ITextSelection_fnGetStart(
879 ITextSelection *me,
880 LONG *pcpFirst)
882 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
883 if (!This->reOle)
884 return CO_E_RELEASED;
886 FIXME("not implemented\n");
887 return E_NOTIMPL;
890 static HRESULT WINAPI ITextSelection_fnSetStart(
891 ITextSelection *me,
892 LONG cpFirst)
894 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
895 if (!This->reOle)
896 return CO_E_RELEASED;
898 FIXME("not implemented\n");
899 return E_NOTIMPL;
902 static HRESULT WINAPI ITextSelection_fnGetEnd(
903 ITextSelection *me,
904 LONG *pcpLim)
906 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
907 if (!This->reOle)
908 return CO_E_RELEASED;
910 FIXME("not implemented\n");
911 return E_NOTIMPL;
914 static HRESULT WINAPI ITextSelection_fnSetEnd(
915 ITextSelection *me,
916 LONG cpLim)
918 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
919 if (!This->reOle)
920 return CO_E_RELEASED;
922 FIXME("not implemented\n");
923 return E_NOTIMPL;
926 static HRESULT WINAPI ITextSelection_fnGetFont(
927 ITextSelection *me,
928 ITextFont **pFont)
930 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
931 if (!This->reOle)
932 return CO_E_RELEASED;
934 FIXME("not implemented\n");
935 return E_NOTIMPL;
938 static HRESULT WINAPI ITextSelection_fnSetFont(
939 ITextSelection *me,
940 ITextFont *pFont)
942 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
943 if (!This->reOle)
944 return CO_E_RELEASED;
946 FIXME("not implemented\n");
947 return E_NOTIMPL;
950 static HRESULT WINAPI ITextSelection_fnGetPara(
951 ITextSelection *me,
952 ITextPara **ppPara)
954 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
955 if (!This->reOle)
956 return CO_E_RELEASED;
958 FIXME("not implemented\n");
959 return E_NOTIMPL;
962 static HRESULT WINAPI ITextSelection_fnSetPara(
963 ITextSelection *me,
964 ITextPara *pPara)
966 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
967 if (!This->reOle)
968 return CO_E_RELEASED;
970 FIXME("not implemented\n");
971 return E_NOTIMPL;
974 static HRESULT WINAPI ITextSelection_fnGetStoryLength(
975 ITextSelection *me,
976 LONG *pcch)
978 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
979 if (!This->reOle)
980 return CO_E_RELEASED;
982 FIXME("not implemented\n");
983 return E_NOTIMPL;
986 static HRESULT WINAPI ITextSelection_fnGetStoryType(
987 ITextSelection *me,
988 LONG *pValue)
990 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
991 if (!This->reOle)
992 return CO_E_RELEASED;
994 FIXME("not implemented\n");
995 return E_NOTIMPL;
998 static HRESULT WINAPI ITextSelection_fnCollapse(
999 ITextSelection *me,
1000 LONG bStart)
1002 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1003 if (!This->reOle)
1004 return CO_E_RELEASED;
1006 FIXME("not implemented\n");
1007 return E_NOTIMPL;
1010 static HRESULT WINAPI ITextSelection_fnExpand(
1011 ITextSelection *me,
1012 LONG Unit,
1013 LONG *pDelta)
1015 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1016 if (!This->reOle)
1017 return CO_E_RELEASED;
1019 FIXME("not implemented\n");
1020 return E_NOTIMPL;
1023 static HRESULT WINAPI ITextSelection_fnGetIndex(
1024 ITextSelection *me,
1025 LONG Unit,
1026 LONG *pIndex)
1028 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1029 if (!This->reOle)
1030 return CO_E_RELEASED;
1032 FIXME("not implemented\n");
1033 return E_NOTIMPL;
1036 static HRESULT WINAPI ITextSelection_fnSetIndex(
1037 ITextSelection *me,
1038 LONG Unit,
1039 LONG Index,
1040 LONG Extend)
1042 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1043 if (!This->reOle)
1044 return CO_E_RELEASED;
1046 FIXME("not implemented\n");
1047 return E_NOTIMPL;
1050 static HRESULT WINAPI ITextSelection_fnSetRange(
1051 ITextSelection *me,
1052 LONG cpActive,
1053 LONG cpOther)
1055 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1056 if (!This->reOle)
1057 return CO_E_RELEASED;
1059 FIXME("not implemented\n");
1060 return E_NOTIMPL;
1063 static HRESULT WINAPI ITextSelection_fnInRange(
1064 ITextSelection *me,
1065 ITextRange *pRange,
1066 LONG *pb)
1068 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1069 if (!This->reOle)
1070 return CO_E_RELEASED;
1072 FIXME("not implemented\n");
1073 return E_NOTIMPL;
1076 static HRESULT WINAPI ITextSelection_fnInStory(
1077 ITextSelection *me,
1078 ITextRange *pRange,
1079 LONG *pb)
1081 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1082 if (!This->reOle)
1083 return CO_E_RELEASED;
1085 FIXME("not implemented\n");
1086 return E_NOTIMPL;
1089 static HRESULT WINAPI ITextSelection_fnIsEqual(
1090 ITextSelection *me,
1091 ITextRange *pRange,
1092 LONG *pb)
1094 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1095 if (!This->reOle)
1096 return CO_E_RELEASED;
1098 FIXME("not implemented\n");
1099 return E_NOTIMPL;
1102 static HRESULT WINAPI ITextSelection_fnSelect(
1103 ITextSelection *me)
1105 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1106 if (!This->reOle)
1107 return CO_E_RELEASED;
1109 FIXME("not implemented\n");
1110 return E_NOTIMPL;
1113 static HRESULT WINAPI ITextSelection_fnStartOf(
1114 ITextSelection *me,
1115 LONG Unit,
1116 LONG Extend,
1117 LONG *pDelta)
1119 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1120 if (!This->reOle)
1121 return CO_E_RELEASED;
1123 FIXME("not implemented\n");
1124 return E_NOTIMPL;
1127 static HRESULT WINAPI ITextSelection_fnEndOf(
1128 ITextSelection *me,
1129 LONG Unit,
1130 LONG Extend,
1131 LONG *pDelta)
1133 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1134 if (!This->reOle)
1135 return CO_E_RELEASED;
1137 FIXME("not implemented\n");
1138 return E_NOTIMPL;
1141 static HRESULT WINAPI ITextSelection_fnMove(
1142 ITextSelection *me,
1143 LONG Unit,
1144 LONG Count,
1145 LONG *pDelta)
1147 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1148 if (!This->reOle)
1149 return CO_E_RELEASED;
1151 FIXME("not implemented\n");
1152 return E_NOTIMPL;
1155 static HRESULT WINAPI ITextSelection_fnMoveStart(
1156 ITextSelection *me,
1157 LONG Unit,
1158 LONG Count,
1159 LONG *pDelta)
1161 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1162 if (!This->reOle)
1163 return CO_E_RELEASED;
1165 FIXME("not implemented\n");
1166 return E_NOTIMPL;
1169 static HRESULT WINAPI ITextSelection_fnMoveEnd(
1170 ITextSelection *me,
1171 LONG Unit,
1172 LONG Count,
1173 LONG *pDelta)
1175 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1176 if (!This->reOle)
1177 return CO_E_RELEASED;
1179 FIXME("not implemented\n");
1180 return E_NOTIMPL;
1183 static HRESULT WINAPI ITextSelection_fnMoveWhile(
1184 ITextSelection *me,
1185 VARIANT *Cset,
1186 LONG Count,
1187 LONG *pDelta)
1189 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1190 if (!This->reOle)
1191 return CO_E_RELEASED;
1193 FIXME("not implemented\n");
1194 return E_NOTIMPL;
1197 static HRESULT WINAPI ITextSelection_fnMoveStartWhile(
1198 ITextSelection *me,
1199 VARIANT *Cset,
1200 LONG Count,
1201 LONG *pDelta)
1203 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1204 if (!This->reOle)
1205 return CO_E_RELEASED;
1207 FIXME("not implemented\n");
1208 return E_NOTIMPL;
1211 static HRESULT WINAPI ITextSelection_fnMoveEndWhile(
1212 ITextSelection *me,
1213 VARIANT *Cset,
1214 LONG Count,
1215 LONG *pDelta)
1217 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1218 if (!This->reOle)
1219 return CO_E_RELEASED;
1221 FIXME("not implemented\n");
1222 return E_NOTIMPL;
1225 static HRESULT WINAPI ITextSelection_fnMoveUntil(
1226 ITextSelection *me,
1227 VARIANT *Cset,
1228 LONG Count,
1229 LONG *pDelta)
1231 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1232 if (!This->reOle)
1233 return CO_E_RELEASED;
1235 FIXME("not implemented\n");
1236 return E_NOTIMPL;
1239 static HRESULT WINAPI ITextSelection_fnMoveStartUntil(
1240 ITextSelection *me,
1241 VARIANT *Cset,
1242 LONG Count,
1243 LONG *pDelta)
1245 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1246 if (!This->reOle)
1247 return CO_E_RELEASED;
1249 FIXME("not implemented\n");
1250 return E_NOTIMPL;
1253 static HRESULT WINAPI ITextSelection_fnMoveEndUntil(
1254 ITextSelection *me,
1255 VARIANT *Cset,
1256 LONG Count,
1257 LONG *pDelta)
1259 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1260 if (!This->reOle)
1261 return CO_E_RELEASED;
1263 FIXME("not implemented\n");
1264 return E_NOTIMPL;
1267 static HRESULT WINAPI ITextSelection_fnFindText(
1268 ITextSelection *me,
1269 BSTR bstr,
1270 LONG cch,
1271 LONG Flags,
1272 LONG *pLength)
1274 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1275 if (!This->reOle)
1276 return CO_E_RELEASED;
1278 FIXME("not implemented\n");
1279 return E_NOTIMPL;
1282 static HRESULT WINAPI ITextSelection_fnFindTextStart(
1283 ITextSelection *me,
1284 BSTR bstr,
1285 LONG cch,
1286 LONG Flags,
1287 LONG *pLength)
1289 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1290 if (!This->reOle)
1291 return CO_E_RELEASED;
1293 FIXME("not implemented\n");
1294 return E_NOTIMPL;
1297 static HRESULT WINAPI ITextSelection_fnFindTextEnd(
1298 ITextSelection *me,
1299 BSTR bstr,
1300 LONG cch,
1301 LONG Flags,
1302 LONG *pLength)
1304 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1305 if (!This->reOle)
1306 return CO_E_RELEASED;
1308 FIXME("not implemented\n");
1309 return E_NOTIMPL;
1312 static HRESULT WINAPI ITextSelection_fnDelete(
1313 ITextSelection *me,
1314 LONG Unit,
1315 LONG Count,
1316 LONG *pDelta)
1318 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1319 if (!This->reOle)
1320 return CO_E_RELEASED;
1322 FIXME("not implemented\n");
1323 return E_NOTIMPL;
1326 static HRESULT WINAPI ITextSelection_fnCut(
1327 ITextSelection *me,
1328 VARIANT *pVar)
1330 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1331 if (!This->reOle)
1332 return CO_E_RELEASED;
1334 FIXME("not implemented\n");
1335 return E_NOTIMPL;
1338 static HRESULT WINAPI ITextSelection_fnCopy(
1339 ITextSelection *me,
1340 VARIANT *pVar)
1342 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1343 if (!This->reOle)
1344 return CO_E_RELEASED;
1346 FIXME("not implemented\n");
1347 return E_NOTIMPL;
1350 static HRESULT WINAPI ITextSelection_fnPaste(
1351 ITextSelection *me,
1352 VARIANT *pVar,
1353 LONG Format)
1355 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1356 if (!This->reOle)
1357 return CO_E_RELEASED;
1359 FIXME("not implemented\n");
1360 return E_NOTIMPL;
1363 static HRESULT WINAPI ITextSelection_fnCanPaste(
1364 ITextSelection *me,
1365 VARIANT *pVar,
1366 LONG Format,
1367 LONG *pb)
1369 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1370 if (!This->reOle)
1371 return CO_E_RELEASED;
1373 FIXME("not implemented\n");
1374 return E_NOTIMPL;
1377 static HRESULT WINAPI ITextSelection_fnCanEdit(
1378 ITextSelection *me,
1379 LONG *pb)
1381 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1382 if (!This->reOle)
1383 return CO_E_RELEASED;
1385 FIXME("not implemented\n");
1386 return E_NOTIMPL;
1389 static HRESULT WINAPI ITextSelection_fnChangeCase(
1390 ITextSelection *me,
1391 LONG Type)
1393 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1394 if (!This->reOle)
1395 return CO_E_RELEASED;
1397 FIXME("not implemented\n");
1398 return E_NOTIMPL;
1401 static HRESULT WINAPI ITextSelection_fnGetPoint(
1402 ITextSelection *me,
1403 LONG Type,
1404 LONG *cx,
1405 LONG *cy)
1407 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1408 if (!This->reOle)
1409 return CO_E_RELEASED;
1411 FIXME("not implemented\n");
1412 return E_NOTIMPL;
1415 static HRESULT WINAPI ITextSelection_fnSetPoint(
1416 ITextSelection *me,
1417 LONG x,
1418 LONG y,
1419 LONG Type,
1420 LONG Extend)
1422 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1423 if (!This->reOle)
1424 return CO_E_RELEASED;
1426 FIXME("not implemented\n");
1427 return E_NOTIMPL;
1430 static HRESULT WINAPI ITextSelection_fnScrollIntoView(
1431 ITextSelection *me,
1432 LONG Value)
1434 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1435 if (!This->reOle)
1436 return CO_E_RELEASED;
1438 FIXME("not implemented\n");
1439 return E_NOTIMPL;
1442 static HRESULT WINAPI ITextSelection_fnGetEmbeddedObject(
1443 ITextSelection *me,
1444 IUnknown **ppv)
1446 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1447 if (!This->reOle)
1448 return CO_E_RELEASED;
1450 FIXME("not implemented\n");
1451 return E_NOTIMPL;
1454 /*** ITextSelection methods ***/
1455 static HRESULT WINAPI ITextSelection_fnGetFlags(
1456 ITextSelection *me,
1457 LONG *pFlags)
1459 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1460 if (!This->reOle)
1461 return CO_E_RELEASED;
1463 FIXME("not implemented\n");
1464 return E_NOTIMPL;
1467 static HRESULT WINAPI ITextSelection_fnSetFlags(
1468 ITextSelection *me,
1469 LONG Flags)
1471 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1472 if (!This->reOle)
1473 return CO_E_RELEASED;
1475 FIXME("not implemented\n");
1476 return E_NOTIMPL;
1479 static HRESULT WINAPI ITextSelection_fnGetType(
1480 ITextSelection *me,
1481 LONG *pType)
1483 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1484 if (!This->reOle)
1485 return CO_E_RELEASED;
1487 FIXME("not implemented\n");
1488 return E_NOTIMPL;
1491 static HRESULT WINAPI ITextSelection_fnMoveLeft(
1492 ITextSelection *me,
1493 LONG Unit,
1494 LONG Count,
1495 LONG Extend,
1496 LONG *pDelta)
1498 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1499 if (!This->reOle)
1500 return CO_E_RELEASED;
1502 FIXME("not implemented\n");
1503 return E_NOTIMPL;
1506 static HRESULT WINAPI ITextSelection_fnMoveRight(
1507 ITextSelection *me,
1508 LONG Unit,
1509 LONG Count,
1510 LONG Extend,
1511 LONG *pDelta)
1513 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1514 if (!This->reOle)
1515 return CO_E_RELEASED;
1517 FIXME("not implemented\n");
1518 return E_NOTIMPL;
1521 static HRESULT WINAPI ITextSelection_fnMoveUp(
1522 ITextSelection *me,
1523 LONG Unit,
1524 LONG Count,
1525 LONG Extend,
1526 LONG *pDelta)
1528 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1529 if (!This->reOle)
1530 return CO_E_RELEASED;
1532 FIXME("not implemented\n");
1533 return E_NOTIMPL;
1536 static HRESULT WINAPI ITextSelection_fnMoveDown(
1537 ITextSelection *me,
1538 LONG Unit,
1539 LONG Count,
1540 LONG Extend,
1541 LONG *pDelta)
1543 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1544 if (!This->reOle)
1545 return CO_E_RELEASED;
1547 FIXME("not implemented\n");
1548 return E_NOTIMPL;
1551 static HRESULT WINAPI ITextSelection_fnHomeKey(
1552 ITextSelection *me,
1553 LONG Unit,
1554 LONG Extend,
1555 LONG *pDelta)
1557 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1558 if (!This->reOle)
1559 return CO_E_RELEASED;
1561 FIXME("not implemented\n");
1562 return E_NOTIMPL;
1565 static HRESULT WINAPI ITextSelection_fnEndKey(
1566 ITextSelection *me,
1567 LONG Unit,
1568 LONG Extend,
1569 LONG *pDelta)
1571 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1572 if (!This->reOle)
1573 return CO_E_RELEASED;
1575 FIXME("not implemented\n");
1576 return E_NOTIMPL;
1579 static HRESULT WINAPI ITextSelection_fnTypeText(
1580 ITextSelection *me,
1581 BSTR bstr)
1583 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1584 if (!This->reOle)
1585 return CO_E_RELEASED;
1587 FIXME("not implemented\n");
1588 return E_NOTIMPL;
1591 static const ITextSelectionVtbl tsvt = {
1592 ITextSelection_fnQueryInterface,
1593 ITextSelection_fnAddRef,
1594 ITextSelection_fnRelease,
1595 ITextSelection_fnGetTypeInfoCount,
1596 ITextSelection_fnGetTypeInfo,
1597 ITextSelection_fnGetIDsOfNames,
1598 ITextSelection_fnInvoke,
1599 ITextSelection_fnGetText,
1600 ITextSelection_fnSetText,
1601 ITextSelection_fnGetChar,
1602 ITextSelection_fnSetChar,
1603 ITextSelection_fnGetDuplicate,
1604 ITextSelection_fnGetFormattedText,
1605 ITextSelection_fnSetFormattedText,
1606 ITextSelection_fnGetStart,
1607 ITextSelection_fnSetStart,
1608 ITextSelection_fnGetEnd,
1609 ITextSelection_fnSetEnd,
1610 ITextSelection_fnGetFont,
1611 ITextSelection_fnSetFont,
1612 ITextSelection_fnGetPara,
1613 ITextSelection_fnSetPara,
1614 ITextSelection_fnGetStoryLength,
1615 ITextSelection_fnGetStoryType,
1616 ITextSelection_fnCollapse,
1617 ITextSelection_fnExpand,
1618 ITextSelection_fnGetIndex,
1619 ITextSelection_fnSetIndex,
1620 ITextSelection_fnSetRange,
1621 ITextSelection_fnInRange,
1622 ITextSelection_fnInStory,
1623 ITextSelection_fnIsEqual,
1624 ITextSelection_fnSelect,
1625 ITextSelection_fnStartOf,
1626 ITextSelection_fnEndOf,
1627 ITextSelection_fnMove,
1628 ITextSelection_fnMoveStart,
1629 ITextSelection_fnMoveEnd,
1630 ITextSelection_fnMoveWhile,
1631 ITextSelection_fnMoveStartWhile,
1632 ITextSelection_fnMoveEndWhile,
1633 ITextSelection_fnMoveUntil,
1634 ITextSelection_fnMoveStartUntil,
1635 ITextSelection_fnMoveEndUntil,
1636 ITextSelection_fnFindText,
1637 ITextSelection_fnFindTextStart,
1638 ITextSelection_fnFindTextEnd,
1639 ITextSelection_fnDelete,
1640 ITextSelection_fnCut,
1641 ITextSelection_fnCopy,
1642 ITextSelection_fnPaste,
1643 ITextSelection_fnCanPaste,
1644 ITextSelection_fnCanEdit,
1645 ITextSelection_fnChangeCase,
1646 ITextSelection_fnGetPoint,
1647 ITextSelection_fnSetPoint,
1648 ITextSelection_fnScrollIntoView,
1649 ITextSelection_fnGetEmbeddedObject,
1650 ITextSelection_fnGetFlags,
1651 ITextSelection_fnSetFlags,
1652 ITextSelection_fnGetType,
1653 ITextSelection_fnMoveLeft,
1654 ITextSelection_fnMoveRight,
1655 ITextSelection_fnMoveUp,
1656 ITextSelection_fnMoveDown,
1657 ITextSelection_fnHomeKey,
1658 ITextSelection_fnEndKey,
1659 ITextSelection_fnTypeText
1662 static ITextSelectionImpl *
1663 CreateTextSelection(IRichEditOleImpl *reOle)
1665 ITextSelectionImpl *txtSel = heap_alloc(sizeof *txtSel);
1666 if (!txtSel)
1667 return NULL;
1669 txtSel->lpVtbl = &tsvt;
1670 txtSel->ref = 1;
1671 txtSel->reOle = reOle;
1672 return txtSel;
1675 LRESULT CreateIRichEditOle(ME_TextEditor *editor, LPVOID *ppObj)
1677 IRichEditOleImpl *reo;
1679 reo = heap_alloc(sizeof(IRichEditOleImpl));
1680 if (!reo)
1681 return 0;
1683 reo->lpRichEditOleVtbl = &revt;
1684 reo->lpTextDocumentVtbl = &tdvt;
1685 reo->ref = 1;
1686 reo->editor = editor;
1687 reo->txtSel = CreateTextSelection(reo);
1688 if (!reo->txtSel)
1690 heap_free(reo);
1691 return 0;
1693 reo->clientSite = CreateOleClientSite(reo);
1694 if (!reo->txtSel)
1696 ITextSelection_Release((ITextSelection *) reo->txtSel);
1697 heap_free(reo);
1698 return 0;
1700 TRACE("Created %p\n",reo);
1701 *ppObj = reo;
1703 return 1;
1706 static void convert_sizel(ME_Context *c, const SIZEL* szl, SIZE* sz)
1708 /* sizel is in .01 millimeters, sz in pixels */
1709 sz->cx = MulDiv(szl->cx, c->dpi.cx, 2540);
1710 sz->cy = MulDiv(szl->cy, c->dpi.cy, 2540);
1713 /******************************************************************************
1714 * ME_GetOLEObjectSize
1716 * Sets run extent for OLE objects.
1718 void ME_GetOLEObjectSize(ME_Context *c, ME_Run *run, SIZE *pSize)
1720 IDataObject* ido;
1721 FORMATETC fmt;
1722 STGMEDIUM stgm;
1723 DIBSECTION dibsect;
1724 ENHMETAHEADER emh;
1726 assert(run->nFlags & MERF_GRAPHICS);
1727 assert(run->ole_obj);
1729 if (run->ole_obj->sizel.cx != 0 || run->ole_obj->sizel.cy != 0)
1731 convert_sizel(c, &run->ole_obj->sizel, pSize);
1732 return;
1735 IOleObject_QueryInterface(run->ole_obj->poleobj, &IID_IDataObject, (void**)&ido);
1736 fmt.cfFormat = CF_BITMAP;
1737 fmt.ptd = NULL;
1738 fmt.dwAspect = DVASPECT_CONTENT;
1739 fmt.lindex = -1;
1740 fmt.tymed = TYMED_GDI;
1741 if (IDataObject_GetData(ido, &fmt, &stgm) != S_OK)
1743 fmt.cfFormat = CF_ENHMETAFILE;
1744 fmt.tymed = TYMED_ENHMF;
1745 if (IDataObject_GetData(ido, &fmt, &stgm) != S_OK)
1747 FIXME("unsupported format\n");
1748 pSize->cx = pSize->cy = 0;
1749 IDataObject_Release(ido);
1750 return;
1754 switch (stgm.tymed)
1756 case TYMED_GDI:
1757 GetObjectW(stgm.u.hBitmap, sizeof(dibsect), &dibsect);
1758 pSize->cx = dibsect.dsBm.bmWidth;
1759 pSize->cy = dibsect.dsBm.bmHeight;
1760 if (!stgm.pUnkForRelease) DeleteObject(stgm.u.hBitmap);
1761 break;
1762 case TYMED_ENHMF:
1763 GetEnhMetaFileHeader(stgm.u.hEnhMetaFile, sizeof(emh), &emh);
1764 pSize->cx = emh.rclBounds.right - emh.rclBounds.left;
1765 pSize->cy = emh.rclBounds.bottom - emh.rclBounds.top;
1766 if (!stgm.pUnkForRelease) DeleteEnhMetaFile(stgm.u.hEnhMetaFile);
1767 break;
1768 default:
1769 FIXME("Unsupported tymed %d\n", stgm.tymed);
1770 break;
1772 IDataObject_Release(ido);
1773 if (c->editor->nZoomNumerator != 0)
1775 pSize->cx = MulDiv(pSize->cx, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
1776 pSize->cy = MulDiv(pSize->cy, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
1780 void ME_DrawOLE(ME_Context *c, int x, int y, ME_Run *run,
1781 ME_Paragraph *para, BOOL selected)
1783 IDataObject* ido;
1784 FORMATETC fmt;
1785 STGMEDIUM stgm;
1786 DIBSECTION dibsect;
1787 ENHMETAHEADER emh;
1788 HDC hMemDC;
1789 SIZE sz;
1790 BOOL has_size;
1792 assert(run->nFlags & MERF_GRAPHICS);
1793 assert(run->ole_obj);
1794 if (IOleObject_QueryInterface(run->ole_obj->poleobj, &IID_IDataObject, (void**)&ido) != S_OK)
1796 FIXME("Couldn't get interface\n");
1797 return;
1799 has_size = run->ole_obj->sizel.cx != 0 || run->ole_obj->sizel.cy != 0;
1800 fmt.cfFormat = CF_BITMAP;
1801 fmt.ptd = NULL;
1802 fmt.dwAspect = DVASPECT_CONTENT;
1803 fmt.lindex = -1;
1804 fmt.tymed = TYMED_GDI;
1805 if (IDataObject_GetData(ido, &fmt, &stgm) != S_OK)
1807 fmt.cfFormat = CF_ENHMETAFILE;
1808 fmt.tymed = TYMED_ENHMF;
1809 if (IDataObject_GetData(ido, &fmt, &stgm) != S_OK)
1811 FIXME("Couldn't get storage medium\n");
1812 IDataObject_Release(ido);
1813 return;
1816 switch (stgm.tymed)
1818 case TYMED_GDI:
1819 GetObjectW(stgm.u.hBitmap, sizeof(dibsect), &dibsect);
1820 hMemDC = CreateCompatibleDC(c->hDC);
1821 SelectObject(hMemDC, stgm.u.hBitmap);
1822 if (!has_size && c->editor->nZoomNumerator == 0)
1824 sz.cx = dibsect.dsBm.bmWidth;
1825 sz.cy = dibsect.dsBm.bmHeight;
1826 BitBlt(c->hDC, x, y - dibsect.dsBm.bmHeight,
1827 dibsect.dsBm.bmWidth, dibsect.dsBm.bmHeight,
1828 hMemDC, 0, 0, SRCCOPY);
1830 else
1832 if (has_size)
1834 convert_sizel(c, &run->ole_obj->sizel, &sz);
1836 else
1838 sz.cx = MulDiv(dibsect.dsBm.bmWidth,
1839 c->editor->nZoomNumerator, c->editor->nZoomDenominator);
1840 sz.cy = MulDiv(dibsect.dsBm.bmHeight,
1841 c->editor->nZoomNumerator, c->editor->nZoomDenominator);
1843 StretchBlt(c->hDC, x, y - sz.cy, sz.cx, sz.cy,
1844 hMemDC, 0, 0, dibsect.dsBm.bmWidth, dibsect.dsBm.bmHeight, SRCCOPY);
1846 if (!stgm.pUnkForRelease) DeleteObject(stgm.u.hBitmap);
1847 break;
1848 case TYMED_ENHMF:
1849 GetEnhMetaFileHeader(stgm.u.hEnhMetaFile, sizeof(emh), &emh);
1850 if (!has_size && c->editor->nZoomNumerator == 0)
1852 sz.cy = emh.rclBounds.bottom - emh.rclBounds.top;
1853 sz.cx = emh.rclBounds.right - emh.rclBounds.left;
1855 else
1857 if (has_size)
1859 convert_sizel(c, &run->ole_obj->sizel, &sz);
1861 else
1863 sz.cy = MulDiv(emh.rclBounds.bottom - emh.rclBounds.top,
1864 c->editor->nZoomNumerator, c->editor->nZoomDenominator);
1865 sz.cx = MulDiv(emh.rclBounds.right - emh.rclBounds.left,
1866 c->editor->nZoomNumerator, c->editor->nZoomDenominator);
1870 RECT rc;
1872 rc.left = x;
1873 rc.top = y - sz.cy;
1874 rc.right = x + sz.cx;
1875 rc.bottom = y;
1876 PlayEnhMetaFile(c->hDC, stgm.u.hEnhMetaFile, &rc);
1878 if (!stgm.pUnkForRelease) DeleteEnhMetaFile(stgm.u.hEnhMetaFile);
1879 break;
1880 default:
1881 FIXME("Unsupported tymed %d\n", stgm.tymed);
1882 selected = FALSE;
1883 break;
1885 if (selected && !c->editor->bHideSelection)
1886 PatBlt(c->hDC, x, y - sz.cy, sz.cx, sz.cy, DSTINVERT);
1887 IDataObject_Release(ido);
1890 void ME_DeleteReObject(REOBJECT* reo)
1892 if (reo->poleobj) IOleObject_Release(reo->poleobj);
1893 if (reo->pstg) IStorage_Release(reo->pstg);
1894 if (reo->polesite) IOleClientSite_Release(reo->polesite);
1895 FREE_OBJ(reo);
1898 void ME_CopyReObject(REOBJECT* dst, const REOBJECT* src)
1900 *dst = *src;
1902 if (dst->poleobj) IOleObject_AddRef(dst->poleobj);
1903 if (dst->pstg) IStorage_AddRef(dst->pstg);
1904 if (dst->polesite) IOleClientSite_AddRef(dst->polesite);