#include "TextClass.h"
#include "LayoutFile.h"
+#include "CiteEnginesList.h"
#include "Color.h"
#include "Counters.h"
#include "Floating.h"
// You should also run the development/tools/updatelayouts.py script,
// to update the format of all of our layout files.
//
-int const LAYOUT_FORMAT = 59; //gm: OutlinerName, AddToToc, IsTocCaption
+int const LAYOUT_FORMAT = 62; //spitz PassThru for arguments.
+
+
+// Layout format for the current lyx file format. Controls which format is
+// targeted by Local Layout > Convert. In master, equal to LAYOUT_FORMAT.
+int const LYXFILE_LAYOUT_FORMAT = LAYOUT_FORMAT;
+
namespace {
};
-bool layout2layout(FileName const & filename, FileName const & tempfile)
+bool layout2layout(FileName const & filename, FileName const & tempfile,
+ int const format = LAYOUT_FORMAT)
{
FileName const script = libFileSearch("scripts", "layout2layout.py");
if (script.empty()) {
LYXERR0("Could not find layout conversion "
- "script layout2layout.py.");
+ "script layout2layout.py.");
return false;
}
ostringstream command;
command << os::python() << ' ' << quoteName(script.toFilesystemEncoding())
- << ' ' << quoteName(filename.toFilesystemEncoding())
- << ' ' << quoteName(tempfile.toFilesystemEncoding());
+ << " -t " << format
+ << ' ' << quoteName(filename.toFilesystemEncoding())
+ << ' ' << quoteName(tempfile.toFilesystemEncoding());
string const command_str = command.str();
LYXERR(Debug::TCLASS, "Running `" << command_str << '\'');
cmd_ret const ret = runCommand(command_str);
if (ret.first != 0) {
- LYXERR0("Could not run layout conversion script layout2layout.py.");
+ if (format == LAYOUT_FORMAT)
+ LYXERR0("Conversion of layout with layout2layout.py has failed.");
return false;
}
return true;
return "input file";
case TextClass::MODULE:
return "module file";
+ case TextClass::CITE_ENGINE:
+ return "cite engine";
case TextClass::VALIDATION:
return "validation";
}
docstring const TextClass::plain_layout_ = from_ascii(N_("Plain Layout"));
-InsetLayout DocumentClass::plain_insetlayout_;
-
-
/////////////////////////////////////////////////////////////////////////
//
// TextClass
os.close();
TempFile tmp2("convert_localXXXXXX.layout");
FileName const tempfile = tmp2.name();
- bool success = layout2layout(fn, tempfile);
+ bool success = layout2layout(fn, tempfile, LYXFILE_LAYOUT_FORMAT);
if (!success)
return "";
ifstream is(tempfile.toFilesystemEncoding().c_str());
os << str;
os.close();
- // now try to convert it
- bool const worx = convertLayoutFormat(tempfile, rt);
- if (!worx) {
+ // now try to convert it to LAYOUT_FORMAT
+ if (!convertLayoutFormat(tempfile, rt)) {
LYXERR0("Unable to convert internal layout information to format "
<< LAYOUT_FORMAT);
return ERROR;
}
+
return OK_OLDFORMAT;
}
// Either way, we just scan the rest and discard it
else {
Layout lay;
+ // false positive from coverity
+ // coverity[CHECKED_RETURN]
readStyle(lexrc, lay);
}
break;
break;
case TC_PREAMBLE:
- preamble_ = from_utf8(lexrc.getLongString("EndPreamble"));
+ preamble_ = lexrc.getLongString(from_ascii("EndPreamble"));
break;
case TC_HTMLPREAMBLE:
- htmlpreamble_ = from_utf8(lexrc.getLongString("EndPreamble"));
+ htmlpreamble_ = lexrc.getLongString(from_ascii("EndPreamble"));
break;
case TC_HTMLSTYLES:
- htmlstyles_ = from_utf8(lexrc.getLongString("EndStyles"));
+ htmlstyles_ = lexrc.getLongString(from_ascii("EndStyles"));
break;
case TC_HTMLTOCSECTION:
break;
case TC_ADDTOPREAMBLE:
- preamble_ += from_utf8(lexrc.getLongString("EndPreamble"));
+ preamble_ += lexrc.getLongString(from_ascii("EndPreamble"));
break;
case TC_ADDTOHTMLPREAMBLE:
- htmlpreamble_ += from_utf8(lexrc.getLongString("EndPreamble"));
+ htmlpreamble_ += lexrc.getLongString(from_ascii("EndPreamble"));
break;
case TC_ADDTOHTMLSTYLES:
- htmlstyles_ += from_utf8(lexrc.getLongString("EndStyles"));
+ htmlstyles_ += lexrc.getLongString(from_ascii("EndStyles"));
break;
case TC_PROVIDES: {
break;
case TC_DEFAULTBIBLIO:
- if (lexrc.next())
- cite_default_biblio_style_ = rtrim(lexrc.getString());
+ if (lexrc.next()) {
+ vector<string> const dbs =
+ getVectorFromString(rtrim(lexrc.getString()), "|");
+ vector<string>::const_iterator it = dbs.begin();
+ vector<string>::const_iterator end = dbs.end();
+ for (; it != end; ++it) {
+ if (!contains(*it, ':'))
+ cite_default_biblio_style_[opt_enginetype_] = *it;
+ else {
+ string eng;
+ string const db = split(*it, eng, ':');
+ cite_default_biblio_style_[eng] = db;
+ }
+ }
+ }
break;
case TC_FULLAUTHORLIST:
string ext;
string htmlattr;
- string htmlstyle;
+ docstring htmlstyle;
string htmltag;
string listname;
string listcommand;
break;
case FT_HTMLSTYLE:
lexrc.next();
- htmlstyle = lexrc.getLongString("EndHTMLStyle");
+ htmlstyle = lexrc.getLongString(from_ascii("EndHTMLStyle"));
break;
case FT_HTMLTAG:
lexrc.next();
n = n.substr(0, i);
}
// Layout "name" not found.
+ return plainInsetLayout();
+}
+
+
+InsetLayout const & DocumentClass::plainInsetLayout() {
+ static const InsetLayout plain_insetlayout_;
return plain_insetlayout_;
}
DocumentClassPtr getDocumentClass(
LayoutFile const & baseClass, LayoutModuleList const & modlist,
+ LayoutModuleList const & celist,
bool const clone)
{
DocumentClassPtr doc_class =
frontend::Alert::warning(_("Read Error"), msg);
}
}
+
+ LayoutModuleList::const_iterator cit = celist.begin();
+ LayoutModuleList::const_iterator cen = celist.end();
+ for (; cit != cen; ++cit) {
+ string const ceName = *cit;
+ LyXCiteEngine * ce = theCiteEnginesList[ceName];
+ if (!ce) {
+ docstring const msg =
+ bformat(_("The cite engine %1$s has been requested by\n"
+ "this document but has not been found in the list of\n"
+ "available engines. If you recently installed it, you\n"
+ "probably need to reconfigure LyX.\n"), from_utf8(ceName));
+ if (!clone)
+ frontend::Alert::warning(_("Cite Engine not available"), msg);
+ continue;
+ }
+ if (!ce->isAvailable() && !clone) {
+ docstring const prereqs = from_utf8(getStringFromVector(ce->prerequisites(), "\n\t"));
+ docstring const msg =
+ bformat(_("The cite engine %1$s requires a package that is not\n"
+ "available in your LaTeX installation, or a converter that\n"
+ "you have not installed. LaTeX output may not be possible.\n"
+ "Missing prerequisites:\n"
+ "\t%2$s\n"
+ "See section 3.1.2.3 (Modules) of the User's Guide for more information."),
+ from_utf8(ceName), prereqs);
+ frontend::Alert::warning(_("Package not available"), msg, true);
+ }
+ FileName layout_file = libFileSearch("citeengines", ce->getFilename());
+ if (!doc_class->read(layout_file, TextClass::CITE_ENGINE)) {
+ docstring const msg =
+ bformat(_("Error reading cite engine %1$s\n"), from_utf8(ceName));
+ frontend::Alert::warning(_("Read Error"), msg);
+ }
+ }
+
return doc_class;
}