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
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 #define NONAMELESSUNION
28 #define NONAMELESSSTRUCT
34 #include "wine/unicode.h"
35 #include "oleauto.h" /* for SysAllocString(....) */
39 #include "wine/debug.h"
40 #include "connpt.h" /* for CreateConnectionPoint */
42 WINE_DEFAULT_DEBUG_CHANNEL(ole);
44 /***********************************************************************
45 * Declaration of constants used when serializing the font object.
47 #define FONTPERSIST_ITALIC 0x02
48 #define FONTPERSIST_UNDERLINE 0x04
49 #define FONTPERSIST_STRIKETHROUGH 0x08
51 /***********************************************************************
52 * Declaration of the implementation class for the IFont interface
54 typedef struct OLEFontImpl OLEFontImpl;
59 * This class supports many interfaces. IUnknown, IFont,
60 * IDispatch, IDispFont IPersistStream and IConnectionPointContainer.
61 * The first two are supported by the first vtable, the next two are
62 * supported by the second table and the last two have their own.
64 ICOM_VTABLE(IFont)* lpvtbl1;
65 ICOM_VTABLE(IDispatch)* lpvtbl2;
66 ICOM_VTABLE(IPersistStream)* lpvtbl3;
67 ICOM_VTABLE(IConnectionPointContainer)* lpvtbl4;
68 ICOM_VTABLE(IPersistPropertyBag)* lpvtbl5;
69 ICOM_VTABLE(IPersistStreamInit)* lpvtbl6;
71 * Reference count for that instance of the class.
76 * This structure contains the description of the class.
81 * Contain the font associated with this object.
96 IConnectionPoint *pCP;
100 * Here, I define utility macros to help with the casting of the
102 * There is a version to accomodate all of the VTables implemented
105 #define _ICOM_THIS(class,name) class* this = (class*)name
106 #define _ICOM_THIS_From_IDispatch(class, name) class* this = (class*)(((char*)name)-sizeof(void*))
107 #define _ICOM_THIS_From_IPersistStream(class, name) class* this = (class*)(((char*)name)-2*sizeof(void*))
108 #define _ICOM_THIS_From_IConnectionPointContainer(class, name) class* this = (class*)(((char*)name)-3*sizeof(void*))
109 #define _ICOM_THIS_From_IPersistPropertyBag(class, name) class* this = (class*)(((char*)name)-4*sizeof(void*))
110 #define _ICOM_THIS_From_IPersistStreamInit(class, name) class* this = (class*)(((char*)name)-5*sizeof(void*))
113 /***********************************************************************
114 * Prototypes for the implementation functions for the IFont
117 static OLEFontImpl* OLEFontImpl_Construct(LPFONTDESC fontDesc);
118 static void OLEFontImpl_Destroy(OLEFontImpl* fontDesc);
119 static HRESULT WINAPI OLEFontImpl_QueryInterface(IFont* iface, REFIID riid, VOID** ppvoid);
120 static ULONG WINAPI OLEFontImpl_AddRef(IFont* iface);
121 static ULONG WINAPI OLEFontImpl_Release(IFont* iface);
122 static HRESULT WINAPI OLEFontImpl_get_Name(IFont* iface, BSTR* pname);
123 static HRESULT WINAPI OLEFontImpl_put_Name(IFont* iface, BSTR name);
124 static HRESULT WINAPI OLEFontImpl_get_Size(IFont* iface, CY* psize);
125 static HRESULT WINAPI OLEFontImpl_put_Size(IFont* iface, CY size);
126 static HRESULT WINAPI OLEFontImpl_get_Bold(IFont* iface, BOOL* pbold);
127 static HRESULT WINAPI OLEFontImpl_put_Bold(IFont* iface, BOOL bold);
128 static HRESULT WINAPI OLEFontImpl_get_Italic(IFont* iface, BOOL* pitalic);
129 static HRESULT WINAPI OLEFontImpl_put_Italic(IFont* iface, BOOL italic);
130 static HRESULT WINAPI OLEFontImpl_get_Underline(IFont* iface, BOOL* punderline);
131 static HRESULT WINAPI OLEFontImpl_put_Underline(IFont* iface, BOOL underline);
132 static HRESULT WINAPI OLEFontImpl_get_Strikethrough(IFont* iface, BOOL* pstrikethrough);
133 static HRESULT WINAPI OLEFontImpl_put_Strikethrough(IFont* iface, BOOL strikethrough);
134 static HRESULT WINAPI OLEFontImpl_get_Weight(IFont* iface, short* pweight);
135 static HRESULT WINAPI OLEFontImpl_put_Weight(IFont* iface, short weight);
136 static HRESULT WINAPI OLEFontImpl_get_Charset(IFont* iface, short* pcharset);
137 static HRESULT WINAPI OLEFontImpl_put_Charset(IFont* iface, short charset);
138 static HRESULT WINAPI OLEFontImpl_get_hFont(IFont* iface, HFONT* phfont);
139 static HRESULT WINAPI OLEFontImpl_Clone(IFont* iface, IFont** ppfont);
140 static HRESULT WINAPI OLEFontImpl_IsEqual(IFont* iface, IFont* pFontOther);
141 static HRESULT WINAPI OLEFontImpl_SetRatio(IFont* iface, long cyLogical, long cyHimetric);
142 static HRESULT WINAPI OLEFontImpl_QueryTextMetrics(IFont* iface, TEXTMETRICOLE* ptm);
143 static HRESULT WINAPI OLEFontImpl_AddRefHfont(IFont* iface, HFONT hfont);
144 static HRESULT WINAPI OLEFontImpl_ReleaseHfont(IFont* iface, HFONT hfont);
145 static HRESULT WINAPI OLEFontImpl_SetHdc(IFont* iface, HDC hdc);
147 /***********************************************************************
148 * Prototypes for the implementation functions for the IDispatch
151 static HRESULT WINAPI OLEFontImpl_IDispatch_QueryInterface(IDispatch* iface,
154 static ULONG WINAPI OLEFontImpl_IDispatch_AddRef(IDispatch* iface);
155 static ULONG WINAPI OLEFontImpl_IDispatch_Release(IDispatch* iface);
156 static HRESULT WINAPI OLEFontImpl_GetTypeInfoCount(IDispatch* iface,
157 unsigned int* pctinfo);
158 static HRESULT WINAPI OLEFontImpl_GetTypeInfo(IDispatch* iface,
161 ITypeInfo** ppTInfo);
162 static HRESULT WINAPI OLEFontImpl_GetIDsOfNames(IDispatch* iface,
168 static HRESULT WINAPI OLEFontImpl_Invoke(IDispatch* iface,
173 DISPPARAMS* pDispParams,
175 EXCEPINFO* pExepInfo,
178 /***********************************************************************
179 * Prototypes for the implementation functions for the IPersistStream
182 static HRESULT WINAPI OLEFontImpl_IPersistStream_QueryInterface(IPersistStream* iface,
185 static ULONG WINAPI OLEFontImpl_IPersistStream_AddRef(IPersistStream* iface);
186 static ULONG WINAPI OLEFontImpl_IPersistStream_Release(IPersistStream* iface);
187 static HRESULT WINAPI OLEFontImpl_GetClassID(IPersistStream* iface,
189 static HRESULT WINAPI OLEFontImpl_IsDirty(IPersistStream* iface);
190 static HRESULT WINAPI OLEFontImpl_Load(IPersistStream* iface,
191 IStream* pLoadStream);
192 static HRESULT WINAPI OLEFontImpl_Save(IPersistStream* iface,
195 static HRESULT WINAPI OLEFontImpl_GetSizeMax(IPersistStream* iface,
196 ULARGE_INTEGER* pcbSize);
198 /***********************************************************************
199 * Prototypes for the implementation functions for the
200 * IConnectionPointContainer interface
202 static HRESULT WINAPI OLEFontImpl_IConnectionPointContainer_QueryInterface(
203 IConnectionPointContainer* iface,
206 static ULONG WINAPI OLEFontImpl_IConnectionPointContainer_AddRef(
207 IConnectionPointContainer* iface);
208 static ULONG WINAPI OLEFontImpl_IConnectionPointContainer_Release(
209 IConnectionPointContainer* iface);
210 static HRESULT WINAPI OLEFontImpl_EnumConnectionPoints(
211 IConnectionPointContainer* iface,
212 IEnumConnectionPoints **ppEnum);
213 static HRESULT WINAPI OLEFontImpl_FindConnectionPoint(
214 IConnectionPointContainer* iface,
216 IConnectionPoint **ppCp);
219 * Virtual function tables for the OLEFontImpl class.
221 static ICOM_VTABLE(IFont) OLEFontImpl_VTable =
223 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
224 OLEFontImpl_QueryInterface,
227 OLEFontImpl_get_Name,
228 OLEFontImpl_put_Name,
229 OLEFontImpl_get_Size,
230 OLEFontImpl_put_Size,
231 OLEFontImpl_get_Bold,
232 OLEFontImpl_put_Bold,
233 OLEFontImpl_get_Italic,
234 OLEFontImpl_put_Italic,
235 OLEFontImpl_get_Underline,
236 OLEFontImpl_put_Underline,
237 OLEFontImpl_get_Strikethrough,
238 OLEFontImpl_put_Strikethrough,
239 OLEFontImpl_get_Weight,
240 OLEFontImpl_put_Weight,
241 OLEFontImpl_get_Charset,
242 OLEFontImpl_put_Charset,
243 OLEFontImpl_get_hFont,
246 OLEFontImpl_SetRatio,
247 OLEFontImpl_QueryTextMetrics,
248 OLEFontImpl_AddRefHfont,
249 OLEFontImpl_ReleaseHfont,
253 static ICOM_VTABLE(IDispatch) OLEFontImpl_IDispatch_VTable =
255 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
256 OLEFontImpl_IDispatch_QueryInterface,
257 OLEFontImpl_IDispatch_AddRef,
258 OLEFontImpl_IDispatch_Release,
259 OLEFontImpl_GetTypeInfoCount,
260 OLEFontImpl_GetTypeInfo,
261 OLEFontImpl_GetIDsOfNames,
265 static ICOM_VTABLE(IPersistStream) OLEFontImpl_IPersistStream_VTable =
267 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
268 OLEFontImpl_IPersistStream_QueryInterface,
269 OLEFontImpl_IPersistStream_AddRef,
270 OLEFontImpl_IPersistStream_Release,
271 OLEFontImpl_GetClassID,
275 OLEFontImpl_GetSizeMax
278 static ICOM_VTABLE(IConnectionPointContainer)
279 OLEFontImpl_IConnectionPointContainer_VTable =
281 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
282 OLEFontImpl_IConnectionPointContainer_QueryInterface,
283 OLEFontImpl_IConnectionPointContainer_AddRef,
284 OLEFontImpl_IConnectionPointContainer_Release,
285 OLEFontImpl_EnumConnectionPoints,
286 OLEFontImpl_FindConnectionPoint
289 static ICOM_VTABLE(IPersistPropertyBag) OLEFontImpl_IPersistPropertyBag_VTable;
290 static ICOM_VTABLE(IPersistStreamInit) OLEFontImpl_IPersistStreamInit_VTable;
291 /******************************************************************************
292 * OleCreateFontIndirect [OLEAUT32.420]
294 HRESULT WINAPI OleCreateFontIndirect(
295 LPFONTDESC lpFontDesc,
299 OLEFontImpl* newFont = 0;
302 TRACE("(%p, %s, %p)\n", lpFontDesc, debugstr_guid(riid), ppvObj);
314 WCHAR fname[] = { 'S','y','s','t','e','m',0 };
316 fd.cbSizeofstruct = sizeof(fd);
317 fd.lpstrName = fname;
318 fd.cySize.s.Lo = 80000;
324 fd.fStrikethrough = 0;
329 * Try to construct a new instance of the class.
331 newFont = OLEFontImpl_Construct(lpFontDesc);
334 return E_OUTOFMEMORY;
337 * Make sure it supports the interface required by the caller.
339 hr = IFont_QueryInterface((IFont*)newFont, riid, ppvObj);
342 * Release the reference obtained in the constructor. If
343 * the QueryInterface was unsuccessful, it will free the class.
345 IFont_Release((IFont*)newFont);
351 /***********************************************************************
352 * Implementation of the OLEFontImpl class.
355 /***********************************************************************
356 * OLEFont_SendNotify (internal)
358 * Sends notification messages of changed properties to any interested
361 static void OLEFont_SendNotify(OLEFontImpl* this, DISPID dispID)
363 IEnumConnections *pEnum;
367 hres = IConnectionPoint_EnumConnections(this->pCP, &pEnum);
368 if (FAILED(hres)) /* When we have 0 connections. */
371 while(IEnumConnections_Next(pEnum, 1, &CD, NULL) == S_OK) {
372 IPropertyNotifySink *sink;
374 IUnknown_QueryInterface(CD.pUnk, &IID_IPropertyNotifySink, (LPVOID)&sink);
375 IPropertyNotifySink_OnChanged(sink, dispID);
376 IPropertyNotifySink_Release(sink);
377 IUnknown_Release(CD.pUnk);
379 IEnumConnections_Release(pEnum);
383 /************************************************************************
384 * OLEFontImpl_Construct
386 * This method will construct a new instance of the OLEFontImpl
389 * The caller of this method must release the object when it's
392 static OLEFontImpl* OLEFontImpl_Construct(LPFONTDESC fontDesc)
394 OLEFontImpl* newObject = 0;
397 * Allocate space for the object.
399 newObject = HeapAlloc(GetProcessHeap(), 0, sizeof(OLEFontImpl));
405 * Initialize the virtual function table.
407 newObject->lpvtbl1 = &OLEFontImpl_VTable;
408 newObject->lpvtbl2 = &OLEFontImpl_IDispatch_VTable;
409 newObject->lpvtbl3 = &OLEFontImpl_IPersistStream_VTable;
410 newObject->lpvtbl4 = &OLEFontImpl_IConnectionPointContainer_VTable;
411 newObject->lpvtbl5 = &OLEFontImpl_IPersistPropertyBag_VTable;
412 newObject->lpvtbl6 = &OLEFontImpl_IPersistStreamInit_VTable;
415 * Start with one reference count. The caller of this function
416 * must release the interface pointer when it is done.
421 * Copy the description of the font in the object.
423 assert(fontDesc->cbSizeofstruct >= sizeof(FONTDESC));
425 newObject->description.cbSizeofstruct = sizeof(FONTDESC);
426 newObject->description.lpstrName = HeapAlloc(GetProcessHeap(),
428 (lstrlenW(fontDesc->lpstrName)+1) * sizeof(WCHAR));
429 strcpyW(newObject->description.lpstrName, fontDesc->lpstrName);
430 newObject->description.cySize = fontDesc->cySize;
431 newObject->description.sWeight = fontDesc->sWeight;
432 newObject->description.sCharset = fontDesc->sCharset;
433 newObject->description.fItalic = fontDesc->fItalic;
434 newObject->description.fUnderline = fontDesc->fUnderline;
435 newObject->description.fStrikethrough = fontDesc->fStrikethrough;
438 * Initializing all the other members.
440 newObject->gdiFont = 0;
441 newObject->fontLock = 0;
442 newObject->cyLogical = 72L;
443 newObject->cyHimetric = 2540L;
444 CreateConnectionPoint((IUnknown*)newObject, &IID_IPropertyNotifySink, &newObject->pCP);
445 TRACE("returning %p\n", newObject);
449 /************************************************************************
450 * OLEFontImpl_Destroy
452 * This method is called by the Release method when the reference
453 * count goes down to 0. It will free all resources used by
456 static void OLEFontImpl_Destroy(OLEFontImpl* fontDesc)
458 TRACE("(%p)\n", fontDesc);
460 if (fontDesc->description.lpstrName!=0)
461 HeapFree(GetProcessHeap(), 0, fontDesc->description.lpstrName);
463 if (fontDesc->gdiFont!=0)
464 DeleteObject(fontDesc->gdiFont);
466 HeapFree(GetProcessHeap(), 0, fontDesc);
469 /************************************************************************
470 * OLEFontImpl_QueryInterface (IUnknown)
472 * See Windows documentation for more details on IUnknown methods.
474 HRESULT WINAPI OLEFontImpl_QueryInterface(
479 _ICOM_THIS(OLEFontImpl, iface);
480 TRACE("(%p)->(%s, %p)\n", this, debugstr_guid(riid), ppvObject);
483 * Perform a sanity check on the parameters.
485 if ( (this==0) || (ppvObject==0) )
489 * Initialize the return parameter.
494 * Compare the riid with the interface IDs implemented by this object.
496 if (IsEqualGUID(&IID_IUnknown, riid))
497 *ppvObject = (IFont*)this;
498 if (IsEqualGUID(&IID_IFont, riid))
499 *ppvObject = (IFont*)this;
500 if (IsEqualGUID(&IID_IDispatch, riid))
501 *ppvObject = (IDispatch*)&(this->lpvtbl2);
502 if (IsEqualGUID(&IID_IFontDisp, riid))
503 *ppvObject = (IDispatch*)&(this->lpvtbl2);
504 if (IsEqualGUID(&IID_IPersistStream, riid))
505 *ppvObject = (IPersistStream*)&(this->lpvtbl3);
506 if (IsEqualGUID(&IID_IConnectionPointContainer, riid))
507 *ppvObject = (IConnectionPointContainer*)&(this->lpvtbl4);
508 if (IsEqualGUID(&IID_IPersistPropertyBag, riid))
509 *ppvObject = (IPersistPropertyBag*)&(this->lpvtbl5);
510 if (IsEqualGUID(&IID_IPersistStreamInit, riid))
511 *ppvObject = (IPersistStreamInit*)&(this->lpvtbl6);
514 * Check that we obtained an interface.
518 FIXME("() : asking for unsupported interface %s\n",debugstr_guid(riid));
519 return E_NOINTERFACE;
521 OLEFontImpl_AddRef((IFont*)this);
525 /************************************************************************
526 * OLEFontImpl_AddRef (IUnknown)
528 * See Windows documentation for more details on IUnknown methods.
530 ULONG WINAPI OLEFontImpl_AddRef(
533 _ICOM_THIS(OLEFontImpl, iface);
534 TRACE("(%p)->(ref=%ld)\n", this, this->ref);
540 /************************************************************************
541 * OLEFontImpl_Release (IUnknown)
543 * See Windows documentation for more details on IUnknown methods.
545 ULONG WINAPI OLEFontImpl_Release(
548 _ICOM_THIS(OLEFontImpl, iface);
549 TRACE("(%p)->(ref=%ld)\n", this, this->ref);
552 * Decrease the reference count on this object.
557 * If the reference count goes down to 0, perform suicide.
561 OLEFontImpl_Destroy(this);
569 /************************************************************************
570 * OLEFontImpl_get_Name (IFont)
572 * See Windows documentation for more details on IFont methods.
574 static HRESULT WINAPI OLEFontImpl_get_Name(
578 _ICOM_THIS(OLEFontImpl, iface);
579 TRACE("(%p)->(%p)\n", this, pname);
586 if (this->description.lpstrName!=0)
587 *pname = SysAllocString(this->description.lpstrName);
594 /************************************************************************
595 * OLEFontImpl_put_Name (IFont)
597 * See Windows documentation for more details on IFont methods.
599 static HRESULT WINAPI OLEFontImpl_put_Name(
603 _ICOM_THIS(OLEFontImpl, iface);
604 TRACE("(%p)->(%p)\n", this, name);
606 if (this->description.lpstrName==0)
608 this->description.lpstrName = HeapAlloc(GetProcessHeap(),
610 (lstrlenW(name)+1) * sizeof(WCHAR));
614 this->description.lpstrName = HeapReAlloc(GetProcessHeap(),
616 this->description.lpstrName,
617 (lstrlenW(name)+1) * sizeof(WCHAR));
620 if (this->description.lpstrName==0)
621 return E_OUTOFMEMORY;
623 strcpyW(this->description.lpstrName, name);
624 TRACE("new name %s\n", debugstr_w(this->description.lpstrName));
625 OLEFont_SendNotify(this, DISPID_FONT_NAME);
629 /************************************************************************
630 * OLEFontImpl_get_Size (IFont)
632 * See Windows documentation for more details on IFont methods.
634 static HRESULT WINAPI OLEFontImpl_get_Size(
638 _ICOM_THIS(OLEFontImpl, iface);
639 TRACE("(%p)->(%p)\n", this, psize);
648 psize->s.Lo = this->description.cySize.s.Lo;
653 /************************************************************************
654 * OLEFontImpl_put_Size (IFont)
656 * See Windows documentation for more details on IFont methods.
658 static HRESULT WINAPI OLEFontImpl_put_Size(
662 _ICOM_THIS(OLEFontImpl, iface);
663 TRACE("(%p)->(%ld)\n", this, size.s.Lo);
664 this->description.cySize.s.Hi = 0;
665 this->description.cySize.s.Lo = size.s.Lo;
666 OLEFont_SendNotify(this, DISPID_FONT_SIZE);
671 /************************************************************************
672 * OLEFontImpl_get_Bold (IFont)
674 * See Windows documentation for more details on IFont methods.
676 static HRESULT WINAPI OLEFontImpl_get_Bold(
680 _ICOM_THIS(OLEFontImpl, iface);
681 TRACE("(%p)->(%p)\n", this, pbold);
688 *pbold = this->description.sWeight > 550;
693 /************************************************************************
694 * OLEFontImpl_put_Bold (IFont)
696 * See Windows documentation for more details on IFont methods.
698 static HRESULT WINAPI OLEFontImpl_put_Bold(
702 _ICOM_THIS(OLEFontImpl, iface);
703 TRACE("(%p)->(%d)\n", this, bold);
704 this->description.sWeight = bold ? FW_BOLD : FW_NORMAL;
705 OLEFont_SendNotify(this, DISPID_FONT_BOLD);
710 /************************************************************************
711 * OLEFontImpl_get_Italic (IFont)
713 * See Windows documentation for more details on IFont methods.
715 static HRESULT WINAPI OLEFontImpl_get_Italic(
719 _ICOM_THIS(OLEFontImpl, iface);
720 TRACE("(%p)->(%p)\n", this, pitalic);
727 *pitalic = this->description.fItalic;
732 /************************************************************************
733 * OLEFontImpl_put_Italic (IFont)
735 * See Windows documentation for more details on IFont methods.
737 static HRESULT WINAPI OLEFontImpl_put_Italic(
741 _ICOM_THIS(OLEFontImpl, iface);
742 TRACE("(%p)->(%d)\n", this, italic);
744 this->description.fItalic = italic;
746 OLEFont_SendNotify(this, DISPID_FONT_ITALIC);
750 /************************************************************************
751 * OLEFontImpl_get_Underline (IFont)
753 * See Windows documentation for more details on IFont methods.
755 static HRESULT WINAPI OLEFontImpl_get_Underline(
759 _ICOM_THIS(OLEFontImpl, iface);
760 TRACE("(%p)->(%p)\n", this, punderline);
768 *punderline = this->description.fUnderline;
773 /************************************************************************
774 * OLEFontImpl_put_Underline (IFont)
776 * See Windows documentation for more details on IFont methods.
778 static HRESULT WINAPI OLEFontImpl_put_Underline(
782 _ICOM_THIS(OLEFontImpl, iface);
783 TRACE("(%p)->(%d)\n", this, underline);
785 this->description.fUnderline = underline;
787 OLEFont_SendNotify(this, DISPID_FONT_UNDER);
791 /************************************************************************
792 * OLEFontImpl_get_Strikethrough (IFont)
794 * See Windows documentation for more details on IFont methods.
796 static HRESULT WINAPI OLEFontImpl_get_Strikethrough(
798 BOOL* pstrikethrough)
800 _ICOM_THIS(OLEFontImpl, iface);
801 TRACE("(%p)->(%p)\n", this, pstrikethrough);
806 if (pstrikethrough==0)
809 *pstrikethrough = this->description.fStrikethrough;
814 /************************************************************************
815 * OLEFontImpl_put_Strikethrough (IFont)
817 * See Windows documentation for more details on IFont methods.
819 static HRESULT WINAPI OLEFontImpl_put_Strikethrough(
823 _ICOM_THIS(OLEFontImpl, iface);
824 TRACE("(%p)->(%d)\n", this, strikethrough);
826 this->description.fStrikethrough = strikethrough;
827 OLEFont_SendNotify(this, DISPID_FONT_STRIKE);
832 /************************************************************************
833 * OLEFontImpl_get_Weight (IFont)
835 * See Windows documentation for more details on IFont methods.
837 static HRESULT WINAPI OLEFontImpl_get_Weight(
841 _ICOM_THIS(OLEFontImpl, iface);
842 TRACE("(%p)->(%p)\n", this, pweight);
850 *pweight = this->description.sWeight;
855 /************************************************************************
856 * OLEFontImpl_put_Weight (IFont)
858 * See Windows documentation for more details on IFont methods.
860 static HRESULT WINAPI OLEFontImpl_put_Weight(
864 _ICOM_THIS(OLEFontImpl, iface);
865 TRACE("(%p)->(%d)\n", this, weight);
867 this->description.sWeight = weight;
869 OLEFont_SendNotify(this, DISPID_FONT_WEIGHT);
873 /************************************************************************
874 * OLEFontImpl_get_Charset (IFont)
876 * See Windows documentation for more details on IFont methods.
878 static HRESULT WINAPI OLEFontImpl_get_Charset(
882 _ICOM_THIS(OLEFontImpl, iface);
883 TRACE("(%p)->(%p)\n", this, pcharset);
891 *pcharset = this->description.sCharset;
896 /************************************************************************
897 * OLEFontImpl_put_Charset (IFont)
899 * See Windows documentation for more details on IFont methods.
901 static HRESULT WINAPI OLEFontImpl_put_Charset(
905 _ICOM_THIS(OLEFontImpl, iface);
906 TRACE("(%p)->(%d)\n", this, charset);
908 this->description.sCharset = charset;
909 OLEFont_SendNotify(this, DISPID_FONT_CHARSET);
914 /************************************************************************
915 * OLEFontImpl_get_hFont (IFont)
917 * See Windows documentation for more details on IFont methods.
919 static HRESULT WINAPI OLEFontImpl_get_hFont(
923 _ICOM_THIS(OLEFontImpl, iface);
924 TRACE("(%p)->(%p)\n", this, phfont);
929 * Realize the font if necessary
931 if (this->gdiFont==0)
938 * The height of the font returned by the get_Size property is the
939 * height of the font in points multiplied by 10000... Using some
940 * simple conversions and the ratio given by the application, it can
941 * be converted to a height in pixels.
943 IFont_get_Size(iface, &cySize);
945 fontHeight = MulDiv( cySize.s.Lo, this->cyLogical, this->cyHimetric );
947 memset(&logFont, 0, sizeof(LOGFONTW));
949 logFont.lfHeight = ((fontHeight%10000L)>5000L) ? (-fontHeight/10000L)-1 :
950 (-fontHeight/10000L);
951 logFont.lfItalic = this->description.fItalic;
952 logFont.lfUnderline = this->description.fUnderline;
953 logFont.lfStrikeOut = this->description.fStrikethrough;
954 logFont.lfWeight = this->description.sWeight;
955 logFont.lfCharSet = this->description.sCharset;
956 logFont.lfOutPrecision = OUT_CHARACTER_PRECIS;
957 logFont.lfClipPrecision = CLIP_DEFAULT_PRECIS;
958 logFont.lfQuality = DEFAULT_QUALITY;
959 logFont.lfPitchAndFamily = DEFAULT_PITCH;
960 strcpyW(logFont.lfFaceName,this->description.lpstrName);
962 this->gdiFont = CreateFontIndirectW(&logFont);
965 *phfont = this->gdiFont;
966 TRACE("Returning %p\n", *phfont);
970 /************************************************************************
971 * OLEFontImpl_Clone (IFont)
973 * See Windows documentation for more details on IFont methods.
975 static HRESULT WINAPI OLEFontImpl_Clone(
979 OLEFontImpl* newObject = 0;
983 _ICOM_THIS(OLEFontImpl, iface);
984 TRACE("(%p)->(%p)\n", this, ppfont);
992 * Allocate space for the object.
994 newObject = HeapAlloc(GetProcessHeap(), 0, sizeof(OLEFontImpl));
997 return E_OUTOFMEMORY;
1001 /* We need to alloc new memory for the string, otherwise
1002 * we free memory twice.
1004 newObject->description.lpstrName = HeapAlloc(
1006 (1+strlenW(this->description.lpstrName))*2
1008 strcpyW(newObject->description.lpstrName, this->description.lpstrName);
1009 /* We need to clone the HFONT too. This is just cut & paste from above */
1010 IFont_get_Size(iface, &cySize);
1012 fontHeight = MulDiv(cySize.s.Lo, this->cyLogical,this->cyHimetric);
1014 memset(&logFont, 0, sizeof(LOGFONTW));
1016 logFont.lfHeight = ((fontHeight%10000L)>5000L) ? (-fontHeight/10000L)-1 :
1017 (-fontHeight/10000L);
1018 logFont.lfItalic = this->description.fItalic;
1019 logFont.lfUnderline = this->description.fUnderline;
1020 logFont.lfStrikeOut = this->description.fStrikethrough;
1021 logFont.lfWeight = this->description.sWeight;
1022 logFont.lfCharSet = this->description.sCharset;
1023 logFont.lfOutPrecision = OUT_CHARACTER_PRECIS;
1024 logFont.lfClipPrecision = CLIP_DEFAULT_PRECIS;
1025 logFont.lfQuality = DEFAULT_QUALITY;
1026 logFont.lfPitchAndFamily = DEFAULT_PITCH;
1027 strcpyW(logFont.lfFaceName,this->description.lpstrName);
1029 newObject->gdiFont = CreateFontIndirectW(&logFont);
1032 /* The cloned object starts with a reference count of 1 */
1035 *ppfont = (IFont*)newObject;
1040 /************************************************************************
1041 * OLEFontImpl_IsEqual (IFont)
1043 * See Windows documentation for more details on IFont methods.
1045 static HRESULT WINAPI OLEFontImpl_IsEqual(
1049 FIXME("(%p, %p), stub!\n",iface,pFontOther);
1053 /************************************************************************
1054 * OLEFontImpl_SetRatio (IFont)
1056 * See Windows documentation for more details on IFont methods.
1058 static HRESULT WINAPI OLEFontImpl_SetRatio(
1063 _ICOM_THIS(OLEFontImpl, iface);
1064 TRACE("(%p)->(%ld, %ld)\n", this, cyLogical, cyHimetric);
1066 this->cyLogical = cyLogical;
1067 this->cyHimetric = cyHimetric;
1072 /************************************************************************
1073 * OLEFontImpl_QueryTextMetrics (IFont)
1075 * See Windows documentation for more details on IFont methods.
1077 static HRESULT WINAPI OLEFontImpl_QueryTextMetrics(
1081 FIXME("(%p, %p), stub!\n",iface,ptm);
1085 /************************************************************************
1086 * OLEFontImpl_AddRefHfont (IFont)
1088 * See Windows documentation for more details on IFont methods.
1090 static HRESULT WINAPI OLEFontImpl_AddRefHfont(
1094 _ICOM_THIS(OLEFontImpl, iface);
1095 TRACE("(%p)->(%p) (lock=%ld)\n", this, hfont, this->fontLock);
1097 if ( (hfont == 0) ||
1098 (hfont != this->gdiFont) )
1099 return E_INVALIDARG;
1106 /************************************************************************
1107 * OLEFontImpl_ReleaseHfont (IFont)
1109 * See Windows documentation for more details on IFont methods.
1111 static HRESULT WINAPI OLEFontImpl_ReleaseHfont(
1115 _ICOM_THIS(OLEFontImpl, iface);
1116 TRACE("(%p)->(%p) (lock=%ld)\n", this, hfont, this->fontLock);
1118 if ( (hfont == 0) ||
1119 (hfont != this->gdiFont) )
1120 return E_INVALIDARG;
1125 * If we just released our last font reference, destroy it.
1127 if (this->fontLock==0)
1129 DeleteObject(this->gdiFont);
1136 /************************************************************************
1137 * OLEFontImpl_SetHdc (IFont)
1139 * See Windows documentation for more details on IFont methods.
1141 static HRESULT WINAPI OLEFontImpl_SetHdc(
1145 _ICOM_THIS(OLEFontImpl, iface);
1146 FIXME("(%p)->(%p): Stub\n", this, hdc);
1150 /************************************************************************
1151 * OLEFontImpl_IDispatch_QueryInterface (IUnknown)
1153 * See Windows documentation for more details on IUnknown methods.
1155 static HRESULT WINAPI OLEFontImpl_IDispatch_QueryInterface(
1160 _ICOM_THIS_From_IDispatch(IFont, iface);
1162 return IFont_QueryInterface(this, riid, ppvoid);
1165 /************************************************************************
1166 * OLEFontImpl_IDispatch_Release (IUnknown)
1168 * See Windows documentation for more details on IUnknown methods.
1170 static ULONG WINAPI OLEFontImpl_IDispatch_Release(
1173 _ICOM_THIS_From_IDispatch(IFont, iface);
1175 return IFont_Release(this);
1178 /************************************************************************
1179 * OLEFontImpl_IDispatch_AddRef (IUnknown)
1181 * See Windows documentation for more details on IUnknown methods.
1183 static ULONG WINAPI OLEFontImpl_IDispatch_AddRef(
1186 _ICOM_THIS_From_IDispatch(IFont, iface);
1188 return IFont_AddRef(this);
1191 /************************************************************************
1192 * OLEFontImpl_GetTypeInfoCount (IDispatch)
1194 * See Windows documentation for more details on IDispatch methods.
1196 static HRESULT WINAPI OLEFontImpl_GetTypeInfoCount(
1198 unsigned int* pctinfo)
1200 _ICOM_THIS_From_IDispatch(IFont, iface);
1201 FIXME("(%p)->(%p): Stub\n", this, pctinfo);
1206 /************************************************************************
1207 * OLEFontImpl_GetTypeInfo (IDispatch)
1209 * See Windows documentation for more details on IDispatch methods.
1211 static HRESULT WINAPI OLEFontImpl_GetTypeInfo(
1215 ITypeInfo** ppTInfo)
1217 WCHAR stdole32tlb[] = {'s','t','d','o','l','e','3','2','.','t','l','b',0};
1221 _ICOM_THIS_From_IDispatch(OLEFontImpl, iface);
1222 TRACE("(%p, iTInfo=%d, lcid=%04x, %p), unimplemented stub!\n", this, iTInfo, (int)lcid, ppTInfo);
1225 hres = LoadTypeLib(stdole32tlb, &tl);
1227 FIXME("Could not load the stdole32.tlb?\n");
1230 hres = ITypeLib_GetTypeInfoOfGuid(tl, &IID_IDispatch, ppTInfo);
1232 FIXME("Did not IDispatch typeinfo from typelib, hres %lx\n",hres);
1237 /************************************************************************
1238 * OLEFontImpl_GetIDsOfNames (IDispatch)
1240 * See Windows documentation for more details on IDispatch methods.
1242 static HRESULT WINAPI OLEFontImpl_GetIDsOfNames(
1245 LPOLESTR* rgszNames,
1250 _ICOM_THIS_From_IDispatch(IFont, iface);
1251 FIXME("(%p,%s,%p,%d,%04x,%p), stub!\n", this, debugstr_guid(riid), rgszNames,
1252 cNames, (int)lcid, rgDispId
1257 /************************************************************************
1258 * OLEFontImpl_Invoke (IDispatch)
1260 * See Windows documentation for more details on IDispatch methods.
1262 * Note: Do not call _put_Xxx methods, since setting things here
1263 * should not call notify functions as I found out debugging the generic
1266 static HRESULT WINAPI OLEFontImpl_Invoke(
1268 DISPID dispIdMember,
1272 DISPPARAMS* pDispParams,
1273 VARIANT* pVarResult,
1274 EXCEPINFO* pExepInfo,
1277 _ICOM_THIS_From_IDispatch(IFont, iface);
1278 OLEFontImpl *xthis = (OLEFontImpl*)this;
1280 switch (dispIdMember) {
1281 case DISPID_FONT_NAME:
1283 case DISPATCH_PROPERTYGET:
1284 case DISPATCH_PROPERTYGET|DISPATCH_METHOD:
1285 V_VT(pVarResult) = VT_BSTR;
1286 return OLEFontImpl_get_Name(this, &V_BSTR(pVarResult));
1287 case DISPATCH_PROPERTYPUT: {
1288 BSTR name = V_BSTR(&pDispParams->rgvarg[0]);
1289 if (V_VT(&pDispParams->rgvarg[0])!=VT_BSTR) {
1290 FIXME("property put of Name, vt is not VT_BSTR but %d\n",V_VT(&pDispParams->rgvarg[0]));
1293 if (!xthis->description.lpstrName)
1294 xthis->description.lpstrName = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(name)+1) * sizeof(WCHAR));
1296 xthis->description.lpstrName = HeapReAlloc(GetProcessHeap(), 0, xthis->description.lpstrName, (lstrlenW(name)+1) * sizeof(WCHAR));
1298 if (xthis->description.lpstrName==0)
1299 return E_OUTOFMEMORY;
1300 strcpyW(xthis->description.lpstrName, name);
1305 case DISPID_FONT_BOLD:
1307 case DISPATCH_PROPERTYGET:
1308 case DISPATCH_PROPERTYGET|DISPATCH_METHOD:
1309 V_VT(pVarResult) = VT_BOOL;
1310 return OLEFontImpl_get_Bold(this, (BOOL*)&V_BOOL(pVarResult));
1311 case DISPATCH_PROPERTYPUT:
1312 if (V_VT(&pDispParams->rgvarg[0]) != VT_BOOL) {
1313 FIXME("DISPID_FONT_BOLD/put, vt is %d, not VT_BOOL.\n",V_VT(&pDispParams->rgvarg[0]));
1316 xthis->description.sWeight = V_BOOL(&pDispParams->rgvarg[0]) ? FW_BOLD : FW_NORMAL;
1321 case DISPID_FONT_ITALIC:
1323 case DISPATCH_PROPERTYGET:
1324 case DISPATCH_PROPERTYGET|DISPATCH_METHOD:
1325 V_VT(pVarResult) = VT_BOOL;
1326 return OLEFontImpl_get_Italic(this, (BOOL*)&V_BOOL(pVarResult));
1327 case DISPATCH_PROPERTYPUT:
1328 if (V_VT(&pDispParams->rgvarg[0]) != VT_BOOL) {
1329 FIXME("DISPID_FONT_ITALIC/put, vt is %d, not VT_BOOL.\n",V_VT(&pDispParams->rgvarg[0]));
1332 xthis->description.fItalic = V_BOOL(&pDispParams->rgvarg[0]);
1337 case DISPID_FONT_UNDER:
1339 case DISPATCH_PROPERTYGET:
1340 case DISPATCH_PROPERTYGET|DISPATCH_METHOD:
1341 V_VT(pVarResult) = VT_BOOL;
1342 return OLEFontImpl_get_Underline(this, (BOOL*)&V_BOOL(pVarResult));
1343 case DISPATCH_PROPERTYPUT:
1344 if (V_VT(&pDispParams->rgvarg[0]) != VT_BOOL) {
1345 FIXME("DISPID_FONT_UNDER/put, vt is %d, not VT_BOOL.\n",V_VT(&pDispParams->rgvarg[0]));
1348 xthis->description.fUnderline = V_BOOL(&pDispParams->rgvarg[0]);
1353 case DISPID_FONT_STRIKE:
1355 case DISPATCH_PROPERTYGET:
1356 case DISPATCH_PROPERTYGET|DISPATCH_METHOD:
1357 V_VT(pVarResult) = VT_BOOL;
1358 return OLEFontImpl_get_Strikethrough(this, (BOOL*)&V_BOOL(pVarResult));
1359 case DISPATCH_PROPERTYPUT:
1360 if (V_VT(&pDispParams->rgvarg[0]) != VT_BOOL) {
1361 FIXME("DISPID_FONT_STRIKE/put, vt is %d, not VT_BOOL.\n",V_VT(&pDispParams->rgvarg[0]));
1364 xthis->description.fStrikethrough = V_BOOL(&pDispParams->rgvarg[0]);
1369 case DISPID_FONT_SIZE:
1371 case DISPATCH_PROPERTYPUT: {
1372 assert (pDispParams->cArgs == 1);
1373 xthis->description.cySize.s.Hi = 0;
1374 if (V_VT(&pDispParams->rgvarg[0]) != VT_CY) {
1375 if (V_VT(&pDispParams->rgvarg[0]) == VT_I2) {
1376 xthis->description.cySize.s.Lo = V_I2(&pDispParams->rgvarg[0]) * 10000;
1378 FIXME("property put for Size with vt %d unsupported!\n",V_VT(&pDispParams->rgvarg[0]));
1381 xthis->description.cySize.s.Lo = V_CY(&pDispParams->rgvarg[0]).s.Lo;
1385 case DISPATCH_PROPERTYGET:
1386 case DISPATCH_PROPERTYGET|DISPATCH_METHOD:
1387 V_VT(pVarResult) = VT_CY;
1388 return OLEFontImpl_get_Size(this, &V_CY(pVarResult));
1391 case DISPID_FONT_CHARSET:
1393 case DISPATCH_PROPERTYPUT:
1394 assert (pDispParams->cArgs == 1);
1395 if (V_VT(&pDispParams->rgvarg[0]) != VT_I2)
1396 FIXME("varg of first disparg is not VT_I2, but %d\n",V_VT(&pDispParams->rgvarg[0]));
1397 xthis->description.sCharset = V_I2(&pDispParams->rgvarg[0]);
1399 case DISPATCH_PROPERTYGET:
1400 case DISPATCH_PROPERTYGET|DISPATCH_METHOD:
1401 V_VT(pVarResult) = VT_I2;
1402 return OLEFontImpl_get_Charset(this, &V_I2(pVarResult));
1406 FIXME("%p->(%ld,%s,%lx,%x,%p,%p,%p,%p), unhandled dispid/flag!\n",
1407 this,dispIdMember,debugstr_guid(riid),lcid,
1408 wFlags,pDispParams,pVarResult,pExepInfo,puArgErr
1413 /************************************************************************
1414 * OLEFontImpl_IPersistStream_QueryInterface (IUnknown)
1416 * See Windows documentation for more details on IUnknown methods.
1418 static HRESULT WINAPI OLEFontImpl_IPersistStream_QueryInterface(
1419 IPersistStream* iface,
1423 _ICOM_THIS_From_IPersistStream(IFont, iface);
1425 return IFont_QueryInterface(this, riid, ppvoid);
1428 /************************************************************************
1429 * OLEFontImpl_IPersistStream_Release (IUnknown)
1431 * See Windows documentation for more details on IUnknown methods.
1433 static ULONG WINAPI OLEFontImpl_IPersistStream_Release(
1434 IPersistStream* iface)
1436 _ICOM_THIS_From_IPersistStream(IFont, iface);
1438 return IFont_Release(this);
1441 /************************************************************************
1442 * OLEFontImpl_IPersistStream_AddRef (IUnknown)
1444 * See Windows documentation for more details on IUnknown methods.
1446 static ULONG WINAPI OLEFontImpl_IPersistStream_AddRef(
1447 IPersistStream* iface)
1449 _ICOM_THIS_From_IPersistStream(IFont, iface);
1451 return IFont_AddRef(this);
1454 /************************************************************************
1455 * OLEFontImpl_GetClassID (IPersistStream)
1457 * See Windows documentation for more details on IPersistStream methods.
1459 static HRESULT WINAPI OLEFontImpl_GetClassID(
1460 IPersistStream* iface,
1463 TRACE("(%p,%p)\n",iface,pClassID);
1467 memcpy(pClassID, &CLSID_StdFont, sizeof(CLSID_StdFont));
1472 /************************************************************************
1473 * OLEFontImpl_IsDirty (IPersistStream)
1475 * See Windows documentation for more details on IPersistStream methods.
1477 static HRESULT WINAPI OLEFontImpl_IsDirty(
1478 IPersistStream* iface)
1480 TRACE("(%p)\n",iface);
1484 /************************************************************************
1485 * OLEFontImpl_Load (IPersistStream)
1487 * See Windows documentation for more details on IPersistStream methods.
1489 * This is the format of the standard font serialization as far as I
1492 * Offset Type Value Comment
1493 * 0x0000 Byte Unknown Probably a version number, contains 0x01
1494 * 0x0001 Short Charset Charset value from the FONTDESC structure
1495 * 0x0003 Byte Attributes Flags defined as follows:
1497 * 00000100 - Underline
1498 * 00001000 - Strikethrough
1499 * 0x0004 Short Weight Weight value from FONTDESC structure
1500 * 0x0006 DWORD size "Low" portion of the cySize member of the FONTDESC
1502 * 0x000A Byte name length Length of the font name string (no null character)
1503 * 0x000B String name Name of the font (ASCII, no nul character)
1505 static HRESULT WINAPI OLEFontImpl_Load(
1506 IPersistStream* iface,
1507 IStream* pLoadStream)
1509 char readBuffer[0x100];
1516 _ICOM_THIS_From_IPersistStream(OLEFontImpl, iface);
1519 * Read the version byte
1521 IStream_Read(pLoadStream, &bVersion, 1, &cbRead);
1530 IStream_Read(pLoadStream, &this->description.sCharset, 2, &cbRead);
1538 IStream_Read(pLoadStream, &bAttributes, 1, &cbRead);
1543 this->description.fItalic = (bAttributes & FONTPERSIST_ITALIC) != 0;
1544 this->description.fStrikethrough = (bAttributes & FONTPERSIST_STRIKETHROUGH) != 0;
1545 this->description.fUnderline = (bAttributes & FONTPERSIST_UNDERLINE) != 0;
1550 IStream_Read(pLoadStream, &this->description.sWeight, 2, &cbRead);
1558 IStream_Read(pLoadStream, &this->description.cySize.s.Lo, 4, &cbRead);
1563 this->description.cySize.s.Hi = 0;
1568 IStream_Read(pLoadStream, &bStringSize, 1, &cbRead);
1573 IStream_Read(pLoadStream, readBuffer, bStringSize, &cbRead);
1575 if (cbRead!=bStringSize)
1578 if (this->description.lpstrName!=0)
1579 HeapFree(GetProcessHeap(), 0, this->description.lpstrName);
1581 len = MultiByteToWideChar( CP_ACP, 0, readBuffer, bStringSize, NULL, 0 );
1582 this->description.lpstrName = HeapAlloc( GetProcessHeap(), 0, (len+1) * sizeof(WCHAR) );
1583 MultiByteToWideChar( CP_ACP, 0, readBuffer, bStringSize, this->description.lpstrName, len );
1584 this->description.lpstrName[len] = 0;
1586 /* Ensure use of this font causes a new one to be created @@@@ */
1587 DeleteObject(this->gdiFont);
1593 /************************************************************************
1594 * OLEFontImpl_Save (IPersistStream)
1596 * See Windows documentation for more details on IPersistStream methods.
1598 static HRESULT WINAPI OLEFontImpl_Save(
1599 IPersistStream* iface,
1600 IStream* pOutStream,
1603 char* writeBuffer = NULL;
1605 BYTE bVersion = 0x01;
1609 _ICOM_THIS_From_IPersistStream(OLEFontImpl, iface);
1612 * Read the version byte
1614 IStream_Write(pOutStream, &bVersion, 1, &cbWritten);
1622 IStream_Write(pOutStream, &this->description.sCharset, 2, &cbWritten);
1632 if (this->description.fItalic)
1633 bAttributes |= FONTPERSIST_ITALIC;
1635 if (this->description.fStrikethrough)
1636 bAttributes |= FONTPERSIST_STRIKETHROUGH;
1638 if (this->description.fUnderline)
1639 bAttributes |= FONTPERSIST_UNDERLINE;
1641 IStream_Write(pOutStream, &bAttributes, 1, &cbWritten);
1649 IStream_Write(pOutStream, &this->description.sWeight, 2, &cbWritten);
1657 IStream_Write(pOutStream, &this->description.cySize.s.Lo, 4, &cbWritten);
1665 if (this->description.lpstrName!=0)
1666 bStringSize = WideCharToMultiByte( CP_ACP, 0, this->description.lpstrName,
1667 strlenW(this->description.lpstrName), NULL, 0, NULL, NULL );
1671 IStream_Write(pOutStream, &bStringSize, 1, &cbWritten);
1678 if (!(writeBuffer = HeapAlloc( GetProcessHeap(), 0, bStringSize ))) return E_OUTOFMEMORY;
1679 WideCharToMultiByte( CP_ACP, 0, this->description.lpstrName,
1680 strlenW(this->description.lpstrName),
1681 writeBuffer, bStringSize, NULL, NULL );
1683 IStream_Write(pOutStream, writeBuffer, bStringSize, &cbWritten);
1684 HeapFree(GetProcessHeap(), 0, writeBuffer);
1686 if (cbWritten!=bStringSize)
1693 /************************************************************************
1694 * OLEFontImpl_GetSizeMax (IPersistStream)
1696 * See Windows documentation for more details on IPersistStream methods.
1698 static HRESULT WINAPI OLEFontImpl_GetSizeMax(
1699 IPersistStream* iface,
1700 ULARGE_INTEGER* pcbSize)
1702 _ICOM_THIS_From_IPersistStream(OLEFontImpl, iface);
1707 pcbSize->u.HighPart = 0;
1708 pcbSize->u.LowPart = 0;
1710 pcbSize->u.LowPart += sizeof(BYTE); /* Version */
1711 pcbSize->u.LowPart += sizeof(WORD); /* Lang code */
1712 pcbSize->u.LowPart += sizeof(BYTE); /* Flags */
1713 pcbSize->u.LowPart += sizeof(WORD); /* Weight */
1714 pcbSize->u.LowPart += sizeof(DWORD); /* Size */
1715 pcbSize->u.LowPart += sizeof(BYTE); /* StrLength */
1717 if (this->description.lpstrName!=0)
1718 pcbSize->u.LowPart += lstrlenW(this->description.lpstrName);
1723 /************************************************************************
1724 * OLEFontImpl_IConnectionPointContainer_QueryInterface (IUnknown)
1726 * See Windows documentation for more details on IUnknown methods.
1728 static HRESULT WINAPI OLEFontImpl_IConnectionPointContainer_QueryInterface(
1729 IConnectionPointContainer* iface,
1733 _ICOM_THIS_From_IConnectionPointContainer(OLEFontImpl, iface);
1735 return IFont_QueryInterface((IFont*)this, riid, ppvoid);
1738 /************************************************************************
1739 * OLEFontImpl_IConnectionPointContainer_Release (IUnknown)
1741 * See Windows documentation for more details on IUnknown methods.
1743 static ULONG WINAPI OLEFontImpl_IConnectionPointContainer_Release(
1744 IConnectionPointContainer* iface)
1746 _ICOM_THIS_From_IConnectionPointContainer(OLEFontImpl, iface);
1748 return IFont_Release((IFont*)this);
1751 /************************************************************************
1752 * OLEFontImpl_IConnectionPointContainer_AddRef (IUnknown)
1754 * See Windows documentation for more details on IUnknown methods.
1756 static ULONG WINAPI OLEFontImpl_IConnectionPointContainer_AddRef(
1757 IConnectionPointContainer* iface)
1759 _ICOM_THIS_From_IConnectionPointContainer(OLEFontImpl, iface);
1761 return IFont_AddRef((IFont*)this);
1764 /************************************************************************
1765 * OLEFontImpl_EnumConnectionPoints (IConnectionPointContainer)
1767 * See Windows documentation for more details on IConnectionPointContainer
1770 static HRESULT WINAPI OLEFontImpl_EnumConnectionPoints(
1771 IConnectionPointContainer* iface,
1772 IEnumConnectionPoints **ppEnum)
1774 _ICOM_THIS_From_IConnectionPointContainer(OLEFontImpl, iface);
1776 FIXME("(%p)->(%p): stub\n", this, ppEnum);
1780 /************************************************************************
1781 * OLEFontImpl_FindConnectionPoint (IConnectionPointContainer)
1783 * See Windows documentation for more details on IConnectionPointContainer
1786 static HRESULT WINAPI OLEFontImpl_FindConnectionPoint(
1787 IConnectionPointContainer* iface,
1789 IConnectionPoint **ppCp)
1791 _ICOM_THIS_From_IConnectionPointContainer(OLEFontImpl, iface);
1792 TRACE("(%p)->(%s, %p): stub\n", this, debugstr_guid(riid), ppCp);
1794 if(memcmp(riid, &IID_IPropertyNotifySink, sizeof(IID_IPropertyNotifySink)) == 0) {
1795 return IConnectionPoint_QueryInterface(this->pCP, &IID_IConnectionPoint,
1798 FIXME("Tried to find connection point on %s\n", debugstr_guid(riid));
1799 return E_NOINTERFACE;
1803 /************************************************************************
1804 * OLEFontImpl implementation of IPersistPropertyBag.
1806 static HRESULT WINAPI OLEFontImpl_IPersistPropertyBag_QueryInterface(
1807 IPersistPropertyBag *iface, REFIID riid, LPVOID *ppvObj
1809 _ICOM_THIS_From_IPersistPropertyBag(IFont, iface);
1810 return IFont_QueryInterface(this,riid,ppvObj);
1813 static ULONG WINAPI OLEFontImpl_IPersistPropertyBag_AddRef(
1814 IPersistPropertyBag *iface
1816 _ICOM_THIS_From_IPersistPropertyBag(IFont, iface);
1817 return IFont_AddRef(this);
1820 static ULONG WINAPI OLEFontImpl_IPersistPropertyBag_Release(
1821 IPersistPropertyBag *iface
1823 _ICOM_THIS_From_IPersistPropertyBag(IFont, iface);
1824 return IFont_Release(this);
1827 static HRESULT WINAPI OLEFontImpl_IPersistPropertyBag_GetClassID(
1828 IPersistPropertyBag *iface, CLSID *classid
1830 FIXME("(%p,%p), stub!\n", iface, classid);
1834 static HRESULT WINAPI OLEFontImpl_IPersistPropertyBag_InitNew(
1835 IPersistPropertyBag *iface
1837 FIXME("(%p), stub!\n", iface);
1841 static HRESULT WINAPI OLEFontImpl_IPersistPropertyBag_Load(
1842 IPersistPropertyBag *iface, IPropertyBag* pPropBag, IErrorLog* pErrorLog
1844 FIXME("(%p,%p,%p), stub!\n", iface, pPropBag, pErrorLog);
1848 static HRESULT WINAPI OLEFontImpl_IPersistPropertyBag_Save(
1849 IPersistPropertyBag *iface, IPropertyBag* pPropBag, BOOL fClearDirty,
1850 BOOL fSaveAllProperties
1852 FIXME("(%p,%p,%d,%d), stub!\n", iface, pPropBag, fClearDirty, fSaveAllProperties);
1856 static ICOM_VTABLE(IPersistPropertyBag) OLEFontImpl_IPersistPropertyBag_VTable =
1858 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
1859 OLEFontImpl_IPersistPropertyBag_QueryInterface,
1860 OLEFontImpl_IPersistPropertyBag_AddRef,
1861 OLEFontImpl_IPersistPropertyBag_Release,
1863 OLEFontImpl_IPersistPropertyBag_GetClassID,
1864 OLEFontImpl_IPersistPropertyBag_InitNew,
1865 OLEFontImpl_IPersistPropertyBag_Load,
1866 OLEFontImpl_IPersistPropertyBag_Save
1869 /************************************************************************
1870 * OLEFontImpl implementation of IPersistStreamInit.
1872 static HRESULT WINAPI OLEFontImpl_IPersistStreamInit_QueryInterface(
1873 IPersistStreamInit *iface, REFIID riid, LPVOID *ppvObj
1875 _ICOM_THIS_From_IPersistStreamInit(IFont, iface);
1876 return IFont_QueryInterface(this,riid,ppvObj);
1879 static ULONG WINAPI OLEFontImpl_IPersistStreamInit_AddRef(
1880 IPersistStreamInit *iface
1882 _ICOM_THIS_From_IPersistStreamInit(IFont, iface);
1883 return IFont_AddRef(this);
1886 static ULONG WINAPI OLEFontImpl_IPersistStreamInit_Release(
1887 IPersistStreamInit *iface
1889 _ICOM_THIS_From_IPersistStreamInit(IFont, iface);
1890 return IFont_Release(this);
1893 static HRESULT WINAPI OLEFontImpl_IPersistStreamInit_GetClassID(
1894 IPersistStreamInit *iface, CLSID *classid
1896 FIXME("(%p,%p), stub!\n", iface, classid);
1900 static HRESULT WINAPI OLEFontImpl_IPersistStreamInit_IsDirty(
1901 IPersistStreamInit *iface
1903 FIXME("(%p), stub!\n", iface);
1907 static HRESULT WINAPI OLEFontImpl_IPersistStreamInit_Load(
1908 IPersistStreamInit *iface, LPSTREAM pStm
1910 FIXME("(%p,%p), stub!\n", iface, pStm);
1914 static HRESULT WINAPI OLEFontImpl_IPersistStreamInit_Save(
1915 IPersistStreamInit *iface, LPSTREAM pStm, BOOL fClearDirty
1917 FIXME("(%p,%p,%d), stub!\n", iface, pStm, fClearDirty);
1921 static HRESULT WINAPI OLEFontImpl_IPersistStreamInit_GetSizeMax(
1922 IPersistStreamInit *iface, ULARGE_INTEGER *pcbSize
1924 FIXME("(%p,%p), stub!\n", iface, pcbSize);
1928 static HRESULT WINAPI OLEFontImpl_IPersistStreamInit_InitNew(
1929 IPersistStreamInit *iface
1931 FIXME("(%p), stub!\n", iface);
1935 static ICOM_VTABLE(IPersistStreamInit) OLEFontImpl_IPersistStreamInit_VTable =
1937 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
1938 OLEFontImpl_IPersistStreamInit_QueryInterface,
1939 OLEFontImpl_IPersistStreamInit_AddRef,
1940 OLEFontImpl_IPersistStreamInit_Release,
1942 OLEFontImpl_IPersistStreamInit_GetClassID,
1943 OLEFontImpl_IPersistStreamInit_IsDirty,
1944 OLEFontImpl_IPersistStreamInit_Load,
1945 OLEFontImpl_IPersistStreamInit_Save,
1946 OLEFontImpl_IPersistStreamInit_GetSizeMax,
1947 OLEFontImpl_IPersistStreamInit_InitNew
1950 /*******************************************************************************
1951 * StdFont ClassFactory
1955 /* IUnknown fields */
1956 ICOM_VFIELD(IClassFactory);
1958 } IClassFactoryImpl;
1960 static HRESULT WINAPI
1961 SFCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
1962 ICOM_THIS(IClassFactoryImpl,iface);
1964 FIXME("(%p)->(%s,%p),stub!\n",This,debugstr_guid(riid),ppobj);
1965 return E_NOINTERFACE;
1969 SFCF_AddRef(LPCLASSFACTORY iface) {
1970 ICOM_THIS(IClassFactoryImpl,iface);
1971 return ++(This->ref);
1974 static ULONG WINAPI SFCF_Release(LPCLASSFACTORY iface) {
1975 ICOM_THIS(IClassFactoryImpl,iface);
1976 /* static class, won't be freed */
1977 return --(This->ref);
1980 static HRESULT WINAPI SFCF_CreateInstance(
1981 LPCLASSFACTORY iface,LPUNKNOWN pOuter,REFIID riid,LPVOID *ppobj
1983 return OleCreateFontIndirect(NULL,riid,ppobj);
1987 static HRESULT WINAPI SFCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
1988 ICOM_THIS(IClassFactoryImpl,iface);
1989 FIXME("(%p)->(%d),stub!\n",This,dolock);
1993 static ICOM_VTABLE(IClassFactory) SFCF_Vtbl = {
1994 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
1995 SFCF_QueryInterface,
1998 SFCF_CreateInstance,
2001 static IClassFactoryImpl STDFONT_CF = {&SFCF_Vtbl, 1 };
2003 void _get_STDFONT_CF(LPVOID *ppv) { *ppv = (LPVOID)&STDFONT_CF; }