Ignore:
Timestamp:
Sep 15, 2001, 11:32:00 AM (24 years ago)
Author:
sandervl
Message:

restored old version + wine update

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/ole32/oleobj.c

    r6648 r6711  
    1 /* $Id: oleobj.c,v 1.2 2001-09-05 13:17:11 bird Exp $ */
    21/*
    3  *  OLE2 COM objects
     2 *      OLE2 COM objects
    43 *
    5  *  Copyright 1998 Eric Kohl
     4 *      Copyright 1998 Eric Kohl
    65 *      Copyright 1999 Francis Beaudet
    76 */
     
    1312#include "debugtools.h"
    1413#include "oleidl.h"
     14
     15#ifdef __WIN32OS2__
     16#undef FIXME
     17#undef TRACE
     18#ifdef DEBUG
     19#define TRACE WriteLog("OLE32: %s", __FUNCTION__); WriteLog
     20#define FIXME WriteLog("FIXME OLE32: %s", __FUNCTION__); WriteLog
     21#else
     22#define TRACE 1 ? (void)0 : (void)((int (*)(char *, ...)) NULL)
     23#define FIXME 1 ? (void)0 : (void)((int (*)(char *, ...)) NULL)
     24#endif
     25#endif
    1526
    1627DEFAULT_DEBUG_CHANNEL(ole);
     
    7283
    7384  lpoah= (OleAdviseHolderImpl*)HeapAlloc(GetProcessHeap(),
    74                     0,
    75                     sizeof(OleAdviseHolderImpl));
    76 
     85                                        0,
     86                                        sizeof(OleAdviseHolderImpl));
     87 
    7788  ICOM_VTBL(lpoah) = &oahvt;
    7889  lpoah->ref = 1;
    7990  lpoah->maxSinks = INITIAL_SINKS;
    8091  lpoah->arrayOfSinks = HeapAlloc(GetProcessHeap(),
    81                   0,
    82                   lpoah->maxSinks * sizeof(IAdviseSink*));
     92                                  0,
     93                                  lpoah->maxSinks * sizeof(IAdviseSink*));
    8394
    8495  for (index = 0; index < lpoah->maxSinks; index++)
     
    106117    }
    107118  }
    108 
     119 
    109120  HeapFree(GetProcessHeap(),
    110        0,
    111        ptrToDestroy->arrayOfSinks);
    112 
     121           0,
     122           ptrToDestroy->arrayOfSinks);
     123 
    113124
    114125  HeapFree(GetProcessHeap(),
    115        0,
    116        ptrToDestroy);
     126           0,
     127           ptrToDestroy);
    117128}
    118129
     
    122133static HRESULT WINAPI OleAdviseHolderImpl_QueryInterface(
    123134  LPOLEADVISEHOLDER iface,
    124   REFIID            riid,
     135  REFIID            riid, 
    125136  LPVOID*           ppvObj)
    126137{
    127   ICOM_THIS(OleAdviseHolderImpl, iface);
     138  ICOM_THIS(OleAdviseHolderImpl, iface); 
    128139  TRACE("(%p)->(%s,%p)\n",This,debugstr_guid(riid),ppvObj);
    129140  /*
     
    135146  *ppvObj = NULL;
    136147
    137   if (IsEqualIID(riid, &IID_IUnknown))
     148  if (IsEqualIID(riid, &IID_IUnknown)) 
    138149  {
    139150    /* IUnknown */
    140     *ppvObj = This;
    141   }
    142   else if(IsEqualIID(riid, &IID_IOleAdviseHolder))
     151    *ppvObj = This; 
     152  }
     153  else if(IsEqualIID(riid, &IID_IOleAdviseHolder)) 
    143154  {
    144155    /* IOleAdviseHolder */
     
    148159  if(*ppvObj == NULL)
    149160    return E_NOINTERFACE;
    150 
     161 
    151162  /*
    152163   * A successful QI always increments the reference count.
     
    163174  LPOLEADVISEHOLDER iface)
    164175{
    165   ICOM_THIS(OleAdviseHolderImpl, iface);
    166   TRACE("(%p)->(ref=%ld)\n", This, This->ref);
     176  ICOM_THIS(OleAdviseHolderImpl, iface); 
     177  TRACE("(%p)->(ref=%ld)\n", This, This->ref); 
    167178  return ++(This->ref);
    168179}
     
    174185  LPOLEADVISEHOLDER iface)
    175186{
    176   ICOM_THIS(OleAdviseHolderImpl, iface);
    177   TRACE("(%p)->(ref=%ld)\n", This, This->ref);
     187  ICOM_THIS(OleAdviseHolderImpl, iface); 
     188  TRACE("(%p)->(ref=%ld)\n", This, This->ref); 
    178189  This->ref--;
    179190
     
    197208{
    198209  DWORD index;
    199 
    200   ICOM_THIS(OleAdviseHolderImpl, iface);
     210 
     211  ICOM_THIS(OleAdviseHolderImpl, iface); 
    201212
    202213  TRACE("(%p)->(%p, %p)\n", This, pAdvise, pdwConnection);
     
    207218  if (pdwConnection==NULL)
    208219    return E_POINTER;
    209 
     220 
    210221  *pdwConnection = 0;
    211222
     
    228239    This->maxSinks+=INITIAL_SINKS;
    229240
    230     This->arrayOfSinks = HeapReAlloc(GetProcessHeap(),
    231                      0,
    232                      This->arrayOfSinks,
    233                      This->maxSinks*sizeof(IAdviseSink*));
     241    This->arrayOfSinks = HeapReAlloc(GetProcessHeap(), 
     242                                     0,
     243                                     This->arrayOfSinks,
     244                                     This->maxSinks*sizeof(IAdviseSink*));
    234245
    235246    for (i=index;i < This->maxSinks; i++)
    236       This->arrayOfSinks[i]=0;
     247      This->arrayOfSinks[i]=0;     
    237248  }
    238249
     
    259270 */
    260271static HRESULT WINAPI OleAdviseHolderImpl_Unadvise(
    261   LPOLEADVISEHOLDER iface,
     272  LPOLEADVISEHOLDER iface, 
    262273  DWORD             dwConnection)
    263274{
    264   ICOM_THIS(OleAdviseHolderImpl, iface);
     275  ICOM_THIS(OleAdviseHolderImpl, iface); 
    265276
    266277  TRACE("(%p)->(%lu)\n", This, dwConnection);
    267278
    268279  /*
    269    * So we don't return 0 as a cookie, the index was
     280   * So we don't return 0 as a cookie, the index was 
    270281   * incremented by 1 in OleAdviseHolderImpl_Advise
    271282   * we have to compensate.
    272283   */
    273284  dwConnection--;
    274 
     285 
    275286  /*
    276287   * Check for invalid cookies.
    277288   */
    278   if ( (dwConnection < 0) ||
     289  if ( (dwConnection < 0) || 
    279290       (dwConnection >= This->maxSinks) )
    280291    return OLE_E_NOCONNECTION;
     
    298309OleAdviseHolderImpl_EnumAdvise (LPOLEADVISEHOLDER iface, IEnumSTATDATA **ppenumAdvise)
    299310{
    300     ICOM_THIS(OleAdviseHolderImpl, iface);
     311    ICOM_THIS(OleAdviseHolderImpl, iface); 
    301312    FIXME("(%p)->(%p)\n", This, ppenumAdvise);
    302313
     
    312323OleAdviseHolderImpl_SendOnRename (LPOLEADVISEHOLDER iface, IMoniker *pmk)
    313324{
    314     ICOM_THIS(OleAdviseHolderImpl, iface);
     325    ICOM_THIS(OleAdviseHolderImpl, iface); 
    315326    FIXME("(%p)->(%p)\n", This, pmk);
    316327
     
    325336OleAdviseHolderImpl_SendOnSave (LPOLEADVISEHOLDER iface)
    326337{
    327     ICOM_THIS(OleAdviseHolderImpl, iface);
     338    ICOM_THIS(OleAdviseHolderImpl, iface); 
    328339    FIXME("(%p)\n", This);
    329340
     
    337348OleAdviseHolderImpl_SendOnClose (LPOLEADVISEHOLDER iface)
    338349{
    339     ICOM_THIS(OleAdviseHolderImpl, iface);
     350    ICOM_THIS(OleAdviseHolderImpl, iface); 
    340351    FIXME("(%p)\n", This);
    341352
     
    351362  FORMATETC fmat;
    352363  DWORD advf;
    353 } DataAdviseConnection;
     364} DataAdviseConnection; 
    354365
    355366typedef struct DataAdviseHolder
     
    368379static void               DataAdviseHolder_Destructor(DataAdviseHolder* ptrToDestroy);
    369380static HRESULT WINAPI     DataAdviseHolder_QueryInterface(
    370                 IDataAdviseHolder*      iface,
    371                 REFIID                  riid,
    372                 void**                  ppvObject);
    373 static ULONG WINAPI       DataAdviseHolder_AddRef(
     381                            IDataAdviseHolder*      iface,
     382                            REFIID                  riid,
     383                            void**                  ppvObject);
     384static ULONG WINAPI       DataAdviseHolder_AddRef( 
    374385                            IDataAdviseHolder*      iface);
    375 static ULONG WINAPI       DataAdviseHolder_Release(
     386static ULONG WINAPI       DataAdviseHolder_Release( 
    376387                            IDataAdviseHolder*      iface);
    377 static HRESULT WINAPI     DataAdviseHolder_Advise(
     388static HRESULT WINAPI     DataAdviseHolder_Advise( 
    378389                            IDataAdviseHolder*      iface,
    379                 IDataObject*            pDataObject,
    380                 FORMATETC*              pFetc,
    381                 DWORD                   advf,
    382                 IAdviseSink*            pAdvise,
    383                 DWORD*                  pdwConnection);
    384 static HRESULT WINAPI     DataAdviseHolder_Unadvise(
     390                            IDataObject*            pDataObject,
     391                            FORMATETC*              pFetc,
     392                            DWORD                   advf,
     393                            IAdviseSink*            pAdvise,
     394                            DWORD*                  pdwConnection);
     395static HRESULT WINAPI     DataAdviseHolder_Unadvise( 
    385396                            IDataAdviseHolder*      iface,
    386                 DWORD                   dwConnection);
    387 static HRESULT WINAPI     DataAdviseHolder_EnumAdvise(
    388                             IDataAdviseHolder*      iface,
    389                 IEnumSTATDATA**         ppenumAdvise);
    390 static HRESULT WINAPI     DataAdviseHolder_SendOnDataChange(
    391                             IDataAdviseHolder*      iface,
    392                 IDataObject*            pDataObject,
    393                 DWORD                   dwReserved,
    394                 DWORD                   advf);
     397                            DWORD                   dwConnection);
     398static HRESULT WINAPI     DataAdviseHolder_EnumAdvise( 
     399                            IDataAdviseHolder*      iface,       
     400                            IEnumSTATDATA**         ppenumAdvise);
     401static HRESULT WINAPI     DataAdviseHolder_SendOnDataChange( 
     402                            IDataAdviseHolder*      iface, 
     403                            IDataObject*            pDataObject,
     404                            DWORD                   dwReserved,
     405                            DWORD                   advf);
    395406
    396407/**************************************************************************
     
    417428
    418429  newHolder = (DataAdviseHolder*)HeapAlloc(GetProcessHeap(),
    419                        0,
    420                        sizeof(DataAdviseHolder));
    421 
     430                                           0,
     431                                           sizeof(DataAdviseHolder));
     432 
    422433  ICOM_VTBL(newHolder) = &DataAdviseHolderImpl_VTable;
    423434  newHolder->ref = 1;
    424435  newHolder->maxCons = INITIAL_SINKS;
    425436  newHolder->Connections = HeapAlloc(GetProcessHeap(),
    426                      HEAP_ZERO_MEMORY,
    427                      newHolder->maxCons *
    428                      sizeof(DataAdviseConnection));
     437                                     HEAP_ZERO_MEMORY,
     438                                     newHolder->maxCons *
     439                                     sizeof(DataAdviseConnection));
    429440
    430441  TRACE("returning %p\n", newHolder);
     
    448459    }
    449460  }
    450 
     461 
    451462  HeapFree(GetProcessHeap(), 0, ptrToDestroy->Connections);
    452463  HeapFree(GetProcessHeap(), 0, ptrToDestroy);
     
    463474  void**                  ppvObject)
    464475{
    465   ICOM_THIS(DataAdviseHolder, iface);
     476  ICOM_THIS(DataAdviseHolder, iface); 
    466477  TRACE("(%p)->(%s,%p)\n",This,debugstr_guid(riid),ppvObject);
    467478  /*
     
    470481  if ( (This==0) || (ppvObject==0) )
    471482    return E_INVALIDARG;
    472 
     483 
    473484  /*
    474485   * Initialize the return parameter.
     
    484495    *ppvObject = iface;
    485496  }
    486 
     497 
    487498  /*
    488499   * Check that we obtained an interface.
     
    492503    return E_NOINTERFACE;
    493504  }
    494 
     505 
    495506  /*
    496507   * Query Interface always increases the reference count by one when it is
    497    * successful.
     508   * successful. 
    498509   */
    499510  IUnknown_AddRef((IUnknown*)*ppvObject);
    500511
    501   return S_OK;;
     512  return S_OK;; 
    502513}
    503514
     
    507518 * See Windows documentation for more details on IUnknown methods.
    508519 */
    509 static ULONG WINAPI       DataAdviseHolder_AddRef(
     520static ULONG WINAPI       DataAdviseHolder_AddRef(                             
    510521  IDataAdviseHolder*      iface)
    511522{
    512   ICOM_THIS(DataAdviseHolder, iface);
     523  ICOM_THIS(DataAdviseHolder, iface); 
    513524  TRACE("(%p) (ref=%ld)\n", This, This->ref);
    514525  This->ref++;
     
    522533 * See Windows documentation for more details on IUnknown methods.
    523534 */
    524 static ULONG WINAPI DataAdviseHolder_Release(
     535static ULONG WINAPI DataAdviseHolder_Release( 
    525536  IDataAdviseHolder*      iface)
    526537{
     
    542553    return 0;
    543554  }
    544 
     555 
    545556  return This->ref;
    546557}
     
    552563static HRESULT WINAPI DataAdviseHolder_Advise(
    553564  IDataAdviseHolder*      iface,
    554   IDataObject*            pDataObject,
    555   FORMATETC*              pFetc,
    556   DWORD                   advf,
    557   IAdviseSink*            pAdvise,
     565  IDataObject*            pDataObject, 
     566  FORMATETC*              pFetc, 
     567  DWORD                   advf, 
     568  IAdviseSink*            pAdvise, 
    558569  DWORD*                  pdwConnection)
    559570{
    560571  DWORD index;
    561 
    562   ICOM_THIS(DataAdviseHolder, iface);
     572 
     573  ICOM_THIS(DataAdviseHolder, iface); 
    563574
    564575  TRACE("(%p)->(%p, %p, %08lx, %p, %p)\n", This, pDataObject, pFetc, advf,
    565     pAdvise, pdwConnection);
     576        pAdvise, pdwConnection);
    566577  /*
    567578   * Sanity check
     
    569580  if (pdwConnection==NULL)
    570581    return E_POINTER;
    571 
     582 
    572583  *pdwConnection = 0;
    573584
     
    588599    This->maxCons+=INITIAL_SINKS;
    589600    This->Connections = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
    590                     This->Connections,
    591                     This->maxCons*sizeof(DataAdviseConnection));
     601                                    This->Connections,
     602                                    This->maxCons*sizeof(DataAdviseConnection));
    592603  }
    593604  /*
     
    617628 * DataAdviseHolder_Unadvise
    618629 */
    619 static HRESULT WINAPI     DataAdviseHolder_Unadvise(
     630static HRESULT WINAPI     DataAdviseHolder_Unadvise( 
    620631  IDataAdviseHolder*      iface,
    621632  DWORD                   dwConnection)
    622633{
    623   ICOM_THIS(DataAdviseHolder, iface);
     634  ICOM_THIS(DataAdviseHolder, iface); 
    624635
    625636  TRACE("(%p)->(%lu)\n", This, dwConnection);
    626637
    627638  /*
    628    * So we don't return 0 as a cookie, the index was
     639   * So we don't return 0 as a cookie, the index was 
    629640   * incremented by 1 in OleAdviseHolderImpl_Advise
    630641   * we have to compensate.
    631642   */
    632643  dwConnection--;
    633 
     644 
    634645  /*
    635646   * Check for invalid cookies.
    636647   */
    637   if ( (dwConnection < 0) ||
     648  if ( (dwConnection < 0) || 
    638649       (dwConnection >= This->maxCons) )
    639650    return OLE_E_NOCONNECTION;
     
    650661}
    651662
    652 static HRESULT WINAPI     DataAdviseHolder_EnumAdvise(
    653   IDataAdviseHolder*      iface,
     663static HRESULT WINAPI     DataAdviseHolder_EnumAdvise( 
     664  IDataAdviseHolder*      iface,       
    654665  IEnumSTATDATA**         ppenumAdvise)
    655666{
    656   ICOM_THIS(DataAdviseHolder, iface);
     667  ICOM_THIS(DataAdviseHolder, iface); 
    657668
    658669  FIXME("(%p)->(%p)\n", This, ppenumAdvise);
     
    663674 * DataAdviseHolder_SendOnDataChange
    664675 */
    665 static HRESULT WINAPI     DataAdviseHolder_SendOnDataChange(
    666   IDataAdviseHolder*      iface,
    667   IDataObject*            pDataObject,
    668   DWORD                   dwReserved,
     676static HRESULT WINAPI     DataAdviseHolder_SendOnDataChange( 
     677  IDataAdviseHolder*      iface, 
     678  IDataObject*            pDataObject, 
     679  DWORD                   dwReserved, 
    669680  DWORD                   advf)
    670681{
    671   ICOM_THIS(DataAdviseHolder, iface);
     682  ICOM_THIS(DataAdviseHolder, iface); 
    672683  DWORD index;
    673684  STGMEDIUM stg;
     
    679690    if(This->Connections[index].sink != NULL) {
    680691      if(!(This->Connections[index].advf & ADVF_NODATA)) {
    681     TRACE("Calling IDataObject_GetData\n");
    682     res = IDataObject_GetData(pDataObject,
    683                   &(This->Connections[index].fmat),
    684                   &stg);
    685     TRACE("returns %08lx\n", res);
     692        TRACE("Calling IDataObject_GetData\n");
     693        res = IDataObject_GetData(pDataObject,
     694                                  &(This->Connections[index].fmat),
     695                                  &stg);
     696        TRACE("returns %08lx\n", res);
    686697      }
    687698      TRACE("Calling IAdviseSink_OnDataChange\n");
    688699      IAdviseSink_OnDataChange(This->Connections[index].sink,
    689                      &(This->Connections[index].fmat),
    690                      &stg);
     700                                     &(This->Connections[index].fmat),
     701                                     &stg);
    691702      TRACE("Done IAdviseSink_OnDataChange\n");
    692703      if(This->Connections[index].advf & ADVF_ONLYONCE) {
    693     TRACE("Removing connection\n");
    694     DataAdviseHolder_Unadvise(iface, index+1);
     704        TRACE("Removing connection\n");
     705        DataAdviseHolder_Unadvise(iface, index+1);
    695706      }
    696707    }
Note: See TracChangeset for help on using the changeset viewer.