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

Markus Mohrhard markus.mohrhard at collabora.co.uk
Fri Aug 15 18:25:19 PDT 2014


 sc/qa/unit/ucalc.cxx               |   34 ++++++++++++++++++++++++++++++++++
 sc/qa/unit/ucalc.hxx               |    2 ++
 sc/source/core/data/document10.cxx |    5 +++++
 3 files changed, 41 insertions(+)

New commits:
commit 17f6f60c1c20782fb1cde69b949b97c2f3b0d830
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Sat Aug 16 03:13:38 2014 +0200

    add test case for fdo#82503
    
    Change-Id: I715f8b2c09bd6af2cf1f45029f0561d79817deed

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 20b7ba7..644f7fb 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -6864,6 +6864,40 @@ void Test::testCondCopyPaste()
     m_pDoc->DeleteTab(0);
 }
 
+void Test::testCondCopyPasteSingleCell()
+{
+    m_pDoc->InsertTab(0, "Test");
+
+    ScConditionalFormat* pFormat = new ScConditionalFormat(1, m_pDoc);
+    ScRange aCondFormatRange(0,0,0,3,3,0);
+    ScRangeList aRangeList(aCondFormatRange);
+    pFormat->AddRange(aRangeList);
+
+    ScCondFormatEntry* pEntry = new ScCondFormatEntry(SC_COND_DIRECT,"=B2","",m_pDoc,ScAddress(0,0,0),ScGlobal::GetRscString(STR_STYLENAME_RESULT));
+    pFormat->AddEntry(pEntry);
+    sal_uLong nIndex = m_pDoc->AddCondFormat(pFormat, 0);
+
+    ScDocument aClipDoc(SCDOCMODE_CLIP);
+    copyToClip(m_pDoc, ScRange(0,0,0,0,0,0), &aClipDoc);
+
+    ScRange aTargetRange(4,4,0,4,4,0);
+    pasteFromClip(m_pDoc, aTargetRange, &aClipDoc);
+
+    ScConditionalFormat* pPastedFormat = m_pDoc->GetCondFormat(4,4,0);
+    CPPUNIT_ASSERT(pPastedFormat);
+
+    CPPUNIT_ASSERT_EQUAL(ScRangeList(aTargetRange), pPastedFormat->GetRange());
+    CPPUNIT_ASSERT( nIndex != pPastedFormat->GetKey());
+    const SfxPoolItem* pItem = m_pDoc->GetAttr( 4, 4, 0, ATTR_CONDITIONAL );
+    const ScCondFormatItem* pCondFormatItem = static_cast<const ScCondFormatItem*>(pItem);
+
+    CPPUNIT_ASSERT(pCondFormatItem);
+    CPPUNIT_ASSERT_EQUAL(size_t(1), pCondFormatItem->GetCondFormatData().size());
+    CPPUNIT_ASSERT( nIndex != pCondFormatItem->GetCondFormatData().at(0) );
+
+    m_pDoc->DeleteTab(0);
+}
+
 void Test::testIconSet()
 {
     m_pDoc->InsertTab(0, "Test");
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index 80c46bf..5c03a70 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -374,6 +374,7 @@ public:
     void testCondFormatInsertCol();
     void testCondFormatInsertDeleteSheets();
     void testCondCopyPaste();
+    void testCondCopyPasteSingleCell(); //e.g. fdo#82503
     void testIconSet();
 
     void testImportStream();
@@ -552,6 +553,7 @@ public:
     CPPUNIT_TEST(testCondFormatInsertCol);
     CPPUNIT_TEST(testCondFormatInsertDeleteSheets);
     CPPUNIT_TEST(testCondCopyPaste);
+    CPPUNIT_TEST(testCondCopyPasteSingleCell);
     CPPUNIT_TEST(testIconSet);
     CPPUNIT_TEST(testImportStream);
     CPPUNIT_TEST(testDeleteContents);
commit 8c9014cc6e5a502f5719f17c111c29448d4d6f6b
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Sat Aug 16 03:07:07 2014 +0200

    copy conditional formatting for single cells, fdo#82503
    
    Change-Id: I22f239fbbbfa3ac562b860efb990dff10d0e0e24

diff --git a/sc/source/core/data/document10.cxx b/sc/source/core/data/document10.cxx
index 49db92e..983e794 100644
--- a/sc/source/core/data/document10.cxx
+++ b/sc/source/core/data/document10.cxx
@@ -203,7 +203,12 @@ bool ScDocument::CopyOneCellFromClip(
 
     SCTAB nTabEnd = rCxt.getTabEnd();
     for (SCTAB i = rCxt.getTabStart(); i <= nTabEnd && i < static_cast<SCTAB>(maTabs.size()); ++i)
+    {
         maTabs[i]->CopyOneCellFromClip(rCxt, nCol1, nRow1, nCol2, nRow2);
+        if (rCxt.getInsertFlag() & IDF_ATTRIB)
+            maTabs[i]->CopyConditionalFormat(nCol1, nRow1, nCol2, nRow2, nCol1 - aClipRange.aStart.Col(),
+                    nRow1 - aClipRange.aStart.Row(), pSrcTab);
+    }
 
     return true;
 }


More information about the Libreoffice-commits mailing list