[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - 3 commits - mdds/0001-Combine-these-two-calls.-There-is-no-reason-why-they.patch mdds/0001-Fix-it-here-too.patch mdds/UnpackedTarball_mdds.mk sc/qa sc/source

Kohei Yoshida kohei.yoshida at gmail.com
Tue Jun 25 08:04:33 PDT 2013


 mdds/0001-Combine-these-two-calls.-There-is-no-reason-why-they.patch |   27 ++
 mdds/0001-Fix-it-here-too.patch                                      |   26 ++
 mdds/UnpackedTarball_mdds.mk                                         |    2 
 sc/qa/unit/ucalc.cxx                                                 |  122 +++++++---
 sc/source/core/data/dociter.cxx                                      |    6 
 5 files changed, 145 insertions(+), 38 deletions(-)

New commits:
commit 1efd0a6a1db0414bc4929865fc6e282cabacab8d
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Tue Jun 25 11:06:43 2013 -0400

    The horizontal cell iterator was *still* broken. Let's fix it again.
    
    And add a test for it.
    
    Change-Id: If76a67e02ac6ad5199d664850bd8591bd3032f32

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index b29a89e..462087a4 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -404,6 +404,12 @@ void printRange(ScDocument* pDoc, const ScRange& rRange, const char* pCaption)
 template<size_t _Size>
 ScRange insertRangeData(ScDocument* pDoc, const ScAddress& rPos, const char* aData[][_Size], size_t nRowCount)
 {
+    ScRange aRange(rPos);
+    aRange.aEnd.SetCol(rPos.Col()+_Size-1);
+    aRange.aEnd.SetRow(rPos.Row()+nRowCount-1);
+
+    clearRange(pDoc, aRange);
+
     for (size_t i = 0; i < _Size; ++i)
     {
         for (size_t j = 0; j < nRowCount; ++j)
@@ -417,9 +423,6 @@ ScRange insertRangeData(ScDocument* pDoc, const ScAddress& rPos, const char* aDa
         }
     }
 
-    ScRange aRange(rPos);
-    aRange.aEnd.SetCol(rPos.Col()+_Size-1);
-    aRange.aEnd.SetRow(rPos.Row()+nRowCount-1);
     printRange(pDoc, aRange, "Range data content");
     return aRange;
 }
@@ -1785,48 +1788,97 @@ void Test::testVolatileFunc()
     m_pDoc->DeleteTab(0);
 }
 
-void Test::testHorizontalIterator()
-{
-    m_pDoc->InsertTab(0, "test");
+namespace {
 
-    // Raw data
-    const char* aData[][2] = {
-        { "A", "B" },
-        { "C", "1" },
-        { "D", "2" },
-        { "E", "3" }
-    };
+struct HoriIterCheck
+{
+    SCCOL nCol;
+    SCROW nRow;
+    const char* pVal;
+};
 
+template<size_t _Size>
+bool checkHorizontalIterator(ScDocument* pDoc, const char* pData[][_Size], size_t nDataCount, const HoriIterCheck* pChecks, size_t nCheckCount)
+{
     ScAddress aPos(0,0,0);
-    insertRangeData(m_pDoc, aPos, aData, SAL_N_ELEMENTS(aData));
-    ScHorizontalCellIterator aIter(m_pDoc, 0, 0, 0, 1, SAL_N_ELEMENTS(aData));
-
-    struct {
-        SCCOL nCol;
-        SCROW nRow;
-        const char* pVal;
-    } aChecks[] = {
-        { 0, 0, "A" },
-        { 1, 0, "B" },
-        { 0, 1, "C" },
-        { 1, 1, "1" },
-        { 0, 2, "D" },
-        { 1, 2, "2" },
-        { 0, 3, "E" },
-        { 1, 3, "3" },
-    };
+    insertRangeData(pDoc, aPos, pData, nDataCount);
+    ScHorizontalCellIterator aIter(pDoc, 0, 0, 0, 1, nDataCount-1);
 
     SCCOL nCol;
     SCROW nRow;
-    size_t i = 0, n = SAL_N_ELEMENTS(aChecks);
+    size_t i = 0;
     for (ScRefCellValue* pCell = aIter.GetNext(nCol, nRow); pCell; pCell = aIter.GetNext(nCol, nRow), ++i)
     {
-        if (i >= n)
+        if (i >= nCheckCount)
             CPPUNIT_FAIL("Iterator claims there is more data than there should be.");
 
-        CPPUNIT_ASSERT_EQUAL(aChecks[i].nCol, nCol);
-        CPPUNIT_ASSERT_EQUAL(aChecks[i].nRow, nRow);
-        CPPUNIT_ASSERT_EQUAL(OUString::createFromAscii(aChecks[i].pVal), pCell->getString());
+        if (pChecks[i].nCol != nCol)
+            return false;
+
+        if (pChecks[i].nRow != nRow)
+            return false;
+
+        if (OUString::createFromAscii(pChecks[i].pVal) != pCell->getString())
+            return false;
+    }
+
+    return true;
+}
+
+}
+
+void Test::testHorizontalIterator()
+{
+    m_pDoc->InsertTab(0, "test");
+
+    {
+        // Raw data
+        const char* aData[][2] = {
+            { "A", "B" },
+            { "C", "1" },
+            { "D", "2" },
+            { "E", "3" }
+        };
+
+        HoriIterCheck aChecks[] = {
+            { 0, 0, "A" },
+            { 1, 0, "B" },
+            { 0, 1, "C" },
+            { 1, 1, "1" },
+            { 0, 2, "D" },
+            { 1, 2, "2" },
+            { 0, 3, "E" },
+            { 1, 3, "3" },
+        };
+
+        bool bRes = checkHorizontalIterator(
+            m_pDoc, aData, SAL_N_ELEMENTS(aData), aChecks, SAL_N_ELEMENTS(aChecks));
+
+        if (!bRes)
+            CPPUNIT_FAIL("Failed on test 1.");
+    }
+
+    {
+        // Raw data
+        const char* aData[][2] = {
+            { "A", "B" },
+            { "C",  0  },
+            { "D", "E" },
+        };
+
+        HoriIterCheck aChecks[] = {
+            { 0, 0, "A" },
+            { 1, 0, "B" },
+            { 0, 1, "C" },
+            { 0, 2, "D" },
+            { 1, 2, "E" },
+        };
+
+        bool bRes = checkHorizontalIterator(
+            m_pDoc, aData, SAL_N_ELEMENTS(aData), aChecks, SAL_N_ELEMENTS(aChecks));
+
+        if (!bRes)
+            CPPUNIT_FAIL("Failed on test 2.");
     }
 
     m_pDoc->DeleteTab(0);
diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx
index b5b0e4f..032362b 100644
--- a/sc/source/core/data/dociter.cxx
+++ b/sc/source/core/data/dociter.cxx
@@ -1785,9 +1785,6 @@ void ScHorizontalCellIterator::Advance()
         if (r.maPos == r.maEnd)
             continue;
 
-        if (r.maPos->type == sc::element_type_empty)
-            continue;
-
         size_t nRow = static_cast<size_t>(mnRow);
         if (nRow < r.maPos->position)
             continue;
@@ -1796,6 +1793,9 @@ void ScHorizontalCellIterator::Advance()
             if (!advanceBlock(nRow, r.maPos, r.maEnd))
                 continue;
 
+        if (r.maPos->type == sc::element_type_empty)
+            continue;
+
         // Found in the current row.
         mnCol = i;
         bMore = true;
commit e05af970b376342ae199e6d7d77abe67cfbd2eaf
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Tue Jun 25 09:43:54 2013 -0400

    Another place where the same fix needs to be applied.
    
    Change-Id: I2d54fa4c39c28b815a051977715e1db672156957

diff --git a/mdds/0001-Fix-it-here-too.patch b/mdds/0001-Fix-it-here-too.patch
new file mode 100644
index 0000000..9884ff0
--- /dev/null
+++ b/mdds/0001-Fix-it-here-too.patch
@@ -0,0 +1,26 @@
+From e9fdebe0cad9277cfed994cae7fe9d08efbb4ba8 Mon Sep 17 00:00:00 2001
+From: Kohei Yoshida <kohei.yoshida at gmail.com>
+Date: Tue, 25 Jun 2013 09:42:19 -0400
+Subject: [PATCH] Fix it here too.
+
+---
+ include/mdds/multi_type_vector_def.inl | 3 +--
+ 1 file changed, 1 insertion(+), 2 deletions(-)
+
+diff --git a/include/mdds/multi_type_vector_def.inl b/include/mdds/multi_type_vector_def.inl
+index 685899b..cea8ae0 100644
+--- a/include/mdds/multi_type_vector_def.inl
++++ b/c/d/include/mdds/multi_type_vector_def.inl
+@@ -1829,8 +1829,7 @@ void multi_type_vector<_CellBlockFunc>::swap_single_blocks(
+         }
+         else
+         {
+-            m_blocks.insert(m_blocks.begin()+block_index+1, NULL);
+-            m_blocks[block_index+1] = new block(len);
++            m_blocks.insert(m_blocks.begin()+block_index+1, new block(len));
+             block* blk = m_blocks[block_index+1];
+             blk->mp_data = dst_data.release();
+         }
+-- 
+1.8.0
+
diff --git a/mdds/UnpackedTarball_mdds.mk b/mdds/UnpackedTarball_mdds.mk
index bbad2dd..9d85d74 100644
--- a/mdds/UnpackedTarball_mdds.mk
+++ b/mdds/UnpackedTarball_mdds.mk
@@ -17,6 +17,7 @@ $(eval $(call gb_UnpackedTarball_add_patches,mdds,\
 	mdds/mdds_0.6.0.patch \
 	mdds/0001-Workaround-for-an-old-gcc-bug.patch \
 	mdds/0001-Combine-these-two-calls.-There-is-no-reason-why-they.patch \
+	mdds/0001-Fix-it-here-too.patch \
 ))
 
 # vim: set noet sw=4 ts=4:
commit 67b8928e5832e6d32878f2f1163adb8759a97869
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Tue Jun 25 08:19:37 2013 -0400

    Try to help the Windows tinderbox.
    
    Change-Id: Ia3c6df80ff26ea00e91dd97841c4867bf0a55705

diff --git a/mdds/0001-Combine-these-two-calls.-There-is-no-reason-why-they.patch b/mdds/0001-Combine-these-two-calls.-There-is-no-reason-why-they.patch
new file mode 100644
index 0000000..783210d
--- /dev/null
+++ b/mdds/0001-Combine-these-two-calls.-There-is-no-reason-why-they.patch
@@ -0,0 +1,27 @@
+From a2a1c432f65c0612bb6f1c23a50bd41d2cf0cbdd Mon Sep 17 00:00:00 2001
+From: Kohei Yoshida <kohei.yoshida at gmail.com>
+Date: Tue, 25 Jun 2013 08:08:09 -0400
+Subject: [PATCH] Combine these two calls. There is no reason why they have to
+ separate.
+
+---
+ include/mdds/multi_type_vector_def.inl | 3 +--
+ 1 file changed, 1 insertion(+), 2 deletions(-)
+
+diff --git a/include/mdds/multi_type_vector_def.inl b/include/mdds/multi_type_vector_def.inl
+index 36dde5e..685899b 100644
+--- a/include/mdds/multi_type_vector_def.inl
++++ b/c/d/include/mdds/multi_type_vector_def.inl
+@@ -1801,8 +1801,7 @@ void multi_type_vector<_CellBlockFunc>::swap_single_blocks(
+         else
+         {
+             // Insert a new block to store the new elements.
+-            m_blocks.insert(m_blocks.begin()+block_index, NULL);
+-            m_blocks[block_index] = new block(len);
++            m_blocks.insert(m_blocks.begin()+block_index, new block(len));
+             block* blk = m_blocks[block_index];
+             blk->mp_data = dst_data.release();
+         }
+-- 
+1.8.0
+
diff --git a/mdds/UnpackedTarball_mdds.mk b/mdds/UnpackedTarball_mdds.mk
index 69fbf18..bbad2dd 100644
--- a/mdds/UnpackedTarball_mdds.mk
+++ b/mdds/UnpackedTarball_mdds.mk
@@ -16,6 +16,7 @@ $(eval $(call gb_UnpackedTarball_set_patchlevel,mdds,3))
 $(eval $(call gb_UnpackedTarball_add_patches,mdds,\
 	mdds/mdds_0.6.0.patch \
 	mdds/0001-Workaround-for-an-old-gcc-bug.patch \
+	mdds/0001-Combine-these-two-calls.-There-is-no-reason-why-they.patch \
 ))
 
 # vim: set noet sw=4 ts=4:


More information about the Libreoffice-commits mailing list