LibreOffice Module sc (master)  1
edittextiterator.cxx
Go to the documentation of this file.
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 
18  mrTable(*rDoc.maTabs.at(nTab)),
19  mnCol(0),
20  mpCells(nullptr),
21  miEnd(maPos.first)
22 {
23  init();
24 }
25 
27 {
28  mnCol = 0;
29  if (mnCol >= mrTable.aCol.size())
30  mnCol = -1;
31 
32  if (mnCol != -1)
33  {
34  mpCells = &mrTable.aCol[mnCol].maCells;
35  maPos = mpCells->position(0);
36  miEnd = mpCells->end();
37  }
38 }
39 
41 {
42  while (maPos.first->type != sc::element_type_edittext)
43  {
44  incBlock();
45  if (maPos.first == miEnd)
46  {
47  // Move to the next column.
48  ++mnCol;
49  if (mnCol >= mrTable.aCol.size())
50  // No more columns.
51  return nullptr;
52 
53  mpCells = &mrTable.aCol[mnCol].maCells;
54  maPos = mpCells->position(0);
55  miEnd = mpCells->end();
56  }
57  }
58 
59  // We are on the right block type.
60  return sc::edittext_block::at(*maPos.first->data, maPos.second);
61 }
62 
64 {
65  ++maPos.first;
66  maPos.second = 0;
67 }
68 
70 {
71  init();
72  if (mnCol == -1)
73  return nullptr;
74  return seek();
75 }
76 
78 {
79  if (mnCol == -1)
80  return nullptr;
81 
82  if (maPos.first == miEnd)
83  return nullptr;
84 
85  // increment position by one
86  if (maPos.second + 1 < maPos.first->size)
87  // Increment within the block.
88  ++maPos.second;
89  else
90  incBlock();
91 
92  return seek();
93 }
94 
95 }
96 
97 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SCCOL size() const
EditTextIterator(const ScDocument &rDoc, SCTAB nTab)
sal_Int32 mnCol
const CellStoreType * mpCells
const EditTextObject * first()
CellStoreType::const_position_type maPos
const ScTable & mrTable
ScColContainer aCol
Definition: table.hxx:158
const mdds::mtv::element_t element_type_edittext
Definition: mtvelements.hxx:48
const EditTextObject * next()
const EditTextObject * seek()
Move to the next edit text cell position if the current position is not an edit text.
CellStoreType::const_iterator miEnd
constexpr OUStringLiteral first
sal_Int16 SCTAB
Definition: types.hxx:22
void init()
Initialize members w.r.t the dynamic column container in the given table.