Changeset 9400 for trunk/src/oleaut32/olefont.c
- Timestamp:
- Nov 12, 2002, 6:07:48 PM (23 years ago)
- File:
-
- 1 edited
-
trunk/src/oleaut32/olefont.c (modified) (58 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/oleaut32/olefont.c
r8450 r9400 25 25 #include "oleaut32.h" 26 26 #endif 27 28 27 #include <assert.h> 29 28 #include <string.h> … … 59 58 { 60 59 /* 61 * This class supports many interfaces. IUnknown, IFont, 60 * This class supports many interfaces. IUnknown, IFont, 62 61 * IDispatch, IDispFont IPersistStream and IConnectionPointContainer. 63 62 * The first two are supported by the first vtable, the next two are … … 98 97 99 98 /* 100 * Here, I define utility macros to help with the casting of the 99 * Here, I define utility macros to help with the casting of the 101 100 * "this" parameter. 102 101 * There is a version to accomodate all of the VTables implemented … … 104 103 */ 105 104 #define _ICOM_THIS(class,name) class* this = (class*)name; 106 #define _ICOM_THIS_From_IDispatch(class, name) class* this = (class*)(((char*)name)-sizeof(void*)); 107 #define _ICOM_THIS_From_IPersistStream(class, name) class* this = (class*)(((char*)name)-2*sizeof(void*)); 108 #define _ICOM_THIS_From_IConnectionPointContainer(class, name) class* this = (class*)(((char*)name)-3*sizeof(void*)); 105 #define _ICOM_THIS_From_IDispatch(class, name) class* this = (class*)(((char*)name)-sizeof(void*)); 106 #define _ICOM_THIS_From_IPersistStream(class, name) class* this = (class*)(((char*)name)-2*sizeof(void*)); 107 #define _ICOM_THIS_From_IConnectionPointContainer(class, name) class* this = (class*)(((char*)name)-3*sizeof(void*)); 109 108 110 109 … … 147 146 * interface 148 147 */ 149 static HRESULT WINAPI OLEFontImpl_IDispatch_QueryInterface(IDispatch* iface, 150 REFIID riid, 148 static HRESULT WINAPI OLEFontImpl_IDispatch_QueryInterface(IDispatch* iface, 149 REFIID riid, 151 150 VOID** ppvoid); 152 151 static ULONG WINAPI OLEFontImpl_IDispatch_AddRef(IDispatch* iface); 153 152 static ULONG WINAPI OLEFontImpl_IDispatch_Release(IDispatch* iface); 154 static HRESULT WINAPI OLEFontImpl_GetTypeInfoCount(IDispatch* iface, 153 static HRESULT WINAPI OLEFontImpl_GetTypeInfoCount(IDispatch* iface, 155 154 unsigned int* pctinfo); 156 static HRESULT WINAPI OLEFontImpl_GetTypeInfo(IDispatch* iface, 155 static HRESULT WINAPI OLEFontImpl_GetTypeInfo(IDispatch* iface, 157 156 UINT iTInfo, 158 LCID lcid, 157 LCID lcid, 159 158 ITypeInfo** ppTInfo); 160 159 static HRESULT WINAPI OLEFontImpl_GetIDsOfNames(IDispatch* iface, 161 REFIID riid, 162 LPOLESTR* rgszNames, 163 UINT cNames, 160 REFIID riid, 161 LPOLESTR* rgszNames, 162 UINT cNames, 164 163 LCID lcid, 165 164 DISPID* rgDispId); 166 165 static HRESULT WINAPI OLEFontImpl_Invoke(IDispatch* iface, 167 DISPID dispIdMember, 168 REFIID riid, 169 LCID lcid, 166 DISPID dispIdMember, 167 REFIID riid, 168 LCID lcid, 170 169 WORD wFlags, 171 170 DISPPARAMS* pDispParams, 172 VARIANT* pVarResult, 171 VARIANT* pVarResult, 173 172 EXCEPINFO* pExepInfo, 174 UINT* puArgErr); 173 UINT* puArgErr); 175 174 176 175 /*********************************************************************** … … 178 177 * interface 179 178 */ 180 static HRESULT WINAPI OLEFontImpl_IPersistStream_QueryInterface(IPersistStream* iface, 181 REFIID riid, 179 static HRESULT WINAPI OLEFontImpl_IPersistStream_QueryInterface(IPersistStream* iface, 180 REFIID riid, 182 181 VOID** ppvoid); 183 182 static ULONG WINAPI OLEFontImpl_IPersistStream_AddRef(IPersistStream* iface); 184 183 static ULONG WINAPI OLEFontImpl_IPersistStream_Release(IPersistStream* iface); 185 static HRESULT WINAPI OLEFontImpl_GetClassID(IPersistStream* iface, 184 static HRESULT WINAPI OLEFontImpl_GetClassID(IPersistStream* iface, 186 185 CLSID* pClassID); 187 186 static HRESULT WINAPI OLEFontImpl_IsDirty(IPersistStream* iface); … … 190 189 static HRESULT WINAPI OLEFontImpl_Save(IPersistStream* iface, 191 190 IStream* pOutStream, 192 BOOL fClearDirty); 191 BOOL fClearDirty); 193 192 static HRESULT WINAPI OLEFontImpl_GetSizeMax(IPersistStream* iface, 194 ULARGE_INTEGER* pcbSize); 193 ULARGE_INTEGER* pcbSize); 195 194 196 195 /*********************************************************************** … … 199 198 */ 200 199 static HRESULT WINAPI OLEFontImpl_IConnectionPointContainer_QueryInterface( 201 IConnectionPointContainer* iface, 202 REFIID riid, 200 IConnectionPointContainer* iface, 201 REFIID riid, 203 202 VOID** ppvoid); 204 203 static ULONG WINAPI OLEFontImpl_IConnectionPointContainer_AddRef( … … 240 239 OLEFontImpl_put_Charset, 241 240 OLEFontImpl_get_hFont, 242 OLEFontImpl_Clone, 241 OLEFontImpl_Clone, 243 242 OLEFontImpl_IsEqual, 244 243 OLEFontImpl_SetRatio, … … 347 346 348 347 IConnectionPoint_EnumConnections(this->pCP, &pEnum); 349 348 350 349 while(IEnumConnections_Next(pEnum, 1, &CD, NULL) == S_OK) { 351 350 IPropertyNotifySink *sink; … … 359 358 return; 360 359 } 361 360 362 361 /************************************************************************ 363 362 * OLEFontImpl_Construct … … 380 379 if (newObject==0) 381 380 return newObject; 382 381 383 382 /* 384 383 * Initialize the virtual function table. … … 388 387 newObject->lpvtbl3 = &OLEFontImpl_IPersistStream_VTable; 389 388 newObject->lpvtbl4 = &OLEFontImpl_IConnectionPointContainer_VTable; 390 391 /* 392 * Start with one reference count. The caller of this function 389 390 /* 391 * Start with one reference count. The caller of this function 393 392 * must release the interface pointer when it is done. 394 393 */ … … 402 401 newObject->description.cbSizeofstruct = sizeof(FONTDESC); 403 402 newObject->description.lpstrName = HeapAlloc(GetProcessHeap(), 404 0, 403 0, 405 404 (lstrlenW(fontDesc->lpstrName)+1) * sizeof(WCHAR)); 406 405 strcpyW(newObject->description.lpstrName, fontDesc->lpstrName); … … 464 463 if ( (this==0) || (ppvObject==0) ) 465 464 return E_INVALIDARG; 466 465 467 466 /* 468 467 * Initialize the return parameter. 469 468 */ 470 469 *ppvObject = 0; 471 470 472 471 /* 473 472 * Compare the riid with the interface IDs implemented by this object. 474 473 */ 475 if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0) 474 if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0) 476 475 { 477 476 *ppvObject = (IFont*)this; 478 477 } 479 else if (memcmp(&IID_IFont, riid, sizeof(IID_IFont)) == 0) 478 else if (memcmp(&IID_IFont, riid, sizeof(IID_IFont)) == 0) 480 479 { 481 480 *ppvObject = (IFont*)this; 482 481 } 483 else if (memcmp(&IID_IDispatch, riid, sizeof(IID_IDispatch)) == 0) 482 else if (memcmp(&IID_IDispatch, riid, sizeof(IID_IDispatch)) == 0) 484 483 { 485 484 *ppvObject = (IDispatch*)&(this->lpvtbl2); 486 485 } 487 else if (memcmp(&IID_IFontDisp, riid, sizeof(IID_IFontDisp)) == 0) 486 else if (memcmp(&IID_IFontDisp, riid, sizeof(IID_IFontDisp)) == 0) 488 487 { 489 488 *ppvObject = (IDispatch*)&(this->lpvtbl2); 490 489 } 491 else if (memcmp(&IID_IPersistStream, riid, sizeof(IID_IPersistStream)) == 0) 490 else if (memcmp(&IID_IPersistStream, riid, sizeof(IID_IPersistStream)) == 0) 492 491 { 493 492 *ppvObject = (IPersistStream*)&(this->lpvtbl3); 494 493 } 495 494 else if (memcmp(&IID_IConnectionPointContainer, riid, 496 sizeof(IID_IConnectionPointContainer)) == 0) 495 sizeof(IID_IConnectionPointContainer)) == 0) 497 496 { 498 497 *ppvObject = (IPersistStream*)&(this->lpvtbl4); 499 498 } 500 499 501 500 /* 502 501 * Check that we obtained an interface. … … 507 506 return E_NOINTERFACE; 508 507 } 509 508 510 509 /* 511 510 * Query Interface always increases the reference count by one when it is … … 514 513 OLEFontImpl_AddRef((IFont*)this); 515 514 516 return S_OK; ;517 } 518 515 return S_OK; 516 } 517 519 518 /************************************************************************ 520 519 * OLEFontImpl_AddRef (IUnknown) … … 522 521 * See Windows documentation for more details on IUnknown methods. 523 522 */ 524 ULONG WINAPI OLEFontImpl_AddRef( 523 ULONG WINAPI OLEFontImpl_AddRef( 525 524 IFont* iface) 526 525 { … … 531 530 return this->ref; 532 531 } 533 532 534 533 /************************************************************************ 535 534 * OLEFontImpl_Release (IUnknown) … … 537 536 * See Windows documentation for more details on IUnknown methods. 538 537 */ 539 ULONG WINAPI OLEFontImpl_Release( 538 ULONG WINAPI OLEFontImpl_Release( 540 539 IFont* iface) 541 540 { … … 557 556 return 0; 558 557 } 559 558 560 559 return this->ref; 561 560 } 562 561 563 562 /************************************************************************ 564 563 * OLEFontImpl_get_Name (IFont) … … 567 566 */ 568 567 static HRESULT WINAPI OLEFontImpl_get_Name( 569 IFont* iface, 568 IFont* iface, 570 569 BSTR* pname) 571 570 { … … 592 591 */ 593 592 static HRESULT WINAPI OLEFontImpl_put_Name( 594 IFont* iface, 593 IFont* iface, 595 594 BSTR name) 596 595 { … … 601 600 { 602 601 this->description.lpstrName = HeapAlloc(GetProcessHeap(), 603 0, 602 0, 604 603 (lstrlenW(name)+1) * sizeof(WCHAR)); 605 604 } … … 607 606 { 608 607 this->description.lpstrName = HeapReAlloc(GetProcessHeap(), 609 0, 608 0, 610 609 this->description.lpstrName, 611 610 (lstrlenW(name)+1) * sizeof(WCHAR)); … … 627 626 */ 628 627 static HRESULT WINAPI OLEFontImpl_get_Size( 629 IFont* iface, 628 IFont* iface, 630 629 CY* psize) 631 630 { … … 651 650 */ 652 651 static HRESULT WINAPI OLEFontImpl_put_Size( 653 IFont* iface, 652 IFont* iface, 654 653 CY size) 655 654 { … … 669 668 */ 670 669 static HRESULT WINAPI OLEFontImpl_get_Bold( 671 IFont* iface, 670 IFont* iface, 672 671 BOOL* pbold) 673 672 { … … 708 707 */ 709 708 static HRESULT WINAPI OLEFontImpl_get_Italic( 710 IFont* iface, 709 IFont* iface, 711 710 BOOL* pitalic) 712 711 { … … 730 729 */ 731 730 static HRESULT WINAPI OLEFontImpl_put_Italic( 732 IFont* iface, 731 IFont* iface, 733 732 BOOL italic) 734 733 { … … 748 747 */ 749 748 static HRESULT WINAPI OLEFontImpl_get_Underline( 750 IFont* iface, 749 IFont* iface, 751 750 BOOL* punderline) 752 751 { … … 789 788 */ 790 789 static HRESULT WINAPI OLEFontImpl_get_Strikethrough( 791 IFont* iface, 790 IFont* iface, 792 791 BOOL* pstrikethrough) 793 792 { … … 812 811 */ 813 812 static HRESULT WINAPI OLEFontImpl_put_Strikethrough( 814 IFont* iface, 813 IFont* iface, 815 814 BOOL strikethrough) 816 815 { … … 830 829 */ 831 830 static HRESULT WINAPI OLEFontImpl_get_Weight( 832 IFont* iface, 831 IFont* iface, 833 832 short* pweight) 834 833 { … … 853 852 */ 854 853 static HRESULT WINAPI OLEFontImpl_put_Weight( 855 IFont* iface, 854 IFont* iface, 856 855 short weight) 857 856 { … … 871 870 */ 872 871 static HRESULT WINAPI OLEFontImpl_get_Charset( 873 IFont* iface, 872 IFont* iface, 874 873 short* pcharset) 875 874 { … … 894 893 */ 895 894 static HRESULT WINAPI OLEFontImpl_put_Charset( 896 IFont* iface, 895 IFont* iface, 897 896 short charset) 898 897 { … … 928 927 INT fontHeight; 929 928 CY cySize; 930 929 931 930 /* 932 931 * The height of the font returned by the get_Size property is the … … 959 958 960 959 *phfont = this->gdiFont; 961 TRACE("Returning % 08x\n", *phfont);960 TRACE("Returning %p\n", *phfont); 962 961 return S_OK; 963 962 } … … 1001 1000 (1+strlenW(this->description.lpstrName))*2 1002 1001 ); 1002 strcpyW(newObject->description.lpstrName, this->description.lpstrName); 1003 1003 /* We need to clone the HFONT too. This is just cut & paste from above */ 1004 1004 IFont_get_Size(iface, &cySize); … … 1039 1039 */ 1040 1040 static HRESULT WINAPI OLEFontImpl_IsEqual( 1041 IFont* iface, 1041 IFont* iface, 1042 1042 IFont* pFontOther) 1043 1043 { … … 1071 1071 */ 1072 1072 static HRESULT WINAPI OLEFontImpl_QueryTextMetrics( 1073 IFont* iface, 1073 IFont* iface, 1074 1074 TEXTMETRICOLE* ptm) 1075 1075 { … … 1084 1084 */ 1085 1085 static HRESULT WINAPI OLEFontImpl_AddRefHfont( 1086 IFont* iface, 1086 IFont* iface, 1087 1087 HFONT hfont) 1088 1088 { 1089 1089 _ICOM_THIS(OLEFontImpl, iface); 1090 TRACE("(%p)->(% 08x) (lock=%ld)\n", this, hfont, this->fontLock);1090 TRACE("(%p)->(%p) (lock=%ld)\n", this, hfont, this->fontLock); 1091 1091 1092 1092 if ( (hfont == 0) || … … 1109 1109 { 1110 1110 _ICOM_THIS(OLEFontImpl, iface); 1111 TRACE("(%p)->(% 08x) (lock=%ld)\n", this, hfont, this->fontLock);1111 TRACE("(%p)->(%p) (lock=%ld)\n", this, hfont, this->fontLock); 1112 1112 1113 1113 if ( (hfont == 0) || … … 1123 1123 { 1124 1124 DeleteObject(this->gdiFont); 1125 this->gdiFont = 0; 1125 this->gdiFont = 0; 1126 1126 } 1127 1127 … … 1139 1139 { 1140 1140 _ICOM_THIS(OLEFontImpl, iface); 1141 FIXME("(%p)->(% 08x): Stub\n", this, hdc);1141 FIXME("(%p)->(%p): Stub\n", this, hdc); 1142 1142 return E_NOTIMPL; 1143 1143 } … … 1190 1190 */ 1191 1191 static HRESULT WINAPI OLEFontImpl_GetTypeInfoCount( 1192 IDispatch* iface, 1192 IDispatch* iface, 1193 1193 unsigned int* pctinfo) 1194 1194 { … … 1205 1205 */ 1206 1206 static HRESULT WINAPI OLEFontImpl_GetTypeInfo( 1207 IDispatch* iface, 1207 IDispatch* iface, 1208 1208 UINT iTInfo, 1209 LCID lcid, 1209 LCID lcid, 1210 1210 ITypeInfo** ppTInfo) 1211 1211 { … … 1223 1223 static HRESULT WINAPI OLEFontImpl_GetIDsOfNames( 1224 1224 IDispatch* iface, 1225 REFIID riid, 1226 LPOLESTR* rgszNames, 1227 UINT cNames, 1225 REFIID riid, 1226 LPOLESTR* rgszNames, 1227 UINT cNames, 1228 1228 LCID lcid, 1229 1229 DISPID* rgDispId) … … 1242 1242 static HRESULT WINAPI OLEFontImpl_Invoke( 1243 1243 IDispatch* iface, 1244 DISPID dispIdMember, 1245 REFIID riid, 1246 LCID lcid, 1244 DISPID dispIdMember, 1245 REFIID riid, 1246 LCID lcid, 1247 1247 WORD wFlags, 1248 1248 DISPPARAMS* pDispParams, 1249 VARIANT* pVarResult, 1249 VARIANT* pVarResult, 1250 1250 EXCEPINFO* pExepInfo, 1251 1251 UINT* puArgErr) … … 1305 1305 */ 1306 1306 static HRESULT WINAPI OLEFontImpl_GetClassID( 1307 IPersistStream* iface, 1307 IPersistStream* iface, 1308 1308 CLSID* pClassID) 1309 1309 { … … 1360 1360 1361 1361 _ICOM_THIS_From_IPersistStream(OLEFontImpl, iface); 1362 1362 1363 1363 /* 1364 1364 * Read the version byte … … 1389 1389 this->description.fStrikethrough = (bAttributes & FONTPERSIST_STRIKETHROUGH) != 0; 1390 1390 this->description.fUnderline = (bAttributes & FONTPERSIST_UNDERLINE) != 0; 1391 1391 1392 1392 /* 1393 1393 * Weight … … 1428 1428 MultiByteToWideChar( CP_ACP, 0, readBuffer, bStringSize, this->description.lpstrName, len ); 1429 1429 this->description.lpstrName[len] = 0; 1430 1431 /* Ensure use of this font causes a new one to be created @@@@ */ 1432 DeleteObject(this->gdiFont); 1433 this->gdiFont = 0; 1430 1434 1431 1435 return S_OK; … … 1447 1451 BYTE bAttributes; 1448 1452 BYTE bStringSize; 1449 1453 1450 1454 _ICOM_THIS_From_IPersistStream(OLEFontImpl, iface); 1451 1455 … … 1476 1480 if (this->description.fStrikethrough) 1477 1481 bAttributes |= FONTPERSIST_STRIKETHROUGH; 1478 1482 1479 1483 if (this->description.fUnderline) 1480 1484 bAttributes |= FONTPERSIST_UNDERLINE; … … 1484 1488 if (cbWritten!=1) 1485 1489 return E_FAIL; 1486 1490 1487 1491 /* 1488 1492 * Weight … … 1652 1656 } IClassFactoryImpl; 1653 1657 1654 static HRESULT WINAPI 1658 static HRESULT WINAPI 1655 1659 SFCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) { 1656 1660 ICOM_THIS(IClassFactoryImpl,iface);
Note:
See TracChangeset
for help on using the changeset viewer.
