Ignore:
Timestamp:
Sep 14, 2000, 4:57:01 PM (25 years ago)
Author:
davidr
Message:

BugFixes & Updates (CorelWine)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/ole32/compositemoniker.cpp

    r1033 r4258  
    1 /* $Id: compositemoniker.cpp,v 1.1 1999-09-24 21:49:42 davidr Exp $ */
     1/* $Id: compositemoniker.cpp,v 1.2 2000-09-14 14:57:01 davidr Exp $ */
    22/*
    33 * CompositeMonikers functions.
     
    1414#include "debugtools.h"
    1515
    16 DEFAULT_DEBUG_CHANNEL(ole)
     16DEFAULT_DEBUG_CHANNEL(moniker)
    1717
    1818#define  BLOCK_TAB_SIZE 5 /* represent the first size table and it's increment block size */
     
    4242typedef struct EnumMonikerImpl{
    4343
    44     ICOM_VTABLE(IEnumMoniker)*  lpvtbl;  /* VTable relative to the IEnumMoniker interface.*/
     44    ICOM_VFIELD(IEnumMoniker);  /* VTable relative to the IEnumMoniker interface.*/
    4545
    4646    ULONG ref; /* reference counter for this object */
     
    285285HRESULT WINAPI CompositeMonikerImpl_Load(IMoniker* iface,IStream* pStm)
    286286{
    287     HRESULT res;
    288     DWORD constant;
    289     CLSID clsid;
    290     WCHAR string[1]={0};
     287    HRESULT     res;
     288    CLSID       clsid;
     289    WCHAR       string[1]={0};
     290    ULONG       countMoniker;
    291291   
    292292    ICOM_THIS(CompositeMonikerImpl,iface);   
     
    296296    /* this function call OleLoadFromStream function for each moniker within this object */
    297297
    298     /* read the a constant writen by CompositeMonikerImpl_Save (see CompositeMonikerImpl_Save for more details)*/
    299     res=IStream_Read(pStm,&constant,sizeof(DWORD),NULL);
    300 
    301     if (SUCCEEDED(res)&& constant!=3)
    302         return E_FAIL;
    303 
    304     while(1){
     298    /* read the number of monikers within the composite moniker*/
     299    res=IStream_Read(pStm,&countMoniker,sizeof(countMoniker),NULL);
     300
     301    for(This->tabLastIndex=0; This->tabLastIndex < countMoniker; This->tabLastIndex++)
     302    {
    305303#if 0
    306304        res=OleLoadFromStream(pStm,&IID_IMoniker,(void**)&This->tabMoniker[This->tabLastIndex]);
    307305#endif
    308306        res=ReadClassStm(pStm,&clsid);
    309         printf("res=%ld",res);
     307
    310308        if (FAILED(res))
    311             break;
    312 
    313         if (IsEqualIID(&clsid,&CLSID_FileMoniker)){
     309            return res;
     310
     311        if (IsEqualIID(&clsid,&CLSID_FileMoniker))
     312        {
    314313            res=CreateFileMoniker(string,&This->tabMoniker[This->tabLastIndex]);
    315314            if (FAILED(res))
    316                 break;
    317             res=IMoniker_Load(This->tabMoniker[This->tabLastIndex],pStm);
     315                return res;
     316        }
     317        else if (IsEqualIID(&clsid,&CLSID_ItemMoniker))
     318        {
     319            CreateItemMoniker(string,string,&This->tabMoniker[This->tabLastIndex]);
    318320            if (FAILED(res))
    319                 break;
    320         }
    321         else if (IsEqualIID(&clsid,&CLSID_ItemMoniker)){
    322             CreateItemMoniker(string,string,&This->tabMoniker[This->tabLastIndex]);
    323             if (res!=S_OK)
    324                 break;
    325             IMoniker_Load(This->tabMoniker[This->tabLastIndex],pStm);
    326             if (FAILED(res))
    327                 break;
    328         }
    329         else if (IsEqualIID(&clsid,&CLSID_AntiMoniker)){
     321                return res;
     322        }
     323        else if (IsEqualIID(&clsid,&CLSID_AntiMoniker))
     324        {
    330325            CreateAntiMoniker(&This->tabMoniker[This->tabLastIndex]);
    331326            if (FAILED(res))
    332                 break;
    333             IMoniker_Load(This->tabMoniker[This->tabLastIndex],pStm);
    334             if (FAILED(res))
    335                 break;
    336         }
    337         else if (IsEqualIID(&clsid,&CLSID_CompositeMoniker))
     327                return res;
     328        }
     329        else
    338330            return E_FAIL;
    339331
    340         else{
    341             FIXME("()");
    342             break;
    343             return E_NOTIMPL;
    344         }
     332        res=IMoniker_Load(This->tabMoniker[This->tabLastIndex],pStm);
     333        if (FAILED(res))
     334            return res;
    345335
    346336        /* resize the table if needed */
    347         if (++This->tabLastIndex==This->tabSize){
     337        if (This->tabLastIndex==This->tabSize){
    348338               
    349339            This->tabSize+=BLOCK_TAB_SIZE;
    350             This->tabMoniker=(IMoniker**)HeapReAlloc(GetProcessHeap(),0,This->tabMoniker,This->tabSize*sizeof(IMoniker));
     340            This->tabMoniker=(IMoniker**)HeapReAlloc(
     341                GetProcessHeap(),0,This->tabMoniker,This->tabSize*sizeof(IMoniker));
    351342
    352343            if (This->tabMoniker==NULL)
    353             return E_OUTOFMEMORY;
     344                return E_OUTOFMEMORY;
    354345        }
    355346    }
     
    366357    IEnumMoniker *enumMk;
    367358    IMoniker *pmk;
    368     DWORD constant=3;
     359
     360    ICOM_THIS(CompositeMonikerImpl,iface);
    369361   
    370362    TRACE("(%p,%p,%d)\n",iface,pStm,fClearDirty);
     
    372364    /* this function call OleSaveToStream function for each moniker within this object */
    373365
    374     /* when I tested this function in windows system ! I usually found this constant in the begining of */
    375     /* the stream  I dont known why (there's no indication in specification) ! */
    376     res=IStream_Write(pStm,&constant,sizeof(constant),NULL);
     366    /* write the number of monikers within the composite moniker*/
     367    res=IStream_Write(pStm,&(This->tabLastIndex),sizeof(This->tabLastIndex),NULL);
    377368
    378369    IMoniker_Enum(iface,TRUE,&enumMk);
     
    410401    TRACE("(%p,%p)\n",iface,pcbSize);
    411402
    412     if (pcbSize!=NULL)
     403    if (pcbSize==NULL)
    413404        return E_POINTER;
    414405
    415     pcbSize->LowPart =0;
     406    pcbSize->LowPart =sizeof(DWORD) + 48;
    416407    pcbSize->HighPart=0;
    417408
     
    424415        IMoniker_Release(pmk);
    425416
    426         pcbSize->LowPart +=ptmpSize.LowPart;
     417        pcbSize->LowPart +=ptmpSize.LowPart;    // FIXME - 64bit Math
    427418        pcbSize->HighPart+=ptmpSize.HighPart;
    428419    }
     
    432423    return S_OK;
    433424}
     425
     426#if 0
     427/******************************************************************************
     428 *         CompositeMonikerImpl_GetSizeToSave (Local)
     429 *******************************************************************************/
     430HRESULT CompositeMonikerImpl_GetSizeToSave(IMoniker* iface,ULARGE_INTEGER* pcbSize)
     431{
     432    IEnumMoniker *enumMk;
     433    IMoniker *pmk;
     434    HRESULT hRes;
     435    ULARGE_INTEGER ptmpSize;
     436
     437    if (pcbSize==NULL)
     438        return E_POINTER;
     439
     440    pcbSize->LowPart = sizeof(DWORD);
     441    pcbSize->HighPart=0;
     442
     443    IMoniker_Enum(iface,TRUE,&enumMk);
     444
     445    while((hRes = IEnumMoniker_Next(enumMk,1,&pmk,NULL))==S_OK){
     446
     447        GetSizeToSaveMoniker(pmk,&ptmpSize);
     448        IMoniker_Release(pmk);
     449
     450        pcbSize->LowPart +=ptmpSize.LowPart;    // FIXME - 64bit math
     451        pcbSize->HighPart+=ptmpSize.HighPart;
     452    }
     453    IEnumMoniker_Release(enumMk);
     454
     455    return S_OK;
     456}
     457#endif
     458
    434459
    435460/******************************************************************************
     
    15091534{
    15101535    ICOM_THIS(EnumMonikerImpl,iface);
    1511     ULONG i
    1512         ;
    1513     TRACE("(%p)\n",This);
     1536
     1537    ULONG i;
    15141538
    15151539    This->ref--;
     
    16101634   
    16111635    /* Initialize the virtual function table. */
    1612     newEnumMoniker->lpvtbl      = &VT_EnumMonikerImpl;
    1613     newEnumMoniker->ref          = 0;
    1614 
    1615     newEnumMoniker->tabSize=tabSize;
    1616     newEnumMoniker->currentPos=currentPos;
    1617 
    1618     newEnumMoniker->tabMoniker=(IMoniker**)HeapAlloc(GetProcessHeap(),0,tabSize*sizeof(IMoniker));
     1636    ICOM_VTBL(newEnumMoniker)  = &VT_EnumMonikerImpl;
     1637    newEnumMoniker->ref        = 0;
     1638
     1639    newEnumMoniker->tabSize    = tabSize;
     1640    newEnumMoniker->currentPos = currentPos;
     1641
     1642    newEnumMoniker->tabMoniker =(IMoniker**)HeapAlloc(GetProcessHeap(),0,tabSize*sizeof(IMoniker));
    16191643
    16201644    if (newEnumMoniker->tabMoniker==NULL)
Note: See TracChangeset for help on using the changeset viewer.