LCOV - code coverage report
Current view: top level - libreoffice/sc/source/core/data - segmenttree.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 189 244 77.5 %
Date: 2012-12-17 Functions: 59 73 80.8 %
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             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : 
      21             : #include "segmenttree.hxx"
      22             : 
      23             : #include <mdds/flat_segment_tree.hpp>
      24             : 
      25             : #include <limits>
      26             : 
      27             : using ::std::numeric_limits;
      28             : 
      29             : // ============================================================================
      30             : 
      31             : template<typename _ValueType, typename _ExtValueType = _ValueType>
      32             : class ScFlatSegmentsImpl
      33             : {
      34             : public:
      35             :     typedef _ValueType ValueType;
      36             :     typedef _ExtValueType ExtValueType;
      37             : 
      38             :     struct RangeData
      39             :     {
      40             :         SCCOLROW    mnPos1;
      41             :         SCCOLROW    mnPos2;
      42             :         ValueType   mnValue;
      43             :     };
      44             : 
      45             :     ScFlatSegmentsImpl(SCCOLROW nMax, ValueType nDefault);
      46             :     ScFlatSegmentsImpl(const ScFlatSegmentsImpl& r);
      47             :     ~ScFlatSegmentsImpl();
      48             : 
      49             :     bool setValue(SCCOLROW nPos1, SCCOLROW nPos2, ValueType nValue);
      50             :     ValueType getValue(SCCOLROW nPos);
      51             :     ExtValueType getSumValue(SCCOLROW nPos1, SCCOLROW nPos2);
      52             :     bool getRangeData(SCCOLROW nPos, RangeData& rData);
      53             :     bool getRangeDataLeaf(SCCOLROW nPos, RangeData& rData);
      54             :     void removeSegment(SCCOLROW nPos1, SCCOLROW nPos2);
      55             :     void insertSegment(SCCOLROW nPos, SCCOLROW nSize, bool bSkipStartBoundary);
      56             : 
      57             :     SCROW findLastNotOf(ValueType nValue) const;
      58             : 
      59             :     // range iteration
      60             :     bool getFirst(RangeData& rData);
      61             :     bool getNext(RangeData& rData);
      62             : 
      63        1162 :     void enableTreeSearch(bool b)
      64             :     {
      65        1162 :         mbTreeSearchEnabled = b;
      66        1162 :     }
      67             : 
      68             : private:
      69             :     typedef ::mdds::flat_segment_tree<SCCOLROW, ValueType> fst_type;
      70             :     fst_type maSegments;
      71             :     typename fst_type::const_iterator maItr;
      72             : 
      73             :     bool mbTreeSearchEnabled:1;
      74             : };
      75             : 
      76             : template<typename _ValueType, typename _ExtValueType>
      77        9056 : ScFlatSegmentsImpl<_ValueType, _ExtValueType>::ScFlatSegmentsImpl(SCCOLROW nMax, ValueType nDefault) :
      78             :     maSegments(0, nMax+1, nDefault),
      79        9056 :     mbTreeSearchEnabled(true)
      80             : {
      81        9056 : }
      82             : 
      83             : template<typename _ValueType, typename _ExtValueType>
      84           0 : ScFlatSegmentsImpl<_ValueType, _ExtValueType>::ScFlatSegmentsImpl(const ScFlatSegmentsImpl<_ValueType, _ExtValueType>& r) :
      85             :     maSegments(r.maSegments),
      86           0 :     mbTreeSearchEnabled(r.mbTreeSearchEnabled)
      87             : {
      88           0 : }
      89             : 
      90             : template<typename _ValueType, typename _ExtValueType>
      91        8288 : ScFlatSegmentsImpl<_ValueType, _ExtValueType>::~ScFlatSegmentsImpl()
      92             : {
      93        8288 : }
      94             : 
      95             : template<typename _ValueType, typename _ExtValueType>
      96     2787030 : bool ScFlatSegmentsImpl<_ValueType, _ExtValueType>::setValue(SCCOLROW nPos1, SCCOLROW nPos2, ValueType nValue)
      97             : {
      98     2787030 :     ::std::pair<typename fst_type::const_iterator, bool> ret;
      99     2787030 :     ret = maSegments.insert(maItr, nPos1, nPos2+1, nValue);
     100     2787030 :     maItr = ret.first;
     101     2787030 :     return ret.second;
     102             : }
     103             : 
     104             : template<typename _ValueType, typename _ExtValueType>
     105        1850 : typename ScFlatSegmentsImpl<_ValueType, _ExtValueType>::ValueType ScFlatSegmentsImpl<_ValueType, _ExtValueType>::getValue(SCCOLROW nPos)
     106             : {
     107        1850 :     ValueType nValue = 0;
     108        1850 :     if (!mbTreeSearchEnabled)
     109             :     {
     110          48 :         maSegments.search(nPos, nValue);
     111          48 :         return nValue;
     112             :     }
     113             : 
     114        1802 :     if (!maSegments.is_tree_valid())
     115           4 :         maSegments.build_tree();
     116             : 
     117        1802 :     maSegments.search_tree(nPos, nValue);
     118        1802 :     return nValue;
     119             : }
     120             : 
     121             : template<typename _ValueType, typename _ExtValueType>
     122             : typename ScFlatSegmentsImpl<_ValueType, _ExtValueType>::ExtValueType
     123        1418 : ScFlatSegmentsImpl<_ValueType, _ExtValueType>::getSumValue(SCCOLROW nPos1, SCCOLROW nPos2)
     124             : {
     125             :     RangeData aData;
     126        1418 :     if (!getRangeData(nPos1, aData))
     127           0 :         return 0;
     128             : 
     129        1418 :     sal_uInt32 nValue = 0;
     130             : 
     131        1418 :     SCROW nCurPos = nPos1;
     132        1418 :     SCROW nEndPos = aData.mnPos2;
     133        5116 :     while (nEndPos <= nPos2)
     134             :     {
     135        2886 :         nValue += aData.mnValue * (nEndPos - nCurPos + 1);
     136        2886 :         nCurPos = nEndPos + 1;
     137        2886 :         if (!getRangeData(nCurPos, aData))
     138         606 :             break;
     139             : 
     140        2280 :         nEndPos = aData.mnPos2;
     141             :     }
     142        1418 :     if (nCurPos <= nPos2)
     143             :     {
     144         568 :         nEndPos = ::std::min(nEndPos, nPos2);
     145         568 :         nValue += aData.mnValue * (nEndPos - nCurPos + 1);
     146             :     }
     147        1418 :     return nValue;
     148             : }
     149             : 
     150             : template<typename _ValueType, typename _ExtValueType>
     151     1688010 : bool ScFlatSegmentsImpl<_ValueType, _ExtValueType>::getRangeData(SCCOLROW nPos, RangeData& rData)
     152             : {
     153     1688010 :     if (!mbTreeSearchEnabled)
     154        5976 :         return getRangeDataLeaf(nPos, rData);
     155             : 
     156             :     ValueType nValue;
     157             :     SCCOLROW nPos1, nPos2;
     158             : 
     159     1682034 :     if (!maSegments.is_tree_valid())
     160        6746 :         maSegments.build_tree();
     161             : 
     162     1682034 :     if (!maSegments.search_tree(nPos, nValue, &nPos1, &nPos2))
     163         492 :         return false;
     164             : 
     165     1681542 :     rData.mnPos1 = nPos1;
     166     1681542 :     rData.mnPos2 = nPos2-1; // end point is not inclusive.
     167     1681542 :     rData.mnValue = nValue;
     168     1681542 :     return true;
     169             : }
     170             : 
     171             : template<typename _ValueType, typename _ExtValueType>
     172        6042 : bool ScFlatSegmentsImpl<_ValueType, _ExtValueType>::getRangeDataLeaf(SCCOLROW nPos, RangeData& rData)
     173             : {
     174             :     ValueType nValue;
     175             :     SCCOLROW nPos1, nPos2;
     176             : 
     177             :     // Conduct leaf-node only search.  Faster when searching between range insertion.
     178             :     ::std::pair<typename fst_type::const_iterator, bool> ret =
     179        6042 :         maSegments.search(maItr, nPos, nValue, &nPos1, &nPos2);
     180             : 
     181        6042 :     if (!ret.second)
     182         114 :         return false;
     183             : 
     184        5928 :     maItr = ret.first;
     185             : 
     186        5928 :     rData.mnPos1 = nPos1;
     187        5928 :     rData.mnPos2 = nPos2-1; // end point is not inclusive.
     188        5928 :     rData.mnValue = nValue;
     189        5928 :     return true;
     190             : }
     191             : 
     192             : template<typename _ValueType, typename _ExtValueType>
     193          26 : void ScFlatSegmentsImpl<_ValueType, _ExtValueType>::removeSegment(SCCOLROW nPos1, SCCOLROW nPos2)
     194             : {
     195          26 :     maSegments.shift_left(nPos1, nPos2);
     196          26 :     maItr = maSegments.begin();
     197          26 : }
     198             : 
     199             : template<typename _ValueType, typename _ExtValueType>
     200          34 : void ScFlatSegmentsImpl<_ValueType, _ExtValueType>::insertSegment(SCCOLROW nPos, SCCOLROW nSize, bool bSkipStartBoundary)
     201             : {
     202          34 :     maSegments.shift_right(nPos, nSize, bSkipStartBoundary);
     203          34 :     maItr = maSegments.begin();
     204          34 : }
     205             : 
     206             : template<typename _ValueType, typename _ExtValueType>
     207          16 : SCCOLROW ScFlatSegmentsImpl<_ValueType, _ExtValueType>::findLastNotOf(ValueType nValue) const
     208             : {
     209          16 :     SCCOLROW nPos = numeric_limits<SCCOLROW>::max(); // position not found.
     210          16 :     typename fst_type::const_reverse_iterator itr = maSegments.rbegin(), itrEnd = maSegments.rend();
     211             :     // Note that when searching in reverse direction, we need to skip the first
     212             :     // node, since the right-most leaf node does not store a valid value.
     213          16 :     for (++itr; itr != itrEnd; ++itr)
     214             :     {
     215           0 :         if (itr->second != nValue)
     216             :         {
     217           0 :             nPos = (--itr)->first - 1;
     218           0 :             break;
     219             :         }
     220             :     }
     221          16 :     return nPos;
     222             : }
     223             : 
     224             : template<typename _ValueType, typename _ExtValueType>
     225           0 : bool ScFlatSegmentsImpl<_ValueType, _ExtValueType>::getFirst(RangeData& rData)
     226             : {
     227           0 :     maItr = maSegments.begin();
     228           0 :     return getNext(rData);
     229             : }
     230             : 
     231             : template<typename _ValueType, typename _ExtValueType>
     232           0 : bool ScFlatSegmentsImpl<_ValueType, _ExtValueType>::getNext(RangeData& rData)
     233             : {
     234           0 :     typename fst_type::const_iterator itrEnd = maSegments.end();
     235           0 :     if (maItr == itrEnd)
     236           0 :         return false;
     237             : 
     238           0 :     rData.mnPos1 = maItr->first;
     239           0 :     rData.mnValue = maItr->second;
     240             : 
     241           0 :     ++maItr;
     242           0 :     if (maItr == itrEnd)
     243           0 :         return false;
     244             : 
     245           0 :     rData.mnPos2 = maItr->first - 1;
     246           0 :     return true;
     247             : }
     248             : 
     249             : // ============================================================================
     250             : 
     251         468 : class ScFlatUInt16SegmentsImpl : public ScFlatSegmentsImpl<sal_uInt16, sal_uInt32>
     252             : {
     253             : public:
     254         612 :     explicit ScFlatUInt16SegmentsImpl(SCCOLROW nMax, sal_uInt16 nDefault) :
     255         612 :         ScFlatSegmentsImpl<sal_uInt16, sal_uInt32>(nMax, nDefault)
     256             :     {
     257         612 :     }
     258             : };
     259             : 
     260             : // ----------------------------------------------------------------------------
     261             : 
     262        7820 : class ScFlatBoolSegmentsImpl : public ScFlatSegmentsImpl<bool>
     263             : {
     264             : public:
     265        8444 :     explicit ScFlatBoolSegmentsImpl(SCCOLROW nMax) :
     266        8444 :         ScFlatSegmentsImpl<bool>(nMax, false)
     267             :     {
     268        8444 :     }
     269             : 
     270             :     bool setTrue(SCCOLROW nPos1, SCCOLROW nPos2);
     271             :     bool setFalse(SCCOLROW nPos1, SCCOLROW nPos2);
     272             : };
     273             : 
     274     2771058 : bool ScFlatBoolSegmentsImpl::setTrue(SCCOLROW nPos1, SCCOLROW nPos2)
     275             : {
     276     2771058 :     return setValue(nPos1, nPos2, true);
     277             : }
     278             : 
     279       10404 : bool ScFlatBoolSegmentsImpl::setFalse(SCCOLROW nPos1, SCCOLROW nPos2)
     280             : {
     281       10404 :     return setValue(nPos1, nPos2, false);
     282             : }
     283             : 
     284             : // ============================================================================
     285             : 
     286         254 : ScFlatBoolRowSegments::ForwardIterator::ForwardIterator(ScFlatBoolRowSegments& rSegs) :
     287         254 :     mrSegs(rSegs), mnCurPos(0), mnLastPos(-1), mbCurValue(false)
     288             : {
     289         254 : }
     290             : 
     291     4931108 : bool ScFlatBoolRowSegments::ForwardIterator::getValue(SCROW nPos, bool& rVal)
     292             : {
     293     4931108 :     if (nPos >= mnCurPos)
     294             :         // It can only go in a forward direction.
     295     4931108 :         mnCurPos = nPos;
     296             : 
     297     4931108 :     if (mnCurPos > mnLastPos)
     298             :     {
     299             :         // position not in the current segment.  Update the current value.
     300             :         ScFlatBoolRowSegments::RangeData aData;
     301         274 :         if (!mrSegs.getRangeData(mnCurPos, aData))
     302           0 :             return false;
     303             : 
     304         274 :         mbCurValue = aData.mbValue;
     305         274 :         mnLastPos = aData.mnRow2;
     306             :     }
     307             : 
     308     4931108 :     rVal = mbCurValue;
     309     4931108 :     return true;
     310             : }
     311             : 
     312     4931108 : SCROW ScFlatBoolRowSegments::ForwardIterator::getLastPos() const
     313             : {
     314     4931108 :     return mnLastPos;
     315             : }
     316             : 
     317             : // ----------------------------------------------------------------------------
     318             : 
     319           0 : ScFlatBoolRowSegments::RangeIterator::RangeIterator(ScFlatBoolRowSegments& rSegs) :
     320           0 :     mrSegs(rSegs)
     321             : {
     322           0 : }
     323             : 
     324           0 : bool ScFlatBoolRowSegments::RangeIterator::getFirst(RangeData& rRange)
     325             : {
     326             :     ScFlatBoolSegmentsImpl::RangeData aData;
     327           0 :     if (!mrSegs.mpImpl->getFirst(aData))
     328           0 :         return false;
     329             : 
     330           0 :     rRange.mnRow1  = static_cast<SCROW>(aData.mnPos1);
     331           0 :     rRange.mnRow2  = static_cast<SCROW>(aData.mnPos2);
     332           0 :     rRange.mbValue = static_cast<bool>(aData.mnValue);
     333           0 :     return true;
     334             : }
     335             : 
     336           0 : bool ScFlatBoolRowSegments::RangeIterator::getNext(RangeData& rRange)
     337             : {
     338             :     ScFlatBoolSegmentsImpl::RangeData aData;
     339           0 :     if (!mrSegs.mpImpl->getNext(aData))
     340           0 :         return false;
     341             : 
     342           0 :     rRange.mnRow1  = static_cast<SCROW>(aData.mnPos1);
     343           0 :     rRange.mnRow2  = static_cast<SCROW>(aData.mnPos2);
     344           0 :     rRange.mbValue = static_cast<bool>(aData.mnValue);
     345           0 :     return true;
     346             : }
     347             : 
     348             : // ----------------------------------------------------------------------------
     349             : 
     350        6994 : ScFlatBoolRowSegments::ScFlatBoolRowSegments() :
     351        6994 :     mpImpl(new ScFlatBoolSegmentsImpl(static_cast<SCCOLROW>(MAXROW)))
     352             : {
     353        6994 : }
     354             : 
     355           0 : ScFlatBoolRowSegments::ScFlatBoolRowSegments(const ScFlatBoolRowSegments& r) :
     356           0 :     mpImpl(new ScFlatBoolSegmentsImpl(*r.mpImpl))
     357             : {
     358           0 : }
     359             : 
     360        6682 : ScFlatBoolRowSegments::~ScFlatBoolRowSegments()
     361             : {
     362        6682 : }
     363             : 
     364     2732284 : bool ScFlatBoolRowSegments::setTrue(SCROW nRow1, SCROW nRow2)
     365             : {
     366     2732284 :     return mpImpl->setTrue(static_cast<SCCOLROW>(nRow1), static_cast<SCCOLROW>(nRow2));
     367             : }
     368             : 
     369         114 : bool ScFlatBoolRowSegments::setFalse(SCROW nRow1, SCROW nRow2)
     370             : {
     371         114 :     return mpImpl->setFalse(static_cast<SCCOLROW>(nRow1), static_cast<SCCOLROW>(nRow2));
     372             : }
     373             : 
     374           0 : bool ScFlatBoolRowSegments::getValue(SCROW nRow)
     375             : {
     376           0 :     return mpImpl->getValue(static_cast<SCCOLROW>(nRow));
     377             : }
     378             : 
     379      357490 : bool ScFlatBoolRowSegments::getRangeData(SCROW nRow, RangeData& rData)
     380             : {
     381             :     ScFlatBoolSegmentsImpl::RangeData aData;
     382      357490 :     if (!mpImpl->getRangeData(static_cast<SCCOLROW>(nRow), aData))
     383           0 :         return false;
     384             : 
     385      357490 :     rData.mbValue = aData.mnValue;
     386      357490 :     rData.mnRow1  = static_cast<SCROW>(aData.mnPos1);
     387      357490 :     rData.mnRow2  = static_cast<SCROW>(aData.mnPos2);
     388      357490 :     return true;
     389             : }
     390             : 
     391          66 : bool ScFlatBoolRowSegments::getRangeDataLeaf(SCROW nRow, RangeData& rData)
     392             : {
     393             :     ScFlatBoolSegmentsImpl::RangeData aData;
     394          66 :     if (!mpImpl->getRangeDataLeaf(static_cast<SCCOLROW>(nRow), aData))
     395           0 :         return false;
     396             : 
     397          66 :     rData.mbValue = aData.mnValue;
     398          66 :     rData.mnRow1  = static_cast<SCROW>(aData.mnPos1);
     399          66 :     rData.mnRow2  = static_cast<SCROW>(aData.mnPos2);
     400          66 :     return true;
     401             : }
     402             : 
     403          12 : void ScFlatBoolRowSegments::removeSegment(SCROW nRow1, SCROW nRow2)
     404             : {
     405          12 :     mpImpl->removeSegment(static_cast<SCCOLROW>(nRow1), static_cast<SCCOLROW>(nRow2));
     406          12 : }
     407             : 
     408          20 : void ScFlatBoolRowSegments::insertSegment(SCROW nRow, SCROW nSize, bool bSkipStartBoundary)
     409             : {
     410          20 :     mpImpl->insertSegment(static_cast<SCCOLROW>(nRow), static_cast<SCCOLROW>(nSize), bSkipStartBoundary);
     411          20 : }
     412             : 
     413          12 : SCROW ScFlatBoolRowSegments::findLastNotOf(bool bValue) const
     414             : {
     415          12 :     return static_cast<SCROW>(mpImpl->findLastNotOf(bValue));
     416             : }
     417             : 
     418             : // ============================================================================
     419             : 
     420        1450 : ScFlatBoolColSegments::ScFlatBoolColSegments() :
     421        1450 :     mpImpl(new ScFlatBoolSegmentsImpl(static_cast<SCCOLROW>(MAXCOL)))
     422             : {
     423        1450 : }
     424             : 
     425           0 : ScFlatBoolColSegments::ScFlatBoolColSegments(const ScFlatBoolColSegments& r) :
     426           0 :     mpImpl(new ScFlatBoolSegmentsImpl(*r.mpImpl))
     427             : {
     428           0 : }
     429             : 
     430        1138 : ScFlatBoolColSegments::~ScFlatBoolColSegments()
     431             : {
     432        1138 : }
     433             : 
     434       38774 : bool ScFlatBoolColSegments::setTrue(SCCOL nCol1, SCCOL nCol2)
     435             : {
     436       38774 :     return mpImpl->setTrue(static_cast<SCCOLROW>(nCol1), static_cast<SCCOLROW>(nCol2));
     437             : }
     438             : 
     439       10290 : bool ScFlatBoolColSegments::setFalse(SCCOL nCol1, SCCOL nCol2)
     440             : {
     441       10290 :     return mpImpl->setFalse(static_cast<SCCOLROW>(nCol1), static_cast<SCCOLROW>(nCol2));
     442             : }
     443             : 
     444      912474 : bool ScFlatBoolColSegments::getRangeData(SCCOL nCol, RangeData& rData)
     445             : {
     446             :     ScFlatBoolSegmentsImpl::RangeData aData;
     447      912474 :     if (!mpImpl->getRangeData(static_cast<SCCOLROW>(nCol), aData))
     448           0 :         return false;
     449             : 
     450      912474 :     rData.mbValue = aData.mnValue;
     451      912474 :     rData.mnCol1  = static_cast<SCCOL>(aData.mnPos1);
     452      912474 :     rData.mnCol2  = static_cast<SCCOL>(aData.mnPos2);
     453      912474 :     return true;
     454             : }
     455             : 
     456           8 : void ScFlatBoolColSegments::removeSegment(SCCOL nCol1, SCCOL nCol2)
     457             : {
     458           8 :     mpImpl->removeSegment(static_cast<SCCOLROW>(nCol1), static_cast<SCCOLROW>(nCol2));
     459           8 : }
     460             : 
     461           4 : void ScFlatBoolColSegments::insertSegment(SCCOL nCol, SCCOL nSize, bool bSkipStartBoundary)
     462             : {
     463           4 :     mpImpl->insertSegment(static_cast<SCCOLROW>(nCol), static_cast<SCCOLROW>(nSize), bSkipStartBoundary);
     464           4 : }
     465             : 
     466             : // ============================================================================
     467             : 
     468        1226 : ScFlatUInt16RowSegments::ForwardIterator::ForwardIterator(ScFlatUInt16RowSegments& rSegs) :
     469        1226 :     mrSegs(rSegs), mnCurPos(0), mnLastPos(-1), mnCurValue(0)
     470             : {
     471        1226 : }
     472             : 
     473     4932078 : bool ScFlatUInt16RowSegments::ForwardIterator::getValue(SCROW nPos, sal_uInt16& rVal)
     474             : {
     475     4932078 :     if (nPos >= mnCurPos)
     476             :         // It can only go in a forward direction.
     477     4932078 :         mnCurPos = nPos;
     478             : 
     479     4932078 :     if (mnCurPos > mnLastPos)
     480             :     {
     481             :         // position not in the current segment.  Update the current value.
     482             :         ScFlatUInt16RowSegments::RangeData aData;
     483        2010 :         if (!mrSegs.getRangeData(mnCurPos, aData))
     484           0 :             return false;
     485             : 
     486        2010 :         mnCurValue = aData.mnValue;
     487        2010 :         mnLastPos = aData.mnRow2;
     488             :     }
     489             : 
     490     4932078 :     rVal = mnCurValue;
     491     4932078 :     return true;
     492             : }
     493             : 
     494     4931820 : SCROW ScFlatUInt16RowSegments::ForwardIterator::getLastPos() const
     495             : {
     496     4931820 :     return mnLastPos;
     497             : }
     498             : 
     499             : // ----------------------------------------------------------------------------
     500             : 
     501         612 : ScFlatUInt16RowSegments::ScFlatUInt16RowSegments(sal_uInt16 nDefault) :
     502         612 :     mpImpl(new ScFlatUInt16SegmentsImpl(static_cast<SCCOLROW>(MAXROW), nDefault))
     503             : {
     504         612 : }
     505             : 
     506           0 : ScFlatUInt16RowSegments::ScFlatUInt16RowSegments(const ScFlatUInt16RowSegments& r) :
     507           0 :     mpImpl(new ScFlatUInt16SegmentsImpl(*r.mpImpl))
     508             : {
     509           0 : }
     510             : 
     511         468 : ScFlatUInt16RowSegments::~ScFlatUInt16RowSegments()
     512             : {
     513         468 : }
     514             : 
     515        5568 : void ScFlatUInt16RowSegments::setValue(SCROW nRow1, SCROW nRow2, sal_uInt16 nValue)
     516             : {
     517        5568 :     mpImpl->setValue(static_cast<SCCOLROW>(nRow1), static_cast<SCCOLROW>(nRow2), nValue);
     518        5568 : }
     519             : 
     520        1850 : sal_uInt16 ScFlatUInt16RowSegments::getValue(SCROW nRow)
     521             : {
     522        1850 :     return mpImpl->getValue(static_cast<SCCOLROW>(nRow));
     523             : }
     524             : 
     525        1418 : sal_uInt32 ScFlatUInt16RowSegments::getSumValue(SCROW nRow1, SCROW nRow2)
     526             : {
     527        1418 :     return mpImpl->getSumValue(static_cast<SCCOLROW>(nRow1), static_cast<SCCOLROW>(nRow2));
     528             : }
     529             : 
     530      413742 : bool ScFlatUInt16RowSegments::getRangeData(SCROW nRow, RangeData& rData)
     531             : {
     532             :     ScFlatUInt16SegmentsImpl::RangeData aData;
     533      413742 :     if (!mpImpl->getRangeData(static_cast<SCCOLROW>(nRow), aData))
     534           0 :         return false;
     535             : 
     536      413742 :     rData.mnRow1  = aData.mnPos1;
     537      413742 :     rData.mnRow2  = aData.mnPos2;
     538      413742 :     rData.mnValue = aData.mnValue;
     539      413742 :     return true;
     540             : }
     541             : 
     542           6 : void ScFlatUInt16RowSegments::removeSegment(SCROW nRow1, SCROW nRow2)
     543             : {
     544           6 :     mpImpl->removeSegment(static_cast<SCCOLROW>(nRow1), static_cast<SCCOLROW>(nRow2));
     545           6 : }
     546             : 
     547          10 : void ScFlatUInt16RowSegments::insertSegment(SCROW nRow, SCROW nSize, bool bSkipStartBoundary)
     548             : {
     549          10 :     mpImpl->insertSegment(static_cast<SCCOLROW>(nRow), static_cast<SCCOLROW>(nSize), bSkipStartBoundary);
     550          10 : }
     551             : 
     552           4 : SCROW ScFlatUInt16RowSegments::findLastNotOf(sal_uInt16 nValue) const
     553             : {
     554           4 :     return static_cast<SCROW>(mpImpl->findLastNotOf(nValue));
     555             : }
     556             : 
     557        1162 : void ScFlatUInt16RowSegments::enableTreeSearch(bool bEnable)
     558             : {
     559        1162 :     mpImpl->enableTreeSearch(bEnable);
     560        1264 : }
     561             : 
     562             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10