writerfilter/qa/cppunittests/ooxml/ooxml.cxx | 16 ++++++++++++++++ writerfilter/source/dmapper/DomainMapper.cxx | 27 +++++++++++++++------------ 2 files changed, 31 insertions(+), 12 deletions(-)
New commits: commit c4d56ce68eadc06582004a1c6ecb62f1b9b9bf38 Author: Justin Luth <justin.l...@collabora.com> AuthorDate: Mon Sep 9 12:56:36 2024 -0400 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Tue Sep 10 08:33:36 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. make CppunitTest_writerfilter_ooxml Change-Id: I1562d736cbf3f2833a4a1f1edfc40897a7d4f92f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173105 Reviewed-by: Justin Luth <jl...@mail.com> Tested-by: Jenkins Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173115 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Miklos Vajna <vmik...@collabora.com> diff --git a/writerfilter/qa/cppunittests/ooxml/ooxml.cxx b/writerfilter/qa/cppunittests/ooxml/ooxml.cxx index 42c8d2222607..2335727c5110 100644 --- a/writerfilter/qa/cppunittests/ooxml/ooxml.cxx +++ b/writerfilter/qa/cppunittests/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(107), + aLineSpacing.Height); } } diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx index 9354fecbae8d..44d9132c0bca 100644 --- a/writerfilter/source/dmapper/DomainMapper.cxx +++ b/writerfilter/source/dmapper/DomainMapper.cxx @@ -548,19 +548,22 @@ void DomainMapper::lcl_attribute(Id nName, Value & val) // exactly, atLeast, auto if( sal::static_int_cast<Id>(nIntValue) == NS_ooxml::LN_Value_doc_ST_LineSpacingRule_auto) { - m_pImpl->appendGrabBag(m_pImpl->m_aSubInteropGrabBag, "lineRule", "auto"); - if (aSpacing.Height >= 0) + if (aSpacing.Mode != style::LineSpacingMode::PROP) { - aSpacing.Mode = style::LineSpacingMode::PROP; - //reinterpret the already set value - aSpacing.Height = sal_Int16( aSpacing.Height * 100 / ConversionHelper::convertTwipToMM100( nSingleLineSpacing )); - } - else - { - // Negative value still means a positive height, - // just the mode is "exact". - aSpacing.Mode = style::LineSpacingMode::FIX; - aSpacing.Height *= -1; + m_pImpl->appendGrabBag(m_pImpl->m_aSubInteropGrabBag, "lineRule", "auto"); + if (aSpacing.Height >= 0) + { + aSpacing.Mode = style::LineSpacingMode::PROP; + //reinterpret the already set value + aSpacing.Height = sal_Int16( aSpacing.Height * 100 / ConversionHelper::convertTwipToMM100( 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) == NS_ooxml::LN_Value_doc_ST_LineSpacingRule_atLeast)