]> git.lyx.org Git - lyx.git/blobdiff - src/buffer.C
remove noload/don't typeset
[lyx.git] / src / buffer.C
index 44ac43836b6184d991c482282b9c53662ed14112..7538be4e6d7a6863ccca7c86a34aa0eac20e53ca 100644 (file)
@@ -20,7 +20,6 @@
 
 #include "buffer.h"
 #include "bufferlist.h"
-#include "counters.h"
 #include "LyXAction.h"
 #include "lyxrc.h"
 #include "lyxlex.h"
@@ -147,24 +146,17 @@ extern BufferList bufferlist;
 
 namespace {
 
-const int LYX_FORMAT = 220;
+const int LYX_FORMAT = 221;
 
 } // namespace anon
 
 Buffer::Buffer(string const & file, bool ronly)
        : niceFile(true), lyx_clean(true), bak_clean(true),
          unnamed(false), dep_clean(0), read_only(ronly),
-         filename_(file), users(0), ctrs(new Counters)
+         filename_(file), users(0)
 {
        lyxerr[Debug::INFO] << "Buffer::Buffer()" << endl;
-//     filename = file;
        filepath_ = OnlyPath(file);
-//     lyx_clean = true;
-//     bak_clean = true;
-//     dep_clean = 0;
-//     read_only = ronly;
-//     unnamed = false;
-//     users = 0;
        lyxvc.buffer(this);
        if (read_only || lyxrc.use_tempdir) {
                tmppath = CreateBufferTmpDir();
@@ -1161,13 +1153,14 @@ bool Buffer::readFile(LyXLex & lex, Paragraph * par)
                        if (dot != string::npos)
                                tmp_format.erase(dot, 1);
                        file_format = strToInt(tmp_format);
+                       //lyxerr << "format: " << file_format << endl;
                        if (file_format == LYX_FORMAT) {
                                // current format
                        } else if (file_format > LYX_FORMAT) {
                                // future format
                                Alert::alert(_("Warning!"),
-                                          _("LyX file format is newer that what"),
-                                          _("is supported in this LyX version. Expect some problems."));
+                                       _("The file was created with a newer version of"
+                                       "LyX. This is likely to cause problems."));
 
                        } else if (file_format < LYX_FORMAT) {
                                // old formats
@@ -1176,14 +1169,22 @@ bool Buffer::readFile(LyXLex & lex, Paragraph * par)
                                                   _("Old LyX file format found. "
                                                     "Use LyX 0.10.x to read this!"));
                                        return false;
-                               } else if (file_format < 220) {
-                                       string const command = "lyx2lyx "
+                               } else {
+                                       string command =
+                                               LibFileSearch("lyx2lyx", "lyx2lyx");
+                                       if (command.empty()) {
+                                               Alert::alert(_("ERROR!"),
+                                                            _("Can't find conversion script."));
+                                               return false;
+                                       }
+                                       command += " -t"
+                                               +tostr(LYX_FORMAT)+" "
                                                + QuoteName(filename_);
                                        cmd_ret const ret = RunCommand(command);
                                        if (ret.first) {
                                                Alert::alert(_("ERROR!"),
-                                                    _("An error occured while "
-                                                      "running the conversion script."));
+                                                            _("An error occured while "
+                                                              "running the conversion script."));
                                                return false;
                                        }
                                        istringstream is(ret.second);
@@ -3150,26 +3151,6 @@ void Buffer::validate(LaTeXFeatures & features) const
 }
 
 
-// This function should be in Buffer because it's a buffer's property (ale)
-string const Buffer::getIncludeonlyList(char delim)
-{
-       string lst;
-       for (inset_iterator it = inset_iterator_begin();
-           it != inset_iterator_end(); ++it) {
-               if (it->lyxCode() == Inset::INCLUDE_CODE) {
-                       InsetInclude & inc = static_cast<InsetInclude &>(*it);
-                       if (inc.isIncludeOnly()) {
-                               if (!lst.empty())
-                                       lst += delim;
-                               lst += inc.getRelFileBaseName();
-                       }
-               }
-       }
-       lyxerr[Debug::INFO] << "Includeonly(" << lst << ')' << endl;
-       return lst;
-}
-
-
 vector<string> const Buffer::getLabelList() const
 {
        /// if this is a child document and the parent is already loaded
@@ -3217,20 +3198,21 @@ vector<pair<string, string> > const Buffer::getBibkeyList() const
                }
        }
 
+       if (!keys.empty())
+               return keys;
+
        // Might be either using bibtex or a child has bibliography
-       if (keys.empty()) {
-               for (inset_iterator it = inset_const_iterator_begin();
-                       it != inset_const_iterator_end(); ++it) {
-                       // Search for Bibtex or Include inset
-                       if (it->lyxCode() == Inset::BIBTEX_CODE) {
-                               vector<StringPair> tmp =
-                                       static_cast<InsetBibtex &>(*it).getKeys(this);
-                               keys.insert(keys.end(), tmp.begin(), tmp.end());
-                       } else if (it->lyxCode() == Inset::INCLUDE_CODE) {
-                               vector<StringPair> const tmp =
-                                       static_cast<InsetInclude &>(*it).getKeys();
-                               keys.insert(keys.end(), tmp.begin(), tmp.end());
-                       }
+       for (inset_iterator it = inset_const_iterator_begin();
+               it != inset_const_iterator_end(); ++it) {
+               // Search for Bibtex or Include inset
+               if (it->lyxCode() == Inset::BIBTEX_CODE) {
+                       vector<StringPair> tmp =
+                               static_cast<InsetBibtex &>(*it).getKeys(this);
+                       keys.insert(keys.end(), tmp.begin(), tmp.end());
+               } else if (it->lyxCode() == Inset::INCLUDE_CODE) {
+                       vector<StringPair> const tmp =
+                               static_cast<InsetInclude &>(*it).getKeys();
+                       keys.insert(keys.end(), tmp.begin(), tmp.end());
                }
        }
 
@@ -3337,12 +3319,6 @@ bool Buffer::isMultiLingual()
 }
 
 
-Counters & Buffer::counters() const
-{
-       return *ctrs.get();
-}
-
-
 void Buffer::inset_iterator::setParagraph()
 {
        while (pit != pend) {