diff options
author | Kohei Yoshida <kohei.yoshida@collabora.com> | 2014-11-12 13:15:13 -0500 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@collabora.com> | 2014-11-13 16:01:41 -0500 |
commit | 81116b30b2884f7270be442c675f51ac23e0719f (patch) | |
tree | 2a57628ac6020bcc93d14fd67249f7a7a6b07b27 | |
parent | Window build fix of 'make saxfastparser use libmlx2's sax2 interface' (diff) | |
download | core-81116b30b2884f7270be442c675f51ac23e0719f.tar.gz core-81116b30b2884f7270be442c675f51ac23e0719f.zip |
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
-rw-r--r-- | sc/inc/sharedformula.hxx | 14 | ||||
-rw-r--r-- | sc/source/core/data/documentimport.cxx | 18 | ||||
-rw-r--r-- | sc/source/core/tool/sharedformula.cxx | 13 |
3 files changed, 40 insertions, 5 deletions
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<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 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 <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 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<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: */ |