]> git.lyx.org Git - lyx.git/blobdiff - src/buffer.C
last Friday's text*.C -> text_func shuffle
[lyx.git] / src / buffer.C
index 2b724aa8a2ff163450e7bb1ae4bb17d18e07dfc9..b51a4762d4dca385f285934cf225c262d53a1818 100644 (file)
@@ -11,6 +11,7 @@
 #include <config.h>
 
 #include "buffer.h"
+#include "buffer_funcs.h"
 #include "bufferlist.h"
 #include "LyXAction.h"
 #include "lyxrc.h"
@@ -85,6 +86,8 @@
 #include <locale>
 #endif
 
+using namespace lyx::support;
+
 #ifndef CXX_GLOBAL_CSTD
 using std::pow;
 #endif
@@ -273,6 +276,7 @@ int Buffer::readHeader(LyXLex & lex)
                lyxerr[Debug::PARSER] << "Handling header token: `"
                                      << token << '\'' << endl;
 
+
                string unknown = params.readToken(lex, token);
                if (!unknown.empty()) {
                        if (unknown[0] != '\\') {
@@ -280,10 +284,10 @@ int Buffer::readHeader(LyXLex & lex)
                        } else {
                                ++unknown_tokens;
                                string const s = bformat(_("Unknown token: "
-                                                          "%1$s %2$s\n"), 
-                                                        token, 
+                                                          "%1$s %2$s\n"),
+                                                        token,
                                                         lex.getString());
-                               parseError(ErrorItem(_("Header error"), s, 
+                               parseError(ErrorItem(_("Header error"), s,
                                                     -1, 0, 0));
                        }
                }
@@ -306,6 +310,7 @@ bool Buffer::readBody(LyXLex & lex, ParagraphList::iterator pit)
        bool the_end_read = false;
 
        if (paragraphs.empty()) {
+               readHeader(lex);
                if (!params.getLyXTextClass().load()) {
                        string theclass = params.getLyXTextClass().name();
                        Alert::error(_("Can't load document class"), bformat(
@@ -540,7 +545,7 @@ bool Buffer::readFile(LyXLex & lex, string const & filename,
                        // This code is reached if lyx2lyx failed (for
                        // some reason) to change the file format of
                        // the file.
-                       lyx::Assert(false);
+                       Assert(false);
                        return false;
                }
        }
@@ -624,7 +629,7 @@ bool Buffer::save() const
        } else {
                // Saving failed, so backup is not backup
                if (lyxrc.make_backup) {
-                       lyx::rename(s, fileName());
+                       rename(s, fileName());
                }
                return false;
        }
@@ -1116,7 +1121,7 @@ void Buffer::makeLinuxDocFile(string const & fname, bool nice, bool body_only)
                ofs << "<!doctype linuxdoc system";
 
                string preamble = params.preamble;
-               const string name = nice ? ChangeExtension(filename_, ".sgml")
+               string const name = nice ? ChangeExtension(filename_, ".sgml")
                         : fname;
                preamble += features.getIncludedFiles(name);
                preamble += features.getLyXSGMLEntities();
@@ -1144,8 +1149,6 @@ void Buffer::makeLinuxDocFile(string const & fname, bool nice, bool body_only)
        string item_name;
        vector<string> environment_stack(5);
 
-       users->resetErrorList();
-
        ParagraphList::iterator pit = paragraphs.begin();
        ParagraphList::iterator pend = paragraphs.end();
        for (; pit != pend; ++pit) {
@@ -1274,8 +1277,6 @@ void Buffer::makeLinuxDocFile(string const & fname, bool nice, bool body_only)
 
        // we want this to be true outside previews (for insetexternal)
        niceFile = true;
-
-       users->showErrorList(_("LinuxDoc"));
 }
 
 
@@ -1554,7 +1555,7 @@ void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body)
                    << "  PUBLIC \"-//OASIS//DTD DocBook V4.1//EN\"";
 
                string preamble = params.preamble;
-               const string name = nice ? ChangeExtension(filename_, ".sgml")
+               string const name = nice ? ChangeExtension(filename_, ".sgml")
                         : fname;
                preamble += features.getIncludedFiles(name);
                preamble += features.getLyXSGMLEntities();
@@ -1592,8 +1593,6 @@ void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body)
        string item_name;
        string command_name;
 
-       users->resetErrorList();
-
        ParagraphList::iterator par = paragraphs.begin();
        ParagraphList::iterator pend = paragraphs.end();
 
@@ -1650,7 +1649,7 @@ void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body)
                        sgmlparam = style->latexparam();
                        c_params = split(sgmlparam, c_depth,'|');
 
-                       cmd_depth = lyx::atoi(c_depth);
+                       cmd_depth = atoi(c_depth);
 
                        if (command_flag) {
                                if (cmd_depth < command_base) {
@@ -1809,7 +1808,6 @@ void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body)
 
        // we want this to be true outside previews (for insetexternal)
        niceFile = true;
-       users->showErrorList(_("DocBook"));
 }
 
 
@@ -1935,9 +1933,7 @@ int Buffer::runChktex()
                             _("Could not run chktex successfully."));
        } else if (res > 0) {
                // Insert all errors as errors boxes
-               ErrorList el (*this, terr);
-               users->setErrorList(el);
-               users->showErrorList(_("ChkTeX"));
+               parseErrors(*this, terr);
        }
 
        users->owner()->busy(false);
@@ -2014,7 +2010,7 @@ void Buffer::getLabelList(std::vector<string> & list) const
 
 
 // This is also a buffer property (ale)
-void Buffer::fillWithBibKeys(vector<pair<string, string> > & keys) const
+void Buffer::fillWithBibKeys(std::vector<std::pair<string, string> > & keys) const
 {
        /// if this is a child document and the parent is already loaded
        /// use the parent's list instead  [ale990412]