From 7060c7b642fdc0a369505e430652ee44205e7eed Mon Sep 17 00:00:00 2001 From: Justin Luth Date: Thu, 6 Oct 2016 16:53:23 +0300 Subject: tdf#95367 DOCX: allow r-t of changed first/follow sections Change-Id: Ibb97411a7dfeebc3edbdd149842bfe626942cf7f Reviewed-on: https://gerrit.libreoffice.org/29559 Tested-by: Jenkins Reviewed-by: Miklos Vajna --- .../ooxmlexport/data/inheritFirstHeader.docx | Bin 0 -> 15002 bytes .../data/tdf95367_inheritFollowStyle.docx | Bin 0 -> 13861 bytes sw/qa/extras/ooxmlexport/ooxmlexport4.cxx | 28 +++++++++++++++++++++ .../ooxmlimport/data/inheritFirstHeader.docx | Bin 15002 -> 0 bytes .../data/tdf95367_inheritFollowStyle.docx | Bin 13861 -> 0 bytes sw/qa/extras/ooxmlimport/ooxmlimport.cxx | 28 --------------------- sw/source/filter/ww8/docxattributeoutput.cxx | 6 ++--- sw/source/filter/ww8/docxexport.cxx | 4 +++ sw/source/filter/ww8/wrtww8.cxx | 4 +++ 9 files changed, 39 insertions(+), 31 deletions(-) create mode 100644 sw/qa/extras/ooxmlexport/data/inheritFirstHeader.docx create mode 100644 sw/qa/extras/ooxmlexport/data/tdf95367_inheritFollowStyle.docx delete mode 100644 sw/qa/extras/ooxmlimport/data/inheritFirstHeader.docx delete mode 100644 sw/qa/extras/ooxmlimport/data/tdf95367_inheritFollowStyle.docx diff --git a/sw/qa/extras/ooxmlexport/data/inheritFirstHeader.docx b/sw/qa/extras/ooxmlexport/data/inheritFirstHeader.docx new file mode 100644 index 000000000000..e3d7d20a2d23 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/inheritFirstHeader.docx differ diff --git a/sw/qa/extras/ooxmlexport/data/tdf95367_inheritFollowStyle.docx b/sw/qa/extras/ooxmlexport/data/tdf95367_inheritFollowStyle.docx new file mode 100644 index 000000000000..96d91ddcafcd Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf95367_inheritFollowStyle.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx index 559c4a7a976e..1a6c967e45b3 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx @@ -1031,6 +1031,34 @@ DECLARE_OOXMLEXPORT_TEST(testTdf90697_continuousBreaksComplex2,"tdf92724_continu } } +DECLARE_OOXMLEXPORT_TEST(testTdf95367_inheritFollowStyle, "tdf95367_inheritFollowStyle.docx") +{ + CPPUNIT_ASSERT_EQUAL(OUString("header"), parseDump("/root/page[2]/header/txt/text()")); +} + +DECLARE_OOXMLEXPORT_TEST(testInheritFirstHeader,"inheritFirstHeader.docx") +{ +// First page headers always link to last used first header, never to a follow header + uno::Reference xModel(mxComponent, uno::UNO_QUERY); + uno::Reference xTextViewCursorSupplier(xModel->getCurrentController(), uno::UNO_QUERY); + uno::Reference xCursor(xTextViewCursorSupplier->getViewCursor(), uno::UNO_QUERY); + + xCursor->jumpToLastPage(); + OUString sPageStyleName = getProperty( xCursor, "PageStyleName" ); + uno::Reference xHeaderText = getProperty< uno::Reference >(getStyles("PageStyles")->getByName(sPageStyleName), "HeaderText"); + CPPUNIT_ASSERT_EQUAL( OUString("Last Header"), xHeaderText->getString() ); + + xCursor->jumpToPreviousPage(); + sPageStyleName = getProperty( xCursor, "PageStyleName" ); + xHeaderText = getProperty< uno::Reference >(getStyles("PageStyles")->getByName(sPageStyleName), "HeaderText"); + CPPUNIT_ASSERT_EQUAL( OUString("First Header"), xHeaderText->getString() ); + + xCursor->jumpToPreviousPage(); + sPageStyleName = getProperty( xCursor, "PageStyleName" ); + xHeaderText = getProperty< uno::Reference >(getStyles("PageStyles")->getByName(sPageStyleName), "HeaderText"); + CPPUNIT_ASSERT_EQUAL( OUString("Follow Header"), xHeaderText->getString() ); +} + DECLARE_OOXMLEXPORT_TEST(testTdf81345_045Original,"tdf81345.docx") { //Header wasn't replaced and columns were missing because no new style was created. diff --git a/sw/qa/extras/ooxmlimport/data/inheritFirstHeader.docx b/sw/qa/extras/ooxmlimport/data/inheritFirstHeader.docx deleted file mode 100644 index e3d7d20a2d23..000000000000 Binary files a/sw/qa/extras/ooxmlimport/data/inheritFirstHeader.docx and /dev/null differ diff --git a/sw/qa/extras/ooxmlimport/data/tdf95367_inheritFollowStyle.docx b/sw/qa/extras/ooxmlimport/data/tdf95367_inheritFollowStyle.docx deleted file mode 100644 index 96d91ddcafcd..000000000000 Binary files a/sw/qa/extras/ooxmlimport/data/tdf95367_inheritFollowStyle.docx and /dev/null differ diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx index f42f1e61f507..912e01b55e70 100644 --- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx +++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx @@ -443,11 +443,6 @@ are on page 2 and page 3 CPPUNIT_ASSERT_EQUAL( OUString("two"), parseDump("/root/page[3]/body/txt/text()") ); } -DECLARE_OOXMLIMPORT_TEST(testTdf95367_inheritFollowStyle, "tdf95367_inheritFollowStyle.docx") -{ - CPPUNIT_ASSERT_EQUAL(OUString("header"), parseDump("/root/page[2]/header/txt/text()")); -} - DECLARE_OOXMLIMPORT_TEST(testN652364, "n652364.docx") { /* @@ -993,29 +988,6 @@ DECLARE_OOXMLIMPORT_TEST(testN780843b, "n780843b.docx") 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 xModel(mxComponent, uno::UNO_QUERY); - uno::Reference xTextViewCursorSupplier(xModel->getCurrentController(), uno::UNO_QUERY); - uno::Reference xCursor(xTextViewCursorSupplier->getViewCursor(), uno::UNO_QUERY); - - xCursor->jumpToLastPage(); - OUString sPageStyleName = getProperty( xCursor, "PageStyleName" ); - uno::Reference xHeaderText = getProperty< uno::Reference >(getStyles("PageStyles")->getByName(sPageStyleName), "HeaderText"); - CPPUNIT_ASSERT_EQUAL( OUString("Last Header"), xHeaderText->getString() ); - - xCursor->jumpToPreviousPage(); - sPageStyleName = getProperty( xCursor, "PageStyleName" ); - xHeaderText = getProperty< uno::Reference >(getStyles("PageStyles")->getByName(sPageStyleName), "HeaderText"); - CPPUNIT_ASSERT_EQUAL( OUString("First Header"), xHeaderText->getString() ); - - xCursor->jumpToPreviousPage(); - sPageStyleName = getProperty( xCursor, "PageStyleName" ); - xHeaderText = getProperty< uno::Reference >(getStyles("PageStyles")->getByName(sPageStyleName), "HeaderText"); - CPPUNIT_ASSERT_EQUAL( OUString("Follow Header"), xHeaderText->getString() ); -} - DECLARE_OOXMLIMPORT_TEST(testShadow, "imgshadow.docx") { /* diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index 62e8e8f5ec6c..582e8cde7b92 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -821,13 +821,13 @@ void DocxAttributeOutput::SectionBreaks(const SwNode& rNode) } else if (rNode.IsEndNode()) { - // End of something: make sure that it's the end of a table. - assert(rNode.StartOfSectionNode()->IsTableNode()); if (aNextIndex.GetNode().IsTextNode()) { // Handle section break between a table and a text node following it. + // Also handle section endings const SwTextNode* pTextNode = aNextIndex.GetNode().GetTextNode(); - m_rExport.OutputSectionBreaks(pTextNode->GetpSwAttrSet(), *pTextNode, m_tableReference->m_bTableCellOpen, pTextNode->GetText().isEmpty()); + if (rNode.StartOfSectionNode()->IsTableNode() || rNode.StartOfSectionNode()->IsSectionNode()) + m_rExport.OutputSectionBreaks(pTextNode->GetpSwAttrSet(), *pTextNode, m_tableReference->m_bTableCellOpen, pTextNode->GetText().isEmpty()); } } } diff --git a/sw/source/filter/ww8/docxexport.cxx b/sw/source/filter/ww8/docxexport.cxx index e19cf1990ab2..05459deb461e 100644 --- a/sw/source/filter/ww8/docxexport.cxx +++ b/sw/source/filter/ww8/docxexport.cxx @@ -509,6 +509,10 @@ void DocxExport::OutputEndNode( const SwEndNode& rEndNode ) AttrOutput().SectionBreak( msword::PageBreak, m_pSections->CurrentSectionInfo( ) ); m_pSections->AppendSection( m_pAktPageDesc, pParentFormat, nRstLnNum ); } + else + { + AttrOutput().SectionBreaks( rEndNode ); + } } else if (TXT_MAINTEXT == m_nTextTyp && rEndNode.StartOfSectionNode()->IsTableNode()) // End node of a table: see if a section break should be written after the table. diff --git a/sw/source/filter/ww8/wrtww8.cxx b/sw/source/filter/ww8/wrtww8.cxx index 63324ec652e6..224f961d0f9e 100644 --- a/sw/source/filter/ww8/wrtww8.cxx +++ b/sw/source/filter/ww8/wrtww8.cxx @@ -2735,6 +2735,10 @@ void MSWordExportBase::WriteText() AppendSection( m_pAktPageDesc, pParentFormat, nRstLnNum ); } + else + { + OutputEndNode( *rNd.GetEndNode() ); + } } } else if ( rNd.IsStartNode() ) -- cgit