LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sc/inc - columnspanset.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 5 5 100.0 %
Date: 2013-07-09 Functions: 5 5 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 SC_COLUMNSPANSET_HXX
      11             : #define SC_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             : 
      24             : namespace sc {
      25             : 
      26             : struct ColumnBlockConstPosition;
      27             : 
      28             : /**
      29             :  * Structure that stores segments of boolean flags per column, and perform
      30             :  * custom action on those segments.
      31             :  */
      32             : class ColumnSpanSet : boost::noncopyable
      33             : {
      34             :     typedef mdds::flat_segment_tree<SCROW, bool> ColumnSpansType;
      35             : 
      36        1053 :     struct ColumnType
      37             :     {
      38             :         ColumnSpansType maSpans;
      39             :         ColumnSpansType::const_iterator miPos;
      40             : 
      41             :         ColumnType(SCROW nStart, SCROW nEnd, bool bInit);
      42             :     };
      43             : 
      44             :     typedef std::vector<ColumnType*> TableType;
      45             :     typedef std::vector<TableType*> DocType;
      46             : 
      47             :     DocType maDoc;
      48             :     bool mbInit;
      49             : 
      50             :     ColumnType& getColumn(SCTAB nTab, SCCOL nCol);
      51             : 
      52             : public:
      53          55 :     class Action
      54             :     {
      55             :     public:
      56             :         virtual ~Action() = 0;
      57             :         virtual void startColumn(SCTAB nTab, SCCOL nCol);
      58             :         virtual void execute(const ScAddress& rPos, SCROW nLength, bool bVal) = 0;
      59             :     };
      60             : 
      61         731 :     class ColumnAction
      62             :     {
      63             :     public:
      64             :         virtual ~ColumnAction() = 0;
      65             :         virtual void startColumn(ScColumn* pCol) = 0;
      66             :         virtual void execute(SCROW nRow1, SCROW nRow2, bool bVal) = 0;
      67             :     };
      68             : 
      69             :     ColumnSpanSet(bool bInit);
      70             :     ~ColumnSpanSet();
      71             : 
      72             :     void set(SCTAB nTab, SCCOL nCol, SCROW nRow, bool bVal);
      73             :     void set(SCTAB nTab, SCCOL nCol, SCROW nRow1, SCROW nRow2, bool bVal);
      74             :     void set(const ScRange& rRange, bool bVal);
      75             : 
      76             :     void executeAction(Action& ac) const;
      77             :     void executeColumnAction(ScDocument& rDoc, ColumnAction& ac) const;
      78             : };
      79             : 
      80             : /**
      81             :  * Keep track of spans in a single column only.
      82             :  */
      83      898441 : class SingleColumnSpanSet
      84             : {
      85             : public:
      86             :     typedef mdds::flat_segment_tree<SCROW, bool> ColumnSpansType;
      87             : 
      88             :     struct Span
      89             :     {
      90             :         SCROW mnRow1;
      91             :         SCROW mnRow2;
      92             : 
      93        4824 :         Span(SCROW nRow1, SCROW nRow2) : mnRow1(nRow1), mnRow2(nRow2) {}
      94             :     };
      95             : 
      96             :     typedef std::vector<Span> SpansType;
      97             : 
      98             :     SingleColumnSpanSet();
      99             : 
     100             :     /**
     101             :      * Scan an entire column and tag all non-empty cell positions.
     102             :      */
     103             :     void scan(const ScColumn& rColumn);
     104             : 
     105             :     /**
     106             :      * Scan a column between specified range, and tag all non-empty cell
     107             :      * positions.
     108             :      */
     109             :     void scan(const ScColumn& rColumn, SCROW nStart, SCROW nEnd);
     110             : 
     111             :     void scan(
     112             :         ColumnBlockConstPosition& rBlockPos, const ScColumn& rColumn, SCROW nStart, SCROW nEnd);
     113             : 
     114             :     /**
     115             :      * Scan all marked data and tag all marked segments in specified column.
     116             :      */
     117             :     void scan(const ScMarkData& rMark, SCTAB nTab, SCCOL nCol);
     118             : 
     119             :     void set(SCROW nRow1, SCROW nRow2, bool bVal);
     120             : 
     121             :     void getRows(std::vector<SCROW> &rRows) const;
     122             : 
     123             :     void getSpans(SpansType& rSpans) const;
     124             : 
     125             : private:
     126             :     ColumnSpansType maSpans;
     127             : };
     128             : 
     129             : }
     130             : 
     131             : #endif
     132             : 
     133             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10