1999-05-02 11:27:08 +02:00
|
|
|
/*
|
|
|
|
* OLE 2 Data cache
|
|
|
|
*
|
|
|
|
* Copyright 1999 Francis Beaudet
|
2000-05-24 01:34:40 +02:00
|
|
|
* Copyright 2000 Abey George
|
1999-05-02 11:27:08 +02:00
|
|
|
*
|
2002-03-10 00:29:33 +01:00
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*
|
1999-05-02 11:27:08 +02:00
|
|
|
* NOTES:
|
|
|
|
* The OLE2 data cache supports a whole whack of
|
|
|
|
* interfaces including:
|
|
|
|
* IDataObject, IPersistStorage, IViewObject2,
|
|
|
|
* IOleCache2 and IOleCacheControl.
|
|
|
|
*
|
1999-05-08 12:55:32 +02:00
|
|
|
* Most of the implementation details are taken from: Inside OLE
|
1999-05-02 11:27:08 +02:00
|
|
|
* second edition by Kraig Brockschmidt,
|
|
|
|
*
|
1999-05-08 12:55:32 +02:00
|
|
|
* NOTES
|
|
|
|
* - This implementation of the datacache will let your application
|
|
|
|
* load documents that have embedded OLE objects in them and it will
|
2002-06-01 01:06:46 +02:00
|
|
|
* also retrieve the metafile representation of those objects.
|
1999-05-08 12:55:32 +02:00
|
|
|
* - This implementation of the datacache will also allow your
|
|
|
|
* application to save new documents with OLE objects in them.
|
2002-06-01 01:06:46 +02:00
|
|
|
* - The main thing that it doesn't do is allow you to activate
|
1999-05-08 12:55:32 +02:00
|
|
|
* or modify the OLE objects in any way.
|
|
|
|
* - I haven't found any good documentation on the real usage of
|
|
|
|
* the streams created by the data cache. In particular, How to
|
|
|
|
* determine what the XXX stands for in the stream name
|
2000-03-19 13:42:58 +01:00
|
|
|
* "\002OlePresXXX". It appears to just be a counter.
|
1999-05-08 12:55:32 +02:00
|
|
|
* - Also, I don't know the real content of the presentation stream
|
2002-06-01 01:06:46 +02:00
|
|
|
* header. I was able to figure-out where the extent of the object
|
2000-03-19 13:42:58 +01:00
|
|
|
* was stored and the aspect, but that's about it.
|
1999-05-02 11:27:08 +02:00
|
|
|
*/
|
|
|
|
#include <assert.h>
|
2001-01-26 21:43:40 +01:00
|
|
|
#include <string.h>
|
2000-02-10 20:39:48 +01:00
|
|
|
#include "windef.h"
|
1999-08-18 20:35:57 +02:00
|
|
|
#include "winbase.h"
|
2000-02-10 20:39:48 +01:00
|
|
|
#include "wingdi.h"
|
2000-05-24 01:34:40 +02:00
|
|
|
#include "winuser.h"
|
1999-05-02 11:27:08 +02:00
|
|
|
#include "winerror.h"
|
2000-09-26 02:00:55 +02:00
|
|
|
#include "wine/obj_base.h"
|
|
|
|
#include "wine/obj_misc.h"
|
|
|
|
#include "wine/obj_storage.h"
|
|
|
|
#include "wine/obj_moniker.h"
|
|
|
|
#include "wine/obj_dataobject.h"
|
1999-08-18 20:35:57 +02:00
|
|
|
#include "wine/obj_oleview.h"
|
|
|
|
#include "wine/obj_cache.h"
|
2000-06-13 03:10:29 +02:00
|
|
|
#include "wine/unicode.h"
|
2000-05-24 01:34:40 +02:00
|
|
|
#include "ole2.h"
|
2002-03-10 00:29:33 +01:00
|
|
|
#include "wine/debug.h"
|
1999-05-02 11:27:08 +02:00
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(ole);
|
1999-05-02 11:27:08 +02:00
|
|
|
|
|
|
|
/****************************************************************************
|
1999-05-08 12:55:32 +02:00
|
|
|
* PresentationDataHeader
|
|
|
|
*
|
|
|
|
* This structure represents the header of the \002OlePresXXX stream in
|
|
|
|
* the OLE object strorage.
|
|
|
|
*
|
|
|
|
* Most fields are still unknown.
|
1999-05-02 11:27:08 +02:00
|
|
|
*/
|
1999-05-08 12:55:32 +02:00
|
|
|
typedef struct PresentationDataHeader
|
1999-05-02 11:27:08 +02:00
|
|
|
{
|
2000-03-19 13:42:58 +01:00
|
|
|
DWORD unknown1; /* -1 */
|
|
|
|
DWORD unknown2; /* 3, possibly CF_METAFILEPICT */
|
|
|
|
DWORD unknown3; /* 4, possibly TYMED_ISTREAM */
|
|
|
|
DVASPECT dvAspect;
|
|
|
|
DWORD unknown5; /* -1 */
|
1999-05-08 12:55:32 +02:00
|
|
|
|
|
|
|
DWORD unknown6;
|
2000-03-19 13:42:58 +01:00
|
|
|
DWORD unknown7; /* 0 */
|
2000-05-24 01:34:40 +02:00
|
|
|
DWORD dwObjectExtentX;
|
|
|
|
DWORD dwObjectExtentY;
|
|
|
|
DWORD dwSize;
|
1999-05-08 12:55:32 +02:00
|
|
|
} PresentationDataHeader;
|
1999-05-02 11:27:08 +02:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* DataCache
|
|
|
|
*/
|
|
|
|
struct DataCache
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* List all interface VTables here
|
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
ICOM_VTABLE(IDataObject)* lpvtbl1;
|
1999-05-02 11:27:08 +02:00
|
|
|
ICOM_VTABLE(IUnknown)* lpvtbl2;
|
|
|
|
ICOM_VTABLE(IPersistStorage)* lpvtbl3;
|
2002-06-01 01:06:46 +02:00
|
|
|
ICOM_VTABLE(IViewObject2)* lpvtbl4;
|
1999-05-02 11:27:08 +02:00
|
|
|
ICOM_VTABLE(IOleCache2)* lpvtbl5;
|
|
|
|
ICOM_VTABLE(IOleCacheControl)* lpvtbl6;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Reference count of this object
|
|
|
|
*/
|
|
|
|
ULONG ref;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* IUnknown implementation of the outer object.
|
|
|
|
*/
|
|
|
|
IUnknown* outerUnknown;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This storage pointer is set through a call to
|
|
|
|
* IPersistStorage_Load. This is where the visual
|
|
|
|
* representation of the object is stored.
|
|
|
|
*/
|
|
|
|
IStorage* presentationStorage;
|
1999-05-08 12:55:32 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* The user of this object can setup ONE advise sink
|
|
|
|
* connection with the object. These parameters describe
|
|
|
|
* that connection.
|
|
|
|
*/
|
|
|
|
DWORD sinkAspects;
|
|
|
|
DWORD sinkAdviseFlag;
|
|
|
|
IAdviseSink* sinkInterface;
|
|
|
|
|
1999-05-02 11:27:08 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct DataCache DataCache;
|
|
|
|
|
|
|
|
/*
|
2002-06-01 01:06:46 +02:00
|
|
|
* Here, I define utility macros to help with the casting of the
|
1999-05-02 11:27:08 +02:00
|
|
|
* "this" parameter.
|
|
|
|
* There is a version to accomodate all of the VTables implemented
|
|
|
|
* by this object.
|
|
|
|
*/
|
|
|
|
#define _ICOM_THIS_From_IDataObject(class,name) class* this = (class*)name;
|
2002-06-01 01:06:46 +02:00
|
|
|
#define _ICOM_THIS_From_NDIUnknown(class, name) class* this = (class*)(((char*)name)-sizeof(void*));
|
|
|
|
#define _ICOM_THIS_From_IPersistStorage(class, name) class* this = (class*)(((char*)name)-2*sizeof(void*));
|
|
|
|
#define _ICOM_THIS_From_IViewObject2(class, name) class* this = (class*)(((char*)name)-3*sizeof(void*));
|
|
|
|
#define _ICOM_THIS_From_IOleCache2(class, name) class* this = (class*)(((char*)name)-4*sizeof(void*));
|
|
|
|
#define _ICOM_THIS_From_IOleCacheControl(class, name) class* this = (class*)(((char*)name)-5*sizeof(void*));
|
1999-05-02 11:27:08 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Prototypes for the methods of the DataCache class.
|
|
|
|
*/
|
|
|
|
static DataCache* DataCache_Construct(REFCLSID clsid,
|
|
|
|
LPUNKNOWN pUnkOuter);
|
|
|
|
static void DataCache_Destroy(DataCache* ptrToDestroy);
|
1999-05-08 12:55:32 +02:00
|
|
|
static HRESULT DataCache_ReadPresentationData(DataCache* this,
|
|
|
|
DWORD drawAspect,
|
|
|
|
PresentationDataHeader* header);
|
2000-03-19 13:42:58 +01:00
|
|
|
static HRESULT DataCache_OpenPresStream(DataCache *this,
|
|
|
|
DWORD drawAspect,
|
|
|
|
IStream **pStm);
|
1999-05-08 12:55:32 +02:00
|
|
|
static HMETAFILE DataCache_ReadPresMetafile(DataCache* this,
|
|
|
|
DWORD drawAspect);
|
|
|
|
static void DataCache_FireOnViewChange(DataCache* this,
|
|
|
|
DWORD aspect,
|
|
|
|
LONG lindex);
|
1999-05-02 11:27:08 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Prototypes for the methods of the DataCache class
|
|
|
|
* that implement non delegating IUnknown methods.
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI DataCache_NDIUnknown_QueryInterface(
|
|
|
|
IUnknown* iface,
|
|
|
|
REFIID riid,
|
|
|
|
void** ppvObject);
|
2002-06-01 01:06:46 +02:00
|
|
|
static ULONG WINAPI DataCache_NDIUnknown_AddRef(
|
1999-05-02 11:27:08 +02:00
|
|
|
IUnknown* iface);
|
2002-06-01 01:06:46 +02:00
|
|
|
static ULONG WINAPI DataCache_NDIUnknown_Release(
|
1999-05-02 11:27:08 +02:00
|
|
|
IUnknown* iface);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Prototypes for the methods of the DataCache class
|
|
|
|
* that implement IDataObject methods.
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI DataCache_IDataObject_QueryInterface(
|
|
|
|
IDataObject* iface,
|
|
|
|
REFIID riid,
|
|
|
|
void** ppvObject);
|
2002-06-01 01:06:46 +02:00
|
|
|
static ULONG WINAPI DataCache_IDataObject_AddRef(
|
1999-05-02 11:27:08 +02:00
|
|
|
IDataObject* iface);
|
2002-06-01 01:06:46 +02:00
|
|
|
static ULONG WINAPI DataCache_IDataObject_Release(
|
1999-05-02 11:27:08 +02:00
|
|
|
IDataObject* iface);
|
|
|
|
static HRESULT WINAPI DataCache_GetData(
|
|
|
|
IDataObject* iface,
|
2002-06-01 01:06:46 +02:00
|
|
|
LPFORMATETC pformatetcIn,
|
1999-05-02 11:27:08 +02:00
|
|
|
STGMEDIUM* pmedium);
|
|
|
|
static HRESULT WINAPI DataCache_GetDataHere(
|
2002-06-01 01:06:46 +02:00
|
|
|
IDataObject* iface,
|
1999-05-02 11:27:08 +02:00
|
|
|
LPFORMATETC pformatetc,
|
|
|
|
STGMEDIUM* pmedium);
|
|
|
|
static HRESULT WINAPI DataCache_QueryGetData(
|
|
|
|
IDataObject* iface,
|
|
|
|
LPFORMATETC pformatetc);
|
|
|
|
static HRESULT WINAPI DataCache_GetCanonicalFormatEtc(
|
2002-06-01 01:06:46 +02:00
|
|
|
IDataObject* iface,
|
|
|
|
LPFORMATETC pformatectIn,
|
1999-05-02 11:27:08 +02:00
|
|
|
LPFORMATETC pformatetcOut);
|
|
|
|
static HRESULT WINAPI DataCache_IDataObject_SetData(
|
|
|
|
IDataObject* iface,
|
2002-06-01 01:06:46 +02:00
|
|
|
LPFORMATETC pformatetc,
|
|
|
|
STGMEDIUM* pmedium,
|
1999-05-02 11:27:08 +02:00
|
|
|
BOOL fRelease);
|
|
|
|
static HRESULT WINAPI DataCache_EnumFormatEtc(
|
2002-06-01 01:06:46 +02:00
|
|
|
IDataObject* iface,
|
1999-05-02 11:27:08 +02:00
|
|
|
DWORD dwDirection,
|
|
|
|
IEnumFORMATETC** ppenumFormatEtc);
|
|
|
|
static HRESULT WINAPI DataCache_DAdvise(
|
2002-06-01 01:06:46 +02:00
|
|
|
IDataObject* iface,
|
|
|
|
FORMATETC* pformatetc,
|
|
|
|
DWORD advf,
|
|
|
|
IAdviseSink* pAdvSink,
|
1999-05-02 11:27:08 +02:00
|
|
|
DWORD* pdwConnection);
|
|
|
|
static HRESULT WINAPI DataCache_DUnadvise(
|
|
|
|
IDataObject* iface,
|
|
|
|
DWORD dwConnection);
|
|
|
|
static HRESULT WINAPI DataCache_EnumDAdvise(
|
|
|
|
IDataObject* iface,
|
|
|
|
IEnumSTATDATA** ppenumAdvise);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Prototypes for the methods of the DataCache class
|
|
|
|
* that implement IPersistStorage methods.
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI DataCache_IPersistStorage_QueryInterface(
|
|
|
|
IPersistStorage* iface,
|
|
|
|
REFIID riid,
|
|
|
|
void** ppvObject);
|
2002-06-01 01:06:46 +02:00
|
|
|
static ULONG WINAPI DataCache_IPersistStorage_AddRef(
|
1999-05-02 11:27:08 +02:00
|
|
|
IPersistStorage* iface);
|
2002-06-01 01:06:46 +02:00
|
|
|
static ULONG WINAPI DataCache_IPersistStorage_Release(
|
1999-05-02 11:27:08 +02:00
|
|
|
IPersistStorage* iface);
|
2002-06-01 01:06:46 +02:00
|
|
|
static HRESULT WINAPI DataCache_GetClassID(
|
1999-07-31 15:13:23 +02:00
|
|
|
IPersistStorage* iface,
|
1999-05-02 11:27:08 +02:00
|
|
|
CLSID* pClassID);
|
2002-06-01 01:06:46 +02:00
|
|
|
static HRESULT WINAPI DataCache_IsDirty(
|
1999-05-02 11:27:08 +02:00
|
|
|
IPersistStorage* iface);
|
2002-06-01 01:06:46 +02:00
|
|
|
static HRESULT WINAPI DataCache_InitNew(
|
|
|
|
IPersistStorage* iface,
|
1999-05-02 11:27:08 +02:00
|
|
|
IStorage* pStg);
|
2002-06-01 01:06:46 +02:00
|
|
|
static HRESULT WINAPI DataCache_Load(
|
1999-05-02 11:27:08 +02:00
|
|
|
IPersistStorage* iface,
|
|
|
|
IStorage* pStg);
|
2002-06-01 01:06:46 +02:00
|
|
|
static HRESULT WINAPI DataCache_Save(
|
1999-05-02 11:27:08 +02:00
|
|
|
IPersistStorage* iface,
|
2002-06-01 01:06:46 +02:00
|
|
|
IStorage* pStg,
|
1999-05-02 11:27:08 +02:00
|
|
|
BOOL fSameAsLoad);
|
2002-06-01 01:06:46 +02:00
|
|
|
static HRESULT WINAPI DataCache_SaveCompleted(
|
|
|
|
IPersistStorage* iface,
|
1999-05-02 11:27:08 +02:00
|
|
|
IStorage* pStgNew);
|
|
|
|
static HRESULT WINAPI DataCache_HandsOffStorage(
|
|
|
|
IPersistStorage* iface);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Prototypes for the methods of the DataCache class
|
|
|
|
* that implement IViewObject2 methods.
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI DataCache_IViewObject2_QueryInterface(
|
|
|
|
IViewObject2* iface,
|
|
|
|
REFIID riid,
|
|
|
|
void** ppvObject);
|
2002-06-01 01:06:46 +02:00
|
|
|
static ULONG WINAPI DataCache_IViewObject2_AddRef(
|
1999-05-02 11:27:08 +02:00
|
|
|
IViewObject2* iface);
|
2002-06-01 01:06:46 +02:00
|
|
|
static ULONG WINAPI DataCache_IViewObject2_Release(
|
1999-05-02 11:27:08 +02:00
|
|
|
IViewObject2* iface);
|
|
|
|
static HRESULT WINAPI DataCache_Draw(
|
|
|
|
IViewObject2* iface,
|
|
|
|
DWORD dwDrawAspect,
|
|
|
|
LONG lindex,
|
|
|
|
void* pvAspect,
|
2002-06-01 01:06:46 +02:00
|
|
|
DVTARGETDEVICE* ptd,
|
|
|
|
HDC hdcTargetDev,
|
1999-05-02 11:27:08 +02:00
|
|
|
HDC hdcDraw,
|
|
|
|
LPCRECTL lprcBounds,
|
|
|
|
LPCRECTL lprcWBounds,
|
|
|
|
IVO_ContCallback pfnContinue,
|
|
|
|
DWORD dwContinue);
|
|
|
|
static HRESULT WINAPI DataCache_GetColorSet(
|
2002-06-01 01:06:46 +02:00
|
|
|
IViewObject2* iface,
|
|
|
|
DWORD dwDrawAspect,
|
|
|
|
LONG lindex,
|
|
|
|
void* pvAspect,
|
|
|
|
DVTARGETDEVICE* ptd,
|
|
|
|
HDC hicTargetDevice,
|
1999-05-02 11:27:08 +02:00
|
|
|
LOGPALETTE** ppColorSet);
|
|
|
|
static HRESULT WINAPI DataCache_Freeze(
|
|
|
|
IViewObject2* iface,
|
|
|
|
DWORD dwDrawAspect,
|
|
|
|
LONG lindex,
|
2002-06-01 01:06:46 +02:00
|
|
|
void* pvAspect,
|
1999-05-02 11:27:08 +02:00
|
|
|
DWORD* pdwFreeze);
|
|
|
|
static HRESULT WINAPI DataCache_Unfreeze(
|
|
|
|
IViewObject2* iface,
|
|
|
|
DWORD dwFreeze);
|
|
|
|
static HRESULT WINAPI DataCache_SetAdvise(
|
|
|
|
IViewObject2* iface,
|
2002-06-01 01:06:46 +02:00
|
|
|
DWORD aspects,
|
|
|
|
DWORD advf,
|
1999-05-02 11:27:08 +02:00
|
|
|
IAdviseSink* pAdvSink);
|
|
|
|
static HRESULT WINAPI DataCache_GetAdvise(
|
2002-06-01 01:06:46 +02:00
|
|
|
IViewObject2* iface,
|
|
|
|
DWORD* pAspects,
|
|
|
|
DWORD* pAdvf,
|
1999-05-02 11:27:08 +02:00
|
|
|
IAdviseSink** ppAdvSink);
|
|
|
|
static HRESULT WINAPI DataCache_GetExtent(
|
2002-06-01 01:06:46 +02:00
|
|
|
IViewObject2* iface,
|
|
|
|
DWORD dwDrawAspect,
|
|
|
|
LONG lindex,
|
|
|
|
DVTARGETDEVICE* ptd,
|
1999-05-02 11:27:08 +02:00
|
|
|
LPSIZEL lpsizel);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Prototypes for the methods of the DataCache class
|
|
|
|
* that implement IOleCache2 methods.
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI DataCache_IOleCache2_QueryInterface(
|
|
|
|
IOleCache2* iface,
|
|
|
|
REFIID riid,
|
|
|
|
void** ppvObject);
|
2002-06-01 01:06:46 +02:00
|
|
|
static ULONG WINAPI DataCache_IOleCache2_AddRef(
|
1999-05-02 11:27:08 +02:00
|
|
|
IOleCache2* iface);
|
2002-06-01 01:06:46 +02:00
|
|
|
static ULONG WINAPI DataCache_IOleCache2_Release(
|
1999-05-02 11:27:08 +02:00
|
|
|
IOleCache2* iface);
|
|
|
|
static HRESULT WINAPI DataCache_Cache(
|
|
|
|
IOleCache2* iface,
|
|
|
|
FORMATETC* pformatetc,
|
|
|
|
DWORD advf,
|
|
|
|
DWORD* pdwConnection);
|
|
|
|
static HRESULT WINAPI DataCache_Uncache(
|
|
|
|
IOleCache2* iface,
|
|
|
|
DWORD dwConnection);
|
|
|
|
static HRESULT WINAPI DataCache_EnumCache(
|
|
|
|
IOleCache2* iface,
|
|
|
|
IEnumSTATDATA** ppenumSTATDATA);
|
|
|
|
static HRESULT WINAPI DataCache_InitCache(
|
|
|
|
IOleCache2* iface,
|
|
|
|
IDataObject* pDataObject);
|
|
|
|
static HRESULT WINAPI DataCache_IOleCache2_SetData(
|
|
|
|
IOleCache2* iface,
|
|
|
|
FORMATETC* pformatetc,
|
|
|
|
STGMEDIUM* pmedium,
|
|
|
|
BOOL fRelease);
|
|
|
|
static HRESULT WINAPI DataCache_UpdateCache(
|
|
|
|
IOleCache2* iface,
|
2002-06-01 01:06:46 +02:00
|
|
|
LPDATAOBJECT pDataObject,
|
1999-05-02 11:27:08 +02:00
|
|
|
DWORD grfUpdf,
|
|
|
|
LPVOID pReserved);
|
|
|
|
static HRESULT WINAPI DataCache_DiscardCache(
|
|
|
|
IOleCache2* iface,
|
|
|
|
DWORD dwDiscardOptions);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Prototypes for the methods of the DataCache class
|
|
|
|
* that implement IOleCacheControl methods.
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI DataCache_IOleCacheControl_QueryInterface(
|
|
|
|
IOleCacheControl* iface,
|
|
|
|
REFIID riid,
|
|
|
|
void** ppvObject);
|
2002-06-01 01:06:46 +02:00
|
|
|
static ULONG WINAPI DataCache_IOleCacheControl_AddRef(
|
1999-05-02 11:27:08 +02:00
|
|
|
IOleCacheControl* iface);
|
2002-06-01 01:06:46 +02:00
|
|
|
static ULONG WINAPI DataCache_IOleCacheControl_Release(
|
1999-05-02 11:27:08 +02:00
|
|
|
IOleCacheControl* iface);
|
|
|
|
static HRESULT WINAPI DataCache_OnRun(
|
|
|
|
IOleCacheControl* iface,
|
|
|
|
LPDATAOBJECT pDataObject);
|
|
|
|
static HRESULT WINAPI DataCache_OnStop(
|
|
|
|
IOleCacheControl* iface);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Virtual function tables for the DataCache class.
|
|
|
|
*/
|
|
|
|
static ICOM_VTABLE(IUnknown) DataCache_NDIUnknown_VTable =
|
|
|
|
{
|
1999-05-22 13:41:38 +02:00
|
|
|
ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
|
1999-05-02 11:27:08 +02:00
|
|
|
DataCache_NDIUnknown_QueryInterface,
|
|
|
|
DataCache_NDIUnknown_AddRef,
|
|
|
|
DataCache_NDIUnknown_Release
|
|
|
|
};
|
|
|
|
|
|
|
|
static ICOM_VTABLE(IDataObject) DataCache_IDataObject_VTable =
|
|
|
|
{
|
1999-05-22 13:41:38 +02:00
|
|
|
ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
|
1999-05-02 11:27:08 +02:00
|
|
|
DataCache_IDataObject_QueryInterface,
|
|
|
|
DataCache_IDataObject_AddRef,
|
|
|
|
DataCache_IDataObject_Release,
|
|
|
|
DataCache_GetData,
|
|
|
|
DataCache_GetDataHere,
|
|
|
|
DataCache_QueryGetData,
|
|
|
|
DataCache_GetCanonicalFormatEtc,
|
|
|
|
DataCache_IDataObject_SetData,
|
|
|
|
DataCache_EnumFormatEtc,
|
|
|
|
DataCache_DAdvise,
|
|
|
|
DataCache_DUnadvise,
|
|
|
|
DataCache_EnumDAdvise
|
|
|
|
};
|
|
|
|
|
|
|
|
static ICOM_VTABLE(IPersistStorage) DataCache_IPersistStorage_VTable =
|
|
|
|
{
|
1999-05-22 13:41:38 +02:00
|
|
|
ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
|
1999-05-02 11:27:08 +02:00
|
|
|
DataCache_IPersistStorage_QueryInterface,
|
|
|
|
DataCache_IPersistStorage_AddRef,
|
|
|
|
DataCache_IPersistStorage_Release,
|
|
|
|
DataCache_GetClassID,
|
|
|
|
DataCache_IsDirty,
|
|
|
|
DataCache_InitNew,
|
|
|
|
DataCache_Load,
|
|
|
|
DataCache_Save,
|
|
|
|
DataCache_SaveCompleted,
|
|
|
|
DataCache_HandsOffStorage
|
|
|
|
};
|
|
|
|
|
|
|
|
static ICOM_VTABLE(IViewObject2) DataCache_IViewObject2_VTable =
|
|
|
|
{
|
1999-05-22 13:41:38 +02:00
|
|
|
ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
|
1999-05-02 11:27:08 +02:00
|
|
|
DataCache_IViewObject2_QueryInterface,
|
|
|
|
DataCache_IViewObject2_AddRef,
|
|
|
|
DataCache_IViewObject2_Release,
|
|
|
|
DataCache_Draw,
|
|
|
|
DataCache_GetColorSet,
|
|
|
|
DataCache_Freeze,
|
|
|
|
DataCache_Unfreeze,
|
|
|
|
DataCache_SetAdvise,
|
|
|
|
DataCache_GetAdvise,
|
|
|
|
DataCache_GetExtent
|
|
|
|
};
|
|
|
|
|
|
|
|
static ICOM_VTABLE(IOleCache2) DataCache_IOleCache2_VTable =
|
|
|
|
{
|
1999-05-22 13:41:38 +02:00
|
|
|
ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
|
1999-05-02 11:27:08 +02:00
|
|
|
DataCache_IOleCache2_QueryInterface,
|
|
|
|
DataCache_IOleCache2_AddRef,
|
|
|
|
DataCache_IOleCache2_Release,
|
|
|
|
DataCache_Cache,
|
|
|
|
DataCache_Uncache,
|
|
|
|
DataCache_EnumCache,
|
|
|
|
DataCache_InitCache,
|
|
|
|
DataCache_IOleCache2_SetData,
|
|
|
|
DataCache_UpdateCache,
|
|
|
|
DataCache_DiscardCache
|
|
|
|
};
|
|
|
|
|
|
|
|
static ICOM_VTABLE(IOleCacheControl) DataCache_IOleCacheControl_VTable =
|
|
|
|
{
|
1999-05-22 13:41:38 +02:00
|
|
|
ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
|
1999-05-02 11:27:08 +02:00
|
|
|
DataCache_IOleCacheControl_QueryInterface,
|
|
|
|
DataCache_IOleCacheControl_AddRef,
|
|
|
|
DataCache_IOleCacheControl_Release,
|
|
|
|
DataCache_OnRun,
|
|
|
|
DataCache_OnStop
|
|
|
|
};
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* CreateDataCache [OLE32.54]
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI CreateDataCache(
|
2002-06-01 01:06:46 +02:00
|
|
|
LPUNKNOWN pUnkOuter,
|
|
|
|
REFCLSID rclsid,
|
|
|
|
REFIID riid,
|
1999-05-02 11:27:08 +02:00
|
|
|
LPVOID* ppvObj)
|
|
|
|
{
|
|
|
|
DataCache* newCache = NULL;
|
|
|
|
HRESULT hr = S_OK;
|
|
|
|
|
2000-01-18 06:09:49 +01:00
|
|
|
TRACE("(%s, %p, %s, %p)\n", debugstr_guid(rclsid), pUnkOuter, debugstr_guid(riid), ppvObj);
|
1999-05-02 11:27:08 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Sanity check
|
|
|
|
*/
|
|
|
|
if (ppvObj==0)
|
|
|
|
return E_POINTER;
|
|
|
|
|
|
|
|
*ppvObj = 0;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If this cache is constructed for aggregation, make sure
|
|
|
|
* the caller is requesting the IUnknown interface.
|
|
|
|
* This is necessary because it's the only time the non-delegating
|
|
|
|
* IUnknown pointer can be returned to the outside.
|
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
if ( (pUnkOuter!=NULL) &&
|
1999-05-02 11:27:08 +02:00
|
|
|
(memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) != 0) )
|
|
|
|
return CLASS_E_NOAGGREGATION;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Try to construct a new instance of the class.
|
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
newCache = DataCache_Construct(rclsid,
|
1999-05-02 11:27:08 +02:00
|
|
|
pUnkOuter);
|
|
|
|
|
|
|
|
if (newCache == 0)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Make sure it supports the interface required by the caller.
|
|
|
|
*/
|
|
|
|
hr = IUnknown_QueryInterface((IUnknown*)&(newCache->lpvtbl2), riid, ppvObj);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Release the reference obtained in the constructor. If
|
|
|
|
* the QueryInterface was unsuccessful, it will free the class.
|
|
|
|
*/
|
|
|
|
IUnknown_Release((IUnknown*)&(newCache->lpvtbl2));
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************
|
|
|
|
* Method implementation for DataCache class.
|
|
|
|
*/
|
|
|
|
static DataCache* DataCache_Construct(
|
|
|
|
REFCLSID clsid,
|
|
|
|
LPUNKNOWN pUnkOuter)
|
|
|
|
{
|
|
|
|
DataCache* newObject = 0;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Allocate space for the object.
|
|
|
|
*/
|
|
|
|
newObject = HeapAlloc(GetProcessHeap(), 0, sizeof(DataCache));
|
|
|
|
|
|
|
|
if (newObject==0)
|
|
|
|
return newObject;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-05-02 11:27:08 +02:00
|
|
|
/*
|
|
|
|
* Initialize the virtual function table.
|
|
|
|
*/
|
|
|
|
newObject->lpvtbl1 = &DataCache_IDataObject_VTable;
|
|
|
|
newObject->lpvtbl2 = &DataCache_NDIUnknown_VTable;
|
|
|
|
newObject->lpvtbl3 = &DataCache_IPersistStorage_VTable;
|
|
|
|
newObject->lpvtbl4 = &DataCache_IViewObject2_VTable;
|
|
|
|
newObject->lpvtbl5 = &DataCache_IOleCache2_VTable;
|
|
|
|
newObject->lpvtbl6 = &DataCache_IOleCacheControl_VTable;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-05-02 11:27:08 +02:00
|
|
|
/*
|
2002-06-01 01:06:46 +02:00
|
|
|
* Start with one reference count. The caller of this function
|
1999-05-02 11:27:08 +02:00
|
|
|
* must release the interface pointer when it is done.
|
|
|
|
*/
|
|
|
|
newObject->ref = 1;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialize the outer unknown
|
2002-06-01 01:06:46 +02:00
|
|
|
* We don't keep a reference on the outer unknown since, the way
|
1999-05-02 11:27:08 +02:00
|
|
|
* aggregation works, our lifetime is at least as large as it's
|
|
|
|
* lifetime.
|
|
|
|
*/
|
|
|
|
if (pUnkOuter==NULL)
|
|
|
|
pUnkOuter = (IUnknown*)&(newObject->lpvtbl2);
|
|
|
|
|
|
|
|
newObject->outerUnknown = pUnkOuter;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialize the other members of the structure.
|
|
|
|
*/
|
|
|
|
newObject->presentationStorage = NULL;
|
1999-05-08 12:55:32 +02:00
|
|
|
newObject->sinkAspects = 0;
|
|
|
|
newObject->sinkAdviseFlag = 0;
|
|
|
|
newObject->sinkInterface = 0;
|
1999-05-02 11:27:08 +02:00
|
|
|
|
|
|
|
return newObject;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void DataCache_Destroy(
|
|
|
|
DataCache* ptrToDestroy)
|
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("()\n");
|
1999-05-08 12:55:32 +02:00
|
|
|
|
|
|
|
if (ptrToDestroy->sinkInterface != NULL)
|
|
|
|
{
|
|
|
|
IAdviseSink_Release(ptrToDestroy->sinkInterface);
|
|
|
|
ptrToDestroy->sinkInterface = NULL;
|
|
|
|
}
|
|
|
|
|
1999-05-02 11:27:08 +02:00
|
|
|
if (ptrToDestroy->presentationStorage != NULL)
|
|
|
|
{
|
|
|
|
IStorage_Release(ptrToDestroy->presentationStorage);
|
|
|
|
ptrToDestroy->presentationStorage = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Free the datacache pointer.
|
|
|
|
*/
|
|
|
|
HeapFree(GetProcessHeap(), 0, ptrToDestroy);
|
|
|
|
}
|
|
|
|
|
1999-05-08 12:55:32 +02:00
|
|
|
/************************************************************************
|
|
|
|
* DataCache_ReadPresentationData
|
|
|
|
*
|
2002-06-01 01:06:46 +02:00
|
|
|
* This method will read information for the requested presentation
|
1999-05-08 12:55:32 +02:00
|
|
|
* into the given structure.
|
|
|
|
*
|
|
|
|
* Param:
|
|
|
|
* this - Pointer to the DataCache object
|
|
|
|
* drawAspect - The aspect of the object that we wish to draw.
|
|
|
|
* header - The structure containing information about this
|
|
|
|
* aspect of the object.
|
|
|
|
*/
|
|
|
|
static HRESULT DataCache_ReadPresentationData(
|
|
|
|
DataCache* this,
|
|
|
|
DWORD drawAspect,
|
|
|
|
PresentationDataHeader* header)
|
|
|
|
{
|
|
|
|
IStream* presStream = NULL;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
/*
|
2000-03-19 13:42:58 +01:00
|
|
|
* Open the presentation stream.
|
1999-05-08 12:55:32 +02:00
|
|
|
*/
|
2000-03-19 13:42:58 +01:00
|
|
|
hres = DataCache_OpenPresStream(
|
1999-05-08 12:55:32 +02:00
|
|
|
this,
|
|
|
|
drawAspect,
|
2000-03-19 13:42:58 +01:00
|
|
|
&presStream);
|
1999-05-08 12:55:32 +02:00
|
|
|
|
|
|
|
if (FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
/*
|
2000-03-19 13:42:58 +01:00
|
|
|
* Read the header.
|
1999-05-08 12:55:32 +02:00
|
|
|
*/
|
2000-03-08 19:49:36 +01:00
|
|
|
|
1999-05-08 12:55:32 +02:00
|
|
|
hres = IStream_Read(
|
|
|
|
presStream,
|
|
|
|
header,
|
|
|
|
sizeof(PresentationDataHeader),
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Cleanup.
|
|
|
|
*/
|
|
|
|
IStream_Release(presStream);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We don't want to propagate any other error
|
|
|
|
* code than a failure.
|
|
|
|
*/
|
|
|
|
if (hres!=S_OK)
|
|
|
|
hres = E_FAIL;
|
|
|
|
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* DataCache_FireOnViewChange
|
|
|
|
*
|
|
|
|
* This method will fire an OnViewChange notification to the advise
|
|
|
|
* sink registered with the datacache.
|
|
|
|
*
|
|
|
|
* See IAdviseSink::OnViewChange for more details.
|
|
|
|
*/
|
|
|
|
static void DataCache_FireOnViewChange(
|
|
|
|
DataCache* this,
|
|
|
|
DWORD aspect,
|
|
|
|
LONG lindex)
|
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("(%p, %lx, %ld)\n", this, aspect, lindex);
|
1999-05-08 12:55:32 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* The sink supplies a filter when it registers
|
|
|
|
* we make sure we only send the notifications when that
|
|
|
|
* filter matches.
|
|
|
|
*/
|
|
|
|
if ((this->sinkAspects & aspect) != 0)
|
|
|
|
{
|
|
|
|
if (this->sinkInterface != NULL)
|
|
|
|
{
|
|
|
|
IAdviseSink_OnViewChange(this->sinkInterface,
|
|
|
|
aspect,
|
|
|
|
lindex);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Some sinks want to be unregistered automatically when
|
|
|
|
* the first notification goes out.
|
|
|
|
*/
|
|
|
|
if ( (this->sinkAdviseFlag & ADVF_ONLYONCE) != 0)
|
|
|
|
{
|
|
|
|
IAdviseSink_Release(this->sinkInterface);
|
|
|
|
|
|
|
|
this->sinkInterface = NULL;
|
|
|
|
this->sinkAspects = 0;
|
|
|
|
this->sinkAdviseFlag = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-03-19 13:42:58 +01:00
|
|
|
/* Helper for DataCache_OpenPresStream */
|
|
|
|
static BOOL DataCache_IsPresentationStream(const STATSTG *elem)
|
|
|
|
{
|
|
|
|
/* The presentation streams have names of the form "\002OlePresXXX",
|
|
|
|
* where XXX goes from 000 to 999. */
|
|
|
|
static const WCHAR OlePres[] = { 2,'O','l','e','P','r','e','s' };
|
|
|
|
|
|
|
|
LPCWSTR name = elem->pwcsName;
|
|
|
|
|
|
|
|
return (elem->type == STGTY_STREAM)
|
|
|
|
&& (elem->cbSize.s.LowPart >= sizeof(PresentationDataHeader))
|
2000-06-13 03:10:29 +02:00
|
|
|
&& (strlenW(name) == 11)
|
|
|
|
&& (strncmpW(name, OlePres, 8) == 0)
|
2000-06-23 18:13:33 +02:00
|
|
|
&& (name[8] >= '0') && (name[8] <= '9')
|
|
|
|
&& (name[9] >= '0') && (name[9] <= '9')
|
|
|
|
&& (name[10] >= '0') && (name[10] <= '9');
|
2000-03-19 13:42:58 +01:00
|
|
|
}
|
|
|
|
|
1999-05-08 12:55:32 +02:00
|
|
|
/************************************************************************
|
2000-03-19 13:42:58 +01:00
|
|
|
* DataCache_OpenPresStream
|
1999-05-08 12:55:32 +02:00
|
|
|
*
|
2000-03-19 13:42:58 +01:00
|
|
|
* This method will find the stream for the given presentation. It makes
|
|
|
|
* no attempt at fallback.
|
1999-05-08 12:55:32 +02:00
|
|
|
*
|
|
|
|
* Param:
|
|
|
|
* this - Pointer to the DataCache object
|
|
|
|
* drawAspect - The aspect of the object that we wish to draw.
|
2000-03-19 13:42:58 +01:00
|
|
|
* pStm - A returned stream. It points to the beginning of the
|
|
|
|
* - presentation data, including the header.
|
|
|
|
*
|
|
|
|
* Errors:
|
|
|
|
* S_OK The requested stream has been opened.
|
|
|
|
* OLE_E_BLANK The requested stream could not be found.
|
|
|
|
* Quite a few others I'm too lazy to map correctly.
|
1999-05-08 12:55:32 +02:00
|
|
|
*
|
2000-03-19 13:42:58 +01:00
|
|
|
* Notes:
|
|
|
|
* Algorithm: Scan the elements of the presentation storage, looking
|
|
|
|
* for presentation streams. For each presentation stream,
|
|
|
|
* load the header and check to see if the aspect maches.
|
|
|
|
*
|
|
|
|
* If a fallback is desired, just opening the first presentation stream
|
|
|
|
* is a possibility.
|
1999-05-08 12:55:32 +02:00
|
|
|
*/
|
2000-03-19 13:42:58 +01:00
|
|
|
static HRESULT DataCache_OpenPresStream(
|
|
|
|
DataCache *this,
|
1999-05-08 12:55:32 +02:00
|
|
|
DWORD drawAspect,
|
2000-03-19 13:42:58 +01:00
|
|
|
IStream **ppStm)
|
1999-05-08 12:55:32 +02:00
|
|
|
{
|
2000-03-19 13:42:58 +01:00
|
|
|
STATSTG elem;
|
|
|
|
IEnumSTATSTG *pEnum;
|
|
|
|
HRESULT hr;
|
1999-05-08 12:55:32 +02:00
|
|
|
|
2000-03-19 13:42:58 +01:00
|
|
|
if (!ppStm) return E_POINTER;
|
1999-05-08 12:55:32 +02:00
|
|
|
|
2000-03-19 13:42:58 +01:00
|
|
|
hr = IStorage_EnumElements(this->presentationStorage, 0, NULL, 0, &pEnum);
|
|
|
|
if (FAILED(hr)) return hr;
|
1999-05-08 12:55:32 +02:00
|
|
|
|
2000-03-19 13:42:58 +01:00
|
|
|
while ((hr = IEnumSTATSTG_Next(pEnum, 1, &elem, NULL)) == S_OK)
|
|
|
|
{
|
|
|
|
if (DataCache_IsPresentationStream(&elem))
|
|
|
|
{
|
|
|
|
IStream *pStm;
|
|
|
|
|
|
|
|
hr = IStorage_OpenStream(this->presentationStorage, elem.pwcsName,
|
|
|
|
NULL, STGM_READ | STGM_SHARE_EXCLUSIVE, 0,
|
|
|
|
&pStm);
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
PresentationDataHeader header;
|
|
|
|
ULONG actual_read;
|
|
|
|
|
|
|
|
hr = IStream_Read(pStm, &header, sizeof(header), &actual_read);
|
|
|
|
|
|
|
|
/* can't use SUCCEEDED(hr): S_FALSE counts as an error */
|
|
|
|
if (hr == S_OK && actual_read == sizeof(header)
|
|
|
|
&& header.dvAspect == drawAspect)
|
|
|
|
{
|
|
|
|
/* Rewind the stream before returning it. */
|
|
|
|
LARGE_INTEGER offset;
|
|
|
|
offset.s.LowPart = 0;
|
|
|
|
offset.s.HighPart = 0;
|
|
|
|
IStream_Seek(pStm, offset, STREAM_SEEK_SET, NULL);
|
|
|
|
|
|
|
|
*ppStm = pStm;
|
|
|
|
|
|
|
|
CoTaskMemFree(elem.pwcsName);
|
|
|
|
IEnumSTATSTG_Release(pEnum);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
IStream_Release(pStm);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
CoTaskMemFree(elem.pwcsName);
|
|
|
|
}
|
|
|
|
|
|
|
|
IEnumSTATSTG_Release(pEnum);
|
|
|
|
|
|
|
|
return (hr == S_FALSE ? OLE_E_BLANK : hr);
|
1999-05-08 12:55:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* DataCache_ReadPresentationData
|
|
|
|
*
|
2002-06-01 01:06:46 +02:00
|
|
|
* This method will read information for the requested presentation
|
1999-05-08 12:55:32 +02:00
|
|
|
* into the given structure.
|
|
|
|
*
|
|
|
|
* Param:
|
|
|
|
* this - Pointer to the DataCache object
|
|
|
|
* drawAspect - The aspect of the object that we wish to draw.
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* This method returns a metafile handle if it is successful.
|
|
|
|
* it will return 0 if not.
|
|
|
|
*/
|
|
|
|
static HMETAFILE DataCache_ReadPresMetafile(
|
|
|
|
DataCache* this,
|
|
|
|
DWORD drawAspect)
|
|
|
|
{
|
|
|
|
LARGE_INTEGER offset;
|
|
|
|
IStream* presStream = NULL;
|
|
|
|
HRESULT hres;
|
|
|
|
void* metafileBits;
|
|
|
|
STATSTG streamInfo;
|
|
|
|
HMETAFILE newMetafile = 0;
|
|
|
|
|
|
|
|
/*
|
2000-03-19 13:42:58 +01:00
|
|
|
* Open the presentation stream.
|
1999-05-08 12:55:32 +02:00
|
|
|
*/
|
2000-03-19 13:42:58 +01:00
|
|
|
hres = DataCache_OpenPresStream(
|
2002-06-01 01:06:46 +02:00
|
|
|
this,
|
1999-05-08 12:55:32 +02:00
|
|
|
drawAspect,
|
|
|
|
&presStream);
|
|
|
|
|
|
|
|
if (FAILED(hres))
|
2002-07-29 02:14:59 +02:00
|
|
|
return (HMETAFILE)hres;
|
1999-05-08 12:55:32 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Get the size of the stream.
|
|
|
|
*/
|
|
|
|
hres = IStream_Stat(presStream,
|
|
|
|
&streamInfo,
|
|
|
|
STATFLAG_NONAME);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Skip the header
|
|
|
|
*/
|
1999-09-19 16:20:33 +02:00
|
|
|
offset.s.HighPart = 0;
|
|
|
|
offset.s.LowPart = sizeof(PresentationDataHeader);
|
1999-05-08 12:55:32 +02:00
|
|
|
|
|
|
|
hres = IStream_Seek(
|
|
|
|
presStream,
|
|
|
|
offset,
|
|
|
|
STREAM_SEEK_SET,
|
|
|
|
NULL);
|
|
|
|
|
2000-03-19 13:42:58 +01:00
|
|
|
streamInfo.cbSize.s.LowPart -= offset.s.LowPart;
|
|
|
|
|
1999-05-08 12:55:32 +02:00
|
|
|
/*
|
|
|
|
* Allocate a buffer for the metafile bits.
|
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
metafileBits = HeapAlloc(GetProcessHeap(),
|
|
|
|
0,
|
1999-09-19 16:20:33 +02:00
|
|
|
streamInfo.cbSize.s.LowPart);
|
1999-05-08 12:55:32 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Read the metafile bits.
|
|
|
|
*/
|
|
|
|
hres = IStream_Read(
|
|
|
|
presStream,
|
|
|
|
metafileBits,
|
1999-09-19 16:20:33 +02:00
|
|
|
streamInfo.cbSize.s.LowPart,
|
1999-05-08 12:55:32 +02:00
|
|
|
NULL);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Create a metafile with those bits.
|
|
|
|
*/
|
|
|
|
if (SUCCEEDED(hres))
|
|
|
|
{
|
1999-09-19 16:20:33 +02:00
|
|
|
newMetafile = SetMetaFileBitsEx(streamInfo.cbSize.s.LowPart, metafileBits);
|
1999-05-08 12:55:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Cleanup.
|
|
|
|
*/
|
|
|
|
HeapFree(GetProcessHeap(), 0, metafileBits);
|
|
|
|
IStream_Release(presStream);
|
|
|
|
|
|
|
|
if (newMetafile==0)
|
|
|
|
hres = E_FAIL;
|
|
|
|
|
|
|
|
return newMetafile;
|
|
|
|
}
|
|
|
|
|
1999-05-02 11:27:08 +02:00
|
|
|
/*********************************************************
|
|
|
|
* Method implementation for the non delegating IUnknown
|
|
|
|
* part of the DataCache class.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/************************************************************************
|
1999-05-08 12:55:32 +02:00
|
|
|
* DataCache_NDIUnknown_QueryInterface (IUnknown)
|
1999-05-02 11:27:08 +02:00
|
|
|
*
|
|
|
|
* See Windows documentation for more details on IUnknown methods.
|
|
|
|
*
|
|
|
|
* This version of QueryInterface will not delegate it's implementation
|
|
|
|
* to the outer unknown.
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI DataCache_NDIUnknown_QueryInterface(
|
|
|
|
IUnknown* iface,
|
|
|
|
REFIID riid,
|
|
|
|
void** ppvObject)
|
|
|
|
{
|
|
|
|
_ICOM_THIS_From_NDIUnknown(DataCache, iface);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Perform a sanity check on the parameters.
|
|
|
|
*/
|
|
|
|
if ( (this==0) || (ppvObject==0) )
|
|
|
|
return E_INVALIDARG;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-05-02 11:27:08 +02:00
|
|
|
/*
|
|
|
|
* Initialize the return parameter.
|
|
|
|
*/
|
|
|
|
*ppvObject = 0;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Compare the riid with the interface IDs implemented by this object.
|
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0)
|
1999-05-02 11:27:08 +02:00
|
|
|
{
|
|
|
|
*ppvObject = iface;
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
else if (memcmp(&IID_IDataObject, riid, sizeof(IID_IDataObject)) == 0)
|
1999-05-02 11:27:08 +02:00
|
|
|
{
|
|
|
|
*ppvObject = (IDataObject*)&(this->lpvtbl1);
|
|
|
|
}
|
|
|
|
else if ( (memcmp(&IID_IPersistStorage, riid, sizeof(IID_IPersistStorage)) == 0) ||
|
|
|
|
(memcmp(&IID_IPersist, riid, sizeof(IID_IPersist)) == 0) )
|
|
|
|
{
|
|
|
|
*ppvObject = (IPersistStorage*)&(this->lpvtbl3);
|
|
|
|
}
|
|
|
|
else if ( (memcmp(&IID_IViewObject, riid, sizeof(IID_IViewObject)) == 0) ||
|
|
|
|
(memcmp(&IID_IViewObject2, riid, sizeof(IID_IViewObject2)) == 0) )
|
|
|
|
{
|
|
|
|
*ppvObject = (IViewObject2*)&(this->lpvtbl4);
|
|
|
|
}
|
|
|
|
else if ( (memcmp(&IID_IOleCache, riid, sizeof(IID_IOleCache)) == 0) ||
|
|
|
|
(memcmp(&IID_IOleCache2, riid, sizeof(IID_IOleCache2)) == 0) )
|
|
|
|
{
|
|
|
|
*ppvObject = (IOleCache2*)&(this->lpvtbl5);
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
else if (memcmp(&IID_IOleCacheControl, riid, sizeof(IID_IOleCacheControl)) == 0)
|
1999-05-02 11:27:08 +02:00
|
|
|
{
|
|
|
|
*ppvObject = (IOleCacheControl*)&(this->lpvtbl6);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check that we obtained an interface.
|
|
|
|
*/
|
|
|
|
if ((*ppvObject)==0)
|
|
|
|
{
|
2000-07-16 17:44:22 +02:00
|
|
|
WARN( "() : asking for unsupported interface %s\n", debugstr_guid(riid));
|
1999-05-02 11:27:08 +02:00
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-05-02 11:27:08 +02:00
|
|
|
/*
|
|
|
|
* Query Interface always increases the reference count by one when it is
|
2002-06-01 01:06:46 +02:00
|
|
|
* successful.
|
1999-05-02 11:27:08 +02:00
|
|
|
*/
|
|
|
|
IUnknown_AddRef((IUnknown*)*ppvObject);
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
return S_OK;
|
1999-05-02 11:27:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* DataCache_NDIUnknown_AddRef (IUnknown)
|
|
|
|
*
|
|
|
|
* See Windows documentation for more details on IUnknown methods.
|
|
|
|
*
|
|
|
|
* This version of QueryInterface will not delegate it's implementation
|
|
|
|
* to the outer unknown.
|
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
static ULONG WINAPI DataCache_NDIUnknown_AddRef(
|
1999-05-02 11:27:08 +02:00
|
|
|
IUnknown* iface)
|
|
|
|
{
|
|
|
|
_ICOM_THIS_From_NDIUnknown(DataCache, iface);
|
|
|
|
|
|
|
|
this->ref++;
|
|
|
|
|
|
|
|
return this->ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* DataCache_NDIUnknown_Release (IUnknown)
|
|
|
|
*
|
|
|
|
* See Windows documentation for more details on IUnknown methods.
|
|
|
|
*
|
|
|
|
* This version of QueryInterface will not delegate it's implementation
|
|
|
|
* to the outer unknown.
|
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
static ULONG WINAPI DataCache_NDIUnknown_Release(
|
1999-05-02 11:27:08 +02:00
|
|
|
IUnknown* iface)
|
|
|
|
{
|
|
|
|
_ICOM_THIS_From_NDIUnknown(DataCache, iface);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Decrease the reference count on this object.
|
|
|
|
*/
|
|
|
|
this->ref--;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If the reference count goes down to 0, perform suicide.
|
|
|
|
*/
|
|
|
|
if (this->ref==0)
|
|
|
|
{
|
|
|
|
DataCache_Destroy(this);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-05-02 11:27:08 +02:00
|
|
|
return this->ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************
|
|
|
|
* Method implementation for the IDataObject
|
|
|
|
* part of the DataCache class.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* DataCache_IDataObject_QueryInterface (IUnknown)
|
|
|
|
*
|
|
|
|
* See Windows documentation for more details on IUnknown methods.
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI DataCache_IDataObject_QueryInterface(
|
|
|
|
IDataObject* iface,
|
|
|
|
REFIID riid,
|
|
|
|
void** ppvObject)
|
|
|
|
{
|
|
|
|
_ICOM_THIS_From_IDataObject(DataCache, iface);
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject);
|
1999-05-02 11:27:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* DataCache_IDataObject_AddRef (IUnknown)
|
|
|
|
*
|
|
|
|
* See Windows documentation for more details on IUnknown methods.
|
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
static ULONG WINAPI DataCache_IDataObject_AddRef(
|
1999-05-02 11:27:08 +02:00
|
|
|
IDataObject* iface)
|
|
|
|
{
|
|
|
|
_ICOM_THIS_From_IDataObject(DataCache, iface);
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
return IUnknown_AddRef(this->outerUnknown);
|
1999-05-02 11:27:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* DataCache_IDataObject_Release (IUnknown)
|
|
|
|
*
|
|
|
|
* See Windows documentation for more details on IUnknown methods.
|
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
static ULONG WINAPI DataCache_IDataObject_Release(
|
1999-05-02 11:27:08 +02:00
|
|
|
IDataObject* iface)
|
|
|
|
{
|
|
|
|
_ICOM_THIS_From_IDataObject(DataCache, iface);
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
return IUnknown_Release(this->outerUnknown);
|
1999-05-02 11:27:08 +02:00
|
|
|
}
|
|
|
|
|
2000-05-24 01:34:40 +02:00
|
|
|
/************************************************************************
|
|
|
|
* DataCache_GetData
|
|
|
|
*
|
|
|
|
* Get Data from a source dataobject using format pformatetcIn->cfFormat
|
|
|
|
* See Windows documentation for more details on GetData.
|
|
|
|
* TODO: Currently only CF_METAFILEPICT is implemented
|
|
|
|
*/
|
1999-05-02 11:27:08 +02:00
|
|
|
static HRESULT WINAPI DataCache_GetData(
|
|
|
|
IDataObject* iface,
|
2002-06-01 01:06:46 +02:00
|
|
|
LPFORMATETC pformatetcIn,
|
1999-05-02 11:27:08 +02:00
|
|
|
STGMEDIUM* pmedium)
|
|
|
|
{
|
2000-05-24 01:34:40 +02:00
|
|
|
HRESULT hr = 0;
|
|
|
|
HRESULT hrRet = E_UNEXPECTED;
|
|
|
|
IPersistStorage *pPersistStorage = 0;
|
|
|
|
IStorage *pStorage = 0;
|
|
|
|
IStream *pStream = 0;
|
|
|
|
OLECHAR name[]={ 2, 'O', 'l', 'e', 'P', 'r', 'e', 's', '0', '0', '0', 0};
|
|
|
|
HGLOBAL hGlobalMF = 0;
|
|
|
|
void *mfBits = 0;
|
|
|
|
PresentationDataHeader pdh;
|
|
|
|
METAFILEPICT *mfPict;
|
|
|
|
HMETAFILE hMetaFile = 0;
|
|
|
|
|
|
|
|
if (pformatetcIn->cfFormat == CF_METAFILEPICT)
|
|
|
|
{
|
|
|
|
/* Get the Persist Storage */
|
|
|
|
|
|
|
|
hr = IDataObject_QueryInterface(iface, &IID_IPersistStorage, (void**)&pPersistStorage);
|
|
|
|
|
|
|
|
if (hr != S_OK)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
/* Create a doc file to copy the doc to a storage */
|
|
|
|
|
|
|
|
hr = StgCreateDocfile(NULL, STGM_CREATE | STGM_READWRITE | STGM_SHARE_EXCLUSIVE, 0, &pStorage);
|
|
|
|
|
|
|
|
if (hr != S_OK)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
/* Save it to storage */
|
|
|
|
|
|
|
|
hr = OleSave(pPersistStorage, pStorage, FALSE);
|
|
|
|
|
|
|
|
if (hr != S_OK)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
/* Open the Presentation data srteam */
|
|
|
|
|
|
|
|
hr = IStorage_OpenStream(pStorage, name, 0, STGM_CREATE|STGM_SHARE_EXCLUSIVE|STGM_READWRITE, 0, &pStream);
|
|
|
|
|
|
|
|
if (hr != S_OK)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
/* Read the presentation header */
|
|
|
|
|
|
|
|
hr = IStream_Read(pStream, &pdh, sizeof(PresentationDataHeader), NULL);
|
|
|
|
|
|
|
|
if (hr != S_OK)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
mfBits = HeapAlloc(GetProcessHeap(), 0, pdh.dwSize);
|
|
|
|
|
|
|
|
/* Read the Metafile bits */
|
|
|
|
|
|
|
|
hr = IStream_Read(pStream, mfBits, pdh.dwSize, NULL);
|
|
|
|
|
|
|
|
if (hr != S_OK)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
/* Create the metafile and place it in the STGMEDIUM structure */
|
|
|
|
|
|
|
|
hMetaFile = SetMetaFileBitsEx(pdh.dwSize, mfBits);
|
|
|
|
|
|
|
|
hGlobalMF = GlobalAlloc(GMEM_SHARE|GMEM_MOVEABLE, sizeof(METAFILEPICT));
|
|
|
|
mfPict = (METAFILEPICT *)GlobalLock(hGlobalMF);
|
|
|
|
mfPict->hMF = hMetaFile;
|
|
|
|
|
|
|
|
GlobalUnlock(hGlobalMF);
|
|
|
|
|
|
|
|
pmedium->u.hGlobal = hGlobalMF;
|
|
|
|
pmedium->tymed = TYMED_MFPICT;
|
|
|
|
hrRet = S_OK;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
|
|
|
|
if (mfBits)
|
|
|
|
HeapFree(GetProcessHeap(), 0, mfBits);
|
|
|
|
|
|
|
|
if (pStream)
|
|
|
|
IStream_Release(pStream);
|
|
|
|
|
|
|
|
if (pStorage)
|
|
|
|
IStorage_Release(pStorage);
|
|
|
|
|
|
|
|
if (pPersistStorage)
|
|
|
|
IPersistStorage_Release(pPersistStorage);
|
|
|
|
|
|
|
|
return hrRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* TODO: Other formats are not implemented */
|
|
|
|
|
1999-05-02 11:27:08 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI DataCache_GetDataHere(
|
2002-06-01 01:06:46 +02:00
|
|
|
IDataObject* iface,
|
1999-05-02 11:27:08 +02:00
|
|
|
LPFORMATETC pformatetc,
|
|
|
|
STGMEDIUM* pmedium)
|
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
FIXME("stub\n");
|
1999-05-02 11:27:08 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI DataCache_QueryGetData(
|
|
|
|
IDataObject* iface,
|
|
|
|
LPFORMATETC pformatetc)
|
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
FIXME("stub\n");
|
1999-05-02 11:27:08 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* DataCache_EnumFormatEtc (IDataObject)
|
|
|
|
*
|
|
|
|
* The data cache doesn't implement this method.
|
|
|
|
*
|
|
|
|
* See Windows documentation for more details on IDataObject methods.
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI DataCache_GetCanonicalFormatEtc(
|
2002-06-01 01:06:46 +02:00
|
|
|
IDataObject* iface,
|
|
|
|
LPFORMATETC pformatectIn,
|
1999-05-02 11:27:08 +02:00
|
|
|
LPFORMATETC pformatetcOut)
|
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("()\n");
|
1999-05-02 11:27:08 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* DataCache_IDataObject_SetData (IDataObject)
|
|
|
|
*
|
|
|
|
* This method is delegated to the IOleCache2 implementation.
|
|
|
|
*
|
|
|
|
* See Windows documentation for more details on IDataObject methods.
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI DataCache_IDataObject_SetData(
|
|
|
|
IDataObject* iface,
|
2002-06-01 01:06:46 +02:00
|
|
|
LPFORMATETC pformatetc,
|
|
|
|
STGMEDIUM* pmedium,
|
1999-05-02 11:27:08 +02:00
|
|
|
BOOL fRelease)
|
|
|
|
{
|
|
|
|
IOleCache2* oleCache = NULL;
|
|
|
|
HRESULT hres;
|
|
|
|
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("(%p, %p, %p, %d)\n", iface, pformatetc, pmedium, fRelease);
|
1999-05-02 11:27:08 +02:00
|
|
|
|
|
|
|
hres = IDataObject_QueryInterface(iface, &IID_IOleCache2, (void**)&oleCache);
|
|
|
|
|
|
|
|
if (FAILED(hres))
|
|
|
|
return E_UNEXPECTED;
|
|
|
|
|
|
|
|
hres = IOleCache2_SetData(oleCache, pformatetc, pmedium, fRelease);
|
|
|
|
|
|
|
|
IOleCache2_Release(oleCache);
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
return hres;
|
1999-05-02 11:27:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* DataCache_EnumFormatEtc (IDataObject)
|
|
|
|
*
|
|
|
|
* The data cache doesn't implement this method.
|
|
|
|
*
|
|
|
|
* See Windows documentation for more details on IDataObject methods.
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI DataCache_EnumFormatEtc(
|
2002-06-01 01:06:46 +02:00
|
|
|
IDataObject* iface,
|
1999-05-02 11:27:08 +02:00
|
|
|
DWORD dwDirection,
|
|
|
|
IEnumFORMATETC** ppenumFormatEtc)
|
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("()\n");
|
1999-05-02 11:27:08 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* DataCache_DAdvise (IDataObject)
|
|
|
|
*
|
|
|
|
* The data cache doesn't support connections.
|
|
|
|
*
|
|
|
|
* See Windows documentation for more details on IDataObject methods.
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI DataCache_DAdvise(
|
2002-06-01 01:06:46 +02:00
|
|
|
IDataObject* iface,
|
|
|
|
FORMATETC* pformatetc,
|
|
|
|
DWORD advf,
|
|
|
|
IAdviseSink* pAdvSink,
|
1999-05-02 11:27:08 +02:00
|
|
|
DWORD* pdwConnection)
|
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("()\n");
|
1999-05-02 11:27:08 +02:00
|
|
|
return OLE_E_ADVISENOTSUPPORTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* DataCache_DUnadvise (IDataObject)
|
|
|
|
*
|
|
|
|
* The data cache doesn't support connections.
|
|
|
|
*
|
|
|
|
* See Windows documentation for more details on IDataObject methods.
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI DataCache_DUnadvise(
|
|
|
|
IDataObject* iface,
|
|
|
|
DWORD dwConnection)
|
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("()\n");
|
1999-05-02 11:27:08 +02:00
|
|
|
return OLE_E_NOCONNECTION;
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* DataCache_EnumDAdvise (IDataObject)
|
|
|
|
*
|
|
|
|
* The data cache doesn't support connections.
|
|
|
|
*
|
|
|
|
* See Windows documentation for more details on IDataObject methods.
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI DataCache_EnumDAdvise(
|
|
|
|
IDataObject* iface,
|
|
|
|
IEnumSTATDATA** ppenumAdvise)
|
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("()\n");
|
1999-05-02 11:27:08 +02:00
|
|
|
return OLE_E_ADVISENOTSUPPORTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************
|
|
|
|
* Method implementation for the IDataObject
|
|
|
|
* part of the DataCache class.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* DataCache_IPersistStorage_QueryInterface (IUnknown)
|
|
|
|
*
|
|
|
|
* See Windows documentation for more details on IUnknown methods.
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI DataCache_IPersistStorage_QueryInterface(
|
|
|
|
IPersistStorage* iface,
|
|
|
|
REFIID riid,
|
|
|
|
void** ppvObject)
|
|
|
|
{
|
|
|
|
_ICOM_THIS_From_IPersistStorage(DataCache, iface);
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject);
|
1999-05-02 11:27:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* DataCache_IPersistStorage_AddRef (IUnknown)
|
|
|
|
*
|
|
|
|
* See Windows documentation for more details on IUnknown methods.
|
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
static ULONG WINAPI DataCache_IPersistStorage_AddRef(
|
1999-05-02 11:27:08 +02:00
|
|
|
IPersistStorage* iface)
|
|
|
|
{
|
|
|
|
_ICOM_THIS_From_IPersistStorage(DataCache, iface);
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
return IUnknown_AddRef(this->outerUnknown);
|
1999-05-02 11:27:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* DataCache_IPersistStorage_Release (IUnknown)
|
|
|
|
*
|
|
|
|
* See Windows documentation for more details on IUnknown methods.
|
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
static ULONG WINAPI DataCache_IPersistStorage_Release(
|
1999-05-02 11:27:08 +02:00
|
|
|
IPersistStorage* iface)
|
|
|
|
{
|
|
|
|
_ICOM_THIS_From_IPersistStorage(DataCache, iface);
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
return IUnknown_Release(this->outerUnknown);
|
1999-05-02 11:27:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* DataCache_GetClassID (IPersistStorage)
|
|
|
|
*
|
|
|
|
* The data cache doesn't implement this method.
|
|
|
|
*
|
|
|
|
* See Windows documentation for more details on IPersistStorage methods.
|
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
static HRESULT WINAPI DataCache_GetClassID(
|
1999-07-31 15:13:23 +02:00
|
|
|
IPersistStorage* iface,
|
1999-05-02 11:27:08 +02:00
|
|
|
CLSID* pClassID)
|
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("(%p, %p)\n", iface, pClassID);
|
1999-05-02 11:27:08 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
1999-05-08 12:55:32 +02:00
|
|
|
/************************************************************************
|
|
|
|
* DataCache_IsDirty (IPersistStorage)
|
|
|
|
*
|
2002-06-01 01:06:46 +02:00
|
|
|
* Until we actully connect to a running object and retrieve new
|
1999-05-08 12:55:32 +02:00
|
|
|
* information to it, we never get dirty.
|
|
|
|
*
|
|
|
|
* See Windows documentation for more details on IPersistStorage methods.
|
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
static HRESULT WINAPI DataCache_IsDirty(
|
1999-05-02 11:27:08 +02:00
|
|
|
IPersistStorage* iface)
|
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("(%p)\n", iface);
|
1999-05-08 12:55:32 +02:00
|
|
|
|
|
|
|
return S_FALSE;
|
1999-05-02 11:27:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* DataCache_InitNew (IPersistStorage)
|
|
|
|
*
|
|
|
|
* The data cache implementation of IPersistStorage_InitNew simply stores
|
|
|
|
* the storage pointer.
|
|
|
|
*
|
|
|
|
* See Windows documentation for more details on IPersistStorage methods.
|
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
static HRESULT WINAPI DataCache_InitNew(
|
|
|
|
IPersistStorage* iface,
|
1999-05-02 11:27:08 +02:00
|
|
|
IStorage* pStg)
|
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("(%p, %p)\n", iface, pStg);
|
1999-05-02 11:27:08 +02:00
|
|
|
|
|
|
|
return DataCache_Load(iface, pStg);
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* DataCache_Load (IPersistStorage)
|
|
|
|
*
|
2002-06-01 01:06:46 +02:00
|
|
|
* The data cache implementation of IPersistStorage_Load doesn't
|
1999-05-02 11:27:08 +02:00
|
|
|
* actually load anything. Instead, it holds on to the storage pointer
|
2002-06-01 01:06:46 +02:00
|
|
|
* and it will load the presentation information when the
|
1999-05-02 11:27:08 +02:00
|
|
|
* IDataObject_GetData or IViewObject2_Draw methods are called.
|
|
|
|
*
|
|
|
|
* See Windows documentation for more details on IPersistStorage methods.
|
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
static HRESULT WINAPI DataCache_Load(
|
1999-05-02 11:27:08 +02:00
|
|
|
IPersistStorage* iface,
|
|
|
|
IStorage* pStg)
|
|
|
|
{
|
|
|
|
_ICOM_THIS_From_IPersistStorage(DataCache, iface);
|
|
|
|
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("(%p, %p)\n", iface, pStg);
|
1999-05-02 11:27:08 +02:00
|
|
|
|
|
|
|
if (this->presentationStorage != NULL)
|
|
|
|
{
|
|
|
|
IStorage_Release(this->presentationStorage);
|
|
|
|
}
|
|
|
|
|
|
|
|
this->presentationStorage = pStg;
|
|
|
|
|
|
|
|
if (this->presentationStorage != NULL)
|
|
|
|
{
|
|
|
|
IStorage_AddRef(this->presentationStorage);
|
|
|
|
}
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
1999-05-08 12:55:32 +02:00
|
|
|
/************************************************************************
|
|
|
|
* DataCache_Save (IPersistStorage)
|
|
|
|
*
|
2002-06-01 01:06:46 +02:00
|
|
|
* Until we actully connect to a running object and retrieve new
|
1999-05-08 12:55:32 +02:00
|
|
|
* information to it, we never have to save anything. However, it is
|
|
|
|
* our responsability to copy the information when saving to a new
|
|
|
|
* storage.
|
|
|
|
*
|
|
|
|
* See Windows documentation for more details on IPersistStorage methods.
|
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
static HRESULT WINAPI DataCache_Save(
|
1999-05-02 11:27:08 +02:00
|
|
|
IPersistStorage* iface,
|
2002-06-01 01:06:46 +02:00
|
|
|
IStorage* pStg,
|
1999-05-02 11:27:08 +02:00
|
|
|
BOOL fSameAsLoad)
|
|
|
|
{
|
1999-05-08 12:55:32 +02:00
|
|
|
_ICOM_THIS_From_IPersistStorage(DataCache, iface);
|
|
|
|
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("(%p, %p, %d)\n", iface, pStg, fSameAsLoad);
|
1999-05-08 12:55:32 +02:00
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
if ( (!fSameAsLoad) &&
|
1999-05-08 12:55:32 +02:00
|
|
|
(this->presentationStorage!=NULL) )
|
|
|
|
{
|
|
|
|
return IStorage_CopyTo(this->presentationStorage,
|
|
|
|
0,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
pStg);
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
1999-05-02 11:27:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* DataCache_SaveCompleted (IPersistStorage)
|
|
|
|
*
|
|
|
|
* This method is called to tell the cache to release the storage
|
|
|
|
* pointer it's currentlu holding.
|
|
|
|
*
|
|
|
|
* See Windows documentation for more details on IPersistStorage methods.
|
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
static HRESULT WINAPI DataCache_SaveCompleted(
|
|
|
|
IPersistStorage* iface,
|
1999-05-02 11:27:08 +02:00
|
|
|
IStorage* pStgNew)
|
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("(%p, %p)\n", iface, pStgNew);
|
1999-05-02 11:27:08 +02:00
|
|
|
|
2000-03-08 19:49:36 +01:00
|
|
|
if (pStgNew)
|
|
|
|
{
|
1999-05-02 11:27:08 +02:00
|
|
|
/*
|
|
|
|
* First, make sure we get our hands off any storage we have.
|
|
|
|
*/
|
2000-03-08 19:49:36 +01:00
|
|
|
|
1999-05-02 11:27:08 +02:00
|
|
|
DataCache_HandsOffStorage(iface);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Then, attach to the new storage.
|
|
|
|
*/
|
2000-03-08 19:49:36 +01:00
|
|
|
|
1999-05-02 11:27:08 +02:00
|
|
|
DataCache_Load(iface, pStgNew);
|
2000-03-08 19:49:36 +01:00
|
|
|
}
|
1999-05-02 11:27:08 +02:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* DataCache_HandsOffStorage (IPersistStorage)
|
|
|
|
*
|
|
|
|
* This method is called to tell the cache to release the storage
|
|
|
|
* pointer it's currentlu holding.
|
|
|
|
*
|
|
|
|
* See Windows documentation for more details on IPersistStorage methods.
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI DataCache_HandsOffStorage(
|
|
|
|
IPersistStorage* iface)
|
|
|
|
{
|
|
|
|
_ICOM_THIS_From_IPersistStorage(DataCache, iface);
|
|
|
|
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("(%p)\n", iface);
|
1999-05-02 11:27:08 +02:00
|
|
|
|
|
|
|
if (this->presentationStorage != NULL)
|
|
|
|
{
|
|
|
|
IStorage_Release(this->presentationStorage);
|
|
|
|
this->presentationStorage = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************
|
|
|
|
* Method implementation for the IViewObject2
|
|
|
|
* part of the DataCache class.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* DataCache_IViewObject2_QueryInterface (IUnknown)
|
|
|
|
*
|
|
|
|
* See Windows documentation for more details on IUnknown methods.
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI DataCache_IViewObject2_QueryInterface(
|
|
|
|
IViewObject2* iface,
|
|
|
|
REFIID riid,
|
|
|
|
void** ppvObject)
|
|
|
|
{
|
|
|
|
_ICOM_THIS_From_IViewObject2(DataCache, iface);
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject);
|
1999-05-02 11:27:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* DataCache_IViewObject2_AddRef (IUnknown)
|
|
|
|
*
|
|
|
|
* See Windows documentation for more details on IUnknown methods.
|
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
static ULONG WINAPI DataCache_IViewObject2_AddRef(
|
1999-05-02 11:27:08 +02:00
|
|
|
IViewObject2* iface)
|
|
|
|
{
|
|
|
|
_ICOM_THIS_From_IViewObject2(DataCache, iface);
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
return IUnknown_AddRef(this->outerUnknown);
|
1999-05-02 11:27:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* DataCache_IViewObject2_Release (IUnknown)
|
|
|
|
*
|
|
|
|
* See Windows documentation for more details on IUnknown methods.
|
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
static ULONG WINAPI DataCache_IViewObject2_Release(
|
1999-05-02 11:27:08 +02:00
|
|
|
IViewObject2* iface)
|
|
|
|
{
|
|
|
|
_ICOM_THIS_From_IViewObject2(DataCache, iface);
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
return IUnknown_Release(this->outerUnknown);
|
1999-05-02 11:27:08 +02:00
|
|
|
}
|
|
|
|
|
1999-05-08 12:55:32 +02:00
|
|
|
/************************************************************************
|
|
|
|
* DataCache_Draw (IViewObject2)
|
|
|
|
*
|
|
|
|
* This method will draw the cached representation of the object
|
|
|
|
* to the given device context.
|
|
|
|
*
|
|
|
|
* See Windows documentation for more details on IViewObject2 methods.
|
|
|
|
*/
|
1999-05-02 11:27:08 +02:00
|
|
|
static HRESULT WINAPI DataCache_Draw(
|
|
|
|
IViewObject2* iface,
|
|
|
|
DWORD dwDrawAspect,
|
|
|
|
LONG lindex,
|
|
|
|
void* pvAspect,
|
2002-06-01 01:06:46 +02:00
|
|
|
DVTARGETDEVICE* ptd,
|
|
|
|
HDC hdcTargetDev,
|
1999-05-02 11:27:08 +02:00
|
|
|
HDC hdcDraw,
|
|
|
|
LPCRECTL lprcBounds,
|
|
|
|
LPCRECTL lprcWBounds,
|
|
|
|
IVO_ContCallback pfnContinue,
|
|
|
|
DWORD dwContinue)
|
|
|
|
{
|
1999-05-08 12:55:32 +02:00
|
|
|
PresentationDataHeader presData;
|
|
|
|
HMETAFILE presMetafile = 0;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
_ICOM_THIS_From_IViewObject2(DataCache, iface);
|
|
|
|
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("(%p, %lx, %ld, %p, %x, %x, %p, %p, %p, %lx)\n",
|
1999-05-08 12:55:32 +02:00
|
|
|
iface,
|
|
|
|
dwDrawAspect,
|
|
|
|
lindex,
|
|
|
|
pvAspect,
|
2002-06-01 01:06:46 +02:00
|
|
|
hdcTargetDev,
|
1999-05-08 12:55:32 +02:00
|
|
|
hdcDraw,
|
|
|
|
lprcBounds,
|
|
|
|
lprcWBounds,
|
|
|
|
pfnContinue,
|
|
|
|
dwContinue);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Sanity check
|
|
|
|
*/
|
|
|
|
if (lprcBounds==NULL)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* First, we need to retrieve the dimensions of the
|
|
|
|
* image in the metafile.
|
|
|
|
*/
|
|
|
|
hres = DataCache_ReadPresentationData(this,
|
|
|
|
dwDrawAspect,
|
|
|
|
&presData);
|
|
|
|
|
|
|
|
if (FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Then, we can extract the metafile itself from the cached
|
|
|
|
* data.
|
2000-03-19 13:42:58 +01:00
|
|
|
*
|
|
|
|
* FIXME Unless it isn't a metafile. I think it could be any CF_XXX type,
|
|
|
|
* particularly CF_DIB.
|
1999-05-08 12:55:32 +02:00
|
|
|
*/
|
|
|
|
presMetafile = DataCache_ReadPresMetafile(this,
|
|
|
|
dwDrawAspect);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If we have a metafile, just draw baby...
|
|
|
|
* We have to be careful not to modify the state of the
|
|
|
|
* DC.
|
|
|
|
*/
|
|
|
|
if (presMetafile!=0)
|
|
|
|
{
|
|
|
|
INT prevMapMode = SetMapMode(hdcDraw, MM_ANISOTROPIC);
|
|
|
|
SIZE oldWindowExt;
|
|
|
|
SIZE oldViewportExt;
|
|
|
|
POINT oldViewportOrg;
|
|
|
|
|
|
|
|
SetWindowExtEx(hdcDraw,
|
2000-05-24 01:34:40 +02:00
|
|
|
presData.dwObjectExtentX,
|
|
|
|
presData.dwObjectExtentY,
|
1999-05-08 12:55:32 +02:00
|
|
|
&oldWindowExt);
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
SetViewportExtEx(hdcDraw,
|
1999-05-08 12:55:32 +02:00
|
|
|
lprcBounds->right - lprcBounds->left,
|
|
|
|
lprcBounds->bottom - lprcBounds->top,
|
|
|
|
&oldViewportExt);
|
|
|
|
|
|
|
|
SetViewportOrgEx(hdcDraw,
|
|
|
|
lprcBounds->left,
|
|
|
|
lprcBounds->top,
|
|
|
|
&oldViewportOrg);
|
|
|
|
|
|
|
|
PlayMetaFile(hdcDraw, presMetafile);
|
|
|
|
|
|
|
|
SetWindowExtEx(hdcDraw,
|
|
|
|
oldWindowExt.cx,
|
|
|
|
oldWindowExt.cy,
|
|
|
|
NULL);
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
SetViewportExtEx(hdcDraw,
|
1999-05-08 12:55:32 +02:00
|
|
|
oldViewportExt.cx,
|
|
|
|
oldViewportExt.cy,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
SetViewportOrgEx(hdcDraw,
|
|
|
|
oldViewportOrg.x,
|
|
|
|
oldViewportOrg.y,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
SetMapMode(hdcDraw, prevMapMode);
|
|
|
|
|
|
|
|
DeleteMetaFile(presMetafile);
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
1999-05-02 11:27:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI DataCache_GetColorSet(
|
2002-06-01 01:06:46 +02:00
|
|
|
IViewObject2* iface,
|
|
|
|
DWORD dwDrawAspect,
|
|
|
|
LONG lindex,
|
|
|
|
void* pvAspect,
|
|
|
|
DVTARGETDEVICE* ptd,
|
|
|
|
HDC hicTargetDevice,
|
1999-05-02 11:27:08 +02:00
|
|
|
LOGPALETTE** ppColorSet)
|
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
FIXME("stub\n");
|
1999-05-02 11:27:08 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI DataCache_Freeze(
|
|
|
|
IViewObject2* iface,
|
|
|
|
DWORD dwDrawAspect,
|
|
|
|
LONG lindex,
|
2002-06-01 01:06:46 +02:00
|
|
|
void* pvAspect,
|
1999-05-02 11:27:08 +02:00
|
|
|
DWORD* pdwFreeze)
|
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
FIXME("stub\n");
|
1999-05-02 11:27:08 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI DataCache_Unfreeze(
|
|
|
|
IViewObject2* iface,
|
|
|
|
DWORD dwFreeze)
|
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
FIXME("stub\n");
|
1999-05-02 11:27:08 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
1999-05-08 12:55:32 +02:00
|
|
|
/************************************************************************
|
|
|
|
* DataCache_SetAdvise (IViewObject2)
|
|
|
|
*
|
|
|
|
* This sets-up an advisory sink with the data cache. When the object's
|
|
|
|
* view changes, this sink is called.
|
|
|
|
*
|
|
|
|
* See Windows documentation for more details on IViewObject2 methods.
|
|
|
|
*/
|
1999-05-02 11:27:08 +02:00
|
|
|
static HRESULT WINAPI DataCache_SetAdvise(
|
|
|
|
IViewObject2* iface,
|
2002-06-01 01:06:46 +02:00
|
|
|
DWORD aspects,
|
|
|
|
DWORD advf,
|
1999-05-02 11:27:08 +02:00
|
|
|
IAdviseSink* pAdvSink)
|
|
|
|
{
|
1999-05-08 12:55:32 +02:00
|
|
|
_ICOM_THIS_From_IViewObject2(DataCache, iface);
|
|
|
|
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("(%p, %lx, %lx, %p)\n", iface, aspects, advf, pAdvSink);
|
1999-05-08 12:55:32 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* A call to this function removes the previous sink
|
|
|
|
*/
|
|
|
|
if (this->sinkInterface != NULL)
|
|
|
|
{
|
|
|
|
IAdviseSink_Release(this->sinkInterface);
|
|
|
|
this->sinkInterface = NULL;
|
2002-06-01 01:06:46 +02:00
|
|
|
this->sinkAspects = 0;
|
1999-05-08 12:55:32 +02:00
|
|
|
this->sinkAdviseFlag = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Now, setup the new one.
|
|
|
|
*/
|
|
|
|
if (pAdvSink!=NULL)
|
|
|
|
{
|
|
|
|
this->sinkInterface = pAdvSink;
|
2002-06-01 01:06:46 +02:00
|
|
|
this->sinkAspects = aspects;
|
|
|
|
this->sinkAdviseFlag = advf;
|
1999-05-08 12:55:32 +02:00
|
|
|
|
|
|
|
IAdviseSink_AddRef(this->sinkInterface);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* When the ADVF_PRIMEFIRST flag is set, we have to advise the
|
|
|
|
* sink immediately.
|
|
|
|
*/
|
|
|
|
if (advf & ADVF_PRIMEFIRST)
|
|
|
|
{
|
|
|
|
DataCache_FireOnViewChange(this,
|
|
|
|
DVASPECT_CONTENT,
|
|
|
|
-1);
|
|
|
|
}
|
|
|
|
|
1999-05-02 11:27:08 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
1999-05-08 12:55:32 +02:00
|
|
|
/************************************************************************
|
|
|
|
* DataCache_GetAdvise (IViewObject2)
|
|
|
|
*
|
2002-06-01 01:06:46 +02:00
|
|
|
* This method queries the current state of the advise sink
|
1999-05-08 12:55:32 +02:00
|
|
|
* installed on the data cache.
|
|
|
|
*
|
|
|
|
* See Windows documentation for more details on IViewObject2 methods.
|
|
|
|
*/
|
1999-05-02 11:27:08 +02:00
|
|
|
static HRESULT WINAPI DataCache_GetAdvise(
|
2002-06-01 01:06:46 +02:00
|
|
|
IViewObject2* iface,
|
|
|
|
DWORD* pAspects,
|
|
|
|
DWORD* pAdvf,
|
1999-05-02 11:27:08 +02:00
|
|
|
IAdviseSink** ppAdvSink)
|
|
|
|
{
|
1999-05-08 12:55:32 +02:00
|
|
|
_ICOM_THIS_From_IViewObject2(DataCache, iface);
|
|
|
|
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("(%p, %p, %p, %p)\n", iface, pAspects, pAdvf, ppAdvSink);
|
1999-05-08 12:55:32 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Just copy all the requested values.
|
|
|
|
*/
|
|
|
|
if (pAspects!=NULL)
|
|
|
|
*pAspects = this->sinkAspects;
|
|
|
|
|
|
|
|
if (pAdvf!=NULL)
|
|
|
|
*pAdvf = this->sinkAdviseFlag;
|
|
|
|
|
|
|
|
if (ppAdvSink!=NULL)
|
|
|
|
{
|
2002-06-01 01:06:46 +02:00
|
|
|
IAdviseSink_QueryInterface(this->sinkInterface,
|
|
|
|
&IID_IAdviseSink,
|
1999-05-08 12:55:32 +02:00
|
|
|
(void**)ppAdvSink);
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
1999-05-02 11:27:08 +02:00
|
|
|
}
|
|
|
|
|
1999-05-08 12:55:32 +02:00
|
|
|
/************************************************************************
|
|
|
|
* DataCache_GetExtent (IViewObject2)
|
|
|
|
*
|
|
|
|
* This method retrieves the "natural" size of this cached object.
|
|
|
|
*
|
|
|
|
* See Windows documentation for more details on IViewObject2 methods.
|
|
|
|
*/
|
1999-05-02 11:27:08 +02:00
|
|
|
static HRESULT WINAPI DataCache_GetExtent(
|
2002-06-01 01:06:46 +02:00
|
|
|
IViewObject2* iface,
|
|
|
|
DWORD dwDrawAspect,
|
|
|
|
LONG lindex,
|
|
|
|
DVTARGETDEVICE* ptd,
|
1999-05-02 11:27:08 +02:00
|
|
|
LPSIZEL lpsizel)
|
|
|
|
{
|
1999-05-08 12:55:32 +02:00
|
|
|
PresentationDataHeader presData;
|
|
|
|
HRESULT hres = E_FAIL;
|
1999-05-02 11:27:08 +02:00
|
|
|
|
1999-05-08 12:55:32 +02:00
|
|
|
_ICOM_THIS_From_IViewObject2(DataCache, iface);
|
1999-05-02 11:27:08 +02:00
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
TRACE("(%p, %lx, %ld, %p, %p)\n",
|
1999-05-08 12:55:32 +02:00
|
|
|
iface, dwDrawAspect, lindex, ptd, lpsizel);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Sanity check
|
|
|
|
*/
|
|
|
|
if (lpsizel==NULL)
|
|
|
|
return E_POINTER;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialize the out parameter.
|
|
|
|
*/
|
|
|
|
lpsizel->cx = 0;
|
|
|
|
lpsizel->cy = 0;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This flag should be set to -1.
|
|
|
|
*/
|
|
|
|
if (lindex!=-1)
|
1999-07-04 18:02:24 +02:00
|
|
|
FIXME("Unimplemented flag lindex = %ld\n", lindex);
|
1999-05-08 12:55:32 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Right now, we suport only the callback from
|
|
|
|
* the default handler.
|
|
|
|
*/
|
|
|
|
if (ptd!=NULL)
|
1999-07-04 18:02:24 +02:00
|
|
|
FIXME("Unimplemented ptd = %p\n", ptd);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-05-08 12:55:32 +02:00
|
|
|
/*
|
2002-06-01 01:06:46 +02:00
|
|
|
* Get the presentation information from the
|
1999-05-08 12:55:32 +02:00
|
|
|
* cache.
|
|
|
|
*/
|
|
|
|
hres = DataCache_ReadPresentationData(this,
|
|
|
|
dwDrawAspect,
|
|
|
|
&presData);
|
|
|
|
|
|
|
|
if (SUCCEEDED(hres))
|
|
|
|
{
|
2000-05-24 01:34:40 +02:00
|
|
|
lpsizel->cx = presData.dwObjectExtentX;
|
|
|
|
lpsizel->cy = presData.dwObjectExtentY;
|
1999-05-08 12:55:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This method returns OLE_E_BLANK when it fails.
|
|
|
|
*/
|
|
|
|
if (FAILED(hres))
|
|
|
|
hres = OLE_E_BLANK;
|
|
|
|
|
|
|
|
return hres;
|
1999-05-02 11:27:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************
|
|
|
|
* Method implementation for the IOleCache2
|
|
|
|
* part of the DataCache class.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* DataCache_IOleCache2_QueryInterface (IUnknown)
|
|
|
|
*
|
|
|
|
* See Windows documentation for more details on IUnknown methods.
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI DataCache_IOleCache2_QueryInterface(
|
|
|
|
IOleCache2* iface,
|
|
|
|
REFIID riid,
|
|
|
|
void** ppvObject)
|
|
|
|
{
|
|
|
|
_ICOM_THIS_From_IOleCache2(DataCache, iface);
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject);
|
1999-05-02 11:27:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* DataCache_IOleCache2_AddRef (IUnknown)
|
|
|
|
*
|
|
|
|
* See Windows documentation for more details on IUnknown methods.
|
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
static ULONG WINAPI DataCache_IOleCache2_AddRef(
|
1999-05-02 11:27:08 +02:00
|
|
|
IOleCache2* iface)
|
|
|
|
{
|
|
|
|
_ICOM_THIS_From_IOleCache2(DataCache, iface);
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
return IUnknown_AddRef(this->outerUnknown);
|
1999-05-02 11:27:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* DataCache_IOleCache2_Release (IUnknown)
|
|
|
|
*
|
|
|
|
* See Windows documentation for more details on IUnknown methods.
|
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
static ULONG WINAPI DataCache_IOleCache2_Release(
|
1999-05-02 11:27:08 +02:00
|
|
|
IOleCache2* iface)
|
|
|
|
{
|
|
|
|
_ICOM_THIS_From_IOleCache2(DataCache, iface);
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
return IUnknown_Release(this->outerUnknown);
|
1999-05-02 11:27:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI DataCache_Cache(
|
|
|
|
IOleCache2* iface,
|
|
|
|
FORMATETC* pformatetc,
|
|
|
|
DWORD advf,
|
|
|
|
DWORD* pdwConnection)
|
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
FIXME("stub\n");
|
1999-05-02 11:27:08 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI DataCache_Uncache(
|
|
|
|
IOleCache2* iface,
|
|
|
|
DWORD dwConnection)
|
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
FIXME("stub\n");
|
1999-05-02 11:27:08 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI DataCache_EnumCache(
|
|
|
|
IOleCache2* iface,
|
|
|
|
IEnumSTATDATA** ppenumSTATDATA)
|
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
FIXME("stub\n");
|
1999-05-02 11:27:08 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI DataCache_InitCache(
|
|
|
|
IOleCache2* iface,
|
|
|
|
IDataObject* pDataObject)
|
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
FIXME("stub\n");
|
1999-05-02 11:27:08 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI DataCache_IOleCache2_SetData(
|
|
|
|
IOleCache2* iface,
|
|
|
|
FORMATETC* pformatetc,
|
|
|
|
STGMEDIUM* pmedium,
|
|
|
|
BOOL fRelease)
|
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
FIXME("stub\n");
|
1999-05-02 11:27:08 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI DataCache_UpdateCache(
|
|
|
|
IOleCache2* iface,
|
2002-06-01 01:06:46 +02:00
|
|
|
LPDATAOBJECT pDataObject,
|
1999-05-02 11:27:08 +02:00
|
|
|
DWORD grfUpdf,
|
|
|
|
LPVOID pReserved)
|
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
FIXME("stub\n");
|
1999-05-02 11:27:08 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI DataCache_DiscardCache(
|
|
|
|
IOleCache2* iface,
|
|
|
|
DWORD dwDiscardOptions)
|
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
FIXME("stub\n");
|
1999-05-02 11:27:08 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************
|
|
|
|
* Method implementation for the IOleCacheControl
|
|
|
|
* part of the DataCache class.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* DataCache_IOleCacheControl_QueryInterface (IUnknown)
|
|
|
|
*
|
|
|
|
* See Windows documentation for more details on IUnknown methods.
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI DataCache_IOleCacheControl_QueryInterface(
|
|
|
|
IOleCacheControl* iface,
|
|
|
|
REFIID riid,
|
|
|
|
void** ppvObject)
|
|
|
|
{
|
|
|
|
_ICOM_THIS_From_IOleCacheControl(DataCache, iface);
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject);
|
1999-05-02 11:27:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* DataCache_IOleCacheControl_AddRef (IUnknown)
|
|
|
|
*
|
|
|
|
* See Windows documentation for more details on IUnknown methods.
|
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
static ULONG WINAPI DataCache_IOleCacheControl_AddRef(
|
1999-05-02 11:27:08 +02:00
|
|
|
IOleCacheControl* iface)
|
|
|
|
{
|
|
|
|
_ICOM_THIS_From_IOleCacheControl(DataCache, iface);
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
return IUnknown_AddRef(this->outerUnknown);
|
1999-05-02 11:27:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* DataCache_IOleCacheControl_Release (IUnknown)
|
|
|
|
*
|
|
|
|
* See Windows documentation for more details on IUnknown methods.
|
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
static ULONG WINAPI DataCache_IOleCacheControl_Release(
|
1999-05-02 11:27:08 +02:00
|
|
|
IOleCacheControl* iface)
|
|
|
|
{
|
|
|
|
_ICOM_THIS_From_IOleCacheControl(DataCache, iface);
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
return IUnknown_Release(this->outerUnknown);
|
1999-05-02 11:27:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI DataCache_OnRun(
|
|
|
|
IOleCacheControl* iface,
|
|
|
|
LPDATAOBJECT pDataObject)
|
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
FIXME("stub\n");
|
1999-05-02 11:27:08 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI DataCache_OnStop(
|
|
|
|
IOleCacheControl* iface)
|
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
FIXME("stub\n");
|
1999-05-02 11:27:08 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|