[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source
Kohei Yoshida
kohei.yoshida at collabora.com
Fri Feb 7 08:56:35 PST 2014
sc/qa/unit/ucalc.cxx | 37 +++++++++++++++++++++++++++++++++++++
sc/qa/unit/ucalc.hxx | 2 ++
sc/source/core/data/dociter.cxx | 2 +-
3 files changed, 40 insertions(+), 1 deletion(-)
New commits:
commit 738bd2cfd446debbc0e08fb5500004276fa28c7d
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Fri Feb 7 11:52:16 2014 -0500
fdo#74507: Ensure that we have non-null pointer to ScColumn.
Else it would cause a null pointer dereferencing when "precision as shown"
option is set.
Change-Id: Ie8d2fdb916b575fff7e0217c45c18a2c799577cb
diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx
index 188a3fc..5bb9236 100644
--- a/sc/source/core/data/dociter.cxx
+++ b/sc/source/core/data/dociter.cxx
@@ -170,7 +170,7 @@ bool ScValueIterator::GetThis(double& rValue, sal_uInt16& rErr)
bNextColumn = true;
}
- ScColumn* pCol = NULL;
+ ScColumn* pCol = &(pDoc->maTabs[mnTab])->aCol[mnCol];
if (bNextColumn)
{
// Find the next available column.
commit 6437313bdba12836d9e472654ad402601af58077
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Fri Feb 7 11:45:07 2014 -0500
fdo#74507: Write test for this to induce the crash during unit test run.
Change-Id: Ib25136c203f7da17a9b7f086916d870225bc729b
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 596bd92..275e4a0 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -56,6 +56,7 @@
#include <asciiopt.hxx>
#include <impex.hxx>
#include <columnspanset.hxx>
+#include <docoptio.hxx>
#include "formula/IFunctionDescription.hxx"
@@ -1189,6 +1190,42 @@ void Test::testHorizontalIterator()
m_pDoc->DeleteTab(0);
}
+void Test::testValueIterator()
+{
+ m_pDoc->InsertTab(0, "Test");
+
+ // Turn on "precision as shown" option.
+ ScDocOptions aOpt = m_pDoc->GetDocOptions();
+ aOpt.SetCalcAsShown(true);
+ m_pDoc->SetDocOptions(aOpt);
+
+ // Purely horizontal data layout with numeric data.
+ for (SCCOL i = 1; i <= 3; ++i)
+ m_pDoc->SetValue(ScAddress(i,2,0), i);
+
+ double fVal;
+ sal_uInt16 nErr;
+
+ {
+ const double aChecks[] = { 1.0, 2.0, 3.0 };
+ size_t nCheckLen = SAL_N_ELEMENTS(aChecks);
+
+ ScValueIterator aIter(m_pDoc, ScRange(1,2,0,3,2,0));
+ bool bHas = false;
+
+ size_t nCheckPos = 0;
+ for (bHas = aIter.GetFirst(fVal, nErr); bHas; bHas = aIter.GetNext(fVal, nErr), ++nCheckPos)
+ {
+ CPPUNIT_ASSERT_MESSAGE("Iteration longer than expected.", nCheckPos < nCheckLen);
+ CPPUNIT_ASSERT_EQUAL(aChecks[nCheckPos], fVal);
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(0), nErr);
+ }
+ }
+
+
+ m_pDoc->DeleteTab(0);
+}
+
void Test::testFormulaDepTracking()
{
CPPUNIT_ASSERT_MESSAGE ("failed to insert sheet", m_pDoc->InsertTab (0, "foo"));
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index dfa3a4b..74b79a3 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -137,6 +137,7 @@ public:
void testVolatileFunc();
void testHorizontalIterator();
+ void testValueIterator();
/**
* Basic test for formula dependency tracking.
@@ -361,6 +362,7 @@ public:
CPPUNIT_TEST(testSheetsFunc);
CPPUNIT_TEST(testVolatileFunc);
CPPUNIT_TEST(testHorizontalIterator);
+ CPPUNIT_TEST(testValueIterator);
CPPUNIT_TEST(testFormulaDepTracking);
CPPUNIT_TEST(testFormulaDepTracking2);
CPPUNIT_TEST(testCellBroadcaster);
More information about the Libreoffice-commits
mailing list