+ RowListIterator() :
+ row_it_(RowList::const_iterator()),
+ row_end_(RowList::const_iterator()),
+ it_(RowEntryList::const_iterator()),
+ it_end_(RowEntryList::const_iterator()) { }
+
+
+ RowEntry const & operator*()
+ {
+ return *it_;
+ }
+
+
+ RowListIterator & operator++()
+ {
+ ++it_;
+ normalize();
+ return *this;
+ }
+
+
+ bool atEnd() const
+ {
+ return row_it_ == row_end_;
+ }
+
+
+ bool operator==(RowListIterator const & a) const
+ {
+ return row_it_ == a.row_it_ && ((atEnd() && a.atEnd()) || it_ == a.it_);
+ }
+
+
+ bool operator!=(RowListIterator const & a) const { return !operator==(a); }
+
+
+ // Current row.
+ RowList::const_iterator const & row() const
+ {
+ return row_it_;
+ }
+private:
+ // ensures that it_ points to a valid value unless row_it_ == row_end_
+ void normalize()
+ {
+ if (row_it_ == row_end_)
+ return;
+ while (it_ == it_end_) {
+ ++row_it_;
+ if (row_it_ != row_end_) {
+ it_ = row_it_->begin();
+ it_end_ = row_it_->end();
+ } else
+ return;
+ }
+ }
+ //
+ RowList::const_iterator row_it_;
+ //
+ RowList::const_iterator row_end_;
+ //
+ RowEntryList::const_iterator it_;
+ //
+ RowEntryList::const_iterator it_end_;
+};
+
+
+TexRow::RowListIterator TexRow::begin() const
+{
+ return RowListIterator(rowlist_.begin(), rowlist_.end());
+}
+
+
+TexRow::RowListIterator TexRow::end() const
+{
+ return RowListIterator(rowlist_.end(), rowlist_.end());
+}
+
+
+std::pair<int,int> TexRow::rowFromDocIterator(DocIterator const & dit) const
+{
+ bool beg_found = false;
+ bool end_is_next = true;
+ int end_offset = 1;
+ size_t best_slice = 0;
+ RowEntry best_entry = row_none;
+ size_t const n = dit.depth();
+ // this loop finds a pair (best_beg_row,best_end_row) where best_beg_row is
+ // the first row of the topmost possible CursorSlice, and best_end_row is
+ // the one just before the first row matching the next CursorSlice.
+ RowListIterator const begin = this->begin();//necessary disambiguation
+ RowListIterator const end = this->end();
+ RowListIterator best_beg_entry;
+ //best last entry with same pos as the beg_entry, or first entry with pos
+ //immediately following the beg_entry
+ RowListIterator best_end_entry;
+ RowListIterator it = begin;