riched20: Implement SetEnd().
[wine.git] / dlls / riched20 / richole.c
blob4f85325d56ae9d54763ea725ec4dd6d2204c2a4a
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 COBJMACROS
27 #include "windef.h"
28 #include "winbase.h"
29 #include "wingdi.h"
30 #include "winuser.h"
31 #include "ole2.h"
32 #include "richole.h"
33 #include "editor.h"
34 #include "tom.h"
35 #include "wine/debug.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(richedit);
39 /* there is no way to be consistent across different sets of headers - mingw, Wine, Win32 SDK*/
41 #include "initguid.h"
42 DEFINE_GUID(IID_ITextServices, 0x8d33f740, 0xcf58, 0x11ce, 0xa8, 0x9d, 0x00, 0xaa, 0x00, 0x6c, 0xad, 0xc5);
43 DEFINE_GUID(IID_ITextHost, 0x13e670f4,0x1a5a,0x11cf,0xab,0xeb,0x00,0xaa,0x00,0xb6,0x5e,0xa1);
44 DEFINE_GUID(IID_ITextHost2, 0x13e670f5,0x1a5a,0x11cf,0xab,0xeb,0x00,0xaa,0x00,0xb6,0x5e,0xa1);
45 DEFINE_GUID(IID_ITextDocument, 0x8cc497c0, 0xa1df, 0x11ce, 0x80, 0x98, 0x00, 0xaa, 0x00, 0x47, 0xbe, 0x5d);
46 DEFINE_GUID(IID_ITextRange, 0x8cc497c2, 0xa1df, 0x11ce, 0x80, 0x98, 0x00, 0xaa, 0x00, 0x47, 0xbe, 0x5d);
47 DEFINE_GUID(IID_ITextSelection, 0x8cc497c1, 0xa1df, 0x11ce, 0x80, 0x98, 0x00, 0xaa, 0x00, 0x47, 0xbe, 0x5d);
48 DEFINE_GUID(IID_ITextFont, 0x8cc497c3, 0xa1df, 0x11ce, 0x80, 0x98, 0x00, 0xaa, 0x00, 0x47, 0xbe, 0x5d);
49 DEFINE_GUID(IID_ITextPara, 0x8cc497c4, 0xa1df, 0x11ce, 0x80, 0x98, 0x00, 0xaa, 0x00, 0x47, 0xbe, 0x5d);
51 typedef struct ITextSelectionImpl ITextSelectionImpl;
52 typedef struct IOleClientSiteImpl IOleClientSiteImpl;
53 typedef struct ITextRangeImpl ITextRangeImpl;
55 typedef struct IRichEditOleImpl {
56 IUnknown IUnknown_inner;
57 IRichEditOle IRichEditOle_iface;
58 ITextDocument ITextDocument_iface;
59 IUnknown *outer_unk;
60 LONG ref;
62 ME_TextEditor *editor;
63 ITextSelectionImpl *txtSel;
64 IOleClientSiteImpl *clientSite;
65 struct list rangelist;
66 } IRichEditOleImpl;
68 struct ITextRangeImpl {
69 ITextRange ITextRange_iface;
70 LONG ref;
71 LONG start, end;
72 struct list entry;
74 IRichEditOleImpl *reOle;
77 struct ITextSelectionImpl {
78 ITextSelection ITextSelection_iface;
79 LONG ref;
81 IRichEditOleImpl *reOle;
84 typedef struct ITextFontImpl {
85 ITextFont ITextFont_iface;
86 LONG ref;
88 ITextRange *range;
89 } ITextFontImpl;
91 typedef struct ITextParaImpl {
92 ITextPara ITextPara_iface;
93 LONG ref;
95 ITextRange *range;
96 } ITextParaImpl;
98 struct IOleClientSiteImpl {
99 IOleClientSite IOleClientSite_iface;
100 IOleWindow IOleWindow_iface;
101 IOleInPlaceSite IOleInPlaceSite_iface;
102 LONG ref;
104 IRichEditOleImpl *reOle;
107 static inline IRichEditOleImpl *impl_from_IRichEditOle(IRichEditOle *iface)
109 return CONTAINING_RECORD(iface, IRichEditOleImpl, IRichEditOle_iface);
112 static inline IRichEditOleImpl *impl_from_ITextDocument(ITextDocument *iface)
114 return CONTAINING_RECORD(iface, IRichEditOleImpl, ITextDocument_iface);
117 static inline IRichEditOleImpl *impl_from_IUnknown(IUnknown *iface)
119 return CONTAINING_RECORD(iface, IRichEditOleImpl, IUnknown_inner);
122 static inline IOleClientSiteImpl *impl_from_IOleWindow(IOleWindow *iface)
124 return CONTAINING_RECORD(iface, IOleClientSiteImpl, IOleWindow_iface);
127 static inline IOleClientSiteImpl *impl_from_IOleInPlaceSite(IOleInPlaceSite *iface)
129 return CONTAINING_RECORD(iface, IOleClientSiteImpl, IOleInPlaceSite_iface);
132 static inline ITextSelectionImpl *impl_from_ITextSelection(ITextSelection *iface)
134 return CONTAINING_RECORD(iface, ITextSelectionImpl, ITextSelection_iface);
137 static inline ITextFontImpl *impl_from_ITextFont(ITextFont *iface)
139 return CONTAINING_RECORD(iface, ITextFontImpl, ITextFont_iface);
142 static inline ITextParaImpl *impl_from_ITextPara(ITextPara *iface)
144 return CONTAINING_RECORD(iface, ITextParaImpl, ITextPara_iface);
147 static HRESULT create_textfont(ITextRange*, ITextFont**);
148 static HRESULT create_textpara(ITextRange*, ITextPara**);
150 static HRESULT WINAPI IRichEditOleImpl_inner_fnQueryInterface(IUnknown *iface, REFIID riid, LPVOID *ppvObj)
152 IRichEditOleImpl *This = impl_from_IUnknown(iface);
154 TRACE("%p %s\n", This, debugstr_guid(riid));
156 *ppvObj = NULL;
157 if (IsEqualGUID(riid, &IID_IUnknown))
158 *ppvObj = &This->IUnknown_inner;
159 else if (IsEqualGUID(riid, &IID_IRichEditOle))
160 *ppvObj = &This->IRichEditOle_iface;
161 else if (IsEqualGUID(riid, &IID_ITextDocument))
162 *ppvObj = &This->ITextDocument_iface;
163 if (*ppvObj)
165 IUnknown_AddRef((IUnknown *)*ppvObj);
166 return S_OK;
168 FIXME("%p: unhandled interface %s\n", This, debugstr_guid(riid));
170 return E_NOINTERFACE;
173 static ULONG WINAPI IRichEditOleImpl_inner_fnAddRef(IUnknown *iface)
175 IRichEditOleImpl *This = impl_from_IUnknown(iface);
176 ULONG ref = InterlockedIncrement(&This->ref);
178 TRACE("%p ref = %u\n", This, ref);
180 return ref;
183 static ULONG WINAPI IRichEditOleImpl_inner_fnRelease(IUnknown *iface)
185 IRichEditOleImpl *This = impl_from_IUnknown(iface);
186 ULONG ref = InterlockedDecrement(&This->ref);
188 TRACE ("%p ref=%u\n", This, ref);
190 if (!ref)
192 ITextRangeImpl *txtRge;
194 TRACE("Destroying %p\n", This);
195 This->txtSel->reOle = NULL;
196 This->editor->reOle = NULL;
197 ITextSelection_Release(&This->txtSel->ITextSelection_iface);
198 IOleClientSite_Release(&This->clientSite->IOleClientSite_iface);
199 LIST_FOR_EACH_ENTRY(txtRge, &This->rangelist, ITextRangeImpl, entry)
200 txtRge->reOle = NULL;
201 heap_free(This);
203 return ref;
206 static const IUnknownVtbl reo_unk_vtbl =
208 IRichEditOleImpl_inner_fnQueryInterface,
209 IRichEditOleImpl_inner_fnAddRef,
210 IRichEditOleImpl_inner_fnRelease
213 static HRESULT WINAPI
214 IRichEditOle_fnQueryInterface(IRichEditOle *me, REFIID riid, LPVOID *ppvObj)
216 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
217 return IUnknown_QueryInterface(This->outer_unk, riid, ppvObj);
220 static ULONG WINAPI
221 IRichEditOle_fnAddRef(IRichEditOle *me)
223 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
224 return IUnknown_AddRef(This->outer_unk);
227 static ULONG WINAPI
228 IRichEditOle_fnRelease(IRichEditOle *me)
230 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
231 return IUnknown_Release(This->outer_unk);
234 static HRESULT WINAPI
235 IRichEditOle_fnActivateAs(IRichEditOle *me, REFCLSID rclsid, REFCLSID rclsidAs)
237 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
238 FIXME("stub %p\n",This);
239 return E_NOTIMPL;
242 static HRESULT WINAPI
243 IRichEditOle_fnContextSensitiveHelp(IRichEditOle *me, BOOL fEnterMode)
245 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
246 FIXME("stub %p\n",This);
247 return E_NOTIMPL;
250 static HRESULT WINAPI
251 IRichEditOle_fnConvertObject(IRichEditOle *me, LONG iob,
252 REFCLSID rclsidNew, LPCSTR lpstrUserTypeNew)
254 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
255 FIXME("stub %p\n",This);
256 return E_NOTIMPL;
259 static inline IOleClientSiteImpl *impl_from_IOleClientSite(IOleClientSite *iface)
261 return CONTAINING_RECORD(iface, IOleClientSiteImpl, IOleClientSite_iface);
264 static HRESULT WINAPI
265 IOleClientSite_fnQueryInterface(IOleClientSite *me, REFIID riid, LPVOID *ppvObj)
267 IOleClientSiteImpl *This = impl_from_IOleClientSite(me);
268 TRACE("%p %s\n", me, debugstr_guid(riid) );
270 *ppvObj = NULL;
271 if (IsEqualGUID(riid, &IID_IUnknown) ||
272 IsEqualGUID(riid, &IID_IOleClientSite))
273 *ppvObj = me;
274 else if (IsEqualGUID(riid, &IID_IOleWindow))
275 *ppvObj = &This->IOleWindow_iface;
276 else if (IsEqualGUID(riid, &IID_IOleInPlaceSite))
277 *ppvObj = &This->IOleInPlaceSite_iface;
278 if (*ppvObj)
280 IOleClientSite_AddRef(me);
281 return S_OK;
283 FIXME("%p: unhandled interface %s\n", me, debugstr_guid(riid) );
285 return E_NOINTERFACE;
288 static ULONG WINAPI IOleClientSite_fnAddRef(IOleClientSite *iface)
290 IOleClientSiteImpl *This = impl_from_IOleClientSite(iface);
291 return InterlockedIncrement(&This->ref);
294 static ULONG WINAPI IOleClientSite_fnRelease(IOleClientSite *iface)
296 IOleClientSiteImpl *This = impl_from_IOleClientSite(iface);
297 ULONG ref = InterlockedDecrement(&This->ref);
298 if (ref == 0)
299 heap_free(This);
300 return ref;
303 static HRESULT WINAPI IOleClientSite_fnSaveObject(IOleClientSite *iface)
305 IOleClientSiteImpl *This = impl_from_IOleClientSite(iface);
306 if (!This->reOle)
307 return CO_E_RELEASED;
309 FIXME("stub %p\n", iface);
310 return E_NOTIMPL;
314 static HRESULT WINAPI IOleClientSite_fnGetMoniker(IOleClientSite *iface, DWORD dwAssign,
315 DWORD dwWhichMoniker, IMoniker **ppmk)
317 IOleClientSiteImpl *This = impl_from_IOleClientSite(iface);
318 if (!This->reOle)
319 return CO_E_RELEASED;
321 FIXME("stub %p\n", iface);
322 return E_NOTIMPL;
325 static HRESULT WINAPI IOleClientSite_fnGetContainer(IOleClientSite *iface,
326 IOleContainer **ppContainer)
328 IOleClientSiteImpl *This = impl_from_IOleClientSite(iface);
329 if (!This->reOle)
330 return CO_E_RELEASED;
332 FIXME("stub %p\n", iface);
333 return E_NOTIMPL;
336 static HRESULT WINAPI IOleClientSite_fnShowObject(IOleClientSite *iface)
338 IOleClientSiteImpl *This = impl_from_IOleClientSite(iface);
339 if (!This->reOle)
340 return CO_E_RELEASED;
342 FIXME("stub %p\n", iface);
343 return E_NOTIMPL;
346 static HRESULT WINAPI IOleClientSite_fnOnShowWindow(IOleClientSite *iface, BOOL fShow)
348 IOleClientSiteImpl *This = impl_from_IOleClientSite(iface);
349 if (!This->reOle)
350 return CO_E_RELEASED;
352 FIXME("stub %p\n", iface);
353 return E_NOTIMPL;
356 static HRESULT WINAPI IOleClientSite_fnRequestNewObjectLayout(IOleClientSite *iface)
358 IOleClientSiteImpl *This = impl_from_IOleClientSite(iface);
359 if (!This->reOle)
360 return CO_E_RELEASED;
362 FIXME("stub %p\n", iface);
363 return E_NOTIMPL;
366 static const IOleClientSiteVtbl ocst = {
367 IOleClientSite_fnQueryInterface,
368 IOleClientSite_fnAddRef,
369 IOleClientSite_fnRelease,
370 IOleClientSite_fnSaveObject,
371 IOleClientSite_fnGetMoniker,
372 IOleClientSite_fnGetContainer,
373 IOleClientSite_fnShowObject,
374 IOleClientSite_fnOnShowWindow,
375 IOleClientSite_fnRequestNewObjectLayout
378 /* IOleWindow interface */
379 static HRESULT WINAPI IOleWindow_fnQueryInterface(IOleWindow *iface, REFIID riid, void **ppvObj)
381 IOleClientSiteImpl *This = impl_from_IOleWindow(iface);
382 return IOleClientSite_QueryInterface(&This->IOleClientSite_iface, riid, ppvObj);
385 static ULONG WINAPI IOleWindow_fnAddRef(IOleWindow *iface)
387 IOleClientSiteImpl *This = impl_from_IOleWindow(iface);
388 return IOleClientSite_AddRef(&This->IOleClientSite_iface);
391 static ULONG WINAPI IOleWindow_fnRelease(IOleWindow *iface)
393 IOleClientSiteImpl *This = impl_from_IOleWindow(iface);
394 return IOleClientSite_Release(&This->IOleClientSite_iface);
397 static HRESULT WINAPI IOleWindow_fnContextSensitiveHelp(IOleWindow *iface, BOOL fEnterMode)
399 IOleClientSiteImpl *This = impl_from_IOleWindow(iface);
400 FIXME("not implemented: (%p)->(%d)\n", This, fEnterMode);
401 return E_NOTIMPL;
404 static HRESULT WINAPI IOleWindow_fnGetWindow(IOleWindow *iface, HWND *phwnd)
406 IOleClientSiteImpl *This = impl_from_IOleWindow(iface);
407 TRACE("(%p)->(%p)\n", This, phwnd);
409 if (!phwnd)
410 return E_INVALIDARG;
412 *phwnd = This->reOle->editor->hWnd;
413 return S_OK;
416 static const IOleWindowVtbl olewinvt = {
417 IOleWindow_fnQueryInterface,
418 IOleWindow_fnAddRef,
419 IOleWindow_fnRelease,
420 IOleWindow_fnGetWindow,
421 IOleWindow_fnContextSensitiveHelp
424 /* IOleInPlaceSite interface */
425 static HRESULT STDMETHODCALLTYPE IOleInPlaceSite_fnQueryInterface(IOleInPlaceSite *iface, REFIID riid, void **ppvObj)
427 IOleClientSiteImpl *This = impl_from_IOleInPlaceSite(iface);
428 return IOleClientSite_QueryInterface(&This->IOleClientSite_iface, riid, ppvObj);
431 static ULONG STDMETHODCALLTYPE IOleInPlaceSite_fnAddRef(IOleInPlaceSite *iface)
433 IOleClientSiteImpl *This = impl_from_IOleInPlaceSite(iface);
434 return IOleClientSite_AddRef(&This->IOleClientSite_iface);
437 static ULONG STDMETHODCALLTYPE IOleInPlaceSite_fnRelease(IOleInPlaceSite *iface)
439 IOleClientSiteImpl *This = impl_from_IOleInPlaceSite(iface);
440 return IOleClientSite_Release(&This->IOleClientSite_iface);
443 static HRESULT STDMETHODCALLTYPE IOleInPlaceSite_fnGetWindow(IOleInPlaceSite *iface, HWND *phwnd)
445 IOleClientSiteImpl *This = impl_from_IOleInPlaceSite(iface);
446 return IOleWindow_GetWindow(&This->IOleWindow_iface, phwnd);
449 static HRESULT STDMETHODCALLTYPE IOleInPlaceSite_fnContextSensitiveHelp(IOleInPlaceSite *iface, BOOL fEnterMode)
451 IOleClientSiteImpl *This = impl_from_IOleInPlaceSite(iface);
452 return IOleWindow_ContextSensitiveHelp(&This->IOleWindow_iface, fEnterMode);
455 static HRESULT STDMETHODCALLTYPE IOleInPlaceSite_fnCanInPlaceActivate(IOleInPlaceSite *iface)
457 IOleClientSiteImpl *This = impl_from_IOleInPlaceSite(iface);
458 FIXME("not implemented: (%p)\n", This);
459 return E_NOTIMPL;
462 static HRESULT STDMETHODCALLTYPE IOleInPlaceSite_fnOnInPlaceActivate(IOleInPlaceSite *iface)
464 IOleClientSiteImpl *This = impl_from_IOleInPlaceSite(iface);
465 FIXME("not implemented: (%p)\n", This);
466 return E_NOTIMPL;
469 static HRESULT STDMETHODCALLTYPE IOleInPlaceSite_fnOnUIActivate(IOleInPlaceSite *iface)
471 IOleClientSiteImpl *This = impl_from_IOleInPlaceSite(iface);
472 FIXME("not implemented: (%p)\n", This);
473 return E_NOTIMPL;
476 static HRESULT STDMETHODCALLTYPE IOleInPlaceSite_fnGetWindowContext(IOleInPlaceSite *iface, IOleInPlaceFrame **ppFrame,
477 IOleInPlaceUIWindow **ppDoc, LPRECT lprcPosRect,
478 LPRECT lprcClipRect, LPOLEINPLACEFRAMEINFO lpFrameInfo)
480 IOleClientSiteImpl *This = impl_from_IOleInPlaceSite(iface);
481 FIXME("not implemented: (%p)->(%p %p %p %p %p)\n", This, ppFrame, ppDoc, lprcPosRect, lprcClipRect, lpFrameInfo);
482 return E_NOTIMPL;
485 static HRESULT STDMETHODCALLTYPE IOleInPlaceSite_fnScroll(IOleInPlaceSite *iface, SIZE scrollExtent)
487 IOleClientSiteImpl *This = impl_from_IOleInPlaceSite(iface);
488 FIXME("not implemented: (%p)\n", This);
489 return E_NOTIMPL;
492 static HRESULT STDMETHODCALLTYPE IOleInPlaceSite_fnOnUIDeactivate(IOleInPlaceSite *iface, BOOL fUndoable)
494 IOleClientSiteImpl *This = impl_from_IOleInPlaceSite(iface);
495 FIXME("not implemented: (%p)->(%d)\n", This, fUndoable);
496 return E_NOTIMPL;
499 static HRESULT STDMETHODCALLTYPE IOleInPlaceSite_fnOnInPlaceDeactivate(IOleInPlaceSite *iface)
501 IOleClientSiteImpl *This = impl_from_IOleInPlaceSite(iface);
502 FIXME("not implemented: (%p)\n", This);
503 return E_NOTIMPL;
506 static HRESULT STDMETHODCALLTYPE IOleInPlaceSite_fnDiscardUndoState(IOleInPlaceSite *iface)
508 IOleClientSiteImpl *This = impl_from_IOleInPlaceSite(iface);
509 FIXME("not implemented: (%p)\n", This);
510 return E_NOTIMPL;
513 static HRESULT STDMETHODCALLTYPE IOleInPlaceSite_fnDeactivateAndUndo(IOleInPlaceSite *iface)
515 IOleClientSiteImpl *This = impl_from_IOleInPlaceSite(iface);
516 FIXME("not implemented: (%p)\n", This);
517 return E_NOTIMPL;
520 static HRESULT STDMETHODCALLTYPE IOleInPlaceSite_fnOnPosRectChange(IOleInPlaceSite *iface, LPCRECT lprcPosRect)
522 IOleClientSiteImpl *This = impl_from_IOleInPlaceSite(iface);
523 FIXME("not implemented: (%p)->(%p)\n", This, lprcPosRect);
524 return E_NOTIMPL;
527 static const IOleInPlaceSiteVtbl olestvt =
529 IOleInPlaceSite_fnQueryInterface,
530 IOleInPlaceSite_fnAddRef,
531 IOleInPlaceSite_fnRelease,
532 IOleInPlaceSite_fnGetWindow,
533 IOleInPlaceSite_fnContextSensitiveHelp,
534 IOleInPlaceSite_fnCanInPlaceActivate,
535 IOleInPlaceSite_fnOnInPlaceActivate,
536 IOleInPlaceSite_fnOnUIActivate,
537 IOleInPlaceSite_fnGetWindowContext,
538 IOleInPlaceSite_fnScroll,
539 IOleInPlaceSite_fnOnUIDeactivate,
540 IOleInPlaceSite_fnOnInPlaceDeactivate,
541 IOleInPlaceSite_fnDiscardUndoState,
542 IOleInPlaceSite_fnDeactivateAndUndo,
543 IOleInPlaceSite_fnOnPosRectChange
546 static IOleClientSiteImpl *
547 CreateOleClientSite(IRichEditOleImpl *reOle)
549 IOleClientSiteImpl *clientSite = heap_alloc(sizeof *clientSite);
550 if (!clientSite)
551 return NULL;
553 clientSite->IOleClientSite_iface.lpVtbl = &ocst;
554 clientSite->IOleWindow_iface.lpVtbl = &olewinvt;
555 clientSite->IOleInPlaceSite_iface.lpVtbl = &olestvt;
556 clientSite->ref = 1;
557 clientSite->reOle = reOle;
558 return clientSite;
561 static HRESULT WINAPI
562 IRichEditOle_fnGetClientSite(IRichEditOle *me,
563 LPOLECLIENTSITE *lplpolesite)
565 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
567 TRACE("%p,%p\n",This, lplpolesite);
569 if(!lplpolesite)
570 return E_INVALIDARG;
571 *lplpolesite = &This->clientSite->IOleClientSite_iface;
572 IOleClientSite_AddRef(*lplpolesite);
573 return S_OK;
576 static HRESULT WINAPI
577 IRichEditOle_fnGetClipboardData(IRichEditOle *me, CHARRANGE *lpchrg,
578 DWORD reco, LPDATAOBJECT *lplpdataobj)
580 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
581 ME_Cursor start;
582 int nChars;
584 TRACE("(%p,%p,%d)\n",This, lpchrg, reco);
585 if(!lplpdataobj)
586 return E_INVALIDARG;
587 if(!lpchrg) {
588 int nFrom, nTo, nStartCur = ME_GetSelectionOfs(This->editor, &nFrom, &nTo);
589 start = This->editor->pCursors[nStartCur];
590 nChars = nTo - nFrom;
591 } else {
592 ME_CursorFromCharOfs(This->editor, lpchrg->cpMin, &start);
593 nChars = lpchrg->cpMax - lpchrg->cpMin;
595 return ME_GetDataObject(This->editor, &start, nChars, lplpdataobj);
598 static LONG WINAPI IRichEditOle_fnGetLinkCount(IRichEditOle *me)
600 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
601 FIXME("stub %p\n",This);
602 return E_NOTIMPL;
605 static HRESULT WINAPI
606 IRichEditOle_fnGetObject(IRichEditOle *me, LONG iob,
607 REOBJECT *lpreobject, DWORD dwFlags)
609 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
610 FIXME("stub %p\n",This);
611 return E_NOTIMPL;
614 static LONG WINAPI
615 IRichEditOle_fnGetObjectCount(IRichEditOle *me)
617 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
618 FIXME("stub %p\n",This);
619 return 0;
622 static HRESULT WINAPI
623 IRichEditOle_fnHandsOffStorage(IRichEditOle *me, LONG iob)
625 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
626 FIXME("stub %p\n",This);
627 return E_NOTIMPL;
630 static HRESULT WINAPI
631 IRichEditOle_fnImportDataObject(IRichEditOle *me, LPDATAOBJECT lpdataobj,
632 CLIPFORMAT cf, HGLOBAL hMetaPict)
634 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
635 FIXME("stub %p\n",This);
636 return E_NOTIMPL;
639 static HRESULT WINAPI
640 IRichEditOle_fnInPlaceDeactivate(IRichEditOle *me)
642 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
643 FIXME("stub %p\n",This);
644 return E_NOTIMPL;
647 static HRESULT WINAPI
648 IRichEditOle_fnInsertObject(IRichEditOle *me, REOBJECT *reo)
650 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
651 TRACE("(%p,%p)\n", This, reo);
653 if (reo->cbStruct < sizeof(*reo)) return STG_E_INVALIDPARAMETER;
655 ME_InsertOLEFromCursor(This->editor, reo, 0);
656 ME_CommitUndo(This->editor);
657 ME_UpdateRepaint(This->editor, FALSE);
658 return S_OK;
661 static HRESULT WINAPI IRichEditOle_fnSaveCompleted(IRichEditOle *me, LONG iob,
662 LPSTORAGE lpstg)
664 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
665 FIXME("stub %p\n",This);
666 return E_NOTIMPL;
669 static HRESULT WINAPI
670 IRichEditOle_fnSetDvaspect(IRichEditOle *me, LONG iob, DWORD dvaspect)
672 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
673 FIXME("stub %p\n",This);
674 return E_NOTIMPL;
677 static HRESULT WINAPI IRichEditOle_fnSetHostNames(IRichEditOle *me,
678 LPCSTR lpstrContainerApp, LPCSTR lpstrContainerObj)
680 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
681 FIXME("stub %p %s %s\n",This, lpstrContainerApp, lpstrContainerObj);
682 return E_NOTIMPL;
685 static HRESULT WINAPI
686 IRichEditOle_fnSetLinkAvailable(IRichEditOle *me, LONG iob, BOOL fAvailable)
688 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
689 FIXME("stub %p\n",This);
690 return E_NOTIMPL;
693 static const IRichEditOleVtbl revt = {
694 IRichEditOle_fnQueryInterface,
695 IRichEditOle_fnAddRef,
696 IRichEditOle_fnRelease,
697 IRichEditOle_fnGetClientSite,
698 IRichEditOle_fnGetObjectCount,
699 IRichEditOle_fnGetLinkCount,
700 IRichEditOle_fnGetObject,
701 IRichEditOle_fnInsertObject,
702 IRichEditOle_fnConvertObject,
703 IRichEditOle_fnActivateAs,
704 IRichEditOle_fnSetHostNames,
705 IRichEditOle_fnSetLinkAvailable,
706 IRichEditOle_fnSetDvaspect,
707 IRichEditOle_fnHandsOffStorage,
708 IRichEditOle_fnSaveCompleted,
709 IRichEditOle_fnInPlaceDeactivate,
710 IRichEditOle_fnContextSensitiveHelp,
711 IRichEditOle_fnGetClipboardData,
712 IRichEditOle_fnImportDataObject
715 /* ITextRange interface */
716 static inline ITextRangeImpl *impl_from_ITextRange(ITextRange *iface)
718 return CONTAINING_RECORD(iface, ITextRangeImpl, ITextRange_iface);
721 static HRESULT WINAPI ITextRange_fnQueryInterface(ITextRange *me, REFIID riid, void **ppvObj)
723 *ppvObj = NULL;
724 if (IsEqualGUID(riid, &IID_IUnknown)
725 || IsEqualGUID(riid, &IID_IDispatch)
726 || IsEqualGUID(riid, &IID_ITextRange))
728 *ppvObj = me;
729 ITextRange_AddRef(me);
730 return S_OK;
733 return E_NOINTERFACE;
736 static ULONG WINAPI ITextRange_fnAddRef(ITextRange *me)
738 ITextRangeImpl *This = impl_from_ITextRange(me);
739 return InterlockedIncrement(&This->ref);
742 static ULONG WINAPI ITextRange_fnRelease(ITextRange *me)
744 ITextRangeImpl *This = impl_from_ITextRange(me);
745 ULONG ref = InterlockedDecrement(&This->ref);
747 TRACE ("%p ref=%u\n", This, ref);
748 if (ref == 0)
750 if (This->reOle)
752 list_remove(&This->entry);
753 This->reOle = NULL;
755 heap_free(This);
757 return ref;
760 static HRESULT WINAPI ITextRange_fnGetTypeInfoCount(ITextRange *me, UINT *pctinfo)
762 ITextRangeImpl *This = impl_from_ITextRange(me);
763 if (!This->reOle)
764 return CO_E_RELEASED;
766 FIXME("not implemented %p\n", This);
767 return E_NOTIMPL;
770 static HRESULT WINAPI ITextRange_fnGetTypeInfo(ITextRange *me, UINT iTInfo, LCID lcid,
771 ITypeInfo **ppTInfo)
773 ITextRangeImpl *This = impl_from_ITextRange(me);
774 if (!This->reOle)
775 return CO_E_RELEASED;
777 FIXME("not implemented %p\n", This);
778 return E_NOTIMPL;
781 static HRESULT WINAPI ITextRange_fnGetIDsOfNames(ITextRange *me, REFIID riid, LPOLESTR *rgszNames,
782 UINT cNames, LCID lcid, DISPID *rgDispId)
784 ITextRangeImpl *This = impl_from_ITextRange(me);
785 if (!This->reOle)
786 return CO_E_RELEASED;
788 FIXME("not implemented %p\n", This);
789 return E_NOTIMPL;
792 static HRESULT WINAPI ITextRange_fnInvoke(ITextRange *me, DISPID dispIdMember, REFIID riid,
793 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
794 VARIANT *pVarResult, EXCEPINFO *pExcepInfo,
795 UINT *puArgErr)
797 ITextRangeImpl *This = impl_from_ITextRange(me);
798 if (!This->reOle)
799 return CO_E_RELEASED;
801 FIXME("not implemented %p\n", This);
802 return E_NOTIMPL;
805 static HRESULT WINAPI ITextRange_fnGetText(ITextRange *me, BSTR *pbstr)
807 ITextRangeImpl *This = impl_from_ITextRange(me);
808 if (!This->reOle)
809 return CO_E_RELEASED;
811 FIXME("not implemented %p\n", This);
812 return E_NOTIMPL;
815 static HRESULT WINAPI ITextRange_fnSetText(ITextRange *me, BSTR bstr)
817 ITextRangeImpl *This = impl_from_ITextRange(me);
818 if (!This->reOle)
819 return CO_E_RELEASED;
821 FIXME("not implemented %p\n", This);
822 return E_NOTIMPL;
825 static HRESULT range_GetChar(ME_TextEditor *editor, ME_Cursor *cursor, LONG *pch)
827 WCHAR wch[2];
829 ME_GetTextW(editor, wch, 1, cursor, 1, FALSE, cursor->pRun->next->type == diTextEnd);
830 *pch = wch[0];
832 return S_OK;
835 static HRESULT WINAPI ITextRange_fnGetChar(ITextRange *me, LONG *pch)
837 ITextRangeImpl *This = impl_from_ITextRange(me);
838 ME_Cursor cursor;
840 if (!This->reOle)
841 return CO_E_RELEASED;
842 TRACE("%p\n", pch);
843 if (!pch)
844 return E_INVALIDARG;
846 ME_CursorFromCharOfs(This->reOle->editor, This->start, &cursor);
847 return range_GetChar(This->reOle->editor, &cursor, pch);
850 static HRESULT WINAPI ITextRange_fnSetChar(ITextRange *me, LONG ch)
852 ITextRangeImpl *This = impl_from_ITextRange(me);
853 if (!This->reOle)
854 return CO_E_RELEASED;
856 FIXME("not implemented %p\n", This);
857 return E_NOTIMPL;
860 static HRESULT CreateITextRange(IRichEditOleImpl *reOle, LONG start, LONG end, ITextRange** ppRange);
862 static HRESULT WINAPI ITextRange_fnGetDuplicate(ITextRange *me, ITextRange **ppRange)
864 ITextRangeImpl *This = impl_from_ITextRange(me);
865 if (!This->reOle)
866 return CO_E_RELEASED;
868 TRACE("%p %p\n", This, ppRange);
869 if (!ppRange)
870 return E_INVALIDARG;
872 return CreateITextRange(This->reOle, This->start, This->end, ppRange);
875 static HRESULT WINAPI ITextRange_fnGetFormattedText(ITextRange *me, ITextRange **ppRange)
877 ITextRangeImpl *This = impl_from_ITextRange(me);
878 if (!This->reOle)
879 return CO_E_RELEASED;
881 FIXME("not implemented %p\n", This);
882 return E_NOTIMPL;
885 static HRESULT WINAPI ITextRange_fnSetFormattedText(ITextRange *me, ITextRange *pRange)
887 ITextRangeImpl *This = impl_from_ITextRange(me);
888 if (!This->reOle)
889 return CO_E_RELEASED;
891 FIXME("not implemented %p\n", This);
892 return E_NOTIMPL;
895 static HRESULT WINAPI ITextRange_fnGetStart(ITextRange *me, LONG *pcpFirst)
897 ITextRangeImpl *This = impl_from_ITextRange(me);
898 if (!This->reOle)
899 return CO_E_RELEASED;
901 if (!pcpFirst)
902 return E_INVALIDARG;
903 *pcpFirst = This->start;
904 TRACE("%d\n", *pcpFirst);
905 return S_OK;
908 static HRESULT WINAPI ITextRange_fnSetStart(ITextRange *me, LONG start)
910 ITextRangeImpl *This = impl_from_ITextRange(me);
911 int len;
913 TRACE("(%p)->(%d)\n", This, start);
915 if (!This->reOle)
916 return CO_E_RELEASED;
918 if (start == This->start)
919 return S_FALSE;
921 if (start < 0) {
922 This->start = 0;
923 return S_OK;
926 len = ME_GetTextLength(This->reOle->editor);
927 if (start > This->end)
928 This->end = len;
930 if (start > len)
931 This->start = len;
932 else
933 This->start = start;
935 return S_OK;
938 static HRESULT WINAPI ITextRange_fnGetEnd(ITextRange *me, LONG *pcpLim)
940 ITextRangeImpl *This = impl_from_ITextRange(me);
941 if (!This->reOle)
942 return CO_E_RELEASED;
944 if (!pcpLim)
945 return E_INVALIDARG;
946 *pcpLim = This->end;
947 TRACE("%d\n", *pcpLim);
948 return S_OK;
951 static HRESULT WINAPI ITextRange_fnSetEnd(ITextRange *me, LONG end)
953 ITextRangeImpl *This = impl_from_ITextRange(me);
954 int len;
956 TRACE("(%p)->(%d)\n", This, end);
958 if (!This->reOle)
959 return CO_E_RELEASED;
961 if (end == This->end)
962 return S_FALSE;
964 if (end < This->start) {
965 This->start = This->end = max(0, end);
966 return S_OK;
969 len = ME_GetTextLength(This->reOle->editor);
970 if (end > len)
971 This->end = len + 1;
972 else
973 This->end = end;
975 return S_OK;
978 static HRESULT WINAPI ITextRange_fnGetFont(ITextRange *me, ITextFont **font)
980 ITextRangeImpl *This = impl_from_ITextRange(me);
982 TRACE("(%p)->(%p)\n", This, font);
984 if (!This->reOle)
985 return CO_E_RELEASED;
987 if (!font)
988 return E_INVALIDARG;
990 return create_textfont(me, font);
993 static HRESULT WINAPI ITextRange_fnSetFont(ITextRange *me, ITextFont *pFont)
995 ITextRangeImpl *This = impl_from_ITextRange(me);
996 if (!This->reOle)
997 return CO_E_RELEASED;
999 FIXME("not implemented %p\n", This);
1000 return E_NOTIMPL;
1003 static HRESULT WINAPI ITextRange_fnGetPara(ITextRange *me, ITextPara **para)
1005 ITextRangeImpl *This = impl_from_ITextRange(me);
1007 TRACE("(%p)->(%p)\n", This, para);
1009 if (!This->reOle)
1010 return CO_E_RELEASED;
1012 if (!para)
1013 return E_INVALIDARG;
1015 return create_textpara(me, para);
1018 static HRESULT WINAPI ITextRange_fnSetPara(ITextRange *me, ITextPara *pPara)
1020 ITextRangeImpl *This = impl_from_ITextRange(me);
1021 if (!This->reOle)
1022 return CO_E_RELEASED;
1024 FIXME("not implemented %p\n", This);
1025 return E_NOTIMPL;
1028 static HRESULT WINAPI ITextRange_fnGetStoryLength(ITextRange *me, LONG *pcch)
1030 ITextRangeImpl *This = impl_from_ITextRange(me);
1031 if (!This->reOle)
1032 return CO_E_RELEASED;
1034 FIXME("not implemented %p\n", This);
1035 return E_NOTIMPL;
1038 static HRESULT WINAPI ITextRange_fnGetStoryType(ITextRange *me, LONG *pValue)
1040 ITextRangeImpl *This = impl_from_ITextRange(me);
1041 if (!This->reOle)
1042 return CO_E_RELEASED;
1044 FIXME("not implemented %p\n", This);
1045 return E_NOTIMPL;
1048 static HRESULT range_Collapse(LONG bStart, LONG *start, LONG *end)
1050 if (*end == *start)
1051 return S_FALSE;
1053 if (bStart == tomEnd || bStart == tomFalse)
1054 *start = *end;
1055 else
1056 *end = *start;
1057 return S_OK;
1060 static HRESULT WINAPI ITextRange_fnCollapse(ITextRange *me, LONG bStart)
1062 ITextRangeImpl *This = impl_from_ITextRange(me);
1063 if (!This->reOle)
1064 return CO_E_RELEASED;
1066 return range_Collapse(bStart, &This->start, &This->end);
1069 static HRESULT WINAPI ITextRange_fnExpand(ITextRange *me, LONG Unit, LONG *pDelta)
1071 ITextRangeImpl *This = impl_from_ITextRange(me);
1072 if (!This->reOle)
1073 return CO_E_RELEASED;
1075 FIXME("not implemented %p\n", This);
1076 return E_NOTIMPL;
1079 static HRESULT WINAPI ITextRange_fnGetIndex(ITextRange *me, LONG Unit, LONG *pIndex)
1081 ITextRangeImpl *This = impl_from_ITextRange(me);
1082 if (!This->reOle)
1083 return CO_E_RELEASED;
1085 FIXME("not implemented %p\n", This);
1086 return E_NOTIMPL;
1089 static HRESULT WINAPI ITextRange_fnSetIndex(ITextRange *me, LONG Unit, LONG Index,
1090 LONG Extend)
1092 ITextRangeImpl *This = impl_from_ITextRange(me);
1093 if (!This->reOle)
1094 return CO_E_RELEASED;
1096 FIXME("not implemented %p\n", This);
1097 return E_NOTIMPL;
1100 static HRESULT WINAPI ITextRange_fnSetRange(ITextRange *me, LONG cpActive, LONG cpOther)
1102 ITextRangeImpl *This = impl_from_ITextRange(me);
1103 if (!This->reOle)
1104 return CO_E_RELEASED;
1106 FIXME("not implemented %p\n", This);
1107 return E_NOTIMPL;
1110 static HRESULT WINAPI ITextRange_fnInRange(ITextRange *me, ITextRange *pRange, LONG *pb)
1112 ITextRangeImpl *This = impl_from_ITextRange(me);
1113 if (!This->reOle)
1114 return CO_E_RELEASED;
1116 FIXME("not implemented %p\n", This);
1117 return E_NOTIMPL;
1120 static HRESULT WINAPI ITextRange_fnInStory(ITextRange *me, ITextRange *pRange, LONG *pb)
1122 ITextRangeImpl *This = impl_from_ITextRange(me);
1123 if (!This->reOle)
1124 return CO_E_RELEASED;
1126 FIXME("not implemented %p\n", This);
1127 return E_NOTIMPL;
1130 static HRESULT WINAPI ITextRange_fnIsEqual(ITextRange *me, ITextRange *pRange, LONG *pb)
1132 ITextRangeImpl *This = impl_from_ITextRange(me);
1133 if (!This->reOle)
1134 return CO_E_RELEASED;
1136 FIXME("not implemented %p\n", This);
1137 return E_NOTIMPL;
1140 static HRESULT WINAPI ITextRange_fnSelect(ITextRange *me)
1142 ITextRangeImpl *This = impl_from_ITextRange(me);
1143 if (!This->reOle)
1144 return CO_E_RELEASED;
1146 FIXME("not implemented %p\n", This);
1147 return E_NOTIMPL;
1150 static HRESULT WINAPI ITextRange_fnStartOf(ITextRange *me, LONG Unit, LONG Extend,
1151 LONG *pDelta)
1153 ITextRangeImpl *This = impl_from_ITextRange(me);
1154 if (!This->reOle)
1155 return CO_E_RELEASED;
1157 FIXME("not implemented %p\n", This);
1158 return E_NOTIMPL;
1161 static HRESULT WINAPI ITextRange_fnEndOf(ITextRange *me, LONG Unit, LONG Extend,
1162 LONG *pDelta)
1164 ITextRangeImpl *This = impl_from_ITextRange(me);
1165 if (!This->reOle)
1166 return CO_E_RELEASED;
1168 FIXME("not implemented %p\n", This);
1169 return E_NOTIMPL;
1172 static HRESULT WINAPI ITextRange_fnMove(ITextRange *me, LONG Unit, LONG Count, LONG *pDelta)
1174 ITextRangeImpl *This = impl_from_ITextRange(me);
1175 if (!This->reOle)
1176 return CO_E_RELEASED;
1178 FIXME("not implemented %p\n", This);
1179 return E_NOTIMPL;
1182 static HRESULT WINAPI ITextRange_fnMoveStart(ITextRange *me, LONG Unit, LONG Count,
1183 LONG *pDelta)
1185 ITextRangeImpl *This = impl_from_ITextRange(me);
1186 if (!This->reOle)
1187 return CO_E_RELEASED;
1189 FIXME("not implemented %p\n", This);
1190 return E_NOTIMPL;
1193 static HRESULT WINAPI ITextRange_fnMoveEnd(ITextRange *me, LONG Unit, LONG Count,
1194 LONG *pDelta)
1196 ITextRangeImpl *This = impl_from_ITextRange(me);
1197 if (!This->reOle)
1198 return CO_E_RELEASED;
1200 FIXME("not implemented %p\n", This);
1201 return E_NOTIMPL;
1204 static HRESULT WINAPI ITextRange_fnMoveWhile(ITextRange *me, VARIANT *Cset, LONG Count,
1205 LONG *pDelta)
1207 ITextRangeImpl *This = impl_from_ITextRange(me);
1208 if (!This->reOle)
1209 return CO_E_RELEASED;
1211 FIXME("not implemented %p\n", This);
1212 return E_NOTIMPL;
1215 static HRESULT WINAPI ITextRange_fnMoveStartWhile(ITextRange *me, VARIANT *Cset, LONG Count,
1216 LONG *pDelta)
1218 ITextRangeImpl *This = impl_from_ITextRange(me);
1219 if (!This->reOle)
1220 return CO_E_RELEASED;
1222 FIXME("not implemented %p\n", This);
1223 return E_NOTIMPL;
1226 static HRESULT WINAPI ITextRange_fnMoveEndWhile(ITextRange *me, VARIANT *Cset, LONG Count,
1227 LONG *pDelta)
1229 ITextRangeImpl *This = impl_from_ITextRange(me);
1230 if (!This->reOle)
1231 return CO_E_RELEASED;
1233 FIXME("not implemented %p\n", This);
1234 return E_NOTIMPL;
1237 static HRESULT WINAPI ITextRange_fnMoveUntil(ITextRange *me, VARIANT *Cset, LONG Count,
1238 LONG *pDelta)
1240 ITextRangeImpl *This = impl_from_ITextRange(me);
1241 if (!This->reOle)
1242 return CO_E_RELEASED;
1244 FIXME("not implemented %p\n", This);
1245 return E_NOTIMPL;
1248 static HRESULT WINAPI ITextRange_fnMoveStartUntil(ITextRange *me, VARIANT *Cset, LONG Count,
1249 LONG *pDelta)
1251 ITextRangeImpl *This = impl_from_ITextRange(me);
1252 if (!This->reOle)
1253 return CO_E_RELEASED;
1255 FIXME("not implemented %p\n", This);
1256 return E_NOTIMPL;
1259 static HRESULT WINAPI ITextRange_fnMoveEndUntil(ITextRange *me, VARIANT *Cset, LONG Count,
1260 LONG *pDelta)
1262 ITextRangeImpl *This = impl_from_ITextRange(me);
1263 if (!This->reOle)
1264 return CO_E_RELEASED;
1266 FIXME("not implemented %p\n", This);
1267 return E_NOTIMPL;
1270 static HRESULT WINAPI ITextRange_fnFindText(ITextRange *me, BSTR bstr, LONG cch, LONG Flags,
1271 LONG *pLength)
1273 ITextRangeImpl *This = impl_from_ITextRange(me);
1274 if (!This->reOle)
1275 return CO_E_RELEASED;
1277 FIXME("not implemented %p\n", This);
1278 return E_NOTIMPL;
1281 static HRESULT WINAPI ITextRange_fnFindTextStart(ITextRange *me, BSTR bstr, LONG cch,
1282 LONG Flags, LONG *pLength)
1284 ITextRangeImpl *This = impl_from_ITextRange(me);
1285 if (!This->reOle)
1286 return CO_E_RELEASED;
1288 FIXME("not implemented %p\n", This);
1289 return E_NOTIMPL;
1292 static HRESULT WINAPI ITextRange_fnFindTextEnd(ITextRange *me, BSTR bstr, LONG cch,
1293 LONG Flags, LONG *pLength)
1295 ITextRangeImpl *This = impl_from_ITextRange(me);
1296 if (!This->reOle)
1297 return CO_E_RELEASED;
1299 FIXME("not implemented %p\n", This);
1300 return E_NOTIMPL;
1303 static HRESULT WINAPI ITextRange_fnDelete(ITextRange *me, LONG Unit, LONG Count,
1304 LONG *pDelta)
1306 ITextRangeImpl *This = impl_from_ITextRange(me);
1307 if (!This->reOle)
1308 return CO_E_RELEASED;
1310 FIXME("not implemented %p\n", This);
1311 return E_NOTIMPL;
1314 static HRESULT WINAPI ITextRange_fnCut(ITextRange *me, VARIANT *pVar)
1316 ITextRangeImpl *This = impl_from_ITextRange(me);
1317 if (!This->reOle)
1318 return CO_E_RELEASED;
1320 FIXME("not implemented %p\n", This);
1321 return E_NOTIMPL;
1324 static HRESULT WINAPI ITextRange_fnCopy(ITextRange *me, VARIANT *pVar)
1326 ITextRangeImpl *This = impl_from_ITextRange(me);
1327 if (!This->reOle)
1328 return CO_E_RELEASED;
1330 FIXME("not implemented %p\n", This);
1331 return E_NOTIMPL;
1334 static HRESULT WINAPI ITextRange_fnPaste(ITextRange *me, VARIANT *pVar, LONG Format)
1336 ITextRangeImpl *This = impl_from_ITextRange(me);
1337 if (!This->reOle)
1338 return CO_E_RELEASED;
1340 FIXME("not implemented %p\n", This);
1341 return E_NOTIMPL;
1344 static HRESULT WINAPI ITextRange_fnCanPaste(ITextRange *me, VARIANT *pVar, LONG Format,
1345 LONG *pb)
1347 ITextRangeImpl *This = impl_from_ITextRange(me);
1348 if (!This->reOle)
1349 return CO_E_RELEASED;
1351 FIXME("not implemented %p\n", This);
1352 return E_NOTIMPL;
1355 static HRESULT WINAPI ITextRange_fnCanEdit(ITextRange *me, LONG *pb)
1357 ITextRangeImpl *This = impl_from_ITextRange(me);
1358 if (!This->reOle)
1359 return CO_E_RELEASED;
1361 FIXME("not implemented %p\n", This);
1362 return E_NOTIMPL;
1365 static HRESULT WINAPI ITextRange_fnChangeCase(ITextRange *me, LONG Type)
1367 ITextRangeImpl *This = impl_from_ITextRange(me);
1368 if (!This->reOle)
1369 return CO_E_RELEASED;
1371 FIXME("not implemented %p\n", This);
1372 return E_NOTIMPL;
1375 static HRESULT WINAPI ITextRange_fnGetPoint(ITextRange *me, LONG Type, LONG *cx, LONG *cy)
1377 ITextRangeImpl *This = impl_from_ITextRange(me);
1378 if (!This->reOle)
1379 return CO_E_RELEASED;
1381 FIXME("not implemented %p\n", This);
1382 return E_NOTIMPL;
1385 static HRESULT WINAPI ITextRange_fnSetPoint(ITextRange *me, LONG x, LONG y, LONG Type,
1386 LONG Extend)
1388 ITextRangeImpl *This = impl_from_ITextRange(me);
1389 if (!This->reOle)
1390 return CO_E_RELEASED;
1392 FIXME("not implemented %p\n", This);
1393 return E_NOTIMPL;
1396 static HRESULT WINAPI ITextRange_fnScrollIntoView(ITextRange *me, LONG Value)
1398 ITextRangeImpl *This = impl_from_ITextRange(me);
1399 if (!This->reOle)
1400 return CO_E_RELEASED;
1402 FIXME("not implemented %p\n", This);
1403 return E_NOTIMPL;
1406 static HRESULT WINAPI ITextRange_fnGetEmbeddedObject(ITextRange *me, IUnknown **ppv)
1408 ITextRangeImpl *This = impl_from_ITextRange(me);
1409 if (!This->reOle)
1410 return CO_E_RELEASED;
1412 FIXME("not implemented %p\n", This);
1413 return E_NOTIMPL;
1416 static const ITextRangeVtbl trvt = {
1417 ITextRange_fnQueryInterface,
1418 ITextRange_fnAddRef,
1419 ITextRange_fnRelease,
1420 ITextRange_fnGetTypeInfoCount,
1421 ITextRange_fnGetTypeInfo,
1422 ITextRange_fnGetIDsOfNames,
1423 ITextRange_fnInvoke,
1424 ITextRange_fnGetText,
1425 ITextRange_fnSetText,
1426 ITextRange_fnGetChar,
1427 ITextRange_fnSetChar,
1428 ITextRange_fnGetDuplicate,
1429 ITextRange_fnGetFormattedText,
1430 ITextRange_fnSetFormattedText,
1431 ITextRange_fnGetStart,
1432 ITextRange_fnSetStart,
1433 ITextRange_fnGetEnd,
1434 ITextRange_fnSetEnd,
1435 ITextRange_fnGetFont,
1436 ITextRange_fnSetFont,
1437 ITextRange_fnGetPara,
1438 ITextRange_fnSetPara,
1439 ITextRange_fnGetStoryLength,
1440 ITextRange_fnGetStoryType,
1441 ITextRange_fnCollapse,
1442 ITextRange_fnExpand,
1443 ITextRange_fnGetIndex,
1444 ITextRange_fnSetIndex,
1445 ITextRange_fnSetRange,
1446 ITextRange_fnInRange,
1447 ITextRange_fnInStory,
1448 ITextRange_fnIsEqual,
1449 ITextRange_fnSelect,
1450 ITextRange_fnStartOf,
1451 ITextRange_fnEndOf,
1452 ITextRange_fnMove,
1453 ITextRange_fnMoveStart,
1454 ITextRange_fnMoveEnd,
1455 ITextRange_fnMoveWhile,
1456 ITextRange_fnMoveStartWhile,
1457 ITextRange_fnMoveEndWhile,
1458 ITextRange_fnMoveUntil,
1459 ITextRange_fnMoveStartUntil,
1460 ITextRange_fnMoveEndUntil,
1461 ITextRange_fnFindText,
1462 ITextRange_fnFindTextStart,
1463 ITextRange_fnFindTextEnd,
1464 ITextRange_fnDelete,
1465 ITextRange_fnCut,
1466 ITextRange_fnCopy,
1467 ITextRange_fnPaste,
1468 ITextRange_fnCanPaste,
1469 ITextRange_fnCanEdit,
1470 ITextRange_fnChangeCase,
1471 ITextRange_fnGetPoint,
1472 ITextRange_fnSetPoint,
1473 ITextRange_fnScrollIntoView,
1474 ITextRange_fnGetEmbeddedObject
1477 /* ITextFont */
1478 static HRESULT WINAPI TextFont_QueryInterface(ITextFont *iface, REFIID riid, void **ppv)
1480 ITextFontImpl *This = impl_from_ITextFont(iface);
1482 TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
1484 if (IsEqualIID(riid, &IID_ITextFont) ||
1485 IsEqualIID(riid, &IID_IDispatch) ||
1486 IsEqualIID(riid, &IID_IUnknown))
1488 *ppv = iface;
1489 ITextFont_AddRef(iface);
1490 return S_OK;
1493 *ppv = NULL;
1494 return E_NOINTERFACE;
1497 static ULONG WINAPI TextFont_AddRef(ITextFont *iface)
1499 ITextFontImpl *This = impl_from_ITextFont(iface);
1500 ULONG ref = InterlockedIncrement(&This->ref);
1501 TRACE("(%p)->(%u)\n", This, ref);
1502 return ref;
1505 static ULONG WINAPI TextFont_Release(ITextFont *iface)
1507 ITextFontImpl *This = impl_from_ITextFont(iface);
1508 ULONG ref = InterlockedDecrement(&This->ref);
1510 TRACE("(%p)->(%u)\n", This, ref);
1512 if (!ref)
1514 ITextRange_Release(This->range);
1515 heap_free(This);
1518 return ref;
1521 static HRESULT WINAPI TextFont_GetTypeInfoCount(ITextFont *iface, UINT *pctinfo)
1523 FIXME("stub\n");
1524 *pctinfo = 0;
1525 return E_NOTIMPL;
1528 static HRESULT WINAPI TextFont_GetTypeInfo(ITextFont *iface, UINT iTInfo, LCID lcid,
1529 ITypeInfo **ppTInfo)
1531 FIXME("stub\n");
1532 return E_NOTIMPL;
1535 static HRESULT WINAPI TextFont_GetIDsOfNames(ITextFont *iface, REFIID riid,
1536 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
1538 FIXME("stub\n");
1539 return E_NOTIMPL;
1542 static HRESULT WINAPI TextFont_Invoke(
1543 ITextFont *iface,
1544 DISPID dispIdMember,
1545 REFIID riid,
1546 LCID lcid,
1547 WORD wFlags,
1548 DISPPARAMS *pDispParams,
1549 VARIANT *pVarResult,
1550 EXCEPINFO *pExcepInfo,
1551 UINT *puArgErr)
1553 FIXME("stub\n");
1554 return E_NOTIMPL;
1557 static HRESULT WINAPI TextFont_GetDuplicate(ITextFont *iface, ITextFont **ret)
1559 ITextFontImpl *This = impl_from_ITextFont(iface);
1560 FIXME("(%p)->(%p): stub\n", This, ret);
1561 return E_NOTIMPL;
1564 static HRESULT WINAPI TextFont_SetDuplicate(ITextFont *iface, ITextFont *pFont)
1566 ITextFontImpl *This = impl_from_ITextFont(iface);
1567 FIXME("(%p)->(%p): stub\n", This, pFont);
1568 return E_NOTIMPL;
1571 static HRESULT WINAPI TextFont_CanChange(ITextFont *iface, LONG *ret)
1573 ITextFontImpl *This = impl_from_ITextFont(iface);
1574 FIXME("(%p)->(%p): stub\n", This, ret);
1575 return E_NOTIMPL;
1578 static HRESULT WINAPI TextFont_IsEqual(ITextFont *iface, ITextFont *font, LONG *ret)
1580 ITextFontImpl *This = impl_from_ITextFont(iface);
1581 FIXME("(%p)->(%p): stub\n", This, ret);
1582 return E_NOTIMPL;
1585 static HRESULT WINAPI TextFont_Reset(ITextFont *iface, LONG value)
1587 ITextFontImpl *This = impl_from_ITextFont(iface);
1588 FIXME("(%p): stub\n", This);
1589 return E_NOTIMPL;
1592 static HRESULT WINAPI TextFont_GetStyle(ITextFont *iface, LONG *value)
1594 ITextFontImpl *This = impl_from_ITextFont(iface);
1595 FIXME("(%p)->(%p): stub\n", This, value);
1596 return E_NOTIMPL;
1599 static HRESULT WINAPI TextFont_SetStyle(ITextFont *iface, LONG value)
1601 ITextFontImpl *This = impl_from_ITextFont(iface);
1602 FIXME("(%p)->(%d): stub\n", This, value);
1603 return E_NOTIMPL;
1606 static HRESULT WINAPI TextFont_GetAllCaps(ITextFont *iface, LONG *value)
1608 ITextFontImpl *This = impl_from_ITextFont(iface);
1609 FIXME("(%p)->(%p): stub\n", This, value);
1610 return E_NOTIMPL;
1613 static HRESULT WINAPI TextFont_SetAllCaps(ITextFont *iface, LONG value)
1615 ITextFontImpl *This = impl_from_ITextFont(iface);
1616 FIXME("(%p)->(%d): stub\n", This, value);
1617 return E_NOTIMPL;
1620 static HRESULT WINAPI TextFont_GetAnimation(ITextFont *iface, LONG *value)
1622 ITextFontImpl *This = impl_from_ITextFont(iface);
1623 FIXME("(%p)->(%p): stub\n", This, value);
1624 return E_NOTIMPL;
1627 static HRESULT WINAPI TextFont_SetAnimation(ITextFont *iface, LONG value)
1629 ITextFontImpl *This = impl_from_ITextFont(iface);
1630 FIXME("(%p)->(%d): stub\n", This, value);
1631 return E_NOTIMPL;
1634 static HRESULT WINAPI TextFont_GetBackColor(ITextFont *iface, LONG *value)
1636 ITextFontImpl *This = impl_from_ITextFont(iface);
1637 FIXME("(%p)->(%p): stub\n", This, value);
1638 return E_NOTIMPL;
1641 static HRESULT WINAPI TextFont_SetBackColor(ITextFont *iface, LONG value)
1643 ITextFontImpl *This = impl_from_ITextFont(iface);
1644 FIXME("(%p)->(%d): stub\n", This, value);
1645 return E_NOTIMPL;
1648 static HRESULT WINAPI TextFont_GetBold(ITextFont *iface, LONG *value)
1650 ITextFontImpl *This = impl_from_ITextFont(iface);
1651 FIXME("(%p)->(%p): stub\n", This, value);
1652 return E_NOTIMPL;
1655 static HRESULT WINAPI TextFont_SetBold(ITextFont *iface, LONG value)
1657 ITextFontImpl *This = impl_from_ITextFont(iface);
1658 FIXME("(%p)->(%d): stub\n", This, value);
1659 return E_NOTIMPL;
1662 static HRESULT WINAPI TextFont_GetEmboss(ITextFont *iface, LONG *value)
1664 ITextFontImpl *This = impl_from_ITextFont(iface);
1665 FIXME("(%p)->(%p): stub\n", This, value);
1666 return E_NOTIMPL;
1669 static HRESULT WINAPI TextFont_SetEmboss(ITextFont *iface, LONG value)
1671 ITextFontImpl *This = impl_from_ITextFont(iface);
1672 FIXME("(%p)->(%d): stub\n", This, value);
1673 return E_NOTIMPL;
1676 static HRESULT WINAPI TextFont_GetForeColor(ITextFont *iface, LONG *value)
1678 ITextFontImpl *This = impl_from_ITextFont(iface);
1679 FIXME("(%p)->(%p): stub\n", This, value);
1680 return E_NOTIMPL;
1683 static HRESULT WINAPI TextFont_SetForeColor(ITextFont *iface, LONG value)
1685 ITextFontImpl *This = impl_from_ITextFont(iface);
1686 FIXME("(%p)->(%d): stub\n", This, value);
1687 return E_NOTIMPL;
1690 static HRESULT WINAPI TextFont_GetHidden(ITextFont *iface, LONG *value)
1692 ITextFontImpl *This = impl_from_ITextFont(iface);
1693 FIXME("(%p)->(%p): stub\n", This, value);
1694 return E_NOTIMPL;
1697 static HRESULT WINAPI TextFont_SetHidden(ITextFont *iface, LONG value)
1699 ITextFontImpl *This = impl_from_ITextFont(iface);
1700 FIXME("(%p)->(%d): stub\n", This, value);
1701 return E_NOTIMPL;
1704 static HRESULT WINAPI TextFont_GetEngrave(ITextFont *iface, LONG *value)
1706 ITextFontImpl *This = impl_from_ITextFont(iface);
1707 FIXME("(%p)->(%p): stub\n", This, value);
1708 return E_NOTIMPL;
1711 static HRESULT WINAPI TextFont_SetEngrave(ITextFont *iface, LONG value)
1713 ITextFontImpl *This = impl_from_ITextFont(iface);
1714 FIXME("(%p)->(%d): stub\n", This, value);
1715 return E_NOTIMPL;
1718 static HRESULT WINAPI TextFont_GetItalic(ITextFont *iface, LONG *value)
1720 ITextFontImpl *This = impl_from_ITextFont(iface);
1721 FIXME("(%p)->(%p): stub\n", This, value);
1722 return E_NOTIMPL;
1725 static HRESULT WINAPI TextFont_SetItalic(ITextFont *iface, LONG value)
1727 ITextFontImpl *This = impl_from_ITextFont(iface);
1728 FIXME("(%p)->(%d): stub\n", This, value);
1729 return E_NOTIMPL;
1732 static HRESULT WINAPI TextFont_GetKerning(ITextFont *iface, FLOAT *value)
1734 ITextFontImpl *This = impl_from_ITextFont(iface);
1735 FIXME("(%p)->(%p): stub\n", This, value);
1736 return E_NOTIMPL;
1739 static HRESULT WINAPI TextFont_SetKerning(ITextFont *iface, FLOAT value)
1741 ITextFontImpl *This = impl_from_ITextFont(iface);
1742 FIXME("(%p)->(%.2f): stub\n", This, value);
1743 return E_NOTIMPL;
1746 static HRESULT WINAPI TextFont_GetLanguageID(ITextFont *iface, LONG *value)
1748 ITextFontImpl *This = impl_from_ITextFont(iface);
1749 FIXME("(%p)->(%p): stub\n", This, value);
1750 return E_NOTIMPL;
1753 static HRESULT WINAPI TextFont_SetLanguageID(ITextFont *iface, LONG value)
1755 ITextFontImpl *This = impl_from_ITextFont(iface);
1756 FIXME("(%p)->(%d): stub\n", This, value);
1757 return E_NOTIMPL;
1760 static HRESULT WINAPI TextFont_GetName(ITextFont *iface, BSTR *value)
1762 ITextFontImpl *This = impl_from_ITextFont(iface);
1763 FIXME("(%p)->(%p): stub\n", This, value);
1764 return E_NOTIMPL;
1767 static HRESULT WINAPI TextFont_SetName(ITextFont *iface, BSTR value)
1769 ITextFontImpl *This = impl_from_ITextFont(iface);
1770 FIXME("(%p)->(%s): stub\n", This, debugstr_w(value));
1771 return E_NOTIMPL;
1774 static HRESULT WINAPI TextFont_GetOutline(ITextFont *iface, LONG *value)
1776 ITextFontImpl *This = impl_from_ITextFont(iface);
1777 FIXME("(%p)->(%p): stub\n", This, value);
1778 return E_NOTIMPL;
1781 static HRESULT WINAPI TextFont_SetOutline(ITextFont *iface, LONG value)
1783 ITextFontImpl *This = impl_from_ITextFont(iface);
1784 FIXME("(%p)->(%d): stub\n", This, value);
1785 return E_NOTIMPL;
1788 static HRESULT WINAPI TextFont_GetPosition(ITextFont *iface, FLOAT *value)
1790 ITextFontImpl *This = impl_from_ITextFont(iface);
1791 FIXME("(%p)->(%p): stub\n", This, value);
1792 return E_NOTIMPL;
1795 static HRESULT WINAPI TextFont_SetPosition(ITextFont *iface, FLOAT value)
1797 ITextFontImpl *This = impl_from_ITextFont(iface);
1798 FIXME("(%p)->(%.2f): stub\n", This, value);
1799 return E_NOTIMPL;
1802 static HRESULT WINAPI TextFont_GetProtected(ITextFont *iface, LONG *value)
1804 ITextFontImpl *This = impl_from_ITextFont(iface);
1805 FIXME("(%p)->(%p): stub\n", This, value);
1806 return E_NOTIMPL;
1809 static HRESULT WINAPI TextFont_SetProtected(ITextFont *iface, LONG value)
1811 ITextFontImpl *This = impl_from_ITextFont(iface);
1812 FIXME("(%p)->(%d): stub\n", This, value);
1813 return E_NOTIMPL;
1816 static HRESULT WINAPI TextFont_GetShadow(ITextFont *iface, LONG *value)
1818 ITextFontImpl *This = impl_from_ITextFont(iface);
1819 FIXME("(%p)->(%p): stub\n", This, value);
1820 return E_NOTIMPL;
1823 static HRESULT WINAPI TextFont_SetShadow(ITextFont *iface, LONG value)
1825 ITextFontImpl *This = impl_from_ITextFont(iface);
1826 FIXME("(%p)->(%d): stub\n", This, value);
1827 return E_NOTIMPL;
1830 static HRESULT WINAPI TextFont_GetSize(ITextFont *iface, FLOAT *value)
1832 ITextFontImpl *This = impl_from_ITextFont(iface);
1833 FIXME("(%p)->(%p): stub\n", This, value);
1834 return E_NOTIMPL;
1837 static HRESULT WINAPI TextFont_SetSize(ITextFont *iface, FLOAT value)
1839 ITextFontImpl *This = impl_from_ITextFont(iface);
1840 FIXME("(%p)->(%.2f): stub\n", This, value);
1841 return E_NOTIMPL;
1844 static HRESULT WINAPI TextFont_GetSmallCaps(ITextFont *iface, LONG *value)
1846 ITextFontImpl *This = impl_from_ITextFont(iface);
1847 FIXME("(%p)->(%p): stub\n", This, value);
1848 return E_NOTIMPL;
1851 static HRESULT WINAPI TextFont_SetSmallCaps(ITextFont *iface, LONG value)
1853 ITextFontImpl *This = impl_from_ITextFont(iface);
1854 FIXME("(%p)->(%d): stub\n", This, value);
1855 return E_NOTIMPL;
1858 static HRESULT WINAPI TextFont_GetSpacing(ITextFont *iface, FLOAT *value)
1860 ITextFontImpl *This = impl_from_ITextFont(iface);
1861 FIXME("(%p)->(%p): stub\n", This, value);
1862 return E_NOTIMPL;
1865 static HRESULT WINAPI TextFont_SetSpacing(ITextFont *iface, FLOAT value)
1867 ITextFontImpl *This = impl_from_ITextFont(iface);
1868 FIXME("(%p)->(%.2f): stub\n", This, value);
1869 return E_NOTIMPL;
1872 static HRESULT WINAPI TextFont_GetStrikeThrough(ITextFont *iface, LONG *value)
1874 ITextFontImpl *This = impl_from_ITextFont(iface);
1875 FIXME("(%p)->(%p): stub\n", This, value);
1876 return E_NOTIMPL;
1879 static HRESULT WINAPI TextFont_SetStrikeThrough(ITextFont *iface, LONG value)
1881 ITextFontImpl *This = impl_from_ITextFont(iface);
1882 FIXME("(%p)->(%d): stub\n", This, value);
1883 return E_NOTIMPL;
1886 static HRESULT WINAPI TextFont_GetSubscript(ITextFont *iface, LONG *value)
1888 ITextFontImpl *This = impl_from_ITextFont(iface);
1889 FIXME("(%p)->(%p): stub\n", This, value);
1890 return E_NOTIMPL;
1893 static HRESULT WINAPI TextFont_SetSubscript(ITextFont *iface, LONG value)
1895 ITextFontImpl *This = impl_from_ITextFont(iface);
1896 FIXME("(%p)->(%d): stub\n", This, value);
1897 return E_NOTIMPL;
1900 static HRESULT WINAPI TextFont_GetSuperscript(ITextFont *iface, LONG *value)
1902 ITextFontImpl *This = impl_from_ITextFont(iface);
1903 FIXME("(%p)->(%p): stub\n", This, value);
1904 return E_NOTIMPL;
1907 static HRESULT WINAPI TextFont_SetSuperscript(ITextFont *iface, LONG value)
1909 ITextFontImpl *This = impl_from_ITextFont(iface);
1910 FIXME("(%p)->(%d): stub\n", This, value);
1911 return E_NOTIMPL;
1914 static HRESULT WINAPI TextFont_GetUnderline(ITextFont *iface, LONG *value)
1916 ITextFontImpl *This = impl_from_ITextFont(iface);
1917 FIXME("(%p)->(%p): stub\n", This, value);
1918 return E_NOTIMPL;
1921 static HRESULT WINAPI TextFont_SetUnderline(ITextFont *iface, LONG value)
1923 ITextFontImpl *This = impl_from_ITextFont(iface);
1924 FIXME("(%p)->(%d): stub\n", This, value);
1925 return E_NOTIMPL;
1928 static HRESULT WINAPI TextFont_GetWeight(ITextFont *iface, LONG *value)
1930 ITextFontImpl *This = impl_from_ITextFont(iface);
1931 FIXME("(%p)->(%p): stub\n", This, value);
1932 return E_NOTIMPL;
1935 static HRESULT WINAPI TextFont_SetWeight(ITextFont *iface, LONG value)
1937 ITextFontImpl *This = impl_from_ITextFont(iface);
1938 FIXME("(%p)->(%d): stub\n", This, value);
1939 return E_NOTIMPL;
1942 static ITextFontVtbl textfontvtbl = {
1943 TextFont_QueryInterface,
1944 TextFont_AddRef,
1945 TextFont_Release,
1946 TextFont_GetTypeInfoCount,
1947 TextFont_GetTypeInfo,
1948 TextFont_GetIDsOfNames,
1949 TextFont_Invoke,
1950 TextFont_GetDuplicate,
1951 TextFont_SetDuplicate,
1952 TextFont_CanChange,
1953 TextFont_IsEqual,
1954 TextFont_Reset,
1955 TextFont_GetStyle,
1956 TextFont_SetStyle,
1957 TextFont_GetAllCaps,
1958 TextFont_SetAllCaps,
1959 TextFont_GetAnimation,
1960 TextFont_SetAnimation,
1961 TextFont_GetBackColor,
1962 TextFont_SetBackColor,
1963 TextFont_GetBold,
1964 TextFont_SetBold,
1965 TextFont_GetEmboss,
1966 TextFont_SetEmboss,
1967 TextFont_GetForeColor,
1968 TextFont_SetForeColor,
1969 TextFont_GetHidden,
1970 TextFont_SetHidden,
1971 TextFont_GetEngrave,
1972 TextFont_SetEngrave,
1973 TextFont_GetItalic,
1974 TextFont_SetItalic,
1975 TextFont_GetKerning,
1976 TextFont_SetKerning,
1977 TextFont_GetLanguageID,
1978 TextFont_SetLanguageID,
1979 TextFont_GetName,
1980 TextFont_SetName,
1981 TextFont_GetOutline,
1982 TextFont_SetOutline,
1983 TextFont_GetPosition,
1984 TextFont_SetPosition,
1985 TextFont_GetProtected,
1986 TextFont_SetProtected,
1987 TextFont_GetShadow,
1988 TextFont_SetShadow,
1989 TextFont_GetSize,
1990 TextFont_SetSize,
1991 TextFont_GetSmallCaps,
1992 TextFont_SetSmallCaps,
1993 TextFont_GetSpacing,
1994 TextFont_SetSpacing,
1995 TextFont_GetStrikeThrough,
1996 TextFont_SetStrikeThrough,
1997 TextFont_GetSubscript,
1998 TextFont_SetSubscript,
1999 TextFont_GetSuperscript,
2000 TextFont_SetSuperscript,
2001 TextFont_GetUnderline,
2002 TextFont_SetUnderline,
2003 TextFont_GetWeight,
2004 TextFont_SetWeight
2007 static HRESULT create_textfont(ITextRange *range, ITextFont **ret)
2009 ITextFontImpl *font;
2011 *ret = NULL;
2012 font = heap_alloc(sizeof(*font));
2013 if (!font)
2014 return E_OUTOFMEMORY;
2016 font->ITextFont_iface.lpVtbl = &textfontvtbl;
2017 font->ref = 1;
2018 font->range = range;
2019 ITextRange_AddRef(range);
2021 *ret = &font->ITextFont_iface;
2022 return S_OK;
2025 /* ITextPara */
2026 static HRESULT WINAPI TextPara_QueryInterface(ITextPara *iface, REFIID riid, void **ppv)
2028 ITextParaImpl *This = impl_from_ITextPara(iface);
2030 TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
2032 if (IsEqualIID(riid, &IID_ITextPara) ||
2033 IsEqualIID(riid, &IID_IDispatch) ||
2034 IsEqualIID(riid, &IID_IUnknown))
2036 *ppv = iface;
2037 ITextPara_AddRef(iface);
2038 return S_OK;
2041 *ppv = NULL;
2042 return E_NOINTERFACE;
2045 static ULONG WINAPI TextPara_AddRef(ITextPara *iface)
2047 ITextParaImpl *This = impl_from_ITextPara(iface);
2048 ULONG ref = InterlockedIncrement(&This->ref);
2049 TRACE("(%p)->(%u)\n", This, ref);
2050 return ref;
2053 static ULONG WINAPI TextPara_Release(ITextPara *iface)
2055 ITextParaImpl *This = impl_from_ITextPara(iface);
2056 ULONG ref = InterlockedDecrement(&This->ref);
2058 TRACE("(%p)->(%u)\n", This, ref);
2060 if (!ref)
2062 ITextRange_Release(This->range);
2063 heap_free(This);
2066 return ref;
2069 static HRESULT WINAPI TextPara_GetTypeInfoCount(ITextPara *iface, UINT *pctinfo)
2071 FIXME("stub\n");
2072 *pctinfo = 0;
2073 return E_NOTIMPL;
2076 static HRESULT WINAPI TextPara_GetTypeInfo(ITextPara *iface, UINT iTInfo, LCID lcid,
2077 ITypeInfo **ppTInfo)
2079 FIXME("stub\n");
2080 return E_NOTIMPL;
2083 static HRESULT WINAPI TextPara_GetIDsOfNames(ITextPara *iface, REFIID riid,
2084 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
2086 FIXME("stub\n");
2087 return E_NOTIMPL;
2090 static HRESULT WINAPI TextPara_Invoke(
2091 ITextPara *iface,
2092 DISPID dispIdMember,
2093 REFIID riid,
2094 LCID lcid,
2095 WORD wFlags,
2096 DISPPARAMS *pDispParams,
2097 VARIANT *pVarResult,
2098 EXCEPINFO *pExcepInfo,
2099 UINT *puArgErr)
2101 FIXME("stub\n");
2102 return E_NOTIMPL;
2105 static HRESULT WINAPI TextPara_GetDuplicate(ITextPara *iface, ITextPara **ret)
2107 ITextParaImpl *This = impl_from_ITextPara(iface);
2108 FIXME("(%p)->(%p)\n", This, ret);
2109 return E_NOTIMPL;
2112 static HRESULT WINAPI TextPara_SetDuplicate(ITextPara *iface, ITextPara *para)
2114 ITextParaImpl *This = impl_from_ITextPara(iface);
2115 FIXME("(%p)->(%p)\n", This, para);
2116 return E_NOTIMPL;
2119 static HRESULT WINAPI TextPara_CanChange(ITextPara *iface, LONG *ret)
2121 ITextParaImpl *This = impl_from_ITextPara(iface);
2122 FIXME("(%p)->(%p)\n", This, ret);
2123 return E_NOTIMPL;
2126 static HRESULT WINAPI TextPara_IsEqual(ITextPara *iface, ITextPara *para, LONG *ret)
2128 ITextParaImpl *This = impl_from_ITextPara(iface);
2129 FIXME("(%p)->(%p %p)\n", This, para, ret);
2130 return E_NOTIMPL;
2133 static HRESULT WINAPI TextPara_Reset(ITextPara *iface, LONG value)
2135 ITextParaImpl *This = impl_from_ITextPara(iface);
2136 FIXME("(%p)->(%d)\n", This, value);
2137 return E_NOTIMPL;
2140 static HRESULT WINAPI TextPara_GetStyle(ITextPara *iface, LONG *value)
2142 ITextParaImpl *This = impl_from_ITextPara(iface);
2143 FIXME("(%p)->(%p)\n", This, value);
2144 return E_NOTIMPL;
2147 static HRESULT WINAPI TextPara_SetStyle(ITextPara *iface, LONG value)
2149 ITextParaImpl *This = impl_from_ITextPara(iface);
2150 FIXME("(%p)->(%d)\n", This, value);
2151 return E_NOTIMPL;
2154 static HRESULT WINAPI TextPara_GetAlignment(ITextPara *iface, LONG *value)
2156 ITextParaImpl *This = impl_from_ITextPara(iface);
2157 FIXME("(%p)->(%p)\n", This, value);
2158 return E_NOTIMPL;
2161 static HRESULT WINAPI TextPara_SetAlignment(ITextPara *iface, LONG value)
2163 ITextParaImpl *This = impl_from_ITextPara(iface);
2164 FIXME("(%p)->(%d)\n", This, value);
2165 return E_NOTIMPL;
2168 static HRESULT WINAPI TextPara_GetHyphenation(ITextPara *iface, LONG *value)
2170 ITextParaImpl *This = impl_from_ITextPara(iface);
2171 FIXME("(%p)->(%p)\n", This, value);
2172 return E_NOTIMPL;
2175 static HRESULT WINAPI TextPara_SetHyphenation(ITextPara *iface, LONG value)
2177 ITextParaImpl *This = impl_from_ITextPara(iface);
2178 FIXME("(%p)->(%d)\n", This, value);
2179 return E_NOTIMPL;
2182 static HRESULT WINAPI TextPara_GetFirstLineIndent(ITextPara *iface, FLOAT *value)
2184 ITextParaImpl *This = impl_from_ITextPara(iface);
2185 FIXME("(%p)->(%p)\n", This, value);
2186 return E_NOTIMPL;
2189 static HRESULT WINAPI TextPara_GetKeepTogether(ITextPara *iface, LONG *value)
2191 ITextParaImpl *This = impl_from_ITextPara(iface);
2192 FIXME("(%p)->(%p)\n", This, value);
2193 return E_NOTIMPL;
2196 static HRESULT WINAPI TextPara_SetKeepTogether(ITextPara *iface, LONG value)
2198 ITextParaImpl *This = impl_from_ITextPara(iface);
2199 FIXME("(%p)->(%d)\n", This, value);
2200 return E_NOTIMPL;
2203 static HRESULT WINAPI TextPara_GetKeepWithNext(ITextPara *iface, LONG *value)
2205 ITextParaImpl *This = impl_from_ITextPara(iface);
2206 FIXME("(%p)->(%p)\n", This, value);
2207 return E_NOTIMPL;
2210 static HRESULT WINAPI TextPara_SetKeepWithNext(ITextPara *iface, LONG value)
2212 ITextParaImpl *This = impl_from_ITextPara(iface);
2213 FIXME("(%p)->(%d)\n", This, value);
2214 return E_NOTIMPL;
2217 static HRESULT WINAPI TextPara_GetLeftIndent(ITextPara *iface, FLOAT *value)
2219 ITextParaImpl *This = impl_from_ITextPara(iface);
2220 FIXME("(%p)->(%p)\n", This, value);
2221 return E_NOTIMPL;
2224 static HRESULT WINAPI TextPara_GetLineSpacing(ITextPara *iface, FLOAT *value)
2226 ITextParaImpl *This = impl_from_ITextPara(iface);
2227 FIXME("(%p)->(%p)\n", This, value);
2228 return E_NOTIMPL;
2231 static HRESULT WINAPI TextPara_GetLineSpacingRule(ITextPara *iface, LONG *value)
2233 ITextParaImpl *This = impl_from_ITextPara(iface);
2234 FIXME("(%p)->(%p)\n", This, value);
2235 return E_NOTIMPL;
2238 static HRESULT WINAPI TextPara_GetListAlignment(ITextPara *iface, LONG *value)
2240 ITextParaImpl *This = impl_from_ITextPara(iface);
2241 FIXME("(%p)->(%p)\n", This, value);
2242 return E_NOTIMPL;
2245 static HRESULT WINAPI TextPara_SetListAlignment(ITextPara *iface, LONG value)
2247 ITextParaImpl *This = impl_from_ITextPara(iface);
2248 FIXME("(%p)->(%d)\n", This, value);
2249 return E_NOTIMPL;
2252 static HRESULT WINAPI TextPara_GetListLevelIndex(ITextPara *iface, LONG *value)
2254 ITextParaImpl *This = impl_from_ITextPara(iface);
2255 FIXME("(%p)->(%p)\n", This, value);
2256 return E_NOTIMPL;
2259 static HRESULT WINAPI TextPara_SetListLevelIndex(ITextPara *iface, LONG value)
2261 ITextParaImpl *This = impl_from_ITextPara(iface);
2262 FIXME("(%p)->(%d)\n", This, value);
2263 return E_NOTIMPL;
2266 static HRESULT WINAPI TextPara_GetListStart(ITextPara *iface, LONG *value)
2268 ITextParaImpl *This = impl_from_ITextPara(iface);
2269 FIXME("(%p)->(%p)\n", This, value);
2270 return E_NOTIMPL;
2273 static HRESULT WINAPI TextPara_SetListStart(ITextPara *iface, LONG value)
2275 ITextParaImpl *This = impl_from_ITextPara(iface);
2276 FIXME("(%p)->(%d)\n", This, value);
2277 return E_NOTIMPL;
2280 static HRESULT WINAPI TextPara_GetListTab(ITextPara *iface, FLOAT *value)
2282 ITextParaImpl *This = impl_from_ITextPara(iface);
2283 FIXME("(%p)->(%p)\n", This, value);
2284 return E_NOTIMPL;
2287 static HRESULT WINAPI TextPara_SetListTab(ITextPara *iface, FLOAT value)
2289 ITextParaImpl *This = impl_from_ITextPara(iface);
2290 FIXME("(%p)->(%.2f)\n", This, value);
2291 return E_NOTIMPL;
2294 static HRESULT WINAPI TextPara_GetListType(ITextPara *iface, LONG *value)
2296 ITextParaImpl *This = impl_from_ITextPara(iface);
2297 FIXME("(%p)->(%p)\n", This, value);
2298 return E_NOTIMPL;
2301 static HRESULT WINAPI TextPara_SetListType(ITextPara *iface, LONG value)
2303 ITextParaImpl *This = impl_from_ITextPara(iface);
2304 FIXME("(%p)->(%d)\n", This, value);
2305 return E_NOTIMPL;
2308 static HRESULT WINAPI TextPara_GetNoLineNumber(ITextPara *iface, LONG *value)
2310 ITextParaImpl *This = impl_from_ITextPara(iface);
2311 FIXME("(%p)->(%p)\n", This, value);
2312 return E_NOTIMPL;
2315 static HRESULT WINAPI TextPara_SetNoLineNumber(ITextPara *iface, LONG value)
2317 ITextParaImpl *This = impl_from_ITextPara(iface);
2318 FIXME("(%p)->(%d)\n", This, value);
2319 return E_NOTIMPL;
2322 static HRESULT WINAPI TextPara_GetPageBreakBefore(ITextPara *iface, LONG *value)
2324 ITextParaImpl *This = impl_from_ITextPara(iface);
2325 FIXME("(%p)->(%p)\n", This, value);
2326 return E_NOTIMPL;
2329 static HRESULT WINAPI TextPara_SetPageBreakBefore(ITextPara *iface, LONG value)
2331 ITextParaImpl *This = impl_from_ITextPara(iface);
2332 FIXME("(%p)->(%d)\n", This, value);
2333 return E_NOTIMPL;
2336 static HRESULT WINAPI TextPara_GetRightIndent(ITextPara *iface, FLOAT *value)
2338 ITextParaImpl *This = impl_from_ITextPara(iface);
2339 FIXME("(%p)->(%p)\n", This, value);
2340 return E_NOTIMPL;
2343 static HRESULT WINAPI TextPara_SetRightIndent(ITextPara *iface, FLOAT value)
2345 ITextParaImpl *This = impl_from_ITextPara(iface);
2346 FIXME("(%p)->(%.2f)\n", This, value);
2347 return E_NOTIMPL;
2350 static HRESULT WINAPI TextPara_SetIndents(ITextPara *iface, FLOAT StartIndent, FLOAT LeftIndent, FLOAT RightIndent)
2352 ITextParaImpl *This = impl_from_ITextPara(iface);
2353 FIXME("(%p)->(%.2f %.2f %.2f)\n", This, StartIndent, LeftIndent, RightIndent);
2354 return E_NOTIMPL;
2357 static HRESULT WINAPI TextPara_SetLineSpacing(ITextPara *iface, LONG LineSpacingRule, FLOAT LineSpacing)
2359 ITextParaImpl *This = impl_from_ITextPara(iface);
2360 FIXME("(%p)->(%d %.2f)\n", This, LineSpacingRule, LineSpacing);
2361 return E_NOTIMPL;
2364 static HRESULT WINAPI TextPara_GetSpaceAfter(ITextPara *iface, FLOAT *value)
2366 ITextParaImpl *This = impl_from_ITextPara(iface);
2367 FIXME("(%p)->(%p)\n", This, value);
2368 return E_NOTIMPL;
2371 static HRESULT WINAPI TextPara_SetSpaceAfter(ITextPara *iface, FLOAT value)
2373 ITextParaImpl *This = impl_from_ITextPara(iface);
2374 FIXME("(%p)->(%.2f)\n", This, value);
2375 return E_NOTIMPL;
2378 static HRESULT WINAPI TextPara_GetSpaceBefore(ITextPara *iface, FLOAT *value)
2380 ITextParaImpl *This = impl_from_ITextPara(iface);
2381 FIXME("(%p)->(%p)\n", This, value);
2382 return E_NOTIMPL;
2385 static HRESULT WINAPI TextPara_SetSpaceBefore(ITextPara *iface, FLOAT value)
2387 ITextParaImpl *This = impl_from_ITextPara(iface);
2388 FIXME("(%p)->(%.2f)\n", This, value);
2389 return E_NOTIMPL;
2392 static HRESULT WINAPI TextPara_GetWidowControl(ITextPara *iface, LONG *value)
2394 ITextParaImpl *This = impl_from_ITextPara(iface);
2395 FIXME("(%p)->(%p)\n", This, value);
2396 return E_NOTIMPL;
2399 static HRESULT WINAPI TextPara_SetWidowControl(ITextPara *iface, LONG value)
2401 ITextParaImpl *This = impl_from_ITextPara(iface);
2402 FIXME("(%p)->(%d)\n", This, value);
2403 return E_NOTIMPL;
2406 static HRESULT WINAPI TextPara_GetTabCount(ITextPara *iface, LONG *value)
2408 ITextParaImpl *This = impl_from_ITextPara(iface);
2409 FIXME("(%p)->(%p)\n", This, value);
2410 return E_NOTIMPL;
2413 static HRESULT WINAPI TextPara_AddTab(ITextPara *iface, FLOAT tbPos, LONG tbAlign, LONG tbLeader)
2415 ITextParaImpl *This = impl_from_ITextPara(iface);
2416 FIXME("(%p)->(%.2f %d %d)\n", This, tbPos, tbAlign, tbLeader);
2417 return E_NOTIMPL;
2420 static HRESULT WINAPI TextPara_ClearAllTabs(ITextPara *iface)
2422 ITextParaImpl *This = impl_from_ITextPara(iface);
2423 FIXME("(%p)\n", This);
2424 return E_NOTIMPL;
2427 static HRESULT WINAPI TextPara_DeleteTab(ITextPara *iface, FLOAT pos)
2429 ITextParaImpl *This = impl_from_ITextPara(iface);
2430 FIXME("(%p)->(%.2f)\n", This, pos);
2431 return E_NOTIMPL;
2434 static HRESULT WINAPI TextPara_GetTab(ITextPara *iface, LONG iTab, FLOAT *ptbPos, LONG *ptbAlign, LONG *ptbLeader)
2436 ITextParaImpl *This = impl_from_ITextPara(iface);
2437 FIXME("(%p)->(%d %p %p %p)\n", This, iTab, ptbPos, ptbAlign, ptbLeader);
2438 return E_NOTIMPL;
2441 static ITextParaVtbl textparavtbl = {
2442 TextPara_QueryInterface,
2443 TextPara_AddRef,
2444 TextPara_Release,
2445 TextPara_GetTypeInfoCount,
2446 TextPara_GetTypeInfo,
2447 TextPara_GetIDsOfNames,
2448 TextPara_Invoke,
2449 TextPara_GetDuplicate,
2450 TextPara_SetDuplicate,
2451 TextPara_CanChange,
2452 TextPara_IsEqual,
2453 TextPara_Reset,
2454 TextPara_GetStyle,
2455 TextPara_SetStyle,
2456 TextPara_GetAlignment,
2457 TextPara_SetAlignment,
2458 TextPara_GetHyphenation,
2459 TextPara_SetHyphenation,
2460 TextPara_GetFirstLineIndent,
2461 TextPara_GetKeepTogether,
2462 TextPara_SetKeepTogether,
2463 TextPara_GetKeepWithNext,
2464 TextPara_SetKeepWithNext,
2465 TextPara_GetLeftIndent,
2466 TextPara_GetLineSpacing,
2467 TextPara_GetLineSpacingRule,
2468 TextPara_GetListAlignment,
2469 TextPara_SetListAlignment,
2470 TextPara_GetListLevelIndex,
2471 TextPara_SetListLevelIndex,
2472 TextPara_GetListStart,
2473 TextPara_SetListStart,
2474 TextPara_GetListTab,
2475 TextPara_SetListTab,
2476 TextPara_GetListType,
2477 TextPara_SetListType,
2478 TextPara_GetNoLineNumber,
2479 TextPara_SetNoLineNumber,
2480 TextPara_GetPageBreakBefore,
2481 TextPara_SetPageBreakBefore,
2482 TextPara_GetRightIndent,
2483 TextPara_SetRightIndent,
2484 TextPara_SetIndents,
2485 TextPara_SetLineSpacing,
2486 TextPara_GetSpaceAfter,
2487 TextPara_SetSpaceAfter,
2488 TextPara_GetSpaceBefore,
2489 TextPara_SetSpaceBefore,
2490 TextPara_GetWidowControl,
2491 TextPara_SetWidowControl,
2492 TextPara_GetTabCount,
2493 TextPara_AddTab,
2494 TextPara_ClearAllTabs,
2495 TextPara_DeleteTab,
2496 TextPara_GetTab
2499 static HRESULT create_textpara(ITextRange *range, ITextPara **ret)
2501 ITextParaImpl *para;
2503 *ret = NULL;
2504 para = heap_alloc(sizeof(*para));
2505 if (!para)
2506 return E_OUTOFMEMORY;
2508 para->ITextPara_iface.lpVtbl = &textparavtbl;
2509 para->ref = 1;
2510 para->range = range;
2511 ITextRange_AddRef(range);
2513 *ret = &para->ITextPara_iface;
2514 return S_OK;
2517 /* ITextDocument */
2518 static HRESULT WINAPI
2519 ITextDocument_fnQueryInterface(ITextDocument* me, REFIID riid,
2520 void** ppvObject)
2522 IRichEditOleImpl *This = impl_from_ITextDocument(me);
2523 return IRichEditOle_QueryInterface(&This->IRichEditOle_iface, riid, ppvObject);
2526 static ULONG WINAPI
2527 ITextDocument_fnAddRef(ITextDocument* me)
2529 IRichEditOleImpl *This = impl_from_ITextDocument(me);
2530 return IRichEditOle_AddRef(&This->IRichEditOle_iface);
2533 static ULONG WINAPI
2534 ITextDocument_fnRelease(ITextDocument* me)
2536 IRichEditOleImpl *This = impl_from_ITextDocument(me);
2537 return IRichEditOle_Release(&This->IRichEditOle_iface);
2540 static HRESULT WINAPI
2541 ITextDocument_fnGetTypeInfoCount(ITextDocument* me,
2542 UINT* pctinfo)
2544 IRichEditOleImpl *This = impl_from_ITextDocument(me);
2545 FIXME("stub %p\n",This);
2546 return E_NOTIMPL;
2549 static HRESULT WINAPI
2550 ITextDocument_fnGetTypeInfo(ITextDocument* me, UINT iTInfo, LCID lcid,
2551 ITypeInfo** ppTInfo)
2553 IRichEditOleImpl *This = impl_from_ITextDocument(me);
2554 FIXME("stub %p\n",This);
2555 return E_NOTIMPL;
2558 static HRESULT WINAPI
2559 ITextDocument_fnGetIDsOfNames(ITextDocument* me, REFIID riid,
2560 LPOLESTR* rgszNames, UINT cNames, LCID lcid, DISPID* rgDispId)
2562 IRichEditOleImpl *This = impl_from_ITextDocument(me);
2563 FIXME("stub %p\n",This);
2564 return E_NOTIMPL;
2567 static HRESULT WINAPI
2568 ITextDocument_fnInvoke(ITextDocument* me, DISPID dispIdMember,
2569 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS* pDispParams,
2570 VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr)
2572 IRichEditOleImpl *This = impl_from_ITextDocument(me);
2573 FIXME("stub %p\n",This);
2574 return E_NOTIMPL;
2577 static HRESULT WINAPI
2578 ITextDocument_fnGetName(ITextDocument* me, BSTR* pName)
2580 IRichEditOleImpl *This = impl_from_ITextDocument(me);
2581 FIXME("stub %p\n",This);
2582 return E_NOTIMPL;
2585 static HRESULT WINAPI
2586 ITextDocument_fnGetSelection(ITextDocument* me, ITextSelection** ppSel)
2588 IRichEditOleImpl *This = impl_from_ITextDocument(me);
2589 TRACE("(%p)\n", me);
2591 if(!ppSel)
2592 return E_INVALIDARG;
2593 *ppSel = &This->txtSel->ITextSelection_iface;
2594 ITextSelection_AddRef(*ppSel);
2595 return S_OK;
2598 static HRESULT WINAPI
2599 ITextDocument_fnGetStoryCount(ITextDocument* me, LONG* pCount)
2601 IRichEditOleImpl *This = impl_from_ITextDocument(me);
2602 FIXME("stub %p\n",This);
2603 return E_NOTIMPL;
2606 static HRESULT WINAPI
2607 ITextDocument_fnGetStoryRanges(ITextDocument* me,
2608 ITextStoryRanges** ppStories)
2610 IRichEditOleImpl *This = impl_from_ITextDocument(me);
2611 FIXME("stub %p\n",This);
2612 return E_NOTIMPL;
2615 static HRESULT WINAPI
2616 ITextDocument_fnGetSaved(ITextDocument* me, LONG* pValue)
2618 IRichEditOleImpl *This = impl_from_ITextDocument(me);
2619 FIXME("stub %p\n",This);
2620 return E_NOTIMPL;
2623 static HRESULT WINAPI
2624 ITextDocument_fnSetSaved(ITextDocument* me, LONG Value)
2626 IRichEditOleImpl *This = impl_from_ITextDocument(me);
2627 FIXME("stub %p\n",This);
2628 return E_NOTIMPL;
2631 static HRESULT WINAPI
2632 ITextDocument_fnGetDefaultTabStop(ITextDocument* me, float* pValue)
2634 IRichEditOleImpl *This = impl_from_ITextDocument(me);
2635 FIXME("stub %p\n",This);
2636 return E_NOTIMPL;
2639 static HRESULT WINAPI
2640 ITextDocument_fnSetDefaultTabStop(ITextDocument* me, float Value)
2642 IRichEditOleImpl *This = impl_from_ITextDocument(me);
2643 FIXME("stub %p\n",This);
2644 return E_NOTIMPL;
2647 static HRESULT WINAPI
2648 ITextDocument_fnNew(ITextDocument* me)
2650 IRichEditOleImpl *This = impl_from_ITextDocument(me);
2651 FIXME("stub %p\n",This);
2652 return E_NOTIMPL;
2655 static HRESULT WINAPI
2656 ITextDocument_fnOpen(ITextDocument* me, VARIANT* pVar, LONG Flags,
2657 LONG CodePage)
2659 IRichEditOleImpl *This = impl_from_ITextDocument(me);
2660 FIXME("stub %p\n",This);
2661 return E_NOTIMPL;
2664 static HRESULT WINAPI
2665 ITextDocument_fnSave(ITextDocument* me, VARIANT* pVar, LONG Flags,
2666 LONG CodePage)
2668 IRichEditOleImpl *This = impl_from_ITextDocument(me);
2669 FIXME("stub %p\n",This);
2670 return E_NOTIMPL;
2673 static HRESULT WINAPI
2674 ITextDocument_fnFreeze(ITextDocument* me, LONG* pCount)
2676 IRichEditOleImpl *This = impl_from_ITextDocument(me);
2677 FIXME("stub %p\n",This);
2678 return E_NOTIMPL;
2681 static HRESULT WINAPI
2682 ITextDocument_fnUnfreeze(ITextDocument* me, LONG* pCount)
2684 IRichEditOleImpl *This = impl_from_ITextDocument(me);
2685 FIXME("stub %p\n",This);
2686 return E_NOTIMPL;
2689 static HRESULT WINAPI
2690 ITextDocument_fnBeginEditCollection(ITextDocument* me)
2692 IRichEditOleImpl *This = impl_from_ITextDocument(me);
2693 FIXME("stub %p\n",This);
2694 return E_NOTIMPL;
2697 static HRESULT WINAPI
2698 ITextDocument_fnEndEditCollection(ITextDocument* me)
2700 IRichEditOleImpl *This = impl_from_ITextDocument(me);
2701 FIXME("stub %p\n",This);
2702 return E_NOTIMPL;
2705 static HRESULT WINAPI
2706 ITextDocument_fnUndo(ITextDocument* me, LONG Count, LONG* prop)
2708 IRichEditOleImpl *This = impl_from_ITextDocument(me);
2709 FIXME("stub %p\n",This);
2710 return E_NOTIMPL;
2713 static HRESULT WINAPI
2714 ITextDocument_fnRedo(ITextDocument* me, LONG Count, LONG* prop)
2716 IRichEditOleImpl *This = impl_from_ITextDocument(me);
2717 FIXME("stub %p\n",This);
2718 return E_NOTIMPL;
2721 static HRESULT CreateITextRange(IRichEditOleImpl *reOle, LONG start, LONG end, ITextRange** ppRange)
2723 ITextRangeImpl *txtRge = heap_alloc(sizeof(ITextRangeImpl));
2725 if (!txtRge)
2726 return E_OUTOFMEMORY;
2727 txtRge->ITextRange_iface.lpVtbl = &trvt;
2728 txtRge->ref = 1;
2729 txtRge->reOle = reOle;
2730 txtRge->start = start;
2731 txtRge->end = end;
2732 list_add_head(&reOle->rangelist, &txtRge->entry);
2733 *ppRange = &txtRge->ITextRange_iface;
2734 return S_OK;
2737 static HRESULT WINAPI
2738 ITextDocument_fnRange(ITextDocument* me, LONG cp1, LONG cp2,
2739 ITextRange** ppRange)
2741 IRichEditOleImpl *This = impl_from_ITextDocument(me);
2742 const int len = ME_GetTextLength(This->editor) + 1;
2744 TRACE("%p %p %d %d\n", This, ppRange, cp1, cp2);
2745 if (!ppRange)
2746 return E_INVALIDARG;
2748 cp1 = max(cp1, 0);
2749 cp2 = max(cp2, 0);
2750 cp1 = min(cp1, len);
2751 cp2 = min(cp2, len);
2752 if (cp1 > cp2)
2754 LONG tmp;
2755 tmp = cp1;
2756 cp1 = cp2;
2757 cp2 = tmp;
2759 if (cp1 == len)
2760 cp1 = cp2 = len - 1;
2762 return CreateITextRange(This, cp1, cp2, ppRange);
2765 static HRESULT WINAPI
2766 ITextDocument_fnRangeFromPoint(ITextDocument* me, LONG x, LONG y,
2767 ITextRange** ppRange)
2769 IRichEditOleImpl *This = impl_from_ITextDocument(me);
2770 FIXME("stub %p\n",This);
2771 return E_NOTIMPL;
2774 static const ITextDocumentVtbl tdvt = {
2775 ITextDocument_fnQueryInterface,
2776 ITextDocument_fnAddRef,
2777 ITextDocument_fnRelease,
2778 ITextDocument_fnGetTypeInfoCount,
2779 ITextDocument_fnGetTypeInfo,
2780 ITextDocument_fnGetIDsOfNames,
2781 ITextDocument_fnInvoke,
2782 ITextDocument_fnGetName,
2783 ITextDocument_fnGetSelection,
2784 ITextDocument_fnGetStoryCount,
2785 ITextDocument_fnGetStoryRanges,
2786 ITextDocument_fnGetSaved,
2787 ITextDocument_fnSetSaved,
2788 ITextDocument_fnGetDefaultTabStop,
2789 ITextDocument_fnSetDefaultTabStop,
2790 ITextDocument_fnNew,
2791 ITextDocument_fnOpen,
2792 ITextDocument_fnSave,
2793 ITextDocument_fnFreeze,
2794 ITextDocument_fnUnfreeze,
2795 ITextDocument_fnBeginEditCollection,
2796 ITextDocument_fnEndEditCollection,
2797 ITextDocument_fnUndo,
2798 ITextDocument_fnRedo,
2799 ITextDocument_fnRange,
2800 ITextDocument_fnRangeFromPoint
2803 /* ITextSelection */
2804 static HRESULT WINAPI ITextSelection_fnQueryInterface(
2805 ITextSelection *me,
2806 REFIID riid,
2807 void **ppvObj)
2809 *ppvObj = NULL;
2810 if (IsEqualGUID(riid, &IID_IUnknown)
2811 || IsEqualGUID(riid, &IID_IDispatch)
2812 || IsEqualGUID(riid, &IID_ITextRange)
2813 || IsEqualGUID(riid, &IID_ITextSelection))
2815 *ppvObj = me;
2816 ITextSelection_AddRef(me);
2817 return S_OK;
2820 return E_NOINTERFACE;
2823 static ULONG WINAPI ITextSelection_fnAddRef(ITextSelection *me)
2825 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2826 return InterlockedIncrement(&This->ref);
2829 static ULONG WINAPI ITextSelection_fnRelease(ITextSelection *me)
2831 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2832 ULONG ref = InterlockedDecrement(&This->ref);
2833 if (ref == 0)
2834 heap_free(This);
2835 return ref;
2838 static HRESULT WINAPI ITextSelection_fnGetTypeInfoCount(ITextSelection *me, UINT *pctinfo)
2840 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2841 if (!This->reOle)
2842 return CO_E_RELEASED;
2844 FIXME("not implemented\n");
2845 return E_NOTIMPL;
2848 static HRESULT WINAPI ITextSelection_fnGetTypeInfo(ITextSelection *me, UINT iTInfo, LCID lcid,
2849 ITypeInfo **ppTInfo)
2851 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2852 if (!This->reOle)
2853 return CO_E_RELEASED;
2855 FIXME("not implemented\n");
2856 return E_NOTIMPL;
2859 static HRESULT WINAPI ITextSelection_fnGetIDsOfNames(ITextSelection *me, REFIID riid,
2860 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
2862 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2863 if (!This->reOle)
2864 return CO_E_RELEASED;
2866 FIXME("not implemented\n");
2867 return E_NOTIMPL;
2870 static HRESULT WINAPI ITextSelection_fnInvoke(
2871 ITextSelection *me,
2872 DISPID dispIdMember,
2873 REFIID riid,
2874 LCID lcid,
2875 WORD wFlags,
2876 DISPPARAMS *pDispParams,
2877 VARIANT *pVarResult,
2878 EXCEPINFO *pExcepInfo,
2879 UINT *puArgErr)
2881 FIXME("not implemented\n");
2882 return E_NOTIMPL;
2885 /*** ITextRange methods ***/
2886 static HRESULT WINAPI ITextSelection_fnGetText(ITextSelection *me, BSTR *pbstr)
2888 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2889 ME_Cursor *start = NULL, *end = NULL;
2890 int nChars, endOfs;
2891 BOOL bEOP;
2893 if (!This->reOle)
2894 return CO_E_RELEASED;
2895 TRACE("%p\n", pbstr);
2896 if (!pbstr)
2897 return E_INVALIDARG;
2899 ME_GetSelection(This->reOle->editor, &start, &end);
2900 endOfs = ME_GetCursorOfs(end);
2901 nChars = endOfs - ME_GetCursorOfs(start);
2902 if (!nChars)
2904 *pbstr = NULL;
2905 return S_OK;
2908 *pbstr = SysAllocStringLen(NULL, nChars);
2909 if (!*pbstr)
2910 return E_OUTOFMEMORY;
2912 bEOP = (end->pRun->next->type == diTextEnd && endOfs > ME_GetTextLength(This->reOle->editor));
2913 ME_GetTextW(This->reOle->editor, *pbstr, nChars, start, nChars, FALSE, bEOP);
2914 TRACE("%s\n", wine_dbgstr_w(*pbstr));
2916 return S_OK;
2919 static HRESULT WINAPI ITextSelection_fnSetText(ITextSelection *me, BSTR bstr)
2921 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2922 if (!This->reOle)
2923 return CO_E_RELEASED;
2925 FIXME("not implemented\n");
2926 return E_NOTIMPL;
2929 static HRESULT WINAPI ITextSelection_fnGetChar(ITextSelection *me, LONG *pch)
2931 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2932 ME_Cursor *start = NULL, *end = NULL;
2934 if (!This->reOle)
2935 return CO_E_RELEASED;
2936 TRACE("%p\n", pch);
2937 if (!pch)
2938 return E_INVALIDARG;
2940 ME_GetSelection(This->reOle->editor, &start, &end);
2941 return range_GetChar(This->reOle->editor, start, pch);
2944 static HRESULT WINAPI ITextSelection_fnSetChar(ITextSelection *me, LONG ch)
2946 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2947 if (!This->reOle)
2948 return CO_E_RELEASED;
2950 FIXME("not implemented\n");
2951 return E_NOTIMPL;
2954 static HRESULT WINAPI ITextSelection_fnGetDuplicate(ITextSelection *me, ITextRange **ppRange)
2956 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2957 if (!This->reOle)
2958 return CO_E_RELEASED;
2960 FIXME("not implemented\n");
2961 return E_NOTIMPL;
2964 static HRESULT WINAPI ITextSelection_fnGetFormattedText(ITextSelection *me, ITextRange **ppRange)
2966 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2967 if (!This->reOle)
2968 return CO_E_RELEASED;
2970 FIXME("not implemented\n");
2971 return E_NOTIMPL;
2974 static HRESULT WINAPI ITextSelection_fnSetFormattedText(ITextSelection *me, ITextRange *pRange)
2976 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2977 if (!This->reOle)
2978 return CO_E_RELEASED;
2980 FIXME("not implemented\n");
2981 return E_NOTIMPL;
2984 static HRESULT WINAPI ITextSelection_fnGetStart(ITextSelection *me, LONG *pcpFirst)
2986 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2987 LONG lim;
2988 if (!This->reOle)
2989 return CO_E_RELEASED;
2991 if (!pcpFirst)
2992 return E_INVALIDARG;
2993 ME_GetSelectionOfs(This->reOle->editor, pcpFirst, &lim);
2994 TRACE("%d\n", *pcpFirst);
2995 return S_OK;
2998 static HRESULT WINAPI ITextSelection_fnSetStart(ITextSelection *me, LONG cpFirst)
3000 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3001 if (!This->reOle)
3002 return CO_E_RELEASED;
3004 FIXME("not implemented\n");
3005 return E_NOTIMPL;
3008 static HRESULT WINAPI ITextSelection_fnGetEnd(ITextSelection *me, LONG *pcpLim)
3010 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3011 LONG first;
3012 if (!This->reOle)
3013 return CO_E_RELEASED;
3015 if (!pcpLim)
3016 return E_INVALIDARG;
3017 ME_GetSelectionOfs(This->reOle->editor, &first, pcpLim);
3018 TRACE("%d\n", *pcpLim);
3019 return S_OK;
3022 static HRESULT WINAPI ITextSelection_fnSetEnd(ITextSelection *me, LONG cpLim)
3024 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3025 if (!This->reOle)
3026 return CO_E_RELEASED;
3028 FIXME("not implemented\n");
3029 return E_NOTIMPL;
3032 static HRESULT WINAPI ITextSelection_fnGetFont(ITextSelection *me, ITextFont **pFont)
3034 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3035 if (!This->reOle)
3036 return CO_E_RELEASED;
3038 FIXME("not implemented\n");
3039 return E_NOTIMPL;
3042 static HRESULT WINAPI ITextSelection_fnSetFont(ITextSelection *me, ITextFont *pFont)
3044 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3045 if (!This->reOle)
3046 return CO_E_RELEASED;
3048 FIXME("not implemented\n");
3049 return E_NOTIMPL;
3052 static HRESULT WINAPI ITextSelection_fnGetPara(ITextSelection *me, ITextPara **para)
3054 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3055 if (!This->reOle)
3056 return CO_E_RELEASED;
3058 FIXME("not implemented\n");
3059 return E_NOTIMPL;
3062 static HRESULT WINAPI ITextSelection_fnSetPara(ITextSelection *me, ITextPara *pPara)
3064 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3065 if (!This->reOle)
3066 return CO_E_RELEASED;
3068 FIXME("not implemented\n");
3069 return E_NOTIMPL;
3072 static HRESULT WINAPI ITextSelection_fnGetStoryLength(ITextSelection *me, LONG *pcch)
3074 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3075 if (!This->reOle)
3076 return CO_E_RELEASED;
3078 FIXME("not implemented\n");
3079 return E_NOTIMPL;
3082 static HRESULT WINAPI ITextSelection_fnGetStoryType(ITextSelection *me, LONG *pValue)
3084 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3085 if (!This->reOle)
3086 return CO_E_RELEASED;
3088 FIXME("not implemented\n");
3089 return E_NOTIMPL;
3092 static HRESULT WINAPI ITextSelection_fnCollapse(ITextSelection *me, LONG bStart)
3094 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3095 LONG start, end;
3096 HRESULT hres;
3097 if (!This->reOle)
3098 return CO_E_RELEASED;
3100 ME_GetSelectionOfs(This->reOle->editor, &start, &end);
3101 hres = range_Collapse(bStart, &start, &end);
3102 if (SUCCEEDED(hres))
3103 ME_SetSelection(This->reOle->editor, start, end);
3104 return hres;
3107 static HRESULT WINAPI ITextSelection_fnExpand(ITextSelection *me, LONG Unit, LONG *pDelta)
3109 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3110 if (!This->reOle)
3111 return CO_E_RELEASED;
3113 FIXME("not implemented\n");
3114 return E_NOTIMPL;
3117 static HRESULT WINAPI ITextSelection_fnGetIndex(ITextSelection *me, LONG Unit, LONG *pIndex)
3119 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3120 if (!This->reOle)
3121 return CO_E_RELEASED;
3123 FIXME("not implemented\n");
3124 return E_NOTIMPL;
3127 static HRESULT WINAPI ITextSelection_fnSetIndex(ITextSelection *me, LONG Unit, LONG Index,
3128 LONG Extend)
3130 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3131 if (!This->reOle)
3132 return CO_E_RELEASED;
3134 FIXME("not implemented\n");
3135 return E_NOTIMPL;
3138 static HRESULT WINAPI ITextSelection_fnSetRange(ITextSelection *me, LONG cpActive, LONG cpOther)
3140 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3141 if (!This->reOle)
3142 return CO_E_RELEASED;
3144 FIXME("not implemented\n");
3145 return E_NOTIMPL;
3148 static HRESULT WINAPI ITextSelection_fnInRange(ITextSelection *me, ITextRange *pRange, LONG *pb)
3150 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3151 if (!This->reOle)
3152 return CO_E_RELEASED;
3154 FIXME("not implemented\n");
3155 return E_NOTIMPL;
3158 static HRESULT WINAPI ITextSelection_fnInStory(ITextSelection *me, ITextRange *pRange, LONG *pb)
3160 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3161 if (!This->reOle)
3162 return CO_E_RELEASED;
3164 FIXME("not implemented\n");
3165 return E_NOTIMPL;
3168 static HRESULT WINAPI ITextSelection_fnIsEqual(ITextSelection *me, ITextRange *pRange, LONG *pb)
3170 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3171 if (!This->reOle)
3172 return CO_E_RELEASED;
3174 FIXME("not implemented\n");
3175 return E_NOTIMPL;
3178 static HRESULT WINAPI ITextSelection_fnSelect(ITextSelection *me)
3180 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3181 if (!This->reOle)
3182 return CO_E_RELEASED;
3184 FIXME("not implemented\n");
3185 return E_NOTIMPL;
3188 static HRESULT WINAPI ITextSelection_fnStartOf(ITextSelection *me, LONG Unit, LONG Extend,
3189 LONG *pDelta)
3191 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3192 if (!This->reOle)
3193 return CO_E_RELEASED;
3195 FIXME("not implemented\n");
3196 return E_NOTIMPL;
3199 static HRESULT WINAPI ITextSelection_fnEndOf(ITextSelection *me, LONG Unit, LONG Extend,
3200 LONG *pDelta)
3202 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3203 if (!This->reOle)
3204 return CO_E_RELEASED;
3206 FIXME("not implemented\n");
3207 return E_NOTIMPL;
3210 static HRESULT WINAPI ITextSelection_fnMove(ITextSelection *me, LONG Unit, LONG Count, LONG *pDelta)
3212 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3213 if (!This->reOle)
3214 return CO_E_RELEASED;
3216 FIXME("not implemented\n");
3217 return E_NOTIMPL;
3220 static HRESULT WINAPI ITextSelection_fnMoveStart(ITextSelection *me, LONG Unit, LONG Count,
3221 LONG *pDelta)
3223 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3224 if (!This->reOle)
3225 return CO_E_RELEASED;
3227 FIXME("not implemented\n");
3228 return E_NOTIMPL;
3231 static HRESULT WINAPI ITextSelection_fnMoveEnd(ITextSelection *me, LONG Unit, LONG Count,
3232 LONG *pDelta)
3234 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3235 if (!This->reOle)
3236 return CO_E_RELEASED;
3238 FIXME("not implemented\n");
3239 return E_NOTIMPL;
3242 static HRESULT WINAPI ITextSelection_fnMoveWhile(ITextSelection *me, VARIANT *Cset, LONG Count,
3243 LONG *pDelta)
3245 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3246 if (!This->reOle)
3247 return CO_E_RELEASED;
3249 FIXME("not implemented\n");
3250 return E_NOTIMPL;
3253 static HRESULT WINAPI ITextSelection_fnMoveStartWhile(ITextSelection *me, VARIANT *Cset, LONG Count,
3254 LONG *pDelta)
3256 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3257 if (!This->reOle)
3258 return CO_E_RELEASED;
3260 FIXME("not implemented\n");
3261 return E_NOTIMPL;
3264 static HRESULT WINAPI ITextSelection_fnMoveEndWhile(ITextSelection *me, VARIANT *Cset, LONG Count,
3265 LONG *pDelta)
3267 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3268 if (!This->reOle)
3269 return CO_E_RELEASED;
3271 FIXME("not implemented\n");
3272 return E_NOTIMPL;
3275 static HRESULT WINAPI ITextSelection_fnMoveUntil(ITextSelection *me, VARIANT *Cset, LONG Count,
3276 LONG *pDelta)
3278 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3279 if (!This->reOle)
3280 return CO_E_RELEASED;
3282 FIXME("not implemented\n");
3283 return E_NOTIMPL;
3286 static HRESULT WINAPI ITextSelection_fnMoveStartUntil(ITextSelection *me, VARIANT *Cset, LONG Count,
3287 LONG *pDelta)
3289 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3290 if (!This->reOle)
3291 return CO_E_RELEASED;
3293 FIXME("not implemented\n");
3294 return E_NOTIMPL;
3297 static HRESULT WINAPI ITextSelection_fnMoveEndUntil(ITextSelection *me, VARIANT *Cset, LONG Count,
3298 LONG *pDelta)
3300 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3301 if (!This->reOle)
3302 return CO_E_RELEASED;
3304 FIXME("not implemented\n");
3305 return E_NOTIMPL;
3308 static HRESULT WINAPI ITextSelection_fnFindText(ITextSelection *me, BSTR bstr, LONG cch, LONG Flags,
3309 LONG *pLength)
3311 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3312 if (!This->reOle)
3313 return CO_E_RELEASED;
3315 FIXME("not implemented\n");
3316 return E_NOTIMPL;
3319 static HRESULT WINAPI ITextSelection_fnFindTextStart(ITextSelection *me, BSTR bstr, LONG cch,
3320 LONG Flags, LONG *pLength)
3322 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3323 if (!This->reOle)
3324 return CO_E_RELEASED;
3326 FIXME("not implemented\n");
3327 return E_NOTIMPL;
3330 static HRESULT WINAPI ITextSelection_fnFindTextEnd(ITextSelection *me, BSTR bstr, LONG cch,
3331 LONG Flags, LONG *pLength)
3333 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3334 if (!This->reOle)
3335 return CO_E_RELEASED;
3337 FIXME("not implemented\n");
3338 return E_NOTIMPL;
3341 static HRESULT WINAPI ITextSelection_fnDelete(ITextSelection *me, LONG Unit, LONG Count,
3342 LONG *pDelta)
3344 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3345 if (!This->reOle)
3346 return CO_E_RELEASED;
3348 FIXME("not implemented\n");
3349 return E_NOTIMPL;
3352 static HRESULT WINAPI ITextSelection_fnCut(ITextSelection *me, VARIANT *pVar)
3354 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3355 if (!This->reOle)
3356 return CO_E_RELEASED;
3358 FIXME("not implemented\n");
3359 return E_NOTIMPL;
3362 static HRESULT WINAPI ITextSelection_fnCopy(ITextSelection *me, VARIANT *pVar)
3364 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3365 if (!This->reOle)
3366 return CO_E_RELEASED;
3368 FIXME("not implemented\n");
3369 return E_NOTIMPL;
3372 static HRESULT WINAPI ITextSelection_fnPaste(ITextSelection *me, VARIANT *pVar, LONG Format)
3374 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3375 if (!This->reOle)
3376 return CO_E_RELEASED;
3378 FIXME("not implemented\n");
3379 return E_NOTIMPL;
3382 static HRESULT WINAPI ITextSelection_fnCanPaste(ITextSelection *me, VARIANT *pVar, LONG Format,
3383 LONG *pb)
3385 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3386 if (!This->reOle)
3387 return CO_E_RELEASED;
3389 FIXME("not implemented\n");
3390 return E_NOTIMPL;
3393 static HRESULT WINAPI ITextSelection_fnCanEdit(ITextSelection *me, LONG *pb)
3395 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3396 if (!This->reOle)
3397 return CO_E_RELEASED;
3399 FIXME("not implemented\n");
3400 return E_NOTIMPL;
3403 static HRESULT WINAPI ITextSelection_fnChangeCase(ITextSelection *me, LONG Type)
3405 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3406 if (!This->reOle)
3407 return CO_E_RELEASED;
3409 FIXME("not implemented\n");
3410 return E_NOTIMPL;
3413 static HRESULT WINAPI ITextSelection_fnGetPoint(ITextSelection *me, LONG Type, LONG *cx, LONG *cy)
3415 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3416 if (!This->reOle)
3417 return CO_E_RELEASED;
3419 FIXME("not implemented\n");
3420 return E_NOTIMPL;
3423 static HRESULT WINAPI ITextSelection_fnSetPoint(ITextSelection *me, LONG x, LONG y, LONG Type,
3424 LONG Extend)
3426 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3427 if (!This->reOle)
3428 return CO_E_RELEASED;
3430 FIXME("not implemented\n");
3431 return E_NOTIMPL;
3434 static HRESULT WINAPI ITextSelection_fnScrollIntoView(ITextSelection *me, LONG Value)
3436 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3437 if (!This->reOle)
3438 return CO_E_RELEASED;
3440 FIXME("not implemented\n");
3441 return E_NOTIMPL;
3444 static HRESULT WINAPI ITextSelection_fnGetEmbeddedObject(ITextSelection *me, IUnknown **ppv)
3446 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3447 if (!This->reOle)
3448 return CO_E_RELEASED;
3450 FIXME("not implemented\n");
3451 return E_NOTIMPL;
3454 /*** ITextSelection methods ***/
3455 static HRESULT WINAPI ITextSelection_fnGetFlags(ITextSelection *me, LONG *pFlags)
3457 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3458 if (!This->reOle)
3459 return CO_E_RELEASED;
3461 FIXME("not implemented\n");
3462 return E_NOTIMPL;
3465 static HRESULT WINAPI ITextSelection_fnSetFlags(ITextSelection *me, LONG Flags)
3467 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3468 if (!This->reOle)
3469 return CO_E_RELEASED;
3471 FIXME("not implemented\n");
3472 return E_NOTIMPL;
3475 static HRESULT WINAPI ITextSelection_fnGetType(ITextSelection *me, LONG *pType)
3477 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3478 if (!This->reOle)
3479 return CO_E_RELEASED;
3481 FIXME("not implemented\n");
3482 return E_NOTIMPL;
3485 static HRESULT WINAPI ITextSelection_fnMoveLeft(ITextSelection *me, LONG Unit, LONG Count,
3486 LONG Extend, LONG *pDelta)
3488 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3489 if (!This->reOle)
3490 return CO_E_RELEASED;
3492 FIXME("not implemented\n");
3493 return E_NOTIMPL;
3496 static HRESULT WINAPI ITextSelection_fnMoveRight(ITextSelection *me, LONG Unit, LONG Count,
3497 LONG Extend, LONG *pDelta)
3499 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3500 if (!This->reOle)
3501 return CO_E_RELEASED;
3503 FIXME("not implemented\n");
3504 return E_NOTIMPL;
3507 static HRESULT WINAPI ITextSelection_fnMoveUp(ITextSelection *me, LONG Unit, LONG Count,
3508 LONG Extend, LONG *pDelta)
3510 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3511 if (!This->reOle)
3512 return CO_E_RELEASED;
3514 FIXME("not implemented\n");
3515 return E_NOTIMPL;
3518 static HRESULT WINAPI ITextSelection_fnMoveDown(ITextSelection *me, LONG Unit, LONG Count,
3519 LONG Extend, LONG *pDelta)
3521 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3522 if (!This->reOle)
3523 return CO_E_RELEASED;
3525 FIXME("not implemented\n");
3526 return E_NOTIMPL;
3529 static HRESULT WINAPI ITextSelection_fnHomeKey(ITextSelection *me, LONG Unit, LONG Extend,
3530 LONG *pDelta)
3532 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3533 if (!This->reOle)
3534 return CO_E_RELEASED;
3536 FIXME("not implemented\n");
3537 return E_NOTIMPL;
3540 static HRESULT WINAPI ITextSelection_fnEndKey(ITextSelection *me, LONG Unit, LONG Extend,
3541 LONG *pDelta)
3543 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3544 if (!This->reOle)
3545 return CO_E_RELEASED;
3547 FIXME("not implemented\n");
3548 return E_NOTIMPL;
3551 static HRESULT WINAPI ITextSelection_fnTypeText(ITextSelection *me, BSTR bstr)
3553 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3554 if (!This->reOle)
3555 return CO_E_RELEASED;
3557 FIXME("not implemented\n");
3558 return E_NOTIMPL;
3561 static const ITextSelectionVtbl tsvt = {
3562 ITextSelection_fnQueryInterface,
3563 ITextSelection_fnAddRef,
3564 ITextSelection_fnRelease,
3565 ITextSelection_fnGetTypeInfoCount,
3566 ITextSelection_fnGetTypeInfo,
3567 ITextSelection_fnGetIDsOfNames,
3568 ITextSelection_fnInvoke,
3569 ITextSelection_fnGetText,
3570 ITextSelection_fnSetText,
3571 ITextSelection_fnGetChar,
3572 ITextSelection_fnSetChar,
3573 ITextSelection_fnGetDuplicate,
3574 ITextSelection_fnGetFormattedText,
3575 ITextSelection_fnSetFormattedText,
3576 ITextSelection_fnGetStart,
3577 ITextSelection_fnSetStart,
3578 ITextSelection_fnGetEnd,
3579 ITextSelection_fnSetEnd,
3580 ITextSelection_fnGetFont,
3581 ITextSelection_fnSetFont,
3582 ITextSelection_fnGetPara,
3583 ITextSelection_fnSetPara,
3584 ITextSelection_fnGetStoryLength,
3585 ITextSelection_fnGetStoryType,
3586 ITextSelection_fnCollapse,
3587 ITextSelection_fnExpand,
3588 ITextSelection_fnGetIndex,
3589 ITextSelection_fnSetIndex,
3590 ITextSelection_fnSetRange,
3591 ITextSelection_fnInRange,
3592 ITextSelection_fnInStory,
3593 ITextSelection_fnIsEqual,
3594 ITextSelection_fnSelect,
3595 ITextSelection_fnStartOf,
3596 ITextSelection_fnEndOf,
3597 ITextSelection_fnMove,
3598 ITextSelection_fnMoveStart,
3599 ITextSelection_fnMoveEnd,
3600 ITextSelection_fnMoveWhile,
3601 ITextSelection_fnMoveStartWhile,
3602 ITextSelection_fnMoveEndWhile,
3603 ITextSelection_fnMoveUntil,
3604 ITextSelection_fnMoveStartUntil,
3605 ITextSelection_fnMoveEndUntil,
3606 ITextSelection_fnFindText,
3607 ITextSelection_fnFindTextStart,
3608 ITextSelection_fnFindTextEnd,
3609 ITextSelection_fnDelete,
3610 ITextSelection_fnCut,
3611 ITextSelection_fnCopy,
3612 ITextSelection_fnPaste,
3613 ITextSelection_fnCanPaste,
3614 ITextSelection_fnCanEdit,
3615 ITextSelection_fnChangeCase,
3616 ITextSelection_fnGetPoint,
3617 ITextSelection_fnSetPoint,
3618 ITextSelection_fnScrollIntoView,
3619 ITextSelection_fnGetEmbeddedObject,
3620 ITextSelection_fnGetFlags,
3621 ITextSelection_fnSetFlags,
3622 ITextSelection_fnGetType,
3623 ITextSelection_fnMoveLeft,
3624 ITextSelection_fnMoveRight,
3625 ITextSelection_fnMoveUp,
3626 ITextSelection_fnMoveDown,
3627 ITextSelection_fnHomeKey,
3628 ITextSelection_fnEndKey,
3629 ITextSelection_fnTypeText
3632 static ITextSelectionImpl *
3633 CreateTextSelection(IRichEditOleImpl *reOle)
3635 ITextSelectionImpl *txtSel = heap_alloc(sizeof *txtSel);
3636 if (!txtSel)
3637 return NULL;
3639 txtSel->ITextSelection_iface.lpVtbl = &tsvt;
3640 txtSel->ref = 1;
3641 txtSel->reOle = reOle;
3642 return txtSel;
3645 LRESULT CreateIRichEditOle(IUnknown *outer_unk, ME_TextEditor *editor, LPVOID *ppvObj)
3647 IRichEditOleImpl *reo;
3649 reo = heap_alloc(sizeof(IRichEditOleImpl));
3650 if (!reo)
3651 return 0;
3653 reo->IUnknown_inner.lpVtbl = &reo_unk_vtbl;
3654 reo->IRichEditOle_iface.lpVtbl = &revt;
3655 reo->ITextDocument_iface.lpVtbl = &tdvt;
3656 reo->ref = 1;
3657 reo->editor = editor;
3658 reo->txtSel = CreateTextSelection(reo);
3659 if (!reo->txtSel)
3661 heap_free(reo);
3662 return 0;
3664 reo->clientSite = CreateOleClientSite(reo);
3665 if (!reo->clientSite)
3667 ITextSelection_Release(&reo->txtSel->ITextSelection_iface);
3668 heap_free(reo);
3669 return 0;
3671 TRACE("Created %p\n",reo);
3672 list_init(&reo->rangelist);
3673 if (outer_unk)
3674 reo->outer_unk = outer_unk;
3675 else
3676 reo->outer_unk = &reo->IUnknown_inner;
3677 *ppvObj = &reo->IRichEditOle_iface;
3679 return 1;
3682 static void convert_sizel(const ME_Context *c, const SIZEL* szl, SIZE* sz)
3684 /* sizel is in .01 millimeters, sz in pixels */
3685 sz->cx = MulDiv(szl->cx, c->dpi.cx, 2540);
3686 sz->cy = MulDiv(szl->cy, c->dpi.cy, 2540);
3689 /******************************************************************************
3690 * ME_GetOLEObjectSize
3692 * Sets run extent for OLE objects.
3694 void ME_GetOLEObjectSize(const ME_Context *c, ME_Run *run, SIZE *pSize)
3696 IDataObject* ido;
3697 FORMATETC fmt;
3698 STGMEDIUM stgm;
3699 DIBSECTION dibsect;
3700 ENHMETAHEADER emh;
3702 assert(run->nFlags & MERF_GRAPHICS);
3703 assert(run->ole_obj);
3705 if (run->ole_obj->sizel.cx != 0 || run->ole_obj->sizel.cy != 0)
3707 convert_sizel(c, &run->ole_obj->sizel, pSize);
3708 if (c->editor->nZoomNumerator != 0)
3710 pSize->cx = MulDiv(pSize->cx, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
3711 pSize->cy = MulDiv(pSize->cy, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
3713 return;
3716 if (IOleObject_QueryInterface(run->ole_obj->poleobj, &IID_IDataObject, (void**)&ido) != S_OK)
3718 FIXME("Query Interface IID_IDataObject failed!\n");
3719 pSize->cx = pSize->cy = 0;
3720 return;
3722 fmt.cfFormat = CF_BITMAP;
3723 fmt.ptd = NULL;
3724 fmt.dwAspect = DVASPECT_CONTENT;
3725 fmt.lindex = -1;
3726 fmt.tymed = TYMED_GDI;
3727 if (IDataObject_GetData(ido, &fmt, &stgm) != S_OK)
3729 fmt.cfFormat = CF_ENHMETAFILE;
3730 fmt.tymed = TYMED_ENHMF;
3731 if (IDataObject_GetData(ido, &fmt, &stgm) != S_OK)
3733 FIXME("unsupported format\n");
3734 pSize->cx = pSize->cy = 0;
3735 IDataObject_Release(ido);
3736 return;
3740 switch (stgm.tymed)
3742 case TYMED_GDI:
3743 GetObjectW(stgm.u.hBitmap, sizeof(dibsect), &dibsect);
3744 pSize->cx = dibsect.dsBm.bmWidth;
3745 pSize->cy = dibsect.dsBm.bmHeight;
3746 if (!stgm.pUnkForRelease) DeleteObject(stgm.u.hBitmap);
3747 break;
3748 case TYMED_ENHMF:
3749 GetEnhMetaFileHeader(stgm.u.hEnhMetaFile, sizeof(emh), &emh);
3750 pSize->cx = emh.rclBounds.right - emh.rclBounds.left;
3751 pSize->cy = emh.rclBounds.bottom - emh.rclBounds.top;
3752 if (!stgm.pUnkForRelease) DeleteEnhMetaFile(stgm.u.hEnhMetaFile);
3753 break;
3754 default:
3755 FIXME("Unsupported tymed %d\n", stgm.tymed);
3756 break;
3758 IDataObject_Release(ido);
3759 if (c->editor->nZoomNumerator != 0)
3761 pSize->cx = MulDiv(pSize->cx, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
3762 pSize->cy = MulDiv(pSize->cy, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
3766 void ME_DrawOLE(ME_Context *c, int x, int y, ME_Run *run,
3767 ME_Paragraph *para, BOOL selected)
3769 IDataObject* ido;
3770 FORMATETC fmt;
3771 STGMEDIUM stgm;
3772 DIBSECTION dibsect;
3773 ENHMETAHEADER emh;
3774 HDC hMemDC;
3775 SIZE sz;
3776 BOOL has_size;
3778 assert(run->nFlags & MERF_GRAPHICS);
3779 assert(run->ole_obj);
3780 if (IOleObject_QueryInterface(run->ole_obj->poleobj, &IID_IDataObject, (void**)&ido) != S_OK)
3782 FIXME("Couldn't get interface\n");
3783 return;
3785 has_size = run->ole_obj->sizel.cx != 0 || run->ole_obj->sizel.cy != 0;
3786 fmt.cfFormat = CF_BITMAP;
3787 fmt.ptd = NULL;
3788 fmt.dwAspect = DVASPECT_CONTENT;
3789 fmt.lindex = -1;
3790 fmt.tymed = TYMED_GDI;
3791 if (IDataObject_GetData(ido, &fmt, &stgm) != S_OK)
3793 fmt.cfFormat = CF_ENHMETAFILE;
3794 fmt.tymed = TYMED_ENHMF;
3795 if (IDataObject_GetData(ido, &fmt, &stgm) != S_OK)
3797 FIXME("Couldn't get storage medium\n");
3798 IDataObject_Release(ido);
3799 return;
3802 switch (stgm.tymed)
3804 case TYMED_GDI:
3805 GetObjectW(stgm.u.hBitmap, sizeof(dibsect), &dibsect);
3806 hMemDC = CreateCompatibleDC(c->hDC);
3807 SelectObject(hMemDC, stgm.u.hBitmap);
3808 if (has_size)
3810 convert_sizel(c, &run->ole_obj->sizel, &sz);
3811 } else {
3812 sz.cx = MulDiv(dibsect.dsBm.bmWidth, c->dpi.cx, 96);
3813 sz.cy = MulDiv(dibsect.dsBm.bmHeight, c->dpi.cy, 96);
3815 if (c->editor->nZoomNumerator != 0)
3817 sz.cx = MulDiv(sz.cx, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
3818 sz.cy = MulDiv(sz.cy, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
3820 if (sz.cx == dibsect.dsBm.bmWidth && sz.cy == dibsect.dsBm.bmHeight)
3822 BitBlt(c->hDC, x, y - sz.cy,
3823 dibsect.dsBm.bmWidth, dibsect.dsBm.bmHeight,
3824 hMemDC, 0, 0, SRCCOPY);
3825 } else {
3826 StretchBlt(c->hDC, x, y - sz.cy, sz.cx, sz.cy,
3827 hMemDC, 0, 0, dibsect.dsBm.bmWidth,
3828 dibsect.dsBm.bmHeight, SRCCOPY);
3830 DeleteDC(hMemDC);
3831 if (!stgm.pUnkForRelease) DeleteObject(stgm.u.hBitmap);
3832 break;
3833 case TYMED_ENHMF:
3834 GetEnhMetaFileHeader(stgm.u.hEnhMetaFile, sizeof(emh), &emh);
3835 if (has_size)
3837 convert_sizel(c, &run->ole_obj->sizel, &sz);
3838 } else {
3839 sz.cy = MulDiv(emh.rclBounds.bottom - emh.rclBounds.top, c->dpi.cx, 96);
3840 sz.cx = MulDiv(emh.rclBounds.right - emh.rclBounds.left, c->dpi.cy, 96);
3842 if (c->editor->nZoomNumerator != 0)
3844 sz.cx = MulDiv(sz.cx, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
3845 sz.cy = MulDiv(sz.cy, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
3849 RECT rc;
3851 rc.left = x;
3852 rc.top = y - sz.cy;
3853 rc.right = x + sz.cx;
3854 rc.bottom = y;
3855 PlayEnhMetaFile(c->hDC, stgm.u.hEnhMetaFile, &rc);
3857 if (!stgm.pUnkForRelease) DeleteEnhMetaFile(stgm.u.hEnhMetaFile);
3858 break;
3859 default:
3860 FIXME("Unsupported tymed %d\n", stgm.tymed);
3861 selected = FALSE;
3862 break;
3864 if (selected && !c->editor->bHideSelection)
3865 PatBlt(c->hDC, x, y - sz.cy, sz.cx, sz.cy, DSTINVERT);
3866 IDataObject_Release(ido);
3869 void ME_DeleteReObject(REOBJECT* reo)
3871 if (reo->poleobj) IOleObject_Release(reo->poleobj);
3872 if (reo->pstg) IStorage_Release(reo->pstg);
3873 if (reo->polesite) IOleClientSite_Release(reo->polesite);
3874 FREE_OBJ(reo);
3877 void ME_CopyReObject(REOBJECT* dst, const REOBJECT* src)
3879 *dst = *src;
3881 if (dst->poleobj) IOleObject_AddRef(dst->poleobj);
3882 if (dst->pstg) IStorage_AddRef(dst->pstg);
3883 if (dst->polesite) IOleClientSite_AddRef(dst->polesite);
3886 void ME_GetITextDocumentInterface(IRichEditOle *iface, LPVOID *ppvObj)
3888 IRichEditOleImpl *This = impl_from_IRichEditOle(iface);
3889 *ppvObj = &This->ITextDocument_iface;