20#include <com/sun/star/embed/XTransactedObject.hpp>
21#include <com/sun/star/embed/XEmbedPersist.hpp>
22#include <com/sun/star/embed/XEmbeddedObject.hpp>
23#include <com/sun/star/uno/Exception.hpp>
25#include <com/sun/star/beans/XPropertySet.hpp>
26#include <com/sun/star/beans/XPropertySetInfo.hpp>
27#include <com/sun/star/form/FormButtonType.hpp>
47#include <osl/diagnose.h>
52#include <drawview.hxx>
74 m_pModel(
std::move(pClipModel) ),
75 m_aObjDesc(
std::move( aDesc )),
80 m_bDragWasInternal( false ),
97 if (nSdrObjKind == SdrObjKind::OLE2)
102 uno::Reference< embed::XEmbedPersist > xPersObj(
static_cast<SdrOle2Obj*
>(
pObject)->GetObjRef(), uno::UNO_QUERY );
103 if ( xPersObj.is() && xPersObj->hasEntry() )
106 catch( uno::Exception& )
113 if (nSdrObjKind == SdrObjKind::Graphic)
116 if (
static_cast<SdrGrafObj*
>(
pObject)->GetGraphic().GetType() == GraphicType::Bitmap )
123 if (pUnoCtrl && SdrInventor::FmForm == pUnoCtrl->
GetObjInventor())
125 const uno::Reference<awt::XControlModel>& xControlModel = pUnoCtrl->
GetUnoControlModel();
126 OSL_ENSURE( xControlModel.is(),
"uno control without model" );
127 if ( xControlModel.is() )
129 uno::Reference< beans::XPropertySet > xPropSet( xControlModel, uno::UNO_QUERY );
130 uno::Reference< beans::XPropertySetInfo > xInfo = xPropSet->getPropertySetInfo();
132 OUString sPropButtonType(
"ButtonType" );
134 if(xInfo->hasPropertyByName( sPropButtonType ))
136 uno::Any aAny = xPropSet->getPropertyValue( sPropButtonType );
137 form::FormButtonType eTmp;
138 if ( (aAny >>= eTmp) && eTmp == form::FormButtonType_URL )
141 OUString sPropTargetURL(
"TargetURL" );
142 if(xInfo->hasPropertyByName( sPropTargetURL ))
144 aAny = xPropSet->getPropertyValue( sPropTargetURL );
146 if ( (aAny >>= sTmp) && !sTmp.isEmpty() )
148 OUString aUrl = sTmp;
149 OUString aAbs = aUrl;
164 OUString sPropLabel(
"Label" );
165 if(xInfo->hasPropertyByName( sPropLabel ))
167 aAny = xPropSet->getPropertyValue( sPropLabel );
168 if ( (aAny >>= sTmp) && !sTmp.isEmpty() )
204 if ( pContainerShell )
221 OSL_FAIL(
"ScDrawTransferObj wasn't released");
242 bool bOnlyControls =
false;
253 bOnlyControls =
true;
256 if (
dynamic_cast<const SdrUnoObj*
>( pObj) ==
nullptr)
258 bOnlyControls =
false;
267 return bOnlyControls;
274 AddFormat( SotClipboardFormatId::OBJECTDESCRIPTOR );
277 AddFormat( SotClipboardFormatId::BITMAP );
278 AddFormat( SotClipboardFormatId::GDIMETAFILE );
283 AddFormat( SotClipboardFormatId::DRAWING );
285 AddFormat( SotClipboardFormatId::OBJECTDESCRIPTOR );
287 AddFormat( SotClipboardFormatId::GDIMETAFILE );
289 AddFormat( SotClipboardFormatId::BITMAP );
294 AddFormat( SotClipboardFormatId::OBJECTDESCRIPTOR );
296 AddFormat( SotClipboardFormatId::STRING );
297 AddFormat( SotClipboardFormatId::UNIFORMRESOURCELOCATOR );
298 AddFormat( SotClipboardFormatId::NETSCAPE_BOOKMARK );
299 AddFormat( SotClipboardFormatId::DRAWING );
303 AddFormat( SotClipboardFormatId::EMBED_SOURCE );
304 AddFormat( SotClipboardFormatId::OBJECTDESCRIPTOR );
305 AddFormat( SotClipboardFormatId::GDIMETAFILE );
316 for(
const auto& rItem : aVector )
322 AddFormat( SotClipboardFormatId::EMBED_SOURCE );
323 AddFormat( SotClipboardFormatId::OBJECTDESCRIPTOR );
324 AddFormat( SotClipboardFormatId::DRAWING );
330 AddFormat( SotClipboardFormatId::BITMAP );
331 AddFormat( SotClipboardFormatId::GDIMETAFILE );
344 if (
m_bOleObj && nFormat != SotClipboardFormatId::GDIMETAFILE )
358 if ( nFormat == SotClipboardFormatId::LINKSRCDESCRIPTOR || nFormat == SotClipboardFormatId::OBJECTDESCRIPTOR )
362 else if ( nFormat == SotClipboardFormatId::DRAWING )
370 else if ( nFormat == SotClipboardFormatId::BITMAP
371 || nFormat == SotClipboardFormatId::PNG
372 || nFormat == SotClipboardFormatId::GDIMETAFILE )
378 OSL_ENSURE( pPv,
"pPv not there..." );
380 if ( nFormat == SotClipboardFormatId::GDIMETAFILE )
385 else if ( nFormat == SotClipboardFormatId::SVXB )
394 if (
pObject &&
pObject->GetObjIdentifier() == SdrObjKind::Graphic)
401 else if ( nFormat == SotClipboardFormatId::EMBED_SOURCE )
429 const css::datatransfer::DataFlavor& )
434 switch (nUserObjectId)
440 rxOStm->SetBufferSize( 0xff00 );
479 embed::XEmbeddedObject* pEmbObj =
static_cast<embed::XEmbeddedObject*
>(pUserObject);
483 uno::Reference< embed::XStorage > xWorkStore =
486 uno::Reference < embed::XEmbedPersist > xPers(
static_cast<embed::XVisualObject*
>(pEmbObj), uno::UNO_QUERY );
491 uno::Sequence < beans::PropertyValue >
aSeq;
492 OUString aDummyName(
"Dummy");
493 xPers->storeToEntry( xWorkStore, aDummyName,
aSeq,
aSeq );
494 if ( xWorkStore->isStreamElement( aDummyName ) )
497 uno::Reference < io::XStream > xNewStream = xWorkStore->openStreamElement( aDummyName, embed::ElementModes::READ );
504 uno::Reference < embed::XStorage > xNewStg = xWorkStore->openStorageElement( aDummyName, embed::ElementModes::READ );
505 xNewStg->copyToStorage( xDocStg );
506 uno::Reference < embed::XTransactedObject > xTrans( xDocStg, uno::UNO_QUERY );
511 catch ( uno::Exception& )
527 uno::Reference< embed::XStorage > xWorkStore =
534 SfxMedium aMedium( xWorkStore, OUString() );
538 uno::Reference< embed::XTransactedObject > xTransact( xWorkStore, uno::UNO_QUERY );
539 if ( xTransact.is() )
542 rxOStm->SetBufferSize( 0xff00 );
543 rxOStm->WriteStream( *pTempStream );
545 xWorkStore->dispose();
548 catch ( uno::Exception& )
556 OSL_FAIL(
"unknown object id");
589 OSL_ENSURE(pDestPV,
"PageView ?");
668 pEmbedTransfer->SetParentShellID(
maShellID);
690 pPool->CopyUsedGraphicStylesFrom(
m_pModel->GetStyleSheetPool());
695 SdrView aDestView(*pDestModel);
700 nullptr, SdrInsertFlags::NONE);
INetURLObject smartRel2Abs(OUString const &rTheRelURIRef, bool &rWasAbsolute, bool bIgnoreFragment=false, EncodeMechanism eMechanism=EncodeMechanism::WasEncoded, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8, bool bRelativeNonURIs=false, FSysStyle eStyle=FSysStyle::Detect) const
static void FillProtectedChartRangesVector(ScRangeListVector &rRangesVector, const ScDocument &rDocument, const SdrPage *pPage)
const ScDocument & GetDocument() const
void UpdateOle(const ScViewData &rViewData, bool bSnapSize=false)
virtual void SetVisArea(const tools::Rectangle &rVisArea) override
SC_DLLPUBLIC void InitDrawLayer(SfxObjectShell *pDocShell=nullptr)
SC_DLLPUBLIC const ScViewOptions & GetViewOptions() const
SC_DLLPUBLIC void SetViewOptions(const ScViewOptions &rOpt)
SC_DLLPUBLIC ScDrawLayer * GetDrawLayer()
SC_DLLPUBLIC ScStyleSheetPool * GetStyleSheetPool() const
virtual bool WriteObject(tools::SvRef< SotTempStream > &rxOStm, void *pUserObject, sal_uInt32 nUserObjectId, const css::datatransfer::DataFlavor &rFlavor) override
virtual ~ScDrawTransferObj() override
ScDragSrc m_nDragSourceFlags
void SetDrawPersist(const SfxObjectShellRef &rRef)
virtual void AddSupportedFormats() override
ScRangeListVector m_aProtectedChartRangesVector
void SetDragSource(const ScDrawView *pView)
static ScDrawTransferObj * GetOwnClipboard(const css::uno::Reference< css::datatransfer::XTransferable2 > &)
void SetDragWasInternal()
ScDrawTransferObj(std::unique_ptr< SdrModel > pClipModel, ScDocShell *pContainerShell, TransferableObjectDescriptor aDesc)
SdrOle2Obj * GetSingleObject()
TransferableDataHelper m_aOleData
virtual void DragFinished(sal_Int8 nDropAction) override
void SetDragSourceFlags(ScDragSrc nFlags)
SfxObjectShellRef m_aDocShellRef
std::unique_ptr< SdrModel > m_pModel
virtual bool GetData(const css::datatransfer::DataFlavor &rFlavor, const OUString &rDestDoc) override
void SetDragSourceObj(SdrObject &rObj, SCTAB nTab)
TransferableObjectDescriptor m_aObjDesc
std::unique_ptr< SdrView > m_pDragSourceView
SfxObjectShellRef m_aDrawPersistRef
const OUString & GetShellID() const
std::optional< INetBookmark > m_oBookmark
const ScDragData & GetDragData() const
void CopyStyleFrom(SfxStyleSheetBasePool *pSrcPool, const OUString &rName, SfxStyleFamily eFamily, bool bNewStyleHierarchy=false)
void SetScreen(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2)
void SetTabNo(SCTAB nNewTab)
void SetCurX(SCCOL nNewCurX)
void SetCurY(SCROW nNewCurY)
void SetOption(ScViewOption eOpt, bool bNew)
GDIMetaFile GetMarkedObjMetaFile(bool bNoVDevIfOneMtfMarked=false) const
virtual bool Paste(const SdrModel &rMod, const Point &rPos, SdrObjList *pLst, SdrInsertFlags nOptions)
virtual std::unique_ptr< SdrModel > CreateMarkedObjModel() const
BitmapEx GetMarkedObjBitmapEx(bool bNoVDevIfOneBmpMarked=false, const sal_uInt32 nMaximumQuadraticPixels=500000, const std::optional< Size > &rTargetDPI=std::nullopt) const
const Graphic & GetGraphic() const
size_t GetMarkCount() const
SdrMark * GetMark(size_t nNum) const
const SdrMarkList & GetMarkedObjectList() const
void MarkAllObj(SdrPageView *pPV=nullptr)
const tools::Rectangle & GetAllMarkedRect() const
bool MarkObj(const Point &rPnt, short nTol=-2, bool bToggle=false, bool bDeep=false)
SdrObject * GetMarkedSdrObj() const
sal_uInt16 GetMasterPageCount() const
const SfxItemPool & GetItemPool() const
void BurnInStyleSheetAttributes()
const SdrPage * GetPage(sal_uInt16 nPgNum) const
sal_uInt16 GetPageCount() const
SdrPageView * ShowSdrPage(SdrPage *pPage) override
const SfxPoolItem & GetMergedItem(const sal_uInt16 nWhich) const
virtual SdrInventor GetObjInventor() const
SdrModel & getSdrModelFromSdrObject() const
void SetMergedItem(const SfxPoolItem &rItem)
sal_Int64 GetAspect() const
css::uno::Reference< css::embed::XEmbeddedObject > const & GetObjRef() const
const Graphic * GetGraphic() const
virtual SdrPageView * ShowSdrPage(SdrPage *pPage)
SdrModel & getSdrModelFromSdrView() const
SdrPageView * GetSdrPageView() const
SdrModel & GetModel() const
const css::uno::Reference< css::awt::XControlModel > & GetUnoControlModel() const
const SfxPoolItem & GetDefaultItem(sal_uInt16 nWhich) const
const INetURLObject & GetURLObject() const
virtual bool DoSaveCompleted(SfxMedium *pNewStor=nullptr, bool bRegisterRecent=true)
SfxMedium * GetMedium() const
bool DoSaveObjectAs(SfxMedium &rNewStor, bool bCommit)
void SetupStorage(const css::uno::Reference< css::embed::XStorage > &xStorage, sal_Int32 nVersion, bool bTemplate) const
constexpr tools::Long Height() const
constexpr tools::Long Width() const
static SotClipboardFormatId GetFormat(const css::datatransfer::DataFlavor &rFlavor)
static void FillTransferableObjectDescriptor(TransferableObjectDescriptor &rDesc, const css::uno::Reference< css::embed::XEmbeddedObject > &xObj, const Graphic *pGraphic, sal_Int64 nAspect)
sal_uInt32 GetHeight() const
virtual void DragFinished(sal_Int8 nDropAction) override
const DataFlavorExVector & GetDataFlavorExVector() const
css::uno::Any GetAny(SotClipboardFormatId nFormat, const OUString &rDestDoc) const
bool HasFormat(SotClipboardFormatId nFormat) const
const css::uno::Reference< css::datatransfer::XTransferable > & GetTransferable() const
bool SetGraphic(const Graphic &rGraphic)
bool SetTransferableObjectDescriptor(const TransferableObjectDescriptor &rDesc)
bool SetAny(const css::uno::Any &rAny)
bool SetObject(void *pUserObject, sal_uInt32 nUserObjectId, const css::datatransfer::DataFlavor &rFlavor)
bool SetBitmapEx(const BitmapEx &rBitmap, const css::datatransfer::DataFlavor &rFlavor)
bool SetINetBookmark(const INetBookmark &rBmk, const css::datatransfer::DataFlavor &rFlavor)
bool HasFormat(SotClipboardFormatId nFormat)
void PrepareOLE(const TransferableObjectDescriptor &rObjDesc)
void AddFormat(SotClipboardFormatId nFormat)
bool SetGDIMetaFile(const GDIMetaFile &rMtf)
static css::uno::Reference< css::embed::XStorage > GetStorageFromStream(const css::uno::Reference< css::io::XStream > &xStream, sal_Int32 nStorageMode=css::embed::ElementModes::READWRITE, const css::uno::Reference< css::uno::XComponentContext > &rxContext=css::uno::Reference< css::uno::XComponentContext >())
static void CopyInputToOutput(const css::uno::Reference< css::io::XInputStream > &xInput, const css::uno::Reference< css::io::XOutputStream > &xOutput)
SvStream * GetStream(StreamMode eMode)
static void lcl_InitMarks(SdrMarkView &rDest, const SdrMarkView &rSource, SCTAB nTab)
constexpr sal_uInt32 SCDRAWTRANS_TYPE_DRAWMODEL
constexpr sal_uInt32 SCDRAWTRANS_TYPE_EMBOBJ
constexpr sal_uInt32 SCDRAWTRANS_TYPE_DOCUMENT
static bool lcl_HasOnlyControls(SdrModel *pModel)
constexpr TypedWhichId< SvxFontHeightItem > EE_CHAR_FONTHEIGHT(EE_CHAR_START+2)
EmbeddedObjectRef * pObject
::std::vector< DataFlavorEx > DataFlavorExVector
constexpr SdrLayerID SC_LAYER_FRONT(0)
constexpr SdrLayerID SC_LAYER_CONTROLS(3)
Sequence< sal_Int8 > aSeq
OUString ScResId(TranslateId aId)
ScDrawTransferObj * pDrawTransfer
SVXCORE_DLLPUBLIC bool SvxDrawingLayerExport(SdrModel *pModel, const css::uno::Reference< css::io::XOutputStream > &xOut)