sc/qa/unit/subsequent_filters_test2.cxx | 38 ++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+)
New commits: commit 3275f57221904426e5c136f5596a83050f8585a4 Author: Henry Castro <hcas...@collabora.com> AuthorDate: Fri Nov 24 10:00:54 2023 -0400 Commit: Henry Castro <hcas...@collabora.com> CommitDate: Wed Nov 29 20:54:34 2023 +0100 sc: qa: add unit test "testBackColorFilter" Change-Id: Icdccd6778d1157bb31f38b510a58562a640bdeae Signed-off-by: Henry Castro <hcas...@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159929 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160089 Tested-by: Jenkins diff --git a/sc/qa/unit/subsequent_filters_test2.cxx b/sc/qa/unit/subsequent_filters_test2.cxx index 790ab5c99057..22339c010e8f 100644 --- a/sc/qa/unit/subsequent_filters_test2.cxx +++ b/sc/qa/unit/subsequent_filters_test2.cxx @@ -27,6 +27,8 @@ #include <editeng/justifyitem.hxx> #include <editeng/lineitem.hxx> #include <editeng/colritem.hxx> +#include <cellvalue.hxx> +#include <docpool.hxx> #include <dbdata.hxx> #include <validat.hxx> #include <formulacell.hxx> @@ -39,6 +41,7 @@ #include <columnspanset.hxx> #include <tokenstringcontext.hxx> #include <externalrefmgr.hxx> +#include <filterentries.hxx> #include <com/sun/star/drawing/XDrawPageSupplier.hpp> #include <com/sun/star/sheet/XSpreadsheetDocument.hpp> @@ -1626,6 +1629,41 @@ CPPUNIT_TEST_FIXTURE(ScFiltersTest2, testSingleLine) testCells(pDoc); } +CPPUNIT_TEST_FIXTURE(ScFiltersTest2, testBackColorFilter) +{ + Color aBackColor1(0xc99c00); + Color aBackColor2(0x0369a3); + + createScDoc(); + ScDocument* pDoc = getScDoc(); + + ScPatternAttr aPattern1(pDoc->GetPool()); + aPattern1.GetItemSet().Put(SvxBrushItem(aBackColor1, ATTR_BACKGROUND)); + + ScPatternAttr aPattern2(pDoc->GetPool()); + aPattern2.GetItemSet().Put(SvxBrushItem(aBackColor2, ATTR_BACKGROUND)); + + // Apply the pattern to cell A1:A2 + pDoc->ApplyPatternAreaTab(0, 0, 0, 1, 0, aPattern1); + + // Apply the pattern to cell A3:A5 + pDoc->ApplyPatternAreaTab(0, 2, 0, 4, 0, aPattern2); + + { + ScRefCellValue aCell; + aCell.assign(*pDoc, ScAddress(0, 0, 0)); + CPPUNIT_ASSERT_MESSAGE("Cell A1 should be empty.", aCell.isEmpty()); + aCell.assign(*pDoc, ScAddress(0, 2, 0)); + CPPUNIT_ASSERT_MESSAGE("Cell A3 should be empty.", aCell.isEmpty()); + } + + { + ScFilterEntries aFilterEntries; + pDoc->GetFilterEntriesArea(0, 0, 4, 0, true, aFilterEntries); + CPPUNIT_ASSERT_EQUAL(size_t(2), aFilterEntries.getBackgroundColors().size()); + } +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */