ReactOS 0.4.16-dev-92-g0c2cdca
ole2.c File Reference
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
#include "objbase.h"
#include "shlguid.h"
#include "wine/test.h"
Include dependency graph for ole2.c:

Go to the source code of this file.

Classes

struct  expected_method
 
struct  PresentationDataHeader
 
struct  stream_def
 
struct  storage_def
 

Macros

#define COBJMACROS
 
#define CONST_VTABLE
 
#define WIN32_LEAN_AND_MEAN
 
#define ok_ole_success(hr, func)   ok(hr == S_OK, func " failed with error 0x%08x\n", hr)
 
#define DEFINE_EXPECT(func)    static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
 
#define SET_EXPECT(func)    expect_ ## func = TRUE
 
#define CHECK_EXPECT2(func)
 
#define CHECK_EXPECT(func)
 
#define CHECK_CALLED(func)
 
#define TEST_OPTIONAL   0x1
 
#define TEST_TODO   0x2
 
#define CHECK_EXPECTED_METHOD(method_name)   check_expected_method_fmt(method_name, NULL)
 
#define CHECK_EXPECTED_METHOD_FMT(method_name, fmt)   check_expected_method_fmt(method_name, fmt)
 
#define CHECK_NO_EXTRA_METHODS()
 
#define MAX_STREAM   16
 
#define MAX_FMTS   5
 

Typedefs

typedef struct PresentationDataHeader PresentationDataHeader
 

Functions

 DEFINE_EXPECT (Storage_Stat)
 
 DEFINE_EXPECT (Storage_OpenStream_CompObj)
 
 DEFINE_EXPECT (Storage_OpenStream_OlePres)
 
 DEFINE_EXPECT (Storage_SetClass)
 
 DEFINE_EXPECT (Storage_CreateStream_CompObj)
 
 DEFINE_EXPECT (Storage_CreateStream_OlePres)
 
 DEFINE_EXPECT (Storage_OpenStream_Ole)
 
 DEFINE_EXPECT (Storage_DestroyElement)
 
static void check_expected_method_fmt (const char *method_name, const FORMATETC *fmt)
 
static void create_dib (STGMEDIUM *med)
 
static void create_bitmap (STGMEDIUM *med)
 
static void create_emf (STGMEDIUM *med)
 
static void create_mfpict (STGMEDIUM *med)
 
static void create_text (STGMEDIUM *med)
 
static HRESULT WINAPI OleObject_QueryInterface (IOleObject *iface, REFIID riid, void **ppv)
 
static ULONG WINAPI OleObject_AddRef (IOleObject *iface)
 
static ULONG WINAPI OleObject_Release (IOleObject *iface)
 
static HRESULT WINAPI OleObject_SetClientSite (IOleObject *iface, IOleClientSite *pClientSite)
 
static HRESULT WINAPI OleObject_GetClientSite (IOleObject *iface, IOleClientSite **ppClientSite)
 
static HRESULT WINAPI OleObject_SetHostNames (IOleObject *iface, LPCOLESTR szContainerApp, LPCOLESTR szContainerObj)
 
static HRESULT WINAPI OleObject_Close (IOleObject *iface, DWORD dwSaveOption)
 
static HRESULT WINAPI OleObject_SetMoniker (IOleObject *iface, DWORD dwWhichMoniker, IMoniker *pmk)
 
static HRESULT WINAPI OleObject_GetMoniker (IOleObject *iface, DWORD dwAssign, DWORD dwWhichMoniker, IMoniker **ppmk)
 
static HRESULT WINAPI OleObject_InitFromData (IOleObject *iface, IDataObject *pDataObject, BOOL fCreation, DWORD dwReserved)
 
static HRESULT WINAPI OleObject_GetClipboardData (IOleObject *iface, DWORD dwReserved, IDataObject **ppDataObject)
 
static HRESULT WINAPI OleObject_DoVerb (IOleObject *iface, LONG iVerb, LPMSG lpmsg, IOleClientSite *pActiveSite, LONG lindex, HWND hwndParent, LPCRECT lprcPosRect)
 
static HRESULT WINAPI OleObject_EnumVerbs (IOleObject *iface, IEnumOLEVERB **ppEnumOleVerb)
 
static HRESULT WINAPI OleObject_Update (IOleObject *iface)
 
static HRESULT WINAPI OleObject_IsUpToDate (IOleObject *iface)
 
static HRESULT WINAPI OleObject_GetUserClassID (IOleObject *iface, CLSID *pClsid)
 
static HRESULT WINAPI OleObject_GetUserType (IOleObject *iface, DWORD dwFormOfType, LPOLESTR *pszUserType)
 
static HRESULT WINAPI OleObject_SetExtent (IOleObject *iface, DWORD dwDrawAspect, SIZEL *psizel)
 
static HRESULT WINAPI OleObject_GetExtent (IOleObject *iface, DWORD dwDrawAspect, SIZEL *psizel)
 
static HRESULT WINAPI OleObject_Advise (IOleObject *iface, IAdviseSink *pAdvSink, DWORD *pdwConnection)
 
static HRESULT WINAPI OleObject_Unadvise (IOleObject *iface, DWORD dwConnection)
 
static HRESULT WINAPI OleObject_EnumAdvise (IOleObject *iface, IEnumSTATDATA **ppenumAdvise)
 
static HRESULT WINAPI OleObject_GetMiscStatus (IOleObject *iface, DWORD aspect, DWORD *pdwStatus)
 
static HRESULT WINAPI OleObject_SetColorScheme (IOleObject *iface, LOGPALETTE *pLogpal)
 
static HRESULT WINAPI OleObjectPersistStg_QueryInterface (IPersistStorage *iface, REFIID riid, void **ppv)
 
static ULONG WINAPI OleObjectPersistStg_AddRef (IPersistStorage *iface)
 
static ULONG WINAPI OleObjectPersistStg_Release (IPersistStorage *iface)
 
static HRESULT WINAPI OleObjectPersistStg_GetClassId (IPersistStorage *iface, CLSID *clsid)
 
static HRESULT WINAPI OleObjectPersistStg_IsDirty (IPersistStorage *iface)
 
static HRESULT WINAPI OleObjectPersistStg_InitNew (IPersistStorage *iface, IStorage *pStg)
 
static HRESULT WINAPI OleObjectPersistStg_Load (IPersistStorage *iface, IStorage *pStg)
 
static HRESULT WINAPI OleObjectPersistStg_Save (IPersistStorage *iface, IStorage *pStgSave, BOOL fSameAsLoad)
 
static HRESULT WINAPI OleObjectPersistStg_SaveCompleted (IPersistStorage *iface, IStorage *pStgNew)
 
static HRESULT WINAPI OleObjectPersistStg_HandsOffStorage (IPersistStorage *iface)
 
static HRESULT WINAPI OleObjectCache_QueryInterface (IOleCache *iface, REFIID riid, void **ppv)
 
static ULONG WINAPI OleObjectCache_AddRef (IOleCache *iface)
 
static ULONG WINAPI OleObjectCache_Release (IOleCache *iface)
 
static HRESULT WINAPI OleObjectCache_Cache (IOleCache *iface, FORMATETC *pformatetc, DWORD advf, DWORD *pdwConnection)
 
static HRESULT WINAPI OleObjectCache_Uncache (IOleCache *iface, DWORD dwConnection)
 
static HRESULT WINAPI OleObjectCache_EnumCache (IOleCache *iface, IEnumSTATDATA **ppenumSTATDATA)
 
static HRESULT WINAPI OleObjectCache_InitCache (IOleCache *iface, IDataObject *pDataObject)
 
static HRESULT WINAPI OleObjectCache_SetData (IOleCache *iface, FORMATETC *pformatetc, STGMEDIUM *pmedium, BOOL fRelease)
 
static HRESULT WINAPI OleObjectCF_QueryInterface (IClassFactory *iface, REFIID riid, void **ppv)
 
static ULONG WINAPI OleObjectCF_AddRef (IClassFactory *iface)
 
static ULONG WINAPI OleObjectCF_Release (IClassFactory *iface)
 
static HRESULT WINAPI OleObjectCF_CreateInstance (IClassFactory *iface, IUnknown *punkOuter, REFIID riid, void **ppv)
 
static HRESULT WINAPI OleObjectCF_LockServer (IClassFactory *iface, BOOL lock)
 
static HRESULT WINAPI OleObjectRunnable_QueryInterface (IRunnableObject *iface, REFIID riid, void **ppv)
 
static ULONG WINAPI OleObjectRunnable_AddRef (IRunnableObject *iface)
 
static ULONG WINAPI OleObjectRunnable_Release (IRunnableObject *iface)
 
static HRESULT WINAPI OleObjectRunnable_GetRunningClass (IRunnableObject *iface, LPCLSID lpClsid)
 
static HRESULT WINAPI OleObjectRunnable_Run (IRunnableObject *iface, LPBINDCTX pbc)
 
static BOOL WINAPI OleObjectRunnable_IsRunning (IRunnableObject *iface)
 
static HRESULT WINAPI OleObjectRunnable_LockRunning (IRunnableObject *iface, BOOL fLock, BOOL fLastUnlockCloses)
 
static HRESULT WINAPI OleObjectRunnable_SetContainedObject (IRunnableObject *iface, BOOL fContained)
 
static HRESULT WINAPI viewobject_QueryInterface (IViewObject *iface, REFIID riid, void **obj)
 
static ULONG WINAPI viewobject_AddRef (IViewObject *iface)
 
static ULONG WINAPI viewobject_Release (IViewObject *iface)
 
static HRESULT WINAPI viewobject_Draw (IViewObject *iface, DWORD aspect, LONG index, void *paspect, DVTARGETDEVICE *ptd, HDC hdcTargetDev, HDC hdcDraw, LPCRECTL bounds, LPCRECTL wbounds, BOOL(STDMETHODCALLTYPE *pfnContinue)(ULONG_PTR dwContinue), ULONG_PTR dwContinue)
 
static HRESULT WINAPI viewobject_GetColorSet (IViewObject *iface, DWORD draw_aspect, LONG index, void *aspect, DVTARGETDEVICE *ptd, HDC hicTargetDev, LOGPALETTE **colorset)
 
static HRESULT WINAPI viewobject_Freeze (IViewObject *iface, DWORD draw_aspect, LONG index, void *aspect, DWORD *freeze)
 
static HRESULT WINAPI viewobject_Unfreeze (IViewObject *iface, DWORD freeze)
 
static HRESULT WINAPI viewobject_SetAdvise (IViewObject *iface, DWORD aspects, DWORD advf, IAdviseSink *sink)
 
static HRESULT WINAPI viewobject_GetAdvise (IViewObject *iface, DWORD *aspects, DWORD *advf, IAdviseSink **sink)
 
static void test_OleCreate (IStorage *pStorage)
 
static void test_OleLoad (IStorage *pStorage)
 
static BOOL STDMETHODCALLTYPE draw_continue (ULONG_PTR param)
 
static BOOL STDMETHODCALLTYPE draw_continue_false (ULONG_PTR param)
 
static HRESULT WINAPI AdviseSink_QueryInterface (IAdviseSink *iface, REFIID riid, void **ppv)
 
static ULONG WINAPI AdviseSink_AddRef (IAdviseSink *iface)
 
static ULONG WINAPI AdviseSink_Release (IAdviseSink *iface)
 
static void WINAPI AdviseSink_OnDataChange (IAdviseSink *iface, FORMATETC *pFormatetc, STGMEDIUM *pStgmed)
 
static void WINAPI AdviseSink_OnViewChange (IAdviseSink *iface, DWORD dwAspect, LONG lindex)
 
static void WINAPI AdviseSink_OnRename (IAdviseSink *iface, IMoniker *pmk)
 
static void WINAPI AdviseSink_OnSave (IAdviseSink *iface)
 
static void WINAPI AdviseSink_OnClose (IAdviseSink *iface)
 
static HRESULT WINAPI DataObject_QueryInterface (IDataObject *iface, REFIID riid, void **ppvObject)
 
static ULONG WINAPI DataObject_AddRef (IDataObject *iface)
 
static ULONG WINAPI DataObject_Release (IDataObject *iface)
 
static BOOL fmtetc_equal (const FORMATETC *a, const FORMATETC *b)
 
static HRESULT WINAPI DataObject_GetData (IDataObject *iface, FORMATETC *fmt_in, STGMEDIUM *med)
 
static HRESULT WINAPI DataObject_GetDataHere (IDataObject *iface, LPFORMATETC pformatetc, STGMEDIUM *pmedium)
 
static HRESULT WINAPI DataObject_QueryGetData (IDataObject *iface, FORMATETC *fmt_in)
 
static HRESULT WINAPI DataObject_GetCanonicalFormatEtc (IDataObject *iface, LPFORMATETC pformatectIn, LPFORMATETC pformatetcOut)
 
static HRESULT WINAPI DataObject_SetData (IDataObject *iface, LPFORMATETC pformatetc, STGMEDIUM *pmedium, BOOL fRelease)
 
static HRESULT WINAPI DataObject_EnumFormatEtc (IDataObject *iface, DWORD dwDirection, IEnumFORMATETC **ppenumFormatEtc)
 
static HRESULT WINAPI DataObject_DAdvise (IDataObject *iface, FORMATETC *pformatetc, DWORD advf, IAdviseSink *pAdvSink, DWORD *pdwConnection)
 
static HRESULT WINAPI DataObject_DUnadvise (IDataObject *iface, DWORD dwConnection)
 
static HRESULT WINAPI DataObject_EnumDAdvise (IDataObject *iface, IEnumSTATDATA **ppenumAdvise)
 
static HRESULT WINAPI Unknown_QueryInterface (IUnknown *iface, REFIID riid, void **ppv)
 
static ULONG WINAPI Unknown_AddRef (IUnknown *iface)
 
static ULONG WINAPI Unknown_Release (IUnknown *iface)
 
static void check_enum_cache (IOleCache2 *cache, const STATDATA *expect, int num)
 
static void test_data_cache (void)
 
static IStoragecreate_storage (int num)
 
static void test_data_cache_dib_contents_stream (int num)
 
static void check_bitmap_size (HBITMAP h, int cx, int cy)
 
static void check_dib_size (HGLOBAL h, int cx, int cy)
 
static void test_data_cache_cache (void)
 
static void test_data_cache_init (void)
 
static void test_data_cache_initnew (void)
 
static void test_data_cache_updatecache (void)
 
static void test_default_handler (void)
 
static void test_runnable (void)
 
static HRESULT WINAPI OleRun_QueryInterface (IRunnableObject *iface, REFIID riid, void **ppv)
 
static ULONG WINAPI OleRun_AddRef (IRunnableObject *iface)
 
static ULONG WINAPI OleRun_Release (IRunnableObject *iface)
 
static HRESULT WINAPI OleRun_GetRunningClass (IRunnableObject *iface, CLSID *clsid)
 
static HRESULT WINAPI OleRun_Run (IRunnableObject *iface, LPBINDCTX ctx)
 
static BOOL WINAPI OleRun_IsRunning (IRunnableObject *iface)
 
static HRESULT WINAPI OleRun_LockRunning (IRunnableObject *iface, BOOL lock, BOOL last_unlock_closes)
 
static HRESULT WINAPI OleRun_SetContainedObject (IRunnableObject *iface, BOOL contained)
 
static void test_OleRun (void)
 
static void test_OleLockRunning (void)
 
static void test_OleDraw (void)
 
static HRESULT WINAPI Storage_QueryInterface (IStorage *iface, REFIID riid, void **ppvObject)
 
static ULONG WINAPI Storage_AddRef (IStorage *iface)
 
static ULONG WINAPI Storage_Release (IStorage *iface)
 
static HRESULT WINAPI Storage_CreateStream (IStorage *iface, LPCOLESTR pwcsName, DWORD grfMode, DWORD reserved1, DWORD reserved2, IStream **ppstm)
 
static HRESULT WINAPI Storage_OpenStream (IStorage *iface, LPCOLESTR pwcsName, void *reserved1, DWORD grfMode, DWORD reserved2, IStream **ppstm)
 
static HRESULT WINAPI Storage_CreateStorage (IStorage *iface, LPCOLESTR pwcsName, DWORD grfMode, DWORD dwStgFmt, DWORD reserved2, IStorage **ppstg)
 
static HRESULT WINAPI Storage_OpenStorage (IStorage *iface, LPCOLESTR pwcsName, IStorage *pstgPriority, DWORD grfMode, SNB snbExclude, DWORD reserved, IStorage **ppstg)
 
static HRESULT WINAPI Storage_CopyTo (IStorage *iface, DWORD ciidExclude, const IID *rgiidExclude, SNB snbExclude, IStorage *pstgDest)
 
static HRESULT WINAPI Storage_MoveElementTo (IStorage *iface, LPCOLESTR pwcsName, IStorage *pstgDest, LPCOLESTR pwcsNewName, DWORD grfFlags)
 
static HRESULT WINAPI Storage_Commit (IStorage *iface, DWORD grfCommitFlags)
 
static HRESULT WINAPI Storage_Revert (IStorage *iface)
 
static HRESULT WINAPI Storage_EnumElements (IStorage *iface, DWORD reserved1, void *reserved2, DWORD reserved3, IEnumSTATSTG **ppenum)
 
static HRESULT WINAPI Storage_DestroyElement (IStorage *iface, LPCOLESTR pwcsName)
 
static HRESULT WINAPI Storage_RenameElement (IStorage *iface, LPCOLESTR pwcsOldName, LPCOLESTR pwcsNewName)
 
static HRESULT WINAPI Storage_SetElementTimes (IStorage *iface, LPCOLESTR pwcsName, const FILETIME *pctime, const FILETIME *patime, const FILETIME *pmtime)
 
static HRESULT WINAPI Storage_SetClass (IStorage *iface, REFCLSID clsid)
 
static HRESULT WINAPI Storage_SetStateBits (IStorage *iface, DWORD grfStateBits, DWORD grfMask)
 
static HRESULT WINAPI Storage_Stat (IStorage *iface, STATSTG *pstatstg, DWORD grfStatFlag)
 
static void test_OleDoAutoConvert (void)
 
static void test_data_cache_save (void)
 
static int read_clipformat (IStream *stream)
 
static void check_storage_contents (IStorage *stg, const struct storage_def *stg_def, int *enumerated_streams, int *matched_streams)
 
static HRESULT stgmedium_cmp (const STGMEDIUM *med1, STGMEDIUM *med2)
 
static IStoragecreate_storage_from_def (const struct storage_def *stg_def)
 
static void get_stgdef (struct storage_def *stg_def, CLIPFORMAT cf, STGMEDIUM *stg_med, int stm_idx)
 
static void get_stgmedium (CLIPFORMAT cfFormat, STGMEDIUM *stgmedium)
 
static void test_data_cache_save_data (void)
 
static void test_data_cache_contents (void)
 
static void test_OleCreateStaticFromData (void)
 
 START_TEST (ole2)
 

Variables

static const CLSIDStorage_SetClass_CLSID
 
static int Storage_DestroyElement_limit
 
static IPersistStorage OleObjectPersistStg = { &OleObjectPersistStgVtbl }
 
static IOleCachecache
 
static IRunnableObjectrunnable
 
static const CLSID CLSID_WineTestOld
 
static const CLSID CLSID_WineTest
 
static const IID IID_WineTest
 
static const struct expected_methodexpected_method_list
 
static FORMATETC * g_expected_fetc = NULL
 
static BOOL g_showRunnable = TRUE
 
static BOOL g_isRunning = TRUE
 
static HRESULT g_GetMiscStatusFailsWith = S_OK
 
static HRESULT g_QIFailsWith
 
static UINT cf_test_1
 
static UINT cf_test_2
 
static UINT cf_test_3
 
static FORMATETC * g_dataobject_fmts
 
static const BYTE dib []
 
static const IOleObjectVtbl OleObjectVtbl
 
static IOleObject OleObject = { &OleObjectVtbl }
 
static const IPersistStorageVtbl OleObjectPersistStgVtbl
 
static const IOleCacheVtbl OleObjectCacheVtbl
 
static IOleCache OleObjectCache = { &OleObjectCacheVtbl }
 
static const IClassFactoryVtbl OleObjectCFVtbl
 
static IClassFactory OleObjectCF = { &OleObjectCFVtbl }
 
static const IRunnableObjectVtbl OleObjectRunnableVtbl
 
static IRunnableObject OleObjectRunnable = { &OleObjectRunnableVtbl }
 
static const CLSID CLSID_Equation3 = {0x0002CE02, 0x0000, 0x0000, {0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46} }
 
static const struct IViewObjectVtbl viewobjectvtbl
 
static IViewObject viewobject = { &viewobjectvtbl }
 
static const IAdviseSinkVtbl AdviseSinkVtbl
 
static IAdviseSink AdviseSink = { &AdviseSinkVtbl }
 
static IDataObjectVtbl DataObjectVtbl
 
static IDataObject DataObject = { &DataObjectVtbl }
 
static const IUnknownVtbl UnknownVtbl
 
static IUnknown unknown = { &UnknownVtbl }
 
static const WCHAR CONTENTS [] = {'C','O','N','T','E','N','T','S',0}
 
static BYTE file_dib []
 
static const IRunnableObjectVtbl oleruntestvtbl
 
static IRunnableObject testrunnable = { &oleruntestvtbl }
 
static const WCHAR olepres0W [] = {2,'O','l','e','P','r','e','s','0','0','0',0}
 
static const WCHAR comp_objW [] = {1,'C','o','m','p','O','b','j',0}
 
static IStreamcomp_obj_stream
 
static IStreamole_stream
 
static IStreamolepres_stream
 
static IStreamcontents_stream
 
static IStorageVtbl StorageVtbl
 
static IStorage Storage = { &StorageVtbl }
 
static const unsigned char bmpimage []
 
static const unsigned char mf_blank_bits []
 
static const struct storage_def stg_def_0
 
static const struct storage_def stg_def_0_saved
 
static const struct storage_def stg_def_1
 
static const struct storage_def stg_def_1_saved
 
static const struct storage_def stg_def_2
 
static const struct storage_def stg_def_2_saved
 
static const struct storage_def stg_def_3
 
static const struct storage_def stg_def_3_saved
 
static const struct storage_def stg_def_4
 
static const struct storage_def stg_def_4_saved
 
static const struct storage_def stg_def_5
 
static const struct storage_def stg_def_5_saved
 
static const struct storage_def stg_def_6
 
static const struct storage_def stg_def_6_saved
 
static const struct storage_def stg_def_7
 
static const struct storage_def stg_def_7_saved
 
static const struct storage_def stg_def_8
 
static const struct storage_def stg_def_8_saved
 
static const struct storage_def stg_def_9
 
static const struct storage_def stg_def_9_saved
 
static const BYTE dib_inf []
 
static const BYTE mf_rec []
 

Macro Definition Documentation

◆ CHECK_CALLED

#define CHECK_CALLED (   func)
Value:
do { \
ok(called_ ## func, "expected " #func "\n"); \
expect_ ## func = called_ ## func = FALSE; \
}while(0)
#define FALSE
Definition: types.h:117
GLenum func
Definition: glext.h:6028
#define expect_(expected, got, precision)
Definition: font.c:29

Definition at line 56 of file ole2.c.

◆ CHECK_EXPECT

#define CHECK_EXPECT (   func)
Value:
do { \
CHECK_EXPECT2(func); \
expect_ ## func = FALSE; \
}while(0)

Definition at line 50 of file ole2.c.

◆ CHECK_EXPECT2

#define CHECK_EXPECT2 (   func)
Value:
do { \
ok(expect_ ##func, "unexpected call " #func "\n"); \
called_ ## func = TRUE; \
}while(0)
#define TRUE
Definition: types.h:120

Definition at line 44 of file ole2.c.

◆ CHECK_EXPECTED_METHOD

#define CHECK_EXPECTED_METHOD (   method_name)    check_expected_method_fmt(method_name, NULL)

Definition at line 190 of file ole2.c.

◆ CHECK_EXPECTED_METHOD_FMT

#define CHECK_EXPECTED_METHOD_FMT (   method_name,
  fmt 
)    check_expected_method_fmt(method_name, fmt)

Definition at line 191 of file ole2.c.

◆ CHECK_NO_EXTRA_METHODS

#define CHECK_NO_EXTRA_METHODS ( )
Value:
do { \
ok(!expected_method_list->method, "Method sequence starting from %s not called\n", expected_method_list->method); \
} while (0)
static const struct expected_method * expected_method_list
Definition: ole2.c:112
#define TEST_OPTIONAL
Definition: ole2.c:102

Definition at line 193 of file ole2.c.

◆ COBJMACROS

#define COBJMACROS

Definition at line 22 of file ole2.c.

◆ CONST_VTABLE

#define CONST_VTABLE

Definition at line 23 of file ole2.c.

◆ DEFINE_EXPECT

#define DEFINE_EXPECT (   func)     static BOOL expect_ ## func = FALSE, called_ ## func = FALSE

Definition at line 38 of file ole2.c.

◆ MAX_FMTS

#define MAX_FMTS   5

Definition at line 4342 of file ole2.c.

◆ MAX_STREAM

#define MAX_STREAM   16

Definition at line 3835 of file ole2.c.

◆ ok_ole_success

#define ok_ole_success (   hr,
  func 
)    ok(hr == S_OK, func " failed with error 0x%08x\n", hr)

Definition at line 36 of file ole2.c.

◆ SET_EXPECT

#define SET_EXPECT (   func)     expect_ ## func = TRUE

Definition at line 41 of file ole2.c.

◆ TEST_OPTIONAL

#define TEST_OPTIONAL   0x1

Definition at line 102 of file ole2.c.

◆ TEST_TODO

#define TEST_TODO   0x2

Definition at line 103 of file ole2.c.

◆ WIN32_LEAN_AND_MEAN

#define WIN32_LEAN_AND_MEAN

Definition at line 24 of file ole2.c.

Typedef Documentation

◆ PresentationDataHeader

Function Documentation

◆ AdviseSink_AddRef()

static ULONG WINAPI AdviseSink_AddRef ( IAdviseSink iface)
static

Definition at line 1391 of file ole2.c.

1392{
1393 return 2;
1394}

◆ AdviseSink_OnClose()

static void WINAPI AdviseSink_OnClose ( IAdviseSink iface)
static

Definition at line 1430 of file ole2.c.

1431{
1432 CHECK_EXPECTED_METHOD("AdviseSink_OnClose");
1433}
#define CHECK_EXPECTED_METHOD(method_name)
Definition: ole2.c:190

◆ AdviseSink_OnDataChange()

static void WINAPI AdviseSink_OnDataChange ( IAdviseSink iface,
FORMATETC *  pFormatetc,
STGMEDIUM *  pStgmed 
)
static

Definition at line 1402 of file ole2.c.

1406{
1407 CHECK_EXPECTED_METHOD("AdviseSink_OnDataChange");
1408}

◆ AdviseSink_OnRename()

static void WINAPI AdviseSink_OnRename ( IAdviseSink iface,
IMoniker pmk 
)
static

Definition at line 1418 of file ole2.c.

1421{
1422 CHECK_EXPECTED_METHOD("AdviseSink_OnRename");
1423}

◆ AdviseSink_OnSave()

static void WINAPI AdviseSink_OnSave ( IAdviseSink iface)
static

Definition at line 1425 of file ole2.c.

1426{
1427 CHECK_EXPECTED_METHOD("AdviseSink_OnSave");
1428}

◆ AdviseSink_OnViewChange()

static void WINAPI AdviseSink_OnViewChange ( IAdviseSink iface,
DWORD  dwAspect,
LONG  lindex 
)
static

Definition at line 1410 of file ole2.c.

1414{
1415 CHECK_EXPECTED_METHOD("AdviseSink_OnViewChange");
1416}

◆ AdviseSink_QueryInterface()

static HRESULT WINAPI AdviseSink_QueryInterface ( IAdviseSink iface,
REFIID  riid,
void **  ppv 
)
static

Definition at line 1379 of file ole2.c.

1380{
1382 {
1383 *ppv = iface;
1384 IAdviseSink_AddRef(iface);
1385 return S_OK;
1386 }
1387 *ppv = NULL;
1388 return E_NOINTERFACE;
1389}
const GUID IID_IUnknown
#define NULL
Definition: types.h:112
REFIID riid
Definition: atlbase.h:39
REFIID LPVOID * ppv
Definition: atlbase.h:39
#define S_OK
Definition: intsafe.h:52
const GUID IID_IAdviseSink
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95
#define E_NOINTERFACE
Definition: winerror.h:2364

◆ AdviseSink_Release()

static ULONG WINAPI AdviseSink_Release ( IAdviseSink iface)
static

Definition at line 1396 of file ole2.c.

1397{
1398 return 1;
1399}

◆ check_bitmap_size()

static void check_bitmap_size ( HBITMAP  h,
int  cx,
int  cy 
)
static

Definition at line 2213 of file ole2.c.

2214{
2215 BITMAP bm;
2216
2217 GetObjectW( h, sizeof(bm), &bm );
2218 ok( bm.bmWidth == cx, "got %d expect %d\n", bm.bmWidth, cx );
2219 ok( bm.bmHeight == cy, "got %d expect %d\n", bm.bmHeight, cy );
2220}
#define ok(value,...)
Definition: atltest.h:57
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:586
_Out_opt_ int * cx
Definition: commctrl.h:585
Definition: bl.h:1331
int WINAPI GetObjectW(_In_ HANDLE h, _In_ int c, _Out_writes_bytes_opt_(c) LPVOID pv)

Referenced by test_data_cache_cache().

◆ check_dib_size()

static void check_dib_size ( HGLOBAL  h,
int  cx,
int  cy 
)
static

Definition at line 2222 of file ole2.c.

2223{
2225
2226 info = GlobalLock( h );
2227 ok( info->bmiHeader.biWidth == cx, "got %d expect %d\n", info->bmiHeader.biWidth, cx );
2228 ok( info->bmiHeader.biHeight == cy, "got %d expect %d\n", info->bmiHeader.biHeight, cy );
2229 GlobalUnlock( h );
2230}
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190

Referenced by test_data_cache_cache().

◆ check_enum_cache()

static void check_enum_cache ( IOleCache2 cache,
const STATDATA *  expect,
int  num 
)
static

Definition at line 1659 of file ole2.c.

1660{
1661 IEnumSTATDATA *enum_stat;
1662 STATDATA stat;
1663 HRESULT hr;
1664
1665 hr = IOleCache2_EnumCache( cache, &enum_stat );
1666 ok( hr == S_OK, "got %08x\n", hr );
1667
1668 while (IEnumSTATDATA_Next(enum_stat, 1, &stat, NULL) == S_OK)
1669 {
1670 ok( stat.formatetc.cfFormat == expect->formatetc.cfFormat, "got %d expect %d\n",
1671 stat.formatetc.cfFormat, expect->formatetc.cfFormat );
1672 ok( !stat.formatetc.ptd == !expect->formatetc.ptd, "got %p expect %p\n",
1673 stat.formatetc.ptd, expect->formatetc.ptd );
1674 ok( stat.formatetc.dwAspect == expect->formatetc.dwAspect, "got %d expect %d\n",
1675 stat.formatetc.dwAspect, expect->formatetc.dwAspect );
1676 ok( stat.formatetc.lindex == expect->formatetc.lindex, "got %d expect %d\n",
1677 stat.formatetc.lindex, expect->formatetc.lindex );
1678 ok( stat.formatetc.tymed == expect->formatetc.tymed, "got %d expect %d\n",
1679 stat.formatetc.tymed, expect->formatetc.tymed );
1680 ok( stat.advf == expect->advf, "got %d expect %d\n", stat.advf, expect->advf );
1681 ok( stat.pAdvSink == 0, "got %p\n", stat.pAdvSink );
1682 ok( stat.dwConnection == expect->dwConnection, "got %d expect %d\n", stat.dwConnection, expect->dwConnection );
1683 num--;
1684 expect++;
1685 }
1686
1687 ok( num == 0, "incorrect number. num %d\n", num );
1688
1689 IEnumSTATDATA_Release( enum_stat );
1690}
#define expect(EXPECTED, GOT)
Definition: SystemMenu.c:483
#define stat
Definition: acwin.h:99
GLuint GLuint num
Definition: glext.h:9618
HRESULT hr
Definition: shlfolder.c:183
Definition: cache.c:49
Definition: stat.h:55

Referenced by test_data_cache_cache(), test_data_cache_dib_contents_stream(), test_data_cache_init(), test_data_cache_initnew(), and test_data_cache_updatecache().

◆ check_expected_method_fmt()

static void check_expected_method_fmt ( const char method_name,
const FORMATETC *  fmt 
)
inlinestatic

Definition at line 154 of file ole2.c.

156{
157 trace("%s\n", method_name);
158 ok(expected_method_list->method != NULL, "Extra method %s called\n", method_name);
159 if (!strcmp(expected_method_list->method, "WINE_EXTRA"))
160 {
161 todo_wine ok(0, "Too many method calls.\n");
162 return;
163 }
164 if (expected_method_list->method)
165 {
166 while (expected_method_list->flags & TEST_OPTIONAL &&
167 strcmp(expected_method_list->method, method_name) != 0)
170 {
171 ok(!strcmp(expected_method_list->method, method_name),
172 "Expected %s to be called instead of %s\n",
173 expected_method_list->method, method_name);
174 if (fmt)
175 {
176 ok(fmt->cfFormat == expected_method_list->fmt.cfFormat, "got cf %04x vs %04x\n",
177 fmt->cfFormat, expected_method_list->fmt.cfFormat );
178 ok(fmt->dwAspect == expected_method_list->fmt.dwAspect, "got aspect %d vs %d\n",
179 fmt->dwAspect, expected_method_list->fmt.dwAspect );
180 ok(fmt->lindex == expected_method_list->fmt.lindex, "got lindex %d vs %d\n",
181 fmt->lindex, expected_method_list->fmt.lindex );
182 ok(fmt->tymed == expected_method_list->fmt.tymed, "got tymed %d vs %d\n",
183 fmt->tymed, expected_method_list->fmt.tymed );
184 }
185 }
187 }
188}
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define trace
Definition: atltest.h:70
#define todo_wine_if(is_todo)
Definition: custom.c:86
#define todo_wine
Definition: custom.c:89
#define TEST_TODO
Definition: ole2.c:103
Definition: dsound.c:943

◆ check_storage_contents()

static void check_storage_contents ( IStorage stg,
const struct storage_def stg_def,
int enumerated_streams,
int matched_streams 
)
static

Definition at line 3994 of file ole2.c.

3996{
3997 HRESULT hr;
3998 IEnumSTATSTG *enumstg;
3999 IStream *stream;
4000 STATSTG stat;
4001 int i, seen_stream[MAX_STREAM] = { 0 };
4002
4003 if (winetest_debug > 1)
4004 trace("check_storage_contents:\n=============================================\n");
4005
4006 *enumerated_streams = 0;
4007 *matched_streams = 0;
4008
4009 hr = IStorage_Stat(stg, &stat, STATFLAG_NONAME);
4010 ok(hr == S_OK, "unexpected %#x\n", hr);
4011 ok(IsEqualCLSID(stg_def->clsid, &stat.clsid), "expected %s, got %s\n",
4012 wine_dbgstr_guid(stg_def->clsid), wine_dbgstr_guid(&stat.clsid));
4013
4014 hr = IStorage_EnumElements(stg, 0, NULL, 0, &enumstg);
4015 ok(hr == S_OK, "unexpected %#x\n", hr);
4016
4017 for (;;)
4018 {
4019 ULONG bytes;
4020 int clipformat = -1;
4022 char name[32];
4023 BYTE data[1024];
4024
4025 memset(&header, 0, sizeof(header));
4026
4027 hr = IEnumSTATSTG_Next(enumstg, 1, &stat, NULL);
4028 if(hr == S_FALSE) break;
4029 ok(hr == S_OK, "unexpected %#x\n", hr);
4030
4031 if (winetest_debug > 1)
4032 trace("name %s, type %u, size %d, clsid %s\n",
4033 wine_dbgstr_w(stat.pwcsName), stat.type, stat.cbSize.u.LowPart, wine_dbgstr_guid(&stat.clsid));
4034
4035 ok(stat.type == STGTY_STREAM, "unexpected %#x\n", stat.type);
4036
4037 WideCharToMultiByte(CP_ACP, 0, stat.pwcsName, -1, name, sizeof(name), NULL, NULL);
4038
4039 hr = IStorage_OpenStream(stg, stat.pwcsName, NULL, STGM_READ | STGM_SHARE_EXCLUSIVE, 0, &stream);
4040 ok(hr == S_OK, "unexpected %#x\n", hr);
4041
4042 if (!memcmp(name, "\2OlePres", 8))
4043 {
4044 ULONG header_size = sizeof(header);
4045
4046 clipformat = read_clipformat(stream);
4047
4048 if (clipformat == 0) /* view cache */
4049 header_size = FIELD_OFFSET(PresentationDataHeader, unknown7);
4050
4051 hr = IStream_Read(stream, &header, header_size, &bytes);
4052 ok(hr == S_OK, "unexpected %#x\n", hr);
4053 ok(bytes == header_size, "read %u bytes, expected %u\n", bytes, header_size);
4054
4055 if (winetest_debug > 1)
4056 trace("header: tdSize %#x, dvAspect %#x, lindex %#x, advf %#x, unknown7 %#x, dwObjectExtentX %#x, dwObjectExtentY %#x, dwSize %#x\n",
4057 header.tdSize, header.dvAspect, header.lindex, header.advf, header.unknown7,
4058 header.dwObjectExtentX, header.dwObjectExtentY, header.dwSize);
4059 }
4060
4061 memset(data, 0, sizeof(data));
4062 hr = IStream_Read(stream, data, sizeof(data), &bytes);
4063 ok(hr == S_OK, "unexpected %#x\n", hr);
4064 if (winetest_debug > 1)
4065 trace("stream data (%u bytes): %02x %02x %02x %02x\n", bytes, data[0], data[1], data[2], data[3]);
4066
4067 for (i = 0; i < stg_def->stream_count; i++)
4068 {
4069 if (seen_stream[i]) continue;
4070
4071 if (winetest_debug > 1)
4072 trace("%s/%s, %d/%d, %d/%d, %d/%d\n",
4073 stg_def->stream[i].name, name,
4074 stg_def->stream[i].cf, clipformat,
4075 stg_def->stream[i].dvAspect, header.dvAspect,
4076 stg_def->stream[i].advf, header.advf);
4077
4078 if (!strcmp(stg_def->stream[i].name, name) &&
4079 stg_def->stream[i].cf == clipformat &&
4080 stg_def->stream[i].dvAspect == header.dvAspect &&
4081 stg_def->stream[i].advf == header.advf &&
4082 stg_def->stream[i].data_size <= bytes &&
4083 (!stg_def->stream[i].data_size ||
4084 (!memcmp(stg_def->stream[i].data, data, min(stg_def->stream[i].data_size, bytes)))))
4085 {
4086 if (winetest_debug > 1)
4087 trace("stream %d matches def stream %d\n", *enumerated_streams, i);
4088 seen_stream[i] = 1;
4089 *matched_streams += 1;
4090 }
4091 }
4092
4093 CoTaskMemFree(stat.pwcsName);
4094 IStream_Release(stream);
4095
4096 *enumerated_streams += 1;
4097 }
4098
4099 IEnumSTATSTG_Release(enumstg);
4100}
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
static unsigned char bytes[4]
Definition: adnsresfilter.c:74
#define CP_ACP
Definition: compat.h:109
#define WideCharToMultiByte
Definition: compat.h:111
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:442
#define wine_dbgstr_w
Definition: kernel32.h:34
#define MAX_STREAM
Definition: ole2.c:3835
static int read_clipformat(IStream *stream)
Definition: ole2.c:3971
#define min(a, b)
Definition: monoChain.cc:55
#define STGM_SHARE_EXCLUSIVE
Definition: objbase.h:923
#define STGM_READ
Definition: objbase.h:917
#define IsEqualCLSID(rclsid1, rclsid2)
Definition: guiddef.h:96
static __inline const char * wine_dbgstr_guid(const GUID *id)
Definition: debug.h:197
int winetest_debug
#define memset(x, y, z)
Definition: compat.h:39
Definition: name.c:39
int stream_count
Definition: ole2.c:3850
const CLSID * clsid
Definition: ole2.c:3849
struct stream_def stream[MAX_STREAM]
Definition: ole2.c:3851
Definition: parse.h:23
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
uint32_t ULONG
Definition: typedefs.h:59
#define S_FALSE
Definition: winerror.h:2357
unsigned char BYTE
Definition: xxhash.c:193

Referenced by test_data_cache_contents(), test_data_cache_save_data(), and test_OleCreateStaticFromData().

◆ create_bitmap()

static void create_bitmap ( STGMEDIUM *  med)
static

Definition at line 223 of file ole2.c.

224{
225 med->tymed = TYMED_GDI;
226 U(med)->hBitmap = CreateBitmap( 1, 1, 1, 1, NULL );
227 med->pUnkForRelease = NULL;
228}
#define U(x)
Definition: wordpad.c:45
HBITMAP WINAPI CreateBitmap(_In_ INT cx, _In_ INT cy, _In_ UINT cPlanes, _In_ UINT cBitsPerPel, _In_opt_ const VOID *pvBits)

◆ create_dib()

static void create_dib ( STGMEDIUM *  med)
static

Definition at line 211 of file ole2.c.

212{
213 void *ptr;
214
215 med->tymed = TYMED_HGLOBAL;
216 U(med)->hGlobal = GlobalAlloc( GMEM_MOVEABLE, sizeof(dib) );
217 ptr = GlobalLock( U(med)->hGlobal );
218 memcpy( ptr, dib, sizeof(dib) );
219 GlobalUnlock( U(med)->hGlobal );
220 med->pUnkForRelease = NULL;
221}
HGLOBAL NTAPI GlobalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:368
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static PVOID ptr
Definition: dispmode.c:27
static const BYTE dib[]
Definition: ole2.c:201
#define GMEM_MOVEABLE
Definition: winbase.h:294

Referenced by DataObject_GetData(), get_stgmedium(), test_data_cache_cache(), and wined3d_texture_update_desc().

◆ create_emf()

static void create_emf ( STGMEDIUM *  med)
static

Definition at line 230 of file ole2.c.

231{
233
234 Rectangle(hdc, 0, 0, 150, 300);
235 med->tymed = TYMED_ENHMF;
236 U(med)->hEnhMetaFile = CloseEnhMetaFile(hdc);
237 med->pUnkForRelease = NULL;
238}
HDC hdc
Definition: main.c:9
static HDC
Definition: imagelist.c:88
HDC WINAPI CreateEnhMetaFileW(_In_opt_ HDC, _In_opt_ LPCWSTR, _In_opt_ LPCRECT, _In_opt_ LPCWSTR)
HENHMETAFILE WINAPI CloseEnhMetaFile(_In_ HDC hdc)
BOOL WINAPI Rectangle(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)

◆ create_mfpict()

static void create_mfpict ( STGMEDIUM *  med)
static

Definition at line 240 of file ole2.c.

241{
242 METAFILEPICT *mf;
244
245 Rectangle(hdc, 0, 0, 100, 200);
246
247 med->tymed = TYMED_MFPICT;
248 U(med)->hMetaFilePict = GlobalAlloc(GMEM_MOVEABLE, sizeof(METAFILEPICT));
249 mf = GlobalLock(U(med)->hMetaFilePict);
250 mf->mm = MM_ANISOTROPIC;
251 mf->xExt = 100;
252 mf->yExt = 200;
253 mf->hMF = CloseMetaFile(hdc);
254 GlobalUnlock(U(med)->hMetaFilePict);
255 med->pUnkForRelease = NULL;
256}
HMETAFILE hMF
Definition: wingdi.h:2608
#define MM_ANISOTROPIC
Definition: wingdi.h:867
HMETAFILE WINAPI CloseMetaFile(_In_ HDC hdc)
HDC WINAPI CreateMetaFileW(_In_opt_ LPCWSTR)

Referenced by get_stgmedium().

◆ create_storage()

static IStorage * create_storage ( int  num)
static

Definition at line 2099 of file ole2.c.

2100{
2101 IStorage *stg;
2102 IStream *stm;
2103 HRESULT hr;
2104 ULONG written;
2105
2107 ok( hr == S_OK, "got %08x\n", hr);
2108 hr = IStorage_SetClass( stg, &CLSID_Picture_Dib );
2109 ok( hr == S_OK, "got %08x\n", hr);
2110 hr = IStorage_CreateStream( stg, CONTENTS, STGM_READWRITE | STGM_SHARE_EXCLUSIVE | STGM_CREATE, 0, 0, &stm );
2111 ok( hr == S_OK, "got %08x\n", hr);
2112 if (num == 1) /* Set biXPelsPerMeter = 0 */
2113 {
2114 file_dib[0x26] = 0;
2115 file_dib[0x27] = 0;
2116 }
2117 hr = IStream_Write( stm, file_dib, sizeof(file_dib), &written );
2118 ok( hr == S_OK, "got %08x\n", hr);
2119 IStream_Release( stm );
2120 return stg;
2121}
const CLSID CLSID_Picture_Dib
HRESULT WINAPI StgCreateDocfile(LPCOLESTR pwcsName, DWORD grfMode, DWORD reserved, IStorage **ppstgOpen)
Definition: storage32.c:8636
static BYTE file_dib[]
Definition: ole2.c:2087
static const WCHAR CONTENTS[]
Definition: ole2.c:2084
#define STGM_CREATE
Definition: objbase.h:926
#define STGM_READWRITE
Definition: objbase.h:919
#define STGM_DELETEONRELEASE
Definition: objbase.h:925

◆ create_storage_from_def()

static IStorage * create_storage_from_def ( const struct storage_def stg_def)
static

Definition at line 4179 of file ole2.c.

4180{
4181 HRESULT hr;
4182 IStorage *stg;
4183 IStream *stm;
4184 int i;
4185
4187 ok(hr == S_OK, "unexpected %#x\n", hr);
4188
4189 hr = IStorage_SetClass(stg, stg_def->clsid);
4190 ok(hr == S_OK, "unexpected %#x\n", hr);
4191
4192 for (i = 0; i < stg_def->stream_count; i++)
4193 {
4194 WCHAR name[32];
4195
4196 MultiByteToWideChar(CP_ACP, 0, stg_def->stream[i].name, -1, name, 32);
4197 hr = IStorage_CreateStream(stg, name, STGM_READWRITE | STGM_SHARE_EXCLUSIVE, 0, 0, &stm);
4198 ok(hr == S_OK, "unexpected %#x\n", hr);
4199
4200 if (stg_def->stream[i].cf != -1)
4201 {
4202 int clipformat[2];
4204
4205 if (stg_def->stream[i].cf)
4206 {
4207 clipformat[0] = -1;
4208 clipformat[1] = stg_def->stream[i].cf;
4209 hr = IStream_Write(stm, clipformat, sizeof(clipformat), NULL);
4210 }
4211 else
4212 {
4213 clipformat[0] = 0;
4214 hr = IStream_Write(stm, &clipformat[0], sizeof(clipformat[0]), NULL);
4215 }
4216 ok(hr == S_OK, "unexpected %#x\n", hr);
4217
4218 hdr.tdSize = sizeof(hdr.tdSize);
4219 hdr.dvAspect = stg_def->stream[i].dvAspect;
4220 hdr.lindex = -1;
4221 hdr.advf = stg_def->stream[i].advf;
4222 hdr.unknown7 = 0;
4223 hdr.dwObjectExtentX = 0;
4224 hdr.dwObjectExtentY = 0;
4225 hdr.dwSize = stg_def->stream[i].data_size;
4226 hr = IStream_Write(stm, &hdr, sizeof(hdr), NULL);
4227 ok(hr == S_OK, "unexpected %#x\n", hr);
4228 }
4229
4230 if (stg_def->stream[i].data_size)
4231 {
4232 hr = IStream_Write(stm, stg_def->stream[i].data, stg_def->stream[i].data_size, NULL);
4233 ok(hr == S_OK, "unexpected %#x\n", hr);
4234 }
4235
4236 IStream_Release(stm);
4237 }
4238
4239 return stg;
4240}
#define MultiByteToWideChar
Definition: compat.h:110
char hdr[14]
Definition: iptest.cpp:33
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by test_data_cache_contents().

◆ create_text()

static void create_text ( STGMEDIUM *  med)
static

Definition at line 258 of file ole2.c.

259{
261 char *p;
262
265 strcpy(p, "test");
267
268 med->tymed = TYMED_HGLOBAL;
269 U(med)->hGlobal = handle;
270 med->pUnkForRelease = NULL;
271}
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
GLfloat GLfloat p
Definition: glext.h:8902
#define GMEM_DDESHARE
Definition: winbase.h:298

◆ DataObject_AddRef()

static ULONG WINAPI DataObject_AddRef ( IDataObject iface)
static

Definition at line 1465 of file ole2.c.

1467{
1468 CHECK_EXPECTED_METHOD("DataObject_AddRef");
1469 return 2;
1470}

◆ DataObject_DAdvise()

static HRESULT WINAPI DataObject_DAdvise ( IDataObject iface,
FORMATETC *  pformatetc,
DWORD  advf,
IAdviseSink pAdvSink,
DWORD pdwConnection 
)
static

Definition at line 1570 of file ole2.c.

1576{
1577 STGMEDIUM stgmedium;
1578
1579 CHECK_EXPECTED_METHOD("DataObject_DAdvise");
1580 *pdwConnection = 1;
1581
1582 if(advf & ADVF_PRIMEFIRST)
1583 {
1584 ok(pformatetc->cfFormat == cf_test_2, "got %04x\n", pformatetc->cfFormat);
1585 stgmedium.tymed = TYMED_HGLOBAL;
1586 U(stgmedium).hGlobal = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, 4);
1587 stgmedium.pUnkForRelease = NULL;
1588 IAdviseSink_OnDataChange(pAdvSink, pformatetc, &stgmedium);
1589 }
1590
1591 return S_OK;
1592}
static UINT cf_test_2
Definition: ole2.c:120
#define GMEM_ZEROINIT
Definition: winbase.h:306

◆ DataObject_DUnadvise()

static HRESULT WINAPI DataObject_DUnadvise ( IDataObject iface,
DWORD  dwConnection 
)
static

Definition at line 1594 of file ole2.c.

1597{
1598 CHECK_EXPECTED_METHOD("DataObject_DUnadvise");
1599 return S_OK;
1600}

◆ DataObject_EnumDAdvise()

static HRESULT WINAPI DataObject_EnumDAdvise ( IDataObject iface,
IEnumSTATDATA **  ppenumAdvise 
)
static

Definition at line 1602 of file ole2.c.

1605{
1606 CHECK_EXPECTED_METHOD("DataObject_EnumDAdvise");
1608}
#define OLE_E_ADVISENOTSUPPORTED
Definition: winerror.h:2617

◆ DataObject_EnumFormatEtc()

static HRESULT WINAPI DataObject_EnumFormatEtc ( IDataObject iface,
DWORD  dwDirection,
IEnumFORMATETC **  ppenumFormatEtc 
)
static

Definition at line 1561 of file ole2.c.

1565{
1566 CHECK_EXPECTED_METHOD("DataObject_EnumFormatEtc");
1567 return E_NOTIMPL;
1568}
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ DataObject_GetCanonicalFormatEtc()

static HRESULT WINAPI DataObject_GetCanonicalFormatEtc ( IDataObject iface,
LPFORMATETC  pformatectIn,
LPFORMATETC  pformatetcOut 
)
static

Definition at line 1542 of file ole2.c.

1546{
1547 CHECK_EXPECTED_METHOD("DataObject_GetCanonicalFormatEtc");
1548 return E_NOTIMPL;
1549}

◆ DataObject_GetData()

static HRESULT WINAPI DataObject_GetData ( IDataObject iface,
FORMATETC *  fmt_in,
STGMEDIUM *  med 
)
static

Definition at line 1487 of file ole2.c.

1489{
1490 FORMATETC *fmt;
1491
1492 CHECK_EXPECTED_METHOD_FMT("DataObject_GetData", fmt_in);
1493
1494 for (fmt = g_dataobject_fmts; fmt && fmt->cfFormat != 0; fmt++)
1495 {
1496 if (fmtetc_equal( fmt_in, fmt ))
1497 {
1498 switch (fmt->cfFormat)
1499 {
1500 case CF_DIB:
1501 create_dib( med );
1502 return S_OK;
1503 case CF_BITMAP:
1504 create_bitmap( med );
1505 return S_OK;
1506 case CF_ENHMETAFILE:
1507 create_emf( med );
1508 return S_OK;
1509 case CF_TEXT:
1510 create_text( med );
1511 return S_OK;
1512 default:
1513 trace( "unhandled fmt %d\n", fmt->cfFormat );
1514 }
1515 }
1516 }
1517
1518 return S_FALSE;
1519}
#define CF_BITMAP
Definition: constants.h:397
#define CF_ENHMETAFILE
Definition: constants.h:409
#define CF_TEXT
Definition: constants.h:396
#define CF_DIB
Definition: constants.h:403
static HGLOBAL create_text(void)
Definition: clipboard.c:1496
static HENHMETAFILE create_emf(void)
Definition: clipboard.c:1505
#define CHECK_EXPECTED_METHOD_FMT(method_name, fmt)
Definition: ole2.c:191
static void create_dib(STGMEDIUM *med)
Definition: ole2.c:211
static BOOL fmtetc_equal(const FORMATETC *a, const FORMATETC *b)
Definition: ole2.c:1479
static FORMATETC * g_dataobject_fmts
Definition: ole2.c:122
static HBITMAP create_bitmap(void)
Definition: clipboard.c:534

◆ DataObject_GetDataHere()

static HRESULT WINAPI DataObject_GetDataHere ( IDataObject iface,
LPFORMATETC  pformatetc,
STGMEDIUM *  pmedium 
)
static

Definition at line 1521 of file ole2.c.

1525{
1526 CHECK_EXPECTED_METHOD("DataObject_GetDataHere");
1527 return E_NOTIMPL;
1528}

◆ DataObject_QueryGetData()

static HRESULT WINAPI DataObject_QueryGetData ( IDataObject iface,
FORMATETC *  fmt_in 
)
static

Definition at line 1530 of file ole2.c.

1531{
1532 FORMATETC *fmt;
1533
1534 CHECK_EXPECTED_METHOD_FMT("DataObject_QueryGetData", fmt_in);
1535
1536 for (fmt = g_dataobject_fmts; fmt && fmt->cfFormat != 0; fmt++)
1537 if (fmtetc_equal( fmt_in, fmt )) return S_OK;
1538
1539 return S_FALSE;
1540}

◆ DataObject_QueryInterface()

static HRESULT WINAPI DataObject_QueryInterface ( IDataObject iface,
REFIID  riid,
void **  ppvObject 
)
static

Definition at line 1449 of file ole2.c.

1453{
1454 CHECK_EXPECTED_METHOD("DataObject_QueryInterface");
1455
1457 {
1458 *ppvObject = iface;
1459 return S_OK;
1460 }
1461 *ppvObject = NULL;
1462 return S_OK;
1463}
const GUID IID_IDataObject
_In_ void _In_ PCCERT_CONTEXT _In_opt_ LPFILETIME _In_ DWORD _In_ DWORD _Outptr_opt_ void ** ppvObject
Definition: wincrypt.h:6082

◆ DataObject_Release()

static ULONG WINAPI DataObject_Release ( IDataObject iface)
static

Definition at line 1472 of file ole2.c.

1474{
1475 CHECK_EXPECTED_METHOD("DataObject_Release");
1476 return 1;
1477}

◆ DataObject_SetData()

static HRESULT WINAPI DataObject_SetData ( IDataObject iface,
LPFORMATETC  pformatetc,
STGMEDIUM *  pmedium,
BOOL  fRelease 
)
static

Definition at line 1551 of file ole2.c.

1556{
1557 CHECK_EXPECTED_METHOD("DataObject_SetData");
1558 return E_NOTIMPL;
1559}

◆ DEFINE_EXPECT() [1/8]

DEFINE_EXPECT ( Storage_CreateStream_CompObj  )

◆ DEFINE_EXPECT() [2/8]

DEFINE_EXPECT ( Storage_CreateStream_OlePres  )

◆ DEFINE_EXPECT() [3/8]

DEFINE_EXPECT ( Storage_DestroyElement  )

◆ DEFINE_EXPECT() [4/8]

DEFINE_EXPECT ( Storage_OpenStream_CompObj  )

◆ DEFINE_EXPECT() [5/8]

DEFINE_EXPECT ( Storage_OpenStream_Ole  )

◆ DEFINE_EXPECT() [6/8]

DEFINE_EXPECT ( Storage_OpenStream_OlePres  )

◆ DEFINE_EXPECT() [7/8]

DEFINE_EXPECT ( Storage_SetClass  )

◆ DEFINE_EXPECT() [8/8]

DEFINE_EXPECT ( Storage_Stat  )

◆ draw_continue()

static BOOL STDMETHODCALLTYPE draw_continue ( ULONG_PTR  param)
static

Definition at line 1367 of file ole2.c.

1368{
1369 CHECK_EXPECTED_METHOD("draw_continue");
1370 return TRUE;
1371}

Referenced by test_data_cache().

◆ draw_continue_false()

static BOOL STDMETHODCALLTYPE draw_continue_false ( ULONG_PTR  param)
static

Definition at line 1373 of file ole2.c.

1374{
1375 CHECK_EXPECTED_METHOD("draw_continue_false");
1376 return FALSE;
1377}

Referenced by test_data_cache().

◆ fmtetc_equal()

static BOOL fmtetc_equal ( const FORMATETC *  a,
const FORMATETC *  b 
)
inlinestatic

Definition at line 1479 of file ole2.c.

1480{
1481 /* FIXME ptd */
1482 return a->cfFormat == b->cfFormat && a->dwAspect == b->dwAspect &&
1483 a->lindex == b->lindex && a->tymed == b->tymed;
1484
1485}
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204

Referenced by DataObject_GetData(), and DataObject_QueryGetData().

◆ get_stgdef()

static void get_stgdef ( struct storage_def stg_def,
CLIPFORMAT  cf,
STGMEDIUM *  stg_med,
int  stm_idx 
)
static

Definition at line 4255 of file ole2.c.

4256{
4257 BYTE *data;
4258 int data_size;
4259 METAFILEPICT *mfpict;
4260 HDC hdc;
4261
4262 switch (cf)
4263 {
4264 case CF_DIB:
4265 data_size = sizeof(dib);
4266 if (!strcmp(stg_def->stream[stm_idx].name, "CONTENTS"))
4267 {
4268 data_size += sizeof(dib_inf);
4269 data = HeapAlloc(GetProcessHeap(), 0, data_size);
4270 memcpy(data, dib_inf, sizeof(dib_inf));
4271 memcpy(data + sizeof(dib_inf), dib, sizeof(dib));
4272 }
4273 else
4274 {
4275 data = HeapAlloc(GetProcessHeap(), 0, data_size);
4276 memcpy(data, dib, sizeof(dib));
4277 }
4278 stg_def->stream[stm_idx].data = data;
4279 stg_def->stream[stm_idx].data_size = data_size;
4280 break;
4281 case CF_METAFILEPICT:
4282 mfpict = GlobalLock(U(stg_med)->hMetaFilePict);
4283 data_size = GetMetaFileBitsEx(mfpict->hMF, 0, NULL);
4284 if (!strcmp(stg_def->stream[stm_idx].name, "CONTENTS"))
4285 {
4286 data = HeapAlloc(GetProcessHeap(), 0, data_size + sizeof(mf_rec));
4287 memcpy(data, mf_rec, sizeof(mf_rec));
4288 GetMetaFileBitsEx(mfpict->hMF, data_size, data + sizeof(mf_rec));
4289 data_size += sizeof(mf_rec);
4290 }
4291 else
4292 {
4293 data = HeapAlloc(GetProcessHeap(), 0, data_size);
4294 GetMetaFileBitsEx(mfpict->hMF, data_size, data);
4295 }
4296 GlobalUnlock(U(stg_med)->hMetaFilePict);
4297 stg_def->stream[stm_idx].data_size = data_size;
4298 stg_def->stream[stm_idx].data = data;
4299 break;
4300 case CF_ENHMETAFILE:
4301 if (!strcmp(stg_def->stream[stm_idx].name, "CONTENTS"))
4302 {
4303 data_size = GetEnhMetaFileBits(U(stg_med)->hEnhMetaFile, 0, NULL);
4304 data = HeapAlloc(GetProcessHeap(), 0, sizeof(DWORD) + sizeof(ENHMETAHEADER) + data_size);
4305 *((DWORD *)data) = sizeof(ENHMETAHEADER);
4306 GetEnhMetaFileBits(U(stg_med)->hEnhMetaFile, data_size, data + sizeof(DWORD) + sizeof(ENHMETAHEADER));
4307 memcpy(data + sizeof(DWORD), data + sizeof(DWORD) + sizeof(ENHMETAHEADER), sizeof(ENHMETAHEADER));
4308 data_size += sizeof(DWORD) + sizeof(ENHMETAHEADER);
4309 }
4310 else
4311 {
4312 hdc = GetDC(NULL);
4313 data_size = GetWinMetaFileBits(U(stg_med)->hEnhMetaFile, 0, NULL, MM_ANISOTROPIC, hdc);
4314 data = HeapAlloc(GetProcessHeap(), 0, data_size);
4315 GetWinMetaFileBits(U(stg_med)->hEnhMetaFile, data_size, data, MM_ANISOTROPIC, hdc);
4316 ReleaseDC(NULL, hdc);
4317 }
4318 stg_def->stream[stm_idx].data_size = data_size;
4319 stg_def->stream[stm_idx].data = data;
4320 break;
4321 }
4322}
#define CF_METAFILEPICT
Definition: constants.h:398
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
unsigned long DWORD
Definition: ntddk_ex.h:95
static const BYTE dib_inf[]
Definition: ole2.c:4242
static const BYTE mf_rec[]
Definition: ole2.c:4248
#define DWORD
Definition: nt_native.h:44
UINT WINAPI GetEnhMetaFileBits(_In_ HENHMETAFILE hEMF, _In_ UINT nSize, _Out_writes_bytes_opt_(nSize) LPBYTE lpData)
UINT WINAPI GetWinMetaFileBits(_In_ HENHMETAFILE hemf, _In_ UINT cbData16, _Out_writes_bytes_opt_(cbData16) LPBYTE pData16, _In_ INT iMapMode, _In_ HDC hdcRef)
UINT WINAPI GetMetaFileBitsEx(_In_ HMETAFILE hMF, _In_ UINT cbBuffer, _Out_writes_bytes_opt_(cbBuffer) LPVOID lpData)
struct tagENHMETAHEADER ENHMETAHEADER
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
HDC WINAPI GetDC(_In_opt_ HWND)

Referenced by test_data_cache_save_data(), and test_OleCreateStaticFromData().

◆ get_stgmedium()

static void get_stgmedium ( CLIPFORMAT  cfFormat,
STGMEDIUM *  stgmedium 
)
static

Definition at line 4324 of file ole2.c.

4325{
4326 switch (cfFormat)
4327 {
4328 case CF_DIB:
4329 create_dib(stgmedium);
4330 break;
4331 case CF_METAFILEPICT:
4332 create_mfpict(stgmedium);
4333 break;
4334 case CF_ENHMETAFILE:
4335 create_emf(stgmedium);
4336 break;
4337 default:
4338 ok(0, "cf %x not implemented\n", cfFormat);
4339 }
4340}
static void create_mfpict(STGMEDIUM *med)
Definition: ole2.c:240

Referenced by test_data_cache_save_data(), and test_OleCreateStaticFromData().

◆ OleObject_AddRef()

static ULONG WINAPI OleObject_AddRef ( IOleObject iface)
static

Definition at line 299 of file ole2.c.

300{
301 CHECK_EXPECTED_METHOD("OleObject_AddRef");
302 return 2;
303}

◆ OleObject_Advise()

static HRESULT WINAPI OleObject_Advise ( IOleObject iface,
IAdviseSink pAdvSink,
DWORD pdwConnection 
)
static

Definition at line 484 of file ole2.c.

490{
491 CHECK_EXPECTED_METHOD("OleObject_Advise");
492 return S_OK;
493}

◆ OleObject_Close()

static HRESULT WINAPI OleObject_Close ( IOleObject iface,
DWORD  dwSaveOption 
)
static

Definition at line 342 of file ole2.c.

347{
348 CHECK_EXPECTED_METHOD("OleObject_Close");
349 return S_OK;
350}

◆ OleObject_DoVerb()

static HRESULT WINAPI OleObject_DoVerb ( IOleObject iface,
LONG  iVerb,
LPMSG  lpmsg,
IOleClientSite pActiveSite,
LONG  lindex,
HWND  hwndParent,
LPCRECT  lprcPosRect 
)
static

Definition at line 398 of file ole2.c.

408{
409 CHECK_EXPECTED_METHOD("OleObject_DoVerb");
410 return S_OK;
411}

◆ OleObject_EnumAdvise()

static HRESULT WINAPI OleObject_EnumAdvise ( IOleObject iface,
IEnumSTATDATA **  ppenumAdvise 
)
static

Definition at line 505 of file ole2.c.

510{
511 CHECK_EXPECTED_METHOD("OleObject_EnumAdvise");
512 return E_NOTIMPL;
513}

◆ OleObject_EnumVerbs()

static HRESULT WINAPI OleObject_EnumVerbs ( IOleObject iface,
IEnumOLEVERB **  ppEnumOleVerb 
)
static

Definition at line 413 of file ole2.c.

418{
419 CHECK_EXPECTED_METHOD("OleObject_EnumVerbs");
420 return E_NOTIMPL;
421}

◆ OleObject_GetClientSite()

static HRESULT WINAPI OleObject_GetClientSite ( IOleObject iface,
IOleClientSite **  ppClientSite 
)
static

Definition at line 321 of file ole2.c.

326{
327 CHECK_EXPECTED_METHOD("OleObject_GetClientSite");
328 return E_NOTIMPL;
329}

◆ OleObject_GetClipboardData()

static HRESULT WINAPI OleObject_GetClipboardData ( IOleObject iface,
DWORD  dwReserved,
IDataObject **  ppDataObject 
)
static

Definition at line 387 of file ole2.c.

393{
394 CHECK_EXPECTED_METHOD("OleObject_GetClipboardData");
395 return E_NOTIMPL;
396}

◆ OleObject_GetExtent()

static HRESULT WINAPI OleObject_GetExtent ( IOleObject iface,
DWORD  dwDrawAspect,
SIZEL psizel 
)
static

Definition at line 473 of file ole2.c.

479{
480 CHECK_EXPECTED_METHOD("OleObject_GetExtent");
481 return E_NOTIMPL;
482}

◆ OleObject_GetMiscStatus()

static HRESULT WINAPI OleObject_GetMiscStatus ( IOleObject iface,
DWORD  aspect,
DWORD pdwStatus 
)
static

Definition at line 515 of file ole2.c.

521{
522 CHECK_EXPECTED_METHOD("OleObject_GetMiscStatus");
523
524 ok(aspect == DVASPECT_CONTENT, "got aspect %d\n", aspect);
525
527 {
528 *pdwStatus = OLEMISC_RECOMPOSEONRESIZE;
529 return S_OK;
530 }
531 else
532 {
533 *pdwStatus = 0x1234;
535 }
536}
static HRESULT g_GetMiscStatusFailsWith
Definition: ole2.c:117
@ OLEMISC_RECOMPOSEONRESIZE
Definition: actctx.c:83

◆ OleObject_GetMoniker()

static HRESULT WINAPI OleObject_GetMoniker ( IOleObject iface,
DWORD  dwAssign,
DWORD  dwWhichMoniker,
IMoniker **  ppmk 
)
static

Definition at line 363 of file ole2.c.

370{
371 CHECK_EXPECTED_METHOD("OleObject_GetMoniker");
372 return S_OK;
373}

◆ OleObject_GetUserClassID()

static HRESULT WINAPI OleObject_GetUserClassID ( IOleObject iface,
CLSID pClsid 
)
static

Definition at line 441 of file ole2.c.

446{
447 CHECK_EXPECTED_METHOD("OleObject_GetUserClassID");
448 return E_NOTIMPL;
449}

◆ OleObject_GetUserType()

static HRESULT WINAPI OleObject_GetUserType ( IOleObject iface,
DWORD  dwFormOfType,
LPOLESTR pszUserType 
)
static

Definition at line 451 of file ole2.c.

457{
458 CHECK_EXPECTED_METHOD("OleObject_GetUserType");
459 return E_NOTIMPL;
460}

◆ OleObject_InitFromData()

static HRESULT WINAPI OleObject_InitFromData ( IOleObject iface,
IDataObject pDataObject,
BOOL  fCreation,
DWORD  dwReserved 
)
static

Definition at line 375 of file ole2.c.

382{
383 CHECK_EXPECTED_METHOD("OleObject_InitFromData");
384 return S_OK;
385}

◆ OleObject_IsUpToDate()

static HRESULT WINAPI OleObject_IsUpToDate ( IOleObject iface)
static

Definition at line 432 of file ole2.c.

436{
437 CHECK_EXPECTED_METHOD("OleObject_IsUpToDate");
438 return S_OK;
439}

◆ OleObject_QueryInterface()

static HRESULT WINAPI OleObject_QueryInterface ( IOleObject iface,
REFIID  riid,
void **  ppv 
)
static

Definition at line 273 of file ole2.c.

274{
275 CHECK_EXPECTED_METHOD("OleObject_QueryInterface");
276
277 *ppv = NULL;
278
280 *ppv = iface;
283 else if (IsEqualIID(riid, &IID_IOleCache))
284 *ppv = cache;
286 *ppv = runnable;
287 else if (IsEqualIID(riid, &IID_WineTest))
288 return g_QIFailsWith;
289
290 if(*ppv) {
291 IUnknown_AddRef((IUnknown*)*ppv);
292 return S_OK;
293 }
294
295 trace("OleObject_QueryInterface: returning E_NOINTERFACE\n");
296 return E_NOINTERFACE;
297}
static IPersistStorage OleObjectPersistStg
Definition: ole2.c:74
static HRESULT g_QIFailsWith
Definition: ole2.c:118
static IOleCache * cache
Definition: ole2.c:75
static BOOL g_showRunnable
Definition: ole2.c:115
static const IID IID_WineTest
Definition: ole2.c:94
static IRunnableObject * runnable
Definition: ole2.c:76
const GUID IID_IOleCache
const GUID IID_IRunnableObject
const GUID IID_IPersistStorage
const GUID IID_IOleObject

◆ OleObject_Release()

static ULONG WINAPI OleObject_Release ( IOleObject iface)
static

Definition at line 305 of file ole2.c.

306{
307 CHECK_EXPECTED_METHOD("OleObject_Release");
308 return 1;
309}

◆ OleObject_SetClientSite()

static HRESULT WINAPI OleObject_SetClientSite ( IOleObject iface,
IOleClientSite pClientSite 
)
static

Definition at line 311 of file ole2.c.

316{
317 CHECK_EXPECTED_METHOD("OleObject_SetClientSite");
318 return S_OK;
319}

◆ OleObject_SetColorScheme()

static HRESULT WINAPI OleObject_SetColorScheme ( IOleObject iface,
LOGPALETTE pLogpal 
)
static

Definition at line 538 of file ole2.c.

543{
544 CHECK_EXPECTED_METHOD("OleObject_SetColorScheme");
545 return E_NOTIMPL;
546}

◆ OleObject_SetExtent()

static HRESULT WINAPI OleObject_SetExtent ( IOleObject iface,
DWORD  dwDrawAspect,
SIZEL psizel 
)
static

Definition at line 462 of file ole2.c.

468{
469 CHECK_EXPECTED_METHOD("OleObject_SetExtent");
470 return S_OK;
471}

◆ OleObject_SetHostNames()

static HRESULT WINAPI OleObject_SetHostNames ( IOleObject iface,
LPCOLESTR  szContainerApp,
LPCOLESTR  szContainerObj 
)
static

Definition at line 331 of file ole2.c.

337{
338 CHECK_EXPECTED_METHOD("OleObject_SetHostNames");
339 return S_OK;
340}

◆ OleObject_SetMoniker()

static HRESULT WINAPI OleObject_SetMoniker ( IOleObject iface,
DWORD  dwWhichMoniker,
IMoniker pmk 
)
static

Definition at line 352 of file ole2.c.

358{
359 CHECK_EXPECTED_METHOD("OleObject_SetMoniker");
360 return S_OK;
361}

◆ OleObject_Unadvise()

static HRESULT WINAPI OleObject_Unadvise ( IOleObject iface,
DWORD  dwConnection 
)
static

Definition at line 495 of file ole2.c.

500{
501 CHECK_EXPECTED_METHOD("OleObject_Unadvise");
502 return S_OK;
503}

◆ OleObject_Update()

static HRESULT WINAPI OleObject_Update ( IOleObject iface)
static

Definition at line 423 of file ole2.c.

427{
428 CHECK_EXPECTED_METHOD("OleObject_Update");
429 return S_OK;
430}

◆ OleObjectCache_AddRef()

static ULONG WINAPI OleObjectCache_AddRef ( IOleCache iface)
static

Definition at line 682 of file ole2.c.

683{
684 CHECK_EXPECTED_METHOD("OleObjectCache_AddRef");
685 return 2;
686}

◆ OleObjectCache_Cache()

static HRESULT WINAPI OleObjectCache_Cache ( IOleCache iface,
FORMATETC *  pformatetc,
DWORD  advf,
DWORD pdwConnection 
)
static

Definition at line 694 of file ole2.c.

701{
702 CHECK_EXPECTED_METHOD("OleObjectCache_Cache");
703 if (g_expected_fetc) {
704 ok(pformatetc != NULL, "pformatetc should not be NULL\n");
705 if (pformatetc) {
706 ok(pformatetc->cfFormat == g_expected_fetc->cfFormat,
707 "cfFormat: %x\n", pformatetc->cfFormat);
708 ok((pformatetc->ptd != NULL) == (g_expected_fetc->ptd != NULL),
709 "ptd: %p\n", pformatetc->ptd);
710 ok(pformatetc->dwAspect == g_expected_fetc->dwAspect,
711 "dwAspect: %x\n", pformatetc->dwAspect);
712 ok(pformatetc->lindex == g_expected_fetc->lindex,
713 "lindex: %x\n", pformatetc->lindex);
714 ok(pformatetc->tymed == g_expected_fetc->tymed,
715 "tymed: %x\n", pformatetc->tymed);
716 }
717 } else
718 ok(pformatetc == NULL, "pformatetc should be NULL\n");
719 return S_OK;
720}
static FORMATETC * g_expected_fetc
Definition: ole2.c:113

◆ OleObjectCache_EnumCache()

static HRESULT WINAPI OleObjectCache_EnumCache ( IOleCache iface,
IEnumSTATDATA **  ppenumSTATDATA 
)
static

Definition at line 732 of file ole2.c.

737{
738 CHECK_EXPECTED_METHOD("OleObjectCache_EnumCache");
739 return S_OK;
740}

◆ OleObjectCache_InitCache()

static HRESULT WINAPI OleObjectCache_InitCache ( IOleCache iface,
IDataObject pDataObject 
)
static

Definition at line 743 of file ole2.c.

748{
749 CHECK_EXPECTED_METHOD("OleObjectCache_InitCache");
750 return S_OK;
751}

◆ OleObjectCache_QueryInterface()

static HRESULT WINAPI OleObjectCache_QueryInterface ( IOleCache iface,
REFIID  riid,
void **  ppv 
)
static

Definition at line 677 of file ole2.c.

678{
679 return IOleObject_QueryInterface(&OleObject, riid, ppv);
680}
static IOleObject OleObject
Definition: ole2.c:576

◆ OleObjectCache_Release()

static ULONG WINAPI OleObjectCache_Release ( IOleCache iface)
static

Definition at line 688 of file ole2.c.

689{
690 CHECK_EXPECTED_METHOD("OleObjectCache_Release");
691 return 1;
692}

◆ OleObjectCache_SetData()

static HRESULT WINAPI OleObjectCache_SetData ( IOleCache iface,
FORMATETC *  pformatetc,
STGMEDIUM *  pmedium,
BOOL  fRelease 
)
static

Definition at line 754 of file ole2.c.

761{
762 CHECK_EXPECTED_METHOD("OleObjectCache_SetData");
763 return S_OK;
764}

◆ OleObjectCache_Uncache()

static HRESULT WINAPI OleObjectCache_Uncache ( IOleCache iface,
DWORD  dwConnection 
)
static

Definition at line 722 of file ole2.c.

727{
728 CHECK_EXPECTED_METHOD("OleObjectCache_Uncache");
729 return S_OK;
730}

◆ OleObjectCF_AddRef()

static ULONG WINAPI OleObjectCF_AddRef ( IClassFactory iface)
static

Definition at line 793 of file ole2.c.

794{
795 return 2;
796}

◆ OleObjectCF_CreateInstance()

static HRESULT WINAPI OleObjectCF_CreateInstance ( IClassFactory iface,
IUnknown punkOuter,
REFIID  riid,
void **  ppv 
)
static

Definition at line 803 of file ole2.c.

804{
805 return IOleObject_QueryInterface(&OleObject, riid, ppv);
806}

◆ OleObjectCF_LockServer()

static HRESULT WINAPI OleObjectCF_LockServer ( IClassFactory iface,
BOOL  lock 
)
static

Definition at line 808 of file ole2.c.

809{
810 return S_OK;
811}

◆ OleObjectCF_QueryInterface()

static HRESULT WINAPI OleObjectCF_QueryInterface ( IClassFactory iface,
REFIID  riid,
void **  ppv 
)
static

Definition at line 781 of file ole2.c.

782{
784 {
785 *ppv = iface;
786 IClassFactory_AddRef(iface);
787 return S_OK;
788 }
789 *ppv = NULL;
790 return E_NOINTERFACE;
791}
const GUID IID_IClassFactory

◆ OleObjectCF_Release()

static ULONG WINAPI OleObjectCF_Release ( IClassFactory iface)
static

Definition at line 798 of file ole2.c.

799{
800 return 1;
801}

◆ OleObjectPersistStg_AddRef()

static ULONG WINAPI OleObjectPersistStg_AddRef ( IPersistStorage iface)
static

Definition at line 584 of file ole2.c.

585{
586 CHECK_EXPECTED_METHOD("OleObjectPersistStg_AddRef");
587 return 2;
588}

◆ OleObjectPersistStg_GetClassId()

static HRESULT WINAPI OleObjectPersistStg_GetClassId ( IPersistStorage iface,
CLSID clsid 
)
static

Definition at line 596 of file ole2.c.

597{
598 CHECK_EXPECTED_METHOD("OleObjectPersistStg_GetClassId");
599 return E_NOTIMPL;
600}

◆ OleObjectPersistStg_HandsOffStorage()

static HRESULT WINAPI OleObjectPersistStg_HandsOffStorage ( IPersistStorage iface)
static

Definition at line 652 of file ole2.c.

656{
657 CHECK_EXPECTED_METHOD("OleObjectPersistStg_HandsOffStorage");
658 return S_OK;
659}

◆ OleObjectPersistStg_InitNew()

static HRESULT WINAPI OleObjectPersistStg_InitNew ( IPersistStorage iface,
IStorage pStg 
)
static

Definition at line 611 of file ole2.c.

616{
617 CHECK_EXPECTED_METHOD("OleObjectPersistStg_InitNew");
618 return S_OK;
619}

◆ OleObjectPersistStg_IsDirty()

static HRESULT WINAPI OleObjectPersistStg_IsDirty ( IPersistStorage iface)
static

Definition at line 602 of file ole2.c.

606{
607 CHECK_EXPECTED_METHOD("OleObjectPersistStg_IsDirty");
608 return S_OK;
609}

◆ OleObjectPersistStg_Load()

static HRESULT WINAPI OleObjectPersistStg_Load ( IPersistStorage iface,
IStorage pStg 
)
static

Definition at line 621 of file ole2.c.

626{
627 CHECK_EXPECTED_METHOD("OleObjectPersistStg_Load");
628 return S_OK;
629}

◆ OleObjectPersistStg_QueryInterface()

static HRESULT WINAPI OleObjectPersistStg_QueryInterface ( IPersistStorage iface,
REFIID  riid,
void **  ppv 
)
static

Definition at line 578 of file ole2.c.

579{
580 trace("OleObjectPersistStg_QueryInterface\n");
581 return IOleObject_QueryInterface(&OleObject, riid, ppv);
582}

◆ OleObjectPersistStg_Release()

static ULONG WINAPI OleObjectPersistStg_Release ( IPersistStorage iface)
static

Definition at line 590 of file ole2.c.

591{
592 CHECK_EXPECTED_METHOD("OleObjectPersistStg_Release");
593 return 1;
594}

◆ OleObjectPersistStg_Save()

static HRESULT WINAPI OleObjectPersistStg_Save ( IPersistStorage iface,
IStorage pStgSave,
BOOL  fSameAsLoad 
)
static

Definition at line 631 of file ole2.c.

637{
638 CHECK_EXPECTED_METHOD("OleObjectPersistStg_Save");
639 return S_OK;
640}

◆ OleObjectPersistStg_SaveCompleted()

static HRESULT WINAPI OleObjectPersistStg_SaveCompleted ( IPersistStorage iface,
IStorage pStgNew 
)
static

Definition at line 642 of file ole2.c.

647{
648 CHECK_EXPECTED_METHOD("OleObjectPersistStg_SaveCompleted");
649 return S_OK;
650}

◆ OleObjectRunnable_AddRef()

static ULONG WINAPI OleObjectRunnable_AddRef ( IRunnableObject iface)
static

Definition at line 829 of file ole2.c.

830{
831 CHECK_EXPECTED_METHOD("OleObjectRunnable_AddRef");
832 return 2;
833}

◆ OleObjectRunnable_GetRunningClass()

static HRESULT WINAPI OleObjectRunnable_GetRunningClass ( IRunnableObject iface,
LPCLSID  lpClsid 
)
static

Definition at line 841 of file ole2.c.

844{
845 CHECK_EXPECTED_METHOD("OleObjectRunnable_GetRunningClass");
846 return E_NOTIMPL;
847}

◆ OleObjectRunnable_IsRunning()

static BOOL WINAPI OleObjectRunnable_IsRunning ( IRunnableObject iface)
static

Definition at line 857 of file ole2.c.

858{
859 CHECK_EXPECTED_METHOD("OleObjectRunnable_IsRunning");
860 return g_isRunning;
861}
static BOOL g_isRunning
Definition: ole2.c:116

◆ OleObjectRunnable_LockRunning()

static HRESULT WINAPI OleObjectRunnable_LockRunning ( IRunnableObject iface,
BOOL  fLock,
BOOL  fLastUnlockCloses 
)
static

Definition at line 863 of file ole2.c.

867{
868 CHECK_EXPECTED_METHOD("OleObjectRunnable_LockRunning");
869 return S_OK;
870}

◆ OleObjectRunnable_QueryInterface()

static HRESULT WINAPI OleObjectRunnable_QueryInterface ( IRunnableObject iface,
REFIID  riid,
void **  ppv 
)
static

Definition at line 824 of file ole2.c.

825{
826 return IOleObject_QueryInterface(&OleObject, riid, ppv);
827}

◆ OleObjectRunnable_Release()

static ULONG WINAPI OleObjectRunnable_Release ( IRunnableObject iface)
static

Definition at line 835 of file ole2.c.

836{
837 CHECK_EXPECTED_METHOD("OleObjectRunnable_Release");
838 return 1;
839}

◆ OleObjectRunnable_Run()

static HRESULT WINAPI OleObjectRunnable_Run ( IRunnableObject iface,
LPBINDCTX  pbc 
)
static

Definition at line 849 of file ole2.c.

852{
853 CHECK_EXPECTED_METHOD("OleObjectRunnable_Run");
854 return S_OK;
855}

◆ OleObjectRunnable_SetContainedObject()

static HRESULT WINAPI OleObjectRunnable_SetContainedObject ( IRunnableObject iface,
BOOL  fContained 
)
static

Definition at line 872 of file ole2.c.

875{
876 CHECK_EXPECTED_METHOD("OleObjectRunnable_SetContainedObject");
877 return S_OK;
878}

◆ OleRun_AddRef()

static ULONG WINAPI OleRun_AddRef ( IRunnableObject iface)
static

Definition at line 3215 of file ole2.c.

3216{
3217 return 2;
3218}

◆ OleRun_GetRunningClass()

static HRESULT WINAPI OleRun_GetRunningClass ( IRunnableObject iface,
CLSID clsid 
)
static

Definition at line 3225 of file ole2.c.

3226{
3227 ok(0, "unexpected\n");
3228 return E_NOTIMPL;
3229}

◆ OleRun_IsRunning()

static BOOL WINAPI OleRun_IsRunning ( IRunnableObject iface)
static

Definition at line 3237 of file ole2.c.

3238{
3239 ok(0, "unexpected\n");
3240 return FALSE;
3241}

◆ OleRun_LockRunning()

static HRESULT WINAPI OleRun_LockRunning ( IRunnableObject iface,
BOOL  lock,
BOOL  last_unlock_closes 
)
static

Definition at line 3243 of file ole2.c.

3245{
3246 ok(0, "unexpected\n");
3247 return E_NOTIMPL;
3248}

◆ OleRun_QueryInterface()

static HRESULT WINAPI OleRun_QueryInterface ( IRunnableObject iface,
REFIID  riid,
void **  ppv 
)
static

Definition at line 3197 of file ole2.c.

3198{
3199 *ppv = NULL;
3200
3201 if (IsEqualIID(riid, &IID_IUnknown) ||
3203 *ppv = iface;
3204 }
3205
3206 if (*ppv)
3207 {
3208 IUnknown_AddRef((IUnknown *)*ppv);
3209 return S_OK;
3210 }
3211
3212 return E_NOINTERFACE;
3213}

◆ OleRun_Release()

static ULONG WINAPI OleRun_Release ( IRunnableObject iface)
static

Definition at line 3220 of file ole2.c.

3221{
3222 return 1;
3223}

◆ OleRun_Run()

static HRESULT WINAPI OleRun_Run ( IRunnableObject iface,
LPBINDCTX  ctx 
)
static

Definition at line 3231 of file ole2.c.

3232{
3233 ok(ctx == NULL, "got %p\n", ctx);
3234 return 0xdeadc0de;
3235}

◆ OleRun_SetContainedObject()

static HRESULT WINAPI OleRun_SetContainedObject ( IRunnableObject iface,
BOOL  contained 
)
static

Definition at line 3250 of file ole2.c.

3251{
3252 ok(0, "unexpected\n");
3253 return E_NOTIMPL;
3254}

◆ read_clipformat()

static int read_clipformat ( IStream stream)
static

Definition at line 3971 of file ole2.c.

3972{
3973 HRESULT hr;
3974 ULONG bytes;
3975 int length, clipformat = -2;
3976
3977 hr = IStream_Read(stream, &length, sizeof(length), &bytes);
3978 if (hr != S_OK || bytes != sizeof(length))
3979 return -2;
3980 if (length == 0)
3981 return 0;
3982 if (length == -1)
3983 {
3984 hr = IStream_Read(stream, &clipformat, sizeof(clipformat), &bytes);
3985 if (hr != S_OK || bytes != sizeof(clipformat))
3986 return -2;
3987 }
3988 else
3989 ok(0, "unhandled clipformat length %d\n", length);
3990
3991 return clipformat;
3992}
GLuint GLsizei GLsizei * length
Definition: glext.h:6040

Referenced by check_storage_contents().

◆ START_TEST()

START_TEST ( ole2  )

Definition at line 4786 of file ole2.c.

4787{
4788 DWORD dwRegister;
4789 IStorage *pStorage;
4790 STATSTG statstg;
4791 HRESULT hr;
4792
4793 cf_test_1 = RegisterClipboardFormatA("cf_winetest_1");
4794 cf_test_2 = RegisterClipboardFormatA("cf_winetest_2");
4795 cf_test_3 = RegisterClipboardFormatA("cf_winetest_3");
4796
4798
4799 hr = CoRegisterClassObject(&CLSID_Equation3, (IUnknown *)&OleObjectCF, CLSCTX_INPROC_SERVER, REGCLS_MULTIPLEUSE, &dwRegister);
4800 ok_ole_success(hr, "CoRegisterClassObject");
4801
4803 ok_ole_success(hr, "StgCreateDocfile");
4804
4805 test_OleCreate(pStorage);
4806
4807 hr = IStorage_Stat(pStorage, &statstg, STATFLAG_NONAME);
4808 ok_ole_success(hr, "IStorage_Stat");
4809 ok(IsEqualCLSID(&CLSID_Equation3, &statstg.clsid), "Wrong CLSID in storage\n");
4810
4811 test_OleLoad(pStorage);
4812
4813 IStorage_Release(pStorage);
4814
4815 hr = CoRevokeClassObject(dwRegister);
4816 ok_ole_success(hr, "CoRevokeClassObject");
4817
4819
4828 test_runnable();
4829 test_OleRun();
4831 test_OleDraw();
4837
4839}
HRESULT WINAPI CoRegisterClassObject(REFCLSID rclsid, LPUNKNOWN pUnk, DWORD dwClsContext, DWORD flags, LPDWORD lpdwRegister)
Definition: compobj.c:2897
HRESULT WINAPI DECLSPEC_HOTPATCH CoRevokeClassObject(DWORD dwRegister)
Definition: compobj.c:1086
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:1964
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:2067
static void test_data_cache_updatecache(void)
Definition: ole2.c:2644
static UINT cf_test_1
Definition: ole2.c:120
static void test_data_cache_save(void)
Definition: ole2.c:3740
#define ok_ole_success(hr, func)
Definition: ole2.c:36
static const CLSID CLSID_WineTest
Definition: ole2.c:86
static void test_runnable(void)
Definition: ole2.c:3151
static void test_data_cache_cache(void)
Definition: ole2.c:2232
static void test_default_handler(void)
Definition: ole2.c:2945
static void test_OleLockRunning(void)
Definition: ole2.c:3282
static void test_data_cache_save_data(void)
Definition: ole2.c:4343
static const CLSID CLSID_Equation3
Definition: ole2.c:894
static IClassFactory OleObjectCF
Definition: ole2.c:822
static UINT cf_test_3
Definition: ole2.c:120
static void test_OleCreateStaticFromData(void)
Definition: ole2.c:4617
static void test_data_cache_initnew(void)
Definition: ole2.c:2530
static void test_OleLoad(IStorage *pStorage)
Definition: ole2.c:1206
static void test_OleDraw(void)
Definition: ole2.c:3290
static void test_data_cache(void)
Definition: ole2.c:1692
static void test_OleDoAutoConvert(void)
Definition: ole2.c:3550
static void test_data_cache_dib_contents_stream(int num)
Definition: ole2.c:2123
static void test_data_cache_contents(void)
Definition: ole2.c:4540
static void test_data_cache_init(void)
Definition: ole2.c:2485
static void test_OleCreate(IStorage *pStorage)
Definition: ole2.c:974
static void test_OleRun(void)
Definition: ole2.c:3270
static const CLSID * Storage_SetClass_CLSID
Definition: ole2.c:71
@ REGCLS_MULTIPLEUSE
Definition: objbase.h:393
UINT WINAPI RegisterClipboardFormatA(_In_ LPCSTR)

◆ stgmedium_cmp()

static HRESULT stgmedium_cmp ( const STGMEDIUM *  med1,
STGMEDIUM *  med2 
)
static

Definition at line 4102 of file ole2.c.

4103{
4104 BYTE *data1, *data2;
4105 ULONG datasize1, datasize2;
4106
4107 if (med1->tymed != med2->tymed)
4108 return E_FAIL;
4109
4110 if (med1->tymed == TYMED_MFPICT)
4111 {
4112 METAFILEPICT *mfpict1 = GlobalLock(U(med1)->hMetaFilePict);
4113 METAFILEPICT *mfpict2 = GlobalLock(U(med2)->hMetaFilePict);
4114
4115 datasize1 = GetMetaFileBitsEx(mfpict1->hMF, 0, NULL);
4116 datasize2 = GetMetaFileBitsEx(mfpict2->hMF, 0, NULL);
4117 if (datasize1 == datasize2)
4118 {
4119 data1 = HeapAlloc(GetProcessHeap(), 0, datasize1);
4120 data2 = HeapAlloc(GetProcessHeap(), 0, datasize2);
4121 GetMetaFileBitsEx(mfpict1->hMF, datasize1, data1);
4122 GetMetaFileBitsEx(mfpict2->hMF, datasize2, data2);
4123 }
4124 else return E_FAIL;
4125 }
4126 else if (med1->tymed == TYMED_ENHMF)
4127 {
4128 datasize1 = GetEnhMetaFileBits(med1->hEnhMetaFile, 0, NULL);
4129 datasize2 = GetEnhMetaFileBits(med2->hEnhMetaFile, 0, NULL);
4130 if (datasize1 == datasize2)
4131 {
4132 data1 = HeapAlloc(GetProcessHeap(), 0, datasize1);
4133 data2 = HeapAlloc(GetProcessHeap(), 0, datasize2);
4134 GetEnhMetaFileBits(med1->hEnhMetaFile, datasize1, data1);
4135 GetEnhMetaFileBits(med2->hEnhMetaFile, datasize2, data2);
4136 }
4137 else return E_FAIL;
4138 }
4139 else if (med1->tymed == TYMED_HGLOBAL)
4140 {
4141 datasize1 = GlobalSize(med1->hGlobal);
4142 datasize2 = GlobalSize(med2->hGlobal);
4143
4144 if (datasize1 == datasize2)
4145 {
4146 data1 = GlobalLock(med1->hGlobal);
4147 data2 = GlobalLock(med2->hGlobal);
4148 }
4149 else
4150 return E_FAIL;
4151 }
4152 else
4153 return E_NOTIMPL;
4154
4155 if (memcmp(data1, data2, datasize1) != 0)
4156 return E_FAIL;
4157
4158 if (med1->tymed == TYMED_HGLOBAL)
4159 {
4160 GlobalUnlock(U(med1)->hGlobal);
4161 GlobalUnlock(U(med2)->hGlobal);
4162 }
4163 else if (med1->tymed == TYMED_MFPICT)
4164 {
4167 GlobalUnlock(U(med1)->hMetaFilePict);
4168 GlobalUnlock(U(med2)->hMetaFilePict);
4169 }
4170 else
4171 {
4174 }
4175
4176 return S_OK;
4177}
#define E_FAIL
Definition: ddrawi.h:102
#define HeapFree(x, y, z)
Definition: compat.h:735
SIZE_T NTAPI GlobalSize(HGLOBAL hMem)
Definition: heapmem.c:1090
Definition: tftpd.h:126
Definition: tftpd.h:138

Referenced by test_data_cache_save_data().

◆ Storage_AddRef()

static ULONG WINAPI Storage_AddRef ( IStorage iface)
static

Definition at line 3318 of file ole2.c.

3319{
3320 ok(0, "unexpected call to AddRef\n");
3321 return 2;
3322}

◆ Storage_Commit()

static HRESULT WINAPI Storage_Commit ( IStorage iface,
DWORD  grfCommitFlags 
)
static

Definition at line 3452 of file ole2.c.

3453{
3454 ok(0, "unexpected call to Commit\n");
3455 return E_NOTIMPL;
3456}

◆ Storage_CopyTo()

static HRESULT WINAPI Storage_CopyTo ( IStorage iface,
DWORD  ciidExclude,
const IID rgiidExclude,
SNB  snbExclude,
IStorage pstgDest 
)
static

Definition at line 3440 of file ole2.c.

3441{
3442 ok(0, "unexpected call to CopyTo\n");
3443 return E_NOTIMPL;
3444}

◆ Storage_CreateStorage()

static HRESULT WINAPI Storage_CreateStorage ( IStorage iface,
LPCOLESTR  pwcsName,
DWORD  grfMode,
DWORD  dwStgFmt,
DWORD  reserved2,
IStorage **  ppstg 
)
static

Definition at line 3428 of file ole2.c.

3429{
3430 ok(0, "unexpected call to CreateStorage\n");
3431 return E_NOTIMPL;
3432}

◆ Storage_CreateStream()

static HRESULT WINAPI Storage_CreateStream ( IStorage iface,
LPCOLESTR  pwcsName,
DWORD  grfMode,
DWORD  reserved1,
DWORD  reserved2,
IStream **  ppstm 
)
static

Definition at line 3330 of file ole2.c.

3331{
3332 ULARGE_INTEGER size = {{0}};
3333 LARGE_INTEGER pos = {{0}};
3334 HRESULT hr;
3335
3336 if (!lstrcmpW(pwcsName, comp_objW))
3337 {
3338 CHECK_EXPECT(Storage_CreateStream_CompObj);
3339 *ppstm = comp_obj_stream;
3340
3341 todo_wine ok(grfMode == (STGM_CREATE|STGM_SHARE_EXCLUSIVE|STGM_READWRITE), "grfMode = %x\n", grfMode);
3342 }
3343 else if (!lstrcmpW(pwcsName, olepres0W))
3344 {
3345 CHECK_EXPECT(Storage_CreateStream_OlePres);
3346 *ppstm = olepres_stream;
3347
3348 todo_wine ok(grfMode == (STGM_SHARE_EXCLUSIVE|STGM_READWRITE), "grfMode = %x\n", grfMode);
3349 }
3350 else
3351 {
3353 ok(0, "unexpected stream name %s\n", wine_dbgstr_w(pwcsName));
3354#if 0 /* FIXME: return NULL once Wine is fixed */
3355 *ppstm = NULL;
3356 return E_NOTIMPL;
3357#else
3358 *ppstm = contents_stream;
3359#endif
3360 }
3361
3362 ok(!reserved1, "reserved1 = %x\n", reserved1);
3363 ok(!reserved2, "reserved2 = %x\n", reserved2);
3364 ok(!!ppstm, "ppstm = NULL\n");
3365
3366 IStream_AddRef(*ppstm);
3367 hr = IStream_Seek(*ppstm, pos, STREAM_SEEK_SET, NULL);
3368 ok(hr == S_OK, "IStream_Seek returned %x\n", hr);
3369 hr = IStream_SetSize(*ppstm, size);
3370 ok(hr == S_OK, "IStream_SetSize returned %x\n", hr);
3371 return S_OK;
3372}
int WINAPI lstrcmpW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4242
uint8_t reserved2[12]
Definition: fsck.fat.h:23
GLsizeiptr size
Definition: glext.h:5919
#define CHECK_EXPECT(func)
Definition: ole2.c:50
static const WCHAR comp_objW[]
Definition: ole2.c:3306
static const WCHAR olepres0W[]
Definition: ole2.c:3305
static IStream * olepres_stream
Definition: ole2.c:3309
static IStream * comp_obj_stream
Definition: ole2.c:3307
static IStream * contents_stream
Definition: ole2.c:3310

◆ Storage_DestroyElement()

static HRESULT WINAPI Storage_DestroyElement ( IStorage iface,
LPCOLESTR  pwcsName 
)
static

Definition at line 3470 of file ole2.c.

3471{
3472 char name[32];
3473 int stream_n, cmp;
3474
3476 cmp = CompareStringW(LOCALE_NEUTRAL, 0, pwcsName, 8, olepres0W, 8);
3477 ok(cmp == CSTR_EQUAL,
3478 "unexpected call to DestroyElement(%s)\n", wine_dbgstr_w(pwcsName));
3479
3480 WideCharToMultiByte(CP_ACP, 0, pwcsName, -1, name, sizeof(name), NULL, NULL);
3481 stream_n = atol(name + 8);
3482 if (stream_n <= Storage_DestroyElement_limit)
3483 return S_OK;
3484
3485 return STG_E_FILENOTFOUND;
3486}
INT WINAPI CompareStringW(LCID lcid, DWORD flags, LPCWSTR str1, INT len1, LPCWSTR str2, INT len2)
Definition: locale.c:4013
_Check_return_ long __cdecl atol(_In_z_ const char *_Str)
#define cmp(status, error)
Definition: error.c:114
static HRESULT WINAPI Storage_DestroyElement(IStorage *iface, LPCOLESTR pwcsName)
Definition: ole2.c:3470
static int Storage_DestroyElement_limit
Definition: ole2.c:72
#define CHECK_EXPECT2(func)
Definition: ole2.c:44
#define LOCALE_NEUTRAL
#define STG_E_FILENOTFOUND
Definition: winerror.h:2565
#define CSTR_EQUAL
Definition: winnls.h:456

Referenced by Storage_DestroyElement(), and test_data_cache_save().

◆ Storage_EnumElements()

static HRESULT WINAPI Storage_EnumElements ( IStorage iface,
DWORD  reserved1,
void reserved2,
DWORD  reserved3,
IEnumSTATSTG **  ppenum 
)
static

Definition at line 3464 of file ole2.c.

3465{
3466 ok(0, "unexpected call to EnumElements\n");
3467 return E_NOTIMPL;
3468}

◆ Storage_MoveElementTo()

static HRESULT WINAPI Storage_MoveElementTo ( IStorage iface,
LPCOLESTR  pwcsName,
IStorage pstgDest,
LPCOLESTR  pwcsNewName,
DWORD  grfFlags 
)
static

Definition at line 3446 of file ole2.c.

3447{
3448 ok(0, "unexpected call to MoveElementTo\n");
3449 return E_NOTIMPL;
3450}

◆ Storage_OpenStorage()

static HRESULT WINAPI Storage_OpenStorage ( IStorage iface,
LPCOLESTR  pwcsName,
IStorage pstgPriority,
DWORD  grfMode,
SNB  snbExclude,
DWORD  reserved,
IStorage **  ppstg 
)
static

Definition at line 3434 of file ole2.c.

3435{
3436 ok(0, "unexpected call to OpenStorage\n");
3437 return E_NOTIMPL;
3438}

◆ Storage_OpenStream()

static HRESULT WINAPI Storage_OpenStream ( IStorage iface,
LPCOLESTR  pwcsName,
void reserved1,
DWORD  grfMode,
DWORD  reserved2,
IStream **  ppstm 
)
static

Definition at line 3374 of file ole2.c.

3375{
3376 static const WCHAR ole1W[] = {1,'O','l','e',0};
3377
3378 LARGE_INTEGER pos = {{0}};
3379 HRESULT hr;
3380
3381 ok(!reserved1, "reserved1 = %p\n", reserved1);
3382 ok(!reserved2, "reserved2 = %x\n", reserved2);
3383 ok(!!ppstm, "ppstm = NULL\n");
3384
3385 if(!lstrcmpW(pwcsName, comp_objW)) {
3386 CHECK_EXPECT2(Storage_OpenStream_CompObj);
3387 ok(grfMode == STGM_SHARE_EXCLUSIVE, "grfMode = %x\n", grfMode);
3388
3389 *ppstm = comp_obj_stream;
3390 IStream_AddRef(comp_obj_stream);
3391 hr = IStream_Seek(comp_obj_stream, pos, STREAM_SEEK_SET, NULL);
3392 ok(hr == S_OK, "IStream_Seek returned %x\n", hr);
3393 return S_OK;
3394 }else if(!lstrcmpW(pwcsName, ole1W)) {
3395 CHECK_EXPECT(Storage_OpenStream_Ole);
3396
3397 if (!ole_stream)
3398 {
3399 ok(grfMode == (STGM_SHARE_EXCLUSIVE|STGM_READ), "grfMode = %x\n", grfMode);
3400
3401 *ppstm = NULL;
3402 return STG_E_FILENOTFOUND;
3403 }
3404
3405 ok(grfMode == (STGM_SHARE_EXCLUSIVE|STGM_READWRITE), "grfMode = %x\n", grfMode);
3406
3407 *ppstm = ole_stream;
3408 IStream_AddRef(ole_stream);
3409 hr = IStream_Seek(ole_stream, pos, STREAM_SEEK_SET, NULL);
3410 ok(hr == S_OK, "IStream_Seek returned %x\n", hr);
3411 return S_OK;
3412
3413 }else if(!lstrcmpW(pwcsName, olepres0W)) {
3414 CHECK_EXPECT(Storage_OpenStream_OlePres);
3415 ok(grfMode == (STGM_SHARE_EXCLUSIVE|STGM_READWRITE), "grfMode = %x\n", grfMode);
3416
3417 *ppstm = olepres_stream;
3418 IStream_AddRef(olepres_stream);
3419 hr = IStream_Seek(olepres_stream, pos, STREAM_SEEK_SET, NULL);
3420 ok(hr == S_OK, "IStream_Seek returned %x\n", hr);
3421 return S_OK;
3422 }
3423
3424 ok(0, "unexpected call to OpenStream: %s\n", wine_dbgstr_w(pwcsName));
3425 return E_NOTIMPL;
3426}
static IStream * ole_stream
Definition: ole2.c:3308

◆ Storage_QueryInterface()

static HRESULT WINAPI Storage_QueryInterface ( IStorage iface,
REFIID  riid,
void **  ppvObject 
)
static

Definition at line 3312 of file ole2.c.

3313{
3314 ok(0, "unexpected call to QueryInterface\n");
3315 return E_NOTIMPL;
3316}

◆ Storage_Release()

static ULONG WINAPI Storage_Release ( IStorage iface)
static

Definition at line 3324 of file ole2.c.

3325{
3326 ok(0, "unexpected call to Release\n");
3327 return 1;
3328}

◆ Storage_RenameElement()

static HRESULT WINAPI Storage_RenameElement ( IStorage iface,
LPCOLESTR  pwcsOldName,
LPCOLESTR  pwcsNewName 
)
static

Definition at line 3488 of file ole2.c.

3489{
3490 ok(0, "unexpected call to RenameElement\n");
3491 return E_NOTIMPL;
3492}

◆ Storage_Revert()

static HRESULT WINAPI Storage_Revert ( IStorage iface)
static

Definition at line 3458 of file ole2.c.

3459{
3460 ok(0, "unexpected call to Revert\n");
3461 return E_NOTIMPL;
3462}

◆ Storage_SetClass()

static HRESULT WINAPI Storage_SetClass ( IStorage iface,
REFCLSID  clsid 
)
static

Definition at line 3500 of file ole2.c.

3501{
3503 ok(IsEqualIID(clsid, Storage_SetClass_CLSID), "expected %s, got %s\n",
3505 return S_OK;
3506}
static HRESULT WINAPI Storage_SetClass(IStorage *iface, REFCLSID clsid)
Definition: ole2.c:3500
REFCLSID clsid
Definition: msctf.c:82

Referenced by Storage_SetClass(), and test_OleDoAutoConvert().

◆ Storage_SetElementTimes()

static HRESULT WINAPI Storage_SetElementTimes ( IStorage iface,
LPCOLESTR  pwcsName,
const FILETIME pctime,
const FILETIME patime,
const FILETIME pmtime 
)
static

Definition at line 3494 of file ole2.c.

3495{
3496 ok(0, "unexpected call to SetElementTimes\n");
3497 return E_NOTIMPL;
3498}

◆ Storage_SetStateBits()

static HRESULT WINAPI Storage_SetStateBits ( IStorage iface,
DWORD  grfStateBits,
DWORD  grfMask 
)
static

Definition at line 3508 of file ole2.c.

3509{
3510 ok(0, "unexpected call to SetStateBits\n");
3511 return E_NOTIMPL;
3512}

◆ Storage_Stat()

static HRESULT WINAPI Storage_Stat ( IStorage iface,
STATSTG *  pstatstg,
DWORD  grfStatFlag 
)
static

Definition at line 3514 of file ole2.c.

3515{
3517 ok(pstatstg != NULL, "pstatstg = NULL\n");
3518 ok(grfStatFlag == STATFLAG_NONAME, "grfStatFlag = %x\n", grfStatFlag);
3519
3520 memset(pstatstg, 0, sizeof(STATSTG));
3521 pstatstg->type = STGTY_STORAGE;
3522 pstatstg->clsid = CLSID_WineTestOld;
3523 return S_OK;
3524}
static HRESULT WINAPI Storage_Stat(IStorage *iface, STATSTG *pstatstg, DWORD grfStatFlag)
Definition: ole2.c:3514
static const CLSID CLSID_WineTestOld
Definition: ole2.c:78

Referenced by Storage_Stat(), and test_OleDoAutoConvert().

◆ test_data_cache()

static void test_data_cache ( void  )
static

Definition at line 1692 of file ole2.c.

1693{
1694 HRESULT hr;
1695 IOleCache2 *pOleCache;
1696 IOleCache *olecache;
1697 IStorage *pStorage;
1698 IUnknown *unk, *unk2;
1699 IPersistStorage *pPS;
1700 IViewObject *pViewObject;
1701 IOleCacheControl *pOleCacheControl;
1702 IDataObject *pCacheDataObject;
1703 FORMATETC fmtetc;
1704 STGMEDIUM stgmedium;
1705 DWORD dwConnection;
1706 DWORD dwFreeze;
1707 RECTL rcBounds;
1708 HDC hdcMem;
1709 CLSID clsid;
1710 char szSystemDir[MAX_PATH];
1711 WCHAR wszPath[MAX_PATH];
1712 static const WCHAR wszShell32[] = {'\\','s','h','e','l','l','3','2','.','d','l','l',0};
1713
1714 static const struct expected_method methods_cacheinitnew[] =
1715 {
1716 { "AdviseSink_OnViewChange", 0 },
1717 { "AdviseSink_OnViewChange", 0 },
1718 { "draw_continue", 1 },
1719 { "draw_continue_false", 1 },
1720 { "DataObject_DAdvise", 0 },
1721 { "DataObject_DAdvise", 0 },
1722 { "DataObject_DUnadvise", 0 },
1723 { "DataObject_DUnadvise", 0 },
1724 { NULL, 0 }
1725 };
1726 static const struct expected_method methods_cacheload[] =
1727 {
1728 { "AdviseSink_OnViewChange", 0 },
1729 { "draw_continue", 1 },
1730 { "draw_continue", 1 },
1731 { "draw_continue", 1 },
1732 { "DataObject_GetData", 0, { CF_DIB, NULL, DVASPECT_THUMBNAIL, -1, TYMED_HGLOBAL} },
1733 { "DataObject_GetData", 0, { CF_BITMAP, NULL, DVASPECT_THUMBNAIL, -1, TYMED_GDI} },
1734 { "DataObject_GetData", 0, { CF_METAFILEPICT, NULL, DVASPECT_ICON, -1, TYMED_MFPICT} },
1735 { NULL, 0 }
1736 };
1737 static const struct expected_method methods_cachethenrun[] =
1738 {
1739 { "DataObject_DAdvise", 0 },
1740 { "DataObject_DAdvise", 0 },
1741 { "DataObject_DAdvise", 0 },
1742 { "DataObject_DAdvise", 0 },
1743 { "DataObject_DUnadvise", 0 },
1744 { "DataObject_DUnadvise", 0 },
1745 { "DataObject_DUnadvise", 0 },
1746 { "DataObject_DUnadvise", 0 },
1747 { NULL, 0 }
1748 };
1749
1750 GetSystemDirectoryA(szSystemDir, ARRAY_SIZE(szSystemDir));
1751
1752 expected_method_list = methods_cacheinitnew;
1753
1754 fmtetc.cfFormat = CF_METAFILEPICT;
1755 fmtetc.dwAspect = DVASPECT_ICON;
1756 fmtetc.lindex = -1;
1757 fmtetc.ptd = NULL;
1758 fmtetc.tymed = TYMED_MFPICT;
1759
1761 ok_ole_success(hr, "StgCreateDocfile");
1762
1763 /* aggregation */
1764
1765 /* requested is not IUnknown */
1766 hr = CreateDataCache(&unknown, &CLSID_NULL, &IID_IOleCache2, (void**)&pOleCache);
1767 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
1768
1769 hr = CreateDataCache(&unknown, &CLSID_NULL, &IID_IUnknown, (void**)&unk);
1770 ok(hr == S_OK, "got 0x%08x\n", hr);
1771
1772 hr = IUnknown_QueryInterface(unk, &IID_IOleCache, (void**)&olecache);
1773 ok(hr == S_OK, "got 0x%08x\n", hr);
1774 hr = IUnknown_QueryInterface(unk, &IID_IOleCache2, (void**)&pOleCache);
1775 ok(hr == S_OK, "got 0x%08x\n", hr);
1776 ok(unk != (IUnknown*)olecache, "got %p, expected %p\n", olecache, unk);
1777 ok(unk != (IUnknown*)pOleCache, "got %p, expected %p\n", pOleCache, unk);
1778 IOleCache2_Release(pOleCache);
1779 IOleCache_Release(olecache);
1780 IUnknown_Release(unk);
1781
1782 hr = CreateDataCache(NULL, &CLSID_NULL, &IID_IUnknown, (void**)&unk);
1783 ok(hr == S_OK, "got 0x%08x\n", hr);
1784 hr = IUnknown_QueryInterface(unk, &IID_IOleCache, (void**)&olecache);
1785 ok(hr == S_OK, "got 0x%08x\n", hr);
1786 hr = IUnknown_QueryInterface(unk, &IID_IOleCache2, (void**)&pOleCache);
1787 ok(hr == S_OK, "got 0x%08x\n", hr);
1788 hr = IUnknown_QueryInterface(unk, &IID_IUnknown, (void**)&unk2);
1789 ok(hr == S_OK, "got 0x%08x\n", hr);
1790 ok(unk == (IUnknown*)olecache, "got %p, expected %p\n", olecache, unk);
1791 ok(unk == (IUnknown*)pOleCache, "got %p, expected %p\n", pOleCache, unk);
1792 ok(unk == unk2, "got %p, expected %p\n", unk2, unk);
1793 IUnknown_Release(unk2);
1794 IOleCache2_Release(pOleCache);
1795 IOleCache_Release(olecache);
1796 IUnknown_Release(unk);
1797
1798 /* Test with new data */
1799
1800 hr = CreateDataCache(NULL, &CLSID_NULL, &IID_IOleCache2, (LPVOID *)&pOleCache);
1801 ok_ole_success(hr, "CreateDataCache");
1802
1803 hr = IOleCache2_QueryInterface(pOleCache, &IID_IPersistStorage, (LPVOID *)&pPS);
1804 ok_ole_success(hr, "IOleCache_QueryInterface(IID_IPersistStorage)");
1805 hr = IOleCache2_QueryInterface(pOleCache, &IID_IViewObject, (LPVOID *)&pViewObject);
1806 ok_ole_success(hr, "IOleCache_QueryInterface(IID_IViewObject)");
1807 hr = IOleCache2_QueryInterface(pOleCache, &IID_IOleCacheControl, (LPVOID *)&pOleCacheControl);
1808 ok_ole_success(hr, "IOleCache_QueryInterface(IID_IOleCacheControl)");
1809
1810 hr = IViewObject_SetAdvise(pViewObject, DVASPECT_ICON, ADVF_PRIMEFIRST, &AdviseSink);
1811 ok_ole_success(hr, "IViewObject_SetAdvise");
1812
1813 hr = IPersistStorage_InitNew(pPS, pStorage);
1814 ok_ole_success(hr, "IPersistStorage_InitNew");
1815
1816 hr = IPersistStorage_IsDirty(pPS);
1817 ok_ole_success(hr, "IPersistStorage_IsDirty");
1818
1819 hr = IPersistStorage_GetClassID(pPS, &clsid);
1820 ok_ole_success(hr, "IPersistStorage_GetClassID");
1821 ok(IsEqualCLSID(&clsid, &IID_NULL), "clsid should be blank\n");
1822
1823 hr = IOleCache2_Uncache(pOleCache, 0xdeadbeef);
1824 ok(hr == OLE_E_NOCONNECTION, "IOleCache_Uncache with invalid value should return OLE_E_NOCONNECTION instead of 0x%x\n", hr);
1825
1826 /* Both tests crash on NT4 and below. StgCreatePropSetStg is only available on w2k and above. */
1827 if (GetProcAddress(GetModuleHandleA("ole32.dll"), "StgCreatePropSetStg"))
1828 {
1829 hr = IOleCache2_Cache(pOleCache, NULL, 0, &dwConnection);
1830 ok(hr == E_INVALIDARG, "IOleCache_Cache with NULL fmtetc should have returned E_INVALIDARG instead of 0x%08x\n", hr);
1831
1832 hr = IOleCache2_Cache(pOleCache, NULL, 0, NULL);
1833 ok(hr == E_INVALIDARG, "IOleCache_Cache with NULL pdwConnection should have returned E_INVALIDARG instead of 0x%08x\n", hr);
1834 }
1835 else
1836 {
1837 skip("tests with NULL parameters will crash on NT4 and below\n");
1838 }
1839
1840 for (fmtetc.cfFormat = CF_TEXT; fmtetc.cfFormat < CF_MAX; fmtetc.cfFormat++)
1841 {
1842 int i;
1843 fmtetc.dwAspect = DVASPECT_THUMBNAIL;
1844 for (i = 0; i < 7; i++)
1845 {
1846 fmtetc.tymed = 1 << i;
1847 hr = IOleCache2_Cache(pOleCache, &fmtetc, 0, &dwConnection);
1848 if ((fmtetc.cfFormat == CF_METAFILEPICT && fmtetc.tymed == TYMED_MFPICT) ||
1849 (fmtetc.cfFormat == CF_BITMAP && fmtetc.tymed == TYMED_GDI) ||
1850 (fmtetc.cfFormat == CF_DIB && fmtetc.tymed == TYMED_HGLOBAL) ||
1851 (fmtetc.cfFormat == CF_ENHMETAFILE && fmtetc.tymed == TYMED_ENHMF))
1852 ok(hr == S_OK, "IOleCache_Cache cfFormat = %d, tymed = %d should have returned S_OK instead of 0x%08x\n",
1853 fmtetc.cfFormat, fmtetc.tymed, hr);
1854 else if (fmtetc.tymed == TYMED_HGLOBAL)
1856 broken(hr == S_OK && fmtetc.cfFormat == CF_BITMAP) /* Win9x & NT4 */,
1857 "IOleCache_Cache cfFormat = %d, tymed = %d should have returned CACHE_S_FORMATETC_NOTSUPPORTED instead of 0x%08x\n",
1858 fmtetc.cfFormat, fmtetc.tymed, hr);
1859 else
1860 ok(hr == DV_E_TYMED, "IOleCache_Cache cfFormat = %d, tymed = %d should have returned DV_E_TYMED instead of 0x%08x\n",
1861 fmtetc.cfFormat, fmtetc.tymed, hr);
1862 if (SUCCEEDED(hr))
1863 {
1864 hr = IOleCache2_Uncache(pOleCache, dwConnection);
1865 ok_ole_success(hr, "IOleCache_Uncache");
1866 }
1867 }
1868 }
1869
1870 fmtetc.cfFormat = CF_BITMAP;
1871 fmtetc.dwAspect = DVASPECT_THUMBNAIL;
1872 fmtetc.tymed = TYMED_GDI;
1873 hr = IOleCache2_Cache(pOleCache, &fmtetc, 0, &dwConnection);
1874 ok_ole_success(hr, "IOleCache_Cache");
1875
1876 fmtetc.cfFormat = 0;
1877 fmtetc.dwAspect = DVASPECT_ICON;
1878 fmtetc.tymed = TYMED_MFPICT;
1879 hr = IOleCache2_Cache(pOleCache, &fmtetc, 0, &dwConnection);
1880 ok_ole_success(hr, "IOleCache_Cache");
1881
1882 MultiByteToWideChar(CP_ACP, 0, szSystemDir, -1, wszPath, ARRAY_SIZE(wszPath));
1883 memcpy(wszPath+lstrlenW(wszPath), wszShell32, sizeof(wszShell32));
1884
1885 fmtetc.cfFormat = CF_METAFILEPICT;
1886 stgmedium.tymed = TYMED_MFPICT;
1887 U(stgmedium).hMetaFilePict = OleMetafilePictFromIconAndLabel(
1888 LoadIconA(NULL, (LPSTR)IDI_APPLICATION), wszPath, wszPath, 0);
1889 stgmedium.pUnkForRelease = NULL;
1890
1891 fmtetc.dwAspect = DVASPECT_CONTENT;
1892 hr = IOleCache2_SetData(pOleCache, &fmtetc, &stgmedium, FALSE);
1893 ok(hr == OLE_E_BLANK, "IOleCache_SetData for aspect not in cache should have return OLE_E_BLANK instead of 0x%08x\n", hr);
1894
1895 fmtetc.dwAspect = DVASPECT_ICON;
1896 hr = IOleCache2_SetData(pOleCache, &fmtetc, &stgmedium, FALSE);
1897 ok_ole_success(hr, "IOleCache_SetData");
1898 ReleaseStgMedium(&stgmedium);
1899
1900 hr = IViewObject_Freeze(pViewObject, DVASPECT_ICON, -1, NULL, &dwFreeze);
1901 todo_wine {
1902 ok_ole_success(hr, "IViewObject_Freeze");
1903 hr = IViewObject_Freeze(pViewObject, DVASPECT_CONTENT, -1, NULL, &dwFreeze);
1904 ok(hr == OLE_E_BLANK, "IViewObject_Freeze with uncached aspect should have returned OLE_E_BLANK instead of 0x%08x\n", hr);
1905 }
1906
1907 rcBounds.left = 0;
1908 rcBounds.top = 0;
1909 rcBounds.right = 100;
1910 rcBounds.bottom = 100;
1912
1913 hr = IViewObject_Draw(pViewObject, DVASPECT_ICON, -1, NULL, NULL, NULL, hdcMem, &rcBounds, NULL, draw_continue, 0xdeadbeef);
1914 ok_ole_success(hr, "IViewObject_Draw");
1915
1916 hr = IViewObject_Draw(pViewObject, DVASPECT_CONTENT, -1, NULL, NULL, NULL, hdcMem, &rcBounds, NULL, draw_continue, 0xdeadbeef);
1917 ok(hr == OLE_E_BLANK, "IViewObject_Draw with uncached aspect should have returned OLE_E_BLANK instead of 0x%08x\n", hr);
1918
1919 /* a NULL draw_continue fn ptr */
1920 hr = IViewObject_Draw(pViewObject, DVASPECT_ICON, -1, NULL, NULL, NULL, hdcMem, &rcBounds, NULL, NULL, 0xdeadbeef);
1921 ok_ole_success(hr, "IViewObject_Draw");
1922
1923 /* draw_continue that returns FALSE to abort drawing */
1924 hr = IViewObject_Draw(pViewObject, DVASPECT_ICON, -1, NULL, NULL, NULL, hdcMem, &rcBounds, NULL, draw_continue_false, 0xdeadbeef);
1925 ok(hr == E_ABORT ||
1926 broken(hr == S_OK), /* win9x may skip the callbacks */
1927 "IViewObject_Draw with draw_continue_false returns 0x%08x\n", hr);
1928
1930
1931 hr = IOleCacheControl_OnRun(pOleCacheControl, &DataObject);
1932 ok_ole_success(hr, "IOleCacheControl_OnRun");
1933
1934 hr = IPersistStorage_Save(pPS, pStorage, TRUE);
1935 ok_ole_success(hr, "IPersistStorage_Save");
1936
1937 hr = IPersistStorage_SaveCompleted(pPS, NULL);
1938 ok_ole_success(hr, "IPersistStorage_SaveCompleted");
1939
1940 hr = IPersistStorage_IsDirty(pPS);
1941 ok(hr == S_FALSE, "IPersistStorage_IsDirty should have returned S_FALSE instead of 0x%x\n", hr);
1942
1943 IPersistStorage_Release(pPS);
1944 IViewObject_Release(pViewObject);
1945 IOleCache2_Release(pOleCache);
1946 IOleCacheControl_Release(pOleCacheControl);
1947
1949
1950 /* Test with loaded data */
1951 trace("Testing loaded data with CreateDataCache:\n");
1952 expected_method_list = methods_cacheload;
1953
1954 hr = CreateDataCache(NULL, &CLSID_NULL, &IID_IOleCache2, (LPVOID *)&pOleCache);
1955 ok_ole_success(hr, "CreateDataCache");
1956
1957 hr = IOleCache2_QueryInterface(pOleCache, &IID_IPersistStorage, (LPVOID *)&pPS);
1958 ok_ole_success(hr, "IOleCache_QueryInterface(IID_IPersistStorage)");
1959 hr = IOleCache2_QueryInterface(pOleCache, &IID_IViewObject, (LPVOID *)&pViewObject);
1960 ok_ole_success(hr, "IOleCache_QueryInterface(IID_IViewObject)");
1961
1962 hr = IViewObject_SetAdvise(pViewObject, DVASPECT_ICON, ADVF_PRIMEFIRST, &AdviseSink);
1963 ok_ole_success(hr, "IViewObject_SetAdvise");
1964
1965 hr = IPersistStorage_Load(pPS, pStorage);
1966 ok_ole_success(hr, "IPersistStorage_Load");
1967
1968 hr = IPersistStorage_IsDirty(pPS);
1969 ok(hr == S_FALSE, "IPersistStorage_IsDirty should have returned S_FALSE instead of 0x%x\n", hr);
1970
1971 fmtetc.cfFormat = 0;
1972 fmtetc.dwAspect = DVASPECT_ICON;
1973 fmtetc.lindex = -1;
1974 fmtetc.ptd = NULL;
1975 fmtetc.tymed = TYMED_MFPICT;
1976 hr = IOleCache2_Cache(pOleCache, &fmtetc, 0, &dwConnection);
1977 ok(hr == CACHE_S_SAMECACHE, "IOleCache_Cache with already loaded data format type should return CACHE_S_SAMECACHE instead of 0x%x\n", hr);
1978
1979 rcBounds.left = 0;
1980 rcBounds.top = 0;
1981 rcBounds.right = 100;
1982 rcBounds.bottom = 100;
1984
1985 hr = IViewObject_Draw(pViewObject, DVASPECT_ICON, -1, NULL, NULL, NULL, hdcMem, &rcBounds, NULL, draw_continue, 0xdeadbeef);
1986 ok_ole_success(hr, "IViewObject_Draw");
1987
1988 hr = IViewObject_Draw(pViewObject, DVASPECT_CONTENT, -1, NULL, NULL, NULL, hdcMem, &rcBounds, NULL, draw_continue, 0xdeadbeef);
1989 ok(hr == OLE_E_BLANK, "IViewObject_Draw with uncached aspect should have returned OLE_E_BLANK instead of 0x%08x\n", hr);
1990
1991 /* unload the cached storage object, causing it to be reloaded */
1992 hr = IOleCache2_DiscardCache(pOleCache, DISCARDCACHE_NOSAVE);
1993 ok_ole_success(hr, "IOleCache2_DiscardCache");
1994 hr = IViewObject_Draw(pViewObject, DVASPECT_ICON, -1, NULL, NULL, NULL, hdcMem, &rcBounds, NULL, draw_continue, 0xdeadbeef);
1995 ok_ole_success(hr, "IViewObject_Draw");
1996
1997 /* unload the cached storage object, but don't allow it to be reloaded */
1998 hr = IPersistStorage_HandsOffStorage(pPS);
1999 ok_ole_success(hr, "IPersistStorage_HandsOffStorage");
2000 hr = IViewObject_Draw(pViewObject, DVASPECT_ICON, -1, NULL, NULL, NULL, hdcMem, &rcBounds, NULL, draw_continue, 0xdeadbeef);
2001 ok_ole_success(hr, "IViewObject_Draw");
2002 hr = IOleCache2_DiscardCache(pOleCache, DISCARDCACHE_NOSAVE);
2003 ok_ole_success(hr, "IOleCache2_DiscardCache");
2004 hr = IViewObject_Draw(pViewObject, DVASPECT_ICON, -1, NULL, NULL, NULL, hdcMem, &rcBounds, NULL, draw_continue, 0xdeadbeef);
2005 ok(hr == OLE_E_BLANK, "IViewObject_Draw with uncached aspect should have returned OLE_E_BLANK instead of 0x%08x\n", hr);
2006
2008
2009 hr = IOleCache2_InitCache(pOleCache, &DataObject);
2010 ok(hr == CACHE_E_NOCACHE_UPDATED, "IOleCache_InitCache should have returned CACHE_E_NOCACHE_UPDATED instead of 0x%08x\n", hr);
2011
2012 IPersistStorage_Release(pPS);
2013 IViewObject_Release(pViewObject);
2014 IOleCache2_Release(pOleCache);
2015
2017
2018 hr = CreateDataCache(NULL, &CLSID_NULL, &IID_IOleCache2, (LPVOID *)&pOleCache);
2019 ok_ole_success(hr, "CreateDataCache");
2020
2021 expected_method_list = methods_cachethenrun;
2022
2023 hr = IOleCache2_QueryInterface(pOleCache, &IID_IDataObject, (LPVOID *)&pCacheDataObject);
2024 ok_ole_success(hr, "IOleCache_QueryInterface(IID_IDataObject)");
2025 hr = IOleCache2_QueryInterface(pOleCache, &IID_IOleCacheControl, (LPVOID *)&pOleCacheControl);
2026 ok_ole_success(hr, "IOleCache_QueryInterface(IID_IOleCacheControl)");
2027
2028 fmtetc.cfFormat = CF_METAFILEPICT;
2029 fmtetc.dwAspect = DVASPECT_CONTENT;
2030 fmtetc.tymed = TYMED_MFPICT;
2031
2032 hr = IOleCache2_Cache(pOleCache, &fmtetc, 0, &dwConnection);
2033 ok_ole_success(hr, "IOleCache_Cache");
2034
2035 hr = IDataObject_GetData(pCacheDataObject, &fmtetc, &stgmedium);
2036 ok(hr == OLE_E_BLANK, "got %08x\n", hr);
2037
2038 fmtetc.cfFormat = cf_test_1;
2039 fmtetc.dwAspect = DVASPECT_CONTENT;
2040 fmtetc.tymed = TYMED_HGLOBAL;
2041
2042 hr = IOleCache2_Cache(pOleCache, &fmtetc, 0, &dwConnection);
2043 ok(hr == CACHE_S_FORMATETC_NOTSUPPORTED, "got %08x\n", hr);
2044
2045 hr = IDataObject_GetData(pCacheDataObject, &fmtetc, &stgmedium);
2046 ok(hr == OLE_E_BLANK, "got %08x\n", hr);
2047
2048 fmtetc.cfFormat = cf_test_2;
2049 hr = IOleCache2_Cache(pOleCache, &fmtetc, ADVF_PRIMEFIRST, &dwConnection);
2050 ok(hr == CACHE_S_FORMATETC_NOTSUPPORTED, "got %08x\n", hr);
2051
2052 hr = IDataObject_GetData(pCacheDataObject, &fmtetc, &stgmedium);
2053 ok(hr == OLE_E_BLANK, "got %08x\n", hr);
2054
2055 hr = IOleCacheControl_OnRun(pOleCacheControl, &DataObject);
2056 ok_ole_success(hr, "IOleCacheControl_OnRun");
2057
2058 fmtetc.cfFormat = cf_test_3;
2059 hr = IOleCache2_Cache(pOleCache, &fmtetc, 0, &dwConnection);
2060 ok(hr == CACHE_S_FORMATETC_NOTSUPPORTED, "got %08x\n", hr);
2061
2062 fmtetc.cfFormat = cf_test_1;
2063 hr = IDataObject_GetData(pCacheDataObject, &fmtetc, &stgmedium);
2064 ok(hr == OLE_E_BLANK, "got %08x\n", hr);
2065
2066 fmtetc.cfFormat = cf_test_2;
2067 hr = IDataObject_GetData(pCacheDataObject, &fmtetc, &stgmedium);
2068 ok(hr == S_OK, "got %08x\n", hr);
2069 ReleaseStgMedium(&stgmedium);
2070
2071 fmtetc.cfFormat = cf_test_3;
2072 hr = IDataObject_GetData(pCacheDataObject, &fmtetc, &stgmedium);
2073 ok(hr == OLE_E_BLANK, "got %08x\n", hr);
2074
2075 IOleCacheControl_Release(pOleCacheControl);
2076 IDataObject_Release(pCacheDataObject);
2077 IOleCache2_Release(pOleCache);
2078
2080
2081 IStorage_Release(pStorage);
2082}
#define skip(...)
Definition: atltest.h:64
#define broken(x)
Definition: atltest.h:178
#define CF_MAX
Definition: constants.h:412
#define ARRAY_SIZE(A)
Definition: main.h:20
HRESULT WINAPI CreateDataCache(LPUNKNOWN pUnkOuter, REFCLSID rclsid, REFIID riid, LPVOID *ppvObj)
Definition: datacache.c:3035
#define E_INVALIDARG
Definition: ddrawi.h:101
#define GetProcAddress(x, y)
Definition: compat.h:753
#define MAX_PATH
Definition: compat.h:34
#define lstrlenW
Definition: compat.h:750
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
UINT WINAPI GetSystemDirectoryA(OUT LPSTR lpBuffer, IN UINT uSize)
Definition: path.c:2283
void WINAPI ReleaseStgMedium(STGMEDIUM *pmedium)
Definition: ole2.c:2033
#define SUCCEEDED(hr)
Definition: intsafe.h:50
static BOOL STDMETHODCALLTYPE draw_continue_false(ULONG_PTR param)
Definition: ole2.c:1373
static IUnknown unknown
Definition: ole2.c:1657
static IAdviseSink AdviseSink
Definition: ole2.c:1447
#define CHECK_NO_EXTRA_METHODS()
Definition: ole2.c:193
static BOOL STDMETHODCALLTYPE draw_continue(ULONG_PTR param)
Definition: ole2.c:1367
static IDataObject DataObject
Definition: ole2.c:1626
HGLOBAL WINAPI OleMetafilePictFromIconAndLabel(HICON hIcon, LPOLESTR lpszLabel, LPOLESTR lpszSourceFile, UINT iIconIndex)
Definition: ole32_main.c:40
const GUID IID_IViewObject
const GUID IID_IOleCache2
const GUID IID_IOleCacheControl
#define CLSID_NULL
Definition: guiddef.h:99
#define IID_NULL
Definition: guiddef.h:98
long bottom
Definition: polytest.cpp:53
long right
Definition: polytest.cpp:53
long top
Definition: polytest.cpp:53
long left
Definition: polytest.cpp:53
HDC hdcMem
Definition: welcome.c:104
#define CACHE_S_SAMECACHE
Definition: winerror.h:2707
#define OLE_E_NOCONNECTION
Definition: winerror.h:2618
#define CACHE_S_FORMATETC_NOTSUPPORTED
Definition: winerror.h:2706
#define CACHE_E_NOCACHE_UPDATED
Definition: winerror.h:2712
#define DV_E_TYMED
Definition: winerror.h:2638
#define E_ABORT
Definition: winerror.h:2366
#define OLE_E_BLANK
Definition: winerror.h:2621
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
BOOL WINAPI DeleteDC(_In_ HDC)
#define IDI_APPLICATION
Definition: winuser.h:704
HICON WINAPI LoadIconA(_In_opt_ HINSTANCE hInstance, _In_ LPCSTR lpIconName)
Definition: cursoricon.c:2104
char * LPSTR
Definition: xmlstorage.h:182

Referenced by START_TEST().

◆ test_data_cache_cache()

static void test_data_cache_cache ( void  )
static

Definition at line 2232 of file ole2.c.

2233{
2234 HRESULT hr;
2237 FORMATETC fmt;
2238 DWORD conn;
2239 STGMEDIUM med;
2240 STATDATA expect[] =
2241 {
2242 {{ CF_DIB, 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL }, 0, NULL, 0 },
2243 {{ CF_BITMAP, 0, DVASPECT_CONTENT, -1, TYMED_GDI }, 0, NULL, 0 },
2244 {{ CF_METAFILEPICT, 0, DVASPECT_CONTENT, -1, TYMED_MFPICT }, 0, NULL, 0 },
2245 {{ CF_ENHMETAFILE, 0, DVASPECT_CONTENT, -1, TYMED_ENHMF }, 0, NULL, 0 }
2246 };
2247 STATDATA view_caching[] =
2248 {
2249 {{ 0, 0, DVASPECT_CONTENT, -1, TYMED_ENHMF }, 0, NULL, 0 },
2250 {{ 0, 0, DVASPECT_THUMBNAIL, -1, TYMED_HGLOBAL }, 0, NULL, 0 },
2251 {{ 0, 0, DVASPECT_DOCPRINT, -1, TYMED_HGLOBAL }, 0, NULL, 0 },
2252 {{ CF_METAFILEPICT, 0, DVASPECT_ICON, -1, TYMED_MFPICT }, 0, NULL, 0 }
2253 };
2254
2256 ok( hr == S_OK, "got %08x\n", hr );
2257
2258 /* create a dib entry which will also create a bitmap entry too */
2259 fmt.cfFormat = CF_DIB;
2260 fmt.ptd = NULL;
2261 fmt.dwAspect = DVASPECT_CONTENT;
2262 fmt.lindex = -1;
2263 fmt.tymed = TYMED_HGLOBAL;
2264
2265 hr = IOleCache2_Cache( cache, &fmt, 0, &conn );
2266 ok( hr == S_OK, "got %08x\n", hr );
2267 ok( conn == 2, "got %d\n", conn );
2268 expect[0].dwConnection = conn;
2269 expect[1].dwConnection = conn;
2270
2272
2273 /* now try to add a bitmap */
2274 fmt.cfFormat = CF_BITMAP;
2275 fmt.tymed = TYMED_GDI;
2276
2277 hr = IOleCache2_Cache( cache, &fmt, 0, &conn );
2278 ok( hr == CACHE_S_SAMECACHE, "got %08x\n", hr );
2279
2280 /* metafile */
2281 fmt.cfFormat = CF_METAFILEPICT;
2282 fmt.tymed = TYMED_MFPICT;
2283
2284 hr = IOleCache2_Cache( cache, &fmt, 0, &conn );
2285 ok( hr == S_OK, "got %08x\n", hr );
2286 ok( conn == 3, "got %d\n", conn );
2287 expect[2].dwConnection = conn;
2288
2290
2291 /* enhmetafile */
2292 fmt.cfFormat = CF_ENHMETAFILE;
2293 fmt.tymed = TYMED_ENHMF;
2294
2295 hr = IOleCache2_Cache( cache, &fmt, 0, &conn );
2296 ok( hr == S_OK, "got %08x\n", hr );
2297 ok( conn == 4, "got %d\n", conn );
2298 expect[3].dwConnection = conn;
2299
2301
2302 /* uncache everything */
2303 hr = IOleCache2_Uncache( cache, expect[3].dwConnection );
2304 ok( hr == S_OK, "got %08x\n", hr );
2305 hr = IOleCache2_Uncache( cache, expect[2].dwConnection );
2306 ok( hr == S_OK, "got %08x\n", hr );
2307 hr = IOleCache2_Uncache( cache, expect[0].dwConnection );
2308 ok( hr == S_OK, "got %08x\n", hr );
2309 hr = IOleCache2_Uncache( cache, expect[0].dwConnection );
2310 ok( hr == OLE_E_NOCONNECTION, "got %08x\n", hr );
2311
2313
2314 /* just create a bitmap entry which again adds both dib and bitmap */
2315 fmt.cfFormat = CF_BITMAP;
2316 fmt.tymed = TYMED_GDI;
2317
2318 hr = IOleCache2_Cache( cache, &fmt, 0, &conn );
2319 ok( hr == S_OK, "got %08x\n", hr );
2320
2321 expect[0].dwConnection = conn;
2322 expect[1].dwConnection = conn;
2323
2325
2326 /* Try setting a 1x1 bitmap */
2327 hr = IOleCache2_QueryInterface( cache, &IID_IDataObject, (void **) &data );
2328 ok( hr == S_OK, "got %08x\n", hr );
2329
2330 create_bitmap( &med );
2331
2332 hr = IOleCache2_SetData( cache, &fmt, &med, TRUE );
2333 ok( hr == S_OK, "got %08x\n", hr );
2334
2335 hr = IDataObject_GetData( data, &fmt, &med );
2336 ok( hr == S_OK, "got %08x\n", hr );
2337 ok( med.tymed == TYMED_GDI, "got %d\n", med.tymed );
2338 check_bitmap_size( U(med).hBitmap, 1, 1 );
2339 ReleaseStgMedium( &med );
2340
2341 fmt.cfFormat = CF_DIB;
2342 fmt.tymed = TYMED_HGLOBAL;
2343 hr = IDataObject_GetData( data, &fmt, &med );
2344 ok( hr == S_OK, "got %08x\n", hr );
2345 ok( med.tymed == TYMED_HGLOBAL, "got %d\n", med.tymed );
2346 check_dib_size( U(med).hGlobal, 1, 1 );
2347 ReleaseStgMedium( &med );
2348
2349 /* Now set a 2x1 dib */
2350 fmt.cfFormat = CF_DIB;
2351 fmt.tymed = TYMED_HGLOBAL;
2352 create_dib( &med );
2353
2354 hr = IOleCache2_SetData( cache, &fmt, &med, TRUE );
2355 ok( hr == S_OK, "got %08x\n", hr );
2356
2357 fmt.cfFormat = CF_BITMAP;
2358 fmt.tymed = TYMED_GDI;
2359 hr = IDataObject_GetData( data, &fmt, &med );
2360 ok( hr == S_OK, "got %08x\n", hr );
2361 ok( med.tymed == TYMED_GDI, "got %d\n", med.tymed );
2362 check_bitmap_size( U(med).hBitmap, 2, 1 );
2363 ReleaseStgMedium( &med );
2364
2365 fmt.cfFormat = CF_DIB;
2366 fmt.tymed = TYMED_HGLOBAL;
2367 hr = IDataObject_GetData( data, &fmt, &med );
2368 ok( hr == S_OK, "got %08x\n", hr );
2369 ok( med.tymed == TYMED_HGLOBAL, "got %d\n", med.tymed );
2370 check_dib_size( U(med).hGlobal, 2, 1 );
2371 ReleaseStgMedium( &med );
2372
2373 /* uncache everything */
2374 hr = IOleCache2_Uncache( cache, conn );
2375 ok( hr == S_OK, "got %08x\n", hr );
2376
2377 /* view caching */
2378 fmt.cfFormat = 0;
2379 fmt.tymed = TYMED_ENHMF;
2380 hr = IOleCache2_Cache( cache, &fmt, 0, &conn );
2381 ok( hr == S_OK, "got %08x\n", hr );
2382 view_caching[0].dwConnection = conn;
2383
2384 fmt.tymed = TYMED_HGLOBAL;
2385 hr = IOleCache2_Cache( cache, &fmt, 0, &conn );
2386 ok( hr == CACHE_S_SAMECACHE, "got %08x\n", hr );
2387
2388 fmt.dwAspect = DVASPECT_THUMBNAIL;
2389 hr = IOleCache2_Cache( cache, &fmt, 0, &conn );
2390 ok( hr == S_OK, "got %08x\n", hr );
2391 view_caching[1].dwConnection = conn;
2392
2393 fmt.dwAspect = DVASPECT_DOCPRINT;
2394 hr = IOleCache2_Cache( cache, &fmt, 0, &conn );
2395 ok( hr == S_OK, "got %08x\n", hr );
2396 view_caching[2].dwConnection = conn;
2397
2398 /* DVASPECT_ICON view cache gets mapped to CF_METAFILEPICT */
2399 fmt.dwAspect = DVASPECT_ICON;
2400 hr = IOleCache2_Cache( cache, &fmt, 0, &conn );
2401 ok( hr == S_OK, "got %08x\n", hr );
2402 view_caching[3].dwConnection = conn;
2403
2404 check_enum_cache( cache, view_caching, 4 );
2405
2406 /* uncache everything */
2407 hr = IOleCache2_Uncache( cache, view_caching[3].dwConnection );
2408 ok( hr == S_OK, "got %08x\n", hr );
2409 hr = IOleCache2_Uncache( cache, view_caching[2].dwConnection );
2410 ok( hr == S_OK, "got %08x\n", hr );
2411 hr = IOleCache2_Uncache( cache, view_caching[1].dwConnection );
2412 ok( hr == S_OK, "got %08x\n", hr );
2413 hr = IOleCache2_Uncache( cache, view_caching[0].dwConnection );
2414 ok( hr == S_OK, "got %08x\n", hr );
2415
2416 /* Only able to set cfFormat == CF_METAFILEPICT (or == 0, see above) for DVASPECT_ICON */
2417 fmt.dwAspect = DVASPECT_ICON;
2418 fmt.cfFormat = CF_DIB;
2419 fmt.tymed = TYMED_HGLOBAL;
2420 hr = IOleCache2_Cache( cache, &fmt, 0, &conn );
2421 ok( hr == DV_E_FORMATETC, "got %08x\n", hr );
2422 fmt.cfFormat = CF_BITMAP;
2423 fmt.tymed = TYMED_GDI;
2424 hr = IOleCache2_Cache( cache, &fmt, 0, &conn );
2425 ok( hr == DV_E_FORMATETC, "got %08x\n", hr );
2426 fmt.cfFormat = CF_ENHMETAFILE;
2427 fmt.tymed = TYMED_ENHMF;
2428 hr = IOleCache2_Cache( cache, &fmt, 0, &conn );
2429 ok( hr == DV_E_FORMATETC, "got %08x\n", hr );
2430 fmt.cfFormat = CF_METAFILEPICT;
2431 fmt.tymed = TYMED_MFPICT;
2432 hr = IOleCache2_Cache( cache, &fmt, 0, &conn );
2433 ok( hr == S_OK, "got %08x\n", hr );
2434
2435 /* uncache everything */
2436 hr = IOleCache2_Uncache( cache, conn );
2437 ok( hr == S_OK, "got %08x\n", hr );
2438
2439 /* tymed == 0 */
2440 fmt.cfFormat = CF_ENHMETAFILE;
2441 fmt.dwAspect = DVASPECT_CONTENT;
2442 fmt.tymed = 0;
2443 hr = IOleCache2_Cache( cache, &fmt, 0, &conn );
2444 ok( hr == DV_E_TYMED, "got %08x\n", hr );
2445
2446 IDataObject_Release( data );
2447 IOleCache2_Release( cache );
2448
2449 /* tests for a static class cache */
2451
2452 fmt.cfFormat = CF_DIB;
2453 fmt.dwAspect = DVASPECT_CONTENT;
2454 fmt.tymed = TYMED_HGLOBAL;
2455 hr = IOleCache2_Cache( cache, &fmt, 0, &conn );
2456 ok( hr == CACHE_S_SAMECACHE, "got %08x\n", hr );
2457
2458 /* aspect other than DVASPECT_CONTENT should fail */
2459 fmt.dwAspect = DVASPECT_THUMBNAIL;
2460 hr = IOleCache2_Cache( cache, &fmt, 0, &conn );
2461 ok( FAILED(hr), "got %08x\n", hr );
2462
2463 fmt.dwAspect = DVASPECT_DOCPRINT;
2464 hr = IOleCache2_Cache( cache, &fmt, 0, &conn );
2465 ok( FAILED(hr), "got %08x\n", hr );
2466
2467 /* try caching another clip format */
2468 fmt.cfFormat = CF_METAFILEPICT;
2469 fmt.dwAspect = DVASPECT_CONTENT;
2470 fmt.tymed = TYMED_MFPICT;
2471 hr = IOleCache2_Cache( cache, &fmt, 0, &conn );
2472 ok( FAILED(hr), "got %08x\n", hr );
2473
2474 /* As an exception, it's possible to add an icon aspect */
2475 fmt.cfFormat = CF_METAFILEPICT;
2476 fmt.dwAspect = DVASPECT_ICON;
2477 fmt.tymed = TYMED_MFPICT;
2478 hr = IOleCache2_Cache( cache, &fmt, 0, &conn );
2479 ok( hr == S_OK, "got %08x\n", hr );
2480
2481 IOleCache2_Release( cache );
2482}
static HBITMAP hBitmap
Definition: timezone.c:26
#define FAILED(hr)
Definition: intsafe.h:51
static void check_dib_size(HGLOBAL h, int cx, int cy)
Definition: ole2.c:2222
static void check_bitmap_size(HBITMAP h, int cx, int cy)
Definition: ole2.c:2213
static void check_enum_cache(IOleCache2 *cache, const STATDATA *expect, int num)
Definition: ole2.c:1659
#define DV_E_FORMATETC
Definition: winerror.h:2633

Referenced by START_TEST().

◆ test_data_cache_contents()

static void test_data_cache_contents ( void  )
static

Definition at line 4540 of file ole2.c.

4541{
4542 HRESULT hr;
4543 IStorage *doc1, *doc2;
4545 IPersistStorage *stg;
4546 int i, enumerated_streams, matched_streams;
4547 static const struct
4548 {
4549 const struct storage_def *in;
4550 const struct storage_def *out;
4551 } test_data[] =
4552 {
4563 };
4564
4565 for (i = 0; i < ARRAY_SIZE(test_data); i++)
4566 {
4567 if (winetest_debug > 1)
4568 trace("start testing storage def %d\n", i);
4569
4571 if (!doc1) continue;
4572
4573 enumerated_streams = matched_streams = -1;
4574 check_storage_contents(doc1, test_data[i].in, &enumerated_streams, &matched_streams);
4575 ok(enumerated_streams == matched_streams, "%d in: enumerated %d != matched %d\n", i,
4576 enumerated_streams, matched_streams);
4577 ok(enumerated_streams == test_data[i].in->stream_count, "%d: created %d != def streams %d\n", i,
4578 enumerated_streams, test_data[i].in->stream_count);
4579
4581 ok(hr == S_OK, "unexpected %#x\n", hr);
4582 hr = IOleCache2_QueryInterface(cache, &IID_IPersistStorage, (void **)&stg);
4583 ok(hr == S_OK, "unexpected %#x\n", hr);
4584 hr = IPersistStorage_Load(stg, doc1);
4585 ok(hr == S_OK, "unexpected %#x\n", hr);
4586
4587 IStorage_Release(doc1);
4588
4590 ok(hr == S_OK, "unexpected %#x\n", hr);
4591
4592 hr = IPersistStorage_IsDirty(stg);
4593 ok(hr == S_FALSE, "%d: unexpected %#x\n", i, hr);
4594
4595 hr = IPersistStorage_Save(stg, doc2, FALSE);
4596 ok(hr == S_OK, "unexpected %#x\n", hr);
4597
4598 IPersistStorage_Release(stg);
4599
4600 enumerated_streams = matched_streams = -1;
4601 check_storage_contents(doc2, test_data[i].out, &enumerated_streams, &matched_streams);
4603 ok(enumerated_streams == matched_streams, "%d out: enumerated %d != matched %d\n", i,
4604 enumerated_streams, matched_streams);
4606 || test_data[i].in == &stg_def_6))
4607 ok(enumerated_streams == test_data[i].out->stream_count, "%d: saved streams %d != def streams %d\n", i,
4608 enumerated_streams, test_data[i].out->stream_count);
4609
4610 IStorage_Release(doc2);
4611
4612 if (winetest_debug > 1)
4613 trace("done testing storage def %d\n", i);
4614 }
4615}
GLuint in
Definition: glext.h:9616
static IStorage * create_storage_from_def(const struct storage_def *stg_def)
Definition: ole2.c:4179
static const struct storage_def stg_def_9
Definition: ole2.c:3961
static const struct storage_def stg_def_1
Definition: ole2.c:3863
static const struct storage_def stg_def_7
Definition: ole2.c:3943
static const struct storage_def stg_def_6
Definition: ole2.c:3929
static const struct storage_def stg_def_0_saved
Definition: ole2.c:3859
static const struct storage_def stg_def_9_saved
Definition: ole2.c:3966
static const struct storage_def stg_def_4
Definition: ole2.c:3901
static const struct storage_def stg_def_5_saved
Definition: ole2.c:3924
static const struct storage_def stg_def_1_saved
Definition: ole2.c:3869
static const struct storage_def stg_def_2
Definition: ole2.c:3874
static const struct storage_def stg_def_8
Definition: ole2.c:3952
static void check_storage_contents(IStorage *stg, const struct storage_def *stg_def, int *enumerated_streams, int *matched_streams)
Definition: ole2.c:3994
static const struct storage_def stg_def_7_saved
Definition: ole2.c:3948
static const struct storage_def stg_def_2_saved
Definition: ole2.c:3880
static const struct storage_def stg_def_0
Definition: ole2.c:3854
static const struct storage_def stg_def_3
Definition: ole2.c:3885
static const struct storage_def stg_def_5
Definition: ole2.c:3915
static const struct storage_def stg_def_6_saved
Definition: ole2.c:3938
static const struct storage_def stg_def_3_saved
Definition: ole2.c:3894
static const struct storage_def stg_def_8_saved
Definition: ole2.c:3957
static const struct storage_def stg_def_4_saved
Definition: ole2.c:3910
static FILE * out
Definition: regtests2xml.c:44

Referenced by START_TEST().

◆ test_data_cache_dib_contents_stream()

static void test_data_cache_dib_contents_stream ( int  num)
static

Definition at line 2123 of file ole2.c.

2124{
2125 HRESULT hr;
2126 IUnknown *unk;
2127 IPersistStorage *persist;
2130 IStorage *stg;
2132 FORMATETC fmt = {CF_DIB, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };
2133 STGMEDIUM med;
2134 CLSID cls;
2135 SIZEL sz;
2136 BYTE *ptr;
2137 BITMAPINFOHEADER expect_info;
2138 STATDATA enum_expect[] =
2139 {
2140 {{ CF_DIB, 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL }, 0, NULL, 1 },
2141 {{ CF_BITMAP, 0, DVASPECT_CONTENT, -1, TYMED_GDI }, 0, NULL, 1 },
2142 };
2143
2145 ok( SUCCEEDED(hr), "got %08x\n", hr );
2146 hr = IUnknown_QueryInterface( unk, &IID_IPersistStorage, (void **)&persist );
2147 ok( SUCCEEDED(hr), "got %08x\n", hr );
2148 hr = IUnknown_QueryInterface( unk, &IID_IDataObject, (void **)&data );
2149 ok( SUCCEEDED(hr), "got %08x\n", hr );
2150 hr = IUnknown_QueryInterface( unk, &IID_IViewObject2, (void **)&view );
2151 ok( SUCCEEDED(hr), "got %08x\n", hr );
2152 hr = IUnknown_QueryInterface( unk, &IID_IOleCache2, (void **)&cache );
2153 ok( SUCCEEDED(hr), "got %08x\n", hr );
2154
2155 stg = create_storage( num );
2156
2157 hr = IPersistStorage_Load( persist, stg );
2158 ok( SUCCEEDED(hr), "got %08x\n", hr );
2159 IStorage_Release( stg );
2160
2161 hr = IPersistStorage_GetClassID( persist, &cls );
2162 ok( SUCCEEDED(hr), "got %08x\n", hr );
2163 ok( IsEqualCLSID( &cls, &CLSID_Picture_Dib ), "class id mismatch\n" );
2164
2165 hr = IDataObject_GetData( data, &fmt, &med );
2166 ok( SUCCEEDED(hr), "got %08x\n", hr );
2167 ok( med.tymed == TYMED_HGLOBAL, "got %x\n", med.tymed );
2168 ok( GlobalSize( U(med).hGlobal ) >= sizeof(dib) - sizeof(BITMAPFILEHEADER),
2169 "got %lu\n", GlobalSize( U(med).hGlobal ) );
2170 ptr = GlobalLock( U(med).hGlobal );
2171
2172 expect_info = *(BITMAPINFOHEADER *)(file_dib + sizeof(BITMAPFILEHEADER));
2173 if (expect_info.biXPelsPerMeter == 0 || expect_info.biYPelsPerMeter == 0)
2174 {
2175 HDC hdc = GetDC( 0 );
2176 expect_info.biXPelsPerMeter = MulDiv( GetDeviceCaps( hdc, LOGPIXELSX ), 10000, 254 );
2177 expect_info.biYPelsPerMeter = MulDiv( GetDeviceCaps( hdc, LOGPIXELSY ), 10000, 254 );
2178 ReleaseDC( 0, hdc );
2179 }
2180 ok( !memcmp( ptr, &expect_info, sizeof(expect_info) ), "mismatch\n" );
2181 ok( !memcmp( ptr + sizeof(expect_info), file_dib + sizeof(BITMAPFILEHEADER) + sizeof(expect_info),
2182 sizeof(file_dib) - sizeof(BITMAPFILEHEADER) - sizeof(expect_info) ), "mismatch\n" );
2183 GlobalUnlock( U(med).hGlobal );
2184 ReleaseStgMedium( &med );
2185
2186 check_enum_cache( cache, enum_expect, 2 );
2187
2188 hr = IViewObject2_GetExtent( view, DVASPECT_CONTENT, -1, NULL, &sz );
2189 ok( SUCCEEDED(hr), "got %08x\n", hr );
2190 if (num == 0)
2191 {
2192 ok( sz.cx == 1000, "got %d\n", sz.cx );
2193 ok( sz.cy == 250, "got %d\n", sz.cy );
2194 }
2195 else
2196 {
2197 HDC hdc = GetDC( 0 );
2198 LONG x = 2 * 2540 / GetDeviceCaps( hdc, LOGPIXELSX );
2199 LONG y = 1 * 2540 / GetDeviceCaps( hdc, LOGPIXELSY );
2200 ok( sz.cx == x, "got %d %d\n", sz.cx, x );
2201 ok( sz.cy == y, "got %d %d\n", sz.cy, y );
2202
2203 ReleaseDC( 0, hdc );
2204 }
2205
2206 IOleCache2_Release( cache );
2207 IViewObject2_Release( view );
2208 IDataObject_Release( data );
2209 IPersistStorage_Release( persist );
2210 IUnknown_Release( unk );
2211}
const CLSID CLSID_Picture_Metafile
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
static HGLOBAL create_storage(void)
Definition: clipboard.c:1289
INT WINAPI MulDiv(INT nNumber, INT nNumerator, INT nDenominator)
Definition: muldiv.c:25
const GUID IID_IViewObject2
long LONG
Definition: pedump.c:60
LONG biYPelsPerMeter
Definition: