[Libreoffice-commits] .: Branch 'libreoffice-4-0' - 3 commits - sc/qa sc/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Wed Jan 2 17:53:41 PST 2013
sc/qa/unit/ucalc.cxx | 44 +++++++++++++++++++++++++++++++++++++++
sc/source/core/tool/scmatrix.cxx | 2 +
sc/source/ui/unoobj/dapiuno.cxx | 12 ++++++++--
3 files changed, 56 insertions(+), 2 deletions(-)
New commits:
commit b060b43f093dce23222fd99375b1c6bd433703d9
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Wed Jan 2 16:03:35 2013 -0500
fdo#58539: Avoid throwing exception not specified in the signature.
This should fix the crasher with the fdo#45266 document.
Change-Id: I41cf02f211e289b85c31b2d2d60e0c4d849b7e8e
diff --git a/sc/source/ui/unoobj/dapiuno.cxx b/sc/source/ui/unoobj/dapiuno.cxx
index feb8b4c..07c2693 100644
--- a/sc/source/ui/unoobj/dapiuno.cxx
+++ b/sc/source/ui/unoobj/dapiuno.cxx
@@ -2697,8 +2697,16 @@ Reference< XDataPilotField > SAL_CALL ScDataPilotFieldObj::createNameGroup( cons
Reference< XNameAccess > xFields(mrParent.getDataPilotFields(), UNO_QUERY);
if (xFields.is())
{
- xRet.set(xFields->getByName(sNewDim), UNO_QUERY);
- OSL_ENSURE(xRet.is(), "there is a name, so there should be also a field");
+ try
+ {
+ xRet.set(xFields->getByName(sNewDim), UNO_QUERY);
+ OSL_ENSURE(xRet.is(), "there is a name, so there should be also a field");
+ }
+ catch (const container::NoSuchElementException&)
+ {
+ // Avoid throwing exception that's not specified in the method signature.
+ throw RuntimeException();
+ }
}
}
return xRet;
commit 30285360e5d1fbb14bb6bf54e55a3a9f9b7619e7
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Wed Jan 2 15:49:24 2013 -0500
fdo#58539: Resizing matrix should also resize the flag storage too.
Or else resizing and then putting empty elements may crash. The flag
storage is used only for empty elements.
Change-Id: I1ada8f795a01336af185e6180bc03247c44472ba
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 4b7e4fd..6a8af5d 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -1548,6 +1548,16 @@ void Test::testMatrix()
pMat->PutString(aStr, 8, 2);
pMat->PutEmptyPath(8, 11);
checkMatrixElements<PartiallyFilledEmptyMatrix>(*pMat);
+
+ // Test resizing.
+ pMat = new ScMatrix(0, 0);
+ pMat->Resize(2, 2, 1.5);
+ pMat->PutEmpty(1, 1);
+
+ CPPUNIT_ASSERT_EQUAL(1.5, pMat->GetDouble(0, 0));
+ CPPUNIT_ASSERT_EQUAL(1.5, pMat->GetDouble(0, 1));
+ CPPUNIT_ASSERT_EQUAL(1.5, pMat->GetDouble(1, 0));
+ CPPUNIT_ASSERT_MESSAGE("PutEmpty() call failed.", pMat->IsEmpty(1, 1));
}
void Test::testEnterMixedMatrix()
diff --git a/sc/source/core/tool/scmatrix.cxx b/sc/source/core/tool/scmatrix.cxx
index 66dcb2f..0a92ffc 100644
--- a/sc/source/core/tool/scmatrix.cxx
+++ b/sc/source/core/tool/scmatrix.cxx
@@ -418,11 +418,13 @@ bool ScMatrixImpl::IsImmutable() const
void ScMatrixImpl::Resize(SCSIZE nC, SCSIZE nR)
{
maMat.resize(nR, nC);
+ maMatFlag.resize(nR, nC);
}
void ScMatrixImpl::Resize(SCSIZE nC, SCSIZE nR, double fVal)
{
maMat.resize(nR, nC, fVal);
+ maMatFlag.resize(nR, nC);
}
void ScMatrixImpl::SetErrorInterpreter( ScInterpreter* p)
commit e2b91f39f7162e031c07235a60bfe04f26fee53a
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Wed Jan 2 14:07:09 2013 -0500
fdo#56278: Write a unit test for this.
The reported bug description was very concise and unit-testable. We
should turn it into a real test.
Change-Id: I7383316e8fcf799a59b1c32a1722fd4b6b224d1c
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 55b8b9c..4b7e4fd 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -121,7 +121,16 @@ public:
*/
void testSheetsFunc();
void testVolatileFunc();
+
+ /**
+ * Basic test for formula dependency tracking.
+ */
void testFormulaDepTracking();
+
+ /**
+ * Another test for formula dependency tracking, inspired by fdo#56278.
+ */
+ void testFormulaDepTracking2();
void testFuncParam();
void testNamedRange();
void testCSV();
@@ -248,6 +257,7 @@ public:
CPPUNIT_TEST(testSheetsFunc);
CPPUNIT_TEST(testVolatileFunc);
CPPUNIT_TEST(testFormulaDepTracking);
+ CPPUNIT_TEST(testFormulaDepTracking2);
CPPUNIT_TEST(testFuncParam);
CPPUNIT_TEST(testNamedRange);
CPPUNIT_TEST(testCSV);
@@ -1223,6 +1233,30 @@ void Test::testFormulaDepTracking()
m_pDoc->DeleteTab(0);
}
+void Test::testFormulaDepTracking2()
+{
+ CPPUNIT_ASSERT_MESSAGE ("failed to insert sheet", m_pDoc->InsertTab (0, "foo"));
+
+ AutoCalcSwitch aACSwitch(m_pDoc, true); // turn on auto calculation.
+
+ double val = 2.0;
+ m_pDoc->SetValue(0, 0, 0, val);
+ val = 4.0;
+ m_pDoc->SetValue(1, 0, 0, val);
+ val = 5.0;
+ m_pDoc->SetValue(0, 1, 0, val);
+ m_pDoc->SetString(2, 0, 0, "=A1/B1");
+ m_pDoc->SetString(1, 1, 0, "=B1*C1");
+
+ CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(1, 1, 0)); // B2 should equal 2.
+
+ clearRange(m_pDoc, ScAddress(2, 0, 0)); // Delete C1.
+
+ CPPUNIT_ASSERT_EQUAL(0.0, m_pDoc->GetValue(1, 1, 0)); // B2 should now equal 0.
+
+ m_pDoc->DeleteTab(0);
+}
+
void Test::testFuncParam()
{
rtl::OUString aTabName("foo");
More information about the Libreoffice-commits
mailing list