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(-)
New commits: commit 81116b30b2884f7270be442c675f51ac23e0719f Author: Kohei Yoshida <[email protected]> Date: Wed Nov 12 13:15:13 2014 -0500 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 diff --git a/sc/inc/sharedformula.hxx b/sc/inc/sharedformula.hxx index b29843f..e1799bf 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<SCROW>& 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 ed46752..02242cb 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 <attarray.hxx> +#include <sharedformula.hxx> #include <svl/sharedstringpool.hxx> #include <svl/languageoptions.hxx> @@ -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 6f66365..65d91a73 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<S splitFormulaCellGroups(rCells, aRows2); } +void SharedFormulaUtil::startListeningAsGroup( sc::StartListeningContext& rCxt, ScFormulaCell** ppSharedTop ) +{ + assert((**ppSharedTop).IsSharedTop()); + + ScFormulaCell** pp = ppSharedTop; + ScFormulaCell** ppEnd = ppSharedTop + (**ppSharedTop).GetSharedLength(); + for (; pp != ppEnd; ++pp) + { + ScFormulaCell& rFC = **pp; + rFC.StartListeningTo(rCxt); + } +} + } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
