Ignore:
Timestamp:
Nov 12, 2002, 6:07:48 PM (23 years ago)
Author:
sandervl
Message:

Wine resync

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/oleaut32/olefont.c

    r8450 r9400  
    2525#include "oleaut32.h"
    2626#endif
    27 
    2827#include <assert.h>
    2928#include <string.h>
     
    5958{
    6059  /*
    61    * This class supports many interfaces. IUnknown, IFont, 
     60   * This class supports many interfaces. IUnknown, IFont,
    6261   * IDispatch, IDispFont IPersistStream and IConnectionPointContainer.
    6362   * The first two are supported by the first vtable, the next two are
     
    9897
    9998/*
    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
    101100 * "this" parameter.
    102101 * There is a version to accomodate all of the VTables implemented
     
    104103 */
    105104#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*));
    109108
    110109
     
    147146 * interface
    148147 */
    149 static HRESULT WINAPI OLEFontImpl_IDispatch_QueryInterface(IDispatch* iface, 
    150                                                     REFIID     riid, 
     148static HRESULT WINAPI OLEFontImpl_IDispatch_QueryInterface(IDispatch* iface,
     149                                                    REFIID     riid,
    151150                                                    VOID**     ppvoid);
    152151static ULONG   WINAPI OLEFontImpl_IDispatch_AddRef(IDispatch* iface);
    153152static ULONG   WINAPI OLEFontImpl_IDispatch_Release(IDispatch* iface);
    154 static HRESULT WINAPI OLEFontImpl_GetTypeInfoCount(IDispatch*    iface, 
     153static HRESULT WINAPI OLEFontImpl_GetTypeInfoCount(IDispatch*    iface,
    155154                                                   unsigned int* pctinfo);
    156 static HRESULT WINAPI OLEFontImpl_GetTypeInfo(IDispatch*  iface, 
     155static HRESULT WINAPI OLEFontImpl_GetTypeInfo(IDispatch*  iface,
    157156                                              UINT      iTInfo,
    158                                               LCID        lcid, 
     157                                              LCID        lcid,
    159158                                              ITypeInfo** ppTInfo);
    160159static HRESULT WINAPI OLEFontImpl_GetIDsOfNames(IDispatch*  iface,
    161                                                 REFIID      riid, 
    162                                                 LPOLESTR* rgszNames, 
    163                                                 UINT      cNames, 
     160                                                REFIID      riid,
     161                                                LPOLESTR* rgszNames,
     162                                                UINT      cNames,
    164163                                                LCID        lcid,
    165164                                                DISPID*     rgDispId);
    166165static HRESULT WINAPI OLEFontImpl_Invoke(IDispatch*  iface,
    167                                          DISPID      dispIdMember, 
    168                                          REFIID      riid, 
    169                                          LCID        lcid, 
     166                                         DISPID      dispIdMember,
     167                                         REFIID      riid,
     168                                         LCID        lcid,
    170169                                         WORD        wFlags,
    171170                                         DISPPARAMS* pDispParams,
    172                                          VARIANT*    pVarResult, 
     171                                         VARIANT*    pVarResult,
    173172                                         EXCEPINFO*  pExepInfo,
    174                                          UINT*     puArgErr); 
     173                                         UINT*     puArgErr);
    175174
    176175/***********************************************************************
     
    178177 * interface
    179178 */
    180 static HRESULT WINAPI OLEFontImpl_IPersistStream_QueryInterface(IPersistStream* iface, 
    181                                                     REFIID     riid, 
     179static HRESULT WINAPI OLEFontImpl_IPersistStream_QueryInterface(IPersistStream* iface,
     180                                                    REFIID     riid,
    182181                                                    VOID**     ppvoid);
    183182static ULONG   WINAPI OLEFontImpl_IPersistStream_AddRef(IPersistStream* iface);
    184183static ULONG   WINAPI OLEFontImpl_IPersistStream_Release(IPersistStream* iface);
    185 static HRESULT WINAPI OLEFontImpl_GetClassID(IPersistStream* iface, 
     184static HRESULT WINAPI OLEFontImpl_GetClassID(IPersistStream* iface,
    186185                                             CLSID*                pClassID);
    187186static HRESULT WINAPI OLEFontImpl_IsDirty(IPersistStream*  iface);
     
    190189static HRESULT WINAPI OLEFontImpl_Save(IPersistStream*  iface,
    191190                                       IStream*         pOutStream,
    192                                        BOOL             fClearDirty); 
     191                                       BOOL             fClearDirty);
    193192static HRESULT WINAPI OLEFontImpl_GetSizeMax(IPersistStream*  iface,
    194                                              ULARGE_INTEGER*  pcbSize); 
     193                                             ULARGE_INTEGER*  pcbSize);
    195194
    196195/***********************************************************************
     
    199198 */
    200199static HRESULT WINAPI OLEFontImpl_IConnectionPointContainer_QueryInterface(
    201                                             IConnectionPointContainer* iface, 
    202                                             REFIID     riid, 
     200                                            IConnectionPointContainer* iface,
     201                                            REFIID     riid,
    203202                                            VOID**     ppvoid);
    204203static ULONG   WINAPI OLEFontImpl_IConnectionPointContainer_AddRef(
     
    240239  OLEFontImpl_put_Charset,
    241240  OLEFontImpl_get_hFont,
    242   OLEFontImpl_Clone, 
     241  OLEFontImpl_Clone,
    243242  OLEFontImpl_IsEqual,
    244243  OLEFontImpl_SetRatio,
     
    347346
    348347  IConnectionPoint_EnumConnections(this->pCP, &pEnum);
    349  
     348
    350349  while(IEnumConnections_Next(pEnum, 1, &CD, NULL) == S_OK) {
    351350    IPropertyNotifySink *sink;
     
    359358  return;
    360359}
    361  
     360
    362361/************************************************************************
    363362 * OLEFontImpl_Construct
     
    380379  if (newObject==0)
    381380    return newObject;
    382  
     381
    383382  /*
    384383   * Initialize the virtual function table.
     
    388387  newObject->lpvtbl3 = &OLEFontImpl_IPersistStream_VTable;
    389388  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
    393392   * must release the interface pointer when it is done.
    394393   */
     
    402401  newObject->description.cbSizeofstruct = sizeof(FONTDESC);
    403402  newObject->description.lpstrName = HeapAlloc(GetProcessHeap(),
    404                                                0, 
     403                                               0,
    405404                                               (lstrlenW(fontDesc->lpstrName)+1) * sizeof(WCHAR));
    406405  strcpyW(newObject->description.lpstrName, fontDesc->lpstrName);
     
    464463  if ( (this==0) || (ppvObject==0) )
    465464    return E_INVALIDARG;
    466  
     465
    467466  /*
    468467   * Initialize the return parameter.
    469468   */
    470469  *ppvObject = 0;
    471  
     470
    472471  /*
    473472   * Compare the riid with the interface IDs implemented by this object.
    474473   */
    475   if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0) 
     474  if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0)
    476475  {
    477476    *ppvObject = (IFont*)this;
    478477  }
    479   else if (memcmp(&IID_IFont, riid, sizeof(IID_IFont)) == 0) 
     478  else if (memcmp(&IID_IFont, riid, sizeof(IID_IFont)) == 0)
    480479  {
    481480    *ppvObject = (IFont*)this;
    482481  }
    483   else if (memcmp(&IID_IDispatch, riid, sizeof(IID_IDispatch)) == 0) 
     482  else if (memcmp(&IID_IDispatch, riid, sizeof(IID_IDispatch)) == 0)
    484483  {
    485484    *ppvObject = (IDispatch*)&(this->lpvtbl2);
    486485  }
    487   else if (memcmp(&IID_IFontDisp, riid, sizeof(IID_IFontDisp)) == 0) 
     486  else if (memcmp(&IID_IFontDisp, riid, sizeof(IID_IFontDisp)) == 0)
    488487  {
    489488    *ppvObject = (IDispatch*)&(this->lpvtbl2);
    490489  }
    491   else if (memcmp(&IID_IPersistStream, riid, sizeof(IID_IPersistStream)) == 0) 
     490  else if (memcmp(&IID_IPersistStream, riid, sizeof(IID_IPersistStream)) == 0)
    492491  {
    493492    *ppvObject = (IPersistStream*)&(this->lpvtbl3);
    494493  }
    495494  else if (memcmp(&IID_IConnectionPointContainer, riid,
    496                   sizeof(IID_IConnectionPointContainer)) == 0) 
     495                  sizeof(IID_IConnectionPointContainer)) == 0)
    497496  {
    498497    *ppvObject = (IPersistStream*)&(this->lpvtbl4);
    499498  }
    500  
     499
    501500  /*
    502501   * Check that we obtained an interface.
     
    507506    return E_NOINTERFACE;
    508507  }
    509  
     508
    510509  /*
    511510   * Query Interface always increases the reference count by one when it is
     
    514513  OLEFontImpl_AddRef((IFont*)this);
    515514
    516   return S_OK;;
    517 }
    518        
     515  return S_OK;
     516}
     517
    519518/************************************************************************
    520519 * OLEFontImpl_AddRef (IUnknown)
     
    522521 * See Windows documentation for more details on IUnknown methods.
    523522 */
    524 ULONG WINAPI OLEFontImpl_AddRef( 
     523ULONG WINAPI OLEFontImpl_AddRef(
    525524  IFont* iface)
    526525{
     
    531530  return this->ref;
    532531}
    533        
     532
    534533/************************************************************************
    535534 * OLEFontImpl_Release (IUnknown)
     
    537536 * See Windows documentation for more details on IUnknown methods.
    538537 */
    539 ULONG WINAPI OLEFontImpl_Release( 
     538ULONG WINAPI OLEFontImpl_Release(
    540539      IFont* iface)
    541540{
     
    557556    return 0;
    558557  }
    559  
     558
    560559  return this->ref;
    561560}
    562        
     561
    563562/************************************************************************
    564563 * OLEFontImpl_get_Name (IFont)
     
    567566 */
    568567static HRESULT WINAPI OLEFontImpl_get_Name(
    569   IFont*  iface, 
     568  IFont*  iface,
    570569  BSTR* pname)
    571570{
     
    592591 */
    593592static HRESULT WINAPI OLEFontImpl_put_Name(
    594   IFont* iface, 
     593  IFont* iface,
    595594  BSTR name)
    596595{
     
    601600  {
    602601    this->description.lpstrName = HeapAlloc(GetProcessHeap(),
    603                                             0, 
     602                                            0,
    604603                                            (lstrlenW(name)+1) * sizeof(WCHAR));
    605604  }
     
    607606  {
    608607    this->description.lpstrName = HeapReAlloc(GetProcessHeap(),
    609                                               0, 
     608                                              0,
    610609                                              this->description.lpstrName,
    611610                                              (lstrlenW(name)+1) * sizeof(WCHAR));
     
    627626 */
    628627static HRESULT WINAPI OLEFontImpl_get_Size(
    629   IFont* iface, 
     628  IFont* iface,
    630629  CY*    psize)
    631630{
     
    651650 */
    652651static HRESULT WINAPI OLEFontImpl_put_Size(
    653   IFont* iface, 
     652  IFont* iface,
    654653  CY     size)
    655654{
     
    669668 */
    670669static HRESULT WINAPI OLEFontImpl_get_Bold(
    671   IFont*  iface, 
     670  IFont*  iface,
    672671  BOOL* pbold)
    673672{
     
    708707 */
    709708static HRESULT WINAPI OLEFontImpl_get_Italic(
    710   IFont*  iface, 
     709  IFont*  iface,
    711710  BOOL* pitalic)
    712711{
     
    730729 */
    731730static HRESULT WINAPI OLEFontImpl_put_Italic(
    732   IFont* iface, 
     731  IFont* iface,
    733732  BOOL italic)
    734733{
     
    748747 */
    749748static HRESULT WINAPI OLEFontImpl_get_Underline(
    750   IFont*  iface, 
     749  IFont*  iface,
    751750  BOOL* punderline)
    752751{
     
    789788 */
    790789static HRESULT WINAPI OLEFontImpl_get_Strikethrough(
    791   IFont*  iface, 
     790  IFont*  iface,
    792791  BOOL* pstrikethrough)
    793792{
     
    812811 */
    813812static HRESULT WINAPI OLEFontImpl_put_Strikethrough(
    814  IFont* iface, 
     813 IFont* iface,
    815814 BOOL strikethrough)
    816815{
     
    830829 */
    831830static HRESULT WINAPI OLEFontImpl_get_Weight(
    832   IFont* iface, 
     831  IFont* iface,
    833832  short* pweight)
    834833{
     
    853852 */
    854853static HRESULT WINAPI OLEFontImpl_put_Weight(
    855   IFont* iface, 
     854  IFont* iface,
    856855  short  weight)
    857856{
     
    871870 */
    872871static HRESULT WINAPI OLEFontImpl_get_Charset(
    873   IFont* iface, 
     872  IFont* iface,
    874873  short* pcharset)
    875874{
     
    894893 */
    895894static HRESULT WINAPI OLEFontImpl_put_Charset(
    896   IFont* iface, 
     895  IFont* iface,
    897896  short charset)
    898897{
     
    928927    INT      fontHeight;
    929928    CY       cySize;
    930    
     929
    931930    /*
    932931     * The height of the font returned by the get_Size property is the
     
    959958
    960959  *phfont = this->gdiFont;
    961   TRACE("Returning %08x\n", *phfont);
     960  TRACE("Returning %p\n", *phfont);
    962961  return S_OK;
    963962}
     
    10011000        (1+strlenW(this->description.lpstrName))*2
    10021001  );
     1002  strcpyW(newObject->description.lpstrName, this->description.lpstrName);
    10031003  /* We need to clone the HFONT too. This is just cut & paste from above */
    10041004  IFont_get_Size(iface, &cySize);
     
    10391039 */
    10401040static HRESULT WINAPI OLEFontImpl_IsEqual(
    1041   IFont* iface, 
     1041  IFont* iface,
    10421042  IFont* pFontOther)
    10431043{
     
    10711071 */
    10721072static HRESULT      WINAPI OLEFontImpl_QueryTextMetrics(
    1073   IFont*         iface, 
     1073  IFont*         iface,
    10741074  TEXTMETRICOLE* ptm)
    10751075{
     
    10841084 */
    10851085static HRESULT WINAPI OLEFontImpl_AddRefHfont(
    1086   IFont*  iface, 
     1086  IFont*  iface,
    10871087  HFONT hfont)
    10881088{
    10891089  _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);
    10911091
    10921092  if ( (hfont == 0) ||
     
    11091109{
    11101110  _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);
    11121112
    11131113  if ( (hfont == 0) ||
     
    11231123  {
    11241124    DeleteObject(this->gdiFont);
    1125     this->gdiFont = 0; 
     1125    this->gdiFont = 0;
    11261126  }
    11271127
     
    11391139{
    11401140  _ICOM_THIS(OLEFontImpl, iface);
    1141   FIXME("(%p)->(%08x): Stub\n", this, hdc);
     1141  FIXME("(%p)->(%p): Stub\n", this, hdc);
    11421142  return E_NOTIMPL;
    11431143}
     
    11901190 */
    11911191static HRESULT WINAPI OLEFontImpl_GetTypeInfoCount(
    1192   IDispatch*    iface, 
     1192  IDispatch*    iface,
    11931193  unsigned int* pctinfo)
    11941194{
     
    12051205 */
    12061206static HRESULT WINAPI OLEFontImpl_GetTypeInfo(
    1207   IDispatch*  iface, 
     1207  IDispatch*  iface,
    12081208  UINT      iTInfo,
    1209   LCID        lcid, 
     1209  LCID        lcid,
    12101210  ITypeInfo** ppTInfo)
    12111211{
     
    12231223static HRESULT WINAPI OLEFontImpl_GetIDsOfNames(
    12241224  IDispatch*  iface,
    1225   REFIID      riid, 
    1226   LPOLESTR* rgszNames, 
    1227   UINT      cNames, 
     1225  REFIID      riid,
     1226  LPOLESTR* rgszNames,
     1227  UINT      cNames,
    12281228  LCID        lcid,
    12291229  DISPID*     rgDispId)
     
    12421242static HRESULT WINAPI OLEFontImpl_Invoke(
    12431243  IDispatch*  iface,
    1244   DISPID      dispIdMember, 
    1245   REFIID      riid, 
    1246   LCID        lcid, 
     1244  DISPID      dispIdMember,
     1245  REFIID      riid,
     1246  LCID        lcid,
    12471247  WORD        wFlags,
    12481248  DISPPARAMS* pDispParams,
    1249   VARIANT*    pVarResult, 
     1249  VARIANT*    pVarResult,
    12501250  EXCEPINFO*  pExepInfo,
    12511251  UINT*     puArgErr)
     
    13051305 */
    13061306static HRESULT WINAPI OLEFontImpl_GetClassID(
    1307   IPersistStream* iface, 
     1307  IPersistStream* iface,
    13081308  CLSID*                pClassID)
    13091309{
     
    13601360
    13611361  _ICOM_THIS_From_IPersistStream(OLEFontImpl, iface);
    1362  
     1362
    13631363  /*
    13641364   * Read the version byte
     
    13891389  this->description.fStrikethrough = (bAttributes & FONTPERSIST_STRIKETHROUGH) != 0;
    13901390  this->description.fUnderline     = (bAttributes & FONTPERSIST_UNDERLINE) != 0;
    1391    
     1391
    13921392  /*
    13931393   * Weight
     
    14281428  MultiByteToWideChar( CP_ACP, 0, readBuffer, bStringSize, this->description.lpstrName, len );
    14291429  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;
    14301434
    14311435  return S_OK;
     
    14471451  BYTE  bAttributes;
    14481452  BYTE  bStringSize;
    1449  
     1453
    14501454  _ICOM_THIS_From_IPersistStream(OLEFontImpl, iface);
    14511455
     
    14761480  if (this->description.fStrikethrough)
    14771481    bAttributes |= FONTPERSIST_STRIKETHROUGH;
    1478  
     1482
    14791483  if (this->description.fUnderline)
    14801484    bAttributes |= FONTPERSIST_UNDERLINE;
     
    14841488  if (cbWritten!=1)
    14851489    return E_FAIL;
    1486  
     1490
    14871491  /*
    14881492   * Weight
     
    16521656} IClassFactoryImpl;
    16531657
    1654 static HRESULT WINAPI 
     1658static HRESULT WINAPI
    16551659SFCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
    16561660        ICOM_THIS(IClassFactoryImpl,iface);
Note: See TracChangeset for help on using the changeset viewer.