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;
70 constexpr operator bool()
const {
return m_ptr; }
71 constexpr operator Cell *()
const {
return m_ptr; }
72 constexpr Cell *operator->()
const {
return m_ptr; }
76 static_assert(std::is_class<Cell>::value,
"The type argument must be a class");
84 static constexpr iterator end() {
return {}; }
104template <
typename Cell>
106 static_assert(std::is_class<Cell>::value,
"The type argument must be a class");
112 std::vector<Frame> m_stack;
115 using iterator_category = std::forward_iterator_tag;
117 using difference_type = std::ptrdiff_t;
128 return operator++(), ret;
135 const auto *
const prev = m_ptr;
138 if (prev->IsBrokenIntoLines() && prev->GetBrokenCellCount() > 0) {
142 m_stack.push_back(Frame{
const_cast<Cell *
>(prev), 1});
146 while (!next && !m_stack.empty()) {
147 Frame &frame = m_stack.back();
148 if (frame.nextIndex < frame.parent->GetBrokenCellCount()) {
149 next = frame.parent->GetBrokenCell(frame.nextIndex++);
156 Cell *
const afterParent = frame.parent->GetNext();
163 wxASSERT(prev != m_ptr);
167 {
return m_ptr == o.m_ptr; }
168 operator bool()
const {
return m_ptr; }
169 operator Cell*()
const {
return m_ptr; }
170 Cell *operator->()
const {
return m_ptr; }
175 static_assert(std::is_class<Cell>::value,
"The type argument must be a class");
183 static constexpr iterator end() {
return {}; }
193 enum class Advance { Always, OnlyIfNull };
194 const Cell *m_parentCell = {};
195 Cell *m_innerCell = {};
197 size_t m_endIndex = 0;
199 static size_t GetInnerCellCount(
const Cell *cell);
200 static Cell *GetInnerCell(
const Cell *cell,
size_t index);
202 using iterator_category = std::forward_iterator_tag;
204 using difference_type = std::ptrdiff_t;
210 m_parentCell(parentCell),
211 m_endIndex(parentCell ? GetInnerCellCount(parentCell) : 0)
213 FindFirstInnerCell();
220 return operator++(), ret;
225 AdvanceLoop(Advance::Always);
229 {
return m_innerCell == o.m_innerCell; }
230 operator bool()
const {
return m_innerCell; }
231 operator Cell*()
const {
return m_innerCell; }
232 Cell *operator->()
const {
return m_innerCell; }
235 void FindFirstInnerCell();
236 void AdvanceLoop(Advance mode);
239inline void InnerCellIterator::FindFirstInnerCell()
243 m_innerCell = GetInnerCell(m_parentCell, 0);
244 AdvanceLoop(Advance::OnlyIfNull);
248inline void InnerCellIterator::AdvanceLoop(Advance mode)
250 const Cell *prev = m_innerCell;
251 if (mode == Advance::OnlyIfNull && prev)
256 if (m_index == m_endIndex)
258 m_innerCell =
nullptr;
261 m_innerCell = GetInnerCell(m_parentCell, m_index);
262 wxASSERT(!prev || prev != m_innerCell);
275 iterator begin()
const {
return m_iter; }
276 static iterator end() {
return {}; }
Definition: CellIterators.h:174
Walks the "draw list": the flattened sequence of cells that make up one displayed line,...
Definition: CellIterators.h:105
Definition: CellIterators.h:75
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:864
virtual Cell * GetBrokenCell(size_t index) const
Retrieve a piece of this cell's broken (linear/1D) display; see GetBrokenCellCount().
Definition: Cell.h:890
Definition: CellIterators.h:268
Iterates the inner cells of a cell.
Definition: CellIterators.h:192