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.
254 const IFontVtbl
* lpVtbl
;
255 const IDispatchVtbl
* lpvtblIDispatch
;
256 const IPersistStreamVtbl
* lpvtblIPersistStream
;
257 const IConnectionPointContainerVtbl
* lpvtblIConnectionPointContainer
;
258 const IPersistPropertyBagVtbl
* lpvtblIPersistPropertyBag
;
259 const IPersistStreamInitVtbl
* lpvtblIPersistStreamInit
;
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.
281 IConnectionPoint
*pPropertyNotifyCP
;
282 IConnectionPoint
*pFontEventsCP
;
286 * Here, I define utility macros to help with the casting of the
288 * There is a version to accommodate all of the VTables implemented
292 static inline OLEFontImpl
*impl_from_IDispatch( IDispatch
*iface
)
294 return (OLEFontImpl
*)((char*)iface
- FIELD_OFFSET(OLEFontImpl
, lpvtblIDispatch
));
297 static inline OLEFontImpl
*impl_from_IPersistStream( IPersistStream
*iface
)
299 return (OLEFontImpl
*)((char*)iface
- FIELD_OFFSET(OLEFontImpl
, lpvtblIPersistStream
));
302 static inline OLEFontImpl
*impl_from_IConnectionPointContainer( IConnectionPointContainer
*iface
)
304 return (OLEFontImpl
*)((char*)iface
- FIELD_OFFSET(OLEFontImpl
, lpvtblIConnectionPointContainer
));
307 static inline OLEFontImpl
*impl_from_IPersistPropertyBag( IPersistPropertyBag
*iface
)
309 return (OLEFontImpl
*)((char*)iface
- FIELD_OFFSET(OLEFontImpl
, lpvtblIPersistPropertyBag
));
312 static inline OLEFontImpl
*impl_from_IPersistStreamInit( IPersistStreamInit
*iface
)
314 return (OLEFontImpl
*)((char*)iface
- FIELD_OFFSET(OLEFontImpl
, lpvtblIPersistStreamInit
));
318 /***********************************************************************
319 * Prototypes for the implementation functions for the IFont
322 static OLEFontImpl
* OLEFontImpl_Construct(const FONTDESC
*fontDesc
);
323 static void OLEFontImpl_Destroy(OLEFontImpl
* fontDesc
);
324 static ULONG WINAPI
OLEFontImpl_AddRef(IFont
* iface
);
326 /******************************************************************************
327 * OleCreateFontIndirect [OLEAUT32.420]
329 HRESULT WINAPI
OleCreateFontIndirect(
330 LPFONTDESC lpFontDesc
,
334 OLEFontImpl
* newFont
= 0;
337 TRACE("(%p, %s, %p)\n", lpFontDesc
, debugstr_guid(riid
), ppvObj
);
349 static WCHAR fname
[] = { 'S','y','s','t','e','m',0 };
351 fd
.cbSizeofstruct
= sizeof(fd
);
352 fd
.lpstrName
= fname
;
353 fd
.cySize
.s
.Lo
= 80000;
359 fd
.fStrikethrough
= 0;
364 * Try to construct a new instance of the class.
366 newFont
= OLEFontImpl_Construct(lpFontDesc
);
369 return E_OUTOFMEMORY
;
372 * Make sure it supports the interface required by the caller.
374 hr
= IFont_QueryInterface((IFont
*)newFont
, riid
, ppvObj
);
377 * Release the reference obtained in the constructor. If
378 * the QueryInterface was unsuccessful, it will free the class.
380 IFont_Release((IFont
*)newFont
);
386 /***********************************************************************
387 * Implementation of the OLEFontImpl class.
390 /***********************************************************************
391 * OLEFont_SendNotify (internal)
393 * Sends notification messages of changed properties to any interested
396 static void OLEFont_SendNotify(OLEFontImpl
* this, DISPID dispID
)
398 static const WCHAR wszName
[] = {'N','a','m','e',0};
399 static const WCHAR wszSize
[] = {'S','i','z','e',0};
400 static const WCHAR wszBold
[] = {'B','o','l','d',0};
401 static const WCHAR wszItalic
[] = {'I','t','a','l','i','c',0};
402 static const WCHAR wszUnder
[] = {'U','n','d','e','r','l','i','n','e',0};
403 static const WCHAR wszStrike
[] = {'S','t','r','i','k','e','t','h','r','o','u','g','h',0};
404 static const WCHAR wszWeight
[] = {'W','e','i','g','h','t',0};
405 static const WCHAR wszCharset
[] = {'C','h','a','r','s','s','e','t',0};
406 static const LPCWSTR dispid_mapping
[] =
419 IEnumConnections
*pEnum
;
425 hres
= IConnectionPoint_EnumConnections(this->pPropertyNotifyCP
, &pEnum
);
428 while(IEnumConnections_Next(pEnum
, 1, &CD
, NULL
) == S_OK
) {
429 IPropertyNotifySink
*sink
;
431 IUnknown_QueryInterface(CD
.pUnk
, &IID_IPropertyNotifySink
, (LPVOID
)&sink
);
432 IPropertyNotifySink_OnChanged(sink
, dispID
);
433 IPropertyNotifySink_Release(sink
);
434 IUnknown_Release(CD
.pUnk
);
436 IEnumConnections_Release(pEnum
);
439 hres
= IConnectionPoint_EnumConnections(this->pFontEventsCP
, &pEnum
);
442 DISPPARAMS dispparams
;
445 VariantInit(&vararg
);
446 V_VT(&vararg
) = VT_BSTR
;
447 V_BSTR(&vararg
) = SysAllocString(dispid_mapping
[dispID
]);
449 dispparams
.cArgs
= 1;
450 dispparams
.cNamedArgs
= 0;
451 dispparams
.rgdispidNamedArgs
= NULL
;
452 dispparams
.rgvarg
= &vararg
;
454 while(IEnumConnections_Next(pEnum
, 1, &CD
, NULL
) == S_OK
) {
455 IFontEventsDisp
*disp
;
457 IUnknown_QueryInterface(CD
.pUnk
, &IID_IFontEventsDisp
, (LPVOID
)&disp
);
458 IDispatch_Invoke(disp
, DISPID_FONT_CHANGED
, &IID_NULL
,
459 LOCALE_NEUTRAL
, INVOKE_FUNC
, &dispparams
, NULL
,
462 IDispatch_Release(disp
);
463 IUnknown_Release(CD
.pUnk
);
465 VariantClear(&vararg
);
466 IEnumConnections_Release(pEnum
);
470 /************************************************************************
471 * OLEFontImpl_QueryInterface (IUnknown)
473 * See Windows documentation for more details on IUnknown methods.
475 static HRESULT WINAPI
OLEFontImpl_QueryInterface(
480 OLEFontImpl
*this = (OLEFontImpl
*)iface
;
481 TRACE("(%p)->(%s, %p)\n", this, debugstr_guid(riid
), ppvObject
);
486 * Compare the riid with the interface IDs implemented by this object.
488 if (IsEqualGUID(&IID_IUnknown
, riid
))
490 if (IsEqualGUID(&IID_IFont
, riid
))
492 if (IsEqualGUID(&IID_IDispatch
, riid
))
493 *ppvObject
= &this->lpvtblIDispatch
;
494 if (IsEqualGUID(&IID_IFontDisp
, riid
))
495 *ppvObject
= &this->lpvtblIDispatch
;
496 if (IsEqualIID(&IID_IPersist
, riid
) || IsEqualGUID(&IID_IPersistStream
, riid
))
497 *ppvObject
= &this->lpvtblIPersistStream
;
498 if (IsEqualGUID(&IID_IConnectionPointContainer
, riid
))
499 *ppvObject
= &this->lpvtblIConnectionPointContainer
;
500 if (IsEqualGUID(&IID_IPersistPropertyBag
, riid
))
501 *ppvObject
= &this->lpvtblIPersistPropertyBag
;
502 if (IsEqualGUID(&IID_IPersistStreamInit
, riid
))
503 *ppvObject
= &this->lpvtblIPersistStreamInit
;
506 * Check that we obtained an interface.
510 FIXME("() : asking for unsupported interface %s\n",debugstr_guid(riid
));
511 return E_NOINTERFACE
;
513 OLEFontImpl_AddRef((IFont
*)this);
517 /************************************************************************
518 * OLEFontImpl_AddRef (IUnknown)
520 * See Windows documentation for more details on IUnknown methods.
522 static ULONG WINAPI
OLEFontImpl_AddRef(
525 OLEFontImpl
*this = (OLEFontImpl
*)iface
;
526 TRACE("(%p)->(ref=%d)\n", this, this->ref
);
527 return InterlockedIncrement(&this->ref
);
530 /************************************************************************
531 * OLEFontImpl_Release (IUnknown)
533 * See Windows documentation for more details on IUnknown methods.
535 static ULONG WINAPI
OLEFontImpl_Release(
538 OLEFontImpl
*this = (OLEFontImpl
*)iface
;
540 TRACE("(%p)->(ref=%d)\n", this, this->ref
);
542 /* Decrease the reference count for current interface */
543 ret
= InterlockedDecrement(&this->ref
);
545 /* If the reference count goes down to 0, destroy. */
548 ULONG fontlist_refs
= InterlockedDecrement(&ifont_cnt
);
550 /* Final IFont object so destroy font cache */
551 if (fontlist_refs
== 0)
553 HFONTItem
*item
, *cursor2
;
555 EnterCriticalSection(&OLEFontImpl_csHFONTLIST
);
556 LIST_FOR_EACH_ENTRY_SAFE(item
, cursor2
, &OLEFontImpl_hFontList
, HFONTItem
, entry
)
557 HFONTItem_Delete(item
);
558 LeaveCriticalSection(&OLEFontImpl_csHFONTLIST
);
563 dec_int_ref(this->gdiFont
);
565 OLEFontImpl_Destroy(this);
577 static int CALLBACK
font_enum_proc(const LOGFONTW
*elf
, const TEXTMETRICW
*ntm
, DWORD type
, LPARAM lp
)
579 enum_data
*data
= (enum_data
*)lp
;
581 if(elf
->lfCharSet
== data
->orig_cs
)
583 data
->avail_cs
= data
->orig_cs
;
586 if(data
->avail_cs
== -1) data
->avail_cs
= elf
->lfCharSet
;
590 static void realize_font(OLEFontImpl
*This
)
596 WCHAR text_face
[LF_FACESIZE
];
605 old_font
= SelectObject(hdc
, This
->gdiFont
);
606 GetTextFaceW(hdc
, sizeof(text_face
) / sizeof(text_face
[0]), text_face
);
607 SelectObject(hdc
, old_font
);
608 dec_int_ref(This
->gdiFont
);
612 memset(&logFont
, 0, sizeof(LOGFONTW
));
614 lstrcpynW(logFont
.lfFaceName
, This
->description
.lpstrName
, LF_FACESIZE
);
615 logFont
.lfCharSet
= This
->description
.sCharset
;
617 /* If the font name has been changed then enumerate all charsets
618 and pick one that'll result in the font specified being selected */
619 if(text_face
[0] && lstrcmpiW(text_face
, This
->description
.lpstrName
))
622 data
.orig_cs
= This
->description
.sCharset
;
624 logFont
.lfCharSet
= DEFAULT_CHARSET
;
625 EnumFontFamiliesExW(get_dc(), &logFont
, font_enum_proc
, (LPARAM
)&data
, 0);
626 if(data
.avail_cs
!= -1) logFont
.lfCharSet
= data
.avail_cs
;
631 * The height of the font returned by the get_Size property is the
632 * height of the font in points multiplied by 10000... Using some
633 * simple conversions and the ratio given by the application, it can
634 * be converted to a height in pixels.
636 * Standard ratio is 72 / 2540, or 18 / 635 in lowest terms.
637 * Ratio is applied here relative to the standard.
640 fontHeight
= MulDiv( This
->description
.cySize
.s
.Lo
, This
->cyLogical
*635, This
->cyHimetric
*18 );
643 logFont
.lfHeight
= ((fontHeight
%10000L)>5000L) ? (-fontHeight
/10000L) - 1 :
644 (-fontHeight
/10000L);
645 logFont
.lfItalic
= This
->description
.fItalic
;
646 logFont
.lfUnderline
= This
->description
.fUnderline
;
647 logFont
.lfStrikeOut
= This
->description
.fStrikethrough
;
648 logFont
.lfWeight
= This
->description
.sWeight
;
649 logFont
.lfOutPrecision
= OUT_CHARACTER_PRECIS
;
650 logFont
.lfClipPrecision
= CLIP_DEFAULT_PRECIS
;
651 logFont
.lfQuality
= DEFAULT_QUALITY
;
652 logFont
.lfPitchAndFamily
= DEFAULT_PITCH
;
654 This
->gdiFont
= CreateFontIndirectW(&logFont
);
657 add_hfontitem(This
->gdiFont
);
659 /* Fixup the name and charset properties so that they match the
661 old_font
= SelectObject(get_dc(), This
->gdiFont
);
662 GetTextFaceW(hdc
, sizeof(text_face
) / sizeof(text_face
[0]), text_face
);
663 if(lstrcmpiW(text_face
, This
->description
.lpstrName
))
665 HeapFree(GetProcessHeap(), 0, This
->description
.lpstrName
);
666 This
->description
.lpstrName
= strdupW(text_face
);
668 GetTextMetricsW(hdc
, &tm
);
669 This
->description
.sCharset
= tm
.tmCharSet
;
670 SelectObject(hdc
, old_font
);
674 /************************************************************************
675 * OLEFontImpl_get_Name (IFont)
677 * See Windows documentation for more details on IFont methods.
679 static HRESULT WINAPI
OLEFontImpl_get_Name(
683 OLEFontImpl
*this = (OLEFontImpl
*)iface
;
684 TRACE("(%p)->(%p)\n", this, pname
);
691 if(this->dirty
) realize_font(this);
693 if (this->description
.lpstrName
!=0)
694 *pname
= SysAllocString(this->description
.lpstrName
);
701 /************************************************************************
702 * OLEFontImpl_put_Name (IFont)
704 * See Windows documentation for more details on IFont methods.
706 static HRESULT WINAPI
OLEFontImpl_put_Name(
710 OLEFontImpl
*this = (OLEFontImpl
*)iface
;
711 TRACE("(%p)->(%p)\n", this, name
);
714 return CTL_E_INVALIDPROPERTYVALUE
;
716 if (this->description
.lpstrName
==0)
718 this->description
.lpstrName
= HeapAlloc(GetProcessHeap(),
720 (lstrlenW(name
)+1) * sizeof(WCHAR
));
724 this->description
.lpstrName
= HeapReAlloc(GetProcessHeap(),
726 this->description
.lpstrName
,
727 (lstrlenW(name
)+1) * sizeof(WCHAR
));
730 if (this->description
.lpstrName
==0)
731 return E_OUTOFMEMORY
;
733 strcpyW(this->description
.lpstrName
, name
);
734 TRACE("new name %s\n", debugstr_w(this->description
.lpstrName
));
735 OLEFont_SendNotify(this, DISPID_FONT_NAME
);
739 /************************************************************************
740 * OLEFontImpl_get_Size (IFont)
742 * See Windows documentation for more details on IFont methods.
744 static HRESULT WINAPI
OLEFontImpl_get_Size(
748 OLEFontImpl
*this = (OLEFontImpl
*)iface
;
749 TRACE("(%p)->(%p)\n", this, psize
);
757 if(this->dirty
) realize_font(this);
760 psize
->s
.Lo
= this->description
.cySize
.s
.Lo
;
765 /************************************************************************
766 * OLEFontImpl_put_Size (IFont)
768 * See Windows documentation for more details on IFont methods.
770 static HRESULT WINAPI
OLEFontImpl_put_Size(
774 OLEFontImpl
*this = (OLEFontImpl
*)iface
;
775 TRACE("(%p)->(%d)\n", this, size
.s
.Lo
);
776 this->description
.cySize
.s
.Hi
= 0;
777 this->description
.cySize
.s
.Lo
= size
.s
.Lo
;
778 OLEFont_SendNotify(this, DISPID_FONT_SIZE
);
783 /************************************************************************
784 * OLEFontImpl_get_Bold (IFont)
786 * See Windows documentation for more details on IFont methods.
788 static HRESULT WINAPI
OLEFontImpl_get_Bold(
792 OLEFontImpl
*this = (OLEFontImpl
*)iface
;
793 TRACE("(%p)->(%p)\n", this, pbold
);
800 if(this->dirty
) realize_font(this);
802 *pbold
= this->description
.sWeight
> 550;
807 /************************************************************************
808 * OLEFontImpl_put_Bold (IFont)
810 * See Windows documentation for more details on IFont methods.
812 static HRESULT WINAPI
OLEFontImpl_put_Bold(
816 OLEFontImpl
*this = (OLEFontImpl
*)iface
;
817 TRACE("(%p)->(%d)\n", this, bold
);
818 this->description
.sWeight
= bold
? FW_BOLD
: FW_NORMAL
;
819 OLEFont_SendNotify(this, DISPID_FONT_BOLD
);
824 /************************************************************************
825 * OLEFontImpl_get_Italic (IFont)
827 * See Windows documentation for more details on IFont methods.
829 static HRESULT WINAPI
OLEFontImpl_get_Italic(
833 OLEFontImpl
*this = (OLEFontImpl
*)iface
;
834 TRACE("(%p)->(%p)\n", this, pitalic
);
841 if(this->dirty
) realize_font(this);
843 *pitalic
= this->description
.fItalic
;
848 /************************************************************************
849 * OLEFontImpl_put_Italic (IFont)
851 * See Windows documentation for more details on IFont methods.
853 static HRESULT WINAPI
OLEFontImpl_put_Italic(
857 OLEFontImpl
*this = (OLEFontImpl
*)iface
;
858 TRACE("(%p)->(%d)\n", this, italic
);
860 this->description
.fItalic
= italic
;
862 OLEFont_SendNotify(this, DISPID_FONT_ITALIC
);
866 /************************************************************************
867 * OLEFontImpl_get_Underline (IFont)
869 * See Windows documentation for more details on IFont methods.
871 static HRESULT WINAPI
OLEFontImpl_get_Underline(
875 OLEFontImpl
*this = (OLEFontImpl
*)iface
;
876 TRACE("(%p)->(%p)\n", this, punderline
);
884 if(this->dirty
) realize_font(this);
886 *punderline
= this->description
.fUnderline
;
891 /************************************************************************
892 * OLEFontImpl_put_Underline (IFont)
894 * See Windows documentation for more details on IFont methods.
896 static HRESULT WINAPI
OLEFontImpl_put_Underline(
900 OLEFontImpl
*this = (OLEFontImpl
*)iface
;
901 TRACE("(%p)->(%d)\n", this, underline
);
903 this->description
.fUnderline
= underline
;
905 OLEFont_SendNotify(this, DISPID_FONT_UNDER
);
909 /************************************************************************
910 * OLEFontImpl_get_Strikethrough (IFont)
912 * See Windows documentation for more details on IFont methods.
914 static HRESULT WINAPI
OLEFontImpl_get_Strikethrough(
916 BOOL
* pstrikethrough
)
918 OLEFontImpl
*this = (OLEFontImpl
*)iface
;
919 TRACE("(%p)->(%p)\n", this, pstrikethrough
);
924 if (pstrikethrough
==0)
927 if(this->dirty
) realize_font(this);
929 *pstrikethrough
= this->description
.fStrikethrough
;
934 /************************************************************************
935 * OLEFontImpl_put_Strikethrough (IFont)
937 * See Windows documentation for more details on IFont methods.
939 static HRESULT WINAPI
OLEFontImpl_put_Strikethrough(
943 OLEFontImpl
*this = (OLEFontImpl
*)iface
;
944 TRACE("(%p)->(%d)\n", this, strikethrough
);
946 this->description
.fStrikethrough
= strikethrough
;
947 OLEFont_SendNotify(this, DISPID_FONT_STRIKE
);
952 /************************************************************************
953 * OLEFontImpl_get_Weight (IFont)
955 * See Windows documentation for more details on IFont methods.
957 static HRESULT WINAPI
OLEFontImpl_get_Weight(
961 OLEFontImpl
*this = (OLEFontImpl
*)iface
;
962 TRACE("(%p)->(%p)\n", this, pweight
);
970 if(this->dirty
) realize_font(this);
972 *pweight
= this->description
.sWeight
;
977 /************************************************************************
978 * OLEFontImpl_put_Weight (IFont)
980 * See Windows documentation for more details on IFont methods.
982 static HRESULT WINAPI
OLEFontImpl_put_Weight(
986 OLEFontImpl
*this = (OLEFontImpl
*)iface
;
987 TRACE("(%p)->(%d)\n", this, weight
);
989 this->description
.sWeight
= weight
;
991 OLEFont_SendNotify(this, DISPID_FONT_WEIGHT
);
995 /************************************************************************
996 * OLEFontImpl_get_Charset (IFont)
998 * See Windows documentation for more details on IFont methods.
1000 static HRESULT WINAPI
OLEFontImpl_get_Charset(
1004 OLEFontImpl
*this = (OLEFontImpl
*)iface
;
1005 TRACE("(%p)->(%p)\n", this, pcharset
);
1013 if(this->dirty
) realize_font(this);
1015 *pcharset
= this->description
.sCharset
;
1020 /************************************************************************
1021 * OLEFontImpl_put_Charset (IFont)
1023 * See Windows documentation for more details on IFont methods.
1025 static HRESULT WINAPI
OLEFontImpl_put_Charset(
1029 OLEFontImpl
*this = (OLEFontImpl
*)iface
;
1030 TRACE("(%p)->(%d)\n", this, charset
);
1032 this->description
.sCharset
= charset
;
1033 OLEFont_SendNotify(this, DISPID_FONT_CHARSET
);
1038 /************************************************************************
1039 * OLEFontImpl_get_hFont (IFont)
1041 * See Windows documentation for more details on IFont methods.
1043 static HRESULT WINAPI
OLEFontImpl_get_hFont(
1047 OLEFontImpl
*this = (OLEFontImpl
*)iface
;
1048 TRACE("(%p)->(%p)\n", this, phfont
);
1052 if(this->dirty
) realize_font(this);
1054 *phfont
= this->gdiFont
;
1055 TRACE("Returning %p\n", *phfont
);
1059 /************************************************************************
1060 * OLEFontImpl_Clone (IFont)
1062 * See Windows documentation for more details on IFont methods.
1064 static HRESULT WINAPI
OLEFontImpl_Clone(
1068 OLEFontImpl
* newObject
= 0;
1069 OLEFontImpl
*this = (OLEFontImpl
*)iface
;
1071 TRACE("(%p)->(%p)\n", this, ppfont
);
1079 * Allocate space for the object.
1081 newObject
= HeapAlloc(GetProcessHeap(), 0, sizeof(OLEFontImpl
));
1083 if (newObject
==NULL
)
1084 return E_OUTOFMEMORY
;
1088 /* We need to alloc new memory for the string, otherwise
1089 * we free memory twice.
1091 newObject
->description
.lpstrName
= HeapAlloc(
1093 (1+strlenW(this->description
.lpstrName
))*2
1095 strcpyW(newObject
->description
.lpstrName
, this->description
.lpstrName
);
1098 /* Increment internal ref in hfont item list */
1099 if(newObject
->gdiFont
) inc_int_ref(newObject
->gdiFont
);
1101 InterlockedIncrement(&ifont_cnt
);
1103 /* create new connection points */
1104 newObject
->pPropertyNotifyCP
= NULL
;
1105 newObject
->pFontEventsCP
= NULL
;
1106 CreateConnectionPoint((IUnknown
*)newObject
, &IID_IPropertyNotifySink
, &newObject
->pPropertyNotifyCP
);
1107 CreateConnectionPoint((IUnknown
*)newObject
, &IID_IFontEventsDisp
, &newObject
->pFontEventsCP
);
1109 if (!newObject
->pPropertyNotifyCP
|| !newObject
->pFontEventsCP
)
1111 OLEFontImpl_Destroy(newObject
);
1112 return E_OUTOFMEMORY
;
1115 /* The cloned object starts with a reference count of 1 */
1118 *ppfont
= (IFont
*)newObject
;
1123 /************************************************************************
1124 * OLEFontImpl_IsEqual (IFont)
1126 * See Windows documentation for more details on IFont methods.
1128 static HRESULT WINAPI
OLEFontImpl_IsEqual(
1132 OLEFontImpl
*left
= (OLEFontImpl
*)iface
;
1133 OLEFontImpl
*right
= (OLEFontImpl
*)pFontOther
;
1135 INT left_len
,right_len
;
1137 if(pFontOther
== NULL
)
1139 else if (left
->description
.cySize
.s
.Lo
!= right
->description
.cySize
.s
.Lo
)
1141 else if (left
->description
.cySize
.s
.Hi
!= right
->description
.cySize
.s
.Hi
)
1143 else if (left
->description
.sWeight
!= right
->description
.sWeight
)
1145 else if (left
->description
.sCharset
!= right
->description
.sCharset
)
1147 else if (left
->description
.fItalic
!= right
->description
.fItalic
)
1149 else if (left
->description
.fUnderline
!= right
->description
.fUnderline
)
1151 else if (left
->description
.fStrikethrough
!= right
->description
.fStrikethrough
)
1154 /* Check from string */
1155 left_len
= strlenW(left
->description
.lpstrName
);
1156 right_len
= strlenW(right
->description
.lpstrName
);
1157 ret
= CompareStringW(0,0,left
->description
.lpstrName
, left_len
,
1158 right
->description
.lpstrName
, right_len
);
1159 if (ret
!= CSTR_EQUAL
)
1165 /************************************************************************
1166 * OLEFontImpl_SetRatio (IFont)
1168 * See Windows documentation for more details on IFont methods.
1170 static HRESULT WINAPI
OLEFontImpl_SetRatio(
1175 OLEFontImpl
*this = (OLEFontImpl
*)iface
;
1176 TRACE("(%p)->(%d, %d)\n", this, cyLogical
, cyHimetric
);
1178 this->cyLogical
= cyLogical
;
1179 this->cyHimetric
= cyHimetric
;
1184 /************************************************************************
1185 * OLEFontImpl_QueryTextMetrics (IFont)
1187 * See Windows documentation for more details on IFont methods.
1189 static HRESULT WINAPI
OLEFontImpl_QueryTextMetrics(
1194 HFONT hOldFont
, hNewFont
;
1197 OLEFontImpl_get_hFont(iface
, &hNewFont
);
1198 hOldFont
= SelectObject(hdcRef
, hNewFont
);
1199 GetTextMetricsW(hdcRef
, ptm
);
1200 SelectObject(hdcRef
, hOldFont
);
1201 ReleaseDC(0, hdcRef
);
1205 /************************************************************************
1206 * OLEFontImpl_AddRefHfont (IFont)
1208 * See Windows documentation for more details on IFont methods.
1210 static HRESULT WINAPI
OLEFontImpl_AddRefHfont(
1214 OLEFontImpl
*this = (OLEFontImpl
*)iface
;
1216 TRACE("(%p)->(%p)\n", this, hfont
);
1218 if (!hfont
) return E_INVALIDARG
;
1220 return inc_ext_ref(hfont
);
1223 /************************************************************************
1224 * OLEFontImpl_ReleaseHfont (IFont)
1226 * See Windows documentation for more details on IFont methods.
1228 static HRESULT WINAPI
OLEFontImpl_ReleaseHfont(
1232 OLEFontImpl
*this = (OLEFontImpl
*)iface
;
1234 TRACE("(%p)->(%p)\n", this, hfont
);
1236 if (!hfont
) return E_INVALIDARG
;
1238 return dec_ext_ref(hfont
);
1241 /************************************************************************
1242 * OLEFontImpl_SetHdc (IFont)
1244 * See Windows documentation for more details on IFont methods.
1246 static HRESULT WINAPI
OLEFontImpl_SetHdc(
1250 OLEFontImpl
*this = (OLEFontImpl
*)iface
;
1251 FIXME("(%p)->(%p): Stub\n", this, hdc
);
1256 * Virtual function tables for the OLEFontImpl class.
1258 static const IFontVtbl OLEFontImpl_VTable
=
1260 OLEFontImpl_QueryInterface
,
1262 OLEFontImpl_Release
,
1263 OLEFontImpl_get_Name
,
1264 OLEFontImpl_put_Name
,
1265 OLEFontImpl_get_Size
,
1266 OLEFontImpl_put_Size
,
1267 OLEFontImpl_get_Bold
,
1268 OLEFontImpl_put_Bold
,
1269 OLEFontImpl_get_Italic
,
1270 OLEFontImpl_put_Italic
,
1271 OLEFontImpl_get_Underline
,
1272 OLEFontImpl_put_Underline
,
1273 OLEFontImpl_get_Strikethrough
,
1274 OLEFontImpl_put_Strikethrough
,
1275 OLEFontImpl_get_Weight
,
1276 OLEFontImpl_put_Weight
,
1277 OLEFontImpl_get_Charset
,
1278 OLEFontImpl_put_Charset
,
1279 OLEFontImpl_get_hFont
,
1281 OLEFontImpl_IsEqual
,
1282 OLEFontImpl_SetRatio
,
1283 OLEFontImpl_QueryTextMetrics
,
1284 OLEFontImpl_AddRefHfont
,
1285 OLEFontImpl_ReleaseHfont
,
1289 /************************************************************************
1290 * OLEFontImpl_IDispatch_QueryInterface (IUnknown)
1292 * See Windows documentation for more details on IUnknown methods.
1294 static HRESULT WINAPI
OLEFontImpl_IDispatch_QueryInterface(
1299 OLEFontImpl
*this = impl_from_IDispatch(iface
);
1301 return IFont_QueryInterface((IFont
*)this, riid
, ppvoid
);
1304 /************************************************************************
1305 * OLEFontImpl_IDispatch_Release (IUnknown)
1307 * See Windows documentation for more details on IUnknown methods.
1309 static ULONG WINAPI
OLEFontImpl_IDispatch_Release(
1312 OLEFontImpl
*this = impl_from_IDispatch(iface
);
1314 return IFont_Release((IFont
*)this);
1317 /************************************************************************
1318 * OLEFontImpl_IDispatch_AddRef (IUnknown)
1320 * See Windows documentation for more details on IUnknown methods.
1322 static ULONG WINAPI
OLEFontImpl_IDispatch_AddRef(
1325 OLEFontImpl
*this = impl_from_IDispatch(iface
);
1327 return IFont_AddRef((IFont
*)this);
1330 /************************************************************************
1331 * OLEFontImpl_GetTypeInfoCount (IDispatch)
1333 * See Windows documentation for more details on IDispatch methods.
1335 static HRESULT WINAPI
OLEFontImpl_GetTypeInfoCount(
1337 unsigned int* pctinfo
)
1339 OLEFontImpl
*this = impl_from_IDispatch(iface
);
1340 TRACE("(%p)->(%p)\n", this, pctinfo
);
1346 /************************************************************************
1347 * OLEFontImpl_GetTypeInfo (IDispatch)
1349 * See Windows documentation for more details on IDispatch methods.
1351 static HRESULT WINAPI
OLEFontImpl_GetTypeInfo(
1355 ITypeInfo
** ppTInfo
)
1357 static const WCHAR stdole2tlb
[] = {'s','t','d','o','l','e','2','.','t','l','b',0};
1361 OLEFontImpl
*this = impl_from_IDispatch(iface
);
1362 TRACE("(%p, iTInfo=%d, lcid=%04x, %p)\n", this, iTInfo
, (int)lcid
, ppTInfo
);
1365 hres
= LoadTypeLib(stdole2tlb
, &tl
);
1367 ERR("Could not load the stdole2.tlb?\n");
1370 hres
= ITypeLib_GetTypeInfoOfGuid(tl
, &IID_IFontDisp
, ppTInfo
);
1371 ITypeLib_Release(tl
);
1373 FIXME("Did not IDispatch typeinfo from typelib, hres %x\n",hres
);
1378 /************************************************************************
1379 * OLEFontImpl_GetIDsOfNames (IDispatch)
1381 * See Windows documentation for more details on IDispatch methods.
1383 static HRESULT WINAPI
OLEFontImpl_GetIDsOfNames(
1386 LPOLESTR
* rgszNames
,
1394 OLEFontImpl
*this = impl_from_IDispatch(iface
);
1396 TRACE("(%p,%s,%p,cNames=%d,lcid=%04x,%p)\n", this, debugstr_guid(riid
),
1397 rgszNames
, cNames
, (int)lcid
, rgDispId
);
1401 return E_INVALIDARG
;
1405 /* retrieve type information */
1406 hres
= OLEFontImpl_GetTypeInfo(iface
, 0, lcid
, &pTInfo
);
1410 ERR("GetTypeInfo failed.\n");
1414 /* convert names to DISPIDs */
1415 hres
= DispGetIDsOfNames (pTInfo
, rgszNames
, cNames
, rgDispId
);
1416 ITypeInfo_Release(pTInfo
);
1422 /************************************************************************
1423 * OLEFontImpl_Invoke (IDispatch)
1425 * See Windows documentation for more details on IDispatch methods.
1427 * Note: Do not call _put_Xxx methods, since setting things here
1428 * should not call notify functions as I found out debugging the generic
1431 static HRESULT WINAPI
OLEFontImpl_Invoke(
1433 DISPID dispIdMember
,
1437 DISPPARAMS
* pDispParams
,
1438 VARIANT
* pVarResult
,
1439 EXCEPINFO
* pExepInfo
,
1442 OLEFontImpl
*this = impl_from_IDispatch(iface
);
1445 TRACE("%p->(%d,%s,0x%x,0x%x,%p,%p,%p,%p)\n", this, dispIdMember
,
1446 debugstr_guid(riid
), lcid
, wFlags
, pDispParams
, pVarResult
, pExepInfo
,
1449 /* validate parameters */
1451 if (!IsEqualIID(riid
, &IID_NULL
))
1453 ERR("riid was %s instead of IID_NULL\n", debugstr_guid(riid
));
1454 return DISP_E_UNKNOWNINTERFACE
;
1457 if (wFlags
& DISPATCH_PROPERTYGET
)
1461 ERR("null pVarResult not allowed when DISPATCH_PROPERTYGET specified\n");
1462 return DISP_E_PARAMNOTOPTIONAL
;
1465 else if (wFlags
& DISPATCH_PROPERTYPUT
)
1469 ERR("null pDispParams not allowed when DISPATCH_PROPERTYPUT specified\n");
1470 return DISP_E_PARAMNOTOPTIONAL
;
1472 if (pDispParams
->cArgs
!= 1)
1474 ERR("param count for DISPATCH_PROPERTYPUT was %d instead of 1\n", pDispParams
->cArgs
);
1475 return DISP_E_BADPARAMCOUNT
;
1480 ERR("one of DISPATCH_PROPERTYGET or DISPATCH_PROPERTYPUT must be specified\n");
1481 return DISP_E_MEMBERNOTFOUND
;
1484 switch (dispIdMember
) {
1485 case DISPID_FONT_NAME
:
1486 if (wFlags
& DISPATCH_PROPERTYGET
) {
1487 V_VT(pVarResult
) = VT_BSTR
;
1488 return IFont_get_Name((IFont
*)this, &V_BSTR(pVarResult
));
1492 VariantInit(&vararg
);
1493 hr
= VariantChangeTypeEx(&vararg
, &pDispParams
->rgvarg
[0], lcid
, 0, VT_BSTR
);
1497 hr
= IFont_put_Name((IFont
*)this, V_BSTR(&vararg
));
1499 VariantClear(&vararg
);
1503 case DISPID_FONT_BOLD
:
1504 if (wFlags
& DISPATCH_PROPERTYGET
) {
1506 hr
= IFont_get_Bold((IFont
*)this, &value
);
1507 V_VT(pVarResult
) = VT_BOOL
;
1508 V_BOOL(pVarResult
) = value
? VARIANT_TRUE
: VARIANT_FALSE
;
1513 VariantInit(&vararg
);
1514 hr
= VariantChangeTypeEx(&vararg
, &pDispParams
->rgvarg
[0], lcid
, 0, VT_BOOL
);
1518 hr
= IFont_put_Bold((IFont
*)this, V_BOOL(&vararg
));
1520 VariantClear(&vararg
);
1524 case DISPID_FONT_ITALIC
:
1525 if (wFlags
& DISPATCH_PROPERTYGET
) {
1527 hr
= IFont_get_Italic((IFont
*)this, &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_Italic((IFont
*)this, V_BOOL(&vararg
));
1541 VariantClear(&vararg
);
1545 case DISPID_FONT_UNDER
:
1546 if (wFlags
& DISPATCH_PROPERTYGET
) {
1548 hr
= IFont_get_Underline((IFont
*)this, &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_Underline((IFont
*)this, V_BOOL(&vararg
));
1562 VariantClear(&vararg
);
1566 case DISPID_FONT_STRIKE
:
1567 if (wFlags
& DISPATCH_PROPERTYGET
) {
1569 hr
= IFont_get_Strikethrough((IFont
*)this, &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_Strikethrough((IFont
*)this, V_BOOL(&vararg
));
1583 VariantClear(&vararg
);
1587 case DISPID_FONT_SIZE
:
1588 if (wFlags
& DISPATCH_PROPERTYGET
) {
1589 V_VT(pVarResult
) = VT_CY
;
1590 return OLEFontImpl_get_Size((IFont
*)this, &V_CY(pVarResult
));
1594 VariantInit(&vararg
);
1595 hr
= VariantChangeTypeEx(&vararg
, &pDispParams
->rgvarg
[0], lcid
, 0, VT_CY
);
1599 hr
= IFont_put_Size((IFont
*)this, V_CY(&vararg
));
1601 VariantClear(&vararg
);
1605 case DISPID_FONT_WEIGHT
:
1606 if (wFlags
& DISPATCH_PROPERTYGET
) {
1607 V_VT(pVarResult
) = VT_I2
;
1608 return OLEFontImpl_get_Weight((IFont
*)this, &V_I2(pVarResult
));
1612 VariantInit(&vararg
);
1613 hr
= VariantChangeTypeEx(&vararg
, &pDispParams
->rgvarg
[0], lcid
, 0, VT_I2
);
1617 hr
= IFont_put_Weight((IFont
*)this, V_I2(&vararg
));
1619 VariantClear(&vararg
);
1623 case DISPID_FONT_CHARSET
:
1624 if (wFlags
& DISPATCH_PROPERTYGET
) {
1625 V_VT(pVarResult
) = VT_I2
;
1626 return OLEFontImpl_get_Charset((IFont
*)this, &V_I2(pVarResult
));
1630 VariantInit(&vararg
);
1631 hr
= VariantChangeTypeEx(&vararg
, &pDispParams
->rgvarg
[0], lcid
, 0, VT_I2
);
1635 hr
= IFont_put_Charset((IFont
*)this, V_I2(&vararg
));
1637 VariantClear(&vararg
);
1642 ERR("member not found for dispid 0x%x\n", dispIdMember
);
1643 return DISP_E_MEMBERNOTFOUND
;
1647 static const IDispatchVtbl OLEFontImpl_IDispatch_VTable
=
1649 OLEFontImpl_IDispatch_QueryInterface
,
1650 OLEFontImpl_IDispatch_AddRef
,
1651 OLEFontImpl_IDispatch_Release
,
1652 OLEFontImpl_GetTypeInfoCount
,
1653 OLEFontImpl_GetTypeInfo
,
1654 OLEFontImpl_GetIDsOfNames
,
1658 /************************************************************************
1659 * OLEFontImpl_IPersistStream_QueryInterface (IUnknown)
1661 * See Windows documentation for more details on IUnknown methods.
1663 static HRESULT WINAPI
OLEFontImpl_IPersistStream_QueryInterface(
1664 IPersistStream
* iface
,
1668 OLEFontImpl
*this = impl_from_IPersistStream(iface
);
1670 return IFont_QueryInterface((IFont
*)this, riid
, ppvoid
);
1673 /************************************************************************
1674 * OLEFontImpl_IPersistStream_Release (IUnknown)
1676 * See Windows documentation for more details on IUnknown methods.
1678 static ULONG WINAPI
OLEFontImpl_IPersistStream_Release(
1679 IPersistStream
* iface
)
1681 OLEFontImpl
*this = impl_from_IPersistStream(iface
);
1683 return IFont_Release((IFont
*)this);
1686 /************************************************************************
1687 * OLEFontImpl_IPersistStream_AddRef (IUnknown)
1689 * See Windows documentation for more details on IUnknown methods.
1691 static ULONG WINAPI
OLEFontImpl_IPersistStream_AddRef(
1692 IPersistStream
* iface
)
1694 OLEFontImpl
*this = impl_from_IPersistStream(iface
);
1696 return IFont_AddRef((IFont
*)this);
1699 /************************************************************************
1700 * OLEFontImpl_GetClassID (IPersistStream)
1702 * See Windows documentation for more details on IPersistStream methods.
1704 static HRESULT WINAPI
OLEFontImpl_GetClassID(
1705 IPersistStream
* iface
,
1708 TRACE("(%p,%p)\n",iface
,pClassID
);
1712 *pClassID
= CLSID_StdFont
;
1717 /************************************************************************
1718 * OLEFontImpl_IsDirty (IPersistStream)
1720 * See Windows documentation for more details on IPersistStream methods.
1722 static HRESULT WINAPI
OLEFontImpl_IsDirty(
1723 IPersistStream
* iface
)
1725 TRACE("(%p)\n",iface
);
1729 /************************************************************************
1730 * OLEFontImpl_Load (IPersistStream)
1732 * See Windows documentation for more details on IPersistStream methods.
1734 * This is the format of the standard font serialization as far as I
1737 * Offset Type Value Comment
1738 * 0x0000 Byte Unknown Probably a version number, contains 0x01
1739 * 0x0001 Short Charset Charset value from the FONTDESC structure
1740 * 0x0003 Byte Attributes Flags defined as follows:
1742 * 00000100 - Underline
1743 * 00001000 - Strikethrough
1744 * 0x0004 Short Weight Weight value from FONTDESC structure
1745 * 0x0006 DWORD size "Low" portion of the cySize member of the FONTDESC
1747 * 0x000A Byte name length Length of the font name string (no null character)
1748 * 0x000B String name Name of the font (ASCII, no nul character)
1750 static HRESULT WINAPI
OLEFontImpl_Load(
1751 IPersistStream
* iface
,
1752 IStream
* pLoadStream
)
1754 char readBuffer
[0x100];
1761 OLEFontImpl
*this = impl_from_IPersistStream(iface
);
1764 * Read the version byte
1766 IStream_Read(pLoadStream
, &bVersion
, 1, &cbRead
);
1775 IStream_Read(pLoadStream
, &this->description
.sCharset
, 2, &cbRead
);
1783 IStream_Read(pLoadStream
, &bAttributes
, 1, &cbRead
);
1788 this->description
.fItalic
= (bAttributes
& FONTPERSIST_ITALIC
) != 0;
1789 this->description
.fStrikethrough
= (bAttributes
& FONTPERSIST_STRIKETHROUGH
) != 0;
1790 this->description
.fUnderline
= (bAttributes
& FONTPERSIST_UNDERLINE
) != 0;
1795 IStream_Read(pLoadStream
, &this->description
.sWeight
, 2, &cbRead
);
1803 IStream_Read(pLoadStream
, &this->description
.cySize
.s
.Lo
, 4, &cbRead
);
1808 this->description
.cySize
.s
.Hi
= 0;
1813 IStream_Read(pLoadStream
, &bStringSize
, 1, &cbRead
);
1818 IStream_Read(pLoadStream
, readBuffer
, bStringSize
, &cbRead
);
1820 if (cbRead
!=bStringSize
)
1823 HeapFree(GetProcessHeap(), 0, this->description
.lpstrName
);
1825 len
= MultiByteToWideChar( CP_ACP
, 0, readBuffer
, bStringSize
, NULL
, 0 );
1826 this->description
.lpstrName
= HeapAlloc( GetProcessHeap(), 0, (len
+1) * sizeof(WCHAR
) );
1827 MultiByteToWideChar( CP_ACP
, 0, readBuffer
, bStringSize
, this->description
.lpstrName
, len
);
1828 this->description
.lpstrName
[len
] = 0;
1830 /* Ensure use of this font causes a new one to be created */
1831 dec_int_ref(this->gdiFont
);
1838 /************************************************************************
1839 * OLEFontImpl_Save (IPersistStream)
1841 * See Windows documentation for more details on IPersistStream methods.
1843 static HRESULT WINAPI
OLEFontImpl_Save(
1844 IPersistStream
* iface
,
1845 IStream
* pOutStream
,
1848 char* writeBuffer
= NULL
;
1850 BYTE bVersion
= 0x01;
1854 OLEFontImpl
*this = impl_from_IPersistStream(iface
);
1857 * Read the version byte
1859 IStream_Write(pOutStream
, &bVersion
, 1, &cbWritten
);
1867 IStream_Write(pOutStream
, &this->description
.sCharset
, 2, &cbWritten
);
1877 if (this->description
.fItalic
)
1878 bAttributes
|= FONTPERSIST_ITALIC
;
1880 if (this->description
.fStrikethrough
)
1881 bAttributes
|= FONTPERSIST_STRIKETHROUGH
;
1883 if (this->description
.fUnderline
)
1884 bAttributes
|= FONTPERSIST_UNDERLINE
;
1886 IStream_Write(pOutStream
, &bAttributes
, 1, &cbWritten
);
1894 IStream_Write(pOutStream
, &this->description
.sWeight
, 2, &cbWritten
);
1902 IStream_Write(pOutStream
, &this->description
.cySize
.s
.Lo
, 4, &cbWritten
);
1910 if (this->description
.lpstrName
!=0)
1911 bStringSize
= WideCharToMultiByte( CP_ACP
, 0, this->description
.lpstrName
,
1912 strlenW(this->description
.lpstrName
), NULL
, 0, NULL
, NULL
);
1916 IStream_Write(pOutStream
, &bStringSize
, 1, &cbWritten
);
1923 if (!(writeBuffer
= HeapAlloc( GetProcessHeap(), 0, bStringSize
))) return E_OUTOFMEMORY
;
1924 WideCharToMultiByte( CP_ACP
, 0, this->description
.lpstrName
,
1925 strlenW(this->description
.lpstrName
),
1926 writeBuffer
, bStringSize
, NULL
, NULL
);
1928 IStream_Write(pOutStream
, writeBuffer
, bStringSize
, &cbWritten
);
1929 HeapFree(GetProcessHeap(), 0, writeBuffer
);
1931 if (cbWritten
!=bStringSize
)
1938 /************************************************************************
1939 * OLEFontImpl_GetSizeMax (IPersistStream)
1941 * See Windows documentation for more details on IPersistStream methods.
1943 static HRESULT WINAPI
OLEFontImpl_GetSizeMax(
1944 IPersistStream
* iface
,
1945 ULARGE_INTEGER
* pcbSize
)
1947 OLEFontImpl
*this = impl_from_IPersistStream(iface
);
1952 pcbSize
->u
.HighPart
= 0;
1953 pcbSize
->u
.LowPart
= 0;
1955 pcbSize
->u
.LowPart
+= sizeof(BYTE
); /* Version */
1956 pcbSize
->u
.LowPart
+= sizeof(WORD
); /* Lang code */
1957 pcbSize
->u
.LowPart
+= sizeof(BYTE
); /* Flags */
1958 pcbSize
->u
.LowPart
+= sizeof(WORD
); /* Weight */
1959 pcbSize
->u
.LowPart
+= sizeof(DWORD
); /* Size */
1960 pcbSize
->u
.LowPart
+= sizeof(BYTE
); /* StrLength */
1962 if (this->description
.lpstrName
!=0)
1963 pcbSize
->u
.LowPart
+= WideCharToMultiByte( CP_ACP
, 0, this->description
.lpstrName
,
1964 strlenW(this->description
.lpstrName
),
1965 NULL
, 0, NULL
, NULL
);
1970 static const IPersistStreamVtbl OLEFontImpl_IPersistStream_VTable
=
1972 OLEFontImpl_IPersistStream_QueryInterface
,
1973 OLEFontImpl_IPersistStream_AddRef
,
1974 OLEFontImpl_IPersistStream_Release
,
1975 OLEFontImpl_GetClassID
,
1976 OLEFontImpl_IsDirty
,
1979 OLEFontImpl_GetSizeMax
1982 /************************************************************************
1983 * OLEFontImpl_IConnectionPointContainer_QueryInterface (IUnknown)
1985 * See Windows documentation for more details on IUnknown methods.
1987 static HRESULT WINAPI
OLEFontImpl_IConnectionPointContainer_QueryInterface(
1988 IConnectionPointContainer
* iface
,
1992 OLEFontImpl
*this = impl_from_IConnectionPointContainer(iface
);
1994 return IFont_QueryInterface((IFont
*)this, riid
, ppvoid
);
1997 /************************************************************************
1998 * OLEFontImpl_IConnectionPointContainer_Release (IUnknown)
2000 * See Windows documentation for more details on IUnknown methods.
2002 static ULONG WINAPI
OLEFontImpl_IConnectionPointContainer_Release(
2003 IConnectionPointContainer
* iface
)
2005 OLEFontImpl
*this = impl_from_IConnectionPointContainer(iface
);
2007 return IFont_Release((IFont
*)this);
2010 /************************************************************************
2011 * OLEFontImpl_IConnectionPointContainer_AddRef (IUnknown)
2013 * See Windows documentation for more details on IUnknown methods.
2015 static ULONG WINAPI
OLEFontImpl_IConnectionPointContainer_AddRef(
2016 IConnectionPointContainer
* iface
)
2018 OLEFontImpl
*this = impl_from_IConnectionPointContainer(iface
);
2020 return IFont_AddRef((IFont
*)this);
2023 /************************************************************************
2024 * OLEFontImpl_EnumConnectionPoints (IConnectionPointContainer)
2026 * See Windows documentation for more details on IConnectionPointContainer
2029 static HRESULT WINAPI
OLEFontImpl_EnumConnectionPoints(
2030 IConnectionPointContainer
* iface
,
2031 IEnumConnectionPoints
**ppEnum
)
2033 OLEFontImpl
*this = impl_from_IConnectionPointContainer(iface
);
2035 FIXME("(%p)->(%p): stub\n", this, ppEnum
);
2039 /************************************************************************
2040 * OLEFontImpl_FindConnectionPoint (IConnectionPointContainer)
2042 * See Windows documentation for more details on IConnectionPointContainer
2045 static HRESULT WINAPI
OLEFontImpl_FindConnectionPoint(
2046 IConnectionPointContainer
* iface
,
2048 IConnectionPoint
**ppCp
)
2050 OLEFontImpl
*this = impl_from_IConnectionPointContainer(iface
);
2051 TRACE("(%p)->(%s, %p)\n", this, debugstr_guid(riid
), ppCp
);
2053 if(IsEqualIID(riid
, &IID_IPropertyNotifySink
)) {
2054 return IConnectionPoint_QueryInterface(this->pPropertyNotifyCP
,
2055 &IID_IConnectionPoint
,
2057 } else if(IsEqualIID(riid
, &IID_IFontEventsDisp
)) {
2058 return IConnectionPoint_QueryInterface(this->pFontEventsCP
,
2059 &IID_IConnectionPoint
,
2062 FIXME("no connection point for %s\n", debugstr_guid(riid
));
2063 return CONNECT_E_NOCONNECTION
;
2067 static const IConnectionPointContainerVtbl
2068 OLEFontImpl_IConnectionPointContainer_VTable
=
2070 OLEFontImpl_IConnectionPointContainer_QueryInterface
,
2071 OLEFontImpl_IConnectionPointContainer_AddRef
,
2072 OLEFontImpl_IConnectionPointContainer_Release
,
2073 OLEFontImpl_EnumConnectionPoints
,
2074 OLEFontImpl_FindConnectionPoint
2077 /************************************************************************
2078 * OLEFontImpl implementation of IPersistPropertyBag.
2080 static HRESULT WINAPI
OLEFontImpl_IPersistPropertyBag_QueryInterface(
2081 IPersistPropertyBag
*iface
, REFIID riid
, LPVOID
*ppvObj
2083 OLEFontImpl
*this = impl_from_IPersistPropertyBag(iface
);
2084 return IFont_QueryInterface((IFont
*)this,riid
,ppvObj
);
2087 static ULONG WINAPI
OLEFontImpl_IPersistPropertyBag_AddRef(
2088 IPersistPropertyBag
*iface
2090 OLEFontImpl
*this = impl_from_IPersistPropertyBag(iface
);
2091 return IFont_AddRef((IFont
*)this);
2094 static ULONG WINAPI
OLEFontImpl_IPersistPropertyBag_Release(
2095 IPersistPropertyBag
*iface
2097 OLEFontImpl
*this = impl_from_IPersistPropertyBag(iface
);
2098 return IFont_Release((IFont
*)this);
2101 static HRESULT WINAPI
OLEFontImpl_IPersistPropertyBag_GetClassID(
2102 IPersistPropertyBag
*iface
, CLSID
*classid
2104 FIXME("(%p,%p), stub!\n", iface
, classid
);
2108 static HRESULT WINAPI
OLEFontImpl_IPersistPropertyBag_InitNew(
2109 IPersistPropertyBag
*iface
2111 FIXME("(%p), stub!\n", iface
);
2115 static HRESULT WINAPI
OLEFontImpl_IPersistPropertyBag_Load(
2116 IPersistPropertyBag
*iface
, IPropertyBag
* pPropBag
, IErrorLog
* pErrorLog
2118 /* (from Visual Basic 6 property bag)
2119 Name = "MS Sans Serif"
2123 Underline = 0 'False
2125 Strikethrough = 0 'False
2127 static const WCHAR sAttrName
[] = {'N','a','m','e',0};
2128 static const WCHAR sAttrSize
[] = {'S','i','z','e',0};
2129 static const WCHAR sAttrCharset
[] = {'C','h','a','r','s','e','t',0};
2130 static const WCHAR sAttrWeight
[] = {'W','e','i','g','h','t',0};
2131 static const WCHAR sAttrUnderline
[] = {'U','n','d','e','r','l','i','n','e',0};
2132 static const WCHAR sAttrItalic
[] = {'I','t','a','l','i','c',0};
2133 static const WCHAR sAttrStrikethrough
[] = {'S','t','r','i','k','e','t','h','r','o','u','g','h',0};
2134 OLEFontImpl
*this = impl_from_IPersistPropertyBag(iface
);
2138 VariantInit(&value
);
2140 iRes
= IPropertyBag_Read(pPropBag
, sAttrName
, &value
, pErrorLog
);
2143 iRes
= VariantChangeType(&value
, &value
, 0, VT_BSTR
);
2145 iRes
= IFont_put_Name((IFont
*)this, V_BSTR(&value
));
2147 else if (iRes
== E_INVALIDARG
)
2150 VariantClear(&value
);
2153 iRes
= IPropertyBag_Read(pPropBag
, sAttrSize
, &value
, pErrorLog
);
2156 iRes
= VariantChangeType(&value
, &value
, 0, VT_CY
);
2158 iRes
= IFont_put_Size((IFont
*)this, V_CY(&value
));
2160 else if (iRes
== E_INVALIDARG
)
2163 VariantClear(&value
);
2167 iRes
= IPropertyBag_Read(pPropBag
, sAttrCharset
, &value
, pErrorLog
);
2170 iRes
= VariantChangeType(&value
, &value
, 0, VT_I2
);
2172 iRes
= IFont_put_Charset((IFont
*)this, V_I2(&value
));
2174 else if (iRes
== E_INVALIDARG
)
2177 VariantClear(&value
);
2181 iRes
= IPropertyBag_Read(pPropBag
, sAttrWeight
, &value
, pErrorLog
);
2184 iRes
= VariantChangeType(&value
, &value
, 0, VT_I2
);
2186 iRes
= IFont_put_Weight((IFont
*)this, V_I2(&value
));
2188 else if (iRes
== E_INVALIDARG
)
2191 VariantClear(&value
);
2195 iRes
= IPropertyBag_Read(pPropBag
, sAttrUnderline
, &value
, pErrorLog
);
2198 iRes
= VariantChangeType(&value
, &value
, 0, VT_BOOL
);
2200 iRes
= IFont_put_Underline((IFont
*)this, V_BOOL(&value
));
2202 else if (iRes
== E_INVALIDARG
)
2205 VariantClear(&value
);
2209 iRes
= IPropertyBag_Read(pPropBag
, sAttrItalic
, &value
, pErrorLog
);
2212 iRes
= VariantChangeType(&value
, &value
, 0, VT_BOOL
);
2214 iRes
= IFont_put_Italic((IFont
*)this, V_BOOL(&value
));
2216 else if (iRes
== E_INVALIDARG
)
2219 VariantClear(&value
);
2223 iRes
= IPropertyBag_Read(pPropBag
, sAttrStrikethrough
, &value
, pErrorLog
);
2226 iRes
= VariantChangeType(&value
, &value
, 0, VT_BOOL
);
2228 IFont_put_Strikethrough((IFont
*)this, V_BOOL(&value
));
2230 else if (iRes
== E_INVALIDARG
)
2233 VariantClear(&value
);
2237 WARN("-- 0x%08x\n", iRes
);
2241 static HRESULT WINAPI
OLEFontImpl_IPersistPropertyBag_Save(
2242 IPersistPropertyBag
*iface
, IPropertyBag
* pPropBag
, BOOL fClearDirty
,
2243 BOOL fSaveAllProperties
2245 FIXME("(%p,%p,%d,%d), stub!\n", iface
, pPropBag
, fClearDirty
, fSaveAllProperties
);
2249 static const IPersistPropertyBagVtbl OLEFontImpl_IPersistPropertyBag_VTable
=
2251 OLEFontImpl_IPersistPropertyBag_QueryInterface
,
2252 OLEFontImpl_IPersistPropertyBag_AddRef
,
2253 OLEFontImpl_IPersistPropertyBag_Release
,
2255 OLEFontImpl_IPersistPropertyBag_GetClassID
,
2256 OLEFontImpl_IPersistPropertyBag_InitNew
,
2257 OLEFontImpl_IPersistPropertyBag_Load
,
2258 OLEFontImpl_IPersistPropertyBag_Save
2261 /************************************************************************
2262 * OLEFontImpl implementation of IPersistStreamInit.
2264 static HRESULT WINAPI
OLEFontImpl_IPersistStreamInit_QueryInterface(
2265 IPersistStreamInit
*iface
, REFIID riid
, LPVOID
*ppvObj
2267 OLEFontImpl
*this = impl_from_IPersistStreamInit(iface
);
2268 return IFont_QueryInterface((IFont
*)this,riid
,ppvObj
);
2271 static ULONG WINAPI
OLEFontImpl_IPersistStreamInit_AddRef(
2272 IPersistStreamInit
*iface
2274 OLEFontImpl
*this = impl_from_IPersistStreamInit(iface
);
2275 return IFont_AddRef((IFont
*)this);
2278 static ULONG WINAPI
OLEFontImpl_IPersistStreamInit_Release(
2279 IPersistStreamInit
*iface
2281 OLEFontImpl
*this = impl_from_IPersistStreamInit(iface
);
2282 return IFont_Release((IFont
*)this);
2285 static HRESULT WINAPI
OLEFontImpl_IPersistStreamInit_GetClassID(
2286 IPersistStreamInit
*iface
, CLSID
*classid
2288 FIXME("(%p,%p), stub!\n", iface
, classid
);
2292 static HRESULT WINAPI
OLEFontImpl_IPersistStreamInit_IsDirty(
2293 IPersistStreamInit
*iface
2295 FIXME("(%p), stub!\n", iface
);
2299 static HRESULT WINAPI
OLEFontImpl_IPersistStreamInit_Load(
2300 IPersistStreamInit
*iface
, LPSTREAM pStm
2302 FIXME("(%p,%p), stub!\n", iface
, pStm
);
2306 static HRESULT WINAPI
OLEFontImpl_IPersistStreamInit_Save(
2307 IPersistStreamInit
*iface
, LPSTREAM pStm
, BOOL fClearDirty
2309 FIXME("(%p,%p,%d), stub!\n", iface
, pStm
, fClearDirty
);
2313 static HRESULT WINAPI
OLEFontImpl_IPersistStreamInit_GetSizeMax(
2314 IPersistStreamInit
*iface
, ULARGE_INTEGER
*pcbSize
2316 FIXME("(%p,%p), stub!\n", iface
, pcbSize
);
2320 static HRESULT WINAPI
OLEFontImpl_IPersistStreamInit_InitNew(
2321 IPersistStreamInit
*iface
2323 FIXME("(%p), stub!\n", iface
);
2327 static const IPersistStreamInitVtbl OLEFontImpl_IPersistStreamInit_VTable
=
2329 OLEFontImpl_IPersistStreamInit_QueryInterface
,
2330 OLEFontImpl_IPersistStreamInit_AddRef
,
2331 OLEFontImpl_IPersistStreamInit_Release
,
2333 OLEFontImpl_IPersistStreamInit_GetClassID
,
2334 OLEFontImpl_IPersistStreamInit_IsDirty
,
2335 OLEFontImpl_IPersistStreamInit_Load
,
2336 OLEFontImpl_IPersistStreamInit_Save
,
2337 OLEFontImpl_IPersistStreamInit_GetSizeMax
,
2338 OLEFontImpl_IPersistStreamInit_InitNew
2341 /************************************************************************
2342 * OLEFontImpl_Construct
2344 * This method will construct a new instance of the OLEFontImpl
2347 * The caller of this method must release the object when it's
2350 static OLEFontImpl
* OLEFontImpl_Construct(const FONTDESC
*fontDesc
)
2352 OLEFontImpl
* newObject
= 0;
2355 * Allocate space for the object.
2357 newObject
= HeapAlloc(GetProcessHeap(), 0, sizeof(OLEFontImpl
));
2363 * Initialize the virtual function table.
2365 newObject
->lpVtbl
= &OLEFontImpl_VTable
;
2366 newObject
->lpvtblIDispatch
= &OLEFontImpl_IDispatch_VTable
;
2367 newObject
->lpvtblIPersistStream
= &OLEFontImpl_IPersistStream_VTable
;
2368 newObject
->lpvtblIConnectionPointContainer
= &OLEFontImpl_IConnectionPointContainer_VTable
;
2369 newObject
->lpvtblIPersistPropertyBag
= &OLEFontImpl_IPersistPropertyBag_VTable
;
2370 newObject
->lpvtblIPersistStreamInit
= &OLEFontImpl_IPersistStreamInit_VTable
;
2373 * Start with one reference count. The caller of this function
2374 * must release the interface pointer when it is done.
2379 * Copy the description of the font in the object.
2381 assert(fontDesc
->cbSizeofstruct
>= sizeof(FONTDESC
));
2383 newObject
->description
.cbSizeofstruct
= sizeof(FONTDESC
);
2384 newObject
->description
.lpstrName
= HeapAlloc(GetProcessHeap(),
2386 (lstrlenW(fontDesc
->lpstrName
)+1) * sizeof(WCHAR
));
2387 strcpyW(newObject
->description
.lpstrName
, fontDesc
->lpstrName
);
2388 newObject
->description
.cySize
= fontDesc
->cySize
;
2389 newObject
->description
.sWeight
= fontDesc
->sWeight
;
2390 newObject
->description
.sCharset
= fontDesc
->sCharset
;
2391 newObject
->description
.fItalic
= fontDesc
->fItalic
;
2392 newObject
->description
.fUnderline
= fontDesc
->fUnderline
;
2393 newObject
->description
.fStrikethrough
= fontDesc
->fStrikethrough
;
2396 * Initializing all the other members.
2398 newObject
->gdiFont
= 0;
2399 newObject
->dirty
= TRUE
;
2400 newObject
->cyLogical
= 72L;
2401 newObject
->cyHimetric
= 2540L;
2402 newObject
->pPropertyNotifyCP
= NULL
;
2403 newObject
->pFontEventsCP
= NULL
;
2405 CreateConnectionPoint((IUnknown
*)newObject
, &IID_IPropertyNotifySink
, &newObject
->pPropertyNotifyCP
);
2406 CreateConnectionPoint((IUnknown
*)newObject
, &IID_IFontEventsDisp
, &newObject
->pFontEventsCP
);
2408 if (!newObject
->pPropertyNotifyCP
|| !newObject
->pFontEventsCP
)
2410 OLEFontImpl_Destroy(newObject
);
2414 InterlockedIncrement(&ifont_cnt
);
2416 TRACE("returning %p\n", newObject
);
2420 /************************************************************************
2421 * OLEFontImpl_Destroy
2423 * This method is called by the Release method when the reference
2424 * count goes down to 0. It will free all resources used by
2427 static void OLEFontImpl_Destroy(OLEFontImpl
* fontDesc
)
2429 TRACE("(%p)\n", fontDesc
);
2431 HeapFree(GetProcessHeap(), 0, fontDesc
->description
.lpstrName
);
2433 if (fontDesc
->pPropertyNotifyCP
)
2434 IConnectionPoint_Release(fontDesc
->pPropertyNotifyCP
);
2435 if (fontDesc
->pFontEventsCP
)
2436 IConnectionPoint_Release(fontDesc
->pFontEventsCP
);
2438 HeapFree(GetProcessHeap(), 0, fontDesc
);
2441 /*******************************************************************************
2442 * StdFont ClassFactory
2446 /* IUnknown fields */
2447 const IClassFactoryVtbl
*lpVtbl
;
2449 } IClassFactoryImpl
;
2451 static HRESULT WINAPI
2452 SFCF_QueryInterface(LPCLASSFACTORY iface
,REFIID riid
,LPVOID
*ppobj
) {
2453 IClassFactoryImpl
*This
= (IClassFactoryImpl
*)iface
;
2455 FIXME("(%p)->(%s,%p),stub!\n",This
,debugstr_guid(riid
),ppobj
);
2456 return E_NOINTERFACE
;
2460 SFCF_AddRef(LPCLASSFACTORY iface
) {
2461 IClassFactoryImpl
*This
= (IClassFactoryImpl
*)iface
;
2462 return InterlockedIncrement(&This
->ref
);
2465 static ULONG WINAPI
SFCF_Release(LPCLASSFACTORY iface
) {
2466 IClassFactoryImpl
*This
= (IClassFactoryImpl
*)iface
;
2467 /* static class, won't be freed */
2468 return InterlockedDecrement(&This
->ref
);
2471 static HRESULT WINAPI
SFCF_CreateInstance(
2472 LPCLASSFACTORY iface
,LPUNKNOWN pOuter
,REFIID riid
,LPVOID
*ppobj
2474 return OleCreateFontIndirect(NULL
,riid
,ppobj
);
2478 static HRESULT WINAPI
SFCF_LockServer(LPCLASSFACTORY iface
,BOOL dolock
) {
2479 IClassFactoryImpl
*This
= (IClassFactoryImpl
*)iface
;
2480 FIXME("(%p)->(%d),stub!\n",This
,dolock
);
2484 static const IClassFactoryVtbl SFCF_Vtbl
= {
2485 SFCF_QueryInterface
,
2488 SFCF_CreateInstance
,
2491 static IClassFactoryImpl STDFONT_CF
= {&SFCF_Vtbl
, 1 };
2493 void _get_STDFONT_CF(LPVOID
*ppv
) { *ppv
= &STDFONT_CF
; }