Introducing FontList::setRange()

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21126 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Abdelrazak Younes 2007-10-22 19:18:51 +00:00
parent 3d33cd8bd3
commit c86e632afa
3 changed files with 16 additions and 2 deletions

View File

@ -122,6 +122,14 @@ void FontList::decreasePosAfterPos(pos_type pos)
}
void FontList::setRange(pos_type startpos, pos_type endpos, Font const & font)
{
// FIXME: Optimize!!!
for (pos_type pos = startpos; pos != endpos; ++pos)
set(pos, font);
}
void FontList::set(pos_type pos, Font const & font)
{
// No need to simplify this because it will disappear

View File

@ -94,6 +94,11 @@ public:
///
void set(pos_type pos, Font const & font);
///
void setRange(
pos_type startpos,
pos_type endpos,
Font const & font);
///
void increasePosAfterPos(pos_type pos);
///
void decreasePosAfterPos(pos_type pos);

View File

@ -1153,15 +1153,16 @@ void Paragraph::appendString(docstring const & s, Font const & font,
Change const & change)
{
size_t end = s.size();
pos_type startpos = text_.size();
// FIXME: Optimize this!
text_.reserve(text_.size() + end);
text_.reserve(startpos + end);
for (pos_type i = 0; i != end; ++i) {
// track change
d->changes_.insert(change, i);
// when appending characters, no need to update tables
text_.push_back(s[i]);
setFont(i, font);
}
d->fontlist_.setRange(startpos, text_.size(), font);
}