#include "LyXAction.h"
#include "Lexer.h"
#include "Text.h"
+#include "LyX.h"
#include "LyXRC.h"
#include "LyXVC.h"
#include "Messages.h"
namespace {
-int const LYX_FORMAT = 269;
+int const LYX_FORMAT = 276;
} // namespace anon
///
TocBackend toc_backend;
+
+ /// Container for all sort of Buffer dependant errors.
+ map<string, ErrorList> errorLists;
};
params().headheight.erase();
params().headsep.erase();
params().footskip.erase();
+ params().listings_params.clear();
for (int i = 0; i < 4; ++i) {
params().user_defined_bullet(i) = ITEMIZE_DEFAULTS[i];
params().temp_bullet(i) = ITEMIZE_DEFAULTS[i];
}
- ErrorList & errorList = errorLists_["Parse"];
+ ErrorList & errorList = pimpl_->errorLists["Parse"];
while (lex.isOK()) {
lex.next();
// Returns false if "\end_document" is not read (Asger)
bool Buffer::readDocument(Lexer & lex)
{
- ErrorList & errorList = errorLists_["Parse"];
+ ErrorList & errorList = pimpl_->errorLists["Parse"];
errorList.clear();
lex.next();
}
if (params().outputChanges) {
- if (!LaTeXFeatures::isAvailable("dvipost")) {
+ bool dvipost = LaTeXFeatures::isAvailable("dvipost");
+ bool xcolorsoul = LaTeXFeatures::isAvailable("soul") &&
+ LaTeXFeatures::isAvailable("xcolor");
+
+ if (!dvipost && !xcolorsoul) {
Alert::warning(_("Changes not shown in LaTeX output"),
- _("Changes will not be highlighted in LaTeX output, "
- "because dvipost is not installed.\n"
- "If you are familiar with TeX, consider redefining "
- "\\lyxinserted and \\lyxdeleted in the LaTeX preamble."));
- } else {
+ _("Changes will not be highlighted in LaTeX output, "
+ "because neither dvipost nor xcolor/soul are installed.\n"
+ "Please install these packages or redefine "
+ "\\lyxadded and \\lyxdeleted in the LaTeX preamble."));
+ } else if (!xcolorsoul) {
Alert::warning(_("Changes not shown in LaTeX output"),
- _("Changes will not be highlighted in LaTeX output "
- "when using pdflatex.\n"
- "If you are familiar with TeX, consider redefining "
- "\\lyxinserted and \\lyxdeleted in the LaTeX preamble."));
+ _("Changes will not be highlighted in LaTeX output "
+ "when using pdflatex, because xcolor and soul are not installed.\n"
+ "Please install both packages or redefine "
+ "\\lyxadded and \\lyxdeleted in the LaTeX preamble."));
}
}
}
ostringstream command;
command << os::python()
- << ' ' << quoteName(lyx2lyx.toFilesystemEncoding())
- << " -t " << convert<string>(LYX_FORMAT)
- << " -o " << quoteName(tmpfile.toFilesystemEncoding())
- << ' ' << quoteName(filename.toFilesystemEncoding());
+ << ' ' << quoteName(lyx2lyx.toFilesystemEncoding())
+ << " -t " << convert<string>(LYX_FORMAT)
+ << " -o " << quoteName(tmpfile.toFilesystemEncoding())
+ << ' ' << quoteName(filename.toFilesystemEncoding());
string const command_str = command.str();
LYXERR(Debug::INFO) << "Running '"
backupName = FileName(fileName() + '~');
if (!lyxrc.backupdir_path.empty())
backupName = FileName(addName(lyxrc.backupdir_path,
- subst(os::internal_path(backupName.absFilename()), '/', '!')));
+ subst(os::internal_path(backupName.absFilename()), '/', '!')));
try {
fs::copy_file(encodedFilename, backupName.toFilesystemEncoding(), false);
madeBackup = true;
} catch (fs::filesystem_error const & fe) {
Alert::error(_("Backup failure"),
- bformat(_("Cannot create backup file %1$s.\n"
- "Please check whether the directory exists and is writeable."),
- from_utf8(backupName.absFilename())));
+ bformat(_("Cannot create backup file %1$s.\n"
+ "Please check whether the directory exists and is writeable."),
+ from_utf8(backupName.absFilename())));
LYXERR(Debug::DEBUG) << "Fs error: " << fe.what() << endl;
}
}
<< "\\lyxformat " << LYX_FORMAT << "\n"
<< "\\begin_document\n";
+
+ /// For each author, set 'used' to true if there is a change
+ /// by this author in the document; otherwise set it to 'false'.
+ AuthorList::Authors::const_iterator a_it = params().authors().begin();
+ AuthorList::Authors::const_iterator a_end = params().authors().end();
+ for (; a_it != a_end; ++a_it)
+ a_it->second.used(false);
+
+ ParIterator const end = par_iterator_end();
+ ParIterator it = par_iterator_begin();
+ for ( ; it != end; ++it)
+ it->checkAuthors(params().authors());
+
// now write out the buffer parameters.
ofs << "\\begin_header\n";
params().writeFile(ofs);
if (!openFileWrite(ofs, fname))
return false;
+ bool failed_export = false;
try {
writeLaTeXSource(ofs, original_path,
runparams, output_preamble, output_body);
}
- catch (iconv_codecvt_facet_exception &) {
- Alert::error(_("Encoding error"),
- _("Some characters of your document are not "
- "representable in the chosen encoding.\n"
- "Changing the document encoding to utf8 could help."));
- return false;
+ catch (iconv_codecvt_facet_exception & e) {
+ lyxerr << "Caught iconv exception: " << e.what() << endl;
+ failed_export = true;
+ }
+ catch (std::exception const & e) {
+ lyxerr << "Caught \"normal\" exception: " << e.what() << endl;
+ failed_export = true;
+ }
+ catch (...) {
+ lyxerr << "Caught some really weird exception..." << endl;
+ LyX::cref().emergencyCleanup();
+ abort();
}
ofs.close();
if (ofs.fail()) {
+ failed_export = true;
lyxerr << "File '" << fname << "' was not closed properly." << endl;
- Alert::error(_("Error closing file"),
- _("The output file could not be closed properly.\n"
- " Probably some characters of your document are not "
- "representable in the chosen encoding.\n"
- "Changing the document encoding to utf8 could help."));
+ }
+
+ if (failed_export) {
+ Alert::error(_("Encoding error"),
+ _("Some characters of your document are probably not "
+ "representable in the chosen encoding.\n"
+ "Changing the document encoding to utf8 could help."));
return false;
}
return true;
!params().language->babel().empty()) {
// FIXME UNICODE
os << from_utf8(subst(lyxrc.language_command_begin,
- "$$lang",
- params().language->babel()))
+ "$$lang",
+ params().language->babel()))
<< '\n';
texrow().newline();
}
if (!lyxrc.language_auto_end &&
!params().language->babel().empty()) {
os << from_utf8(subst(lyxrc.language_command_end,
- "$$lang",
- params().language->babel()))
+ "$$lang",
+ params().language->babel()))
<< '\n';
texrow().newline();
}
LYXERR(Debug::LATEX) << "makeDocBookFile..." << endl;
//ofstream ofs;
- odocfstream ofs;
+ odocfstream ofs;
if (!openFileWrite(ofs, fname))
return;
if (runparams.flavor == OutputParams::XML)
os << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
- // FIXME UNICODE
+ // FIXME UNICODE
os << "<!DOCTYPE " << from_ascii(top_element) << ' ';
- // FIXME UNICODE
+ // FIXME UNICODE
if (! tclass.class_header().empty())
- os << from_ascii(tclass.class_header());
+ os << from_ascii(tclass.class_header());
else if (runparams.flavor == OutputParams::XML)
os << "PUBLIC \"-//OASIS//DTD DocBook XML//EN\" "
<< "\"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd\"";
preamble += features.getLyXSGMLEntities();
if (!preamble.empty()) {
- os << "\n [ " << preamble << " ]";
+ os << "\n [ " << preamble << " ]";
}
os << ">\n\n";
}
Alert::error(_("chktex failure"),
_("Could not run chktex successfully."));
} else if (res > 0) {
- ErrorList & errorList = errorLists_["ChkTeX"];
+ ErrorList & errorList = pimpl_->errorLists["ChkTeX"];
// Clear out old errors
errorList.clear();
// Fill-in the error list with the TeX errors
TextClass const & tclass = params().getTextClass();
if (params().outputChanges) {
- if (features.runparams().flavor == OutputParams::LATEX) {
- if (LaTeXFeatures::isAvailable("dvipost")) {
+ bool dvipost = LaTeXFeatures::isAvailable("dvipost");
+ bool xcolorsoul = LaTeXFeatures::isAvailable("soul") &&
+ LaTeXFeatures::isAvailable("xcolor");
+
+ if (features.runparams().flavor == OutputParams::LATEX) {
+ if (dvipost) {
+ features.require("ct-dvipost");
features.require("dvipost");
+ } else if (xcolorsoul) {
+ features.require("ct-xcolor-soul");
+ features.require("soul");
+ features.require("xcolor");
} else {
features.require("ct-none");
}
} else if (features.runparams().flavor == OutputParams::PDFLATEX ) {
- features.require("ct-none");
- }
+ if (xcolorsoul) {
+ features.require("ct-xcolor-soul");
+ features.require("soul");
+ features.require("xcolor");
+ features.require("pdfcolmk"); // improves color handling in PDF output
+ } else {
+ features.require("ct-none");
+ }
+ }
}
// AMS Style is at document level
void Buffer::setParentName(string const & name)
{
- params().parentname = name;
+ if (name == pimpl_->filename.absFilename())
+ // Avoids recursive include.
+ params().parentname.clear();
+ else
+ params().parentname = name;
}
if (!params().parentname.empty()
&& theBufferList().exists(params().parentname)) {
Buffer const * buf = theBufferList().getBuffer(params().parentname);
- if (buf)
+ //We need to check if the parent is us...
+ //FIXME RECURSIVE INCLUDE
+ //This is not sufficient, since recursive includes could be downstream.
+ if (buf && buf != this)
return buf->getMasterBuffer();
}
runparams.dryrun = true;
if (full_source) {
- os << "% Preview source code\n\n";
+ os << "% " << _("Preview source code") << "\n\n";
if (isLatex())
writeLaTeXSource(os, filePath(), runparams, true, true);
else {
runparams.par_begin = par_begin;
runparams.par_end = par_end;
if (par_begin + 1 == par_end)
- os << "% Preview source code for paragraph " << par_begin << "\n\n";
+ os << "% "
+ << bformat(_("Preview source code for paragraph %1$s"), par_begin)
+ << "\n\n";
else
- os << "% Preview source code from paragraph " << par_begin
- << " to " << par_end - 1 << "\n\n";
+ os << "% "
+ << bformat(_("Preview source code from paragraph %1$s to %2$s"),
+ convert<docstring>(par_begin),
+ convert<docstring>(par_end - 1))
+ << "\n\n";
// output paragraphs
if (isLatex()) {
texrow().reset();
ErrorList const & Buffer::errorList(string const & type) const
{
static ErrorList const emptyErrorList;
- std::map<string, ErrorList>::const_iterator I = errorLists_.find(type);
- if (I == errorLists_.end())
+ std::map<string, ErrorList>::const_iterator I = pimpl_->errorLists.find(type);
+ if (I == pimpl_->errorLists.end())
return emptyErrorList;
return I->second;
ErrorList & Buffer::errorList(string const & type)
{
- return errorLists_[type];
+ return pimpl_->errorLists[type];
}