summaryrefslogtreecommitdiff
path: root/sc/source/core/data/column3.cxx
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2014-11-17 23:25:28 -0500
committerKohei Yoshida <kohei.yoshida@collabora.com>2014-11-18 08:31:58 -0500
commit1acc10db8c6fd413567ced4feb2543ac8f150eb0 (patch)
tree87256f9f3ff755324a4b101e67b55ebf86256541 /sc/source/core/data/column3.cxx
parent087b6041794a6a04c2e957ebf9a03fd223fa0fb3 (diff)
Register group area listeners as needed when inserting/deleting cells.
Change-Id: I583ace5d134d526d660d4ff0bbf4a16aa10cbe5a
Diffstat (limited to 'sc/source/core/data/column3.cxx')
-rw-r--r--sc/source/core/data/column3.cxx35
1 files changed, 26 insertions, 9 deletions
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index 67c51be7e39e..bba48f2e029c 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -1506,16 +1506,34 @@ public:
}
};
-class StartNeededListenerHandler
+class StartNeededListenersHandler
{
- ScDocument* mpDoc;
+ sc::StartListeningContext* mpCxt;
public:
- StartNeededListenerHandler(ScDocument* pDoc) : mpDoc(pDoc) {}
+ StartNeededListenersHandler( sc::StartListeningContext& rCxt ) : mpCxt(&rCxt) {}
- void operator() (size_t, ScFormulaCell* p)
+ void operator() ( sc::CellStoreType::value_type& aBlk )
{
- if (p->NeedsListening())
- p->StartListeningTo(mpDoc);
+ if (aBlk.type != sc::element_type_formula)
+ return;
+
+ ScFormulaCell** pp = &sc::formula_block::at(*aBlk.data, 0);
+ ScFormulaCell** ppEnd = pp + aBlk.size;
+
+ for (; pp != ppEnd; ++pp)
+ {
+ ScFormulaCell& rFC = **pp;
+ if (!rFC.NeedsListening())
+ continue;
+
+ if (rFC.IsSharedTop())
+ {
+ sc::SharedFormulaUtil::startListeningAsGroup(*mpCxt, pp);
+ pp += rFC.GetSharedLength() - 1; // Move to the last cell in the group.
+ }
+ else
+ rFC.StartListeningTo(*mpCxt);
+ }
}
};
@@ -1527,10 +1545,9 @@ void ScColumn::StartAllListeners()
sc::ProcessFormula(maCells, aFunc);
}
-void ScColumn::StartNeededListeners()
+void ScColumn::StartNeededListeners( sc::StartListeningContext& rCxt )
{
- StartNeededListenerHandler aFunc(pDocument);
- sc::ProcessFormula(maCells, aFunc);
+ std::for_each(maCells.begin(), maCells.end(), StartNeededListenersHandler(rCxt));
}
namespace {