22#include <com/sun/star/uno/Any.h>
23#include <com/sun/star/uno/Exception.hpp>
24#include <com/sun/star/datatransfer/XTransferable.hpp>
27#include <osl/thread.h>
37 sal_uInt64 pResult = 0;
39 uno::Reference< datatransfer::XTransferable > xTransferable(
m_pDocHolder->GetDocument(), uno::UNO_QUERY );
40 if ( xTransferable.is() )
42 datatransfer::DataFlavor aFlavor;
46 aFlavor.MimeType =
"application/x-openoffice-emf;windows_formatname=\"Image EMF\"";
47 aFlavor.HumanPresentableName =
"Enhanced Windows MetaFile";
51 aFlavor.MimeType =
"application/x-openoffice-wmf;windows_formatname=\"Image WMF\"";
52 aFlavor.HumanPresentableName =
"Windows GDIMetaFile";
57 uno::Any aAny = xTransferable->getTransferData( aFlavor );
70 return DV_E_FORMATETC;
73 return STG_E_MEDIUMFULL;
75 if ( pFormatetc->dwAspect == DVASPECT_THUMBNAIL
76 || pFormatetc->dwAspect == DVASPECT_ICON
77 || pFormatetc->dwAspect == DVASPECT_DOCPRINT )
80 if ( pFormatetc->cfFormat == CF_ENHMETAFILE )
82 if ( !( pFormatetc->tymed & TYMED_ENHMF ) )
89 pMedium->tymed = TYMED_ENHMF;
90 pMedium->hEnhMetaFile = hMeta;
91 pMedium->pUnkForRelease =
nullptr;
96 return STG_E_MEDIUMFULL;
98 else if ( pFormatetc->cfFormat == CF_METAFILEPICT )
100 if ( !( pFormatetc->tymed & TYMED_MFPICT ) )
107 pMedium->tymed = TYMED_MFPICT;
108 pMedium->hMetaFilePict = hMeta;
109 pMedium->pUnkForRelease =
nullptr;
114 return STG_E_MEDIUMFULL;
118 CLIPFORMAT cf_embSource =
static_cast<CLIPFORMAT
>(RegisterClipboardFormatW( L
"Embed Source" ));
119 CLIPFORMAT cf_embObj =
static_cast<CLIPFORMAT
>(RegisterClipboardFormatW( L
"Embedded Object" ));
120 if ( pFormatetc->cfFormat == cf_embSource || pFormatetc->cfFormat == cf_embObj )
122 if ( !( pFormatetc->tymed & TYMED_ISTORAGE ) )
125 CComPtr< IStorage > pNewStg;
126 HRESULT
hr = StgCreateDocfile(
nullptr, STGM_CREATE | STGM_READWRITE | STGM_DELETEONRELEASE, 0, &pNewStg );
127 if ( FAILED(
hr ) || !pNewStg )
return STG_E_MEDIUMFULL;
130 if ( FAILED(
hr ) )
return STG_E_MEDIUMFULL;
132 pMedium->tymed = TYMED_ISTORAGE;
133 pMedium->pstg = pNewStg;
134 pMedium->pstg->AddRef();
135 pMedium->pUnkForRelease = pNewStg;
141 return DV_E_FORMATETC;
147 return DV_E_FORMATETC;
150 return STG_E_MEDIUMFULL;
152 if ( pFormatetc->dwAspect == DVASPECT_THUMBNAIL
153 || pFormatetc->dwAspect == DVASPECT_ICON
154 || pFormatetc->dwAspect == DVASPECT_DOCPRINT )
155 return DV_E_DVASPECT;
157 CLIPFORMAT cf_embSource =
static_cast<CLIPFORMAT
>(RegisterClipboardFormatW( L
"Embed Source" ));
158 CLIPFORMAT cf_embObj =
static_cast<CLIPFORMAT
>(RegisterClipboardFormatW( L
"Embedded Object" ));
160 if ( pFormatetc->cfFormat == cf_embSource || pFormatetc->cfFormat == cf_embObj )
162 if ( !( pFormatetc->tymed & TYMED_ISTORAGE ) )
165 if ( !pMedium->pstg )
return STG_E_MEDIUMFULL;
168 if ( FAILED(
hr ) )
return STG_E_MEDIUMFULL;
170 pMedium->tymed = TYMED_ISTORAGE;
171 pMedium->pUnkForRelease =
nullptr;
176 return DV_E_FORMATETC;
183 if ( pFormatetc->dwAspect == DVASPECT_THUMBNAIL
184 || pFormatetc->dwAspect == DVASPECT_ICON
185 || pFormatetc->dwAspect == DVASPECT_DOCPRINT )
186 return DV_E_DVASPECT;
188 if ( pFormatetc->cfFormat == CF_ENHMETAFILE )
190 if ( !( pFormatetc->tymed & TYMED_ENHMF ) )
195 else if ( pFormatetc->cfFormat == CF_METAFILEPICT )
197 if ( !( pFormatetc->tymed & TYMED_MFPICT ) )
204 CLIPFORMAT cf_embSource =
static_cast<CLIPFORMAT
>(RegisterClipboardFormatW( L
"Embed Source" ));
205 CLIPFORMAT cf_embObj =
static_cast<CLIPFORMAT
>(RegisterClipboardFormatW( L
"Embedded Object" ));
206 if ( pFormatetc->cfFormat == cf_embSource || pFormatetc->cfFormat == cf_embObj )
208 if ( !( pFormatetc->tymed & TYMED_ISTORAGE ) )
216 return DV_E_FORMATETC;
222 if ( !pFormatetcIn || !pFormatetcOut )
223 return DV_E_FORMATETC;
225 pFormatetcOut->ptd =
nullptr;
226 pFormatetcOut->cfFormat = pFormatetcIn->cfFormat;
227 pFormatetcOut->dwAspect = DVASPECT_CONTENT;
229 if ( pFormatetcIn->cfFormat == CF_ENHMETAFILE )
231 pFormatetcOut->tymed = TYMED_ENHMF;
234 else if ( pFormatetcIn->cfFormat == CF_METAFILEPICT )
236 pFormatetcOut->tymed = TYMED_MFPICT;
241 CLIPFORMAT cf_embSource =
static_cast<CLIPFORMAT
>(RegisterClipboardFormatW( L
"Embed Source" ));
242 CLIPFORMAT cf_embObj =
static_cast<CLIPFORMAT
>(RegisterClipboardFormatW( L
"Embedded Object" ));
243 if ( pFormatetcIn->cfFormat == cf_embSource || pFormatetcIn->cfFormat == cf_embObj )
245 pFormatetcOut->tymed = TYMED_ISTORAGE;
250 return DV_E_FORMATETC;
260 if ( dwDirection == DATADIR_GET )
270 return E_OUTOFMEMORY;
272 return m_pDAdviseHolder->Advise(
static_cast<IDataObject*
>(
this), pFormatetc, advf, pAdvSink, pdwConnection );
279 return E_OUTOFMEMORY;
288 return E_OUTOFMEMORY;
STDMETHOD() GetCanonicalFormatEtc(FORMATETC *pFormatetcIn, FORMATETC *pFormatetcOut) override
sal_uInt64 getMetaFileHandle_Impl(bool isEnhMeta)
STDMETHOD() DUnadvise(DWORD dwConnection) override
HRESULT SaveTo_Impl(IStorage *pStg)
STDMETHOD() GetData(FORMATETC *pFormatetc, STGMEDIUM *pMedium) override
STDMETHOD() SetData(FORMATETC *pFormatetc, STGMEDIUM *pMedium, BOOL fRelease) override
rtl::Reference< DocumentHolder > m_pDocHolder
STDMETHOD() GetDataHere(FORMATETC *pFormatetc, STGMEDIUM *pMedium) override
STDMETHOD() EnumDAdvise(IEnumSTATDATA **ppenumAdvise) override
STDMETHOD() DAdvise(FORMATETC *pFormatetc, DWORD advf, IAdviseSink *pAdvSink, DWORD *pdwConnection) override
STDMETHOD() EnumFormatEtc(DWORD dwDirection, IEnumFORMATETC **ppFormatetc) override
STDMETHOD() QueryGetData(FORMATETC *pFormatetc) override
CComPtr< IDataAdviseHolder > m_pDAdviseHolder
css::uno::Type const & get()
const wchar_t *typedef BOOL