summaryrefslogtreecommitdiff
path: root/sc/inc/sharedformula.hxx
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@gmail.com>2013-07-10 16:32:39 -0400
committerKohei Yoshida <kohei.yoshida@gmail.com>2013-07-11 00:25:37 -0400
commit0797dd8714413f8319515df9831a86703b589558 (patch)
treecd12f739ef0ac620fa4b4eaa35f6d1f50a3ec97b /sc/inc/sharedformula.hxx
parent217896aa33e40b113fafdaa109d02992f7d9506a (diff)
Group formula cells in ScColumn::MixData().
Change-Id: I38186e2bf82ed56fbe859b17dcc1d31f36471bd8
Diffstat (limited to 'sc/inc/sharedformula.hxx')
-rw-r--r--sc/inc/sharedformula.hxx58
1 files changed, 58 insertions, 0 deletions
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: */