| 1 | /* $Id: olefont.cpp,v 1.3 1999-11-18 00:27:36 davidr Exp $ */ | 
|---|
| 2 | /* | 
|---|
| 3 | * OLE Font encapsulation implementation | 
|---|
| 4 | * | 
|---|
| 5 | * This file contains an implementation of the IFont | 
|---|
| 6 | * interface and the OleCreateFontIndirect API call. | 
|---|
| 7 | * | 
|---|
| 8 | * Copyright 1999 Francis Beaudet | 
|---|
| 9 | * Copyright 1999 Sander van Leeuwen  (WINE OS/2 Port 990815) | 
|---|
| 10 | * | 
|---|
| 11 | * Project Odin Software License can be found in LICENSE.TXT | 
|---|
| 12 | * | 
|---|
| 13 | */ | 
|---|
| 14 | #include "oleaut32.h" | 
|---|
| 15 | #include <assert.h> | 
|---|
| 16 | #include <string.h> | 
|---|
| 17 | #include "winerror.h" | 
|---|
| 18 | #include "oleauto.h" | 
|---|
| 19 | #include "ocidl.h" | 
|---|
| 20 | #include "olectl.h" | 
|---|
| 21 | #include "debugtools.h" | 
|---|
| 22 | #include "heap.h" | 
|---|
| 23 |  | 
|---|
| 24 | DEFAULT_DEBUG_CHANNEL(ole) | 
|---|
| 25 |  | 
|---|
| 26 | /*********************************************************************** | 
|---|
| 27 | * Declaration of constants used when serializing the font object. | 
|---|
| 28 | */ | 
|---|
| 29 | #define FONTPERSIST_ITALIC        0x02 | 
|---|
| 30 | #define FONTPERSIST_UNDERLINE     0x04 | 
|---|
| 31 | #define FONTPERSIST_STRIKETHROUGH 0x08 | 
|---|
| 32 |  | 
|---|
| 33 | /*********************************************************************** | 
|---|
| 34 | * Declaration of the implementation class for the IFont interface | 
|---|
| 35 | */ | 
|---|
| 36 | typedef struct OLEFontImpl OLEFontImpl; | 
|---|
| 37 |  | 
|---|
| 38 | struct OLEFontImpl | 
|---|
| 39 | { | 
|---|
| 40 | /* | 
|---|
| 41 | * This class supports many interfaces. IUnknown, IFont, | 
|---|
| 42 | * IDispatch, IDispFont and IPersistStream. The first two are | 
|---|
| 43 | * supported by the first vtablem the next two are supported by | 
|---|
| 44 | * the second table and the last one has it's own. | 
|---|
| 45 | */ | 
|---|
| 46 | ICOM_VTABLE(IFont)*     lpvtbl1; | 
|---|
| 47 | ICOM_VTABLE(IDispatch)* lpvtbl2; | 
|---|
| 48 | ICOM_VTABLE(IPersistStream)*            lpvtbl3; | 
|---|
| 49 |  | 
|---|
| 50 | /* | 
|---|
| 51 | * Reference count for that instance of the class. | 
|---|
| 52 | */ | 
|---|
| 53 | ULONG ref; | 
|---|
| 54 |  | 
|---|
| 55 | /* | 
|---|
| 56 | * This structure contains the description of the class. | 
|---|
| 57 | */ | 
|---|
| 58 | FONTDESC description; | 
|---|
| 59 |  | 
|---|
| 60 | /* | 
|---|
| 61 | * Contain the font associated with this object. | 
|---|
| 62 | */ | 
|---|
| 63 | HFONT gdiFont; | 
|---|
| 64 |  | 
|---|
| 65 | /* | 
|---|
| 66 | * Font lock count. | 
|---|
| 67 | */ | 
|---|
| 68 | DWORD fontLock; | 
|---|
| 69 |  | 
|---|
| 70 | /* | 
|---|
| 71 | * Size ratio | 
|---|
| 72 | */ | 
|---|
| 73 | long cyLogical; | 
|---|
| 74 | long cyHimetric; | 
|---|
| 75 | }; | 
|---|
| 76 |  | 
|---|
| 77 | /* | 
|---|
| 78 | * Here, I define utility macros to help with the casting of the | 
|---|
| 79 | * "thisptr" parameter. | 
|---|
| 80 | * There is a version to accomodate all of the VTables implemented | 
|---|
| 81 | * by this object. | 
|---|
| 82 | */ | 
|---|
| 83 | #define _ICOM_THIS(class,name) class* thisptr = (class*)name; | 
|---|
| 84 | #define _ICOM_THIS_From_IDispatch(class, name) class* thisptr = (class*)(((char*)name)-sizeof(void*)); | 
|---|
| 85 | #define _ICOM_THIS_From_IPersistStream(class, name) class* thisptr = (class*)(((char*)name)-2*sizeof(void*)); | 
|---|
| 86 |  | 
|---|
| 87 | /*********************************************************************** | 
|---|
| 88 | * Prototypes for the implementation functions for the IFont | 
|---|
| 89 | * interface | 
|---|
| 90 | */ | 
|---|
| 91 | static OLEFontImpl* OLEFontImpl_Construct(LPFONTDESC fontDesc); | 
|---|
| 92 | static void         OLEFontImpl_Destroy(OLEFontImpl* fontDesc); | 
|---|
| 93 | static HRESULT      WINAPI OLEFontImpl_QueryInterface(IFont* iface, REFIID riid, VOID** ppvoid); | 
|---|
| 94 | static ULONG        WINAPI OLEFontImpl_AddRef(IFont* iface); | 
|---|
| 95 | static ULONG        WINAPI OLEFontImpl_Release(IFont* iface); | 
|---|
| 96 | static HRESULT      WINAPI OLEFontImpl_get_Name(IFont* iface, BSTR* pname); | 
|---|
| 97 | static HRESULT      WINAPI OLEFontImpl_put_Name(IFont* iface, BSTR name); | 
|---|
| 98 | static HRESULT      WINAPI OLEFontImpl_get_Size(IFont* iface, CY* psize); | 
|---|
| 99 | static HRESULT      WINAPI OLEFontImpl_put_Size(IFont* iface, CY size); | 
|---|
| 100 | static HRESULT      WINAPI OLEFontImpl_get_Bold(IFont* iface, BOOL* pbold); | 
|---|
| 101 | static HRESULT      WINAPI OLEFontImpl_put_Bold(IFont* iface, BOOL bold); | 
|---|
| 102 | static HRESULT      WINAPI OLEFontImpl_get_Italic(IFont* iface, BOOL* pitalic); | 
|---|
| 103 | static HRESULT      WINAPI OLEFontImpl_put_Italic(IFont* iface, BOOL italic); | 
|---|
| 104 | static HRESULT      WINAPI OLEFontImpl_get_Underline(IFont* iface, BOOL* punderline); | 
|---|
| 105 | static HRESULT      WINAPI OLEFontImpl_put_Underline(IFont* iface, BOOL underline); | 
|---|
| 106 | static HRESULT      WINAPI OLEFontImpl_get_Strikethrough(IFont* iface, BOOL* pstrikethrough); | 
|---|
| 107 | static HRESULT      WINAPI OLEFontImpl_put_Strikethrough(IFont* iface, BOOL strikethrough); | 
|---|
| 108 | static HRESULT      WINAPI OLEFontImpl_get_Weight(IFont* iface, short* pweight); | 
|---|
| 109 | static HRESULT      WINAPI OLEFontImpl_put_Weight(IFont* iface, short weight); | 
|---|
| 110 | static HRESULT      WINAPI OLEFontImpl_get_Charset(IFont* iface, short* pcharset); | 
|---|
| 111 | static HRESULT      WINAPI OLEFontImpl_put_Charset(IFont* iface, short charset); | 
|---|
| 112 | static HRESULT      WINAPI OLEFontImpl_get_hFont(IFont* iface, HFONT* phfont); | 
|---|
| 113 | static HRESULT      WINAPI OLEFontImpl_Clone(IFont* iface, IFont** ppfont); | 
|---|
| 114 | static HRESULT      WINAPI OLEFontImpl_IsEqual(IFont* iface, IFont* pFontOther); | 
|---|
| 115 | static HRESULT      WINAPI OLEFontImpl_SetRatio(IFont* iface, long cyLogical, long cyHimetric); | 
|---|
| 116 | static HRESULT      WINAPI OLEFontImpl_QueryTextMetrics(IFont* iface, TEXTMETRICOLE* ptm); | 
|---|
| 117 | static HRESULT      WINAPI OLEFontImpl_AddRefHfont(IFont* iface, HFONT hfont); | 
|---|
| 118 | static HRESULT      WINAPI OLEFontImpl_ReleaseHfont(IFont* iface, HFONT hfont); | 
|---|
| 119 | static HRESULT      WINAPI OLEFontImpl_SetHdc(IFont* iface, HDC hdc); | 
|---|
| 120 |  | 
|---|
| 121 | /*********************************************************************** | 
|---|
| 122 | * Prototypes for the implementation functions for the IDispatch | 
|---|
| 123 | * interface | 
|---|
| 124 | */ | 
|---|
| 125 | static HRESULT WINAPI OLEFontImpl_IDispatch_QueryInterface(IDispatch* iface, | 
|---|
| 126 | REFIID     riid, | 
|---|
| 127 | VOID**     ppvoid); | 
|---|
| 128 | static ULONG   WINAPI OLEFontImpl_IDispatch_AddRef(IDispatch* iface); | 
|---|
| 129 | static ULONG   WINAPI OLEFontImpl_IDispatch_Release(IDispatch* iface); | 
|---|
| 130 | static HRESULT WINAPI OLEFontImpl_GetTypeInfoCount(IDispatch*    iface, | 
|---|
| 131 | unsigned int* pctinfo); | 
|---|
| 132 | static HRESULT WINAPI OLEFontImpl_GetTypeInfo(IDispatch*  iface, | 
|---|
| 133 | UINT      iTInfo, | 
|---|
| 134 | LCID        lcid, | 
|---|
| 135 | ITypeInfo** ppTInfo); | 
|---|
| 136 | static HRESULT WINAPI OLEFontImpl_GetIDsOfNames(IDispatch*  iface, | 
|---|
| 137 | REFIID      riid, | 
|---|
| 138 | LPOLESTR* rgszNames, | 
|---|
| 139 | UINT      cNames, | 
|---|
| 140 | LCID        lcid, | 
|---|
| 141 | DISPID*     rgDispId); | 
|---|
| 142 | static HRESULT WINAPI OLEFontImpl_Invoke(IDispatch*  iface, | 
|---|
| 143 | DISPID      dispIdMember, | 
|---|
| 144 | REFIID      riid, | 
|---|
| 145 | LCID        lcid, | 
|---|
| 146 | WORD        wFlags, | 
|---|
| 147 | DISPPARAMS* pDispParams, | 
|---|
| 148 | VARIANT*    pVarResult, | 
|---|
| 149 | EXCEPINFO*  pExepInfo, | 
|---|
| 150 | UINT*     puArgErr); | 
|---|
| 151 |  | 
|---|
| 152 | /*********************************************************************** | 
|---|
| 153 | * Prototypes for the implementation functions for the IPersistStream | 
|---|
| 154 | * interface | 
|---|
| 155 | */ | 
|---|
| 156 | static HRESULT WINAPI OLEFontImpl_IPersistStream_QueryInterface(IPersistStream* iface, | 
|---|
| 157 | REFIID     riid, | 
|---|
| 158 | VOID**     ppvoid); | 
|---|
| 159 | static ULONG   WINAPI OLEFontImpl_IPersistStream_AddRef(IPersistStream* iface); | 
|---|
| 160 | static ULONG   WINAPI OLEFontImpl_IPersistStream_Release(IPersistStream* iface); | 
|---|
| 161 | static HRESULT WINAPI OLEFontImpl_GetClassID(IPersistStream* iface, | 
|---|
| 162 | CLSID*                pClassID); | 
|---|
| 163 | static HRESULT WINAPI OLEFontImpl_IsDirty(IPersistStream*  iface); | 
|---|
| 164 | static HRESULT WINAPI OLEFontImpl_Load(IPersistStream*  iface, | 
|---|
| 165 | IStream*         pLoadStream); | 
|---|
| 166 | static HRESULT WINAPI OLEFontImpl_Save(IPersistStream*  iface, | 
|---|
| 167 | IStream*         pOutStream, | 
|---|
| 168 | BOOL             fClearDirty); | 
|---|
| 169 | static HRESULT WINAPI OLEFontImpl_GetSizeMax(IPersistStream*  iface, | 
|---|
| 170 | ULARGE_INTEGER*  pcbSize); | 
|---|
| 171 |  | 
|---|
| 172 | /* | 
|---|
| 173 | * Virtual function tables for the OLEFontImpl class. | 
|---|
| 174 | */ | 
|---|
| 175 | static ICOM_VTABLE(IFont) OLEFontImpl_VTable = | 
|---|
| 176 | { | 
|---|
| 177 | ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE | 
|---|
| 178 | OLEFontImpl_QueryInterface, | 
|---|
| 179 | OLEFontImpl_AddRef, | 
|---|
| 180 | OLEFontImpl_Release, | 
|---|
| 181 | OLEFontImpl_get_Name, | 
|---|
| 182 | OLEFontImpl_put_Name, | 
|---|
| 183 | OLEFontImpl_get_Size, | 
|---|
| 184 | OLEFontImpl_put_Size, | 
|---|
| 185 | OLEFontImpl_get_Bold, | 
|---|
| 186 | OLEFontImpl_put_Bold, | 
|---|
| 187 | OLEFontImpl_get_Italic, | 
|---|
| 188 | OLEFontImpl_put_Italic, | 
|---|
| 189 | OLEFontImpl_get_Underline, | 
|---|
| 190 | OLEFontImpl_put_Underline, | 
|---|
| 191 | OLEFontImpl_get_Strikethrough, | 
|---|
| 192 | OLEFontImpl_put_Strikethrough, | 
|---|
| 193 | OLEFontImpl_get_Weight, | 
|---|
| 194 | OLEFontImpl_put_Weight, | 
|---|
| 195 | OLEFontImpl_get_Charset, | 
|---|
| 196 | OLEFontImpl_put_Charset, | 
|---|
| 197 | OLEFontImpl_get_hFont, | 
|---|
| 198 | OLEFontImpl_Clone, | 
|---|
| 199 | OLEFontImpl_IsEqual, | 
|---|
| 200 | OLEFontImpl_SetRatio, | 
|---|
| 201 | OLEFontImpl_QueryTextMetrics, | 
|---|
| 202 | OLEFontImpl_AddRefHfont, | 
|---|
| 203 | OLEFontImpl_ReleaseHfont, | 
|---|
| 204 | OLEFontImpl_SetHdc | 
|---|
| 205 | }; | 
|---|
| 206 |  | 
|---|
| 207 | static ICOM_VTABLE(IDispatch) OLEFontImpl_IDispatch_VTable = | 
|---|
| 208 | { | 
|---|
| 209 | ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE | 
|---|
| 210 | OLEFontImpl_IDispatch_QueryInterface, | 
|---|
| 211 | OLEFontImpl_IDispatch_AddRef, | 
|---|
| 212 | OLEFontImpl_IDispatch_Release, | 
|---|
| 213 | OLEFontImpl_GetTypeInfoCount, | 
|---|
| 214 | OLEFontImpl_GetTypeInfo, | 
|---|
| 215 | OLEFontImpl_GetIDsOfNames, | 
|---|
| 216 | OLEFontImpl_Invoke | 
|---|
| 217 | }; | 
|---|
| 218 |  | 
|---|
| 219 | static ICOM_VTABLE(IPersistStream) OLEFontImpl_IPersistStream_VTable = | 
|---|
| 220 | { | 
|---|
| 221 | ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE | 
|---|
| 222 | OLEFontImpl_IPersistStream_QueryInterface, | 
|---|
| 223 | OLEFontImpl_IPersistStream_AddRef, | 
|---|
| 224 | OLEFontImpl_IPersistStream_Release, | 
|---|
| 225 | OLEFontImpl_GetClassID, | 
|---|
| 226 | OLEFontImpl_IsDirty, | 
|---|
| 227 | OLEFontImpl_Load, | 
|---|
| 228 | OLEFontImpl_Save, | 
|---|
| 229 | OLEFontImpl_GetSizeMax | 
|---|
| 230 | }; | 
|---|
| 231 |  | 
|---|
| 232 | /****************************************************************************** | 
|---|
| 233 | *              OleCreateFontIndirect   [OLEAUT32.420] | 
|---|
| 234 | */ | 
|---|
| 235 | INT WINAPI OleCreateFontIndirect( | 
|---|
| 236 | LPFONTDESC lpFontDesc, | 
|---|
| 237 | REFIID     riid, | 
|---|
| 238 | VOID**     ppvObj) | 
|---|
| 239 | { | 
|---|
| 240 | OLEFontImpl* newFont = 0; | 
|---|
| 241 | HRESULT      hr      = S_OK; | 
|---|
| 242 |  | 
|---|
| 243 | /* | 
|---|
| 244 | * Sanity check | 
|---|
| 245 | */ | 
|---|
| 246 | if (ppvObj==0) | 
|---|
| 247 | return E_POINTER; | 
|---|
| 248 |  | 
|---|
| 249 | *ppvObj = 0; | 
|---|
| 250 |  | 
|---|
| 251 | /* | 
|---|
| 252 | * Try to construct a new instance of the class. | 
|---|
| 253 | */ | 
|---|
| 254 | newFont = OLEFontImpl_Construct(lpFontDesc); | 
|---|
| 255 |  | 
|---|
| 256 | if (newFont == 0) | 
|---|
| 257 | return E_OUTOFMEMORY; | 
|---|
| 258 |  | 
|---|
| 259 | /* | 
|---|
| 260 | * Make sure it supports the interface required by the caller. | 
|---|
| 261 | */ | 
|---|
| 262 | hr = IFont_QueryInterface((IFont*)newFont, riid, ppvObj); | 
|---|
| 263 |  | 
|---|
| 264 | /* | 
|---|
| 265 | * Release the reference obtained in the constructor. If | 
|---|
| 266 | * the QueryInterface was unsuccessful, it will free the class. | 
|---|
| 267 | */ | 
|---|
| 268 | IFont_Release((IFont*)newFont); | 
|---|
| 269 |  | 
|---|
| 270 | return hr; | 
|---|
| 271 | } | 
|---|
| 272 |  | 
|---|
| 273 |  | 
|---|
| 274 | /*********************************************************************** | 
|---|
| 275 | * Implementation of the OLEFontImpl class. | 
|---|
| 276 | */ | 
|---|
| 277 |  | 
|---|
| 278 | /************************************************************************ | 
|---|
| 279 | * OLEFontImpl_Construct | 
|---|
| 280 | * | 
|---|
| 281 | * This method will construct a new instance of the OLEFontImpl | 
|---|
| 282 | * class. | 
|---|
| 283 | * | 
|---|
| 284 | * The caller of this method must release the object when it's | 
|---|
| 285 | * done with it. | 
|---|
| 286 | */ | 
|---|
| 287 | static OLEFontImpl* OLEFontImpl_Construct(LPFONTDESC fontDesc) | 
|---|
| 288 | { | 
|---|
| 289 | OLEFontImpl* newObject = 0; | 
|---|
| 290 |  | 
|---|
| 291 | /* | 
|---|
| 292 | * Allocate space for the object. | 
|---|
| 293 | */ | 
|---|
| 294 | newObject = (OLEFontImpl*)HeapAlloc(GetProcessHeap(), 0, sizeof(OLEFontImpl)); | 
|---|
| 295 |  | 
|---|
| 296 | if (newObject==0) | 
|---|
| 297 | return newObject; | 
|---|
| 298 |  | 
|---|
| 299 | /* | 
|---|
| 300 | * Initialize the virtual function table. | 
|---|
| 301 | */ | 
|---|
| 302 | newObject->lpvtbl1 = &OLEFontImpl_VTable; | 
|---|
| 303 | newObject->lpvtbl2 = &OLEFontImpl_IDispatch_VTable; | 
|---|
| 304 | newObject->lpvtbl3 = &OLEFontImpl_IPersistStream_VTable; | 
|---|
| 305 |  | 
|---|
| 306 | /* | 
|---|
| 307 | * Start with one reference count. The caller of this function | 
|---|
| 308 | * must release the interface pointer when it is done. | 
|---|
| 309 | */ | 
|---|
| 310 | newObject->ref = 1; | 
|---|
| 311 |  | 
|---|
| 312 | /* | 
|---|
| 313 | * Copy the description of the font in the object. | 
|---|
| 314 | */ | 
|---|
| 315 | assert(fontDesc->cbSizeofstruct >= sizeof(FONTDESC)); | 
|---|
| 316 |  | 
|---|
| 317 | newObject->description.cbSizeofstruct = sizeof(FONTDESC); | 
|---|
| 318 | newObject->description.lpstrName = (LPWSTR)HeapAlloc(GetProcessHeap(), | 
|---|
| 319 | 0, | 
|---|
| 320 | (lstrlenW(fontDesc->lpstrName)+1) * sizeof(WCHAR)); | 
|---|
| 321 | lstrcpyW(newObject->description.lpstrName, fontDesc->lpstrName); | 
|---|
| 322 | newObject->description.cySize         = fontDesc->cySize; | 
|---|
| 323 | newObject->description.sWeight        = fontDesc->sWeight; | 
|---|
| 324 | newObject->description.sCharset       = fontDesc->sCharset; | 
|---|
| 325 | newObject->description.fItalic        = fontDesc->fItalic; | 
|---|
| 326 | newObject->description.fUnderline     = fontDesc->fUnderline; | 
|---|
| 327 | newObject->description.fStrikethrough = fontDesc->fStrikethrough; | 
|---|
| 328 |  | 
|---|
| 329 | /* | 
|---|
| 330 | * Initializing all the other members. | 
|---|
| 331 | */ | 
|---|
| 332 | newObject->gdiFont  = 0; | 
|---|
| 333 | newObject->fontLock = 0; | 
|---|
| 334 | newObject->cyHimetric = 1; | 
|---|
| 335 | newObject->cyLogical  = 1; | 
|---|
| 336 |  | 
|---|
| 337 | return newObject; | 
|---|
| 338 | } | 
|---|
| 339 |  | 
|---|
| 340 | /************************************************************************ | 
|---|
| 341 | * OLEFontImpl_Construct | 
|---|
| 342 | * | 
|---|
| 343 | * This method is called by the Release method when the reference | 
|---|
| 344 | * count goes doen to 0. it will free all resources used by | 
|---|
| 345 | * this object. | 
|---|
| 346 | */ | 
|---|
| 347 | static void OLEFontImpl_Destroy(OLEFontImpl* fontDesc) | 
|---|
| 348 | { | 
|---|
| 349 | if (fontDesc->description.lpstrName!=0) | 
|---|
| 350 | HeapFree(GetProcessHeap(), 0, fontDesc->description.lpstrName); | 
|---|
| 351 |  | 
|---|
| 352 | if (fontDesc->gdiFont!=0) | 
|---|
| 353 | DeleteObject(fontDesc->gdiFont); | 
|---|
| 354 |  | 
|---|
| 355 | HeapFree(GetProcessHeap(), 0, fontDesc); | 
|---|
| 356 | } | 
|---|
| 357 |  | 
|---|
| 358 | /************************************************************************ | 
|---|
| 359 | * OLEFontImpl_QueryInterface (IUnknown) | 
|---|
| 360 | * | 
|---|
| 361 | * See Windows documentation for more details on IUnknown methods. | 
|---|
| 362 | */ | 
|---|
| 363 | HRESULT WINAPI OLEFontImpl_QueryInterface( | 
|---|
| 364 | IFont*  iface, | 
|---|
| 365 | REFIID  riid, | 
|---|
| 366 | void**  ppvObject) | 
|---|
| 367 | { | 
|---|
| 368 | _ICOM_THIS(OLEFontImpl, iface); | 
|---|
| 369 |  | 
|---|
| 370 | /* | 
|---|
| 371 | * Perform a sanity check on the parameters. | 
|---|
| 372 | */ | 
|---|
| 373 | if ( (thisptr==0) || (ppvObject==0) ) | 
|---|
| 374 | return E_INVALIDARG; | 
|---|
| 375 |  | 
|---|
| 376 | /* | 
|---|
| 377 | * Initialize the return parameter. | 
|---|
| 378 | */ | 
|---|
| 379 | *ppvObject = 0; | 
|---|
| 380 |  | 
|---|
| 381 | /* | 
|---|
| 382 | * Compare the riid with the interface IDs implemented by this object. | 
|---|
| 383 | */ | 
|---|
| 384 | if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0) | 
|---|
| 385 | { | 
|---|
| 386 | *ppvObject = (IFont*)thisptr; | 
|---|
| 387 | } | 
|---|
| 388 | else if (memcmp(&IID_IFont, riid, sizeof(IID_IFont)) == 0) | 
|---|
| 389 | { | 
|---|
| 390 | *ppvObject = (IFont*)thisptr; | 
|---|
| 391 | } | 
|---|
| 392 | else if (memcmp(&IID_IDispatch, riid, sizeof(IID_IDispatch)) == 0) | 
|---|
| 393 | { | 
|---|
| 394 | *ppvObject = (IDispatch*)&(thisptr->lpvtbl2); | 
|---|
| 395 | } | 
|---|
| 396 | else if (memcmp(&IID_IFontDisp, riid, sizeof(IID_IFontDisp)) == 0) | 
|---|
| 397 | { | 
|---|
| 398 | *ppvObject = (IDispatch*)&(thisptr->lpvtbl2); | 
|---|
| 399 | } | 
|---|
| 400 | else if (memcmp(&IID_IPersistStream, riid, sizeof(IID_IPersistStream)) == 0) | 
|---|
| 401 | { | 
|---|
| 402 | *ppvObject = (IPersistStream*)&(thisptr->lpvtbl3); | 
|---|
| 403 | } | 
|---|
| 404 |  | 
|---|
| 405 | /* | 
|---|
| 406 | * Check that we obtained an interface. | 
|---|
| 407 | */ | 
|---|
| 408 | if ((*ppvObject)==0) | 
|---|
| 409 | { | 
|---|
| 410 | char clsid[50]; | 
|---|
| 411 |  | 
|---|
| 412 | WINE_StringFromCLSID((LPCLSID)riid,clsid); | 
|---|
| 413 |  | 
|---|
| 414 | WARN( | 
|---|
| 415 | "OLEAUT32: IFont->QueryInterface(%s) : unsupported interface requested!", | 
|---|
| 416 | clsid); | 
|---|
| 417 |  | 
|---|
| 418 | return E_NOINTERFACE; | 
|---|
| 419 | } | 
|---|
| 420 |  | 
|---|
| 421 | /* | 
|---|
| 422 | * Query Interface always increases the reference count by one when it is | 
|---|
| 423 | * successful | 
|---|
| 424 | */ | 
|---|
| 425 | OLEFontImpl_AddRef((IFont*)thisptr); | 
|---|
| 426 |  | 
|---|
| 427 | return S_OK;; | 
|---|
| 428 | } | 
|---|
| 429 |  | 
|---|
| 430 | /************************************************************************ | 
|---|
| 431 | * OLEFontImpl_AddRef (IUnknown) | 
|---|
| 432 | * | 
|---|
| 433 | * See Windows documentation for more details on IUnknown methods. | 
|---|
| 434 | */ | 
|---|
| 435 | ULONG WINAPI OLEFontImpl_AddRef( | 
|---|
| 436 | IFont* iface) | 
|---|
| 437 | { | 
|---|
| 438 | _ICOM_THIS(OLEFontImpl, iface); | 
|---|
| 439 |  | 
|---|
| 440 | thisptr->ref++; | 
|---|
| 441 |  | 
|---|
| 442 | return thisptr->ref; | 
|---|
| 443 | } | 
|---|
| 444 |  | 
|---|
| 445 | /************************************************************************ | 
|---|
| 446 | * OLEFontImpl_Release (IUnknown) | 
|---|
| 447 | * | 
|---|
| 448 | * See Windows documentation for more details on IUnknown methods. | 
|---|
| 449 | */ | 
|---|
| 450 | ULONG WINAPI OLEFontImpl_Release( | 
|---|
| 451 | IFont* iface) | 
|---|
| 452 | { | 
|---|
| 453 | _ICOM_THIS(OLEFontImpl, iface); | 
|---|
| 454 |  | 
|---|
| 455 | /* | 
|---|
| 456 | * Decrease the reference count on this object. | 
|---|
| 457 | */ | 
|---|
| 458 | thisptr->ref--; | 
|---|
| 459 |  | 
|---|
| 460 | /* | 
|---|
| 461 | * If the reference count goes down to 0, perform suicide. | 
|---|
| 462 | */ | 
|---|
| 463 | if (thisptr->ref==0) | 
|---|
| 464 | { | 
|---|
| 465 | OLEFontImpl_Destroy(thisptr); | 
|---|
| 466 |  | 
|---|
| 467 | return 0; | 
|---|
| 468 | } | 
|---|
| 469 |  | 
|---|
| 470 | return thisptr->ref; | 
|---|
| 471 | } | 
|---|
| 472 |  | 
|---|
| 473 | /************************************************************************ | 
|---|
| 474 | * OLEFontImpl_get_Name (IFont) | 
|---|
| 475 | * | 
|---|
| 476 | * See Windows documentation for more details on IFont methods. | 
|---|
| 477 | */ | 
|---|
| 478 | static HRESULT WINAPI OLEFontImpl_get_Name( | 
|---|
| 479 | IFont*  iface, | 
|---|
| 480 | BSTR* pname) | 
|---|
| 481 | { | 
|---|
| 482 | _ICOM_THIS(OLEFontImpl, iface); | 
|---|
| 483 |  | 
|---|
| 484 | /* | 
|---|
| 485 | * Sanity check. | 
|---|
| 486 | */ | 
|---|
| 487 | if (pname==0) | 
|---|
| 488 | return E_POINTER; | 
|---|
| 489 |  | 
|---|
| 490 | if (thisptr->description.lpstrName!=0) | 
|---|
| 491 | *pname = SysAllocString(thisptr->description.lpstrName); | 
|---|
| 492 | else | 
|---|
| 493 | *pname = 0; | 
|---|
| 494 |  | 
|---|
| 495 | return S_OK; | 
|---|
| 496 | } | 
|---|
| 497 |  | 
|---|
| 498 | /************************************************************************ | 
|---|
| 499 | * OLEFontImpl_put_Name (IFont) | 
|---|
| 500 | * | 
|---|
| 501 | * See Windows documentation for more details on IFont methods. | 
|---|
| 502 | */ | 
|---|
| 503 | static HRESULT WINAPI OLEFontImpl_put_Name( | 
|---|
| 504 | IFont* iface, | 
|---|
| 505 | BSTR name) | 
|---|
| 506 | { | 
|---|
| 507 | _ICOM_THIS(OLEFontImpl, iface); | 
|---|
| 508 |  | 
|---|
| 509 | if (thisptr->description.lpstrName==0) | 
|---|
| 510 | { | 
|---|
| 511 | thisptr->description.lpstrName = (LPWSTR)HeapAlloc(GetProcessHeap(), | 
|---|
| 512 | 0, | 
|---|
| 513 | (lstrlenW(name)+1) * sizeof(WCHAR)); | 
|---|
| 514 | } | 
|---|
| 515 | else | 
|---|
| 516 | { | 
|---|
| 517 | thisptr->description.lpstrName = (LPWSTR)HeapReAlloc(GetProcessHeap(), | 
|---|
| 518 | 0, | 
|---|
| 519 | thisptr->description.lpstrName, | 
|---|
| 520 | (lstrlenW(name)+1) * sizeof(WCHAR)); | 
|---|
| 521 | } | 
|---|
| 522 |  | 
|---|
| 523 | if (thisptr->description.lpstrName==0) | 
|---|
| 524 | return E_OUTOFMEMORY; | 
|---|
| 525 |  | 
|---|
| 526 | lstrcpyW(thisptr->description.lpstrName, name); | 
|---|
| 527 |  | 
|---|
| 528 | return S_OK; | 
|---|
| 529 | } | 
|---|
| 530 |  | 
|---|
| 531 | /************************************************************************ | 
|---|
| 532 | * OLEFontImpl_get_Size (IFont) | 
|---|
| 533 | * | 
|---|
| 534 | * See Windows documentation for more details on IFont methods. | 
|---|
| 535 | */ | 
|---|
| 536 | static HRESULT WINAPI OLEFontImpl_get_Size( | 
|---|
| 537 | IFont* iface, | 
|---|
| 538 | CY*    psize) | 
|---|
| 539 | { | 
|---|
| 540 | _ICOM_THIS(OLEFontImpl, iface); | 
|---|
| 541 |  | 
|---|
| 542 | /* | 
|---|
| 543 | * Sanity check | 
|---|
| 544 | */ | 
|---|
| 545 | if (psize==0) | 
|---|
| 546 | return E_POINTER; | 
|---|
| 547 |  | 
|---|
| 548 | psize->u.Hi = 0; | 
|---|
| 549 | psize->u.Lo = thisptr->description.cySize.u.Lo; | 
|---|
| 550 |  | 
|---|
| 551 | return S_OK; | 
|---|
| 552 | } | 
|---|
| 553 |  | 
|---|
| 554 | /************************************************************************ | 
|---|
| 555 | * OLEFontImpl_put_Size (IFont) | 
|---|
| 556 | * | 
|---|
| 557 | * See Windows documentation for more details on IFont methods. | 
|---|
| 558 | */ | 
|---|
| 559 | static HRESULT WINAPI OLEFontImpl_put_Size( | 
|---|
| 560 | IFont* iface, | 
|---|
| 561 | CY     size) | 
|---|
| 562 | { | 
|---|
| 563 | _ICOM_THIS(OLEFontImpl, iface); | 
|---|
| 564 |  | 
|---|
| 565 | thisptr->description.cySize.u.Hi = 0; | 
|---|
| 566 | thisptr->description.cySize.u.Lo = thisptr->description.cySize.u.Lo; | 
|---|
| 567 |  | 
|---|
| 568 | return S_OK; | 
|---|
| 569 | } | 
|---|
| 570 |  | 
|---|
| 571 | /************************************************************************ | 
|---|
| 572 | * OLEFontImpl_get_Bold (IFont) | 
|---|
| 573 | * | 
|---|
| 574 | * See Windows documentation for more details on IFont methods. | 
|---|
| 575 | */ | 
|---|
| 576 | static HRESULT WINAPI OLEFontImpl_get_Bold( | 
|---|
| 577 | IFont*  iface, | 
|---|
| 578 | BOOL* pbold) | 
|---|
| 579 | { | 
|---|
| 580 | FIXME("():Stub\n"); | 
|---|
| 581 | return E_NOTIMPL; | 
|---|
| 582 | } | 
|---|
| 583 |  | 
|---|
| 584 | /************************************************************************ | 
|---|
| 585 | * OLEFontImpl_put_Bold (IFont) | 
|---|
| 586 | * | 
|---|
| 587 | * See Windows documentation for more details on IFont methods. | 
|---|
| 588 | */ | 
|---|
| 589 | static HRESULT WINAPI OLEFontImpl_put_Bold( | 
|---|
| 590 | IFont* iface, | 
|---|
| 591 | BOOL bold) | 
|---|
| 592 | { | 
|---|
| 593 | FIXME("():Stub\n"); | 
|---|
| 594 | return E_NOTIMPL; | 
|---|
| 595 | } | 
|---|
| 596 |  | 
|---|
| 597 | /************************************************************************ | 
|---|
| 598 | * OLEFontImpl_get_Italic (IFont) | 
|---|
| 599 | * | 
|---|
| 600 | * See Windows documentation for more details on IFont methods. | 
|---|
| 601 | */ | 
|---|
| 602 | static HRESULT WINAPI OLEFontImpl_get_Italic( | 
|---|
| 603 | IFont*  iface, | 
|---|
| 604 | BOOL* pitalic) | 
|---|
| 605 | { | 
|---|
| 606 | _ICOM_THIS(OLEFontImpl, iface); | 
|---|
| 607 |  | 
|---|
| 608 | /* | 
|---|
| 609 | * Sanity check | 
|---|
| 610 | */ | 
|---|
| 611 | if (pitalic==0) | 
|---|
| 612 | return E_POINTER; | 
|---|
| 613 |  | 
|---|
| 614 | *pitalic = thisptr->description.fItalic; | 
|---|
| 615 |  | 
|---|
| 616 | return S_OK; | 
|---|
| 617 | } | 
|---|
| 618 |  | 
|---|
| 619 | /************************************************************************ | 
|---|
| 620 | * OLEFontImpl_put_Italic (IFont) | 
|---|
| 621 | * | 
|---|
| 622 | * See Windows documentation for more details on IFont methods. | 
|---|
| 623 | */ | 
|---|
| 624 | static HRESULT WINAPI OLEFontImpl_put_Italic( | 
|---|
| 625 | IFont* iface, | 
|---|
| 626 | BOOL italic) | 
|---|
| 627 | { | 
|---|
| 628 | _ICOM_THIS(OLEFontImpl, iface); | 
|---|
| 629 |  | 
|---|
| 630 | thisptr->description.fItalic = italic; | 
|---|
| 631 |  | 
|---|
| 632 | return S_OK; | 
|---|
| 633 | } | 
|---|
| 634 |  | 
|---|
| 635 | /************************************************************************ | 
|---|
| 636 | * OLEFontImpl_get_Underline (IFont) | 
|---|
| 637 | * | 
|---|
| 638 | * See Windows documentation for more details on IFont methods. | 
|---|
| 639 | */ | 
|---|
| 640 | static HRESULT WINAPI OLEFontImpl_get_Underline( | 
|---|
| 641 | IFont*  iface, | 
|---|
| 642 | BOOL* punderline) | 
|---|
| 643 | { | 
|---|
| 644 | _ICOM_THIS(OLEFontImpl, iface); | 
|---|
| 645 |  | 
|---|
| 646 | /* | 
|---|
| 647 | * Sanity check | 
|---|
| 648 | */ | 
|---|
| 649 | if (punderline==0) | 
|---|
| 650 | return E_POINTER; | 
|---|
| 651 |  | 
|---|
| 652 | *punderline = thisptr->description.fUnderline; | 
|---|
| 653 |  | 
|---|
| 654 | return S_OK; | 
|---|
| 655 | } | 
|---|
| 656 |  | 
|---|
| 657 | /************************************************************************ | 
|---|
| 658 | * OLEFontImpl_put_Underline (IFont) | 
|---|
| 659 | * | 
|---|
| 660 | * See Windows documentation for more details on IFont methods. | 
|---|
| 661 | */ | 
|---|
| 662 | static HRESULT WINAPI OLEFontImpl_put_Underline( | 
|---|
| 663 | IFont* iface, | 
|---|
| 664 | BOOL underline) | 
|---|
| 665 | { | 
|---|
| 666 | _ICOM_THIS(OLEFontImpl, iface); | 
|---|
| 667 |  | 
|---|
| 668 | thisptr->description.fUnderline = underline; | 
|---|
| 669 |  | 
|---|
| 670 | return S_OK; | 
|---|
| 671 | } | 
|---|
| 672 |  | 
|---|
| 673 | /************************************************************************ | 
|---|
| 674 | * OLEFontImpl_get_Strikethrough (IFont) | 
|---|
| 675 | * | 
|---|
| 676 | * See Windows documentation for more details on IFont methods. | 
|---|
| 677 | */ | 
|---|
| 678 | static HRESULT WINAPI OLEFontImpl_get_Strikethrough( | 
|---|
| 679 | IFont*  iface, | 
|---|
| 680 | BOOL* pstrikethrough) | 
|---|
| 681 | { | 
|---|
| 682 | _ICOM_THIS(OLEFontImpl, iface); | 
|---|
| 683 |  | 
|---|
| 684 | /* | 
|---|
| 685 | * Sanity check | 
|---|
| 686 | */ | 
|---|
| 687 | if (pstrikethrough==0) | 
|---|
| 688 | return E_POINTER; | 
|---|
| 689 |  | 
|---|
| 690 | *pstrikethrough = thisptr->description.fStrikethrough; | 
|---|
| 691 |  | 
|---|
| 692 | return S_OK; | 
|---|
| 693 | } | 
|---|
| 694 |  | 
|---|
| 695 | /************************************************************************ | 
|---|
| 696 | * OLEFontImpl_put_Strikethrough (IFont) | 
|---|
| 697 | * | 
|---|
| 698 | * See Windows documentation for more details on IFont methods. | 
|---|
| 699 | */ | 
|---|
| 700 | static HRESULT WINAPI OLEFontImpl_put_Strikethrough( | 
|---|
| 701 | IFont* iface, | 
|---|
| 702 | BOOL strikethrough) | 
|---|
| 703 | { | 
|---|
| 704 | _ICOM_THIS(OLEFontImpl, iface); | 
|---|
| 705 |  | 
|---|
| 706 | thisptr->description.fStrikethrough = strikethrough; | 
|---|
| 707 |  | 
|---|
| 708 | return S_OK; | 
|---|
| 709 | } | 
|---|
| 710 |  | 
|---|
| 711 | /************************************************************************ | 
|---|
| 712 | * OLEFontImpl_get_Weight (IFont) | 
|---|
| 713 | * | 
|---|
| 714 | * See Windows documentation for more details on IFont methods. | 
|---|
| 715 | */ | 
|---|
| 716 | static HRESULT WINAPI OLEFontImpl_get_Weight( | 
|---|
| 717 | IFont* iface, | 
|---|
| 718 | short* pweight) | 
|---|
| 719 | { | 
|---|
| 720 | _ICOM_THIS(OLEFontImpl, iface); | 
|---|
| 721 |  | 
|---|
| 722 | /* | 
|---|
| 723 | * Sanity check | 
|---|
| 724 | */ | 
|---|
| 725 | if (pweight==0) | 
|---|
| 726 | return E_POINTER; | 
|---|
| 727 |  | 
|---|
| 728 | *pweight = thisptr->description.sWeight; | 
|---|
| 729 |  | 
|---|
| 730 | return S_OK; | 
|---|
| 731 | } | 
|---|
| 732 |  | 
|---|
| 733 | /************************************************************************ | 
|---|
| 734 | * OLEFontImpl_put_Weight (IFont) | 
|---|
| 735 | * | 
|---|
| 736 | * See Windows documentation for more details on IFont methods. | 
|---|
| 737 | */ | 
|---|
| 738 | static HRESULT WINAPI OLEFontImpl_put_Weight( | 
|---|
| 739 | IFont* iface, | 
|---|
| 740 | short  weight) | 
|---|
| 741 | { | 
|---|
| 742 | _ICOM_THIS(OLEFontImpl, iface); | 
|---|
| 743 |  | 
|---|
| 744 | thisptr->description.sWeight = weight; | 
|---|
| 745 |  | 
|---|
| 746 | return S_OK; | 
|---|
| 747 | } | 
|---|
| 748 |  | 
|---|
| 749 | /************************************************************************ | 
|---|
| 750 | * OLEFontImpl_get_Charset (IFont) | 
|---|
| 751 | * | 
|---|
| 752 | * See Windows documentation for more details on IFont methods. | 
|---|
| 753 | */ | 
|---|
| 754 | static HRESULT WINAPI OLEFontImpl_get_Charset( | 
|---|
| 755 | IFont* iface, | 
|---|
| 756 | short* pcharset) | 
|---|
| 757 | { | 
|---|
| 758 | _ICOM_THIS(OLEFontImpl, iface); | 
|---|
| 759 |  | 
|---|
| 760 | /* | 
|---|
| 761 | * Sanity check | 
|---|
| 762 | */ | 
|---|
| 763 | if (pcharset==0) | 
|---|
| 764 | return E_POINTER; | 
|---|
| 765 |  | 
|---|
| 766 | *pcharset = thisptr->description.sCharset; | 
|---|
| 767 |  | 
|---|
| 768 | return S_OK; | 
|---|
| 769 | } | 
|---|
| 770 |  | 
|---|
| 771 | /************************************************************************ | 
|---|
| 772 | * OLEFontImpl_put_Charset (IFont) | 
|---|
| 773 | * | 
|---|
| 774 | * See Windows documentation for more details on IFont methods. | 
|---|
| 775 | */ | 
|---|
| 776 | static HRESULT WINAPI OLEFontImpl_put_Charset( | 
|---|
| 777 | IFont* iface, | 
|---|
| 778 | short charset) | 
|---|
| 779 | { | 
|---|
| 780 | _ICOM_THIS(OLEFontImpl, iface); | 
|---|
| 781 |  | 
|---|
| 782 | thisptr->description.sCharset = charset; | 
|---|
| 783 |  | 
|---|
| 784 | return S_OK; | 
|---|
| 785 | } | 
|---|
| 786 |  | 
|---|
| 787 | /************************************************************************ | 
|---|
| 788 | * OLEFontImpl_get_hFont (IFont) | 
|---|
| 789 | * | 
|---|
| 790 | * See Windows documentation for more details on IFont methods. | 
|---|
| 791 | */ | 
|---|
| 792 | static HRESULT WINAPI OLEFontImpl_get_hFont( | 
|---|
| 793 | IFont*   iface, | 
|---|
| 794 | HFONT* phfont) | 
|---|
| 795 | { | 
|---|
| 796 | _ICOM_THIS(OLEFontImpl, iface); | 
|---|
| 797 |  | 
|---|
| 798 | if (phfont==NULL) | 
|---|
| 799 | return E_POINTER; | 
|---|
| 800 |  | 
|---|
| 801 | /* | 
|---|
| 802 | * Realize the font if necessary | 
|---|
| 803 | */ | 
|---|
| 804 | if (thisptr->gdiFont==0) | 
|---|
| 805 | { | 
|---|
| 806 | LOGFONTW logFont; | 
|---|
| 807 | INT      fontHeight; | 
|---|
| 808 | CY       cySize; | 
|---|
| 809 |  | 
|---|
| 810 | /* | 
|---|
| 811 | * The height of the font returned by the get_Size property is the | 
|---|
| 812 | * height of the font in points multiplied by 10000... Using some | 
|---|
| 813 | * simple conversions and the ratio given by the application, it can | 
|---|
| 814 | * be converted to a height in pixels. | 
|---|
| 815 | */ | 
|---|
| 816 | IFont_get_Size(iface, &cySize); | 
|---|
| 817 |  | 
|---|
| 818 | fontHeight = MulDiv(cySize.u.Lo, 2540L, 72L); | 
|---|
| 819 | fontHeight = MulDiv(fontHeight, thisptr->cyLogical,thisptr->cyHimetric); | 
|---|
| 820 |  | 
|---|
| 821 | memset(&logFont, 0, sizeof(LOGFONTW)); | 
|---|
| 822 |  | 
|---|
| 823 | logFont.lfHeight          = ((fontHeight%10000L)>5000L) ? (-fontHeight/10000L)-1 : | 
|---|
| 824 | (-fontHeight/10000L); | 
|---|
| 825 | logFont.lfItalic          = thisptr->description.fItalic; | 
|---|
| 826 | logFont.lfUnderline       = thisptr->description.fUnderline; | 
|---|
| 827 | logFont.lfStrikeOut       = thisptr->description.fStrikethrough; | 
|---|
| 828 | logFont.lfWeight          = thisptr->description.sWeight; | 
|---|
| 829 | logFont.lfCharSet         = thisptr->description.sCharset; | 
|---|
| 830 | logFont.lfOutPrecision    = OUT_CHARACTER_PRECIS; | 
|---|
| 831 | logFont.lfClipPrecision   = CLIP_DEFAULT_PRECIS; | 
|---|
| 832 | logFont.lfQuality         = DEFAULT_QUALITY; | 
|---|
| 833 | logFont.lfPitchAndFamily  = DEFAULT_PITCH; | 
|---|
| 834 | lstrcpyW(logFont.lfFaceName,thisptr->description.lpstrName); | 
|---|
| 835 |  | 
|---|
| 836 | thisptr->gdiFont = CreateFontIndirectW(&logFont); | 
|---|
| 837 | } | 
|---|
| 838 |  | 
|---|
| 839 | *phfont = thisptr->gdiFont; | 
|---|
| 840 |  | 
|---|
| 841 | return S_OK; | 
|---|
| 842 | } | 
|---|
| 843 |  | 
|---|
| 844 | /************************************************************************ | 
|---|
| 845 | * OLEFontImpl_Clone (IFont) | 
|---|
| 846 | * | 
|---|
| 847 | * See Windows documentation for more details on IFont methods. | 
|---|
| 848 | */ | 
|---|
| 849 | static HRESULT WINAPI OLEFontImpl_Clone( | 
|---|
| 850 | IFont*  iface, | 
|---|
| 851 | IFont** ppfont) | 
|---|
| 852 | { | 
|---|
| 853 | OLEFontImpl* newObject = 0; | 
|---|
| 854 |  | 
|---|
| 855 | _ICOM_THIS(OLEFontImpl, iface); | 
|---|
| 856 |  | 
|---|
| 857 | if (ppfont == NULL) | 
|---|
| 858 | return E_POINTER; | 
|---|
| 859 |  | 
|---|
| 860 | *ppfont = NULL; | 
|---|
| 861 |  | 
|---|
| 862 | /* | 
|---|
| 863 | * Allocate space for the object. | 
|---|
| 864 | */ | 
|---|
| 865 | newObject = (OLEFontImpl*) HeapAlloc(GetProcessHeap(), 0, sizeof(OLEFontImpl)); | 
|---|
| 866 |  | 
|---|
| 867 | if (newObject==NULL) | 
|---|
| 868 | return E_OUTOFMEMORY; | 
|---|
| 869 |  | 
|---|
| 870 | *newObject = *thisptr; | 
|---|
| 871 |  | 
|---|
| 872 | /* | 
|---|
| 873 | * That new object starts with a reference count of 1 | 
|---|
| 874 | */ | 
|---|
| 875 | newObject->ref          = 1; | 
|---|
| 876 |  | 
|---|
| 877 | *ppfont = (IFont*)newObject; | 
|---|
| 878 |  | 
|---|
| 879 | return S_OK; | 
|---|
| 880 | } | 
|---|
| 881 |  | 
|---|
| 882 | /************************************************************************ | 
|---|
| 883 | * OLEFontImpl_IsEqual (IFont) | 
|---|
| 884 | * | 
|---|
| 885 | * See Windows documentation for more details on IFont methods. | 
|---|
| 886 | */ | 
|---|
| 887 | static HRESULT WINAPI OLEFontImpl_IsEqual( | 
|---|
| 888 | IFont* iface, | 
|---|
| 889 | IFont* pFontOther) | 
|---|
| 890 | { | 
|---|
| 891 | FIXME("():Stub\n"); | 
|---|
| 892 | return E_NOTIMPL; | 
|---|
| 893 | } | 
|---|
| 894 |  | 
|---|
| 895 | /************************************************************************ | 
|---|
| 896 | * OLEFontImpl_SetRatio (IFont) | 
|---|
| 897 | * | 
|---|
| 898 | * See Windows documentation for more details on IFont methods. | 
|---|
| 899 | */ | 
|---|
| 900 | static HRESULT WINAPI OLEFontImpl_SetRatio( | 
|---|
| 901 | IFont* iface, | 
|---|
| 902 | long   cyLogical, | 
|---|
| 903 | long   cyHimetric) | 
|---|
| 904 | { | 
|---|
| 905 | _ICOM_THIS(OLEFontImpl, iface); | 
|---|
| 906 |  | 
|---|
| 907 | thisptr->cyLogical  = cyLogical; | 
|---|
| 908 | thisptr->cyHimetric = cyHimetric; | 
|---|
| 909 |  | 
|---|
| 910 | return S_OK; | 
|---|
| 911 | } | 
|---|
| 912 |  | 
|---|
| 913 | /************************************************************************ | 
|---|
| 914 | * OLEFontImpl_QueryTextMetrics (IFont) | 
|---|
| 915 | * | 
|---|
| 916 | * See Windows documentation for more details on IFont methods. | 
|---|
| 917 | */ | 
|---|
| 918 | static HRESULT      WINAPI OLEFontImpl_QueryTextMetrics( | 
|---|
| 919 | IFont*         iface, | 
|---|
| 920 | TEXTMETRICOLE* ptm) | 
|---|
| 921 | { | 
|---|
| 922 | FIXME("():Stub\n"); | 
|---|
| 923 | return E_NOTIMPL; | 
|---|
| 924 | } | 
|---|
| 925 |  | 
|---|
| 926 | /************************************************************************ | 
|---|
| 927 | * OLEFontImpl_AddRefHfont (IFont) | 
|---|
| 928 | * | 
|---|
| 929 | * See Windows documentation for more details on IFont methods. | 
|---|
| 930 | */ | 
|---|
| 931 | static HRESULT WINAPI OLEFontImpl_AddRefHfont( | 
|---|
| 932 | IFont*  iface, | 
|---|
| 933 | HFONT hfont) | 
|---|
| 934 | { | 
|---|
| 935 | _ICOM_THIS(OLEFontImpl, iface); | 
|---|
| 936 |  | 
|---|
| 937 | if ( (hfont == 0) || | 
|---|
| 938 | (hfont != thisptr->gdiFont) ) | 
|---|
| 939 | return E_INVALIDARG; | 
|---|
| 940 |  | 
|---|
| 941 | thisptr->fontLock++; | 
|---|
| 942 |  | 
|---|
| 943 | return S_OK; | 
|---|
| 944 | } | 
|---|
| 945 |  | 
|---|
| 946 | /************************************************************************ | 
|---|
| 947 | * OLEFontImpl_ReleaseHfont (IFont) | 
|---|
| 948 | * | 
|---|
| 949 | * See Windows documentation for more details on IFont methods. | 
|---|
| 950 | */ | 
|---|
| 951 | static HRESULT WINAPI OLEFontImpl_ReleaseHfont( | 
|---|
| 952 | IFont*  iface, | 
|---|
| 953 | HFONT hfont) | 
|---|
| 954 | { | 
|---|
| 955 | _ICOM_THIS(OLEFontImpl, iface); | 
|---|
| 956 |  | 
|---|
| 957 | if ( (hfont == 0) || | 
|---|
| 958 | (hfont != thisptr->gdiFont) ) | 
|---|
| 959 | return E_INVALIDARG; | 
|---|
| 960 |  | 
|---|
| 961 | thisptr->fontLock--; | 
|---|
| 962 |  | 
|---|
| 963 | /* | 
|---|
| 964 | * If we just released our last font reference, destroy it. | 
|---|
| 965 | */ | 
|---|
| 966 | if (thisptr->fontLock==0) | 
|---|
| 967 | { | 
|---|
| 968 | DeleteObject(thisptr->gdiFont); | 
|---|
| 969 | thisptr->gdiFont = 0; | 
|---|
| 970 | } | 
|---|
| 971 |  | 
|---|
| 972 | return S_OK; | 
|---|
| 973 | } | 
|---|
| 974 |  | 
|---|
| 975 | /************************************************************************ | 
|---|
| 976 | * OLEFontImpl_SetHdc (IFont) | 
|---|
| 977 | * | 
|---|
| 978 | * See Windows documentation for more details on IFont methods. | 
|---|
| 979 | */ | 
|---|
| 980 | static HRESULT WINAPI OLEFontImpl_SetHdc( | 
|---|
| 981 | IFont* iface, | 
|---|
| 982 | HDC  hdc) | 
|---|
| 983 | { | 
|---|
| 984 | FIXME("():Stub\n"); | 
|---|
| 985 | return E_NOTIMPL; | 
|---|
| 986 | } | 
|---|
| 987 |  | 
|---|
| 988 | /************************************************************************ | 
|---|
| 989 | * OLEFontImpl_IDispatch_QueryInterface (IUnknown) | 
|---|
| 990 | * | 
|---|
| 991 | * See Windows documentation for more details on IUnknown methods. | 
|---|
| 992 | */ | 
|---|
| 993 | static HRESULT WINAPI OLEFontImpl_IDispatch_QueryInterface( | 
|---|
| 994 | IDispatch* iface, | 
|---|
| 995 | REFIID     riid, | 
|---|
| 996 | VOID**     ppvoid) | 
|---|
| 997 | { | 
|---|
| 998 | _ICOM_THIS_From_IDispatch(IFont, iface); | 
|---|
| 999 |  | 
|---|
| 1000 | return IFont_QueryInterface(thisptr, riid, ppvoid); | 
|---|
| 1001 | } | 
|---|
| 1002 |  | 
|---|
| 1003 | /************************************************************************ | 
|---|
| 1004 | * OLEFontImpl_IDispatch_Release (IUnknown) | 
|---|
| 1005 | * | 
|---|
| 1006 | * See Windows documentation for more details on IUnknown methods. | 
|---|
| 1007 | */ | 
|---|
| 1008 | static ULONG WINAPI OLEFontImpl_IDispatch_Release( | 
|---|
| 1009 | IDispatch* iface) | 
|---|
| 1010 | { | 
|---|
| 1011 | _ICOM_THIS_From_IDispatch(IFont, iface); | 
|---|
| 1012 |  | 
|---|
| 1013 | return IFont_Release(thisptr); | 
|---|
| 1014 | } | 
|---|
| 1015 |  | 
|---|
| 1016 | /************************************************************************ | 
|---|
| 1017 | * OLEFontImpl_IDispatch_AddRef (IUnknown) | 
|---|
| 1018 | * | 
|---|
| 1019 | * See Windows documentation for more details on IUnknown methods. | 
|---|
| 1020 | */ | 
|---|
| 1021 | static ULONG WINAPI OLEFontImpl_IDispatch_AddRef( | 
|---|
| 1022 | IDispatch* iface) | 
|---|
| 1023 | { | 
|---|
| 1024 | _ICOM_THIS_From_IDispatch(IFont, iface); | 
|---|
| 1025 |  | 
|---|
| 1026 | return IFont_AddRef(thisptr); | 
|---|
| 1027 | } | 
|---|
| 1028 |  | 
|---|
| 1029 | /************************************************************************ | 
|---|
| 1030 | * OLEFontImpl_GetTypeInfoCount (IDispatch) | 
|---|
| 1031 | * | 
|---|
| 1032 | * See Windows documentation for more details on IDispatch methods. | 
|---|
| 1033 | */ | 
|---|
| 1034 | static HRESULT WINAPI OLEFontImpl_GetTypeInfoCount( | 
|---|
| 1035 | IDispatch*    iface, | 
|---|
| 1036 | unsigned int* pctinfo) | 
|---|
| 1037 | { | 
|---|
| 1038 | FIXME("():Stub\n"); | 
|---|
| 1039 |  | 
|---|
| 1040 | return E_NOTIMPL; | 
|---|
| 1041 | } | 
|---|
| 1042 |  | 
|---|
| 1043 | /************************************************************************ | 
|---|
| 1044 | * OLEFontImpl_GetTypeInfo (IDispatch) | 
|---|
| 1045 | * | 
|---|
| 1046 | * See Windows documentation for more details on IDispatch methods. | 
|---|
| 1047 | */ | 
|---|
| 1048 | static HRESULT WINAPI OLEFontImpl_GetTypeInfo( | 
|---|
| 1049 | IDispatch*  iface, | 
|---|
| 1050 | UINT      iTInfo, | 
|---|
| 1051 | LCID        lcid, | 
|---|
| 1052 | ITypeInfo** ppTInfo) | 
|---|
| 1053 | { | 
|---|
| 1054 | FIXME("():Stub\n"); | 
|---|
| 1055 |  | 
|---|
| 1056 | return E_NOTIMPL; | 
|---|
| 1057 | } | 
|---|
| 1058 |  | 
|---|
| 1059 | /************************************************************************ | 
|---|
| 1060 | * OLEFontImpl_GetIDsOfNames (IDispatch) | 
|---|
| 1061 | * | 
|---|
| 1062 | * See Windows documentation for more details on IDispatch methods. | 
|---|
| 1063 | */ | 
|---|
| 1064 | static HRESULT WINAPI OLEFontImpl_GetIDsOfNames( | 
|---|
| 1065 | IDispatch*  iface, | 
|---|
| 1066 | REFIID      riid, | 
|---|
| 1067 | LPOLESTR* rgszNames, | 
|---|
| 1068 | UINT      cNames, | 
|---|
| 1069 | LCID        lcid, | 
|---|
| 1070 | DISPID*     rgDispId) | 
|---|
| 1071 | { | 
|---|
| 1072 | FIXME("():Stub\n"); | 
|---|
| 1073 |  | 
|---|
| 1074 | return E_NOTIMPL; | 
|---|
| 1075 | } | 
|---|
| 1076 |  | 
|---|
| 1077 | /************************************************************************ | 
|---|
| 1078 | * OLEFontImpl_Invoke (IDispatch) | 
|---|
| 1079 | * | 
|---|
| 1080 | * See Windows documentation for more details on IDispatch methods. | 
|---|
| 1081 | */ | 
|---|
| 1082 | static HRESULT WINAPI OLEFontImpl_Invoke( | 
|---|
| 1083 | IDispatch*  iface, | 
|---|
| 1084 | DISPID      dispIdMember, | 
|---|
| 1085 | REFIID      riid, | 
|---|
| 1086 | LCID        lcid, | 
|---|
| 1087 | WORD        wFlags, | 
|---|
| 1088 | DISPPARAMS* pDispParams, | 
|---|
| 1089 | VARIANT*    pVarResult, | 
|---|
| 1090 | EXCEPINFO*  pExepInfo, | 
|---|
| 1091 | UINT*     puArgErr) | 
|---|
| 1092 | { | 
|---|
| 1093 | FIXME("():Stub\n"); | 
|---|
| 1094 |  | 
|---|
| 1095 | return E_NOTIMPL; | 
|---|
| 1096 | } | 
|---|
| 1097 |  | 
|---|
| 1098 | /************************************************************************ | 
|---|
| 1099 | * OLEFontImpl_IPersistStream_QueryInterface (IUnknown) | 
|---|
| 1100 | * | 
|---|
| 1101 | * See Windows documentation for more details on IUnknown methods. | 
|---|
| 1102 | */ | 
|---|
| 1103 | static HRESULT WINAPI OLEFontImpl_IPersistStream_QueryInterface( | 
|---|
| 1104 | IPersistStream* iface, | 
|---|
| 1105 | REFIID     riid, | 
|---|
| 1106 | VOID**     ppvoid) | 
|---|
| 1107 | { | 
|---|
| 1108 | _ICOM_THIS_From_IPersistStream(IFont, iface); | 
|---|
| 1109 |  | 
|---|
| 1110 | return IFont_QueryInterface(thisptr, riid, ppvoid); | 
|---|
| 1111 | } | 
|---|
| 1112 |  | 
|---|
| 1113 | /************************************************************************ | 
|---|
| 1114 | * OLEFontImpl_IPersistStream_Release (IUnknown) | 
|---|
| 1115 | * | 
|---|
| 1116 | * See Windows documentation for more details on IUnknown methods. | 
|---|
| 1117 | */ | 
|---|
| 1118 | static ULONG WINAPI OLEFontImpl_IPersistStream_Release( | 
|---|
| 1119 | IPersistStream* iface) | 
|---|
| 1120 | { | 
|---|
| 1121 | _ICOM_THIS_From_IPersistStream(IFont, iface); | 
|---|
| 1122 |  | 
|---|
| 1123 | return IFont_Release(thisptr); | 
|---|
| 1124 | } | 
|---|
| 1125 |  | 
|---|
| 1126 | /************************************************************************ | 
|---|
| 1127 | * OLEFontImpl_IPersistStream_AddRef (IUnknown) | 
|---|
| 1128 | * | 
|---|
| 1129 | * See Windows documentation for more details on IUnknown methods. | 
|---|
| 1130 | */ | 
|---|
| 1131 | static ULONG WINAPI OLEFontImpl_IPersistStream_AddRef( | 
|---|
| 1132 | IPersistStream* iface) | 
|---|
| 1133 | { | 
|---|
| 1134 | _ICOM_THIS_From_IPersistStream(IFont, iface); | 
|---|
| 1135 |  | 
|---|
| 1136 | return IFont_AddRef(thisptr); | 
|---|
| 1137 | } | 
|---|
| 1138 |  | 
|---|
| 1139 | /************************************************************************ | 
|---|
| 1140 | * OLEFontImpl_GetClassID (IPersistStream) | 
|---|
| 1141 | * | 
|---|
| 1142 | * See Windows documentation for more details on IPersistStream methods. | 
|---|
| 1143 | */ | 
|---|
| 1144 | static HRESULT WINAPI OLEFontImpl_GetClassID( | 
|---|
| 1145 | IPersistStream* iface, | 
|---|
| 1146 | CLSID*                pClassID) | 
|---|
| 1147 | { | 
|---|
| 1148 | if (pClassID==0) | 
|---|
| 1149 | return E_POINTER; | 
|---|
| 1150 |  | 
|---|
| 1151 | memcpy(pClassID, &CLSID_StdFont, sizeof(CLSID_StdFont)); | 
|---|
| 1152 |  | 
|---|
| 1153 | return S_OK; | 
|---|
| 1154 | } | 
|---|
| 1155 |  | 
|---|
| 1156 | /************************************************************************ | 
|---|
| 1157 | * OLEFontImpl_IsDirty (IPersistStream) | 
|---|
| 1158 | * | 
|---|
| 1159 | * See Windows documentation for more details on IPersistStream methods. | 
|---|
| 1160 | */ | 
|---|
| 1161 | static HRESULT WINAPI OLEFontImpl_IsDirty( | 
|---|
| 1162 | IPersistStream*  iface) | 
|---|
| 1163 | { | 
|---|
| 1164 | return S_OK; | 
|---|
| 1165 | } | 
|---|
| 1166 |  | 
|---|
| 1167 | /************************************************************************ | 
|---|
| 1168 | * OLEFontImpl_Load (IPersistStream) | 
|---|
| 1169 | * | 
|---|
| 1170 | * See Windows documentation for more details on IPersistStream methods. | 
|---|
| 1171 | * | 
|---|
| 1172 | * This is the format of the standard font serialization as far as I | 
|---|
| 1173 | * know | 
|---|
| 1174 | * | 
|---|
| 1175 | * Offset   Type   Value           Comment | 
|---|
| 1176 | * 0x0000   Byte   Unknown         Probably a version number, contains 0x01 | 
|---|
| 1177 | * 0x0001   Short  Charset         Charset value from the FONTDESC structure | 
|---|
| 1178 | * 0x0003   Byte   Attributes      Flags defined as follows: | 
|---|
| 1179 | *                                     00000010 - Italic | 
|---|
| 1180 | *                                     00000100 - Underline | 
|---|
| 1181 | *                                     00001000 - Strikethrough | 
|---|
| 1182 | * 0x0004   Short  Weight          Weight value from FONTDESC structure | 
|---|
| 1183 | * 0x0006   DWORD  size            "Low" portion of the cySize member of the FONTDESC | 
|---|
| 1184 | *                                 structure/ | 
|---|
| 1185 | * 0x000A   Byte   name length     Length of the font name string (no null character) | 
|---|
| 1186 | * 0x000B   String name            Name of the font (ASCII, no nul character) | 
|---|
| 1187 | */ | 
|---|
| 1188 | static HRESULT WINAPI OLEFontImpl_Load( | 
|---|
| 1189 | IPersistStream*  iface, | 
|---|
| 1190 | IStream*         pLoadStream) | 
|---|
| 1191 | { | 
|---|
| 1192 | char  readBuffer[0x100]; | 
|---|
| 1193 | ULONG cbRead; | 
|---|
| 1194 | BYTE  bVersion; | 
|---|
| 1195 | BYTE  bAttributes; | 
|---|
| 1196 | BYTE  bStringSize; | 
|---|
| 1197 |  | 
|---|
| 1198 | _ICOM_THIS_From_IPersistStream(OLEFontImpl, iface); | 
|---|
| 1199 |  | 
|---|
| 1200 | /* | 
|---|
| 1201 | * Read the version byte | 
|---|
| 1202 | */ | 
|---|
| 1203 | IStream_Read(pLoadStream, &bVersion, 1, &cbRead); | 
|---|
| 1204 |  | 
|---|
| 1205 | if ( (cbRead!=1) || | 
|---|
| 1206 | (bVersion!=0x01) ) | 
|---|
| 1207 | return E_FAIL; | 
|---|
| 1208 |  | 
|---|
| 1209 | /* | 
|---|
| 1210 | * Charset | 
|---|
| 1211 | */ | 
|---|
| 1212 | IStream_Read(pLoadStream, &thisptr->description.sCharset, 2, &cbRead); | 
|---|
| 1213 |  | 
|---|
| 1214 | if (cbRead!=2) | 
|---|
| 1215 | return E_FAIL; | 
|---|
| 1216 |  | 
|---|
| 1217 | /* | 
|---|
| 1218 | * Attributes | 
|---|
| 1219 | */ | 
|---|
| 1220 | IStream_Read(pLoadStream, &bAttributes, 1, &cbRead); | 
|---|
| 1221 |  | 
|---|
| 1222 | if (cbRead!=1) | 
|---|
| 1223 | return E_FAIL; | 
|---|
| 1224 |  | 
|---|
| 1225 | thisptr->description.fItalic        = (bAttributes & FONTPERSIST_ITALIC) != 0; | 
|---|
| 1226 | thisptr->description.fStrikethrough = (bAttributes & FONTPERSIST_STRIKETHROUGH) != 0; | 
|---|
| 1227 | thisptr->description.fUnderline     = (bAttributes & FONTPERSIST_UNDERLINE) != 0; | 
|---|
| 1228 |  | 
|---|
| 1229 | /* | 
|---|
| 1230 | * Weight | 
|---|
| 1231 | */ | 
|---|
| 1232 | IStream_Read(pLoadStream, &thisptr->description.sWeight, 2, &cbRead); | 
|---|
| 1233 |  | 
|---|
| 1234 | if (cbRead!=2) | 
|---|
| 1235 | return E_FAIL; | 
|---|
| 1236 |  | 
|---|
| 1237 | /* | 
|---|
| 1238 | * Size | 
|---|
| 1239 | */ | 
|---|
| 1240 | IStream_Read(pLoadStream, &thisptr->description.cySize.u.Lo, 4, &cbRead); | 
|---|
| 1241 |  | 
|---|
| 1242 | if (cbRead!=4) | 
|---|
| 1243 | return E_FAIL; | 
|---|
| 1244 |  | 
|---|
| 1245 | thisptr->description.cySize.u.Hi = 0; | 
|---|
| 1246 |  | 
|---|
| 1247 | /* | 
|---|
| 1248 | * FontName | 
|---|
| 1249 | */ | 
|---|
| 1250 | IStream_Read(pLoadStream, &bStringSize, 1, &cbRead); | 
|---|
| 1251 |  | 
|---|
| 1252 | if (cbRead!=1) | 
|---|
| 1253 | return E_FAIL; | 
|---|
| 1254 |  | 
|---|
| 1255 | memset(readBuffer, 0, 0x100); | 
|---|
| 1256 | IStream_Read(pLoadStream, readBuffer, bStringSize, &cbRead); | 
|---|
| 1257 |  | 
|---|
| 1258 | if (cbRead!=bStringSize) | 
|---|
| 1259 | return E_FAIL; | 
|---|
| 1260 |  | 
|---|
| 1261 | if (thisptr->description.lpstrName!=0) | 
|---|
| 1262 | HeapFree(GetProcessHeap(), 0, thisptr->description.lpstrName); | 
|---|
| 1263 |  | 
|---|
| 1264 | thisptr->description.lpstrName = HEAP_strdupAtoW(GetProcessHeap(), | 
|---|
| 1265 | HEAP_ZERO_MEMORY, | 
|---|
| 1266 | readBuffer); | 
|---|
| 1267 |  | 
|---|
| 1268 | return S_OK; | 
|---|
| 1269 | } | 
|---|
| 1270 |  | 
|---|
| 1271 | /************************************************************************ | 
|---|
| 1272 | * OLEFontImpl_Save (IPersistStream) | 
|---|
| 1273 | * | 
|---|
| 1274 | * See Windows documentation for more details on IPersistStream methods. | 
|---|
| 1275 | */ | 
|---|
| 1276 | static HRESULT WINAPI OLEFontImpl_Save( | 
|---|
| 1277 | IPersistStream*  iface, | 
|---|
| 1278 | IStream*         pOutStream, | 
|---|
| 1279 | BOOL             fClearDirty) | 
|---|
| 1280 | { | 
|---|
| 1281 | char* writeBuffer = NULL; | 
|---|
| 1282 | ULONG cbWritten; | 
|---|
| 1283 | BYTE  bVersion = 0x01; | 
|---|
| 1284 | BYTE  bAttributes; | 
|---|
| 1285 | BYTE  bStringSize; | 
|---|
| 1286 |  | 
|---|
| 1287 | _ICOM_THIS_From_IPersistStream(OLEFontImpl, iface); | 
|---|
| 1288 |  | 
|---|
| 1289 | /* | 
|---|
| 1290 | * Read the version byte | 
|---|
| 1291 | */ | 
|---|
| 1292 | IStream_Write(pOutStream, &bVersion, 1, &cbWritten); | 
|---|
| 1293 |  | 
|---|
| 1294 | if (cbWritten!=1) | 
|---|
| 1295 | return E_FAIL; | 
|---|
| 1296 |  | 
|---|
| 1297 | /* | 
|---|
| 1298 | * Charset | 
|---|
| 1299 | */ | 
|---|
| 1300 | IStream_Write(pOutStream, &thisptr->description.sCharset, 2, &cbWritten); | 
|---|
| 1301 |  | 
|---|
| 1302 | if (cbWritten!=2) | 
|---|
| 1303 | return E_FAIL; | 
|---|
| 1304 |  | 
|---|
| 1305 | /* | 
|---|
| 1306 | * Attributes | 
|---|
| 1307 | */ | 
|---|
| 1308 | bAttributes = 0; | 
|---|
| 1309 |  | 
|---|
| 1310 | if (thisptr->description.fItalic) | 
|---|
| 1311 | bAttributes |= FONTPERSIST_ITALIC; | 
|---|
| 1312 |  | 
|---|
| 1313 | if (thisptr->description.fStrikethrough) | 
|---|
| 1314 | bAttributes |= FONTPERSIST_STRIKETHROUGH; | 
|---|
| 1315 |  | 
|---|
| 1316 | if (thisptr->description.fUnderline) | 
|---|
| 1317 | bAttributes |= FONTPERSIST_UNDERLINE; | 
|---|
| 1318 |  | 
|---|
| 1319 | IStream_Write(pOutStream, &bAttributes, 1, &cbWritten); | 
|---|
| 1320 |  | 
|---|
| 1321 | if (cbWritten!=1) | 
|---|
| 1322 | return E_FAIL; | 
|---|
| 1323 |  | 
|---|
| 1324 | /* | 
|---|
| 1325 | * Weight | 
|---|
| 1326 | */ | 
|---|
| 1327 | IStream_Write(pOutStream, &thisptr->description.sWeight, 2, &cbWritten); | 
|---|
| 1328 |  | 
|---|
| 1329 | if (cbWritten!=2) | 
|---|
| 1330 | return E_FAIL; | 
|---|
| 1331 |  | 
|---|
| 1332 | /* | 
|---|
| 1333 | * Size | 
|---|
| 1334 | */ | 
|---|
| 1335 | IStream_Write(pOutStream, &thisptr->description.cySize.u.Lo, 4, &cbWritten); | 
|---|
| 1336 |  | 
|---|
| 1337 | if (cbWritten!=4) | 
|---|
| 1338 | return E_FAIL; | 
|---|
| 1339 |  | 
|---|
| 1340 | /* | 
|---|
| 1341 | * FontName | 
|---|
| 1342 | */ | 
|---|
| 1343 | if (thisptr->description.lpstrName!=0) | 
|---|
| 1344 | bStringSize = lstrlenW(thisptr->description.lpstrName); | 
|---|
| 1345 | else | 
|---|
| 1346 | bStringSize = 0; | 
|---|
| 1347 |  | 
|---|
| 1348 | IStream_Write(pOutStream, &bStringSize, 1, &cbWritten); | 
|---|
| 1349 |  | 
|---|
| 1350 | if (cbWritten!=1) | 
|---|
| 1351 | return E_FAIL; | 
|---|
| 1352 |  | 
|---|
| 1353 | if (bStringSize!=0) | 
|---|
| 1354 | { | 
|---|
| 1355 | writeBuffer = HEAP_strdupWtoA(GetProcessHeap(), | 
|---|
| 1356 | HEAP_ZERO_MEMORY, | 
|---|
| 1357 | thisptr->description.lpstrName); | 
|---|
| 1358 |  | 
|---|
| 1359 | if (writeBuffer==0) | 
|---|
| 1360 | return E_OUTOFMEMORY; | 
|---|
| 1361 |  | 
|---|
| 1362 | IStream_Write(pOutStream, writeBuffer, bStringSize, &cbWritten); | 
|---|
| 1363 |  | 
|---|
| 1364 | HeapFree(GetProcessHeap(), 0, writeBuffer); | 
|---|
| 1365 |  | 
|---|
| 1366 | if (cbWritten!=bStringSize) | 
|---|
| 1367 | return E_FAIL; | 
|---|
| 1368 | } | 
|---|
| 1369 |  | 
|---|
| 1370 | return S_OK; | 
|---|
| 1371 | } | 
|---|
| 1372 |  | 
|---|
| 1373 | /************************************************************************ | 
|---|
| 1374 | * OLEFontImpl_GetSizeMax (IPersistStream) | 
|---|
| 1375 | * | 
|---|
| 1376 | * See Windows documentation for more details on IPersistStream methods. | 
|---|
| 1377 | */ | 
|---|
| 1378 | static HRESULT WINAPI OLEFontImpl_GetSizeMax( | 
|---|
| 1379 | IPersistStream*  iface, | 
|---|
| 1380 | ULARGE_INTEGER*  pcbSize) | 
|---|
| 1381 | { | 
|---|
| 1382 | _ICOM_THIS_From_IPersistStream(OLEFontImpl, iface); | 
|---|
| 1383 |  | 
|---|
| 1384 | if (pcbSize==NULL) | 
|---|
| 1385 | return E_POINTER; | 
|---|
| 1386 |  | 
|---|
| 1387 | pcbSize->HighPart = 0; | 
|---|
| 1388 | pcbSize->LowPart = 0; | 
|---|
| 1389 |  | 
|---|
| 1390 | pcbSize->LowPart += sizeof(BYTE);  /* Version */ | 
|---|
| 1391 | pcbSize->LowPart += sizeof(WORD);  /* Lang code */ | 
|---|
| 1392 | pcbSize->LowPart += sizeof(BYTE);  /* Flags */ | 
|---|
| 1393 | pcbSize->LowPart += sizeof(WORD);  /* Weight */ | 
|---|
| 1394 | pcbSize->LowPart += sizeof(DWORD); /* Size */ | 
|---|
| 1395 | pcbSize->LowPart += sizeof(BYTE);  /* StrLength */ | 
|---|
| 1396 |  | 
|---|
| 1397 | if (thisptr->description.lpstrName!=0) | 
|---|
| 1398 | pcbSize->LowPart += lstrlenW(thisptr->description.lpstrName); | 
|---|
| 1399 |  | 
|---|
| 1400 | return S_OK; | 
|---|
| 1401 | } | 
|---|