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

Miklos Vajna vmiklos at collabora.co.uk
Tue Jul 4 08:17:50 UTC 2017


 sw/qa/extras/ooxmlexport/data/tdf105095.docx      |binary
 sw/qa/extras/ooxmlexport/ooxmlexport8.cxx         |    7 ++++++-
 sw/qa/extras/ooxmlexport/ooxmlexport9.cxx         |   10 ++++++++++
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |   18 ++++++++++++++----
 4 files changed, 30 insertions(+), 5 deletions(-)

New commits:
commit abc440a691efb872afac385ce5ed28cd5db56c8c
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Tue Jul 4 08:51:53 2017 +0200

    tdf#105095 DOCX import: conditionally ignore leading tab in footnotes
    
    Commit b38629ae210b204a6d24d6e9c5c62eaaf563d494 (cp#1000017 DOCX/RTF
    import: avoid fake tab char in footnotes, 2013-12-05) added code to
    strip leading tabs from footnote text to improve odt->docx->odt rountrip
    experience.
    
    Turns out that this is correct only in case the gap between the footnote
    number and the content is provided by a paragraph margin. In case there
    is no such margin, then the tab is wanted; so only conditionally ignore
    such leading tab characters.
    
    Change-Id: I9d419bf2fd3b4899208489210cbe9809a2ab0736
    Reviewed-on: https://gerrit.libreoffice.org/39490
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
    Tested-by: Jenkins <ci at libreoffice.org>

diff --git a/sw/qa/extras/ooxmlexport/data/tdf105095.docx b/sw/qa/extras/ooxmlexport/data/tdf105095.docx
new file mode 100644
index 000000000000..0a6a7a2ac326
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf105095.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx
index 808ac9679b14..370d220e6a74 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx
@@ -1988,7 +1988,12 @@ DECLARE_OOXMLEXPORT_TEST(testTdf90810, "tdf90810short.docx")
     uno::Reference<text::XFootnote> xFootnote(xFootnoteIdxAcc->getByIndex(0), uno::UNO_QUERY);
     uno::Reference<text::XText> xFootnoteText(xFootnote, uno::UNO_QUERY);
     rtl::OUString sFootnoteText = xFootnoteText->getString();
-    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(90), sFootnoteText.getLength());
+    // Original document doesn't have a leading tab in the footnote, but the
+    // export adds one unconditionally.
+    if (mbExported)
+        CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(91), sFootnoteText.getLength());
+    else
+        CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(90), sFootnoteText.getLength());
 }
 
 DECLARE_OOXMLEXPORT_TEST(testTdf89165, "tdf89165.docx")
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
index 30836becd964..cf729eab49a1 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
@@ -736,6 +736,16 @@ DECLARE_OOXMLEXPORT_TEST(testTdf100075, "tdf100075.docx")
     CPPUNIT_ASSERT(getProperty<sal_Int32>(xFrame1, "Height") > getProperty<sal_Int32>(xFrame2, "Height"));
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf105095, "tdf105095.docx")
+{
+    uno::Reference<text::XFootnotesSupplier> xFootnotesSupplier(mxComponent, uno::UNO_QUERY);
+    uno::Reference<container::XIndexAccess> xFootnotes(xFootnotesSupplier->getFootnotes(), uno::UNO_QUERY);
+    uno::Reference<text::XTextRange> xTextRange(xFootnotes->getByIndex(0), uno::UNO_QUERY);
+    // This failed, tab between the footnote number and the footnote content
+    // was lost on import.
+    CPPUNIT_ASSERT(xTextRange->getString().endsWith("\tfootnote"));
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 40a99feb0864..f7200d3aeb62 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -1721,10 +1721,20 @@ void DomainMapper_Impl::PushFootOrEndnote( bool bIsFootnote )
         // Redlines for the footnote anchor
         CheckRedline( xFootnote->getAnchor( ) );
 
-        // Word has a leading tab on footnotes, but we don't implement space
-        // between the footnote number and text using a tab, so just ignore
-        // that for now.
-        m_bIgnoreNextTab = true;
+        // Word has a leading tab on footnotes, but we may implement space
+        // between the footnote number and text using a paragraph margin, not a
+        // tab (Writer default). So ignore that in case there is a margin set.
+        uno::Reference<style::XStyleFamiliesSupplier> xStylesSupplier( GetTextDocument(), uno::UNO_QUERY);
+        uno::Reference<container::XNameAccess> xStyleFamilies = xStylesSupplier->getStyleFamilies();
+        uno::Reference<container::XNameContainer> xStyles;
+        xStyleFamilies->getByName("ParagraphStyles") >>= xStyles;
+        uno::Reference<beans::XPropertySet> xStyle(xStyles->getByName("Footnote"), uno::UNO_QUERY);
+        if (xStyle.is())
+        {
+            sal_Int32 nMargin = 0;
+            xStyle->getPropertyValue("ParaLeftMargin") >>= nMargin;
+            m_bIgnoreNextTab = nMargin > 0;
+        }
     }
     catch( const uno::Exception& e )
     {


More information about the Libreoffice-commits mailing list