Changeset 6711 for trunk/src/ole32


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

restored old version + wine update

Location:
trunk/src/ole32
Files:
24 edited

Legend:

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

    r6648 r6711  
    1 /* $Id: antimoniker.c,v 1.2 2001-09-05 13:17:07 bird Exp $ */
    21/***************************************************************************************
    3  *                        AntiMonikers implementation
     2 *                            AntiMonikers implementation
    43 *
    54 *               Copyright 1999  Noomen Hamza
     
    1615#include "debugtools.h"
    1716
     17#ifdef __WIN32OS2__
     18#undef FIXME
     19#undef TRACE
     20#ifdef DEBUG
     21#define TRACE WriteLog("OLE32: %s", __FUNCTION__); WriteLog
     22#define FIXME WriteLog("FIXME OLE32: %s", __FUNCTION__); WriteLog
     23#else
     24#define TRACE 1 ? (void)0 : (void)((int (*)(char *, ...)) NULL)
     25#define FIXME 1 ? (void)0 : (void)((int (*)(char *, ...)) NULL)
     26#endif
     27#endif
     28
    1829DEFAULT_DEBUG_CHANNEL(ole);
    1930
     
    2334    ICOM_VTABLE(IMoniker)*  lpvtbl1;  /* VTable relative to the IMoniker interface.*/
    2435
    25     /* The ROT (RunningObjectTable implementation) uses the IROTData interface to test whether
     36    /* The ROT (RunningObjectTable implementation) uses the IROTData interface to test whether 
    2637     * two monikers are equal. That's whay IROTData interface is implemented by monikers.
    2738     */
     
    129140{
    130141    ICOM_THIS(AntiMonikerImpl,iface);
    131 
     142 
    132143  TRACE("(%p,%p,%p)\n",This,riid,ppvObject);
    133144
    134145  /* Perform a sanity check on the parameters.*/
    135146    if ( (This==0) || (ppvObject==0) )
    136     return E_INVALIDARG;
    137 
     147        return E_INVALIDARG;
     148 
    138149  /* Initialize the return parameter */
    139150  *ppvObject = 0;
     
    152163    if ((*ppvObject)==0)
    153164        return E_NOINTERFACE;
    154 
     165 
    155166   /* Query Interface always increases the reference count by one when it is successful */
    156167  AntiMonikerImpl_AddRef(iface);
     
    201212    if (pClassID==NULL)
    202213        return E_POINTER;
    203 
     214           
    204215    *pClassID = CLSID_AntiMoniker;
    205 
     216       
    206217    return S_OK;
    207218}
     
    245256    DWORD constant=1;
    246257    HRESULT res;
    247 
     258   
    248259    /* data writen by this function is only a DWORD constant seted to 1 ! */
    249260    res=IStream_Write(pStm,&constant,sizeof(constant),NULL);
     
    264275
    265276    /* for more details see AntiMonikerImpl_Save coments */
    266 
     277   
    267278    /* Normaly the sizemax must be the  size of DWORD ! but I tested this function it ususlly return 16 bytes */
    268279    /* more than the number of bytes used by AntiMoniker::Save function */
     
    343354
    344355    *ppmkReduced=iface;
    345 
     356   
    346357    return MK_S_REDUCED_TO_SELF;
    347358}
     
    358369
    359370    if ((ppmkComposite==NULL)||(pmkRight==NULL))
    360     return E_POINTER;
     371        return E_POINTER;
    361372
    362373    *ppmkComposite=0;
    363 
     374   
    364375    if (fOnlyIfNotGeneric)
    365376        return MK_E_NEEDGENERIC;
     
    377388    if (ppenumMoniker == NULL)
    378389        return E_POINTER;
    379 
     390   
    380391    *ppenumMoniker = NULL;
    381392
     
    389400{
    390401    DWORD mkSys;
    391 
     402   
    392403    TRACE("(%p,%p)\n",iface,pmkOtherMoniker);
    393404
    394405    if (pmkOtherMoniker==NULL)
    395406        return S_FALSE;
    396 
     407   
    397408    IMoniker_IsSystemMoniker(pmkOtherMoniker,&mkSys);
    398409
     
    477488{
    478489    DWORD mkSys;
    479 
     490   
    480491    IMoniker_IsSystemMoniker(pmkOther,&mkSys);
    481492
     
    487498
    488499        IMoniker_AddRef(iface);
    489 
     500       
    490501        return MK_S_US;
    491502    }
     
    520531{
    521532    WCHAR back[]={'\\','.','.',0};
    522 
     533   
    523534    TRACE("(%p,%p,%p,%p)\n",iface,pbc,pmkToLeft,ppszDisplayName);
    524535
     
    537548
    538549    strcpyW(*ppszDisplayName,back);
    539 
     550   
    540551    return S_OK;
    541552}
     
    564575    if (!pwdMksys)
    565576        return E_POINTER;
    566 
     577   
    567578    (*pwdMksys)=MKSYS_ANTIMONIKER;
    568579
     
    601612{
    602613    ICOM_THIS_From_IROTData(IMoniker, iface);
    603 
     614   
    604615    TRACE("(%p)\n",iface);
    605616
     
    620631
    621632/******************************************************************************
    622  *        CreateAntiMoniker [OLE.55]
     633 *        CreateAntiMoniker     [OLE.55]
    623634 ******************************************************************************/
    624635HRESULT WINAPI CreateAntiMoniker(LPMONIKER * ppmk)
     
    627638    HRESULT        hr = S_OK;
    628639    IID riid=IID_IMoniker;
    629 
     640   
    630641    TRACE("(%p)\n",ppmk);
    631642
  • trunk/src/ole32/bindctx.c

    r6648 r6711  
    1 /* $Id: bindctx.c,v 1.2 2001-09-05 13:17:07 bird Exp $ */
    21/***************************************************************************************
    3  *                        BindCtx implementation
     2 *                            BindCtx implementation
    43 *
    54 *  Copyright 1999  Noomen Hamza
     
    1817#include "heap.h"
    1918
     19#ifdef __WIN32OS2__
     20#undef FIXME
     21#undef TRACE
     22#ifdef DEBUG
     23#define TRACE WriteLog("OLE32: %s", __FUNCTION__); WriteLog
     24#define FIXME WriteLog("FIXME OLE32: %s", __FUNCTION__); WriteLog
     25#else
     26#define TRACE 1 ? (void)0 : (void)((int (*)(char *, ...)) NULL)
     27#define FIXME 1 ? (void)0 : (void)((int (*)(char *, ...)) NULL)
     28#endif
     29#endif
     30
    2031DEFAULT_DEBUG_CHANNEL(ole);
    2132
    2233/* represent the first size table and it's increment block size */
    23 #define  BLOCK_TAB_SIZE 10
     34#define  BLOCK_TAB_SIZE 10 
    2435#define  MAX_TAB_SIZE   0xFFFFFFFF
    2536
     
    3950
    4051    ICOM_VFIELD(IBindCtx); /* VTable relative to the IBindCtx interface.*/
    41 
     52                                     
    4253    ULONG ref; /* reference counter for this object */
    4354
     
    103114  if ( (This==0) || (ppvObject==0) )
    104115      return E_INVALIDARG;
    105 
     116 
    106117  /* Initialize the return parameter.*/
    107118  *ppvObject = 0;
     
    117128  if ((*ppvObject)==0)
    118129      return E_NOINTERFACE;
    119 
     130 
    120131   /* Query Interface always increases the reference count by one when it is successful */
    121132  BindCtxImpl_AddRef(iface);
     
    224235    if (punk==NULL)
    225236        return E_POINTER;
    226 
     237   
    227238    IUnknown_AddRef(punk);
    228 
     239   
    229240    /* put the object in the first free element in the table */
    230241    This->bindCtxTable[lastIndex].pObj = punk;
     
    264275    /* check if the object was registred or not */
    265276    if (BindCtxImpl_GetObjectIndex(This,punk,NULL,&index)==S_FALSE)
    266 
     277       
    267278        return MK_E_NOTBOUND;
    268279
    269280    IUnknown_Release(This->bindCtxTable[index].pObj);
    270 
     281   
    271282    /* left-shift all elements in the right side of the current revoked object */
    272283    for(j=index; j<This->bindCtxTableLastIndex-1; j++)
    273284        This->bindCtxTable[j]= This->bindCtxTable[j+1];
    274 
     285   
    275286    This->bindCtxTableLastIndex--;
    276287
     
    308319    if (pbindopts==NULL)
    309320        return E_POINTER;
    310 
     321   
    311322    if (pbindopts->cbStruct > sizeof(BIND_OPTS2))
    312323    {
     
    352363    if (pprot==NULL)
    353364        return E_POINTER;
    354 
     365   
    355366    res=GetRunningObjectTable(0, pprot);
    356367
     
    369380    if (punk==NULL)
    370381        return E_INVALIDARG;
    371 
     382   
    372383    IUnknown_AddRef(punk);
    373384
     
    390401
    391402    This->bindCtxTableLastIndex++;
    392 
     403   
    393404    if (This->bindCtxTableLastIndex == This->bindCtxTableSize){ /* table is full ! must be resized */
    394405
     
    420431
    421432    *punk=0;
    422 
     433   
    423434    if (BindCtxImpl_GetObjectIndex(This,NULL,pszkey,&index)==S_FALSE)
    424435        return E_FAIL;
    425436
    426437    IUnknown_AddRef(This->bindCtxTable[index].pObj);
    427 
     438   
    428439    *punk = This->bindCtxTable[index].pObj;
    429440
     
    447458    /* release the object if it's found */
    448459    IUnknown_Release(This->bindCtxTable[index].pObj);
    449 
     460   
    450461    /* remove the object from the table with a left-shifting of all objects in the right side */
    451462    for(j=index; j<This->bindCtxTableLastIndex-1; j++)
    452463        This->bindCtxTable[j]= This->bindCtxTable[j+1];
    453 
     464   
    454465    This->bindCtxTableLastIndex--;
    455466
     
    477488    DWORD i;
    478489    BYTE found=0;
    479 
     490   
    480491    TRACE("(%p,%p,%p,%p)\n",This,punk,pszkey,index);
    481492
  • trunk/src/ole32/clipboard.c

    r6648 r6711  
    1 /* $Id: clipboard.c,v 1.2 2001-09-05 13:17:07 bird Exp $ */
    21/*
    32 *  OLE 2 clipboard support
     
    8281
    8382  /*
    84    * The hidden OLE clipboard window. This window is used as the bridge between the
     83   * The hidden OLE clipboard window. This window is used as the bridge between the 
    8584   * the OLE and windows clipboard API. (Windows creates one such window per process)
    8685   */
     
    115114*   DO NOT add any members before the VTables declaration!
    116115*/
    117 typedef struct
     116typedef struct 
    118117{
    119118  /* IEnumFORMATETC VTable */
    120119  ICOM_VFIELD(IEnumFORMATETC);
    121 
     120 
    122121  /* IEnumFORMATETC fields */
    123122  UINT                         posFmt;    /* current enumerator position */
     
    134133   */
    135134  IUnknown*                    pUnkDataObj;
    136 
     135 
    137136} IEnumFORMATETCImpl;
    138137
     
    173172            REFIID           riid,
    174173            void**           ppvObject);
    175 static ULONG WINAPI OLEClipbrd_IDataObject_AddRef(
     174static ULONG WINAPI OLEClipbrd_IDataObject_AddRef( 
    176175            IDataObject*     iface);
    177 static ULONG WINAPI OLEClipbrd_IDataObject_Release(
     176static ULONG WINAPI OLEClipbrd_IDataObject_Release( 
    178177            IDataObject*     iface);
    179178static HRESULT WINAPI OLEClipbrd_IDataObject_GetData(
    180         IDataObject*     iface,
    181         LPFORMATETC      pformatetcIn,
    182         STGMEDIUM*       pmedium);
     179            IDataObject*     iface,
     180            LPFORMATETC      pformatetcIn,
     181            STGMEDIUM*       pmedium);
    183182static HRESULT WINAPI OLEClipbrd_IDataObject_GetDataHere(
    184         IDataObject*     iface,
    185         LPFORMATETC      pformatetc,
    186         STGMEDIUM*       pmedium);
     183            IDataObject*     iface,
     184            LPFORMATETC      pformatetc,
     185            STGMEDIUM*       pmedium);
    187186static HRESULT WINAPI OLEClipbrd_IDataObject_QueryGetData(
    188         IDataObject*     iface,
    189         LPFORMATETC      pformatetc);
     187            IDataObject*     iface,
     188            LPFORMATETC      pformatetc);
    190189static HRESULT WINAPI OLEClipbrd_IDataObject_GetCanonicalFormatEtc(
    191         IDataObject*     iface,
    192         LPFORMATETC      pformatectIn,
    193         LPFORMATETC      pformatetcOut);
     190            IDataObject*     iface,
     191            LPFORMATETC      pformatectIn,
     192            LPFORMATETC      pformatetcOut);
    194193static HRESULT WINAPI OLEClipbrd_IDataObject_SetData(
    195         IDataObject*     iface,
    196         LPFORMATETC      pformatetc,
    197         STGMEDIUM*       pmedium,
    198         BOOL             fRelease);
     194            IDataObject*     iface,
     195            LPFORMATETC      pformatetc,
     196            STGMEDIUM*       pmedium,
     197            BOOL             fRelease);
    199198static HRESULT WINAPI OLEClipbrd_IDataObject_EnumFormatEtc(
    200         IDataObject*     iface,
    201         DWORD            dwDirection,
    202         IEnumFORMATETC** ppenumFormatEtc);
     199            IDataObject*     iface,       
     200            DWORD            dwDirection,
     201            IEnumFORMATETC** ppenumFormatEtc);
    203202static HRESULT WINAPI OLEClipbrd_IDataObject_DAdvise(
    204         IDataObject*     iface,
    205         FORMATETC*       pformatetc,
    206         DWORD            advf,
    207         IAdviseSink*     pAdvSink,
    208         DWORD*           pdwConnection);
     203            IDataObject*     iface,
     204            FORMATETC*       pformatetc,
     205            DWORD            advf,
     206            IAdviseSink*     pAdvSink,
     207            DWORD*           pdwConnection);
    209208static HRESULT WINAPI OLEClipbrd_IDataObject_DUnadvise(
    210         IDataObject*     iface,
    211         DWORD            dwConnection);
     209            IDataObject*     iface,
     210            DWORD            dwConnection);
    212211static HRESULT WINAPI OLEClipbrd_IDataObject_EnumDAdvise(
    213         IDataObject*     iface,
    214         IEnumSTATDATA**  ppenumAdvise);
     212            IDataObject*     iface,
     213            IEnumSTATDATA**  ppenumAdvise);
    215214
    216215/*
     
    266265
    267266/*
    268  * Name of our registered OLE clipboard window class
     267 * Name of our registered OLE clipboard window class 
    269268 */
    270269CHAR OLEClipbrd_WNDCLASS[] = "CLIPBRDWNDCLASS";
     
    280279
    281280/*---------------------------------------------------------------------*
    282  *           Win32 OLE clipboard API
     281 *           Win32 OLE clipboard API 
    283282 *---------------------------------------------------------------------*/
    284283
     
    291290 *
    292291 *    S_OK                  IDataObject pointer placed on the clipboard
    293  *    CLIPBRD_E_CANT_OPEN   OpenClipboard failed
    294  *    CLIPBRD_E_CANT_EMPTY  EmptyClipboard failed
     292 *    CLIPBRD_E_CANT_OPEN   OpenClipboard failed 
     293 *    CLIPBRD_E_CANT_EMPTY  EmptyClipboard failed 
    295294 *    CLIPBRD_E_CANT_CLOSE  CloseClipboard failed
    296295 *    CLIPBRD_E_CANT_SET    SetClipboard failed
     
    307306  OLEClipbrd **ppDataObject;
    308307*/
    309 
     308 
    310309  TRACE("(%p)\n", pDataObj);
    311 
     310 
    312311  /*
    313312   * Make sure we have a clipboard object
     
    332331  /*
    333332   * Empty the current clipboard and make our window the clipboard owner
    334    * NOTE: This will trigger a WM_DESTROYCLIPBOARD message
     333   * NOTE: This will trigger a WM_DESTROYCLIPBOARD message 
    335334   */
    336335  if ( !EmptyClipboard() )
     
    357356
    358357  /*
    359    * Enumerate all HGLOBAL formats supported by the source and make
     358   * Enumerate all HGLOBAL formats supported by the source and make 
    360359   * those formats available using delayed rendering using SetClipboardData.
    361    * Only global memory based data items may be made available to non-OLE
    362    * applications via the standard Windows clipboard API. Data based on other
     360   * Only global memory based data items may be made available to non-OLE 
     361   * applications via the standard Windows clipboard API. Data based on other 
    363362   * mediums(non TYMED_HGLOBAL) can only be accessed via the Ole Clipboard API.
    364363   *
     
    374373      HANDLE_ERROR( hr );
    375374    }
    376 
     375     
    377376    while ( S_OK == IEnumFORMATETC_Next(penumFormatetc, 1, &rgelt, NULL) )
    378377    {
     
    383382              GetClipboardFormatNameA(rgelt.cfFormat, szFmtName, sizeof(szFmtName)-1)
    384383                ? szFmtName : "");
    385 
     384 
    386385        SetClipboardData( rgelt.cfFormat, (HANDLE)NULL);
    387386      }
     
    392391  /*
    393392   * Windows additionally creates a new "DataObject" clipboard format
    394    * and stores in on the clipboard. We could possibly store a pointer
     393   * and stores in on the clipboard. We could possibly store a pointer 
    395394   * to our internal IDataObject interface on the clipboard. I'm not
    396395   * sure what the use of this is though.
     
    403402   if (hDataObject==0)
    404403     HANDLE_ERROR( E_OUTOFMEMORY );
    405 
     404   
    406405   ppDataObject = (OLEClipbrd**)GlobalLock(hDataObject);
    407406   *ppDataObject = theOleClipboard;
     
    411410     HANDLE_ERROR( CLIPBRD_E_CANT_SET );
    412411*/
    413 
     412 
    414413  hr = S_OK;
    415414
     
    440439/***********************************************************************
    441440 * OleGetClipboard [OLE32.105]
    442  * Returns a pointer to our internal IDataObject which represents the conceptual
    443  * state of the Windows clipboard. If the current clipboard already contains
     441 * Returns a pointer to our internal IDataObject which represents the conceptual 
     442 * state of the Windows clipboard. If the current clipboard already contains 
    444443 * an IDataObject, our internal IDataObject will delegate to this object.
    445444 */
     
    448447  HRESULT hr = S_OK;
    449448  TRACE("()\n");
    450 
     449   
    451450  /*
    452451   * Make sure we have a clipboard object
     
    489488  BOOL bClipboardOpen = FALSE;
    490489  IDataObject* pIDataObjectSrc = NULL;
    491 
     490 
    492491  TRACE("()\n");
    493492
     
    509508  pIDataObjectSrc = theOleClipboard->pIDataObjectSrc;
    510509  IDataObject_AddRef(pIDataObjectSrc);
    511 
     510 
    512511  /*
    513512   * Open the Windows clipboard
     
    549548    }
    550549  }
    551 
     550 
    552551  IEnumFORMATETC_Release(penumFormatetc);
    553 
     552 
    554553  /*
    555554   * Release the source data object we are holding on to
     
    572571 *           OleIsCurrentClipboard [OLE32.110]
    573572 */
    574 HRESULT WINAPI OleIsCurrentClipboard (  IDataObject *pDataObject)
     573HRESULT WINAPI OleIsCurrentClipboard (  IDataObject *pDataObject) 
    575574{
    576575  TRACE("()\n");
     
    588587
    589588/*---------------------------------------------------------------------*
    590  *           Internal implementation methods for the OLE clipboard
     589 *           Internal implementation methods for the OLE clipboard 
    591590 *---------------------------------------------------------------------*/
    592591
    593592/***********************************************************************
    594593 * OLEClipbrd_Initialize()
    595  * Initializes the OLE clipboard.
     594 * Initializes the OLE clipboard. 
    596595 */
    597596void OLEClipbrd_Initialize()
    598597{
    599598  /*
    600    * Create the clipboard if necessary
     599   * Create the clipboard if necessary 
    601600   */
    602601  if ( !theOleClipboard )
     
    610609/***********************************************************************
    611610 * OLEClipbrd_UnInitialize()
    612  * Un-Initializes the OLE clipboard
     611 * Un-Initializes the OLE clipboard 
    613612 */
    614613void OLEClipbrd_UnInitialize()
     
    637636  OLEClipbrd* newObject = NULL;
    638637  HGLOBAL hNewObject = 0;
    639 
     638 
    640639  /*
    641640   * Allocate space for the object. We use GlobalAlloc since we need
     
    651650   */
    652651  newObject = GlobalLock(hNewObject);
    653 
     652 
    654653  /*
    655654   * Initialize the virtual function table.
     
    658657
    659658  /*
    660    * Start with one reference count. The caller of this function
     659   * Start with one reference count. The caller of this function 
    661660   * must release the interface pointer when it is done.
    662661   */
     
    664663
    665664  newObject->hSelf = hNewObject;
    666 
     665 
    667666  /*
    668667   * The Ole clipboard is a singleton - save the global handle and pointer
     
    677676{
    678677  TRACE("()\n");
    679 
     678   
    680679  if ( !ptrToDestroy )
    681680    return;
    682681
    683682  /*
    684    * Destroy the Ole clipboard window
     683   * Destroy the Ole clipboard window 
    685684   */
    686685  if ( ptrToDestroy->hWndClipboard )
     
    704703/***********************************************************************
    705704 * OLEClipbrd_CreateWindow()
    706  * Create the clipboard window
     705 * Create the clipboard window 
    707706 */
    708707static HWND OLEClipbrd_CreateWindow()
     
    711710  WNDCLASSEXA wcex;
    712711
    713   /*
    714    * Register the clipboard window class if necessary
     712  /* 
     713   * Register the clipboard window class if necessary 
    715714   */
    716715    ZeroMemory( &wcex, sizeof(WNDCLASSEXA));
     
    728727
    729728  /*
    730    * Create a hidden window to receive OLE clipboard messages
     729   * Create a hidden window to receive OLE clipboard messages 
    731730   */
    732731
     
    738737 */
    739738
    740   hwnd = CreateWindowA(OLEClipbrd_WNDCLASS,
    741                     "ClipboardWindow",
    742                     WS_POPUP | WS_CLIPSIBLINGS | WS_OVERLAPPED,
    743                     CW_USEDEFAULT, CW_USEDEFAULT,
    744                     CW_USEDEFAULT, CW_USEDEFAULT,
    745                     0,
    746                     0,
    747                     0,
    748                     0 /*(LPVOID)&clipboardInfo */);
     739  hwnd = CreateWindowA(OLEClipbrd_WNDCLASS, 
     740                                    "ClipboardWindow",
     741                                    WS_POPUP | WS_CLIPSIBLINGS | WS_OVERLAPPED,
     742                                    CW_USEDEFAULT, CW_USEDEFAULT,
     743                                    CW_USEDEFAULT, CW_USEDEFAULT,
     744                                    0,
     745                                    0,
     746                                    0,
     747                                    0 /*(LPVOID)&clipboardInfo */);
    749748
    750749  return hwnd;
     
    757756static void OLEClipbrd_DestroyWindow(HWND hwnd)
    758757{
    759   /*
    760    * Destroy clipboard window and unregister its WNDCLASS
     758  /* 
     759   * Destroy clipboard window and unregister its WNDCLASS 
    761760   */
    762761  DestroyWindow(hwnd);
     
    766765/***********************************************************************
    767766 * OLEClipbrd_WndProc(HWND, unsigned, WORD, LONG)
    768  * Processes messages sent to the OLE clipboard window.
    769  * Note that we will intercept messages in our WndProc only when data
    770  * has been placed in the clipboard via OleSetClipboard().
     767 * Processes messages sent to the OLE clipboard window. 
     768 * Note that we will intercept messages in our WndProc only when data 
     769 * has been placed in the clipboard via OleSetClipboard(). 
    771770 * i.e. Only when OLE owns the windows clipboard.
    772771 */
     
    774773  (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
    775774{
    776   switch (message)
     775  switch (message) 
    777776  {
    778777    /*
    779      * WM_RENDERFORMAT
     778     * WM_RENDERFORMAT 
    780779     * We receive this message to allow us to handle delayed rendering of
    781      * a specific clipboard format when an application requests data in
     780     * a specific clipboard format when an application requests data in 
    782781     * that format by calling GetClipboardData.
    783      * (Recall that in OleSetClipboard, we used SetClipboardData to
     782     * (Recall that in OleSetClipboard, we used SetClipboardData to 
    784783     * make all HGLOBAL formats supported by the source IDataObject
    785784     * available using delayed rendering)
    786      * On receiving this mesage we must actually render the data in the
    787      * specified format and place it on the clipboard by calling the
    788      * SetClipboardData function.
     785     * On receiving this mesage we must actually render the data in the 
     786     * specified format and place it on the clipboard by calling the 
     787     * SetClipboardData function. 
    789788     */
    790789    case WM_RENDERFORMAT:
    791790    {
    792791      FORMATETC rgelt;
    793 
     792       
    794793      ZeroMemory( &rgelt, sizeof(FORMATETC));
    795794
     
    803802
    804803      TRACE("(): WM_RENDERFORMAT(cfFormat=%d)\n", rgelt.cfFormat);
    805 
     804     
    806805      /*
    807806       * Render the clipboard data.
     
    827826      IEnumFORMATETC* penumFormatetc = NULL;
    828827      FORMATETC rgelt;
    829 
     828     
    830829      TRACE("(): WM_RENDERALLFORMATS\n");
    831 
     830     
    832831      /*
    833832       * Render all HGLOBAL formats supported by the source into
     
    846845        {
    847846          /*
    848            * Render the clipboard data.
     847           * Render the clipboard data. 
    849848           */
    850849          if ( FAILED(OLEClipbrd_RenderFormat( (IDataObject*)&(theOleClipboard->lpvtbl1), &rgelt )) )
    851850            continue;
    852 
     851       
    853852          TRACE("(): WM_RENDERALLFORMATS(cfFormat=%d)\n", rgelt.cfFormat);
    854853        }
    855854      }
    856 
     855     
    857856      IEnumFORMATETC_Release(penumFormatetc);
    858857
     
    993992
    994993        HeapFree(GetProcessHeap(), 0, mfBits);
    995 
     994 
    996995        GlobalUnlock(std2.u.hMetaFilePict);
    997996
     
    10211020   *  Put a copy of the rendered data back on the clipboard
    10221021   */
    1023 
     1022 
    10241023  if ( !(hDup = OLEClipbrd_GlobalDupMem(hStorage)) )
    10251024    HANDLE_ERROR( E_OUTOFMEMORY );
    1026 
     1025       
    10271026  if ( !SetClipboardData( pFormatetc->cfFormat, hDup ) )
    10281027  {
     
    10321031
    10331032CLEANUP:
    1034 
     1033 
    10351034  ReleaseStgMedium(&std);
    1036 
     1035 
    10371036  return hr;
    10381037}
     
    10481047    PVOID pGlobalSrc, pGlobalDest;
    10491048    DWORD cBytes;
    1050 
     1049   
    10511050    if ( !hGlobalSrc )
    10521051      return 0;
     
    10551054    if ( 0 == cBytes )
    10561055      return 0;
    1057 
     1056       
    10581057    hGlobalDest = GlobalAlloc( GMEM_DDESHARE|GMEM_MOVEABLE,
    10591058                               cBytes );
    10601059    if ( !hGlobalDest )
    10611060      return 0;
    1062 
     1061   
    10631062    pGlobalSrc = GlobalLock(hGlobalSrc);
    10641063    pGlobalDest = GlobalLock(hGlobalDest);
     
    10671066
    10681067    memcpy(pGlobalDest, pGlobalSrc, cBytes);
    1069 
     1068       
    10701069    GlobalUnlock(hGlobalSrc);
    10711070    GlobalUnlock(hGlobalDest);
     
    10761075
    10771076/*---------------------------------------------------------------------*
    1078  *  Implementation of the internal IDataObject interface exposed by
     1077 *  Implementation of the internal IDataObject interface exposed by 
    10791078 *  the OLE clipboard.
    10801079 *---------------------------------------------------------------------*/
     
    10911090            void**           ppvObject)
    10921091{
    1093   /*
    1094    * Declare "This" pointer
     1092  /* 
     1093   * Declare "This" pointer 
    10951094   */
    10961095  ICOM_THIS(OLEClipbrd, iface);
    10971096  TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,debugstr_guid(riid),ppvObject);
    1098 
     1097 
    10991098  /*
    11001099   * Perform a sanity check on the parameters.
     
    11021101  if ( (This==0) || (ppvObject==0) )
    11031102    return E_INVALIDARG;
    1104 
     1103 
    11051104  /*
    11061105   * Initialize the return parameter.
     
    11111110   * Compare the riid with the interface IDs implemented by this object.
    11121111   */
    1113   if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0)
     1112  if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0) 
    11141113  {
    11151114    *ppvObject = iface;
    11161115  }
    1117   else if (memcmp(&IID_IDataObject, riid, sizeof(IID_IDataObject)) == 0)
     1116  else if (memcmp(&IID_IDataObject, riid, sizeof(IID_IDataObject)) == 0) 
    11181117  {
    11191118    *ppvObject = (IDataObject*)&(This->lpvtbl1);
     
    11241123    return E_NOINTERFACE;
    11251124  }
    1126 
     1125 
    11271126  /*
    11281127   * Query Interface always increases the reference count by one when it is
    1129    * successful.
     1128   * successful. 
    11301129   */
    11311130  IUnknown_AddRef((IUnknown*)*ppvObject);
     
    11391138 * See Windows documentation for more details on IUnknown methods.
    11401139 */
    1141 static ULONG WINAPI OLEClipbrd_IDataObject_AddRef(
     1140static ULONG WINAPI OLEClipbrd_IDataObject_AddRef( 
    11421141            IDataObject*     iface)
    11431142{
    1144   /*
    1145    * Declare "This" pointer
     1143  /* 
     1144   * Declare "This" pointer 
    11461145   */
    11471146  ICOM_THIS(OLEClipbrd, iface);
    11481147
    11491148  TRACE("(%p)->(count=%lu)\n",This, This->ref);
    1150 
     1149 
    11511150  This->ref++;
    11521151
     
    11591158 * See Windows documentation for more details on IUnknown methods.
    11601159 */
    1161 static ULONG WINAPI OLEClipbrd_IDataObject_Release(
     1160static ULONG WINAPI OLEClipbrd_IDataObject_Release( 
    11621161            IDataObject*     iface)
    11631162{
    1164   /*
    1165    * Declare "This" pointer
     1163  /* 
     1164   * Declare "This" pointer 
    11661165   */
    11671166  ICOM_THIS(OLEClipbrd, iface);
    11681167
    11691168  TRACE("(%p)->(count=%lu)\n",This, This->ref);
    1170 
     1169 
    11711170  /*
    11721171   * Decrease the reference count on this object.
     
    11811180    OLEClipbrd_Destroy(This);
    11821181  }
    1183 
     1182 
    11841183  return This->ref;
    11851184}
    11861185
    1187 
     1186 
    11881187/************************************************************************
    11891188 * OLEClipbrd_IDataObject_GetData (IDataObject)
    11901189 *
    1191  * The OLE Clipboard's implementation of this method delegates to
     1190 * The OLE Clipboard's implementation of this method delegates to 
    11921191 * a data source if there is one or wraps around the windows clipboard
    11931192 *
     
    11951194 */
    11961195static HRESULT WINAPI OLEClipbrd_IDataObject_GetData(
    1197         IDataObject*     iface,
    1198         LPFORMATETC      pformatetcIn,
    1199         STGMEDIUM*       pmedium)
     1196            IDataObject*     iface,
     1197            LPFORMATETC      pformatetcIn,
     1198            STGMEDIUM*       pmedium)
    12001199{
    12011200  HANDLE      hData = 0;
     
    12041203
    12051204  /*
    1206    * Declare "This" pointer
     1205   * Declare "This" pointer 
    12071206   */
    12081207  ICOM_THIS(OLEClipbrd, iface);
    1209 
     1208 
    12101209  TRACE("(%p,%p,%p)\n", iface, pformatetcIn, pmedium);
    12111210
     
    12331232*/
    12341233
    1235   /*
     1234  /* 
    12361235   * Otherwise, get the data from the windows clipboard using GetClipboardData
    12371236   */
     
    12411240  hData = GetClipboardData(pformatetcIn->cfFormat);
    12421241
    1243   /*
     1242  /* 
    12441243   * Return the clipboard data in the storage medium structure
    12451244   */
     
    12471246  pmedium->u.hGlobal = (HGLOBAL)hData;
    12481247  pmedium->pUnkForRelease = NULL;
    1249 
     1248 
    12501249  hr = S_OK;
    1251 
     1250 
    12521251CLEANUP:
    12531252  /*
     
    12631262
    12641263static HRESULT WINAPI OLEClipbrd_IDataObject_GetDataHere(
    1265         IDataObject*     iface,
    1266         LPFORMATETC      pformatetc,
    1267         STGMEDIUM*       pmedium)
     1264            IDataObject*     iface,
     1265            LPFORMATETC      pformatetc,
     1266            STGMEDIUM*       pmedium)
    12681267{
    12691268  FIXME(": Stub\n");
     
    12741273 * OLEClipbrd_IDataObject_QueryGetData (IDataObject)
    12751274 *
    1276  * The OLE Clipboard's implementation of this method delegates to
     1275 * The OLE Clipboard's implementation of this method delegates to 
    12771276 * a data source if there is one or wraps around the windows clipboard
    12781277 * function IsClipboardFormatAvailable() otherwise.
     
    12811280 */
    12821281static HRESULT WINAPI OLEClipbrd_IDataObject_QueryGetData(
    1283         IDataObject*     iface,
    1284         LPFORMATETC      pformatetc)
    1285 {
    1286   /*
    1287    * Declare "This" pointer
     1282            IDataObject*     iface,
     1283            LPFORMATETC      pformatetc)
     1284{
     1285  /* 
     1286   * Declare "This" pointer 
    12881287   */
    12891288  ICOM_THIS(OLEClipbrd, iface);
     
    13151314  if ( pformatetc->tymed != TYMED_HGLOBAL )
    13161315    return DV_E_TYMED;
    1317 
     1316         
    13181317  /*
    13191318   * Delegate to the Windows clipboard function IsClipboardFormatAvailable
     
    13281327 */
    13291328static HRESULT WINAPI OLEClipbrd_IDataObject_GetCanonicalFormatEtc(
    1330         IDataObject*     iface,
    1331         LPFORMATETC      pformatectIn,
    1332         LPFORMATETC      pformatetcOut)
     1329            IDataObject*     iface,
     1330            LPFORMATETC      pformatectIn,
     1331            LPFORMATETC      pformatetcOut)
    13331332{
    13341333  TRACE("(%p, %p, %p)\n", iface, pformatectIn, pformatetcOut);
     
    13441343 * OLEClipbrd_IDataObject_SetData (IDataObject)
    13451344 *
    1346  * The OLE Clipboard's does not implement this method
     1345 * The OLE Clipboard's does not implement this method 
    13471346 *
    13481347 * See Windows documentation for more details on IDataObject methods.
    13491348 */
    13501349static HRESULT WINAPI OLEClipbrd_IDataObject_SetData(
    1351         IDataObject*     iface,
    1352         LPFORMATETC      pformatetc,
    1353         STGMEDIUM*       pmedium,
    1354         BOOL             fRelease)
     1350            IDataObject*     iface,
     1351            LPFORMATETC      pformatetc,
     1352            STGMEDIUM*       pmedium,
     1353            BOOL             fRelease)
    13551354{
    13561355  TRACE("\n");
     
    13641363 */
    13651364static HRESULT WINAPI OLEClipbrd_IDataObject_EnumFormatEtc(
    1366         IDataObject*     iface,
    1367         DWORD            dwDirection,
    1368         IEnumFORMATETC** ppenumFormatEtc)
     1365            IDataObject*     iface,
     1366            DWORD            dwDirection,
     1367            IEnumFORMATETC** ppenumFormatEtc)
    13691368{
    13701369  HRESULT hr = S_OK;
     
    13731372  UINT format;
    13741373  BOOL bClipboardOpen;
    1375 
    1376   /*
    1377    * Declare "This" pointer
     1374 
     1375  /* 
     1376   * Declare "This" pointer 
    13781377   */
    13791378  ICOM_THIS(OLEClipbrd, iface);
     
    14281427      HANDLE_ERROR( E_FAIL );
    14291428    }
    1430 
     1429   
    14311430    /* Init the FORMATETC struct */
    14321431    afmt[i].cfFormat = format;
     
    14471446  if (FAILED( hr = IEnumFORMATETC_AddRef(*ppenumFormatEtc)))
    14481447    HANDLE_ERROR( hr );
    1449 
     1448     
    14501449  hr = S_OK;
    1451 
     1450 
    14521451CLEANUP:
    14531452  /*
     
    14561455  if (afmt)
    14571456    HeapFree(GetProcessHeap(), 0, afmt);
    1458 
     1457 
    14591458  /*
    14601459   * Close Windows clipboard
     
    14691468 * OLEClipbrd_IDataObject_DAdvise (IDataObject)
    14701469 *
    1471  * The OLE Clipboard's does not implement this method
     1470 * The OLE Clipboard's does not implement this method 
    14721471 *
    14731472 * See Windows documentation for more details on IDataObject methods.
    14741473 */
    14751474static HRESULT WINAPI OLEClipbrd_IDataObject_DAdvise(
    1476         IDataObject*     iface,
    1477         FORMATETC*       pformatetc,
    1478         DWORD            advf,
    1479         IAdviseSink*     pAdvSink,
    1480         DWORD*           pdwConnection)
     1475            IDataObject*     iface,
     1476            FORMATETC*       pformatetc,
     1477            DWORD            advf,
     1478            IAdviseSink*     pAdvSink,
     1479            DWORD*           pdwConnection)
    14811480{
    14821481  TRACE("\n");
     
    14871486 * OLEClipbrd_IDataObject_DUnadvise (IDataObject)
    14881487 *
    1489  * The OLE Clipboard's does not implement this method
     1488 * The OLE Clipboard's does not implement this method 
    14901489 *
    14911490 * See Windows documentation for more details on IDataObject methods.
    14921491 */
    14931492static HRESULT WINAPI OLEClipbrd_IDataObject_DUnadvise(
    1494         IDataObject*     iface,
    1495         DWORD            dwConnection)
     1493            IDataObject*     iface,
     1494            DWORD            dwConnection)
    14961495{
    14971496  TRACE("\n");
     
    15071506 */
    15081507static HRESULT WINAPI OLEClipbrd_IDataObject_EnumDAdvise(
    1509         IDataObject*     iface,
    1510         IEnumSTATDATA**  ppenumAdvise)
     1508            IDataObject*     iface,
     1509            IEnumSTATDATA**  ppenumAdvise)
    15111510{
    15121511  TRACE("\n");
     
    15341533  DWORD size=cfmt * sizeof(FORMATETC);
    15351534  LPMALLOC pIMalloc;
    1536 
     1535 
    15371536  ef = (IEnumFORMATETCImpl*)HeapAlloc(GetProcessHeap(),
    15381537                                      HEAP_ZERO_MEMORY,
     
    15401539  if (!ef)
    15411540    return NULL;
    1542 
     1541 
    15431542  ef->ref = 0;
    15441543  ICOM_VTBL(ef) = &efvt;
    15451544  ef->pUnkDataObj = pUnkDataObj;
    1546 
     1545 
    15471546  ef->posFmt = 0;
    15481547  ef->countFmt = cfmt;
     
    15511550  ef->pFmt = (LPFORMATETC)IMalloc_Alloc(pIMalloc, size);
    15521551  IMalloc_Release(pIMalloc);
    1553 
     1552 
    15541553  if (ef->pFmt)
    15551554    memcpy(ef->pFmt, afmt, size);
    1556 
     1555 
    15571556  TRACE("(%p)->()\n",ef);
    15581557  return (LPENUMFORMATETC)ef;
     
    15761575   * we only need to support the IUnknown and IEnumFORMATETC interfaces
    15771576   */
    1578 
     1577 
    15791578  *ppvObj = NULL;
    1580 
     1579 
    15811580  if(IsEqualIID(riid, &IID_IUnknown))
    15821581  {
     
    15861585  {
    15871586    *ppvObj = (IDataObject*)This;
    1588   }
    1589 
     1587  }   
     1588 
    15901589  if(*ppvObj)
    15911590  {
     
    15941593    return S_OK;
    15951594  }
    1596 
     1595 
    15971596  TRACE("-- Interface: E_NOINTERFACE\n");
    15981597  return E_NOINTERFACE;
     
    16151614  if (This->pUnkDataObj)
    16161615    IUnknown_AddRef(This->pUnkDataObj);
    1617 
     1616 
    16181617  return ++(This->ref);
    16191618}
     
    16331632  if (This->pUnkDataObj)
    16341633    IUnknown_Release(This->pUnkDataObj);  /* Release parent data object */
    1635 
    1636   if (!--(This->ref))
     1634 
     1635  if (!--(This->ref)) 
    16371636  {
    16381637    TRACE("() - destroying IEnumFORMATETC(%p)\n",This);
     
    16421641      IMalloc_Release(pIMalloc);
    16431642    }
    1644 
     1643     
    16451644    HeapFree(GetProcessHeap(),0,This);
    16461645    return 0;
     
    16611660  UINT cfetch;
    16621661  HRESULT hres = S_FALSE;
    1663 
     1662 
    16641663  TRACE("(%p)->(pos=%u)\n", This, This->posFmt);
    1665 
     1664 
    16661665  if (This->posFmt < This->countFmt)
    16671666  {
     
    16721671      hres = S_OK;
    16731672    }
    1674 
     1673   
    16751674    memcpy(rgelt, &This->pFmt[This->posFmt], cfetch * sizeof(FORMATETC));
    16761675    This->posFmt += cfetch;
     
    16801679    cfetch = 0;
    16811680  }
    1682 
     1681 
    16831682  if (pceltFethed)
    16841683  {
    16851684    *pceltFethed = cfetch;
    16861685  }
    1687 
     1686 
    16881687  return hres;
    16891688}
     
    16981697  ICOM_THIS(IEnumFORMATETCImpl,iface);
    16991698  TRACE("(%p)->(num=%lu)\n", This, celt);
    1700 
     1699 
    17011700  This->posFmt += celt;
    17021701  if (This->posFmt > This->countFmt)
     
    17171716  ICOM_THIS(IEnumFORMATETCImpl,iface);
    17181717  TRACE("(%p)->()\n", This);
    1719 
     1718 
    17201719  This->posFmt = 0;
    17211720  return S_OK;
     
    17321731  ICOM_THIS(IEnumFORMATETCImpl,iface);
    17331732  HRESULT hr = S_OK;
    1734 
     1733 
    17351734  TRACE("(%p)->(ppenum=%p)\n", This, ppenum);
    17361735
     
    17441743  if (FAILED( hr = IEnumFORMATETC_AddRef(*ppenum)))
    17451744    return ( hr );
    1746 
     1745 
    17471746  return (*ppenum) ? S_OK : E_OUTOFMEMORY;
    17481747}
  • trunk/src/ole32/compobj.c

    r6648 r6711  
    1 /* $Id: compobj.c,v 1.2 2001-09-05 13:17:07 bird Exp $ */
    21/*
    3  *  COMPOBJ library
    4  *
    5  *  Copyright 1995  Martin von Loewis
    6  *  Copyright 1998  Justin Bradford
     2 *      COMPOBJ library
     3 *
     4 *      Copyright 1995  Martin von Loewis
     5 *      Copyright 1998  Justin Bradford
    76 *      Copyright 1999  Francis Beaudet
    87 *  Copyright 1999  Sylvain St-Germain
     
    3837#ifdef __WIN32OS2__
    3938#include <heapstring.h>
     39
     40#undef FIXME
     41#undef TRACE
     42#ifdef DEBUG
     43#define TRACE WriteLog("OLE32: %s", __FUNCTION__); WriteLog
     44#define FIXME WriteLog("FIXME OLE32: %s", __FUNCTION__); WriteLog
     45#else
     46#define TRACE 1 ? (void)0 : (void)((int (*)(char *, ...)) NULL)
     47#define FIXME 1 ? (void)0 : (void)((int (*)(char *, ...)) NULL)
     48#endif
    4049#endif
    4150
     
    4554 *  COM External Lock structures and methods declaration
    4655 *
    47  *  This api provides a linked list to managed external references to
    48  *  COM objects.
    49  *
    50  *  The public interface consists of three calls:
     56 *  This api provides a linked list to managed external references to 
     57 *  COM objects. 
     58 *
     59 *  The public interface consists of three calls: 
    5160 *      COM_ExternalLockAddRef
    5261 *      COM_ExternalLockRelease
     
    5867
    5968/*
    60  * Declaration of the static structure that manage the
     69 * Declaration of the static structure that manage the 
    6170 * external lock to COM  objects.
    6271 */
     
    8392
    8493/*
    85  * Public Interface to the external lock list
     94 * Public Interface to the external lock list   
    8695 */
    8796static void COM_ExternalLockFreeList();
     
    91100
    92101/*
    93  * Private methods used to managed the linked list
     102 * Private methods used to managed the linked list   
    94103 */
    95104static BOOL COM_ExternalLockInsert(
     
    153162 */
    154163typedef struct tagOpenDll {
    155   HINSTANCE hLibrary;
     164  HINSTANCE hLibrary;       
    156165  struct tagOpenDll *next;
    157166} OpenDll;
     
    164173 */
    165174static HRESULT COM_GetRegisteredClassObject(REFCLSID    rclsid,
    166                         DWORD       dwClsContext,
    167                         LPUNKNOWN*  ppUnk);
     175                                            DWORD       dwClsContext,
     176                                            LPUNKNOWN*  ppUnk);
    168177
    169178static void COM_RevokeAllClasses();
     
    174183 *
    175184 * RETURNS
    176  *  Current build version, hiword is majornumber, loword is minornumber
     185 *      Current build version, hiword is majornumber, loword is minornumber
    177186 */
    178187DWORD WINAPI CoBuildVersion(void)
     
    184193#ifndef __WIN32OS2__
    185194/******************************************************************************
    186  *      CoInitialize16  [COMPOBJ.2]
     195 *              CoInitialize16  [COMPOBJ.2]
    187196 * Set the win16 IMalloc used for memory management
    188197 */
    189198HRESULT WINAPI CoInitialize16(
    190     LPVOID lpReserved   /* [in] pointer to win16 malloc interface */
     199        LPVOID lpReserved       /* [in] pointer to win16 malloc interface */
    191200) {
    192201    currentMalloc16 = (LPMALLOC16)lpReserved;
     
    196205
    197206/******************************************************************************
    198  *      CoInitialize    [OLE32.26]
     207 *              CoInitialize    [OLE32.26]
    199208 *
    200209 * Initializes the COM libraries.
     
    203212 */
    204213HRESULT WINAPI CoInitialize(
    205     LPVOID lpReserved   /* [in] pointer to win32 malloc interface
     214        LPVOID lpReserved       /* [in] pointer to win32 malloc interface
    206215                                   (obsolete, should be NULL) */
    207 )
     216) 
    208217{
    209218  /*
     
    214223
    215224/******************************************************************************
    216  *      CoInitializeEx  [OLE32.163]
     225 *              CoInitializeEx  [OLE32.163]
    217226 *
    218227 * Initializes the COM libraries. The behavior used to set the win32 IMalloc
     
    226235 *
    227236 * BUGS
    228  * Only the single threaded model is supported. As a result RPC_E_CHANGED_MODE
     237 * Only the single threaded model is supported. As a result RPC_E_CHANGED_MODE 
    229238 * is never returned.
    230239 *
     
    232241 */
    233242HRESULT WINAPI CoInitializeEx(
    234     LPVOID lpReserved,  /* [in] pointer to win32 malloc interface
     243        LPVOID lpReserved,      /* [in] pointer to win32 malloc interface
    235244                                   (obsolete, should be NULL) */
    236     DWORD dwCoInit      /* [in] A value from COINIT specifies the threading model */
    237 )
     245        DWORD dwCoInit          /* [in] A value from COINIT specifies the threading model */
     246) 
    238247{
    239248  HRESULT hr;
     
    249258   * Check for unsupported features.
    250259   */
    251   if (dwCoInit!=COINIT_APARTMENTTHREADED)
     260  if (dwCoInit!=COINIT_APARTMENTTHREADED) 
    252261  {
    253262    FIXME(":(%p,%x): unsupported flag %x\n", lpReserved, (int)dwCoInit, (int)dwCoInit);
     
    284293/***********************************************************************
    285294 *           CoUninitialize16   [COMPOBJ.3]
    286  * Don't know what it does.
     295 * Don't know what it does. 
    287296 * 3-Nov-98 -- this was originally misspelled, I changed it to what I
    288297 *   believe is the correct spelling
     
    305314{
    306315  TRACE("()\n");
    307 
     316 
    308317  /*
    309318   * Decrease the reference count.
    310319   */
    311320  s_COMLockCount--;
    312 
     321 
    313322  /*
    314323   * If we are back to 0 locks on the COM library, make sure we free
     
    344353 *           CoGetMalloc16    [COMPOBJ.4]
    345354 * RETURNS
    346  *  The current win16 IMalloc
     355 *      The current win16 IMalloc
    347356 */
    348357HRESULT WINAPI CoGetMalloc16(
    349     DWORD dwMemContext, /* [in] unknown */
    350     LPMALLOC16 * lpMalloc   /* [out] current win16 malloc interface */
     358        DWORD dwMemContext,     /* [in] unknown */
     359        LPMALLOC16 * lpMalloc   /* [out] current win16 malloc interface */
    351360) {
    352361    if(!currentMalloc16)
    353     currentMalloc16 = IMalloc16_Constructor();
     362        currentMalloc16 = IMalloc16_Constructor();
    354363    *lpMalloc = currentMalloc16;
    355364    return S_OK;
     
    358367
    359368/******************************************************************************
    360  *      CoGetMalloc [OLE32.20]
     369 *              CoGetMalloc     [OLE32.20]
    361370 *
    362371 * RETURNS
    363  *  The current win32 IMalloc
     372 *      The current win32 IMalloc
    364373 */
    365374HRESULT WINAPI CoGetMalloc(
    366     DWORD dwMemContext, /* [in] unknown */
    367     LPMALLOC *lpMalloc  /* [out] current win32 malloc interface */
     375        DWORD dwMemContext,     /* [in] unknown */
     376        LPMALLOC *lpMalloc      /* [out] current win32 malloc interface */
    368377) {
    369378    if(!currentMalloc32)
    370     currentMalloc32 = IMalloc_Constructor();
     379        currentMalloc32 = IMalloc_Constructor();
    371380    *lpMalloc = currentMalloc32;
    372381    return S_OK;
     
    378387 */
    379388HRESULT WINAPI CoCreateStandardMalloc16(DWORD dwMemContext,
    380                       LPMALLOC16 *lpMalloc)
     389                                          LPMALLOC16 *lpMalloc)
    381390{
    382391    /* FIXME: docu says we shouldn't return the same allocator as in
     
    387396
    388397/******************************************************************************
    389  *      CoDisconnectObject  [COMPOBJ.15]
     398 *              CoDisconnectObject      [COMPOBJ.15]
    390399 */
    391400HRESULT WINAPI CoDisconnectObject( LPUNKNOWN lpUnk, DWORD reserved )
     
    401410 *
    402411 * RETURNS
    403  *  TRUE if equal
     412 *      TRUE if equal
    404413 */
    405414BOOL16 WINAPI IsEqualGUID16(
    406     GUID* g1,   /* [in] unique id 1 */
    407     GUID* g2    /* [in] unique id 2 */
     415        GUID* g1,       /* [in] unique id 1 */
     416        GUID* g2        /* [in] unique id 2 */
    408417) {
    409418    return !memcmp( g1, g2, sizeof(GUID) );
     
    412421
    413422/******************************************************************************
    414  *      CLSIDFromString16   [COMPOBJ.20]
    415  * Converts a unique identifier from its string representation into
     423 *              CLSIDFromString16       [COMPOBJ.20]
     424 * Converts a unique identifier from its string representation into 
    416425 * the GUID struct.
    417426 *
    418  * Class id: DWORD-WORD-WORD-BYTES[2]-BYTES[6]
     427 * Class id: DWORD-WORD-WORD-BYTES[2]-BYTES[6] 
    419428 *
    420429 * RETURNS
    421  *  the converted GUID
     430 *      the converted GUID
    422431 */
    423432HRESULT WINAPI CLSIDFromString16(
    424     LPCOLESTR16 idstr,  /* [in] string representation of guid */
    425     CLSID *id       /* [out] GUID converted from string */
     433        LPCOLESTR16 idstr,      /* [in] string representation of guid */
     434        CLSID *id               /* [out] GUID converted from string */
    426435) {
    427436  BYTE *s = (BYTE *) idstr;
    428437  BYTE *p;
    429   int   i;
     438  int   i;
    430439  BYTE table[256];
    431440
    432441  if (!s)
    433       s = "{00000000-0000-0000-0000-000000000000}";
     442          s = "{00000000-0000-0000-0000-000000000000}";
    434443  else {  /* validate the CLSID string */
    435444
     
    468477  p = (BYTE *) id;
    469478
    470   s++;  /* skip leading brace  */
     479  s++;  /* skip leading brace  */
    471480  for (i = 0; i < 4; i++) {
    472481    p[3 - i] = table[*s]<<4 | table[*(s+1)];
     
    474483  }
    475484  p += 4;
    476   s++;  /* skip - */
     485  s++;  /* skip - */
    477486
    478487  for (i = 0; i < 2; i++) {
     
    481490  }
    482491  p += 2;
    483   s++;  /* skip - */
     492  s++;  /* skip - */
    484493
    485494  for (i = 0; i < 2; i++) {
     
    488497  }
    489498  p += 2;
    490   s++;  /* skip - */
     499  s++;  /* skip - */
    491500
    492501  /* these are just sequential bytes */
     
    495504    s += 2;
    496505  }
    497   s++;  /* skip - */
     506  s++;  /* skip - */
    498507
    499508  for (i = 0; i < 6; i++) {
     
    506515
    507516/******************************************************************************
    508  *      CoCreateGuid[OLE32.6]
     517 *              CoCreateGuid[OLE32.6]
    509518 *
    510519 */
    511520HRESULT WINAPI CoCreateGuid(
    512     GUID *pguid /* [out] points to the GUID to initialize */
     521        GUID *pguid /* [out] points to the GUID to initialize */
    513522) {
    514523    return UuidCreate(pguid);
     
    516525
    517526/******************************************************************************
    518  *      CLSIDFromString [OLE32.3]
    519  * Converts a unique identifier from its string representation into
     527 *              CLSIDFromString [OLE32.3]
     528 * Converts a unique identifier from its string representation into 
    520529 * the GUID struct.
    521530 *
     
    524533 *
    525534 * RETURNS
    526  *  the converted GUID
     535 *      the converted GUID
    527536 */
    528537HRESULT WINAPI CLSIDFromString(
    529     LPCOLESTR idstr,    /* [in] string representation of GUID */
    530     CLSID *id       /* [out] GUID represented by above string */
     538        LPCOLESTR idstr,        /* [in] string representation of GUID */
     539        CLSID *id               /* [out] GUID represented by above string */
    531540) {
    532541    LPOLESTR16      xid = HEAP_strdupWtoA(GetProcessHeap(),0,idstr);
     
    541550
    542551/******************************************************************************
    543  *      WINE_StringFromCLSID    [Internal]
     552 *              WINE_StringFromCLSID    [Internal]
    544553 * Converts a GUID into the respective string representation.
    545554 *
     
    547556 *
    548557 * RETURNS
    549  *  the string representation and HRESULT
     558 *      the string representation and HRESULT
    550559 */
    551560#ifdef __WIN32OS2__
    552561HRESULT WINAPI WINE_StringFromCLSID(
    553     const CLSID *id,    /* [in] GUID to be converted */
    554     LPSTR idstr     /* [out] pointer to buffer to contain converted guid */
     562        const CLSID *id,        /* [in] GUID to be converted */
     563        LPSTR idstr             /* [out] pointer to buffer to contain converted guid */
    555564#else
    556565static HRESULT WINE_StringFromCLSID(
    557     const CLSID *id,    /* [in] GUID to be converted */
    558     LPSTR idstr     /* [out] pointer to buffer to contain converted guid */
     566        const CLSID *id,        /* [in] GUID to be converted */
     567        LPSTR idstr             /* [out] pointer to buffer to contain converted guid */
    559568#endif
    560569) {
    561570  static const char *hex = "0123456789ABCDEF";
    562571  char *s;
    563   int   i;
     572  int   i;
    564573
    565574  if (!id)
    566     { ERR("called with id=Null\n");
    567       *idstr = 0x00;
    568       return E_FAIL;
    569     }
    570 
     575        { ERR("called with id=Null\n");
     576          *idstr = 0x00;
     577          return E_FAIL;
     578        }
     579       
    571580  sprintf(idstr, "{%08lX-%04X-%04X-%02X%02X-",
    572       id->Data1, id->Data2, id->Data3,
    573       id->Data4[0], id->Data4[1]);
     581          id->Data1, id->Data2, id->Data3,
     582          id->Data4[0], id->Data4[1]);
    574583  s = &idstr[25];
    575584
     
    589598#ifndef __WIN32OS2__
    590599/******************************************************************************
    591  *      StringFromCLSID16   [COMPOBJ.19]
     600 *              StringFromCLSID16       [COMPOBJ.19]
    592601 * Converts a GUID into the respective string representation.
    593602 * The target string is allocated using the OLE IMalloc.
    594603 * RETURNS
    595  *  the string representation and HRESULT
     604 *      the string representation and HRESULT
    596605 */
    597606HRESULT WINAPI StringFromCLSID16(
    598607        REFCLSID id,            /* [in] the GUID to be converted */
    599     LPOLESTR16 *idstr   /* [out] a pointer to a to-be-allocated segmented pointer pointing to the resulting string */
     608        LPOLESTR16 *idstr       /* [out] a pointer to a to-be-allocated segmented pointer pointing to the resulting string */
    600609
    601610) {
    602611    extern BOOL WINAPI K32WOWCallback16Ex( DWORD vpfn16, DWORD dwFlags,
    603612                                           DWORD cbArgs, LPVOID pArgs, LPDWORD pdwRetCode );
    604     LPMALLOC16  mllc;
    605     HRESULT ret;
    606     DWORD   args[2];
     613    LPMALLOC16  mllc;
     614    HRESULT     ret;
     615    DWORD       args[2];
    607616
    608617    ret = CoGetMalloc16(0,&mllc);
     
    616625     */
    617626    if (!K32WOWCallback16Ex(
    618         (DWORD)((ICOM_VTABLE(IMalloc16)*)MapSL(
     627        (DWORD)((ICOM_VTABLE(IMalloc16)*)MapSL(
    619628            (SEGPTR)ICOM_VTBL(((LPMALLOC16)MapSL((SEGPTR)mllc))))
    620     )->Alloc,
    621     WCB16_CDECL,
    622     2*sizeof(DWORD),
    623     (LPVOID)args,
    624     (LPDWORD)idstr
     629        )->Alloc,
     630        WCB16_CDECL,
     631        2*sizeof(DWORD),
     632        (LPVOID)args,
     633        (LPDWORD)idstr
    625634    )) {
    626         WARN("CallTo16 IMalloc16 failed\n");
    627         return E_FAIL;
     635        WARN("CallTo16 IMalloc16 failed\n");
     636        return E_FAIL;
    628637    }
    629638    return WINE_StringFromCLSID(id,MapSL((SEGPTR)*idstr));
     
    631640#endif
    632641/******************************************************************************
    633  *      StringFromCLSID [OLE32.151]
     642 *              StringFromCLSID [OLE32.151]
    634643 * Converts a GUID into the respective string representation.
    635644 * The target string is allocated using the OLE IMalloc.
    636645 * RETURNS
    637  *  the string representation and HRESULT
     646 *      the string representation and HRESULT
    638647 */
    639648HRESULT WINAPI StringFromCLSID(
    640649        REFCLSID id,            /* [in] the GUID to be converted */
    641     LPOLESTR *idstr /* [out] a pointer to a to-be-allocated pointer pointing to the resulting string */
     650        LPOLESTR *idstr /* [out] a pointer to a to-be-allocated pointer pointing to the resulting string */
    642651) {
    643     char            buf[80];
    644     HRESULT       ret;
    645     LPMALLOC    mllc;
    646 
    647     if ((ret=CoGetMalloc(0,&mllc)))
    648         return ret;
    649 
    650     ret=WINE_StringFromCLSID(id,buf);
    651     if (!ret) {
     652        char            buf[80];
     653        HRESULT       ret;
     654        LPMALLOC        mllc;
     655
     656        if ((ret=CoGetMalloc(0,&mllc)))
     657                return ret;
     658
     659        ret=WINE_StringFromCLSID(id,buf);
     660        if (!ret) {
    652661            DWORD len = MultiByteToWideChar( CP_ACP, 0, buf, -1, NULL, 0 );
    653662            *idstr = IMalloc_Alloc( mllc, len * sizeof(WCHAR) );
    654663            MultiByteToWideChar( CP_ACP, 0, buf, -1, *idstr, len );
    655     }
    656     return ret;
    657 }
    658 
    659 /******************************************************************************
    660  *      StringFromGUID2 [COMPOBJ.76] [OLE32.152]
     664        }
     665        return ret;
     666}
     667
     668/******************************************************************************
     669 *              StringFromGUID2 [COMPOBJ.76] [OLE32.152]
    661670 *
    662671 * Converts a global unique identifier into a string of an API-
     
    664673 *
    665674 * RETURNS
    666  *  The (UNICODE) string representation of the GUID in 'str'
    667  *  The length of the resulting string, 0 if there was any problem.
     675 *      The (UNICODE) string representation of the GUID in 'str'
     676 *      The length of the resulting string, 0 if there was any problem.
    668677 */
    669678INT WINAPI
    670679StringFromGUID2(REFGUID id, LPOLESTR str, INT cmax)
    671680{
    672   char      xguid[80];
     681  char          xguid[80];
    673682
    674683  if (WINE_StringFromCLSID(id,xguid))
    675     return 0;
     684        return 0;
    676685  return MultiByteToWideChar( CP_ACP, 0, xguid, -1, str, cmax );
    677686}
     
    730739
    731740/******************************************************************************
    732  *      CLSIDFromProgID16   [COMPOBJ.61]
     741 *              CLSIDFromProgID16       [COMPOBJ.61]
    733742 * Converts a program id into the respective GUID. (By using a registry lookup)
    734743 * RETURNS
    735  *  riid associated with the progid
     744 *      riid associated with the progid
    736745 */
    737746HRESULT WINAPI CLSIDFromProgID16(
    738     LPCOLESTR16 progid, /* [in] program id as found in registry */
    739     LPCLSID riid        /* [out] associated CLSID */
     747        LPCOLESTR16 progid,     /* [in] program id as found in registry */
     748        LPCLSID riid            /* [out] associated CLSID */
    740749) {
    741     char    *buf,buf2[80];
    742     DWORD   buf2len;
    743     HRESULT err;
    744     HKEY    xhkey;
    745 
    746     buf = HeapAlloc(GetProcessHeap(),0,strlen(progid)+8);
    747     sprintf(buf,"%s\\CLSID",progid);
    748     if ((err=RegOpenKeyA(HKEY_CLASSES_ROOT,buf,&xhkey))) {
    749         HeapFree(GetProcessHeap(),0,buf);
     750        char    *buf,buf2[80];
     751        DWORD   buf2len;
     752        HRESULT err;
     753        HKEY    xhkey;
     754
     755        buf = HeapAlloc(GetProcessHeap(),0,strlen(progid)+8);
     756        sprintf(buf,"%s\\CLSID",progid);
     757        if ((err=RegOpenKeyA(HKEY_CLASSES_ROOT,buf,&xhkey))) {
     758                HeapFree(GetProcessHeap(),0,buf);
    750759                return CO_E_CLASSSTRING;
    751     }
    752     HeapFree(GetProcessHeap(),0,buf);
    753     buf2len = sizeof(buf2);
    754     if ((err=RegQueryValueA(xhkey,NULL,buf2,&buf2len))) {
    755         RegCloseKey(xhkey);
     760        }
     761        HeapFree(GetProcessHeap(),0,buf);
     762        buf2len = sizeof(buf2);
     763        if ((err=RegQueryValueA(xhkey,NULL,buf2,&buf2len))) {
     764                RegCloseKey(xhkey);
    756765                return CO_E_CLASSSTRING;
    757     }
    758     RegCloseKey(xhkey);
    759     return CLSIDFromString16(buf2,riid);
    760 }
    761 
    762 /******************************************************************************
    763  *      CLSIDFromProgID [OLE32.2]
     766        }
     767        RegCloseKey(xhkey);
     768        return CLSIDFromString16(buf2,riid);
     769}
     770
     771/******************************************************************************
     772 *              CLSIDFromProgID [OLE32.2]
    764773 * Converts a program id into the respective GUID. (By using a registry lookup)
    765774 * RETURNS
    766  *  riid associated with the progid
     775 *      riid associated with the progid
    767776 */
    768777HRESULT WINAPI CLSIDFromProgID(
    769     LPCOLESTR progid,   /* [in] program id as found in registry */
    770     LPCLSID riid        /* [out] associated CLSID */
     778        LPCOLESTR progid,       /* [in] program id as found in registry */
     779        LPCLSID riid            /* [out] associated CLSID */
    771780) {
    772     LPOLESTR16 pid = HEAP_strdupWtoA(GetProcessHeap(),0,progid);
    773     HRESULT       ret = CLSIDFromProgID16(pid,riid);
    774 
    775     HeapFree(GetProcessHeap(),0,pid);
    776     return ret;
     781        LPOLESTR16 pid = HEAP_strdupWtoA(GetProcessHeap(),0,progid);
     782        HRESULT       ret = CLSIDFromProgID16(pid,riid);
     783
     784        HeapFree(GetProcessHeap(),0,pid);
     785        return ret;
    777786}
    778787
     
    783792 *
    784793 * This function returns the CLSID of the DLL that implements the proxy and stub
    785  * for the specified interface.
    786  *
    787  * It determines this by searching the
     794 * for the specified interface. 
     795 *
     796 * It determines this by searching the 
    788797 * HKEY_CLASSES_ROOT\Interface\{string form of riid}\ProxyStubClsid32 in the registry
    789798 * and any interface id registered by CoRegisterPSClsid within the current process.
    790  *
     799 * 
    791800 * FIXME: We only search the registry, not ids registered with CoRegisterPSClsid.
    792801 */
     
    823832
    824833    /* ... Once we have the key, query the registry to get the
    825        value of CLSID as a string, and convert it into a
     834       value of CLSID as a string, and convert it into a 
    826835       proper CLSID structure to be passed back to the app */
    827836    buf2len = sizeof(buf2);
     
    847856
    848857/***********************************************************************
    849  *      WriteClassStm
     858 *              WriteClassStm
    850859 *
    851860 * This function write a CLSID on stream
     
    862871
    863872/***********************************************************************
    864  *      ReadClassStm
     873 *              ReadClassStm
    865874 *
    866875 * This function read a CLSID from a stream
     
    870879    ULONG nbByte;
    871880    HRESULT res;
    872 
     881   
    873882    TRACE("(%p,%p)\n",pStm,rclsid);
    874883
    875884    if (rclsid==NULL)
    876885        return E_INVALIDARG;
    877 
     886   
    878887    res = IStream_Read(pStm,(void*)rclsid,sizeof(CLSID),&nbByte);
    879888
    880889    if (FAILED(res))
    881890        return res;
    882 
     891   
    883892    if (nbByte != sizeof(CLSID))
    884893        return S_FALSE;
     
    893902 */
    894903HRESULT WINAPI LookupETask16(HTASK16 *hTask,LPVOID p) {
    895     FIXME("(%p,%p),stub!\n",hTask,p);
    896     if ((*hTask = GetCurrentTask()) == hETask) {
    897         memcpy(p, Table_ETask, sizeof(Table_ETask));
    898     }
    899     return 0;
     904        FIXME("(%p,%p),stub!\n",hTask,p);
     905        if ((*hTask = GetCurrentTask()) == hETask) {
     906                memcpy(p, Table_ETask, sizeof(Table_ETask));
     907        }
     908        return 0;
    900909}
    901910
     
    906915HRESULT WINAPI SetETask16(HTASK16 hTask, LPVOID p) {
    907916        FIXME("(%04x,%p),stub!\n",hTask,p);
    908     hETask = hTask;
    909     return 0;
     917        hETask = hTask;
     918        return 0;
    910919}
    911920
     
    915924 */
    916925HRESULT WINAPI CallObjectInWOW(LPVOID p1,LPVOID p2) {
    917     FIXME("(%p,%p),stub!\n",p1,p2);
    918     return 0;
    919 }
    920 
    921 /******************************************************************************
    922  *      CoRegisterClassObject16 [COMPOBJ.5]
     926        FIXME("(%p,%p),stub!\n",p1,p2);
     927        return 0;
     928}
     929
     930/******************************************************************************
     931 *              CoRegisterClassObject16 [COMPOBJ.5]
    923932 *
    924933 * Don't know where it registers it ...
    925934 */
    926935HRESULT WINAPI CoRegisterClassObject16(
    927     REFCLSID rclsid,
    928     LPUNKNOWN pUnk,
    929     DWORD dwClsContext, /* [in] CLSCTX flags indicating the context in which to run the executable */
    930     DWORD flags,        /* [in] REGCLS flags indicating how connections are made */
    931     LPDWORD lpdwRegister
     936        REFCLSID rclsid,
     937        LPUNKNOWN pUnk,
     938        DWORD dwClsContext, /* [in] CLSCTX flags indicating the context in which to run the executable */
     939        DWORD flags,        /* [in] REGCLS flags indicating how connections are made */
     940        LPDWORD lpdwRegister
    932941) {
    933     char    buf[80];
    934 
    935     WINE_StringFromCLSID(rclsid,buf);
    936 
    937     FIXME("(%s,%p,0x%08lx,0x%08lx,%p),stub\n",
    938         buf,pUnk,dwClsContext,flags,lpdwRegister
    939     );
    940     return 0;
     942        char    buf[80];
     943
     944        WINE_StringFromCLSID(rclsid,buf);
     945
     946        FIXME("(%s,%p,0x%08lx,0x%08lx,%p),stub\n",
     947                buf,pUnk,dwClsContext,flags,lpdwRegister
     948        );
     949        return 0;
    941950}
    942951
     
    957966 * COM_GetRegisteredClassObject
    958967 *
    959  * This internal method is used to scan the registered class list to
     968 * This internal method is used to scan the registered class list to 
    960969 * find a class object.
    961970 *
    962  * Params:
     971 * Params: 
    963972 *   rclsid        Class ID of the class to find.
    964973 *   dwClsContext  Class context to match.
     
    968977 */
    969978static HRESULT COM_GetRegisteredClassObject(
    970     REFCLSID    rclsid,
    971     DWORD       dwClsContext,
    972     LPUNKNOWN*  ppUnk)
     979        REFCLSID    rclsid,
     980        DWORD       dwClsContext,
     981        LPUNKNOWN*  ppUnk)
    973982{
    974983  RegisteredClass* curClass;
     
    10191028
    10201029/******************************************************************************
    1021  *      CoRegisterClassObject   [OLE32.36]
     1030 *              CoRegisterClassObject   [OLE32.36]
    10221031 *
    10231032 * This method will register the class object for a given class ID.
     
    10261035 */
    10271036HRESULT WINAPI CoRegisterClassObject(
    1028     REFCLSID rclsid,
    1029     LPUNKNOWN pUnk,
    1030     DWORD dwClsContext, /* [in] CLSCTX flags indicating the context in which to run the executable */
    1031     DWORD flags,        /* [in] REGCLS flags indicating how connections are made */
    1032     LPDWORD lpdwRegister
    1033 )
     1037        REFCLSID rclsid,
     1038        LPUNKNOWN pUnk,
     1039        DWORD dwClsContext, /* [in] CLSCTX flags indicating the context in which to run the executable */
     1040        DWORD flags,        /* [in] REGCLS flags indicating how connections are made */
     1041        LPDWORD lpdwRegister
     1042) 
    10341043{
    10351044  RegisteredClass* newClass;
     
    10411050
    10421051  TRACE("(%s,%p,0x%08lx,0x%08lx,%p)\n",
    1043     buf,pUnk,dwClsContext,flags,lpdwRegister);
     1052        buf,pUnk,dwClsContext,flags,lpdwRegister);
    10441053
    10451054  /*
     
    10721081    return CO_E_OBJISREG;
    10731082  }
    1074 
     1083   
    10751084  /*
    10761085   * If it is not registered, we must create a new entry for this class and
     
    11031112   */
    11041113  *lpdwRegister = newClass->dwCookie;
    1105 
     1114   
    11061115  /*
    11071116   * We're successful Yippee!
     
    11181127 */
    11191128HRESULT WINAPI CoRevokeClassObject(
    1120         DWORD dwRegister)
     1129        DWORD dwRegister) 
    11211130{
    11221131  RegisteredClass** prevClassLink;
     
    11761185    REFIID iid, LPVOID *ppv
    11771186) {
    1178     LPUNKNOWN   regClassObject;
    1179     HRESULT hres = E_UNEXPECTED;
    1180     char    xclsid[80];
     1187    LPUNKNOWN   regClassObject;
     1188    HRESULT     hres = E_UNEXPECTED;
     1189    char        xclsid[80];
    11811190    WCHAR dllName[MAX_PATH+1];
    11821191    DWORD dllNameLen = sizeof(dllName);
    11831192    HINSTANCE hLibrary;
    11841193#ifdef __WIN32OS2__
    1185     typedef HRESULT (* CALLBACK DllGetClassObjectFunc)(REFCLSID clsid,
    1186                  REFIID iid, LPVOID *ppv);
     1194    typedef HRESULT (* CALLBACK DllGetClassObjectFunc)(REFCLSID clsid, 
     1195                             REFIID iid, LPVOID *ppv);
    11871196#else
    1188     typedef HRESULT CALLBACK (*DllGetClassObjectFunc)(REFCLSID clsid,
    1189                  REFIID iid, LPVOID *ppv);
     1197    typedef HRESULT CALLBACK (*DllGetClassObjectFunc)(REFCLSID clsid, 
     1198                             REFIID iid, LPVOID *ppv);
    11901199#endif
    11911200    DllGetClassObjectFunc DllGetClassObject;
     
    11941203
    11951204    TRACE("\n\tCLSID:\t%s,\n\tIID:\t%s\n",
    1196     debugstr_guid(rclsid),
    1197     debugstr_guid(iid)
     1205        debugstr_guid(rclsid),
     1206        debugstr_guid(iid)
    11981207    );
    11991208
    12001209    if (pServerInfo) {
    1201     FIXME("\tpServerInfo: name=%s\n",debugstr_w(pServerInfo->pwszName));
    1202     FIXME("\t\tpAuthInfo=%p\n",pServerInfo->pAuthInfo);
     1210        FIXME("\tpServerInfo: name=%s\n",debugstr_w(pServerInfo->pwszName));
     1211        FIXME("\t\tpAuthInfo=%p\n",pServerInfo->pAuthInfo);
    12031212    }
    12041213
    12051214    /*
    1206      * First, try and see if we can't match the class ID with one of the
     1215     * First, try and see if we can't match the class ID with one of the 
    12071216     * registered classes.
    12081217     */
     
    12291238    ){
    12301239        FIXME("%s %s not supported!\n",
    1231         (dwClsContext&CLSCTX_LOCAL_SERVER)?"CLSCTX_LOCAL_SERVER":"",
    1232         (dwClsContext&CLSCTX_REMOTE_SERVER)?"CLSCTX_REMOTE_SERVER":""
    1233     );
    1234     return E_ACCESSDENIED;
     1240                (dwClsContext&CLSCTX_LOCAL_SERVER)?"CLSCTX_LOCAL_SERVER":"",
     1241                (dwClsContext&CLSCTX_REMOTE_SERVER)?"CLSCTX_REMOTE_SERVER":""
     1242        );
     1243        return E_ACCESSDENIED;
    12351244    }
    12361245
    12371246    if ((CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER) & dwClsContext) {
    12381247        HKEY key;
    1239     char buf[200];
    1240 
    1241     sprintf(buf,"CLSID\\%s\\InprocServer32",xclsid);
     1248        char buf[200];
     1249
     1250        sprintf(buf,"CLSID\\%s\\InprocServer32",xclsid);
    12421251        hres = RegOpenKeyExA(HKEY_CLASSES_ROOT, buf, 0, KEY_READ, &key);
    12431252
    1244     if (hres != ERROR_SUCCESS) {
    1245         return REGDB_E_CLASSNOTREG;
    1246     }
    1247 
    1248     memset(dllName,0,sizeof(dllName));
    1249     hres= RegQueryValueExW(key,NULL,NULL,NULL,(LPBYTE)dllName,&dllNameLen);
    1250     if (hres)
    1251         return REGDB_E_CLASSNOTREG; /* FIXME: check retval */
    1252     RegCloseKey(key);
    1253     TRACE("found InprocServer32 dll %s\n", debugstr_w(dllName));
    1254 
    1255     /* open dll, call DllGetClassObject */
    1256     hLibrary = CoLoadLibrary(dllName, TRUE);
    1257     if (hLibrary == 0) {
    1258         FIXME("couldn't load InprocServer32 dll %s\n", debugstr_w(dllName));
    1259         return E_ACCESSDENIED; /* or should this be CO_E_DLLNOTFOUND? */
    1260     }
    1261     DllGetClassObject = (DllGetClassObjectFunc)GetProcAddress(hLibrary, "DllGetClassObject");
    1262     if (!DllGetClassObject) {
    1263         /* not sure if this should be called here CoFreeLibrary(hLibrary);*/
    1264         FIXME("couldn't find function DllGetClassObject in %s\n", debugstr_w(dllName));
    1265         return E_ACCESSDENIED;
    1266     }
    1267 
    1268     /*
    1269     * Ask the DLL for its class object. (there was a note here about class
    1270     * factories but this is good.
    1271     */
    1272     return DllGetClassObject(rclsid, iid, ppv);
     1253        if (hres != ERROR_SUCCESS) {
     1254            return REGDB_E_CLASSNOTREG;
     1255        }
     1256
     1257        memset(dllName,0,sizeof(dllName));
     1258        hres= RegQueryValueExW(key,NULL,NULL,NULL,(LPBYTE)dllName,&dllNameLen);
     1259        if (hres)
     1260                return REGDB_E_CLASSNOTREG; /* FIXME: check retval */
     1261        RegCloseKey(key);
     1262        TRACE("found InprocServer32 dll %s\n", debugstr_w(dllName));
     1263
     1264        /* open dll, call DllGetClassObject */
     1265        hLibrary = CoLoadLibrary(dllName, TRUE);
     1266        if (hLibrary == 0) {
     1267            FIXME("couldn't load InprocServer32 dll %s\n", debugstr_w(dllName));
     1268            return E_ACCESSDENIED; /* or should this be CO_E_DLLNOTFOUND? */
     1269        }
     1270        DllGetClassObject = (DllGetClassObjectFunc)GetProcAddress(hLibrary, "DllGetClassObject");
     1271        if (!DllGetClassObject) {
     1272            /* not sure if this should be called here CoFreeLibrary(hLibrary);*/
     1273            FIXME("couldn't find function DllGetClassObject in %s\n", debugstr_w(dllName));
     1274            return E_ACCESSDENIED;
     1275        }
     1276
     1277        /*
     1278        * Ask the DLL for its class object. (there was a note here about class
     1279        * factories but this is good.
     1280        */
     1281        return DllGetClassObject(rclsid, iid, ppv);
    12731282    }
    12741283    return hres;
     
    12821291HRESULT WINAPI CoResumeClassObjects(void)
    12831292{
    1284     FIXME("\n");
    1285     return S_OK;
     1293        FIXME("\n");
     1294        return S_OK;
    12861295}
    12871296
     
    13171326       pattern in the registry. this case is not frequently used ! so I present only the psodocode for
    13181327       this case
    1319 
     1328       
    13201329     for(i=0;i<nFileTypes;i++)
    13211330
     
    13501359    length=lstrlenW(absFile);
    13511360    for(i=length-1; ( (i>=0) && (extention[i]=absFile[i]) );i--);
    1352 
     1361       
    13531362    /* get the progId associated to the extension */
    13541363    progId=CoTaskMemAlloc(sizeProgId);
     
    13781387#ifndef __WIN32OS2__
    13791388/******************************************************************************
    1380  *      CoRegisterMessageFilter16   [COMPOBJ.27]
     1389 *              CoRegisterMessageFilter16       [COMPOBJ.27]
    13811390 */
    13821391HRESULT WINAPI CoRegisterMessageFilter16(
    1383     LPMESSAGEFILTER lpMessageFilter,
    1384     LPMESSAGEFILTER *lplpMessageFilter
     1392        LPMESSAGEFILTER lpMessageFilter,
     1393        LPMESSAGEFILTER *lplpMessageFilter
    13851394) {
    1386     FIXME("(%p,%p),stub!\n",lpMessageFilter,lplpMessageFilter);
    1387     return 0;
     1395        FIXME("(%p,%p),stub!\n",lpMessageFilter,lplpMessageFilter);
     1396        return 0;
    13881397}
    13891398#endif
     
    13931402 */
    13941403HRESULT WINAPI CoCreateInstance(
    1395     REFCLSID rclsid,
    1396     LPUNKNOWN pUnkOuter,
    1397     DWORD dwClsContext,
    1398     REFIID iid,
    1399     LPVOID *ppv)
    1400 {
    1401     HRESULT hres;
    1402     LPCLASSFACTORY lpclf = 0;
     1404        REFCLSID rclsid,
     1405        LPUNKNOWN pUnkOuter,
     1406        DWORD dwClsContext,
     1407        REFIID iid,
     1408        LPVOID *ppv)
     1409{
     1410        HRESULT hres;
     1411        LPCLASSFACTORY lpclf = 0;
    14031412
    14041413  /*
     
    14121421   */
    14131422  *ppv = 0;
    1414 
     1423 
    14151424  /*
    14161425   * Get a class factory to construct the object we want.
    14171426   */
    14181427  hres = CoGetClassObject(rclsid,
    1419               dwClsContext,
    1420               NULL,
    1421               &IID_IClassFactory,
    1422               (LPVOID)&lpclf);
     1428                          dwClsContext,
     1429                          NULL,
     1430                          &IID_IClassFactory,
     1431                          (LPVOID)&lpclf);
    14231432
    14241433  if (FAILED(hres)) {
     
    14301439   * Create the object and don't forget to release the factory
    14311440   */
    1432     hres = IClassFactory_CreateInstance(lpclf, pUnkOuter, iid, ppv);
    1433     IClassFactory_Release(lpclf);
    1434 
    1435     return hres;
     1441        hres = IClassFactory_CreateInstance(lpclf, pUnkOuter, iid, ppv);
     1442        IClassFactory_Release(lpclf);
     1443
     1444        return hres;
    14361445}
    14371446
     
    14401449 */
    14411450HRESULT WINAPI CoCreateInstanceEx(
    1442   REFCLSID      rclsid,
     1451  REFCLSID      rclsid, 
    14431452  LPUNKNOWN     pUnkOuter,
    1444   DWORD         dwClsContext,
     1453  DWORD         dwClsContext, 
    14451454  COSERVERINFO* pServerInfo,
    14461455  ULONG         cmq,
     
    14731482   * Get the object and get its IUnknown pointer.
    14741483   */
    1475   hr = CoCreateInstance(rclsid,
    1476             pUnkOuter,
    1477             dwClsContext,
    1478             &IID_IUnknown,
    1479             (VOID**)&pUnk);
     1484  hr = CoCreateInstance(rclsid, 
     1485                        pUnkOuter,
     1486                        dwClsContext,
     1487                        &IID_IUnknown,
     1488                        (VOID**)&pUnk);
    14801489
    14811490  if (hr)
     
    14881497  {
    14891498    pResults[index].hr = IUnknown_QueryInterface(pUnk,
    1490                         pResults[index].pIID,
    1491                         (VOID**)&(pResults[index].pItf));
     1499                                                pResults[index].pIID,
     1500                                                (VOID**)&(pResults[index].pItf));
    14921501
    14931502    if (pResults[index].hr == S_OK)
     
    15201529    prev = NULL;
    15211530    for (ptr = openDllList; ptr != NULL; ptr=ptr->next) {
    1522     if (ptr->hLibrary == hLibrary) {
    1523         break;
    1524     }
    1525     prev = ptr;
     1531        if (ptr->hLibrary == hLibrary) {
     1532            break;
     1533        }
     1534        prev = ptr;
    15261535    }
    15271536
    15281537    if (ptr == NULL) {
    1529     /* shouldn't happen if user passed in a valid hLibrary */
    1530     return;
     1538        /* shouldn't happen if user passed in a valid hLibrary */
     1539        return;
    15311540    }
    15321541    /* assert: ptr points to the library entry to free */
     
    15351544    FreeLibrary(hLibrary);
    15361545    if (ptr == openDllList) {
    1537     tmp = openDllList->next;
    1538     HeapFree(GetProcessHeap(), 0, openDllList);
    1539     openDllList = tmp;
     1546        tmp = openDllList->next;
     1547        HeapFree(GetProcessHeap(), 0, openDllList);
     1548        openDllList = tmp;
    15401549    } else {
    1541     tmp = ptr->next;
    1542     HeapFree(GetProcessHeap(), 0, ptr);
    1543     prev->next = tmp;
     1550        tmp = ptr->next;
     1551        HeapFree(GetProcessHeap(), 0, ptr);
     1552        prev->next = tmp;
    15441553    }
    15451554
     
    15551564
    15561565    for (ptr = openDllList; ptr != NULL; ) {
    1557     tmp=ptr->next;
    1558     CoFreeLibrary(ptr->hLibrary);
    1559     ptr = tmp;
     1566        tmp=ptr->next;
     1567        CoFreeLibrary(ptr->hLibrary);
     1568        ptr = tmp;
    15601569    }
    15611570}
     
    15731582
    15741583    for (ptr = openDllList; ptr != NULL; ) {
    1575     DllCanUnloadNow = (DllCanUnloadNowFunc)
    1576         GetProcAddress(ptr->hLibrary, "DllCanUnloadNow");
    1577 
    1578     if ( (DllCanUnloadNow != NULL) &&
    1579          (DllCanUnloadNow() == S_OK) ) {
    1580         tmp=ptr->next;
    1581         CoFreeLibrary(ptr->hLibrary);
    1582         ptr = tmp;
    1583     } else {
    1584         ptr=ptr->next;
    1585     }
     1584        DllCanUnloadNow = (DllCanUnloadNowFunc)
     1585            GetProcAddress(ptr->hLibrary, "DllCanUnloadNow");
     1586       
     1587        if ( (DllCanUnloadNow != NULL) &&
     1588             (DllCanUnloadNow() == S_OK) ) {
     1589            tmp=ptr->next;
     1590            CoFreeLibrary(ptr->hLibrary);
     1591            ptr = tmp;
     1592        } else {
     1593            ptr=ptr->next;
     1594        }
    15861595    }
    15871596}
     
    15901599 *           CoFileTimeNow [COMPOBJ.82, OLE32.10]
    15911600 * RETURNS
    1592  *  the current system time in lpFileTime
     1601 *      the current system time in lpFileTime
    15931602 */
    15941603HRESULT WINAPI CoFileTimeNow( FILETIME *lpFileTime ) /* [out] the current time */
     
    16011610 *           CoTaskMemAlloc (OLE32.43)
    16021611 * RETURNS
    1603  *  pointer to newly allocated block
     1612 *      pointer to newly allocated block
    16041613 */
    16051614LPVOID WINAPI CoTaskMemAlloc(
    1606     ULONG size  /* [in] size of memoryblock to be allocated */
     1615        ULONG size      /* [in] size of memoryblock to be allocated */
    16071616) {
    1608     LPMALLOC    lpmalloc;
    1609     HRESULT ret = CoGetMalloc(0,&lpmalloc);
    1610 
    1611     if (FAILED(ret))
    1612     return NULL;
     1617    LPMALLOC    lpmalloc;
     1618    HRESULT     ret = CoGetMalloc(0,&lpmalloc);
     1619
     1620    if (FAILED(ret)) 
     1621        return NULL;
    16131622
    16141623    return IMalloc_Alloc(lpmalloc,size);
     
    16181627 */
    16191628VOID WINAPI CoTaskMemFree(
    1620     LPVOID ptr  /* [in] pointer to be freed */
     1629        LPVOID ptr      /* [in] pointer to be freed */
    16211630) {
    1622     LPMALLOC    lpmalloc;
    1623     HRESULT ret = CoGetMalloc(0,&lpmalloc);
    1624 
    1625     if (FAILED(ret))
     1631    LPMALLOC    lpmalloc;
     1632    HRESULT     ret = CoGetMalloc(0,&lpmalloc);
     1633
     1634    if (FAILED(ret)) 
    16261635      return;
    16271636
     
    16321641 *           CoTaskMemRealloc (OLE32.45)
    16331642 * RETURNS
    1634  *  pointer to newly allocated block
     1643 *      pointer to newly allocated block
    16351644 */
    16361645LPVOID WINAPI CoTaskMemRealloc(
    16371646  LPVOID pvOld,
    1638   ULONG  size)  /* [in] size of memoryblock to be allocated */
     1647  ULONG  size)  /* [in] size of memoryblock to be allocated */
    16391648{
    16401649  LPMALLOC lpmalloc;
    16411650  HRESULT  ret = CoGetMalloc(0,&lpmalloc);
    1642 
    1643   if (FAILED(ret))
     1651 
     1652  if (FAILED(ret)) 
    16441653    return NULL;
    16451654
     
    16551664    OpenDll *ptr;
    16561665    OpenDll *tmp;
    1657 
     1666 
    16581667    TRACE("(%s, %d)\n", debugstr_w(lpszLibName), bAutoFree);
    16591668
     
    16611670
    16621671    if (!bAutoFree)
    1663     return hLibrary;
     1672        return hLibrary;
    16641673
    16651674    if (openDllList == NULL) {
    16661675        /* empty list -- add first node */
    16671676        openDllList = (OpenDll*)HeapAlloc(GetProcessHeap(),0, sizeof(OpenDll));
    1668     openDllList->hLibrary=hLibrary;
    1669     openDllList->next = NULL;
     1677        openDllList->hLibrary=hLibrary;
     1678        openDllList->next = NULL;
    16701679    } else {
    16711680        /* search for this dll */
    16721681        int found = FALSE;
    16731682        for (ptr = openDllList; ptr->next != NULL; ptr=ptr->next) {
    1674         if (ptr->hLibrary == hLibrary) {
    1675             found = TRUE;
    1676         break;
     1683            if (ptr->hLibrary == hLibrary) {
     1684                found = TRUE;
     1685                break;
     1686            }
    16771687        }
    1678         }
    1679     if (!found) {
    1680         /* dll not found, add it */
    1681         tmp = openDllList;
    1682         openDllList = (OpenDll*)HeapAlloc(GetProcessHeap(),0, sizeof(OpenDll));
    1683         openDllList->hLibrary = hLibrary;
    1684         openDllList->next = tmp;
    1685     }
    1686     }
    1687 
     1688        if (!found) {
     1689            /* dll not found, add it */
     1690            tmp = openDllList;
     1691            openDllList = (OpenDll*)HeapAlloc(GetProcessHeap(),0, sizeof(OpenDll));
     1692            openDllList->hLibrary = hLibrary;
     1693            openDllList->next = tmp;
     1694        }
     1695    }
     1696     
    16881697    return hLibrary;
    16891698}
     
    16991708#ifndef __WIN32OS2__
    17001709/******************************************************************************
    1701  *      CoLockObjectExternal16  [COMPOBJ.63]
     1710 *              CoLockObjectExternal16  [COMPOBJ.63]
    17021711 */
    17031712HRESULT WINAPI CoLockObjectExternal16(
    1704     LPUNKNOWN pUnk,     /* [in] object to be locked */
    1705     BOOL16 fLock,       /* [in] do lock */
    1706     BOOL16 fLastUnlockReleases  /* [in] ? */
     1713    LPUNKNOWN pUnk,             /* [in] object to be locked */
     1714    BOOL16 fLock,               /* [in] do lock */
     1715    BOOL16 fLastUnlockReleases  /* [in] ? */
    17071716) {
    17081717    FIXME("(%p,%d,%d),stub!\n",pUnk,fLock,fLastUnlockReleases);
     
    17121721
    17131722/******************************************************************************
    1714  *      CoLockObjectExternal    [OLE32.31]
     1723 *              CoLockObjectExternal    [OLE32.31]
    17151724 */
    17161725HRESULT WINAPI CoLockObjectExternal(
    1717     LPUNKNOWN pUnk,     /* [in] object to be locked */
    1718     BOOL fLock,     /* [in] do lock */
     1726    LPUNKNOWN pUnk,             /* [in] object to be locked */
     1727    BOOL fLock,         /* [in] do lock */
    17191728    BOOL fLastUnlockReleases) /* [in] unlock all */
    17201729{
    17211730
    1722   if (fLock)
     1731  if (fLock) 
    17231732  {
    1724     /*
     1733    /* 
    17251734     * Increment the external lock coutner, COM_ExternalLockAddRef also
    17261735     * increment the object's internal lock counter.
    17271736     */
    1728     COM_ExternalLockAddRef( pUnk);
     1737    COM_ExternalLockAddRef( pUnk); 
    17291738  }
    17301739  else
    17311740  {
    1732     /*
     1741    /* 
    17331742     * Decrement the external lock coutner, COM_ExternalLockRelease also
    17341743     * decrement the object's internal lock counter.
     
    17661775{
    17671776   FIXME ("(%p %p): stub\n", punkOuter, ppunkMarshal);
    1768 
     1777   
    17691778   return S_OK;
    17701779}
     
    17751784 */
    17761785HRESULT WINAPI OLE32_DllGetClassObject(REFCLSID rclsid, REFIID iid,LPVOID *ppv)
    1777 {
    1778     FIXME("\n\tCLSID:\t%s,\n\tIID:\t%s\n",debugstr_guid(rclsid),debugstr_guid(iid));
    1779     *ppv = NULL;
    1780     return CLASS_E_CLASSNOTAVAILABLE;
     1786{       
     1787        FIXME("\n\tCLSID:\t%s,\n\tIID:\t%s\n",debugstr_guid(rclsid),debugstr_guid(iid));
     1788        *ppv = NULL;
     1789        return CLASS_E_CLASSNOTAVAILABLE;
    17811790}
    17821791
     
    17851794 * COM_RevokeAllClasses
    17861795 *
    1787  * This method is called when the COM libraries are uninitialized to
     1796 * This method is called when the COM libraries are uninitialized to 
    17881797 * release all the references to the class objects registered with
    17891798 * the library
     
    18021811
    18031812/****************************************************************************
    1804  * Public - Method that increments the count for a IUnknown* in the linked
     1813 * Public - Method that increments the count for a IUnknown* in the linked 
    18051814 * list.  The item is inserted if not already in the list.
    18061815 */
     
    18231832   * Add an internal lock to the object
    18241833   */
    1825   IUnknown_AddRef(pUnk);
     1834  IUnknown_AddRef(pUnk); 
    18261835}
    18271836
    18281837/****************************************************************************
    1829  * Public - Method that decrements the count for a IUnknown* in the linked
     1838 * Public - Method that decrements the count for a IUnknown* in the linked 
    18301839 * list.  The item is removed from the list if its count end up at zero or if
    18311840 * bRelAll is TRUE.
     
    18441853      IUnknown_Release(pUnk);     /* release local locks as well */
    18451854
    1846       if ( bRelAll == FALSE )
     1855      if ( bRelAll == FALSE ) 
    18471856        break;  /* perform single release */
    18481857
    1849     } while ( externalLock->uRefCount > 0 );
     1858    } while ( externalLock->uRefCount > 0 ); 
    18501859
    18511860    if ( externalLock->uRefCount == 0 )  /* get rid of the list entry */
     
    18651874    COM_ExternalLockDelete(head);     /* get rid of the head stuff       */
    18661875
    1867     head = elList.head;               /* get the new head...             */
     1876    head = elList.head;               /* get the new head...             */ 
    18681877  }
    18691878}
     
    18811890  {
    18821891      DPRINTF( "\t%p with %lu references count.\n", current->pUnk, current->uRefCount);
    1883 
    1884     /* Skip to the next item */
     1892 
     1893    /* Skip to the next item */ 
    18851894    current = current->next;
    1886   }
     1895  } 
    18871896
    18881897}
     
    19041913  IUnknown         *pUnk)
    19051914{
    1906   if ( element == EL_END_OF_LIST )
     1915  if ( element == EL_END_OF_LIST ) 
    19071916    return EL_NOT_FOUND;
    19081917
     
    19101919    return element;
    19111920
    1912   else                                 /* Not the right guy, keep on looking */
     1921  else                                 /* Not the right guy, keep on looking */ 
    19131922    return COM_ExternalLockLocate( element->next, pUnk);
    19141923}
     
    19301939  if (newLock!=NULL)
    19311940  {
    1932     if ( elList.head == EL_END_OF_LIST )
     1941    if ( elList.head == EL_END_OF_LIST ) 
    19331942    {
    19341943      elList.head = newLock;    /* The list is empty */
    19351944    }
    1936     else
     1945    else 
    19371946    {
    1938       /*
     1947      /* 
    19391948       * insert does it at the head
    19401949       */
     
    19441953
    19451954    /*
    1946      * Set new list item data member
     1955     * Set new list item data member 
    19471956     */
    19481957    newLock->pUnk      = pUnk;
    19491958    newLock->uRefCount = 1;
    19501959    newLock->next      = previousHead;
    1951 
     1960   
    19521961    return TRUE;
    19531962  }
     
    19661975  if ( current == itemList )
    19671976  {
    1968     /*
    1969      * this section handles the deletion of the first node
     1977    /* 
     1978     * this section handles the deletion of the first node 
    19701979     */
    19711980    elList.head = itemList->next;
    1972     HeapFree( GetProcessHeap(), 0, itemList);
     1981    HeapFree( GetProcessHeap(), 0, itemList); 
    19731982  }
    19741983  else
    19751984  {
    1976     do
     1985    do 
    19771986    {
    19781987      if ( current->next == itemList )   /* We found the item to free  */
    19791988      {
    19801989        current->next = itemList->next;  /* readjust the list pointers */
    1981 
    1982         HeapFree( GetProcessHeap(), 0, itemList);
    1983         break;
     1990 
     1991        HeapFree( GetProcessHeap(), 0, itemList); 
     1992        break; 
    19841993      }
    1985 
    1986       /* Skip to the next item */
     1994 
     1995      /* Skip to the next item */ 
    19871996      current = current->next;
    1988 
     1997 
    19891998    } while ( current != EL_END_OF_LIST );
    19901999  }
     
    20322041    {
    20332042        res = REGDB_E_CLASSNOTREG;
    2034     goto done;
     2043        goto done;
    20352044    }
    20362045    len = 200;
     
    20402049    {
    20412050        res = REGDB_E_KEYMISSING;
    2042     goto done;
     2051        goto done;
    20432052    }
    20442053    MultiByteToWideChar( CP_ACP, 0, buf, -1, wbuf, sizeof(wbuf)/sizeof(WCHAR) );
     
    20652074    {
    20662075        res = REGDB_E_CLASSNOTREG;
    2067     goto done;
     2076        goto done;
    20682077    }
    20692078    if (RegCreateKeyA(hkey, "AutoConvertTo", &hkeyConvert))
    20702079    {
    20712080        res = REGDB_E_WRITEREGDB;
    2072     goto done;
     2081        goto done;
    20732082    }
    20742083    if (RegSetValueExA(hkeyConvert, NULL, 0,
     
    20762085    {
    20772086        res = REGDB_E_WRITEREGDB;
    2078     goto done;
     2087        goto done;
    20792088    }
    20802089
     
    20922101 *
    20932102 * RETURNS
    2094  *  TRUE if equal
     2103 *      TRUE if equal
    20952104 */
    20962105#undef IsEqualGUID
     
    21112120
    21122121HRESULT WIN32API CLSIDFromStringA(
    2113     LPCSTR      lpsz,       // [in] - ASCII string CLSID
    2114     LPCLSID     pclsid)     // [out] - Binary CLSID
     2122    LPCSTR              lpsz,           // [in] - ASCII string CLSID
     2123    LPCLSID             pclsid)         // [out] - Binary CLSID
    21152124{
    21162125    return CLSIDFromString16(lpsz, pclsid);
  • trunk/src/ole32/compositemoniker.c

    r6648 r6711  
    1 /* $Id: compositemoniker.c,v 1.2 2001-09-05 13:17:08 bird Exp $ */
    21/***************************************************************************************
    3  *                        CompositeMonikers implementation
     2 *                            CompositeMonikers implementation
    43 *
    54 *               Copyright 1999  Noomen Hamza
     
    1817#include "ole2.h"
    1918
     19#ifdef __WIN32OS2__
     20#undef FIXME
     21#undef TRACE
     22#ifdef DEBUG
     23#define TRACE WriteLog("OLE32: %s", __FUNCTION__); WriteLog
     24#define FIXME WriteLog("FIXME OLE32: %s", __FUNCTION__); WriteLog
     25#else
     26#define TRACE 1 ? (void)0 : (void)((int (*)(char *, ...)) NULL)
     27#define FIXME 1 ? (void)0 : (void)((int (*)(char *, ...)) NULL)
     28#endif
     29#endif
     30
    2031DEFAULT_DEBUG_CHANNEL(ole);
    2132
     
    2738    ICOM_VTABLE(IMoniker)*  lpvtbl1;  /* VTable relative to the IMoniker interface.*/
    2839
    29     /* The ROT (RunningObjectTable implementation) uses the IROTData interface to test whether
     40    /* The ROT (RunningObjectTable implementation) uses the IROTData interface to test whether 
    3041     * two monikers are equal. That's whay IROTData interface is implemented by monikers.
    3142     */
     
    187198{
    188199    ICOM_THIS(CompositeMonikerImpl,iface);
    189 
     200 
    190201    TRACE("(%p,%p,%p)\n",This,riid,ppvObject);
    191202
    192203    /* Perform a sanity check on the parameters.*/
    193204    if ( (This==0) || (ppvObject==0) )
    194     return E_INVALIDARG;
    195 
     205        return E_INVALIDARG;
     206 
    196207    /* Initialize the return parameter */
    197208    *ppvObject = 0;
     
    236247    ICOM_THIS(CompositeMonikerImpl,iface);
    237248    ULONG i;
    238 
     249   
    239250    TRACE("(%p)\n",This);
    240251
     
    247258        for (i=0;i<This->tabLastIndex;i++)
    248259            IMoniker_Release(This->tabMoniker[i]);
    249 
     260       
    250261        CompositeMonikerImpl_Destroy(This);
    251262
     
    264275    if (pClassID==NULL)
    265276        return E_POINTER;
    266 
     277           
    267278    *pClassID = CLSID_CompositeMoniker;
    268 
     279       
    269280    return S_OK;
    270281}
     
    293304    CLSID clsid;
    294305    WCHAR string[1]={0};
    295 
    296     ICOM_THIS(CompositeMonikerImpl,iface);
     306   
     307    ICOM_THIS(CompositeMonikerImpl,iface);   
    297308
    298309    TRACE("(%p,%p)\n",iface,pStm);
     
    350361        /* resize the table if needed */
    351362        if (++This->tabLastIndex==This->tabSize){
    352 
     363               
    353364            This->tabSize+=BLOCK_TAB_SIZE;
    354365            This->tabMoniker=HeapReAlloc(GetProcessHeap(),0,This->tabMoniker,This->tabSize*sizeof(IMoniker));
     
    371382    IMoniker *pmk;
    372383    DWORD constant=3;
    373 
     384   
    374385    TRACE("(%p,%p,%d)\n",iface,pStm,fClearDirty);
    375386
     
    446457    IMoniker *tempMk;
    447458    HRESULT res;
    448 
     459   
    449460    TRACE("(%p,%p,%p)\n",This,pmkFirst,pmkRest);
    450461
     
    472483
    473484        IMoniker_Enum(pmkFirst,TRUE,&enumMoniker);
    474 
     485       
    475486        while(IEnumMoniker_Next(enumMoniker,1,&This->tabMoniker[This->tabLastIndex],NULL)==S_OK){
    476487
    477488
    478489            if (++This->tabLastIndex==This->tabSize){
    479 
     490               
    480491                This->tabSize+=BLOCK_TAB_SIZE;
    481492                This->tabMoniker=HeapReAlloc(GetProcessHeap(),0,This->tabMoniker,This->tabSize*sizeof(IMoniker));
     
    492503
    493504    IMoniker_IsSystemMoniker(pmkRest,&mkSys);
    494 
     505   
    495506    if (mkSys!=MKSYS_GENERICCOMPOSITE){
    496507
     
    499510        res=IMoniker_ComposeWith(This->tabMoniker[This->tabLastIndex-1],pmkRest,TRUE,&tempMk);
    500511
    501         if (res==MK_E_NEEDGENERIC){
     512        if (res==MK_E_NEEDGENERIC){ 
    502513
    503514            /* there's no simplification in this case */
     
    508519            IMoniker_AddRef(pmkRest);
    509520        }
    510         else if (tempMk==NULL){
     521        else if (tempMk==NULL){ 
    511522
    512523            /* we have an antimoniker after a simple moniker so we can make a simplification in this case */
     
    526537        /* resize tabMoniker if needed */
    527538        if (This->tabLastIndex==This->tabSize){
    528 
     539               
    529540            This->tabSize+=BLOCK_TAB_SIZE;
    530541
     
    563574
    564575            if (This->tabLastIndex==This->tabSize){
    565 
     576               
    566577                This->tabSize+=BLOCK_TAB_SIZE;
    567578
     
    606617    IMoniker *tempMk,*antiMk,*mostRigthMk;
    607618    IEnumMoniker *enumMoniker;
    608 
     619   
    609620    TRACE("(%p,%p,%p,%p,%p)\n",iface,pbc,pmkToLeft,riid,ppvResult);
    610621
    611622    if (ppvResult==NULL)
    612623        return E_POINTER;
    613 
     624   
    614625    *ppvResult=0;
    615626    /* If pmkToLeft is NULL, this method looks for the moniker in the ROT, and if found, queries the retrieved */
     
    635646        IEnumMoniker_Next(enumMoniker,1,&mostRigthMk,NULL);
    636647        IEnumMoniker_Release(enumMoniker);
    637 
     648       
    638649        res=CreateAntiMoniker(&antiMk);
    639650        res=IMoniker_ComposeWith(iface,antiMk,0,&tempMk);
    640651        IMoniker_Release(antiMk);
    641 
     652       
    642653        res=CompositeMonikerImpl_BindToObject(mostRigthMk,pbc,tempMk,riid,ppvResult);
    643654
     
    670681
    671682    if (pmkToLeft!=NULL){
    672 
     683       
    673684        IMoniker_Enum(iface,FALSE,&enumMoniker);
    674685        IEnumMoniker_Next(enumMoniker,1,&mostRigthMk,NULL);
    675686        IEnumMoniker_Release(enumMoniker);
    676 
     687       
    677688        res=CreateAntiMoniker(&antiMk);
    678689        res=IMoniker_ComposeWith(iface,antiMk,0,&tempMk);
    679690        IMoniker_Release(antiMk);
    680 
     691       
    681692        res=CompositeMonikerImpl_BindToStorage(mostRigthMk,pbc,tempMk,riid,ppvResult);
    682693
     
    716727        IEnumMoniker_Next(enumMoniker,1,&mostRigthMk,NULL);
    717728        IEnumMoniker_Release(enumMoniker);
    718 
     729       
    719730        res=CreateAntiMoniker(&antiMk);
    720731        res=IMoniker_ComposeWith(iface,antiMk,0,&tempMk);
     
    733744        IEnumMoniker_Next(enumMoniker,1,&mostRigthMk,NULL);
    734745        IEnumMoniker_Release(enumMoniker);
    735 
     746       
    736747        res=CreateAntiMoniker(&antiMk);
    737748        res=IMoniker_ComposeWith(iface,antiMk,0,&tempMk);
     
    769780
    770781    if ((ppmkComposite==NULL)||(pmkRight==NULL))
    771     return E_POINTER;
     782        return E_POINTER;
    772783
    773784    *ppmkComposite=0;
     
    776787    /* otherwise, the method returns the result of combining the two monikers by calling the */
    777788    /* CreateGenericComposite function */
    778 
     789   
    779790    if (fOnlyIfNotGeneric)
    780791        return MK_E_NEEDGENERIC;
    781 
     792   
    782793    return CreateGenericComposite(iface,pmkRight,ppmkComposite);
    783794}
     
    794805    if (ppenumMoniker == NULL)
    795806        return E_POINTER;
    796 
     807   
    797808    return EnumMonikerImpl_CreateEnumMoniker(This->tabMoniker,This->tabLastIndex,0,fForward,ppenumMoniker);
    798809}
     
    806817    IMoniker *tempMk1,*tempMk2;
    807818    HRESULT res1,res2,res;
    808 
     819   
    809820    TRACE("(%p,%p)\n",iface,pmkOtherMoniker);
    810821
     
    818829    if (enumMoniker1==NULL)
    819830        return S_FALSE;
    820 
     831   
    821832    IMoniker_Enum(iface,TRUE,&enumMoniker2);
    822833
     
    825836        res1=IEnumMoniker_Next(enumMoniker1,1,&tempMk1,NULL);
    826837        res2=IEnumMoniker_Next(enumMoniker2,1,&tempMk2,NULL);
    827 
     838       
    828839        if((res1==S_OK)&&(res2==S_OK)){
    829840
     
    895906        /* If pmkToLeft is NULL, this method returns S_OK if pmkNewlyRunning is non-NULL and is equal */
    896907        /* to this moniker */
    897 
     908       
    898909        if (pmkNewlyRunning!=NULL)
    899910
     
    913924            /* IMoniker::IsRunning on the rightmost component of the composite, passing the remainder of */
    914925            /* the composite as the pmkToLeft parameter for that call.                                   */
    915 
     926           
    916927             res=IBindCtx_GetRunningObjectTable(pbc,&rot);
    917928
     
    957968    IMoniker *tempMk,*antiMk,*mostRigthMk;
    958969    IEnumMoniker *enumMoniker;
    959 
     970   
    960971    TRACE("(%p,%p,%p,%p)\n",iface,pbc,pmkToLeft,pCompositeTime);
    961972
     
    10541065    IEnumMoniker *enumMoniker1,*enumMoniker2;
    10551066    ULONG i,nbCommonMk=0;
    1056 
     1067   
    10571068    /* If the other moniker is a composite, this method compares the components of each composite from left  */
    10581069    /* to right. The returned common prefix moniker might also be a composite moniker, depending on how many */
     
    10611072    if (ppmkPrefix==NULL)
    10621073        return E_POINTER;
    1063 
     1074   
    10641075    *ppmkPrefix=0;
    10651076
    10661077    if (pmkOther==NULL)
    10671078        return MK_E_NOPREFIX;
    1068 
     1079   
    10691080    IMoniker_IsSystemMoniker(pmkOther,&mkSys);
    10701081
     
    11301141            IMoniker_Release(tempMk1);
    11311142            IMoniker_Release(tempMk2);
    1132 
     1143           
    11331144            /* compose all common monikers in a composite moniker */
    11341145            for(i=0;i<nbCommonMk;i++){
     
    11411152
    11421153                IMoniker_Release(tempMk1);
    1143 
     1154               
    11441155                *ppmkPrefix=tempMk2;
    11451156            }
     
    11821193    DWORD mkSys;
    11831194    HRESULT res1,res2;
    1184 
     1195   
    11851196    *restMk=0;
    11861197
     
    12801291
    12811292    /* finds the common prefix of the two monikers */
    1282     res=IMoniker_CommonPrefixWith(iface,pmkOther,&commonMk);
     1293    res=IMoniker_CommonPrefixWith(iface,pmkOther,&commonMk);   
    12831294
    12841295    /* if there's no common prefix or the two moniker are equal the relative is the other moniker */
     
    13371348    if (ppszDisplayName==NULL)
    13381349        return E_POINTER;
    1339 
     1350   
    13401351    *ppszDisplayName=CoTaskMemAlloc(sizeof(WCHAR));
    13411352
     
    13491360
    13501361    IMoniker_Enum(iface,TRUE,&enumMoniker);
    1351 
     1362   
    13521363    while(IEnumMoniker_Next(enumMoniker,1,&tempMk,NULL)==S_OK){
    13531364
     
    14091420    if (!pwdMksys)
    14101421        return E_POINTER;
    1411 
     1422   
    14121423    (*pwdMksys)=MKSYS_GENERICCOMPOSITE;
    14131424
     
    14461457{
    14471458    ICOM_THIS_From_IROTData(IMoniker, iface);
    1448 
     1459   
    14491460    TRACE("(%p)\n",iface);
    14501461
     
    14701481{
    14711482    ICOM_THIS(EnumMonikerImpl,iface);
    1472 
     1483 
    14731484    TRACE("(%p,%p,%p)\n",This,riid,ppvObject);
    14741485
    14751486    /* Perform a sanity check on the parameters.*/
    14761487    if ( (This==0) || (ppvObject==0) )
    1477     return E_INVALIDARG;
    1478 
     1488        return E_INVALIDARG;
     1489 
    14791490    /* Initialize the return parameter */
    14801491    *ppvObject = 0;
     
    15211532    /* destroy the object if there's no more reference on it */
    15221533    if (This->ref==0){
    1523 
     1534       
    15241535        for(i=0;i<This->tabSize;i++)
    15251536            IMoniker_Release(This->tabMoniker[i]);
     
    15481559    if (pceltFethed!=NULL)
    15491560        *pceltFethed= i;
    1550 
     1561   
    15511562    if (i==celt)
    15521563        return S_OK;
     
    15661577
    15671578    This->currentPos+=celt;
    1568 
     1579   
    15691580    return S_OK;
    15701581}
     
    16121623    if (currentPos > tabSize)
    16131624        return E_INVALIDARG;
    1614 
     1625   
    16151626    /* Initialize the virtual function table. */
    16161627    ICOM_VTBL(newEnumMoniker)    = &VT_EnumMonikerImpl;
     
    16441655
    16451656/******************************************************************************
    1646  *        CreateGenericComposite    [OLE.55]
     1657 *        CreateGenericComposite        [OLE.55]
    16471658 ******************************************************************************/
    16481659HRESULT WINAPI CreateGenericComposite(LPMONIKER pmkFirst, LPMONIKER pmkRest, LPMONIKER* ppmkComposite)
     
    16551666    if (ppmkComposite==NULL)
    16561667        return E_POINTER;
    1657 
     1668   
    16581669    *ppmkComposite=0;
    16591670
     
    16931704
    16941705/******************************************************************************
    1695  *        MonikerCommonPrefixWith   [OLE.55]
     1706 *        MonikerCommonPrefixWith       [OLE.55]
    16961707 ******************************************************************************/
    16971708HRESULT WINAPI MonikerCommonPrefixWith(IMoniker* pmkThis,IMoniker* pmkOther,IMoniker** ppmkCommon)
  • trunk/src/ole32/datacache.c

    r6648 r6711  
    1 /* $Id: datacache.c,v 1.2 2001-09-05 13:17:08 bird Exp $ */
    21/*
    3  *  OLE 2 Data cache
     2 *      OLE 2 Data cache
    43 *
    54 *      Copyright 1999  Francis Beaudet
     
    1817 *  -  This implementation of the datacache will let your application
    1918 *     load documents that have embedded OLE objects in them and it will
    20  *     also retrieve the metafile representation of those objects.
     19 *     also retrieve the metafile representation of those objects. 
    2120 *  -  This implementation of the datacache will also allow your
    2221 *     application to save new documents with OLE objects in them.
    23  *  -  The main thing that it doesn't do is allow you to activate
     22 *  -  The main thing that it doesn't do is allow you to activate 
    2423 *     or modify the OLE objects in any way.
    2524 *  -  I haven't found any good documentation on the real usage of
     
    2827 *     "\002OlePresXXX". It appears to just be a counter.
    2928 *  -  Also, I don't know the real content of the presentation stream
    30  *     header. I was able to figure-out where the extent of the object
     29 *     header. I was able to figure-out where the extent of the object 
    3130 *     was stored and the aspect, but that's about it.
    3231 */
     
    6160typedef struct PresentationDataHeader
    6261{
    63   DWORD unknown1;   /* -1 */
    64   DWORD unknown2;   /* 3, possibly CF_METAFILEPICT */
    65   DWORD unknown3;   /* 4, possibly TYMED_ISTREAM */
     62  DWORD unknown1;       /* -1 */
     63  DWORD unknown2;       /* 3, possibly CF_METAFILEPICT */
     64  DWORD unknown3;       /* 4, possibly TYMED_ISTREAM */
    6665  DVASPECT dvAspect;
    67   DWORD unknown5;   /* -1 */
     66  DWORD unknown5;       /* -1 */
    6867
    6968  DWORD unknown6;
    70   DWORD unknown7;   /* 0 */
     69  DWORD unknown7;       /* 0 */
    7170  DWORD dwObjectExtentX;
    7271  DWORD dwObjectExtentY;
     
    8281   * List all interface VTables here
    8382   */
    84   ICOM_VTABLE(IDataObject)*      lpvtbl1;
     83  ICOM_VTABLE(IDataObject)*      lpvtbl1; 
    8584  ICOM_VTABLE(IUnknown)*         lpvtbl2;
    8685  ICOM_VTABLE(IPersistStorage)*  lpvtbl3;
    87   ICOM_VTABLE(IViewObject2)*     lpvtbl4;
     86  ICOM_VTABLE(IViewObject2)*     lpvtbl4; 
    8887  ICOM_VTABLE(IOleCache2)*       lpvtbl5;
    8988  ICOM_VTABLE(IOleCacheControl)* lpvtbl6;
     
    120119
    121120/*
    122  * Here, I define utility macros to help with the casting of the
     121 * Here, I define utility macros to help with the casting of the 
    123122 * "this" parameter.
    124123 * There is a version to accomodate all of the VTables implemented
     
    126125 */
    127126#define _ICOM_THIS_From_IDataObject(class,name)       class* this = (class*)name;
    128 #define _ICOM_THIS_From_NDIUnknown(class, name)       class* this = (class*)(((char*)name)-sizeof(void*));
    129 #define _ICOM_THIS_From_IPersistStorage(class, name)  class* this = (class*)(((char*)name)-2*sizeof(void*));
    130 #define _ICOM_THIS_From_IViewObject2(class, name)     class* this = (class*)(((char*)name)-3*sizeof(void*));
    131 #define _ICOM_THIS_From_IOleCache2(class, name)       class* this = (class*)(((char*)name)-4*sizeof(void*));
    132 #define _ICOM_THIS_From_IOleCacheControl(class, name) class* this = (class*)(((char*)name)-5*sizeof(void*));
     127#define _ICOM_THIS_From_NDIUnknown(class, name)       class* this = (class*)(((char*)name)-sizeof(void*)); 
     128#define _ICOM_THIS_From_IPersistStorage(class, name)  class* this = (class*)(((char*)name)-2*sizeof(void*)); 
     129#define _ICOM_THIS_From_IViewObject2(class, name)     class* this = (class*)(((char*)name)-3*sizeof(void*)); 
     130#define _ICOM_THIS_From_IOleCache2(class, name)       class* this = (class*)(((char*)name)-4*sizeof(void*)); 
     131#define _ICOM_THIS_From_IOleCacheControl(class, name) class* this = (class*)(((char*)name)-5*sizeof(void*)); 
    133132
    134133/*
     
    136135 */
    137136static DataCache* DataCache_Construct(REFCLSID  clsid,
    138                       LPUNKNOWN pUnkOuter);
     137                                      LPUNKNOWN pUnkOuter);
    139138static void       DataCache_Destroy(DataCache* ptrToDestroy);
    140139static HRESULT    DataCache_ReadPresentationData(DataCache*              this,
    141                         DWORD                   drawAspect,
    142                         PresentationDataHeader* header);
     140                                                DWORD                   drawAspect,
     141                                                PresentationDataHeader* header);
    143142static HRESULT    DataCache_OpenPresStream(DataCache *this,
    144                        DWORD      drawAspect,
    145                        IStream  **pStm);
     143                                           DWORD      drawAspect,
     144                                           IStream  **pStm);
    146145static HMETAFILE  DataCache_ReadPresMetafile(DataCache* this,
    147                          DWORD      drawAspect);
     146                                             DWORD      drawAspect);
    148147static void       DataCache_FireOnViewChange(DataCache* this,
    149                          DWORD      aspect,
    150                          LONG       lindex);
     148                                             DWORD      aspect,
     149                                             LONG       lindex);
    151150
    152151/*
     
    158157            REFIID         riid,
    159158            void**         ppvObject);
    160 static ULONG WINAPI DataCache_NDIUnknown_AddRef(
     159static ULONG WINAPI DataCache_NDIUnknown_AddRef( 
    161160            IUnknown*      iface);
    162 static ULONG WINAPI DataCache_NDIUnknown_Release(
     161static ULONG WINAPI DataCache_NDIUnknown_Release( 
    163162            IUnknown*      iface);
    164163
     
    171170            REFIID           riid,
    172171            void**           ppvObject);
    173 static ULONG WINAPI DataCache_IDataObject_AddRef(
     172static ULONG WINAPI DataCache_IDataObject_AddRef( 
    174173            IDataObject*     iface);
    175 static ULONG WINAPI DataCache_IDataObject_Release(
     174static ULONG WINAPI DataCache_IDataObject_Release( 
    176175            IDataObject*     iface);
    177176static HRESULT WINAPI DataCache_GetData(
    178         IDataObject*     iface,
    179         LPFORMATETC      pformatetcIn,
    180         STGMEDIUM*       pmedium);
     177            IDataObject*     iface,
     178            LPFORMATETC      pformatetcIn,
     179            STGMEDIUM*       pmedium);
    181180static HRESULT WINAPI DataCache_GetDataHere(
    182         IDataObject*     iface,
    183         LPFORMATETC      pformatetc,
    184         STGMEDIUM*       pmedium);
     181            IDataObject*     iface,
     182            LPFORMATETC      pformatetc,
     183            STGMEDIUM*       pmedium);
    185184static HRESULT WINAPI DataCache_QueryGetData(
    186         IDataObject*     iface,
    187         LPFORMATETC      pformatetc);
     185            IDataObject*     iface,
     186            LPFORMATETC      pformatetc);
    188187static HRESULT WINAPI DataCache_GetCanonicalFormatEtc(
    189         IDataObject*     iface,
    190         LPFORMATETC      pformatectIn,
    191         LPFORMATETC      pformatetcOut);
     188            IDataObject*     iface,
     189            LPFORMATETC      pformatectIn,
     190            LPFORMATETC      pformatetcOut);
    192191static HRESULT WINAPI DataCache_IDataObject_SetData(
    193         IDataObject*     iface,
    194         LPFORMATETC      pformatetc,
    195         STGMEDIUM*       pmedium,
    196         BOOL             fRelease);
     192            IDataObject*     iface,
     193            LPFORMATETC      pformatetc,
     194            STGMEDIUM*       pmedium,
     195            BOOL             fRelease);
    197196static HRESULT WINAPI DataCache_EnumFormatEtc(
    198         IDataObject*     iface,
    199         DWORD            dwDirection,
    200         IEnumFORMATETC** ppenumFormatEtc);
     197            IDataObject*     iface,       
     198            DWORD            dwDirection,
     199            IEnumFORMATETC** ppenumFormatEtc);
    201200static HRESULT WINAPI DataCache_DAdvise(
    202         IDataObject*     iface,
    203         FORMATETC*       pformatetc,
    204         DWORD            advf,
    205         IAdviseSink*     pAdvSink,
    206         DWORD*           pdwConnection);
     201            IDataObject*     iface,
     202            FORMATETC*       pformatetc,
     203            DWORD            advf,
     204            IAdviseSink*     pAdvSink,
     205            DWORD*           pdwConnection);
    207206static HRESULT WINAPI DataCache_DUnadvise(
    208         IDataObject*     iface,
    209         DWORD            dwConnection);
     207            IDataObject*     iface,
     208            DWORD            dwConnection);
    210209static HRESULT WINAPI DataCache_EnumDAdvise(
    211         IDataObject*     iface,
    212         IEnumSTATDATA**  ppenumAdvise);
     210            IDataObject*     iface,
     211            IEnumSTATDATA**  ppenumAdvise);
    213212
    214213/*
     
    220219            REFIID           riid,
    221220            void**           ppvObject);
    222 static ULONG WINAPI DataCache_IPersistStorage_AddRef(
     221static ULONG WINAPI DataCache_IPersistStorage_AddRef( 
    223222            IPersistStorage* iface);
    224 static ULONG WINAPI DataCache_IPersistStorage_Release(
     223static ULONG WINAPI DataCache_IPersistStorage_Release( 
    225224            IPersistStorage* iface);
    226 static HRESULT WINAPI DataCache_GetClassID(
     225static HRESULT WINAPI DataCache_GetClassID( 
    227226            IPersistStorage* iface,
    228         CLSID*           pClassID);
    229 static HRESULT WINAPI DataCache_IsDirty(
     227            CLSID*           pClassID);
     228static HRESULT WINAPI DataCache_IsDirty( 
    230229            IPersistStorage* iface);
    231 static HRESULT WINAPI DataCache_InitNew(
     230static HRESULT WINAPI DataCache_InitNew(
     231            IPersistStorage* iface,
     232            IStorage*        pStg);
     233static HRESULT WINAPI DataCache_Load(
    232234            IPersistStorage* iface,
    233         IStorage*        pStg);
    234 static HRESULT WINAPI DataCache_Load(
     235            IStorage*        pStg);
     236static HRESULT WINAPI DataCache_Save(
    235237            IPersistStorage* iface,
    236         IStorage*        pStg);
    237 static HRESULT WINAPI DataCache_Save(
    238             IPersistStorage* iface,
    239         IStorage*        pStg,
    240         BOOL             fSameAsLoad);
    241 static HRESULT WINAPI DataCache_SaveCompleted(
    242             IPersistStorage* iface,
    243         IStorage*        pStgNew);
     238            IStorage*        pStg,
     239            BOOL             fSameAsLoad);
     240static HRESULT WINAPI DataCache_SaveCompleted(
     241            IPersistStorage* iface, 
     242            IStorage*        pStgNew);
    244243static HRESULT WINAPI DataCache_HandsOffStorage(
    245244            IPersistStorage* iface);
     
    253252            REFIID           riid,
    254253            void**           ppvObject);
    255 static ULONG WINAPI DataCache_IViewObject2_AddRef(
     254static ULONG WINAPI DataCache_IViewObject2_AddRef( 
    256255            IViewObject2* iface);
    257 static ULONG WINAPI DataCache_IViewObject2_Release(
     256static ULONG WINAPI DataCache_IViewObject2_Release( 
    258257            IViewObject2* iface);
    259258static HRESULT WINAPI DataCache_Draw(
    260259            IViewObject2*    iface,
    261         DWORD            dwDrawAspect,
    262         LONG             lindex,
    263         void*            pvAspect,
    264         DVTARGETDEVICE*  ptd,
    265         HDC              hdcTargetDev,
    266         HDC              hdcDraw,
    267         LPCRECTL         lprcBounds,
    268         LPCRECTL         lprcWBounds,
    269         IVO_ContCallback pfnContinue,
    270         DWORD            dwContinue);
     260            DWORD            dwDrawAspect,
     261            LONG             lindex,
     262            void*            pvAspect,
     263            DVTARGETDEVICE*  ptd,
     264            HDC              hdcTargetDev,
     265            HDC              hdcDraw,
     266            LPCRECTL         lprcBounds,
     267            LPCRECTL         lprcWBounds,
     268            IVO_ContCallback pfnContinue,
     269            DWORD            dwContinue);
    271270static HRESULT WINAPI DataCache_GetColorSet(
    272             IViewObject2*   iface,
    273         DWORD           dwDrawAspect,
    274         LONG            lindex,
    275         void*           pvAspect,
    276         DVTARGETDEVICE* ptd,
    277         HDC             hicTargetDevice,
    278         LOGPALETTE**    ppColorSet);
     271            IViewObject2*   iface, 
     272            DWORD           dwDrawAspect,
     273            LONG            lindex,
     274            void*           pvAspect,
     275            DVTARGETDEVICE* ptd,
     276            HDC             hicTargetDevice,
     277            LOGPALETTE**    ppColorSet);
    279278static HRESULT WINAPI DataCache_Freeze(
    280279            IViewObject2*   iface,
    281         DWORD           dwDrawAspect,
    282         LONG            lindex,
    283         void*           pvAspect,
    284         DWORD*          pdwFreeze);
     280            DWORD           dwDrawAspect,
     281            LONG            lindex,
     282            void*           pvAspect,
     283            DWORD*          pdwFreeze);
    285284static HRESULT WINAPI DataCache_Unfreeze(
    286285            IViewObject2*   iface,
    287         DWORD           dwFreeze);
     286            DWORD           dwFreeze);
    288287static HRESULT WINAPI DataCache_SetAdvise(
    289288            IViewObject2*   iface,
    290         DWORD           aspects,
    291         DWORD           advf,
    292         IAdviseSink*    pAdvSink);
     289            DWORD           aspects,
     290            DWORD           advf,
     291            IAdviseSink*    pAdvSink);
    293292static HRESULT WINAPI DataCache_GetAdvise(
    294             IViewObject2*   iface,
    295         DWORD*          pAspects,
    296         DWORD*          pAdvf,
    297         IAdviseSink**   ppAdvSink);
     293            IViewObject2*   iface, 
     294            DWORD*          pAspects,
     295            DWORD*          pAdvf,
     296            IAdviseSink**   ppAdvSink);
    298297static HRESULT WINAPI DataCache_GetExtent(
    299             IViewObject2*   iface,
    300         DWORD           dwDrawAspect,
    301         LONG            lindex,
    302         DVTARGETDEVICE* ptd,
    303         LPSIZEL         lpsizel);
     298            IViewObject2*   iface, 
     299            DWORD           dwDrawAspect,
     300            LONG            lindex,
     301            DVTARGETDEVICE* ptd,
     302            LPSIZEL         lpsizel);
    304303
    305304/*
     
    311310            REFIID          riid,
    312311            void**          ppvObject);
    313 static ULONG WINAPI DataCache_IOleCache2_AddRef(
     312static ULONG WINAPI DataCache_IOleCache2_AddRef( 
    314313            IOleCache2*     iface);
    315 static ULONG WINAPI DataCache_IOleCache2_Release(
     314static ULONG WINAPI DataCache_IOleCache2_Release( 
    316315            IOleCache2*     iface);
    317316static HRESULT WINAPI DataCache_Cache(
    318317            IOleCache2*     iface,
    319         FORMATETC*      pformatetc,
    320         DWORD           advf,
    321         DWORD*          pdwConnection);
     318            FORMATETC*      pformatetc,
     319            DWORD           advf,
     320            DWORD*          pdwConnection);
    322321static HRESULT WINAPI DataCache_Uncache(
    323         IOleCache2*     iface,
    324         DWORD           dwConnection);
     322            IOleCache2*     iface,
     323            DWORD           dwConnection);
    325324static HRESULT WINAPI DataCache_EnumCache(
    326325            IOleCache2*     iface,
    327         IEnumSTATDATA** ppenumSTATDATA);
     326            IEnumSTATDATA** ppenumSTATDATA);
    328327static HRESULT WINAPI DataCache_InitCache(
    329         IOleCache2*     iface,
    330         IDataObject*    pDataObject);
     328            IOleCache2*     iface,
     329            IDataObject*    pDataObject);
    331330static HRESULT WINAPI DataCache_IOleCache2_SetData(
    332331            IOleCache2*     iface,
    333         FORMATETC*      pformatetc,
    334         STGMEDIUM*      pmedium,
    335         BOOL            fRelease);
     332            FORMATETC*      pformatetc,
     333            STGMEDIUM*      pmedium,
     334            BOOL            fRelease);
    336335static HRESULT WINAPI DataCache_UpdateCache(
    337336            IOleCache2*     iface,
    338         LPDATAOBJECT    pDataObject,
    339         DWORD           grfUpdf,
    340         LPVOID          pReserved);
     337            LPDATAOBJECT    pDataObject,
     338            DWORD           grfUpdf,
     339            LPVOID          pReserved);
    341340static HRESULT WINAPI DataCache_DiscardCache(
    342341            IOleCache2*     iface,
    343         DWORD           dwDiscardOptions);
     342            DWORD           dwDiscardOptions);
    344343
    345344/*
     
    351350            REFIID            riid,
    352351            void**            ppvObject);
    353 static ULONG WINAPI DataCache_IOleCacheControl_AddRef(
     352static ULONG WINAPI DataCache_IOleCacheControl_AddRef( 
    354353            IOleCacheControl* iface);
    355 static ULONG WINAPI DataCache_IOleCacheControl_Release(
     354static ULONG WINAPI DataCache_IOleCacheControl_Release( 
    356355            IOleCacheControl* iface);
    357356static HRESULT WINAPI DataCache_OnRun(
    358         IOleCacheControl* iface,
    359         LPDATAOBJECT      pDataObject);
     357            IOleCacheControl* iface,
     358            LPDATAOBJECT      pDataObject);
    360359static HRESULT WINAPI DataCache_OnStop(
    361         IOleCacheControl* iface);
     360            IOleCacheControl* iface);
    362361
    363362/*
     
    448447 */
    449448HRESULT WINAPI CreateDataCache(
    450   LPUNKNOWN pUnkOuter,
    451   REFCLSID  rclsid,
    452   REFIID    riid,
     449  LPUNKNOWN pUnkOuter, 
     450  REFCLSID  rclsid, 
     451  REFIID    riid, 
    453452  LPVOID*   ppvObj)
    454453{
     
    472471   * IUnknown pointer can be returned to the outside.
    473472   */
    474   if ( (pUnkOuter!=NULL) &&
     473  if ( (pUnkOuter!=NULL) && 
    475474       (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) != 0) )
    476475    return CLASS_E_NOAGGREGATION;
     
    479478   * Try to construct a new instance of the class.
    480479   */
    481   newCache = DataCache_Construct(rclsid,
    482                 pUnkOuter);
     480  newCache = DataCache_Construct(rclsid, 
     481                                pUnkOuter);
    483482
    484483  if (newCache == 0)
     
    515514  if (newObject==0)
    516515    return newObject;
    517 
     516 
    518517  /*
    519518   * Initialize the virtual function table.
     
    525524  newObject->lpvtbl5 = &DataCache_IOleCache2_VTable;
    526525  newObject->lpvtbl6 = &DataCache_IOleCacheControl_VTable;
    527 
    528   /*
    529    * Start with one reference count. The caller of this function
     526 
     527  /*
     528   * Start with one reference count. The caller of this function 
    530529   * must release the interface pointer when it is done.
    531530   */
     
    534533  /*
    535534   * Initialize the outer unknown
    536    * We don't keep a reference on the outer unknown since, the way
     535   * We don't keep a reference on the outer unknown since, the way 
    537536   * aggregation works, our lifetime is at least as large as it's
    538537   * lifetime.
     
    580579 * DataCache_ReadPresentationData
    581580 *
    582  * This method will read information for the requested presentation
     581 * This method will read information for the requested presentation 
    583582 * into the given structure.
    584583 *
     
    602601  hres = DataCache_OpenPresStream(
    603602           this,
    604        drawAspect,
    605        &presStream);
     603           drawAspect,
     604           &presStream);
    606605
    607606  if (FAILED(hres))
     
    614613  hres = IStream_Read(
    615614           presStream,
    616        header,
    617        sizeof(PresentationDataHeader),
    618        NULL);
     615           header,
     616           sizeof(PresentationDataHeader),
     617           NULL);
    619618
    620619  /*
     
    658657    {
    659658      IAdviseSink_OnViewChange(this->sinkInterface,
    660                    aspect,
    661                    lindex);
     659                               aspect,
     660                               lindex);
    662661
    663662      /*
     
    667666      if ( (this->sinkAdviseFlag & ADVF_ONLYONCE) != 0)
    668667      {
    669     IAdviseSink_Release(this->sinkInterface);
    670 
    671     this->sinkInterface  = NULL;
    672     this->sinkAspects    = 0;
    673     this->sinkAdviseFlag = 0;
     668        IAdviseSink_Release(this->sinkInterface);
     669
     670        this->sinkInterface  = NULL;
     671        this->sinkAspects    = 0;
     672        this->sinkAdviseFlag = 0;
    674673      }
    675674    }
     
    687686
    688687    return (elem->type == STGTY_STREAM)
    689     && (elem->cbSize.s.LowPart >= sizeof(PresentationDataHeader))
    690     && (strlenW(name) == 11)
    691     && (strncmpW(name, OlePres, 8) == 0)
    692     && (name[8] >= '0') && (name[8] <= '9')
    693     && (name[9] >= '0') && (name[9] <= '9')
    694     && (name[10] >= '0') && (name[10] <= '9');
     688        && (elem->cbSize.s.LowPart >= sizeof(PresentationDataHeader))
     689        && (strlenW(name) == 11)
     690        && (strncmpW(name, OlePres, 8) == 0)
     691        && (name[8] >= '0') && (name[8] <= '9')
     692        && (name[9] >= '0') && (name[9] <= '9')
     693        && (name[10] >= '0') && (name[10] <= '9');
    695694}
    696695
     
    708707 *
    709708 * Errors:
    710  *   S_OK       The requested stream has been opened.
    711  *   OLE_E_BLANK    The requested stream could not be found.
     709 *   S_OK               The requested stream has been opened.
     710 *   OLE_E_BLANK        The requested stream could not be found.
    712711 *   Quite a few others I'm too lazy to map correctly.
    713712 *
    714713 * Notes:
    715  *   Algorithm: Scan the elements of the presentation storage, looking
    716  *      for presentation streams. For each presentation stream,
    717  *      load the header and check to see if the aspect maches.
     714 *   Algorithm: Scan the elements of the presentation storage, looking
     715 *              for presentation streams. For each presentation stream,
     716 *              load the header and check to see if the aspect maches.
    718717 *
    719718 *   If a fallback is desired, just opening the first presentation stream
     
    736735    while ((hr = IEnumSTATSTG_Next(pEnum, 1, &elem, NULL)) == S_OK)
    737736    {
    738     if (DataCache_IsPresentationStream(&elem))
    739     {
    740         IStream *pStm;
    741 
    742         hr = IStorage_OpenStream(this->presentationStorage, elem.pwcsName,
    743                      NULL, STGM_READ | STGM_SHARE_EXCLUSIVE, 0,
    744                      &pStm);
    745         if (SUCCEEDED(hr))
    746         {
    747         PresentationDataHeader header;
    748         ULONG actual_read;
    749 
    750         hr = IStream_Read(pStm, &header, sizeof(header), &actual_read);
    751 
    752         /* can't use SUCCEEDED(hr): S_FALSE counts as an error */
    753         if (hr == S_OK && actual_read == sizeof(header)
    754             && header.dvAspect == drawAspect)
    755         {
    756             /* Rewind the stream before returning it. */
    757             LARGE_INTEGER offset;
    758             offset.s.LowPart = 0;
    759             offset.s.HighPart = 0;
    760             IStream_Seek(pStm, offset, STREAM_SEEK_SET, NULL);
    761 
    762             *ppStm = pStm;
    763 
    764             CoTaskMemFree(elem.pwcsName);
    765             IEnumSTATSTG_Release(pEnum);
    766 
    767             return S_OK;
    768         }
    769 
    770         IStream_Release(pStm);
    771         }
     737        if (DataCache_IsPresentationStream(&elem))
     738        {
     739            IStream *pStm;
     740
     741            hr = IStorage_OpenStream(this->presentationStorage, elem.pwcsName,
     742                                     NULL, STGM_READ | STGM_SHARE_EXCLUSIVE, 0,
     743                                     &pStm);
     744            if (SUCCEEDED(hr))
     745            {
     746                PresentationDataHeader header;
     747                ULONG actual_read;
     748
     749                hr = IStream_Read(pStm, &header, sizeof(header), &actual_read);
     750
     751                /* can't use SUCCEEDED(hr): S_FALSE counts as an error */
     752                if (hr == S_OK && actual_read == sizeof(header)
     753                    && header.dvAspect == drawAspect)
     754                {
     755                    /* Rewind the stream before returning it. */
     756                    LARGE_INTEGER offset;
     757                    offset.s.LowPart = 0;
     758                    offset.s.HighPart = 0;
     759                    IStream_Seek(pStm, offset, STREAM_SEEK_SET, NULL);
     760
     761                    *ppStm = pStm;
     762
     763                    CoTaskMemFree(elem.pwcsName);
     764                    IEnumSTATSTG_Release(pEnum);
     765
     766                    return S_OK;
     767                }
     768
     769                IStream_Release(pStm);
     770            }
     771        }
     772
     773        CoTaskMemFree(elem.pwcsName);
    772774    }
    773775
    774     CoTaskMemFree(elem.pwcsName);
    775     }
    776 
    777776    IEnumSTATSTG_Release(pEnum);
    778777
     
    783782 * DataCache_ReadPresentationData
    784783 *
    785  * This method will read information for the requested presentation
     784 * This method will read information for the requested presentation 
    786785 * into the given structure.
    787786 *
     
    809808   */
    810809  hres = DataCache_OpenPresStream(
    811            this,
    812        drawAspect,
    813        &presStream);
     810           this, 
     811           drawAspect,
     812           &presStream);
    814813
    815814  if (FAILED(hres))
     
    820819   */
    821820  hres = IStream_Stat(presStream,
    822               &streamInfo,
    823               STATFLAG_NONAME);
     821                      &streamInfo,
     822                      STATFLAG_NONAME);
    824823
    825824  /*
     
    831830  hres = IStream_Seek(
    832831           presStream,
    833        offset,
    834        STREAM_SEEK_SET,
    835        NULL);
     832           offset,
     833           STREAM_SEEK_SET,
     834           NULL);
    836835
    837836  streamInfo.cbSize.s.LowPart -= offset.s.LowPart;
     
    840839   * Allocate a buffer for the metafile bits.
    841840   */
    842   metafileBits = HeapAlloc(GetProcessHeap(),
    843                0,
    844                streamInfo.cbSize.s.LowPart);
     841  metafileBits = HeapAlloc(GetProcessHeap(), 
     842                           0,
     843                           streamInfo.cbSize.s.LowPart);
    845844
    846845  /*
     
    848847   */
    849848  hres = IStream_Read(
    850        presStream,
    851        metafileBits,
    852        streamInfo.cbSize.s.LowPart,
    853        NULL);
     849           presStream,
     850           metafileBits,
     851           streamInfo.cbSize.s.LowPart,
     852           NULL);
    854853
    855854  /*
     
    898897  if ( (this==0) || (ppvObject==0) )
    899898    return E_INVALIDARG;
    900 
     899 
    901900  /*
    902901   * Initialize the return parameter.
     
    907906   * Compare the riid with the interface IDs implemented by this object.
    908907   */
    909   if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0)
     908  if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0) 
    910909  {
    911910    *ppvObject = iface;
    912911  }
    913   else if (memcmp(&IID_IDataObject, riid, sizeof(IID_IDataObject)) == 0)
     912  else if (memcmp(&IID_IDataObject, riid, sizeof(IID_IDataObject)) == 0) 
    914913  {
    915914    *ppvObject = (IDataObject*)&(this->lpvtbl1);
    916915  }
    917916  else if ( (memcmp(&IID_IPersistStorage, riid, sizeof(IID_IPersistStorage)) == 0)  ||
    918         (memcmp(&IID_IPersist, riid, sizeof(IID_IPersist)) == 0) )
     917            (memcmp(&IID_IPersist, riid, sizeof(IID_IPersist)) == 0) )
    919918  {
    920919    *ppvObject = (IPersistStorage*)&(this->lpvtbl3);
    921920  }
    922921  else if ( (memcmp(&IID_IViewObject, riid, sizeof(IID_IViewObject)) == 0) ||
    923         (memcmp(&IID_IViewObject2, riid, sizeof(IID_IViewObject2)) == 0) )
     922            (memcmp(&IID_IViewObject2, riid, sizeof(IID_IViewObject2)) == 0) )
    924923  {
    925924    *ppvObject = (IViewObject2*)&(this->lpvtbl4);
    926925  }
    927926  else if ( (memcmp(&IID_IOleCache, riid, sizeof(IID_IOleCache)) == 0) ||
    928         (memcmp(&IID_IOleCache2, riid, sizeof(IID_IOleCache2)) == 0) )
     927            (memcmp(&IID_IOleCache2, riid, sizeof(IID_IOleCache2)) == 0) )
    929928  {
    930929    *ppvObject = (IOleCache2*)&(this->lpvtbl5);
    931930  }
    932   else if (memcmp(&IID_IOleCacheControl, riid, sizeof(IID_IOleCacheControl)) == 0)
     931  else if (memcmp(&IID_IOleCacheControl, riid, sizeof(IID_IOleCacheControl)) == 0) 
    933932  {
    934933    *ppvObject = (IOleCacheControl*)&(this->lpvtbl6);
     
    943942    return E_NOINTERFACE;
    944943  }
    945 
     944 
    946945  /*
    947946   * Query Interface always increases the reference count by one when it is
    948    * successful.
     947   * successful. 
    949948   */
    950949  IUnknown_AddRef((IUnknown*)*ppvObject);
    951950
    952   return S_OK;;
     951  return S_OK;; 
    953952}
    954953
     
    961960 * to the outer unknown.
    962961 */
    963 static ULONG WINAPI DataCache_NDIUnknown_AddRef(
     962static ULONG WINAPI DataCache_NDIUnknown_AddRef( 
    964963            IUnknown*      iface)
    965964{
     
    979978 * to the outer unknown.
    980979 */
    981 static ULONG WINAPI DataCache_NDIUnknown_Release(
     980static ULONG WINAPI DataCache_NDIUnknown_Release( 
    982981            IUnknown*      iface)
    983982{
     
    998997    return 0;
    999998  }
    1000 
     999 
    10011000  return this->ref;
    10021001}
     
    10191018  _ICOM_THIS_From_IDataObject(DataCache, iface);
    10201019
    1021   return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject);
     1020  return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject); 
    10221021}
    10231022
     
    10271026 * See Windows documentation for more details on IUnknown methods.
    10281027 */
    1029 static ULONG WINAPI DataCache_IDataObject_AddRef(
     1028static ULONG WINAPI DataCache_IDataObject_AddRef( 
    10301029            IDataObject*     iface)
    10311030{
    10321031  _ICOM_THIS_From_IDataObject(DataCache, iface);
    10331032
    1034   return IUnknown_AddRef(this->outerUnknown);
     1033  return IUnknown_AddRef(this->outerUnknown); 
    10351034}
    10361035
     
    10401039 * See Windows documentation for more details on IUnknown methods.
    10411040 */
    1042 static ULONG WINAPI DataCache_IDataObject_Release(
     1041static ULONG WINAPI DataCache_IDataObject_Release( 
    10431042            IDataObject*     iface)
    10441043{
    10451044  _ICOM_THIS_From_IDataObject(DataCache, iface);
    10461045
    1047   return IUnknown_Release(this->outerUnknown);
     1046  return IUnknown_Release(this->outerUnknown); 
    10481047}
    10491048
     
    10561055 */
    10571056static HRESULT WINAPI DataCache_GetData(
    1058         IDataObject*     iface,
    1059         LPFORMATETC      pformatetcIn,
    1060         STGMEDIUM*       pmedium)
     1057            IDataObject*     iface,
     1058            LPFORMATETC      pformatetcIn,
     1059            STGMEDIUM*       pmedium)
    10611060{
    10621061  HRESULT hr = 0;
     
    11551154
    11561155static HRESULT WINAPI DataCache_GetDataHere(
    1157         IDataObject*     iface,
    1158         LPFORMATETC      pformatetc,
    1159         STGMEDIUM*       pmedium)
     1156            IDataObject*     iface,
     1157            LPFORMATETC      pformatetc,
     1158            STGMEDIUM*       pmedium)
    11601159{
    11611160  FIXME("stub\n");
     
    11641163
    11651164static HRESULT WINAPI DataCache_QueryGetData(
    1166         IDataObject*     iface,
    1167         LPFORMATETC      pformatetc)
     1165            IDataObject*     iface,
     1166            LPFORMATETC      pformatetc)
    11681167{
    11691168  FIXME("stub\n");
     
    11791178 */
    11801179static HRESULT WINAPI DataCache_GetCanonicalFormatEtc(
    1181         IDataObject*     iface,
    1182         LPFORMATETC      pformatectIn,
    1183         LPFORMATETC      pformatetcOut)
     1180            IDataObject*     iface,
     1181            LPFORMATETC      pformatectIn,
     1182            LPFORMATETC      pformatetcOut)
    11841183{
    11851184  TRACE("()\n");
     
    11951194 */
    11961195static HRESULT WINAPI DataCache_IDataObject_SetData(
    1197         IDataObject*     iface,
    1198         LPFORMATETC      pformatetc,
    1199         STGMEDIUM*       pmedium,
    1200         BOOL             fRelease)
     1196            IDataObject*     iface,
     1197            LPFORMATETC      pformatetc,
     1198            STGMEDIUM*       pmedium,
     1199            BOOL             fRelease)
    12011200{
    12021201  IOleCache2* oleCache = NULL;
     
    12251224 */
    12261225static HRESULT WINAPI DataCache_EnumFormatEtc(
    1227         IDataObject*     iface,
    1228         DWORD            dwDirection,
    1229         IEnumFORMATETC** ppenumFormatEtc)
     1226            IDataObject*     iface,       
     1227            DWORD            dwDirection,
     1228            IEnumFORMATETC** ppenumFormatEtc)
    12301229{
    12311230  TRACE("()\n");
     
    12411240 */
    12421241static HRESULT WINAPI DataCache_DAdvise(
    1243         IDataObject*     iface,
    1244         FORMATETC*       pformatetc,
    1245         DWORD            advf,
    1246         IAdviseSink*     pAdvSink,
    1247         DWORD*           pdwConnection)
     1242            IDataObject*     iface,
     1243            FORMATETC*       pformatetc,
     1244            DWORD            advf,
     1245            IAdviseSink*     pAdvSink,
     1246            DWORD*           pdwConnection)
    12481247{
    12491248  TRACE("()\n");
     
    12591258 */
    12601259static HRESULT WINAPI DataCache_DUnadvise(
    1261         IDataObject*     iface,
    1262         DWORD            dwConnection)
     1260            IDataObject*     iface,
     1261            DWORD            dwConnection)
    12631262{
    12641263  TRACE("()\n");
     
    12741273 */
    12751274static HRESULT WINAPI DataCache_EnumDAdvise(
    1276         IDataObject*     iface,
    1277         IEnumSTATDATA**  ppenumAdvise)
     1275            IDataObject*     iface,
     1276            IEnumSTATDATA**  ppenumAdvise)
    12781277{
    12791278  TRACE("()\n");
     
    12981297  _ICOM_THIS_From_IPersistStorage(DataCache, iface);
    12991298
    1300   return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject);
     1299  return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject); 
    13011300}
    13021301
     
    13061305 * See Windows documentation for more details on IUnknown methods.
    13071306 */
    1308 static ULONG WINAPI DataCache_IPersistStorage_AddRef(
     1307static ULONG WINAPI DataCache_IPersistStorage_AddRef( 
    13091308            IPersistStorage* iface)
    13101309{
    13111310  _ICOM_THIS_From_IPersistStorage(DataCache, iface);
    13121311
    1313   return IUnknown_AddRef(this->outerUnknown);
     1312  return IUnknown_AddRef(this->outerUnknown); 
    13141313}
    13151314
     
    13191318 * See Windows documentation for more details on IUnknown methods.
    13201319 */
    1321 static ULONG WINAPI DataCache_IPersistStorage_Release(
     1320static ULONG WINAPI DataCache_IPersistStorage_Release( 
    13221321            IPersistStorage* iface)
    13231322{
    13241323  _ICOM_THIS_From_IPersistStorage(DataCache, iface);
    13251324
    1326   return IUnknown_Release(this->outerUnknown);
     1325  return IUnknown_Release(this->outerUnknown); 
    13271326}
    13281327
     
    13341333 * See Windows documentation for more details on IPersistStorage methods.
    13351334 */
    1336 static HRESULT WINAPI DataCache_GetClassID(
     1335static HRESULT WINAPI DataCache_GetClassID( 
    13371336            IPersistStorage* iface,
    1338         CLSID*           pClassID)
     1337            CLSID*           pClassID)
    13391338{
    13401339  TRACE("(%p, %p)\n", iface, pClassID);
     
    13451344 * DataCache_IsDirty (IPersistStorage)
    13461345 *
    1347  * Until we actully connect to a running object and retrieve new
     1346 * Until we actully connect to a running object and retrieve new 
    13481347 * information to it, we never get dirty.
    13491348 *
    13501349 * See Windows documentation for more details on IPersistStorage methods.
    13511350 */
    1352 static HRESULT WINAPI DataCache_IsDirty(
     1351static HRESULT WINAPI DataCache_IsDirty( 
    13531352            IPersistStorage* iface)
    13541353{
     
    13661365 * See Windows documentation for more details on IPersistStorage methods.
    13671366 */
    1368 static HRESULT WINAPI DataCache_InitNew(
     1367static HRESULT WINAPI DataCache_InitNew(
     1368            IPersistStorage* iface,
     1369            IStorage*        pStg)
     1370{
     1371  TRACE("(%p, %p)\n", iface, pStg);
     1372
     1373  return DataCache_Load(iface, pStg);
     1374}
     1375
     1376/************************************************************************
     1377 * DataCache_Load (IPersistStorage)
     1378 *
     1379 * The data cache implementation of IPersistStorage_Load doesn't
     1380 * actually load anything. Instead, it holds on to the storage pointer
     1381 * and it will load the presentation information when the
     1382 * IDataObject_GetData or IViewObject2_Draw methods are called.
     1383 *
     1384 * See Windows documentation for more details on IPersistStorage methods.
     1385 */
     1386static HRESULT WINAPI DataCache_Load(
    13691387            IPersistStorage* iface,
    1370         IStorage*        pStg)
    1371 {
     1388            IStorage*        pStg)
     1389{
     1390  _ICOM_THIS_From_IPersistStorage(DataCache, iface);
     1391
    13721392  TRACE("(%p, %p)\n", iface, pStg);
    13731393
    1374   return DataCache_Load(iface, pStg);
    1375 }
    1376 
    1377 /************************************************************************
    1378  * DataCache_Load (IPersistStorage)
    1379  *
    1380  * The data cache implementation of IPersistStorage_Load doesn't
    1381  * actually load anything. Instead, it holds on to the storage pointer
    1382  * and it will load the presentation information when the
    1383  * IDataObject_GetData or IViewObject2_Draw methods are called.
    1384  *
    1385  * See Windows documentation for more details on IPersistStorage methods.
    1386  */
    1387 static HRESULT WINAPI DataCache_Load(
    1388             IPersistStorage* iface,
    1389         IStorage*        pStg)
    1390 {
    1391   _ICOM_THIS_From_IPersistStorage(DataCache, iface);
    1392 
    1393   TRACE("(%p, %p)\n", iface, pStg);
    1394 
    13951394  if (this->presentationStorage != NULL)
    13961395  {
     
    14101409 * DataCache_Save (IPersistStorage)
    14111410 *
    1412  * Until we actully connect to a running object and retrieve new
     1411 * Until we actully connect to a running object and retrieve new 
    14131412 * information to it, we never have to save anything. However, it is
    14141413 * our responsability to copy the information when saving to a new
     
    14171416 * See Windows documentation for more details on IPersistStorage methods.
    14181417 */
    1419 static HRESULT WINAPI DataCache_Save(
     1418static HRESULT WINAPI DataCache_Save( 
    14201419            IPersistStorage* iface,
    1421         IStorage*        pStg,
    1422         BOOL             fSameAsLoad)
     1420            IStorage*        pStg,
     1421            BOOL             fSameAsLoad)
    14231422{
    14241423  _ICOM_THIS_From_IPersistStorage(DataCache, iface);
     
    14261425  TRACE("(%p, %p, %d)\n", iface, pStg, fSameAsLoad);
    14271426
    1428   if ( (!fSameAsLoad) &&
     1427  if ( (!fSameAsLoad) && 
    14291428       (this->presentationStorage!=NULL) )
    14301429  {
    14311430    return IStorage_CopyTo(this->presentationStorage,
    1432                0,
    1433                NULL,
    1434                NULL,
    1435                pStg);
     1431                           0,
     1432                           NULL,
     1433                           NULL,
     1434                           pStg);
    14361435  }
    14371436
     
    14471446 * See Windows documentation for more details on IPersistStorage methods.
    14481447 */
    1449 static HRESULT WINAPI DataCache_SaveCompleted(
    1450             IPersistStorage* iface,
    1451         IStorage*        pStgNew)
     1448static HRESULT WINAPI DataCache_SaveCompleted( 
     1449            IPersistStorage* iface, 
     1450            IStorage*        pStgNew)
    14521451{
    14531452  TRACE("(%p, %p)\n", iface, pStgNew);
     
    15121511  _ICOM_THIS_From_IViewObject2(DataCache, iface);
    15131512
    1514   return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject);
     1513  return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject); 
    15151514}
    15161515
     
    15201519 * See Windows documentation for more details on IUnknown methods.
    15211520 */
    1522 static ULONG WINAPI DataCache_IViewObject2_AddRef(
     1521static ULONG WINAPI DataCache_IViewObject2_AddRef( 
    15231522            IViewObject2* iface)
    15241523{
    15251524  _ICOM_THIS_From_IViewObject2(DataCache, iface);
    15261525
    1527   return IUnknown_AddRef(this->outerUnknown);
     1526  return IUnknown_AddRef(this->outerUnknown); 
    15281527}
    15291528
     
    15331532 * See Windows documentation for more details on IUnknown methods.
    15341533 */
    1535 static ULONG WINAPI DataCache_IViewObject2_Release(
     1534static ULONG WINAPI DataCache_IViewObject2_Release( 
    15361535            IViewObject2* iface)
    15371536{
    15381537  _ICOM_THIS_From_IViewObject2(DataCache, iface);
    15391538
    1540   return IUnknown_Release(this->outerUnknown);
     1539  return IUnknown_Release(this->outerUnknown); 
    15411540}
    15421541
     
    15511550static HRESULT WINAPI DataCache_Draw(
    15521551            IViewObject2*    iface,
    1553         DWORD            dwDrawAspect,
    1554         LONG             lindex,
    1555         void*            pvAspect,
    1556         DVTARGETDEVICE*  ptd,
    1557         HDC              hdcTargetDev,
    1558         HDC              hdcDraw,
    1559         LPCRECTL         lprcBounds,
    1560         LPCRECTL         lprcWBounds,
    1561         IVO_ContCallback pfnContinue,
    1562         DWORD            dwContinue)
     1552            DWORD            dwDrawAspect,
     1553            LONG             lindex,
     1554            void*            pvAspect,
     1555            DVTARGETDEVICE*  ptd,
     1556            HDC              hdcTargetDev,
     1557            HDC              hdcDraw,
     1558            LPCRECTL         lprcBounds,
     1559            LPCRECTL         lprcWBounds,
     1560            IVO_ContCallback pfnContinue,
     1561            DWORD            dwContinue)
    15631562{
    15641563  PresentationDataHeader presData;
     
    15691568
    15701569  TRACE("(%p, %lx, %ld, %p, %x, %x, %p, %p, %p, %lx)\n",
    1571     iface,
    1572     dwDrawAspect,
    1573     lindex,
    1574     pvAspect,
    1575     hdcTargetDev,
    1576     hdcDraw,
    1577     lprcBounds,
    1578     lprcWBounds,
    1579     pfnContinue,
    1580     dwContinue);
     1570        iface,
     1571        dwDrawAspect,
     1572        lindex,
     1573        pvAspect,
     1574        hdcTargetDev,
     1575        hdcDraw,
     1576        lprcBounds,
     1577        lprcWBounds,
     1578        pfnContinue,
     1579        dwContinue);
    15811580
    15821581  /*
     
    15911590   */
    15921591  hres = DataCache_ReadPresentationData(this,
    1593                     dwDrawAspect,
    1594                     &presData);
     1592                                        dwDrawAspect,
     1593                                        &presData);
    15951594
    15961595  if (FAILED(hres))
     
    16051604   */
    16061605  presMetafile = DataCache_ReadPresMetafile(this,
    1607                         dwDrawAspect);
     1606                                            dwDrawAspect);
    16081607
    16091608  /*
     
    16201619
    16211620    SetWindowExtEx(hdcDraw,
    1622            presData.dwObjectExtentX,
    1623            presData.dwObjectExtentY,
    1624            &oldWindowExt);
    1625 
    1626     SetViewportExtEx(hdcDraw,
    1627              lprcBounds->right - lprcBounds->left,
    1628              lprcBounds->bottom - lprcBounds->top,
    1629              &oldViewportExt);
     1621                   presData.dwObjectExtentX,
     1622                   presData.dwObjectExtentY,
     1623                   &oldWindowExt);
     1624
     1625    SetViewportExtEx(hdcDraw, 
     1626                     lprcBounds->right - lprcBounds->left,
     1627                     lprcBounds->bottom - lprcBounds->top,
     1628                     &oldViewportExt);
    16301629
    16311630    SetViewportOrgEx(hdcDraw,
    1632              lprcBounds->left,
    1633              lprcBounds->top,
    1634              &oldViewportOrg);
     1631                     lprcBounds->left,
     1632                     lprcBounds->top,
     1633                     &oldViewportOrg);
    16351634
    16361635    PlayMetaFile(hdcDraw, presMetafile);
    16371636
    16381637    SetWindowExtEx(hdcDraw,
    1639            oldWindowExt.cx,
    1640            oldWindowExt.cy,
    1641            NULL);
    1642 
    1643     SetViewportExtEx(hdcDraw,
    1644              oldViewportExt.cx,
    1645              oldViewportExt.cy,
    1646              NULL);
     1638                   oldWindowExt.cx,
     1639                   oldWindowExt.cy,
     1640                   NULL);
     1641
     1642    SetViewportExtEx(hdcDraw, 
     1643                     oldViewportExt.cx,
     1644                     oldViewportExt.cy,
     1645                     NULL);
    16471646
    16481647    SetViewportOrgEx(hdcDraw,
    1649              oldViewportOrg.x,
    1650              oldViewportOrg.y,
    1651              NULL);
     1648                     oldViewportOrg.x,
     1649                     oldViewportOrg.y,
     1650                     NULL);
    16521651
    16531652    SetMapMode(hdcDraw, prevMapMode);
     
    16601659
    16611660static HRESULT WINAPI DataCache_GetColorSet(
    1662             IViewObject2*   iface,
    1663         DWORD           dwDrawAspect,
    1664         LONG            lindex,
    1665         void*           pvAspect,
    1666         DVTARGETDEVICE* ptd,
    1667         HDC             hicTargetDevice,
    1668         LOGPALETTE**    ppColorSet)
     1661            IViewObject2*   iface, 
     1662            DWORD           dwDrawAspect,
     1663            LONG            lindex,
     1664            void*           pvAspect,
     1665            DVTARGETDEVICE* ptd,
     1666            HDC             hicTargetDevice,
     1667            LOGPALETTE**    ppColorSet)
    16691668{
    16701669  FIXME("stub\n");
     
    16741673static HRESULT WINAPI DataCache_Freeze(
    16751674            IViewObject2*   iface,
    1676         DWORD           dwDrawAspect,
    1677         LONG            lindex,
    1678         void*           pvAspect,
    1679         DWORD*          pdwFreeze)
     1675            DWORD           dwDrawAspect,
     1676            LONG            lindex,
     1677            void*           pvAspect,
     1678            DWORD*          pdwFreeze)
    16801679{
    16811680  FIXME("stub\n");
     
    16851684static HRESULT WINAPI DataCache_Unfreeze(
    16861685            IViewObject2*   iface,
    1687         DWORD           dwFreeze)
     1686            DWORD           dwFreeze)
    16881687{
    16891688  FIXME("stub\n");
     
    17011700static HRESULT WINAPI DataCache_SetAdvise(
    17021701            IViewObject2*   iface,
    1703         DWORD           aspects,
    1704         DWORD           advf,
    1705         IAdviseSink*    pAdvSink)
     1702            DWORD           aspects,
     1703            DWORD           advf,
     1704            IAdviseSink*    pAdvSink)
    17061705{
    17071706  _ICOM_THIS_From_IViewObject2(DataCache, iface);
     
    17161715    IAdviseSink_Release(this->sinkInterface);
    17171716    this->sinkInterface  = NULL;
    1718     this->sinkAspects    = 0;
     1717    this->sinkAspects    = 0; 
    17191718    this->sinkAdviseFlag = 0;
    17201719  }
     
    17261725  {
    17271726    this->sinkInterface  = pAdvSink;
    1728     this->sinkAspects    = aspects;
    1729     this->sinkAdviseFlag = advf;
     1727    this->sinkAspects    = aspects; 
     1728    this->sinkAdviseFlag = advf;   
    17301729
    17311730    IAdviseSink_AddRef(this->sinkInterface);
     
    17391738  {
    17401739    DataCache_FireOnViewChange(this,
    1741                    DVASPECT_CONTENT,
    1742                    -1);
     1740                               DVASPECT_CONTENT,
     1741                               -1);
    17431742  }
    17441743
     
    17491748 * DataCache_GetAdvise (IViewObject2)
    17501749 *
    1751  * This method queries the current state of the advise sink
     1750 * This method queries the current state of the advise sink 
    17521751 * installed on the data cache.
    17531752 *
     
    17551754 */
    17561755static HRESULT WINAPI DataCache_GetAdvise(
    1757             IViewObject2*   iface,
    1758         DWORD*          pAspects,
    1759         DWORD*          pAdvf,
    1760         IAdviseSink**   ppAdvSink)
     1756            IViewObject2*   iface, 
     1757            DWORD*          pAspects,
     1758            DWORD*          pAdvf,
     1759            IAdviseSink**   ppAdvSink)
    17611760{
    17621761  _ICOM_THIS_From_IViewObject2(DataCache, iface);
     
    17751774  if (ppAdvSink!=NULL)
    17761775  {
    1777     IAdviseSink_QueryInterface(this->sinkInterface,
    1778                    &IID_IAdviseSink,
    1779                    (void**)ppAdvSink);
     1776    IAdviseSink_QueryInterface(this->sinkInterface, 
     1777                               &IID_IAdviseSink,
     1778                               (void**)ppAdvSink);
    17801779  }
    17811780
     
    17911790 */
    17921791static HRESULT WINAPI DataCache_GetExtent(
    1793             IViewObject2*   iface,
    1794         DWORD           dwDrawAspect,
    1795         LONG            lindex,
    1796         DVTARGETDEVICE* ptd,
    1797         LPSIZEL         lpsizel)
     1792            IViewObject2*   iface, 
     1793            DWORD           dwDrawAspect,
     1794            LONG            lindex,
     1795            DVTARGETDEVICE* ptd,
     1796            LPSIZEL         lpsizel)
    17981797{
    17991798  PresentationDataHeader presData;
     
    18021801  _ICOM_THIS_From_IViewObject2(DataCache, iface);
    18031802
    1804   TRACE("(%p, %lx, %ld, %p, %p)\n",
    1805     iface, dwDrawAspect, lindex, ptd, lpsizel);
     1803  TRACE("(%p, %lx, %ld, %p, %p)\n", 
     1804        iface, dwDrawAspect, lindex, ptd, lpsizel);
    18061805
    18071806  /*
     
    18291828  if (ptd!=NULL)
    18301829    FIXME("Unimplemented ptd = %p\n", ptd);
    1831 
    1832   /*
    1833    * Get the presentation information from the
     1830 
     1831  /*
     1832   * Get the presentation information from the 
    18341833   * cache.
    18351834   */
    18361835  hres = DataCache_ReadPresentationData(this,
    1837                     dwDrawAspect,
    1838                     &presData);
     1836                                        dwDrawAspect,
     1837                                        &presData);
    18391838
    18401839  if (SUCCEEDED(hres))
     
    18711870  _ICOM_THIS_From_IOleCache2(DataCache, iface);
    18721871
    1873   return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject);
     1872  return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject); 
    18741873}
    18751874
     
    18791878 * See Windows documentation for more details on IUnknown methods.
    18801879 */
    1881 static ULONG WINAPI DataCache_IOleCache2_AddRef(
     1880static ULONG WINAPI DataCache_IOleCache2_AddRef( 
    18821881            IOleCache2*     iface)
    18831882{
    18841883  _ICOM_THIS_From_IOleCache2(DataCache, iface);
    18851884
    1886   return IUnknown_AddRef(this->outerUnknown);
     1885  return IUnknown_AddRef(this->outerUnknown); 
    18871886}
    18881887
     
    18921891 * See Windows documentation for more details on IUnknown methods.
    18931892 */
    1894 static ULONG WINAPI DataCache_IOleCache2_Release(
     1893static ULONG WINAPI DataCache_IOleCache2_Release( 
    18951894            IOleCache2*     iface)
    18961895{
    18971896  _ICOM_THIS_From_IOleCache2(DataCache, iface);
    18981897
    1899   return IUnknown_Release(this->outerUnknown);
     1898  return IUnknown_Release(this->outerUnknown); 
    19001899}
    19011900
    19021901static HRESULT WINAPI DataCache_Cache(
    19031902            IOleCache2*     iface,
    1904         FORMATETC*      pformatetc,
    1905         DWORD           advf,
    1906         DWORD*          pdwConnection)
     1903            FORMATETC*      pformatetc,
     1904            DWORD           advf,
     1905            DWORD*          pdwConnection)
    19071906{
    19081907  FIXME("stub\n");
     
    19111910
    19121911static HRESULT WINAPI DataCache_Uncache(
    1913         IOleCache2*     iface,
    1914         DWORD           dwConnection)
     1912            IOleCache2*     iface,
     1913            DWORD           dwConnection)
    19151914{
    19161915  FIXME("stub\n");
     
    19201919static HRESULT WINAPI DataCache_EnumCache(
    19211920            IOleCache2*     iface,
    1922         IEnumSTATDATA** ppenumSTATDATA)
     1921            IEnumSTATDATA** ppenumSTATDATA)
    19231922{
    19241923  FIXME("stub\n");
     
    19271926
    19281927static HRESULT WINAPI DataCache_InitCache(
    1929         IOleCache2*     iface,
    1930         IDataObject*    pDataObject)
     1928            IOleCache2*     iface,
     1929            IDataObject*    pDataObject)
    19311930{
    19321931  FIXME("stub\n");
     
    19361935static HRESULT WINAPI DataCache_IOleCache2_SetData(
    19371936            IOleCache2*     iface,
    1938         FORMATETC*      pformatetc,
    1939         STGMEDIUM*      pmedium,
    1940         BOOL            fRelease)
     1937            FORMATETC*      pformatetc,
     1938            STGMEDIUM*      pmedium,
     1939            BOOL            fRelease)
    19411940{
    19421941  FIXME("stub\n");
     
    19461945static HRESULT WINAPI DataCache_UpdateCache(
    19471946            IOleCache2*     iface,
    1948         LPDATAOBJECT    pDataObject,
    1949         DWORD           grfUpdf,
    1950         LPVOID          pReserved)
     1947            LPDATAOBJECT    pDataObject,
     1948            DWORD           grfUpdf,
     1949            LPVOID          pReserved)
    19511950{
    19521951  FIXME("stub\n");
     
    19561955static HRESULT WINAPI DataCache_DiscardCache(
    19571956            IOleCache2*     iface,
    1958         DWORD           dwDiscardOptions)
     1957            DWORD           dwDiscardOptions)
    19591958{
    19601959  FIXME("stub\n");
     
    19801979  _ICOM_THIS_From_IOleCacheControl(DataCache, iface);
    19811980
    1982   return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject);
     1981  return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject); 
    19831982}
    19841983
     
    19881987 * See Windows documentation for more details on IUnknown methods.
    19891988 */
    1990 static ULONG WINAPI DataCache_IOleCacheControl_AddRef(
     1989static ULONG WINAPI DataCache_IOleCacheControl_AddRef( 
    19911990            IOleCacheControl* iface)
    19921991{
    19931992  _ICOM_THIS_From_IOleCacheControl(DataCache, iface);
    19941993
    1995   return IUnknown_AddRef(this->outerUnknown);
     1994  return IUnknown_AddRef(this->outerUnknown); 
    19961995}
    19971996
     
    20012000 * See Windows documentation for more details on IUnknown methods.
    20022001 */
    2003 static ULONG WINAPI DataCache_IOleCacheControl_Release(
     2002static ULONG WINAPI DataCache_IOleCacheControl_Release( 
    20042003            IOleCacheControl* iface)
    20052004{
    20062005  _ICOM_THIS_From_IOleCacheControl(DataCache, iface);
    20072006
    2008   return IUnknown_Release(this->outerUnknown);
     2007  return IUnknown_Release(this->outerUnknown); 
    20092008}
    20102009
    20112010static HRESULT WINAPI DataCache_OnRun(
    2012         IOleCacheControl* iface,
    2013         LPDATAOBJECT      pDataObject)
     2011            IOleCacheControl* iface,
     2012            LPDATAOBJECT      pDataObject)
    20142013{
    20152014  FIXME("stub\n");
     
    20182017
    20192018static HRESULT WINAPI DataCache_OnStop(
    2020         IOleCacheControl* iface)
     2019            IOleCacheControl* iface)
    20212020{
    20222021  FIXME("stub\n");
  • trunk/src/ole32/defaulthandler.c

    r6648 r6711  
    1 /* $Id: defaulthandler.c,v 1.2 2001-09-05 13:17:08 bird Exp $ */
    21/*
    3  *  OLE 2 default object handler
     2 *      OLE 2 default object handler
    43 *
    54 *      Copyright 1999  Francis Beaudet
     
    2625 *   done in this area.
    2726 *
    28  * - Some functions still return E_NOTIMPL they have to be
     27 * - Some functions still return E_NOTIMPL they have to be 
    2928 *   implemented. Most of those are related to the running of the
    3029 *   actual server.
     
    5453   * List all interface VTables here
    5554   */
    56   ICOM_VTABLE(IOleObject)*      lpvtbl1;
     55  ICOM_VTABLE(IOleObject)*      lpvtbl1; 
    5756  ICOM_VTABLE(IUnknown)*        lpvtbl2;
    5857  ICOM_VTABLE(IDataObject)*     lpvtbl3;
     
    9190
    9291  /*
    93    * The IDataAdviseHolder maintains the data
     92   * The IDataAdviseHolder maintains the data 
    9493   * connections on behalf of the default handler.
    9594   */
     
    9998   * Name of the container and object contained
    10099   */
    101   LPWSTR containerApp;
     100  LPWSTR containerApp; 
    102101  LPWSTR containerObj;
    103102
     
    107106
    108107/*
    109  * Here, I define utility macros to help with the casting of the
     108 * Here, I define utility macros to help with the casting of the 
    110109 * "this" parameter.
    111110 * There is a version to accomodate all of the VTables implemented
     
    113112 */
    114113#define _ICOM_THIS_From_IOleObject(class,name)       class* this = (class*)name;
    115 #define _ICOM_THIS_From_NDIUnknown(class, name)      class* this = (class*)(((char*)name)-sizeof(void*));
    116 #define _ICOM_THIS_From_IDataObject(class, name)     class* this = (class*)(((char*)name)-2*sizeof(void*));
    117 #define _ICOM_THIS_From_IRunnableObject(class, name) class* this = (class*)(((char*)name)-3*sizeof(void*));
     114#define _ICOM_THIS_From_NDIUnknown(class, name)      class* this = (class*)(((char*)name)-sizeof(void*)); 
     115#define _ICOM_THIS_From_IDataObject(class, name)     class* this = (class*)(((char*)name)-2*sizeof(void*)); 
     116#define _ICOM_THIS_From_IRunnableObject(class, name) class* this = (class*)(((char*)name)-3*sizeof(void*)); 
    118117
    119118/*
     
    121120 */
    122121static DefaultHandler* DefaultHandler_Construct(REFCLSID  clsid,
    123                         LPUNKNOWN pUnkOuter);
     122                                                LPUNKNOWN pUnkOuter);
    124123static void            DefaultHandler_Destroy(DefaultHandler* ptrToDestroy);
    125124
     
    132131            REFIID         riid,
    133132            void**         ppvObject);
    134 static ULONG WINAPI DefaultHandler_NDIUnknown_AddRef(
     133static ULONG WINAPI DefaultHandler_NDIUnknown_AddRef( 
    135134            IUnknown*      iface);
    136 static ULONG WINAPI DefaultHandler_NDIUnknown_Release(
     135static ULONG WINAPI DefaultHandler_NDIUnknown_Release( 
    137136            IUnknown*      iface);
    138137
     
    145144            REFIID           riid,
    146145            void**           ppvObject);
    147 static ULONG WINAPI DefaultHandler_AddRef(
     146static ULONG WINAPI DefaultHandler_AddRef( 
    148147            IOleObject*        iface);
    149 static ULONG WINAPI DefaultHandler_Release(
     148static ULONG WINAPI DefaultHandler_Release( 
    150149            IOleObject*        iface);
    151150static HRESULT WINAPI DefaultHandler_SetClientSite(
    152         IOleObject*        iface,
    153         IOleClientSite*    pClientSite);
     151            IOleObject*        iface,
     152            IOleClientSite*    pClientSite);
    154153static HRESULT WINAPI DefaultHandler_GetClientSite(
    155         IOleObject*        iface,
    156         IOleClientSite**   ppClientSite);
     154            IOleObject*        iface,
     155            IOleClientSite**   ppClientSite);
    157156static HRESULT WINAPI DefaultHandler_SetHostNames(
    158         IOleObject*        iface,
    159         LPCOLESTR          szContainerApp,
    160         LPCOLESTR          szContainerObj);
     157            IOleObject*        iface,
     158            LPCOLESTR          szContainerApp,
     159            LPCOLESTR          szContainerObj);
    161160static HRESULT WINAPI DefaultHandler_Close(
    162         IOleObject*        iface,
    163         DWORD              dwSaveOption);
     161            IOleObject*        iface,
     162            DWORD              dwSaveOption);
    164163static HRESULT WINAPI DefaultHandler_SetMoniker(
    165         IOleObject*        iface,
    166         DWORD              dwWhichMoniker,
    167         IMoniker*          pmk);
     164            IOleObject*        iface,
     165            DWORD              dwWhichMoniker,
     166            IMoniker*          pmk);
    168167static HRESULT WINAPI DefaultHandler_GetMoniker(
    169         IOleObject*        iface,
    170         DWORD              dwAssign,
    171         DWORD              dwWhichMoniker,
    172         IMoniker**         ppmk);
     168            IOleObject*        iface,
     169            DWORD              dwAssign,
     170            DWORD              dwWhichMoniker,
     171            IMoniker**         ppmk);
    173172static HRESULT WINAPI DefaultHandler_InitFromData(
    174         IOleObject*        iface,
    175         IDataObject*       pDataObject,
    176         BOOL               fCreation,
    177         DWORD              dwReserved);
     173            IOleObject*        iface,
     174            IDataObject*       pDataObject,
     175            BOOL               fCreation,
     176            DWORD              dwReserved);
    178177static HRESULT WINAPI DefaultHandler_GetClipboardData(
    179         IOleObject*        iface,
    180         DWORD              dwReserved,
    181         IDataObject**      ppDataObject);
     178            IOleObject*        iface,
     179            DWORD              dwReserved,
     180            IDataObject**      ppDataObject);
    182181static HRESULT WINAPI DefaultHandler_DoVerb(
    183         IOleObject*        iface,
    184         LONG               iVerb,
     182            IOleObject*        iface,
     183            LONG               iVerb,
    185184#ifdef __WIN32OS2__
    186         LPMSG              lpmsg,
     185            LPMSG              lpmsg,
    187186#else
    188         struct tagMSG*     lpmsg,
     187            struct tagMSG*     lpmsg,
    189188#endif
    190         IOleClientSite*    pActiveSite,
    191         LONG               lindex,
    192         HWND               hwndParent,
    193         LPCRECT            lprcPosRect);
     189            IOleClientSite*    pActiveSite,
     190            LONG               lindex,
     191            HWND               hwndParent,
     192            LPCRECT            lprcPosRect);
    194193static HRESULT WINAPI DefaultHandler_EnumVerbs(
    195         IOleObject*        iface,
    196         IEnumOLEVERB**     ppEnumOleVerb);
     194            IOleObject*        iface,
     195            IEnumOLEVERB**     ppEnumOleVerb);
    197196static HRESULT WINAPI DefaultHandler_Update(
    198         IOleObject*        iface);
     197            IOleObject*        iface);
    199198static HRESULT WINAPI DefaultHandler_IsUpToDate(
    200         IOleObject*        iface);
     199            IOleObject*        iface);
    201200static HRESULT WINAPI DefaultHandler_GetUserClassID(
    202         IOleObject*        iface,
    203         CLSID*             pClsid);
     201            IOleObject*        iface,
     202            CLSID*             pClsid);
    204203static HRESULT WINAPI DefaultHandler_GetUserType(
    205         IOleObject*        iface,
    206         DWORD              dwFormOfType,
    207         LPOLESTR*          pszUserType);
     204            IOleObject*        iface,
     205            DWORD              dwFormOfType,
     206            LPOLESTR*          pszUserType);
    208207static HRESULT WINAPI DefaultHandler_SetExtent(
    209         IOleObject*        iface,
    210         DWORD              dwDrawAspect,
    211         SIZEL*             psizel);
     208            IOleObject*        iface,
     209            DWORD              dwDrawAspect,
     210            SIZEL*             psizel);
    212211static HRESULT WINAPI DefaultHandler_GetExtent(
    213         IOleObject*        iface,
    214         DWORD              dwDrawAspect,
    215         SIZEL*             psizel);
     212            IOleObject*        iface,
     213            DWORD              dwDrawAspect,
     214            SIZEL*             psizel);
    216215static HRESULT WINAPI DefaultHandler_Advise(
    217         IOleObject*        iface,
    218         IAdviseSink*       pAdvSink,
    219         DWORD*             pdwConnection);
     216            IOleObject*        iface,
     217            IAdviseSink*       pAdvSink,
     218            DWORD*             pdwConnection);
    220219static HRESULT WINAPI DefaultHandler_Unadvise(
    221         IOleObject*        iface,
    222         DWORD              dwConnection);
     220            IOleObject*        iface,
     221            DWORD              dwConnection);
    223222static HRESULT WINAPI DefaultHandler_EnumAdvise(
    224         IOleObject*        iface,
    225         IEnumSTATDATA**    ppenumAdvise);
     223            IOleObject*        iface,
     224            IEnumSTATDATA**    ppenumAdvise);
    226225static HRESULT WINAPI DefaultHandler_GetMiscStatus(
    227         IOleObject*        iface,
    228         DWORD              dwAspect,
    229         DWORD*             pdwStatus);
     226            IOleObject*        iface,
     227            DWORD              dwAspect,
     228            DWORD*             pdwStatus);
    230229static HRESULT WINAPI DefaultHandler_SetColorScheme(
    231         IOleObject*           iface,
    232         struct tagLOGPALETTE* pLogpal);
     230            IOleObject*           iface,
     231            struct tagLOGPALETTE* pLogpal);
    233232
    234233/*
     
    240239            REFIID           riid,
    241240            void**           ppvObject);
    242 static ULONG WINAPI DefaultHandler_IDataObject_AddRef(
     241static ULONG WINAPI DefaultHandler_IDataObject_AddRef( 
    243242            IDataObject*     iface);
    244 static ULONG WINAPI DefaultHandler_IDataObject_Release(
     243static ULONG WINAPI DefaultHandler_IDataObject_Release( 
    245244            IDataObject*     iface);
    246245static HRESULT WINAPI DefaultHandler_GetData(
    247         IDataObject*     iface,
    248         LPFORMATETC      pformatetcIn,
    249         STGMEDIUM*       pmedium);
     246            IDataObject*     iface,
     247            LPFORMATETC      pformatetcIn,
     248            STGMEDIUM*       pmedium);
    250249static HRESULT WINAPI DefaultHandler_GetDataHere(
    251         IDataObject*     iface,
    252         LPFORMATETC      pformatetc,
    253         STGMEDIUM*       pmedium);
     250            IDataObject*     iface,
     251            LPFORMATETC      pformatetc,
     252            STGMEDIUM*       pmedium);
    254253static HRESULT WINAPI DefaultHandler_QueryGetData(
    255         IDataObject*     iface,
    256         LPFORMATETC      pformatetc);
     254            IDataObject*     iface,
     255            LPFORMATETC      pformatetc);
    257256static HRESULT WINAPI DefaultHandler_GetCanonicalFormatEtc(
    258         IDataObject*     iface,
    259         LPFORMATETC      pformatectIn,
    260         LPFORMATETC      pformatetcOut);
     257            IDataObject*     iface,
     258            LPFORMATETC      pformatectIn,
     259            LPFORMATETC      pformatetcOut);
    261260static HRESULT WINAPI DefaultHandler_SetData(
    262         IDataObject*     iface,
    263         LPFORMATETC      pformatetc,
    264         STGMEDIUM*       pmedium,
    265         BOOL             fRelease);
     261            IDataObject*     iface,
     262            LPFORMATETC      pformatetc,
     263            STGMEDIUM*       pmedium,
     264            BOOL             fRelease);
    266265static HRESULT WINAPI DefaultHandler_EnumFormatEtc(
    267         IDataObject*     iface,
    268         DWORD            dwDirection,
    269         IEnumFORMATETC** ppenumFormatEtc);
     266            IDataObject*     iface,       
     267            DWORD            dwDirection,
     268            IEnumFORMATETC** ppenumFormatEtc);
    270269static HRESULT WINAPI DefaultHandler_DAdvise(
    271         IDataObject*     iface,
    272         FORMATETC*       pformatetc,
    273         DWORD            advf,
    274         IAdviseSink*     pAdvSink,
    275         DWORD*           pdwConnection);
     270            IDataObject*     iface,
     271            FORMATETC*       pformatetc,
     272            DWORD            advf,
     273            IAdviseSink*     pAdvSink,
     274            DWORD*           pdwConnection);
    276275static HRESULT WINAPI DefaultHandler_DUnadvise(
    277         IDataObject*     iface,
    278         DWORD            dwConnection);
     276            IDataObject*     iface,
     277            DWORD            dwConnection);
    279278static HRESULT WINAPI DefaultHandler_EnumDAdvise(
    280         IDataObject*     iface,
    281         IEnumSTATDATA**  ppenumAdvise);
     279            IDataObject*     iface,
     280            IEnumSTATDATA**  ppenumAdvise);
    282281
    283282/*
     
    289288            REFIID               riid,
    290289            void**               ppvObject);
    291 static ULONG WINAPI DefaultHandler_IRunnableObject_AddRef(
     290static ULONG WINAPI DefaultHandler_IRunnableObject_AddRef( 
    292291            IRunnableObject*     iface);
    293 static ULONG WINAPI DefaultHandler_IRunnableObject_Release(
     292static ULONG WINAPI DefaultHandler_IRunnableObject_Release( 
    294293            IRunnableObject*     iface);
    295 static HRESULT WINAPI DefaultHandler_GetRunningClass(
     294static HRESULT WINAPI DefaultHandler_GetRunningClass(
     295            IRunnableObject*     iface,   
     296            LPCLSID              lpClsid);
     297static HRESULT WINAPI DefaultHandler_Run(
    296298            IRunnableObject*     iface,
    297         LPCLSID              lpClsid);
    298 static HRESULT WINAPI DefaultHandler_Run(
    299             IRunnableObject*     iface,
    300         IBindCtx*            pbc);
    301 static BOOL    WINAPI DefaultHandler_IsRunning(
     299            IBindCtx*            pbc);
     300static BOOL    WINAPI DefaultHandler_IsRunning(
    302301            IRunnableObject*     iface);
    303 static HRESULT WINAPI DefaultHandler_LockRunning(
    304             IRunnableObject*     iface,
    305         BOOL                 fLock,
    306         BOOL                 fLastUnlockCloses);
    307 static HRESULT WINAPI DefaultHandler_SetContainedObject(
    308             IRunnableObject*     iface,
    309         BOOL                 fContained);
     302static HRESULT WINAPI DefaultHandler_LockRunning( 
     303            IRunnableObject*     iface, 
     304            BOOL                 fLock,
     305            BOOL                 fLastUnlockCloses);
     306static HRESULT WINAPI DefaultHandler_SetContainedObject( 
     307            IRunnableObject*     iface, 
     308            BOOL                 fContained);
    310309
    311310
     
    408407   * IUnknown pointer can be returned to the outside.
    409408   */
    410   if ( (pUnkOuter!=NULL) &&
     409  if ( (pUnkOuter!=NULL) && 
    411410       (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) != 0) )
    412411    return CLASS_E_NOAGGREGATION;
     
    415414   * Try to construct a new instance of the class.
    416415   */
    417   newHandler = DefaultHandler_Construct(clsid,
    418                     pUnkOuter);
     416  newHandler = DefaultHandler_Construct(clsid, 
     417                                        pUnkOuter);
    419418
    420419  if (newHandler == 0)
     
    451450  if (newObject==0)
    452451    return newObject;
    453 
     452 
    454453  /*
    455454   * Initialize the virtual function table.
     
    461460
    462461  /*
    463    * Start with one reference count. The caller of this function
     462   * Start with one reference count. The caller of this function 
    464463   * must release the interface pointer when it is done.
    465464   */
     
    468467  /*
    469468   * Initialize the outer unknown
    470    * We don't keep a reference on the outer unknown since, the way
     469   * We don't keep a reference on the outer unknown since, the way 
    471470   * aggregation works, our lifetime is at least as large as it's
    472471   * lifetime.
     
    480479   * Create a datacache object.
    481480   * We aggregate with the datacache. Make sure we pass our outer
    482    * unknown as the datacache's outer unknown.
     481   * unknown as the datacache's outer unknown. 
    483482   */
    484483  CreateDataCache(newObject->outerUnknown,
    485           clsid,
    486           &IID_IUnknown,
    487           (void**)&newObject->dataCache);
     484                  clsid,
     485                  &IID_IUnknown,
     486                  (void**)&newObject->dataCache);
    488487
    489488  /*
     
    517516    ptrToDestroy->containerObj = NULL;
    518517  }
    519 
     518 
    520519  /*
    521520   * Release our reference to the data cache.
     
    586585  if ( (this==0) || (ppvObject==0) )
    587586    return E_INVALIDARG;
    588 
     587 
    589588  /*
    590589   * Initialize the return parameter.
     
    595594   * Compare the riid with the interface IDs implemented by this object.
    596595   */
    597   if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0)
     596  if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0) 
    598597  {
    599598    *ppvObject = iface;
    600599  }
    601   else if (memcmp(&IID_IOleObject, riid, sizeof(IID_IOleObject)) == 0)
     600  else if (memcmp(&IID_IOleObject, riid, sizeof(IID_IOleObject)) == 0) 
    602601  {
    603602    *ppvObject = (IOleObject*)&(this->lpvtbl1);
    604603  }
    605   else if (memcmp(&IID_IDataObject, riid, sizeof(IID_IDataObject)) == 0)
     604  else if (memcmp(&IID_IDataObject, riid, sizeof(IID_IDataObject)) == 0) 
    606605  {
    607606    *ppvObject = (IDataObject*)&(this->lpvtbl3);
    608607  }
    609   else if (memcmp(&IID_IRunnableObject, riid, sizeof(IID_IRunnableObject)) == 0)
     608  else if (memcmp(&IID_IRunnableObject, riid, sizeof(IID_IRunnableObject)) == 0) 
    610609  {
    611610    *ppvObject = (IRunnableObject*)&(this->lpvtbl4);
     
    617616     */
    618617    if (IUnknown_QueryInterface(this->dataCache, riid, ppvObject) == S_OK)
    619     return S_OK;
    620   }
    621 
     618        return S_OK;
     619  }
     620 
    622621  /*
    623622   * Check that we obtained an interface.
     
    628627    return E_NOINTERFACE;
    629628  }
    630 
     629 
    631630  /*
    632631   * Query Interface always increases the reference count by one when it is
    633    * successful.
     632   * successful. 
    634633   */
    635634  IUnknown_AddRef((IUnknown*)*ppvObject);
    636635
    637   return S_OK;;
     636  return S_OK;; 
    638637}
    639638
     
    646645 * to the outer unknown.
    647646 */
    648 static ULONG WINAPI DefaultHandler_NDIUnknown_AddRef(
     647static ULONG WINAPI DefaultHandler_NDIUnknown_AddRef( 
    649648            IUnknown*      iface)
    650649{
     
    664663 * to the outer unknown.
    665664 */
    666 static ULONG WINAPI DefaultHandler_NDIUnknown_Release(
     665static ULONG WINAPI DefaultHandler_NDIUnknown_Release( 
    667666            IUnknown*      iface)
    668667{
     
    683682    return 0;
    684683  }
    685 
     684 
    686685  return this->ref;
    687686}
     
    704703  _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
    705704
    706   return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject);
     705  return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject); 
    707706}
    708707
     
    712711 * See Windows documentation for more details on IUnknown methods.
    713712 */
    714 static ULONG WINAPI DefaultHandler_AddRef(
     713static ULONG WINAPI DefaultHandler_AddRef( 
    715714            IOleObject*        iface)
    716715{
     
    725724 * See Windows documentation for more details on IUnknown methods.
    726725 */
    727 static ULONG WINAPI DefaultHandler_Release(
     726static ULONG WINAPI DefaultHandler_Release( 
    728727            IOleObject*        iface)
    729728{
     
    742741 */
    743742static HRESULT WINAPI DefaultHandler_SetClientSite(
    744         IOleObject*        iface,
    745         IOleClientSite*    pClientSite)
     743            IOleObject*        iface,
     744            IOleClientSite*    pClientSite)
    746745{
    747746  _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
     
    777776 */
    778777static HRESULT WINAPI DefaultHandler_GetClientSite(
    779         IOleObject*        iface,
    780         IOleClientSite**   ppClientSite)
     778            IOleObject*        iface,
     779            IOleClientSite**   ppClientSite)
    781780{
    782781  _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
     
    807806 */
    808807static HRESULT WINAPI DefaultHandler_SetHostNames(
    809         IOleObject*        iface,
    810         LPCOLESTR          szContainerApp,
    811         LPCOLESTR          szContainerObj)
     808            IOleObject*        iface,
     809            LPCOLESTR          szContainerApp,
     810            LPCOLESTR          szContainerObj)
    812811{
    813812  _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
    814813
    815814  TRACE("(%p, %s, %s)\n",
    816     iface,
    817     debugstr_w(szContainerApp),
    818     debugstr_w(szContainerObj));
     815        iface,
     816        debugstr_w(szContainerApp),
     817        debugstr_w(szContainerObj));
    819818
    820819  /*
    821820   * Be sure to cleanup before re-assinging the strings.
    822    */
     821   */ 
    823822  if (this->containerApp!=NULL)
    824823  {
     
    861860 */
    862861static HRESULT WINAPI DefaultHandler_Close(
    863         IOleObject*        iface,
    864         DWORD              dwSaveOption)
     862            IOleObject*        iface,
     863            DWORD              dwSaveOption)
    865864{
    866865  TRACE("()\n");
     
    876875 */
    877876static HRESULT WINAPI DefaultHandler_SetMoniker(
    878         IOleObject*        iface,
    879         DWORD              dwWhichMoniker,
    880         IMoniker*          pmk)
     877            IOleObject*        iface,
     878            DWORD              dwWhichMoniker,
     879            IMoniker*          pmk)
    881880{
    882881  TRACE("(%p, %ld, %p)\n",
    883     iface,
    884     dwWhichMoniker,
    885     pmk);
     882        iface,
     883        dwWhichMoniker,
     884        pmk);
    886885
    887886  return S_OK;
     
    896895 */
    897896static HRESULT WINAPI DefaultHandler_GetMoniker(
    898         IOleObject*        iface,
    899         DWORD              dwAssign,
    900         DWORD              dwWhichMoniker,
    901         IMoniker**         ppmk)
     897            IOleObject*        iface,
     898            DWORD              dwAssign,
     899            DWORD              dwWhichMoniker,
     900            IMoniker**         ppmk)
    902901{
    903902  _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
    904903
    905904  TRACE("(%p, %ld, %ld, %p)\n",
    906     iface, dwAssign, dwWhichMoniker, ppmk);
     905        iface, dwAssign, dwWhichMoniker, ppmk);
    907906
    908907  if (this->clientSite)
    909908  {
    910909    return IOleClientSite_GetMoniker(this->clientSite,
    911                      dwAssign,
    912                      dwWhichMoniker,
    913                      ppmk);
    914 
     910                                     dwAssign,
     911                                     dwWhichMoniker,
     912                                     ppmk);
     913                             
    915914  }
    916915
     
    922921 *
    923922 * This method is meaningless if the server is not running
    924  *
     923 * 
    925924 * See Windows documentation for more details on IOleObject methods.
    926925 */
    927926static HRESULT WINAPI DefaultHandler_InitFromData(
    928         IOleObject*        iface,
    929         IDataObject*       pDataObject,
    930         BOOL               fCreation,
    931         DWORD              dwReserved)
     927            IOleObject*        iface,
     928            IDataObject*       pDataObject,
     929            BOOL               fCreation,
     930            DWORD              dwReserved)
    932931{
    933932  TRACE("(%p, %p, %d, %ld)\n",
    934     iface, pDataObject, fCreation, dwReserved);
     933        iface, pDataObject, fCreation, dwReserved);
    935934
    936935  return OLE_E_NOTRUNNING;
     
    941940 *
    942941 * This method is meaningless if the server is not running
    943  *
     942 * 
    944943 * See Windows documentation for more details on IOleObject methods.
    945944 */
    946945static HRESULT WINAPI DefaultHandler_GetClipboardData(
    947         IOleObject*        iface,
    948         DWORD              dwReserved,
    949         IDataObject**      ppDataObject)
     946            IOleObject*        iface,
     947            DWORD              dwReserved,
     948            IDataObject**      ppDataObject)
    950949{
    951950  TRACE("(%p, %ld, %p)\n",
    952     iface, dwReserved, ppDataObject);
     951        iface, dwReserved, ppDataObject);
    953952
    954953  return OLE_E_NOTRUNNING;
     
    956955
    957956static HRESULT WINAPI DefaultHandler_DoVerb(
    958         IOleObject*        iface,
    959         LONG               iVerb,
     957            IOleObject*        iface,
     958            LONG               iVerb,
    960959#ifdef __WIN32OS2__
    961         LPMSG              lpmsg,
     960            LPMSG              lpmsg,
    962961#else
    963         struct tagMSG*     lpmsg,
     962            struct tagMSG*     lpmsg,
    964963#endif
    965         IOleClientSite*    pActiveSite,
    966         LONG               lindex,
    967         HWND               hwndParent,
    968         LPCRECT            lprcPosRect)
     964            IOleClientSite*    pActiveSite,
     965            LONG               lindex,
     966            HWND               hwndParent,
     967            LPCRECT            lprcPosRect)
    969968{
    970969  FIXME(": Stub\n");
     
    977976 * The default handler implementation of this method simply delegates
    978977 * to OleRegEnumVerbs
    979  *
     978 * 
    980979 * See Windows documentation for more details on IOleObject methods.
    981980 */
    982981static HRESULT WINAPI DefaultHandler_EnumVerbs(
    983         IOleObject*        iface,
    984         IEnumOLEVERB**     ppEnumOleVerb)
     982            IOleObject*        iface,
     983            IEnumOLEVERB**     ppEnumOleVerb)
    985984{
    986985  _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
     
    992991
    993992static HRESULT WINAPI DefaultHandler_Update(
    994         IOleObject*        iface)
     993            IOleObject*        iface)
    995994{
    996995  FIXME(": Stub\n");
     
    10021001 *
    10031002 * This method is meaningless if the server is not running
    1004  *
     1003 * 
    10051004 * See Windows documentation for more details on IOleObject methods.
    10061005 */
    10071006static HRESULT WINAPI DefaultHandler_IsUpToDate(
    1008         IOleObject*        iface)
     1007            IOleObject*        iface)
    10091008{
    10101009  TRACE("(%p)\n", iface);
     
    10171016 *
    10181017 * TODO: Map to a new class ID if emulation is active.
    1019  *
     1018 * 
    10201019 * See Windows documentation for more details on IOleObject methods.
    10211020 */
    10221021static HRESULT WINAPI DefaultHandler_GetUserClassID(
    1023         IOleObject*        iface,
    1024         CLSID*             pClsid)
     1022            IOleObject*        iface,
     1023            CLSID*             pClsid)
    10251024{
    10261025  _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
     
    10441043 * The default handler implementation of this method simply delegates
    10451044 * to OleRegGetUserType
    1046  *
     1045 * 
    10471046 * See Windows documentation for more details on IOleObject methods.
    10481047 */
    10491048static HRESULT WINAPI DefaultHandler_GetUserType(
    1050         IOleObject*        iface,
    1051         DWORD              dwFormOfType,
    1052         LPOLESTR*          pszUserType)
     1049            IOleObject*        iface,
     1050            DWORD              dwFormOfType,
     1051            LPOLESTR*          pszUserType)
    10531052{
    10541053  _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
     
    10671066 */
    10681067static HRESULT WINAPI DefaultHandler_SetExtent(
    1069         IOleObject*        iface,
    1070         DWORD              dwDrawAspect,
    1071         SIZEL*             psizel)
     1068            IOleObject*        iface,
     1069            DWORD              dwDrawAspect,
     1070            SIZEL*             psizel)
    10721071{
    10731072  TRACE("(%p, %lx, (%ld x %ld))\n", iface,
     
    10851084 */
    10861085static HRESULT WINAPI DefaultHandler_GetExtent(
    1087         IOleObject*        iface,
    1088         DWORD              dwDrawAspect,
    1089         SIZEL*             psizel)
     1086            IOleObject*        iface,
     1087            DWORD              dwDrawAspect,
     1088            SIZEL*             psizel)
    10901089{
    10911090  DVTARGETDEVICE* targetDevice;
     
    10931092  HRESULT         hres;
    10941093
    1095   _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
     1094  _ICOM_THIS_From_IOleObject(DefaultHandler, iface); 
    10961095
    10971096  TRACE("(%p, %lx, %p)\n", iface, dwDrawAspect, psizel);
     
    11061105   *
    11071106   * Here we would build a valid DVTARGETDEVICE structure
    1108    * but, since we are calling into the data cache, we
    1109    * know it's implementation and we'll skip this
     1107   * but, since we are calling into the data cache, we 
     1108   * know it's implementation and we'll skip this 
    11101109   * extra work until later.
    11111110   */
     
    11131112
    11141113  hres = IViewObject2_GetExtent(cacheView,
    1115                 dwDrawAspect,
    1116                 -1,
    1117                 targetDevice,
    1118                 psizel);
     1114                                dwDrawAspect,
     1115                                -1,
     1116                                targetDevice,
     1117                                psizel);
    11191118
    11201119  /*
     
    11351134 */
    11361135static HRESULT WINAPI DefaultHandler_Advise(
    1137         IOleObject*        iface,
    1138         IAdviseSink*       pAdvSink,
    1139         DWORD*             pdwConnection)
     1136            IOleObject*        iface,
     1137            IAdviseSink*       pAdvSink,
     1138            DWORD*             pdwConnection)
    11401139{
    11411140  HRESULT hres = S_OK;
    1142   _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
     1141  _ICOM_THIS_From_IOleObject(DefaultHandler, iface); 
    11431142
    11441143  TRACE("(%p, %p, %p)\n", iface, pAdvSink, pdwConnection);
     
    11541153  if (SUCCEEDED(hres))
    11551154  {
    1156     hres = IOleAdviseHolder_Advise(this->oleAdviseHolder,
    1157                    pAdvSink,
    1158                    pdwConnection);
     1155    hres = IOleAdviseHolder_Advise(this->oleAdviseHolder, 
     1156                                   pAdvSink,
     1157                                   pdwConnection);
    11591158  }
    11601159
     
    11711170 */
    11721171static HRESULT WINAPI DefaultHandler_Unadvise(
    1173         IOleObject*        iface,
    1174         DWORD              dwConnection)
    1175 {
    1176   _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
     1172            IOleObject*        iface,
     1173            DWORD              dwConnection)
     1174{
     1175  _ICOM_THIS_From_IOleObject(DefaultHandler, iface); 
    11771176
    11781177  TRACE("(%p, %ld)\n", iface, dwConnection);
     
    11861185
    11871186  return IOleAdviseHolder_Unadvise(this->oleAdviseHolder,
    1188                    dwConnection);
     1187                                   dwConnection);
    11891188}
    11901189
     
    11981197 */
    11991198static HRESULT WINAPI DefaultHandler_EnumAdvise(
    1200         IOleObject*        iface,
    1201         IEnumSTATDATA**    ppenumAdvise)
    1202 {
    1203   _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
     1199            IOleObject*        iface,
     1200            IEnumSTATDATA**    ppenumAdvise)
     1201{
     1202  _ICOM_THIS_From_IOleObject(DefaultHandler, iface); 
    12041203
    12051204  TRACE("(%p, %p)\n", iface, ppenumAdvise);
     
    12181217  if (this->oleAdviseHolder==NULL)
    12191218    return IOleAdviseHolder_EnumAdvise(this->oleAdviseHolder,
    1220                        ppenumAdvise);
     1219                                       ppenumAdvise);
    12211220
    12221221  return S_OK;
     
    12321231 */
    12331232static HRESULT WINAPI DefaultHandler_GetMiscStatus(
    1234         IOleObject*        iface,
    1235         DWORD              dwAspect,
    1236         DWORD*             pdwStatus)
     1233            IOleObject*        iface,
     1234            DWORD              dwAspect,
     1235            DWORD*             pdwStatus)
    12371236{
    12381237  HRESULT hres;
     
    12571256 */
    12581257static HRESULT WINAPI DefaultHandler_SetColorScheme(
    1259         IOleObject*           iface,
    1260         struct tagLOGPALETTE* pLogpal)
     1258            IOleObject*           iface,
     1259            struct tagLOGPALETTE* pLogpal)
    12611260{
    12621261  TRACE("(%p, %p))\n", iface, pLogpal);
     
    12751274 */
    12761275static HRESULT WINAPI DefaultHandler_IDataObject_QueryInterface(
    1277             IDataObject*     iface,
     1276            IDataObject*     iface, 
    12781277           REFIID           riid,
    12791278            void**           ppvObject)
     
    12811280  _ICOM_THIS_From_IDataObject(DefaultHandler, iface);
    12821281
    1283   return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject);
     1282  return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject); 
    12841283}
    12851284
     
    12891288 * See Windows documentation for more details on IUnknown methods.
    12901289 */
    1291 static ULONG WINAPI DefaultHandler_IDataObject_AddRef(
     1290static ULONG WINAPI DefaultHandler_IDataObject_AddRef( 
    12921291            IDataObject*     iface)
    12931292{
    12941293  _ICOM_THIS_From_IDataObject(DefaultHandler, iface);
    12951294
    1296   return IUnknown_AddRef(this->outerUnknown);
     1295  return IUnknown_AddRef(this->outerUnknown); 
    12971296}
    12981297
     
    13021301 * See Windows documentation for more details on IUnknown methods.
    13031302 */
    1304 static ULONG WINAPI DefaultHandler_IDataObject_Release(
     1303static ULONG WINAPI DefaultHandler_IDataObject_Release( 
    13051304            IDataObject*     iface)
    13061305{
    13071306  _ICOM_THIS_From_IDataObject(DefaultHandler, iface);
    13081307
    1309   return IUnknown_Release(this->outerUnknown);
     1308  return IUnknown_Release(this->outerUnknown); 
    13101309}
    13111310
     
    13181317 */
    13191318static HRESULT WINAPI DefaultHandler_GetData(
    1320         IDataObject*     iface,
    1321         LPFORMATETC      pformatetcIn,
    1322         STGMEDIUM*       pmedium)
     1319            IDataObject*     iface,
     1320            LPFORMATETC      pformatetcIn,
     1321            STGMEDIUM*       pmedium)
    13231322{
    13241323  IDataObject* cacheDataObject = NULL;
     
    13291328  TRACE("(%p, %p, %p)\n", iface, pformatetcIn, pmedium);
    13301329
    1331   hres = IUnknown_QueryInterface(this->dataCache,
    1332                 &IID_IDataObject,
    1333                 (void**)&cacheDataObject);
     1330  hres = IUnknown_QueryInterface(this->dataCache, 
     1331                                &IID_IDataObject,
     1332                                (void**)&cacheDataObject);
    13341333
    13351334  if (FAILED(hres))
     
    13371336
    13381337  hres = IDataObject_GetData(cacheDataObject,
    1339                  pformatetcIn,
    1340                  pmedium);
    1341 
     1338                             pformatetcIn,
     1339                             pmedium);
     1340 
    13421341  IDataObject_Release(cacheDataObject);
    1343 
     1342 
    13441343  return hres;
    13451344}
    13461345
    13471346static HRESULT WINAPI DefaultHandler_GetDataHere(
    1348         IDataObject*     iface,
    1349         LPFORMATETC      pformatetc,
    1350         STGMEDIUM*       pmedium)
     1347            IDataObject*     iface,
     1348            LPFORMATETC      pformatetc,
     1349            STGMEDIUM*       pmedium)
    13511350{
    13521351  FIXME(": Stub\n");
     
    13571356 * DefaultHandler_QueryGetData (IDataObject)
    13581357 *
    1359  * The default handler's implementation of this method delegates to
     1358 * The default handler's implementation of this method delegates to 
    13601359 * the cache.
    13611360 *
     
    13631362 */
    13641363static HRESULT WINAPI DefaultHandler_QueryGetData(
    1365         IDataObject*     iface,
    1366         LPFORMATETC      pformatetc)
     1364            IDataObject*     iface,
     1365            LPFORMATETC      pformatetc)
    13671366{
    13681367  IDataObject* cacheDataObject = NULL;
     
    13731372  TRACE("(%p, %p)\n", iface, pformatetc);
    13741373
    1375   hres = IUnknown_QueryInterface(this->dataCache,
    1376                 &IID_IDataObject,
    1377                 (void**)&cacheDataObject);
     1374  hres = IUnknown_QueryInterface(this->dataCache, 
     1375                                &IID_IDataObject,
     1376                                (void**)&cacheDataObject);
    13781377
    13791378  if (FAILED(hres))
     
    13811380
    13821381  hres = IDataObject_QueryGetData(cacheDataObject,
    1383                   pformatetc);
     1382                                  pformatetc);
    13841383
    13851384  IDataObject_Release(cacheDataObject);
    1386 
     1385 
    13871386  return hres;
    13881387}
     
    13961395 */
    13971396static HRESULT WINAPI DefaultHandler_GetCanonicalFormatEtc(
    1398         IDataObject*     iface,
    1399         LPFORMATETC      pformatectIn,
    1400         LPFORMATETC      pformatetcOut)
     1397            IDataObject*     iface,
     1398            LPFORMATETC      pformatectIn,
     1399            LPFORMATETC      pformatetcOut)
    14011400{
    14021401  FIXME("(%p, %p, %p)\n", iface, pformatectIn, pformatetcOut);
     
    14081407 * DefaultHandler_SetData (IDataObject)
    14091408 *
    1410  * The default handler's implementation of this method delegates to
     1409 * The default handler's implementation of this method delegates to 
    14111410 * the cache.
    14121411 *
     
    14141413 */
    14151414static HRESULT WINAPI DefaultHandler_SetData(
    1416         IDataObject*     iface,
    1417         LPFORMATETC      pformatetc,
    1418         STGMEDIUM*       pmedium,
    1419         BOOL             fRelease)
     1415            IDataObject*     iface,
     1416            LPFORMATETC      pformatetc,
     1417            STGMEDIUM*       pmedium,
     1418            BOOL             fRelease)
    14201419{
    14211420  IDataObject* cacheDataObject = NULL;
     
    14261425  TRACE("(%p, %p, %p, %d)\n", iface, pformatetc, pmedium, fRelease);
    14271426
    1428   hres = IUnknown_QueryInterface(this->dataCache,
    1429                 &IID_IDataObject,
    1430                 (void**)&cacheDataObject);
     1427  hres = IUnknown_QueryInterface(this->dataCache, 
     1428                                &IID_IDataObject,
     1429                                (void**)&cacheDataObject);
    14311430
    14321431  if (FAILED(hres))
     
    14341433
    14351434  hres = IDataObject_SetData(cacheDataObject,
    1436                  pformatetc,
    1437                  pmedium,
    1438                  fRelease);
    1439 
     1435                             pformatetc,
     1436                             pmedium,
     1437                             fRelease);
     1438 
    14401439  IDataObject_Release(cacheDataObject);
    1441 
     1440 
    14421441  return hres;
    14431442}
     
    14521451 */
    14531452static HRESULT WINAPI DefaultHandler_EnumFormatEtc(
    1454         IDataObject*     iface,
    1455         DWORD            dwDirection,
    1456         IEnumFORMATETC** ppenumFormatEtc)
     1453            IDataObject*     iface,       
     1454            DWORD            dwDirection,
     1455            IEnumFORMATETC** ppenumFormatEtc)
    14571456{
    14581457  HRESULT hres;
     
    14751474 */
    14761475static HRESULT WINAPI DefaultHandler_DAdvise(
    1477         IDataObject*     iface,
    1478         FORMATETC*       pformatetc,
    1479         DWORD            advf,
    1480         IAdviseSink*     pAdvSink,
    1481         DWORD*           pdwConnection)
     1476            IDataObject*     iface,
     1477            FORMATETC*       pformatetc,
     1478            DWORD            advf,
     1479            IAdviseSink*     pAdvSink,
     1480            DWORD*           pdwConnection)
    14821481{
    14831482  HRESULT hres = S_OK;
    1484   _ICOM_THIS_From_IDataObject(DefaultHandler, iface);
    1485 
    1486   TRACE("(%p, %p, %ld, %p, %p)\n",
    1487     iface, pformatetc, advf, pAdvSink, pdwConnection);
     1483  _ICOM_THIS_From_IDataObject(DefaultHandler, iface); 
     1484
     1485  TRACE("(%p, %p, %ld, %p, %p)\n", 
     1486        iface, pformatetc, advf, pAdvSink, pdwConnection);
    14881487
    14891488  /*
     
    14971496  if (SUCCEEDED(hres))
    14981497  {
    1499     hres = IDataAdviseHolder_Advise(this->dataAdviseHolder,
    1500                     iface,
    1501                     pformatetc,
    1502                     advf,
    1503                     pAdvSink,
    1504                     pdwConnection);
     1498    hres = IDataAdviseHolder_Advise(this->dataAdviseHolder, 
     1499                                    iface,
     1500                                    pformatetc,
     1501                                    advf,
     1502                                    pAdvSink,
     1503                                    pdwConnection);
    15051504  }
    15061505
     
    15171516 */
    15181517static HRESULT WINAPI DefaultHandler_DUnadvise(
    1519         IDataObject*     iface,
    1520         DWORD            dwConnection)
    1521 {
    1522   _ICOM_THIS_From_IDataObject(DefaultHandler, iface);
     1518            IDataObject*     iface,
     1519            DWORD            dwConnection)
     1520{
     1521  _ICOM_THIS_From_IDataObject(DefaultHandler, iface); 
    15231522
    15241523  TRACE("(%p, %ld)\n", iface, dwConnection);
     
    15331532  }
    15341533
    1535   return IDataAdviseHolder_Unadvise(this->dataAdviseHolder,
    1536                     dwConnection);
     1534  return IDataAdviseHolder_Unadvise(this->dataAdviseHolder, 
     1535                                    dwConnection);
    15371536}
    15381537
     
    15461545 */
    15471546static HRESULT WINAPI DefaultHandler_EnumDAdvise(
    1548         IDataObject*     iface,
    1549         IEnumSTATDATA**  ppenumAdvise)
    1550 {
    1551   _ICOM_THIS_From_IDataObject(DefaultHandler, iface);
     1547            IDataObject*     iface,
     1548            IEnumSTATDATA**  ppenumAdvise)
     1549{
     1550  _ICOM_THIS_From_IDataObject(DefaultHandler, iface); 
    15521551
    15531552  TRACE("(%p, %p)\n", iface, ppenumAdvise);
     
    15691568  if (this->dataAdviseHolder!=NULL)
    15701569  {
    1571     return IDataAdviseHolder_EnumAdvise(this->dataAdviseHolder,
    1572                     ppenumAdvise);
     1570    return IDataAdviseHolder_EnumAdvise(this->dataAdviseHolder, 
     1571                                        ppenumAdvise);
    15731572  }
    15741573
     
    15771576
    15781577/*********************************************************
    1579  * Methods implementation for the IRunnableObject part
     1578 * Methods implementation for the IRunnableObject part 
    15801579 * of the DefaultHandler class.
    15811580 */
     
    15931592  _ICOM_THIS_From_IRunnableObject(DefaultHandler, iface);
    15941593
    1595   return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject);
     1594  return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject); 
    15961595}
    15971596
     
    16011600 * See Windows documentation for more details on IUnknown methods.
    16021601 */
    1603 static ULONG WINAPI DefaultHandler_IRunnableObject_AddRef(
     1602static ULONG WINAPI DefaultHandler_IRunnableObject_AddRef( 
    16041603            IRunnableObject*     iface)
    16051604{
     
    16141613 * See Windows documentation for more details on IUnknown methods.
    16151614 */
    1616 static ULONG WINAPI DefaultHandler_IRunnableObject_Release(
     1615static ULONG WINAPI DefaultHandler_IRunnableObject_Release( 
    16171616            IRunnableObject*     iface)
    16181617{
     
    16251624 * DefaultHandler_GetRunningClass (IRunnableObject)
    16261625 *
    1627  * According to Brockscmidt, Chapter 19, the default handler's
     1626 * According to Brockscmidt, Chapter 19, the default handler's 
    16281627 * implementation of IRunnableobject does nothing until the object
    16291628 * is actually running.
     
    16311630 * See Windows documentation for more details on IRunnableObject methods.
    16321631 */
    1633 static HRESULT WINAPI DefaultHandler_GetRunningClass(
    1634             IRunnableObject*     iface,
    1635         LPCLSID              lpClsid)
     1632static HRESULT WINAPI DefaultHandler_GetRunningClass( 
     1633            IRunnableObject*     iface,   
     1634            LPCLSID              lpClsid)
    16361635{
    16371636  TRACE("()\n");
     
    16391638}
    16401639
    1641 static HRESULT WINAPI DefaultHandler_Run(
     1640static HRESULT WINAPI DefaultHandler_Run( 
    16421641            IRunnableObject*     iface,
    1643         IBindCtx*            pbc)
     1642            IBindCtx*            pbc)
    16441643{
    16451644  FIXME(": Stub\n");
     
    16501649 * DefaultHandler_IsRunning (IRunnableObject)
    16511650 *
    1652  * According to Brockscmidt, Chapter 19, the default handler's
     1651 * According to Brockscmidt, Chapter 19, the default handler's 
    16531652 * implementation of IRunnableobject does nothing until the object
    16541653 * is actually running.
     
    16561655 * See Windows documentation for more details on IRunnableObject methods.
    16571656 */
    1658 static BOOL    WINAPI DefaultHandler_IsRunning(
     1657static BOOL    WINAPI DefaultHandler_IsRunning( 
    16591658            IRunnableObject*     iface)
    16601659{
     
    16661665 * DefaultHandler_LockRunning (IRunnableObject)
    16671666 *
    1668  * According to Brockscmidt, Chapter 19, the default handler's
     1667 * According to Brockscmidt, Chapter 19, the default handler's 
    16691668 * implementation of IRunnableobject does nothing until the object
    16701669 * is actually running.
     
    16721671 * See Windows documentation for more details on IRunnableObject methods.
    16731672 */
    1674 static HRESULT WINAPI DefaultHandler_LockRunning(
    1675             IRunnableObject*     iface,
    1676         BOOL                 fLock,
    1677         BOOL                 fLastUnlockCloses)
     1673static HRESULT WINAPI DefaultHandler_LockRunning( 
     1674            IRunnableObject*     iface, 
     1675            BOOL                 fLock,
     1676            BOOL                 fLastUnlockCloses)
    16781677{
    16791678  TRACE("()\n");
     
    16841683 * DefaultHandler_SetContainedObject (IRunnableObject)
    16851684 *
    1686  * According to Brockscmidt, Chapter 19, the default handler's
     1685 * According to Brockscmidt, Chapter 19, the default handler's 
    16871686 * implementation of IRunnableobject does nothing until the object
    16881687 * is actually running.
     
    16901689 * See Windows documentation for more details on IRunnableObject methods.
    16911690 */
    1692 static HRESULT WINAPI DefaultHandler_SetContainedObject(
    1693             IRunnableObject*     iface,
    1694         BOOL                 fContained)
     1691static HRESULT WINAPI DefaultHandler_SetContainedObject( 
     1692            IRunnableObject*     iface, 
     1693            BOOL                 fContained)
    16951694{
    16961695  TRACE("()\n");
  • trunk/src/ole32/errorinfo.c

    r6648 r6711  
    1 /* $Id: errorinfo.c,v 1.3 2001-09-05 13:17:09 bird Exp $ */
    21/*
    32 * ErrorInfo API
     
    65 *
    76 *
    8  * The errorinfo is a per-thread object. The reference is stored in the
     7 * The errorinfo is a per-thread object. The reference is stored in the 
    98 * TEB at offset 0xf80
    109 */
     
    3130    WCHAR* stringBuffer;
    3231    DWORD len;
    33 
     32   
    3433    if (in == NULL)
    35     return NULL;
     34        return NULL;
    3635    /*
    3736     * Find the lenth of the buffer passed-in in bytes.
     
    9089{
    9190    DWORD* bufferPointer;
    92 
     91   
    9392    /* NULL is a valid parameter */
    9493    if(!in) return;
     
    112111typedef struct ErrorInfoImpl
    113112{
    114     ICOM_VTABLE(IErrorInfo)     *lpvtei;
    115     ICOM_VTABLE(ICreateErrorInfo)   *lpvtcei;
    116     ICOM_VTABLE(ISupportErrorInfo)  *lpvtsei;
    117     DWORD               ref;
    118 
    119     GUID m_Guid;
    120     BSTR bstrSource;
    121     BSTR bstrDescription;
    122     BSTR bstrHelpFile;
    123     DWORD m_dwHelpContext;
     113        ICOM_VTABLE(IErrorInfo)         *lpvtei;
     114        ICOM_VTABLE(ICreateErrorInfo)   *lpvtcei;
     115        ICOM_VTABLE(ISupportErrorInfo)  *lpvtsei;
     116        DWORD                           ref;
     117       
     118        GUID m_Guid;
     119        BSTR bstrSource;
     120        BSTR bstrDescription;
     121        BSTR bstrHelpFile;
     122        DWORD m_dwHelpContext;
    124123} ErrorInfoImpl;
    125124
    126 static ICOM_VTABLE(IErrorInfo)      IErrorInfoImpl_VTable;
    127 static ICOM_VTABLE(ICreateErrorInfo)    ICreateErrorInfoImpl_VTable;
    128 static ICOM_VTABLE(ISupportErrorInfo)   ISupportErrorInfoImpl_VTable;
     125static ICOM_VTABLE(IErrorInfo)          IErrorInfoImpl_VTable;
     126static ICOM_VTABLE(ICreateErrorInfo)    ICreateErrorInfoImpl_VTable;
     127static ICOM_VTABLE(ISupportErrorInfo)   ISupportErrorInfoImpl_VTable;
    129128
    130129/*
    131130 converts a objectpointer to This
    132131 */
    133 #define _IErrorInfo_Offset ((int)(&(((ErrorInfoImpl*)0)->lpvtei)))
    134 #define _ICOM_THIS_From_IErrorInfo(class, name) class* This = (class*)(((char*)name)-_IErrorInfo_Offset);
    135 
    136 #define _ICreateErrorInfo_Offset ((int)(&(((ErrorInfoImpl*)0)->lpvtcei)))
    137 #define _ICOM_THIS_From_ICreateErrorInfo(class, name) class* This = (class*)(((char*)name)-_ICreateErrorInfo_Offset);
    138 
    139 #define _ISupportErrorInfo_Offset ((int)(&(((ErrorInfoImpl*)0)->lpvtsei)))
    140 #define _ICOM_THIS_From_ISupportErrorInfo(class, name) class* This = (class*)(((char*)name)-_ISupportErrorInfo_Offset);
     132#define _IErrorInfo_Offset ((int)(&(((ErrorInfoImpl*)0)->lpvtei))) 
     133#define _ICOM_THIS_From_IErrorInfo(class, name) class* This = (class*)(((char*)name)-_IErrorInfo_Offset); 
     134
     135#define _ICreateErrorInfo_Offset ((int)(&(((ErrorInfoImpl*)0)->lpvtcei))) 
     136#define _ICOM_THIS_From_ICreateErrorInfo(class, name) class* This = (class*)(((char*)name)-_ICreateErrorInfo_Offset); 
     137
     138#define _ISupportErrorInfo_Offset ((int)(&(((ErrorInfoImpl*)0)->lpvtsei))) 
     139#define _ICOM_THIS_From_ISupportErrorInfo(class, name) class* This = (class*)(((char*)name)-_ISupportErrorInfo_Offset); 
    141140
    142141/*
    143142 converts This to a objectpointer
    144143 */
    145 #define _IErrorInfo_(This)      (IErrorInfo*)&(This->lpvtei)
    146 #define _ICreateErrorInfo_(This)    (ICreateErrorInfo*)&(This->lpvtcei)
    147 #define _ISupportErrorInfo_(This)   (ISupportErrorInfo*)&(This->lpvtsei)
     144#define _IErrorInfo_(This)              (IErrorInfo*)&(This->lpvtei)
     145#define _ICreateErrorInfo_(This)        (ICreateErrorInfo*)&(This->lpvtcei)
     146#define _ISupportErrorInfo_(This)       (ISupportErrorInfo*)&(This->lpvtsei)
    148147
    149148IErrorInfo * IErrorInfoImpl_Constructor()
    150149{
    151     ErrorInfoImpl * ei = HeapAlloc(GetProcessHeap(), 0, sizeof(ErrorInfoImpl));
    152     if (ei)
    153     {
    154       ei->lpvtei = &IErrorInfoImpl_VTable;
    155       ei->lpvtcei = &ICreateErrorInfoImpl_VTable;
    156       ei->lpvtsei = &ISupportErrorInfoImpl_VTable;
    157       ei->ref = 1;
    158       ei->bstrSource = NULL;
    159       ei->bstrDescription = NULL;
    160       ei->bstrHelpFile = NULL;
    161       ei->m_dwHelpContext = 0;
    162     }
    163     return (IErrorInfo *)ei;
     150        ErrorInfoImpl * ei = HeapAlloc(GetProcessHeap(), 0, sizeof(ErrorInfoImpl));
     151        if (ei)
     152        {
     153          ei->lpvtei = &IErrorInfoImpl_VTable;
     154          ei->lpvtcei = &ICreateErrorInfoImpl_VTable;
     155          ei->lpvtsei = &ISupportErrorInfoImpl_VTable;
     156          ei->ref = 1;
     157          ei->bstrSource = NULL;
     158          ei->bstrDescription = NULL;
     159          ei->bstrHelpFile = NULL;
     160          ei->m_dwHelpContext = 0;
     161        }
     162        return (IErrorInfo *)ei;
    164163}
    165164
    166165
    167166static HRESULT WINAPI IErrorInfoImpl_QueryInterface(
    168     IErrorInfo* iface,
    169     REFIID     riid,
    170     VOID**     ppvoid)
    171 {
    172     _ICOM_THIS_From_IErrorInfo(ErrorInfoImpl, iface);
    173     TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,debugstr_guid(riid),ppvoid);
    174 
    175     *ppvoid = NULL;
    176 
    177     if(IsEqualIID(riid, &IID_IErrorInfo))
    178     {
    179       *ppvoid = _IErrorInfo_(This);
    180     }
    181     else if(IsEqualIID(riid, &IID_ICreateErrorInfo))
    182     {
    183       *ppvoid = _ICreateErrorInfo_(This);
    184     }
    185     else if(IsEqualIID(riid, &IID_ISupportErrorInfo))
    186     {
    187       *ppvoid = _ISupportErrorInfo_(This);
    188     }
    189 
    190     if(*ppvoid)
    191     {
    192       IUnknown_AddRef( (IUnknown*)*ppvoid );
    193       TRACE("-- Interface: (%p)->(%p)\n",ppvoid,*ppvoid);
    194       return S_OK;
    195     }
    196     TRACE("-- Interface: E_NOINTERFACE\n");
    197     return E_NOINTERFACE;
     167        IErrorInfo* iface,
     168        REFIID     riid,
     169        VOID**     ppvoid)
     170{
     171        _ICOM_THIS_From_IErrorInfo(ErrorInfoImpl, iface);
     172        TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,debugstr_guid(riid),ppvoid);
     173
     174        *ppvoid = NULL;
     175
     176        if(IsEqualIID(riid, &IID_IErrorInfo))
     177        {
     178          *ppvoid = _IErrorInfo_(This);
     179        }
     180        else if(IsEqualIID(riid, &IID_ICreateErrorInfo))
     181        {
     182          *ppvoid = _ICreateErrorInfo_(This);
     183        }
     184        else if(IsEqualIID(riid, &IID_ISupportErrorInfo))
     185        {
     186          *ppvoid = _ISupportErrorInfo_(This);
     187        }
     188
     189        if(*ppvoid)
     190        {
     191          IUnknown_AddRef( (IUnknown*)*ppvoid );
     192          TRACE("-- Interface: (%p)->(%p)\n",ppvoid,*ppvoid);
     193          return S_OK;
     194        }
     195        TRACE("-- Interface: E_NOINTERFACE\n");
     196        return E_NOINTERFACE;
    198197}
    199198
    200199static ULONG WINAPI IErrorInfoImpl_AddRef(
    201     IErrorInfo* iface)
    202 {
    203     _ICOM_THIS_From_IErrorInfo(ErrorInfoImpl, iface);
    204     TRACE("(%p)->(count=%lu)\n",This,This->ref);
    205     return InterlockedIncrement(&This->ref);
     200        IErrorInfo* iface)
     201{
     202        _ICOM_THIS_From_IErrorInfo(ErrorInfoImpl, iface);
     203        TRACE("(%p)->(count=%lu)\n",This,This->ref);
     204        return InterlockedIncrement(&This->ref);
    206205}
    207206
    208207static ULONG WINAPI IErrorInfoImpl_Release(
    209     IErrorInfo* iface)
    210 {
    211     _ICOM_THIS_From_IErrorInfo(ErrorInfoImpl, iface);
    212     TRACE("(%p)->(count=%lu)\n",This,This->ref);
    213 
    214     if (!InterlockedDecrement(&This->ref))
    215     {
    216       TRACE("-- destroying IErrorInfo(%p)\n",This);
    217       HeapFree(GetProcessHeap(),0,This);
    218       return 0;
    219     }
    220     return This->ref;
     208        IErrorInfo* iface)
     209{
     210        _ICOM_THIS_From_IErrorInfo(ErrorInfoImpl, iface);
     211        TRACE("(%p)->(count=%lu)\n",This,This->ref);
     212
     213        if (!InterlockedDecrement(&This->ref))
     214        {
     215          TRACE("-- destroying IErrorInfo(%p)\n",This);
     216          HeapFree(GetProcessHeap(),0,This);
     217          return 0;
     218        }
     219        return This->ref;
    221220}
    222221
    223222static HRESULT WINAPI IErrorInfoImpl_GetGUID(
    224     IErrorInfo* iface,
    225     GUID * pGUID)
    226 {
    227     _ICOM_THIS_From_IErrorInfo(ErrorInfoImpl, iface);
    228     TRACE("(%p)->(count=%lu)\n",This,This->ref);
    229     if(!pGUID )return E_INVALIDARG;
    230     memcpy(pGUID, &This->m_Guid, sizeof(GUID));
    231     return S_OK;
     223        IErrorInfo* iface,
     224        GUID * pGUID)
     225{
     226        _ICOM_THIS_From_IErrorInfo(ErrorInfoImpl, iface);
     227        TRACE("(%p)->(count=%lu)\n",This,This->ref);
     228        if(!pGUID )return E_INVALIDARG;
     229        memcpy(pGUID, &This->m_Guid, sizeof(GUID));
     230        return S_OK;
    232231}
    233232
    234233static HRESULT WINAPI IErrorInfoImpl_GetSource(
    235     IErrorInfo* iface,
    236     BSTR *pBstrSource)
    237 {
    238     _ICOM_THIS_From_IErrorInfo(ErrorInfoImpl, iface);
    239     TRACE("(%p)->(pBstrSource=%p)\n",This,pBstrSource);
    240     if (pBstrSource == NULL)
    241         return E_INVALIDARG;
    242     *pBstrSource = ERRORINFO_SysAllocString(This->bstrSource);
    243     return S_OK;
     234        IErrorInfo* iface,
     235        BSTR *pBstrSource)
     236{
     237        _ICOM_THIS_From_IErrorInfo(ErrorInfoImpl, iface);
     238        TRACE("(%p)->(pBstrSource=%p)\n",This,pBstrSource);
     239        if (pBstrSource == NULL)
     240            return E_INVALIDARG;
     241        *pBstrSource = ERRORINFO_SysAllocString(This->bstrSource);
     242        return S_OK;
    244243}
    245244
    246245static HRESULT WINAPI IErrorInfoImpl_GetDescription(
    247     IErrorInfo* iface,
    248     BSTR *pBstrDescription)
    249 {
    250     _ICOM_THIS_From_IErrorInfo(ErrorInfoImpl, iface);
    251 
    252     TRACE("(%p)->(pBstrDescription=%p)\n",This,pBstrDescription);
    253     if (pBstrDescription == NULL)
    254         return E_INVALIDARG;
    255     *pBstrDescription = ERRORINFO_SysAllocString(This->bstrDescription);
    256 
    257     return S_OK;
     246        IErrorInfo* iface,
     247        BSTR *pBstrDescription)
     248{
     249        _ICOM_THIS_From_IErrorInfo(ErrorInfoImpl, iface);
     250
     251        TRACE("(%p)->(pBstrDescription=%p)\n",This,pBstrDescription);
     252        if (pBstrDescription == NULL)
     253            return E_INVALIDARG;
     254        *pBstrDescription = ERRORINFO_SysAllocString(This->bstrDescription);
     255       
     256        return S_OK;
    258257}
    259258
    260259static HRESULT WINAPI IErrorInfoImpl_GetHelpFile(
    261     IErrorInfo* iface,
    262     BSTR *pBstrHelpFile)
    263 {
    264     _ICOM_THIS_From_IErrorInfo(ErrorInfoImpl, iface);
    265 
    266     TRACE("(%p)->(pBstrHelpFile=%p)\n",This, pBstrHelpFile);
    267     if (pBstrHelpFile == NULL)
    268         return E_INVALIDARG;
    269     *pBstrHelpFile = ERRORINFO_SysAllocString(This->bstrHelpFile);
    270 
    271     return S_OK;
     260        IErrorInfo* iface,
     261        BSTR *pBstrHelpFile)
     262{
     263        _ICOM_THIS_From_IErrorInfo(ErrorInfoImpl, iface);
     264
     265        TRACE("(%p)->(pBstrHelpFile=%p)\n",This, pBstrHelpFile);
     266        if (pBstrHelpFile == NULL)
     267            return E_INVALIDARG;
     268        *pBstrHelpFile = ERRORINFO_SysAllocString(This->bstrHelpFile);
     269       
     270        return S_OK;
    272271}
    273272
    274273static HRESULT WINAPI IErrorInfoImpl_GetHelpContext(
    275     IErrorInfo* iface,
    276     DWORD *pdwHelpContext)
    277 {
    278     _ICOM_THIS_From_IErrorInfo(ErrorInfoImpl, iface);
    279     TRACE("(%p)->(pdwHelpContext=%p)\n",This, pdwHelpContext);
    280     if (pdwHelpContext == NULL)
    281         return E_INVALIDARG;
    282     *pdwHelpContext = This->m_dwHelpContext;
    283 
    284     return S_OK;
     274        IErrorInfo* iface,
     275        DWORD *pdwHelpContext)
     276{
     277        _ICOM_THIS_From_IErrorInfo(ErrorInfoImpl, iface);
     278        TRACE("(%p)->(pdwHelpContext=%p)\n",This, pdwHelpContext);
     279        if (pdwHelpContext == NULL)
     280            return E_INVALIDARG;
     281        *pdwHelpContext = This->m_dwHelpContext;
     282       
     283        return S_OK;
    285284}
    286285
     
    291290  IErrorInfoImpl_AddRef,
    292291  IErrorInfoImpl_Release,
    293 
     292 
    294293  IErrorInfoImpl_GetGUID,
    295294  IErrorInfoImpl_GetSource,
     
    301300
    302301static HRESULT WINAPI ICreateErrorInfoImpl_QueryInterface(
    303     ICreateErrorInfo* iface,
    304     REFIID     riid,
    305     VOID**     ppvoid)
    306 {
    307     _ICOM_THIS_From_ICreateErrorInfo(ErrorInfoImpl, iface);
    308     TRACE("(%p)\n", This);
    309     return IErrorInfo_QueryInterface(_IErrorInfo_(This), riid, ppvoid);
     302        ICreateErrorInfo* iface,
     303        REFIID     riid,
     304        VOID**     ppvoid)
     305{
     306        _ICOM_THIS_From_ICreateErrorInfo(ErrorInfoImpl, iface);
     307        TRACE("(%p)\n", This);
     308        return IErrorInfo_QueryInterface(_IErrorInfo_(This), riid, ppvoid);
    310309}
    311310
    312311static ULONG WINAPI ICreateErrorInfoImpl_AddRef(
    313     ICreateErrorInfo* iface)
    314 {
    315     _ICOM_THIS_From_ICreateErrorInfo(ErrorInfoImpl, iface);
    316     TRACE("(%p)\n", This);
    317     return IErrorInfo_AddRef(_IErrorInfo_(This));
     312        ICreateErrorInfo* iface)
     313{
     314        _ICOM_THIS_From_ICreateErrorInfo(ErrorInfoImpl, iface);
     315        TRACE("(%p)\n", This);
     316        return IErrorInfo_AddRef(_IErrorInfo_(This));
    318317}
    319318
    320319static ULONG WINAPI ICreateErrorInfoImpl_Release(
    321     ICreateErrorInfo* iface)
    322 {
    323     _ICOM_THIS_From_ICreateErrorInfo(ErrorInfoImpl, iface);
    324     TRACE("(%p)\n", This);
    325     return IErrorInfo_Release(_IErrorInfo_(This));
     320        ICreateErrorInfo* iface)
     321{
     322        _ICOM_THIS_From_ICreateErrorInfo(ErrorInfoImpl, iface);
     323        TRACE("(%p)\n", This);
     324        return IErrorInfo_Release(_IErrorInfo_(This));
    326325}
    327326
    328327
    329328static HRESULT WINAPI ICreateErrorInfoImpl_SetGUID(
    330     ICreateErrorInfo* iface,
    331     REFGUID rguid)
    332 {
    333     _ICOM_THIS_From_ICreateErrorInfo(ErrorInfoImpl, iface);
    334     TRACE("(%p)->(%s)\n", This, debugstr_guid(rguid));
    335     memcpy(&This->m_Guid,  rguid, sizeof(GUID));
    336     return S_OK;
     329        ICreateErrorInfo* iface,
     330        REFGUID rguid)
     331{
     332        _ICOM_THIS_From_ICreateErrorInfo(ErrorInfoImpl, iface);
     333        TRACE("(%p)->(%s)\n", This, debugstr_guid(rguid));
     334        memcpy(&This->m_Guid,  rguid, sizeof(GUID));
     335        return S_OK;
    337336}
    338337
    339338static HRESULT WINAPI ICreateErrorInfoImpl_SetSource(
    340     ICreateErrorInfo* iface,
    341     LPOLESTR szSource)
    342 {
    343     _ICOM_THIS_From_ICreateErrorInfo(ErrorInfoImpl, iface);
    344     TRACE("(%p)\n",This);
    345     if (This->bstrSource != NULL)
    346         ERRORINFO_SysFreeString(This->bstrSource);
    347     This->bstrSource = ERRORINFO_SysAllocString(szSource);
    348 
    349     return S_OK;
     339        ICreateErrorInfo* iface,
     340        LPOLESTR szSource)
     341{
     342        _ICOM_THIS_From_ICreateErrorInfo(ErrorInfoImpl, iface);
     343        TRACE("(%p)\n",This);
     344        if (This->bstrSource != NULL)
     345            ERRORINFO_SysFreeString(This->bstrSource);
     346        This->bstrSource = ERRORINFO_SysAllocString(szSource);
     347       
     348        return S_OK;
    350349}
    351350
    352351static HRESULT WINAPI ICreateErrorInfoImpl_SetDescription(
    353     ICreateErrorInfo* iface,
    354     LPOLESTR szDescription)
    355 {
    356     _ICOM_THIS_From_ICreateErrorInfo(ErrorInfoImpl, iface);
    357     TRACE("(%p)\n",This);
    358     if (This->bstrDescription != NULL)
    359         ERRORINFO_SysFreeString(This->bstrDescription);
    360     This->bstrDescription = ERRORINFO_SysAllocString(szDescription);
    361 
    362     return S_OK;
     352        ICreateErrorInfo* iface,
     353        LPOLESTR szDescription)
     354{
     355        _ICOM_THIS_From_ICreateErrorInfo(ErrorInfoImpl, iface);
     356        TRACE("(%p)\n",This);
     357        if (This->bstrDescription != NULL)
     358            ERRORINFO_SysFreeString(This->bstrDescription);
     359        This->bstrDescription = ERRORINFO_SysAllocString(szDescription);
     360       
     361        return S_OK;
    363362}
    364363
    365364static HRESULT WINAPI ICreateErrorInfoImpl_SetHelpFile(
    366     ICreateErrorInfo* iface,
    367     LPOLESTR szHelpFile)
    368 {
    369     _ICOM_THIS_From_ICreateErrorInfo(ErrorInfoImpl, iface);
    370     TRACE("(%p)\n",This);
    371     if (This->bstrHelpFile != NULL)
    372         ERRORINFO_SysFreeString(This->bstrHelpFile);
    373     This->bstrHelpFile = ERRORINFO_SysAllocString(szHelpFile);
    374 
    375     return S_OK;
     365        ICreateErrorInfo* iface,
     366        LPOLESTR szHelpFile)
     367{
     368        _ICOM_THIS_From_ICreateErrorInfo(ErrorInfoImpl, iface);
     369        TRACE("(%p)\n",This);
     370        if (This->bstrHelpFile != NULL)
     371            ERRORINFO_SysFreeString(This->bstrHelpFile);
     372        This->bstrHelpFile = ERRORINFO_SysAllocString(szHelpFile);
     373
     374        return S_OK;
    376375}
    377376
    378377static HRESULT WINAPI ICreateErrorInfoImpl_SetHelpContext(
    379     ICreateErrorInfo* iface,
    380     DWORD dwHelpContext)
    381 {
    382     _ICOM_THIS_From_ICreateErrorInfo(ErrorInfoImpl, iface);
    383     TRACE("(%p)\n",This);
    384     This->m_dwHelpContext = dwHelpContext;
    385 
    386     return S_OK;
     378        ICreateErrorInfo* iface,
     379        DWORD dwHelpContext)
     380{
     381        _ICOM_THIS_From_ICreateErrorInfo(ErrorInfoImpl, iface);
     382        TRACE("(%p)\n",This);
     383        This->m_dwHelpContext = dwHelpContext;
     384       
     385        return S_OK;
    387386}
    388387
     
    402401
    403402static HRESULT WINAPI ISupportErrorInfoImpl_QueryInterface(
    404     ISupportErrorInfo* iface,
    405     REFIID     riid,
    406     VOID**     ppvoid)
    407 {
    408     _ICOM_THIS_From_ISupportErrorInfo(ErrorInfoImpl, iface);
    409     TRACE("(%p)\n", This);
    410 
    411     return IErrorInfo_QueryInterface(_IErrorInfo_(This), riid, ppvoid);
     403        ISupportErrorInfo* iface,
     404        REFIID     riid,
     405        VOID**     ppvoid)
     406{
     407        _ICOM_THIS_From_ISupportErrorInfo(ErrorInfoImpl, iface);
     408        TRACE("(%p)\n", This);
     409       
     410        return IErrorInfo_QueryInterface(_IErrorInfo_(This), riid, ppvoid);
    412411}
    413412
    414413static ULONG WINAPI ISupportErrorInfoImpl_AddRef(
    415     ISupportErrorInfo* iface)
    416 {
    417     _ICOM_THIS_From_ISupportErrorInfo(ErrorInfoImpl, iface);
    418     TRACE("(%p)\n", This);
    419     return IErrorInfo_AddRef(_IErrorInfo_(This));
     414        ISupportErrorInfo* iface)
     415{
     416        _ICOM_THIS_From_ISupportErrorInfo(ErrorInfoImpl, iface);
     417        TRACE("(%p)\n", This);
     418        return IErrorInfo_AddRef(_IErrorInfo_(This));
    420419}
    421420
    422421static ULONG WINAPI ISupportErrorInfoImpl_Release(
    423     ISupportErrorInfo* iface)
    424 {
    425     _ICOM_THIS_From_ISupportErrorInfo(ErrorInfoImpl, iface);
    426     TRACE("(%p)\n", This);
    427     return IErrorInfo_Release(_IErrorInfo_(This));
     422        ISupportErrorInfo* iface)
     423{
     424        _ICOM_THIS_From_ISupportErrorInfo(ErrorInfoImpl, iface);
     425        TRACE("(%p)\n", This);
     426        return IErrorInfo_Release(_IErrorInfo_(This));
    428427}
    429428
    430429
    431430static HRESULT WINAPI ISupportErrorInfoImpl_InterfaceSupportsErrorInfo(
    432     ISupportErrorInfo* iface,
    433     REFIID riid)
    434 {
    435     _ICOM_THIS_From_ISupportErrorInfo(ErrorInfoImpl, iface);
    436     TRACE("(%p)->(%s)\n", This, debugstr_guid(riid));
    437     return (IsEqualIID(riid, &This->m_Guid)) ? S_OK : S_FALSE;
     431        ISupportErrorInfo* iface,
     432        REFIID riid)
     433{
     434        _ICOM_THIS_From_ISupportErrorInfo(ErrorInfoImpl, iface);
     435        TRACE("(%p)->(%s)\n", This, debugstr_guid(riid));
     436        return (IsEqualIID(riid, &This->m_Guid)) ? S_OK : S_FALSE;
    438437}
    439438
     
    449448};
    450449/***********************************************************************
    451  *      CreateErrorInfo
     450 *              CreateErrorInfo
    452451 */
    453452HRESULT WINAPI CreateErrorInfo(ICreateErrorInfo **pperrinfo)
    454453{
    455     IErrorInfo * pei;
    456     HRESULT res;
    457     TRACE("(%p): stub:\n", pperrinfo);
    458     if(! pperrinfo ) return E_INVALIDARG;
    459     if(!(pei=IErrorInfoImpl_Constructor()))return E_OUTOFMEMORY;
    460 
    461     res = IErrorInfo_QueryInterface(pei, &IID_ICreateErrorInfo, (LPVOID*)pperrinfo);
    462     IErrorInfo_Release(pei);
    463     return res;
     454        IErrorInfo * pei;
     455        HRESULT res;
     456        TRACE("(%p): stub:\n", pperrinfo);
     457        if(! pperrinfo ) return E_INVALIDARG;
     458        if(!(pei=IErrorInfoImpl_Constructor()))return E_OUTOFMEMORY;
     459       
     460        res = IErrorInfo_QueryInterface(pei, &IID_ICreateErrorInfo, (LPVOID*)pperrinfo);
     461        IErrorInfo_Release(pei);
     462        return res;
    464463}
    465464
    466465/***********************************************************************
    467  *      GetErrorInfo
     466 *              GetErrorInfo
    468467 */
    469468HRESULT WINAPI GetErrorInfo(ULONG dwReserved, IErrorInfo **pperrinfo)
    470469{
    471     TRACE("(%ld, %p, %p): stub:\n", dwReserved, pperrinfo, NtCurrentTeb()->ErrorInfo);
    472 
    473     if(! pperrinfo ) return E_INVALIDARG;
    474     if(!(*pperrinfo = (IErrorInfo*)(NtCurrentTeb()->ErrorInfo))) return S_FALSE;
    475 
    476     /* clear thread error state */
    477     NtCurrentTeb()->ErrorInfo = NULL;
    478     return S_OK;
     470        TRACE("(%ld, %p, %p): stub:\n", dwReserved, pperrinfo, NtCurrentTeb()->ErrorInfo);
     471
     472        if(! pperrinfo ) return E_INVALIDARG;
     473        if(!(*pperrinfo = (IErrorInfo*)(NtCurrentTeb()->ErrorInfo))) return S_FALSE;
     474
     475        /* clear thread error state */
     476        NtCurrentTeb()->ErrorInfo = NULL;
     477        return S_OK;
    479478}
    480479
    481480/***********************************************************************
    482  *      SetErrorInfo
     481 *              SetErrorInfo
    483482 */
    484483HRESULT WINAPI SetErrorInfo(ULONG dwReserved, IErrorInfo *perrinfo)
    485484{
    486     IErrorInfo * pei;
    487     TRACE("(%ld, %p): stub:\n", dwReserved, perrinfo);
    488 
    489     /* release old errorinfo */
    490     pei = (IErrorInfo*)NtCurrentTeb()->ErrorInfo;
    491     if(pei) IErrorInfo_Release(pei);
    492 
    493     /* set to new value */
    494     NtCurrentTeb()->ErrorInfo = perrinfo;
    495     if(perrinfo) IErrorInfo_AddRef(perrinfo);
    496     return S_OK;
    497 }
     485        IErrorInfo * pei;
     486        TRACE("(%ld, %p): stub:\n", dwReserved, perrinfo);
     487
     488        /* release old errorinfo */
     489        pei = (IErrorInfo*)NtCurrentTeb()->ErrorInfo;
     490        if(pei) IErrorInfo_Release(pei);
     491
     492        /* set to new value */
     493        NtCurrentTeb()->ErrorInfo = perrinfo;
     494        if(perrinfo) IErrorInfo_AddRef(perrinfo);
     495        return S_OK;
     496}
  • trunk/src/ole32/filemoniker.c

    r6648 r6711  
    1 /* $Id: filemoniker.c,v 1.2 2001-09-05 13:17:09 bird Exp $ */
    21/***************************************************************************************
    3  *                        FileMonikers implementation
     2 *                            FileMonikers implementation
    43 *
    54 *               Copyright 1999  Noomen Hamza
     
    2726    ICOM_VTABLE(IMoniker)*  lpvtbl1;  /* VTable relative to the IMoniker interface.*/
    2827
    29     /* The ROT (RunningObjectTable implementation) uses the IROTData interface to test whether
     28    /* The ROT (RunningObjectTable implementation) uses the IROTData interface to test whether 
    3029     * two monikers are equal. That's whay IROTData interface is implemented by monikers.
    3130     */
     
    137136{
    138137    ICOM_THIS(FileMonikerImpl,iface);
    139 
     138 
    140139  TRACE("(%p,%p,%p)\n",This,riid,ppvObject);
    141140
    142141    /* Perform a sanity check on the parameters.*/
    143142    if ( (This==0) || (ppvObject==0) )
    144     return E_INVALIDARG;
    145 
     143        return E_INVALIDARG;
     144 
    146145    /* Initialize the return parameter */
    147146  *ppvObject = 0;
     
    154153       )
    155154        *ppvObject = iface;
    156 
     155   
    157156    else if (IsEqualIID(&IID_IROTData, riid))
    158157        *ppvObject = (IROTData*)&(This->lpvtbl2);
     
    161160    if ((*ppvObject)==0)
    162161        return E_NOINTERFACE;
    163 
     162 
    164163    /* Query Interface always increases the reference count by one when it is successful */
    165164  FileMonikerImpl_AddRef(iface);
     
    213212
    214213    *pClassID = CLSID_FileMoniker;
    215 
     214       
    216215    return S_OK;
    217216}
     
    253252    if (bread!=sizeof(WORD) || wbuffer!=0)
    254253        return E_FAIL;
    255 
     254   
    256255    /* read filePath string length (plus one) */
    257256    res=IStream_Read(pStm,&length,sizeof(DWORD),&bread);
     
    269268    if (bread != sizeof(DWORD) || dwbuffer != 0xDEADFFFF)
    270269        return E_FAIL;
    271 
     270       
    272271    length--;
    273 
     272       
    274273    for(i=0;i<10;i++){
    275274        res=IStream_Read(pStm,&wbuffer,sizeof(WORD),&bread);
     
    277276            return E_FAIL;
    278277    }
    279 
     278   
    280279    if (length>8)
    281280        length=0;
    282 
     281       
    283282    doubleLenHex=doubleLenDec=2*length;
    284283    if (length > 5)
     
    291290    if (length==0)
    292291        return res;
    293 
     292       
    294293    res=IStream_Read(pStm,&dwbuffer,sizeof(DWORD),&bread);
    295294    if (bread!=sizeof(DWORD) || dwbuffer!=doubleLenHex)
     
    312311
    313312    HeapFree(GetProcessHeap(),0,filePathA);
    314 
     313   
    315314    return res;
    316315}
     
    325324    /* this function saves data of this object. In the begining I thougth that I have just to write
    326325     * the filePath string on Stream. But, when I tested this function whith windows programs samples !
    327      * I noted that it was not the case. So I analysed data written by this function on Windows system and
     326     * I noted that it was not the case. So I analysed data written by this function on Windows system and 
    328327     * what did this function do exactly ! but I have no idear a bout its logic !
    329328     * I guessed data who must be written on stream wich is:
     
    334333     */
    335334
    336     ICOM_THIS(FileMonikerImpl,iface);
     335    ICOM_THIS(FileMonikerImpl,iface);       
    337336
    338337    HRESULT res;
     
    369368    /* write a DWORD set to 0xDEADFFFF: constant */
    370369    res=IStream_Write(pStm,&constant1,sizeof(DWORD),NULL);
    371 
     370       
    372371    len--;
    373372    /* write 10 times a DWORD set to 0 : constants */
    374373    for(i=0;i<10;i++)
    375374        res=IStream_Write(pStm,&zero,sizeof(WORD),NULL);
    376 
     375       
    377376    if (len>8)
    378377        len=0;
    379 
     378       
    380379    doubleLenHex=doubleLenDec=2*len;
    381380    if (len > 5)
     
    416415
    417416    /* for more details see FileMonikerImpl_Save coments */
    418 
     417   
    419418    sizeMAx =  sizeof(WORD) +           /* first WORD is 0 */
    420419               sizeof(DWORD)+           /* length of filePath including "\0" in the end of the string */
     
    426425    if (len==0 || len > 8)
    427426        return S_OK;
    428 
     427   
    429428    sizeMAx += sizeof(DWORD)+           /* size of the unicode filePath: "\0" not included */
    430429               sizeof(WORD)+            /* constant : 0x3 */
    431430               len*sizeof(WCHAR);       /* unicde filePath string */
    432 
     431   
    433432    pcbSize->s.LowPart=sizeMAx;
    434433    pcbSize->s.HighPart=0;
     
    448447    WCHAR bkSlash[]={'\\',0};
    449448    BYTE addBkSlash;
    450 
     449   
    451450    TRACE("(%p,%p)\n",This,lpszPathName);
    452451
     
    493492
    494493        *This->filePathName=0;
    495 
     494   
    496495        for(i=0;tabStr[i]!=NULL;i++)
    497496            strcatW(This->filePathName,tabStr[i]);
    498 
     497   
    499498        if (addBkSlash)
    500499            strcatW(This->filePathName,bkSlash);
     
    539538    IClassFactory *pcf=0;
    540539    IClassActivator *pca=0;
    541 
    542     ICOM_THIS(FileMonikerImpl,iface);
     540   
     541    ICOM_THIS(FileMonikerImpl,iface);   
    543542
    544543    *ppvResult=0;
     
    547546
    548547    if(pmkToLeft==NULL){
    549 
     548       
    550549        res=IBindCtx_GetRunningObjectTable(pbc,&prot);
    551550
     
    579578
    580579            res=IMoniker_BindToObject(pmkToLeft,pbc,NULL,&IID_IClassActivator,(void**)&pca);
    581 
     580       
    582581            if (res==E_NOINTERFACE)
    583582                return MK_E_INTERMEDIATEINTERFACENOTSUPPORTED;
     
    598597
    599598            FIXME("()");
    600 
     599           
    601600            /*res=GetClassFile(This->filePathName,&clsID);
    602601
     
    634633    if (pcf!=NULL)
    635634        IClassFactory_Release(pcf);
    636 
     635   
    637636    return res;
    638637}
     
    737736
    738737    if (pmkRight==NULL)
    739     return E_INVALIDARG;
     738        return E_INVALIDARG;
    740739
    741740    *ppmkComposite=0;
    742 
     741   
    743742    IMoniker_IsSystemMoniker(pmkRight,&mkSys);
    744743
     
    769768        /* the length of the composed path string  is raised by the sum of the two paths lengths  */
    770769        newStr=HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR)*(lstrlenW(str1)+lstrlenW(str2)+1));
    771 
    772       if (newStr==NULL)
    773         return E_OUTOFMEMORY;
     770       
     771          if (newStr==NULL)
     772                return E_OUTOFMEMORY;
    774773
    775774        /* new path is the concatenation of the rest of str1 and str2 */
     
    779778        if ((strDec2[i]==NULL && lastIdx1>-1 && lastIdx2>-1) || lstrcmpW(strDec2[i],bkSlash)!=0)
    780779            strcatW(newStr,bkSlash);
    781 
     780           
    782781        for(j=i;j<=lastIdx2;j++)
    783782            strcatW(newStr,strDec2[j]);
    784 
     783       
    785784        /* create a new moniker with the new string */
    786785        res=CreateFileMoniker(newStr,ppmkComposite);
     
    858857
    859858    IMoniker_GetDisplayName(pmkOtherMoniker,bind,NULL,&filePath);
    860 
     859   
    861860    if (lstrcmpiW(filePath,
    862861                  This->filePathName)!=0)
    863862
    864863        return S_FALSE;
    865 
     864   
    866865    return S_OK;
    867866}
     
    880879    if (pdwHash==NULL)
    881880        return E_POINTER;
    882 
     881   
    883882    val =  This->filePathName;
    884883    len = lstrlenW(val);
     
    887886        for (i = len ; i > 0; i--) {
    888887            h = (h * 37) + val[off++];
    889     }
     888        }
    890889    } else {
    891890        /* only sample some characters */
    892     skip = len / 8;
    893     for (i = len ; i > 0; i -= skip, off += skip) {
     891        skip = len / 8;
     892        for (i = len ; i > 0; i -= skip, off += skip) {
    894893            h = (h * 39) + val[off];
    895     }
     894        }
    896895}
    897896
     
    964963        if (!GetFileAttributesExW(This->filePathName,GetFileExInfoStandard,&info))
    965964            return MK_E_NOOBJECT;
    966 
     965       
    967966        *pFileTime=info.ftLastWriteTime;
    968967}
     
    999998    if (pmkOther==NULL)
    1000999        return E_INVALIDARG;
    1001 
     1000   
    10021001    *ppmkPrefix=0;
    1003 
     1002   
    10041003    /* check if we have the same type of moniker */
    10051004    IMoniker_IsSystemMoniker(pmkOther,&mkSys);
     
    10231022
    10241023        *commonPath=0;
    1025 
     1024       
    10261025        for(sameIdx=0; ( (stringTable1[sameIdx]!=NULL) &&
    10271026                         (stringTable2[sameIdx]!=NULL) &&
     
    10421041        if (machimeNameCase && *stringTable1[sameIdx-1]=='\\')
    10431042            sameIdx--;
    1044 
     1043       
    10451044        if (machimeNameCase && (sameIdx<=3) && (nb1 > 3 || nb2 > 3) )
    10461045            return MK_E_NOPREFIX;
     
    10481047        for(i=0;i<sameIdx;i++)
    10491048            strcatW(commonPath,stringTable1[i]);
    1050 
     1049       
    10511050        for(i=0;i<nb1;i++)
    10521051            CoTaskMemFree(stringTable1[i]);
     
    10601059
    10611060        HeapFree(GetProcessHeap(),0,commonPath);
    1062 
     1061       
    10631062        return CreateFileMoniker(commonPath,ppmkPrefix);
    10641063    }
     
    10801079
    10811080    strgtable =CoTaskMemAlloc(len*sizeof(LPOLESTR));
    1082 
     1081   
    10831082    if (strgtable==NULL)
    1084     return E_OUTOFMEMORY;
    1085 
     1083        return E_OUTOFMEMORY;
     1084   
    10861085    while(str[i]!=0){
    10871086
     
    10911090
    10921091            if (strgtable[tabIndex]==NULL)
    1093             return E_OUTOFMEMORY;
     1092                return E_OUTOFMEMORY;
    10941093
    10951094            strcpyW(strgtable[tabIndex++],bSlash);
     
    11141113    }
    11151114    strgtable[tabIndex]=NULL;
    1116 
     1115   
    11171116    *stringTable=strgtable;
    1118 
     1117   
    11191118    return tabIndex;
    11201119}
     
    11301129    DWORD len1=0,len2=0,sameIdx=0,j=0;
    11311130    WCHAR back[] ={'.','.','\\',0};
    1132 
     1131   
    11331132    TRACE("(%p,%p,%p)\n",iface,pmOther,ppmkRelPath);
    11341133
     
    11381137    if (pmOther==NULL)
    11391138        return E_INVALIDARG;
    1140 
     1139   
    11411140    res=CreateBindCtx(0,&bind);
    11421141    if (FAILED(res))
    1143     return res;
     1142        return res;
    11441143
    11451144    res=IMoniker_GetDisplayName(iface,bind,NULL,&str1);
    11461145    if (FAILED(res))
    1147     return res;
     1146        return res;
    11481147    res=IMoniker_GetDisplayName(pmOther,bind,NULL,&str2);
    11491148    if (FAILED(res))
    1150     return res;
     1149        return res;
    11511150
    11521151    len1=FileMonikerImpl_DecomposePath(str1,&tabStr1);
     
    11541153
    11551154    if (FAILED(len1) || FAILED(len2))
    1156     return E_OUTOFMEMORY;
    1157 
     1155        return E_OUTOFMEMORY;
     1156       
    11581157    /* count the number of similar items from the begin of the two paths */
    11591158    for(sameIdx=0; ( (tabStr1[sameIdx]!=NULL) &&
    1160            (tabStr2[sameIdx]!=NULL) &&
     1159                   (tabStr2[sameIdx]!=NULL) &&
    11611160               (lstrcmpiW(tabStr1[sameIdx],tabStr2[sameIdx])==0)); sameIdx++);
    11621161
     
    11761175    for(j=sameIdx;tabStr2[j]!=NULL;j++)
    11771176        strcatW(relPath,tabStr2[j]);
    1178 
     1177   
    11791178    res=CreateFileMoniker(relPath,ppmkRelPath);
    1180 
     1179   
    11811180    for(j=0; tabStr1[j]!=NULL;j++)
    11821181        CoTaskMemFree(tabStr1[j]);
     
    12201219
    12211220    strcpyW(*ppszDisplayName,This->filePathName);
    1222 
     1221   
    12231222    return S_OK;
    12241223}
     
    12471246    if (!pwdMksys)
    12481247        return E_POINTER;
    1249 
     1248   
    12501249    (*pwdMksys)=MKSYS_FILEMONIKER;
    12511250
     
    12841283{
    12851284    ICOM_THIS_From_IROTData(IMoniker, iface);
    1286 
     1285   
    12871286    TRACE("(%p)\n",This);
    12881287
     
    13281327    if(lpszPathName==NULL)
    13291328        return MK_E_SYNTAX;
    1330 
     1329           
    13311330    *ppmk=0;
    1332 
     1331       
    13331332    newFileMoniker = HeapAlloc(GetProcessHeap(), 0, sizeof(FileMonikerImpl));
    13341333
     
    13391338
    13401339    if (SUCCEEDED(hr))
    1341     hr = FileMonikerImpl_QueryInterface((IMoniker*)newFileMoniker,&riid,(void**)ppmk);
     1340        hr = FileMonikerImpl_QueryInterface((IMoniker*)newFileMoniker,&riid,(void**)ppmk);
    13421341    else
    13431342        HeapFree(GetProcessHeap(),0,newFileMoniker);
  • trunk/src/ole32/hglobalstream.c

    r6648 r6711  
    1 /* $Id: hglobalstream.c,v 1.2 2001-09-05 13:17:09 bird Exp $ */
    21/*
    32 * HGLOBAL Stream implementation
     
    3029{
    3130  ICOM_VFIELD(IStream);  /* Needs to be the first item in the stuct
    32               * since we want to cast this in a IStream pointer */
    33 
     31                          * since we want to cast this in a IStream pointer */
     32 
    3433  /*
    3534   * Reference count
    3635   */
    37   ULONG          ref;
     36  ULONG              ref;
    3837
    3938  /*
     
    6564 */
    6665HGLOBALStreamImpl* HGLOBALStreamImpl_Construct(
    67         HGLOBAL  hGlobal,
    68         BOOL     fDeleteOnRelease);
     66                HGLOBAL  hGlobal,
     67                BOOL     fDeleteOnRelease);
    6968
    7069void HGLOBALStreamImpl_Destroy(
     
    7574
    7675HRESULT WINAPI HGLOBALStreamImpl_QueryInterface(
    77         IStream*      iface,
    78         REFIID         riid,        /* [in] */
    79         void**         ppvObject);  /* [iid_is][out] */
    80 
     76                IStream*      iface,
     77                REFIID         riid,            /* [in] */         
     78                void**         ppvObject);  /* [iid_is][out] */
     79       
    8180ULONG WINAPI HGLOBALStreamImpl_AddRef(
    82         IStream*      iface);
    83 
     81                IStream*      iface);
     82       
    8483ULONG WINAPI HGLOBALStreamImpl_Release(
    85         IStream*      iface);
    86 
    87 HRESULT WINAPI HGLOBALStreamImpl_Read(
    88             IStream*      iface,
    89         void*          pv,        /* [length_is][size_is][out] */
    90         ULONG          cb,        /* [in] */
    91         ULONG*         pcbRead);  /* [out] */
    92 
     84                IStream*      iface);
     85       
     86HRESULT WINAPI HGLOBALStreamImpl_Read( 
     87                IStream*      iface,
     88                void*          pv,        /* [length_is][size_is][out] */
     89                ULONG          cb,        /* [in] */                     
     90                ULONG*         pcbRead);  /* [out] */                   
     91       
    9392HRESULT WINAPI HGLOBALStreamImpl_Write(
    94         IStream*      iface,
    95         const void*    pv,          /* [size_is][in] */
    96         ULONG          cb,          /* [in] */
    97         ULONG*         pcbWritten); /* [out] */
    98 
    99 HRESULT WINAPI HGLOBALStreamImpl_Seek(
    100         IStream*      iface,
    101         LARGE_INTEGER   dlibMove,         /* [in] */
    102         DWORD           dwOrigin,         /* [in] */
    103         ULARGE_INTEGER* plibNewPosition); /* [out] */
    104 
    105 HRESULT WINAPI HGLOBALStreamImpl_SetSize(
    106             IStream*      iface,
    107         ULARGE_INTEGER  libNewSize);  /* [in] */
    108 
    109 HRESULT WINAPI HGLOBALStreamImpl_CopyTo(
    110         IStream*      iface,
    111         IStream*      pstm,         /* [unique][in] */
    112         ULARGE_INTEGER  cb,           /* [in] */
    113         ULARGE_INTEGER* pcbRead,      /* [out] */
    114         ULARGE_INTEGER* pcbWritten);  /* [out] */
    115 
    116 HRESULT WINAPI HGLOBALStreamImpl_Commit(
    117             IStream*      iface,
    118         DWORD           grfCommitFlags); /* [in] */
    119 
    120 HRESULT WINAPI HGLOBALStreamImpl_Revert(
    121         IStream*  iface);
    122 
    123 HRESULT WINAPI HGLOBALStreamImpl_LockRegion(
    124         IStream*     iface,
    125         ULARGE_INTEGER libOffset,   /* [in] */
    126         ULARGE_INTEGER cb,          /* [in] */
    127         DWORD          dwLockType); /* [in] */
    128 
    129 HRESULT WINAPI HGLOBALStreamImpl_UnlockRegion(
    130         IStream*     iface,
    131         ULARGE_INTEGER libOffset,   /* [in] */
    132             ULARGE_INTEGER cb,          /* [in] */
    133         DWORD          dwLockType); /* [in] */
    134 
    135 HRESULT WINAPI HGLOBALStreamImpl_Stat(
    136         IStream*     iface,
    137             STATSTG*       pstatstg,     /* [out] */
    138             DWORD          grfStatFlag); /* [in] */
    139 
    140 HRESULT WINAPI HGLOBALStreamImpl_Clone(
    141         IStream*     iface,
    142         IStream**    ppstm);       /* [out] */
     93                IStream*      iface,
     94                const void*    pv,          /* [size_is][in] */
     95                ULONG          cb,          /* [in] */         
     96                ULONG*         pcbWritten); /* [out] */         
     97       
     98HRESULT WINAPI HGLOBALStreamImpl_Seek( 
     99                IStream*      iface,
     100                LARGE_INTEGER   dlibMove,         /* [in] */
     101                DWORD           dwOrigin,         /* [in] */
     102                ULARGE_INTEGER* plibNewPosition); /* [out] */
     103       
     104HRESULT WINAPI HGLOBALStreamImpl_SetSize( 
     105                IStream*      iface,
     106                ULARGE_INTEGER  libNewSize);  /* [in] */
     107       
     108HRESULT WINAPI HGLOBALStreamImpl_CopyTo( 
     109                IStream*      iface,
     110                IStream*      pstm,         /* [unique][in] */
     111                ULARGE_INTEGER  cb,           /* [in] */         
     112                ULARGE_INTEGER* pcbRead,      /* [out] */       
     113                ULARGE_INTEGER* pcbWritten);  /* [out] */       
     114
     115HRESULT WINAPI HGLOBALStreamImpl_Commit( 
     116                IStream*      iface,
     117                DWORD           grfCommitFlags); /* [in] */
     118       
     119HRESULT WINAPI HGLOBALStreamImpl_Revert( 
     120                IStream*  iface);
     121       
     122HRESULT WINAPI HGLOBALStreamImpl_LockRegion( 
     123                IStream*     iface,
     124                ULARGE_INTEGER libOffset,   /* [in] */
     125                ULARGE_INTEGER cb,          /* [in] */
     126                DWORD          dwLockType); /* [in] */
     127       
     128HRESULT WINAPI HGLOBALStreamImpl_UnlockRegion( 
     129                IStream*     iface,
     130                ULARGE_INTEGER libOffset,   /* [in] */
     131                ULARGE_INTEGER cb,          /* [in] */
     132                DWORD          dwLockType); /* [in] */
     133       
     134HRESULT WINAPI HGLOBALStreamImpl_Stat( 
     135                IStream*     iface,
     136                STATSTG*       pstatstg,     /* [out] */
     137                DWORD          grfStatFlag); /* [in] */
     138       
     139HRESULT WINAPI HGLOBALStreamImpl_Clone( 
     140                IStream*     iface,
     141                IStream**    ppstm);       /* [out] */
    143142
    144143
     
    169168 */
    170169HRESULT WINAPI CreateStreamOnHGlobal(
    171         HGLOBAL   hGlobal,
    172         BOOL      fDeleteOnRelease,
    173         LPSTREAM* ppstm)
     170                HGLOBAL   hGlobal,
     171                BOOL      fDeleteOnRelease,
     172                LPSTREAM* ppstm)
    174173{
    175174  HGLOBALStreamImpl* newStream;
    176175
    177176  newStream = HGLOBALStreamImpl_Construct(hGlobal,
    178                       fDeleteOnRelease);
     177                                          fDeleteOnRelease);
    179178
    180179  if (newStream!=NULL)
    181180  {
    182     return IUnknown_QueryInterface((IUnknown*)newStream,
    183                    &IID_IStream,
    184                    (void**)ppstm);
     181    return IUnknown_QueryInterface((IUnknown*)newStream, 
     182                                   &IID_IStream,
     183                                   (void**)ppstm);
    185184  }
    186185
     
    223222 * Params:
    224223 *    hGlobal          - Handle that will support the stream. can be NULL.
    225  *    fDeleteOnRelease - Flag set to TRUE if the HGLOBAL will be released
     224 *    fDeleteOnRelease - Flag set to TRUE if the HGLOBAL will be released 
    226225 *                       when the IStream object is destroyed.
    227226 */
    228227HGLOBALStreamImpl* HGLOBALStreamImpl_Construct(
    229         HGLOBAL  hGlobal,
    230         BOOL     fDeleteOnRelease)
     228                HGLOBAL  hGlobal,
     229                BOOL     fDeleteOnRelease)
    231230{
    232231  HGLOBALStreamImpl* newStream;
    233232
    234233  newStream = HeapAlloc(GetProcessHeap(), 0, sizeof(HGLOBALStreamImpl));
    235 
     234 
    236235  if (newStream!=0)
    237236  {
     
    241240    ICOM_VTBL(newStream) = &HGLOBALStreamImpl_Vtbl;
    242241    newStream->ref    = 0;
    243 
     242   
    244243    /*
    245244     * Initialize the support.
     
    254253    {
    255254      newStream->supportHandle = GlobalAlloc(GMEM_MOVEABLE | GMEM_NODISCARD |
    256                          GMEM_SHARE, 0);
     255                                             GMEM_SHARE, 0);
    257256    }
    258 
     257   
    259258    /*
    260259     * Start the stream at the begining.
     
    262261    newStream->currentPosition.s.HighPart = 0;
    263262    newStream->currentPosition.s.LowPart = 0;
    264 
     263   
    265264    /*
    266265     * Initialize the size of the stream to the size of the handle.
     
    269268    newStream->streamSize.s.LowPart  = GlobalSize(newStream->supportHandle);
    270269  }
    271 
     270 
    272271  return newStream;
    273272}
     
    276275 * This is the destructor of the HGLOBALStreamImpl class.
    277276 *
    278  * This method will clean-up all the resources used-up by the given HGLOBALStreamImpl
     277 * This method will clean-up all the resources used-up by the given HGLOBALStreamImpl 
    279278 * class. The pointer passed-in to this function will be freed and will not
    280279 * be valid anymore.
     
    296295   * Finally, free the memory used-up by the class.
    297296   */
    298   HeapFree(GetProcessHeap(), 0, This);
     297  HeapFree(GetProcessHeap(), 0, This); 
    299298}
    300299
     
    304303 */
    305304HRESULT WINAPI HGLOBALStreamImpl_QueryInterface(
    306           IStream*     iface,
    307           REFIID         riid,        /* [in] */
    308           void**         ppvObject)   /* [iid_is][out] */
     305                  IStream*     iface,
     306                  REFIID         riid,        /* [in] */         
     307                  void**         ppvObject)   /* [iid_is][out] */
    309308{
    310309  HGLOBALStreamImpl* const This=(HGLOBALStreamImpl*)iface;
     
    315314  if (ppvObject==0)
    316315    return E_INVALIDARG;
    317 
     316 
    318317  /*
    319318   * Initialize the return parameter.
    320319   */
    321320  *ppvObject = 0;
    322 
     321 
    323322  /*
    324323   * Compare the riid with the interface IDs implemented by this object.
    325324   */
    326   if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0)
     325  if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0) 
    327326  {
    328327    *ppvObject = (IStream*)This;
    329328  }
    330   else if (memcmp(&IID_IStream, riid, sizeof(IID_IStream)) == 0)
     329  else if (memcmp(&IID_IStream, riid, sizeof(IID_IStream)) == 0) 
    331330  {
    332331    *ppvObject = (IStream*)This;
    333332  }
    334 
     333 
    335334  /*
    336335   * Check that we obtained an interface.
     
    338337  if ((*ppvObject)==0)
    339338    return E_NOINTERFACE;
    340 
     339 
    341340  /*
    342341   * Query Interface always increases the reference count by one when it is
     
    344343   */
    345344  HGLOBALStreamImpl_AddRef(iface);
    346 
     345 
    347346  return S_OK;;
    348347}
     
    353352 */
    354353ULONG WINAPI HGLOBALStreamImpl_AddRef(
    355         IStream* iface)
     354                IStream* iface)
    356355{
    357356  HGLOBALStreamImpl* const This=(HGLOBALStreamImpl*)iface;
    358357
    359358  This->ref++;
    360 
     359 
    361360  return This->ref;
    362361}
     
    367366 */
    368367ULONG WINAPI HGLOBALStreamImpl_Release(
    369         IStream* iface)
     368                IStream* iface)
    370369{
    371370  HGLOBALStreamImpl* const This=(HGLOBALStreamImpl*)iface;
    372371
    373372  ULONG newRef;
    374 
     373 
    375374  This->ref--;
    376 
     375 
    377376  newRef = This->ref;
    378 
     377 
    379378  /*
    380379   * If the reference count goes down to 0, perform suicide.
     
    384383    HGLOBALStreamImpl_Destroy(This);
    385384  }
    386 
     385 
    387386  return newRef;
    388387}
     
    397396 * See the documentation of ISequentialStream for more info.
    398397 */
    399 HRESULT WINAPI HGLOBALStreamImpl_Read(
    400           IStream*     iface,
    401           void*          pv,        /* [length_is][size_is][out] */
    402           ULONG          cb,        /* [in] */
    403           ULONG*         pcbRead)   /* [out] */
     398HRESULT WINAPI HGLOBALStreamImpl_Read( 
     399                  IStream*     iface,
     400                  void*          pv,        /* [length_is][size_is][out] */
     401                  ULONG          cb,        /* [in] */                     
     402                  ULONG*         pcbRead)   /* [out] */                   
    404403{
    405404  HGLOBALStreamImpl* const This=(HGLOBALStreamImpl*)iface;
     
    410409
    411410  TRACE("(%p, %p, %ld, %p)\n", iface,
    412     pv, cb, pcbRead);
    413 
    414   /*
     411        pv, cb, pcbRead);
     412 
     413  /* 
    415414   * If the caller is not interested in the nubmer of bytes read,
    416415   * we use another buffer to avoid "if" statements in the code.
     
    418417  if (pcbRead==0)
    419418    pcbRead = &bytesReadBuffer;
    420 
     419 
    421420  /*
    422421   * Using the known size of the stream, calculate the number of bytes
     
    446445   */
    447446  GlobalUnlock(This->supportHandle);
    448 
     447 
    449448  /*
    450449   * The function returns S_OK if the buffer was filled completely
     
    454453  if(*pcbRead == cb)
    455454    return S_OK;
    456 
     455 
    457456  return S_FALSE;
    458457}
    459 
     458       
    460459/***
    461460 * This method is part of the ISequentialStream interface.
     
    469468 */
    470469HRESULT WINAPI HGLOBALStreamImpl_Write(
    471               IStream*     iface,
    472           const void*    pv,          /* [size_is][in] */
    473           ULONG          cb,          /* [in] */
    474           ULONG*         pcbWritten)  /* [out] */
     470                  IStream*     iface,
     471                  const void*    pv,          /* [size_is][in] */
     472                  ULONG          cb,          /* [in] */         
     473                  ULONG*         pcbWritten)  /* [out] */         
    475474{
    476475  HGLOBALStreamImpl* const This=(HGLOBALStreamImpl*)iface;
     
    481480
    482481  TRACE("(%p, %p, %ld, %p)\n", iface,
    483     pv, cb, pcbWritten);
    484 
     482        pv, cb, pcbWritten);
     483 
    485484  /*
    486485   * If the caller is not interested in the number of bytes written,
     
    489488  if (pcbWritten == 0)
    490489    pcbWritten = &bytesWritten;
    491 
     490 
    492491  if (cb == 0)
    493492  {
     
    499498    newSize.s.LowPart = This->currentPosition.s.LowPart + cb;
    500499  }
    501 
     500 
    502501  /*
    503502   * Verify if we need to grow the stream
     
    508507   IStream_SetSize(iface, newSize);
    509508  }
    510 
     509 
    511510  /*
    512511   * Lock the buffer in position and copy the data.
     
    514513  supportBuffer = GlobalLock(This->supportHandle);
    515514
    516   memcpy((char *) supportBuffer+This->currentPosition.s.LowPart, pv, cb);
     515  memcpy((char *) supportBuffer+This->currentPosition.s.LowPart, pv, cb); 
    517516
    518517  /*
     
    530529   */
    531530  GlobalUnlock(This->supportHandle);
    532 
     531 
    533532  return S_OK;
    534533}
     
    541540 *
    542541 * See the documentation of IStream for more info.
    543  */
    544 HRESULT WINAPI HGLOBALStreamImpl_Seek(
    545           IStream*      iface,
    546           LARGE_INTEGER   dlibMove,         /* [in] */
    547           DWORD           dwOrigin,         /* [in] */
    548           ULARGE_INTEGER* plibNewPosition) /* [out] */
     542 */       
     543HRESULT WINAPI HGLOBALStreamImpl_Seek( 
     544                  IStream*      iface,
     545                  LARGE_INTEGER   dlibMove,         /* [in] */
     546                  DWORD           dwOrigin,         /* [in] */
     547                  ULARGE_INTEGER* plibNewPosition) /* [out] */
    549548{
    550549  HGLOBALStreamImpl* const This=(HGLOBALStreamImpl*)iface;
     
    553552
    554553  TRACE("(%p, %ld, %ld, %p)\n", iface,
    555     dlibMove.s.LowPart, dwOrigin, plibNewPosition);
    556 
    557   /*
     554        dlibMove.s.LowPart, dwOrigin, plibNewPosition);
     555
     556  /* 
    558557   * The caller is allowed to pass in NULL as the new position return value.
    559558   * If it happens, we assign it to a dynamic variable to avoid special cases
     
    609608  plibNewPosition->s.LowPart += dlibMove.s.LowPart;
    610609  This->currentPosition = *plibNewPosition;
    611 
     610 
    612611  return S_OK;
    613612}
     
    622621 * See the documentation of IStream for more info.
    623622 */
    624 HRESULT WINAPI HGLOBALStreamImpl_SetSize(
    625                      IStream*      iface,
    626                      ULARGE_INTEGER  libNewSize)   /* [in] */
     623HRESULT WINAPI HGLOBALStreamImpl_SetSize( 
     624                                     IStream*      iface,
     625                                     ULARGE_INTEGER  libNewSize)   /* [in] */
    627626{
    628627  HGLOBALStreamImpl* const This=(HGLOBALStreamImpl*)iface;
     
    635634  if (libNewSize.s.HighPart != 0)
    636635    return STG_E_INVALIDFUNCTION;
    637 
     636 
    638637  if (This->streamSize.s.LowPart == libNewSize.s.LowPart)
    639638    return S_OK;
     
    642641   * Re allocate the HGlobal to fit the new size of the stream.
    643642   */
    644   This->supportHandle = GlobalReAlloc(This->supportHandle,
    645                       libNewSize.s.LowPart,
    646                       0);
     643  This->supportHandle = GlobalReAlloc(This->supportHandle, 
     644                                      libNewSize.s.LowPart,
     645                                      0);
    647646
    648647  This->streamSize.s.LowPart = libNewSize.s.LowPart;
    649 
     648 
    650649  return S_OK;
    651650}
    652 
     651       
    653652/***
    654653 * This method is part of the IStream interface.
     
    658657 * See the documentation of IStream for more info.
    659658 */
    660 HRESULT WINAPI HGLOBALStreamImpl_CopyTo(
    661                     IStream*      iface,
    662                     IStream*      pstm,         /* [unique][in] */
    663                     ULARGE_INTEGER  cb,           /* [in] */
    664                     ULARGE_INTEGER* pcbRead,      /* [out] */
    665                     ULARGE_INTEGER* pcbWritten)   /* [out] */
     659HRESULT WINAPI HGLOBALStreamImpl_CopyTo( 
     660                                    IStream*      iface,
     661                                    IStream*      pstm,         /* [unique][in] */
     662                                    ULARGE_INTEGER  cb,           /* [in] */         
     663                                    ULARGE_INTEGER* pcbRead,      /* [out] */       
     664                                    ULARGE_INTEGER* pcbWritten)   /* [out] */       
    666665{
    667666  HRESULT        hr = S_OK;
     
    671670  ULARGE_INTEGER totalBytesWritten;
    672671
    673   TRACE("(%p, %p, %ld, %p, %p)\n", iface, pstm,
    674     cb.s.LowPart, pcbRead, pcbWritten);
     672  TRACE("(%p, %p, %ld, %p, %p)\n", iface, pstm, 
     673        cb.s.LowPart, pcbRead, pcbWritten);
    675674
    676675  /*
     
    694693    else
    695694      copySize = cb.s.LowPart;
    696 
     695   
    697696    IStream_Read(iface, tmpBuffer, copySize, &bytesRead);
    698697
    699698    totalBytesRead.s.LowPart += bytesRead;
    700 
     699   
    701700    IStream_Write(pstm, tmpBuffer, bytesRead, &bytesWritten);
    702701
     
    711710      break;
    712711    }
    713 
     712   
    714713    if (bytesRead!=copySize)
    715714      cb.s.LowPart = 0;
     
    738737 * This method is part of the IStream interface.
    739738 *
    740  * For streams supported by HGLOBALS, this function does nothing.
     739 * For streams supported by HGLOBALS, this function does nothing. 
    741740 * This is what the documentation tells us.
    742741 *
    743742 * See the documentation of IStream for more info.
    744  */
    745 HRESULT WINAPI HGLOBALStreamImpl_Commit(
    746           IStream*      iface,
    747           DWORD         grfCommitFlags)  /* [in] */
     743 */       
     744HRESULT WINAPI HGLOBALStreamImpl_Commit( 
     745                  IStream*      iface,
     746                  DWORD         grfCommitFlags)  /* [in] */
    748747{
    749748  return S_OK;
     
    753752 * This method is part of the IStream interface.
    754753 *
    755  * For streams supported by HGLOBALS, this function does nothing.
     754 * For streams supported by HGLOBALS, this function does nothing. 
    756755 * This is what the documentation tells us.
    757756 *
    758757 * See the documentation of IStream for more info.
    759  */
    760 HRESULT WINAPI HGLOBALStreamImpl_Revert(
    761           IStream* iface)
     758 */       
     759HRESULT WINAPI HGLOBALStreamImpl_Revert( 
     760                  IStream* iface)
    762761{
    763762  return S_OK;
     
    767766 * This method is part of the IStream interface.
    768767 *
    769  * For streams supported by HGLOBALS, this function does nothing.
     768 * For streams supported by HGLOBALS, this function does nothing. 
    770769 * This is what the documentation tells us.
    771770 *
    772771 * See the documentation of IStream for more info.
    773  */
    774 HRESULT WINAPI HGLOBALStreamImpl_LockRegion(
    775           IStream*       iface,
    776           ULARGE_INTEGER libOffset,   /* [in] */
    777           ULARGE_INTEGER cb,          /* [in] */
    778           DWORD          dwLockType)  /* [in] */
     772 */       
     773HRESULT WINAPI HGLOBALStreamImpl_LockRegion( 
     774                  IStream*       iface,
     775                  ULARGE_INTEGER libOffset,   /* [in] */
     776                  ULARGE_INTEGER cb,          /* [in] */
     777                  DWORD          dwLockType)  /* [in] */
    779778{
    780779  return S_OK;
     
    784783 * This method is part of the IStream interface.
    785784 *
    786  * For streams supported by HGLOBALS, this function does nothing.
     785 * For streams supported by HGLOBALS, this function does nothing. 
    787786 * This is what the documentation tells us.
    788787 *
    789788 * See the documentation of IStream for more info.
    790  */
    791 HRESULT WINAPI HGLOBALStreamImpl_UnlockRegion(
    792           IStream*       iface,
    793           ULARGE_INTEGER libOffset,   /* [in] */
    794           ULARGE_INTEGER cb,          /* [in] */
    795           DWORD          dwLockType)  /* [in] */
     789 */       
     790HRESULT WINAPI HGLOBALStreamImpl_UnlockRegion( 
     791                  IStream*       iface,
     792                  ULARGE_INTEGER libOffset,   /* [in] */
     793                  ULARGE_INTEGER cb,          /* [in] */
     794                  DWORD          dwLockType)  /* [in] */
    796795{
    797796  return S_OK;
     
    805804 *
    806805 * See the documentation of IStream for more info.
    807  */
    808 HRESULT WINAPI HGLOBALStreamImpl_Stat(
    809           IStream*     iface,
    810           STATSTG*     pstatstg,     /* [out] */
    811           DWORD        grfStatFlag)  /* [in] */
     806 */       
     807HRESULT WINAPI HGLOBALStreamImpl_Stat( 
     808                  IStream*     iface,
     809                  STATSTG*     pstatstg,     /* [out] */
     810                  DWORD        grfStatFlag)  /* [in] */
    812811{
    813812  HGLOBALStreamImpl* const This=(HGLOBALStreamImpl*)iface;
     
    821820  return S_OK;
    822821}
    823 
    824 HRESULT WINAPI HGLOBALStreamImpl_Clone(
    825           IStream*     iface,
    826           IStream**    ppstm) /* [out] */
     822       
     823HRESULT WINAPI HGLOBALStreamImpl_Clone( 
     824                  IStream*     iface,
     825                  IStream**    ppstm) /* [out] */
    827826{
    828827  FIXME("not implemented!\n");
  • trunk/src/ole32/ifs.c

    r6648 r6711  
    1 /* $Id: ifs.c,v 1.2 2001-09-05 13:17:09 bird Exp $ */
    21/*
    3  *  basic interfaces
     2 *      basic interfaces
    43 *
    5  *  Copyright 1997  Marcus Meissner
     4 *      Copyright 1997  Marcus Meissner
    65 */
    76
     
    3130
    3231/******************************************************************************
    33  *      IUnknown_AddRef [VTABLE:IUNKNOWN.1]
    34  */
    35 static ULONG WINAPI IUnknown_fnAddRef(LPUNKNOWN iface) {
    36     ICOM_THIS(IUnknownImpl,iface);
    37     TRACE("(%p)->AddRef()\n",This);
    38     return ++(This->ref);
     32 *              IUnknown_AddRef [VTABLE:IUNKNOWN.1]
     33 */
     34static ULONG WINAPI IUnknown_fnAddRef(LPUNKNOWN iface) { 
     35        ICOM_THIS(IUnknownImpl,iface);
     36        TRACE("(%p)->AddRef()\n",This);
     37        return ++(This->ref);
    3938}
    4039
     
    4342 */
    4443static ULONG WINAPI IUnknown_fnRelease(LPUNKNOWN iface) {
    45     ICOM_THIS(IUnknownImpl,iface);
    46     TRACE("(%p)->Release()\n",This);
    47     if (!--(This->ref)) {
    48         HeapFree(GetProcessHeap(),0,This);
    49         return 0;
    50     }
    51     return This->ref;
     44        ICOM_THIS(IUnknownImpl,iface);
     45        TRACE("(%p)->Release()\n",This);
     46        if (!--(This->ref)) {
     47                HeapFree(GetProcessHeap(),0,This);
     48                return 0;
     49        }
     50        return This->ref;
    5251}
    5352
     
    5655 */
    5756static HRESULT WINAPI IUnknown_fnQueryInterface(LPUNKNOWN iface,REFIID refiid,LPVOID *obj) {
    58     ICOM_THIS(IUnknownImpl,iface);
    59 
    60     TRACE("(%p)->QueryInterface(%s,%p)\n",This,debugstr_guid(refiid),obj);
    61 
    62     if (!memcmp(&IID_IUnknown,refiid,sizeof(IID_IUnknown))) {
    63         *obj = This;
    64         return 0;
    65     }
    66     return OLE_E_ENUM_NOMORE;
    67 }
    68 
    69 static ICOM_VTABLE(IUnknown) uvt =
    70 {
    71     ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
    72     IUnknown_fnQueryInterface,
    73     IUnknown_fnAddRef,
    74     IUnknown_fnRelease
     57        ICOM_THIS(IUnknownImpl,iface);
     58
     59        TRACE("(%p)->QueryInterface(%s,%p)\n",This,debugstr_guid(refiid),obj);
     60
     61        if (!memcmp(&IID_IUnknown,refiid,sizeof(IID_IUnknown))) {
     62                *obj = This;
     63                return 0;
     64        }
     65        return OLE_E_ENUM_NOMORE;
     66}
     67
     68static ICOM_VTABLE(IUnknown) uvt = 
     69{
     70        ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
     71        IUnknown_fnQueryInterface,
     72        IUnknown_fnAddRef,
     73        IUnknown_fnRelease
    7574};
    7675
     
    8079LPUNKNOWN
    8180IUnknown_Constructor() {
    82     IUnknownImpl*   unk;
    83 
    84     unk = (IUnknownImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IUnknownImpl));
    85     ICOM_VTBL(unk)  = &uvt;
    86     unk->ref    = 1;
    87     return (LPUNKNOWN)unk;
     81        IUnknownImpl*   unk;
     82
     83        unk = (IUnknownImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IUnknownImpl));
     84        ICOM_VTBL(unk)  = &uvt;
     85        unk->ref        = 1;
     86        return (LPUNKNOWN)unk;
    8887}
    8988
     
    101100
    102101/******************************************************************************
    103  *      IMalloc16_QueryInterface    [COMPOBJ.500]
     102 *              IMalloc16_QueryInterface        [COMPOBJ.500]
    104103 */
    105104HRESULT WINAPI IMalloc16_fnQueryInterface(IMalloc16* iface,REFIID refiid,LPVOID *obj) {
    106105        ICOM_THIS(IMalloc16Impl,iface);
    107106
    108     TRACE("(%p)->QueryInterface(%s,%p)\n",This,debugstr_guid(refiid),obj);
    109     if (    !memcmp(&IID_IUnknown,refiid,sizeof(IID_IUnknown)) ||
    110         !memcmp(&IID_IMalloc,refiid,sizeof(IID_IMalloc))
    111     ) {
    112         *obj = This;
    113         return 0;
    114     }
    115     return OLE_E_ENUM_NOMORE;
    116 }
    117 
    118 /******************************************************************************
    119  *      IMalloc16_AddRef    [COMPOBJ.501]
     107        TRACE("(%p)->QueryInterface(%s,%p)\n",This,debugstr_guid(refiid),obj);
     108        if (    !memcmp(&IID_IUnknown,refiid,sizeof(IID_IUnknown)) ||
     109                !memcmp(&IID_IMalloc,refiid,sizeof(IID_IMalloc))
     110        ) {
     111                *obj = This;
     112                return 0;
     113        }
     114        return OLE_E_ENUM_NOMORE;
     115}
     116
     117/******************************************************************************
     118 *              IMalloc16_AddRef        [COMPOBJ.501]
    120119 */
    121120ULONG WINAPI IMalloc16_fnAddRef(IMalloc16* iface) {
    122121        ICOM_THIS(IMalloc16Impl,iface);
    123     TRACE("(%p)->AddRef()\n",This);
    124     return 1; /* cannot be freed */
    125 }
    126 
    127 /******************************************************************************
    128  *      IMalloc16_Release   [COMPOBJ.502]
     122        TRACE("(%p)->AddRef()\n",This);
     123        return 1; /* cannot be freed */
     124}
     125
     126/******************************************************************************
     127 *              IMalloc16_Release       [COMPOBJ.502]
    129128 */
    130129ULONG WINAPI IMalloc16_fnRelease(IMalloc16* iface) {
    131130        ICOM_THIS(IMalloc16Impl,iface);
    132     TRACE("(%p)->Release()\n",This);
    133     return 1; /* cannot be freed */
     131        TRACE("(%p)->Release()\n",This);
     132        return 1; /* cannot be freed */
    134133}
    135134
     
    139138SEGPTR WINAPI IMalloc16_fnAlloc(IMalloc16* iface,DWORD cb) {
    140139        ICOM_THIS(IMalloc16Impl,iface);
    141     TRACE("(%p)->Alloc(%ld)\n",This,cb);
     140        TRACE("(%p)->Alloc(%ld)\n",This,cb);
    142141        return MapLS( HeapAlloc( GetProcessHeap(), HEAP_WINE_SEGPTR, cb ) );
    143142}
     
    166165DWORD WINAPI IMalloc16_fnGetSize(const IMalloc16* iface,SEGPTR pv)
    167166{
    168     ICOM_CTHIS(IMalloc16Impl,iface);
     167        ICOM_CTHIS(IMalloc16Impl,iface);
    169168        TRACE("(%p)->GetSize(%08lx)\n",This,pv);
    170169        return HeapSize( GetProcessHeap(), HEAP_WINE_SEGPTR, MapSL(pv) );
     
    176175INT16 WINAPI IMalloc16_fnDidAlloc(const IMalloc16* iface,LPVOID pv) {
    177176        ICOM_CTHIS(IMalloc16,iface);
    178     TRACE("(%p)->DidAlloc(%p)\n",This,pv);
    179     return (INT16)-1;
     177        TRACE("(%p)->DidAlloc(%p)\n",This,pv);
     178        return (INT16)-1;
    180179}
    181180
     
    185184LPVOID WINAPI IMalloc16_fnHeapMinimize(IMalloc16* iface) {
    186185        ICOM_THIS(IMalloc16Impl,iface);
    187     TRACE("(%p)->HeapMinimize()\n",This);
    188     return NULL;
     186        TRACE("(%p)->HeapMinimize()\n",This);
     187        return NULL;
    189188}
    190189
     
    196195LPMALLOC16
    197196IMalloc16_Constructor() {
    198     IMalloc16Impl*  This;
    199         HMODULE16   hcomp = GetModuleHandle16("COMPOBJ");
    200 
    201     This = (IMalloc16Impl*)SEGPTR_NEW(IMalloc16Impl);
     197        IMalloc16Impl*  This;
     198        HMODULE16       hcomp = GetModuleHandle16("COMPOBJ");
     199
     200        This = (IMalloc16Impl*)SEGPTR_NEW(IMalloc16Impl);
    202201        if (!msegvt16) {
    203202            msegvt16 = SEGPTR_NEW(ICOM_VTABLE(IMalloc16));
     
    214213            VTENT(HeapMinimize);
    215214#undef VTENT
    216     }
     215        }
    217216        ICOM_VTBL(This) = (ICOM_VTABLE(IMalloc16)*)SEGPTR_GET(msegvt16);
    218     This->ref = 1;
    219     return (LPMALLOC16)SEGPTR_GET(This);
     217        This->ref = 1;
     218        return (LPMALLOC16)SEGPTR_GET(This);
    220219}
    221220#endif
     
    231230
    232231/******************************************************************************
    233  *      IMalloc32_QueryInterface    [VTABLE]
     232 *              IMalloc32_QueryInterface        [VTABLE]
    234233 */
    235234static HRESULT WINAPI IMalloc_fnQueryInterface(LPMALLOC iface,REFIID refiid,LPVOID *obj) {
    236     ICOM_THIS(IMalloc32Impl,iface);
    237 
    238     TRACE("(%p)->QueryInterface(%s,%p)\n",This,debugstr_guid(refiid),obj);
    239     if (    !memcmp(&IID_IUnknown,refiid,sizeof(IID_IUnknown)) ||
    240         !memcmp(&IID_IMalloc,refiid,sizeof(IID_IMalloc))
    241     ) {
    242         *obj = This;
    243         return S_OK;
    244     }
    245     return OLE_E_ENUM_NOMORE;
    246 }
    247 
    248 /******************************************************************************
    249  *      IMalloc32_AddRef    [VTABLE]
     235        ICOM_THIS(IMalloc32Impl,iface);
     236
     237        TRACE("(%p)->QueryInterface(%s,%p)\n",This,debugstr_guid(refiid),obj);
     238        if (    !memcmp(&IID_IUnknown,refiid,sizeof(IID_IUnknown)) ||
     239                !memcmp(&IID_IMalloc,refiid,sizeof(IID_IMalloc))
     240        ) {
     241                *obj = This;
     242                return S_OK;
     243        }
     244        return OLE_E_ENUM_NOMORE;
     245}
     246
     247/******************************************************************************
     248 *              IMalloc32_AddRef        [VTABLE]
    250249 */
    251250static ULONG WINAPI IMalloc_fnAddRef(LPMALLOC iface) {
    252     ICOM_THIS(IMalloc32Impl,iface);
    253     TRACE("(%p)->AddRef()\n",This);
    254     return 1; /* cannot be freed */
    255 }
    256 
    257 /******************************************************************************
    258  *      IMalloc32_Release   [VTABLE]
     251        ICOM_THIS(IMalloc32Impl,iface);
     252        TRACE("(%p)->AddRef()\n",This);
     253        return 1; /* cannot be freed */
     254}
     255
     256/******************************************************************************
     257 *              IMalloc32_Release       [VTABLE]
    259258 */
    260259static ULONG WINAPI IMalloc_fnRelease(LPMALLOC iface) {
    261     ICOM_THIS(IMalloc32Impl,iface);
    262     TRACE("(%p)->Release()\n",This);
    263     return 1; /* cannot be freed */
     260        ICOM_THIS(IMalloc32Impl,iface);
     261        TRACE("(%p)->Release()\n",This);
     262        return 1; /* cannot be freed */
    264263}
    265264
     
    268267 */
    269268static LPVOID WINAPI IMalloc_fnAlloc(LPMALLOC iface,DWORD cb) {
    270     LPVOID addr;
    271     ICOM_THIS(IMalloc32Impl,iface);
    272     addr = HeapAlloc(GetProcessHeap(),0,cb);
    273     TRACE("(%p)->Alloc(%ld) -> %p\n",This,cb,addr);
    274     return addr;
     269        LPVOID addr;
     270        ICOM_THIS(IMalloc32Impl,iface);
     271        addr = HeapAlloc(GetProcessHeap(),0,cb);
     272        TRACE("(%p)->Alloc(%ld) -> %p\n",This,cb,addr);
     273        return addr;
    275274}
    276275
     
    279278 */
    280279static LPVOID WINAPI IMalloc_fnRealloc(LPMALLOC iface,LPVOID pv,DWORD cb) {
    281     ICOM_THIS(IMalloc32Impl,iface);
    282     TRACE("(%p)->Realloc(%p,%ld)\n",This,pv,cb);
    283     return HeapReAlloc(GetProcessHeap(),0,pv,cb);
     280        ICOM_THIS(IMalloc32Impl,iface);
     281        TRACE("(%p)->Realloc(%p,%ld)\n",This,pv,cb);
     282        return HeapReAlloc(GetProcessHeap(),0,pv,cb);
    284283}
    285284
     
    288287 */
    289288static VOID WINAPI IMalloc_fnFree(LPMALLOC iface,LPVOID pv) {
    290     ICOM_THIS(IMalloc32Impl,iface);
    291     TRACE("(%p)->Free(%p)\n",This,pv);
    292     HeapFree(GetProcessHeap(),0,pv);
     289        ICOM_THIS(IMalloc32Impl,iface);
     290        TRACE("(%p)->Free(%p)\n",This,pv);
     291        HeapFree(GetProcessHeap(),0,pv);
    293292}
    294293
     
    297296 */
    298297static DWORD WINAPI IMalloc_fnGetSize(LPMALLOC iface,LPVOID pv) {
    299     ICOM_CTHIS(IMalloc,iface);
    300     TRACE("(%p)->GetSize(%p)\n",This,pv);
    301     return HeapSize(GetProcessHeap(),0,pv);
     298        ICOM_CTHIS(IMalloc,iface);
     299        TRACE("(%p)->GetSize(%p)\n",This,pv);
     300        return HeapSize(GetProcessHeap(),0,pv);
    302301}
    303302
     
    306305 */
    307306static INT WINAPI IMalloc_fnDidAlloc(LPMALLOC iface,LPVOID pv) {
    308     ICOM_CTHIS(IMalloc32Impl,iface);
    309     TRACE("(%p)->DidAlloc(%p)\n",This,pv);
    310     return -1;
     307        ICOM_CTHIS(IMalloc32Impl,iface);
     308        TRACE("(%p)->DidAlloc(%p)\n",This,pv);
     309        return -1;
    311310}
    312311
     
    315314 */
    316315static VOID WINAPI IMalloc_fnHeapMinimize(LPMALLOC iface) {
    317     ICOM_THIS(IMalloc32Impl,iface);
    318     TRACE("(%p)->HeapMinimize()\n",This);
    319 }
    320 
    321 static ICOM_VTABLE(IMalloc) VT_IMalloc32 =
     316        ICOM_THIS(IMalloc32Impl,iface);
     317        TRACE("(%p)->HeapMinimize()\n",This);
     318}
     319
     320static ICOM_VTABLE(IMalloc) VT_IMalloc32 = 
    322321{
    323322    ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
     
    338337LPMALLOC
    339338IMalloc_Constructor() {
    340     IMalloc32Impl* This;
    341 
    342     This = (IMalloc32Impl*)HeapAlloc(GetProcessHeap(),0,sizeof(IMalloc32Impl));
    343     ICOM_VTBL(This) = &VT_IMalloc32;
    344     This->ref = 1;
    345     return (LPMALLOC)This;
     339        IMalloc32Impl* This;
     340
     341        This = (IMalloc32Impl*)HeapAlloc(GetProcessHeap(),0,sizeof(IMalloc32Impl));
     342        ICOM_VTBL(This) = &VT_IMalloc32;
     343        This->ref = 1;
     344        return (LPMALLOC)This;
    346345}
    347346
     
    351350
    352351/******************************************************************************
    353  *      IsValidInterface    [OLE32.78]
     352 *              IsValidInterface        [OLE32.78]
    354353 *
    355354 * RETURNS
     
    357356 */
    358357BOOL WINAPI IsValidInterface(
    359     LPUNKNOWN punk  /* [in] interface to be tested */
     358        LPUNKNOWN punk  /* [in] interface to be tested */
    360359) {
    361     return !(
    362         IsBadReadPtr(punk,4)                    ||
    363         IsBadReadPtr(ICOM_VTBL(punk),4)             ||
     360        return !(
     361                IsBadReadPtr(punk,4)                                    ||
     362                IsBadReadPtr(ICOM_VTBL(punk),4)                         ||
    364363#ifdef __WIN32OS2__
    365         IsBadReadPtr(ICOM_VTBL(punk)->fnQueryInterface,9)   ||
    366         IsBadCodePtr((FARPROC)ICOM_VTBL(punk)->fnQueryInterface)
     364                IsBadReadPtr(ICOM_VTBL(punk)->fnQueryInterface,9)       ||
     365                IsBadCodePtr((FARPROC)ICOM_VTBL(punk)->fnQueryInterface)
    367366#else
    368         IsBadReadPtr(ICOM_VTBL(punk)->QueryInterface,9) ||
    369         IsBadCodePtr((FARPROC)ICOM_VTBL(punk)->QueryInterface)
     367                IsBadReadPtr(ICOM_VTBL(punk)->QueryInterface,9) ||
     368                IsBadCodePtr((FARPROC)ICOM_VTBL(punk)->QueryInterface)
    370369#endif
    371     );
    372 }
     370        );
     371}
  • trunk/src/ole32/initole32.cpp

    r6648 r6711  
    1 /* $Id: initole32.cpp,v 1.3 2001-09-05 13:17:10 bird Exp $
     1/*
    22 * DLL entry point
    33 *
     
    5252   case DLL_THREAD_ATTACH:
    5353   case DLL_THREAD_DETACH:
    54     return OLE32_DllEntryPoint(hinstDLL, fdwReason, fImpLoad);
     54        return OLE32_DllEntryPoint(hinstDLL, fdwReason, fImpLoad);
    5555
    5656   case DLL_PROCESS_DETACH:
    5757        OLE32_DllEntryPoint(hinstDLL, fdwReason, fImpLoad);
    58     return TRUE;
     58        return TRUE;
    5959   }
    6060   return FALSE;
     
    8282      case 0 :
    8383      {
    84     dllHandle = RegisterLxDll(hModule, LibMainOLE32, (PVOID)&ole32os2_PEResTab);
    85          if(dllHandle == 0)
    86         return 0UL;
     84        dllHandle = RegisterLxDll(hModule, LibMainOLE32, (PVOID)&ole32os2_PEResTab);
     85         if(dllHandle == 0) 
     86                return 0UL;
    8787
    8888         break;
     
    9090      case 1 :
    9191         if(dllHandle) {
    92         UnregisterLxDll(dllHandle);
     92                UnregisterLxDll(dllHandle);
    9393         }
    9494         break;
  • trunk/src/ole32/initterm.cpp

    r6648 r6711  
    1 /* $Id: initterm.cpp,v 1.11 2001-09-05 13:17:10 bird Exp $
    2  *
     1/*
    32 * DLL entry point
    43 *
  • trunk/src/ole32/itemmoniker.c

    r6648 r6711  
    1 /* $Id: itemmoniker.c,v 1.2 2001-09-05 13:17:10 bird Exp $ */
    21/***************************************************************************************
    3  *                        ItemMonikers implementation
     2 *                            ItemMonikers implementation
    43 *
    54 *           Copyright 1999  Noomen Hamza
     
    2625    ICOM_VTABLE(IMoniker)*  lpvtbl1;  /* VTable relative to the IMoniker interface.*/
    2726
    28     /* The ROT (RunningObjectTable implementation) uses the IROTData interface to test whether
     27    /* The ROT (RunningObjectTable implementation) uses the IROTData interface to test whether 
    2928     * two monikers are equal. That's whay IROTData interface is implemented by monikers.
    3029     */
     
    3635
    3736    LPOLESTR itemDelimiter; /* Delimiter string */
    38 
     37   
    3938} ItemMonikerImpl;
    4039
     
    141140  /* Perform a sanity check on the parameters.*/
    142141    if ( (This==0) || (ppvObject==0) )
    143     return E_INVALIDARG;
    144 
     142        return E_INVALIDARG;
     143 
    145144  /* Initialize the return parameter */
    146145  *ppvObject = 0;
     
    153152     )
    154153      *ppvObject = iface;
    155 
     154 
    156155    else if (IsEqualIID(&IID_IROTData, riid))
    157156        *ppvObject = (IROTData*)&(This->lpvtbl2);
     
    160159    if ((*ppvObject)==0)
    161160        return E_NOINTERFACE;
    162 
     161 
    163162   /* Query Interface always increases the reference count by one when it is successful */
    164163  ItemMonikerImpl_AddRef(iface);
     
    209208    if (pClassID==NULL)
    210209        return E_POINTER;
    211 
     210           
    212211    *pClassID = CLSID_ItemMoniker;
    213 
     212       
    214213    return S_OK;
    215214}
     
    343342
    344343    /* for more details see ItemMonikerImpl_Save coments */
    345 
     344   
    346345    pcbSize->s.LowPart =  sizeof(DWORD) + /* DWORD which contains delimiter length */
    347346                        delimiterLength + /* item delimiter string */
     
    363362    int sizeStr1=lstrlenW(lpszItem), sizeStr2;
    364363    static const OLECHAR emptystr[1];
    365     LPCOLESTR   delim;
     364    LPCOLESTR   delim;
    366365
    367366    TRACE("(%p,%p)\n",This,lpszItem);
     
    374373    This->itemName=HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR)*(sizeStr1+1));
    375374    if (!This->itemName)
    376     return E_OUTOFMEMORY;
     375        return E_OUTOFMEMORY;
    377376    strcpyW(This->itemName,lpszItem);
    378377
    379378    if (!lpszDelim)
    380     FIXME("lpszDelim is NULL. Using empty string which is possibly wrong.\n");
     379        FIXME("lpszDelim is NULL. Using empty string which is possibly wrong.\n");
    381380
    382381    delim = lpszDelim ? lpszDelim : emptystr;
     
    385384    This->itemDelimiter=HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR)*(sizeStr2+1));
    386385    if (!This->itemDelimiter) {
    387     HeapFree(GetProcessHeap(),0,This->itemName);
    388     return E_OUTOFMEMORY;
     386        HeapFree(GetProcessHeap(),0,This->itemName);
     387        return E_OUTOFMEMORY;
    389388    }
    390389    strcpyW(This->itemDelimiter,delim);
     
    420419{
    421420    ICOM_THIS(ItemMonikerImpl,iface);
    422 
     421   
    423422    HRESULT   res;
    424423    IID    refid=IID_IOleItemContainer;
     
    467466    if(pmkToLeft==NULL)
    468467        return E_INVALIDARG;
    469 
     468       
    470469    res=IMoniker_BindToObject(pmkToLeft,pbc,NULL,&IID_IOleItemContainer,(void**)&poic);
    471470
     
    497496
    498497    *ppmkReduced=iface;
    499 
     498   
    500499    return MK_S_REDUCED_TO_SELF;
    501500}
     
    517516
    518517    if ((ppmkComposite==NULL)||(pmkRight==NULL))
    519     return E_POINTER;
     518        return E_POINTER;
    520519
    521520    *ppmkComposite=0;
    522 
     521   
    523522    IMoniker_IsSystemMoniker(pmkRight,&mkSys);
    524523
     
    530529        /* if pmkRight is a composite whose leftmost component is an anti-moniker,           */
    531530        /* the returned moniker is the composite after the leftmost anti-moniker is removed. */
    532 
     531       
    533532         if(mkSys==MKSYS_GENERICCOMPOSITE){
    534533
     
    548547                tempMkComposite=iface;
    549548                IMoniker_AddRef(iface);
    550 
     549               
    551550                while(IEnumMoniker_Next(penumMk,1,&pmostLeftMk,NULL)==S_OK){
    552551
     
    605604    if (pmkOtherMoniker==NULL)
    606605        return S_FALSE;
    607 
     606   
    608607    /* This method returns S_OK if both monikers are item monikers and their display names are */
    609608    /* identical (using a case-insensitive comparison); otherwise, the method returns S_FALSE. */
     
    620619    IMoniker_GetDisplayName(iface,bind,NULL,&dispName1);
    621620    IMoniker_GetDisplayName(pmkOtherMoniker,bind,NULL,&dispName2);
    622 
     621   
    623622    if (lstrcmpW(dispName1,dispName2)!=0)
    624623        return S_FALSE;
    625 
     624   
    626625    return S_OK;
    627626}
     
    640639    if (pdwHash==NULL)
    641640        return E_POINTER;
    642 
     641   
    643642    val =  This->itemName;
    644643    len = lstrlenW(val);
     
    650649    } else {
    651650        /* only sample some characters */
    652     skip = len / 8;
    653     for (i = len ; i > 0; i -= skip, off += skip) {
     651        skip = len / 8;
     652        for (i = len ; i > 0; i -= skip, off += skip) {
    654653            h = (h * 39) + val[off];
    655     }
     654        }
    656655    }
    657656
     
    699698        /* requesting an IOleItemContainer interface pointer. The method then calls IOleItemContainer::IsRunning,*/
    700699        /* passing the string contained within this moniker. */
    701 
     700       
    702701        res=IMoniker_BindToObject(pmkToLeft,pbc,NULL,&IID_IOleItemContainer,(void**)&poic);
    703702
     
    780779
    781780        *ppmkPrefix=iface;
    782 
     781       
    783782        IMoniker_AddRef(iface);
    784 
     783       
    785784        return MK_S_US;
    786785    }
     
    802801
    803802    *ppmkRelPath=0;
    804 
     803   
    805804    return MK_E_NOTBINDABLE;
    806805}
     
    832831    strcpyW(*ppszDisplayName,This->itemDelimiter);
    833832    strcatW(*ppszDisplayName,This->itemName);
    834 
     833   
    835834    return S_OK;
    836835}
     
    886885    if (!pwdMksys)
    887886        return E_POINTER;
    888 
     887   
    889888    (*pwdMksys)=MKSYS_ITEMMONIKER;
    890889
     
    923922{
    924923    ICOM_THIS_From_IROTData(IMoniker, iface);
    925 
     924   
    926925    TRACE("(%p)\n",iface);
    927926
     
    942941
    943942/******************************************************************************
    944  *        CreateItemMoniker16   [OLE2.28]
     943 *        CreateItemMoniker16   [OLE2.28]
    945944 ******************************************************************************/
    946945HRESULT WINAPI CreateItemMoniker16(LPCOLESTR16 lpszDelim,LPCOLESTR  lpszItem,LPMONIKER* ppmk)
     
    953952
    954953/******************************************************************************
    955  *        CreateItemMoniker [OLE.55]
     954 *        CreateItemMoniker     [OLE.55]
    956955 ******************************************************************************/
    957956HRESULT WINAPI CreateItemMoniker(LPCOLESTR lpszDelim,LPCOLESTR  lpszItem, LPMONIKER * ppmk)
  • trunk/src/ole32/memlockbytes.c

    r6648 r6711  
    1 /* $Id: memlockbytes.c,v 1.2 2001-09-05 13:17:10 bird Exp $ */
    21/******************************************************************************
    32 *
     
    2625{
    2726  /*
    28    * Needs to be the first item in the stuct
     27   * Needs to be the first item in the stuct 
    2928   * since we want to cast this in an ILockBytes pointer
    3029   */
     
    189188  HGLOBALLockBytesImpl* newLockBytes;
    190189  newLockBytes = HeapAlloc(GetProcessHeap(), 0, sizeof(HGLOBALLockBytesImpl));
    191 
     190 
    192191  if (newLockBytes!=0)
    193192  {
     
    197196    ICOM_VTBL(newLockBytes) = &HGLOBALLockBytesImpl_Vtbl;
    198197    newLockBytes->ref    = 0;
    199 
     198 
    200199    /*
    201200     * Initialize the support.
     
    399398   * The function returns S_OK if the specified number of bytes were read
    400399   * or the end of the array was reached.
    401    * It returns STG_E_READFAULT if the number of bytes to read does not equal
     400   * It returns STG_E_READFAULT if the number of bytes to read does not equal 
    402401   * the number of bytes actually read.
    403402   */
     
    504503  if (libNewSize.s.HighPart != 0)
    505504    return STG_E_INVALIDFUNCTION;
    506 
     505 
    507506  if (This->byteArraySize.s.LowPart == libNewSize.s.LowPart)
    508507    return S_OK;
     
    519518
    520519  This->byteArraySize.s.LowPart = libNewSize.s.LowPart;
    521 
     520 
    522521  return S_OK;
    523522}
  • trunk/src/ole32/moniker.c

    r6648 r6711  
    1 /* $Id: moniker.c,v 1.3 2001-09-05 13:17:10 bird Exp $ */
    21/*
    3  *  Monikers
     2 *      Monikers
    43 *
    5  *  Copyright 1998  Marcus Meissner
     4 *      Copyright 1998  Marcus Meissner
    65 *      Copyright 1999  Noomen Hamza
    76 */
     
    2322#include "compobj_private.h"
    2423
     24#ifdef __WIN32OS2__
     25#undef FIXME
     26#undef TRACE
     27#ifdef DEBUG
     28#define TRACE WriteLog("OLE32: %s", __FUNCTION__); WriteLog
     29#define FIXME WriteLog("FIXME OLE32: %s", __FUNCTION__); WriteLog
     30#else
     31#define TRACE 1 ? (void)0 : (void)((int (*)(char *, ...)) NULL)
     32#define FIXME 1 ? (void)0 : (void)((int (*)(char *, ...)) NULL)
     33#endif
     34#endif
     35
    2536DEFAULT_DEBUG_CHANNEL(ole);
    2637
     
    4758    DWORD      runObjTabLastIndx;  /* first free index element in the table.        */
    4859    DWORD      runObjTabRegister; /* registration key of the next registered object */
    49 
     60   
    5061} RunningObjectTableImpl;
    5162
     
    137148{
    138149    TRACE("()\n");
    139 
     150   
    140151    if (runningObjectTableInstance==NULL)
    141152        return E_INVALIDARG;
     
    170181            if (( This->runObjTab[i].regTypeObj &  ROTFLAGS_REGISTRATIONKEEPSALIVE) != 0)
    171182                IUnknown_Release(This->runObjTab[i].pObj);
    172 
     183 
    173184            IMoniker_Release(This->runObjTab[i].pmkObj);
    174185        }
     
    230241    if (runningObjectTableInstance==NULL)
    231242        return E_POINTER;
    232 
     243   
    233244    RunningObjectTableImpl_Release((IRunningObjectTable*)runningObjectTableInstance);
    234245
     
    271282    This->runObjTab[This->runObjTabLastIndx].identRegObj = This->runObjTabRegister;
    272283    CoFileTimeNow(&(This->runObjTab[This->runObjTabLastIndx].lastModifObj));
    273 
     284   
    274285    /* gives a registration identifier to the registered object*/
    275286    (*pdwRegister)= This->runObjTabRegister;
     
    278289
    279290        FIXME("runObjTabRegister: %ld is out of data limite \n",This->runObjTabRegister);
    280     return E_FAIL;
     291        return E_FAIL;
    281292}
    282293    This->runObjTabRegister++;
    283294    This->runObjTabLastIndx++;
    284 
     295   
    285296    if (This->runObjTabLastIndx == This->runObjTabSize){ /* table is full ! so it must be resized */
    286297
     
    296307
    297308    IMoniker_AddRef(pmkObjectName);
    298 
     309   
    299310    return res;
    300311}
     
    322333
    323334    IMoniker_Release(This->runObjTab[index].pmkObj);
    324 
     335   
    325336    /* remove the object from the table */
    326337    for(j=index; j<This->runObjTabLastIndx-1; j++)
    327338        This->runObjTab[j]= This->runObjTab[j+1];
    328 
     339   
    329340    This->runObjTabLastIndx--;
    330341
     
    337348HRESULT WINAPI RunningObjectTableImpl_IsRunning(  IRunningObjectTable* iface,
    338349                                                  IMoniker *pmkObjectName)  /* Pointer to the moniker of the object whose status is desired */
    339 {
     350{   
    340351    ICOM_THIS(RunningObjectTableImpl,iface);
    341352
     
    359370    if (ppunkObject==NULL)
    360371        return E_POINTER;
    361 
     372   
    362373    *ppunkObject=0;
    363374
     
    394405    return S_OK;
    395406}
    396 
     407   
    397408/***********************************************************************
    398409 *        RunningObjectTable_GetTimeOfLastChange
     
    448459        /* search object identified by a register identifier */
    449460        for(i=0;((i<This->runObjTabLastIndx)&&(This->runObjTab[i].identRegObj!=identReg));i++);
    450 
     461   
    451462    if (i==This->runObjTabLastIndx)  return S_FALSE;
    452463
     
    457468
    458469/******************************************************************************
    459  *      GetRunningObjectTable16 [OLE2.30]
     470 *              GetRunningObjectTable16 [OLE2.30]
    460471 */
    461472HRESULT WINAPI GetRunningObjectTable16(DWORD reserved, LPRUNNINGOBJECTTABLE *pprot)
    462473{
    463     FIXME("(%ld,%p),stub!\n",reserved,pprot);
     474        FIXME("(%ld,%p),stub!\n",reserved,pprot);
    464475    return E_NOTIMPL;
    465476}
     
    491502HRESULT WINAPI OleRun(LPUNKNOWN pUnknown)
    492503{
    493   IRunnableObject   *runable;
     504  IRunnableObject       *runable;
    494505  ICOM_THIS(IRunnableObject,pUnknown);
    495   LRESULT       ret;
     506  LRESULT               ret;
    496507
    497508#ifdef __WIN32OS2__
     
    502513
    503514  ret = IRunnableObject_QueryInterface(This,&IID_IRunnableObject,(LPVOID*)&runable);
    504   if (ret)
    505     return 0; /* Appears to return no error. */
     515  if (ret) 
     516        return 0; /* Appears to return no error. */
    506517  ret  = IRunnableObject_Run(runable,NULL);
    507518  IRunnableObject_Release(runable);
     
    513524 */
    514525HRESULT WINAPI MkParseDisplayName(LPBC pbc, LPCOLESTR szUserName,
    515                 LPDWORD pchEaten, LPMONIKER *ppmk)
     526                                LPDWORD pchEaten, LPMONIKER *ppmk)
    516527{
    517528    FIXME("(%p, %s, %p, %p): stub.\n", pbc, debugstr_w(szUserName), pchEaten, *ppmk);
    518529    if (!(IsValidInterface((LPUNKNOWN) pbc)))
    519     return E_INVALIDARG;
     530        return E_INVALIDARG;
    520531
    521532    return MK_E_SYNTAX;
  • trunk/src/ole32/ole2.c

    r6648 r6711  
    1 /* $Id: ole2.c,v 1.2 2001-09-05 13:17:11 bird Exp $ */
    21/*
    3  *  OLE2 library
    4  *
    5  *  Copyright 1995  Martin von Loewis
     2 *      OLE2 library
     3 *
     4 *      Copyright 1995  Martin von Loewis
    65 *      Copyright 1999  Francis Beaudet
    7  *      Copyright 1999  Noel Borthwick
     6 *      Copyright 1999  Noel Borthwick 
    87 */
    98
     
    3332
    3433/******************************************************************************
    35  * These are static/global variables and internal data structures that the
     34 * These are static/global variables and internal data structures that the 
    3635 * OLE module uses to maintain it's state.
    3736 */
     
    9594
    9695/******************************************************************************
    97  * These are the prototypes of miscelaneous utility methods
     96 * These are the prototypes of miscelaneous utility methods 
    9897 */
    9998static void OLEUTL_ReadRegistryDWORDValue(HKEY regKey, DWORD* pdwValue);
     
    124123static void            OLEDD_UnInitialize();
    125124static void            OLEDD_InsertDropTarget(
    126             DropTargetNode* nodeToAdd);
     125                        DropTargetNode* nodeToAdd);
    127126static DropTargetNode* OLEDD_ExtractDropTarget(
    128127                         HWND hwndOfTarget);
     
    130129                         HWND hwndOfTarget);
    131130static LRESULT WINAPI  OLEDD_DragTrackerWindowProc(
    132              HWND   hwnd,
    133             UINT   uMsg,
    134              WPARAM wParam,
    135             LPARAM   lParam);
     131                         HWND   hwnd,
     132                        UINT   uMsg,
     133                         WPARAM wParam,
     134                        LPARAM   lParam);
    136135static void OLEDD_TrackMouseMove(
    137136                         TrackerWindowInfo* trackerInfo,
    138             POINT            mousePos,
    139             DWORD              keyState);
     137                        POINT            mousePos,
     138                        DWORD              keyState);
    140139static void OLEDD_TrackStateChange(
    141140                         TrackerWindowInfo* trackerInfo,
    142             POINT            mousePos,
    143             DWORD              keyState);
     141                        POINT            mousePos,
     142                        DWORD              keyState);
    144143static DWORD OLEDD_GetButtonState();
    145144
    146145
    147146/******************************************************************************
    148  *      OleBuildVersion [OLE2.1]
     147 *              OleBuildVersion [OLE2.1]
    149148 */
    150149DWORD WINAPI OleBuildVersion(void)
     
    169168
    170169  /*
    171    * If the CoInitializeEx call failed, the OLE libraries can't be
     170   * If the CoInitializeEx call failed, the OLE libraries can't be 
    172171   * initialized.
    173172   */
    174173  if (FAILED(hr))
    175     return hr;
     174    return hr;   
    176175
    177176  /*
     
    185184  if (OLE_moduleLockCount==0)
    186185{
    187     /*
     186    /* 
    188187     * Initialize the libraries.
    189188     */
     
    209208   * Then, we increase the lock count on the OLE module.
    210209   */
    211   OLE_moduleLockCount++;
     210  OLE_moduleLockCount++; 
    212211
    213212  return hr;
     
    215214
    216215/******************************************************************************
    217  *      CoGetCurrentProcess [COMPOBJ.34] [OLE2.2][OLE32.108]
     216 *              CoGetCurrentProcess     [COMPOBJ.34] [OLE2.2][OLE32.108]
    218217 *
    219218 * NOTES
     
    222221DWORD WINAPI CoGetCurrentProcess(void)
    223222{
    224     return GetCurrentProcessId();
     223        return GetCurrentProcessId();
    225224}
    226225
    227226/******************************************************************************
    228  *      OleUninitialize [OLE2.3] [OLE32.131]
     227 *              OleUninitialize [OLE2.3] [OLE32.131]
    229228 */
    230229void WINAPI OleUninitialize(void)
     
    256255     */
    257256    OLEDD_UnInitialize();
    258 
     257   
    259258    /*
    260259     * OLE shared menu
     
    262261    OLEMenu_UnInitialize();
    263262  }
    264 
     263 
    265264  /*
    266265   * Then, uninitialize the COM libraries.
     
    272271//imessagefilter.cpp
    273272/******************************************************************************
    274  *      CoRegisterMessageFilter [OLE32.38]
     273 *              CoRegisterMessageFilter [OLE32.38]
    275274 */
    276275HRESULT WINAPI CoRegisterMessageFilter(
    277     LPMESSAGEFILTER lpMessageFilter,    /* [in] Pointer to interface */
    278     LPMESSAGEFILTER *lplpMessageFilter  /* [out] Indirect pointer to prior instance if non-NULL */
     276    LPMESSAGEFILTER lpMessageFilter,    /* [in] Pointer to interface */
     277    LPMESSAGEFILTER *lplpMessageFilter  /* [out] Indirect pointer to prior instance if non-NULL */
    279278) {
    280279    FIXME("stub\n");
    281280    if (lplpMessageFilter) {
    282     *lplpMessageFilter = NULL;
     281        *lplpMessageFilter = NULL;
    283282    }
    284283    return S_OK;
     
    287286
    288287/******************************************************************************
    289  *      OleInitializeWOW    [OLE32.109]
     288 *              OleInitializeWOW        [OLE32.109]
    290289 */
    291290HRESULT WINAPI OleInitializeWOW(DWORD x) {
     
    298297 */
    299298HRESULT WINAPI RegisterDragDrop16(
    300     HWND16 hwnd,
    301     LPDROPTARGET pDropTarget
     299        HWND16 hwnd,
     300        LPDROPTARGET pDropTarget
    302301) {
    303     FIXME("(0x%04x,%p),stub!\n",hwnd,pDropTarget);
    304     return S_OK;
     302        FIXME("(0x%04x,%p),stub!\n",hwnd,pDropTarget);
     303        return S_OK;
    305304}
    306305
     
    309308 */
    310309HRESULT WINAPI RegisterDragDrop(
    311     HWND hwnd,
    312     LPDROPTARGET pDropTarget)
     310        HWND hwnd,
     311        LPDROPTARGET pDropTarget)
    313312{
    314313  DropTargetNode* dropTargetInfo;
     
    342341  dropTargetInfo->dropTarget  = pDropTarget;
    343342  IDropTarget_AddRef(dropTargetInfo->dropTarget);
    344 
     343 
    345344  OLEDD_InsertDropTarget(dropTargetInfo);
    346345
    347     return S_OK;
     346        return S_OK;
    348347}
    349348
     
    352351 */
    353352HRESULT WINAPI RevokeDragDrop16(
    354     HWND16 hwnd
     353        HWND16 hwnd
    355354) {
    356     FIXME("(0x%04x),stub!\n",hwnd);
    357     return S_OK;
     355        FIXME("(0x%04x),stub!\n",hwnd);
     356        return S_OK;
    358357}
    359358
     
    362361 */
    363362HRESULT WINAPI RevokeDragDrop(
    364     HWND hwnd)
     363        HWND hwnd)
    365364{
    366365  DropTargetNode* dropTargetInfo;
     
    384383   */
    385384  IDropTarget_Release(dropTargetInfo->dropTarget);
    386   HeapFree(GetProcessHeap(), 0, dropTargetInfo);
    387 
    388     return S_OK;
     385  HeapFree(GetProcessHeap(), 0, dropTargetInfo); 
     386
     387        return S_OK;
    389388}
    390389
     
    397396 * way they are registered.
    398397 */
    399 HRESULT WINAPI OleRegGetUserType(
    400     REFCLSID clsid,
    401     DWORD dwFormOfType,
    402     LPOLESTR* pszUserType)
     398HRESULT WINAPI OleRegGetUserType( 
     399        REFCLSID clsid,
     400        DWORD dwFormOfType,
     401        LPOLESTR* pszUserType)
    403402{
    404403  char    keyName[60];
     
    428427   */
    429428  hres = RegOpenKeyA(HKEY_CLASSES_ROOT,
    430              keyName,
    431              &clsidKey);
     429                     keyName,
     430                     &clsidKey);
    432431
    433432  if (hres != ERROR_SUCCESS)
     
    440439
    441440  hres = RegQueryValueExA(clsidKey,
    442               "",
    443               NULL,
    444               &dwKeyType,
    445               NULL,
    446               &cbData);
     441                          "",
     442                          NULL,
     443                          &dwKeyType,
     444                          NULL,
     445                          &cbData);
    447446
    448447  if (hres!=ERROR_SUCCESS)
     
    474473
    475474  hres = RegQueryValueExA(clsidKey,
    476               "",
    477               NULL,
    478               &dwKeyType,
    479               buffer,
    480               &cbData);
     475                          "",
     476                          NULL,
     477                          &dwKeyType,
     478                          buffer,
     479                          &cbData);
    481480
    482481  RegCloseKey(clsidKey);
    483482
    484 
     483 
    485484  if (hres!=ERROR_SUCCESS)
    486485  {
     
    528527
    529528  hwndTrackWindow = CreateWindowA(OLEDD_DRAGTRACKERCLASS,
    530                     "TrackerWindow",
    531                     WS_POPUP,
    532                     CW_USEDEFAULT, CW_USEDEFAULT,
    533                     CW_USEDEFAULT, CW_USEDEFAULT,
    534                     0,
    535                     0,
    536                     0,
    537                     (LPVOID)&trackerInfo);
     529                                    "TrackerWindow",
     530                                    WS_POPUP,
     531                                    CW_USEDEFAULT, CW_USEDEFAULT,
     532                                    CW_USEDEFAULT, CW_USEDEFAULT,
     533                                    0,
     534                                    0,
     535                                    0,
     536                                    (LPVOID)&trackerInfo);
    538537
    539538  if (hwndTrackWindow!=0)
     
    549548    while (!trackerInfo.trackingDone && GetMessageA(&msg, 0, 0, 0) )
    550549    {
    551       if ( (msg.message >= WM_KEYFIRST) &&
    552        (msg.message <= WM_KEYLAST) )
     550      if ( (msg.message >= WM_KEYFIRST) && 
     551           (msg.message <= WM_KEYLAST) )
    553552      {
    554     /*
    555     * When keyboard messages are sent to windows on this thread, we
    556     * want to ignore notify the drop source that the state changed.
    557     * in the case of the Escape key, we also notify the drop source
    558     * we give it a special meaning.
    559     */
    560     if ( (msg.message==WM_KEYDOWN) &&
    561          (msg.wParam==VK_ESCAPE) )
    562     {
    563       trackerInfo.escPressed = TRUE;
    564     }
    565 
    566     /*
    567     * Notify the drop source.
    568      */
    569     OLEDD_TrackStateChange(&trackerInfo,
    570                    msg.pt,
    571                    OLEDD_GetButtonState());
     553        /*
     554        * When keyboard messages are sent to windows on this thread, we
     555        * want to ignore notify the drop source that the state changed.
     556        * in the case of the Escape key, we also notify the drop source
     557        * we give it a special meaning.
     558        */
     559        if ( (msg.message==WM_KEYDOWN) &&
     560             (msg.wParam==VK_ESCAPE) )
     561        {
     562          trackerInfo.escPressed = TRUE;
     563        }
     564
     565        /*
     566        * Notify the drop source.
     567         */       
     568        OLEDD_TrackStateChange(&trackerInfo,
     569                               msg.pt,
     570                               OLEDD_GetButtonState());
    572571      }
    573572      else
    574573      {
    575     /*
    576     * Dispatch the messages only when it's not a keyboard message.
    577     */
    578     DispatchMessageA(&msg);
     574        /*
     575        * Dispatch the messages only when it's not a keyboard message.
     576        */
     577        DispatchMessageA(&msg);
    579578      }
    580579    }
     
    634633   */
    635634  result = RegOpenKeyA(HKEY_CLASSES_ROOT,
    636                keyName,
    637                &clsidKey);
     635                       keyName,
     636                       &clsidKey);
    638637
    639638  if (result != ERROR_SUCCESS)
     
    644643   */
    645644  result = RegOpenKeyA(clsidKey,
    646                "MiscStatus",
    647                &miscStatusKey);
    648 
    649 
     645                       "MiscStatus",
     646                       &miscStatusKey);
     647
     648 
    650649  if (result != ERROR_SUCCESS)
    651650  {
     
    665664
    666665  result = RegOpenKeyA(miscStatusKey,
    667                keyName,
    668                &aspectKey);
    669 
     666                       keyName,
     667                       &aspectKey);
     668 
    670669  if (result == ERROR_SUCCESS)
    671670  {
     
    687686 */
    688687HRESULT WINAPI OleSetContainedObject(
    689   LPUNKNOWN pUnknown,
     688  LPUNKNOWN pUnknown, 
    690689  BOOL      fContained)
    691690{
     
    696695
    697696  hres = IUnknown_QueryInterface(pUnknown,
    698                 &IID_IRunnableObject,
    699                 (void**)&runnable);
     697                                &IID_IRunnableObject,
     698                                (void**)&runnable);
    700699
    701700  if (SUCCEEDED(hres))
     
    715714 */
    716715HRESULT WINAPI OleLoad(
    717   LPSTORAGE       pStg,
    718   REFIID          riid,
    719   LPOLECLIENTSITE pClientSite,
     716  LPSTORAGE       pStg, 
     717  REFIID          riid, 
     718  LPOLECLIENTSITE pClientSite, 
    720719  LPVOID*         ppvObj)
    721720{
     
    726725
    727726  TRACE("(%p,%p,%p,%p)\n", pStg, riid, pClientSite, ppvObj);
    728 
     727 
    729728  /*
    730729   * TODO, Conversion ... OleDoAutoConvert
     
    740739   */
    741740  hres = CoCreateInstance(&storageInfo.clsid,
    742               NULL,
    743               CLSCTX_INPROC_HANDLER,
    744               &IID_IOleObject,
    745               (void**)&oleObject);
     741                          NULL,
     742                          CLSCTX_INPROC_HANDLER,
     743                          &IID_IOleObject,
     744                          (void**)&oleObject);
    746745
    747746  /*
     
    752751  {
    753752    hres = OleCreateDefaultHandler(&storageInfo.clsid,
    754                    NULL,
    755                    &IID_IOleObject,
    756                    (void**)&oleObject);
     753                                   NULL,
     754                                   &IID_IOleObject,
     755                                   (void**)&oleObject);
    757756  }
    758757
     
    772771   */
    773772  hres = IOleObject_QueryInterface(oleObject,
    774                    &IID_IPersistStorage,
    775                    (void**)&persistStorage);
    776 
    777   if (SUCCEEDED(hres))
     773                                   &IID_IPersistStorage,
     774                                   (void**)&persistStorage);
     775
     776  if (SUCCEEDED(hres)) 
    778777  {
    779778    IPersistStorage_Load(persistStorage, pStg);
     
    828827  {
    829828    IStorage_Commit(pStg,
    830             STGC_DEFAULT);
    831   }
    832 
     829                    STGC_DEFAULT);
     830  }
     831 
    833832  return hres;
    834833}
     
    838837 *              OleLockRunning        [OLE32.114]
    839838 */
    840 HRESULT WINAPI OleLockRunning(LPUNKNOWN pUnknown, BOOL fLock, BOOL fLastUnlockCloses)
     839HRESULT WINAPI OleLockRunning(LPUNKNOWN pUnknown, BOOL fLock, BOOL fLastUnlockCloses) 
    841840{
    842841  IRunnableObject* runnable = NULL;
     
    846845
    847846  hres = IUnknown_QueryInterface(pUnknown,
    848                 &IID_IRunnableObject,
    849                 (void**)&runnable);
     847                                &IID_IRunnableObject,
     848                                (void**)&runnable);
    850849
    851850  if (SUCCEEDED(hres))
     
    903902  pHookItem->tid = tid;
    904903  pHookItem->hHeap = GetProcessHeap();
    905 
     904 
    906905  /* Install a thread scope message hook for WH_GETMESSAGE */
    907906  pHookItem->GetMsg_hHook = SetWindowsHookExA( WH_GETMESSAGE, OLEMenu_GetMsgProc,
     
    919918  pHookItem->next = hook_list;
    920919  hook_list = pHookItem;
    921 
     920 
    922921  return TRUE;
    923 
     922 
    924923CLEANUP:
    925924  /* Unhook any hooks */
     
    930929  /* Release the hook table entry */
    931930  HeapFree(pHookItem->hHeap, 0, pHookItem );
    932 
     931 
    933932  return FALSE;
    934933}
     
    995994      return pHookItem;
    996995  }
    997 
     996 
    998997  return NULL;
    999998}
     
    10161015  {
    10171016    HMENU hsubmenu;
    1018 
     1017     
    10191018    /*  Is the current item a submenu? */
    10201019    if ( (hsubmenu = GetSubMenu(hMainMenu, i)) )
     
    10631062  if ( !OLEMenu_FindMainMenuIndex( pOleMenuDescriptor->hmenuCombined, hmenu,  &nPos ) )
    10641063    return FALSE;
    1065 
     1064 
    10661065  /* The group widths array has counts for the number of elements
    10671066   * in the groups File, Edit, Container, Object, Window, Help.
     
    10961095  OleMenuHookItem *pHookItem = NULL;
    10971096  WORD fuFlags;
    1098 
     1097 
    10991098  TRACE("%i, %04x, %08x\n", code, wParam, (unsigned)lParam );
    11001099
     
    11021101  if ( HC_ACTION != code )
    11031102    goto NEXTHOOK;
    1104 
     1103     
    11051104  /* Retrieve the current message being dispatched from lParam */
    11061105  pMsg = (LPCWPSTRUCT)lParam;
     
    11321131      goto NEXTHOOK;
    11331132    }
    1134 
     1133   
    11351134    case WM_INITMENUPOPUP:
    11361135    {
     
    11391138      break;
    11401139    }
    1141 
     1140   
    11421141    case WM_MENUSELECT:
    11431142    {
     
    11521151      break;
    11531152    }
    1154 
     1153   
    11551154    case WM_DRAWITEM:
    11561155    {
     
    11721171                  pMsg->message, pMsg->wParam, pMsg->lParam );
    11731172  }
    1174 
     1173   
    11751174NEXTHOOK:
    11761175  if ( pOleMenuDescriptor )
    11771176    GlobalUnlock( hOleMenu );
    1178 
     1177 
    11791178  /* Lookup the hook item for the current thread */
    11801179  if ( !( pHookItem = OLEMenu_IsHookInstalled( GetCurrentThreadId() ) ) )
     
    11841183    return 0;
    11851184  }
    1186 
     1185 
    11871186  /* Pass on the message to the next hooker */
    11881187  return CallNextHookEx( pHookItem->CallWndProc_hHook, code, wParam, lParam );
     
    12011200  OleMenuHookItem *pHookItem = NULL;
    12021201  WORD wCode;
    1203 
     1202 
    12041203  TRACE("%i, %04x, %08x\n", code, wParam, (unsigned)lParam );
    12051204
     
    12071206  if ( HC_ACTION != code )
    12081207    goto NEXTHOOK;
    1209 
     1208     
    12101209  /* Retrieve the current message being dispatched from lParam */
    12111210  pMsg = (LPMSG)lParam;
     
    12461245    pMsg->hwnd = pOleMenuDescriptor->hwndActiveObject;
    12471246  }
    1248 
     1247   
    12491248NEXTHOOK:
    12501249  if ( pOleMenuDescriptor )
    12511250    GlobalUnlock( hOleMenu );
    1252 
     1251 
    12531252  /* Lookup the hook item for the current thread */
    12541253  if ( !( pHookItem = OLEMenu_IsHookInstalled( GetCurrentThreadId() ) ) )
     
    12581257    return FALSE;
    12591258  }
    1260 
     1259 
    12611260  /* Pass on the message to the next hooker */
    12621261  return CallNextHookEx( pHookItem->GetMsg_hHook, code, wParam, lParam );
     
    12961295  for ( i = 0; i < 6; i++ )
    12971296    pOleMenuDescriptor->mgw.width[i] = lpMenuWidths->width[i];
    1298 
     1297 
    12991298  pOleMenuDescriptor->hmenuCombined = hmenuCombined;
    13001299  pOleMenuDescriptor->bIsServerItem = FALSE;
    13011300  GlobalUnlock( hOleMenu );
    1302 
     1301     
    13031302  return hOleMenu;
    13041303}
     
    13131312  if ( hmenuDescriptor )
    13141313    GlobalFree( hmenuDescriptor );
    1315     return S_OK;
     1314        return S_OK;
    13161315}
    13171316
     
    13221321 * OLE should install context sensitive help F1 filtering for the app when
    13231322 * these are non null.
    1324  *
     1323 * 
    13251324 * PARAMS:
    13261325 *     hOleMenu         Handle to composite menu descriptor
     
    13501349  {
    13511350     FIXME("(%x, %x, %x, %p, %p), Context sensitive help filtering not implemented!\n",
    1352     (unsigned int)hOleMenu,
    1353     hwndFrame,
    1354     hwndActiveObject,
    1355     lpFrame,
    1356     lpActiveObject);
     1351        (unsigned int)hOleMenu,
     1352        hwndFrame,
     1353        hwndActiveObject,
     1354        lpFrame,
     1355        lpActiveObject);
    13571356  }
    13581357
     
    13701369    if ( OLEMenu_IsHookInstalled( GetCurrentThreadId() ) )
    13711370  return E_FAIL;
    1372 
     1371       
    13731372    /* Get the menu descriptor */
    13741373    pOleMenuDescriptor = (OleMenuDescriptor *) GlobalLock( hOleMenu );
     
    13821381    GlobalUnlock( hOleMenu );
    13831382    pOleMenuDescriptor = NULL;
    1384 
     1383   
    13851384    /* Add a menu descriptor windows property to the frame window */
    13861385    SetPropA( hwndFrame, "PROP_OLEMenuDescriptor", hOleMenu );
     
    13951394    if ( !OLEMenu_UnInstallHooks( GetCurrentThreadId() ) )
    13961395      return E_FAIL;
    1397 
     1396   
    13981397    /* Remove the menu descriptor property from the frame window */
    13991398    RemovePropA( hwndFrame, "PROP_OLEMenuDescriptor" );
    14001399  }
    1401 
     1400     
    14021401  return S_OK;
    14031402}
     
    14201419#endif
    14211420    {
    1422     WARN_(accel)("invalid accel handle=%04x\n", hAccel);
    1423     return FALSE;
     1421        WARN_(accel)("invalid accel handle=%04x\n", hAccel);
     1422        return FALSE;
    14241423    }
    14251424    if((lpMsg->message != WM_KEYDOWN &&
    1426     lpMsg->message != WM_KEYUP &&
    1427     lpMsg->message != WM_SYSKEYDOWN &&
    1428     lpMsg->message != WM_SYSKEYUP &&
    1429     lpMsg->message != WM_CHAR)) return FALSE;
     1425        lpMsg->message != WM_KEYUP &&
     1426        lpMsg->message != WM_SYSKEYDOWN &&
     1427        lpMsg->message != WM_SYSKEYUP &&
     1428        lpMsg->message != WM_CHAR)) return FALSE;
    14301429
    14311430    TRACE_(accel)("hAccel=%04x, cAccelEntries=%d,"
    1432         "msg->hwnd=%04x, msg->message=%04x, wParam=%08x, lParam=%08lx\n",
    1433         hAccel, cAccelEntries,
    1434         lpMsg->hwnd, lpMsg->message, lpMsg->wParam, lpMsg->lParam);
     1431                "msg->hwnd=%04x, msg->message=%04x, wParam=%08x, lParam=%08lx\n",
     1432                hAccel, cAccelEntries,
     1433                lpMsg->hwnd, lpMsg->message, lpMsg->wParam, lpMsg->lParam);
    14351434    for(i = 0; i < cAccelEntries; i++)
    14361435    {
    1437     if(lpAccelTbl[i].key != lpMsg->wParam)
    1438         continue;
    1439 
    1440     if(lpMsg->message == WM_CHAR)
    1441     {
    1442         if(!(lpAccelTbl[i].fVirt & FALT) && !(lpAccelTbl[i].fVirt & FVIRTKEY))
    1443         {
    1444         TRACE_(accel)("found accel for WM_CHAR: ('%c')\n", lpMsg->wParam & 0xff);
    1445         goto found;
    1446         }
    1447     }
    1448     else
    1449     {
    1450         if(lpAccelTbl[i].fVirt & FVIRTKEY)
    1451         {
    1452         INT mask = 0;
    1453         TRACE_(accel)("found accel for virt_key %04x (scan %04x)\n",
    1454                 lpMsg->wParam, HIWORD(lpMsg->lParam) & 0xff);
    1455         if(GetKeyState(VK_SHIFT) & 0x8000) mask |= FSHIFT;
    1456         if(GetKeyState(VK_CONTROL) & 0x8000) mask |= FCONTROL;
    1457         if(GetKeyState(VK_MENU) & 0x8000) mask |= FALT;
    1458         if(mask == (lpAccelTbl[i].fVirt & (FSHIFT | FCONTROL | FALT))) goto found;
    1459         TRACE_(accel)("incorrect SHIFT/CTRL/ALT-state\n");
    1460         }
    1461         else
    1462         {
    1463         if(!(lpMsg->lParam & 0x01000000))  /* no special_key */
    1464         {
    1465             if((lpAccelTbl[i].fVirt & FALT) && (lpMsg->lParam & 0x20000000))
    1466             {                              /* ^^ ALT pressed */
    1467             TRACE_(accel)("found accel for Alt-%c\n", lpMsg->wParam & 0xff);
    1468             goto found;
    1469             }
    1470         }
    1471         }
    1472     }
    1473     }
     1436        if(lpAccelTbl[i].key != lpMsg->wParam)
     1437            continue;
     1438
     1439        if(lpMsg->message == WM_CHAR)
     1440        {
     1441            if(!(lpAccelTbl[i].fVirt & FALT) && !(lpAccelTbl[i].fVirt & FVIRTKEY))
     1442            {
     1443                TRACE_(accel)("found accel for WM_CHAR: ('%c')\n", lpMsg->wParam & 0xff);
     1444                goto found;
     1445            }
     1446        }
     1447        else
     1448        {
     1449            if(lpAccelTbl[i].fVirt & FVIRTKEY)
     1450            {
     1451                INT mask = 0;
     1452                TRACE_(accel)("found accel for virt_key %04x (scan %04x)\n",
     1453                                lpMsg->wParam, HIWORD(lpMsg->lParam) & 0xff);
     1454                if(GetKeyState(VK_SHIFT) & 0x8000) mask |= FSHIFT;
     1455                if(GetKeyState(VK_CONTROL) & 0x8000) mask |= FCONTROL;
     1456                if(GetKeyState(VK_MENU) & 0x8000) mask |= FALT;
     1457                if(mask == (lpAccelTbl[i].fVirt & (FSHIFT | FCONTROL | FALT))) goto found;
     1458                TRACE_(accel)("incorrect SHIFT/CTRL/ALT-state\n");
     1459            }
     1460            else
     1461            {
     1462                if(!(lpMsg->lParam & 0x01000000))  /* no special_key */
     1463                {
     1464                    if((lpAccelTbl[i].fVirt & FALT) && (lpMsg->lParam & 0x20000000))
     1465                    {                                                  /* ^^ ALT pressed */
     1466                        TRACE_(accel)("found accel for Alt-%c\n", lpMsg->wParam & 0xff);
     1467                        goto found;
     1468                    }
     1469                }
     1470            }
     1471        }
     1472    }   
    14741473
    14751474    WARN_(accel)("couldn't translate accelerator key\n");
     
    14911490    case TYMED_HGLOBAL:
    14921491    {
    1493       if ( (pmedium->pUnkForRelease==0) &&
    1494        (pmedium->u.hGlobal!=0) )
    1495     GlobalFree(pmedium->u.hGlobal);
     1492      if ( (pmedium->pUnkForRelease==0) && 
     1493           (pmedium->u.hGlobal!=0) )
     1494        GlobalFree(pmedium->u.hGlobal);
    14961495
    14971496      pmedium->u.hGlobal = 0;
     
    15021501      if (pmedium->u.lpszFileName!=0)
    15031502      {
    1504     if (pmedium->pUnkForRelease==0)
    1505     {
    1506       DeleteFileW(pmedium->u.lpszFileName);
    1507     }
    1508 
    1509     CoTaskMemFree(pmedium->u.lpszFileName);
     1503        if (pmedium->pUnkForRelease==0)
     1504        {
     1505          DeleteFileW(pmedium->u.lpszFileName);
     1506        }
     1507       
     1508        CoTaskMemFree(pmedium->u.lpszFileName);
    15101509      }
    15111510
     
    15171516      if (pmedium->u.pstm!=0)
    15181517      {
    1519     IStream_Release(pmedium->u.pstm);
     1518        IStream_Release(pmedium->u.pstm);
    15201519      }
    15211520
     
    15271526      if (pmedium->u.pstg!=0)
    15281527      {
    1529     IStorage_Release(pmedium->u.pstg);
     1528        IStorage_Release(pmedium->u.pstg);
    15301529      }
    15311530
     
    15351534    case TYMED_GDI:
    15361535    {
    1537       if ( (pmedium->pUnkForRelease==0) &&
    1538        (pmedium->u.hGlobal!=0) )
    1539     DeleteObject(pmedium->u.hGlobal);
     1536      if ( (pmedium->pUnkForRelease==0) && 
     1537           (pmedium->u.hGlobal!=0) )
     1538        DeleteObject(pmedium->u.hGlobal);
    15401539
    15411540      pmedium->u.hGlobal = 0;
     
    15441543    case TYMED_MFPICT:
    15451544    {
    1546       if ( (pmedium->pUnkForRelease==0) &&
    1547        (pmedium->u.hMetaFilePict!=0) )
     1545      if ( (pmedium->pUnkForRelease==0) && 
     1546           (pmedium->u.hMetaFilePict!=0) )
    15481547      {
    1549     LPMETAFILEPICT pMP = GlobalLock(pmedium->u.hMetaFilePict);
    1550     DeleteMetaFile(pMP->hMF);
    1551     GlobalUnlock(pmedium->u.hMetaFilePict);
    1552     GlobalFree(pmedium->u.hMetaFilePict);
     1548        LPMETAFILEPICT pMP = GlobalLock(pmedium->u.hMetaFilePict);
     1549        DeleteMetaFile(pMP->hMF);
     1550        GlobalUnlock(pmedium->u.hMetaFilePict);
     1551        GlobalFree(pmedium->u.hMetaFilePict);
    15531552      }
    15541553
     
    15581557    case TYMED_ENHMF:
    15591558    {
    1560       if ( (pmedium->pUnkForRelease==0) &&
    1561        (pmedium->u.hEnhMetaFile!=0) )
     1559      if ( (pmedium->pUnkForRelease==0) && 
     1560           (pmedium->u.hEnhMetaFile!=0) )
    15621561      {
    1563     DeleteEnhMetaFile(pmedium->u.hEnhMetaFile);
     1562        DeleteEnhMetaFile(pmedium->u.hEnhMetaFile);
    15641563      }
    15651564
     
    15991598    wndClass.hbrBackground = 0;
    16001599    wndClass.lpszClassName = OLEDD_DRAGTRACKERCLASS;
    1601 
     1600 
    16021601    RegisterClassA (&wndClass);
    16031602}
     
    16651664  /*
    16661665   * If we get here, we have found a spot for our item. The parentNodeLink
    1667    * pointer points to the pointer that we have to modify.
     1666   * pointer points to the pointer that we have to modify. 
    16681667   * The curNode should be NULL. We just have to establish the link and Voila!
    16691668   */
     
    17121711    {
    17131712      /*
    1714        * The item was found in the list. Detach it from it's parent and
     1713       * The item was found in the list. Detach it from it's parent and 
    17151714       * re-insert it's kids in the tree.
    17161715       */
     
    17281727      if (curNode->nextDropTarget!=NULL)
    17291728      {
    1730     OLEDD_InsertDropTarget(curNode->nextDropTarget);
     1729        OLEDD_InsertDropTarget(curNode->nextDropTarget);
    17311730      }
    17321731
     
    18021801 */
    18031802static LRESULT WINAPI OLEDD_DragTrackerWindowProc(
    1804              HWND   hwnd,
    1805             UINT   uMsg,
    1806              WPARAM wParam,
    1807             LPARAM   lParam)
     1803                         HWND   hwnd,
     1804                        UINT   uMsg,
     1805                         WPARAM wParam,
     1806                        LPARAM   lParam)
    18081807{
    18091808  switch (uMsg)
     
    18131812      LPCREATESTRUCTA createStruct = (LPCREATESTRUCTA)lParam;
    18141813
    1815       SetWindowLongA(hwnd, 0, (LONG)createStruct->lpCreateParams);
    1816 
    1817 
     1814      SetWindowLongA(hwnd, 0, (LONG)createStruct->lpCreateParams); 
     1815
     1816     
    18181817      break;
    18191818    }
     
    19101909   * DragOver notification
    19111910   */
    1912   if ( (trackerInfo->curDragTarget != 0) &&
     1911  if ( (trackerInfo->curDragTarget != 0) && 
    19131912       (trackerInfo->curDragTargetHWND==hwndNewTarget) )
    19141913  {
    19151914    POINTL  mousePosParam;
    1916 
     1915   
    19171916    /*
    19181917     * The documentation tells me that the coordinate should be in the target
     
    19221921    mousePosParam.x = mousePos.x;
    19231922    mousePosParam.y = mousePos.y;
    1924 
     1923   
    19251924    IDropTarget_DragOver(trackerInfo->curDragTarget,
    1926             keyState,
    1927             mousePosParam,
    1928             trackerInfo->pdwEffect);
     1925                        keyState,
     1926                        mousePosParam,
     1927                        trackerInfo->pdwEffect);
    19291928  }
    19301929  else
    19311930  {
    19321931    DropTargetNode* newDropTargetNode = 0;
    1933 
     1932   
    19341933    /*
    19351934     * If we changed window, we have to notify our old target and check for
     
    19401939      IDropTarget_DragLeave(trackerInfo->curDragTarget);
    19411940    }
    1942 
     1941   
    19431942    /*
    19441943     * Make sure we're hovering over a window.
     
    19511950      HWND nexttar = hwndNewTarget;
    19521951      do {
    1953     newDropTargetNode = OLEDD_FindDropTarget(nexttar);
     1952        newDropTargetNode = OLEDD_FindDropTarget(nexttar);
    19541953      } while (!newDropTargetNode && (nexttar = GetParent(nexttar)) != 0);
    19551954      if(nexttar) hwndNewTarget = nexttar;
     
    19571956      trackerInfo->curDragTargetHWND = hwndNewTarget;
    19581957      trackerInfo->curDragTarget     = newDropTargetNode ? newDropTargetNode->dropTarget : 0;
    1959 
     1958     
    19601959      /*
    19611960       * If there is, notify it that we just dragged-in
     
    19631962      if (trackerInfo->curDragTarget!=0)
    19641963      {
    1965     POINTL  mousePosParam;
    1966 
    1967     /*
    1968     * The documentation tells me that the coordinate should be in the target
    1969     * window's coordinate space. However, the tests I made tell me the
    1970     * coordinates should be in screen coordinates.
    1971     */
    1972     mousePosParam.x = mousePos.x;
    1973     mousePosParam.y = mousePos.y;
    1974 
    1975     IDropTarget_DragEnter(trackerInfo->curDragTarget,
    1976                   trackerInfo->dataObject,
    1977                   keyState,
    1978                   mousePosParam,
    1979                   trackerInfo->pdwEffect);
     1964        POINTL  mousePosParam;
     1965       
     1966        /*
     1967        * The documentation tells me that the coordinate should be in the target
     1968        * window's coordinate space. However, the tests I made tell me the
     1969        * coordinates should be in screen coordinates.
     1970        */
     1971        mousePosParam.x = mousePos.x;
     1972        mousePosParam.y = mousePos.y;
     1973       
     1974        IDropTarget_DragEnter(trackerInfo->curDragTarget,
     1975                              trackerInfo->dataObject,
     1976                              keyState,
     1977                              mousePosParam,
     1978                              trackerInfo->pdwEffect);
    19801979      }
    19811980    }
     
    19911990
    19921991  /*
    1993    * Now that we have done that, we have to tell the source to give
    1994    * us feedback on the work being done by the target.  If we don't
     1992   * Now that we have done that, we have to tell the source to give 
     1993   * us feedback on the work being done by the target.  If we don't 
    19951994   * have a target, simulate no effect.
    19961995   */
     
    20012000
    20022001  hr = IDropSource_GiveFeedback(trackerInfo->dropSource,
    2003                 *trackerInfo->pdwEffect);
     2002                                *trackerInfo->pdwEffect);
    20042003
    20052004  /*
     
    20272026      SetCursor(LoadCursorA(OLE32_hInstance, MAKEINTRESOURCEA(0)));
    20282027    }
    2029   }
     2028  } 
    20302029}
    20312030
     
    20552054   */
    20562055  trackerInfo->returnValue = IDropSource_QueryContinueDrag(
    2057                    trackerInfo->dropSource,
    2058                    trackerInfo->escPressed,
    2059                    keyState);
    2060 
     2056                               trackerInfo->dropSource,
     2057                               trackerInfo->escPressed,
     2058                               keyState);
     2059 
    20612060  /*
    20622061   * All the return valued will stop the operation except the S_OK
     
    20712070
    20722071    /*
    2073      * Release the mouse in case the drop target decides to show a popup
     2072     * Release the mouse in case the drop target decides to show a popup 
    20742073     * or a menu or something.
    20752074     */
    20762075    ReleaseCapture();
    2077 
     2076   
    20782077    /*
    2079      * If we end-up over a target, drop the object in the target or
     2078     * If we end-up over a target, drop the object in the target or 
    20802079     * inform the target that the operation was cancelled.
    20812080     */
     
    20842083      switch (trackerInfo->returnValue)
    20852084      {
    2086     /*
    2087      * If the source wants us to complete the operation, we tell
    2088     * the drop target that we just dropped the object in it.
    2089     */
     2085        /*
     2086         * If the source wants us to complete the operation, we tell
     2087        * the drop target that we just dropped the object in it.
     2088        */
    20902089        case DRAGDROP_S_DROP:
    2091     {
    2092       POINTL  mousePosParam;
    2093 
    2094       /*
    2095        * The documentation tells me that the coordinate should be
    2096        * in the target window's coordinate space. However, the tests
    2097        * I made tell me the coordinates should be in screen coordinates.
    2098        */
    2099       mousePosParam.x = mousePos.x;
    2100       mousePosParam.y = mousePos.y;
    2101 
    2102       IDropTarget_Drop(trackerInfo->curDragTarget,
    2103                trackerInfo->dataObject,
    2104                keyState,
    2105                mousePosParam,
    2106                trackerInfo->pdwEffect);
    2107       break;
    2108     }
    2109     /*
    2110      * If the source told us that we should cancel, fool the drop
    2111     * target by telling it that the mouse left it's window.
    2112      * Also set the drop effect to "NONE" in case the application
    2113     * ignores the result of DoDragDrop.
    2114     */
     2090        {
     2091          POINTL  mousePosParam;
     2092       
     2093          /*
     2094           * The documentation tells me that the coordinate should be
     2095           * in the target window's coordinate space. However, the tests
     2096           * I made tell me the coordinates should be in screen coordinates.
     2097           */
     2098          mousePosParam.x = mousePos.x;
     2099          mousePosParam.y = mousePos.y;
     2100         
     2101          IDropTarget_Drop(trackerInfo->curDragTarget,
     2102                           trackerInfo->dataObject,
     2103                           keyState,
     2104                           mousePosParam,
     2105                           trackerInfo->pdwEffect);
     2106          break;
     2107        }
     2108        /*
     2109         * If the source told us that we should cancel, fool the drop
     2110        * target by telling it that the mouse left it's window.
     2111         * Also set the drop effect to "NONE" in case the application
     2112        * ignores the result of DoDragDrop.
     2113        */
    21152114        case DRAGDROP_S_CANCEL:
    2116       IDropTarget_DragLeave(trackerInfo->curDragTarget);
    2117       *trackerInfo->pdwEffect = DROPEFFECT_NONE;
    2118       break;
     2115          IDropTarget_DragLeave(trackerInfo->curDragTarget);
     2116          *trackerInfo->pdwEffect = DROPEFFECT_NONE;
     2117          break;
    21192118      }
    21202119    }
     
    21632162 * params:
    21642163 *     regKey   - Key to read the default value from
    2165  *     pdwValue - Pointer to the location where the DWORD
     2164 *     pdwValue - Pointer to the location where the DWORD 
    21662165 *                value is returned. This value is not modified
    21672166 *                if the value is not found.
     
    21692168
    21702169static void OLEUTL_ReadRegistryDWORDValue(
    2171   HKEY   regKey,
     2170  HKEY   regKey, 
    21722171  DWORD* pdwValue)
    21732172{
     
    21782177
    21792178  lres = RegQueryValueExA(regKey,
    2180               "",
    2181               NULL,
    2182               &dwKeyType,
    2183               (LPBYTE)buffer,
    2184               &cbData);
     2179                          "",
     2180                          NULL,
     2181                          &dwKeyType,
     2182                          (LPBYTE)buffer,
     2183                          &cbData);
    21852184
    21862185  if (lres==ERROR_SUCCESS)
     
    21892188    {
    21902189      case REG_DWORD:
    2191     *pdwValue = *(DWORD*)buffer;
    2192     break;
     2190        *pdwValue = *(DWORD*)buffer;
     2191        break;
    21932192      case REG_EXPAND_SZ:
    21942193      case REG_MULTI_SZ:
    21952194      case REG_SZ:
    2196     *pdwValue = (DWORD)strtoul(buffer, NULL, 10);
    2197     break;
     2195        *pdwValue = (DWORD)strtoul(buffer, NULL, 10);
     2196        break;
    21982197    }
    21992198  }
     
    22102209 */
    22112210HGLOBAL16 WINAPI OleMetaFilePictFromIconAndLabel16(
    2212     HICON16 hIcon,
    2213     LPCOLESTR16 lpszLabel,
    2214     LPCOLESTR16 lpszSourceFile,
    2215     UINT16 iIconIndex
     2211        HICON16 hIcon,
     2212        LPCOLESTR16 lpszLabel,
     2213        LPCOLESTR16 lpszSourceFile,
     2214        UINT16 iIconIndex
    22162215) {
    22172216    METAFILEPICT16 *mf;
     
    22232222    if (!hIcon) {
    22242223        if (lpszSourceFile) {
    2225         HINSTANCE16 hInstance = LoadLibrary16(lpszSourceFile);
    2226 
    2227         /* load the icon at index from lpszSourceFile */
    2228         hIcon = (HICON16)LoadIconA(hInstance, (LPCSTR)(DWORD)iIconIndex);
    2229         FreeLibrary16(hInstance);
    2230     } else
    2231         return (HGLOBAL)NULL;
     2224            HINSTANCE16 hInstance = LoadLibrary16(lpszSourceFile);
     2225
     2226            /* load the icon at index from lpszSourceFile */
     2227            hIcon = (HICON16)LoadIconA(hInstance, (LPCSTR)(DWORD)iIconIndex);
     2228            FreeLibrary16(hInstance);
     2229        } else
     2230            return (HGLOBAL)NULL;
    22322231    }
    22332232
  • trunk/src/ole32/ole2impl.c

    r6648 r6711  
    1 /* $Id: ole2impl.c,v 1.2 2001-09-05 13:17:11 bird Exp $ */
    21/*
    32 * Ole 2 Create functions implementation
  • trunk/src/ole32/ole2stubs.c

    r6648 r6711  
    1 /* $Id: ole2stubs.c,v 1.2 2001-09-05 13:17:11 bird Exp $ */
    21/*
    32 * Temporary place for ole2 stubs.
     
    2019 */
    2120HRESULT WINAPI  OleCreateLinkToFile(LPCOLESTR lpszFileName, REFIID riid,
    22             DWORD renderopt, LPFORMATETC lpFormatEtc,
    23             LPOLECLIENTSITE pClientSite, LPSTORAGE pStg, LPVOID* ppvObj)
     21                        DWORD renderopt, LPFORMATETC lpFormatEtc,
     22                        LPOLECLIENTSITE pClientSite, LPSTORAGE pStg, LPVOID* ppvObj)
    2423{
    2524    FIXME("(%p,%p,%li,%p,%p,%p,%p), stub!\n",lpszFileName, riid, renderopt, lpFormatEtc, pClientSite, pStg, ppvObj);
     
    3231 */
    3332HRESULT WINAPI OleDuplicateData(HANDLE hSrc, CLIPFORMAT cfFormat,
    34                               UINT uiFlags)
     33                                  UINT uiFlags)
    3534{
    3635    FIXME("(%x,%x,%x), stub!\n", hSrc, cfFormat, uiFlags);
     
    3837}
    3938
    40 
     39 
    4140/***********************************************************************
    4241 *               WriteFmtUserTypeStg (OLE32.160)
    4342 */
    4443HRESULT WINAPI WriteFmtUserTypeStg(
    45       LPSTORAGE pstg, CLIPFORMAT cf, LPOLESTR lpszUserType)
     44          LPSTORAGE pstg, CLIPFORMAT cf, LPOLESTR lpszUserType)
    4645{
    4746    FIXME("(%p,%x,%s) stub!\n",pstg,cf,debugstr_w(lpszUserType));
     
    8281 */
    8382HRESULT WINAPI OleCreate(
    84     REFCLSID rclsid,
    85     REFIID riid,
    86     DWORD renderopt,
    87     LPFORMATETC pFormatEtc,
    88     LPOLECLIENTSITE pClientSite,
    89     LPSTORAGE pStg,
    90     LPVOID* ppvObj)
     83        REFCLSID rclsid,
     84        REFIID riid,
     85        DWORD renderopt,
     86        LPFORMATETC pFormatEtc,
     87        LPOLECLIENTSITE pClientSite,
     88        LPSTORAGE pStg,
     89        LPVOID* ppvObj)
    9190{
    9291  HRESULT hres, hres1;
    9392  IUnknown * pUnk = NULL;
    94 
     93   
    9594  FIXME("\n\t%s\n\t%s stub!\n", debugstr_guid(rclsid), debugstr_guid(riid));
    9695
     
    106105        hres1 = IOleObject_SetClientSite(pOE, pClientSite);
    107106        TRACE("-- result 0x%08lx\n", hres1);
    108     IOleObject_Release(pOE);
     107        IOleObject_Release(pOE);
    109108      }
    110109      if (SUCCEEDED((hres = IUnknown_QueryInterface( pUnk, &IID_IPersistStorage, (LPVOID*)&pPS))))
    111110      {
    112111        TRACE("trying to set stg %p\n", pStg);
    113     hres1 = IPersistStorage_InitNew(pPS, pStg);
     112        hres1 = IPersistStorage_InitNew(pPS, pStg);
    114113        TRACE("-- result 0x%08lx\n", hres1);
    115     IPersistStorage_Release(pPS);
     114        IPersistStorage_Release(pPS);
    116115      }
    117116    }
     
    209208 */
    210209HRESULT     WINAPI OleRegEnumFormatEtc (
    211   REFCLSID clsid,
     210  REFCLSID clsid, 
    212211  DWORD    dwDirection,
    213212  LPENUMFORMATETC* ppenumFormatetc)
     
    219218
    220219/***********************************************************************
    221  *           PropVariantClear               [OLE32.166]
     220 *           PropVariantClear                       [OLE32.166]
    222221 */
    223222HRESULT WINAPI PropVariantClear(void *pvar) /* [in/out] FIXME: PROPVARIANT * */
    224223{
    225     FIXME("(%p): stub:\n", pvar);
    226 
    227     *(LPWORD)pvar = 0;
    228     /* sets at least the vt field to VT_EMPTY */
    229     return S_OK;
    230 }
    231 
    232 /***********************************************************************
    233  *           PropVariantCopy                [OLE32.246]
     224        FIXME("(%p): stub:\n", pvar);
     225
     226        *(LPWORD)pvar = 0;
     227        /* sets at least the vt field to VT_EMPTY */
     228        return S_OK;
     229}
     230
     231/***********************************************************************
     232 *           PropVariantCopy                        [OLE32.246]
    234233 */
    235234HRESULT WINAPI PropVariantCopy(void *pvarDest,      /* [out] FIXME: PROPVARIANT * */
    236                    const void *pvarSrc) /* [in] FIXME: const PROPVARIANT * */
    237 {
    238     FIXME("(%p, %p): stub:\n", pvarDest, pvarSrc);
    239 
    240     return S_OK;
    241 }
    242 
    243 /***********************************************************************
    244  *           FreePropVariantArray               [OLE32.195]
     235                               const void *pvarSrc) /* [in] FIXME: const PROPVARIANT * */
     236{
     237        FIXME("(%p, %p): stub:\n", pvarDest, pvarSrc);
     238
     239        return S_OK;
     240}
     241
     242/***********************************************************************
     243 *           FreePropVariantArray                           [OLE32.195]
    245244 */
    246245HRESULT WINAPI FreePropVariantArray(ULONG cVariants, /* [in] */
    247                     void *rgvars)    /* [in/out] FIXME: PROPVARIANT * */
    248 {
    249     FIXME("(%lu, %p): stub:\n", cVariants, rgvars);
    250 
    251     return S_OK;
     246                                    void *rgvars)    /* [in/out] FIXME: PROPVARIANT * */
     247{
     248        FIXME("(%lu, %p): stub:\n", cVariants, rgvars);
     249
     250        return S_OK;
    252251}
    253252
  • trunk/src/ole32/ole32_main.c

    r6648 r6711  
    1 /* $Id: ole32_main.c,v 1.2 2001-09-05 13:17:11 bird Exp $ */
    21/*
    32 *  OLE32 Initialization
     
    1716
    1817/***********************************************************************
    19  *      DllEntryPoint (OLE32.@)
     18 *              DllEntryPoint (OLE32.@)
    2019 */
    2120
     
    2726    case DLL_PROCESS_ATTACH:
    2827        OLE32_hInstance = hinstDLL;
    29     break;
     28        break;
    3029
    3130    case DLL_PROCESS_DETACH:
    3231        OLE32_hInstance = 0;
    33     break;
     32        break;
    3433    }
    3534    return TRUE;
     
    3736
    3837/***********************************************************************
    39  *      DllRegisterServer (OLE32.@)
     38 *              DllRegisterServer (OLE32.@)
    4039 */
    4140HRESULT WINAPI OLE32_DllRegisterServer() {
  • 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    }
  • trunk/src/ole32/stg_bigblockfile.c

    r6648 r6711  
    1 /* $Id: stg_bigblockfile.c,v 1.3 2001-09-05 13:17:12 bird Exp $ */
    21/******************************************************************************
    32 *
    43 * BigBlockFile
    54 *
    6  * This is the implementation of a file that consists of blocks of
     5 * This is the implementation of a file that consists of blocks of 
    76 * a predetermined size.
    8  * This class is used in the Compound File implementation of the
    9  * IStorage and IStream interfaces. It provides the functionality
    10  * to read and write any blocks in the file as well as setting and
     7 * This class is used in the Compound File implementation of the 
     8 * IStorage and IStream interfaces. It provides the functionality 
     9 * to read and write any blocks in the file as well as setting and 
    1110 * obtaining the size of the file.
    1211 * The blocks are indexed sequentially from the start of the file
    1312 * starting with -1.
    14  *
     13 * 
    1514 * TODO:
    1615 * - Support for a transacted mode
     
    4544#include "debugtools.h"
    4645
     46#ifdef __WIN32OS2__
     47#undef FIXME
     48#undef TRACE
     49#ifdef DEBUG
     50#define TRACE WriteLog("OLE32: %s", __FUNCTION__); WriteLog
     51#define FIXME WriteLog("FIXME OLE32: %s", __FUNCTION__); WriteLog
     52#else
     53#define TRACE 1 ? (void)0 : (void)((int (*)(char *, ...)) NULL)
     54#define FIXME 1 ? (void)0 : (void)((int (*)(char *, ...)) NULL)
     55#endif
     56#endif
     57
    4758DEFAULT_DEBUG_CHANNEL(storage);
    4859
     
    7081/***
    7182 * This structure identifies the paged that are mapped
    72  * from the file and their position in memory. It is
     83 * from the file and their position in memory. It is 
    7384 * also used to hold a reference count to those pages.
    7485 *
     
    103114                                                 ULONG          index,
    104115                                                 DWORD          desired_access);
    105 static MappedPage* BIGBLOCKFILE_GetPageFromPointer(LPBIGBLOCKFILE This,
    106                            void*         pBlock);
     116static MappedPage* BIGBLOCKFILE_GetPageFromPointer(LPBIGBLOCKFILE This, 
     117                                                   void*         pBlock);
    107118static MappedPage* BIGBLOCKFILE_CreatePage(LPBIGBLOCKFILE This,
    108                        ULONG page_index);
     119                                           ULONG page_index);
    109120static DWORD     BIGBLOCKFILE_GetProtectMode(DWORD openFlags);
    110121static BOOL      BIGBLOCKFILE_FileInit(LPBIGBLOCKFILE This, HANDLE hFile);
     
    119130 */
    120131static inline BOOL BIGBLOCKFILE_TestBit(const BlockBits *bb,
    121                     unsigned int index)
     132                                        unsigned int index)
    122133{
    123134    unsigned int array_index = index / (CHAR_BIT * sizeof(unsigned int));
     
    151162 *      BIGBLOCKFILE_Construct
    152163 *
    153  * Construct a big block file. Create the file mapping object.
     164 * Construct a big block file. Create the file mapping object. 
    154165 * Create the read only mapped pages list, the writable mapped page list
    155166 * and the blocks in use list.
     
    231242
    232243  This->filesize.s.LowPart = GetFileSize(This->hfile,
    233                     &This->filesize.s.HighPart);
     244                                        &This->filesize.s.HighPart);
    234245
    235246  This->maplist = NULL;
     
    324335  /*
    325336   * validate the block index
    326    *
     337   * 
    327338   */
    328339  if (This->blocksize * (index + 1)
     
    330341  {
    331342    TRACE("out of range %lu vs %lu\n", This->blocksize * (index + 1),
    332       This->filesize.s.LowPart);
     343          This->filesize.s.LowPart);
    333344    return NULL;
    334345  }
     
    380391
    381392    if (pBlock == NULL)
    382     return;
     393        return;
    383394
    384395    page = BIGBLOCKFILE_GetPageFromPointer(This, pBlock);
    385396
    386397    if (page == NULL)
    387     return;
     398        return;
    388399
    389400    BIGBLOCKFILE_ReleaseMappedPage(This, page);
     
    394405 *
    395406 * Sets the size of the file.
    396  *
     407 * 
    397408 */
    398409void BIGBLOCKFILE_SetSize(LPBIGBLOCKFILE This, ULARGE_INTEGER newSize)
     
    406417   */
    407418  BIGBLOCKFILE_UnmapAllMappedPages(This);
    408 
     419 
    409420  if (This->fileBased)
    410421  {
     
    424435     *
    425436     * The problem is that the SetFilePointer-SetEndOfFile combo below
    426      * doesn't always succeed. The file is not grown. It seems like the
     437     * doesn't always succeed. The file is not grown. It seems like the 
    427438     * operation is cached. By doing the WriteFile, the file is actually
    428439     * grown on disk.
     
    433444    WriteFile(This->hfile, buf, 10, NULL, NULL);
    434445    /*
    435      * END HACK
     446     * END HACK 
    436447     */
    437448
     
    441452    SetFilePointer(This->hfile, newSize.s.LowPart, NULL, FILE_BEGIN);
    442453    SetEndOfFile(This->hfile);
    443 
     454 
    444455    /*
    445456     * re-create the file mapping object
     
    448459                                        NULL,
    449460                                        This->flProtect,
    450                                         0, 0,
     461                                        0, 0, 
    451462                                        NULL);
    452463  }
     
    477488 *
    478489 * Returns the size of the file.
    479  *
     490 * 
    480491 */
    481492ULARGE_INTEGER BIGBLOCKFILE_GetSize(LPBIGBLOCKFILE This)
     
    490501 */
    491502static BOOL BIGBLOCKFILE_AccessCheck(MappedPage *page, ULONG block_index,
    492                      DWORD desired_access)
     503                                     DWORD desired_access)
    493504{
    494505    assert(block_index < BLOCKS_PER_PAGE);
     
    496507    if (desired_access == FILE_MAP_READ)
    497508    {
    498     if (BIGBLOCKFILE_TestBit(&page->writable_blocks, block_index))
    499         return FALSE;
    500 
    501     BIGBLOCKFILE_SetBit(&page->readable_blocks, block_index);
     509        if (BIGBLOCKFILE_TestBit(&page->writable_blocks, block_index))
     510            return FALSE;
     511
     512        BIGBLOCKFILE_SetBit(&page->readable_blocks, block_index);
    502513    }
    503514    else
    504515    {
    505     assert(desired_access == FILE_MAP_WRITE);
    506 
    507     if (BIGBLOCKFILE_TestBit(&page->readable_blocks, block_index))
    508         return FALSE;
    509 
    510     BIGBLOCKFILE_SetBit(&page->writable_blocks, block_index);
     516        assert(desired_access == FILE_MAP_WRITE);
     517
     518        if (BIGBLOCKFILE_TestBit(&page->readable_blocks, block_index))
     519            return FALSE;
     520
     521        BIGBLOCKFILE_SetBit(&page->writable_blocks, block_index);
    511522    }
    512523
     
    520531 */
    521532static void* BIGBLOCKFILE_GetBigBlockPointer(
    522   LPBIGBLOCKFILE This,
    523   ULONG          block_index,
     533  LPBIGBLOCKFILE This, 
     534  ULONG          block_index, 
    524535  DWORD          desired_access)
    525536{
     
    532543    if (!BIGBLOCKFILE_AccessCheck(page, block_on_page, desired_access))
    533544    {
    534     BIGBLOCKFILE_ReleaseMappedPage(This, page);
    535     return NULL;
     545        BIGBLOCKFILE_ReleaseMappedPage(This, page);
     546        return NULL;
    536547    }
    537548
     
    548559 */
    549560static MappedPage *BIGBLOCKFILE_GetPageFromPointer(LPBIGBLOCKFILE This,
    550                            void *pBlock)
     561                                                   void *pBlock)
    551562{
    552563    MappedPage *page;
     
    554565    for (page = This->maplist; page != NULL; page = page->next)
    555566    {
    556     if ((LPBYTE)pBlock >= (LPBYTE)page->lpBytes
    557         && (LPBYTE)pBlock <= (LPBYTE)page->lpBytes + PAGE_SIZE)
    558         break;
     567        if ((LPBYTE)pBlock >= (LPBYTE)page->lpBytes
     568            && (LPBYTE)pBlock <= (LPBYTE)page->lpBytes + PAGE_SIZE)
     569            break;
    559570
    560571    }
     
    568579 */
    569580static MappedPage *BIGBLOCKFILE_FindPageInList(MappedPage *head,
    570                            ULONG page_index)
     581                                               ULONG page_index)
    571582{
    572583    for (; head != NULL; head = head->next)
    573584    {
    574     if (head->page_index == page_index)
    575     {
    576         InterlockedIncrement(&head->refcnt);
    577         break;
    578     }
     585        if (head->page_index == page_index)
     586        {
     587            InterlockedIncrement(&head->refcnt);
     588            break;
     589        }
    579590    }
    580591
     
    612623    if (!page)
    613624    {
    614     page = BIGBLOCKFILE_FindPageInList(This->victimhead, page_index);
     625        page = BIGBLOCKFILE_FindPageInList(This->victimhead, page_index);
     626        if (page)
     627        {
     628            This->num_victim_pages--;
     629
     630            BIGBLOCKFILE_Zero(&page->readable_blocks);
     631            BIGBLOCKFILE_Zero(&page->writable_blocks);
     632        }
     633    }
     634
    615635    if (page)
    616636    {
    617         This->num_victim_pages--;
    618 
    619         BIGBLOCKFILE_Zero(&page->readable_blocks);
    620         BIGBLOCKFILE_Zero(&page->writable_blocks);
    621     }
    622     }
    623 
    624     if (page)
    625     {
    626     /* If the page is not already at the head of the list, move
    627      * it there. (Also moves pages from victim to main list.) */
    628     if (This->maplist != page)
    629     {
    630         if (This->victimhead == page) This->victimhead = page->next;
    631         if (This->victimtail == page) This->victimtail = page->prev;
    632 
    633         BIGBLOCKFILE_UnlinkPage(page);
    634 
    635         BIGBLOCKFILE_LinkHeadPage(&This->maplist, page);
    636     }
    637 
    638     return page;
     637        /* If the page is not already at the head of the list, move
     638         * it there. (Also moves pages from victim to main list.) */
     639        if (This->maplist != page)
     640        {
     641            if (This->victimhead == page) This->victimhead = page->next;
     642            if (This->victimtail == page) This->victimtail = page->prev;
     643
     644            BIGBLOCKFILE_UnlinkPage(page);
     645
     646            BIGBLOCKFILE_LinkHeadPage(&This->maplist, page);
     647        }
     648
     649        return page;
    639650    }
    640651
     
    653664    if (This->fileBased)
    654665    {
    655     DWORD numBytesToMap;
    656     DWORD desired_access;
    657 
    658     if (lowoffset + PAGE_SIZE > This->filesize.s.LowPart)
    659         numBytesToMap = This->filesize.s.LowPart - lowoffset;
     666        DWORD numBytesToMap;
     667        DWORD desired_access;
     668
     669        if (lowoffset + PAGE_SIZE > This->filesize.s.LowPart)
     670            numBytesToMap = This->filesize.s.LowPart - lowoffset;
     671        else
     672            numBytesToMap = PAGE_SIZE;
     673
     674        if (This->flProtect == PAGE_READONLY)
     675            desired_access = FILE_MAP_READ;
     676        else
     677            desired_access = FILE_MAP_WRITE;
     678
     679        page->lpBytes = MapViewOfFile(This->hfilemap, desired_access, 0,
     680                                      lowoffset, numBytesToMap);
     681    }
    660682    else
    661         numBytesToMap = PAGE_SIZE;
    662 
    663     if (This->flProtect == PAGE_READONLY)
    664         desired_access = FILE_MAP_READ;
    665     else
    666         desired_access = FILE_MAP_WRITE;
    667 
    668     page->lpBytes = MapViewOfFile(This->hfilemap, desired_access, 0,
    669                       lowoffset, numBytesToMap);
    670     }
    671     else
    672     {
    673     page->lpBytes = (LPBYTE)This->pbytearray + lowoffset;
     683    {
     684        page->lpBytes = (LPBYTE)This->pbytearray + lowoffset;
    674685    }
    675686
     
    680691
    681692static MappedPage *BIGBLOCKFILE_CreatePage(LPBIGBLOCKFILE This,
    682                        ULONG page_index)
     693                                           ULONG page_index)
    683694{
    684695    MappedPage *page;
     
    706717    TRACE("%ld at %p\n", page->page_index, page->lpBytes);
    707718    if (page->refcnt > 0)
    708     ERR("unmapping inuse page %p\n", page->lpBytes);
     719        ERR("unmapping inuse page %p\n", page->lpBytes);
    709720
    710721    if (This->fileBased && page->lpBytes)
    711     UnmapViewOfFile(page->lpBytes);
     722        UnmapViewOfFile(page->lpBytes);
    712723
    713724    page->lpBytes = NULL;
     
    737748    if (!InterlockedDecrement(&page->refcnt))
    738749    {
    739     if (This->maplist == page) This->maplist = page->next;
    740 
    741     BIGBLOCKFILE_UnlinkPage(page);
    742 
    743     if (MAX_VICTIM_PAGES > 0)
    744     {
    745         if (This->num_victim_pages >= MAX_VICTIM_PAGES)
    746         {
    747         MappedPage *victim = This->victimtail;
    748         if (victim)
    749         {
    750             This->victimtail = victim->prev;
    751             if (This->victimhead == victim)
    752             This->victimhead = victim->next;
    753 
    754             BIGBLOCKFILE_UnlinkPage(victim);
    755             BIGBLOCKFILE_DeletePage(This, victim);
    756         }
    757         }
    758         else This->num_victim_pages++;
    759 
    760         BIGBLOCKFILE_LinkHeadPage(&This->victimhead, page);
    761         if (This->victimtail == NULL) This->victimtail = page;
    762     }
    763     else
    764         BIGBLOCKFILE_DeletePage(This, page);
     750        if (This->maplist == page) This->maplist = page->next;
     751
     752        BIGBLOCKFILE_UnlinkPage(page);
     753
     754        if (MAX_VICTIM_PAGES > 0)
     755        {
     756            if (This->num_victim_pages >= MAX_VICTIM_PAGES)
     757            {
     758                MappedPage *victim = This->victimtail;
     759                if (victim)
     760                {
     761                    This->victimtail = victim->prev;
     762                    if (This->victimhead == victim)
     763                        This->victimhead = victim->next;
     764
     765                    BIGBLOCKFILE_UnlinkPage(victim);
     766                    BIGBLOCKFILE_DeletePage(This, victim);
     767                }
     768            }
     769            else This->num_victim_pages++;
     770
     771            BIGBLOCKFILE_LinkHeadPage(&This->victimhead, page);
     772            if (This->victimtail == NULL) This->victimtail = page;
     773        }
     774        else
     775            BIGBLOCKFILE_DeletePage(This, page);
    765776    }
    766777}
     
    770781    while (list != NULL)
    771782    {
    772     MappedPage *next = list->next;
    773 
    774     BIGBLOCKFILE_DeletePage(This, list);
    775 
    776     list = next;
     783        MappedPage *next = list->next;
     784
     785        BIGBLOCKFILE_DeletePage(This, list);
     786
     787        list = next;
    777788    }
    778789}
     
    800811    for (; list != NULL; list = list->next)
    801812    {
    802     BIGBLOCKFILE_UnmapPage(This, list);
     813        BIGBLOCKFILE_UnmapPage(This, list);
    803814    }
    804815}
     
    814825    while (list != NULL)
    815826    {
    816     MappedPage *next = list->next;
    817 
    818     if (list->page_index * PAGE_SIZE > This->filesize.s.LowPart)
    819     {
    820         TRACE("discarding %lu\n", list->page_index);
    821 
    822         /* page is entirely outside of the file, delete it */
    823         BIGBLOCKFILE_UnlinkPage(list);
    824         BIGBLOCKFILE_DeletePage(This, list);
    825     }
    826     else
    827     {
    828         /* otherwise, remap it */
    829         BIGBLOCKFILE_MapPage(This, list);
    830     }
    831 
    832     list = next;
     827        MappedPage *next = list->next;
     828
     829        if (list->page_index * PAGE_SIZE > This->filesize.s.LowPart)
     830        {
     831            TRACE("discarding %lu\n", list->page_index);
     832
     833            /* page is entirely outside of the file, delete it */
     834            BIGBLOCKFILE_UnlinkPage(list);
     835            BIGBLOCKFILE_DeletePage(This, list);
     836        }
     837        else
     838        {
     839            /* otherwise, remap it */
     840            BIGBLOCKFILE_MapPage(This, list);
     841        }
     842
     843        list = next;
    833844    }
    834845}
     
    849860{
    850861    if (openFlags & (STGM_WRITE | STGM_READWRITE))
    851     return PAGE_READWRITE;
     862        return PAGE_READWRITE;
    852863    else
    853     return PAGE_READONLY;
    854 }
     864        return PAGE_READONLY;
     865}
  • trunk/src/ole32/stg_stream.c

    r6648 r6711  
    1 /* $Id: stg_stream.c,v 1.3 2001-09-05 13:17:12 bird Exp $ */
    21/*
    32 * Compound Storage (32 bit version)
     
    2827
    2928#include "storage32.h"
     29
     30#ifdef __WIN32OS2__
     31#undef FIXME
     32#undef TRACE
     33#ifdef DEBUG
     34#define TRACE WriteLog("OLE32: %s", __FUNCTION__); WriteLog
     35#define FIXME WriteLog("FIXME OLE32: %s", __FUNCTION__); WriteLog
     36#else
     37#define TRACE 1 ? (void)0 : (void)((int (*)(char *, ...)) NULL)
     38#define FIXME 1 ? (void)0 : (void)((int (*)(char *, ...)) NULL)
     39#endif
     40#endif
    3041
    3142DEFAULT_DEBUG_CHANNEL(storage);
     
    6677 */
    6778StgStreamImpl* StgStreamImpl_Construct(
    68         StorageBaseImpl* parentStorage,
     79                StorageBaseImpl* parentStorage,
    6980    DWORD            grfMode,
    7081    ULONG            ownerProperty)
     
    7384
    7485  newStream = HeapAlloc(GetProcessHeap(), 0, sizeof(StgStreamImpl));
    75 
     86 
    7687  if (newStream!=0)
    7788  {
     
    8192    ICOM_VTBL(newStream) = &StgStreamImpl_Vtbl;
    8293    newStream->ref       = 0;
    83 
     94   
    8495    /*
    8596     * We want to nail-down the reference to the storage in case the
     
    89100    IStorage_AddRef((IStorage*)newStream->parentStorage);
    90101
    91     newStream->grfMode = grfMode;
     102    newStream->grfMode = grfMode;   
    92103    newStream->ownerProperty = ownerProperty;
    93 
     104   
    94105    /*
    95106     * Start the stream at the begining.
     
    97108    newStream->currentPosition.s.HighPart = 0;
    98109    newStream->currentPosition.s.LowPart = 0;
    99 
     110   
    100111    /*
    101112     * Initialize the rest of the data.
     
    105116    newStream->bigBlockChain       = 0;
    106117    newStream->smallBlockChain     = 0;
    107 
     118   
    108119    /*
    109120     * Read the size from the property and determine if the blocks forming
     
    112123    StgStreamImpl_OpenBlockChain(newStream);
    113124  }
    114 
     125 
    115126  return newStream;
    116127}
     
    119130 * This is the destructor of the StgStreamImpl class.
    120131 *
    121  * This method will clean-up all the resources used-up by the given StgStreamImpl
     132 * This method will clean-up all the resources used-up by the given StgStreamImpl 
    122133 * class. The pointer passed-in to this function will be freed and will not
    123134 * be valid anymore.
     
    151162   * Finally, free the memory used-up by the class.
    152163   */
    153   HeapFree(GetProcessHeap(), 0, This);
     164  HeapFree(GetProcessHeap(), 0, This); 
    154165}
    155166
     
    159170 */
    160171HRESULT WINAPI StgStreamImpl_QueryInterface(
    161           IStream*     iface,
    162           REFIID         riid,        /* [in] */
    163           void**         ppvObject)   /* [iid_is][out] */
     172                  IStream*     iface,
     173                  REFIID         riid,        /* [in] */         
     174                  void**         ppvObject)   /* [iid_is][out] */
    164175{
    165176  StgStreamImpl* const This=(StgStreamImpl*)iface;
     
    170181  if (ppvObject==0)
    171182    return E_INVALIDARG;
    172 
     183 
    173184  /*
    174185   * Initialize the return parameter.
    175186   */
    176187  *ppvObject = 0;
    177 
     188 
    178189  /*
    179190   * Compare the riid with the interface IDs implemented by this object.
    180191   */
    181   if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0)
     192  if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0) 
    182193  {
    183194    *ppvObject = (IStream*)This;
    184195  }
    185   else if (memcmp(&IID_IStream, riid, sizeof(IID_IStream)) == 0)
     196  else if (memcmp(&IID_IStream, riid, sizeof(IID_IStream)) == 0) 
    186197  {
    187198    *ppvObject = (IStream*)This;
    188199  }
    189 
     200 
    190201  /*
    191202   * Check that we obtained an interface.
     
    193204  if ((*ppvObject)==0)
    194205    return E_NOINTERFACE;
    195 
     206 
    196207  /*
    197208   * Query Interface always increases the reference count by one when it is
     
    199210   */
    200211  StgStreamImpl_AddRef(iface);
    201 
     212 
    202213  return S_OK;;
    203214}
     
    208219 */
    209220ULONG WINAPI StgStreamImpl_AddRef(
    210         IStream* iface)
     221                IStream* iface)
    211222{
    212223  StgStreamImpl* const This=(StgStreamImpl*)iface;
    213224
    214225  This->ref++;
    215 
     226 
    216227  return This->ref;
    217228}
     
    222233 */
    223234ULONG WINAPI StgStreamImpl_Release(
    224         IStream* iface)
     235                IStream* iface)
    225236{
    226237  StgStreamImpl* const This=(StgStreamImpl*)iface;
    227238
    228239  ULONG newRef;
    229 
     240 
    230241  This->ref--;
    231 
     242 
    232243  newRef = This->ref;
    233 
     244 
    234245  /*
    235246   * If the reference count goes down to 0, perform suicide.
     
    239250    StgStreamImpl_Destroy(This);
    240251  }
    241 
     252 
    242253  return newRef;
    243254}
     
    273284   */
    274285  readSucessful = StorageImpl_ReadProperty(This->parentStorage->ancestorStorage,
    275                          This->ownerProperty,
    276                          &curProperty);
    277 
     286                                             This->ownerProperty,
     287                                             &curProperty);
     288 
    278289  if (readSucessful)
    279290  {
    280291    This->streamSize = curProperty.size;
    281 
     292   
    282293    /*
    283294     * This code supports only streams that are <32 bits in size.
    284295     */
    285296    assert(This->streamSize.s.HighPart == 0);
    286 
     297   
    287298    if(curProperty.startingBlock == BLOCK_END_OF_CHAIN)
    288299    {
     
    292303    {
    293304      if ( (This->streamSize.s.HighPart == 0) &&
    294        (This->streamSize.s.LowPart < LIMIT_TO_USE_SMALL_BLOCK) )
     305           (This->streamSize.s.LowPart < LIMIT_TO_USE_SMALL_BLOCK) )
    295306      {
    296     This->smallBlockChain = SmallBlockChainStream_Construct(
    297                                 This->parentStorage->ancestorStorage,
    298                                 This->ownerProperty);
     307        This->smallBlockChain = SmallBlockChainStream_Construct(
     308                                                                This->parentStorage->ancestorStorage,   
     309                                                                This->ownerProperty);
    299310      }
    300311      else
    301312      {
    302     This->bigBlockChain = BlockChainStream_Construct(
    303                             This->parentStorage->ancestorStorage,
    304                             NULL,
    305                             This->ownerProperty);
     313        This->bigBlockChain = BlockChainStream_Construct(
     314                                                        This->parentStorage->ancestorStorage,
     315                                                        NULL,
     316                                                        This->ownerProperty);
    306317      }
    307318    }
     
    318329 * See the documentation of ISequentialStream for more info.
    319330 */
    320 HRESULT WINAPI StgStreamImpl_Read(
    321           IStream*     iface,
    322           void*          pv,        /* [length_is][size_is][out] */
    323           ULONG          cb,        /* [in] */
    324           ULONG*         pcbRead)   /* [out] */
     331HRESULT WINAPI StgStreamImpl_Read( 
     332                  IStream*     iface,
     333                  void*          pv,        /* [length_is][size_is][out] */
     334                  ULONG          cb,        /* [in] */                     
     335                  ULONG*         pcbRead)   /* [out] */                   
    325336{
    326337  StgStreamImpl* const This=(StgStreamImpl*)iface;
     
    330341
    331342  TRACE("(%p, %p, %ld, %p)\n",
    332     iface, pv, cb, pcbRead);
    333 
    334   /*
     343        iface, pv, cb, pcbRead);
     344
     345  /* 
    335346   * If the caller is not interested in the nubmer of bytes read,
    336347   * we use another buffer to avoid "if" statements in the code.
     
    338349  if (pcbRead==0)
    339350    pcbRead = &bytesReadBuffer;
    340 
     351 
    341352  /*
    342353   * Using the known size of the stream, calculate the number of bytes
     
    344355   */
    345356  bytesToReadFromBuffer = min( This->streamSize.s.LowPart - This->currentPosition.s.LowPart, cb);
    346 
     357 
    347358  /*
    348359   * Depending on the type of chain that was opened when the stream was constructed,
     
    352363  {
    353364    SmallBlockChainStream_ReadAt(This->smallBlockChain,
    354                 This->currentPosition,
    355                 bytesToReadFromBuffer,
    356                 pv,
    357                 pcbRead);
    358 
     365                                This->currentPosition,
     366                                bytesToReadFromBuffer,
     367                                pv,
     368                                pcbRead);
     369   
    359370  }
    360371  else if (This->bigBlockChain!=0)
    361372  {
    362373    BlockChainStream_ReadAt(This->bigBlockChain,
    363                 This->currentPosition,
    364                 bytesToReadFromBuffer,
    365                 pv,
    366                 pcbRead);
     374                            This->currentPosition,
     375                            bytesToReadFromBuffer,
     376                            pv,
     377                            pcbRead);
    367378  }
    368379  else
     
    387398   */
    388399  This->currentPosition.s.LowPart += *pcbRead;
    389 
     400 
    390401  /*
    391402   * The function returns S_OK if the buffer was filled completely
     
    395406  if(*pcbRead == cb)
    396407    return S_OK;
    397 
     408 
    398409  return S_FALSE;
    399410}
    400 
     411       
    401412/***
    402413 * This method is part of the ISequentialStream interface.
     
    410421 */
    411422HRESULT WINAPI StgStreamImpl_Write(
    412               IStream*     iface,
    413           const void*    pv,          /* [size_is][in] */
    414           ULONG          cb,          /* [in] */
    415           ULONG*         pcbWritten)  /* [out] */
     423                  IStream*     iface,
     424                  const void*    pv,          /* [size_is][in] */
     425                  ULONG          cb,          /* [in] */         
     426                  ULONG*         pcbWritten)  /* [out] */         
    416427{
    417428  StgStreamImpl* const This=(StgStreamImpl*)iface;
     
    421432
    422433  TRACE("(%p, %p, %ld, %p)\n",
    423     iface, pv, cb, pcbWritten);
    424 
     434        iface, pv, cb, pcbWritten);
     435 
    425436  /*
    426437   * Do we have permission to write to this stream?
     
    436447  if (pcbWritten == 0)
    437448    pcbWritten = &bytesWritten;
    438 
     449 
    439450  /*
    440451   * Initialize the out parameter
     
    451462    newSize.s.LowPart = This->currentPosition.s.LowPart + cb;
    452463  }
    453 
     464 
    454465  /*
    455466   * Verify if we need to grow the stream
     
    460471    IStream_SetSize(iface, newSize);
    461472  }
    462 
     473 
    463474  /*
    464475   * Depending on the type of chain that was opened when the stream was constructed,
     
    468479  {
    469480    SmallBlockChainStream_WriteAt(This->smallBlockChain,
    470                   This->currentPosition,
    471                   cb,
    472                   pv,
    473                   pcbWritten);
    474 
     481                                  This->currentPosition,
     482                                  cb,
     483                                  pv,
     484                                  pcbWritten);
     485   
    475486  }
    476487  else if (This->bigBlockChain!=0)
    477488  {
    478489    BlockChainStream_WriteAt(This->bigBlockChain,
    479                  This->currentPosition,
    480                  cb,
    481                  pv,
    482                  pcbWritten);
     490                             This->currentPosition,
     491                             cb,
     492                             pv,
     493                             pcbWritten);
    483494  }
    484495  else
    485496    assert(FALSE);
    486 
     497 
    487498  /*
    488499   * Advance the position pointer for the number of positions written.
    489500   */
    490501  This->currentPosition.s.LowPart += *pcbWritten;
    491 
     502 
    492503  return S_OK;
    493504}
     
    500511 *
    501512 * See the documentation of IStream for more info.
    502  */
    503 HRESULT WINAPI StgStreamImpl_Seek(
    504           IStream*      iface,
    505           LARGE_INTEGER   dlibMove,         /* [in] */
    506           DWORD           dwOrigin,         /* [in] */
    507           ULARGE_INTEGER* plibNewPosition) /* [out] */
     513 */       
     514HRESULT WINAPI StgStreamImpl_Seek( 
     515                  IStream*      iface,
     516                  LARGE_INTEGER   dlibMove,         /* [in] */
     517                  DWORD           dwOrigin,         /* [in] */
     518                  ULARGE_INTEGER* plibNewPosition) /* [out] */
    508519{
    509520  StgStreamImpl* const This=(StgStreamImpl*)iface;
     
    512523
    513524  TRACE("(%p, %ld, %ld, %p)\n",
    514     iface, dlibMove.s.LowPart, dwOrigin, plibNewPosition);
    515 
    516   /*
     525        iface, dlibMove.s.LowPart, dwOrigin, plibNewPosition);
     526
     527  /* 
    517528   * The caller is allowed to pass in NULL as the new position return value.
    518529   * If it happens, we assign it to a dynamic variable to avoid special cases
     
    556567      /* ... and subtract with carry */
    557568      if (dlibMove.s.LowPart > plibNewPosition->s.LowPart) {
    558       /* carry needed, This accounts for any underflows at [1]*/
    559       plibNewPosition->s.HighPart -= 1;
     569          /* carry needed, This accounts for any underflows at [1]*/
     570          plibNewPosition->s.HighPart -= 1;
    560571      }
    561572      plibNewPosition->s.LowPart -= dlibMove.s.LowPart; /* [1] */
    562       plibNewPosition->s.HighPart -= dlibMove.s.HighPart;
     573      plibNewPosition->s.HighPart -= dlibMove.s.HighPart; 
    563574  } else {
    564575      /* add directly */
     
    566577      plibNewPosition->s.LowPart += dlibMove.s.LowPart;
    567578      if((plibNewPosition->s.LowPart < initialLowPart) ||
    568     (plibNewPosition->s.LowPart < dlibMove.s.LowPart)) {
    569       /* LowPart has rolled over => add the carry digit to HighPart */
    570       plibNewPosition->s.HighPart++;
     579        (plibNewPosition->s.LowPart < dlibMove.s.LowPart)) {
     580          /* LowPart has rolled over => add the carry digit to HighPart */
     581          plibNewPosition->s.HighPart++;
    571582      }
    572       plibNewPosition->s.HighPart += dlibMove.s.HighPart;
    573   }
    574   /*
    575    * Check if we end-up before the beginning of the file. That should
     583      plibNewPosition->s.HighPart += dlibMove.s.HighPart; 
     584  }
     585  /*
     586   * Check if we end-up before the beginning of the file. That should 
    576587   * trigger an error.
    577588   */
     
    581592
    582593    /*
    583    * We currently don't support files with offsets of >32 bits.
     594   * We currently don't support files with offsets of >32 bits. 
    584595   * Note that we have checked for a negative offset already
    585596     */
     
    594605   */
    595606  This->currentPosition = *plibNewPosition;
    596 
     607 
    597608  return S_OK;
    598609}
     
    607618 * See the documentation of IStream for more info.
    608619 */
    609 HRESULT WINAPI StgStreamImpl_SetSize(
    610                      IStream*      iface,
    611                      ULARGE_INTEGER  libNewSize)   /* [in] */
     620HRESULT WINAPI StgStreamImpl_SetSize( 
     621                                     IStream*      iface,
     622                                     ULARGE_INTEGER  libNewSize)   /* [in] */
    612623{
    613624  StgStreamImpl* const This=(StgStreamImpl*)iface;
     
    658669  Success = StorageImpl_ReadProperty(This->parentStorage->ancestorStorage,
    659670                                       This->ownerProperty,
    660                                        &curProperty);
     671                                       &curProperty); 
    661672  /*
    662673   * Determine if we have to switch from small to big blocks or vice versa
    663    */
    664   if ( (This->smallBlockChain!=0) &&
     674   */ 
     675  if ( (This->smallBlockChain!=0) && 
    665676       (curProperty.size.s.LowPart < LIMIT_TO_USE_SMALL_BLOCK) )
    666677  {
     
    694705  curProperty.size.s.HighPart = libNewSize.s.HighPart;
    695706  curProperty.size.s.LowPart = libNewSize.s.LowPart;
    696 
     707 
    697708  if (Success)
    698709  {
    699710    StorageImpl_WriteProperty(This->parentStorage->ancestorStorage,
    700                 This->ownerProperty,
    701                 &curProperty);
    702   }
    703 
     711                                This->ownerProperty,
     712                                &curProperty);
     713  }
     714 
    704715  This->streamSize = libNewSize;
    705 
     716 
    706717  return S_OK;
    707718}
    708 
     719       
    709720/***
    710721 * This method is part of the IStream interface.
     
    714725 * See the documentation of IStream for more info.
    715726 */
    716 HRESULT WINAPI StgStreamImpl_CopyTo(
    717                     IStream*      iface,
    718                     IStream*      pstm,         /* [unique][in] */
    719                     ULARGE_INTEGER  cb,           /* [in] */
    720                     ULARGE_INTEGER* pcbRead,      /* [out] */
    721                     ULARGE_INTEGER* pcbWritten)   /* [out] */
     727HRESULT WINAPI StgStreamImpl_CopyTo( 
     728                                    IStream*      iface,
     729                                    IStream*      pstm,         /* [unique][in] */
     730                                    ULARGE_INTEGER  cb,           /* [in] */         
     731                                    ULARGE_INTEGER* pcbRead,      /* [out] */       
     732                                    ULARGE_INTEGER* pcbWritten)   /* [out] */       
    722733{
    723734  HRESULT        hr = S_OK;
     
    727738  ULARGE_INTEGER totalBytesWritten;
    728739
    729   TRACE("(%p, %p, %ld, %p, %p)\n",
    730     iface, pstm, cb.s.LowPart, pcbRead, pcbWritten);
     740  TRACE("(%p, %p, %ld, %p, %p)\n", 
     741        iface, pstm, cb.s.LowPart, pcbRead, pcbWritten);
    731742
    732743  /*
     
    750761    else
    751762      copySize = cb.s.LowPart;
    752 
     763   
    753764    IStream_Read(iface, tmpBuffer, copySize, &bytesRead);
    754765
    755766    totalBytesRead.s.LowPart += bytesRead;
    756 
     767   
    757768    IStream_Write(pstm, tmpBuffer, bytesRead, &bytesWritten);
    758769
     
    767778      break;
    768779    }
    769 
     780   
    770781    if (bytesRead!=copySize)
    771782      cb.s.LowPart = 0;
     
    798809 *
    799810 * See the documentation of IStream for more info.
    800  */
    801 HRESULT WINAPI StgStreamImpl_Commit(
    802           IStream*      iface,
    803           DWORD           grfCommitFlags)  /* [in] */
     811 */       
     812HRESULT WINAPI StgStreamImpl_Commit( 
     813                  IStream*      iface,
     814                  DWORD           grfCommitFlags)  /* [in] */
    804815{
    805816  return S_OK;
     
    813824 *
    814825 * See the documentation of IStream for more info.
    815  */
    816 HRESULT WINAPI StgStreamImpl_Revert(
    817           IStream* iface)
     826 */       
     827HRESULT WINAPI StgStreamImpl_Revert( 
     828                  IStream* iface)
    818829{
    819830  return S_OK;
    820831}
    821832
    822 HRESULT WINAPI StgStreamImpl_LockRegion(
    823                     IStream*     iface,
    824                     ULARGE_INTEGER libOffset,   /* [in] */
    825                     ULARGE_INTEGER cb,          /* [in] */
    826                     DWORD          dwLockType)  /* [in] */
     833HRESULT WINAPI StgStreamImpl_LockRegion( 
     834                                        IStream*     iface,
     835                                        ULARGE_INTEGER libOffset,   /* [in] */
     836                                        ULARGE_INTEGER cb,          /* [in] */
     837                                        DWORD          dwLockType)  /* [in] */
    827838{
    828839  FIXME("not implemented!\n");
     
    830841}
    831842
    832 HRESULT WINAPI StgStreamImpl_UnlockRegion(
    833                       IStream*     iface,
    834                       ULARGE_INTEGER libOffset,   /* [in] */
    835                       ULARGE_INTEGER cb,          /* [in] */
    836                       DWORD          dwLockType)  /* [in] */
     843HRESULT WINAPI StgStreamImpl_UnlockRegion( 
     844                                          IStream*     iface,
     845                                          ULARGE_INTEGER libOffset,   /* [in] */
     846                                          ULARGE_INTEGER cb,          /* [in] */
     847                                          DWORD          dwLockType)  /* [in] */
    837848{
    838849  FIXME("not implemented!\n");
     
    847858 *
    848859 * See the documentation of IStream for more info.
    849  */
    850 HRESULT WINAPI StgStreamImpl_Stat(
    851           IStream*     iface,
    852           STATSTG*       pstatstg,     /* [out] */
    853           DWORD          grfStatFlag)  /* [in] */
     860 */       
     861HRESULT WINAPI StgStreamImpl_Stat( 
     862                  IStream*     iface,
     863                  STATSTG*       pstatstg,     /* [out] */
     864                  DWORD          grfStatFlag)  /* [in] */
    854865{
    855866  StgStreamImpl* const This=(StgStreamImpl*)iface;
     
    857868  StgProperty    curProperty;
    858869  BOOL         readSucessful;
    859 
     870 
    860871  /*
    861872   * Read the information from the property.
    862873   */
    863874  readSucessful = StorageImpl_ReadProperty(This->parentStorage->ancestorStorage,
    864                          This->ownerProperty,
    865                          &curProperty);
    866 
     875                                             This->ownerProperty,
     876                                             &curProperty);
     877 
    867878  if (readSucessful)
    868879  {
    869     StorageUtl_CopyPropertyToSTATSTG(pstatstg,
    870                      &curProperty,
    871                      grfStatFlag);
     880    StorageUtl_CopyPropertyToSTATSTG(pstatstg, 
     881                                     &curProperty,
     882                                     grfStatFlag);
    872883
    873884    pstatstg->grfMode = This->grfMode;
    874 
     885   
    875886    return S_OK;
    876887  }
    877 
     888 
    878889  return E_FAIL;
    879890}
    880 
    881 HRESULT WINAPI StgStreamImpl_Clone(
    882                    IStream*     iface,
    883                    IStream**    ppstm) /* [out] */
    884 {
    885   FIXME("not implemented!\n");
    886   return E_NOTIMPL;
    887 }
     891       
     892/***
     893 * This method is part of the IStream interface.
     894 *
     895 * This method returns a clone of the interface that allows for
     896 * another seek pointer
     897 *
     898 * See the documentation of IStream for more info.
     899 *
     900 * I am not totally sure what I am doing here but I presume that this
     901 * should be basically as simple as creating a new stream with the same
     902 * parent etc and positioning its seek cursor.
     903 */       
     904HRESULT WINAPI StgStreamImpl_Clone(
     905                                   IStream*     iface,
     906                                   IStream**    ppstm) /* [out] */
     907{
     908  StgStreamImpl* const This=(StgStreamImpl*)iface;
     909  HRESULT hres;
     910  StgStreamImpl* new_stream;
     911  LARGE_INTEGER seek_pos;
     912
     913  /*
     914   * Sanity check
     915   */
     916  if ( ppstm == 0 )
     917    return STG_E_INVALIDPOINTER;
     918
     919  new_stream = StgStreamImpl_Construct (This->parentStorage, This->grfMode, This->ownerProperty);
     920
     921  if (!new_stream)
     922    return STG_E_INSUFFICIENTMEMORY; /* Currently the only reason for new_stream=0 */
     923
     924  *ppstm = (IStream*) new_stream;
     925  seek_pos.QuadPart = This->currentPosition.QuadPart;
     926 
     927  hres=StgStreamImpl_Seek (*ppstm, seek_pos, STREAM_SEEK_SET, NULL);
     928 
     929  assert (SUCCEEDED(hres));
     930
     931  return S_OK;
     932}
  • trunk/src/ole32/storage32.c

    r6648 r6711  
    1 /* $Id: storage32.c,v 1.3 2001-09-05 13:17:12 bird Exp $ */
    21/*
    32 * Compound Storage (32 bit version)
     
    3837#define FILE_BEGIN 0
    3938
     39#ifdef __WIN32OS2__
     40#undef FIXME
     41#undef TRACE
     42#ifdef DEBUG
     43#define TRACE WriteLog("OLE32: %s", __FUNCTION__); WriteLog
     44#define FIXME WriteLog("FIXME OLE32: %s", __FUNCTION__); WriteLog
     45#else
     46#define TRACE 1 ? (void)0 : (void)((int (*)(char *, ...)) NULL)
     47#define FIXME 1 ? (void)0 : (void)((int (*)(char *, ...)) NULL)
     48#endif
     49#endif
     50
    4051
    4152/* Used for OleConvertIStorageToOLESTREAM and OleConvertOLESTREAMToIStorage */
     
    4859/* OLESTREAM memory structure to use for Get and Put Routines */
    4960/* Used for OleConvertIStorageToOLESTREAM and OleConvertOLESTREAMToIStorage */
    50 typedef struct
     61typedef struct 
    5162{
    5263    DWORD dwOleID;
     
    8697    DWORD dwExtentX;
    8798    DWORD dwExtentY;
    88     DWORD dwSize;
     99    DWORD dwSize; 
    89100    BYTE *pData;
    90101}OLECONVERT_ISTORAGE_OLEPRES;
     
    111122  INT         typeOfRelation);
    112123
    113 static HRESULT adjustPropertyChain(
     124static HRESULT adjustPropertyChain( 
    114125  StorageImpl *This,
    115126  StgProperty   propertyToDelete,
     
    138149 * Declaration of miscellaneous functions...
    139150 */
    140 static HRESULT validateSTGM(DWORD stgmValue);
     151static HRESULT validateSTGM(DWORD stgmValue); 
    141152
    142153static DWORD GetShareModeFromSTGM(DWORD stgm);
     
    224235 * This method implements the common QueryInterface for all IStorage32
    225236 * implementations contained in this file.
    226  *
     237 * 
    227238 * See Windows documentation for more details on IUnknown methods.
    228239 */
     
    238249  if ( (This==0) || (ppvObject==0) )
    239250    return E_INVALIDARG;
    240 
     251 
    241252  /*
    242253   * Initialize the return parameter.
    243254   */
    244255  *ppvObject = 0;
    245 
     256 
    246257  /*
    247258   * Compare the riid with the interface IDs implemented by this object.
    248259   */
    249   if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0)
     260  if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0) 
    250261  {
    251262    *ppvObject = (IStorage*)This;
    252263  }
    253   else if (memcmp(&IID_IStorage, riid, sizeof(IID_IStorage)) == 0)
     264  else if (memcmp(&IID_IStorage, riid, sizeof(IID_IStorage)) == 0) 
    254265  {
    255266    *ppvObject = (IStorage*)This;
    256267  }
    257 
     268 
    258269  /*
    259270   * Check that we obtained an interface.
     
    261272  if ((*ppvObject)==0)
    262273    return E_NOINTERFACE;
    263 
     274 
    264275  /*
    265276   * Query Interface always increases the reference count by one when it is
     
    270281  return S_OK;
    271282}
    272 
     283       
    273284/************************************************************************
    274285 * Storage32BaseImpl_AddRef (IUnknown)
     
    276287 * This method implements the common AddRef for all IStorage32
    277288 * implementations contained in this file.
    278  *
     289 * 
    279290 * See Windows documentation for more details on IUnknown methods.
    280291 */
    281 ULONG WINAPI StorageBaseImpl_AddRef(
     292ULONG WINAPI StorageBaseImpl_AddRef( 
    282293            IStorage* iface)
    283294{
     
    287298  return This->ref;
    288299}
    289 
     300       
    290301/************************************************************************
    291302 * Storage32BaseImpl_Release (IUnknown)
     
    293304 * This method implements the common Release for all IStorage32
    294305 * implementations contained in this file.
    295  *
     306 * 
    296307 * See Windows documentation for more details on IUnknown methods.
    297308 */
    298 ULONG WINAPI StorageBaseImpl_Release(
     309ULONG WINAPI StorageBaseImpl_Release( 
    299310      IStorage* iface)
    300311{
     
    311322  {
    312323    /*
    313      * Since we are using a system of base-classes, we want to call the
    314      * destructor of the appropriate derived class. To do this, we are
     324     * Since we are using a system of base-classes, we want to call the 
     325     * destructor of the appropriate derived class. To do this, we are 
    315326     * using virtual functions to implement the destructor.
    316327     */
     
    319330    return 0;
    320331  }
    321 
     332 
    322333  return This->ref;
    323334}
     
    330341 * See Windows documentation for more details on IStorage methods.
    331342 */
    332 HRESULT WINAPI StorageBaseImpl_OpenStream(
     343HRESULT WINAPI StorageBaseImpl_OpenStream( 
    333344  IStorage*        iface,
    334345  const OLECHAR*   pwcsName,  /* [string][in] */
    335346  void*            reserved1, /* [unique][in] */
    336   DWORD            grfMode,   /* [in]  */
    337   DWORD            reserved2, /* [in]  */
    338   IStream**        ppstm)     /* [out] */
     347  DWORD            grfMode,   /* [in]  */       
     348  DWORD            reserved2, /* [in]  */       
     349  IStream**        ppstm)     /* [out] */       
    339350{
    340351  ICOM_THIS(StorageBaseImpl,iface);
     
    344355  ULONG             foundPropertyIndex;
    345356
    346   TRACE("(%p, %s, %p, %lx, %ld, %p)\n",
    347     iface, debugstr_w(pwcsName), reserved1, grfMode, reserved2, ppstm);
     357  TRACE("(%p, %s, %p, %lx, %ld, %p)\n", 
     358        iface, debugstr_w(pwcsName), reserved1, grfMode, reserved2, ppstm);
    348359
    349360  /*
     
    352363  if ( (pwcsName==NULL) || (ppstm==0) )
    353364    return E_INVALIDARG;
    354 
     365 
    355366  /*
    356367   * Initialize the out parameter
    357368   */
    358369  *ppstm = 0;
    359 
     370 
    360371  /*
    361372   * Validate the STGM flags
     
    376387   */
    377388  propertyEnumeration = IEnumSTATSTGImpl_Construct(
    378     This->ancestorStorage,
     389    This->ancestorStorage, 
    379390    This->rootPropertySetIndex);
    380 
     391 
    381392  /*
    382393   * Search the enumeration for the property with the given name
     
    386397    pwcsName,
    387398    &currentProperty);
    388 
     399 
    389400  /*
    390401   * Delete the property enumeration since we don't need it anymore
    391402   */
    392403  IEnumSTATSTGImpl_Destroy(propertyEnumeration);
    393 
     404 
    394405  /*
    395406   * If it was found, construct the stream object and return a pointer to it.
    396407   */
    397   if ( (foundPropertyIndex!=PROPERTY_NULL) &&
     408  if ( (foundPropertyIndex!=PROPERTY_NULL) && 
    398409       (currentProperty.propertyType==PROPTYPE_STREAM) )
    399410  {
    400411    newStream = StgStreamImpl_Construct(This, grfMode, foundPropertyIndex);
    401 
     412   
    402413    if (newStream!=0)
    403414    {
     
    406417
    407418      /*
    408        * Since we are returning a pointer to the interface, we have to
     419       * Since we are returning a pointer to the interface, we have to 
    409420       * nail down the reference.
    410421       */
    411422      StgStreamImpl_AddRef(*ppstm);
    412 
     423     
    413424      return S_OK;
    414425    }
    415 
     426   
    416427    return E_OUTOFMEMORY;
    417428  }
    418 
     429 
    419430  return STG_E_FILENOTFOUND;
    420431}
     
    424435 *
    425436 * This method will open a new storage object from the current storage.
    426  *
     437 * 
    427438 * See Windows documentation for more details on IStorage methods.
    428  */
    429 HRESULT WINAPI StorageBaseImpl_OpenStorage(
     439 */       
     440HRESULT WINAPI StorageBaseImpl_OpenStorage( 
    430441  IStorage*        iface,
    431   const OLECHAR*   pwcsName,      /* [string][unique][in] */
    432   IStorage*        pstgPriority,  /* [unique][in] */
    433   DWORD            grfMode,       /* [in] */
    434   SNB              snbExclude,    /* [unique][in] */
    435   DWORD            reserved,      /* [in] */
    436   IStorage**       ppstg)         /* [out] */
     442  const OLECHAR*   pwcsName,      /* [string][unique][in] */ 
     443  IStorage*        pstgPriority,  /* [unique][in] */         
     444  DWORD            grfMode,       /* [in] */                 
     445  SNB              snbExclude,    /* [unique][in] */         
     446  DWORD            reserved,      /* [in] */                 
     447  IStorage**       ppstg)         /* [out] */                       
    437448{
    438449  ICOM_THIS(StorageBaseImpl,iface);
     
    442453  ULONG                  foundPropertyIndex;
    443454
    444   TRACE("(%p, %s, %p, %lx, %p, %ld, %p)\n",
    445     iface, debugstr_w(pwcsName), pstgPriority,
    446     grfMode, snbExclude, reserved, ppstg);
    447 
     455  TRACE("(%p, %s, %p, %lx, %p, %ld, %p)\n", 
     456        iface, debugstr_w(pwcsName), pstgPriority,
     457        grfMode, snbExclude, reserved, ppstg);
     458 
    448459  /*
    449460   * Perform a sanity check on the parameters.
     
    451462  if ( (This==0) || (pwcsName==NULL) || (ppstg==0) )
    452463    return E_INVALIDARG;
    453 
     464 
    454465  /*
    455466   * Validate the STGM flags
     
    461472   * As documented.
    462473   */
    463   if ( !(grfMode & STGM_SHARE_EXCLUSIVE) ||
     474  if ( !(grfMode & STGM_SHARE_EXCLUSIVE) || 
    464475        (grfMode & STGM_DELETEONRELEASE) ||
    465476        (grfMode & STGM_PRIORITY) )
     
    470481   */
    471482  *ppstg = 0;
    472 
     483 
    473484  /*
    474485   * Create a property enumeration to search the properties
    475486   */
    476487  propertyEnumeration = IEnumSTATSTGImpl_Construct(
    477                           This->ancestorStorage,
     488                          This->ancestorStorage, 
    478489                          This->rootPropertySetIndex);
    479 
     490 
    480491  /*
    481492   * Search the enumeration for the property with the given name
     
    485496                         pwcsName,
    486497                         &currentProperty);
    487 
     498 
    488499  /*
    489500   * Delete the property enumeration since we don't need it anymore
    490501   */
    491502  IEnumSTATSTGImpl_Destroy(propertyEnumeration);
    492 
     503 
    493504  /*
    494505   * If it was found, construct the stream object and return a pointer to it.
    495506   */
    496   if ( (foundPropertyIndex!=PROPERTY_NULL) &&
     507  if ( (foundPropertyIndex!=PROPERTY_NULL) && 
    497508       (currentProperty.propertyType==PROPTYPE_STORAGE) )
    498509  {
     
    503514                   This->ancestorStorage,
    504515                   foundPropertyIndex);
    505 
     516   
    506517    if (newStorage != 0)
    507518    {
     
    509520
    510521      /*
    511        * Since we are returning a pointer to the interface,
     522       * Since we are returning a pointer to the interface, 
    512523       * we have to nail down the reference.
    513524       */
    514525      StorageBaseImpl_AddRef(*ppstg);
    515 
     526     
    516527      return S_OK;
    517528    }
    518 
     529   
    519530    return STG_E_INSUFFICIENTMEMORY;
    520531  }
    521 
     532 
    522533  return STG_E_FILENOTFOUND;
    523534}
     
    526537 * Storage32BaseImpl_EnumElements (IStorage)
    527538 *
    528  * This method will create an enumerator object that can be used to
     539 * This method will create an enumerator object that can be used to 
    529540 * retrieve informatino about all the properties in the storage object.
    530  *
     541 * 
    531542 * See Windows documentation for more details on IStorage methods.
    532  */
    533 HRESULT WINAPI StorageBaseImpl_EnumElements(
     543 */       
     544HRESULT WINAPI StorageBaseImpl_EnumElements( 
    534545  IStorage*       iface,
    535   DWORD           reserved1, /* [in] */
    536   void*           reserved2, /* [size_is][unique][in] */
    537   DWORD           reserved3, /* [in] */
    538   IEnumSTATSTG**  ppenum)    /* [out] */
     546  DWORD           reserved1, /* [in] */                 
     547  void*           reserved2, /* [size_is][unique][in] */ 
     548  DWORD           reserved3, /* [in] */                 
     549  IEnumSTATSTG**  ppenum)    /* [out] */                 
    539550{
    540551  ICOM_THIS(StorageBaseImpl,iface);
    541552  IEnumSTATSTGImpl* newEnum;
    542553
    543   TRACE("(%p, %ld, %p, %ld, %p)\n",
    544     iface, reserved1, reserved2, reserved3, ppenum);
     554  TRACE("(%p, %ld, %p, %ld, %p)\n", 
     555        iface, reserved1, reserved2, reserved3, ppenum);
    545556
    546557  /*
     
    549560  if ( (This==0) || (ppenum==0))
    550561    return E_INVALIDARG;
    551 
     562 
    552563  /*
    553564   * Construct the enumerator.
     
    566577     */
    567578    IEnumSTATSTGImpl_AddRef(*ppenum);
    568 
     579   
    569580    return S_OK;
    570581  }
     
    577588 *
    578589 * This method will retrieve information about this storage object.
    579  *
     590 * 
    580591 * See Windows documentation for more details on IStorage methods.
    581  */
    582 HRESULT WINAPI StorageBaseImpl_Stat(
     592 */       
     593HRESULT WINAPI StorageBaseImpl_Stat( 
    583594  IStorage*        iface,
    584   STATSTG*         pstatstg,     /* [out] */
    585   DWORD            grfStatFlag)  /* [in] */
     595  STATSTG*         pstatstg,     /* [out] */ 
     596  DWORD            grfStatFlag)  /* [in] */ 
    586597{
    587598  ICOM_THIS(StorageBaseImpl,iface);
     
    589600  BOOL         readSuccessful;
    590601
    591   TRACE("(%p, %p, %lx)\n",
    592     iface, pstatstg, grfStatFlag);
     602  TRACE("(%p, %p, %lx)\n", 
     603        iface, pstatstg, grfStatFlag);
    593604
    594605  /*
     
    609620  {
    610621    StorageUtl_CopyPropertyToSTATSTG(
    611       pstatstg,
    612       &curProperty,
     622      pstatstg, 
     623      &curProperty, 
    613624      grfStatFlag);
    614 
     625   
    615626    return S_OK;
    616627  }
    617 
     628 
    618629  return E_FAIL;
    619630}
     
    622633 * Storage32BaseImpl_RenameElement (IStorage)
    623634 *
    624  * This method will rename the specified element.
     635 * This method will rename the specified element. 
    625636 *
    626637 * See Windows documentation for more details on IStorage methods.
    627  *
    628  * Implementation notes: The method used to rename consists of creating a clone
    629  *    of the deleted StgProperty object setting it with the new name and to
     638 * 
     639 * Implementation notes: The method used to rename consists of creating a clone 
     640 *    of the deleted StgProperty object setting it with the new name and to 
    630641 *    perform a DestroyElement of the old StgProperty.
    631642 */
     
    640651  ULONG             foundPropertyIndex;
    641652
    642   TRACE("(%p, %s, %s)\n",
    643     iface, debugstr_w(pwcsOldName), debugstr_w(pwcsNewName));
     653  TRACE("(%p, %s, %s)\n", 
     654        iface, debugstr_w(pwcsOldName), debugstr_w(pwcsNewName));
    644655
    645656  /*
     
    687698     * Setup a new property for the renamed property
    688699     */
    689     renamedProperty.sizeOfNameString =
     700    renamedProperty.sizeOfNameString = 
    690701      ( lstrlenW(pwcsNewName)+1 ) * sizeof(WCHAR);
    691 
     702 
    692703    if (renamedProperty.sizeOfNameString > PROPERTY_NAME_BUFFER_LEN)
    693704      return STG_E_INVALIDNAME;
    694 
     705 
    695706    strcpyW(renamedProperty.name, pwcsNewName);
    696 
     707 
    697708    renamedProperty.propertyType  = currentProperty.propertyType;
    698709    renamedProperty.startingBlock = currentProperty.startingBlock;
    699710    renamedProperty.size.s.LowPart  = currentProperty.size.s.LowPart;
    700711    renamedProperty.size.s.HighPart = currentProperty.size.s.HighPart;
    701 
     712 
    702713    renamedProperty.previousProperty = PROPERTY_NULL;
    703714    renamedProperty.nextProperty     = PROPERTY_NULL;
    704 
     715 
    705716    /*
    706717     * Bring the dirProperty link in case it is a storage and in which
     
    708719     */
    709720    renamedProperty.dirProperty = currentProperty.dirProperty;
    710 
    711     /* call CoFileTime to get the current time
     721 
     722    /* call CoFileTime to get the current time 
    712723    renamedProperty.timeStampS1
    713724    renamedProperty.timeStampD1
    714725    renamedProperty.timeStampS2
    715726    renamedProperty.timeStampD2
    716     renamedProperty.propertyUniqueID
     727    renamedProperty.propertyUniqueID 
    717728    */
    718 
    719     /*
     729 
     730    /* 
    720731     * Obtain a free property in the property chain
    721732     */
    722733    renamedPropertyIndex = getFreeProperty(This->ancestorStorage);
    723 
     734 
    724735    /*
    725736     * Save the new property into the new property spot
    726      */
     737     */ 
    727738    StorageImpl_WriteProperty(
    728739      This->ancestorStorage,
    729       renamedPropertyIndex,
     740      renamedPropertyIndex, 
    730741      &renamedProperty);
    731 
    732     /*
     742 
     743    /* 
    733744     * Find a spot in the property chain for our newly created property.
    734745     */
    735746    updatePropertyChain(
    736747      (StorageImpl*)This,
    737       renamedPropertyIndex,
     748      renamedPropertyIndex, 
    738749      renamedProperty);
    739750
    740751    /*
    741      * At this point the renamed property has been inserted in the tree,
    742      * now, before to Destroy the old property we must zeroed it's dirProperty
    743      * otherwise the DestroyProperty below will zap it all and we do not want
     752     * At this point the renamed property has been inserted in the tree, 
     753     * now, before to Destroy the old property we must zeroed it's dirProperty 
     754     * otherwise the DestroyProperty below will zap it all and we do not want 
    744755     * this to happen.
    745756     * Also, we fake that the old property is a storage so the DestroyProperty
    746757     * will not do a SetSize(0) on the stream data.
    747      *
     758     * 
    748759     * This means that we need to tweek the StgProperty if it is a stream or a
    749760     * non empty storage.
     
    757768    StorageImpl_WriteProperty(
    758769      This->ancestorStorage,
    759       foundPropertyIndex,
     770      foundPropertyIndex, 
    760771      &currentProperty);
    761772
    762     /*
    763      * Invoke Destroy to get rid of the ole property and automatically redo
    764      * the linking of it's previous and next members...
    765      */
    766     StorageImpl_DestroyElement((IStorage*)This->ancestorStorage, pwcsOldName);
     773    /* 
     774     * Invoke Destroy to get rid of the ole property and automatically redo 
     775     * the linking of it's previous and next members... 
     776     */ 
     777    StorageImpl_DestroyElement((IStorage*)This->ancestorStorage, pwcsOldName); 
    767778
    768779  }
     
    781792 * Storage32BaseImpl_CreateStream (IStorage)
    782793 *
    783  * This method will create a stream object within this storage
     794 * This method will create a stream object within this storage 
    784795 *
    785796 * See Windows documentation for more details on IStorage methods.
     
    799810  ULONG             foundPropertyIndex, newPropertyIndex;
    800811
    801   TRACE("(%p, %s, %lx, %ld, %ld, %p)\n",
    802     iface, debugstr_w(pwcsName), grfMode,
    803     reserved1, reserved2, ppstm);
     812  TRACE("(%p, %s, %lx, %ld, %ld, %p)\n", 
     813        iface, debugstr_w(pwcsName), grfMode,
     814        reserved1, reserved2, ppstm);
    804815
    805816  /*
     
    846857  {
    847858    /*
    848      * An element with this name already exists
     859     * An element with this name already exists 
    849860     */
    850861    if (grfMode & STGM_CREATE)
    851862    {
    852       IStorage_DestroyElement(iface, pwcsName);
    853     }
    854     else
     863      IStorage_DestroyElement(iface, pwcsName); 
     864    }
     865    else 
    855866      return STG_E_FILEALREADYEXISTS;
    856867  }
    857868
    858   /*
    859    * memset the empty property
     869  /* 
     870   * memset the empty property 
    860871   */
    861872  memset(&newStreamProperty, 0, sizeof(StgProperty));
     
    878889  newStreamProperty.dirProperty      = PROPERTY_NULL;
    879890
    880   /* call CoFileTime to get the current time
     891  /* call CoFileTime to get the current time 
    881892  newStreamProperty.timeStampS1
    882893  newStreamProperty.timeStampD1
     
    888899
    889900  /*
    890    * Get a free property or create a new one
     901   * Get a free property or create a new one 
    891902   */
    892903  newPropertyIndex = getFreeProperty(This->ancestorStorage);
     
    894905  /*
    895906   * Save the new property into the new property spot
    896    */
     907   */ 
    897908  StorageImpl_WriteProperty(
    898909    This->ancestorStorage,
    899     newPropertyIndex,
     910    newPropertyIndex, 
    900911    &newStreamProperty);
    901912
    902   /*
     913  /* 
    903914   * Find a spot in the property chain for our newly created property.
    904915   */
    905916  updatePropertyChain(
    906917    (StorageImpl*)This,
    907     newPropertyIndex,
     918    newPropertyIndex, 
    908919    newStreamProperty);
    909920
    910   /*
     921  /* 
    911922   * Open the stream to return it.
    912923   */
     
    934945 * Storage32BaseImpl_SetClass (IStorage)
    935946 *
    936  * This method will write the specified CLSID in the property of this
     947 * This method will write the specified CLSID in the property of this 
    937948 * storage.
    938949 *
     
    949960
    950961  TRACE("(%p, %p)\n", iface, clsid);
    951 
     962 
    952963  success = StorageImpl_ReadProperty(This->ancestorStorage,
    953964                                       This->rootPropertySetIndex,
     
    970981** Storage32Impl implementation
    971982*/
    972 
     983       
    973984/************************************************************************
    974985 * Storage32Impl_CreateStorage (IStorage)
     
    978989 * See Windows documentation for more details on IStorage methods.
    979990 */
    980 HRESULT WINAPI StorageImpl_CreateStorage(
     991HRESULT WINAPI StorageImpl_CreateStorage( 
    981992  IStorage*      iface,
    982   const OLECHAR  *pwcsName, /* [string][in] */
    983   DWORD            grfMode,   /* [in] */
    984   DWORD            reserved1, /* [in] */
    985   DWORD            reserved2, /* [in] */
    986   IStorage       **ppstg)   /* [out] */
     993  const OLECHAR  *pwcsName, /* [string][in] */ 
     994  DWORD            grfMode,   /* [in] */ 
     995  DWORD            reserved1, /* [in] */ 
     996  DWORD            reserved2, /* [in] */ 
     997  IStorage       **ppstg)   /* [out] */ 
    987998{
    988999  StorageImpl* const This=(StorageImpl*)iface;
     
    9951006  HRESULT          hr;
    9961007
    997   TRACE("(%p, %s, %lx, %ld, %ld, %p)\n",
    998     iface, debugstr_w(pwcsName), grfMode,
    999     reserved1, reserved2, ppstg);
    1000 
     1008  TRACE("(%p, %s, %lx, %ld, %ld, %p)\n", 
     1009        iface, debugstr_w(pwcsName), grfMode,
     1010        reserved1, reserved2, ppstg);
     1011 
    10011012  /*
    10021013   * Validate parameters
     
    10341045  {
    10351046    /*
    1036      * An element with this name already exists
     1047     * An element with this name already exists 
    10371048     */
    10381049    if (grfMode & STGM_CREATE)
    1039       IStorage_DestroyElement(iface, pwcsName);
    1040     else
     1050      IStorage_DestroyElement(iface, pwcsName); 
     1051    else 
    10411052      return STG_E_FILEALREADYEXISTS;
    10421053  }
    10431054
    1044   /*
    1045    * memset the empty property
     1055  /* 
     1056   * memset the empty property 
    10461057   */
    10471058  memset(&newProperty, 0, sizeof(StgProperty));
     
    10631074  newProperty.dirProperty      = PROPERTY_NULL;
    10641075
    1065   /* call CoFileTime to get the current time
     1076  /* call CoFileTime to get the current time 
    10661077  newProperty.timeStampS1
    10671078  newProperty.timeStampD1
     
    10721083  /*  newStorageProperty.propertyUniqueID */
    10731084
    1074   /*
     1085  /* 
    10751086   * Obtain a free property in the property chain
    10761087   */
     
    10791090  /*
    10801091   * Save the new property into the new property spot
    1081    */
     1092   */ 
    10821093  StorageImpl_WriteProperty(
    10831094    This->ancestorStorage,
    1084     newPropertyIndex,
     1095    newPropertyIndex, 
    10851096    &newProperty);
    10861097
    1087   /*
     1098  /* 
    10881099   * Find a spot in the property chain for our newly created property.
    10891100   */
    10901101  updatePropertyChain(
    10911102    This,
    1092     newPropertyIndex,
     1103    newPropertyIndex, 
    10931104    newProperty);
    10941105
    1095   /*
     1106  /* 
    10961107   * Open it to get a pointer to return.
    10971108   */
     
    11101121  }
    11111122
    1112 
     1123 
    11131124  return S_OK;
    11141125}
     
    11411152      if (currentProperty.sizeOfNameString == 0)
    11421153      {
    1143         /*
     1154        /* 
    11441155         * The property existis and is available, we found it.
    11451156         */
     
    11581169  } while (newPropertyIndex == PROPERTY_NULL);
    11591170
    1160   /*
    1161    * grow the property chain
     1171  /* 
     1172   * grow the property chain 
    11621173   */
    11631174  if (! readSuccessful)
     
    11691180    ULONG          blockCount    = 0;
    11701181
    1171     /*
    1172      * obtain the new count of property blocks
     1182    /* 
     1183     * obtain the new count of property blocks 
    11731184     */
    11741185    blockCount = BlockChainStream_GetCount(
    11751186                   storage->ancestorStorage->rootBlockChain)+1;
    11761187
    1177     /*
    1178      * initialize the size used by the property stream
     1188    /* 
     1189     * initialize the size used by the property stream 
    11791190     */
    11801191    newSize.s.HighPart = 0;
    11811192    newSize.s.LowPart  = storage->bigBlockSize * blockCount;
    11821193
    1183     /*
    1184      * add a property block to the property chain
     1194    /* 
     1195     * add a property block to the property chain 
    11851196     */
    11861197    BlockChainStream_SetSize(storage->ancestorStorage->rootBlockChain, newSize);
    11871198
    1188     /*
    1189      * memset the empty property in order to initialize the unused newly
     1199    /* 
     1200     * memset the empty property in order to initialize the unused newly 
    11901201     * created property
    11911202     */
    11921203    memset(&emptyProperty, 0, sizeof(StgProperty));
    11931204
    1194     /*
     1205    /* 
    11951206     * initialize them
    11961207     */
    1197     lastProperty = storage->bigBlockSize / PROPSET_BLOCK_SIZE * blockCount;
    1198 
     1208    lastProperty = storage->bigBlockSize / PROPSET_BLOCK_SIZE * blockCount; 
     1209   
    11991210    for(
    12001211      propertyIndex = newPropertyIndex;
     
    12041215      StorageImpl_WriteProperty(
    12051216        storage->ancestorStorage,
    1206         propertyIndex,
     1217        propertyIndex, 
    12071218        &emptyProperty);
    12081219    }
     
    12161227 * Internal Method
    12171228 *
    1218  * Case insensitive comparaison of StgProperty.name by first considering
     1229 * Case insensitive comparaison of StgProperty.name by first considering 
    12191230 * their size.
    12201231 *
     
    12291240  LONG diff      = lstrlenW(newProperty) - lstrlenW(currentProperty);
    12301241
    1231   if (diff == 0)
    1232   {
    1233     /*
     1242  if (diff == 0) 
     1243  {
     1244    /* 
    12341245     * We compare the string themselves only when they are of the same lenght
    12351246     */
     
    12371248  }
    12381249
    1239   return diff;
     1250  return diff; 
    12401251}
    12411252
     
    12491260  StorageImpl *storage,
    12501261  ULONG         newPropertyIndex,
    1251   StgProperty   newProperty)
     1262  StgProperty   newProperty) 
    12521263{
    12531264  StgProperty currentProperty;
     
    12621273  if (currentProperty.dirProperty != PROPERTY_NULL)
    12631274  {
    1264     /*
     1275    /* 
    12651276     * The root storage contains some element, therefore, start the research
    12661277     * for the appropriate location.
     
    12751286
    12761287    /*
    1277      * Read
     1288     * Read 
    12781289     */
    12791290    StorageImpl_ReadProperty(storage->ancestorStorage,
     
    12881299    {
    12891300      LONG diff = propertyNameCmp( newProperty.name, currentProperty.name);
    1290 
     1301 
    12911302      if (diff < 0)
    12921303      {
     
    13271338      else
    13281339      {
    1329     /*
    1330     * Trying to insert an item with the same name in the
    1331     * subtree structure.
    1332     */
    1333     assert(FALSE);
     1340        /*
     1341        * Trying to insert an item with the same name in the
     1342        * subtree structure.
     1343        */
     1344        assert(FALSE);
    13341345      }
    13351346
     
    13401351  else
    13411352  {
    1342     /*
     1353    /* 
    13431354     * The root storage is empty, link the new property to it's dir property
    13441355     */
     
    13501361}
    13511362
    1352 
     1363     
    13531364/*************************************************************************
    13541365 * CopyTo (IStorage)
    13551366 */
    1356 HRESULT WINAPI StorageImpl_CopyTo(
     1367HRESULT WINAPI StorageImpl_CopyTo( 
    13571368  IStorage*   iface,
    1358   DWORD       ciidExclude,  /* [in] */
    1359   const IID*  rgiidExclude, /* [size_is][unique][in] */
    1360   SNB         snbExclude,   /* [unique][in] */
    1361   IStorage*   pstgDest)     /* [unique][in] */
     1369  DWORD       ciidExclude,  /* [in] */ 
     1370  const IID*  rgiidExclude, /* [size_is][unique][in] */ 
     1371  SNB         snbExclude,   /* [unique][in] */ 
     1372  IStorage*   pstgDest)     /* [unique][in] */ 
    13621373{
    13631374  IEnumSTATSTG *elements     = 0;
     
    13701381    FIXME("Exclude option not implemented\n");
    13711382
    1372   TRACE("(%p, %ld, %p, %p, %p)\n",
    1373     iface, ciidExclude, rgiidExclude,
    1374     snbExclude, pstgDest);
     1383  TRACE("(%p, %ld, %p, %p, %p)\n", 
     1384        iface, ciidExclude, rgiidExclude,
     1385        snbExclude, pstgDest);
    13751386
    13761387  /*
     
    13801391    return STG_E_INVALIDPOINTER;
    13811392
    1382   /*
     1393  /* 
    13831394   * Enumerate the elements
    13841395   */
     
    13931404  IStorage_Stat( iface, &curElement, STATFLAG_NONAME);
    13941405  IStorage_SetClass( pstgDest, &curElement.clsid );
    1395 
     1406 
    13961407  do
    13971408  {
     
    14131424       */
    14141425      hr = IStorage_OpenStorage( iface, curElement.pwcsName, NULL,
    1415                 STGM_READ|STGM_SHARE_EXCLUSIVE,
    1416                 NULL, 0, &pstgChild );
     1426                                STGM_READ|STGM_SHARE_EXCLUSIVE,
     1427                                NULL, 0, &pstgChild );
    14171428
    14181429      if (hr != S_OK)
     
    14251436      if (pstgChild == pstgDest)
    14261437      {
    1427     IEnumSTATSTG_Release(elements);
    1428 
    1429     return STG_E_ACCESSDENIED;
     1438        IEnumSTATSTG_Release(elements);
     1439
     1440        return STG_E_ACCESSDENIED;
    14301441      }
    1431 
     1442           
    14321443      /*
    14331444       * create a new storage in destination storage
     
    14351446      hr = IStorage_CreateStorage( pstgDest, curElement.pwcsName,
    14361447                                   STGM_FAILIFTHERE|STGM_WRITE|STGM_SHARE_EXCLUSIVE,
    1437                    0, 0,
     1448                                   0, 0,
    14381449                                   &pstgTmp );
    14391450      /*
     
    14461457                                   NULL, 0, &pstgTmp );
    14471458      }
    1448 
     1459       
    14491460      if (hr != S_OK)
    14501461        break;
    14511462
    1452 
     1463       
    14531464      /*
    14541465       * do the copy recursively
     
    14561467      hr = IStorage_CopyTo( pstgChild, ciidExclude, rgiidExclude,
    14571468                               snbExclude, pstgTmp );
    1458 
     1469                               
    14591470      IStorage_Release( pstgTmp );
    14601471      IStorage_Release( pstgChild );
     
    14771488       */
    14781489      hr = IStorage_OpenStream( iface, curElement.pwcsName, NULL,
    1479                 STGM_READ|STGM_SHARE_EXCLUSIVE,
    1480                 0, &pstrChild );
     1490                                STGM_READ|STGM_SHARE_EXCLUSIVE,
     1491                                0, &pstrChild );
    14811492
    14821493      if (hr != S_OK)
     
    14921503       */
    14931504      IStream_SetSize(pstrTmp, strStat.cbSize);
    1494 
     1505     
    14951506      /*
    14961507       * do the copy
     
    14981509      hr = IStream_CopyTo( pstrChild, pstrTmp, strStat.cbSize,
    14991510                           NULL, NULL );
    1500 
     1511                               
    15011512      IStream_Release( pstrTmp );
    15021513      IStream_Release( pstrChild );
     
    15131524   */
    15141525  IEnumSTATSTG_Release(elements);
    1515 
     1526 
    15161527  return hr;
    15171528}
    1518 
     1529       
    15191530/*************************************************************************
    15201531 * MoveElementTo (IStorage)
    15211532 */
    1522 HRESULT WINAPI StorageImpl_MoveElementTo(
     1533HRESULT WINAPI StorageImpl_MoveElementTo( 
    15231534  IStorage*     iface,
    1524   const OLECHAR *pwcsName,   /* [string][in] */
    1525   IStorage      *pstgDest,   /* [unique][in] */
    1526   const OLECHAR *pwcsNewName,/* [string][in] */
    1527   DWORD           grfFlags)    /* [in] */
     1535  const OLECHAR *pwcsName,   /* [string][in] */ 
     1536  IStorage      *pstgDest,   /* [unique][in] */ 
     1537  const OLECHAR *pwcsNewName,/* [string][in] */ 
     1538  DWORD           grfFlags)    /* [in] */ 
    15281539{
    15291540  FIXME("not implemented!\n");
    15301541  return E_NOTIMPL;
    15311542}
    1532 
     1543       
    15331544/*************************************************************************
    15341545 * Commit (IStorage)
    15351546 */
    1536 HRESULT WINAPI StorageImpl_Commit(
     1547HRESULT WINAPI StorageImpl_Commit( 
    15371548  IStorage*   iface,
    1538   DWORD         grfCommitFlags)/* [in] */
     1549  DWORD         grfCommitFlags)/* [in] */ 
    15391550{
    15401551  FIXME("(%ld): stub!\n", grfCommitFlags);
    15411552  return S_OK;
    15421553}
    1543 
     1554       
    15441555/*************************************************************************
    15451556 * Revert (IStorage)
    15461557 */
    1547 HRESULT WINAPI StorageImpl_Revert(
     1558HRESULT WINAPI StorageImpl_Revert( 
    15481559  IStorage* iface)
    15491560{
     
    15551566 * DestroyElement (IStorage)
    15561567 *
    1557  * Stategy: This implementation is build this way for simplicity not for speed.
     1568 * Stategy: This implementation is build this way for simplicity not for speed. 
    15581569 *          I always delete the top most element of the enumeration and adjust
    1559  *          the deleted element pointer all the time.  This takes longer to
    1560  *          do but allow to reinvoke DestroyElement whenever we encounter a
     1570 *          the deleted element pointer all the time.  This takes longer to 
     1571 *          do but allow to reinvoke DestroyElement whenever we encounter a 
    15611572 *          storage object.  The optimisation reside in the usage of another
    1562  *          enumeration stategy that would give all the leaves of a storage
     1573 *          enumeration stategy that would give all the leaves of a storage 
    15631574 *          first. (postfix order)
    15641575 */
    1565 HRESULT WINAPI StorageImpl_DestroyElement(
     1576HRESULT WINAPI StorageImpl_DestroyElement( 
    15661577  IStorage*     iface,
    1567   const OLECHAR *pwcsName)/* [string][in] */
     1578  const OLECHAR *pwcsName)/* [string][in] */ 
    15681579{
    15691580  StorageImpl* const This=(StorageImpl*)iface;
     
    15781589  ULONG             parentPropertyId;
    15791590
    1580   TRACE("(%p, %s)\n",
    1581     iface, debugstr_w(pwcsName));
     1591  TRACE("(%p, %s)\n", 
     1592        iface, debugstr_w(pwcsName));
    15821593
    15831594  /*
    15841595   * Perform a sanity check on the parameters.
    15851596   */
    1586   if (pwcsName==NULL)
     1597  if (pwcsName==NULL) 
    15871598    return STG_E_INVALIDPOINTER;
    1588 
     1599 
    15891600  /*
    15901601   * Create a property enumeration to search the property with the given name
    15911602   */
    15921603  propertyEnumeration = IEnumSTATSTGImpl_Construct(
    1593     This->ancestorStorage,
     1604    This->ancestorStorage, 
    15941605    This->rootPropertySetIndex);
    1595 
     1606 
    15961607  foundPropertyIndexToDelete = IEnumSTATSTGImpl_FindProperty(
    15971608    propertyEnumeration,
     
    16011612  IEnumSTATSTGImpl_Destroy(propertyEnumeration);
    16021613
    1603   if ( foundPropertyIndexToDelete == PROPERTY_NULL )
     1614  if ( foundPropertyIndexToDelete == PROPERTY_NULL ) 
    16041615  {
    16051616    return STG_E_FILENOTFOUND;
    16061617  }
    16071618
    1608   /*
    1609    * Find the parent property of the property to delete (the one that
    1610    * link to it).  If This->dirProperty == foundPropertyIndexToDelete,
     1619  /* 
     1620   * Find the parent property of the property to delete (the one that 
     1621   * link to it).  If This->dirProperty == foundPropertyIndexToDelete, 
    16111622   * the parent is This. Otherwise, the parent is one of it's sibling...
    16121623   */
    16131624
    1614   /*
     1625  /* 
    16151626   * First, read This's StgProperty..
    16161627   */
    1617   res = StorageImpl_ReadProperty(
     1628  res = StorageImpl_ReadProperty( 
    16181629          This->ancestorStorage,
    16191630          This->rootPropertySetIndex,
     
    16221633  assert(res==TRUE);
    16231634
    1624   /*
     1635  /* 
    16251636   * Second, check to see if by any chance the actual storage (This) is not
    16261637   * the parent of the property to delete... We never know...
     
    16281639  if ( parentProperty.dirProperty == foundPropertyIndexToDelete )
    16291640  {
    1630     /*
     1641    /* 
    16311642     * Set data as it would have been done in the else part...
    16321643     */
     
    16341645    parentPropertyId = This->rootPropertySetIndex;
    16351646  }
    1636   else
    1637   {
    1638     /*
    1639      * Create a property enumeration to search the parent properties, and
     1647  else 
     1648  { 
     1649    /*
     1650     * Create a property enumeration to search the parent properties, and 
    16401651     * delete it once done.
    16411652     */
     
    16431654
    16441655    propertyEnumeration2 = IEnumSTATSTGImpl_Construct(
    1645       This->ancestorStorage,
     1656      This->ancestorStorage, 
    16461657      This->rootPropertySetIndex);
    1647 
     1658 
    16481659    typeOfRelation = IEnumSTATSTGImpl_FindParentProperty(
    16491660      propertyEnumeration2,
     
    16551666  }
    16561667
    1657   if ( propertyToDelete.propertyType == PROPTYPE_STORAGE )
     1668  if ( propertyToDelete.propertyType == PROPTYPE_STORAGE ) 
    16581669  {
    16591670    hr = deleteStorageProperty(
    1660            This,
     1671           This, 
    16611672           foundPropertyIndexToDelete,
    16621673           propertyToDelete);
    1663   }
     1674  } 
    16641675  else if ( propertyToDelete.propertyType == PROPTYPE_STREAM )
    16651676  {
    16661677    hr = deleteStreamProperty(
    1667            This,
     1678           This, 
    16681679           foundPropertyIndexToDelete,
    16691680           propertyToDelete);
    16701681  }
    16711682
    1672   if (hr!=S_OK)
     1683  if (hr!=S_OK) 
    16731684    return hr;
    16741685
     
    16781689  hr = adjustPropertyChain(
    16791690        This,
    1680         propertyToDelete,
     1691        propertyToDelete, 
    16811692        parentProperty,
    16821693        parentPropertyId,
     
    17221733  }
    17231734
    1724   /*
     1735  /* 
    17251736   * Enumerate the elements
    17261737   */
     
    17361747    {
    17371748      destroyHr = StorageImpl_DestroyElement(
    1738                     (IStorage*)childStorage,
     1749                    (IStorage*)childStorage, 
    17391750                    (OLECHAR*)currentElement.pwcsName);
    17401751
     
    17611772  IStorage_Release(childStorage);
    17621773  IEnumSTATSTG_Release(elements);
    1763 
     1774   
    17641775  return destroyHr;
    17651776}
     
    17911802         0,
    17921803         &pis);
    1793 
     1804   
    17941805  if (hr!=S_OK)
    17951806  {
     
    17971808  }
    17981809
    1799   /*
    1800    * Zap the stream
    1801    */
    1802   hr = IStream_SetSize(pis, size);
     1810  /* 
     1811   * Zap the stream 
     1812   */ 
     1813  hr = IStream_SetSize(pis, size); 
    18031814
    18041815  if(hr != S_OK)
     
    18121823  IStream_Release(pis);
    18131824
    1814   /*
     1825  /* 
    18151826   * Invalidate the property by zeroing it's name member.
    18161827   */
    18171828  propertyToDelete.sizeOfNameString = 0;
    18181829
    1819   /*
     1830  /* 
    18201831   * Here we should re-read the property so we get the updated pointer
    18211832   * but since we are here to zap it, I don't do it...
    18221833   */
    18231834  StorageImpl_WriteProperty(
    1824     parentStorage->ancestorStorage,
     1835    parentStorage->ancestorStorage, 
    18251836    indexOfPropertyToDelete,
    18261837    &propertyToDelete);
     
    18511862  res = StorageImpl_ReadProperty(
    18521863          storage->ancestorStorage,
    1853           storePropertyIndex,
     1864          storePropertyIndex, 
    18541865          &storeProperty);
    18551866
     
    18651876      return findPlaceholder(
    18661877               storage,
    1867                propertyIndexToStore,
     1878               propertyIndexToStore, 
    18681879               storeProperty.previousProperty,
    18691880               typeOfRelation);
     
    18801891      return findPlaceholder(
    18811892               storage,
    1882                propertyIndexToStore,
     1893               propertyIndexToStore, 
    18831894               storeProperty.nextProperty,
    18841895               typeOfRelation);
     
    18881899      storeProperty.nextProperty = propertyIndexToStore;
    18891900    }
    1890   }
     1901  } 
    18911902  else if (typeOfRelation == PROPERTY_RELATION_DIR)
    18921903  {
     
    18951906      return findPlaceholder(
    18961907               storage,
    1897                propertyIndexToStore,
     1908               propertyIndexToStore, 
    18981909               storeProperty.dirProperty,
    18991910               typeOfRelation);
     
    19071918  hr = StorageImpl_WriteProperty(
    19081919         storage->ancestorStorage,
    1909          storePropertyIndex,
     1920         storePropertyIndex, 
    19101921         &storeProperty);
    19111922
     
    19221933 * Internal Method
    19231934 *
    1924  * This method takes the previous and the next property link of a property
     1935 * This method takes the previous and the next property link of a property 
    19251936 * to be deleted and find them a place in the Storage.
    19261937 */
    1927 static HRESULT adjustPropertyChain(
     1938static HRESULT adjustPropertyChain( 
    19281939  StorageImpl *This,
    19291940  StgProperty   propertyToDelete,
     
    19391950  HRESULT hr                     = S_OK;
    19401951  BOOL  res                    = TRUE;
    1941 
    1942   if (typeOfRelation == PROPERTY_RELATION_PREVIOUS)
    1943   {
    1944     if (propertyToDelete.previousProperty != PROPERTY_NULL)
    1945     {
    1946       /*
     1952 
     1953  if (typeOfRelation == PROPERTY_RELATION_PREVIOUS) 
     1954  {
     1955    if (propertyToDelete.previousProperty != PROPERTY_NULL) 
     1956    {
     1957      /* 
    19471958       * Set the parent previous to the property to delete previous
    19481959       */
    19491960      newLinkProperty = propertyToDelete.previousProperty;
    19501961
    1951       if (propertyToDelete.nextProperty != PROPERTY_NULL)
     1962      if (propertyToDelete.nextProperty != PROPERTY_NULL) 
    19521963      {
    19531964        /*
    1954          * We also need to find a storage for the other link, setup variables
     1965         * We also need to find a storage for the other link, setup variables 
    19551966         * to do this at the end...
    1956          */
     1967         */     
    19571968        needToFindAPlaceholder = TRUE;
    19581969        storeNode              = propertyToDelete.previousProperty;
     
    19601971        relationType           = PROPERTY_RELATION_NEXT;
    19611972      }
    1962     }
    1963     else if (propertyToDelete.nextProperty != PROPERTY_NULL)
    1964     {
    1965       /*
     1973    } 
     1974    else if (propertyToDelete.nextProperty != PROPERTY_NULL) 
     1975    {
     1976      /* 
    19661977       * Set the parent previous to the property to delete next
    19671978       */
    19681979      newLinkProperty = propertyToDelete.nextProperty;
    19691980    }
    1970 
    1971     /*
     1981   
     1982    /* 
    19721983     * Link it for real...
    1973      */
     1984     */ 
    19741985    parentProperty.previousProperty = newLinkProperty;
    1975 
    1976   }
    1977   else if (typeOfRelation == PROPERTY_RELATION_NEXT)
    1978   {
    1979     if (propertyToDelete.previousProperty != PROPERTY_NULL)
    1980     {
    1981       /*
     1986 
     1987  } 
     1988  else if (typeOfRelation == PROPERTY_RELATION_NEXT) 
     1989  {
     1990    if (propertyToDelete.previousProperty != PROPERTY_NULL) 
     1991    {
     1992      /* 
    19821993       * Set the parent next to the property to delete next previous
    19831994       */
    19841995      newLinkProperty = propertyToDelete.previousProperty;
    1985 
    1986       if (propertyToDelete.nextProperty != PROPERTY_NULL)
     1996     
     1997      if (propertyToDelete.nextProperty != PROPERTY_NULL) 
    19871998      {
    19881999        /*
    1989          * We also need to find a storage for the other link, setup variables
     2000         * We also need to find a storage for the other link, setup variables 
    19902001         * to do this at the end...
    1991          */
     2002         */     
    19922003        needToFindAPlaceholder = TRUE;
    19932004        storeNode              = propertyToDelete.previousProperty;
     
    19952006        relationType           = PROPERTY_RELATION_NEXT;
    19962007      }
    1997     }
    1998     else if (propertyToDelete.nextProperty != PROPERTY_NULL)
    1999     {
    2000       /*
     2008    } 
     2009    else if (propertyToDelete.nextProperty != PROPERTY_NULL) 
     2010    {
     2011      /* 
    20012012       * Set the parent next to the property to delete next
    20022013       */
     
    20042015    }
    20052016
    2006     /*
     2017    /* 
    20072018     * Link it for real...
    2008      */
     2019     */ 
    20092020    parentProperty.nextProperty = newLinkProperty;
    2010   }
     2021  } 
    20112022  else /* (typeOfRelation == PROPERTY_RELATION_DIR) */
    20122023  {
    2013     if (propertyToDelete.previousProperty != PROPERTY_NULL)
    2014     {
    2015       /*
     2024    if (propertyToDelete.previousProperty != PROPERTY_NULL) 
     2025    {
     2026      /* 
    20162027       * Set the parent dir to the property to delete previous
    20172028       */
    20182029      newLinkProperty = propertyToDelete.previousProperty;
    20192030
    2020       if (propertyToDelete.nextProperty != PROPERTY_NULL)
     2031      if (propertyToDelete.nextProperty != PROPERTY_NULL) 
    20212032      {
    20222033        /*
    2023          * We also need to find a storage for the other link, setup variables
     2034         * We also need to find a storage for the other link, setup variables 
    20242035         * to do this at the end...
    2025          */
     2036         */     
    20262037        needToFindAPlaceholder = TRUE;
    20272038        storeNode              = propertyToDelete.previousProperty;
     
    20292040        relationType           = PROPERTY_RELATION_NEXT;
    20302041      }
    2031     }
    2032     else if (propertyToDelete.nextProperty != PROPERTY_NULL)
    2033     {
    2034       /*
     2042    } 
     2043    else if (propertyToDelete.nextProperty != PROPERTY_NULL) 
     2044    {
     2045      /* 
    20352046       * Set the parent dir to the property to delete next
    20362047       */
     
    20382049    }
    20392050
    2040     /*
     2051    /* 
    20412052     * Link it for real...
    2042      */
     2053     */ 
    20432054    parentProperty.dirProperty = newLinkProperty;
    20442055  }
    20452056
    2046   /*
    2047    * Write back the parent property
     2057  /* 
     2058   * Write back the parent property   
    20482059   */
    20492060  res = StorageImpl_WriteProperty(
    2050           This->ancestorStorage,
     2061          This->ancestorStorage, 
    20512062          parentPropertyId,
    20522063          &parentProperty);
     
    20572068
    20582069  /*
    2059    * If a placeholder is required for the other link, then, find one and
     2070   * If a placeholder is required for the other link, then, find one and 
    20602071   * get out of here...
    20612072   */
    2062   if (needToFindAPlaceholder)
     2073  if (needToFindAPlaceholder) 
    20632074  {
    20642075    hr = findPlaceholder(
    2065            This,
    2066            toStoreNode,
     2076           This, 
     2077           toStoreNode, 
    20672078           storeNode,
    20682079           relationType);
     
    20762087 * SetElementTimes (IStorage)
    20772088 */
    2078 HRESULT WINAPI StorageImpl_SetElementTimes(
     2089HRESULT WINAPI StorageImpl_SetElementTimes( 
    20792090  IStorage*     iface,
    2080   const OLECHAR *pwcsName,/* [string][in] */
    2081   const FILETIME  *pctime,  /* [in] */
    2082   const FILETIME  *patime,  /* [in] */
    2083   const FILETIME  *pmtime)  /* [in] */
     2091  const OLECHAR *pwcsName,/* [string][in] */ 
     2092  const FILETIME  *pctime,  /* [in] */ 
     2093  const FILETIME  *patime,  /* [in] */ 
     2094  const FILETIME  *pmtime)  /* [in] */ 
    20842095{
    20852096  FIXME("not implemented!\n");
     
    20902101 * SetStateBits (IStorage)
    20912102 */
    2092 HRESULT WINAPI StorageImpl_SetStateBits(
     2103HRESULT WINAPI StorageImpl_SetStateBits( 
    20932104  IStorage*   iface,
    2094   DWORD         grfStateBits,/* [in] */
    2095   DWORD         grfMask)     /* [in] */
     2105  DWORD         grfStateBits,/* [in] */ 
     2106  DWORD         grfMask)     /* [in] */ 
    20962107{
    20972108  FIXME("not implemented!\n");
     
    21112122  BOOL      readSuccessful;
    21122123  ULONG       currentPropertyIndex;
    2113 
     2124 
    21142125  if ( FAILED( validateSTGM(openFlags) ))
    21152126    return STG_E_INVALIDFLAG;
    21162127
    21172128  memset(This, 0, sizeof(StorageImpl));
    2118 
     2129 
    21192130  /*
    21202131   * Initialize the virtual fgunction table.
     
    21222133  ICOM_VTBL(This)    = &Storage32Impl_Vtbl;
    21232134  This->v_destructor = &StorageImpl_Destroy;
    2124 
     2135 
    21252136  /*
    21262137   * This is the top-level storage so initialize the ancester pointer
     
    21282139   */
    21292140  This->ancestorStorage = This;
    2130 
     2141 
    21312142  /*
    21322143   * Initialize the physical support of the storage.
    21332144   */
    21342145  This->hFile = hFile;
    2135 
     2146 
    21362147  /*
    21372148   * Initialize the big block cache.
     
    21472158  if (This->bigBlockFile == 0)
    21482159    return E_FAIL;
    2149 
     2160 
    21502161  if (fileCreate)
    21512162  {
     
    21592170     * - There is no small block depot
    21602171     */
    2161     memset( This->bigBlockDepotStart,
    2162             BLOCK_UNUSED,
     2172    memset( This->bigBlockDepotStart,     
     2173            BLOCK_UNUSED, 
    21632174            sizeof(This->bigBlockDepotStart));
    21642175
     
    22142225   */
    22152226  This->prevFreeBlock = 0;
    2216 
     2227 
    22172228  /*
    22182229   * Create the block chain abstractions.
    22192230   */
    2220   This->rootBlockChain =
     2231  This->rootBlockChain = 
    22212232    BlockChainStream_Construct(This, &This->rootStartBlock, PROPERTY_NULL);
    22222233
    22232234  This->smallBlockDepotChain = BlockChainStream_Construct(
    2224                                  This,
    2225                                  &This->smallBlockDepotStart,
     2235                                 This, 
     2236                                 &This->smallBlockDepotStart, 
    22262237                                 PROPERTY_NULL);
    22272238
    22282239  /*
    2229    * Write the root property
     2240   * Write the root property 
    22302241   */
    22312242  if (fileCreate)
     
    22542265   */
    22552266  currentPropertyIndex = 0;
    2256 
     2267 
    22572268  do
    22582269  {
    22592270    readSuccessful = StorageImpl_ReadProperty(
    2260                       This,
    2261                       currentPropertyIndex,
     2271                      This, 
     2272                      currentPropertyIndex, 
    22622273                      &currentProperty);
    2263 
     2274   
    22642275    if (readSuccessful)
    22652276    {
     
    22722283
    22732284    currentPropertyIndex++;
    2274 
     2285   
    22752286  } while (readSuccessful && (This->rootPropertySetIndex == PROPERTY_NULL) );
    2276 
     2287 
    22772288  if (!readSuccessful)
    22782289  {
     
    22852296   */
    22862297  This->smallBlockRootChain = BlockChainStream_Construct(
    2287                                 This,
    2288                                 NULL,
     2298                                This, 
     2299                                NULL, 
    22892300                                This->rootPropertySetIndex);
    2290 
     2301 
    22912302  return hr;
    22922303}
     
    28212832
    28222833    StorageUtl_ReadWord(
    2823       headerBigBlock,
    2824       OFFSET_BIGBLOCKSIZEBITS,
     2834      headerBigBlock, 
     2835      OFFSET_BIGBLOCKSIZEBITS,   
    28252836      &This->bigBlockSizeBits);
    28262837
    28272838    StorageUtl_ReadWord(
    2828       headerBigBlock,
    2829       OFFSET_SMALLBLOCKSIZEBITS,
     2839      headerBigBlock, 
     2840      OFFSET_SMALLBLOCKSIZEBITS, 
    28302841      &This->smallBlockSizeBits);
    28312842
    28322843    StorageUtl_ReadDWord(
    2833       headerBigBlock,
    2834       OFFSET_BBDEPOTCOUNT,
     2844      headerBigBlock, 
     2845      OFFSET_BBDEPOTCOUNT,     
    28352846      &This->bigBlockDepotCount);
    28362847
    28372848    StorageUtl_ReadDWord(
    2838       headerBigBlock,
    2839       OFFSET_ROOTSTARTBLOCK,
     2849      headerBigBlock, 
     2850      OFFSET_ROOTSTARTBLOCK,   
    28402851      &This->rootStartBlock);
    28412852
    28422853    StorageUtl_ReadDWord(
    2843       headerBigBlock,
    2844       OFFSET_SBDEPOTSTART,
     2854      headerBigBlock, 
     2855      OFFSET_SBDEPOTSTART,     
    28452856      &This->smallBlockDepotStart);
    28462857
     2858    StorageUtl_ReadDWord(
     2859      headerBigBlock,
     2860      OFFSET_EXTBBDEPOTSTART,   
     2861      &This->extBigBlockDepotStart);
     2862
    28472863    StorageUtl_ReadDWord(
    2848       headerBigBlock,
    2849       OFFSET_EXTBBDEPOTSTART,
    2850       &This->extBigBlockDepotStart);
    2851 
    2852     StorageUtl_ReadDWord(
    2853       headerBigBlock,
    2854       OFFSET_EXTBBDEPOTCOUNT,
     2864      headerBigBlock,
     2865      OFFSET_EXTBBDEPOTCOUNT,   
    28552866      &This->extBigBlockDepotCount);
    2856 
     2867   
    28572868    for (index = 0; index < COUNT_BBDEPOTINHEADER; index ++)
    28582869    {
    28592870      StorageUtl_ReadDWord(
    2860         headerBigBlock,
     2871        headerBigBlock, 
    28612872        OFFSET_BBDEPOTSTART + (sizeof(ULONG)*index),
    28622873        &(This->bigBlockDepotStart[index]));
    28632874    }
    2864 
     2875   
    28652876    /*
    28662877     * Make the bitwise arithmetic to get the size of the blocks in bytes.
     
    28762887      This->smallBlockSize = 0x000000001 >> (DWORD)This->smallBlockSizeBits;
    28772888    }
    2878 
    2879     /*
    2880      * Right now, the code is making some assumptions about the size of the
     2889   
     2890    /*
     2891     * Right now, the code is making some assumptions about the size of the 
    28812892     * blocks, just make sure they are what we're expecting.
    28822893     */
    2883     assert( (This->bigBlockSize==DEF_BIG_BLOCK_SIZE) &&
     2894    assert( (This->bigBlockSize==DEF_BIG_BLOCK_SIZE) && 
    28842895            (This->smallBlockSize==DEF_SMALL_BLOCK_SIZE));
    2885 
     2896   
    28862897    /*
    28872898     * Release the block.
     
    28912902    hr = S_OK;
    28922903  }
    2893 
     2904 
    28942905  return hr;
    28952906}
     
    29112922   */
    29122923  success = StorageImpl_ReadBigBlock(This, -1, headerBigBlock);
    2913 
     2924 
    29142925  /*
    29152926   * If the block read failed, the file is probably new.
     
    29212932     */
    29222933    memset(headerBigBlock, 0, BIG_BLOCK_SIZE);
    2923 
     2934   
    29242935    /*
    29252936     * Initialize the magic number.
    29262937     */
    29272938    memcpy(headerBigBlock, STORAGE_magic, sizeof(STORAGE_magic));
    2928 
     2939   
    29292940    /*
    29302941     * And a bunch of things we don't know what they mean
     
    29362947    StorageUtl_WriteDWord(headerBigBlock, 0x40, (DWORD)0x0001);
    29372948  }
    2938 
     2949 
    29392950  /*
    29402951   * Write the information to the header.
     
    29432954  {
    29442955    StorageUtl_WriteWord(
    2945       headerBigBlock,
    2946       OFFSET_BIGBLOCKSIZEBITS,
     2956      headerBigBlock, 
     2957      OFFSET_BIGBLOCKSIZEBITS,   
    29472958      This->bigBlockSizeBits);
    29482959
    29492960    StorageUtl_WriteWord(
    2950       headerBigBlock,
    2951       OFFSET_SMALLBLOCKSIZEBITS,
     2961      headerBigBlock, 
     2962      OFFSET_SMALLBLOCKSIZEBITS, 
    29522963      This->smallBlockSizeBits);
    29532964
    29542965    StorageUtl_WriteDWord(
    2955       headerBigBlock,
    2956       OFFSET_BBDEPOTCOUNT,
     2966      headerBigBlock, 
     2967      OFFSET_BBDEPOTCOUNT,     
    29572968      This->bigBlockDepotCount);
    29582969
    29592970    StorageUtl_WriteDWord(
    2960       headerBigBlock,
    2961       OFFSET_ROOTSTARTBLOCK,
     2971      headerBigBlock, 
     2972      OFFSET_ROOTSTARTBLOCK,   
    29622973      This->rootStartBlock);
    29632974
    29642975    StorageUtl_WriteDWord(
    2965       headerBigBlock,
    2966       OFFSET_SBDEPOTSTART,
     2976      headerBigBlock, 
     2977      OFFSET_SBDEPOTSTART,     
    29672978      This->smallBlockDepotStart);
    29682979
    29692980    StorageUtl_WriteDWord(
    2970       headerBigBlock,
    2971       OFFSET_EXTBBDEPOTSTART,
     2981      headerBigBlock, 
     2982      OFFSET_EXTBBDEPOTSTART,   
    29722983      This->extBigBlockDepotStart);
    29732984
    29742985    StorageUtl_WriteDWord(
    2975       headerBigBlock,
    2976       OFFSET_EXTBBDEPOTCOUNT,
     2986      headerBigBlock, 
     2987      OFFSET_EXTBBDEPOTCOUNT,   
    29772988      This->extBigBlockDepotCount);
    29782989
     
    29802991    {
    29812992      StorageUtl_WriteDWord(
    2982         headerBigBlock,
     2993        headerBigBlock, 
    29832994        OFFSET_BBDEPOTSTART + (sizeof(ULONG)*index),
    29842995        (This->bigBlockDepotStart[index]));
    29852996    }
    29862997  }
    2987 
     2998 
    29882999  /*
    29893000   * Write the big block back to the file.
     
    30093020  offsetInPropSet.s.HighPart = 0;
    30103021  offsetInPropSet.s.LowPart  = index * PROPSET_BLOCK_SIZE;
    3011 
     3022 
    30123023  readSuccessful = BlockChainStream_ReadAt(
    30133024                    This->rootBlockChain,
     
    30163027                    currentProperty,
    30173028                    &bytesRead);
    3018 
     3029 
    30193030  if (readSuccessful)
    30203031  {
    30213032    memset(buffer->name, 0, sizeof(buffer->name));
    30223033    memcpy(
    3023       buffer->name,
    3024       currentProperty+OFFSET_PS_NAME,
     3034      buffer->name, 
     3035      currentProperty+OFFSET_PS_NAME, 
    30253036      PROPERTY_NAME_BUFFER_LEN );
    30263037
    30273038    memcpy(&buffer->propertyType, currentProperty + OFFSET_PS_PROPERTYTYPE, 1);
    3028 
     3039   
    30293040    StorageUtl_ReadWord(
    3030       currentProperty,
    3031       OFFSET_PS_NAMELENGTH,
     3041      currentProperty, 
     3042      OFFSET_PS_NAMELENGTH, 
    30323043      &buffer->sizeOfNameString);
    30333044
    30343045    StorageUtl_ReadDWord(
    3035       currentProperty,
    3036       OFFSET_PS_PREVIOUSPROP,
     3046      currentProperty, 
     3047      OFFSET_PS_PREVIOUSPROP, 
    30373048      &buffer->previousProperty);
    30383049
    30393050    StorageUtl_ReadDWord(
    3040       currentProperty,
    3041       OFFSET_PS_NEXTPROP,
     3051      currentProperty, 
     3052      OFFSET_PS_NEXTPROP,     
    30423053      &buffer->nextProperty);
    30433054
    30443055    StorageUtl_ReadDWord(
    3045       currentProperty,
    3046       OFFSET_PS_DIRPROP,
     3056      currentProperty, 
     3057      OFFSET_PS_DIRPROP,     
    30473058      &buffer->dirProperty);
    30483059
    30493060    StorageUtl_ReadGUID(
    3050       currentProperty,
    3051       OFFSET_PS_GUID,
     3061      currentProperty, 
     3062      OFFSET_PS_GUID,       
    30523063      &buffer->propertyUniqueID);
    30533064
    30543065    StorageUtl_ReadDWord(
    3055       currentProperty,
    3056       OFFSET_PS_TSS1,
     3066      currentProperty, 
     3067      OFFSET_PS_TSS1,         
    30573068      &buffer->timeStampS1);
    30583069
    30593070    StorageUtl_ReadDWord(
    3060       currentProperty,
    3061       OFFSET_PS_TSD1,
     3071      currentProperty, 
     3072      OFFSET_PS_TSD1,         
    30623073      &buffer->timeStampD1);
    30633074
    30643075    StorageUtl_ReadDWord(
    3065       currentProperty,
    3066       OFFSET_PS_TSS2,
     3076      currentProperty, 
     3077      OFFSET_PS_TSS2,         
    30673078      &buffer->timeStampS2);
    30683079
    30693080    StorageUtl_ReadDWord(
    3070       currentProperty,
    3071       OFFSET_PS_TSD2,
     3081      currentProperty, 
     3082      OFFSET_PS_TSD2,         
    30723083      &buffer->timeStampD2);
    30733084
    30743085    StorageUtl_ReadDWord(
    3075       currentProperty,
    3076       OFFSET_PS_STARTBLOCK,
     3086      currentProperty, 
     3087      OFFSET_PS_STARTBLOCK,   
    30773088      &buffer->startingBlock);
    30783089
    30793090    StorageUtl_ReadDWord(
    3080       currentProperty,
    3081       OFFSET_PS_SIZE,
     3091      currentProperty, 
     3092      OFFSET_PS_SIZE,         
    30823093      &buffer->size.s.LowPart);
    30833094
     
    31073118
    31083119  memcpy(
    3109     currentProperty + OFFSET_PS_NAME,
    3110     buffer->name,
     3120    currentProperty + OFFSET_PS_NAME, 
     3121    buffer->name, 
    31113122    PROPERTY_NAME_BUFFER_LEN );
    31123123
     
    31143125
    31153126  StorageUtl_WriteWord(
    3116     currentProperty,
    3117       OFFSET_PS_NAMELENGTH,
     3127    currentProperty, 
     3128      OFFSET_PS_NAMELENGTH,   
    31183129      buffer->sizeOfNameString);
    31193130
    31203131  StorageUtl_WriteDWord(
    3121     currentProperty,
    3122       OFFSET_PS_PREVIOUSPROP,
     3132    currentProperty, 
     3133      OFFSET_PS_PREVIOUSPROP, 
    31233134      buffer->previousProperty);
    31243135
    31253136  StorageUtl_WriteDWord(
    3126     currentProperty,
    3127       OFFSET_PS_NEXTPROP,
     3137    currentProperty, 
     3138      OFFSET_PS_NEXTPROP,     
    31283139      buffer->nextProperty);
    31293140
    31303141  StorageUtl_WriteDWord(
    3131     currentProperty,
    3132       OFFSET_PS_DIRPROP,
     3142    currentProperty, 
     3143      OFFSET_PS_DIRPROP,     
    31333144      buffer->dirProperty);
    31343145
    31353146  StorageUtl_WriteGUID(
    3136     currentProperty,
    3137       OFFSET_PS_GUID,
     3147    currentProperty, 
     3148      OFFSET_PS_GUID,       
    31383149      &buffer->propertyUniqueID);
    31393150
    31403151  StorageUtl_WriteDWord(
    3141     currentProperty,
    3142       OFFSET_PS_TSS1,
     3152    currentProperty, 
     3153      OFFSET_PS_TSS1,         
    31433154      buffer->timeStampS1);
    31443155
    31453156  StorageUtl_WriteDWord(
    3146     currentProperty,
    3147       OFFSET_PS_TSD1,
     3157    currentProperty, 
     3158      OFFSET_PS_TSD1,         
    31483159      buffer->timeStampD1);
    31493160
    31503161  StorageUtl_WriteDWord(
    3151     currentProperty,
    3152       OFFSET_PS_TSS2,
     3162    currentProperty, 
     3163      OFFSET_PS_TSS2,         
    31533164      buffer->timeStampS2);
    31543165
    31553166  StorageUtl_WriteDWord(
    3156     currentProperty,
    3157       OFFSET_PS_TSD2,
     3167    currentProperty, 
     3168      OFFSET_PS_TSD2,         
    31583169      buffer->timeStampD2);
    31593170
    31603171  StorageUtl_WriteDWord(
    3161     currentProperty,
    3162       OFFSET_PS_STARTBLOCK,
     3172    currentProperty, 
     3173      OFFSET_PS_STARTBLOCK,   
    31633174      buffer->startingBlock);
    31643175
    31653176  StorageUtl_WriteDWord(
    3166     currentProperty,
    3167       OFFSET_PS_SIZE,
     3177    currentProperty, 
     3178      OFFSET_PS_SIZE,         
    31683179      buffer->size.s.LowPart);
    31693180
     
    32113222
    32123223    StorageImpl_ReleaseBigBlock(This, bigBlockBuffer);
    3213 
     3224   
    32143225    return TRUE;
    32153226  }
    3216 
     3227 
    32173228  return FALSE;
    32183229}
     
    33443355
    33453356StorageInternalImpl* StorageInternalImpl_Construct(
    3346   StorageImpl* ancestorStorage,
     3357  StorageImpl* ancestorStorage, 
    33473358  ULONG          rootPropertyIndex)
    33483359{
     
    33953406** does nothing.
    33963407*/
    3397 HRESULT WINAPI StorageInternalImpl_Commit(
     3408HRESULT WINAPI StorageInternalImpl_Commit( 
    33983409  IStorage*            iface,
    3399   DWORD                  grfCommitFlags)  /* [in] */
     3410  DWORD                  grfCommitFlags)  /* [in] */ 
    34003411{
    34013412  return S_OK;
    34023413}
    3403 
     3414       
    34043415/******************************************************************************
    34053416**
     
    34093420** does nothing.
    34103421*/
    3411 HRESULT WINAPI StorageInternalImpl_Revert(
     3422HRESULT WINAPI StorageInternalImpl_Revert( 
    34123423  IStorage*            iface)
    34133424{
     
    34263437
    34273438  newEnumeration = HeapAlloc(GetProcessHeap(), 0, sizeof(IEnumSTATSTGImpl));
    3428 
     3439 
    34293440  if (newEnumeration!=0)
    34303441  {
     
    34343445    ICOM_VTBL(newEnumeration) = &IEnumSTATSTGImpl_Vtbl;
    34353446    newEnumeration->ref       = 0;
    3436 
     3447   
    34373448    /*
    34383449     * We want to nail-down the reference to the storage in case the
     
    34413452    newEnumeration->parentStorage = parentStorage;
    34423453    IStorage_AddRef((IStorage*)newEnumeration->parentStorage);
    3443 
     3454   
    34443455    newEnumeration->firstPropertyNode   = firstPropertyNode;
    3445 
     3456   
    34463457    /*
    34473458     * Initialize the search stack
     
    34493460    newEnumeration->stackSize    = 0;
    34503461    newEnumeration->stackMaxSize = ENUMSTATSGT_SIZE_INCREMENT;
    3451     newEnumeration->stackToVisit =
     3462    newEnumeration->stackToVisit = 
    34523463      HeapAlloc(GetProcessHeap(), 0, sizeof(ULONG)*ENUMSTATSGT_SIZE_INCREMENT);
    3453 
     3464   
    34543465    /*
    34553466     * Make sure the current node of the iterator is the first one.
     
    34573468    IEnumSTATSTGImpl_Reset((IEnumSTATSTG*)newEnumeration);
    34583469  }
    3459 
     3470 
    34603471  return newEnumeration;
    34613472}
     
    34893500   * Compare the riid with the interface IDs implemented by this object.
    34903501   */
    3491   if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0)
     3502  if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0) 
    34923503  {
    34933504    *ppvObject = (IEnumSTATSTG*)This;
    34943505  }
    3495   else if (memcmp(&IID_IStorage, riid, sizeof(IID_IEnumSTATSTG)) == 0)
     3506  else if (memcmp(&IID_IStorage, riid, sizeof(IID_IEnumSTATSTG)) == 0) 
    34963507  {
    34973508    *ppvObject = (IEnumSTATSTG*)This;
     
    35123523  return S_OK;
    35133524}
    3514 
     3525       
    35153526ULONG   WINAPI IEnumSTATSTGImpl_AddRef(
    35163527  IEnumSTATSTG* iface)
     
    35213532  return This->ref;
    35223533}
    3523 
     3534       
    35243535ULONG   WINAPI IEnumSTATSTGImpl_Release(
    35253536  IEnumSTATSTG* iface)
     
    35603571   */
    35613572  if ( (rgelt==0) || ( (celt!=1) && (pceltFetched==0) ) )
    3562     return E_INVALIDARG;
    3563 
     3573    return E_INVALIDARG; 
     3574 
    35643575  /*
    35653576   * To avoid the special case, get another pointer to a ULONG value if
     
    35683579  if (pceltFetched==0)
    35693580    pceltFetched = &objectFetched;
    3570 
     3581 
    35713582  /*
    35723583   * Start the iteration, we will iterate until we hit the end of the
     
    35803591  currentSearchNode = IEnumSTATSTGImpl_PopSearchNode(This, FALSE);
    35813592
    3582   while ( ( *pceltFetched < celt) &&
     3593  while ( ( *pceltFetched < celt) && 
    35833594          ( currentSearchNode!=PROPERTY_NULL) )
    35843595  {
    3585     /*
     3596    /* 
    35863597     * Remove the top node from the stack
    35873598     */
     
    35923603     */
    35933604    StorageImpl_ReadProperty(This->parentStorage,
    3594       currentSearchNode,
     3605      currentSearchNode, 
    35953606      &currentProperty);
    35963607
     
    36013612      &currentProperty,
    36023613      STATFLAG_DEFAULT);
    3603 
     3614       
    36043615    /*
    36053616     * Step to the next item in the iteration
     
    36253636}
    36263637
    3627 
     3638       
    36283639HRESULT WINAPI IEnumSTATSTGImpl_Skip(
    36293640  IEnumSTATSTG* iface,
     
    36413652  currentSearchNode = IEnumSTATSTGImpl_PopSearchNode(This, FALSE);
    36423653
    3643   while ( (objectFetched < celt) &&
     3654  while ( (objectFetched < celt) && 
    36443655          (currentSearchNode!=PROPERTY_NULL) )
    36453656  {
    3646     /*
     3657    /* 
    36473658     * Remove the top node from the stack
    36483659     */
     
    36533664     */
    36543665    StorageImpl_ReadProperty(This->parentStorage,
    3655       currentSearchNode,
     3666      currentSearchNode, 
    36563667      &currentProperty);
    3657 
     3668   
    36583669    /*
    36593670     * Step to the next item in the iteration
     
    36773688  return S_FALSE;
    36783689}
    3679 
     3690       
    36803691HRESULT WINAPI IEnumSTATSTGImpl_Reset(
    36813692  IEnumSTATSTG* iface)
     
    36963707  readSuccessful = StorageImpl_ReadProperty(
    36973708                    This->parentStorage,
    3698                     This->firstPropertyNode,
     3709                    This->firstPropertyNode, 
    36993710                    &rootProperty);
    37003711
     
    37113722  return S_OK;
    37123723}
    3713 
     3724       
    37143725HRESULT WINAPI IEnumSTATSTGImpl_Clone(
    37153726  IEnumSTATSTG* iface,
     
    37253736  if (ppenum==0)
    37263737    return E_INVALIDARG;
    3727 
     3738 
    37283739  newClone = IEnumSTATSTGImpl_Construct(This->parentStorage,
    37293740               This->firstPropertyNode);
    37303741
    3731 
     3742 
    37323743  /*
    37333744   * The new clone enumeration must point to the same current node as
     
    37363747  newClone->stackSize    = This->stackSize    ;
    37373748  newClone->stackMaxSize = This->stackMaxSize ;
    3738   newClone->stackToVisit =
     3749  newClone->stackToVisit = 
    37393750    HeapAlloc(GetProcessHeap(), 0, sizeof(ULONG) * newClone->stackMaxSize);
    37403751
    37413752  memcpy(
    3742     newClone->stackToVisit,
    3743     This->stackToVisit,
     3753    newClone->stackToVisit, 
     3754    This->stackToVisit, 
    37443755    sizeof(ULONG) * newClone->stackSize);
    37453756
     
    37573768INT IEnumSTATSTGImpl_FindParentProperty(
    37583769  IEnumSTATSTGImpl *This,
    3759   ULONG             childProperty,
     3770  ULONG             childProperty, 
    37603771  StgProperty      *currentProperty,
    37613772  ULONG            *thisNodeId)
     
    37753786   */
    37763787  currentSearchNode = IEnumSTATSTGImpl_PopSearchNode(This, FALSE);
    3777 
     3788 
    37783789
    37793790  while (currentSearchNode!=PROPERTY_NULL)
     
    37843795    *thisNodeId = currentSearchNode;
    37853796
    3786     /*
     3797    /* 
    37873798     * Remove the top node from the stack
    37883799     */
     
    37943805    StorageImpl_ReadProperty(
    37953806      This->parentStorage,
    3796       currentSearchNode,
     3807      currentSearchNode, 
    37973808      currentProperty);
    3798 
     3809     
    37993810    if (currentProperty->previousProperty == childProperty)
    38003811      return PROPERTY_RELATION_PREVIOUS;
    38013812
    3802     else if (currentProperty->nextProperty == childProperty)
     3813    else if (currentProperty->nextProperty == childProperty) 
    38033814      return PROPERTY_RELATION_NEXT;
    3804 
     3815 
    38053816    else if (currentProperty->dirProperty == childProperty)
    38063817      return PROPERTY_RELATION_DIR;
    3807 
     3818       
    38083819    /*
    38093820     * Push the next search node in the search stack.
     
    38343845  while (currentSearchNode!=PROPERTY_NULL)
    38353846  {
    3836     /*
     3847    /* 
    38373848     * Remove the top node from the stack
    38383849     */
     
    38433854     */
    38443855    StorageImpl_ReadProperty(This->parentStorage,
    3845       currentSearchNode,
     3856      currentSearchNode, 
    38463857      currentProperty);
    38473858
    38483859    if ( propertyNameCmp(
    3849           (OLECHAR*)currentProperty->name,
     3860          (OLECHAR*)currentProperty->name, 
    38503861          (OLECHAR*)lpszPropName) == 0)
    38513862      return currentSearchNode;
     
    38863897
    38873898    This->stackToVisit = HeapReAlloc(
    3888                            GetProcessHeap(),
     3899                           GetProcessHeap(), 
    38893900                           0,
    38903901                           This->stackToVisit,
     
    39003911  readSuccessful = StorageImpl_ReadProperty(
    39013912                    This->parentStorage,
    3902                     nodeToPush,
     3913                    nodeToPush, 
    39033914                    &rootProperty);
    39043915
     
    39873998  else
    39883999  {
    3989     destination->pwcsName =
     4000    destination->pwcsName = 
    39904001      CoTaskMemAlloc((lstrlenW(source->name)+1)*sizeof(WCHAR));
    39914002
    39924003    strcpyW((LPWSTR)destination->pwcsName, source->name);
    39934004  }
    3994 
     4005 
    39954006  switch (source->propertyType)
    39964007  {
     
    40044015    default:
    40054016      destination->type = STGTY_STREAM;
    4006       break;
     4017      break;       
    40074018  }
    40084019
    40094020  destination->cbSize            = source->size;
    4010 /*
     4021/*   
    40114022  currentReturnStruct->mtime     = {0}; TODO
    40124023  currentReturnStruct->ctime     = {0};
    4013   currentReturnStruct->atime     = {0};
     4024  currentReturnStruct->atime     = {0}; 
    40144025*/
    40154026  destination->grfMode           = 0;
    4016   destination->grfLocksSupported = 0;
     4027  destination->grfLocksSupported = 0; 
    40174028  destination->clsid             = source->propertyUniqueID;
    4018   destination->grfStateBits      = 0;
    4019   destination->reserved          = 0;
     4029  destination->grfStateBits      = 0; 
     4030  destination->reserved          = 0; 
    40204031}
    40214032
     
    40254036
    40264037BlockChainStream* BlockChainStream_Construct(
    4027   StorageImpl* parentStorage,
     4038  StorageImpl* parentStorage, 
    40284039  ULONG*         headOfStreamPlaceHolder,
    40294040  ULONG          propertyIndex)
     
    40984109 * Returns the number of blocks that comprises this chain.
    40994110 * This is not the size of the stream as the last block may not be full!
    4100  *
     4111 * 
    41014112 */
    41024113ULONG BlockChainStream_GetCount(BlockChainStream* This)
     
    41124123
    41134124    blockIndex = StorageImpl_GetNextBlockInChain(
    4114                    This->parentStorage,
     4125                   This->parentStorage, 
    41154126                   blockIndex);
    41164127  }
     
    41204131
    41214132/******************************************************************************
    4122  *      BlockChainStream_ReadAt
     4133 *      BlockChainStream_ReadAt 
    41234134 *
    41244135 * Reads a specified number of bytes from this chain at the specified offset.
     
    41604171  while ( (blockNoInSequence > 0) &&  (blockIndex != BLOCK_END_OF_CHAIN))
    41614172  {
    4162     blockIndex =
     4173    blockIndex = 
    41634174      StorageImpl_GetNextBlockInChain(This->parentStorage, blockIndex);
    4164 
     4175   
    41654176    blockNoInSequence--;
    41664177  }
     
    41734184  *bytesRead   = 0;
    41744185  bufferWalker = buffer;
    4175 
     4186 
    41764187  while ( (size > 0) && (blockIndex != BLOCK_END_OF_CHAIN) )
    41774188  {
     
    41794190     * Calculate how many bytes we can copy from this big block.
    41804191     */
    4181     bytesToReadInBuffer =
     4192    bytesToReadInBuffer = 
    41824193      min(This->parentStorage->bigBlockSize - offsetInBlock, size);
    4183 
     4194   
    41844195    /*
    41854196     * Copy those bytes to the buffer
    41864197     */
    4187     bigBlockBuffer =
     4198    bigBlockBuffer = 
    41884199      StorageImpl_GetROBigBlock(This->parentStorage, blockIndex);
    4189 
     4200   
    41904201    memcpy(bufferWalker, bigBlockBuffer + offsetInBlock, bytesToReadInBuffer);
    4191 
     4202   
    41924203    StorageImpl_ReleaseBigBlock(This->parentStorage, bigBlockBuffer);
    4193 
     4204   
    41944205    /*
    41954206     * Step to the next big block.
    41964207     */
    4197     blockIndex    =
     4208    blockIndex    = 
    41984209      StorageImpl_GetNextBlockInChain(This->parentStorage, blockIndex);
    41994210
     
    42044215
    42054216  }
    4206 
     4217 
    42074218  return (size == 0);
    42084219}
     
    42494260  while ( (blockNoInSequence > 0) &&  (blockIndex != BLOCK_END_OF_CHAIN))
    42504261  {
    4251     blockIndex =
     4262    blockIndex = 
    42524263      StorageImpl_GetNextBlockInChain(This->parentStorage, blockIndex);
    4253 
     4264   
    42544265    blockNoInSequence--;
    42554266  }
     
    42694280     * Calculate how many bytes we can copy from this big block.
    42704281     */
    4271     bytesToWrite =
     4282    bytesToWrite = 
    42724283      min(This->parentStorage->bigBlockSize - offsetInBlock, size);
    4273 
     4284   
    42744285    /*
    42754286     * Copy those bytes to the buffer
    42764287     */
    42774288    bigBlockBuffer = StorageImpl_GetBigBlock(This->parentStorage, blockIndex);
    4278 
     4289   
    42794290    memcpy(bigBlockBuffer + offsetInBlock, bufferWalker, bytesToWrite);
    4280 
     4291   
    42814292    StorageImpl_ReleaseBigBlock(This->parentStorage, bigBlockBuffer);
    4282 
     4293   
    42834294    /*
    42844295     * Step to the next big block.
    42854296     */
    4286     blockIndex    =
     4297    blockIndex    = 
    42874298      StorageImpl_GetNextBlockInChain(This->parentStorage, blockIndex);
    42884299
     
    42924303    offsetInBlock  = 0;      /* There is no offset on the next block */
    42934304  }
    4294 
     4305 
    42954306  return (size == 0);
    42964307}
     
    43294340  while (count < numBlocks)
    43304341  {
    4331     blockIndex =
     4342    blockIndex = 
    43324343      StorageImpl_GetNextBlockInChain(This->parentStorage, blockIndex);
    43334344
     
    43364347
    43374348  /* Get the next block before marking the new end */
    4338   extraBlock =
     4349  extraBlock = 
    43394350    StorageImpl_GetNextBlockInChain(This->parentStorage, blockIndex);
    43404351
    43414352  /* Mark the new end of chain */
    43424353  StorageImpl_SetNextBlockInChain(
    4343     This->parentStorage,
    4344     blockIndex,
     4354    This->parentStorage, 
     4355    blockIndex, 
    43454356    BLOCK_END_OF_CHAIN);
    43464357
     
    43534364  while (extraBlock != BLOCK_END_OF_CHAIN)
    43544365  {
    4355     blockIndex =
     4366    blockIndex = 
    43564367      StorageImpl_GetNextBlockInChain(This->parentStorage, extraBlock);
    43574368
     
    43974408
    43984409      StorageImpl_ReadProperty(
    4399         This->parentStorage,
     4410        This->parentStorage, 
    44004411        This->ownerPropertyIndex,
    44014412        &chainProp);
    44024413
    4403       chainProp.startingBlock = blockIndex;
     4414      chainProp.startingBlock = blockIndex; 
    44044415
    44054416      StorageImpl_WriteProperty(
    4406         This->parentStorage,
     4417        This->parentStorage, 
    44074418        This->ownerPropertyIndex,
    44084419        &chainProp);
     
    44534464
    44544465      StorageImpl_SetNextBlockInChain(
    4455     This->parentStorage,
    4456     currentBlock,
    4457     blockIndex);
     4466        This->parentStorage,
     4467        currentBlock,
     4468        blockIndex);
    44584469
    44594470      StorageImpl_SetNextBlockInChain(
    4460         This->parentStorage,
    4461     blockIndex,
    4462     BLOCK_END_OF_CHAIN);
     4471        This->parentStorage, 
     4472        blockIndex,
     4473        BLOCK_END_OF_CHAIN);
    44634474
    44644475      currentBlock = blockIndex;
     
    44814492 * TODO: Free the actual blocks in the file when we shrink the chain.
    44824493 *       Currently, the blocks are still in the file. So the file size
    4483  *       doesn't shrink even if we shrink streams.
     4494 *       doesn't shrink even if we shrink streams. 
    44844495 */
    44854496BOOL BlockChainStream_SetSize(
     
    44984509  else
    44994510  {
    4500     ULARGE_INTEGER fileSize =
     4511    ULARGE_INTEGER fileSize = 
    45014512      BIGBLOCKFILE_GetSize(This->parentStorage->bigBlockFile);
    45024513
     
    45074518     */
    45084519    if ((diff % This->parentStorage->bigBlockSize) != 0)
    4509       diff += (This->parentStorage->bigBlockSize -
     4520      diff += (This->parentStorage->bigBlockSize - 
    45104521                (diff % This->parentStorage->bigBlockSize) );
    45114522
     
    45314542  if(This->headOfStreamPlaceHolder == NULL)
    45324543  {
    4533     /*
    4534      * This chain is a data stream read the property and return
     4544    /* 
     4545     * This chain is a data stream read the property and return 
    45354546     * the appropriate size
    45364547     */
     
    45454556  {
    45464557    /*
    4547      * this chain is a chain that does not have a property, figure out the
    4548      * size by making the product number of used blocks times the
     4558     * this chain is a chain that does not have a property, figure out the 
     4559     * size by making the product number of used blocks times the 
    45494560     * size of them
    45504561     */
     
    45524563    result.s.HighPart = 0;
    45534564
    4554     result.s.LowPart  =
    4555       BlockChainStream_GetCount(This) *
     4565    result.s.LowPart  = 
     4566      BlockChainStream_GetCount(This) * 
    45564567      This->parentStorage->bigBlockSize;
    45574568
     
    45654576
    45664577SmallBlockChainStream* SmallBlockChainStream_Construct(
    4567   StorageImpl* parentStorage,
     4578  StorageImpl* parentStorage, 
    45684579  ULONG          propertyIndex)
    45694580{
     
    46164627 *
    46174628 * Returns the index of the next small block in this chain.
    4618  *
     4629 * 
    46194630 * Return Values:
    46204631 *    - BLOCK_END_OF_CHAIN: end of this chain
     
    47434754    else
    47444755    {
    4745       ULONG count =
     4756      ULONG count = 
    47464757        BlockChainStream_GetCount(This->parentStorage->smallBlockDepotChain);
    47474758
     
    47544765      {
    47554766        sbdIndex = nextBlock;
    4756         nextBlock =
     4767        nextBlock = 
    47574768          StorageImpl_GetNextBlockInChain(This->parentStorage, sbdIndex);
    47584769      }
     
    47614772      if (sbdIndex != BLOCK_END_OF_CHAIN)
    47624773        StorageImpl_SetNextBlockInChain(
    4763           This->parentStorage,
    4764           sbdIndex,
     4774          This->parentStorage, 
     4775          sbdIndex, 
    47654776          newsbdIndex);
    47664777
    47674778      StorageImpl_SetNextBlockInChain(
    4768         This->parentStorage,
    4769         newsbdIndex,
     4779        This->parentStorage, 
     4780        newsbdIndex, 
    47704781        BLOCK_END_OF_CHAIN);
    47714782
     
    47734784       * Initialize all the small blocks to free
    47744785       */
    4775       smallBlockDepot =
     4786      smallBlockDepot = 
    47764787        StorageImpl_GetBigBlock(This->parentStorage, newsbdIndex);
    47774788
     
    47854796         */
    47864797        StgProperty rootProp;
    4787         ULONG sbStartIndex;
     4798        ULONG sbStartIndex; 
    47884799
    47894800        /*
     
    47944805
    47954806        /*
    4796          * And allocate the first big block that will contain small blocks
     4807         * And allocate the first big block that will contain small blocks 
    47974808         */
    4798         sbStartIndex =
     4809        sbStartIndex = 
    47994810          StorageImpl_GetNextFreeBigBlock(This->parentStorage);
    48004811
    48014812        StorageImpl_SetNextBlockInChain(
    4802           This->parentStorage,
    4803           sbStartIndex,
     4813          This->parentStorage, 
     4814          sbStartIndex, 
    48044815          BLOCK_END_OF_CHAIN);
    48054816
    48064817        StorageImpl_ReadProperty(
    4807           This->parentStorage,
    4808           This->parentStorage->rootPropertySetIndex,
     4818          This->parentStorage, 
     4819          This->parentStorage->rootPropertySetIndex, 
    48094820          &rootProp);
    48104821
     
    48144825
    48154826        StorageImpl_WriteProperty(
    4816           This->parentStorage,
    4817           This->parentStorage->rootPropertySetIndex,
     4827          This->parentStorage, 
     4828          This->parentStorage->rootPropertySetIndex, 
    48184829          &rootProp);
    48194830      }
     
    48214832  }
    48224833
    4823   smallBlocksPerBigBlock =
     4834  smallBlocksPerBigBlock = 
    48244835    This->parentStorage->bigBlockSize / This->parentStorage->smallBlockSize;
    48254836
     
    48334844
    48344845    StorageImpl_ReadProperty(
    4835       This->parentStorage,
    4836       This->parentStorage->rootPropertySetIndex,
     4846      This->parentStorage, 
     4847      This->parentStorage->rootPropertySetIndex, 
    48374848      &rootProp);
    48384849
    4839     if (rootProp.size.s.LowPart <
     4850    if (rootProp.size.s.LowPart < 
    48404851       (blocksRequired * This->parentStorage->bigBlockSize))
    48414852    {
     
    48434854
    48444855      BlockChainStream_SetSize(
    4845         This->parentStorage->smallBlockRootChain,
     4856        This->parentStorage->smallBlockRootChain, 
    48464857        rootProp.size);
    48474858
    48484859      StorageImpl_WriteProperty(
    4849         This->parentStorage,
    4850         This->parentStorage->rootPropertySetIndex,
     4860        This->parentStorage, 
     4861        This->parentStorage->rootPropertySetIndex, 
    48514862        &rootProp);
    48524863    }
     
    48614872 * Reads a specified number of bytes from this chain at the specified offset.
    48624873 * bytesRead may be NULL.
    4863  * Failure will be returned if the specified number of bytes has not been read.
     4874 * Failure will be returned if the specified number of bytes has not been read. 
    48644875 */
    48654876BOOL SmallBlockChainStream_ReadAt(
     
    48714882{
    48724883  ULARGE_INTEGER offsetInBigBlockFile;
    4873   ULONG blockNoInSequence =
     4884  ULONG blockNoInSequence = 
    48744885    offset.s.LowPart / This->parentStorage->smallBlockSize;
    48754886
     
    49084919     * Calculate how many bytes we can copy from this small block.
    49094920     */
    4910     bytesToReadInBuffer =
     4921    bytesToReadInBuffer = 
    49114922      min(This->parentStorage->smallBlockSize - offsetInBlock, size);
    49124923
     
    49154926     */
    49164927    offsetInBigBlockFile.s.HighPart  = 0;
    4917     offsetInBigBlockFile.s.LowPart   =
     4928    offsetInBigBlockFile.s.LowPart   = 
    49184929      blockIndex * This->parentStorage->smallBlockSize;
    49194930
     
    49594970{
    49604971  ULARGE_INTEGER offsetInBigBlockFile;
    4961   ULONG blockNoInSequence =
     4972  ULONG blockNoInSequence = 
    49624973    offset.s.LowPart / This->parentStorage->smallBlockSize;
    49634974
     
    49674978  ULONG bytesWrittenFromBigBlockFile;
    49684979  BYTE* bufferWalker;
    4969 
     4980 
    49704981  /*
    49714982   * This should never happen on a small block file.
    49724983   */
    49734984  assert(offset.s.HighPart==0);
    4974 
     4985 
    49754986  /*
    49764987   * Find the first block in the stream that contains part of the buffer.
    49774988   */
    49784989  blockIndex = SmallBlockChainStream_GetHeadOfChain(This);
    4979 
     4990 
    49804991  while ( (blockNoInSequence > 0) &&  (blockIndex != BLOCK_END_OF_CHAIN))
    49814992  {
    49824993    blockIndex = SmallBlockChainStream_GetNextBlockInChain(This, blockIndex);
    4983 
     4994   
    49844995    blockNoInSequence--;
    49854996  }
    4986 
     4997 
    49874998  /*
    49884999   * Start writing the buffer.
     
    49985009     * Calculate how many bytes we can copy to this small block.
    49995010     */
    5000     bytesToWriteInBuffer =
     5011    bytesToWriteInBuffer = 
    50015012      min(This->parentStorage->smallBlockSize - offsetInBlock, size);
    5002 
     5013   
    50035014    /*
    50045015     * Calculate the offset of the small block in the small block file.
    50055016     */
    50065017    offsetInBigBlockFile.s.HighPart  = 0;
    5007     offsetInBigBlockFile.s.LowPart   =
     5018    offsetInBigBlockFile.s.LowPart   = 
    50085019      blockIndex * This->parentStorage->smallBlockSize;
    50095020
    50105021    offsetInBigBlockFile.s.LowPart  += offsetInBlock;
    5011 
     5022   
    50125023    /*
    50135024     * Write those bytes in the buffer to the small block file.
     
    50185029      bufferWalker,
    50195030      &bytesWrittenFromBigBlockFile);
    5020 
     5031   
    50215032    assert(bytesWrittenFromBigBlockFile == bytesToWriteInBuffer);
    5022 
     5033   
    50235034    /*
    50245035     * Step to the next big block.
     
    50305041    offsetInBlock  = 0;     /* There is no offset on the next block */
    50315042  }
    5032 
     5043 
    50335044  return (size == 0);
    50345045}
     
    50375048 *       SmallBlockChainStream_Shrink
    50385049 *
    5039  * Shrinks this chain in the small block depot.
     5050 * Shrinks this chain in the small block depot. 
    50405051 */
    50415052BOOL SmallBlockChainStream_Shrink(
     
    50655076  /*
    50665077   * If the count is 0, we have a special case, the head of the chain was
    5067    * just freed.
     5078   * just freed. 
    50685079   */
    50695080  if (count == 0)
     
    50715082    StgProperty chainProp;
    50725083
    5073     StorageImpl_ReadProperty(This->parentStorage,
    5074                  This->ownerPropertyIndex,
    5075                  &chainProp);
     5084    StorageImpl_ReadProperty(This->parentStorage, 
     5085                             This->ownerPropertyIndex,
     5086                             &chainProp);
    50765087
    50775088    chainProp.startingBlock = BLOCK_END_OF_CHAIN;
    50785089
    50795090    StorageImpl_WriteProperty(This->parentStorage,
    5080                   This->ownerPropertyIndex,
    5081                   &chainProp);
     5091                              This->ownerPropertyIndex,
     5092                              &chainProp);
    50825093
    50835094    /*
     
    50935104    /* Mark the new end of chain */
    50945105    SmallBlockChainStream_SetNextBlockInChain(
    5095       This,
    5096       blockIndex,
     5106      This, 
     5107      blockIndex, 
    50975108      BLOCK_END_OF_CHAIN);
    50985109  }
     
    51085119  }
    51095120
    5110   return TRUE;
     5121  return TRUE; 
    51115122}
    51125123
     
    51445155    blockIndex = chainProp.startingBlock;
    51455156    SmallBlockChainStream_SetNextBlockInChain(
    5146       This,
    5147       blockIndex,
     5157      This, 
     5158      blockIndex, 
    51485159      BLOCK_END_OF_CHAIN);
    51495160  }
     
    51785189
    51795190    SmallBlockChainStream_SetNextBlockInChain(
    5180       This,
    5181       blockIndex,
     5191      This, 
     5192      blockIndex, 
    51825193      BLOCK_END_OF_CHAIN);
    51835194
     
    52205231 * TODO: Free the actual blocks in the file when we shrink the chain.
    52215232 *       Currently, the blocks are still in the file. So the file size
    5222  *       doesn't shrink even if we shrink streams.
     5233 *       doesn't shrink even if we shrink streams. 
    52235234 */
    52245235BOOL SmallBlockChainStream_SetSize(
     
    52785289  WCHAR          tempFileName[MAX_PATH];
    52795290
    5280   TRACE("(%s, %lx, %ld, %p)\n",
    5281     debugstr_w(pwcsName), grfMode,
    5282     reserved, ppstgOpen);
     5291  TRACE("(%s, %lx, %ld, %p)\n", 
     5292        debugstr_w(pwcsName), grfMode,
     5293        reserved, ppstgOpen);
    52835294
    52845295  /*
     
    53265337
    53275338  /*
    5328    * Interpret the STGM value grfMode
     5339   * Interpret the STGM value grfMode 
    53295340   */
    53305341  shareMode    = GetShareModeFromSTGM(grfMode);
     
    53515362                        fileAttributes,
    53525363            0);
    5353 
     5364 
    53545365  if (hFile == INVALID_HANDLE_VALUE)
    53555366  {
     
    53615372   */
    53625373  newStorage = HeapAlloc(GetProcessHeap(), 0, sizeof(StorageImpl));
    5363 
     5374 
    53645375  if (newStorage == 0)
    53655376    return STG_E_INSUFFICIENTMEMORY;
     
    53725383         TRUE,
    53735384         TRUE);
    5374 
     5385 
    53755386  if (FAILED(hr))
    53765387  {
     
    53985409  DWORD           grfMode,
    53995410  SNB           snbExclude,
    5400   DWORD           reserved,
     5411  DWORD           reserved, 
    54015412  IStorage      **ppstgOpen)
    54025413{
     
    54075418  DWORD          accessMode;
    54085419
    5409   TRACE("(%s, %p, %lx, %p, %ld, %p)\n",
    5410     debugstr_w(pwcsName), pstgPriority, grfMode,
    5411     snbExclude, reserved, ppstgOpen);
     5420  TRACE("(%s, %p, %lx, %p, %ld, %p)\n", 
     5421        debugstr_w(pwcsName), pstgPriority, grfMode,
     5422        snbExclude, reserved, ppstgOpen);
    54125423
    54135424  /*
     
    54335444   */
    54345445  *ppstgOpen = 0;
    5435 
    5436   hFile = CreateFileW( pwcsName,
     5446 
     5447  hFile = CreateFileW( pwcsName, 
    54375448                       accessMode,
    54385449                       shareMode,
     
    54415452                       FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS,
    54425453                       0);
    5443 
    5444 
     5454 
     5455 
    54455456  if (hFile==INVALID_HANDLE_VALUE)
    54465457  {
     
    54785489   */
    54795490  newStorage = HeapAlloc(GetProcessHeap(), 0, sizeof(StorageImpl));
    5480 
     5491 
    54815492  if (newStorage == 0)
    54825493    return STG_E_INSUFFICIENTMEMORY;
     
    54895500         TRUE,
    54905501         FALSE);
    5491 
     5502 
    54925503  if (FAILED(hr))
    54935504  {
     
    54975508     */
    54985509    if(hr == STG_E_INVALIDHEADER)
    5499     return STG_E_FILEALREADYEXISTS;
     5510        return STG_E_FILEALREADYEXISTS;
    55005511    return hr;
    55015512  }
    5502 
     5513 
    55035514  /*
    55045515   * Get an "out" pointer for the caller.
     
    55085519         (REFIID)&IID_IStorage,
    55095520         (void**)ppstgOpen);
    5510 
     5521 
    55115522  return hr;
    55125523}
     
    55605571         (void**)ppstgOpen);
    55615572
    5562   return hr;
     5573  return hr; 
    55635574}
    55645575
     
    55985609   */
    55995610  newStorage = HeapAlloc(GetProcessHeap(), 0, sizeof(StorageImpl));
    5600 
     5611 
    56015612  if (newStorage == 0)
    56025613    return STG_E_INSUFFICIENTMEMORY;
     
    56345645HRESULT WINAPI StgSetTimes(WCHAR * str, FILETIME * a, FILETIME * b, FILETIME *c )
    56355646{
    5636 
     5647 
    56375648  FIXME("(%p, %p, %p, %p),stub!\n", str, a, b, c);
    56385649  return FALSE;
     
    56855696    STATSTG pstatstg;
    56865697    HRESULT hRes;
    5687 
     5698   
    56885699    TRACE("()\n");
    56895700
     
    57085719HRESULT  WINAPI OleLoadFromStream(IStream *pStm,REFIID iidInterface,void** ppvObj)
    57095720{
    5710     CLSID   clsid;
    5711     HRESULT res;
    5712     LPPERSISTSTREAM xstm;
     5721    CLSID       clsid;
     5722    HRESULT     res;
     5723    LPPERSISTSTREAM     xstm;
    57135724
    57145725    TRACE("(%p,%s,%p)\n",pStm,debugstr_guid(iidInterface),ppvObj);
     
    57165727    res=ReadClassStm(pStm,&clsid);
    57175728    if (!SUCCEEDED(res))
    5718     return res;
     5729        return res;
    57195730    res=CoCreateInstance(&clsid,NULL,CLSCTX_INPROC_SERVER,iidInterface,ppvObj);
    57205731    if (!SUCCEEDED(res))
    5721     return res;
     5732        return res;
    57225733    res=IUnknown_QueryInterface((IUnknown*)*ppvObj,&IID_IPersistStream,(LPVOID*)&xstm);
    57235734    if (!SUCCEEDED(res)) {
    5724     IUnknown_Release((IUnknown*)*ppvObj);
    5725     return res;
     5735        IUnknown_Release((IUnknown*)*ppvObj);
     5736        return res;
    57265737    }
    57275738    res=IPersistStream_Load(xstm,pStm);
    57285739    IPersistStream_Release(xstm);
    57295740    /* FIXME: all refcounts ok at this point? I think they should be:
    5730      *      pStm    : unchanged
    5731      *      ppvObj  : 1
    5732      *      xstm    : 0 (released)
     5741     *          pStm    : unchanged
     5742     *          ppvObj  : 1
     5743     *          xstm    : 0 (released)
    57335744     */
    57345745    return res;
     
    57465757    CLSID clsid;
    57475758    HRESULT res;
    5748 
     5759   
    57495760    TRACE("(%p,%p)\n",pPStm,pStm);
    57505761
     
    57525763
    57535764    if (SUCCEEDED(res)){
    5754 
     5765       
    57555766        res=WriteClassStm(pStm,&clsid);
    57565767
     
    57705781 * STGM_TRANSACTED           0x00010000
    57715782 * STGM_SIMPLE               0x08000000
    5772  *
     5783 * 
    57735784 * STGM_READ                 0x00000000
    57745785 * STGM_WRITE                0x00000001
    57755786 * STGM_READWRITE            0x00000002
    5776  *
     5787 * 
    57775788 * STGM_SHARE_DENY_NONE      0x00000040
    57785789 * STGM_SHARE_DENY_READ      0x00000030
    57795790 * STGM_SHARE_DENY_WRITE     0x00000020
    57805791 * STGM_SHARE_EXCLUSIVE      0x00000010
    5781  *
     5792 * 
    57825793 * STGM_PRIORITY             0x00040000
    57835794 * STGM_DELETEONRELEASE      0x04000000
     
    57955806  BOOL bSTGM_SIMPLE           = ((stgm & STGM_SIMPLE) == STGM_SIMPLE);
    57965807  BOOL bSTGM_DIRECT           = ! (bSTGM_TRANSACTED || bSTGM_SIMPLE);
    5797 
     5808   
    57985809  BOOL bSTGM_WRITE            = ((stgm & STGM_WRITE) == STGM_WRITE);
    57995810  BOOL bSTGM_READWRITE        = ((stgm & STGM_READWRITE) == STGM_READWRITE);
    58005811  BOOL bSTGM_READ             = ! (bSTGM_WRITE || bSTGM_READWRITE);
    5801 
     5812   
    58025813  BOOL bSTGM_SHARE_DENY_NONE  =
    58035814                     ((stgm & STGM_SHARE_DENY_NONE)  == STGM_SHARE_DENY_NONE);
     
    58145825  BOOL bSTGM_CREATE           = ((stgm & STGM_CREATE) == STGM_CREATE);
    58155826  BOOL bSTGM_CONVERT          = ((stgm & STGM_CONVERT) == STGM_CONVERT);
    5816 
     5827   
    58175828  BOOL bSTGM_NOSCRATCH        = ((stgm & STGM_NOSCRATCH) == STGM_NOSCRATCH);
    58185829  BOOL bSTGM_NOSNAPSHOT       = ((stgm & STGM_NOSNAPSHOT) == STGM_NOSNAPSHOT);
    58195830
    5820   /*
     5831  /* 
    58215832   * STGM_DIRECT | STGM_TRANSACTED | STGM_SIMPLE
    58225833   */
     
    58255836      return E_FAIL;
    58265837
    5827   /*
     5838  /* 
    58285839   * STGM_WRITE |  STGM_READWRITE | STGM_READ
    58295840   */
     
    58335844
    58345845  /*
    5835    * STGM_SHARE_DENY_NONE | others
     5846   * STGM_SHARE_DENY_NONE | others 
    58365847   * (I assume here that DENY_READ implies DENY_WRITE)
    58375848   */
    58385849  if ( bSTGM_SHARE_DENY_NONE )
    58395850    if ( bSTGM_SHARE_DENY_READ ||
    5840          bSTGM_SHARE_DENY_WRITE ||
    5841          bSTGM_SHARE_EXCLUSIVE)
     5851         bSTGM_SHARE_DENY_WRITE || 
     5852         bSTGM_SHARE_EXCLUSIVE) 
    58425853      return E_FAIL;
    58435854
     
    58545865  if ( bSTGM_NOSCRATCH && ! bSTGM_TRANSACTED )
    58555866    return E_FAIL;
    5856 
    5857   /*
    5858    * STGM_NOSNAPSHOT requires STGM_TRANSACTED and
     5867 
     5868  /*
     5869   * STGM_NOSNAPSHOT requires STGM_TRANSACTED and 
    58595870   * not STGM_SHARE_EXCLUSIVE or STGM_SHARE_DENY_WRITE`
    58605871   */
    58615872  if (bSTGM_NOSNAPSHOT)
    58625873  {
    5863     if ( ! ( bSTGM_TRANSACTED &&
     5874    if ( ! ( bSTGM_TRANSACTED && 
    58645875           !(bSTGM_SHARE_EXCLUSIVE || bSTGM_SHARE_DENY_WRITE)) )
    58655876    return E_FAIL;
     
    58735884 *
    58745885 * This method will return a share mode flag from a STGM value.
    5875  * The STGM value is assumed valid.
     5886 * The STGM value is assumed valid. 
    58765887 */
    58775888static DWORD GetShareModeFromSTGM(DWORD stgm)
     
    59435954  /* All other cases */
    59445955  if (stgm & ~ (STGM_CREATE|STGM_CONVERT))
    5945     FIXME("unhandled storage mode : 0x%08lx\n",stgm & ~ (STGM_CREATE|STGM_CONVERT));
     5956        FIXME("unhandled storage mode : 0x%08lx\n",stgm & ~ (STGM_CREATE|STGM_CONVERT));
    59465957  return CREATE_NEW;
    59475958}
     
    59495960
    59505961/*************************************************************************
    5951  * OLECONVERT_LoadOLE10 [Internal]
    5952  *
    5953  * Loads the OLE10 STREAM to memory
     5962 * OLECONVERT_LoadOLE10 [Internal] 
     5963 *
     5964 * Loads the OLE10 STREAM to memory 
    59545965 *
    59555966 * PARAMS
     
    59645975 * NOTES
    59655976 *     This function is used by OleConvertOLESTREAMToIStorage only.
    5966  *
     5977 *     
    59675978 *     Memory allocated for pData must be freed by the caller
    59685979 */
    59695980HRESULT OLECONVERT_LoadOLE10(LPOLESTREAM pOleStream, OLECONVERT_OLESTREAM_DATA *pData, BOOL bStrem1)
    59705981{
    5971     DWORD dwSize;
    5972     HRESULT hRes = S_OK;
    5973     int nTryCnt=0;
    5974     int max_try = 6;
    5975 
    5976     pData->pData = NULL;
    5977     pData->pstrOleObjFileName = (CHAR *) NULL;
    5978 
    5979     for( nTryCnt=0;nTryCnt < max_try; nTryCnt++)
    5980     {
    5981     /* Get the OleID */
    5982     dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)&(pData->dwOleID), sizeof(pData->dwOleID));
    5983     if(dwSize != sizeof(pData->dwOleID))
    5984     {
    5985         hRes = CONVERT10_E_OLESTREAM_GET;
    5986     }
    5987     else if(pData->dwOleID != OLESTREAM_ID)
    5988     {
    5989         hRes = CONVERT10_E_OLESTREAM_FMT;
    5990     }
    5991         else
    5992         {
    5993             hRes = S_OK;
    5994             break;
    5995         }
    5996     }
    5997 
    5998     if(hRes == S_OK)
    5999     {
    6000         /* Get the TypeID...more info needed for this field */
    6001         dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)&(pData->dwTypeID), sizeof(pData->dwTypeID));
    6002         if(dwSize != sizeof(pData->dwTypeID))
    6003         {
    6004             hRes = CONVERT10_E_OLESTREAM_GET;
    6005         }
    6006     }
    6007     if(hRes == S_OK)
    6008     {
    6009         if(pData->dwTypeID != 0)
    6010         {
    6011             /* Get the lenght of the OleTypeName */
    6012             dwSize = pOleStream->lpstbl->Get(pOleStream, (void *) &(pData->dwOleTypeNameLength), sizeof(pData->dwOleTypeNameLength));
    6013             if(dwSize != sizeof(pData->dwOleTypeNameLength))
    6014             {
    6015                 hRes = CONVERT10_E_OLESTREAM_GET;
    6016             }
    6017 
    6018             if(hRes == S_OK)
    6019             {
    6020                 if(pData->dwOleTypeNameLength > 0)
    6021                 {
    6022                     /* Get the OleTypeName */
    6023                     dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)pData->strOleTypeName, pData->dwOleTypeNameLength);
    6024                     if(dwSize != pData->dwOleTypeNameLength)
    6025                     {
    6026                         hRes = CONVERT10_E_OLESTREAM_GET;
    6027                     }
    6028                 }
    6029             }
    6030             if(bStrem1)
    6031             {
    6032                 dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)&(pData->dwOleObjFileNameLength), sizeof(pData->dwOleObjFileNameLength));
    6033                 if(dwSize != sizeof(pData->dwOleObjFileNameLength))
    6034                 {
    6035                     hRes = CONVERT10_E_OLESTREAM_GET;
    6036                 }
    6037             if(hRes == S_OK)
    6038             {
    6039                     if(pData->dwOleObjFileNameLength < 1) /* there is no file name exist */
    6040                         pData->dwOleObjFileNameLength = sizeof(pData->dwOleObjFileNameLength);
    6041                     pData->pstrOleObjFileName = (CHAR *)malloc(pData->dwOleObjFileNameLength);
    6042                     if(pData->pstrOleObjFileName)
    6043                     {
    6044                         dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)(pData->pstrOleObjFileName),pData->dwOleObjFileNameLength);
    6045                         if(dwSize != pData->dwOleObjFileNameLength)
    6046                         {
    6047                             hRes = CONVERT10_E_OLESTREAM_GET;
    6048                         }
    6049                     }
    6050                     else
    6051                         hRes = CONVERT10_E_OLESTREAM_GET;
    6052                 }
    6053             }
    6054             else
    6055             {
    6056                 /* Get the Width of the Metafile */
    6057                 dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)&(pData->dwMetaFileWidth), sizeof(pData->dwMetaFileWidth));
    6058                 if(dwSize != sizeof(pData->dwMetaFileWidth))
    6059                 {
    6060                     hRes = CONVERT10_E_OLESTREAM_GET;
    6061                 }
    6062             if(hRes == S_OK)
    6063             {
    6064                 /* Get the Height of the Metafile */
    6065                 dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)&(pData->dwMetaFileHeight), sizeof(pData->dwMetaFileHeight));
    6066                 if(dwSize != sizeof(pData->dwMetaFileHeight))
    6067                 {
    6068                     hRes = CONVERT10_E_OLESTREAM_GET;
    6069                 }
    6070             }
    6071             }
    6072             if(hRes == S_OK)
    6073             {
    6074                 /* Get the Lenght of the Data */
    6075                 dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)&(pData->dwDataLength), sizeof(pData->dwDataLength));
    6076                 if(dwSize != sizeof(pData->dwDataLength))
    6077                 {
    6078                     hRes = CONVERT10_E_OLESTREAM_GET;
    6079                 }
    6080             }
    6081 
    6082             if(hRes == S_OK) /* I don't know what is this 8 byts information is we have to figure out */
    6083             {
    6084                 if(!bStrem1) /* if it is a second OLE stream data */
    6085                 {
    6086                     pData->dwDataLength -= 8;
    6087                     dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)(pData->strUnknown), sizeof(pData->strUnknown));
    6088                     if(dwSize != sizeof(pData->strUnknown))
    6089                     {
    6090                         hRes = CONVERT10_E_OLESTREAM_GET;
    6091                     }
    6092                 }
    6093             }
    6094             if(hRes == S_OK)
    6095             {
    6096                 if(pData->dwDataLength > 0)
    6097                 {
    6098                     pData->pData = (BYTE *)HeapAlloc(GetProcessHeap(),0,pData->dwDataLength);
    6099 
    6100                     /* Get Data (ex. IStorage, Metafile, or BMP) */
    6101                     if(pData->pData)
    6102                     {
    6103                         dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)pData->pData, pData->dwDataLength);
    6104                         if(dwSize != pData->dwDataLength)
    6105                         {
    6106                             hRes = CONVERT10_E_OLESTREAM_GET;
    6107                         }
    6108                     }
    6109                     else
    6110                     {
    6111                         hRes = CONVERT10_E_OLESTREAM_GET;
    6112                     }
    6113                 }
    6114             }
    6115         }
    6116     }
    6117     return hRes;
     5982        DWORD dwSize;
     5983        HRESULT hRes = S_OK;
     5984        int nTryCnt=0;
     5985        int max_try = 6;
     5986
     5987        pData->pData = NULL;
     5988        pData->pstrOleObjFileName = (CHAR *) NULL;
     5989
     5990        for( nTryCnt=0;nTryCnt < max_try; nTryCnt++)
     5991        {
     5992        /* Get the OleID */
     5993        dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)&(pData->dwOleID), sizeof(pData->dwOleID));
     5994        if(dwSize != sizeof(pData->dwOleID))
     5995        {
     5996                hRes = CONVERT10_E_OLESTREAM_GET;
     5997        }
     5998        else if(pData->dwOleID != OLESTREAM_ID)
     5999        {
     6000                hRes = CONVERT10_E_OLESTREAM_FMT;
     6001        }
     6002                else
     6003                {
     6004                        hRes = S_OK;
     6005                        break;
     6006                }
     6007        }
     6008
     6009        if(hRes == S_OK)
     6010        {
     6011                /* Get the TypeID...more info needed for this field */
     6012                dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)&(pData->dwTypeID), sizeof(pData->dwTypeID));
     6013                if(dwSize != sizeof(pData->dwTypeID))
     6014                {
     6015                        hRes = CONVERT10_E_OLESTREAM_GET;
     6016                }
     6017        }
     6018        if(hRes == S_OK)
     6019        {
     6020                if(pData->dwTypeID != 0)
     6021                {
     6022                        /* Get the lenght of the OleTypeName */
     6023                        dwSize = pOleStream->lpstbl->Get(pOleStream, (void *) &(pData->dwOleTypeNameLength), sizeof(pData->dwOleTypeNameLength));
     6024                        if(dwSize != sizeof(pData->dwOleTypeNameLength))
     6025                        {
     6026                                hRes = CONVERT10_E_OLESTREAM_GET;
     6027                        }
     6028
     6029                        if(hRes == S_OK)
     6030                        {
     6031                                if(pData->dwOleTypeNameLength > 0)
     6032                                {
     6033                                        /* Get the OleTypeName */
     6034                                        dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)pData->strOleTypeName, pData->dwOleTypeNameLength);
     6035                                        if(dwSize != pData->dwOleTypeNameLength)
     6036                                        {
     6037                                                hRes = CONVERT10_E_OLESTREAM_GET;
     6038                                        }
     6039                                }
     6040                        }
     6041                        if(bStrem1)
     6042                        {
     6043                                dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)&(pData->dwOleObjFileNameLength), sizeof(pData->dwOleObjFileNameLength));
     6044                                if(dwSize != sizeof(pData->dwOleObjFileNameLength))
     6045                                {
     6046                                        hRes = CONVERT10_E_OLESTREAM_GET;
     6047                                }
     6048                        if(hRes == S_OK)
     6049                        {
     6050                                        if(pData->dwOleObjFileNameLength < 1) /* there is no file name exist */
     6051                                                pData->dwOleObjFileNameLength = sizeof(pData->dwOleObjFileNameLength);
     6052                                        pData->pstrOleObjFileName = (CHAR *)malloc(pData->dwOleObjFileNameLength);
     6053                                        if(pData->pstrOleObjFileName)
     6054                                        {
     6055                                                dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)(pData->pstrOleObjFileName),pData->dwOleObjFileNameLength);
     6056                                                if(dwSize != pData->dwOleObjFileNameLength)
     6057                                                {
     6058                                                        hRes = CONVERT10_E_OLESTREAM_GET;
     6059                                                }
     6060                                        }
     6061                                        else
     6062                                                hRes = CONVERT10_E_OLESTREAM_GET;
     6063                                }
     6064                        }
     6065                        else
     6066                        {
     6067                                /* Get the Width of the Metafile */
     6068                                dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)&(pData->dwMetaFileWidth), sizeof(pData->dwMetaFileWidth));
     6069                                if(dwSize != sizeof(pData->dwMetaFileWidth))
     6070                                {
     6071                                        hRes = CONVERT10_E_OLESTREAM_GET;
     6072                                }
     6073                        if(hRes == S_OK)
     6074                        {
     6075                                /* Get the Height of the Metafile */
     6076                                dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)&(pData->dwMetaFileHeight), sizeof(pData->dwMetaFileHeight));
     6077                                if(dwSize != sizeof(pData->dwMetaFileHeight))
     6078                                {
     6079                                        hRes = CONVERT10_E_OLESTREAM_GET;
     6080                                }
     6081                        }
     6082                        }
     6083                        if(hRes == S_OK)
     6084                        {
     6085                                /* Get the Lenght of the Data */
     6086                                dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)&(pData->dwDataLength), sizeof(pData->dwDataLength));
     6087                                if(dwSize != sizeof(pData->dwDataLength))
     6088                                {
     6089                                        hRes = CONVERT10_E_OLESTREAM_GET;
     6090                                }
     6091                        }
     6092
     6093                        if(hRes == S_OK) /* I don't know what is this 8 byts information is we have to figure out */
     6094                        {
     6095                                if(!bStrem1) /* if it is a second OLE stream data */
     6096                                {
     6097                                        pData->dwDataLength -= 8;
     6098                                        dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)(pData->strUnknown), sizeof(pData->strUnknown));
     6099                                        if(dwSize != sizeof(pData->strUnknown))
     6100                                        {
     6101                                                hRes = CONVERT10_E_OLESTREAM_GET;
     6102                                        }
     6103                                }
     6104                        }
     6105                        if(hRes == S_OK)
     6106                        {
     6107                                if(pData->dwDataLength > 0)
     6108                                {
     6109                                        pData->pData = (BYTE *)HeapAlloc(GetProcessHeap(),0,pData->dwDataLength);
     6110
     6111                                        /* Get Data (ex. IStorage, Metafile, or BMP) */
     6112                                        if(pData->pData)
     6113                                        {
     6114                                                dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)pData->pData, pData->dwDataLength);
     6115                                                if(dwSize != pData->dwDataLength)
     6116                                                {
     6117                                                        hRes = CONVERT10_E_OLESTREAM_GET;
     6118                                                }
     6119                                        }
     6120                                        else
     6121                                        {
     6122                                                hRes = CONVERT10_E_OLESTREAM_GET;
     6123                                        }
     6124                                }
     6125                        }
     6126                }
     6127        }
     6128        return hRes;
    61186129}
    61196130
    61206131/*************************************************************************
    6121  * OLECONVERT_SaveOLE10 [Internal]
    6122  *
    6123  * Saves the OLE10 STREAM From memory
     6132 * OLECONVERT_SaveOLE10 [Internal] 
     6133 *
     6134 * Saves the OLE10 STREAM From memory 
    61246135 *
    61256136 * PARAMS
     
    61336144 * NOTES
    61346145 *     This function is used by OleConvertIStorageToOLESTREAM only.
    6135  *
     6146 *     
    61366147 */
    61376148HRESULT OLECONVERT_SaveOLE10(OLECONVERT_OLESTREAM_DATA *pData, LPOLESTREAM pOleStream)
     
    62276238
    62286239/*************************************************************************
    6229  * OLECONVERT_GetOLE20FromOLE10[Internal]
     6240 * OLECONVERT_GetOLE20FromOLE10[Internal] 
    62306241 *
    62316242 * This function copies OLE10 Data (the IStorage in the OLESTREAM) to disk,
    6232  * opens it, and copies the content to the dest IStorage for
     6243 * opens it, and copies the content to the dest IStorage for 
    62336244 * OleConvertOLESTREAMToIStorage
    6234  *
     6245 * 
    62356246 *
    62366247 * PARAMS
     
    62436254 *
    62446255 * NOTES
    6245  *
    6246  *
     6256 *     
     6257 *     
    62476258 */
    62486259void OLECONVERT_GetOLE20FromOLE10(LPSTORAGE pDestStorage, BYTE *pBuffer, DWORD nBufferLength)
     
    62796290
    62806291/*************************************************************************
    6281  * OLECONVERT_WriteOLE20ToBuffer [Internal]
    6282  *
    6283  * Saves the OLE10 STREAM From memory
     6292 * OLECONVERT_WriteOLE20ToBuffer [Internal] 
     6293 *
     6294 * Saves the OLE10 STREAM From memory 
    62846295 *
    62856296 * PARAMS
     
    62946305 *
    62956306 *     Used by OleConvertIStorageToOLESTREAM only.
    6296  *
     6307 *     
    62976308 */
    62986309DWORD OLECONVERT_WriteOLE20ToBuffer(LPSTORAGE pStorage, BYTE **pData)
     
    63066317
    63076318    *pData = NULL;
    6308 
     6319   
    63096320    /* Create temp Storage */
    63106321    GetTempPathW(MAX_PATH, wstrTempDir);
     
    63336344
    63346345/*************************************************************************
    6335  * OLECONVERT_CreateOleStream [Internal]
     6346 * OLECONVERT_CreateOleStream [Internal] 
    63366347 *
    63376348 * Creates the "\001OLE" stream in the IStorage if neccessary.
     
    63486359 *     This stream is still unknown, MS Word seems to have extra data
    63496360 *     but since the data is stored in the OLESTREAM there should be
    6350  *     no need to recreate the stream.  If the stream is manually
     6361 *     no need to recreate the stream.  If the stream is manually 
    63516362 *     deleted it will create it with this default data.
    6352  *
     6363 *     
    63536364 */
    63546365void OLECONVERT_CreateOleStream(LPSTORAGE pStorage)
     
    63576368    IStream *pStream;
    63586369    WCHAR wstrStreamName[] = {1,'O', 'l', 'e', 0};
    6359     BYTE pOleStreamHeader [] =
    6360     {
    6361         0x01, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
    6362         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    6363         0x00, 0x00, 0x00, 0x00
     6370    BYTE pOleStreamHeader [] = 
     6371    {
     6372        0x01, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 
     6373        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
     6374        0x00, 0x00, 0x00, 0x00 
    63646375    };
    6365 
     6376   
    63666377    /* Create stream if not present */
    6367     hRes = IStorage_CreateStream(pStorage, wstrStreamName,
     6378    hRes = IStorage_CreateStream(pStorage, wstrStreamName, 
    63686379        STGM_WRITE  | STGM_SHARE_EXCLUSIVE, 0, 0, &pStream );
    63696380
     
    63786389
    63796390/*************************************************************************
    6380  * OLECONVERT_CreateCompObjStream [Internal]
     6391 * OLECONVERT_CreateCompObjStream [Internal] 
    63816392 *
    63826393 * Creates a "\001CompObj" is the destination IStorage if necessary.
    63836394 *
    63846395 * PARAMS
    6385  *     pStorage       [I] The dest IStorage to create the CompObj Stream
     6396 *     pStorage       [I] The dest IStorage to create the CompObj Stream 
    63866397 *                        if necessary.
    63876398 *     strOleTypeName [I] The ProgID
     
    63956406 *
    63966407 *     The stream data is stored in the OLESTREAM and there should be
    6397  *     no need to recreate the stream.  If the stream is manually
     6408 *     no need to recreate the stream.  If the stream is manually 
    63986409 *     deleted it will attempt to create it by querying the registry.
    63996410 *
    6400  *
     6411 *     
    64016412 */
    64026413HRESULT OLECONVERT_CreateCompObjStream(LPSTORAGE pStorage, LPCSTR strOleTypeName)
     
    64176428
    64186429    /*  Create a CompObj stream if it doesn't exist */
    6419     hStorageRes = IStorage_CreateStream(pStorage, wstrStreamName,
     6430    hStorageRes = IStorage_CreateStream(pStorage, wstrStreamName, 
    64206431        STGM_WRITE  | STGM_SHARE_EXCLUSIVE, 0, 0, &pStream );
    64216432    if(hStorageRes == S_OK)
     
    64386449            LONG hErr;
    64396450            /* Get the CLSID Default Name from the Registry */
    6440             hErr = RegOpenKeyA(HKEY_CLASSES_ROOT, IStorageCompObj.strProgIDName, &hKey);
     6451            hErr = RegOpenKeyA(HKEY_CLASSES_ROOT, IStorageCompObj.strProgIDName, &hKey); 
    64416452            if(hErr == ERROR_SUCCESS)
    64426453            {
     
    64806491
    64816492/*************************************************************************
    6482  * OLECONVERT_CreateOlePresStream[Internal]
     6493 * OLECONVERT_CreateOlePresStream[Internal] 
    64836494 *
    64846495 * Creates the "\002OlePres000" Stream with the Metafile data
     
    64876498 *     pStorage     [I] The dest IStorage to create \002OLEPres000 stream in.
    64886499 *     dwExtentX    [I] Width of the Metafile
    6489  *     dwExtentY    [I] Height of the Metafile
     6500 *     dwExtentY    [I] Height of the Metafile 
    64906501 *     pData        [I] Metafile data
    64916502 *     dwDataLength [I] Size of the Metafile data
     
    64976508 * NOTES
    64986509 *     This function is used by OleConvertOLESTREAMToIStorage only.
    6499  *
     6510 *     
    65006511 */
    65016512void OLECONVERT_CreateOlePresStream(LPSTORAGE pStorage, DWORD dwExtentX, DWORD dwExtentY , BYTE *pData, DWORD dwDataLength)
     
    65046515    IStream *pStream;
    65056516    WCHAR wstrStreamName[] = {2, 'O', 'l', 'e', 'P', 'r', 'e', 's', '0', '0', '0', 0};
    6506     BYTE pOlePresStreamHeader [] =
    6507     {
    6508         0xFF, 0xFF, 0xFF, 0xFF, 0x03, 0x00, 0x00, 0x00,
    6509         0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
     6517    BYTE pOlePresStreamHeader [] = 
     6518    {
     6519        0xFF, 0xFF, 0xFF, 0xFF, 0x03, 0x00, 0x00, 0x00, 
     6520        0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 
    65106521        0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00,
    65116522        0x00, 0x00, 0x00, 0x00
    65126523    };
    65136524
    6514     BYTE pOlePresStreamHeaderEmpty [] =
    6515     {
    6516         0x00, 0x00, 0x00, 0x00,
    6517         0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
     6525    BYTE pOlePresStreamHeaderEmpty [] = 
     6526    {
     6527        0x00, 0x00, 0x00, 0x00, 
     6528        0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 
    65186529        0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00,
    65196530        0x00, 0x00, 0x00, 0x00
    65206531    };
    6521 
     6532     
    65226533    /* Create the OlePres000 Stream */
    6523     hRes = IStorage_CreateStream(pStorage, wstrStreamName,
     6534    hRes = IStorage_CreateStream(pStorage, wstrStreamName, 
    65246535        STGM_CREATE | STGM_WRITE  | STGM_SHARE_EXCLUSIVE, 0, 0, &pStream );
    65256536
     
    65656576
    65666577/*************************************************************************
    6567  * OLECONVERT_CreateOle10NativeStream [Internal]
     6578 * OLECONVERT_CreateOle10NativeStream [Internal] 
    65686579 *
    65696580 * Creates the "\001Ole10Native" Stream (should contain a BMP)
     
    65816592 *
    65826593 *     Might need to verify the data and return appropriate error message
    6583  *
     6594 *     
    65846595 */
    65856596void OLECONVERT_CreateOle10NativeStream(LPSTORAGE pStorage, BYTE *pData, DWORD dwDataLength)
     
    65886599    IStream *pStream;
    65896600    WCHAR wstrStreamName[] = {1, 'O', 'l', 'e', '1', '0', 'N', 'a', 't', 'i', 'v', 'e', 0};
    6590 
     6601   
    65916602    /* Create the Ole10Native Stream */
    6592     hRes = IStorage_CreateStream(pStorage, wstrStreamName,
     6603    hRes = IStorage_CreateStream(pStorage, wstrStreamName, 
    65936604        STGM_CREATE | STGM_WRITE  | STGM_SHARE_EXCLUSIVE, 0, 0, &pStream );
    65946605
     
    66046615
    66056616/*************************************************************************
    6606  * OLECONVERT_GetOLE10ProgID [Internal]
     6617 * OLECONVERT_GetOLE10ProgID [Internal] 
    66076618 *
    66086619 * Finds the ProgID (or OleTypeID) from the IStorage
     
    66206631 *     This function is used by OleConvertIStorageToOLESTREAM only.
    66216632 *
    6622  *
     6633 *     
    66236634 */
    66246635HRESULT OLECONVERT_GetOLE10ProgID(LPSTORAGE pStorage, char *strProgID, DWORD *dwSize)
     
    66316642
    66326643    /* Open the CompObj Stream */
    6633     hRes = IStorage_OpenStream(pStorage, wstrStreamName, NULL,
     6644    hRes = IStorage_OpenStream(pStorage, wstrStreamName, NULL, 
    66346645        STGM_READ  | STGM_SHARE_EXCLUSIVE, 0, &pStream );
    66356646    if(hRes == S_OK)
     
    66686679            *dwSize = WideCharToMultiByte(CP_ACP, 0, wstrProgID, -1, strProgID, *dwSize, NULL, FALSE);
    66696680        }
    6670 
     6681 
    66716682    }
    66726683    return hRes;
     
    66746685
    66756686/*************************************************************************
    6676  * OLECONVERT_GetOle10PresData [Internal]
     6687 * OLECONVERT_GetOle10PresData [Internal] 
    66776688 *
    66786689 * Converts IStorage "/001Ole10Native" stream to a OLE10 Stream
     
    66896700 *
    66906701 *     Memory allocated for pData must be freed by the caller
    6691  *
    6692  *
     6702 *     
     6703 *     
    66936704 */
    66946705void OLECONVERT_GetOle10PresData(LPSTORAGE pStorage, OLECONVERT_OLESTREAM_DATA *pOleStreamData)
     
    67106721
    67116722    /* Open Ole10Native Stream */
    6712     hRes = IStorage_OpenStream(pStorage, wstrStreamName, NULL,
     6723    hRes = IStorage_OpenStream(pStorage, wstrStreamName, NULL, 
    67136724        STGM_READ  | STGM_SHARE_EXCLUSIVE, 0, &pStream );
    67146725    if(hRes == S_OK)
     
    67296740
    67306741/*************************************************************************
    6731  * OLECONVERT_GetOle20PresData[Internal]
     6742 * OLECONVERT_GetOle20PresData[Internal] 
    67326743 *
    67336744 * Converts IStorage "/002OlePres000" stream to a OLE10 Stream
     
    67426753 * NOTES
    67436754 *     This function is used by OleConvertIStorageToOLESTREAM only.
    6744  *
     6755 *     
    67456756 *     Memory allocated for pData must be freed by the caller
    67466757 */
     
    67696780
    67706781    /* Open OlePress000 stream */
    6771     hRes = IStorage_OpenStream(pStorage, wstrStreamName, NULL,
     6782    hRes = IStorage_OpenStream(pStorage, wstrStreamName, NULL, 
    67726783        STGM_READ  | STGM_SHARE_EXCLUSIVE, 0, &pStream );
    67736784    if(hRes == S_OK)
     
    68176828
    68186829/*************************************************************************
    6819  * OleConvertOLESTREAMToIStorage [OLE32.87]
     6830 * OleConvertOLESTREAMToIStorage [OLE32.87] 
    68206831 *
    68216832 * Read info on MSDN
     
    68266837 *      Still some unknowns for the IStorage: "\002OlePres000", "\001CompObj",
    68276838 *      and "\001OLE" streams
    6828  *
     6839 *     
    68296840 */
    68306841HRESULT WINAPI OleConvertOLESTREAMToIStorage (
    6831     LPOLESTREAM pOleStream,
    6832     LPSTORAGE pstg,
     6842    LPOLESTREAM pOleStream, 
     6843    LPSTORAGE pstg, 
    68336844    const DVTARGETDEVICE* ptd)
    68346845{
     
    69026913        }
    69036914        if(pOleStreamData[i].pstrOleObjFileName != NULL)
    6904     {
    6905             HeapFree(GetProcessHeap(),0,pOleStreamData[i].pstrOleObjFileName);
    6906             pOleStreamData[i].pstrOleObjFileName = NULL;
    6907     }
     6915        {
     6916                HeapFree(GetProcessHeap(),0,pOleStreamData[i].pstrOleObjFileName);
     6917                pOleStreamData[i].pstrOleObjFileName = NULL;
     6918        }
    69086919    }
    69096920    return hRes;
     
    69216932 *      Still some unknowns for the IStorage: "\002OlePres000", "\001CompObj",
    69226933 *      and "\001OLE" streams.
    6923  *
     6934 *     
    69246935 */
    69256936HRESULT WINAPI OleConvertIStorageToOLESTREAM (
    6926     LPSTORAGE pstg,
     6937    LPSTORAGE pstg, 
    69276938    LPOLESTREAM pOleStream)
    69286939{
     
    69496960    {
    69506961        /*Was it originaly Ole10 */
    6951         hRes = IStorage_OpenStream(pstg, wstrStreamName, 0, STGM_READ | STGM_SHARE_EXCLUSIVE, 0, &pStream);
     6962        hRes = IStorage_OpenStream(pstg, wstrStreamName, 0, STGM_READ | STGM_SHARE_EXCLUSIVE, 0, &pStream);   
    69526963        if(hRes == S_OK)
    69536964        {
     
    69846995
    69856996/***********************************************************************
    6986  *      GetConvertStg (OLE32.68)
     6997 *              GetConvertStg (OLE32.68)
    69876998 */
    69886999HRESULT WINAPI GetConvertStg(LPGUID guid) {
     
    69987009 */
    69997010HRESULT WINAPI StgIsStorageFile16(LPCOLESTR16 fn) {
    7000     HFILE       hf;
    7001     OFSTRUCT    ofs;
    7002     BYTE        magic[24];
    7003 
    7004     TRACE("(\'%s\')\n",fn);
    7005     hf = OpenFile(fn,&ofs,OF_SHARE_DENY_NONE);
    7006     if (hf==HFILE_ERROR)
    7007         return STG_E_FILENOTFOUND;
    7008     if (24!=_lread(hf,magic,24)) {
    7009         WARN(" too short\n");
    7010         _lclose(hf);
    7011         return S_FALSE;
    7012     }
    7013     if (!memcmp(magic,STORAGE_magic,8)) {
    7014         WARN(" -> YES\n");
    7015         _lclose(hf);
    7016         return S_OK;
    7017     }
    7018     if (!memcmp(magic,STORAGE_notmagic,8)) {
    7019         WARN(" -> NO\n");
    7020         _lclose(hf);
    7021         return S_FALSE;
    7022     }
    7023     if (!memcmp(magic,STORAGE_oldmagic,8)) {
    7024         WARN(" -> old format\n");
    7025         _lclose(hf);
    7026         return STG_E_OLDFORMAT;
    7027     }
    7028     WARN(" -> Invalid header.\n");
    7029     _lclose(hf);
    7030     return STG_E_INVALIDHEADER;
     7011        HFILE           hf;
     7012        OFSTRUCT        ofs;
     7013        BYTE            magic[24];
     7014
     7015        TRACE("(\'%s\')\n",fn);
     7016        hf = OpenFile(fn,&ofs,OF_SHARE_DENY_NONE);
     7017        if (hf==HFILE_ERROR)
     7018                return STG_E_FILENOTFOUND;
     7019        if (24!=_lread(hf,magic,24)) {
     7020                WARN(" too short\n");
     7021                _lclose(hf);
     7022                return S_FALSE;
     7023        }
     7024        if (!memcmp(magic,STORAGE_magic,8)) {
     7025                WARN(" -> YES\n");
     7026                _lclose(hf);
     7027                return S_OK;
     7028        }
     7029        if (!memcmp(magic,STORAGE_notmagic,8)) {
     7030                WARN(" -> NO\n");
     7031                _lclose(hf);
     7032                return S_FALSE;
     7033        }
     7034        if (!memcmp(magic,STORAGE_oldmagic,8)) {
     7035                WARN(" -> old format\n");
     7036                _lclose(hf);
     7037                return STG_E_OLDFORMAT;
     7038        }
     7039        WARN(" -> Invalid header.\n");
     7040        _lclose(hf);
     7041        return STG_E_INVALIDHEADER;
    70317042}
    70327043
     
    70347045 * StgIsStorageFile [OLE32.146]
    70357046 */
    7036 HRESULT WINAPI
    7037 StgIsStorageFile(LPCOLESTR fn)
    7038 {
    7039     LPOLESTR16  xfn = HEAP_strdupWtoA(GetProcessHeap(),0,fn);
    7040     HRESULT ret = StgIsStorageFile16(xfn);
    7041 
    7042     HeapFree(GetProcessHeap(),0,xfn);
    7043     return ret;
     7047HRESULT WINAPI 
     7048StgIsStorageFile(LPCOLESTR fn) 
     7049{
     7050        LPOLESTR16      xfn = HEAP_strdupWtoA(GetProcessHeap(),0,fn);
     7051        HRESULT ret = StgIsStorageFile16(xfn);
     7052
     7053        HeapFree(GetProcessHeap(),0,xfn);
     7054        return ret;
    70447055}
    70457056#endif
Note: See TracChangeset for help on using the changeset viewer.