The presence of IDataObject describes the cache as a source of data. GetData, GetDataHere, and QueryGetData are implemented as you would expect and deal with the contents of the cache. SetData delegates to IOleCache2::SetData, as we'll see shortly, and format enumeration and advisory connections are not supported at all. On the other hand, IPersistStorage is fully implemented so that Save will write any data in the cache to separate streams (regardless of that data's native storage medium) and Load will read information from those streams back into the cache. Those streams are named "\002OlePres<xxx>", where <xxx> varies from 000 to 999. IViewObject2 is also fully implemented, which means a client can ask the cache to draw any presentation within it. In addition, the cache will notify the client through IDataObject::SetData or IOleCache2::Cache any time a view is changed. Overall, the behavior of the cache's IDataObject, IPersistStorage, and IViewObject interfaces is summarized in Tables 11-1, 11-2, and 11-3.
IDataObject | Behavior |
DAdvise | Returns OLE_E_ADVISENOTSUPPORTED. |
DUnadvise | Returns OLE_E_NOCONNECTION. |
EnumDAdvise | Returns OLE_E_ADVISENOTSUPPORTED. |
EnumFormatEtc | Returns E_NOTIMPL. |
GetCanonicalFormatEtc | Returns E_NOTIMPL. |
GetData | Attempts to find the data in the cache, which must use the mediums TYMED_HGLOBAL, TYMED_MFPICT, TYMED_GDI, TYMED_ISTORAGE, |
and TYMED_ISTREAM. DV_E_TYMED is returned for any other medium. OLE_E_BLANK is returned for data that is not found in the cache. | |
GetDataHere | Same as for GetData but supports only TYMED_HGLOBAL, TYMED_ISTORAGE, and TYMED_ISTREAM. |
QueryGetData | Returns NOERROR if the format is present in the cache; otherwise, returns S_FALSE. |
SetData | Delegates to IOleCache2::SetData. |
Table 11-1.
Behavior of the data cache's IDataObject interface.
IPersistStorage | Behavior |
GetClassID | Returns E_NOTIMPL. |
IsDirty | Returns S_OK if the cache contents have been changed; otherwise, returns S_FALSE. |
InitNew | Returns NOERROR but saves the IStorage pointer, calling AddRef on it. |
Load | Loads information about cached data from streams in IStorage and saves the IStorage pointer. No data is actually loaded until required through IDataObject::GetData or IViewObject2::Draw. |
Save | Saves any presentations that have changed since the call to Load, as well as an information block describing what is cached. Data is stored in streams named "\002OlePres<xxx>", where <xxx> varies from 000 to 999. |
SaveCompleted | Releases and replaces any held pointers as necessary and returns NOERROR. |
HandsOffStorage | Releases any held pointers and returns NOERROR. |
Table 11-2.
Behavior of the data cache's IPersistStorage interface.
IViewObject2 | Behavior |
Draw | Attempts to draw using a presentation from the cache; otherwise, returns OLE_E_BLANK. |
GetColorSet | Tries to determine the color set from the metafile or bitmap in the cache. Returns OLE_E_BLANK if there is no presentation; otherwise, returns NOERROR or S_FALSE, depending on the success of the function. |
Freeze | Adds the aspect to an internal list that affects the behavior of Draw and returns NOERROR if successful or OLE_E_BLANK if not. Returns VIEW_S_ALREADY_FROZEN if this is a repeat request. |
Unfreeze | Removes an entry from the internal list of frozen aspects and frees any duplicate presentation. Returns OLE_E_NOCONNECTION if the aspect was not frozen; otherwise, returns NOERROR. |
SetAdvise | Saves the IAdviseSink pointer and returns NOERROR. |
GetAdvise | Returns the last IAdviseSink from SetAdvise and returns NOERROR. |
GetExtent | Returns the size of a known presentation (extents from a METAFILEPICT or the size of a bitmap) and returns NOERROR; otherwise, returns OLE_E_BLANK. |
Table 11-3.
Behavior of the data cache's IViewObject2 interface.