Commit ebdea25e authored by Francis Beaudet's avatar Francis Beaudet Committed by Alexandre Julliard

Implemented the OLE object default handler and data cache.

parent 585c8466
......@@ -1752,7 +1752,7 @@ static HRESULT WINAPI ISVViewObject_Draw(
HDC hdcDraw,
LPCRECTL lprcBounds,
LPCRECTL lprcWBounds,
pfnContinue pfnContinue,
IVO_ContCallback pfnContinue,
DWORD dwContinue)
{
......
......@@ -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 */
......@@ -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
......
......@@ -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) \
......
......@@ -10,6 +10,8 @@ C_SRCS = \
bindctx.c \
compobj.c \
compositemoniker.c \
datacache.c \
defaulthandler.c \
filemoniker.c \
guid.c \
hglobalstream.c \
......
This diff is collapsed. Click to expand it.
......@@ -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)
......@@ -85,6 +88,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
*/
static void OLEMenu_Initialize();
......@@ -373,14 +381,97 @@ 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");
return S_OK;
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");
return REGDB_E_CLASSNOTREG;
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;
}
}
}
......@@ -160,24 +160,6 @@ HRESULT WINAPI OleQueryCreateFromData(LPDATAOBJECT pSrcDataObject)
}
/******************************************************************************
* 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]
*/
HRESULT WINAPI ReadFmtUserTypeStg (LPSTORAGE pstg, CLIPFORMAT* pcf, LPOLESTR* lplpszUserType)
......@@ -207,15 +189,6 @@ HRESULT WINAPI OleRun(LPUNKNOWN pUnknown)
}
/******************************************************************************
* OleSetContainedObject [OLE32.128]
*/
HRESULT WINAPI OleSetContainedObject(LPUNKNOWN pUnknown, BOOL fContained)
{
FIXME(ole,"(%p,%x), stub!\n", pUnknown, fContained);
return S_OK;
}
/******************************************************************************
* OleCreateLinkFromData [OLE32.95]
*/
......@@ -229,15 +202,6 @@ HRESULT WINAPI OleCreateLinkFromData(LPDATAOBJECT pSrcDataObj, REFIID riid,
}
/******************************************************************************
* 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]
*/
BOOL WINAPI OleIsRunning(LPOLEOBJECT pObject)
......@@ -256,6 +220,19 @@ HRESULT WINAPI OleRegEnumVerbs (REFCLSID clsid, LPENUMOLEVERB* ppenum)
}
/***********************************************************************
* 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]
*/
HRESULT WINAPI OleSave(
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment