ERT simplification

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21224 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Martin Vermeer 2007-10-27 14:05:05 +00:00
parent 0a554a5216
commit 9bc5e190d4
2 changed files with 21 additions and 23 deletions

View File

@ -101,6 +101,22 @@ InsetERT::~InsetERT()
}
void InsetERT::resetParagraphsFont()
{
Font font(Font::ALL_INHERIT, latex_language);
ParagraphList::iterator par = paragraphs().begin();
ParagraphList::iterator const end = paragraphs().end();
while (par != end) {
pos_type siz = par->size();
for (pos_type i = 0; i <= siz; ++i) {
par->setFont(i, font);
}
par->params().clear();
++par;
}
}
void InsetERT::write(Buffer const & buf, ostream & os) const
{
os << "ERT" << "\n";
@ -119,16 +135,7 @@ void InsetERT::read(Buffer const & buf, Lexer & lex)
// inherits the language from the last position of the existing text.
// As a side effect this makes us also robust against bugs in LyX
// that might lead to font changes in ERT in .lyx files.
Font font(Font::ALL_INHERIT, latex_language);
ParagraphList::iterator par = paragraphs().begin();
ParagraphList::iterator const end = paragraphs().end();
while (par != end) {
pos_type siz = par->size();
for (pos_type i = 0; i <= siz; ++i) {
par->setFont(i, font);
}
++par;
}
resetParagraphsFont();
}
@ -213,20 +220,8 @@ void InsetERT::doDispatch(Cursor & cur, FuncRequest & cmd)
// attributes.
// FIXME: Change only the pasted paragraphs
Font font = layout->font;
// ERT contents has always latex_language
font.setLanguage(latex_language);
ParagraphList::iterator const end = paragraphs().end();
for (ParagraphList::iterator par = paragraphs().begin();
par != end; ++par) {
// in case par had a manual label
par->setBeginOfBody();
pos_type const siz = par->size();
for (pos_type i = 0; i < siz; ++i) {
par->setFont(i, font);
}
par->params().clear();
}
resetParagraphsFont();
break;
}
default:

View File

@ -82,6 +82,9 @@ protected:
virtual void doDispatch(Cursor & cur, FuncRequest & cmd);
///
bool getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus &) const;
///
void resetParagraphsFont();
private:
virtual Inset * clone() const;
///