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

Kohei Yoshida kohei.yoshida at collabora.com
Fri May 9 11:06:02 PDT 2014


 sc/qa/unit/ucalc.cxx            |   55 ++++++++++++++++++++++++++++++++++++++++
 sc/qa/unit/ucalc.hxx            |    2 +
 sc/source/core/data/column3.cxx |    4 +-
 3 files changed, 59 insertions(+), 2 deletions(-)

New commits:
commit f4673ccd5e26d38a28f297d64ed70ba719d21ef2
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Fri May 9 14:04:30 2014 -0400

    fdo#77379: Don't return from the call. Notes are handled at the end.
    
    Returning prematurely would end up skipping pasting of notes.
    
    Change-Id: I79e0968023342a68fe729f31eb6cfc3cfacd5850

diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index e3a81a5..8bb8223 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -873,7 +873,7 @@ public:
             case sc::element_type_string:
             {
                 if (!bString)
-                    return;
+                    break;
 
                 sc::string_block::const_iterator it = sc::string_block::begin(*node.data);
                 std::advance(it, nOffset);
@@ -897,7 +897,7 @@ public:
             case sc::element_type_edittext:
             {
                 if (!bString)
-                    return;
+                    break;
 
                 sc::edittext_block::const_iterator it = sc::edittext_block::begin(*node.data);
                 std::advance(it, nOffset);
commit 71cd1ca57faf423fb607fab64914719238bc1e4f
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Fri May 9 13:50:31 2014 -0400

    fdo#77379: Write test for this.
    
    Change-Id: Iccc0b499abae90f5b780aebab17ff6315b5690ec

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 1ca19b8..4cf444f 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -5400,6 +5400,61 @@ void Test::testNoteLifeCycle()
     m_pDoc->DeleteTab(0);
 }
 
+void Test::testNoteCopyPaste()
+{
+    m_pDoc->InsertTab(0, "Test");
+
+    // We need a drawing layer in order to create caption objects.
+    m_pDoc->InitDrawLayer(&getDocShell());
+
+    // Insert in B2 a text and cell comment.
+    ScAddress aPos(1,1,0);
+    m_pDoc->SetString(aPos, "Text");
+    ScPostIt* pNote = m_pDoc->GetOrCreateNote(aPos);
+    CPPUNIT_ASSERT(pNote);
+    pNote->SetText(aPos, "Note1");
+
+    // Insert in B4 a number and cell comment.
+    aPos.SetRow(3);
+    m_pDoc->SetValue(aPos, 1.1);
+    pNote = m_pDoc->GetOrCreateNote(aPos);
+    CPPUNIT_ASSERT(pNote);
+    pNote->SetText(aPos, "Note2");
+
+    // Copy B2:B4 to clipboard.
+    ScMarkData aMark;
+    aMark.SelectOneTable(0);
+    ScRange aCopyRange(1,1,0,1,3,0);
+    ScDocument aClipDoc(SCDOCMODE_CLIP);
+    aClipDoc.ResetClip(m_pDoc, &aMark);
+    ScClipParam aClipParam(aCopyRange, false);
+    m_pDoc->CopyToClip(aClipParam, &aClipDoc, &aMark, false, false, false, true, false);
+
+    // Make sure the notes are in the clipboard.
+    pNote = aClipDoc.GetNote(ScAddress(1,1,0));
+    CPPUNIT_ASSERT(pNote);
+    CPPUNIT_ASSERT_EQUAL(OUString("Note1"), pNote->GetText());
+
+    pNote = aClipDoc.GetNote(ScAddress(1,3,0));
+    CPPUNIT_ASSERT(pNote);
+    CPPUNIT_ASSERT_EQUAL(OUString("Note2"), pNote->GetText());
+
+    // Paste to B6:B8 but only cell notes.
+    ScRange aDestRange(1,5,0,1,7,0);
+    m_pDoc->CopyFromClip(aDestRange, aMark, IDF_NOTE, NULL, &aClipDoc);
+
+    // Make sure the notes are there.
+    pNote = m_pDoc->GetNote(ScAddress(1,5,0));
+    CPPUNIT_ASSERT(pNote);
+    CPPUNIT_ASSERT_EQUAL(OUString("Note1"), pNote->GetText());
+
+    pNote = m_pDoc->GetNote(ScAddress(1,7,0));
+    CPPUNIT_ASSERT(pNote);
+    CPPUNIT_ASSERT_EQUAL(OUString("Note2"), pNote->GetText());
+
+    m_pDoc->DeleteTab(0);
+}
+
 void Test::testAreasWithNotes()
 {
     ScDocument* pDoc = getDocShell().GetDocument();
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index dbe84e7..76c74cc 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -341,6 +341,7 @@ public:
     void testNoteDeleteRow();
     void testNoteDeleteCol();
     void testNoteLifeCycle();
+    void testNoteCopyPaste();
     void testAreasWithNotes();
     void testAnchoredRotatedShape();
     void testCellTextWidth();
@@ -499,6 +500,7 @@ public:
     CPPUNIT_TEST(testNoteDeleteRow);
     CPPUNIT_TEST(testNoteDeleteCol);
     CPPUNIT_TEST(testNoteLifeCycle);
+    CPPUNIT_TEST(testNoteCopyPaste);
     CPPUNIT_TEST(testAreasWithNotes);
     CPPUNIT_TEST(testAnchoredRotatedShape);
     CPPUNIT_TEST(testCellTextWidth);


More information about the Libreoffice-commits mailing list