Commit 32c8934d authored by Alexandre Julliard's avatar Alexandre Julliard

Abey George (of Macadamian/Corel)

When you open files with Embedded objects, they were not getting drawn correctly. When you paste OLE objects with presentation data, they were not getting drawn correctly.
parent b200793d
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
* OLE 2 Data cache * OLE 2 Data cache
* *
* Copyright 1999 Francis Beaudet * Copyright 1999 Francis Beaudet
* Copyright 2000 Abey George
* *
* NOTES: * NOTES:
* The OLE2 data cache supports a whole whack of * The OLE2 data cache supports a whole whack of
...@@ -32,10 +33,12 @@ ...@@ -32,10 +33,12 @@
#include "windef.h" #include "windef.h"
#include "winbase.h" #include "winbase.h"
#include "wingdi.h" #include "wingdi.h"
#include "winuser.h"
#include "winerror.h" #include "winerror.h"
#include "crtdll.h" #include "crtdll.h"
#include "wine/obj_oleview.h" #include "wine/obj_oleview.h"
#include "wine/obj_cache.h" #include "wine/obj_cache.h"
#include "ole2.h"
#include "debugtools.h" #include "debugtools.h"
DEFAULT_DEBUG_CHANNEL(ole); DEFAULT_DEBUG_CHANNEL(ole);
...@@ -58,9 +61,9 @@ typedef struct PresentationDataHeader ...@@ -58,9 +61,9 @@ typedef struct PresentationDataHeader
DWORD unknown6; DWORD unknown6;
DWORD unknown7; /* 0 */ DWORD unknown7; /* 0 */
DWORD objectExtentX; DWORD dwObjectExtentX;
DWORD objectExtentY; DWORD dwObjectExtentY;
DWORD unknown8; DWORD dwSize;
} PresentationDataHeader; } PresentationDataHeader;
/**************************************************************************** /****************************************************************************
...@@ -1037,12 +1040,109 @@ static ULONG WINAPI DataCache_IDataObject_Release( ...@@ -1037,12 +1040,109 @@ static ULONG WINAPI DataCache_IDataObject_Release(
return IUnknown_Release(this->outerUnknown); return IUnknown_Release(this->outerUnknown);
} }
/************************************************************************
* DataCache_GetData
*
* Get Data from a source dataobject using format pformatetcIn->cfFormat
* See Windows documentation for more details on GetData.
* TODO: Currently only CF_METAFILEPICT is implemented
*/
static HRESULT WINAPI DataCache_GetData( static HRESULT WINAPI DataCache_GetData(
IDataObject* iface, IDataObject* iface,
LPFORMATETC pformatetcIn, LPFORMATETC pformatetcIn,
STGMEDIUM* pmedium) STGMEDIUM* pmedium)
{ {
FIXME("stub\n"); HRESULT hr = 0;
HRESULT hrRet = E_UNEXPECTED;
IPersistStorage *pPersistStorage = 0;
IStorage *pStorage = 0;
IStream *pStream = 0;
OLECHAR name[]={ 2, 'O', 'l', 'e', 'P', 'r', 'e', 's', '0', '0', '0', 0};
HGLOBAL hGlobalMF = 0;
void *mfBits = 0;
PresentationDataHeader pdh;
METAFILEPICT *mfPict;
HMETAFILE hMetaFile = 0;
if (pformatetcIn->cfFormat == CF_METAFILEPICT)
{
/* Get the Persist Storage */
hr = IDataObject_QueryInterface(iface, &IID_IPersistStorage, (void**)&pPersistStorage);
if (hr != S_OK)
goto cleanup;
/* Create a doc file to copy the doc to a storage */
hr = StgCreateDocfile(NULL, STGM_CREATE | STGM_READWRITE | STGM_SHARE_EXCLUSIVE, 0, &pStorage);
if (hr != S_OK)
goto cleanup;
/* Save it to storage */
hr = OleSave(pPersistStorage, pStorage, FALSE);
if (hr != S_OK)
goto cleanup;
/* Open the Presentation data srteam */
hr = IStorage_OpenStream(pStorage, name, 0, STGM_CREATE|STGM_SHARE_EXCLUSIVE|STGM_READWRITE, 0, &pStream);
if (hr != S_OK)
goto cleanup;
/* Read the presentation header */
hr = IStream_Read(pStream, &pdh, sizeof(PresentationDataHeader), NULL);
if (hr != S_OK)
goto cleanup;
mfBits = HeapAlloc(GetProcessHeap(), 0, pdh.dwSize);
/* Read the Metafile bits */
hr = IStream_Read(pStream, mfBits, pdh.dwSize, NULL);
if (hr != S_OK)
goto cleanup;
/* Create the metafile and place it in the STGMEDIUM structure */
hMetaFile = SetMetaFileBitsEx(pdh.dwSize, mfBits);
hGlobalMF = GlobalAlloc(GMEM_SHARE|GMEM_MOVEABLE, sizeof(METAFILEPICT));
mfPict = (METAFILEPICT *)GlobalLock(hGlobalMF);
mfPict->hMF = hMetaFile;
GlobalUnlock(hGlobalMF);
pmedium->u.hGlobal = hGlobalMF;
pmedium->tymed = TYMED_MFPICT;
hrRet = S_OK;
cleanup:
if (mfBits)
HeapFree(GetProcessHeap(), 0, mfBits);
if (pStream)
IStream_Release(pStream);
if (pStorage)
IStorage_Release(pStorage);
if (pPersistStorage)
IPersistStorage_Release(pPersistStorage);
return hrRet;
}
/* TODO: Other formats are not implemented */
return E_NOTIMPL; return E_NOTIMPL;
} }
...@@ -1512,8 +1612,8 @@ static HRESULT WINAPI DataCache_Draw( ...@@ -1512,8 +1612,8 @@ static HRESULT WINAPI DataCache_Draw(
POINT oldViewportOrg; POINT oldViewportOrg;
SetWindowExtEx(hdcDraw, SetWindowExtEx(hdcDraw,
presData.objectExtentX, presData.dwObjectExtentX,
presData.objectExtentY, presData.dwObjectExtentY,
&oldWindowExt); &oldWindowExt);
SetViewportExtEx(hdcDraw, SetViewportExtEx(hdcDraw,
...@@ -1732,8 +1832,8 @@ static HRESULT WINAPI DataCache_GetExtent( ...@@ -1732,8 +1832,8 @@ static HRESULT WINAPI DataCache_GetExtent(
if (SUCCEEDED(hres)) if (SUCCEEDED(hres))
{ {
lpsizel->cx = presData.objectExtentX; lpsizel->cx = presData.dwObjectExtentX;
lpsizel->cy = presData.objectExtentY; lpsizel->cy = presData.dwObjectExtentY;
} }
/* /*
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
* OLE 2 default object handler * OLE 2 default object handler
* *
* Copyright 1999 Francis Beaudet * Copyright 1999 Francis Beaudet
* Copyright 2000 Abey George
* *
* NOTES: * NOTES:
* The OLE2 default object handler supports a whole whack of * The OLE2 default object handler supports a whole whack of
...@@ -1296,13 +1297,39 @@ static ULONG WINAPI DefaultHandler_IDataObject_Release( ...@@ -1296,13 +1297,39 @@ static ULONG WINAPI DefaultHandler_IDataObject_Release(
return IUnknown_Release(this->outerUnknown); return IUnknown_Release(this->outerUnknown);
} }
/************************************************************************
* DefaultHandler_GetData
*
* Get Data from a source dataobject using format pformatetcIn->cfFormat
* See Windows documentation for more details on GetData.
* Default handler's implementation of this method delegates to the cache.
*/
static HRESULT WINAPI DefaultHandler_GetData( static HRESULT WINAPI DefaultHandler_GetData(
IDataObject* iface, IDataObject* iface,
LPFORMATETC pformatetcIn, LPFORMATETC pformatetcIn,
STGMEDIUM* pmedium) STGMEDIUM* pmedium)
{ {
FIXME(": Stub\n"); IDataObject* cacheDataObject = NULL;
return E_NOTIMPL; HRESULT hres;
_ICOM_THIS_From_IDataObject(DefaultHandler, iface);
TRACE("(%p, %p, %p)\n", iface, pformatetcIn, pmedium);
hres = IUnknown_QueryInterface(this->dataCache,
&IID_IDataObject,
(void**)&cacheDataObject);
if (FAILED(hres))
return E_UNEXPECTED;
hres = IDataObject_GetData(cacheDataObject,
pformatetcIn,
pmedium);
IDataObject_Release(cacheDataObject);
return hres;
} }
static HRESULT WINAPI DefaultHandler_GetDataHere( static HRESULT WINAPI DefaultHandler_GetDataHere(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment