diff options
author | Caolán McNamara <caolanm@redhat.com> | 2013-09-09 16:54:30 +0100 |
---|---|---|
committer | Fridrich Strba <fridrich@documentfoundation.org> | 2013-09-14 13:07:55 +0000 |
commit | 0964a73d03bf9f5b9f485ff39f97c7e7b54339b3 (patch) | |
tree | 03daf76da42bed476f8a34b5e36f524fa4876afc | |
parent | c09bd7346f38b5c2f4048fa3e613883690b98c51 (diff) |
Resolves: fdo#34987 skip autoheight reset if it will be set to the same value
Triggered by aa9af08b389a106fcfb53842ac7669b208a27205 which explicitly sets
rSet.Put( SdrTextAutoGrowHeightItem(FALSE) ); so there is something set on the
style which is being overwritten.
The code here resets the style to the default of "true" before going on to set
it to the explicit "false" again. In that window of time the master shapes
listen to the property change, on being set to autoheight they resize and on
being unset, they remain stuck on their autoheight calculated size.
Reviewed-on: https://gerrit.libreoffice.org/5887
Reviewed-by: mhofmann <borim7@web.de>
Reviewed-by: Thorsten Behrens <thb@documentfoundation.org>
Tested-by: Thorsten Behrens <thb@documentfoundation.org>
(cherry picked from commit 14e7a290dab7fead66ef6ff7f94c6a425d80ceb6)
Conflicts:
xmloff/source/draw/ximpstyl.cxx
Change-Id: I567a791b2bbbcb3a1a111633fabf509142984645
Reviewed-on: https://gerrit.libreoffice.org/5929
Reviewed-by: Fridrich Strba <fridrich@documentfoundation.org>
Tested-by: Fridrich Strba <fridrich@documentfoundation.org>
-rw-r--r-- | xmloff/source/draw/ximpstyl.cxx | 45 |
1 files changed, 43 insertions, 2 deletions
diff --git a/xmloff/source/draw/ximpstyl.cxx b/xmloff/source/draw/ximpstyl.cxx index db902df9a80a..d5fae19fef85 100644 --- a/xmloff/source/draw/ximpstyl.cxx +++ b/xmloff/source/draw/ximpstyl.cxx @@ -1312,6 +1312,43 @@ void SdXMLStylesContext::ImpSetCellStyles() const } } +//Resolves: fdo#34987 if the style's auto height before and after is the same +//then don't reset it back to the underlying default of true for the small +//period before its going to be reset to false again. Doing this avoids the +//master page shapes from resizing themselves due to autoheight becoming +//enabled before having autoheight turned off again and getting stuck on that +//autosized height +static bool canSkipReset(const OUString &rName, const XMLPropStyleContext* pPropStyle, + const uno::Reference< beans::XPropertySet > &rPropSet, const UniReference < XMLPropertySetMapper >& rPrMap) +{ + bool bCanSkipReset = false; + if (pPropStyle && rName == "TextAutoGrowHeight") + { + sal_Bool bOldStyleTextAutoGrowHeight(sal_False); + rPropSet->getPropertyValue("TextAutoGrowHeight") >>= bOldStyleTextAutoGrowHeight; + + sal_Int32 nIndexStyle = rPrMap->GetEntryIndex(XML_NAMESPACE_DRAW, "auto-grow-height", 0); + if (nIndexStyle != -1) + { + const ::std::vector< XMLPropertyState > &rProperties = pPropStyle->GetProperties(); + ::std::vector< XMLPropertyState >::const_iterator property = rProperties.begin(); + for(; property != rProperties.end(); ++property) + { + sal_Int32 nIdx = property->mnIndex; + if (nIdx == nIndexStyle) + { + sal_Bool bNewStyleTextAutoGrowHeight(sal_False); + property->maValue >>= bNewStyleTextAutoGrowHeight; + if (bNewStyleTextAutoGrowHeight == bOldStyleTextAutoGrowHeight) + bCanSkipReset = true;; + break; + } + } + } + } + return bCanSkipReset; +} + ////////////////////////////////////////////////////////////////////////////// // help function used by ImpSetGraphicStyles() and ImpSetMasterPageStyles() // @@ -1341,6 +1378,7 @@ void SdXMLStylesContext::ImpSetGraphicStyles( uno::Reference< container::XNameAc if(nFamily == pStyle->GetFamily() && !pStyle->IsDefaultStyle()) { OUString aStyleName(pStyle->GetDisplayName()); + if( nPrefLen ) { sal_Int32 nStylePrefLen = aStyleName.lastIndexOf( sal_Unicode('-') ) + 1; @@ -1350,6 +1388,8 @@ void SdXMLStylesContext::ImpSetGraphicStyles( uno::Reference< container::XNameAc aStyleName = aStyleName.copy( nPrefLen ); } + XMLPropStyleContext* pPropStyle = dynamic_cast< XMLPropStyleContext* >(const_cast< SvXMLStyleContext* >( pStyle ) ); + uno::Reference< style::XStyle > xStyle; if(xPageStyles->hasByName(aStyleName)) { @@ -1378,6 +1418,9 @@ void SdXMLStylesContext::ImpSetGraphicStyles( uno::Reference< container::XNameAc const OUString& rName = xPrMap->GetEntryAPIName( i ); if( xPropSetInfo->hasPropertyByName( rName ) && beans::PropertyState_DIRECT_VALUE == xPropState->getPropertyState( rName ) ) { + bool bCanSkipReset = canSkipReset(rName, pPropStyle, xPropSet, xPrMap); + if (bCanSkipReset) + continue; xPropState->setPropertyToDefault( rName ); } } @@ -1408,9 +1451,7 @@ void SdXMLStylesContext::ImpSetGraphicStyles( uno::Reference< container::XNameAc if(xStyle.is()) { // set properties at style - XMLPropStyleContext* pPropStyle = dynamic_cast< XMLPropStyleContext* >( const_cast< SvXMLStyleContext* >( pStyle ) ); uno::Reference< beans::XPropertySet > xPropSet(xStyle, uno::UNO_QUERY); - if(xPropSet.is() && pPropStyle) { pPropStyle->FillPropertySet(xPropSet); |