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

Kohei Yoshida kohei.yoshida at collabora.com
Fri Mar 7 11:26:43 PST 2014


 sc/qa/unit/ucalc.cxx            |   36 ++++++++++++++++++++++++++++++++++++
 sc/source/core/data/column2.cxx |   10 +++++-----
 2 files changed, 41 insertions(+), 5 deletions(-)

New commits:
commit 01de94471c20a8b9c36d6080638d70e57eac55bf
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Fri Mar 7 14:23:46 2014 -0500

    fdo#75718: Correctly count the length of trailing empty range.
    
    This affects auto fill, apparently.
    
    Change-Id: I653918d374122bc9bb938231934c149da79a3306

diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index 6c6e47e..38eb94e 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -1214,13 +1214,13 @@ bool ScColumn::IsNotesEmptyBlock(SCROW nStartRow, SCROW nEndRow) const
 
 SCSIZE ScColumn::GetEmptyLinesInBlock( SCROW nStartRow, SCROW nEndRow, ScDirection eDir ) const
 {
-    // Given a range of rows, find a top or bottom empty segment.
+    // Given a range of rows, find a top or bottom empty segment.  Skip the start row.
     switch (eDir)
     {
         case DIR_TOP:
         {
             // Determine the length of empty head segment.
-            size_t nLength = nEndRow - nStartRow + 1;
+            size_t nLength = nEndRow - nStartRow;
             std::pair<sc::CellStoreType::const_iterator,size_t> aPos = maCells.position(nStartRow);
             sc::CellStoreType::const_iterator it = aPos.first;
             if (it->type != sc::element_type_empty)
@@ -1234,8 +1234,8 @@ SCSIZE ScColumn::GetEmptyLinesInBlock( SCROW nStartRow, SCROW nEndRow, ScDirecti
         break;
         case DIR_BOTTOM:
         {
-            // Determine the length empty tail segment.
-            size_t nLength = nEndRow - nStartRow + 1;
+            // Determine the length of empty tail segment.
+            size_t nLength = nEndRow - nStartRow;
             std::pair<sc::CellStoreType::const_iterator,size_t> aPos = maCells.position(nEndRow);
             sc::CellStoreType::const_iterator it = aPos.first;
             if (it->type != sc::element_type_empty)
@@ -1243,7 +1243,7 @@ SCSIZE ScColumn::GetEmptyLinesInBlock( SCROW nStartRow, SCROW nEndRow, ScDirecti
                 return 0;
 
             // length of this empty block from the tip to the end row position.
-            size_t nThisLen = aPos.second;
+            size_t nThisLen = aPos.second + 1;
             return std::min(nThisLen, nLength);
         }
         break;
commit 9d54a7f67196cac2a5701c06d8dc55f102d0af60
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Fri Mar 7 14:22:49 2014 -0500

    fdo#75718: Write unit test for this.
    
    Change-Id: I1f1fe515485209b67f14a1407ee20a88e71c08c9

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index bf691c6..a49b6d2 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -4220,6 +4220,42 @@ void Test::testAutoFill()
         aTestValue = m_pDoc->GetString( 0, i, 0 );
         CPPUNIT_ASSERT_EQUAL( aTestValue, OUString("January") );
     }
+
+    // Clear column A for a new test.
+    clearRange(m_pDoc, ScRange(0,0,0,0,MAXROW,0));
+    m_pDoc->SetRowHidden(0, MAXROW, 0, false); // Show all rows.
+
+    // Fill A1:A6 with 1,2,3,4,5,6.
+    ScDocFunc& rFunc = getDocShell().GetDocFunc();
+    m_pDoc->SetValue(ScAddress(0,0,0), 1.0);
+    ScRange aRange(0,0,0,0,5,0);
+    aMarkData.SetMarkArea(aRange);
+    rFunc.FillSeries(aRange, &aMarkData, FILL_TO_BOTTOM, FILL_AUTO, FILL_DAY, MAXDOUBLE, 1.0, MAXDOUBLE, true, true);
+    CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(ScAddress(0,0,0)));
+    CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(ScAddress(0,1,0)));
+    CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(ScAddress(0,2,0)));
+    CPPUNIT_ASSERT_EQUAL(4.0, m_pDoc->GetValue(ScAddress(0,3,0)));
+    CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc->GetValue(ScAddress(0,4,0)));
+    CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc->GetValue(ScAddress(0,5,0)));
+
+    // Undo should clear the area except for the top cell.
+    SfxUndoManager* pUndoMgr = m_pDoc->GetUndoManager();
+    CPPUNIT_ASSERT(pUndoMgr);
+    pUndoMgr->Undo();
+
+    CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(ScAddress(0,0,0)));
+    for (SCROW i = 1; i <= 5; ++i)
+        CPPUNIT_ASSERT(m_pDoc->GetCellType(ScAddress(0,i,0)) == CELLTYPE_NONE);
+
+    // Redo should put the serial values back in.
+    pUndoMgr->Redo();
+    CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(ScAddress(0,0,0)));
+    CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(ScAddress(0,1,0)));
+    CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(ScAddress(0,2,0)));
+    CPPUNIT_ASSERT_EQUAL(4.0, m_pDoc->GetValue(ScAddress(0,3,0)));
+    CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc->GetValue(ScAddress(0,4,0)));
+    CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc->GetValue(ScAddress(0,5,0)));
+
     m_pDoc->DeleteTab(0);
 }
 


More information about the Libreoffice-commits mailing list