LCOV - code coverage report
Current view: top level - sc/source/core/data - edittextiterator.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 38 39 97.4 %
Date: 2015-06-13 12:38:46 Functions: 8 8 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             : #include "edittextiterator.hxx"
      11             : #include "document.hxx"
      12             : #include "table.hxx"
      13             : #include "column.hxx"
      14             : 
      15             : namespace sc {
      16             : 
      17          38 : EditTextIterator::EditTextIterator( const ScDocument& rDoc, SCTAB nTab ) :
      18          38 :     mrTable(*rDoc.maTabs.at(nTab)),
      19          38 :     mpCol(&mrTable.aCol[0]),
      20          38 :     mpColEnd(mpCol + static_cast<size_t>(MAXCOLCOUNT)),
      21             :     mpCells(&mpCol->maCells),
      22             :     maPos(mpCells->position(0)),
      23         114 :     miEnd(mpCells->end())
      24             : {
      25          38 : }
      26             : 
      27          69 : const EditTextObject* EditTextIterator::seek()
      28             : {
      29       39136 :     while (maPos.first->type != sc::element_type_edittext)
      30             :     {
      31       39036 :         incBlock();
      32       39036 :         if (maPos.first == miEnd)
      33             :         {
      34             :             // Move to the next column.
      35       38912 :             ++mpCol;
      36       38912 :             if (mpCol == mpColEnd)
      37             :                 // No more columns.
      38          38 :                 return NULL;
      39             : 
      40       38874 :             mpCells = &mpCol->maCells;
      41       38874 :             maPos = mpCells->position(0);
      42       38874 :             miEnd = mpCells->end();
      43             :         }
      44             :     }
      45             : 
      46             :     // We are on the right block type.
      47          31 :     return sc::edittext_block::at(*maPos.first->data, maPos.second);
      48             : }
      49             : 
      50          31 : void EditTextIterator::incPos()
      51             : {
      52          31 :     if (maPos.second + 1 < maPos.first->size)
      53             :         // Increment within the block.
      54          12 :         ++maPos.second;
      55             :     else
      56          19 :         incBlock();
      57          31 : }
      58             : 
      59       39055 : void EditTextIterator::incBlock()
      60             : {
      61       39055 :     ++maPos.first;
      62       39055 :     maPos.second = 0;
      63       39055 : }
      64             : 
      65          38 : const EditTextObject* EditTextIterator::first()
      66             : {
      67          38 :     mpCol = &mrTable.aCol[0];
      68          38 :     mpColEnd = mpCol + static_cast<size_t>(MAXCOLCOUNT);
      69          38 :     mpCells = &mpCol->maCells;
      70          38 :     maPos = mpCells->position(0);
      71          38 :     miEnd = mpCells->end();
      72          38 :     return seek();
      73             : }
      74             : 
      75          31 : const EditTextObject* EditTextIterator::next()
      76             : {
      77          31 :     if (maPos.first == miEnd)
      78           0 :         return NULL;
      79             : 
      80          31 :     incPos();
      81          31 :     return seek();
      82             : }
      83             : 
      84         156 : }
      85             : 
      86             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11