[RICHED20] Sync with Wine Staging 3.9. CORE-14656
[reactos.git] / dll / win32 / riched20 / richole.c
1 /*
2 * RichEdit GUIDs and OLE interface
3 *
4 * Copyright 2004 by Krzysztof Foltman
5 * Copyright 2004 Aric Stewart
6 *
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.
11 *
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.
16 *
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
20 */
21
22 #include <stdarg.h>
23
24 #define NONAMELESSUNION
25 #define COBJMACROS
26
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"
37
38 WINE_DEFAULT_DEBUG_CHANNEL(richedit);
39
40 /* there is no way to be consistent across different sets of headers - mingw, Wine, Win32 SDK*/
41
42 #include "initguid.h"
43
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);
53
54 static ITypeLib *typelib;
55
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
64 };
65
66 static const IID * const tid_ids[] =
67 {
68 &IID_NULL,
69 &IID_ITextDocument,
70 &IID_ITextRange,
71 &IID_ITextSelection,
72 &IID_ITextFont,
73 &IID_ITextPara,
74 };
75 static ITypeInfo *typeinfos[LAST_tid];
76
77 static HRESULT load_typelib(void)
78 {
79 ITypeLib *tl;
80 HRESULT hr;
81
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;
86 }
87
88 if (InterlockedCompareExchangePointer((void**)&typelib, tl, NULL))
89 ITypeLib_Release(tl);
90 return hr;
91 }
92
93 void release_typelib(void)
94 {
95 unsigned i;
96
97 if (!typelib)
98 return;
99
100 for (i = 0; i < sizeof(typeinfos)/sizeof(*typeinfos); i++)
101 if (typeinfos[i])
102 ITypeInfo_Release(typeinfos[i]);
103
104 ITypeLib_Release(typelib);
105 }
106
107 static HRESULT get_typeinfo(enum tid_t tid, ITypeInfo **typeinfo)
108 {
109 HRESULT hr;
110
111 if (!typelib)
112 hr = load_typelib();
113 if (!typelib)
114 return hr;
115
116 if (!typeinfos[tid])
117 {
118 ITypeInfo *ti;
119
120 hr = ITypeLib_GetTypeInfoOfGuid(typelib, tid_ids[tid], &ti);
121 if (FAILED(hr))
122 {
123 ERR("GetTypeInfoOfGuid(%s) failed: %08x\n", debugstr_guid(tid_ids[tid]), hr);
124 return hr;
125 }
126
127 if (InterlockedCompareExchangePointer((void**)(typeinfos+tid), ti, NULL))
128 ITypeInfo_Release(ti);
129 }
130
131 *typeinfo = typeinfos[tid];
132 return S_OK;
133 }
134
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);
137
138 typedef struct ITextSelectionImpl ITextSelectionImpl;
139 typedef struct IOleClientSiteImpl IOleClientSiteImpl;
140 typedef struct ITextRangeImpl ITextRangeImpl;
141
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
169 };
170
171 static const DWORD textfont_prop_masks[][2] = {
172 { CFM_ALLCAPS, CFE_ALLCAPS },
173 { CFM_ANIMATION },
174 { CFM_BACKCOLOR, CFE_AUTOBACKCOLOR },
175 { CFM_BOLD, CFE_BOLD },
176 { CFM_EMBOSS, CFE_EMBOSS },
177 { CFM_COLOR, CFE_AUTOCOLOR },
178 { CFM_HIDDEN, CFE_HIDDEN },
179 { CFM_IMPRINT, CFE_IMPRINT },
180 { CFM_ITALIC, CFE_ITALIC },
181 { CFM_KERNING },
182 { CFM_LCID },
183 { CFM_FACE },
184 { CFM_OUTLINE, CFE_OUTLINE },
185 { CFM_OFFSET },
186 { CFM_PROTECTED, CFE_PROTECTED },
187 { CFM_SHADOW, CFE_SHADOW },
188 { CFM_SIZE },
189 { CFM_SMALLCAPS, CFE_SMALLCAPS },
190 { CFM_SPACING },
191 { CFM_STRIKEOUT, CFE_STRIKEOUT },
192 { CFM_SUBSCRIPT, CFE_SUBSCRIPT },
193 { CFM_SUPERSCRIPT, CFE_SUPERSCRIPT },
194 { CFM_UNDERLINE, CFE_UNDERLINE },
195 { CFM_WEIGHT }
196 };
197
198 typedef union {
199 FLOAT f;
200 LONG l;
201 BSTR str;
202 } textfont_prop_val;
203
204 enum range_update_op {
205 RANGE_UPDATE_DELETE
206 };
207
208 typedef struct IRichEditOleImpl {
209 IUnknown IUnknown_inner;
210 IRichEditOle IRichEditOle_iface;
211 ITextDocument ITextDocument_iface;
212 IUnknown *outer_unk;
213 LONG ref;
214
215 ME_TextEditor *editor;
216 ITextSelectionImpl *txtSel;
217
218 struct list rangelist;
219 struct list clientsites;
220 } IRichEditOleImpl;
221
222 struct reole_child {
223 struct list entry;
224 IRichEditOleImpl *reole;
225 };
226
227 struct ITextRangeImpl {
228 struct reole_child child;
229 ITextRange ITextRange_iface;
230 LONG ref;
231 LONG start, end;
232 };
233
234 struct ITextSelectionImpl {
235 ITextSelection ITextSelection_iface;
236 LONG ref;
237
238 IRichEditOleImpl *reOle;
239 };
240
241 typedef struct ITextFontImpl {
242 ITextFont ITextFont_iface;
243 LONG ref;
244
245 ITextRange *range;
246 textfont_prop_val props[FONT_PROPID_LAST];
247 BOOL get_cache_enabled;
248 BOOL set_cache_enabled;
249 } ITextFontImpl;
250
251 typedef struct ITextParaImpl {
252 ITextPara ITextPara_iface;
253 LONG ref;
254
255 ITextRange *range;
256 } ITextParaImpl;
257
258 struct IOleClientSiteImpl {
259 struct reole_child child;
260 IOleClientSite IOleClientSite_iface;
261 IOleInPlaceSite IOleInPlaceSite_iface;
262 LONG ref;
263 };
264
265 static inline IRichEditOleImpl *impl_from_IRichEditOle(IRichEditOle *iface)
266 {
267 return CONTAINING_RECORD(iface, IRichEditOleImpl, IRichEditOle_iface);
268 }
269
270 static inline IRichEditOleImpl *impl_from_ITextDocument(ITextDocument *iface)
271 {
272 return CONTAINING_RECORD(iface, IRichEditOleImpl, ITextDocument_iface);
273 }
274
275 static inline IRichEditOleImpl *impl_from_IUnknown(IUnknown *iface)
276 {
277 return CONTAINING_RECORD(iface, IRichEditOleImpl, IUnknown_inner);
278 }
279
280 static inline IOleClientSiteImpl *impl_from_IOleInPlaceSite(IOleInPlaceSite *iface)
281 {
282 return CONTAINING_RECORD(iface, IOleClientSiteImpl, IOleInPlaceSite_iface);
283 }
284
285 static inline ITextRangeImpl *impl_from_ITextRange(ITextRange *iface)
286 {
287 return CONTAINING_RECORD(iface, ITextRangeImpl, ITextRange_iface);
288 }
289
290 static inline ITextSelectionImpl *impl_from_ITextSelection(ITextSelection *iface)
291 {
292 return CONTAINING_RECORD(iface, ITextSelectionImpl, ITextSelection_iface);
293 }
294
295 static inline ITextFontImpl *impl_from_ITextFont(ITextFont *iface)
296 {
297 return CONTAINING_RECORD(iface, ITextFontImpl, ITextFont_iface);
298 }
299
300 static inline ITextParaImpl *impl_from_ITextPara(ITextPara *iface)
301 {
302 return CONTAINING_RECORD(iface, ITextParaImpl, ITextPara_iface);
303 }
304
305 static HRESULT create_textfont(ITextRange*, const ITextFontImpl*, ITextFont**);
306 static HRESULT create_textpara(ITextRange*, ITextPara**);
307 static ITextSelectionImpl *CreateTextSelection(IRichEditOleImpl*);
308
309 static HRESULT textrange_get_storylength(ME_TextEditor *editor, LONG *length)
310 {
311 if (!length)
312 return E_INVALIDARG;
313
314 *length = ME_GetTextLength(editor) + 1;
315 return S_OK;
316 }
317
318 static void textranges_update_ranges(IRichEditOleImpl *reole, LONG start, LONG end, enum range_update_op op)
319 {
320 ITextRangeImpl *range;
321
322 LIST_FOR_EACH_ENTRY(range, &reole->rangelist, ITextRangeImpl, child.entry) {
323 switch (op)
324 {
325 case RANGE_UPDATE_DELETE:
326 /* range fully covered by deleted range - collapse to insertion point */
327 if (range->start >= start && range->end <= end)
328 range->start = range->end = start;
329 /* deleted range cuts from the right */
330 else if (range->start < start && range->end <= end)
331 range->end = start;
332 /* deleted range cuts from the left */
333 else if (range->start >= start && range->end > end) {
334 range->start = start;
335 range->end -= end - start;
336 }
337 /* deleted range cuts within */
338 else
339 range->end -= end - start;
340 break;
341 default:
342 FIXME("unknown update op, %d\n", op);
343 }
344 }
345 }
346
347 static inline BOOL is_equal_textfont_prop_value(enum textfont_prop_id propid, textfont_prop_val *left,
348 textfont_prop_val *right)
349 {
350 switch (propid)
351 {
352 case FONT_ALLCAPS:
353 case FONT_ANIMATION:
354 case FONT_BACKCOLOR:
355 case FONT_BOLD:
356 case FONT_EMBOSS:
357 case FONT_FORECOLOR:
358 case FONT_HIDDEN:
359 case FONT_ENGRAVE:
360 case FONT_ITALIC:
361 case FONT_KERNING:
362 case FONT_LANGID:
363 case FONT_OUTLINE:
364 case FONT_PROTECTED:
365 case FONT_SHADOW:
366 case FONT_SMALLCAPS:
367 case FONT_STRIKETHROUGH:
368 case FONT_SUBSCRIPT:
369 case FONT_SUPERSCRIPT:
370 case FONT_UNDERLINE:
371 case FONT_WEIGHT:
372 return left->l == right->l;
373 case FONT_NAME:
374 return !strcmpW(left->str, right->str);
375 case FONT_POSITION:
376 case FONT_SIZE:
377 case FONT_SPACING:
378 return left->f == right->f;
379 default:
380 FIXME("unhandled font property %d\n", propid);
381 return FALSE;
382 }
383 }
384
385 static inline void init_textfont_prop_value(enum textfont_prop_id propid, textfont_prop_val *v)
386 {
387 switch (propid)
388 {
389 case FONT_ALLCAPS:
390 case FONT_ANIMATION:
391 case FONT_BACKCOLOR:
392 case FONT_BOLD:
393 case FONT_EMBOSS:
394 case FONT_FORECOLOR:
395 case FONT_HIDDEN:
396 case FONT_ENGRAVE:
397 case FONT_ITALIC:
398 case FONT_KERNING:
399 case FONT_LANGID:
400 case FONT_OUTLINE:
401 case FONT_PROTECTED:
402 case FONT_SHADOW:
403 case FONT_SMALLCAPS:
404 case FONT_STRIKETHROUGH:
405 case FONT_SUBSCRIPT:
406 case FONT_SUPERSCRIPT:
407 case FONT_UNDERLINE:
408 case FONT_WEIGHT:
409 v->l = tomUndefined;
410 return;
411 case FONT_NAME:
412 v->str = NULL;
413 return;
414 case FONT_POSITION:
415 case FONT_SIZE:
416 case FONT_SPACING:
417 v->f = tomUndefined;
418 return;
419 default:
420 FIXME("unhandled font property %d\n", propid);
421 v->l = tomUndefined;
422 return;
423 }
424 }
425
426 static inline FLOAT twips_to_points(LONG value)
427 {
428 return value * 72.0 / 1440;
429 }
430
431 static inline FLOAT points_to_twips(FLOAT value)
432 {
433 return value * 1440 / 72.0;
434 }
435
436 static HRESULT get_textfont_prop_for_pos(const IRichEditOleImpl *reole, int pos, enum textfont_prop_id propid,
437 textfont_prop_val *value)
438 {
439 ME_Cursor from, to;
440 CHARFORMAT2W fmt;
441
442 memset(&fmt, 0, sizeof(fmt));
443 fmt.cbSize = sizeof(fmt);
444 fmt.dwMask = textfont_prop_masks[propid][0];
445
446 ME_CursorFromCharOfs(reole->editor, pos, &from);
447 to = from;
448 ME_MoveCursorChars(reole->editor, &to, 1, FALSE);
449 ME_GetCharFormat(reole->editor, &from, &to, &fmt);
450
451 switch (propid)
452 {
453 case FONT_ALLCAPS:
454 case FONT_BOLD:
455 case FONT_EMBOSS:
456 case FONT_HIDDEN:
457 case FONT_ENGRAVE:
458 case FONT_ITALIC:
459 case FONT_OUTLINE:
460 case FONT_PROTECTED:
461 case FONT_SHADOW:
462 case FONT_SMALLCAPS:
463 case FONT_STRIKETHROUGH:
464 case FONT_SUBSCRIPT:
465 case FONT_SUPERSCRIPT:
466 case FONT_UNDERLINE:
467 value->l = fmt.dwEffects & textfont_prop_masks[propid][1] ? tomTrue : tomFalse;
468 break;
469 case FONT_ANIMATION:
470 value->l = fmt.bAnimation;
471 break;
472 case FONT_BACKCOLOR:
473 value->l = fmt.dwEffects & CFE_AUTOBACKCOLOR ? GetSysColor(COLOR_WINDOW) : fmt.crBackColor;
474 break;
475 case FONT_FORECOLOR:
476 value->l = fmt.dwEffects & CFE_AUTOCOLOR ? GetSysColor(COLOR_WINDOWTEXT) : fmt.crTextColor;
477 break;
478 case FONT_KERNING:
479 value->f = twips_to_points(fmt.wKerning);
480 break;
481 case FONT_LANGID:
482 value->l = fmt.lcid;
483 break;
484 case FONT_NAME:
485 /* this case is used exclusively by GetName() */
486 value->str = SysAllocString(fmt.szFaceName);
487 if (!value->str)
488 return E_OUTOFMEMORY;
489 break;
490 case FONT_POSITION:
491 value->f = twips_to_points(fmt.yOffset);
492 break;
493 case FONT_SIZE:
494 value->f = twips_to_points(fmt.yHeight);
495 break;
496 case FONT_SPACING:
497 value->f = fmt.sSpacing;
498 break;
499 case FONT_WEIGHT:
500 value->l = fmt.wWeight;
501 break;
502 default:
503 FIXME("unhandled font property %d\n", propid);
504 return E_FAIL;
505 }
506
507 return S_OK;
508 }
509
510 static inline const IRichEditOleImpl *get_range_reole(ITextRange *range)
511 {
512 IRichEditOleImpl *reole = NULL;
513 ITextRange_QueryInterface(range, &IID_Igetrichole, (void**)&reole);
514 return reole;
515 }
516
517 static void textrange_set_font(ITextRange *range, ITextFont *font)
518 {
519 CHARFORMAT2W fmt;
520 HRESULT hr;
521 LONG value;
522 BSTR str;
523 FLOAT f;
524
525 #define CHARFORMAT_SET_B_FIELD(mask, value) \
526 if (hr == S_OK && value != tomUndefined) { \
527 fmt.dwMask |= CFM_##mask; \
528 if (value == tomTrue) fmt.dwEffects |= CFE_##mask; \
529 } \
530
531 /* fill format data from font */
532 memset(&fmt, 0, sizeof(fmt));
533 fmt.cbSize = sizeof(fmt);
534
535 value = tomUndefined;
536 hr = ITextFont_GetAllCaps(font, &value);
537 CHARFORMAT_SET_B_FIELD(ALLCAPS, value);
538
539 value = tomUndefined;
540 hr = ITextFont_GetBold(font, &value);
541 CHARFORMAT_SET_B_FIELD(BOLD, value);
542
543 value = tomUndefined;
544 hr = ITextFont_GetEmboss(font, &value);
545 CHARFORMAT_SET_B_FIELD(EMBOSS, value);
546
547 value = tomUndefined;
548 hr = ITextFont_GetHidden(font, &value);
549 CHARFORMAT_SET_B_FIELD(HIDDEN, value);
550
551 value = tomUndefined;
552 hr = ITextFont_GetEngrave(font, &value);
553 CHARFORMAT_SET_B_FIELD(IMPRINT, value);
554
555 value = tomUndefined;
556 hr = ITextFont_GetItalic(font, &value);
557 CHARFORMAT_SET_B_FIELD(ITALIC, value);
558
559 value = tomUndefined;
560 hr = ITextFont_GetOutline(font, &value);
561 CHARFORMAT_SET_B_FIELD(OUTLINE, value);
562
563 value = tomUndefined;
564 hr = ITextFont_GetProtected(font, &value);
565 CHARFORMAT_SET_B_FIELD(PROTECTED, value);
566
567 value = tomUndefined;
568 hr = ITextFont_GetShadow(font, &value);
569 CHARFORMAT_SET_B_FIELD(SHADOW, value);
570
571 value = tomUndefined;
572 hr = ITextFont_GetSmallCaps(font, &value);
573 CHARFORMAT_SET_B_FIELD(SMALLCAPS, value);
574
575 value = tomUndefined;
576 hr = ITextFont_GetStrikeThrough(font, &value);
577 CHARFORMAT_SET_B_FIELD(STRIKEOUT, value);
578
579 value = tomUndefined;
580 hr = ITextFont_GetSubscript(font, &value);
581 CHARFORMAT_SET_B_FIELD(SUBSCRIPT, value);
582
583 value = tomUndefined;
584 hr = ITextFont_GetSuperscript(font, &value);
585 CHARFORMAT_SET_B_FIELD(SUPERSCRIPT, value);
586
587 value = tomUndefined;
588 hr = ITextFont_GetUnderline(font, &value);
589 CHARFORMAT_SET_B_FIELD(UNDERLINE, value);
590
591 #undef CHARFORMAT_SET_B_FIELD
592
593 value = tomUndefined;
594 hr = ITextFont_GetAnimation(font, &value);
595 if (hr == S_OK && value != tomUndefined) {
596 fmt.dwMask |= CFM_ANIMATION;
597 fmt.bAnimation = value;
598 }
599
600 value = tomUndefined;
601 hr = ITextFont_GetBackColor(font, &value);
602 if (hr == S_OK && value != tomUndefined) {
603 fmt.dwMask |= CFM_BACKCOLOR;
604 if (value == tomAutoColor)
605 fmt.dwEffects |= CFE_AUTOBACKCOLOR;
606 else
607 fmt.crBackColor = value;
608 }
609
610 value = tomUndefined;
611 hr = ITextFont_GetForeColor(font, &value);
612 if (hr == S_OK && value != tomUndefined) {
613 fmt.dwMask |= CFM_COLOR;
614 if (value == tomAutoColor)
615 fmt.dwEffects |= CFE_AUTOCOLOR;
616 else
617 fmt.crTextColor = value;
618 }
619
620 value = tomUndefined;
621 hr = ITextFont_GetKerning(font, &f);
622 if (hr == S_OK && f != tomUndefined) {
623 fmt.dwMask |= CFM_KERNING;
624 fmt.wKerning = points_to_twips(f);
625 }
626
627 value = tomUndefined;
628 hr = ITextFont_GetLanguageID(font, &value);
629 if (hr == S_OK && value != tomUndefined) {
630 fmt.dwMask |= CFM_LCID;
631 fmt.lcid = value;
632 }
633
634 if (ITextFont_GetName(font, &str) == S_OK) {
635 fmt.dwMask |= CFM_FACE;
636 lstrcpynW(fmt.szFaceName, str, sizeof(fmt.szFaceName)/sizeof(WCHAR));
637 SysFreeString(str);
638 }
639
640 hr = ITextFont_GetPosition(font, &f);
641 if (hr == S_OK && f != tomUndefined) {
642 fmt.dwMask |= CFM_OFFSET;
643 fmt.yOffset = points_to_twips(f);
644 }
645
646 hr = ITextFont_GetSize(font, &f);
647 if (hr == S_OK && f != tomUndefined) {
648 fmt.dwMask |= CFM_SIZE;
649 fmt.yHeight = points_to_twips(f);
650 }
651
652 hr = ITextFont_GetSpacing(font, &f);
653 if (hr == S_OK && f != tomUndefined) {
654 fmt.dwMask |= CFM_SPACING;
655 fmt.sSpacing = f;
656 }
657
658 hr = ITextFont_GetWeight(font, &value);
659 if (hr == S_OK && value != tomUndefined) {
660 fmt.dwMask |= CFM_WEIGHT;
661 fmt.wWeight = value;
662 }
663
664 if (fmt.dwMask) {
665 const IRichEditOleImpl *reole = get_range_reole(range);
666 ME_Cursor from, to;
667 LONG start, end;
668
669 ITextRange_GetStart(range, &start);
670 ITextRange_GetEnd(range, &end);
671
672 ME_CursorFromCharOfs(reole->editor, start, &from);
673 ME_CursorFromCharOfs(reole->editor, end, &to);
674 ME_SetCharFormat(reole->editor, &from, &to, &fmt);
675 }
676 }
677
678 static HRESULT get_textfont_prop(const ITextFontImpl *font, enum textfont_prop_id propid, textfont_prop_val *value)
679 {
680 const IRichEditOleImpl *reole;
681 textfont_prop_val v;
682 LONG start, end, i;
683 HRESULT hr;
684
685 /* when font is not attached to any range use cached values */
686 if (!font->range || font->get_cache_enabled) {
687 *value = font->props[propid];
688 return S_OK;
689 }
690
691 if (!(reole = get_range_reole(font->range)))
692 return CO_E_RELEASED;
693
694 init_textfont_prop_value(propid, value);
695
696 ITextRange_GetStart(font->range, &start);
697 ITextRange_GetEnd(font->range, &end);
698
699 /* iterate trough a range to see if property value is consistent */
700 hr = get_textfont_prop_for_pos(reole, start, propid, &v);
701 if (FAILED(hr))
702 return hr;
703
704 for (i = start + 1; i < end; i++) {
705 textfont_prop_val cur;
706
707 hr = get_textfont_prop_for_pos(reole, i, propid, &cur);
708 if (FAILED(hr))
709 return hr;
710
711 if (!is_equal_textfont_prop_value(propid, &v, &cur))
712 return S_OK;
713 }
714
715 *value = v;
716 return S_OK;
717 }
718
719 static HRESULT get_textfont_propf(const ITextFontImpl *font, enum textfont_prop_id propid, FLOAT *value)
720 {
721 textfont_prop_val v;
722 HRESULT hr;
723
724 if (!value)
725 return E_INVALIDARG;
726
727 hr = get_textfont_prop(font, propid, &v);
728 *value = v.f;
729 return hr;
730 }
731
732 static HRESULT get_textfont_propl(const ITextFontImpl *font, enum textfont_prop_id propid, LONG *value)
733 {
734 textfont_prop_val v;
735 HRESULT hr;
736
737 if (!value)
738 return E_INVALIDARG;
739
740 hr = get_textfont_prop(font, propid, &v);
741 *value = v.l;
742 return hr;
743 }
744
745 /* Value should already have a terminal value, for boolean properties it means tomToggle is not handled */
746 static HRESULT set_textfont_prop(ITextFontImpl *font, enum textfont_prop_id propid, const textfont_prop_val *value)
747 {
748 const IRichEditOleImpl *reole;
749 ME_Cursor from, to;
750 CHARFORMAT2W fmt;
751 LONG start, end;
752
753 /* when font is not attached to any range use cache */
754 if (!font->range || font->set_cache_enabled) {
755 if (propid == FONT_NAME) {
756 SysFreeString(font->props[propid].str);
757 font->props[propid].str = SysAllocString(value->str);
758 }
759 else
760 font->props[propid] = *value;
761 return S_OK;
762 }
763
764 if (!(reole = get_range_reole(font->range)))
765 return CO_E_RELEASED;
766
767 memset(&fmt, 0, sizeof(fmt));
768 fmt.cbSize = sizeof(fmt);
769 fmt.dwMask = textfont_prop_masks[propid][0];
770
771 switch (propid)
772 {
773 case FONT_ALLCAPS:
774 case FONT_BOLD:
775 case FONT_EMBOSS:
776 case FONT_HIDDEN:
777 case FONT_ENGRAVE:
778 case FONT_ITALIC:
779 case FONT_OUTLINE:
780 case FONT_PROTECTED:
781 case FONT_SHADOW:
782 case FONT_SMALLCAPS:
783 case FONT_STRIKETHROUGH:
784 case FONT_SUBSCRIPT:
785 case FONT_SUPERSCRIPT:
786 case FONT_UNDERLINE:
787 fmt.dwEffects = value->l == tomTrue ? textfont_prop_masks[propid][1] : 0;
788 break;
789 case FONT_ANIMATION:
790 fmt.bAnimation = value->l;
791 break;
792 case FONT_BACKCOLOR:
793 case FONT_FORECOLOR:
794 if (value->l == tomAutoColor)
795 fmt.dwEffects = textfont_prop_masks[propid][1];
796 else if (propid == FONT_BACKCOLOR)
797 fmt.crBackColor = value->l;
798 else
799 fmt.crTextColor = value->l;
800 break;
801 case FONT_KERNING:
802 fmt.wKerning = value->f;
803 break;
804 case FONT_LANGID:
805 fmt.lcid = value->l;
806 break;
807 case FONT_POSITION:
808 fmt.yOffset = value->f;
809 break;
810 case FONT_SIZE:
811 fmt.yHeight = value->f;
812 break;
813 case FONT_SPACING:
814 fmt.sSpacing = value->f;
815 break;
816 case FONT_WEIGHT:
817 fmt.wWeight = value->l;
818 break;
819 case FONT_NAME:
820 lstrcpynW(fmt.szFaceName, value->str, sizeof(fmt.szFaceName)/sizeof(WCHAR));
821 break;
822 default:
823 FIXME("unhandled font property %d\n", propid);
824 return E_FAIL;
825 }
826
827 ITextRange_GetStart(font->range, &start);
828 ITextRange_GetEnd(font->range, &end);
829
830 ME_CursorFromCharOfs(reole->editor, start, &from);
831 ME_CursorFromCharOfs(reole->editor, end, &to);
832 ME_SetCharFormat(reole->editor, &from, &to, &fmt);
833
834 return S_OK;
835 }
836
837 static inline HRESULT set_textfont_propl(ITextFontImpl *font, enum textfont_prop_id propid, LONG value)
838 {
839 textfont_prop_val v;
840 v.l = value;
841 return set_textfont_prop(font, propid, &v);
842 }
843
844 static inline HRESULT set_textfont_propf(ITextFontImpl *font, enum textfont_prop_id propid, FLOAT value)
845 {
846 textfont_prop_val v;
847 v.f = value;
848 return set_textfont_prop(font, propid, &v);
849 }
850
851 static HRESULT set_textfont_propd(ITextFontImpl *font, enum textfont_prop_id propid, LONG value)
852 {
853 textfont_prop_val v;
854
855 switch (value)
856 {
857 case tomUndefined:
858 return S_OK;
859 case tomToggle: {
860 LONG oldvalue;
861 get_textfont_propl(font, propid, &oldvalue);
862 if (oldvalue == tomFalse)
863 value = tomTrue;
864 else if (oldvalue == tomTrue)
865 value = tomFalse;
866 else
867 return E_INVALIDARG;
868 /* fallthrough */
869 }
870 case tomTrue:
871 case tomFalse:
872 v.l = value;
873 return set_textfont_prop(font, propid, &v);
874 default:
875 return E_INVALIDARG;
876 }
877 }
878
879 static HRESULT textfont_getname_from_range(ITextRange *range, BSTR *ret)
880 {
881 const IRichEditOleImpl *reole;
882 textfont_prop_val v;
883 HRESULT hr;
884 LONG start;
885
886 if (!(reole = get_range_reole(range)))
887 return CO_E_RELEASED;
888
889 ITextRange_GetStart(range, &start);
890 hr = get_textfont_prop_for_pos(reole, start, FONT_NAME, &v);
891 *ret = v.str;
892 return hr;
893 }
894
895 static void textfont_cache_range_props(ITextFontImpl *font)
896 {
897 enum textfont_prop_id propid;
898 for (propid = FONT_PROPID_FIRST; propid < FONT_PROPID_LAST; propid++) {
899 if (propid == FONT_NAME)
900 textfont_getname_from_range(font->range, &font->props[propid].str);
901 else
902 get_textfont_prop(font, propid, &font->props[propid]);
903 }
904 }
905
906 static HRESULT textrange_expand(ITextRange *range, LONG unit, LONG *delta)
907 {
908 LONG expand_start, expand_end;
909
910 switch (unit)
911 {
912 case tomStory:
913 expand_start = 0;
914 ITextRange_GetStoryLength(range, &expand_end);
915 break;
916 default:
917 FIXME("unit %d is not supported\n", unit);
918 return E_NOTIMPL;
919 }
920
921 if (delta) {
922 LONG start, end;
923
924 ITextRange_GetStart(range, &start);
925 ITextRange_GetEnd(range, &end);
926 *delta = expand_end - expand_start - (end - start);
927 }
928
929 ITextRange_SetStart(range, expand_start);
930 ITextRange_SetEnd(range, expand_end);
931
932 return S_OK;
933 }
934
935 static HRESULT WINAPI IRichEditOleImpl_inner_fnQueryInterface(IUnknown *iface, REFIID riid, LPVOID *ppvObj)
936 {
937 IRichEditOleImpl *This = impl_from_IUnknown(iface);
938
939 TRACE("%p %s\n", This, debugstr_guid(riid));
940
941 *ppvObj = NULL;
942 if (IsEqualGUID(riid, &IID_IUnknown))
943 *ppvObj = &This->IUnknown_inner;
944 else if (IsEqualGUID(riid, &IID_IRichEditOle))
945 *ppvObj = &This->IRichEditOle_iface;
946 else if (IsEqualGUID(riid, &IID_ITextDocument))
947 *ppvObj = &This->ITextDocument_iface;
948 if (*ppvObj)
949 {
950 IUnknown_AddRef((IUnknown *)*ppvObj);
951 return S_OK;
952 }
953
954 if (IsEqualGUID(riid, &IID_ITextServices))
955 {
956 static int once;
957 if (!once++) FIXME("%p: unhandled interface IID_ITextServices\n", This);
958 return E_NOINTERFACE;
959 }
960
961 FIXME("%p: unhandled interface %s\n", This, debugstr_guid(riid));
962
963 return E_NOINTERFACE;
964 }
965
966 static ULONG WINAPI IRichEditOleImpl_inner_fnAddRef(IUnknown *iface)
967 {
968 IRichEditOleImpl *This = impl_from_IUnknown(iface);
969 ULONG ref = InterlockedIncrement(&This->ref);
970
971 TRACE("%p ref = %u\n", This, ref);
972
973 return ref;
974 }
975
976 static ULONG WINAPI IRichEditOleImpl_inner_fnRelease(IUnknown *iface)
977 {
978 IRichEditOleImpl *This = impl_from_IUnknown(iface);
979 ULONG ref = InterlockedDecrement(&This->ref);
980
981 TRACE ("%p ref=%u\n", This, ref);
982
983 if (!ref)
984 {
985 IOleClientSiteImpl *clientsite;
986 ITextRangeImpl *txtRge;
987
988 This->editor->reOle = NULL;
989 if (This->txtSel) {
990 This->txtSel->reOle = NULL;
991 ITextSelection_Release(&This->txtSel->ITextSelection_iface);
992 }
993
994 LIST_FOR_EACH_ENTRY(txtRge, &This->rangelist, ITextRangeImpl, child.entry)
995 txtRge->child.reole = NULL;
996
997 LIST_FOR_EACH_ENTRY(clientsite, &This->clientsites, IOleClientSiteImpl, child.entry)
998 clientsite->child.reole = NULL;
999
1000 heap_free(This);
1001 }
1002 return ref;
1003 }
1004
1005 static const IUnknownVtbl reo_unk_vtbl =
1006 {
1007 IRichEditOleImpl_inner_fnQueryInterface,
1008 IRichEditOleImpl_inner_fnAddRef,
1009 IRichEditOleImpl_inner_fnRelease
1010 };
1011
1012 static HRESULT WINAPI
1013 IRichEditOle_fnQueryInterface(IRichEditOle *me, REFIID riid, LPVOID *ppvObj)
1014 {
1015 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
1016 return IUnknown_QueryInterface(This->outer_unk, riid, ppvObj);
1017 }
1018
1019 static ULONG WINAPI
1020 IRichEditOle_fnAddRef(IRichEditOle *me)
1021 {
1022 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
1023 return IUnknown_AddRef(This->outer_unk);
1024 }
1025
1026 static ULONG WINAPI
1027 IRichEditOle_fnRelease(IRichEditOle *me)
1028 {
1029 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
1030 return IUnknown_Release(This->outer_unk);
1031 }
1032
1033 static HRESULT WINAPI
1034 IRichEditOle_fnActivateAs(IRichEditOle *me, REFCLSID rclsid, REFCLSID rclsidAs)
1035 {
1036 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
1037 FIXME("stub %p\n",This);
1038 return E_NOTIMPL;
1039 }
1040
1041 static HRESULT WINAPI
1042 IRichEditOle_fnContextSensitiveHelp(IRichEditOle *me, BOOL fEnterMode)
1043 {
1044 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
1045 FIXME("stub %p\n",This);
1046 return E_NOTIMPL;
1047 }
1048
1049 static HRESULT WINAPI
1050 IRichEditOle_fnConvertObject(IRichEditOle *me, LONG iob,
1051 REFCLSID rclsidNew, LPCSTR lpstrUserTypeNew)
1052 {
1053 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
1054 FIXME("stub %p\n",This);
1055 return E_NOTIMPL;
1056 }
1057
1058 static inline IOleClientSiteImpl *impl_from_IOleClientSite(IOleClientSite *iface)
1059 {
1060 return CONTAINING_RECORD(iface, IOleClientSiteImpl, IOleClientSite_iface);
1061 }
1062
1063 static HRESULT WINAPI
1064 IOleClientSite_fnQueryInterface(IOleClientSite *me, REFIID riid, LPVOID *ppvObj)
1065 {
1066 IOleClientSiteImpl *This = impl_from_IOleClientSite(me);
1067 TRACE("%p %s\n", me, debugstr_guid(riid) );
1068
1069 *ppvObj = NULL;
1070 if (IsEqualGUID(riid, &IID_IUnknown) ||
1071 IsEqualGUID(riid, &IID_IOleClientSite))
1072 *ppvObj = me;
1073 else if (IsEqualGUID(riid, &IID_IOleWindow) ||
1074 IsEqualGUID(riid, &IID_IOleInPlaceSite))
1075 *ppvObj = &This->IOleInPlaceSite_iface;
1076 if (*ppvObj)
1077 {
1078 IOleClientSite_AddRef(me);
1079 return S_OK;
1080 }
1081 FIXME("%p: unhandled interface %s\n", me, debugstr_guid(riid) );
1082
1083 return E_NOINTERFACE;
1084 }
1085
1086 static ULONG WINAPI IOleClientSite_fnAddRef(IOleClientSite *iface)
1087 {
1088 IOleClientSiteImpl *This = impl_from_IOleClientSite(iface);
1089 ULONG ref = InterlockedIncrement(&This->ref);
1090 TRACE("(%p)->(%u)\n", This, ref);
1091 return ref;
1092 }
1093
1094 static ULONG WINAPI IOleClientSite_fnRelease(IOleClientSite *iface)
1095 {
1096 IOleClientSiteImpl *This = impl_from_IOleClientSite(iface);
1097 ULONG ref = InterlockedDecrement(&This->ref);
1098
1099 TRACE("(%p)->(%u)\n", This, ref);
1100
1101 if (ref == 0) {
1102 if (This->child.reole) {
1103 list_remove(&This->child.entry);
1104 This->child.reole = NULL;
1105 }
1106 heap_free(This);
1107 }
1108 return ref;
1109 }
1110
1111 static HRESULT WINAPI IOleClientSite_fnSaveObject(IOleClientSite *iface)
1112 {
1113 IOleClientSiteImpl *This = impl_from_IOleClientSite(iface);
1114 if (!This->child.reole)
1115 return CO_E_RELEASED;
1116
1117 FIXME("stub %p\n", iface);
1118 return E_NOTIMPL;
1119 }
1120
1121 static HRESULT WINAPI IOleClientSite_fnGetMoniker(IOleClientSite *iface, DWORD dwAssign,
1122 DWORD dwWhichMoniker, IMoniker **ppmk)
1123 {
1124 IOleClientSiteImpl *This = impl_from_IOleClientSite(iface);
1125 if (!This->child.reole)
1126 return CO_E_RELEASED;
1127
1128 FIXME("stub %p\n", iface);
1129 return E_NOTIMPL;
1130 }
1131
1132 static HRESULT WINAPI IOleClientSite_fnGetContainer(IOleClientSite *iface,
1133 IOleContainer **ppContainer)
1134 {
1135 IOleClientSiteImpl *This = impl_from_IOleClientSite(iface);
1136 if (!This->child.reole)
1137 return CO_E_RELEASED;
1138
1139 FIXME("stub %p\n", iface);
1140 return E_NOTIMPL;
1141 }
1142
1143 static HRESULT WINAPI IOleClientSite_fnShowObject(IOleClientSite *iface)
1144 {
1145 IOleClientSiteImpl *This = impl_from_IOleClientSite(iface);
1146 if (!This->child.reole)
1147 return CO_E_RELEASED;
1148
1149 FIXME("stub %p\n", iface);
1150 return E_NOTIMPL;
1151 }
1152
1153 static HRESULT WINAPI IOleClientSite_fnOnShowWindow(IOleClientSite *iface, BOOL fShow)
1154 {
1155 IOleClientSiteImpl *This = impl_from_IOleClientSite(iface);
1156 if (!This->child.reole)
1157 return CO_E_RELEASED;
1158
1159 FIXME("stub %p\n", iface);
1160 return E_NOTIMPL;
1161 }
1162
1163 static HRESULT WINAPI IOleClientSite_fnRequestNewObjectLayout(IOleClientSite *iface)
1164 {
1165 IOleClientSiteImpl *This = impl_from_IOleClientSite(iface);
1166 if (!This->child.reole)
1167 return CO_E_RELEASED;
1168
1169 FIXME("stub %p\n", iface);
1170 return E_NOTIMPL;
1171 }
1172
1173 static const IOleClientSiteVtbl ocst = {
1174 IOleClientSite_fnQueryInterface,
1175 IOleClientSite_fnAddRef,
1176 IOleClientSite_fnRelease,
1177 IOleClientSite_fnSaveObject,
1178 IOleClientSite_fnGetMoniker,
1179 IOleClientSite_fnGetContainer,
1180 IOleClientSite_fnShowObject,
1181 IOleClientSite_fnOnShowWindow,
1182 IOleClientSite_fnRequestNewObjectLayout
1183 };
1184
1185 /* IOleInPlaceSite interface */
1186 static HRESULT STDMETHODCALLTYPE IOleInPlaceSite_fnQueryInterface(IOleInPlaceSite *iface, REFIID riid, void **ppvObj)
1187 {
1188 IOleClientSiteImpl *This = impl_from_IOleInPlaceSite(iface);
1189 return IOleClientSite_QueryInterface(&This->IOleClientSite_iface, riid, ppvObj);
1190 }
1191
1192 static ULONG STDMETHODCALLTYPE IOleInPlaceSite_fnAddRef(IOleInPlaceSite *iface)
1193 {
1194 IOleClientSiteImpl *This = impl_from_IOleInPlaceSite(iface);
1195 return IOleClientSite_AddRef(&This->IOleClientSite_iface);
1196 }
1197
1198 static ULONG STDMETHODCALLTYPE IOleInPlaceSite_fnRelease(IOleInPlaceSite *iface)
1199 {
1200 IOleClientSiteImpl *This = impl_from_IOleInPlaceSite(iface);
1201 return IOleClientSite_Release(&This->IOleClientSite_iface);
1202 }
1203
1204 static HRESULT STDMETHODCALLTYPE IOleInPlaceSite_fnGetWindow(IOleInPlaceSite *iface, HWND *phwnd)
1205 {
1206 IOleClientSiteImpl *This = impl_from_IOleInPlaceSite(iface);
1207
1208 TRACE("(%p)->(%p)\n", This, phwnd);
1209
1210 if (!This->child.reole)
1211 return CO_E_RELEASED;
1212
1213 if (!phwnd)
1214 return E_INVALIDARG;
1215
1216 *phwnd = This->child.reole->editor->hWnd;
1217 return S_OK;
1218 }
1219
1220 static HRESULT STDMETHODCALLTYPE IOleInPlaceSite_fnContextSensitiveHelp(IOleInPlaceSite *iface, BOOL fEnterMode)
1221 {
1222 IOleClientSiteImpl *This = impl_from_IOleInPlaceSite(iface);
1223 FIXME("not implemented: (%p)->(%d)\n", This, fEnterMode);
1224 return E_NOTIMPL;
1225 }
1226
1227 static HRESULT STDMETHODCALLTYPE IOleInPlaceSite_fnCanInPlaceActivate(IOleInPlaceSite *iface)
1228 {
1229 IOleClientSiteImpl *This = impl_from_IOleInPlaceSite(iface);
1230 FIXME("not implemented: (%p)\n", This);
1231 return E_NOTIMPL;
1232 }
1233
1234 static HRESULT STDMETHODCALLTYPE IOleInPlaceSite_fnOnInPlaceActivate(IOleInPlaceSite *iface)
1235 {
1236 IOleClientSiteImpl *This = impl_from_IOleInPlaceSite(iface);
1237 FIXME("not implemented: (%p)\n", This);
1238 return E_NOTIMPL;
1239 }
1240
1241 static HRESULT STDMETHODCALLTYPE IOleInPlaceSite_fnOnUIActivate(IOleInPlaceSite *iface)
1242 {
1243 IOleClientSiteImpl *This = impl_from_IOleInPlaceSite(iface);
1244 FIXME("not implemented: (%p)\n", This);
1245 return E_NOTIMPL;
1246 }
1247
1248 static HRESULT STDMETHODCALLTYPE IOleInPlaceSite_fnGetWindowContext(IOleInPlaceSite *iface, IOleInPlaceFrame **ppFrame,
1249 IOleInPlaceUIWindow **ppDoc, LPRECT lprcPosRect,
1250 LPRECT lprcClipRect, LPOLEINPLACEFRAMEINFO lpFrameInfo)
1251 {
1252 IOleClientSiteImpl *This = impl_from_IOleInPlaceSite(iface);
1253 FIXME("not implemented: (%p)->(%p %p %p %p %p)\n", This, ppFrame, ppDoc, lprcPosRect, lprcClipRect, lpFrameInfo);
1254 return E_NOTIMPL;
1255 }
1256
1257 static HRESULT STDMETHODCALLTYPE IOleInPlaceSite_fnScroll(IOleInPlaceSite *iface, SIZE scrollExtent)
1258 {
1259 IOleClientSiteImpl *This = impl_from_IOleInPlaceSite(iface);
1260 FIXME("not implemented: (%p)\n", This);
1261 return E_NOTIMPL;
1262 }
1263
1264 static HRESULT STDMETHODCALLTYPE IOleInPlaceSite_fnOnUIDeactivate(IOleInPlaceSite *iface, BOOL fUndoable)
1265 {
1266 IOleClientSiteImpl *This = impl_from_IOleInPlaceSite(iface);
1267 FIXME("not implemented: (%p)->(%d)\n", This, fUndoable);
1268 return E_NOTIMPL;
1269 }
1270
1271 static HRESULT STDMETHODCALLTYPE IOleInPlaceSite_fnOnInPlaceDeactivate(IOleInPlaceSite *iface)
1272 {
1273 IOleClientSiteImpl *This = impl_from_IOleInPlaceSite(iface);
1274 FIXME("not implemented: (%p)\n", This);
1275 return E_NOTIMPL;
1276 }
1277
1278 static HRESULT STDMETHODCALLTYPE IOleInPlaceSite_fnDiscardUndoState(IOleInPlaceSite *iface)
1279 {
1280 IOleClientSiteImpl *This = impl_from_IOleInPlaceSite(iface);
1281 FIXME("not implemented: (%p)\n", This);
1282 return E_NOTIMPL;
1283 }
1284
1285 static HRESULT STDMETHODCALLTYPE IOleInPlaceSite_fnDeactivateAndUndo(IOleInPlaceSite *iface)
1286 {
1287 IOleClientSiteImpl *This = impl_from_IOleInPlaceSite(iface);
1288 FIXME("not implemented: (%p)\n", This);
1289 return E_NOTIMPL;
1290 }
1291
1292 static HRESULT STDMETHODCALLTYPE IOleInPlaceSite_fnOnPosRectChange(IOleInPlaceSite *iface, LPCRECT lprcPosRect)
1293 {
1294 IOleClientSiteImpl *This = impl_from_IOleInPlaceSite(iface);
1295 FIXME("not implemented: (%p)->(%p)\n", This, lprcPosRect);
1296 return E_NOTIMPL;
1297 }
1298
1299 static const IOleInPlaceSiteVtbl olestvt =
1300 {
1301 IOleInPlaceSite_fnQueryInterface,
1302 IOleInPlaceSite_fnAddRef,
1303 IOleInPlaceSite_fnRelease,
1304 IOleInPlaceSite_fnGetWindow,
1305 IOleInPlaceSite_fnContextSensitiveHelp,
1306 IOleInPlaceSite_fnCanInPlaceActivate,
1307 IOleInPlaceSite_fnOnInPlaceActivate,
1308 IOleInPlaceSite_fnOnUIActivate,
1309 IOleInPlaceSite_fnGetWindowContext,
1310 IOleInPlaceSite_fnScroll,
1311 IOleInPlaceSite_fnOnUIDeactivate,
1312 IOleInPlaceSite_fnOnInPlaceDeactivate,
1313 IOleInPlaceSite_fnDiscardUndoState,
1314 IOleInPlaceSite_fnDeactivateAndUndo,
1315 IOleInPlaceSite_fnOnPosRectChange
1316 };
1317
1318 static HRESULT CreateOleClientSite(IRichEditOleImpl *reOle, IOleClientSite **ret)
1319 {
1320 IOleClientSiteImpl *clientSite = heap_alloc(sizeof *clientSite);
1321
1322 if (!clientSite)
1323 return E_OUTOFMEMORY;
1324
1325 clientSite->IOleClientSite_iface.lpVtbl = &ocst;
1326 clientSite->IOleInPlaceSite_iface.lpVtbl = &olestvt;
1327 clientSite->ref = 1;
1328 clientSite->child.reole = reOle;
1329 list_add_head(&reOle->clientsites, &clientSite->child.entry);
1330
1331 *ret = &clientSite->IOleClientSite_iface;
1332 return S_OK;
1333 }
1334
1335 static HRESULT WINAPI
1336 IRichEditOle_fnGetClientSite(IRichEditOle *me, IOleClientSite **clientsite)
1337 {
1338 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
1339
1340 TRACE("(%p)->(%p)\n", This, clientsite);
1341
1342 if (!clientsite)
1343 return E_INVALIDARG;
1344
1345 return CreateOleClientSite(This, clientsite);
1346 }
1347
1348 static HRESULT WINAPI
1349 IRichEditOle_fnGetClipboardData(IRichEditOle *me, CHARRANGE *lpchrg,
1350 DWORD reco, LPDATAOBJECT *lplpdataobj)
1351 {
1352 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
1353 ME_Cursor start;
1354 int nChars;
1355
1356 TRACE("(%p,%p,%d)\n",This, lpchrg, reco);
1357 if(!lplpdataobj)
1358 return E_INVALIDARG;
1359 if(!lpchrg) {
1360 int nFrom, nTo, nStartCur = ME_GetSelectionOfs(This->editor, &nFrom, &nTo);
1361 start = This->editor->pCursors[nStartCur];
1362 nChars = nTo - nFrom;
1363 } else {
1364 ME_CursorFromCharOfs(This->editor, lpchrg->cpMin, &start);
1365 nChars = lpchrg->cpMax - lpchrg->cpMin;
1366 }
1367 return ME_GetDataObject(This->editor, &start, nChars, lplpdataobj);
1368 }
1369
1370 static LONG WINAPI IRichEditOle_fnGetLinkCount(IRichEditOle *me)
1371 {
1372 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
1373 FIXME("stub %p\n",This);
1374 return E_NOTIMPL;
1375 }
1376
1377 static HRESULT WINAPI
1378 IRichEditOle_fnGetObject(IRichEditOle *me, LONG iob,
1379 REOBJECT *lpreobject, DWORD dwFlags)
1380 {
1381 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
1382 struct re_object *reobj = NULL;
1383 LONG count = 0;
1384
1385 TRACE("(%p)->(%x, %p, %x)\n", This, iob, lpreobject, dwFlags);
1386
1387 if (!lpreobject || !lpreobject->cbStruct)
1388 return E_INVALIDARG;
1389
1390 if (iob == REO_IOB_USE_CP)
1391 {
1392 ME_Cursor cursor;
1393
1394 TRACE("character offset: %d\n", lpreobject->cp);
1395 ME_CursorFromCharOfs(This->editor, lpreobject->cp, &cursor);
1396 if (!cursor.pRun->member.run.reobj)
1397 return E_INVALIDARG;
1398 else
1399 reobj = cursor.pRun->member.run.reobj;
1400 }
1401 else
1402 {
1403 if (iob > IRichEditOle_GetObjectCount(me))
1404 return E_INVALIDARG;
1405 LIST_FOR_EACH_ENTRY(reobj, &This->editor->reobj_list, struct re_object, entry)
1406 {
1407 if (count == iob)
1408 break;
1409 count++;
1410 }
1411 }
1412 ME_CopyReObject(lpreobject, &reobj->obj, dwFlags);
1413 return S_OK;
1414 }
1415
1416 static LONG WINAPI
1417 IRichEditOle_fnGetObjectCount(IRichEditOle *me)
1418 {
1419 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
1420 TRACE("(%p)\n",This);
1421 return list_count(&This->editor->reobj_list);
1422 }
1423
1424 static HRESULT WINAPI
1425 IRichEditOle_fnHandsOffStorage(IRichEditOle *me, LONG iob)
1426 {
1427 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
1428 FIXME("stub %p\n",This);
1429 return E_NOTIMPL;
1430 }
1431
1432 static HRESULT WINAPI
1433 IRichEditOle_fnImportDataObject(IRichEditOle *me, LPDATAOBJECT lpdataobj,
1434 CLIPFORMAT cf, HGLOBAL hMetaPict)
1435 {
1436 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
1437 FIXME("stub %p\n",This);
1438 return E_NOTIMPL;
1439 }
1440
1441 static HRESULT WINAPI
1442 IRichEditOle_fnInPlaceDeactivate(IRichEditOle *me)
1443 {
1444 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
1445 FIXME("stub %p\n",This);
1446 return E_NOTIMPL;
1447 }
1448
1449 static HRESULT WINAPI
1450 IRichEditOle_fnInsertObject(IRichEditOle *me, REOBJECT *reo)
1451 {
1452 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
1453
1454 TRACE("(%p,%p)\n", This, reo);
1455
1456 if (!reo)
1457 return E_INVALIDARG;
1458
1459 if (reo->cbStruct < sizeof(*reo)) return STG_E_INVALIDPARAMETER;
1460
1461 ME_InsertOLEFromCursor(This->editor, reo, 0);
1462 ME_CommitUndo(This->editor);
1463 ME_UpdateRepaint(This->editor, FALSE);
1464 return S_OK;
1465 }
1466
1467 static HRESULT WINAPI IRichEditOle_fnSaveCompleted(IRichEditOle *me, LONG iob,
1468 LPSTORAGE lpstg)
1469 {
1470 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
1471 FIXME("stub %p\n",This);
1472 return E_NOTIMPL;
1473 }
1474
1475 static HRESULT WINAPI
1476 IRichEditOle_fnSetDvaspect(IRichEditOle *me, LONG iob, DWORD dvaspect)
1477 {
1478 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
1479 FIXME("stub %p\n",This);
1480 return E_NOTIMPL;
1481 }
1482
1483 static HRESULT WINAPI IRichEditOle_fnSetHostNames(IRichEditOle *me,
1484 LPCSTR lpstrContainerApp, LPCSTR lpstrContainerObj)
1485 {
1486 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
1487 FIXME("stub %p %s %s\n",This, lpstrContainerApp, lpstrContainerObj);
1488 return E_NOTIMPL;
1489 }
1490
1491 static HRESULT WINAPI
1492 IRichEditOle_fnSetLinkAvailable(IRichEditOle *me, LONG iob, BOOL fAvailable)
1493 {
1494 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
1495 FIXME("stub %p\n",This);
1496 return E_NOTIMPL;
1497 }
1498
1499 static const IRichEditOleVtbl revt = {
1500 IRichEditOle_fnQueryInterface,
1501 IRichEditOle_fnAddRef,
1502 IRichEditOle_fnRelease,
1503 IRichEditOle_fnGetClientSite,
1504 IRichEditOle_fnGetObjectCount,
1505 IRichEditOle_fnGetLinkCount,
1506 IRichEditOle_fnGetObject,
1507 IRichEditOle_fnInsertObject,
1508 IRichEditOle_fnConvertObject,
1509 IRichEditOle_fnActivateAs,
1510 IRichEditOle_fnSetHostNames,
1511 IRichEditOle_fnSetLinkAvailable,
1512 IRichEditOle_fnSetDvaspect,
1513 IRichEditOle_fnHandsOffStorage,
1514 IRichEditOle_fnSaveCompleted,
1515 IRichEditOle_fnInPlaceDeactivate,
1516 IRichEditOle_fnContextSensitiveHelp,
1517 IRichEditOle_fnGetClipboardData,
1518 IRichEditOle_fnImportDataObject
1519 };
1520
1521 /* ITextRange interface */
1522 static HRESULT WINAPI ITextRange_fnQueryInterface(ITextRange *me, REFIID riid, void **ppvObj)
1523 {
1524 ITextRangeImpl *This = impl_from_ITextRange(me);
1525
1526 *ppvObj = NULL;
1527 if (IsEqualGUID(riid, &IID_IUnknown)
1528 || IsEqualGUID(riid, &IID_IDispatch)
1529 || IsEqualGUID(riid, &IID_ITextRange))
1530 {
1531 *ppvObj = me;
1532 ITextRange_AddRef(me);
1533 return S_OK;
1534 }
1535 else if (IsEqualGUID(riid, &IID_Igetrichole))
1536 {
1537 *ppvObj = This->child.reole;
1538 return S_OK;
1539 }
1540
1541 return E_NOINTERFACE;
1542 }
1543
1544 static ULONG WINAPI ITextRange_fnAddRef(ITextRange *me)
1545 {
1546 ITextRangeImpl *This = impl_from_ITextRange(me);
1547 return InterlockedIncrement(&This->ref);
1548 }
1549
1550 static ULONG WINAPI ITextRange_fnRelease(ITextRange *me)
1551 {
1552 ITextRangeImpl *This = impl_from_ITextRange(me);
1553 ULONG ref = InterlockedDecrement(&This->ref);
1554
1555 TRACE ("%p ref=%u\n", This, ref);
1556 if (ref == 0)
1557 {
1558 if (This->child.reole)
1559 {
1560 list_remove(&This->child.entry);
1561 This->child.reole = NULL;
1562 }
1563 heap_free(This);
1564 }
1565 return ref;
1566 }
1567
1568 static HRESULT WINAPI ITextRange_fnGetTypeInfoCount(ITextRange *me, UINT *pctinfo)
1569 {
1570 ITextRangeImpl *This = impl_from_ITextRange(me);
1571 TRACE("(%p)->(%p)\n", This, pctinfo);
1572 *pctinfo = 1;
1573 return S_OK;
1574 }
1575
1576 static HRESULT WINAPI ITextRange_fnGetTypeInfo(ITextRange *me, UINT iTInfo, LCID lcid,
1577 ITypeInfo **ppTInfo)
1578 {
1579 ITextRangeImpl *This = impl_from_ITextRange(me);
1580 HRESULT hr;
1581
1582 TRACE("(%p)->(%u,%d,%p)\n", This, iTInfo, lcid, ppTInfo);
1583
1584 hr = get_typeinfo(ITextRange_tid, ppTInfo);
1585 if (SUCCEEDED(hr))
1586 ITypeInfo_AddRef(*ppTInfo);
1587 return hr;
1588 }
1589
1590 static HRESULT WINAPI ITextRange_fnGetIDsOfNames(ITextRange *me, REFIID riid, LPOLESTR *rgszNames,
1591 UINT cNames, LCID lcid, DISPID *rgDispId)
1592 {
1593 ITextRangeImpl *This = impl_from_ITextRange(me);
1594 ITypeInfo *ti;
1595 HRESULT hr;
1596
1597 TRACE("(%p)->(%s, %p, %u, %d, %p)\n", This, debugstr_guid(riid), rgszNames, cNames, lcid,
1598 rgDispId);
1599
1600 hr = get_typeinfo(ITextRange_tid, &ti);
1601 if (SUCCEEDED(hr))
1602 hr = ITypeInfo_GetIDsOfNames(ti, rgszNames, cNames, rgDispId);
1603 return hr;
1604 }
1605
1606 static HRESULT WINAPI ITextRange_fnInvoke(ITextRange *me, DISPID dispIdMember, REFIID riid,
1607 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
1608 VARIANT *pVarResult, EXCEPINFO *pExcepInfo,
1609 UINT *puArgErr)
1610 {
1611 ITextRangeImpl *This = impl_from_ITextRange(me);
1612 ITypeInfo *ti;
1613 HRESULT hr;
1614
1615 TRACE("(%p)->(%d, %s, %d, %u, %p, %p, %p, %p)\n", This, dispIdMember, debugstr_guid(riid),
1616 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
1617
1618 hr = get_typeinfo(ITextRange_tid, &ti);
1619 if (SUCCEEDED(hr))
1620 hr = ITypeInfo_Invoke(ti, me, dispIdMember, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
1621 return hr;
1622 }
1623
1624 static HRESULT WINAPI ITextRange_fnGetText(ITextRange *me, BSTR *str)
1625 {
1626 ITextRangeImpl *This = impl_from_ITextRange(me);
1627 ME_TextEditor *editor;
1628 ME_Cursor start, end;
1629 int length;
1630 BOOL bEOP;
1631
1632 TRACE("(%p)->(%p)\n", This, str);
1633
1634 if (!This->child.reole)
1635 return CO_E_RELEASED;
1636
1637 if (!str)
1638 return E_INVALIDARG;
1639
1640 /* return early for degenerate range */
1641 if (This->start == This->end) {
1642 *str = NULL;
1643 return S_OK;
1644 }
1645
1646 editor = This->child.reole->editor;
1647 ME_CursorFromCharOfs(editor, This->start, &start);
1648 ME_CursorFromCharOfs(editor, This->end, &end);
1649
1650 length = This->end - This->start;
1651 *str = SysAllocStringLen(NULL, length);
1652 if (!*str)
1653 return E_OUTOFMEMORY;
1654
1655 bEOP = (end.pRun->next->type == diTextEnd && This->end > ME_GetTextLength(editor));
1656 ME_GetTextW(editor, *str, length, &start, length, FALSE, bEOP);
1657 return S_OK;
1658 }
1659
1660 static HRESULT WINAPI ITextRange_fnSetText(ITextRange *me, BSTR str)
1661 {
1662 ITextRangeImpl *This = impl_from_ITextRange(me);
1663 ME_TextEditor *editor;
1664 ME_Cursor cursor;
1665 ME_Style *style;
1666 int len;
1667
1668 TRACE("(%p)->(%s)\n", This, debugstr_w(str));
1669
1670 if (!This->child.reole)
1671 return CO_E_RELEASED;
1672
1673 editor = This->child.reole->editor;
1674
1675 /* delete only where's something to delete */
1676 if (This->start != This->end) {
1677 ME_CursorFromCharOfs(editor, This->start, &cursor);
1678 ME_InternalDeleteText(editor, &cursor, This->end - This->start, FALSE);
1679 }
1680
1681 if (!str || !*str) {
1682 /* will update this range as well */
1683 textranges_update_ranges(This->child.reole, This->start, This->end, RANGE_UPDATE_DELETE);
1684 return S_OK;
1685 }
1686
1687 /* it's safer not to rely on stored BSTR length */
1688 len = strlenW(str);
1689 cursor = editor->pCursors[0];
1690 ME_CursorFromCharOfs(editor, This->start, &editor->pCursors[0]);
1691 style = ME_GetInsertStyle(editor, 0);
1692 ME_InsertTextFromCursor(editor, 0, str, len, style);
1693 ME_ReleaseStyle(style);
1694 editor->pCursors[0] = cursor;
1695
1696 if (len < This->end - This->start)
1697 textranges_update_ranges(This->child.reole, This->start + len, This->end, RANGE_UPDATE_DELETE);
1698 else
1699 This->end = len - This->start;
1700
1701 return S_OK;
1702 }
1703
1704 static HRESULT range_GetChar(ME_TextEditor *editor, ME_Cursor *cursor, LONG *pch)
1705 {
1706 WCHAR wch[2];
1707
1708 ME_GetTextW(editor, wch, 1, cursor, 1, FALSE, cursor->pRun->next->type == diTextEnd);
1709 *pch = wch[0];
1710
1711 return S_OK;
1712 }
1713
1714 static HRESULT WINAPI ITextRange_fnGetChar(ITextRange *me, LONG *pch)
1715 {
1716 ITextRangeImpl *This = impl_from_ITextRange(me);
1717 ME_TextEditor *editor;
1718 ME_Cursor cursor;
1719
1720 TRACE("(%p)->(%p)\n", This, pch);
1721
1722 if (!This->child.reole)
1723 return CO_E_RELEASED;
1724
1725 if (!pch)
1726 return E_INVALIDARG;
1727
1728 editor = This->child.reole->editor;
1729 ME_CursorFromCharOfs(editor, This->start, &cursor);
1730 return range_GetChar(editor, &cursor, pch);
1731 }
1732
1733 static HRESULT WINAPI ITextRange_fnSetChar(ITextRange *me, LONG ch)
1734 {
1735 ITextRangeImpl *This = impl_from_ITextRange(me);
1736
1737 FIXME("(%p)->(%x): stub\n", This, ch);
1738
1739 if (!This->child.reole)
1740 return CO_E_RELEASED;
1741
1742 return E_NOTIMPL;
1743 }
1744
1745 static HRESULT CreateITextRange(IRichEditOleImpl *reOle, LONG start, LONG end, ITextRange** ppRange);
1746
1747 static HRESULT WINAPI ITextRange_fnGetDuplicate(ITextRange *me, ITextRange **ppRange)
1748 {
1749 ITextRangeImpl *This = impl_from_ITextRange(me);
1750
1751 TRACE("(%p)->(%p)\n", This, ppRange);
1752
1753 if (!This->child.reole)
1754 return CO_E_RELEASED;
1755
1756 if (!ppRange)
1757 return E_INVALIDARG;
1758
1759 return CreateITextRange(This->child.reole, This->start, This->end, ppRange);
1760 }
1761
1762 static HRESULT WINAPI ITextRange_fnGetFormattedText(ITextRange *me, ITextRange **range)
1763 {
1764 ITextRangeImpl *This = impl_from_ITextRange(me);
1765
1766 FIXME("(%p)->(%p): stub\n", This, range);
1767
1768 if (!This->child.reole)
1769 return CO_E_RELEASED;
1770
1771 return E_NOTIMPL;
1772 }
1773
1774 static HRESULT WINAPI ITextRange_fnSetFormattedText(ITextRange *me, ITextRange *range)
1775 {
1776 ITextRangeImpl *This = impl_from_ITextRange(me);
1777
1778 FIXME("(%p)->(%p): stub\n", This, range);
1779
1780 if (!This->child.reole)
1781 return CO_E_RELEASED;
1782
1783 return E_NOTIMPL;
1784 }
1785
1786 static HRESULT WINAPI ITextRange_fnGetStart(ITextRange *me, LONG *start)
1787 {
1788 ITextRangeImpl *This = impl_from_ITextRange(me);
1789
1790 TRACE("(%p)->(%p)\n", This, start);
1791
1792 if (!This->child.reole)
1793 return CO_E_RELEASED;
1794
1795 if (!start)
1796 return E_INVALIDARG;
1797
1798 *start = This->start;
1799 return S_OK;
1800 }
1801
1802 static HRESULT textrange_setstart(const IRichEditOleImpl *reole, LONG value, LONG *start, LONG *end)
1803 {
1804 int len;
1805
1806 if (value < 0)
1807 value = 0;
1808
1809 if (value == *start)
1810 return S_FALSE;
1811
1812 if (value <= *end) {
1813 *start = value;
1814 return S_OK;
1815 }
1816
1817 len = ME_GetTextLength(reole->editor);
1818 *start = *end = value > len ? len : value;
1819 return S_OK;
1820 }
1821
1822 static HRESULT WINAPI ITextRange_fnSetStart(ITextRange *me, LONG value)
1823 {
1824 ITextRangeImpl *This = impl_from_ITextRange(me);
1825
1826 TRACE("(%p)->(%d)\n", This, value);
1827
1828 if (!This->child.reole)
1829 return CO_E_RELEASED;
1830
1831 return textrange_setstart(This->child.reole, value, &This->start, &This->end);
1832 }
1833
1834 static HRESULT WINAPI ITextRange_fnGetEnd(ITextRange *me, LONG *end)
1835 {
1836 ITextRangeImpl *This = impl_from_ITextRange(me);
1837
1838 TRACE("(%p)->(%p)\n", This, end);
1839
1840 if (!This->child.reole)
1841 return CO_E_RELEASED;
1842
1843 if (!end)
1844 return E_INVALIDARG;
1845
1846 *end = This->end;
1847 return S_OK;
1848 }
1849
1850 static HRESULT textrange_setend(const IRichEditOleImpl *reole, LONG value, LONG *start, LONG *end)
1851 {
1852 int len;
1853
1854 if (value == *end)
1855 return S_FALSE;
1856
1857 if (value < *start) {
1858 *start = *end = max(0, value);
1859 return S_OK;
1860 }
1861
1862 len = ME_GetTextLength(reole->editor);
1863 *end = value > len ? len + 1 : value;
1864 return S_OK;
1865 }
1866
1867 static HRESULT WINAPI ITextRange_fnSetEnd(ITextRange *me, LONG value)
1868 {
1869 ITextRangeImpl *This = impl_from_ITextRange(me);
1870
1871 TRACE("(%p)->(%d)\n", This, value);
1872
1873 if (!This->child.reole)
1874 return CO_E_RELEASED;
1875
1876 return textrange_setend(This->child.reole, value, &This->start, &This->end);
1877 }
1878
1879 static HRESULT WINAPI ITextRange_fnGetFont(ITextRange *me, ITextFont **font)
1880 {
1881 ITextRangeImpl *This = impl_from_ITextRange(me);
1882
1883 TRACE("(%p)->(%p)\n", This, font);
1884
1885 if (!This->child.reole)
1886 return CO_E_RELEASED;
1887
1888 if (!font)
1889 return E_INVALIDARG;
1890
1891 return create_textfont(me, NULL, font);
1892 }
1893
1894 static HRESULT WINAPI ITextRange_fnSetFont(ITextRange *me, ITextFont *font)
1895 {
1896 ITextRangeImpl *This = impl_from_ITextRange(me);
1897
1898 TRACE("(%p)->(%p)\n", This, font);
1899
1900 if (!font)
1901 return E_INVALIDARG;
1902
1903 if (!This->child.reole)
1904 return CO_E_RELEASED;
1905
1906 textrange_set_font(me, font);
1907 return S_OK;
1908 }
1909
1910 static HRESULT WINAPI ITextRange_fnGetPara(ITextRange *me, ITextPara **para)
1911 {
1912 ITextRangeImpl *This = impl_from_ITextRange(me);
1913
1914 TRACE("(%p)->(%p)\n", This, para);
1915
1916 if (!This->child.reole)
1917 return CO_E_RELEASED;
1918
1919 if (!para)
1920 return E_INVALIDARG;
1921
1922 return create_textpara(me, para);
1923 }
1924
1925 static HRESULT WINAPI ITextRange_fnSetPara(ITextRange *me, ITextPara *para)
1926 {
1927 ITextRangeImpl *This = impl_from_ITextRange(me);
1928
1929 FIXME("(%p)->(%p): stub\n", This, para);
1930
1931 if (!This->child.reole)
1932 return CO_E_RELEASED;
1933
1934 return E_NOTIMPL;
1935 }
1936
1937 static HRESULT WINAPI ITextRange_fnGetStoryLength(ITextRange *me, LONG *length)
1938 {
1939 ITextRangeImpl *This = impl_from_ITextRange(me);
1940
1941 TRACE("(%p)->(%p)\n", This, length);
1942
1943 if (!This->child.reole)
1944 return CO_E_RELEASED;
1945
1946 return textrange_get_storylength(This->child.reole->editor, length);
1947 }
1948
1949 static HRESULT WINAPI ITextRange_fnGetStoryType(ITextRange *me, LONG *value)
1950 {
1951 ITextRangeImpl *This = impl_from_ITextRange(me);
1952
1953 TRACE("(%p)->(%p)\n", This, value);
1954
1955 if (!This->child.reole)
1956 return CO_E_RELEASED;
1957
1958 if (!value)
1959 return E_INVALIDARG;
1960
1961 *value = tomUnknownStory;
1962 return S_OK;
1963 }
1964
1965 static HRESULT range_Collapse(LONG bStart, LONG *start, LONG *end)
1966 {
1967 if (*end == *start)
1968 return S_FALSE;
1969
1970 if (bStart == tomEnd)
1971 *start = *end;
1972 else
1973 *end = *start;
1974 return S_OK;
1975 }
1976
1977 static HRESULT WINAPI ITextRange_fnCollapse(ITextRange *me, LONG bStart)
1978 {
1979 ITextRangeImpl *This = impl_from_ITextRange(me);
1980
1981 TRACE("(%p)->(%d)\n", This, bStart);
1982
1983 if (!This->child.reole)
1984 return CO_E_RELEASED;
1985
1986 return range_Collapse(bStart, &This->start, &This->end);
1987 }
1988
1989 static HRESULT WINAPI ITextRange_fnExpand(ITextRange *me, LONG unit, LONG *delta)
1990 {
1991 ITextRangeImpl *This = impl_from_ITextRange(me);
1992
1993 TRACE("(%p)->(%d %p)\n", This, unit, delta);
1994
1995 if (!This->child.reole)
1996 return CO_E_RELEASED;
1997
1998 return textrange_expand(me, unit, delta);
1999 }
2000
2001 static HRESULT WINAPI ITextRange_fnGetIndex(ITextRange *me, LONG unit, LONG *index)
2002 {
2003 ITextRangeImpl *This = impl_from_ITextRange(me);
2004
2005 FIXME("(%p)->(%d %p): stub\n", This, unit, index);
2006
2007 if (!This->child.reole)
2008 return CO_E_RELEASED;
2009
2010 return E_NOTIMPL;
2011 }
2012
2013 static HRESULT WINAPI ITextRange_fnSetIndex(ITextRange *me, LONG unit, LONG index,
2014 LONG extend)
2015 {
2016 ITextRangeImpl *This = impl_from_ITextRange(me);
2017
2018 FIXME("(%p)->(%d %d %d): stub\n", This, unit, index, extend);
2019
2020 if (!This->child.reole)
2021 return CO_E_RELEASED;
2022
2023 return E_NOTIMPL;
2024 }
2025
2026 static void cp2range(ME_TextEditor *editor, LONG *cp1, LONG *cp2)
2027 {
2028 int len = ME_GetTextLength(editor) + 1;
2029 *cp1 = max(*cp1, 0);
2030 *cp2 = max(*cp2, 0);
2031 *cp1 = min(*cp1, len);
2032 *cp2 = min(*cp2, len);
2033 if (*cp1 > *cp2)
2034 {
2035 int tmp = *cp1;
2036 *cp1 = *cp2;
2037 *cp2 = tmp;
2038 }
2039 if (*cp1 == len)
2040 *cp1 = *cp2 = len - 1;
2041 }
2042
2043 static HRESULT WINAPI ITextRange_fnSetRange(ITextRange *me, LONG anchor, LONG active)
2044 {
2045 ITextRangeImpl *This = impl_from_ITextRange(me);
2046
2047 FIXME("(%p)->(%d %d): stub\n", This, anchor, active);
2048
2049 if (!This->child.reole)
2050 return CO_E_RELEASED;
2051
2052 cp2range(This->child.reole->editor, &anchor, &active);
2053 if (anchor == This->start && active == This->end)
2054 return S_FALSE;
2055
2056 This->start = anchor;
2057 This->end = active;
2058 return S_OK;
2059 }
2060
2061 static HRESULT textrange_inrange(LONG start, LONG end, ITextRange *range, LONG *ret)
2062 {
2063 LONG from, to, v;
2064
2065 if (!ret)
2066 ret = &v;
2067
2068 if (FAILED(ITextRange_GetStart(range, &from)) || FAILED(ITextRange_GetEnd(range, &to))) {
2069 *ret = tomFalse;
2070 }
2071 else
2072 *ret = (start >= from && end <= to) ? tomTrue : tomFalse;
2073 return *ret == tomTrue ? S_OK : S_FALSE;
2074 }
2075
2076 static HRESULT WINAPI ITextRange_fnInRange(ITextRange *me, ITextRange *range, LONG *ret)
2077 {
2078 ITextRangeImpl *This = impl_from_ITextRange(me);
2079
2080 TRACE("(%p)->(%p %p)\n", This, range, ret);
2081
2082 if (ret)
2083 *ret = tomFalse;
2084
2085 if (!This->child.reole)
2086 return CO_E_RELEASED;
2087
2088 if (!range)
2089 return S_FALSE;
2090
2091 return textrange_inrange(This->start, This->end, range, ret);
2092 }
2093
2094 static HRESULT WINAPI ITextRange_fnInStory(ITextRange *me, ITextRange *pRange, LONG *ret)
2095 {
2096 ITextRangeImpl *This = impl_from_ITextRange(me);
2097
2098 FIXME("(%p)->(%p): stub\n", This, ret);
2099
2100 if (!This->child.reole)
2101 return CO_E_RELEASED;
2102
2103 return E_NOTIMPL;
2104 }
2105
2106 static HRESULT textrange_isequal(LONG start, LONG end, ITextRange *range, LONG *ret)
2107 {
2108 LONG from, to, v;
2109
2110 if (!ret)
2111 ret = &v;
2112
2113 if (FAILED(ITextRange_GetStart(range, &from)) || FAILED(ITextRange_GetEnd(range, &to))) {
2114 *ret = tomFalse;
2115 }
2116 else
2117 *ret = (start == from && end == to) ? tomTrue : tomFalse;
2118 return *ret == tomTrue ? S_OK : S_FALSE;
2119 }
2120
2121 static HRESULT WINAPI ITextRange_fnIsEqual(ITextRange *me, ITextRange *range, LONG *ret)
2122 {
2123 ITextRangeImpl *This = impl_from_ITextRange(me);
2124
2125 TRACE("(%p)->(%p %p)\n", This, range, ret);
2126
2127 if (ret)
2128 *ret = tomFalse;
2129
2130 if (!This->child.reole)
2131 return CO_E_RELEASED;
2132
2133 if (!range)
2134 return S_FALSE;
2135
2136 return textrange_isequal(This->start, This->end, range, ret);
2137 }
2138
2139 static HRESULT WINAPI ITextRange_fnSelect(ITextRange *me)
2140 {
2141 ITextRangeImpl *This = impl_from_ITextRange(me);
2142
2143 TRACE("(%p)\n", This);
2144
2145 if (!This->child.reole)
2146 return CO_E_RELEASED;
2147
2148 ME_SetSelection(This->child.reole->editor, This->start, This->end);
2149 return S_OK;
2150 }
2151
2152 static HRESULT WINAPI ITextRange_fnStartOf(ITextRange *me, LONG unit, LONG extend,
2153 LONG *delta)
2154 {
2155 ITextRangeImpl *This = impl_from_ITextRange(me);
2156
2157 FIXME("(%p)->(%d %d %p): stub\n", This, unit, extend, delta);
2158
2159 if (!This->child.reole)
2160 return CO_E_RELEASED;
2161
2162 return E_NOTIMPL;
2163 }
2164
2165 static HRESULT WINAPI ITextRange_fnEndOf(ITextRange *me, LONG unit, LONG extend,
2166 LONG *delta)
2167 {
2168 ITextRangeImpl *This = impl_from_ITextRange(me);
2169
2170 FIXME("(%p)->(%d %d %p): stub\n", This, unit, extend, delta);
2171
2172 if (!This->child.reole)
2173 return CO_E_RELEASED;
2174
2175 return E_NOTIMPL;
2176 }
2177
2178 static HRESULT WINAPI ITextRange_fnMove(ITextRange *me, LONG unit, LONG count, LONG *delta)
2179 {
2180 ITextRangeImpl *This = impl_from_ITextRange(me);
2181
2182 FIXME("(%p)->(%d %d %p): stub\n", This, unit, count, delta);
2183
2184 if (!This->child.reole)
2185 return CO_E_RELEASED;
2186
2187 return E_NOTIMPL;
2188 }
2189
2190 static HRESULT WINAPI ITextRange_fnMoveStart(ITextRange *me, LONG unit, LONG count,
2191 LONG *delta)
2192 {
2193 ITextRangeImpl *This = impl_from_ITextRange(me);
2194
2195 FIXME("(%p)->(%d %d %p): stub\n", This, unit, count, delta);
2196
2197 if (!This->child.reole)
2198 return CO_E_RELEASED;
2199
2200 return E_NOTIMPL;
2201 }
2202
2203 static HRESULT textrange_moveend(ITextRange *range, LONG unit, LONG count, LONG *delta)
2204 {
2205 LONG old_start, old_end, new_start, new_end;
2206 HRESULT hr = S_OK;
2207
2208 if (!count)
2209 {
2210 if (delta)
2211 *delta = 0;
2212 return S_FALSE;
2213 }
2214
2215 ITextRange_GetStart(range, &old_start);
2216 ITextRange_GetEnd(range, &old_end);
2217 switch (unit)
2218 {
2219 case tomStory:
2220 if (count < 0)
2221 new_start = new_end = 0;
2222 else
2223 {
2224 new_start = old_start;
2225 ITextRange_GetStoryLength(range, &new_end);
2226 }
2227 if (delta)
2228 {
2229 if (new_end < old_end)
2230 *delta = -1;
2231 else if (new_end == old_end)
2232 *delta = 0;
2233 else
2234 *delta = 1;
2235 }
2236 break;
2237 default:
2238 FIXME("unit %d is not supported\n", unit);
2239 return E_NOTIMPL;
2240 }
2241 if (new_end == old_end)
2242 hr = S_FALSE;
2243 ITextRange_SetStart(range, new_start);
2244 ITextRange_SetEnd(range, new_end);
2245
2246 return hr;
2247 }
2248
2249 static HRESULT WINAPI ITextRange_fnMoveEnd(ITextRange *me, LONG unit, LONG count,
2250 LONG *delta)
2251 {
2252 ITextRangeImpl *This = impl_from_ITextRange(me);
2253
2254 TRACE("(%p)->(%d %d %p)\n", This, unit, count, delta);
2255
2256 if (!This->child.reole)
2257 return CO_E_RELEASED;
2258
2259 return textrange_moveend(me, unit, count, delta);
2260 }
2261
2262 static HRESULT WINAPI ITextRange_fnMoveWhile(ITextRange *me, VARIANT *charset, LONG count,
2263 LONG *delta)
2264 {
2265 ITextRangeImpl *This = impl_from_ITextRange(me);
2266
2267 FIXME("(%p)->(%s %d %p): stub\n", This, debugstr_variant(charset), count, delta);
2268
2269 if (!This->child.reole)
2270 return CO_E_RELEASED;
2271
2272 return E_NOTIMPL;
2273 }
2274
2275 static HRESULT WINAPI ITextRange_fnMoveStartWhile(ITextRange *me, VARIANT *charset, LONG count,
2276 LONG *delta)
2277 {
2278 ITextRangeImpl *This = impl_from_ITextRange(me);
2279
2280 FIXME("(%p)->(%s %d %p): stub\n", This, debugstr_variant(charset), count, delta);
2281
2282 if (!This->child.reole)
2283 return CO_E_RELEASED;
2284
2285 return E_NOTIMPL;
2286 }
2287
2288 static HRESULT WINAPI ITextRange_fnMoveEndWhile(ITextRange *me, VARIANT *charset, LONG count,
2289 LONG *delta)
2290 {
2291 ITextRangeImpl *This = impl_from_ITextRange(me);
2292
2293 FIXME("(%p)->(%s %d %p): stub\n", This, debugstr_variant(charset), count, delta);
2294
2295 if (!This->child.reole)
2296 return CO_E_RELEASED;
2297
2298 return E_NOTIMPL;
2299 }
2300
2301 static HRESULT WINAPI ITextRange_fnMoveUntil(ITextRange *me, VARIANT *charset, LONG count,
2302 LONG *delta)
2303 {
2304 ITextRangeImpl *This = impl_from_ITextRange(me);
2305
2306 FIXME("(%p)->(%s %d %p): stub\n", This, debugstr_variant(charset), count, delta);
2307
2308 if (!This->child.reole)
2309 return CO_E_RELEASED;
2310
2311 return E_NOTIMPL;
2312 }
2313
2314 static HRESULT WINAPI ITextRange_fnMoveStartUntil(ITextRange *me, VARIANT *charset, LONG count,
2315 LONG *delta)
2316 {
2317 ITextRangeImpl *This = impl_from_ITextRange(me);
2318
2319 FIXME("(%p)->(%s %d %p): stub\n", This, debugstr_variant(charset), count, delta);
2320
2321 if (!This->child.reole)
2322 return CO_E_RELEASED;
2323
2324 return E_NOTIMPL;
2325 }
2326
2327 static HRESULT WINAPI ITextRange_fnMoveEndUntil(ITextRange *me, VARIANT *charset, LONG count,
2328 LONG *delta)
2329 {
2330 ITextRangeImpl *This = impl_from_ITextRange(me);
2331
2332 FIXME("(%p)->(%s %d %p): stub\n", This, debugstr_variant(charset), count, delta);
2333
2334 if (!This->child.reole)
2335 return CO_E_RELEASED;
2336
2337 return E_NOTIMPL;
2338 }
2339
2340 static HRESULT WINAPI ITextRange_fnFindText(ITextRange *me, BSTR text, LONG count, LONG flags,
2341 LONG *length)
2342 {
2343 ITextRangeImpl *This = impl_from_ITextRange(me);
2344
2345 FIXME("(%p)->(%s %d %x %p): stub\n", This, debugstr_w(text), count, flags, length);
2346
2347 if (!This->child.reole)
2348 return CO_E_RELEASED;
2349
2350 return E_NOTIMPL;
2351 }
2352
2353 static HRESULT WINAPI ITextRange_fnFindTextStart(ITextRange *me, BSTR text, LONG count,
2354 LONG flags, LONG *length)
2355 {
2356 ITextRangeImpl *This = impl_from_ITextRange(me);
2357
2358 FIXME("(%p)->(%s %d %x %p): stub\n", This, debugstr_w(text), count, flags, length);
2359
2360 if (!This->child.reole)
2361 return CO_E_RELEASED;
2362
2363 return E_NOTIMPL;
2364 }
2365
2366 static HRESULT WINAPI ITextRange_fnFindTextEnd(ITextRange *me, BSTR text, LONG count,
2367 LONG flags, LONG *length)
2368 {
2369 ITextRangeImpl *This = impl_from_ITextRange(me);
2370
2371 FIXME("(%p)->(%s %d %x %p): stub\n", This, debugstr_w(text), count, flags, length);
2372
2373 if (!This->child.reole)
2374 return CO_E_RELEASED;
2375
2376 return E_NOTIMPL;
2377 }
2378
2379 static HRESULT WINAPI ITextRange_fnDelete(ITextRange *me, LONG unit, LONG count, LONG *delta)
2380 {
2381 ITextRangeImpl *This = impl_from_ITextRange(me);
2382
2383 FIXME("(%p)->(%d %d %p): stub\n", This, unit, count, delta);
2384
2385 if (!This->child.reole)
2386 return CO_E_RELEASED;
2387
2388 return E_NOTIMPL;
2389 }
2390
2391 static HRESULT WINAPI ITextRange_fnCut(ITextRange *me, VARIANT *v)
2392 {
2393 ITextRangeImpl *This = impl_from_ITextRange(me);
2394
2395 FIXME("(%p)->(%p): stub\n", This, v);
2396
2397 if (!This->child.reole)
2398 return CO_E_RELEASED;
2399
2400 return E_NOTIMPL;
2401 }
2402
2403 static HRESULT WINAPI ITextRange_fnCopy(ITextRange *me, VARIANT *v)
2404 {
2405 ITextRangeImpl *This = impl_from_ITextRange(me);
2406
2407 FIXME("(%p)->(%p): stub\n", This, v);
2408
2409 if (!This->child.reole)
2410 return CO_E_RELEASED;
2411
2412 return E_NOTIMPL;
2413 }
2414
2415 static HRESULT WINAPI ITextRange_fnPaste(ITextRange *me, VARIANT *v, LONG format)
2416 {
2417 ITextRangeImpl *This = impl_from_ITextRange(me);
2418
2419 FIXME("(%p)->(%s %x): stub\n", This, debugstr_variant(v), format);
2420
2421 if (!This->child.reole)
2422 return CO_E_RELEASED;
2423
2424 return E_NOTIMPL;
2425 }
2426
2427 static HRESULT WINAPI ITextRange_fnCanPaste(ITextRange *me, VARIANT *v, LONG format, LONG *ret)
2428 {
2429 ITextRangeImpl *This = impl_from_ITextRange(me);
2430
2431 FIXME("(%p)->(%s %x %p): stub\n", This, debugstr_variant(v), format, ret);
2432
2433 if (!This->child.reole)
2434 return CO_E_RELEASED;
2435
2436 return E_NOTIMPL;
2437 }
2438
2439 static HRESULT WINAPI ITextRange_fnCanEdit(ITextRange *me, LONG *ret)
2440 {
2441 ITextRangeImpl *This = impl_from_ITextRange(me);
2442
2443 FIXME("(%p)->(%p): stub\n", This, ret);
2444
2445 if (!This->child.reole)
2446 return CO_E_RELEASED;
2447
2448 return E_NOTIMPL;
2449 }
2450
2451 static HRESULT WINAPI ITextRange_fnChangeCase(ITextRange *me, LONG type)
2452 {
2453 ITextRangeImpl *This = impl_from_ITextRange(me);
2454
2455 FIXME("(%p)->(%d): stub\n", This, type);
2456
2457 if (!This->child.reole)
2458 return CO_E_RELEASED;
2459
2460 return E_NOTIMPL;
2461 }
2462
2463 static HRESULT WINAPI ITextRange_fnGetPoint(ITextRange *me, LONG type, LONG *cx, LONG *cy)
2464 {
2465 ITextRangeImpl *This = impl_from_ITextRange(me);
2466
2467 FIXME("(%p)->(%d %p %p): stub\n", This, type, cx, cy);
2468
2469 if (!This->child.reole)
2470 return CO_E_RELEASED;
2471
2472 return E_NOTIMPL;
2473 }
2474
2475 static HRESULT WINAPI ITextRange_fnSetPoint(ITextRange *me, LONG x, LONG y, LONG type,
2476 LONG extend)
2477 {
2478 ITextRangeImpl *This = impl_from_ITextRange(me);
2479
2480 FIXME("(%p)->(%d %d %d %d): stub\n", This, x, y, type, extend);
2481
2482 if (!This->child.reole)
2483 return CO_E_RELEASED;
2484
2485 return E_NOTIMPL;
2486 }
2487
2488 static HRESULT WINAPI ITextRange_fnScrollIntoView(ITextRange *me, LONG value)
2489 {
2490 ITextRangeImpl *This = impl_from_ITextRange(me);
2491 ME_TextEditor *editor;
2492 ME_Cursor cursor;
2493 int x, y, height;
2494
2495 TRACE("(%p)->(%d)\n", This, value);
2496
2497 if (!This->child.reole)
2498 return CO_E_RELEASED;
2499
2500 editor = This->child.reole->editor;
2501
2502 switch (value)
2503 {
2504 case tomStart:
2505 ME_CursorFromCharOfs(editor, This->start, &cursor);
2506 ME_GetCursorCoordinates(editor, &cursor, &x, &y, &height);
2507 break;
2508 default:
2509 FIXME("bStart value %d not handled\n", value);
2510 return E_NOTIMPL;
2511 }
2512 ME_ScrollAbs(editor, x, y);
2513 return S_OK;
2514 }
2515
2516 static HRESULT WINAPI ITextRange_fnGetEmbeddedObject(ITextRange *me, IUnknown **ppv)
2517 {
2518 ITextRangeImpl *This = impl_from_ITextRange(me);
2519
2520 FIXME("(%p)->(%p): stub\n", This, ppv);
2521
2522 if (!This->child.reole)
2523 return CO_E_RELEASED;
2524
2525 return E_NOTIMPL;
2526 }
2527
2528 static const ITextRangeVtbl trvt = {
2529 ITextRange_fnQueryInterface,
2530 ITextRange_fnAddRef,
2531 ITextRange_fnRelease,
2532 ITextRange_fnGetTypeInfoCount,
2533 ITextRange_fnGetTypeInfo,
2534 ITextRange_fnGetIDsOfNames,
2535 ITextRange_fnInvoke,
2536 ITextRange_fnGetText,
2537 ITextRange_fnSetText,
2538 ITextRange_fnGetChar,
2539 ITextRange_fnSetChar,
2540 ITextRange_fnGetDuplicate,
2541 ITextRange_fnGetFormattedText,
2542 ITextRange_fnSetFormattedText,
2543 ITextRange_fnGetStart,
2544 ITextRange_fnSetStart,
2545 ITextRange_fnGetEnd,
2546 ITextRange_fnSetEnd,
2547 ITextRange_fnGetFont,
2548 ITextRange_fnSetFont,
2549 ITextRange_fnGetPara,
2550 ITextRange_fnSetPara,
2551 ITextRange_fnGetStoryLength,
2552 ITextRange_fnGetStoryType,
2553 ITextRange_fnCollapse,
2554 ITextRange_fnExpand,
2555 ITextRange_fnGetIndex,
2556 ITextRange_fnSetIndex,
2557 ITextRange_fnSetRange,
2558 ITextRange_fnInRange,
2559 ITextRange_fnInStory,
2560 ITextRange_fnIsEqual,
2561 ITextRange_fnSelect,
2562 ITextRange_fnStartOf,
2563 ITextRange_fnEndOf,
2564 ITextRange_fnMove,
2565 ITextRange_fnMoveStart,
2566 ITextRange_fnMoveEnd,
2567 ITextRange_fnMoveWhile,
2568 ITextRange_fnMoveStartWhile,
2569 ITextRange_fnMoveEndWhile,
2570 ITextRange_fnMoveUntil,
2571 ITextRange_fnMoveStartUntil,
2572 ITextRange_fnMoveEndUntil,
2573 ITextRange_fnFindText,
2574 ITextRange_fnFindTextStart,
2575 ITextRange_fnFindTextEnd,
2576 ITextRange_fnDelete,
2577 ITextRange_fnCut,
2578 ITextRange_fnCopy,
2579 ITextRange_fnPaste,
2580 ITextRange_fnCanPaste,
2581 ITextRange_fnCanEdit,
2582 ITextRange_fnChangeCase,
2583 ITextRange_fnGetPoint,
2584 ITextRange_fnSetPoint,
2585 ITextRange_fnScrollIntoView,
2586 ITextRange_fnGetEmbeddedObject
2587 };
2588
2589 /* ITextFont */
2590 static HRESULT WINAPI TextFont_QueryInterface(ITextFont *iface, REFIID riid, void **ppv)
2591 {
2592 ITextFontImpl *This = impl_from_ITextFont(iface);
2593
2594 TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
2595
2596 if (IsEqualIID(riid, &IID_ITextFont) ||
2597 IsEqualIID(riid, &IID_IDispatch) ||
2598 IsEqualIID(riid, &IID_IUnknown))
2599 {
2600 *ppv = iface;
2601 ITextFont_AddRef(iface);
2602 return S_OK;
2603 }
2604
2605 *ppv = NULL;
2606 return E_NOINTERFACE;
2607 }
2608
2609 static ULONG WINAPI TextFont_AddRef(ITextFont *iface)
2610 {
2611 ITextFontImpl *This = impl_from_ITextFont(iface);
2612 ULONG ref = InterlockedIncrement(&This->ref);
2613 TRACE("(%p)->(%u)\n", This, ref);
2614 return ref;
2615 }
2616
2617 static ULONG WINAPI TextFont_Release(ITextFont *iface)
2618 {
2619 ITextFontImpl *This = impl_from_ITextFont(iface);
2620 ULONG ref = InterlockedDecrement(&This->ref);
2621
2622 TRACE("(%p)->(%u)\n", This, ref);
2623
2624 if (!ref)
2625 {
2626 if (This->range)
2627 ITextRange_Release(This->range);
2628 SysFreeString(This->props[FONT_NAME].str);
2629 heap_free(This);
2630 }
2631
2632 return ref;
2633 }
2634
2635 static HRESULT WINAPI TextFont_GetTypeInfoCount(ITextFont *iface, UINT *pctinfo)
2636 {
2637 ITextFontImpl *This = impl_from_ITextFont(iface);
2638 TRACE("(%p)->(%p)\n", This, pctinfo);
2639 *pctinfo = 1;
2640 return S_OK;
2641 }
2642
2643 static HRESULT WINAPI TextFont_GetTypeInfo(ITextFont *iface, UINT iTInfo, LCID lcid,
2644 ITypeInfo **ppTInfo)
2645 {
2646 ITextFontImpl *This = impl_from_ITextFont(iface);
2647 HRESULT hr;
2648
2649 TRACE("(%p)->(%u,%d,%p)\n", This, iTInfo, lcid, ppTInfo);
2650
2651 hr = get_typeinfo(ITextFont_tid, ppTInfo);
2652 if (SUCCEEDED(hr))
2653 ITypeInfo_AddRef(*ppTInfo);
2654 return hr;
2655 }
2656
2657 static HRESULT WINAPI TextFont_GetIDsOfNames(ITextFont *iface, REFIID riid,
2658 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
2659 {
2660 ITextFontImpl *This = impl_from_ITextFont(iface);
2661 ITypeInfo *ti;
2662 HRESULT hr;
2663
2664 TRACE("(%p)->(%s, %p, %u, %d, %p)\n", This, debugstr_guid(riid),
2665 rgszNames, cNames, lcid, rgDispId);
2666
2667 hr = get_typeinfo(ITextFont_tid, &ti);
2668 if (SUCCEEDED(hr))
2669 hr = ITypeInfo_GetIDsOfNames(ti, rgszNames, cNames, rgDispId);
2670 return hr;
2671 }
2672
2673 static HRESULT WINAPI TextFont_Invoke(
2674 ITextFont *iface,
2675 DISPID dispIdMember,
2676 REFIID riid,
2677 LCID lcid,
2678 WORD wFlags,
2679 DISPPARAMS *pDispParams,
2680 VARIANT *pVarResult,
2681 EXCEPINFO *pExcepInfo,
2682 UINT *puArgErr)
2683 {
2684 ITextFontImpl *This = impl_from_ITextFont(iface);
2685 ITypeInfo *ti;
2686 HRESULT hr;
2687
2688 TRACE("(%p)->(%d, %s, %d, %u, %p, %p, %p, %p)\n", This, dispIdMember, debugstr_guid(riid),
2689 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
2690
2691 hr = get_typeinfo(ITextFont_tid, &ti);
2692 if (SUCCEEDED(hr))
2693 hr = ITypeInfo_Invoke(ti, iface, dispIdMember, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
2694 return hr;
2695 }
2696
2697 static HRESULT WINAPI TextFont_GetDuplicate(ITextFont *iface, ITextFont **ret)
2698 {
2699 ITextFontImpl *This = impl_from_ITextFont(iface);
2700
2701 TRACE("(%p)->(%p)\n", This, ret);
2702
2703 if (!ret)
2704 return E_INVALIDARG;
2705
2706 *ret = NULL;
2707 if (This->range && !get_range_reole(This->range))
2708 return CO_E_RELEASED;
2709
2710 return create_textfont(NULL, This, ret);
2711 }
2712
2713 static HRESULT WINAPI TextFont_SetDuplicate(ITextFont *iface, ITextFont *pFont)
2714 {
2715 ITextFontImpl *This = impl_from_ITextFont(iface);
2716 FIXME("(%p)->(%p): stub\n", This, pFont);
2717
2718 if (This->range && !get_range_reole(This->range))
2719 return CO_E_RELEASED;
2720
2721 return E_NOTIMPL;
2722 }
2723
2724 static HRESULT WINAPI TextFont_CanChange(ITextFont *iface, LONG *ret)
2725 {
2726 ITextFontImpl *This = impl_from_ITextFont(iface);
2727 FIXME("(%p)->(%p): stub\n", This, ret);
2728
2729 if (This->range && !get_range_reole(This->range))
2730 return CO_E_RELEASED;
2731
2732 return E_NOTIMPL;
2733 }
2734
2735 static HRESULT WINAPI TextFont_IsEqual(ITextFont *iface, ITextFont *font, LONG *ret)
2736 {
2737 ITextFontImpl *This = impl_from_ITextFont(iface);
2738 FIXME("(%p)->(%p %p): stub\n", This, font, ret);
2739
2740 if (This->range && !get_range_reole(This->range))
2741 return CO_E_RELEASED;
2742
2743 return E_NOTIMPL;
2744 }
2745
2746 static void textfont_reset_to_default(ITextFontImpl *font)
2747 {
2748 enum textfont_prop_id id;
2749
2750 for (id = FONT_PROPID_FIRST; id < FONT_PROPID_LAST; id++) {
2751 switch (id)
2752 {
2753 case FONT_ALLCAPS:
2754 case FONT_ANIMATION:
2755 case FONT_BOLD:
2756 case FONT_EMBOSS:
2757 case FONT_HIDDEN:
2758 case FONT_ENGRAVE:
2759 case FONT_ITALIC:
2760 case FONT_OUTLINE:
2761 case FONT_PROTECTED:
2762 case FONT_SHADOW:
2763 case FONT_SMALLCAPS:
2764 case FONT_STRIKETHROUGH:
2765 case FONT_SUBSCRIPT:
2766 case FONT_SUPERSCRIPT:
2767 case FONT_UNDERLINE:
2768 font->props[id].l = tomFalse;
2769 break;
2770 case FONT_BACKCOLOR:
2771 case FONT_FORECOLOR:
2772 font->props[id].l = tomAutoColor;
2773 break;
2774 case FONT_KERNING:
2775 case FONT_POSITION:
2776 case FONT_SIZE:
2777 case FONT_SPACING:
2778 font->props[id].f = 0.0;
2779 break;
2780 case FONT_LANGID:
2781 font->props[id].l = GetSystemDefaultLCID();
2782 break;
2783 case FONT_NAME: {
2784 static const WCHAR sysW[] = {'S','y','s','t','e','m',0};
2785 SysFreeString(font->props[id].str);
2786 font->props[id].str = SysAllocString(sysW);
2787 break;
2788 }
2789 case FONT_WEIGHT:
2790 font->props[id].l = FW_NORMAL;
2791 break;
2792 default:
2793 FIXME("font property %d not handled\n", id);
2794 }
2795 }
2796 }
2797
2798 static void textfont_reset_to_undefined(ITextFontImpl *font)
2799 {
2800 enum textfont_prop_id id;
2801
2802 for (id = FONT_PROPID_FIRST; id < FONT_PROPID_LAST; id++) {
2803 switch (id)
2804 {
2805 case FONT_ALLCAPS:
2806 case FONT_ANIMATION:
2807 case FONT_BOLD:
2808 case FONT_EMBOSS:
2809 case FONT_HIDDEN:
2810 case FONT_ENGRAVE:
2811 case FONT_ITALIC:
2812 case FONT_OUTLINE:
2813 case FONT_PROTECTED:
2814 case FONT_SHADOW:
2815 case FONT_SMALLCAPS:
2816 case FONT_STRIKETHROUGH:
2817 case FONT_SUBSCRIPT:
2818 case FONT_SUPERSCRIPT:
2819 case FONT_UNDERLINE:
2820 case FONT_BACKCOLOR:
2821 case FONT_FORECOLOR:
2822 case FONT_LANGID:
2823 case FONT_WEIGHT:
2824 font->props[id].l = tomUndefined;
2825 break;
2826 case FONT_KERNING:
2827 case FONT_POSITION:
2828 case FONT_SIZE:
2829 case FONT_SPACING:
2830 font->props[id].f = tomUndefined;
2831 break;
2832 case FONT_NAME:
2833 break;
2834 default:
2835 FIXME("font property %d not handled\n", id);
2836 }
2837 }
2838 }
2839
2840 static void textfont_apply_range_props(ITextFontImpl *font)
2841 {
2842 enum textfont_prop_id propid;
2843 for (propid = FONT_PROPID_FIRST; propid < FONT_PROPID_LAST; propid++)
2844 set_textfont_prop(font, propid, &font->props[propid]);
2845 }
2846
2847 static HRESULT WINAPI TextFont_Reset(ITextFont *iface, LONG value)
2848 {
2849 ITextFontImpl *This = impl_from_ITextFont(iface);
2850
2851 TRACE("(%p)->(%d)\n", This, value);
2852
2853 /* If font is attached to a range, released or not, we can't
2854 reset to undefined */
2855 if (This->range) {
2856 if (!get_range_reole(This->range))
2857 return CO_E_RELEASED;
2858
2859 switch (value)
2860 {
2861 case tomUndefined:
2862 return E_INVALIDARG;
2863 case tomCacheParms:
2864 textfont_cache_range_props(This);
2865 This->get_cache_enabled = TRUE;
2866 break;
2867 case tomTrackParms:
2868 This->get_cache_enabled = FALSE;
2869 break;
2870 case tomApplyLater:
2871 This->set_cache_enabled = TRUE;
2872 break;
2873 case tomApplyNow:
2874 This->set_cache_enabled = FALSE;
2875 textfont_apply_range_props(This);
2876 break;
2877 case tomUsePoints:
2878 case tomUseTwips:
2879 return E_INVALIDARG;
2880 default:
2881 FIXME("reset mode %d not supported\n", value);
2882 }
2883
2884 return S_OK;
2885 }
2886 else {
2887 switch (value)
2888 {
2889 /* reset to global defaults */
2890 case tomDefault:
2891 textfont_reset_to_default(This);
2892 return S_OK;
2893 /* all properties are set to tomUndefined, font name is retained */
2894 case tomUndefined:
2895 textfont_reset_to_undefined(This);
2896 return S_OK;
2897 case tomApplyNow:
2898 case tomApplyLater:
2899 case tomTrackParms:
2900 case tomCacheParms:
2901 return S_OK;
2902 case tomUsePoints:
2903 case tomUseTwips:
2904 return E_INVALIDARG;
2905 }
2906 }
2907
2908 FIXME("reset mode %d not supported\n", value);
2909 return E_NOTIMPL;
2910 }
2911
2912 static HRESULT WINAPI TextFont_GetStyle(ITextFont *iface, LONG *value)
2913 {
2914 ITextFontImpl *This = impl_from_ITextFont(iface);
2915 FIXME("(%p)->(%p): stub\n", This, value);
2916
2917 if (This->range && !get_range_reole(This->range))
2918 return CO_E_RELEASED;
2919
2920 return E_NOTIMPL;
2921 }
2922
2923 static HRESULT WINAPI TextFont_SetStyle(ITextFont *iface, LONG value)
2924 {
2925 ITextFontImpl *This = impl_from_ITextFont(iface);
2926 FIXME("(%p)->(%d): stub\n", This, value);
2927
2928 if (This->range && !get_range_reole(This->range))
2929 return CO_E_RELEASED;
2930
2931 return E_NOTIMPL;
2932 }
2933
2934 static HRESULT WINAPI TextFont_GetAllCaps(ITextFont *iface, LONG *value)
2935 {
2936 ITextFontImpl *This = impl_from_ITextFont(iface);
2937 TRACE("(%p)->(%p)\n", This, value);
2938 return get_textfont_propl(This, FONT_ALLCAPS, value);
2939 }
2940
2941 static HRESULT WINAPI TextFont_SetAllCaps(ITextFont *iface, LONG value)
2942 {
2943 ITextFontImpl *This = impl_from_ITextFont(iface);
2944 TRACE("(%p)->(%d)\n", This, value);
2945 return set_textfont_propd(This, FONT_ALLCAPS, value);
2946 }
2947
2948 static HRESULT WINAPI TextFont_GetAnimation(ITextFont *iface, LONG *value)
2949 {
2950 ITextFontImpl *This = impl_from_ITextFont(iface);
2951 TRACE("(%p)->(%p)\n", This, value);
2952 return get_textfont_propl(This, FONT_ANIMATION, value);
2953 }
2954
2955 static HRESULT WINAPI TextFont_SetAnimation(ITextFont *iface, LONG value)
2956 {
2957 ITextFontImpl *This = impl_from_ITextFont(iface);
2958
2959 TRACE("(%p)->(%d)\n", This, value);
2960
2961 if (value < tomNoAnimation || value > tomAnimationMax)
2962 return E_INVALIDARG;
2963
2964 return set_textfont_propl(This, FONT_ANIMATION, value);
2965 }
2966
2967 static HRESULT WINAPI TextFont_GetBackColor(ITextFont *iface, LONG *value)
2968 {
2969 ITextFontImpl *This = impl_from_ITextFont(iface);
2970 TRACE("(%p)->(%p)\n", This, value);
2971 return get_textfont_propl(This, FONT_BACKCOLOR, value);
2972 }
2973
2974 static HRESULT WINAPI TextFont_SetBackColor(ITextFont *iface, LONG value)
2975 {
2976 ITextFontImpl *This = impl_from_ITextFont(iface);
2977 TRACE("(%p)->(%d)\n", This, value);
2978 return set_textfont_propl(This, FONT_BACKCOLOR, value);
2979 }
2980
2981 static HRESULT WINAPI TextFont_GetBold(ITextFont *iface, LONG *value)
2982 {
2983 ITextFontImpl *This = impl_from_ITextFont(iface);
2984 TRACE("(%p)->(%p)\n", This, value);
2985 return get_textfont_propl(This, FONT_BOLD, value);
2986 }
2987
2988 static HRESULT WINAPI TextFont_SetBold(ITextFont *iface, LONG value)
2989 {
2990 ITextFontImpl *This = impl_from_ITextFont(iface);
2991 TRACE("(%p)->(%d)\n", This, value);
2992 return set_textfont_propd(This, FONT_BOLD, value);
2993 }
2994
2995 static HRESULT WINAPI TextFont_GetEmboss(ITextFont *iface, LONG *value)
2996 {
2997 ITextFontImpl *This = impl_from_ITextFont(iface);
2998 TRACE("(%p)->(%p)\n", This, value);
2999 return get_textfont_propl(This, FONT_EMBOSS, value);
3000 }
3001
3002 static HRESULT WINAPI TextFont_SetEmboss(ITextFont *iface, LONG value)
3003 {
3004 ITextFontImpl *This = impl_from_ITextFont(iface);
3005 TRACE("(%p)->(%d)\n", This, value);
3006 return set_textfont_propd(This, FONT_EMBOSS, value);
3007 }
3008
3009 static HRESULT WINAPI TextFont_GetForeColor(ITextFont *iface, LONG *value)
3010 {
3011 ITextFontImpl *This = impl_from_ITextFont(iface);
3012 TRACE("(%p)->(%p)\n", This, value);
3013 return get_textfont_propl(This, FONT_FORECOLOR, value);
3014 }
3015
3016 static HRESULT WINAPI TextFont_SetForeColor(ITextFont *iface, LONG value)
3017 {
3018 ITextFontImpl *This = impl_from_ITextFont(iface);
3019 TRACE("(%p)->(%d)\n", This, value);
3020 return set_textfont_propl(This, FONT_FORECOLOR, value);
3021 }
3022
3023 static HRESULT WINAPI TextFont_GetHidden(ITextFont *iface, LONG *value)
3024 {
3025 ITextFontImpl *This = impl_from_ITextFont(iface);
3026 TRACE("(%p)->(%p)\n", This, value);
3027 return get_textfont_propl(This, FONT_HIDDEN, value);
3028 }
3029
3030 static HRESULT WINAPI TextFont_SetHidden(ITextFont *iface, LONG value)
3031 {
3032 ITextFontImpl *This = impl_from_ITextFont(iface);
3033 TRACE("(%p)->(%d)\n", This, value);
3034 return set_textfont_propd(This, FONT_HIDDEN, value);
3035 }
3036
3037 static HRESULT WINAPI TextFont_GetEngrave(ITextFont *iface, LONG *value)
3038 {
3039 ITextFontImpl *This = impl_from_ITextFont(iface);
3040 TRACE("(%p)->(%p)\n", This, value);
3041 return get_textfont_propl(This, FONT_ENGRAVE, value);
3042 }
3043
3044 static HRESULT WINAPI TextFont_SetEngrave(ITextFont *iface, LONG value)
3045 {
3046 ITextFontImpl *This = impl_from_ITextFont(iface);
3047 TRACE("(%p)->(%d)\n", This, value);
3048 return set_textfont_propd(This, FONT_ENGRAVE, value);
3049 }
3050
3051 static HRESULT WINAPI TextFont_GetItalic(ITextFont *iface, LONG *value)
3052 {
3053 ITextFontImpl *This = impl_from_ITextFont(iface);
3054 TRACE("(%p)->(%p)\n", This, value);
3055 return get_textfont_propl(This, FONT_ITALIC, value);
3056 }
3057
3058 static HRESULT WINAPI TextFont_SetItalic(ITextFont *iface, LONG value)
3059 {
3060 ITextFontImpl *This = impl_from_ITextFont(iface);
3061 TRACE("(%p)->(%d)\n", This, value);
3062 return set_textfont_propd(This, FONT_ITALIC, value);
3063 }
3064
3065 static HRESULT WINAPI TextFont_GetKerning(ITextFont *iface, FLOAT *value)
3066 {
3067 ITextFontImpl *This = impl_from_ITextFont(iface);
3068 TRACE("(%p)->(%p)\n", This, value);
3069 return get_textfont_propf(This, FONT_KERNING, value);
3070 }
3071
3072 static HRESULT WINAPI TextFont_SetKerning(ITextFont *iface, FLOAT value)
3073 {
3074 ITextFontImpl *This = impl_from_ITextFont(iface);
3075 TRACE("(%p)->(%.2f)\n", This, value);
3076 return set_textfont_propf(This, FONT_KERNING, value);
3077 }
3078
3079 static HRESULT WINAPI TextFont_GetLanguageID(ITextFont *iface, LONG *value)
3080 {
3081 ITextFontImpl *This = impl_from_ITextFont(iface);
3082 TRACE("(%p)->(%p)\n", This, value);
3083 return get_textfont_propl(This, FONT_LANGID, value);
3084 }
3085
3086 static HRESULT WINAPI TextFont_SetLanguageID(ITextFont *iface, LONG value)
3087 {
3088 ITextFontImpl *This = impl_from_ITextFont(iface);
3089 TRACE("(%p)->(%d)\n", This, value);
3090 return set_textfont_propl(This, FONT_LANGID, value);
3091 }
3092
3093 static HRESULT WINAPI TextFont_GetName(ITextFont *iface, BSTR *value)
3094 {
3095 ITextFontImpl *This = impl_from_ITextFont(iface);
3096
3097 TRACE("(%p)->(%p)\n", This, value);
3098
3099 if (!value)
3100 return E_INVALIDARG;
3101
3102 *value = NULL;
3103
3104 if (!This->range) {
3105 if (This->props[FONT_NAME].str)
3106 *value = SysAllocString(This->props[FONT_NAME].str);
3107 else
3108 *value = SysAllocStringLen(NULL, 0);
3109 return *value ? S_OK : E_OUTOFMEMORY;
3110 }
3111
3112 return textfont_getname_from_range(This->range, value);
3113 }
3114
3115 static HRESULT WINAPI TextFont_SetName(ITextFont *iface, BSTR value)
3116 {
3117 ITextFontImpl *This = impl_from_ITextFont(iface);
3118 textfont_prop_val v;
3119
3120 TRACE("(%p)->(%s)\n", This, debugstr_w(value));
3121
3122 v.str = value;
3123 return set_textfont_prop(This, FONT_NAME, &v);
3124 }
3125
3126 static HRESULT WINAPI TextFont_GetOutline(ITextFont *iface, LONG *value)
3127 {
3128 ITextFontImpl *This = impl_from_ITextFont(iface);
3129 TRACE("(%p)->(%p)\n", This, value);
3130 return get_textfont_propl(This, FONT_OUTLINE, value);
3131 }
3132
3133 static HRESULT WINAPI TextFont_SetOutline(ITextFont *iface, LONG value)
3134 {
3135 ITextFontImpl *This = impl_from_ITextFont(iface);
3136 TRACE("(%p)->(%d)\n", This, value);
3137 return set_textfont_propd(This, FONT_OUTLINE, value);
3138 }
3139
3140 static HRESULT WINAPI TextFont_GetPosition(ITextFont *iface, FLOAT *value)
3141 {
3142 ITextFontImpl *This = impl_from_ITextFont(iface);
3143 TRACE("(%p)->(%p)\n", This, value);
3144 return get_textfont_propf(This, FONT_POSITION, value);
3145 }
3146
3147 static HRESULT WINAPI TextFont_SetPosition(ITextFont *iface, FLOAT value)
3148 {
3149 ITextFontImpl *This = impl_from_ITextFont(iface);
3150 TRACE("(%p)->(%.2f)\n", This, value);
3151 return set_textfont_propf(This, FONT_POSITION, value);
3152 }
3153
3154 static HRESULT WINAPI TextFont_GetProtected(ITextFont *iface, LONG *value)
3155 {
3156 ITextFontImpl *This = impl_from_ITextFont(iface);
3157 TRACE("(%p)->(%p)\n", This, value);
3158 return get_textfont_propl(This, FONT_PROTECTED, value);
3159 }
3160
3161 static HRESULT WINAPI TextFont_SetProtected(ITextFont *iface, LONG value)
3162 {
3163 ITextFontImpl *This = impl_from_ITextFont(iface);
3164 TRACE("(%p)->(%d)\n", This, value);
3165 return set_textfont_propd(This, FONT_PROTECTED, value);
3166 }
3167
3168 static HRESULT WINAPI TextFont_GetShadow(ITextFont *iface, LONG *value)
3169 {
3170 ITextFontImpl *This = impl_from_ITextFont(iface);
3171 TRACE("(%p)->(%p)\n", This, value);
3172 return get_textfont_propl(This, FONT_SHADOW, value);
3173 }
3174
3175 static HRESULT WINAPI TextFont_SetShadow(ITextFont *iface, LONG value)
3176 {
3177 ITextFontImpl *This = impl_from_ITextFont(iface);
3178 TRACE("(%p)->(%d)\n", This, value);
3179 return set_textfont_propd(This, FONT_SHADOW, value);
3180 }
3181
3182 static HRESULT WINAPI TextFont_GetSize(ITextFont *iface, FLOAT *value)
3183 {
3184 ITextFontImpl *This = impl_from_ITextFont(iface);
3185 TRACE("(%p)->(%p)\n", This, value);
3186 return get_textfont_propf(This, FONT_SIZE, value);
3187 }
3188
3189 static HRESULT WINAPI TextFont_SetSize(ITextFont *iface, FLOAT value)
3190 {
3191 ITextFontImpl *This = impl_from_ITextFont(iface);
3192 TRACE("(%p)->(%.2f)\n", This, value);
3193 return set_textfont_propf(This, FONT_SIZE, value);
3194 }
3195
3196 static HRESULT WINAPI TextFont_GetSmallCaps(ITextFont *iface, LONG *value)
3197 {
3198 ITextFontImpl *This = impl_from_ITextFont(iface);
3199 TRACE("(%p)->(%p)\n", This, value);
3200 return get_textfont_propl(This, FONT_SMALLCAPS, value);
3201 }
3202
3203 static HRESULT WINAPI TextFont_SetSmallCaps(ITextFont *iface, LONG value)
3204 {
3205 ITextFontImpl *This = impl_from_ITextFont(iface);
3206 TRACE("(%p)->(%d)\n", This, value);
3207 return set_textfont_propd(This, FONT_SMALLCAPS, value);
3208 }
3209
3210 static HRESULT WINAPI TextFont_GetSpacing(ITextFont *iface, FLOAT *value)
3211 {
3212 ITextFontImpl *This = impl_from_ITextFont(iface);
3213 TRACE("(%p)->(%p)\n", This, value);
3214 return get_textfont_propf(This, FONT_SPACING, value);
3215 }
3216
3217 static HRESULT WINAPI TextFont_SetSpacing(ITextFont *iface, FLOAT value)
3218 {
3219 ITextFontImpl *This = impl_from_ITextFont(iface);
3220 TRACE("(%p)->(%.2f)\n", This, value);
3221 return set_textfont_propf(This, FONT_SPACING, value);
3222 }
3223
3224 static HRESULT WINAPI TextFont_GetStrikeThrough(ITextFont *iface, LONG *value)
3225 {
3226 ITextFontImpl *This = impl_from_ITextFont(iface);
3227 TRACE("(%p)->(%p)\n", This, value);
3228 return get_textfont_propl(This, FONT_STRIKETHROUGH, value);
3229 }
3230
3231 static HRESULT WINAPI TextFont_SetStrikeThrough(ITextFont *iface,