* Paragraph::highestFontInRange(): Transfer some more code from Paragraph to FontList.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21064 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Abdelrazak Younes 2007-10-19 14:55:44 +00:00
parent 2f72a0a721
commit 0077782724
3 changed files with 42 additions and 28 deletions

View File

@ -177,4 +177,38 @@ void FontList::set(pos_type pos, Font const & font)
}
}
Font_size FontList::highestInRange
(pos_type startpos, pos_type endpos, Font_size 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;
}
Font::FONT_SIZE maxsize = Font::SIZE_TINY;
for (; cit != end_it; ++cit) {
Font::FONT_SIZE size = cit->font().size();
if (size == Font::INHERIT_SIZE)
size = def_size;
if (size > maxsize && size <= Font::SIZE_HUGER)
maxsize = size;
}
return maxsize;
}
} // namespace lyx

View File

@ -96,6 +96,13 @@ public:
///
void decreasePosAfterPos(pos_type pos);
/// Returns the height of the highest font in range
Font_size highestInRange(
pos_type startpos,
pos_type endpos,
Font_size def_size
) const;
private:
///
List list_;

View File

@ -1338,34 +1338,7 @@ Font const Paragraph::getLayoutFont
Font_size Paragraph::highestFontInRange
(pos_type startpos, pos_type endpos, Font_size def_size) const
{
if (d->fontlist_.empty())
return def_size;
FontList::const_iterator end_it = d->fontlist_.begin();
FontList::const_iterator const end = d->fontlist_.end();
for (; end_it != end; ++end_it) {
if (end_it->pos() >= endpos)
break;
}
if (end_it != end)
++end_it;
FontList::const_iterator cit = d->fontlist_.begin();
for (; cit != end; ++cit) {
if (cit->pos() >= startpos)
break;
}
Font::FONT_SIZE maxsize = Font::SIZE_TINY;
for (; cit != end_it; ++cit) {
Font::FONT_SIZE size = cit->font().size();
if (size == Font::INHERIT_SIZE)
size = def_size;
if (size > maxsize && size <= Font::SIZE_HUGER)
maxsize = size;
}
return maxsize;
return d->fontlist_.highestInRange(startpos, endpos, def_size);
}