[Libreoffice-commits] core.git: sc/qa

Markus Mohrhard markus.mohrhard at googlemail.com
Fri Feb 23 17:25:51 UTC 2018


 sc/qa/unit/ucalc.hxx            |    2 +
 sc/qa/unit/ucalc_condformat.cxx |   50 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 52 insertions(+)

New commits:
commit a5ce0b396fdf48bba13d9e0433614d0e0e4368ea
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Thu Feb 22 23:34:03 2018 +0100

    add test for tdf#115835
    
    Change-Id: Ic07e35fcba503461793abb88b463b6e43ca61972
    Reviewed-on: https://gerrit.libreoffice.org/50212
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>

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: */


More information about the Libreoffice-commits mailing list