Get rid of the non-standard ICOM_THIS macro.
[wine.git] / dlls / oleaut32 / olefont.c
bloba4bd9938b48031cfe8a0914c8ac815a427e33cd8
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_From_IDispatch(class, name) class* this = (class*)(((char*)name)-sizeof(void*))
108 #define _ICOM_THIS_From_IPersistStream(class, name) class* this = (class*)(((char*)name)-2*sizeof(void*))
109 #define _ICOM_THIS_From_IConnectionPointContainer(class, name) class* this = (class*)(((char*)name)-3*sizeof(void*))
110 #define _ICOM_THIS_From_IPersistPropertyBag(class, name) class* this = (class*)(((char*)name)-4*sizeof(void*))
111 #define _ICOM_THIS_From_IPersistStreamInit(class, name) class* this = (class*)(((char*)name)-5*sizeof(void*))
114 /***********************************************************************
115 * Prototypes for the implementation functions for the IFont
116 * interface
118 static OLEFontImpl* OLEFontImpl_Construct(LPFONTDESC fontDesc);
119 static void OLEFontImpl_Destroy(OLEFontImpl* fontDesc);
120 static HRESULT WINAPI OLEFontImpl_QueryInterface(IFont* iface, REFIID riid, VOID** ppvoid);
121 static ULONG WINAPI OLEFontImpl_AddRef(IFont* iface);
122 static ULONG WINAPI OLEFontImpl_Release(IFont* iface);
123 static HRESULT WINAPI OLEFontImpl_get_Name(IFont* iface, BSTR* pname);
124 static HRESULT WINAPI OLEFontImpl_put_Name(IFont* iface, BSTR name);
125 static HRESULT WINAPI OLEFontImpl_get_Size(IFont* iface, CY* psize);
126 static HRESULT WINAPI OLEFontImpl_put_Size(IFont* iface, CY size);
127 static HRESULT WINAPI OLEFontImpl_get_Bold(IFont* iface, BOOL* pbold);
128 static HRESULT WINAPI OLEFontImpl_put_Bold(IFont* iface, BOOL bold);
129 static HRESULT WINAPI OLEFontImpl_get_Italic(IFont* iface, BOOL* pitalic);
130 static HRESULT WINAPI OLEFontImpl_put_Italic(IFont* iface, BOOL italic);
131 static HRESULT WINAPI OLEFontImpl_get_Underline(IFont* iface, BOOL* punderline);
132 static HRESULT WINAPI OLEFontImpl_put_Underline(IFont* iface, BOOL underline);
133 static HRESULT WINAPI OLEFontImpl_get_Strikethrough(IFont* iface, BOOL* pstrikethrough);
134 static HRESULT WINAPI OLEFontImpl_put_Strikethrough(IFont* iface, BOOL strikethrough);
135 static HRESULT WINAPI OLEFontImpl_get_Weight(IFont* iface, short* pweight);
136 static HRESULT WINAPI OLEFontImpl_put_Weight(IFont* iface, short weight);
137 static HRESULT WINAPI OLEFontImpl_get_Charset(IFont* iface, short* pcharset);
138 static HRESULT WINAPI OLEFontImpl_put_Charset(IFont* iface, short charset);
139 static HRESULT WINAPI OLEFontImpl_get_hFont(IFont* iface, HFONT* phfont);
140 static HRESULT WINAPI OLEFontImpl_Clone(IFont* iface, IFont** ppfont);
141 static HRESULT WINAPI OLEFontImpl_IsEqual(IFont* iface, IFont* pFontOther);
142 static HRESULT WINAPI OLEFontImpl_SetRatio(IFont* iface, long cyLogical, long cyHimetric);
143 static HRESULT WINAPI OLEFontImpl_QueryTextMetrics(IFont* iface, TEXTMETRICOLE* ptm);
144 static HRESULT WINAPI OLEFontImpl_AddRefHfont(IFont* iface, HFONT hfont);
145 static HRESULT WINAPI OLEFontImpl_ReleaseHfont(IFont* iface, HFONT hfont);
146 static HRESULT WINAPI OLEFontImpl_SetHdc(IFont* iface, HDC hdc);
148 /***********************************************************************
149 * Prototypes for the implementation functions for the IDispatch
150 * interface
152 static HRESULT WINAPI OLEFontImpl_IDispatch_QueryInterface(IDispatch* iface,
153 REFIID riid,
154 VOID** ppvoid);
155 static ULONG WINAPI OLEFontImpl_IDispatch_AddRef(IDispatch* iface);
156 static ULONG WINAPI OLEFontImpl_IDispatch_Release(IDispatch* iface);
157 static HRESULT WINAPI OLEFontImpl_GetTypeInfoCount(IDispatch* iface,
158 unsigned int* pctinfo);
159 static HRESULT WINAPI OLEFontImpl_GetTypeInfo(IDispatch* iface,
160 UINT iTInfo,
161 LCID lcid,
162 ITypeInfo** ppTInfo);
163 static HRESULT WINAPI OLEFontImpl_GetIDsOfNames(IDispatch* iface,
164 REFIID riid,
165 LPOLESTR* rgszNames,
166 UINT cNames,
167 LCID lcid,
168 DISPID* rgDispId);
169 static HRESULT WINAPI OLEFontImpl_Invoke(IDispatch* iface,
170 DISPID dispIdMember,
171 REFIID riid,
172 LCID lcid,
173 WORD wFlags,
174 DISPPARAMS* pDispParams,
175 VARIANT* pVarResult,
176 EXCEPINFO* pExepInfo,
177 UINT* puArgErr);
179 /***********************************************************************
180 * Prototypes for the implementation functions for the IPersistStream
181 * interface
183 static HRESULT WINAPI OLEFontImpl_IPersistStream_QueryInterface(IPersistStream* iface,
184 REFIID riid,
185 VOID** ppvoid);
186 static ULONG WINAPI OLEFontImpl_IPersistStream_AddRef(IPersistStream* iface);
187 static ULONG WINAPI OLEFontImpl_IPersistStream_Release(IPersistStream* iface);
188 static HRESULT WINAPI OLEFontImpl_GetClassID(IPersistStream* iface,
189 CLSID* pClassID);
190 static HRESULT WINAPI OLEFontImpl_IsDirty(IPersistStream* iface);
191 static HRESULT WINAPI OLEFontImpl_Load(IPersistStream* iface,
192 IStream* pLoadStream);
193 static HRESULT WINAPI OLEFontImpl_Save(IPersistStream* iface,
194 IStream* pOutStream,
195 BOOL fClearDirty);
196 static HRESULT WINAPI OLEFontImpl_GetSizeMax(IPersistStream* iface,
197 ULARGE_INTEGER* pcbSize);
199 /***********************************************************************
200 * Prototypes for the implementation functions for the
201 * IConnectionPointContainer interface
203 static HRESULT WINAPI OLEFontImpl_IConnectionPointContainer_QueryInterface(
204 IConnectionPointContainer* iface,
205 REFIID riid,
206 VOID** ppvoid);
207 static ULONG WINAPI OLEFontImpl_IConnectionPointContainer_AddRef(
208 IConnectionPointContainer* iface);
209 static ULONG WINAPI OLEFontImpl_IConnectionPointContainer_Release(
210 IConnectionPointContainer* iface);
211 static HRESULT WINAPI OLEFontImpl_EnumConnectionPoints(
212 IConnectionPointContainer* iface,
213 IEnumConnectionPoints **ppEnum);
214 static HRESULT WINAPI OLEFontImpl_FindConnectionPoint(
215 IConnectionPointContainer* iface,
216 REFIID riid,
217 IConnectionPoint **ppCp);
220 * Virtual function tables for the OLEFontImpl class.
222 static IFontVtbl OLEFontImpl_VTable =
224 OLEFontImpl_QueryInterface,
225 OLEFontImpl_AddRef,
226 OLEFontImpl_Release,
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,
244 OLEFontImpl_Clone,
245 OLEFontImpl_IsEqual,
246 OLEFontImpl_SetRatio,
247 OLEFontImpl_QueryTextMetrics,
248 OLEFontImpl_AddRefHfont,
249 OLEFontImpl_ReleaseHfont,
250 OLEFontImpl_SetHdc
253 static IDispatchVtbl OLEFontImpl_IDispatch_VTable =
255 OLEFontImpl_IDispatch_QueryInterface,
256 OLEFontImpl_IDispatch_AddRef,
257 OLEFontImpl_IDispatch_Release,
258 OLEFontImpl_GetTypeInfoCount,
259 OLEFontImpl_GetTypeInfo,
260 OLEFontImpl_GetIDsOfNames,
261 OLEFontImpl_Invoke
264 static IPersistStreamVtbl OLEFontImpl_IPersistStream_VTable =
266 OLEFontImpl_IPersistStream_QueryInterface,
267 OLEFontImpl_IPersistStream_AddRef,
268 OLEFontImpl_IPersistStream_Release,
269 OLEFontImpl_GetClassID,
270 OLEFontImpl_IsDirty,
271 OLEFontImpl_Load,
272 OLEFontImpl_Save,
273 OLEFontImpl_GetSizeMax
276 static IConnectionPointContainerVtbl
277 OLEFontImpl_IConnectionPointContainer_VTable =
279 OLEFontImpl_IConnectionPointContainer_QueryInterface,
280 OLEFontImpl_IConnectionPointContainer_AddRef,
281 OLEFontImpl_IConnectionPointContainer_Release,
282 OLEFontImpl_EnumConnectionPoints,
283 OLEFontImpl_FindConnectionPoint
286 static IPersistPropertyBagVtbl OLEFontImpl_IPersistPropertyBag_VTable;
287 static IPersistStreamInitVtbl OLEFontImpl_IPersistStreamInit_VTable;
288 /******************************************************************************
289 * OleCreateFontIndirect [OLEAUT32.420]
291 HRESULT WINAPI OleCreateFontIndirect(
292 LPFONTDESC lpFontDesc,
293 REFIID riid,
294 LPVOID* ppvObj)
296 OLEFontImpl* newFont = 0;
297 HRESULT hr = S_OK;
299 TRACE("(%p, %s, %p)\n", lpFontDesc, debugstr_guid(riid), ppvObj);
301 * Sanity check
303 if (ppvObj==0)
304 return E_POINTER;
306 *ppvObj = 0;
308 if (!lpFontDesc) {
309 FONTDESC fd;
311 static const WCHAR fname[] = { 'S','y','s','t','e','m',0 };
313 fd.cbSizeofstruct = sizeof(fd);
314 fd.lpstrName = (WCHAR*)fname;
315 fd.cySize.s.Lo = 80000;
316 fd.cySize.s.Hi = 0;
317 fd.sWeight = 0;
318 fd.sCharset = 0;
319 fd.fItalic = 0;
320 fd.fUnderline = 0;
321 fd.fStrikethrough = 0;
322 lpFontDesc = &fd;
326 * Try to construct a new instance of the class.
328 newFont = OLEFontImpl_Construct(lpFontDesc);
330 if (newFont == 0)
331 return E_OUTOFMEMORY;
334 * Make sure it supports the interface required by the caller.
336 hr = IFont_QueryInterface((IFont*)newFont, riid, ppvObj);
339 * Release the reference obtained in the constructor. If
340 * the QueryInterface was unsuccessful, it will free the class.
342 IFont_Release((IFont*)newFont);
344 return hr;
348 /***********************************************************************
349 * Implementation of the OLEFontImpl class.
352 /***********************************************************************
353 * OLEFont_SendNotify (internal)
355 * Sends notification messages of changed properties to any interested
356 * connections.
358 static void OLEFont_SendNotify(OLEFontImpl* this, DISPID dispID)
360 IEnumConnections *pEnum;
361 CONNECTDATA CD;
362 HRESULT hres;
364 hres = IConnectionPoint_EnumConnections(this->pCP, &pEnum);
365 if (FAILED(hres)) /* When we have 0 connections. */
366 return;
368 while(IEnumConnections_Next(pEnum, 1, &CD, NULL) == S_OK) {
369 IPropertyNotifySink *sink;
371 IUnknown_QueryInterface(CD.pUnk, &IID_IPropertyNotifySink, (LPVOID)&sink);
372 IPropertyNotifySink_OnChanged(sink, dispID);
373 IPropertyNotifySink_Release(sink);
374 IUnknown_Release(CD.pUnk);
376 IEnumConnections_Release(pEnum);
377 return;
380 /************************************************************************
381 * OLEFontImpl_Construct
383 * This method will construct a new instance of the OLEFontImpl
384 * class.
386 * The caller of this method must release the object when it's
387 * done with it.
389 static OLEFontImpl* OLEFontImpl_Construct(LPFONTDESC fontDesc)
391 OLEFontImpl* newObject = 0;
394 * Allocate space for the object.
396 newObject = HeapAlloc(GetProcessHeap(), 0, sizeof(OLEFontImpl));
398 if (newObject==0)
399 return newObject;
402 * Initialize the virtual function table.
404 newObject->lpvtbl1 = &OLEFontImpl_VTable;
405 newObject->lpvtbl2 = &OLEFontImpl_IDispatch_VTable;
406 newObject->lpvtbl3 = &OLEFontImpl_IPersistStream_VTable;
407 newObject->lpvtbl4 = &OLEFontImpl_IConnectionPointContainer_VTable;
408 newObject->lpvtbl5 = &OLEFontImpl_IPersistPropertyBag_VTable;
409 newObject->lpvtbl6 = &OLEFontImpl_IPersistStreamInit_VTable;
412 * Start with one reference count. The caller of this function
413 * must release the interface pointer when it is done.
415 newObject->ref = 1;
418 * Copy the description of the font in the object.
420 assert(fontDesc->cbSizeofstruct >= sizeof(FONTDESC));
422 newObject->description.cbSizeofstruct = sizeof(FONTDESC);
423 newObject->description.lpstrName = HeapAlloc(GetProcessHeap(),
425 (lstrlenW(fontDesc->lpstrName)+1) * sizeof(WCHAR));
426 strcpyW(newObject->description.lpstrName, fontDesc->lpstrName);
427 newObject->description.cySize = fontDesc->cySize;
428 newObject->description.sWeight = fontDesc->sWeight;
429 newObject->description.sCharset = fontDesc->sCharset;
430 newObject->description.fItalic = fontDesc->fItalic;
431 newObject->description.fUnderline = fontDesc->fUnderline;
432 newObject->description.fStrikethrough = fontDesc->fStrikethrough;
435 * Initializing all the other members.
437 newObject->gdiFont = 0;
438 newObject->fontLock = 0;
439 newObject->cyLogical = 72L;
440 newObject->cyHimetric = 2540L;
441 CreateConnectionPoint((IUnknown*)newObject, &IID_IPropertyNotifySink, &newObject->pCP);
442 TRACE("returning %p\n", newObject);
443 return newObject;
446 /************************************************************************
447 * OLEFontImpl_Destroy
449 * This method is called by the Release method when the reference
450 * count goes down to 0. It will free all resources used by
451 * this object.
453 static void OLEFontImpl_Destroy(OLEFontImpl* fontDesc)
455 TRACE("(%p)\n", fontDesc);
457 if (fontDesc->description.lpstrName!=0)
458 HeapFree(GetProcessHeap(), 0, fontDesc->description.lpstrName);
460 if (fontDesc->gdiFont!=0)
461 DeleteObject(fontDesc->gdiFont);
463 HeapFree(GetProcessHeap(), 0, fontDesc);
466 /************************************************************************
467 * OLEFontImpl_QueryInterface (IUnknown)
469 * See Windows documentation for more details on IUnknown methods.
471 HRESULT WINAPI OLEFontImpl_QueryInterface(
472 IFont* iface,
473 REFIID riid,
474 void** ppvObject)
476 OLEFontImpl *this = (OLEFontImpl *)iface;
477 TRACE("(%p)->(%s, %p)\n", this, debugstr_guid(riid), ppvObject);
480 * Perform a sanity check on the parameters.
482 if ( (this==0) || (ppvObject==0) )
483 return E_INVALIDARG;
486 * Initialize the return parameter.
488 *ppvObject = 0;
491 * Compare the riid with the interface IDs implemented by this object.
493 if (IsEqualGUID(&IID_IUnknown, riid))
494 *ppvObject = (IFont*)this;
495 if (IsEqualGUID(&IID_IFont, riid))
496 *ppvObject = (IFont*)this;
497 if (IsEqualGUID(&IID_IDispatch, riid))
498 *ppvObject = (IDispatch*)&(this->lpvtbl2);
499 if (IsEqualGUID(&IID_IFontDisp, riid))
500 *ppvObject = (IDispatch*)&(this->lpvtbl2);
501 if (IsEqualGUID(&IID_IPersistStream, riid))
502 *ppvObject = (IPersistStream*)&(this->lpvtbl3);
503 if (IsEqualGUID(&IID_IConnectionPointContainer, riid))
504 *ppvObject = (IConnectionPointContainer*)&(this->lpvtbl4);
505 if (IsEqualGUID(&IID_IPersistPropertyBag, riid))
506 *ppvObject = (IPersistPropertyBag*)&(this->lpvtbl5);
507 if (IsEqualGUID(&IID_IPersistStreamInit, riid))
508 *ppvObject = (IPersistStreamInit*)&(this->lpvtbl6);
511 * Check that we obtained an interface.
513 if ((*ppvObject)==0)
515 FIXME("() : asking for unsupported interface %s\n",debugstr_guid(riid));
516 return E_NOINTERFACE;
518 OLEFontImpl_AddRef((IFont*)this);
519 return S_OK;
522 /************************************************************************
523 * OLEFontImpl_AddRef (IUnknown)
525 * See Windows documentation for more details on IUnknown methods.
527 ULONG WINAPI OLEFontImpl_AddRef(
528 IFont* iface)
530 OLEFontImpl *this = (OLEFontImpl *)iface;
531 TRACE("(%p)->(ref=%ld)\n", this, this->ref);
532 this->ref++;
534 return this->ref;
537 /************************************************************************
538 * OLEFontImpl_Release (IUnknown)
540 * See Windows documentation for more details on IUnknown methods.
542 ULONG WINAPI OLEFontImpl_Release(
543 IFont* iface)
545 OLEFontImpl *this = (OLEFontImpl *)iface;
546 TRACE("(%p)->(ref=%ld)\n", this, this->ref);
549 * Decrease the reference count on this object.
551 this->ref--;
554 * If the reference count goes down to 0, perform suicide.
556 if (this->ref==0)
558 OLEFontImpl_Destroy(this);
560 return 0;
563 return this->ref;
566 /************************************************************************
567 * OLEFontImpl_get_Name (IFont)
569 * See Windows documentation for more details on IFont methods.
571 static HRESULT WINAPI OLEFontImpl_get_Name(
572 IFont* iface,
573 BSTR* pname)
575 OLEFontImpl *this = (OLEFontImpl *)iface;
576 TRACE("(%p)->(%p)\n", this, pname);
578 * Sanity check.
580 if (pname==0)
581 return E_POINTER;
583 if (this->description.lpstrName!=0)
584 *pname = SysAllocString(this->description.lpstrName);
585 else
586 *pname = 0;
588 return S_OK;
591 /************************************************************************
592 * OLEFontImpl_put_Name (IFont)
594 * See Windows documentation for more details on IFont methods.
596 static HRESULT WINAPI OLEFontImpl_put_Name(
597 IFont* iface,
598 BSTR name)
600 OLEFontImpl *this = (OLEFontImpl *)iface;
601 TRACE("(%p)->(%p)\n", this, name);
603 if (this->description.lpstrName==0)
605 this->description.lpstrName = HeapAlloc(GetProcessHeap(),
607 (lstrlenW(name)+1) * sizeof(WCHAR));
609 else
611 this->description.lpstrName = HeapReAlloc(GetProcessHeap(),
613 this->description.lpstrName,
614 (lstrlenW(name)+1) * sizeof(WCHAR));
617 if (this->description.lpstrName==0)
618 return E_OUTOFMEMORY;
620 strcpyW(this->description.lpstrName, name);
621 TRACE("new name %s\n", debugstr_w(this->description.lpstrName));
622 OLEFont_SendNotify(this, DISPID_FONT_NAME);
623 return S_OK;
626 /************************************************************************
627 * OLEFontImpl_get_Size (IFont)
629 * See Windows documentation for more details on IFont methods.
631 static HRESULT WINAPI OLEFontImpl_get_Size(
632 IFont* iface,
633 CY* psize)
635 OLEFontImpl *this = (OLEFontImpl *)iface;
636 TRACE("(%p)->(%p)\n", this, psize);
639 * Sanity check
641 if (psize==0)
642 return E_POINTER;
644 psize->s.Hi = 0;
645 psize->s.Lo = this->description.cySize.s.Lo;
647 return S_OK;
650 /************************************************************************
651 * OLEFontImpl_put_Size (IFont)
653 * See Windows documentation for more details on IFont methods.
655 static HRESULT WINAPI OLEFontImpl_put_Size(
656 IFont* iface,
657 CY size)
659 OLEFontImpl *this = (OLEFontImpl *)iface;
660 TRACE("(%p)->(%ld)\n", this, size.s.Lo);
661 this->description.cySize.s.Hi = 0;
662 this->description.cySize.s.Lo = size.s.Lo;
663 OLEFont_SendNotify(this, DISPID_FONT_SIZE);
665 return S_OK;
668 /************************************************************************
669 * OLEFontImpl_get_Bold (IFont)
671 * See Windows documentation for more details on IFont methods.
673 static HRESULT WINAPI OLEFontImpl_get_Bold(
674 IFont* iface,
675 BOOL* pbold)
677 OLEFontImpl *this = (OLEFontImpl *)iface;
678 TRACE("(%p)->(%p)\n", this, pbold);
680 * Sanity check
682 if (pbold==0)
683 return E_POINTER;
685 *pbold = this->description.sWeight > 550;
687 return S_OK;
690 /************************************************************************
691 * OLEFontImpl_put_Bold (IFont)
693 * See Windows documentation for more details on IFont methods.
695 static HRESULT WINAPI OLEFontImpl_put_Bold(
696 IFont* iface,
697 BOOL bold)
699 OLEFontImpl *this = (OLEFontImpl *)iface;
700 TRACE("(%p)->(%d)\n", this, bold);
701 this->description.sWeight = bold ? FW_BOLD : FW_NORMAL;
702 OLEFont_SendNotify(this, DISPID_FONT_BOLD);
704 return S_OK;
707 /************************************************************************
708 * OLEFontImpl_get_Italic (IFont)
710 * See Windows documentation for more details on IFont methods.
712 static HRESULT WINAPI OLEFontImpl_get_Italic(
713 IFont* iface,
714 BOOL* pitalic)
716 OLEFontImpl *this = (OLEFontImpl *)iface;
717 TRACE("(%p)->(%p)\n", this, pitalic);
719 * Sanity check
721 if (pitalic==0)
722 return E_POINTER;
724 *pitalic = this->description.fItalic;
726 return S_OK;
729 /************************************************************************
730 * OLEFontImpl_put_Italic (IFont)
732 * See Windows documentation for more details on IFont methods.
734 static HRESULT WINAPI OLEFontImpl_put_Italic(
735 IFont* iface,
736 BOOL italic)
738 OLEFontImpl *this = (OLEFontImpl *)iface;
739 TRACE("(%p)->(%d)\n", this, italic);
741 this->description.fItalic = italic;
743 OLEFont_SendNotify(this, DISPID_FONT_ITALIC);
744 return S_OK;
747 /************************************************************************
748 * OLEFontImpl_get_Underline (IFont)
750 * See Windows documentation for more details on IFont methods.
752 static HRESULT WINAPI OLEFontImpl_get_Underline(
753 IFont* iface,
754 BOOL* punderline)
756 OLEFontImpl *this = (OLEFontImpl *)iface;
757 TRACE("(%p)->(%p)\n", this, punderline);
760 * Sanity check
762 if (punderline==0)
763 return E_POINTER;
765 *punderline = this->description.fUnderline;
767 return S_OK;
770 /************************************************************************
771 * OLEFontImpl_put_Underline (IFont)
773 * See Windows documentation for more details on IFont methods.
775 static HRESULT WINAPI OLEFontImpl_put_Underline(
776 IFont* iface,
777 BOOL underline)
779 OLEFontImpl *this = (OLEFontImpl *)iface;
780 TRACE("(%p)->(%d)\n", this, underline);
782 this->description.fUnderline = underline;
784 OLEFont_SendNotify(this, DISPID_FONT_UNDER);
785 return S_OK;
788 /************************************************************************
789 * OLEFontImpl_get_Strikethrough (IFont)
791 * See Windows documentation for more details on IFont methods.
793 static HRESULT WINAPI OLEFontImpl_get_Strikethrough(
794 IFont* iface,
795 BOOL* pstrikethrough)
797 OLEFontImpl *this = (OLEFontImpl *)iface;
798 TRACE("(%p)->(%p)\n", this, pstrikethrough);
801 * Sanity check
803 if (pstrikethrough==0)
804 return E_POINTER;
806 *pstrikethrough = this->description.fStrikethrough;
808 return S_OK;
811 /************************************************************************
812 * OLEFontImpl_put_Strikethrough (IFont)
814 * See Windows documentation for more details on IFont methods.
816 static HRESULT WINAPI OLEFontImpl_put_Strikethrough(
817 IFont* iface,
818 BOOL strikethrough)
820 OLEFontImpl *this = (OLEFontImpl *)iface;
821 TRACE("(%p)->(%d)\n", this, strikethrough);
823 this->description.fStrikethrough = strikethrough;
824 OLEFont_SendNotify(this, DISPID_FONT_STRIKE);
826 return S_OK;
829 /************************************************************************
830 * OLEFontImpl_get_Weight (IFont)
832 * See Windows documentation for more details on IFont methods.
834 static HRESULT WINAPI OLEFontImpl_get_Weight(
835 IFont* iface,
836 short* pweight)
838 OLEFontImpl *this = (OLEFontImpl *)iface;
839 TRACE("(%p)->(%p)\n", this, pweight);
842 * Sanity check
844 if (pweight==0)
845 return E_POINTER;
847 *pweight = this->description.sWeight;
849 return S_OK;
852 /************************************************************************
853 * OLEFontImpl_put_Weight (IFont)
855 * See Windows documentation for more details on IFont methods.
857 static HRESULT WINAPI OLEFontImpl_put_Weight(
858 IFont* iface,
859 short weight)
861 OLEFontImpl *this = (OLEFontImpl *)iface;
862 TRACE("(%p)->(%d)\n", this, weight);
864 this->description.sWeight = weight;
866 OLEFont_SendNotify(this, DISPID_FONT_WEIGHT);
867 return S_OK;
870 /************************************************************************
871 * OLEFontImpl_get_Charset (IFont)
873 * See Windows documentation for more details on IFont methods.
875 static HRESULT WINAPI OLEFontImpl_get_Charset(
876 IFont* iface,
877 short* pcharset)
879 OLEFontImpl *this = (OLEFontImpl *)iface;
880 TRACE("(%p)->(%p)\n", this, pcharset);
883 * Sanity check
885 if (pcharset==0)
886 return E_POINTER;
888 *pcharset = this->description.sCharset;
890 return S_OK;
893 /************************************************************************
894 * OLEFontImpl_put_Charset (IFont)
896 * See Windows documentation for more details on IFont methods.
898 static HRESULT WINAPI OLEFontImpl_put_Charset(
899 IFont* iface,
900 short charset)
902 OLEFontImpl *this = (OLEFontImpl *)iface;
903 TRACE("(%p)->(%d)\n", this, charset);
905 this->description.sCharset = charset;
906 OLEFont_SendNotify(this, DISPID_FONT_CHARSET);
908 return S_OK;
911 /************************************************************************
912 * OLEFontImpl_get_hFont (IFont)
914 * See Windows documentation for more details on IFont methods.
916 static HRESULT WINAPI OLEFontImpl_get_hFont(
917 IFont* iface,
918 HFONT* phfont)
920 OLEFontImpl *this = (OLEFontImpl *)iface;
921 TRACE("(%p)->(%p)\n", this, phfont);
922 if (phfont==NULL)
923 return E_POINTER;
926 * Realize the font if necessary
928 if (this->gdiFont==0)
930 LOGFONTW logFont;
931 INT fontHeight;
932 CY cySize;
935 * The height of the font returned by the get_Size property is the
936 * height of the font in points multiplied by 10000... Using some
937 * simple conversions and the ratio given by the application, it can
938 * be converted to a height in pixels.
940 IFont_get_Size(iface, &cySize);
942 fontHeight = MulDiv( cySize.s.Lo, this->cyLogical, this->cyHimetric );
944 memset(&logFont, 0, sizeof(LOGFONTW));
946 logFont.lfHeight = ((fontHeight%10000L)>5000L) ? (-fontHeight/10000L)-1 :
947 (-fontHeight/10000L);
948 logFont.lfItalic = this->description.fItalic;
949 logFont.lfUnderline = this->description.fUnderline;
950 logFont.lfStrikeOut = this->description.fStrikethrough;
951 logFont.lfWeight = this->description.sWeight;
952 logFont.lfCharSet = this->description.sCharset;
953 logFont.lfOutPrecision = OUT_CHARACTER_PRECIS;
954 logFont.lfClipPrecision = CLIP_DEFAULT_PRECIS;
955 logFont.lfQuality = DEFAULT_QUALITY;
956 logFont.lfPitchAndFamily = DEFAULT_PITCH;
957 strcpyW(logFont.lfFaceName,this->description.lpstrName);
959 this->gdiFont = CreateFontIndirectW(&logFont);
962 *phfont = this->gdiFont;
963 TRACE("Returning %p\n", *phfont);
964 return S_OK;
967 /************************************************************************
968 * OLEFontImpl_Clone (IFont)
970 * See Windows documentation for more details on IFont methods.
972 static HRESULT WINAPI OLEFontImpl_Clone(
973 IFont* iface,
974 IFont** ppfont)
976 OLEFontImpl* newObject = 0;
977 LOGFONTW logFont;
978 INT fontHeight;
979 CY cySize;
980 OLEFontImpl *this = (OLEFontImpl *)iface;
981 TRACE("(%p)->(%p)\n", this, ppfont);
983 if (ppfont == NULL)
984 return E_POINTER;
986 *ppfont = NULL;
989 * Allocate space for the object.
991 newObject = HeapAlloc(GetProcessHeap(), 0, sizeof(OLEFontImpl));
993 if (newObject==NULL)
994 return E_OUTOFMEMORY;
996 *newObject = *this;
998 /* We need to alloc new memory for the string, otherwise
999 * we free memory twice.
1001 newObject->description.lpstrName = HeapAlloc(
1002 GetProcessHeap(),0,
1003 (1+strlenW(this->description.lpstrName))*2
1005 strcpyW(newObject->description.lpstrName, this->description.lpstrName);
1006 /* We need to clone the HFONT too. This is just cut & paste from above */
1007 IFont_get_Size(iface, &cySize);
1009 fontHeight = MulDiv(cySize.s.Lo, this->cyLogical,this->cyHimetric);
1011 memset(&logFont, 0, sizeof(LOGFONTW));
1013 logFont.lfHeight = ((fontHeight%10000L)>5000L) ? (-fontHeight/10000L)-1 :
1014 (-fontHeight/10000L);
1015 logFont.lfItalic = this->description.fItalic;
1016 logFont.lfUnderline = this->description.fUnderline;
1017 logFont.lfStrikeOut = this->description.fStrikethrough;
1018 logFont.lfWeight = this->description.sWeight;
1019 logFont.lfCharSet = this->description.sCharset;
1020 logFont.lfOutPrecision = OUT_CHARACTER_PRECIS;
1021 logFont.lfClipPrecision = CLIP_DEFAULT_PRECIS;
1022 logFont.lfQuality = DEFAULT_QUALITY;
1023 logFont.lfPitchAndFamily = DEFAULT_PITCH;
1024 strcpyW(logFont.lfFaceName,this->description.lpstrName);
1026 newObject->gdiFont = CreateFontIndirectW(&logFont);
1029 /* The cloned object starts with a reference count of 1 */
1030 newObject->ref = 1;
1032 *ppfont = (IFont*)newObject;
1034 return S_OK;
1037 /************************************************************************
1038 * OLEFontImpl_IsEqual (IFont)
1040 * See Windows documentation for more details on IFont methods.
1042 static HRESULT WINAPI OLEFontImpl_IsEqual(
1043 IFont* iface,
1044 IFont* pFontOther)
1046 FIXME("(%p, %p), stub!\n",iface,pFontOther);
1047 return E_NOTIMPL;
1050 /************************************************************************
1051 * OLEFontImpl_SetRatio (IFont)
1053 * See Windows documentation for more details on IFont methods.
1055 static HRESULT WINAPI OLEFontImpl_SetRatio(
1056 IFont* iface,
1057 long cyLogical,
1058 long cyHimetric)
1060 OLEFontImpl *this = (OLEFontImpl *)iface;
1061 TRACE("(%p)->(%ld, %ld)\n", this, cyLogical, cyHimetric);
1063 this->cyLogical = cyLogical;
1064 this->cyHimetric = cyHimetric;
1066 return S_OK;
1069 /************************************************************************
1070 * OLEFontImpl_QueryTextMetrics (IFont)
1072 * See Windows documentation for more details on IFont methods.
1074 static HRESULT WINAPI OLEFontImpl_QueryTextMetrics(
1075 IFont* iface,
1076 TEXTMETRICOLE* ptm)
1078 FIXME("(%p, %p), stub!\n",iface,ptm);
1079 return E_NOTIMPL;
1082 /************************************************************************
1083 * OLEFontImpl_AddRefHfont (IFont)
1085 * See Windows documentation for more details on IFont methods.
1087 static HRESULT WINAPI OLEFontImpl_AddRefHfont(
1088 IFont* iface,
1089 HFONT hfont)
1091 OLEFontImpl *this = (OLEFontImpl *)iface;
1092 TRACE("(%p)->(%p) (lock=%ld)\n", this, hfont, this->fontLock);
1094 if ( (hfont == 0) ||
1095 (hfont != this->gdiFont) )
1096 return E_INVALIDARG;
1098 this->fontLock++;
1100 return S_OK;
1103 /************************************************************************
1104 * OLEFontImpl_ReleaseHfont (IFont)
1106 * See Windows documentation for more details on IFont methods.
1108 static HRESULT WINAPI OLEFontImpl_ReleaseHfont(
1109 IFont* iface,
1110 HFONT hfont)
1112 OLEFontImpl *this = (OLEFontImpl *)iface;
1113 TRACE("(%p)->(%p) (lock=%ld)\n", this, hfont, this->fontLock);
1115 if ( (hfont == 0) ||
1116 (hfont != this->gdiFont) )
1117 return E_INVALIDARG;
1119 this->fontLock--;
1122 * If we just released our last font reference, destroy it.
1124 if (this->fontLock==0)
1126 DeleteObject(this->gdiFont);
1127 this->gdiFont = 0;
1130 return S_OK;
1133 /************************************************************************
1134 * OLEFontImpl_SetHdc (IFont)
1136 * See Windows documentation for more details on IFont methods.
1138 static HRESULT WINAPI OLEFontImpl_SetHdc(
1139 IFont* iface,
1140 HDC hdc)
1142 OLEFontImpl *this = (OLEFontImpl *)iface;
1143 FIXME("(%p)->(%p): Stub\n", this, hdc);
1144 return E_NOTIMPL;
1147 /************************************************************************
1148 * OLEFontImpl_IDispatch_QueryInterface (IUnknown)
1150 * See Windows documentation for more details on IUnknown methods.
1152 static HRESULT WINAPI OLEFontImpl_IDispatch_QueryInterface(
1153 IDispatch* iface,
1154 REFIID riid,
1155 VOID** ppvoid)
1157 _ICOM_THIS_From_IDispatch(IFont, iface);
1159 return IFont_QueryInterface(this, riid, ppvoid);
1162 /************************************************************************
1163 * OLEFontImpl_IDispatch_Release (IUnknown)
1165 * See Windows documentation for more details on IUnknown methods.
1167 static ULONG WINAPI OLEFontImpl_IDispatch_Release(
1168 IDispatch* iface)
1170 _ICOM_THIS_From_IDispatch(IFont, iface);
1172 return IFont_Release(this);
1175 /************************************************************************
1176 * OLEFontImpl_IDispatch_AddRef (IUnknown)
1178 * See Windows documentation for more details on IUnknown methods.
1180 static ULONG WINAPI OLEFontImpl_IDispatch_AddRef(
1181 IDispatch* iface)
1183 _ICOM_THIS_From_IDispatch(IFont, iface);
1185 return IFont_AddRef(this);
1188 /************************************************************************
1189 * OLEFontImpl_GetTypeInfoCount (IDispatch)
1191 * See Windows documentation for more details on IDispatch methods.
1193 static HRESULT WINAPI OLEFontImpl_GetTypeInfoCount(
1194 IDispatch* iface,
1195 unsigned int* pctinfo)
1197 _ICOM_THIS_From_IDispatch(IFont, iface);
1198 FIXME("(%p)->(%p): Stub\n", this, pctinfo);
1200 return E_NOTIMPL;
1203 /************************************************************************
1204 * OLEFontImpl_GetTypeInfo (IDispatch)
1206 * See Windows documentation for more details on IDispatch methods.
1208 static HRESULT WINAPI OLEFontImpl_GetTypeInfo(
1209 IDispatch* iface,
1210 UINT iTInfo,
1211 LCID lcid,
1212 ITypeInfo** ppTInfo)
1214 static const WCHAR stdole32tlb[] = {'s','t','d','o','l','e','3','2','.','t','l','b',0};
1215 ITypeLib *tl;
1216 HRESULT hres;
1218 _ICOM_THIS_From_IDispatch(OLEFontImpl, iface);
1219 TRACE("(%p, iTInfo=%d, lcid=%04x, %p), unimplemented stub!\n", this, iTInfo, (int)lcid, ppTInfo);
1220 if (iTInfo != 0)
1221 return E_FAIL;
1222 hres = LoadTypeLib(stdole32tlb, &tl);
1223 if (FAILED(hres)) {
1224 FIXME("Could not load the stdole32.tlb?\n");
1225 return hres;
1227 hres = ITypeLib_GetTypeInfoOfGuid(tl, &IID_IDispatch, ppTInfo);
1228 if (FAILED(hres)) {
1229 FIXME("Did not IDispatch typeinfo from typelib, hres %lx\n",hres);
1231 return hres;
1234 /************************************************************************
1235 * OLEFontImpl_GetIDsOfNames (IDispatch)
1237 * See Windows documentation for more details on IDispatch methods.
1239 static HRESULT WINAPI OLEFontImpl_GetIDsOfNames(
1240 IDispatch* iface,
1241 REFIID riid,
1242 LPOLESTR* rgszNames,
1243 UINT cNames,
1244 LCID lcid,
1245 DISPID* rgDispId)
1247 _ICOM_THIS_From_IDispatch(IFont, iface);
1248 FIXME("(%p,%s,%p,%d,%04x,%p), stub!\n", this, debugstr_guid(riid), rgszNames,
1249 cNames, (int)lcid, rgDispId
1251 return E_NOTIMPL;
1254 /************************************************************************
1255 * OLEFontImpl_Invoke (IDispatch)
1257 * See Windows documentation for more details on IDispatch methods.
1259 * Note: Do not call _put_Xxx methods, since setting things here
1260 * should not call notify functions as I found out debugging the generic
1261 * MS VB5 installer.
1263 static HRESULT WINAPI OLEFontImpl_Invoke(
1264 IDispatch* iface,
1265 DISPID dispIdMember,
1266 REFIID riid,
1267 LCID lcid,
1268 WORD wFlags,
1269 DISPPARAMS* pDispParams,
1270 VARIANT* pVarResult,
1271 EXCEPINFO* pExepInfo,
1272 UINT* puArgErr)
1274 _ICOM_THIS_From_IDispatch(IFont, iface);
1275 OLEFontImpl *xthis = (OLEFontImpl*)this;
1277 switch (dispIdMember) {
1278 case DISPID_FONT_NAME:
1279 switch (wFlags) {
1280 case DISPATCH_PROPERTYGET:
1281 case DISPATCH_PROPERTYGET|DISPATCH_METHOD:
1282 V_VT(pVarResult) = VT_BSTR;
1283 return OLEFontImpl_get_Name(this, &V_BSTR(pVarResult));
1284 case DISPATCH_PROPERTYPUT: {
1285 BSTR name = V_BSTR(&pDispParams->rgvarg[0]);
1286 if (V_VT(&pDispParams->rgvarg[0])!=VT_BSTR) {
1287 FIXME("property put of Name, vt is not VT_BSTR but %d\n",V_VT(&pDispParams->rgvarg[0]));
1288 return E_FAIL;
1290 if (!xthis->description.lpstrName)
1291 xthis->description.lpstrName = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(name)+1) * sizeof(WCHAR));
1292 else
1293 xthis->description.lpstrName = HeapReAlloc(GetProcessHeap(), 0, xthis->description.lpstrName, (lstrlenW(name)+1) * sizeof(WCHAR));
1295 if (xthis->description.lpstrName==0)
1296 return E_OUTOFMEMORY;
1297 strcpyW(xthis->description.lpstrName, name);
1298 return S_OK;
1301 break;
1302 case DISPID_FONT_BOLD:
1303 switch (wFlags) {
1304 case DISPATCH_PROPERTYGET:
1305 case DISPATCH_PROPERTYGET|DISPATCH_METHOD:
1306 V_VT(pVarResult) = VT_BOOL;
1307 return OLEFontImpl_get_Bold(this, (BOOL*)&V_BOOL(pVarResult));
1308 case DISPATCH_PROPERTYPUT:
1309 if (V_VT(&pDispParams->rgvarg[0]) != VT_BOOL) {
1310 FIXME("DISPID_FONT_BOLD/put, vt is %d, not VT_BOOL.\n",V_VT(&pDispParams->rgvarg[0]));
1311 return E_FAIL;
1312 } else {
1313 xthis->description.sWeight = V_BOOL(&pDispParams->rgvarg[0]) ? FW_BOLD : FW_NORMAL;
1314 return S_OK;
1317 break;
1318 case DISPID_FONT_ITALIC:
1319 switch (wFlags) {
1320 case DISPATCH_PROPERTYGET:
1321 case DISPATCH_PROPERTYGET|DISPATCH_METHOD:
1322 V_VT(pVarResult) = VT_BOOL;
1323 return OLEFontImpl_get_Italic(this, (BOOL*)&V_BOOL(pVarResult));
1324 case DISPATCH_PROPERTYPUT:
1325 if (V_VT(&pDispParams->rgvarg[0]) != VT_BOOL) {
1326 FIXME("DISPID_FONT_ITALIC/put, vt is %d, not VT_BOOL.\n",V_VT(&pDispParams->rgvarg[0]));
1327 return E_FAIL;
1328 } else {
1329 xthis->description.fItalic = V_BOOL(&pDispParams->rgvarg[0]);
1330 return S_OK;
1333 break;
1334 case DISPID_FONT_UNDER:
1335 switch (wFlags) {
1336 case DISPATCH_PROPERTYGET:
1337 case DISPATCH_PROPERTYGET|DISPATCH_METHOD:
1338 V_VT(pVarResult) = VT_BOOL;
1339 return OLEFontImpl_get_Underline(this, (BOOL*)&V_BOOL(pVarResult));
1340 case DISPATCH_PROPERTYPUT:
1341 if (V_VT(&pDispParams->rgvarg[0]) != VT_BOOL) {
1342 FIXME("DISPID_FONT_UNDER/put, vt is %d, not VT_BOOL.\n",V_VT(&pDispParams->rgvarg[0]));
1343 return E_FAIL;
1344 } else {
1345 xthis->description.fUnderline = V_BOOL(&pDispParams->rgvarg[0]);
1346 return S_OK;
1349 break;
1350 case DISPID_FONT_STRIKE:
1351 switch (wFlags) {
1352 case DISPATCH_PROPERTYGET:
1353 case DISPATCH_PROPERTYGET|DISPATCH_METHOD:
1354 V_VT(pVarResult) = VT_BOOL;
1355 return OLEFontImpl_get_Strikethrough(this, (BOOL*)&V_BOOL(pVarResult));
1356 case DISPATCH_PROPERTYPUT:
1357 if (V_VT(&pDispParams->rgvarg[0]) != VT_BOOL) {
1358 FIXME("DISPID_FONT_STRIKE/put, vt is %d, not VT_BOOL.\n",V_VT(&pDispParams->rgvarg[0]));
1359 return E_FAIL;
1360 } else {
1361 xthis->description.fStrikethrough = V_BOOL(&pDispParams->rgvarg[0]);
1362 return S_OK;
1365 break;
1366 case DISPID_FONT_SIZE:
1367 switch (wFlags) {
1368 case DISPATCH_PROPERTYPUT: {
1369 assert (pDispParams->cArgs == 1);
1370 xthis->description.cySize.s.Hi = 0;
1371 if (V_VT(&pDispParams->rgvarg[0]) != VT_CY) {
1372 if (V_VT(&pDispParams->rgvarg[0]) == VT_I2) {
1373 xthis->description.cySize.s.Lo = V_I2(&pDispParams->rgvarg[0]) * 10000;
1374 } else {
1375 FIXME("property put for Size with vt %d unsupported!\n",V_VT(&pDispParams->rgvarg[0]));
1377 } else {
1378 xthis->description.cySize.s.Lo = V_CY(&pDispParams->rgvarg[0]).s.Lo;
1380 return S_OK;
1382 case DISPATCH_PROPERTYGET:
1383 case DISPATCH_PROPERTYGET|DISPATCH_METHOD:
1384 V_VT(pVarResult) = VT_CY;
1385 return OLEFontImpl_get_Size(this, &V_CY(pVarResult));
1387 break;
1388 case DISPID_FONT_CHARSET:
1389 switch (wFlags) {
1390 case DISPATCH_PROPERTYPUT:
1391 assert (pDispParams->cArgs == 1);
1392 if (V_VT(&pDispParams->rgvarg[0]) != VT_I2)
1393 FIXME("varg of first disparg is not VT_I2, but %d\n",V_VT(&pDispParams->rgvarg[0]));
1394 xthis->description.sCharset = V_I2(&pDispParams->rgvarg[0]);
1395 return S_OK;
1396 case DISPATCH_PROPERTYGET:
1397 case DISPATCH_PROPERTYGET|DISPATCH_METHOD:
1398 V_VT(pVarResult) = VT_I2;
1399 return OLEFontImpl_get_Charset(this, &V_I2(pVarResult));
1401 break;
1403 FIXME("%p->(%ld,%s,%lx,%x,%p,%p,%p,%p), unhandled dispid/flag!\n",
1404 this,dispIdMember,debugstr_guid(riid),lcid,
1405 wFlags,pDispParams,pVarResult,pExepInfo,puArgErr
1407 return S_OK;
1410 /************************************************************************
1411 * OLEFontImpl_IPersistStream_QueryInterface (IUnknown)
1413 * See Windows documentation for more details on IUnknown methods.
1415 static HRESULT WINAPI OLEFontImpl_IPersistStream_QueryInterface(
1416 IPersistStream* iface,
1417 REFIID riid,
1418 VOID** ppvoid)
1420 _ICOM_THIS_From_IPersistStream(IFont, iface);
1422 return IFont_QueryInterface(this, riid, ppvoid);
1425 /************************************************************************
1426 * OLEFontImpl_IPersistStream_Release (IUnknown)
1428 * See Windows documentation for more details on IUnknown methods.
1430 static ULONG WINAPI OLEFontImpl_IPersistStream_Release(
1431 IPersistStream* iface)
1433 _ICOM_THIS_From_IPersistStream(IFont, iface);
1435 return IFont_Release(this);
1438 /************************************************************************
1439 * OLEFontImpl_IPersistStream_AddRef (IUnknown)
1441 * See Windows documentation for more details on IUnknown methods.
1443 static ULONG WINAPI OLEFontImpl_IPersistStream_AddRef(
1444 IPersistStream* iface)
1446 _ICOM_THIS_From_IPersistStream(IFont, iface);
1448 return IFont_AddRef(this);
1451 /************************************************************************
1452 * OLEFontImpl_GetClassID (IPersistStream)
1454 * See Windows documentation for more details on IPersistStream methods.
1456 static HRESULT WINAPI OLEFontImpl_GetClassID(
1457 IPersistStream* iface,
1458 CLSID* pClassID)
1460 TRACE("(%p,%p)\n",iface,pClassID);
1461 if (pClassID==0)
1462 return E_POINTER;
1464 memcpy(pClassID, &CLSID_StdFont, sizeof(CLSID_StdFont));
1466 return S_OK;
1469 /************************************************************************
1470 * OLEFontImpl_IsDirty (IPersistStream)
1472 * See Windows documentation for more details on IPersistStream methods.
1474 static HRESULT WINAPI OLEFontImpl_IsDirty(
1475 IPersistStream* iface)
1477 TRACE("(%p)\n",iface);
1478 return S_OK;
1481 /************************************************************************
1482 * OLEFontImpl_Load (IPersistStream)
1484 * See Windows documentation for more details on IPersistStream methods.
1486 * This is the format of the standard font serialization as far as I
1487 * know
1489 * Offset Type Value Comment
1490 * 0x0000 Byte Unknown Probably a version number, contains 0x01
1491 * 0x0001 Short Charset Charset value from the FONTDESC structure
1492 * 0x0003 Byte Attributes Flags defined as follows:
1493 * 00000010 - Italic
1494 * 00000100 - Underline
1495 * 00001000 - Strikethrough
1496 * 0x0004 Short Weight Weight value from FONTDESC structure
1497 * 0x0006 DWORD size "Low" portion of the cySize member of the FONTDESC
1498 * structure/
1499 * 0x000A Byte name length Length of the font name string (no null character)
1500 * 0x000B String name Name of the font (ASCII, no nul character)
1502 static HRESULT WINAPI OLEFontImpl_Load(
1503 IPersistStream* iface,
1504 IStream* pLoadStream)
1506 char readBuffer[0x100];
1507 ULONG cbRead;
1508 BYTE bVersion;
1509 BYTE bAttributes;
1510 BYTE bStringSize;
1511 INT len;
1513 _ICOM_THIS_From_IPersistStream(OLEFontImpl, iface);
1516 * Read the version byte
1518 IStream_Read(pLoadStream, &bVersion, 1, &cbRead);
1520 if ( (cbRead!=1) ||
1521 (bVersion!=0x01) )
1522 return E_FAIL;
1525 * Charset
1527 IStream_Read(pLoadStream, &this->description.sCharset, 2, &cbRead);
1529 if (cbRead!=2)
1530 return E_FAIL;
1533 * Attributes
1535 IStream_Read(pLoadStream, &bAttributes, 1, &cbRead);
1537 if (cbRead!=1)
1538 return E_FAIL;
1540 this->description.fItalic = (bAttributes & FONTPERSIST_ITALIC) != 0;
1541 this->description.fStrikethrough = (bAttributes & FONTPERSIST_STRIKETHROUGH) != 0;
1542 this->description.fUnderline = (bAttributes & FONTPERSIST_UNDERLINE) != 0;
1545 * Weight
1547 IStream_Read(pLoadStream, &this->description.sWeight, 2, &cbRead);
1549 if (cbRead!=2)
1550 return E_FAIL;
1553 * Size
1555 IStream_Read(pLoadStream, &this->description.cySize.s.Lo, 4, &cbRead);
1557 if (cbRead!=4)
1558 return E_FAIL;
1560 this->description.cySize.s.Hi = 0;
1563 * FontName
1565 IStream_Read(pLoadStream, &bStringSize, 1, &cbRead);
1567 if (cbRead!=1)
1568 return E_FAIL;
1570 IStream_Read(pLoadStream, readBuffer, bStringSize, &cbRead);
1572 if (cbRead!=bStringSize)
1573 return E_FAIL;
1575 if (this->description.lpstrName!=0)
1576 HeapFree(GetProcessHeap(), 0, this->description.lpstrName);
1578 len = MultiByteToWideChar( CP_ACP, 0, readBuffer, bStringSize, NULL, 0 );
1579 this->description.lpstrName = HeapAlloc( GetProcessHeap(), 0, (len+1) * sizeof(WCHAR) );
1580 MultiByteToWideChar( CP_ACP, 0, readBuffer, bStringSize, this->description.lpstrName, len );
1581 this->description.lpstrName[len] = 0;
1583 /* Ensure use of this font causes a new one to be created @@@@ */
1584 DeleteObject(this->gdiFont);
1585 this->gdiFont = 0;
1587 return S_OK;
1590 /************************************************************************
1591 * OLEFontImpl_Save (IPersistStream)
1593 * See Windows documentation for more details on IPersistStream methods.
1595 static HRESULT WINAPI OLEFontImpl_Save(
1596 IPersistStream* iface,
1597 IStream* pOutStream,
1598 BOOL fClearDirty)
1600 char* writeBuffer = NULL;
1601 ULONG cbWritten;
1602 BYTE bVersion = 0x01;
1603 BYTE bAttributes;
1604 BYTE bStringSize;
1606 _ICOM_THIS_From_IPersistStream(OLEFontImpl, iface);
1609 * Read the version byte
1611 IStream_Write(pOutStream, &bVersion, 1, &cbWritten);
1613 if (cbWritten!=1)
1614 return E_FAIL;
1617 * Charset
1619 IStream_Write(pOutStream, &this->description.sCharset, 2, &cbWritten);
1621 if (cbWritten!=2)
1622 return E_FAIL;
1625 * Attributes
1627 bAttributes = 0;
1629 if (this->description.fItalic)
1630 bAttributes |= FONTPERSIST_ITALIC;
1632 if (this->description.fStrikethrough)
1633 bAttributes |= FONTPERSIST_STRIKETHROUGH;
1635 if (this->description.fUnderline)
1636 bAttributes |= FONTPERSIST_UNDERLINE;
1638 IStream_Write(pOutStream, &bAttributes, 1, &cbWritten);
1640 if (cbWritten!=1)
1641 return E_FAIL;
1644 * Weight
1646 IStream_Write(pOutStream, &this->description.sWeight, 2, &cbWritten);
1648 if (cbWritten!=2)
1649 return E_FAIL;
1652 * Size
1654 IStream_Write(pOutStream, &this->description.cySize.s.Lo, 4, &cbWritten);
1656 if (cbWritten!=4)
1657 return E_FAIL;
1660 * FontName
1662 if (this->description.lpstrName!=0)
1663 bStringSize = WideCharToMultiByte( CP_ACP, 0, this->description.lpstrName,
1664 strlenW(this->description.lpstrName), NULL, 0, NULL, NULL );
1665 else
1666 bStringSize = 0;
1668 IStream_Write(pOutStream, &bStringSize, 1, &cbWritten);
1670 if (cbWritten!=1)
1671 return E_FAIL;
1673 if (bStringSize!=0)
1675 if (!(writeBuffer = HeapAlloc( GetProcessHeap(), 0, bStringSize ))) return E_OUTOFMEMORY;
1676 WideCharToMultiByte( CP_ACP, 0, this->description.lpstrName,
1677 strlenW(this->description.lpstrName),
1678 writeBuffer, bStringSize, NULL, NULL );
1680 IStream_Write(pOutStream, writeBuffer, bStringSize, &cbWritten);
1681 HeapFree(GetProcessHeap(), 0, writeBuffer);
1683 if (cbWritten!=bStringSize)
1684 return E_FAIL;
1687 return S_OK;
1690 /************************************************************************
1691 * OLEFontImpl_GetSizeMax (IPersistStream)
1693 * See Windows documentation for more details on IPersistStream methods.
1695 static HRESULT WINAPI OLEFontImpl_GetSizeMax(
1696 IPersistStream* iface,
1697 ULARGE_INTEGER* pcbSize)
1699 _ICOM_THIS_From_IPersistStream(OLEFontImpl, iface);
1701 if (pcbSize==NULL)
1702 return E_POINTER;
1704 pcbSize->u.HighPart = 0;
1705 pcbSize->u.LowPart = 0;
1707 pcbSize->u.LowPart += sizeof(BYTE); /* Version */
1708 pcbSize->u.LowPart += sizeof(WORD); /* Lang code */
1709 pcbSize->u.LowPart += sizeof(BYTE); /* Flags */
1710 pcbSize->u.LowPart += sizeof(WORD); /* Weight */
1711 pcbSize->u.LowPart += sizeof(DWORD); /* Size */
1712 pcbSize->u.LowPart += sizeof(BYTE); /* StrLength */
1714 if (this->description.lpstrName!=0)
1715 pcbSize->u.LowPart += lstrlenW(this->description.lpstrName);
1717 return S_OK;
1720 /************************************************************************
1721 * OLEFontImpl_IConnectionPointContainer_QueryInterface (IUnknown)
1723 * See Windows documentation for more details on IUnknown methods.
1725 static HRESULT WINAPI OLEFontImpl_IConnectionPointContainer_QueryInterface(
1726 IConnectionPointContainer* iface,
1727 REFIID riid,
1728 VOID** ppvoid)
1730 _ICOM_THIS_From_IConnectionPointContainer(OLEFontImpl, iface);
1732 return IFont_QueryInterface((IFont*)this, riid, ppvoid);
1735 /************************************************************************
1736 * OLEFontImpl_IConnectionPointContainer_Release (IUnknown)
1738 * See Windows documentation for more details on IUnknown methods.
1740 static ULONG WINAPI OLEFontImpl_IConnectionPointContainer_Release(
1741 IConnectionPointContainer* iface)
1743 _ICOM_THIS_From_IConnectionPointContainer(OLEFontImpl, iface);
1745 return IFont_Release((IFont*)this);
1748 /************************************************************************
1749 * OLEFontImpl_IConnectionPointContainer_AddRef (IUnknown)
1751 * See Windows documentation for more details on IUnknown methods.
1753 static ULONG WINAPI OLEFontImpl_IConnectionPointContainer_AddRef(
1754 IConnectionPointContainer* iface)
1756 _ICOM_THIS_From_IConnectionPointContainer(OLEFontImpl, iface);
1758 return IFont_AddRef((IFont*)this);
1761 /************************************************************************
1762 * OLEFontImpl_EnumConnectionPoints (IConnectionPointContainer)
1764 * See Windows documentation for more details on IConnectionPointContainer
1765 * methods.
1767 static HRESULT WINAPI OLEFontImpl_EnumConnectionPoints(
1768 IConnectionPointContainer* iface,
1769 IEnumConnectionPoints **ppEnum)
1771 _ICOM_THIS_From_IConnectionPointContainer(OLEFontImpl, iface);
1773 FIXME("(%p)->(%p): stub\n", this, ppEnum);
1774 return E_NOTIMPL;
1777 /************************************************************************
1778 * OLEFontImpl_FindConnectionPoint (IConnectionPointContainer)
1780 * See Windows documentation for more details on IConnectionPointContainer
1781 * methods.
1783 static HRESULT WINAPI OLEFontImpl_FindConnectionPoint(
1784 IConnectionPointContainer* iface,
1785 REFIID riid,
1786 IConnectionPoint **ppCp)
1788 _ICOM_THIS_From_IConnectionPointContainer(OLEFontImpl, iface);
1789 TRACE("(%p)->(%s, %p): stub\n", this, debugstr_guid(riid), ppCp);
1791 if(memcmp(riid, &IID_IPropertyNotifySink, sizeof(IID_IPropertyNotifySink)) == 0) {
1792 return IConnectionPoint_QueryInterface(this->pCP, &IID_IConnectionPoint,
1793 (LPVOID)ppCp);
1794 } else {
1795 FIXME("Tried to find connection point on %s\n", debugstr_guid(riid));
1796 return E_NOINTERFACE;
1800 /************************************************************************
1801 * OLEFontImpl implementation of IPersistPropertyBag.
1803 static HRESULT WINAPI OLEFontImpl_IPersistPropertyBag_QueryInterface(
1804 IPersistPropertyBag *iface, REFIID riid, LPVOID *ppvObj
1806 _ICOM_THIS_From_IPersistPropertyBag(IFont, iface);
1807 return IFont_QueryInterface(this,riid,ppvObj);
1810 static ULONG WINAPI OLEFontImpl_IPersistPropertyBag_AddRef(
1811 IPersistPropertyBag *iface
1813 _ICOM_THIS_From_IPersistPropertyBag(IFont, iface);
1814 return IFont_AddRef(this);
1817 static ULONG WINAPI OLEFontImpl_IPersistPropertyBag_Release(
1818 IPersistPropertyBag *iface
1820 _ICOM_THIS_From_IPersistPropertyBag(IFont, iface);
1821 return IFont_Release(this);
1824 static HRESULT WINAPI OLEFontImpl_IPersistPropertyBag_GetClassID(
1825 IPersistPropertyBag *iface, CLSID *classid
1827 FIXME("(%p,%p), stub!\n", iface, classid);
1828 return E_FAIL;
1831 static HRESULT WINAPI OLEFontImpl_IPersistPropertyBag_InitNew(
1832 IPersistPropertyBag *iface
1834 FIXME("(%p), stub!\n", iface);
1835 return S_OK;
1838 static HRESULT WINAPI OLEFontImpl_IPersistPropertyBag_Load(
1839 IPersistPropertyBag *iface, IPropertyBag* pPropBag, IErrorLog* pErrorLog
1841 /* (from Visual Basic 6 property bag)
1842 Name = "MS Sans Serif"
1843 Size = 13.8
1844 Charset = 0
1845 Weight = 400
1846 Underline = 0 'False
1847 Italic = 0 'False
1848 Strikethrough = 0 'False
1850 static const WCHAR sAttrName[] = {'N','a','m','e',0};
1851 static const WCHAR sAttrSize[] = {'S','i','z','e',0};
1852 static const WCHAR sAttrCharset[] = {'C','h','a','r','s','e','t',0};
1853 static const WCHAR sAttrWeight[] = {'W','e','i','g','h','t',0};
1854 static const WCHAR sAttrUnderline[] = {'U','n','d','e','r','l','i','n','e',0};
1855 static const WCHAR sAttrItalic[] = {'I','t','a','l','i','c',0};
1856 static const WCHAR sAttrStrikethrough[] = {'S','t','r','i','k','e','t','h','r','o','u','g','h',0};
1857 VARIANT rawAttr;
1858 VARIANT valueAttr;
1859 HRESULT iRes = S_OK;
1860 _ICOM_THIS_From_IPersistPropertyBag(IFont, iface);
1862 VariantInit(&rawAttr);
1863 VariantInit(&valueAttr);
1865 if (iRes == S_OK) {
1866 iRes = IPropertyBag_Read(pPropBag, sAttrName, &rawAttr, pErrorLog);
1867 if (iRes == S_OK)
1869 iRes = VariantChangeType(&rawAttr, &valueAttr, 0, VT_BSTR);
1870 if (iRes == S_OK)
1871 iRes = IFont_put_Name(this, V_BSTR(&valueAttr));
1873 else if (iRes == E_INVALIDARG)
1874 iRes = S_OK;
1875 VariantClear(&rawAttr);
1876 VariantClear(&valueAttr);
1879 if (iRes == S_OK) {
1880 iRes = IPropertyBag_Read(pPropBag, sAttrSize, &rawAttr, pErrorLog);
1881 if (iRes == S_OK)
1883 iRes = VariantChangeType(&rawAttr, &valueAttr, 0, VT_CY);
1884 if (iRes == S_OK)
1885 iRes = IFont_put_Size(this, V_CY(&valueAttr));
1887 else if (iRes == E_INVALIDARG)
1888 iRes = S_OK;
1889 VariantClear(&rawAttr);
1890 VariantClear(&valueAttr);
1893 if (iRes == S_OK) {
1894 iRes = IPropertyBag_Read(pPropBag, sAttrCharset, &rawAttr, pErrorLog);
1895 if (iRes == S_OK)
1897 iRes = VariantChangeType(&rawAttr, &valueAttr, 0, VT_I2);
1898 if (iRes == S_OK)
1899 iRes = IFont_put_Charset(this, V_I2(&valueAttr));
1901 else if (iRes == E_INVALIDARG)
1902 iRes = S_OK;
1903 VariantClear(&rawAttr);
1904 VariantClear(&valueAttr);
1907 if (iRes == S_OK) {
1908 iRes = IPropertyBag_Read(pPropBag, sAttrWeight, &rawAttr, pErrorLog);
1909 if (iRes == S_OK)
1911 iRes = VariantChangeType(&rawAttr, &valueAttr, 0, VT_I2);
1912 if (iRes == S_OK)
1913 iRes = IFont_put_Weight(this, V_I2(&valueAttr));
1915 else if (iRes == E_INVALIDARG)
1916 iRes = S_OK;
1917 VariantClear(&rawAttr);
1918 VariantClear(&valueAttr);
1922 if (iRes == S_OK) {
1923 iRes = IPropertyBag_Read(pPropBag, sAttrUnderline, &rawAttr, pErrorLog);
1924 if (iRes == S_OK)
1926 iRes = VariantChangeType(&rawAttr, &valueAttr, 0, VT_BOOL);
1927 if (iRes == S_OK)
1928 iRes = IFont_put_Underline(this, V_BOOL(&valueAttr));
1930 else if (iRes == E_INVALIDARG)
1931 iRes = S_OK;
1932 VariantClear(&rawAttr);
1933 VariantClear(&valueAttr);
1936 if (iRes == S_OK) {
1937 iRes = IPropertyBag_Read(pPropBag, sAttrItalic, &rawAttr, pErrorLog);
1938 if (iRes == S_OK)
1940 iRes = VariantChangeType(&rawAttr, &valueAttr, 0, VT_BOOL);
1941 if (iRes == S_OK)
1942 iRes = IFont_put_Italic(this, V_BOOL(&valueAttr));
1944 else if (iRes == E_INVALIDARG)
1945 iRes = S_OK;
1946 VariantClear(&rawAttr);
1947 VariantClear(&valueAttr);
1950 if (iRes == S_OK) {
1951 iRes = IPropertyBag_Read(pPropBag, sAttrStrikethrough, &rawAttr, pErrorLog);
1952 if (iRes == S_OK)
1954 iRes = VariantChangeType(&rawAttr, &valueAttr, 0, VT_BOOL);
1955 if (iRes == S_OK)
1956 IFont_put_Strikethrough(this, V_BOOL(&valueAttr));
1958 else if (iRes == E_INVALIDARG)
1959 iRes = S_OK;
1960 VariantClear(&rawAttr);
1961 VariantClear(&valueAttr);
1964 if (FAILED(iRes))
1965 WARN("-- 0x%08lx\n", iRes);
1966 return iRes;
1969 static HRESULT WINAPI OLEFontImpl_IPersistPropertyBag_Save(
1970 IPersistPropertyBag *iface, IPropertyBag* pPropBag, BOOL fClearDirty,
1971 BOOL fSaveAllProperties
1973 FIXME("(%p,%p,%d,%d), stub!\n", iface, pPropBag, fClearDirty, fSaveAllProperties);
1974 return E_FAIL;
1977 static IPersistPropertyBagVtbl OLEFontImpl_IPersistPropertyBag_VTable =
1979 OLEFontImpl_IPersistPropertyBag_QueryInterface,
1980 OLEFontImpl_IPersistPropertyBag_AddRef,
1981 OLEFontImpl_IPersistPropertyBag_Release,
1983 OLEFontImpl_IPersistPropertyBag_GetClassID,
1984 OLEFontImpl_IPersistPropertyBag_InitNew,
1985 OLEFontImpl_IPersistPropertyBag_Load,
1986 OLEFontImpl_IPersistPropertyBag_Save
1989 /************************************************************************
1990 * OLEFontImpl implementation of IPersistStreamInit.
1992 static HRESULT WINAPI OLEFontImpl_IPersistStreamInit_QueryInterface(
1993 IPersistStreamInit *iface, REFIID riid, LPVOID *ppvObj
1995 _ICOM_THIS_From_IPersistStreamInit(IFont, iface);
1996 return IFont_QueryInterface(this,riid,ppvObj);
1999 static ULONG WINAPI OLEFontImpl_IPersistStreamInit_AddRef(
2000 IPersistStreamInit *iface
2002 _ICOM_THIS_From_IPersistStreamInit(IFont, iface);
2003 return IFont_AddRef(this);
2006 static ULONG WINAPI OLEFontImpl_IPersistStreamInit_Release(
2007 IPersistStreamInit *iface
2009 _ICOM_THIS_From_IPersistStreamInit(IFont, iface);
2010 return IFont_Release(this);
2013 static HRESULT WINAPI OLEFontImpl_IPersistStreamInit_GetClassID(
2014 IPersistStreamInit *iface, CLSID *classid
2016 FIXME("(%p,%p), stub!\n", iface, classid);
2017 return E_FAIL;
2020 static HRESULT WINAPI OLEFontImpl_IPersistStreamInit_IsDirty(
2021 IPersistStreamInit *iface
2023 FIXME("(%p), stub!\n", iface);
2024 return E_FAIL;
2027 static HRESULT WINAPI OLEFontImpl_IPersistStreamInit_Load(
2028 IPersistStreamInit *iface, LPSTREAM pStm
2030 FIXME("(%p,%p), stub!\n", iface, pStm);
2031 return E_FAIL;
2034 static HRESULT WINAPI OLEFontImpl_IPersistStreamInit_Save(
2035 IPersistStreamInit *iface, LPSTREAM pStm, BOOL fClearDirty
2037 FIXME("(%p,%p,%d), stub!\n", iface, pStm, fClearDirty);
2038 return E_FAIL;
2041 static HRESULT WINAPI OLEFontImpl_IPersistStreamInit_GetSizeMax(
2042 IPersistStreamInit *iface, ULARGE_INTEGER *pcbSize
2044 FIXME("(%p,%p), stub!\n", iface, pcbSize);
2045 return E_FAIL;
2048 static HRESULT WINAPI OLEFontImpl_IPersistStreamInit_InitNew(
2049 IPersistStreamInit *iface
2051 FIXME("(%p), stub!\n", iface);
2052 return S_OK;
2055 static IPersistStreamInitVtbl OLEFontImpl_IPersistStreamInit_VTable =
2057 OLEFontImpl_IPersistStreamInit_QueryInterface,
2058 OLEFontImpl_IPersistStreamInit_AddRef,
2059 OLEFontImpl_IPersistStreamInit_Release,
2061 OLEFontImpl_IPersistStreamInit_GetClassID,
2062 OLEFontImpl_IPersistStreamInit_IsDirty,
2063 OLEFontImpl_IPersistStreamInit_Load,
2064 OLEFontImpl_IPersistStreamInit_Save,
2065 OLEFontImpl_IPersistStreamInit_GetSizeMax,
2066 OLEFontImpl_IPersistStreamInit_InitNew
2069 /*******************************************************************************
2070 * StdFont ClassFactory
2072 typedef struct
2074 /* IUnknown fields */
2075 IClassFactoryVtbl *lpVtbl;
2076 DWORD ref;
2077 } IClassFactoryImpl;
2079 static HRESULT WINAPI
2080 SFCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
2081 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
2083 FIXME("(%p)->(%s,%p),stub!\n",This,debugstr_guid(riid),ppobj);
2084 return E_NOINTERFACE;
2087 static ULONG WINAPI
2088 SFCF_AddRef(LPCLASSFACTORY iface) {
2089 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
2090 return ++(This->ref);
2093 static ULONG WINAPI SFCF_Release(LPCLASSFACTORY iface) {
2094 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
2095 /* static class, won't be freed */
2096 return --(This->ref);
2099 static HRESULT WINAPI SFCF_CreateInstance(
2100 LPCLASSFACTORY iface,LPUNKNOWN pOuter,REFIID riid,LPVOID *ppobj
2102 return OleCreateFontIndirect(NULL,riid,ppobj);
2106 static HRESULT WINAPI SFCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
2107 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
2108 FIXME("(%p)->(%d),stub!\n",This,dolock);
2109 return S_OK;
2112 static IClassFactoryVtbl SFCF_Vtbl = {
2113 SFCF_QueryInterface,
2114 SFCF_AddRef,
2115 SFCF_Release,
2116 SFCF_CreateInstance,
2117 SFCF_LockServer
2119 static IClassFactoryImpl STDFONT_CF = {&SFCF_Vtbl, 1 };
2121 void _get_STDFONT_CF(LPVOID *ppv) { *ppv = (LPVOID)&STDFONT_CF; }