summaryrefslogtreecommitdiff
path: root/sc/qa
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2018-02-22 23:34:03 +0100
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2018-02-23 18:25:26 +0100
commita5ce0b396fdf48bba13d9e0433614d0e0e4368ea (patch)
tree08f6f2773b78a3b93a517aeff4ca6cfb5af1112a /sc/qa
parentff6def51db86ea2a516739f2dd67f24fa024af4e (diff)
add test for tdf#115835
Change-Id: Ic07e35fcba503461793abb88b463b6e43ca61972 Reviewed-on: https://gerrit.libreoffice.org/50212 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
Diffstat (limited to 'sc/qa')
-rw-r--r--sc/qa/unit/ucalc.hxx2
-rw-r--r--sc/qa/unit/ucalc_condformat.cxx50
2 files changed, 52 insertions, 0 deletions
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index a130d4ad69c7..6ee3d2c988bc 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -514,6 +514,7 @@ public:
void testCondFormatEndsWithVal();
void testCondFormatUndoList();
+ void testMultipleSingleCellCondFormatCopyPaste();
void testImportStream();
void testDeleteContents();
@@ -795,6 +796,7 @@ public:
CPPUNIT_TEST(testCondFormatUpdateReferenceDelRow);
CPPUNIT_TEST(testCondFormatUpdateReferenceInsRow);
CPPUNIT_TEST(testCondFormatUndoList);
+ CPPUNIT_TEST(testMultipleSingleCellCondFormatCopyPaste);
CPPUNIT_TEST(testIconSet);
CPPUNIT_TEST(testDataBarLengthAutomaticAxis);
CPPUNIT_TEST(testDataBarLengthMiddleAxis);
diff --git a/sc/qa/unit/ucalc_condformat.cxx b/sc/qa/unit/ucalc_condformat.cxx
index e0f18ca1fd5b..bd79b68526ab 100644
--- a/sc/qa/unit/ucalc_condformat.cxx
+++ b/sc/qa/unit/ucalc_condformat.cxx
@@ -1106,4 +1106,54 @@ void Test::testCondFormatUndoList()
m_pDoc->DeleteTab(0);
}
+namespace {
+
+sal_uInt32 addSingleCellCondFormat(ScDocument* pDoc, const ScAddress& rAddr, sal_uInt32 nKey)
+{
+ ScConditionalFormat* pFormat = new ScConditionalFormat(nKey, pDoc);
+ ScRange aCondFormatRange(rAddr);
+ ScRangeList aRangeList(aCondFormatRange);
+ pFormat->SetRange(aRangeList);
+
+ ScCondFormatEntry* pEntry = new ScCondFormatEntry(ScConditionMode::Direct, "=B2" + OUString::number(nKey), "",
+ pDoc, ScAddress(0,0,0), ScGlobal::GetRscString(STR_STYLENAME_RESULT));
+ pFormat->AddEntry(pEntry);
+ return pDoc->AddCondFormat(pFormat, 0);
+}
+
+}
+
+void Test::testMultipleSingleCellCondFormatCopyPaste()
+{
+ m_pDoc->InsertTab(0, "Test");
+
+ sal_uInt32 nFirstCondFormatKey = addSingleCellCondFormat(m_pDoc, ScAddress(0, 0, 0), 1);
+ sal_uInt32 nSecondCondFormatKey = addSingleCellCondFormat(m_pDoc, ScAddress(1, 0, 0), 2);
+
+ ScDocument aClipDoc(SCDOCMODE_CLIP);
+ copyToClip(m_pDoc, ScRange(0,0,0,2,0,0), &aClipDoc);
+ ScRange aTargetRange(2,4,0,7,4,0);
+ pasteOneCellFromClip(m_pDoc, aTargetRange, &aClipDoc);
+
+ for (SCCOL nCol = 2; nCol <= 7; ++nCol)
+ {
+ std::cout << nCol << std::endl;
+ ScConditionalFormat* pFormat = m_pDoc->GetCondFormat(nCol, 4, 0);
+ if (((nCol - 2) % 3) == 0)
+ {
+ CPPUNIT_ASSERT_EQUAL(pFormat->GetKey(), nFirstCondFormatKey);
+ }
+ else if (((nCol - 2) % 3) == 1)
+ {
+ CPPUNIT_ASSERT_EQUAL(pFormat->GetKey(), nSecondCondFormatKey);
+ }
+ else
+ {
+ CPPUNIT_ASSERT(!pFormat);
+ }
+ }
+
+ m_pDoc->DeleteTab(0);
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */