]> git.lyx.org Git - lyx.git/blobdiff - src/buffer.C
fix "make dist" target
[lyx.git] / src / buffer.C
index 5de92cfbcb2cb5d62b357fb849b8bacbaee409f0..b70fca7b6316e2449268764dc939c4c51b639386 100644 (file)
@@ -33,7 +33,7 @@
 #endif
 
 #ifdef __GNUG__
-#pragma implementation "buffer.h"
+#pragma implementation
 #endif
 
 #include "buffer.h"
 #include "insets/insettabular.h"
 #include "insets/insettheorem.h"
 #include "insets/insetcaption.h"
+#include "insets/insetfloatlist.h"
 #include "support/filetools.h"
 #include "support/path.h"
+#include "support/os.h"
 #include "LaTeX.h"
 #include "Chktex.h"
 #include "LyXView.h"
@@ -165,19 +167,11 @@ Buffer::~Buffer()
        
        LyXParagraph * par = paragraph;
        LyXParagraph * tmppar;
-#ifndef NEW_INSETS
-       while (par) {
-               tmppar = par->next_;
-               delete par;
-               par = tmppar;
-       }
-#else
        while (par) {
                tmppar = par->next();
                delete par;
                par = tmppar;
        }
-#endif
        paragraph = 0;
 }
 
@@ -294,10 +288,6 @@ bool Buffer::readLyXformat2(LyXLex & lex, LyXParagraph * par)
 {
        int pos = 0;
        char depth = 0; // signed or unsigned?
-#ifndef NEW_INSETS
-       LyXParagraph::footnote_flag footnoteflag = LyXParagraph::NO_FOOTNOTE;
-       LyXParagraph::footnote_kind footnotekind = LyXParagraph::FOOTNOTE;
-#endif
        bool the_end_read = false;
 
        LyXParagraph * return_par = 0;
@@ -341,10 +331,6 @@ bool Buffer::readLyXformat2(LyXLex & lex, LyXParagraph * par)
                        parseSingleLyXformat2Token(lex, par, return_par,
                                                   pretoken, pos, depth,
                                                   font
-#ifndef NEW_INSETS
-                                                  , footnoteflag,
-                                                  footnotekind
-#endif
                                );
        }
    
@@ -370,20 +356,14 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par,
                                   LyXParagraph *& return_par,
                                   string const & token, int & pos,
                                   char & depth, LyXFont & font
-#ifndef NEW_INSETS
-                                  , LyXParagraph::footnote_flag & footnoteflag,
-                                  LyXParagraph::footnote_kind & footnotekind
-#endif
        )
 {
        bool the_end_read = false;
 #ifndef NO_PEXTRA_REALLY
-#ifdef NEW_INSETS
        // This is super temporary but is needed to get the compability
        // mode for minipages work correctly together with new tabulars.
        static int call_depth = 0;
        ++call_depth;
-#endif
        bool checkminipage = false;
        static LyXParagraph * minipar = 0;
        static LyXParagraph * parBeforeMinipage = 0;
@@ -403,40 +383,6 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par,
                par->InsertInset(pos, inset, font);
                ++pos;
        } else if (token == "\\layout") {
-#ifndef NEW_INSETS
-               if (!return_par) 
-                       return_par = par;
-               else {
-                       par->fitToSize();
-                       par = new LyXParagraph(par);
-               }
-               pos = 0;
-               lex.EatLine();
-               string const layoutname = lex.GetString();
-               pair<bool, LyXTextClass::LayoutList::size_type> pp
-                       = textclasslist.NumberOfLayout(params.textclass,
-                                                      layoutname);
-               if (pp.first) {
-                       par->layout = pp.second;
-               } else { // layout not found
-                       // use default layout "Standard" (0)
-                       par->layout = 0;
-               }
-               // Test whether the layout is obsolete.
-               LyXLayout const & layout =
-                       textclasslist.Style(params.textclass,
-                                           par->layout); 
-               if (!layout.obsoleted_by().empty())
-                       par->layout = 
-                               textclasslist.NumberOfLayout(params.textclass, 
-                                                            layout.obsoleted_by()).second;
-               par->footnoteflag = footnoteflag;
-               par->footnotekind = footnotekind;
-               par->params.depth(depth);
-               font = LyXFont(LyXFont::ALL_INHERIT, params.language);
-               if (file_format < 216 && params.language->lang() == "hebrew")
-                       font.setLanguage(default_language);
-#else
                 lex.EatLine();
                 string const layoutname = lex.GetString();
                 pair<bool, LyXTextClass::LayoutList::size_type> pp
@@ -527,34 +473,7 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par,
 #if USE_CAPTION
                 }
 #endif
-#endif
-#ifndef NEW_INSETS
-       } else if (token == "\\end_float") {
-               if (!return_par) 
-                       return_par = par;
-               else {
-                       par->fitToSize();
-                       par = new LyXParagraph(par);
-               }
-               footnotekind = LyXParagraph::FOOTNOTE;
-               footnoteflag = LyXParagraph::NO_FOOTNOTE;
-               pos = 0;
-               lex.EatLine();
-               par->layout = LYX_DUMMY_LAYOUT;
-               font = LyXFont(LyXFont::ALL_INHERIT, params.language);
-               if (file_format < 216 && params.language->lang() == "hebrew")
-                       font.setLanguage(default_language);
-       } else if (token == "\\begin_float") {
-               int tmpret = lex.FindToken(string_footnotekinds);
-               if (tmpret == -1) ++tmpret;
-               if (tmpret != LYX_LAYOUT_DEFAULT) 
-                       footnotekind = static_cast<LyXParagraph::footnote_kind>(tmpret); // bad
-               if (footnotekind == LyXParagraph::FOOTNOTE
-                   || footnotekind == LyXParagraph::MARGIN)
-                       footnoteflag = LyXParagraph::CLOSED_FOOTNOTE;
-               else 
-                       footnoteflag = LyXParagraph::OPEN_FOOTNOTE;
-#else
+
        } else if (token == "\\begin_float") {
                // This is the compability reader. It can be removed in
                // LyX version 1.3.0. (Lgb)
@@ -628,7 +547,6 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par,
                inset->Read(this, nylex);
                par->InsertInset(pos, inset, font);
                ++pos;
-#endif
        } else if (token == "\\begin_deeper") {
                ++depth;
        } else if (token == "\\end_deeper") {
@@ -1265,40 +1183,44 @@ void Buffer::readInset(LyXLex & lex, LyXParagraph *& par,
                InsetCommandParams inscmd;
                inscmd.Read(lex);
 
-               if (inscmd.getCmdName() == "cite") {
+               string const cmdName = inscmd.getCmdName();
+               
+               if (cmdName == "cite") {
                        inset = new InsetCitation(inscmd);
-               } else if (inscmd.getCmdName() == "bibitem") {
+               } else if (cmdName == "bibitem") {
                        lex.printError("Wrong place for bibitem");
                        inset = new InsetBibKey(inscmd);
-               } else if (inscmd.getCmdName() == "BibTeX") {
+               } else if (cmdName == "BibTeX") {
                        inset = new InsetBibtex(inscmd);
-               } else if (inscmd.getCmdName() == "index") {
+               } else if (cmdName == "index") {
                        inset = new InsetIndex(inscmd);
-               } else if (inscmd.getCmdName() == "include") {
+               } else if (cmdName == "include") {
                        inset = new InsetInclude(inscmd, *this);
-               } else if (inscmd.getCmdName() == "label") {
+               } else if (cmdName == "label") {
                        inset = new InsetLabel(inscmd);
-               } else if (inscmd.getCmdName() == "url"
-                          || inscmd.getCmdName() == "htmlurl") {
+               } else if (cmdName == "url"
+                          || cmdName == "htmlurl") {
                        inset = new InsetUrl(inscmd);
-               } else if (inscmd.getCmdName() == "ref"
-                          || inscmd.getCmdName() == "pageref"
-                          || inscmd.getCmdName() == "vref"
-                          || inscmd.getCmdName() == "vpageref"
-                          || inscmd.getCmdName() == "prettyref") {
+               } else if (cmdName == "ref"
+                          || cmdName == "pageref"
+                          || cmdName == "vref"
+                          || cmdName == "vpageref"
+                          || cmdName == "prettyref") {
                        if (!inscmd.getOptions().empty()
                            || !inscmd.getContents().empty()) {
                                inset = new InsetRef(inscmd, *this);
                        }
-               } else if (inscmd.getCmdName() == "tableofcontents"
-                          || inscmd.getCmdName() == "listofalgorithms"
-                          || inscmd.getCmdName() == "listoffigures"
-                          || inscmd.getCmdName() == "listoftables"
-                          || inscmd.getCmdName() == "listof{algorithm}{List of Algorithms}") {
+               } else if (cmdName == "tableofcontents") {
                        inset = new InsetTOC(inscmd);
-               } else if (inscmd.getCmdName() == "printindex") {
+               } else if (cmdName == "listofalgorithms") {
+                       inset = new InsetFloatList("algorithm");
+               } else if (cmdName == "listoffigures") {
+                       inset = new InsetFloatList("figure");
+               } else if (cmdName == "listoftables") {
+                       inset = new InsetFloatList("table");
+               } else if (cmdName == "printindex") {
                        inset = new InsetPrintIndex(inscmd);
-               } else if (inscmd.getCmdName() == "lyxparent") {
+               } else if (cmdName == "lyxparent") {
                        inset = new InsetParent(inscmd, *this);
                }
        } else {
@@ -1341,6 +1263,8 @@ void Buffer::readInset(LyXLex & lex, LyXParagraph *& par,
                        inset = new InsetCaption;
                } else if (tmptok == "GRAPHICS") {
                        inset = new InsetGraphics;
+               } else if (tmptok == "FloatList") {
+                       inset = new InsetFloatList;
                }
                
                if (inset) inset->Read(this, lex);
@@ -1418,7 +1342,7 @@ bool Buffer::save() const
                s = fileName() + '~';
                if (!lyxrc.backupdir_path.empty())
                        s = AddName(lyxrc.backupdir_path,
-                                   subst(CleanupPath(s),'/','!'));
+                                   subst(os::slashify_path(s),'/','!'));
 
                // Rename is the wrong way of making a backup,
                // this is the correct way.
@@ -1541,12 +1465,11 @@ bool Buffer::writeFile(string const & fname, bool flag) const
        // now write out the buffer paramters.
        params.writeFile(ofs);
 
-       char footnoteflag = 0;
        char depth = 0;
 
        // this will write out all the paragraphs
        // using recursive descent.
-       paragraph->writeFile(this, ofs, params, footnoteflag, depth);
+       paragraph->writeFile(this, ofs, params, depth);
 
        // Write marker that shows file is complete
        ofs << "\n\\the_end" << endl;
@@ -1582,13 +1505,6 @@ string const Buffer::asciiParagraph(LyXParagraph const * par,
                                    unsigned int linelen) const
 {
        ostringstream buffer;
-       LyXFont font1;
-       LyXFont font2;
-       Inset const * inset;
-       char c;
-#ifndef NEW_INSETS
-       LyXParagraph::footnote_flag footnoteflag = LyXParagraph::NO_FOOTNOTE;
-#endif
        char depth = 0;
        int ltype = 0;
        int ltype_depth = 0;
@@ -1597,30 +1513,8 @@ string const Buffer::asciiParagraph(LyXParagraph const * par,
 
        int noparbreak = 0;
        int islatex = 0;
-#ifndef NEW_INSETS
-       if (par->footnoteflag != LyXParagraph::NO_FOOTNOTE ||
-           !par->previous_
-           || par->previous()->footnoteflag == LyXParagraph::NO_FOOTNOTE) {
-               /* begins a footnote environment ? */ 
-               if (footnoteflag != par->footnoteflag) {
-                       footnoteflag = par->footnoteflag;
-                       if (footnoteflag) {
-                               size_t const j = strlen(string_footnotekinds[par->footnotekind]) + 4;
-                               if ((linelen > 0) &&
-                                   ((currlinelen + j) > linelen)) {
-                                       buffer << "\n";
-                                       currlinelen = 0;
-                               }
-                               buffer << "(["
-                                      << string_footnotekinds[par->footnotekind]
-                                      << "] ";
-                               currlinelen += j;
-                       }
-               }
-#else
-               if (!par->previous()) {
-#endif
-               /* begins or ends a deeper area ?*/ 
+       if (!par->previous()) {
+               // begins or ends a deeper area ?
                if (depth != par->params.depth()) {
                        if (par->params.depth() > depth) {
                                while (par->params.depth() > depth) {
@@ -1633,7 +1527,7 @@ string const Buffer::asciiParagraph(LyXParagraph const * par,
                        }
                }
                
-               /* First write the layout */
+               // First write the layout
                string const tmp = textclasslist.NameOfLayout(params.textclass, par->layout);
                if (tmp == "Itemize") {
                        ltype = 1;
@@ -1673,40 +1567,29 @@ string const Buffer::asciiParagraph(LyXParagraph const * par,
                
                /* what about the alignment */ 
        } else {
-#ifndef NEW_INSETS
-               /* dummy layout, that means a footnote ended */ 
-               footnoteflag = LyXParagraph::NO_FOOTNOTE;
-               buffer << ") ";
-               noparbreak = 1;
-#else
                lyxerr << "Should this ever happen?" << endl;
-#endif
        }
       
-       font1 = LyXFont(LyXFont::ALL_INHERIT, params.language);
+       LyXFont const font1 = LyXFont(LyXFont::ALL_INHERIT, params.language);
        for (LyXParagraph::size_type i = 0; i < par->size(); ++i) {
-               if (!i &&
-#ifndef NEW_INSETS
-                   !footnoteflag &&
-#endif
-                   !noparbreak) {
+               if (!i && !noparbreak) {
                        if (linelen > 0)
                                buffer << "\n\n";
                        for (char j = 0; j < depth; ++j)
                                buffer << "  ";
                        currlinelen = depth * 2;
                        switch (ltype) {
-                       case 0: /* Standard */
-                       case 4: /* (Sub)Paragraph */
-                       case 5: /* Description */
+                       case 0: // Standard
+                       case 4: // (Sub)Paragraph
+                       case 5: // Description
                                break;
-                       case 6: /* Abstract */
+                       case 6: // Abstract
                                if (linelen > 0)
                                        buffer << "Abstract\n\n";
                                else
                                        buffer << "Abstract: ";
                                break;
-                       case 7: /* Bibliography */
+                       case 7: // Bibliography
                                if (!ref_printed) {
                                        if (linelen > 0)
                                                buffer << "References\n\n";
@@ -1725,7 +1608,7 @@ string const Buffer::asciiParagraph(LyXParagraph const * par,
                                currlinelen += (ltype_depth-depth)*2;
                        }
                }
-               font2 = par->GetFontSettings(params, i);
+               LyXFont const font2 = par->GetFontSettings(params, i);
                if (font1.latex() != font2.latex()) {
                        if (font2.latex() == LyXFont::OFF)
                                islatex = 0;
@@ -1734,23 +1617,29 @@ string const Buffer::asciiParagraph(LyXParagraph const * par,
                } else {
                        islatex = 0;
                }
-               c = par->GetUChar(params, i);
+               
+               char c = par->GetUChar(params, i);
                if (islatex)
                        continue;
                switch (c) {
                case LyXParagraph::META_INSET:
-                       if ((inset = par->GetInset(i))) {
+               {
+                       Inset const * inset = par->GetInset(i);
+                       if (inset) {
                                if (!inset->Ascii(this, buffer)) {
                                        string dummy;
-                                       string s = rsplit(buffer.str().c_str(),
-                                                         dummy, '\n');
+                                       string const s =
+                                               rsplit(buffer.str().c_str(),
+                                                      dummy, '\n');
                                        currlinelen += s.length();
                                } else {
                                        // to be sure it breaks paragraph
                                        currlinelen += linelen;
                                }
                        }
-                       break;
+               }
+               break;
+               
                case LyXParagraph::META_NEWLINE:
                        if (linelen > 0) {
                                buffer << "\n";
@@ -1765,12 +1654,15 @@ string const Buffer::asciiParagraph(LyXParagraph const * par,
                                currlinelen += (ltype_depth - depth) * 2;
                        }
                        break;
+                       
                case LyXParagraph::META_HFILL: 
                        buffer << "\t";
                        break;
+                       
                case '\\':
                        buffer << "\\";
                        break;
+                       
                default:
                        if ((linelen > 0) && (currlinelen > (linelen - 10)) &&
                            (c == ' ') && ((i + 2) < par->size()))
@@ -1878,7 +1770,7 @@ void Buffer::makeLaTeXFile(string const & fname,
                if (!original_path.empty()) {
                        ofs << "\\makeatletter\n"
                            << "\\def\\input@path{{"
-                           << original_path << "/}}\n"
+                           << os::external_path(original_path) << "/}}\n"
                            << "\\makeatother\n";
                        texrow.newline();
                        texrow.newline();
@@ -1887,13 +1779,12 @@ void Buffer::makeLaTeXFile(string const & fname,
                
                ofs << "\\documentclass";
                
-               string options; // the document class options.
+               ostringstream options; // the document class options.
                
                if (tokenPos(tclass.opt_fontsize(),
                             '|', params.fontsize) >= 0) {
                        // only write if existing in list (and not default)
-                       options += params.fontsize;
-                       options += "pt,";
+                       options << params.fontsize << "pt,";
                }
                
                
@@ -1901,22 +1792,22 @@ void Buffer::makeLaTeXFile(string const & fname,
                    (params.paperpackage == BufferParams::PACKAGE_NONE)) {
                        switch (params.papersize) {
                        case BufferParams::PAPER_A4PAPER:
-                               options += "a4paper,";
+                               options << "a4paper,";
                                break;
                        case BufferParams::PAPER_USLETTER:
-                               options += "letterpaper,";
+                               options << "letterpaper,";
                                break;
                        case BufferParams::PAPER_A5PAPER:
-                               options += "a5paper,";
+                               options << "a5paper,";
                                break;
                        case BufferParams::PAPER_B5PAPER:
-                               options += "b5paper,";
+                               options << "b5paper,";
                                break;
                        case BufferParams::PAPER_EXECUTIVEPAPER:
-                               options += "executivepaper,";
+                               options << "executivepaper,";
                                break;
                        case BufferParams::PAPER_LEGALPAPER:
-                               options += "legalpaper,";
+                               options << "legalpaper,";
                                break;
                        }
                }
@@ -1925,30 +1816,29 @@ void Buffer::makeLaTeXFile(string const & fname,
                if (params.sides != tclass.sides()) {
                        switch (params.sides) {
                        case LyXTextClass::OneSide:
-                               options += "oneside,";
+                               options << "oneside,";
                                break;
                        case LyXTextClass::TwoSides:
-                               options += "twoside,";
+                               options << "twoside,";
                                break;
                        }
-
                }
 
                // if needed
                if (params.columns != tclass.columns()) {
                        if (params.columns == 2)
-                               options += "twocolumn,";
+                               options << "twocolumn,";
                        else
-                               options += "onecolumn,";
+                               options << "onecolumn,";
                }
 
                if (!params.use_geometry 
                    && params.orientation == BufferParams::ORIENTATION_LANDSCAPE)
-                       options += "landscape,";
+                       options << "landscape,";
                
                // language should be a parameter to \documentclass
                use_babel = false;
-               string language_options;
+               ostringstream language_options;
                if (params.language->babel() == "hebrew"
                    && default_language->babel() != "hebrew")
                         // This seems necessary
@@ -1961,20 +1851,21 @@ void Buffer::makeLaTeXFile(string const & fname,
                        for (LaTeXFeatures::LanguageList::const_iterator cit =
                                     features.UsedLanguages.begin();
                             cit != features.UsedLanguages.end(); ++cit)
-                               language_options += (*cit)->babel() + ',';
-                       language_options += params.language->babel();
+                               language_options << (*cit)->babel() << ',';
+                       language_options << params.language->babel();
                        if (lyxrc.language_global_options)
-                               options += language_options + ',';
+                               options << language_options.str() << ',';
                }
 
                // the user-defined options
                if (!params.options.empty()) {
-                       options += params.options + ',';
+                       options << params.options << ',';
                }
-               
-               if (!options.empty()){
-                       options = strip(options, ',');
-                       ofs << '[' << options << ']';
+
+               string strOptions(options.str().c_str());
+               if (!strOptions.empty()){
+                       strOptions = strip(strOptions, ',');
+                       ofs << '[' << strOptions << ']';
                }
                
                ofs << '{'
@@ -2150,8 +2041,9 @@ void Buffer::makeLaTeXFile(string const & fname,
                        string tmp = lyxrc.language_package;
                        if (!lyxrc.language_global_options
                            && tmp == "\\usepackage{babel}")
-                               tmp = "\\usepackage[" +
-                                       language_options + "]{babel}";
+                               tmp = string("\\usepackage[") +
+                                       language_options.str().c_str() +
+                                       "]{babel}";
                        ofs << tmp << "\n";
                        texrow.newline();
                }
@@ -2332,17 +2224,9 @@ void Buffer::latexParagraphs(ostream & ofs, LyXParagraph * par,
 {
        bool was_title = false;
        bool already_title = false;
-       std::ostringstream ftnote;
-       TexRow ft_texrow;
-       int ftcount = 0;
 
        // if only_body
        while (par != endpar) {
-#ifndef NEW_INSETS
-               if (par->IsDummy())
-                       lyxerr[Debug::LATEX] << "Error in latexParagraphs."
-                                            << endl;
-#endif
                LyXLayout const & layout =
                        textclasslist.Style(params.textclass,
                                            par->layout);
@@ -2360,44 +2244,11 @@ void Buffer::latexParagraphs(ostream & ofs, LyXParagraph * par,
                        already_title = true;
                        was_title = false;                  
                }
-               // We are at depth 0 so we can just use
-               // ordinary \footnote{} generation
-               // flag this with ftcount
-               ftcount = -1;
-               if (layout.isEnvironment()
-#ifndef NEW_INSETS
-                    || par->params.pextraType() != LyXParagraph::PEXTRA_NONE
-#endif
-                       ) {
-                       par = par->TeXEnvironment(this, params, ofs, texrow
-#ifndef NEW_INSETS
-                                                 ,ftnote, ft_texrow, ftcount
-#endif
-                               );
+               
+               if (layout.isEnvironment()) {
+                       par = par->TeXEnvironment(this, params, ofs, texrow);
                } else {
-                       par = par->TeXOnePar(this, params, ofs, texrow, false
-#ifndef NEW_INSETS
-                                            ,
-                                            ftnote, ft_texrow, ftcount
-#endif
-                               );
-               }
-
-               // Write out what we've generated...
-               if (ftcount >= 1) {
-                       if (ftcount > 1) {
-                               ofs << "\\addtocounter{footnote}{-"
-                                   << ftcount - 1
-                                   << '}';
-                       }
-                       ofs << ftnote.str();
-                       texrow += ft_texrow;
-
-                       // The extra .c_str() is needed when we use
-                       // lyxstring instead of the STL string class. 
-                       ftnote.str(string().c_str());
-                       ft_texrow.reset();
-                       ftcount = 0;
+                       par = par->TeXOnePar(this, params, ofs, texrow, false);
                }
        }
        // It might be that we only have a title in this document
@@ -2518,12 +2369,7 @@ void Buffer::makeLinuxDocFile(string const & fname, bool nice, bool body_only)
                                string const temp = "toc";
                                sgmlOpenTag(ofs, depth, temp);
 
-#ifndef NEW_INSETS
-                               par = par->next_;
-                               linuxDocHandleFootnote(ofs, par, depth);
-#else
                                par = par->next();
-#endif
                                continue;
                        }
                }
@@ -2605,19 +2451,9 @@ void Buffer::makeLinuxDocFile(string const & fname, bool nice, bool body_only)
                        break;
                }
 
-#ifndef NEW_INSETS
-               do {
-                       SimpleLinuxDocOnePar(ofs, par, depth);
-                       
-                       par = par->next_;
-                       linuxDocHandleFootnote(ofs, par, depth);
-               }
-               while(par && par->IsDummy());
-#else
                SimpleLinuxDocOnePar(ofs, par, depth);
 
                par = par->next();
-#endif
 
                ofs << "\n";
                // write closing SGML tags
@@ -2649,39 +2485,16 @@ void Buffer::makeLinuxDocFile(string const & fname, bool nice, bool body_only)
 }
 
 
-#ifndef NEW_INSETS
-void Buffer::linuxDocHandleFootnote(ostream & os, LyXParagraph * & par,
-                                   int depth)
-{
-       string const tag = "footnote";
-
-       while (par && par->footnoteflag != LyXParagraph::NO_FOOTNOTE) {
-               sgmlOpenTag(os, depth + 1, tag);
-               SimpleLinuxDocOnePar(os, par, 0, depth + 1);
-               sgmlCloseTag(os, depth + 1, tag);
-               par = par->next_;
-       }
-}
-#endif
-
-
 void Buffer::DocBookHandleCaption(ostream & os, string & inner_tag,
                                  int depth, int desc_on,
                                  LyXParagraph * & par)
 {
        LyXParagraph * tpar = par;
-#ifndef NEW_INSETS
-       while (tpar
-              && (tpar->footnoteflag != LyXParagraph::NO_FOOTNOTE)
-              && (tpar->layout != textclasslist.NumberOfLayout(params.textclass,
-                                                            "Caption").second))
-               tpar = tpar->next_;
-#else
        while (tpar
               && (tpar->layout != textclasslist.NumberOfLayout(params.textclass,
                                                                "Caption").second))
                tpar = tpar->next();
-#endif
+
        if (tpar &&
            tpar->layout == textclasslist.NumberOfLayout(params.textclass,
                                                         "Caption").second) {
@@ -2696,106 +2509,6 @@ void Buffer::DocBookHandleCaption(ostream & os, string & inner_tag,
 }
 
 
-#ifndef NEW_INSETS
-void Buffer::DocBookHandleFootnote(ostream & os, LyXParagraph * & par,
-                                  int depth)
-{
-       string tag, inner_tag;
-       string tmp_par, extra_par;
-       bool inner_span = false;
-       int desc_on = 4;
-
-       // Someone should give this enum a proper name (Lgb)
-       enum SOME_ENUM {
-               NO_ONE,
-               FOOTNOTE_LIKE,
-               MARGIN_LIKE,
-               FIG_LIKE,
-               TAB_LIKE
-       };
-       SOME_ENUM last = NO_ONE;
-       SOME_ENUM present = FOOTNOTE_LIKE;
-
-       while (par && par->footnoteflag != LyXParagraph::NO_FOOTNOTE) {
-               if (last == present) {
-                       if (inner_span) {
-                               if (!tmp_par.empty()) {
-                                       os << tmp_par;
-                                       tmp_par.erase();
-                                       sgmlCloseTag(os, depth + 1, inner_tag);
-                                       sgmlOpenTag(os, depth + 1, inner_tag);
-                               }
-                       } else {
-                               os << "\n";
-                       }
-               } else {
-                       os << tmp_par;
-                       if (!inner_tag.empty()) sgmlCloseTag(os, depth + 1,
-                                                           inner_tag);
-                       if (!extra_par.empty()) os << extra_par;
-                       if (!tag.empty()) sgmlCloseTag(os, depth, tag);
-                       extra_par.erase();
-
-                       switch (par->footnotekind) {
-                       case LyXParagraph::FOOTNOTE:
-                       case LyXParagraph::ALGORITHM:
-                               tag = "footnote";
-                               inner_tag = "para";
-                               present = FOOTNOTE_LIKE;
-                               inner_span = true;
-                               break;
-                       case LyXParagraph::MARGIN:
-                               tag = "sidebar";
-                               inner_tag = "para";
-                               present = MARGIN_LIKE;
-                               inner_span = true;
-                               break;
-                       case LyXParagraph::FIG:
-                       case LyXParagraph::WIDE_FIG:
-                               tag = "figure";
-                               inner_tag = "title";
-                               present = FIG_LIKE;
-                               inner_span = false;
-                               break;
-                       case LyXParagraph::TAB:
-                       case LyXParagraph::WIDE_TAB:
-                               tag = "table";
-                               inner_tag = "title";
-                               present = TAB_LIKE;
-                               inner_span = false;
-                               break;
-                       }
-                       sgmlOpenTag(os, depth, tag);
-                       if ((present == TAB_LIKE) || (present == FIG_LIKE)) {
-                               DocBookHandleCaption(os, inner_tag, depth,
-                                                    desc_on, par);
-                               inner_tag.erase();
-                       } else {
-                               sgmlOpenTag(os, depth + 1, inner_tag);
-                       }
-               }
-               // ignore all caption here, we processed them above!!!
-               if (par->layout != textclasslist
-                   .NumberOfLayout(params.textclass,
-                                   "Caption").second) {
-                       std::ostringstream ost;
-                       SimpleDocBookOnePar(ost, extra_par, par,
-                                           desc_on, depth + 2);
-                       tmp_par += ost.str().c_str();
-               }
-               tmp_par = frontStrip(strip(tmp_par));
-
-               last = present;
-               par = par->next_;
-       }
-       os << tmp_par;
-       if (!inner_tag.empty()) sgmlCloseTag(os, depth + 1, inner_tag);
-       if (!extra_par.empty()) os << extra_par;
-       if (!tag.empty()) sgmlCloseTag(os, depth, tag);
-}
-#endif
-
-
 // checks, if newcol chars should be put into this line
 // writes newline, if necessary.
 namespace {
@@ -3289,21 +3002,11 @@ void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body)
                        break;
                }
 
-#ifndef NEW_INSETS
-               do {
-                       string extra_par;
-                       SimpleDocBookOnePar(ofs, extra_par, par, desc_on,
-                                           depth + 1 + command_depth);
-                       par = par->next_;
-                       DocBookHandleFootnote(ofs, par,
-                                             depth + 1 + command_depth);
-               } while(par && par->IsDummy());
-#else
                string extra_par;
                SimpleDocBookOnePar(ofs, extra_par, par, desc_on,
                                    depth + 1 + command_depth);
                par = par->next();
-#endif
+
                string end_tag;
                // write closing SGML tags
                switch (style.latextype) {
@@ -3536,11 +3239,7 @@ void Buffer::validate(LaTeXFeatures & features) const
                par->validate(features);
 
                // and then the next paragraph
-#ifndef NEW_INSETS
-               par = par->next_;
-#else
                par = par->next();
-#endif
        }
 
        // the bullet shapes are buffer level not paragraph level
@@ -3646,101 +3345,61 @@ Buffer::Lists const Buffer::getLists() const
 {
        Lists l;
        LyXParagraph * par = paragraph;
-#ifdef NEW_INSETS
        bool found;
        LyXTextClassList::size_type cap;
        boost::tie(found, cap) = textclasslist
                .NumberOfLayout(params.textclass, "Caption");
-#endif
 
        while (par) {
-#ifndef NEW_INSETS
-               if (par->footnoteflag != LyXParagraph::NO_FOOTNOTE) {
-                       if (textclasslist.Style(params.textclass, 
-                                               par->GetLayout()).labeltype
-                           == LABEL_SENSITIVE) {
-                               string type;
-                               switch (par->footnotekind) {
-                               case LyXParagraph::FIG:
-                               case LyXParagraph::WIDE_FIG:
-                                       type = "LOF";
-                                       break;
-                               case LyXParagraph::TAB:
-                               case LyXParagraph::WIDE_TAB:
-                                       type = "LOT";
-                                       break;
-                               case LyXParagraph::ALGORITHM:
-                                       type = "LOA";
-                                       break;
-                               case LyXParagraph::FOOTNOTE:
-                               case LyXParagraph::MARGIN:
-                                       break;
-                               }
-                               if (!type.empty()) {
-                                       SingleList & item = l[type];
-                                       string const str =
-                                               tostr(item.size()+1) + ". " + par->String(this, false);
-                                       item.push_back(TocItem(par, 0, str));
-                               }
-                       }
-               } else if (!par->IsDummy()) {
-#endif
-                       char const labeltype =
-                               textclasslist.Style(params.textclass, 
-                                                   par->GetLayout()).labeltype;
-      
-                       if (labeltype >= LABEL_COUNTER_CHAPTER
-                           && labeltype <= LABEL_COUNTER_CHAPTER + params.tocdepth) {
+               char const labeltype =
+                       textclasslist.Style(params.textclass, 
+                                           par->GetLayout()).labeltype;
+               
+               if (labeltype >= LABEL_COUNTER_CHAPTER
+                   && labeltype <= LABEL_COUNTER_CHAPTER + params.tocdepth) {
                                // insert this into the table of contents
-                               SingleList & item = l["TOC"];
-                               int depth = max(0,
-                                               labeltype - 
-                                               textclasslist.TextClass(params.textclass).maxcounter());
-                               item.push_back(TocItem(par, depth, par->String(this, true)));
-                       }
-#ifdef NEW_INSETS
-                       // For each paragrph, traverse its insets and look for
-                       // FLOAT_CODE
+                       SingleList & item = l["TOC"];
+                       int depth = max(0,
+                                       labeltype - 
+                                       textclasslist.TextClass(params.textclass).maxcounter());
+                       item.push_back(TocItem(par, depth, par->String(this, true)));
+               }
+               // For each paragrph, traverse its insets and look for
+               // FLOAT_CODE
+               
+               if (found) {
+                       LyXParagraph::inset_iterator it =
+                               par->inset_iterator_begin();
+                       LyXParagraph::inset_iterator end =
+                               par->inset_iterator_end();
                        
-                       if (found) {
-                               LyXParagraph::inset_iterator it =
-                                       par->inset_iterator_begin();
-                               LyXParagraph::inset_iterator end =
-                                       par->inset_iterator_end();
-
-                               for (; it != end; ++it) {
-                                       if ((*it)->LyxCode() == Inset::FLOAT_CODE) {
-                                               InsetFloat * il =
-                                                       static_cast<InsetFloat*>(*it);
-                                               
-                                               string const type = il->type();
-                                               
-                                               // Now find the caption in the float...
-                                               // We now tranverse the paragraphs of
-                                               // the inset...
-                                               LyXParagraph * tmp = il->inset.par;
-                                               while (tmp) {
-                                                       if (tmp->layout == cap) {
-                                                               SingleList & item = l[type];
-                                                               string const str =
-                                                                       tostr(item.size()+1) + ". " + tmp->String(this, false);
-                                                               item.push_back(TocItem(tmp, 0 , str));
-                                                       }
-                                                       tmp = tmp->next();
+                       for (; it != end; ++it) {
+                               if ((*it)->LyxCode() == Inset::FLOAT_CODE) {
+                                       InsetFloat * il =
+                                               static_cast<InsetFloat*>(*it);
+                                       
+                                       string const type = il->type();
+                                       
+                                       // Now find the caption in the float...
+                                       // We now tranverse the paragraphs of
+                                       // the inset...
+                                       LyXParagraph * tmp = il->inset.par;
+                                       while (tmp) {
+                                               if (tmp->layout == cap) {
+                                                       SingleList & item = l[type];
+                                                       string const str =
+                                                               tostr(item.size()+1) + ". " + tmp->String(this, false);
+                                                       item.push_back(TocItem(tmp, 0 , str));
                                                }
+                                               tmp = tmp->next();
                                        }
                                }
-                       } else {
-                               lyxerr << "caption not found" << endl;
                        }
-                       
-#endif
-#ifndef NEW_INSETS
+               } else {
+                       lyxerr << "caption not found" << endl;
                }
-               par = par->next_;
-#else
+               
                par = par->next();
-#endif
        }
        return l;
 }
@@ -3763,11 +3422,7 @@ vector<pair<string, string> > const Buffer::getBibkeyList()
                if (par->bibkey)
                        keys.push_back(pair<string, string>(par->bibkey->getContents(),
                                                           par->String(this, false)));
-#ifndef NEW_INSETS
-               par = par->next_;
-#else
                par = par->next();
-#endif
        }
 
        // Might be either using bibtex or a child has bibliography
@@ -3862,15 +3517,9 @@ void Buffer::resizeInsets(BufferView * bv)
 {
        /// then remove all LyXText in text-insets
        LyXParagraph * par = paragraph;
-#ifndef NEW_INSETS
-       for (; par; par = par->next_) {
-           par->resizeInsetsLyXText(bv);
-       }
-#else
        for (; par; par = par->next()) {
            par->resizeInsetsLyXText(bv);
        }
-#endif
 }
 
 
@@ -3880,11 +3529,7 @@ void Buffer::ChangeLanguage(Language const * from, Language const * to)
        LyXParagraph * par = paragraph;
        while (par) {
                par->ChangeLanguage(params, from, to);
-#ifndef NEW_INSETS
-               par = par->next_;
-#else
                par = par->next();
-#endif
        }
 }
 
@@ -3895,11 +3540,7 @@ bool Buffer::isMultiLingual()
        while (par) {
                if (par->isMultiLingual(params))
                        return true;
-#ifndef NEW_INSETS
-               par = par->next_;
-#else
                par = par->next();
-#endif
        }
        return false;
 }
@@ -3911,11 +3552,7 @@ Buffer::inset_iterator::inset_iterator(LyXParagraph * paragraph,
 {
        it = par->InsetIterator(pos);
        if (it == par->inset_iterator_end()) {
-#ifndef NEW_INSETS
-               par = par->next_;
-#else
                par = par->next();
-#endif
                SetParagraph();
        }
 }
@@ -3927,11 +3564,7 @@ void Buffer::inset_iterator::SetParagraph()
                it = par->inset_iterator_begin();
                if (it != par->inset_iterator_end())
                        return;
-#ifndef NEW_INSETS
-               par = par->next_;
-#else
                par = par->next();
-#endif
        }
        //it = 0;
        // We maintain an invariant that whenever par = 0 then it = 0