ReactOS  0.4.15-dev-1397-g19779b3
datacache.c File Reference
#include <stdarg.h>
#include <string.h>
#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
#include "winuser.h"
#include "winerror.h"
#include "ole2.h"
#include "compobj_private.h"
#include "wine/list.h"
#include "wine/debug.h"
#include <pshpack2.h>
#include <poppack.h>
Include dependency graph for datacache.c:

Go to the source code of this file.

Classes

struct  PresentationDataHeader
 
struct  DataCacheEntry
 
struct  DataCache
 
struct  meta_placeable
 

Macros

#define COBJMACROS
 
#define NONAMELESSUNION
 
#define STREAM_NUMBER_NOT_SET   -2
 
#define STREAM_NUMBER_CONTENTS   -1 /* CONTENTS stream */
 

Typedefs

typedef struct PresentationDataHeader PresentationDataHeader
 
typedef struct DataCacheEntry DataCacheEntry
 
typedef struct DataCache DataCache
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (ole)
 
static DataCacheimpl_from_IDataObject (IDataObject *iface)
 
static DataCacheimpl_from_IUnknown (IUnknown *iface)
 
static DataCacheimpl_from_IPersistStorage (IPersistStorage *iface)
 
static DataCacheimpl_from_IViewObject2 (IViewObject2 *iface)
 
static DataCacheimpl_from_IOleCache2 (IOleCache2 *iface)
 
static DataCacheimpl_from_IOleCacheControl (IOleCacheControl *iface)
 
static DataCacheimpl_from_IAdviseSink (IAdviseSink *iface)
 
const chardebugstr_formatetc (const FORMATETC *formatetc)
 
static int bitmap_info_size (const BITMAPINFO *info, WORD coloruse)
 
static void DataCacheEntry_Destroy (DataCache *cache, DataCacheEntry *cache_entry)
 
static void DataCache_Destroy (DataCache *ptrToDestroy)
 
static DataCacheEntryDataCache_GetEntryForFormatEtc (DataCache *This, const FORMATETC *formatetc)
 
static HRESULT get_static_entry (DataCache *cache, DataCacheEntry **cache_entry)
 
static HRESULT check_valid_formatetc (const FORMATETC *fmt)
 
static BOOL init_cache_entry (DataCacheEntry *entry, const FORMATETC *fmt, DWORD advf, DWORD id)
 
static HRESULT DataCache_CreateEntry (DataCache *This, const FORMATETC *formatetc, DWORD advf, BOOL automatic, DataCacheEntry **cache_entry)
 
static void DataCache_FireOnViewChange (DataCache *this, DWORD aspect, LONG lindex)
 
static HRESULT read_clipformat (IStream *stream, CLIPFORMAT *clipformat)
 
static HRESULT write_clipformat (IStream *stream, CLIPFORMAT clipformat)
 
static HRESULT open_pres_stream (IStorage *stg, int stream_number, IStream **stm)
 
static HRESULT synthesize_emf (HMETAFILEPICT data, STGMEDIUM *med)
 
static HRESULT load_mf_pict (DataCacheEntry *cache_entry, IStream *stm)
 
static HRESULT load_dib (DataCacheEntry *cache_entry, IStream *stm)
 
static HRESULT load_emf (DataCacheEntry *cache_entry, IStream *stm)
 
static HRESULT DataCacheEntry_LoadData (DataCacheEntry *cache_entry, IStorage *stg)
 
static void init_stream_header (DataCacheEntry *entry, PresentationDataHeader *header)
 
static HRESULT save_dib (DataCacheEntry *entry, BOOL contents, IStream *stream)
 
static HRESULT save_mfpict (DataCacheEntry *entry, BOOL contents, IStream *stream)
 
static HRESULT save_emf (DataCacheEntry *entry, BOOL contents, IStream *stream)
 
static HRESULT save_view_cache (DataCacheEntry *entry, IStream *stream)
 
static HRESULT create_stream (DataCacheEntry *cache_entry, IStorage *storage, BOOL contents, IStream **stream)
 
static HRESULT DataCacheEntry_Save (DataCacheEntry *cache_entry, IStorage *storage, BOOL same_as_load)
 
static HRESULT copy_stg_medium (CLIPFORMAT cf, STGMEDIUM *dest_stgm, const STGMEDIUM *src_stgm)
 
static HRESULT synthesize_dib (HBITMAP bm, STGMEDIUM *med)
 
static HRESULT synthesize_bitmap (HGLOBAL dib, STGMEDIUM *med)
 
static HRESULT DataCacheEntry_SetData (DataCacheEntry *cache_entry, const FORMATETC *formatetc, STGMEDIUM *stgmedium, BOOL fRelease)
 
static HRESULT DataCacheEntry_GetData (DataCacheEntry *cache_entry, IStorage *stg, FORMATETC *fmt, STGMEDIUM *stgmedium)
 
static HRESULT DataCacheEntry_DiscardData (DataCacheEntry *cache_entry)
 
static DWORD tymed_from_cf (DWORD cf)
 
static HRESULT create_automatic_entry (DataCache *cache, const CLSID *clsid)
 
static HRESULT WINAPI DataCache_NDIUnknown_QueryInterface (IUnknown *iface, REFIID riid, void **ppvObject)
 
static ULONG WINAPI DataCache_NDIUnknown_AddRef (IUnknown *iface)
 
static ULONG WINAPI DataCache_NDIUnknown_Release (IUnknown *iface)
 
static HRESULT WINAPI DataCache_IDataObject_QueryInterface (IDataObject *iface, REFIID riid, void **ppvObject)
 
static ULONG WINAPI DataCache_IDataObject_AddRef (IDataObject *iface)
 
static ULONG WINAPI DataCache_IDataObject_Release (IDataObject *iface)
 
static HRESULT WINAPI DataCache_GetData (IDataObject *iface, LPFORMATETC pformatetcIn, STGMEDIUM *pmedium)
 
static HRESULT WINAPI DataCache_GetDataHere (IDataObject *iface, LPFORMATETC pformatetc, STGMEDIUM *pmedium)
 
static HRESULT WINAPI DataCache_QueryGetData (IDataObject *iface, FORMATETC *fmt)
 
static HRESULT WINAPI DataCache_GetCanonicalFormatEtc (IDataObject *iface, LPFORMATETC pformatectIn, LPFORMATETC pformatetcOut)
 
static HRESULT WINAPI DataCache_IDataObject_SetData (IDataObject *iface, LPFORMATETC pformatetc, STGMEDIUM *pmedium, BOOL fRelease)
 
static HRESULT WINAPI DataCache_EnumFormatEtc (IDataObject *iface, DWORD dwDirection, IEnumFORMATETC **ppenumFormatEtc)
 
static HRESULT WINAPI DataCache_DAdvise (IDataObject *iface, FORMATETC *pformatetc, DWORD advf, IAdviseSink *pAdvSink, DWORD *pdwConnection)
 
static HRESULT WINAPI DataCache_DUnadvise (IDataObject *iface, DWORD dwConnection)
 
static HRESULT WINAPI DataCache_EnumDAdvise (IDataObject *iface, IEnumSTATDATA **ppenumAdvise)
 
static HRESULT WINAPI DataCache_IPersistStorage_QueryInterface (IPersistStorage *iface, REFIID riid, void **ppvObject)
 
static ULONG WINAPI DataCache_IPersistStorage_AddRef (IPersistStorage *iface)
 
static ULONG WINAPI DataCache_IPersistStorage_Release (IPersistStorage *iface)
 
static HRESULT WINAPI DataCache_GetClassID (IPersistStorage *iface, CLSID *clsid)
 
static HRESULT WINAPI DataCache_IsDirty (IPersistStorage *iface)
 
static HRESULT WINAPI DataCache_InitNew (IPersistStorage *iface, IStorage *pStg)
 
static HRESULT add_cache_entry (DataCache *This, const FORMATETC *fmt, DWORD advf, int stream_number)
 
static HRESULT parse_pres_streams (DataCache *cache, IStorage *stg)
 
static HRESULT parse_contents_stream (DataCache *cache, IStorage *stg)
 
static HRESULT WINAPI DataCache_Load (IPersistStorage *iface, IStorage *stg)
 
static HRESULT WINAPI DataCache_Save (IPersistStorage *iface, IStorage *stg, BOOL same_as_load)
 
static HRESULT WINAPI DataCache_SaveCompleted (IPersistStorage *iface, IStorage *pStgNew)
 
static HRESULT WINAPI DataCache_HandsOffStorage (IPersistStorage *iface)
 
static HRESULT WINAPI DataCache_IViewObject2_QueryInterface (IViewObject2 *iface, REFIID riid, void **ppvObject)
 
static ULONG WINAPI DataCache_IViewObject2_AddRef (IViewObject2 *iface)
 
static ULONG WINAPI DataCache_IViewObject2_Release (IViewObject2 *iface)
 
static HRESULT WINAPI DataCache_Draw (IViewObject2 *iface, DWORD dwDrawAspect, LONG lindex, void *pvAspect, DVTARGETDEVICE *ptd, HDC hdcTargetDev, HDC hdcDraw, LPCRECTL lprcBounds, LPCRECTL lprcWBounds, BOOL(CALLBACK *pfnContinue)(ULONG_PTR dwContinue), ULONG_PTR dwContinue)
 
static HRESULT WINAPI DataCache_GetColorSet (IViewObject2 *iface, DWORD dwDrawAspect, LONG lindex, void *pvAspect, DVTARGETDEVICE *ptd, HDC hicTargetDevice, LOGPALETTE **ppColorSet)
 
static HRESULT WINAPI DataCache_Freeze (IViewObject2 *iface, DWORD dwDrawAspect, LONG lindex, void *pvAspect, DWORD *pdwFreeze)
 
static HRESULT WINAPI DataCache_Unfreeze (IViewObject2 *iface, DWORD dwFreeze)
 
static HRESULT WINAPI DataCache_SetAdvise (IViewObject2 *iface, DWORD aspects, DWORD advf, IAdviseSink *pAdvSink)
 
static HRESULT WINAPI DataCache_GetAdvise (IViewObject2 *iface, DWORD *pAspects, DWORD *pAdvf, IAdviseSink **ppAdvSink)
 
static HRESULT WINAPI DataCache_GetExtent (IViewObject2 *iface, DWORD dwDrawAspect, LONG lindex, DVTARGETDEVICE *ptd, LPSIZEL lpsizel)
 
static HRESULT WINAPI DataCache_IOleCache2_QueryInterface (IOleCache2 *iface, REFIID riid, void **ppvObject)
 
static ULONG WINAPI DataCache_IOleCache2_AddRef (IOleCache2 *iface)
 
static ULONG WINAPI DataCache_IOleCache2_Release (IOleCache2 *iface)
 
static HRESULT setup_sink (DataCache *This, DataCacheEntry *cache_entry)
 
static HRESULT WINAPI DataCache_Cache (IOleCache2 *iface, FORMATETC *pformatetc, DWORD advf, DWORD *pdwConnection)
 
static HRESULT WINAPI DataCache_Uncache (IOleCache2 *iface, DWORD dwConnection)
 
static HRESULT WINAPI DataCache_EnumCache (IOleCache2 *iface, IEnumSTATDATA **enum_stat)
 
static HRESULT WINAPI DataCache_InitCache (IOleCache2 *iface, IDataObject *data)
 
static HRESULT WINAPI DataCache_IOleCache2_SetData (IOleCache2 *iface, FORMATETC *pformatetc, STGMEDIUM *pmedium, BOOL fRelease)
 
static BOOL entry_updatable (DataCacheEntry *entry, DWORD mode)
 
static HRESULT WINAPI DataCache_UpdateCache (IOleCache2 *iface, IDataObject *data, DWORD mode, void *reserved)
 
static HRESULT WINAPI DataCache_DiscardCache (IOleCache2 *iface, DWORD dwDiscardOptions)
 
static HRESULT WINAPI DataCache_IOleCacheControl_QueryInterface (IOleCacheControl *iface, REFIID riid, void **ppvObject)
 
static ULONG WINAPI DataCache_IOleCacheControl_AddRef (IOleCacheControl *iface)
 
static ULONG WINAPI DataCache_IOleCacheControl_Release (IOleCacheControl *iface)
 
static HRESULT WINAPI DataCache_OnRun (IOleCacheControl *iface, IDataObject *data_obj)
 
static HRESULT WINAPI DataCache_OnStop (IOleCacheControl *iface)
 
static HRESULT WINAPI DataCache_IAdviseSink_QueryInterface (IAdviseSink *iface, REFIID iid, void **obj)
 
static ULONG WINAPI DataCache_IAdviseSink_AddRef (IAdviseSink *iface)
 
static ULONG WINAPI DataCache_IAdviseSink_Release (IAdviseSink *iface)
 
static void WINAPI DataCache_OnDataChange (IAdviseSink *iface, FORMATETC *fmt, STGMEDIUM *med)
 
static void WINAPI DataCache_OnViewChange (IAdviseSink *iface, DWORD aspect, LONG index)
 
static void WINAPI DataCache_OnRename (IAdviseSink *iface, IMoniker *mk)
 
static void WINAPI DataCache_OnSave (IAdviseSink *iface)
 
static void WINAPI DataCache_OnClose (IAdviseSink *iface)
 
static DataCacheDataCache_Construct (REFCLSID clsid, LPUNKNOWN pUnkOuter)
 
HRESULT WINAPI CreateDataCache (LPUNKNOWN pUnkOuter, REFCLSID rclsid, REFIID riid, LPVOID *ppvObj)
 

Variables

static const WCHAR CONTENTS [] = {'C','O','N','T','E','N','T','S',0}
 
static const IUnknownVtbl DataCache_NDIUnknown_VTable
 
static const IDataObjectVtbl DataCache_IDataObject_VTable
 
static const IPersistStorageVtbl DataCache_IPersistStorage_VTable
 
static const IViewObject2Vtbl DataCache_IViewObject2_VTable
 
static const IOleCache2Vtbl DataCache_IOleCache2_VTable
 
static const IOleCacheControlVtbl DataCache_IOleCacheControl_VTable
 
static const IAdviseSinkVtbl DataCache_IAdviseSink_VTable
 

Macro Definition Documentation

◆ COBJMACROS

#define COBJMACROS

Definition at line 50 of file datacache.c.

◆ NONAMELESSUNION

#define NONAMELESSUNION

Definition at line 51 of file datacache.c.

◆ STREAM_NUMBER_CONTENTS

#define STREAM_NUMBER_CONTENTS   -1 /* CONTENTS stream */

Definition at line 93 of file datacache.c.

◆ STREAM_NUMBER_NOT_SET

#define STREAM_NUMBER_NOT_SET   -2

Definition at line 92 of file datacache.c.

Typedef Documentation

◆ DataCache

Definition at line 172 of file datacache.c.

◆ DataCacheEntry

◆ PresentationDataHeader

Function Documentation

◆ add_cache_entry()

static HRESULT add_cache_entry ( DataCache This,
const FORMATETC *  fmt,
DWORD  advf,
int  stream_number 
)
static

Definition at line 1747 of file datacache.c.

1748 {
1750  HRESULT hr = S_OK;
1751 
1752  TRACE( "loading entry with formatetc: %s\n", debugstr_formatetc( fmt ) );
1753 
1755  if (!cache_entry)
1757  if (SUCCEEDED( hr ))
1758  {
1760  cache_entry->load_stream_num = stream_number;
1761  cache_entry->save_stream_num = stream_number;
1762  cache_entry->dirty = FALSE;
1763  }
1764  return hr;
1765 }
HRESULT hr
Definition: shlfolder.c:183
Definition: svc_auth_des.c:77
static DataCacheEntry * DataCache_GetEntryForFormatEtc(DataCache *This, const FORMATETC *formatetc)
Definition: datacache.c:291
#define FALSE
Definition: types.h:117
const char * debugstr_formatetc(const FORMATETC *formatetc)
Definition: datacache.c:216
if SUCCEEDED(hr)
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:79
#define S_OK
Definition: intsafe.h:51
static HRESULT DataCache_CreateEntry(DataCache *This, const FORMATETC *formatetc, DWORD advf, BOOL automatic, DataCacheEntry **cache_entry)
Definition: datacache.c:381
static HRESULT DataCacheEntry_DiscardData(DataCacheEntry *cache_entry)
Definition: datacache.c:1286
Definition: dsound.c:943

Referenced by parse_pres_streams().

◆ bitmap_info_size()

static int bitmap_info_size ( const BITMAPINFO info,
WORD  coloruse 
)
static

Definition at line 228 of file datacache.c.

229 {
230  unsigned int colors, size, masks = 0;
231 
232  if (info->bmiHeader.biSize == sizeof(BITMAPCOREHEADER))
233  {
234  const BITMAPCOREHEADER *core = (const BITMAPCOREHEADER *)info;
235  colors = (core->bcBitCount <= 8) ? 1 << core->bcBitCount : 0;
236  return sizeof(BITMAPCOREHEADER) + colors *
237  ((coloruse == DIB_RGB_COLORS) ? sizeof(RGBTRIPLE) : sizeof(WORD));
238  }
239  else /* assume BITMAPINFOHEADER */
240  {
241  colors = info->bmiHeader.biClrUsed;
242  if (colors > 256) /* buffer overflow otherwise */
243  colors = 256;
244  if (!colors && (info->bmiHeader.biBitCount <= 8))
245  colors = 1 << info->bmiHeader.biBitCount;
246  if (info->bmiHeader.biCompression == BI_BITFIELDS) masks = 3;
247  size = max( info->bmiHeader.biSize, sizeof(BITMAPINFOHEADER) + masks * sizeof(DWORD) );
248  return size + colors * ((coloruse == DIB_RGB_COLORS) ? sizeof(RGBQUAD) : sizeof(WORD));
249  }
250 }
#define max(a, b)
Definition: svc.c:63
ActualNumberDriverObjects * sizeof(PDRIVER_OBJECT)) PDRIVER_OBJECT *DriverObjectList
#define BI_BITFIELDS
Definition: mmreg.h:507
GLsizeiptr size
Definition: glext.h:5919
ULONG RGBQUAD
Definition: precomp.h:50
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned long DWORD
Definition: ntddk_ex.h:95
#define DIB_RGB_COLORS
Definition: wingdi.h:366
static const BYTE masks[8]
Definition: dib.c:2760

Referenced by DataCache_Draw(), load_dib(), PlayMetaFileRecord(), save_dib(), synthesize_bitmap(), and synthesize_dib().

◆ check_valid_formatetc()

static HRESULT check_valid_formatetc ( const FORMATETC *  fmt)
static

Definition at line 340 of file datacache.c.

341 {
342  /* DVASPECT_ICON must be CF_METAFILEPICT */
343  if (fmt->dwAspect == DVASPECT_ICON && fmt->cfFormat != CF_METAFILEPICT)
344  return DV_E_FORMATETC;
345 
346  if (!fmt->cfFormat ||
347  (fmt->cfFormat == CF_METAFILEPICT && fmt->tymed == TYMED_MFPICT) ||
348  (fmt->cfFormat == CF_BITMAP && fmt->tymed == TYMED_GDI) ||
349  (fmt->cfFormat == CF_DIB && fmt->tymed == TYMED_HGLOBAL) ||
350  (fmt->cfFormat == CF_ENHMETAFILE && fmt->tymed == TYMED_ENHMF))
351  return S_OK;
352  else if (fmt->tymed == TYMED_HGLOBAL)
354  else
355  {
356  WARN("invalid clipformat/tymed combination: %d/%d\n", fmt->cfFormat, fmt->tymed);
357  return DV_E_TYMED;
358  }
359 }
#define CF_ENHMETAFILE
Definition: constants.h:409
#define WARN(fmt,...)
Definition: debug.h:112
#define CF_METAFILEPICT
Definition: constants.h:398
#define CF_BITMAP
Definition: constants.h:397
#define DV_E_FORMATETC
Definition: winerror.h:2633
#define DV_E_TYMED
Definition: winerror.h:2638
#define S_OK
Definition: intsafe.h:51
#define CACHE_S_FORMATETC_NOTSUPPORTED
Definition: winerror.h:2706
Definition: dsound.c:943
#define CF_DIB
Definition: constants.h:403

Referenced by DataCache_CreateEntry().

◆ copy_stg_medium()

static HRESULT copy_stg_medium ( CLIPFORMAT  cf,
STGMEDIUM *  dest_stgm,
const STGMEDIUM *  src_stgm 
)
static

Definition at line 1139 of file datacache.c.

1141 {
1142  if (src_stgm->tymed == TYMED_MFPICT)
1143  {
1144  const METAFILEPICT *src_mfpict = GlobalLock(src_stgm->u.hMetaFilePict);
1145  METAFILEPICT *dest_mfpict;
1146 
1147  if (!src_mfpict)
1148  return DV_E_STGMEDIUM;
1149  dest_stgm->u.hMetaFilePict = GlobalAlloc(GMEM_MOVEABLE, sizeof(METAFILEPICT));
1150  dest_mfpict = GlobalLock(dest_stgm->u.hMetaFilePict);
1151  if (!dest_mfpict)
1152  {
1153  GlobalUnlock(src_stgm->u.hMetaFilePict);
1154  return E_OUTOFMEMORY;
1155  }
1156  *dest_mfpict = *src_mfpict;
1157  dest_mfpict->hMF = CopyMetaFileW(src_mfpict->hMF, NULL);
1158  GlobalUnlock(src_stgm->u.hMetaFilePict);
1159  GlobalUnlock(dest_stgm->u.hMetaFilePict);
1160  }
1161  else if (src_stgm->tymed != TYMED_NULL)
1162  {
1163  dest_stgm->u.hGlobal = OleDuplicateData(src_stgm->u.hGlobal, cf,
1164  GMEM_MOVEABLE);
1165  if (!dest_stgm->u.hGlobal)
1166  return E_OUTOFMEMORY;
1167  }
1168  dest_stgm->tymed = src_stgm->tymed;
1169  dest_stgm->pUnkForRelease = src_stgm->pUnkForRelease;
1170  if (dest_stgm->pUnkForRelease)
1171  IUnknown_AddRef(dest_stgm->pUnkForRelease);
1172  return S_OK;
1173 }
HMETAFILE hMF
Definition: wingdi.h:2607
HGLOBAL NTAPI GlobalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:368
#define DV_E_STGMEDIUM
Definition: winerror.h:2635
HANDLE WINAPI OleDuplicateData(HANDLE hSrc, CLIPFORMAT cfFormat, UINT uiFlags)
Definition: ole2impl.c:425
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
#define S_OK
Definition: intsafe.h:51
HMETAFILE WINAPI CopyMetaFileW(_In_ HMETAFILE hmfSrc, _In_opt_ LPCWSTR pszFile)
#define NULL
Definition: types.h:112
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
#define GMEM_MOVEABLE
Definition: winbase.h:291

Referenced by DataCacheEntry_GetData(), and DataCacheEntry_SetData().

◆ create_automatic_entry()

static HRESULT create_automatic_entry ( DataCache cache,
const CLSID clsid 
)
static

Definition at line 1312 of file datacache.c.

1313 {
1314  static const struct data
1315  {
1316  const CLSID *clsid;
1317  FORMATETC fmt;
1318  } data[] =
1319  {
1320  { &CLSID_Picture_Dib, { CF_DIB, 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL } },
1321  { &CLSID_Picture_Metafile, { CF_METAFILEPICT, 0, DVASPECT_CONTENT, -1, TYMED_MFPICT } },
1322  { &CLSID_Picture_EnhMetafile, { CF_ENHMETAFILE, 0, DVASPECT_CONTENT, -1, TYMED_ENHMF } },
1323  { NULL }
1324  };
1325  const struct data *ptr = data;
1326  struct list *head;
1328 
1329  if (IsEqualCLSID( &cache->clsid, clsid )) return S_OK;
1330 
1331  /* move and reassign any pre-existing automatic entry */
1332  if ((head = list_head( &cache->cache_list )))
1333  {
1335  if (entry->id == 1)
1336  {
1337  list_remove( &entry->entry );
1338  entry->id = cache->last_cache_id++;
1339  list_add_tail( &cache->cache_list, &entry->entry );
1340  }
1341  }
1342 
1343  while (ptr->clsid)
1344  {
1345  if (IsEqualCLSID( clsid, ptr->clsid ))
1346  {
1347  cache->clsid_static = TRUE;
1348  return DataCache_CreateEntry( cache, &ptr->fmt, 0, TRUE, NULL );
1349  }
1350  ptr++;
1351  }
1352  cache->clsid_static = FALSE;
1353  return S_OK;
1354 }
Definition: cache.c:48
#define CF_ENHMETAFILE
Definition: constants.h:409
struct outqueuenode * head
Definition: adnsresfilter.c:66
#define TRUE
Definition: types.h:120
const char * fmt
Definition: wsprintf.c:30
#define CF_METAFILEPICT
Definition: constants.h:398
const CLSID CLSID_Picture_Dib
__WINE_SERVER_LIST_INLINE struct list * list_head(const struct list *list)
Definition: list.h:131
__WINE_SERVER_LIST_INLINE void list_add_tail(struct list *list, struct list *elem)
Definition: list.h:102
#define FALSE
Definition: types.h:117
static PVOID ptr
Definition: dispmode.c:27
__WINE_SERVER_LIST_INLINE void list_remove(struct list *elem)
Definition: list.h:108
const CLSID CLSID_Picture_EnhMetafile
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
REFCLSID clsid
Definition: msctf.c:82
uint32_t entry
Definition: isohybrid.c:63
Definition: _list.h:228
#define S_OK
Definition: intsafe.h:51
const CLSID CLSID_Picture_Metafile
static HRESULT DataCache_CreateEntry(DataCache *This, const FORMATETC *formatetc, DWORD advf, BOOL automatic, DataCacheEntry **cache_entry)
Definition: datacache.c:381
#define NULL
Definition: types.h:112
#define LIST_ENTRY(type)
Definition: queue.h:175
#define IsEqualCLSID(rclsid1, rclsid2)
Definition: guiddef.h:96
#define CF_DIB
Definition: constants.h:403

Referenced by DataCache_Construct(), DataCache_InitNew(), and DataCache_Load().

◆ create_stream()

static HRESULT create_stream ( DataCacheEntry cache_entry,
IStorage storage,
BOOL  contents,
IStream **  stream 
)
static

Definition at line 1082 of file datacache.c.

1084 {
1085  WCHAR pres[] = {2,'O','l','e','P','r','e','s',
1086  '0' + (cache_entry->save_stream_num / 100) % 10,
1087  '0' + (cache_entry->save_stream_num / 10) % 10,
1088  '0' + cache_entry->save_stream_num % 10, 0};
1089  const WCHAR *name;
1090 
1091  if (contents)
1092  name = CONTENTS;
1093  else
1094  name = pres;
1095 
1096  return IStorage_CreateStream(storage, name,
1098  0, 0, stream);
1099 }
#define STGM_SHARE_EXCLUSIVE
Definition: objbase.h:922
#define STGM_CREATE
Definition: objbase.h:925
Definition: svc_auth_des.c:77
__wchar_t WCHAR
Definition: xmlstorage.h:180
Definition: parse.h:22
#define STGM_READWRITE
Definition: objbase.h:918
Definition: name.c:38
static const WCHAR CONTENTS[]
Definition: datacache.c:533
GLuint const GLchar * name
Definition: glext.h:6031

Referenced by DataCacheEntry_Save().

◆ CreateDataCache()

HRESULT WINAPI CreateDataCache ( LPUNKNOWN  pUnkOuter,
REFCLSID  rclsid,
REFIID  riid,
LPVOID ppvObj 
)

Definition at line 3035 of file datacache.c.

3040 {
3041  DataCache* newCache = NULL;
3042  HRESULT hr = S_OK;
3043 
3044  TRACE("(%s, %p, %s, %p)\n", debugstr_guid(rclsid), pUnkOuter, debugstr_guid(riid), ppvObj);
3045 
3046  /*
3047  * Sanity check
3048  */
3049  if (ppvObj==0)
3050  return E_POINTER;
3051 
3052  *ppvObj = 0;
3053 
3054  /*
3055  * If this cache is constructed for aggregation, make sure
3056  * the caller is requesting the IUnknown interface.
3057  * This is necessary because it's the only time the non-delegating
3058  * IUnknown pointer can be returned to the outside.
3059  */
3060  if ( pUnkOuter && !IsEqualIID(&IID_IUnknown, riid) )
3061  return E_INVALIDARG;
3062 
3063  /*
3064  * Try to construct a new instance of the class.
3065  */
3066  newCache = DataCache_Construct(rclsid,
3067  pUnkOuter);
3068 
3069  if (newCache == 0)
3070  return E_OUTOFMEMORY;
3071 
3072  hr = IUnknown_QueryInterface(&newCache->IUnknown_inner, riid, ppvObj);
3073  IUnknown_Release(&newCache->IUnknown_inner);
3074 
3075  return hr;
3076 }
HRESULT hr
Definition: shlfolder.c:183
REFIID riid
Definition: precomp.h:44
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_INVALIDARG
Definition: ddrawi.h:101
#define debugstr_guid
Definition: kernel32.h:35
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:79
const GUID IID_IUnknown
static DataCache * DataCache_Construct(REFCLSID clsid, LPUNKNOWN pUnkOuter)
Definition: datacache.c:2967
#define S_OK
Definition: intsafe.h:51
#define NULL
Definition: types.h:112
IUnknown IUnknown_inner
Definition: datacache.c:126
#define E_POINTER
Definition: winerror.h:2365
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95

Referenced by DefaultHandler_Construct(), test_data_cache(), test_data_cache_cache(), test_data_cache_contents(), test_data_cache_dib_contents_stream(), test_data_cache_init(), test_data_cache_initnew(), test_data_cache_save(), test_data_cache_save_data(), and test_data_cache_updatecache().

◆ DataCache_Cache()

static HRESULT WINAPI DataCache_Cache ( IOleCache2 iface,
FORMATETC *  pformatetc,
DWORD  advf,
DWORD pdwConnection 
)
static

Definition at line 2439 of file datacache.c.

2444 {
2447  HRESULT hr;
2448  FORMATETC fmt_cpy;
2449 
2450  TRACE("(%p, 0x%x, %p)\n", pformatetc, advf, pdwConnection);
2451 
2452  if (!pformatetc || !pdwConnection)
2453  return E_INVALIDARG;
2454 
2455  TRACE("pformatetc = %s\n", debugstr_formatetc(pformatetc));
2456 
2457  fmt_cpy = *pformatetc; /* No need for a deep copy */
2458  if (fmt_cpy.cfFormat == CF_BITMAP && fmt_cpy.tymed == TYMED_GDI)
2459  {
2460  fmt_cpy.cfFormat = CF_DIB;
2461  fmt_cpy.tymed = TYMED_HGLOBAL;
2462  }
2463 
2464  /* View caching DVASPECT_ICON gets converted to CF_METAFILEPICT */
2465  if (fmt_cpy.dwAspect == DVASPECT_ICON && fmt_cpy.cfFormat == 0)
2466  {
2467  fmt_cpy.cfFormat = CF_METAFILEPICT;
2468  fmt_cpy.tymed = TYMED_MFPICT;
2469  }
2470 
2471  *pdwConnection = 0;
2472 
2474  if (cache_entry)
2475  {
2476  TRACE("found an existing cache entry\n");
2477  *pdwConnection = cache_entry->id;
2478  return CACHE_S_SAMECACHE;
2479  }
2480 
2481  if (This->clsid_static && fmt_cpy.dwAspect != DVASPECT_ICON) return DV_E_FORMATETC;
2482 
2483  hr = DataCache_CreateEntry(This, &fmt_cpy, advf, FALSE, &cache_entry);
2484 
2485  if (SUCCEEDED(hr))
2486  {
2487  *pdwConnection = cache_entry->id;
2489  }
2490 
2491  return hr;
2492 }
HRESULT hr
Definition: shlfolder.c:183
static DataCache * impl_from_IOleCache2(IOleCache2 *iface)
Definition: datacache.c:201
#define CF_METAFILEPICT
Definition: constants.h:398
Definition: svc_auth_des.c:77
static DataCacheEntry * DataCache_GetEntryForFormatEtc(DataCache *This, const FORMATETC *formatetc)
Definition: datacache.c:291
#define FALSE
Definition: types.h:117
const char * debugstr_formatetc(const FORMATETC *formatetc)
Definition: datacache.c:216
if SUCCEEDED(hr)
#define E_INVALIDARG
Definition: ddrawi.h:101
#define CF_BITMAP
Definition: constants.h:397
#define TRACE(s)
Definition: solgame.cpp:4
#define DV_E_FORMATETC
Definition: winerror.h:2633
LONG HRESULT
Definition: typedefs.h:79
static HRESULT setup_sink(DataCache *This, DataCacheEntry *cache_entry)
Definition: datacache.c:2424
#define CACHE_S_SAMECACHE
Definition: winerror.h:2707
static HRESULT DataCache_CreateEntry(DataCache *This, const FORMATETC *formatetc, DWORD advf, BOOL automatic, DataCacheEntry **cache_entry)
Definition: datacache.c:381
#define CF_DIB
Definition: constants.h:403

◆ DataCache_Construct()

static DataCache* DataCache_Construct ( REFCLSID  clsid,
LPUNKNOWN  pUnkOuter 
)
static

Definition at line 2967 of file datacache.c.

2970 {
2971  DataCache* newObject = 0;
2972 
2973  /*
2974  * Allocate space for the object.
2975  */
2976  newObject = HeapAlloc(GetProcessHeap(), 0, sizeof(DataCache));
2977 
2978  if (newObject==0)
2979  return newObject;
2980 
2981  /*
2982  * Initialize the virtual function table.
2983  */
2984  newObject->IDataObject_iface.lpVtbl = &DataCache_IDataObject_VTable;
2985  newObject->IUnknown_inner.lpVtbl = &DataCache_NDIUnknown_VTable;
2988  newObject->IOleCache2_iface.lpVtbl = &DataCache_IOleCache2_VTable;
2990  newObject->IAdviseSink_iface.lpVtbl = &DataCache_IAdviseSink_VTable;
2991  newObject->outer_unk = pUnkOuter ? pUnkOuter : &newObject->IUnknown_inner;
2992  newObject->ref = 1;
2993 
2994  /*
2995  * Initialize the other members of the structure.
2996  */
2997  newObject->sinkAspects = 0;
2998  newObject->sinkAdviseFlag = 0;
2999  newObject->sinkInterface = 0;
3000  newObject->clsid = CLSID_NULL;
3001  newObject->clsid_static = FALSE;
3002  newObject->presentationStorage = NULL;
3003  list_init(&newObject->cache_list);
3004  newObject->last_cache_id = 2;
3005  newObject->dirty = FALSE;
3006  newObject->running_object = NULL;
3007 
3008  create_automatic_entry( newObject, clsid );
3009  newObject->clsid = *clsid;
3010 
3011  return newObject;
3012 }
CLSID clsid
Definition: datacache.c:156
BOOL dirty
Definition: datacache.c:167
IUnknown * outer_unk
Definition: datacache.c:145
static const IOleCacheControlVtbl DataCache_IOleCacheControl_VTable
Definition: datacache.c:2943
IAdviseSink IAdviseSink_iface
Definition: datacache.c:135
IViewObject2 IViewObject2_iface
Definition: datacache.c:129
IPersistStorage IPersistStorage_iface
Definition: datacache.c:128
#define FALSE
Definition: types.h:117
static const IDataObjectVtbl DataCache_IDataObject_VTable
Definition: datacache.c:2885
IDataObject IDataObject_iface
Definition: datacache.c:127
DWORD last_cache_id
Definition: datacache.c:165
static const IPersistStorageVtbl DataCache_IPersistStorage_VTable
Definition: datacache.c:2901
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define CLSID_NULL
Definition: guiddef.h:99
struct list cache_list
Definition: datacache.c:163
BOOL clsid_static
Definition: datacache.c:158
REFCLSID clsid
Definition: msctf.c:82
DWORD sinkAdviseFlag
Definition: datacache.c:153
static const IUnknownVtbl DataCache_NDIUnknown_VTable
Definition: datacache.c:2878
DWORD sinkAspects
Definition: datacache.c:152
LONG ref
Definition: datacache.c:140
static const IViewObject2Vtbl DataCache_IViewObject2_VTable
Definition: datacache.c:2915
#define NULL
Definition: types.h:112
IUnknown IUnknown_inner
Definition: datacache.c:126
__WINE_SERVER_LIST_INLINE void list_init(struct list *list)
Definition: list.h:149
IDataObject * running_object
Definition: datacache.c:169
static HRESULT create_automatic_entry(DataCache *cache, const CLSID *clsid)
Definition: datacache.c:1312
IStorage * presentationStorage
Definition: datacache.c:160
IOleCacheControl IOleCacheControl_iface
Definition: datacache.c:131
static const IOleCache2Vtbl DataCache_IOleCache2_VTable
Definition: datacache.c:2929
static const IAdviseSinkVtbl DataCache_IAdviseSink_VTable
Definition: datacache.c:2952
IOleCache2 IOleCache2_iface
Definition: datacache.c:130
IAdviseSink * sinkInterface
Definition: datacache.c:154

Referenced by CreateDataCache().

◆ DataCache_CreateEntry()

static HRESULT DataCache_CreateEntry ( DataCache This,
const FORMATETC *  formatetc,
DWORD  advf,
BOOL  automatic,
DataCacheEntry **  cache_entry 
)
static

Definition at line 381 of file datacache.c.

383 {
384  HRESULT hr;
385  DWORD id = automatic ? 1 : This->last_cache_id;
387 
388  hr = check_valid_formatetc( formatetc );
389  if (FAILED(hr))
390  return hr;
392  TRACE("creating unsupported format %d\n", formatetc->cfFormat);
393 
394  entry = HeapAlloc(GetProcessHeap(), 0, sizeof(*entry));
395  if (!entry)
396  return E_OUTOFMEMORY;
397 
398  if (!init_cache_entry(entry, formatetc, advf, id))
399  goto fail;
400 
401  if (automatic)
402  list_add_head(&This->cache_list, &entry->entry);
403  else
404  {
405  list_add_tail(&This->cache_list, &entry->entry);
406  This->last_cache_id++;
407  }
408 
409  if (cache_entry) *cache_entry = entry;
410  return hr;
411 
412 fail:
414  return E_OUTOFMEMORY;
415 }
HRESULT hr
Definition: shlfolder.c:183
__WINE_SERVER_LIST_INLINE void list_add_head(struct list *list, struct list *elem)
Definition: list.h:96
Definition: svc_auth_des.c:77
__WINE_SERVER_LIST_INLINE void list_add_tail(struct list *list, struct list *elem)
Definition: list.h:102
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
LONG HRESULT
Definition: typedefs.h:79
unsigned long DWORD
Definition: ntddk_ex.h:95
uint32_t entry
Definition: isohybrid.c:63
static HRESULT check_valid_formatetc(const FORMATETC *fmt)
Definition: datacache.c:340
#define CACHE_S_FORMATETC_NOTSUPPORTED
Definition: winerror.h:2706
static BOOL init_cache_entry(DataCacheEntry *entry, const FORMATETC *fmt, DWORD advf, DWORD id)
Definition: datacache.c:361
#define HeapFree(x, y, z)
Definition: compat.h:594

Referenced by add_cache_entry(), create_automatic_entry(), and DataCache_Cache().

◆ DataCache_DAdvise()

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

Definition at line 1598 of file datacache.c.

1604 {
1605  TRACE("()\n");
1606  return OLE_E_ADVISENOTSUPPORTED;
1607 }
#define TRACE(s)
Definition: solgame.cpp:4
#define OLE_E_ADVISENOTSUPPORTED
Definition: winerror.h:2617

◆ DataCache_Destroy()

static void DataCache_Destroy ( DataCache ptrToDestroy)
static

Definition at line 263 of file datacache.c.

265 {
266  DataCacheEntry *cache_entry, *next_cache_entry;
267 
268  TRACE("()\n");
269 
270  if (ptrToDestroy->sinkInterface != NULL)
271  {
272  IAdviseSink_Release(ptrToDestroy->sinkInterface);
273  ptrToDestroy->sinkInterface = NULL;
274  }
275 
276  LIST_FOR_EACH_ENTRY_SAFE(cache_entry, next_cache_entry, &ptrToDestroy->cache_list, DataCacheEntry, entry)
277  DataCacheEntry_Destroy(ptrToDestroy, cache_entry);
278 
279  if (ptrToDestroy->presentationStorage != NULL)
280  {
281  IStorage_Release(ptrToDestroy->presentationStorage);
282  ptrToDestroy->presentationStorage = NULL;
283  }
284 
285  /*
286  * Free the datacache pointer.
287  */
288  HeapFree(GetProcessHeap(), 0, ptrToDestroy);
289 }
Definition: svc_auth_des.c:77
static void DataCacheEntry_Destroy(DataCache *cache, DataCacheEntry *cache_entry)
Definition: datacache.c:252
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:595
struct list cache_list
Definition: datacache.c:163
uint32_t entry
Definition: isohybrid.c:63
#define LIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, list, type, field)
Definition: list.h:204
#define NULL
Definition: types.h:112
IStorage * presentationStorage
Definition: datacache.c:160
#define HeapFree(x, y, z)
Definition: compat.h:594
IAdviseSink * sinkInterface
Definition: datacache.c:154

Referenced by DataCache_NDIUnknown_Release().

◆ DataCache_DiscardCache()

static HRESULT WINAPI DataCache_DiscardCache ( IOleCache2 iface,
DWORD  dwDiscardOptions 
)
static

Definition at line 2702 of file datacache.c.

2705 {
2708  HRESULT hr = S_OK;
2709 
2710  TRACE("(%d)\n", dwDiscardOptions);
2711 
2712  if (dwDiscardOptions == DISCARDCACHE_SAVEIFDIRTY)
2713  hr = DataCache_Save(&This->IPersistStorage_iface, This->presentationStorage, TRUE);
2714 
2716  {
2718  if (FAILED(hr))
2719  break;
2720  }
2721 
2722  return hr;
2723 }
HRESULT hr
Definition: shlfolder.c:183
static DataCache * impl_from_IOleCache2(IOleCache2 *iface)
Definition: datacache.c:201
static HRESULT WINAPI DataCache_Save(IPersistStorage *iface, IStorage *stg, BOOL same_as_load)
Definition: datacache.c:1879
#define TRUE
Definition: types.h:120
Definition: svc_auth_des.c:77
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:79
uint32_t entry
Definition: isohybrid.c:63
#define S_OK
Definition: intsafe.h:51
static HRESULT DataCacheEntry_DiscardData(DataCacheEntry *cache_entry)
Definition: datacache.c:1286

◆ DataCache_Draw()

static HRESULT WINAPI DataCache_Draw ( IViewObject2 iface,
DWORD  dwDrawAspect,
LONG  lindex,
void pvAspect,
DVTARGETDEVICE *  ptd,
HDC  hdcTargetDev,
HDC  hdcDraw,
LPCRECTL  lprcBounds,
LPCRECTL  lprcWBounds,
BOOL(CALLBACK *pfnContinue)(ULONG_PTR dwContinue)  ,
ULONG_PTR  dwContinue 
)
static

Definition at line 2006 of file datacache.c.

2018 {
2020  HRESULT hres;
2022 
2023  TRACE("(%p, %x, %d, %p, %p, %p, %p, %p, %p, %lx)\n",
2024  iface,
2025  dwDrawAspect,
2026  lindex,
2027  pvAspect,
2028  hdcTargetDev,
2029  hdcDraw,
2030  lprcBounds,
2031  lprcWBounds,
2032  pfnContinue,
2033  dwContinue);
2034 
2035  if (lprcBounds==NULL)
2036  return E_INVALIDARG;
2037 
2039  {
2040  /* FIXME: compare ptd too */
2041  if ((cache_entry->fmtetc.dwAspect != dwDrawAspect) ||
2042  (cache_entry->fmtetc.lindex != lindex))
2043  continue;
2044 
2045  /* if the data hasn't been loaded yet, do it now */
2046  if ((cache_entry->stgmedium.tymed == TYMED_NULL) && (cache_entry->load_stream_num != STREAM_NUMBER_NOT_SET))
2047  {
2048  hres = DataCacheEntry_LoadData(cache_entry, This->presentationStorage);
2049  if (FAILED(hres))
2050  continue;
2051  }
2052 
2053  /* no data */
2054  if (cache_entry->stgmedium.tymed == TYMED_NULL)
2055  continue;
2056 
2057  if (pfnContinue && !pfnContinue(dwContinue)) return E_ABORT;
2058 
2059  switch (cache_entry->fmtetc.cfFormat)
2060  {
2061  case CF_METAFILEPICT:
2062  {
2063  /*
2064  * We have to be careful not to modify the state of the
2065  * DC.
2066  */
2067  INT prevMapMode;
2068  SIZE oldWindowExt;
2069  SIZE oldViewportExt;
2070  POINT oldViewportOrg;
2071  METAFILEPICT *mfpict;
2072 
2073  if ((cache_entry->stgmedium.tymed != TYMED_MFPICT) ||
2074  !((mfpict = GlobalLock(cache_entry->stgmedium.u.hMetaFilePict))))
2075  continue;
2076 
2077  prevMapMode = SetMapMode(hdcDraw, mfpict->mm);
2078 
2079  SetWindowExtEx(hdcDraw,
2080  mfpict->xExt,
2081  mfpict->yExt,
2082  &oldWindowExt);
2083 
2084  SetViewportExtEx(hdcDraw,
2085  lprcBounds->right - lprcBounds->left,
2086  lprcBounds->bottom - lprcBounds->top,
2087  &oldViewportExt);
2088 
2089  SetViewportOrgEx(hdcDraw,
2090  lprcBounds->left,
2091  lprcBounds->top,
2092  &oldViewportOrg);
2093 
2094  PlayMetaFile(hdcDraw, mfpict->hMF);
2095 
2096  SetWindowExtEx(hdcDraw,
2097  oldWindowExt.cx,
2098  oldWindowExt.cy,
2099  NULL);
2100 
2101  SetViewportExtEx(hdcDraw,
2102  oldViewportExt.cx,
2103  oldViewportExt.cy,
2104  NULL);
2105 
2106  SetViewportOrgEx(hdcDraw,
2107  oldViewportOrg.x,
2108  oldViewportOrg.y,
2109  NULL);
2110 
2111  SetMapMode(hdcDraw, prevMapMode);
2112 
2113  GlobalUnlock(cache_entry->stgmedium.u.hMetaFilePict);
2114 
2115  return S_OK;
2116  }
2117  case CF_DIB:
2118  {
2119  BITMAPINFO *info;
2120  BYTE *bits;
2121 
2122  if ((cache_entry->stgmedium.tymed != TYMED_HGLOBAL) ||
2123  !((info = GlobalLock( cache_entry->stgmedium.u.hGlobal ))))
2124  continue;
2125 
2127  StretchDIBits( hdcDraw, lprcBounds->left, lprcBounds->top,
2128  lprcBounds->right - lprcBounds->left, lprcBounds->bottom - lprcBounds->top,
2129  0, 0, info->bmiHeader.biWidth, info->bmiHeader.biHeight,
2131 
2132  GlobalUnlock( cache_entry->stgmedium.u.hGlobal );
2133  return S_OK;
2134  }
2135  }
2136  }
2137 
2138  WARN("no data could be found to be drawn\n");
2139 
2140  return OLE_E_BLANK;
2141 }
static DataCache * impl_from_IViewObject2(IViewObject2 *iface)
Definition: datacache.c:196
int WINAPI StretchDIBits(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_ int, _In_ int, _In_ int, _In_ int, _In_opt_ const VOID *, _In_ const BITMAPINFO *, _In_ UINT, _In_ DWORD)
HMETAFILE hMF
Definition: wingdi.h:2607
BOOL WINAPI SetViewportOrgEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPPOINT)
Definition: coord.c:655
BOOL WINAPI SetWindowExtEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPSIZE)
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
#define WARN(fmt,...)
Definition: debug.h:112
long bottom
Definition: polytest.cpp:53
#define CF_METAFILEPICT
Definition: constants.h:398
Definition: svc_auth_des.c:77
GLenum GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * bits
Definition: glext.h:10929
int32_t INT
Definition: typedefs.h:58
long right
Definition: polytest.cpp:53
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
int WINAPI SetMapMode(_In_ HDC, _In_ int)
long top
Definition: polytest.cpp:53
#define E_INVALIDARG
Definition: ddrawi.h:101
LONG cx
Definition: windef.h:334
long left
Definition: polytest.cpp:53
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:79
static int bitmap_info_size(const BITMAPINFO *info, WORD coloruse)
Definition: datacache.c:228
struct _test_info info[]
Definition: SetCursorPos.c:19
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
uint32_t entry
Definition: isohybrid.c:63
#define E_ABORT
Definition: winerror.h:2366
unsigned char BYTE
Definition: xxhash.c:193
#define S_OK
Definition: intsafe.h:51
#define OLE_E_BLANK
Definition: winerror.h:2621
#define NULL
Definition: types.h:112
static HRESULT DataCacheEntry_LoadData(DataCacheEntry *cache_entry, IStorage *stg)
Definition: datacache.c:831
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
#define STREAM_NUMBER_NOT_SET
Definition: datacache.c:92
BOOL WINAPI SetViewportExtEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPSIZE)
Definition: coord.c:465
#define DIB_RGB_COLORS
Definition: wingdi.h:366
LONG cy
Definition: windef.h:335
BOOL WINAPI PlayMetaFile(_In_ HDC, _In_ HMETAFILE)
#define SRCCOPY
Definition: wingdi.h:332
#define CF_DIB
Definition: constants.h:403

◆ DataCache_DUnadvise()

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

Definition at line 1614 of file datacache.c.

1617 {
1618  TRACE("()\n");
1619  return OLE_E_NOCONNECTION;
1620 }
#define OLE_E_NOCONNECTION
Definition: winerror.h:2618
#define TRACE(s)
Definition: solgame.cpp:4

◆ DataCache_EnumCache()

static HRESULT WINAPI DataCache_EnumCache ( IOleCache2 iface,
IEnumSTATDATA **  enum_stat 
)
static

Definition at line 2515 of file datacache.c.

2517 {
2518  DataCache *This = impl_from_IOleCache2( iface );
2520  int i = 0, count = 0;
2521  STATDATA *data;
2522  HRESULT hr;
2523 
2524  TRACE( "(%p, %p)\n", This, enum_stat );
2525 
2527  {
2528  count++;
2529  if (cache_entry->fmtetc.cfFormat == CF_DIB)
2530  count++;
2531  }
2532 
2533  data = CoTaskMemAlloc( count * sizeof(*data) );
2534  if (!data) return E_OUTOFMEMORY;
2535 
2537  {
2538  if (i == count) goto fail;
2539  hr = copy_formatetc( &data[i].formatetc, &cache_entry->fmtetc );
2540  if (FAILED(hr)) goto fail;
2541  data[i].advf = cache_entry->advise_flags;
2542  data[i].pAdvSink = NULL;
2543  data[i].dwConnection = cache_entry->id;
2544  i++;
2545 
2546  if (cache_entry->fmtetc.cfFormat == CF_DIB)
2547  {
2548  if (i == count) goto fail;
2549  hr = copy_formatetc( &data[i].formatetc, &cache_entry->fmtetc );
2550  if (FAILED(hr)) goto fail;
2551  data[i].formatetc.cfFormat = CF_BITMAP;
2552  data[i].formatetc.tymed = TYMED_GDI;
2553  data[i].advf = cache_entry->advise_flags;
2554  data[i].pAdvSink = NULL;
2555  data[i].dwConnection = cache_entry->id;
2556  i++;
2557  }
2558  }
2559 
2560  hr = EnumSTATDATA_Construct( NULL, 0, i, data, FALSE, enum_stat );
2561  if (SUCCEEDED(hr)) return hr;
2562 
2563 fail:
2564  while (i--) CoTaskMemFree( data[i].formatetc.ptd );
2565  CoTaskMemFree( data );
2566  return hr;
2567 }
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:442
HRESULT hr
Definition: shlfolder.c:183
static DataCache * impl_from_IOleCache2(IOleCache2 *iface)
Definition: datacache.c:201
GLuint GLuint GLsizei count
Definition: gl.h:1545
Definition: svc_auth_des.c:77
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define FALSE
Definition: types.h:117
if SUCCEEDED(hr)
#define CF_BITMAP
Definition: constants.h:397
static HRESULT copy_formatetc(FORMATETC *dst, const FORMATETC *src)
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:79
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
uint32_t entry
Definition: isohybrid.c:63
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
#define NULL
Definition: types.h:112
HRESULT EnumSTATDATA_Construct(IUnknown *holder, ULONG index, DWORD array_len, STATDATA *data, BOOL copy, IEnumSTATDATA **ppenum) DECLSPEC_HIDDEN
Definition: oleobj.c:197
LPVOID WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: ifs.c:426
#define CF_DIB
Definition: constants.h:403

◆ DataCache_EnumDAdvise()

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

Definition at line 1627 of file datacache.c.

1630 {
1631  TRACE("()\n");
1632  return OLE_E_ADVISENOTSUPPORTED;
1633 }
#define TRACE(s)
Definition: solgame.cpp:4
#define OLE_E_ADVISENOTSUPPORTED
Definition: winerror.h:2617

◆ DataCache_EnumFormatEtc()

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

Definition at line 1584 of file datacache.c.

1588 {
1589  TRACE("()\n");
1590  return E_NOTIMPL;
1591 }
#define TRACE(s)
Definition: solgame.cpp:4
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ DataCache_FireOnViewChange()

static void DataCache_FireOnViewChange ( DataCache this,
DWORD  aspect,
LONG  lindex 
)
static

Definition at line 425 of file datacache.c.

429 {
430  TRACE("(%p, %x, %d)\n", this, aspect, lindex);
431 
432  /*
433  * The sink supplies a filter when it registers
434  * we make sure we only send the notifications when that
435  * filter matches.
436  */
437  if ((this->sinkAspects & aspect) != 0)
438  {
439  if (this->sinkInterface != NULL)
440  {
441  IAdviseSink_OnViewChange(this->sinkInterface,
442  aspect,
443  lindex);
444 
445  /*
446  * Some sinks want to be unregistered automatically when
447  * the first notification goes out.
448  */
449  if ( (this->sinkAdviseFlag & ADVF_ONLYONCE) != 0)
450  {
451  IAdviseSink_Release(this->sinkInterface);
452 
453  this->sinkInterface = NULL;
454  this->sinkAspects = 0;
455  this->sinkAdviseFlag = 0;
456  }
457  }
458  }
459 }
#define TRACE(s)
Definition: solgame.cpp:4
#define NULL
Definition: types.h:112

Referenced by DataCache_IOleCache2_SetData(), and DataCache_SetAdvise().

◆ DataCache_Freeze()

static HRESULT WINAPI DataCache_Freeze ( IViewObject2 iface,
DWORD  dwDrawAspect,
LONG  lindex,
void pvAspect,
DWORD pdwFreeze 
)
static

Definition at line 2156 of file datacache.c.

2162 {
2163  FIXME("stub\n");
2164  return E_NOTIMPL;
2165 }
#define FIXME(fmt,...)
Definition: debug.h:111
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ DataCache_GetAdvise()

static HRESULT WINAPI DataCache_GetAdvise ( IViewObject2 iface,
DWORD pAspects,
DWORD pAdvf,
IAdviseSink **  ppAdvSink 
)
static

Definition at line 2232 of file datacache.c.

2237 {
2238  DataCache *this = impl_from_IViewObject2(iface);
2239 
2240  TRACE("(%p, %p, %p, %p)\n", iface, pAspects, pAdvf, ppAdvSink);
2241 
2242  /*
2243  * Just copy all the requested values.
2244  */
2245  if (pAspects!=NULL)
2246  *pAspects = this->sinkAspects;
2247 
2248  if (pAdvf!=NULL)
2249  *pAdvf = this->sinkAdviseFlag;
2250 
2251  if (ppAdvSink!=NULL)
2252  {
2253  if (this->sinkInterface != NULL)
2254  IAdviseSink_QueryInterface(this->sinkInterface,
2255  &IID_IAdviseSink,
2256  (void**)ppAdvSink);
2257  else *ppAdvSink = NULL;
2258  }
2259 
2260  return S_OK;
2261 }
static DataCache * impl_from_IViewObject2(IViewObject2 *iface)
Definition: datacache.c:196
const GUID IID_IAdviseSink
#define TRACE(s)
Definition: solgame.cpp:4
#define S_OK
Definition: intsafe.h:51
#define NULL
Definition: types.h:112

◆ DataCache_GetCanonicalFormatEtc()

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

Definition at line 1542 of file datacache.c.

1546 {
1547  TRACE("()\n");
1548  return E_NOTIMPL;
1549 }
#define TRACE(s)
Definition: solgame.cpp:4
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ DataCache_GetClassID()

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

Definition at line 1679 of file datacache.c.

1680 {
1682 
1683  TRACE( "(%p, %p) returning %s\n", iface, clsid, debugstr_guid(&This->clsid) );
1684  *clsid = This->clsid;
1685 
1686  return S_OK;
1687 }
#define debugstr_guid
Definition: kernel32.h:35
#define TRACE(s)
Definition: solgame.cpp:4
REFCLSID clsid
Definition: msctf.c:82
#define S_OK
Definition: intsafe.h:51
static DataCache * impl_from_IPersistStorage(IPersistStorage *iface)
Definition: datacache.c:191

◆ DataCache_GetColorSet()

static HRESULT WINAPI DataCache_GetColorSet ( IViewObject2 iface,
DWORD  dwDrawAspect,
LONG  lindex,
void pvAspect,
DVTARGETDEVICE *  ptd,
HDC  hicTargetDevice,
LOGPALETTE **  ppColorSet 
)
static

Definition at line 2143 of file datacache.c.

2151 {
2152  FIXME("stub\n");
2153  return E_NOTIMPL;
2154 }
#define FIXME(fmt,...)
Definition: debug.h:111
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ DataCache_GetData()

static HRESULT WINAPI DataCache_GetData ( IDataObject iface,
LPFORMATETC  pformatetcIn,
STGMEDIUM *  pmedium 
)
static

Definition at line 1498 of file datacache.c.

1502 {
1505 
1506  TRACE("(%p, %s, %p)\n", iface, debugstr_formatetc(pformatetcIn), pmedium);
1507 
1508  memset(pmedium, 0, sizeof(*pmedium));
1509 
1511  if (!cache_entry)
1512  return OLE_E_BLANK;
1513 
1514  return DataCacheEntry_GetData(cache_entry, This->presentationStorage, pformatetcIn, pmedium);
1515 }
static DataCache * impl_from_IDataObject(IDataObject *iface)
Definition: datacache.c:181
Definition: svc_auth_des.c:77
static DataCacheEntry * DataCache_GetEntryForFormatEtc(DataCache *This, const FORMATETC *formatetc)
Definition: datacache.c:291
const char * debugstr_formatetc(const FORMATETC *formatetc)
Definition: datacache.c:216
#define TRACE(s)
Definition: solgame.cpp:4
static HRESULT DataCacheEntry_GetData(DataCacheEntry *cache_entry, IStorage *stg, FORMATETC *fmt, STGMEDIUM *stgmedium)
Definition: datacache.c:1269
#define OLE_E_BLANK
Definition: winerror.h:2621
#define memset(x, y, z)
Definition: compat.h:39

◆ DataCache_GetDataHere()

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

Definition at line 1517 of file datacache.c.

1521 {
1522  FIXME("stub\n");
1523  return E_NOTIMPL;
1524 }
#define FIXME(fmt,...)
Definition: debug.h:111
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ DataCache_GetEntryForFormatEtc()

static DataCacheEntry* DataCache_GetEntryForFormatEtc ( DataCache This,
const FORMATETC *  formatetc 
)
static

Definition at line 291 of file datacache.c.

292 {
294  FORMATETC fmt = *formatetc;
295 
296  if (fmt.cfFormat == CF_BITMAP)
297  {
298  fmt.cfFormat = CF_DIB;
299  fmt.tymed = TYMED_HGLOBAL;
300  }
301 
303  {
304  /* FIXME: also compare DVTARGETDEVICEs */
305  if ((fmt.cfFormat == cache_entry->fmtetc.cfFormat) &&
306  (fmt.dwAspect == cache_entry->fmtetc.dwAspect) &&
307  (fmt.lindex == cache_entry->fmtetc.lindex) &&
308  ((fmt.tymed == cache_entry->fmtetc.tymed) || !cache_entry->fmtetc.cfFormat)) /* tymed is ignored for view caching */
309  return cache_entry;
310  }
311  return NULL;
312 }
Definition: svc_auth_des.c:77
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
#define CF_BITMAP
Definition: constants.h:397
uint32_t entry
Definition: isohybrid.c:63
#define NULL
Definition: types.h:112
Definition: dsound.c:943
#define CF_DIB
Definition: constants.h:403

Referenced by add_cache_entry(), DataCache_Cache(), DataCache_GetData(), DataCache_IOleCache2_SetData(), and DataCache_QueryGetData().

◆ DataCache_GetExtent()

static HRESULT WINAPI DataCache_GetExtent ( IViewObject2 iface,
DWORD  dwDrawAspect,
LONG  lindex,
DVTARGETDEVICE *  ptd,
LPSIZEL  lpsizel 
)
static

Definition at line 2268 of file datacache.c.

2274 {
2276  HRESULT hres = E_FAIL;
2278 
2279  TRACE("(%p, %x, %d, %p, %p)\n",
2280  iface, dwDrawAspect, lindex, ptd, lpsizel);
2281 
2282  if (lpsizel==NULL)
2283  return E_POINTER;
2284 
2285  lpsizel->cx = 0;
2286  lpsizel->cy = 0;
2287 
2288  if (lindex!=-1)
2289  FIXME("Unimplemented flag lindex = %d\n", lindex);
2290 
2291  /*
2292  * Right now, we support only the callback from
2293  * the default handler.
2294  */
2295  if (ptd!=NULL)
2296  FIXME("Unimplemented ptd = %p\n", ptd);
2297 
2299  {
2300  /* FIXME: compare ptd too */
2301  if ((cache_entry->fmtetc.dwAspect != dwDrawAspect) ||
2302  (cache_entry->fmtetc.lindex != lindex))
2303  continue;
2304 
2305  /* if the data hasn't been loaded yet, do it now */
2306  if ((cache_entry->stgmedium.tymed == TYMED_NULL) && (cache_entry->load_stream_num != STREAM_NUMBER_NOT_SET))
2307  {
2308  hres = DataCacheEntry_LoadData(cache_entry, This->presentationStorage);
2309  if (FAILED(hres))
2310  continue;
2311  }
2312 
2313  /* no data */
2314  if (cache_entry->stgmedium.tymed == TYMED_NULL)
2315  continue;
2316 
2317 
2318  switch (cache_entry->fmtetc.cfFormat)
2319  {
2320  case CF_METAFILEPICT:
2321  {
2322  METAFILEPICT *mfpict;
2323 
2324  if ((cache_entry->stgmedium.tymed != TYMED_MFPICT) ||
2325  !((mfpict = GlobalLock(cache_entry->stgmedium.u.hMetaFilePict))))
2326  continue;
2327 
2328  lpsizel->cx = mfpict->xExt;
2329  lpsizel->cy = mfpict->yExt;
2330 
2331  GlobalUnlock(cache_entry->stgmedium.u.hMetaFilePict);
2332 
2333  return S_OK;
2334  }
2335  case CF_DIB:
2336  {
2338  LONG x_pels_m, y_pels_m;
2339 
2340 
2341  if ((cache_entry->stgmedium.tymed != TYMED_HGLOBAL) ||
2342  !((info = GlobalLock( cache_entry->stgmedium.u.hGlobal ))))
2343  continue;
2344 
2345  x_pels_m = info->biXPelsPerMeter;
2346  y_pels_m = info->biYPelsPerMeter;
2347 
2348  /* Size in units of 0.01mm (ie. MM_HIMETRIC) */
2349  if (x_pels_m != 0 && y_pels_m != 0)
2350  {
2351  lpsizel->cx = info->biWidth * 100000 / x_pels_m;
2352  lpsizel->cy = info->biHeight * 100000 / y_pels_m;
2353  }
2354  else
2355  {
2356  HDC hdc = GetDC( 0 );
2357  lpsizel->cx = info->biWidth * 2540 / GetDeviceCaps( hdc, LOGPIXELSX );
2358  lpsizel->cy = info->biHeight * 2540 / GetDeviceCaps( hdc, LOGPIXELSY );
2359 
2360  ReleaseDC( 0, hdc );
2361  }
2362 
2363  GlobalUnlock( cache_entry->stgmedium.u.hGlobal );
2364 
2365  return S_OK;
2366  }
2367  }
2368  }
2369 
2370  WARN("no data could be found to get the extents from\n");
2371 
2372  /*
2373  * This method returns OLE_E_BLANK when it fails.
2374  */
2375  return OLE_E_BLANK;
2376 }
static DataCache * impl_from_IViewObject2(IViewObject2 *iface)
Definition: datacache.c:196
#define LOGPIXELSX
Definition: wingdi.h:717
HDC WINAPI GetDC(_In_opt_ HWND)
#define WARN(fmt,...)
Definition: debug.h:112
static HDC
Definition: imagelist.c:92
#define CF_METAFILEPICT
Definition: constants.h:398
Definition: svc_auth_des.c:77
#define E_FAIL
Definition: ddrawi.h:102
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
long LONG
Definition: pedump.c:60
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
#define FIXME(fmt,...)
Definition: debug.h:111
LONG cx
Definition: windef.h:334
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:79
struct _test_info info[]
Definition: SetCursorPos.c:19
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
HDC hdc
Definition: main.c:9
int WINAPI GetDeviceCaps(_In_opt_ HDC, _In_ int)
uint32_t entry
Definition: isohybrid.c:63
#define S_OK
Definition: intsafe.h:51
#define OLE_E_BLANK
Definition: winerror.h:2621
#define NULL
Definition: types.h:112
static HRESULT DataCacheEntry_LoadData(DataCacheEntry *cache_entry, IStorage *stg)
Definition: datacache.c:831
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
#define STREAM_NUMBER_NOT_SET
Definition: datacache.c:92
#define LOGPIXELSY
Definition: wingdi.h:718
#define E_POINTER
Definition: winerror.h:2365
LONG cy
Definition: windef.h:335
#define CF_DIB
Definition: constants.h:403

◆ DataCache_HandsOffStorage()

static HRESULT WINAPI DataCache_HandsOffStorage ( IPersistStorage iface)
static

Definition at line 1944 of file datacache.c.

1946 {
1947  DataCache *this = impl_from_IPersistStorage(iface);
1948 
1949  TRACE("(%p)\n", iface);
1950 
1951  if (this->presentationStorage != NULL)
1952  {
1953  IStorage_Release(this->presentationStorage);
1954  this->presentationStorage = NULL;
1955  }
1956 
1957  return S_OK;
1958 }
#define TRACE(s)
Definition: solgame.cpp:4
#define S_OK
Definition: intsafe.h:51
static DataCache * impl_from_IPersistStorage(IPersistStorage *iface)
Definition: datacache.c:191
#define NULL
Definition: types.h:112

◆ DataCache_IAdviseSink_AddRef()

static ULONG WINAPI DataCache_IAdviseSink_AddRef ( IAdviseSink iface)
static

Definition at line 2838 of file datacache.c.

2839 {
2840  return 2;
2841 }

◆ DataCache_IAdviseSink_QueryInterface()

static HRESULT WINAPI DataCache_IAdviseSink_QueryInterface ( IAdviseSink iface,
REFIID  iid,
void **  obj 
)
static

Definition at line 2821 of file datacache.c.

2822 {
2823  *obj = NULL;
2824  if (IsEqualIID(&IID_IUnknown, iid) ||
2825  IsEqualIID(&IID_IAdviseSink, iid))
2826  {
2827  *obj = iface;
2828  }
2829 
2830  if(*obj)
2831  {
2832  IAdviseSink_AddRef(iface);
2833  return S_OK;
2834  }
2835  return E_NOINTERFACE;
2836 }
#define E_NOINTERFACE
Definition: winerror.h:2364
const GUID IID_IAdviseSink
const GUID IID_IUnknown
#define S_OK
Definition: intsafe.h:51
#define NULL
Definition: types.h:112
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95

◆ DataCache_IAdviseSink_Release()

static ULONG WINAPI DataCache_IAdviseSink_Release ( IAdviseSink iface)
static

Definition at line 2843 of file datacache.c.

2844 {
2845  return 1;
2846 }

◆ DataCache_IDataObject_AddRef()

static ULONG WINAPI DataCache_IDataObject_AddRef ( IDataObject iface)
static

Definition at line 1474 of file datacache.c.

1476 {
1477  DataCache *this = impl_from_IDataObject(iface);
1478 
1479  return IUnknown_AddRef(this->outer_unk);
1480 }
static DataCache * impl_from_IDataObject(IDataObject *iface)
Definition: datacache.c:181

◆ DataCache_IDataObject_QueryInterface()

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

Definition at line 1461 of file datacache.c.

1465 {
1466  DataCache *this = impl_from_IDataObject(iface);
1467 
1468  return IUnknown_QueryInterface(this->outer_unk, riid, ppvObject);
1469 }
static DataCache * impl_from_IDataObject(IDataObject *iface)
Definition: datacache.c:181
REFIID riid
Definition: precomp.h:44
REFIID LPVOID * ppvObject
Definition: precomp.h:44

◆ DataCache_IDataObject_Release()

static ULONG WINAPI DataCache_IDataObject_Release ( IDataObject iface)
static

Definition at line 1485 of file datacache.c.

1487 {
1488  DataCache *this = impl_from_IDataObject(iface);
1489 
1490  return IUnknown_Release(this->outer_unk);
1491 }
static DataCache * impl_from_IDataObject(IDataObject *iface)
Definition: datacache.c:181

◆ DataCache_IDataObject_SetData()

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

Definition at line 1556 of file datacache.c.

1561 {
1562  IOleCache2* oleCache = NULL;
1563  HRESULT hres;
1564 
1565  TRACE("(%p, %p, %p, %d)\n", iface, pformatetc, pmedium, fRelease);
1566 
1567  hres = IDataObject_QueryInterface(iface, &IID_IOleCache2, (void**)&oleCache);
1568 
1569  if (FAILED(hres))
1570  return E_UNEXPECTED;
1571 
1572  hres = IOleCache2_SetData(oleCache, pformatetc, pmedium, fRelease);
1573 
1574  IOleCache2_Release(oleCache);
1575 
1576  return hres;
1577 }
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:79
const GUID IID_IOleCache2
#define NULL
Definition: types.h:112
#define E_UNEXPECTED
Definition: winerror.h:2456

◆ DataCache_InitCache()

static HRESULT WINAPI DataCache_InitCache ( IOleCache2 iface,
IDataObject data 
)
static

Definition at line 2569 of file datacache.c.

2570 {
2571  TRACE( "(%p %p)\n", iface, data );
2572  return IOleCache2_UpdateCache( iface, data, UPDFCACHE_ALLBUTNODATACACHE, NULL );
2573 }
#define TRACE(s)
Definition: solgame.cpp:4
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define NULL
Definition: types.h:112

◆ DataCache_InitNew()

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

Definition at line 1716 of file datacache.c.

1719 {
1721  CLSID clsid;
1722  HRESULT hr;
1723 
1724  TRACE("(%p, %p)\n", iface, pStg);
1725 
1726  if (This->presentationStorage != NULL)
1727  return CO_E_ALREADYINITIALIZED;
1728 
1729  This->presentationStorage = pStg;
1730 
1731  IStorage_AddRef(This->presentationStorage);
1732  This->dirty = TRUE;
1733  ReadClassStg( pStg, &clsid );
1735  if (FAILED(hr))
1736  {
1737  IStorage_Release( pStg );
1738  This->presentationStorage = NULL;
1739  return hr;
1740  }
1741  This->clsid = clsid;
1742 
1743  return S_OK;
1744 }
HRESULT hr
Definition: shlfolder.c:183
#define TRUE
Definition: types.h:120
#define TRACE(s)
Definition: solgame.cpp:4
#define CO_E_ALREADYINITIALIZED
Definition: winerror.h:2804
LONG HRESULT
Definition: typedefs.h:79
REFCLSID clsid
Definition: msctf.c:82
#define S_OK
Definition: intsafe.h:51
static DataCache * impl_from_IPersistStorage(IPersistStorage *iface)
Definition: datacache.c:191
HRESULT WINAPI ReadClassStg(IStorage *pstg, CLSID *pclsid)
Definition: storage32.c:9103
#define NULL
Definition: types.h:112
static HRESULT create_automatic_entry(DataCache *cache, const CLSID *clsid)
Definition: datacache.c:1312

◆ DataCache_IOleCache2_AddRef()

static ULONG WINAPI DataCache_IOleCache2_AddRef ( IOleCache2 iface)
static

Definition at line 2400 of file datacache.c.

2402 {
2403  DataCache *this = impl_from_IOleCache2(iface);
2404 
2405  return IUnknown_AddRef(this->outer_unk);
2406 }
static DataCache * impl_from_IOleCache2(IOleCache2 *iface)
Definition: datacache.c:201

◆ DataCache_IOleCache2_QueryInterface()

static HRESULT WINAPI DataCache_IOleCache2_QueryInterface ( IOleCache2 iface,
REFIID  riid,
void **  ppvObject 
)
static

Definition at line 2387 of file datacache.c.

2391 {
2392  DataCache *this = impl_from_IOleCache2(iface);
2393 
2394  return IUnknown_QueryInterface(this->outer_unk, riid, ppvObject);
2395 }
static DataCache * impl_from_IOleCache2(IOleCache2 *iface)
Definition: datacache.c:201
REFIID riid
Definition: precomp.h:44
REFIID LPVOID * ppvObject
Definition: precomp.h:44

◆ DataCache_IOleCache2_Release()

static ULONG WINAPI DataCache_IOleCache2_Release ( IOleCache2 iface)
static

Definition at line 2411 of file datacache.c.

2413 {
2414  DataCache *this = impl_from_IOleCache2(iface);
2415 
2416  return IUnknown_Release(this->outer_unk);
2417 }
static DataCache * impl_from_IOleCache2(IOleCache2 *iface)
Definition: datacache.c:201

◆ DataCache_IOleCache2_SetData()

static HRESULT WINAPI DataCache_IOleCache2_SetData ( IOleCache2 iface,
FORMATETC *  pformatetc,
STGMEDIUM *  pmedium,
BOOL  fRelease 
)
static

Definition at line 2575 of file datacache.c.

2580 {
2583  HRESULT hr;
2584 
2585  TRACE("(%p, %p, %s)\n", pformatetc, pmedium, fRelease ? "TRUE" : "FALSE");
2586  TRACE("formatetc = %s\n", debugstr_formatetc(pformatetc));
2587 
2589  if (cache_entry)
2590  {
2591  hr = DataCacheEntry_SetData(cache_entry, pformatetc, pmedium, fRelease);
2592 
2593  if (SUCCEEDED(hr))
2594  DataCache_FireOnViewChange(This, cache_entry->fmtetc.dwAspect,
2595  cache_entry->fmtetc.lindex);
2596 
2597  return hr;
2598  }
2599  WARN("cache entry not found\n");
2600 
2601  return OLE_E_BLANK;
2602 }
HRESULT hr
Definition: shlfolder.c:183
static DataCache * impl_from_IOleCache2(IOleCache2 *iface)
Definition: datacache.c:201
#define WARN(fmt,...)
Definition: debug.h:112
Definition: svc_auth_des.c:77
static DataCacheEntry * DataCache_GetEntryForFormatEtc(DataCache *This, const FORMATETC *formatetc)
Definition: datacache.c:291
const char * debugstr_formatetc(const FORMATETC *formatetc)
Definition: datacache.c:216
if SUCCEEDED(hr)
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:79
#define OLE_E_BLANK
Definition: winerror.h:2621
static HRESULT DataCacheEntry_SetData(DataCacheEntry *cache_entry, const FORMATETC *formatetc, STGMEDIUM *stgmedium, BOOL fRelease)
Definition: datacache.c:1224
static void DataCache_FireOnViewChange(DataCache *this, DWORD aspect, LONG lindex)
Definition: datacache.c:425

◆ DataCache_IOleCacheControl_AddRef()

static ULONG WINAPI DataCache_IOleCacheControl_AddRef ( IOleCacheControl iface)
static

Definition at line 2747 of file datacache.c.

2749 {
2750  DataCache *this = impl_from_IOleCacheControl(iface);
2751 
2752  return IUnknown_AddRef(this->outer_unk);
2753 }
static DataCache * impl_from_IOleCacheControl(IOleCacheControl *iface)
Definition: datacache.c:206

◆ DataCache_IOleCacheControl_QueryInterface()

static HRESULT WINAPI DataCache_IOleCacheControl_QueryInterface ( IOleCacheControl iface,
REFIID  riid,
void **  ppvObject 
)
static

Definition at line 2734 of file datacache.c.

2738 {
2739  DataCache *this = impl_from_IOleCacheControl(iface);
2740 
2741  return IUnknown_QueryInterface(this->outer_unk, riid, ppvObject);
2742 }
REFIID riid
Definition: precomp.h:44
static DataCache * impl_from_IOleCacheControl(IOleCacheControl *iface)
Definition: datacache.c:206
REFIID LPVOID * ppvObject
Definition: precomp.h:44

◆ DataCache_IOleCacheControl_Release()

static ULONG WINAPI DataCache_IOleCacheControl_Release ( IOleCacheControl iface)
static

Definition at line 2758 of file datacache.c.

2760 {
2761  DataCache *this = impl_from_IOleCacheControl(iface);
2762 
2763  return IUnknown_Release(this->outer_unk);
2764 }
static DataCache * impl_from_IOleCacheControl(IOleCacheControl *iface)
Definition: datacache.c:206

◆ DataCache_IPersistStorage_AddRef()

static ULONG WINAPI DataCache_IPersistStorage_AddRef ( IPersistStorage iface)
static

Definition at line 1656 of file datacache.c.

1658 {
1659  DataCache *this = impl_from_IPersistStorage(iface);
1660 
1661  return IUnknown_AddRef(this->outer_unk);
1662 }
static DataCache * impl_from_IPersistStorage(IPersistStorage *iface)
Definition: datacache.c:191

◆ DataCache_IPersistStorage_QueryInterface()

static HRESULT WINAPI DataCache_IPersistStorage_QueryInterface ( IPersistStorage iface,
REFIID  riid,
void **  ppvObject 
)
static

Definition at line 1643 of file datacache.c.

1647 {
1648  DataCache *this = impl_from_IPersistStorage(iface);
1649 
1650  return IUnknown_QueryInterface(this->outer_unk, riid, ppvObject);
1651 }
REFIID riid
Definition: precomp.h:44
REFIID LPVOID * ppvObject
Definition: precomp.h:44
static DataCache * impl_from_IPersistStorage(IPersistStorage *iface)
Definition: datacache.c:191

◆ DataCache_IPersistStorage_Release()

static ULONG WINAPI DataCache_IPersistStorage_Release ( IPersistStorage iface)
static

Definition at line 1667 of file datacache.c.

1669 {
1670  DataCache *this = impl_from_IPersistStorage(iface);
1671 
1672  return IUnknown_Release(this->outer_unk);
1673 }
static DataCache * impl_from_IPersistStorage(IPersistStorage *iface)
Definition: datacache.c:191

◆ DataCache_IsDirty()

static HRESULT WINAPI DataCache_IsDirty ( IPersistStorage iface)
static

Definition at line 1692 of file datacache.c.

1694 {
1697 
1698  TRACE("(%p)\n", iface);
1699 
1700  if (This->dirty)
1701  return S_OK;
1702 
1704  if (cache_entry->dirty)
1705  return S_OK;
1706 
1707  return S_FALSE;
1708 }
Definition: svc_auth_des.c:77
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
#define S_FALSE
Definition: winerror.h:2357
#define TRACE(s)
Definition: solgame.cpp:4
uint32_t entry
Definition: isohybrid.c:63
#define S_OK
Definition: intsafe.h:51
static DataCache * impl_from_IPersistStorage(IPersistStorage *iface)
Definition: datacache.c:191

◆ DataCache_IViewObject2_AddRef()

static ULONG WINAPI DataCache_IViewObject2_AddRef ( IViewObject2 iface)
static

Definition at line 1981 of file datacache.c.

1983 {
1984  DataCache *this = impl_from_IViewObject2(iface);
1985 
1986  return IUnknown_AddRef(this->outer_unk);
1987 }
static DataCache * impl_from_IViewObject2(IViewObject2 *iface)
Definition: datacache.c:196

◆ DataCache_IViewObject2_QueryInterface()

static HRESULT WINAPI DataCache_IViewObject2_QueryInterface ( IViewObject2 iface,
REFIID  riid,
void **  ppvObject 
)
static

Definition at line 1968 of file datacache.c.

1972 {
1973  DataCache *this = impl_from_IViewObject2(iface);
1974 
1975  return IUnknown_QueryInterface(this->outer_unk, riid, ppvObject);
1976 }
static DataCache * impl_from_IViewObject2(IViewObject2 *iface)
Definition: datacache.c:196
REFIID riid
Definition: precomp.h:44
REFIID LPVOID * ppvObject
Definition: precomp.h:44

◆ DataCache_IViewObject2_Release()

static ULONG WINAPI DataCache_IViewObject2_Release ( IViewObject2 iface)
static

Definition at line 1992 of file datacache.c.

1994 {
1995  DataCache *this = impl_from_IViewObject2(iface);
1996 
1997  return IUnknown_Release(this->outer_unk);
1998 }
static DataCache * impl_from_IViewObject2(IViewObject2 *iface)
Definition: datacache.c:196

◆ DataCache_Load()

static HRESULT WINAPI DataCache_Load ( IPersistStorage iface,
IStorage stg 
)
static

Definition at line 1832 of file datacache.c.

1833 {
1835  HRESULT hr;
1836  CLSID clsid;
1837  DataCacheEntry *entry, *cursor2;
1838 
1839  TRACE("(%p, %p)\n", iface, stg);
1840 
1841  IPersistStorage_HandsOffStorage( iface );
1842 
1843  LIST_FOR_EACH_ENTRY_SAFE( entry, cursor2, &This->cache_list, DataCacheEntry, entry )
1845  This->clsid = CLSID_NULL;
1846 
1847  ReadClassStg( stg, &clsid );
1849  if (FAILED( hr )) return hr;
1850 
1851  This->clsid = clsid;
1852 
1853  if (This->clsid_static)
1854  {
1855  hr = parse_contents_stream( This, stg );
1856  if (FAILED(hr)) hr = parse_pres_streams( This, stg );
1857  }
1858  else
1859  hr = parse_pres_streams( This, stg );
1860 
1861  if (SUCCEEDED( hr ))
1862  {
1863  This->dirty = FALSE;
1864  This->presentationStorage = stg;
1865  IStorage_AddRef( This->presentationStorage );
1866  }
1867 
1868  return hr;
1869 }
static HRESULT parse_contents_stream(DataCache *cache, IStorage *stg)
Definition: datacache.c:1803
HRESULT hr
Definition: shlfolder.c:183
#define FALSE
Definition: types.h:117
if SUCCEEDED(hr)
static void DataCacheEntry_Destroy(DataCache *cache, DataCacheEntry *cache_entry)
Definition: datacache.c:252
#define TRACE(s)
Definition: solgame.cpp:4
#define CLSID_NULL
Definition: guiddef.h:99
LONG HRESULT
Definition: typedefs.h:79
REFCLSID clsid
Definition: msctf.c:82
uint32_t entry
Definition: isohybrid.c:63
static DataCache * impl_from_IPersistStorage(IPersistStorage *iface)
Definition: datacache.c:191
#define LIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, list, type, field)
Definition: list.h:204
HRESULT WINAPI ReadClassStg(IStorage *pstg, CLSID *pclsid)
Definition: storage32.c:9103
static HRESULT parse_pres_streams(DataCache *cache, IStorage *stg)
Definition: datacache.c:1767
static HRESULT create_automatic_entry(DataCache *cache, const CLSID *clsid)
Definition: datacache.c:1312

Referenced by DataCache_SaveCompleted().

◆ DataCache_NDIUnknown_AddRef()

static ULONG WINAPI DataCache_NDIUnknown_AddRef ( IUnknown iface)
static

Definition at line 1427 of file datacache.c.

1429 {
1430  DataCache *this = impl_from_IUnknown(iface);
1431  return InterlockedIncrement(&this->ref);
1432 }
Definition: send.c:48
#define InterlockedIncrement
Definition: armddk.h:53
static DataCache * impl_from_IUnknown(IUnknown *iface)
Definition: datacache.c:186

◆ DataCache_NDIUnknown_QueryInterface()

static HRESULT WINAPI DataCache_NDIUnknown_QueryInterface ( IUnknown iface,
REFIID  riid,
void **  ppvObject 
)
static

Definition at line 1367 of file datacache.c.

1371 {
1372  DataCache *this = impl_from_IUnknown(iface);
1373 
1374  if ( ppvObject==0 )
1375  return E_INVALIDARG;
1376 
1377  *ppvObject = 0;
1378 
1379  if (IsEqualIID(&IID_IUnknown, riid))
1380  {
1381  if (this->outer_unk == iface) /* non-aggregated, return IUnknown from IOleCache2 */
1382  *ppvObject = &this->IOleCache2_iface;
1383  else
1384  *ppvObject = iface;
1385  }
1386  else if (IsEqualIID(&IID_IDataObject, riid))
1387  {
1388  *ppvObject = &this->IDataObject_iface;
1389  }
1390  else if ( IsEqualIID(&IID_IPersistStorage, riid) ||
1392  {
1393  *ppvObject = &this->IPersistStorage_iface;
1394  }
1395  else if ( IsEqualIID(&IID_IViewObject, riid) ||
1397  {
1398  *ppvObject = &this->IViewObject2_iface;
1399  }
1400  else if ( IsEqualIID(&IID_IOleCache, riid) ||
1402  {
1403  *ppvObject = &this->IOleCache2_iface;
1404  }
1405  else if ( IsEqualIID(&IID_IOleCacheControl, riid) )
1406  {
1407  *ppvObject = &this->IOleCacheControl_iface;
1408  }
1409 
1410  if ((*ppvObject)==0)
1411  {
1412  WARN( "() : asking for unsupported interface %s\n", debugstr_guid(riid));
1413  return E_NOINTERFACE;
1414  }
1415 
1416  IUnknown_AddRef((IUnknown*)*ppvObject);
1417 
1418  return S_OK;
1419 }
const GUID IID_IViewObject
#define E_NOINTERFACE
Definition: winerror.h:2364
REFIID riid
Definition: precomp.h:44
const GUID IID_IPersist
Definition: proxy.cpp:14
const GUID IID_IOleCacheControl
#define WARN(fmt,...)
Definition: debug.h:112
const GUID IID_IDataObject
const GUID IID_IPersistStorage
#define E_INVALIDARG
Definition: ddrawi.h:101
#define debugstr_guid
Definition: kernel32.h:35
const GUID IID_IUnknown
REFIID LPVOID * ppvObject
Definition: precomp.h:44
const GUID IID_IOleCache2
#define S_OK
Definition: intsafe.h:51
const GUID IID_IViewObject2
static DataCache * impl_from_IUnknown(IUnknown *iface)
Definition: datacache.c:186
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95
const GUID IID_IOleCache

◆ DataCache_NDIUnknown_Release()

static ULONG WINAPI DataCache_NDIUnknown_Release ( IUnknown iface)
static

Definition at line 1440 of file datacache.c.

1442 {
1443  DataCache *this = impl_from_IUnknown(iface);
1444  ULONG ref;
1445 
1446  ref = InterlockedDecrement(&this->ref);
1447 
1448  if (ref == 0) DataCache_Destroy(this);
1449 
1450  return ref;
1451 }
static void DataCache_Destroy(DataCache *ptrToDestroy)
Definition: datacache.c:263
Definition: send.c:48
GLenum GLint ref
Definition: glext.h:6028
#define InterlockedDecrement
Definition: armddk.h:52
unsigned int ULONG
Definition: retypes.h:1
static DataCache * impl_from_IUnknown(IUnknown *iface)
Definition: datacache.c:186

◆ DataCache_OnClose()

static void WINAPI DataCache_OnClose ( IAdviseSink iface)
static

Definition at line 2870 of file datacache.c.

2871 {
2872  FIXME("stub\n");
2873 }
#define FIXME(fmt,...)
Definition: debug.h:111

◆ DataCache_OnDataChange()

static void WINAPI DataCache_OnDataChange ( IAdviseSink iface,
FORMATETC *  fmt,
STGMEDIUM *  med 
)
static

Definition at line 2848 of file datacache.c.

2849 {
2851  TRACE("(%p)->(%s, %p)\n", This, debugstr_formatetc(fmt), med);
2852  IOleCache2_SetData(&This->IOleCache2_iface, fmt, med, FALSE);
2853 }
#define FALSE
Definition: types.h:117
const char * debugstr_formatetc(const FORMATETC *formatetc)
Definition: datacache.c:216
#define TRACE(s)
Definition: solgame.cpp:4
Definition: dsound.c:943
static DataCache * impl_from_IAdviseSink(IAdviseSink *iface)
Definition: datacache.c:211

◆ DataCache_OnRename()

static void WINAPI DataCache_OnRename ( IAdviseSink iface,
IMoniker mk 
)
static

Definition at line 2860 of file datacache.c.

2861 {
2862  FIXME("stub\n");
2863 }
#define FIXME(fmt,...)
Definition: debug.h:111

◆ DataCache_OnRun()

static HRESULT WINAPI DataCache_OnRun ( IOleCacheControl iface,
IDataObject data_obj 
)
static

Definition at line 2769 of file datacache.c.

2770 {
2773 
2774  TRACE("(%p)->(%p)\n", iface, data_obj);
2775 
2776  if(This->running_object) return S_OK;
2777 
2778  /* No reference is taken on the data object */
2779  This->running_object = data_obj;
2780 
2782  {
2784  }
2785 
2786  return S_OK;
2787 }
Definition: svc_auth_des.c:77
static DataCache * impl_from_IOleCacheControl(IOleCacheControl *iface)
Definition: datacache.c:206
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
#define TRACE(s)
Definition: solgame.cpp:4
static HRESULT setup_sink(DataCache *This, DataCacheEntry *cache_entry)
Definition: datacache.c:2424
uint32_t entry
Definition: isohybrid.c:63
#define S_OK
Definition: intsafe.h:51

◆ DataCache_OnSave()

static void WINAPI DataCache_OnSave ( IAdviseSink iface)
static

Definition at line 2865 of file datacache.c.

2866 {
2867  FIXME("stub\n");
2868 }
#define FIXME(fmt,...)
Definition: debug.h:111

◆ DataCache_OnStop()

static HRESULT WINAPI DataCache_OnStop ( IOleCacheControl iface)
static

Definition at line 2792 of file datacache.c.

2793 {
2796 
2797  TRACE("(%p)\n", iface);
2798 
2799  if(!This->running_object) return S_OK;
2800 
2802  {
2803  if(cache_entry->sink_id)
2804  {
2805  IDataObject_DUnadvise(This->running_object, cache_entry->sink_id);
2806  cache_entry->sink_id = 0;
2807  }
2808  }
2809 
2810  /* No ref taken in OnRun, so no Release call here */
2811  This->running_object = NULL;
2812  return S_OK;
2813 }
Definition: svc_auth_des.c:77
static DataCache * impl_from_IOleCacheControl(IOleCacheControl *iface)
Definition: datacache.c:206
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
#define TRACE(s)
Definition: solgame.cpp:4
uint32_t entry
Definition: isohybrid.c:63
#define S_OK
Definition: intsafe.h:51
#define NULL
Definition: types.h:112

◆ DataCache_OnViewChange()

static void WINAPI DataCache_OnViewChange ( IAdviseSink iface,
DWORD  aspect,
LONG  index 
)
static

Definition at line 2855 of file datacache.c.

2856 {
2857  FIXME("stub\n");
2858 }
#define FIXME(fmt,...)
Definition: debug.h:111

◆ DataCache_QueryGetData()

static HRESULT WINAPI DataCache_QueryGetData ( IDataObject iface,
FORMATETC *  fmt 
)
static

Definition at line 1526 of file datacache.c.

1527 {
1528  DataCache *This = impl_from_IDataObject( iface );
1530 
1531  TRACE( "(%p)->(%s)\n", iface, debugstr_formatetc( fmt ) );
1533 
1534  return cache_entry ? S_OK : S_FALSE;
1535 }
static DataCache * impl_from_IDataObject(IDataObject *iface)
Definition: datacache.c:181
Definition: svc_auth_des.c:77
static DataCacheEntry * DataCache_GetEntryForFormatEtc(DataCache *This, const FORMATETC *formatetc)
Definition: datacache.c:291
const char * debugstr_formatetc(const FORMATETC *formatetc)
Definition: datacache.c:216
#define S_FALSE
Definition: winerror.h:2357
#define TRACE(s)
Definition: solgame.cpp:4
#define S_OK
Definition: intsafe.h:51
Definition: dsound.c:943

◆ DataCache_Save()

static HRESULT WINAPI DataCache_Save ( IPersistStorage iface,
IStorage stg,
BOOL  same_as_load 
)
static

Definition at line 1879 of file datacache.c.

1880 {
1883  HRESULT hr = S_OK;
1884  int stream_number = 0;
1885 
1886  TRACE("(%p, %p, %d)\n", iface, stg, same_as_load);
1887 
1888  /* assign stream numbers to the cache entries */
1890  {
1891  if (cache_entry->save_stream_num != stream_number)
1892  {
1893  cache_entry->dirty = TRUE; /* needs to be written out again */
1894  cache_entry->save_stream_num = stream_number;
1895  }
1896  stream_number++;
1897  }
1898 
1899  /* write out the cache entries */
1901  {
1902  if (!same_as_load || cache_entry->dirty)
1903  {
1904  hr = DataCacheEntry_Save(cache_entry, stg, same_as_load);
1905  if (FAILED(hr))
1906  break;
1907 
1908  if (same_as_load) cache_entry->dirty = FALSE;
1909  }
1910  }
1911 
1912  if (same_as_load) This->dirty = FALSE;
1913  return hr;
1914 }
HRESULT hr
Definition: shlfolder.c:183
#define TRUE
Definition: types.h:120
Definition: svc_auth_des.c:77
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
#define FALSE
Definition: types.h:117
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:79
uint32_t entry
Definition: isohybrid.c:63
#define S_OK
Definition: intsafe.h:51
static DataCache * impl_from_IPersistStorage(IPersistStorage *iface)
Definition: datacache.c:191
static HRESULT DataCacheEntry_Save(DataCacheEntry *cache_entry, IStorage *storage, BOOL same_as_load)
Definition: datacache.c:1101

Referenced by DataCache_DiscardCache().

◆ DataCache_SaveCompleted()

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

Definition at line 1922 of file datacache.c.

1925 {
1926  TRACE("(%p, %p)\n", iface, pStgNew);
1927 
1928  if (pStgNew)
1929  {
1930  IPersistStorage_HandsOffStorage(iface);
1931 
1932  DataCache_Load(iface, pStgNew);
1933  }
1934 
1935  return S_OK;
1936 }
#define TRACE(s)
Definition: solgame.cpp:4
static HRESULT WINAPI DataCache_Load(IPersistStorage *iface, IStorage *stg)
Definition: datacache.c:1832
#define S_OK
Definition: intsafe.h:51

◆ DataCache_SetAdvise()

static HRESULT WINAPI DataCache_SetAdvise ( IViewObject2 iface,
DWORD  aspects,
DWORD  advf,
IAdviseSink pAdvSink 
)
static

Definition at line 2181 of file datacache.c.

2186 {
2187  DataCache *this = impl_from_IViewObject2(iface);
2188 
2189  TRACE("(%p, %x, %x, %p)\n", iface, aspects, advf, pAdvSink);
2190 
2191  /*
2192  * A call to this function removes the previous sink
2193  */
2194  if (this->sinkInterface != NULL)
2195  {
2196  IAdviseSink_Release(this->sinkInterface);
2197  this->sinkInterface = NULL;
2198  this->sinkAspects = 0;
2199  this->sinkAdviseFlag = 0;
2200  }
2201 
2202  /*
2203  * Now, setup the new one.
2204  */
2205  if (pAdvSink!=NULL)
2206  {
2207  this->sinkInterface = pAdvSink;
2208  this->sinkAspects = aspects;
2209  this->sinkAdviseFlag = advf;
2210 
2211  IAdviseSink_AddRef(this->sinkInterface);
2212  }
2213 
2214  /*
2215  * When the ADVF_PRIMEFIRST flag is set, we have to advise the
2216  * sink immediately.
2217  */
2218  if (advf & ADVF_PRIMEFIRST)
2219  {
2220  DataCache_FireOnViewChange(this, aspects, -1);
2221  }
2222 
2223  return S_OK;
2224 }
static DataCache * impl_from_IViewObject2(IViewObject2 *iface)
Definition: datacache.c:196
#define TRACE(s)
Definition: solgame.cpp:4
#define S_OK
Definition: intsafe.h:51
#define NULL
Definition: types.h:112
static void DataCache_FireOnViewChange(DataCache *this, DWORD aspect, LONG lindex)
Definition: datacache.c:425

◆ DataCache_Uncache()

static HRESULT WINAPI DataCache_Uncache ( IOleCache2 iface,
DWORD  dwConnection 
)
static

Definition at line 2494 of file datacache.c.

2497 {
2500 
2501  TRACE("(%d)\n", dwConnection);
2502 
2504  if (cache_entry->id == dwConnection)
2505  {
2507  return S_OK;
2508  }
2509 
2510  WARN("no connection found for %d\n", dwConnection);
2511 
2512  return OLE_E_NOCONNECTION;
2513 }
static DataCache * impl_from_IOleCache2(IOleCache2 *iface)
Definition: datacache.c:201
#define WARN(fmt,...)
Definition: debug.h:112
Definition: svc_auth_des.c:77
#define OLE_E_NOCONNECTION
Definition: winerror.h:2618
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
static void DataCacheEntry_Destroy(DataCache *cache, DataCacheEntry *cache_entry)
Definition: datacache.c:252
#define TRACE(s)
Definition: solgame.cpp:4
uint32_t entry
Definition: isohybrid.c:63
#define S_OK
Definition: intsafe.h:51

◆ DataCache_Unfreeze()

static HRESULT WINAPI DataCache_Unfreeze ( IViewObject2 iface,
DWORD  dwFreeze 
)
static

Definition at line 2167 of file datacache.c.

2170 {
2171  FIXME("stub\n");
2172  return E_NOTIMPL;
2173 }
#define FIXME(fmt,...)
Definition: debug.h:111
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ DataCache_UpdateCache()

static HRESULT WINAPI DataCache_UpdateCache ( IOleCache2 iface,
IDataObject data,
DWORD  mode,
void reserved 
)
static

Definition at line 2619 of file datacache.c.

2621 {
2624  STGMEDIUM med;
2625  HRESULT hr = S_OK;
2626  CLIPFORMAT view_list[] = { CF_METAFILEPICT, CF_ENHMETAFILE, CF_DIB, CF_BITMAP };
2627  FORMATETC fmt;
2628  int i, slots = 0;
2629  BOOL done_one = FALSE;
2630 
2631  TRACE( "(%p %p %08x %p)\n", iface, data, mode, reserved );
2632 
2634  {
2635  slots++;
2636 
2637  if (!entry_updatable( cache_entry, mode ))
2638  {
2639  done_one = TRUE;
2640  continue;
2641  }
2642 
2643  fmt = cache_entry->fmtetc;
2644 
2645  if (fmt.cfFormat)
2646  {
2647  hr = IDataObject_GetData( data, &fmt, &med );
2648  if (hr != S_OK && fmt.cfFormat == CF_DIB)
2649  {
2650  fmt.cfFormat = CF_BITMAP;
2651  fmt.tymed = TYMED_GDI;
2652  hr = IDataObject_GetData( data, &fmt, &med );
2653  }
2654  if (hr != S_OK && fmt.cfFormat == CF_ENHMETAFILE)
2655  {
2656  fmt.cfFormat = CF_METAFILEPICT;
2657  fmt.tymed = TYMED_MFPICT;
2658  hr = IDataObject_GetData( data, &fmt, &med );
2659  }
2660  if (hr == S_OK)
2661  {
2663  if (hr != S_OK) ReleaseStgMedium( &med );
2664  else done_one = TRUE;
2665  }
2666  }
2667  else
2668  {
2669  for (i = 0; i < ARRAY_SIZE(view_list); i++)
2670  {
2671  fmt.cfFormat = view_list[i];
2672  fmt.tymed = tymed_from_cf( fmt.cfFormat );
2673  hr = IDataObject_QueryGetData( data, &fmt );
2674  if (hr == S_OK)
2675  {
2676  hr = IDataObject_GetData( data, &fmt, &med );
2677  if (hr == S_OK)
2678  {
2679  if (fmt.cfFormat == CF_BITMAP)
2680  {
2681  cache_entry->fmtetc.cfFormat = CF_DIB;
2682  cache_entry->fmtetc.tymed = TYMED_HGLOBAL;
2683  }
2684  else
2685  {
2686  cache_entry->fmtetc.cfFormat = fmt.cfFormat;
2687  cache_entry->fmtetc.tymed = fmt.tymed;
2688  }
2690  if (hr != S_OK) ReleaseStgMedium( &med );
2691  else done_one = TRUE;
2692  break;
2693  }
2694  }
2695  }
2696  }
2697  }
2698 
2699  return (!slots || done_one) ? S_OK : CACHE_E_NOCACHE_UPDATED;
2700 }
#define CF_ENHMETAFILE
Definition: constants.h:409
HRESULT hr
Definition: shlfolder.c:183
static DataCache * impl_from_IOleCache2(IOleCache2 *iface)
Definition: datacache.c:201
void WINAPI ReleaseStgMedium(STGMEDIUM *pmedium)
Definition: ole2.c:2033
#define TRUE
Definition: types.h:120
const char * fmt
Definition: wsprintf.c:30
#define CF_METAFILEPICT
Definition: constants.h:398
Definition: svc_auth_des.c:77
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
r reserved
Definition: btrfs.c:2940
#define CF_BITMAP
Definition: constants.h:397
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:79
static BOOL entry_updatable(DataCacheEntry *entry, DWORD mode)
Definition: datacache.c:2604
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
static DWORD tymed_from_cf(DWORD cf)
Definition: datacache.c:1292
uint32_t entry
Definition: isohybrid.c:63
GLenum mode
Definition: glext.h:6217
#define S_OK
Definition: intsafe.h:51
#define CACHE_E_NOCACHE_UPDATED
Definition: winerror.h:2712
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
#define ARRAY_SIZE(a)
Definition: main.h:24
static HRESULT DataCacheEntry_SetData(DataCacheEntry *cache_entry, const FORMATETC *formatetc, STGMEDIUM *stgmedium, BOOL fRelease)
Definition: datacache.c:1224
Definition: dsound.c:943
#define CF_DIB
Definition: constants.h:403

◆ DataCacheEntry_Destroy()

static void DataCacheEntry_Destroy ( DataCache cache,
DataCacheEntry cache_entry 
)
static

Definition at line 252 of file datacache.c.

253 {
254  list_remove(&cache_entry->entry);
255  CoTaskMemFree(cache_entry->fmtetc.ptd);
256  ReleaseStgMedium(&cache_entry->stgmedium);
257  if(cache_entry->sink_id)
258  IDataObject_DUnadvise(cache->running_object, cache_entry->sink_id);
259 
261 }
Definition: cache.c:48
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:442
void WINAPI ReleaseStgMedium(STGMEDIUM *pmedium)
Definition: ole2.c:2033
Definition: svc_auth_des.c:77
__WINE_SERVER_LIST_INLINE void list_remove(struct list *elem)
Definition: list.h:108
#define GetProcessHeap()
Definition: compat.h:595
#define HeapFree(x, y, z)
Definition: compat.h:594

Referenced by DataCache_Destroy(), DataCache_Load(), and DataCache_Uncache().

◆ DataCacheEntry_DiscardData()

static HRESULT DataCacheEntry_DiscardData ( DataCacheEntry cache_entry)
inlinestatic

Definition at line 1286 of file datacache.c.

1287 {
1288  ReleaseStgMedium(&cache_entry->stgmedium);
1289  return S_OK;
1290 }
void WINAPI ReleaseStgMedium(STGMEDIUM *pmedium)
Definition: ole2.c:2033
Definition: svc_auth_des.c:77
#define S_OK
Definition: intsafe.h:51

Referenced by add_cache_entry(), and DataCache_DiscardCache().

◆ DataCacheEntry_GetData()

static HRESULT DataCacheEntry_GetData ( DataCacheEntry cache_entry,
IStorage stg,
FORMATETC *  fmt,
STGMEDIUM *  stgmedium 
)
static

Definition at line 1269 of file datacache.c.

1270 {
1271  if (cache_entry->stgmedium.tymed == TYMED_NULL && cache_entry->load_stream_num != STREAM_NUMBER_NOT_SET)
1272  {
1274  if (FAILED(hr))
1275  return hr;
1276  }
1277  if (cache_entry->stgmedium.tymed == TYMED_NULL)
1278  return OLE_E_BLANK;
1279 
1280  if (fmt->cfFormat == CF_BITMAP)
1281  return synthesize_bitmap( cache_entry->stgmedium.u.hGlobal, stgmedium );
1282 
1283  return copy_stg_medium(cache_entry->fmtetc.cfFormat, stgmedium, &cache_entry->stgmedium);
1284 }
HRESULT hr
Definition: shlfolder.c:183
Definition: svc_auth_des.c:77
#define CF_BITMAP
Definition: constants.h:397
LONG HRESULT
Definition: typedefs.h:79
static HRESULT copy_stg_medium(CLIPFORMAT cf, STGMEDIUM *dest_stgm, const STGMEDIUM *src_stgm)
Definition: datacache.c:1139
static HRESULT synthesize_bitmap(HGLOBAL dib, STGMEDIUM *med)
Definition: datacache.c:1203
#define OLE_E_BLANK
Definition: winerror.h:2621
static HRESULT DataCacheEntry_LoadData(DataCacheEntry *cache_entry, IStorage *stg)
Definition: datacache.c:831
#define STREAM_NUMBER_NOT_SET
Definition: datacache.c:92
Definition: dsound.c:943

Referenced by DataCache_GetData().

◆ DataCacheEntry_LoadData()

static HRESULT DataCacheEntry_LoadData ( DataCacheEntry cache_entry,
IStorage stg 
)
static

Definition at line 831 of file datacache.c.

832 {
833  HRESULT hr;
834  IStream *stm;
835 
836  if (!stg) return OLE_E_BLANK;
837  hr = open_pres_stream( stg, cache_entry->load_stream_num, &stm );
838  if (FAILED(hr)) return hr;
839 
840  switch (cache_entry->fmtetc.cfFormat)
841  {
842  case CF_METAFILEPICT:
843  hr = load_mf_pict( cache_entry, stm );
844  break;
845 
846  case CF_DIB:
847  hr = load_dib( cache_entry, stm );
848  break;
849 
850  case CF_ENHMETAFILE:
851  hr = load_emf( cache_entry, stm );
852  break;
853 
854  default:
855  FIXME( "Unimplemented clip format %x\n", cache_entry->fmtetc.cfFormat );
856  hr = E_NOTIMPL;
857  }
858 
859  IStream_Release( stm );
860  return hr;
861 }
#define CF_ENHMETAFILE
Definition: constants.h:409
HRESULT hr
Definition: shlfolder.c:183
static HRESULT load_mf_pict(DataCacheEntry *cache_entry, IStream *stm)
Definition: datacache.c:584
#define CF_METAFILEPICT
Definition: constants.h:398
Definition: svc_auth_des.c:77
static HRESULT load_emf(DataCacheEntry *cache_entry, IStream *stm)
Definition: datacache.c:764
#define FIXME(fmt,...)
Definition: debug.h:111
LONG HRESULT
Definition: typedefs.h:79
#define OLE_E_BLANK
Definition: winerror.h:2621
#define E_NOTIMPL
Definition: ddrawi.h:99
static HRESULT open_pres_stream(IStorage *stg, int stream_number, IStream **stm)
Definition: datacache.c:535
static HRESULT load_dib(DataCacheEntry *cache_entry, IStream *stm)
Definition: datacache.c:666
#define CF_DIB
Definition: constants.h:403

Referenced by DataCache_Draw(), DataCache_GetExtent(), and DataCacheEntry_GetData().

◆ DataCacheEntry_Save()

static HRESULT DataCacheEntry_Save ( DataCacheEntry cache_entry,
IStorage storage,
BOOL  same_as_load 
)
static

Definition at line 1101 of file datacache.c.

1103 {
1104  HRESULT hr;
1105  IStream *stream;
1106  BOOL contents = (cache_entry->id == 1);
1107 
1108  TRACE("stream_number = %d, fmtetc = %s\n", cache_entry->save_stream_num, debugstr_formatetc(&cache_entry->fmtetc));
1109 
1110  hr = create_stream(cache_entry, storage, contents, &stream);
1111  if (FAILED(hr))
1112  return hr;
1113 
1114  switch (cache_entry->fmtetc.cfFormat)
1115  {
1116  case CF_DIB:
1117  hr = save_dib(cache_entry, contents, stream);
1118  break;
1119  case CF_METAFILEPICT:
1120  hr = save_mfpict(cache_entry, contents, stream);
1121  break;
1122  case CF_ENHMETAFILE:
1123  hr = save_emf(cache_entry, contents, stream);
1124  break;
1125  case 0:
1127  break;
1128  default:
1129  FIXME("got unsupported clipboard format %x\n", cache_entry->fmtetc.cfFormat);
1130  }
1131 
1132  IStream_Release(stream);
1133  return hr;
1134 }
#define CF_ENHMETAFILE
Definition: constants.h:409
HRESULT hr
Definition: shlfolder.c:183
static HRESULT save_dib(DataCacheEntry *entry, BOOL contents, IStream *stream)
Definition: datacache.c:877
static HRESULT save_mfpict(DataCacheEntry *entry, BOOL contents, IStream *stream)
Definition: datacache.c:935
static HRESULT create_stream(DataCacheEntry *cache_entry, IStorage *storage, BOOL contents, IStream **stream)
Definition: datacache.c:1082
#define CF_METAFILEPICT
Definition: constants.h:398
Definition: svc_auth_des.c:77
static HRESULT save_view_cache(DataCacheEntry *entry, IStream *stream)
Definition: datacache.c:1069
const char * debugstr_formatetc(const FORMATETC *formatetc)
Definition: datacache.c:216
unsigned int BOOL
Definition: ntddk_ex.h:94
#define FIXME(fmt,...)
Definition: debug.h:111
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:79
Definition: parse.h:22
GLuint GLuint stream
Definition: glext.h:7522
static HRESULT save_emf(DataCacheEntry *entry, BOOL contents, IStream *stream)
Definition: datacache.c:1016
#define CF_DIB
Definition: constants.h:403

Referenced by DataCache_Save().

◆ DataCacheEntry_SetData()

static HRESULT DataCacheEntry_SetData ( DataCacheEntry cache_entry,
const FORMATETC *  formatetc,
STGMEDIUM *  stgmedium,
BOOL  fRelease 
)
static

Definition at line 1224 of file datacache.c.

1228 {
1229  STGMEDIUM copy;
1230  HRESULT hr;
1231 
1232  if ((!cache_entry->fmtetc.cfFormat && !formatetc->cfFormat) ||
1233  (cache_entry->fmtetc.tymed == TYMED_NULL && formatetc->tymed == TYMED_NULL) ||
1234  stgmedium->tymed == TYMED_NULL)
1235  {
1236  WARN("invalid formatetc\n");
1237  return DV_E_FORMATETC;
1238  }
1239 
1240  cache_entry->dirty = TRUE;
1241  ReleaseStgMedium(&cache_entry->stgmedium);
1242 
1243  if (formatetc->cfFormat == CF_BITMAP)
1244  {
1245  hr = synthesize_dib( stgmedium->u.hBitmap, &copy );
1246  if (FAILED(hr)) return hr;
1247  if (fRelease) ReleaseStgMedium(stgmedium);
1248  stgmedium = &copy;
1249  fRelease = TRUE;
1250  }
1251  else if (formatetc->cfFormat == CF_METAFILEPICT && cache_entry->fmtetc.cfFormat == CF_ENHMETAFILE)
1252  {
1253  hr = synthesize_emf( stgmedium->u.hMetaFilePict, &copy );
1254  if (FAILED(hr)) return hr;
1255  if (fRelease) ReleaseStgMedium(stgmedium);
1256  stgmedium = &copy;
1257  fRelease = TRUE;
1258  }
1259 
1260  if (fRelease)
1261  {
1262  cache_entry->stgmedium = *stgmedium;
1263  return S_OK;
1264  }
1265  else
1266  return copy_stg_medium(cache_entry->fmtetc.cfFormat, &cache_entry->stgmedium, stgmedium);
1267 }
#define CF_ENHMETAFILE
Definition: constants.h:409
HRESULT hr
Definition: shlfolder.c:183
void WINAPI ReleaseStgMedium(STGMEDIUM *pmedium)
Definition: ole2.c:2033
#define TRUE
Definition: types.h:120
#define WARN(fmt,...)
Definition: debug.h:112
#define CF_METAFILEPICT
Definition: constants.h:398
Definition: svc_auth_des.c:77
#define CF_BITMAP
Definition: constants.h:397
#define DV_E_FORMATETC
Definition: winerror.h:2633
LONG HRESULT
Definition: typedefs.h:79
static HRESULT copy_stg_medium(CLIPFORMAT cf, STGMEDIUM *dest_stgm, const STGMEDIUM *src_stgm)
Definition: datacache.c:1139
static HRESULT synthesize_dib(HBITMAP bm, STGMEDIUM *med)
Definition: datacache.c:1175
#define S_OK
Definition: intsafe.h:51
INT copy(TCHAR source[MAX_PATH], TCHAR dest[MAX_PATH], INT append, DWORD lpdwFlags, BOOL bTouch)
Definition: copy.c:51
static HRESULT synthesize_emf(HMETAFILEPICT data, STGMEDIUM *med)
Definition: datacache.c:549

Referenced by DataCache_IOleCache2_SetData(), and DataCache_UpdateCache().

◆ debugstr_formatetc()

const char* debugstr_formatetc ( const FORMATETC *  formatetc)

Definition at line 216 of file datacache.c.

217 {
218  return wine_dbg_sprintf("{ cfFormat = 0x%x, ptd = %p, dwAspect = %d, lindex = %d, tymed = %d }",
219  formatetc->cfFormat, formatetc->ptd, formatetc->dwAspect,
220  formatetc->lindex, formatetc->tymed);
221 }
const char * wine_dbg_sprintf(const char *format,...)
Definition: compat.c:296

Referenced by add_cache_entry(), DataCache_Cache(), DataCache_GetData(), DataCache_IOleCache2_SetData(), DataCache_OnDataChange(), DataCache_QueryGetData(), DataCacheEntry_Save(), and OleCreateFromFileEx().

◆ entry_updatable()

static BOOL entry_updatable ( DataCacheEntry entry,
DWORD  mode 
)
static

Definition at line 2604 of file datacache.c.

2605 {
2606  BOOL is_blank = entry->stgmedium.tymed == TYMED_NULL;
2607 
2608  if ((mode & UPDFCACHE_ONLYIFBLANK) && !is_blank) return FALSE;
2609 
2610  if ((mode & UPDFCACHE_NODATACACHE) && (entry->advise_flags & ADVF_NODATA)) return TRUE;
2611  if ((mode & UPDFCACHE_ONSAVECACHE) && (entry->advise_flags & ADVFCACHE_ONSAVE)) return TRUE;
2612  if ((mode & UPDFCACHE_ONSTOPCACHE) && (entry->advise_flags & ADVF_DATAONSTOP)) return TRUE;
2613  if ((mode & UPDFCACHE_NORMALCACHE) && (entry->advise_flags == 0)) return TRUE;
2614  if ((mode & UPDFCACHE_IFBLANK) && (is_blank && !(entry->advise_flags & ADVF_NODATA))) return TRUE;
2615 
2616  return FALSE;
2617 }
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
uint32_t entry
Definition: isohybrid.c:63
GLenum mode
Definition: glext.h:6217

Referenced by DataCache_UpdateCache().

◆ get_static_entry()

static HRESULT get_static_entry ( DataCache cache,
DataCacheEntry **  cache_entry 
)
static

Definition at line 316 of file datacache.c.

317 {
319  struct list *head = list_head( &cache->cache_list );
320  HRESULT hr = E_FAIL;
321 
322  *cache_entry = NULL;
323 
324  if (head)
325  {
327  if (entry->id == 1)
328  {
329  *cache_entry = entry;
330  hr = S_OK;
331  }
332  }
333 
334  return hr;
335 }
Definition: cache.c:48
HRESULT hr
Definition: shlfolder.c:183
struct outqueuenode * head
Definition: adnsresfilter.c:66
Definition: svc_auth_des.c:77
#define E_FAIL
Definition: ddrawi.h:102
__WINE_SERVER_LIST_INLINE struct list * list_head(const struct list *list)
Definition: list.h:131
LONG HRESULT
Definition: typedefs.h:79
uint32_t entry
Definition: isohybrid.c:63
Definition: _list.h:228
#define S_OK
Definition: intsafe.h:51
#define NULL
Definition: types.h:112
#define LIST_ENTRY(type)
Definition: queue.h:175

Referenced by parse_contents_stream().

◆ impl_from_IAdviseSink()

static DataCache* impl_from_IAdviseSink ( IAdviseSink iface)
inlinestatic

Definition at line 211 of file datacache.c.

212 {
213  return CONTAINING_RECORD(iface, DataCache, IAdviseSink_iface);
214 }
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560

Referenced by DataCache_OnDataChange().

◆ impl_from_IDataObject()

static DataCache* impl_from_IDataObject ( IDataObject iface)
inlinestatic

Definition at line 181 of file datacache.c.

182 {
183  return CONTAINING_RECORD(iface, DataCache, IDataObject_iface);
184 }
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560

Referenced by DataCache_GetData(), DataCache_IDataObject_AddRef(), DataCache_IDataObject_QueryInterface(), DataCache_IDataObject_Release(), and DataCache_QueryGetData().

◆ impl_from_IOleCache2()

static DataCache* impl_from_IOleCache2 ( IOleCache2 iface)
inlinestatic

Definition at line 201 of file datacache.c.

202 {
203  return CONTAINING_RECORD(iface, DataCache, IOleCache2_iface);
204 }
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560

Referenced by DataCache_Cache(), DataCache_DiscardCache(), DataCache_EnumCache(), DataCache_IOleCache2_AddRef(), DataCache_IOleCache2_QueryInterface(), DataCache_IOleCache2_Release(), DataCache_IOleCache2_SetData(), DataCache_Uncache(), and DataCache_UpdateCache().

◆ impl_from_IOleCacheControl()

static DataCache* impl_from_IOleCacheControl ( IOleCacheControl iface)
inlinestatic

Definition at line 206 of file datacache.c.

207 {
208  return CONTAINING_RECORD(iface, DataCache, IOleCacheControl_iface);
209 }
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560

Referenced by DataCache_IOleCacheControl_AddRef(), DataCache_IOleCacheControl_QueryInterface(), DataCache_IOleCacheControl_Release(), DataCache_OnRun(), and DataCache_OnStop().

◆ impl_from_IPersistStorage()

static DataCache* impl_from_IPersistStorage ( IPersistStorage iface)
inlinestatic

Definition at line 191 of file datacache.c.

192 {
193  return CONTAINING_RECORD(iface, DataCache, IPersistStorage_iface);
194 }
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560

Referenced by DataCache_GetClassID(), DataCache_HandsOffStorage(), DataCache_InitNew(), DataCache_IPersistStorage_AddRef(), DataCache_IPersistStorage_QueryInterface(), DataCache_IPersistStorage_Release(), DataCache_IsDirty(), DataCache_Load(), and DataCache_Save().

◆ impl_from_IUnknown()

static DataCache* impl_from_IUnknown ( IUnknown iface)
inlinestatic

Definition at line 186 of file datacache.c.

187 {
188  return CONTAINING_RECORD(iface, DataCache, IUnknown_inner);
189 }
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560

Referenced by DataCache_NDIUnknown_AddRef(), DataCache_NDIUnknown_QueryInterface(), and DataCache_NDIUnknown_Release().

◆ impl_from_IViewObject2()

static DataCache* impl_from_IViewObject2 ( IViewObject2 iface)
inlinestatic

Definition at line 196 of file datacache.c.

197 {
198  return CONTAINING_RECORD(iface, DataCache, IViewObject2_iface);
199 }
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560

Referenced by DataCache_Draw(), DataCache_GetAdvise(), DataCache_GetExtent(), DataCache_IViewObject2_AddRef(), DataCache_IViewObject2_QueryInterface(), DataCache_IViewObject2_Release(), and DataCache_SetAdvise().

◆ init_cache_entry()

static BOOL init_cache_entry ( DataCacheEntry entry,
const FORMATETC *  fmt,
DWORD  advf,
DWORD  id 
)
static

Definition at line 361 of file datacache.c.

363 {
364  HRESULT hr;
365 
366  hr = copy_formatetc(&entry->fmtetc, fmt);
367  if (FAILED(hr)) return FALSE;
368 
369  entry->stgmedium.tymed = TYMED_NULL;
370  entry->stgmedium.pUnkForRelease = NULL;
371  entry->id = id;
372  entry->dirty = TRUE;
373  entry->load_stream_num = STREAM_NUMBER_NOT_SET;
374  entry->save_stream_num = STREAM_NUMBER_NOT_SET;
375  entry->sink_id = 0;
376  entry->advise_flags = advf;
377 
378  return TRUE;
379 }
HRESULT hr
Definition: shlfolder.c:183
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
static HRESULT copy_formatetc(FORMATETC *dst, const FORMATETC *src)
LONG HRESULT
Definition: typedefs.h:79
uint32_t entry
Definition: isohybrid.c:63
#define NULL
Definition: types.h:112
GLenum GLuint id
Definition: glext.h:5579
#define STREAM_NUMBER_NOT_SET
Definition: datacache.c:92
Definition: dsound.c:943

Referenced by DataCache_CreateEntry().

◆ init_stream_header()

static void init_stream_header ( DataCacheEntry entry,
PresentationDataHeader header 
)
static

Definition at line 863 of file datacache.c.

864 {
865  if (entry->fmtetc.ptd)
866  FIXME("ptd not serialized\n");
867  header->tdSize = sizeof(header->tdSize);
868  header->dvAspect = entry->fmtetc.dwAspect;
869  header->lindex = entry->fmtetc.lindex;
870  header->advf = entry->advise_flags;
871  header->unknown7 = 0;
872  header->dwObjectExtentX = 0;
873  header->dwObjectExtentY = 0;
874  header->dwSize = 0;
875 }
#define FIXME(fmt,...)
Definition: debug.h:111
uint32_t entry
Definition: isohybrid.c:63

Referenced by save_dib(), save_emf(), save_mfpict(), and save_view_cache().

◆ load_dib()

static HRESULT load_dib ( DataCacheEntry cache_entry,
IStream stm 
)
static

Definition at line 666 of file datacache.c.

667 {
668  HRESULT hr;
669  STATSTG stat;
670  BYTE *dib;
671  HGLOBAL hglobal;
672  ULONG read, info_size, bi_size;
675  CLIPFORMAT cf;
677  ULARGE_INTEGER current_pos;
678  static const LARGE_INTEGER offset_zero;
679 
680  hr = IStream_Stat( stm, &stat, STATFLAG_NONAME );
681  if (FAILED( hr )) return hr;
682 
683  if (cache_entry->load_stream_num != STREAM_NUMBER_CONTENTS)
684  {
685  hr = read_clipformat( stm, &cf );
686  if (hr != S_OK) return hr;
687  hr = IStream_Read( stm, &pres, sizeof(pres), &read );
688  if (hr != S_OK) return hr;
689  }
690  else
691  {
692  hr = IStream_Read( stm, &file, sizeof(BITMAPFILEHEADER), &read );
693  if (hr != S_OK) return hr;
694  }
695 
696  hr = IStream_Seek( stm, offset_zero, STREAM_SEEK_CUR, &current_pos );
697  if (FAILED( hr )) return hr;
698  stat.cbSize.QuadPart -= current_pos.QuadPart;
699 
700  hglobal = GlobalAlloc( GMEM_MOVEABLE, stat.cbSize.u.LowPart );
701  if (!hglobal) return E_OUTOFMEMORY;
702  dib = GlobalLock( hglobal );
703 
704  /* read first DWORD of BITMAPINFOHEADER */
705  hr = IStream_Read( stm, dib, sizeof(DWORD), &read );
706  if (hr != S_OK) goto fail;
707  bi_size = *(DWORD *)dib;
708  if (stat.cbSize.QuadPart < bi_size) goto fail;
709 
710  /* read rest of BITMAPINFOHEADER */
711  hr = IStream_Read( stm, dib + sizeof(DWORD), bi_size - sizeof(DWORD), &read );
712  if (hr != S_OK) goto fail;
713 
714  info_size = bitmap_info_size( (BITMAPINFO *)dib, DIB_RGB_COLORS );
715  if (stat.cbSize.QuadPart < info_size) goto fail;
716  if (info_size > bi_size)
717  {
718  hr = IStream_Read( stm, dib + bi_size, info_size - bi_size, &read );
719  if (hr != S_OK) goto fail;
720  }
721  stat.cbSize.QuadPart -= info_size;
722 
723  /* set Stream pointer to beginning of bitmap bits */
724  if (cache_entry->load_stream_num == STREAM_NUMBER_CONTENTS && file.bfOffBits)
725  {
727 
728  skip.QuadPart = file.bfOffBits - sizeof(file) - info_size;
729  if (stat.cbSize.QuadPart < skip.QuadPart) goto fail;
730  hr = IStream_Seek( stm, skip, STREAM_SEEK_CUR, NULL );
731  if (hr != S_OK) goto fail;
732  stat.cbSize.QuadPart -= skip.QuadPart;
733  }
734 
735  hr = IStream_Read( stm, dib + info_size, stat.cbSize.u.LowPart, &read );
736  if (hr != S_OK) goto fail;
737 
738  if (bi_size >= sizeof(*info))
739  {
741  if (info->biXPelsPerMeter == 0 || info->biYPelsPerMeter == 0)
742  {
743  HDC hdc = GetDC( 0 );
744  info->biXPelsPerMeter = MulDiv( GetDeviceCaps( hdc, LOGPIXELSX ), 10000, 254 );
745  info->biYPelsPerMeter = MulDiv( GetDeviceCaps( hdc, LOGPIXELSY ), 10000, 254 );
746  ReleaseDC( 0, hdc );
747  }
748  }
749 
750  GlobalUnlock( hglobal );
751 
752  cache_entry->stgmedium.tymed = TYMED_HGLOBAL;
753  cache_entry->stgmedium.u.hGlobal = hglobal;
754 
755  return hr;
756 
757 fail:
758  GlobalUnlock( hglobal );
759  GlobalFree( hglobal );
760  return hr;
761 
762 }
static IClassFactory * cf
#define LOGPIXELSX
Definition: wingdi.h:717
HGLOBAL NTAPI GlobalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:368
HRESULT hr
Definition: shlfolder.c:183
HDC WINAPI GetDC(_In_opt_ HWND)
static HDC
Definition: imagelist.c:92
Definition: svc_auth_des.c:77
#define STREAM_NUMBER_CONTENTS
Definition: datacache.c:93
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
LONG HRESULT
Definition: typedefs.h:79
static int bitmap_info_size(const BITMAPINFO *info, WORD coloruse)
Definition: datacache.c:228
const char file[]
Definition: icontest.c:11
unsigned long DWORD
Definition: ntddk_ex.h:95
HGLOBAL NTAPI GlobalFree(HGLOBAL hMem)
Definition: heapmem.c:611
struct _test_info info[]
Definition: SetCursorPos.c:19
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
HDC hdc
Definition: main.c:9
int WINAPI GetDeviceCaps(_In_opt_ HDC, _In_ int)
Definition: stat.h:55
unsigned char BYTE
Definition: xxhash.c:193
static HRESULT read_clipformat(IStream *stream, CLIPFORMAT *clipformat)
Definition: datacache.c:461
_CRTIMP int __cdecl stat(const char *_Filename, struct stat *_Stat)
Definition: stat.h:345
#define S_OK
Definition: intsafe.h:51
#define NULL
Definition: types.h:112
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
static const BYTE dib[]
Definition: ole2.c:201
#define skip(...)
Definition: atltest.h:64
unsigned int ULONG
Definition: retypes.h:1
#define LOGPIXELSY
Definition: wingdi.h:718
#define DIB_RGB_COLORS
Definition: wingdi.h:366
#define MulDiv(x, y, z)
Definition: gdifloat.h:86
#define GMEM_MOVEABLE
Definition: winbase.h:291
_CRTIMP int __cdecl read(_In_ int _FileHandle, _Out_writes_bytes_(_MaxCharCount) void *_DstBuf, _In_ unsigned int _MaxCharCount)
Definition: fci.c:126

Referenced by DataCacheEntry_LoadData().

◆ load_emf()

static HRESULT load_emf ( DataCacheEntry cache_entry,
IStream stm 
)
static

Definition at line 764 of file datacache.c.

765 {
766  HRESULT hr;
767 
768  if (cache_entry->load_stream_num != STREAM_NUMBER_CONTENTS)
769  {
770  STGMEDIUM stgmed;
771 
772  hr = load_mf_pict( cache_entry, stm );
773  if (SUCCEEDED( hr ))
774  {
775  hr = synthesize_emf( cache_entry->stgmedium.u.hMetaFilePict, &stgmed );
776  ReleaseStgMedium( &cache_entry->stgmedium );
777  }
778  if (SUCCEEDED( hr ))
779  cache_entry->stgmedium = stgmed;
780  }
781  else
782  {
783  STATSTG stat;
784  BYTE *data;
785  ULONG read, size_bits;
786 
787  hr = IStream_Stat( stm, &stat, STATFLAG_NONAME );
788 
789  if (SUCCEEDED( hr ))
790  {
791  data = HeapAlloc( GetProcessHeap(), 0, stat.cbSize.u.LowPart );
792  if (!data) return E_OUTOFMEMORY;
793 
794  hr = IStream_Read( stm, data, stat.cbSize.u.LowPart, &read );
795  if (hr != S_OK)
796  {
797  HeapFree( GetProcessHeap(), 0, data );
798  return hr;
799  }
800 
801  if (read <= sizeof(DWORD) + sizeof(ENHMETAHEADER))
802  {
803  HeapFree( GetProcessHeap(), 0, data );
804  return E_FAIL;
805  }
806  size_bits = read - sizeof(DWORD) - sizeof(ENHMETAHEADER);
807  cache_entry->stgmedium.u.hEnhMetaFile = SetEnhMetaFileBits( size_bits, data + (read - size_bits) );
808  cache_entry->stgmedium.tymed = TYMED_ENHMF;
809  cache_entry->stgmedium.pUnkForRelease = NULL;
810 
811  HeapFree( GetProcessHeap(), 0, data );
812  }
813  }
814 
815  return hr;
816 }
HRESULT hr
Definition: shlfolder.c:183
static HRESULT load_mf_pict(DataCacheEntry *cache_entry, IStream *stm)
Definition: datacache.c:584
void WINAPI ReleaseStgMedium(STGMEDIUM *pmedium)
Definition: ole2.c:2033
HENHMETAFILE WINAPI SetEnhMetaFileBits(_In_ UINT nSize, _In_reads_bytes_(nSize) const BYTE *pb)
Definition: svc_auth_des.c:77
#define E_FAIL
Definition: ddrawi.h:102
#define STREAM_NUMBER_CONTENTS
Definition: datacache.c:93
#define DWORD
Definition: nt_native.h:44
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
if SUCCEEDED(hr)
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
LONG HRESULT
Definition: typedefs.h:79
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
Definition: stat.h:55
unsigned char BYTE
Definition: xxhash.c:193
_CRTIMP int __cdecl stat(const char *_Filename, struct stat *_Stat)
Definition: stat.h:345
#define S_OK
Definition: intsafe.h:51
#define NULL
Definition: types.h:112
unsigned int ULONG
Definition: retypes.h:1
static HRESULT synthesize_emf(HMETAFILEPICT data, STGMEDIUM *med)
Definition: datacache.c:549
#define HeapFree(x, y, z)
Definition: compat.h:594
_CRTIMP int __cdecl read(_In_ int _FileHandle, _Out_writes_bytes_(_MaxCharCount) void *_DstBuf, _In_ unsigned int _MaxCharCount)

Referenced by DataCacheEntry_LoadData().

◆ load_mf_pict()

static HRESULT load_mf_pict ( DataCacheEntry cache_entry,
IStream stm 
)
static

Definition at line 584 of file datacache.c.

585 {
586  HRESULT hr;
587  STATSTG stat;
588  ULARGE_INTEGER current_pos;
589  void *bits;
590  METAFILEPICT *mfpict;
591  HGLOBAL hmfpict;
593  CLIPFORMAT clipformat;
594  static const LARGE_INTEGER offset_zero;
595  ULONG read;
596  struct meta_placeable mf_place;
597 
598  hr = IStream_Stat( stm, &stat, STATFLAG_NONAME );
599  if (FAILED( hr )) return hr;
600 
601  if (cache_entry->load_stream_num != STREAM_NUMBER_CONTENTS)
602  {
603  hr = read_clipformat( stm, &clipformat );
604  if (hr != S_OK) return hr;
605  hr = IStream_Read( stm, &header, sizeof(header), &read );
606  if (hr != S_OK) return hr;
607  }
608  else
609  {
610  hr = IStream_Read( stm, &mf_place, sizeof(mf_place), &read );
611  if (hr != S_OK) return hr;
612  }
613 
614  hr = IStream_Seek( stm, offset_zero, STREAM_SEEK_CUR, &current_pos );
615  if (FAILED( hr )) return hr;
616  stat.cbSize.QuadPart -= current_pos.QuadPart;
617 
618  hmfpict = GlobalAlloc( GMEM_MOVEABLE, sizeof(METAFILEPICT) );
619  if (!hmfpict) return E_OUTOFMEMORY;
620  mfpict = GlobalLock( hmfpict );
621 
622  bits = HeapAlloc( GetProcessHeap(), 0, stat.cbSize.u.LowPart);
623  if (!bits)
624  {
625  GlobalFree( hmfpict );
626  return E_OUTOFMEMORY;
627  }
628 
629  hr = IStream_Read( stm, bits, stat.cbSize.u.LowPart, &read );
630 
631  if (SUCCEEDED( hr ))
632  {
633  mfpict->mm = MM_ANISOTROPIC;
634  /* FIXME: get this from the stream */
635  if (cache_entry->load_stream_num != STREAM_NUMBER_CONTENTS)
636  {
637  mfpict->xExt = header.dwObjectExtentX;
638  mfpict->yExt = header.dwObjectExtentY;
639  }
640  else
641  {
642  mfpict->xExt = ((mf_place.bounding_box[2] - mf_place.bounding_box[0])
643  * 2540) / mf_place.inch;
644  mfpict->yExt = ((mf_place.bounding_box[3] - mf_place.bounding_box[1])
645  * 2540) / mf_place.inch;
646  }
647  mfpict->hMF = SetMetaFileBitsEx( stat.cbSize.u.LowPart, bits );
648  if (!mfpict->hMF)
649  hr = E_FAIL;
650  }
651 
652  GlobalUnlock( hmfpict );
653  if (SUCCEEDED( hr ))
654  {
655  cache_entry->stgmedium.tymed = TYMED_MFPICT;
656  cache_entry->stgmedium.u.hMetaFilePict = hmfpict;
657  }
658  else
659  GlobalFree( hmfpict );
660 
661  HeapFree( GetProcessHeap(), 0, bits );
662 
663  return hr;
664 }
HMETAFILE WINAPI SetMetaFileBitsEx(_In_ UINT cbBuffer, _In_reads_bytes_(cbBuffer) CONST BYTE *lpData)
HMETAFILE hMF
Definition: wingdi.h:2607
HGLOBAL NTAPI GlobalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:368
HRESULT hr
Definition: shlfolder.c:183
Definition: svc_auth_des.c:77
#define E_FAIL
Definition: ddrawi.h:102
#define STREAM_NUMBER_CONTENTS
Definition: datacache.c:93
GLenum GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * bits
Definition: glext.h:10929
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185
if SUCCEEDED(hr)
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
LONG HRESULT
Definition: typedefs.h:79
HGLOBAL NTAPI GlobalFree(HGLOBAL hMem)
Definition: heapmem.c:611
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
#define MM_ANISOTROPIC
Definition: wingdi.h:866
Definition: stat.h:55
static HRESULT read_clipformat(IStream *stream, CLIPFORMAT *clipformat)
Definition: datacache.c:461
_CRTIMP int __cdecl stat(const char *_Filename, struct stat *_Stat)
Definition: stat.h:345
#define S_OK
Definition: intsafe.h:51
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
unsigned int ULONG
Definition: retypes.h:1
#define HeapFree(x, y, z)
Definition: compat.h:594
#define GMEM_MOVEABLE
Definition: winbase.h:291
struct CFHEADER header
Definition: fdi.c:101
_CRTIMP int __cdecl read(_In_ int _FileHandle, _Out_writes_bytes_(_MaxCharCount) void *_DstBuf, _In_ unsigned int _MaxCharCount)

Referenced by DataCacheEntry_LoadData(), and load_emf().

◆ open_pres_stream()

static HRESULT open_pres_stream ( IStorage stg,
int  stream_number,
IStream **  stm 
)
static

Definition at line 535 of file datacache.c.

536 {
537  WCHAR pres[] = {2,'O','l','e','P','r','e','s',
538  '0' + (stream_number / 100) % 10,
539  '0' + (stream_number / 10) % 10,
540  '0' + stream_number % 10, 0};
541  const WCHAR *name = pres;
542 
543  if (stream_number == STREAM_NUMBER_NOT_SET) return E_FAIL;
544  if (stream_number == STREAM_NUMBER_CONTENTS) name = CONTENTS;
545 
546  return IStorage_OpenStream( stg, name, NULL, STGM_READ | STGM_SHARE_EXCLUSIVE, 0, stm );
547 }
#define STGM_SHARE_EXCLUSIVE
Definition: objbase.h:922
#define E_FAIL
Definition: ddrawi.h:102
#define STREAM_NUMBER_CONTENTS
Definition: datacache.c:93
#define STGM_READ
Definition: objbase.h:916
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NULL
Definition: types.h:112
Definition: name.c:38
static const WCHAR CONTENTS[]
Definition: datacache.c:533
#define STREAM_NUMBER_NOT_SET
Definition: datacache.c:92

Referenced by DataCacheEntry_LoadData(), parse_contents_stream(), and parse_pres_streams().

◆ parse_contents_stream()

static HRESULT parse_contents_stream ( DataCache cache,
IStorage stg 
)
static

Definition at line 1803 of file datacache.c.

1804 {
1805  HRESULT hr;
1806  IStream *stm;
1808 
1809  hr = open_pres_stream( stg, STREAM_NUMBER_CONTENTS, &stm );
1810  if (FAILED( hr )) return hr;
1811 
1813  if (hr == S_OK)
1814  {
1815  cache_entry->load_stream_num = STREAM_NUMBER_CONTENTS;
1816  cache_entry->save_stream_num = STREAM_NUMBER_CONTENTS;
1817  cache_entry->dirty = FALSE;
1818  }
1819 
1820  IStream_Release( stm );
1821  return hr;
1822 }
Definition: cache.c:48
HRESULT hr
Definition: shlfolder.c:183
Definition: svc_auth_des.c:77
#define STREAM_NUMBER_CONTENTS
Definition: datacache.c:93
#define FALSE
Definition: types.h:117
LONG HRESULT
Definition: typedefs.h:79
static HRESULT get_static_entry(DataCache *cache, DataCacheEntry **cache_entry)
Definition: datacache.c:316
#define S_OK
Definition: intsafe.h:51
static HRESULT open_pres_stream(IStorage *stg, int stream_number, IStream **stm)
Definition: datacache.c:535

Referenced by DataCache_Load().

◆ parse_pres_streams()

static HRESULT parse_pres_streams ( DataCache cache,
IStorage stg 
)
static

Definition at line 1767 of file datacache.c.

1768 {
1769  HRESULT hr;
1770  IStream *stm;
1772  ULONG actual_read;
1773  CLIPFORMAT clipformat;
1774  FORMATETC fmtetc;
1775  int stream_number = 0;
1776 
1777  do
1778  {
1779  hr = open_pres_stream( stg, stream_number, &stm );
1780  if (FAILED(hr)) break;
1781 
1782  hr = read_clipformat( stm, &clipformat );
1783 
1784  if (hr == S_OK) hr = IStream_Read( stm, &header, sizeof(header), &actual_read );
1785 
1786  if (hr == S_OK && actual_read == sizeof(header))
1787  {
1788  fmtetc.cfFormat = clipformat;
1789  fmtetc.ptd = NULL; /* FIXME */
1790  fmtetc.dwAspect = header.dvAspect;
1791  fmtetc.lindex = header.lindex;
1792  fmtetc.tymed = tymed_from_cf( clipformat );
1793 
1794  add_cache_entry( cache, &fmtetc, header.advf, stream_number );
1795  }
1796  IStream_Release( stm );
1797  stream_number++;
1798  } while (hr == S_OK);
1799 
1800  return S_OK;
1801 }
Definition: cache.c:48
HRESULT hr
Definition: shlfolder.c:183
static HRESULT add_cache_entry(DataCache *This, const FORMATETC *fmt, DWORD advf, int stream_number)
Definition: datacache.c:1747
LONG HRESULT
Definition: typedefs.h:79
static DWORD tymed_from_cf(DWORD cf)
Definition: datacache.c:1292
static HRESULT read_clipformat(IStream *stream, CLIPFORMAT *clipformat)
Definition: datacache.c:461
#define S_OK
Definition: intsafe.h:51
#define NULL
Definition: types.h:112
unsigned int ULONG
Definition: retypes.h:1
static HRESULT open_pres_stream(IStorage *stg, int stream_number, IStream **stm)
Definition: datacache.c:535
struct CFHEADER header
Definition: fdi.c:101

Referenced by DataCache_Load().

◆ read_clipformat()

static HRESULT read_clipformat ( IStream stream,
CLIPFORMAT *  clipformat 
)
static

Definition at line 461 of file datacache.c.

462 {
463  DWORD length;
464  HRESULT hr;
465  ULONG read;
466 
467  *clipformat = 0;
468 
469  hr = IStream_Read(stream, &length, sizeof(length), &read);
470  if (hr != S_OK || read != sizeof(length))
471  return DV_E_CLIPFORMAT;
472  if (!length) {
473  /* No clipboard format present */
474  return S_OK;
475  }
476  if (length == -1)
477  {
478  DWORD cf;
479  hr = IStream_Read(stream, &cf, sizeof(cf), &read);
480  if (hr != S_OK || read != sizeof(cf))
481  return DV_E_CLIPFORMAT;
482  *clipformat = cf;
483  }
484  else
485  {
486  char *format_name = HeapAlloc(GetProcessHeap(), 0, length);
487  if (!format_name)
488  return E_OUTOFMEMORY;
489  hr = IStream_Read(stream, format_name, length, &read);
490  if (hr != S_OK || read != length || format_name[length - 1] != '\0')
491  {
492  HeapFree(GetProcessHeap(), 0, format_name);
493  return DV_E_CLIPFORMAT;
494  }
495  *clipformat = RegisterClipboardFormatA(format_name);
496  HeapFree(GetProcessHeap(), 0, format_name);
497  }
498  return S_OK;
499 }
static IClassFactory * cf
HRESULT hr
Definition: shlfolder.c:183
#define DV_E_CLIPFORMAT
Definition: winerror.h:2639
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
LONG HRESULT
Definition: typedefs.h:79
unsigned long DWORD
Definition: ntddk_ex.h:95
Definition: parse.h:22
UINT WINAPI RegisterClipboardFormatA(_In_ LPCSTR)
#define S_OK
Definition: intsafe.h:51
unsigned int ULONG
Definition: retypes.h:1
#define HeapFree(x, y, z)
Definition: compat.h:594
_CRTIMP int __cdecl read(_In_ int _FileHandle, _Out_writes_bytes_(_MaxCharCount) void *_DstBuf, _In_ unsigned int _MaxCharCount)

Referenced by load_dib(), load_mf_pict(), and parse_pres_streams().

◆ save_dib()

static HRESULT save_dib ( DataCacheEntry entry,
BOOL  contents,
IStream stream 
)
static

Definition at line 877 of file datacache.c.

878 {
879  HRESULT hr = S_OK;
880  int data_size = 0;
881  BITMAPINFO *bmi = NULL;
882 
883  if (entry->stgmedium.tymed != TYMED_NULL)
884  {
885  data_size = GlobalSize(entry->stgmedium.u.hGlobal);
886  bmi = GlobalLock(entry->stgmedium.u.hGlobal);
887  }
888 
889  if (!contents)
890  {
892 
894  hr = write_clipformat(stream, entry->fmtetc.cfFormat);
895  if (FAILED(hr)) goto end;
896  if (data_size)
897  {
898  header.dwSize = data_size;
899  /* Size in units of 0.01mm (ie. MM_HIMETRIC) */
900  if (bmi->bmiHeader.biXPelsPerMeter != 0 && bmi->bmiHeader.biYPelsPerMeter != 0)
901  {
902  header.dwObjectExtentX = MulDiv(bmi->bmiHeader.biWidth, 100000, bmi->bmiHeader.biXPelsPerMeter);
903  header.dwObjectExtentY = MulDiv(bmi->bmiHeader.biHeight, 100000, bmi->bmiHeader.biYPelsPerMeter);
904  }
905  else
906  {
907  HDC hdc = GetDC(0);
908  header.dwObjectExtentX = MulDiv(bmi->bmiHeader.biWidth, 2540, GetDeviceCaps(hdc, LOGPIXELSX));
909  header.dwObjectExtentY = MulDiv(bmi->bmiHeader.biHeight, 2540, GetDeviceCaps(hdc, LOGPIXELSY));
910  ReleaseDC(0, hdc);
911  }
912  }
913  hr = IStream_Write(stream, &header, sizeof(PresentationDataHeader), NULL);
914  if (hr == S_OK && data_size)
915  hr = IStream_Write(stream, bmi, data_size, NULL);
916  }
917  else if(data_size)
918  {
919  BITMAPFILEHEADER bmp_fhdr;
920 
921  bmp_fhdr.bfType = 0x4d42;
922  bmp_fhdr.bfSize = data_size + sizeof(BITMAPFILEHEADER);
923  bmp_fhdr.bfReserved1 = bmp_fhdr.bfReserved2 = 0;
924  bmp_fhdr.bfOffBits = bitmap_info_size(bmi, DIB_RGB_COLORS) + sizeof(BITMAPFILEHEADER);
925  hr = IStream_Write(stream, &bmp_fhdr, sizeof(BITMAPFILEHEADER), NULL);
926  if (hr == S_OK)
927  hr = IStream_Write(stream, bmi, data_size, NULL);
928  }
929 
930 end:
931  if (bmi) GlobalUnlock(entry->stgmedium.u.hGlobal);
932  return hr;
933 }
#define LOGPIXELSX
Definition: wingdi.h:717
BITMAPINFOHEADER bmiHeader
Definition: wingdi.h:1475
HRESULT hr
Definition: shlfolder.c:183
HDC WINAPI GetDC(_In_opt_ HWND)
LONG biXPelsPerMeter
Definition: amvideo.idl:37
static HDC
Definition: imagelist.c:92
LONG biYPelsPerMeter
Definition: amvideo.idl:38
static HRESULT write_clipformat(IStream *stream, CLIPFORMAT clipformat)
Definition: datacache.c:501
SIZE_T NTAPI GlobalSize(HGLOBAL hMem)
Definition: heapmem.c:1090
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
LONG HRESULT
Definition: typedefs.h:79
static int bitmap_info_size(const BITMAPINFO *info, WORD coloruse)
Definition: datacache.c:228
GLuint GLuint end
Definition: gl.h:1545
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
Definition: parse.h:22
HDC hdc
Definition: main.c:9
int WINAPI GetDeviceCaps(_In_opt_ HDC, _In_ int)
uint32_t entry
Definition: isohybrid.c:63
#define S_OK
Definition: intsafe.h:51
struct tagBITMAPFILEHEADER BITMAPFILEHEADER
#define NULL
Definition: types.h:112
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
#define LOGPIXELSY
Definition: wingdi.h:718
#define DIB_RGB_COLORS
Definition: wingdi.h:366
static void init_stream_header(DataCacheEntry *entry, PresentationDataHeader *header)
Definition: datacache.c:863
#define MulDiv(x, y, z)
Definition: gdifloat.h:86
struct CFHEADER header
Definition: fdi.c:101

Referenced by DataCacheEntry_Save().

◆ save_emf()

static HRESULT save_emf ( DataCacheEntry entry,
BOOL  contents,
IStream stream 
)
static

Definition at line 1016 of file datacache.c.

1017 {
1018  HRESULT hr = S_OK;
1019  int data_size = 0;
1020  BYTE *data;
1021 
1022  if (!contents)
1023  {
1025  METAFILEPICT *mfpict;
1026  HDC hdc = GetDC(0);
1027 
1029  hr = write_clipformat(stream, entry->fmtetc.cfFormat);
1030  if (FAILED(hr))
1031  {
1032  ReleaseDC(0, hdc);
1033  return hr;
1034  }
1035  data_size = GetWinMetaFileBits(entry->stgmedium.u.hEnhMetaFile, 0, NULL, MM_ANISOTROPIC, hdc);
1036  header.dwSize = data_size;
1037  data = HeapAlloc(GetProcessHeap(), 0, header.dwSize);
1038  if (!data)
1039  {
1040  ReleaseDC(0, hdc);
1041  return E_OUTOFMEMORY;
1042  }
1043  GetWinMetaFileBits(entry->stgmedium.u.hEnhMetaFile, header.dwSize, data, MM_ANISOTROPIC, hdc);
1044  ReleaseDC(0, hdc);
1045  mfpict = (METAFILEPICT *)data;
1046  header.dwObjectExtentX = mfpict->xExt;
1047  header.dwObjectExtentY = mfpict->yExt;
1048  hr = IStream_Write(stream, &header, sizeof(PresentationDataHeader), NULL);
1049  if (hr == S_OK && data_size)
1050  hr = IStream_Write(stream, data, data_size, NULL);
1051  HeapFree(GetProcessHeap(), 0, data);
1052  }
1053  else if (entry->stgmedium.tymed != TYMED_NULL)
1054  {
1055  data_size = GetEnhMetaFileBits(entry->stgmedium.u.hEnhMetaFile, 0, NULL);
1056  data = HeapAlloc(GetProcessHeap(), 0, sizeof(DWORD) + sizeof(ENHMETAHEADER) + data_size);
1057  if (!data) return E_OUTOFMEMORY;
1058  *((DWORD *)data) = sizeof(ENHMETAHEADER);
1059  GetEnhMetaFileBits(entry->stgmedium.u.hEnhMeta