#include "support/gettext.h"
#include "support/lassert.h"
#include "support/lstrings.h" // contains
#include "support/gettext.h"
#include "support/lassert.h"
#include "support/lstrings.h" // contains
InsetInclude::InsetInclude(Buffer * buf, InsetCommandParams const & p)
: InsetCommand(buf, p), include_label(uniqueID()),
preview_(make_unique<RenderMonitoredPreview>(this)), failedtoload_(false),
InsetInclude::InsetInclude(Buffer * buf, InsetCommandParams const & p)
: InsetCommand(buf, p), include_label(uniqueID()),
preview_(make_unique<RenderMonitoredPreview>(this)), failedtoload_(false),
- set_label_(false), label_(nullptr), child_buffer_(nullptr), file_exist_(false),
+ label_(nullptr), child_buffer_(nullptr), file_exist_(false),
InsetInclude::InsetInclude(InsetInclude const & other)
: InsetCommand(other), include_label(other.include_label),
preview_(make_unique<RenderMonitoredPreview>(this)), failedtoload_(false),
InsetInclude::InsetInclude(InsetInclude const & other)
: InsetCommand(other), include_label(other.include_label),
preview_(make_unique<RenderMonitoredPreview>(this)), failedtoload_(false),
- set_label_(false), label_(nullptr), child_buffer_(nullptr),
+ label_(nullptr), child_buffer_(nullptr),
FileName const included_file = includedFileName(buffer(), params());
Buffer const * const masterBuffer = buffer().masterBuffer();
FileName const included_file = includedFileName(buffer(), params());
Buffer const * const masterBuffer = buffer().masterBuffer();
+ if (runparams.inDeletedInset) {
+ // We cannot strike-out whole children,
+ // so we just output a note.
+ os << "\\textbf{"
+ << bformat(buffer().B_("[INCLUDED FILE %1$s DELETED!]"),
+ from_utf8(included_file.onlyFileName()))
+ << "}";
+ return;
+ }
+
// if incfile is relative, make it relative to the master
// buffer directory.
if (!FileName::isAbsolute(incfile)) {
// if incfile is relative, make it relative to the master
// buffer directory.
if (!FileName::isAbsolute(incfile)) {
FileName const writefile(makeAbsPath(mangled, runparams.for_preview ?
buffer().temppath() : masterBuffer->temppath()));
FileName const writefile(makeAbsPath(mangled, runparams.for_preview ?
buffer().temppath() : masterBuffer->temppath()));
- LYXERR(Debug::LATEX, "incfile:" << incfile);
- LYXERR(Debug::LATEX, "exportfile:" << exportfile);
- LYXERR(Debug::LATEX, "writefile:" << writefile);
+ LYXERR(Debug::OUTFILE, "incfile:" << incfile);
+ LYXERR(Debug::OUTFILE, "exportfile:" << exportfile);
+ LYXERR(Debug::OUTFILE, "writefile:" << writefile);
to_utf8(bformat(_("Could not copy the file\n%1$s\n"
"into the temporary directory."),
from_utf8(included_file.absFileName()))));
to_utf8(bformat(_("Could not copy the file\n%1$s\n"
"into the temporary directory."),
from_utf8(included_file.absFileName()))));
{
// just write the filename if we're making a tooltip or toc entry,
// or are generating this for advanced search
{
// just write the filename if we're making a tooltip or toc entry,
// or are generating this for advanced search
os << '[' << screenLabel() << '\n'
<< ltrim(getParam("filename")) << "\n]";
return PLAINTEXT_NEWLINE + 1; // one char on a separate line
}
if (isVerbatim(params()) || isListings(params())) {
os << '[' << screenLabel() << '\n'
<< ltrim(getParam("filename")) << "\n]";
return PLAINTEXT_NEWLINE + 1; // one char on a separate line
}
if (isVerbatim(params()) || isListings(params())) {
ibuf->writeDocBookSource(xs.os(), op, Buffer::IncludedFile);
} else {
xs << XMLStream::ESCAPE_NONE << "<!-- Included file: ";
ibuf->writeDocBookSource(xs.os(), op, Buffer::IncludedFile);
} else {
xs << XMLStream::ESCAPE_NONE << "<!-- Included file: ";
- if (!set_label_) {
- set_label_ = true;
- button_.update(screenLabel(), true, false, !file_exist_ || recursion_error_);
- }
- button_.metrics(mi, dim);
+ setBroken(!file_exist_ || recursion_error_);
+ InsetCommand::metrics(mi, dim);
runparams.for_preview = true;
inset.latex(os, runparams);
runparams.for_preview = true;
inset.latex(os, runparams);
InsetCommandParams const & params = inset.params();
if (RenderPreview::previewText() && preview_wanted(params, buffer)) {
renderer.setAbsFile(includedFileName(buffer, params));
InsetCommandParams const & params = inset.params();
if (RenderPreview::previewText() && preview_wanted(params, buffer)) {
renderer.setAbsFile(includedFileName(buffer, params));
- docstring const snippet = latexString(inset);
+ docstring snippet;
+ try {
+ // InsetInclude::latex() throws if generation of LaTeX
+ // fails, e.g. if lyx2lyx fails because file is too
+ // new, or knitr fails.
+ snippet = latexString(inset);
+ } catch (...) {
+ // remove current preview because it is likely
+ // associated with the previous included file name
+ renderer.removePreview(buffer);
+ LYXERR0("Preview of include failed.");
+ return;
+ }
InsetListingsParams p(to_utf8(params()["lstparams"]));
b.argumentItem(from_utf8(p.getParamValue("caption")));
b.pop();
InsetListingsParams p(to_utf8(params()["lstparams"]));
b.argumentItem(from_utf8(p.getParamValue("caption")));
b.pop();
TocBuilder & b = backend.builder("child");
b.pushItem(cpit, screenLabel(), output_active);
b.pop();
TocBuilder & b = backend.builder("child");
b.pushItem(cpit, screenLabel(), output_active);
b.pop();
- TocBuilder & b = backend.builder("child");
- docstring str = childbuffer ? childbuffer->fileName().displayName()
- : from_ascii("?");
- b.pushItem(cpit, str, output_active);
- b.pop();
+ TocBuilder & b = backend.builder("child");
+ string const fname = ltrim(to_utf8(params()["filename"]));
+ // mark non-existent file with MISSING
+ docstring const str = (file_exist_ ? from_ascii("") : _("MISSING: "))
+ + from_utf8(onlyFileName(fname)) + " (" + from_utf8(fname) + ")";
+ b.pushItem(cpit, str, output_active);
+ b.pop();
- if (checkForRecursiveInclude(childbuffer))
- return;
- buffer().pushIncludedBuffer(childbuffer);
- // Update the child's tocBackend. The outliner uses the master's, but
- // the navigation menu uses the child's.
- childbuffer->tocBackend().update(output_active, utype);
- // Include Tocs from children
- childbuffer->inset().addToToc(DocIterator(), output_active, utype,
- backend);
- buffer().popIncludedBuffer();
- // Copy missing outliner names (though the user has been warned against
- // having different document class and module selection between master
- // and child).
- for (auto const & name
- : childbuffer->params().documentClass().outlinerNames())
- backend.addName(name.first, translateIfPossible(name.second));
- }
+ if (checkForRecursiveInclude(childbuffer))
+ return;
+ buffer().pushIncludedBuffer(childbuffer);
+ // Update the child's tocBackend. The outliner uses the master's, but
+ // the navigation menu uses the child's.
+ childbuffer->tocBackend().update(output_active, utype);
+ // Include Tocs from children
+ childbuffer->inset().addToToc(DocIterator(), output_active, utype,
+ backend);
+ buffer().popIncludedBuffer();
+ // Copy missing outliner names (though the user has been warned against
+ // having different document class and module selection between master
+ // and child).
+ for (auto const & name
+ : childbuffer->params().documentClass().outlinerNames())
+ backend.addName(name.first, translateIfPossible(name.second));
if (childbuffer) {
if (!checkForRecursiveInclude(childbuffer))
childbuffer->updateBuffer(Buffer::UpdateChildOnly, utype);
if (childbuffer) {
if (!checkForRecursiveInclude(childbuffer))
childbuffer->updateBuffer(Buffer::UpdateChildOnly, utype);