diff --git a/sc/qa/unit/PivotTableFormatsImportExport.cxx b/sc/qa/unit/PivotTableFormatsImportExport.cxx index 936df5b0866a..e107d6344db8 100644 --- a/sc/qa/unit/PivotTableFormatsImportExport.cxx +++ b/sc/qa/unit/PivotTableFormatsImportExport.cxx @@ -43,13 +43,6 @@ ScAddress parseAddress(const ScDocument& rDoc, OUString const& rAddressString) return aAddress; } -Color getBackgroundColor(const ScDocument& rDoc, OUString const& rAddressString) -{ - const ScPatternAttr* pPattern = rDoc.GetPattern(parseAddress(rDoc, rAddressString)); - const SvxBrushItem& rItem = pPattern->GetItem(ATTR_BACKGROUND); - return rItem.GetColor(); -} - /** Compare pivot table output against Excel reference output below. * The reference area starts 1 row after the pivot table ends. * Returns empty string if all cells match, otherwise lists mismatches. */ @@ -387,39 +380,12 @@ CPPUNIT_TEST_FIXTURE(ScPivotTableFormatsImportExport, testPivotTableWithNoSource CPPUNIT_TEST_FIXTURE(ScPivotTableFormatsImportExport, testPivotTableFormatsGrandTotal) { - // Check that we can support pivot table cell formats on grand total output. - - // In the file: pivot table is at B3:G14, reference output is at B17:G28. createScDoc("xlsx/pivot-table/PivotTableFormatsGrandTotal.xlsx"); - auto checkFormats = [this]() { ScDocument& rDocument = *getScDoc(); - - CPPUNIT_ASSERT_EQUAL(Color(0x00B050), getBackgroundColor(rDocument, u"G4"_ustr)); - CPPUNIT_ASSERT(Color(0x00B050) != getBackgroundColor(rDocument, u"G3"_ustr)); - CPPUNIT_ASSERT(Color(0x00B050) != getBackgroundColor(rDocument, u"G5"_ustr)); - CPPUNIT_ASSERT(Color(0x00B050) != getBackgroundColor(rDocument, u"F4"_ustr)); - - // grandRow="1" labelOnly="1" offset="A256" - CPPUNIT_ASSERT_EQUAL(Color(0xC00000), getBackgroundColor(rDocument, u"B14"_ustr)); - - // grandRow="1" labelOnly="1" offset="IV256" - CPPUNIT_ASSERT_EQUAL(Color(0xFFFF00), getBackgroundColor(rDocument, u"C14"_ustr)); - - // grandRow="1" grandCol="1" - intersection - CPPUNIT_ASSERT_EQUAL(Color(0x00B0F0), getBackgroundColor(rDocument, u"G14"_ustr)); - - // grandRow="1" data with reference field="2" selected="0" - CPPUNIT_ASSERT_EQUAL(Color(0x92D050), getBackgroundColor(rDocument, u"E14"_ustr)); - CPPUNIT_ASSERT(Color(0x92D050) != getBackgroundColor(rDocument, u"D14"_ustr)); - CPPUNIT_ASSERT(Color(0x92D050) != getBackgroundColor(rDocument, u"F14"_ustr)); - - // grandCol="1" data with subtotal reference - CPPUNIT_ASSERT_EQUAL(Color(0x0070C0), getBackgroundColor(rDocument, u"G5"_ustr)); - CPPUNIT_ASSERT_EQUAL(Color(0x0070C0), getBackgroundColor(rDocument, u"G6"_ustr)); - CPPUNIT_ASSERT_EQUAL(Color(0x0070C0), getBackgroundColor(rDocument, u"G7"_ustr)); - CPPUNIT_ASSERT_EQUAL(Color(0x0070C0), getBackgroundColor(rDocument, u"G8"_ustr)); - CPPUNIT_ASSERT(Color(0x0070C0) != getBackgroundColor(rDocument, u"G9"_ustr)); + auto[aPivotRange, aReferenceRange] = getPivotAndReferenceRanges(rDocument); + OUString aMismatches = comparePivotWithReference(rDocument, aPivotRange, aReferenceRange); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell format mismatches found", OUString(), aMismatches); }; checkFormats(); diff --git a/sc/qa/unit/data/xlsx/pivot-table/PivotTableFormatsGrandTotal.xlsx b/sc/qa/unit/data/xlsx/pivot-table/PivotTableFormatsGrandTotal.xlsx index c2f50f523dda..757690bddc70 100644 Binary files a/sc/qa/unit/data/xlsx/pivot-table/PivotTableFormatsGrandTotal.xlsx and b/sc/qa/unit/data/xlsx/pivot-table/PivotTableFormatsGrandTotal.xlsx differ