]> git.lyx.org Git - lyx.git/blobdiff - src/paragraph.C
Applied Angus patch to compile on DEC C++ and to avoid name clashes
[lyx.git] / src / paragraph.C
index a17825476c65a166f6a23ddba048acc2e5826316..7b04bddeb6471e55091a792188c87f3d3e0fd8be 100644 (file)
@@ -38,6 +38,7 @@
 #include "support/lyxmanip.h"
 #include "BufferView.h"
 #include "encoding.h"
+#include "ParameterStruct.h"
 
 using std::ostream;
 using std::endl;
@@ -54,9 +55,14 @@ int tex_code_break_column = 72;  // needs non-zero initialization. set later.
 extern string bibitemWidest(Buffer const *);
 
 // this is a minibuffer
-static char minibuffer_char;
-static LyXFont minibuffer_font;
-static Inset * minibuffer_inset;
+
+namespace {
+
+char minibuffer_char;
+LyXFont minibuffer_font;
+Inset * minibuffer_inset;
+
+} // namespace anon
 
 
 extern BufferView * current_view;
@@ -65,21 +71,22 @@ extern BufferView * current_view;
 // declared in lyxparagraph.h
 unsigned int LyXParagraph::paragraph_id = 0;
 
+// Initialize static member.
+ShareContainer<LyXFont> LyXParagraph::FontTable::container;
+
 
 LyXParagraph::LyXParagraph()
 {
        text.reserve(500); // is this number too big?
        for (int i = 0; i < 10; ++i) setCounter(i , 0);
-       appendix = false;
        enumdepth = 0;
        itemdepth = 0;
-       next = 0;
-       previous = 0;
+       next_ = 0;
+       previous_ = 0;
 #ifndef NEW_INSETS
        footnoteflag = LyXParagraph::NO_FOOTNOTE;
        footnotekind = LyXParagraph::FOOTNOTE; // should not be needed
 #endif
-       align = LYX_ALIGN_BLOCK;
 
        inset_owner = 0;
        id_ = paragraph_id++;
@@ -95,15 +102,14 @@ LyXParagraph::LyXParagraph(LyXParagraph * par)
        par->fitToSize();
        
        for (int i = 0; i < 10; ++i) setCounter(i, 0);
-       appendix = false;
        enumdepth = 0;
        itemdepth = 0;
        // double linked list begin
-       next = par->next;
-       if (next)
-               next->previous = this;
-       previous = par;
-       previous->next = this;
+       next_ = par->next_;
+       if (next_)
+               next_->previous_ = this;
+       previous_ = par;
+       previous_->next_ = this;
        // end
 #ifndef NEW_INSETS
        footnoteflag = LyXParagraph::NO_FOOTNOTE;
@@ -119,18 +125,13 @@ LyXParagraph::LyXParagraph(LyXParagraph * par)
 
 
 void LyXParagraph::writeFile(Buffer const * buf, ostream & os,
-                            BufferParams const & params,
+                            BufferParams const & bparams,
                             char footflag, char dth) const
 {
 #ifndef NEW_INSETS
-       if (
-               footnoteflag != LyXParagraph::NO_FOOTNOTE ||
-           !previous
-           || previous->footnoteflag == LyXParagraph::NO_FOOTNOTE
-               ) {
-#endif
-               
-#ifndef NEW_INSETS
+       if (footnoteflag != LyXParagraph::NO_FOOTNOTE ||
+           !previous_
+           || previous_->footnoteflag == LyXParagraph::NO_FOOTNOTE) {
                // The beginning or the end of a footnote environment?
                if (footflag != footnoteflag) {
                        footflag = footnoteflag;
@@ -144,14 +145,14 @@ void LyXParagraph::writeFile(Buffer const * buf, ostream & os,
                }
 #endif
                // The beginning or end of a deeper (i.e. nested) area?
-               if (dth != depth) {
-                       if (depth > dth) {
-                               while (depth > dth) {
+               if (dth != params.depth()) {
+                       if (params.depth() > dth) {
+                               while (params.depth() > dth) {
                                        os << "\n\\begin_deeper ";
                                        ++dth;
                                }
                        } else {
-                               while (depth < dth) {
+                               while (params.depth() < dth) {
                                        os << "\n\\end_deeper ";
                                        --dth;
                                }
@@ -160,49 +161,49 @@ void LyXParagraph::writeFile(Buffer const * buf, ostream & os,
 
                // First write the layout
                os << "\n\\layout "
-                  << textclasslist.NameOfLayout(params.textclass, layout)
+                  << textclasslist.NameOfLayout(bparams.textclass, layout)
                   << "\n";
 
                // Maybe some vertical spaces.
-               if (added_space_top.kind() != VSpace::NONE)
+               if (params.spaceTop().kind() != VSpace::NONE)
                        os << "\\added_space_top "
-                          << added_space_top.asLyXCommand() << " ";
-               if (added_space_bottom.kind() != VSpace::NONE)
+                          << params.spaceTop().asLyXCommand() << " ";
+               if (params.spaceBottom().kind() != VSpace::NONE)
                        os << "\\added_space_bottom "
-                          << added_space_bottom.asLyXCommand() << " ";
+                          << params.spaceBottom().asLyXCommand() << " ";
 
                // Maybe the paragraph has special spacing
-               spacing.writeFile(os, true);
+               params.spacing().writeFile(os, true);
                
                // The labelwidth string used in lists.
-               if (!labelwidthstring.empty())
+               if (!params.labelWidthString().empty())
                        os << "\\labelwidthstring "
-                          << labelwidthstring << '\n';
+                          << params.labelWidthString() << '\n';
 
                // Lines above or below?
-               if (line_top)
+               if (params.lineTop())
                        os << "\\line_top ";
-               if (line_bottom)
+               if (params.lineBottom())
                        os << "\\line_bottom ";
 
                // Pagebreaks above or below?
-               if (pagebreak_top)
+               if (params.pagebreakTop())
                        os << "\\pagebreak_top ";
-               if (pagebreak_bottom)
+               if (params.pagebreakBottom())
                        os << "\\pagebreak_bottom ";
                        
                // Start of appendix?
-               if (start_of_appendix)
+               if (params.startOfAppendix())
                        os << "\\start_of_appendix ";
 
                // Noindent?
-               if (noindent)
+               if (params.noindent())
                        os << "\\noindent ";
                        
                // Alignment?
-               if (align != LYX_ALIGN_LAYOUT) {
+               if (params.align() != LYX_ALIGN_LAYOUT) {
                        int h = 0;
-                       switch (align) {
+                       switch (params.align()) {
                        case LYX_ALIGN_LEFT: h = 1; break;
                        case LYX_ALIGN_RIGHT: h = 2; break;
                        case LYX_ALIGN_CENTER: h = 3; break;
@@ -210,27 +211,29 @@ void LyXParagraph::writeFile(Buffer const * buf, ostream & os,
                        }
                        os << "\\align " << string_align[h] << " ";
                }
-                if (pextra_type != PEXTRA_NONE) {
-                        os << "\\pextra_type " << pextra_type;
-                        if (pextra_type == PEXTRA_MINIPAGE) {
+#ifndef NO_PEXTRA
+                if (params.pextraType() != PEXTRA_NONE) {
+                        os << "\\pextra_type " << params.pextraType();
+                        if (params.pextraType() == PEXTRA_MINIPAGE) {
                                os << " \\pextra_alignment "
-                                  << pextra_alignment;
-                               if (pextra_hfill)
+                                  << params.pextraAlignment();
+                               if (params.pextraHfill())
                                        os << " \\pextra_hfill "
-                                          << pextra_hfill;
-                               if (pextra_start_minipage)
+                                          << params.pextraHfill();
+                               if (params.pextraStartMinipage())
                                        os << " \\pextra_start_minipage "
-                                          << pextra_start_minipage;
+                                          << params.pextraStartMinipage();
                         }
-                        if (!pextra_width.empty()) {
+                        if (!params.pextraWidth().empty()) {
                                os << " \\pextra_width "
-                                  << VSpace(pextra_width).asLyXCommand();
-                        } else if (!pextra_widthp.empty()) {
+                                  << VSpace(params.pextraWidth()).asLyXCommand();
+                        } else if (!params.pextraWidthp().empty()) {
                                os << " \\pextra_widthp "
-                                  << pextra_widthp;
+                                  << params.pextraWidthp();
                         }
                        os << '\n';
                 }
+#endif
 #ifndef NEW_INSETS
        } else {
                // Dummy layout. This means that a footnote ended.
@@ -243,7 +246,7 @@ void LyXParagraph::writeFile(Buffer const * buf, ostream & os,
        if (bibkey)
                bibkey->Write(buf, os);
 
-       LyXFont font1(LyXFont::ALL_INHERIT, params.language);
+       LyXFont font1(LyXFont::ALL_INHERIT, bparams.language);
 
        int column = 0;
        for (size_type i = 0; i < size(); ++i) {
@@ -253,7 +256,7 @@ void LyXParagraph::writeFile(Buffer const * buf, ostream & os,
                }
                
                // Write font changes
-               LyXFont font2 = GetFontSettings(params, i);
+               LyXFont font2 = GetFontSettings(bparams, i);
                if (font2 != font1) {
                        font2.lyxWriteChanges(font1, os);
                        column = 0;
@@ -317,46 +320,46 @@ void LyXParagraph::writeFile(Buffer const * buf, ostream & os,
        }
        
        // now write the next paragraph
-       if (next)
-               next->writeFile(buf, os, params, footflag, dth);
+       if (next_)
+               next_->writeFile(buf, os, bparams, footflag, dth);
 }
 
 
 void LyXParagraph::validate(LaTeXFeatures & features) const
 {
-       BufferParams const & params = features.bufferParams();
+       BufferParams const & bparams = features.bufferParams();
 
 #ifndef NEW_INSETS
        // this will be useful later
        LyXLayout const & layout =
-               textclasslist.Style(params.textclass, 
+               textclasslist.Style(bparams.textclass, 
                                    GetLayout());
 #endif
        
        // check the params.
-       if (line_top || line_bottom)
+       if (params.lineTop() || params.lineBottom())
                features.lyxline = true;
-       if (!spacing.isDefault())
+       if (!params.spacing().isDefault())
                features.setspace = true;
        
        // then the layouts
        features.layout[GetLayout()] = true;
 
        // then the fonts
-       Language const * doc_language = params.language;
+       Language const * doc_language = bparams.language;
        
        for (FontList::const_iterator cit = fontlist.begin();
             cit != fontlist.end(); ++cit) {
-               if ((*cit).font.noun() == LyXFont::ON) {
+               if ((*cit).font().noun() == LyXFont::ON) {
                        lyxerr[Debug::LATEX] << "font.noun: "
-                                            << (*cit).font.noun()
+                                            << (*cit).font().noun()
                                             << endl;
                        features.noun = true;
                        lyxerr[Debug::LATEX] << "Noun enabled. Font: "
-                                            << (*cit).font.stateText(0)
+                                            << (*cit).font().stateText(0)
                                             << endl;
                }
-               switch ((*cit).font.color()) {
+               switch ((*cit).font().color()) {
                case LColor::none:
                case LColor::inherit:
                case LColor::ignore:
@@ -364,11 +367,11 @@ void LyXParagraph::validate(LaTeXFeatures & features) const
                default:
                        features.color = true;
                        lyxerr[Debug::LATEX] << "Color enabled. Font: "
-                                            << (*cit).font.stateText(0)
+                                            << (*cit).font().stateText(0)
                                             << endl;
                }
 
-               Language const * language = (*cit).font.language();
+               Language const * language = (*cit).font().language();
                if (language->babel() != doc_language->babel()) {
                        features.UsedLanguages.insert(language);
                        lyxerr[Debug::LATEX] << "Found language "
@@ -383,18 +386,22 @@ void LyXParagraph::validate(LaTeXFeatures & features) const
                        (*cit).inset->Validate(features);
        }
 
-        if (pextra_type == PEXTRA_INDENT)
+#ifndef NO_PEXTRA
+        if (params.pextraType() == PEXTRA_INDENT)
                 features.LyXParagraphIndent = true;
-        if (pextra_type == PEXTRA_FLOATFLT)
+        if (params.pextraType() == PEXTRA_FLOATFLT)
                 features.floatflt = true;
+#endif
 #ifndef NEW_INSETS
         if (layout.needprotect 
-           && next && next->footnoteflag != LyXParagraph::NO_FOOTNOTE)
+           && next_ && next_->footnoteflag != LyXParagraph::NO_FOOTNOTE)
                features.NeedLyXFootnoteCode = true;
 #endif
-        if (params.paragraph_separation == BufferParams::PARSEP_INDENT
-            && pextra_type == LyXParagraph::PEXTRA_MINIPAGE)
+#ifndef NO_PEXTRA
+        if (bparams.paragraph_separation == BufferParams::PARSEP_INDENT
+            && params.pextraType() == LyXParagraph::PEXTRA_MINIPAGE)
                features.NeedLyXMinipageIndent = true;
+#endif
 #ifndef NEW_INSETS
        if (footnoteflag != NO_FOOTNOTE && footnotekind == ALGORITHM)
                features.algorithm = true;
@@ -473,43 +480,20 @@ bool LyXParagraph::InsertFromMinibuffer(LyXParagraph::size_type pos)
 
 void LyXParagraph::Clear()
 {
-       line_top = false;
-       line_bottom = false;
-   
-       pagebreak_top = false;
-       pagebreak_bottom = false;
-
-       added_space_top = VSpace(VSpace::NONE);
-       added_space_bottom = VSpace(VSpace::NONE);
-       spacing.set(Spacing::Default);
+       params.clear();
        
-       align = LYX_ALIGN_LAYOUT;
-       depth = 0;
-       noindent = false;
-
-        pextra_type = PEXTRA_NONE;
-        pextra_width.erase();
-        pextra_widthp.erase();
-        pextra_alignment = MINIPAGE_ALIGN_TOP;
-        pextra_hfill = false;
-        pextra_start_minipage = false;
-
-        labelstring.erase();
-       labelwidthstring.erase();
        layout = 0;
        bibkey = 0;
-       
-       start_of_appendix = false;
 }
 
 
 // the destructor removes the new paragraph from the list
 LyXParagraph::~LyXParagraph()
 {
-       if (previous)
-               previous->next = next;
-       if (next)
-               next->previous = previous;
+       if (previous_)
+               previous_->next_ = next_;
+       if (next_)
+               next_->previous_ = previous_;
 
        for (InsetList::iterator it = insetlist.begin();
             it != insetlist.end(); ++it) {
@@ -530,7 +514,7 @@ void LyXParagraph::Erase(LyXParagraph::size_type pos)
        // > because last is the next unused position, and you can 
        // use it if you want
        if (pos > size()) {
-               if (next && next->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) 
+               if (next_ && next_->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) 
                        NextAfterFootnote()->Erase(pos - text.size() - 1);
                else 
                        lyxerr.debug() << "ERROR (LyXParagraph::Erase): "
@@ -566,9 +550,9 @@ void LyXParagraph::Erase(LyXParagraph::size_type pos)
                        lower_bound(fontlist.begin(),
                                    fontlist.end(),
                                    search_font, matchFT());
-               if (it != fontlist.end() && (*it).pos == pos &&
+               if (it != fontlist.end() && (*it).pos() == pos &&
                    (pos == 0 || 
-                    (it != fontlist.begin() && (*(it - 1)).pos == pos - 1))) {
+                    (it != fontlist.begin() && (*(it - 1)).pos() == pos - 1))) {
                        // If it is a multi-character font
                        // entry, we just make it smaller
                        // (see update below), otherwise we
@@ -577,7 +561,7 @@ void LyXParagraph::Erase(LyXParagraph::size_type pos)
                        fontlist.erase(fontlist.begin() + i);
                        it = fontlist.begin() + i;
                        if (i > 0 && i < fontlist.size() &&
-                           fontlist[i - 1].font == fontlist[i].font) {
+                           fontlist[i - 1].font() == fontlist[i].font()) {
                                fontlist.erase(fontlist.begin() + i - 1);
                                it = fontlist.begin() + i - 1;
                        }
@@ -586,7 +570,7 @@ void LyXParagraph::Erase(LyXParagraph::size_type pos)
                // Update all other entries.
                FontList::iterator fend = fontlist.end();
                for (; it != fend; ++it)
-                       --(*it).pos;
+                       (*it).pos((*it).pos() - 1);
 
                // Update the inset table.
                InsetTable search_inset(pos, 0);
@@ -622,8 +606,8 @@ void LyXParagraph::InsertChar(LyXParagraph::size_type pos,
        // > because last is the next unused position, and you can 
        // use it if you want
        if (pos > size()) {
-               if (next
-                   && next->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) 
+               if (next_
+                   && next_->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) 
                        NextAfterFootnote()->InsertChar(pos - text.size() - 1,
                                                        c);
                else 
@@ -642,7 +626,7 @@ void LyXParagraph::InsertChar(LyXParagraph::size_type pos,
                                                 fontlist.end(),
                                                 search_font, matchFT());
             it != fontlist.end(); ++it)
-               ++(*it).pos;
+               (*it).pos((*it).pos() + 1);
    
        // Update the inset table.
        InsetTable search_inset(pos, 0);
@@ -673,8 +657,8 @@ void LyXParagraph::InsertInset(LyXParagraph::size_type pos,
        // > because last is the next unused position, and you can 
        // use it if you want
        if (pos > size()) {
-               if (next
-                   && next->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) 
+               if (next_
+                   && next_->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) 
                        NextAfterFootnote()
                                ->InsertInset(pos - text.size() - 1,
                                              inset, font);
@@ -719,8 +703,8 @@ Inset * LyXParagraph::GetInset(LyXParagraph::size_type pos)
 {
 #ifndef NEW_INSETS
        if (pos >= size()) {
-               if (next
-                   && next->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) 
+               if (next_
+                   && next_->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) 
                        return NextAfterFootnote()
                                ->GetInset(pos - text.size() - 1);
                else
@@ -758,8 +742,8 @@ Inset const * LyXParagraph::GetInset(LyXParagraph::size_type pos) const
 {
 #ifndef NEW_INSETS
        if (pos >= size()) {
-               if (next
-                   && next->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) 
+               if (next_
+                   && next_->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) 
                        return NextAfterFootnote()
                                ->GetInset(pos - text.size() - 1);
                else
@@ -808,7 +792,7 @@ LyXFont const LyXParagraph::GetFontSettings(BufferParams const & bparams,
                                                    fontlist.end(),
                                                    search_font, matchFT());
                if (cit != fontlist.end())
-                       return (*cit).font;
+                       return (*cit).font();
 #ifndef NEW_INSETS
        }
 #endif
@@ -816,8 +800,8 @@ LyXFont const LyXParagraph::GetFontSettings(BufferParams const & bparams,
        // > because last is the next unused position, and you can 
        // use it if you want
        else if (pos > size()) {
-               if (next
-                   && next->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) 
+               if (next_
+                   && next_->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) 
                        return NextAfterFootnote()
                                ->GetFontSettings(bparams,
                                                  pos - text.size() - 1);
@@ -851,11 +835,11 @@ LyXFont const LyXParagraph::GetFirstFontSettings() const
 {
        if (size() > 0) {
                if (!fontlist.empty())
-                       return fontlist[0].font;
+                       return fontlist[0].font();
        }
        
 #ifndef NEW_INSETS
-       else if (next && next->footnoteflag != LyXParagraph::NO_FOOTNOTE) 
+       else if (next_ && next_->footnoteflag != LyXParagraph::NO_FOOTNOTE) 
                return NextAfterFootnote()->GetFirstFontSettings();
 #endif
        return LyXFont(LyXFont::ALL_INHERIT);
@@ -939,7 +923,7 @@ LyXParagraph::HighestFontInRange(LyXParagraph::size_type startpos,
                                 fontlist.end(),
                                 start_search, matchFT());
             cit != end_it; ++cit) {
-               LyXFont::FONT_SIZE size = (*cit).font.size();
+               LyXFont::FONT_SIZE size = (*cit).font().size();
                if (size > maxsize && size <= LyXFont::SIZE_HUGER)
                        maxsize = size;
        }
@@ -968,7 +952,7 @@ LyXParagraph::GetChar(LyXParagraph::size_type pos) const
        // > because last is the next unused position, and you can 
        // use it if you want
        else if (pos > size()) {
-               if (next && next->footnoteflag != LyXParagraph::NO_FOOTNOTE) 
+               if (next_ && next_->footnoteflag != LyXParagraph::NO_FOOTNOTE) 
                        return NextAfterFootnote()
                                ->GetChar(pos - text.size() - 1);
                else
@@ -982,14 +966,14 @@ LyXParagraph::GetChar(LyXParagraph::size_type pos) const
                return '\0';
        } else {
                // We should have a footnote environment.
-               if (!next || next->footnoteflag == LyXParagraph::NO_FOOTNOTE) {
+               if (!next_ || next_->footnoteflag == LyXParagraph::NO_FOOTNOTE) {
                        // Notice that LyX does request the
                        // last char from time to time. (Asger)
                        //lyxerr << "ERROR (LyXParagraph::GetChar): "
                        //      "expected footnote." << endl;
                        return '\0';
                }
-               switch (next->footnotekind) {
+               switch (next_->footnotekind) {
                case LyXParagraph::FOOTNOTE:
                        return LyXParagraph::META_FOOTNOTE;
                case LyXParagraph::MARGIN:
@@ -1097,20 +1081,17 @@ string const LyXParagraph::GetWord(LyXParagraph::size_type & lastpos) const
 }
 
 
-#ifdef NEW_INSETS
-#warning Remember to get rid of this one. (Lgb)
-#endif
+#ifndef NEW_INSETS
 LyXParagraph::size_type LyXParagraph::Last() const
 {
-#ifndef NEW_INSETS
-       if (next && next->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE)
+       if (next_ && next_->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE)
                return text.size() + NextAfterFootnote()->Last() + 1;
        // the 1 is the symbol
        // for the footnote
        else
-#endif
                return text.size();
 }
+#endif
 
 
 #ifndef NEW_INSETS
@@ -1119,8 +1100,8 @@ LyXParagraph * LyXParagraph::ParFromPos(LyXParagraph::size_type pos)
        // > because last is the next unused position, and you can 
        // use it if you want
        if (pos > size()) {
-               if (next
-                   && next->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) 
+               if (next_
+                   && next_->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) 
                        return NextAfterFootnote()
                                ->ParFromPos(pos - text.size() - 1);
                else
@@ -1139,8 +1120,8 @@ int LyXParagraph::PositionInParFromPos(LyXParagraph::size_type pos) const
        // > because last is the next unused position, and you can 
        // use it if you want
        if (pos > size()) {
-               if (next
-                   && next->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) 
+               if (next_
+                   && next_->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) 
                        return NextAfterFootnote()
                                ->PositionInParFromPos(pos - text.size() - 1);
                else
@@ -1162,8 +1143,8 @@ void LyXParagraph::SetFont(LyXParagraph::size_type pos,
        // > because last is the next unused position, and you can 
        // use it if you want
        if (pos > size()) {
-               if (next &&
-                   next->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) {
+               if (next_ &&
+                   next_->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) {
                        NextAfterFootnote()->SetFont(pos - text.size() - 1,
                                                     font);
                } else
@@ -1190,83 +1171,110 @@ void LyXParagraph::SetFont(LyXParagraph::size_type pos,
        unsigned int i = it - fontlist.begin();
        bool notfound = it == fontlist.end();
 
-       if (!notfound && fontlist[i].font == font)
+       if (!notfound && fontlist[i].font() == font)
                return;
 
        bool begin = pos == 0 || notfound ||
-               (i > 0 && fontlist[i-1].pos == pos - 1);
+               (i > 0 && fontlist[i-1].pos() == pos - 1);
        // Is position pos is a beginning of a font block?
-       bool end = !notfound && fontlist[i].pos == pos;
+       bool end = !notfound && fontlist[i].pos() == pos;
        // Is position pos is the end of a font block?
        if (begin && end) { // A single char block
                if (i + 1 < fontlist.size() &&
-                   fontlist[i + 1].font == font) {
+                   fontlist[i + 1].font() == font) {
                        // Merge the singleton block with the next block
                        fontlist.erase(fontlist.begin() + i);
-                       if (i > 0 && fontlist[i - 1].font == font)
+                       if (i > 0 && fontlist[i - 1].font() == font)
                                fontlist.erase(fontlist.begin() + i-1);
-               } else if (i > 0 && fontlist[i - 1].font == font) {
+               } else if (i > 0 && fontlist[i - 1].font() == font) {
                        // Merge the singleton block with the previous block
-                       fontlist[i - 1].pos = pos;
+                       fontlist[i - 1].pos(pos);
                        fontlist.erase(fontlist.begin() + i);
                } else
-                       fontlist[i].font = font;
+                       fontlist[i].font(font);
        } else if (begin) {
-               if (i > 0 && fontlist[i - 1].font == font)
-                       fontlist[i - 1].pos = pos;
+               if (i > 0 && fontlist[i - 1].font() == font)
+                       fontlist[i - 1].pos(pos);
                else
                        fontlist.insert(fontlist.begin() + i,
                                        FontTable(pos, font));
        } else if (end) {
-               fontlist[i].pos = pos - 1;
+               fontlist[i].pos(pos - 1);
                if (!(i + 1 < fontlist.size() &&
-                     fontlist[i + 1].font == font))
+                     fontlist[i + 1].font() == font))
                        fontlist.insert(fontlist.begin() + i + 1,
                                        FontTable(pos, font));
        } else { // The general case. The block is splitted into 3 blocks
                fontlist.insert(fontlist.begin() + i, 
-                               FontTable(pos - 1, fontlist[i].font));
+                               FontTable(pos - 1, fontlist[i].font()));
                fontlist.insert(fontlist.begin() + i + 1,
                                FontTable(pos, font));
        }
 }
 
-   
+
+
+void LyXParagraph::next(LyXParagraph * p)
+{
+       next_ = p;
+}
+
+
 // This function is able to hide closed footnotes.
-LyXParagraph * LyXParagraph::Next()
+LyXParagraph * LyXParagraph::next()
+{
+#ifndef NEW_INSETS
+       if (next_ && next_->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) {
+               LyXParagraph * tmp = next_;
+               while (tmp
+                      && tmp->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE)
+                       tmp = tmp->next_;
+               if (tmp && tmp->footnoteflag != LyXParagraph::CLOSED_FOOTNOTE) 
+                       return tmp->next(); /* there can be more than one
+                                              footnote in a logical
+                                              paragraph */
+               else
+                       return next_;  // This should never happen!
+       } else
+#endif
+               return next_;
+}
+
+
+LyXParagraph const * LyXParagraph::next() const
 {
 #ifndef NEW_INSETS
-       if (next && next->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) {
-               LyXParagraph * tmp = next;
+       if (next_ && next_->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) {
+               LyXParagraph * tmp = next_;
                while (tmp
                       && tmp->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE)
-                       tmp = tmp->next;
+                       tmp = tmp->next_;
                if (tmp && tmp->footnoteflag != LyXParagraph::CLOSED_FOOTNOTE) 
-                       return tmp->Next(); /* there can be more than one
+                       return tmp->next(); /* there can be more than one
                                               footnote in a logical
                                               paragraph */
                else
-                       return next;  // This should never happen!
+                       return next_;  // This should never happen!
        } else
 #endif
-               return next;
+               return next_;
 }
 
 
 #ifndef NEW_INSETS
 LyXParagraph * LyXParagraph::NextAfterFootnote()
 {
-       if (next && next->footnoteflag != LyXParagraph::NO_FOOTNOTE) {
-               LyXParagraph * tmp = next;
+       if (next_ && next_->footnoteflag != LyXParagraph::NO_FOOTNOTE) {
+               LyXParagraph * tmp = next_;
                while (tmp && tmp->footnoteflag != LyXParagraph::NO_FOOTNOTE)
-                       tmp = tmp->next;
+                       tmp = tmp->next_;
                if (tmp && tmp->footnoteflag != LyXParagraph::CLOSED_FOOTNOTE) 
                        return tmp;   /* there can be more than one footnote
                                         in a logical paragraph */
                else
-                       return next;  // This should never happen!
+                       return next_;  // This should never happen!
        } else
-               return next;
+               return next_;
 }
 #endif
 
@@ -1274,17 +1282,17 @@ LyXParagraph * LyXParagraph::NextAfterFootnote()
 #ifndef NEW_INSETS
 LyXParagraph const * LyXParagraph::NextAfterFootnote() const
 {
-       if (next && next->footnoteflag != LyXParagraph::NO_FOOTNOTE) {
-               LyXParagraph * tmp = next;
+       if (next_ && next_->footnoteflag != LyXParagraph::NO_FOOTNOTE) {
+               LyXParagraph * tmp = next_;
                while (tmp && tmp->footnoteflag != LyXParagraph::NO_FOOTNOTE)
-                       tmp = tmp->next;
+                       tmp = tmp->next_;
                if (tmp && tmp->footnoteflag != LyXParagraph::CLOSED_FOOTNOTE) 
                        return tmp;   /* there can be more than one footnote
                                         in a logical paragraph */
                else
-                       return next;  // This should never happen!
+                       return next_;  // This should never happen!
        } else
-               return next;
+               return next_;
 }
 #endif
 
@@ -1293,17 +1301,17 @@ LyXParagraph const * LyXParagraph::NextAfterFootnote() const
 LyXParagraph * LyXParagraph::PreviousBeforeFootnote()
 {
        LyXParagraph * tmp;
-       if (previous && previous->footnoteflag != LyXParagraph::NO_FOOTNOTE) {
-               tmp = previous;
+       if (previous_ && previous_->footnoteflag != LyXParagraph::NO_FOOTNOTE) {
+               tmp = previous_;
                while (tmp && tmp->footnoteflag != LyXParagraph::NO_FOOTNOTE)
-                       tmp = tmp->previous;
+                       tmp = tmp->previous_;
                if (tmp && tmp->footnoteflag != LyXParagraph::CLOSED_FOOTNOTE) 
                        return tmp;    /* there can be more than one footnote
                                          in a logical paragraph */
                else
-                       return previous;  // This should never happen!
+                       return previous_;  // This should never happen!
        } else
-               return previous;
+               return previous_;
 }
 #endif
 
@@ -1315,8 +1323,8 @@ LyXParagraph * LyXParagraph::LastPhysicalPar()
                return this;
    
        LyXParagraph * tmp = this;
-       while (tmp->next
-              && tmp->next->footnoteflag != LyXParagraph::NO_FOOTNOTE)
+       while (tmp->next_
+              && tmp->next_->footnoteflag != LyXParagraph::NO_FOOTNOTE)
                tmp = tmp->NextAfterFootnote();
    
        return tmp;
@@ -1331,8 +1339,8 @@ LyXParagraph const * LyXParagraph::LastPhysicalPar() const
                return this;
    
        LyXParagraph const * tmp = this;
-       while (tmp->next
-              && tmp->next->footnoteflag != LyXParagraph::NO_FOOTNOTE)
+       while (tmp->next_
+              && tmp->next_->footnoteflag != LyXParagraph::NO_FOOTNOTE)
                tmp = tmp->NextAfterFootnote();
    
        return tmp;
@@ -1350,7 +1358,7 @@ LyXParagraph * LyXParagraph::FirstPhysicalPar()
        while (tmppar &&
               (tmppar->IsDummy()
                || tmppar->footnoteflag != LyXParagraph::NO_FOOTNOTE))
-               tmppar = tmppar->previous;
+               tmppar = tmppar->previous_;
    
        if (!tmppar) {
                return this;
@@ -1370,7 +1378,7 @@ LyXParagraph const * LyXParagraph::FirstPhysicalPar() const
        while (tmppar &&
               (tmppar->IsDummy()
                || tmppar->footnoteflag != LyXParagraph::NO_FOOTNOTE))
-               tmppar = tmppar->previous;
+               tmppar = tmppar->previous_;
    
        if (!tmppar) {
                return this;
@@ -1380,52 +1388,58 @@ LyXParagraph const * LyXParagraph::FirstPhysicalPar() const
 #endif
 
 
+void LyXParagraph::previous(LyXParagraph * p)
+{
+       previous_ = p;
+}
+
+
 // This function is able to hide closed footnotes.
-LyXParagraph * LyXParagraph::Previous()
+LyXParagraph * LyXParagraph::previous()
 {
 #ifndef NEW_INSETS
-       LyXParagraph * tmp = previous;
+       LyXParagraph * tmp = previous_;
        if (!tmp)
                return tmp;
 
-       if (tmp->previous
-           && tmp->previous->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) {
-               tmp = tmp->previous;
+       if (tmp->previous_
+           && tmp->previous_->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) {
+               tmp = tmp->previous_;
                while (tmp
                       && tmp->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE)
-                       tmp = tmp->previous;
+                       tmp = tmp->previous_;
                if (tmp && tmp->footnoteflag != LyXParagraph::CLOSED_FOOTNOTE) 
-                       return tmp->next->Previous();   
+                       return tmp->next_->previous();  
 
                else
-                       return previous; 
+                       return previous_
        } else
 #endif
-               return previous;
+               return previous_;
 }
 
 
 // This function is able to hide closed footnotes.
-LyXParagraph const * LyXParagraph::Previous() const
+LyXParagraph const * LyXParagraph::previous() const
 {
 #ifndef NEW_INSETS
-       LyXParagraph * tmp = previous;
+       LyXParagraph * tmp = previous_;
        if (!tmp)
                return tmp;
-       if (tmp->previous
-           && tmp->previous->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) {
-               tmp = tmp->previous;
+       if (tmp->previous_
+           && tmp->previous_->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) {
+               tmp = tmp->previous_;
                while (tmp
                       && tmp->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE)
-                       tmp = tmp->previous;
+                       tmp = tmp->previous_;
                if (tmp && tmp->footnoteflag != LyXParagraph::CLOSED_FOOTNOTE) 
-                       return tmp->next->Previous();   
+                       return tmp->next_->previous();  
 
                else
-                       return previous
+                       return previous_;
        } else
 #endif
-               return previous;
+               return previous_;
 }
 
 
@@ -1460,45 +1474,45 @@ void LyXParagraph::BreakParagraph(BufferParams const & bparams,
        // layout stays the same with latex-environments
        if (flag) {
                tmp->SetOnlyLayout(bparams, firstpar->layout);
-               tmp->SetLabelWidthString(firstpar->labelwidthstring);
+               tmp->SetLabelWidthString(firstpar->params.labelWidthString());
        }
 #else
        // layout stays the same with latex-environments
        if (flag) {
                tmp->SetOnlyLayout(bparams, layout);
-               tmp->SetLabelWidthString(labelwidthstring);
+               tmp->SetLabelWidthString(params.labelWidthString());
        }
 #endif
 #ifndef NEW_INSETS
        if (Last() > pos || !Last() || flag == 2) {
                tmp->SetOnlyLayout(bparams, firstpar->layout);
-               tmp->align = firstpar->align;
-               tmp->SetLabelWidthString(firstpar->labelwidthstring);
+               tmp->params.align(firstpar->params.align());
+               tmp->SetLabelWidthString(firstpar->params.labelWidthString());
       
-               tmp->line_bottom = firstpar->line_bottom;
-               firstpar->line_bottom = false;
-               tmp->pagebreak_bottom = firstpar->pagebreak_bottom;
-               firstpar->pagebreak_bottom = false;
-               tmp->added_space_bottom = firstpar->added_space_bottom;
-               firstpar->added_space_bottom = VSpace(VSpace::NONE);
+               tmp->params.lineBottom(firstpar->params.lineBottom());
+               firstpar->params.lineBottom(false);
+               tmp->params.pagebreakBottom(firstpar->params.pagebreakBottom());
+               firstpar->params.pagebreakBottom(false);
+               tmp->params.spaceBottom(firstpar->params.spaceBottom());
+               firstpar->params.spaceBottom(VSpace(VSpace::NONE));
       
-               tmp->depth = firstpar->depth;
-               tmp->noindent = firstpar->noindent;
+               tmp->params.depth(firstpar->params.depth());
+               tmp->params.noindent(firstpar->params.noindent());
 #else
-       if (Last() > pos || !Last() || flag == 2) {
+       if (size() > pos || !size() || flag == 2) {
                tmp->SetOnlyLayout(bparams, layout);
-               tmp->align = align;
-               tmp->SetLabelWidthString(labelwidthstring);
+               tmp->params.align(params.align());
+               tmp->SetLabelWidthString(params.labelWidthString());
       
-               tmp->line_bottom = line_bottom;
-               line_bottom = false;
-               tmp->pagebreak_bottom = pagebreak_bottom;
-               pagebreak_bottom = false;
-               tmp->added_space_bottom = added_space_bottom;
-               added_space_bottom = VSpace(VSpace::NONE);
+               tmp->params.lineBottom(params.lineBottom());
+               params.lineBottom(false);
+               tmp->params.pagebreakBottom(params.pagebreakBottom());
+               params.pagebreakBottom(false);
+               tmp->params.spaceBottom(params.spaceBottom());
+               params.spaceBottom(VSpace(VSpace::NONE));
       
-               tmp->depth = depth;
-               tmp->noindent = noindent;
+               tmp->params.depth(params.depth());
+               tmp->params.noindent(params.noindent());
 #endif
                // copy everything behind the break-position
                // to the new paragraph
@@ -1540,31 +1554,31 @@ void LyXParagraph::BreakParagraph(BufferParams const & bparams,
 #ifndef NEW_INSETS
        // just an idea of me
        if (!pos) {
-               tmp->line_top = firstpar->line_top;
-               tmp->pagebreak_top = firstpar->pagebreak_top;
-               tmp->added_space_top = firstpar->added_space_top;
+               tmp->params.lineTop(firstpar->params.lineTop());
+               tmp->params.pagebreakTop(firstpar->params.pagebreakTop());
+               tmp->params.spaceTop(firstpar->params.spaceTop());
                tmp->bibkey = firstpar->bibkey;
                firstpar->Clear();
                // layout stays the same with latex-environments
                if (flag) {
                        firstpar->SetOnlyLayout(bparams, tmp->layout);
-                       firstpar->SetLabelWidthString(tmp->labelwidthstring);
-                       firstpar->depth = tmp->depth;
+                       firstpar->SetLabelWidthString(tmp->params.labelWidthString());
+                       firstpar->params.depth(tmp->params.depth());
                }
        }
 #else
        // just an idea of me
        if (!pos) {
-               tmp->line_top = line_top;
-               tmp->pagebreak_top = pagebreak_top;
-               tmp->added_space_top = added_space_top;
+               tmp->params.lineTop(params.lineTop());
+               tmp->params.pagebreakTop(params.pagebreakTop());
+               tmp->params.spaceTop(params.spaceTop());
                tmp->bibkey = bibkey;
                Clear();
                // layout stays the same with latex-environments
                if (flag) {
                        SetOnlyLayout(bparams, tmp->layout);
-                       SetLabelWidthString(tmp->labelwidthstring);
-                       depth = tmp->depth;
+                       SetLabelWidthString(tmp->params.labelWidthString());
+                       params.depth(tmp->params.depth());
                }
        }
 #endif
@@ -1579,28 +1593,10 @@ void LyXParagraph::MakeSameLayout(LyXParagraph const * par)
        footnotekind = par->footnotekind;
 #endif
        layout = par->layout;
-       align = par-> align;
-       SetLabelWidthString(par->labelwidthstring);
-
-       line_bottom = par->line_bottom;
-       pagebreak_bottom = par->pagebreak_bottom;
-       added_space_bottom = par->added_space_bottom;
-
-       line_top = par->line_top;
-       pagebreak_top = par->pagebreak_top;
-       added_space_top = par->added_space_top;
-
-       spacing = par->spacing;
+       params.makeSame(par->params);
        
-        pextra_type = par->pextra_type;
-        pextra_width = par->pextra_width;
-        pextra_widthp = par->pextra_widthp;
-        pextra_alignment = par->pextra_alignment;
-        pextra_hfill = par->pextra_hfill;
-        pextra_start_minipage = par->pextra_start_minipage;
-
-       noindent = par->noindent;
-       depth = par->depth;
+       // This can be changed after NEW_INSETS is in effect. (Lgb)
+       SetLabelWidthString(par->params.labelWidthString());
 }
 
 
@@ -1610,10 +1606,10 @@ LyXParagraph * LyXParagraph::FirstSelfrowPar()
        LyXParagraph * tmppar = this;
        while (tmppar && (
                (tmppar->IsDummy()
-                && tmppar->previous->footnoteflag == 
+                && tmppar->previous_->footnoteflag == 
                 LyXParagraph::CLOSED_FOOTNOTE)
                || tmppar->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE))
-               tmppar = tmppar->previous;
+               tmppar = tmppar->previous_;
    
        if (!tmppar)
                return this;  // This should never happen!
@@ -1631,8 +1627,10 @@ int LyXParagraph::StripLeadingSpaces(LyXTextClassList::size_type tclass)
        int i = 0;
 #ifndef NEW_INSETS
        if (!IsDummy()) {
-#endif
                while (Last()
+#else
+               while (size()
+#endif
                       && (IsNewline(0) || IsLineSeparator(0))){
                        Erase(0);
                        ++i;
@@ -1682,33 +1680,13 @@ bool LyXParagraph::HasSameLayout(LyXParagraph const * par) const
        par = par->FirstPhysicalPar();
 #endif
 
-       return (
+       return 
 #ifndef NEW_INSETS
                par->footnoteflag == footnoteflag &&
                par->footnotekind == footnotekind &&
 #endif
                par->layout == layout &&
-
-               par->align == align &&
-
-               par->line_bottom == line_bottom &&
-               par->pagebreak_bottom == pagebreak_bottom &&
-               par->added_space_bottom == added_space_bottom &&
-
-               par->line_top == line_top &&
-               par->pagebreak_top == pagebreak_top &&
-               par->added_space_top == added_space_top &&
-
-               par->spacing == spacing &&
-               
-                par->pextra_type == pextra_type &&
-                par->pextra_width == pextra_width && 
-                par->pextra_widthp == pextra_widthp && 
-                par->pextra_alignment == pextra_alignment && 
-                par->pextra_hfill == pextra_hfill && 
-                par->pextra_start_minipage == pextra_start_minipage && 
-               par->noindent == noindent &&
-               par->depth == depth);
+               params.sameLayout(par->params);
 }
 
 
@@ -1754,7 +1732,7 @@ void LyXParagraph::BreakParagraphConservative(BufferParams const & bparams,
 
        // When can pos > Last()?
        // I guess pos == Last() is possible.
-       if (Last() > pos) {
+       if (size() > pos) {
                // copy everything behind the break-position to the new
                // paragraph
                size_type pos_end = text.size() - 1;
@@ -1783,24 +1761,25 @@ void LyXParagraph::BreakParagraphConservative(BufferParams const & bparams,
 void LyXParagraph::PasteParagraph(BufferParams const & bparams)
 {
        // copy the next paragraph to this one
-       LyXParagraph * the_next = Next();
-#ifndef NEW_INSETS   
-       LyXParagraph * firstpar = FirstPhysicalPar();
-#endif
+       LyXParagraph * the_next = next();
    
        // first the DTP-stuff
 #ifndef NEW_INSETS
-       firstpar->line_bottom = the_next->line_bottom;
-       firstpar->added_space_bottom = the_next->added_space_bottom;
-       firstpar->pagebreak_bottom = the_next->pagebreak_bottom;
-#else
-       line_bottom = the_next->line_bottom;
-       added_space_bottom = the_next->added_space_bottom;
-       pagebreak_bottom = the_next->pagebreak_bottom;
-#endif
+       LyXParagraph * firstpar = FirstPhysicalPar();
+       firstpar->params.lineBottom(the_next->params.lineBottom());
+       firstpar->params.spaceBottom(the_next->params.spaceBottom());
+       firstpar->params.pagebreakBottom(the_next->params.pagebreakBottom());
 
        size_type pos_end = the_next->text.size() - 1;
        size_type pos_insert = Last();
+#else
+       params.lineBottom(the_next->params.lineBottom());
+       params.spaceBottom(the_next->params.spaceBottom());
+       params.pagebreakBottom(the_next->params.pagebreakBottom());
+
+       size_type pos_end = the_next->text.size() - 1;
+       size_type pos_insert = size();
+#endif
 
        // ok, now copy the paragraph
        size_type i, j;
@@ -1811,10 +1790,10 @@ void LyXParagraph::PasteParagraph(BufferParams const & bparams)
        }
    
        // delete the next paragraph
-       LyXParagraph * ppar = the_next->previous;
-       LyXParagraph * npar = the_next->next;
+       LyXParagraph * ppar = the_next->previous_;
+       LyXParagraph * npar = the_next->next_;
        delete the_next;
-       ppar->next = npar;
+       ppar->next(npar);
 }
 
 
@@ -1822,10 +1801,10 @@ void LyXParagraph::PasteParagraph(BufferParams const & bparams)
 void LyXParagraph::OpenFootnote(LyXParagraph::size_type pos)
 {
        LyXParagraph * par = ParFromPos(pos);
-       par = par->next;
+       par = par->next_;
        while (par && par->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) {
                par->footnoteflag = LyXParagraph::OPEN_FOOTNOTE;
-               par = par->next;
+               par = par->next_;
        }
 }
 
@@ -1833,10 +1812,10 @@ void LyXParagraph::OpenFootnote(LyXParagraph::size_type pos)
 void LyXParagraph::CloseFootnote(LyXParagraph::size_type pos)
 {
        LyXParagraph * par = ParFromPos(pos);
-       par = par->next;
+       par = par->next_;
        while (par && par->footnoteflag == LyXParagraph::OPEN_FOOTNOTE) {
                par->footnoteflag = LyXParagraph::CLOSED_FOOTNOTE;
-               par = par->next;
+               par = par->next_;
        }
 }
 #endif
@@ -1856,18 +1835,18 @@ int LyXParagraph::GetEndLabel(BufferParams const & bparams) const
 #ifndef NEW_INSETS
                        if (footnoteflag == NO_FOOTNOTE)
                                last = LastPhysicalPar();
-                       else if (next->footnoteflag == NO_FOOTNOTE)
+                       else if (next_->footnoteflag == NO_FOOTNOTE)
                                return endlabeltype;
 #else
                        last = this;
 #endif
 
-                       if (!last || !last->next)
+                       if (!last || !last->next_)
                                return endlabeltype;
 
-                       int next_depth = last->next->GetDepth();
+                       int next_depth = last->next_->GetDepth();
                        if (par_depth > next_depth ||
-                           (par_depth == next_depth && layout != last->next->GetLayout() ))
+                           (par_depth == next_depth && layout != last->next_->GetLayout() ))
                                return endlabeltype;
                        break;
                }
@@ -1894,9 +1873,9 @@ LyXTextClass::size_type LyXParagraph::GetLayout() const
 char LyXParagraph::GetDepth() const
 {
 #ifndef NEW_INSETS
-       return FirstPhysicalPar()->depth;
+       return FirstPhysicalPar()->params.depth();
 #else
-       return depth;
+       return params.depth();
 #endif
 }
 
@@ -1904,9 +1883,9 @@ char LyXParagraph::GetDepth() const
 char LyXParagraph::GetAlign() const
 {
 #ifndef NEW_INSETS
-       return FirstPhysicalPar()->align;
+       return FirstPhysicalPar()->params.align();
 #else
-       return align;
+       return params.align();
 #endif
 }
 
@@ -1914,9 +1893,9 @@ char LyXParagraph::GetAlign() const
 string const & LyXParagraph::GetLabelstring() const
 {
 #ifndef NEW_INSETS
-       return FirstPhysicalPar()->labelstring;
+       return FirstPhysicalPar()->params.labelString();
 #else
-       return labelstring;
+       return params.labelString();
 #endif
 }
 
@@ -1935,11 +1914,11 @@ int LyXParagraph::GetFirstCounter(int i) const
 string const LyXParagraph::GetLabelWidthString() const
 {
 #ifndef NEW_INSETS
-       if (!FirstPhysicalPar()->labelwidthstring.empty())
-               return FirstPhysicalPar()->labelwidthstring;
+       if (!FirstPhysicalPar()->params.labelWidthString().empty())
+               return FirstPhysicalPar()->params.labelWidthString();
 #else
-       if (!labelwidthstring.empty())
-               return labelwidthstring;
+       if (!params.labelWidthString().empty())
+               return params.labelWidthString();
 #endif
        else
                return _("Senseless with this layout!");
@@ -1951,9 +1930,9 @@ void LyXParagraph::SetLabelWidthString(string const & s)
 #ifndef NEW_INSETS
        LyXParagraph * par = FirstPhysicalPar();
 
-       par->labelwidthstring = s;
+       par->params.labelWidthString(s);
 #else
-       labelwidthstring = s;
+       params.labelWidthString(s);
 #endif
 }
 
@@ -1971,52 +1950,56 @@ void LyXParagraph::SetOnlyLayout(BufferParams const & bparams,
 
        par->layout = new_layout;
 
-        if (par->pextra_type == PEXTRA_NONE) {
-                if (par->Previous()) {
+#ifndef NO_PEXTRA
+        if (par->params.pextraType() == PEXTRA_NONE) {
+#endif
+                if (par->previous()) {
 #ifndef NEW_INSETS
-                        ppar = par->Previous()->FirstPhysicalPar();
+                        ppar = par->previous()->FirstPhysicalPar();
 #else
-                       ppar = par->Previous();
+                       ppar = par->previous();
 #endif
                         while(ppar
-                             && ppar->Previous()
-                             && (ppar->depth > par->depth))
+                             && ppar->previous()
+                             && (ppar->params.depth() > par->params.depth()))
 #ifndef NEW_INSETS
-                                ppar = ppar->Previous()->FirstPhysicalPar();
+                                ppar = ppar->previous()->FirstPhysicalPar();
 #else
-                       ppar = ppar->Previous();
+                       ppar = ppar->previous();
 #endif
                 }
-                if (par->Next()) {
+                if (par->next()) {
 #ifndef NEW_INSETS
-                        npar = par->Next()->NextAfterFootnote();
+                        npar = par->next()->NextAfterFootnote();
 #else
-                       npar = par->Next();
+                       npar = par->next();
 #endif
                         while(npar
-                             && npar->Next()
-                             && (npar->depth > par->depth))
+                             && npar->next()
+                             && (npar->params.depth() > par->params.depth()))
 #ifndef NEW_INSETS
-                                npar = npar->Next()->NextAfterFootnote();
+                                npar = npar->next()->NextAfterFootnote();
 #else
-                       npar = npar->Next();
+                       npar = npar->next();
 #endif
                 }
-                if (ppar && (ppar->pextra_type != PEXTRA_NONE)) {
-                        string
-                                p1 = ppar->pextra_width,
-                                p2 = ppar->pextra_widthp;
-                        ppar->SetPExtraType(bparams, ppar->pextra_type,
+#ifndef NO_PEXTRA
+                if (ppar && (ppar->params.pextraType() != PEXTRA_NONE)) {
+                        string p1 = ppar->params.pextraWidth();
+                       string p2 = ppar->params.pextraWidthp();
+                        ppar->SetPExtraType(bparams,
+                                           ppar->params.pextraType(),
                                             p1, p2);
                 }
-                if ((par->pextra_type == PEXTRA_NONE) &&
-                    npar && (npar->pextra_type != PEXTRA_NONE)) {
-                        string const p1 = npar->pextra_width;
-                       string const p2 = npar->pextra_widthp;
-                        npar->SetPExtraType(bparams, npar->pextra_type,
+                if ((par->params.pextraType() == PEXTRA_NONE) &&
+                    npar && (npar->params.pextraType() != PEXTRA_NONE)) {
+                        string const p1 = npar->params.pextraWidth();
+                       string const p2 = npar->params.pextraWidthp();
+                        npar->SetPExtraType(bparams, npar->params.pextraType(),
                                             p1, p2);
                 }
         }
+#endif
 }
 
 
@@ -2033,57 +2016,61 @@ void LyXParagraph::SetLayout(BufferParams const & bparams,
                * npar = 0;
 
         par->layout = new_layout;
-       par->labelwidthstring.erase();
-       par->align = LYX_ALIGN_LAYOUT;
-       par->added_space_top = VSpace(VSpace::NONE);
-       par->added_space_bottom = VSpace(VSpace::NONE);
-       par->spacing.set(Spacing::Default);
-
-        if (par->pextra_type == PEXTRA_NONE) {
-                if (par->Previous()) {
+       par->params.labelWidthString(string());
+       par->params.align(LYX_ALIGN_LAYOUT);
+       par->params.spaceTop(VSpace(VSpace::NONE));
+       par->params.spaceBottom(VSpace(VSpace::NONE));
+       par->params.spacing(Spacing(Spacing::Default));
+
+#ifndef NO_PEXTRA
+        if (par->params.pextraType() == PEXTRA_NONE) {
+#endif
+                if (par->previous()) {
 #ifndef NEW_INSETS
-                        ppar = par->Previous()->FirstPhysicalPar();
+                        ppar = par->previous()->FirstPhysicalPar();
 #else
-                       ppar = par->Previous();
+                       ppar = par->previous();
 #endif
                         while(ppar
-                             && ppar->Previous()
-                             && (ppar->depth > par->depth))
+                             && ppar->previous()
+                             && (ppar->params.depth() > par->params.depth()))
 #ifndef NEW_INSETS
-                                ppar = ppar->Previous()->FirstPhysicalPar();
+                                ppar = ppar->previous()->FirstPhysicalPar();
 #else
-                       ppar = ppar->Previous();
+                       ppar = ppar->previous();
 #endif
                 }
-                if (par->Next()) {
+                if (par->next()) {
 #ifndef NEW_INSETS
-                        npar = par->Next()->NextAfterFootnote();
+                        npar = par->next()->NextAfterFootnote();
 #else
-                       npar = par->Next();
+                       npar = par->next();
 #endif
                         while(npar
-                             && npar->Next()
-                             && (npar->depth > par->depth))
+                             && npar->next()
+                             && (npar->params.depth() > par->params.depth()))
 #ifndef NEW_INSETS
-                                npar = npar->Next()->NextAfterFootnote();
+                                npar = npar->next()->NextAfterFootnote();
 #else
-                       npar = npar->Next();
+                       npar = npar->next();
 #endif
                 }
-                if (ppar && (ppar->pextra_type != PEXTRA_NONE)) {
-                        string const p1 = ppar->pextra_width;
-                       string const p2 = ppar->pextra_widthp;
-                        ppar->SetPExtraType(bparams, ppar->pextra_type,
+#ifndef NO_PEXTRA
+                if (ppar && (ppar->params.pextraType() != PEXTRA_NONE)) {
+                        string const p1 = ppar->params.pextraWidth();
+                       string const p2 = ppar->params.pextraWidthp();
+                        ppar->SetPExtraType(bparams, ppar->params.pextraType(),
                                             p1, p2);
                 }
-                if ((par->pextra_type == PEXTRA_NONE) &&
-                    npar && (npar->pextra_type != PEXTRA_NONE)) {
-                        string const p1 = npar->pextra_width;
-                       string const p2 = npar->pextra_widthp;
-                        npar->SetPExtraType(bparams, npar->pextra_type,
+                if ((par->params.pextraType() == PEXTRA_NONE) &&
+                    npar && (npar->params.pextraType() != PEXTRA_NONE)) {
+                        string const p1 = npar->params.pextraWidth();
+                       string const p2 = npar->params.pextraWidthp();
+                        npar->SetPExtraType(bparams, npar->params.pextraType(),
                                             p1, p2);
                 }
         }
+#endif
 }
 
 
@@ -2126,7 +2113,7 @@ int LyXParagraph::BeginningOfMainBody() const
 #ifndef NEW_INSETS
        if (i == 0 && i == size() &&
            !(footnoteflag == LyXParagraph::NO_FOOTNOTE
-             && next && next->footnoteflag != LyXParagraph::NO_FOOTNOTE))
+             && next_ && next_->footnoteflag != LyXParagraph::NO_FOOTNOTE))
                ++i;                           /* the cursor should not jump  
                                                * to the main body if there
                                                * is nothing in! */
@@ -2143,9 +2130,9 @@ LyXParagraph * LyXParagraph::DepthHook(int deth)
    
        do {
 #ifndef NEW_INSETS
-               newpar = newpar->FirstPhysicalPar()->Previous();
+               newpar = newpar->FirstPhysicalPar()->previous();
 #else
-               newpar = newpar->Previous();
+               newpar = newpar->previous();
 #endif
        } while (newpar && newpar->GetDepth() > deth
 #ifndef NEW_INSETS
@@ -2154,7 +2141,7 @@ LyXParagraph * LyXParagraph::DepthHook(int deth)
                );
    
        if (!newpar) {
-               if (Previous() || GetDepth())
+               if (previous() || GetDepth())
                        lyxerr << "ERROR (LyXParagraph::DepthHook): "
                                "no hook." << endl;
                newpar = this;
@@ -2175,9 +2162,9 @@ LyXParagraph const * LyXParagraph::DepthHook(int deth) const
    
        do {
 #ifndef NEW_INSETS
-               newpar = newpar->FirstPhysicalPar()->Previous();
+               newpar = newpar->FirstPhysicalPar()->previous();
 #else
-               newpar = newpar->Previous();
+               newpar = newpar->previous();
 #endif
        } while (newpar && newpar->GetDepth() > deth
 #ifndef NEW_INSETS
@@ -2186,7 +2173,7 @@ LyXParagraph const * LyXParagraph::DepthHook(int deth) const
                );
    
        if (!newpar) {
-               if (Previous() || GetDepth())
+               if (previous() || GetDepth())
                        lyxerr << "ERROR (LyXParagraph::DepthHook): "
                                "no hook." << endl;
                newpar = this;
@@ -2243,7 +2230,7 @@ int LyXParagraph::GetPositionOfInset(Inset * inset) const
 #ifndef NEW_INSETS
        // Think about footnotes.
        if (footnoteflag == LyXParagraph::NO_FOOTNOTE 
-           && next && next->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) {
+           && next_ && next_->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) {
                int const further = 
                        NextAfterFootnote()->GetPositionOfInset(inset);
                if (further != -1)
@@ -2277,14 +2264,14 @@ LyXParagraph * LyXParagraph::TeXOnePar(Buffer const * buf,
                lyxerr << "ERROR (LyXParagraph::TeXOnePar) is dummy." << endl;
 #endif
 
-       if (start_of_appendix) {
+       if (params.startOfAppendix()) {
                os << "\\appendix\n";
                texrow.newline();
        }
 
-       if (!spacing.isDefault()
-           && (!Previous() || !Previous()->HasSameLayout(this))) {
-               os << spacing.writeEnvirBegin() << "\n";
+       if (!params.spacing().isDefault()
+           && (!previous() || !previous()->HasSameLayout(this))) {
+               os << params.spacing().writeEnvirBegin() << "\n";
                texrow.newline();
        }
        
@@ -2293,16 +2280,16 @@ LyXParagraph * LyXParagraph::TeXOnePar(Buffer const * buf,
                texrow.newline();
        }
 
-       if (pagebreak_top) {
+       if (params.pagebreakTop()) {
                os << "\\newpage";
                further_blank_line = true;
        }
-       if (added_space_top.kind() != VSpace::NONE) {
-               os << added_space_top.asLatexCommand(bparams);
+       if (params.spaceTop().kind() != VSpace::NONE) {
+               os << params.spaceTop().asLatexCommand(bparams);
                further_blank_line = true;
        }
       
-       if (line_top) {
+       if (params.lineTop()) {
                os << "\\lyxline{\\" << getFont(bparams, 0).latexSize() << '}'
                   << "\\vspace{-1\\parskip}";
                further_blank_line = true;
@@ -2315,8 +2302,8 @@ LyXParagraph * LyXParagraph::TeXOnePar(Buffer const * buf,
 
        Language const * language = getParLanguage(bparams);
        Language const * doc_language = bparams.language;
-       Language const * previous_language = previous
-               ? previous->getParLanguage(bparams) : doc_language;
+       Language const * previous_language = previous_
+               ? previous_->getParLanguage(bparams) : doc_language;
        if (language->babel() != doc_language->babel() &&
            language->babel() != previous_language->babel()) {
                os << subst(lyxrc.language_command_begin, "$$lang",
@@ -2354,12 +2341,12 @@ LyXParagraph * LyXParagraph::TeXOnePar(Buffer const * buf,
 
        bool need_par = SimpleTeXOnePar(buf, bparams, os, texrow, moving_arg);
  
-       LyXParagraph * par = next;
+       LyXParagraph * par = next_;
 #ifndef NEW_INSETS
        // Spit out footnotes
        if (lyxrc.rtl_support) {
-               if (next && next->footnoteflag != LyXParagraph::NO_FOOTNOTE
-                   && next->footnoteflag != footnoteflag) {
+               if (next_ && next_->footnoteflag != LyXParagraph::NO_FOOTNOTE
+                   && next_->footnoteflag != footnoteflag) {
                        LyXParagraph * p = 0;
                        bool is_rtl = (size() > 0) 
                                ? GetFontSettings(bparams,
@@ -2381,13 +2368,13 @@ LyXParagraph * LyXParagraph::TeXOnePar(Buffer const * buf,
                                        ? par->GetFontSettings(bparams,
                                                               par->size()-1).isRightToLeft()
                                        : language->RightToLeft();
-                               if (par->next &&
-                                   par->next->footnoteflag != LyXParagraph::NO_FOOTNOTE &&
+                               if (par->next_ &&
+                                   par->next_->footnoteflag != LyXParagraph::NO_FOOTNOTE &&
                                    (p = par->NextAfterFootnote()) != 0 &&
                                    p->size() > 0 &&
                                    p->GetFontSettings(bparams, 0).isRightToLeft() != is_rtl)
                                        is_rtl = language->RightToLeft();
-                               par = par->next;
+                               par = par->next_;
                        }
                }
        } else {
@@ -2398,7 +2385,7 @@ LyXParagraph * LyXParagraph::TeXOnePar(Buffer const * buf,
                                               foot, foot_texrow, foot_count,
                                               false);
                        par->SimpleTeXOnePar(buf, bparams, os, texrow, moving_arg);
-                       par = par->next;
+                       par = par->next_;
                }
        }
 #endif
@@ -2412,10 +2399,14 @@ LyXParagraph * LyXParagraph::TeXOnePar(Buffer const * buf,
        // Is this really needed ? (Dekel)
        // We do not need to use to change the font for the last paragraph
        // or for a command.
+#ifndef NEW_INSETS
        LyXFont font = getFont(bparams, Last() - 1);
+#else
+       LyXFont font = getFont(bparams, size() - 1);
+#endif
        bool is_command = textclasslist.Style(bparams.textclass,
                                              GetLayout()).isCommand();
-       if (style.resfont.size() != font.size() && next && !is_command) {
+       if (style.resfont.size() != font.size() && next_ && !is_command) {
                if (!need_par)
                        os << "{";
                os << "\\" << font.latexSize() << " \\par}";
@@ -2438,7 +2429,7 @@ LyXParagraph * LyXParagraph::TeXOnePar(Buffer const * buf,
        switch (style.latextype) {
        case LATEX_ITEM_ENVIRONMENT:
        case LATEX_LIST_ENVIRONMENT:
-                if (par && (depth < par->depth)) {
+                if (par && (params.depth() < par->params.depth())) {
                         os << '\n';
                         texrow.newline();
                 }
@@ -2448,15 +2439,18 @@ LyXParagraph * LyXParagraph::TeXOnePar(Buffer const * buf,
                // skip it otherwise fall through
                if (par
                    && (par->layout != layout
-                       || par->depth != depth
-                       || par->pextra_type != pextra_type))
+                       || par->params.depth() != params.depth()
+#ifndef NO_PEXTRA
+                       || par->params.pextraType() != params.pextraType()
+#endif
+                           ))
                        break;
        default:
                // we don't need it for the last paragraph!!!
                // or for tables in floats
                //   -- effectively creates a \par where there isn't one which
                //      breaks a \subfigure or \subtable.
-               if (next) {
+               if (next_) {
 //                 && footnoteflag == LyXParagraph::NO_FOOTNOTE) {
                        os << '\n';
                        texrow.newline();
@@ -2464,17 +2458,23 @@ LyXParagraph * LyXParagraph::TeXOnePar(Buffer const * buf,
        }
        
        further_blank_line = false;
-       if (line_bottom) {
-               os << "\\lyxline{\\" << getFont(bparams, Last() - 1).latexSize() << '}';
+       if (params.lineBottom()) {
+#ifndef NEW_INSETS
+               os << "\\lyxline{\\" << getFont(bparams,
+                                               Last() - 1).latexSize() << '}';
+#else
+               os << "\\lyxline{\\" << getFont(bparams,
+                                               size() - 1).latexSize() << '}';
+#endif
                further_blank_line = true;
        }
 
-       if (added_space_bottom.kind() != VSpace::NONE) {
-               os << added_space_bottom.asLatexCommand(bparams);
+       if (params.spaceBottom().kind() != VSpace::NONE) {
+               os << params.spaceBottom().asLatexCommand(bparams);
                further_blank_line = true;
        }
       
-       if (pagebreak_bottom) {
+       if (params.pagebreakBottom()) {
                os << "\\newpage";
                further_blank_line = true;
        }
@@ -2484,14 +2484,14 @@ LyXParagraph * LyXParagraph::TeXOnePar(Buffer const * buf,
                texrow.newline();
        }
 
-       if (!spacing.isDefault()
+       if (!params.spacing().isDefault()
            && (!par || !par->HasSameLayout(this))) {
-               os << spacing.writeEnvirEnd() << "\n";
+               os << params.spacing().writeEnvirEnd() << "\n";
                texrow.newline();
        }
        
        // we don't need it for the last paragraph!!!
-       if (next
+       if (next_
 #ifndef NEW_INSETS
            && !(footnoteflag != LyXParagraph::NO_FOOTNOTE && par &&
               par->footnoteflag == LyXParagraph::NO_FOOTNOTE)
@@ -2546,7 +2546,7 @@ bool LyXParagraph::SimpleTeXOnePar(Buffer const * buf,
                if (style.isCommand()) {
                        os << '{';
                        ++column;
-               } else if (align != LYX_ALIGN_LAYOUT) {
+               } else if (params.align() != LYX_ALIGN_LAYOUT) {
                        os << '{';
                        ++column;
                        return_value = true;
@@ -2583,7 +2583,7 @@ bool LyXParagraph::SimpleTeXOnePar(Buffer const * buf,
                        if (style.isCommand()) {
                                os << '{';
                                ++column;
-                       } else if (align != LYX_ALIGN_LAYOUT && next) {
+                       } else if (params.align() != LYX_ALIGN_LAYOUT && next_) {
                                // We do not need \par here (Dekel)
                                // os << "{\\par";
                                os << "{";
@@ -2591,11 +2591,11 @@ bool LyXParagraph::SimpleTeXOnePar(Buffer const * buf,
                                return_value = true;
                        }
 
-                       if (noindent) {
+                       if (params.noindent()) {
                                os << "\\noindent ";
                                column += 10;
                        }
-                       switch (align) {
+                       switch (params.align()) {
                        case LYX_ALIGN_NONE:
                        case LYX_ALIGN_BLOCK:
                        case LYX_ALIGN_LAYOUT:
@@ -2639,8 +2639,8 @@ bool LyXParagraph::SimpleTeXOnePar(Buffer const * buf,
 #ifndef NEW_INSETS
                LyXParagraph * p = 0;
                if (i == 0
-                   && previous && 
-                   previous->footnoteflag != LyXParagraph::NO_FOOTNOTE &&
+                   && previous_ && 
+                   previous_->footnoteflag != LyXParagraph::NO_FOOTNOTE &&
                    (p = PreviousBeforeFootnote()) != 0)
                        last_font = p->getFont(bparams, p->size() - 1);
                else
@@ -2717,12 +2717,12 @@ bool LyXParagraph::SimpleTeXOnePar(Buffer const * buf,
        // If we have an open font definition, we have to close it
        if (open_font) {
                LyXParagraph * p = 0;
-               if (next
+               if (next_
 #ifndef NEW_INSETS
-                   && next->footnoteflag != LyXParagraph::NO_FOOTNOTE
+                   && next_->footnoteflag != LyXParagraph::NO_FOOTNOTE
                    && (p =  NextAfterFootnote()) != 0
 #else
-                       && (p = next)
+                       && (p = next_)
 #endif
                )
                        running_font.latexWriteEndChanges(os, basefont,
@@ -2870,6 +2870,7 @@ void LyXParagraph::SimpleTeXSpecialChars(Buffer const * buf,
                if (inset) {
                        bool close = false;
                        int const len = os.tellp();
+                       //ostream::pos_type const len = os.tellp();
                        if ((inset->LyxCode() == Inset::GRAPHICS_CODE
                             || inset->LyxCode() == Inset::MATH_CODE
                             || inset->LyxCode() == Inset::URL_CODE)
@@ -2887,7 +2888,7 @@ void LyXParagraph::SimpleTeXSpecialChars(Buffer const * buf,
                        if (tmp) {
                                column = 0;
                        } else {
-                               column += os.tellp() - len;
+                               column += int(os.tellp()) - len;
                        }
                        for (; tmp--;) {
                                texrow.newline();
@@ -3124,7 +3125,7 @@ LyXParagraph * LyXParagraph::TeXDeeper(Buffer const * buf,
        LyXParagraph * par = this;
 
        while (par &&
-              (par->depth == depth)
+              (par->params.depth() == params.depth())
 #ifndef NEW_INSETS
               && (par->footnoteflag == footnoteflag)
 #endif
@@ -3135,7 +3136,10 @@ LyXParagraph * LyXParagraph::TeXDeeper(Buffer const * buf,
 #endif
                if (textclasslist.Style(bparams.textclass, 
                                        par->layout).isEnvironment()
-                   || par->pextra_type != PEXTRA_NONE) {
+#ifndef NO_PEXTRA
+                   || par->params.pextraType() != PEXTRA_NONE
+#endif
+                       ) {
                        par = par->TeXEnvironment(buf, bparams,
                                                  os, texrow
 #ifndef NEW_INSETS
@@ -3170,14 +3174,18 @@ LyXParagraph * LyXParagraph::TeXEnvironment(Buffer const * buf,
 #endif
        )
 {
+#ifndef NO_PEXTRA
        bool eindent_open = false;
+#endif
 #ifndef NEW_INSETS
        bool foot_this_level = false;
 #endif
+#ifndef NO_PEXTRA
        // flags when footnotetext should be appended to file.
         static bool minipage_open = false;
         static int minipage_open_depth = 0;
        char par_sep = bparams.paragraph_separation;
+#endif
     
        lyxerr[Debug::LATEX] << "TeXEnvironment...     " << this << endl;
 #ifndef NEW_INSETS
@@ -3188,37 +3196,38 @@ LyXParagraph * LyXParagraph::TeXEnvironment(Buffer const * buf,
        LyXLayout const & style =
                textclasslist.Style(bparams.textclass,
                                    layout);
-       
-       if (pextra_type == PEXTRA_INDENT) {
-               if (!pextra_width.empty()) {
+
+#ifndef NO_PEXTRA
+       if (params.pextraType() == PEXTRA_INDENT) {
+               if (!params.pextraWidth().empty()) {
                        os << "\\begin{LyXParagraphIndent}{"
-                          << pextra_width << "}\n";
+                          << params.pextraWidth() << "}\n";
                } else {
                        //float ib = atof(pextra_widthp.c_str())/100;
                        // string can't handle floats at present (971109)
                        // so I'll do a conversion by hand knowing that
                        // the limits are 0.0 to 1.0. ARRae.
                        os << "\\begin{LyXParagraphIndent}{";
-                       switch (pextra_widthp.length()) {
+                       switch (params.pextraWidthp().length()) {
                        case 3:
                                os << "1.00";
                                break;
                        case 2:
                                os << "0."
-                                  << pextra_widthp;
+                                  << params.pextraWidthp();
                                break;
                        case 1:
                                os << "0.0"
-                                  << pextra_widthp;
+                                  << params.pextraWidthp();
                        }
                        os << "\\columnwidth}\n";
                }
                texrow.newline();
                eindent_open = true;
        }
-       if ((pextra_type == PEXTRA_MINIPAGE) && !minipage_open) {
-               if (pextra_hfill && Previous() &&
-                   (Previous()->pextra_type == PEXTRA_MINIPAGE)) {
+       if ((params.pextraType() == PEXTRA_MINIPAGE) && !minipage_open) {
+               if (params.pextraHfill() && previous() &&
+                   (previous()->params.pextraType() == PEXTRA_MINIPAGE)) {
                        os << "\\hfill{}\n";
                        texrow.newline();
                }
@@ -3227,7 +3236,7 @@ LyXParagraph * LyXParagraph::TeXEnvironment(Buffer const * buf,
                        texrow.newline();
                }
                os << "\\begin{minipage}";
-               switch (pextra_alignment) {
+               switch (params.pextraAlignment()) {
                case MINIPAGE_ALIGN_TOP:
                        os << "[t]";
                        break;
@@ -3238,25 +3247,25 @@ LyXParagraph * LyXParagraph::TeXEnvironment(Buffer const * buf,
                        os << "[b]";
                        break;
                }
-               if (!pextra_width.empty()) {
-                       os << '{' << pextra_width << "}\n";
+               if (!params.pextraWidth().empty()) {
+                       os << '{' << params.pextraWidth() << "}\n";
                } else {
                        //float ib = atof(par->pextra_width.c_str())/100;
                        // string can't handle floats at present
                        // so I'll do a conversion by hand knowing that
                        // the limits are 0.0 to 1.0. ARRae.
                        os << '{';
-                       switch (pextra_widthp.length()) {
+                       switch (params.pextraWidthp().length()) {
                        case 3:
                                os << "1.00";
                                break;
                        case 2:
                                os << "0."
-                                  << pextra_widthp;
+                                  << params.pextraWidthp();
                                break;
                        case 1:
                                os << "0.0"
-                                  << pextra_widthp;
+                                  << params.pextraWidthp();
                        }
                        os << "\\columnwidth}\n";
                }
@@ -3266,9 +3275,9 @@ LyXParagraph * LyXParagraph::TeXEnvironment(Buffer const * buf,
                        texrow.newline();
                }
                minipage_open = true;
-                minipage_open_depth = depth;
+                minipage_open_depth = params.depth();
        }
-
+#endif
 #ifdef WITH_WARNINGS
 #warning Define FANCY_FOOTNOTE_CODE to re-enable Allan footnote code
        //I disabled it because it breaks when lists span on several
@@ -3285,7 +3294,7 @@ LyXParagraph * LyXParagraph::TeXEnvironment(Buffer const * buf,
                        }
 #endif
                        os << "\\begin{" << style.latexname() << "}{"
-                          << labelwidthstring << "}\n";
+                          << params.labelWidthString() << "}\n";
                } else if (style.labeltype == LABEL_BIBLIO) {
                        // ale970405
                        os << "\\begin{" << style.latexname() << "}{"
@@ -3316,10 +3325,10 @@ LyXParagraph * LyXParagraph::TeXEnvironment(Buffer const * buf,
                                     foot, foot_texrow, foot_count
 #endif
                        );
-
+#ifndef NO_PEXTRA
                 if (minipage_open && par && !style.isEnvironment() &&
-                    (par->pextra_type == PEXTRA_MINIPAGE) &&
-                    par->pextra_start_minipage) {
+                    (par->params.pextraType() == PEXTRA_MINIPAGE) &&
+                    par->params.pextraStartMinipage()) {
                        os << "\\end{minipage}\n";
                        texrow.newline();
                        if (par_sep == BufferParams::PARSEP_INDENT) {
@@ -3328,7 +3337,8 @@ LyXParagraph * LyXParagraph::TeXEnvironment(Buffer const * buf,
                        }
                        minipage_open = false;
                 }
-               if (par && par->depth > depth) {
+#endif
+               if (par && par->params.depth() > params.depth()) {
                        if (textclasslist.Style(bparams.textclass,
                                                par->layout).isParagraph()
                            // Thinko!
@@ -3354,10 +3364,11 @@ LyXParagraph * LyXParagraph::TeXEnvironment(Buffer const * buf,
 #endif
                                );
                }
-               if (par && par->layout == layout && par->depth == depth &&
-                   (par->pextra_type == PEXTRA_MINIPAGE) && !minipage_open) {
-                       if (par->pextra_hfill && par->Previous() &&
-                           (par->Previous()->pextra_type == PEXTRA_MINIPAGE)){
+#ifndef NO_PEXTRA
+               if (par && par->layout == layout && par->params.depth() == params.depth() &&
+                   (par->params.pextraType() == PEXTRA_MINIPAGE) && !minipage_open) {
+                       if (par->params.pextraHfill() && par->previous() &&
+                           (par->previous()->params.pextraType() == PEXTRA_MINIPAGE)){
                                os << "\\hfill{}\n";
                                 texrow.newline();
                         }
@@ -3366,7 +3377,7 @@ LyXParagraph * LyXParagraph::TeXEnvironment(Buffer const * buf,
                                texrow.newline();
                        }
                        os << "\\begin{minipage}";
-                       switch (par->pextra_alignment) {
+                       switch (par->params.pextraAlignment()) {
                        case MINIPAGE_ALIGN_TOP:
                                os << "[t]";
                                break;
@@ -3377,23 +3388,23 @@ LyXParagraph * LyXParagraph::TeXEnvironment(Buffer const * buf,
                                os << "[b]";
                                break;
                        }
-                       if (!par->pextra_width.empty()) {
-                               os << '{' << par->pextra_width << "}\n";
+                       if (!par->params.pextraWidth().empty()) {
+                               os << '{' << par->params.pextraWidth() << "}\n";
                        } else {
                                //float ib = atof(par->pextra_widthp.c_str())/100;
                                // string can't handle floats at present
                                // so I'll do a conversion by hand knowing that
                                // the limits are 0.0 to 1.0. ARRae.
                                os << '{';
-                               switch (par->pextra_widthp.length()) {
+                               switch (par->params.pextraWidthp().length()) {
                                case 3:
                                        os << "1.00";
                                        break;
                                case 2:
-                                       os << "0." << par->pextra_widthp;
+                                       os << "0." << par->params.pextraWidthp();
                                        break;
                                case 1:
-                                       os << "0.0" << par->pextra_widthp;
+                                       os << "0.0" << par->params.pextraWidthp();
                                }
                                os << "\\columnwidth}\n";
                        }
@@ -3403,19 +3414,23 @@ LyXParagraph * LyXParagraph::TeXEnvironment(Buffer const * buf,
                                texrow.newline();
                        }
                        minipage_open = true;
-                        minipage_open_depth = par->depth;
+                        minipage_open_depth = par->params.depth();
                }
+#endif
        } while (par
                 && par->layout == layout
-                && par->depth == depth
-                && par->pextra_type == pextra_type
+                && par->params.depth() == params.depth()
+#ifndef NO_PEXTRA
+                && par->params.pextraType() == params.pextraType()
+#endif
 #ifndef NEW_INSETS
                 && par->footnoteflag == footnoteflag
 #endif
                );
  
        if (style.isEnvironment()) {
-               os << "\\end{" << style.latexname() << '}';
+               os << "\\end{" << style.latexname() << "}\n";
+
 #ifndef NEW_INSETS
                // maybe this should go after the minipage closes?
                if (foot_this_level) {
@@ -3434,16 +3449,17 @@ LyXParagraph * LyXParagraph::TeXEnvironment(Buffer const * buf,
                }
 #endif
        }
-        if (minipage_open && (minipage_open_depth == depth) &&
-            (!par || par->pextra_start_minipage ||
-             par->pextra_type != PEXTRA_MINIPAGE)) {
+#ifndef NO_PEXTRA
+        if (minipage_open && (minipage_open_depth == params.depth()) &&
+            (!par || par->params.pextraStartMinipage() ||
+             par->params.pextraType() != PEXTRA_MINIPAGE)) {
                 os << "\\end{minipage}\n";
                texrow.newline();
                 if (par_sep == BufferParams::PARSEP_INDENT) {
                         os << "}\n";
                        texrow.newline();
                 }
-                if (par && par->pextra_type != PEXTRA_MINIPAGE) {
+                if (par && par->params.pextraType() != PEXTRA_MINIPAGE) {
                         os << "\\medskip\n\n";
                        texrow.newline();
                        texrow.newline();
@@ -3454,11 +3470,12 @@ LyXParagraph * LyXParagraph::TeXEnvironment(Buffer const * buf,
                os << "\\end{LyXParagraphIndent}\n";
                texrow.newline();
        }
-        if (!(par && (par->pextra_type == PEXTRA_MINIPAGE) 
-             && par->pextra_hfill)) {
+        if (!(par && (par->params.pextraType() == PEXTRA_MINIPAGE) 
+             && par->params.pextraHfill())) {
                 os << '\n';
                texrow.newline();
        }
+#endif
        lyxerr[Debug::LATEX] << "TeXEnvironment...done " << par << endl;
        return par;  // ale970302
 }
@@ -3480,7 +3497,7 @@ LyXParagraph * LyXParagraph::TeXFootnote(Buffer const * buf,
        LyXParagraph * par = this;
        LyXLayout const & style =
                textclasslist.Style(bparams.textclass, 
-                                   previous->GetLayout());
+                                   previous_->GetLayout());
        
        if (style.needprotect && footnotekind != LyXParagraph::FOOTNOTE){
                lyxerr << "ERROR (LyXParagraph::TeXFootnote): "
@@ -3550,15 +3567,15 @@ LyXParagraph * LyXParagraph::TeXFootnote(Buffer const * buf,
                os << "\\marginpar{\n";
                break;
        case LyXParagraph::FIG:
-               if (pextra_type == PEXTRA_FLOATFLT
-                   && (!pextra_width.empty()
-                       || !pextra_widthp.empty())) {
-                       if (!pextra_width.empty())
+               if (params.pextraType() == PEXTRA_FLOATFLT
+                   && (!params.pextraWidth().empty()
+                       || !params.pextraWidthp().empty())) {
+                       if (!params.pextraWidth().empty())
                                os << "\\begin{floatingfigure}{"
-                                  << pextra_width << "}\n";
+                                  << params.pextraWidth() << "}\n";
                        else
                                os << "\\begin{floatingfigure}{"
-                                  << lyx::atoi(pextra_widthp) / 100.0
+                                  << lyx::atoi(params.pextraWidthp()) / 100.0
                                   << "\\textwidth}\n";
                } else {
                        os << "\\begin{figure}";
@@ -3610,7 +3627,7 @@ LyXParagraph * LyXParagraph::TeXFootnote(Buffer const * buf,
                                lyxerr << "ERROR (LyXParagraph::TeXFootnote)"
                                       << endl;
                        if (style.isEnvironment()
-                           || par->pextra_type == PEXTRA_MINIPAGE) { /* && !minipage_open ?? */
+                           || par->params.pextraType() == PEXTRA_MINIPAGE) { /* && !minipage_open ?? */
                                // Allows the use of minipages within float
                                // environments. Shouldn't be circular because
                                // we don't support footnotes inside
@@ -3626,7 +3643,7 @@ LyXParagraph * LyXParagraph::TeXFootnote(Buffer const * buf,
                                                     foot_count);
                        }
                        
-                       if (par && !par->IsDummy() && par->depth > depth) {
+                       if (par && !par->IsDummy() && par->params.depth() > params.depth()) {
                                par = par->TeXDeeper(buf, bparams, os, texrow,
                                                     foot, foot_texrow,
                                                     foot_count);
@@ -3647,7 +3664,7 @@ LyXParagraph * LyXParagraph::TeXFootnote(Buffer const * buf,
                                lyxerr << "ERROR (LyXParagraph::TeXFootnote)"
                                       << endl;
                        if (style.isEnvironment()
-                           || par->pextra_type == PEXTRA_MINIPAGE) { /* && !minipage_open ?? */
+                           || par->params.pextraType() == PEXTRA_MINIPAGE) { /* && !minipage_open ?? */
                                // Allows the use of minipages within float
                                // environments. Shouldn't be circular because
                                // we don't support footnotes inside
@@ -3664,7 +3681,7 @@ LyXParagraph * LyXParagraph::TeXFootnote(Buffer const * buf,
                                                     dummy_count);
                        }
 
-                       if (par && !par->IsDummy() && par->depth > depth) {
+                       if (par && !par->IsDummy() && par->params.depth() > params.depth()) {
                                par = par->TeXDeeper(buf, bparams,
                                                     foot, foot_texrow,
                                                     dummy, dummy_texrow,
@@ -3694,9 +3711,9 @@ LyXParagraph * LyXParagraph::TeXFootnote(Buffer const * buf,
                os << '}';
                break;
        case LyXParagraph::FIG:
-               if (pextra_type == PEXTRA_FLOATFLT
-                   && (!pextra_width.empty()
-                       || !pextra_widthp.empty()))
+               if (params.pextraType() == PEXTRA_FLOATFLT
+                   && (!params.pextraWidth().empty()
+                       || !params.pextraWidthp().empty()))
                        os << "\\end{floatingfigure}";
                else
                        os << "\\end{figure}";
@@ -3727,25 +3744,26 @@ LyXParagraph * LyXParagraph::TeXFootnote(Buffer const * buf,
                texrow.newline();
        }
 
-       lyxerr[Debug::LATEX] << "TeXFootnote...done " << par->next << endl;
+       lyxerr[Debug::LATEX] << "TeXFootnote...done " << par->next_ << endl;
        return par;
 }
 
 
 bool LyXParagraph::IsDummy() const
 {
-       return (footnoteflag == LyXParagraph::NO_FOOTNOTE && previous
-               && previous->footnoteflag != LyXParagraph::NO_FOOTNOTE);
+       return (footnoteflag == LyXParagraph::NO_FOOTNOTE && previous_
+               && previous_->footnoteflag != LyXParagraph::NO_FOOTNOTE);
 }
 #endif
 
+#ifndef NO_PEXTRA
 void LyXParagraph::SetPExtraType(BufferParams const & bparams,
                                 int type, string const & width,
                                 string const & widthp)
 {
-       pextra_type = type;
-       pextra_width = width;
-       pextra_widthp = widthp;
+       params.pextraType(type);
+       params.pextraWidth(width);
+       params.pextraWidthp(widthp);
 
        if (textclasslist.Style(bparams.textclass, 
                                layout).isEnvironment()) {
@@ -3753,15 +3771,15 @@ void LyXParagraph::SetPExtraType(BufferParams const & bparams,
                LyXParagraph * ppar = par;
 
                while (par && (par->layout == layout)
-                      && (par->depth == depth)) {
+                      && (par->params.depth() == params.depth())) {
                        ppar = par;
-                       par = par->Previous();
+                       par = par->previous();
 #ifndef NEW_INSETS
                        if (par)
                                par = par->FirstPhysicalPar();
 #endif
-                       while (par && par->depth > depth) {
-                               par = par->Previous();
+                       while (par && par->params.depth() > params.depth()) {
+                               par = par->previous();
 #ifndef NEW_INSETS
                                if (par)
                                        par = par->FirstPhysicalPar();
@@ -3770,24 +3788,24 @@ void LyXParagraph::SetPExtraType(BufferParams const & bparams,
                }
                par = ppar;
                while (par && (par->layout == layout)
-                      && (par->depth == depth)) {
-                       par->pextra_type = type;
-                       par->pextra_width = width;
-                       par->pextra_widthp = widthp;
+                      && (par->params.depth() == params.depth())) {
+                       par->params.pextraType(type);
+                       par->params.pextraWidth(width);
+                       par->params.pextraWidthp(widthp);
 #ifndef NEW_INSETS
                        par = par->NextAfterFootnote();
 #else
-                       par = par->Next();
+                       par = par->next();
 #endif
-                       if (par && (par->depth > depth))
+                       if (par && (par->params.depth() > params.depth()))
                                par->SetPExtraType(bparams,
                                                   type, width, widthp);
 #ifndef NEW_INSETS
-                       while (par && ((par->depth > depth) || par->IsDummy()))
+                       while (par && ((par->params.depth() > params.depth()) || par->IsDummy()))
                                par = par->NextAfterFootnote();
 #else
-                       while (par && ((par->depth > depth)))
-                               par = par->Next();
+                       while (par && par->params.depth() > params.depth())
+                               par = par->next();
 #endif
                }
        }
@@ -3796,12 +3814,12 @@ void LyXParagraph::SetPExtraType(BufferParams const & bparams,
 
 void LyXParagraph::UnsetPExtraType(BufferParams const & bparams)
 {
-       if (pextra_type == PEXTRA_NONE)
+       if (params.pextraType() == PEXTRA_NONE)
                return;
     
-       pextra_type = PEXTRA_NONE;
-       pextra_width.erase();
-       pextra_widthp.erase();
+       params.pextraType(PEXTRA_NONE);
+       params.pextraWidth(string());
+       params.pextraWidthp(string());
 
        if (textclasslist.Style(bparams.textclass, 
                                layout).isEnvironment()) {
@@ -3809,15 +3827,15 @@ void LyXParagraph::UnsetPExtraType(BufferParams const & bparams)
                LyXParagraph * ppar = par;
 
                while (par && (par->layout == layout)
-                      && (par->depth == depth)) {
+                      && (par->params.depth() == params.depth())) {
                        ppar = par;
-                       par = par->Previous();
+                       par = par->previous();
 #ifndef NEW_INSETS
                        if (par)
                                par = par->FirstPhysicalPar();
 #endif
-                       while (par && par->depth > depth) {
-                               par = par->Previous();
+                       while (par && par->params.depth() > params.depth()) {
+                               par = par->previous();
 #ifndef NEW_INSETS
                                if (par)
                                        par = par->FirstPhysicalPar();
@@ -3826,27 +3844,28 @@ void LyXParagraph::UnsetPExtraType(BufferParams const & bparams)
                }
                par = ppar;
                while (par && (par->layout == layout)
-                      && (par->depth == depth)) {
-                       par->pextra_type = PEXTRA_NONE;
-                       par->pextra_width.erase();
-                       par->pextra_widthp.erase();
+                      && (par->params.depth() == params.depth())) {
+                       par->params.pextraType(PEXTRA_NONE);
+                       par->params.pextraWidth(string());
+                       par->params.pextraWidthp(string());
 #ifndef NEW_INSETS
                        par = par->NextAfterFootnote();
 #else
-                       par = par->Next();
+                       par = par->next();
 #endif
-                       if (par && (par->depth > depth))
+                       if (par && (par->params.depth() > params.depth()))
                                par->UnsetPExtraType(bparams);
 #ifndef NEW_INSETS
-                       while (par && ((par->depth > depth) || par->IsDummy()))
+                       while (par && ((par->params.depth() > params.depth()) || par->IsDummy()))
                                par = par->NextAfterFootnote();
 #else
-                       while (par && ((par->depth > depth)))
-                               par = par->Next();
+                       while (par && par->params.depth() > params.depth())
+                               par = par->next();
 #endif
                }
        }
 }
+#endif
 
 
 bool LyXParagraph::IsHfill(size_type pos) const
@@ -3925,8 +3944,8 @@ LyXParagraph::getParLanguage(BufferParams const & bparams) const
 #endif
        if (size() > 0)
                return GetFirstFontSettings().language();
-       else if (previous)
-               return previous->getParLanguage(bparams);
+       else if (previous_)
+               return previous_->getParLanguage(bparams);
        else
                return bparams.language;
 }
@@ -3957,7 +3976,7 @@ bool LyXParagraph::isMultiLingual(BufferParams const & bparams)
        Language const * doc_language = bparams.language;
        for (FontList::const_iterator cit = fontlist.begin();
             cit != fontlist.end(); ++cit)
-               if ((*cit).font.language() != doc_language)
+               if ((*cit).font().language() != doc_language)
                        return true;
        return false;
 }
@@ -3970,11 +3989,11 @@ string const LyXParagraph::String(Buffer const * buffer, bool label)
        BufferParams const & bparams = buffer->params;
        string s;
 #ifndef NEW_INSETS
-       if (label && !IsDummy() && !labelstring.empty())
+       if (label && !IsDummy() && !params.labelString().empty())
 #else
-       if (label && !labelstring.empty())
+       if (label && !params.labelString().empty())
 #endif
-               s += labelstring + ' ';
+               s += params.labelString() + ' ';
        string::size_type const len = s.size();
 
        for (LyXParagraph::size_type i = 0; i < size(); ++i) {
@@ -3990,7 +4009,7 @@ string const LyXParagraph::String(Buffer const * buffer, bool label)
        }
 
 #ifndef NEW_INSETS
-       if (next && next->footnoteflag != LyXParagraph::NO_FOOTNOTE 
+       if (next_ && next_->footnoteflag != LyXParagraph::NO_FOOTNOTE 
            && footnoteflag == LyXParagraph::NO_FOOTNOTE)
                s += NextAfterFootnote()->String(buffer, false);
 
@@ -4012,11 +4031,11 @@ string const LyXParagraph::String(Buffer const * buffer,
        string s;
 
 #ifndef NEW_INSETS
-       if (beg == 0 && !IsDummy() && !labelstring.empty())
+       if (beg == 0 && !IsDummy() && !params.labelString().empty())
 #else
-       if (beg == 0 && !labelstring.empty())
+       if (beg == 0 && !params.labelString().empty())
 #endif
-               s += labelstring + ' ';
+               s += params.labelString() + ' ';
 
        for (LyXParagraph::size_type i = beg; i < end; ++i) {
                value_type c = GetUChar(buffer->params, i);