From 78b195c484f8b10eb356a6f9079942e709fd8cda Mon Sep 17 00:00:00 2001 From: Justin Luth Date: Sat, 11 Mar 2017 09:24:38 +0300 Subject: ooxmlimport: move bnc#519228 unit test to ooxmlexport9 The unit test wasn't round-tripping due to the paragraph count changing. Writer always add a CR to a blank paragraph, and so these are ignored on import (bRemove). The unit test's second paragraph was one of these. Simplifying the unit test by removing that CR, allowing it to become a round-trippable test. Change-Id: I8786915fb5df8fc4325a6a427ab84bb879632a7a Reviewed-on: https://gerrit.libreoffice.org/35072 Tested-by: Jenkins Reviewed-by: Justin Luth Tested-by: Justin Luth Reviewed-by: Miklos Vajna --- .../ooxmlexport/data/bnc519228_odd-breaksB.docx | Bin 0 -> 13674 bytes sw/qa/extras/ooxmlexport/ooxmlexport9.cxx | 33 +++++++++++++++++++++ .../ooxmlimport/data/bnc519228_odd-breaks.docx | Bin 14777 -> 0 bytes sw/qa/extras/ooxmlimport/ooxmlimport.cxx | 33 --------------------- 4 files changed, 33 insertions(+), 33 deletions(-) create mode 100755 sw/qa/extras/ooxmlexport/data/bnc519228_odd-breaksB.docx delete mode 100644 sw/qa/extras/ooxmlimport/data/bnc519228_odd-breaks.docx diff --git a/sw/qa/extras/ooxmlexport/data/bnc519228_odd-breaksB.docx b/sw/qa/extras/ooxmlexport/data/bnc519228_odd-breaksB.docx new file mode 100755 index 000000000000..674d71401110 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/bnc519228_odd-breaksB.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx index 176c9180a29a..678e0923637d 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -260,6 +261,38 @@ DECLARE_OOXMLEXPORT_TEST(testTdf103573, "tdf103573.docx") CPPUNIT_ASSERT_EQUAL_MESSAGE("Not centered horizontally relatively to right page border", text::RelOrientation::PAGE_RIGHT, nValue); } +DECLARE_OOXMLEXPORT_TEST(testBnc519228OddBreaks, "bnc519228_odd-breaksB.docx") +{ + // Check that all the normal styles are not set as right-only, those should be only those used after odd page breaks. + uno::Reference defaultStyle(getStyles("PageStyles")->getByName("Standard"), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(uno::makeAny(style::PageStyleLayout_ALL), defaultStyle->getPropertyValue("PageStyleLayout")); + uno::Reference firstPage( getStyles("PageStyles")->getByName("First Page"), uno::UNO_QUERY ); + CPPUNIT_ASSERT_EQUAL(uno::makeAny(style::PageStyleLayout_ALL), firstPage->getPropertyValue("PageStyleLayout")); + + OUString page1StyleName = getProperty( getParagraph( 1, "This is the first page." ), "PageDescName"); + uno::Reference page1Style(getStyles("PageStyles")->getByName(page1StyleName), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(uno::makeAny(style::PageStyleLayout_RIGHT), page1Style->getPropertyValue("PageStyleLayout")); + getParagraphOfText( 1, getProperty< uno::Reference >(page1Style, "HeaderText"), "This is the header for odd pages"); + + // Page2 comes from follow of style for page 1 and should be a normal page. Also check the two page style have the same properties, + // since page style for page1 was created from page style for page 2. + uno::Any page2StyleAny = uno::Reference( + getParagraph(2, "This is page 2, which is obviously an even page."), + uno::UNO_QUERY_THROW)->getPropertyValue("PageDescName"); + CPPUNIT_ASSERT_EQUAL(uno::Any(), page2StyleAny); + OUString page2StyleName = getProperty( page1Style, "FollowStyle" ); + uno::Reference page2Style(getStyles("PageStyles")->getByName(page2StyleName), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(uno::makeAny(style::PageStyleLayout_ALL), page2Style->getPropertyValue("PageStyleLayout")); + getParagraphOfText( 1, getProperty< uno::Reference >(page2Style, "HeaderTextLeft"), "This is the even header"); + getParagraphOfText( 1, getProperty< uno::Reference >(page2Style, "HeaderTextRight"), "This is the header for odd pages"); + CPPUNIT_ASSERT_EQUAL(getProperty(page1Style, "TopMargin"), getProperty(page2Style, "TopMargin")); + + OUString page5StyleName = getProperty( getParagraph( 4, "Then an odd break after an odd page, should lead us to page #5." ), "PageDescName"); + uno::Reference page5Style(getStyles("PageStyles")->getByName(page5StyleName), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(uno::makeAny(style::PageStyleLayout_RIGHT), page5Style->getPropertyValue("PageStyleLayout")); + getParagraphOfText( 1, getProperty< uno::Reference >(page5Style, "HeaderText"), "This is the header for odd pages"); +} + DECLARE_OOXMLEXPORT_TEST(testTdf79329, "tdf79329.docx") { uno::Reference xTablesSupplier(mxComponent, uno::UNO_QUERY); diff --git a/sw/qa/extras/ooxmlimport/data/bnc519228_odd-breaks.docx b/sw/qa/extras/ooxmlimport/data/bnc519228_odd-breaks.docx deleted file mode 100644 index 8711d62df045..000000000000 Binary files a/sw/qa/extras/ooxmlimport/data/bnc519228_odd-breaks.docx and /dev/null differ diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx index 367b894a08d7..77880b935b96 100644 --- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx +++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx @@ -44,7 +44,6 @@ #include #include #include -#include #include #include #include @@ -917,38 +916,6 @@ DECLARE_OOXMLIMPORT_TEST(testFloatingTableSectionColumns, "floating-table-sectio CPPUNIT_ASSERT( tableWidth.toInt32() > 10000 ); } -DECLARE_OOXMLIMPORT_TEST(testBnc519228OddBreaks, "bnc519228_odd-breaks.docx") -{ - // Check that all the normal styles are not set as right-only, those should be only those used after odd page breaks. - uno::Reference defaultStyle(getStyles("PageStyles")->getByName("Standard"), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(uno::makeAny(style::PageStyleLayout_ALL), defaultStyle->getPropertyValue("PageStyleLayout")); - uno::Reference firstPage( getStyles("PageStyles")->getByName("First Page"), uno::UNO_QUERY ); - CPPUNIT_ASSERT_EQUAL(uno::makeAny(style::PageStyleLayout_ALL), firstPage->getPropertyValue("PageStyleLayout")); - - OUString page1StyleName = getProperty( getParagraph( 1, "This is the first page." ), "PageDescName"); - uno::Reference page1Style(getStyles("PageStyles")->getByName(page1StyleName), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(uno::makeAny(style::PageStyleLayout_RIGHT), page1Style->getPropertyValue("PageStyleLayout")); - getParagraphOfText( 1, getProperty< uno::Reference >(page1Style, "HeaderText"), "This is the header for odd pages"); - - // Page2 comes from follow of style for page 1 and should be a normal page. Also check the two page style have the same properties, - // since page style for page1 was created from page style for page 2. - uno::Any page2StyleAny = uno::Reference( - getParagraph(3, "This is page 2, which is obviously an even page."), - uno::UNO_QUERY_THROW)->getPropertyValue("PageDescName"); - CPPUNIT_ASSERT_EQUAL(uno::Any(), page2StyleAny); - OUString page2StyleName = getProperty( page1Style, "FollowStyle" ); - uno::Reference page2Style(getStyles("PageStyles")->getByName(page2StyleName), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(uno::makeAny(style::PageStyleLayout_ALL), page2Style->getPropertyValue("PageStyleLayout")); - getParagraphOfText( 1, getProperty< uno::Reference >(page2Style, "HeaderTextLeft"), "This is the even header"); - getParagraphOfText( 1, getProperty< uno::Reference >(page2Style, "HeaderTextRight"), "This is the header for odd pages"); - CPPUNIT_ASSERT_EQUAL(getProperty(page1Style, "TopMargin"), getProperty(page2Style, "TopMargin")); - - OUString page5StyleName = getProperty( getParagraph( 5, "Then an odd break after an odd page, should lead us to page #5." ), "PageDescName"); - uno::Reference page5Style(getStyles("PageStyles")->getByName(page5StyleName), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(uno::makeAny(style::PageStyleLayout_RIGHT), page5Style->getPropertyValue("PageStyleLayout")); - getParagraphOfText( 1, getProperty< uno::Reference >(page5Style, "HeaderText"), "This is the header for odd pages"); -} - static OString dateTimeToString( const util::DateTime& dt ) { return DateTimeToOString( DateTime( Date( dt.Day, dt.Month, dt.Year ), tools::Time( dt.Hours, dt.Minutes, dt.Seconds ))); -- cgit