[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source
Kohei Yoshida
kohei.yoshida at collabora.com
Tue May 6 12:25:50 PDT 2014
sc/qa/unit/ucalc.cxx | 9 +++++++
sc/qa/unit/ucalc.hxx | 8 ++++++
sc/qa/unit/ucalc_formula.cxx | 52 +++++++++++++++++++++++++++++-------------
sc/source/core/tool/token.cxx | 2 -
4 files changed, 54 insertions(+), 17 deletions(-)
New commits:
commit 7aa32a759fb7b440f870739f7bb680f405f338ce
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Tue May 6 15:24:50 2014 -0400
fdo#77647: Fix the column insertion use case.
Change-Id: I7c78f54c9386eced16113e69e625d23ed4acedd7
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index b1f8e02..636ff01 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -2546,7 +2546,7 @@ bool expandRange( const sc::RefUpdateContext& rCxt, ScRange& rRefRange, const Sc
// Selected range is only partially overlapping in vertical direction. Bail out.
return false;
- if (!rCxt.mrDoc.IsExpandRefs() && rSelectedRange.aStart.Col() == rRefRange.aStart.Col())
+ if (!rCxt.mrDoc.IsExpandRefs() && rSelectedRange.aStart.Col() <= rRefRange.aStart.Col())
// Selected range is at the left end and the edge expansion is turned off. No expansion.
return false;
commit 48631bde1ccdbd618e5892b7050822b61b843332
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Tue May 6 15:23:57 2014 -0400
fdo#77647: Test for reference adjustment on column insertion.
Change-Id: Ic95ff3892efbfc003ae9976b4fba4129de11bbef
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 97e6521..d764673 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -62,6 +62,7 @@
#include <patattr.hxx>
#include <docpool.hxx>
#include <globalnames.hxx>
+#include <inputopt.hxx>
#include "formula/IFunctionDescription.hxx"
@@ -6139,6 +6140,14 @@ ScUndoPaste* Test::createUndoPaste(ScDocShell& rDocSh, const ScRange& rRange, Sc
&rDocSh, rRange, aMarkData, pUndoDoc, NULL, IDF_ALL, pRefUndoData, false);
}
+void Test::setExpandRefs(bool bExpand)
+{
+ ScModule* pMod = SC_MOD();
+ ScInputOptions aOpt = pMod->GetInputOptions();
+ aOpt.SetExpandRefs(bExpand);
+ pMod->SetInputOptions(aOpt);
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(Test);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index f812630..dbe84e7 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -47,6 +47,12 @@ public:
static void pasteFromClip(ScDocument* pDestDoc, const ScRange& rDestRange, ScDocument* pClipDoc);
static ScUndoPaste* createUndoPaste(ScDocShell& rDocSh, const ScRange& rRange, ScDocument* pUndoDoc);
+ /**
+ * Enable or disable expand reference options which controls how
+ * references in formula are expanded when inserting rows or columns.
+ */
+ static void setExpandRefs(bool bExpand);
+
template<size_t _Size>
static ScRange insertRangeData(ScDocument* pDoc, const ScAddress& rPos, const char* aData[][_Size], size_t nRowCount)
{
@@ -119,6 +125,7 @@ public:
void testFormulaRefUpdateRange();
void testFormulaRefUpdateSheets();
void testFormulaRefUpdateInsertRows();
+ void testFormulaRefUpdateInsertColumns();
void testFormulaRefUpdateMove();
void testFormulaRefUpdateMoveUndo();
void testFormulaRefUpdateNamedExpression();
@@ -375,6 +382,7 @@ public:
CPPUNIT_TEST(testFormulaRefUpdateRange);
CPPUNIT_TEST(testFormulaRefUpdateSheets);
CPPUNIT_TEST(testFormulaRefUpdateInsertRows);
+ CPPUNIT_TEST(testFormulaRefUpdateInsertColumns);
CPPUNIT_TEST(testFormulaRefUpdateMove);
CPPUNIT_TEST(testFormulaRefUpdateMoveUndo);
CPPUNIT_TEST(testFormulaRefUpdateNamedExpression);
diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index efe73a0..3f75db8 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -17,7 +17,6 @@
#include "scopetools.hxx"
#include "formulacell.hxx"
#include "formulagroup.hxx"
-#include "inputopt.hxx"
#include "scmod.hxx"
#include "docsh.hxx"
#include "docfunc.hxx"
@@ -1036,10 +1035,7 @@ void Test::testFormulaRefUpdateRange()
sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on.
- ScModule* pMod = SC_MOD();
- ScInputOptions aOpt = pMod->GetInputOptions();
- aOpt.SetExpandRefs(false);
- pMod->SetInputOptions(aOpt);
+ setExpandRefs(false);
// Set values to B2:C5.
m_pDoc->SetValue(ScAddress(1,1,0), 1);
@@ -1166,7 +1162,7 @@ void Test::testFormulaRefUpdateRange()
clearRange(m_pDoc, ScRange(0,0,0,20,20,0));
// Disable expansion of range reference on insertion in adjacent areas.
- m_pDoc->SetExpandRefs(false);
+ setExpandRefs(false);
// Fill C2:D3 with values.
m_pDoc->SetValue(ScAddress(2,1,0), 1);
@@ -1251,8 +1247,7 @@ void Test::testFormulaRefUpdateRange()
clearRange(m_pDoc, ScRange(0,0,0,20,20,0));
// Turn edge expansion on.
- aOpt.SetExpandRefs(true);
- pMod->SetInputOptions(aOpt);
+ setExpandRefs(true);
// Fill C6:D7 with values.
m_pDoc->SetValue(ScAddress(2,5,0), 1);
@@ -1479,10 +1474,7 @@ void Test::testFormulaRefUpdateSheets()
void Test::testFormulaRefUpdateInsertRows()
{
- ScModule* pMod = SC_MOD();
- ScInputOptions aOpt = pMod->GetInputOptions();
- aOpt.SetExpandRefs(false);
- pMod->SetInputOptions(aOpt);
+ setExpandRefs(false);
sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on.
m_pDoc->InsertTab(0, "Formula");
@@ -1537,6 +1529,37 @@ void Test::testFormulaRefUpdateInsertRows()
m_pDoc->DeleteTab(0);
}
+void Test::testFormulaRefUpdateInsertColumns()
+{
+ sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on.
+ setExpandRefs(false);
+
+ m_pDoc->InsertTab(0, "Formula");
+
+ // Set values in B1:B3.
+ m_pDoc->SetValue(ScAddress(1,0,0), 1.0);
+ m_pDoc->SetValue(ScAddress(1,1,0), 2.0);
+ m_pDoc->SetValue(ScAddress(1,2,0), 3.0);
+
+ // Reference them in B4.
+ m_pDoc->SetString(ScAddress(1,3,0), "=SUM(B1:B3)");
+ CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc->GetValue(ScAddress(1,3,0)));
+
+ // Inert columns over A:B.
+ ScMarkData aMark;
+ aMark.SelectOneTable(0);
+ ScDocFunc& rFunc = getDocShell().GetDocFunc();
+ rFunc.InsertCells(ScRange(0,0,0,1,MAXROW,0), &aMark, INS_INSCOLS, false, true, false);
+
+ // Now, the original column B has moved to column D.
+ if (!checkFormula(*m_pDoc, ScAddress(3,3,0), "SUM(D1:D3)"))
+ CPPUNIT_FAIL("Wrong formula in D4 after column insertion.");
+
+ CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc->GetValue(ScAddress(3,3,0)));
+
+ m_pDoc->DeleteTab(0);
+}
+
void Test::testFormulaRefUpdateMove()
{
m_pDoc->InsertTab(0, "Sheet1");
@@ -1982,10 +2005,7 @@ void Test::testFormulaRefUpdateNamedExpressionMove()
void Test::testFormulaRefUpdateNamedExpressionExpandRef()
{
- ScModule* pMod = SC_MOD();
- ScInputOptions aOpt = pMod->GetInputOptions();
- aOpt.SetExpandRefs(true); // turn on automatic range expansion.
- pMod->SetInputOptions(aOpt);
+ setExpandRefs(true);
sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on.
More information about the Libreoffice-commits
mailing list