From 35e62d9e649badfe00d0b8ea4c307d3fbbda735c Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Mon, 29 May 2017 11:25:58 +0200 Subject: tdf#107684 DOCX export: fix duplicated element for styles Next to the existing OutlineNumbering() (which is only used for styles), commit fd2d14d5543c82eb875e720c98b51518699a8fbc (Implement DOCX export of paragraph outline level, 2013-10-04) added ParaOutlineLevel() to the attribute output class that also wrote the outline level of a paragraph (style), but worked for the cases when the style was imported by writerfilter as well. As a side-effect styles imported by xmloff now have their outline level property handled twice, leading to duplicated elements. Fix the problem by only writing in ParaOutlineLevel(): it covers both use-cases, so no need to do anything in OutlineNumbering(). Change-Id: Ic982dd70a00609cdfc3744a8ab69aaa828410fd0 Reviewed-on: https://gerrit.libreoffice.org/38132 Reviewed-by: Miklos Vajna Tested-by: Jenkins (cherry picked from commit fe13c249c8964355e39869a357c393f3208b6def) Reviewed-on: https://gerrit.libreoffice.org/38637 Reviewed-by: Michael Stahl --- sw/qa/extras/ooxmlexport/data/tdf107684.odt | Bin 0 -> 12357 bytes sw/qa/extras/ooxmlexport/ooxmlexport9.cxx | 7 +++++++ sw/source/filter/ww8/docxattributeoutput.cxx | 4 ++-- 3 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 sw/qa/extras/ooxmlexport/data/tdf107684.odt diff --git a/sw/qa/extras/ooxmlexport/data/tdf107684.odt b/sw/qa/extras/ooxmlexport/data/tdf107684.odt new file mode 100644 index 000000000000..0ca7c53d23f3 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf107684.odt differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx index 093aecd16901..73392c03cea2 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx @@ -258,6 +258,13 @@ DECLARE_OOXMLEXPORT_TEST(testTdf107033, "tdf107033.docx") CPPUNIT_ASSERT_EQUAL(static_cast(25), getProperty(xPageStyle, "FootnoteLineRelativeWidth")); } +DECLARE_OOXMLEXPORT_TEST(testTdf107684, "tdf107684.odt") +{ + if (xmlDocPtr pXmlDoc = parseExport("word/styles.xml")) + // This was 1, was duplicated for Heading1. + assertXPath(pXmlDoc, "//w:style[@w:styleId='Heading1']/w:pPr/w:outlineLvl", 1); +} + 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 845fac3cf733..9a6d0d05218f 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -5394,9 +5394,9 @@ void lcl_OutlineLevel(sax_fastparser::FSHelperPtr const & pSerializer, sal_uInt1 } -void DocxAttributeOutput::OutlineNumbering(sal_uInt8 const nLvl) +void DocxAttributeOutput::OutlineNumbering(sal_uInt8 const /*nLvl*/) { - lcl_OutlineLevel(m_pSerializer, nLvl); + // Handled by ParaOutlineLevel() instead. } void DocxAttributeOutput::ParaOutlineLevel(const SfxUInt16Item& rItem) -- cgit v1.2.3