diff options
author | Justin Luth <justin_luth@sil.org> | 2016-07-04 21:39:37 +0300 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-07-08 07:24:10 +0000 |
commit | a60b2f7c227709d27d6294558fd396557a9ffd20 (patch) | |
tree | a55d9d19f169ea12c8d37f6031a20100dc4ab824 | |
parent | f8847d3ab4a5ea567f97b05181ed307135ade258 (diff) |
tdf#64372 docx import: don't ignore continuous section break
If the previous break was also a continuous section break,
this break was simply ignored ever since
commit 1fdd61db155cf63d5dd55cc2bfb45af33796e131.
Thus, the default handler took over and assigned PROP_PAGE_DESC
if there was some kind of page style known
(either the first page/Standard defaults or any "converted" styles
that had been created) which effectively became a new page break.
Change-Id: I839570b0330ba274552cc671014e997c42765f4b
Reviewed-on: https://gerrit.libreoffice.org/26567
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Justin Luth <justin_luth@sil.org>
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
-rwxr-xr-x | sw/qa/extras/ooxmlexport/data/tdf64372_continuousBreaks.docx | bin | 0 -> 11735 bytes | |||
-rwxr-xr-x | sw/qa/extras/ooxmlexport/data/tdf92724_continuousBreaksComplex.docx | bin | 0 -> 26913 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport4.cxx | 20 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlimport/ooxmlimport.cxx | 7 | ||||
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper.cxx | 12 |
5 files changed, 29 insertions, 10 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/tdf64372_continuousBreaks.docx b/sw/qa/extras/ooxmlexport/data/tdf64372_continuousBreaks.docx Binary files differnew file mode 100755 index 000000000000..20ad82bb5115 --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/tdf64372_continuousBreaks.docx diff --git a/sw/qa/extras/ooxmlexport/data/tdf92724_continuousBreaksComplex.docx b/sw/qa/extras/ooxmlexport/data/tdf92724_continuousBreaksComplex.docx Binary files differnew file mode 100755 index 000000000000..808d05697bd0 --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/tdf92724_continuousBreaksComplex.docx diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx index f2bb607e6e7f..c4ab555cde6a 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx @@ -971,6 +971,26 @@ DECLARE_OOXMLEXPORT_TEST(testTdf96750_landscapeFollow, "tdf96750_landscapeFollow CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(xStyle, "IsLandscape")); } +DECLARE_OOXMLEXPORT_TEST(testTdf64372_continuousBreaks,"tdf64372_continuousBreaks.docx") +{ + //There are no page breaks, so everything should be on the first page. + uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY); + uno::Reference<text::XTextViewCursorSupplier> xTextViewCursorSupplier(xModel->getCurrentController(), uno::UNO_QUERY); + uno::Reference<text::XPageCursor> xCursor(xTextViewCursorSupplier->getViewCursor(), uno::UNO_QUERY); + xCursor->jumpToLastPage(); + CPPUNIT_ASSERT_EQUAL(sal_Int16(1), xCursor->getPage()); +} + +DECLARE_OOXMLEXPORT_TEST(testTdf92724_continuousBreaksComplex,"tdf92724_continuousBreaksComplex.docx") +{ + //There are 2 page breaks, so there should be 3 pages. + uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY); + uno::Reference<text::XTextViewCursorSupplier> xTextViewCursorSupplier(xModel->getCurrentController(), uno::UNO_QUERY); + uno::Reference<text::XPageCursor> xCursor(xTextViewCursorSupplier->getViewCursor(), uno::UNO_QUERY); + xCursor->jumpToLastPage(); + CPPUNIT_ASSERT_EQUAL(sal_Int16(3), xCursor->getPage()); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx index d94d3ce6170e..4826c61b47e2 100644 --- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx +++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx @@ -986,6 +986,13 @@ DECLARE_OOXMLIMPORT_TEST(testN780843, "n780843.docx") xPara = getParagraph(1); aStyleName = getProperty<OUString>(xPara, "PageStyleName"); CPPUNIT_ASSERT_EQUAL(OUString("First Page"), aStyleName); + + //tdf64372 this document should only have one page break (2 pages, not 3) + uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY); + uno::Reference<text::XTextViewCursorSupplier> xTextViewCursorSupplier(xModel->getCurrentController(), uno::UNO_QUERY); + uno::Reference<text::XPageCursor> xCursor(xTextViewCursorSupplier->getViewCursor(), uno::UNO_QUERY); + xCursor->jumpToLastPage(); + CPPUNIT_ASSERT_EQUAL(sal_Int16(2), xCursor->getPage()); } DECLARE_OOXMLIMPORT_TEST(testShadow, "imgshadow.docx") diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx index 36c5bfe083bd..b1b4f6d6f33e 100644 --- a/writerfilter/source/dmapper/DomainMapper.cxx +++ b/writerfilter/source/dmapper/DomainMapper.cxx @@ -1721,17 +1721,9 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, const PropertyMapPtr& rContext ) OSL_ENSURE(pSectionContext, "SectionContext unavailable!"); if(pSectionContext) { - // Ignore continuous section break at the end of the document, if the previous section had the same type as well - // It makes the importer lose margin settings with no benefit + //continuous break only allowed if it is not the only section break SectionPropertyMap* pLastContext = m_pImpl->GetLastSectionContext(); - int nPrevBreakType = NS_ooxml::LN_Value_ST_SectionMark_continuous; - bool bHasPrevSection = false; - if (pLastContext) - { - bHasPrevSection = true; - nPrevBreakType = pLastContext->GetBreakType(); - } - if (m_pImpl->GetParaSectpr() || nIntValue != static_cast<sal_Int32>(NS_ooxml::LN_Value_ST_SectionMark_continuous) || (bHasPrevSection && nPrevBreakType != nIntValue)) + if ( nIntValue != static_cast<sal_Int32>(NS_ooxml::LN_Value_ST_SectionMark_continuous) || pLastContext || m_pImpl->GetParaSectpr() ) pSectionContext->SetBreakType( nIntValue ); } break; |