summaryrefslogtreecommitdiff
path: root/sc/source/ui/StatisticsDialogs
diff options
context:
space:
mode:
authorDennis Francis <dennis.francis@collabora.com>2019-05-04 21:49:44 +0530
committerEike Rathke <erack@redhat.com>2019-05-20 15:43:41 +0200
commit1bfbe2a44021ca4ae6716caa39fc8a375914be5c (patch)
treea6a633e7a4f19c437442492e378002bd545f8a67 /sc/source/ui/StatisticsDialogs
parent6b2cff82957e8b2c2ca729f076e6d798a74830e6 (diff)
tdf#99938 : Allow batch of formula-cells to be written...
using a single undo document from ScMovingAverageDialog rather than write tons of formula-cells to the document one by one thus creating that many number of undo docs unnecessarily. Change-Id: I2528e0ab47f83e0c5ea40c73d00db5af14f656e0 Reviewed-on: https://gerrit.libreoffice.org/71823 Tested-by: Jenkins Reviewed-by: Eike Rathke <erack@redhat.com>
Diffstat (limited to 'sc/source/ui/StatisticsDialogs')
-rw-r--r--sc/source/ui/StatisticsDialogs/MovingAverageDialog.cxx8
-rw-r--r--sc/source/ui/StatisticsDialogs/TableFillingAndNavigationTools.cxx22
2 files changed, 27 insertions, 3 deletions
diff --git a/sc/source/ui/StatisticsDialogs/MovingAverageDialog.cxx b/sc/source/ui/StatisticsDialogs/MovingAverageDialog.cxx
index 4f4d5960e199..4d59e28336c7 100644
--- a/sc/source/ui/StatisticsDialogs/MovingAverageDialog.cxx
+++ b/sc/source/ui/StatisticsDialogs/MovingAverageDialog.cxx
@@ -75,6 +75,7 @@ ScRange ScMovingAverageDialog::ApplyOutput(ScDocShell* pDocShell)
output.nextRow();
DataCellIterator aDataCellIterator = pIterator->iterateCells();
+ std::vector<OUString> aFormulas;
for (; aDataCellIterator.hasNext(); aDataCellIterator.next())
{
@@ -98,14 +99,15 @@ ScRange ScMovingAverageDialog::ApplyOutput(ScDocShell* pDocShell)
{
aTemplate.setTemplate("=AVERAGE(%RANGE%)");
aTemplate.applyRange("%RANGE%", ScRange(aIntervalStart, aIntervalEnd));
- output.writeFormula(aTemplate.getTemplate());
+ aFormulas.push_back(aTemplate.getTemplate());
}
else
{
- output.writeFormula("=#N/A");
+ aFormulas.push_back("=#N/A");
}
- output.nextRow();
}
+
+ output.writeFormulas(aFormulas);
output.nextColumn();
}
return ScRange(output.mMinimumAddress, output.mMaximumAddress);
diff --git a/sc/source/ui/StatisticsDialogs/TableFillingAndNavigationTools.cxx b/sc/source/ui/StatisticsDialogs/TableFillingAndNavigationTools.cxx
index 15936bc2d518..f793417f04a7 100644
--- a/sc/source/ui/StatisticsDialogs/TableFillingAndNavigationTools.cxx
+++ b/sc/source/ui/StatisticsDialogs/TableFillingAndNavigationTools.cxx
@@ -163,6 +163,28 @@ void AddressWalkerWriter::writeFormula(const OUString& aFormula)
new ScFormulaCell(mpDocument, mCurrentAddress, aFormula, meGrammar), true);
}
+void AddressWalkerWriter::writeFormulas(const std::vector<OUString>& rFormulas)
+{
+ size_t nLength = rFormulas.size();
+ if (!nLength)
+ return;
+
+ const size_t nMaxLen = MAXROW - mCurrentAddress.Row() + 1;
+ // If not done already, trim the length to fit.
+ if (nLength > nMaxLen)
+ nLength = nMaxLen;
+
+ std::vector<ScFormulaCell*> aFormulaCells(nLength);
+ ScAddress aAddr(mCurrentAddress);
+ for (size_t nIdx = 0; nIdx < nLength; ++nIdx)
+ {
+ aFormulaCells[nIdx] = new ScFormulaCell(mpDocument, aAddr, rFormulas[nIdx], meGrammar);
+ aAddr.IncRow(1);
+ }
+
+ mpDocShell->GetDocFunc().SetFormulaCells(mCurrentAddress, aFormulaCells, true);
+}
+
void AddressWalkerWriter::writeMatrixFormula(const OUString& aFormula, SCCOL nCols, SCROW nRows)
{
ScRange aRange;