Don't define BEGIN_INTERFACE in unknwn.h.
[wine/multimedia.git] / dlls / oleaut32 / olefont.c
blobc094c71d94d6827c818b9418e7432d794be70d45
1 /*
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
23 #include <assert.h>
24 #include <stdarg.h>
25 #include <string.h>
27 #define COBJMACROS
28 #define NONAMELESSUNION
29 #define NONAMELESSSTRUCT
31 #include "winerror.h"
32 #include "windef.h"
33 #include "winbase.h"
34 #include "wingdi.h"
35 #include "winuser.h"
36 #include "wine/unicode.h"
37 #include "objbase.h"
38 #include "oleauto.h" /* for SysAllocString(....) */
39 #include "ole2.h"
40 #include "olectl.h"
41 #include "wine/debug.h"
42 #include "connpt.h" /* for CreateConnectionPoint */
44 WINE_DEFAULT_DEBUG_CHANNEL(ole);
46 /***********************************************************************
47 * Declaration of constants used when serializing the font object.
49 #define FONTPERSIST_ITALIC 0x02
50 #define FONTPERSIST_UNDERLINE 0x04
51 #define FONTPERSIST_STRIKETHROUGH 0x08
53 /***********************************************************************
54 * Declaration of the implementation class for the IFont interface
56 typedef struct OLEFontImpl OLEFontImpl;
58 struct OLEFontImpl
61 * This class supports many interfaces. IUnknown, IFont,
62 * IDispatch, IDispFont IPersistStream and IConnectionPointContainer.
63 * The first two are supported by the first vtable, the next two are
64 * supported by the second table and the last two have their own.
66 IFontVtbl* lpvtbl1;
67 IDispatchVtbl* lpvtbl2;
68 IPersistStreamVtbl* lpvtbl3;
69 IConnectionPointContainerVtbl* lpvtbl4;
70 IPersistPropertyBagVtbl* lpvtbl5;
71 IPersistStreamInitVtbl* lpvtbl6;
73 * Reference count for that instance of the class.
75 ULONG ref;
78 * This structure contains the description of the class.
80 FONTDESC description;
83 * Contain the font associated with this object.
85 HFONT gdiFont;
88 * Font lock count.
90 DWORD fontLock;
93 * Size ratio
95 long cyLogical;
96 long cyHimetric;
98 IConnectionPoint *pCP;
102 * Here, I define utility macros to help with the casting of the
103 * "this" parameter.
104 * There is a version to accomodate all of the VTables implemented
105 * by this object.
107 #define _ICOM_THIS(class,name) class* this = (class*)name
108 #define _ICOM_THIS_From_IDispatch(class, name) class* this = (class*)(((char*)name)-sizeof(void*))
109 #define _ICOM_THIS_From_IPersistStream(class, name) class* this = (class*)(((char*)name)-2*sizeof(void*))
110 #define _ICOM_THIS_From_IConnectionPointContainer(class, name) class* this = (class*)(((char*)name)-3*sizeof(void*))
111 #define _ICOM_THIS_From_IPersistPropertyBag(class, name) class* this = (class*)(((char*)name)-4*sizeof(void*))
112 #define _ICOM_THIS_From_IPersistStreamInit(class, name) class* this = (class*)(((char*)name)-5*sizeof(void*))
115 /***********************************************************************
116 * Prototypes for the implementation functions for the IFont
117 * interface
119 static OLEFontImpl* OLEFontImpl_Construct(LPFONTDESC fontDesc);
120 static void OLEFontImpl_Destroy(OLEFontImpl* fontDesc);
121 static HRESULT WINAPI OLEFontImpl_QueryInterface(IFont* iface, REFIID riid, VOID** ppvoid);
122 static ULONG WINAPI OLEFontImpl_AddRef(IFont* iface);
123 static ULONG WINAPI OLEFontImpl_Release(IFont* iface);
124 static HRESULT WINAPI OLEFontImpl_get_Name(IFont* iface, BSTR* pname);
125 static HRESULT WINAPI OLEFontImpl_put_Name(IFont* iface, BSTR name);
126 static HRESULT WINAPI OLEFontImpl_get_Size(IFont* iface, CY* psize);
127 static HRESULT WINAPI OLEFontImpl_put_Size(IFont* iface, CY size);
128 static HRESULT WINAPI OLEFontImpl_get_Bold(IFont* iface, BOOL* pbold);
129 static HRESULT WINAPI OLEFontImpl_put_Bold(IFont* iface, BOOL bold);
130 static HRESULT WINAPI OLEFontImpl_get_Italic(IFont* iface, BOOL* pitalic);
131 static HRESULT WINAPI OLEFontImpl_put_Italic(IFont* iface, BOOL italic);
132 static HRESULT WINAPI OLEFontImpl_get_Underline(IFont* iface, BOOL* punderline);
133 static HRESULT WINAPI OLEFontImpl_put_Underline(IFont* iface, BOOL underline);
134 static HRESULT WINAPI OLEFontImpl_get_Strikethrough(IFont* iface, BOOL* pstrikethrough);
135 static HRESULT WINAPI OLEFontImpl_put_Strikethrough(IFont* iface, BOOL strikethrough);
136 static HRESULT WINAPI OLEFontImpl_get_Weight(IFont* iface, short* pweight);
137 static HRESULT WINAPI OLEFontImpl_put_Weight(IFont* iface, short weight);
138 static HRESULT WINAPI OLEFontImpl_get_Charset(IFont* iface, short* pcharset);
139 static HRESULT WINAPI OLEFontImpl_put_Charset(IFont* iface, short charset);
140 static HRESULT WINAPI OLEFontImpl_get_hFont(IFont* iface, HFONT* phfont);
141 static HRESULT WINAPI OLEFontImpl_Clone(IFont* iface, IFont** ppfont);
142 static HRESULT WINAPI OLEFontImpl_IsEqual(IFont* iface, IFont* pFontOther);
143 static HRESULT WINAPI OLEFontImpl_SetRatio(IFont* iface, long cyLogical, long cyHimetric);
144 static HRESULT WINAPI OLEFontImpl_QueryTextMetrics(IFont* iface, TEXTMETRICOLE* ptm);
145 static HRESULT WINAPI OLEFontImpl_AddRefHfont(IFont* iface, HFONT hfont);
146 static HRESULT WINAPI OLEFontImpl_ReleaseHfont(IFont* iface, HFONT hfont);
147 static HRESULT WINAPI OLEFontImpl_SetHdc(IFont* iface, HDC hdc);
149 /***********************************************************************
150 * Prototypes for the implementation functions for the IDispatch
151 * interface
153 static HRESULT WINAPI OLEFontImpl_IDispatch_QueryInterface(IDispatch* iface,
154 REFIID riid,
155 VOID** ppvoid);
156 static ULONG WINAPI OLEFontImpl_IDispatch_AddRef(IDispatch* iface);
157 static ULONG WINAPI OLEFontImpl_IDispatch_Release(IDispatch* iface);
158 static HRESULT WINAPI OLEFontImpl_GetTypeInfoCount(IDispatch* iface,
159 unsigned int* pctinfo);
160 static HRESULT WINAPI OLEFontImpl_GetTypeInfo(IDispatch* iface,
161 UINT iTInfo,
162 LCID lcid,
163 ITypeInfo** ppTInfo);
164 static HRESULT WINAPI OLEFontImpl_GetIDsOfNames(IDispatch* iface,
165 REFIID riid,
166 LPOLESTR* rgszNames,
167 UINT cNames,
168 LCID lcid,
169 DISPID* rgDispId);
170 static HRESULT WINAPI OLEFontImpl_Invoke(IDispatch* iface,
171 DISPID dispIdMember,
172 REFIID riid,
173 LCID lcid,
174 WORD wFlags,
175 DISPPARAMS* pDispParams,
176 VARIANT* pVarResult,
177 EXCEPINFO* pExepInfo,
178 UINT* puArgErr);
180 /***********************************************************************
181 * Prototypes for the implementation functions for the IPersistStream
182 * interface
184 static HRESULT WINAPI OLEFontImpl_IPersistStream_QueryInterface(IPersistStream* iface,
185 REFIID riid,
186 VOID** ppvoid);
187 static ULONG WINAPI OLEFontImpl_IPersistStream_AddRef(IPersistStream* iface);
188 static ULONG WINAPI OLEFontImpl_IPersistStream_Release(IPersistStream* iface);
189 static HRESULT WINAPI OLEFontImpl_GetClassID(IPersistStream* iface,
190 CLSID* pClassID);
191 static HRESULT WINAPI OLEFontImpl_IsDirty(IPersistStream* iface);
192 static HRESULT WINAPI OLEFontImpl_Load(IPersistStream* iface,
193 IStream* pLoadStream);
194 static HRESULT WINAPI OLEFontImpl_Save(IPersistStream* iface,
195 IStream* pOutStream,
196 BOOL fClearDirty);
197 static HRESULT WINAPI OLEFontImpl_GetSizeMax(IPersistStream* iface,
198 ULARGE_INTEGER* pcbSize);
200 /***********************************************************************
201 * Prototypes for the implementation functions for the
202 * IConnectionPointContainer interface
204 static HRESULT WINAPI OLEFontImpl_IConnectionPointContainer_QueryInterface(
205 IConnectionPointContainer* iface,
206 REFIID riid,
207 VOID** ppvoid);
208 static ULONG WINAPI OLEFontImpl_IConnectionPointContainer_AddRef(
209 IConnectionPointContainer* iface);
210 static ULONG WINAPI OLEFontImpl_IConnectionPointContainer_Release(
211 IConnectionPointContainer* iface);
212 static HRESULT WINAPI OLEFontImpl_EnumConnectionPoints(
213 IConnectionPointContainer* iface,
214 IEnumConnectionPoints **ppEnum);
215 static HRESULT WINAPI OLEFontImpl_FindConnectionPoint(
216 IConnectionPointContainer* iface,
217 REFIID riid,
218 IConnectionPoint **ppCp);
221 * Virtual function tables for the OLEFontImpl class.
223 static IFontVtbl OLEFontImpl_VTable =
225 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
226 OLEFontImpl_QueryInterface,
227 OLEFontImpl_AddRef,
228 OLEFontImpl_Release,
229 OLEFontImpl_get_Name,
230 OLEFontImpl_put_Name,
231 OLEFontImpl_get_Size,
232 OLEFontImpl_put_Size,
233 OLEFontImpl_get_Bold,
234 OLEFontImpl_put_Bold,
235 OLEFontImpl_get_Italic,
236 OLEFontImpl_put_Italic,
237 OLEFontImpl_get_Underline,
238 OLEFontImpl_put_Underline,
239 OLEFontImpl_get_Strikethrough,
240 OLEFontImpl_put_Strikethrough,
241 OLEFontImpl_get_Weight,
242 OLEFontImpl_put_Weight,
243 OLEFontImpl_get_Charset,
244 OLEFontImpl_put_Charset,
245 OLEFontImpl_get_hFont,
246 OLEFontImpl_Clone,
247 OLEFontImpl_IsEqual,
248 OLEFontImpl_SetRatio,
249 OLEFontImpl_QueryTextMetrics,
250 OLEFontImpl_AddRefHfont,
251 OLEFontImpl_ReleaseHfont,
252 OLEFontImpl_SetHdc
255 static IDispatchVtbl OLEFontImpl_IDispatch_VTable =
257 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
258 OLEFontImpl_IDispatch_QueryInterface,
259 OLEFontImpl_IDispatch_AddRef,
260 OLEFontImpl_IDispatch_Release,
261 OLEFontImpl_GetTypeInfoCount,
262 OLEFontImpl_GetTypeInfo,
263 OLEFontImpl_GetIDsOfNames,
264 OLEFontImpl_Invoke
267 static IPersistStreamVtbl OLEFontImpl_IPersistStream_VTable =
269 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
270 OLEFontImpl_IPersistStream_QueryInterface,
271 OLEFontImpl_IPersistStream_AddRef,
272 OLEFontImpl_IPersistStream_Release,
273 OLEFontImpl_GetClassID,
274 OLEFontImpl_IsDirty,
275 OLEFontImpl_Load,
276 OLEFontImpl_Save,
277 OLEFontImpl_GetSizeMax
280 static IConnectionPointContainerVtbl
281 OLEFontImpl_IConnectionPointContainer_VTable =
283 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
284 OLEFontImpl_IConnectionPointContainer_QueryInterface,
285 OLEFontImpl_IConnectionPointContainer_AddRef,
286 OLEFontImpl_IConnectionPointContainer_Release,
287 OLEFontImpl_EnumConnectionPoints,
288 OLEFontImpl_FindConnectionPoint
291 static IPersistPropertyBagVtbl OLEFontImpl_IPersistPropertyBag_VTable;
292 static IPersistStreamInitVtbl OLEFontImpl_IPersistStreamInit_VTable;
293 /******************************************************************************
294 * OleCreateFontIndirect [OLEAUT32.420]
296 HRESULT WINAPI OleCreateFontIndirect(
297 LPFONTDESC lpFontDesc,
298 REFIID riid,
299 LPVOID* ppvObj)
301 OLEFontImpl* newFont = 0;
302 HRESULT hr = S_OK;
304 TRACE("(%p, %s, %p)\n", lpFontDesc, debugstr_guid(riid), ppvObj);
306 * Sanity check
308 if (ppvObj==0)
309 return E_POINTER;
311 *ppvObj = 0;
313 if (!lpFontDesc) {
314 FONTDESC fd;
316 static const WCHAR fname[] = { 'S','y','s','t','e','m',0 };
318 fd.cbSizeofstruct = sizeof(fd);
319 fd.lpstrName = (WCHAR*)fname;
320 fd.cySize.s.Lo = 80000;
321 fd.cySize.s.Hi = 0;
322 fd.sWeight = 0;
323 fd.sCharset = 0;
324 fd.fItalic = 0;
325 fd.fUnderline = 0;
326 fd.fStrikethrough = 0;
327 lpFontDesc = &fd;
331 * Try to construct a new instance of the class.
333 newFont = OLEFontImpl_Construct(lpFontDesc);
335 if (newFont == 0)
336 return E_OUTOFMEMORY;
339 * Make sure it supports the interface required by the caller.
341 hr = IFont_QueryInterface((IFont*)newFont, riid, ppvObj);
344 * Release the reference obtained in the constructor. If
345 * the QueryInterface was unsuccessful, it will free the class.
347 IFont_Release((IFont*)newFont);
349 return hr;
353 /***********************************************************************
354 * Implementation of the OLEFontImpl class.
357 /***********************************************************************
358 * OLEFont_SendNotify (internal)
360 * Sends notification messages of changed properties to any interested
361 * connections.
363 static void OLEFont_SendNotify(OLEFontImpl* this, DISPID dispID)
365 IEnumConnections *pEnum;
366 CONNECTDATA CD;
367 HRESULT hres;
369 hres = IConnectionPoint_EnumConnections(this->pCP, &pEnum);
370 if (FAILED(hres)) /* When we have 0 connections. */
371 return;
373 while(IEnumConnections_Next(pEnum, 1, &CD, NULL) == S_OK) {
374 IPropertyNotifySink *sink;
376 IUnknown_QueryInterface(CD.pUnk, &IID_IPropertyNotifySink, (LPVOID)&sink);
377 IPropertyNotifySink_OnChanged(sink, dispID);
378 IPropertyNotifySink_Release(sink);
379 IUnknown_Release(CD.pUnk);
381 IEnumConnections_Release(pEnum);
382 return;
385 /************************************************************************
386 * OLEFontImpl_Construct
388 * This method will construct a new instance of the OLEFontImpl
389 * class.
391 * The caller of this method must release the object when it's
392 * done with it.
394 static OLEFontImpl* OLEFontImpl_Construct(LPFONTDESC fontDesc)
396 OLEFontImpl* newObject = 0;
399 * Allocate space for the object.
401 newObject = HeapAlloc(GetProcessHeap(), 0, sizeof(OLEFontImpl));
403 if (newObject==0)
404 return newObject;
407 * Initialize the virtual function table.
409 newObject->lpvtbl1 = &OLEFontImpl_VTable;
410 newObject->lpvtbl2 = &OLEFontImpl_IDispatch_VTable;
411 newObject->lpvtbl3 = &OLEFontImpl_IPersistStream_VTable;
412 newObject->lpvtbl4 = &OLEFontImpl_IConnectionPointContainer_VTable;
413 newObject->lpvtbl5 = &OLEFontImpl_IPersistPropertyBag_VTable;
414 newObject->lpvtbl6 = &OLEFontImpl_IPersistStreamInit_VTable;
417 * Start with one reference count. The caller of this function
418 * must release the interface pointer when it is done.
420 newObject->ref = 1;
423 * Copy the description of the font in the object.
425 assert(fontDesc->cbSizeofstruct >= sizeof(FONTDESC));
427 newObject->description.cbSizeofstruct = sizeof(FONTDESC);
428 newObject->description.lpstrName = HeapAlloc(GetProcessHeap(),
430 (lstrlenW(fontDesc->lpstrName)+1) * sizeof(WCHAR));
431 strcpyW(newObject->description.lpstrName, fontDesc->lpstrName);
432 newObject->description.cySize = fontDesc->cySize;
433 newObject->description.sWeight = fontDesc->sWeight;
434 newObject->description.sCharset = fontDesc->sCharset;
435 newObject->description.fItalic = fontDesc->fItalic;
436 newObject->description.fUnderline = fontDesc->fUnderline;
437 newObject->description.fStrikethrough = fontDesc->fStrikethrough;
440 * Initializing all the other members.
442 newObject->gdiFont = 0;
443 newObject->fontLock = 0;
444 newObject->cyLogical = 72L;
445 newObject->cyHimetric = 2540L;
446 CreateConnectionPoint((IUnknown*)newObject, &IID_IPropertyNotifySink, &newObject->pCP);
447 TRACE("returning %p\n", newObject);
448 return newObject;
451 /************************************************************************
452 * OLEFontImpl_Destroy
454 * This method is called by the Release method when the reference
455 * count goes down to 0. It will free all resources used by
456 * this object.
458 static void OLEFontImpl_Destroy(OLEFontImpl* fontDesc)
460 TRACE("(%p)\n", fontDesc);
462 if (fontDesc->description.lpstrName!=0)
463 HeapFree(GetProcessHeap(), 0, fontDesc->description.lpstrName);
465 if (fontDesc->gdiFont!=0)
466 DeleteObject(fontDesc->gdiFont);
468 HeapFree(GetProcessHeap(), 0, fontDesc);
471 /************************************************************************
472 * OLEFontImpl_QueryInterface (IUnknown)
474 * See Windows documentation for more details on IUnknown methods.
476 HRESULT WINAPI OLEFontImpl_QueryInterface(
477 IFont* iface,
478 REFIID riid,
479 void** ppvObject)
481 _ICOM_THIS(OLEFontImpl, iface);
482 TRACE("(%p)->(%s, %p)\n", this, debugstr_guid(riid), ppvObject);
485 * Perform a sanity check on the parameters.
487 if ( (this==0) || (ppvObject==0) )
488 return E_INVALIDARG;
491 * Initialize the return parameter.
493 *ppvObject = 0;
496 * Compare the riid with the interface IDs implemented by this object.
498 if (IsEqualGUID(&IID_IUnknown, riid))
499 *ppvObject = (IFont*)this;
500 if (IsEqualGUID(&IID_IFont, riid))
501 *ppvObject = (IFont*)this;
502 if (IsEqualGUID(&IID_IDispatch, riid))
503 *ppvObject = (IDispatch*)&(this->lpvtbl2);
504 if (IsEqualGUID(&IID_IFontDisp, riid))
505 *ppvObject = (IDispatch*)&(this->lpvtbl2);
506 if (IsEqualGUID(&IID_IPersistStream, riid))
507 *ppvObject = (IPersistStream*)&(this->lpvtbl3);
508 if (IsEqualGUID(&IID_IConnectionPointContainer, riid))
509 *ppvObject = (IConnectionPointContainer*)&(this->lpvtbl4);
510 if (IsEqualGUID(&IID_IPersistPropertyBag, riid))
511 *ppvObject = (IPersistPropertyBag*)&(this->lpvtbl5);
512 if (IsEqualGUID(&IID_IPersistStreamInit, riid))
513 *ppvObject = (IPersistStreamInit*)&(this->lpvtbl6);
516 * Check that we obtained an interface.
518 if ((*ppvObject)==0)
520 FIXME("() : asking for unsupported interface %s\n",debugstr_guid(riid));
521 return E_NOINTERFACE;
523 OLEFontImpl_AddRef((IFont*)this);
524 return S_OK;
527 /************************************************************************
528 * OLEFontImpl_AddRef (IUnknown)
530 * See Windows documentation for more details on IUnknown methods.
532 ULONG WINAPI OLEFontImpl_AddRef(
533 IFont* iface)
535 _ICOM_THIS(OLEFontImpl, iface);
536 TRACE("(%p)->(ref=%ld)\n", this, this->ref);
537 this->ref++;
539 return this->ref;
542 /************************************************************************
543 * OLEFontImpl_Release (IUnknown)
545 * See Windows documentation for more details on IUnknown methods.
547 ULONG WINAPI OLEFontImpl_Release(
548 IFont* iface)
550 _ICOM_THIS(OLEFontImpl, iface);
551 TRACE("(%p)->(ref=%ld)\n", this, this->ref);
554 * Decrease the reference count on this object.
556 this->ref--;
559 * If the reference count goes down to 0, perform suicide.
561 if (this->ref==0)
563 OLEFontImpl_Destroy(this);
565 return 0;
568 return this->ref;
571 /************************************************************************
572 * OLEFontImpl_get_Name (IFont)
574 * See Windows documentation for more details on IFont methods.
576 static HRESULT WINAPI OLEFontImpl_get_Name(
577 IFont* iface,
578 BSTR* pname)
580 _ICOM_THIS(OLEFontImpl, iface);
581 TRACE("(%p)->(%p)\n", this, pname);
583 * Sanity check.
585 if (pname==0)
586 return E_POINTER;
588 if (this->description.lpstrName!=0)
589 *pname = SysAllocString(this->description.lpstrName);
590 else
591 *pname = 0;
593 return S_OK;
596 /************************************************************************
597 * OLEFontImpl_put_Name (IFont)
599 * See Windows documentation for more details on IFont methods.
601 static HRESULT WINAPI OLEFontImpl_put_Name(
602 IFont* iface,
603 BSTR name)
605 _ICOM_THIS(OLEFontImpl, iface);
606 TRACE("(%p)->(%p)\n", this, name);
608 if (this->description.lpstrName==0)
610 this->description.lpstrName = HeapAlloc(GetProcessHeap(),
612 (lstrlenW(name)+1) * sizeof(WCHAR));
614 else
616 this->description.lpstrName = HeapReAlloc(GetProcessHeap(),
618 this->description.lpstrName,
619 (lstrlenW(name)+1) * sizeof(WCHAR));
622 if (this->description.lpstrName==0)
623 return E_OUTOFMEMORY;
625 strcpyW(this->description.lpstrName, name);
626 TRACE("new name %s\n", debugstr_w(this->description.lpstrName));
627 OLEFont_SendNotify(this, DISPID_FONT_NAME);
628 return S_OK;
631 /************************************************************************
632 * OLEFontImpl_get_Size (IFont)
634 * See Windows documentation for more details on IFont methods.
636 static HRESULT WINAPI OLEFontImpl_get_Size(
637 IFont* iface,
638 CY* psize)
640 _ICOM_THIS(OLEFontImpl, iface);
641 TRACE("(%p)->(%p)\n", this, psize);
644 * Sanity check
646 if (psize==0)
647 return E_POINTER;
649 psize->s.Hi = 0;
650 psize->s.Lo = this->description.cySize.s.Lo;
652 return S_OK;
655 /************************************************************************
656 * OLEFontImpl_put_Size (IFont)
658 * See Windows documentation for more details on IFont methods.
660 static HRESULT WINAPI OLEFontImpl_put_Size(
661 IFont* iface,
662 CY size)
664 _ICOM_THIS(OLEFontImpl, iface);
665 TRACE("(%p)->(%ld)\n", this, size.s.Lo);
666 this->description.cySize.s.Hi = 0;
667 this->description.cySize.s.Lo = size.s.Lo;
668 OLEFont_SendNotify(this, DISPID_FONT_SIZE);
670 return S_OK;
673 /************************************************************************
674 * OLEFontImpl_get_Bold (IFont)
676 * See Windows documentation for more details on IFont methods.
678 static HRESULT WINAPI OLEFontImpl_get_Bold(
679 IFont* iface,
680 BOOL* pbold)
682 _ICOM_THIS(OLEFontImpl, iface);
683 TRACE("(%p)->(%p)\n", this, pbold);
685 * Sanity check
687 if (pbold==0)
688 return E_POINTER;
690 *pbold = this->description.sWeight > 550;
692 return S_OK;
695 /************************************************************************
696 * OLEFontImpl_put_Bold (IFont)
698 * See Windows documentation for more details on IFont methods.
700 static HRESULT WINAPI OLEFontImpl_put_Bold(
701 IFont* iface,
702 BOOL bold)
704 _ICOM_THIS(OLEFontImpl, iface);
705 TRACE("(%p)->(%d)\n", this, bold);
706 this->description.sWeight = bold ? FW_BOLD : FW_NORMAL;
707 OLEFont_SendNotify(this, DISPID_FONT_BOLD);
709 return S_OK;
712 /************************************************************************
713 * OLEFontImpl_get_Italic (IFont)
715 * See Windows documentation for more details on IFont methods.
717 static HRESULT WINAPI OLEFontImpl_get_Italic(
718 IFont* iface,
719 BOOL* pitalic)
721 _ICOM_THIS(OLEFontImpl, iface);
722 TRACE("(%p)->(%p)\n", this, pitalic);
724 * Sanity check
726 if (pitalic==0)
727 return E_POINTER;
729 *pitalic = this->description.fItalic;
731 return S_OK;
734 /************************************************************************
735 * OLEFontImpl_put_Italic (IFont)
737 * See Windows documentation for more details on IFont methods.
739 static HRESULT WINAPI OLEFontImpl_put_Italic(
740 IFont* iface,
741 BOOL italic)
743 _ICOM_THIS(OLEFontImpl, iface);
744 TRACE("(%p)->(%d)\n", this, italic);
746 this->description.fItalic = italic;
748 OLEFont_SendNotify(this, DISPID_FONT_ITALIC);
749 return S_OK;
752 /************************************************************************
753 * OLEFontImpl_get_Underline (IFont)
755 * See Windows documentation for more details on IFont methods.
757 static HRESULT WINAPI OLEFontImpl_get_Underline(
758 IFont* iface,
759 BOOL* punderline)
761 _ICOM_THIS(OLEFontImpl, iface);
762 TRACE("(%p)->(%p)\n", this, punderline);
765 * Sanity check
767 if (punderline==0)
768 return E_POINTER;
770 *punderline = this->description.fUnderline;
772 return S_OK;
775 /************************************************************************
776 * OLEFontImpl_put_Underline (IFont)
778 * See Windows documentation for more details on IFont methods.
780 static HRESULT WINAPI OLEFontImpl_put_Underline(
781 IFont* iface,
782 BOOL underline)
784 _ICOM_THIS(OLEFontImpl, iface);
785 TRACE("(%p)->(%d)\n", this, underline);
787 this->description.fUnderline = underline;
789 OLEFont_SendNotify(this, DISPID_FONT_UNDER);
790 return S_OK;
793 /************************************************************************
794 * OLEFontImpl_get_Strikethrough (IFont)
796 * See Windows documentation for more details on IFont methods.
798 static HRESULT WINAPI OLEFontImpl_get_Strikethrough(
799 IFont* iface,
800 BOOL* pstrikethrough)
802 _ICOM_THIS(OLEFontImpl, iface);
803 TRACE("(%p)->(%p)\n", this, pstrikethrough);
806 * Sanity check
808 if (pstrikethrough==0)
809 return E_POINTER;
811 *pstrikethrough = this->description.fStrikethrough;
813 return S_OK;
816 /************************************************************************
817 * OLEFontImpl_put_Strikethrough (IFont)
819 * See Windows documentation for more details on IFont methods.
821 static HRESULT WINAPI OLEFontImpl_put_Strikethrough(
822 IFont* iface,
823 BOOL strikethrough)
825 _ICOM_THIS(OLEFontImpl, iface);
826 TRACE("(%p)->(%d)\n", this, strikethrough);
828 this->description.fStrikethrough = strikethrough;
829 OLEFont_SendNotify(this, DISPID_FONT_STRIKE);
831 return S_OK;
834 /************************************************************************
835 * OLEFontImpl_get_Weight (IFont)
837 * See Windows documentation for more details on IFont methods.
839 static HRESULT WINAPI OLEFontImpl_get_Weight(
840 IFont* iface,
841 short* pweight)
843 _ICOM_THIS(OLEFontImpl, iface);
844 TRACE("(%p)->(%p)\n", this, pweight);
847 * Sanity check
849 if (pweight==0)
850 return E_POINTER;
852 *pweight = this->description.sWeight;
854 return S_OK;
857 /************************************************************************
858 * OLEFontImpl_put_Weight (IFont)
860 * See Windows documentation for more details on IFont methods.
862 static HRESULT WINAPI OLEFontImpl_put_Weight(
863 IFont* iface,
864 short weight)
866 _ICOM_THIS(OLEFontImpl, iface);
867 TRACE("(%p)->(%d)\n", this, weight);
869 this->description.sWeight = weight;
871 OLEFont_SendNotify(this, DISPID_FONT_WEIGHT);
872 return S_OK;
875 /************************************************************************
876 * OLEFontImpl_get_Charset (IFont)
878 * See Windows documentation for more details on IFont methods.
880 static HRESULT WINAPI OLEFontImpl_get_Charset(
881 IFont* iface,
882 short* pcharset)
884 _ICOM_THIS(OLEFontImpl, iface);
885 TRACE("(%p)->(%p)\n", this, pcharset);
888 * Sanity check
890 if (pcharset==0)
891 return E_POINTER;
893 *pcharset = this->description.sCharset;
895 return S_OK;
898 /************************************************************************
899 * OLEFontImpl_put_Charset (IFont)
901 * See Windows documentation for more details on IFont methods.
903 static HRESULT WINAPI OLEFontImpl_put_Charset(
904 IFont* iface,
905 short charset)
907 _ICOM_THIS(OLEFontImpl, iface);
908 TRACE("(%p)->(%d)\n", this, charset);
910 this->description.sCharset = charset;
911 OLEFont_SendNotify(this, DISPID_FONT_CHARSET);
913 return S_OK;
916 /************************************************************************
917 * OLEFontImpl_get_hFont (IFont)
919 * See Windows documentation for more details on IFont methods.
921 static HRESULT WINAPI OLEFontImpl_get_hFont(
922 IFont* iface,
923 HFONT* phfont)
925 _ICOM_THIS(OLEFontImpl, iface);
926 TRACE("(%p)->(%p)\n", this, phfont);
927 if (phfont==NULL)
928 return E_POINTER;
931 * Realize the font if necessary
933 if (this->gdiFont==0)
935 LOGFONTW logFont;
936 INT fontHeight;
937 CY cySize;
940 * The height of the font returned by the get_Size property is the
941 * height of the font in points multiplied by 10000... Using some
942 * simple conversions and the ratio given by the application, it can
943 * be converted to a height in pixels.
945 IFont_get_Size(iface, &cySize);
947 fontHeight = MulDiv( cySize.s.Lo, this->cyLogical, this->cyHimetric );
949 memset(&logFont, 0, sizeof(LOGFONTW));
951 logFont.lfHeight = ((fontHeight%10000L)>5000L) ? (-fontHeight/10000L)-1 :
952 (-fontHeight/10000L);
953 logFont.lfItalic = this->description.fItalic;
954 logFont.lfUnderline = this->description.fUnderline;
955 logFont.lfStrikeOut = this->description.fStrikethrough;
956 logFont.lfWeight = this->description.sWeight;
957 logFont.lfCharSet = this->description.sCharset;
958 logFont.lfOutPrecision = OUT_CHARACTER_PRECIS;
959 logFont.lfClipPrecision = CLIP_DEFAULT_PRECIS;
960 logFont.lfQuality = DEFAULT_QUALITY;
961 logFont.lfPitchAndFamily = DEFAULT_PITCH;
962 strcpyW(logFont.lfFaceName,this->description.lpstrName);
964 this->gdiFont = CreateFontIndirectW(&logFont);
967 *phfont = this->gdiFont;
968 TRACE("Returning %p\n", *phfont);
969 return S_OK;
972 /************************************************************************
973 * OLEFontImpl_Clone (IFont)
975 * See Windows documentation for more details on IFont methods.
977 static HRESULT WINAPI OLEFontImpl_Clone(
978 IFont* iface,
979 IFont** ppfont)
981 OLEFontImpl* newObject = 0;
982 LOGFONTW logFont;
983 INT fontHeight;
984 CY cySize;
985 _ICOM_THIS(OLEFontImpl, iface);
986 TRACE("(%p)->(%p)\n", this, ppfont);
988 if (ppfont == NULL)
989 return E_POINTER;
991 *ppfont = NULL;
994 * Allocate space for the object.
996 newObject = HeapAlloc(GetProcessHeap(), 0, sizeof(OLEFontImpl));
998 if (newObject==NULL)
999 return E_OUTOFMEMORY;
1001 *newObject = *this;
1003 /* We need to alloc new memory for the string, otherwise
1004 * we free memory twice.
1006 newObject->description.lpstrName = HeapAlloc(
1007 GetProcessHeap(),0,
1008 (1+strlenW(this->description.lpstrName))*2
1010 strcpyW(newObject->description.lpstrName, this->description.lpstrName);
1011 /* We need to clone the HFONT too. This is just cut & paste from above */
1012 IFont_get_Size(iface, &cySize);
1014 fontHeight = MulDiv(cySize.s.Lo, this->cyLogical,this->cyHimetric);
1016 memset(&logFont, 0, sizeof(LOGFONTW));
1018 logFont.lfHeight = ((fontHeight%10000L)>5000L) ? (-fontHeight/10000L)-1 :
1019 (-fontHeight/10000L);
1020 logFont.lfItalic = this->description.fItalic;
1021 logFont.lfUnderline = this->description.fUnderline;
1022 logFont.lfStrikeOut = this->description.fStrikethrough;
1023 logFont.lfWeight = this->description.sWeight;
1024 logFont.lfCharSet = this->description.sCharset;
1025 logFont.lfOutPrecision = OUT_CHARACTER_PRECIS;
1026 logFont.lfClipPrecision = CLIP_DEFAULT_PRECIS;
1027 logFont.lfQuality = DEFAULT_QUALITY;
1028 logFont.lfPitchAndFamily = DEFAULT_PITCH;
1029 strcpyW(logFont.lfFaceName,this->description.lpstrName);
1031 newObject->gdiFont = CreateFontIndirectW(&logFont);
1034 /* The cloned object starts with a reference count of 1 */
1035 newObject->ref = 1;
1037 *ppfont = (IFont*)newObject;
1039 return S_OK;
1042 /************************************************************************
1043 * OLEFontImpl_IsEqual (IFont)
1045 * See Windows documentation for more details on IFont methods.
1047 static HRESULT WINAPI OLEFontImpl_IsEqual(
1048 IFont* iface,
1049 IFont* pFontOther)
1051 FIXME("(%p, %p), stub!\n",iface,pFontOther);
1052 return E_NOTIMPL;
1055 /************************************************************************
1056 * OLEFontImpl_SetRatio (IFont)
1058 * See Windows documentation for more details on IFont methods.
1060 static HRESULT WINAPI OLEFontImpl_SetRatio(
1061 IFont* iface,
1062 long cyLogical,
1063 long cyHimetric)
1065 _ICOM_THIS(OLEFontImpl, iface);
1066 TRACE("(%p)->(%ld, %ld)\n", this, cyLogical, cyHimetric);
1068 this->cyLogical = cyLogical;
1069 this->cyHimetric = cyHimetric;
1071 return S_OK;
1074 /************************************************************************
1075 * OLEFontImpl_QueryTextMetrics (IFont)
1077 * See Windows documentation for more details on IFont methods.
1079 static HRESULT WINAPI OLEFontImpl_QueryTextMetrics(
1080 IFont* iface,
1081 TEXTMETRICOLE* ptm)
1083 FIXME("(%p, %p), stub!\n",iface,ptm);
1084 return E_NOTIMPL;
1087 /************************************************************************
1088 * OLEFontImpl_AddRefHfont (IFont)
1090 * See Windows documentation for more details on IFont methods.
1092 static HRESULT WINAPI OLEFontImpl_AddRefHfont(
1093 IFont* iface,
1094 HFONT hfont)
1096 _ICOM_THIS(OLEFontImpl, iface);
1097 TRACE("(%p)->(%p) (lock=%ld)\n", this, hfont, this->fontLock);
1099 if ( (hfont == 0) ||
1100 (hfont != this->gdiFont) )
1101 return E_INVALIDARG;
1103 this->fontLock++;
1105 return S_OK;
1108 /************************************************************************
1109 * OLEFontImpl_ReleaseHfont (IFont)
1111 * See Windows documentation for more details on IFont methods.
1113 static HRESULT WINAPI OLEFontImpl_ReleaseHfont(
1114 IFont* iface,
1115 HFONT hfont)
1117 _ICOM_THIS(OLEFontImpl, iface);
1118 TRACE("(%p)->(%p) (lock=%ld)\n", this, hfont, this->fontLock);
1120 if ( (hfont == 0) ||
1121 (hfont != this->gdiFont) )
1122 return E_INVALIDARG;
1124 this->fontLock--;
1127 * If we just released our last font reference, destroy it.
1129 if (this->fontLock==0)
1131 DeleteObject(this->gdiFont);
1132 this->gdiFont = 0;
1135 return S_OK;
1138 /************************************************************************
1139 * OLEFontImpl_SetHdc (IFont)
1141 * See Windows documentation for more details on IFont methods.
1143 static HRESULT WINAPI OLEFontImpl_SetHdc(
1144 IFont* iface,
1145 HDC hdc)
1147 _ICOM_THIS(OLEFontImpl, iface);
1148 FIXME("(%p)->(%p): Stub\n", this, hdc);
1149 return E_NOTIMPL;
1152 /************************************************************************
1153 * OLEFontImpl_IDispatch_QueryInterface (IUnknown)
1155 * See Windows documentation for more details on IUnknown methods.
1157 static HRESULT WINAPI OLEFontImpl_IDispatch_QueryInterface(
1158 IDispatch* iface,
1159 REFIID riid,
1160 VOID** ppvoid)
1162 _ICOM_THIS_From_IDispatch(IFont, iface);
1164 return IFont_QueryInterface(this, riid, ppvoid);
1167 /************************************************************************
1168 * OLEFontImpl_IDispatch_Release (IUnknown)
1170 * See Windows documentation for more details on IUnknown methods.
1172 static ULONG WINAPI OLEFontImpl_IDispatch_Release(
1173 IDispatch* iface)
1175 _ICOM_THIS_From_IDispatch(IFont, iface);
1177 return IFont_Release(this);
1180 /************************************************************************
1181 * OLEFontImpl_IDispatch_AddRef (IUnknown)
1183 * See Windows documentation for more details on IUnknown methods.
1185 static ULONG WINAPI OLEFontImpl_IDispatch_AddRef(
1186 IDispatch* iface)
1188 _ICOM_THIS_From_IDispatch(IFont, iface);
1190 return IFont_AddRef(this);
1193 /************************************************************************
1194 * OLEFontImpl_GetTypeInfoCount (IDispatch)
1196 * See Windows documentation for more details on IDispatch methods.
1198 static HRESULT WINAPI OLEFontImpl_GetTypeInfoCount(
1199 IDispatch* iface,
1200 unsigned int* pctinfo)
1202 _ICOM_THIS_From_IDispatch(IFont, iface);
1203 FIXME("(%p)->(%p): Stub\n", this, pctinfo);
1205 return E_NOTIMPL;
1208 /************************************************************************
1209 * OLEFontImpl_GetTypeInfo (IDispatch)
1211 * See Windows documentation for more details on IDispatch methods.
1213 static HRESULT WINAPI OLEFontImpl_GetTypeInfo(
1214 IDispatch* iface,
1215 UINT iTInfo,
1216 LCID lcid,
1217 ITypeInfo** ppTInfo)
1219 static const WCHAR stdole32tlb[] = {'s','t','d','o','l','e','3','2','.','t','l','b',0};
1220 ITypeLib *tl;
1221 HRESULT hres;
1223 _ICOM_THIS_From_IDispatch(OLEFontImpl, iface);
1224 TRACE("(%p, iTInfo=%d, lcid=%04x, %p), unimplemented stub!\n", this, iTInfo, (int)lcid, ppTInfo);
1225 if (iTInfo != 0)
1226 return E_FAIL;
1227 hres = LoadTypeLib(stdole32tlb, &tl);
1228 if (FAILED(hres)) {
1229 FIXME("Could not load the stdole32.tlb?\n");
1230 return hres;
1232 hres = ITypeLib_GetTypeInfoOfGuid(tl, &IID_IDispatch, ppTInfo);
1233 if (FAILED(hres)) {
1234 FIXME("Did not IDispatch typeinfo from typelib, hres %lx\n",hres);
1236 return hres;
1239 /************************************************************************
1240 * OLEFontImpl_GetIDsOfNames (IDispatch)
1242 * See Windows documentation for more details on IDispatch methods.
1244 static HRESULT WINAPI OLEFontImpl_GetIDsOfNames(
1245 IDispatch* iface,
1246 REFIID riid,
1247 LPOLESTR* rgszNames,
1248 UINT cNames,
1249 LCID lcid,
1250 DISPID* rgDispId)
1252 _ICOM_THIS_From_IDispatch(IFont, iface);
1253 FIXME("(%p,%s,%p,%d,%04x,%p), stub!\n", this, debugstr_guid(riid), rgszNames,
1254 cNames, (int)lcid, rgDispId
1256 return E_NOTIMPL;
1259 /************************************************************************
1260 * OLEFontImpl_Invoke (IDispatch)
1262 * See Windows documentation for more details on IDispatch methods.
1264 * Note: Do not call _put_Xxx methods, since setting things here
1265 * should not call notify functions as I found out debugging the generic
1266 * MS VB5 installer.
1268 static HRESULT WINAPI OLEFontImpl_Invoke(
1269 IDispatch* iface,
1270 DISPID dispIdMember,
1271 REFIID riid,
1272 LCID lcid,
1273 WORD wFlags,
1274 DISPPARAMS* pDispParams,
1275 VARIANT* pVarResult,
1276 EXCEPINFO* pExepInfo,
1277 UINT* puArgErr)
1279 _ICOM_THIS_From_IDispatch(IFont, iface);
1280 OLEFontImpl *xthis = (OLEFontImpl*)this;
1282 switch (dispIdMember) {
1283 case DISPID_FONT_NAME:
1284 switch (wFlags) {
1285 case DISPATCH_PROPERTYGET:
1286 case DISPATCH_PROPERTYGET|DISPATCH_METHOD:
1287 V_VT(pVarResult) = VT_BSTR;
1288 return OLEFontImpl_get_Name(this, &V_BSTR(pVarResult));
1289 case DISPATCH_PROPERTYPUT: {
1290 BSTR name = V_BSTR(&pDispParams->rgvarg[0]);
1291 if (V_VT(&pDispParams->rgvarg[0])!=VT_BSTR) {
1292 FIXME("property put of Name, vt is not VT_BSTR but %d\n",V_VT(&pDispParams->rgvarg[0]));
1293 return E_FAIL;
1295 if (!xthis->description.lpstrName)
1296 xthis->description.lpstrName = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(name)+1) * sizeof(WCHAR));
1297 else
1298 xthis->description.lpstrName = HeapReAlloc(GetProcessHeap(), 0, xthis->description.lpstrName, (lstrlenW(name)+1) * sizeof(WCHAR));
1300 if (xthis->description.lpstrName==0)
1301 return E_OUTOFMEMORY;
1302 strcpyW(xthis->description.lpstrName, name);
1303 return S_OK;
1306 break;
1307 case DISPID_FONT_BOLD:
1308 switch (wFlags) {
1309 case DISPATCH_PROPERTYGET:
1310 case DISPATCH_PROPERTYGET|DISPATCH_METHOD:
1311 V_VT(pVarResult) = VT_BOOL;
1312 return OLEFontImpl_get_Bold(this, (BOOL*)&V_BOOL(pVarResult));
1313 case DISPATCH_PROPERTYPUT:
1314 if (V_VT(&pDispParams->rgvarg[0]) != VT_BOOL) {
1315 FIXME("DISPID_FONT_BOLD/put, vt is %d, not VT_BOOL.\n",V_VT(&pDispParams->rgvarg[0]));
1316 return E_FAIL;
1317 } else {
1318 xthis->description.sWeight = V_BOOL(&pDispParams->rgvarg[0]) ? FW_BOLD : FW_NORMAL;
1319 return S_OK;
1322 break;
1323 case DISPID_FONT_ITALIC:
1324 switch (wFlags) {
1325 case DISPATCH_PROPERTYGET:
1326 case DISPATCH_PROPERTYGET|DISPATCH_METHOD:
1327 V_VT(pVarResult) = VT_BOOL;
1328 return OLEFontImpl_get_Italic(this, (BOOL*)&V_BOOL(pVarResult));
1329 case DISPATCH_PROPERTYPUT:
1330 if (V_VT(&pDispParams->rgvarg[0]) != VT_BOOL) {
1331 FIXME("DISPID_FONT_ITALIC/put, vt is %d, not VT_BOOL.\n",V_VT(&pDispParams->rgvarg[0]));
1332 return E_FAIL;
1333 } else {
1334 xthis->description.fItalic = V_BOOL(&pDispParams->rgvarg[0]);
1335 return S_OK;
1338 break;
1339 case DISPID_FONT_UNDER:
1340 switch (wFlags) {
1341 case DISPATCH_PROPERTYGET:
1342 case DISPATCH_PROPERTYGET|DISPATCH_METHOD:
1343 V_VT(pVarResult) = VT_BOOL;
1344 return OLEFontImpl_get_Underline(this, (BOOL*)&V_BOOL(pVarResult));
1345 case DISPATCH_PROPERTYPUT:
1346 if (V_VT(&pDispParams->rgvarg[0]) != VT_BOOL) {
1347 FIXME("DISPID_FONT_UNDER/put, vt is %d, not VT_BOOL.\n",V_VT(&pDispParams->rgvarg[0]));
1348 return E_FAIL;
1349 } else {
1350 xthis->description.fUnderline = V_BOOL(&pDispParams->rgvarg[0]);
1351 return S_OK;
1354 break;
1355 case DISPID_FONT_STRIKE:
1356 switch (wFlags) {
1357 case DISPATCH_PROPERTYGET:
1358 case DISPATCH_PROPERTYGET|DISPATCH_METHOD:
1359 V_VT(pVarResult) = VT_BOOL;
1360 return OLEFontImpl_get_Strikethrough(this, (BOOL*)&V_BOOL(pVarResult));
1361 case DISPATCH_PROPERTYPUT:
1362 if (V_VT(&pDispParams->rgvarg[0]) != VT_BOOL) {
1363 FIXME("DISPID_FONT_STRIKE/put, vt is %d, not VT_BOOL.\n",V_VT(&pDispParams->rgvarg[0]));
1364 return E_FAIL;
1365 } else {
1366 xthis->description.fStrikethrough = V_BOOL(&pDispParams->rgvarg[0]);
1367 return S_OK;
1370 break;
1371 case DISPID_FONT_SIZE:
1372 switch (wFlags) {
1373 case DISPATCH_PROPERTYPUT: {
1374 assert (pDispParams->cArgs == 1);
1375 xthis->description.cySize.s.Hi = 0;
1376 if (V_VT(&pDispParams->rgvarg[0]) != VT_CY) {
1377 if (V_VT(&pDispParams->rgvarg[0]) == VT_I2) {
1378 xthis->description.cySize.s.Lo = V_I2(&pDispParams->rgvarg[0]) * 10000;
1379 } else {
1380 FIXME("property put for Size with vt %d unsupported!\n",V_VT(&pDispParams->rgvarg[0]));
1382 } else {
1383 xthis->description.cySize.s.Lo = V_CY(&pDispParams->rgvarg[0]).s.Lo;
1385 return S_OK;
1387 case DISPATCH_PROPERTYGET:
1388 case DISPATCH_PROPERTYGET|DISPATCH_METHOD:
1389 V_VT(pVarResult) = VT_CY;
1390 return OLEFontImpl_get_Size(this, &V_CY(pVarResult));
1392 break;
1393 case DISPID_FONT_CHARSET:
1394 switch (wFlags) {
1395 case DISPATCH_PROPERTYPUT:
1396 assert (pDispParams->cArgs == 1);
1397 if (V_VT(&pDispParams->rgvarg[0]) != VT_I2)
1398 FIXME("varg of first disparg is not VT_I2, but %d\n",V_VT(&pDispParams->rgvarg[0]));
1399 xthis->description.sCharset = V_I2(&pDispParams->rgvarg[0]);
1400 return S_OK;
1401 case DISPATCH_PROPERTYGET:
1402 case DISPATCH_PROPERTYGET|DISPATCH_METHOD:
1403 V_VT(pVarResult) = VT_I2;
1404 return OLEFontImpl_get_Charset(this, &V_I2(pVarResult));
1406 break;
1408 FIXME("%p->(%ld,%s,%lx,%x,%p,%p,%p,%p), unhandled dispid/flag!\n",
1409 this,dispIdMember,debugstr_guid(riid),lcid,
1410 wFlags,pDispParams,pVarResult,pExepInfo,puArgErr
1412 return S_OK;
1415 /************************************************************************
1416 * OLEFontImpl_IPersistStream_QueryInterface (IUnknown)
1418 * See Windows documentation for more details on IUnknown methods.
1420 static HRESULT WINAPI OLEFontImpl_IPersistStream_QueryInterface(
1421 IPersistStream* iface,
1422 REFIID riid,
1423 VOID** ppvoid)
1425 _ICOM_THIS_From_IPersistStream(IFont, iface);
1427 return IFont_QueryInterface(this, riid, ppvoid);
1430 /************************************************************************
1431 * OLEFontImpl_IPersistStream_Release (IUnknown)
1433 * See Windows documentation for more details on IUnknown methods.
1435 static ULONG WINAPI OLEFontImpl_IPersistStream_Release(
1436 IPersistStream* iface)
1438 _ICOM_THIS_From_IPersistStream(IFont, iface);
1440 return IFont_Release(this);
1443 /************************************************************************
1444 * OLEFontImpl_IPersistStream_AddRef (IUnknown)
1446 * See Windows documentation for more details on IUnknown methods.
1448 static ULONG WINAPI OLEFontImpl_IPersistStream_AddRef(
1449 IPersistStream* iface)
1451 _ICOM_THIS_From_IPersistStream(IFont, iface);
1453 return IFont_AddRef(this);
1456 /************************************************************************
1457 * OLEFontImpl_GetClassID (IPersistStream)
1459 * See Windows documentation for more details on IPersistStream methods.
1461 static HRESULT WINAPI OLEFontImpl_GetClassID(
1462 IPersistStream* iface,
1463 CLSID* pClassID)
1465 TRACE("(%p,%p)\n",iface,pClassID);
1466 if (pClassID==0)
1467 return E_POINTER;
1469 memcpy(pClassID, &CLSID_StdFont, sizeof(CLSID_StdFont));
1471 return S_OK;
1474 /************************************************************************
1475 * OLEFontImpl_IsDirty (IPersistStream)
1477 * See Windows documentation for more details on IPersistStream methods.
1479 static HRESULT WINAPI OLEFontImpl_IsDirty(
1480 IPersistStream* iface)
1482 TRACE("(%p)\n",iface);
1483 return S_OK;
1486 /************************************************************************
1487 * OLEFontImpl_Load (IPersistStream)
1489 * See Windows documentation for more details on IPersistStream methods.
1491 * This is the format of the standard font serialization as far as I
1492 * know
1494 * Offset Type Value Comment
1495 * 0x0000 Byte Unknown Probably a version number, contains 0x01
1496 * 0x0001 Short Charset Charset value from the FONTDESC structure
1497 * 0x0003 Byte Attributes Flags defined as follows:
1498 * 00000010 - Italic
1499 * 00000100 - Underline
1500 * 00001000 - Strikethrough
1501 * 0x0004 Short Weight Weight value from FONTDESC structure
1502 * 0x0006 DWORD size "Low" portion of the cySize member of the FONTDESC
1503 * structure/
1504 * 0x000A Byte name length Length of the font name string (no null character)
1505 * 0x000B String name Name of the font (ASCII, no nul character)
1507 static HRESULT WINAPI OLEFontImpl_Load(
1508 IPersistStream* iface,
1509 IStream* pLoadStream)
1511 char readBuffer[0x100];
1512 ULONG cbRead;
1513 BYTE bVersion;
1514 BYTE bAttributes;
1515 BYTE bStringSize;
1516 INT len;
1518 _ICOM_THIS_From_IPersistStream(OLEFontImpl, iface);
1521 * Read the version byte
1523 IStream_Read(pLoadStream, &bVersion, 1, &cbRead);
1525 if ( (cbRead!=1) ||
1526 (bVersion!=0x01) )
1527 return E_FAIL;
1530 * Charset
1532 IStream_Read(pLoadStream, &this->description.sCharset, 2, &cbRead);
1534 if (cbRead!=2)
1535 return E_FAIL;
1538 * Attributes
1540 IStream_Read(pLoadStream, &bAttributes, 1, &cbRead);
1542 if (cbRead!=1)
1543 return E_FAIL;
1545 this->description.fItalic = (bAttributes & FONTPERSIST_ITALIC) != 0;
1546 this->description.fStrikethrough = (bAttributes & FONTPERSIST_STRIKETHROUGH) != 0;
1547 this->description.fUnderline = (bAttributes & FONTPERSIST_UNDERLINE) != 0;
1550 * Weight
1552 IStream_Read(pLoadStream, &this->description.sWeight, 2, &cbRead);
1554 if (cbRead!=2)
1555 return E_FAIL;
1558 * Size
1560 IStream_Read(pLoadStream, &this->description.cySize.s.Lo, 4, &cbRead);
1562 if (cbRead!=4)
1563 return E_FAIL;
1565 this->description.cySize.s.Hi = 0;
1568 * FontName
1570 IStream_Read(pLoadStream, &bStringSize, 1, &cbRead);
1572 if (cbRead!=1)
1573 return E_FAIL;
1575 IStream_Read(pLoadStream, readBuffer, bStringSize, &cbRead);
1577 if (cbRead!=bStringSize)
1578 return E_FAIL;
1580 if (this->description.lpstrName!=0)
1581 HeapFree(GetProcessHeap(), 0, this->description.lpstrName);
1583 len = MultiByteToWideChar( CP_ACP, 0, readBuffer, bStringSize, NULL, 0 );
1584 this->description.lpstrName = HeapAlloc( GetProcessHeap(), 0, (len+1) * sizeof(WCHAR) );
1585 MultiByteToWideChar( CP_ACP, 0, readBuffer, bStringSize, this->description.lpstrName, len );
1586 this->description.lpstrName[len] = 0;
1588 /* Ensure use of this font causes a new one to be created @@@@ */
1589 DeleteObject(this->gdiFont);
1590 this->gdiFont = 0;
1592 return S_OK;
1595 /************************************************************************
1596 * OLEFontImpl_Save (IPersistStream)
1598 * See Windows documentation for more details on IPersistStream methods.
1600 static HRESULT WINAPI OLEFontImpl_Save(
1601 IPersistStream* iface,
1602 IStream* pOutStream,
1603 BOOL fClearDirty)
1605 char* writeBuffer = NULL;
1606 ULONG cbWritten;
1607 BYTE bVersion = 0x01;
1608 BYTE bAttributes;
1609 BYTE bStringSize;
1611 _ICOM_THIS_From_IPersistStream(OLEFontImpl, iface);
1614 * Read the version byte
1616 IStream_Write(pOutStream, &bVersion, 1, &cbWritten);
1618 if (cbWritten!=1)
1619 return E_FAIL;
1622 * Charset
1624 IStream_Write(pOutStream, &this->description.sCharset, 2, &cbWritten);
1626 if (cbWritten!=2)
1627 return E_FAIL;
1630 * Attributes
1632 bAttributes = 0;
1634 if (this->description.fItalic)
1635 bAttributes |= FONTPERSIST_ITALIC;
1637 if (this->description.fStrikethrough)
1638 bAttributes |= FONTPERSIST_STRIKETHROUGH;
1640 if (this->description.fUnderline)
1641 bAttributes |= FONTPERSIST_UNDERLINE;
1643 IStream_Write(pOutStream, &bAttributes, 1, &cbWritten);
1645 if (cbWritten!=1)
1646 return E_FAIL;
1649 * Weight
1651 IStream_Write(pOutStream, &this->description.sWeight, 2, &cbWritten);
1653 if (cbWritten!=2)
1654 return E_FAIL;
1657 * Size
1659 IStream_Write(pOutStream, &this->description.cySize.s.Lo, 4, &cbWritten);
1661 if (cbWritten!=4)
1662 return E_FAIL;
1665 * FontName
1667 if (this->description.lpstrName!=0)
1668 bStringSize = WideCharToMultiByte( CP_ACP, 0, this->description.lpstrName,
1669 strlenW(this->description.lpstrName), NULL, 0, NULL, NULL );
1670 else
1671 bStringSize = 0;
1673 IStream_Write(pOutStream, &bStringSize, 1, &cbWritten);
1675 if (cbWritten!=1)
1676 return E_FAIL;
1678 if (bStringSize!=0)
1680 if (!(writeBuffer = HeapAlloc( GetProcessHeap(), 0, bStringSize ))) return E_OUTOFMEMORY;
1681 WideCharToMultiByte( CP_ACP, 0, this->description.lpstrName,
1682 strlenW(this->description.lpstrName),
1683 writeBuffer, bStringSize, NULL, NULL );
1685 IStream_Write(pOutStream, writeBuffer, bStringSize, &cbWritten);
1686 HeapFree(GetProcessHeap(), 0, writeBuffer);
1688 if (cbWritten!=bStringSize)
1689 return E_FAIL;
1692 return S_OK;
1695 /************************************************************************
1696 * OLEFontImpl_GetSizeMax (IPersistStream)
1698 * See Windows documentation for more details on IPersistStream methods.
1700 static HRESULT WINAPI OLEFontImpl_GetSizeMax(
1701 IPersistStream* iface,
1702 ULARGE_INTEGER* pcbSize)
1704 _ICOM_THIS_From_IPersistStream(OLEFontImpl, iface);
1706 if (pcbSize==NULL)
1707 return E_POINTER;
1709 pcbSize->u.HighPart = 0;
1710 pcbSize->u.LowPart = 0;
1712 pcbSize->u.LowPart += sizeof(BYTE); /* Version */
1713 pcbSize->u.LowPart += sizeof(WORD); /* Lang code */
1714 pcbSize->u.LowPart += sizeof(BYTE); /* Flags */
1715 pcbSize->u.LowPart += sizeof(WORD); /* Weight */
1716 pcbSize->u.LowPart += sizeof(DWORD); /* Size */
1717 pcbSize->u.LowPart += sizeof(BYTE); /* StrLength */
1719 if (this->description.lpstrName!=0)
1720 pcbSize->u.LowPart += lstrlenW(this->description.lpstrName);
1722 return S_OK;
1725 /************************************************************************
1726 * OLEFontImpl_IConnectionPointContainer_QueryInterface (IUnknown)
1728 * See Windows documentation for more details on IUnknown methods.
1730 static HRESULT WINAPI OLEFontImpl_IConnectionPointContainer_QueryInterface(
1731 IConnectionPointContainer* iface,
1732 REFIID riid,
1733 VOID** ppvoid)
1735 _ICOM_THIS_From_IConnectionPointContainer(OLEFontImpl, iface);
1737 return IFont_QueryInterface((IFont*)this, riid, ppvoid);
1740 /************************************************************************
1741 * OLEFontImpl_IConnectionPointContainer_Release (IUnknown)
1743 * See Windows documentation for more details on IUnknown methods.
1745 static ULONG WINAPI OLEFontImpl_IConnectionPointContainer_Release(
1746 IConnectionPointContainer* iface)
1748 _ICOM_THIS_From_IConnectionPointContainer(OLEFontImpl, iface);
1750 return IFont_Release((IFont*)this);
1753 /************************************************************************
1754 * OLEFontImpl_IConnectionPointContainer_AddRef (IUnknown)
1756 * See Windows documentation for more details on IUnknown methods.
1758 static ULONG WINAPI OLEFontImpl_IConnectionPointContainer_AddRef(
1759 IConnectionPointContainer* iface)
1761 _ICOM_THIS_From_IConnectionPointContainer(OLEFontImpl, iface);
1763 return IFont_AddRef((IFont*)this);
1766 /************************************************************************
1767 * OLEFontImpl_EnumConnectionPoints (IConnectionPointContainer)
1769 * See Windows documentation for more details on IConnectionPointContainer
1770 * methods.
1772 static HRESULT WINAPI OLEFontImpl_EnumConnectionPoints(
1773 IConnectionPointContainer* iface,
1774 IEnumConnectionPoints **ppEnum)
1776 _ICOM_THIS_From_IConnectionPointContainer(OLEFontImpl, iface);
1778 FIXME("(%p)->(%p): stub\n", this, ppEnum);
1779 return E_NOTIMPL;
1782 /************************************************************************
1783 * OLEFontImpl_FindConnectionPoint (IConnectionPointContainer)
1785 * See Windows documentation for more details on IConnectionPointContainer
1786 * methods.
1788 static HRESULT WINAPI OLEFontImpl_FindConnectionPoint(
1789 IConnectionPointContainer* iface,
1790 REFIID riid,
1791 IConnectionPoint **ppCp)
1793 _ICOM_THIS_From_IConnectionPointContainer(OLEFontImpl, iface);
1794 TRACE("(%p)->(%s, %p): stub\n", this, debugstr_guid(riid), ppCp);
1796 if(memcmp(riid, &IID_IPropertyNotifySink, sizeof(IID_IPropertyNotifySink)) == 0) {
1797 return IConnectionPoint_QueryInterface(this->pCP, &IID_IConnectionPoint,
1798 (LPVOID)ppCp);
1799 } else {
1800 FIXME("Tried to find connection point on %s\n", debugstr_guid(riid));
1801 return E_NOINTERFACE;
1805 /************************************************************************
1806 * OLEFontImpl implementation of IPersistPropertyBag.
1808 static HRESULT WINAPI OLEFontImpl_IPersistPropertyBag_QueryInterface(
1809 IPersistPropertyBag *iface, REFIID riid, LPVOID *ppvObj
1811 _ICOM_THIS_From_IPersistPropertyBag(IFont, iface);
1812 return IFont_QueryInterface(this,riid,ppvObj);
1815 static ULONG WINAPI OLEFontImpl_IPersistPropertyBag_AddRef(
1816 IPersistPropertyBag *iface
1818 _ICOM_THIS_From_IPersistPropertyBag(IFont, iface);
1819 return IFont_AddRef(this);
1822 static ULONG WINAPI OLEFontImpl_IPersistPropertyBag_Release(
1823 IPersistPropertyBag *iface
1825 _ICOM_THIS_From_IPersistPropertyBag(IFont, iface);
1826 return IFont_Release(this);
1829 static HRESULT WINAPI OLEFontImpl_IPersistPropertyBag_GetClassID(
1830 IPersistPropertyBag *iface, CLSID *classid
1832 FIXME("(%p,%p), stub!\n", iface, classid);
1833 return E_FAIL;
1836 static HRESULT WINAPI OLEFontImpl_IPersistPropertyBag_InitNew(
1837 IPersistPropertyBag *iface
1839 FIXME("(%p), stub!\n", iface);
1840 return S_OK;
1843 static HRESULT WINAPI OLEFontImpl_IPersistPropertyBag_Load(
1844 IPersistPropertyBag *iface, IPropertyBag* pPropBag, IErrorLog* pErrorLog
1846 /* (from Visual Basic 6 property bag)
1847 Name = "MS Sans Serif"
1848 Size = 13.8
1849 Charset = 0
1850 Weight = 400
1851 Underline = 0 'False
1852 Italic = 0 'False
1853 Strikethrough = 0 'False
1855 static const WCHAR sAttrName[] = {'N','a','m','e',0};
1856 static const WCHAR sAttrSize[] = {'S','i','z','e',0};
1857 static const WCHAR sAttrCharset[] = {'C','h','a','r','s','e','t',0};
1858 static const WCHAR sAttrWeight[] = {'W','e','i','g','h','t',0};
1859 static const WCHAR sAttrUnderline[] = {'U','n','d','e','r','l','i','n','e',0};
1860 static const WCHAR sAttrItalic[] = {'I','t','a','l','i','c',0};
1861 static const WCHAR sAttrStrikethrough[] = {'S','t','r','i','k','e','t','h','r','o','u','g','h',0};
1862 VARIANT rawAttr;
1863 VARIANT valueAttr;
1864 HRESULT iRes = S_OK;
1865 _ICOM_THIS_From_IPersistPropertyBag(IFont, iface);
1867 VariantInit(&rawAttr);
1868 VariantInit(&valueAttr);
1870 if (iRes == S_OK) {
1871 iRes = IPropertyBag_Read(pPropBag, sAttrName, &rawAttr, pErrorLog);
1872 if (iRes == S_OK)
1874 iRes = VariantChangeType(&rawAttr, &valueAttr, 0, VT_BSTR);
1875 if (iRes == S_OK)
1876 iRes = IFont_put_Name(this, V_BSTR(&valueAttr));
1878 else if (iRes == E_INVALIDARG)
1879 iRes = S_OK;
1880 VariantClear(&rawAttr);
1881 VariantClear(&valueAttr);
1884 if (iRes == S_OK) {
1885 iRes = IPropertyBag_Read(pPropBag, sAttrSize, &rawAttr, pErrorLog);
1886 if (iRes == S_OK)
1888 iRes = VariantChangeType(&rawAttr, &valueAttr, 0, VT_CY);
1889 if (iRes == S_OK)
1890 iRes = IFont_put_Size(this, V_CY(&valueAttr));
1892 else if (iRes == E_INVALIDARG)
1893 iRes = S_OK;
1894 VariantClear(&rawAttr);
1895 VariantClear(&valueAttr);
1898 if (iRes == S_OK) {
1899 iRes = IPropertyBag_Read(pPropBag, sAttrCharset, &rawAttr, pErrorLog);
1900 if (iRes == S_OK)
1902 iRes = VariantChangeType(&rawAttr, &valueAttr, 0, VT_I2);
1903 if (iRes == S_OK)
1904 iRes = IFont_put_Charset(this, V_I2(&valueAttr));
1906 else if (iRes == E_INVALIDARG)
1907 iRes = S_OK;
1908 VariantClear(&rawAttr);
1909 VariantClear(&valueAttr);
1912 if (iRes == S_OK) {
1913 iRes = IPropertyBag_Read(pPropBag, sAttrWeight, &rawAttr, pErrorLog);
1914 if (iRes == S_OK)
1916 iRes = VariantChangeType(&rawAttr, &valueAttr, 0, VT_I2);
1917 if (iRes == S_OK)
1918 iRes = IFont_put_Weight(this, V_I2(&valueAttr));
1920 else if (iRes == E_INVALIDARG)
1921 iRes = S_OK;
1922 VariantClear(&rawAttr);
1923 VariantClear(&valueAttr);
1927 if (iRes == S_OK) {
1928 iRes = IPropertyBag_Read(pPropBag, sAttrUnderline, &rawAttr, pErrorLog);
1929 if (iRes == S_OK)
1931 iRes = VariantChangeType(&rawAttr, &valueAttr, 0, VT_BOOL);
1932 if (iRes == S_OK)
1933 iRes = IFont_put_Underline(this, V_BOOL(&valueAttr));
1935 else if (iRes == E_INVALIDARG)
1936 iRes = S_OK;
1937 VariantClear(&rawAttr);
1938 VariantClear(&valueAttr);
1941 if (iRes == S_OK) {
1942 iRes = IPropertyBag_Read(pPropBag, sAttrItalic, &rawAttr, pErrorLog);
1943 if (iRes == S_OK)
1945 iRes = VariantChangeType(&rawAttr, &valueAttr, 0, VT_BOOL);
1946 if (iRes == S_OK)
1947 iRes = IFont_put_Italic(this, V_BOOL(&valueAttr));
1949 else if (iRes == E_INVALIDARG)
1950 iRes = S_OK;
1951 VariantClear(&rawAttr);
1952 VariantClear(&valueAttr);
1955 if (iRes == S_OK) {
1956 iRes = IPropertyBag_Read(pPropBag, sAttrStrikethrough, &rawAttr, pErrorLog);
1957 if (iRes == S_OK)
1959 iRes = VariantChangeType(&rawAttr, &valueAttr, 0, VT_BOOL);
1960 if (iRes == S_OK)
1961 IFont_put_Strikethrough(this, V_BOOL(&valueAttr));
1963 else if (iRes == E_INVALIDARG)
1964 iRes = S_OK;
1965 VariantClear(&rawAttr);
1966 VariantClear(&valueAttr);
1969 if (FAILED(iRes))
1970 WARN("-- 0x%08lx\n", iRes);
1971 return iRes;
1974 static HRESULT WINAPI OLEFontImpl_IPersistPropertyBag_Save(
1975 IPersistPropertyBag *iface, IPropertyBag* pPropBag, BOOL fClearDirty,
1976 BOOL fSaveAllProperties
1978 FIXME("(%p,%p,%d,%d), stub!\n", iface, pPropBag, fClearDirty, fSaveAllProperties);
1979 return E_FAIL;
1982 static IPersistPropertyBagVtbl OLEFontImpl_IPersistPropertyBag_VTable =
1984 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
1985 OLEFontImpl_IPersistPropertyBag_QueryInterface,
1986 OLEFontImpl_IPersistPropertyBag_AddRef,
1987 OLEFontImpl_IPersistPropertyBag_Release,
1989 OLEFontImpl_IPersistPropertyBag_GetClassID,
1990 OLEFontImpl_IPersistPropertyBag_InitNew,
1991 OLEFontImpl_IPersistPropertyBag_Load,
1992 OLEFontImpl_IPersistPropertyBag_Save
1995 /************************************************************************
1996 * OLEFontImpl implementation of IPersistStreamInit.
1998 static HRESULT WINAPI OLEFontImpl_IPersistStreamInit_QueryInterface(
1999 IPersistStreamInit *iface, REFIID riid, LPVOID *ppvObj
2001 _ICOM_THIS_From_IPersistStreamInit(IFont, iface);
2002 return IFont_QueryInterface(this,riid,ppvObj);
2005 static ULONG WINAPI OLEFontImpl_IPersistStreamInit_AddRef(
2006 IPersistStreamInit *iface
2008 _ICOM_THIS_From_IPersistStreamInit(IFont, iface);
2009 return IFont_AddRef(this);
2012 static ULONG WINAPI OLEFontImpl_IPersistStreamInit_Release(
2013 IPersistStreamInit *iface
2015 _ICOM_THIS_From_IPersistStreamInit(IFont, iface);
2016 return IFont_Release(this);
2019 static HRESULT WINAPI OLEFontImpl_IPersistStreamInit_GetClassID(
2020 IPersistStreamInit *iface, CLSID *classid
2022 FIXME("(%p,%p), stub!\n", iface, classid);
2023 return E_FAIL;
2026 static HRESULT WINAPI OLEFontImpl_IPersistStreamInit_IsDirty(
2027 IPersistStreamInit *iface
2029 FIXME("(%p), stub!\n", iface);
2030 return E_FAIL;
2033 static HRESULT WINAPI OLEFontImpl_IPersistStreamInit_Load(
2034 IPersistStreamInit *iface, LPSTREAM pStm
2036 FIXME("(%p,%p), stub!\n", iface, pStm);
2037 return E_FAIL;
2040 static HRESULT WINAPI OLEFontImpl_IPersistStreamInit_Save(
2041 IPersistStreamInit *iface, LPSTREAM pStm, BOOL fClearDirty
2043 FIXME("(%p,%p,%d), stub!\n", iface, pStm, fClearDirty);
2044 return E_FAIL;
2047 static HRESULT WINAPI OLEFontImpl_IPersistStreamInit_GetSizeMax(
2048 IPersistStreamInit *iface, ULARGE_INTEGER *pcbSize
2050 FIXME("(%p,%p), stub!\n", iface, pcbSize);
2051 return E_FAIL;
2054 static HRESULT WINAPI OLEFontImpl_IPersistStreamInit_InitNew(
2055 IPersistStreamInit *iface
2057 FIXME("(%p), stub!\n", iface);
2058 return S_OK;
2061 static IPersistStreamInitVtbl OLEFontImpl_IPersistStreamInit_VTable =
2063 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
2064 OLEFontImpl_IPersistStreamInit_QueryInterface,
2065 OLEFontImpl_IPersistStreamInit_AddRef,
2066 OLEFontImpl_IPersistStreamInit_Release,
2068 OLEFontImpl_IPersistStreamInit_GetClassID,
2069 OLEFontImpl_IPersistStreamInit_IsDirty,
2070 OLEFontImpl_IPersistStreamInit_Load,
2071 OLEFontImpl_IPersistStreamInit_Save,
2072 OLEFontImpl_IPersistStreamInit_GetSizeMax,
2073 OLEFontImpl_IPersistStreamInit_InitNew
2076 /*******************************************************************************
2077 * StdFont ClassFactory
2079 typedef struct
2081 /* IUnknown fields */
2082 IClassFactoryVtbl *lpVtbl;
2083 DWORD ref;
2084 } IClassFactoryImpl;
2086 static HRESULT WINAPI
2087 SFCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
2088 ICOM_THIS(IClassFactoryImpl,iface);
2090 FIXME("(%p)->(%s,%p),stub!\n",This,debugstr_guid(riid),ppobj);
2091 return E_NOINTERFACE;
2094 static ULONG WINAPI
2095 SFCF_AddRef(LPCLASSFACTORY iface) {
2096 ICOM_THIS(IClassFactoryImpl,iface);
2097 return ++(This->ref);
2100 static ULONG WINAPI SFCF_Release(LPCLASSFACTORY iface) {
2101 ICOM_THIS(IClassFactoryImpl,iface);
2102 /* static class, won't be freed */
2103 return --(This->ref);
2106 static HRESULT WINAPI SFCF_CreateInstance(
2107 LPCLASSFACTORY iface,LPUNKNOWN pOuter,REFIID riid,LPVOID *ppobj
2109 return OleCreateFontIndirect(NULL,riid,ppobj);
2113 static HRESULT WINAPI SFCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
2114 ICOM_THIS(IClassFactoryImpl,iface);
2115 FIXME("(%p)->(%d),stub!\n",This,dolock);
2116 return S_OK;
2119 static IClassFactoryVtbl SFCF_Vtbl = {
2120 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
2121 SFCF_QueryInterface,
2122 SFCF_AddRef,
2123 SFCF_Release,
2124 SFCF_CreateInstance,
2125 SFCF_LockServer
2127 static IClassFactoryImpl STDFONT_CF = {&SFCF_Vtbl, 1 };
2129 void _get_STDFONT_CF(LPVOID *ppv) { *ppv = (LPVOID)&STDFONT_CF; }