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

Generated by: LCOV version 1.10