[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-4.2' - sw/qa writerfilter/source

Miklos Vajna vmiklos at collabora.co.uk
Mon Jun 16 08:45:44 PDT 2014


 sw/qa/extras/ooxmlimport/data/footnote.docx       |binary
 sw/qa/extras/ooxmlimport/ooxmlimport.cxx          |   11 +++++++++++
 writerfilter/source/dmapper/DomainMapper.cxx      |    4 +++-
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |    3 +++
 writerfilter/source/dmapper/DomainMapper_Impl.hxx |    2 ++
 5 files changed, 19 insertions(+), 1 deletion(-)

New commits:
commit 79299cd95f9b52d2ccd6973781e922381aa74281
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Wed Jun 11 12:39:33 2014 +0200

    DOCX import: fix additional empty paragraphs around footnote text
    
    Regression from commit abe1e852a232e3bdab7b9177d099fe3929f5a4aa (handle
    properly page breaks even if a page contains only a frame (fdo#55381),
    2014-04-21), DomainMapper::lcl_endSectionGroup() inserted an empty
    paragraph before and after the real footnote text. Disable addition of
    the dummy paragraph for footnotes.
    
    (cherry picked from commit 4d120b6ab181f530d3fedc963b1c6ec777f2608a)
    Signed-off-by: Luboš Luňák <l.lunak at collabora.com>
    
    Conflicts:
    	sw/qa/extras/ooxmlimport/ooxmlimport.cxx
    	writerfilter/source/dmapper/DomainMapper.cxx
    
    Change-Id: I6e1954c9bd5520ac284d66244ce1c9004e970305

diff --git a/sw/qa/extras/ooxmlimport/data/footnote.docx b/sw/qa/extras/ooxmlimport/data/footnote.docx
new file mode 100644
index 0000000..f5c94bd
Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/footnote.docx differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index 47c499a..88acef8 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -1692,6 +1692,17 @@ DECLARE_OOXMLIMPORT_TEST(testFdo69649, "fdo69649.docx")
     xTocString = xTocString.copy(256);
     CPPUNIT_ASSERT(xTocString.startsWithIgnoreAsciiCase( "Heading 15.1:\t15" ) );
 }
+
+DECLARE_OOXMLIMPORT_TEST(testFootnote, "footnote.docx")
+{
+    uno::Reference<text::XFootnotesSupplier> xFootnotesSupplier(mxComponent, uno::UNO_QUERY);
+    uno::Reference<container::XIndexAccess> xFootnotes(xFootnotesSupplier->getFootnotes(), uno::UNO_QUERY);
+    uno::Reference<text::XTextRange> xFootnote(xFootnotes->getByIndex(0), uno::UNO_QUERY);
+    OUString aFootnote = xFootnote->getString();
+    // Ensure there are no additional newlines after "bar".
+    CPPUNIT_ASSERT(aFootnote.endsWith("bar"));
+}
+
 #endif
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index 4c5337e..a824f6e 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -3655,7 +3655,9 @@ void DomainMapper::lcl_endSectionGroup()
 {
     m_pImpl->CheckUnregisteredFrameConversion();
     m_pImpl->ExecuteFrameConversion();
-    if(m_pImpl->GetIsFirstParagraphInSection())
+    // First paragraph in a footnote doesn't count: that would create
+    // additional paragraphs before and after the real footnote content.
+    if(m_pImpl->GetIsFirstParagraphInSection() && !m_pImpl->IsInFootOrEndnote())
     {
         // This section has no paragraph at all (e.g. they are all actually in a frame).
         // If this section has a page break, there would be nothing to apply to the page
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index a1b1128..a92b120 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -164,6 +164,7 @@ DomainMapper_Impl::DomainMapper_Impl(
         m_bInAnyTableImport( false ),
         m_bInHeaderFooterImport( false ),
         m_bDiscardHeaderFooter( false ),
+        m_bInFootOrEndnote(false),
         m_bLineNumberingSet( false ),
         m_bIsInFootnoteProperties( true ),
         m_bIsCustomFtnMark( false ),
@@ -1553,6 +1554,7 @@ void DomainMapper_Impl::PopPageHeaderFooter()
 
 void DomainMapper_Impl::PushFootOrEndnote( bool bIsFootnote )
 {
+    m_bInFootOrEndnote = true;
     try
     {
         // Redlines outside the footnote should not affect footnote content
@@ -1716,6 +1718,7 @@ void DomainMapper_Impl::PopFootOrEndnote()
         return;
     }
     m_aRedlines.pop();
+    m_bInFootOrEndnote = false;
 }
 
 
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
index c5d76b5..b7d01d9 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
@@ -370,6 +370,7 @@ private:
     bool                            m_bInAnyTableImport; //in import of fonts, styles, lists or lfos
     bool                            m_bInHeaderFooterImport;
     bool                            m_bDiscardHeaderFooter;
+    bool                            m_bInFootOrEndnote;
 
     bool                            m_bLineNumberingSet;
     bool                            m_bIsInFootnoteProperties;
@@ -568,6 +569,7 @@ public:
 
     void PushFootOrEndnote( bool bIsFootnote );
     void PopFootOrEndnote();
+    bool IsInFootOrEndnote() const { return m_bInFootOrEndnote; }
 
     void PushAnnotation();
     void PopAnnotation();


More information about the Libreoffice-commits mailing list