LCOV - code coverage report
Current view: top level - sc/inc - columnspanset.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 4 4 100.0 %
Date: 2014-11-03 Functions: 4 4 100.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 INCLUDED_SC_INC_COLUMNSPANSET_HXX
      11             : #define INCLUDED_SC_INC_COLUMNSPANSET_HXX
      12             : 
      13             : #include "address.hxx"
      14             : 
      15             : #include <vector>
      16             : #include <mdds/flat_segment_tree.hpp>
      17             : #include <boost/noncopyable.hpp>
      18             : 
      19             : class ScDocument;
      20             : class ScColumn;
      21             : class ScMarkData;
      22             : class ScRange;
      23             : class ScRangeList;
      24             : 
      25             : namespace sc {
      26             : 
      27             : struct ColumnBlockConstPosition;
      28             : 
      29             : struct RowSpan
      30             : {
      31             :     SCROW mnRow1;
      32             :     SCROW mnRow2;
      33             : 
      34             :     RowSpan(SCROW nRow1, SCROW nRow2);
      35             : };
      36             : 
      37             : struct SC_DLLPUBLIC ColRowSpan
      38             : {
      39             :     SCCOLROW mnStart;
      40             :     SCCOLROW mnEnd;
      41             : 
      42             :     ColRowSpan(SCCOLROW nStart, SCCOLROW nEnd);
      43             : };
      44             : 
      45             : /**
      46             :  * Structure that stores segments of boolean flags per column, and perform
      47             :  * custom action on those segments.
      48             :  */
      49             : class ColumnSpanSet : boost::noncopyable
      50             : {
      51             : public:
      52             :     typedef mdds::flat_segment_tree<SCROW, bool> ColumnSpansType;
      53             : 
      54             : private:
      55        3036 :     struct ColumnType
      56             :     {
      57             :         ColumnSpansType maSpans;
      58             :         ColumnSpansType::const_iterator miPos;
      59             : 
      60             :         ColumnType(SCROW nStart, SCROW nEnd, bool bInit);
      61             :     };
      62             : 
      63             :     typedef std::vector<ColumnType*> TableType;
      64             :     typedef std::vector<TableType*> DocType;
      65             : 
      66             :     DocType maDoc;
      67             :     bool mbInit;
      68             : 
      69             :     ColumnType& getColumn(SCTAB nTab, SCCOL nCol);
      70             : 
      71             : public:
      72         274 :     class Action
      73             :     {
      74             :     public:
      75             :         virtual ~Action() = 0;
      76             :         virtual void startColumn(SCTAB nTab, SCCOL nCol);
      77             :         virtual void execute(const ScAddress& rPos, SCROW nLength, bool bVal) = 0;
      78             :     };
      79             : 
      80        1795 :     class ColumnAction
      81             :     {
      82             :     public:
      83             :         virtual ~ColumnAction() = 0;
      84             :         virtual void startColumn(ScColumn* pCol) = 0;
      85             :         virtual void execute(SCROW nRow1, SCROW nRow2, bool bVal) = 0;
      86             :     };
      87             : 
      88             :     ColumnSpanSet(bool bInit);
      89             :     ~ColumnSpanSet();
      90             : 
      91             :     void set(SCTAB nTab, SCCOL nCol, SCROW nRow, bool bVal);
      92             :     void set(SCTAB nTab, SCCOL nCol, SCROW nRow1, SCROW nRow2, bool bVal);
      93             :     void set(const ScRange& rRange, bool bVal);
      94             : 
      95             :     /**
      96             :      * Scan specified range in a specified sheet and mark all non-empty cells
      97             :      * with specified boolean value.
      98             :      */
      99             :     void scan(const ScDocument& rDoc, SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, bool bVal);
     100             : 
     101             :     void executeAction(Action& ac) const;
     102             :     void executeColumnAction(ScDocument& rDoc, ColumnAction& ac) const;
     103             : };
     104             : 
     105             : /**
     106             :  * Keep track of spans in a single column only.
     107             :  */
     108     3284610 : class SingleColumnSpanSet
     109             : {
     110             : public:
     111             :     typedef mdds::flat_segment_tree<SCROW, bool> ColumnSpansType;
     112             : 
     113             :     typedef std::vector<RowSpan> SpansType;
     114             : 
     115             :     SingleColumnSpanSet();
     116             : 
     117             :     /**
     118             :      * Scan an entire column and tag all non-empty cell positions.
     119             :      */
     120             :     void scan(const ScColumn& rColumn);
     121             : 
     122             :     /**
     123             :      * Scan a column between specified range, and tag all non-empty cell
     124             :      * positions.
     125             :      */
     126             :     void scan(const ScColumn& rColumn, SCROW nStart, SCROW nEnd);
     127             : 
     128             :     void scan(
     129             :         ColumnBlockConstPosition& rBlockPos, const ScColumn& rColumn, SCROW nStart, SCROW nEnd);
     130             : 
     131             :     /**
     132             :      * Scan all marked data and tag all marked segments in specified column.
     133             :      */
     134             :     void scan(const ScMarkData& rMark, SCTAB nTab, SCCOL nCol);
     135             : 
     136             :     void scan(const ScRangeList& rRanges, SCTAB nTab, SCCOL nCol);
     137             : 
     138             :     void set(SCROW nRow1, SCROW nRow2, bool bVal);
     139             : 
     140             :     void getRows(std::vector<SCROW> &rRows) const;
     141             : 
     142             :     void getSpans(SpansType& rSpans) const;
     143             : 
     144             : private:
     145             :     ColumnSpansType maSpans;
     146             : };
     147             : 
     148             : }
     149             : 
     150             : #endif
     151             : 
     152             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10