#include "encoding.h"
#include "exporter.h"
#include "Lsstream.h"
+#include "converter.h"
using std::ostream;
using std::ofstream;
using std::setw;
using std::endl;
using std::pair;
+using std::make_pair;
using std::vector;
using std::max;
using std::set;
extern LyXAction lyxaction;
-static const float LYX_FORMAT = 2.17;
+static const int LYX_FORMAT = 218;
extern int tex_code_break_column;
".tex");
}
+pair<Buffer::LogType, string> const Buffer::getLogName(void) const
+{
+ string filename, fname, bname, path;
+
+ filename = getLatexName(false);
+
+ if (filename.empty())
+ return make_pair(Buffer::latexlog, string());
+
+ path = OnlyPath(filename);
+
+ if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1))
+ path = tmppath;
+
+ fname = AddName(path, OnlyFilename(ChangeExtension(filename, ".log")));
+ bname = AddName(path, OnlyFilename(ChangeExtension(filename,
+ formats.Extension("literate") + ".out")));
+
+ // If no Latex log or Build log is newer, show Build log
+
+ FileInfo f_fi(fname), b_fi(bname);
+
+ if (b_fi.exist() &&
+ (!f_fi.exist() || f_fi.getModificationTime() < b_fi.getModificationTime())) {
+ lyxerr[Debug::FILES] << "Log name calculated as : " << bname << endl;
+ return make_pair(Buffer::buildlog, bname);
+ }
+ lyxerr[Debug::FILES] << "Log name calculated as : " << fname << endl;
+ return make_pair(Buffer::latexlog, fname);
+}
void Buffer::setReadonly(bool flag)
{
LyXParagraph * return_par = 0;
LyXFont font(LyXFont::ALL_INHERIT, params.language);
- if (format < 2.16 && params.language->lang() == "hebrew")
+ if (file_format < 216 && params.language->lang() == "hebrew")
font.setLanguage(default_language);
-
// If we are inserting, we cheat and get a token in advance
bool has_token = false;
string pretoken;
#endif
par->depth = depth;
font = LyXFont(LyXFont::ALL_INHERIT, params.language);
- if (format < 2.16 && params.language->lang() == "hebrew")
+ if (file_format < 216 && params.language->lang() == "hebrew")
font.setLanguage(default_language);
#ifndef NEW_INSETS
} else if (token == "\\end_float") {
lex.EatLine();
par->layout = LYX_DUMMY_LAYOUT;
font = LyXFont(LyXFont::ALL_INHERIT, params.language);
- if (format < 2.16 && params.language->lang() == "hebrew")
+ if (file_format < 216 && params.language->lang() == "hebrew")
font.setLanguage(default_language);
} else if (token == "\\begin_float") {
int tmpret = lex.FindToken(string_footnotekinds);
int tmpret = lex.FindToken(string_align);
if (tmpret == -1) ++tmpret;
if (tmpret != LYX_LAYOUT_DEFAULT) { // tmpret != 99 ???
-#if 0
- int tmpret2 = 1;
- for (; tmpret > 0; --tmpret)
- tmpret2 = tmpret2 * 2;
-#else
int const tmpret2 = int(pow(2.0, tmpret));
-#endif
//lyxerr << "Tmpret2 = " << tmpret2 << endl;
par->align = LyXAlignment(tmpret2);
}
++pos;
} else if (token == "\\bibitem") { // ale970302
if (!par->bibkey) {
- InsetCommandParams p( "bibitem" );
+ InsetCommandParams p("bibitem", "dummy");
par->bibkey = new InsetBibKey(p);
}
par->bibkey->Read(this, lex);
string const token(lex.GetString());
if (token == "\\lyxformat") { // the first token _must_ be...
lex.EatLine();
- format = lex.GetFloat();
- if (format > 1.0) {
- if (LYX_FORMAT - format > 0.05) {
- lyxerr << fmt(_("Warning: need lyxformat %.2f but found %.2f"),
- LYX_FORMAT, format) << endl;
- }
- if (format - LYX_FORMAT > 0.05) {
- lyxerr << fmt(_("ERROR: need lyxformat %.2f but found %.2f"),
- LYX_FORMAT, format) << endl;
+ string tmp_format = lex.GetString();
+ //lyxerr << "LyX Format: `" << tmp_format << "'" << endl;
+ // if present remove ".," from string.
+ string::size_type dot = tmp_format.find_first_of(".,");
+ //lyxerr << " dot found at " << dot << endl;
+ if (dot != string::npos)
+ tmp_format.erase(dot, 1);
+ file_format = strToInt(tmp_format);
+ if (file_format == LYX_FORMAT) {
+ // current format
+ } else if (file_format > LYX_FORMAT) {
+ // future format
+ WriteAlert(_("Warning!"),
+ _("LyX file format is newer that what"),
+ _("is supported in this LyX version. Expect some problems."));
+
+ } else if (file_format < LYX_FORMAT) {
+ // old formats
+ if (file_format < 200) {
+ WriteAlert(_("ERROR!"),
+ _("Old LyX file format found. "
+ "Use LyX 0.10.x to read this!"));
+ return false;
}
- bool the_end = readLyXformat2(lex, par);
- // Formats >= 2.13 support "\the_end" marker
- if (format < 2.13)
- the_end = true;
-
- setPaperStuff();
-
- if (!the_end)
- WriteAlert(_("Warning!"),
- _("Reading of document is not complete"),
- _("Maybe the document is truncated"));
- // We simulate a safe reading anyways to allow
- // users to take the chance... (Asger)
- return true;
- } // format < 1.0
- else {
- WriteAlert(_("ERROR!"),
- _("Old LyX file format found. "
- "Use LyX 0.10.x to read this!"));
- return false;
}
-
+ bool the_end = readLyXformat2(lex, par);
+ setPaperStuff();
+ // the_end was added in 213
+ if (file_format < 213)
+ the_end = true;
+
+ if (!the_end)
+ WriteAlert(_("Warning!"),
+ _("Reading of document is not complete"),
+ _("Maybe the document is truncated"));
+ return true;
} else { // "\\lyxformat" not found
WriteAlert(_("ERROR!"), _("Not a LyX file!"));
}
// write out a comment in the top of the file
ofs << '#' << LYX_DOCVERSION
- << " created this file. For more info see http://www.lyx.org/\n";
- ofs.setf(ios::showpoint|ios::fixed);
- ofs.precision(2);
-#ifndef HAVE_LOCALE
- char dummy_format[512];
- sprintf(dummy_format, "%.2f", LYX_FORMAT);
- ofs << "\\lyxformat " << dummy_format << "\n";
-#else
- ofs << "\\lyxformat " << setw(4) << LYX_FORMAT << "\n";
-#endif
+ << " created this file. For more info see http://www.lyx.org/\n"
+ << "\\lyxformat " << LYX_FORMAT << "\n";
+
// now write out the buffer paramters.
params.writeFile(ofs);
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;
font1 = LyXFont(LyXFont::ALL_INHERIT, params.language);
for (LyXParagraph::size_type i = 0; i < par->size(); ++i) {
- if (!i && !footnoteflag && !noparbreak){
+ if (!i &&
+#ifndef NEW_INSETS
+ !footnoteflag &&
+#endif
+ !noparbreak) {
if (linelen > 0)
buffer << "\n\n";
for (char j = 0; j < depth; ++j)
} else {
islatex = 0;
}
- c = par->GetChar(i);
+ c = par->GetUChar(params, i);
if (islatex)
continue;
switch (c) {
// language should be a parameter to \documentclass
bool use_babel = false;
- if (params.language->babel() == "hebrew") // This seems necessary
+ if (params.language->babel() == "hebrew"
+ && default_language->babel() != "hebrew")
+ // This seems necessary
features.UsedLanguages.insert(default_language);
#ifdef DO_USE_DEFAULT_LANGUAGE
if (params.language->lang() != "default" ||
// end of \documentclass defs
// font selection must be done before loading fontenc.sty
- if (params.fonts != "default") {
+ // The ae package is not needed when using OT1 font encoding.
+ if (params.fonts != "default" &&
+ (params.fonts != "ae" || lyxrc.fontenc != "default")) {
ofs << "\\usepackage{" << params.fonts << "}\n";
texrow.newline();
+ if (params.fonts == "ae") {
+ ofs << "\\usepackage{aecompl}\n";
+ texrow.newline();
+ }
}
// this one is not per buffer
if (lyxrc.fontenc != "default") {
ofs << "}\n";
texrow.newline();
}
- if (params.use_amsmath
+ if (features.amsstyle
&& !tclass.provides(LyXTextClass::amsmath)) {
ofs << "\\usepackage{amsmath}\n";
texrow.newline();
int j;
// pop all tags till specified one
- for (j = pos; (j >= 0) && (strcmp(stack[j], tag.c_str())); --j)
+ for (j = pos; (j >= 0) && tag != stack[j]; --j)
os << "</" << stack[j] << ">";
// closes the tag
#else
// pop all tags till specified one
int j = pos;
- for (int j = pos; (j >= 0) && (strcmp(stack[j], tag.c_str())); --j)
+ for (int j = pos; (j >= 0) && tag != stack[j]; --j)
os << "</" << stack[j] << ">";
// closes the tag
<< sgml_includedfiles << " \n]>\n\n";
}
- if (params.options.empty())
- sgmlOpenTag(ofs, 0, top_element);
- else {
- string top = top_element;
+ string top = top_element;
+ top += " lang=\"";
+ top += params.language->code();
+ top += "\"";
+
+ if (!params.options.empty()) {
top += " ";
top += params.options;
- sgmlOpenTag(ofs, 0, top);
}
+ sgmlOpenTag(ofs, 0, top);
ofs << "<!-- DocBook file was created by " << LYX_DOCVERSION
<< "\n See http://www.lyx.org/ for more information -->\n";
}
sgmlOpenTag(ofs, depth + command_depth, command_name);
- item_name = "title";
- if (command_name != "!-- --")
- sgmlOpenTag(ofs, depth + 1 + command_depth, item_name);
+ if (c_params.empty())
+ item_name = "title";
+ else
+ item_name = c_params;
+ sgmlOpenTag(ofs, depth + 1 + command_depth, item_name);
break;
case LATEX_ENVIRONMENT:
}
if (style.latextype == LATEX_ENVIRONMENT) {
- if (!style.latexparam().empty())
- sgmlOpenTag(ofs, depth + command_depth,
- style.latexparam());
+ if (!style.latexparam().empty()) {
+ if(style.latexparam() == "CDATA")
+ ofs << "<![ CDATA [";
+ else
+ sgmlOpenTag(ofs, depth + command_depth,
+ style.latexparam());
+ }
break;
}
// write closing SGML tags
switch (style.latextype) {
case LATEX_COMMAND:
- end_tag = "title";
- if (command_name != "!-- --")
- sgmlCloseTag(ofs, depth + command_depth, end_tag);
+ if (c_params.empty())
+ end_tag = "title";
+ else
+ end_tag = c_params;
+ sgmlCloseTag(ofs, depth + command_depth, end_tag);
break;
case LATEX_ENVIRONMENT:
- if (!style.latexparam().empty())
- sgmlCloseTag(ofs, depth + command_depth,
- style.latexparam());
+ if (!style.latexparam().empty()) {
+ if(style.latexparam() == "CDATA")
+ ofs << "]]>";
+ else
+ sgmlCloseTag(ofs, depth + command_depth,
+ style.latexparam());
+ }
break;
case LATEX_ITEM_ENVIRONMENT:
if (desc_on == 1) break;
}
-vector<vector<Buffer::TocItem> > const Buffer::getTocList()
+vector<vector<Buffer::TocItem> > const Buffer::getTocList() const
{
int figs = 0;
int tables = 0;