Implemented the OLE object default handler and data cache.

This commit is contained in:
Francis Beaudet 1999-05-02 09:27:08 +00:00 committed by Alexandre Julliard
parent 585c8466ab
commit ebdea25edc
11 changed files with 3810 additions and 169 deletions

View File

@ -1752,7 +1752,7 @@ static HRESULT WINAPI ISVViewObject_Draw(
HDC hdcDraw,
LPCRECTL lprcBounds,
LPCRECTL lprcWBounds,
pfnContinue pfnContinue,
IVO_ContCallback pfnContinue,
DWORD dwContinue)
{

View File

@ -40,7 +40,13 @@ HRESULT WINAPI ReadClassStm(IStream *pStm,REFCLSID pclsid);
HRESULT WINAPI OleSave(LPPERSISTSTORAGE pPS, LPSTORAGE pStg, BOOL fSameAsLoad);
HRESULT WINAPI OleRegGetUserType(REFCLSID clsid,
DWORD dwFormOfType,
LPOLESTR* pszUserType);
HRESULT WINAPI OleRegGetMiscStatus (REFCLSID clsid, DWORD dwAspect, DWORD* pdwStatus);
HRESULT WINAPI OleRegEnumFormatEtc (REFCLSID clsid,
DWORD dwDirection,
LPENUMFORMATETC* ppenumFormatetc);
HRESULT WINAPI CreateStreamOnHGlobal (HGLOBAL hGlobal, BOOL fDeleteOnRelease, LPSTREAM* ppstm);
HRESULT WINAPI OleRegEnumVerbs (REFCLSID clsid, LPENUMOLEVERB* ppenum);
BOOL WINAPI OleIsRunning(LPOLEOBJECT pObject);
@ -79,6 +85,11 @@ HRESULT WINAPI WriteFmtUserTypeStg(LPSTORAGE pstg, CLIPFORMAT cf, LPOLESTR l
HRESULT WINAPI OleTranslateAccelerator (LPOLEINPLACEFRAME lpFrame, LPOLEINPLACEFRAMEINFO lpFrameInfo, LPMSG lpmsg);
HRESULT WINAPI OleCreateFromData(LPDATAOBJECT pSrcDataObj, REFIID riid, DWORD renderopt, LPFORMATETC pFormatEtc,
LPOLECLIENTSITE pClientSite, LPSTORAGE pStg, LPVOID* ppvObj);
HRESULT WINAPI OleCreateDefaultHandler(REFCLSID clsid,
LPUNKNOWN pUnkOuter,
REFIID riid,
LPVOID* ppvObj);
HRESULT WINAPI CreateOleAdviseHolder (LPOLEADVISEHOLDER *ppOAHolder);
#endif /* __WINE_OLE2_H */

View File

@ -109,7 +109,7 @@ ICOM_DEFINE(IOleObject,IUnknown)
#define IOleObject_AddRef(p) ICOM_CALL (AddRef,p)
#define IOleObject_Release(p) ICOM_CALL (Release,p)
/*** IOleObject methods ***/
#define IOleObject_SetClientSite(p,a,b,c,d) ICOM_CALL1(SetClientSite,p,a)
#define IOleObject_SetClientSite(p,a) ICOM_CALL1(SetClientSite,p,a)
#define IOleObject_GetClientSite(p,a,b) ICOM_CALL1(GetClientSite,p,a)
#define IOleObject_SetHostNames(p,a,b) ICOM_CALL2(SetHostNames,p,a,b)
#define IOleObject_Close(p,a,b) ICOM_CALL1(Close,p,a)
@ -156,12 +156,12 @@ ICOM_DEFINE(IOleAdviseHolder,IUnknown)
#define IOleAdviseHolder_AddRef(p) ICOM_CALL (AddRef,p)
#define IOleAdviseHolder_Release(p) ICOM_CALL (Release,p)
/*** IOleAdviseHolder methods ***/
#define IOleAdviseHolder_Advise(p,a,b) ICOM_CALL2(UpdateCache,p,a,b)
#define IOleAdviseHolder_Unadvise(p,a) ICOM_CALL1(OnStop,p,a)
#define IOleAdviseHolder_EnumAdvise(p,a) ICOM_CALL1(OnStop,p,a)
#define IOleAdviseHolder_SendOnRename(p,a) ICOM_CALL1(OnStop,p,a)
#define IOleAdviseHolder_SendOnSave(p) ICOM_CALL (OnStop,p)
#define IOleAdviseHolder_SendOnClose(p) ICOM_CALL (OnStop,p)
#define IOleAdviseHolder_Advise(p,a,b) ICOM_CALL2(Advise,p,a,b)
#define IOleAdviseHolder_Unadvise(p,a) ICOM_CALL1(Unadvise,p,a)
#define IOleAdviseHolder_EnumAdvise(p,a) ICOM_CALL1(EnumAdvise,p,a)
#define IOleAdviseHolder_SendOnRename(p,a) ICOM_CALL1(SendOnRename,p,a)
#define IOleAdviseHolder_SendOnSave(p) ICOM_CALL (SendOnSave,p)
#define IOleAdviseHolder_SendOnClose(p) ICOM_CALL (SendOnClose,p)
#endif

View File

@ -29,11 +29,11 @@ typedef struct IViewObject2 IViewObject2, *LPVIEWOBJECT2;
/*****************************************************************************
* IViewObject interface
*/
typedef BOOL (CALLBACK* pfnContinue)(DWORD);
typedef BOOL (CALLBACK* IVO_ContCallback)(DWORD);
#define ICOM_INTERFACE IViewObject
#define IViewObject_METHODS \
ICOM_METHOD10(HRESULT,Draw, DWORD,dwDrawAspect, LONG,lindex, void*,pvAspect, DVTARGETDEVICE*,ptd, HDC,hdcTargetDev, HDC,hdcDraw, LPCRECTL,lprcBounds, LPCRECTL,lprcWBounds, pfnContinue,, DWORD,dwContinue) \
ICOM_METHOD10(HRESULT,Draw, DWORD,dwDrawAspect, LONG,lindex, void*,pvAspect, DVTARGETDEVICE*,ptd, HDC,hdcTargetDev, HDC,hdcDraw, LPCRECTL,lprcBounds, LPCRECTL,lprcWBounds, IVO_ContCallback, pfnContinue, DWORD,dwContinue) \
ICOM_METHOD6(HRESULT,GetColorSet, DWORD,dwDrawAspect, LONG,lindex, void*,pvAspect, DVTARGETDEVICE*,ptd, HDC,hicTargetDevice, LOGPALETTE**,ppColorSet) \
ICOM_METHOD4(HRESULT,Freeze, DWORD,dwDrawAspect, LONG,lindex, void*,pvAspect, DWORD*,pdwFreeze) \
ICOM_METHOD1(HRESULT,Unfreeze, DWORD,dwFreeze) \

View File

@ -10,6 +10,8 @@ C_SRCS = \
bindctx.c \
compobj.c \
compositemoniker.c \
datacache.c \
defaulthandler.c \
filemoniker.c \
guid.c \
hglobalstream.c \

1304
ole/datacache.c Normal file

File diff suppressed because it is too large Load Diff

1659
ole/defaulthandler.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -7,6 +7,8 @@
*/
#include <assert.h>
#include <stdlib.h>
#include <strings.h>
#include "winuser.h"
#include "winerror.h"
@ -17,6 +19,7 @@
#include "wine/obj_clientserver.h"
#include "debug.h"
#include "ole2ver.h"
#include "winreg.h"
DEFAULT_DEBUG_CHANNEL(ole)
@ -84,6 +87,11 @@ static const char OLEDD_DRAGTRACKERCLASS[] = "WineDragDropTracker32";
*/
static DropTargetNode* targetListHead = NULL;
/******************************************************************************
* These are the prototypes of miscelaneous utility methods
*/
static void OLEUTL_ReadRegistryDWORDValue(HKEY regKey, DWORD* pdwValue);
/******************************************************************************
* These are the prototypes of the utility methods used to manage a shared menu
*/
@ -373,13 +381,96 @@ HRESULT WINAPI RevokeDragDrop(
/***********************************************************************
* OleRegGetUserType (OLE32.122)
*
* This implementation of OleRegGetUserType ignores the dwFormOfType
* parameter and always returns the full name of the object. This is
* not too bad since this is the case for many objects because of the
* way they are registered.
*/
HRESULT WINAPI OleRegGetUserType(
REFCLSID clsid,
DWORD dwFormOfType,
LPOLESTR* pszUserType)
{
FIXME(ole,",stub!\n");
char xclsid[50];
char keyName[60];
DWORD dwKeyType;
DWORD cbData;
HKEY clsidKey;
LONG hres;
/*
* Initialize the out parameter.
*/
*pszUserType = NULL;
/*
* Build the key name we're looking for
*/
WINE_StringFromCLSID((LPCLSID)clsid, xclsid);
strcpy(keyName, "CLSID\\");
strcat(keyName, xclsid);
strcat(keyName, "\\");
TRACE(ole,"(%s, %ld, %p)\n", keyName, dwFormOfType, pszUserType);
/*
* Open the class id Key
*/
hres = RegOpenKeyA(HKEY_CLASSES_ROOT,
keyName,
&clsidKey);
if (hres != ERROR_SUCCESS)
return REGDB_E_CLASSNOTREG;
/*
* Retrieve the size of the name string.
*/
cbData = 0;
hres = RegQueryValueExA(clsidKey,
"",
NULL,
&dwKeyType,
NULL,
&cbData);
if (hres!=ERROR_SUCCESS)
{
RegCloseKey(clsidKey);
return REGDB_E_READREGDB;
}
/*
* Allocate a buffer for the registry value.
*/
*pszUserType = CoTaskMemAlloc(cbData);
if (*pszUserType==NULL)
{
RegCloseKey(clsidKey);
return E_OUTOFMEMORY;
}
hres = RegQueryValueExA(HKEY_CLASSES_ROOT,
"",
NULL,
&dwKeyType,
(LPBYTE)*pszUserType,
&cbData);
RegCloseKey(clsidKey);
if (hres!=ERROR_SUCCESS)
{
CoTaskMemFree(*pszUserType);
*pszUserType=NULL;
return REGDB_E_READREGDB;
}
return S_OK;
}
@ -492,8 +583,193 @@ HRESULT WINAPI OleRegGetMiscStatus(
DWORD dwAspect,
DWORD* pdwStatus)
{
FIXME(ole,"(),stub!\n");
char xclsid[50];
char keyName[60];
HKEY clsidKey;
HKEY miscStatusKey;
HKEY aspectKey;
LONG result;
/*
* Initialize the out parameter.
*/
*pdwStatus = 0;
/*
* Build the key name we're looking for
*/
WINE_StringFromCLSID((LPCLSID)clsid, xclsid);
strcpy(keyName, "CLSID\\");
strcat(keyName, xclsid);
strcat(keyName, "\\");
TRACE(ole,"(%s, %ld, %p)\n", keyName, dwAspect, pdwStatus);
/*
* Open the class id Key
*/
result = RegOpenKeyA(HKEY_CLASSES_ROOT,
keyName,
&clsidKey);
if (result != ERROR_SUCCESS)
return REGDB_E_CLASSNOTREG;
/*
* Get the MiscStatus
*/
result = RegOpenKeyA(clsidKey,
"MiscStatus",
&miscStatusKey);
if (result != ERROR_SUCCESS)
{
RegCloseKey(clsidKey);
return REGDB_E_READREGDB;
}
/*
* Read the default value
*/
OLEUTL_ReadRegistryDWORDValue(miscStatusKey, pdwStatus);
/*
* Open the key specific to the requested aspect.
*/
sprintf(keyName, "%ld", dwAspect);
result = RegOpenKeyA(miscStatusKey,
keyName,
&aspectKey);
if (result == ERROR_SUCCESS)
{
OLEUTL_ReadRegistryDWORDValue(aspectKey, pdwStatus);
RegCloseKey(aspectKey);
}
/*
* Cleanup
*/
RegCloseKey(miscStatusKey);
RegCloseKey(clsidKey);
return S_OK;
}
/******************************************************************************
* OleSetContainedObject [OLE32.128]
*/
HRESULT WINAPI OleSetContainedObject(
LPUNKNOWN pUnknown,
BOOL fContained)
{
IRunnableObject* runnable = NULL;
HRESULT hres;
TRACE(ole,"(%p,%x), stub!\n", pUnknown, fContained);
hres = IUnknown_QueryInterface(pUnknown,
&IID_IRunnableObject,
(void**)&runnable);
if (SUCCEEDED(hres))
{
hres = IRunnableObject_SetContainedObject(runnable, fContained);
IRunnableObject_Release(runnable);
return hres;
}
return S_OK;
}
/******************************************************************************
* OleLoad [OLE32.112]
*/
HRESULT WINAPI OleLoad(
LPSTORAGE pStg,
REFIID riid,
LPOLECLIENTSITE pClientSite,
LPVOID* ppvObj)
{
IPersistStorage* persistStorage = NULL;
IOleObject* oleObject = NULL;
STATSTG storageInfo;
HRESULT hres;
TRACE(ole,"(%p,%p,%p,%p)\n", pStg, riid, pClientSite, ppvObj);
/*
* TODO, Conversion ... OleDoAutoConvert
*/
/*
* Get the class ID for the object.
*/
hres = IStorage_Stat(pStg, &storageInfo, STATFLAG_NONAME);
/*
* Now, try and create the handler for the object
*/
hres = CoCreateInstance(&storageInfo.clsid,
NULL,
CLSCTX_INPROC_HANDLER,
&IID_IOleObject,
(void**)&oleObject);
/*
* If that fails, as it will most times, load the default
* OLE handler.
*/
if (FAILED(hres))
{
hres = OleCreateDefaultHandler(&storageInfo.clsid,
NULL,
&IID_IOleObject,
(void**)&oleObject);
}
/*
* If we couldn't find a handler... this is bad. Abort the whole thing.
*/
if (FAILED(hres))
return hres;
/*
* Inform the new object of it's client site.
*/
hres = IOleObject_SetClientSite(oleObject, pClientSite);
/*
* Initialize the object with it's IPersistStorage interface.
*/
hres = IOleObject_QueryInterface(oleObject,
&IID_IPersistStorage,
(void**)&persistStorage);
if (SUCCEEDED(hres))
{
IPersistStorage_Load(persistStorage, pStg);
IPersistStorage_Release(persistStorage);
persistStorage = NULL;
}
/*
* Return the requested interface to the caller.
*/
hres = IOleObject_QueryInterface(oleObject, riid, ppvObj);
/*
* Cleanup interfaces used internally
*/
IOleObject_Release(oleObject);
return hres;
}
/***********************************************************************
@ -1739,4 +2015,49 @@ static DWORD OLEDD_GetButtonState()
return keyMask;
}
/***
* OLEDD_GetButtonState()
*
* This method will read the default value of the registry key in
* parameter and extract a DWORD value from it. The registry key value
* can be in a string key or a DWORD key.
*
* params:
* regKey - Key to read the default value from
* pdwValue - Pointer to the location where the DWORD
* value is returned. This value is not modified
* if the value is not found.
*/
static void OLEUTL_ReadRegistryDWORDValue(
HKEY regKey,
DWORD* pdwValue)
{
char buffer[20];
DWORD dwKeyType;
DWORD cbData = 20;
LONG lres;
lres = RegQueryValueExA(regKey,
"",
NULL,
&dwKeyType,
(LPBYTE)buffer,
&cbData);
if (lres==ERROR_SUCCESS)
{
switch (dwKeyType)
{
case REG_DWORD:
*pdwValue = *(DWORD*)buffer;
break;
case REG_EXPAND_SZ:
case REG_MULTI_SZ:
case REG_SZ:
*pdwValue = (DWORD)strtoul(buffer, NULL, 10);
break;
}
}
}

View File

@ -159,24 +159,6 @@ HRESULT WINAPI OleQueryCreateFromData(LPDATAOBJECT pSrcDataObject)
return S_OK;
}
/******************************************************************************
* CreateDataAdviseHolder [OLE32.53]
*/
HRESULT WINAPI CreateDataAdviseHolder(LPDATAADVISEHOLDER* ppDAHolder)
{
FIXME(ole,"(%p), stub!\n", ppDAHolder);
return S_OK;
}
/******************************************************************************
* OleLoad [OLE32.112]
*/
HRESULT WINAPI OleLoad(LPSTORAGE pStg, REFIID riid, LPOLECLIENTSITE pClientSite, LPVOID* ppvObj)
{
FIXME(ole,"(%p,%p,%p,%p), stub!\n", pStg, riid, pClientSite, ppvObj);
return S_OK;
}
/******************************************************************************
* ReadFmtUserTypeStg [OLE32.136]
*/
@ -206,15 +188,6 @@ HRESULT WINAPI OleRun(LPUNKNOWN pUnknown)
return S_OK;
}
/******************************************************************************
* OleSetContainedObject [OLE32.128]
*/
HRESULT WINAPI OleSetContainedObject(LPUNKNOWN pUnknown, BOOL fContained)
{
FIXME(ole,"(%p,%x), stub!\n", pUnknown, fContained);
return S_OK;
}
/******************************************************************************
* OleCreateLinkFromData [OLE32.95]
*/
@ -228,15 +201,6 @@ HRESULT WINAPI OleCreateLinkFromData(LPDATAOBJECT pSrcDataObj, REFIID riid,
return S_OK;
}
/******************************************************************************
* CreateDataCache [OLE32.54]
*/
HRESULT WINAPI CreateDataCache(LPUNKNOWN pUnkOuter, REFCLSID rclsid, REFIID iid, LPVOID* ppv)
{
FIXME(ole,"(%p,%p,%p,%p), stub!\n", pUnkOuter, rclsid, iid, ppv);
return S_OK;
}
/******************************************************************************
* OleIsRunning [OLE32.111]
*/
@ -255,6 +219,19 @@ HRESULT WINAPI OleRegEnumVerbs (REFCLSID clsid, LPENUMOLEVERB* ppenum)
return S_OK;
}
/***********************************************************************
* OleRegEnumFormatEtc [OLE32.119]
*/
HRESULT WINAPI OleRegEnumFormatEtc (
REFCLSID clsid,
DWORD dwDirection,
LPENUMFORMATETC* ppenumFormatetc)
{
FIXME(ole,"(%p, %ld, %p), stub!\n", clsid, dwDirection, ppenumFormatetc);
return S_OK;
}
/***********************************************************************
* OleSave [OLE32.124]
*/

View File

@ -2,6 +2,7 @@
* OLE2 COM objects
*
* Copyright 1998 Eric Kohl
* Copyright 1999 Francis Beaudet
*/
@ -15,150 +16,273 @@ DEFAULT_DEBUG_CHANNEL(ole)
/**************************************************************************
* IOleAdviseHolder Implementation
* OleAdviseHolderImpl Implementation
*/
typedef struct
typedef struct OleAdviseHolderImpl
{
ICOM_VTABLE(IOleAdviseHolder)* lpvtbl;
DWORD ref;
} IOleAdviseHolderImpl;
static HRESULT WINAPI IOleAdviseHolder_fnQueryInterface(LPOLEADVISEHOLDER,REFIID,LPVOID*);
static ULONG WINAPI IOleAdviseHolder_fnAddRef(LPOLEADVISEHOLDER);
static ULONG WINAPI IOleAdviseHolder_fnRelease(LPOLEADVISEHOLDER);
static HRESULT WINAPI IOleAdviseHolder_fnAdvise(LPOLEADVISEHOLDER, IAdviseSink*, DWORD*);
static HRESULT WINAPI IOleAdviseHolder_fnUnadvise (LPOLEADVISEHOLDER, DWORD);
static HRESULT WINAPI IOleAdviseHolder_fnEnumAdvise (LPOLEADVISEHOLDER, IEnumSTATDATA **);
static HRESULT WINAPI IOleAdviseHolder_fnSendOnRename (LPOLEADVISEHOLDER, IMoniker *);
static HRESULT WINAPI IOleAdviseHolder_fnSendOnSave (LPOLEADVISEHOLDER);
static HRESULT WINAPI IOleAdviseHolder_fnSendOnClose (LPOLEADVISEHOLDER);
DWORD ref;
DWORD maxSinks;
IAdviseSink** arrayOfSinks;
} OleAdviseHolderImpl;
static LPOLEADVISEHOLDER OleAdviseHolderImpl_Constructor();
static void OleAdviseHolderImpl_Destructor(OleAdviseHolderImpl* ptrToDestroy);
static HRESULT WINAPI OleAdviseHolderImpl_QueryInterface(LPOLEADVISEHOLDER,REFIID,LPVOID*);
static ULONG WINAPI OleAdviseHolderImpl_AddRef(LPOLEADVISEHOLDER);
static ULONG WINAPI OleAdviseHolderImpl_Release(LPOLEADVISEHOLDER);
static HRESULT WINAPI OleAdviseHolderImpl_Advise(LPOLEADVISEHOLDER, IAdviseSink*, DWORD*);
static HRESULT WINAPI OleAdviseHolderImpl_Unadvise (LPOLEADVISEHOLDER, DWORD);
static HRESULT WINAPI OleAdviseHolderImpl_EnumAdvise (LPOLEADVISEHOLDER, IEnumSTATDATA **);
static HRESULT WINAPI OleAdviseHolderImpl_SendOnRename (LPOLEADVISEHOLDER, IMoniker *);
static HRESULT WINAPI OleAdviseHolderImpl_SendOnSave (LPOLEADVISEHOLDER);
static HRESULT WINAPI OleAdviseHolderImpl_SendOnClose (LPOLEADVISEHOLDER);
/**************************************************************************
* IOleAdviseHolder_VTable
* OleAdviseHolderImpl_VTable
*/
static struct ICOM_VTABLE(IOleAdviseHolder) oahvt =
{
IOleAdviseHolder_fnQueryInterface,
IOleAdviseHolder_fnAddRef,
IOleAdviseHolder_fnRelease,
IOleAdviseHolder_fnAdvise,
IOleAdviseHolder_fnUnadvise,
IOleAdviseHolder_fnEnumAdvise,
IOleAdviseHolder_fnSendOnRename,
IOleAdviseHolder_fnSendOnSave,
IOleAdviseHolder_fnSendOnClose
OleAdviseHolderImpl_QueryInterface,
OleAdviseHolderImpl_AddRef,
OleAdviseHolderImpl_Release,
OleAdviseHolderImpl_Advise,
OleAdviseHolderImpl_Unadvise,
OleAdviseHolderImpl_EnumAdvise,
OleAdviseHolderImpl_SendOnRename,
OleAdviseHolderImpl_SendOnSave,
OleAdviseHolderImpl_SendOnClose
};
/**************************************************************************
* IOleAdviseHolder_Constructor
* OleAdviseHolderImpl_Constructor
*/
LPOLEADVISEHOLDER IOleAdviseHolder_Constructor()
static LPOLEADVISEHOLDER OleAdviseHolderImpl_Constructor()
{
IOleAdviseHolderImpl* lpoah;
OleAdviseHolderImpl* lpoah;
DWORD index;
lpoah= (OleAdviseHolderImpl*)HeapAlloc(GetProcessHeap(),
0,
sizeof(OleAdviseHolderImpl));
lpoah= (IOleAdviseHolderImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IOleAdviseHolderImpl));
lpoah->ref = 1;
lpoah->lpvtbl = &oahvt;
FIXME (ole, "(%p)->()\n", lpoah);
lpoah->ref = 1;
lpoah->maxSinks = 10;
lpoah->arrayOfSinks = HeapAlloc(GetProcessHeap(),
0,
lpoah->maxSinks * sizeof(IAdviseSink*));
for (index = 0; index < lpoah->maxSinks; index++)
lpoah->arrayOfSinks[index]=0;
return (LPOLEADVISEHOLDER)lpoah;
}
/**************************************************************************
* IOleAdviseHolder_QueryInterface
* OleAdviseHolderImpl_Destructor
*/
static HRESULT WINAPI
IOleAdviseHolder_fnQueryInterface (LPOLEADVISEHOLDER iface, REFIID riid, LPVOID *ppvObj)
static void OleAdviseHolderImpl_Destructor(
OleAdviseHolderImpl* ptrToDestroy)
{
ICOM_THIS(IOleAdviseHolderImpl, iface);
char xriid[50];
WINE_StringFromCLSID((LPCLSID)riid,xriid);
FIXME (ole, "(%p)->(\n\tIID:\t%s)\n", This, xriid);
DWORD index;
for (index = 0; index < ptrToDestroy->maxSinks; index++)
{
if (ptrToDestroy->arrayOfSinks[index]!=0)
{
IAdviseSink_Release(ptrToDestroy->arrayOfSinks[index]);
ptrToDestroy->arrayOfSinks[index] = NULL;
}
}
HeapFree(GetProcessHeap(),
0,
ptrToDestroy->arrayOfSinks);
HeapFree(GetProcessHeap(),
0,
ptrToDestroy);
}
/**************************************************************************
* OleAdviseHolderImpl_QueryInterface
*/
static HRESULT WINAPI OleAdviseHolderImpl_QueryInterface(
LPOLEADVISEHOLDER iface,
REFIID riid,
LPVOID* ppvObj)
{
ICOM_THIS(OleAdviseHolderImpl, iface);
/*
* Sanity check
*/
if (ppvObj==NULL)
return E_POINTER;
*ppvObj = NULL;
if(IsEqualIID(riid, &IID_IUnknown)) {
if (IsEqualIID(riid, &IID_IUnknown))
{
/* IUnknown */
*ppvObj = This;
}
else if(IsEqualIID(riid, &IID_IOleAdviseHolder)) {
else if(IsEqualIID(riid, &IID_IOleAdviseHolder))
{
/* IOleAdviseHolder */
*ppvObj = (IOleAdviseHolder*) This;
}
if(*ppvObj) {
(*(LPOLEADVISEHOLDER*)ppvObj)->lpvtbl->fnAddRef(iface);
FIXME (ole, "-- Interface: (%p)->(%p)\n", ppvObj, *ppvObj);
return S_OK;
}
FIXME (ole, "-- Interface: E_NOINTERFACE\n");
if(*ppvObj == NULL)
return E_NOINTERFACE;
/*
* A successful QI always increments the reference count.
*/
IUnknown_AddRef((IUnknown*)*ppvObj);
return S_OK;
}
/******************************************************************************
* IOleAdviseHolder_AddRef
* OleAdviseHolderImpl_AddRef
*/
static ULONG WINAPI
IOleAdviseHolder_fnAddRef (LPOLEADVISEHOLDER iface)
static ULONG WINAPI OleAdviseHolderImpl_AddRef(
LPOLEADVISEHOLDER iface)
{
ICOM_THIS(IOleAdviseHolderImpl, iface);
FIXME (ole, "(%p)->(count=%lu)\n", This, This->ref);
ICOM_THIS(OleAdviseHolderImpl, iface);
return ++(This->ref);
}
/******************************************************************************
* IOleAdviseHolder_Release
* OleAdviseHolderImpl_Release
*/
static ULONG WINAPI
IOleAdviseHolder_fnRelease (LPOLEADVISEHOLDER iface)
static ULONG WINAPI OleAdviseHolderImpl_Release(
LPOLEADVISEHOLDER iface)
{
ICOM_THIS(IOleAdviseHolderImpl, iface);
FIXME (ole, "(%p)->(count=%lu)\n", This, This->ref);
if (!--(This->ref)) {
FIXME (ole, "-- destroying IOleAdviseHolder(%p)\n", This);
HeapFree(GetProcessHeap(),0,This);
ICOM_THIS(OleAdviseHolderImpl, iface);
This->ref--;
if (This->ref == 0)
{
OleAdviseHolderImpl_Destructor(This);
return 0;
}
return This->ref;
}
/******************************************************************************
* IOleAdviseHolder_Advise
* OleAdviseHolderImpl_Advise
*/
static HRESULT WINAPI
IOleAdviseHolder_fnAdvise (LPOLEADVISEHOLDER iface,
IAdviseSink *pAdvise, DWORD *pdwConnection)
static HRESULT WINAPI OleAdviseHolderImpl_Advise(
LPOLEADVISEHOLDER iface,
IAdviseSink* pAdvise,
DWORD* pdwConnection)
{
ICOM_THIS(IOleAdviseHolderImpl, iface);
FIXME (ole, "(%p)->(%p %p)\n", This, pAdvise, pdwConnection);
DWORD index;
ICOM_THIS(OleAdviseHolderImpl, iface);
TRACE(ole, "(%p, %p, %p)\n", This, pAdvise, pdwConnection);
/*
* Sanity check
*/
if (pdwConnection==NULL)
return E_POINTER;
*pdwConnection = 0;
return S_OK;
}
/******************************************************************************
* IOleAdviseHolder_Unadvise
/*
* Find a free spot in the array.
*/
static HRESULT WINAPI
IOleAdviseHolder_fnUnadvise (LPOLEADVISEHOLDER iface, DWORD dwConnection)
{
ICOM_THIS(IOleAdviseHolderImpl, iface);
FIXME (ole, "(%p)->(%lu)\n", This, dwConnection);
for (index = 0; index < This->maxSinks; index++)
{
if (This->arrayOfSinks[index]==NULL)
break;
}
/*
* If the array is full, we need to grow it.
*/
if (index == This->maxSinks)
{
DWORD i;
This->maxSinks+=10;
This->arrayOfSinks = HeapReAlloc(GetProcessHeap(),
0,
This->arrayOfSinks,
This->maxSinks*sizeof(IAdviseSink*));
for (i=index;i < This->maxSinks; i++)
This->arrayOfSinks[i]=0;
}
/*
* Store the new sink
*/
This->arrayOfSinks[index] = pAdvise;
if (This->arrayOfSinks[index]!=NULL)
IAdviseSink_AddRef(This->arrayOfSinks[index]);
/*
* Return the index as the cookie.
*/
*pdwConnection = index;
return S_OK;
}
/******************************************************************************
* IOleAdviseHolder_EnumAdvise
* OleAdviseHolderImpl_Unadvise
*/
static HRESULT WINAPI OleAdviseHolderImpl_Unadvise(
LPOLEADVISEHOLDER iface,
DWORD dwConnection)
{
ICOM_THIS(OleAdviseHolderImpl, iface);
TRACE(ole, "(%p, %lu)\n", This, dwConnection);
/*
* Check for invalid cookies.
*/
if (dwConnection >= This->maxSinks)
return OLE_E_NOCONNECTION;
if (This->arrayOfSinks[dwConnection] == NULL)
return OLE_E_NOCONNECTION;
/*
* Release the sink and mark the spot in the list as free.
*/
IAdviseSink_Release(This->arrayOfSinks[dwConnection]);
This->arrayOfSinks[dwConnection] = NULL;
return S_OK;
}
/******************************************************************************
* OleAdviseHolderImpl_EnumAdvise
*/
static HRESULT WINAPI
IOleAdviseHolder_fnEnumAdvise (LPOLEADVISEHOLDER iface, IEnumSTATDATA **ppenumAdvise)
OleAdviseHolderImpl_EnumAdvise (LPOLEADVISEHOLDER iface, IEnumSTATDATA **ppenumAdvise)
{
ICOM_THIS(IOleAdviseHolderImpl, iface);
ICOM_THIS(OleAdviseHolderImpl, iface);
FIXME (ole, "(%p)->(%p)\n", This, ppenumAdvise);
*ppenumAdvise = NULL;
@ -167,12 +291,12 @@ IOleAdviseHolder_fnEnumAdvise (LPOLEADVISEHOLDER iface, IEnumSTATDATA **ppenumAd
}
/******************************************************************************
* IOleAdviseHolder_SendOnRename
* OleAdviseHolderImpl_SendOnRename
*/
static HRESULT WINAPI
IOleAdviseHolder_fnSendOnRename (LPOLEADVISEHOLDER iface, IMoniker *pmk)
OleAdviseHolderImpl_SendOnRename (LPOLEADVISEHOLDER iface, IMoniker *pmk)
{
ICOM_THIS(IOleAdviseHolderImpl, iface);
ICOM_THIS(OleAdviseHolderImpl, iface);
FIXME (ole, "(%p)->(%p)\n", This, pmk);
@ -180,12 +304,12 @@ IOleAdviseHolder_fnSendOnRename (LPOLEADVISEHOLDER iface, IMoniker *pmk)
}
/******************************************************************************
* IOleAdviseHolder_SendOnSave
* OleAdviseHolderImpl_SendOnSave
*/
static HRESULT WINAPI
IOleAdviseHolder_fnSendOnSave (LPOLEADVISEHOLDER iface)
OleAdviseHolderImpl_SendOnSave (LPOLEADVISEHOLDER iface)
{
ICOM_THIS(IOleAdviseHolderImpl, iface);
ICOM_THIS(OleAdviseHolderImpl, iface);
FIXME (ole, "(%p)\n", This);
@ -193,18 +317,232 @@ IOleAdviseHolder_fnSendOnSave (LPOLEADVISEHOLDER iface)
}
/******************************************************************************
* IOleAdviseHolder_SendOnClose
* OleAdviseHolderImpl_SendOnClose
*/
static HRESULT WINAPI
IOleAdviseHolder_fnSendOnClose (LPOLEADVISEHOLDER iface)
OleAdviseHolderImpl_SendOnClose (LPOLEADVISEHOLDER iface)
{
ICOM_THIS(IOleAdviseHolderImpl, iface);
ICOM_THIS(OleAdviseHolderImpl, iface);
FIXME (ole, "(%p)\n", This);
return S_OK;
}
/**************************************************************************
* DataAdviseHolder Implementation
*/
typedef struct DataAdviseHolder
{
ICOM_VTABLE(IDataAdviseHolder)* lpvtbl;
DWORD ref;
} DataAdviseHolder;
/**************************************************************************
* DataAdviseHolder method prototypes
*/
static IDataAdviseHolder* DataAdviseHolder_Constructor();
static void DataAdviseHolder_Destructor(DataAdviseHolder* ptrToDestroy);
static HRESULT WINAPI DataAdviseHolder_QueryInterface(
IDataAdviseHolder* iface,
REFIID riid,
void** ppvObject);
static ULONG WINAPI DataAdviseHolder_AddRef(
IDataAdviseHolder* iface);
static ULONG WINAPI DataAdviseHolder_Release(
IDataAdviseHolder* iface);
static HRESULT WINAPI DataAdviseHolder_Advise(
IDataAdviseHolder* iface,
IDataObject* pDataObject,
FORMATETC* pFetc,
DWORD advf,
IAdviseSink* pAdvise,
DWORD* pdwConnection);
static HRESULT WINAPI DataAdviseHolder_Unadvise(
IDataAdviseHolder* iface,
DWORD dwConnection);
static HRESULT WINAPI DataAdviseHolder_EnumAdvise(
IDataAdviseHolder* iface,
IEnumSTATDATA** ppenumAdvise);
static HRESULT WINAPI DataAdviseHolder_SendOnDataChange(
IDataAdviseHolder* iface,
IDataObject* pDataObject,
DWORD dwReserved,
DWORD advf);
/**************************************************************************
* DataAdviseHolderImpl_VTable
*/
static struct ICOM_VTABLE(IDataAdviseHolder) DataAdviseHolderImpl_VTable =
{
DataAdviseHolder_QueryInterface,
DataAdviseHolder_AddRef,
DataAdviseHolder_Release,
DataAdviseHolder_Advise,
DataAdviseHolder_Unadvise,
DataAdviseHolder_EnumAdvise,
DataAdviseHolder_SendOnDataChange
};
/******************************************************************************
* DataAdviseHolder_Constructor
*/
static IDataAdviseHolder* DataAdviseHolder_Constructor()
{
DataAdviseHolder* newHolder;
newHolder = (DataAdviseHolder*)HeapAlloc(GetProcessHeap(),
0,
sizeof(DataAdviseHolder));
newHolder->lpvtbl = &DataAdviseHolderImpl_VTable;
newHolder->ref = 1;
return (IDataAdviseHolder*)newHolder;
}
/******************************************************************************
* DataAdviseHolder_Destructor
*/
static void DataAdviseHolder_Destructor(
DataAdviseHolder* ptrToDestroy)
{
HeapFree(GetProcessHeap(),
0,
ptrToDestroy);
}
/************************************************************************
* DataAdviseHolder_QueryInterface (IUnknown)
*
* See Windows documentation for more details on IUnknown methods.
*/
static HRESULT WINAPI DataAdviseHolder_QueryInterface(
IDataAdviseHolder* iface,
REFIID riid,
void** ppvObject)
{
ICOM_THIS(DataAdviseHolder, iface);
/*
* Perform a sanity check on the parameters.
*/
if ( (This==0) || (ppvObject==0) )
return E_INVALIDARG;
/*
* Initialize the return parameter.
*/
*ppvObject = 0;
/*
* Compare the riid with the interface IDs implemented by this object.
*/
if ( (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0) ||
(memcmp(&IID_IDataAdviseHolder, riid, sizeof(IID_IDataAdviseHolder)) == 0) )
{
*ppvObject = iface;
}
/*
* Check that we obtained an interface.
*/
if ((*ppvObject)==0)
{
return E_NOINTERFACE;
}
/*
* Query Interface always increases the reference count by one when it is
* successful.
*/
IUnknown_AddRef((IUnknown*)*ppvObject);
return S_OK;;
}
/************************************************************************
* DataAdviseHolder_AddRef (IUnknown)
*
* See Windows documentation for more details on IUnknown methods.
*/
static ULONG WINAPI DataAdviseHolder_AddRef(
IDataAdviseHolder* iface)
{
ICOM_THIS(DataAdviseHolder, iface);
This->ref++;
return This->ref;
}
/************************************************************************
* DataAdviseHolder_Release (IUnknown)
*
* See Windows documentation for more details on IUnknown methods.
*/
static ULONG WINAPI DataAdviseHolder_Release(
IDataAdviseHolder* iface)
{
ICOM_THIS(DataAdviseHolder, iface);
/*
* Decrease the reference count on this object.
*/
This->ref--;
/*
* If the reference count goes down to 0, perform suicide.
*/
if (This->ref==0)
{
DataAdviseHolder_Destructor(This);
return 0;
}
return This->ref;
}
static HRESULT WINAPI DataAdviseHolder_Advise(
IDataAdviseHolder* iface,
IDataObject* pDataObject,
FORMATETC* pFetc,
DWORD advf,
IAdviseSink* pAdvise,
DWORD* pdwConnection)
{
FIXME(ole, "(): stub\n");
return E_NOTIMPL;
}
static HRESULT WINAPI DataAdviseHolder_Unadvise(
IDataAdviseHolder* iface,
DWORD dwConnection)
{
FIXME(ole, "(): stub\n");
return E_NOTIMPL;
}
static HRESULT WINAPI DataAdviseHolder_EnumAdvise(
IDataAdviseHolder* iface,
IEnumSTATDATA** ppenumAdvise)
{
FIXME(ole, "(): stub\n");
return E_NOTIMPL;
}
static HRESULT WINAPI DataAdviseHolder_SendOnDataChange(
IDataAdviseHolder* iface,
IDataObject* pDataObject,
DWORD dwReserved,
DWORD advf)
{
FIXME(ole, "(): stub\n");
return E_NOTIMPL;
}
/***********************************************************************
* API functions
*/
@ -212,15 +550,44 @@ IOleAdviseHolder_fnSendOnClose (LPOLEADVISEHOLDER iface)
/***********************************************************************
* CreateOleAdviseHolder [OLE32.59]
*/
HRESULT WINAPI CreateOleAdviseHolder (LPOLEADVISEHOLDER *ppOAHolder)
HRESULT WINAPI CreateOleAdviseHolder(
LPOLEADVISEHOLDER *ppOAHolder)
{
FIXME(ole,"(%p): stub!\n", ppOAHolder);
TRACE(ole, "(%p)\n", ppOAHolder);
*ppOAHolder = IOleAdviseHolder_Constructor ();
if (*ppOAHolder)
/*
* Sanity check,
*/
if (ppOAHolder==NULL)
return E_POINTER;
*ppOAHolder = OleAdviseHolderImpl_Constructor ();
if (*ppOAHolder != NULL)
return S_OK;
return E_OUTOFMEMORY;
}
/******************************************************************************
* CreateDataAdviseHolder [OLE32.53]
*/
HRESULT WINAPI CreateDataAdviseHolder(
LPDATAADVISEHOLDER* ppDAHolder)
{
TRACE(ole,"(%p)\n", ppDAHolder);
/*
* Sanity check,
*/
if (ppDAHolder==NULL)
return E_POINTER;
*ppDAHolder = DataAdviseHolder_Constructor();
if (*ppDAHolder != NULL)
return S_OK;
*ppOAHolder = 0;
return E_OUTOFMEMORY;
}

View File

@ -90,7 +90,7 @@ type win32
87 stub OleConvertOLESTREAMToIStorage
88 stub OleConvertOLESTREAMToIStorageEx
89 stdcall OleCreate(ptr ptr long ptr ptr ptr ptr) OleCreate
90 stub OleCreateDefaultHandler
90 stdcall OleCreateDefaultHandler(ptr ptr ptr ptr) OleCreateDefaultHandler
91 stub OleCreateEmbeddingHelper
92 stdcall OleCreateFromData(ptr ptr long ptr ptr ptr ptr) OleCreateFromData
93 stdcall OleCreateFromFile(ptr ptr ptr long ptr ptr ptr ptr) OleCreateFromFile
@ -119,7 +119,7 @@ type win32
116 stub OleNoteObjectVisible
117 stdcall OleQueryCreateFromData(ptr) OleQueryCreateFromData
118 stdcall OleQueryLinkFromData(ptr) OleQueryLinkFromData
119 stub OleRegEnumFormatEtc
119 stdcall OleRegEnumFormatEtc(ptr long ptr) OleRegEnumFormatEtc
120 stdcall OleRegEnumVerbs(long ptr) OleRegEnumVerbs
121 stdcall OleRegGetMiscStatus(ptr long ptr) OleRegGetMiscStatus
122 stdcall OleRegGetUserType(long long ptr) OleRegGetUserType