2 * OLE Font encapsulation implementation
4 * This file contains an implementation of the IFont
5 * interface and the OleCreateFontIndirect API call.
7 * Copyright 1999 Francis Beaudet
8 * Copyright 2006 (Google) Benjamin Arai
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2.1 of the License, or (at your option) any later version.
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with this library; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
29 #define NONAMELESSUNION
30 #define NONAMELESSSTRUCT
37 #include "wine/list.h"
38 #include "wine/unicode.h"
40 #include "oleauto.h" /* for SysAllocString(....) */
43 #include "wine/debug.h"
44 #include "connpt.h" /* for CreateConnectionPoint */
47 WINE_DEFAULT_DEBUG_CHANNEL(ole
);
49 /***********************************************************************
50 * Declaration of constants used when serializing the font object.
52 #define FONTPERSIST_ITALIC 0x02
53 #define FONTPERSIST_UNDERLINE 0x04
54 #define FONTPERSIST_STRIKETHROUGH 0x08
56 static HDC olefont_hdc
;
58 /***********************************************************************
59 * List of the HFONTs it has given out, with each one having a separate
62 typedef struct _HFONTItem
66 /* Reference count of any IFont objects that own this hfont */
69 /* Total reference count of any refs held by the application obtained by AddRefHfont plus any internal refs */
72 /* The font associated with this object. */
75 } HFONTItem
, *PHFONTItem
;
77 static struct list OLEFontImpl_hFontList
= LIST_INIT(OLEFontImpl_hFontList
);
79 /* Counts how many fonts contain at least one lock */
80 static LONG ifont_cnt
= 0;
82 /***********************************************************************
83 * Critical section for OLEFontImpl_hFontList
85 static CRITICAL_SECTION OLEFontImpl_csHFONTLIST
;
86 static CRITICAL_SECTION_DEBUG OLEFontImpl_csHFONTLIST_debug
=
88 0, 0, &OLEFontImpl_csHFONTLIST
,
89 { &OLEFontImpl_csHFONTLIST_debug
.ProcessLocksList
,
90 &OLEFontImpl_csHFONTLIST_debug
.ProcessLocksList
},
91 0, 0, { (DWORD_PTR
)(__FILE__
": OLEFontImpl_csHFONTLIST") }
93 static CRITICAL_SECTION OLEFontImpl_csHFONTLIST
= { &OLEFontImpl_csHFONTLIST_debug
, -1, 0, 0, 0, 0 };
95 static HDC
get_dc(void)
98 EnterCriticalSection(&OLEFontImpl_csHFONTLIST
);
100 olefont_hdc
= CreateCompatibleDC(NULL
);
102 LeaveCriticalSection(&OLEFontImpl_csHFONTLIST
);
106 static void delete_dc(void)
108 EnterCriticalSection(&OLEFontImpl_csHFONTLIST
);
111 DeleteDC(olefont_hdc
);
114 LeaveCriticalSection(&OLEFontImpl_csHFONTLIST
);
117 static void HFONTItem_Delete(PHFONTItem item
)
119 DeleteObject(item
->gdiFont
);
120 list_remove(&item
->entry
);
121 HeapFree(GetProcessHeap(), 0, item
);
124 /* Find hfont item entry in the list. Should be called while holding the crit sect */
125 static HFONTItem
*find_hfontitem(HFONT hfont
)
129 LIST_FOR_EACH_ENTRY(item
, &OLEFontImpl_hFontList
, HFONTItem
, entry
)
131 if (item
->gdiFont
== hfont
)
137 /* Add an item to the list with one internal reference */
138 static HRESULT
add_hfontitem(HFONT hfont
)
140 HFONTItem
*new_item
= HeapAlloc(GetProcessHeap(), 0, sizeof(*new_item
));
142 if(!new_item
) return E_OUTOFMEMORY
;
144 new_item
->int_refs
= 1;
145 new_item
->total_refs
= 1;
146 new_item
->gdiFont
= hfont
;
147 EnterCriticalSection(&OLEFontImpl_csHFONTLIST
);
148 list_add_tail(&OLEFontImpl_hFontList
,&new_item
->entry
);
149 LeaveCriticalSection(&OLEFontImpl_csHFONTLIST
);
153 static HRESULT
inc_int_ref(HFONT hfont
)
156 HRESULT hr
= S_FALSE
;
158 EnterCriticalSection(&OLEFontImpl_csHFONTLIST
);
159 item
= find_hfontitem(hfont
);
167 LeaveCriticalSection(&OLEFontImpl_csHFONTLIST
);
172 /* decrements the internal ref of a hfont item. If both refs are zero it'll
173 remove the item from the list and delete the hfont */
174 static HRESULT
dec_int_ref(HFONT hfont
)
177 HRESULT hr
= S_FALSE
;
179 EnterCriticalSection(&OLEFontImpl_csHFONTLIST
);
180 item
= find_hfontitem(hfont
);
186 if(item
->int_refs
== 0 && item
->total_refs
== 0)
187 HFONTItem_Delete(item
);
190 LeaveCriticalSection(&OLEFontImpl_csHFONTLIST
);
195 static HRESULT
inc_ext_ref(HFONT hfont
)
198 HRESULT hr
= S_FALSE
;
200 EnterCriticalSection(&OLEFontImpl_csHFONTLIST
);
202 item
= find_hfontitem(hfont
);
208 LeaveCriticalSection(&OLEFontImpl_csHFONTLIST
);
213 static HRESULT
dec_ext_ref(HFONT hfont
)
216 HRESULT hr
= S_FALSE
;
218 EnterCriticalSection(&OLEFontImpl_csHFONTLIST
);
220 item
= find_hfontitem(hfont
);
223 if(--item
->total_refs
>= 0) hr
= S_OK
;
225 LeaveCriticalSection(&OLEFontImpl_csHFONTLIST
);
230 static WCHAR
*strdupW(const WCHAR
* str
)
233 DWORD size
= (strlenW(str
) + 1) * sizeof(WCHAR
);
235 ret
= HeapAlloc(GetProcessHeap(), 0, size
);
237 memcpy(ret
, str
, size
);
241 /***********************************************************************
242 * Declaration of the implementation class for the IFont interface
244 typedef struct OLEFontImpl OLEFontImpl
;
249 * This class supports many interfaces. IUnknown, IFont,
250 * IDispatch, IDispFont IPersistStream and IConnectionPointContainer.
251 * The first two are supported by the first vtable, the next two are
252 * supported by the second table and the last two have their own.
255 IDispatch IDispatch_iface
;
256 IPersistStream IPersistStream_iface
;
257 IConnectionPointContainer IConnectionPointContainer_iface
;
258 IPersistPropertyBag IPersistPropertyBag_iface
;
259 IPersistStreamInit IPersistStreamInit_iface
;
261 * Reference count for that instance of the class.
266 * This structure contains the description of the class.
268 FONTDESC description
;
271 * Contain the font associated with this object.
282 * Stash realized height (pixels) from TEXTMETRIC - used in get_Size()
286 IConnectionPoint
*pPropertyNotifyCP
;
287 IConnectionPoint
*pFontEventsCP
;
291 * Here, I define utility macros to help with the casting of the
293 * There is a version to accommodate all of the VTables implemented
297 static inline OLEFontImpl
*impl_from_IFont(IFont
*iface
)
299 return CONTAINING_RECORD(iface
, OLEFontImpl
, IFont_iface
);
302 static inline OLEFontImpl
*impl_from_IDispatch( IDispatch
*iface
)
304 return CONTAINING_RECORD(iface
, OLEFontImpl
, IDispatch_iface
);
307 static inline OLEFontImpl
*impl_from_IPersistStream( IPersistStream
*iface
)
309 return CONTAINING_RECORD(iface
, OLEFontImpl
, IPersistStream_iface
);
312 static inline OLEFontImpl
*impl_from_IConnectionPointContainer( IConnectionPointContainer
*iface
)
314 return CONTAINING_RECORD(iface
, OLEFontImpl
, IConnectionPointContainer_iface
);
317 static inline OLEFontImpl
*impl_from_IPersistPropertyBag( IPersistPropertyBag
*iface
)
319 return CONTAINING_RECORD(iface
, OLEFontImpl
, IPersistPropertyBag_iface
);
322 static inline OLEFontImpl
*impl_from_IPersistStreamInit( IPersistStreamInit
*iface
)
324 return CONTAINING_RECORD(iface
, OLEFontImpl
, IPersistStreamInit_iface
);
328 /***********************************************************************
329 * Prototypes for the implementation functions for the IFont
332 static OLEFontImpl
* OLEFontImpl_Construct(const FONTDESC
*fontDesc
);
333 static void OLEFontImpl_Destroy(OLEFontImpl
* fontDesc
);
334 static ULONG WINAPI
OLEFontImpl_AddRef(IFont
* iface
);
336 /******************************************************************************
337 * OleCreateFontIndirect [OLEAUT32.420]
339 HRESULT WINAPI
OleCreateFontIndirect(
340 LPFONTDESC lpFontDesc
,
344 OLEFontImpl
* newFont
= 0;
348 TRACE("(%p, %s, %p)\n", lpFontDesc
, debugstr_guid(riid
), ppvObj
);
358 static WCHAR fname
[] = { 'S','y','s','t','e','m',0 };
360 fd
.cbSizeofstruct
= sizeof(fd
);
361 fd
.lpstrName
= fname
;
362 fd
.cySize
.s
.Lo
= 80000;
368 fd
.fStrikethrough
= 0;
373 * Try to construct a new instance of the class.
375 newFont
= OLEFontImpl_Construct(lpFontDesc
);
378 return E_OUTOFMEMORY
;
381 * Make sure it supports the interface required by the caller.
383 hr
= IFont_QueryInterface(&newFont
->IFont_iface
, riid
, ppvObj
);
386 * Release the reference obtained in the constructor. If
387 * the QueryInterface was unsuccessful, it will free the class.
389 IFont_Release(&newFont
->IFont_iface
);
395 /***********************************************************************
396 * Implementation of the OLEFontImpl class.
399 /***********************************************************************
400 * OLEFont_SendNotify (internal)
402 * Sends notification messages of changed properties to any interested
405 static void OLEFont_SendNotify(OLEFontImpl
* this, DISPID dispID
)
407 static const WCHAR wszName
[] = {'N','a','m','e',0};
408 static const WCHAR wszSize
[] = {'S','i','z','e',0};
409 static const WCHAR wszBold
[] = {'B','o','l','d',0};
410 static const WCHAR wszItalic
[] = {'I','t','a','l','i','c',0};
411 static const WCHAR wszUnder
[] = {'U','n','d','e','r','l','i','n','e',0};
412 static const WCHAR wszStrike
[] = {'S','t','r','i','k','e','t','h','r','o','u','g','h',0};
413 static const WCHAR wszWeight
[] = {'W','e','i','g','h','t',0};
414 static const WCHAR wszCharset
[] = {'C','h','a','r','s','s','e','t',0};
415 static const LPCWSTR dispid_mapping
[] =
428 IEnumConnections
*pEnum
;
434 hres
= IConnectionPoint_EnumConnections(this->pPropertyNotifyCP
, &pEnum
);
437 while(IEnumConnections_Next(pEnum
, 1, &CD
, NULL
) == S_OK
) {
438 IPropertyNotifySink
*sink
;
440 IUnknown_QueryInterface(CD
.pUnk
, &IID_IPropertyNotifySink
, (LPVOID
)&sink
);
441 IPropertyNotifySink_OnChanged(sink
, dispID
);
442 IPropertyNotifySink_Release(sink
);
443 IUnknown_Release(CD
.pUnk
);
445 IEnumConnections_Release(pEnum
);
448 hres
= IConnectionPoint_EnumConnections(this->pFontEventsCP
, &pEnum
);
451 DISPPARAMS dispparams
;
454 VariantInit(&vararg
);
455 V_VT(&vararg
) = VT_BSTR
;
456 V_BSTR(&vararg
) = SysAllocString(dispid_mapping
[dispID
]);
458 dispparams
.cArgs
= 1;
459 dispparams
.cNamedArgs
= 0;
460 dispparams
.rgdispidNamedArgs
= NULL
;
461 dispparams
.rgvarg
= &vararg
;
463 while(IEnumConnections_Next(pEnum
, 1, &CD
, NULL
) == S_OK
) {
464 IFontEventsDisp
*disp
;
466 IUnknown_QueryInterface(CD
.pUnk
, &IID_IFontEventsDisp
, (LPVOID
)&disp
);
467 IDispatch_Invoke(disp
, DISPID_FONT_CHANGED
, &IID_NULL
,
468 LOCALE_NEUTRAL
, INVOKE_FUNC
, &dispparams
, NULL
,
471 IDispatch_Release(disp
);
472 IUnknown_Release(CD
.pUnk
);
474 VariantClear(&vararg
);
475 IEnumConnections_Release(pEnum
);
479 /************************************************************************
480 * OLEFontImpl_QueryInterface (IUnknown)
482 * See Windows documentation for more details on IUnknown methods.
484 static HRESULT WINAPI
OLEFontImpl_QueryInterface(
489 OLEFontImpl
*this = impl_from_IFont(iface
);
490 TRACE("(%p)->(%s, %p)\n", this, debugstr_guid(riid
), ppvObject
);
495 * Compare the riid with the interface IDs implemented by this object.
497 if (IsEqualGUID(&IID_IUnknown
, riid
))
499 if (IsEqualGUID(&IID_IFont
, riid
))
501 if (IsEqualGUID(&IID_IDispatch
, riid
))
502 *ppvObject
= &this->IDispatch_iface
;
503 if (IsEqualGUID(&IID_IFontDisp
, riid
))
504 *ppvObject
= &this->IDispatch_iface
;
505 if (IsEqualIID(&IID_IPersist
, riid
) || IsEqualGUID(&IID_IPersistStream
, riid
))
506 *ppvObject
= &this->IPersistStream_iface
;
507 if (IsEqualGUID(&IID_IConnectionPointContainer
, riid
))
508 *ppvObject
= &this->IConnectionPointContainer_iface
;
509 if (IsEqualGUID(&IID_IPersistPropertyBag
, riid
))
510 *ppvObject
= &this->IPersistPropertyBag_iface
;
511 if (IsEqualGUID(&IID_IPersistStreamInit
, riid
))
512 *ppvObject
= &this->IPersistStreamInit_iface
;
515 * Check that we obtained an interface.
519 FIXME("() : asking for unsupported interface %s\n",debugstr_guid(riid
));
520 return E_NOINTERFACE
;
522 OLEFontImpl_AddRef(&this->IFont_iface
);
526 /************************************************************************
527 * OLEFontImpl_AddRef (IUnknown)
529 * See Windows documentation for more details on IUnknown methods.
531 static ULONG WINAPI
OLEFontImpl_AddRef(
534 OLEFontImpl
*this = impl_from_IFont(iface
);
535 TRACE("(%p)->(ref=%d)\n", this, this->ref
);
536 return InterlockedIncrement(&this->ref
);
539 /************************************************************************
540 * OLEFontImpl_Release (IUnknown)
542 * See Windows documentation for more details on IUnknown methods.
544 static ULONG WINAPI
OLEFontImpl_Release(
547 OLEFontImpl
*this = impl_from_IFont(iface
);
549 TRACE("(%p)->(ref=%d)\n", this, this->ref
);
551 /* Decrease the reference count for current interface */
552 ret
= InterlockedDecrement(&this->ref
);
554 /* If the reference count goes down to 0, destroy. */
557 ULONG fontlist_refs
= InterlockedDecrement(&ifont_cnt
);
559 /* Final IFont object so destroy font cache */
560 if (fontlist_refs
== 0)
562 HFONTItem
*item
, *cursor2
;
564 EnterCriticalSection(&OLEFontImpl_csHFONTLIST
);
565 LIST_FOR_EACH_ENTRY_SAFE(item
, cursor2
, &OLEFontImpl_hFontList
, HFONTItem
, entry
)
566 HFONTItem_Delete(item
);
567 LeaveCriticalSection(&OLEFontImpl_csHFONTLIST
);
572 dec_int_ref(this->gdiFont
);
574 OLEFontImpl_Destroy(this);
586 static int CALLBACK
font_enum_proc(const LOGFONTW
*elf
, const TEXTMETRICW
*ntm
, DWORD type
, LPARAM lp
)
588 enum_data
*data
= (enum_data
*)lp
;
590 if(elf
->lfCharSet
== data
->orig_cs
)
592 data
->avail_cs
= data
->orig_cs
;
595 if(data
->avail_cs
== -1) data
->avail_cs
= elf
->lfCharSet
;
599 static void realize_font(OLEFontImpl
*This
)
605 WCHAR text_face
[LF_FACESIZE
];
614 old_font
= SelectObject(hdc
, This
->gdiFont
);
615 GetTextFaceW(hdc
, sizeof(text_face
) / sizeof(text_face
[0]), text_face
);
616 SelectObject(hdc
, old_font
);
617 dec_int_ref(This
->gdiFont
);
621 memset(&logFont
, 0, sizeof(LOGFONTW
));
623 lstrcpynW(logFont
.lfFaceName
, This
->description
.lpstrName
, LF_FACESIZE
);
624 logFont
.lfCharSet
= This
->description
.sCharset
;
626 /* If the font name has been changed then enumerate all charsets
627 and pick one that'll result in the font specified being selected */
628 if(text_face
[0] && lstrcmpiW(text_face
, This
->description
.lpstrName
))
631 data
.orig_cs
= This
->description
.sCharset
;
633 logFont
.lfCharSet
= DEFAULT_CHARSET
;
634 EnumFontFamiliesExW(get_dc(), &logFont
, font_enum_proc
, (LPARAM
)&data
, 0);
635 if(data
.avail_cs
!= -1) logFont
.lfCharSet
= data
.avail_cs
;
640 * The height of the font returned by the get_Size property is the
641 * height of the font in points multiplied by 10000... Using some
642 * simple conversions and the ratio given by the application, it can
643 * be converted to a height in pixels.
645 * Standard ratio is 72 / 2540, or 18 / 635 in lowest terms.
646 * Ratio is applied here relative to the standard.
649 fontHeight
= MulDiv( This
->description
.cySize
.s
.Lo
, This
->cyLogical
*635, This
->cyHimetric
*18 );
652 logFont
.lfHeight
= ((fontHeight
%10000L)>5000L) ? (-fontHeight
/10000L) - 1 :
653 (-fontHeight
/10000L);
654 logFont
.lfItalic
= This
->description
.fItalic
;
655 logFont
.lfUnderline
= This
->description
.fUnderline
;
656 logFont
.lfStrikeOut
= This
->description
.fStrikethrough
;
657 logFont
.lfWeight
= This
->description
.sWeight
;
658 logFont
.lfOutPrecision
= OUT_CHARACTER_PRECIS
;
659 logFont
.lfClipPrecision
= CLIP_DEFAULT_PRECIS
;
660 logFont
.lfQuality
= DEFAULT_QUALITY
;
661 logFont
.lfPitchAndFamily
= DEFAULT_PITCH
;
663 This
->gdiFont
= CreateFontIndirectW(&logFont
);
666 add_hfontitem(This
->gdiFont
);
668 /* Fixup the name and charset properties so that they match the
670 old_font
= SelectObject(get_dc(), This
->gdiFont
);
671 GetTextFaceW(hdc
, sizeof(text_face
) / sizeof(text_face
[0]), text_face
);
672 if(lstrcmpiW(text_face
, This
->description
.lpstrName
))
674 HeapFree(GetProcessHeap(), 0, This
->description
.lpstrName
);
675 This
->description
.lpstrName
= strdupW(text_face
);
677 GetTextMetricsW(hdc
, &tm
);
678 This
->description
.sCharset
= tm
.tmCharSet
;
679 /* While we have it handy, stash the realized font height for use by get_Size() */
680 This
->nRealHeight
= tm
.tmHeight
- tm
.tmInternalLeading
; /* corresponds to LOGFONT lfHeight */
681 SelectObject(hdc
, old_font
);
685 /************************************************************************
686 * OLEFontImpl_get_Name (IFont)
688 * See Windows documentation for more details on IFont methods.
690 static HRESULT WINAPI
OLEFontImpl_get_Name(
694 OLEFontImpl
*this = impl_from_IFont(iface
);
695 TRACE("(%p)->(%p)\n", this, pname
);
702 if(this->dirty
) realize_font(this);
704 if (this->description
.lpstrName
!=0)
705 *pname
= SysAllocString(this->description
.lpstrName
);
712 /************************************************************************
713 * OLEFontImpl_put_Name (IFont)
715 * See Windows documentation for more details on IFont methods.
717 static HRESULT WINAPI
OLEFontImpl_put_Name(
721 OLEFontImpl
*this = impl_from_IFont(iface
);
722 TRACE("(%p)->(%p)\n", this, name
);
725 return CTL_E_INVALIDPROPERTYVALUE
;
727 if (this->description
.lpstrName
==0)
729 this->description
.lpstrName
= HeapAlloc(GetProcessHeap(),
731 (lstrlenW(name
)+1) * sizeof(WCHAR
));
735 this->description
.lpstrName
= HeapReAlloc(GetProcessHeap(),
737 this->description
.lpstrName
,
738 (lstrlenW(name
)+1) * sizeof(WCHAR
));
741 if (this->description
.lpstrName
==0)
742 return E_OUTOFMEMORY
;
744 strcpyW(this->description
.lpstrName
, name
);
745 TRACE("new name %s\n", debugstr_w(this->description
.lpstrName
));
746 OLEFont_SendNotify(this, DISPID_FONT_NAME
);
750 /************************************************************************
751 * OLEFontImpl_get_Size (IFont)
753 * See Windows documentation for more details on IFont methods.
755 static HRESULT WINAPI
OLEFontImpl_get_Size(
759 OLEFontImpl
*this = impl_from_IFont(iface
);
760 TRACE("(%p)->(%p)\n", this, psize
);
768 if(this->dirty
) realize_font(this);
771 * Convert realized font height in pixels to points descaled by current
772 * scaling ratio then scaled up by 10000.
774 psize
->s
.Lo
= MulDiv(this->nRealHeight
,
775 this->cyHimetric
* 72 * 10000,
776 this->cyLogical
* 2540);
782 /************************************************************************
783 * OLEFontImpl_put_Size (IFont)
785 * See Windows documentation for more details on IFont methods.
787 static HRESULT WINAPI
OLEFontImpl_put_Size(
791 OLEFontImpl
*this = impl_from_IFont(iface
);
792 TRACE("(%p)->(%d)\n", this, size
.s
.Lo
);
793 this->description
.cySize
.s
.Hi
= 0;
794 this->description
.cySize
.s
.Lo
= size
.s
.Lo
;
795 OLEFont_SendNotify(this, DISPID_FONT_SIZE
);
800 /************************************************************************
801 * OLEFontImpl_get_Bold (IFont)
803 * See Windows documentation for more details on IFont methods.
805 static HRESULT WINAPI
OLEFontImpl_get_Bold(
809 OLEFontImpl
*this = impl_from_IFont(iface
);
810 TRACE("(%p)->(%p)\n", this, pbold
);
817 if(this->dirty
) realize_font(this);
819 *pbold
= this->description
.sWeight
> 550;
824 /************************************************************************
825 * OLEFontImpl_put_Bold (IFont)
827 * See Windows documentation for more details on IFont methods.
829 static HRESULT WINAPI
OLEFontImpl_put_Bold(
833 OLEFontImpl
*this = impl_from_IFont(iface
);
834 TRACE("(%p)->(%d)\n", this, bold
);
835 this->description
.sWeight
= bold
? FW_BOLD
: FW_NORMAL
;
836 OLEFont_SendNotify(this, DISPID_FONT_BOLD
);
841 /************************************************************************
842 * OLEFontImpl_get_Italic (IFont)
844 * See Windows documentation for more details on IFont methods.
846 static HRESULT WINAPI
OLEFontImpl_get_Italic(
850 OLEFontImpl
*this = impl_from_IFont(iface
);
851 TRACE("(%p)->(%p)\n", this, pitalic
);
858 if(this->dirty
) realize_font(this);
860 *pitalic
= this->description
.fItalic
;
865 /************************************************************************
866 * OLEFontImpl_put_Italic (IFont)
868 * See Windows documentation for more details on IFont methods.
870 static HRESULT WINAPI
OLEFontImpl_put_Italic(
874 OLEFontImpl
*this = impl_from_IFont(iface
);
875 TRACE("(%p)->(%d)\n", this, italic
);
877 this->description
.fItalic
= italic
;
879 OLEFont_SendNotify(this, DISPID_FONT_ITALIC
);
883 /************************************************************************
884 * OLEFontImpl_get_Underline (IFont)
886 * See Windows documentation for more details on IFont methods.
888 static HRESULT WINAPI
OLEFontImpl_get_Underline(
892 OLEFontImpl
*this = impl_from_IFont(iface
);
893 TRACE("(%p)->(%p)\n", this, punderline
);
901 if(this->dirty
) realize_font(this);
903 *punderline
= this->description
.fUnderline
;
908 /************************************************************************
909 * OLEFontImpl_put_Underline (IFont)
911 * See Windows documentation for more details on IFont methods.
913 static HRESULT WINAPI
OLEFontImpl_put_Underline(
917 OLEFontImpl
*this = impl_from_IFont(iface
);
918 TRACE("(%p)->(%d)\n", this, underline
);
920 this->description
.fUnderline
= underline
;
922 OLEFont_SendNotify(this, DISPID_FONT_UNDER
);
926 /************************************************************************
927 * OLEFontImpl_get_Strikethrough (IFont)
929 * See Windows documentation for more details on IFont methods.
931 static HRESULT WINAPI
OLEFontImpl_get_Strikethrough(
933 BOOL
* pstrikethrough
)
935 OLEFontImpl
*this = impl_from_IFont(iface
);
936 TRACE("(%p)->(%p)\n", this, pstrikethrough
);
941 if (pstrikethrough
==0)
944 if(this->dirty
) realize_font(this);
946 *pstrikethrough
= this->description
.fStrikethrough
;
951 /************************************************************************
952 * OLEFontImpl_put_Strikethrough (IFont)
954 * See Windows documentation for more details on IFont methods.
956 static HRESULT WINAPI
OLEFontImpl_put_Strikethrough(
960 OLEFontImpl
*this = impl_from_IFont(iface
);
961 TRACE("(%p)->(%d)\n", this, strikethrough
);
963 this->description
.fStrikethrough
= strikethrough
;
964 OLEFont_SendNotify(this, DISPID_FONT_STRIKE
);
969 /************************************************************************
970 * OLEFontImpl_get_Weight (IFont)
972 * See Windows documentation for more details on IFont methods.
974 static HRESULT WINAPI
OLEFontImpl_get_Weight(
978 OLEFontImpl
*this = impl_from_IFont(iface
);
979 TRACE("(%p)->(%p)\n", this, pweight
);
987 if(this->dirty
) realize_font(this);
989 *pweight
= this->description
.sWeight
;
994 /************************************************************************
995 * OLEFontImpl_put_Weight (IFont)
997 * See Windows documentation for more details on IFont methods.
999 static HRESULT WINAPI
OLEFontImpl_put_Weight(
1003 OLEFontImpl
*this = impl_from_IFont(iface
);
1004 TRACE("(%p)->(%d)\n", this, weight
);
1006 this->description
.sWeight
= weight
;
1008 OLEFont_SendNotify(this, DISPID_FONT_WEIGHT
);
1012 /************************************************************************
1013 * OLEFontImpl_get_Charset (IFont)
1015 * See Windows documentation for more details on IFont methods.
1017 static HRESULT WINAPI
OLEFontImpl_get_Charset(
1021 OLEFontImpl
*this = impl_from_IFont(iface
);
1022 TRACE("(%p)->(%p)\n", this, pcharset
);
1030 if(this->dirty
) realize_font(this);
1032 *pcharset
= this->description
.sCharset
;
1037 /************************************************************************
1038 * OLEFontImpl_put_Charset (IFont)
1040 * See Windows documentation for more details on IFont methods.
1042 static HRESULT WINAPI
OLEFontImpl_put_Charset(
1046 OLEFontImpl
*this = impl_from_IFont(iface
);
1047 TRACE("(%p)->(%d)\n", this, charset
);
1049 this->description
.sCharset
= charset
;
1050 OLEFont_SendNotify(this, DISPID_FONT_CHARSET
);
1055 /************************************************************************
1056 * OLEFontImpl_get_hFont (IFont)
1058 * See Windows documentation for more details on IFont methods.
1060 static HRESULT WINAPI
OLEFontImpl_get_hFont(
1064 OLEFontImpl
*this = impl_from_IFont(iface
);
1065 TRACE("(%p)->(%p)\n", this, phfont
);
1069 if(this->dirty
) realize_font(this);
1071 *phfont
= this->gdiFont
;
1072 TRACE("Returning %p\n", *phfont
);
1076 /************************************************************************
1077 * OLEFontImpl_Clone (IFont)
1079 * See Windows documentation for more details on IFont methods.
1081 static HRESULT WINAPI
OLEFontImpl_Clone(
1085 OLEFontImpl
* newObject
= 0;
1086 OLEFontImpl
*this = impl_from_IFont(iface
);
1088 TRACE("(%p)->(%p)\n", this, ppfont
);
1096 * Allocate space for the object.
1098 newObject
= HeapAlloc(GetProcessHeap(), 0, sizeof(OLEFontImpl
));
1100 if (newObject
==NULL
)
1101 return E_OUTOFMEMORY
;
1105 /* We need to alloc new memory for the string, otherwise
1106 * we free memory twice.
1108 newObject
->description
.lpstrName
= HeapAlloc(
1110 (1+strlenW(this->description
.lpstrName
))*2
1112 strcpyW(newObject
->description
.lpstrName
, this->description
.lpstrName
);
1115 /* Increment internal ref in hfont item list */
1116 if(newObject
->gdiFont
) inc_int_ref(newObject
->gdiFont
);
1118 InterlockedIncrement(&ifont_cnt
);
1120 /* create new connection points */
1121 newObject
->pPropertyNotifyCP
= NULL
;
1122 newObject
->pFontEventsCP
= NULL
;
1123 CreateConnectionPoint((IUnknown
*)newObject
, &IID_IPropertyNotifySink
, &newObject
->pPropertyNotifyCP
);
1124 CreateConnectionPoint((IUnknown
*)newObject
, &IID_IFontEventsDisp
, &newObject
->pFontEventsCP
);
1126 if (!newObject
->pPropertyNotifyCP
|| !newObject
->pFontEventsCP
)
1128 OLEFontImpl_Destroy(newObject
);
1129 return E_OUTOFMEMORY
;
1132 /* The cloned object starts with a reference count of 1 */
1135 *ppfont
= &newObject
->IFont_iface
;
1140 /************************************************************************
1141 * OLEFontImpl_IsEqual (IFont)
1143 * See Windows documentation for more details on IFont methods.
1145 static HRESULT WINAPI
OLEFontImpl_IsEqual(
1149 OLEFontImpl
*left
= impl_from_IFont(iface
);
1150 OLEFontImpl
*right
= impl_from_IFont(pFontOther
);
1152 INT left_len
,right_len
;
1154 if(pFontOther
== NULL
)
1156 else if (left
->description
.cySize
.s
.Lo
!= right
->description
.cySize
.s
.Lo
)
1158 else if (left
->description
.cySize
.s
.Hi
!= right
->description
.cySize
.s
.Hi
)
1160 else if (left
->description
.sWeight
!= right
->description
.sWeight
)
1162 else if (left
->description
.sCharset
!= right
->description
.sCharset
)
1164 else if (left
->description
.fItalic
!= right
->description
.fItalic
)
1166 else if (left
->description
.fUnderline
!= right
->description
.fUnderline
)
1168 else if (left
->description
.fStrikethrough
!= right
->description
.fStrikethrough
)
1171 /* Check from string */
1172 left_len
= strlenW(left
->description
.lpstrName
);
1173 right_len
= strlenW(right
->description
.lpstrName
);
1174 ret
= CompareStringW(0,0,left
->description
.lpstrName
, left_len
,
1175 right
->description
.lpstrName
, right_len
);
1176 if (ret
!= CSTR_EQUAL
)
1182 /************************************************************************
1183 * OLEFontImpl_SetRatio (IFont)
1185 * See Windows documentation for more details on IFont methods.
1187 static HRESULT WINAPI
OLEFontImpl_SetRatio(
1192 OLEFontImpl
*this = impl_from_IFont(iface
);
1193 TRACE("(%p)->(%d, %d)\n", this, cyLogical
, cyHimetric
);
1195 if(cyLogical
== 0 || cyHimetric
== 0)
1196 return E_INVALIDARG
;
1198 this->cyLogical
= cyLogical
;
1199 this->cyHimetric
= cyHimetric
;
1205 /************************************************************************
1206 * OLEFontImpl_QueryTextMetrics (IFont)
1208 * See Windows documentation for more details on IFont methods.
1210 static HRESULT WINAPI
OLEFontImpl_QueryTextMetrics(
1215 HFONT hOldFont
, hNewFont
;
1218 OLEFontImpl_get_hFont(iface
, &hNewFont
);
1219 hOldFont
= SelectObject(hdcRef
, hNewFont
);
1220 GetTextMetricsW(hdcRef
, ptm
);
1221 SelectObject(hdcRef
, hOldFont
);
1222 ReleaseDC(0, hdcRef
);
1226 /************************************************************************
1227 * OLEFontImpl_AddRefHfont (IFont)
1229 * See Windows documentation for more details on IFont methods.
1231 static HRESULT WINAPI
OLEFontImpl_AddRefHfont(
1235 OLEFontImpl
*this = impl_from_IFont(iface
);
1237 TRACE("(%p)->(%p)\n", this, hfont
);
1239 if (!hfont
) return E_INVALIDARG
;
1241 return inc_ext_ref(hfont
);
1244 /************************************************************************
1245 * OLEFontImpl_ReleaseHfont (IFont)
1247 * See Windows documentation for more details on IFont methods.
1249 static HRESULT WINAPI
OLEFontImpl_ReleaseHfont(
1253 OLEFontImpl
*this = impl_from_IFont(iface
);
1255 TRACE("(%p)->(%p)\n", this, hfont
);
1257 if (!hfont
) return E_INVALIDARG
;
1259 return dec_ext_ref(hfont
);
1262 /************************************************************************
1263 * OLEFontImpl_SetHdc (IFont)
1265 * See Windows documentation for more details on IFont methods.
1267 static HRESULT WINAPI
OLEFontImpl_SetHdc(
1271 OLEFontImpl
*this = impl_from_IFont(iface
);
1272 FIXME("(%p)->(%p): Stub\n", this, hdc
);
1277 * Virtual function tables for the OLEFontImpl class.
1279 static const IFontVtbl OLEFontImpl_VTable
=
1281 OLEFontImpl_QueryInterface
,
1283 OLEFontImpl_Release
,
1284 OLEFontImpl_get_Name
,
1285 OLEFontImpl_put_Name
,
1286 OLEFontImpl_get_Size
,
1287 OLEFontImpl_put_Size
,
1288 OLEFontImpl_get_Bold
,
1289 OLEFontImpl_put_Bold
,
1290 OLEFontImpl_get_Italic
,
1291 OLEFontImpl_put_Italic
,
1292 OLEFontImpl_get_Underline
,
1293 OLEFontImpl_put_Underline
,
1294 OLEFontImpl_get_Strikethrough
,
1295 OLEFontImpl_put_Strikethrough
,
1296 OLEFontImpl_get_Weight
,
1297 OLEFontImpl_put_Weight
,
1298 OLEFontImpl_get_Charset
,
1299 OLEFontImpl_put_Charset
,
1300 OLEFontImpl_get_hFont
,
1302 OLEFontImpl_IsEqual
,
1303 OLEFontImpl_SetRatio
,
1304 OLEFontImpl_QueryTextMetrics
,
1305 OLEFontImpl_AddRefHfont
,
1306 OLEFontImpl_ReleaseHfont
,
1310 /************************************************************************
1311 * OLEFontImpl_IDispatch_QueryInterface (IUnknown)
1313 * See Windows documentation for more details on IUnknown methods.
1315 static HRESULT WINAPI
OLEFontImpl_IDispatch_QueryInterface(
1320 OLEFontImpl
*this = impl_from_IDispatch(iface
);
1322 return IFont_QueryInterface(&this->IFont_iface
, riid
, ppvoid
);
1325 /************************************************************************
1326 * OLEFontImpl_IDispatch_Release (IUnknown)
1328 * See Windows documentation for more details on IUnknown methods.
1330 static ULONG WINAPI
OLEFontImpl_IDispatch_Release(
1333 OLEFontImpl
*this = impl_from_IDispatch(iface
);
1335 return IFont_Release(&this->IFont_iface
);
1338 /************************************************************************
1339 * OLEFontImpl_IDispatch_AddRef (IUnknown)
1341 * See Windows documentation for more details on IUnknown methods.
1343 static ULONG WINAPI
OLEFontImpl_IDispatch_AddRef(
1346 OLEFontImpl
*this = impl_from_IDispatch(iface
);
1348 return IFont_AddRef(&this->IFont_iface
);
1351 /************************************************************************
1352 * OLEFontImpl_GetTypeInfoCount (IDispatch)
1354 * See Windows documentation for more details on IDispatch methods.
1356 static HRESULT WINAPI
OLEFontImpl_GetTypeInfoCount(
1358 unsigned int* pctinfo
)
1360 OLEFontImpl
*this = impl_from_IDispatch(iface
);
1361 TRACE("(%p)->(%p)\n", this, pctinfo
);
1367 /************************************************************************
1368 * OLEFontImpl_GetTypeInfo (IDispatch)
1370 * See Windows documentation for more details on IDispatch methods.
1372 static HRESULT WINAPI
OLEFontImpl_GetTypeInfo(
1376 ITypeInfo
** ppTInfo
)
1378 static const WCHAR stdole2tlb
[] = {'s','t','d','o','l','e','2','.','t','l','b',0};
1382 OLEFontImpl
*this = impl_from_IDispatch(iface
);
1383 TRACE("(%p, iTInfo=%d, lcid=%04x, %p)\n", this, iTInfo
, (int)lcid
, ppTInfo
);
1386 hres
= LoadTypeLib(stdole2tlb
, &tl
);
1388 ERR("Could not load the stdole2.tlb?\n");
1391 hres
= ITypeLib_GetTypeInfoOfGuid(tl
, &IID_IFontDisp
, ppTInfo
);
1392 ITypeLib_Release(tl
);
1394 FIXME("Did not IDispatch typeinfo from typelib, hres %x\n",hres
);
1399 /************************************************************************
1400 * OLEFontImpl_GetIDsOfNames (IDispatch)
1402 * See Windows documentation for more details on IDispatch methods.
1404 static HRESULT WINAPI
OLEFontImpl_GetIDsOfNames(
1407 LPOLESTR
* rgszNames
,
1415 OLEFontImpl
*this = impl_from_IDispatch(iface
);
1417 TRACE("(%p,%s,%p,cNames=%d,lcid=%04x,%p)\n", this, debugstr_guid(riid
),
1418 rgszNames
, cNames
, (int)lcid
, rgDispId
);
1422 return E_INVALIDARG
;
1426 /* retrieve type information */
1427 hres
= OLEFontImpl_GetTypeInfo(iface
, 0, lcid
, &pTInfo
);
1431 ERR("GetTypeInfo failed.\n");
1435 /* convert names to DISPIDs */
1436 hres
= DispGetIDsOfNames (pTInfo
, rgszNames
, cNames
, rgDispId
);
1437 ITypeInfo_Release(pTInfo
);
1443 /************************************************************************
1444 * OLEFontImpl_Invoke (IDispatch)
1446 * See Windows documentation for more details on IDispatch methods.
1448 * Note: Do not call _put_Xxx methods, since setting things here
1449 * should not call notify functions as I found out debugging the generic
1452 static HRESULT WINAPI
OLEFontImpl_Invoke(
1454 DISPID dispIdMember
,
1458 DISPPARAMS
* pDispParams
,
1459 VARIANT
* pVarResult
,
1460 EXCEPINFO
* pExepInfo
,
1463 OLEFontImpl
*this = impl_from_IDispatch(iface
);
1466 TRACE("%p->(%d,%s,0x%x,0x%x,%p,%p,%p,%p)\n", this, dispIdMember
,
1467 debugstr_guid(riid
), lcid
, wFlags
, pDispParams
, pVarResult
, pExepInfo
,
1470 /* validate parameters */
1472 if (!IsEqualIID(riid
, &IID_NULL
))
1474 ERR("riid was %s instead of IID_NULL\n", debugstr_guid(riid
));
1475 return DISP_E_UNKNOWNINTERFACE
;
1478 if (wFlags
& DISPATCH_PROPERTYGET
)
1482 ERR("null pVarResult not allowed when DISPATCH_PROPERTYGET specified\n");
1483 return DISP_E_PARAMNOTOPTIONAL
;
1486 else if (wFlags
& DISPATCH_PROPERTYPUT
)
1490 ERR("null pDispParams not allowed when DISPATCH_PROPERTYPUT specified\n");
1491 return DISP_E_PARAMNOTOPTIONAL
;
1493 if (pDispParams
->cArgs
!= 1)
1495 ERR("param count for DISPATCH_PROPERTYPUT was %d instead of 1\n", pDispParams
->cArgs
);
1496 return DISP_E_BADPARAMCOUNT
;
1501 ERR("one of DISPATCH_PROPERTYGET or DISPATCH_PROPERTYPUT must be specified\n");
1502 return DISP_E_MEMBERNOTFOUND
;
1505 switch (dispIdMember
) {
1506 case DISPID_FONT_NAME
:
1507 if (wFlags
& DISPATCH_PROPERTYGET
) {
1508 V_VT(pVarResult
) = VT_BSTR
;
1509 return IFont_get_Name(&this->IFont_iface
, &V_BSTR(pVarResult
));
1513 VariantInit(&vararg
);
1514 hr
= VariantChangeTypeEx(&vararg
, &pDispParams
->rgvarg
[0], lcid
, 0, VT_BSTR
);
1518 hr
= IFont_put_Name(&this->IFont_iface
, V_BSTR(&vararg
));
1520 VariantClear(&vararg
);
1524 case DISPID_FONT_BOLD
:
1525 if (wFlags
& DISPATCH_PROPERTYGET
) {
1527 hr
= IFont_get_Bold(&this->IFont_iface
, &value
);
1528 V_VT(pVarResult
) = VT_BOOL
;
1529 V_BOOL(pVarResult
) = value
? VARIANT_TRUE
: VARIANT_FALSE
;
1534 VariantInit(&vararg
);
1535 hr
= VariantChangeTypeEx(&vararg
, &pDispParams
->rgvarg
[0], lcid
, 0, VT_BOOL
);
1539 hr
= IFont_put_Bold(&this->IFont_iface
, V_BOOL(&vararg
));
1541 VariantClear(&vararg
);
1545 case DISPID_FONT_ITALIC
:
1546 if (wFlags
& DISPATCH_PROPERTYGET
) {
1548 hr
= IFont_get_Italic(&this->IFont_iface
, &value
);
1549 V_VT(pVarResult
) = VT_BOOL
;
1550 V_BOOL(pVarResult
) = value
? VARIANT_TRUE
: VARIANT_FALSE
;
1555 VariantInit(&vararg
);
1556 hr
= VariantChangeTypeEx(&vararg
, &pDispParams
->rgvarg
[0], lcid
, 0, VT_BOOL
);
1560 hr
= IFont_put_Italic(&this->IFont_iface
, V_BOOL(&vararg
));
1562 VariantClear(&vararg
);
1566 case DISPID_FONT_UNDER
:
1567 if (wFlags
& DISPATCH_PROPERTYGET
) {
1569 hr
= IFont_get_Underline(&this->IFont_iface
, &value
);
1570 V_VT(pVarResult
) = VT_BOOL
;
1571 V_BOOL(pVarResult
) = value
? VARIANT_TRUE
: VARIANT_FALSE
;
1576 VariantInit(&vararg
);
1577 hr
= VariantChangeTypeEx(&vararg
, &pDispParams
->rgvarg
[0], lcid
, 0, VT_BOOL
);
1581 hr
= IFont_put_Underline(&this->IFont_iface
, V_BOOL(&vararg
));
1583 VariantClear(&vararg
);
1587 case DISPID_FONT_STRIKE
:
1588 if (wFlags
& DISPATCH_PROPERTYGET
) {
1590 hr
= IFont_get_Strikethrough(&this->IFont_iface
, &value
);
1591 V_VT(pVarResult
) = VT_BOOL
;
1592 V_BOOL(pVarResult
) = value
? VARIANT_TRUE
: VARIANT_FALSE
;
1597 VariantInit(&vararg
);
1598 hr
= VariantChangeTypeEx(&vararg
, &pDispParams
->rgvarg
[0], lcid
, 0, VT_BOOL
);
1602 hr
= IFont_put_Strikethrough(&this->IFont_iface
, V_BOOL(&vararg
));
1604 VariantClear(&vararg
);
1608 case DISPID_FONT_SIZE
:
1609 if (wFlags
& DISPATCH_PROPERTYGET
) {
1610 V_VT(pVarResult
) = VT_CY
;
1611 return OLEFontImpl_get_Size(&this->IFont_iface
, &V_CY(pVarResult
));
1615 VariantInit(&vararg
);
1616 hr
= VariantChangeTypeEx(&vararg
, &pDispParams
->rgvarg
[0], lcid
, 0, VT_CY
);
1620 hr
= IFont_put_Size(&this->IFont_iface
, V_CY(&vararg
));
1622 VariantClear(&vararg
);
1626 case DISPID_FONT_WEIGHT
:
1627 if (wFlags
& DISPATCH_PROPERTYGET
) {
1628 V_VT(pVarResult
) = VT_I2
;
1629 return OLEFontImpl_get_Weight(&this->IFont_iface
, &V_I2(pVarResult
));
1633 VariantInit(&vararg
);
1634 hr
= VariantChangeTypeEx(&vararg
, &pDispParams
->rgvarg
[0], lcid
, 0, VT_I2
);
1638 hr
= IFont_put_Weight(&this->IFont_iface
, V_I2(&vararg
));
1640 VariantClear(&vararg
);
1644 case DISPID_FONT_CHARSET
:
1645 if (wFlags
& DISPATCH_PROPERTYGET
) {
1646 V_VT(pVarResult
) = VT_I2
;
1647 return OLEFontImpl_get_Charset(&this->IFont_iface
, &V_I2(pVarResult
));
1651 VariantInit(&vararg
);
1652 hr
= VariantChangeTypeEx(&vararg
, &pDispParams
->rgvarg
[0], lcid
, 0, VT_I2
);
1656 hr
= IFont_put_Charset(&this->IFont_iface
, V_I2(&vararg
));
1658 VariantClear(&vararg
);
1663 ERR("member not found for dispid 0x%x\n", dispIdMember
);
1664 return DISP_E_MEMBERNOTFOUND
;
1668 static const IDispatchVtbl OLEFontImpl_IDispatch_VTable
=
1670 OLEFontImpl_IDispatch_QueryInterface
,
1671 OLEFontImpl_IDispatch_AddRef
,
1672 OLEFontImpl_IDispatch_Release
,
1673 OLEFontImpl_GetTypeInfoCount
,
1674 OLEFontImpl_GetTypeInfo
,
1675 OLEFontImpl_GetIDsOfNames
,
1679 /************************************************************************
1680 * OLEFontImpl_IPersistStream_QueryInterface (IUnknown)
1682 * See Windows documentation for more details on IUnknown methods.
1684 static HRESULT WINAPI
OLEFontImpl_IPersistStream_QueryInterface(
1685 IPersistStream
* iface
,
1689 OLEFontImpl
*this = impl_from_IPersistStream(iface
);
1691 return IFont_QueryInterface(&this->IFont_iface
, riid
, ppvoid
);
1694 /************************************************************************
1695 * OLEFontImpl_IPersistStream_Release (IUnknown)
1697 * See Windows documentation for more details on IUnknown methods.
1699 static ULONG WINAPI
OLEFontImpl_IPersistStream_Release(
1700 IPersistStream
* iface
)
1702 OLEFontImpl
*this = impl_from_IPersistStream(iface
);
1704 return IFont_Release(&this->IFont_iface
);
1707 /************************************************************************
1708 * OLEFontImpl_IPersistStream_AddRef (IUnknown)
1710 * See Windows documentation for more details on IUnknown methods.
1712 static ULONG WINAPI
OLEFontImpl_IPersistStream_AddRef(
1713 IPersistStream
* iface
)
1715 OLEFontImpl
*this = impl_from_IPersistStream(iface
);
1717 return IFont_AddRef(&this->IFont_iface
);
1720 /************************************************************************
1721 * OLEFontImpl_GetClassID (IPersistStream)
1723 * See Windows documentation for more details on IPersistStream methods.
1725 static HRESULT WINAPI
OLEFontImpl_GetClassID(
1726 IPersistStream
* iface
,
1729 TRACE("(%p,%p)\n",iface
,pClassID
);
1733 *pClassID
= CLSID_StdFont
;
1738 /************************************************************************
1739 * OLEFontImpl_IsDirty (IPersistStream)
1741 * See Windows documentation for more details on IPersistStream methods.
1743 static HRESULT WINAPI
OLEFontImpl_IsDirty(
1744 IPersistStream
* iface
)
1746 TRACE("(%p)\n",iface
);
1750 /************************************************************************
1751 * OLEFontImpl_Load (IPersistStream)
1753 * See Windows documentation for more details on IPersistStream methods.
1755 * This is the format of the standard font serialization as far as I
1758 * Offset Type Value Comment
1759 * 0x0000 Byte Unknown Probably a version number, contains 0x01
1760 * 0x0001 Short Charset Charset value from the FONTDESC structure
1761 * 0x0003 Byte Attributes Flags defined as follows:
1763 * 00000100 - Underline
1764 * 00001000 - Strikethrough
1765 * 0x0004 Short Weight Weight value from FONTDESC structure
1766 * 0x0006 DWORD size "Low" portion of the cySize member of the FONTDESC
1768 * 0x000A Byte name length Length of the font name string (no null character)
1769 * 0x000B String name Name of the font (ASCII, no nul character)
1771 static HRESULT WINAPI
OLEFontImpl_Load(
1772 IPersistStream
* iface
,
1773 IStream
* pLoadStream
)
1775 char readBuffer
[0x100];
1782 OLEFontImpl
*this = impl_from_IPersistStream(iface
);
1785 * Read the version byte
1787 IStream_Read(pLoadStream
, &bVersion
, 1, &cbRead
);
1796 IStream_Read(pLoadStream
, &this->description
.sCharset
, 2, &cbRead
);
1804 IStream_Read(pLoadStream
, &bAttributes
, 1, &cbRead
);
1809 this->description
.fItalic
= (bAttributes
& FONTPERSIST_ITALIC
) != 0;
1810 this->description
.fStrikethrough
= (bAttributes
& FONTPERSIST_STRIKETHROUGH
) != 0;
1811 this->description
.fUnderline
= (bAttributes
& FONTPERSIST_UNDERLINE
) != 0;
1816 IStream_Read(pLoadStream
, &this->description
.sWeight
, 2, &cbRead
);
1824 IStream_Read(pLoadStream
, &this->description
.cySize
.s
.Lo
, 4, &cbRead
);
1829 this->description
.cySize
.s
.Hi
= 0;
1834 IStream_Read(pLoadStream
, &bStringSize
, 1, &cbRead
);
1839 IStream_Read(pLoadStream
, readBuffer
, bStringSize
, &cbRead
);
1841 if (cbRead
!=bStringSize
)
1844 HeapFree(GetProcessHeap(), 0, this->description
.lpstrName
);
1846 len
= MultiByteToWideChar( CP_ACP
, 0, readBuffer
, bStringSize
, NULL
, 0 );
1847 this->description
.lpstrName
= HeapAlloc( GetProcessHeap(), 0, (len
+1) * sizeof(WCHAR
) );
1848 MultiByteToWideChar( CP_ACP
, 0, readBuffer
, bStringSize
, this->description
.lpstrName
, len
);
1849 this->description
.lpstrName
[len
] = 0;
1851 /* Ensure use of this font causes a new one to be created */
1852 dec_int_ref(this->gdiFont
);
1859 /************************************************************************
1860 * OLEFontImpl_Save (IPersistStream)
1862 * See Windows documentation for more details on IPersistStream methods.
1864 static HRESULT WINAPI
OLEFontImpl_Save(
1865 IPersistStream
* iface
,
1866 IStream
* pOutStream
,
1869 char* writeBuffer
= NULL
;
1871 BYTE bVersion
= 0x01;
1875 OLEFontImpl
*this = impl_from_IPersistStream(iface
);
1878 * Read the version byte
1880 IStream_Write(pOutStream
, &bVersion
, 1, &cbWritten
);
1888 IStream_Write(pOutStream
, &this->description
.sCharset
, 2, &cbWritten
);
1898 if (this->description
.fItalic
)
1899 bAttributes
|= FONTPERSIST_ITALIC
;
1901 if (this->description
.fStrikethrough
)
1902 bAttributes
|= FONTPERSIST_STRIKETHROUGH
;
1904 if (this->description
.fUnderline
)
1905 bAttributes
|= FONTPERSIST_UNDERLINE
;
1907 IStream_Write(pOutStream
, &bAttributes
, 1, &cbWritten
);
1915 IStream_Write(pOutStream
, &this->description
.sWeight
, 2, &cbWritten
);
1923 IStream_Write(pOutStream
, &this->description
.cySize
.s
.Lo
, 4, &cbWritten
);
1931 if (this->description
.lpstrName
!=0)
1932 bStringSize
= WideCharToMultiByte( CP_ACP
, 0, this->description
.lpstrName
,
1933 strlenW(this->description
.lpstrName
), NULL
, 0, NULL
, NULL
);
1937 IStream_Write(pOutStream
, &bStringSize
, 1, &cbWritten
);
1944 if (!(writeBuffer
= HeapAlloc( GetProcessHeap(), 0, bStringSize
))) return E_OUTOFMEMORY
;
1945 WideCharToMultiByte( CP_ACP
, 0, this->description
.lpstrName
,
1946 strlenW(this->description
.lpstrName
),
1947 writeBuffer
, bStringSize
, NULL
, NULL
);
1949 IStream_Write(pOutStream
, writeBuffer
, bStringSize
, &cbWritten
);
1950 HeapFree(GetProcessHeap(), 0, writeBuffer
);
1952 if (cbWritten
!=bStringSize
)
1959 /************************************************************************
1960 * OLEFontImpl_GetSizeMax (IPersistStream)
1962 * See Windows documentation for more details on IPersistStream methods.
1964 static HRESULT WINAPI
OLEFontImpl_GetSizeMax(
1965 IPersistStream
* iface
,
1966 ULARGE_INTEGER
* pcbSize
)
1968 OLEFontImpl
*this = impl_from_IPersistStream(iface
);
1973 pcbSize
->u
.HighPart
= 0;
1974 pcbSize
->u
.LowPart
= 0;
1976 pcbSize
->u
.LowPart
+= sizeof(BYTE
); /* Version */
1977 pcbSize
->u
.LowPart
+= sizeof(WORD
); /* Lang code */
1978 pcbSize
->u
.LowPart
+= sizeof(BYTE
); /* Flags */
1979 pcbSize
->u
.LowPart
+= sizeof(WORD
); /* Weight */
1980 pcbSize
->u
.LowPart
+= sizeof(DWORD
); /* Size */
1981 pcbSize
->u
.LowPart
+= sizeof(BYTE
); /* StrLength */
1983 if (this->description
.lpstrName
!=0)
1984 pcbSize
->u
.LowPart
+= WideCharToMultiByte( CP_ACP
, 0, this->description
.lpstrName
,
1985 strlenW(this->description
.lpstrName
),
1986 NULL
, 0, NULL
, NULL
);
1991 static const IPersistStreamVtbl OLEFontImpl_IPersistStream_VTable
=
1993 OLEFontImpl_IPersistStream_QueryInterface
,
1994 OLEFontImpl_IPersistStream_AddRef
,
1995 OLEFontImpl_IPersistStream_Release
,
1996 OLEFontImpl_GetClassID
,
1997 OLEFontImpl_IsDirty
,
2000 OLEFontImpl_GetSizeMax
2003 /************************************************************************
2004 * OLEFontImpl_IConnectionPointContainer_QueryInterface (IUnknown)
2006 * See Windows documentation for more details on IUnknown methods.
2008 static HRESULT WINAPI
OLEFontImpl_IConnectionPointContainer_QueryInterface(
2009 IConnectionPointContainer
* iface
,
2013 OLEFontImpl
*this = impl_from_IConnectionPointContainer(iface
);
2015 return IFont_QueryInterface(&this->IFont_iface
, riid
, ppvoid
);
2018 /************************************************************************
2019 * OLEFontImpl_IConnectionPointContainer_Release (IUnknown)
2021 * See Windows documentation for more details on IUnknown methods.
2023 static ULONG WINAPI
OLEFontImpl_IConnectionPointContainer_Release(
2024 IConnectionPointContainer
* iface
)
2026 OLEFontImpl
*this = impl_from_IConnectionPointContainer(iface
);
2028 return IFont_Release(&this->IFont_iface
);
2031 /************************************************************************
2032 * OLEFontImpl_IConnectionPointContainer_AddRef (IUnknown)
2034 * See Windows documentation for more details on IUnknown methods.
2036 static ULONG WINAPI
OLEFontImpl_IConnectionPointContainer_AddRef(
2037 IConnectionPointContainer
* iface
)
2039 OLEFontImpl
*this = impl_from_IConnectionPointContainer(iface
);
2041 return IFont_AddRef(&this->IFont_iface
);
2044 /************************************************************************
2045 * OLEFontImpl_EnumConnectionPoints (IConnectionPointContainer)
2047 * See Windows documentation for more details on IConnectionPointContainer
2050 static HRESULT WINAPI
OLEFontImpl_EnumConnectionPoints(
2051 IConnectionPointContainer
* iface
,
2052 IEnumConnectionPoints
**ppEnum
)
2054 OLEFontImpl
*this = impl_from_IConnectionPointContainer(iface
);
2056 FIXME("(%p)->(%p): stub\n", this, ppEnum
);
2060 /************************************************************************
2061 * OLEFontImpl_FindConnectionPoint (IConnectionPointContainer)
2063 * See Windows documentation for more details on IConnectionPointContainer
2066 static HRESULT WINAPI
OLEFontImpl_FindConnectionPoint(
2067 IConnectionPointContainer
* iface
,
2069 IConnectionPoint
**ppCp
)
2071 OLEFontImpl
*this = impl_from_IConnectionPointContainer(iface
);
2072 TRACE("(%p)->(%s, %p)\n", this, debugstr_guid(riid
), ppCp
);
2074 if(IsEqualIID(riid
, &IID_IPropertyNotifySink
)) {
2075 return IConnectionPoint_QueryInterface(this->pPropertyNotifyCP
,
2076 &IID_IConnectionPoint
,
2078 } else if(IsEqualIID(riid
, &IID_IFontEventsDisp
)) {
2079 return IConnectionPoint_QueryInterface(this->pFontEventsCP
,
2080 &IID_IConnectionPoint
,
2083 FIXME("no connection point for %s\n", debugstr_guid(riid
));
2084 return CONNECT_E_NOCONNECTION
;
2088 static const IConnectionPointContainerVtbl
2089 OLEFontImpl_IConnectionPointContainer_VTable
=
2091 OLEFontImpl_IConnectionPointContainer_QueryInterface
,
2092 OLEFontImpl_IConnectionPointContainer_AddRef
,
2093 OLEFontImpl_IConnectionPointContainer_Release
,
2094 OLEFontImpl_EnumConnectionPoints
,
2095 OLEFontImpl_FindConnectionPoint
2098 /************************************************************************
2099 * OLEFontImpl implementation of IPersistPropertyBag.
2101 static HRESULT WINAPI
OLEFontImpl_IPersistPropertyBag_QueryInterface(
2102 IPersistPropertyBag
*iface
, REFIID riid
, LPVOID
*ppvObj
2104 OLEFontImpl
*this = impl_from_IPersistPropertyBag(iface
);
2105 return IFont_QueryInterface(&this->IFont_iface
,riid
,ppvObj
);
2108 static ULONG WINAPI
OLEFontImpl_IPersistPropertyBag_AddRef(
2109 IPersistPropertyBag
*iface
2111 OLEFontImpl
*this = impl_from_IPersistPropertyBag(iface
);
2112 return IFont_AddRef(&this->IFont_iface
);
2115 static ULONG WINAPI
OLEFontImpl_IPersistPropertyBag_Release(
2116 IPersistPropertyBag
*iface
2118 OLEFontImpl
*this = impl_from_IPersistPropertyBag(iface
);
2119 return IFont_Release(&this->IFont_iface
);
2122 static HRESULT WINAPI
OLEFontImpl_IPersistPropertyBag_GetClassID(
2123 IPersistPropertyBag
*iface
, CLSID
*classid
2125 FIXME("(%p,%p), stub!\n", iface
, classid
);
2129 static HRESULT WINAPI
OLEFontImpl_IPersistPropertyBag_InitNew(
2130 IPersistPropertyBag
*iface
2132 FIXME("(%p), stub!\n", iface
);
2136 static HRESULT WINAPI
OLEFontImpl_IPersistPropertyBag_Load(
2137 IPersistPropertyBag
*iface
, IPropertyBag
* pPropBag
, IErrorLog
* pErrorLog
2139 /* (from Visual Basic 6 property bag)
2140 Name = "MS Sans Serif"
2144 Underline = 0 'False
2146 Strikethrough = 0 'False
2148 static const WCHAR sAttrName
[] = {'N','a','m','e',0};
2149 static const WCHAR sAttrSize
[] = {'S','i','z','e',0};
2150 static const WCHAR sAttrCharset
[] = {'C','h','a','r','s','e','t',0};
2151 static const WCHAR sAttrWeight
[] = {'W','e','i','g','h','t',0};
2152 static const WCHAR sAttrUnderline
[] = {'U','n','d','e','r','l','i','n','e',0};
2153 static const WCHAR sAttrItalic
[] = {'I','t','a','l','i','c',0};
2154 static const WCHAR sAttrStrikethrough
[] = {'S','t','r','i','k','e','t','h','r','o','u','g','h',0};
2155 OLEFontImpl
*this = impl_from_IPersistPropertyBag(iface
);
2159 VariantInit(&value
);
2161 iRes
= IPropertyBag_Read(pPropBag
, sAttrName
, &value
, pErrorLog
);
2164 iRes
= VariantChangeType(&value
, &value
, 0, VT_BSTR
);
2166 iRes
= IFont_put_Name(&this->IFont_iface
, V_BSTR(&value
));
2168 else if (iRes
== E_INVALIDARG
)
2171 VariantClear(&value
);
2174 iRes
= IPropertyBag_Read(pPropBag
, sAttrSize
, &value
, pErrorLog
);
2177 iRes
= VariantChangeType(&value
, &value
, 0, VT_CY
);
2179 iRes
= IFont_put_Size(&this->IFont_iface
, V_CY(&value
));
2181 else if (iRes
== E_INVALIDARG
)
2184 VariantClear(&value
);
2188 iRes
= IPropertyBag_Read(pPropBag
, sAttrCharset
, &value
, pErrorLog
);
2191 iRes
= VariantChangeType(&value
, &value
, 0, VT_I2
);
2193 iRes
= IFont_put_Charset(&this->IFont_iface
, V_I2(&value
));
2195 else if (iRes
== E_INVALIDARG
)
2198 VariantClear(&value
);
2202 iRes
= IPropertyBag_Read(pPropBag
, sAttrWeight
, &value
, pErrorLog
);
2205 iRes
= VariantChangeType(&value
, &value
, 0, VT_I2
);
2207 iRes
= IFont_put_Weight(&this->IFont_iface
, V_I2(&value
));
2209 else if (iRes
== E_INVALIDARG
)
2212 VariantClear(&value
);
2216 iRes
= IPropertyBag_Read(pPropBag
, sAttrUnderline
, &value
, pErrorLog
);
2219 iRes
= VariantChangeType(&value
, &value
, 0, VT_BOOL
);
2221 iRes
= IFont_put_Underline(&this->IFont_iface
, V_BOOL(&value
));
2223 else if (iRes
== E_INVALIDARG
)
2226 VariantClear(&value
);
2230 iRes
= IPropertyBag_Read(pPropBag
, sAttrItalic
, &value
, pErrorLog
);
2233 iRes
= VariantChangeType(&value
, &value
, 0, VT_BOOL
);
2235 iRes
= IFont_put_Italic(&this->IFont_iface
, V_BOOL(&value
));
2237 else if (iRes
== E_INVALIDARG
)
2240 VariantClear(&value
);
2244 iRes
= IPropertyBag_Read(pPropBag
, sAttrStrikethrough
, &value
, pErrorLog
);
2247 iRes
= VariantChangeType(&value
, &value
, 0, VT_BOOL
);
2249 IFont_put_Strikethrough(&this->IFont_iface
, V_BOOL(&value
));
2251 else if (iRes
== E_INVALIDARG
)
2254 VariantClear(&value
);
2258 WARN("-- 0x%08x\n", iRes
);
2262 static HRESULT WINAPI
OLEFontImpl_IPersistPropertyBag_Save(
2263 IPersistPropertyBag
*iface
, IPropertyBag
* pPropBag
, BOOL fClearDirty
,
2264 BOOL fSaveAllProperties
2266 FIXME("(%p,%p,%d,%d), stub!\n", iface
, pPropBag
, fClearDirty
, fSaveAllProperties
);
2270 static const IPersistPropertyBagVtbl OLEFontImpl_IPersistPropertyBag_VTable
=
2272 OLEFontImpl_IPersistPropertyBag_QueryInterface
,
2273 OLEFontImpl_IPersistPropertyBag_AddRef
,
2274 OLEFontImpl_IPersistPropertyBag_Release
,
2276 OLEFontImpl_IPersistPropertyBag_GetClassID
,
2277 OLEFontImpl_IPersistPropertyBag_InitNew
,
2278 OLEFontImpl_IPersistPropertyBag_Load
,
2279 OLEFontImpl_IPersistPropertyBag_Save
2282 /************************************************************************
2283 * OLEFontImpl implementation of IPersistStreamInit.
2285 static HRESULT WINAPI
OLEFontImpl_IPersistStreamInit_QueryInterface(
2286 IPersistStreamInit
*iface
, REFIID riid
, LPVOID
*ppvObj
2288 OLEFontImpl
*this = impl_from_IPersistStreamInit(iface
);
2289 return IFont_QueryInterface(&this->IFont_iface
,riid
,ppvObj
);
2292 static ULONG WINAPI
OLEFontImpl_IPersistStreamInit_AddRef(
2293 IPersistStreamInit
*iface
2295 OLEFontImpl
*this = impl_from_IPersistStreamInit(iface
);
2296 return IFont_AddRef(&this->IFont_iface
);
2299 static ULONG WINAPI
OLEFontImpl_IPersistStreamInit_Release(
2300 IPersistStreamInit
*iface
2302 OLEFontImpl
*this = impl_from_IPersistStreamInit(iface
);
2303 return IFont_Release(&this->IFont_iface
);
2306 static HRESULT WINAPI
OLEFontImpl_IPersistStreamInit_GetClassID(
2307 IPersistStreamInit
*iface
, CLSID
*classid
2309 FIXME("(%p,%p), stub!\n", iface
, classid
);
2313 static HRESULT WINAPI
OLEFontImpl_IPersistStreamInit_IsDirty(
2314 IPersistStreamInit
*iface
2316 FIXME("(%p), stub!\n", iface
);
2320 static HRESULT WINAPI
OLEFontImpl_IPersistStreamInit_Load(
2321 IPersistStreamInit
*iface
, LPSTREAM pStm
2323 FIXME("(%p,%p), stub!\n", iface
, pStm
);
2327 static HRESULT WINAPI
OLEFontImpl_IPersistStreamInit_Save(
2328 IPersistStreamInit
*iface
, LPSTREAM pStm
, BOOL fClearDirty
2330 FIXME("(%p,%p,%d), stub!\n", iface
, pStm
, fClearDirty
);
2334 static HRESULT WINAPI
OLEFontImpl_IPersistStreamInit_GetSizeMax(
2335 IPersistStreamInit
*iface
, ULARGE_INTEGER
*pcbSize
2337 FIXME("(%p,%p), stub!\n", iface
, pcbSize
);
2341 static HRESULT WINAPI
OLEFontImpl_IPersistStreamInit_InitNew(
2342 IPersistStreamInit
*iface
2344 FIXME("(%p), stub!\n", iface
);
2348 static const IPersistStreamInitVtbl OLEFontImpl_IPersistStreamInit_VTable
=
2350 OLEFontImpl_IPersistStreamInit_QueryInterface
,
2351 OLEFontImpl_IPersistStreamInit_AddRef
,
2352 OLEFontImpl_IPersistStreamInit_Release
,
2354 OLEFontImpl_IPersistStreamInit_GetClassID
,
2355 OLEFontImpl_IPersistStreamInit_IsDirty
,
2356 OLEFontImpl_IPersistStreamInit_Load
,
2357 OLEFontImpl_IPersistStreamInit_Save
,
2358 OLEFontImpl_IPersistStreamInit_GetSizeMax
,
2359 OLEFontImpl_IPersistStreamInit_InitNew
2362 /************************************************************************
2363 * OLEFontImpl_Construct
2365 * This method will construct a new instance of the OLEFontImpl
2368 * The caller of this method must release the object when it's
2371 static OLEFontImpl
* OLEFontImpl_Construct(const FONTDESC
*fontDesc
)
2373 OLEFontImpl
* newObject
= 0;
2376 * Allocate space for the object.
2378 newObject
= HeapAlloc(GetProcessHeap(), 0, sizeof(OLEFontImpl
));
2384 * Initialize the virtual function table.
2386 newObject
->IFont_iface
.lpVtbl
= &OLEFontImpl_VTable
;
2387 newObject
->IDispatch_iface
.lpVtbl
= &OLEFontImpl_IDispatch_VTable
;
2388 newObject
->IPersistStream_iface
.lpVtbl
= &OLEFontImpl_IPersistStream_VTable
;
2389 newObject
->IConnectionPointContainer_iface
.lpVtbl
= &OLEFontImpl_IConnectionPointContainer_VTable
;
2390 newObject
->IPersistPropertyBag_iface
.lpVtbl
= &OLEFontImpl_IPersistPropertyBag_VTable
;
2391 newObject
->IPersistStreamInit_iface
.lpVtbl
= &OLEFontImpl_IPersistStreamInit_VTable
;
2394 * Start with one reference count. The caller of this function
2395 * must release the interface pointer when it is done.
2400 * Copy the description of the font in the object.
2402 assert(fontDesc
->cbSizeofstruct
>= sizeof(FONTDESC
));
2404 newObject
->description
.cbSizeofstruct
= sizeof(FONTDESC
);
2405 newObject
->description
.lpstrName
= HeapAlloc(GetProcessHeap(),
2407 (lstrlenW(fontDesc
->lpstrName
)+1) * sizeof(WCHAR
));
2408 strcpyW(newObject
->description
.lpstrName
, fontDesc
->lpstrName
);
2409 newObject
->description
.cySize
= fontDesc
->cySize
;
2410 newObject
->description
.sWeight
= fontDesc
->sWeight
;
2411 newObject
->description
.sCharset
= fontDesc
->sCharset
;
2412 newObject
->description
.fItalic
= fontDesc
->fItalic
;
2413 newObject
->description
.fUnderline
= fontDesc
->fUnderline
;
2414 newObject
->description
.fStrikethrough
= fontDesc
->fStrikethrough
;
2417 * Initializing all the other members.
2419 newObject
->gdiFont
= 0;
2420 newObject
->dirty
= TRUE
;
2421 newObject
->cyLogical
= GetDeviceCaps(get_dc(), LOGPIXELSY
);
2422 newObject
->cyHimetric
= 2540L;
2423 newObject
->pPropertyNotifyCP
= NULL
;
2424 newObject
->pFontEventsCP
= NULL
;
2426 CreateConnectionPoint((IUnknown
*)newObject
, &IID_IPropertyNotifySink
, &newObject
->pPropertyNotifyCP
);
2427 CreateConnectionPoint((IUnknown
*)newObject
, &IID_IFontEventsDisp
, &newObject
->pFontEventsCP
);
2429 if (!newObject
->pPropertyNotifyCP
|| !newObject
->pFontEventsCP
)
2431 OLEFontImpl_Destroy(newObject
);
2435 InterlockedIncrement(&ifont_cnt
);
2437 TRACE("returning %p\n", newObject
);
2441 /************************************************************************
2442 * OLEFontImpl_Destroy
2444 * This method is called by the Release method when the reference
2445 * count goes down to 0. It will free all resources used by
2448 static void OLEFontImpl_Destroy(OLEFontImpl
* fontDesc
)
2450 TRACE("(%p)\n", fontDesc
);
2452 HeapFree(GetProcessHeap(), 0, fontDesc
->description
.lpstrName
);
2454 if (fontDesc
->pPropertyNotifyCP
)
2455 IConnectionPoint_Release(fontDesc
->pPropertyNotifyCP
);
2456 if (fontDesc
->pFontEventsCP
)
2457 IConnectionPoint_Release(fontDesc
->pFontEventsCP
);
2459 HeapFree(GetProcessHeap(), 0, fontDesc
);
2462 /*******************************************************************************
2463 * StdFont ClassFactory
2467 /* IUnknown fields */
2468 IClassFactory IClassFactory_iface
;
2470 } IClassFactoryImpl
;
2472 static inline IClassFactoryImpl
*impl_from_IClassFactory(IClassFactory
*iface
)
2474 return CONTAINING_RECORD(iface
, IClassFactoryImpl
, IClassFactory_iface
);
2477 static HRESULT WINAPI
2478 SFCF_QueryInterface(LPCLASSFACTORY iface
,REFIID riid
,LPVOID
*ppobj
) {
2479 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
2481 FIXME("(%p)->(%s,%p),stub!\n",This
,debugstr_guid(riid
),ppobj
);
2482 return E_NOINTERFACE
;
2486 SFCF_AddRef(LPCLASSFACTORY iface
) {
2487 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
2488 return InterlockedIncrement(&This
->ref
);
2491 static ULONG WINAPI
SFCF_Release(LPCLASSFACTORY iface
) {
2492 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
2493 /* static class, won't be freed */
2494 return InterlockedDecrement(&This
->ref
);
2497 static HRESULT WINAPI
SFCF_CreateInstance(
2498 LPCLASSFACTORY iface
,LPUNKNOWN pOuter
,REFIID riid
,LPVOID
*ppobj
2500 return OleCreateFontIndirect(NULL
,riid
,ppobj
);
2504 static HRESULT WINAPI
SFCF_LockServer(LPCLASSFACTORY iface
,BOOL dolock
) {
2505 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
2506 FIXME("(%p)->(%d),stub!\n",This
,dolock
);
2510 static const IClassFactoryVtbl SFCF_Vtbl
= {
2511 SFCF_QueryInterface
,
2514 SFCF_CreateInstance
,
2517 static IClassFactoryImpl STDFONT_CF
= {{&SFCF_Vtbl
}, 1 };
2519 void _get_STDFONT_CF(LPVOID
*ppv
) { *ppv
= &STDFONT_CF
; }