[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.2' - sw/qa sw/source
Miklos Vajna (via logerrit)
logerrit at kemper.freedesktop.org
Mon Jan 27 13:18:18 UTC 2020
sw/qa/extras/ooxmlexport/ooxmlexport13.cxx | 29 +++++++++++++++++++++++++++
sw/source/filter/ww8/docxattributeoutput.cxx | 6 +----
2 files changed, 31 insertions(+), 4 deletions(-)
New commits:
commit d3b4949a457c06e15a1c47550d90d97c0fe443bc
Author: Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Fri Jan 24 17:01:29 2020 +0100
Commit: Miklos Vajna <vmiklos at collabora.com>
CommitDate: Mon Jan 27 14:17:44 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.
(cherry picked from commit ff139ea42279cc9861abb13e22878c9d435acb21)
Conflicts:
sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
Change-Id: I60cbc3392a6460ba2760b2c02ae0755726478ec1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87517
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx
index f2e3877271a0..8706782b6d9c 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx
@@ -15,6 +15,8 @@
#include <com/sun/star/text/XTextFrame.hpp>
#include <com/sun/star/text/XTextFramesSupplier.hpp>
#include <com/sun/star/drawing/XControlShape.hpp>
+#include <com/sun/star/style/LineSpacing.hpp>
+#include <com/sun/star/style/LineSpacingMode.hpp>
#include <sfx2/docfile.hxx>
#include <sfx2/docfilt.hxx>
@@ -388,6 +390,33 @@ DECLARE_OOXMLIMPORT_TEST(testContSectBreakHeaderFooter, "cont-sect-break-header-
parseDump("/root/page[3]/footer/txt/text()"));
}
+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_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 78854596ad1b..8ea9ec639f2d 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -7882,20 +7882,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