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