diff options
-rw-r--r-- | sc/source/ui/navipi/content.cxx | 14 | ||||
-rw-r--r-- | svx/source/svdraw/svdxcgv.cxx | 15 |
2 files changed, 20 insertions, 9 deletions
diff --git a/sc/source/ui/navipi/content.cxx b/sc/source/ui/navipi/content.cxx index 49558c8c19b1..48b95d965767 100644 --- a/sc/source/ui/navipi/content.cxx +++ b/sc/source/ui/navipi/content.cxx @@ -1137,7 +1137,21 @@ static bool lcl_DoDragObject( ScDocShell* pSrcShell, const OUString& rName, ScCo SdrPageView* pPV = aEditView.GetSdrPageView(); aEditView.MarkObj(pObject, pPV); + // tdf125520 this is a D&D-start potentially with an OLE object. If + // so, we need to do similar as e.g. in ScDrawView::BeginDrag so that + // the temporary SdrModel for transfer does have a GetPersist() so + // that the EmbeddedObjectContainer gets copied. We noeed no CheckOle + // here, test is simpler. + ScDocShellRef aDragShellRef; + if(OBJ_OLE2 == pObject->GetObjIdentifier()) + { + aDragShellRef = new ScDocShell; // DocShell needs a Ref immediately + aDragShellRef->DoInitNew(); + } + + ScDrawLayer::SetGlobalDrawPersist(aDragShellRef.get()); std::unique_ptr<SdrModel> pDragModel(aEditView.CreateMarkedObjModel()); + ScDrawLayer::SetGlobalDrawPersist(nullptr); TransferableObjectDescriptor aObjDesc; pSrcShell->FillTransferableObjectDescriptor( aObjDesc ); diff --git a/svx/source/svdraw/svdxcgv.cxx b/svx/source/svdraw/svdxcgv.cxx index c3fccab27d74..e8c8a3218a89 100644 --- a/svx/source/svdraw/svdxcgv.cxx +++ b/svx/source/svdraw/svdxcgv.cxx @@ -47,6 +47,7 @@ #include <sdr/contact/objectcontactofobjlistpainter.hxx> #include <svx/sdr/contact/displayinfo.hxx> #include <svx/svdotable.hxx> +#include <sal/log.hxx> using namespace com::sun::star; @@ -735,16 +736,12 @@ std::unique_ptr<SdrModel> SdrExchangeView::CreateMarkedObjModel() const if(nullptr == pNewObj) { // not cloned yet - if (pObj->GetObjIdentifier() == OBJ_OLE2) + if(pObj->GetObjIdentifier() == OBJ_OLE2 && nullptr == mpModel->GetPersist()) { - // tdf#125520 - temp SdrModel will need a comphelper::IEmbeddedHelper - // to successfully clone the OLE content, use the one from source model - // in the temporary SdrModel - it gets not deleted in SdrModel destructor. - // As long as the temporary SdrModel is used temporarily (and does NOT get - // extended to a full document) this *should* work. There stay some - // concerns about what may happen in BG and if saved/loaded from clipboard, - // so this *might* need to be enhanced in the future. - pNewModel->SetPersist(mpModel->GetPersist()); + // tdf#125520 - former fix was wrong, the SdrModel + // has to have a GetPersist() already, see task. + // We can still warn here when this is not the case + SAL_WARN( "svx", "OLE gets cloned Persist, EmbeddedObjectContainer will not be copied" ); } // use default way |