1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
10 #include "edittextiterator.hxx"
11 #include "document.hxx"
17 EditTextIterator::EditTextIterator( const ScDocument
& rDoc
, SCTAB nTab
) :
18 mrTable(*rDoc
.maTabs
.at(nTab
)),
19 mpCol(&mrTable
.aCol
[0]),
20 mpColEnd(mpCol
+ static_cast<size_t>(MAXCOLCOUNT
)),
21 mpCells(&mpCol
->maCells
),
22 maPos(mpCells
->position(0)),
27 const EditTextObject
* EditTextIterator::seek()
29 while (maPos
.first
->type
!= sc::element_type_edittext
)
32 if (maPos
.first
== miEnd
)
34 // Move to the next column.
36 if (mpCol
== mpColEnd
)
40 mpCells
= &mpCol
->maCells
;
41 maPos
= mpCells
->position(0);
42 miEnd
= mpCells
->end();
46 // We are on the right block type.
47 return sc::edittext_block::at(*maPos
.first
->data
, maPos
.second
);
50 void EditTextIterator::incPos()
52 if (maPos
.second
+ 1 < maPos
.first
->size
)
53 // Increment within the block.
59 void EditTextIterator::incBlock()
65 const EditTextObject
* EditTextIterator::first()
67 mpCol
= &mrTable
.aCol
[0];
68 mpColEnd
= mpCol
+ static_cast<size_t>(MAXCOLCOUNT
);
69 mpCells
= &mpCol
->maCells
;
70 maPos
= mpCells
->position(0);
71 miEnd
= mpCells
->end();
75 const EditTextObject
* EditTextIterator::next()
77 if (maPos
.first
== miEnd
)
86 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */