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.setInzipName(to_utf8(params["embed"]));
149 file.enable(buffer.embedded(), &buffer, false);
153 InsetLabel * createLabel(docstring const & label_str)
155 if (label_str.empty())
157 InsetCommandParams icp(LABEL_CODE);
158 icp["name"] = label_str;
159 return new InsetLabel(icp);
165 InsetInclude::InsetInclude(InsetCommandParams const & p)
166 : InsetCommand(p, "include"), include_label(uniqueID()),
167 preview_(new RenderMonitoredPreview(this)), set_label_(false), label_(0)
169 preview_->fileChanged(boost::bind(&InsetInclude::fileChanged, this));
171 if (isListings(params())) {
172 InsetListingsParams listing_params(to_utf8(p["lstparams"]));
173 label_ = createLabel(from_utf8(listing_params.getParamValue("label")));
178 InsetInclude::InsetInclude(InsetInclude const & other)
179 : InsetCommand(other), include_label(other.include_label),
180 preview_(new RenderMonitoredPreview(this)), set_label_(false), label_(0)
182 preview_->fileChanged(boost::bind(&InsetInclude::fileChanged, this));
185 label_ = new InsetLabel(*other.label_);
189 InsetInclude::~InsetInclude()
192 if (isVerbatim(params()) || isListings(params()))
196 string const parent_filename = buffer().absFileName();
197 FileName const included_file = makeAbsPath(to_utf8(params()["filename"]),
198 onlyPath(parent_filename));
200 if (!isLyXFilename(included_file.absFilename()))
203 Buffer * child = theBufferList().getBuffer(included_file.absFilename());
204 // File not opened, nothing to close.
208 // Child document has a different parent, don't close it.
209 if (child->parent() != &buffer())
213 theBufferList().release(child);
217 void InsetInclude::setBuffer(Buffer & buffer)
221 label_->setBuffer(buffer);
226 ParamInfo const & InsetInclude::findInfo(string const & /* cmdName */)
229 // This is only correct for the case of listings, but it'll do for now.
230 // In the other cases, this second parameter should just be empty.
231 static ParamInfo param_info_;
232 if (param_info_.empty()) {
233 param_info_.add("filename", ParamInfo::LATEX_REQUIRED);
234 param_info_.add("lstparams", ParamInfo::LATEX_OPTIONAL);
235 param_info_.add("embed", ParamInfo::LYX_INTERNAL);
241 bool InsetInclude::isCompatibleCommand(string const & s)
243 return type(s) != NONE;
247 void InsetInclude::doDispatch(Cursor & cur, FuncRequest & cmd)
249 BOOST_ASSERT(&cur.buffer() == &buffer());
250 switch (cmd.action) {
252 case LFUN_INSET_MODIFY: {
253 InsetCommandParams p(INCLUDE_CODE);
254 InsetCommandMailer::string2params("include", to_utf8(cmd.argument()), p);
255 if (!p.getCmdName().empty()) {
256 Buffer const & buf = cur.buffer();
258 InsetListingsParams new_params(to_utf8(p["lstparams"]));
259 docstring const label_str = from_utf8(new_params.getParamValue("label"));
260 if (label_str.empty())
263 label_->updateCommand(label_str);
265 label_ = createLabel(label_str);
266 label_->setBuffer(buffer());
271 // the embed parameter passed back from the dialog
272 // is "true" or "false", we need to change it.
273 EmbeddedFile file = EmbeddedFile(to_utf8(p["filename"]),
274 onlyPath(parentFilename(buf)));
275 file.setEmbed(p["embed"] == _("true"));
276 // move file around if needed, an exception may be raised.
277 file.enable(buf.embedded(), &buf, true);
278 // if things are OK..., set p["embed"]
280 p["embed"] = from_utf8(file.inzipName());
283 } catch (ExceptionMessage const & message) {
284 Alert::error(message.title_, message.details_);
285 // do not set parameter if an error happens
289 buffer().updateBibfilesCache();
295 //pass everything else up the chain
297 InsetCommand::doDispatch(cur, cmd);
303 void InsetInclude::setParams(InsetCommandParams const & p)
305 InsetCommand::setParams(p);
308 if (preview_->monitoring())
309 preview_->stopMonitoring();
311 if (type(params()) == INPUT)
312 add_preview(*preview_, *this, buffer());
316 docstring InsetInclude::screenLabel() const
320 switch (type(params())) {
322 temp = buffer().B_("Input");
325 temp = buffer().B_("Verbatim Input");
328 temp = buffer().B_("Verbatim Input*");
331 temp = buffer().B_("Include");
334 temp = listings_label_;
342 if (params()["filename"].empty())
345 temp += from_utf8(onlyFilename(to_utf8(params()["filename"])));
347 if (!params()["embed"].empty())
348 temp += _(" (embedded)");
353 /// return the child buffer if the file is a LyX doc and is loaded
354 Buffer * getChildBuffer(Buffer const & buffer, InsetCommandParams const & params)
356 if (isVerbatim(params) || isListings(params))
359 string const included_file = includedFilename(buffer, params).absFilename();
360 if (!isLyXFilename(included_file))
363 Buffer * childBuffer = loadIfNeeded(buffer, params);
365 // FIXME: recursive includes
366 return (childBuffer == &buffer) ? 0 : childBuffer;
370 /// return true if the file is or got loaded.
371 Buffer * loadIfNeeded(Buffer const & parent, InsetCommandParams const & params)
373 if (isVerbatim(params) || isListings(params))
376 string const parent_filename = parent.absFileName();
377 FileName const included_file = makeAbsPath(to_utf8(params["filename"]),
378 onlyPath(parent_filename));
380 if (!isLyXFilename(included_file.absFilename()))
383 Buffer * child = theBufferList().getBuffer(included_file.absFilename());
385 // the readonly flag can/will be wrong, not anymore I think.
386 if (!included_file.exists())
389 child = theBufferList().newBuffer(included_file.absFilename());
391 // Buffer creation is not possible.
394 if (!child->loadLyXFile(included_file)) {
395 //close the buffer we just opened
396 theBufferList().release(child);
400 if (!child->errorList("Parse").empty()) {
401 // FIXME: Do something.
404 child->setParent(&parent);
409 int InsetInclude::latex(odocstream & os, OutputParams const & runparams) const
411 string incfile = to_utf8(params()["filename"]);
413 // Do nothing if no file name has been specified
417 FileName const included_file =
418 includedFilename(buffer(), params()).availableFile();
420 // Check we're not trying to include ourselves.
421 // FIXME RECURSIVE INCLUDE
422 // This isn't sufficient, as the inclusion could be downstream.
423 // But it'll have to do for now.
424 if (isInputOrInclude(params()) &&
425 buffer().absFileName() == included_file.absFilename())
427 Alert::error(_("Recursive input"),
428 bformat(_("Attempted to include file %1$s in itself! "
429 "Ignoring inclusion."), from_utf8(incfile)));
433 Buffer const * const masterBuffer = buffer().masterBuffer();
435 // if incfile is relative, make it relative to the master
437 if (!FileName(incfile).isAbsolute()) {
439 incfile = to_utf8(makeRelPath(from_utf8(included_file.absFilename()),
440 from_utf8(masterBuffer->filePath())));
443 // write it to a file (so far the complete file)
444 string const exportfile = changeExtension(incfile, ".tex");
445 string const mangled =
446 DocFileName(changeExtension(included_file.absFilename(),".tex")).
448 FileName const writefile(makeAbsPath(mangled, masterBuffer->temppath()));
452 else if (!isValidLaTeXFilename(incfile)) {
453 frontend::Alert::warning(_("Invalid filename"),
454 _("The following filename is likely to cause trouble "
455 "when running the exported file through LaTeX: ") +
458 LYXERR(Debug::LATEX, "incfile:" << incfile);
459 LYXERR(Debug::LATEX, "exportfile:" << exportfile);
460 LYXERR(Debug::LATEX, "writefile:" << writefile);
462 if (runparams.inComment || runparams.dryrun) {
463 //Don't try to load or copy the file if we're
464 //in a comment or doing a dryrun
465 } else if (isInputOrInclude(params()) &&
466 isLyXFilename(included_file.absFilename())) {
467 //if it's a LyX file and we're inputting or including,
468 //try to load it so we can write the associated latex
469 if (!loadIfNeeded(buffer(), params()))
472 Buffer * tmp = theBufferList().getBuffer(included_file.absFilename());
474 if (tmp->params().baseClass() != masterBuffer->params().baseClass()) {
476 docstring text = bformat(_("Included file `%1$s'\n"
477 "has textclass `%2$s'\n"
478 "while parent file has textclass `%3$s'."),
479 included_file.displayName(),
480 from_utf8(tmp->params().documentClass().name()),
481 from_utf8(masterBuffer->params().documentClass().name()));
482 Alert::warning(_("Different textclasses"), text);
485 // Make sure modules used in child are all included in master
486 //FIXME It might be worth loading the children's modules into the master
487 //over in BufferParams rather than doing this check.
488 vector<string> const masterModules = masterBuffer->params().getModules();
489 vector<string> const childModules = tmp->params().getModules();
490 vector<string>::const_iterator it = childModules.begin();
491 vector<string>::const_iterator end = childModules.end();
492 for (; it != end; ++it) {
493 string const module = *it;
494 vector<string>::const_iterator found =
495 find(masterModules.begin(), masterModules.end(), module);
496 if (found != masterModules.end()) {
497 docstring text = bformat(_("Included file `%1$s'\n"
498 "uses module `%2$s'\n"
499 "which is not used in parent file."),
500 included_file.displayName(), from_utf8(module));
501 Alert::warning(_("Module not found"), text);
505 tmp->markDepClean(masterBuffer->temppath());
507 // FIXME: handle non existing files
508 // FIXME: Second argument is irrelevant!
509 // since only_body is true, makeLaTeXFile will not look at second
510 // argument. Should we set it to string(), or should makeLaTeXFile
511 // make use of it somehow? (JMarc 20031002)
512 // The included file might be written in a different encoding
513 Encoding const * const oldEnc = runparams.encoding;
514 runparams.encoding = &tmp->params().encoding();
515 tmp->makeLaTeXFile(writefile,
516 masterFileName(buffer()).onlyPath().absFilename(),
518 runparams.encoding = oldEnc;
520 // In this case, it's not a LyX file, so we copy the file
521 // to the temp dir, so that .aux files etc. are not created
522 // in the original dir. Files included by this file will be
523 // found via input@path, see ../Buffer.cpp.
524 unsigned long const checksum_in = included_file.checksum();
525 unsigned long const checksum_out = writefile.checksum();
527 if (checksum_in != checksum_out) {
528 if (!included_file.copyTo(writefile)) {
531 to_utf8(bformat(_("Could not copy the file\n%1$s\n"
532 "into the temporary directory."),
533 from_utf8(included_file.absFilename()))));
539 string const tex_format = (runparams.flavor == OutputParams::LATEX) ?
540 "latex" : "pdflatex";
541 if (isVerbatim(params())) {
542 incfile = latex_path(incfile);
544 os << '\\' << from_ascii(params().getCmdName()) << '{'
545 << from_utf8(incfile) << '}';
546 } else if (type(params()) == INPUT) {
547 runparams.exportdata->addExternalFile(tex_format, writefile,
550 // \input wants file with extension (default is .tex)
551 if (!isLyXFilename(included_file.absFilename())) {
552 incfile = latex_path(incfile);
554 os << '\\' << from_ascii(params().getCmdName())
555 << '{' << from_utf8(incfile) << '}';
557 incfile = changeExtension(incfile, ".tex");
558 incfile = latex_path(incfile);
560 os << '\\' << from_ascii(params().getCmdName())
561 << '{' << from_utf8(incfile) << '}';
563 } else if (type(params()) == LISTINGS) {
564 os << '\\' << from_ascii(params().getCmdName());
565 string const opt = to_utf8(params()["lstparams"]);
566 // opt is set in QInclude dialog and should have passed validation.
567 InsetListingsParams params(opt);
568 if (!params.params().empty())
569 os << "[" << from_utf8(params.params()) << "]";
570 os << '{' << from_utf8(incfile) << '}';
572 runparams.exportdata->addExternalFile(tex_format, writefile,
575 // \include don't want extension and demands that the
576 // file really have .tex
577 incfile = changeExtension(incfile, string());
578 incfile = latex_path(incfile);
580 os << '\\' << from_ascii(params().getCmdName()) << '{'
581 << from_utf8(incfile) << '}';
588 int InsetInclude::plaintext(odocstream & os, OutputParams const &) const
590 if (isVerbatim(params()) || isListings(params())) {
591 os << '[' << screenLabel() << '\n';
592 // FIXME: We don't know the encoding of the file, default to UTF-8.
593 os << includedFilename(buffer(), params()).fileContents("UTF-8");
595 return PLAINTEXT_NEWLINE + 1; // one char on a separate line
597 docstring const str = '[' + screenLabel() + ']';
604 int InsetInclude::docbook(odocstream & os, OutputParams const & runparams) const
606 string incfile = to_utf8(params()["filename"]);
608 // Do nothing if no file name has been specified
612 string const included_file = includedFilename(buffer(), params()).absFilename();
614 // Check we're not trying to include ourselves.
615 // FIXME RECURSIVE INCLUDE
616 // This isn't sufficient, as the inclusion could be downstream.
617 // But it'll have to do for now.
618 if (buffer().absFileName() == included_file) {
619 Alert::error(_("Recursive input"),
620 bformat(_("Attempted to include file %1$s in itself! "
621 "Ignoring inclusion."), from_utf8(incfile)));
625 // write it to a file (so far the complete file)
626 string const exportfile = changeExtension(incfile, ".sgml");
627 DocFileName writefile(changeExtension(included_file, ".sgml"));
629 if (loadIfNeeded(buffer(), params())) {
630 Buffer * tmp = theBufferList().getBuffer(included_file);
632 string const mangled = writefile.mangledFilename();
633 writefile = makeAbsPath(mangled,
634 buffer().masterBuffer()->temppath());
638 LYXERR(Debug::LATEX, "incfile:" << incfile);
639 LYXERR(Debug::LATEX, "exportfile:" << exportfile);
640 LYXERR(Debug::LATEX, "writefile:" << writefile);
642 tmp->makeDocBookFile(writefile, runparams, true);
645 runparams.exportdata->addExternalFile("docbook", writefile,
647 runparams.exportdata->addExternalFile("docbook-xml", writefile,
650 if (isVerbatim(params()) || isListings(params())) {
651 os << "<inlinegraphic fileref=\""
652 << '&' << include_label << ';'
653 << "\" format=\"linespecific\">";
655 os << '&' << include_label << ';';
661 void InsetInclude::validate(LaTeXFeatures & features) const
663 string incfile = to_utf8(params()["filename"]);
666 BOOST_ASSERT(&buffer() == &features.buffer());
668 string const included_file =
669 includedFilename(buffer(), params()).availableFile().absFilename();
671 if (isLyXFilename(included_file))
672 writefile = changeExtension(included_file, ".sgml");
674 writefile = included_file;
676 if (!features.runparams().nice && !isVerbatim(params()) && !isListings(params())) {
677 incfile = DocFileName(writefile).mangledFilename();
678 writefile = makeAbsPath(incfile,
679 buffer().masterBuffer()->temppath()).absFilename();
682 features.includeFile(include_label, writefile);
684 if (isVerbatim(params()))
685 features.require("verbatim");
686 else if (isListings(params()))
687 features.require("listings");
689 // Here we must do the fun stuff...
690 // Load the file in the include if it needs
692 if (loadIfNeeded(buffer(), params())) {
694 Buffer * const tmp = theBufferList().getBuffer(included_file);
695 // make sure the buffer isn't us
696 // FIXME RECURSIVE INCLUDES
697 // This is not sufficient, as recursive includes could be
698 // more than a file away. But it will do for now.
699 if (tmp && tmp != &buffer()) {
700 // We must temporarily change features.buffer,
701 // otherwise it would always be the master buffer,
702 // and nested includes would not work.
703 features.setBuffer(*tmp);
704 tmp->validate(features);
705 features.setBuffer(buffer());
711 void InsetInclude::fillWithBibKeys(BiblioInfo & keys,
712 InsetIterator const & /*di*/) const
714 if (loadIfNeeded(buffer(), params())) {
715 string const included_file = includedFilename(buffer(), params()).absFilename();
716 Buffer * tmp = theBufferList().getBuffer(included_file);
717 //FIXME This is kind of a dirty hack and should be made reasonable.
719 keys.fillWithBibKeys(tmp);
720 tmp->setParent(&buffer());
725 void InsetInclude::updateBibfilesCache()
727 Buffer * const tmp = getChildBuffer(buffer(), params());
730 tmp->updateBibfilesCache();
731 tmp->setParent(&buffer());
736 EmbeddedFileList const &
737 InsetInclude::getBibfilesCache(Buffer const & buffer) const
739 Buffer * const tmp = getChildBuffer(buffer, params());
742 EmbeddedFileList const & cache = tmp->getBibfilesCache();
743 tmp->setParent(&buffer);
746 static EmbeddedFileList const empty;
751 void InsetInclude::metrics(MetricsInfo & mi, Dimension & dim) const
753 BOOST_ASSERT(mi.base.bv);
755 bool use_preview = false;
756 if (RenderPreview::status() != LyXRC::PREVIEW_OFF) {
757 graphics::PreviewImage const * pimage =
758 preview_->getPreviewImage(mi.base.bv->buffer());
759 use_preview = pimage && pimage->image();
763 preview_->metrics(mi, dim);
767 button_.update(screenLabel(), true);
769 button_.metrics(mi, dim);
772 Box b(0, dim.wid, -dim.asc, dim.des);
777 void InsetInclude::draw(PainterInfo & pi, int x, int y) const
779 BOOST_ASSERT(pi.base.bv);
781 bool use_preview = false;
782 if (RenderPreview::status() != LyXRC::PREVIEW_OFF) {
783 graphics::PreviewImage const * pimage =
784 preview_->getPreviewImage(pi.base.bv->buffer());
785 use_preview = pimage && pimage->image();
789 preview_->draw(pi, x, y);
791 button_.draw(pi, x, y);
795 Inset::DisplayType InsetInclude::display() const
797 return type(params()) == INPUT ? Inline : AlignCenter;
806 void InsetInclude::fileChanged() const
808 Buffer const * const buffer = updateFrontend();
812 preview_->removePreview(*buffer);
813 add_preview(*preview_.get(), *this, *buffer);
814 preview_->startLoading(*buffer);
820 bool preview_wanted(InsetCommandParams const & params, Buffer const & buffer)
822 FileName const included_file = includedFilename(buffer, params);
824 return type(params) == INPUT && params.preview() &&
825 included_file.isReadableFile();
829 docstring latexString(InsetInclude const & inset)
832 // We don't need to set runparams.encoding since this will be done
833 // by latex() anyway.
834 OutputParams runparams(0);
835 runparams.flavor = OutputParams::LATEX;
836 inset.latex(os, runparams);
842 void add_preview(RenderMonitoredPreview & renderer, InsetInclude const & inset,
843 Buffer const & buffer)
845 InsetCommandParams const & params = inset.params();
846 if (RenderPreview::status() != LyXRC::PREVIEW_OFF &&
847 preview_wanted(params, buffer)) {
848 renderer.setAbsFile(includedFilename(buffer, params));
849 docstring const snippet = latexString(inset);
850 renderer.addPreview(snippet, buffer);
857 void InsetInclude::addPreview(graphics::PreviewLoader & ploader) const
859 Buffer const & buffer = ploader.buffer();
860 if (!preview_wanted(params(), buffer))
862 preview_->setAbsFile(includedFilename(buffer, params()));
863 docstring const snippet = latexString(*this);
864 preview_->addPreview(snippet, ploader);
868 void InsetInclude::addToToc(ParConstIterator const & cpit) const
870 bool const embedded_status = !params()["embed"].empty();
871 TocBackend & backend = buffer().tocBackend();
873 if (isListings(params())) {
875 label_->addToToc(cpit);
877 InsetListingsParams p(to_utf8(params()["lstparams"]));
878 string caption = p.getParamValue("caption");
881 Toc & toc = backend.toc("listing");
882 docstring str = convert<docstring>(toc.size() + 1)
883 + ". " + from_utf8(caption);
884 if (embedded_status) {
885 backend.toc("embedded").push_back(TocItem(cpit, 0, str));
886 str += _(" (embedded)");
888 ParConstIterator pit = cpit;
889 pit.push_back(*this);
890 toc.push_back(TocItem(pit, 0, str));
893 Buffer const * const childbuffer = getChildBuffer(buffer(), params());
896 // Add it to the embedded list nonetheless.
897 backend.toc("embedded").push_back(TocItem(cpit, 0,
898 params()["filename"]));
902 Toc & toc = backend.toc("child");
903 docstring str = childbuffer->fileName().displayName();
904 if (embedded_status) {
905 backend.toc("embedded").push_back(TocItem(cpit, 0, str));
906 str += _(" (embedded)");
908 toc.push_back(TocItem(cpit, 0, str));
910 TocList & toclist = backend.tocs();
911 TocList const & childtoclist = childbuffer->tocBackend().tocs();
912 TocList::const_iterator it = childtoclist.begin();
913 TocList::const_iterator const end = childtoclist.end();
914 for(; it != end; ++it)
915 toclist[it->first].insert(toclist[it->first].end(),
916 it->second.begin(), it->second.end());
920 void InsetInclude::updateLabels(ParIterator const & it)
922 Buffer const * const childbuffer = getChildBuffer(buffer(), params());
924 lyx::updateLabels(*childbuffer, true);
927 if (!isListings(params()))
931 label_->updateLabels(it);
933 InsetListingsParams const par(to_utf8(params()["lstparams"]));
934 if (par.getParamValue("caption").empty()) {
935 listings_label_.clear();
938 Counters & counters = buffer().params().documentClass().counters();
939 docstring const cnt = from_ascii("listing");
940 listings_label_ = buffer().B_("Program Listing");
941 if (counters.hasCounter(cnt)) {
943 listings_label_ += " " + convert<docstring>(counters.value(cnt));
948 void InsetInclude::registerEmbeddedFiles(EmbeddedFileList & files) const
950 files.registerFile(includedFilename(buffer(), params()), this, buffer());
954 void InsetInclude::updateEmbeddedFile(EmbeddedFile const & file)
956 InsetCommandParams p = params();
957 p["filename"] = from_utf8(file.outputFilename());
958 p["embed"] = file.embedded() ? from_utf8(file.inzipName()) : docstring();