sw/qa/writerfilter/ooxml/ooxml.cxx | 16 ++++++++++ sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx | 29 ++++++++++--------- 2 files changed, 32 insertions(+), 13 deletions(-)
New commits: commit cea35086310d16f3f53f83fc18c1b8f26bae19da Author: Justin Luth <justin.l...@collabora.com> AuthorDate: Mon Sep 9 12:56:36 2024 -0400 Commit: Justin Luth <jl...@mail.com> CommitDate: Mon Sep 9 20:37:43 2024 +0200 writerfilter line spacing: don't convert PROP to PROP The default is FIX, and so the code assumed that if we got an AUTO then we would have to convert a FIXed height to a PROPortional height. But in this bizarre case, the pPrDefault had already been parsed once, so the property already had a proportional 108% which would never happen in any regular circumstances. But regardless, if we have a defined value that is proportional, and now we get an "auto", we can just leave the value as it is. Change-Id: I1562d736cbf3f2833a4a1f1edfc40897a7d4f92f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173105 Reviewed-by: Justin Luth <jl...@mail.com> Tested-by: Jenkins diff --git a/sw/qa/writerfilter/ooxml/ooxml.cxx b/sw/qa/writerfilter/ooxml/ooxml.cxx index 76d5b389c375..f0ce47aa1e0c 100644 --- a/sw/qa/writerfilter/ooxml/ooxml.cxx +++ b/sw/qa/writerfilter/ooxml/ooxml.cxx @@ -9,6 +9,9 @@ #include <test/unoapi_test.hxx> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/style/LineSpacing.hpp> +#include <com/sun/star/style/XStyleFamiliesSupplier.hpp> #include <com/sun/star/text/XTextTablesSupplier.hpp> #include <com/sun/star/text/XTextDocument.hpp> @@ -68,6 +71,19 @@ CPPUNIT_TEST_FIXTURE(Test, testRecursiveHeaderRels) // Given a document with self-referencing rels in a header/footer: loadFromFile(u"recursive_header_rels.docx"); // It should not crash/hang on load + + // given an essentially corrupt document, which parses styles.xml multiple times, + uno::Reference<style::XStyleFamiliesSupplier> xSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XNameAccess> xStyleFamilies = xSupplier->getStyleFamilies(); + uno::Reference<container::XNameAccess> xStyleFamily( + xStyleFamilies->getByName(u"ParagraphStyles"_ustr), uno::UNO_QUERY_THROW); + uno::Reference<beans::XPropertySet> xStandard(xStyleFamily->getByName(u"Standard"_ustr), + uno::UNO_QUERY_THROW); + style::LineSpacing aLineSpacing; + xStandard->getPropertyValue(u"ParaLineSpacing"_ustr) >>= aLineSpacing; + // the proportional line spacing defined as default for the entire document should be 108% + CPPUNIT_ASSERT_EQUAL_MESSAGE("Default para style has 1.08 line-spacing", sal_Int16(108), + aLineSpacing.Height); } } diff --git a/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx b/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx index b365c7eb7f39..7d0f8346bd76 100644 --- a/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx +++ b/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx @@ -5167,20 +5167,23 @@ void DomainMapper_Impl::SetLineSpacing(const Id nName, sal_Int32 nIntValue, bool if (sal::static_int_cast<Id>(nIntValue) == NS_ooxml::LN_Value_doc_ST_LineSpacingRule_auto) { appendGrabBag(m_aSubInteropGrabBag, u"lineRule"_ustr, u"auto"_ustr); - if (aSpacing.Height >= 0) + if (aSpacing.Mode != style::LineSpacingMode::PROP) { - aSpacing.Mode = style::LineSpacingMode::PROP; - // reinterpret the already set value - aSpacing.Height = sal_Int16( - round(aSpacing.Height * 100.0 - / ConversionHelper::convertTwipToMm100_Limited(nSingleLineSpacing))); - } - else - { - // Negative value still means a positive height, - // just the mode is "exact". - aSpacing.Mode = style::LineSpacingMode::FIX; - aSpacing.Height *= -1; + if (aSpacing.Height >= 0) + { + aSpacing.Mode = style::LineSpacingMode::PROP; + // reinterpret the already set value + aSpacing.Height = sal_Int16( + round(aSpacing.Height * 100.0 + / ConversionHelper::convertTwipToMm100_Limited(nSingleLineSpacing))); + } + else + { + // Negative value still means a positive height, + // just the mode is "exact". + aSpacing.Mode = style::LineSpacingMode::FIX; + aSpacing.Height *= -1; + } } } else if (sal::static_int_cast<Id>(nIntValue)