msvcrt/tests: Remove a space before a '\n'.
[wine/gsoc-2012-control.git] / dlls / riched20 / richole.c
blobee8ea600a6898b261df44f82ae6fbbef32dfe539
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 CHARRANGE tmpchrg;
320 TRACE("(%p,%p,%d)\n",This, lpchrg, reco);
321 if(!lplpdataobj)
322 return E_INVALIDARG;
323 if(!lpchrg) {
324 ME_GetSelection(This->editor, &tmpchrg.cpMin, &tmpchrg.cpMax);
325 lpchrg = &tmpchrg;
327 return ME_GetDataObject(This->editor, lpchrg, lplpdataobj);
330 static LONG WINAPI IRichEditOle_fnGetLinkCount(IRichEditOle *me)
332 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
333 FIXME("stub %p\n",This);
334 return E_NOTIMPL;
337 static HRESULT WINAPI
338 IRichEditOle_fnGetObject(IRichEditOle *me, LONG iob,
339 REOBJECT *lpreobject, DWORD dwFlags)
341 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
342 FIXME("stub %p\n",This);
343 return E_NOTIMPL;
346 static LONG WINAPI
347 IRichEditOle_fnGetObjectCount(IRichEditOle *me)
349 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
350 FIXME("stub %p\n",This);
351 return 0;
354 static HRESULT WINAPI
355 IRichEditOle_fnHandsOffStorage(IRichEditOle *me, LONG iob)
357 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
358 FIXME("stub %p\n",This);
359 return E_NOTIMPL;
362 static HRESULT WINAPI
363 IRichEditOle_fnImportDataObject(IRichEditOle *me, LPDATAOBJECT lpdataobj,
364 CLIPFORMAT cf, HGLOBAL hMetaPict)
366 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
367 FIXME("stub %p\n",This);
368 return E_NOTIMPL;
371 static HRESULT WINAPI
372 IRichEditOle_fnInPlaceDeactivate(IRichEditOle *me)
374 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
375 FIXME("stub %p\n",This);
376 return E_NOTIMPL;
379 static HRESULT WINAPI
380 IRichEditOle_fnInsertObject(IRichEditOle *me, REOBJECT *reo)
382 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
383 TRACE("(%p,%p)\n", This, reo);
385 if (reo->cbStruct < sizeof(*reo)) return STG_E_INVALIDPARAMETER;
386 if (reo->poleobj) IOleObject_AddRef(reo->poleobj);
387 if (reo->pstg) IStorage_AddRef(reo->pstg);
388 if (reo->polesite) IOleClientSite_AddRef(reo->polesite);
390 ME_InsertOLEFromCursor(This->editor, reo, 0);
391 return S_OK;
394 static HRESULT WINAPI IRichEditOle_fnSaveCompleted(IRichEditOle *me, LONG iob,
395 LPSTORAGE lpstg)
397 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
398 FIXME("stub %p\n",This);
399 return E_NOTIMPL;
402 static HRESULT WINAPI
403 IRichEditOle_fnSetDvaspect(IRichEditOle *me, LONG iob, DWORD dvaspect)
405 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
406 FIXME("stub %p\n",This);
407 return E_NOTIMPL;
410 static HRESULT WINAPI IRichEditOle_fnSetHostNames(IRichEditOle *me,
411 LPCSTR lpstrContainerApp, LPCSTR lpstrContainerObj)
413 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
414 FIXME("stub %p %s %s\n",This, lpstrContainerApp, lpstrContainerObj);
415 return E_NOTIMPL;
418 static HRESULT WINAPI
419 IRichEditOle_fnSetLinkAvailable(IRichEditOle *me, LONG iob, BOOL fAvailable)
421 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
422 FIXME("stub %p\n",This);
423 return E_NOTIMPL;
426 static const IRichEditOleVtbl revt = {
427 IRichEditOle_fnQueryInterface,
428 IRichEditOle_fnAddRef,
429 IRichEditOle_fnRelease,
430 IRichEditOle_fnGetClientSite,
431 IRichEditOle_fnGetObjectCount,
432 IRichEditOle_fnGetLinkCount,
433 IRichEditOle_fnGetObject,
434 IRichEditOle_fnInsertObject,
435 IRichEditOle_fnConvertObject,
436 IRichEditOle_fnActivateAs,
437 IRichEditOle_fnSetHostNames,
438 IRichEditOle_fnSetLinkAvailable,
439 IRichEditOle_fnSetDvaspect,
440 IRichEditOle_fnHandsOffStorage,
441 IRichEditOle_fnSaveCompleted,
442 IRichEditOle_fnInPlaceDeactivate,
443 IRichEditOle_fnContextSensitiveHelp,
444 IRichEditOle_fnGetClipboardData,
445 IRichEditOle_fnImportDataObject
448 static HRESULT WINAPI
449 ITextDocument_fnQueryInterface(ITextDocument* me, REFIID riid,
450 void** ppvObject)
452 IRichEditOleImpl *This = impl_from_ITextDocument(me);
453 return IRichEditOle_fnQueryInterface((IRichEditOle*)&This->lpRichEditOleVtbl,
454 riid, ppvObject);
457 static ULONG WINAPI
458 ITextDocument_fnAddRef(ITextDocument* me)
460 IRichEditOleImpl *This = impl_from_ITextDocument(me);
461 return IRichEditOle_fnAddRef((IRichEditOle*)&This->lpRichEditOleVtbl);
464 static ULONG WINAPI
465 ITextDocument_fnRelease(ITextDocument* me)
467 IRichEditOleImpl *This = impl_from_ITextDocument(me);
468 return IRichEditOle_fnRelease((IRichEditOle*)&This->lpRichEditOleVtbl);
471 static HRESULT WINAPI
472 ITextDocument_fnGetTypeInfoCount(ITextDocument* me,
473 UINT* pctinfo)
475 IRichEditOleImpl *This = impl_from_ITextDocument(me);
476 FIXME("stub %p\n",This);
477 return E_NOTIMPL;
480 static HRESULT WINAPI
481 ITextDocument_fnGetTypeInfo(ITextDocument* me, UINT iTInfo, LCID lcid,
482 ITypeInfo** ppTInfo)
484 IRichEditOleImpl *This = impl_from_ITextDocument(me);
485 FIXME("stub %p\n",This);
486 return E_NOTIMPL;
489 static HRESULT WINAPI
490 ITextDocument_fnGetIDsOfNames(ITextDocument* me, REFIID riid,
491 LPOLESTR* rgszNames, UINT cNames, LCID lcid, DISPID* rgDispId)
493 IRichEditOleImpl *This = impl_from_ITextDocument(me);
494 FIXME("stub %p\n",This);
495 return E_NOTIMPL;
498 static HRESULT WINAPI
499 ITextDocument_fnInvoke(ITextDocument* me, DISPID dispIdMember,
500 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS* pDispParams,
501 VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr)
503 IRichEditOleImpl *This = impl_from_ITextDocument(me);
504 FIXME("stub %p\n",This);
505 return E_NOTIMPL;
508 static HRESULT WINAPI
509 ITextDocument_fnGetName(ITextDocument* me, BSTR* pName)
511 IRichEditOleImpl *This = impl_from_ITextDocument(me);
512 FIXME("stub %p\n",This);
513 return E_NOTIMPL;
516 static HRESULT WINAPI
517 ITextDocument_fnGetSelection(ITextDocument* me, ITextSelection** ppSel)
519 IRichEditOleImpl *This = impl_from_ITextDocument(me);
520 TRACE("(%p)\n", me);
521 *ppSel = (ITextSelection *) This->txtSel;
522 ITextSelection_AddRef(*ppSel);
523 return S_OK;
526 static HRESULT WINAPI
527 ITextDocument_fnGetStoryCount(ITextDocument* me, long* pCount)
529 IRichEditOleImpl *This = impl_from_ITextDocument(me);
530 FIXME("stub %p\n",This);
531 return E_NOTIMPL;
534 static HRESULT WINAPI
535 ITextDocument_fnGetStoryRanges(ITextDocument* me,
536 ITextStoryRanges** ppStories)
538 IRichEditOleImpl *This = impl_from_ITextDocument(me);
539 FIXME("stub %p\n",This);
540 return E_NOTIMPL;
543 static HRESULT WINAPI
544 ITextDocument_fnGetSaved(ITextDocument* me, long* pValue)
546 IRichEditOleImpl *This = impl_from_ITextDocument(me);
547 FIXME("stub %p\n",This);
548 return E_NOTIMPL;
551 static HRESULT WINAPI
552 ITextDocument_fnSetSaved(ITextDocument* me, long Value)
554 IRichEditOleImpl *This = impl_from_ITextDocument(me);
555 FIXME("stub %p\n",This);
556 return E_NOTIMPL;
559 static HRESULT WINAPI
560 ITextDocument_fnGetDefaultTabStop(ITextDocument* me, float* pValue)
562 IRichEditOleImpl *This = impl_from_ITextDocument(me);
563 FIXME("stub %p\n",This);
564 return E_NOTIMPL;
567 static HRESULT WINAPI
568 ITextDocument_fnSetDefaultTabStop(ITextDocument* me, float Value)
570 IRichEditOleImpl *This = impl_from_ITextDocument(me);
571 FIXME("stub %p\n",This);
572 return E_NOTIMPL;
575 static HRESULT WINAPI
576 ITextDocument_fnNew(ITextDocument* me)
578 IRichEditOleImpl *This = impl_from_ITextDocument(me);
579 FIXME("stub %p\n",This);
580 return E_NOTIMPL;
583 static HRESULT WINAPI
584 ITextDocument_fnOpen(ITextDocument* me, VARIANT* pVar, long Flags,
585 long CodePage)
587 IRichEditOleImpl *This = impl_from_ITextDocument(me);
588 FIXME("stub %p\n",This);
589 return E_NOTIMPL;
592 static HRESULT WINAPI
593 ITextDocument_fnSave(ITextDocument* me, VARIANT* pVar, long Flags,
594 long CodePage)
596 IRichEditOleImpl *This = impl_from_ITextDocument(me);
597 FIXME("stub %p\n",This);
598 return E_NOTIMPL;
601 static HRESULT WINAPI
602 ITextDocument_fnFreeze(ITextDocument* me, long* pCount)
604 IRichEditOleImpl *This = impl_from_ITextDocument(me);
605 FIXME("stub %p\n",This);
606 return E_NOTIMPL;
609 static HRESULT WINAPI
610 ITextDocument_fnUnfreeze(ITextDocument* me, long* pCount)
612 IRichEditOleImpl *This = impl_from_ITextDocument(me);
613 FIXME("stub %p\n",This);
614 return E_NOTIMPL;
617 static HRESULT WINAPI
618 ITextDocument_fnBeginEditCollection(ITextDocument* me)
620 IRichEditOleImpl *This = impl_from_ITextDocument(me);
621 FIXME("stub %p\n",This);
622 return E_NOTIMPL;
625 static HRESULT WINAPI
626 ITextDocument_fnEndEditCollection(ITextDocument* me)
628 IRichEditOleImpl *This = impl_from_ITextDocument(me);
629 FIXME("stub %p\n",This);
630 return E_NOTIMPL;
633 static HRESULT WINAPI
634 ITextDocument_fnUndo(ITextDocument* me, long Count, long* prop)
636 IRichEditOleImpl *This = impl_from_ITextDocument(me);
637 FIXME("stub %p\n",This);
638 return E_NOTIMPL;
641 static HRESULT WINAPI
642 ITextDocument_fnRedo(ITextDocument* me, long Count, long* prop)
644 IRichEditOleImpl *This = impl_from_ITextDocument(me);
645 FIXME("stub %p\n",This);
646 return E_NOTIMPL;
649 static HRESULT WINAPI
650 ITextDocument_fnRange(ITextDocument* me, long cp1, long cp2,
651 ITextRange** ppRange)
653 IRichEditOleImpl *This = impl_from_ITextDocument(me);
654 FIXME("stub %p\n",This);
655 return E_NOTIMPL;
658 static HRESULT WINAPI
659 ITextDocument_fnRangeFromPoint(ITextDocument* me, long x, long y,
660 ITextRange** ppRange)
662 IRichEditOleImpl *This = impl_from_ITextDocument(me);
663 FIXME("stub %p\n",This);
664 return E_NOTIMPL;
667 static const ITextDocumentVtbl tdvt = {
668 ITextDocument_fnQueryInterface,
669 ITextDocument_fnAddRef,
670 ITextDocument_fnRelease,
671 ITextDocument_fnGetTypeInfoCount,
672 ITextDocument_fnGetTypeInfo,
673 ITextDocument_fnGetIDsOfNames,
674 ITextDocument_fnInvoke,
675 ITextDocument_fnGetName,
676 ITextDocument_fnGetSelection,
677 ITextDocument_fnGetStoryCount,
678 ITextDocument_fnGetStoryRanges,
679 ITextDocument_fnGetSaved,
680 ITextDocument_fnSetSaved,
681 ITextDocument_fnGetDefaultTabStop,
682 ITextDocument_fnSetDefaultTabStop,
683 ITextDocument_fnNew,
684 ITextDocument_fnOpen,
685 ITextDocument_fnSave,
686 ITextDocument_fnFreeze,
687 ITextDocument_fnUnfreeze,
688 ITextDocument_fnBeginEditCollection,
689 ITextDocument_fnEndEditCollection,
690 ITextDocument_fnUndo,
691 ITextDocument_fnRedo,
692 ITextDocument_fnRange,
693 ITextDocument_fnRangeFromPoint
696 static HRESULT WINAPI ITextSelection_fnQueryInterface(
697 ITextSelection *me,
698 REFIID riid,
699 void **ppvObj)
701 *ppvObj = NULL;
702 if (IsEqualGUID(riid, &IID_IUnknown)
703 || IsEqualGUID(riid, &IID_IDispatch)
704 || IsEqualGUID(riid, &IID_ITextRange)
705 || IsEqualGUID(riid, &IID_ITextSelection))
707 *ppvObj = me;
708 ITextSelection_AddRef(me);
709 return S_OK;
712 return E_NOINTERFACE;
715 static ULONG WINAPI ITextSelection_fnAddRef(
716 ITextSelection *me)
718 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
719 return InterlockedIncrement(&This->ref);
722 static ULONG WINAPI ITextSelection_fnRelease(
723 ITextSelection *me)
725 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
726 ULONG ref = InterlockedDecrement(&This->ref);
727 if (ref == 0)
728 heap_free(This);
729 return ref;
732 static HRESULT WINAPI ITextSelection_fnGetTypeInfoCount(
733 ITextSelection *me,
734 UINT *pctinfo)
736 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
737 if (!This->reOle)
738 return CO_E_RELEASED;
740 FIXME("not implemented\n");
741 return E_NOTIMPL;
744 static HRESULT WINAPI ITextSelection_fnGetTypeInfo(
745 ITextSelection *me,
746 UINT iTInfo,
747 LCID lcid,
748 ITypeInfo **ppTInfo)
750 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
751 if (!This->reOle)
752 return CO_E_RELEASED;
754 FIXME("not implemented\n");
755 return E_NOTIMPL;
758 static HRESULT WINAPI ITextSelection_fnGetIDsOfNames(
759 ITextSelection *me,
760 REFIID riid,
761 LPOLESTR *rgszNames,
762 UINT cNames,
763 LCID lcid,
764 DISPID *rgDispId)
766 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
767 if (!This->reOle)
768 return CO_E_RELEASED;
770 FIXME("not implemented\n");
771 return E_NOTIMPL;
774 static HRESULT WINAPI ITextSelection_fnInvoke(
775 ITextSelection *me,
776 DISPID dispIdMember,
777 REFIID riid,
778 LCID lcid,
779 WORD wFlags,
780 DISPPARAMS *pDispParams,
781 VARIANT *pVarResult,
782 EXCEPINFO *pExcepInfo,
783 UINT *puArgErr)
785 FIXME("not implemented\n");
786 return E_NOTIMPL;
789 /*** ITextRange methods ***/
790 static HRESULT WINAPI ITextSelection_fnGetText(
791 ITextSelection *me,
792 BSTR *pbstr)
794 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
795 if (!This->reOle)
796 return CO_E_RELEASED;
798 FIXME("not implemented\n");
799 return E_NOTIMPL;
802 static HRESULT WINAPI ITextSelection_fnSetText(
803 ITextSelection *me,
804 BSTR bstr)
806 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
807 if (!This->reOle)
808 return CO_E_RELEASED;
810 FIXME("not implemented\n");
811 return E_NOTIMPL;
814 static HRESULT WINAPI ITextSelection_fnGetChar(
815 ITextSelection *me,
816 long *pch)
818 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
819 if (!This->reOle)
820 return CO_E_RELEASED;
822 FIXME("not implemented\n");
823 return E_NOTIMPL;
826 static HRESULT WINAPI ITextSelection_fnSetChar(
827 ITextSelection *me,
828 long ch)
830 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
831 if (!This->reOle)
832 return CO_E_RELEASED;
834 FIXME("not implemented\n");
835 return E_NOTIMPL;
838 static HRESULT WINAPI ITextSelection_fnGetDuplicate(
839 ITextSelection *me,
840 ITextRange **ppRange)
842 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
843 if (!This->reOle)
844 return CO_E_RELEASED;
846 FIXME("not implemented\n");
847 return E_NOTIMPL;
850 static HRESULT WINAPI ITextSelection_fnGetFormattedText(
851 ITextSelection *me,
852 ITextRange **ppRange)
854 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
855 if (!This->reOle)
856 return CO_E_RELEASED;
858 FIXME("not implemented\n");
859 return E_NOTIMPL;
862 static HRESULT WINAPI ITextSelection_fnSetFormattedText(
863 ITextSelection *me,
864 ITextRange *pRange)
866 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
867 if (!This->reOle)
868 return CO_E_RELEASED;
870 FIXME("not implemented\n");
871 return E_NOTIMPL;
874 static HRESULT WINAPI ITextSelection_fnGetStart(
875 ITextSelection *me,
876 long *pcpFirst)
878 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
879 if (!This->reOle)
880 return CO_E_RELEASED;
882 FIXME("not implemented\n");
883 return E_NOTIMPL;
886 static HRESULT WINAPI ITextSelection_fnSetStart(
887 ITextSelection *me,
888 long cpFirst)
890 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
891 if (!This->reOle)
892 return CO_E_RELEASED;
894 FIXME("not implemented\n");
895 return E_NOTIMPL;
898 static HRESULT WINAPI ITextSelection_fnGetEnd(
899 ITextSelection *me,
900 long *pcpLim)
902 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
903 if (!This->reOle)
904 return CO_E_RELEASED;
906 FIXME("not implemented\n");
907 return E_NOTIMPL;
910 static HRESULT WINAPI ITextSelection_fnSetEnd(
911 ITextSelection *me,
912 long cpLim)
914 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
915 if (!This->reOle)
916 return CO_E_RELEASED;
918 FIXME("not implemented\n");
919 return E_NOTIMPL;
922 static HRESULT WINAPI ITextSelection_fnGetFont(
923 ITextSelection *me,
924 ITextFont **pFont)
926 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
927 if (!This->reOle)
928 return CO_E_RELEASED;
930 FIXME("not implemented\n");
931 return E_NOTIMPL;
934 static HRESULT WINAPI ITextSelection_fnSetFont(
935 ITextSelection *me,
936 ITextFont *pFont)
938 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
939 if (!This->reOle)
940 return CO_E_RELEASED;
942 FIXME("not implemented\n");
943 return E_NOTIMPL;
946 static HRESULT WINAPI ITextSelection_fnGetPara(
947 ITextSelection *me,
948 ITextPara **ppPara)
950 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
951 if (!This->reOle)
952 return CO_E_RELEASED;
954 FIXME("not implemented\n");
955 return E_NOTIMPL;
958 static HRESULT WINAPI ITextSelection_fnSetPara(
959 ITextSelection *me,
960 ITextPara *pPara)
962 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
963 if (!This->reOle)
964 return CO_E_RELEASED;
966 FIXME("not implemented\n");
967 return E_NOTIMPL;
970 static HRESULT WINAPI ITextSelection_fnGetStoryLength(
971 ITextSelection *me,
972 long *pcch)
974 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
975 if (!This->reOle)
976 return CO_E_RELEASED;
978 FIXME("not implemented\n");
979 return E_NOTIMPL;
982 static HRESULT WINAPI ITextSelection_fnGetStoryType(
983 ITextSelection *me,
984 long *pValue)
986 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
987 if (!This->reOle)
988 return CO_E_RELEASED;
990 FIXME("not implemented\n");
991 return E_NOTIMPL;
994 static HRESULT WINAPI ITextSelection_fnCollapse(
995 ITextSelection *me,
996 long bStart)
998 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
999 if (!This->reOle)
1000 return CO_E_RELEASED;
1002 FIXME("not implemented\n");
1003 return E_NOTIMPL;
1006 static HRESULT WINAPI ITextSelection_fnExpand(
1007 ITextSelection *me,
1008 long Unit,
1009 long *pDelta)
1011 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1012 if (!This->reOle)
1013 return CO_E_RELEASED;
1015 FIXME("not implemented\n");
1016 return E_NOTIMPL;
1019 static HRESULT WINAPI ITextSelection_fnGetIndex(
1020 ITextSelection *me,
1021 long Unit,
1022 long *pIndex)
1024 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1025 if (!This->reOle)
1026 return CO_E_RELEASED;
1028 FIXME("not implemented\n");
1029 return E_NOTIMPL;
1032 static HRESULT WINAPI ITextSelection_fnSetIndex(
1033 ITextSelection *me,
1034 long Unit,
1035 long Index,
1036 long Extend)
1038 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1039 if (!This->reOle)
1040 return CO_E_RELEASED;
1042 FIXME("not implemented\n");
1043 return E_NOTIMPL;
1046 static HRESULT WINAPI ITextSelection_fnSetRange(
1047 ITextSelection *me,
1048 long cpActive,
1049 long cpOther)
1051 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1052 if (!This->reOle)
1053 return CO_E_RELEASED;
1055 FIXME("not implemented\n");
1056 return E_NOTIMPL;
1059 static HRESULT WINAPI ITextSelection_fnInRange(
1060 ITextSelection *me,
1061 ITextRange *pRange,
1062 long *pb)
1064 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1065 if (!This->reOle)
1066 return CO_E_RELEASED;
1068 FIXME("not implemented\n");
1069 return E_NOTIMPL;
1072 static HRESULT WINAPI ITextSelection_fnInStory(
1073 ITextSelection *me,
1074 ITextRange *pRange,
1075 long *pb)
1077 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1078 if (!This->reOle)
1079 return CO_E_RELEASED;
1081 FIXME("not implemented\n");
1082 return E_NOTIMPL;
1085 static HRESULT WINAPI ITextSelection_fnIsEqual(
1086 ITextSelection *me,
1087 ITextRange *pRange,
1088 long *pb)
1090 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1091 if (!This->reOle)
1092 return CO_E_RELEASED;
1094 FIXME("not implemented\n");
1095 return E_NOTIMPL;
1098 static HRESULT WINAPI ITextSelection_fnSelect(
1099 ITextSelection *me)
1101 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1102 if (!This->reOle)
1103 return CO_E_RELEASED;
1105 FIXME("not implemented\n");
1106 return E_NOTIMPL;
1109 static HRESULT WINAPI ITextSelection_fnStartOf(
1110 ITextSelection *me,
1111 long Unit,
1112 long Extend,
1113 long *pDelta)
1115 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1116 if (!This->reOle)
1117 return CO_E_RELEASED;
1119 FIXME("not implemented\n");
1120 return E_NOTIMPL;
1123 static HRESULT WINAPI ITextSelection_fnEndOf(
1124 ITextSelection *me,
1125 long Unit,
1126 long Extend,
1127 long *pDelta)
1129 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1130 if (!This->reOle)
1131 return CO_E_RELEASED;
1133 FIXME("not implemented\n");
1134 return E_NOTIMPL;
1137 static HRESULT WINAPI ITextSelection_fnMove(
1138 ITextSelection *me,
1139 long Unit,
1140 long Count,
1141 long *pDelta)
1143 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1144 if (!This->reOle)
1145 return CO_E_RELEASED;
1147 FIXME("not implemented\n");
1148 return E_NOTIMPL;
1151 static HRESULT WINAPI ITextSelection_fnMoveStart(
1152 ITextSelection *me,
1153 long Unit,
1154 long Count,
1155 long *pDelta)
1157 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1158 if (!This->reOle)
1159 return CO_E_RELEASED;
1161 FIXME("not implemented\n");
1162 return E_NOTIMPL;
1165 static HRESULT WINAPI ITextSelection_fnMoveEnd(
1166 ITextSelection *me,
1167 long Unit,
1168 long Count,
1169 long *pDelta)
1171 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1172 if (!This->reOle)
1173 return CO_E_RELEASED;
1175 FIXME("not implemented\n");
1176 return E_NOTIMPL;
1179 static HRESULT WINAPI ITextSelection_fnMoveWhile(
1180 ITextSelection *me,
1181 VARIANT *Cset,
1182 long Count,
1183 long *pDelta)
1185 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1186 if (!This->reOle)
1187 return CO_E_RELEASED;
1189 FIXME("not implemented\n");
1190 return E_NOTIMPL;
1193 static HRESULT WINAPI ITextSelection_fnMoveStartWhile(
1194 ITextSelection *me,
1195 VARIANT *Cset,
1196 long Count,
1197 long *pDelta)
1199 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1200 if (!This->reOle)
1201 return CO_E_RELEASED;
1203 FIXME("not implemented\n");
1204 return E_NOTIMPL;
1207 static HRESULT WINAPI ITextSelection_fnMoveEndWhile(
1208 ITextSelection *me,
1209 VARIANT *Cset,
1210 long Count,
1211 long *pDelta)
1213 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1214 if (!This->reOle)
1215 return CO_E_RELEASED;
1217 FIXME("not implemented\n");
1218 return E_NOTIMPL;
1221 static HRESULT WINAPI ITextSelection_fnMoveUntil(
1222 ITextSelection *me,
1223 VARIANT *Cset,
1224 long Count,
1225 long *pDelta)
1227 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1228 if (!This->reOle)
1229 return CO_E_RELEASED;
1231 FIXME("not implemented\n");
1232 return E_NOTIMPL;
1235 static HRESULT WINAPI ITextSelection_fnMoveStartUntil(
1236 ITextSelection *me,
1237 VARIANT *Cset,
1238 long Count,
1239 long *pDelta)
1241 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1242 if (!This->reOle)
1243 return CO_E_RELEASED;
1245 FIXME("not implemented\n");
1246 return E_NOTIMPL;
1249 static HRESULT WINAPI ITextSelection_fnMoveEndUntil(
1250 ITextSelection *me,
1251 VARIANT *Cset,
1252 long Count,
1253 long *pDelta)
1255 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1256 if (!This->reOle)
1257 return CO_E_RELEASED;
1259 FIXME("not implemented\n");
1260 return E_NOTIMPL;
1263 static HRESULT WINAPI ITextSelection_fnFindText(
1264 ITextSelection *me,
1265 BSTR bstr,
1266 long cch,
1267 long Flags,
1268 long *pLength)
1270 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1271 if (!This->reOle)
1272 return CO_E_RELEASED;
1274 FIXME("not implemented\n");
1275 return E_NOTIMPL;
1278 static HRESULT WINAPI ITextSelection_fnFindTextStart(
1279 ITextSelection *me,
1280 BSTR bstr,
1281 long cch,
1282 long Flags,
1283 long *pLength)
1285 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1286 if (!This->reOle)
1287 return CO_E_RELEASED;
1289 FIXME("not implemented\n");
1290 return E_NOTIMPL;
1293 static HRESULT WINAPI ITextSelection_fnFindTextEnd(
1294 ITextSelection *me,
1295 BSTR bstr,
1296 long cch,
1297 long Flags,
1298 long *pLength)
1300 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1301 if (!This->reOle)
1302 return CO_E_RELEASED;
1304 FIXME("not implemented\n");
1305 return E_NOTIMPL;
1308 static HRESULT WINAPI ITextSelection_fnDelete(
1309 ITextSelection *me,
1310 long Unit,
1311 long Count,
1312 long *pDelta)
1314 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1315 if (!This->reOle)
1316 return CO_E_RELEASED;
1318 FIXME("not implemented\n");
1319 return E_NOTIMPL;
1322 static HRESULT WINAPI ITextSelection_fnCut(
1323 ITextSelection *me,
1324 VARIANT *pVar)
1326 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1327 if (!This->reOle)
1328 return CO_E_RELEASED;
1330 FIXME("not implemented\n");
1331 return E_NOTIMPL;
1334 static HRESULT WINAPI ITextSelection_fnCopy(
1335 ITextSelection *me,
1336 VARIANT *pVar)
1338 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1339 if (!This->reOle)
1340 return CO_E_RELEASED;
1342 FIXME("not implemented\n");
1343 return E_NOTIMPL;
1346 static HRESULT WINAPI ITextSelection_fnPaste(
1347 ITextSelection *me,
1348 VARIANT *pVar,
1349 long Format)
1351 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1352 if (!This->reOle)
1353 return CO_E_RELEASED;
1355 FIXME("not implemented\n");
1356 return E_NOTIMPL;
1359 static HRESULT WINAPI ITextSelection_fnCanPaste(
1360 ITextSelection *me,
1361 VARIANT *pVar,
1362 long Format,
1363 long *pb)
1365 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1366 if (!This->reOle)
1367 return CO_E_RELEASED;
1369 FIXME("not implemented\n");
1370 return E_NOTIMPL;
1373 static HRESULT WINAPI ITextSelection_fnCanEdit(
1374 ITextSelection *me,
1375 long *pb)
1377 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1378 if (!This->reOle)
1379 return CO_E_RELEASED;
1381 FIXME("not implemented\n");
1382 return E_NOTIMPL;
1385 static HRESULT WINAPI ITextSelection_fnChangeCase(
1386 ITextSelection *me,
1387 long Type)
1389 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1390 if (!This->reOle)
1391 return CO_E_RELEASED;
1393 FIXME("not implemented\n");
1394 return E_NOTIMPL;
1397 static HRESULT WINAPI ITextSelection_fnGetPoint(
1398 ITextSelection *me,
1399 long Type,
1400 long *cx,
1401 long *cy)
1403 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1404 if (!This->reOle)
1405 return CO_E_RELEASED;
1407 FIXME("not implemented\n");
1408 return E_NOTIMPL;
1411 static HRESULT WINAPI ITextSelection_fnSetPoint(
1412 ITextSelection *me,
1413 long x,
1414 long y,
1415 long Type,
1416 long Extend)
1418 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1419 if (!This->reOle)
1420 return CO_E_RELEASED;
1422 FIXME("not implemented\n");
1423 return E_NOTIMPL;
1426 static HRESULT WINAPI ITextSelection_fnScrollIntoView(
1427 ITextSelection *me,
1428 long Value)
1430 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1431 if (!This->reOle)
1432 return CO_E_RELEASED;
1434 FIXME("not implemented\n");
1435 return E_NOTIMPL;
1438 static HRESULT WINAPI ITextSelection_fnGetEmbeddedObject(
1439 ITextSelection *me,
1440 IUnknown **ppv)
1442 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1443 if (!This->reOle)
1444 return CO_E_RELEASED;
1446 FIXME("not implemented\n");
1447 return E_NOTIMPL;
1450 /*** ITextSelection methods ***/
1451 static HRESULT WINAPI ITextSelection_fnGetFlags(
1452 ITextSelection *me,
1453 long *pFlags)
1455 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1456 if (!This->reOle)
1457 return CO_E_RELEASED;
1459 FIXME("not implemented\n");
1460 return E_NOTIMPL;
1463 static HRESULT WINAPI ITextSelection_fnSetFlags(
1464 ITextSelection *me,
1465 long Flags)
1467 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1468 if (!This->reOle)
1469 return CO_E_RELEASED;
1471 FIXME("not implemented\n");
1472 return E_NOTIMPL;
1475 static HRESULT WINAPI ITextSelection_fnGetType(
1476 ITextSelection *me,
1477 long *pType)
1479 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1480 if (!This->reOle)
1481 return CO_E_RELEASED;
1483 FIXME("not implemented\n");
1484 return E_NOTIMPL;
1487 static HRESULT WINAPI ITextSelection_fnMoveLeft(
1488 ITextSelection *me,
1489 long Unit,
1490 long Count,
1491 long Extend,
1492 long *pDelta)
1494 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1495 if (!This->reOle)
1496 return CO_E_RELEASED;
1498 FIXME("not implemented\n");
1499 return E_NOTIMPL;
1502 static HRESULT WINAPI ITextSelection_fnMoveRight(
1503 ITextSelection *me,
1504 long Unit,
1505 long Count,
1506 long Extend,
1507 long *pDelta)
1509 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1510 if (!This->reOle)
1511 return CO_E_RELEASED;
1513 FIXME("not implemented\n");
1514 return E_NOTIMPL;
1517 static HRESULT WINAPI ITextSelection_fnMoveUp(
1518 ITextSelection *me,
1519 long Unit,
1520 long Count,
1521 long Extend,
1522 long *pDelta)
1524 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1525 if (!This->reOle)
1526 return CO_E_RELEASED;
1528 FIXME("not implemented\n");
1529 return E_NOTIMPL;
1532 static HRESULT WINAPI ITextSelection_fnMoveDown(
1533 ITextSelection *me,
1534 long Unit,
1535 long Count,
1536 long Extend,
1537 long *pDelta)
1539 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1540 if (!This->reOle)
1541 return CO_E_RELEASED;
1543 FIXME("not implemented\n");
1544 return E_NOTIMPL;
1547 static HRESULT WINAPI ITextSelection_fnHomeKey(
1548 ITextSelection *me,
1549 long Unit,
1550 long Extend,
1551 long *pDelta)
1553 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1554 if (!This->reOle)
1555 return CO_E_RELEASED;
1557 FIXME("not implemented\n");
1558 return E_NOTIMPL;
1561 static HRESULT WINAPI ITextSelection_fnEndKey(
1562 ITextSelection *me,
1563 long Unit,
1564 long Extend,
1565 long *pDelta)
1567 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1568 if (!This->reOle)
1569 return CO_E_RELEASED;
1571 FIXME("not implemented\n");
1572 return E_NOTIMPL;
1575 static HRESULT WINAPI ITextSelection_fnTypeText(
1576 ITextSelection *me,
1577 BSTR bstr)
1579 ITextSelectionImpl *This = (ITextSelectionImpl *) me;
1580 if (!This->reOle)
1581 return CO_E_RELEASED;
1583 FIXME("not implemented\n");
1584 return E_NOTIMPL;
1587 static const ITextSelectionVtbl tsvt = {
1588 ITextSelection_fnQueryInterface,
1589 ITextSelection_fnAddRef,
1590 ITextSelection_fnRelease,
1591 ITextSelection_fnGetTypeInfoCount,
1592 ITextSelection_fnGetTypeInfo,
1593 ITextSelection_fnGetIDsOfNames,
1594 ITextSelection_fnInvoke,
1595 ITextSelection_fnGetText,
1596 ITextSelection_fnSetText,
1597 ITextSelection_fnGetChar,
1598 ITextSelection_fnSetChar,
1599 ITextSelection_fnGetDuplicate,
1600 ITextSelection_fnGetFormattedText,
1601 ITextSelection_fnSetFormattedText,
1602 ITextSelection_fnGetStart,
1603 ITextSelection_fnSetStart,
1604 ITextSelection_fnGetEnd,
1605 ITextSelection_fnSetEnd,
1606 ITextSelection_fnGetFont,
1607 ITextSelection_fnSetFont,
1608 ITextSelection_fnGetPara,
1609 ITextSelection_fnSetPara,
1610 ITextSelection_fnGetStoryLength,
1611 ITextSelection_fnGetStoryType,
1612 ITextSelection_fnCollapse,
1613 ITextSelection_fnExpand,
1614 ITextSelection_fnGetIndex,
1615 ITextSelection_fnSetIndex,
1616 ITextSelection_fnSetRange,
1617 ITextSelection_fnInRange,
1618 ITextSelection_fnInStory,
1619 ITextSelection_fnIsEqual,
1620 ITextSelection_fnSelect,
1621 ITextSelection_fnStartOf,
1622 ITextSelection_fnEndOf,
1623 ITextSelection_fnMove,
1624 ITextSelection_fnMoveStart,
1625 ITextSelection_fnMoveEnd,
1626 ITextSelection_fnMoveWhile,
1627 ITextSelection_fnMoveStartWhile,
1628 ITextSelection_fnMoveEndWhile,
1629 ITextSelection_fnMoveUntil,
1630 ITextSelection_fnMoveStartUntil,
1631 ITextSelection_fnMoveEndUntil,
1632 ITextSelection_fnFindText,
1633 ITextSelection_fnFindTextStart,
1634 ITextSelection_fnFindTextEnd,
1635 ITextSelection_fnDelete,
1636 ITextSelection_fnCut,
1637 ITextSelection_fnCopy,
1638 ITextSelection_fnPaste,
1639 ITextSelection_fnCanPaste,
1640 ITextSelection_fnCanEdit,
1641 ITextSelection_fnChangeCase,
1642 ITextSelection_fnGetPoint,
1643 ITextSelection_fnSetPoint,
1644 ITextSelection_fnScrollIntoView,
1645 ITextSelection_fnGetEmbeddedObject,
1646 ITextSelection_fnGetFlags,
1647 ITextSelection_fnSetFlags,
1648 ITextSelection_fnGetType,
1649 ITextSelection_fnMoveLeft,
1650 ITextSelection_fnMoveRight,
1651 ITextSelection_fnMoveUp,
1652 ITextSelection_fnMoveDown,
1653 ITextSelection_fnHomeKey,
1654 ITextSelection_fnEndKey,
1655 ITextSelection_fnTypeText
1658 static ITextSelectionImpl *
1659 CreateTextSelection(IRichEditOleImpl *reOle)
1661 ITextSelectionImpl *txtSel = heap_alloc(sizeof *txtSel);
1662 if (!txtSel)
1663 return NULL;
1665 txtSel->lpVtbl = &tsvt;
1666 txtSel->ref = 1;
1667 txtSel->reOle = reOle;
1668 return txtSel;
1671 LRESULT CreateIRichEditOle(ME_TextEditor *editor, LPVOID *ppObj)
1673 IRichEditOleImpl *reo;
1675 reo = heap_alloc(sizeof(IRichEditOleImpl));
1676 if (!reo)
1677 return 0;
1679 reo->lpRichEditOleVtbl = &revt;
1680 reo->lpTextDocumentVtbl = &tdvt;
1681 reo->ref = 1;
1682 reo->editor = editor;
1683 reo->txtSel = CreateTextSelection(reo);
1684 if (!reo->txtSel)
1686 heap_free(reo);
1687 return 0;
1689 reo->clientSite = CreateOleClientSite(reo);
1690 if (!reo->txtSel)
1692 ITextSelection_Release((ITextSelection *) reo->txtSel);
1693 heap_free(reo);
1694 return 0;
1696 TRACE("Created %p\n",reo);
1697 *ppObj = reo;
1699 return 1;
1702 static void convert_sizel(ME_Context *c, const SIZEL* szl, SIZE* sz)
1704 /* sizel is in .01 millimeters, sz in pixels */
1705 sz->cx = MulDiv(szl->cx, c->dpi.cx, 2540);
1706 sz->cy = MulDiv(szl->cy, c->dpi.cy, 2540);
1709 /******************************************************************************
1710 * ME_GetOLEObjectSize
1712 * Sets run extent for OLE objects.
1714 void ME_GetOLEObjectSize(ME_Context *c, ME_Run *run, SIZE *pSize)
1716 IDataObject* ido;
1717 FORMATETC fmt;
1718 STGMEDIUM stgm;
1719 DIBSECTION dibsect;
1720 ENHMETAHEADER emh;
1722 assert(run->nFlags & MERF_GRAPHICS);
1723 assert(run->ole_obj);
1725 if (run->ole_obj->sizel.cx != 0 || run->ole_obj->sizel.cy != 0)
1727 convert_sizel(c, &run->ole_obj->sizel, pSize);
1728 return;
1731 IOleObject_QueryInterface(run->ole_obj->poleobj, &IID_IDataObject, (void**)&ido);
1732 fmt.cfFormat = CF_BITMAP;
1733 fmt.ptd = NULL;
1734 fmt.dwAspect = DVASPECT_CONTENT;
1735 fmt.lindex = -1;
1736 fmt.tymed = TYMED_GDI;
1737 if (IDataObject_GetData(ido, &fmt, &stgm) != S_OK)
1739 fmt.cfFormat = CF_ENHMETAFILE;
1740 fmt.tymed = TYMED_ENHMF;
1741 if (IDataObject_GetData(ido, &fmt, &stgm) != S_OK)
1743 FIXME("unsupported format\n");
1744 pSize->cx = pSize->cy = 0;
1745 IDataObject_Release(ido);
1746 return;
1750 switch (stgm.tymed)
1752 case TYMED_GDI:
1753 GetObjectW(stgm.u.hBitmap, sizeof(dibsect), &dibsect);
1754 pSize->cx = dibsect.dsBm.bmWidth;
1755 pSize->cy = dibsect.dsBm.bmHeight;
1756 if (!stgm.pUnkForRelease) DeleteObject(stgm.u.hBitmap);
1757 break;
1758 case TYMED_ENHMF:
1759 GetEnhMetaFileHeader(stgm.u.hEnhMetaFile, sizeof(emh), &emh);
1760 pSize->cx = emh.rclBounds.right - emh.rclBounds.left;
1761 pSize->cy = emh.rclBounds.bottom - emh.rclBounds.top;
1762 if (!stgm.pUnkForRelease) DeleteEnhMetaFile(stgm.u.hEnhMetaFile);
1763 break;
1764 default:
1765 FIXME("Unsupported tymed %d\n", stgm.tymed);
1766 break;
1768 IDataObject_Release(ido);
1769 if (c->editor->nZoomNumerator != 0)
1771 pSize->cx = MulDiv(pSize->cx, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
1772 pSize->cy = MulDiv(pSize->cy, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
1776 void ME_DrawOLE(ME_Context *c, int x, int y, ME_Run *run,
1777 ME_Paragraph *para, BOOL selected)
1779 IDataObject* ido;
1780 FORMATETC fmt;
1781 STGMEDIUM stgm;
1782 DIBSECTION dibsect;
1783 ENHMETAHEADER emh;
1784 HDC hMemDC;
1785 SIZE sz;
1786 BOOL has_size;
1788 assert(run->nFlags & MERF_GRAPHICS);
1789 assert(run->ole_obj);
1790 if (IOleObject_QueryInterface(run->ole_obj->poleobj, &IID_IDataObject, (void**)&ido) != S_OK)
1792 FIXME("Couldn't get interface\n");
1793 return;
1795 has_size = run->ole_obj->sizel.cx != 0 || run->ole_obj->sizel.cy != 0;
1796 fmt.cfFormat = CF_BITMAP;
1797 fmt.ptd = NULL;
1798 fmt.dwAspect = DVASPECT_CONTENT;
1799 fmt.lindex = -1;
1800 fmt.tymed = TYMED_GDI;
1801 if (IDataObject_GetData(ido, &fmt, &stgm) != S_OK)
1803 fmt.cfFormat = CF_ENHMETAFILE;
1804 fmt.tymed = TYMED_ENHMF;
1805 if (IDataObject_GetData(ido, &fmt, &stgm) != S_OK)
1807 FIXME("Couldn't get storage medium\n");
1808 IDataObject_Release(ido);
1809 return;
1812 switch (stgm.tymed)
1814 case TYMED_GDI:
1815 GetObjectW(stgm.u.hBitmap, sizeof(dibsect), &dibsect);
1816 hMemDC = CreateCompatibleDC(c->hDC);
1817 SelectObject(hMemDC, stgm.u.hBitmap);
1818 if (!has_size && c->editor->nZoomNumerator == 0)
1820 sz.cx = dibsect.dsBm.bmWidth;
1821 sz.cy = dibsect.dsBm.bmHeight;
1822 BitBlt(c->hDC, x, y - dibsect.dsBm.bmHeight,
1823 dibsect.dsBm.bmWidth, dibsect.dsBm.bmHeight,
1824 hMemDC, 0, 0, SRCCOPY);
1826 else
1828 if (has_size)
1830 convert_sizel(c, &run->ole_obj->sizel, &sz);
1832 else
1834 sz.cx = MulDiv(dibsect.dsBm.bmWidth,
1835 c->editor->nZoomNumerator, c->editor->nZoomDenominator);
1836 sz.cy = MulDiv(dibsect.dsBm.bmHeight,
1837 c->editor->nZoomNumerator, c->editor->nZoomDenominator);
1839 StretchBlt(c->hDC, x, y - sz.cy, sz.cx, sz.cy,
1840 hMemDC, 0, 0, dibsect.dsBm.bmWidth, dibsect.dsBm.bmHeight, SRCCOPY);
1842 if (!stgm.pUnkForRelease) DeleteObject(stgm.u.hBitmap);
1843 break;
1844 case TYMED_ENHMF:
1845 GetEnhMetaFileHeader(stgm.u.hEnhMetaFile, sizeof(emh), &emh);
1846 if (!has_size && c->editor->nZoomNumerator == 0)
1848 sz.cy = emh.rclBounds.bottom - emh.rclBounds.top;
1849 sz.cx = emh.rclBounds.right - emh.rclBounds.left;
1851 else
1853 if (has_size)
1855 convert_sizel(c, &run->ole_obj->sizel, &sz);
1857 else
1859 sz.cy = MulDiv(emh.rclBounds.bottom - emh.rclBounds.top,
1860 c->editor->nZoomNumerator, c->editor->nZoomDenominator);
1861 sz.cx = MulDiv(emh.rclBounds.right - emh.rclBounds.left,
1862 c->editor->nZoomNumerator, c->editor->nZoomDenominator);
1866 RECT rc;
1868 rc.left = x;
1869 rc.top = y - sz.cy;
1870 rc.right = x + sz.cx;
1871 rc.bottom = y;
1872 PlayEnhMetaFile(c->hDC, stgm.u.hEnhMetaFile, &rc);
1874 if (!stgm.pUnkForRelease) DeleteEnhMetaFile(stgm.u.hEnhMetaFile);
1875 break;
1876 default:
1877 FIXME("Unsupported tymed %d\n", stgm.tymed);
1878 selected = FALSE;
1879 break;
1881 if (selected && !c->editor->bHideSelection)
1882 PatBlt(c->hDC, x, y - sz.cy, sz.cx, sz.cy, DSTINVERT);
1883 IDataObject_Release(ido);
1886 void ME_DeleteReObject(REOBJECT* reo)
1888 if (reo->poleobj) IOleObject_Release(reo->poleobj);
1889 if (reo->pstg) IStorage_Release(reo->pstg);
1890 if (reo->polesite) IOleClientSite_Release(reo->polesite);
1891 FREE_OBJ(reo);
1894 void ME_CopyReObject(REOBJECT* dst, const REOBJECT* src)
1896 *dst = *src;
1898 if (dst->poleobj) IOleObject_AddRef(dst->poleobj);
1899 if (dst->pstg) IStorage_AddRef(dst->pstg);
1900 if (dst->polesite) IOleClientSite_AddRef(dst->polesite);