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  maPos(sc::CellStoreType::const_position_type()),
22  miEnd(maPos.first)
23 {
24  init();
25 }
26 
28 {
29  mnCol = 0;
30  if (mnCol >= mrTable.aCol.size())
31  mnCol = -1;
32 
33  if (mnCol != -1)
34  {
35  mpCells = &mrTable.aCol[mnCol].maCells;
36  maPos = mpCells->position(0);
37  miEnd = mpCells->end();
38  }
39 }
40 
42 {
43  while (maPos.first->type != sc::element_type_edittext)
44  {
45  incBlock();
46  if (maPos.first == miEnd)
47  {
48  // Move to the next column.
49  ++mnCol;
50  if (mnCol >= mrTable.aCol.size())
51  // No more columns.
52  return nullptr;
53 
54  mpCells = &mrTable.aCol[mnCol].maCells;
55  maPos = mpCells->position(0);
56  miEnd = mpCells->end();
57  }
58  }
59 
60  // We are on the right block type.
61  return sc::edittext_block::at(*maPos.first->data, maPos.second);
62 }
63 
65 {
66  ++maPos.first;
67  maPos.second = 0;
68 }
69 
71 {
72  init();
73  if (mnCol == -1)
74  return nullptr;
75  return seek();
76 }
77 
79 {
80  if (mnCol == -1)
81  return nullptr;
82 
83  if (maPos.first == miEnd)
84  return nullptr;
85 
86  // increment position by one
87  if (maPos.second + 1 < maPos.first->size)
88  // Increment within the block.
89  ++maPos.second;
90  else
91  incBlock();
92 
93  return seek();
94 }
95 
96 }
97 
98 /* 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()
mdds::multi_type_vector< CellFunc, CellStoreEvent > CellStoreType
CellStoreType::const_position_type maPos
const ScTable & mrTable
ScColContainer aCol
Definition: table.hxx:156
const mdds::mtv::element_t element_type_edittext
Definition: mtvelements.hxx:49
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
sal_Int16 SCTAB
Definition: types.hxx:23
const char first[]
void init()
Initialize members w.r.t the dynamic column container in the given table.