diff options
author | Kohei Yoshida <kohei.yoshida@gmail.com> | 2013-07-10 16:32:39 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@gmail.com> | 2013-07-11 00:25:37 -0400 |
commit | 0797dd8714413f8319515df9831a86703b589558 (patch) | |
tree | cd12f739ef0ac620fa4b4eaa35f6d1f50a3ec97b /sc/inc | |
parent | 217896aa33e40b113fafdaa109d02992f7d9506a (diff) |
Group formula cells in ScColumn::MixData().
Change-Id: I38186e2bf82ed56fbe859b17dcc1d31f36471bd8
Diffstat (limited to 'sc/inc')
-rw-r--r-- | sc/inc/column.hxx | 15 | ||||
-rw-r--r-- | sc/inc/sharedformula.hxx | 58 |
2 files changed, 62 insertions, 11 deletions
diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx index d0240077347e..01e9ef72358e 100644 --- a/sc/inc/column.hxx +++ b/sc/inc/column.hxx @@ -487,17 +487,18 @@ public: bool HasBroadcaster() const; void BroadcastCells( const std::vector<SCROW>& rRows ); - void EndFormulaListening( sc::ColumnBlockPosition& rBlockPos, SCROW nRow1, SCROW nRow2 ); void InterpretDirtyCells( SCROW nRow1, SCROW nRow2 ); void JoinNewFormulaCell( const sc::CellStoreType::position_type& aPos, ScFormulaCell& rCell ) const; /** - * Detouch a formula cell that's about to be deleted, or removed from + * Detach a formula cell that's about to be deleted, or removed from * document storage (if that ever happens). */ - void DetouchFormulaCell( const sc::CellStoreType::position_type& aPos, ScFormulaCell& rCell ) const; + void DetachFormulaCell( const sc::CellStoreType::position_type& aPos, ScFormulaCell& rCell ); + + void DetachFormulaCells( const sc::CellStoreType::position_type& aPos, size_t nLength ); void UnshareFormulaCell( const sc::CellStoreType::position_type& aPos, ScFormulaCell& rCell ) const; @@ -515,14 +516,6 @@ public: */ void RegroupFormulaCells(); - /** - * Regroup existing formula cells when a range of new cells are inserted. - * - * @param nRow1 first row of inserted new cell span. - * @param nRow2 last row of inserted new cell span. - */ - void RegroupFormulaCells( SCROW nRow1, SCROW nRow2 ); - #if DEBUG_COLUMN_STORAGE void DumpFormulaGroups() const; #endif diff --git a/sc/inc/sharedformula.hxx b/sc/inc/sharedformula.hxx new file mode 100644 index 000000000000..fcab6d7dba0d --- /dev/null +++ b/sc/inc/sharedformula.hxx @@ -0,0 +1,58 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef SC_SHAREDFORMULA_HXX +#define SC_SHAREDFORMULA_HXX + +#include "formulacell.hxx" + +namespace sc { + +class SharedFormulaUtil +{ +public: + + template<typename _Iter> + static void groupFormulaCells(const _Iter& itBeg, const _Iter& itEnd) + { + _Iter it = itBeg; + ScFormulaCell* pPrev = *it; + ScFormulaCell* pCur = NULL; + for (++it; it != itEnd; ++it, pPrev = pCur) + { + pCur = *it; + ScFormulaCell::CompareState eState = pPrev->CompareByTokenArray(*pPrev); + if (eState == ScFormulaCell::NotEqual) + continue; + + ScFormulaCellGroupRef xGroup = pPrev->GetCellGroup(); + if (xGroup) + { + // Extend the group. + ++xGroup->mnLength; + pCur->SetCellGroup(xGroup); + continue; + } + + // Create a new group. + xGroup.reset(new ScFormulaCellGroup); + xGroup->mnStart = pPrev->aPos.Row(); + xGroup->mnLength = 2; + xGroup->mbInvariant = (eState == ScFormulaCell::EqualInvariant); + pPrev->SetCellGroup(xGroup); + pCur->SetCellGroup(xGroup); + } + } +}; + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |