riched20: Initial support for changing font properties.
[wine/multimedia.git] / dlls / riched20 / richole.c
blob063522bd9022fff7667412deb91ca07fc96f6583
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 "richedit.h"
35 #include "tom.h"
36 #include "wine/debug.h"
38 WINE_DEFAULT_DEBUG_CHANNEL(richedit);
40 /* there is no way to be consistent across different sets of headers - mingw, Wine, Win32 SDK*/
42 #include "initguid.h"
44 DEFINE_GUID(LIBID_tom, 0x8cc497c9, 0xa1df, 0x11ce, 0x80, 0x98, 0x00, 0xaa, 0x00, 0x47, 0xbe, 0x5d);
45 DEFINE_GUID(IID_ITextServices, 0x8d33f740, 0xcf58, 0x11ce, 0xa8, 0x9d, 0x00, 0xaa, 0x00, 0x6c, 0xad, 0xc5);
46 DEFINE_GUID(IID_ITextHost, 0x13e670f4,0x1a5a,0x11cf,0xab,0xeb,0x00,0xaa,0x00,0xb6,0x5e,0xa1);
47 DEFINE_GUID(IID_ITextHost2, 0x13e670f5,0x1a5a,0x11cf,0xab,0xeb,0x00,0xaa,0x00,0xb6,0x5e,0xa1);
48 DEFINE_GUID(IID_ITextDocument, 0x8cc497c0, 0xa1df, 0x11ce, 0x80, 0x98, 0x00, 0xaa, 0x00, 0x47, 0xbe, 0x5d);
49 DEFINE_GUID(IID_ITextRange, 0x8cc497c2, 0xa1df, 0x11ce, 0x80, 0x98, 0x00, 0xaa, 0x00, 0x47, 0xbe, 0x5d);
50 DEFINE_GUID(IID_ITextSelection, 0x8cc497c1, 0xa1df, 0x11ce, 0x80, 0x98, 0x00, 0xaa, 0x00, 0x47, 0xbe, 0x5d);
51 DEFINE_GUID(IID_ITextFont, 0x8cc497c3, 0xa1df, 0x11ce, 0x80, 0x98, 0x00, 0xaa, 0x00, 0x47, 0xbe, 0x5d);
52 DEFINE_GUID(IID_ITextPara, 0x8cc497c4, 0xa1df, 0x11ce, 0x80, 0x98, 0x00, 0xaa, 0x00, 0x47, 0xbe, 0x5d);
54 static ITypeLib *typelib;
56 enum tid_t {
57 NULL_tid,
58 ITextDocument_tid,
59 ITextRange_tid,
60 ITextSelection_tid,
61 ITextFont_tid,
62 ITextPara_tid,
63 LAST_tid
66 static const IID * const tid_ids[] =
68 &IID_NULL,
69 &IID_ITextDocument,
70 &IID_ITextRange,
71 &IID_ITextSelection,
72 &IID_ITextFont,
73 &IID_ITextPara,
75 static ITypeInfo *typeinfos[LAST_tid];
77 static HRESULT load_typelib(void)
79 ITypeLib *tl;
80 HRESULT hr;
82 hr = LoadRegTypeLib(&LIBID_tom, 1, 0, LOCALE_SYSTEM_DEFAULT, &tl);
83 if (FAILED(hr)) {
84 ERR("LoadRegTypeLib failed: %08x\n", hr);
85 return hr;
88 if (InterlockedCompareExchangePointer((void**)&typelib, tl, NULL))
89 ITypeLib_Release(tl);
90 return hr;
93 void release_typelib(void)
95 unsigned i;
97 if (!typelib)
98 return;
100 for (i = 0; i < sizeof(typeinfos)/sizeof(*typeinfos); i++)
101 if (typeinfos[i])
102 ITypeInfo_Release(typeinfos[i]);
104 ITypeLib_Release(typelib);
107 static HRESULT get_typeinfo(enum tid_t tid, ITypeInfo **typeinfo)
109 HRESULT hr;
111 if (!typelib)
112 hr = load_typelib();
113 if (!typelib)
114 return hr;
116 if (!typeinfos[tid])
118 ITypeInfo *ti;
120 hr = ITypeLib_GetTypeInfoOfGuid(typelib, tid_ids[tid], &ti);
121 if (FAILED(hr))
123 ERR("GetTypeInfoOfGuid(%s) failed: %08x\n", debugstr_guid(tid_ids[tid]), hr);
124 return hr;
127 if (InterlockedCompareExchangePointer((void**)(typeinfos+tid), ti, NULL))
128 ITypeInfo_Release(ti);
131 *typeinfo = typeinfos[tid];
132 return S_OK;
135 /* private IID used to get back IRichEditOleImpl pointer */
136 DEFINE_GUID(IID_Igetrichole, 0xe3ce5c7a, 0x8247, 0x4622, 0x81, 0xad, 0x11, 0x81, 0x02, 0xaa, 0x01, 0x30);
138 typedef struct ITextSelectionImpl ITextSelectionImpl;
139 typedef struct IOleClientSiteImpl IOleClientSiteImpl;
140 typedef struct ITextRangeImpl ITextRangeImpl;
142 enum textfont_prop_id {
143 FONT_ALLCAPS = 0,
144 FONT_ANIMATION,
145 FONT_BACKCOLOR,
146 FONT_BOLD,
147 FONT_EMBOSS,
148 FONT_FORECOLOR,
149 FONT_HIDDEN,
150 FONT_ENGRAVE,
151 FONT_ITALIC,
152 FONT_KERNING,
153 FONT_LANGID,
154 FONT_NAME,
155 FONT_OUTLINE,
156 FONT_POSITION,
157 FONT_PROTECTED,
158 FONT_SHADOW,
159 FONT_SIZE,
160 FONT_SMALLCAPS,
161 FONT_SPACING,
162 FONT_STRIKETHROUGH,
163 FONT_SUBSCRIPT,
164 FONT_SUPERSCRIPT,
165 FONT_UNDERLINE,
166 FONT_WEIGHT,
167 FONT_PROPID_LAST,
168 FONT_PROPID_FIRST = FONT_ALLCAPS
171 static const DWORD textfont_prop_masks[] = {
172 CFM_ALLCAPS,
173 CFM_ANIMATION,
174 CFM_BACKCOLOR,
175 CFM_BOLD,
176 CFM_EMBOSS,
177 CFM_COLOR,
178 CFM_HIDDEN,
179 CFM_IMPRINT,
180 CFM_ITALIC,
181 CFM_KERNING,
182 CFM_LCID,
183 CFM_FACE,
184 CFM_OUTLINE,
185 CFM_OFFSET,
186 CFM_PROTECTED,
187 CFM_SHADOW,
188 CFM_SIZE,
189 CFM_SMALLCAPS,
190 CFM_SPACING,
191 CFM_STRIKEOUT,
192 CFM_SUBSCRIPT,
193 CFM_SUPERSCRIPT,
194 CFM_UNDERLINE,
195 CFM_WEIGHT
198 typedef union {
199 FLOAT f;
200 LONG l;
201 BSTR str;
202 } textfont_prop_val;
204 typedef struct IRichEditOleImpl {
205 IUnknown IUnknown_inner;
206 IRichEditOle IRichEditOle_iface;
207 ITextDocument ITextDocument_iface;
208 IUnknown *outer_unk;
209 LONG ref;
211 ME_TextEditor *editor;
212 ITextSelectionImpl *txtSel;
213 IOleClientSiteImpl *clientSite;
214 struct list rangelist;
215 } IRichEditOleImpl;
217 struct ITextRangeImpl {
218 ITextRange ITextRange_iface;
219 LONG ref;
220 LONG start, end;
221 struct list entry;
223 IRichEditOleImpl *reOle;
226 struct ITextSelectionImpl {
227 ITextSelection ITextSelection_iface;
228 LONG ref;
230 IRichEditOleImpl *reOle;
233 typedef struct ITextFontImpl {
234 ITextFont ITextFont_iface;
235 LONG ref;
237 ITextRange *range;
238 textfont_prop_val props[FONT_PROPID_LAST];
239 BOOL get_cache_enabled;
240 BOOL set_cache_enabled;
241 } ITextFontImpl;
243 typedef struct ITextParaImpl {
244 ITextPara ITextPara_iface;
245 LONG ref;
247 ITextRange *range;
248 } ITextParaImpl;
250 struct IOleClientSiteImpl {
251 IOleClientSite IOleClientSite_iface;
252 IOleWindow IOleWindow_iface;
253 IOleInPlaceSite IOleInPlaceSite_iface;
254 LONG ref;
256 IRichEditOleImpl *reOle;
259 static inline IRichEditOleImpl *impl_from_IRichEditOle(IRichEditOle *iface)
261 return CONTAINING_RECORD(iface, IRichEditOleImpl, IRichEditOle_iface);
264 static inline IRichEditOleImpl *impl_from_ITextDocument(ITextDocument *iface)
266 return CONTAINING_RECORD(iface, IRichEditOleImpl, ITextDocument_iface);
269 static inline IRichEditOleImpl *impl_from_IUnknown(IUnknown *iface)
271 return CONTAINING_RECORD(iface, IRichEditOleImpl, IUnknown_inner);
274 static inline IOleClientSiteImpl *impl_from_IOleWindow(IOleWindow *iface)
276 return CONTAINING_RECORD(iface, IOleClientSiteImpl, IOleWindow_iface);
279 static inline IOleClientSiteImpl *impl_from_IOleInPlaceSite(IOleInPlaceSite *iface)
281 return CONTAINING_RECORD(iface, IOleClientSiteImpl, IOleInPlaceSite_iface);
284 static inline ITextRangeImpl *impl_from_ITextRange(ITextRange *iface)
286 return CONTAINING_RECORD(iface, ITextRangeImpl, ITextRange_iface);
289 static inline ITextSelectionImpl *impl_from_ITextSelection(ITextSelection *iface)
291 return CONTAINING_RECORD(iface, ITextSelectionImpl, ITextSelection_iface);
294 static inline ITextFontImpl *impl_from_ITextFont(ITextFont *iface)
296 return CONTAINING_RECORD(iface, ITextFontImpl, ITextFont_iface);
299 static inline ITextParaImpl *impl_from_ITextPara(ITextPara *iface)
301 return CONTAINING_RECORD(iface, ITextParaImpl, ITextPara_iface);
304 static HRESULT create_textfont(ITextRange*, const ITextFontImpl*, ITextFont**);
305 static HRESULT create_textpara(ITextRange*, ITextPara**);
307 static inline BOOL is_equal_textfont_prop_value(enum textfont_prop_id propid, textfont_prop_val *left,
308 textfont_prop_val *right)
310 switch (propid)
312 case FONT_ALLCAPS:
313 case FONT_ANIMATION:
314 case FONT_BACKCOLOR:
315 case FONT_BOLD:
316 case FONT_EMBOSS:
317 case FONT_FORECOLOR:
318 case FONT_HIDDEN:
319 case FONT_ENGRAVE:
320 case FONT_ITALIC:
321 case FONT_KERNING:
322 case FONT_LANGID:
323 case FONT_OUTLINE:
324 case FONT_PROTECTED:
325 case FONT_SHADOW:
326 case FONT_SMALLCAPS:
327 case FONT_STRIKETHROUGH:
328 case FONT_SUBSCRIPT:
329 case FONT_SUPERSCRIPT:
330 case FONT_UNDERLINE:
331 case FONT_WEIGHT:
332 return left->l == right->l;
333 case FONT_NAME:
334 return !strcmpW(left->str, right->str);
335 case FONT_POSITION:
336 case FONT_SIZE:
337 case FONT_SPACING:
338 return left->f == right->f;
339 default:
340 FIXME("unhandled font property %d\n", propid);
341 return FALSE;
345 static inline void init_textfont_prop_value(enum textfont_prop_id propid, textfont_prop_val *v)
347 switch (propid)
349 case FONT_ALLCAPS:
350 case FONT_ANIMATION:
351 case FONT_BACKCOLOR:
352 case FONT_BOLD:
353 case FONT_EMBOSS:
354 case FONT_FORECOLOR:
355 case FONT_HIDDEN:
356 case FONT_ENGRAVE:
357 case FONT_ITALIC:
358 case FONT_KERNING:
359 case FONT_LANGID:
360 case FONT_OUTLINE:
361 case FONT_PROTECTED:
362 case FONT_SHADOW:
363 case FONT_SMALLCAPS:
364 case FONT_STRIKETHROUGH:
365 case FONT_SUBSCRIPT:
366 case FONT_SUPERSCRIPT:
367 case FONT_UNDERLINE:
368 case FONT_WEIGHT:
369 v->l = tomUndefined;
370 return;
371 case FONT_NAME:
372 v->str = NULL;
373 return;
374 case FONT_POSITION:
375 case FONT_SIZE:
376 case FONT_SPACING:
377 v->f = tomUndefined;
378 return;
379 default:
380 FIXME("unhandled font property %d\n", propid);
381 v->l = tomUndefined;
382 return;
386 static HRESULT get_textfont_prop_for_pos(const IRichEditOleImpl *reole, int pos, enum textfont_prop_id propid,
387 textfont_prop_val *value)
389 ME_Cursor from, to;
390 CHARFORMAT2W fmt;
392 memset(&fmt, 0, sizeof(fmt));
393 fmt.cbSize = sizeof(fmt);
394 fmt.dwMask = textfont_prop_masks[propid];
396 ME_CursorFromCharOfs(reole->editor, pos, &from);
397 to = from;
398 ME_MoveCursorChars(reole->editor, &to, 1);
399 ME_GetCharFormat(reole->editor, &from, &to, &fmt);
401 switch (propid)
403 case FONT_ALLCAPS:
404 value->l = fmt.dwEffects & CFE_ALLCAPS ? tomTrue : tomFalse;
405 break;
406 case FONT_ANIMATION:
407 value->l = fmt.bAnimation;
408 break;
409 case FONT_BACKCOLOR:
410 value->l = fmt.dwEffects & CFE_AUTOBACKCOLOR ? GetSysColor(COLOR_WINDOW) : fmt.crBackColor;
411 break;
412 case FONT_BOLD:
413 value->l = fmt.dwEffects & CFE_BOLD ? tomTrue : tomFalse;
414 break;
415 case FONT_EMBOSS:
416 value->l = fmt.dwEffects & CFE_EMBOSS ? tomTrue : tomFalse;
417 break;
418 case FONT_FORECOLOR:
419 value->l = fmt.dwEffects & CFE_AUTOCOLOR ? GetSysColor(COLOR_WINDOWTEXT) : fmt.crTextColor;
420 break;
421 case FONT_HIDDEN:
422 value->l = fmt.dwEffects & CFE_HIDDEN ? tomTrue : tomFalse;
423 break;
424 case FONT_ENGRAVE:
425 value->l = fmt.dwEffects & CFE_IMPRINT ? tomTrue : tomFalse;
426 break;
427 case FONT_ITALIC:
428 value->l = fmt.dwEffects & CFE_ITALIC ? tomTrue : tomFalse;
429 break;
430 case FONT_KERNING:
431 value->f = fmt.wKerning;
432 break;
433 case FONT_LANGID:
434 value->l = fmt.lcid;
435 break;
436 case FONT_NAME:
437 /* this case is used exclusively by GetName() */
438 value->str = SysAllocString(fmt.szFaceName);
439 if (!value->str)
440 return E_OUTOFMEMORY;
441 break;
442 case FONT_OUTLINE:
443 value->l = fmt.dwEffects & CFE_OUTLINE ? tomTrue : tomFalse;
444 break;
445 case FONT_POSITION:
446 value->f = fmt.yOffset;
447 break;
448 case FONT_PROTECTED:
449 value->l = fmt.dwEffects & CFE_PROTECTED ? tomTrue : tomFalse;
450 break;
451 case FONT_SHADOW:
452 value->l = fmt.dwEffects & CFE_SHADOW ? tomTrue : tomFalse;
453 break;
454 case FONT_SIZE:
455 value->f = fmt.yHeight;
456 break;
457 case FONT_SMALLCAPS:
458 value->l = fmt.dwEffects & CFE_SMALLCAPS ? tomTrue : tomFalse;
459 break;
460 case FONT_SPACING:
461 value->f = fmt.sSpacing;
462 break;
463 case FONT_STRIKETHROUGH:
464 value->l = fmt.dwEffects & CFE_STRIKEOUT ? tomTrue : tomFalse;
465 break;
466 case FONT_SUBSCRIPT:
467 value->l = fmt.dwEffects & CFE_SUBSCRIPT ? tomTrue : tomFalse;
468 break;
469 case FONT_SUPERSCRIPT:
470 value->l = fmt.dwEffects & CFE_SUPERSCRIPT ? tomTrue : tomFalse;
471 break;
472 case FONT_UNDERLINE:
473 value->l = fmt.dwEffects & CFE_UNDERLINE ? tomTrue : tomFalse;
474 break;
475 case FONT_WEIGHT:
476 value->l = fmt.wWeight;
477 break;
478 default:
479 FIXME("unhandled font property %d\n", propid);
480 return E_FAIL;
483 return S_OK;
486 static inline const IRichEditOleImpl *get_range_reole(ITextRange *range)
488 IRichEditOleImpl *reole = NULL;
489 ITextRange_QueryInterface(range, &IID_Igetrichole, (void**)&reole);
490 return reole;
493 static HRESULT get_textfont_prop(const ITextFontImpl *font, enum textfont_prop_id propid, textfont_prop_val *value)
495 const IRichEditOleImpl *reole;
496 textfont_prop_val v;
497 LONG start, end, i;
498 HRESULT hr;
500 /* when font is not attached to any range use cached values */
501 if (!font->range || font->get_cache_enabled) {
502 *value = font->props[propid];
503 return S_OK;
506 if (!(reole = get_range_reole(font->range)))
507 return CO_E_RELEASED;
509 init_textfont_prop_value(propid, value);
511 ITextRange_GetStart(font->range, &start);
512 ITextRange_GetEnd(font->range, &end);
514 /* iterate trough a range to see if property value is consistent */
515 hr = get_textfont_prop_for_pos(reole, start, propid, &v);
516 if (FAILED(hr))
517 return hr;
519 for (i = start + 1; i < end; i++) {
520 textfont_prop_val cur;
522 hr = get_textfont_prop_for_pos(reole, i, propid, &cur);
523 if (FAILED(hr))
524 return hr;
526 if (!is_equal_textfont_prop_value(propid, &v, &cur))
527 return S_OK;
530 *value = v;
531 return S_OK;
534 static HRESULT get_textfont_propf(const ITextFontImpl *font, enum textfont_prop_id propid, FLOAT *value)
536 textfont_prop_val v;
537 HRESULT hr;
539 if (!value)
540 return E_INVALIDARG;
542 hr = get_textfont_prop(font, propid, &v);
543 *value = v.f;
544 return hr;
547 static HRESULT get_textfont_propl(const ITextFontImpl *font, enum textfont_prop_id propid, LONG *value)
549 textfont_prop_val v;
550 HRESULT hr;
552 if (!value)
553 return E_INVALIDARG;
555 hr = get_textfont_prop(font, propid, &v);
556 *value = v.l;
557 return hr;
560 /* Value should already have a terminal value, for boolean properties it means tomToggle is not handled */
561 static HRESULT set_textfont_prop(ITextFontImpl *font, enum textfont_prop_id propid, const textfont_prop_val *value)
563 const IRichEditOleImpl *reole;
564 ME_Cursor from, to;
565 CHARFORMAT2W fmt;
566 LONG start, end;
568 /* when font is not attached to any range use cache */
569 if (!font->range || font->set_cache_enabled) {
570 font->props[propid] = *value;
571 return S_OK;
574 if (!(reole = get_range_reole(font->range)))
575 return CO_E_RELEASED;
577 memset(&fmt, 0, sizeof(fmt));
578 fmt.cbSize = sizeof(fmt);
579 fmt.dwMask = textfont_prop_masks[propid];
581 switch (propid)
583 case FONT_ITALIC:
584 fmt.dwEffects = value->l == tomTrue ? CFE_ITALIC : 0;
585 break;
586 default:
587 FIXME("unhandled font property %d\n", propid);
588 return E_FAIL;
591 ITextRange_GetStart(font->range, &start);
592 ITextRange_GetEnd(font->range, &end);
594 ME_CursorFromCharOfs(reole->editor, start, &from);
595 ME_CursorFromCharOfs(reole->editor, end, &to);
596 ME_SetCharFormat(reole->editor, &from, &to, &fmt);
598 return S_OK;
601 static HRESULT set_textfont_propd(ITextFontImpl *font, enum textfont_prop_id propid, LONG value)
603 textfont_prop_val v;
605 switch (value)
607 case tomUndefined:
608 return S_OK;
609 case tomToggle: {
610 LONG oldvalue;
611 get_textfont_propl(font, propid, &oldvalue);
612 if (oldvalue == tomFalse)
613 value = tomTrue;
614 else if (oldvalue == tomTrue)
615 value = tomFalse;
616 else
617 return E_INVALIDARG;
618 /* fallthrough */
620 case tomTrue:
621 case tomFalse:
622 v.l = value;
623 return set_textfont_prop(font, propid, &v);
624 default:
625 return E_INVALIDARG;
629 static HRESULT textfont_getname_from_range(ITextRange *range, BSTR *ret)
631 const IRichEditOleImpl *reole;
632 textfont_prop_val v;
633 HRESULT hr;
634 LONG start;
636 if (!(reole = get_range_reole(range)))
637 return CO_E_RELEASED;
639 ITextRange_GetStart(range, &start);
640 hr = get_textfont_prop_for_pos(reole, start, FONT_NAME, &v);
641 *ret = v.str;
642 return hr;
645 static void textfont_cache_range_props(ITextFontImpl *font)
647 enum textfont_prop_id propid;
648 for (propid = FONT_PROPID_FIRST; propid < FONT_PROPID_LAST; propid++) {
649 if (propid == FONT_NAME)
650 textfont_getname_from_range(font->range, &font->props[propid].str);
651 else
652 get_textfont_prop(font, propid, &font->props[propid]);
656 static HRESULT WINAPI IRichEditOleImpl_inner_fnQueryInterface(IUnknown *iface, REFIID riid, LPVOID *ppvObj)
658 IRichEditOleImpl *This = impl_from_IUnknown(iface);
660 TRACE("%p %s\n", This, debugstr_guid(riid));
662 *ppvObj = NULL;
663 if (IsEqualGUID(riid, &IID_IUnknown))
664 *ppvObj = &This->IUnknown_inner;
665 else if (IsEqualGUID(riid, &IID_IRichEditOle))
666 *ppvObj = &This->IRichEditOle_iface;
667 else if (IsEqualGUID(riid, &IID_ITextDocument))
668 *ppvObj = &This->ITextDocument_iface;
669 if (*ppvObj)
671 IUnknown_AddRef((IUnknown *)*ppvObj);
672 return S_OK;
674 FIXME("%p: unhandled interface %s\n", This, debugstr_guid(riid));
676 return E_NOINTERFACE;
679 static ULONG WINAPI IRichEditOleImpl_inner_fnAddRef(IUnknown *iface)
681 IRichEditOleImpl *This = impl_from_IUnknown(iface);
682 ULONG ref = InterlockedIncrement(&This->ref);
684 TRACE("%p ref = %u\n", This, ref);
686 return ref;
689 static ULONG WINAPI IRichEditOleImpl_inner_fnRelease(IUnknown *iface)
691 IRichEditOleImpl *This = impl_from_IUnknown(iface);
692 ULONG ref = InterlockedDecrement(&This->ref);
694 TRACE ("%p ref=%u\n", This, ref);
696 if (!ref)
698 ITextRangeImpl *txtRge;
700 TRACE("Destroying %p\n", This);
701 This->txtSel->reOle = NULL;
702 This->editor->reOle = NULL;
703 ITextSelection_Release(&This->txtSel->ITextSelection_iface);
704 IOleClientSite_Release(&This->clientSite->IOleClientSite_iface);
705 LIST_FOR_EACH_ENTRY(txtRge, &This->rangelist, ITextRangeImpl, entry)
706 txtRge->reOle = NULL;
707 heap_free(This);
709 return ref;
712 static const IUnknownVtbl reo_unk_vtbl =
714 IRichEditOleImpl_inner_fnQueryInterface,
715 IRichEditOleImpl_inner_fnAddRef,
716 IRichEditOleImpl_inner_fnRelease
719 static HRESULT WINAPI
720 IRichEditOle_fnQueryInterface(IRichEditOle *me, REFIID riid, LPVOID *ppvObj)
722 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
723 return IUnknown_QueryInterface(This->outer_unk, riid, ppvObj);
726 static ULONG WINAPI
727 IRichEditOle_fnAddRef(IRichEditOle *me)
729 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
730 return IUnknown_AddRef(This->outer_unk);
733 static ULONG WINAPI
734 IRichEditOle_fnRelease(IRichEditOle *me)
736 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
737 return IUnknown_Release(This->outer_unk);
740 static HRESULT WINAPI
741 IRichEditOle_fnActivateAs(IRichEditOle *me, REFCLSID rclsid, REFCLSID rclsidAs)
743 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
744 FIXME("stub %p\n",This);
745 return E_NOTIMPL;
748 static HRESULT WINAPI
749 IRichEditOle_fnContextSensitiveHelp(IRichEditOle *me, BOOL fEnterMode)
751 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
752 FIXME("stub %p\n",This);
753 return E_NOTIMPL;
756 static HRESULT WINAPI
757 IRichEditOle_fnConvertObject(IRichEditOle *me, LONG iob,
758 REFCLSID rclsidNew, LPCSTR lpstrUserTypeNew)
760 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
761 FIXME("stub %p\n",This);
762 return E_NOTIMPL;
765 static inline IOleClientSiteImpl *impl_from_IOleClientSite(IOleClientSite *iface)
767 return CONTAINING_RECORD(iface, IOleClientSiteImpl, IOleClientSite_iface);
770 static HRESULT WINAPI
771 IOleClientSite_fnQueryInterface(IOleClientSite *me, REFIID riid, LPVOID *ppvObj)
773 IOleClientSiteImpl *This = impl_from_IOleClientSite(me);
774 TRACE("%p %s\n", me, debugstr_guid(riid) );
776 *ppvObj = NULL;
777 if (IsEqualGUID(riid, &IID_IUnknown) ||
778 IsEqualGUID(riid, &IID_IOleClientSite))
779 *ppvObj = me;
780 else if (IsEqualGUID(riid, &IID_IOleWindow))
781 *ppvObj = &This->IOleWindow_iface;
782 else if (IsEqualGUID(riid, &IID_IOleInPlaceSite))
783 *ppvObj = &This->IOleInPlaceSite_iface;
784 if (*ppvObj)
786 IOleClientSite_AddRef(me);
787 return S_OK;
789 FIXME("%p: unhandled interface %s\n", me, debugstr_guid(riid) );
791 return E_NOINTERFACE;
794 static ULONG WINAPI IOleClientSite_fnAddRef(IOleClientSite *iface)
796 IOleClientSiteImpl *This = impl_from_IOleClientSite(iface);
797 return InterlockedIncrement(&This->ref);
800 static ULONG WINAPI IOleClientSite_fnRelease(IOleClientSite *iface)
802 IOleClientSiteImpl *This = impl_from_IOleClientSite(iface);
803 ULONG ref = InterlockedDecrement(&This->ref);
804 if (ref == 0)
805 heap_free(This);
806 return ref;
809 static HRESULT WINAPI IOleClientSite_fnSaveObject(IOleClientSite *iface)
811 IOleClientSiteImpl *This = impl_from_IOleClientSite(iface);
812 if (!This->reOle)
813 return CO_E_RELEASED;
815 FIXME("stub %p\n", iface);
816 return E_NOTIMPL;
820 static HRESULT WINAPI IOleClientSite_fnGetMoniker(IOleClientSite *iface, DWORD dwAssign,
821 DWORD dwWhichMoniker, IMoniker **ppmk)
823 IOleClientSiteImpl *This = impl_from_IOleClientSite(iface);
824 if (!This->reOle)
825 return CO_E_RELEASED;
827 FIXME("stub %p\n", iface);
828 return E_NOTIMPL;
831 static HRESULT WINAPI IOleClientSite_fnGetContainer(IOleClientSite *iface,
832 IOleContainer **ppContainer)
834 IOleClientSiteImpl *This = impl_from_IOleClientSite(iface);
835 if (!This->reOle)
836 return CO_E_RELEASED;
838 FIXME("stub %p\n", iface);
839 return E_NOTIMPL;
842 static HRESULT WINAPI IOleClientSite_fnShowObject(IOleClientSite *iface)
844 IOleClientSiteImpl *This = impl_from_IOleClientSite(iface);
845 if (!This->reOle)
846 return CO_E_RELEASED;
848 FIXME("stub %p\n", iface);
849 return E_NOTIMPL;
852 static HRESULT WINAPI IOleClientSite_fnOnShowWindow(IOleClientSite *iface, BOOL fShow)
854 IOleClientSiteImpl *This = impl_from_IOleClientSite(iface);
855 if (!This->reOle)
856 return CO_E_RELEASED;
858 FIXME("stub %p\n", iface);
859 return E_NOTIMPL;
862 static HRESULT WINAPI IOleClientSite_fnRequestNewObjectLayout(IOleClientSite *iface)
864 IOleClientSiteImpl *This = impl_from_IOleClientSite(iface);
865 if (!This->reOle)
866 return CO_E_RELEASED;
868 FIXME("stub %p\n", iface);
869 return E_NOTIMPL;
872 static const IOleClientSiteVtbl ocst = {
873 IOleClientSite_fnQueryInterface,
874 IOleClientSite_fnAddRef,
875 IOleClientSite_fnRelease,
876 IOleClientSite_fnSaveObject,
877 IOleClientSite_fnGetMoniker,
878 IOleClientSite_fnGetContainer,
879 IOleClientSite_fnShowObject,
880 IOleClientSite_fnOnShowWindow,
881 IOleClientSite_fnRequestNewObjectLayout
884 /* IOleWindow interface */
885 static HRESULT WINAPI IOleWindow_fnQueryInterface(IOleWindow *iface, REFIID riid, void **ppvObj)
887 IOleClientSiteImpl *This = impl_from_IOleWindow(iface);
888 return IOleClientSite_QueryInterface(&This->IOleClientSite_iface, riid, ppvObj);
891 static ULONG WINAPI IOleWindow_fnAddRef(IOleWindow *iface)
893 IOleClientSiteImpl *This = impl_from_IOleWindow(iface);
894 return IOleClientSite_AddRef(&This->IOleClientSite_iface);
897 static ULONG WINAPI IOleWindow_fnRelease(IOleWindow *iface)
899 IOleClientSiteImpl *This = impl_from_IOleWindow(iface);
900 return IOleClientSite_Release(&This->IOleClientSite_iface);
903 static HRESULT WINAPI IOleWindow_fnContextSensitiveHelp(IOleWindow *iface, BOOL fEnterMode)
905 IOleClientSiteImpl *This = impl_from_IOleWindow(iface);
906 FIXME("not implemented: (%p)->(%d)\n", This, fEnterMode);
907 return E_NOTIMPL;
910 static HRESULT WINAPI IOleWindow_fnGetWindow(IOleWindow *iface, HWND *phwnd)
912 IOleClientSiteImpl *This = impl_from_IOleWindow(iface);
913 TRACE("(%p)->(%p)\n", This, phwnd);
915 if (!phwnd)
916 return E_INVALIDARG;
918 *phwnd = This->reOle->editor->hWnd;
919 return S_OK;
922 static const IOleWindowVtbl olewinvt = {
923 IOleWindow_fnQueryInterface,
924 IOleWindow_fnAddRef,
925 IOleWindow_fnRelease,
926 IOleWindow_fnGetWindow,
927 IOleWindow_fnContextSensitiveHelp
930 /* IOleInPlaceSite interface */
931 static HRESULT STDMETHODCALLTYPE IOleInPlaceSite_fnQueryInterface(IOleInPlaceSite *iface, REFIID riid, void **ppvObj)
933 IOleClientSiteImpl *This = impl_from_IOleInPlaceSite(iface);
934 return IOleClientSite_QueryInterface(&This->IOleClientSite_iface, riid, ppvObj);
937 static ULONG STDMETHODCALLTYPE IOleInPlaceSite_fnAddRef(IOleInPlaceSite *iface)
939 IOleClientSiteImpl *This = impl_from_IOleInPlaceSite(iface);
940 return IOleClientSite_AddRef(&This->IOleClientSite_iface);
943 static ULONG STDMETHODCALLTYPE IOleInPlaceSite_fnRelease(IOleInPlaceSite *iface)
945 IOleClientSiteImpl *This = impl_from_IOleInPlaceSite(iface);
946 return IOleClientSite_Release(&This->IOleClientSite_iface);
949 static HRESULT STDMETHODCALLTYPE IOleInPlaceSite_fnGetWindow(IOleInPlaceSite *iface, HWND *phwnd)
951 IOleClientSiteImpl *This = impl_from_IOleInPlaceSite(iface);
952 return IOleWindow_GetWindow(&This->IOleWindow_iface, phwnd);
955 static HRESULT STDMETHODCALLTYPE IOleInPlaceSite_fnContextSensitiveHelp(IOleInPlaceSite *iface, BOOL fEnterMode)
957 IOleClientSiteImpl *This = impl_from_IOleInPlaceSite(iface);
958 return IOleWindow_ContextSensitiveHelp(&This->IOleWindow_iface, fEnterMode);
961 static HRESULT STDMETHODCALLTYPE IOleInPlaceSite_fnCanInPlaceActivate(IOleInPlaceSite *iface)
963 IOleClientSiteImpl *This = impl_from_IOleInPlaceSite(iface);
964 FIXME("not implemented: (%p)\n", This);
965 return E_NOTIMPL;
968 static HRESULT STDMETHODCALLTYPE IOleInPlaceSite_fnOnInPlaceActivate(IOleInPlaceSite *iface)
970 IOleClientSiteImpl *This = impl_from_IOleInPlaceSite(iface);
971 FIXME("not implemented: (%p)\n", This);
972 return E_NOTIMPL;
975 static HRESULT STDMETHODCALLTYPE IOleInPlaceSite_fnOnUIActivate(IOleInPlaceSite *iface)
977 IOleClientSiteImpl *This = impl_from_IOleInPlaceSite(iface);
978 FIXME("not implemented: (%p)\n", This);
979 return E_NOTIMPL;
982 static HRESULT STDMETHODCALLTYPE IOleInPlaceSite_fnGetWindowContext(IOleInPlaceSite *iface, IOleInPlaceFrame **ppFrame,
983 IOleInPlaceUIWindow **ppDoc, LPRECT lprcPosRect,
984 LPRECT lprcClipRect, LPOLEINPLACEFRAMEINFO lpFrameInfo)
986 IOleClientSiteImpl *This = impl_from_IOleInPlaceSite(iface);
987 FIXME("not implemented: (%p)->(%p %p %p %p %p)\n", This, ppFrame, ppDoc, lprcPosRect, lprcClipRect, lpFrameInfo);
988 return E_NOTIMPL;
991 static HRESULT STDMETHODCALLTYPE IOleInPlaceSite_fnScroll(IOleInPlaceSite *iface, SIZE scrollExtent)
993 IOleClientSiteImpl *This = impl_from_IOleInPlaceSite(iface);
994 FIXME("not implemented: (%p)\n", This);
995 return E_NOTIMPL;
998 static HRESULT STDMETHODCALLTYPE IOleInPlaceSite_fnOnUIDeactivate(IOleInPlaceSite *iface, BOOL fUndoable)
1000 IOleClientSiteImpl *This = impl_from_IOleInPlaceSite(iface);
1001 FIXME("not implemented: (%p)->(%d)\n", This, fUndoable);
1002 return E_NOTIMPL;
1005 static HRESULT STDMETHODCALLTYPE IOleInPlaceSite_fnOnInPlaceDeactivate(IOleInPlaceSite *iface)
1007 IOleClientSiteImpl *This = impl_from_IOleInPlaceSite(iface);
1008 FIXME("not implemented: (%p)\n", This);
1009 return E_NOTIMPL;
1012 static HRESULT STDMETHODCALLTYPE IOleInPlaceSite_fnDiscardUndoState(IOleInPlaceSite *iface)
1014 IOleClientSiteImpl *This = impl_from_IOleInPlaceSite(iface);
1015 FIXME("not implemented: (%p)\n", This);
1016 return E_NOTIMPL;
1019 static HRESULT STDMETHODCALLTYPE IOleInPlaceSite_fnDeactivateAndUndo(IOleInPlaceSite *iface)
1021 IOleClientSiteImpl *This = impl_from_IOleInPlaceSite(iface);
1022 FIXME("not implemented: (%p)\n", This);
1023 return E_NOTIMPL;
1026 static HRESULT STDMETHODCALLTYPE IOleInPlaceSite_fnOnPosRectChange(IOleInPlaceSite *iface, LPCRECT lprcPosRect)
1028 IOleClientSiteImpl *This = impl_from_IOleInPlaceSite(iface);
1029 FIXME("not implemented: (%p)->(%p)\n", This, lprcPosRect);
1030 return E_NOTIMPL;
1033 static const IOleInPlaceSiteVtbl olestvt =
1035 IOleInPlaceSite_fnQueryInterface,
1036 IOleInPlaceSite_fnAddRef,
1037 IOleInPlaceSite_fnRelease,
1038 IOleInPlaceSite_fnGetWindow,
1039 IOleInPlaceSite_fnContextSensitiveHelp,
1040 IOleInPlaceSite_fnCanInPlaceActivate,
1041 IOleInPlaceSite_fnOnInPlaceActivate,
1042 IOleInPlaceSite_fnOnUIActivate,
1043 IOleInPlaceSite_fnGetWindowContext,
1044 IOleInPlaceSite_fnScroll,
1045 IOleInPlaceSite_fnOnUIDeactivate,
1046 IOleInPlaceSite_fnOnInPlaceDeactivate,
1047 IOleInPlaceSite_fnDiscardUndoState,
1048 IOleInPlaceSite_fnDeactivateAndUndo,
1049 IOleInPlaceSite_fnOnPosRectChange
1052 static IOleClientSiteImpl *
1053 CreateOleClientSite(IRichEditOleImpl *reOle)
1055 IOleClientSiteImpl *clientSite = heap_alloc(sizeof *clientSite);
1056 if (!clientSite)
1057 return NULL;
1059 clientSite->IOleClientSite_iface.lpVtbl = &ocst;
1060 clientSite->IOleWindow_iface.lpVtbl = &olewinvt;
1061 clientSite->IOleInPlaceSite_iface.lpVtbl = &olestvt;
1062 clientSite->ref = 1;
1063 clientSite->reOle = reOle;
1064 return clientSite;
1067 static HRESULT WINAPI
1068 IRichEditOle_fnGetClientSite(IRichEditOle *me,
1069 LPOLECLIENTSITE *lplpolesite)
1071 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
1073 TRACE("%p,%p\n",This, lplpolesite);
1075 if(!lplpolesite)
1076 return E_INVALIDARG;
1077 *lplpolesite = &This->clientSite->IOleClientSite_iface;
1078 IOleClientSite_AddRef(*lplpolesite);
1079 return S_OK;
1082 static HRESULT WINAPI
1083 IRichEditOle_fnGetClipboardData(IRichEditOle *me, CHARRANGE *lpchrg,
1084 DWORD reco, LPDATAOBJECT *lplpdataobj)
1086 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
1087 ME_Cursor start;
1088 int nChars;
1090 TRACE("(%p,%p,%d)\n",This, lpchrg, reco);
1091 if(!lplpdataobj)
1092 return E_INVALIDARG;
1093 if(!lpchrg) {
1094 int nFrom, nTo, nStartCur = ME_GetSelectionOfs(This->editor, &nFrom, &nTo);
1095 start = This->editor->pCursors[nStartCur];
1096 nChars = nTo - nFrom;
1097 } else {
1098 ME_CursorFromCharOfs(This->editor, lpchrg->cpMin, &start);
1099 nChars = lpchrg->cpMax - lpchrg->cpMin;
1101 return ME_GetDataObject(This->editor, &start, nChars, lplpdataobj);
1104 static LONG WINAPI IRichEditOle_fnGetLinkCount(IRichEditOle *me)
1106 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
1107 FIXME("stub %p\n",This);
1108 return E_NOTIMPL;
1111 static HRESULT WINAPI
1112 IRichEditOle_fnGetObject(IRichEditOle *me, LONG iob,
1113 REOBJECT *lpreobject, DWORD dwFlags)
1115 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
1116 FIXME("stub %p\n",This);
1117 return E_NOTIMPL;
1120 static LONG WINAPI
1121 IRichEditOle_fnGetObjectCount(IRichEditOle *me)
1123 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
1124 FIXME("stub %p\n",This);
1125 return 0;
1128 static HRESULT WINAPI
1129 IRichEditOle_fnHandsOffStorage(IRichEditOle *me, LONG iob)
1131 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
1132 FIXME("stub %p\n",This);
1133 return E_NOTIMPL;
1136 static HRESULT WINAPI
1137 IRichEditOle_fnImportDataObject(IRichEditOle *me, LPDATAOBJECT lpdataobj,
1138 CLIPFORMAT cf, HGLOBAL hMetaPict)
1140 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
1141 FIXME("stub %p\n",This);
1142 return E_NOTIMPL;
1145 static HRESULT WINAPI
1146 IRichEditOle_fnInPlaceDeactivate(IRichEditOle *me)
1148 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
1149 FIXME("stub %p\n",This);
1150 return E_NOTIMPL;
1153 static HRESULT WINAPI
1154 IRichEditOle_fnInsertObject(IRichEditOle *me, REOBJECT *reo)
1156 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
1157 TRACE("(%p,%p)\n", This, reo);
1159 if (reo->cbStruct < sizeof(*reo)) return STG_E_INVALIDPARAMETER;
1161 ME_InsertOLEFromCursor(This->editor, reo, 0);
1162 ME_CommitUndo(This->editor);
1163 ME_UpdateRepaint(This->editor, FALSE);
1164 return S_OK;
1167 static HRESULT WINAPI IRichEditOle_fnSaveCompleted(IRichEditOle *me, LONG iob,
1168 LPSTORAGE lpstg)
1170 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
1171 FIXME("stub %p\n",This);
1172 return E_NOTIMPL;
1175 static HRESULT WINAPI
1176 IRichEditOle_fnSetDvaspect(IRichEditOle *me, LONG iob, DWORD dvaspect)
1178 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
1179 FIXME("stub %p\n",This);
1180 return E_NOTIMPL;
1183 static HRESULT WINAPI IRichEditOle_fnSetHostNames(IRichEditOle *me,
1184 LPCSTR lpstrContainerApp, LPCSTR lpstrContainerObj)
1186 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
1187 FIXME("stub %p %s %s\n",This, lpstrContainerApp, lpstrContainerObj);
1188 return E_NOTIMPL;
1191 static HRESULT WINAPI
1192 IRichEditOle_fnSetLinkAvailable(IRichEditOle *me, LONG iob, BOOL fAvailable)
1194 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
1195 FIXME("stub %p\n",This);
1196 return E_NOTIMPL;
1199 static const IRichEditOleVtbl revt = {
1200 IRichEditOle_fnQueryInterface,
1201 IRichEditOle_fnAddRef,
1202 IRichEditOle_fnRelease,
1203 IRichEditOle_fnGetClientSite,
1204 IRichEditOle_fnGetObjectCount,
1205 IRichEditOle_fnGetLinkCount,
1206 IRichEditOle_fnGetObject,
1207 IRichEditOle_fnInsertObject,
1208 IRichEditOle_fnConvertObject,
1209 IRichEditOle_fnActivateAs,
1210 IRichEditOle_fnSetHostNames,
1211 IRichEditOle_fnSetLinkAvailable,
1212 IRichEditOle_fnSetDvaspect,
1213 IRichEditOle_fnHandsOffStorage,
1214 IRichEditOle_fnSaveCompleted,
1215 IRichEditOle_fnInPlaceDeactivate,
1216 IRichEditOle_fnContextSensitiveHelp,
1217 IRichEditOle_fnGetClipboardData,
1218 IRichEditOle_fnImportDataObject
1221 /* ITextRange interface */
1222 static HRESULT WINAPI ITextRange_fnQueryInterface(ITextRange *me, REFIID riid, void **ppvObj)
1224 ITextRangeImpl *This = impl_from_ITextRange(me);
1226 *ppvObj = NULL;
1227 if (IsEqualGUID(riid, &IID_IUnknown)
1228 || IsEqualGUID(riid, &IID_IDispatch)
1229 || IsEqualGUID(riid, &IID_ITextRange))
1231 *ppvObj = me;
1232 ITextRange_AddRef(me);
1233 return S_OK;
1235 else if (IsEqualGUID(riid, &IID_Igetrichole))
1237 *ppvObj = This->reOle;
1238 return S_OK;
1241 return E_NOINTERFACE;
1244 static ULONG WINAPI ITextRange_fnAddRef(ITextRange *me)
1246 ITextRangeImpl *This = impl_from_ITextRange(me);
1247 return InterlockedIncrement(&This->ref);
1250 static ULONG WINAPI ITextRange_fnRelease(ITextRange *me)
1252 ITextRangeImpl *This = impl_from_ITextRange(me);
1253 ULONG ref = InterlockedDecrement(&This->ref);
1255 TRACE ("%p ref=%u\n", This, ref);
1256 if (ref == 0)
1258 if (This->reOle)
1260 list_remove(&This->entry);
1261 This->reOle = NULL;
1263 heap_free(This);
1265 return ref;
1268 static HRESULT WINAPI ITextRange_fnGetTypeInfoCount(ITextRange *me, UINT *pctinfo)
1270 ITextRangeImpl *This = impl_from_ITextRange(me);
1271 TRACE("(%p)->(%p)\n", This, pctinfo);
1272 *pctinfo = 1;
1273 return S_OK;
1276 static HRESULT WINAPI ITextRange_fnGetTypeInfo(ITextRange *me, UINT iTInfo, LCID lcid,
1277 ITypeInfo **ppTInfo)
1279 ITextRangeImpl *This = impl_from_ITextRange(me);
1280 HRESULT hr;
1282 TRACE("(%p)->(%u,%d,%p)\n", This, iTInfo, lcid, ppTInfo);
1284 hr = get_typeinfo(ITextRange_tid, ppTInfo);
1285 if (SUCCEEDED(hr))
1286 ITypeInfo_AddRef(*ppTInfo);
1287 return hr;
1290 static HRESULT WINAPI ITextRange_fnGetIDsOfNames(ITextRange *me, REFIID riid, LPOLESTR *rgszNames,
1291 UINT cNames, LCID lcid, DISPID *rgDispId)
1293 ITextRangeImpl *This = impl_from_ITextRange(me);
1294 ITypeInfo *ti;
1295 HRESULT hr;
1297 TRACE("(%p)->(%p,%p,%u,%d,%p)\n", This, riid, rgszNames, cNames, lcid,
1298 rgDispId);
1300 hr = get_typeinfo(ITextRange_tid, &ti);
1301 if (SUCCEEDED(hr))
1302 hr = ITypeInfo_GetIDsOfNames(ti, rgszNames, cNames, rgDispId);
1303 return hr;
1306 static HRESULT WINAPI ITextRange_fnInvoke(ITextRange *me, DISPID dispIdMember, REFIID riid,
1307 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
1308 VARIANT *pVarResult, EXCEPINFO *pExcepInfo,
1309 UINT *puArgErr)
1311 ITextRangeImpl *This = impl_from_ITextRange(me);
1312 ITypeInfo *ti;
1313 HRESULT hr;
1315 TRACE("(%p)->(%d,%p,%d,%u,%p,%p,%p,%p)\n", This, dispIdMember, riid, lcid,
1316 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
1318 hr = get_typeinfo(ITextRange_tid, &ti);
1319 if (SUCCEEDED(hr))
1320 hr = ITypeInfo_Invoke(ti, me, dispIdMember, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
1321 return hr;
1324 static HRESULT WINAPI ITextRange_fnGetText(ITextRange *me, BSTR *pbstr)
1326 ITextRangeImpl *This = impl_from_ITextRange(me);
1328 FIXME("(%p)->(%p): stub\n", This, pbstr);
1330 if (!This->reOle)
1331 return CO_E_RELEASED;
1333 if (!pbstr)
1334 return E_INVALIDARG;
1336 *pbstr = NULL;
1337 return E_NOTIMPL;
1340 static HRESULT WINAPI ITextRange_fnSetText(ITextRange *me, BSTR bstr)
1342 ITextRangeImpl *This = impl_from_ITextRange(me);
1343 if (!This->reOle)
1344 return CO_E_RELEASED;
1346 FIXME("not implemented %p\n", This);
1347 return E_NOTIMPL;
1350 static HRESULT range_GetChar(ME_TextEditor *editor, ME_Cursor *cursor, LONG *pch)
1352 WCHAR wch[2];
1354 ME_GetTextW(editor, wch, 1, cursor, 1, FALSE, cursor->pRun->next->type == diTextEnd);
1355 *pch = wch[0];
1357 return S_OK;
1360 static HRESULT WINAPI ITextRange_fnGetChar(ITextRange *me, LONG *pch)
1362 ITextRangeImpl *This = impl_from_ITextRange(me);
1363 ME_Cursor cursor;
1365 if (!This->reOle)
1366 return CO_E_RELEASED;
1367 TRACE("%p\n", pch);
1368 if (!pch)
1369 return E_INVALIDARG;
1371 ME_CursorFromCharOfs(This->reOle->editor, This->start, &cursor);
1372 return range_GetChar(This->reOle->editor, &cursor, pch);
1375 static HRESULT WINAPI ITextRange_fnSetChar(ITextRange *me, LONG ch)
1377 ITextRangeImpl *This = impl_from_ITextRange(me);
1378 if (!This->reOle)
1379 return CO_E_RELEASED;
1381 FIXME("not implemented %p\n", This);
1382 return E_NOTIMPL;
1385 static HRESULT CreateITextRange(IRichEditOleImpl *reOle, LONG start, LONG end, ITextRange** ppRange);
1387 static HRESULT WINAPI ITextRange_fnGetDuplicate(ITextRange *me, ITextRange **ppRange)
1389 ITextRangeImpl *This = impl_from_ITextRange(me);
1390 if (!This->reOle)
1391 return CO_E_RELEASED;
1393 TRACE("%p %p\n", This, ppRange);
1394 if (!ppRange)
1395 return E_INVALIDARG;
1397 return CreateITextRange(This->reOle, This->start, This->end, ppRange);
1400 static HRESULT WINAPI ITextRange_fnGetFormattedText(ITextRange *me, ITextRange **ppRange)
1402 ITextRangeImpl *This = impl_from_ITextRange(me);
1403 if (!This->reOle)
1404 return CO_E_RELEASED;
1406 FIXME("not implemented %p\n", This);
1407 return E_NOTIMPL;
1410 static HRESULT WINAPI ITextRange_fnSetFormattedText(ITextRange *me, ITextRange *pRange)
1412 ITextRangeImpl *This = impl_from_ITextRange(me);
1413 if (!This->reOle)
1414 return CO_E_RELEASED;
1416 FIXME("not implemented %p\n", This);
1417 return E_NOTIMPL;
1420 static HRESULT WINAPI ITextRange_fnGetStart(ITextRange *me, LONG *start)
1422 ITextRangeImpl *This = impl_from_ITextRange(me);
1424 TRACE("(%p)->(%p)\n", This, start);
1426 if (!This->reOle)
1427 return CO_E_RELEASED;
1429 if (!start)
1430 return E_INVALIDARG;
1432 *start = This->start;
1433 return S_OK;
1436 static HRESULT textrange_setstart(const IRichEditOleImpl *reole, LONG value, LONG *start, LONG *end)
1438 int len;
1440 if (value < 0)
1441 value = 0;
1443 if (value == *start)
1444 return S_FALSE;
1446 if (value <= *end) {
1447 *start = value;
1448 return S_OK;
1451 len = ME_GetTextLength(reole->editor);
1452 *start = *end = value > len ? len : value;
1453 return S_OK;
1456 static HRESULT WINAPI ITextRange_fnSetStart(ITextRange *me, LONG value)
1458 ITextRangeImpl *This = impl_from_ITextRange(me);
1460 TRACE("(%p)->(%d)\n", This, value);
1462 if (!This->reOle)
1463 return CO_E_RELEASED;
1465 return textrange_setstart(This->reOle, value, &This->start, &This->end);
1468 static HRESULT WINAPI ITextRange_fnGetEnd(ITextRange *me, LONG *end)
1470 ITextRangeImpl *This = impl_from_ITextRange(me);
1472 TRACE("(%p)->(%p)\n", This, end);
1474 if (!This->reOle)
1475 return CO_E_RELEASED;
1477 if (!end)
1478 return E_INVALIDARG;
1480 *end = This->end;
1481 return S_OK;
1484 static HRESULT textrange_setend(const IRichEditOleImpl *reole, LONG value, LONG *start, LONG *end)
1486 int len;
1488 if (value == *end)
1489 return S_FALSE;
1491 if (value < *start) {
1492 *start = *end = max(0, value);
1493 return S_OK;
1496 len = ME_GetTextLength(reole->editor);
1497 *end = value > len ? len + 1 : value;
1498 return S_OK;
1501 static HRESULT WINAPI ITextRange_fnSetEnd(ITextRange *me, LONG value)
1503 ITextRangeImpl *This = impl_from_ITextRange(me);
1505 TRACE("(%p)->(%d)\n", This, value);
1507 if (!This->reOle)
1508 return CO_E_RELEASED;
1510 return textrange_setend(This->reOle, value, &This->start, &This->end);
1513 static HRESULT WINAPI ITextRange_fnGetFont(ITextRange *me, ITextFont **font)
1515 ITextRangeImpl *This = impl_from_ITextRange(me);
1517 TRACE("(%p)->(%p)\n", This, font);
1519 if (!This->reOle)
1520 return CO_E_RELEASED;
1522 if (!font)
1523 return E_INVALIDARG;
1525 return create_textfont(me, NULL, font);
1528 static HRESULT WINAPI ITextRange_fnSetFont(ITextRange *me, ITextFont *pFont)
1530 ITextRangeImpl *This = impl_from_ITextRange(me);
1531 if (!This->reOle)
1532 return CO_E_RELEASED;
1534 FIXME("not implemented %p\n", This);
1535 return E_NOTIMPL;
1538 static HRESULT WINAPI ITextRange_fnGetPara(ITextRange *me, ITextPara **para)
1540 ITextRangeImpl *This = impl_from_ITextRange(me);
1542 TRACE("(%p)->(%p)\n", This, para);
1544 if (!This->reOle)
1545 return CO_E_RELEASED;
1547 if (!para)
1548 return E_INVALIDARG;
1550 return create_textpara(me, para);
1553 static HRESULT WINAPI ITextRange_fnSetPara(ITextRange *me, ITextPara *pPara)
1555 ITextRangeImpl *This = impl_from_ITextRange(me);
1556 if (!This->reOle)
1557 return CO_E_RELEASED;
1559 FIXME("not implemented %p\n", This);
1560 return E_NOTIMPL;
1563 static HRESULT WINAPI ITextRange_fnGetStoryLength(ITextRange *me, LONG *pcch)
1565 ITextRangeImpl *This = impl_from_ITextRange(me);
1566 if (!This->reOle)
1567 return CO_E_RELEASED;
1569 FIXME("not implemented %p\n", This);
1570 return E_NOTIMPL;
1573 static HRESULT WINAPI ITextRange_fnGetStoryType(ITextRange *me, LONG *pValue)
1575 ITextRangeImpl *This = impl_from_ITextRange(me);
1576 if (!This->reOle)
1577 return CO_E_RELEASED;
1579 FIXME("not implemented %p\n", This);
1580 return E_NOTIMPL;
1583 static HRESULT range_Collapse(LONG bStart, LONG *start, LONG *end)
1585 if (*end == *start)
1586 return S_FALSE;
1588 if (bStart == tomEnd || bStart == tomFalse)
1589 *start = *end;
1590 else
1591 *end = *start;
1592 return S_OK;
1595 static HRESULT WINAPI ITextRange_fnCollapse(ITextRange *me, LONG bStart)
1597 ITextRangeImpl *This = impl_from_ITextRange(me);
1598 if (!This->reOle)
1599 return CO_E_RELEASED;
1601 return range_Collapse(bStart, &This->start, &This->end);
1604 static HRESULT WINAPI ITextRange_fnExpand(ITextRange *me, LONG Unit, LONG *pDelta)
1606 ITextRangeImpl *This = impl_from_ITextRange(me);
1607 if (!This->reOle)
1608 return CO_E_RELEASED;
1610 FIXME("not implemented %p\n", This);
1611 return E_NOTIMPL;
1614 static HRESULT WINAPI ITextRange_fnGetIndex(ITextRange *me, LONG Unit, LONG *pIndex)
1616 ITextRangeImpl *This = impl_from_ITextRange(me);
1617 if (!This->reOle)
1618 return CO_E_RELEASED;
1620 FIXME("not implemented %p\n", This);
1621 return E_NOTIMPL;
1624 static HRESULT WINAPI ITextRange_fnSetIndex(ITextRange *me, LONG Unit, LONG Index,
1625 LONG Extend)
1627 ITextRangeImpl *This = impl_from_ITextRange(me);
1628 if (!This->reOle)
1629 return CO_E_RELEASED;
1631 FIXME("not implemented %p\n", This);
1632 return E_NOTIMPL;
1635 static HRESULT WINAPI ITextRange_fnSetRange(ITextRange *me, LONG cpActive, LONG cpOther)
1637 ITextRangeImpl *This = impl_from_ITextRange(me);
1638 if (!This->reOle)
1639 return CO_E_RELEASED;
1641 FIXME("not implemented %p\n", This);
1642 return E_NOTIMPL;
1645 static HRESULT WINAPI ITextRange_fnInRange(ITextRange *me, ITextRange *pRange, LONG *pb)
1647 ITextRangeImpl *This = impl_from_ITextRange(me);
1648 if (!This->reOle)
1649 return CO_E_RELEASED;
1651 FIXME("not implemented %p\n", This);
1652 return E_NOTIMPL;
1655 static HRESULT WINAPI ITextRange_fnInStory(ITextRange *me, ITextRange *pRange, LONG *pb)
1657 ITextRangeImpl *This = impl_from_ITextRange(me);
1658 if (!This->reOle)
1659 return CO_E_RELEASED;
1661 FIXME("not implemented %p\n", This);
1662 return E_NOTIMPL;
1665 static HRESULT WINAPI ITextRange_fnIsEqual(ITextRange *me, ITextRange *pRange, LONG *pb)
1667 ITextRangeImpl *This = impl_from_ITextRange(me);
1668 if (!This->reOle)
1669 return CO_E_RELEASED;
1671 FIXME("not implemented %p\n", This);
1672 return E_NOTIMPL;
1675 static HRESULT WINAPI ITextRange_fnSelect(ITextRange *me)
1677 ITextRangeImpl *This = impl_from_ITextRange(me);
1678 if (!This->reOle)
1679 return CO_E_RELEASED;
1681 FIXME("not implemented %p\n", This);
1682 return E_NOTIMPL;
1685 static HRESULT WINAPI ITextRange_fnStartOf(ITextRange *me, LONG Unit, LONG Extend,
1686 LONG *pDelta)
1688 ITextRangeImpl *This = impl_from_ITextRange(me);
1689 if (!This->reOle)
1690 return CO_E_RELEASED;
1692 FIXME("not implemented %p\n", This);
1693 return E_NOTIMPL;
1696 static HRESULT WINAPI ITextRange_fnEndOf(ITextRange *me, LONG Unit, LONG Extend,
1697 LONG *pDelta)
1699 ITextRangeImpl *This = impl_from_ITextRange(me);
1700 if (!This->reOle)
1701 return CO_E_RELEASED;
1703 FIXME("not implemented %p\n", This);
1704 return E_NOTIMPL;
1707 static HRESULT WINAPI ITextRange_fnMove(ITextRange *me, LONG Unit, LONG Count, LONG *pDelta)
1709 ITextRangeImpl *This = impl_from_ITextRange(me);
1710 if (!This->reOle)
1711 return CO_E_RELEASED;
1713 FIXME("not implemented %p\n", This);
1714 return E_NOTIMPL;
1717 static HRESULT WINAPI ITextRange_fnMoveStart(ITextRange *me, LONG Unit, LONG Count,
1718 LONG *pDelta)
1720 ITextRangeImpl *This = impl_from_ITextRange(me);
1721 if (!This->reOle)
1722 return CO_E_RELEASED;
1724 FIXME("not implemented %p\n", This);
1725 return E_NOTIMPL;
1728 static HRESULT WINAPI ITextRange_fnMoveEnd(ITextRange *me, LONG Unit, LONG Count,
1729 LONG *pDelta)
1731 ITextRangeImpl *This = impl_from_ITextRange(me);
1732 if (!This->reOle)
1733 return CO_E_RELEASED;
1735 FIXME("not implemented %p\n", This);
1736 return E_NOTIMPL;
1739 static HRESULT WINAPI ITextRange_fnMoveWhile(ITextRange *me, VARIANT *Cset, LONG Count,
1740 LONG *pDelta)
1742 ITextRangeImpl *This = impl_from_ITextRange(me);
1743 if (!This->reOle)
1744 return CO_E_RELEASED;
1746 FIXME("not implemented %p\n", This);
1747 return E_NOTIMPL;
1750 static HRESULT WINAPI ITextRange_fnMoveStartWhile(ITextRange *me, VARIANT *Cset, LONG Count,
1751 LONG *pDelta)
1753 ITextRangeImpl *This = impl_from_ITextRange(me);
1754 if (!This->reOle)
1755 return CO_E_RELEASED;
1757 FIXME("not implemented %p\n", This);
1758 return E_NOTIMPL;
1761 static HRESULT WINAPI ITextRange_fnMoveEndWhile(ITextRange *me, VARIANT *Cset, LONG Count,
1762 LONG *pDelta)
1764 ITextRangeImpl *This = impl_from_ITextRange(me);
1765 if (!This->reOle)
1766 return CO_E_RELEASED;
1768 FIXME("not implemented %p\n", This);
1769 return E_NOTIMPL;
1772 static HRESULT WINAPI ITextRange_fnMoveUntil(ITextRange *me, VARIANT *Cset, LONG Count,
1773 LONG *pDelta)
1775 ITextRangeImpl *This = impl_from_ITextRange(me);
1776 if (!This->reOle)
1777 return CO_E_RELEASED;
1779 FIXME("not implemented %p\n", This);
1780 return E_NOTIMPL;
1783 static HRESULT WINAPI ITextRange_fnMoveStartUntil(ITextRange *me, VARIANT *Cset, LONG Count,
1784 LONG *pDelta)
1786 ITextRangeImpl *This = impl_from_ITextRange(me);
1787 if (!This->reOle)
1788 return CO_E_RELEASED;
1790 FIXME("not implemented %p\n", This);
1791 return E_NOTIMPL;
1794 static HRESULT WINAPI ITextRange_fnMoveEndUntil(ITextRange *me, VARIANT *Cset, LONG Count,
1795 LONG *pDelta)
1797 ITextRangeImpl *This = impl_from_ITextRange(me);
1798 if (!This->reOle)
1799 return CO_E_RELEASED;
1801 FIXME("not implemented %p\n", This);
1802 return E_NOTIMPL;
1805 static HRESULT WINAPI ITextRange_fnFindText(ITextRange *me, BSTR bstr, LONG cch, LONG Flags,
1806 LONG *pLength)
1808 ITextRangeImpl *This = impl_from_ITextRange(me);
1809 if (!This->reOle)
1810 return CO_E_RELEASED;
1812 FIXME("not implemented %p\n", This);
1813 return E_NOTIMPL;
1816 static HRESULT WINAPI ITextRange_fnFindTextStart(ITextRange *me, BSTR bstr, LONG cch,
1817 LONG Flags, LONG *pLength)
1819 ITextRangeImpl *This = impl_from_ITextRange(me);
1820 if (!This->reOle)
1821 return CO_E_RELEASED;
1823 FIXME("not implemented %p\n", This);
1824 return E_NOTIMPL;
1827 static HRESULT WINAPI ITextRange_fnFindTextEnd(ITextRange *me, BSTR bstr, LONG cch,
1828 LONG Flags, LONG *pLength)
1830 ITextRangeImpl *This = impl_from_ITextRange(me);
1831 if (!This->reOle)
1832 return CO_E_RELEASED;
1834 FIXME("not implemented %p\n", This);
1835 return E_NOTIMPL;
1838 static HRESULT WINAPI ITextRange_fnDelete(ITextRange *me, LONG Unit, LONG Count,
1839 LONG *pDelta)
1841 ITextRangeImpl *This = impl_from_ITextRange(me);
1842 if (!This->reOle)
1843 return CO_E_RELEASED;
1845 FIXME("not implemented %p\n", This);
1846 return E_NOTIMPL;
1849 static HRESULT WINAPI ITextRange_fnCut(ITextRange *me, VARIANT *pVar)
1851 ITextRangeImpl *This = impl_from_ITextRange(me);
1852 if (!This->reOle)
1853 return CO_E_RELEASED;
1855 FIXME("not implemented %p\n", This);
1856 return E_NOTIMPL;
1859 static HRESULT WINAPI ITextRange_fnCopy(ITextRange *me, VARIANT *pVar)
1861 ITextRangeImpl *This = impl_from_ITextRange(me);
1862 if (!This->reOle)
1863 return CO_E_RELEASED;
1865 FIXME("not implemented %p\n", This);
1866 return E_NOTIMPL;
1869 static HRESULT WINAPI ITextRange_fnPaste(ITextRange *me, VARIANT *pVar, LONG Format)
1871 ITextRangeImpl *This = impl_from_ITextRange(me);
1872 if (!This->reOle)
1873 return CO_E_RELEASED;
1875 FIXME("not implemented %p\n", This);
1876 return E_NOTIMPL;
1879 static HRESULT WINAPI ITextRange_fnCanPaste(ITextRange *me, VARIANT *pVar, LONG Format,
1880 LONG *pb)
1882 ITextRangeImpl *This = impl_from_ITextRange(me);
1883 if (!This->reOle)
1884 return CO_E_RELEASED;
1886 FIXME("not implemented %p\n", This);
1887 return E_NOTIMPL;
1890 static HRESULT WINAPI ITextRange_fnCanEdit(ITextRange *me, LONG *pb)
1892 ITextRangeImpl *This = impl_from_ITextRange(me);
1893 if (!This->reOle)
1894 return CO_E_RELEASED;
1896 FIXME("not implemented %p\n", This);
1897 return E_NOTIMPL;
1900 static HRESULT WINAPI ITextRange_fnChangeCase(ITextRange *me, LONG Type)
1902 ITextRangeImpl *This = impl_from_ITextRange(me);
1903 if (!This->reOle)
1904 return CO_E_RELEASED;
1906 FIXME("not implemented %p\n", This);
1907 return E_NOTIMPL;
1910 static HRESULT WINAPI ITextRange_fnGetPoint(ITextRange *me, LONG Type, LONG *cx, LONG *cy)
1912 ITextRangeImpl *This = impl_from_ITextRange(me);
1913 if (!This->reOle)
1914 return CO_E_RELEASED;
1916 FIXME("not implemented %p\n", This);
1917 return E_NOTIMPL;
1920 static HRESULT WINAPI ITextRange_fnSetPoint(ITextRange *me, LONG x, LONG y, LONG Type,
1921 LONG Extend)
1923 ITextRangeImpl *This = impl_from_ITextRange(me);
1924 if (!This->reOle)
1925 return CO_E_RELEASED;
1927 FIXME("not implemented %p\n", This);
1928 return E_NOTIMPL;
1931 static HRESULT WINAPI ITextRange_fnScrollIntoView(ITextRange *me, LONG Value)
1933 ITextRangeImpl *This = impl_from_ITextRange(me);
1934 if (!This->reOle)
1935 return CO_E_RELEASED;
1937 FIXME("not implemented %p\n", This);
1938 return E_NOTIMPL;
1941 static HRESULT WINAPI ITextRange_fnGetEmbeddedObject(ITextRange *me, IUnknown **ppv)
1943 ITextRangeImpl *This = impl_from_ITextRange(me);
1944 if (!This->reOle)
1945 return CO_E_RELEASED;
1947 FIXME("not implemented %p\n", This);
1948 return E_NOTIMPL;
1951 static const ITextRangeVtbl trvt = {
1952 ITextRange_fnQueryInterface,
1953 ITextRange_fnAddRef,
1954 ITextRange_fnRelease,
1955 ITextRange_fnGetTypeInfoCount,
1956 ITextRange_fnGetTypeInfo,
1957 ITextRange_fnGetIDsOfNames,
1958 ITextRange_fnInvoke,
1959 ITextRange_fnGetText,
1960 ITextRange_fnSetText,
1961 ITextRange_fnGetChar,
1962 ITextRange_fnSetChar,
1963 ITextRange_fnGetDuplicate,
1964 ITextRange_fnGetFormattedText,
1965 ITextRange_fnSetFormattedText,
1966 ITextRange_fnGetStart,
1967 ITextRange_fnSetStart,
1968 ITextRange_fnGetEnd,
1969 ITextRange_fnSetEnd,
1970 ITextRange_fnGetFont,
1971 ITextRange_fnSetFont,
1972 ITextRange_fnGetPara,
1973 ITextRange_fnSetPara,
1974 ITextRange_fnGetStoryLength,
1975 ITextRange_fnGetStoryType,
1976 ITextRange_fnCollapse,
1977 ITextRange_fnExpand,
1978 ITextRange_fnGetIndex,
1979 ITextRange_fnSetIndex,
1980 ITextRange_fnSetRange,
1981 ITextRange_fnInRange,
1982 ITextRange_fnInStory,
1983 ITextRange_fnIsEqual,
1984 ITextRange_fnSelect,
1985 ITextRange_fnStartOf,
1986 ITextRange_fnEndOf,
1987 ITextRange_fnMove,
1988 ITextRange_fnMoveStart,
1989 ITextRange_fnMoveEnd,
1990 ITextRange_fnMoveWhile,
1991 ITextRange_fnMoveStartWhile,
1992 ITextRange_fnMoveEndWhile,
1993 ITextRange_fnMoveUntil,
1994 ITextRange_fnMoveStartUntil,
1995 ITextRange_fnMoveEndUntil,
1996 ITextRange_fnFindText,
1997 ITextRange_fnFindTextStart,
1998 ITextRange_fnFindTextEnd,
1999 ITextRange_fnDelete,
2000 ITextRange_fnCut,
2001 ITextRange_fnCopy,
2002 ITextRange_fnPaste,
2003 ITextRange_fnCanPaste,
2004 ITextRange_fnCanEdit,
2005 ITextRange_fnChangeCase,
2006 ITextRange_fnGetPoint,
2007 ITextRange_fnSetPoint,
2008 ITextRange_fnScrollIntoView,
2009 ITextRange_fnGetEmbeddedObject
2012 /* ITextFont */
2013 static HRESULT WINAPI TextFont_QueryInterface(ITextFont *iface, REFIID riid, void **ppv)
2015 ITextFontImpl *This = impl_from_ITextFont(iface);
2017 TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
2019 if (IsEqualIID(riid, &IID_ITextFont) ||
2020 IsEqualIID(riid, &IID_IDispatch) ||
2021 IsEqualIID(riid, &IID_IUnknown))
2023 *ppv = iface;
2024 ITextFont_AddRef(iface);
2025 return S_OK;
2028 *ppv = NULL;
2029 return E_NOINTERFACE;
2032 static ULONG WINAPI TextFont_AddRef(ITextFont *iface)
2034 ITextFontImpl *This = impl_from_ITextFont(iface);
2035 ULONG ref = InterlockedIncrement(&This->ref);
2036 TRACE("(%p)->(%u)\n", This, ref);
2037 return ref;
2040 static ULONG WINAPI TextFont_Release(ITextFont *iface)
2042 ITextFontImpl *This = impl_from_ITextFont(iface);
2043 ULONG ref = InterlockedDecrement(&This->ref);
2045 TRACE("(%p)->(%u)\n", This, ref);
2047 if (!ref)
2049 if (This->range)
2050 ITextRange_Release(This->range);
2051 SysFreeString(This->props[FONT_NAME].str);
2052 heap_free(This);
2055 return ref;
2058 static HRESULT WINAPI TextFont_GetTypeInfoCount(ITextFont *iface, UINT *pctinfo)
2060 ITextFontImpl *This = impl_from_ITextFont(iface);
2061 TRACE("(%p)->(%p)\n", This, pctinfo);
2062 *pctinfo = 1;
2063 return S_OK;
2066 static HRESULT WINAPI TextFont_GetTypeInfo(ITextFont *iface, UINT iTInfo, LCID lcid,
2067 ITypeInfo **ppTInfo)
2069 ITextFontImpl *This = impl_from_ITextFont(iface);
2070 HRESULT hr;
2072 TRACE("(%p)->(%u,%d,%p)\n", This, iTInfo, lcid, ppTInfo);
2074 hr = get_typeinfo(ITextFont_tid, ppTInfo);
2075 if (SUCCEEDED(hr))
2076 ITypeInfo_AddRef(*ppTInfo);
2077 return hr;
2080 static HRESULT WINAPI TextFont_GetIDsOfNames(ITextFont *iface, REFIID riid,
2081 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
2083 ITextFontImpl *This = impl_from_ITextFont(iface);
2084 ITypeInfo *ti;
2085 HRESULT hr;
2087 TRACE("(%p)->(%p,%p,%u,%d,%p)\n", This, riid, rgszNames, cNames, lcid,
2088 rgDispId);
2090 hr = get_typeinfo(ITextFont_tid, &ti);
2091 if (SUCCEEDED(hr))
2092 hr = ITypeInfo_GetIDsOfNames(ti, rgszNames, cNames, rgDispId);
2093 return hr;
2096 static HRESULT WINAPI TextFont_Invoke(
2097 ITextFont *iface,
2098 DISPID dispIdMember,
2099 REFIID riid,
2100 LCID lcid,
2101 WORD wFlags,
2102 DISPPARAMS *pDispParams,
2103 VARIANT *pVarResult,
2104 EXCEPINFO *pExcepInfo,
2105 UINT *puArgErr)
2107 ITextFontImpl *This = impl_from_ITextFont(iface);
2108 ITypeInfo *ti;
2109 HRESULT hr;
2111 TRACE("(%p)->(%d,%p,%d,%u,%p,%p,%p,%p)\n", This, dispIdMember, riid, lcid,
2112 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
2114 hr = get_typeinfo(ITextFont_tid, &ti);
2115 if (SUCCEEDED(hr))
2116 hr = ITypeInfo_Invoke(ti, iface, dispIdMember, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
2117 return hr;
2120 static HRESULT WINAPI TextFont_GetDuplicate(ITextFont *iface, ITextFont **ret)
2122 ITextFontImpl *This = impl_from_ITextFont(iface);
2124 TRACE("(%p)->(%p)\n", This, ret);
2126 if (!ret)
2127 return E_INVALIDARG;
2129 *ret = NULL;
2130 if (This->range && !get_range_reole(This->range))
2131 return CO_E_RELEASED;
2133 return create_textfont(NULL, This, ret);
2136 static HRESULT WINAPI TextFont_SetDuplicate(ITextFont *iface, ITextFont *pFont)
2138 ITextFontImpl *This = impl_from_ITextFont(iface);
2139 FIXME("(%p)->(%p): stub\n", This, pFont);
2140 return E_NOTIMPL;
2143 static HRESULT WINAPI TextFont_CanChange(ITextFont *iface, LONG *ret)
2145 ITextFontImpl *This = impl_from_ITextFont(iface);
2146 FIXME("(%p)->(%p): stub\n", This, ret);
2147 return E_NOTIMPL;
2150 static HRESULT WINAPI TextFont_IsEqual(ITextFont *iface, ITextFont *font, LONG *ret)
2152 ITextFontImpl *This = impl_from_ITextFont(iface);
2153 FIXME("(%p)->(%p %p): stub\n", This, font, ret);
2154 return E_NOTIMPL;
2157 static void textfont_reset_to_default(ITextFontImpl *font)
2159 enum textfont_prop_id id;
2161 for (id = FONT_PROPID_FIRST; id < FONT_PROPID_LAST; id++) {
2162 switch (id)
2164 case FONT_ALLCAPS:
2165 case FONT_ANIMATION:
2166 case FONT_BOLD:
2167 case FONT_EMBOSS:
2168 case FONT_HIDDEN:
2169 case FONT_ENGRAVE:
2170 case FONT_ITALIC:
2171 case FONT_OUTLINE:
2172 case FONT_PROTECTED:
2173 case FONT_SHADOW:
2174 case FONT_SMALLCAPS:
2175 case FONT_STRIKETHROUGH:
2176 case FONT_SUBSCRIPT:
2177 case FONT_SUPERSCRIPT:
2178 case FONT_UNDERLINE:
2179 font->props[id].l = tomFalse;
2180 break;
2181 case FONT_BACKCOLOR:
2182 case FONT_FORECOLOR:
2183 font->props[id].l = tomAutoColor;
2184 break;
2185 case FONT_KERNING:
2186 case FONT_POSITION:
2187 case FONT_SIZE:
2188 case FONT_SPACING:
2189 font->props[id].f = 0.0;
2190 break;
2191 case FONT_LANGID:
2192 font->props[id].l = GetSystemDefaultLCID();
2193 break;
2194 case FONT_NAME: {
2195 static const WCHAR sysW[] = {'S','y','s','t','e','m',0};
2196 SysFreeString(font->props[id].str);
2197 font->props[id].str = SysAllocString(sysW);
2198 break;
2200 case FONT_WEIGHT:
2201 font->props[id].l = FW_NORMAL;
2202 break;
2203 default:
2204 FIXME("font property %d not handled\n", id);
2209 static void textfont_reset_to_undefined(ITextFontImpl *font)
2211 enum textfont_prop_id id;
2213 for (id = FONT_PROPID_FIRST; id < FONT_PROPID_LAST; id++) {
2214 switch (id)
2216 case FONT_ALLCAPS:
2217 case FONT_ANIMATION:
2218 case FONT_BOLD:
2219 case FONT_EMBOSS:
2220 case FONT_HIDDEN:
2221 case FONT_ENGRAVE:
2222 case FONT_ITALIC:
2223 case FONT_OUTLINE:
2224 case FONT_PROTECTED:
2225 case FONT_SHADOW:
2226 case FONT_SMALLCAPS:
2227 case FONT_STRIKETHROUGH:
2228 case FONT_SUBSCRIPT:
2229 case FONT_SUPERSCRIPT:
2230 case FONT_UNDERLINE:
2231 case FONT_BACKCOLOR:
2232 case FONT_FORECOLOR:
2233 case FONT_LANGID:
2234 case FONT_WEIGHT:
2235 font->props[id].l = tomUndefined;
2236 break;
2237 case FONT_KERNING:
2238 case FONT_POSITION:
2239 case FONT_SIZE:
2240 case FONT_SPACING:
2241 font->props[id].f = tomUndefined;
2242 break;
2243 case FONT_NAME:
2244 break;
2245 default:
2246 FIXME("font property %d not handled\n", id);
2251 static void textfont_apply_range_props(ITextFontImpl *font)
2253 enum textfont_prop_id propid;
2254 for (propid = FONT_PROPID_FIRST; propid < FONT_PROPID_LAST; propid++)
2255 set_textfont_prop(font, propid, &font->props[propid]);
2258 static HRESULT WINAPI TextFont_Reset(ITextFont *iface, LONG value)
2260 ITextFontImpl *This = impl_from_ITextFont(iface);
2262 TRACE("(%p)->(%d)\n", This, value);
2264 /* If font is attached to a range, released or not, we can't
2265 reset to undefined */
2266 if (This->range) {
2267 if (!get_range_reole(This->range))
2268 return CO_E_RELEASED;
2270 switch (value)
2272 case tomUndefined:
2273 return E_INVALIDARG;
2274 case tomCacheParms:
2275 textfont_cache_range_props(This);
2276 This->get_cache_enabled = TRUE;
2277 break;
2278 case tomTrackParms:
2279 This->get_cache_enabled = FALSE;
2280 break;
2281 case tomApplyLater:
2282 This->set_cache_enabled = TRUE;
2283 break;
2284 case tomApplyNow:
2285 This->set_cache_enabled = FALSE;
2286 textfont_apply_range_props(This);
2287 break;
2288 default:
2289 FIXME("reset mode %d not supported\n", value);
2292 return S_OK;
2294 else {
2295 switch (value)
2297 /* reset to global defaults */
2298 case tomDefault:
2299 textfont_reset_to_default(This);
2300 return S_OK;
2301 /* all properties are set to tomUndefined, font name is retained */
2302 case tomUndefined:
2303 textfont_reset_to_undefined(This);
2304 return S_OK;
2305 case tomApplyNow:
2306 case tomApplyLater:
2307 case tomTrackParms:
2308 case tomCacheParms:
2309 return S_OK;
2313 FIXME("reset mode %d not supported\n", value);
2314 return E_NOTIMPL;
2317 static HRESULT WINAPI TextFont_GetStyle(ITextFont *iface, LONG *value)
2319 ITextFontImpl *This = impl_from_ITextFont(iface);
2320 FIXME("(%p)->(%p): stub\n", This, value);
2321 return E_NOTIMPL;
2324 static HRESULT WINAPI TextFont_SetStyle(ITextFont *iface, LONG value)
2326 ITextFontImpl *This = impl_from_ITextFont(iface);
2327 FIXME("(%p)->(%d): stub\n", This, value);
2328 return E_NOTIMPL;
2331 static HRESULT WINAPI TextFont_GetAllCaps(ITextFont *iface, LONG *value)
2333 ITextFontImpl *This = impl_from_ITextFont(iface);
2334 TRACE("(%p)->(%p)\n", This, value);
2335 return get_textfont_propl(This, FONT_ALLCAPS, value);
2338 static HRESULT WINAPI TextFont_SetAllCaps(ITextFont *iface, LONG value)
2340 ITextFontImpl *This = impl_from_ITextFont(iface);
2341 FIXME("(%p)->(%d): stub\n", This, value);
2342 return E_NOTIMPL;
2345 static HRESULT WINAPI TextFont_GetAnimation(ITextFont *iface, LONG *value)
2347 ITextFontImpl *This = impl_from_ITextFont(iface);
2348 TRACE("(%p)->(%p)\n", This, value);
2349 return get_textfont_propl(This, FONT_ANIMATION, value);
2352 static HRESULT WINAPI TextFont_SetAnimation(ITextFont *iface, LONG value)
2354 ITextFontImpl *This = impl_from_ITextFont(iface);
2355 FIXME("(%p)->(%d): stub\n", This, value);
2356 return E_NOTIMPL;
2359 static HRESULT WINAPI TextFont_GetBackColor(ITextFont *iface, LONG *value)
2361 ITextFontImpl *This = impl_from_ITextFont(iface);
2362 TRACE("(%p)->(%p)\n", This, value);
2363 return get_textfont_propl(This, FONT_BACKCOLOR, value);
2366 static HRESULT WINAPI TextFont_SetBackColor(ITextFont *iface, LONG value)
2368 ITextFontImpl *This = impl_from_ITextFont(iface);
2369 FIXME("(%p)->(%d): stub\n", This, value);
2370 return E_NOTIMPL;
2373 static HRESULT WINAPI TextFont_GetBold(ITextFont *iface, LONG *value)
2375 ITextFontImpl *This = impl_from_ITextFont(iface);
2376 TRACE("(%p)->(%p)\n", This, value);
2377 return get_textfont_propl(This, FONT_BOLD, value);
2380 static HRESULT WINAPI TextFont_SetBold(ITextFont *iface, LONG value)
2382 ITextFontImpl *This = impl_from_ITextFont(iface);
2383 FIXME("(%p)->(%d): stub\n", This, value);
2384 return E_NOTIMPL;
2387 static HRESULT WINAPI TextFont_GetEmboss(ITextFont *iface, LONG *value)
2389 ITextFontImpl *This = impl_from_ITextFont(iface);
2390 TRACE("(%p)->(%p)\n", This, value);
2391 return get_textfont_propl(This, FONT_EMBOSS, value);
2394 static HRESULT WINAPI TextFont_SetEmboss(ITextFont *iface, LONG value)
2396 ITextFontImpl *This = impl_from_ITextFont(iface);
2397 FIXME("(%p)->(%d): stub\n", This, value);
2398 return E_NOTIMPL;
2401 static HRESULT WINAPI TextFont_GetForeColor(ITextFont *iface, LONG *value)
2403 ITextFontImpl *This = impl_from_ITextFont(iface);
2404 TRACE("(%p)->(%p)\n", This, value);
2405 return get_textfont_propl(This, FONT_FORECOLOR, value);
2408 static HRESULT WINAPI TextFont_SetForeColor(ITextFont *iface, LONG value)
2410 ITextFontImpl *This = impl_from_ITextFont(iface);
2411 FIXME("(%p)->(%d): stub\n", This, value);
2412 return E_NOTIMPL;
2415 static HRESULT WINAPI TextFont_GetHidden(ITextFont *iface, LONG *value)
2417 ITextFontImpl *This = impl_from_ITextFont(iface);
2418 TRACE("(%p)->(%p)\n", This, value);
2419 return get_textfont_propl(This, FONT_HIDDEN, value);
2422 static HRESULT WINAPI TextFont_SetHidden(ITextFont *iface, LONG value)
2424 ITextFontImpl *This = impl_from_ITextFont(iface);
2425 FIXME("(%p)->(%d): stub\n", This, value);
2426 return E_NOTIMPL;
2429 static HRESULT WINAPI TextFont_GetEngrave(ITextFont *iface, LONG *value)
2431 ITextFontImpl *This = impl_from_ITextFont(iface);
2432 TRACE("(%p)->(%p)\n", This, value);
2433 return get_textfont_propl(This, FONT_ENGRAVE, value);
2436 static HRESULT WINAPI TextFont_SetEngrave(ITextFont *iface, LONG value)
2438 ITextFontImpl *This = impl_from_ITextFont(iface);
2439 FIXME("(%p)->(%d): stub\n", This, value);
2440 return E_NOTIMPL;
2443 static HRESULT WINAPI TextFont_GetItalic(ITextFont *iface, LONG *value)
2445 ITextFontImpl *This = impl_from_ITextFont(iface);
2446 TRACE("(%p)->(%p)\n", This, value);
2447 return get_textfont_propl(This, FONT_ITALIC, value);
2450 static HRESULT WINAPI TextFont_SetItalic(ITextFont *iface, LONG value)
2452 ITextFontImpl *This = impl_from_ITextFont(iface);
2453 TRACE("(%p)->(%d)\n", This, value);
2454 return set_textfont_propd(This, FONT_ITALIC, value);
2457 static HRESULT WINAPI TextFont_GetKerning(ITextFont *iface, FLOAT *value)
2459 ITextFontImpl *This = impl_from_ITextFont(iface);
2460 TRACE("(%p)->(%p)\n", This, value);
2461 return get_textfont_propf(This, FONT_KERNING, value);
2464 static HRESULT WINAPI TextFont_SetKerning(ITextFont *iface, FLOAT value)
2466 ITextFontImpl *This = impl_from_ITextFont(iface);
2467 FIXME("(%p)->(%.2f): stub\n", This, value);
2468 return E_NOTIMPL;
2471 static HRESULT WINAPI TextFont_GetLanguageID(ITextFont *iface, LONG *value)
2473 ITextFontImpl *This = impl_from_ITextFont(iface);
2474 TRACE("(%p)->(%p)\n", This, value);
2475 return get_textfont_propl(This, FONT_LANGID, value);
2478 static HRESULT WINAPI TextFont_SetLanguageID(ITextFont *iface, LONG value)
2480 ITextFontImpl *This = impl_from_ITextFont(iface);
2481 FIXME("(%p)->(%d): stub\n", This, value);
2482 return E_NOTIMPL;
2485 static HRESULT WINAPI TextFont_GetName(ITextFont *iface, BSTR *value)
2487 ITextFontImpl *This = impl_from_ITextFont(iface);
2489 TRACE("(%p)->(%p)\n", This, value);
2491 if (!value)
2492 return E_INVALIDARG;
2494 *value = NULL;
2496 if (!This->range) {
2497 if (This->props[FONT_NAME].str)
2498 *value = SysAllocString(This->props[FONT_NAME].str);
2499 else
2500 *value = SysAllocStringLen(NULL, 0);
2501 return *value ? S_OK : E_OUTOFMEMORY;
2504 return textfont_getname_from_range(This->range, value);
2507 static HRESULT WINAPI TextFont_SetName(ITextFont *iface, BSTR value)
2509 ITextFontImpl *This = impl_from_ITextFont(iface);
2510 FIXME("(%p)->(%s): stub\n", This, debugstr_w(value));
2511 return E_NOTIMPL;
2514 static HRESULT WINAPI TextFont_GetOutline(ITextFont *iface, LONG *value)
2516 ITextFontImpl *This = impl_from_ITextFont(iface);
2517 TRACE("(%p)->(%p)\n", This, value);
2518 return get_textfont_propl(This, FONT_OUTLINE, value);
2521 static HRESULT WINAPI TextFont_SetOutline(ITextFont *iface, LONG value)
2523 ITextFontImpl *This = impl_from_ITextFont(iface);
2524 FIXME("(%p)->(%d): stub\n", This, value);
2525 return E_NOTIMPL;
2528 static HRESULT WINAPI TextFont_GetPosition(ITextFont *iface, FLOAT *value)
2530 ITextFontImpl *This = impl_from_ITextFont(iface);
2531 TRACE("(%p)->(%p)\n", This, value);
2532 return get_textfont_propf(This, FONT_POSITION, value);
2535 static HRESULT WINAPI TextFont_SetPosition(ITextFont *iface, FLOAT value)
2537 ITextFontImpl *This = impl_from_ITextFont(iface);
2538 FIXME("(%p)->(%.2f): stub\n", This, value);
2539 return E_NOTIMPL;
2542 static HRESULT WINAPI TextFont_GetProtected(ITextFont *iface, LONG *value)
2544 ITextFontImpl *This = impl_from_ITextFont(iface);
2545 TRACE("(%p)->(%p)\n", This, value);
2546 return get_textfont_propl(This, FONT_PROTECTED, value);
2549 static HRESULT WINAPI TextFont_SetProtected(ITextFont *iface, LONG value)
2551 ITextFontImpl *This = impl_from_ITextFont(iface);
2552 FIXME("(%p)->(%d): stub\n", This, value);
2553 return E_NOTIMPL;
2556 static HRESULT WINAPI TextFont_GetShadow(ITextFont *iface, LONG *value)
2558 ITextFontImpl *This = impl_from_ITextFont(iface);
2559 TRACE("(%p)->(%p)\n", This, value);
2560 return get_textfont_propl(This, FONT_SHADOW, value);
2563 static HRESULT WINAPI TextFont_SetShadow(ITextFont *iface, LONG value)
2565 ITextFontImpl *This = impl_from_ITextFont(iface);
2566 FIXME("(%p)->(%d): stub\n", This, value);
2567 return E_NOTIMPL;
2570 static HRESULT WINAPI TextFont_GetSize(ITextFont *iface, FLOAT *value)
2572 ITextFontImpl *This = impl_from_ITextFont(iface);
2573 TRACE("(%p)->(%p)\n", This, value);
2574 return get_textfont_propf(This, FONT_SIZE, value);
2577 static HRESULT WINAPI TextFont_SetSize(ITextFont *iface, FLOAT value)
2579 ITextFontImpl *This = impl_from_ITextFont(iface);
2580 FIXME("(%p)->(%.2f): stub\n", This, value);
2581 return E_NOTIMPL;
2584 static HRESULT WINAPI TextFont_GetSmallCaps(ITextFont *iface, LONG *value)
2586 ITextFontImpl *This = impl_from_ITextFont(iface);
2587 TRACE("(%p)->(%p)\n", This, value);
2588 return get_textfont_propl(This, FONT_SMALLCAPS, value);
2591 static HRESULT WINAPI TextFont_SetSmallCaps(ITextFont *iface, LONG value)
2593 ITextFontImpl *This = impl_from_ITextFont(iface);
2594 FIXME("(%p)->(%d): stub\n", This, value);
2595 return E_NOTIMPL;
2598 static HRESULT WINAPI TextFont_GetSpacing(ITextFont *iface, FLOAT *value)
2600 ITextFontImpl *This = impl_from_ITextFont(iface);
2601 TRACE("(%p)->(%p)\n", This, value);
2602 return get_textfont_propf(This, FONT_SPACING, value);
2605 static HRESULT WINAPI TextFont_SetSpacing(ITextFont *iface, FLOAT value)
2607 ITextFontImpl *This = impl_from_ITextFont(iface);
2608 FIXME("(%p)->(%.2f): stub\n", This, value);
2609 return E_NOTIMPL;
2612 static HRESULT WINAPI TextFont_GetStrikeThrough(ITextFont *iface, LONG *value)
2614 ITextFontImpl *This = impl_from_ITextFont(iface);
2615 TRACE("(%p)->(%p)\n", This, value);
2616 return get_textfont_propl(This, FONT_STRIKETHROUGH, value);
2619 static HRESULT WINAPI TextFont_SetStrikeThrough(ITextFont *iface, LONG value)
2621 ITextFontImpl *This = impl_from_ITextFont(iface);
2622 FIXME("(%p)->(%d): stub\n", This, value);
2623 return E_NOTIMPL;
2626 static HRESULT WINAPI TextFont_GetSubscript(ITextFont *iface, LONG *value)
2628 ITextFontImpl *This = impl_from_ITextFont(iface);
2629 TRACE("(%p)->(%p)\n", This, value);
2630 return get_textfont_propl(This, FONT_SUBSCRIPT, value);
2633 static HRESULT WINAPI TextFont_SetSubscript(ITextFont *iface, LONG value)
2635 ITextFontImpl *This = impl_from_ITextFont(iface);
2636 FIXME("(%p)->(%d): stub\n", This, value);
2637 return E_NOTIMPL;
2640 static HRESULT WINAPI TextFont_GetSuperscript(ITextFont *iface, LONG *value)
2642 ITextFontImpl *This = impl_from_ITextFont(iface);
2643 TRACE("(%p)->(%p)\n", This, value);
2644 return get_textfont_propl(This, FONT_SUPERSCRIPT, value);
2647 static HRESULT WINAPI TextFont_SetSuperscript(ITextFont *iface, LONG value)
2649 ITextFontImpl *This = impl_from_ITextFont(iface);
2650 FIXME("(%p)->(%d): stub\n", This, value);
2651 return E_NOTIMPL;
2654 static HRESULT WINAPI TextFont_GetUnderline(ITextFont *iface, LONG *value)
2656 ITextFontImpl *This = impl_from_ITextFont(iface);
2657 TRACE("(%p)->(%p)\n", This, value);
2658 return get_textfont_propl(This, FONT_UNDERLINE, value);
2661 static HRESULT WINAPI TextFont_SetUnderline(ITextFont *iface, LONG value)
2663 ITextFontImpl *This = impl_from_ITextFont(iface);
2664 FIXME("(%p)->(%d): stub\n", This, value);
2665 return E_NOTIMPL;
2668 static HRESULT WINAPI TextFont_GetWeight(ITextFont *iface, LONG *value)
2670 ITextFontImpl *This = impl_from_ITextFont(iface);
2671 TRACE("(%p)->(%p)\n", This, value);
2672 return get_textfont_propl(This, FONT_WEIGHT, value);
2675 static HRESULT WINAPI TextFont_SetWeight(ITextFont *iface, LONG value)
2677 ITextFontImpl *This = impl_from_ITextFont(iface);
2678 FIXME("(%p)->(%d): stub\n", This, value);
2679 return E_NOTIMPL;
2682 static ITextFontVtbl textfontvtbl = {
2683 TextFont_QueryInterface,
2684 TextFont_AddRef,
2685 TextFont_Release,
2686 TextFont_GetTypeInfoCount,
2687 TextFont_GetTypeInfo,
2688 TextFont_GetIDsOfNames,
2689 TextFont_Invoke,
2690 TextFont_GetDuplicate,
2691 TextFont_SetDuplicate,
2692 TextFont_CanChange,
2693 TextFont_IsEqual,
2694 TextFont_Reset,
2695 TextFont_GetStyle,
2696 TextFont_SetStyle,
2697 TextFont_GetAllCaps,
2698 TextFont_SetAllCaps,
2699 TextFont_GetAnimation,
2700 TextFont_SetAnimation,
2701 TextFont_GetBackColor,
2702 TextFont_SetBackColor,
2703 TextFont_GetBold,
2704 TextFont_SetBold,
2705 TextFont_GetEmboss,
2706 TextFont_SetEmboss,
2707 TextFont_GetForeColor,
2708 TextFont_SetForeColor,
2709 TextFont_GetHidden,
2710 TextFont_SetHidden,
2711 TextFont_GetEngrave,
2712 TextFont_SetEngrave,
2713 TextFont_GetItalic,
2714 TextFont_SetItalic,
2715 TextFont_GetKerning,
2716 TextFont_SetKerning,
2717 TextFont_GetLanguageID,
2718 TextFont_SetLanguageID,
2719 TextFont_GetName,
2720 TextFont_SetName,
2721 TextFont_GetOutline,
2722 TextFont_SetOutline,
2723 TextFont_GetPosition,
2724 TextFont_SetPosition,
2725 TextFont_GetProtected,
2726 TextFont_SetProtected,
2727 TextFont_GetShadow,
2728 TextFont_SetShadow,
2729 TextFont_GetSize,
2730 TextFont_SetSize,
2731 TextFont_GetSmallCaps,
2732 TextFont_SetSmallCaps,
2733 TextFont_GetSpacing,
2734 TextFont_SetSpacing,
2735 TextFont_GetStrikeThrough,
2736 TextFont_SetStrikeThrough,
2737 TextFont_GetSubscript,
2738 TextFont_SetSubscript,
2739 TextFont_GetSuperscript,
2740 TextFont_SetSuperscript,
2741 TextFont_GetUnderline,
2742 TextFont_SetUnderline,
2743 TextFont_GetWeight,
2744 TextFont_SetWeight
2747 static HRESULT create_textfont(ITextRange *range, const ITextFontImpl *src, ITextFont **ret)
2749 ITextFontImpl *font;
2751 *ret = NULL;
2752 font = heap_alloc(sizeof(*font));
2753 if (!font)
2754 return E_OUTOFMEMORY;
2756 font->ITextFont_iface.lpVtbl = &textfontvtbl;
2757 font->ref = 1;
2759 if (src) {
2760 font->range = NULL;
2761 font->get_cache_enabled = TRUE;
2762 font->set_cache_enabled = TRUE;
2763 memcpy(&font->props, &src->props, sizeof(font->props));
2764 if (font->props[FONT_NAME].str)
2765 font->props[FONT_NAME].str = SysAllocString(font->props[FONT_NAME].str);
2767 else {
2768 font->range = range;
2769 ITextRange_AddRef(range);
2771 /* cache current properties */
2772 font->get_cache_enabled = FALSE;
2773 font->set_cache_enabled = FALSE;
2774 textfont_cache_range_props(font);
2777 *ret = &font->ITextFont_iface;
2778 return S_OK;
2781 /* ITextPara */
2782 static HRESULT WINAPI TextPara_QueryInterface(ITextPara *iface, REFIID riid, void **ppv)
2784 ITextParaImpl *This = impl_from_ITextPara(iface);
2786 TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
2788 if (IsEqualIID(riid, &IID_ITextPara) ||
2789 IsEqualIID(riid, &IID_IDispatch) ||
2790 IsEqualIID(riid, &IID_IUnknown))
2792 *ppv = iface;
2793 ITextPara_AddRef(iface);
2794 return S_OK;
2797 *ppv = NULL;
2798 return E_NOINTERFACE;
2801 static ULONG WINAPI TextPara_AddRef(ITextPara *iface)
2803 ITextParaImpl *This = impl_from_ITextPara(iface);
2804 ULONG ref = InterlockedIncrement(&This->ref);
2805 TRACE("(%p)->(%u)\n", This, ref);
2806 return ref;
2809 static ULONG WINAPI TextPara_Release(ITextPara *iface)
2811 ITextParaImpl *This = impl_from_ITextPara(iface);
2812 ULONG ref = InterlockedDecrement(&This->ref);
2814 TRACE("(%p)->(%u)\n", This, ref);
2816 if (!ref)
2818 ITextRange_Release(This->range);
2819 heap_free(This);
2822 return ref;
2825 static HRESULT WINAPI TextPara_GetTypeInfoCount(ITextPara *iface, UINT *pctinfo)
2827 ITextParaImpl *This = impl_from_ITextPara(iface);
2828 TRACE("(%p)->(%p)\n", This, pctinfo);
2829 *pctinfo = 1;
2830 return S_OK;
2833 static HRESULT WINAPI TextPara_GetTypeInfo(ITextPara *iface, UINT iTInfo, LCID lcid,
2834 ITypeInfo **ppTInfo)
2836 ITextParaImpl *This = impl_from_ITextPara(iface);
2837 HRESULT hr;
2839 TRACE("(%p)->(%u,%d,%p)\n", This, iTInfo, lcid, ppTInfo);
2841 hr = get_typeinfo(ITextPara_tid, ppTInfo);
2842 if (SUCCEEDED(hr))
2843 ITypeInfo_AddRef(*ppTInfo);
2844 return hr;
2847 static HRESULT WINAPI TextPara_GetIDsOfNames(ITextPara *iface, REFIID riid,
2848 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
2850 ITextParaImpl *This = impl_from_ITextPara(iface);
2851 ITypeInfo *ti;
2852 HRESULT hr;
2854 TRACE("(%p)->(%p,%p,%u,%d,%p)\n", This, riid, rgszNames, cNames, lcid,
2855 rgDispId);
2857 hr = get_typeinfo(ITextPara_tid, &ti);
2858 if (SUCCEEDED(hr))
2859 hr = ITypeInfo_GetIDsOfNames(ti, rgszNames, cNames, rgDispId);
2860 return hr;
2863 static HRESULT WINAPI TextPara_Invoke(
2864 ITextPara *iface,
2865 DISPID dispIdMember,
2866 REFIID riid,
2867 LCID lcid,
2868 WORD wFlags,
2869 DISPPARAMS *pDispParams,
2870 VARIANT *pVarResult,
2871 EXCEPINFO *pExcepInfo,
2872 UINT *puArgErr)
2874 ITextParaImpl *This = impl_from_ITextPara(iface);
2875 ITypeInfo *ti;
2876 HRESULT hr;
2878 TRACE("(%p)->(%d,%p,%d,%u,%p,%p,%p,%p)\n", This, dispIdMember, riid, lcid,
2879 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
2881 hr = get_typeinfo(ITextPara_tid, &ti);
2882 if (SUCCEEDED(hr))
2883 hr = ITypeInfo_Invoke(ti, iface, dispIdMember, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
2884 return hr;
2887 static HRESULT WINAPI TextPara_GetDuplicate(ITextPara *iface, ITextPara **ret)
2889 ITextParaImpl *This = impl_from_ITextPara(iface);
2890 FIXME("(%p)->(%p)\n", This, ret);
2891 return E_NOTIMPL;
2894 static HRESULT WINAPI TextPara_SetDuplicate(ITextPara *iface, ITextPara *para)
2896 ITextParaImpl *This = impl_from_ITextPara(iface);
2897 FIXME("(%p)->(%p)\n", This, para);
2898 return E_NOTIMPL;
2901 static HRESULT WINAPI TextPara_CanChange(ITextPara *iface, LONG *ret)
2903 ITextParaImpl *This = impl_from_ITextPara(iface);
2904 FIXME("(%p)->(%p)\n", This, ret);
2905 return E_NOTIMPL;
2908 static HRESULT WINAPI TextPara_IsEqual(ITextPara *iface, ITextPara *para, LONG *ret)
2910 ITextParaImpl *This = impl_from_ITextPara(iface);
2911 FIXME("(%p)->(%p %p)\n", This, para, ret);
2912 return E_NOTIMPL;
2915 static HRESULT WINAPI TextPara_Reset(ITextPara *iface, LONG value)
2917 ITextParaImpl *This = impl_from_ITextPara(iface);
2918 FIXME("(%p)->(%d)\n", This, value);
2919 return E_NOTIMPL;
2922 static HRESULT WINAPI TextPara_GetStyle(ITextPara *iface, LONG *value)
2924 ITextParaImpl *This = impl_from_ITextPara(iface);
2925 FIXME("(%p)->(%p)\n", This, value);
2926 return E_NOTIMPL;
2929 static HRESULT WINAPI TextPara_SetStyle(ITextPara *iface, LONG value)
2931 ITextParaImpl *This = impl_from_ITextPara(iface);
2932 FIXME("(%p)->(%d)\n", This, value);
2933 return E_NOTIMPL;
2936 static HRESULT WINAPI TextPara_GetAlignment(ITextPara *iface, LONG *value)
2938 ITextParaImpl *This = impl_from_ITextPara(iface);
2939 FIXME("(%p)->(%p)\n", This, value);
2940 return E_NOTIMPL;
2943 static HRESULT WINAPI TextPara_SetAlignment(ITextPara *iface, LONG value)
2945 ITextParaImpl *This = impl_from_ITextPara(iface);
2946 FIXME("(%p)->(%d)\n", This, value);
2947 return E_NOTIMPL;
2950 static HRESULT WINAPI TextPara_GetHyphenation(ITextPara *iface, LONG *value)
2952 ITextParaImpl *This = impl_from_ITextPara(iface);
2953 FIXME("(%p)->(%p)\n", This, value);
2954 return E_NOTIMPL;
2957 static HRESULT WINAPI TextPara_SetHyphenation(ITextPara *iface, LONG value)
2959 ITextParaImpl *This = impl_from_ITextPara(iface);
2960 FIXME("(%p)->(%d)\n", This, value);
2961 return E_NOTIMPL;
2964 static HRESULT WINAPI TextPara_GetFirstLineIndent(ITextPara *iface, FLOAT *value)
2966 ITextParaImpl *This = impl_from_ITextPara(iface);
2967 FIXME("(%p)->(%p)\n", This, value);
2968 return E_NOTIMPL;
2971 static HRESULT WINAPI TextPara_GetKeepTogether(ITextPara *iface, LONG *value)
2973 ITextParaImpl *This = impl_from_ITextPara(iface);
2974 FIXME("(%p)->(%p)\n", This, value);
2975 return E_NOTIMPL;
2978 static HRESULT WINAPI TextPara_SetKeepTogether(ITextPara *iface, LONG value)
2980 ITextParaImpl *This = impl_from_ITextPara(iface);
2981 FIXME("(%p)->(%d)\n", This, value);
2982 return E_NOTIMPL;
2985 static HRESULT WINAPI TextPara_GetKeepWithNext(ITextPara *iface, LONG *value)
2987 ITextParaImpl *This = impl_from_ITextPara(iface);
2988 FIXME("(%p)->(%p)\n", This, value);
2989 return E_NOTIMPL;
2992 static HRESULT WINAPI TextPara_SetKeepWithNext(ITextPara *iface, LONG value)
2994 ITextParaImpl *This = impl_from_ITextPara(iface);
2995 FIXME("(%p)->(%d)\n", This, value);
2996 return E_NOTIMPL;
2999 static HRESULT WINAPI TextPara_GetLeftIndent(ITextPara *iface, FLOAT *value)
3001 ITextParaImpl *This = impl_from_ITextPara(iface);
3002 FIXME("(%p)->(%p)\n", This, value);
3003 return E_NOTIMPL;
3006 static HRESULT WINAPI TextPara_GetLineSpacing(ITextPara *iface, FLOAT *value)
3008 ITextParaImpl *This = impl_from_ITextPara(iface);
3009 FIXME("(%p)->(%p)\n", This, value);
3010 return E_NOTIMPL;
3013 static HRESULT WINAPI TextPara_GetLineSpacingRule(ITextPara *iface, LONG *value)
3015 ITextParaImpl *This = impl_from_ITextPara(iface);
3016 FIXME("(%p)->(%p)\n", This, value);
3017 return E_NOTIMPL;
3020 static HRESULT WINAPI TextPara_GetListAlignment(ITextPara *iface, LONG *value)
3022 ITextParaImpl *This = impl_from_ITextPara(iface);
3023 FIXME("(%p)->(%p)\n", This, value);
3024 return E_NOTIMPL;
3027 static HRESULT WINAPI TextPara_SetListAlignment(ITextPara *iface, LONG value)
3029 ITextParaImpl *This = impl_from_ITextPara(iface);
3030 FIXME("(%p)->(%d)\n", This, value);
3031 return E_NOTIMPL;
3034 static HRESULT WINAPI TextPara_GetListLevelIndex(ITextPara *iface, LONG *value)
3036 ITextParaImpl *This = impl_from_ITextPara(iface);
3037 FIXME("(%p)->(%p)\n", This, value);
3038 return E_NOTIMPL;
3041 static HRESULT WINAPI TextPara_SetListLevelIndex(ITextPara *iface, LONG value)
3043 ITextParaImpl *This = impl_from_ITextPara(iface);
3044 FIXME("(%p)->(%d)\n", This, value);
3045 return E_NOTIMPL;
3048 static HRESULT WINAPI TextPara_GetListStart(ITextPara *iface, LONG *value)
3050 ITextParaImpl *This = impl_from_ITextPara(iface);
3051 FIXME("(%p)->(%p)\n", This, value);
3052 return E_NOTIMPL;
3055 static HRESULT WINAPI TextPara_SetListStart(ITextPara *iface, LONG value)
3057 ITextParaImpl *This = impl_from_ITextPara(iface);
3058 FIXME("(%p)->(%d)\n", This, value);
3059 return E_NOTIMPL;
3062 static HRESULT WINAPI TextPara_GetListTab(ITextPara *iface, FLOAT *value)
3064 ITextParaImpl *This = impl_from_ITextPara(iface);
3065 FIXME("(%p)->(%p)\n", This, value);
3066 return E_NOTIMPL;
3069 static HRESULT WINAPI TextPara_SetListTab(ITextPara *iface, FLOAT value)
3071 ITextParaImpl *This = impl_from_ITextPara(iface);
3072 FIXME("(%p)->(%.2f)\n", This, value);
3073 return E_NOTIMPL;
3076 static HRESULT WINAPI TextPara_GetListType(ITextPara *iface, LONG *value)
3078 ITextParaImpl *This = impl_from_ITextPara(iface);
3079 FIXME("(%p)->(%p)\n", This, value);
3080 return E_NOTIMPL;
3083 static HRESULT WINAPI TextPara_SetListType(ITextPara *iface, LONG value)
3085 ITextParaImpl *This = impl_from_ITextPara(iface);
3086 FIXME("(%p)->(%d)\n", This, value);
3087 return E_NOTIMPL;
3090 static HRESULT WINAPI TextPara_GetNoLineNumber(ITextPara *iface, LONG *value)
3092 ITextParaImpl *This = impl_from_ITextPara(iface);
3093 FIXME("(%p)->(%p)\n", This, value);
3094 return E_NOTIMPL;
3097 static HRESULT WINAPI TextPara_SetNoLineNumber(ITextPara *iface, LONG value)
3099 ITextParaImpl *This = impl_from_ITextPara(iface);
3100 FIXME("(%p)->(%d)\n", This, value);
3101 return E_NOTIMPL;
3104 static HRESULT WINAPI TextPara_GetPageBreakBefore(ITextPara *iface, LONG *value)
3106 ITextParaImpl *This = impl_from_ITextPara(iface);
3107 FIXME("(%p)->(%p)\n", This, value);
3108 return E_NOTIMPL;
3111 static HRESULT WINAPI TextPara_SetPageBreakBefore(ITextPara *iface, LONG value)
3113 ITextParaImpl *This = impl_from_ITextPara(iface);
3114 FIXME("(%p)->(%d)\n", This, value);
3115 return E_NOTIMPL;
3118 static HRESULT WINAPI TextPara_GetRightIndent(ITextPara *iface, FLOAT *value)
3120 ITextParaImpl *This = impl_from_ITextPara(iface);
3121 FIXME("(%p)->(%p)\n", This, value);
3122 return E_NOTIMPL;
3125 static HRESULT WINAPI TextPara_SetRightIndent(ITextPara *iface, FLOAT value)
3127 ITextParaImpl *This = impl_from_ITextPara(iface);
3128 FIXME("(%p)->(%.2f)\n", This, value);
3129 return E_NOTIMPL;
3132 static HRESULT WINAPI TextPara_SetIndents(ITextPara *iface, FLOAT StartIndent, FLOAT LeftIndent, FLOAT RightIndent)
3134 ITextParaImpl *This = impl_from_ITextPara(iface);
3135 FIXME("(%p)->(%.2f %.2f %.2f)\n", This, StartIndent, LeftIndent, RightIndent);
3136 return E_NOTIMPL;
3139 static HRESULT WINAPI TextPara_SetLineSpacing(ITextPara *iface, LONG LineSpacingRule, FLOAT LineSpacing)
3141 ITextParaImpl *This = impl_from_ITextPara(iface);
3142 FIXME("(%p)->(%d %.2f)\n", This, LineSpacingRule, LineSpacing);
3143 return E_NOTIMPL;
3146 static HRESULT WINAPI TextPara_GetSpaceAfter(ITextPara *iface, FLOAT *value)
3148 ITextParaImpl *This = impl_from_ITextPara(iface);
3149 FIXME("(%p)->(%p)\n", This, value);
3150 return E_NOTIMPL;
3153 static HRESULT WINAPI TextPara_SetSpaceAfter(ITextPara *iface, FLOAT value)
3155 ITextParaImpl *This = impl_from_ITextPara(iface);
3156 FIXME("(%p)->(%.2f)\n", This, value);
3157 return E_NOTIMPL;
3160 static HRESULT WINAPI TextPara_GetSpaceBefore(ITextPara *iface, FLOAT *value)
3162 ITextParaImpl *This = impl_from_ITextPara(iface);
3163 FIXME("(%p)->(%p)\n", This, value);
3164 return E_NOTIMPL;
3167 static HRESULT WINAPI TextPara_SetSpaceBefore(ITextPara *iface, FLOAT value)
3169 ITextParaImpl *This = impl_from_ITextPara(iface);
3170 FIXME("(%p)->(%.2f)\n", This, value);
3171 return E_NOTIMPL;
3174 static HRESULT WINAPI TextPara_GetWidowControl(ITextPara *iface, LONG *value)
3176 ITextParaImpl *This = impl_from_ITextPara(iface);
3177 FIXME("(%p)->(%p)\n", This, value);
3178 return E_NOTIMPL;
3181 static HRESULT WINAPI TextPara_SetWidowControl(ITextPara *iface, LONG value)
3183 ITextParaImpl *This = impl_from_ITextPara(iface);
3184 FIXME("(%p)->(%d)\n", This, value);
3185 return E_NOTIMPL;
3188 static HRESULT WINAPI TextPara_GetTabCount(ITextPara *iface, LONG *value)
3190 ITextParaImpl *This = impl_from_ITextPara(iface);
3191 FIXME("(%p)->(%p)\n", This, value);
3192 return E_NOTIMPL;
3195 static HRESULT WINAPI TextPara_AddTab(ITextPara *iface, FLOAT tbPos, LONG tbAlign, LONG tbLeader)
3197 ITextParaImpl *This = impl_from_ITextPara(iface);
3198 FIXME("(%p)->(%.2f %d %d)\n", This, tbPos, tbAlign, tbLeader);
3199 return E_NOTIMPL;
3202 static HRESULT WINAPI TextPara_ClearAllTabs(ITextPara *iface)
3204 ITextParaImpl *This = impl_from_ITextPara(iface);
3205 FIXME("(%p)\n", This);
3206 return E_NOTIMPL;
3209 static HRESULT WINAPI TextPara_DeleteTab(ITextPara *iface, FLOAT pos)
3211 ITextParaImpl *This = impl_from_ITextPara(iface);
3212 FIXME("(%p)->(%.2f)\n", This, pos);
3213 return E_NOTIMPL;
3216 static HRESULT WINAPI TextPara_GetTab(ITextPara *iface, LONG iTab, FLOAT *ptbPos, LONG *ptbAlign, LONG *ptbLeader)
3218 ITextParaImpl *This = impl_from_ITextPara(iface);
3219 FIXME("(%p)->(%d %p %p %p)\n", This, iTab, ptbPos, ptbAlign, ptbLeader);
3220 return E_NOTIMPL;
3223 static ITextParaVtbl textparavtbl = {
3224 TextPara_QueryInterface,
3225 TextPara_AddRef,
3226 TextPara_Release,
3227 TextPara_GetTypeInfoCount,
3228 TextPara_GetTypeInfo,
3229 TextPara_GetIDsOfNames,
3230 TextPara_Invoke,
3231 TextPara_GetDuplicate,
3232 TextPara_SetDuplicate,
3233 TextPara_CanChange,
3234 TextPara_IsEqual,
3235 TextPara_Reset,
3236 TextPara_GetStyle,
3237 TextPara_SetStyle,
3238 TextPara_GetAlignment,
3239 TextPara_SetAlignment,
3240 TextPara_GetHyphenation,
3241 TextPara_SetHyphenation,
3242 TextPara_GetFirstLineIndent,
3243 TextPara_GetKeepTogether,
3244 TextPara_SetKeepTogether,
3245 TextPara_GetKeepWithNext,
3246 TextPara_SetKeepWithNext,
3247 TextPara_GetLeftIndent,
3248 TextPara_GetLineSpacing,
3249 TextPara_GetLineSpacingRule,
3250 TextPara_GetListAlignment,
3251 TextPara_SetListAlignment,
3252 TextPara_GetListLevelIndex,
3253 TextPara_SetListLevelIndex,
3254 TextPara_GetListStart,
3255 TextPara_SetListStart,
3256 TextPara_GetListTab,
3257 TextPara_SetListTab,
3258 TextPara_GetListType,
3259 TextPara_SetListType,
3260 TextPara_GetNoLineNumber,
3261 TextPara_SetNoLineNumber,
3262 TextPara_GetPageBreakBefore,
3263 TextPara_SetPageBreakBefore,
3264 TextPara_GetRightIndent,
3265 TextPara_SetRightIndent,
3266 TextPara_SetIndents,
3267 TextPara_SetLineSpacing,
3268 TextPara_GetSpaceAfter,
3269 TextPara_SetSpaceAfter,
3270 TextPara_GetSpaceBefore,
3271 TextPara_SetSpaceBefore,
3272 TextPara_GetWidowControl,
3273 TextPara_SetWidowControl,
3274 TextPara_GetTabCount,
3275 TextPara_AddTab,
3276 TextPara_ClearAllTabs,
3277 TextPara_DeleteTab,
3278 TextPara_GetTab
3281 static HRESULT create_textpara(ITextRange *range, ITextPara **ret)
3283 ITextParaImpl *para;
3285 *ret = NULL;
3286 para = heap_alloc(sizeof(*para));
3287 if (!para)
3288 return E_OUTOFMEMORY;
3290 para->ITextPara_iface.lpVtbl = &textparavtbl;
3291 para->ref = 1;
3292 para->range = range;
3293 ITextRange_AddRef(range);
3295 *ret = &para->ITextPara_iface;
3296 return S_OK;
3299 /* ITextDocument */
3300 static HRESULT WINAPI
3301 ITextDocument_fnQueryInterface(ITextDocument* me, REFIID riid,
3302 void** ppvObject)
3304 IRichEditOleImpl *This = impl_from_ITextDocument(me);
3305 return IRichEditOle_QueryInterface(&This->IRichEditOle_iface, riid, ppvObject);
3308 static ULONG WINAPI
3309 ITextDocument_fnAddRef(ITextDocument* me)
3311 IRichEditOleImpl *This = impl_from_ITextDocument(me);
3312 return IRichEditOle_AddRef(&This->IRichEditOle_iface);
3315 static ULONG WINAPI
3316 ITextDocument_fnRelease(ITextDocument* me)
3318 IRichEditOleImpl *This = impl_from_ITextDocument(me);
3319 return IRichEditOle_Release(&This->IRichEditOle_iface);
3322 static HRESULT WINAPI
3323 ITextDocument_fnGetTypeInfoCount(ITextDocument* me,
3324 UINT* pctinfo)
3326 IRichEditOleImpl *This = impl_from_ITextDocument(me);
3327 TRACE("(%p)->(%p)\n", This, pctinfo);
3328 *pctinfo = 1;
3329 return S_OK;
3332 static HRESULT WINAPI
3333 ITextDocument_fnGetTypeInfo(ITextDocument* me, UINT iTInfo, LCID lcid,
3334 ITypeInfo** ppTInfo)
3336 IRichEditOleImpl *This = impl_from_ITextDocument(me);
3337 HRESULT hr;
3339 TRACE("(%p)->(%u,%d,%p)\n", This, iTInfo, lcid, ppTInfo);
3341 hr = get_typeinfo(ITextDocument_tid, ppTInfo);
3342 if (SUCCEEDED(hr))
3343 ITypeInfo_AddRef(*ppTInfo);
3344 return hr;
3347 static HRESULT WINAPI
3348 ITextDocument_fnGetIDsOfNames(ITextDocument* me, REFIID riid,
3349 LPOLESTR* rgszNames, UINT cNames, LCID lcid, DISPID* rgDispId)
3351 IRichEditOleImpl *This = impl_from_ITextDocument(me);
3352 ITypeInfo *ti;
3353 HRESULT hr;
3355 TRACE("(%p)->(%p,%p,%u,%d,%p)\n", This, riid, rgszNames, cNames, lcid,
3356 rgDispId);
3358 hr = get_typeinfo(ITextDocument_tid, &ti);
3359 if (SUCCEEDED(hr))
3360 hr = ITypeInfo_GetIDsOfNames(ti, rgszNames, cNames, rgDispId);
3361 return hr;
3364 static HRESULT WINAPI
3365 ITextDocument_fnInvoke(ITextDocument* me, DISPID dispIdMember,
3366 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS* pDispParams,
3367 VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr)
3369 IRichEditOleImpl *This = impl_from_ITextDocument(me);
3370 ITypeInfo *ti;
3371 HRESULT hr;
3373 TRACE("(%p)->(%d,%p,%d,%u,%p,%p,%p,%p)\n", This, dispIdMember, riid, lcid,
3374 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
3376 hr = get_typeinfo(ITextDocument_tid, &ti);
3377 if (SUCCEEDED(hr))
3378 hr = ITypeInfo_Invoke(ti, me, dispIdMember, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
3379 return hr;
3382 static HRESULT WINAPI
3383 ITextDocument_fnGetName(ITextDocument* me, BSTR* pName)
3385 IRichEditOleImpl *This = impl_from_ITextDocument(me);
3386 FIXME("stub %p\n",This);
3387 return E_NOTIMPL;
3390 static HRESULT WINAPI
3391 ITextDocument_fnGetSelection(ITextDocument* me, ITextSelection** ppSel)
3393 IRichEditOleImpl *This = impl_from_ITextDocument(me);
3394 TRACE("(%p)\n", me);
3396 if(!ppSel)
3397 return E_INVALIDARG;
3398 *ppSel = &This->txtSel->ITextSelection_iface;
3399 ITextSelection_AddRef(*ppSel);
3400 return S_OK;
3403 static HRESULT WINAPI
3404 ITextDocument_fnGetStoryCount(ITextDocument* me, LONG* pCount)
3406 IRichEditOleImpl *This = impl_from_ITextDocument(me);
3407 FIXME("stub %p\n",This);
3408 return E_NOTIMPL;
3411 static HRESULT WINAPI
3412 ITextDocument_fnGetStoryRanges(ITextDocument* me,
3413 ITextStoryRanges** ppStories)
3415 IRichEditOleImpl *This = impl_from_ITextDocument(me);
3416 FIXME("stub %p\n",This);
3417 return E_NOTIMPL;
3420 static HRESULT WINAPI
3421 ITextDocument_fnGetSaved(ITextDocument* me, LONG* pValue)
3423 IRichEditOleImpl *This = impl_from_ITextDocument(me);
3424 FIXME("stub %p\n",This);
3425 return E_NOTIMPL;
3428 static HRESULT WINAPI
3429 ITextDocument_fnSetSaved(ITextDocument* me, LONG Value)
3431 IRichEditOleImpl *This = impl_from_ITextDocument(me);
3432 FIXME("stub %p\n",This);
3433 return E_NOTIMPL;
3436 static HRESULT WINAPI
3437 ITextDocument_fnGetDefaultTabStop(ITextDocument* me, float* pValue)
3439 IRichEditOleImpl *This = impl_from_ITextDocument(me);
3440 FIXME("stub %p\n",This);
3441 return E_NOTIMPL;
3444 static HRESULT WINAPI
3445 ITextDocument_fnSetDefaultTabStop(ITextDocument* me, float Value)
3447 IRichEditOleImpl *This = impl_from_ITextDocument(me);
3448 FIXME("stub %p\n",This);
3449 return E_NOTIMPL;
3452 static HRESULT WINAPI
3453 ITextDocument_fnNew(ITextDocument* me)
3455 IRichEditOleImpl *This = impl_from_ITextDocument(me);
3456 FIXME("stub %p\n",This);
3457 return E_NOTIMPL;
3460 static HRESULT WINAPI
3461 ITextDocument_fnOpen(ITextDocument* me, VARIANT* pVar, LONG Flags,
3462 LONG CodePage)
3464 IRichEditOleImpl *This = impl_from_ITextDocument(me);
3465 FIXME("stub %p\n",This);
3466 return E_NOTIMPL;
3469 static HRESULT WINAPI
3470 ITextDocument_fnSave(ITextDocument* me, VARIANT* pVar, LONG Flags,
3471 LONG CodePage)
3473 IRichEditOleImpl *This = impl_from_ITextDocument(me);
3474 FIXME("stub %p\n",This);
3475 return E_NOTIMPL;
3478 static HRESULT WINAPI
3479 ITextDocument_fnFreeze(ITextDocument* me, LONG* pCount)
3481 IRichEditOleImpl *This = impl_from_ITextDocument(me);
3482 FIXME("stub %p\n",This);
3483 return E_NOTIMPL;
3486 static HRESULT WINAPI
3487 ITextDocument_fnUnfreeze(ITextDocument* me, LONG* pCount)
3489 IRichEditOleImpl *This = impl_from_ITextDocument(me);
3490 FIXME("stub %p\n",This);
3491 return E_NOTIMPL;
3494 static HRESULT WINAPI
3495 ITextDocument_fnBeginEditCollection(ITextDocument* me)
3497 IRichEditOleImpl *This = impl_from_ITextDocument(me);
3498 FIXME("stub %p\n",This);
3499 return E_NOTIMPL;
3502 static HRESULT WINAPI
3503 ITextDocument_fnEndEditCollection(ITextDocument* me)
3505 IRichEditOleImpl *This = impl_from_ITextDocument(me);
3506 FIXME("stub %p\n",This);
3507 return E_NOTIMPL;
3510 static HRESULT WINAPI
3511 ITextDocument_fnUndo(ITextDocument* me, LONG Count, LONG* prop)
3513 IRichEditOleImpl *This = impl_from_ITextDocument(me);
3514 FIXME("stub %p\n",This);
3515 return E_NOTIMPL;
3518 static HRESULT WINAPI
3519 ITextDocument_fnRedo(ITextDocument* me, LONG Count, LONG* prop)
3521 IRichEditOleImpl *This = impl_from_ITextDocument(me);
3522 FIXME("stub %p\n",This);
3523 return E_NOTIMPL;
3526 static HRESULT CreateITextRange(IRichEditOleImpl *reOle, LONG start, LONG end, ITextRange** ppRange)
3528 ITextRangeImpl *txtRge = heap_alloc(sizeof(ITextRangeImpl));
3530 if (!txtRge)
3531 return E_OUTOFMEMORY;
3532 txtRge->ITextRange_iface.lpVtbl = &trvt;
3533 txtRge->ref = 1;
3534 txtRge->reOle = reOle;
3535 txtRge->start = start;
3536 txtRge->end = end;
3537 list_add_head(&reOle->rangelist, &txtRge->entry);
3538 *ppRange = &txtRge->ITextRange_iface;
3539 return S_OK;
3542 static HRESULT WINAPI
3543 ITextDocument_fnRange(ITextDocument* me, LONG cp1, LONG cp2,
3544 ITextRange** ppRange)
3546 IRichEditOleImpl *This = impl_from_ITextDocument(me);
3547 const int len = ME_GetTextLength(This->editor) + 1;
3549 TRACE("%p %p %d %d\n", This, ppRange, cp1, cp2);
3550 if (!ppRange)
3551 return E_INVALIDARG;
3553 cp1 = max(cp1, 0);
3554 cp2 = max(cp2, 0);
3555 cp1 = min(cp1, len);
3556 cp2 = min(cp2, len);
3557 if (cp1 > cp2)
3559 LONG tmp;
3560 tmp = cp1;
3561 cp1 = cp2;
3562 cp2 = tmp;
3564 if (cp1 == len)
3565 cp1 = cp2 = len - 1;
3567 return CreateITextRange(This, cp1, cp2, ppRange);
3570 static HRESULT WINAPI
3571 ITextDocument_fnRangeFromPoint(ITextDocument* me, LONG x, LONG y,
3572 ITextRange** ppRange)
3574 IRichEditOleImpl *This = impl_from_ITextDocument(me);
3575 FIXME("stub %p\n",This);
3576 return E_NOTIMPL;
3579 static const ITextDocumentVtbl tdvt = {
3580 ITextDocument_fnQueryInterface,
3581 ITextDocument_fnAddRef,
3582 ITextDocument_fnRelease,
3583 ITextDocument_fnGetTypeInfoCount,
3584 ITextDocument_fnGetTypeInfo,
3585 ITextDocument_fnGetIDsOfNames,
3586 ITextDocument_fnInvoke,
3587 ITextDocument_fnGetName,
3588 ITextDocument_fnGetSelection,
3589 ITextDocument_fnGetStoryCount,
3590 ITextDocument_fnGetStoryRanges,
3591 ITextDocument_fnGetSaved,
3592 ITextDocument_fnSetSaved,
3593 ITextDocument_fnGetDefaultTabStop,
3594 ITextDocument_fnSetDefaultTabStop,
3595 ITextDocument_fnNew,
3596 ITextDocument_fnOpen,
3597 ITextDocument_fnSave,
3598 ITextDocument_fnFreeze,
3599 ITextDocument_fnUnfreeze,
3600 ITextDocument_fnBeginEditCollection,
3601 ITextDocument_fnEndEditCollection,
3602 ITextDocument_fnUndo,
3603 ITextDocument_fnRedo,
3604 ITextDocument_fnRange,
3605 ITextDocument_fnRangeFromPoint
3608 /* ITextSelection */
3609 static HRESULT WINAPI ITextSelection_fnQueryInterface(
3610 ITextSelection *me,
3611 REFIID riid,
3612 void **ppvObj)
3614 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3616 *ppvObj = NULL;
3617 if (IsEqualGUID(riid, &IID_IUnknown)
3618 || IsEqualGUID(riid, &IID_IDispatch)
3619 || IsEqualGUID(riid, &IID_ITextRange)
3620 || IsEqualGUID(riid, &IID_ITextSelection))
3622 *ppvObj = me;
3623 ITextSelection_AddRef(me);
3624 return S_OK;
3626 else if (IsEqualGUID(riid, &IID_Igetrichole))
3628 *ppvObj = This->reOle;
3629 return S_OK;
3632 return E_NOINTERFACE;
3635 static ULONG WINAPI ITextSelection_fnAddRef(ITextSelection *me)
3637 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3638 return InterlockedIncrement(&This->ref);
3641 static ULONG WINAPI ITextSelection_fnRelease(ITextSelection *me)
3643 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3644 ULONG ref = InterlockedDecrement(&This->ref);
3645 if (ref == 0)
3646 heap_free(This);
3647 return ref;
3650 static HRESULT WINAPI ITextSelection_fnGetTypeInfoCount(ITextSelection *me, UINT *pctinfo)
3652 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3653 TRACE("(%p)->(%p)\n", This, pctinfo);
3654 *pctinfo = 1;
3655 return S_OK;
3658 static HRESULT WINAPI ITextSelection_fnGetTypeInfo(ITextSelection *me, UINT iTInfo, LCID lcid,
3659 ITypeInfo **ppTInfo)
3661 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3662 HRESULT hr;
3664 TRACE("(%p)->(%u,%d,%p)\n", This, iTInfo, lcid, ppTInfo);
3666 hr = get_typeinfo(ITextSelection_tid, ppTInfo);
3667 if (SUCCEEDED(hr))
3668 ITypeInfo_AddRef(*ppTInfo);
3669 return hr;
3672 static HRESULT WINAPI ITextSelection_fnGetIDsOfNames(ITextSelection *me, REFIID riid,
3673 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
3675 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3676 ITypeInfo *ti;
3677 HRESULT hr;
3679 TRACE("(%p)->(%p,%p,%u,%d,%p)\n", This, riid, rgszNames, cNames, lcid,
3680 rgDispId);
3682 hr = get_typeinfo(ITextSelection_tid, &ti);
3683 if (SUCCEEDED(hr))
3684 hr = ITypeInfo_GetIDsOfNames(ti, rgszNames, cNames, rgDispId);
3685 return hr;
3688 static HRESULT WINAPI ITextSelection_fnInvoke(
3689 ITextSelection *me,
3690 DISPID dispIdMember,
3691 REFIID riid,
3692 LCID lcid,
3693 WORD wFlags,
3694 DISPPARAMS *pDispParams,
3695 VARIANT *pVarResult,
3696 EXCEPINFO *pExcepInfo,
3697 UINT *puArgErr)
3699 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3700 ITypeInfo *ti;
3701 HRESULT hr;
3703 TRACE("(%p)->(%d,%p,%d,%u,%p,%p,%p,%p)\n", This, dispIdMember, riid, lcid,
3704 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
3706 hr = get_typeinfo(ITextSelection_tid, &ti);
3707 if (SUCCEEDED(hr))
3708 hr = ITypeInfo_Invoke(ti, me, dispIdMember, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
3709 return hr;
3712 /*** ITextRange methods ***/
3713 static HRESULT WINAPI ITextSelection_fnGetText(ITextSelection *me, BSTR *pbstr)
3715 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3716 ME_Cursor *start = NULL, *end = NULL;
3717 int nChars, endOfs;
3718 BOOL bEOP;
3720 TRACE("(%p)->(%p)\n", This, pbstr);
3722 if (!This->reOle)
3723 return CO_E_RELEASED;
3725 if (!pbstr)
3726 return E_INVALIDARG;
3728 ME_GetSelection(This->reOle->editor, &start, &end);
3729 endOfs = ME_GetCursorOfs(end);
3730 nChars = endOfs - ME_GetCursorOfs(start);
3731 if (!nChars)
3733 *pbstr = NULL;
3734 return S_OK;
3737 *pbstr = SysAllocStringLen(NULL, nChars);
3738 if (!*pbstr)
3739 return E_OUTOFMEMORY;
3741 bEOP = (end->pRun->next->type == diTextEnd && endOfs > ME_GetTextLength(This->reOle->editor));
3742 ME_GetTextW(This->reOle->editor, *pbstr, nChars, start, nChars, FALSE, bEOP);
3743 TRACE("%s\n", wine_dbgstr_w(*pbstr));
3745 return S_OK;
3748 static HRESULT WINAPI ITextSelection_fnSetText(ITextSelection *me, BSTR bstr)
3750 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3751 if (!This->reOle)
3752 return CO_E_RELEASED;
3754 FIXME("not implemented\n");
3755 return E_NOTIMPL;
3758 static HRESULT WINAPI ITextSelection_fnGetChar(ITextSelection *me, LONG *pch)
3760 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3761 ME_Cursor *start = NULL, *end = NULL;
3763 if (!This->reOle)
3764 return CO_E_RELEASED;
3765 TRACE("%p\n", pch);
3766 if (!pch)
3767 return E_INVALIDARG;
3769 ME_GetSelection(This->reOle->editor, &start, &end);
3770 return range_GetChar(This->reOle->editor, start, pch);
3773 static HRESULT WINAPI ITextSelection_fnSetChar(ITextSelection *me, LONG ch)
3775 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3776 if (!This->reOle)
3777 return CO_E_RELEASED;
3779 FIXME("not implemented\n");
3780 return E_NOTIMPL;
3783 static HRESULT WINAPI ITextSelection_fnGetDuplicate(ITextSelection *me, ITextRange **ppRange)
3785 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3786 if (!This->reOle)
3787 return CO_E_RELEASED;
3789 FIXME("not implemented\n");
3790 return E_NOTIMPL;
3793 static HRESULT WINAPI ITextSelection_fnGetFormattedText(ITextSelection *me, ITextRange **ppRange)
3795 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3796 if (!This->reOle)
3797 return CO_E_RELEASED;
3799 FIXME("not implemented\n");
3800 return E_NOTIMPL;
3803 static HRESULT WINAPI ITextSelection_fnSetFormattedText(ITextSelection *me, ITextRange *pRange)
3805 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3806 if (!This->reOle)
3807 return CO_E_RELEASED;
3809 FIXME("not implemented\n");
3810 return E_NOTIMPL;
3813 static HRESULT WINAPI ITextSelection_fnGetStart(ITextSelection *me, LONG *pcpFirst)
3815 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3816 LONG lim;
3817 if (!This->reOle)
3818 return CO_E_RELEASED;
3820 if (!pcpFirst)
3821 return E_INVALIDARG;
3822 ME_GetSelectionOfs(This->reOle->editor, pcpFirst, &lim);
3823 TRACE("%d\n", *pcpFirst);
3824 return S_OK;
3827 static HRESULT WINAPI ITextSelection_fnSetStart(ITextSelection *me, LONG value)
3829 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3830 LONG start, end;
3831 HRESULT hr;
3833 TRACE("(%p)->(%d)\n", This, value);
3835 if (!This->reOle)
3836 return CO_E_RELEASED;
3838 ME_GetSelectionOfs(This->reOle->editor, &start, &end);
3839 hr = textrange_setstart(This->reOle, value, &start, &end);
3840 if (hr == S_OK)
3841 ME_SetSelection(This->reOle->editor, start, end);
3843 return hr;
3846 static HRESULT WINAPI ITextSelection_fnGetEnd(ITextSelection *me, LONG *pcpLim)
3848 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3849 LONG first;
3850 if (!This->reOle)
3851 return CO_E_RELEASED;
3853 if (!pcpLim)
3854 return E_INVALIDARG;
3855 ME_GetSelectionOfs(This->reOle->editor, &first, pcpLim);
3856 TRACE("%d\n", *pcpLim);
3857 return S_OK;
3860 static HRESULT WINAPI ITextSelection_fnSetEnd(ITextSelection *me, LONG value)
3862 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3863 LONG start, end;
3864 HRESULT hr;
3866 TRACE("(%p)->(%d)\n", This, value);
3868 if (!This->reOle)
3869 return CO_E_RELEASED;
3871 ME_GetSelectionOfs(This->reOle->editor, &start, &end);
3872 hr = textrange_setend(This->reOle, value, &start, &end);
3873 if (hr == S_OK)
3874 ME_SetSelection(This->reOle->editor, start, end);
3876 return hr;
3879 static HRESULT WINAPI ITextSelection_fnGetFont(ITextSelection *me, ITextFont **font)
3881 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3883 TRACE("(%p)->(%p)\n", This, font);
3885 if (!This->reOle)
3886 return CO_E_RELEASED;
3888 if (!font)
3889 return E_INVALIDARG;
3891 return create_textfont((ITextRange*)me, NULL, font);
3894 static HRESULT WINAPI ITextSelection_fnSetFont(ITextSelection *me, ITextFont *pFont)
3896 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3897 if (!This->reOle)
3898 return CO_E_RELEASED;
3900 FIXME("not implemented\n");
3901 return E_NOTIMPL;
3904 static HRESULT WINAPI ITextSelection_fnGetPara(ITextSelection *me, ITextPara **para)
3906 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3907 if (!This->reOle)
3908 return CO_E_RELEASED;
3910 FIXME("not implemented\n");
3911 return E_NOTIMPL;
3914 static HRESULT WINAPI ITextSelection_fnSetPara(ITextSelection *me, ITextPara *pPara)
3916 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3917 if (!This->reOle)
3918 return CO_E_RELEASED;
3920 FIXME("not implemented\n");
3921 return E_NOTIMPL;
3924 static HRESULT WINAPI ITextSelection_fnGetStoryLength(ITextSelection *me, LONG *pcch)
3926 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3927 if (!This->reOle)
3928 return CO_E_RELEASED;
3930 FIXME("not implemented\n");
3931 return E_NOTIMPL;
3934 static HRESULT WINAPI ITextSelection_fnGetStoryType(ITextSelection *me, LONG *pValue)
3936 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3937 if (!This->reOle)
3938 return CO_E_RELEASED;
3940 FIXME("not implemented\n");
3941 return E_NOTIMPL;
3944 static HRESULT WINAPI ITextSelection_fnCollapse(ITextSelection *me, LONG bStart)
3946 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3947 LONG start, end;
3948 HRESULT hres;
3949 if (!This->reOle)
3950 return CO_E_RELEASED;
3952 ME_GetSelectionOfs(This->reOle->editor, &start, &end);
3953 hres = range_Collapse(bStart, &start, &end);
3954 if (SUCCEEDED(hres))
3955 ME_SetSelection(This->reOle->editor, start, end);
3956 return hres;
3959 static HRESULT WINAPI ITextSelection_fnExpand(ITextSelection *me, LONG Unit, LONG *pDelta)
3961 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3962 if (!This->reOle)
3963 return CO_E_RELEASED;
3965 FIXME("not implemented\n");
3966 return E_NOTIMPL;
3969 static HRESULT WINAPI ITextSelection_fnGetIndex(ITextSelection *me, LONG Unit, LONG *pIndex)
3971 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3972 if (!This->reOle)
3973 return CO_E_RELEASED;
3975 FIXME("not implemented\n");
3976 return E_NOTIMPL;
3979 static HRESULT WINAPI ITextSelection_fnSetIndex(ITextSelection *me, LONG Unit, LONG Index,
3980 LONG Extend)
3982 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3983 if (!This->reOle)
3984 return CO_E_RELEASED;
3986 FIXME("not implemented\n");
3987 return E_NOTIMPL;
3990 static HRESULT WINAPI ITextSelection_fnSetRange(ITextSelection *me, LONG cpActive, LONG cpOther)
3992 ITextSelectionImpl *This = impl_from_ITextSelection(me);
3993 if (!This->reOle)
3994 return CO_E_RELEASED;
3996 FIXME("not implemented\n");
3997 return E_NOTIMPL;
4000 static HRESULT WINAPI ITextSelection_fnInRange(ITextSelection *me, ITextRange *pRange, LONG *pb)
4002 ITextSelectionImpl *This = impl_from_ITextSelection(me);
4003 if (!This->reOle)
4004 return CO_E_RELEASED;
4006 FIXME("not implemented\n");
4007 return E_NOTIMPL;
4010 static HRESULT WINAPI ITextSelection_fnInStory(ITextSelection *me, ITextRange *pRange, LONG *pb)
4012 ITextSelectionImpl *This = impl_from_ITextSelection(me);
4013 if (!This->reOle)
4014 return CO_E_RELEASED;
4016 FIXME("not implemented\n");
4017 return E_NOTIMPL;
4020 static HRESULT WINAPI ITextSelection_fnIsEqual(ITextSelection *me, ITextRange *pRange, LONG *pb)
4022 ITextSelectionImpl *This = impl_from_ITextSelection(me);
4023 if (!This->reOle)
4024 return CO_E_RELEASED;
4026 FIXME("not implemented\n");
4027 return E_NOTIMPL;
4030 static HRESULT WINAPI ITextSelection_fnSelect(ITextSelection *me)
4032 ITextSelectionImpl *This = impl_from_ITextSelection(me);
4033 if (!This->reOle)
4034 return CO_E_RELEASED;
4036 FIXME("not implemented\n");
4037 return E_NOTIMPL;
4040 static HRESULT WINAPI ITextSelection_fnStartOf(ITextSelection *me, LONG Unit, LONG Extend,
4041 LONG *pDelta)
4043 ITextSelectionImpl *This = impl_from_ITextSelection(me);
4044 if (!This->reOle)
4045 return CO_E_RELEASED;
4047 FIXME("not implemented\n");
4048 return E_NOTIMPL;
4051 static HRESULT WINAPI ITextSelection_fnEndOf(ITextSelection *me, LONG Unit, LONG Extend,
4052 LONG *pDelta)
4054 ITextSelectionImpl *This = impl_from_ITextSelection(me);
4055 if (!This->reOle)
4056 return CO_E_RELEASED;
4058 FIXME("not implemented\n");
4059 return E_NOTIMPL;
4062 static HRESULT WINAPI ITextSelection_fnMove(ITextSelection *me, LONG Unit, LONG Count, LONG *pDelta)
4064 ITextSelectionImpl *This = impl_from_ITextSelection(me);
4065 if (!This->reOle)
4066 return CO_E_RELEASED;
4068 FIXME("not implemented\n");
4069 return E_NOTIMPL;
4072 static HRESULT WINAPI ITextSelection_fnMoveStart(ITextSelection *me, LONG Unit, LONG Count,
4073 LONG *pDelta)
4075 ITextSelectionImpl *This = impl_from_ITextSelection(me);
4076 if (!This->reOle)
4077 return CO_E_RELEASED;
4079 FIXME("not implemented\n");
4080 return E_NOTIMPL;
4083 static HRESULT WINAPI ITextSelection_fnMoveEnd(ITextSelection *me, LONG Unit, LONG Count,
4084 LONG *pDelta)
4086 ITextSelectionImpl *This = impl_from_ITextSelection(me);
4087 if (!This->reOle)
4088 return CO_E_RELEASED;
4090 FIXME("not implemented\n");
4091 return E_NOTIMPL;
4094 static HRESULT WINAPI ITextSelection_fnMoveWhile(ITextSelection *me, VARIANT *Cset, LONG Count,
4095 LONG *pDelta)
4097 ITextSelectionImpl *This = impl_from_ITextSelection(me);
4098 if (!This->reOle)
4099 return CO_E_RELEASED;
4101 FIXME("not implemented\n");
4102 return E_NOTIMPL;
4105 static HRESULT WINAPI ITextSelection_fnMoveStartWhile(ITextSelection *me, VARIANT *Cset, LONG Count,
4106 LONG *pDelta)
4108 ITextSelectionImpl *This = impl_from_ITextSelection(me);
4109 if (!This->reOle)
4110 return CO_E_RELEASED;
4112 FIXME("not implemented\n");
4113 return E_NOTIMPL;
4116 static HRESULT WINAPI ITextSelection_fnMoveEndWhile(ITextSelection *me, VARIANT *Cset, LONG Count,
4117 LONG *pDelta)
4119 ITextSelectionImpl *This = impl_from_ITextSelection(me);
4120 if (!This->reOle)
4121 return CO_E_RELEASED;
4123 FIXME("not implemented\n");
4124 return E_NOTIMPL;
4127 static HRESULT WINAPI ITextSelection_fnMoveUntil(ITextSelection *me, VARIANT *Cset, LONG Count,
4128 LONG *pDelta)
4130 ITextSelectionImpl *This = impl_from_ITextSelection(me);
4131 if (!This->reOle)
4132 return CO_E_RELEASED;
4134 FIXME("not implemented\n");
4135 return E_NOTIMPL;
4138 static HRESULT WINAPI ITextSelection_fnMoveStartUntil(ITextSelection *me, VARIANT *Cset, LONG Count,
4139 LONG *pDelta)
4141 ITextSelectionImpl *This = impl_from_ITextSelection(me);
4142 if (!This->reOle)
4143 return CO_E_RELEASED;
4145 FIXME("not implemented\n");
4146 return E_NOTIMPL;
4149 static HRESULT WINAPI ITextSelection_fnMoveEndUntil(ITextSelection *me, VARIANT *Cset, LONG Count,
4150 LONG *pDelta)
4152 ITextSelectionImpl *This = impl_from_ITextSelection(me);
4153 if (!This->reOle)
4154 return CO_E_RELEASED;
4156 FIXME("not implemented\n");
4157 return E_NOTIMPL;
4160 static HRESULT WINAPI ITextSelection_fnFindText(ITextSelection *me, BSTR bstr, LONG cch, LONG Flags,
4161 LONG *pLength)
4163 ITextSelectionImpl *This = impl_from_ITextSelection(me);
4164 if (!This->reOle)
4165 return CO_E_RELEASED;
4167 FIXME("not implemented\n");
4168 return E_NOTIMPL;
4171 static HRESULT WINAPI ITextSelection_fnFindTextStart(ITextSelection *me, BSTR bstr, LONG cch,
4172 LONG Flags, LONG *pLength)
4174 ITextSelectionImpl *This = impl_from_ITextSelection(me);
4175 if (!This->reOle)
4176 return CO_E_RELEASED;
4178 FIXME("not implemented\n");
4179 return E_NOTIMPL;
4182 static HRESULT WINAPI ITextSelection_fnFindTextEnd(ITextSelection *me, BSTR bstr, LONG cch,
4183 LONG Flags, LONG *pLength)
4185 ITextSelectionImpl *This = impl_from_ITextSelection(me);
4186 if (!This->reOle)
4187 return CO_E_RELEASED;
4189 FIXME("not implemented\n");
4190 return E_NOTIMPL;
4193 static HRESULT WINAPI ITextSelection_fnDelete(ITextSelection *me, LONG Unit, LONG Count,
4194 LONG *pDelta)
4196 ITextSelectionImpl *This = impl_from_ITextSelection(me);
4197 if (!This->reOle)
4198 return CO_E_RELEASED;
4200 FIXME("not implemented\n");
4201 return E_NOTIMPL;
4204 static HRESULT WINAPI ITextSelection_fnCut(ITextSelection *me, VARIANT *pVar)
4206 ITextSelectionImpl *This = impl_from_ITextSelection(me);
4207 if (!This->reOle)
4208 return CO_E_RELEASED;
4210 FIXME("not implemented\n");
4211 return E_NOTIMPL;
4214 static HRESULT WINAPI ITextSelection_fnCopy(ITextSelection *me, VARIANT *pVar)
4216 ITextSelectionImpl *This = impl_from_ITextSelection(me);
4217 if (!This->reOle)
4218 return CO_E_RELEASED;
4220 FIXME("not implemented\n");
4221 return E_NOTIMPL;
4224 static HRESULT WINAPI ITextSelection_fnPaste(ITextSelection *me, VARIANT *pVar, LONG Format)
4226 ITextSelectionImpl *This = impl_from_ITextSelection(me);
4227 if (!This->reOle)
4228 return CO_E_RELEASED;
4230 FIXME("not implemented\n");
4231 return E_NOTIMPL;
4234 static HRESULT WINAPI ITextSelection_fnCanPaste(ITextSelection *me, VARIANT *pVar, LONG Format,
4235 LONG *pb)
4237 ITextSelectionImpl *This = impl_from_ITextSelection(me);
4238 if (!This->reOle)
4239 return CO_E_RELEASED;
4241 FIXME("not implemented\n");
4242 return E_NOTIMPL;
4245 static HRESULT WINAPI ITextSelection_fnCanEdit(ITextSelection *me, LONG *pb)
4247 ITextSelectionImpl *This = impl_from_ITextSelection(me);
4248 if (!This->reOle)
4249 return CO_E_RELEASED;
4251 FIXME("not implemented\n");
4252 return E_NOTIMPL;
4255 static HRESULT WINAPI ITextSelection_fnChangeCase(ITextSelection *me, LONG Type)
4257 ITextSelectionImpl *This = impl_from_ITextSelection(me);
4258 if (!This->reOle)
4259 return CO_E_RELEASED;
4261 FIXME("not implemented\n");
4262 return E_NOTIMPL;
4265 static HRESULT WINAPI ITextSelection_fnGetPoint(ITextSelection *me, LONG Type, LONG *cx, LONG *cy)
4267 ITextSelectionImpl *This = impl_from_ITextSelection(me);
4268 if (!This->reOle)
4269 return CO_E_RELEASED;
4271 FIXME("not implemented\n");
4272 return E_NOTIMPL;
4275 static HRESULT WINAPI ITextSelection_fnSetPoint(ITextSelection *me, LONG x, LONG y, LONG Type,
4276 LONG Extend)
4278 ITextSelectionImpl *This = impl_from_ITextSelection(me);
4279 if (!This->reOle)
4280 return CO_E_RELEASED;
4282 FIXME("not implemented\n");
4283 return E_NOTIMPL;
4286 static HRESULT WINAPI ITextSelection_fnScrollIntoView(ITextSelection *me, LONG Value)
4288 ITextSelectionImpl *This = impl_from_ITextSelection(me);
4289 if (!This->reOle)
4290 return CO_E_RELEASED;
4292 FIXME("not implemented\n");
4293 return E_NOTIMPL;
4296 static HRESULT WINAPI ITextSelection_fnGetEmbeddedObject(ITextSelection *me, IUnknown **ppv)
4298 ITextSelectionImpl *This = impl_from_ITextSelection(me);
4299 if (!This->reOle)
4300 return CO_E_RELEASED;
4302 FIXME("not implemented\n");
4303 return E_NOTIMPL;
4306 /*** ITextSelection methods ***/
4307 static HRESULT WINAPI ITextSelection_fnGetFlags(ITextSelection *me, LONG *pFlags)
4309 ITextSelectionImpl *This = impl_from_ITextSelection(me);
4310 if (!This->reOle)
4311 return CO_E_RELEASED;
4313 FIXME("not implemented\n");
4314 return E_NOTIMPL;
4317 static HRESULT WINAPI ITextSelection_fnSetFlags(ITextSelection *me, LONG Flags)
4319 ITextSelectionImpl *This = impl_from_ITextSelection(me);
4320 if (!This->reOle)
4321 return CO_E_RELEASED;
4323 FIXME("not implemented\n");
4324 return E_NOTIMPL;
4327 static HRESULT WINAPI ITextSelection_fnGetType(ITextSelection *me, LONG *pType)
4329 ITextSelectionImpl *This = impl_from_ITextSelection(me);
4330 if (!This->reOle)
4331 return CO_E_RELEASED;
4333 FIXME("not implemented\n");
4334 return E_NOTIMPL;
4337 static HRESULT WINAPI ITextSelection_fnMoveLeft(ITextSelection *me, LONG Unit, LONG Count,
4338 LONG Extend, LONG *pDelta)
4340 ITextSelectionImpl *This = impl_from_ITextSelection(me);
4341 if (!This->reOle)
4342 return CO_E_RELEASED;
4344 FIXME("not implemented\n");
4345 return E_NOTIMPL;
4348 static HRESULT WINAPI ITextSelection_fnMoveRight(ITextSelection *me, LONG Unit, LONG Count,
4349 LONG Extend, LONG *pDelta)
4351 ITextSelectionImpl *This = impl_from_ITextSelection(me);
4352 if (!This->reOle)
4353 return CO_E_RELEASED;
4355 FIXME("not implemented\n");
4356 return E_NOTIMPL;
4359 static HRESULT WINAPI ITextSelection_fnMoveUp(ITextSelection *me, LONG Unit, LONG Count,
4360 LONG Extend, LONG *pDelta)
4362 ITextSelectionImpl *This = impl_from_ITextSelection(me);
4363 if (!This->reOle)
4364 return CO_E_RELEASED;
4366 FIXME("not implemented\n");
4367 return E_NOTIMPL;
4370 static HRESULT WINAPI ITextSelection_fnMoveDown(ITextSelection *me, LONG Unit, LONG Count,
4371 LONG Extend, LONG *pDelta)
4373 ITextSelectionImpl *This = impl_from_ITextSelection(me);
4374 if (!This->reOle)
4375 return CO_E_RELEASED;
4377 FIXME("not implemented\n");
4378 return E_NOTIMPL;
4381 static HRESULT WINAPI ITextSelection_fnHomeKey(ITextSelection *me, LONG Unit, LONG Extend,
4382 LONG *pDelta)
4384 ITextSelectionImpl *This = impl_from_ITextSelection(me);
4385 if (!This->reOle)
4386 return CO_E_RELEASED;
4388 FIXME("not implemented\n");
4389 return E_NOTIMPL;
4392 static HRESULT WINAPI ITextSelection_fnEndKey(ITextSelection *me, LONG Unit, LONG Extend,
4393 LONG *pDelta)
4395 ITextSelectionImpl *This = impl_from_ITextSelection(me);
4396 if (!This->reOle)
4397 return CO_E_RELEASED;
4399 FIXME("not implemented\n");
4400 return E_NOTIMPL;
4403 static HRESULT WINAPI ITextSelection_fnTypeText(ITextSelection *me, BSTR bstr)
4405 ITextSelectionImpl *This = impl_from_ITextSelection(me);
4406 if (!This->reOle)
4407 return CO_E_RELEASED;
4409 FIXME("not implemented\n");
4410 return E_NOTIMPL;
4413 static const ITextSelectionVtbl tsvt = {
4414 ITextSelection_fnQueryInterface,
4415 ITextSelection_fnAddRef,
4416 ITextSelection_fnRelease,
4417 ITextSelection_fnGetTypeInfoCount,
4418 ITextSelection_fnGetTypeInfo,
4419 ITextSelection_fnGetIDsOfNames,
4420 ITextSelection_fnInvoke,
4421 ITextSelection_fnGetText,
4422 ITextSelection_fnSetText,
4423 ITextSelection_fnGetChar,
4424 ITextSelection_fnSetChar,
4425 ITextSelection_fnGetDuplicate,
4426 ITextSelection_fnGetFormattedText,
4427 ITextSelection_fnSetFormattedText,
4428 ITextSelection_fnGetStart,
4429 ITextSelection_fnSetStart,
4430 ITextSelection_fnGetEnd,
4431 ITextSelection_fnSetEnd,
4432 ITextSelection_fnGetFont,
4433 ITextSelection_fnSetFont,
4434 ITextSelection_fnGetPara,
4435 ITextSelection_fnSetPara,
4436 ITextSelection_fnGetStoryLength,
4437 ITextSelection_fnGetStoryType,
4438 ITextSelection_fnCollapse,
4439 ITextSelection_fnExpand,
4440 ITextSelection_fnGetIndex,
4441 ITextSelection_fnSetIndex,
4442 ITextSelection_fnSetRange,
4443 ITextSelection_fnInRange,
4444 ITextSelection_fnInStory,
4445 ITextSelection_fnIsEqual,
4446 ITextSelection_fnSelect,
4447 ITextSelection_fnStartOf,
4448 ITextSelection_fnEndOf,
4449 ITextSelection_fnMove,
4450 ITextSelection_fnMoveStart,
4451 ITextSelection_fnMoveEnd,
4452 ITextSelection_fnMoveWhile,
4453 ITextSelection_fnMoveStartWhile,
4454 ITextSelection_fnMoveEndWhile,
4455 ITextSelection_fnMoveUntil,
4456 ITextSelection_fnMoveStartUntil,
4457 ITextSelection_fnMoveEndUntil,
4458 ITextSelection_fnFindText,
4459 ITextSelection_fnFindTextStart,
4460 ITextSelection_fnFindTextEnd,
4461 ITextSelection_fnDelete,
4462 ITextSelection_fnCut,
4463 ITextSelection_fnCopy,
4464 ITextSelection_fnPaste,
4465 ITextSelection_fnCanPaste,
4466 ITextSelection_fnCanEdit,
4467 ITextSelection_fnChangeCase,
4468 ITextSelection_fnGetPoint,
4469 ITextSelection_fnSetPoint,
4470 ITextSelection_fnScrollIntoView,
4471 ITextSelection_fnGetEmbeddedObject,
4472 ITextSelection_fnGetFlags,
4473 ITextSelection_fnSetFlags,
4474 ITextSelection_fnGetType,
4475 ITextSelection_fnMoveLeft,
4476 ITextSelection_fnMoveRight,
4477 ITextSelection_fnMoveUp,
4478 ITextSelection_fnMoveDown,
4479 ITextSelection_fnHomeKey,
4480 ITextSelection_fnEndKey,
4481 ITextSelection_fnTypeText
4484 static ITextSelectionImpl *
4485 CreateTextSelection(IRichEditOleImpl *reOle)
4487 ITextSelectionImpl *txtSel = heap_alloc(sizeof *txtSel);
4488 if (!txtSel)
4489 return NULL;
4491 txtSel->ITextSelection_iface.lpVtbl = &tsvt;
4492 txtSel->ref = 1;
4493 txtSel->reOle = reOle;
4494 return txtSel;
4497 LRESULT CreateIRichEditOle(IUnknown *outer_unk, ME_TextEditor *editor, LPVOID *ppvObj)
4499 IRichEditOleImpl *reo;
4501 reo = heap_alloc(sizeof(IRichEditOleImpl));
4502 if (!reo)
4503 return 0;
4505 reo->IUnknown_inner.lpVtbl = &reo_unk_vtbl;
4506 reo->IRichEditOle_iface.lpVtbl = &revt;
4507 reo->ITextDocument_iface.lpVtbl = &tdvt;
4508 reo->ref = 1;
4509 reo->editor = editor;
4510 reo->txtSel = CreateTextSelection(reo);
4511 if (!reo->txtSel)
4513 heap_free(reo);
4514 return 0;
4516 reo->clientSite = CreateOleClientSite(reo);
4517 if (!reo->clientSite)
4519 ITextSelection_Release(&reo->txtSel->ITextSelection_iface);
4520 heap_free(reo);
4521 return 0;
4523 TRACE("Created %p\n",reo);
4524 list_init(&reo->rangelist);
4525 if (outer_unk)
4526 reo->outer_unk = outer_unk;
4527 else
4528 reo->outer_unk = &reo->IUnknown_inner;
4529 *ppvObj = &reo->IRichEditOle_iface;
4531 return 1;
4534 static void convert_sizel(const ME_Context *c, const SIZEL* szl, SIZE* sz)
4536 /* sizel is in .01 millimeters, sz in pixels */
4537 sz->cx = MulDiv(szl->cx, c->dpi.cx, 2540);
4538 sz->cy = MulDiv(szl->cy, c->dpi.cy, 2540);
4541 /******************************************************************************
4542 * ME_GetOLEObjectSize
4544 * Sets run extent for OLE objects.
4546 void ME_GetOLEObjectSize(const ME_Context *c, ME_Run *run, SIZE *pSize)
4548 IDataObject* ido;
4549 FORMATETC fmt;
4550 STGMEDIUM stgm;
4551 DIBSECTION dibsect;
4552 ENHMETAHEADER emh;
4554 assert(run->nFlags & MERF_GRAPHICS);
4555 assert(run->ole_obj);
4557 if (run->ole_obj->sizel.cx != 0 || run->ole_obj->sizel.cy != 0)
4559 convert_sizel(c, &run->ole_obj->sizel, pSize);
4560 if (c->editor->nZoomNumerator != 0)
4562 pSize->cx = MulDiv(pSize->cx, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
4563 pSize->cy = MulDiv(pSize->cy, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
4565 return;
4568 if (IOleObject_QueryInterface(run->ole_obj->poleobj, &IID_IDataObject, (void**)&ido) != S_OK)
4570 FIXME("Query Interface IID_IDataObject failed!\n");
4571 pSize->cx = pSize->cy = 0;
4572 return;
4574 fmt.cfFormat = CF_BITMAP;
4575 fmt.ptd = NULL;
4576 fmt.dwAspect = DVASPECT_CONTENT;
4577 fmt.lindex = -1;
4578 fmt.tymed = TYMED_GDI;
4579 if (IDataObject_GetData(ido, &fmt, &stgm) != S_OK)
4581 fmt.cfFormat = CF_ENHMETAFILE;
4582 fmt.tymed = TYMED_ENHMF;
4583 if (IDataObject_GetData(ido, &fmt, &stgm) != S_OK)
4585 FIXME("unsupported format\n");
4586 pSize->cx = pSize->cy = 0;
4587 IDataObject_Release(ido);
4588 return;
4592 switch (stgm.tymed)
4594 case TYMED_GDI:
4595 GetObjectW(stgm.u.hBitmap, sizeof(dibsect), &dibsect);
4596 pSize->cx = dibsect.dsBm.bmWidth;
4597 pSize->cy = dibsect.dsBm.bmHeight;
4598 if (!stgm.pUnkForRelease) DeleteObject(stgm.u.hBitmap);
4599 break;
4600 case TYMED_ENHMF:
4601 GetEnhMetaFileHeader(stgm.u.hEnhMetaFile, sizeof(emh), &emh);
4602 pSize->cx = emh.rclBounds.right - emh.rclBounds.left;
4603 pSize->cy = emh.rclBounds.bottom - emh.rclBounds.top;
4604 if (!stgm.pUnkForRelease) DeleteEnhMetaFile(stgm.u.hEnhMetaFile);
4605 break;
4606 default:
4607 FIXME("Unsupported tymed %d\n", stgm.tymed);
4608 break;
4610 IDataObject_Release(ido);
4611 if (c->editor->nZoomNumerator != 0)
4613 pSize->cx = MulDiv(pSize->cx, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
4614 pSize->cy = MulDiv(pSize->cy, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
4618 void ME_DrawOLE(ME_Context *c, int x, int y, ME_Run *run,
4619 ME_Paragraph *para, BOOL selected)
4621 IDataObject* ido;
4622 FORMATETC fmt;
4623 STGMEDIUM stgm;
4624 DIBSECTION dibsect;
4625 ENHMETAHEADER emh;
4626 HDC hMemDC;
4627 SIZE sz;
4628 BOOL has_size;
4630 assert(run->nFlags & MERF_GRAPHICS);
4631 assert(run->ole_obj);
4632 if (IOleObject_QueryInterface(run->ole_obj->poleobj, &IID_IDataObject, (void**)&ido) != S_OK)
4634 FIXME("Couldn't get interface\n");
4635 return;
4637 has_size = run->ole_obj->sizel.cx != 0 || run->ole_obj->sizel.cy != 0;
4638 fmt.cfFormat = CF_BITMAP;
4639 fmt.ptd = NULL;
4640 fmt.dwAspect = DVASPECT_CONTENT;
4641 fmt.lindex = -1;
4642 fmt.tymed = TYMED_GDI;
4643 if (IDataObject_GetData(ido, &fmt, &stgm) != S_OK)
4645 fmt.cfFormat = CF_ENHMETAFILE;
4646 fmt.tymed = TYMED_ENHMF;
4647 if (IDataObject_GetData(ido, &fmt, &stgm) != S_OK)
4649 FIXME("Couldn't get storage medium\n");
4650 IDataObject_Release(ido);
4651 return;
4654 switch (stgm.tymed)
4656 case TYMED_GDI:
4657 GetObjectW(stgm.u.hBitmap, sizeof(dibsect), &dibsect);
4658 hMemDC = CreateCompatibleDC(c->hDC);
4659 SelectObject(hMemDC, stgm.u.hBitmap);
4660 if (has_size)
4662 convert_sizel(c, &run->ole_obj->sizel, &sz);
4663 } else {
4664 sz.cx = MulDiv(dibsect.dsBm.bmWidth, c->dpi.cx, 96);
4665 sz.cy = MulDiv(dibsect.dsBm.bmHeight, c->dpi.cy, 96);
4667 if (c->editor->nZoomNumerator != 0)
4669 sz.cx = MulDiv(sz.cx, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
4670 sz.cy = MulDiv(sz.cy, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
4672 if (sz.cx == dibsect.dsBm.bmWidth && sz.cy == dibsect.dsBm.bmHeight)
4674 BitBlt(c->hDC, x, y - sz.cy,
4675 dibsect.dsBm.bmWidth, dibsect.dsBm.bmHeight,
4676 hMemDC, 0, 0, SRCCOPY);
4677 } else {
4678 StretchBlt(c->hDC, x, y - sz.cy, sz.cx, sz.cy,
4679 hMemDC, 0, 0, dibsect.dsBm.bmWidth,
4680 dibsect.dsBm.bmHeight, SRCCOPY);
4682 DeleteDC(hMemDC);
4683 if (!stgm.pUnkForRelease) DeleteObject(stgm.u.hBitmap);
4684 break;
4685 case TYMED_ENHMF:
4686 GetEnhMetaFileHeader(stgm.u.hEnhMetaFile, sizeof(emh), &emh);
4687 if (has_size)
4689 convert_sizel(c, &run->ole_obj->sizel, &sz);
4690 } else {
4691 sz.cy = MulDiv(emh.rclBounds.bottom - emh.rclBounds.top, c->dpi.cx, 96);
4692 sz.cx = MulDiv(emh.rclBounds.right - emh.rclBounds.left, c->dpi.cy, 96);
4694 if (c->editor->nZoomNumerator != 0)
4696 sz.cx = MulDiv(sz.cx, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
4697 sz.cy = MulDiv(sz.cy, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
4701 RECT rc;
4703 rc.left = x;
4704 rc.top = y - sz.cy;
4705 rc.right = x + sz.cx;
4706 rc.bottom = y;
4707 PlayEnhMetaFile(c->hDC, stgm.u.hEnhMetaFile, &rc);
4709 if (!stgm.pUnkForRelease) DeleteEnhMetaFile(stgm.u.hEnhMetaFile);
4710 break;
4711 default:
4712 FIXME("Unsupported tymed %d\n", stgm.tymed);
4713 selected = FALSE;
4714 break;
4716 if (selected && !c->editor->bHideSelection)
4717 PatBlt(c->hDC, x, y - sz.cy, sz.cx, sz.cy, DSTINVERT);
4718 IDataObject_Release(ido);
4721 void ME_DeleteReObject(REOBJECT* reo)
4723 if (reo->poleobj) IOleObject_Release(reo->poleobj);
4724 if (reo->pstg) IStorage_Release(reo->pstg);
4725 if (reo->polesite) IOleClientSite_Release(reo->polesite);
4726 FREE_OBJ(reo);
4729 void ME_CopyReObject(REOBJECT* dst, const REOBJECT* src)
4731 *dst = *src;
4733 if (dst->poleobj) IOleObject_AddRef(dst->poleobj);
4734 if (dst->pstg) IStorage_AddRef(dst->pstg);
4735 if (dst->polesite) IOleClientSite_AddRef(dst->polesite);
4738 void ME_GetITextDocumentInterface(IRichEditOle *iface, LPVOID *ppvObj)
4740 IRichEditOleImpl *This = impl_from_IRichEditOle(iface);
4741 *ppvObj = &This->ITextDocument_iface;