sc: Check against reference also in testPivotTableFormatsGrandTotal

The testPivotTableFormatsGrandTotal still used checking specific
cells for background and font color, while most other tests use
checking against the reference that is contained in the document.
This changes the test and also modifies the document to put the
reference at the position that is expected and standard in other
test documents (one empty row between the pivot table end and
reference start).

Change-Id: Id309e998a8527e2cf1fe246917780cbd77beec5f
Reviewed-on: https://gerrit.collaboraoffice.com/c/online/+/2734
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins CPCI <releng@collaboraoffice.com>
(cherry picked from commit 4b8061eedcf1944131fde98724ec0ee9d4b9709c)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/205788
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Tested-by: Jenkins
This commit is contained in:
Tomaž Vajngerl
2026-05-28 09:35:01 +02:00
committed by Xisco Fauli
parent 6afc54463c
commit 296f2ce19c
2 changed files with 3 additions and 37 deletions
+3 -37
View File
@@ -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();