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()
190 if (isVerbatim(params()) || isListings(params()))
194 string const parent_filename = buffer().absFileName();
195 FileName const included_file = makeAbsPath(to_utf8(params()["filename"]),
196 onlyPath(parent_filename));
198 if (!isLyXFilename(included_file.absFilename()))
201 Buffer * child = theBufferList().getBuffer(included_file.absFilename());
202 // File not opened, nothing to close.
206 // Child document has a different parent, don't close it.
207 if (child->parent() != &buffer())
211 theBufferList().release(child);
215 void InsetInclude::setBuffer(Buffer & buffer)
219 label_->setBuffer(buffer);
224 ParamInfo const & InsetInclude::findInfo(string const & /* cmdName */)
227 // This is only correct for the case of listings, but it'll do for now.
228 // In the other cases, this second parameter should just be empty.
229 static ParamInfo param_info_;
230 if (param_info_.empty()) {
231 param_info_.add("filename", ParamInfo::LATEX_REQUIRED);
232 param_info_.add("lstparams", ParamInfo::LATEX_OPTIONAL);
233 param_info_.add("embed", ParamInfo::LYX_INTERNAL);
239 bool InsetInclude::isCompatibleCommand(string const & s)
241 return type(s) != NONE;
245 void InsetInclude::doDispatch(Cursor & cur, FuncRequest & cmd)
247 BOOST_ASSERT(&cur.buffer() == &buffer());
248 switch (cmd.action) {
250 case LFUN_INSET_MODIFY: {
251 InsetCommandParams p(INCLUDE_CODE);
252 InsetCommandMailer::string2params("include", to_utf8(cmd.argument()), p);
253 if (!p.getCmdName().empty()) {
255 InsetListingsParams new_params(to_utf8(p["lstparams"]));
256 docstring const label_str = from_utf8(new_params.getParamValue("label"));
257 if (label_str.empty())
260 label_->updateCommand(label_str);
262 label_ = createLabel(label_str);
263 label_->setBuffer(buffer());
268 // the embed parameter passed back from the dialog
269 // is "true" or "false", we need to change it.
270 if (p["embed"] == _("false"))
273 p["embed"] = from_utf8(EmbeddedFile(to_utf8(p["filename"]),
274 onlyPath(parentFilename(cur.buffer()))).inzipName());
276 includedFilename(cur.buffer(), p);
277 } catch (ExceptionMessage const & message) {
278 Alert::error(message.title_, message.details_);
279 // do not set parameter if an error happens
283 buffer().updateBibfilesCache();
289 //pass everything else up the chain
291 InsetCommand::doDispatch(cur, cmd);
297 void InsetInclude::setParams(InsetCommandParams const & p)
299 InsetCommand::setParams(p);
302 if (preview_->monitoring())
303 preview_->stopMonitoring();
305 if (type(params()) == INPUT)
306 add_preview(*preview_, *this, buffer());
310 docstring InsetInclude::screenLabel() const
314 switch (type(params())) {
316 temp = buffer().B_("Input");
319 temp = buffer().B_("Verbatim Input");
322 temp = buffer().B_("Verbatim Input*");
325 temp = buffer().B_("Include");
328 temp = listings_label_;
336 if (params()["filename"].empty())
339 temp += from_utf8(onlyFilename(to_utf8(params()["filename"])));
341 if (!params()["embed"].empty())
342 temp += _(" (embedded)");
347 /// return the child buffer if the file is a LyX doc and is loaded
348 Buffer * getChildBuffer(Buffer const & buffer, InsetCommandParams const & params)
350 if (isVerbatim(params) || isListings(params))
353 string const included_file = includedFilename(buffer, params).absFilename();
354 if (!isLyXFilename(included_file))
357 Buffer * childBuffer = loadIfNeeded(buffer, params);
359 // FIXME: recursive includes
360 return (childBuffer == &buffer) ? 0 : childBuffer;
364 /// return true if the file is or got loaded.
365 Buffer * loadIfNeeded(Buffer const & parent, InsetCommandParams const & params)
367 if (isVerbatim(params) || isListings(params))
370 string const parent_filename = parent.absFileName();
371 FileName const included_file = makeAbsPath(to_utf8(params["filename"]),
372 onlyPath(parent_filename));
374 if (!isLyXFilename(included_file.absFilename()))
377 Buffer * child = theBufferList().getBuffer(included_file.absFilename());
379 // the readonly flag can/will be wrong, not anymore I think.
380 if (!included_file.exists())
383 child = theBufferList().newBuffer(included_file.absFilename());
385 // Buffer creation is not possible.
388 if (!child->loadLyXFile(included_file)) {
389 //close the buffer we just opened
390 theBufferList().release(child);
394 if (!child->errorList("Parse").empty()) {
395 // FIXME: Do something.
398 child->setParent(&parent);
403 int InsetInclude::latex(odocstream & os, OutputParams const & runparams) const
405 string incfile = to_utf8(params()["filename"]);
407 // Do nothing if no file name has been specified
411 FileName const included_file =
412 includedFilename(buffer(), params()).availableFile();
414 // Check we're not trying to include ourselves.
415 // FIXME RECURSIVE INCLUDE
416 // This isn't sufficient, as the inclusion could be downstream.
417 // But it'll have to do for now.
418 if (isInputOrInclude(params()) &&
419 buffer().absFileName() == included_file.absFilename())
421 Alert::error(_("Recursive input"),
422 bformat(_("Attempted to include file %1$s in itself! "
423 "Ignoring inclusion."), from_utf8(incfile)));
427 Buffer const * const masterBuffer = buffer().masterBuffer();
429 // if incfile is relative, make it relative to the master
431 if (!FileName(incfile).isAbsolute()) {
433 incfile = to_utf8(makeRelPath(from_utf8(included_file.absFilename()),
434 from_utf8(masterBuffer->filePath())));
437 // write it to a file (so far the complete file)
438 string const exportfile = changeExtension(incfile, ".tex");
439 string const mangled =
440 DocFileName(changeExtension(included_file.absFilename(),".tex")).
442 FileName const writefile(makeAbsPath(mangled, masterBuffer->temppath()));
446 else if (!isValidLaTeXFilename(incfile)) {
447 frontend::Alert::warning(_("Invalid filename"),
448 _("The following filename is likely to cause trouble "
449 "when running the exported file through LaTeX: ") +
452 LYXERR(Debug::LATEX, "incfile:" << incfile);
453 LYXERR(Debug::LATEX, "exportfile:" << exportfile);
454 LYXERR(Debug::LATEX, "writefile:" << writefile);
456 if (runparams.inComment || runparams.dryrun) {
457 //Don't try to load or copy the file if we're
458 //in a comment or doing a dryrun
459 } else if (isInputOrInclude(params()) &&
460 isLyXFilename(included_file.absFilename())) {
461 //if it's a LyX file and we're inputting or including,
462 //try to load it so we can write the associated latex
463 if (!loadIfNeeded(buffer(), params()))
466 Buffer * tmp = theBufferList().getBuffer(included_file.absFilename());
468 if (tmp->params().baseClass() != masterBuffer->params().baseClass()) {
470 docstring text = bformat(_("Included file `%1$s'\n"
471 "has textclass `%2$s'\n"
472 "while parent file has textclass `%3$s'."),
473 included_file.displayName(),
474 from_utf8(tmp->params().documentClass().name()),
475 from_utf8(masterBuffer->params().documentClass().name()));
476 Alert::warning(_("Different textclasses"), text);
480 // Make sure modules used in child are all included in master
481 //FIXME It might be worth loading the children's modules into the master
482 //over in BufferParams rather than doing this check.
483 vector<string> const masterModules = masterBuffer->params().getModules();
484 vector<string> const childModules = tmp->params().getModules();
485 vector<string>::const_iterator it = childModules.begin();
486 vector<string>::const_iterator end = childModules.end();
487 for (; it != end; ++it) {
488 string const module = *it;
489 vector<string>::const_iterator found =
490 find(masterModules.begin(), masterModules.end(), module);
491 if (found != masterModules.end()) {
492 docstring text = bformat(_("Included file `%1$s'\n"
493 "uses module `%2$s'\n"
494 "which is not used in parent file."),
495 included_file.displayName(), from_utf8(module));
496 Alert::warning(_("Module not found"), text);
500 tmp->markDepClean(masterBuffer->temppath());
502 // FIXME: handle non existing files
503 // FIXME: Second argument is irrelevant!
504 // since only_body is true, makeLaTeXFile will not look at second
505 // argument. Should we set it to string(), or should makeLaTeXFile
506 // make use of it somehow? (JMarc 20031002)
507 // The included file might be written in a different encoding
508 Encoding const * const oldEnc = runparams.encoding;
509 runparams.encoding = &tmp->params().encoding();
510 tmp->makeLaTeXFile(writefile,
511 masterFileName(buffer()).onlyPath().absFilename(),
513 runparams.encoding = oldEnc;
515 // In this case, it's not a LyX file, so we copy the file
516 // to the temp dir, so that .aux files etc. are not created
517 // in the original dir. Files included by this file will be
518 // found via input@path, see ../Buffer.cpp.
519 unsigned long const checksum_in = included_file.checksum();
520 unsigned long const checksum_out = writefile.checksum();
522 if (checksum_in != checksum_out) {
523 if (!included_file.copyTo(writefile)) {
526 to_utf8(bformat(_("Could not copy the file\n%1$s\n"
527 "into the temporary directory."),
528 from_utf8(included_file.absFilename()))));
534 string const tex_format = (runparams.flavor == OutputParams::LATEX) ?
535 "latex" : "pdflatex";
536 if (isVerbatim(params())) {
537 incfile = latex_path(incfile);
539 os << '\\' << from_ascii(params().getCmdName()) << '{'
540 << from_utf8(incfile) << '}';
541 } else if (type(params()) == INPUT) {
542 runparams.exportdata->addExternalFile(tex_format, writefile,
545 // \input wants file with extension (default is .tex)
546 if (!isLyXFilename(included_file.absFilename())) {
547 incfile = latex_path(incfile);
549 os << '\\' << from_ascii(params().getCmdName())
550 << '{' << from_utf8(incfile) << '}';
552 incfile = changeExtension(incfile, ".tex");
553 incfile = latex_path(incfile);
555 os << '\\' << from_ascii(params().getCmdName())
556 << '{' << from_utf8(incfile) << '}';
558 } else if (type(params()) == LISTINGS) {
559 os << '\\' << from_ascii(params().getCmdName());
560 string const opt = to_utf8(params()["lstparams"]);
561 // opt is set in QInclude dialog and should have passed validation.
562 InsetListingsParams params(opt);
563 if (!params.params().empty())
564 os << "[" << from_utf8(params.params()) << "]";
565 os << '{' << from_utf8(incfile) << '}';
567 runparams.exportdata->addExternalFile(tex_format, writefile,
570 // \include don't want extension and demands that the
571 // file really have .tex
572 incfile = changeExtension(incfile, string());
573 incfile = latex_path(incfile);
575 os << '\\' << from_ascii(params().getCmdName()) << '{'
576 << from_utf8(incfile) << '}';
583 int InsetInclude::plaintext(odocstream & os, OutputParams const &) const
585 if (isVerbatim(params()) || isListings(params())) {
586 os << '[' << screenLabel() << '\n';
587 // FIXME: We don't know the encoding of the file, default to UTF-8.
588 os << includedFilename(buffer(), params()).fileContents("UTF-8");
590 return PLAINTEXT_NEWLINE + 1; // one char on a separate line
592 docstring const str = '[' + screenLabel() + ']';
599 int InsetInclude::docbook(odocstream & os, OutputParams const & runparams) const
601 string incfile = to_utf8(params()["filename"]);
603 // Do nothing if no file name has been specified
607 string const included_file = includedFilename(buffer(), params()).absFilename();
609 // Check we're not trying to include ourselves.
610 // FIXME RECURSIVE INCLUDE
611 // This isn't sufficient, as the inclusion could be downstream.
612 // But it'll have to do for now.
613 if (buffer().absFileName() == included_file) {
614 Alert::error(_("Recursive input"),
615 bformat(_("Attempted to include file %1$s in itself! "
616 "Ignoring inclusion."), from_utf8(incfile)));
620 // write it to a file (so far the complete file)
621 string const exportfile = changeExtension(incfile, ".sgml");
622 DocFileName writefile(changeExtension(included_file, ".sgml"));
624 if (loadIfNeeded(buffer(), params())) {
625 Buffer * tmp = theBufferList().getBuffer(included_file);
627 string const mangled = writefile.mangledFilename();
628 writefile = makeAbsPath(mangled,
629 buffer().masterBuffer()->temppath());
633 LYXERR(Debug::LATEX, "incfile:" << incfile);
634 LYXERR(Debug::LATEX, "exportfile:" << exportfile);
635 LYXERR(Debug::LATEX, "writefile:" << writefile);
637 tmp->makeDocBookFile(writefile, runparams, true);
640 runparams.exportdata->addExternalFile("docbook", writefile,
642 runparams.exportdata->addExternalFile("docbook-xml", writefile,
645 if (isVerbatim(params()) || isListings(params())) {
646 os << "<inlinegraphic fileref=\""
647 << '&' << include_label << ';'
648 << "\" format=\"linespecific\">";
650 os << '&' << include_label << ';';
656 void InsetInclude::validate(LaTeXFeatures & features) const
658 string incfile = to_utf8(params()["filename"]);
661 BOOST_ASSERT(&buffer() == &features.buffer());
663 string const included_file =
664 includedFilename(buffer(), params()).availableFile().absFilename();
666 if (isLyXFilename(included_file))
667 writefile = changeExtension(included_file, ".sgml");
669 writefile = included_file;
671 if (!features.runparams().nice && !isVerbatim(params()) && !isListings(params())) {
672 incfile = DocFileName(writefile).mangledFilename();
673 writefile = makeAbsPath(incfile,
674 buffer().masterBuffer()->temppath()).absFilename();
677 features.includeFile(include_label, writefile);
679 if (isVerbatim(params()))
680 features.require("verbatim");
681 else if (isListings(params()))
682 features.require("listings");
684 // Here we must do the fun stuff...
685 // Load the file in the include if it needs
687 if (loadIfNeeded(buffer(), params())) {
689 Buffer * const tmp = theBufferList().getBuffer(included_file);
690 // make sure the buffer isn't us
691 // FIXME RECURSIVE INCLUDES
692 // This is not sufficient, as recursive includes could be
693 // more than a file away. But it will do for now.
694 if (tmp && tmp != &buffer()) {
695 // We must temporarily change features.buffer,
696 // otherwise it would always be the master buffer,
697 // and nested includes would not work.
698 features.setBuffer(*tmp);
699 tmp->validate(features);
700 features.setBuffer(buffer());
706 void InsetInclude::getLabelList(vector<docstring> & list) const
708 if (isListings(params()) && label_) {
709 label_->getLabelList(list);
713 if (loadIfNeeded(buffer(), params())) {
714 string const included_file = includedFilename(buffer(), params()).absFilename();
715 Buffer * tmp = theBufferList().getBuffer(included_file);
717 tmp->getLabelList(list);
718 tmp->setParent(const_cast<Buffer *>(&buffer()));
723 void InsetInclude::fillWithBibKeys(BiblioInfo & keys,
724 InsetIterator const & /*di*/) const
726 if (loadIfNeeded(buffer(), params())) {
727 string const included_file = includedFilename(buffer(), params()).absFilename();
728 Buffer * tmp = theBufferList().getBuffer(included_file);
729 //FIXME This is kind of a dirty hack and should be made reasonable.
731 keys.fillWithBibKeys(tmp);
732 tmp->setParent(&buffer());
737 void InsetInclude::updateBibfilesCache()
739 Buffer * const tmp = getChildBuffer(buffer(), params());
742 tmp->updateBibfilesCache();
743 tmp->setParent(&buffer());
748 EmbeddedFileList const &
749 InsetInclude::getBibfilesCache(Buffer const & buffer) const
751 Buffer * const tmp = getChildBuffer(buffer, params());
754 EmbeddedFileList const & cache = tmp->getBibfilesCache();
755 tmp->setParent(&buffer);
758 static EmbeddedFileList const empty;
763 void InsetInclude::metrics(MetricsInfo & mi, Dimension & dim) const
765 BOOST_ASSERT(mi.base.bv);
767 bool use_preview = false;
768 if (RenderPreview::status() != LyXRC::PREVIEW_OFF) {
769 graphics::PreviewImage const * pimage =
770 preview_->getPreviewImage(mi.base.bv->buffer());
771 use_preview = pimage && pimage->image();
775 preview_->metrics(mi, dim);
779 button_.update(screenLabel(), true);
781 button_.metrics(mi, dim);
784 Box b(0, dim.wid, -dim.asc, dim.des);
789 void InsetInclude::draw(PainterInfo & pi, int x, int y) const
791 BOOST_ASSERT(pi.base.bv);
793 bool use_preview = false;
794 if (RenderPreview::status() != LyXRC::PREVIEW_OFF) {
795 graphics::PreviewImage const * pimage =
796 preview_->getPreviewImage(pi.base.bv->buffer());
797 use_preview = pimage && pimage->image();
801 preview_->draw(pi, x, y);
803 button_.draw(pi, x, y);
807 Inset::DisplayType InsetInclude::display() const
809 return type(params()) == INPUT ? Inline : AlignCenter;
818 void InsetInclude::fileChanged() const
820 Buffer const * const buffer = updateFrontend();
824 preview_->removePreview(*buffer);
825 add_preview(*preview_.get(), *this, *buffer);
826 preview_->startLoading(*buffer);
832 bool preview_wanted(InsetCommandParams const & params, Buffer const & buffer)
834 FileName const included_file = includedFilename(buffer, params);
836 return type(params) == INPUT && params.preview() &&
837 included_file.isReadableFile();
841 docstring latexString(InsetInclude const & inset)
844 // We don't need to set runparams.encoding since this will be done
845 // by latex() anyway.
846 OutputParams runparams(0);
847 runparams.flavor = OutputParams::LATEX;
848 inset.latex(os, runparams);
854 void add_preview(RenderMonitoredPreview & renderer, InsetInclude const & inset,
855 Buffer const & buffer)
857 InsetCommandParams const & params = inset.params();
858 if (RenderPreview::status() != LyXRC::PREVIEW_OFF &&
859 preview_wanted(params, buffer)) {
860 renderer.setAbsFile(includedFilename(buffer, params));
861 docstring const snippet = latexString(inset);
862 renderer.addPreview(snippet, buffer);
869 void InsetInclude::addPreview(graphics::PreviewLoader & ploader) const
871 Buffer const & buffer = ploader.buffer();
872 if (!preview_wanted(params(), buffer))
874 preview_->setAbsFile(includedFilename(buffer, params()));
875 docstring const snippet = latexString(*this);
876 preview_->addPreview(snippet, ploader);
880 void InsetInclude::addToToc(ParConstIterator const & cpit) const
882 if (isListings(params())) {
884 label_->addToToc(cpit);
886 InsetListingsParams p(to_utf8(params()["lstparams"]));
887 string caption = p.getParamValue("caption");
890 Toc & toc = buffer().tocBackend().toc("listing");
891 docstring const str = convert<docstring>(toc.size() + 1)
892 + ". " + from_utf8(caption);
893 ParConstIterator pit = cpit;
894 pit.push_back(*this);
895 toc.push_back(TocItem(pit, 0, str));
898 Buffer const * const childbuffer = getChildBuffer(buffer(), params());
902 TocList & toclist = buffer().tocBackend().tocs();
903 TocList const & childtoclist = childbuffer->tocBackend().tocs();
904 TocList::const_iterator it = childtoclist.begin();
905 TocList::const_iterator const end = childtoclist.end();
906 for(; it != end; ++it)
907 toclist[it->first].insert(toclist[it->first].end(),
908 it->second.begin(), it->second.end());
912 void InsetInclude::updateLabels(ParIterator const & it)
914 Buffer const * const childbuffer = getChildBuffer(buffer(), params());
916 lyx::updateLabels(*childbuffer, true);
919 if (!isListings(params()))
923 label_->updateLabels(it);
925 InsetListingsParams const par(to_utf8(params()["lstparams"]));
926 if (par.getParamValue("caption").empty()) {
927 listings_label_.clear();
930 Counters & counters = buffer().params().documentClass().counters();
931 docstring const cnt = from_ascii("listing");
932 listings_label_ = buffer().B_("Program Listing");
933 if (counters.hasCounter(cnt)) {
935 listings_label_ += " " + convert<docstring>(counters.value(cnt));
940 void InsetInclude::registerEmbeddedFiles(EmbeddedFileList & files) const
942 files.registerFile(includedFilename(buffer(), params()), this, buffer());
946 void InsetInclude::updateEmbeddedFile(EmbeddedFile const & file)
948 InsetCommandParams p = params();
949 p["filename"] = from_utf8(file.outputFilename());
950 p["embed"] = file.embedded() ? from_utf8(file.inzipName()) : docstring();