X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FFontList.cpp;h=9ccdfee55479be99d0dd85fafcf4d1da912b3dc7;hb=15a87dd3a86235848983022ecb7927675a62d4e3;hp=efe1208f2f59ba5f0895efef18fd36d170b3e902;hpb=992eae252441d6ad15d5a18283e934a6371a016b;p=lyx.git diff --git a/src/FontList.cpp b/src/FontList.cpp index efe1208f2f..9ccdfee554 100644 --- a/src/FontList.cpp +++ b/src/FontList.cpp @@ -20,9 +20,7 @@ #include "FontList.h" -#include - -#include +#include "support/lyxalgo.h" using namespace std; @@ -53,13 +51,14 @@ FontList::const_iterator FontList::fontIterator(pos_type pos) const } -Font & FontList::get(pos_type pos) +Font const & FontList::get(pos_type pos) { iterator end = list_.end(); iterator it = fontIterator(pos); if (it != end && it->pos() == pos) return it->font_; - static Font dummy; + + static Font const dummy; return dummy; } @@ -70,8 +69,8 @@ void FontList::erase(pos_type pos) iterator it = fontIterator(pos); iterator beg = list_.begin(); if (it != list_.end() && it->pos() == pos - && (pos == 0 - || (it != list_.begin() && boost::prior(it)->pos() == pos - 1))) { + && (pos == 0 + || (it != list_.begin() && prev(it, 1)->pos() == pos - 1))) { // If it is a multi-character font // entry, we just make it smaller @@ -136,7 +135,7 @@ void FontList::set(pos_type pos, Font const & font) size_t const i = distance(list_.begin(), it); // Is position pos a beginning of a font block? - bool const begin = pos == 0 || !found + bool const begin = pos == 0 || !found || (i > 0 && list_[i - 1].pos() == pos - 1); // Is position pos at the end of a font block? @@ -181,38 +180,6 @@ void FontList::set(pos_type pos, Font const & font) } -FontSize FontList::highestInRange(pos_type startpos, pos_type endpos, - FontSize def_size) const -{ - if (list_.empty()) - return def_size; - - List::const_iterator end_it = fontIterator(endpos); - const_iterator const end = list_.end(); - if (end_it != end) - ++end_it; - - List::const_iterator cit = fontIterator(startpos); - - FontSize maxsize = FONT_SIZE_TINY; - for (; cit != end_it; ++cit) { - FontSize size = cit->font().fontInfo().size(); - if (size == FONT_SIZE_INHERIT) - size = def_size; - if (size > maxsize && size <= FONT_SIZE_HUGER) - maxsize = size; - } - return maxsize; -} - - -bool FontList::hasChangeInRange(pos_type pos, int len) const -{ - List::const_iterator cit = fontIterator(pos); - return cit == list_.end() || pos + len - 1 <= cit->pos(); -} - - void FontList::validate(LaTeXFeatures & features) const { const_iterator fcit = list_.begin();