ReactOS  0.4.13-dev-249-gcba1a2f
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/unicode.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 94 of file datacache.c.

◆ STREAM_NUMBER_NOT_SET

#define STREAM_NUMBER_NOT_SET   -2

Definition at line 93 of file datacache.c.

Typedef Documentation

◆ DataCache

Definition at line 173 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 1748 of file datacache.c.

1749 {
1751  HRESULT hr = S_OK;
1752 
1753  TRACE( "loading entry with formatetc: %s\n", debugstr_formatetc( fmt ) );
1754 
1756  if (!cache_entry)
1758  if (SUCCEEDED( hr ))
1759  {
1761  cache_entry->load_stream_num = stream_number;
1762  cache_entry->save_stream_num = stream_number;
1763  cache_entry->dirty = FALSE;
1764  }
1765  return hr;
1766 }
HRESULT hr
Definition: shlfolder.c:183
Definition: svc_auth_des.c:77
static DataCacheEntry * DataCache_GetEntryForFormatEtc(DataCache *This, const FORMATETC *formatetc)
Definition: datacache.c:292
const char * debugstr_formatetc(const FORMATETC *formatetc)
Definition: datacache.c:217
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:77
#define S_OK
Definition: intsafe.h:59
static HRESULT DataCache_CreateEntry(DataCache *This, const FORMATETC *formatetc, DWORD advf, BOOL automatic, DataCacheEntry **cache_entry)
Definition: datacache.c:382
static HRESULT DataCacheEntry_DiscardData(DataCacheEntry *cache_entry)
Definition: datacache.c:1287
Definition: dsound.c:943
#define SUCCEEDED(hr)
Definition: intsafe.h:57

Referenced by parse_pres_streams().

◆ bitmap_info_size()

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

Definition at line 229 of file datacache.c.

230 {
231  unsigned int colors, size, masks = 0;
232 
233  if (info->bmiHeader.biSize == sizeof(BITMAPCOREHEADER))
234  {
235  const BITMAPCOREHEADER *core = (const BITMAPCOREHEADER *)info;
236  colors = (core->bcBitCount <= 8) ? 1 << core->bcBitCount : 0;
237  return sizeof(BITMAPCOREHEADER) + colors *
238  ((coloruse == DIB_RGB_COLORS) ? sizeof(RGBTRIPLE) : sizeof(WORD));
239  }
240  else /* assume BITMAPINFOHEADER */
241  {
242  colors = info->bmiHeader.biClrUsed;
243  if (colors > 256) /* buffer overflow otherwise */
244  colors = 256;
245  if (!colors && (info->bmiHeader.biBitCount <= 8))
246  colors = 1 << info->bmiHeader.biBitCount;
247  if (info->bmiHeader.biCompression == BI_BITFIELDS) masks = 3;
248  size = max( info->bmiHeader.biSize, sizeof(BITMAPINFOHEADER) + masks * sizeof(DWORD) );
249  return size + colors * ((coloruse == DIB_RGB_COLORS) ? sizeof(RGBQUAD) : sizeof(WORD));
250  }
251 }
#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
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 341 of file datacache.c.

342 {
343  /* DVASPECT_ICON must be CF_METAFILEPICT */
344  if (fmt->dwAspect == DVASPECT_ICON && fmt->cfFormat != CF_METAFILEPICT)
345  return DV_E_FORMATETC;
346 
347  if (!fmt->cfFormat ||
348  (fmt->cfFormat == CF_METAFILEPICT && fmt->tymed == TYMED_MFPICT) ||
349  (fmt->cfFormat == CF_BITMAP && fmt->tymed == TYMED_GDI) ||
350  (fmt->cfFormat == CF_DIB && fmt->tymed == TYMED_HGLOBAL) ||
351  (fmt->cfFormat == CF_ENHMETAFILE && fmt->tymed == TYMED_ENHMF))
352  return S_OK;
353  else if (fmt->tymed == TYMED_HGLOBAL)
355  else
356  {
357  WARN("invalid clipformat/tymed combination: %d/%d\n", fmt->cfFormat, fmt->tymed);
358  return DV_E_TYMED;
359  }
360 }
#define CF_ENHMETAFILE
Definition: constants.h:409
#define WARN(fmt,...)
Definition: debug.h:111
#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:59
#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 1140 of file datacache.c.

1142 {
1143  if (src_stgm->tymed == TYMED_MFPICT)
1144  {
1145  const METAFILEPICT *src_mfpict = GlobalLock(src_stgm->u.hMetaFilePict);
1146  METAFILEPICT *dest_mfpict;
1147 
1148  if (!src_mfpict)
1149  return DV_E_STGMEDIUM;
1150  dest_stgm->u.hMetaFilePict = GlobalAlloc(GMEM_MOVEABLE, sizeof(METAFILEPICT));
1151  dest_mfpict = GlobalLock(dest_stgm->u.hMetaFilePict);
1152  if (!dest_mfpict)
1153  {
1154  GlobalUnlock(src_stgm->u.hMetaFilePict);
1155  return E_OUTOFMEMORY;
1156  }
1157  *dest_mfpict = *src_mfpict;
1158  dest_mfpict->hMF = CopyMetaFileW(src_mfpict->hMF, NULL);
1159  GlobalUnlock(src_stgm->u.hMetaFilePict);
1160  GlobalUnlock(dest_stgm->u.hMetaFilePict);
1161  }
1162  else if (src_stgm->tymed != TYMED_NULL)
1163  {
1164  dest_stgm->u.hGlobal = OleDuplicateData(src_stgm->u.hGlobal, cf,
1165  GMEM_MOVEABLE);
1166  if (!dest_stgm->u.hGlobal)
1167  return E_OUTOFMEMORY;
1168  }
1169  dest_stgm->tymed = src_stgm->tymed;
1170  dest_stgm->pUnkForRelease = src_stgm->pUnkForRelease;
1171  if (dest_stgm->pUnkForRelease)
1172  IUnknown_AddRef(dest_stgm->pUnkForRelease);
1173  return S_OK;
1174 }
HMETAFILE hMF
Definition: wingdi.h:2586
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
smooth NULL
Definition: ftsmooth.c:416
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
#define S_OK
Definition: intsafe.h:59
HMETAFILE WINAPI CopyMetaFileW(_In_ HMETAFILE hmfSrc, _In_opt_ LPCWSTR pszFile)
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 1313 of file datacache.c.

1314 {
1315  static const struct data
1316  {
1317  const CLSID *clsid;
1318  FORMATETC fmt;
1319  } data[] =
1320  {
1321  { &CLSID_Picture_Dib, { CF_DIB, 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL } },
1322  { &CLSID_Picture_Metafile, { CF_METAFILEPICT, 0, DVASPECT_CONTENT, -1, TYMED_MFPICT } },
1323  { &CLSID_Picture_EnhMetafile, { CF_ENHMETAFILE, 0, DVASPECT_CONTENT, -1, TYMED_ENHMF } },
1324  { NULL }
1325  };
1326  const struct data *ptr = data;
1327  struct list *head;
1329 
1330  if (IsEqualCLSID( &cache->clsid, clsid )) return S_OK;
1331 
1332  /* move and reassign any pre-existing automatic entry */
1333  if ((head = list_head( &cache->cache_list )))
1334  {
1336  if (entry->id == 1)
1337  {
1338  list_remove( &entry->entry );
1339  entry->id = cache->last_cache_id++;
1340  list_add_tail( &cache->cache_list, &entry->entry );
1341  }
1342  }
1343 
1344  while (ptr->clsid)
1345  {
1346  if (IsEqualCLSID( clsid, ptr->clsid ))
1347  {
1348  cache->clsid_static = TRUE;
1349  return DataCache_CreateEntry( cache, &ptr->fmt, 0, TRUE, NULL );
1350  }
1351  ptr++;
1352  }
1353  cache->clsid_static = FALSE;
1354  return S_OK;
1355 }
Definition: cache.c:46
#define TRUE
Definition: types.h:120
#define CF_ENHMETAFILE
Definition: constants.h:409
struct outqueuenode * head
Definition: adnsresfilter.c:66
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
static PVOID ptr
Definition: dispmode.c:27
smooth NULL
Definition: ftsmooth.c:416
__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:84
uint32_t entry
Definition: isohybrid.c:63
Definition: _list.h:228
#define S_OK
Definition: intsafe.h:59
const CLSID CLSID_Picture_Metafile
static HRESULT DataCache_CreateEntry(DataCache *This, const FORMATETC *formatetc, DWORD advf, BOOL automatic, DataCacheEntry **cache_entry)
Definition: datacache.c:382
#define LIST_ENTRY(type)
Definition: queue.h:175
#define IsEqualCLSID(rclsid1, rclsid2)
Definition: guiddef.h:91
#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 1083 of file datacache.c.

1085 {
1086  WCHAR pres[] = {2,'O','l','e','P','r','e','s',
1087  '0' + (cache_entry->save_stream_num / 100) % 10,
1088  '0' + (cache_entry->save_stream_num / 10) % 10,
1089  '0' + cache_entry->save_stream_num % 10, 0};
1090  const WCHAR *name;
1091 
1092  if (contents)
1093  name = CONTENTS;
1094  else
1095  name = pres;
1096 
1097  return IStorage_CreateStream(storage, name,
1099  0, 0, stream);
1100 }
#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:36
static const WCHAR CONTENTS[]
Definition: datacache.c:534
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 3036 of file datacache.c.

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

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 2440 of file datacache.c.

2445 {
2448  HRESULT hr;
2449  FORMATETC fmt_cpy;
2450 
2451  TRACE("(%p, 0x%x, %p)\n", pformatetc, advf, pdwConnection);
2452 
2453  if (!pformatetc || !pdwConnection)
2454  return E_INVALIDARG;
2455 
2456  TRACE("pformatetc = %s\n", debugstr_formatetc(pformatetc));
2457 
2458  fmt_cpy = *pformatetc; /* No need for a deep copy */
2459  if (fmt_cpy.cfFormat == CF_BITMAP && fmt_cpy.tymed == TYMED_GDI)
2460  {
2461  fmt_cpy.cfFormat = CF_DIB;
2462  fmt_cpy.tymed = TYMED_HGLOBAL;
2463  }
2464 
2465  /* View caching DVASPECT_ICON gets converted to CF_METAFILEPICT */
2466  if (fmt_cpy.dwAspect == DVASPECT_ICON && fmt_cpy.cfFormat == 0)
2467  {
2468  fmt_cpy.cfFormat = CF_METAFILEPICT;
2469  fmt_cpy.tymed = TYMED_MFPICT;
2470  }
2471 
2472  *pdwConnection = 0;
2473 
2475  if (cache_entry)
2476  {
2477  TRACE("found an existing cache entry\n");
2478  *pdwConnection = cache_entry->id;
2479  return CACHE_S_SAMECACHE;
2480  }
2481 
2482  if (This->clsid_static && fmt_cpy.dwAspect != DVASPECT_ICON) return DV_E_FORMATETC;
2483 
2484  hr = DataCache_CreateEntry(This, &fmt_cpy, advf, FALSE, &cache_entry);
2485 
2486  if (SUCCEEDED(hr))
2487  {
2488  *pdwConnection = cache_entry->id;
2490  }
2491 
2492  return hr;
2493 }
HRESULT hr
Definition: shlfolder.c:183
static DataCache * impl_from_IOleCache2(IOleCache2 *iface)
Definition: datacache.c:202
#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:292
const char * debugstr_formatetc(const FORMATETC *formatetc)
Definition: datacache.c:217
#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:77
static HRESULT setup_sink(DataCache *This, DataCacheEntry *cache_entry)
Definition: datacache.c:2425
#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:382
#define SUCCEEDED(hr)
Definition: intsafe.h:57
#define CF_DIB
Definition: constants.h:403

◆ DataCache_Construct()

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

Definition at line 2968 of file datacache.c.

2971 {
2972  DataCache* newObject = 0;
2973 
2974  /*
2975  * Allocate space for the object.
2976  */
2977  newObject = HeapAlloc(GetProcessHeap(), 0, sizeof(DataCache));
2978 
2979  if (newObject==0)
2980  return newObject;
2981 
2982  /*
2983  * Initialize the virtual function table.
2984  */
2985  newObject->IDataObject_iface.lpVtbl = &DataCache_IDataObject_VTable;
2986  newObject->IUnknown_inner.lpVtbl = &DataCache_NDIUnknown_VTable;
2989  newObject->IOleCache2_iface.lpVtbl = &DataCache_IOleCache2_VTable;
2991  newObject->IAdviseSink_iface.lpVtbl = &DataCache_IAdviseSink_VTable;
2992  newObject->outer_unk = pUnkOuter ? pUnkOuter : &newObject->IUnknown_inner;
2993  newObject->ref = 1;
2994 
2995  /*
2996  * Initialize the other members of the structure.
2997  */
2998  newObject->sinkAspects = 0;
2999  newObject->sinkAdviseFlag = 0;
3000  newObject->sinkInterface = 0;
3001  newObject->clsid = CLSID_NULL;
3002  newObject->clsid_static = FALSE;
3003  newObject->presentationStorage = NULL;
3004  list_init(&newObject->cache_list);
3005  newObject->last_cache_id = 2;
3006  newObject->dirty = FALSE;
3007  newObject->running_object = NULL;
3008 
3009  create_automatic_entry( newObject, clsid );
3010  newObject->clsid = *clsid;
3011 
3012  return newObject;
3013 }
CLSID clsid
Definition: datacache.c:157
BOOL dirty
Definition: datacache.c:168
IUnknown * outer_unk
Definition: datacache.c:146
static const IOleCacheControlVtbl DataCache_IOleCacheControl_VTable
Definition: datacache.c:2944
IAdviseSink IAdviseSink_iface
Definition: datacache.c:136
IViewObject2 IViewObject2_iface
Definition: datacache.c:130
IPersistStorage IPersistStorage_iface
Definition: datacache.c:129
static const IDataObjectVtbl DataCache_IDataObject_VTable
Definition: datacache.c:2886
IDataObject IDataObject_iface
Definition: datacache.c:128
smooth NULL
Definition: ftsmooth.c:416
DWORD last_cache_id
Definition: datacache.c:166
static const IPersistStorageVtbl DataCache_IPersistStorage_VTable
Definition: datacache.c:2902
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define CLSID_NULL
Definition: guiddef.h:94
struct list cache_list
Definition: datacache.c:164
BOOL clsid_static
Definition: datacache.c:159
REFCLSID clsid
Definition: msctf.c:84
DWORD sinkAdviseFlag
Definition: datacache.c:154
static const IUnknownVtbl DataCache_NDIUnknown_VTable
Definition: datacache.c:2879
DWORD sinkAspects
Definition: datacache.c:153
LONG ref
Definition: datacache.c:141
static const IViewObject2Vtbl DataCache_IViewObject2_VTable
Definition: datacache.c:2916
IUnknown IUnknown_inner
Definition: datacache.c:127
__WINE_SERVER_LIST_INLINE void list_init(struct list *list)
Definition: list.h:149
IDataObject * running_object
Definition: datacache.c:170
static HRESULT create_automatic_entry(DataCache *cache, const CLSID *clsid)
Definition: datacache.c:1313
IStorage * presentationStorage
Definition: datacache.c:161
IOleCacheControl IOleCacheControl_iface
Definition: datacache.c:132
static const IOleCache2Vtbl DataCache_IOleCache2_VTable
Definition: datacache.c:2930
static const IAdviseSinkVtbl DataCache_IAdviseSink_VTable
Definition: datacache.c:2953
IOleCache2 IOleCache2_iface
Definition: datacache.c:131
IAdviseSink * sinkInterface
Definition: datacache.c:155

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 382 of file datacache.c.

384 {
385  HRESULT hr;
386  DWORD id = automatic ? 1 : This->last_cache_id;
388 
389  hr = check_valid_formatetc( formatetc );
390  if (FAILED(hr))
391  return hr;
393  TRACE("creating unsupported format %d\n", formatetc->cfFormat);
394 
395  entry = HeapAlloc(GetProcessHeap(), 0, sizeof(*entry));
396  if (!entry)
397  return E_OUTOFMEMORY;
398 
399  if (!init_cache_entry(entry, formatetc, advf, id))
400  goto fail;
401 
402  if (automatic)
403  list_add_head(&This->cache_list, &entry->entry);
404  else
405  {
406  list_add_tail(&This->cache_list, &entry->entry);
407  This->last_cache_id++;
408  }
409 
410  if (cache_entry) *cache_entry = entry;
411  return hr;
412 
413 fail:
415  return E_OUTOFMEMORY;
416 }
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:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
LONG HRESULT
Definition: typedefs.h:77
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:341
#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:362
#define HeapFree(x, y, z)
Definition: compat.h:394

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 1599 of file datacache.c.

1605 {
1606  TRACE("()\n");
1607  return OLE_E_ADVISENOTSUPPORTED;
1608 }
#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 264 of file datacache.c.

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

Referenced by DataCache_NDIUnknown_Release().

◆ DataCache_DiscardCache()

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

Definition at line 2703 of file datacache.c.

2706 {
2709  HRESULT hr = S_OK;
2710 
2711  TRACE("(%d)\n", dwDiscardOptions);
2712 
2713  if (dwDiscardOptions == DISCARDCACHE_SAVEIFDIRTY)
2714  hr = DataCache_Save(&This->IPersistStorage_iface, This->presentationStorage, TRUE);
2715 
2717  {
2719  if (FAILED(hr))
2720  break;
2721  }
2722 
2723  return hr;
2724 }
#define TRUE
Definition: types.h:120
HRESULT hr
Definition: shlfolder.c:183
static DataCache * impl_from_IOleCache2(IOleCache2 *iface)
Definition: datacache.c:202
static HRESULT WINAPI DataCache_Save(IPersistStorage *iface, IStorage *stg, BOOL same_as_load)
Definition: datacache.c:1880
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:77
uint32_t entry
Definition: isohybrid.c:63
#define S_OK
Definition: intsafe.h:59
static HRESULT DataCacheEntry_DiscardData(DataCacheEntry *cache_entry)
Definition: datacache.c:1287

◆ 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 2007 of file datacache.c.

2019 {
2021  HRESULT hres;
2023 
2024  TRACE("(%p, %x, %d, %p, %p, %p, %p, %p, %p, %lx)\n",
2025  iface,
2026  dwDrawAspect,
2027  lindex,
2028  pvAspect,
2029  hdcTargetDev,
2030  hdcDraw,
2031  lprcBounds,
2032  lprcWBounds,
2033  pfnContinue,
2034  dwContinue);
2035 
2036  if (lprcBounds==NULL)
2037  return E_INVALIDARG;
2038 
2040  {
2041  /* FIXME: compare ptd too */
2042  if ((cache_entry->fmtetc.dwAspect != dwDrawAspect) ||
2043  (cache_entry->fmtetc.lindex != lindex))
2044  continue;
2045 
2046  /* if the data hasn't been loaded yet, do it now */
2047  if ((cache_entry->stgmedium.tymed == TYMED_NULL) && (cache_entry->load_stream_num != STREAM_NUMBER_NOT_SET))
2048  {
2049  hres = DataCacheEntry_LoadData(cache_entry, This->presentationStorage);
2050  if (FAILED(hres))
2051  continue;
2052  }
2053 
2054  /* no data */
2055  if (cache_entry->stgmedium.tymed == TYMED_NULL)
2056  continue;
2057 
2058  if (pfnContinue && !pfnContinue(dwContinue)) return E_ABORT;
2059 
2060  switch (cache_entry->fmtetc.cfFormat)
2061  {
2062  case CF_METAFILEPICT:
2063  {
2064  /*
2065  * We have to be careful not to modify the state of the
2066  * DC.
2067  */
2068  INT prevMapMode;
2069  SIZE oldWindowExt;
2070  SIZE oldViewportExt;
2071  POINT oldViewportOrg;
2072  METAFILEPICT *mfpict;
2073 
2074  if ((cache_entry->stgmedium.tymed != TYMED_MFPICT) ||
2075  !((mfpict = GlobalLock(cache_entry->stgmedium.u.hMetaFilePict))))
2076  continue;
2077 
2078  prevMapMode = SetMapMode(hdcDraw, mfpict->mm);
2079 
2080  SetWindowExtEx(hdcDraw,
2081  mfpict->xExt,
2082  mfpict->yExt,
2083  &oldWindowExt);
2084 
2085  SetViewportExtEx(hdcDraw,
2086  lprcBounds->right - lprcBounds->left,
2087  lprcBounds->bottom - lprcBounds->top,
2088  &oldViewportExt);
2089 
2090  SetViewportOrgEx(hdcDraw,
2091  lprcBounds->left,
2092  lprcBounds->top,
2093  &oldViewportOrg);
2094 
2095  PlayMetaFile(hdcDraw, mfpict->hMF);
2096 
2097  SetWindowExtEx(hdcDraw,
2098  oldWindowExt.cx,
2099  oldWindowExt.cy,
2100  NULL);
2101 
2102  SetViewportExtEx(hdcDraw,
2103  oldViewportExt.cx,
2104  oldViewportExt.cy,
2105  NULL);
2106 
2107  SetViewportOrgEx(hdcDraw,
2108  oldViewportOrg.x,
2109  oldViewportOrg.y,
2110  NULL);
2111 
2112  SetMapMode(hdcDraw, prevMapMode);
2113 
2114  GlobalUnlock(cache_entry->stgmedium.u.hMetaFilePict);
2115 
2116  return S_OK;
2117  }
2118  case CF_DIB:
2119  {
2120  BITMAPINFO *info;
2121  BYTE *bits;
2122 
2123  if ((cache_entry->stgmedium.tymed != TYMED_HGLOBAL) ||
2124  !((info = GlobalLock( cache_entry->stgmedium.u.hGlobal ))))
2125  continue;
2126 
2128  StretchDIBits( hdcDraw, lprcBounds->left, lprcBounds->top,
2129  lprcBounds->right - lprcBounds->left, lprcBounds->bottom - lprcBounds->top,
2130  0, 0, info->bmiHeader.biWidth, info->bmiHeader.biHeight,
2132 
2133  GlobalUnlock( cache_entry->stgmedium.u.hGlobal );
2134  return S_OK;
2135  }
2136  }
2137  }
2138 
2139  WARN("no data could be found to be drawn\n");
2140 
2141  return OLE_E_BLANK;
2142 }
static DataCache * impl_from_IViewObject2(IViewObject2 *iface)
Definition: datacache.c:197
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:2586
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:111
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:56
struct _test_info info[]
Definition: SetCursorPos.c:19
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
smooth NULL
Definition: ftsmooth.c:416
LONG cx
Definition: windef.h:319
long left
Definition: polytest.cpp:53
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
static int bitmap_info_size(const BITMAPINFO *info, WORD coloruse)
Definition: datacache.c:229
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
uint32_t entry
Definition: isohybrid.c:63
unsigned char BYTE
Definition: mem.h:68
#define E_ABORT
Definition: winerror.h:2366
#define S_OK
Definition: intsafe.h:59
#define OLE_E_BLANK
Definition: winerror.h:2621
static HRESULT DataCacheEntry_LoadData(DataCacheEntry *cache_entry, IStorage *stg)
Definition: datacache.c:832
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
#define STREAM_NUMBER_NOT_SET
Definition: datacache.c:93
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:320
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 1615 of file datacache.c.

1618 {
1619  TRACE("()\n");
1620  return OLE_E_NOCONNECTION;
1621 }
#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 2516 of file datacache.c.

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

◆ DataCache_EnumDAdvise()

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

Definition at line 1628 of file datacache.c.

1631 {
1632  TRACE("()\n");
1633  return OLE_E_ADVISENOTSUPPORTED;
1634 }
#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 1585 of file datacache.c.

1589 {
1590  TRACE("()\n");
1591  return E_NOTIMPL;
1592 }
#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 426 of file datacache.c.

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

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 2157 of file datacache.c.

2163 {
2164  FIXME("stub\n");
2165  return E_NOTIMPL;
2166 }
#define FIXME(fmt,...)
Definition: debug.h:110
#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 2233 of file datacache.c.

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

◆ DataCache_GetCanonicalFormatEtc()

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

Definition at line 1543 of file datacache.c.

1547 {
1548  TRACE("()\n");
1549  return E_NOTIMPL;
1550 }
#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 1680 of file datacache.c.

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

◆ 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 2144 of file datacache.c.

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

◆ DataCache_GetData()

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

Definition at line 1499 of file datacache.c.

1503 {
1506 
1507  TRACE("(%p, %s, %p)\n", iface, debugstr_formatetc(pformatetcIn), pmedium);
1508 
1509  memset(pmedium, 0, sizeof(*pmedium));
1510 
1512  if (!cache_entry)
1513  return OLE_E_BLANK;
1514 
1515  return DataCacheEntry_GetData(cache_entry, This->presentationStorage, pformatetcIn, pmedium);
1516 }
static DataCache * impl_from_IDataObject(IDataObject *iface)
Definition: datacache.c:182
Definition: svc_auth_des.c:77
static DataCacheEntry * DataCache_GetEntryForFormatEtc(DataCache *This, const FORMATETC *formatetc)
Definition: datacache.c:292
const char * debugstr_formatetc(const FORMATETC *formatetc)
Definition: datacache.c:217
#define TRACE(s)
Definition: solgame.cpp:4
static HRESULT DataCacheEntry_GetData(DataCacheEntry *cache_entry, IStorage *stg, FORMATETC *fmt, STGMEDIUM *stgmedium)
Definition: datacache.c:1270
#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 1518 of file datacache.c.

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

◆ DataCache_GetEntryForFormatEtc()

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

Definition at line 292 of file datacache.c.

293 {
295  FORMATETC fmt = *formatetc;
296 
297  if (fmt.cfFormat == CF_BITMAP)
298  {
299  fmt.cfFormat = CF_DIB;
300  fmt.tymed = TYMED_HGLOBAL;
301  }
302 
304  {
305  /* FIXME: also compare DVTARGETDEVICEs */
306  if ((fmt.cfFormat == cache_entry->fmtetc.cfFormat) &&
307  (fmt.dwAspect == cache_entry->fmtetc.dwAspect) &&
308  (fmt.lindex == cache_entry->fmtetc.lindex) &&
309  ((fmt.tymed == cache_entry->fmtetc.tymed) || !cache_entry->fmtetc.cfFormat)) /* tymed is ignored for view caching */
310  return cache_entry;
311  }
312  return NULL;
313 }
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
smooth NULL
Definition: ftsmooth.c:416
uint32_t entry
Definition: isohybrid.c:63
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 2269 of file datacache.c.

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

◆ DataCache_HandsOffStorage()

static HRESULT WINAPI DataCache_HandsOffStorage ( IPersistStorage iface)
static

Definition at line 1945 of file datacache.c.

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

◆ DataCache_IAdviseSink_AddRef()

static ULONG WINAPI DataCache_IAdviseSink_AddRef ( IAdviseSink iface)
static

Definition at line 2839 of file datacache.c.

2840 {
2841  return 2;
2842 }

◆ DataCache_IAdviseSink_QueryInterface()

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

Definition at line 2822 of file datacache.c.

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

◆ DataCache_IAdviseSink_Release()

static ULONG WINAPI DataCache_IAdviseSink_Release ( IAdviseSink iface)
static

Definition at line 2844 of file datacache.c.

2845 {
2846  return 1;
2847 }

◆ DataCache_IDataObject_AddRef()

static ULONG WINAPI DataCache_IDataObject_AddRef ( IDataObject iface)
static

Definition at line 1475 of file datacache.c.

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

◆ DataCache_IDataObject_QueryInterface()

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

Definition at line 1462 of file datacache.c.

1466 {
1467  DataCache *this = impl_from_IDataObject(iface);
1468 
1469  return IUnknown_QueryInterface(this->outer_unk, riid, ppvObject);
1470 }
static DataCache * impl_from_IDataObject(IDataObject *iface)
Definition: datacache.c:182
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 1486 of file datacache.c.

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

◆ DataCache_IDataObject_SetData()

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

Definition at line 1557 of file datacache.c.

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

◆ DataCache_InitCache()

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

Definition at line 2570 of file datacache.c.

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

◆ DataCache_InitNew()

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

Definition at line 1717 of file datacache.c.

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

◆ DataCache_IOleCache2_AddRef()

static ULONG WINAPI DataCache_IOleCache2_AddRef ( IOleCache2 iface)
static

Definition at line 2401 of file datacache.c.

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

◆ DataCache_IOleCache2_QueryInterface()

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

Definition at line 2388 of file datacache.c.

2392 {
2393  DataCache *this = impl_from_IOleCache2(iface);
2394 
2395  return IUnknown_QueryInterface(this->outer_unk, riid, ppvObject);
2396 }
static DataCache * impl_from_IOleCache2(IOleCache2 *iface)
Definition: datacache.c:202
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 2412 of file datacache.c.

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

◆ DataCache_IOleCache2_SetData()

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

Definition at line 2576 of file datacache.c.

2581 {
2584  HRESULT hr;
2585 
2586  TRACE("(%p, %p, %s)\n", pformatetc, pmedium, fRelease ? "TRUE" : "FALSE");
2587  TRACE("formatetc = %s\n", debugstr_formatetc(pformatetc));
2588 
2590  if (cache_entry)
2591  {
2592  hr = DataCacheEntry_SetData(cache_entry, pformatetc, pmedium, fRelease);
2593 
2594  if (SUCCEEDED(hr))
2595  DataCache_FireOnViewChange(This, cache_entry->fmtetc.dwAspect,
2596  cache_entry->fmtetc.lindex);
2597 
2598  return hr;
2599  }
2600  WARN("cache entry not found\n");
2601 
2602  return OLE_E_BLANK;
2603 }
HRESULT hr
Definition: shlfolder.c:183
static DataCache * impl_from_IOleCache2(IOleCache2 *iface)
Definition: datacache.c:202
#define WARN(fmt,...)
Definition: debug.h:111
Definition: svc_auth_des.c:77
static DataCacheEntry * DataCache_GetEntryForFormatEtc(DataCache *This, const FORMATETC *formatetc)
Definition: datacache.c:292
const char * debugstr_formatetc(const FORMATETC *formatetc)
Definition: datacache.c:217
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:77
#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:1225
static void DataCache_FireOnViewChange(DataCache *this, DWORD aspect, LONG lindex)
Definition: datacache.c:426
#define SUCCEEDED(hr)
Definition: intsafe.h:57

◆ DataCache_IOleCacheControl_AddRef()

static ULONG WINAPI DataCache_IOleCacheControl_AddRef ( IOleCacheControl iface)
static

Definition at line 2748 of file datacache.c.

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

◆ DataCache_IOleCacheControl_QueryInterface()

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

Definition at line 2735 of file datacache.c.

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

◆ DataCache_IOleCacheControl_Release()

static ULONG WINAPI DataCache_IOleCacheControl_Release ( IOleCacheControl iface)
static

Definition at line 2759 of file datacache.c.

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

◆ DataCache_IPersistStorage_AddRef()

static ULONG WINAPI DataCache_IPersistStorage_AddRef ( IPersistStorage iface)
static

Definition at line 1657 of file datacache.c.

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

◆ DataCache_IPersistStorage_QueryInterface()

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

Definition at line 1644 of file datacache.c.

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

◆ DataCache_IPersistStorage_Release()

static ULONG WINAPI DataCache_IPersistStorage_Release ( IPersistStorage iface)
static

Definition at line 1668 of file datacache.c.

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

◆ DataCache_IsDirty()

static HRESULT WINAPI DataCache_IsDirty ( IPersistStorage iface)
static

Definition at line 1693 of file datacache.c.

1695 {
1698 
1699  TRACE("(%p)\n", iface);
1700 
1701  if (This->dirty)
1702  return S_OK;
1703 
1705  if (cache_entry->dirty)
1706  return S_OK;
1707 
1708  return S_FALSE;
1709 }
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:59
static DataCache * impl_from_IPersistStorage(IPersistStorage *iface)
Definition: datacache.c:192

◆ DataCache_IViewObject2_AddRef()

static ULONG WINAPI DataCache_IViewObject2_AddRef ( IViewObject2 iface)
static

Definition at line 1982 of file datacache.c.

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

◆ DataCache_IViewObject2_QueryInterface()

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

Definition at line 1969 of file datacache.c.

1973 {
1974  DataCache *this = impl_from_IViewObject2(iface);
1975 
1976  return IUnknown_QueryInterface(this->outer_unk, riid, ppvObject);
1977 }
static DataCache * impl_from_IViewObject2(IViewObject2 *iface)
Definition: datacache.c:197
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 1993 of file datacache.c.

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

◆ DataCache_Load()

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

Definition at line 1833 of file datacache.c.

1834 {
1836  HRESULT hr;
1837  CLSID clsid;
1838  DataCacheEntry *entry, *cursor2;
1839 
1840  TRACE("(%p, %p)\n", iface, stg);
1841 
1842  IPersistStorage_HandsOffStorage( iface );
1843 
1844  LIST_FOR_EACH_ENTRY_SAFE( entry, cursor2, &This->cache_list, DataCacheEntry, entry )
1846  This->clsid = CLSID_NULL;
1847 
1848  ReadClassStg( stg, &clsid );
1850  if (FAILED( hr )) return hr;
1851 
1852  This->clsid = clsid;
1853 
1854  if (This->clsid_static)
1855  {
1856  hr = parse_contents_stream( This, stg );
1857  if (FAILED(hr)) hr = parse_pres_streams( This, stg );
1858  }
1859  else
1860  hr = parse_pres_streams( This, stg );
1861 
1862  if (SUCCEEDED( hr ))
1863  {
1864  This->dirty = FALSE;
1865  This->presentationStorage = stg;
1866  IStorage_AddRef( This->presentationStorage );
1867  }
1868 
1869  return hr;
1870 }
static HRESULT parse_contents_stream(DataCache *cache, IStorage *stg)
Definition: datacache.c:1804
HRESULT hr
Definition: shlfolder.c:183
static void DataCacheEntry_Destroy(DataCache *cache, DataCacheEntry *cache_entry)
Definition: datacache.c:253
#define TRACE(s)
Definition: solgame.cpp:4
#define CLSID_NULL
Definition: guiddef.h:94
LONG HRESULT
Definition: typedefs.h:77
REFCLSID clsid
Definition: msctf.c:84
uint32_t entry
Definition: isohybrid.c:63
static DataCache * impl_from_IPersistStorage(IPersistStorage *iface)
Definition: datacache.c:192
#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:9104
static HRESULT parse_pres_streams(DataCache *cache, IStorage *stg)
Definition: datacache.c:1768
static HRESULT create_automatic_entry(DataCache *cache, const CLSID *clsid)
Definition: datacache.c:1313
#define SUCCEEDED(hr)
Definition: intsafe.h:57

Referenced by DataCache_SaveCompleted().

◆ DataCache_NDIUnknown_AddRef()

static ULONG WINAPI DataCache_NDIUnknown_AddRef ( IUnknown iface)
static

Definition at line 1428 of file datacache.c.

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

◆ DataCache_NDIUnknown_QueryInterface()

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

Definition at line 1368 of file datacache.c.

1372 {
1373  DataCache *this = impl_from_IUnknown(iface);
1374 
1375  if ( ppvObject==0 )
1376  return E_INVALIDARG;
1377 
1378  *ppvObject = 0;
1379 
1380  if (IsEqualIID(&IID_IUnknown, riid))
1381  {
1382  if (this->outer_unk == iface) /* non-aggregated, return IUnknown from IOleCache2 */
1383  *ppvObject = &this->IOleCache2_iface;
1384  else
1385  *ppvObject = iface;
1386  }
1387  else if (IsEqualIID(&IID_IDataObject, riid))
1388  {
1389  *ppvObject = &this->IDataObject_iface;
1390  }
1391  else if ( IsEqualIID(&IID_IPersistStorage, riid) ||
1393  {
1394  *ppvObject = &this->IPersistStorage_iface;
1395  }
1396  else if ( IsEqualIID(&IID_IViewObject, riid) ||
1398  {
1399  *ppvObject = &this->IViewObject2_iface;
1400  }
1401  else if ( IsEqualIID(&IID_IOleCache, riid) ||
1403  {
1404  *ppvObject = &this->IOleCache2_iface;
1405  }
1406  else if ( IsEqualIID(&IID_IOleCacheControl, riid) )
1407  {
1408  *ppvObject = &this->IOleCacheControl_iface;
1409  }
1410 
1411  if ((*ppvObject)==0)
1412  {
1413  WARN( "() : asking for unsupported interface %s\n", debugstr_guid(riid));
1414  return E_NOINTERFACE;
1415  }
1416 
1417  IUnknown_AddRef((IUnknown*)*ppvObject);
1418 
1419  return S_OK;
1420 }
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:111
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:59
const GUID IID_IViewObject2
static DataCache * impl_from_IUnknown(IUnknown *iface)
Definition: datacache.c:187
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:90
const GUID IID_IOleCache

◆ DataCache_NDIUnknown_Release()

static ULONG WINAPI DataCache_NDIUnknown_Release ( IUnknown iface)
static

Definition at line 1441 of file datacache.c.

1443 {
1444  DataCache *this = impl_from_IUnknown(iface);
1445  ULONG ref;
1446 
1447  ref = InterlockedDecrement(&this->ref);
1448 
1449  if (ref == 0) DataCache_Destroy(this);
1450 
1451  return ref;
1452 }
static void DataCache_Destroy(DataCache *ptrToDestroy)
Definition: datacache.c:264
Definition: send.c:47
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:187

◆ DataCache_OnClose()

static void WINAPI DataCache_OnClose ( IAdviseSink iface)
static

Definition at line 2871 of file datacache.c.

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

◆ DataCache_OnDataChange()

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

Definition at line 2849 of file datacache.c.

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

◆ DataCache_OnRename()

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

Definition at line 2861 of file datacache.c.

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

◆ DataCache_OnRun()

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

Definition at line 2770 of file datacache.c.

2771 {
2774 
2775  TRACE("(%p)->(%p)\n", iface, data_obj);
2776 
2777  if(This->running_object) return S_OK;
2778 
2779  /* No reference is taken on the data object */
2780  This->running_object = data_obj;
2781 
2783  {
2785  }
2786 
2787  return S_OK;
2788 }
Definition: svc_auth_des.c:77
static DataCache * impl_from_IOleCacheControl(IOleCacheControl *iface)
Definition: datacache.c:207
#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:2425
uint32_t entry
Definition: isohybrid.c:63
#define S_OK
Definition: intsafe.h:59

◆ DataCache_OnSave()

static void WINAPI DataCache_OnSave ( IAdviseSink iface)
static

Definition at line 2866 of file datacache.c.

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

◆ DataCache_OnStop()

static HRESULT WINAPI DataCache_OnStop ( IOleCacheControl iface)
static

Definition at line 2793 of file datacache.c.

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

◆ DataCache_OnViewChange()

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

Definition at line 2856 of file datacache.c.

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

◆ DataCache_QueryGetData()

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

Definition at line 1527 of file datacache.c.

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

◆ DataCache_Save()

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

Definition at line 1880 of file datacache.c.

1881 {
1884  HRESULT hr = S_OK;
1885  int stream_number = 0;
1886 
1887  TRACE("(%p, %p, %d)\n", iface, stg, same_as_load);
1888 
1889  /* assign stream numbers to the cache entries */
1891  {
1892  if (cache_entry->save_stream_num != stream_number)
1893  {
1894  cache_entry->dirty = TRUE; /* needs to be written out again */
1895  cache_entry->save_stream_num = stream_number;
1896  }
1897  stream_number++;
1898  }
1899 
1900  /* write out the cache entries */
1902  {
1903  if (!same_as_load || cache_entry->dirty)
1904  {
1905  hr = DataCacheEntry_Save(cache_entry, stg, same_as_load);
1906  if (FAILED(hr))
1907  break;
1908 
1909  if (same_as_load) cache_entry->dirty = FALSE;
1910  }
1911  }
1912 
1913  if (same_as_load) This->dirty = FALSE;
1914  return hr;
1915 }
#define TRUE
Definition: types.h:120
HRESULT hr
Definition: shlfolder.c:183
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:77
uint32_t entry
Definition: isohybrid.c:63
#define S_OK
Definition: intsafe.h:59
static DataCache * impl_from_IPersistStorage(IPersistStorage *iface)
Definition: datacache.c:192
static HRESULT DataCacheEntry_Save(DataCacheEntry *cache_entry, IStorage *storage, BOOL same_as_load)
Definition: datacache.c:1102

Referenced by DataCache_DiscardCache().

◆ DataCache_SaveCompleted()

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

Definition at line 1923 of file datacache.c.

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

◆ DataCache_SetAdvise()

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

Definition at line 2182 of file datacache.c.

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

◆ DataCache_Uncache()

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

Definition at line 2495 of file datacache.c.

2498 {
2501 
2502  TRACE("(%d)\n", dwConnection);
2503 
2505  if (cache_entry->id == dwConnection)
2506  {
2508  return S_OK;
2509  }
2510 
2511  WARN("no connection found for %d\n", dwConnection);
2512 
2513  return OLE_E_NOCONNECTION;
2514 }
static DataCache * impl_from_IOleCache2(IOleCache2 *iface)
Definition: datacache.c:202
#define WARN(fmt,...)
Definition: debug.h:111
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:253
#define TRACE(s)
Definition: solgame.cpp:4
uint32_t entry
Definition: isohybrid.c:63
#define S_OK
Definition: intsafe.h:59

◆ DataCache_Unfreeze()

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

Definition at line 2168 of file datacache.c.

2171 {
2172  FIXME("stub\n");
2173  return E_NOTIMPL;
2174 }
#define FIXME(fmt,...)
Definition: debug.h:110
#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 2620 of file datacache.c.

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

254 {
255  list_remove(&cache_entry->entry);
256  CoTaskMemFree(cache_entry->fmtetc.ptd);
257  ReleaseStgMedium(&cache_entry->stgmedium);
258  if(cache_entry->sink_id)
259  IDataObject_DUnadvise(cache->running_object, cache_entry->sink_id);
260 
262 }
Definition: cache.c:46
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:422
void WINAPI ReleaseStgMedium(STGMEDIUM *pmedium)
Definition: ole2.c:2036
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:395
#define HeapFree(x, y, z)
Definition: compat.h:394

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

◆ DataCacheEntry_DiscardData()

static HRESULT DataCacheEntry_DiscardData ( DataCacheEntry cache_entry)
inlinestatic

Definition at line 1287 of file datacache.c.

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

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 1270 of file datacache.c.

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

Referenced by DataCache_GetData().

◆ DataCacheEntry_LoadData()

static HRESULT DataCacheEntry_LoadData ( DataCacheEntry cache_entry,
IStorage stg 
)
static

Definition at line 832 of file datacache.c.

833 {
834  HRESULT hr;
835  IStream *stm;
836 
837  if (!stg) return OLE_E_BLANK;
838  hr = open_pres_stream( stg, cache_entry->load_stream_num, &stm );
839  if (FAILED(hr)) return hr;
840 
841  switch (cache_entry->fmtetc.cfFormat)
842  {
843  case CF_METAFILEPICT:
844  hr = load_mf_pict( cache_entry, stm );
845  break;
846 
847  case CF_DIB:
848  hr = load_dib( cache_entry, stm );
849  break;
850 
851  case CF_ENHMETAFILE:
852  hr = load_emf( cache_entry, stm );
853  break;
854 
855  default:
856  FIXME( "Unimplemented clip format %x\n", cache_entry->fmtetc.cfFormat );
857  hr = E_NOTIMPL;
858  }
859 
860  IStream_Release( stm );
861  return hr;
862 }
#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:585
#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:765
#define FIXME(fmt,...)
Definition: debug.h:110
LONG HRESULT
Definition: typedefs.h:77
#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:536
static HRESULT load_dib(DataCacheEntry *cache_entry, IStream *stm)
Definition: datacache.c:667
#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 1102 of file datacache.c.

1104 {
1105  HRESULT hr;
1106  IStream *stream;
1107  BOOL contents = (cache_entry->id == 1);
1108 
1109  TRACE("stream_number = %d, fmtetc = %s\n", cache_entry->save_stream_num, debugstr_formatetc(&cache_entry->fmtetc));
1110 
1111  hr = create_stream(cache_entry, storage, contents, &stream);
1112  if (FAILED(hr))
1113  return hr;
1114 
1115  switch (cache_entry->fmtetc.cfFormat)
1116  {
1117  case CF_DIB:
1118  hr = save_dib(cache_entry, contents, stream);
1119  break;
1120  case CF_METAFILEPICT:
1121  hr = save_mfpict(cache_entry, contents, stream);
1122  break;
1123  case CF_ENHMETAFILE:
1124  hr = save_emf(cache_entry, contents, stream);
1125  break;
1126  case 0:
1128  break;
1129  default:
1130  FIXME("got unsupported clipboard format %x\n", cache_entry->fmtetc.cfFormat);
1131  }
1132 
1133  IStream_Release(stream);
1134  return hr;
1135 }
#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:878
static HRESULT save_mfpict(DataCacheEntry *entry, BOOL contents, IStream *stream)
Definition: datacache.c:936
static HRESULT create_stream(DataCacheEntry *cache_entry, IStorage *storage, BOOL contents, IStream **stream)
Definition: datacache.c:1083
#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:1070
const char * debugstr_formatetc(const FORMATETC *formatetc)
Definition: datacache.c:217
unsigned int BOOL
Definition: ntddk_ex.h:94
#define FIXME(fmt,...)
Definition: debug.h:110
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:77
Definition: parse.h:22
GLuint GLuint stream
Definition: glext.h:7522
static HRESULT save_emf(DataCacheEntry *entry, BOOL contents, IStream *stream)
Definition: datacache.c:1017
#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 1225 of file datacache.c.

1229 {
1230  STGMEDIUM copy;
1231  HRESULT hr;
1232 
1233  if ((!cache_entry->fmtetc.cfFormat && !formatetc->cfFormat) ||
1234  (cache_entry->fmtetc.tymed == TYMED_NULL && formatetc->tymed == TYMED_NULL) ||
1235  stgmedium->tymed == TYMED_NULL)
1236  {
1237  WARN("invalid formatetc\n");
1238  return DV_E_FORMATETC;
1239  }
1240 
1241  cache_entry->dirty = TRUE;
1242  ReleaseStgMedium(&cache_entry->stgmedium);
1243 
1244  if (formatetc->cfFormat == CF_BITMAP)
1245  {
1246  hr = synthesize_dib( stgmedium->u.hBitmap, &copy );
1247  if (FAILED(hr)) return hr;
1248  if (fRelease) ReleaseStgMedium(stgmedium);
1249  stgmedium = &copy;
1250  fRelease = TRUE;
1251  }
1252  else if (formatetc->cfFormat == CF_METAFILEPICT && cache_entry->fmtetc.cfFormat == CF_ENHMETAFILE)
1253  {
1254  hr = synthesize_emf( stgmedium->u.hMetaFilePict, &copy );
1255  if (FAILED(hr)) return hr;
1256  if (fRelease) ReleaseStgMedium(stgmedium);
1257  stgmedium = &copy;
1258  fRelease = TRUE;
1259  }
1260 
1261  if (fRelease)
1262  {
1263  cache_entry->stgmedium = *stgmedium;
1264  return S_OK;
1265  }
1266  else
1267  return copy_stg_medium(cache_entry->fmtetc.cfFormat, &cache_entry->stgmedium, stgmedium);
1268 }
#define TRUE
Definition: types.h:120
#define CF_ENHMETAFILE
Definition: constants.h:409
HRESULT hr
Definition: shlfolder.c:183
void WINAPI ReleaseStgMedium(STGMEDIUM *pmedium)
Definition: ole2.c:2036
#define WARN(fmt,...)
Definition: debug.h:111
#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:77
static HRESULT copy_stg_medium(CLIPFORMAT cf, STGMEDIUM *dest_stgm, const STGMEDIUM *src_stgm)
Definition: datacache.c:1140
static HRESULT synthesize_dib(HBITMAP bm, STGMEDIUM *med)
Definition: datacache.c:1176
#define S_OK
Definition: intsafe.h:59
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:550

Referenced by DataCache_IOleCache2_SetData(), and DataCache_UpdateCache().

◆ debugstr_formatetc()

const char* debugstr_formatetc ( const FORMATETC *  formatetc)

Definition at line 217 of file datacache.c.

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

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 2605 of file datacache.c.

2606 {
2607  BOOL is_blank = entry->stgmedium.tymed == TYMED_NULL;
2608 
2609  if ((mode & UPDFCACHE_ONLYIFBLANK) && !is_blank) return FALSE;
2610 
2611  if ((mode & UPDFCACHE_NODATACACHE) && (entry->advise_flags & ADVF_NODATA)) return TRUE;
2612  if ((mode & UPDFCACHE_ONSAVECACHE) && (entry->advise_flags & ADVFCACHE_ONSAVE)) return TRUE;
2613  if ((mode & UPDFCACHE_ONSTOPCACHE) && (entry->advise_flags & ADVF_DATAONSTOP)) return TRUE;
2614  if ((mode & UPDFCACHE_NORMALCACHE) && (entry->advise_flags == 0)) return TRUE;
2615  if ((mode & UPDFCACHE_IFBLANK) && (is_blank && !(entry->advise_flags & ADVF_NODATA))) return TRUE;
2616 
2617  return FALSE;
2618 }
#define TRUE
Definition: types.h:120
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 317 of file datacache.c.

318 {
320  struct list *head = list_head( &cache->cache_list );
321  HRESULT hr = E_FAIL;
322 
323  *cache_entry = NULL;
324 
325  if (head)
326  {
328  if (entry->id == 1)
329  {
330  *cache_entry = entry;
331  hr = S_OK;
332  }
333  }
334 
335  return hr;
336 }
Definition: cache.c:46
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
smooth NULL
Definition: ftsmooth.c:416
LONG HRESULT
Definition: typedefs.h:77
uint32_t entry
Definition: isohybrid.c:63
Definition: _list.h:228
#define S_OK
Definition: intsafe.h:59
#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 212 of file datacache.c.

213 {
214  return CONTAINING_RECORD(iface, DataCache, IAdviseSink_iface);
215 }
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 182 of file datacache.c.

183 {
184  return CONTAINING_RECORD(iface, DataCache, IDataObject_iface);
185 }
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 202 of file datacache.c.

203 {
204  return CONTAINING_RECORD(iface, DataCache, IOleCache2_iface);
205 }
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 207 of file datacache.c.

208 {
209  return CONTAINING_RECORD(iface, DataCache, IOleCacheControl_iface);
210 }
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 192 of file datacache.c.

193 {
194  return CONTAINING_RECORD(iface, DataCache, IPersistStorage_iface);
195 }
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 187 of file datacache.c.

188 {
189  return CONTAINING_RECORD(iface, DataCache, IUnknown_inner);
190 }
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 197 of file datacache.c.

198 {
199  return CONTAINING_RECORD(iface, DataCache, IViewObject2_iface);
200 }
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 362 of file datacache.c.

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

Referenced by DataCache_CreateEntry().

◆ init_stream_header()

static void init_stream_header ( DataCacheEntry entry,
PresentationDataHeader header 
)
static

Definition at line 864 of file datacache.c.

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

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 667 of file datacache.c.

668 {
669  HRESULT hr;
670  STATSTG stat;
671  BYTE *dib;
672  HGLOBAL hglobal;
673  ULONG read, info_size, bi_size;
676  CLIPFORMAT cf;
678  ULARGE_INTEGER current_pos;
679  static const LARGE_INTEGER offset_zero;
680 
681  hr = IStream_Stat( stm, &stat, STATFLAG_NONAME );
682  if (FAILED( hr )) return hr;
683 
684  if (cache_entry->load_stream_num != STREAM_NUMBER_CONTENTS)
685  {
686  hr = read_clipformat( stm, &cf );
687  if (hr != S_OK) return hr;
688  hr = IStream_Read( stm, &pres, sizeof(pres), &read );
689  if (hr != S_OK) return hr;
690  }
691  else
692  {
693  hr = IStream_Read( stm, &file, sizeof(BITMAPFILEHEADER), &read );
694  if (hr != S_OK) return hr;
695  }
696 
697  hr = IStream_Seek( stm, offset_zero, STREAM_SEEK_CUR, &current_pos );
698  if (FAILED( hr )) return hr;
699  stat.cbSize.QuadPart -= current_pos.QuadPart;
700 
701  hglobal = GlobalAlloc( GMEM_MOVEABLE, stat.cbSize.u.LowPart );
702  if (!hglobal) return E_OUTOFMEMORY;
703  dib = GlobalLock( hglobal );
704 
705  /* read first DWORD of BITMAPINFOHEADER */
706  hr = IStream_Read( stm, dib, sizeof(DWORD), &read );
707  if (hr != S_OK) goto fail;
708  bi_size = *(DWORD *)dib;
709  if (stat.cbSize.QuadPart < bi_size) goto fail;
710 
711  /* read rest of BITMAPINFOHEADER */
712  hr = IStream_Read( stm, dib + sizeof(DWORD), bi_size - sizeof(DWORD), &read );
713  if (hr != S_OK) goto fail;
714 
715  info_size = bitmap_info_size( (BITMAPINFO *)dib, DIB_RGB_COLORS );
716  if (stat.cbSize.QuadPart < info_size) goto fail;
717  if (info_size > bi_size)
718  {
719  hr = IStream_Read( stm, dib + bi_size, info_size - bi_size, &read );
720  if (hr != S_OK) goto fail;
721  }
722  stat.cbSize.QuadPart -= info_size;
723 
724  /* set Stream pointer to beginning of bitmap bits */
725  if (cache_entry->load_stream_num == STREAM_NUMBER_CONTENTS && file.bfOffBits)
726  {
728 
729  skip.QuadPart = file.bfOffBits - sizeof(file) - info_size;
730  if (stat.cbSize.QuadPart < skip.QuadPart) goto fail;
731  hr = IStream_Seek( stm, skip, STREAM_SEEK_CUR, NULL );
732  if (hr != S_OK) goto fail;
733  stat.cbSize.QuadPart -= skip.QuadPart;
734  }
735 
736  hr = IStream_Read( stm, dib + info_size, stat.cbSize.u.LowPart, &read );
737  if (hr != S_OK) goto fail;
738 
739  if (bi_size >= sizeof(*info))
740  {
742  if (info->biXPelsPerMeter == 0 || info->biYPelsPerMeter == 0)
743  {
744  HDC hdc = GetDC( 0 );
745  info->biXPelsPerMeter = MulDiv( GetDeviceCaps( hdc, LOGPIXELSX ), 10000, 254 );
746  info->biYPelsPerMeter = MulDiv( GetDeviceCaps( hdc, LOGPIXELSY ), 10000, 254 );
747  ReleaseDC( 0, hdc );
748  }
749  }
750 
751  GlobalUnlock( hglobal );
752 
753  cache_entry->stgmedium.tymed = TYMED_HGLOBAL;
754  cache_entry->stgmedium.u.hGlobal = hglobal;
755 
756  return hr;
757 
758 fail:
759  GlobalUnlock( hglobal );
760  GlobalFree( hglobal );
761  return hr;
762 
763 }
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:94
struct _test_info info[]
Definition: SetCursorPos.c:19
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
smooth NULL
Definition: ftsmooth.c:416
LONG HRESULT
Definition: typedefs.h:77
static int bitmap_info_size(const BITMAPINFO *info, WORD coloruse)
Definition: datacache.c:229
const char file[]
Definition: icontest.c:11
unsigned long DWORD
Definition: ntddk_ex.h:95
HGLOBAL NTAPI GlobalFree(HGLOBAL hMem)
Definition: heapmem.c:611
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: mem.h:68
static HRESULT read_clipformat(IStream *stream, CLIPFORMAT *clipformat)
Definition: datacache.c:462
_CRTIMP int __cdecl stat(const char *_Filename, struct stat *_Stat)
Definition: stat.h:345
#define S_OK
Definition: intsafe.h:59
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
static const BYTE dib[]
Definition: ole2.c:201
#define skip(...)
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 765 of file datacache.c.

766 {
767  HRESULT hr;
768 
769  if (cache_entry->load_stream_num != STREAM_NUMBER_CONTENTS)
770  {
771  STGMEDIUM stgmed;
772 
773  hr = load_mf_pict( cache_entry, stm );
774  if (SUCCEEDED( hr ))
775  {
776  hr = synthesize_emf( cache_entry->stgmedium.u.hMetaFilePict, &stgmed );
777  ReleaseStgMedium( &cache_entry->stgmedium );
778  }
779  if (SUCCEEDED( hr ))
780  cache_entry->stgmedium = stgmed;
781  }
782  else
783  {
784  STATSTG stat;
785  BYTE *data;
786  ULONG read, size_bits;
787 
788  hr = IStream_Stat( stm, &stat, STATFLAG_NONAME );
789 
790  if (SUCCEEDED( hr ))
791  {
792  data = HeapAlloc( GetProcessHeap(), 0, stat.cbSize.u.LowPart );
793  if (!data) return E_OUTOFMEMORY;
794 
795  hr = IStream_Read( stm, data, stat.cbSize.u.LowPart, &read );
796  if (hr != S_OK)
797  {
798  HeapFree( GetProcessHeap(), 0, data );
799  return hr;
800  }
801 
802  if (read <= sizeof(DWORD) + sizeof(ENHMETAHEADER))
803  {
804  HeapFree( GetProcessHeap(), 0, data );
805  return E_FAIL;
806  }
807  size_bits = read - sizeof(DWORD) - sizeof(ENHMETAHEADER);
808  cache_entry->stgmedium.u.hEnhMetaFile = SetEnhMetaFileBits( size_bits, data + (read - size_bits) );
809  cache_entry->stgmedium.tymed = TYMED_ENHMF;
810  cache_entry->stgmedium.pUnkForRelease = NULL;
811 
812  HeapFree( GetProcessHeap(), 0, data );
813  }
814  }
815 
816  return hr;
817 }
HRESULT hr
Definition: shlfolder.c:183
static HRESULT load_mf_pict(DataCacheEntry *cache_entry, IStream *stm)
Definition: datacache.c:585
void WINAPI ReleaseStgMedium(STGMEDIUM *pmedium)
Definition: ole2.c:2036
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:94
#define DWORD
Definition: nt_native.h:44
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
smooth NULL
Definition: ftsmooth.c:416
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
LONG HRESULT
Definition: typedefs.h:77
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: mem.h:68
_CRTIMP int __cdecl stat(const char *_Filename, struct stat *_Stat)
Definition: stat.h:345
#define S_OK
Definition: intsafe.h:59
unsigned int ULONG
Definition: retypes.h:1
static HRESULT synthesize_emf(HMETAFILEPICT data, STGMEDIUM *med)
Definition: datacache.c:550
#define HeapFree(x, y, z)
Definition: compat.h:394
_CRTIMP int __cdecl read(_In_ int _FileHandle, _Out_writes_bytes_(_MaxCharCount) void *_DstBuf, _In_ unsigned int _MaxCharCount)
#define SUCCEEDED(hr)
Definition: intsafe.h:57

Referenced by DataCacheEntry_LoadData().

◆ load_mf_pict()

static HRESULT load_mf_pict ( DataCacheEntry cache_entry,
IStream stm 
)
static

Definition at line 585 of file datacache.c.

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

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 536 of file datacache.c.

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

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 1804 of file datacache.c.

1805 {
1806  HRESULT hr;
1807  IStream *stm;
1809 
1810  hr = open_pres_stream( stg, STREAM_NUMBER_CONTENTS, &stm );
1811  if (FAILED( hr )) return hr;
1812 
1814  if (hr == S_OK)
1815  {
1816  cache_entry->load_stream_num = STREAM_NUMBER_CONTENTS;
1817  cache_entry->save_stream_num = STREAM_NUMBER_CONTENTS;
1818  cache_entry->dirty = FALSE;
1819  }
1820 
1821  IStream_Release( stm );
1822  return hr;
1823 }
Definition: cache.c:46
HRESULT hr
Definition: shlfolder.c:183
Definition: svc_auth_des.c:77
#define STREAM_NUMBER_CONTENTS
Definition: datacache.c:94
LONG HRESULT
Definition: typedefs.h:77
static HRESULT get_static_entry(DataCache *cache, DataCacheEntry **cache_entry)
Definition: datacache.c:317
#define S_OK
Definition: intsafe.h:59
static HRESULT open_pres_stream(IStorage *stg, int stream_number, IStream **stm)
Definition: datacache.c:536

Referenced by DataCache_Load().

◆ parse_pres_streams()

static HRESULT parse_pres_streams ( DataCache cache,
IStorage stg 
)
static

Definition at line 1768 of file datacache.c.

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

Referenced by DataCache_Load().

◆ read_clipformat()

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

Definition at line 462 of file datacache.c.

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

879 {
880  HRESULT hr = S_OK;
881  int data_size = 0;
882  BITMAPINFO *bmi = NULL;
883 
884  if (entry->stgmedium.tymed != TYMED_NULL)
885  {
886  data_size = GlobalSize(entry->stgmedium.u.hGlobal);
887  bmi = GlobalLock(entry->stgmedium.u.hGlobal);
888  }
889 
890  if (!contents)
891  {
893 
895  hr = write_clipformat(stream, entry->fmtetc.cfFormat);
896  if (FAILED(hr)) goto end;
897  if (data_size)
898  {
899  header.dwSize = data_size;
900  /* Size in units of 0.01mm (ie. MM_HIMETRIC) */
901  if (bmi->bmiHeader.biXPelsPerMeter != 0 && bmi->bmiHeader.biYPelsPerMeter != 0)
902  {
903  header.dwObjectExtentX = MulDiv(bmi->bmiHeader.biWidth, 100000, bmi->bmiHeader.biXPelsPerMeter);
904  header.dwObjectExtentY = MulDiv(bmi->bmiHeader.biHeight, 100000, bmi->bmiHeader.biYPelsPerMeter);
905  }
906  else
907  {
908  HDC hdc = GetDC(0);
909  header.dwObjectExtentX = MulDiv(bmi->bmiHeader.biWidth, 2540, GetDeviceCaps(hdc, LOGPIXELSX));
910  header.dwObjectExtentY = MulDiv(bmi->bmiHeader.biHeight, 2540, GetDeviceCaps(hdc, LOGPIXELSY));
911  ReleaseDC(0, hdc);
912  }
913  }
914  hr = IStream_Write(stream, &header, sizeof(PresentationDataHeader), NULL);
915  if (hr == S_OK && data_size)
916  hr = IStream_Write(stream, bmi, data_size, NULL);
917  }
918  else if(data_size)
919  {
920  BITMAPFILEHEADER bmp_fhdr;
921 
922  bmp_fhdr.bfType = 0x4d42;
923  bmp_fhdr.bfSize = data_size + sizeof(BITMAPFILEHEADER);
924  bmp_fhdr.bfReserved1 = bmp_fhdr.bfReserved2 = 0;
925  bmp_fhdr.bfOffBits = bitmap_info_size(bmi, DIB_RGB_COLORS) + sizeof(BITMAPFILEHEADER);
926  hr = IStream_Write(stream, &bmp_fhdr, sizeof(BITMAPFILEHEADER), NULL);
927  if (hr == S_OK)
928  hr = IStream_Write(stream, bmi, data_size, NULL);
929  }
930 
931 end:
932  if (bmi) GlobalUnlock(entry->stgmedium.u.hGlobal);
933  return hr;
934 }
#define LOGPIXELSX
Definition: wingdi.h:717
BITMAPINFOHEADER bmiHeader
Definition: wingdi.h:1454
HRESULT hr
Definition: shlfolder.c:183
HDC WINAPI GetDC(_In_opt_ HWND)
LONG biXPelsPerMeter
Definition: amvideo.idl:37
static HDC
Definition: imagelist.c:92
GLuint GLuint end
Definition: gl.h:1545
LONG biYPelsPerMeter
Definition: amvideo.idl:38
static HRESULT write_clipformat(IStream *stream, CLIPFORMAT clipformat)
Definition: datacache.c:502
SIZE_T NTAPI GlobalSize(HGLOBAL hMem)
Definition: heapmem.c:1090
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
smooth NULL
Definition: ftsmooth.c:416
LONG HRESULT
Definition: typedefs.h:77
static int bitmap_info_size(const BITMAPINFO *info, WORD coloruse)
Definition: datacache.c:229
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:59
struct tagBITMAPFILEHEADER BITMAPFILEHEADER
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:864
#define MulDiv(x, y, z)
Definition: gdifloat.h:86
struct CFHEADER header
Definition: fdi.c:109

Referenced by DataCacheEntry_Save().

◆ save_emf()

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

Definition at line 1017 of file datacache.c.

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