diff options
author | Justin Luth <justin_luth@sil.org> | 2016-10-22 15:20:38 +0300 |
---|---|---|
committer | Justin Luth <justin_luth@sil.org> | 2016-10-24 11:04:12 +0000 |
commit | d129099624d2b646d975c9567541ed9c18adb7ef (patch) | |
tree | f62fbb41e2878fd22698fb9bdff16de0815ac0ee | |
parent | f5f51cb93d11731c64dfd68044144100f5fc4b28 (diff) |
tdf#89377 writerfilter: table honors ParaStyle break-before-page
.doc format handled in prior patch.
This import .docx patch checks to see if the very first paragraph style
in a table is set with a page-break, and if so, then transfers
that setting to the table itself.
Change-Id: Ibb87eeb0fbdb7fdd84ef43dd1d7e0a6f8e1f8ad5
Reviewed-on: https://gerrit.libreoffice.org/30161
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Justin Luth <justin_luth@sil.org>
-rwxr-xr-x | sw/qa/extras/ooxmlexport/data/tdf89377_tableWithBreakBeforeParaStyle.docx | bin | 0 -> 11507 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport9.cxx | 6 | ||||
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper.cxx | 27 |
3 files changed, 31 insertions, 2 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/tdf89377_tableWithBreakBeforeParaStyle.docx b/sw/qa/extras/ooxmlexport/data/tdf89377_tableWithBreakBeforeParaStyle.docx Binary files differnew file mode 100755 index 000000000000..bf673e86e780 --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/tdf89377_tableWithBreakBeforeParaStyle.docx diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx index 0a637881ebbf..18ab97e5a406 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx @@ -46,6 +46,12 @@ DECLARE_OOXMLEXPORT_TEST(testTdf95031, "tdf95031.docx") CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), getProperty<sal_Int32>(getParagraph(3), "ParaTopMargin")); } +DECLARE_OOXMLEXPORT_TEST(testTdf89377, "tdf89377_tableWithBreakBeforeParaStyle.docx") +{ + // the paragraph style should set table's text-flow break-before-page + CPPUNIT_ASSERT_EQUAL( 3, getPages() ); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx index b93a96511449..f37025f1e32a 100644 --- a/writerfilter/source/dmapper/DomainMapper.cxx +++ b/writerfilter/source/dmapper/DomainMapper.cxx @@ -2533,7 +2533,7 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, const PropertyMapPtr& rContext ) } break; case NS_ooxml::LN_tblStart: - + { /* * Hack for Importing Section Properties * LO is not able to import section properties if first element in the @@ -2545,8 +2545,31 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, const PropertyMapPtr& rContext ) { m_pImpl->AddDummyParaForTableInSection(); } - m_pImpl->m_nTableDepth++; + // if first paragraph style in table has break-before-page, transfer that setting to the table itself. + if( m_pImpl->m_nTableDepth == 0 ) + { + const uno::Any aBreakType = uno::makeAny(style::BreakType_PAGE_BEFORE); + const PropertyMapPtr pParagraphProps = m_pImpl->GetTopContextOfType(CONTEXT_PARAGRAPH); + if( pParagraphProps && pParagraphProps->isSet(PROP_PARA_STYLE_NAME) ) + { + StyleSheetEntryPtr pStyle = nullptr; + OUString sStyleName; + pParagraphProps->getProperty(PROP_PARA_STYLE_NAME)->second >>= sStyleName; + if( !sStyleName.isEmpty() && GetStyleSheetTable() ) + pStyle = GetStyleSheetTable()->FindStyleSheetByStyleName( sStyleName ); + + if( pStyle && pStyle->pProperties + && pStyle->pProperties->isSet(PROP_BREAK_TYPE) + && pStyle->pProperties->getProperty(PROP_BREAK_TYPE)->second == aBreakType ) + { + pParagraphProps->Insert(PROP_BREAK_TYPE, aBreakType); + } + } + } + + m_pImpl->m_nTableDepth++; + } break; case NS_ooxml::LN_tblEnd: m_pImpl->m_nTableDepth--; |