[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source
Markus Mohrhard
markus.mohrhard at collabora.co.uk
Sat Mar 28 08:39:21 PDT 2015
sc/qa/unit/ucalc.hxx | 2 +
sc/qa/unit/ucalc_formula.cxx | 59 ++++++++++++++++++++++++++++++++++++++++++
sc/source/core/tool/token.cxx | 40 +++++++++++++++++++++++++---
3 files changed, 97 insertions(+), 4 deletions(-)
New commits:
commit 7937984a6a04446c0d3484832e6748ad925ddc80
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Sat Mar 28 15:35:13 2015 +0100
test for tdf#90001
Change-Id: If0cb056d5a5e82bec1f4b863e40ec05b405280ac
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index a60e478..1cec088 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -136,6 +136,7 @@ public:
void testFormulaRefUpdate();
void testFormulaRefUpdateRange();
void testFormulaRefUpdateSheets();
+ void testFormulaRefUpdateSheetsDelete();
void testFormulaRefUpdateInsertRows();
void testFormulaRefUpdateInsertColumns();
void testFormulaRefUpdateMove();
@@ -456,6 +457,7 @@ public:
CPPUNIT_TEST(testFormulaRefUpdate);
CPPUNIT_TEST(testFormulaRefUpdateRange);
CPPUNIT_TEST(testFormulaRefUpdateSheets);
+ CPPUNIT_TEST(testFormulaRefUpdateSheetsDelete);
CPPUNIT_TEST(testFormulaRefUpdateInsertRows);
CPPUNIT_TEST(testFormulaRefUpdateInsertColumns);
CPPUNIT_TEST(testFormulaRefUpdateMove);
diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index ca731a2..fe7d417 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -1609,6 +1609,65 @@ void Test::testFormulaRefUpdateInsertRows()
m_pDoc->DeleteTab(0);
}
+void Test::testFormulaRefUpdateSheetsDelete()
+{
+ m_pDoc->InsertTab(0, "Sheet1");
+ m_pDoc->InsertTab(1, "Sheet2");
+ m_pDoc->InsertTab(2, "Sheet3");
+ m_pDoc->InsertTab(3, "Sheet4");
+
+ m_pDoc->SetString(ScAddress(1,1,1), "=SUM(Sheet1.A2:Sheet3.A2");
+ m_pDoc->SetString(ScAddress(2,1,1), "=SUM(Sheet1.A1:Sheet2.A1");
+ m_pDoc->SetString(ScAddress(3,1,1), "=SUM(Sheet2.A3:Sheet4.A3");
+
+ m_pDoc->SetString(ScAddress(1,2,1), "=SUM($Sheet1.A2:$Sheet3.A2");
+ m_pDoc->SetString(ScAddress(2,2,1), "=SUM($Sheet1.A1:$Sheet2.A1");
+ m_pDoc->SetString(ScAddress(3,2,1), "=SUM($Sheet2.A3:$Sheet4.A3");
+
+ m_pDoc->DeleteTab(2);
+
+ if (!checkFormula(*m_pDoc, ScAddress(1,1,1), "SUM(Sheet1.A2:Sheet2.A2)"))
+ CPPUNIT_FAIL("Wrong Formula");
+
+ if (!checkFormula(*m_pDoc, ScAddress(2,1,1), "SUM(Sheet1.A1:Sheet2.A1)"))
+ CPPUNIT_FAIL("Wrong Formula");
+
+ if (!checkFormula(*m_pDoc, ScAddress(3,1,1), "SUM(Sheet2.A3:Sheet4.A3)"))
+ CPPUNIT_FAIL("Wrong Formula");
+
+ if (!checkFormula(*m_pDoc, ScAddress(1,2,1), "SUM($Sheet1.A2:$Sheet2.A2)"))
+ CPPUNIT_FAIL("Wrong Formula");
+
+ if (!checkFormula(*m_pDoc, ScAddress(2,2,1), "SUM($Sheet1.A1:$Sheet2.A1)"))
+ CPPUNIT_FAIL("Wrong Formula");
+
+ if (!checkFormula(*m_pDoc, ScAddress(3,2,1), "SUM($Sheet2.A3:$Sheet4.A3)"))
+ CPPUNIT_FAIL("Wrong Formula");
+
+ m_pDoc->DeleteTab(0);
+
+ if (!checkFormula(*m_pDoc, ScAddress(1,1,0), "SUM(Sheet2.A2:Sheet2.A2)"))
+ CPPUNIT_FAIL("Wrong Formula");
+
+ if (!checkFormula(*m_pDoc, ScAddress(2,1,0), "SUM(Sheet2.A1:Sheet2.A1)"))
+ CPPUNIT_FAIL("Wrong Formula");
+
+ if (!checkFormula(*m_pDoc, ScAddress(3,1,0), "SUM(Sheet2.A3:Sheet4.A3)"))
+ CPPUNIT_FAIL("Wrong Formula");
+
+ if (!checkFormula(*m_pDoc, ScAddress(1,2,0), "SUM($Sheet2.A2:$Sheet2.A2)"))
+ CPPUNIT_FAIL("Wrong Formula");
+
+ if (!checkFormula(*m_pDoc, ScAddress(2,2,0), "SUM($Sheet2.A1:$Sheet2.A1)"))
+ CPPUNIT_FAIL("Wrong Formula");
+
+ if (!checkFormula(*m_pDoc, ScAddress(3,2,0), "SUM($Sheet2.A3:$Sheet4.A3)"))
+ CPPUNIT_FAIL("Wrong Formula");
+
+ m_pDoc->DeleteTab(0);
+ m_pDoc->DeleteTab(0);
+}
+
void Test::testFormulaRefUpdateInsertColumns()
{
sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on.
commit be1b3daeeb64a44e577510561d02147b87db72c2
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Sat Mar 28 05:43:33 2015 +0100
3D refs with more than one sheet should not set sheets deleted, tdf#90001
Change-Id: I501ad421c283ec6a1f2629aa424f4d4c32228516
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 6b582ec..ada4f91 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -3373,6 +3373,41 @@ bool adjustSingleRefOnInsertedTab( ScSingleRefData& rRef, SCTAB nInsPos, SCTAB n
return false;
}
+bool adjustDoubleRefOnDeleteTab(ScComplexRefData& rRef, SCTAB nDelPos, SCTAB nSheets, const ScAddress& rOldPos, const ScAddress& rNewPos)
+{
+ ScSingleRefData& rRef1 = rRef.Ref1;
+ ScSingleRefData& rRef2 = rRef.Ref2;
+ ScAddress aStartPos = rRef1.toAbs(rOldPos);
+ ScAddress aEndPos = rRef2.toAbs(rOldPos);
+ bool bMoreThanOneTab = aStartPos.Tab() != aEndPos.Tab();
+ bool bModified = false;
+ if (bMoreThanOneTab && aStartPos.Tab() == nDelPos)
+ {
+ if (rRef1.IsTabRel())
+ {
+ aStartPos.IncTab(nSheets);
+ rRef1.SetAddress(aStartPos, rOldPos);
+ }
+ bModified = true;
+ }
+ else
+ {
+ bModified = adjustSingleRefOnDeletedTab(rRef1, nDelPos, nSheets, rOldPos, rNewPos);
+ }
+
+ if (bMoreThanOneTab && aEndPos.Tab() == nDelPos)
+ {
+ aEndPos.IncTab(-nSheets);
+ rRef2.SetAddress(aEndPos, rNewPos);
+ bModified = true;
+ }
+ else
+ {
+ bModified |= adjustSingleRefOnDeletedTab(rRef2, nDelPos, nSheets, rOldPos, rNewPos);
+ }
+ return bModified;
+}
+
}
sc::RefUpdateResult ScTokenArray::AdjustReferenceOnDeletedTab( sc::RefUpdateDeleteTabContext& rCxt, const ScAddress& rOldPos )
@@ -3400,10 +3435,7 @@ sc::RefUpdateResult ScTokenArray::AdjustReferenceOnDeletedTab( sc::RefUpdateDele
{
formula::FormulaToken* pToken = *p;
ScComplexRefData& rRef = *pToken->GetDoubleRef();
- if (adjustSingleRefOnDeletedTab(rRef.Ref1, rCxt.mnDeletePos, rCxt.mnSheets, rOldPos, aNewPos))
- aRes.mbReferenceModified = true;
- if (adjustSingleRefOnDeletedTab(rRef.Ref2, rCxt.mnDeletePos, rCxt.mnSheets, rOldPos, aNewPos))
- aRes.mbReferenceModified = true;
+ aRes.mbReferenceModified |= adjustDoubleRefOnDeleteTab(rRef, rCxt.mnDeletePos, rCxt.mnSheets, rOldPos, aNewPos);
}
break;
case svIndex:
More information about the Libreoffice-commits
mailing list