sw/qa/extras/ooxmlexport/data/tdf107033.docx      |binary
 sw/qa/extras/ooxmlexport/ooxmlexport9.cxx         |   10 +++++++++-
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |    6 ++++++
 writerfilter/source/dmapper/DomainMapper_Impl.hxx |    4 +++-
 writerfilter/source/dmapper/PropertyMap.cxx       |   15 ++++++++++++---
 5 files changed, 30 insertions(+), 5 deletions(-)

New commits:
commit e79ef12b7a904f17d4147fa409d055c12b70f952
Author: Miklos Vajna <vmik...@collabora.co.uk>
Date:   Wed May 3 08:39:31 2017 +0200

    tdf#107033 DOCX import: fix unexpected missing footnote separator
    
    Regression from commit 330b860205c7ba69dd6603f65324d0f89ad9cd5f
    (fdo#68787 DOCX import: handle when w:separator is missing for
    footnotes, 2013-09-04), the problem was footnote settings were modified
    also in case there were no footnotes at all in the document.
    
    Make the bug scenario and the original one working at the same time by
    touching footnote settings only in case there is at least one footnote
    in the current section.
    
    Change-Id: I163d11769cbd97957662607fbedfba404181e002

diff --git a/sw/qa/extras/ooxmlexport/data/tdf107033.docx 
b/sw/qa/extras/ooxmlexport/data/tdf107033.docx
new file mode 100644
index 000000000000..f4e08a3d36e5
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf107033.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
index 80c5f85cf055..a4f847a99a70 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
@@ -460,10 +460,18 @@ DECLARE_OOXMLEXPORT_TEST(testTdf106492, "tdf106492.docx")
 DECLARE_OOXMLEXPORT_TEST(testTdf107104, "tdf107104.docx")
 {
     CPPUNIT_ASSERT(getShape(1)->getSize().Width > 0);
-    // This failed: the second arrow was invisible because it had zero height.
+    // This failed: the second arrow was invisible because it had zero width.
     CPPUNIT_ASSERT(getShape(2)->getSize().Width > 0);
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf107033, "tdf107033.docx")
+{
+    uno::Reference<beans::XPropertySet> 
xPageStyle(getStyles("PageStyles")->getByName("Standard"), uno::UNO_QUERY);
+    // This was 0: footnote separator was disabled even in case the document
+    // had no footnotes.
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(25), 
getProperty<sal_Int32>(xPageStyle, "FootnoteLineRelativeWidth"));
+}
+
 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 bbcdc2c58445..8ad1090cd925 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -236,6 +236,7 @@ DomainMapper_Impl::DomainMapper_Impl(
         m_nTableDepth(0),
         m_nTableCellDepth(0),
         m_nLastTableCellParagraphDepth(0),
+        m_bHasFtn(false),
         m_bHasFtnSep(false),
         m_bIgnoreNextPara(false),
         m_bIgnoreNextTab(false),
@@ -5444,6 +5445,9 @@ void DomainMapper_Impl::substream(Id rName,
         propSize[i] = m_aPropertyStacks[i].size();
     }
 #endif
+    // Save "has footnote" state, which is specific to a section in the body
+    // text, so state from substreams is not relevant.
+    bool bHasFtn = m_bHasFtn;
 
     //finalize any waiting frames before starting alternate streams
     CheckUnregisteredFrameConversion();
@@ -5513,12 +5517,14 @@ void DomainMapper_Impl::substream(Id rName,
 
     getTableManager().endLevel();
     popTableManager();
+    m_bHasFtn = bHasFtn;
 
     switch(rName)
     {
     case NS_ooxml::LN_footnote:
     case NS_ooxml::LN_endnote:
         m_pTableHandler->setHadFootOrEndnote(true);
+        m_bHasFtn = true;
         break;
     }
 
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
index 0b033a3a8618..6198dec06cf3 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
@@ -841,7 +841,9 @@ public:
     /// Table cell depth of the last finished paragraph.
     sal_Int32 m_nLastTableCellParagraphDepth;
 
-    /// If the document has a footnote separator.
+    /// If the current section has footnotes.
+    bool m_bHasFtn;
+    /// If the current section has a footnote separator.
     bool m_bHasFtnSep;
 
     /// If the next newline should be ignored, used by the special footnote 
separator paragraph.
diff --git a/writerfilter/source/dmapper/PropertyMap.cxx 
b/writerfilter/source/dmapper/PropertyMap.cxx
index 8c81f7fb0ecb..44a8bf016252 100644
--- a/writerfilter/source/dmapper/PropertyMap.cxx
+++ b/writerfilter/source/dmapper/PropertyMap.cxx
@@ -1001,9 +1001,18 @@ void SectionPropertyMap::HandleMarginsHeaderFooter( bool 
bFirstPage, DomainMappe
 
     if ( rDM_Impl.m_oBackgroundColor )
         Insert( PROP_BACK_COLOR, uno::makeAny( *rDM_Impl.m_oBackgroundColor ) 
);
-    if ( !rDM_Impl.m_bHasFtnSep )
-        // Set footnote line width to zero, document has no footnote separator.
-        Insert( PROP_FOOTNOTE_LINE_RELATIVE_WIDTH, uno::makeAny( sal_Int32( 0 
) ) );
+    if (rDM_Impl.m_bHasFtn)
+    {
+        // Check for missing footnote separator only in case there is at least
+        // one footnote.
+        if (!rDM_Impl.m_bHasFtnSep)
+        {
+            // Set footnote line width to zero, document has no footnote 
separator.
+            Insert(PROP_FOOTNOTE_LINE_RELATIVE_WIDTH, 
uno::makeAny(sal_Int32(0)));
+            rDM_Impl.m_bHasFtn = false;
+        }
+        rDM_Impl.m_bHasFtnSep = false;
+    }
 
     /*** if headers/footers are available then the top/bottom margins of the
     header/footer are copied to the top/bottom margin of the page
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to