X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FDocIterator.h;h=dfef036ae7a01303110d5e433d41db9ff7d97f92;hb=1007714d2ec380d935d59092013ea88373bfb1df;hp=fd4050cec8c40e23bb70b1621d3ff279392070b8;hpb=76dec26fec47df5b828973554b85dc91f3b564d1;p=lyx.git diff --git a/src/DocIterator.h b/src/DocIterator.h index fd4050cec8..dfef036ae7 100644 --- a/src/DocIterator.h +++ b/src/DocIterator.h @@ -20,7 +20,7 @@ namespace lyx { -class LyXText; +class Text; class MathAtom; class Paragraph; @@ -49,7 +49,7 @@ public: /// DocIterator(); /// - explicit DocIterator(InsetBase & inset); + explicit DocIterator(Inset & inset); /// access slice at position \p i CursorSlice const & operator[](size_t i) const { return slices_[i]; } @@ -80,7 +80,7 @@ public: /// how many nested insets do we have? size_t depth() const { return slices_.size(); } /// the containing inset - InsetBase & inset() const { return top().inset(); } + Inset & inset() const { return top().inset(); } /// return the cell of the inset this cursor is in idx_type idx() const { return top().idx(); } /// return the cell of the inset this cursor is in @@ -115,11 +115,11 @@ public: /// return the last column of the top grid col_type lastcol() const { return ncols() - 1; } /// the inset just behind the cursor - InsetBase * nextInset(); + Inset * nextInset(); /// the inset just in front of the cursor - InsetBase * prevInset(); + Inset * prevInset(); /// the inset just in front of the cursor - InsetBase const * prevInset() const; + Inset const * prevInset() const; /// bool boundary() const { return boundary_; } /// @@ -155,20 +155,25 @@ public: // /// the paragraph we're in Paragraph & paragraph(); - /// the paragraph we're in + /// the paragraph we're in in text mode. + /// \warning only works within text! Paragraph const & paragraph() const; + /// the paragraph we're in in any case. + /// This method will give the containing paragraph if + /// in not in text mode (ex: in mathed). + Paragraph const & innerParagraph() const; /// - LyXText * text(); + Text * text(); /// - LyXText const * text() const; + Text const * text() const; /// the containing inset or the cell, respectively - InsetBase * realInset() const; + Inset * realInset() const; /// - InsetBase * innerInsetOfType(int code) const; + Inset * innerInsetOfType(int code) const; /// - LyXText * innerText(); + Text * innerText(); /// - LyXText const * innerText() const; + Text const * innerText() const; // // elementary moving @@ -208,6 +213,9 @@ public: operator<<(std::ostream & os, DocIterator const & cur); /// friend bool operator==(DocIterator const &, DocIterator const &); + friend bool operator<(DocIterator const &, DocIterator const &); + friend bool operator>(DocIterator const &, DocIterator const &); + friend bool operator<=(DocIterator const &, DocIterator const &); /// friend class StableDocIterator; //protected: @@ -218,7 +226,10 @@ public: /// void pop_back() { slices_.pop_back(); } /// recompute the inset parts of the cursor from the document data - void updateInsets(InsetBase * inset); + void updateInsets(Inset * inset); + /// fix DocIterator in circumstances that should never happen. + /// \return true if the DocIterator was fixed. + bool fixIfBroken(); private: /** @@ -244,12 +255,12 @@ private: /// std::vector slices_; /// - InsetBase * inset_; + Inset * inset_; }; -DocIterator doc_iterator_begin(InsetBase & inset); -DocIterator doc_iterator_end(InsetBase & inset); +DocIterator doc_iterator_begin(Inset & inset); +DocIterator doc_iterator_end(Inset & inset); inline @@ -277,7 +288,7 @@ public: /// non-explicit intended StableDocIterator(const DocIterator & it); /// - DocIterator asDocIterator(InsetBase * start) const; + DocIterator asDocIterator(Inset * start) const; /// size_t size() const { return data_.size(); } /// return the position within the paragraph