[Libreoffice-commits] core.git: 3 commits - sc/qa sc/source
Kohei Yoshida
kohei.yoshida at collabora.com
Tue Jul 29 14:21:53 PDT 2014
sc/qa/unit/ucalc.hxx | 2 ++
sc/qa/unit/ucalc_formula.cxx | 38 ++++++++++++++++++++++++++++++++++++++
sc/source/ui/docshell/docfunc.cxx | 34 +++++++++++++++++++++++++++++++---
sc/source/ui/undo/undobase.cxx | 2 +-
4 files changed, 72 insertions(+), 4 deletions(-)
New commits:
commit 1fcc30503549b47046c84333af542ed739f685ba
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Tue Jul 29 17:19:28 2014 -0400
fdo#80846: Get the parameter order right.
It's column, row, tab in this order, not tab, column row.
Change-Id: I32e69a403feaf18532c7ac241fa2a98fc65a4ba7
diff --git a/sc/source/ui/undo/undobase.cxx b/sc/source/ui/undo/undobase.cxx
index dc7efd4..2e244ec 100644
--- a/sc/source/ui/undo/undobase.cxx
+++ b/sc/source/ui/undo/undobase.cxx
@@ -172,7 +172,7 @@ public:
if (!bVal)
return;
- ScRange aRange(mnCurTab, mnCurCol, nRow1, mnCurTab, mnCurCol, nRow2);
+ ScRange aRange(mnCurCol, nRow1, mnCurTab, mnCurCol, nRow2, mnCurTab);
mrDoc.BroadcastCells(aRange, SC_HINT_DATACHANGED);
};
};
commit 2ef608aa35ee50a271ba817ef1538e663b4e0cae
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Tue Jul 29 16:55:32 2014 -0400
fdo#80846: Write test for this.
Change-Id: I80dc88028579a76c7116b3558cf560f9bfed109c
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index 880fde6..cf3d0d5 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -131,6 +131,7 @@ public:
void testFormulaRefUpdateInsertColumns();
void testFormulaRefUpdateMove();
void testFormulaRefUpdateMoveUndo();
+ void testFormulaRefUpdateDeleteContent();
void testFormulaRefUpdateNamedExpression();
void testFormulaRefUpdateNamedExpressionMove();
void testFormulaRefUpdateNamedExpressionExpandRef();
@@ -405,6 +406,7 @@ public:
CPPUNIT_TEST(testFormulaRefUpdateInsertColumns);
CPPUNIT_TEST(testFormulaRefUpdateMove);
CPPUNIT_TEST(testFormulaRefUpdateMoveUndo);
+ CPPUNIT_TEST(testFormulaRefUpdateDeleteContent);
CPPUNIT_TEST(testFormulaRefUpdateNamedExpression);
CPPUNIT_TEST(testFormulaRefUpdateNamedExpressionMove);
CPPUNIT_TEST(testFormulaRefUpdateNamedExpressionExpandRef);
diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index f9a5ac1..c7f03fa 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -1848,6 +1848,44 @@ void Test::testFormulaRefUpdateMoveUndo()
m_pDoc->DeleteTab(0);
}
+void Test::testFormulaRefUpdateDeleteContent()
+{
+ sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on.
+
+ m_pDoc->InsertTab(0, "Test");
+
+ // Set value in B2.
+ m_pDoc->SetValue(ScAddress(1,1,0), 2.0);
+ // Set formula in C2 to reference B2.
+ m_pDoc->SetString(ScAddress(2,1,0), "=B2");
+
+ CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(ScAddress(2,1,0)));
+
+ // Delete B2.
+ ScDocFunc& rFunc = getDocShell().GetDocFunc();
+ ScMarkData aMark;
+ aMark.SetMarkArea(ScAddress(1,1,0));
+ rFunc.DeleteContents(aMark, IDF_CONTENTS, true, true);
+
+ CPPUNIT_ASSERT_MESSAGE("B2 should be empty.", m_pDoc->GetCellType(ScAddress(1,1,0)) == CELLTYPE_NONE);
+ CPPUNIT_ASSERT_EQUAL(0.0, m_pDoc->GetValue(ScAddress(2,1,0)));
+
+ SfxUndoManager* pUndoMgr = m_pDoc->GetUndoManager();
+ CPPUNIT_ASSERT(pUndoMgr);
+
+ // Undo and check the result of C2.
+ pUndoMgr->Undo();
+ CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(ScAddress(1,1,0))); // B2
+ CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(ScAddress(2,1,0))); // C2
+
+ // Redo and check.
+ pUndoMgr->Redo();
+ CPPUNIT_ASSERT_MESSAGE("B2 should be empty.", m_pDoc->GetCellType(ScAddress(1,1,0)) == CELLTYPE_NONE);
+ CPPUNIT_ASSERT_EQUAL(0.0, m_pDoc->GetValue(ScAddress(2,1,0)));
+
+ m_pDoc->DeleteTab(0);
+}
+
void Test::testFormulaRefUpdateNamedExpression()
{
m_pDoc->InsertTab(0, "Formula");
commit 7b13c6d96407b7f4c0c578693bd3b9629015489c
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Tue Jul 29 16:18:05 2014 -0400
Bring this logic from ScViewFaunc::DeleteContents to ScDocFunc's.
To make the bug reported in fdo#80846 reproducible.
Change-Id: Iec400f26c6c6af9ae3bd0afd4fce75939ab1e23d
diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx
index adce808..d41caee 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -628,6 +628,9 @@ bool ScDocFunc::DeleteContents( const ScMarkData& rMark, sal_uInt16 nFlags,
aMultiMark );
}
+ // To keep track of all non-empty cells within the deleted area.
+ boost::shared_ptr<ScSimpleUndo::DataSpansType> pDataSpans;
+
if ( bRecord )
{
pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
@@ -645,6 +648,27 @@ bool ScDocFunc::DeleteContents( const ScMarkData& rMark, sal_uInt16 nFlags,
// note captions are handled in drawing undo
nUndoDocFlags |= IDF_NOCAPTIONS;
rDoc.CopyToDocument( aExtendedRange, nUndoDocFlags, bMulti, pUndoDoc, &aMultiMark );
+
+ pDataSpans.reset(new ScSimpleUndo::DataSpansType);
+
+ ScMarkData::iterator it = aMultiMark.begin(), itEnd = aMultiMark.end();
+ for (; it != itEnd; ++it)
+ {
+ SCTAB nTab = *it;
+
+ SCCOL nCol1 = aMarkRange.aStart.Col(), nCol2 = aMarkRange.aEnd.Col();
+ SCROW nRow1 = aMarkRange.aStart.Row(), nRow2 = aMarkRange.aEnd.Row();
+
+ std::pair<ScSimpleUndo::DataSpansType::iterator,bool> r =
+ pDataSpans->insert(nTab, new sc::ColumnSpanSet(false));
+
+ if (r.second)
+ {
+ ScSimpleUndo::DataSpansType::iterator it2 = r.first;
+ sc::ColumnSpanSet* pSet = it2->second;
+ pSet->scan(rDoc, nTab, nCol1, nRow1, nCol2, nRow2, true);
+ }
+ }
}
//! HideAllCursors(); // falls Zusammenfassung aufgehoben wird
@@ -652,9 +676,13 @@ bool ScDocFunc::DeleteContents( const ScMarkData& rMark, sal_uInt16 nFlags,
// add undo action after drawing undo is complete (objects and note captions)
if( bRecord )
- rDocShell.GetUndoManager()->AddUndoAction(
- new ScUndoDeleteContents( &rDocShell, aMultiMark, aExtendedRange,
- pUndoDoc, bMulti, nFlags, bDrawUndo ) );
+ {
+ ScUndoDeleteContents* pUndo =
+ new ScUndoDeleteContents(
+ &rDocShell, aMultiMark, aExtendedRange, pUndoDoc, bMulti, nFlags, bDrawUndo);
+ rDocShell.GetUndoManager()->AddUndoAction(pUndo);
+ pUndo->SetDataSpans(pDataSpans);
+ }
if (!AdjustRowHeight( aExtendedRange ))
rDocShell.PostPaint( aExtendedRange, PAINT_GRID, nExtFlags );
More information about the Libreoffice-commits
mailing list