diff options
author | Armin Le Grand <Armin.Le.Grand@me.com> | 2020-03-10 16:15:45 +0100 |
---|---|---|
committer | Xisco FaulĂ <xiscofauli@libreoffice.org> | 2020-03-17 14:05:17 +0100 |
commit | 90f57175abf31ebad850c9653b41eccd230893b8 (patch) | |
tree | ebb348876413982c955c9d8bcda5e565274cf3a4 | |
parent | 2898943ed765290e2c58f8dd84053b4ef9ac158e (diff) |
tdf#125520 create a persist correctly for OLE
If the D&D-Start described as in the task is an
OLE object we need to create a Persist-object
to copy the included EmbeddedObjectContainer
Change-Id: Ib8b9677bbc3e6c5b3895abc55e6da5b0a96e33d8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90263
Tested-by: Jenkins
Reviewed-by: Armin Le Grand <Armin.Le.Grand@me.com>
Signed-off-by: Xisco Fauli <xiscofauli@libreoffice.org>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90336
-rw-r--r-- | sc/source/ui/navipi/content.cxx | 14 | ||||
-rw-r--r-- | svx/source/svdraw/svdxcgv.cxx | 12 |
2 files changed, 25 insertions, 1 deletions
diff --git a/sc/source/ui/navipi/content.cxx b/sc/source/ui/navipi/content.cxx index b3800f9505e6..9c556ecddd91 100644 --- a/sc/source/ui/navipi/content.cxx +++ b/sc/source/ui/navipi/content.cxx @@ -1230,7 +1230,21 @@ static void 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 8fcd742ec71f..88083f3e93e0 100644 --- a/svx/source/svdraw/svdxcgv.cxx +++ b/svx/source/svdraw/svdxcgv.cxx @@ -57,6 +57,7 @@ #include <svx/sdr/contact/objectcontactofobjlistpainter.hxx> #include <svx/sdr/contact/displayinfo.hxx> #include <svx/svdotable.hxx> +#include <sal/log.hxx> using namespace com::sun::star; @@ -744,7 +745,16 @@ std::unique_ptr<SdrModel> SdrExchangeView::CreateMarkedObjModel() const if(nullptr == pNewObj) { - // not cloned yet, use default way + // not cloned yet + if(pObj->GetObjIdentifier() == OBJ_OLE2 && nullptr == 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 pNewObj = pObj->CloneSdrObject(*pNewModel); } |