diff options
author | Armin Le Grand <Armin.Le.Grand@cib.de> | 2018-05-29 20:04:34 +0200 |
---|---|---|
committer | Thorsten Behrens <Thorsten.Behrens@CIB.de> | 2018-10-03 10:28:30 +0200 |
commit | bcf7aee3dc42ac4a82dec7fe5ded9d2796b69a66 (patch) | |
tree | 7f23d252bafda8ff811e9cb45441314be082dc04 /svx | |
parent | 8dbcd72f83e2317dd40c0fa605fd26b3f6a2616b (diff) |
Corrected PresObj Styles
When SdrPresObj's get constructed, e.g. when loading/
opening an Impress, the Styles for the PresObj's
(PresentationObjects) need to be constructed carefully
the same way as in former versions. This is a combination
of creating the SdrObject, adding a Style and setting default
Attributes, combined with in.-between corrections. All these
combinations make these fragile, plus the im/export using
ODF XML format and UNO API. With last SOSaw080 changes
not all places were correctly converted (mainly due to
new timing when and how a SdrObject belongs to a SdrPage).
Corrected this now, checked im/export/echange with
libreoffice-6-0 versions.
Stuff is more complicated that initially thought, see comment
added at AttributeProperties::GetObjectItemSet() for more info.
Adaption of the two UnitTest-Files is explained there, too.
Change-Id: Ia90a37492f3a92030790fbd27b7c532883bce923
Reviewed-on: https://gerrit.libreoffice.org/55029
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Armin Le Grand <Armin.Le.Grand@cib.de>
(cherry picked from commit 6ebe8b9068be019d9e8ce4f558eb07304e2023f6)
Reviewed-on: https://gerrit.libreoffice.org/61209
Tested-by: Jenkins
Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
Diffstat (limited to 'svx')
-rw-r--r-- | svx/source/sdr/properties/attributeproperties.cxx | 74 | ||||
-rw-r--r-- | svx/source/sdr/properties/graphicproperties.cxx | 3 | ||||
-rw-r--r-- | svx/source/sdr/properties/oleproperties.cxx | 3 | ||||
-rw-r--r-- | svx/source/sdr/properties/properties.cxx | 3 |
4 files changed, 42 insertions, 41 deletions
diff --git a/svx/source/sdr/properties/attributeproperties.cxx b/svx/source/sdr/properties/attributeproperties.cxx index e8eaf5b183f5..ebd3f8c14780 100644 --- a/svx/source/sdr/properties/attributeproperties.cxx +++ b/svx/source/sdr/properties/attributeproperties.cxx @@ -242,35 +242,42 @@ namespace sdr // remember if we had a SfxItemSet already const bool bHadSfxItemSet(HasSfxItemSet()); - // call parent - this will then guarantee - // SfxItemSet existence + // call parent - this will guarantee SfxItemSet existence DefaultProperties::GetObjectItemSet(); if(!bHadSfxItemSet) { - // SfxItemSet was created and ForceDefaultAttributes() is done. - // We now need to set a default SfxStyleSheet at the SdrObject. This - // is possible now since we always have the SdrModel in SdrObject, - // so use applyDefaultStyleSheetFromSdrModel() which will do the - // right thing in each derivation of BaseProperties. - // We also need to 'rescue' mpStyleSheet if it is already set, - // which means a SfxStyleSheet was already set/ocopied but not - // yet set at the SdrObject. See copy-constructor and how it remembers - // the SfxStyleSheet there. This time, do not reset the - // attributes already set - this is done above. - SfxStyleSheet* pImplicitelyAlreadySet(mpStyleSheet); - - // Set missing defaults and do RemoveHardAttributes. This is - // important, it deletes again the attributes set in - // ForceDefaultAttributes() which are set in the default - // SfxStyleSheet. - const_cast< AttributeProperties* >(this)->applyDefaultStyleSheetFromSdrModel(); - - if(pImplicitelyAlreadySet) + // need to take care for SfxStyleSheet for newly + // created SfxItemSet + if(nullptr == mpStyleSheet) + { + // Set missing defaults without removal of hard attributes. + // This is more complicated historically than I first thought: + // Originally for GetDefaultStyleSheetForSdrGrafObjAndSdrOle2Obj + // SetStyleSheet(..., false) was used, while for GetDefaultStyleSheet + // SetStyleSheet(..., true) was used. Thus, for SdrGrafObj and SdrOle2Obj + // bDontRemoveHardAttr == false -> *do* delete hard attributes was used. + // This was probably not done by purpose, adding the method + // GetDefaultStyleSheetForSdrGrafObjAndSdrOle2Obj additionally to + // GetDefaultStyleSheet was an enhancement to allow for SdrGrafObj/SdrOle2Obj + // with full AttributeSet (adding e.g. FillAttributes). To stay as compatible + // as possible these SdrObjects got a new default-StyleSheet. + // There is no reason to delete the HardAttributes and it anyways has only + // AFAIK effects on a single Item - the SdrTextHorzAdjustItem. To get things + // unified I will stay with not deleting the HardAttributes and adapt the + // UnitTests in CppunitTest_sd_import_tests accordingly. + const_cast< AttributeProperties* >(this)->applyDefaultStyleSheetFromSdrModel(); + } + else { // Late-Init of setting parent to SfxStyleSheet after - // it's creation. - const_cast< AttributeProperties* >(this)->SetStyleSheet(pImplicitelyAlreadySet, true); + // it's creation. Can only happen from copy-constructor + // (where creation of SfxItemSet is avoided due to the + // problem with constructors and virtual functions in C++), + // thus DontRemoveHardAttr is not needed. + const_cast< AttributeProperties* >(this)->SetStyleSheet( + mpStyleSheet, + true); } } @@ -335,11 +342,8 @@ namespace sdr } } - // set item - if(!HasSfxItemSet()) - { - GetObjectItemSet(); - } + // guarantee SfxItemSet existence + GetObjectItemSet(); if(pResultItem) { @@ -366,11 +370,8 @@ namespace sdr void AttributeProperties::SetStyleSheet(SfxStyleSheet* pNewStyleSheet, bool bDontRemoveHardAttr) { - // guarantee SfxItemSet existence here - if(!HasSfxItemSet()) - { - GetObjectItemSet(); - } + // guarantee SfxItemSet existence + GetObjectItemSet(); ImpRemoveStyleSheet(); ImpAddStyleSheet(pNewStyleSheet, bDontRemoveHardAttr); @@ -390,11 +391,8 @@ namespace sdr if(!GetStyleSheet() || dynamic_cast<const SfxStyleSheet *>(mpStyleSheet) == nullptr) return; - // force SfxItemSet existence - if(!HasSfxItemSet()) - { - GetObjectItemSet(); - } + // guarantee SfxItemSet existence + GetObjectItemSet(); // prepare copied, new itemset, but WITHOUT parent SfxItemSet* pDestItemSet = new SfxItemSet(*mpItemSet); diff --git a/svx/source/sdr/properties/graphicproperties.cxx b/svx/source/sdr/properties/graphicproperties.cxx index 2c606b80d433..9097857b2827 100644 --- a/svx/source/sdr/properties/graphicproperties.cxx +++ b/svx/source/sdr/properties/graphicproperties.cxx @@ -39,7 +39,8 @@ namespace sdr if(pStyleSheet) { - SetStyleSheet(pStyleSheet, false); + // do not delete hard attributes when setting dsefault Style + SetStyleSheet(pStyleSheet, true); } else { diff --git a/svx/source/sdr/properties/oleproperties.cxx b/svx/source/sdr/properties/oleproperties.cxx index 096e3e2ec71f..a2a8773987ea 100644 --- a/svx/source/sdr/properties/oleproperties.cxx +++ b/svx/source/sdr/properties/oleproperties.cxx @@ -34,7 +34,8 @@ namespace sdr if(pStyleSheet) { - SetStyleSheet(pStyleSheet, false); + // do not delete hard attributes when setting dsefault Style + SetStyleSheet(pStyleSheet, true); } else { diff --git a/svx/source/sdr/properties/properties.cxx b/svx/source/sdr/properties/properties.cxx index 9670c743722f..bdeeeeaaec8d 100644 --- a/svx/source/sdr/properties/properties.cxx +++ b/svx/source/sdr/properties/properties.cxx @@ -43,7 +43,8 @@ namespace sdr void BaseProperties::applyDefaultStyleSheetFromSdrModel() { - SetStyleSheet(GetSdrObject().getSdrModelFromSdrObject().GetDefaultStyleSheet(), false); + // do not delete hard attributes when setting dsefault Style + SetStyleSheet(GetSdrObject().getSdrModelFromSdrObject().GetDefaultStyleSheet(), true); } const SdrObject& BaseProperties::GetSdrObject() const |