summaryrefslogtreecommitdiff
path: root/sc/qa
diff options
context:
space:
mode:
authorBayram Çiçek <mail@bayramcicek.com.tr>2021-07-14 21:25:05 +0300
committerMuhammet Kara <muhammet.kara@collabora.com>2021-08-23 13:20:26 +0200
commit3a9167e1b8a236da2862f4377e2040a8c189c99c (patch)
tree4fc72bdcd1d524536da42c65347f3d8add9f1c81 /sc/qa
parent23c1ec0d498124fbe275145d236db455f83cd850 (diff)
tdf#143919: Calc: add diagonal borders in Toolbar>Borders
In "Table toolbar > Borders" tab; - Borders UI column size increased to 5 - diagonal left border icon added to 5th place - diagonal right border icon added to 10th place - criss-cross border icon added to 15th place - added diagonal left and diagonal right borders feature - implemented removing diagonal borders when set "no border" - added criss-cross line feature - added a unit test for diagonal borders Change-Id: I2dd7ab797b1a191eb650cc6340ee57d39e45a1ca Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118951 Tested-by: Jenkins Reviewed-by: Heiko Tietze <heiko.tietze@documentfoundation.org> Reviewed-by: Muhammet Kara <muhammet.kara@collabora.com>
Diffstat (limited to 'sc/qa')
-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 f8ddc85a01a4..48ad56946d93 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -76,6 +76,7 @@
#include <editeng/eeitem.hxx>
#include <editeng/wghtitem.hxx>
#include <editeng/postitem.hxx>
+#include <editeng/lineitem.hxx>
#include <svx/svdpage.hxx>
#include <svx/svdocirc.hxx>
@@ -179,6 +180,7 @@ public:
void testSearchCells();
void testFormulaPosition();
void testFormulaWizardSubformula();
+ void testDiagonalBorders();
/**
* Make sure the sheet streams are invalidated properly.
@@ -301,6 +303,7 @@ public:
CPPUNIT_TEST(testSearchCells);
CPPUNIT_TEST(testFormulaPosition);
CPPUNIT_TEST(testFormulaWizardSubformula);
+ CPPUNIT_TEST(testDiagonalBorders);
CPPUNIT_TEST(testJumpToPrecedentsDependents);
CPPUNIT_TEST(testSetBackgroundColor);
CPPUNIT_TEST(testRenameTable);
@@ -5923,6 +5926,77 @@ void Test::testFormulaWizardSubformula()
m_pDoc->DeleteTab(0);
}
+void Test::testDiagonalBorders()
+{
+ m_pDoc->InsertTab(0, "Diagonal");
+
+ ScAddress aPos;
+ const editeng::SvxBorderLine* pLine;
+ const ScPatternAttr* pPat;
+
+ // diagonal left border
+ ::editeng::SvxBorderLine dLeftBorderLine( nullptr, 1 );
+ SvxLineItem dLeftLineItem( ATTR_BORDER_TLBR );
+ dLeftLineItem.SetLine(&dLeftBorderLine);
+
+ // set diagonal left border to cell(A1)
+ m_pDoc->ApplyAttr(0, 0, 0, dLeftLineItem);
+
+ aPos = { 0, 0, 0 };
+ pPat = m_pDoc->GetPattern(aPos);
+ CPPUNIT_ASSERT(pPat);
+
+ pLine = pPat->GetItem(ATTR_BORDER_TLBR).GetLine();
+ CPPUNIT_ASSERT_MESSAGE("Diagonal left border was expected, but not found!", pLine);
+
+ // diagonal right border
+ ::editeng::SvxBorderLine dRightBorderLine( nullptr, 1 );
+ SvxLineItem dRightLineItem( ATTR_BORDER_BLTR );
+ dRightLineItem.SetLine(&dRightBorderLine);
+
+ // set diagonal right border to cell(A2)
+ m_pDoc->ApplyAttr(0, 1, 0, dRightLineItem);
+
+ aPos = { 0, 1, 0 };
+ pPat = m_pDoc->GetPattern(aPos);
+ CPPUNIT_ASSERT(pPat);
+
+ pLine = pPat->GetItem(ATTR_BORDER_BLTR).GetLine();
+ CPPUNIT_ASSERT_MESSAGE("Diagonal right border was expected, but not found!", pLine);
+
+ // diagonal left and right border in the same cell (A5)
+ m_pDoc->ApplyAttr(0, 4, 0, dLeftLineItem);
+ m_pDoc->ApplyAttr(0, 4, 0, dRightLineItem);
+
+ // test if both borders are applied successfully in the same cell (A5)
+ aPos = { 0, 4, 0 };
+ pPat = m_pDoc->GetPattern(aPos);
+ CPPUNIT_ASSERT(pPat);
+
+ pLine = pPat->GetItem(ATTR_BORDER_TLBR).GetLine();
+ CPPUNIT_ASSERT_MESSAGE("Diagonal left border was expected, but not found!", pLine);
+ pLine = pPat->GetItem(ATTR_BORDER_BLTR).GetLine();
+ CPPUNIT_ASSERT_MESSAGE("Diagonal right border was expected, but not found!", pLine);
+
+ // test if both borders are removed successfully
+ dLeftLineItem.SetLine(nullptr);
+ dRightLineItem.SetLine(nullptr);
+
+ // SetLine(nullptr) should remove the lines from (A5)
+ m_pDoc->ApplyAttr(0, 4, 0, dLeftLineItem);
+ m_pDoc->ApplyAttr(0, 4, 0, dRightLineItem);
+
+ pPat = m_pDoc->GetPattern(aPos);
+ CPPUNIT_ASSERT(pPat);
+
+ pLine = pPat->GetItem(ATTR_BORDER_TLBR).GetLine();
+ CPPUNIT_ASSERT_MESSAGE("Diagonal left border was not expected, but is found!", !pLine);
+ pLine = pPat->GetItem(ATTR_BORDER_BLTR).GetLine();
+ CPPUNIT_ASSERT_MESSAGE("Diagonal right border was not expected, but is found!", !pLine);
+
+ m_pDoc->DeleteTab(0);
+}
+
void Test::testSetStringAndNote()
{
m_pDoc->InsertTab(0, "Test");