[Libreoffice-commits] core.git: solenv/clang-format sw/CppunitTest_sw_ooxmlexport13.mk sw/Module_sw.mk sw/qa sw/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Tue Dec 18 08:13:57 UTC 2018
solenv/clang-format/blacklist | 1
sw/CppunitTest_sw_ooxmlexport13.mk | 14 ++++
sw/Module_sw.mk | 1
sw/qa/extras/ooxmlexport/data/tdf121374_sectionHF.odt |binary
sw/qa/extras/ooxmlexport/data/tdf121374_sectionHF2.doc |binary
sw/qa/extras/ooxmlexport/ooxmlexport13.cxx | 55 +++++++++++++++++
sw/qa/extras/ooxmlexport/ooxmlexport5.cxx | 3
sw/source/filter/ww8/wrtw8sty.cxx | 7 +-
8 files changed, 78 insertions(+), 3 deletions(-)
New commits:
commit 8c8c65c84de44f9a9334f72cf05138e5bc9401bd
Author: Justin Luth <justin.luth at collabora.com>
AuthorDate: Sat Dec 8 21:33:02 2018 +0300
Commit: Miklos Vajna <vmiklos at collabora.com>
CommitDate: Tue Dec 18 09:13:34 2018 +0100
tdf121374 ooxmlexport: export H/F to default section
It wouldn't be terrible to duplicate headers/footers
unnecessarily, but it is terrible to have them disappear.
If the last SectPr has no idea about the section start,
it can't know whether it is continuous or started with
a page break. In that case, just ensure that the
header and footer are explicitly written out.
This seems to be a DOCX problem only. I think that
doc and rtf both write the section information at the
BEGINNING of the section, but DOCX writes it at the END.
So, sharing code between these two opposite approaches
is difficult.
A followup commit can try to make it smarter about
knowing the start of the section (because usually
pPDNd is zero).
Another followup commit can add the missing page breaks.
Change-Id: Iff54ed097b4f8692d7d7764089002b00fbde4f51
Reviewed-on: https://gerrit.libreoffice.org/64821
Tested-by: Jenkins
Reviewed-by: Justin Luth <justin_luth at sil.org>
Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
diff --git a/solenv/clang-format/blacklist b/solenv/clang-format/blacklist
index 717bf0c00305..9891f07f2f3c 100644
--- a/solenv/clang-format/blacklist
+++ b/solenv/clang-format/blacklist
@@ -15078,6 +15078,7 @@ sw/qa/extras/ooxmlexport/ooxmlencryption.cxx
sw/qa/extras/ooxmlexport/ooxmlexport.cxx
sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
+sw/qa/extras/ooxmlexport/ooxmlexport13.cxx
sw/qa/extras/ooxmlexport/ooxmlexport2.cxx
sw/qa/extras/ooxmlexport/ooxmlexport3.cxx
sw/qa/extras/ooxmlexport/ooxmlexport4.cxx
diff --git a/sw/CppunitTest_sw_ooxmlexport13.mk b/sw/CppunitTest_sw_ooxmlexport13.mk
new file mode 100644
index 000000000000..22d8ebe3a1a8
--- /dev/null
+++ b/sw/CppunitTest_sw_ooxmlexport13.mk
@@ -0,0 +1,14 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#*************************************************************************
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+#*************************************************************************
+
+$(eval $(call sw_ooxmlexport_test,13))
+
+# vim: set noet sw=4 ts=4:
diff --git a/sw/Module_sw.mk b/sw/Module_sw.mk
index 843553c43ca2..bfcb358343a5 100644
--- a/sw/Module_sw.mk
+++ b/sw/Module_sw.mk
@@ -73,6 +73,7 @@ $(eval $(call gb_Module_add_slowcheck_targets,sw,\
CppunitTest_sw_ooxmlexport10 \
CppunitTest_sw_ooxmlexport11 \
CppunitTest_sw_ooxmlexport12 \
+ CppunitTest_sw_ooxmlexport13 \
CppunitTest_sw_ooxmlexport_template \
CppunitTest_sw_ooxmlfieldexport \
CppunitTest_sw_ooxmllinks \
diff --git a/sw/qa/extras/ooxmlexport/data/tdf121374_sectionHF.odt b/sw/qa/extras/ooxmlexport/data/tdf121374_sectionHF.odt
new file mode 100644
index 000000000000..392fae1b6624
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf121374_sectionHF.odt differ
diff --git a/sw/qa/extras/ooxmlexport/data/tdf121374_sectionHF2.doc b/sw/qa/extras/ooxmlexport/data/tdf121374_sectionHF2.doc
new file mode 100644
index 000000000000..56a33d260e0e
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf121374_sectionHF2.doc differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx
new file mode 100644
index 000000000000..b3d0a219c5cc
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx
@@ -0,0 +1,55 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <swmodeltestbase.hxx>
+
+#include <com/sun/star/awt/Size.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/text/XTextFrame.hpp>
+#include <com/sun/star/text/XTextFramesSupplier.hpp>
+
+#include <sfx2/docfile.hxx>
+#include <sfx2/docfilt.hxx>
+#include <svx/xfillit0.hxx>
+
+class Test : public SwModelTestBase
+{
+public:
+ Test() : SwModelTestBase("/sw/qa/extras/ooxmlexport/data/", "Office Open XML Text") {}
+
+protected:
+ /**
+ * Blacklist handling
+ */
+ bool mustTestImportOf(const char* filename) const override {
+ // If the testcase is stored in some other format, it's pointless to test.
+ return OString(filename).endsWith(".docx");
+ }
+};
+
+DECLARE_OOXMLEXPORT_TEST(testTdf121374_sectionHF, "tdf121374_sectionHF.odt")
+{
+ uno::Reference<beans::XPropertySet> xPageStyle(getStyles("PageStyles")->getByName("Standard"), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xFooterText = getProperty< uno::Reference<text::XTextRange> >(xPageStyle, "FooterText");
+ CPPUNIT_ASSERT_EQUAL( OUString("footer"), xFooterText->getString() );
+
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "Number of Paragraphs", 6, getParagraphs() );
+ //CPPUNIT_ASSERT_EQUAL_MESSAGE( "Number of Pages", 6, getPages() );
+}
+
+DECLARE_OOXMLEXPORT_TEST(testTdf121374_sectionHF2, "tdf121374_sectionHF2.doc")
+{
+ uno::Reference<beans::XPropertySet> xPageStyle(getStyles("PageStyles")->getByName("Standard"), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xHeaderText = getProperty< uno::Reference<text::XTextRange> >(xPageStyle, "HeaderText");
+ CPPUNIT_ASSERT( xHeaderText->getString().startsWith("virkamatka-anomus") );
+}
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx
index bd662172ae0c..4a7118cf56cd 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx
@@ -1035,7 +1035,8 @@ DECLARE_OOXMLEXPORT_TEST(testSectionHeader, "sectionprot.odt")
{
if (xmlDocPtr pXmlDoc = parseExport("word/document.xml"))
{
- assertXPath(pXmlDoc, "//w:headerReference", 1);
+ // this test must not be zero
+ assertXPath(pXmlDoc, "//w:headerReference", 2);
}
}
diff --git a/sw/source/filter/ww8/wrtw8sty.cxx b/sw/source/filter/ww8/wrtw8sty.cxx
index fa0aa300710c..286a613e8e62 100644
--- a/sw/source/filter/ww8/wrtw8sty.cxx
+++ b/sw/source/filter/ww8/wrtw8sty.cxx
@@ -1537,6 +1537,7 @@ void MSWordExportBase::SectionProperties( const WW8_SepInfo& rSepInfo, WW8_PdAtt
*/
sal_uInt8 nBreakCode = 2; // default start new page
bool bOutPgDscSet = true, bLeftRightPgChain = false, bOutputStyleItemSet = false;
+ bool bEnsureHeaderFooterWritten = rSepInfo.pSectionFormat && rSepInfo.bIsFirstParagraph;
const SwFrameFormat* pPdFormat = &pPd->GetMaster();
if ( rSepInfo.pSectionFormat )
{
@@ -1553,7 +1554,9 @@ void MSWordExportBase::SectionProperties( const WW8_SepInfo& rSepInfo, WW8_PdAtt
}
}
- if ( reinterpret_cast<SwSectionFormat*>(sal_IntPtr(-1)) != rSepInfo.pSectionFormat )
+ if ( reinterpret_cast<SwSectionFormat*>(sal_IntPtr(-1)) == rSepInfo.pSectionFormat )
+ bEnsureHeaderFooterWritten |= !rSepInfo.pPDNd && GetExportFormat() == ExportFormat::DOCX;
+ else
{
if ( nBreakCode == 0 )
bOutPgDscSet = false;
@@ -1715,7 +1718,7 @@ void MSWordExportBase::SectionProperties( const WW8_SepInfo& rSepInfo, WW8_PdAtt
: &pPd->GetLeft();
// Ensure that headers are written if section is first paragraph
- if ( nBreakCode != 0 || ( rSepInfo.pSectionFormat && rSepInfo.bIsFirstParagraph ))
+ if ( nBreakCode != 0 || bEnsureHeaderFooterWritten )
{
if ( titlePage )
{
More information about the Libreoffice-commits
mailing list