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

Kohei Yoshida kohei.yoshida at collabora.com
Fri Feb 7 13:00:28 PST 2014


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

New commits:
commit 8f60dd0223f8834224b196153f0d8601403d76dc
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Fri Feb 7 16:02:25 2014 -0500

    fdo#74273: Let's not shift the note twice. Once is enough.
    
    The notes already are shifted at the top of the function.  We don't
    need this bottom one.
    
    Change-Id: I10858d937674e236eecbc42ee08bf6eba197755a

diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index ccd62e9..7da6860 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -291,10 +291,6 @@ void ScColumn::DeleteRow( SCROW nStartRow, SCSIZE nSize )
     maCellTextAttrs.erase(nStartRow, nEndRow);
     maCellTextAttrs.resize(MAXROWCOUNT);
 
-    // Shift the cell notes array too (before the broadcast).
-    maCellNotes.erase(nStartRow, nEndRow);
-    maCellNotes.resize(MAXROWCOUNT);
-
     CellStorageModified();
 
     if (!bShiftCells)
commit 06c17598fb944aebcd0ef0783d2d4a81662208bb
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Fri Feb 7 16:00:08 2014 -0500

    fdo#74273: Adopt existing test to catch this.
    
    Apparently having a non-empty cell where the note is makes the note take
    a slightly different code path.
    
    Change-Id: I23decb83eeb34ee9e16b4f56816648815f102db8

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 275e4a0..b91255e 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -4763,59 +4763,67 @@ void Test::testNoteBasic()
     OUString aTabName2("Table2");
     m_pDoc->InsertTab(0, aTabName);
 
-    ScAddress rAddr(2, 2, 0); // cell C3
-    ScPostIt *pNote = m_pDoc->GetOrCreateNote(rAddr);
+    ScAddress aAddr(2, 2, 0); // cell C3
+    ScPostIt *pNote = m_pDoc->GetOrCreateNote(aAddr);
 
-    pNote->SetText(rAddr, aHello);
+    pNote->SetText(aAddr, aHello);
     pNote->SetAuthor(aJimBob);
 
-    ScPostIt *pGetNote = m_pDoc->GetNote(rAddr);
-    CPPUNIT_ASSERT_MESSAGE("note should be itself", pGetNote == pNote );
+    ScPostIt *pGetNote = m_pDoc->GetNote(aAddr);
+    CPPUNIT_ASSERT_MESSAGE("note should be itself", pGetNote == pNote);
 
     // Insert one row at row 1.
     bool bInsertRow = m_pDoc->InsertRow(0, 0, MAXCOL, 0, 1, 1);
     CPPUNIT_ASSERT_MESSAGE("failed to insert row", bInsertRow );
 
-    CPPUNIT_ASSERT_MESSAGE("note hasn't moved", m_pDoc->GetNote(rAddr) == NULL);
-    rAddr.IncRow(); // cell C4
-    CPPUNIT_ASSERT_MESSAGE("note not there", m_pDoc->GetNote(rAddr) == pNote);
+    CPPUNIT_ASSERT_MESSAGE("note hasn't moved", m_pDoc->GetNote(aAddr) == NULL);
+    aAddr.IncRow(); // cell C4
+    CPPUNIT_ASSERT_MESSAGE("note not there", m_pDoc->GetNote(aAddr) == pNote);
 
     // Insert column at column A.
     bool bInsertCol = m_pDoc->InsertCol(0, 0, MAXROW, 0, 1, 1);
     CPPUNIT_ASSERT_MESSAGE("failed to insert column", bInsertCol );
 
-    CPPUNIT_ASSERT_MESSAGE("note hasn't moved", m_pDoc->GetNote(rAddr) == NULL);
-    rAddr.IncCol(); // cell D4
-    CPPUNIT_ASSERT_MESSAGE("note not there", m_pDoc->GetNote(rAddr) == pNote);
+    CPPUNIT_ASSERT_MESSAGE("note hasn't moved", m_pDoc->GetNote(aAddr) == NULL);
+    aAddr.IncCol(); // cell D4
+    CPPUNIT_ASSERT_MESSAGE("note not there", m_pDoc->GetNote(aAddr) == pNote);
 
     // Insert a new sheet to shift the current sheet to the right.
     m_pDoc->InsertTab(0, aTabName2);
-    CPPUNIT_ASSERT_MESSAGE("note hasn't moved", m_pDoc->GetNote(rAddr) == NULL);
-    rAddr.IncTab(); // Move to the next sheet.
-    CPPUNIT_ASSERT_MESSAGE("note not there", m_pDoc->GetNote(rAddr) == pNote);
+    CPPUNIT_ASSERT_MESSAGE("note hasn't moved", m_pDoc->GetNote(aAddr) == NULL);
+    aAddr.IncTab(); // Move to the next sheet.
+    CPPUNIT_ASSERT_MESSAGE("note not there", m_pDoc->GetNote(aAddr) == pNote);
 
     m_pDoc->DeleteTab(0);
-    rAddr.IncTab(-1);
-    CPPUNIT_ASSERT_MESSAGE("note not there", m_pDoc->GetNote(rAddr) == pNote);
+    aAddr.IncTab(-1);
+    CPPUNIT_ASSERT_MESSAGE("note not there", m_pDoc->GetNote(aAddr) == pNote);
 
     // Insert cell at C4.  This should NOT shift the note position.
     bInsertRow = m_pDoc->InsertRow(2, 0, 2, 0, 3, 1);
     CPPUNIT_ASSERT_MESSAGE("Failed to insert cell at C4.", bInsertRow);
-    CPPUNIT_ASSERT_MESSAGE("Note shouldn't have moved but it has.", m_pDoc->GetNote(rAddr) == pNote);
+    CPPUNIT_ASSERT_MESSAGE("Note shouldn't have moved but it has.", m_pDoc->GetNote(aAddr) == pNote);
 
     // Delete cell at C4.  Again, this should NOT shift the note position.
     m_pDoc->DeleteRow(2, 0, 2, 0, 3, 1);
-    CPPUNIT_ASSERT_MESSAGE("Note shouldn't have moved but it has.", m_pDoc->GetNote(rAddr) == pNote);
+    CPPUNIT_ASSERT_MESSAGE("Note shouldn't have moved but it has.", m_pDoc->GetNote(aAddr) == pNote);
 
     // Now, with the note at D4, delete cell D3. This should shift the note one cell up.
     m_pDoc->DeleteRow(3, 0, 3, 0, 2, 1);
-    rAddr.IncRow(-1); // cell D3
-    CPPUNIT_ASSERT_MESSAGE("Note at D4 should have shifted up to D3.", m_pDoc->GetNote(rAddr) == pNote);
+    aAddr.IncRow(-1); // cell D3
+    CPPUNIT_ASSERT_MESSAGE("Note at D4 should have shifted up to D3.", m_pDoc->GetNote(aAddr) == pNote);
 
     // Delete column C. This should shift the note one cell left.
     m_pDoc->DeleteCol(0, 0, MAXROW, 0, 2, 1);
-    rAddr.IncCol(-1); // cell C3
-    CPPUNIT_ASSERT_MESSAGE("Note at D3 should have shifted left to C3.", m_pDoc->GetNote(rAddr) == pNote);
+    aAddr.IncCol(-1); // cell C3
+    CPPUNIT_ASSERT_MESSAGE("Note at D3 should have shifted left to C3.", m_pDoc->GetNote(aAddr) == pNote);
+
+    // Insert a text where the note is.
+    m_pDoc->SetString(aAddr, "Note is here.");
+
+    // Delete row 1. This should shift the note from C3 to C2.
+    m_pDoc->DeleteRow(0, 0, MAXCOL, 0, 0, 1);
+    aAddr.IncRow(-1); // C2
+    CPPUNIT_ASSERT_MESSAGE("Note at C3 should have shifted up to C2.", m_pDoc->GetNote(aAddr) == pNote);
 
     m_pDoc->DeleteTab(0);
 }
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index 74b79a3..f595467 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -395,7 +395,6 @@ public:
     CPPUNIT_TEST(testDataArea);
     CPPUNIT_TEST(testGraphicsInGroup);
     CPPUNIT_TEST(testGraphicsOnSheetMove);
-    CPPUNIT_TEST(testNoteBasic);
     CPPUNIT_TEST(testStreamValid);
     CPPUNIT_TEST(testFunctionLists);
     CPPUNIT_TEST(testToggleRefFlag);
@@ -431,6 +430,7 @@ public:
     CPPUNIT_TEST(testSortWithFormulaRefs);
     CPPUNIT_TEST(testSortWithStrings);
     CPPUNIT_TEST(testShiftCells);
+    CPPUNIT_TEST(testNoteBasic);
     CPPUNIT_TEST(testNoteDeleteRow);
     CPPUNIT_TEST(testNoteDeleteCol);
     CPPUNIT_TEST(testNoteLifeCycle);


More information about the Libreoffice-commits mailing list