#include "buffer.h"
#include "bufferlist.h"
-#include "counters.h"
#include "LyXAction.h"
#include "lyxrc.h"
#include "lyxlex.h"
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();
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
"Use LyX 0.10.x to read this!"));
return false;
} else {
- string const command = "lyx2lyx "
+ 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);
}
-// 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
}
}
+ 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());
}
}
}
-Counters & Buffer::counters() const
-{
- return *ctrs.get();
-}
-
-
void Buffer::inset_iterator::setParagraph()
{
while (pit != pend) {