diff --git a/sc/qa/unit/data/xlsx/RowImportCellStyleIssue.xlsx b/sc/qa/unit/data/xlsx/RowImportCellStyleIssue.xlsx new file mode 100644 index 000000000000..980cdd35a0d6 Binary files /dev/null and b/sc/qa/unit/data/xlsx/RowImportCellStyleIssue.xlsx differ diff --git a/sc/qa/unit/subsequent_filters_test4.cxx b/sc/qa/unit/subsequent_filters_test4.cxx index ae5c7ff7e4da..4439b3d9ba97 100644 --- a/sc/qa/unit/subsequent_filters_test4.cxx +++ b/sc/qa/unit/subsequent_filters_test4.cxx @@ -26,6 +26,8 @@ #include #include #include +#include +#include #include #include #include @@ -69,20 +71,20 @@ using namespace ::com::sun::star::uno; class ScFiltersTest4 : public ScModelTestBase { public: - ScFiltersTest4(); + ScFiltersTest4() + : ScModelTestBase("sc/qa/unit/data") + { + } protected: - void testImportCrash(const char* rFileName); + void testImportCrash(const char* rFileName) + { + createScDoc(rFileName); + ScDocument* pDoc = getScDoc(); + pDoc->CalcAll(); // perform hard re-calculation. + } }; -void ScFiltersTest4::testImportCrash(const char* rFileName) -{ - createScDoc(rFileName); - - ScDocument* pDoc = getScDoc(); - pDoc->CalcAll(); // perform hard re-calculation. -} - CPPUNIT_TEST_FIXTURE(ScFiltersTest4, testPasswordNew) { //tests opening a file with new password algorithm @@ -1944,9 +1946,32 @@ CPPUNIT_TEST_FIXTURE(ScFiltersTest4, testTdf142905) CPPUNIT_ASSERT_EQUAL(OUString(" 3M "), pDoc->GetString(2, 0, 0)); } -ScFiltersTest4::ScFiltersTest4() - : ScModelTestBase("sc/qa/unit/data") +CPPUNIT_TEST_FIXTURE(ScFiltersTest4, testRowImportCellStyleIssue) { + // Test checks that the correct cell style is imported for the first 6 rows and then the rest of the rows. + // Row 1 to 6 have no background color, after that light2 (background2) theme color. + + createScDoc("xlsx/RowImportCellStyleIssue.xlsx"); + ScDocument* pDoc = getScDoc(); + + // Check cell A6 - should have no background color set + { + const ScPatternAttr* pAttr = pDoc->GetPattern(0, 5, 0); // A6 + const SfxPoolItem& rItem = pAttr->GetItem(ATTR_BACKGROUND); + const SvxBrushItem& rBackground = static_cast(rItem); + CPPUNIT_ASSERT_EQUAL(false, rBackground.isUsed()); + } + + // Check cell A7 - should have light2 (background2) theme color set + { + const ScPatternAttr* pAttr = pDoc->GetPattern(0, 6, 0); // A7 + const SfxPoolItem& rItem = pAttr->GetItem(ATTR_BACKGROUND); + const SvxBrushItem& rBackground = static_cast(rItem); + CPPUNIT_ASSERT_EQUAL(true, rBackground.isUsed()); + CPPUNIT_ASSERT_EQUAL(Color(0xe7e6e6), rBackground.GetColor()); + auto const& rComplexColor = rBackground.getComplexColor(); + CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Light2, rComplexColor.getThemeColorType()); + } } CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sc/subsequent_setup.mk b/sc/subsequent_setup.mk index 6847aca1a775..4cf9b34f984e 100644 --- a/sc/subsequent_setup.mk +++ b/sc/subsequent_setup.mk @@ -30,6 +30,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sc_subsequent_$(1), \ cppu \ cppuhelper \ drawinglayer \ + docmodel \ editeng \ for \ forui \