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

Generated by: LCOV version 1.11