svx/source/sdr/properties/attributeproperties.cxx | 24 ++++++++++++++++++++++ svx/source/sdr/properties/defaultproperties.cxx | 8 ++++++- sw/source/core/doc/doclay.cxx | 4 ++- 3 files changed, 34 insertions(+), 2 deletions(-)
New commits: commit 1a9dad9bdbe6ee8b81965d9b2c29c3dac5a1a642 Author: Armin Le Grand <armin.le.gr...@cib.de (CIB)> Date: Mon Mar 19 11:58:47 2018 +0100 SOSAW080: Corrected some SdrObject::Clone scenarios Especially when cloning to another SdrModel and taking the sdr::properties into account. Change-Id: Ic366d60299f239e3df856ddffedb19e743e4be0c diff --git a/svx/source/sdr/properties/attributeproperties.cxx b/svx/source/sdr/properties/attributeproperties.cxx index b10fcf4bc155..d14b7ffd6b2f 100644 --- a/svx/source/sdr/properties/attributeproperties.cxx +++ b/svx/source/sdr/properties/attributeproperties.cxx @@ -177,6 +177,30 @@ namespace sdr { SfxStyleSheet* pTargetStyleSheet(rProps.GetStyleSheet()); + if(pTargetStyleSheet && &rObj.getSdrModelFromSdrObject() != &GetSdrObject().getSdrModelFromSdrObject()) + { + // TTTT It is a clone to another model, thus the TargetStyleSheet + // is probably also from another SdrModel, so do *not* simply use it. + // + // The DefaultProperties::Clone already has cloned the ::SET items + // to a new SfxItemSet in the new SfxItemPool. There are quite some + // possibilities to continue: + // - Do not use StyleSheet (will do this for now) + // - Search for same StyleSheet in Target-SdrModel and use if found + // (use e.g. Name) + // - Clone used StyleSheet(s) to Target-SdrModel and use + // - Set all Attributes from the StyleSheet as hard attributes at the + // SfxItemSet + // The original AW080 uses 'ImpModelChange' (see there) which Clones + // and uses the used StyleSheets if there is a Target-SfxItemPool + // and sets to hard attributes if not. This may be used later if needed, + // but for now only a single UnitTest uses this Clone-scenario and works + // well with not using the TargetStyleSheet. The logic Cloning + // StyleSheets *should* - if needed - be on a higher level where it is + // potentially better known what would be the correct thing to do. + pTargetStyleSheet = nullptr; + } + if(pTargetStyleSheet) { if(HasSfxItemSet()) diff --git a/svx/source/sdr/properties/defaultproperties.cxx b/svx/source/sdr/properties/defaultproperties.cxx index 167e368382c4..15782c100d28 100644 --- a/svx/source/sdr/properties/defaultproperties.cxx +++ b/svx/source/sdr/properties/defaultproperties.cxx @@ -56,7 +56,13 @@ namespace sdr { if(rProps.mpItemSet) { - mpItemSet.reset(rProps.mpItemSet->Clone()); + // TTTT Clone may be to another model and thus another ItemPool + // SfxItemSet supports that thus we are able to Clone all + // SfxItemState::SET items to the target pool. + mpItemSet.reset( + rProps.mpItemSet->Clone( + true, + &rObj.getSdrModelFromSdrObject().GetItemPool())); // do not keep parent info, this may be changed by later constructors. // This class just copies the ItemSet, ignore parent. diff --git a/sw/source/core/doc/doclay.cxx b/sw/source/core/doc/doclay.cxx index 3b93cd9735da..4430547b343b 100644 --- a/sw/source/core/doc/doclay.cxx +++ b/sw/source/core/doc/doclay.cxx @@ -125,7 +125,9 @@ SdrObject* SwDoc::CloneSdrObj( const SdrObject& rObj, bool bMoveWithinDoc, getIDocumentDrawModelAccess().GetDrawModel()->InsertPage( pPg ); } - SdrObject *pObj = rObj.Clone(); + // TTTT Clone directly to target SdrModel + SdrObject *pObj = rObj.Clone(getIDocumentDrawModelAccess().GetDrawModel()); + if( bMoveWithinDoc && SdrInventor::FmForm == pObj->GetObjInventor() ) { // We need to preserve the Name for Controls _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits