Kaydet (Commit) 4247120b authored tarafından Eike Rathke's avatar Eike Rathke

Broadcast formula cells marked for recalc, tdf#94925 related

In fact the ScDocument::CalcFormulaTree() call in
WorkbookFragment::recalcFormulaCells() never did anything because
no formula cell was added to the tree. Only visible dirty cells
were recalculated, but not their dependents.

Change-Id: I11217fa19adb766f509d0d6854502112de547c59
Reviewed-on: https://gerrit.libreoffice.org/57431Reviewed-by: 's avatarEike Rathke <erack@redhat.com>
Tested-by: Jenkins
üst db2d8301
...@@ -125,8 +125,15 @@ public: ...@@ -125,8 +125,15 @@ public:
void finalize(); void finalize();
/** Broadcast all formula cells that are marked with
FormulaTokenArray::IsRecalcModeMustAfterImport() for a subsequent
ScDocument::CalcFormulaTree().
*/
void broadcastRecalcAfterImport();
private: private:
void initColumn(ScColumn& rCol); void initColumn(ScColumn& rCol);
void broadcastRecalcAfterImportColumn(ScColumn& rCol);
}; };
#endif #endif
......
...@@ -22,6 +22,8 @@ ...@@ -22,6 +22,8 @@
#include <listenercontext.hxx> #include <listenercontext.hxx>
#include <attarray.hxx> #include <attarray.hxx>
#include <sharedformula.hxx> #include <sharedformula.hxx>
#include <bcaslot.hxx>
#include <scopetools.hxx>
#include <svl/sharedstringpool.hxx> #include <svl/sharedstringpool.hxx>
#include <svl/languageoptions.hxx> #include <svl/languageoptions.hxx>
...@@ -720,4 +722,54 @@ void ScDocumentImport::initColumn(ScColumn& rCol) ...@@ -720,4 +722,54 @@ void ScDocumentImport::initColumn(ScColumn& rCol)
rCol.CellStorageModified(); rCol.CellStorageModified();
} }
namespace {
class CellStoreAfterImportBroadcaster
{
public:
CellStoreAfterImportBroadcaster() {}
void operator() (const sc::CellStoreType::value_type& node)
{
if (node.type == sc::element_type_formula)
{
// Broadcast all formula cells marked for recalc.
ScFormulaCell** pp = &sc::formula_block::at(*node.data, 0);
ScFormulaCell** ppEnd = pp + node.size;
for (; pp != ppEnd; ++pp)
{
if ((*pp)->GetCode()->IsRecalcModeMustAfterImport())
(*pp)->SetDirty();
}
}
}
};
}
void ScDocumentImport::broadcastRecalcAfterImport()
{
sc::AutoCalcSwitch aACSwitch( mpImpl->mrDoc, false);
ScBulkBroadcast aBulkBroadcast( mpImpl->mrDoc.GetBASM(), SfxHintId::ScDataChanged);
ScDocument::TableContainer::iterator itTab = mpImpl->mrDoc.maTabs.begin(), itTabEnd = mpImpl->mrDoc.maTabs.end();
for (; itTab != itTabEnd; ++itTab)
{
if (!*itTab)
continue;
ScTable& rTab = **itTab;
SCCOL nNumCols = rTab.aCol.size();
for (SCCOL nColIdx = 0; nColIdx < nNumCols; ++nColIdx)
broadcastRecalcAfterImportColumn(rTab.aCol[nColIdx]);
}
}
void ScDocumentImport::broadcastRecalcAfterImportColumn(ScColumn& rCol)
{
CellStoreAfterImportBroadcaster aFunc;
std::for_each(rCol.maCells.begin(), rCol.maCells.end(), aFunc);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -577,7 +577,10 @@ void WorkbookFragment::recalcFormulaCells() ...@@ -577,7 +577,10 @@ void WorkbookFragment::recalcFormulaCells()
if (bHardRecalc) if (bHardRecalc)
rDocSh.DoHardRecalc(); rDocSh.DoHardRecalc();
else else
{
getDocImport().broadcastRecalcAfterImport();
rDoc.CalcFormulaTree(false, true, false); rDoc.CalcFormulaTree(false, true, false);
}
} }
// private -------------------------------------------------------------------- // private --------------------------------------------------------------------
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment