[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/qa sc/source
Kohei Yoshida
kohei.yoshida at gmail.com
Thu Jun 20 12:22:07 PDT 2013
sc/qa/unit/ucalc.cxx | 26 ++++++++++++--------------
sc/source/core/data/column.cxx | 6 +++---
sc/source/core/data/column3.cxx | 1 -
sc/source/core/data/document.cxx | 6 +++---
4 files changed, 18 insertions(+), 21 deletions(-)
New commits:
commit e0a542d59c61d6a98225df0a6bc35c144de4b012
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Thu Jun 20 15:24:03 2013 -0400
Make sure to set the cloned formula cells dirty during undo / redo.
This fixes the last failed unit test from ucalc.
Change-Id: I37a79e444084397629cac77e2137377cd555a89c
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 76e5aa2..fa7c605 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -5844,14 +5844,12 @@ void Test::testCopyPaste()
m_pDoc->SetRangeName(pGlobalRangeName);
m_pDoc->SetRangeName(0, pLocalRangeName1);
- //add formula
+ // Add formula to B1.
OUString aFormulaString("=local1+global+SUM($C$1:$D$4)");
m_pDoc->SetString(1, 0, 0, aFormulaString);
- double aValue = 0;
- m_pDoc->GetValue(1, 0, 0, aValue);
- std::cout << "Value: " << aValue << std::endl;
- ASSERT_DOUBLES_EQUAL_MESSAGE("formula should return 8", aValue, 8);
+ double fValue = m_pDoc->GetValue(ScAddress(1,0,0));
+ ASSERT_DOUBLES_EQUAL_MESSAGE("formula should return 8", fValue, 8);
//copy Sheet1.A1:C1 to Sheet2.A2:C2
ScRange aRange(0,0,0,2,0,0);
@@ -5869,17 +5867,17 @@ void Test::testCopyPaste()
aMarkData2.SetMarkArea(aRange);
ScRefUndoData* pRefUndoData= new ScRefUndoData(m_pDoc);
ScUndoPaste aUndo(
- &m_xDocShRef, ScRange(0, 1, 1, 2, 1, 1), aMarkData2, pUndoDoc, NULL, IDF_ALL, pRefUndoData, false);
+ &m_xDocShRef, aRange, aMarkData2, pUndoDoc, NULL, IDF_ALL, pRefUndoData, false);
m_pDoc->CopyFromClip(aRange, aMarkData2, nFlags, NULL, &aClipDoc);
//check values after copying
OUString aString;
- m_pDoc->GetValue(1,1,1, aValue);
+ fValue = m_pDoc->GetValue(ScAddress(1,1,1));
m_pDoc->GetFormula(1,1,1, aString);
- ASSERT_DOUBLES_EQUAL_MESSAGE("copied formula should return 2", aValue, 2);
+ ASSERT_DOUBLES_EQUAL_MESSAGE("copied formula should return 2", fValue, 2);
CPPUNIT_ASSERT_MESSAGE("formula string was not copied correctly", aString == aFormulaString);
- m_pDoc->GetValue(0,1,1, aValue);
- CPPUNIT_ASSERT_MESSAGE("copied value should be 1", aValue == 1);
+ fValue = m_pDoc->GetValue(ScAddress(0,1,1));
+ CPPUNIT_ASSERT_MESSAGE("copied value should be 1", fValue == 1);
//chack local range name after copying
pLocal1 = m_pDoc->GetRangeName(1)->findByUpperName(OUString("LOCAL1"));
@@ -5893,14 +5891,14 @@ void Test::testCopyPaste()
//check undo and redo
aUndo.Undo();
- m_pDoc->GetValue(1,1,1, aValue);
- ASSERT_DOUBLES_EQUAL_MESSAGE("after undo formula should return nothing", aValue, 0);
+ fValue = m_pDoc->GetValue(ScAddress(1,1,1));
+ ASSERT_DOUBLES_EQUAL_MESSAGE("after undo formula should return nothing", fValue, 0);
aString = m_pDoc->GetString(2, 1, 1);
CPPUNIT_ASSERT_MESSAGE("after undo string should be removed", aString.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("")));
aUndo.Redo();
- m_pDoc->GetValue(1,1,1, aValue);
- ASSERT_DOUBLES_EQUAL_MESSAGE("formula should return 2 after redo", aValue, 2);
+ fValue = m_pDoc->GetValue(ScAddress(1,1,1));
+ ASSERT_DOUBLES_EQUAL_MESSAGE("formula should return 2 after redo", fValue, 2);
aString = m_pDoc->GetString(2, 1, 1);
CPPUNIT_ASSERT_MESSAGE("Cell Sheet2.C2 should contain: test", aString.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("test")));
m_pDoc->GetFormula(1,1,1, aString);
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index a62b05c..c7ee06b 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -1587,8 +1587,9 @@ class CopyByCloneHandler : public sc::CellBlockCloneHandler
if (bForceFormula || bCloneFormula)
{
// Clone as formula cell.
- rPos.miCellPos = getDestCellStore().set(
- rPos.miCellPos, rDestPos.Row(), new ScFormulaCell(rSrcCell, getDestDoc(), rDestPos));
+ ScFormulaCell* pCell = new ScFormulaCell(rSrcCell, getDestDoc(), rDestPos);
+ pCell->SetDirtyVar();
+ rPos.miCellPos = getDestCellStore().set(rPos.miCellPos, rDestPos.Row(), pCell);
setDefaultAttrToDest(rPos, rDestPos.Row());
return;
@@ -1773,7 +1774,6 @@ void ScColumn::CopyToColumn(
pAttrArray->CopyArea( nRow1, nRow2, 0, *rColumn.pAttrArray);
}
-
if ((nFlags & IDF_CONTENTS) != 0)
{
boost::scoped_ptr<sc::CellBlockCloneHandler> pHdl(NULL);
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index 6559ca3..d2eacdd 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -388,7 +388,6 @@ void ScColumn::CopyCellsInRangeToColumn(
;
}
-
if (bLastBlock)
break;
}
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 2c977f2..05c252e 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -91,6 +91,7 @@
#include "formulacell.hxx"
#include "clipcontext.hxx"
#include "listenercontext.hxx"
+#include "scopetools.hxx"
#include <map>
#include <limits>
@@ -1920,13 +1921,13 @@ void ScDocument::UndoToDocument(const ScRange& rRange,
sal_uInt16 nFlags, bool bOnlyMarked, ScDocument* pDestDoc,
const ScMarkData* pMarks)
{
+ sc::AutoCalcSwitch aAutoCalcSwitch(*this, false);
+
ScRange aNewRange = rRange;
aNewRange.Justify();
SCTAB nTab1 = aNewRange.aStart.Tab();
SCTAB nTab2 = aNewRange.aEnd.Tab();
- bool bOldAutoCalc = pDestDoc->GetAutoCalc();
- pDestDoc->SetAutoCalc( false ); // avoid multiple calculations
sc::CopyToDocContext aCxt(*pDestDoc);
if (nTab1 > 0)
CopyToDocument( 0,0,0, MAXCOL,MAXROW,nTab1-1, IDF_FORMULA, false, pDestDoc, pMarks );
@@ -1942,7 +1943,6 @@ void ScDocument::UndoToDocument(const ScRange& rRange,
if (nTab2 < static_cast<SCTAB>(maTabs.size()))
CopyToDocument( 0,0,nTab2+1, MAXCOL,MAXROW,maTabs.size(), IDF_FORMULA, false, pDestDoc, pMarks );
- pDestDoc->SetAutoCalc( bOldAutoCalc );
}
// bUseRangeForVBA added for VBA api support to allow content of a specified
More information about the Libreoffice-commits
mailing list