summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--svx/source/svdraw/svdobj.cxx7
-rw-r--r--svx/source/unodraw/unopage.cxx31
2 files changed, 38 insertions, 0 deletions
diff --git a/svx/source/svdraw/svdobj.cxx b/svx/source/svdraw/svdobj.cxx
index b5dd038d5622..490af4051362 100644
--- a/svx/source/svdraw/svdobj.cxx
+++ b/svx/source/svdraw/svdobj.cxx
@@ -438,6 +438,13 @@ void SdrObject::SetPage(SdrPage* pNewPage)
// If the page is changing to another page with the same model, we
// assume they create compatible UNO shape objects so we shouldn't have
// to invalidate.
+ // TTTT: This causes quite some problems in SvxDrawPage::add when used
+ // e.g. from Writer - the SdrObject may be cloned to target model, and
+ // the xShape was added to it by purpose (see there). Thus it will be
+ // good to think about if this is really needed - it *seems* to be intended
+ // for a xShape being a on-demand-creatable resource - wit hthe argument that
+ // the SdrPage/UnoPage used influences the SvxShape creation. This uses
+ // ressources and would be nice to get rid of anyways.
if (pOldPage != pPage && !(pOldPage && pPage && pOldModel == &getSdrModelFromSdrObject()))
{
SvxShape* const pShape(getSvxShape());
diff --git a/svx/source/unodraw/unopage.cxx b/svx/source/unodraw/unopage.cxx
index f35a104f6da5..3dc69e899965 100644
--- a/svx/source/unodraw/unopage.cxx
+++ b/svx/source/unodraw/unopage.cxx
@@ -191,6 +191,24 @@ void SAL_CALL SvxDrawPage::add( const uno::Reference< drawing::XShape >& xShape
return;
SdrObject *pObj = pShape->GetSdrObject();
+ bool bNeededToClone(false);
+
+ if(nullptr != pObj && &pObj->getSdrModelFromSdrObject() != &mpPage->getSdrModelFromSdrPage())
+ {
+ // TTTT UNO API tries to add an existing SvxShape to this SvxDrawPage,
+ // but these use different SdrModels. It was possible before to completely
+ // 'change' a SdrObject to another SdrModel (including dangerous MigrateItemPool
+ // stuff), but is no longer. We need to Clone the SdrObject to the target model
+ // and ::Create a new SvxShape (set SdrObject there, take obver values, ...)
+ SdrObject* pClonedSdrShape(pObj->Clone(&mpPage->getSdrModelFromSdrPage()));
+ pObj->setUnoShape(nullptr);
+ pClonedSdrShape->setUnoShape(xShape);
+ // pShape->InvalidateSdrObject();
+ // pShape->Create(pClonedSdrShape, this);
+ SdrObject::Free(pObj);
+ pObj = pClonedSdrShape;
+ bNeededToClone = true;
+ }
if(!pObj)
{
@@ -200,6 +218,19 @@ void SAL_CALL SvxDrawPage::add( const uno::Reference< drawing::XShape >& xShape
else if ( !pObj->IsInserted() )
{
mpPage->InsertObject( pObj );
+
+ if(bNeededToClone)
+ {
+ // TTTT Unfortunately in SdrObject::SetPage (see there) the
+ // xShape/UnoShape at the newly cloned SDrObject is *removed* again,
+ // so re-set it here, the caller *may need it* (e.g. Writer)
+ uno::Reference< uno::XInterface > xShapeCheck(pObj->getWeakUnoShape());
+
+ if( !xShapeCheck.is() )
+ {
+ pObj->setUnoShape(xShape);
+ }
+ }
}
pShape->Create( pObj, this );