sw/qa/extras/ooxmlimport/data/inheritFirstHeader.docx |binary sw/qa/extras/ooxmlimport/data/n780843b.docx |binary sw/qa/extras/ooxmlimport/ooxmlimport.cxx | 52 +++++++++++------- writerfilter/source/dmapper/PropertyMap.cxx | 12 ++-- 4 files changed, 40 insertions(+), 24 deletions(-)
New commits: commit fe8ec3f3f09aae165c854294ad52d6870e70ef8e Author: Justin Luth <justin_l...@sil.org> Date: Fri Sep 30 17:46:38 2016 +0300 n#780843 revert part of docx testcase revert testcase for commit 211916f86585cb4f6258eb30e0474e4c21cd37f1 On import, it is impossible to know where automatic end-of-pages will be, so it cannot be known that all the content before the page-break will be on the first page. Removing this testcase because Writer does not have the capability to dynamically assign headers/footers to continuous break sections. This test worked on this particular document, but not on generic documents. Replacing it with a version of the document with more text before the continuous break, which produces the exact opposite footer results. Change-Id: If660edd47b4eb19798f79babe65c37e1a9848739 Reviewed-on: https://gerrit.libreoffice.org/29408 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Miklos Vajna <vmik...@collabora.co.uk> diff --git a/sw/qa/extras/ooxmlimport/data/inheritFirstHeader.docx b/sw/qa/extras/ooxmlimport/data/inheritFirstHeader.docx new file mode 100644 index 0000000..e3d7d20 Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/inheritFirstHeader.docx differ diff --git a/sw/qa/extras/ooxmlimport/data/n780843b.docx b/sw/qa/extras/ooxmlimport/data/n780843b.docx new file mode 100644 index 0000000..2ba9ab2 Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/n780843b.docx differ diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx index 50f587f..4c099e1 100644 --- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx +++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx @@ -971,25 +971,8 @@ DECLARE_OOXMLIMPORT_TEST(testN780853, "n780853.docx") DECLARE_OOXMLIMPORT_TEST(testN780843, "n780843.docx") { - /* - * The problem was that wrong footer was picked. - * - * oParas = ThisComponent.Text.createEnumeration - * oPara = oParas.nextElement - * oPara = oParas.nextElement - * oPara = oParas.nextElement - * sStyle = oPara.PageStyleName - * oStyle = ThisComponent.StyleFamilies.PageStyles.getByName(sStyle) - * xray oStyle.FooterText.String ' was "hidden footer" - */ - uno::Reference< text::XTextRange > xPara = getParagraph(3); + uno::Reference< text::XTextRange > xPara = getParagraph(1); OUString aStyleName = getProperty<OUString>(xPara, "PageStyleName"); - uno::Reference<beans::XPropertySet> xPageStyle(getStyles("PageStyles")->getByName(aStyleName), uno::UNO_QUERY); - uno::Reference<text::XTextRange> xFooter = getProperty< uno::Reference<text::XTextRange> >(xPageStyle, "FooterText"); - CPPUNIT_ASSERT_EQUAL(OUString("shown footer"), xFooter->getString()); - - 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) @@ -1000,6 +983,39 @@ DECLARE_OOXMLIMPORT_TEST(testN780843, "n780843.docx") CPPUNIT_ASSERT_EQUAL(sal_Int16(2), xCursor->getPage()); } +DECLARE_OOXMLIMPORT_TEST(testN780843b, "n780843b.docx") +{ + // Same document as testN780843 except there is more text before the continuous break. Now the opposite footer results should happen. + uno::Reference< text::XTextRange > xPara = getParagraph(3); + OUString aStyleName = getProperty<OUString>(xPara, "PageStyleName"); + uno::Reference<beans::XPropertySet> xPageStyle(getStyles("PageStyles")->getByName(aStyleName), uno::UNO_QUERY); + uno::Reference<text::XTextRange> xFooterText = getProperty< uno::Reference<text::XTextRange> >(xPageStyle, "FooterText"); + CPPUNIT_ASSERT_EQUAL( OUString("hidden footer"), xFooterText->getString() ); +} + +DECLARE_OOXMLIMPORT_TEST(testInheritFirstHeader,"inheritFirstHeader.docx") +{ +// First page headers always link to last used first header, never to a follow header + 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(); + OUString sPageStyleName = getProperty<OUString>( xCursor, "PageStyleName" ); + uno::Reference<text::XText> xHeaderText = getProperty< uno::Reference<text::XText> >(getStyles("PageStyles")->getByName(sPageStyleName), "HeaderText"); + CPPUNIT_ASSERT_EQUAL( OUString("Last Header"), xHeaderText->getString() ); + + xCursor->jumpToPreviousPage(); + sPageStyleName = getProperty<OUString>( xCursor, "PageStyleName" ); + xHeaderText = getProperty< uno::Reference<text::XText> >(getStyles("PageStyles")->getByName(sPageStyleName), "HeaderText"); + CPPUNIT_ASSERT_EQUAL( OUString("First Header"), xHeaderText->getString() ); + + xCursor->jumpToPreviousPage(); + sPageStyleName = getProperty<OUString>( xCursor, "PageStyleName" ); + xHeaderText = getProperty< uno::Reference<text::XText> >(getStyles("PageStyles")->getByName(sPageStyleName), "HeaderText"); + CPPUNIT_ASSERT_EQUAL( OUString("Follow Header"), xHeaderText->getString() ); +} + DECLARE_OOXMLIMPORT_TEST(testShadow, "imgshadow.docx") { /* diff --git a/writerfilter/source/dmapper/PropertyMap.cxx b/writerfilter/source/dmapper/PropertyMap.cxx index 6a07e9d..03198f3 100644 --- a/writerfilter/source/dmapper/PropertyMap.cxx +++ b/writerfilter/source/dmapper/PropertyMap.cxx @@ -1114,19 +1114,19 @@ throw ( css::beans::UnknownPropertyException, ApplyProperties_( m_aFollowPageStyle ); } - if( pLastContext && m_sFirstPageStyleName.isEmpty() ) - m_sFirstPageStyleName = pLastContext->GetPageStyleName( /*bFirst=*/true ); + // FirstPageStyle may only be inherited if it will not be used or re-linked to a different follow + if( !m_bTitlePage && pLastContext && m_sFirstPageStyleName.isEmpty() ) + m_sFirstPageStyleName = pLastContext->GetPageStyleName( /*bFirst=*/true ); else { HandleMarginsHeaderFooter( /*bFirst=*/true, rDM_Impl ); GetPageStyle( xPageStyles, xTextFactory, /*bFirst=*/true ); if( rDM_Impl.IsNewDoc() && m_aFirstPageStyle.is() ) ApplyProperties_( m_aFirstPageStyle ); - } - GetPageStyle( xPageStyles, xTextFactory, /*bFirst=*/true ); - // Chain m_aFollowPageStyle to be after m_aFirstPageStyle - m_aFirstPageStyle->setPropertyValue( "FollowStyle", uno::makeAny(m_sFollowPageStyleName) ); + // Chain m_aFollowPageStyle to be after m_aFirstPageStyle + m_aFirstPageStyle->setPropertyValue( "FollowStyle", uno::makeAny(m_sFollowPageStyleName) ); + } } void SectionPropertyMap::CloseSectionGroup( DomainMapper_Impl& rDM_Impl ) _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits