summaryrefslogtreecommitdiff
path: root/sc/qa
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2022-03-04 14:18:02 +0100
committerLuboš Luňák <l.lunak@collabora.com>2022-03-23 09:09:07 +0100
commitffbd9053b85b6b22b2401ac20ef0244acd55f244 (patch)
tree664c21ca1ae2158c7233b1b1ed1539aeaa3d7f2e /sc/qa
parentc4077e840ba8983076ef77927b7b47ddb88e44aa (diff)
set properly attributes for cells in unallocated Calc columns
ScTable::ApplySelectionCache() was setting attributes only for allocated columns, so e.g. selecting a whole column and making it bold didn't actually set all of it bold. Make sure it set it for all columns, and make use of the default attribute for unallocated columns to avoid allocating columns just to set them the same attribute. Change-Id: Ie9886317d7a91c6a43951af69b717f9ba32a1c9e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130984 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
Diffstat (limited to 'sc/qa')
-rw-r--r--sc/qa/unit/uicalc/uicalc.cxx41
1 files changed, 41 insertions, 0 deletions
diff --git a/sc/qa/unit/uicalc/uicalc.cxx b/sc/qa/unit/uicalc/uicalc.cxx
index beaf837bf1a4..7a92f711cb13 100644
--- a/sc/qa/unit/uicalc/uicalc.cxx
+++ b/sc/qa/unit/uicalc/uicalc.cxx
@@ -1964,6 +1964,47 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf126926)
CPPUNIT_ASSERT(pDBs->empty());
}
+CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testUnallocatedColumnsAttributes)
+{
+ mxComponent = loadFromDesktop("private:factory/scalc");
+ ScModelObj* pModelObj = dynamic_cast<ScModelObj*>(mxComponent.get());
+ CPPUNIT_ASSERT(pModelObj);
+ ScDocument* pDoc = pModelObj->GetDocument();
+ CPPUNIT_ASSERT(pDoc);
+
+ // If this check fails, this entire test needs adjusting.
+ CPPUNIT_ASSERT_EQUAL(SCCOL(64), pDoc->GetAllocatedColumnsCount(0));
+
+ // Except for first 10 cells make the entire first row bold.
+ goToCell("K1:" + pDoc->MaxColAsString() + "1");
+ dispatchCommand(mxComponent, ".uno:Bold", {});
+
+ // That shouldn't need allocating more columns, just changing the default attribute.
+ CPPUNIT_ASSERT_EQUAL(SCCOL(64), pDoc->GetAllocatedColumnsCount(0));
+ vcl::Font aFont;
+ pDoc->GetPattern(pDoc->MaxCol(), 0, 0)->GetFont(aFont, SC_AUTOCOL_RAW);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("font should be bold", WEIGHT_BOLD, aFont.GetWeight());
+
+ goToCell("A2:CV2"); // first 100 cells in row 2
+ dispatchCommand(mxComponent, ".uno:Bold", {});
+ // These need to be explicitly allocated.
+ CPPUNIT_ASSERT_EQUAL(SCCOL(100), pDoc->GetAllocatedColumnsCount(0));
+ pDoc->GetPattern(99, 1, 0)->GetFont(aFont, SC_AUTOCOL_RAW);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("font should be bold", WEIGHT_BOLD, aFont.GetWeight());
+ pDoc->GetPattern(100, 1, 0)->GetFont(aFont, SC_AUTOCOL_RAW);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("font should not be bold", WEIGHT_NORMAL, aFont.GetWeight());
+
+ goToCell("CW3:" + pDoc->MaxColAsString() + "3"); // All but first 100 cells in row 3.
+ dispatchCommand(mxComponent, ".uno:Bold", {});
+ // First 100 columns need to be allocated to not be bold, the rest should be handled
+ // by the default attribute.
+ CPPUNIT_ASSERT_EQUAL(SCCOL(100), pDoc->GetAllocatedColumnsCount(0));
+ pDoc->GetPattern(99, 2, 0)->GetFont(aFont, SC_AUTOCOL_RAW);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("font should not be bold", WEIGHT_NORMAL, aFont.GetWeight());
+ pDoc->GetPattern(100, 2, 0)->GetFont(aFont, SC_AUTOCOL_RAW);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("font should be bold", WEIGHT_BOLD, aFont.GetWeight());
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */