From 14e7a290dab7fead66ef6ff7f94c6a425d80ceb6 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Mon, 9 Sep 2013 16:54:30 +0100 Subject: 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. Change-Id: I567a791b2bbbcb3a1a111633fabf509142984645 Reviewed-on: https://gerrit.libreoffice.org/5887 Reviewed-by: mhofmann Reviewed-by: Thorsten Behrens Tested-by: Thorsten Behrens --- xmloff/source/draw/ximpstyl.cxx | 45 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/xmloff/source/draw/ximpstyl.cxx b/xmloff/source/draw/ximpstyl.cxx index e092e37807be..ea0fc4a69568 100644 --- a/xmloff/source/draw/ximpstyl.cxx +++ b/xmloff/source/draw/ximpstyl.cxx @@ -1261,6 +1261,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() // void SdXMLStylesContext::ImpSetGraphicStyles( uno::Reference< container::XNameAccess >& xPageStyles, sal_uInt16 nFamily, const OUString& rPrefix) const @@ -1289,6 +1326,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; @@ -1298,6 +1336,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)) { @@ -1326,6 +1366,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 ); } } @@ -1356,9 +1399,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); -- cgit v1.2.3