2 * \file InsetInclude.cpp
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Lars Gullik Bjønnes
7 * \author Richard Heck (conversion to InsetCommand)
8 * \author Bo Peng (embedding stuff)
10 * Full author contact details are available in file CREDITS.
15 #include "InsetInclude.h"
17 #include "LayoutFile.h"
19 #include "buffer_funcs.h"
20 #include "BufferList.h"
21 #include "BufferParams.h"
22 #include "BufferView.h"
24 #include "DispatchResult.h"
25 #include "ErrorList.h"
27 #include "FuncRequest.h"
28 #include "FuncStatus.h"
29 #include "LaTeXFeatures.h"
33 #include "MetricsInfo.h"
34 #include "OutputParams.h"
35 #include "TextClass.h"
36 #include "TocBackend.h"
38 #include "frontends/alert.h"
39 #include "frontends/Painter.h"
41 #include "graphics/PreviewImage.h"
42 #include "graphics/PreviewLoader.h"
44 #include "insets/InsetLabel.h"
45 #include "insets/InsetListingsParams.h"
46 #include "insets/RenderPreview.h"
48 #include "support/debug.h"
49 #include "support/docstream.h"
50 #include "support/ExceptionMessage.h"
51 #include "support/FileNameList.h"
52 #include "support/filetools.h"
53 #include "support/gettext.h"
54 #include "support/lstrings.h" // contains
55 #include "support/lyxalgo.h"
56 #include "support/convert.h"
58 #include <boost/bind.hpp>
61 using namespace lyx::support;
65 namespace Alert = frontend::Alert;
70 docstring const uniqueID()
72 static unsigned int seed = 1000;
73 return "file" + convert<docstring>(++seed);
77 /// the type of inclusion
79 INCLUDE, VERB, INPUT, VERBAST, LISTINGS, NONE
83 Types type(string const & s)
87 if (s == "verbatiminput")
89 if (s == "verbatiminput*")
91 if (s == "lstinputlisting")
99 Types type(InsetCommandParams const & params)
101 return type(params.getCmdName());
105 bool isListings(InsetCommandParams const & params)
107 return type(params) == LISTINGS;
111 bool isVerbatim(InsetCommandParams const & params)
113 Types const t = type(params);
114 return t == VERB || t == VERBAST;
118 bool isInputOrInclude(InsetCommandParams const & params)
120 Types const t = type(params);
121 return t == INPUT || t == INCLUDE;
125 FileName const masterFileName(Buffer const & buffer)
127 return buffer.masterBuffer()->fileName();
131 void add_preview(RenderMonitoredPreview &, InsetInclude const &, Buffer const &);
134 string const parentFilename(Buffer const & buffer)
136 return buffer.absFileName();
140 EmbeddedFile const includedFilename(Buffer const & buffer,
141 InsetCommandParams const & params)
143 // it is not a good idea to create this EmbeddedFile object
144 // each time, but there seems to be no easy way around.
145 EmbeddedFile file(to_utf8(params["filename"]),
146 onlyPath(parentFilename(buffer)));
147 file.setEmbed(!params["embed"].empty());
148 file.enable(buffer.embedded(), &buffer);
152 InsetLabel * createLabel(docstring const & label_str)
154 if (label_str.empty())
156 InsetCommandParams icp(LABEL_CODE);
157 icp["name"] = label_str;
158 return new InsetLabel(icp);
164 InsetInclude::InsetInclude(InsetCommandParams const & p)
165 : InsetCommand(p, "include"), include_label(uniqueID()),
166 preview_(new RenderMonitoredPreview(this)), set_label_(false), label_(0)
168 preview_->fileChanged(boost::bind(&InsetInclude::fileChanged, this));
170 if (isListings(params())) {
171 InsetListingsParams listing_params(to_utf8(p["lstparams"]));
172 label_ = createLabel(from_utf8(listing_params.getParamValue("label")));
177 InsetInclude::InsetInclude(InsetInclude const & other)
178 : InsetCommand(other), include_label(other.include_label),
179 preview_(new RenderMonitoredPreview(this)), set_label_(false), label_(0)
181 preview_->fileChanged(boost::bind(&InsetInclude::fileChanged, this));
184 label_ = new InsetLabel(*other.label_);
188 InsetInclude::~InsetInclude()
191 if (isVerbatim(params()) || isListings(params()))
195 string const parent_filename = buffer().absFileName();
196 FileName const included_file = makeAbsPath(to_utf8(params()["filename"]),
197 onlyPath(parent_filename));
199 if (!isLyXFilename(included_file.absFilename()))
202 Buffer * child = theBufferList().getBuffer(included_file.absFilename());
203 // File not opened, nothing to close.
207 // Child document has a different parent, don't close it.
208 if (child->parent() != &buffer())
212 theBufferList().release(child);
216 void InsetInclude::setBuffer(Buffer & buffer)
220 label_->setBuffer(buffer);
225 ParamInfo const & InsetInclude::findInfo(string const & /* cmdName */)
228 // This is only correct for the case of listings, but it'll do for now.
229 // In the other cases, this second parameter should just be empty.
230 static ParamInfo param_info_;
231 if (param_info_.empty()) {
232 param_info_.add("filename", ParamInfo::LATEX_REQUIRED);
233 param_info_.add("lstparams", ParamInfo::LATEX_OPTIONAL);
234 param_info_.add("embed", ParamInfo::LYX_INTERNAL);
240 bool InsetInclude::isCompatibleCommand(string const & s)
242 return type(s) != NONE;
246 void InsetInclude::doDispatch(Cursor & cur, FuncRequest & cmd)
248 BOOST_ASSERT(&cur.buffer() == &buffer());
249 switch (cmd.action) {
251 case LFUN_INSET_MODIFY: {
252 InsetCommandParams p(INCLUDE_CODE);
253 InsetCommandMailer::string2params("include", to_utf8(cmd.argument()), p);
254 if (!p.getCmdName().empty()) {
256 InsetListingsParams new_params(to_utf8(p["lstparams"]));
257 docstring const label_str = from_utf8(new_params.getParamValue("label"));
258 if (label_str.empty())
261 label_->updateCommand(label_str);
263 label_ = createLabel(label_str);
264 label_->setBuffer(buffer());
269 // the embed parameter passed back from the dialog
270 // is "true" or "false", we need to change it.
271 if (p["embed"] == _("false"))
274 p["embed"] = from_utf8(EmbeddedFile(to_utf8(p["filename"]),
275 onlyPath(parentFilename(cur.buffer()))).inzipName());
277 includedFilename(cur.buffer(), p);
278 } catch (ExceptionMessage const & message) {
279 Alert::error(message.title_, message.details_);
280 // do not set parameter if an error happens
284 buffer().updateBibfilesCache();
290 //pass everything else up the chain
292 InsetCommand::doDispatch(cur, cmd);
298 void InsetInclude::setParams(InsetCommandParams const & p)
300 InsetCommand::setParams(p);
303 if (preview_->monitoring())
304 preview_->stopMonitoring();
306 if (type(params()) == INPUT)
307 add_preview(*preview_, *this, buffer());
311 docstring InsetInclude::screenLabel() const
315 switch (type(params())) {
317 temp = buffer().B_("Input");
320 temp = buffer().B_("Verbatim Input");
323 temp = buffer().B_("Verbatim Input*");
326 temp = buffer().B_("Include");
329 temp = listings_label_;
337 if (params()["filename"].empty())
340 temp += from_utf8(onlyFilename(to_utf8(params()["filename"])));
342 if (!params()["embed"].empty())
343 temp += _(" (embedded)");
348 /// return the child buffer if the file is a LyX doc and is loaded
349 Buffer * getChildBuffer(Buffer const & buffer, InsetCommandParams const & params)
351 if (isVerbatim(params) || isListings(params))
354 string const included_file = includedFilename(buffer, params).absFilename();
355 if (!isLyXFilename(included_file))
358 Buffer * childBuffer = loadIfNeeded(buffer, params);
360 // FIXME: recursive includes
361 return (childBuffer == &buffer) ? 0 : childBuffer;
365 /// return true if the file is or got loaded.
366 Buffer * loadIfNeeded(Buffer const & parent, InsetCommandParams const & params)
368 if (isVerbatim(params) || isListings(params))
371 string const parent_filename = parent.absFileName();
372 FileName const included_file = makeAbsPath(to_utf8(params["filename"]),
373 onlyPath(parent_filename));
375 if (!isLyXFilename(included_file.absFilename()))
378 Buffer * child = theBufferList().getBuffer(included_file.absFilename());
380 // the readonly flag can/will be wrong, not anymore I think.
381 if (!included_file.exists())
384 child = theBufferList().newBuffer(included_file.absFilename());
386 // Buffer creation is not possible.
389 if (!child->loadLyXFile(included_file)) {
390 //close the buffer we just opened
391 theBufferList().release(child);
395 if (!child->errorList("Parse").empty()) {
396 // FIXME: Do something.
399 child->setParent(&parent);
404 int InsetInclude::latex(odocstream & os, OutputParams const & runparams) const
406 string incfile = to_utf8(params()["filename"]);
408 // Do nothing if no file name has been specified
412 FileName const included_file =
413 includedFilename(buffer(), params()).availableFile();
415 // Check we're not trying to include ourselves.
416 // FIXME RECURSIVE INCLUDE
417 // This isn't sufficient, as the inclusion could be downstream.
418 // But it'll have to do for now.
419 if (isInputOrInclude(params()) &&
420 buffer().absFileName() == included_file.absFilename())
422 Alert::error(_("Recursive input"),
423 bformat(_("Attempted to include file %1$s in itself! "
424 "Ignoring inclusion."), from_utf8(incfile)));
428 Buffer const * const masterBuffer = buffer().masterBuffer();
430 // if incfile is relative, make it relative to the master
432 if (!FileName(incfile).isAbsolute()) {
434 incfile = to_utf8(makeRelPath(from_utf8(included_file.absFilename()),
435 from_utf8(masterBuffer->filePath())));
438 // write it to a file (so far the complete file)
439 string const exportfile = changeExtension(incfile, ".tex");
440 string const mangled =
441 DocFileName(changeExtension(included_file.absFilename(),".tex")).
443 FileName const writefile(makeAbsPath(mangled, masterBuffer->temppath()));
447 else if (!isValidLaTeXFilename(incfile)) {
448 frontend::Alert::warning(_("Invalid filename"),
449 _("The following filename is likely to cause trouble "
450 "when running the exported file through LaTeX: ") +
453 LYXERR(Debug::LATEX, "incfile:" << incfile);
454 LYXERR(Debug::LATEX, "exportfile:" << exportfile);
455 LYXERR(Debug::LATEX, "writefile:" << writefile);
457 if (runparams.inComment || runparams.dryrun) {
458 //Don't try to load or copy the file if we're
459 //in a comment or doing a dryrun
460 } else if (isInputOrInclude(params()) &&
461 isLyXFilename(included_file.absFilename())) {
462 //if it's a LyX file and we're inputting or including,
463 //try to load it so we can write the associated latex
464 if (!loadIfNeeded(buffer(), params()))
467 Buffer * tmp = theBufferList().getBuffer(included_file.absFilename());
469 if (tmp->params().baseClass() != masterBuffer->params().baseClass()) {
471 docstring text = bformat(_("Included file `%1$s'\n"
472 "has textclass `%2$s'\n"
473 "while parent file has textclass `%3$s'."),
474 included_file.displayName(),
475 from_utf8(tmp->params().documentClass().name()),
476 from_utf8(masterBuffer->params().documentClass().name()));
477 Alert::warning(_("Different textclasses"), text);
481 // Make sure modules used in child are all included in master
482 //FIXME It might be worth loading the children's modules into the master
483 //over in BufferParams rather than doing this check.
484 vector<string> const masterModules = masterBuffer->params().getModules();
485 vector<string> const childModules = tmp->params().getModules();
486 vector<string>::const_iterator it = childModules.begin();
487 vector<string>::const_iterator end = childModules.end();
488 for (; it != end; ++it) {
489 string const module = *it;
490 vector<string>::const_iterator found =
491 find(masterModules.begin(), masterModules.end(), module);
492 if (found != masterModules.end()) {
493 docstring text = bformat(_("Included file `%1$s'\n"
494 "uses module `%2$s'\n"
495 "which is not used in parent file."),
496 included_file.displayName(), from_utf8(module));
497 Alert::warning(_("Module not found"), text);
501 tmp->markDepClean(masterBuffer->temppath());
503 // FIXME: handle non existing files
504 // FIXME: Second argument is irrelevant!
505 // since only_body is true, makeLaTeXFile will not look at second
506 // argument. Should we set it to string(), or should makeLaTeXFile
507 // make use of it somehow? (JMarc 20031002)
508 // The included file might be written in a different encoding
509 Encoding const * const oldEnc = runparams.encoding;
510 runparams.encoding = &tmp->params().encoding();
511 tmp->makeLaTeXFile(writefile,
512 masterFileName(buffer()).onlyPath().absFilename(),
514 runparams.encoding = oldEnc;
516 // In this case, it's not a LyX file, so we copy the file
517 // to the temp dir, so that .aux files etc. are not created
518 // in the original dir. Files included by this file will be
519 // found via input@path, see ../Buffer.cpp.
520 unsigned long const checksum_in = included_file.checksum();
521 unsigned long const checksum_out = writefile.checksum();
523 if (checksum_in != checksum_out) {
524 if (!included_file.copyTo(writefile)) {
527 to_utf8(bformat(_("Could not copy the file\n%1$s\n"
528 "into the temporary directory."),
529 from_utf8(included_file.absFilename()))));
535 string const tex_format = (runparams.flavor == OutputParams::LATEX) ?
536 "latex" : "pdflatex";
537 if (isVerbatim(params())) {
538 incfile = latex_path(incfile);
540 os << '\\' << from_ascii(params().getCmdName()) << '{'
541 << from_utf8(incfile) << '}';
542 } else if (type(params()) == INPUT) {
543 runparams.exportdata->addExternalFile(tex_format, writefile,
546 // \input wants file with extension (default is .tex)
547 if (!isLyXFilename(included_file.absFilename())) {
548 incfile = latex_path(incfile);
550 os << '\\' << from_ascii(params().getCmdName())
551 << '{' << from_utf8(incfile) << '}';
553 incfile = changeExtension(incfile, ".tex");
554 incfile = latex_path(incfile);
556 os << '\\' << from_ascii(params().getCmdName())
557 << '{' << from_utf8(incfile) << '}';
559 } else if (type(params()) == LISTINGS) {
560 os << '\\' << from_ascii(params().getCmdName());
561 string const opt = to_utf8(params()["lstparams"]);
562 // opt is set in QInclude dialog and should have passed validation.
563 InsetListingsParams params(opt);
564 if (!params.params().empty())
565 os << "[" << from_utf8(params.params()) << "]";
566 os << '{' << from_utf8(incfile) << '}';
568 runparams.exportdata->addExternalFile(tex_format, writefile,
571 // \include don't want extension and demands that the
572 // file really have .tex
573 incfile = changeExtension(incfile, string());
574 incfile = latex_path(incfile);
576 os << '\\' << from_ascii(params().getCmdName()) << '{'
577 << from_utf8(incfile) << '}';
584 int InsetInclude::plaintext(odocstream & os, OutputParams const &) const
586 if (isVerbatim(params()) || isListings(params())) {
587 os << '[' << screenLabel() << '\n';
588 // FIXME: We don't know the encoding of the file, default to UTF-8.
589 os << includedFilename(buffer(), params()).fileContents("UTF-8");
591 return PLAINTEXT_NEWLINE + 1; // one char on a separate line
593 docstring const str = '[' + screenLabel() + ']';
600 int InsetInclude::docbook(odocstream & os, OutputParams const & runparams) const
602 string incfile = to_utf8(params()["filename"]);
604 // Do nothing if no file name has been specified
608 string const included_file = includedFilename(buffer(), params()).absFilename();
610 // Check we're not trying to include ourselves.
611 // FIXME RECURSIVE INCLUDE
612 // This isn't sufficient, as the inclusion could be downstream.
613 // But it'll have to do for now.
614 if (buffer().absFileName() == included_file) {
615 Alert::error(_("Recursive input"),
616 bformat(_("Attempted to include file %1$s in itself! "
617 "Ignoring inclusion."), from_utf8(incfile)));
621 // write it to a file (so far the complete file)
622 string const exportfile = changeExtension(incfile, ".sgml");
623 DocFileName writefile(changeExtension(included_file, ".sgml"));
625 if (loadIfNeeded(buffer(), params())) {
626 Buffer * tmp = theBufferList().getBuffer(included_file);
628 string const mangled = writefile.mangledFilename();
629 writefile = makeAbsPath(mangled,
630 buffer().masterBuffer()->temppath());
634 LYXERR(Debug::LATEX, "incfile:" << incfile);
635 LYXERR(Debug::LATEX, "exportfile:" << exportfile);
636 LYXERR(Debug::LATEX, "writefile:" << writefile);
638 tmp->makeDocBookFile(writefile, runparams, true);
641 runparams.exportdata->addExternalFile("docbook", writefile,
643 runparams.exportdata->addExternalFile("docbook-xml", writefile,
646 if (isVerbatim(params()) || isListings(params())) {
647 os << "<inlinegraphic fileref=\""
648 << '&' << include_label << ';'
649 << "\" format=\"linespecific\">";
651 os << '&' << include_label << ';';
657 void InsetInclude::validate(LaTeXFeatures & features) const
659 string incfile = to_utf8(params()["filename"]);
662 BOOST_ASSERT(&buffer() == &features.buffer());
664 string const included_file =
665 includedFilename(buffer(), params()).availableFile().absFilename();
667 if (isLyXFilename(included_file))
668 writefile = changeExtension(included_file, ".sgml");
670 writefile = included_file;
672 if (!features.runparams().nice && !isVerbatim(params()) && !isListings(params())) {
673 incfile = DocFileName(writefile).mangledFilename();
674 writefile = makeAbsPath(incfile,
675 buffer().masterBuffer()->temppath()).absFilename();
678 features.includeFile(include_label, writefile);
680 if (isVerbatim(params()))
681 features.require("verbatim");
682 else if (isListings(params()))
683 features.require("listings");
685 // Here we must do the fun stuff...
686 // Load the file in the include if it needs
688 if (loadIfNeeded(buffer(), params())) {
690 Buffer * const tmp = theBufferList().getBuffer(included_file);
691 // make sure the buffer isn't us
692 // FIXME RECURSIVE INCLUDES
693 // This is not sufficient, as recursive includes could be
694 // more than a file away. But it will do for now.
695 if (tmp && tmp != &buffer()) {
696 // We must temporarily change features.buffer,
697 // otherwise it would always be the master buffer,
698 // and nested includes would not work.
699 features.setBuffer(*tmp);
700 tmp->validate(features);
701 features.setBuffer(buffer());
707 void InsetInclude::getLabelList(vector<docstring> & list) const
709 if (isListings(params()) && label_) {
710 label_->getLabelList(list);
714 if (loadIfNeeded(buffer(), params())) {
715 string const included_file = includedFilename(buffer(), params()).absFilename();
716 Buffer * tmp = theBufferList().getBuffer(included_file);
718 tmp->getLabelList(list);
719 tmp->setParent(const_cast<Buffer *>(&buffer()));
724 void InsetInclude::fillWithBibKeys(BiblioInfo & keys,
725 InsetIterator const & /*di*/) const
727 if (loadIfNeeded(buffer(), params())) {
728 string const included_file = includedFilename(buffer(), params()).absFilename();
729 Buffer * tmp = theBufferList().getBuffer(included_file);
730 //FIXME This is kind of a dirty hack and should be made reasonable.
732 keys.fillWithBibKeys(tmp);
733 tmp->setParent(&buffer());
738 void InsetInclude::updateBibfilesCache()
740 Buffer * const tmp = getChildBuffer(buffer(), params());
743 tmp->updateBibfilesCache();
744 tmp->setParent(&buffer());
749 EmbeddedFileList const &
750 InsetInclude::getBibfilesCache(Buffer const & buffer) const
752 Buffer * const tmp = getChildBuffer(buffer, params());
755 EmbeddedFileList const & cache = tmp->getBibfilesCache();
756 tmp->setParent(&buffer);
759 static EmbeddedFileList const empty;
764 void InsetInclude::metrics(MetricsInfo & mi, Dimension & dim) const
766 BOOST_ASSERT(mi.base.bv);
768 bool use_preview = false;
769 if (RenderPreview::status() != LyXRC::PREVIEW_OFF) {
770 graphics::PreviewImage const * pimage =
771 preview_->getPreviewImage(mi.base.bv->buffer());
772 use_preview = pimage && pimage->image();
776 preview_->metrics(mi, dim);
780 button_.update(screenLabel(), true);
782 button_.metrics(mi, dim);
785 Box b(0, dim.wid, -dim.asc, dim.des);
790 void InsetInclude::draw(PainterInfo & pi, int x, int y) const
792 BOOST_ASSERT(pi.base.bv);
794 bool use_preview = false;
795 if (RenderPreview::status() != LyXRC::PREVIEW_OFF) {
796 graphics::PreviewImage const * pimage =
797 preview_->getPreviewImage(pi.base.bv->buffer());
798 use_preview = pimage && pimage->image();
802 preview_->draw(pi, x, y);
804 button_.draw(pi, x, y);
808 Inset::DisplayType InsetInclude::display() const
810 return type(params()) == INPUT ? Inline : AlignCenter;
819 void InsetInclude::fileChanged() const
821 Buffer const * const buffer = updateFrontend();
825 preview_->removePreview(*buffer);
826 add_preview(*preview_.get(), *this, *buffer);
827 preview_->startLoading(*buffer);
833 bool preview_wanted(InsetCommandParams const & params, Buffer const & buffer)
835 FileName const included_file = includedFilename(buffer, params);
837 return type(params) == INPUT && params.preview() &&
838 included_file.isReadableFile();
842 docstring latexString(InsetInclude const & inset)
845 // We don't need to set runparams.encoding since this will be done
846 // by latex() anyway.
847 OutputParams runparams(0);
848 runparams.flavor = OutputParams::LATEX;
849 inset.latex(os, runparams);
855 void add_preview(RenderMonitoredPreview & renderer, InsetInclude const & inset,
856 Buffer const & buffer)
858 InsetCommandParams const & params = inset.params();
859 if (RenderPreview::status() != LyXRC::PREVIEW_OFF &&
860 preview_wanted(params, buffer)) {
861 renderer.setAbsFile(includedFilename(buffer, params));
862 docstring const snippet = latexString(inset);
863 renderer.addPreview(snippet, buffer);
870 void InsetInclude::addPreview(graphics::PreviewLoader & ploader) const
872 Buffer const & buffer = ploader.buffer();
873 if (!preview_wanted(params(), buffer))
875 preview_->setAbsFile(includedFilename(buffer, params()));
876 docstring const snippet = latexString(*this);
877 preview_->addPreview(snippet, ploader);
881 void InsetInclude::addToToc(ParConstIterator const & cpit) const
883 if (isListings(params())) {
885 label_->addToToc(cpit);
887 InsetListingsParams p(to_utf8(params()["lstparams"]));
888 string caption = p.getParamValue("caption");
891 Toc & toc = buffer().tocBackend().toc("listing");
892 docstring const str = convert<docstring>(toc.size() + 1)
893 + ". " + from_utf8(caption);
894 ParConstIterator pit = cpit;
895 pit.push_back(*this);
896 toc.push_back(TocItem(pit, 0, str));
899 Buffer const * const childbuffer = getChildBuffer(buffer(), params());
903 TocList & toclist = buffer().tocBackend().tocs();
904 TocList const & childtoclist = childbuffer->tocBackend().tocs();
905 TocList::const_iterator it = childtoclist.begin();
906 TocList::const_iterator const end = childtoclist.end();
907 for(; it != end; ++it)
908 toclist[it->first].insert(toclist[it->first].end(),
909 it->second.begin(), it->second.end());
913 void InsetInclude::updateLabels(ParIterator const & it)
915 Buffer const * const childbuffer = getChildBuffer(buffer(), params());
917 lyx::updateLabels(*childbuffer, true);
920 if (!isListings(params()))
924 label_->updateLabels(it);
926 InsetListingsParams const par(to_utf8(params()["lstparams"]));
927 if (par.getParamValue("caption").empty()) {
928 listings_label_.clear();
931 Counters & counters = buffer().params().documentClass().counters();
932 docstring const cnt = from_ascii("listing");
933 listings_label_ = buffer().B_("Program Listing");
934 if (counters.hasCounter(cnt)) {
936 listings_label_ += " " + convert<docstring>(counters.value(cnt));
941 void InsetInclude::registerEmbeddedFiles(EmbeddedFileList & files) const
943 files.registerFile(includedFilename(buffer(), params()), this, buffer());
947 void InsetInclude::updateEmbeddedFile(EmbeddedFile const & file)
949 InsetCommandParams p = params();
950 p["filename"] = from_utf8(file.outputFilename());
951 p["embed"] = file.embedded() ? from_utf8(file.inzipName()) : docstring();