From 88ef23726498b65b33d80a2e4cf71b00205f80bd Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Wed, 24 Apr 2024 08:27:19 +0200 Subject: CppunitTest_sw_rtfexport4: avoid DECLARE_RTFEXPORT_TEST No need to go via Writer-specific macros here. Change-Id: I680ce101de71dab06616658d7abcb4997c4c9bfa Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166575 Reviewed-by: Miklos Vajna Tested-by: Jenkins --- sw/qa/extras/rtfexport/rtfexport4.cxx | 1404 +++++++++++++++++++-------------- 1 file changed, 816 insertions(+), 588 deletions(-) (limited to 'sw') diff --git a/sw/qa/extras/rtfexport/rtfexport4.cxx b/sw/qa/extras/rtfexport/rtfexport4.cxx index 25f5394b6ae5..d55bb4279252 100644 --- a/sw/qa/extras/rtfexport/rtfexport4.cxx +++ b/sw/qa/extras/rtfexport/rtfexport4.cxx @@ -46,294 +46,403 @@ public: } }; -DECLARE_RTFEXPORT_TEST(testCjklist12, "cjklist12.rtf") +CPPUNIT_TEST_FIXTURE(Test, testCjklist12) { - sal_Int16 numFormat = getNumberingTypeOfParagraph(1); - CPPUNIT_ASSERT_EQUAL(style::NumberingType::AIU_HALFWIDTH_JA, numFormat); + auto verify = [this]() { + sal_Int16 numFormat = getNumberingTypeOfParagraph(1); + CPPUNIT_ASSERT_EQUAL(style::NumberingType::AIU_HALFWIDTH_JA, numFormat); + }; + createSwDoc("cjklist12.rtf"); + verify(); + saveAndReload(mpFilter); + verify(); } -DECLARE_RTFEXPORT_TEST(testCjklist13, "cjklist13.rtf") +CPPUNIT_TEST_FIXTURE(Test, testCjklist13) { - sal_Int16 numFormat = getNumberingTypeOfParagraph(1); - CPPUNIT_ASSERT_EQUAL(style::NumberingType::IROHA_HALFWIDTH_JA, numFormat); + auto verify = [this]() { + sal_Int16 numFormat = getNumberingTypeOfParagraph(1); + CPPUNIT_ASSERT_EQUAL(style::NumberingType::IROHA_HALFWIDTH_JA, numFormat); + }; + createSwDoc("cjklist13.rtf"); + verify(); + saveAndReload(mpFilter); + verify(); } -DECLARE_RTFEXPORT_TEST(testCjklist16, "cjklist16.rtf") +CPPUNIT_TEST_FIXTURE(Test, testCjklist16) { - sal_Int16 numFormat = getNumberingTypeOfParagraph(1); - CPPUNIT_ASSERT_EQUAL(style::NumberingType::NUMBER_TRADITIONAL_JA, numFormat); + auto verify = [this]() { + sal_Int16 numFormat = getNumberingTypeOfParagraph(1); + CPPUNIT_ASSERT_EQUAL(style::NumberingType::NUMBER_TRADITIONAL_JA, numFormat); + }; + createSwDoc("cjklist16.rtf"); + verify(); + saveAndReload(mpFilter); + verify(); } -DECLARE_RTFEXPORT_TEST(testCjklist20, "cjklist20.rtf") +CPPUNIT_TEST_FIXTURE(Test, testCjklist20) { - sal_Int16 numFormat = getNumberingTypeOfParagraph(1); - CPPUNIT_ASSERT_EQUAL(style::NumberingType::AIU_FULLWIDTH_JA, numFormat); + auto verify = [this]() { + sal_Int16 numFormat = getNumberingTypeOfParagraph(1); + CPPUNIT_ASSERT_EQUAL(style::NumberingType::AIU_FULLWIDTH_JA, numFormat); + }; + createSwDoc("cjklist20.rtf"); + verify(); + saveAndReload(mpFilter); + verify(); } -DECLARE_RTFEXPORT_TEST(testCjklist21, "cjklist21.rtf") +CPPUNIT_TEST_FIXTURE(Test, testCjklist21) { - sal_Int16 numFormat = getNumberingTypeOfParagraph(1); - CPPUNIT_ASSERT_EQUAL(style::NumberingType::IROHA_FULLWIDTH_JA, numFormat); + auto verify = [this]() { + sal_Int16 numFormat = getNumberingTypeOfParagraph(1); + CPPUNIT_ASSERT_EQUAL(style::NumberingType::IROHA_FULLWIDTH_JA, numFormat); + }; + createSwDoc("cjklist21.rtf"); + verify(); + saveAndReload(mpFilter); + verify(); } -DECLARE_RTFEXPORT_TEST(testCjklist24, "cjklist24.rtf") +CPPUNIT_TEST_FIXTURE(Test, testCjklist24) { - sal_Int16 numFormat = getNumberingTypeOfParagraph(1); - CPPUNIT_ASSERT_EQUAL(style::NumberingType::HANGUL_SYLLABLE_KO, numFormat); + auto verify = [this]() { + sal_Int16 numFormat = getNumberingTypeOfParagraph(1); + CPPUNIT_ASSERT_EQUAL(style::NumberingType::HANGUL_SYLLABLE_KO, numFormat); + }; + createSwDoc("cjklist24.rtf"); + verify(); + saveAndReload(mpFilter); + verify(); } -DECLARE_RTFEXPORT_TEST(testCjklist25, "cjklist25.rtf") +CPPUNIT_TEST_FIXTURE(Test, testCjklist25) { - sal_Int16 numFormat = getNumberingTypeOfParagraph(1); - CPPUNIT_ASSERT_EQUAL(style::NumberingType::HANGUL_JAMO_KO, numFormat); + auto verify = [this]() { + sal_Int16 numFormat = getNumberingTypeOfParagraph(1); + CPPUNIT_ASSERT_EQUAL(style::NumberingType::HANGUL_JAMO_KO, numFormat); + }; + createSwDoc("cjklist25.rtf"); + verify(); + saveAndReload(mpFilter); + verify(); } -DECLARE_RTFEXPORT_TEST(testCjklist30, "cjklist30.rtf") +CPPUNIT_TEST_FIXTURE(Test, testCjklist30) { - sal_Int16 numFormat = getNumberingTypeOfParagraph(1); - CPPUNIT_ASSERT_EQUAL(style::NumberingType::TIAN_GAN_ZH, numFormat); + auto verify = [this]() { + sal_Int16 numFormat = getNumberingTypeOfParagraph(1); + CPPUNIT_ASSERT_EQUAL(style::NumberingType::TIAN_GAN_ZH, numFormat); + }; + createSwDoc("cjklist30.rtf"); + verify(); + saveAndReload(mpFilter); + verify(); } -DECLARE_RTFEXPORT_TEST(testCjklist31, "cjklist31.rtf") +CPPUNIT_TEST_FIXTURE(Test, testCjklist31) { - sal_Int16 numFormat = getNumberingTypeOfParagraph(1); - CPPUNIT_ASSERT_EQUAL(style::NumberingType::DI_ZI_ZH, numFormat); + auto verify = [this]() { + sal_Int16 numFormat = getNumberingTypeOfParagraph(1); + CPPUNIT_ASSERT_EQUAL(style::NumberingType::DI_ZI_ZH, numFormat); + }; + createSwDoc("cjklist31.rtf"); + verify(); + saveAndReload(mpFilter); + verify(); } -DECLARE_RTFEXPORT_TEST(test148518, "FORMDROPDOWN.rtf") -{ - SwXTextDocument* const pTextDoc(dynamic_cast(mxComponent.get())); - CPPUNIT_ASSERT(pTextDoc); - SwDoc* const pDoc(pTextDoc->GetDocShell()->GetDoc()); - - CPPUNIT_ASSERT(pDoc->getIDocumentMarkAccess()->getFieldmarksBegin() - != pDoc->getIDocumentMarkAccess()->getFieldmarksEnd()); - ::sw::mark::IFieldmark* pFieldmark = dynamic_cast<::sw::mark::IFieldmark*>( - *pDoc->getIDocumentMarkAccess()->getFieldmarksBegin()); - uno::Sequence entries; - (*pFieldmark->GetParameters())[ODF_FORMDROPDOWN_LISTENTRY] >>= entries; - uno::Sequence const expected{ OUString("x"), OUString("v"), OUString("d") }; - CPPUNIT_ASSERT_EQUAL(expected, entries); - sal_Int32 result(-1); - (*pFieldmark->GetParameters())[ODF_FORMDROPDOWN_RESULT] >>= result; - CPPUNIT_ASSERT_EQUAL(sal_Int32(1), result); -} - -DECLARE_RTFEXPORT_TEST(test150269, "hidden-linebreaks.rtf") -{ - uno::Reference xRun = getRun(getParagraph(1), 1, u"\n\n\n"_ustr); - CPPUNIT_ASSERT_EQUAL(true, getProperty(xRun, "CharHidden")); -} - -DECLARE_RTFEXPORT_TEST(test129758, "tdf129631_lostBorders3.rtf") -{ - uno::Reference xStyles(getStyles("ParagraphStyles")); - uno::Reference xStyle(xStyles->getByName("Border"), uno::UNO_QUERY); - // style has borders - table::BorderLine2 border; - border = getProperty(xStyle, "RightBorder"); - CPPUNIT_ASSERT_EQUAL(table::BorderLineStyle::SOLID, border.LineStyle); - CPPUNIT_ASSERT_EQUAL(sal_uInt32(88), border.LineWidth); - border = getProperty(xStyle, "LeftBorder"); - CPPUNIT_ASSERT_EQUAL(table::BorderLineStyle::SOLID, border.LineStyle); - CPPUNIT_ASSERT_EQUAL(sal_uInt32(88), border.LineWidth); - border = getProperty(xStyle, "TopBorder"); - CPPUNIT_ASSERT_EQUAL(table::BorderLineStyle::SOLID, border.LineStyle); - CPPUNIT_ASSERT_EQUAL(sal_uInt32(88), border.LineWidth); - border = getProperty(xStyle, "BottomBorder"); - CPPUNIT_ASSERT_EQUAL(table::BorderLineStyle::SOLID, border.LineStyle); - CPPUNIT_ASSERT_EQUAL(sal_uInt32(88), border.LineWidth); - // style applied - uno::Reference xPara2(getParagraph(2), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(OUString("Border"), getProperty(xPara2, "ParaStyleName")); - // but no borders - border = getProperty(xPara2, "RightBorder"); - CPPUNIT_ASSERT_EQUAL(table::BorderLineStyle::NONE, border.LineStyle); - CPPUNIT_ASSERT_EQUAL(sal_uInt32(0), border.LineWidth); - border = getProperty(xPara2, "LeftBorder"); - CPPUNIT_ASSERT_EQUAL(table::BorderLineStyle::NONE, border.LineStyle); - CPPUNIT_ASSERT_EQUAL(sal_uInt32(0), border.LineWidth); - border = getProperty(xPara2, "TopBorder"); - CPPUNIT_ASSERT_EQUAL(table::BorderLineStyle::NONE, border.LineStyle); - CPPUNIT_ASSERT_EQUAL(sal_uInt32(0), border.LineWidth); - border = getProperty(xPara2, "BottomBorder"); - CPPUNIT_ASSERT_EQUAL(table::BorderLineStyle::NONE, border.LineStyle); - CPPUNIT_ASSERT_EQUAL(sal_uInt32(0), border.LineWidth); - // last paragraph: style applied, no override - uno::Reference xPara4(getParagraph(4), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(OUString("Border"), getProperty(xPara4, "ParaStyleName")); - border = getProperty(xPara4, "RightBorder"); - CPPUNIT_ASSERT_EQUAL(table::BorderLineStyle::SOLID, border.LineStyle); - CPPUNIT_ASSERT_EQUAL(sal_uInt32(88), border.LineWidth); - border = getProperty(xPara4, "LeftBorder"); - CPPUNIT_ASSERT_EQUAL(table::BorderLineStyle::SOLID, border.LineStyle); - CPPUNIT_ASSERT_EQUAL(sal_uInt32(88), border.LineWidth); - border = getProperty(xPara4, "TopBorder"); - CPPUNIT_ASSERT_EQUAL(table::BorderLineStyle::SOLID, border.LineStyle); - CPPUNIT_ASSERT_EQUAL(sal_uInt32(88), border.LineWidth); - border = getProperty(xPara4, "BottomBorder"); - CPPUNIT_ASSERT_EQUAL(table::BorderLineStyle::SOLID, border.LineStyle); - CPPUNIT_ASSERT_EQUAL(sal_uInt32(88), border.LineWidth); -} - -DECLARE_RTFEXPORT_TEST(test150382, "para-border.rtf") -{ - uno::Reference xStyles(getStyles("ParagraphStyles")); - uno::Reference xStyle(xStyles->getByName("Normal,Bordered"), - uno::UNO_QUERY); - // style has borders - table::BorderLine2 border; - border = getProperty(xStyle, "RightBorder"); - CPPUNIT_ASSERT_EQUAL(table::BorderLineStyle::SOLID, border.LineStyle); - CPPUNIT_ASSERT_EQUAL(sal_uInt32(35), border.LineWidth); - CPPUNIT_ASSERT_EQUAL(sal_Int32(7384391), border.Color); - border = getProperty(xStyle, "LeftBorder"); - CPPUNIT_ASSERT_EQUAL(table::BorderLineStyle::SOLID, border.LineStyle); - CPPUNIT_ASSERT_EQUAL(sal_uInt32(35), border.LineWidth); - CPPUNIT_ASSERT_EQUAL(sal_Int32(7384391), border.Color); - border = getProperty(xStyle, "TopBorder"); - CPPUNIT_ASSERT_EQUAL(table::BorderLineStyle::SOLID, border.LineStyle); - CPPUNIT_ASSERT_EQUAL(sal_uInt32(35), border.LineWidth); - CPPUNIT_ASSERT_EQUAL(sal_Int32(7384391), border.Color); - border = getProperty(xStyle, "BottomBorder"); - CPPUNIT_ASSERT_EQUAL(table::BorderLineStyle::SOLID, border.LineStyle); - CPPUNIT_ASSERT_EQUAL(sal_uInt32(35), border.LineWidth); - CPPUNIT_ASSERT_EQUAL(sal_Int32(7384391), border.Color); - // first paragraph: style applied, no override - uno::Reference xPara1(getParagraph(1), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(OUString("Normal,Bordered"), - getProperty(xPara1, "ParaStyleName")); - border = getProperty(xPara1, "RightBorder"); - CPPUNIT_ASSERT_EQUAL(table::BorderLineStyle::SOLID, border.LineStyle); - CPPUNIT_ASSERT_EQUAL(sal_uInt32(35), border.LineWidth); - CPPUNIT_ASSERT_EQUAL(sal_Int32(7384391), border.Color); - border = getProperty(xPara1, "LeftBorder"); - CPPUNIT_ASSERT_EQUAL(table::BorderLineStyle::SOLID, border.LineStyle); - CPPUNIT_ASSERT_EQUAL(sal_uInt32(35), border.LineWidth); - CPPUNIT_ASSERT_EQUAL(sal_Int32(7384391), border.Color); - border = getProperty(xPara1, "TopBorder"); - CPPUNIT_ASSERT_EQUAL(table::BorderLineStyle::SOLID, border.LineStyle); - CPPUNIT_ASSERT_EQUAL(sal_uInt32(35), border.LineWidth); - CPPUNIT_ASSERT_EQUAL(sal_Int32(7384391), border.Color); - border = getProperty(xPara1, "BottomBorder"); - CPPUNIT_ASSERT_EQUAL(table::BorderLineStyle::SOLID, border.LineStyle); - CPPUNIT_ASSERT_EQUAL(sal_uInt32(35), border.LineWidth); - CPPUNIT_ASSERT_EQUAL(sal_Int32(7384391), border.Color); - // second paragraph: style applied - uno::Reference xPara2(getParagraph(2), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(OUString("Normal,Bordered"), - getProperty(xPara2, "ParaStyleName")); - // but no borders - border = getProperty(xPara2, "RightBorder"); - CPPUNIT_ASSERT_EQUAL(table::BorderLineStyle::NONE, border.LineStyle); - CPPUNIT_ASSERT_EQUAL(sal_uInt32(0), border.LineWidth); - border = getProperty(xPara2, "LeftBorder"); - CPPUNIT_ASSERT_EQUAL(table::BorderLineStyle::NONE, border.LineStyle); - CPPUNIT_ASSERT_EQUAL(sal_uInt32(0), border.LineWidth); - border = getProperty(xPara2, "TopBorder"); - CPPUNIT_ASSERT_EQUAL(table::BorderLineStyle::NONE, border.LineStyle); - CPPUNIT_ASSERT_EQUAL(sal_uInt32(0), border.LineWidth); - border = getProperty(xPara2, "BottomBorder"); - CPPUNIT_ASSERT_EQUAL(table::BorderLineStyle::NONE, border.LineStyle); - CPPUNIT_ASSERT_EQUAL(sal_uInt32(0), border.LineWidth); -} - -DECLARE_RTFEXPORT_TEST(testAnchoredAtSamePosition, "anchor.fodt") -{ - SwXTextDocument* const pTextDoc = dynamic_cast(mxComponent.get()); - SwDoc* const pDoc = pTextDoc->GetDocShell()->GetDoc(); - - CPPUNIT_ASSERT_EQUAL(OUString("foobar"), getParagraph(1)->getString()); - - auto& rFlys = *pDoc->GetSpzFrameFormats(); - if (isExported()) - { // 2, not 3: the form control becomes a field on export... - CPPUNIT_ASSERT_EQUAL(size_t(2), rFlys.size()); - } - else - { - CPPUNIT_ASSERT_EQUAL(size_t(3), rFlys.size()); - } +CPPUNIT_TEST_FIXTURE(Test, test148518) +{ + auto verify = [this]() { + SwXTextDocument* const pTextDoc(dynamic_cast(mxComponent.get())); + CPPUNIT_ASSERT(pTextDoc); + SwDoc* const pDoc(pTextDoc->GetDocShell()->GetDoc()); + + CPPUNIT_ASSERT(pDoc->getIDocumentMarkAccess()->getFieldmarksBegin() + != pDoc->getIDocumentMarkAccess()->getFieldmarksEnd()); + ::sw::mark::IFieldmark* pFieldmark = dynamic_cast<::sw::mark::IFieldmark*>( + *pDoc->getIDocumentMarkAccess()->getFieldmarksBegin()); + uno::Sequence entries; + (*pFieldmark->GetParameters())[ODF_FORMDROPDOWN_LISTENTRY] >>= entries; + uno::Sequence const expected{ OUString("x"), OUString("v"), OUString("d") }; + CPPUNIT_ASSERT_EQUAL(expected, entries); + sal_Int32 result(-1); + (*pFieldmark->GetParameters())[ODF_FORMDROPDOWN_RESULT] >>= result; + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), result); + }; + createSwDoc("FORMDROPDOWN.rtf"); + verify(); + saveAndReload(mpFilter); + verify(); +} - sal_Int32 const nIndex(isExported() ? 4 : 3); - CPPUNIT_ASSERT_EQUAL(RndStdIds::FLY_AT_CHAR, rFlys[0]->GetAnchor().GetAnchorId()); - CPPUNIT_ASSERT_EQUAL(SwNodeOffset(12), rFlys[0]->GetAnchor().GetAnchorNode()->GetIndex()); - CPPUNIT_ASSERT_EQUAL(nIndex, rFlys[0]->GetAnchor().GetAnchorContentOffset()); - CPPUNIT_ASSERT_EQUAL(RndStdIds::FLY_AT_CHAR, rFlys[1]->GetAnchor().GetAnchorId()); - CPPUNIT_ASSERT_EQUAL(SwNodeOffset(12), rFlys[1]->GetAnchor().GetAnchorNode()->GetIndex()); - CPPUNIT_ASSERT_EQUAL(nIndex, rFlys[1]->GetAnchor().GetAnchorContentOffset()); -} - -DECLARE_RTFEXPORT_TEST(testRedlineInsdel, "redline-insdel.rtf") -{ - uno::Reference xParagraph = getParagraph(1); - - uno::Reference xRun = getRun(xParagraph, 1); - CPPUNIT_ASSERT_EQUAL(OUString("Text"), getProperty(xRun, "TextPortionType")); - CPPUNIT_ASSERT_EQUAL(OUString("aaa"), xRun->getString()); - - xRun = getRun(xParagraph, 2); - CPPUNIT_ASSERT_EQUAL(OUString("Redline"), getProperty(xRun, "TextPortionType")); - CPPUNIT_ASSERT_EQUAL(OUString("Delete"), getProperty(xRun, "RedlineType")); - xRun = getRun(xParagraph, 3); - CPPUNIT_ASSERT_EQUAL(OUString("Text"), getProperty(xRun, "TextPortionType")); - CPPUNIT_ASSERT_EQUAL(OUString("bbb"), xRun->getString()); - xRun = getRun(xParagraph, 4); - CPPUNIT_ASSERT_EQUAL(OUString("Redline"), getProperty(xRun, "TextPortionType")); - CPPUNIT_ASSERT_EQUAL(OUString("Delete"), getProperty(xRun, "RedlineType")); - - xRun = getRun(xParagraph, 5); - CPPUNIT_ASSERT_EQUAL(OUString("Redline"), getProperty(xRun, "TextPortionType")); - CPPUNIT_ASSERT_EQUAL(OUString("Insert"), getProperty(xRun, "RedlineType")); - xRun = getRun(xParagraph, 6); - CPPUNIT_ASSERT_EQUAL(OUString("Text"), getProperty(xRun, "TextPortionType")); - CPPUNIT_ASSERT_EQUAL(OUString("BBB"), xRun->getString()); - xRun = getRun(xParagraph, 7); - CPPUNIT_ASSERT_EQUAL(OUString("Redline"), getProperty(xRun, "TextPortionType")); - CPPUNIT_ASSERT_EQUAL(OUString("Insert"), getProperty(xRun, "RedlineType")); - - xRun = getRun(xParagraph, 8); - CPPUNIT_ASSERT_EQUAL(OUString("Text"), getProperty(xRun, "TextPortionType")); - CPPUNIT_ASSERT_EQUAL(OUString("ccc"), xRun->getString()); -} - -DECLARE_RTFEXPORT_TEST(testParaAdjustDistribute, "para-adjust-distribute.rtf") -{ - // Without the accompanying fix in place, this test would have failed with - // 'Expected: 2; Actual : 0', i.e. the first paragraph's ParaAdjust was - // left, not block. - CPPUNIT_ASSERT_EQUAL( - style::ParagraphAdjust_BLOCK, - static_cast(getProperty(getParagraph(1), "ParaAdjust"))); - CPPUNIT_ASSERT_EQUAL(style::ParagraphAdjust_BLOCK, - static_cast( - getProperty(getParagraph(1), "ParaLastLineAdjust"))); +CPPUNIT_TEST_FIXTURE(Test, test150269) +{ + auto verify = [this]() { + uno::Reference xRun = getRun(getParagraph(1), 1, u"\n\n\n"_ustr); + CPPUNIT_ASSERT_EQUAL(true, getProperty(xRun, "CharHidden")); + }; + createSwDoc("hidden-linebreaks.rtf"); + verify(); + saveAndReload(mpFilter); + verify(); +} - CPPUNIT_ASSERT_EQUAL( - style::ParagraphAdjust_BLOCK, - static_cast(getProperty(getParagraph(2), "ParaAdjust"))); - CPPUNIT_ASSERT_EQUAL(style::ParagraphAdjust_LEFT, - static_cast( - getProperty(getParagraph(2), "ParaLastLineAdjust"))); +CPPUNIT_TEST_FIXTURE(Test, test129758) +{ + auto verify = [this]() { + uno::Reference xStyles(getStyles("ParagraphStyles")); + uno::Reference xStyle(xStyles->getByName("Border"), uno::UNO_QUERY); + // style has borders + table::BorderLine2 border; + border = getProperty(xStyle, "RightBorder"); + CPPUNIT_ASSERT_EQUAL(table::BorderLineStyle::SOLID, border.LineStyle); + CPPUNIT_ASSERT_EQUAL(sal_uInt32(88), border.LineWidth); + border = getProperty(xStyle, "LeftBorder"); + CPPUNIT_ASSERT_EQUAL(table::BorderLineStyle::SOLID, border.LineStyle); + CPPUNIT_ASSERT_EQUAL(sal_uInt32(88), border.LineWidth); + border = getProperty(xStyle, "TopBorder"); + CPPUNIT_ASSERT_EQUAL(table::BorderLineStyle::SOLID, border.LineStyle); + CPPUNIT_ASSERT_EQUAL(sal_uInt32(88), border.LineWidth); + border = getProperty(xStyle, "BottomBorder"); + CPPUNIT_ASSERT_EQUAL(table::BorderLineStyle::SOLID, border.LineStyle); + CPPUNIT_ASSERT_EQUAL(sal_uInt32(88), border.LineWidth); + // style applied + uno::Reference xPara2(getParagraph(2), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("Border"), getProperty(xPara2, "ParaStyleName")); + // but no borders + border = getProperty(xPara2, "RightBorder"); + CPPUNIT_ASSERT_EQUAL(table::BorderLineStyle::NONE, border.LineStyle); + CPPUNIT_ASSERT_EQUAL(sal_uInt32(0), border.LineWidth); + border = getProperty(xPara2, "LeftBorder"); + CPPUNIT_ASSERT_EQUAL(table::BorderLineStyle::NONE, border.LineStyle); + CPPUNIT_ASSERT_EQUAL(sal_uInt32(0), border.LineWidth); + border = getProperty(xPara2, "TopBorder"); + CPPUNIT_ASSERT_EQUAL(table::BorderLineStyle::NONE, border.LineStyle); + CPPUNIT_ASSERT_EQUAL(sal_uInt32(0), border.LineWidth); + border = getProperty(xPara2, "BottomBorder"); + CPPUNIT_ASSERT_EQUAL(table::BorderLineStyle::NONE, border.LineStyle); + CPPUNIT_ASSERT_EQUAL(sal_uInt32(0), border.LineWidth); + // last paragraph: style applied, no override + uno::Reference xPara4(getParagraph(4), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("Border"), getProperty(xPara4, "ParaStyleName")); + border = getProperty(xPara4, "RightBorder"); + CPPUNIT_ASSERT_EQUAL(table::BorderLineStyle::SOLID, border.LineStyle); + CPPUNIT_ASSERT_EQUAL(sal_uInt32(88), border.LineWidth); + border = getProperty(xPara4, "LeftBorder"); + CPPUNIT_ASSERT_EQUAL(table::BorderLineStyle::SOLID, border.LineStyle); + CPPUNIT_ASSERT_EQUAL(sal_uInt32(88), border.LineWidth); + border = getProperty(xPara4, "TopBorder"); + CPPUNIT_ASSERT_EQUAL(table::BorderLineStyle::SOLID, border.LineStyle); + CPPUNIT_ASSERT_EQUAL(sal_uInt32(88), border.LineWidth); + border = getProperty(xPara4, "BottomBorder"); + CPPUNIT_ASSERT_EQUAL(table::BorderLineStyle::SOLID, border.LineStyle); + CPPUNIT_ASSERT_EQUAL(sal_uInt32(88), border.LineWidth); + }; + createSwDoc("tdf129631_lostBorders3.rtf"); + verify(); + saveAndReload(mpFilter); + verify(); +} + +CPPUNIT_TEST_FIXTURE(Test, test150382) +{ + auto verify = [this]() { + uno::Reference xStyles(getStyles("ParagraphStyles")); + uno::Reference xStyle(xStyles->getByName("Normal,Bordered"), + uno::UNO_QUERY); + // style has borders + table::BorderLine2 border; + border = getProperty(xStyle, "RightBorder"); + CPPUNIT_ASSERT_EQUAL(table::BorderLineStyle::SOLID, border.LineStyle); + CPPUNIT_ASSERT_EQUAL(sal_uInt32(35), border.LineWidth); + CPPUNIT_ASSERT_EQUAL(sal_Int32(7384391), border.Color); + border = getProperty(xStyle, "LeftBorder"); + CPPUNIT_ASSERT_EQUAL(table::BorderLineStyle::SOLID, border.LineStyle); + CPPUNIT_ASSERT_EQUAL(sal_uInt32(35), border.LineWidth); + CPPUNIT_ASSERT_EQUAL(sal_Int32(7384391), border.Color); + border = getProperty(xStyle, "TopBorder"); + CPPUNIT_ASSERT_EQUAL(table::BorderLineStyle::SOLID, border.LineStyle); + CPPUNIT_ASSERT_EQUAL(sal_uInt32(35), border.LineWidth); + CPPUNIT_ASSERT_EQUAL(sal_Int32(7384391), border.Color); + border = getProperty(xStyle, "BottomBorder"); + CPPUNIT_ASSERT_EQUAL(table::BorderLineStyle::SOLID, border.LineStyle); + CPPUNIT_ASSERT_EQUAL(sal_uInt32(35), border.LineWidth); + CPPUNIT_ASSERT_EQUAL(sal_Int32(7384391), border.Color); + // first paragraph: style applied, no override + uno::Reference xPara1(getParagraph(1), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("Normal,Bordered"), + getProperty(xPara1, "ParaStyleName")); + border = getProperty(xPara1, "RightBorder"); + CPPUNIT_ASSERT_EQUAL(table::BorderLineStyle::SOLID, border.LineStyle); + CPPUNIT_ASSERT_EQUAL(sal_uInt32(35), border.LineWidth); + CPPUNIT_ASSERT_EQUAL(sal_Int32(7384391), border.Color); + border = getProperty(xPara1, "LeftBorder"); + CPPUNIT_ASSERT_EQUAL(table::BorderLineStyle::SOLID, border.LineStyle); + CPPUNIT_ASSERT_EQUAL(sal_uInt32(35), border.LineWidth); + CPPUNIT_ASSERT_EQUAL(sal_Int32(7384391), border.Color); + border = getProperty(xPara1, "TopBorder"); + CPPUNIT_ASSERT_EQUAL(table::BorderLineStyle::SOLID, border.LineStyle); + CPPUNIT_ASSERT_EQUAL(sal_uInt32(35), border.LineWidth); + CPPUNIT_ASSERT_EQUAL(sal_Int32(7384391), border.Color); + border = getProperty(xPara1, "BottomBorder"); + CPPUNIT_ASSERT_EQUAL(table::BorderLineStyle::SOLID, border.LineStyle); + CPPUNIT_ASSERT_EQUAL(sal_uInt32(35), border.LineWidth); + CPPUNIT_ASSERT_EQUAL(sal_Int32(7384391), border.Color); + // second paragraph: style applied + uno::Reference xPara2(getParagraph(2), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("Normal,Bordered"), + getProperty(xPara2, "ParaStyleName")); + // but no borders + border = getProperty(xPara2, "RightBorder"); + CPPUNIT_ASSERT_EQUAL(table::BorderLineStyle::NONE, border.LineStyle); + CPPUNIT_ASSERT_EQUAL(sal_uInt32(0), border.LineWidth); + border = getProperty(xPara2, "LeftBorder"); + CPPUNIT_ASSERT_EQUAL(table::BorderLineStyle::NONE, border.LineStyle); + CPPUNIT_ASSERT_EQUAL(sal_uInt32(0), border.LineWidth); + border = getProperty(xPara2, "TopBorder"); + CPPUNIT_ASSERT_EQUAL(table::BorderLineStyle::NONE, border.LineStyle); + CPPUNIT_ASSERT_EQUAL(sal_uInt32(0), border.LineWidth); + border = getProperty(xPara2, "BottomBorder"); + CPPUNIT_ASSERT_EQUAL(table::BorderLineStyle::NONE, border.LineStyle); + CPPUNIT_ASSERT_EQUAL(sal_uInt32(0), border.LineWidth); + }; + createSwDoc("para-border.rtf"); + verify(); + saveAndReload(mpFilter); + verify(); +} + +CPPUNIT_TEST_FIXTURE(Test, testAnchoredAtSamePosition) +{ + auto verify = [this]() { + SwXTextDocument* const pTextDoc = dynamic_cast(mxComponent.get()); + SwDoc* const pDoc = pTextDoc->GetDocShell()->GetDoc(); + + CPPUNIT_ASSERT_EQUAL(OUString("foobar"), getParagraph(1)->getString()); + + auto& rFlys = *pDoc->GetSpzFrameFormats(); + if (isExported()) + { // 2, not 3: the form control becomes a field on export... + CPPUNIT_ASSERT_EQUAL(size_t(2), rFlys.size()); + } + else + { + CPPUNIT_ASSERT_EQUAL(size_t(3), rFlys.size()); + } + + sal_Int32 const nIndex(isExported() ? 4 : 3); + CPPUNIT_ASSERT_EQUAL(RndStdIds::FLY_AT_CHAR, rFlys[0]->GetAnchor().GetAnchorId()); + CPPUNIT_ASSERT_EQUAL(SwNodeOffset(12), rFlys[0]->GetAnchor().GetAnchorNode()->GetIndex()); + CPPUNIT_ASSERT_EQUAL(nIndex, rFlys[0]->GetAnchor().GetAnchorContentOffset()); + CPPUNIT_ASSERT_EQUAL(RndStdIds::FLY_AT_CHAR, rFlys[1]->GetAnchor().GetAnchorId()); + CPPUNIT_ASSERT_EQUAL(SwNodeOffset(12), rFlys[1]->GetAnchor().GetAnchorNode()->GetIndex()); + CPPUNIT_ASSERT_EQUAL(nIndex, rFlys[1]->GetAnchor().GetAnchorContentOffset()); + }; + createSwDoc("anchor.fodt"); + verify(); + saveAndReload(mpFilter); + verify(); +} + +CPPUNIT_TEST_FIXTURE(Test, testRedlineInsdel) +{ + auto verify = [this]() { + uno::Reference xParagraph = getParagraph(1); + + uno::Reference xRun = getRun(xParagraph, 1); + CPPUNIT_ASSERT_EQUAL(OUString("Text"), getProperty(xRun, "TextPortionType")); + CPPUNIT_ASSERT_EQUAL(OUString("aaa"), xRun->getString()); + + xRun = getRun(xParagraph, 2); + CPPUNIT_ASSERT_EQUAL(OUString("Redline"), getProperty(xRun, "TextPortionType")); + CPPUNIT_ASSERT_EQUAL(OUString("Delete"), getProperty(xRun, "RedlineType")); + xRun = getRun(xParagraph, 3); + CPPUNIT_ASSERT_EQUAL(OUString("Text"), getProperty(xRun, "TextPortionType")); + CPPUNIT_ASSERT_EQUAL(OUString("bbb"), xRun->getString()); + xRun = getRun(xParagraph, 4); + CPPUNIT_ASSERT_EQUAL(OUString("Redline"), getProperty(xRun, "TextPortionType")); + CPPUNIT_ASSERT_EQUAL(OUString("Delete"), getProperty(xRun, "RedlineType")); + + xRun = getRun(xParagraph, 5); + CPPUNIT_ASSERT_EQUAL(OUString("Redline"), getProperty(xRun, "TextPortionType")); + CPPUNIT_ASSERT_EQUAL(OUString("Insert"), getProperty(xRun, "RedlineType")); + xRun = getRun(xParagraph, 6); + CPPUNIT_ASSERT_EQUAL(OUString("Text"), getProperty(xRun, "TextPortionType")); + CPPUNIT_ASSERT_EQUAL(OUString("BBB"), xRun->getString()); + xRun = getRun(xParagraph, 7); + CPPUNIT_ASSERT_EQUAL(OUString("Redline"), getProperty(xRun, "TextPortionType")); + CPPUNIT_ASSERT_EQUAL(OUString("Insert"), getProperty(xRun, "RedlineType")); + + xRun = getRun(xParagraph, 8); + CPPUNIT_ASSERT_EQUAL(OUString("Text"), getProperty(xRun, "TextPortionType")); + CPPUNIT_ASSERT_EQUAL(OUString("ccc"), xRun->getString()); + }; + createSwDoc("redline-insdel.rtf"); + verify(); + saveAndReload(mpFilter); + verify(); +} + +CPPUNIT_TEST_FIXTURE(Test, testParaAdjustDistribute) +{ + auto verify = [this]() { + // Without the accompanying fix in place, this test would have failed with + // 'Expected: 2; Actual : 0', i.e. the first paragraph's ParaAdjust was + // left, not block. + CPPUNIT_ASSERT_EQUAL(style::ParagraphAdjust_BLOCK, + static_cast( + getProperty(getParagraph(1), "ParaAdjust"))); + CPPUNIT_ASSERT_EQUAL(style::ParagraphAdjust_BLOCK, + static_cast( + getProperty(getParagraph(1), "ParaLastLineAdjust"))); + + CPPUNIT_ASSERT_EQUAL(style::ParagraphAdjust_BLOCK, + static_cast( + getProperty(getParagraph(2), "ParaAdjust"))); + CPPUNIT_ASSERT_EQUAL(style::ParagraphAdjust_LEFT, + static_cast( + getProperty(getParagraph(2), "ParaLastLineAdjust"))); + }; + createSwDoc("para-adjust-distribute.rtf"); + verify(); + saveAndReload(mpFilter); + verify(); } -DECLARE_RTFEXPORT_TEST(testTdf129574, "mw00_table_of_contents_templates.doc") +CPPUNIT_TEST_FIXTURE(Test, testTdf129574) { - uno::Reference xIndexSupplier(mxComponent, uno::UNO_QUERY); - uno::Reference xIndexes(xIndexSupplier->getDocumentIndexes()); - uno::Reference xTOC(xIndexes->getByIndex(0), uno::UNO_QUERY); - CPPUNIT_ASSERT(xTOC.is()); - uno::Reference xTextRange(xTOC->getAnchor()); - // table of contents contains 4 paragraphs - CPPUNIT_ASSERT_EQUAL(OUString("1.Koffice 1" SAL_NEWLINE_STRING "2.Kword 1" SAL_NEWLINE_STRING - "3.Kspread 1" SAL_NEWLINE_STRING "4.Kpresenter 1"), - xTextRange->getString()); + auto verify = [this]() { + uno::Reference xIndexSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference xIndexes(xIndexSupplier->getDocumentIndexes()); + uno::Reference xTOC(xIndexes->getByIndex(0), uno::UNO_QUERY); + CPPUNIT_ASSERT(xTOC.is()); + uno::Reference xTextRange(xTOC->getAnchor()); + // table of contents contains 4 paragraphs + CPPUNIT_ASSERT_EQUAL(OUString("1.Koffice 1" SAL_NEWLINE_STRING + "2.Kword 1" SAL_NEWLINE_STRING + "3.Kspread 1" SAL_NEWLINE_STRING "4.Kpresenter 1"), + xTextRange->getString()); + }; + createSwDoc("mw00_table_of_contents_templates.doc"); + verify(); + saveAndReload(mpFilter); + verify(); } -DECLARE_RTFEXPORT_TEST(testCjklist34, "cjklist34.rtf") +CPPUNIT_TEST_FIXTURE(Test, testCjklist34) { - sal_Int16 numFormat = getNumberingTypeOfParagraph(1); - CPPUNIT_ASSERT_EQUAL(style::NumberingType::NUMBER_UPPER_ZH_TW, numFormat); + auto verify = [this]() { + sal_Int16 numFormat = getNumberingTypeOfParagraph(1); + CPPUNIT_ASSERT_EQUAL(style::NumberingType::NUMBER_UPPER_ZH_TW, numFormat); + }; + createSwDoc("cjklist34.rtf"); + verify(); + saveAndReload(mpFilter); + verify(); } CPPUNIT_TEST_FIXTURE(Test, testTabStopFillChars) @@ -360,159 +469,225 @@ CPPUNIT_TEST_FIXTURE(Test, testTabStopFillChars) CPPUNIT_ASSERT_EQUAL(u' ', aTabstops[0].FillChar); } -DECLARE_RTFEXPORT_TEST(testTdf146489, "tdf146489.rtf") +CPPUNIT_TEST_FIXTURE(Test, testTdf146489) { - uno::Reference xPara = getParagraph(2, "unnumbered"); - CPPUNIT_ASSERT_EQUAL(OUString(), getProperty(xPara, "ListLabelString")); + auto verify = [this]() { + uno::Reference xPara = getParagraph(2, "unnumbered"); + CPPUNIT_ASSERT_EQUAL(OUString(), getProperty(xPara, "ListLabelString")); + }; + createSwDoc("tdf146489.rtf"); + verify(); + saveAndReload(mpFilter); + verify(); } -DECLARE_RTFEXPORT_TEST(testCjklist38, "cjklist38.rtf") +CPPUNIT_TEST_FIXTURE(Test, testCjklist38) { - sal_Int16 numFormat = getNumberingTypeOfParagraph(1); - CPPUNIT_ASSERT_EQUAL(style::NumberingType::NUMBER_UPPER_ZH, numFormat); + auto verify = [this]() { + sal_Int16 numFormat = getNumberingTypeOfParagraph(1); + CPPUNIT_ASSERT_EQUAL(style::NumberingType::NUMBER_UPPER_ZH, numFormat); + }; + createSwDoc("cjklist38.rtf"); + verify(); + saveAndReload(mpFilter); + verify(); } -DECLARE_RTFEXPORT_TEST(testBtlrCell, "btlr-cell.rtf") +CPPUNIT_TEST_FIXTURE(Test, testBtlrCell) { - // Without the accompanying fix in place, this test would have failed, as - // the btlr text direction in the A1 cell was lost. - uno::Reference xSupplier(mxComponent, uno::UNO_QUERY); - uno::Reference xTables = xSupplier->getTextTables(); - uno::Reference xTable(xTables->getByName("Table1"), uno::UNO_QUERY); - uno::Reference xA1(xTable->getCellByName("A1"), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(text::WritingMode2::BT_LR, getProperty(xA1, "WritingMode")); - - uno::Reference xB1(xTable->getCellByName("B1"), uno::UNO_QUERY); - auto nActual = getProperty(xB1, "WritingMode"); - CPPUNIT_ASSERT(nActual == text::WritingMode2::LR_TB || nActual == text::WritingMode2::CONTEXT); - - uno::Reference xC1(xTable->getCellByName("C1"), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(text::WritingMode2::TB_RL, getProperty(xC1, "WritingMode")); + auto verify = [this]() { + // Without the accompanying fix in place, this test would have failed, as + // the btlr text direction in the A1 cell was lost. + uno::Reference xSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference xTables = xSupplier->getTextTables(); + uno::Reference xTable(xTables->getByName("Table1"), uno::UNO_QUERY); + uno::Reference xA1(xTable->getCellByName("A1"), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(text::WritingMode2::BT_LR, getProperty(xA1, "WritingMode")); + + uno::Reference xB1(xTable->getCellByName("B1"), uno::UNO_QUERY); + auto nActual = getProperty(xB1, "WritingMode"); + CPPUNIT_ASSERT(nActual == text::WritingMode2::LR_TB + || nActual == text::WritingMode2::CONTEXT); + + uno::Reference xC1(xTable->getCellByName("C1"), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(text::WritingMode2::TB_RL, getProperty(xC1, "WritingMode")); + }; + createSwDoc("btlr-cell.rtf"); + verify(); + saveAndReload(mpFilter); + verify(); } -DECLARE_RTFEXPORT_TEST(testTdf114303, "tdf114303.rtf") +CPPUNIT_TEST_FIXTURE(Test, testTdf114303) { - CPPUNIT_ASSERT_EQUAL(text::HoriOrientation::NONE, - getProperty(getShape(1), "HoriOrient")); + auto verify = [this]() { + CPPUNIT_ASSERT_EQUAL(text::HoriOrientation::NONE, + getProperty(getShape(1), "HoriOrient")); + + // Without the fix in place, this test would have failed with + // - Expected: 0 + // - Actual : 1 + CPPUNIT_ASSERT_EQUAL(text::VertOrientation::NONE, + getProperty(getShape(1), "VertOrient")); + }; + createSwDoc("tdf114303.rtf"); + verify(); + saveAndReload(mpFilter); + verify(); +} - // Without the fix in place, this test would have failed with - // - Expected: 0 - // - Actual : 1 - CPPUNIT_ASSERT_EQUAL(text::VertOrientation::NONE, - getProperty(getShape(1), "VertOrient")); +CPPUNIT_TEST_FIXTURE(Test, testTbrlFrame) +{ + auto verify = [this]() { + CPPUNIT_ASSERT_EQUAL(1, getShapes()); + CPPUNIT_ASSERT_EQUAL(1, getPages()); + uno::Reference xShape(getShape(1), uno::UNO_QUERY); + auto nActual = getProperty(xShape, "WritingMode"); + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 2 + // - Actual : 0 + // i.e. custom writing mode was lost. + CPPUNIT_ASSERT_EQUAL(text::WritingMode2::TB_RL, nActual); + }; + createSwDoc("tbrl-frame.odt"); + verify(); + saveAndReload(mpFilter); + verify(); } -DECLARE_RTFEXPORT_TEST(testTbrlFrame, "tbrl-frame.odt") +CPPUNIT_TEST_FIXTURE(Test, testBtlrFrame) { - CPPUNIT_ASSERT_EQUAL(1, getShapes()); - CPPUNIT_ASSERT_EQUAL(1, getPages()); - uno::Reference xShape(getShape(1), uno::UNO_QUERY); - auto nActual = getProperty(xShape, "WritingMode"); - // Without the accompanying fix in place, this test would have failed with: - // - Expected: 2 - // - Actual : 0 - // i.e. custom writing mode was lost. - CPPUNIT_ASSERT_EQUAL(text::WritingMode2::TB_RL, nActual); + auto verify = [this]() { + CPPUNIT_ASSERT_EQUAL(1, getShapes()); + CPPUNIT_ASSERT_EQUAL(1, getPages()); + uno::Reference xShape(getShape(1), uno::UNO_QUERY); + auto nActual = getProperty(xShape, "WritingMode"); + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 5 + // - Actual : 0 + // i.e. custom writing mode was lost. + CPPUNIT_ASSERT_EQUAL(text::WritingMode2::BT_LR, nActual); + }; + createSwDoc("btlr-frame.odt"); + verify(); + saveAndReload(mpFilter); + verify(); } -DECLARE_RTFEXPORT_TEST(testBtlrFrame, "btlr-frame.odt") +CPPUNIT_TEST_FIXTURE(Test, testTdf129578_lostBI) { - CPPUNIT_ASSERT_EQUAL(1, getShapes()); - CPPUNIT_ASSERT_EQUAL(1, getPages()); - uno::Reference xShape(getShape(1), uno::UNO_QUERY); - auto nActual = getProperty(xShape, "WritingMode"); - // Without the accompanying fix in place, this test would have failed with: - // - Expected: 5 - // - Actual : 0 - // i.e. custom writing mode was lost. - CPPUNIT_ASSERT_EQUAL(text::WritingMode2::BT_LR, nActual); + auto verify = [this]() { + CPPUNIT_ASSERT_EQUAL(150.f, + getProperty(getRun(getParagraph(1), 1), "CharWeightAsian")); + CPPUNIT_ASSERT_EQUAL( + awt::FontSlant_ITALIC, + getProperty(getRun(getParagraph(2), 1), "CharPostureAsian")); + }; + createSwDoc("tdf129578_lostBI.rtf"); + verify(); + saveAndReload(mpFilter); + verify(); } -DECLARE_RTFEXPORT_TEST(testTdf129578_lostBI, "tdf129578_lostBI.rtf") +CPPUNIT_TEST_FIXTURE(Test, testTdf129631_lostBorders) { - CPPUNIT_ASSERT_EQUAL(150.f, getProperty(getRun(getParagraph(1), 1), "CharWeightAsian")); - CPPUNIT_ASSERT_EQUAL( - awt::FontSlant_ITALIC, - getProperty(getRun(getParagraph(2), 1), "CharPostureAsian")); -} - -DECLARE_RTFEXPORT_TEST(testTdf129631_lostBorders, "tdf129631_lostBorders.rtf") -{ - uno::Reference paragraphStyles = getStyles("ParagraphStyles"); - uno::Reference xStyleProps(paragraphStyles->getByName("Border"), - uno::UNO_QUERY_THROW); - table::BorderLine2 aBorderLine = getProperty(xStyleProps, "RightBorder"); - CPPUNIT_ASSERT(sal_uInt32(0) != aBorderLine.LineWidth); - CPPUNIT_ASSERT_EQUAL_MESSAGE( - "The border style has normal black borders", COL_BLACK, - Color(ColorTransparency, getProperty(xStyleProps, "RightBorder").Color)); - - aBorderLine = getProperty(getParagraph(2), "RightBorder"); - CPPUNIT_ASSERT(sal_uInt32(0) != aBorderLine.LineWidth); - CPPUNIT_ASSERT_EQUAL_MESSAGE( - "The second paragraph should have dark green borders", sal_Int32(432686), - getProperty(getParagraph(2), "RightBorder").Color); -} - -DECLARE_RTFEXPORT_TEST(testTdf129522_removeShadowStyle, "tdf129522_removeShadowStyle.odt") -{ - CPPUNIT_ASSERT_EQUAL(1, getPages()); - uno::Reference paragraphStyles = getStyles("ParagraphStyles"); - uno::Reference xStyleProps(paragraphStyles->getByName("Shadow"), - uno::UNO_QUERY_THROW); - table::ShadowFormat aShadow = getProperty(xStyleProps, "ParaShadowFormat"); - CPPUNIT_ASSERT_EQUAL(table::ShadowLocation_BOTTOM_RIGHT, aShadow.Location); - - // Shadows were inherited regardless of whether the style disabled them. - xStyleProps.set(paragraphStyles->getByName("Shadow-removed"), uno::UNO_QUERY_THROW); - aShadow = getProperty(xStyleProps, "ParaShadowFormat"); - //CPPUNIT_ASSERT_EQUAL(table::ShadowLocation_NONE, aShadow.Location); - - uno::Reference characterStyles = getStyles("CharacterStyles"); - xStyleProps.set(characterStyles->getByName("CharShadow"), uno::UNO_QUERY_THROW); - aShadow = getProperty(xStyleProps, "CharShadowFormat"); - CPPUNIT_ASSERT_EQUAL(table::ShadowLocation_BOTTOM_RIGHT, aShadow.Location); - - xStyleProps.set(characterStyles->getByName("CharShadow-removed"), uno::UNO_QUERY_THROW); - aShadow = getProperty(xStyleProps, "CharShadowFormat"); - //CPPUNIT_ASSERT_EQUAL(table::ShadowLocation_NONE, aShadow.Location); - - uno::Reference xRun = getRun(getParagraph(1), 2, "style"); - aShadow = getProperty(xRun, "CharShadowFormat"); - //CPPUNIT_ASSERT_EQUAL(table::ShadowLocation_NONE, aShadow.Location); - - xRun.set(getRun(getParagraph(1), 4, "shadow")); - aShadow = getProperty(xRun, "CharShadowFormat"); - CPPUNIT_ASSERT_EQUAL(table::ShadowLocation_BOTTOM_RIGHT, aShadow.Location); - table::BorderLine2 aBorderLine = getProperty(xRun, "CharRightBorder"); - // MS formats can't have a shadow without a border. - // Char borders are all or none, so have to decide to add borders, or throw away shadow... - if (isExported()) + auto verify = [this]() { + uno::Reference paragraphStyles = getStyles("ParagraphStyles"); + uno::Reference xStyleProps(paragraphStyles->getByName("Border"), + uno::UNO_QUERY_THROW); + table::BorderLine2 aBorderLine + = getProperty(xStyleProps, "RightBorder"); CPPUNIT_ASSERT(sal_uInt32(0) != aBorderLine.LineWidth); + CPPUNIT_ASSERT_EQUAL_MESSAGE( + "The border style has normal black borders", COL_BLACK, + Color(ColorTransparency, + getProperty(xStyleProps, "RightBorder").Color)); - xRun.set(getRun(getParagraph(4), 2, "shadow")); - aShadow = getProperty(xRun, "CharShadowFormat"); - //CPPUNIT_ASSERT_EQUAL(table::ShadowLocation_NONE, aShadow.Location); - - xRun.set(getRun(getParagraph(9), 2, "End of test")); - aShadow = getProperty(xRun, "CharShadowFormat"); - CPPUNIT_ASSERT_EQUAL(table::ShadowLocation_BOTTOM_RIGHT, aShadow.Location); - aBorderLine = getProperty(xRun, "CharRightBorder"); - CPPUNIT_ASSERT(sal_uInt32(0) != aBorderLine.LineWidth); + aBorderLine = getProperty(getParagraph(2), "RightBorder"); + CPPUNIT_ASSERT(sal_uInt32(0) != aBorderLine.LineWidth); + CPPUNIT_ASSERT_EQUAL_MESSAGE( + "The second paragraph should have dark green borders", sal_Int32(432686), + getProperty(getParagraph(2), "RightBorder").Color); + }; + createSwDoc("tdf129631_lostBorders.rtf"); + verify(); + saveAndReload(mpFilter); + verify(); } -DECLARE_RTFEXPORT_TEST(testTdf136587_noStyleName, "tdf136587_noStyleName.rtf") +CPPUNIT_TEST_FIXTURE(Test, testTdf129522_removeShadowStyle) { - // An exception stopped all style definitions. - uno::Reference paragraphStyles = getStyles("ParagraphStyles"); - uno::Reference xStyleProps(paragraphStyles->getByName("Style15"), - uno::UNO_QUERY_THROW); - CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_CENTER), - getProperty(xStyleProps, "ParaAdjust")); + auto verify = [this]() { + CPPUNIT_ASSERT_EQUAL(1, getPages()); + uno::Reference paragraphStyles = getStyles("ParagraphStyles"); + uno::Reference xStyleProps(paragraphStyles->getByName("Shadow"), + uno::UNO_QUERY_THROW); + table::ShadowFormat aShadow + = getProperty(xStyleProps, "ParaShadowFormat"); + CPPUNIT_ASSERT_EQUAL(table::ShadowLocation_BOTTOM_RIGHT, aShadow.Location); + + // Shadows were inherited regardless of whether the style disabled them. + xStyleProps.set(paragraphStyles->getByName("Shadow-removed"), uno::UNO_QUERY_THROW); + aShadow = getProperty(xStyleProps, "ParaShadowFormat"); + //CPPUNIT_ASSERT_EQUAL(table::ShadowLocation_NONE, aShadow.Location); + + uno::Reference characterStyles = getStyles("CharacterStyles"); + xStyleProps.set(characterStyles->getByName("CharShadow"), uno::UNO_QUERY_THROW); + aShadow = getProperty(xStyleProps, "CharShadowFormat"); + CPPUNIT_ASSERT_EQUAL(table::ShadowLocation_BOTTOM_RIGHT, aShadow.Location); + + xStyleProps.set(characterStyles->getByName("CharShadow-removed"), uno::UNO_QUERY_THROW); + aShadow = getProperty(xStyleProps, "CharShadowFormat"); + //CPPUNIT_ASSERT_EQUAL(table::ShadowLocation_NONE, aShadow.Location); + + uno::Reference xRun = getRun(getParagraph(1), 2, "style"); + aShadow = getProperty(xRun, "CharShadowFormat"); + //CPPUNIT_ASSERT_EQUAL(table::ShadowLocation_NONE, aShadow.Location); + + xRun.set(getRun(getParagraph(1), 4, "shadow")); + aShadow = getProperty(xRun, "CharShadowFormat"); + CPPUNIT_ASSERT_EQUAL(table::ShadowLocation_BOTTOM_RIGHT, aShadow.Location); + table::BorderLine2 aBorderLine = getProperty(xRun, "CharRightBorder"); + // MS formats can't have a shadow without a border. + // Char borders are all or none, so have to decide to add borders, or throw away shadow... + if (isExported()) + CPPUNIT_ASSERT(sal_uInt32(0) != aBorderLine.LineWidth); + + xRun.set(getRun(getParagraph(4), 2, "shadow")); + aShadow = getProperty(xRun, "CharShadowFormat"); + //CPPUNIT_ASSERT_EQUAL(table::ShadowLocation_NONE, aShadow.Location); + + xRun.set(getRun(getParagraph(9), 2, "End of test")); + aShadow = getProperty(xRun, "CharShadowFormat"); + CPPUNIT_ASSERT_EQUAL(table::ShadowLocation_BOTTOM_RIGHT, aShadow.Location); + aBorderLine = getProperty(xRun, "CharRightBorder"); + CPPUNIT_ASSERT(sal_uInt32(0) != aBorderLine.LineWidth); + }; + createSwDoc("tdf129522_removeShadowStyle.odt"); + verify(); + saveAndReload(mpFilter); + verify(); +} - // The problem was that the default style wasn't imported at all, so the fontsize was only 12. - xStyleProps.set(paragraphStyles->getByName("Default Paragraph Style"), uno::UNO_QUERY_THROW); - CPPUNIT_ASSERT_EQUAL(32.0f, getProperty(xStyleProps, "CharHeight")); +CPPUNIT_TEST_FIXTURE(Test, testTdf136587_noStyleName) +{ + auto verify = [this]() { + // An exception stopped all style definitions. + uno::Reference paragraphStyles = getStyles("ParagraphStyles"); + uno::Reference xStyleProps(paragraphStyles->getByName("Style15"), + uno::UNO_QUERY_THROW); + CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_CENTER), + getProperty(xStyleProps, "ParaAdjust")); + + // The problem was that the default style wasn't imported at all, so the fontsize was only 12. + xStyleProps.set(paragraphStyles->getByName("Default Paragraph Style"), + uno::UNO_QUERY_THROW); + CPPUNIT_ASSERT_EQUAL(32.0f, getProperty(xStyleProps, "CharHeight")); + }; + createSwDoc("tdf136587_noStyleName.rtf"); + verify(); + saveAndReload(mpFilter); + verify(); } CPPUNIT_TEST_FIXTURE(Test, testPageBorder) @@ -533,16 +708,22 @@ CPPUNIT_TEST_FIXTURE(Test, testPageBorder) CPPUNIT_ASSERT_EQUAL(static_cast(71), aRightBorder.LineWidth); } -DECLARE_RTFEXPORT_TEST(testTbrlPage, "tbrl-page.rtf") +CPPUNIT_TEST_FIXTURE(Test, testTbrlPage) { - uno::Reference xPageStyle(getStyles("PageStyles")->getByName("Standard"), - uno::UNO_QUERY); - auto nActual = getProperty(xPageStyle, "WritingMode"); - // Without the accompanying fix in place, this test would have failed with: - // - Expected: 2 - // - Actual : 0 - // i.e. custom writing mode was lost. - CPPUNIT_ASSERT_EQUAL(text::WritingMode2::TB_RL, nActual); + auto verify = [this]() { + uno::Reference xPageStyle( + getStyles("PageStyles")->getByName("Standard"), uno::UNO_QUERY); + auto nActual = getProperty(xPageStyle, "WritingMode"); + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 2 + // - Actual : 0 + // i.e. custom writing mode was lost. + CPPUNIT_ASSERT_EQUAL(text::WritingMode2::TB_RL, nActual); + }; + createSwDoc("tbrl-page.rtf"); + verify(); + saveAndReload(mpFilter); + verify(); } CPPUNIT_TEST_FIXTURE(Test, testTdf126309) @@ -555,20 +736,26 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf126309) static_cast(getProperty(getParagraph(1), "ParaAdjust"))); } -DECLARE_RTFEXPORT_TEST(testTdf116358, "tdf116358.rtf") +CPPUNIT_TEST_FIXTURE(Test, testTdf116358) { - SwXTextDocument* pTextDoc = dynamic_cast(mxComponent.get()); - CPPUNIT_ASSERT(pTextDoc); - SwWrtShell* pWrtShell = pTextDoc->GetDocShell()->GetWrtShell(); - CPPUNIT_ASSERT(pWrtShell); - - // Insert a paragraph break - pWrtShell->SplitNode(false); - - // Entire table should go to page 2, no remains on first page - xmlDocUniquePtr pDump = parseLayoutDump(); - assertXPath(pDump, "/root/page[1]/body/tab"_ostr, 0); - assertXPath(pDump, "/root/page[2]/body/tab"_ostr, 1); + auto verify = [this]() { + SwXTextDocument* pTextDoc = dynamic_cast(mxComponent.get()); + CPPUNIT_ASSERT(pTextDoc); + SwWrtShell* pWrtShell = pTextDoc->GetDocShell()->GetWrtShell(); + CPPUNIT_ASSERT(pWrtShell); + + // Insert a paragraph break + pWrtShell->SplitNode(false); + + // Entire table should go to page 2, no remains on first page + xmlDocUniquePtr pDump = parseLayoutDump(); + assertXPath(pDump, "/root/page[1]/body/tab"_ostr, 0); + assertXPath(pDump, "/root/page[2]/body/tab"_ostr, 1); + }; + createSwDoc("tdf116358.rtf"); + verify(); + saveAndReload(mpFilter); + verify(); } CPPUNIT_TEST_FIXTURE(Test, testGutterLeft) @@ -632,207 +819,248 @@ CPPUNIT_TEST_FIXTURE(Test, testClearingBreak) verify(); } -DECLARE_RTFEXPORT_TEST(testTdf95706, "tdf95706.rtf") +CPPUNIT_TEST_FIXTURE(Test, testTdf95706) { - uno::Reference xRun2 - = getRun(getParagraph(2), 1, u"\u0104\u012e\u0100\u0106\u00c4"_ustr); - CPPUNIT_ASSERT_EQUAL(OUString("Arial"), getProperty(xRun2, "CharFontName")); - - uno::Reference xRun3 - = getRun(getParagraph(3), 1, u"\u0154\u00c1\u00c2\u0102\u00c4"_ustr); - CPPUNIT_ASSERT_EQUAL(OUString("Arial"), getProperty(xRun3, "CharFontName")); - - uno::Reference xRun4 - = getRun(getParagraph(4), 1, u"\u0410\u0411\u0412\u0413\u0414"_ustr); - CPPUNIT_ASSERT_EQUAL(OUString("Arial"), getProperty(xRun4, "CharFontName")); - - uno::Reference xRun5 - = getRun(getParagraph(5), 1, u"\u0390\u0391\u0392\u0393\u0394"_ustr); - CPPUNIT_ASSERT_EQUAL(OUString("Arial"), getProperty(xRun5, "CharFontName")); - - uno::Reference xRun6 - = getRun(getParagraph(6), 1, u"\u00c0\u00c1\u00c2\u00c3\u00c4"_ustr); - CPPUNIT_ASSERT_EQUAL(OUString("Arial"), getProperty(xRun6, "CharFontName")); - - uno::Reference xRun7 - = getRun(getParagraph(7), 1, u"\u05b0\u05b1\u05b2\u05b3\u05b4"_ustr); - // Do not check font for Hebrew: it can be substituted by smth able to handle these chars - //CPPUNIT_ASSERT_EQUAL(OUString("Arial"), getProperty(xRun7, "CharFontName")); - - uno::Reference xRun8 - = getRun(getParagraph(8), 1, u"\u06c1\u0621\u0622\u0623\u0624"_ustr); - // Do not check font for Arabic: it can be substituted by smth able to handle these chars - //CPPUNIT_ASSERT_EQUAL(OUString("Arial"), getProperty(xRun8, "CharFontName")); - - uno::Reference xRun9 - = getRun(getParagraph(9), 1, u"\u00c0\u00c1\u00c2\u0102\u00c4"_ustr); - CPPUNIT_ASSERT_EQUAL(OUString("Arial"), getProperty(xRun9, "CharFontName")); - - // Ensure strange font remains strange. No reason to check content: in this case it can vary on locale - uno::Reference xRun10 = getRun(getParagraph(10), 1); - CPPUNIT_ASSERT_EQUAL(OUString("Arial BlaBlaBla"), - getProperty(xRun10, "CharFontName")); - - uno::Reference xRun12 - = getRun(getParagraph(12), 1, u"\u0390\u0391\u0392\u0393\u0394"_ustr); - CPPUNIT_ASSERT_EQUAL(OUString("Arial"), getProperty(xRun12, "CharFontName")); - - uno::Reference xRun13 - = getRun(getParagraph(13), 1, u"\u0390\u0391\u0392\u0393\u0394"_ustr); - CPPUNIT_ASSERT_EQUAL(OUString("Arial"), getProperty(xRun13, "CharFontName")); - - uno::Reference xRun14 = getRun(getParagraph(14), 1); - CPPUNIT_ASSERT_EQUAL(OUString("Arial"), getProperty(xRun14, "CharFontName")); - - uno::Reference xRun15 - = getRun(getParagraph(15), 1, u"\u0104\u012e\u0100\u0106\u00c4"_ustr); - CPPUNIT_ASSERT_EQUAL(OUString("Arial"), getProperty(xRun15, "CharFontName")); - - uno::Reference xRun16 - = getRun(getParagraph(16), 1, u"\u0104\u012e\u0100\u0106\u00c4"_ustr); - CPPUNIT_ASSERT_EQUAL(OUString("Arial"), getProperty(xRun16, "CharFontName")); + auto verify = [this]() { + uno::Reference xRun2 + = getRun(getParagraph(2), 1, u"\u0104\u012e\u0100\u0106\u00c4"_ustr); + CPPUNIT_ASSERT_EQUAL(OUString("Arial"), getProperty(xRun2, "CharFontName")); + + uno::Reference xRun3 + = getRun(getParagraph(3), 1, u"\u0154\u00c1\u00c2\u0102\u00c4"_ustr); + CPPUNIT_ASSERT_EQUAL(OUString("Arial"), getProperty(xRun3, "CharFontName")); + + uno::Reference xRun4 + = getRun(getParagraph(4), 1, u"\u0410\u0411\u0412\u0413\u0414"_ustr); + CPPUNIT_ASSERT_EQUAL(OUString("Arial"), getProperty(xRun4, "CharFontName")); + + uno::Reference xRun5 + = getRun(getParagraph(5), 1, u"\u0390\u0391\u0392\u0393\u0394"_ustr); + CPPUNIT_ASSERT_EQUAL(OUString("Arial"), getProperty(xRun5, "CharFontName")); + + uno::Reference xRun6 + = getRun(getParagraph(6), 1, u"\u00c0\u00c1\u00c2\u00c3\u00c4"_ustr); + CPPUNIT_ASSERT_EQUAL(OUString("Arial"), getProperty(xRun6, "CharFontName")); + + uno::Reference xRun7 + = getRun(getParagraph(7), 1, u"\u05b0\u05b1\u05b2\u05b3\u05b4"_ustr); + // Do not check font for Hebrew: it can be substituted by smth able to handle these chars + //CPPUNIT_ASSERT_EQUAL(OUString("Arial"), getProperty(xRun7, "CharFontName")); + + uno::Reference xRun8 + = getRun(getParagraph(8), 1, u"\u06c1\u0621\u0622\u0623\u0624"_ustr); + // Do not check font for Arabic: it can be substituted by smth able to handle these chars + //CPPUNIT_ASSERT_EQUAL(OUString("Arial"), getProperty(xRun8, "CharFontName")); + + uno::Reference xRun9 + = getRun(getParagraph(9), 1, u"\u00c0\u00c1\u00c2\u0102\u00c4"_ustr); + CPPUNIT_ASSERT_EQUAL(OUString("Arial"), getProperty(xRun9, "CharFontName")); + + // Ensure strange font remains strange. No reason to check content: in this case it can vary on locale + uno::Reference xRun10 = getRun(getParagraph(10), 1); + CPPUNIT_ASSERT_EQUAL(OUString("Arial BlaBlaBla"), + getProperty(xRun10, "CharFontName")); + + uno::Reference xRun12 + = getRun(getParagraph(12), 1, u"\u0390\u0391\u0392\u0393\u0394"_ustr); + CPPUNIT_ASSERT_EQUAL(OUString("Arial"), getProperty(xRun12, "CharFontName")); + + uno::Reference xRun13 + = getRun(getParagraph(13), 1, u"\u0390\u0391\u0392\u0393\u0394"_ustr); + CPPUNIT_ASSERT_EQUAL(OUString("Arial"), getProperty(xRun13, "CharFontName")); + + uno::Reference xRun14 = getRun(getParagraph(14), 1); + CPPUNIT_ASSERT_EQUAL(OUString("Arial"), getProperty(xRun14, "CharFontName")); + + uno::Reference xRun15 + = getRun(getParagraph(15), 1, u"\u0104\u012e\u0100\u0106\u00c4"_ustr); + CPPUNIT_ASSERT_EQUAL(OUString("Arial"), getProperty(xRun15, "CharFontName")); + + uno::Reference xRun16 + = getRun(getParagraph(16), 1, u"\u0104\u012e\u0100\u0106\u00c4"_ustr); + CPPUNIT_ASSERT_EQUAL(OUString("Arial"), getProperty(xRun16, "CharFontName")); + }; + createSwDoc("tdf95706.rtf"); + verify(); + saveAndReload(mpFilter); + verify(); } -DECLARE_RTFEXPORT_TEST(testTdf95706_2, "tdf95706_2.rtf") +CPPUNIT_TEST_FIXTURE(Test, testTdf95706_2) { - CPPUNIT_ASSERT_EQUAL(OUString("Arial"), - getProperty(getRun(getParagraph(1), 1), "CharFontName")); - CPPUNIT_ASSERT_EQUAL(OUString("Impact"), - getProperty(getRun(getParagraph(2), 1), "CharFontName")); - CPPUNIT_ASSERT_EQUAL(OUString("Times New Roman"), - getProperty(getRun(getParagraph(3), 1), "CharFontName")); - CPPUNIT_ASSERT_EQUAL(OUString("Tahoma"), - getProperty(getRun(getParagraph(4), 1), "CharFontName")); + auto verify = [this]() { + CPPUNIT_ASSERT_EQUAL(OUString("Arial"), + getProperty(getRun(getParagraph(1), 1), "CharFontName")); + CPPUNIT_ASSERT_EQUAL(OUString("Impact"), + getProperty(getRun(getParagraph(2), 1), "CharFontName")); + CPPUNIT_ASSERT_EQUAL(OUString("Times New Roman"), + getProperty(getRun(getParagraph(3), 1), "CharFontName")); + CPPUNIT_ASSERT_EQUAL(OUString("Tahoma"), + getProperty(getRun(getParagraph(4), 1), "CharFontName")); + }; + createSwDoc("tdf95706_2.rtf"); + verify(); + saveAndReload(mpFilter); + verify(); } -DECLARE_RTFEXPORT_TEST(testTdf111851, "tdf111851.rtf") +CPPUNIT_TEST_FIXTURE(Test, testTdf111851) { - uno::Reference xTable(getParagraphOrTable(1), uno::UNO_QUERY); - - // No shading - uno::Reference xCell1(xTable->getCellByName("A1"), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(OUString("a"), xCell1->getString()); - CPPUNIT_ASSERT_EQUAL(COL_TRANSPARENT, getProperty(xCell1, "BackColor")); - - uno::Reference xCell2(xTable->getCellByName("B1"), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(OUString("b"), xCell2->getString()); - CPPUNIT_ASSERT_EQUAL(COL_TRANSPARENT, getProperty(xCell2, "BackColor")); - - // Check some random not standard shading values and ensure some non-white background color - uno::Reference xCell3(xTable->getCellByName("C1"), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(OUString("c"), xCell3->getString()); - Color nShadingColor3 = getProperty(xCell3, "BackColor"); - CPPUNIT_ASSERT(COL_WHITE > nShadingColor3); - CPPUNIT_ASSERT(COL_BLACK < nShadingColor3); - - uno::Reference xCell4(xTable->getCellByName("D1"), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(OUString("d"), xCell4->getString()); - Color nShadingColor4 = getProperty(xCell4, "BackColor"); - CPPUNIT_ASSERT(COL_WHITE > nShadingColor4); - CPPUNIT_ASSERT(COL_BLACK < nShadingColor4); + auto verify = [this]() { + uno::Reference xTable(getParagraphOrTable(1), uno::UNO_QUERY); + + // No shading + uno::Reference xCell1(xTable->getCellByName("A1"), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("a"), xCell1->getString()); + CPPUNIT_ASSERT_EQUAL(COL_TRANSPARENT, getProperty(xCell1, "BackColor")); + + uno::Reference xCell2(xTable->getCellByName("B1"), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("b"), xCell2->getString()); + CPPUNIT_ASSERT_EQUAL(COL_TRANSPARENT, getProperty(xCell2, "BackColor")); + + // Check some random not standard shading values and ensure some non-white background color + uno::Reference xCell3(xTable->getCellByName("C1"), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("c"), xCell3->getString()); + Color nShadingColor3 = getProperty(xCell3, "BackColor"); + CPPUNIT_ASSERT(COL_WHITE > nShadingColor3); + CPPUNIT_ASSERT(COL_BLACK < nShadingColor3); + + uno::Reference xCell4(xTable->getCellByName("D1"), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("d"), xCell4->getString()); + Color nShadingColor4 = getProperty(xCell4, "BackColor"); + CPPUNIT_ASSERT(COL_WHITE > nShadingColor4); + CPPUNIT_ASSERT(COL_BLACK < nShadingColor4); + + // Values 10000 and more - black + uno::Reference xCell5(xTable->getCellByName("E1"), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("e"), xCell5->getString()); + CPPUNIT_ASSERT_EQUAL(COL_BLACK, getProperty(xCell5, "BackColor")); + + uno::Reference xCell6(xTable->getCellByName("F1"), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("f"), xCell6->getString()); + CPPUNIT_ASSERT_EQUAL(COL_BLACK, getProperty(xCell6, "BackColor")); + }; + createSwDoc("tdf111851.rtf"); + verify(); + saveAndReload(mpFilter); + verify(); +} - // Values 10000 and more - black - uno::Reference xCell5(xTable->getCellByName("E1"), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(OUString("e"), xCell5->getString()); - CPPUNIT_ASSERT_EQUAL(COL_BLACK, getProperty(xCell5, "BackColor")); +CPPUNIT_TEST_FIXTURE(Test, testTdf139948) +{ + auto verify = [this]() { + CPPUNIT_ASSERT_EQUAL( + sal_uInt32(0), + getProperty(getParagraph(1, "No border"), "TopBorder").LineWidth); + CPPUNIT_ASSERT_EQUAL(sal_uInt32(0), getProperty( + getParagraph(2, "Border below"), "TopBorder") + .LineWidth); + CPPUNIT_ASSERT_EQUAL( + sal_uInt32(88), + getProperty(getParagraph(3, "Borders below and above"), "TopBorder") + .LineWidth); + CPPUNIT_ASSERT_EQUAL(sal_uInt32(88), getProperty( + getParagraph(4, "Border above"), "TopBorder") + .LineWidth); + CPPUNIT_ASSERT_EQUAL( + sal_uInt32(0), + getProperty(getParagraph(5, "No border"), "TopBorder").LineWidth); + + // And let's ensure that there are no other horizontal borders + CPPUNIT_ASSERT_EQUAL( + sal_uInt32(0), + getProperty(getParagraph(1), "BottomBorder").LineWidth); + CPPUNIT_ASSERT_EQUAL( + sal_uInt32(0), + getProperty(getParagraph(2), "BottomBorder").LineWidth); + CPPUNIT_ASSERT_EQUAL( + sal_uInt32(0), + getProperty(getParagraph(3), "BottomBorder").LineWidth); + CPPUNIT_ASSERT_EQUAL( + sal_uInt32(0), + getProperty(getParagraph(4), "BottomBorder").LineWidth); + CPPUNIT_ASSERT_EQUAL( + sal_uInt32(0), + getProperty(getParagraph(5), "BottomBorder").LineWidth); + }; + createSwDoc("tdf139948.rtf"); + verify(); + saveAndReload(mpFilter); + verify(); +} - uno::Reference xCell6(xTable->getCellByName("F1"), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(OUString("f"), xCell6->getString()); - CPPUNIT_ASSERT_EQUAL(COL_BLACK, getProperty(xCell6, "BackColor")); +CPPUNIT_TEST_FIXTURE(Test, testTdf103956) +{ + auto verify = [this]() { + // Ensure that RTF tables without column width (\cellx or \cellx0) are displayed with some + // suitable width. Currently there is no good support for autofit for RTF docs, so ensure + // that table cells are somehow visible. Width for it is not clear, so here we will check + // table & cell widths are more than default minimal value of 41. + CPPUNIT_ASSERT_MESSAGE( + "Table #1 is too narrow!", + 82 < parseDump("/root/page/body/tab[1]/row/infos/bounds"_ostr, "width"_ostr).toInt32()); + CPPUNIT_ASSERT_MESSAGE( + "Table #1 cell#1 is too narrow!", + 41 < parseDump("/root/page/body/tab[1]/row/cell[1]/infos/bounds"_ostr, "width"_ostr) + .toInt32()); + CPPUNIT_ASSERT_MESSAGE( + "Table #1 cell#2 is too narrow!", + 41 < parseDump("/root/page/body/tab[1]/row/cell[2]/infos/bounds"_ostr, "width"_ostr) + .toInt32()); + + CPPUNIT_ASSERT_MESSAGE( + "Table #2 is too narrow!", + 82 < parseDump("/root/page/body/tab[2]/row/infos/bounds"_ostr, "width"_ostr).toInt32()); + CPPUNIT_ASSERT_MESSAGE( + "Table #2 cell#1 is too narrow!", + 41 < parseDump("/root/page/body/tab[2]/row/cell[1]/infos/bounds"_ostr, "width"_ostr) + .toInt32()); + CPPUNIT_ASSERT_MESSAGE( + "Table #2 cell#2 is too narrow!", + 41 < parseDump("/root/page/body/tab[2]/row/cell[2]/infos/bounds"_ostr, "width"_ostr) + .toInt32()); + + CPPUNIT_ASSERT_MESSAGE( + "Table #3 is too narrow!", + 82 < parseDump("/root/page/body/tab[3]/row/infos/bounds"_ostr, "width"_ostr).toInt32()); + CPPUNIT_ASSERT_MESSAGE( + "Table #3 cell#1 is too narrow!", + 41 < parseDump("/root/page/body/tab[3]/row/cell[1]/infos/bounds"_ostr, "width"_ostr) + .toInt32()); + CPPUNIT_ASSERT_MESSAGE( + "Table #3 cell#2 is too narrow!", + 41 < parseDump("/root/page/body/tab[3]/row/cell[2]/infos/bounds"_ostr, "width"_ostr) + .toInt32()); + }; + createSwDoc("tdf103956.rtf"); + verify(); + saveAndReload(mpFilter); + verify(); } -DECLARE_RTFEXPORT_TEST(testTdf139948, "tdf139948.rtf") +CPPUNIT_TEST_FIXTURE(Test, testTdf148515) { - CPPUNIT_ASSERT_EQUAL( - sal_uInt32(0), - getProperty(getParagraph(1, "No border"), "TopBorder").LineWidth); - CPPUNIT_ASSERT_EQUAL( - sal_uInt32(0), - getProperty(getParagraph(2, "Border below"), "TopBorder").LineWidth); - CPPUNIT_ASSERT_EQUAL( - sal_uInt32(88), - getProperty(getParagraph(3, "Borders below and above"), "TopBorder") - .LineWidth); - CPPUNIT_ASSERT_EQUAL( - sal_uInt32(88), - getProperty(getParagraph(4, "Border above"), "TopBorder").LineWidth); - CPPUNIT_ASSERT_EQUAL( - sal_uInt32(0), - getProperty(getParagraph(5, "No border"), "TopBorder").LineWidth); + auto verify = [this]() { + uno::Reference xTable(getParagraphOrTable(1), uno::UNO_QUERY); - // And let's ensure that there are no other horizontal borders - CPPUNIT_ASSERT_EQUAL( - sal_uInt32(0), getProperty(getParagraph(1), "BottomBorder").LineWidth); - CPPUNIT_ASSERT_EQUAL( - sal_uInt32(0), getProperty(getParagraph(2), "BottomBorder").LineWidth); - CPPUNIT_ASSERT_EQUAL( - sal_uInt32(0), getProperty(getParagraph(3), "BottomBorder").LineWidth); - CPPUNIT_ASSERT_EQUAL( - sal_uInt32(0), getProperty(getParagraph(4), "BottomBorder").LineWidth); - CPPUNIT_ASSERT_EQUAL( - sal_uInt32(0), getProperty(getParagraph(5), "BottomBorder").LineWidth); -} - -DECLARE_RTFEXPORT_TEST(testTdf103956, "tdf103956.rtf") -{ - // Ensure that RTF tables without column width (\cellx or \cellx0) are displayed with some - // suitable width. Currently there is no good support for autofit for RTF docs, so ensure - // that table cells are somehow visible. Width for it is not clear, so here we will check - // table & cell widths are more than default minimal value of 41. - CPPUNIT_ASSERT_MESSAGE( - "Table #1 is too narrow!", - 82 < parseDump("/root/page/body/tab[1]/row/infos/bounds"_ostr, "width"_ostr).toInt32()); - CPPUNIT_ASSERT_MESSAGE( - "Table #1 cell#1 is too narrow!", - 41 < parseDump("/root/page/body/tab[1]/row/cell[1]/infos/bounds"_ostr, "width"_ostr) - .toInt32()); - CPPUNIT_ASSERT_MESSAGE( - "Table #1 cell#2 is too narrow!", - 41 < parseDump("/root/page/body/tab[1]/row/cell[2]/infos/bounds"_ostr, "width"_ostr) - .toInt32()); - - CPPUNIT_ASSERT_MESSAGE( - "Table #2 is too narrow!", - 82 < parseDump("/root/page/body/tab[2]/row/infos/bounds"_ostr, "width"_ostr).toInt32()); - CPPUNIT_ASSERT_MESSAGE( - "Table #2 cell#1 is too narrow!", - 41 < parseDump("/root/page/body/tab[2]/row/cell[1]/infos/bounds"_ostr, "width"_ostr) - .toInt32()); - CPPUNIT_ASSERT_MESSAGE( - "Table #2 cell#2 is too narrow!", - 41 < parseDump("/root/page/body/tab[2]/row/cell[2]/infos/bounds"_ostr, "width"_ostr) - .toInt32()); - - CPPUNIT_ASSERT_MESSAGE( - "Table #3 is too narrow!", - 82 < parseDump("/root/page/body/tab[3]/row/infos/bounds"_ostr, "width"_ostr).toInt32()); - CPPUNIT_ASSERT_MESSAGE( - "Table #3 cell#1 is too narrow!", - 41 < parseDump("/root/page/body/tab[3]/row/cell[1]/infos/bounds"_ostr, "width"_ostr) - .toInt32()); - CPPUNIT_ASSERT_MESSAGE( - "Table #3 cell#2 is too narrow!", - 41 < parseDump("/root/page/body/tab[3]/row/cell[2]/infos/bounds"_ostr, "width"_ostr) - .toInt32()); -} - -DECLARE_RTFEXPORT_TEST(testTdf148515, "tdf148515.rtf") -{ - uno::Reference xTable(getParagraphOrTable(1), uno::UNO_QUERY); - - uno::Reference xCell1(xTable->getCellByName("A1"), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(OUString("XXXXXX"), xCell1->getString()); - CPPUNIT_ASSERT_EQUAL( - 5.0f, - getProperty(getRun(getParagraphOfText(1, xCell1->getText()), 1), "CharHeight")); + uno::Reference xCell1(xTable->getCellByName("A1"), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("XXXXXX"), xCell1->getString()); + CPPUNIT_ASSERT_EQUAL( + 5.0f, + getProperty(getRun(getParagraphOfText(1, xCell1->getText()), 1), "CharHeight")); - uno::Reference xCell2(xTable->getCellByName("B1"), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(OUString(""), xCell2->getString()); - CPPUNIT_ASSERT_EQUAL( - 5.0f, - getProperty(getRun(getParagraphOfText(1, xCell2->getText()), 1), "CharHeight")); + uno::Reference xCell2(xTable->getCellByName("B1"), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString(""), xCell2->getString()); + CPPUNIT_ASSERT_EQUAL( + 5.0f, + getProperty(getRun(getParagraphOfText(1, xCell2->getText()), 1), "CharHeight")); - CPPUNIT_ASSERT_EQUAL(10.f, getProperty(getRun(getParagraph(2), 1), "CharHeight")); + CPPUNIT_ASSERT_EQUAL(10.f, getProperty(getRun(getParagraph(2), 1), "CharHeight")); + }; + createSwDoc("tdf148515.rtf"); + verify(); + saveAndReload(mpFilter); + verify(); } } // end of anonymous namespace -- cgit v1.2.3