]> git.lyx.org Git - features.git/commitdiff
ERT simplification
authorMartin Vermeer <martin.vermeer@hut.fi>
Sat, 27 Oct 2007 14:05:05 +0000 (14:05 +0000)
committerMartin Vermeer <martin.vermeer@hut.fi>
Sat, 27 Oct 2007 14:05:05 +0000 (14:05 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21224 a592a061-630c-0410-9148-cb99ea01b6c8

src/insets/InsetERT.cpp
src/insets/InsetERT.h

index 43efcb22d4b28172f2cb1b851e9288b7acdd8df5..e96daa2f06b73273be4324e49f7e181ae42df937 100644 (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:
index d576b1f201b8ad7e7d80e9f33a7db49e8dbc3466..1477115cab984992709613d0636ec9ca24868aa9 100644 (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;
        ///