From 0797dd8714413f8319515df9831a86703b589558 Mon Sep 17 00:00:00 2001 From: Kohei Yoshida Date: Wed, 10 Jul 2013 16:32:39 -0400 Subject: Group formula cells in ScColumn::MixData(). Change-Id: I38186e2bf82ed56fbe859b17dcc1d31f36471bd8 --- sc/inc/sharedformula.hxx | 58 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 sc/inc/sharedformula.hxx (limited to 'sc/inc/sharedformula.hxx') 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 + 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: */ -- cgit v1.2.3