+ /// true iff same paragraph or math inset or begin_document
+ static bool sameParOrInsetMath(RowEntry entry1, RowEntry entry2);
+ /// computes the distance in pos or cell index
+ /// assumes it is the sameParOrInsetMath
+ static int comparePos(RowEntry entry1, RowEntry entry2);
+
+};
+
+
+/// TexString : dumb struct to pass around docstrings with TexRow information.
+/// They are best created using otexstringstream.
+/// They can be output to otexrowstreams and otexstreams.
+/// A valid TexString has as many newlines in str as in texrow. Be careful not
+/// to introduce a mismatch between the line and the row counts, as this will
+/// assert in devel mode when outputting to a otexstream.
+struct TexString {
+ ///
+ docstring str;
+ ///
+ TexRow texrow;
+ /// Copy can be expensive and is not usually useful for TexString.
+ /// Force explicit copy, prefer move instead. This also prevents
+ /// move()s from being converted into copy silently.
+ explicit TexString(TexString const &) = default;
+ TexString(TexString && other) = default;
+ TexString & operator=(TexString const & other) = default;
+ TexString & operator=(TexString && other) = default;
+ /// Empty TexString
+ TexString() = default;
+ /// Texstring containing str and TexRow with enough lines which are empty
+ explicit TexString(docstring str);
+ /// Texstring containing str and texrow. Must be valid.
+ TexString(docstring str, TexRow texrow);
+ /// Ensure that the string and the TexRow have as many newlines.
+ void validate();
+};
+
+
+// Standard container needs a complete type
+class TexRow::RowEntryList {
+ // For each row we store a list of one special TextEntry and several
+ // RowEntries. (The order is important.) We only want one text entry
+ // because we do not want to store every position in the lyx file. On the
+ // other hand we want to record all math and table cells positions for
+ // enough precision. Usually the count of cells is easier to handle.
+ // The RowEntries are used for forward-search and the code preview pane.
+ std::vector<RowEntry> v_;
+ // The TextEntry is currently used for reverse-search and the error
+ // reporting dialog. Once the latter are adapted to rely on the more precise
+ // RowEntries above, it can be removed.
+ TextEntry text_entry_;
+
+public:
+ typedef std::vector<RowEntry>::iterator iterator;
+ iterator begin() { return v_.begin(); }
+ iterator end() { return v_.end(); }
+ ///
+ typedef std::vector<RowEntry>::const_iterator const_iterator;
+ const_iterator begin() const { return v_.cbegin(); }
+ const_iterator end() const { return v_.cend(); }
+ ///
+ RowEntryList() : text_entry_(TexRow::text_none) {}
+
+ // returns true if the row entry will appear in the row entry list
+ bool addEntry(RowEntry entry);
+
+ // the row entry will appear in the row entry list, but it never counts
+ // as a proper text entry.
+ void forceAddEntry(RowEntry entry);
+
+ // returns the TextEntry or TexRow::text_none if none
+ TextEntry getTextEntry() const;
+
+ // appends a row
+ void append(RowEntryList row);