X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FFontList.cpp;h=1bfab761fd8d7cace97377056fed300f2909eb64;hb=0c7bd9a57f2a308bb9659200eda3b7e45f8d5d3c;hp=954ab4a1d5836a8fee8514428eaa63c6f6bbfc56;hpb=bef58b3b16d3b3c4a13c2c2070cfe1598c1e4b03;p=lyx.git diff --git a/src/FontList.cpp b/src/FontList.cpp index 954ab4a1d5..1bfab761fd 100644 --- a/src/FontList.cpp +++ b/src/FontList.cpp @@ -4,13 +4,13 @@ * Licence details can be found in the file COPYING. * * \author Asger Alstrup - * \author Lars Gullik Bjønnes + * \author Lars Gullik Bjønnes * \author Jean-Marc Lasgouttes * \author Angus Leeming * \author John Levon - * \author André Pönitz + * \author André Pönitz * \author Dekel Tsur - * \author Jürgen Vigna + * \author Jürgen Vigna * \author Abdelrazak Younes * * Full author contact details are available in file CREDITS. @@ -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; } @@ -71,7 +70,7 @@ void FontList::erase(pos_type pos) iterator beg = list_.begin(); if (it != list_.end() && it->pos() == pos && (pos == 0 - || (it != list_.begin() && boost::prior(it)->pos() == pos - 1))) { + || (it != list_.begin() && prev(it, 1)->pos() == pos - 1))) { // If it is a multi-character font // entry, we just make it smaller @@ -127,30 +126,23 @@ void FontList::set(pos_type pos, Font const & font) // in a new kernel. (Asger) // Next search font table - iterator beg = list_.begin(); - iterator it = beg; - iterator endit = list_.end(); - bool found = false; - for (; it != endit; ++it) { - if (it->pos() >= pos) { - found = true; - break; - } - } + List::iterator it = fontIterator(pos); + bool const found = it != list_.end(); if (found && it->font() == font) + // Font is already set. return; - size_t const i = distance(beg, it); + size_t const i = distance(list_.begin(), it); - // Is position pos is a beginning of a font block? - bool begin = pos == 0 || !found + // Is position pos a beginning of a font block? + bool const begin = pos == 0 || !found || (i > 0 && list_[i - 1].pos() == pos - 1); - // Is position pos is the end of a font block? - bool end = found && list_[i].pos() == pos; + // Is position pos at the end of a font block? + bool const end = found && list_[i].pos() == pos; if (!begin && !end) { - // The general case: The block is splitted into 3 blocks + // The general case: The block is split into 3 blocks list_.insert(list_.begin() + i, FontTable(pos - 1, list_[i].font())); list_.insert(list_.begin() + i + 1, @@ -188,56 +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; - - const_iterator end_it = list_.begin(); - const_iterator const end = list_.end(); - for (; end_it != end; ++end_it) { - if (end_it->pos() >= endpos) - break; - } - - if (end_it != end) - ++end_it; - - FontList::const_iterator cit = list_.begin(); - for (; cit != end; ++cit) { - if (cit->pos() >= startpos) - break; - } - - 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 -{ - // FIXME: can't we use fontIterator(pos) instead? - const_iterator cit = list_.begin(); - const_iterator end = list_.end(); - for (; cit != end; ++cit) { - if (cit->pos() >= pos) - break; - } - if (cit != end && pos + len - 1 > cit->pos()) - return false; - - return true; -} - - void FontList::validate(LaTeXFeatures & features) const { const_iterator fcit = list_.begin();