From 2571b39158c679a42a68bea5f219e29a42f4e6a6 Mon Sep 17 00:00:00 2001 From: Justin Luth Date: Sat, 11 Mar 2023 17:50:14 -0500 Subject: tdf#154129 writerfilter framePr: check whole style inheritance: W/H This patch depends on HAnchor, which created vProps. This patch changes the logic a little bit from the previous code. Before, the paragraph has to specify something other than 0 (auto) in order to be acceptable. Well, I don't see any reason why direct formatting shouldn't be able to override a non-auto style value, so we'll make the change and see how it plays out. Errata says: "The standard states that 0 is a valid value of the h attribute. HOWEVER Word treats a value of 0 on this attribute as a value of auto." and: "The standard states that the values of the h attribute are defined by the ST_TwipsMeasure simple type. HOWEVER Word restricts the value of this attribute to be at least 1 and at most 31680." There were no existing ooxmlexport unit tests where the old and new method produced different values. Change-Id: I48934598c1bca8ffc99b97b114d77505f3341105 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148715 Reviewed-by: Justin Luth Tested-by: Jenkins --- writerfilter/source/dmapper/DomainMapper_Impl.cxx | 27 ++++++++++++++++------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index bc1f7f8452ed..e3baf350b5f9 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -1626,19 +1626,30 @@ void DomainMapper_Impl::CheckUnregisteredFrameConversion( ) const StyleSheetPropertyMap* pStyleProperties = pParaStyle->m_pProperties.get(); if (!pStyleProperties) return; - sal_Int32 nWidth = - rAppendContext.pLastParagraphProperties->Getw() > 0 ? - rAppendContext.pLastParagraphProperties->Getw() : - pStyleProperties->props().Getw(); + + sal_Int32 nWidth = -1; + for (const auto pProp : vProps) + { + if (pProp->Getw() < 0) + continue; + nWidth = pProp->Getw(); + break; + } bool bAutoWidth = nWidth < 1; if( bAutoWidth ) nWidth = DEFAULT_FRAME_MIN_WIDTH; aFrameProperties.push_back(comphelper::makePropertyValue(getPropertyName(PROP_WIDTH), nWidth)); - aFrameProperties.push_back(comphelper::makePropertyValue(getPropertyName(PROP_HEIGHT), - rAppendContext.pLastParagraphProperties->Geth() > 0 ? - rAppendContext.pLastParagraphProperties->Geth() : - pStyleProperties->props().Geth() > 0 ? pStyleProperties->props().Geth() : DEFAULT_FRAME_MIN_HEIGHT)); + sal_Int32 nHeight = DEFAULT_FRAME_MIN_HEIGHT; + for (const auto pProp : vProps) + { + if (pProp->Geth() < 0) + continue; + nHeight = pProp->Geth(); + break; + } + aFrameProperties.push_back( + comphelper::makePropertyValue(getPropertyName(PROP_HEIGHT), nHeight)); sal_Int16 nhRule = sal_Int16( rAppendContext.pLastParagraphProperties->GethRule() >= 0 ? -- cgit