[Libreoffice-commits] core.git: Branch 'libreoffice-4-4' - sw/qa writerfilter/source

Miklos Vajna vmiklos at collabora.co.uk
Thu Jul 9 02:36:46 PDT 2015


 sw/qa/extras/ooxmlimport/data/tdf90611.docx       |binary
 sw/qa/extras/ooxmlimport/ooxmlimport.cxx          |   10 ++++++++++
 writerfilter/source/dmapper/DomainMapper.cxx      |    2 +-
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |   13 +++++++++++++
 writerfilter/source/dmapper/DomainMapper_Impl.hxx |    4 ++++
 5 files changed, 28 insertions(+), 1 deletion(-)

New commits:
commit 6178e1e784b8a7881395972b9e6f0222c012a9b1
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Mon Jul 6 09:23:40 2015 +0200

    tdf#90611 DOCX import: fix missing paragraph style on footnotes
    
    One one hand, a problem since commit
    330b860205c7ba69dd6603f65324d0f89ad9cd5f (fdo#68787 DOCX import: handle
    when w:separator is missing for footnotes, 2013-09-04) was that the type
    attribute from <w:footnote w:type="separator"> resulted in two
    ooxml:CT_FtnEdn_type tokens, ignoring too many paragraph ends for
    footnotes, which resulted in missing paragraph style on footnotes.
    
    On the other hand, fixing the first problem showed that it wasn't
    correct that commit 9389cf78e304a5a99bcf1745b9388e14ac36281a (cp#1000018
    RTF import: empty para at the end of footnote text got lost, 2013-11-15)
    unconditionally removed the RemoveLastParagraph() call in
    DomainMapper_Impl::PopFootOrEndnote(). It turns out that RTF and DOCX
    have different semantics here, the footnote is always within a <p></p>
    pair in DOCX, while in RTF a \par at the end of a
    footnote means an empty paragraph. Fix that by conditionally restoring
    the removed RemoveLastParagraph() call.
    
    (cherry picked from commit 519b34300f73b1e08f6194d6ba49d4fc010cf186)
    
    Change-Id: I33020ac761c94addfec8164a17863565e4453b07
    Reviewed-on: https://gerrit.libreoffice.org/16879
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/sw/qa/extras/ooxmlimport/data/tdf90611.docx b/sw/qa/extras/ooxmlimport/data/tdf90611.docx
new file mode 100644
index 0000000..ac54fee
Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/tdf90611.docx differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index beab2d1..1f5843d 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -2599,6 +2599,16 @@ DECLARE_OOXMLIMPORT_TEST(testTdf87460, "tdf87460.docx")
     CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), xEndnotes->getCount());
 }
 
+DECLARE_OOXMLIMPORT_TEST(testTdf90611, "tdf90611.docx")
+{
+    uno::Reference<text::XFootnotesSupplier> xFootnotesSupplier(mxComponent, uno::UNO_QUERY);
+    uno::Reference<container::XIndexAccess> xFootnotes(xFootnotesSupplier->getFootnotes(), uno::UNO_QUERY);
+    uno::Reference<text::XText> xFootnoteText;
+    xFootnotes->getByIndex(0) >>= xFootnoteText;
+    // This was 11.
+    CPPUNIT_ASSERT_EQUAL(10.f, getProperty<float>(getParagraphOfText(1, xFootnoteText), "CharHeight"));
+}
+
 #endif
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index 612b208..8dc4ef2 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -975,7 +975,7 @@ void DomainMapper::lcl_attribute(Id nName, Value & val)
         case NS_ooxml::LN_CT_FtnEdn_type:
             // This is the "separator" footnote, ignore its linebreak.
             if (static_cast<sal_uInt32>(nIntValue) == NS_ooxml::LN_Value_doc_ST_FtnEdn_separator)
-                m_pImpl->m_bIgnoreNextPara = true;
+                m_pImpl->SeenFootOrEndnoteSeparator();
         break;
         case NS_ooxml::LN_CT_DataBinding_prefixMappings:
             m_pImpl->appendGrabBag(m_pImpl->m_aInteropGrabBag, "ooxml:CT_DataBinding_prefixMappings", sStringValue);
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index f043ba1..66453ac 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -185,6 +185,7 @@ DomainMapper_Impl::DomainMapper_Impl(
         m_bInHeaderFooterImport( false ),
         m_bDiscardHeaderFooter( false ),
         m_bInFootOrEndnote(false),
+        m_bSeenFootOrEndnoteSeparator(false),
         m_bLineNumberingSet( false ),
         m_bIsInFootnoteProperties( false ),
         m_bIsCustomFtnMark( false ),
@@ -1712,6 +1713,9 @@ void DomainMapper_Impl::PushAnnotation()
 
 void DomainMapper_Impl::PopFootOrEndnote()
 {
+    if (!IsRTFImport())
+        RemoveLastParagraph();
+
     // In case the foot or endnote did not contain a tab.
     m_bIgnoreNextTab = false;
 
@@ -1724,9 +1728,18 @@ void DomainMapper_Impl::PopFootOrEndnote()
         return;
     }
     m_aRedlines.pop();
+    m_bSeenFootOrEndnoteSeparator = false;
     m_bInFootOrEndnote = false;
 }
 
+void DomainMapper_Impl::SeenFootOrEndnoteSeparator()
+{
+    if (!m_bSeenFootOrEndnoteSeparator)
+    {
+        m_bSeenFootOrEndnoteSeparator = true;
+        m_bIgnoreNextPara = true;
+    }
+}
 
 void DomainMapper_Impl::PopAnnotation()
 {
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
index d88df66..84cb177 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
@@ -387,6 +387,8 @@ private:
     bool                            m_bInHeaderFooterImport;
     bool                            m_bDiscardHeaderFooter;
     bool                            m_bInFootOrEndnote;
+    /// Did we get a <w:separator/> for this footnote already?
+    bool                            m_bSeenFootOrEndnoteSeparator;
 
     bool                            m_bLineNumberingSet;
     bool                            m_bIsInFootnoteProperties;
@@ -608,6 +610,8 @@ public:
     void PushFootOrEndnote( bool bIsFootnote );
     void PopFootOrEndnote();
     bool IsInFootOrEndnote() const { return m_bInFootOrEndnote; }
+    /// Got a <w:separator/>.
+    void SeenFootOrEndnoteSeparator();
 
     void PushAnnotation();
     void PopAnnotation();


More information about the Libreoffice-commits mailing list