[Libreoffice-commits] core.git: sw/qa writerfilter/source

Miklos Vajna vmiklos at collabora.co.uk
Tue Mar 6 08:07:32 UTC 2018


 sw/qa/extras/ooxmlexport/data/tdf115861.docx      |binary
 sw/qa/extras/ooxmlexport/ooxmlexport11.cxx        |    7 +++++++
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |    6 ++++++
 writerfilter/source/dmapper/util.cxx              |   14 +++++++++++++-
 4 files changed, 26 insertions(+), 1 deletion(-)

New commits:
commit 49cf733effc56c09c5e2eb023120c2d3532b5b3d
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Mon Mar 5 22:09:39 2018 +0100

    tdf#115861 DOCX import: avoid last-paragraph removal when discarding footer
    
    Discarding header/footer is necessary when the document or section
    settings request to ignore first or even headers/footers. In the bugdoc
    case settings.xml didn't opt-in for different even/odd footers, but
    there was an even footer to be ignored.
    
    Handle this state at two more places, so we don't end up in a situation
    where we ignore the footer but not its "remove last (empty) paragraph at
    the end of the footer" action.
    
    Also make the debug dumper for text ranges more robust to have a working
    token dump when we try to get the string for a table.
    
    Change-Id: I6395f37aa40c42304e2c918d87dadecb21e9d378
    Reviewed-on: https://gerrit.libreoffice.org/50786
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
    Tested-by: Jenkins <ci at libreoffice.org>

diff --git a/sw/qa/extras/ooxmlexport/data/tdf115861.docx b/sw/qa/extras/ooxmlexport/data/tdf115861.docx
new file mode 100644
index 000000000000..f42a7bad2cfa
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf115861.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
index ebc3d81d9f4a..813b0c3c4f3c 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
@@ -83,6 +83,13 @@ DECLARE_OOXMLEXPORT_TEST(testTdf112694, "tdf112694.docx")
     CPPUNIT_ASSERT(!getProperty<bool>(aPageStyle, "HeaderIsOn"));
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf115861, "tdf115861.docx")
+{
+    // Second item in the paragraph enumeration was a table, 2nd paragraph was
+    // lost.
+    CPPUNIT_ASSERT_EQUAL(OUString("(k)"), getParagraph(2)->getString());
+}
+
 DECLARE_OOXMLEXPORT_TEST(testTdf67207_MERGEFIELD, "mailmerge.docx")
 {
     uno::Reference<beans::XPropertySet> xTextField = getProperty< uno::Reference<beans::XPropertySet> >(getRun(getParagraph(1), 2), "TextField");
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 649898923a9b..ece3775fc686 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -390,6 +390,9 @@ void DomainMapper_Impl::AddDummyParaForTableInSection()
 
 void DomainMapper_Impl::RemoveLastParagraph( )
 {
+    if (m_bDiscardHeaderFooter)
+        return;
+
     if (m_aTextAppendStack.empty())
         return;
     uno::Reference< text::XTextAppend > xTextAppend = m_aTextAppendStack.top().xTextAppend;
@@ -1087,6 +1090,9 @@ static sal_Int32 lcl_getListId(const StyleSheetEntryPtr& rEntry, const StyleShee
 
 void DomainMapper_Impl::finishParagraph( const PropertyMapPtr& pPropertyMap )
 {
+    if (m_bDiscardHeaderFooter)
+        return;
+
 #ifdef DEBUG_WRITERFILTER
     TagLogger::getInstance().startElement("finishParagraph");
 #endif
diff --git a/writerfilter/source/dmapper/util.cxx b/writerfilter/source/dmapper/util.cxx
index e721d6cecb9b..378e30b08a9d 100644
--- a/writerfilter/source/dmapper/util.cxx
+++ b/writerfilter/source/dmapper/util.cxx
@@ -34,7 +34,19 @@ std::string XTextRangeToString(uno::Reference< text::XTextRange > const & textRa
 #ifdef DEBUG_WRITERFILTER
     if (textRange.get())
     {
-        OUString aOUStr = textRange->getString();
+        OUString aOUStr;
+
+        try
+        {
+            aOUStr = textRange->getString();
+        }
+        catch (const uno::Exception& rException)
+        {
+            result += "(exception: ";
+            result += rException.Message.toUtf8().getStr();
+            result += ")";
+        }
+
         OString aOStr(aOUStr.getStr(), aOUStr.getLength(),  RTL_TEXTENCODING_ASCII_US );
 
         result = aOStr.getStr();


More information about the Libreoffice-commits mailing list