When copying to the clipboard you can get a message box with an error
message if the HTML conversion fails (bug 8866). Since errors are in general
completely ignored for clipboard copying, I implemented that for the HTML
case as well. OK to go in?
Georg
diff --git a/src/Buffer.cpp b/src/Buffer.cpp
index ceb86b9..6c320f0 100644
--- a/src/Buffer.cpp
+++ b/src/Buffer.cpp
@@ -1536,7 +1536,10 @@ bool Buffer::makeLaTeXFile(FileName const & fname,
lyxerr << "File '" << fname << "' was not closed properly." << endl;
}
- errors("Export");
+ if (runparams_in.silent)
+ errorList.clear();
+ else
+ errors("Export");
return !failed_export;
}
@@ -2000,7 +2003,10 @@ int Buffer::runChktex()
setBusy(false);
- errors("ChkTeX");
+ if (runparams.silent)
+ d->errorLists["ChkTeX"].clear();
+ else
+ errors("ChkTeX");
return res;
}
@@ -3968,17 +3974,21 @@ Buffer::ExportStatus Buffer::doExport(string const & target, bool put_in_tempdir
// Emit the signal to show the error list or copy it back to the
// cloned Buffer so that it can be emitted afterwards.
if (format != backend_format) {
- if (d->cloned_buffer_) {
+ if (runparams.silent)
+ error_list.clear();
+ else if (d->cloned_buffer_)
d->cloned_buffer_->d->errorLists[error_type] =
d->errorLists[error_type];
- } else
+ else
errors(error_type);
// also to the children, in case of master-buffer-view
ListOfBuffers clist = getDescendents();
ListOfBuffers::const_iterator cit = clist.begin();
ListOfBuffers::const_iterator const cen = clist.end();
for (; cit != cen; ++cit) {
- if (d->cloned_buffer_) {
+ if (runparams.silent)
+ (*cit)->d->errorLists[error_type].clear();
+ else if (d->cloned_buffer_) {
// Enable reverse search by copying back the
// texrow object to the cloned buffer.
// FIXME: this is not thread safe.
diff --git a/src/CutAndPaste.cpp b/src/CutAndPaste.cpp
index ca014be..844a119 100644
--- a/src/CutAndPaste.cpp
+++ b/src/CutAndPaste.cpp
@@ -532,6 +532,8 @@ void putClipboard(ParagraphList const & paragraphs,
OutputParams runparams(encodings.fromLyXName("utf8"));
// We do not need to produce images, etc.
runparams.dryrun = true;
+ // We are not interested in errors (bug 8866)
+ runparams.silent = true;
buffer->writeLyXHTMLSource(oshtml, runparams, Buffer::FullSource);
theClipboard().put(lyx, oshtml.str(), plaintext);
diff --git a/src/OutputParams.cpp b/src/OutputParams.cpp
index ea56d2f..df58ff4 100644
--- a/src/OutputParams.cpp
+++ b/src/OutputParams.cpp
@@ -28,7 +28,7 @@ OutputParams::OutputParams(Encoding const * enc)
inIndexEntry(false), inIPA(false), inDeletedInset(0),
changeOfDeletedInset(Change::UNCHANGED),
par_begin(0), par_end(0), lastid(-1), lastpos(-1), isLastPar(false),
- dryrun(false), pass_thru(false),
+ dryrun(false), silent(false), pass_thru(false),
html_disable_captions(false), html_in_par(false),
html_make_pars(true), for_toc(false), for_tooltip(false),
for_search(false), includeall(false)
diff --git a/src/OutputParams.h b/src/OutputParams.h
index e492a99..f220b5e 100644
--- a/src/OutputParams.h
+++ b/src/OutputParams.h
@@ -245,7 +245,10 @@ public:
* This mode will be used to preview the source code
*/
bool dryrun;
-
+
+ /// whether to display output errors or not
+ bool silent;
+
/// Should we output verbatim or escape LaTeX's special chars?
bool pass_thru;
diff --git a/src/insets/InsetHyperlink.cpp b/src/insets/InsetHyperlink.cpp
index 60c64f9..81caa37 100644
--- a/src/insets/InsetHyperlink.cpp
+++ b/src/insets/InsetHyperlink.cpp
@@ -191,7 +191,7 @@ void InsetHyperlink::latex(otexstream & os,
pair<docstring, docstring> name_latexed =
runparams.encoding->latexString(name, runparams.dryrun);
name = name_latexed.first;
- if (!name_latexed.second.empty()) {
+ if (!name_latexed.second.empty() && !runparams.silent) {
// issue a warning about omitted characters
// FIXME: should be passed to the error dialog
frontend::Alert::warning(_("Uncodable characters"),
diff --git a/src/insets/InsetInclude.cpp b/src/insets/InsetInclude.cpp
index 9a6ed47..fe0c1ed 100644
--- a/src/insets/InsetInclude.cpp
+++ b/src/insets/InsetInclude.cpp
@@ -536,6 +536,8 @@ void InsetInclude::latex(otexstream & os, OutputParams const & runparams) const
if (!runparams.nice)
incfile = mangled;
+ else if (!runparams.silent)
+ ; // no warning wanted
else if (!isValidLaTeXFileName(incfile)) {
frontend::Alert::warning(_("Invalid filename"),
_("The following filename will cause troubles "
@@ -626,42 +628,46 @@ void InsetInclude::latex(otexstream & os, OutputParams const & runparams) const
Buffer * tmp = loadIfNeeded();
if (!tmp) {
- docstring text = bformat(_("Could not load included "
- "file\n`%1$s'\n"
- "Please, check whether it actually exists."),
- included_file.displayName());
- Alert::warning(_("Missing included file"), text);
+ if (!runparams.silent) {
+ docstring text = bformat(_("Could not load included "
+ "file\n`%1$s'\n"
+ "Please, check whether it actually exists."),
+ included_file.displayName());
+ Alert::warning(_("Missing included file"), text);
+ }
return;
}
- if (tmp->params().baseClass() != masterBuffer->params().baseClass()) {
- // FIXME UNICODE
- docstring text = bformat(_("Included file `%1$s'\n"
- "has textclass `%2$s'\n"
- "while parent file has textclass `%3$s'."),
- included_file.displayName(),
- from_utf8(tmp->params().documentClass().name()),
- from_utf8(masterBuffer->params().documentClass().name()));
- Alert::warning(_("Different textclasses"), text, true);
- }
-
- // Make sure modules used in child are all included in master
- // FIXME It might be worth loading the children's modules into the master
- // over in BufferParams rather than doing this check.
- LayoutModuleList const masterModules = masterBuffer->params().getModules();
- LayoutModuleList const childModules = tmp->params().getModules();
- LayoutModuleList::const_iterator it = childModules.begin();
- LayoutModuleList::const_iterator end = childModules.end();
- for (; it != end; ++it) {
- string const module = *it;
- LayoutModuleList::const_iterator found =
- find(masterModules.begin(), masterModules.end(), module);
- if (found == masterModules.end()) {
+ if (!runparams.silent) {
+ if (tmp->params().baseClass() != masterBuffer->params().baseClass()) {
+ // FIXME UNICODE
docstring text = bformat(_("Included file `%1$s'\n"
- "uses module `%2$s'\n"
- "which is not used in parent file."),
- included_file.displayName(), from_utf8(module));
- Alert::warning(_("Module not found"), text);
+ "has textclass `%2$s'\n"
+ "while parent file has textclass `%3$s'."),
+ included_file.displayName(),
+ from_utf8(tmp->params().documentClass().name()),
+ from_utf8(masterBuffer->params().documentClass().name()));
+ Alert::warning(_("Different textclasses"), text, true);
+ }
+
+ // Make sure modules used in child are all included in master
+ // FIXME It might be worth loading the children's modules into the master
+ // over in BufferParams rather than doing this check.
+ LayoutModuleList const masterModules = masterBuffer->params().getModules();
+ LayoutModuleList const childModules = tmp->params().getModules();
+ LayoutModuleList::const_iterator it = childModules.begin();
+ LayoutModuleList::const_iterator end = childModules.end();
+ for (; it != end; ++it) {
+ string const module = *it;
+ LayoutModuleList::const_iterator found =
+ find(masterModules.begin(), masterModules.end(), module);
+ if (found == masterModules.end()) {
+ docstring text = bformat(_("Included file `%1$s'\n"
+ "uses module `%2$s'\n"
+ "which is not used in parent file."),
+ included_file.displayName(), from_utf8(module));
+ Alert::warning(_("Module not found"), text);
+ }
}
}
@@ -688,16 +694,18 @@ void InsetInclude::latex(otexstream & os, OutputParams const & runparams) const
runparams.is_child = true;
if (!tmp->makeLaTeXFile(tmpwritefile, masterFileName(buffer()).
onlyPath().absFileName(), runparams, Buffer::OnlyBody)) {
- docstring msg = bformat(_("Included file `%1$s' "
+ if (!runparams.silent) {
+ docstring msg = bformat(_("Included file `%1$s' "
"was not exported correctly.\nWarning: "
"LaTeX export is probably incomplete."),
included_file.displayName());
- ErrorList const & el = tmp->errorList("Export");
- if (!el.empty())
- msg = bformat(from_ascii("%1$s\n\n%2$s\n\n%3$s"),
+ ErrorList const & el = tmp->errorList("Export");
+ if (!el.empty())
+ msg = bformat(from_ascii("%1$s\n\n%2$s\n\n%3$s"),
msg, el.begin()->error,
el.begin()->description);
- Alert::warning(_("Export failure"), msg);
+ Alert::warning(_("Export failure"), msg);
+ }
}
runparams.encoding = oldEnc;
runparams.master_language = oldLang;
@@ -711,7 +719,7 @@ void InsetInclude::latex(otexstream & os, OutputParams const & runparams) const
included_file,
inc_format, tex_format, el);
- if (!success) {
+ if (!success && !runparams.silent) {
docstring msg = bformat(_("Included file `%1$s' "
"was not exported correctly.\nWarning: "
"LaTeX export is probably incomplete."),
@@ -769,7 +777,8 @@ docstring InsetInclude::xhtml(XHTMLStream & xs, OutputParams const & rp) const
// converter on the included file. But that's just masochistic.)
FileName const included_file = includedFileName(buffer(), params());
if (!isLyXFileName(included_file.absFileName())) {
- frontend::Alert::warning(_("Unsupported Inclusion"),
+ if (!rp.silent)
+ frontend::Alert::warning(_("Unsupported Inclusion"),
bformat(_("LyX does not know how to include non-LyX files when "
"generating HTML output. Offending file:\n%1$s"),
params()["filename"]));
diff --git a/src/insets/InsetListings.cpp b/src/insets/InsetListings.cpp
index 63621e1..32211bb 100644
--- a/src/insets/InsetListings.cpp
+++ b/src/insets/InsetListings.cpp
@@ -213,7 +213,7 @@ void InsetListings::latex(otexstream & os, OutputParams const & runparams) const
+ _("no more lstline delimiters available") + ">";
code = subst(code, from_ascii("!"), delim_error);
delimiter = lstinline_delimiters;
- if (!runparams.dryrun) {
+ if (!runparams.dryrun && !runparams.silent) {
// FIXME: warning should be passed to the error dialog
frontend::Alert::warning(_("Running out of delimiters"),
_("For inline program listings, one character must be reserved\n"
@@ -253,7 +253,7 @@ void InsetListings::latex(otexstream & os, OutputParams const & runparams) const
runparams.encoding = save_enc;
}
- if (!uncodable.empty()) {
+ if (!uncodable.empty() && !runparams.silent) {
// issue a warning about omitted characters
// FIXME: should be passed to the error dialog
frontend::Alert::warning(_("Uncodable characters in listings inset"),