riched20: Implement SetStart().
[wine.git] / dlls / riched20 / richole.c
blob1cb47c2c90b71488dec443ca6533a346f58d8193
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 cpLim)
953 ITextRangeImpl *This = impl_from_ITextRange(me);
954 if (!This->reOle)
955 return CO_E_RELEASED;
957 FIXME("not implemented %p\n", This);
958 return E_NOTIMPL;
961 static HRESULT WINAPI ITextRange_fnGetFont(ITextRange *me, ITextFont **font)
963 ITextRangeImpl *This = impl_from_ITextRange(me);
965 TRACE("(%p)->(%p)\n", This, font);
967 if (!This->reOle)
968 return CO_E_RELEASED;
970 if (!font)
971 return E_INVALIDARG;
973 return create_textfont(me, font);
976 static HRESULT WINAPI ITextRange_fnSetFont(ITextRange *me, ITextFont *pFont)
978 ITextRangeImpl *This = impl_from_ITextRange(me);
979 if (!This->reOle)
980 return CO_E_RELEASED;
982 FIXME("not implemented %p\n", This);
983 return E_NOTIMPL;
986 static HRESULT WINAPI ITextRange_fnGetPara(ITextRange *me, ITextPara **para)
988 ITextRangeImpl *This = impl_from_ITextRange(me);
990 TRACE("(%p)->(%p)\n", This, para);
992 if (!This->reOle)
993 return CO_E_RELEASED;
995 if (!para)
996 return E_INVALIDARG;
998 return create_textpara(me, para);
1001 static HRESULT WINAPI ITextRange_fnSetPara(ITextRange *me, ITextPara *pPara)
1003 ITextRangeImpl *This = impl_from_ITextRange(me);
1004 if (!This->reOle)
1005 return CO_E_RELEASED;
1007 FIXME("not implemented %p\n", This);
1008 return E_NOTIMPL;
1011 static HRESULT WINAPI ITextRange_fnGetStoryLength(ITextRange *me, LONG *pcch)
1013 ITextRangeImpl *This = impl_from_ITextRange(me);
1014 if (!This->reOle)
1015 return CO_E_RELEASED;
1017 FIXME("not implemented %p\n", This);
1018 return E_NOTIMPL;
1021 static HRESULT WINAPI ITextRange_fnGetStoryType(ITextRange *me, LONG *pValue)
1023 ITextRangeImpl *This = impl_from_ITextRange(me);
1024 if (!This->reOle)
1025 return CO_E_RELEASED;
1027 FIXME("not implemented %p\n", This);
1028 return E_NOTIMPL;
1031 static HRESULT range_Collapse(LONG bStart, LONG *start, LONG *end)
1033 if (*end == *start)
1034 return S_FALSE;
1036 if (bStart == tomEnd || bStart == tomFalse)
1037 *start = *end;
1038 else
1039 *end = *start;
1040 return S_OK;
1043 static HRESULT WINAPI ITextRange_fnCollapse(ITextRange *me, LONG bStart)
1045 ITextRangeImpl *This = impl_from_ITextRange(me);
1046 if (!This->reOle)
1047 return CO_E_RELEASED;
1049 return range_Collapse(bStart, &This->start, &This->end);
1052 static HRESULT WINAPI ITextRange_fnExpand(ITextRange *me, LONG Unit, LONG *pDelta)
1054 ITextRangeImpl *This = impl_from_ITextRange(me);
1055 if (!This->reOle)
1056 return CO_E_RELEASED;
1058 FIXME("not implemented %p\n", This);
1059 return E_NOTIMPL;
1062 static HRESULT WINAPI ITextRange_fnGetIndex(ITextRange *me, LONG Unit, LONG *pIndex)
1064 ITextRangeImpl *This = impl_from_ITextRange(me);
1065 if (!This->reOle)
1066 return CO_E_RELEASED;
1068 FIXME("not implemented %p\n", This);
1069 return E_NOTIMPL;
1072 static HRESULT WINAPI ITextRange_fnSetIndex(ITextRange *me, LONG Unit, LONG Index,
1073 LONG Extend)
1075 ITextRangeImpl *This = impl_from_ITextRange(me);
1076 if (!This->reOle)
1077 return CO_E_RELEASED;
1079 FIXME("not implemented %p\n", This);
1080 return E_NOTIMPL;
1083 static HRESULT WINAPI ITextRange_fnSetRange(ITextRange *me, LONG cpActive, LONG cpOther)
1085 ITextRangeImpl *This = impl_from_ITextRange(me);
1086 if (!This->reOle)
1087 return CO_E_RELEASED;
1089 FIXME("not implemented %p\n", This);
1090 return E_NOTIMPL;
1093 static HRESULT WINAPI ITextRange_fnInRange(ITextRange *me, ITextRange *pRange, LONG *pb)
1095 ITextRangeImpl *This = impl_from_ITextRange(me);
1096 if (!This->reOle)
1097 return CO_E_RELEASED;
1099 FIXME("not implemented %p\n", This);
1100 return E_NOTIMPL;
1103 static HRESULT WINAPI ITextRange_fnInStory(ITextRange *me, ITextRange *pRange, LONG *pb)
1105 ITextRangeImpl *This = impl_from_ITextRange(me);
1106 if (!This->reOle)
1107 return CO_E_RELEASED;
1109 FIXME("not implemented %p\n", This);
1110 return E_NOTIMPL;
1113 static HRESULT WINAPI ITextRange_fnIsEqual(ITextRange *me, ITextRange *pRange, LONG *pb)
1115 ITextRangeImpl *This = impl_from_ITextRange(me);
1116 if (!This->reOle)
1117 return CO_E_RELEASED;
1119 FIXME("not implemented %p\n", This);
1120 return E_NOTIMPL;
1123 static HRESULT WINAPI ITextRange_fnSelect(ITextRange *me)
1125 ITextRangeImpl *This = impl_from_ITextRange(me);
1126 if (!This->reOle)
1127 return CO_E_RELEASED;
1129 FIXME("not implemented %p\n", This);
1130 return E_NOTIMPL;
1133 static HRESULT WINAPI ITextRange_fnStartOf(ITextRange *me, LONG Unit, LONG Extend,
1134 LONG *pDelta)
1136 ITextRangeImpl *This = impl_from_ITextRange(me);
1137 if (!This->reOle)
1138 return CO_E_RELEASED;
1140 FIXME("not implemented %p\n", This);
1141 return E_NOTIMPL;
1144 static HRESULT WINAPI ITextRange_fnEndOf(ITextRange *me, LONG Unit, LONG Extend,
1145 LONG *pDelta)
1147 ITextRangeImpl *This = impl_from_ITextRange(me);
1148 if (!This->reOle)
1149 return CO_E_RELEASED;
1151 FIXME("not implemented %p\n", This);
1152 return E_NOTIMPL;
1155 static HRESULT WINAPI ITextRange_fnMove(ITextRange *me, LONG Unit, LONG Count, LONG *pDelta)
1157 ITextRangeImpl *This = impl_from_ITextRange(me);
1158 if (!This->reOle)
1159 return CO_E_RELEASED;
1161 FIXME("not implemented %p\n", This);
1162 return E_NOTIMPL;
1165 static HRESULT WINAPI ITextRange_fnMoveStart(ITextRange *me, LONG Unit, LONG Count,
1166 LONG *pDelta)
1168 ITextRangeImpl *This = impl_from_ITextRange(me);
1169 if (!This->reOle)
1170 return CO_E_RELEASED;
1172 FIXME("not implemented %p\n", This);
1173 return E_NOTIMPL;
1176 static HRESULT WINAPI ITextRange_fnMoveEnd(ITextRange *me, LONG Unit, LONG Count,
1177 LONG *pDelta)
1179 ITextRangeImpl *This = impl_from_ITextRange(me);
1180 if (!This->reOle)
1181 return CO_E_RELEASED;
1183 FIXME("not implemented %p\n", This);
1184 return E_NOTIMPL;
1187 static HRESULT WINAPI ITextRange_fnMoveWhile(ITextRange *me, VARIANT *Cset, LONG Count,
1188 LONG *pDelta)
1190 ITextRangeImpl *This = impl_from_ITextRange(me);
1191 if (!This->reOle)
1192 return CO_E_RELEASED;
1194 FIXME("not implemented %p\n", This);
1195 return E_NOTIMPL;
1198 static HRESULT WINAPI ITextRange_fnMoveStartWhile(ITextRange *me, VARIANT *Cset, LONG Count,
1199 LONG *pDelta)
1201 ITextRangeImpl *This = impl_from_ITextRange(me);
1202 if (!This->reOle)
1203 return CO_E_RELEASED;
1205 FIXME("not implemented %p\n", This);
1206 return E_NOTIMPL;
1209 static HRESULT WINAPI ITextRange_fnMoveEndWhile(ITextRange *me, VARIANT *Cset, LONG Count,
1210 LONG *pDelta)
1212 ITextRangeImpl *This = impl_from_ITextRange(me);
1213 if (!This->reOle)
1214 return CO_E_RELEASED;
1216 FIXME("not implemented %p\n", This);
1217 return E_NOTIMPL;
1220 static HRESULT WINAPI ITextRange_fnMoveUntil(ITextRange *me, VARIANT *Cset, LONG Count,
1221 LONG *pDelta)
1223 ITextRangeImpl *This = impl_from_ITextRange(me);
1224 if (!This->reOle)
1225 return CO_E_RELEASED;
1227 FIXME("not implemented %p\n", This);
1228 return E_NOTIMPL;
1231 static HRESULT WINAPI ITextRange_fnMoveStartUntil(ITextRange *me, VARIANT *Cset, LONG Count,
1232 LONG *pDelta)
1234 ITextRangeImpl *This = impl_from_ITextRange(me);
1235 if (!This->reOle)
1236 return CO_E_RELEASED;
1238 FIXME("not implemented %p\n", This);
1239 return E_NOTIMPL;
1242 static HRESULT WINAPI ITextRange_fnMoveEndUntil(ITextRange *me, VARIANT *Cset, LONG Count,
1243 LONG *pDelta)
1245 ITextRangeImpl *This = impl_from_ITextRange(me);
1246 if (!This->reOle)
1247 return CO_E_RELEASED;
1249 FIXME("not implemented %p\n", This);
1250 return E_NOTIMPL;
1253 static HRESULT WINAPI ITextRange_fnFindText(ITextRange *me, BSTR bstr, LONG cch, LONG Flags,
1254 LONG *pLength)
1256 ITextRangeImpl *This = impl_from_ITextRange(me);
1257 if (!This->reOle)
1258 return CO_E_RELEASED;
1260 FIXME("not implemented %p\n", This);
1261 return E_NOTIMPL;
1264 static HRESULT WINAPI ITextRange_fnFindTextStart(ITextRange *me, BSTR bstr, LONG cch,
1265 LONG Flags, LONG *pLength)
1267 ITextRangeImpl *This = impl_from_ITextRange(me);
1268 if (!This->reOle)
1269 return CO_E_RELEASED;
1271 FIXME("not implemented %p\n", This);
1272 return E_NOTIMPL;
1275 static HRESULT WINAPI ITextRange_fnFindTextEnd(ITextRange *me, BSTR bstr, LONG cch,
1276 LONG Flags, LONG *pLength)
1278 ITextRangeImpl *This = impl_from_ITextRange(me);
1279 if (!This->reOle)
1280 return CO_E_RELEASED;
1282 FIXME("not implemented %p\n", This);
1283 return E_NOTIMPL;
1286 static HRESULT WINAPI ITextRange_fnDelete(ITextRange *me, LONG Unit, LONG Count,
1287 LONG *pDelta)
1289 ITextRangeImpl *This = impl_from_ITextRange(me);
1290 if (!This->reOle)
1291 return CO_E_RELEASED;
1293 FIXME("not implemented %p\n", This);
1294 return E_NOTIMPL;
1297 static HRESULT WINAPI ITextRange_fnCut(ITextRange *me, VARIANT *pVar)
1299 ITextRangeImpl *This = impl_from_ITextRange(me);
1300 if (!This->reOle)
1301 return CO_E_RELEASED;
1303 FIXME("not implemented %p\n", This);
1304 return E_NOTIMPL;
1307 static HRESULT WINAPI ITextRange_fnCopy(ITextRange *me, VARIANT *pVar)
1309 ITextRangeImpl *This = impl_from_ITextRange(me);
1310 if (!This->reOle)
1311 return CO_E_RELEASED;
1313 FIXME("not implemented %p\n", This);
1314 return E_NOTIMPL;
1317 static HRESULT WINAPI ITextRange_fnPaste(ITextRange *me, VARIANT *pVar, LONG Format)
1319 ITextRangeImpl *This = impl_from_ITextRange(me);
1320 if (!This->reOle)
1321 return CO_E_RELEASED;
1323 FIXME("not implemented %p\n", This);
1324 return E_NOTIMPL;
1327 static HRESULT WINAPI ITextRange_fnCanPaste(ITextRange *me, VARIANT *pVar, LONG Format,
1328 LONG *pb)
1330 ITextRangeImpl *This = impl_from_ITextRange(me);
1331 if (!This->reOle)
1332 return CO_E_RELEASED;
1334 FIXME("not implemented %p\n", This);
1335 return E_NOTIMPL;
1338 static HRESULT WINAPI ITextRange_fnCanEdit(ITextRange *me, LONG *pb)
1340 ITextRangeImpl *This = impl_from_ITextRange(me);
1341 if (!This->reOle)
1342 return CO_E_RELEASED;
1344 FIXME("not implemented %p\n", This);
1345 return E_NOTIMPL;
1348 static HRESULT WINAPI ITextRange_fnChangeCase(ITextRange *me, LONG Type)
1350 ITextRangeImpl *This = impl_from_ITextRange(me);
1351 if (!This->reOle)
1352 return CO_E_RELEASED;
1354 FIXME("not implemented %p\n", This);
1355 return E_NOTIMPL;
1358 static HRESULT WINAPI ITextRange_fnGetPoint(ITextRange *me, LONG Type, LONG *cx, LONG *cy)
1360 ITextRangeImpl *This = impl_from_ITextRange(me);
1361 if (!This->reOle)
1362 return CO_E_RELEASED;
1364 FIXME("not implemented %p\n", This);
1365 return E_NOTIMPL;
1368 static HRESULT WINAPI ITextRange_fnSetPoint(ITextRange *me, LONG x, LONG y, LONG Type,
1369 LONG Extend)
1371 ITextRangeImpl *This = impl_from_ITextRange(me);
1372 if (!This->reOle)
1373 return CO_E_RELEASED;
1375 FIXME("not implemented %p\n", This);
1376 return E_NOTIMPL;
1379 static HRESULT WINAPI ITextRange_fnScrollIntoView(ITextRange *me, LONG Value)
1381 ITextRangeImpl *This = impl_from_ITextRange(me);
1382 if (!This->reOle)
1383 return CO_E_RELEASED;
1385 FIXME("not implemented %p\n", This);
1386 return E_NOTIMPL;
1389 static HRESULT WINAPI ITextRange_fnGetEmbeddedObject(ITextRange *me, IUnknown **ppv)
1391 ITextRangeImpl *This = impl_from_ITextRange(me);
1392 if (!This->reOle)
1393 return CO_E_RELEASED;
1395 FIXME("not implemented %p\n", This);
1396 return E_NOTIMPL;
1399 static const ITextRangeVtbl trvt = {
1400 ITextRange_fnQueryInterface,
1401 ITextRange_fnAddRef,
1402 ITextRange_fnRelease,
1403 ITextRange_fnGetTypeInfoCount,
1404 ITextRange_fnGetTypeInfo,
1405 ITextRange_fnGetIDsOfNames,
1406 ITextRange_fnInvoke,
1407 ITextRange_fnGetText,
1408 ITextRange_fnSetText,
1409 ITextRange_fnGetChar,
1410 ITextRange_fnSetChar,
1411 ITextRange_fnGetDuplicate,
1412 ITextRange_fnGetFormattedText,
1413 ITextRange_fnSetFormattedText,
1414 ITextRange_fnGetStart,
1415 ITextRange_fnSetStart,
1416 ITextRange_fnGetEnd,
1417 ITextRange_fnSetEnd,
1418 ITextRange_fnGetFont,
1419 ITextRange_fnSetFont,
1420 ITextRange_fnGetPara,
1421 ITextRange_fnSetPara,
1422 ITextRange_fnGetStoryLength,
1423 ITextRange_fnGetStoryType,
1424 ITextRange_fnCollapse,
1425 ITextRange_fnExpand,
1426 ITextRange_fnGetIndex,
1427 ITextRange_fnSetIndex,
1428 ITextRange_fnSetRange,
1429 ITextRange_fnInRange,
1430 ITextRange_fnInStory,
1431 ITextRange_fnIsEqual,
1432 ITextRange_fnSelect,
1433 ITextRange_fnStartOf,
1434 ITextRange_fnEndOf,
1435 ITextRange_fnMove,
1436 ITextRange_fnMoveStart,
1437 ITextRange_fnMoveEnd,
1438 ITextRange_fnMoveWhile,
1439 ITextRange_fnMoveStartWhile,
1440 ITextRange_fnMoveEndWhile,
1441 ITextRange_fnMoveUntil,
1442 ITextRange_fnMoveStartUntil,
1443 ITextRange_fnMoveEndUntil,
1444 ITextRange_fnFindText,
1445 ITextRange_fnFindTextStart,
1446 ITextRange_fnFindTextEnd,
1447 ITextRange_fnDelete,
1448 ITextRange_fnCut,
1449 ITextRange_fnCopy,
1450 ITextRange_fnPaste,
1451 ITextRange_fnCanPaste,
1452 ITextRange_fnCanEdit,
1453 ITextRange_fnChangeCase,
1454 ITextRange_fnGetPoint,
1455 ITextRange_fnSetPoint,
1456 ITextRange_fnScrollIntoView,
1457 ITextRange_fnGetEmbeddedObject
1460 /* ITextFont */
1461 static HRESULT WINAPI TextFont_QueryInterface(ITextFont *iface, REFIID riid, void **ppv)
1463 ITextFontImpl *This = impl_from_ITextFont(iface);
1465 TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
1467 if (IsEqualIID(riid, &IID_ITextFont) ||
1468 IsEqualIID(riid, &IID_IDispatch) ||
1469 IsEqualIID(riid, &IID_IUnknown))
1471 *ppv = iface;
1472 ITextFont_AddRef(iface);
1473 return S_OK;
1476 *ppv = NULL;
1477 return E_NOINTERFACE;
1480 static ULONG WINAPI TextFont_AddRef(ITextFont *iface)
1482 ITextFontImpl *This = impl_from_ITextFont(iface);
1483 ULONG ref = InterlockedIncrement(&This->ref);
1484 TRACE("(%p)->(%u)\n", This, ref);
1485 return ref;
1488 static ULONG WINAPI TextFont_Release(ITextFont *iface)
1490 ITextFontImpl *This = impl_from_ITextFont(iface);
1491 ULONG ref = InterlockedDecrement(&This->ref);
1493 TRACE("(%p)->(%u)\n", This, ref);
1495 if (!ref)
1497 ITextRange_Release(This->range);
1498 heap_free(This);
1501 return ref;
1504 static HRESULT WINAPI TextFont_GetTypeInfoCount(ITextFont *iface, UINT *pctinfo)
1506 FIXME("stub\n");
1507 *pctinfo = 0;
1508 return E_NOTIMPL;
1511 static HRESULT WINAPI TextFont_GetTypeInfo(ITextFont *iface, UINT iTInfo, LCID lcid,
1512 ITypeInfo **ppTInfo)
1514 FIXME("stub\n");
1515 return E_NOTIMPL;
1518 static HRESULT WINAPI TextFont_GetIDsOfNames(ITextFont *iface, REFIID riid,
1519 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
1521 FIXME("stub\n");
1522 return E_NOTIMPL;
1525 static HRESULT WINAPI TextFont_Invoke(
1526 ITextFont *iface,
1527 DISPID dispIdMember,
1528 REFIID riid,
1529 LCID lcid,
1530 WORD wFlags,
1531 DISPPARAMS *pDispParams,
1532 VARIANT *pVarResult,
1533 EXCEPINFO *pExcepInfo,
1534 UINT *puArgErr)
1536 FIXME("stub\n");
1537 return E_NOTIMPL;
1540 static HRESULT WINAPI TextFont_GetDuplicate(ITextFont *iface, ITextFont **ret)
1542 ITextFontImpl *This = impl_from_ITextFont(iface);
1543 FIXME("(%p)->(%p): stub\n", This, ret);
1544 return E_NOTIMPL;
1547 static HRESULT WINAPI TextFont_SetDuplicate(ITextFont *iface, ITextFont *pFont)
1549 ITextFontImpl *This = impl_from_ITextFont(iface);
1550 FIXME("(%p)->(%p): stub\n", This, pFont);
1551 return E_NOTIMPL;
1554 static HRESULT WINAPI TextFont_CanChange(ITextFont *iface, LONG *ret)
1556 ITextFontImpl *This = impl_from_ITextFont(iface);
1557 FIXME("(%p)->(%p): stub\n", This, ret);
1558 return E_NOTIMPL;
1561 static HRESULT WINAPI TextFont_IsEqual(ITextFont *iface, ITextFont *font, LONG *ret)
1563 ITextFontImpl *This = impl_from_ITextFont(iface);
1564 FIXME("(%p)->(%p): stub\n", This, ret);
1565 return E_NOTIMPL;
1568 static HRESULT WINAPI TextFont_Reset(ITextFont *iface, LONG value)
1570 ITextFontImpl *This = impl_from_ITextFont(iface);
1571 FIXME("(%p): stub\n", This);
1572 return E_NOTIMPL;
1575 static HRESULT WINAPI TextFont_GetStyle(ITextFont *iface, LONG *value)
1577 ITextFontImpl *This = impl_from_ITextFont(iface);
1578 FIXME("(%p)->(%p): stub\n", This, value);
1579 return E_NOTIMPL;
1582 static HRESULT WINAPI TextFont_SetStyle(ITextFont *iface, LONG value)
1584 ITextFontImpl *This = impl_from_ITextFont(iface);
1585 FIXME("(%p)->(%d): stub\n", This, value);
1586 return E_NOTIMPL;
1589 static HRESULT WINAPI TextFont_GetAllCaps(ITextFont *iface, LONG *value)
1591 ITextFontImpl *This = impl_from_ITextFont(iface);
1592 FIXME("(%p)->(%p): stub\n", This, value);
1593 return E_NOTIMPL;
1596 static HRESULT WINAPI TextFont_SetAllCaps(ITextFont *iface, LONG value)
1598 ITextFontImpl *This = impl_from_ITextFont(iface);
1599 FIXME("(%p)->(%d): stub\n", This, value);
1600 return E_NOTIMPL;
1603 static HRESULT WINAPI TextFont_GetAnimation(ITextFont *iface, LONG *value)
1605 ITextFontImpl *This = impl_from_ITextFont(iface);
1606 FIXME("(%p)->(%p): stub\n", This, value);
1607 return E_NOTIMPL;
1610 static HRESULT WINAPI TextFont_SetAnimation(ITextFont *iface, LONG value)
1612 ITextFontImpl *This = impl_from_ITextFont(iface);
1613 FIXME("(%p)->(%d): stub\n", This, value);
1614 return E_NOTIMPL;
1617 static HRESULT WINAPI TextFont_GetBackColor(ITextFont *iface, LONG *value)
1619 ITextFontImpl *This = impl_from_ITextFont(iface);
1620 FIXME("(%p)->(%p): stub\n", This, value);
1621 return E_NOTIMPL;
1624 static HRESULT WINAPI TextFont_SetBackColor(ITextFont *iface, LONG value)
1626 ITextFontImpl *This = impl_from_ITextFont(iface);
1627 FIXME("(%p)->(%d): stub\n", This, value);
1628 return E_NOTIMPL;
1631 static HRESULT WINAPI TextFont_GetBold(ITextFont *iface, LONG *value)
1633 ITextFontImpl *This = impl_from_ITextFont(iface);
1634 FIXME("(%p)->(%p): stub\n", This, value);
1635 return E_NOTIMPL;
1638 static HRESULT WINAPI TextFont_SetBold(ITextFont *iface, LONG value)
1640 ITextFontImpl *This = impl_from_ITextFont(iface);
1641 FIXME("(%p)->(%d): stub\n", This, value);
1642 return E_NOTIMPL;
1645 static HRESULT WINAPI TextFont_GetEmboss(ITextFont *iface, LONG *value)
1647 ITextFontImpl *This = impl_from_ITextFont(iface);
1648 FIXME("(%p)->(%p): stub\n", This, value);
1649 return E_NOTIMPL;
1652 static HRESULT WINAPI TextFont_SetEmboss(ITextFont *iface, LONG value)
1654 ITextFontImpl *This = impl_from_ITextFont(iface);
1655 FIXME("(%p)->(%d): stub\n", This, value);
1656 return E_NOTIMPL;
1659 static HRESULT WINAPI TextFont_GetForeColor(ITextFont *iface, LONG *value)
1661 ITextFontImpl *This = impl_from_ITextFont(iface);
1662 FIXME("(%p)->(%p): stub\n", This, value);
1663 return E_NOTIMPL;
1666 static HRESULT WINAPI TextFont_SetForeColor(ITextFont *iface, LONG value)
1668 ITextFontImpl *This = impl_from_ITextFont(iface);
1669 FIXME("(%p)->(%d): stub\n", This, value);
1670 return E_NOTIMPL;
1673 static HRESULT WINAPI TextFont_GetHidden(ITextFont *iface, LONG *value)
1675 ITextFontImpl *This = impl_from_ITextFont(iface);
1676 FIXME("(%p)->(%p): stub\n", This, value);
1677 return E_NOTIMPL;
1680 static HRESULT WINAPI TextFont_SetHidden(ITextFont *iface, LONG value)
1682 ITextFontImpl *This = impl_from_ITextFont(iface);
1683 FIXME("(%p)->(%d): stub\n", This, value);
1684 return E_NOTIMPL;
1687 static HRESULT WINAPI TextFont_GetEngrave(ITextFont *iface, LONG *value)
1689 ITextFontImpl *This = impl_from_ITextFont(iface);
1690 FIXME("(%p)->(%p): stub\n", This, value);
1691 return E_NOTIMPL;
1694 static HRESULT WINAPI TextFont_SetEngrave(ITextFont *iface, LONG value)
1696 ITextFontImpl *This = impl_from_ITextFont(iface);
1697 FIXME("(%p)->(%d): stub\n", This, value);
1698 return E_NOTIMPL;
1701 static HRESULT WINAPI TextFont_GetItalic(ITextFont *iface, LONG *value)
1703 ITextFontImpl *This = impl_from_ITextFont(iface);
1704 FIXME("(%p)->(%p): stub\n", This, value);
1705 return E_NOTIMPL;
1708 static HRESULT WINAPI TextFont_SetItalic(ITextFont *iface, LONG value)
1710 ITextFontImpl *This = impl_from_ITextFont(iface);
1711 FIXME("(%p)->(%d): stub\n", This, value);
1712 return E_NOTIMPL;
1715 static HRESULT WINAPI TextFont_GetKerning(ITextFont *iface, FLOAT *value)
1717 ITextFontImpl *This = impl_from_ITextFont(iface);
1718 FIXME("(%p)->(%p): stub\n", This, value);
1719 return E_NOTIMPL;
1722 static HRESULT WINAPI TextFont_SetKerning(ITextFont *iface, FLOAT value)
1724 ITextFontImpl *This = impl_from_ITextFont(iface);
1725 FIXME("(%p)->(%.2f): stub\n", This, value);
1726 return E_NOTIMPL;
1729 static HRESULT WINAPI TextFont_GetLanguageID(ITextFont *iface, LONG *value)
1731 ITextFontImpl *This = impl_from_ITextFont(iface);
1732 FIXME("(%p)->(%p): stub\n", This, value);
1733 return E_NOTIMPL;
1736 static HRESULT WINAPI TextFont_SetLanguageID(ITextFont *iface, LONG value)
1738 ITextFontImpl *This = impl_from_ITextFont(iface);
1739 FIXME("(%p)->(%d): stub\n", This, value);
1740 return E_NOTIMPL;
1743 static HRESULT WINAPI TextFont_GetName(ITextFont *iface, BSTR *value)
1745 ITextFontImpl *This = impl_from_ITextFont(iface);
1746 FIXME("(%p)->(%p): stub\n", This, value);
1747 return E_NOTIMPL;
1750 static HRESULT WINAPI TextFont_SetName(ITextFont *iface, BSTR value)
1752 ITextFontImpl *This = impl_from_ITextFont(iface);
1753 FIXME("(%p)->(%s): stub\n", This, debugstr_w(value));
1754 return E_NOTIMPL;
1757 static HRESULT WINAPI TextFont_GetOutline(ITextFont *iface, LONG *value)
1759 ITextFontImpl *This = impl_from_ITextFont(iface);
1760 FIXME("(%p)->(%p): stub\n", This, value);
1761 return E_NOTIMPL;
1764 static HRESULT WINAPI TextFont_SetOutline(ITextFont *iface, LONG value)
1766 ITextFontImpl *This = impl_from_ITextFont(iface);
1767 FIXME("(%p)->(%d): stub\n", This, value);
1768 return E_NOTIMPL;
1771 static HRESULT WINAPI TextFont_GetPosition(ITextFont *iface, FLOAT *value)
1773 ITextFontImpl *This = impl_from_ITextFont(iface);
1774 FIXME("(%p)->(%p): stub\n", This, value);
1775 return E_NOTIMPL;
1778 static HRESULT WINAPI TextFont_SetPosition(ITextFont *iface, FLOAT value)
1780 ITextFontImpl *This = impl_from_ITextFont(iface);
1781 FIXME("(%p)->(%.2f): stub\n", This, value);
1782 return E_NOTIMPL;
1785 static HRESULT WINAPI TextFont_GetProtected(ITextFont *iface, LONG *value)
1787 ITextFontImpl *This = impl_from_ITextFont(iface);
1788 FIXME("(%p)->(%p): stub\n", This, value);
1789 return E_NOTIMPL;
1792 static HRESULT WINAPI TextFont_SetProtected(ITextFont *iface, LONG value)
1794 ITextFontImpl *This = impl_from_ITextFont(iface);
1795 FIXME("(%p)->(%d): stub\n", This, value);
1796 return E_NOTIMPL;
1799 static HRESULT WINAPI TextFont_GetShadow(ITextFont *iface, LONG *value)
1801 ITextFontImpl *This = impl_from_ITextFont(iface);
1802 FIXME("(%p)->(%p): stub\n", This, value);
1803 return E_NOTIMPL;
1806 static HRESULT WINAPI TextFont_SetShadow(ITextFont *iface, LONG value)
1808 ITextFontImpl *This = impl_from_ITextFont(iface);
1809 FIXME("(%p)->(%d): stub\n", This, value);
1810 return E_NOTIMPL;
1813 static HRESULT WINAPI TextFont_GetSize(ITextFont *iface, FLOAT *value)
1815 ITextFontImpl *This = impl_from_ITextFont(iface);
1816 FIXME("(%p)->(%p): stub\n", This, value);
1817 return E_NOTIMPL;
1820 static HRESULT WINAPI TextFont_SetSize(ITextFont *iface, FLOAT value)
1822 ITextFontImpl *This = impl_from_ITextFont(iface);
1823 FIXME("(%p)->(%.2f): stub\n", This, value);
1824 return E_NOTIMPL;
1827 static HRESULT WINAPI TextFont_GetSmallCaps(ITextFont *iface, LONG *value)
1829 ITextFontImpl *This = impl_from_ITextFont(iface);
1830 FIXME("(%p)->(%p): stub\n", This, value);
1831 return E_NOTIMPL;
1834 static HRESULT WINAPI TextFont_SetSmallCaps(ITextFont *iface, LONG value)
1836 ITextFontImpl *This = impl_from_ITextFont(iface);
1837 FIXME("(%p)->(%d): stub\n", This, value);
1838 return E_NOTIMPL;
1841 static HRESULT WINAPI TextFont_GetSpacing(ITextFont *iface, FLOAT *value)
1843 ITextFontImpl *This = impl_from_ITextFont(iface);
1844 FIXME("(%p)->(%p): stub\n", This, value);
1845 return E_NOTIMPL;
1848 static HRESULT WINAPI TextFont_SetSpacing(ITextFont *iface, FLOAT value)
1850 ITextFontImpl *This = impl_from_ITextFont(iface);
1851 FIXME("(%p)->(%.2f): stub\n", This, value);
1852 return E_NOTIMPL;
1855 static HRESULT WINAPI TextFont_GetStrikeThrough(ITextFont *iface, LONG *value)
1857 ITextFontImpl *This = impl_from_ITextFont(iface);
1858 FIXME("(%p)->(%p): stub\n", This, value);
1859 return E_NOTIMPL;
1862 static HRESULT WINAPI TextFont_SetStrikeThrough(ITextFont *iface, LONG value)
1864 ITextFontImpl *This = impl_from_ITextFont(iface);
1865 FIXME("(%p)->(%d): stub\n", This, value);
1866 return E_NOTIMPL;
1869 static HRESULT WINAPI TextFont_GetSubscript(ITextFont *iface, LONG *value)
1871 ITextFontImpl *This = impl_from_ITextFont(iface);
1872 FIXME("(%p)->(%p): stub\n", This, value);
1873 return E_NOTIMPL;
1876 static HRESULT WINAPI TextFont_SetSubscript(ITextFont *iface, LONG value)
1878 ITextFontImpl *This = impl_from_ITextFont(iface);
1879 FIXME("(%p)->(%d): stub\n", This, value);
1880 return E_NOTIMPL;
1883 static HRESULT WINAPI TextFont_GetSuperscript(ITextFont *iface, LONG *value)
1885 ITextFontImpl *This = impl_from_ITextFont(iface);
1886 FIXME("(%p)->(%p): stub\n", This, value);
1887 return E_NOTIMPL;
1890 static HRESULT WINAPI TextFont_SetSuperscript(ITextFont *iface, LONG value)
1892 ITextFontImpl *This = impl_from_ITextFont(iface);
1893 FIXME("(%p)->(%d): stub\n", This, value);
1894 return E_NOTIMPL;
1897 static HRESULT WINAPI TextFont_GetUnderline(ITextFont *iface, LONG *value)
1899 ITextFontImpl *This = impl_from_ITextFont(iface);
1900 FIXME("(%p)->(%p): stub\n", This, value);
1901 return E_NOTIMPL;
1904 static HRESULT WINAPI TextFont_SetUnderline(ITextFont *iface, LONG value)
1906 ITextFontImpl *This = impl_from_ITextFont(iface);
1907 FIXME("(%p)->(%d): stub\n", This, value);
1908 return E_NOTIMPL;
1911 static HRESULT WINAPI TextFont_GetWeight(ITextFont *iface, LONG *value)
1913 ITextFontImpl *This = impl_from_ITextFont(iface);
1914 FIXME("(%p)->(%p): stub\n", This, value);
1915 return E_NOTIMPL;
1918 static HRESULT WINAPI TextFont_SetWeight(ITextFont *iface, LONG value)
1920 ITextFontImpl *This = impl_from_ITextFont(iface);
1921 FIXME("(%p)->(%d): stub\n", This, value);
1922 return E_NOTIMPL;
1925 static ITextFontVtbl textfontvtbl = {
1926 TextFont_QueryInterface,
1927 TextFont_AddRef,
1928 TextFont_Release,
1929 TextFont_GetTypeInfoCount,
1930 TextFont_GetTypeInfo,
1931 TextFont_GetIDsOfNames,
1932 TextFont_Invoke,
1933 TextFont_GetDuplicate,
1934 TextFont_SetDuplicate,
1935 TextFont_CanChange,
1936 TextFont_IsEqual,
1937 TextFont_Reset,
1938 TextFont_GetStyle,
1939 TextFont_SetStyle,
1940 TextFont_GetAllCaps,
1941 TextFont_SetAllCaps,
1942 TextFont_GetAnimation,
1943 TextFont_SetAnimation,
1944 TextFont_GetBackColor,
1945 TextFont_SetBackColor,
1946 TextFont_GetBold,
1947 TextFont_SetBold,
1948 TextFont_GetEmboss,
1949 TextFont_SetEmboss,
1950 TextFont_GetForeColor,
1951 TextFont_SetForeColor,
1952 TextFont_GetHidden,
1953 TextFont_SetHidden,
1954 TextFont_GetEngrave,
1955 TextFont_SetEngrave,
1956 TextFont_GetItalic,
1957 TextFont_SetItalic,
1958 TextFont_GetKerning,
1959 TextFont_SetKerning,
1960 TextFont_GetLanguageID,
1961 TextFont_SetLanguageID,
1962 TextFont_GetName,
1963 TextFont_SetName,
1964 TextFont_GetOutline,
1965 TextFont_SetOutline,
1966 TextFont_GetPosition,
1967 TextFont_SetPosition,
1968 TextFont_GetProtected,
1969 TextFont_SetProtected,
1970 TextFont_GetShadow,
1971 TextFont_SetShadow,
1972 TextFont_GetSize,
1973 TextFont_SetSize,
1974 TextFont_GetSmallCaps,
1975 TextFont_SetSmallCaps,
1976 TextFont_GetSpacing,
1977 TextFont_SetSpacing,
1978 TextFont_GetStrikeThrough,
1979 TextFont_SetStrikeThrough,
1980 TextFont_GetSubscript,
1981 TextFont_SetSubscript,
1982 TextFont_GetSuperscript,
1983 TextFont_SetSuperscript,
1984 TextFont_GetUnderline,
1985 TextFont_SetUnderline,
1986 TextFont_GetWeight,
1987 TextFont_SetWeight
1990 static HRESULT create_textfont(ITextRange *range, ITextFont **ret)
1992 ITextFontImpl *font;
1994 *ret = NULL;
1995 font = heap_alloc(sizeof(*font));
1996 if (!font)
1997 return E_OUTOFMEMORY;
1999 font->ITextFont_iface.lpVtbl = &textfontvtbl;
2000 font->ref = 1;
2001 font->range = range;
2002 ITextRange_AddRef(range);
2004 *ret = &font->ITextFont_iface;
2005 return S_OK;
2008 /* ITextPara */
2009 static HRESULT WINAPI TextPara_QueryInterface(ITextPara *iface, REFIID riid, void **ppv)
2011 ITextParaImpl *This = impl_from_ITextPara(iface);
2013 TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
2015 if (IsEqualIID(riid, &IID_ITextPara) ||
2016 IsEqualIID(riid, &IID_IDispatch) ||
2017 IsEqualIID(riid, &IID_IUnknown))
2019 *ppv = iface;
2020 ITextPara_AddRef(iface);
2021 return S_OK;
2024 *ppv = NULL;
2025 return E_NOINTERFACE;
2028 static ULONG WINAPI TextPara_AddRef(ITextPara *iface)
2030 ITextParaImpl *This = impl_from_ITextPara(iface);
2031 ULONG ref = InterlockedIncrement(&This->ref);
2032 TRACE("(%p)->(%u)\n", This, ref);
2033 return ref;
2036 static ULONG WINAPI TextPara_Release(ITextPara *iface)
2038 ITextParaImpl *This = impl_from_ITextPara(iface);
2039 ULONG ref = InterlockedDecrement(&This->ref);
2041 TRACE("(%p)->(%u)\n", This, ref);
2043 if (!ref)
2045 ITextRange_Release(This->range);
2046 heap_free(This);
2049 return ref;
2052 static HRESULT WINAPI TextPara_GetTypeInfoCount(ITextPara *iface, UINT *pctinfo)
2054 FIXME("stub\n");
2055 *pctinfo = 0;
2056 return E_NOTIMPL;
2059 static HRESULT WINAPI TextPara_GetTypeInfo(ITextPara *iface, UINT iTInfo, LCID lcid,
2060 ITypeInfo **ppTInfo)
2062 FIXME("stub\n");
2063 return E_NOTIMPL;
2066 static HRESULT WINAPI TextPara_GetIDsOfNames(ITextPara *iface, REFIID riid,
2067 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
2069 FIXME("stub\n");
2070 return E_NOTIMPL;
2073 static HRESULT WINAPI TextPara_Invoke(
2074 ITextPara *iface,
2075 DISPID dispIdMember,
2076 REFIID riid,
2077 LCID lcid,
2078 WORD wFlags,
2079 DISPPARAMS *pDispParams,
2080 VARIANT *pVarResult,
2081 EXCEPINFO *pExcepInfo,
2082 UINT *puArgErr)
2084 FIXME("stub\n");
2085 return E_NOTIMPL;
2088 static HRESULT WINAPI TextPara_GetDuplicate(ITextPara *iface, ITextPara **ret)
2090 ITextParaImpl *This = impl_from_ITextPara(iface);
2091 FIXME("(%p)->(%p)\n", This, ret);
2092 return E_NOTIMPL;
2095 static HRESULT WINAPI TextPara_SetDuplicate(ITextPara *iface, ITextPara *para)
2097 ITextParaImpl *This = impl_from_ITextPara(iface);
2098 FIXME("(%p)->(%p)\n", This, para);
2099 return E_NOTIMPL;
2102 static HRESULT WINAPI TextPara_CanChange(ITextPara *iface, LONG *ret)
2104 ITextParaImpl *This = impl_from_ITextPara(iface);
2105 FIXME("(%p)->(%p)\n", This, ret);
2106 return E_NOTIMPL;
2109 static HRESULT WINAPI TextPara_IsEqual(ITextPara *iface, ITextPara *para, LONG *ret)
2111 ITextParaImpl *This = impl_from_ITextPara(iface);
2112 FIXME("(%p)->(%p %p)\n", This, para, ret);
2113 return E_NOTIMPL;
2116 static HRESULT WINAPI TextPara_Reset(ITextPara *iface, LONG value)
2118 ITextParaImpl *This = impl_from_ITextPara(iface);
2119 FIXME("(%p)->(%d)\n", This, value);
2120 return E_NOTIMPL;
2123 static HRESULT WINAPI TextPara_GetStyle(ITextPara *iface, LONG *value)
2125 ITextParaImpl *This = impl_from_ITextPara(iface);
2126 FIXME("(%p)->(%p)\n", This, value);
2127 return E_NOTIMPL;
2130 static HRESULT WINAPI TextPara_SetStyle(ITextPara *iface, LONG value)
2132 ITextParaImpl *This = impl_from_ITextPara(iface);
2133 FIXME("(%p)->(%d)\n", This, value);
2134 return E_NOTIMPL;
2137 static HRESULT WINAPI TextPara_GetAlignment(ITextPara *iface, LONG *value)
2139 ITextParaImpl *This = impl_from_ITextPara(iface);
2140 FIXME("(%p)->(%p)\n", This, value);
2141 return E_NOTIMPL;
2144 static HRESULT WINAPI TextPara_SetAlignment(ITextPara *iface, LONG value)
2146 ITextParaImpl *This = impl_from_ITextPara(iface);
2147 FIXME("(%p)->(%d)\n", This, value);
2148 return E_NOTIMPL;
2151 static HRESULT WINAPI TextPara_GetHyphenation(ITextPara *iface, LONG *value)
2153 ITextParaImpl *This = impl_from_ITextPara(iface);
2154 FIXME("(%p)->(%p)\n", This, value);
2155 return E_NOTIMPL;
2158 static HRESULT WINAPI TextPara_SetHyphenation(ITextPara *iface, LONG value)
2160 ITextParaImpl *This = impl_from_ITextPara(iface);
2161 FIXME("(%p)->(%d)\n", This, value);
2162 return E_NOTIMPL;
2165 static HRESULT WINAPI TextPara_GetFirstLineIndent(ITextPara *iface, FLOAT *value)
2167 ITextParaImpl *This = impl_from_ITextPara(iface);
2168 FIXME("(%p)->(%p)\n", This, value);
2169 return E_NOTIMPL;
2172 static HRESULT WINAPI TextPara_GetKeepTogether(ITextPara *iface, LONG *value)
2174 ITextParaImpl *This = impl_from_ITextPara(iface);
2175 FIXME("(%p)->(%p)\n", This, value);
2176 return E_NOTIMPL;
2179 static HRESULT WINAPI TextPara_SetKeepTogether(ITextPara *iface, LONG value)
2181 ITextParaImpl *This = impl_from_ITextPara(iface);
2182 FIXME("(%p)->(%d)\n", This, value);
2183 return E_NOTIMPL;
2186 static HRESULT WINAPI TextPara_GetKeepWithNext(ITextPara *iface, LONG *value)
2188 ITextParaImpl *This = impl_from_ITextPara(iface);
2189 FIXME("(%p)->(%p)\n", This, value);
2190 return E_NOTIMPL;
2193 static HRESULT WINAPI TextPara_SetKeepWithNext(ITextPara *iface, LONG value)
2195 ITextParaImpl *This = impl_from_ITextPara(iface);
2196 FIXME("(%p)->(%d)\n", This, value);
2197 return E_NOTIMPL;
2200 static HRESULT WINAPI TextPara_GetLeftIndent(ITextPara *iface, FLOAT *value)
2202 ITextParaImpl *This = impl_from_ITextPara(iface);
2203 FIXME("(%p)->(%p)\n", This, value);
2204 return E_NOTIMPL;
2207 static HRESULT WINAPI TextPara_GetLineSpacing(ITextPara *iface, FLOAT *value)
2209 ITextParaImpl *This = impl_from_ITextPara(iface);
2210 FIXME("(%p)->(%p)\n", This, value);
2211 return E_NOTIMPL;
2214 static HRESULT WINAPI TextPara_GetLineSpacingRule(ITextPara *iface, LONG *value)
2216 ITextParaImpl *This = impl_from_ITextPara(iface);
2217 FIXME("(%p)->(%p)\n", This, value);
2218 return E_NOTIMPL;
2221 static HRESULT WINAPI TextPara_GetListAlignment(ITextPara *iface, LONG *value)
2223 ITextParaImpl *This = impl_from_ITextPara(iface);
2224 FIXME("(%p)->(%p)\n", This, value);
2225 return E_NOTIMPL;
2228 static HRESULT WINAPI TextPara_SetListAlignment(ITextPara *iface, LONG value)
2230 ITextParaImpl *This = impl_from_ITextPara(iface);
2231 FIXME("(%p)->(%d)\n", This, value);
2232 return E_NOTIMPL;
2235 static HRESULT WINAPI TextPara_GetListLevelIndex(ITextPara *iface, LONG *value)
2237 ITextParaImpl *This = impl_from_ITextPara(iface);
2238 FIXME("(%p)->(%p)\n", This, value);
2239 return E_NOTIMPL;
2242 static HRESULT WINAPI TextPara_SetListLevelIndex(ITextPara *iface, LONG value)
2244 ITextParaImpl *This = impl_from_ITextPara(iface);
2245 FIXME("(%p)->(%d)\n", This, value);
2246 return E_NOTIMPL;
2249 static HRESULT WINAPI TextPara_GetListStart(ITextPara *iface, LONG *value)
2251 ITextParaImpl *This = impl_from_ITextPara(iface);
2252 FIXME("(%p)->(%p)\n", This, value);
2253 return E_NOTIMPL;
2256 static HRESULT WINAPI TextPara_SetListStart(ITextPara *iface, LONG value)
2258 ITextParaImpl *This = impl_from_ITextPara(iface);
2259 FIXME("(%p)->(%d)\n", This, value);
2260 return E_NOTIMPL;
2263 static HRESULT WINAPI TextPara_GetListTab(ITextPara *iface, FLOAT *value)
2265 ITextParaImpl *This = impl_from_ITextPara(iface);
2266 FIXME("(%p)->(%p)\n", This, value);
2267 return E_NOTIMPL;
2270 static HRESULT WINAPI TextPara_SetListTab(ITextPara *iface, FLOAT value)
2272 ITextParaImpl *This = impl_from_ITextPara(iface);
2273 FIXME("(%p)->(%.2f)\n", This, value);
2274 return E_NOTIMPL;
2277 static HRESULT WINAPI TextPara_GetListType(ITextPara *iface, LONG *value)
2279 ITextParaImpl *This = impl_from_ITextPara(iface);
2280 FIXME("(%p)->(%p)\n", This, value);
2281 return E_NOTIMPL;
2284 static HRESULT WINAPI TextPara_SetListType(ITextPara *iface, LONG value)
2286 ITextParaImpl *This = impl_from_ITextPara(iface);
2287 FIXME("(%p)->(%d)\n", This, value);
2288 return E_NOTIMPL;
2291 static HRESULT WINAPI TextPara_GetNoLineNumber(ITextPara *iface, LONG *value)
2293 ITextParaImpl *This = impl_from_ITextPara(iface);
2294 FIXME("(%p)->(%p)\n", This, value);
2295 return E_NOTIMPL;
2298 static HRESULT WINAPI TextPara_SetNoLineNumber(ITextPara *iface, LONG value)
2300 ITextParaImpl *This = impl_from_ITextPara(iface);
2301 FIXME("(%p)->(%d)\n", This, value);
2302 return E_NOTIMPL;
2305 static HRESULT WINAPI TextPara_GetPageBreakBefore(ITextPara *iface, LONG *value)
2307 ITextParaImpl *This = impl_from_ITextPara(iface);
2308 FIXME("(%p)->(%p)\n", This, value);
2309 return E_NOTIMPL;
2312 static HRESULT WINAPI TextPara_SetPageBreakBefore(ITextPara *iface, LONG value)
2314 ITextParaImpl *This = impl_from_ITextPara(iface);
2315 FIXME("(%p)->(%d)\n", This, value);
2316 return E_NOTIMPL;
2319 static HRESULT WINAPI TextPara_GetRightIndent(ITextPara *iface, FLOAT *value)
2321 ITextParaImpl *This = impl_from_ITextPara(iface);
2322 FIXME("(%p)->(%p)\n", This, value);
2323 return E_NOTIMPL;
2326 static HRESULT WINAPI TextPara_SetRightIndent(ITextPara *iface, FLOAT value)
2328 ITextParaImpl *This = impl_from_ITextPara(iface);
2329 FIXME("(%p)->(%.2f)\n", This, value);
2330 return E_NOTIMPL;
2333 static HRESULT WINAPI TextPara_SetIndents(ITextPara *iface, FLOAT StartIndent, FLOAT LeftIndent, FLOAT RightIndent)
2335 ITextParaImpl *This = impl_from_ITextPara(iface);
2336 FIXME("(%p)->(%.2f %.2f %.2f)\n", This, StartIndent, LeftIndent, RightIndent);
2337 return E_NOTIMPL;
2340 static HRESULT WINAPI TextPara_SetLineSpacing(ITextPara *iface, LONG LineSpacingRule, FLOAT LineSpacing)
2342 ITextParaImpl *This = impl_from_ITextPara(iface);
2343 FIXME("(%p)->(%d %.2f)\n", This, LineSpacingRule, LineSpacing);
2344 return E_NOTIMPL;
2347 static HRESULT WINAPI TextPara_GetSpaceAfter(ITextPara *iface, FLOAT *value)
2349 ITextParaImpl *This = impl_from_ITextPara(iface);
2350 FIXME("(%p)->(%p)\n", This, value);
2351 return E_NOTIMPL;
2354 static HRESULT WINAPI TextPara_SetSpaceAfter(ITextPara *iface, FLOAT value)
2356 ITextParaImpl *This = impl_from_ITextPara(iface);
2357 FIXME("(%p)->(%.2f)\n", This, value);
2358 return E_NOTIMPL;
2361 static HRESULT WINAPI TextPara_GetSpaceBefore(ITextPara *iface, FLOAT *value)
2363 ITextParaImpl *This = impl_from_ITextPara(iface);
2364 FIXME("(%p)->(%p)\n", This, value);
2365 return E_NOTIMPL;
2368 static HRESULT WINAPI TextPara_SetSpaceBefore(ITextPara *iface, FLOAT value)
2370 ITextParaImpl *This = impl_from_ITextPara(iface);
2371 FIXME("(%p)->(%.2f)\n", This, value);
2372 return E_NOTIMPL;
2375 static HRESULT WINAPI TextPara_GetWidowControl(ITextPara *iface, LONG *value)
2377 ITextParaImpl *This = impl_from_ITextPara(iface);
2378 FIXME("(%p)->(%p)\n", This, value);
2379 return E_NOTIMPL;
2382 static HRESULT WINAPI TextPara_SetWidowControl(ITextPara *iface, LONG value)
2384 ITextParaImpl *This = impl_from_ITextPara(iface);
2385 FIXME("(%p)->(%d)\n", This, value);
2386 return E_NOTIMPL;
2389 static HRESULT WINAPI TextPara_GetTabCount(ITextPara *iface, LONG *value)
2391 ITextParaImpl *This = impl_from_ITextPara(iface);
2392 FIXME("(%p)->(%p)\n", This, value);
2393 return E_NOTIMPL;
2396 static HRESULT WINAPI TextPara_AddTab(ITextPara *iface, FLOAT tbPos, LONG tbAlign, LONG tbLeader)
2398 ITextParaImpl *This = impl_from_ITextPara(iface);
2399 FIXME("(%p)->(%.2f %d %d)\n", This, tbPos, tbAlign, tbLeader);
2400 return E_NOTIMPL;
2403 static HRESULT WINAPI TextPara_ClearAllTabs(ITextPara *iface)
2405 ITextParaImpl *This = impl_from_ITextPara(iface);
2406 FIXME("(%p)\n", This);
2407 return E_NOTIMPL;
2410 static HRESULT WINAPI TextPara_DeleteTab(ITextPara *iface, FLOAT pos)
2412 ITextParaImpl *This = impl_from_ITextPara(iface);
2413 FIXME("(%p)->(%.2f)\n", This, pos);
2414 return E_NOTIMPL;
2417 static HRESULT WINAPI TextPara_GetTab(ITextPara *iface, LONG iTab, FLOAT *ptbPos, LONG *ptbAlign, LONG *ptbLeader)
2419 ITextParaImpl *This = impl_from_ITextPara(iface);
2420 FIXME("(%p)->(%d %p %p %p)\n", This, iTab, ptbPos, ptbAlign, ptbLeader);
2421 return E_NOTIMPL;
2424 static ITextParaVtbl textparavtbl = {
2425 TextPara_QueryInterface,
2426 TextPara_AddRef,
2427 TextPara_Release,
2428 TextPara_GetTypeInfoCount,
2429 TextPara_GetTypeInfo,
2430 TextPara_GetIDsOfNames,
2431 TextPara_Invoke,
2432 TextPara_GetDuplicate,
2433 TextPara_SetDuplicate,
2434 TextPara_CanChange,
2435 TextPara_IsEqual,
2436 TextPara_Reset,
2437 TextPara_GetStyle,
2438 TextPara_SetStyle,
2439 TextPara_GetAlignment,
2440 TextPara_SetAlignment,
2441 TextPara_GetHyphenation,
2442 TextPara_SetHyphenation,
2443 TextPara_GetFirstLineIndent,
2444 TextPara_GetKeepTogether,
2445 TextPara_SetKeepTogether,
2446 TextPara_GetKeepWithNext,
2447 TextPara_SetKeepWithNext,
2448 TextPara_GetLeftIndent,
2449 TextPara_GetLineSpacing,
2450 TextPara_GetLineSpacingRule,
2451 TextPara_GetListAlignment,
2452 TextPara_SetListAlignment,
2453 TextPara_GetListLevelIndex,
2454 TextPara_SetListLevelIndex,
2455 TextPara_GetListStart,
2456 TextPara_SetListStart,
2457 TextPara_GetListTab,
2458 TextPara_SetListTab,
2459 TextPara_GetListType,
2460 TextPara_SetListType,
2461 TextPara_GetNoLineNumber,
2462 TextPara_SetNoLineNumber,
2463 TextPara_GetPageBreakBefore,
2464 TextPara_SetPageBreakBefore,
2465 TextPara_GetRightIndent,
2466 TextPara_SetRightIndent,
2467 TextPara_SetIndents,
2468 TextPara_SetLineSpacing,
2469 TextPara_GetSpaceAfter,
2470 TextPara_SetSpaceAfter,
2471 TextPara_GetSpaceBefore,
2472 TextPara_SetSpaceBefore,
2473 TextPara_GetWidowControl,
2474 TextPara_SetWidowControl,
2475 TextPara_GetTabCount,
2476 TextPara_AddTab,
2477 TextPara_ClearAllTabs,
2478 TextPara_DeleteTab,
2479 TextPara_GetTab
2482 static HRESULT create_textpara(ITextRange *range, ITextPara **ret)
2484 ITextParaImpl *para;
2486 *ret = NULL;
2487 para = heap_alloc(sizeof(*para));
2488 if (!para)
2489 return E_OUTOFMEMORY;
2491 para->ITextPara_iface.lpVtbl = &textparavtbl;
2492 para->ref = 1;
2493 para->range = range;
2494 ITextRange_AddRef(range);
2496 *ret = &para->ITextPara_iface;
2497 return S_OK;
2500 /* ITextDocument */
2501 static HRESULT WINAPI
2502 ITextDocument_fnQueryInterface(ITextDocument* me, REFIID riid,
2503 void** ppvObject)
2505 IRichEditOleImpl *This = impl_from_ITextDocument(me);
2506 return IRichEditOle_QueryInterface(&This->IRichEditOle_iface, riid, ppvObject);
2509 static ULONG WINAPI
2510 ITextDocument_fnAddRef(ITextDocument* me)
2512 IRichEditOleImpl *This = impl_from_ITextDocument(me);
2513 return IRichEditOle_AddRef(&This->IRichEditOle_iface);
2516 static ULONG WINAPI
2517 ITextDocument_fnRelease(ITextDocument* me)
2519 IRichEditOleImpl *This = impl_from_ITextDocument(me);
2520 return IRichEditOle_Release(&This->IRichEditOle_iface);
2523 static HRESULT WINAPI
2524 ITextDocument_fnGetTypeInfoCount(ITextDocument* me,
2525 UINT* pctinfo)
2527 IRichEditOleImpl *This = impl_from_ITextDocument(me);
2528 FIXME("stub %p\n",This);
2529 return E_NOTIMPL;
2532 static HRESULT WINAPI
2533 ITextDocument_fnGetTypeInfo(ITextDocument* me, UINT iTInfo, LCID lcid,
2534 ITypeInfo** ppTInfo)
2536 IRichEditOleImpl *This = impl_from_ITextDocument(me);
2537 FIXME("stub %p\n",This);
2538 return E_NOTIMPL;
2541 static HRESULT WINAPI
2542 ITextDocument_fnGetIDsOfNames(ITextDocument* me, REFIID riid,
2543 LPOLESTR* rgszNames, UINT cNames, LCID lcid, DISPID* rgDispId)
2545 IRichEditOleImpl *This = impl_from_ITextDocument(me);
2546 FIXME("stub %p\n",This);
2547 return E_NOTIMPL;
2550 static HRESULT WINAPI
2551 ITextDocument_fnInvoke(ITextDocument* me, DISPID dispIdMember,
2552 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS* pDispParams,
2553 VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr)
2555 IRichEditOleImpl *This = impl_from_ITextDocument(me);
2556 FIXME("stub %p\n",This);
2557 return E_NOTIMPL;
2560 static HRESULT WINAPI
2561 ITextDocument_fnGetName(ITextDocument* me, BSTR* pName)
2563 IRichEditOleImpl *This = impl_from_ITextDocument(me);
2564 FIXME("stub %p\n",This);
2565 return E_NOTIMPL;
2568 static HRESULT WINAPI
2569 ITextDocument_fnGetSelection(ITextDocument* me, ITextSelection** ppSel)
2571 IRichEditOleImpl *This = impl_from_ITextDocument(me);
2572 TRACE("(%p)\n", me);
2574 if(!ppSel)
2575 return E_INVALIDARG;
2576 *ppSel = &This->txtSel->ITextSelection_iface;
2577 ITextSelection_AddRef(*ppSel);
2578 return S_OK;
2581 static HRESULT WINAPI
2582 ITextDocument_fnGetStoryCount(ITextDocument* me, LONG* pCount)
2584 IRichEditOleImpl *This = impl_from_ITextDocument(me);
2585 FIXME("stub %p\n",This);
2586 return E_NOTIMPL;
2589 static HRESULT WINAPI
2590 ITextDocument_fnGetStoryRanges(ITextDocument* me,
2591 ITextStoryRanges** ppStories)
2593 IRichEditOleImpl *This = impl_from_ITextDocument(me);
2594 FIXME("stub %p\n",This);
2595 return E_NOTIMPL;
2598 static HRESULT WINAPI
2599 ITextDocument_fnGetSaved(ITextDocument* me, LONG* pValue)
2601 IRichEditOleImpl *This = impl_from_ITextDocument(me);
2602 FIXME("stub %p\n",This);
2603 return E_NOTIMPL;
2606 static HRESULT WINAPI
2607 ITextDocument_fnSetSaved(ITextDocument* me, LONG Value)
2609 IRichEditOleImpl *This = impl_from_ITextDocument(me);
2610 FIXME("stub %p\n",This);
2611 return E_NOTIMPL;
2614 static HRESULT WINAPI
2615 ITextDocument_fnGetDefaultTabStop(ITextDocument* me, float* pValue)
2617 IRichEditOleImpl *This = impl_from_ITextDocument(me);
2618 FIXME("stub %p\n",This);
2619 return E_NOTIMPL;
2622 static HRESULT WINAPI
2623 ITextDocument_fnSetDefaultTabStop(ITextDocument* me, float Value)
2625 IRichEditOleImpl *This = impl_from_ITextDocument(me);
2626 FIXME("stub %p\n",This);
2627 return E_NOTIMPL;
2630 static HRESULT WINAPI
2631 ITextDocument_fnNew(ITextDocument* me)
2633 IRichEditOleImpl *This = impl_from_ITextDocument(me);
2634 FIXME("stub %p\n",This);
2635 return E_NOTIMPL;
2638 static HRESULT WINAPI
2639 ITextDocument_fnOpen(ITextDocument* me, VARIANT* pVar, LONG Flags,
2640 LONG CodePage)
2642 IRichEditOleImpl *This = impl_from_ITextDocument(me);
2643 FIXME("stub %p\n",This);
2644 return E_NOTIMPL;
2647 static HRESULT WINAPI
2648 ITextDocument_fnSave(ITextDocument* me, VARIANT* pVar, LONG Flags,
2649 LONG CodePage)
2651 IRichEditOleImpl *This = impl_from_ITextDocument(me);
2652 FIXME("stub %p\n",This);
2653 return E_NOTIMPL;
2656 static HRESULT WINAPI
2657 ITextDocument_fnFreeze(ITextDocument* me, LONG* pCount)
2659 IRichEditOleImpl *This = impl_from_ITextDocument(me);
2660 FIXME("stub %p\n",This);
2661 return E_NOTIMPL;
2664 static HRESULT WINAPI
2665 ITextDocument_fnUnfreeze(ITextDocument* me, LONG* pCount)
2667 IRichEditOleImpl *This = impl_from_ITextDocument(me);
2668 FIXME("stub %p\n",This);
2669 return E_NOTIMPL;
2672 static HRESULT WINAPI
2673 ITextDocument_fnBeginEditCollection(ITextDocument* me)
2675 IRichEditOleImpl *This = impl_from_ITextDocument(me);
2676 FIXME("stub %p\n",This);
2677 return E_NOTIMPL;
2680 static HRESULT WINAPI
2681 ITextDocument_fnEndEditCollection(ITextDocument* me)
2683 IRichEditOleImpl *This = impl_from_ITextDocument(me);
2684 FIXME("stub %p\n",This);
2685 return E_NOTIMPL;
2688 static HRESULT WINAPI
2689 ITextDocument_fnUndo(ITextDocument* me, LONG Count, LONG* prop)
2691 IRichEditOleImpl *This = impl_from_ITextDocument(me);
2692 FIXME("stub %p\n",This);
2693 return E_NOTIMPL;
2696 static HRESULT WINAPI
2697 ITextDocument_fnRedo(ITextDocument* me, LONG Count, LONG* prop)
2699 IRichEditOleImpl *This = impl_from_ITextDocument(me);
2700 FIXME("stub %p\n",This);
2701 return E_NOTIMPL;
2704 static HRESULT CreateITextRange(IRichEditOleImpl *reOle, LONG start, LONG end, ITextRange** ppRange)
2706 ITextRangeImpl *txtRge = heap_alloc(sizeof(ITextRangeImpl));
2708 if (!txtRge)
2709 return E_OUTOFMEMORY;
2710 txtRge->ITextRange_iface.lpVtbl = &trvt;
2711 txtRge->ref = 1;
2712 txtRge->reOle = reOle;
2713 txtRge->start = start;
2714 txtRge->end = end;
2715 list_add_head(&reOle->rangelist, &txtRge->entry);
2716 *ppRange = &txtRge->ITextRange_iface;
2717 return S_OK;
2720 static HRESULT WINAPI
2721 ITextDocument_fnRange(ITextDocument* me, LONG cp1, LONG cp2,
2722 ITextRange** ppRange)
2724 IRichEditOleImpl *This = impl_from_ITextDocument(me);
2725 const int len = ME_GetTextLength(This->editor) + 1;
2727 TRACE("%p %p %d %d\n", This, ppRange, cp1, cp2);
2728 if (!ppRange)
2729 return E_INVALIDARG;
2731 cp1 = max(cp1, 0);
2732 cp2 = max(cp2, 0);
2733 cp1 = min(cp1, len);
2734 cp2 = min(cp2, len);
2735 if (cp1 > cp2)
2737 LONG tmp;
2738 tmp = cp1;
2739 cp1 = cp2;
2740 cp2 = tmp;
2742 if (cp1 == len)
2743 cp1 = cp2 = len - 1;
2745 return CreateITextRange(This, cp1, cp2, ppRange);
2748 static HRESULT WINAPI
2749 ITextDocument_fnRangeFromPoint(ITextDocument* me, LONG x, LONG y,
2750 ITextRange** ppRange)
2752 IRichEditOleImpl *This = impl_from_ITextDocument(me);
2753 FIXME("stub %p\n",This);
2754 return E_NOTIMPL;
2757 static const ITextDocumentVtbl tdvt = {
2758 ITextDocument_fnQueryInterface,
2759 ITextDocument_fnAddRef,
2760 ITextDocument_fnRelease,
2761 ITextDocument_fnGetTypeInfoCount,
2762 ITextDocument_fnGetTypeInfo,
2763 ITextDocument_fnGetIDsOfNames,
2764 ITextDocument_fnInvoke,
2765 ITextDocument_fnGetName,
2766 ITextDocument_fnGetSelection,
2767 ITextDocument_fnGetStoryCount,
2768 ITextDocument_fnGetStoryRanges,
2769 ITextDocument_fnGetSaved,
2770 ITextDocument_fnSetSaved,
2771 ITextDocument_fnGetDefaultTabStop,
2772 ITextDocument_fnSetDefaultTabStop,
2773 ITextDocument_fnNew,
2774 ITextDocument_fnOpen,
2775 ITextDocument_fnSave,
2776 ITextDocument_fnFreeze,
2777 ITextDocument_fnUnfreeze,
2778 ITextDocument_fnBeginEditCollection,
2779 ITextDocument_fnEndEditCollection,
2780 ITextDocument_fnUndo,
2781 ITextDocument_fnRedo,
2782 ITextDocument_fnRange,
2783 ITextDocument_fnRangeFromPoint
2786 /* ITextSelection */
2787 static HRESULT WINAPI ITextSelection_fnQueryInterface(
2788 ITextSelection *me,
2789 REFIID riid,
2790 void **ppvObj)
2792 *ppvObj = NULL;
2793 if (IsEqualGUID(riid, &IID_IUnknown)
2794 || IsEqualGUID(riid, &IID_IDispatch)
2795 || IsEqualGUID(riid, &IID_ITextRange)
2796 || IsEqualGUID(riid, &IID_ITextSelection))
2798 *ppvObj = me;
2799 ITextSelection_AddRef(me);
2800 return S_OK;
2803 return E_NOINTERFACE;
2806 static ULONG WINAPI ITextSelection_fnAddRef(ITextSelection *me)
2808 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2809 return InterlockedIncrement(&This->ref);
2812 static ULONG WINAPI ITextSelection_fnRelease(ITextSelection *me)
2814 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2815 ULONG ref = InterlockedDecrement(&This->ref);
2816 if (ref == 0)
2817 heap_free(This);
2818 return ref;
2821 static HRESULT WINAPI ITextSelection_fnGetTypeInfoCount(ITextSelection *me, UINT *pctinfo)
2823 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2824 if (!This->reOle)
2825 return CO_E_RELEASED;
2827 FIXME("not implemented\n");
2828 return E_NOTIMPL;
2831 static HRESULT WINAPI ITextSelection_fnGetTypeInfo(ITextSelection *me, UINT iTInfo, LCID lcid,
2832 ITypeInfo **ppTInfo)
2834 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2835 if (!This->reOle)
2836 return CO_E_RELEASED;
2838 FIXME("not implemented\n");
2839 return E_NOTIMPL;
2842 static HRESULT WINAPI ITextSelection_fnGetIDsOfNames(ITextSelection *me, REFIID riid,
2843 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
2845 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2846 if (!This->reOle)
2847 return CO_E_RELEASED;
2849 FIXME("not implemented\n");
2850 return E_NOTIMPL;
2853 static HRESULT WINAPI ITextSelection_fnInvoke(
2854 ITextSelection *me,
2855 DISPID dispIdMember,
2856 REFIID riid,
2857 LCID lcid,
2858 WORD wFlags,
2859 DISPPARAMS *pDispParams,
2860 VARIANT *pVarResult,
2861 EXCEPINFO *pExcepInfo,
2862 UINT *puArgErr)
2864 FIXME("not implemented\n");
2865 return E_NOTIMPL;
2868 /*** ITextRange methods ***/
2869 static HRESULT WINAPI ITextSelection_fnGetText(ITextSelection *me, BSTR *pbstr)
2871 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2872 ME_Cursor *start = NULL, *end = NULL;
2873 int nChars, endOfs;
2874 BOOL bEOP;
2876 if (!This->reOle)
2877 return CO_E_RELEASED;
2878 TRACE("%p\n", pbstr);
2879 if (!pbstr)
2880 return E_INVALIDARG;
2882 ME_GetSelection(This->reOle->editor, &start, &end);
2883 endOfs = ME_GetCursorOfs(end);
2884 nChars = endOfs - ME_GetCursorOfs(start);
2885 if (!nChars)
2887 *pbstr = NULL;
2888 return S_OK;
2891 *pbstr = SysAllocStringLen(NULL, nChars);
2892 if (!*pbstr)
2893 return E_OUTOFMEMORY;
2895 bEOP = (end->pRun->next->type == diTextEnd && endOfs > ME_GetTextLength(This->reOle->editor));
2896 ME_GetTextW(This->reOle->editor, *pbstr, nChars, start, nChars, FALSE, bEOP);
2897 TRACE("%s\n", wine_dbgstr_w(*pbstr));
2899 return S_OK;
2902 static HRESULT WINAPI ITextSelection_fnSetText(ITextSelection *me, BSTR bstr)
2904 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2905 if (!This->reOle)
2906 return CO_E_RELEASED;
2908 FIXME("not implemented\n");
2909 return E_NOTIMPL;
2912 static HRESULT WINAPI ITextSelection_fnGetChar(ITextSelection *me, LONG *pch)
2914 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2915 ME_Cursor *start = NULL, *end = NULL;
2917 if (!This->reOle)
2918 return CO_E_RELEASED;
2919 TRACE("%p\n", pch);
2920 if (!pch)
2921 return E_INVALIDARG;
2923 ME_GetSelection(This->reOle->editor, &start, &end);
2924 return range_GetChar(This->reOle->editor, start, pch);
2927 static HRESULT WINAPI ITextSelection_fnSetChar(ITextSelection *me, LONG ch)
2929 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2930 if (!This->reOle)
2931 return CO_E_RELEASED;
2933 FIXME("not implemented\n");
2934 return E_NOTIMPL;
2937 static HRESULT WINAPI ITextSelection_fnGetDuplicate(ITextSelection *me, ITextRange **ppRange)
2939 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2940 if (!This->reOle)
2941 return CO_E_RELEASED;
2943 FIXME("not implemented\n");
2944 return E_NOTIMPL;
2947 static HRESULT WINAPI ITextSelection_fnGetFormattedText(ITextSelection *me, ITextRange **ppRange)
2949 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2950 if (!This->reOle)
2951 return CO_E_RELEASED;
2953 FIXME("not implemented\n");
2954 return E_NOTIMPL;
2957 static HRESULT WINAPI ITextSelection_fnSetFormattedText(ITextSelection *me, ITextRange *pRange)
2959 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2960 if (!This->reOle)
2961 return CO_E_RELEASED;
2963 FIXME("not implemented\n");
2964 return E_NOTIMPL;
2967 static HRESULT WINAPI ITextSelection_fnGetStart(ITextSelection *me, LONG *pcpFirst)
2969 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2970 LONG lim;
2971 if (!This->reOle)
2972 return CO_E_RELEASED;
2974 if (!pcpFirst)
2975 return E_INVALIDARG;
2976 ME_GetSelectionOfs(This->reOle->editor, pcpFirst, &lim);
2977 TRACE("%d\n", *pcpFirst);
2978 return S_OK;
2981 static HRESULT WINAPI ITextSelection_fnSetStart(ITextSelection *me, LONG cpFirst)
2983 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2984 if (!This->reOle)
2985 return CO_E_RELEASED;
2987 FIXME("not implemented\n");
2988 return E_NOTIMPL;
2991 static HRESULT WINAPI ITextSelection_fnGetEnd(ITextSelection *me, LONG *pcpLim)
2993 ITextSelectionImpl *This = impl_from_ITextSelection(me);
2994 LONG first;
2995 if (!This->reOle)
2996 return CO_E_RELEASED;
2998 if (!pcpLim)
2999 return E_INVALIDARG;
3000 ME_GetSelectionOfs(This->reOle->editor, &first, pcpLim);
3001 TRACE("%d\n", *pcpLim);
3002 return S_OK;
3005 static HRESULT WINAPI ITextSelection_fnSetEnd(ITextSelection *me, LONG cpLim)
3007 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3008 if (!This->reOle)
3009 return CO_E_RELEASED;
3011 FIXME("not implemented\n");
3012 return E_NOTIMPL;
3015 static HRESULT WINAPI ITextSelection_fnGetFont(ITextSelection *me, ITextFont **pFont)
3017 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3018 if (!This->reOle)
3019 return CO_E_RELEASED;
3021 FIXME("not implemented\n");
3022 return E_NOTIMPL;
3025 static HRESULT WINAPI ITextSelection_fnSetFont(ITextSelection *me, ITextFont *pFont)
3027 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3028 if (!This->reOle)
3029 return CO_E_RELEASED;
3031 FIXME("not implemented\n");
3032 return E_NOTIMPL;
3035 static HRESULT WINAPI ITextSelection_fnGetPara(ITextSelection *me, ITextPara **para)
3037 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3038 if (!This->reOle)
3039 return CO_E_RELEASED;
3041 FIXME("not implemented\n");
3042 return E_NOTIMPL;
3045 static HRESULT WINAPI ITextSelection_fnSetPara(ITextSelection *me, ITextPara *pPara)
3047 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3048 if (!This->reOle)
3049 return CO_E_RELEASED;
3051 FIXME("not implemented\n");
3052 return E_NOTIMPL;
3055 static HRESULT WINAPI ITextSelection_fnGetStoryLength(ITextSelection *me, LONG *pcch)
3057 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3058 if (!This->reOle)
3059 return CO_E_RELEASED;
3061 FIXME("not implemented\n");
3062 return E_NOTIMPL;
3065 static HRESULT WINAPI ITextSelection_fnGetStoryType(ITextSelection *me, LONG *pValue)
3067 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3068 if (!This->reOle)
3069 return CO_E_RELEASED;
3071 FIXME("not implemented\n");
3072 return E_NOTIMPL;
3075 static HRESULT WINAPI ITextSelection_fnCollapse(ITextSelection *me, LONG bStart)
3077 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3078 LONG start, end;
3079 HRESULT hres;
3080 if (!This->reOle)
3081 return CO_E_RELEASED;
3083 ME_GetSelectionOfs(This->reOle->editor, &start, &end);
3084 hres = range_Collapse(bStart, &start, &end);
3085 if (SUCCEEDED(hres))
3086 ME_SetSelection(This->reOle->editor, start, end);
3087 return hres;
3090 static HRESULT WINAPI ITextSelection_fnExpand(ITextSelection *me, LONG Unit, LONG *pDelta)
3092 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3093 if (!This->reOle)
3094 return CO_E_RELEASED;
3096 FIXME("not implemented\n");
3097 return E_NOTIMPL;
3100 static HRESULT WINAPI ITextSelection_fnGetIndex(ITextSelection *me, LONG Unit, LONG *pIndex)
3102 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3103 if (!This->reOle)
3104 return CO_E_RELEASED;
3106 FIXME("not implemented\n");
3107 return E_NOTIMPL;
3110 static HRESULT WINAPI ITextSelection_fnSetIndex(ITextSelection *me, LONG Unit, LONG Index,
3111 LONG Extend)
3113 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3114 if (!This->reOle)
3115 return CO_E_RELEASED;
3117 FIXME("not implemented\n");
3118 return E_NOTIMPL;
3121 static HRESULT WINAPI ITextSelection_fnSetRange(ITextSelection *me, LONG cpActive, LONG cpOther)
3123 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3124 if (!This->reOle)
3125 return CO_E_RELEASED;
3127 FIXME("not implemented\n");
3128 return E_NOTIMPL;
3131 static HRESULT WINAPI ITextSelection_fnInRange(ITextSelection *me, ITextRange *pRange, LONG *pb)
3133 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3134 if (!This->reOle)
3135 return CO_E_RELEASED;
3137 FIXME("not implemented\n");
3138 return E_NOTIMPL;
3141 static HRESULT WINAPI ITextSelection_fnInStory(ITextSelection *me, ITextRange *pRange, LONG *pb)
3143 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3144 if (!This->reOle)
3145 return CO_E_RELEASED;
3147 FIXME("not implemented\n");
3148 return E_NOTIMPL;
3151 static HRESULT WINAPI ITextSelection_fnIsEqual(ITextSelection *me, ITextRange *pRange, LONG *pb)
3153 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3154 if (!This->reOle)
3155 return CO_E_RELEASED;
3157 FIXME("not implemented\n");
3158 return E_NOTIMPL;
3161 static HRESULT WINAPI ITextSelection_fnSelect(ITextSelection *me)
3163 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3164 if (!This->reOle)
3165 return CO_E_RELEASED;
3167 FIXME("not implemented\n");
3168 return E_NOTIMPL;
3171 static HRESULT WINAPI ITextSelection_fnStartOf(ITextSelection *me, LONG Unit, LONG Extend,
3172 LONG *pDelta)
3174 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3175 if (!This->reOle)
3176 return CO_E_RELEASED;
3178 FIXME("not implemented\n");
3179 return E_NOTIMPL;
3182 static HRESULT WINAPI ITextSelection_fnEndOf(ITextSelection *me, LONG Unit, LONG Extend,
3183 LONG *pDelta)
3185 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3186 if (!This->reOle)
3187 return CO_E_RELEASED;
3189 FIXME("not implemented\n");
3190 return E_NOTIMPL;
3193 static HRESULT WINAPI ITextSelection_fnMove(ITextSelection *me, LONG Unit, LONG Count, LONG *pDelta)
3195 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3196 if (!This->reOle)
3197 return CO_E_RELEASED;
3199 FIXME("not implemented\n");
3200 return E_NOTIMPL;
3203 static HRESULT WINAPI ITextSelection_fnMoveStart(ITextSelection *me, LONG Unit, LONG Count,
3204 LONG *pDelta)
3206 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3207 if (!This->reOle)
3208 return CO_E_RELEASED;
3210 FIXME("not implemented\n");
3211 return E_NOTIMPL;
3214 static HRESULT WINAPI ITextSelection_fnMoveEnd(ITextSelection *me, LONG Unit, LONG Count,
3215 LONG *pDelta)
3217 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3218 if (!This->reOle)
3219 return CO_E_RELEASED;
3221 FIXME("not implemented\n");
3222 return E_NOTIMPL;
3225 static HRESULT WINAPI ITextSelection_fnMoveWhile(ITextSelection *me, VARIANT *Cset, LONG Count,
3226 LONG *pDelta)
3228 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3229 if (!This->reOle)
3230 return CO_E_RELEASED;
3232 FIXME("not implemented\n");
3233 return E_NOTIMPL;
3236 static HRESULT WINAPI ITextSelection_fnMoveStartWhile(ITextSelection *me, VARIANT *Cset, LONG Count,
3237 LONG *pDelta)
3239 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3240 if (!This->reOle)
3241 return CO_E_RELEASED;
3243 FIXME("not implemented\n");
3244 return E_NOTIMPL;
3247 static HRESULT WINAPI ITextSelection_fnMoveEndWhile(ITextSelection *me, VARIANT *Cset, LONG Count,
3248 LONG *pDelta)
3250 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3251 if (!This->reOle)
3252 return CO_E_RELEASED;
3254 FIXME("not implemented\n");
3255 return E_NOTIMPL;
3258 static HRESULT WINAPI ITextSelection_fnMoveUntil(ITextSelection *me, VARIANT *Cset, LONG Count,
3259 LONG *pDelta)
3261 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3262 if (!This->reOle)
3263 return CO_E_RELEASED;
3265 FIXME("not implemented\n");
3266 return E_NOTIMPL;
3269 static HRESULT WINAPI ITextSelection_fnMoveStartUntil(ITextSelection *me, VARIANT *Cset, LONG Count,
3270 LONG *pDelta)
3272 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3273 if (!This->reOle)
3274 return CO_E_RELEASED;
3276 FIXME("not implemented\n");
3277 return E_NOTIMPL;
3280 static HRESULT WINAPI ITextSelection_fnMoveEndUntil(ITextSelection *me, VARIANT *Cset, LONG Count,
3281 LONG *pDelta)
3283 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3284 if (!This->reOle)
3285 return CO_E_RELEASED;
3287 FIXME("not implemented\n");
3288 return E_NOTIMPL;
3291 static HRESULT WINAPI ITextSelection_fnFindText(ITextSelection *me, BSTR bstr, LONG cch, LONG Flags,
3292 LONG *pLength)
3294 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3295 if (!This->reOle)
3296 return CO_E_RELEASED;
3298 FIXME("not implemented\n");
3299 return E_NOTIMPL;
3302 static HRESULT WINAPI ITextSelection_fnFindTextStart(ITextSelection *me, BSTR bstr, LONG cch,
3303 LONG Flags, LONG *pLength)
3305 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3306 if (!This->reOle)
3307 return CO_E_RELEASED;
3309 FIXME("not implemented\n");
3310 return E_NOTIMPL;
3313 static HRESULT WINAPI ITextSelection_fnFindTextEnd(ITextSelection *me, BSTR bstr, LONG cch,
3314 LONG Flags, LONG *pLength)
3316 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3317 if (!This->reOle)
3318 return CO_E_RELEASED;
3320 FIXME("not implemented\n");
3321 return E_NOTIMPL;
3324 static HRESULT WINAPI ITextSelection_fnDelete(ITextSelection *me, LONG Unit, LONG Count,
3325 LONG *pDelta)
3327 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3328 if (!This->reOle)
3329 return CO_E_RELEASED;
3331 FIXME("not implemented\n");
3332 return E_NOTIMPL;
3335 static HRESULT WINAPI ITextSelection_fnCut(ITextSelection *me, VARIANT *pVar)
3337 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3338 if (!This->reOle)
3339 return CO_E_RELEASED;
3341 FIXME("not implemented\n");
3342 return E_NOTIMPL;
3345 static HRESULT WINAPI ITextSelection_fnCopy(ITextSelection *me, VARIANT *pVar)
3347 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3348 if (!This->reOle)
3349 return CO_E_RELEASED;
3351 FIXME("not implemented\n");
3352 return E_NOTIMPL;
3355 static HRESULT WINAPI ITextSelection_fnPaste(ITextSelection *me, VARIANT *pVar, LONG Format)
3357 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3358 if (!This->reOle)
3359 return CO_E_RELEASED;
3361 FIXME("not implemented\n");
3362 return E_NOTIMPL;
3365 static HRESULT WINAPI ITextSelection_fnCanPaste(ITextSelection *me, VARIANT *pVar, LONG Format,
3366 LONG *pb)
3368 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3369 if (!This->reOle)
3370 return CO_E_RELEASED;
3372 FIXME("not implemented\n");
3373 return E_NOTIMPL;
3376 static HRESULT WINAPI ITextSelection_fnCanEdit(ITextSelection *me, LONG *pb)
3378 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3379 if (!This->reOle)
3380 return CO_E_RELEASED;
3382 FIXME("not implemented\n");
3383 return E_NOTIMPL;
3386 static HRESULT WINAPI ITextSelection_fnChangeCase(ITextSelection *me, LONG Type)
3388 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3389 if (!This->reOle)
3390 return CO_E_RELEASED;
3392 FIXME("not implemented\n");
3393 return E_NOTIMPL;
3396 static HRESULT WINAPI ITextSelection_fnGetPoint(ITextSelection *me, LONG Type, LONG *cx, LONG *cy)
3398 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3399 if (!This->reOle)
3400 return CO_E_RELEASED;
3402 FIXME("not implemented\n");
3403 return E_NOTIMPL;
3406 static HRESULT WINAPI ITextSelection_fnSetPoint(ITextSelection *me, LONG x, LONG y, LONG Type,
3407 LONG Extend)
3409 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3410 if (!This->reOle)
3411 return CO_E_RELEASED;
3413 FIXME("not implemented\n");
3414 return E_NOTIMPL;
3417 static HRESULT WINAPI ITextSelection_fnScrollIntoView(ITextSelection *me, LONG Value)
3419 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3420 if (!This->reOle)
3421 return CO_E_RELEASED;
3423 FIXME("not implemented\n");
3424 return E_NOTIMPL;
3427 static HRESULT WINAPI ITextSelection_fnGetEmbeddedObject(ITextSelection *me, IUnknown **ppv)
3429 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3430 if (!This->reOle)
3431 return CO_E_RELEASED;
3433 FIXME("not implemented\n");
3434 return E_NOTIMPL;
3437 /*** ITextSelection methods ***/
3438 static HRESULT WINAPI ITextSelection_fnGetFlags(ITextSelection *me, LONG *pFlags)
3440 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3441 if (!This->reOle)
3442 return CO_E_RELEASED;
3444 FIXME("not implemented\n");
3445 return E_NOTIMPL;
3448 static HRESULT WINAPI ITextSelection_fnSetFlags(ITextSelection *me, LONG Flags)
3450 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3451 if (!This->reOle)
3452 return CO_E_RELEASED;
3454 FIXME("not implemented\n");
3455 return E_NOTIMPL;
3458 static HRESULT WINAPI ITextSelection_fnGetType(ITextSelection *me, LONG *pType)
3460 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3461 if (!This->reOle)
3462 return CO_E_RELEASED;
3464 FIXME("not implemented\n");
3465 return E_NOTIMPL;
3468 static HRESULT WINAPI ITextSelection_fnMoveLeft(ITextSelection *me, LONG Unit, LONG Count,
3469 LONG Extend, LONG *pDelta)
3471 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3472 if (!This->reOle)
3473 return CO_E_RELEASED;
3475 FIXME("not implemented\n");
3476 return E_NOTIMPL;
3479 static HRESULT WINAPI ITextSelection_fnMoveRight(ITextSelection *me, LONG Unit, LONG Count,
3480 LONG Extend, LONG *pDelta)
3482 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3483 if (!This->reOle)
3484 return CO_E_RELEASED;
3486 FIXME("not implemented\n");
3487 return E_NOTIMPL;
3490 static HRESULT WINAPI ITextSelection_fnMoveUp(ITextSelection *me, LONG Unit, LONG Count,
3491 LONG Extend, LONG *pDelta)
3493 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3494 if (!This->reOle)
3495 return CO_E_RELEASED;
3497 FIXME("not implemented\n");
3498 return E_NOTIMPL;
3501 static HRESULT WINAPI ITextSelection_fnMoveDown(ITextSelection *me, LONG Unit, LONG Count,
3502 LONG Extend, LONG *pDelta)
3504 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3505 if (!This->reOle)
3506 return CO_E_RELEASED;
3508 FIXME("not implemented\n");
3509 return E_NOTIMPL;
3512 static HRESULT WINAPI ITextSelection_fnHomeKey(ITextSelection *me, LONG Unit, LONG Extend,
3513 LONG *pDelta)
3515 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3516 if (!This->reOle)
3517 return CO_E_RELEASED;
3519 FIXME("not implemented\n");
3520 return E_NOTIMPL;
3523 static HRESULT WINAPI ITextSelection_fnEndKey(ITextSelection *me, LONG Unit, LONG Extend,
3524 LONG *pDelta)
3526 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3527 if (!This->reOle)
3528 return CO_E_RELEASED;
3530 FIXME("not implemented\n");
3531 return E_NOTIMPL;
3534 static HRESULT WINAPI ITextSelection_fnTypeText(ITextSelection *me, BSTR bstr)
3536 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3537 if (!This->reOle)
3538 return CO_E_RELEASED;
3540 FIXME("not implemented\n");
3541 return E_NOTIMPL;
3544 static const ITextSelectionVtbl tsvt = {
3545 ITextSelection_fnQueryInterface,
3546 ITextSelection_fnAddRef,
3547 ITextSelection_fnRelease,
3548 ITextSelection_fnGetTypeInfoCount,
3549 ITextSelection_fnGetTypeInfo,
3550 ITextSelection_fnGetIDsOfNames,
3551 ITextSelection_fnInvoke,
3552 ITextSelection_fnGetText,
3553 ITextSelection_fnSetText,
3554 ITextSelection_fnGetChar,
3555 ITextSelection_fnSetChar,
3556 ITextSelection_fnGetDuplicate,
3557 ITextSelection_fnGetFormattedText,
3558 ITextSelection_fnSetFormattedText,
3559 ITextSelection_fnGetStart,
3560 ITextSelection_fnSetStart,
3561 ITextSelection_fnGetEnd,
3562 ITextSelection_fnSetEnd,
3563 ITextSelection_fnGetFont,
3564 ITextSelection_fnSetFont,
3565 ITextSelection_fnGetPara,
3566 ITextSelection_fnSetPara,
3567 ITextSelection_fnGetStoryLength,
3568 ITextSelection_fnGetStoryType,
3569 ITextSelection_fnCollapse,
3570 ITextSelection_fnExpand,
3571 ITextSelection_fnGetIndex,
3572 ITextSelection_fnSetIndex,
3573 ITextSelection_fnSetRange,
3574 ITextSelection_fnInRange,
3575 ITextSelection_fnInStory,
3576 ITextSelection_fnIsEqual,
3577 ITextSelection_fnSelect,
3578 ITextSelection_fnStartOf,
3579 ITextSelection_fnEndOf,
3580 ITextSelection_fnMove,
3581 ITextSelection_fnMoveStart,
3582 ITextSelection_fnMoveEnd,
3583 ITextSelection_fnMoveWhile,
3584 ITextSelection_fnMoveStartWhile,
3585 ITextSelection_fnMoveEndWhile,
3586 ITextSelection_fnMoveUntil,
3587 ITextSelection_fnMoveStartUntil,
3588 ITextSelection_fnMoveEndUntil,
3589 ITextSelection_fnFindText,
3590 ITextSelection_fnFindTextStart,
3591 ITextSelection_fnFindTextEnd,
3592 ITextSelection_fnDelete,
3593 ITextSelection_fnCut,
3594 ITextSelection_fnCopy,
3595 ITextSelection_fnPaste,
3596 ITextSelection_fnCanPaste,
3597 ITextSelection_fnCanEdit,
3598 ITextSelection_fnChangeCase,
3599 ITextSelection_fnGetPoint,
3600 ITextSelection_fnSetPoint,
3601 ITextSelection_fnScrollIntoView,
3602 ITextSelection_fnGetEmbeddedObject,
3603 ITextSelection_fnGetFlags,
3604 ITextSelection_fnSetFlags,
3605 ITextSelection_fnGetType,
3606 ITextSelection_fnMoveLeft,
3607 ITextSelection_fnMoveRight,
3608 ITextSelection_fnMoveUp,
3609 ITextSelection_fnMoveDown,
3610 ITextSelection_fnHomeKey,
3611 ITextSelection_fnEndKey,
3612 ITextSelection_fnTypeText
3615 static ITextSelectionImpl *
3616 CreateTextSelection(IRichEditOleImpl *reOle)
3618 ITextSelectionImpl *txtSel = heap_alloc(sizeof *txtSel);
3619 if (!txtSel)
3620 return NULL;
3622 txtSel->ITextSelection_iface.lpVtbl = &tsvt;
3623 txtSel->ref = 1;
3624 txtSel->reOle = reOle;
3625 return txtSel;
3628 LRESULT CreateIRichEditOle(IUnknown *outer_unk, ME_TextEditor *editor, LPVOID *ppvObj)
3630 IRichEditOleImpl *reo;
3632 reo = heap_alloc(sizeof(IRichEditOleImpl));
3633 if (!reo)
3634 return 0;
3636 reo->IUnknown_inner.lpVtbl = &reo_unk_vtbl;
3637 reo->IRichEditOle_iface.lpVtbl = &revt;
3638 reo->ITextDocument_iface.lpVtbl = &tdvt;
3639 reo->ref = 1;
3640 reo->editor = editor;
3641 reo->txtSel = CreateTextSelection(reo);
3642 if (!reo->txtSel)
3644 heap_free(reo);
3645 return 0;
3647 reo->clientSite = CreateOleClientSite(reo);
3648 if (!reo->clientSite)
3650 ITextSelection_Release(&reo->txtSel->ITextSelection_iface);
3651 heap_free(reo);
3652 return 0;
3654 TRACE("Created %p\n",reo);
3655 list_init(&reo->rangelist);
3656 if (outer_unk)
3657 reo->outer_unk = outer_unk;
3658 else
3659 reo->outer_unk = &reo->IUnknown_inner;
3660 *ppvObj = &reo->IRichEditOle_iface;
3662 return 1;
3665 static void convert_sizel(const ME_Context *c, const SIZEL* szl, SIZE* sz)
3667 /* sizel is in .01 millimeters, sz in pixels */
3668 sz->cx = MulDiv(szl->cx, c->dpi.cx, 2540);
3669 sz->cy = MulDiv(szl->cy, c->dpi.cy, 2540);
3672 /******************************************************************************
3673 * ME_GetOLEObjectSize
3675 * Sets run extent for OLE objects.
3677 void ME_GetOLEObjectSize(const ME_Context *c, ME_Run *run, SIZE *pSize)
3679 IDataObject* ido;
3680 FORMATETC fmt;
3681 STGMEDIUM stgm;
3682 DIBSECTION dibsect;
3683 ENHMETAHEADER emh;
3685 assert(run->nFlags & MERF_GRAPHICS);
3686 assert(run->ole_obj);
3688 if (run->ole_obj->sizel.cx != 0 || run->ole_obj->sizel.cy != 0)
3690 convert_sizel(c, &run->ole_obj->sizel, pSize);
3691 if (c->editor->nZoomNumerator != 0)
3693 pSize->cx = MulDiv(pSize->cx, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
3694 pSize->cy = MulDiv(pSize->cy, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
3696 return;
3699 if (IOleObject_QueryInterface(run->ole_obj->poleobj, &IID_IDataObject, (void**)&ido) != S_OK)
3701 FIXME("Query Interface IID_IDataObject failed!\n");
3702 pSize->cx = pSize->cy = 0;
3703 return;
3705 fmt.cfFormat = CF_BITMAP;
3706 fmt.ptd = NULL;
3707 fmt.dwAspect = DVASPECT_CONTENT;
3708 fmt.lindex = -1;
3709 fmt.tymed = TYMED_GDI;
3710 if (IDataObject_GetData(ido, &fmt, &stgm) != S_OK)
3712 fmt.cfFormat = CF_ENHMETAFILE;
3713 fmt.tymed = TYMED_ENHMF;
3714 if (IDataObject_GetData(ido, &fmt, &stgm) != S_OK)
3716 FIXME("unsupported format\n");
3717 pSize->cx = pSize->cy = 0;
3718 IDataObject_Release(ido);
3719 return;
3723 switch (stgm.tymed)
3725 case TYMED_GDI:
3726 GetObjectW(stgm.u.hBitmap, sizeof(dibsect), &dibsect);
3727 pSize->cx = dibsect.dsBm.bmWidth;
3728 pSize->cy = dibsect.dsBm.bmHeight;
3729 if (!stgm.pUnkForRelease) DeleteObject(stgm.u.hBitmap);
3730 break;
3731 case TYMED_ENHMF:
3732 GetEnhMetaFileHeader(stgm.u.hEnhMetaFile, sizeof(emh), &emh);
3733 pSize->cx = emh.rclBounds.right - emh.rclBounds.left;
3734 pSize->cy = emh.rclBounds.bottom - emh.rclBounds.top;
3735 if (!stgm.pUnkForRelease) DeleteEnhMetaFile(stgm.u.hEnhMetaFile);
3736 break;
3737 default:
3738 FIXME("Unsupported tymed %d\n", stgm.tymed);
3739 break;
3741 IDataObject_Release(ido);
3742 if (c->editor->nZoomNumerator != 0)
3744 pSize->cx = MulDiv(pSize->cx, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
3745 pSize->cy = MulDiv(pSize->cy, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
3749 void ME_DrawOLE(ME_Context *c, int x, int y, ME_Run *run,
3750 ME_Paragraph *para, BOOL selected)
3752 IDataObject* ido;
3753 FORMATETC fmt;
3754 STGMEDIUM stgm;
3755 DIBSECTION dibsect;
3756 ENHMETAHEADER emh;
3757 HDC hMemDC;
3758 SIZE sz;
3759 BOOL has_size;
3761 assert(run->nFlags & MERF_GRAPHICS);
3762 assert(run->ole_obj);
3763 if (IOleObject_QueryInterface(run->ole_obj->poleobj, &IID_IDataObject, (void**)&ido) != S_OK)
3765 FIXME("Couldn't get interface\n");
3766 return;
3768 has_size = run->ole_obj->sizel.cx != 0 || run->ole_obj->sizel.cy != 0;
3769 fmt.cfFormat = CF_BITMAP;
3770 fmt.ptd = NULL;
3771 fmt.dwAspect = DVASPECT_CONTENT;
3772 fmt.lindex = -1;
3773 fmt.tymed = TYMED_GDI;
3774 if (IDataObject_GetData(ido, &fmt, &stgm) != S_OK)
3776 fmt.cfFormat = CF_ENHMETAFILE;
3777 fmt.tymed = TYMED_ENHMF;
3778 if (IDataObject_GetData(ido, &fmt, &stgm) != S_OK)
3780 FIXME("Couldn't get storage medium\n");
3781 IDataObject_Release(ido);
3782 return;
3785 switch (stgm.tymed)
3787 case TYMED_GDI:
3788 GetObjectW(stgm.u.hBitmap, sizeof(dibsect), &dibsect);
3789 hMemDC = CreateCompatibleDC(c->hDC);
3790 SelectObject(hMemDC, stgm.u.hBitmap);
3791 if (has_size)
3793 convert_sizel(c, &run->ole_obj->sizel, &sz);
3794 } else {
3795 sz.cx = MulDiv(dibsect.dsBm.bmWidth, c->dpi.cx, 96);
3796 sz.cy = MulDiv(dibsect.dsBm.bmHeight, c->dpi.cy, 96);
3798 if (c->editor->nZoomNumerator != 0)
3800 sz.cx = MulDiv(sz.cx, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
3801 sz.cy = MulDiv(sz.cy, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
3803 if (sz.cx == dibsect.dsBm.bmWidth && sz.cy == dibsect.dsBm.bmHeight)
3805 BitBlt(c->hDC, x, y - sz.cy,
3806 dibsect.dsBm.bmWidth, dibsect.dsBm.bmHeight,
3807 hMemDC, 0, 0, SRCCOPY);
3808 } else {
3809 StretchBlt(c->hDC, x, y - sz.cy, sz.cx, sz.cy,
3810 hMemDC, 0, 0, dibsect.dsBm.bmWidth,
3811 dibsect.dsBm.bmHeight, SRCCOPY);
3813 DeleteDC(hMemDC);
3814 if (!stgm.pUnkForRelease) DeleteObject(stgm.u.hBitmap);
3815 break;
3816 case TYMED_ENHMF:
3817 GetEnhMetaFileHeader(stgm.u.hEnhMetaFile, sizeof(emh), &emh);
3818 if (has_size)
3820 convert_sizel(c, &run->ole_obj->sizel, &sz);
3821 } else {
3822 sz.cy = MulDiv(emh.rclBounds.bottom - emh.rclBounds.top, c->dpi.cx, 96);
3823 sz.cx = MulDiv(emh.rclBounds.right - emh.rclBounds.left, c->dpi.cy, 96);
3825 if (c->editor->nZoomNumerator != 0)
3827 sz.cx = MulDiv(sz.cx, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
3828 sz.cy = MulDiv(sz.cy, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
3832 RECT rc;
3834 rc.left = x;
3835 rc.top = y - sz.cy;
3836 rc.right = x + sz.cx;
3837 rc.bottom = y;
3838 PlayEnhMetaFile(c->hDC, stgm.u.hEnhMetaFile, &rc);
3840 if (!stgm.pUnkForRelease) DeleteEnhMetaFile(stgm.u.hEnhMetaFile);
3841 break;
3842 default:
3843 FIXME("Unsupported tymed %d\n", stgm.tymed);
3844 selected = FALSE;
3845 break;
3847 if (selected && !c->editor->bHideSelection)
3848 PatBlt(c->hDC, x, y - sz.cy, sz.cx, sz.cy, DSTINVERT);
3849 IDataObject_Release(ido);
3852 void ME_DeleteReObject(REOBJECT* reo)
3854 if (reo->poleobj) IOleObject_Release(reo->poleobj);
3855 if (reo->pstg) IStorage_Release(reo->pstg);
3856 if (reo->polesite) IOleClientSite_Release(reo->polesite);
3857 FREE_OBJ(reo);
3860 void ME_CopyReObject(REOBJECT* dst, const REOBJECT* src)
3862 *dst = *src;
3864 if (dst->poleobj) IOleObject_AddRef(dst->poleobj);
3865 if (dst->pstg) IStorage_AddRef(dst->pstg);
3866 if (dst->polesite) IOleClientSite_AddRef(dst->polesite);
3869 void ME_GetITextDocumentInterface(IRichEditOle *iface, LPVOID *ppvObj)
3871 IRichEditOleImpl *This = impl_from_IRichEditOle(iface);
3872 *ppvObj = &This->ITextDocument_iface;