From 9bc5e190d4818322ec4828fb507943cfb5eba6fe Mon Sep 17 00:00:00 2001 From: Martin Vermeer Date: Sat, 27 Oct 2007 14:05:05 +0000 Subject: [PATCH] ERT simplification git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21224 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/insets/InsetERT.cpp | 41 ++++++++++++++++++----------------------- src/insets/InsetERT.h | 3 +++ 2 files changed, 21 insertions(+), 23 deletions(-) diff --git a/src/insets/InsetERT.cpp b/src/insets/InsetERT.cpp index 43efcb22d4..e96daa2f06 100644 --- a/src/insets/InsetERT.cpp +++ b/src/insets/InsetERT.cpp @@ -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: diff --git a/src/insets/InsetERT.h b/src/insets/InsetERT.h index d576b1f201..1477115cab 100644 --- a/src/insets/InsetERT.h +++ b/src/insets/InsetERT.h @@ -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; /// -- 2.39.2