+ struct matchIT {
+ /// used by lower_bound and upper_bound
+ inline
+ int operator()(LyXParagraph::InsetTable const & a,
+ LyXParagraph::InsetTable const & b) const {
+ return a.pos < b.pos;
+ }
+ };
+ /** A font entry covers a range of positions. Notice that the
+ entries in the list are inserted in random order.
+ I don't think it's worth the effort to implement a more effective
+ datastructure, because the number of different fonts in a paragraph
+ is limited. (Asger)
+ Nevertheless, I decided to store fontlist using a sorted vector:
+ fontlist = { {pos_1,font_1} , {pos_2,font_2} , ... } where
+ pos_1 < pos_2 < ..., font_{i-1} != font_i for all i,
+ and font_i covers the chars in positions pos_{i-1}+1,...,pos_i
+ (font_1 covers the chars 0,...,pos_1) (Dekel)
+ */
+ struct FontTable {
+ ///
+ FontTable(size_type p, LyXFont const & f)
+ : pos_(p)
+ {
+ font_ = container.get(f);
+ }
+ ///
+ size_type pos() const { return pos_; }
+ ///
+ void pos(size_type p) { pos_ = p; }
+ ///
+ LyXFont const & font() const { return *font_; }
+ ///
+ void font(LyXFont const & f) { font_ = container.get(f);}
+ private:
+ /// End position of paragraph this font attribute covers
+ size_type pos_;
+ /** Font. Interpretation of the font values:
+ If a value is LyXFont::INHERIT_*, it means that the font
+ attribute is inherited from either the layout of this
+ paragraph or, in the case of nested paragraphs, from the
+ layout in the environment one level up until completely
+ resolved.
+ The values LyXFont::IGNORE_* and LyXFont::TOGGLE are NOT
+ allowed in these font tables.
+ */
+ boost::shared_ptr<LyXFont> font_;
+ ///
+ static ShareContainer<LyXFont> container;
+ };