27#ifndef CELLITERATORS_H
28#define CELLITERATORS_H
37 static_assert(std::is_class<Cell>::value,
"The type argument must be a class");
41 using iterator_category = std::forward_iterator_tag;
43 using difference_type = std::ptrdiff_t;
55 return operator++(), ret;
61 const auto *
const prev = m_ptr;
63 wxASSERT(prev != m_ptr);
68 return m_ptr == o.m_ptr;
71 return m_ptr != o.m_ptr;
73 constexpr operator bool()
const {
return m_ptr; }
74 constexpr operator Cell *()
const {
return m_ptr; }
75 constexpr Cell *operator->()
const {
return m_ptr; }
79 static_assert(std::is_class<Cell>::value,
"The type argument must be a class");
87 static constexpr iterator end() {
return {}; }
107template <
typename Cell>
109 static_assert(std::is_class<Cell>::value,
"The type argument must be a class");
115 std::vector<Frame> m_stack;
118 using iterator_category = std::forward_iterator_tag;
120 using difference_type = std::ptrdiff_t;
131 return operator++(), ret;
138 const auto *
const prev = m_ptr;
141 if (prev->IsBrokenIntoLines() && prev->GetBrokenCellCount() > 0) {
145 m_stack.push_back(Frame{
const_cast<Cell *
>(prev), 1});
149 while (!next && !m_stack.empty()) {
150 Frame &frame = m_stack.back();
151 if (frame.nextIndex < frame.parent->GetBrokenCellCount()) {
152 next = frame.parent->GetBrokenCell(frame.nextIndex++);
159 Cell *
const afterParent = frame.parent->GetNext();
166 wxASSERT(prev != m_ptr);
170 {
return m_ptr == o.m_ptr; }
172 {
return m_ptr != o.m_ptr; }
173 operator bool()
const {
return m_ptr; }
174 operator Cell*()
const {
return m_ptr; }
175 Cell *operator->()
const {
return m_ptr; }
180 static_assert(std::is_class<Cell>::value,
"The type argument must be a class");
188 static constexpr iterator end() {
return {}; }
198 enum class Advance { Always, OnlyIfNull };
199 const Cell *m_parentCell = {};
200 Cell *m_innerCell = {};
202 size_t m_endIndex = 0;
204 static size_t GetInnerCellCount(
const Cell *cell);
205 static Cell *GetInnerCell(
const Cell *cell,
size_t index);
207 using iterator_category = std::forward_iterator_tag;
209 using difference_type = std::ptrdiff_t;
215 m_parentCell(parentCell),
216 m_endIndex(parentCell ? GetInnerCellCount(parentCell) : 0)
218 FindFirstInnerCell();
225 return operator++(), ret;
230 AdvanceLoop(Advance::Always);
234 {
return m_innerCell == o.m_innerCell; }
236 {
return m_innerCell != o.m_innerCell; }
237 operator bool()
const {
return m_innerCell; }
238 operator Cell*()
const {
return m_innerCell; }
239 Cell *operator->()
const {
return m_innerCell; }
242 void FindFirstInnerCell();
243 void AdvanceLoop(Advance mode);
246inline void InnerCellIterator::FindFirstInnerCell()
250 m_innerCell = GetInnerCell(m_parentCell, 0);
251 AdvanceLoop(Advance::OnlyIfNull);
255inline void InnerCellIterator::AdvanceLoop(Advance mode)
257 const Cell *prev = m_innerCell;
258 if (mode == Advance::OnlyIfNull && prev)
263 if (m_index == m_endIndex)
265 m_innerCell =
nullptr;
268 m_innerCell = GetInnerCell(m_parentCell, m_index);
269 wxASSERT(!prev || prev != m_innerCell);
282 iterator begin()
const {
return m_iter; }
283 static iterator end() {
return {}; }
Definition: CellIterators.h:179
Walks the "draw list": the flattened sequence of cells that make up one displayed line,...
Definition: CellIterators.h:108
Definition: CellIterators.h:78
Definition: CellIterators.h:36
The base class all cell types the worksheet can consist of are derived from.
Definition: Cell.h:148
Cell * GetNext() const
Get the next cell in the list.
Definition: Cell.h:803
virtual Cell * GetBrokenCell(size_t index) const
Retrieve a piece of this cell's broken (linear/1D) display; see GetBrokenCellCount().
Definition: Cell.h:829
Definition: CellIterators.h:275
Iterates the inner cells of a cell.
Definition: CellIterators.h:197