summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2018-02-23 02:04:50 +0100
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2018-02-24 03:33:03 +0100
commit93117a98e870804ad0ac0152e87355edd1dd5889 (patch)
treef39b39d4b05dd884ac6b458fc000868facdd0c3c
parent63ad8b1c0ddcd895447627ac60701d54ff332c38 (diff)
add test for deduplicating cond format against same format
Change-Id: I9e21b5b53f7a3c579bdaf5dc0dd6102be805faf9 Reviewed-on: https://gerrit.libreoffice.org/50217 Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com> Tested-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
-rw-r--r--sc/qa/unit/ucalc.hxx2
-rw-r--r--sc/qa/unit/ucalc_condformat.cxx41
2 files changed, 38 insertions, 5 deletions
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index 6ee3d2c988bc..630e9b09b0a0 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -515,6 +515,7 @@ public:
void testCondFormatUndoList();
void testMultipleSingleCellCondFormatCopyPaste();
+ void testDeduplicateMultipleCondFormats();
void testImportStream();
void testDeleteContents();
@@ -797,6 +798,7 @@ public:
CPPUNIT_TEST(testCondFormatUpdateReferenceInsRow);
CPPUNIT_TEST(testCondFormatUndoList);
CPPUNIT_TEST(testMultipleSingleCellCondFormatCopyPaste);
+ CPPUNIT_TEST(testDeduplicateMultipleCondFormats);
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 bd79b68526ab..0e8721a0acb8 100644
--- a/sc/qa/unit/ucalc_condformat.cxx
+++ b/sc/qa/unit/ucalc_condformat.cxx
@@ -1108,14 +1108,14 @@ void Test::testCondFormatUndoList()
namespace {
-sal_uInt32 addSingleCellCondFormat(ScDocument* pDoc, const ScAddress& rAddr, sal_uInt32 nKey)
+sal_uInt32 addSingleCellCondFormat(ScDocument* pDoc, const ScAddress& rAddr, sal_uInt32 nKey, const OUString& rCondition)
{
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), "",
+ ScCondFormatEntry* pEntry = new ScCondFormatEntry(ScConditionMode::Direct, rCondition, "",
pDoc, ScAddress(0,0,0), ScGlobal::GetRscString(STR_STYLENAME_RESULT));
pFormat->AddEntry(pEntry);
return pDoc->AddCondFormat(pFormat, 0);
@@ -1127,8 +1127,40 @@ 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);
+ sal_uInt32 nFirstCondFormatKey = addSingleCellCondFormat(m_pDoc, ScAddress(0, 0, 0), 1, "=A2");
+ sal_uInt32 nSecondCondFormatKey = addSingleCellCondFormat(m_pDoc, ScAddress(1, 0, 0), 2, "=B3");
+
+ 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)
+ {
+ 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);
+}
+
+void Test::testDeduplicateMultipleCondFormats()
+{
+ m_pDoc->InsertTab(0, "Test");
+
+ sal_uInt32 nFirstCondFormatKey = addSingleCellCondFormat(m_pDoc, ScAddress(0, 0, 0), 1, "=B2");
+ sal_uInt32 nSecondCondFormatKey = addSingleCellCondFormat(m_pDoc, ScAddress(1, 0, 0), 2, "=B2");
ScDocument aClipDoc(SCDOCMODE_CLIP);
copyToClip(m_pDoc, ScRange(0,0,0,2,0,0), &aClipDoc);
@@ -1137,7 +1169,6 @@ void Test::testMultipleSingleCellCondFormatCopyPaste()
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)
{