summaryrefslogtreecommitdiff
path: root/sc/qa/unit
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2022-05-30 16:33:15 +0200
committerLuboš Luňák <l.lunak@collabora.com>2022-05-30 21:20:54 +0200
commit970ff17f47731be788ec34c0c8ddf3fb2c24ceac (patch)
treebfa21b343607591427c8047a5218d15232039e0d /sc/qa/unit
parent3e738f53a69e474f22b4d6599ce16e5fe3d691df (diff)
fix setting cell borders for unallocated cells
First of all, it should not be clamped to allocated columns. Second, 06d3294502413a231e5c5265609862c7f67a2f2b incorrectly handled unallocated columns by setting the attribute for all rows, instead of handling the inner ones differently. Change-Id: I3115b314971f8c152cbdeda674863a8a78ee12eb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135131 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
Diffstat (limited to 'sc/qa/unit')
-rw-r--r--sc/qa/unit/ucalc.cxx74
1 files changed, 74 insertions, 0 deletions
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 9f8fad755ea1..a83b5482647f 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -157,6 +157,7 @@ public:
void testFormulaPosition();
void testFormulaWizardSubformula();
void testDiagonalBorders();
+ void testWholeDocBorders();
/**
* Make sure the sheet streams are invalidated properly.
@@ -290,6 +291,7 @@ public:
CPPUNIT_TEST(testFormulaPosition);
CPPUNIT_TEST(testFormulaWizardSubformula);
CPPUNIT_TEST(testDiagonalBorders);
+ CPPUNIT_TEST(testWholeDocBorders);
CPPUNIT_TEST(testJumpToPrecedentsDependents);
CPPUNIT_TEST(testSetBackgroundColor);
CPPUNIT_TEST(testRenameTable);
@@ -6310,6 +6312,78 @@ void Test::testDiagonalBorders()
m_pDoc->DeleteTab(0);
}
+void Test::testWholeDocBorders()
+{
+ m_pDoc->InsertTab(0, "Borders");
+
+ // Set outside border to be on all sides, and inside borders to be only vertical.
+ // This should result in edge borders of the spreadsheets being set, but internal
+ // borders between cells should be only vertical, not horizontal.
+ ::editeng::SvxBorderLine line(nullptr, 50, SvxBorderLineStyle::SOLID);
+ SvxBoxItem borderItem(ATTR_BORDER);
+ borderItem.SetLine(&line, SvxBoxItemLine::LEFT);
+ borderItem.SetLine(&line, SvxBoxItemLine::RIGHT);
+ borderItem.SetLine(&line, SvxBoxItemLine::TOP);
+ borderItem.SetLine(&line, SvxBoxItemLine::BOTTOM);
+ SvxBoxInfoItem boxInfoItem(ATTR_BORDER);
+ boxInfoItem.SetLine(&line, SvxBoxInfoItemLine::VERT);
+
+ ScMarkData mark( m_pDoc->GetSheetLimits(), ScRange( 0, 0, 0, m_pDoc->MaxCol(), m_pDoc->MaxRow(), 0 ));
+ m_pDoc->ApplySelectionFrame( mark, borderItem, &boxInfoItem );
+
+ const ScPatternAttr* attr;
+ attr = m_pDoc->GetPattern( 0, 0, 0 );
+ CPPUNIT_ASSERT(attr);
+ CPPUNIT_ASSERT(attr->GetItem(ATTR_BORDER).GetTop());
+ CPPUNIT_ASSERT(attr->GetItem(ATTR_BORDER).GetLeft());
+ CPPUNIT_ASSERT(attr->GetItem(ATTR_BORDER).GetRight());
+ CPPUNIT_ASSERT(!attr->GetItem(ATTR_BORDER).GetBottom());
+
+ attr = m_pDoc->GetPattern( 1, 0, 0 );
+ CPPUNIT_ASSERT(attr);
+ CPPUNIT_ASSERT(attr->GetItem(ATTR_BORDER).GetTop());
+ CPPUNIT_ASSERT(attr->GetItem(ATTR_BORDER).GetLeft());
+ CPPUNIT_ASSERT(attr->GetItem(ATTR_BORDER).GetRight());
+ CPPUNIT_ASSERT(!attr->GetItem(ATTR_BORDER).GetBottom());
+
+ attr = m_pDoc->GetPattern( 0, 1, 0 );
+ CPPUNIT_ASSERT(attr);
+ CPPUNIT_ASSERT(!attr->GetItem(ATTR_BORDER).GetTop());
+ CPPUNIT_ASSERT(attr->GetItem(ATTR_BORDER).GetLeft());
+ CPPUNIT_ASSERT(attr->GetItem(ATTR_BORDER).GetRight());
+ CPPUNIT_ASSERT(!attr->GetItem(ATTR_BORDER).GetBottom());
+
+ attr = m_pDoc->GetPattern( 1, 1, 0 );
+ CPPUNIT_ASSERT(attr);
+ CPPUNIT_ASSERT(!attr->GetItem(ATTR_BORDER).GetTop());
+ CPPUNIT_ASSERT(attr->GetItem(ATTR_BORDER).GetLeft());
+ CPPUNIT_ASSERT(attr->GetItem(ATTR_BORDER).GetRight());
+ CPPUNIT_ASSERT(!attr->GetItem(ATTR_BORDER).GetBottom());
+
+ attr = m_pDoc->GetPattern( m_pDoc->MaxCol(), 0, 0 );
+ CPPUNIT_ASSERT(attr);
+ CPPUNIT_ASSERT(attr->GetItem(ATTR_BORDER).GetTop());
+ CPPUNIT_ASSERT(attr->GetItem(ATTR_BORDER).GetLeft());
+ CPPUNIT_ASSERT(attr->GetItem(ATTR_BORDER).GetRight());
+ CPPUNIT_ASSERT(!attr->GetItem(ATTR_BORDER).GetBottom());
+
+ attr = m_pDoc->GetPattern( 0, m_pDoc->MaxRow(), 0 );
+ CPPUNIT_ASSERT(attr);
+ CPPUNIT_ASSERT(!attr->GetItem(ATTR_BORDER).GetTop());
+ CPPUNIT_ASSERT(attr->GetItem(ATTR_BORDER).GetLeft());
+ CPPUNIT_ASSERT(attr->GetItem(ATTR_BORDER).GetRight());
+ CPPUNIT_ASSERT(attr->GetItem(ATTR_BORDER).GetBottom());
+
+ attr = m_pDoc->GetPattern( m_pDoc->MaxCol(), m_pDoc->MaxRow(), 0 );
+ CPPUNIT_ASSERT(attr);
+ CPPUNIT_ASSERT(!attr->GetItem(ATTR_BORDER).GetTop());
+ CPPUNIT_ASSERT(attr->GetItem(ATTR_BORDER).GetLeft());
+ CPPUNIT_ASSERT(attr->GetItem(ATTR_BORDER).GetRight());
+ CPPUNIT_ASSERT(attr->GetItem(ATTR_BORDER).GetBottom());
+
+ m_pDoc->DeleteTab(0);
+}
+
void Test::testSetStringAndNote()
{
m_pDoc->InsertTab(0, "Test");