dplayx: Adjust GetCaps behaviour to documentation
[wine/gsoc_dplay.git] / dlls / riched20 / richole.c
blob2a9dc0151a009d66f8212c56431be10c6f161b24
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;
391 if (reo->poleobj) IOleObject_AddRef(reo->poleobj);
392 if (reo->pstg) IStorage_AddRef(reo->pstg);
393 if (reo->polesite) IOleClientSite_AddRef(reo->polesite);
395 ME_InsertOLEFromCursor(This->editor, reo, 0);
396 ME_CommitUndo(This->editor);
397 ME_UpdateRepaint(This->editor);
398 return S_OK;
401 static HRESULT WINAPI IRichEditOle_fnSaveCompleted(IRichEditOle *me, LONG iob,
402 LPSTORAGE lpstg)
404 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
405 FIXME("stub %p\n",This);
406 return E_NOTIMPL;
409 static HRESULT WINAPI
410 IRichEditOle_fnSetDvaspect(IRichEditOle *me, LONG iob, DWORD dvaspect)
412 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
413 FIXME("stub %p\n",This);
414 return E_NOTIMPL;
417 static HRESULT WINAPI IRichEditOle_fnSetHostNames(IRichEditOle *me,
418 LPCSTR lpstrContainerApp, LPCSTR lpstrContainerObj)
420 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
421 FIXME("stub %p %s %s\n",This, lpstrContainerApp, lpstrContainerObj);
422 return E_NOTIMPL;
425 static HRESULT WINAPI
426 IRichEditOle_fnSetLinkAvailable(IRichEditOle *me, LONG iob, BOOL fAvailable)
428 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
429 FIXME("stub %p\n",This);
430 return E_NOTIMPL;
433 static const IRichEditOleVtbl revt = {
434 IRichEditOle_fnQueryInterface,
435 IRichEditOle_fnAddRef,
436 IRichEditOle_fnRelease,
437 IRichEditOle_fnGetClientSite,
438 IRichEditOle_fnGetObjectCount,
439 IRichEditOle_fnGetLinkCount,
440 IRichEditOle_fnGetObject,
441 IRichEditOle_fnInsertObject,
442 IRichEditOle_fnConvertObject,
443 IRichEditOle_fnActivateAs,
444 IRichEditOle_fnSetHostNames,
445 IRichEditOle_fnSetLinkAvailable,
446 IRichEditOle_fnSetDvaspect,
447 IRichEditOle_fnHandsOffStorage,
448 IRichEditOle_fnSaveCompleted,
449 IRichEditOle_fnInPlaceDeactivate,
450 IRichEditOle_fnContextSensitiveHelp,
451 IRichEditOle_fnGetClipboardData,
452 IRichEditOle_fnImportDataObject
455 static HRESULT WINAPI
456 ITextDocument_fnQueryInterface(ITextDocument* me, REFIID riid,
457 void** ppvObject)
459 IRichEditOleImpl *This = impl_from_ITextDocument(me);
460 return IRichEditOle_fnQueryInterface((IRichEditOle*)&This->lpRichEditOleVtbl,
461 riid, ppvObject);
464 static ULONG WINAPI
465 ITextDocument_fnAddRef(ITextDocument* me)
467 IRichEditOleImpl *This = impl_from_ITextDocument(me);
468 return IRichEditOle_fnAddRef((IRichEditOle*)&This->lpRichEditOleVtbl);
471 static ULONG WINAPI
472 ITextDocument_fnRelease(ITextDocument* me)
474 IRichEditOleImpl *This = impl_from_ITextDocument(me);
475 return IRichEditOle_fnRelease((IRichEditOle*)&This->lpRichEditOleVtbl);
478 static HRESULT WINAPI
479 ITextDocument_fnGetTypeInfoCount(ITextDocument* me,
480 UINT* pctinfo)
482 IRichEditOleImpl *This = impl_from_ITextDocument(me);
483 FIXME("stub %p\n",This);
484 return E_NOTIMPL;
487 static HRESULT WINAPI
488 ITextDocument_fnGetTypeInfo(ITextDocument* me, UINT iTInfo, LCID lcid,
489 ITypeInfo** ppTInfo)
491 IRichEditOleImpl *This = impl_from_ITextDocument(me);
492 FIXME("stub %p\n",This);
493 return E_NOTIMPL;
496 static HRESULT WINAPI
497 ITextDocument_fnGetIDsOfNames(ITextDocument* me, REFIID riid,
498 LPOLESTR* rgszNames, UINT cNames, LCID lcid, DISPID* rgDispId)
500 IRichEditOleImpl *This = impl_from_ITextDocument(me);
501 FIXME("stub %p\n",This);
502 return E_NOTIMPL;
505 static HRESULT WINAPI
506 ITextDocument_fnInvoke(ITextDocument* me, DISPID dispIdMember,
507 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS* pDispParams,
508 VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr)
510 IRichEditOleImpl *This = impl_from_ITextDocument(me);
511 FIXME("stub %p\n",This);
512 return E_NOTIMPL;
515 static HRESULT WINAPI
516 ITextDocument_fnGetName(ITextDocument* me, BSTR* pName)
518 IRichEditOleImpl *This = impl_from_ITextDocument(me);
519 FIXME("stub %p\n",This);
520 return E_NOTIMPL;
523 static HRESULT WINAPI
524 ITextDocument_fnGetSelection(ITextDocument* me, ITextSelection** ppSel)
526 IRichEditOleImpl *This = impl_from_ITextDocument(me);
527 TRACE("(%p)\n", me);
528 *ppSel = (ITextSelection *) This->txtSel;
529 ITextSelection_AddRef(*ppSel);
530 return S_OK;
533 static HRESULT WINAPI
534 ITextDocument_fnGetStoryCount(ITextDocument* me, LONG* pCount)
536 IRichEditOleImpl *This = impl_from_ITextDocument(me);
537 FIXME("stub %p\n",This);
538 return E_NOTIMPL;
541 static HRESULT WINAPI
542 ITextDocument_fnGetStoryRanges(ITextDocument* me,
543 ITextStoryRanges** ppStories)
545 IRichEditOleImpl *This = impl_from_ITextDocument(me);
546 FIXME("stub %p\n",This);
547 return E_NOTIMPL;
550 static HRESULT WINAPI
551 ITextDocument_fnGetSaved(ITextDocument* me, LONG* pValue)
553 IRichEditOleImpl *This = impl_from_ITextDocument(me);
554 FIXME("stub %p\n",This);
555 return E_NOTIMPL;
558 static HRESULT WINAPI
559 ITextDocument_fnSetSaved(ITextDocument* me, LONG Value)
561 IRichEditOleImpl *This = impl_from_ITextDocument(me);
562 FIXME("stub %p\n",This);
563 return E_NOTIMPL;
566 static HRESULT WINAPI
567 ITextDocument_fnGetDefaultTabStop(ITextDocument* me, float* pValue)
569 IRichEditOleImpl *This = impl_from_ITextDocument(me);
570 FIXME("stub %p\n",This);
571 return E_NOTIMPL;
574 static HRESULT WINAPI
575 ITextDocument_fnSetDefaultTabStop(ITextDocument* me, float Value)
577 IRichEditOleImpl *This = impl_from_ITextDocument(me);
578 FIXME("stub %p\n",This);
579 return E_NOTIMPL;
582 static HRESULT WINAPI
583 ITextDocument_fnNew(ITextDocument* me)
585 IRichEditOleImpl *This = impl_from_ITextDocument(me);
586 FIXME("stub %p\n",This);
587 return E_NOTIMPL;
590 static HRESULT WINAPI
591 ITextDocument_fnOpen(ITextDocument* me, VARIANT* pVar, LONG Flags,
592 LONG CodePage)
594 IRichEditOleImpl *This = impl_from_ITextDocument(me);
595 FIXME("stub %p\n",This);
596 return E_NOTIMPL;
599 static HRESULT WINAPI
600 ITextDocument_fnSave(ITextDocument* me, VARIANT* pVar, LONG Flags,
601 LONG CodePage)
603 IRichEditOleImpl *This = impl_from_ITextDocument(me);
604 FIXME("stub %p\n",This);
605 return E_NOTIMPL;
608 static HRESULT WINAPI
609 ITextDocument_fnFreeze(ITextDocument* me, LONG* pCount)
611 IRichEditOleImpl *This = impl_from_ITextDocument(me);
612 FIXME("stub %p\n",This);
613 return E_NOTIMPL;
616 static HRESULT WINAPI
617 ITextDocument_fnUnfreeze(ITextDocument* me, LONG* pCount)
619 IRichEditOleImpl *This = impl_from_ITextDocument(me);
620 FIXME("stub %p\n",This);
621 return E_NOTIMPL;
624 static HRESULT WINAPI
625 ITextDocument_fnBeginEditCollection(ITextDocument* me)
627 IRichEditOleImpl *This = impl_from_ITextDocument(me);
628 FIXME("stub %p\n",This);
629 return E_NOTIMPL;
632 static HRESULT WINAPI
633 ITextDocument_fnEndEditCollection(ITextDocument* me)
635 IRichEditOleImpl *This = impl_from_ITextDocument(me);
636 FIXME("stub %p\n",This);
637 return E_NOTIMPL;
640 static HRESULT WINAPI
641 ITextDocument_fnUndo(ITextDocument* me, LONG Count, LONG* prop)
643 IRichEditOleImpl *This = impl_from_ITextDocument(me);
644 FIXME("stub %p\n",This);
645 return E_NOTIMPL;
648 static HRESULT WINAPI
649 ITextDocument_fnRedo(ITextDocument* me, LONG Count, LONG* prop)
651 IRichEditOleImpl *This = impl_from_ITextDocument(me);
652 FIXME("stub %p\n",This);
653 return E_NOTIMPL;
656 static HRESULT WINAPI
657 ITextDocument_fnRange(ITextDocument* me, LONG cp1, LONG cp2,
658 ITextRange** ppRange)
660 IRichEditOleImpl *This = impl_from_ITextDocument(me);
661 FIXME("stub %p\n",This);
662 return E_NOTIMPL;
665 static HRESULT WINAPI
666 ITextDocument_fnRangeFromPoint(ITextDocument* me, LONG x, LONG y,
667 ITextRange** ppRange)
669 IRichEditOleImpl *This = impl_from_ITextDocument(me);
670 FIXME("stub %p\n",This);
671 return E_NOTIMPL;
674 static const ITextDocumentVtbl tdvt = {
675 ITextDocument_fnQueryInterface,
676 ITextDocument_fnAddRef,
677 ITextDocument_fnRelease,
678 ITextDocument_fnGetTypeInfoCount,
679 ITextDocument_fnGetTypeInfo,
680 ITextDocument_fnGetIDsOfNames,
681 ITextDocument_fnInvoke,
682 ITextDocument_fnGetName,
683 ITextDocument_fnGetSelection,
684 ITextDocument_fnGetStoryCount,
685 ITextDocument_fnGetStoryRanges,
686 ITextDocument_fnGetSaved,
687 ITextDocument_fnSetSaved,
688 ITextDocument_fnGetDefaultTabStop,
689 ITextDocument_fnSetDefaultTabStop,
690 ITextDocument_fnNew,
691 ITextDocument_fnOpen,
692 ITextDocument_fnSave,
693 ITextDocument_fnFreeze,
694 ITextDocument_fnUnfreeze,
695 ITextDocument_fnBeginEditCollection,
696 ITextDocument_fnEndEditCollection,
697 ITextDocument_fnUndo,
698 ITextDocument_fnRedo,
699 ITextDocument_fnRange,
700 ITextDocument_fnRangeFromPoint
703 static HRESULT WINAPI ITextSelection_fnQueryInterface(
704 ITextSelection *me,
705 REFIID riid,
706 void **ppvObj)
708 *ppvObj = NULL;
709 if (IsEqualGUID(riid, &IID_IUnknown)
710 || IsEqualGUID(riid, &IID_IDispatch)
711 || IsEqualGUID(riid, &IID_ITextRange)
712 || IsEqualGUID(riid, &IID_ITextSelection))
714 *ppvObj = me;
715 ITextSelection_AddRef(me);
716 return S_OK;
719 return E_NOINTERFACE;
722 static ULONG WINAPI ITextSelection_fnAddRef(
723 ITextSelection *me)
725 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
726 return InterlockedIncrement(&This->ref);
729 static ULONG WINAPI ITextSelection_fnRelease(
730 ITextSelection *me)
732 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
733 ULONG ref = InterlockedDecrement(&This->ref);
734 if (ref == 0)
735 heap_free(This);
736 return ref;
739 static HRESULT WINAPI ITextSelection_fnGetTypeInfoCount(
740 ITextSelection *me,
741 UINT *pctinfo)
743 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
744 if (!This->reOle)
745 return CO_E_RELEASED;
747 FIXME("not implemented\n");
748 return E_NOTIMPL;
751 static HRESULT WINAPI ITextSelection_fnGetTypeInfo(
752 ITextSelection *me,
753 UINT iTInfo,
754 LCID lcid,
755 ITypeInfo **ppTInfo)
757 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
758 if (!This->reOle)
759 return CO_E_RELEASED;
761 FIXME("not implemented\n");
762 return E_NOTIMPL;
765 static HRESULT WINAPI ITextSelection_fnGetIDsOfNames(
766 ITextSelection *me,
767 REFIID riid,
768 LPOLESTR *rgszNames,
769 UINT cNames,
770 LCID lcid,
771 DISPID *rgDispId)
773 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
774 if (!This->reOle)
775 return CO_E_RELEASED;
777 FIXME("not implemented\n");
778 return E_NOTIMPL;
781 static HRESULT WINAPI ITextSelection_fnInvoke(
782 ITextSelection *me,
783 DISPID dispIdMember,
784 REFIID riid,
785 LCID lcid,
786 WORD wFlags,
787 DISPPARAMS *pDispParams,
788 VARIANT *pVarResult,
789 EXCEPINFO *pExcepInfo,
790 UINT *puArgErr)
792 FIXME("not implemented\n");
793 return E_NOTIMPL;
796 /*** ITextRange methods ***/
797 static HRESULT WINAPI ITextSelection_fnGetText(
798 ITextSelection *me,
799 BSTR *pbstr)
801 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
802 if (!This->reOle)
803 return CO_E_RELEASED;
805 FIXME("not implemented\n");
806 return E_NOTIMPL;
809 static HRESULT WINAPI ITextSelection_fnSetText(
810 ITextSelection *me,
811 BSTR bstr)
813 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
814 if (!This->reOle)
815 return CO_E_RELEASED;
817 FIXME("not implemented\n");
818 return E_NOTIMPL;
821 static HRESULT WINAPI ITextSelection_fnGetChar(
822 ITextSelection *me,
823 LONG *pch)
825 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
826 if (!This->reOle)
827 return CO_E_RELEASED;
829 FIXME("not implemented\n");
830 return E_NOTIMPL;
833 static HRESULT WINAPI ITextSelection_fnSetChar(
834 ITextSelection *me,
835 LONG ch)
837 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
838 if (!This->reOle)
839 return CO_E_RELEASED;
841 FIXME("not implemented\n");
842 return E_NOTIMPL;
845 static HRESULT WINAPI ITextSelection_fnGetDuplicate(
846 ITextSelection *me,
847 ITextRange **ppRange)
849 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
850 if (!This->reOle)
851 return CO_E_RELEASED;
853 FIXME("not implemented\n");
854 return E_NOTIMPL;
857 static HRESULT WINAPI ITextSelection_fnGetFormattedText(
858 ITextSelection *me,
859 ITextRange **ppRange)
861 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
862 if (!This->reOle)
863 return CO_E_RELEASED;
865 FIXME("not implemented\n");
866 return E_NOTIMPL;
869 static HRESULT WINAPI ITextSelection_fnSetFormattedText(
870 ITextSelection *me,
871 ITextRange *pRange)
873 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
874 if (!This->reOle)
875 return CO_E_RELEASED;
877 FIXME("not implemented\n");
878 return E_NOTIMPL;
881 static HRESULT WINAPI ITextSelection_fnGetStart(
882 ITextSelection *me,
883 LONG *pcpFirst)
885 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
886 if (!This->reOle)
887 return CO_E_RELEASED;
889 FIXME("not implemented\n");
890 return E_NOTIMPL;
893 static HRESULT WINAPI ITextSelection_fnSetStart(
894 ITextSelection *me,
895 LONG cpFirst)
897 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
898 if (!This->reOle)
899 return CO_E_RELEASED;
901 FIXME("not implemented\n");
902 return E_NOTIMPL;
905 static HRESULT WINAPI ITextSelection_fnGetEnd(
906 ITextSelection *me,
907 LONG *pcpLim)
909 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
910 if (!This->reOle)
911 return CO_E_RELEASED;
913 FIXME("not implemented\n");
914 return E_NOTIMPL;
917 static HRESULT WINAPI ITextSelection_fnSetEnd(
918 ITextSelection *me,
919 LONG cpLim)
921 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
922 if (!This->reOle)
923 return CO_E_RELEASED;
925 FIXME("not implemented\n");
926 return E_NOTIMPL;
929 static HRESULT WINAPI ITextSelection_fnGetFont(
930 ITextSelection *me,
931 ITextFont **pFont)
933 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
934 if (!This->reOle)
935 return CO_E_RELEASED;
937 FIXME("not implemented\n");
938 return E_NOTIMPL;
941 static HRESULT WINAPI ITextSelection_fnSetFont(
942 ITextSelection *me,
943 ITextFont *pFont)
945 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
946 if (!This->reOle)
947 return CO_E_RELEASED;
949 FIXME("not implemented\n");
950 return E_NOTIMPL;
953 static HRESULT WINAPI ITextSelection_fnGetPara(
954 ITextSelection *me,
955 ITextPara **ppPara)
957 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
958 if (!This->reOle)
959 return CO_E_RELEASED;
961 FIXME("not implemented\n");
962 return E_NOTIMPL;
965 static HRESULT WINAPI ITextSelection_fnSetPara(
966 ITextSelection *me,
967 ITextPara *pPara)
969 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
970 if (!This->reOle)
971 return CO_E_RELEASED;
973 FIXME("not implemented\n");
974 return E_NOTIMPL;
977 static HRESULT WINAPI ITextSelection_fnGetStoryLength(
978 ITextSelection *me,
979 LONG *pcch)
981 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
982 if (!This->reOle)
983 return CO_E_RELEASED;
985 FIXME("not implemented\n");
986 return E_NOTIMPL;
989 static HRESULT WINAPI ITextSelection_fnGetStoryType(
990 ITextSelection *me,
991 LONG *pValue)
993 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
994 if (!This->reOle)
995 return CO_E_RELEASED;
997 FIXME("not implemented\n");
998 return E_NOTIMPL;
1001 static HRESULT WINAPI ITextSelection_fnCollapse(
1002 ITextSelection *me,
1003 LONG bStart)
1005 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1006 if (!This->reOle)
1007 return CO_E_RELEASED;
1009 FIXME("not implemented\n");
1010 return E_NOTIMPL;
1013 static HRESULT WINAPI ITextSelection_fnExpand(
1014 ITextSelection *me,
1015 LONG Unit,
1016 LONG *pDelta)
1018 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1019 if (!This->reOle)
1020 return CO_E_RELEASED;
1022 FIXME("not implemented\n");
1023 return E_NOTIMPL;
1026 static HRESULT WINAPI ITextSelection_fnGetIndex(
1027 ITextSelection *me,
1028 LONG Unit,
1029 LONG *pIndex)
1031 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1032 if (!This->reOle)
1033 return CO_E_RELEASED;
1035 FIXME("not implemented\n");
1036 return E_NOTIMPL;
1039 static HRESULT WINAPI ITextSelection_fnSetIndex(
1040 ITextSelection *me,
1041 LONG Unit,
1042 LONG Index,
1043 LONG Extend)
1045 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1046 if (!This->reOle)
1047 return CO_E_RELEASED;
1049 FIXME("not implemented\n");
1050 return E_NOTIMPL;
1053 static HRESULT WINAPI ITextSelection_fnSetRange(
1054 ITextSelection *me,
1055 LONG cpActive,
1056 LONG cpOther)
1058 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1059 if (!This->reOle)
1060 return CO_E_RELEASED;
1062 FIXME("not implemented\n");
1063 return E_NOTIMPL;
1066 static HRESULT WINAPI ITextSelection_fnInRange(
1067 ITextSelection *me,
1068 ITextRange *pRange,
1069 LONG *pb)
1071 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1072 if (!This->reOle)
1073 return CO_E_RELEASED;
1075 FIXME("not implemented\n");
1076 return E_NOTIMPL;
1079 static HRESULT WINAPI ITextSelection_fnInStory(
1080 ITextSelection *me,
1081 ITextRange *pRange,
1082 LONG *pb)
1084 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1085 if (!This->reOle)
1086 return CO_E_RELEASED;
1088 FIXME("not implemented\n");
1089 return E_NOTIMPL;
1092 static HRESULT WINAPI ITextSelection_fnIsEqual(
1093 ITextSelection *me,
1094 ITextRange *pRange,
1095 LONG *pb)
1097 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1098 if (!This->reOle)
1099 return CO_E_RELEASED;
1101 FIXME("not implemented\n");
1102 return E_NOTIMPL;
1105 static HRESULT WINAPI ITextSelection_fnSelect(
1106 ITextSelection *me)
1108 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1109 if (!This->reOle)
1110 return CO_E_RELEASED;
1112 FIXME("not implemented\n");
1113 return E_NOTIMPL;
1116 static HRESULT WINAPI ITextSelection_fnStartOf(
1117 ITextSelection *me,
1118 LONG Unit,
1119 LONG Extend,
1120 LONG *pDelta)
1122 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1123 if (!This->reOle)
1124 return CO_E_RELEASED;
1126 FIXME("not implemented\n");
1127 return E_NOTIMPL;
1130 static HRESULT WINAPI ITextSelection_fnEndOf(
1131 ITextSelection *me,
1132 LONG Unit,
1133 LONG Extend,
1134 LONG *pDelta)
1136 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1137 if (!This->reOle)
1138 return CO_E_RELEASED;
1140 FIXME("not implemented\n");
1141 return E_NOTIMPL;
1144 static HRESULT WINAPI ITextSelection_fnMove(
1145 ITextSelection *me,
1146 LONG Unit,
1147 LONG Count,
1148 LONG *pDelta)
1150 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1151 if (!This->reOle)
1152 return CO_E_RELEASED;
1154 FIXME("not implemented\n");
1155 return E_NOTIMPL;
1158 static HRESULT WINAPI ITextSelection_fnMoveStart(
1159 ITextSelection *me,
1160 LONG Unit,
1161 LONG Count,
1162 LONG *pDelta)
1164 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1165 if (!This->reOle)
1166 return CO_E_RELEASED;
1168 FIXME("not implemented\n");
1169 return E_NOTIMPL;
1172 static HRESULT WINAPI ITextSelection_fnMoveEnd(
1173 ITextSelection *me,
1174 LONG Unit,
1175 LONG Count,
1176 LONG *pDelta)
1178 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1179 if (!This->reOle)
1180 return CO_E_RELEASED;
1182 FIXME("not implemented\n");
1183 return E_NOTIMPL;
1186 static HRESULT WINAPI ITextSelection_fnMoveWhile(
1187 ITextSelection *me,
1188 VARIANT *Cset,
1189 LONG Count,
1190 LONG *pDelta)
1192 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1193 if (!This->reOle)
1194 return CO_E_RELEASED;
1196 FIXME("not implemented\n");
1197 return E_NOTIMPL;
1200 static HRESULT WINAPI ITextSelection_fnMoveStartWhile(
1201 ITextSelection *me,
1202 VARIANT *Cset,
1203 LONG Count,
1204 LONG *pDelta)
1206 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1207 if (!This->reOle)
1208 return CO_E_RELEASED;
1210 FIXME("not implemented\n");
1211 return E_NOTIMPL;
1214 static HRESULT WINAPI ITextSelection_fnMoveEndWhile(
1215 ITextSelection *me,
1216 VARIANT *Cset,
1217 LONG Count,
1218 LONG *pDelta)
1220 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1221 if (!This->reOle)
1222 return CO_E_RELEASED;
1224 FIXME("not implemented\n");
1225 return E_NOTIMPL;
1228 static HRESULT WINAPI ITextSelection_fnMoveUntil(
1229 ITextSelection *me,
1230 VARIANT *Cset,
1231 LONG Count,
1232 LONG *pDelta)
1234 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1235 if (!This->reOle)
1236 return CO_E_RELEASED;
1238 FIXME("not implemented\n");
1239 return E_NOTIMPL;
1242 static HRESULT WINAPI ITextSelection_fnMoveStartUntil(
1243 ITextSelection *me,
1244 VARIANT *Cset,
1245 LONG Count,
1246 LONG *pDelta)
1248 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1249 if (!This->reOle)
1250 return CO_E_RELEASED;
1252 FIXME("not implemented\n");
1253 return E_NOTIMPL;
1256 static HRESULT WINAPI ITextSelection_fnMoveEndUntil(
1257 ITextSelection *me,
1258 VARIANT *Cset,
1259 LONG Count,
1260 LONG *pDelta)
1262 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1263 if (!This->reOle)
1264 return CO_E_RELEASED;
1266 FIXME("not implemented\n");
1267 return E_NOTIMPL;
1270 static HRESULT WINAPI ITextSelection_fnFindText(
1271 ITextSelection *me,
1272 BSTR bstr,
1273 LONG cch,
1274 LONG Flags,
1275 LONG *pLength)
1277 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1278 if (!This->reOle)
1279 return CO_E_RELEASED;
1281 FIXME("not implemented\n");
1282 return E_NOTIMPL;
1285 static HRESULT WINAPI ITextSelection_fnFindTextStart(
1286 ITextSelection *me,
1287 BSTR bstr,
1288 LONG cch,
1289 LONG Flags,
1290 LONG *pLength)
1292 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1293 if (!This->reOle)
1294 return CO_E_RELEASED;
1296 FIXME("not implemented\n");
1297 return E_NOTIMPL;
1300 static HRESULT WINAPI ITextSelection_fnFindTextEnd(
1301 ITextSelection *me,
1302 BSTR bstr,
1303 LONG cch,
1304 LONG Flags,
1305 LONG *pLength)
1307 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1308 if (!This->reOle)
1309 return CO_E_RELEASED;
1311 FIXME("not implemented\n");
1312 return E_NOTIMPL;
1315 static HRESULT WINAPI ITextSelection_fnDelete(
1316 ITextSelection *me,
1317 LONG Unit,
1318 LONG Count,
1319 LONG *pDelta)
1321 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1322 if (!This->reOle)
1323 return CO_E_RELEASED;
1325 FIXME("not implemented\n");
1326 return E_NOTIMPL;
1329 static HRESULT WINAPI ITextSelection_fnCut(
1330 ITextSelection *me,
1331 VARIANT *pVar)
1333 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1334 if (!This->reOle)
1335 return CO_E_RELEASED;
1337 FIXME("not implemented\n");
1338 return E_NOTIMPL;
1341 static HRESULT WINAPI ITextSelection_fnCopy(
1342 ITextSelection *me,
1343 VARIANT *pVar)
1345 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1346 if (!This->reOle)
1347 return CO_E_RELEASED;
1349 FIXME("not implemented\n");
1350 return E_NOTIMPL;
1353 static HRESULT WINAPI ITextSelection_fnPaste(
1354 ITextSelection *me,
1355 VARIANT *pVar,
1356 LONG Format)
1358 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1359 if (!This->reOle)
1360 return CO_E_RELEASED;
1362 FIXME("not implemented\n");
1363 return E_NOTIMPL;
1366 static HRESULT WINAPI ITextSelection_fnCanPaste(
1367 ITextSelection *me,
1368 VARIANT *pVar,
1369 LONG Format,
1370 LONG *pb)
1372 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1373 if (!This->reOle)
1374 return CO_E_RELEASED;
1376 FIXME("not implemented\n");
1377 return E_NOTIMPL;
1380 static HRESULT WINAPI ITextSelection_fnCanEdit(
1381 ITextSelection *me,
1382 LONG *pb)
1384 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1385 if (!This->reOle)
1386 return CO_E_RELEASED;
1388 FIXME("not implemented\n");
1389 return E_NOTIMPL;
1392 static HRESULT WINAPI ITextSelection_fnChangeCase(
1393 ITextSelection *me,
1394 LONG Type)
1396 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1397 if (!This->reOle)
1398 return CO_E_RELEASED;
1400 FIXME("not implemented\n");
1401 return E_NOTIMPL;
1404 static HRESULT WINAPI ITextSelection_fnGetPoint(
1405 ITextSelection *me,
1406 LONG Type,
1407 LONG *cx,
1408 LONG *cy)
1410 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1411 if (!This->reOle)
1412 return CO_E_RELEASED;
1414 FIXME("not implemented\n");
1415 return E_NOTIMPL;
1418 static HRESULT WINAPI ITextSelection_fnSetPoint(
1419 ITextSelection *me,
1420 LONG x,
1421 LONG y,
1422 LONG Type,
1423 LONG Extend)
1425 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1426 if (!This->reOle)
1427 return CO_E_RELEASED;
1429 FIXME("not implemented\n");
1430 return E_NOTIMPL;
1433 static HRESULT WINAPI ITextSelection_fnScrollIntoView(
1434 ITextSelection *me,
1435 LONG Value)
1437 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1438 if (!This->reOle)
1439 return CO_E_RELEASED;
1441 FIXME("not implemented\n");
1442 return E_NOTIMPL;
1445 static HRESULT WINAPI ITextSelection_fnGetEmbeddedObject(
1446 ITextSelection *me,
1447 IUnknown **ppv)
1449 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1450 if (!This->reOle)
1451 return CO_E_RELEASED;
1453 FIXME("not implemented\n");
1454 return E_NOTIMPL;
1457 /*** ITextSelection methods ***/
1458 static HRESULT WINAPI ITextSelection_fnGetFlags(
1459 ITextSelection *me,
1460 LONG *pFlags)
1462 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1463 if (!This->reOle)
1464 return CO_E_RELEASED;
1466 FIXME("not implemented\n");
1467 return E_NOTIMPL;
1470 static HRESULT WINAPI ITextSelection_fnSetFlags(
1471 ITextSelection *me,
1472 LONG Flags)
1474 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1475 if (!This->reOle)
1476 return CO_E_RELEASED;
1478 FIXME("not implemented\n");
1479 return E_NOTIMPL;
1482 static HRESULT WINAPI ITextSelection_fnGetType(
1483 ITextSelection *me,
1484 LONG *pType)
1486 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1487 if (!This->reOle)
1488 return CO_E_RELEASED;
1490 FIXME("not implemented\n");
1491 return E_NOTIMPL;
1494 static HRESULT WINAPI ITextSelection_fnMoveLeft(
1495 ITextSelection *me,
1496 LONG Unit,
1497 LONG Count,
1498 LONG Extend,
1499 LONG *pDelta)
1501 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1502 if (!This->reOle)
1503 return CO_E_RELEASED;
1505 FIXME("not implemented\n");
1506 return E_NOTIMPL;
1509 static HRESULT WINAPI ITextSelection_fnMoveRight(
1510 ITextSelection *me,
1511 LONG Unit,
1512 LONG Count,
1513 LONG Extend,
1514 LONG *pDelta)
1516 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1517 if (!This->reOle)
1518 return CO_E_RELEASED;
1520 FIXME("not implemented\n");
1521 return E_NOTIMPL;
1524 static HRESULT WINAPI ITextSelection_fnMoveUp(
1525 ITextSelection *me,
1526 LONG Unit,
1527 LONG Count,
1528 LONG Extend,
1529 LONG *pDelta)
1531 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1532 if (!This->reOle)
1533 return CO_E_RELEASED;
1535 FIXME("not implemented\n");
1536 return E_NOTIMPL;
1539 static HRESULT WINAPI ITextSelection_fnMoveDown(
1540 ITextSelection *me,
1541 LONG Unit,
1542 LONG Count,
1543 LONG Extend,
1544 LONG *pDelta)
1546 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1547 if (!This->reOle)
1548 return CO_E_RELEASED;
1550 FIXME("not implemented\n");
1551 return E_NOTIMPL;
1554 static HRESULT WINAPI ITextSelection_fnHomeKey(
1555 ITextSelection *me,
1556 LONG Unit,
1557 LONG Extend,
1558 LONG *pDelta)
1560 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1561 if (!This->reOle)
1562 return CO_E_RELEASED;
1564 FIXME("not implemented\n");
1565 return E_NOTIMPL;
1568 static HRESULT WINAPI ITextSelection_fnEndKey(
1569 ITextSelection *me,
1570 LONG Unit,
1571 LONG Extend,
1572 LONG *pDelta)
1574 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1575 if (!This->reOle)
1576 return CO_E_RELEASED;
1578 FIXME("not implemented\n");
1579 return E_NOTIMPL;
1582 static HRESULT WINAPI ITextSelection_fnTypeText(
1583 ITextSelection *me,
1584 BSTR bstr)
1586 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1587 if (!This->reOle)
1588 return CO_E_RELEASED;
1590 FIXME("not implemented\n");
1591 return E_NOTIMPL;
1594 static const ITextSelectionVtbl tsvt = {
1595 ITextSelection_fnQueryInterface,
1596 ITextSelection_fnAddRef,
1597 ITextSelection_fnRelease,
1598 ITextSelection_fnGetTypeInfoCount,
1599 ITextSelection_fnGetTypeInfo,
1600 ITextSelection_fnGetIDsOfNames,
1601 ITextSelection_fnInvoke,
1602 ITextSelection_fnGetText,
1603 ITextSelection_fnSetText,
1604 ITextSelection_fnGetChar,
1605 ITextSelection_fnSetChar,
1606 ITextSelection_fnGetDuplicate,
1607 ITextSelection_fnGetFormattedText,
1608 ITextSelection_fnSetFormattedText,
1609 ITextSelection_fnGetStart,
1610 ITextSelection_fnSetStart,
1611 ITextSelection_fnGetEnd,
1612 ITextSelection_fnSetEnd,
1613 ITextSelection_fnGetFont,
1614 ITextSelection_fnSetFont,
1615 ITextSelection_fnGetPara,
1616 ITextSelection_fnSetPara,
1617 ITextSelection_fnGetStoryLength,
1618 ITextSelection_fnGetStoryType,
1619 ITextSelection_fnCollapse,
1620 ITextSelection_fnExpand,
1621 ITextSelection_fnGetIndex,
1622 ITextSelection_fnSetIndex,
1623 ITextSelection_fnSetRange,
1624 ITextSelection_fnInRange,
1625 ITextSelection_fnInStory,
1626 ITextSelection_fnIsEqual,
1627 ITextSelection_fnSelect,
1628 ITextSelection_fnStartOf,
1629 ITextSelection_fnEndOf,
1630 ITextSelection_fnMove,
1631 ITextSelection_fnMoveStart,
1632 ITextSelection_fnMoveEnd,
1633 ITextSelection_fnMoveWhile,
1634 ITextSelection_fnMoveStartWhile,
1635 ITextSelection_fnMoveEndWhile,
1636 ITextSelection_fnMoveUntil,
1637 ITextSelection_fnMoveStartUntil,
1638 ITextSelection_fnMoveEndUntil,
1639 ITextSelection_fnFindText,
1640 ITextSelection_fnFindTextStart,
1641 ITextSelection_fnFindTextEnd,
1642 ITextSelection_fnDelete,
1643 ITextSelection_fnCut,
1644 ITextSelection_fnCopy,
1645 ITextSelection_fnPaste,
1646 ITextSelection_fnCanPaste,
1647 ITextSelection_fnCanEdit,
1648 ITextSelection_fnChangeCase,
1649 ITextSelection_fnGetPoint,
1650 ITextSelection_fnSetPoint,
1651 ITextSelection_fnScrollIntoView,
1652 ITextSelection_fnGetEmbeddedObject,
1653 ITextSelection_fnGetFlags,
1654 ITextSelection_fnSetFlags,
1655 ITextSelection_fnGetType,
1656 ITextSelection_fnMoveLeft,
1657 ITextSelection_fnMoveRight,
1658 ITextSelection_fnMoveUp,
1659 ITextSelection_fnMoveDown,
1660 ITextSelection_fnHomeKey,
1661 ITextSelection_fnEndKey,
1662 ITextSelection_fnTypeText
1665 static ITextSelectionImpl *
1666 CreateTextSelection(IRichEditOleImpl *reOle)
1668 ITextSelectionImpl *txtSel = heap_alloc(sizeof *txtSel);
1669 if (!txtSel)
1670 return NULL;
1672 txtSel->lpVtbl = &tsvt;
1673 txtSel->ref = 1;
1674 txtSel->reOle = reOle;
1675 return txtSel;
1678 LRESULT CreateIRichEditOle(ME_TextEditor *editor, LPVOID *ppObj)
1680 IRichEditOleImpl *reo;
1682 reo = heap_alloc(sizeof(IRichEditOleImpl));
1683 if (!reo)
1684 return 0;
1686 reo->lpRichEditOleVtbl = &revt;
1687 reo->lpTextDocumentVtbl = &tdvt;
1688 reo->ref = 1;
1689 reo->editor = editor;
1690 reo->txtSel = CreateTextSelection(reo);
1691 if (!reo->txtSel)
1693 heap_free(reo);
1694 return 0;
1696 reo->clientSite = CreateOleClientSite(reo);
1697 if (!reo->txtSel)
1699 ITextSelection_Release((ITextSelection *) reo->txtSel);
1700 heap_free(reo);
1701 return 0;
1703 TRACE("Created %p\n",reo);
1704 *ppObj = reo;
1706 return 1;
1709 static void convert_sizel(ME_Context *c, const SIZEL* szl, SIZE* sz)
1711 /* sizel is in .01 millimeters, sz in pixels */
1712 sz->cx = MulDiv(szl->cx, c->dpi.cx, 2540);
1713 sz->cy = MulDiv(szl->cy, c->dpi.cy, 2540);
1716 /******************************************************************************
1717 * ME_GetOLEObjectSize
1719 * Sets run extent for OLE objects.
1721 void ME_GetOLEObjectSize(ME_Context *c, ME_Run *run, SIZE *pSize)
1723 IDataObject* ido;
1724 FORMATETC fmt;
1725 STGMEDIUM stgm;
1726 DIBSECTION dibsect;
1727 ENHMETAHEADER emh;
1729 assert(run->nFlags & MERF_GRAPHICS);
1730 assert(run->ole_obj);
1732 if (run->ole_obj->sizel.cx != 0 || run->ole_obj->sizel.cy != 0)
1734 convert_sizel(c, &run->ole_obj->sizel, pSize);
1735 return;
1738 IOleObject_QueryInterface(run->ole_obj->poleobj, &IID_IDataObject, (void**)&ido);
1739 fmt.cfFormat = CF_BITMAP;
1740 fmt.ptd = NULL;
1741 fmt.dwAspect = DVASPECT_CONTENT;
1742 fmt.lindex = -1;
1743 fmt.tymed = TYMED_GDI;
1744 if (IDataObject_GetData(ido, &fmt, &stgm) != S_OK)
1746 fmt.cfFormat = CF_ENHMETAFILE;
1747 fmt.tymed = TYMED_ENHMF;
1748 if (IDataObject_GetData(ido, &fmt, &stgm) != S_OK)
1750 FIXME("unsupported format\n");
1751 pSize->cx = pSize->cy = 0;
1752 IDataObject_Release(ido);
1753 return;
1757 switch (stgm.tymed)
1759 case TYMED_GDI:
1760 GetObjectW(stgm.u.hBitmap, sizeof(dibsect), &dibsect);
1761 pSize->cx = dibsect.dsBm.bmWidth;
1762 pSize->cy = dibsect.dsBm.bmHeight;
1763 if (!stgm.pUnkForRelease) DeleteObject(stgm.u.hBitmap);
1764 break;
1765 case TYMED_ENHMF:
1766 GetEnhMetaFileHeader(stgm.u.hEnhMetaFile, sizeof(emh), &emh);
1767 pSize->cx = emh.rclBounds.right - emh.rclBounds.left;
1768 pSize->cy = emh.rclBounds.bottom - emh.rclBounds.top;
1769 if (!stgm.pUnkForRelease) DeleteEnhMetaFile(stgm.u.hEnhMetaFile);
1770 break;
1771 default:
1772 FIXME("Unsupported tymed %d\n", stgm.tymed);
1773 break;
1775 IDataObject_Release(ido);
1776 if (c->editor->nZoomNumerator != 0)
1778 pSize->cx = MulDiv(pSize->cx, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
1779 pSize->cy = MulDiv(pSize->cy, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
1783 void ME_DrawOLE(ME_Context *c, int x, int y, ME_Run *run,
1784 ME_Paragraph *para, BOOL selected)
1786 IDataObject* ido;
1787 FORMATETC fmt;
1788 STGMEDIUM stgm;
1789 DIBSECTION dibsect;
1790 ENHMETAHEADER emh;
1791 HDC hMemDC;
1792 SIZE sz;
1793 BOOL has_size;
1795 assert(run->nFlags & MERF_GRAPHICS);
1796 assert(run->ole_obj);
1797 if (IOleObject_QueryInterface(run->ole_obj->poleobj, &IID_IDataObject, (void**)&ido) != S_OK)
1799 FIXME("Couldn't get interface\n");
1800 return;
1802 has_size = run->ole_obj->sizel.cx != 0 || run->ole_obj->sizel.cy != 0;
1803 fmt.cfFormat = CF_BITMAP;
1804 fmt.ptd = NULL;
1805 fmt.dwAspect = DVASPECT_CONTENT;
1806 fmt.lindex = -1;
1807 fmt.tymed = TYMED_GDI;
1808 if (IDataObject_GetData(ido, &fmt, &stgm) != S_OK)
1810 fmt.cfFormat = CF_ENHMETAFILE;
1811 fmt.tymed = TYMED_ENHMF;
1812 if (IDataObject_GetData(ido, &fmt, &stgm) != S_OK)
1814 FIXME("Couldn't get storage medium\n");
1815 IDataObject_Release(ido);
1816 return;
1819 switch (stgm.tymed)
1821 case TYMED_GDI:
1822 GetObjectW(stgm.u.hBitmap, sizeof(dibsect), &dibsect);
1823 hMemDC = CreateCompatibleDC(c->hDC);
1824 SelectObject(hMemDC, stgm.u.hBitmap);
1825 if (!has_size && c->editor->nZoomNumerator == 0)
1827 sz.cx = dibsect.dsBm.bmWidth;
1828 sz.cy = dibsect.dsBm.bmHeight;
1829 BitBlt(c->hDC, x, y - dibsect.dsBm.bmHeight,
1830 dibsect.dsBm.bmWidth, dibsect.dsBm.bmHeight,
1831 hMemDC, 0, 0, SRCCOPY);
1833 else
1835 if (has_size)
1837 convert_sizel(c, &run->ole_obj->sizel, &sz);
1839 else
1841 sz.cx = MulDiv(dibsect.dsBm.bmWidth,
1842 c->editor->nZoomNumerator, c->editor->nZoomDenominator);
1843 sz.cy = MulDiv(dibsect.dsBm.bmHeight,
1844 c->editor->nZoomNumerator, c->editor->nZoomDenominator);
1846 StretchBlt(c->hDC, x, y - sz.cy, sz.cx, sz.cy,
1847 hMemDC, 0, 0, dibsect.dsBm.bmWidth, dibsect.dsBm.bmHeight, SRCCOPY);
1849 if (!stgm.pUnkForRelease) DeleteObject(stgm.u.hBitmap);
1850 break;
1851 case TYMED_ENHMF:
1852 GetEnhMetaFileHeader(stgm.u.hEnhMetaFile, sizeof(emh), &emh);
1853 if (!has_size && c->editor->nZoomNumerator == 0)
1855 sz.cy = emh.rclBounds.bottom - emh.rclBounds.top;
1856 sz.cx = emh.rclBounds.right - emh.rclBounds.left;
1858 else
1860 if (has_size)
1862 convert_sizel(c, &run->ole_obj->sizel, &sz);
1864 else
1866 sz.cy = MulDiv(emh.rclBounds.bottom - emh.rclBounds.top,
1867 c->editor->nZoomNumerator, c->editor->nZoomDenominator);
1868 sz.cx = MulDiv(emh.rclBounds.right - emh.rclBounds.left,
1869 c->editor->nZoomNumerator, c->editor->nZoomDenominator);
1873 RECT rc;
1875 rc.left = x;
1876 rc.top = y - sz.cy;
1877 rc.right = x + sz.cx;
1878 rc.bottom = y;
1879 PlayEnhMetaFile(c->hDC, stgm.u.hEnhMetaFile, &rc);
1881 if (!stgm.pUnkForRelease) DeleteEnhMetaFile(stgm.u.hEnhMetaFile);
1882 break;
1883 default:
1884 FIXME("Unsupported tymed %d\n", stgm.tymed);
1885 selected = FALSE;
1886 break;
1888 if (selected && !c->editor->bHideSelection)
1889 PatBlt(c->hDC, x, y - sz.cy, sz.cx, sz.cy, DSTINVERT);
1890 IDataObject_Release(ido);
1893 void ME_DeleteReObject(REOBJECT* reo)
1895 if (reo->poleobj) IOleObject_Release(reo->poleobj);
1896 if (reo->pstg) IStorage_Release(reo->pstg);
1897 if (reo->polesite) IOleClientSite_Release(reo->polesite);
1898 FREE_OBJ(reo);
1901 void ME_CopyReObject(REOBJECT* dst, const REOBJECT* src)
1903 *dst = *src;
1905 if (dst->poleobj) IOleObject_AddRef(dst->poleobj);
1906 if (dst->pstg) IStorage_AddRef(dst->pstg);
1907 if (dst->polesite) IOleClientSite_AddRef(dst->polesite);