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

Generated by: LCOV version 1.10