sw/qa/extras/rtfexport/rtfexport.cxx | 904 +++++++++++++++++++++-------------- 1 file changed, 567 insertions(+), 337 deletions(-)
New commits: commit c0a8725da1108604510b7d6a330fa673cba31a5d Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Wed Apr 3 08:24:44 2024 +0200 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Wed Apr 3 09:34:24 2024 +0200 CppunitTest_sw_rtfexport: avoid DECLARE_RTFEXPORT_TEST No need to go via Writer-specific macros here. Change-Id: Iee66114a4cb8db712d932cc78f799809ad5e4341 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165730 Reviewed-by: Miklos Vajna <vmik...@collabora.com> Tested-by: Jenkins diff --git a/sw/qa/extras/rtfexport/rtfexport.cxx b/sw/qa/extras/rtfexport/rtfexport.cxx index ac196f7bf5bf..9558d3f5ef0a 100644 --- a/sw/qa/extras/rtfexport/rtfexport.cxx +++ b/sw/qa/extras/rtfexport/rtfexport.cxx @@ -46,69 +46,103 @@ public: } }; -DECLARE_RTFEXPORT_TEST(testZoom, "zoom.rtf") +CPPUNIT_TEST_FIXTURE(Test, testZoom) { - uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY); - uno::Reference<view::XViewSettingsSupplier> xViewSettingsSupplier( - xModel->getCurrentController(), uno::UNO_QUERY); - uno::Reference<beans::XPropertySet> xPropertySet(xViewSettingsSupplier->getViewSettings()); - sal_Int16 nValue = 0; - xPropertySet->getPropertyValue("ZoomValue") >>= nValue; - CPPUNIT_ASSERT_EQUAL(sal_Int16(42), nValue); + auto verify = [this]() { + uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY); + uno::Reference<view::XViewSettingsSupplier> xViewSettingsSupplier( + xModel->getCurrentController(), uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> xPropertySet(xViewSettingsSupplier->getViewSettings()); + sal_Int16 nValue = 0; + xPropertySet->getPropertyValue("ZoomValue") >>= nValue; + CPPUNIT_ASSERT_EQUAL(sal_Int16(42), nValue); + }; + createSwDoc("zoom.rtf"); + verify(); + saveAndReload(mpFilter); + verify(); } -DECLARE_RTFEXPORT_TEST(testFdo38176, "fdo38176.rtf") +CPPUNIT_TEST_FIXTURE(Test, testFdo38176) { - CPPUNIT_ASSERT_EQUAL(u"foo ‑bar"_ustr, getBodyText()); + auto verify = [this]() { CPPUNIT_ASSERT_EQUAL(u"foo ‑bar"_ustr, getBodyText()); }; + createSwDoc("fdo38176.rtf"); + verify(); + saveAndReload(mpFilter); + verify(); } -DECLARE_RTFEXPORT_TEST(testFdo49683, "fdo49683.rtf") +CPPUNIT_TEST_FIXTURE(Test, testFdo49683) { - uno::Reference<document::XDocumentPropertiesSupplier> xDocumentPropertiesSupplier( - mxComponent, uno::UNO_QUERY); - uno::Reference<document::XDocumentProperties> xDocumentProperties( - xDocumentPropertiesSupplier->getDocumentProperties()); - uno::Sequence<OUString> aKeywords(xDocumentProperties->getKeywords()); - CPPUNIT_ASSERT_EQUAL(sal_Int32(2), aKeywords.getLength()); - CPPUNIT_ASSERT_EQUAL(OUString("one"), aKeywords[0]); - CPPUNIT_ASSERT_EQUAL(OUString("two"), aKeywords[1]); + auto verify = [this]() { + uno::Reference<document::XDocumentPropertiesSupplier> xDocumentPropertiesSupplier( + mxComponent, uno::UNO_QUERY); + uno::Reference<document::XDocumentProperties> xDocumentProperties( + xDocumentPropertiesSupplier->getDocumentProperties()); + uno::Sequence<OUString> aKeywords(xDocumentProperties->getKeywords()); + CPPUNIT_ASSERT_EQUAL(sal_Int32(2), aKeywords.getLength()); + CPPUNIT_ASSERT_EQUAL(OUString("one"), aKeywords[0]); + CPPUNIT_ASSERT_EQUAL(OUString("two"), aKeywords[1]); + }; + createSwDoc("fdo49683.rtf"); + verify(); + saveAndReload(mpFilter); + verify(); } // TODO Use case not clear! -DECLARE_RTFEXPORT_TEST(testFdo44174, "fdo44174.rtf") +CPPUNIT_TEST_FIXTURE(Test, testFdo44174) { - uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY); - uno::Reference<text::XTextViewCursorSupplier> xTextViewCursorSupplier( - xModel->getCurrentController(), uno::UNO_QUERY); - uno::Reference<beans::XPropertySet> xPropertySet(xTextViewCursorSupplier->getViewCursor(), - uno::UNO_QUERY); - OUString aValue; - xPropertySet->getPropertyValue("PageStyleName") >>= aValue; - CPPUNIT_ASSERT_EQUAL(OUString("Standard"), aValue); + auto verify = [this]() { + uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY); + uno::Reference<text::XTextViewCursorSupplier> xTextViewCursorSupplier( + xModel->getCurrentController(), uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> xPropertySet(xTextViewCursorSupplier->getViewCursor(), + uno::UNO_QUERY); + OUString aValue; + xPropertySet->getPropertyValue("PageStyleName") >>= aValue; + CPPUNIT_ASSERT_EQUAL(OUString("Standard"), aValue); + }; + createSwDoc("fdo44174.rtf"); + verify(); + saveAndReload(mpFilter); + verify(); } -DECLARE_RTFEXPORT_TEST(testFdo50087, "fdo50087.rtf") +CPPUNIT_TEST_FIXTURE(Test, testFdo50087) { - uno::Reference<document::XDocumentPropertiesSupplier> xDocumentPropertiesSupplier( - mxComponent, uno::UNO_QUERY); - uno::Reference<document::XDocumentProperties> xDocumentProperties( - xDocumentPropertiesSupplier->getDocumentProperties()); - CPPUNIT_ASSERT_EQUAL(OUString("Title"), xDocumentProperties->getTitle()); - CPPUNIT_ASSERT_EQUAL(OUString("Subject"), xDocumentProperties->getSubject()); - CPPUNIT_ASSERT_EQUAL(OUString("First line. Second line."), - xDocumentProperties->getDescription()); + auto verify = [this]() { + uno::Reference<document::XDocumentPropertiesSupplier> xDocumentPropertiesSupplier( + mxComponent, uno::UNO_QUERY); + uno::Reference<document::XDocumentProperties> xDocumentProperties( + xDocumentPropertiesSupplier->getDocumentProperties()); + CPPUNIT_ASSERT_EQUAL(OUString("Title"), xDocumentProperties->getTitle()); + CPPUNIT_ASSERT_EQUAL(OUString("Subject"), xDocumentProperties->getSubject()); + CPPUNIT_ASSERT_EQUAL(OUString("First line. Second line."), + xDocumentProperties->getDescription()); + }; + createSwDoc("fdo50087.rtf"); + verify(); + saveAndReload(mpFilter); + verify(); } -DECLARE_RTFEXPORT_TEST(testFdo50831, "fdo50831.rtf") +CPPUNIT_TEST_FIXTURE(Test, testFdo50831) { - uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY); - uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), - uno::UNO_QUERY); - uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration(); - uno::Reference<beans::XPropertySet> xPropertySet(xParaEnum->nextElement(), uno::UNO_QUERY); - float fValue = 0; - xPropertySet->getPropertyValue("CharHeight") >>= fValue; - CPPUNIT_ASSERT_EQUAL(10.f, fValue); + auto verify = [this]() { + uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), + uno::UNO_QUERY); + uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration(); + uno::Reference<beans::XPropertySet> xPropertySet(xParaEnum->nextElement(), uno::UNO_QUERY); + float fValue = 0; + xPropertySet->getPropertyValue("CharHeight") >>= fValue; + CPPUNIT_ASSERT_EQUAL(10.f, fValue); + }; + createSwDoc("fdo50831.rtf"); + verify(); + saveAndReload(mpFilter); + verify(); } CPPUNIT_TEST_FIXTURE(Test, testFdo48335) @@ -141,33 +175,39 @@ CPPUNIT_TEST_FIXTURE(Test, testFdo48335) CPPUNIT_ASSERT_EQUAL(OUString("SoftPageBreak"), aValue); } -DECLARE_RTFEXPORT_TEST(testFdo38244, "fdo38244.rtf") +CPPUNIT_TEST_FIXTURE(Test, testFdo38244) { - // See ooxmlexport's testFdo38244(). - // Test comment range feature. - uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY); - uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), - uno::UNO_QUERY); - uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration(); - uno::Reference<container::XEnumerationAccess> xRunEnumAccess(xParaEnum->nextElement(), - uno::UNO_QUERY); - uno::Reference<container::XEnumeration> xRunEnum = xRunEnumAccess->createEnumeration(); - xRunEnum->nextElement(); - uno::Reference<beans::XPropertySet> xPropertySet(xRunEnum->nextElement(), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(OUString("Annotation"), - getProperty<OUString>(xPropertySet, "TextPortionType")); - xRunEnum->nextElement(); - xPropertySet.set(xRunEnum->nextElement(), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(OUString("AnnotationEnd"), - getProperty<OUString>(xPropertySet, "TextPortionType")); - - // Test initials. - uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY); - uno::Reference<container::XEnumerationAccess> xFieldsAccess( - xTextFieldsSupplier->getTextFields()); - uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration()); - xPropertySet.set(xFields->nextElement(), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(OUString("M"), getProperty<OUString>(xPropertySet, "Initials")); + auto verify = [this]() { + // See ooxmlexport's testFdo38244(). + // Test comment range feature. + uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), + uno::UNO_QUERY); + uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration(); + uno::Reference<container::XEnumerationAccess> xRunEnumAccess(xParaEnum->nextElement(), + uno::UNO_QUERY); + uno::Reference<container::XEnumeration> xRunEnum = xRunEnumAccess->createEnumeration(); + xRunEnum->nextElement(); + uno::Reference<beans::XPropertySet> xPropertySet(xRunEnum->nextElement(), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("Annotation"), + getProperty<OUString>(xPropertySet, "TextPortionType")); + xRunEnum->nextElement(); + xPropertySet.set(xRunEnum->nextElement(), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("AnnotationEnd"), + getProperty<OUString>(xPropertySet, "TextPortionType")); + + // Test initials. + uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XEnumerationAccess> xFieldsAccess( + xTextFieldsSupplier->getTextFields()); + uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration()); + xPropertySet.set(xFields->nextElement(), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("M"), getProperty<OUString>(xPropertySet, "Initials")); + }; + createSwDoc("fdo38244.rtf"); + verify(); + saveAndReload(mpFilter); + verify(); } CPPUNIT_TEST_FIXTURE(Test, testCommentsNested) @@ -183,14 +223,20 @@ CPPUNIT_TEST_FIXTURE(Test, testCommentsNested) CPPUNIT_ASSERT_EQUAL(OUString("Inner"), getProperty<OUString>(xInner, "Content").trim()); } -DECLARE_RTFEXPORT_TEST(testMathAccents, "math-accents.rtf") +CPPUNIT_TEST_FIXTURE(Test, testMathAccents) { - OUString aActual = getFormula(getRun(getParagraph(1), 1)); - CPPUNIT_ASSERT_EQUAL( - OUString("acute {a} grave {a} check {a} breve {a} circle {a} widevec {a} " - "widetilde {a} widehat {a} dot {a} widevec {a} widevec {a} widetilde " - "{a} underline {a}"), - aActual); + auto verify = [this]() { + OUString aActual = getFormula(getRun(getParagraph(1), 1)); + CPPUNIT_ASSERT_EQUAL( + OUString("acute {a} grave {a} check {a} breve {a} circle {a} widevec {a} " + "widetilde {a} widehat {a} dot {a} widevec {a} widevec {a} widetilde " + "{a} underline {a}"), + aActual); + }; + createSwDoc("math-accents.rtf"); + verify(); + saveAndReload(mpFilter); + verify(); } CPPUNIT_TEST_FIXTURE(Test, testMathEqarray) @@ -202,15 +248,21 @@ CPPUNIT_TEST_FIXTURE(Test, testMathEqarray) aActual); } -DECLARE_RTFEXPORT_TEST(testMathD, "math-d.rtf") +CPPUNIT_TEST_FIXTURE(Test, testMathD) { - OUString aActual = getFormula(getRun(getParagraph(1), 1)); - CPPUNIT_ASSERT_EQUAL( - OUString("left (x mline y mline z right ) left (1 right ) left [2 right ] left " - "ldbracket 3 right rdbracket left lline 4 right rline left ldline 5 " - "right rdline left langle 6 right rangle left langle a mline b right " - "rangle left ({x} over {y} right )"), - aActual); + auto verify = [this]() { + OUString aActual = getFormula(getRun(getParagraph(1), 1)); + CPPUNIT_ASSERT_EQUAL( + OUString("left (x mline y mline z right ) left (1 right ) left [2 right ] left " + "ldbracket 3 right rdbracket left lline 4 right rline left ldline 5 " + "right rdline left langle 6 right rangle left langle a mline b right " + "rangle left ({x} over {y} right )"), + aActual); + }; + createSwDoc("math-d.rtf"); + verify(); + saveAndReload(mpFilter); + verify(); } CPPUNIT_TEST_FIXTURE(Test, testMathEscaping) @@ -227,16 +279,28 @@ CPPUNIT_TEST_FIXTURE(Test, testMathLim) CPPUNIT_ASSERT_EQUAL(u"lim from {x \u2192 1} {x}"_ustr, aActual); } -DECLARE_RTFEXPORT_TEST(testMathMatrix, "math-matrix.rtf") +CPPUNIT_TEST_FIXTURE(Test, testMathMatrix) { - OUString aActual = getFormula(getRun(getParagraph(1), 1)); - CPPUNIT_ASSERT_EQUAL(OUString("left [matrix {1 # 2 ## 3 # 4} right ]"), aActual); + auto verify = [this]() { + OUString aActual = getFormula(getRun(getParagraph(1), 1)); + CPPUNIT_ASSERT_EQUAL(OUString("left [matrix {1 # 2 ## 3 # 4} right ]"), aActual); + }; + createSwDoc("math-matrix.rtf"); + verify(); + saveAndReload(mpFilter); + verify(); } -DECLARE_RTFEXPORT_TEST(testMathBox, "math-mbox.rtf") +CPPUNIT_TEST_FIXTURE(Test, testMathBox) { - OUString aActual = getFormula(getRun(getParagraph(1), 1)); - CPPUNIT_ASSERT_EQUAL(OUString("a"), aActual); + auto verify = [this]() { + OUString aActual = getFormula(getRun(getParagraph(1), 1)); + CPPUNIT_ASSERT_EQUAL(OUString("a"), aActual); + }; + createSwDoc("math-mbox.rtf"); + verify(); + saveAndReload(mpFilter); + verify(); } CPPUNIT_TEST_FIXTURE(Test, testMathMso2007) @@ -294,25 +358,43 @@ CPPUNIT_TEST_FIXTURE(Test, testMathNary) OUString("lllint from {1} to {2} {x + 1} prod from {a} {b} sum to {2} {x}"), aActual); } -DECLARE_RTFEXPORT_TEST(testMathLimupp, "math-limupp.rtf") +CPPUNIT_TEST_FIXTURE(Test, testMathLimupp) { - OUString aActual = getFormula(getRun(getParagraph(1), 1)); - CPPUNIT_ASSERT_EQUAL(OUString("{abcd} overbrace {4}"), aActual); - - aActual = getFormula(getRun(getParagraph(2), 1)); - CPPUNIT_ASSERT_EQUAL(OUString("{xyz} underbrace {3}"), aActual); + auto verify = [this]() { + OUString aActual = getFormula(getRun(getParagraph(1), 1)); + CPPUNIT_ASSERT_EQUAL(OUString("{abcd} overbrace {4}"), aActual); + + aActual = getFormula(getRun(getParagraph(2), 1)); + CPPUNIT_ASSERT_EQUAL(OUString("{xyz} underbrace {3}"), aActual); + }; + createSwDoc("math-limupp.rtf"); + verify(); + saveAndReload(mpFilter); + verify(); } -DECLARE_RTFEXPORT_TEST(testMathStrikeh, "math-strikeh.rtf") +CPPUNIT_TEST_FIXTURE(Test, testMathStrikeh) { - OUString aActual = getFormula(getRun(getParagraph(1), 1)); - CPPUNIT_ASSERT_EQUAL(OUString("overstrike {abc}"), aActual); + auto verify = [this]() { + OUString aActual = getFormula(getRun(getParagraph(1), 1)); + CPPUNIT_ASSERT_EQUAL(OUString("overstrike {abc}"), aActual); + }; + createSwDoc("math-strikeh.rtf"); + verify(); + saveAndReload(mpFilter); + verify(); } -DECLARE_RTFEXPORT_TEST(testMathPlaceholders, "math-placeholders.rtf") +CPPUNIT_TEST_FIXTURE(Test, testMathPlaceholders) { - OUString aActual = getFormula(getRun(getParagraph(1), 1)); - CPPUNIT_ASSERT_EQUAL(OUString("sum from <?> to <?> <?>"), aActual); + auto verify = [this]() { + OUString aActual = getFormula(getRun(getParagraph(1), 1)); + CPPUNIT_ASSERT_EQUAL(OUString("sum from <?> to <?> <?>"), aActual); + }; + createSwDoc("math-placeholders.rtf"); + verify(); + saveAndReload(mpFilter); + verify(); } CPPUNIT_TEST_FIXTURE(Test, testMathRad) @@ -322,20 +404,32 @@ CPPUNIT_TEST_FIXTURE(Test, testMathRad) CPPUNIT_ASSERT_EQUAL(OUString("sqrt {4} nroot {3} {x + 1}"), aActual); } -DECLARE_RTFEXPORT_TEST(testMathSepchr, "math-sepchr.rtf") +CPPUNIT_TEST_FIXTURE(Test, testMathSepchr) { - OUString aActual = getFormula(getRun(getParagraph(1), 1)); - CPPUNIT_ASSERT_EQUAL(OUString("AxByBzC"), aActual); + auto verify = [this]() { + OUString aActual = getFormula(getRun(getParagraph(1), 1)); + CPPUNIT_ASSERT_EQUAL(OUString("AxByBzC"), aActual); + }; + createSwDoc("math-sepchr.rtf"); + verify(); + saveAndReload(mpFilter); + verify(); } -DECLARE_RTFEXPORT_TEST(testMathSubscripts, "math-subscripts.rtf") +CPPUNIT_TEST_FIXTURE(Test, testMathSubscripts) { - OUString aActual = getFormula(getRun(getParagraph(1), 1)); - CPPUNIT_ASSERT_EQUAL( - OUString("{x} ^ {y} + {e} ^ {x} {x} ^ {b} {x} rsub {b} {a} rsub {c} rsup {b} " - "{x} lsub {2} lsup {1} {{x csup {6} csub {3}} lsub {4} lsup {5}} rsub " - "{2} rsup {1}"), - aActual); + auto verify = [this]() { + OUString aActual = getFormula(getRun(getParagraph(1), 1)); + CPPUNIT_ASSERT_EQUAL( + OUString("{x} ^ {y} + {e} ^ {x} {x} ^ {b} {x} rsub {b} {a} rsub {c} rsup {b} " + "{x} lsub {2} lsup {1} {{x csup {6} csub {3}} lsub {4} lsup {5}} rsub " + "{2} rsup {1}"), + aActual); + }; + createSwDoc("math-subscripts.rtf"); + verify(); + saveAndReload(mpFilter); + verify(); } CPPUNIT_TEST_FIXTURE(Test, testMathVerticalstacks) @@ -348,28 +442,34 @@ CPPUNIT_TEST_FIXTURE(Test, testMathVerticalstacks) getFormula(getRun(getParagraph(4), 1))); } -DECLARE_RTFEXPORT_TEST(testTdf49073, "tdf49073.rtf") -{ - // test case for Asian phontic guide (ruby text.) - sal_Unicode aRuby[3] = { 0x304D, 0x3082, 0x3093 }; - OUString sRuby(aRuby, SAL_N_ELEMENTS(aRuby)); - CPPUNIT_ASSERT_EQUAL(sRuby, getProperty<OUString>(getParagraph(1)->getStart(), "RubyText")); - OUString sStyle = getProperty<OUString>(getParagraph(1)->getStart(), "RubyCharStyleName"); - uno::Reference<beans::XPropertySet> xPropertySet( - getStyles("CharacterStyles")->getByName(sStyle), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(5.f, getProperty<float>(xPropertySet, "CharHeight")); - CPPUNIT_ASSERT_EQUAL(sal_Int16(text::RubyAdjust_CENTER), - getProperty<sal_Int16>(getParagraph(2)->getStart(), "RubyAdjust")); - CPPUNIT_ASSERT_EQUAL(sal_Int16(text::RubyAdjust_BLOCK), - getProperty<sal_Int16>(getParagraph(3)->getStart(), "RubyAdjust")); - CPPUNIT_ASSERT_EQUAL(sal_Int16(text::RubyAdjust_INDENT_BLOCK), - getProperty<sal_Int16>(getParagraph(4)->getStart(), "RubyAdjust")); - CPPUNIT_ASSERT_EQUAL(sal_Int16(text::RubyAdjust_LEFT), - getProperty<sal_Int16>(getParagraph(5)->getStart(), "RubyAdjust")); - CPPUNIT_ASSERT_EQUAL(sal_Int16(text::RubyAdjust_RIGHT), - getProperty<sal_Int16>(getParagraph(6)->getStart(), "RubyAdjust")); - CPPUNIT_ASSERT_EQUAL(sal_Int16(text::RubyPosition::INTER_CHARACTER), - getProperty<sal_Int16>(getParagraph(7)->getStart(), "RubyPosition")); +CPPUNIT_TEST_FIXTURE(Test, testTdf49073) +{ + auto verify = [this]() { + // test case for Asian phontic guide (ruby text.) + sal_Unicode aRuby[3] = { 0x304D, 0x3082, 0x3093 }; + OUString sRuby(aRuby, SAL_N_ELEMENTS(aRuby)); + CPPUNIT_ASSERT_EQUAL(sRuby, getProperty<OUString>(getParagraph(1)->getStart(), "RubyText")); + OUString sStyle = getProperty<OUString>(getParagraph(1)->getStart(), "RubyCharStyleName"); + uno::Reference<beans::XPropertySet> xPropertySet( + getStyles("CharacterStyles")->getByName(sStyle), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(5.f, getProperty<float>(xPropertySet, "CharHeight")); + CPPUNIT_ASSERT_EQUAL(sal_Int16(text::RubyAdjust_CENTER), + getProperty<sal_Int16>(getParagraph(2)->getStart(), "RubyAdjust")); + CPPUNIT_ASSERT_EQUAL(sal_Int16(text::RubyAdjust_BLOCK), + getProperty<sal_Int16>(getParagraph(3)->getStart(), "RubyAdjust")); + CPPUNIT_ASSERT_EQUAL(sal_Int16(text::RubyAdjust_INDENT_BLOCK), + getProperty<sal_Int16>(getParagraph(4)->getStart(), "RubyAdjust")); + CPPUNIT_ASSERT_EQUAL(sal_Int16(text::RubyAdjust_LEFT), + getProperty<sal_Int16>(getParagraph(5)->getStart(), "RubyAdjust")); + CPPUNIT_ASSERT_EQUAL(sal_Int16(text::RubyAdjust_RIGHT), + getProperty<sal_Int16>(getParagraph(6)->getStart(), "RubyAdjust")); + CPPUNIT_ASSERT_EQUAL(sal_Int16(text::RubyPosition::INTER_CHARACTER), + getProperty<sal_Int16>(getParagraph(7)->getStart(), "RubyPosition")); + }; + createSwDoc("tdf49073.rtf"); + verify(); + saveAndReload(mpFilter); + verify(); } CPPUNIT_TEST_FIXTURE(Test, testMathRuns) @@ -482,32 +582,45 @@ CPPUNIT_TEST_FIXTURE(Test, testFdo52286) sal_Int32(58), getProperty<sal_Int32>(getRun(getParagraph(2), 2), "CharEscapementHeight")); } -DECLARE_RTFEXPORT_TEST(testFdo61507, "fdo61507.rtf") +CPPUNIT_TEST_FIXTURE(Test, testFdo61507) { - /* - * Unicode-only characters in itle confused Wordpad. Once the exporter - * was fixed to guard the problematic characters with \upr and \ud, the - * importer didn't cope with these new keywords. - */ - - uno::Reference<document::XDocumentPropertiesSupplier> xDocumentPropertiesSupplier( - mxComponent, uno::UNO_QUERY); - uno::Reference<document::XDocumentProperties> xDocumentProperties( - xDocumentPropertiesSupplier->getDocumentProperties()); - CPPUNIT_ASSERT_EQUAL(u"\u00C9\u00C1\u0150\u0170\u222D"_ustr, xDocumentProperties->getTitle()); - - // Only "Hello.", no additional characters. - CPPUNIT_ASSERT_EQUAL(OUString("Hello."), getBodyText()); + auto verify = [this]() { + /* + * Unicode-only characters in itle confused Wordpad. Once the exporter + * was fixed to guard the problematic characters with \upr and \ud, the + * importer didn't cope with these new keywords. + */ + + uno::Reference<document::XDocumentPropertiesSupplier> xDocumentPropertiesSupplier( + mxComponent, uno::UNO_QUERY); + uno::Reference<document::XDocumentProperties> xDocumentProperties( + xDocumentPropertiesSupplier->getDocumentProperties()); + CPPUNIT_ASSERT_EQUAL(u"\u00C9\u00C1\u0150\u0170\u222D"_ustr, + xDocumentProperties->getTitle()); + + // Only "Hello.", no additional characters. + CPPUNIT_ASSERT_EQUAL(OUString("Hello."), getBodyText()); + }; + createSwDoc("fdo61507.rtf"); + verify(); + saveAndReload(mpFilter); + verify(); } -DECLARE_RTFEXPORT_TEST(testFdo30983, "fdo30983.rtf") +CPPUNIT_TEST_FIXTURE(Test, testFdo30983) { - // These were 'page text area', not 'entire page', i.e. both the horizontal - // and vertical positions were incorrect. - CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME, - getProperty<sal_Int16>(getShape(1), "HoriOrientRelation")); - CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME, - getProperty<sal_Int16>(getShape(1), "VertOrientRelation")); + auto verify = [this]() { + // These were 'page text area', not 'entire page', i.e. both the horizontal + // and vertical positions were incorrect. + CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME, + getProperty<sal_Int16>(getShape(1), "HoriOrientRelation")); + CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME, + getProperty<sal_Int16>(getShape(1), "VertOrientRelation")); + }; + createSwDoc("fdo30983.rtf"); + verify(); + saveAndReload(mpFilter); + verify(); } CPPUNIT_TEST_FIXTURE(Test, testPlaceholder) @@ -522,130 +635,181 @@ CPPUNIT_TEST_FIXTURE(Test, testPlaceholder) CPPUNIT_ASSERT_EQUAL(OUString("place holder"), getProperty<OUString>(xField, "Hint")); } -DECLARE_RTFEXPORT_TEST(testMnor, "mnor.rtf") +CPPUNIT_TEST_FIXTURE(Test, testMnor) { - // \mnor wasn't handled, leading to missing quotes around "divF" and so on. - OUString aActual = getFormula(getRun(getParagraph(1), 1)); - CPPUNIT_ASSERT_EQUAL( - u"iiint from {V} to <?> {\"divF\"} dV = llint from {S} to <?> {\"F\" \u2219 \"n\" dS}"_ustr, - aActual); + auto verify = [this]() { + // \mnor wasn't handled, leading to missing quotes around "divF" and so on. + OUString aActual = getFormula(getRun(getParagraph(1), 1)); + CPPUNIT_ASSERT_EQUAL( + u"iiint from {V} to <?> {\"divF\"} dV = llint from {S} to <?> {\"F\" \u2219 \"n\" dS}"_ustr, + aActual); + }; + createSwDoc("mnor.rtf"); + verify(); + saveAndReload(mpFilter); + verify(); } -DECLARE_RTFEXPORT_TEST(testI120928, "i120928.rtf") +CPPUNIT_TEST_FIXTURE(Test, testI120928) { - // \listpicture and \levelpicture0 was ignored, leading to missing graphic bullet in numbering. - uno::Reference<beans::XPropertySet> xPropertySet( - getStyles("NumberingStyles")->getByName("WWNum1"), uno::UNO_QUERY); - uno::Reference<container::XIndexAccess> xLevels( - xPropertySet->getPropertyValue("NumberingRules"), uno::UNO_QUERY); - uno::Sequence<beans::PropertyValue> aProps; - xLevels->getByIndex(0) >>= aProps; // 1st level - - uno::Reference<awt::XBitmap> xBitmap; - sal_Int16 nNumberingType = -1; - - for (beans::PropertyValue const& rProp : aProps) - { - if (rProp.Name == "NumberingType") - nNumberingType = rProp.Value.get<sal_Int16>(); - else if (rProp.Name == "GraphicBitmap") - xBitmap = rProp.Value.get<uno::Reference<awt::XBitmap>>(); - } - CPPUNIT_ASSERT_EQUAL(style::NumberingType::BITMAP, nNumberingType); - CPPUNIT_ASSERT(xBitmap.is()); + auto verify = [this]() { + // \listpicture and \levelpicture0 was ignored, leading to missing graphic bullet in numbering. + uno::Reference<beans::XPropertySet> xPropertySet( + getStyles("NumberingStyles")->getByName("WWNum1"), uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> xLevels( + xPropertySet->getPropertyValue("NumberingRules"), uno::UNO_QUERY); + uno::Sequence<beans::PropertyValue> aProps; + xLevels->getByIndex(0) >>= aProps; // 1st level + + uno::Reference<awt::XBitmap> xBitmap; + sal_Int16 nNumberingType = -1; + + for (beans::PropertyValue const& rProp : aProps) + { + if (rProp.Name == "NumberingType") + nNumberingType = rProp.Value.get<sal_Int16>(); + else if (rProp.Name == "GraphicBitmap") + xBitmap = rProp.Value.get<uno::Reference<awt::XBitmap>>(); + } + CPPUNIT_ASSERT_EQUAL(style::NumberingType::BITMAP, nNumberingType); + CPPUNIT_ASSERT(xBitmap.is()); + }; + createSwDoc("i120928.rtf"); + verify(); + saveAndReload(mpFilter); + verify(); } -DECLARE_RTFEXPORT_TEST(testBookmark, "bookmark.rtf") +CPPUNIT_TEST_FIXTURE(Test, testBookmark) { - uno::Reference<text::XBookmarksSupplier> xBookmarksSupplier(mxComponent, uno::UNO_QUERY); - uno::Reference<text::XTextContent> xBookmark( - xBookmarksSupplier->getBookmarks()->getByName("firstword"), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(OUString("Hello"), xBookmark->getAnchor()->getString()); + auto verify = [this]() { + uno::Reference<text::XBookmarksSupplier> xBookmarksSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<text::XTextContent> xBookmark( + xBookmarksSupplier->getBookmarks()->getByName("firstword"), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("Hello"), xBookmark->getAnchor()->getString()); + }; + createSwDoc("bookmark.rtf"); + verify(); + saveAndReload(mpFilter); + verify(); } -DECLARE_RTFEXPORT_TEST(testHyperlink, "hyperlink.rtf") +CPPUNIT_TEST_FIXTURE(Test, testHyperlink) { - CPPUNIT_ASSERT_EQUAL( - OUString(), getProperty<OUString>(getRun(getParagraph(1), 1, "Hello"), "HyperLinkURL")); - CPPUNIT_ASSERT_EQUAL( - OUString("http://en.wikipedia.org/wiki/World"), - getProperty<OUString>(getRun(getParagraph(1), 2, "world"), "HyperLinkURL")); - CPPUNIT_ASSERT_EQUAL(OUString(), - getProperty<OUString>(getRun(getParagraph(1), 3, "!"), "HyperLinkURL")); + auto verify = [this]() { + CPPUNIT_ASSERT_EQUAL( + OUString(), getProperty<OUString>(getRun(getParagraph(1), 1, "Hello"), "HyperLinkURL")); + CPPUNIT_ASSERT_EQUAL( + OUString("http://en.wikipedia.org/wiki/World"), + getProperty<OUString>(getRun(getParagraph(1), 2, "world"), "HyperLinkURL")); + CPPUNIT_ASSERT_EQUAL( + OUString(), getProperty<OUString>(getRun(getParagraph(1), 3, "!"), "HyperLinkURL")); + }; + createSwDoc("hyperlink.rtf"); + verify(); + saveAndReload(mpFilter); + verify(); } -DECLARE_RTFEXPORT_TEST(testHyperlinkTdf100105, "hyperlink_empty.rtf") +CPPUNIT_TEST_FIXTURE(Test, testHyperlinkTdf100105) { - // export of empty link was invalid, group was closed before it was opened - uno::Reference<text::XTextDocument> xTextDoc(mxComponent, uno::UNO_QUERY); - uno::Reference<text::XTextCursor> xCursor(xTextDoc->getText()->createTextCursor()); - xCursor->gotoStart(false); - CPPUNIT_ASSERT_EQUAL(OUString("http://example.net"), - getProperty<OUString>(xCursor, "HyperLinkURL")); - // getRun doesn't provide a 0-length hyperlink - CPPUNIT_ASSERT_EQUAL( - OUString(), getProperty<OUString>(getRun(getParagraph(1), 1, "foobar"), "HyperLinkURL")); + auto verify = [this]() { + // export of empty link was invalid, group was closed before it was opened + uno::Reference<text::XTextDocument> xTextDoc(mxComponent, uno::UNO_QUERY); + uno::Reference<text::XTextCursor> xCursor(xTextDoc->getText()->createTextCursor()); + xCursor->gotoStart(false); + CPPUNIT_ASSERT_EQUAL(OUString("http://example.net"), + getProperty<OUString>(xCursor, "HyperLinkURL")); + // getRun doesn't provide a 0-length hyperlink + CPPUNIT_ASSERT_EQUAL(OUString(), getProperty<OUString>(getRun(getParagraph(1), 1, "foobar"), + "HyperLinkURL")); + }; + createSwDoc("hyperlink_empty.rtf"); + verify(); + saveAndReload(mpFilter); + verify(); } -DECLARE_RTFEXPORT_TEST(test78758, "fdo78758.rtf") +CPPUNIT_TEST_FIXTURE(Test, test78758) { - CPPUNIT_ASSERT_EQUAL( - OUString("#__RefHeading___Toc264438068"), - getProperty<OUString>(getRun(getParagraph(2), 1, "EE5E EeEEE5EE"), "HyperLinkURL")); - CPPUNIT_ASSERT_EQUAL(OUString("#__RefHeading___Toc264438068"), - getProperty<OUString>(getRun(getParagraph(2), 2, "e"), "HyperLinkURL")); - CPPUNIT_ASSERT_EQUAL(OUString("#__RefHeading___Toc264438068"), - getProperty<OUString>(getRun(getParagraph(2), 3, " 46"), "HyperLinkURL")); + auto verify = [this]() { + CPPUNIT_ASSERT_EQUAL( + OUString("#__RefHeading___Toc264438068"), + getProperty<OUString>(getRun(getParagraph(2), 1, "EE5E EeEEE5EE"), "HyperLinkURL")); + CPPUNIT_ASSERT_EQUAL( + OUString("#__RefHeading___Toc264438068"), + getProperty<OUString>(getRun(getParagraph(2), 2, "e"), "HyperLinkURL")); + CPPUNIT_ASSERT_EQUAL( + OUString("#__RefHeading___Toc264438068"), + getProperty<OUString>(getRun(getParagraph(2), 3, " 46"), "HyperLinkURL")); + }; + createSwDoc("fdo78758.rtf"); + verify(); + saveAndReload(mpFilter); + verify(); } -DECLARE_RTFEXPORT_TEST(testTextFrameBorders, "textframe-borders.rtf") +CPPUNIT_TEST_FIXTURE(Test, testTextFrameBorders) { - uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY); - uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(), - uno::UNO_QUERY); - uno::Reference<beans::XPropertySet> xFrame(xIndexAccess->getByIndex(0), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(Color(0xD99594), getProperty<Color>(xFrame, "BackColor")); - - table::BorderLine2 aBorder = getProperty<table::BorderLine2>(xFrame, "TopBorder"); - CPPUNIT_ASSERT_EQUAL(Color(0xC0504D), Color(ColorTransparency, aBorder.Color)); - CPPUNIT_ASSERT_EQUAL(sal_uInt32(35), aBorder.LineWidth); - - table::ShadowFormat aShadowFormat = getProperty<table::ShadowFormat>(xFrame, "ShadowFormat"); - CPPUNIT_ASSERT_EQUAL(table::ShadowLocation_BOTTOM_RIGHT, aShadowFormat.Location); - CPPUNIT_ASSERT_EQUAL(sal_Int16(48), aShadowFormat.ShadowWidth); - CPPUNIT_ASSERT_EQUAL(Color(0x622423), Color(ColorTransparency, aShadowFormat.Color)); + auto verify = [this]() { + uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(), + uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> xFrame(xIndexAccess->getByIndex(0), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(Color(0xD99594), getProperty<Color>(xFrame, "BackColor")); + + table::BorderLine2 aBorder = getProperty<table::BorderLine2>(xFrame, "TopBorder"); + CPPUNIT_ASSERT_EQUAL(Color(0xC0504D), Color(ColorTransparency, aBorder.Color)); + CPPUNIT_ASSERT_EQUAL(sal_uInt32(35), aBorder.LineWidth); + + table::ShadowFormat aShadowFormat + = getProperty<table::ShadowFormat>(xFrame, "ShadowFormat"); + CPPUNIT_ASSERT_EQUAL(table::ShadowLocation_BOTTOM_RIGHT, aShadowFormat.Location); + CPPUNIT_ASSERT_EQUAL(sal_Int16(48), aShadowFormat.ShadowWidth); + CPPUNIT_ASSERT_EQUAL(Color(0x622423), Color(ColorTransparency, aShadowFormat.Color)); + }; + createSwDoc("textframe-borders.rtf"); + verify(); + saveAndReload(mpFilter); + verify(); } -DECLARE_RTFEXPORT_TEST(testTextframeGradient, "textframe-gradient.rtf") +CPPUNIT_TEST_FIXTURE(Test, testTextframeGradient) { - uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY); - uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(), - uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xIndexAccess->getCount()); - - uno::Reference<beans::XPropertySet> xFrame(xIndexAccess->getByIndex(0), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT, - getProperty<drawing::FillStyle>(xFrame, "FillStyle")); - awt::Gradient2 aGradient = getProperty<awt::Gradient2>(xFrame, "FillGradient"); - - // prepare compare colors - const Color aColA(0xd99594); - const Color aColB(0xc0504d); - const Color aColC(0x666666); - const Color aColD(COL_BLACK); - - CPPUNIT_ASSERT_EQUAL(awt::GradientStyle_AXIAL, aGradient.Style); - CPPUNIT_ASSERT_EQUAL(aColB, Color(ColorTransparency, aGradient.StartColor)); - CPPUNIT_ASSERT_EQUAL(aColA, Color(ColorTransparency, aGradient.EndColor)); - - xFrame.set(xIndexAccess->getByIndex(1), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT, - getProperty<drawing::FillStyle>(xFrame, "FillStyle")); - aGradient = getProperty<awt::Gradient2>(xFrame, "FillGradient"); - - CPPUNIT_ASSERT_EQUAL(awt::GradientStyle_AXIAL, aGradient.Style); - CPPUNIT_ASSERT_EQUAL(aColD, Color(ColorTransparency, aGradient.StartColor)); - CPPUNIT_ASSERT_EQUAL(aColC, Color(ColorTransparency, aGradient.EndColor)); + auto verify = [this]() { + uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(), + uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xIndexAccess->getCount()); + + uno::Reference<beans::XPropertySet> xFrame(xIndexAccess->getByIndex(0), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT, + getProperty<drawing::FillStyle>(xFrame, "FillStyle")); + awt::Gradient2 aGradient = getProperty<awt::Gradient2>(xFrame, "FillGradient"); + + // prepare compare colors + const Color aColA(0xd99594); + const Color aColB(0xc0504d); + const Color aColC(0x666666); + const Color aColD(COL_BLACK); + + CPPUNIT_ASSERT_EQUAL(awt::GradientStyle_AXIAL, aGradient.Style); + CPPUNIT_ASSERT_EQUAL(aColB, Color(ColorTransparency, aGradient.StartColor)); + CPPUNIT_ASSERT_EQUAL(aColA, Color(ColorTransparency, aGradient.EndColor)); + + xFrame.set(xIndexAccess->getByIndex(1), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT, + getProperty<drawing::FillStyle>(xFrame, "FillStyle")); + aGradient = getProperty<awt::Gradient2>(xFrame, "FillGradient"); + + CPPUNIT_ASSERT_EQUAL(awt::GradientStyle_AXIAL, aGradient.Style); + CPPUNIT_ASSERT_EQUAL(aColD, Color(ColorTransparency, aGradient.StartColor)); + CPPUNIT_ASSERT_EQUAL(aColC, Color(ColorTransparency, aGradient.EndColor)); + }; + createSwDoc("textframe-gradient.rtf"); + verify(); + saveAndReload(mpFilter); + verify(); } CPPUNIT_TEST_FIXTURE(Test, testTdf159824_axialGradient) @@ -667,54 +831,78 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf159824_axialGradient) CPPUNIT_ASSERT_EQUAL(COL_WHITE, Color(ColorTransparency, aGradient.EndColor)); } -DECLARE_RTFEXPORT_TEST(testRecordChanges, "record-changes.rtf") +CPPUNIT_TEST_FIXTURE(Test, testRecordChanges) { - // evisions wasn't imported/exported. - CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(mxComponent, "RecordChanges")); + auto verify = [this]() { + // evisions wasn't imported/exported. + CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(mxComponent, "RecordChanges")); + }; + createSwDoc("record-changes.rtf"); + verify(); + saveAndReload(mpFilter); + verify(); } -DECLARE_RTFEXPORT_TEST(testTextframeTable, "textframe-table.rtf") +CPPUNIT_TEST_FIXTURE(Test, testTextframeTable) { - uno::Reference<text::XTextRange> xTextRange(getShape(1), uno::UNO_QUERY); - uno::Reference<text::XText> xText = xTextRange->getText(); - CPPUNIT_ASSERT_EQUAL(OUString("First para."), getParagraphOfText(1, xText)->getString()); - uno::Reference<text::XTextTable> xTable(getParagraphOrTable(2, xText), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(OUString("A"), uno::Reference<text::XTextRange>( - xTable->getCellByName("A1"), uno::UNO_QUERY_THROW) - ->getString()); - CPPUNIT_ASSERT_EQUAL(OUString("B"), uno::Reference<text::XTextRange>( - xTable->getCellByName("B1"), uno::UNO_QUERY_THROW) - ->getString()); - CPPUNIT_ASSERT_EQUAL(OUString("Last para."), getParagraphOfText(3, xText)->getString()); + auto verify = [this]() { + uno::Reference<text::XTextRange> xTextRange(getShape(1), uno::UNO_QUERY); + uno::Reference<text::XText> xText = xTextRange->getText(); + CPPUNIT_ASSERT_EQUAL(OUString("First para."), getParagraphOfText(1, xText)->getString()); + uno::Reference<text::XTextTable> xTable(getParagraphOrTable(2, xText), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("A"), uno::Reference<text::XTextRange>( + xTable->getCellByName("A1"), uno::UNO_QUERY_THROW) + ->getString()); + CPPUNIT_ASSERT_EQUAL(OUString("B"), uno::Reference<text::XTextRange>( + xTable->getCellByName("B1"), uno::UNO_QUERY_THROW) + ->getString()); + CPPUNIT_ASSERT_EQUAL(OUString("Last para."), getParagraphOfText(3, xText)->getString()); + }; + createSwDoc("textframe-table.rtf"); + verify(); + saveAndReload(mpFilter); + verify(); } -DECLARE_RTFEXPORT_TEST(testFdo66682, "fdo66682.rtf") +CPPUNIT_TEST_FIXTURE(Test, testFdo66682) { - uno::Reference<beans::XPropertySet> xPropertySet( - getStyles("NumberingStyles")->getByName("WWNum1"), uno::UNO_QUERY); - uno::Reference<container::XIndexAccess> xLevels( - xPropertySet->getPropertyValue("NumberingRules"), uno::UNO_QUERY); - uno::Sequence<beans::PropertyValue> aProps; - xLevels->getByIndex(0) >>= aProps; // 1st level - - OUString aListFormat; - for (beans::PropertyValue const& rProp : aProps) - { - if (rProp.Name == "ListFormat") - aListFormat = rProp.Value.get<OUString>(); - } - // Suffix was ' - CPPUNIT_ASSERT_EQUAL(OUString(" %1% "), aListFormat); + auto verify = [this]() { + uno::Reference<beans::XPropertySet> xPropertySet( + getStyles("NumberingStyles")->getByName("WWNum1"), uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> xLevels( + xPropertySet->getPropertyValue("NumberingRules"), uno::UNO_QUERY); + uno::Sequence<beans::PropertyValue> aProps; + xLevels->getByIndex(0) >>= aProps; // 1st level + + OUString aListFormat; + for (beans::PropertyValue const& rProp : aProps) + { + if (rProp.Name == "ListFormat") + aListFormat = rProp.Value.get<OUString>(); + } + // Suffix was ' + CPPUNIT_ASSERT_EQUAL(OUString(" %1% "), aListFormat); + }; + createSwDoc("fdo66682.rtf"); + verify(); + saveAndReload(mpFilter); + verify(); } -DECLARE_RTFEXPORT_TEST(testParaShadow, "para-shadow.rtf") +CPPUNIT_TEST_FIXTURE(Test, testParaShadow) { - // The problem was that rdrsh was ignored. - table::ShadowFormat aShadow - = getProperty<table::ShadowFormat>(getParagraph(2), "ParaShadowFormat"); - CPPUNIT_ASSERT_EQUAL(COL_BLACK, Color(ColorTransparency, aShadow.Color)); - CPPUNIT_ASSERT_EQUAL(table::ShadowLocation_BOTTOM_RIGHT, aShadow.Location); - CPPUNIT_ASSERT_EQUAL(sal_Int16(convertTwipToMm100(60)), aShadow.ShadowWidth); + auto verify = [this]() { + // The problem was that rdrsh was ignored. + table::ShadowFormat aShadow + = getProperty<table::ShadowFormat>(getParagraph(2), "ParaShadowFormat"); + CPPUNIT_ASSERT_EQUAL(COL_BLACK, Color(ColorTransparency, aShadow.Color)); + CPPUNIT_ASSERT_EQUAL(table::ShadowLocation_BOTTOM_RIGHT, aShadow.Location); + CPPUNIT_ASSERT_EQUAL(sal_Int16(convertTwipToMm100(60)), aShadow.ShadowWidth); + }; + createSwDoc("para-shadow.rtf"); + verify(); + saveAndReload(mpFilter); + verify(); } CPPUNIT_TEST_FIXTURE(Test, testCharacterBorder) @@ -762,29 +950,47 @@ CPPUNIT_TEST_FIXTURE(Test, testCharacterBorder) } } -DECLARE_RTFEXPORT_TEST(testFdo66743, "fdo66743.rtf") +CPPUNIT_TEST_FIXTURE(Test, testFdo66743) { - uno::Reference<text::XTextTable> xTable(getParagraphOrTable(1), uno::UNO_QUERY); - uno::Reference<table::XCell> xCell = xTable->getCellByName("A1"); - // This was too dark, 0x7f7f7f. - CPPUNIT_ASSERT_EQUAL(Color(0xd8d8d8), getProperty<Color>(xCell, "BackColor")); + auto verify = [this]() { + uno::Reference<text::XTextTable> xTable(getParagraphOrTable(1), uno::UNO_QUERY); + uno::Reference<table::XCell> xCell = xTable->getCellByName("A1"); + // This was too dark, 0x7f7f7f. + CPPUNIT_ASSERT_EQUAL(Color(0xd8d8d8), getProperty<Color>(xCell, "BackColor")); + }; + createSwDoc("fdo66743.rtf"); + verify(); + saveAndReload(mpFilter); + verify(); } -DECLARE_RTFEXPORT_TEST(testFdo68787, "fdo68787.rtf") +CPPUNIT_TEST_FIXTURE(Test, testFdo68787) { - uno::Reference<beans::XPropertySet> xPageStyle(getStyles("PageStyles")->getByName("Standard"), - uno::UNO_QUERY); - // This was 0, the 'lack of - CPPUNIT_ASSERT_EQUAL(sal_Int32(25), - getProperty<sal_Int32>(xPageStyle, "FootnoteLineRelativeWidth")); + auto verify = [this]() { + uno::Reference<beans::XPropertySet> xPageStyle( + getStyles("PageStyles")->getByName("Standard"), uno::UNO_QUERY); + // This was 0, the 'lack of + CPPUNIT_ASSERT_EQUAL(sal_Int32(25), + getProperty<sal_Int32>(xPageStyle, "FootnoteLineRelativeWidth")); + }; + createSwDoc("fdo68787.rtf"); + verify(); + saveAndReload(mpFilter); + verify(); } -DECLARE_RTFEXPORT_TEST(testFdo74709, "fdo74709.rtf") +CPPUNIT_TEST_FIXTURE(Test, testFdo74709) { - uno::Reference<table::XCell> xCell = getCell(getParagraphOrTable(1), "B1"); - // This was 0, as top/bottom/left/right padding wasn't imported. - CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(360)), - getProperty<sal_Int32>(xCell, "RightBorderDistance")); + auto verify = [this]() { + uno::Reference<table::XCell> xCell = getCell(getParagraphOrTable(1), "B1"); + // This was 0, as top/bottom/left/right padding wasn't imported. + CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(360)), + getProperty<sal_Int32>(xCell, "RightBorderDistance")); + }; + createSwDoc("fdo74709.rtf"); + verify(); + saveAndReload(mpFilter); + verify(); } CPPUNIT_TEST_FIXTURE(Test, testTdf84832) @@ -796,38 +1002,62 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf84832) getProperty<sal_Int32>(xCell, "LeftBorderDistance")); } -DECLARE_RTFEXPORT_TEST(testRelsize, "relsize.rtf") +CPPUNIT_TEST_FIXTURE(Test, testRelsize) { - uno::Reference<drawing::XShape> xShape = getShape(1); - CPPUNIT_ASSERT_EQUAL(sal_Int16(40), getProperty<sal_Int16>(xShape, "RelativeWidth")); - CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME, - getProperty<sal_Int16>(xShape, "RelativeWidthRelation")); - CPPUNIT_ASSERT_EQUAL(sal_Int16(20), getProperty<sal_Int16>(xShape, "RelativeHeight")); - CPPUNIT_ASSERT_EQUAL(text::RelOrientation::FRAME, - getProperty<sal_Int16>(xShape, "RelativeHeightRelation")); + auto verify = [this]() { + uno::Reference<drawing::XShape> xShape = getShape(1); + CPPUNIT_ASSERT_EQUAL(sal_Int16(40), getProperty<sal_Int16>(xShape, "RelativeWidth")); + CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME, + getProperty<sal_Int16>(xShape, "RelativeWidthRelation")); + CPPUNIT_ASSERT_EQUAL(sal_Int16(20), getProperty<sal_Int16>(xShape, "RelativeHeight")); + CPPUNIT_ASSERT_EQUAL(text::RelOrientation::FRAME, + getProperty<sal_Int16>(xShape, "RelativeHeightRelation")); + }; + createSwDoc("relsize.rtf"); + verify(); + saveAndReload(mpFilter); + verify(); } -DECLARE_RTFEXPORT_TEST(testLineNumbering, "linenumbering.rtf") +CPPUNIT_TEST_FIXTURE(Test, testLineNumbering) { - uno::Reference<text::XLineNumberingProperties> xLineNumberingProperties(mxComponent, - uno::UNO_QUERY_THROW); - uno::Reference<beans::XPropertySet> xPropertySet - = xLineNumberingProperties->getLineNumberingProperties(); - CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(xPropertySet, "IsOn")); - CPPUNIT_ASSERT_EQUAL(sal_Int32(5), getProperty<sal_Int32>(xPropertySet, "Interval")); + auto verify = [this]() { + uno::Reference<text::XLineNumberingProperties> xLineNumberingProperties( + mxComponent, uno::UNO_QUERY_THROW); + uno::Reference<beans::XPropertySet> xPropertySet + = xLineNumberingProperties->getLineNumberingProperties(); + CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(xPropertySet, "IsOn")); + CPPUNIT_ASSERT_EQUAL(sal_Int32(5), getProperty<sal_Int32>(xPropertySet, "Interval")); + }; + createSwDoc("linenumbering.rtf"); + verify(); + saveAndReload(mpFilter); + verify(); } -DECLARE_RTFEXPORT_TEST(testFdo77600, "fdo77600.rtf") +CPPUNIT_TEST_FIXTURE(Test, testFdo77600) { - // This was 'Liberation Serif'. - CPPUNIT_ASSERT_EQUAL(OUString("Arial"), - getProperty<OUString>(getRun(getParagraph(1), 3), "CharFontName")); + auto verify = [this]() { + // This was 'Liberation Serif'. + CPPUNIT_ASSERT_EQUAL(OUString("Arial"), + getProperty<OUString>(getRun(getParagraph(1), 3), "CharFontName")); + }; + createSwDoc("fdo77600.rtf"); + verify(); + saveAndReload(mpFilter); + verify(); } -DECLARE_RTFEXPORT_TEST(testFdo80167, "fdo80167.rtf") +CPPUNIT_TEST_FIXTURE(Test, testFdo80167) { - // Problem was that after export, the page break was missing, so this was 1. - CPPUNIT_ASSERT_EQUAL(2, getPages()); + auto verify = [this]() { + // Problem was that after export, the page break was missing, so this was 1. + CPPUNIT_ASSERT_EQUAL(2, getPages()); + }; + createSwDoc("fdo80167.rtf"); + verify(); + saveAndReload(mpFilter); + verify(); } CPPUNIT_TEST_FIXTURE(Test, testFdo32613)