summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@suse.cz>2013-09-02 10:27:49 +0200
committerMiklos Vajna <vmiklos@suse.cz>2013-09-02 10:31:14 +0200
commit7d3778e0ef9f54f3c8988f1b84d58e7002d6c625 (patch)
tree27117b9bd8fe6dc023185f2a51e4b4507882a529
parentc41920416c22bfccf7fdeeefcd69baf6eadedaa3 (diff)
bnc#816593 DOCX import: ignore page breaks in tables
Change-Id: Ibb250148d41d1929fa17dd993bb71c93c0e09dcf
-rwxr-xr-xsw/qa/extras/ooxmlimport/data/table-pagebreak.docxbin0 -> 10148 bytes
-rw-r--r--sw/qa/extras/ooxmlimport/ooxmlimport.cxx11
-rw-r--r--writerfilter/source/dmapper/DomainMapper.cxx6
-rw-r--r--writerfilter/source/dmapper/DomainMapper_Impl.cxx8
-rw-r--r--writerfilter/source/dmapper/DomainMapper_Impl.hxx9
-rw-r--r--writerfilter/source/ooxml/OOXMLFastContextHandler.cxx10
-rw-r--r--writerfilter/source/ooxml/model.xml1
7 files changed, 44 insertions, 1 deletions
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 000000000000..06ecf9535af1
--- /dev/null
+++ b/sw/qa/extras/ooxmlimport/data/table-pagebreak.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index 64c0764d66d9..9927df7c4a36 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -129,6 +129,7 @@ public:
void testBnc780044Spacing();
void testTableAutoNested();
void testTableStyleParprop();
+ void testTablePagebreak();
CPPUNIT_TEST_SUITE(Test);
#if !defined(MACOSX) && !defined(WNT)
@@ -224,6 +225,7 @@ void Test::run()
{"bnc780044_spacing.docx", &Test::testBnc780044Spacing},
{"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)
@@ -1519,6 +1521,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 e592d89846c4..261d99cee165 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -3403,6 +3403,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 7725b86d0604..8a4b252a33e1 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -174,7 +174,8 @@ DomainMapper_Impl::DomainMapper_Impl(
m_xInsertTextRange(xInsertTextRange),
m_bIsNewDoc(bIsNewDoc),
m_bInTableStyleRunProps(false),
- m_pSdtHelper(0)
+ m_pSdtHelper(0),
+ m_nTableDepth(0)
{
appendTableManager( );
@@ -616,6 +617,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 e342ebe3c60e..9b1ebe120432 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
@@ -692,6 +692,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 7b73ba03e4af..88456239f0be 100644
--- a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
+++ b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
@@ -1957,6 +1957,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 ea8f082c4d9c..63c182cab969 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">