+ /// an individual par id/pos <=> row mapping
+ struct TextEntry { int id; int pos; };
+
+ /// an individual math id/cell <=> row mapping
+ struct MathEntry { uid_type id; idx_type cell; };
+
+ /// a container for passing entries around
+ struct RowEntry {
+ bool is_math;// true iff the union is a math
+ union {
+ struct TextEntry text;
+ struct MathEntry math;
+ };
+ };
+
+ // 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.
+ class RowEntryList : public std::vector<RowEntry> {
+ public:
+ RowEntryList() : std::vector<RowEntry>(), text_entry_(-1) {}
+
+ // returns true if the row entry will appear in the row entry list
+ bool addEntry(RowEntry const &);
+
+ // the row entry will appear in the row entry list, but it never counts
+ // as a proper text entry.
+ void forceAddEntry(RowEntry const &);
+
+ // returns the TextEntry or TexRow::text_none if none
+ TextEntry getTextEntry() const;
+
+ // returns the first entry, or TexRow::row_none if none
+ RowEntry entry() const;
+
+ // appends a row
+ void append(RowEntryList const &);
+
+ private:
+ size_t text_entry_;
+ };
+
+ /// Returns true if RowEntry is devoid of information
+ static bool isNone(RowEntry const &);
+ static const TextEntry text_none;
+ static const RowEntry row_none;
+
+ /// Returns true if TextEntry is devoid of information
+ static bool isNone(TextEntry const &);
+
+ /// Converts a CursorSlice into a RowEntry
+ static RowEntry rowEntryFromCursorSlice(CursorSlice const & slice);
+
+ /// Encapsulates the paragraph and position for later use
+ static RowEntry textEntry(int id, int pos);
+
+ /// Encapsulates a cell and position for later use
+ static RowEntry mathEntry(uid_type id, idx_type cell);
+
+ /// true iff same paragraph or math inset
+ static bool sameParOrInsetMath(RowEntry const &, RowEntry const &);
+
+ /// computes the distance in pos or cell index
+ /// assumes it is the sameParOrInsetMath
+ static int comparePos(RowEntry const & entry1, RowEntry const & entry2);
+
+ /// for debugging purposes
+ static docstring asString(RowEntry const &);
+