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

Miklos Vajna vmiklos at suse.cz
Fri Sep 6 04:32:26 PDT 2013


 sw/qa/extras/ooxmlimport/data/table-pagebreak.docx    |binary
 sw/qa/extras/ooxmlimport/ooxmlimport.cxx              |   11 +++++++++++
 writerfilter/source/dmapper/DomainMapper.cxx          |    6 ++++++
 writerfilter/source/dmapper/DomainMapper_Impl.cxx     |    8 +++++++-
 writerfilter/source/dmapper/DomainMapper_Impl.hxx     |    9 +++++++++
 writerfilter/source/ooxml/OOXMLFastContextHandler.cxx |   10 ++++++++++
 writerfilter/source/ooxml/model.xml                   |    1 +
 7 files changed, 44 insertions(+), 1 deletion(-)

New commits:
commit 869dc1a6b8a65f2bf8b3926169478ced0cf382ae
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Mon Sep 2 10:27:49 2013 +0200

    bnc#816593 DOCX import: ignore page breaks in tables
    
    (cherry picked from commit 7d3778e0ef9f54f3c8988f1b84d58e7002d6c625)
    
    Conflicts:
    	writerfilter/source/dmapper/DomainMapper.cxx
    
    Change-Id: Ibb250148d41d1929fa17dd993bb71c93c0e09dcf
    Reviewed-on: https://gerrit.libreoffice.org/5787
    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/table-pagebreak.docx b/sw/qa/extras/ooxmlimport/data/table-pagebreak.docx
new file mode 100755
index 0000000..06ecf95
Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/table-pagebreak.docx differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index 090b5d8..5223c87 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -130,6 +130,7 @@ public:
     void testTableFloating();
     void testTableAutoNested();
     void testTableStyleParprop();
+    void testTablePagebreak();
 
     CPPUNIT_TEST_SUITE(Test);
 #if !defined(MACOSX) && !defined(WNT)
@@ -225,6 +226,7 @@ void Test::run()
         {"table-floating.docx", &Test::testTableFloating},
         {"table-auto-nested.docx", &Test::testTableAutoNested},
         {"table-style-parprop.docx", &Test::testTableStyleParprop},
+        {"table-pagebreak.docx", &Test::testTablePagebreak},
     };
     header();
     for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i)
@@ -1594,6 +1596,15 @@ void Test::testTableStyleParprop()
     CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(getParagraphOfText(1, xCell->getText()), "ParaBottomMargin"));
 }
 
+void Test::testTablePagebreak()
+{
+    // Page break inside table: should be ignored (was style::BreakType_PAGE_BEFORE before).
+    CPPUNIT_ASSERT_EQUAL(style::BreakType_NONE, getProperty<style::BreakType>(getParagraphOrTable(2), "BreakType"));
+
+    // This one is outside the table: should not be ignored.
+    CPPUNIT_ASSERT_EQUAL(style::BreakType_PAGE_BEFORE, getProperty<style::BreakType>(getParagraph(3), "BreakType"));
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index a2b2bce..5ac4b05 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -3356,6 +3356,12 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, PropertyMapPtr rContext, SprmType
         }
     }
     break;
+    case NS_ooxml::LN_tblStart:
+        m_pImpl->m_nTableDepth++;
+    break;
+    case NS_ooxml::LN_tblEnd:
+        m_pImpl->m_nTableDepth--;
+    break;
     default:
         {
 #ifdef DEBUG_DOMAINMAPPER
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 6319c79..5bd4e62 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -190,7 +190,8 @@ DomainMapper_Impl::DomainMapper_Impl(
         m_xInsertTextRange(xInsertTextRange),
         m_bIsNewDoc(bIsNewDoc),
         m_bInTableStyleRunProps(false),
-        m_pSdtHelper(0)
+        m_pSdtHelper(0),
+        m_nTableDepth(0)
 
 {
     appendTableManager( );
@@ -632,6 +633,11 @@ void DomainMapper_Impl::deferBreak( BreakType deferredBreakType)
             m_bIsColumnBreakDeferred = true;
         break;
     case PAGE_BREAK:
+            // See SwWW8ImplReader::HandlePageBreakChar(), page break should be
+            // ignored inside tables.
+            if (m_nTableDepth > 0)
+                return;
+
             m_bIsPageBreakDeferred = true;
         break;
     default:
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
index 30cc2c7..c65d804 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
@@ -691,6 +691,15 @@ public:
 
     /// Document background color, applied to every page style.
     boost::optional<sal_Int32> m_oBackgroundColor;
+
+    /**
+     * This contains the raw table depth. m_nTableDepth > 0 is the same as
+     * getTableManager().isInTable(), unless we're in the first paragraph of a
+     * table, or first paragraph after a table, as the table manager is only
+     * updated once we ended the paragraph (and know if the para has the
+     * PFInTable SPRM or not).
+     */
+    sal_Int32 m_nTableDepth;
 };
 } //namespace dmapper
 } //namespace writerfilter
diff --git a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
index 6447203..4f2b130 100644
--- a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
+++ b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
@@ -1960,6 +1960,16 @@ void OOXMLFastContextHandlerTextTable::lcl_endFastElement
 {
     endAction(Element);
 
+    boost::shared_ptr<OOXMLPropertySet> pProps( new OOXMLPropertySetImpl );
+    {
+        OOXMLValue::Pointer_t pVal
+            (new OOXMLIntegerValue(mnTableDepth));
+        OOXMLProperty::Pointer_t pProp
+            (new OOXMLPropertyImpl(NS_ooxml::LN_tblEnd, pVal, OOXMLPropertyImpl::SPRM));
+        pProps->add(pProp);
+    }
+    mpParserState->setCharacterProperties(pProps);
+
     mnTableDepth--;
     mpParserState->endTable();
 }
diff --git a/writerfilter/source/ooxml/model.xml b/writerfilter/source/ooxml/model.xml
index c15f798..4fad4ba 100644
--- a/writerfilter/source/ooxml/model.xml
+++ b/writerfilter/source/ooxml/model.xml
@@ -39,6 +39,7 @@
   <token tokenid="ooxml:trackchange"/>
   <token tokenid="ooxml:object"/>
   <token tokenid="ooxml:tblStart"/>
+  <token tokenid="ooxml:tblEnd"/>
   <token tokenid="ooxml:ffdata"/>
   <token tokenid="ooxml:starmath"/>
   <namespace name="dml-stylesheet" url="http://schemas.openxmlformats.org/drawingml/2006/main" file="dml-stylesheet.rng">


More information about the Libreoffice-commits mailing list