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>
70 m_pModel(
std::move(pClipModel) ),
76 m_bDragWasInternal(
false ),
87 if (pObject && !aIter.
Next())
93 if (nSdrObjKind == SdrObjKind::OLE2)
98 uno::Reference< embed::XEmbedPersist > xPersObj( static_cast<SdrOle2Obj*>(pObject)->GetObjRef(), uno::UNO_QUERY );
99 if ( xPersObj.is() && xPersObj->hasEntry() )
102 catch( uno::Exception& )
109 if (nSdrObjKind == SdrObjKind::Graphic)
112 if ( static_cast<SdrGrafObj*>(pObject)->GetGraphic().GetType() == GraphicType::Bitmap )
119 if (pUnoCtrl && SdrInventor::FmForm == pUnoCtrl->
GetObjInventor())
121 const uno::Reference<awt::XControlModel>& xControlModel = pUnoCtrl->
GetUnoControlModel();
122 OSL_ENSURE( xControlModel.is(),
"uno control without model" );
123 if ( xControlModel.is() )
125 uno::Reference< beans::XPropertySet > xPropSet( xControlModel, uno::UNO_QUERY );
126 uno::Reference< beans::XPropertySetInfo > xInfo = xPropSet->getPropertySetInfo();
128 OUString sPropButtonType(
"ButtonType" );
130 if(xInfo->hasPropertyByName( sPropButtonType ))
132 uno::Any aAny = xPropSet->getPropertyValue( sPropButtonType );
133 form::FormButtonType eTmp;
134 if ( (aAny >>= eTmp) && eTmp == form::FormButtonType_URL )
137 OUString sPropTargetURL(
"TargetURL" );
138 if(xInfo->hasPropertyByName( sPropTargetURL ))
140 aAny = xPropSet->getPropertyValue( sPropTargetURL );
142 if ( (aAny >>= sTmp) && !sTmp.isEmpty() )
144 OUString aUrl = sTmp;
145 OUString aAbs = aUrl;
160 OUString sPropLabel(
"Label" );
161 if(xInfo->hasPropertyByName( sPropLabel ))
163 aAny = xPropSet->getPropertyValue( sPropLabel );
164 if ( (aAny >>= sTmp) && !sTmp.isEmpty() )
200 if ( pContainerShell )
217 OSL_FAIL(
"ScDrawTransferObj wasn't released");
233 return comphelper::getFromUnoTunnel<ScDrawTransferObj>(xTransferable);
238 bool bOnlyControls =
false;
249 bOnlyControls =
true;
252 if (dynamic_cast<const SdrUnoObj*>( pObj) ==
nullptr)
254 bOnlyControls =
false;
263 return bOnlyControls;
270 AddFormat( SotClipboardFormatId::OBJECTDESCRIPTOR );
273 AddFormat( SotClipboardFormatId::BITMAP );
274 AddFormat( SotClipboardFormatId::GDIMETAFILE );
279 AddFormat( SotClipboardFormatId::DRAWING );
281 AddFormat( SotClipboardFormatId::OBJECTDESCRIPTOR );
283 AddFormat( SotClipboardFormatId::GDIMETAFILE );
285 AddFormat( SotClipboardFormatId::BITMAP );
290 AddFormat( SotClipboardFormatId::OBJECTDESCRIPTOR );
292 AddFormat( SotClipboardFormatId::STRING );
293 AddFormat( SotClipboardFormatId::UNIFORMRESOURCELOCATOR );
294 AddFormat( SotClipboardFormatId::NETSCAPE_BOOKMARK );
295 AddFormat( SotClipboardFormatId::DRAWING );
299 AddFormat( SotClipboardFormatId::EMBED_SOURCE );
300 AddFormat( SotClipboardFormatId::OBJECTDESCRIPTOR );
301 AddFormat( SotClipboardFormatId::GDIMETAFILE );
312 for(
const auto& rItem : aVector )
318 AddFormat( SotClipboardFormatId::EMBED_SOURCE );
319 AddFormat( SotClipboardFormatId::OBJECTDESCRIPTOR );
320 AddFormat( SotClipboardFormatId::DRAWING );
326 AddFormat( SotClipboardFormatId::BITMAP );
327 AddFormat( SotClipboardFormatId::GDIMETAFILE );
340 if (
m_bOleObj && nFormat != SotClipboardFormatId::GDIMETAFILE )
354 if ( nFormat == SotClipboardFormatId::LINKSRCDESCRIPTOR || nFormat == SotClipboardFormatId::OBJECTDESCRIPTOR )
358 else if ( nFormat == SotClipboardFormatId::DRAWING )
362 else if ( nFormat == SotClipboardFormatId::BITMAP
363 || nFormat == SotClipboardFormatId::PNG
364 || nFormat == SotClipboardFormatId::GDIMETAFILE )
370 OSL_ENSURE( pPv,
"pPv not there..." );
372 if ( nFormat == SotClipboardFormatId::GDIMETAFILE )
377 else if ( nFormat == SotClipboardFormatId::SVXB )
393 else if ( nFormat == SotClipboardFormatId::EMBED_SOURCE )
421 const css::datatransfer::DataFlavor& )
426 switch (nUserObjectId)
431 rxOStm->SetBufferSize( 0xff00 );
439 OSL_ENSURE(0 ==
m_pModel->GetMasterPageCount(),
"SW with MasterPages (!)");
441 for(sal_uInt16
a(0);
a <
m_pModel->GetPageCount();
a++)
446 while(aIter.IsMore())
470 embed::XEmbeddedObject* pEmbObj =
static_cast<embed::XEmbeddedObject*
>(pUserObject);
474 uno::Reference< embed::XStorage > xWorkStore =
477 uno::Reference < embed::XEmbedPersist > xPers( static_cast<embed::XVisualObject*>(pEmbObj), uno::UNO_QUERY );
482 uno::Sequence < beans::PropertyValue >
aSeq;
483 OUString aDummyName(
"Dummy");
484 xPers->storeToEntry( xWorkStore, aDummyName, aSeq, aSeq );
485 if ( xWorkStore->isStreamElement( aDummyName ) )
488 uno::Reference < io::XStream > xNewStream = xWorkStore->openStreamElement( aDummyName, embed::ElementModes::READ );
495 uno::Reference < embed::XStorage > xNewStg = xWorkStore->openStorageElement( aDummyName, embed::ElementModes::READ );
496 xNewStg->copyToStorage( xDocStg );
497 uno::Reference < embed::XTransactedObject > xTrans( xDocStg, uno::UNO_QUERY );
502 catch ( uno::Exception& )
518 uno::Reference< embed::XStorage > xWorkStore =
525 SfxMedium aMedium( xWorkStore, OUString() );
529 uno::Reference< embed::XTransactedObject > xTransact( xWorkStore, uno::UNO_QUERY );
530 if ( xTransact.is() )
536 rxOStm->SetBufferSize( 0xff00 );
537 rxOStm->WriteStream( *pSrcStm );
541 xWorkStore->dispose();
544 catch ( uno::Exception& )
552 OSL_FAIL(
"unknown object id");
585 OSL_ENSURE(pDestPV,
"PageView ?");
589 for (
size_t i=0;
i<nCount; ++
i)
664 pEmbedTransfer->SetParentShellID(
maShellID);
687 SdrView aDestView(*pDestModel);
692 nullptr, SdrInsertFlags::NONE);
703 if ( dynamic_cast<const SdrUnoObj*>( pObject) !=
nullptr )
707 pObject = aIter.
Next();
729 return theScDrawTransferObjUnoTunnelId.
getSeq();
ScDragSrc m_nDragSourceFlags
void SetOption(ScViewOption eOpt, bool bNew)
static ScDrawTransferObj * GetOwnClipboard(const css::uno::Reference< css::datatransfer::XTransferable2 > &)
static void FillProtectedChartRangesVector(ScRangeListVector &rRangesVector, const ScDocument &rDocument, const SdrPage *pPage)
const ScDragData & GetDragData() const
size_t GetMarkCount() const
void SetCurX(SCCOL nNewCurX)
css::uno::Any GetAny(SotClipboardFormatId nFormat, const OUString &rDestDoc) const
bool SetBitmapEx(const BitmapEx &rBitmap, const css::datatransfer::DataFlavor &rFlavor)
virtual bool DoSaveCompleted(SfxMedium *pNewStor=nullptr, bool bRegisterRecent=true)
css::uno::Reference< css::embed::XEmbeddedObject > const & GetObjRef() const
static void CopyInputToOutput(const css::uno::Reference< css::io::XInputStream > &xInput, const css::uno::Reference< css::io::XOutputStream > &xOutput)
virtual bool Paste(const SdrModel &rMod, const Point &rPos, SdrObjList *pLst, SdrInsertFlags nOptions)
::std::vector< DataFlavorEx > DataFlavorExVector
TransferableDataHelper m_aOleData
bool SetTransferableObjectDescriptor(const TransferableObjectDescriptor &rDesc)
virtual void DragFinished(sal_Int8 nDropAction) override
virtual void AddSupportedFormats() override
bool HasFormat(SotClipboardFormatId nFormat)
SdrMark * GetMark(size_t nNum) const
ScRangeListVector m_aProtectedChartRangesVector
constexpr sal_uInt32 SCDRAWTRANS_TYPE_DOCUMENT
void SetDragWasInternal()
virtual SdrObjKind GetObjIdentifier() const
EmbeddedObjectRef * pObject
bool HasFormat(SotClipboardFormatId nFormat) const
constexpr TypedWhichId< SvxFontHeightItem > EE_CHAR_FONTHEIGHT(EE_CHAR_START+2)
static bool lcl_HasOnlyControls(SdrModel *pModel)
bool SetINetBookmark(const INetBookmark &rBmk, const css::datatransfer::DataFlavor &rFlavor)
bool SetObject(void *pUserObject, sal_uInt32 nUserObjectId, const css::datatransfer::DataFlavor &rFlavor)
void AddFormat(SotClipboardFormatId nFormat)
constexpr tools::Long Width() const
static std::unique_ptr< SvStream > CreateStream(const OUString &rFileName, StreamMode eOpenMode, css::uno::Reference< css::awt::XWindow > xParentWin=nullptr)
void SetDragSourceFlags(ScDragSrc nFlags)
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 >())
virtual bool WriteObject(tools::SvRef< SotTempStream > &rxOStm, void *pUserObject, sal_uInt32 nUserObjectId, const css::datatransfer::DataFlavor &rFlavor) override
static void lcl_InitMarks(SdrMarkView &rDest, const SdrMarkView &rSource, SCTAB nTab)
virtual void DragFinished(sal_Int8 nDropAction) override
ScDrawTransferObj * pDrawTransfer
SdrPageView * ShowSdrPage(SdrPage *pPage) override
virtual bool GetData(const css::datatransfer::DataFlavor &rFlavor, const OUString &rDestDoc) override
GDIMetaFile GetMarkedObjMetaFile(bool bNoVDevIfOneMtfMarked=false) const
virtual sal_Int64 SAL_CALL getSomething(const css::uno::Sequence< sal_Int8 > &rId) override
const css::uno::Sequence< sal_Int8 > & getSeq() const
SdrObject * GetMarkedSdrObj() const
void SetTabNo(SCTAB nNewTab)
void MarkAllObj(SdrPageView *pPV=nullptr)
bool SetGraphic(const Graphic &rGraphic)
SC_DLLPUBLIC ScDrawLayer * GetDrawLayer()
SC_DLLPUBLIC void InitDrawLayer(SfxObjectShell *pDocShell=nullptr)
constexpr sal_uInt32 SCDRAWTRANS_TYPE_EMBOBJ
OUString const & GetURL() const
const Graphic & GetGraphic() const
std::unique_ptr< SdrModel > m_pModel
void SetCurY(SCROW nNewCurY)
SC_DLLPUBLIC void SetViewOptions(const ScViewOptions &rOpt)
const SdrMarkList & GetMarkedObjectList() const
const SdrPage * GetPage(sal_uInt16 nPgNum) const
SdrModel & getSdrModelFromSdrObject() const
void PrepareOLE(const TransferableObjectDescriptor &rObjDesc)
static css::uno::Reference< css::embed::XStorage > GetStorageFromURL(const OUString &aURL, sal_Int32 nStorageMode, const css::uno::Reference< css::uno::XComponentContext > &rxContext=css::uno::Reference< css::uno::XComponentContext >())
virtual SdrPageView * ShowSdrPage(SdrPage *pPage)
void SetMergedItem(const SfxPoolItem &rItem)
const SfxPoolItem & GetMergedItem(const sal_uInt16 nWhich) const
ScDrawTransferObj(std::unique_ptr< SdrModel > pClipModel, ScDocShell *pContainerShell, const TransferableObjectDescriptor &rDesc)
const SfxPoolItem & GetDefaultItem(sal_uInt16 nWhich) const
const tools::Rectangle & GetAllMarkedRect() const
virtual SdrInventor GetObjInventor() const
SC_DLLPUBLIC const ScViewOptions & GetViewOptions() const
static SotClipboardFormatId GetFormat(const css::datatransfer::DataFlavor &rFlavor)
void UpdateOle(const ScViewData &rViewData, bool bSnapSize=false)
std::unique_ptr< SdrView > m_pDragSourceView
sal_uInt32 GetHeight() const
const OUString & GetShellID() const
sal_Int64 GetAspect() const
static void FillTransferableObjectDescriptor(TransferableObjectDescriptor &rDesc, const css::uno::Reference< css::embed::XEmbeddedObject > &xObj, const Graphic *pGraphic, sal_Int64 nAspect)
void SetDragSourceObj(SdrObject &rObj, SCTAB nTab)
constexpr tools::Long Height() const
std::unique_ptr< INetBookmark > m_pBookmark
sal_Int64 getSomethingImpl(const css::uno::Sequence< sal_Int8 > &rId, T *pThis, FallbackToGetSomethingOf< Base >={})
constexpr SdrLayerID SC_LAYER_FRONT(0)
const INetURLObject & GetURLObject() const
constexpr sal_uInt32 SCDRAWTRANS_TYPE_DRAWMODEL
static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId()
Sequence< sal_Int8 > aSeq
const ScDocument & GetDocument() const
SfxObjectShellRef m_aDocShellRef
BitmapEx GetMarkedObjBitmapEx(bool bNoVDevIfOneBmpMarked=false, const sal_uInt32 nMaximumQuadraticPixels=500000, const std::optional< Size > &rTargetDPI=std::nullopt) const
void SetDrawPersist(const SfxObjectShellRef &rRef)
SdrPageView * GetSdrPageView() const
const css::uno::Reference< css::awt::XControlModel > & GetUnoControlModel() const
bool DoSaveObjectAs(SfxMedium &rNewStor, bool bCommit)
SVXCORE_DLLPUBLIC bool SvxDrawingLayerExport(SdrModel *pModel, const css::uno::Reference< css::io::XOutputStream > &xOut)
void SetupStorage(const css::uno::Reference< css::embed::XStorage > &xStorage, sal_Int32 nVersion, bool bTemplate) const
SdrModel & getSdrModelFromSdrView() const
bool MarkObj(const Point &rPnt, short nTol=-2, bool bToggle=false, bool bDeep=false)
virtual void SetVisArea(const tools::Rectangle &rVisArea) override
void SetScreen(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2)
bool SetAny(const css::uno::Any &rAny)
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
const css::uno::Reference< css::datatransfer::XTransferable > & GetTransferable() const
SdrModel * GetModel() const
TransferableObjectDescriptor m_aObjDesc
constexpr SdrLayerID SC_LAYER_CONTROLS(3)
void SetDragSource(const ScDrawView *pView)
void EnableKillingFile(bool bEnable=true)
SfxObjectShellRef m_aDrawPersistRef
bool SetGDIMetaFile(const GDIMetaFile &rMtf)
const Graphic * GetGraphic() const
bool m_bDetectedRangeSegmentation false
virtual ~ScDrawTransferObj() override
SdrOle2Obj * GetSingleObject()
virtual void NbcSetLayer(SdrLayerID nLayer)
const DataFlavorExVector & GetDataFlavorExVector() const
SfxMedium * GetMedium() const