LCOV - code coverage report
Current view: top level - sc/inc - sharedformula.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 17 0.0 %
Date: 2014-04-14 Functions: 0 1 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  */
       9             : 
      10             : #ifndef SC_SHAREDFORMULA_HXX
      11             : #define SC_SHAREDFORMULA_HXX
      12             : 
      13             : #include "formulacell.hxx"
      14             : #include "mtvelements.hxx"
      15             : 
      16             : #include <vector>
      17             : 
      18             : namespace sc {
      19             : 
      20             : class SharedFormulaUtil
      21             : {
      22             : public:
      23             : 
      24             :     /**
      25             :      * Group formula cells stored in the passed container. The formula cells
      26             :      * in the container are assumed to be all <b>non-shared</b>.
      27             :      */
      28             :     template<typename _Iter>
      29           0 :     static void groupFormulaCells(const _Iter& itBeg, const _Iter& itEnd)
      30             :     {
      31           0 :         _Iter it = itBeg;
      32           0 :         ScFormulaCell* pPrev = *it;
      33           0 :         ScFormulaCell* pCur = NULL;
      34           0 :         for (++it; it != itEnd; ++it, pPrev = pCur)
      35             :         {
      36           0 :             pCur = *it;
      37           0 :             ScFormulaCell::CompareState eState = pCur->CompareByTokenArray(*pPrev);
      38           0 :             if (eState == ScFormulaCell::NotEqual)
      39           0 :                 continue;
      40             : 
      41           0 :             ScFormulaCellGroupRef xGroup = pPrev->GetCellGroup();
      42           0 :             if (xGroup)
      43             :             {
      44             :                 // Extend the group.
      45           0 :                 ++xGroup->mnLength;
      46           0 :                 pCur->SetCellGroup(xGroup);
      47           0 :                 continue;
      48             :             }
      49             : 
      50             :             // Create a new group.
      51           0 :             xGroup = pPrev->CreateCellGroup(2, eState == ScFormulaCell::EqualInvariant);
      52           0 :             pCur->SetCellGroup(xGroup);
      53             :         }
      54           0 :     }
      55             : 
      56             :     /**
      57             :      * Split existing shared formula range at specified position. The cell at
      58             :      * specified position becomes the top cell of the lower shared formula
      59             :      * range after this call.  This method does nothing if the cell at
      60             :      * specified position is not a formula cell.
      61             :      *
      62             :      * @param aPos position of cell to examine.
      63             :      */
      64             :     static void splitFormulaCellGroup(const CellStoreType::position_type& aPos);
      65             : 
      66             :     /**
      67             :      * Split existing shared formula ranges at specified row positions.
      68             :      *
      69             :      * @param rCells cell storage container
      70             :      * @param rBounds row positions at which to split existing shared formula
      71             :      *                ranges. Note that this method will directly modify this
      72             :      *                parameter to sort and remove duplicates.
      73             :      */
      74             :     static void splitFormulaCellGroups(CellStoreType& rCells, std::vector<SCROW>& rBounds);
      75             : 
      76             :     /**
      77             :      * See if two specified adjacent formula cells can be merged, and if they
      78             :      * can, merge them into the same group.
      79             :      *
      80             :      * @param rPos position object of the first cell
      81             :      * @param rCell1 first cell
      82             :      * @param rCell2 second cell located immediately below the first cell.
      83             :      */
      84             :     static void joinFormulaCells(
      85             :         const CellStoreType::position_type& rPos, ScFormulaCell& rCell1, ScFormulaCell& rCell2);
      86             :     /**
      87             :      * Merge with an existing formula group (if any) located immediately above
      88             :      * if the cell at specified position is a formula cell, and its formula
      89             :      * tokens are identical to that of the above formula group.
      90             :      *
      91             :      * @param aPos position of cell to examine.
      92             :      */
      93             :     static void joinFormulaCellAbove(const CellStoreType::position_type& aPos);
      94             : 
      95             :     /**
      96             :      * Turn a shared formula cell into a non-shared one, and split it off from
      97             :      * the adjacent formula cell groups.
      98             :      *
      99             :      * @param aPos position of cell to examine
     100             :      * @param rCell formula cell instance
     101             :      */
     102             :     static void unshareFormulaCell(const CellStoreType::position_type& aPos, ScFormulaCell& rCell);
     103             : };
     104             : 
     105             : }
     106             : 
     107             : #endif
     108             : 
     109             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10