summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2014-03-13 16:08:03 -0400
committerKohei Yoshida <kohei.yoshida@collabora.com>2014-03-13 16:09:32 -0400
commit36bcab7859b7dfa1f1377bb5865c881742f178dd (patch)
treee4f2a3f92306cc178a6a853401daf6fc3c964653
parentce524556df4bf06cde1229475b9de9822a89f62b (diff)
fdo#76132: Don't create a formula group of length 1.
That's asking for trouble. Change-Id: I6aaa4d1e2aed4f166ee216c3eb02d3b7794c9a8c
-rw-r--r--sc/source/core/data/column4.cxx35
1 files changed, 25 insertions, 10 deletions
diff --git a/sc/source/core/data/column4.cxx b/sc/source/core/data/column4.cxx
index fa188180f272..2f216233e800 100644
--- a/sc/source/core/data/column4.cxx
+++ b/sc/source/core/data/column4.cxx
@@ -334,25 +334,40 @@ void ScColumn::CloneFormulaCell( const ScFormulaCell& rSrc, const std::vector<sc
{
SCROW nRow1 = itSpan->mnRow1, nRow2 = itSpan->mnRow2;
size_t nLen = nRow2 - nRow1 + 1;
+ assert(nLen > 0);
aFormulas.clear();
aFormulas.reserve(nLen);
ScAddress aPos(nCol, nRow1, nTab);
- ScFormulaCellGroupRef xGroup(new ScFormulaCellGroup);
- xGroup->setCode(*rSrc.GetCode());
- xGroup->compileCode(*pDocument, aPos, pDocument->GetGrammar());
- for (size_t i = 0; i < nLen; ++i, aPos.IncRow())
+
+ if (nLen == 1)
{
- ScFormulaCell* pCell = new ScFormulaCell(pDocument, aPos, xGroup);
- if (i == 0)
- {
- xGroup->mpTopCell = pCell;
- xGroup->mnLength = nLen;
- }
+ // Single, ungrouped formula cell.
+ ScFormulaCell* pCell =
+ new ScFormulaCell(rSrc, *pDocument, aPos, pDocument->GetGrammar());
pCell->StartListeningTo(aCxt);
pCell->SetDirty();
aFormulas.push_back(pCell);
}
+ else
+ {
+ // Create a group of formula cells.
+ ScFormulaCellGroupRef xGroup(new ScFormulaCellGroup);
+ xGroup->setCode(*rSrc.GetCode());
+ xGroup->compileCode(*pDocument, aPos, pDocument->GetGrammar());
+ for (size_t i = 0; i < nLen; ++i, aPos.IncRow())
+ {
+ ScFormulaCell* pCell = new ScFormulaCell(pDocument, aPos, xGroup);
+ if (i == 0)
+ {
+ xGroup->mpTopCell = pCell;
+ xGroup->mnLength = nLen;
+ }
+ pCell->StartListeningTo(aCxt);
+ pCell->SetDirty();
+ aFormulas.push_back(pCell);
+ }
+ }
itPos = maCells.set(itPos, nRow1, aFormulas.begin(), aFormulas.end());