[Libreoffice-commits] core.git: sw/qa sw/source
Miklos Vajna (via logerrit)
logerrit at kemper.freedesktop.org
Fri Jan 24 17:19:01 UTC 2020
sw/qa/extras/ooxmlexport/ooxmlexport14.cxx | 29 +++++++++++++++++++++++++++
sw/source/filter/ww8/docxattributeoutput.cxx | 6 +----
2 files changed, 31 insertions(+), 4 deletions(-)
New commits:
commit ff139ea42279cc9861abb13e22878c9d435acb21
Author: Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Fri Jan 24 17:01:29 2020 +0100
Commit: Miklos Vajna <vmiklos at collabora.com>
CommitDate: Fri Jan 24 18:18:28 2020 +0100
DOCX export: fix line spacing when spacing is 0
When the input was:
<w:pPr>
<w:spacing w:line="0" w:lineRule="atLeast"/>
</w:pPr>
Then we used to write:
<w:pPr>
<w:spacing w:lineRule="auto"/>
</w:pPr>
which is clarly wrong.
The comment at the end of AttributeOutputBase::ParaLineSpacing()
documents the intention reasonably clearly (and is in sync with what's
in the DOC and DOCX spec), adapt
DocxAttributeOutput::ParaLineSpacing_Impl() accordingly.
Change-Id: I60cbc3392a6460ba2760b2c02ae0755726478ec1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87351
Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
Tested-by: Jenkins
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
index d582e777de06..1b4bf79fdc2d 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
@@ -20,6 +20,8 @@
#include <com/sun/star/text/TableColumnSeparator.hpp>
#include <com/sun/star/text/XDocumentIndex.hpp>
#include <com/sun/star/text/RelOrientation.hpp>
+#include <com/sun/star/style/LineSpacing.hpp>
+#include <com/sun/star/style/LineSpacingMode.hpp>
class Test : public SwModelTestBase
{
@@ -219,6 +221,33 @@ DECLARE_OOXMLEXPORT_TEST(testTdf121658, "tdf121658.docx")
assertXPath(pXmlSettings, "/w:settings/w:doNotHyphenateCaps");
}
+CPPUNIT_TEST_FIXTURE(SwModelTestBase, testZeroLineSpacing)
+{
+ // Create the doc model.
+ loadURL("private:factory/swriter", nullptr);
+ uno::Reference<beans::XPropertySet> xParagraph(getParagraph(1), uno::UNO_QUERY);
+ style::LineSpacing aSpacing;
+ aSpacing.Mode = style::LineSpacingMode::MINIMUM;
+ aSpacing.Height = 0;
+ xParagraph->setPropertyValue("ParaLineSpacing", uno::makeAny(aSpacing));
+
+ // Export to docx.
+ uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY);
+ utl::MediaDescriptor aMediaDescriptor;
+ aMediaDescriptor["FilterName"] <<= OUString("Office Open XML Text");
+ xStorable->storeToURL(maTempFile.GetURL(), aMediaDescriptor.getAsConstPropertyValueList());
+ mbExported = true;
+ xmlDocPtr pXmlDoc = parseExport("word/document.xml");
+ CPPUNIT_ASSERT(pXmlDoc);
+
+ // Without the accompanying fix in place, this test would have failed with:
+ // - Expected: atLeast
+ // - Actual : auto
+ // i.e. the minimal linespacing was lost on export.
+ assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:pPr/w:spacing", "lineRule", "atLeast");
+ assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:pPr/w:spacing", "line", "0");
+}
+
CPPUNIT_TEST_FIXTURE(SwModelTestBase, testSemiTransparentText)
{
// Create an in-memory empty document.
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index d30d19eaad66..cef9035c15e9 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -7724,20 +7724,18 @@ void DocxAttributeOutput::ParaLineSpacing_Impl( short nSpace, short nMulti )
FSNS( XML_w, XML_lineRule ), "exact",
FSNS( XML_w, XML_line ), OString::number( -nSpace ).getStr() );
}
- else if( nMulti )
+ else if( nSpace > 0 && nMulti )
{
AddToAttrList( m_pParagraphSpacingAttrList, 2,
FSNS( XML_w, XML_lineRule ), "auto",
FSNS( XML_w, XML_line ), OString::number( nSpace ).getStr() );
}
- else if ( nSpace > 0 )
+ else
{
AddToAttrList( m_pParagraphSpacingAttrList, 2,
FSNS( XML_w, XML_lineRule ), "atLeast",
FSNS( XML_w, XML_line ), OString::number( nSpace ).getStr() );
}
- else
- AddToAttrList( m_pParagraphSpacingAttrList, FSNS( XML_w, XML_lineRule ), "auto" );
}
void DocxAttributeOutput::ParaAdjust( const SvxAdjustItem& rAdjust )
More information about the Libreoffice-commits
mailing list