From e969c131a2d8ca21d32e5caaa302ee904021a1e5 Mon Sep 17 00:00:00 2001 From: Kohei Yoshida Date: Wed, 12 Nov 2014 13:15:13 -0500 Subject: Differentiate shared and non-shared formula cells when registering. For now this is just for a pure redirection, but later we'll use this to do a different area listening registration for grouped formula cells. Change-Id: I8e68bb53c3e96821175ae562ef36ec5e800c8688 --- sc/inc/sharedformula.hxx | 14 ++++++++++++++ sc/source/core/data/documentimport.cxx | 18 +++++++++++++----- sc/source/core/tool/sharedformula.cxx | 13 +++++++++++++ 3 files changed, 40 insertions(+), 5 deletions(-) (limited to 'sc') diff --git a/sc/inc/sharedformula.hxx b/sc/inc/sharedformula.hxx index b29843f8547a..e1799bf70e0b 100644 --- a/sc/inc/sharedformula.hxx +++ b/sc/inc/sharedformula.hxx @@ -17,6 +17,8 @@ namespace sc { +class StartListeningContext; + class SharedFormulaUtil { public: @@ -109,6 +111,18 @@ public: * @param rRows row positions at which to unshare formula cells. */ static void unshareFormulaCells(CellStoreType& rCells, std::vector& rRows); + + /** + * Have all formula cells belonging to a group start listening to their + * references. + * + * @param rCxt context object. + * @param ppSharedTop memory position of the pointer of the topmost + * formula cell instance in the cell storage. The + * caller is responsible for ensuring that it is indeed + * the topmost cell of a shared formula group. + */ + static void startListeningAsGroup( StartListeningContext& rCxt, ScFormulaCell** ppSharedTop ); }; } diff --git a/sc/source/core/data/documentimport.cxx b/sc/source/core/data/documentimport.cxx index ed46752bdfa1..02242cbac7bc 100644 --- a/sc/source/core/data/documentimport.cxx +++ b/sc/source/core/data/documentimport.cxx @@ -21,6 +21,7 @@ #include "paramisc.hxx" #include "listenercontext.hxx" #include +#include #include #include @@ -558,12 +559,19 @@ public: if (node.type == sc::element_type_formula) { // Have all formula cells start listening to the document. - sc::formula_block::iterator it = sc::formula_block::begin(*node.data); - sc::formula_block::iterator itEnd = sc::formula_block::end(*node.data); - for (; it != itEnd; ++it) + ScFormulaCell** pp = &sc::formula_block::at(*node.data, 0); + ScFormulaCell** ppEnd = pp + node.size; + for (; pp != ppEnd; ++pp) { - ScFormulaCell& rFC = **it; - rFC.StartListeningTo(mrDocImpl.maListenCxt); + ScFormulaCell& rFC = **pp; + if (rFC.IsSharedTop()) + { + // Register formula cells as a group. + sc::SharedFormulaUtil::startListeningAsGroup(mrDocImpl.maListenCxt, pp); + pp += rFC.GetSharedLength() - 1; // Move to the last one in the group. + } + else + rFC.StartListeningTo(mrDocImpl.maListenCxt); } } } diff --git a/sc/source/core/tool/sharedformula.cxx b/sc/source/core/tool/sharedformula.cxx index 6f6636557915..65d91a73d7dc 100644 --- a/sc/source/core/tool/sharedformula.cxx +++ b/sc/source/core/tool/sharedformula.cxx @@ -326,6 +326,19 @@ void SharedFormulaUtil::unshareFormulaCells(CellStoreType& rCells, std::vector