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