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

Generated by: LCOV version 1.10