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)
9 * Full author contact details are available in file CREDITS.
14 #include "InsetInclude.h"
17 #include "buffer_funcs.h"
18 #include "BufferList.h"
19 #include "BufferParams.h"
20 #include "BufferView.h"
22 #include "DispatchResult.h"
23 #include "ErrorList.h"
26 #include "FuncRequest.h"
27 #include "FuncStatus.h"
28 #include "LaTeXFeatures.h"
29 #include "LayoutFile.h"
30 #include "LayoutModuleList.h"
35 #include "MetricsInfo.h"
36 #include "OutputParams.h"
37 #include "TextClass.h"
38 #include "TocBackend.h"
40 #include "frontends/alert.h"
41 #include "frontends/Painter.h"
43 #include "graphics/PreviewImage.h"
44 #include "graphics/PreviewLoader.h"
46 #include "insets/InsetLabel.h"
47 #include "insets/InsetListingsParams.h"
48 #include "insets/RenderPreview.h"
50 #include "support/convert.h"
51 #include "support/debug.h"
52 #include "support/docstream.h"
53 #include "support/FileNameList.h"
54 #include "support/filetools.h"
55 #include "support/gettext.h"
56 #include "support/lassert.h"
57 #include "support/lstrings.h" // contains
58 #include "support/lyxalgo.h"
60 #include <boost/bind.hpp>
63 using namespace lyx::support;
67 namespace Alert = frontend::Alert;
72 docstring const uniqueID()
74 static unsigned int seed = 1000;
75 return "file" + convert<docstring>(++seed);
79 /// the type of inclusion
81 INCLUDE, VERB, INPUT, VERBAST, LISTINGS, NONE
85 Types type(string const & s)
89 if (s == "verbatiminput")
91 if (s == "verbatiminput*")
93 if (s == "lstinputlisting")
101 Types type(InsetCommandParams const & params)
103 return type(params.getCmdName());
107 bool isListings(InsetCommandParams const & params)
109 return type(params) == LISTINGS;
113 bool isVerbatim(InsetCommandParams const & params)
115 Types const t = type(params);
116 return t == VERB || t == VERBAST;
120 bool isInputOrInclude(InsetCommandParams const & params)
122 Types const t = type(params);
123 return t == INPUT || t == INCLUDE;
127 FileName const masterFileName(Buffer const & buffer)
129 return buffer.masterBuffer()->fileName();
133 void add_preview(RenderMonitoredPreview &, InsetInclude const &, Buffer const &);
136 string const parentFilename(Buffer const & buffer)
138 return buffer.absFileName();
142 FileName const includedFilename(Buffer const & buffer,
143 InsetCommandParams const & params)
145 return makeAbsPath(to_utf8(params["filename"]),
146 onlyPath(parentFilename(buffer)));
150 InsetLabel * createLabel(docstring const & label_str)
152 if (label_str.empty())
154 InsetCommandParams icp(LABEL_CODE);
155 icp["name"] = label_str;
156 return new InsetLabel(icp);
162 InsetInclude::InsetInclude(InsetCommandParams const & p)
163 : InsetCommand(p, "include"), include_label(uniqueID()),
164 preview_(new RenderMonitoredPreview(this)), failedtoload_(false),
165 set_label_(false), label_(0)
167 preview_->fileChanged(boost::bind(&InsetInclude::fileChanged, this));
169 if (isListings(params())) {
170 InsetListingsParams listing_params(to_utf8(p["lstparams"]));
171 label_ = createLabel(from_utf8(listing_params.getParamValue("label")));
176 InsetInclude::InsetInclude(InsetInclude const & other)
177 : InsetCommand(other), include_label(other.include_label),
178 preview_(new RenderMonitoredPreview(this)), failedtoload_(false),
179 set_label_(false), label_(0)
181 preview_->fileChanged(boost::bind(&InsetInclude::fileChanged, this));
184 label_ = new InsetLabel(*other.label_);
188 InsetInclude::~InsetInclude()
194 void InsetInclude::setBuffer(Buffer & buffer)
196 InsetCommand::setBuffer(buffer);
198 label_->setBuffer(buffer);
202 ParamInfo const & InsetInclude::findInfo(string const & /* cmdName */)
205 // This is only correct for the case of listings, but it'll do for now.
206 // In the other cases, this second parameter should just be empty.
207 static ParamInfo param_info_;
208 if (param_info_.empty()) {
209 param_info_.add("filename", ParamInfo::LATEX_REQUIRED);
210 param_info_.add("lstparams", ParamInfo::LATEX_OPTIONAL);
216 bool InsetInclude::isCompatibleCommand(string const & s)
218 return type(s) != NONE;
222 void InsetInclude::doDispatch(Cursor & cur, FuncRequest & cmd)
224 LASSERT(cur.buffer() == &buffer(), return);
225 switch (cmd.action) {
227 case LFUN_INSET_EDIT: {
228 editIncluded(to_utf8(params()["filename"]));
232 case LFUN_INSET_MODIFY: {
233 InsetCommandParams p(INCLUDE_CODE);
234 if (cmd.getArg(0) == "changetype") {
235 InsetCommand::doDispatch(cur, cmd);
238 InsetCommand::string2params("include", to_utf8(cmd.argument()), p);
239 if (!p.getCmdName().empty()) {
241 InsetListingsParams new_params(to_utf8(p["lstparams"]));
242 docstring const new_label =
243 from_utf8(new_params.getParamValue("label"));
245 if (new_label.empty()) {
251 old_label = label_->getParam("name");
253 label_ = createLabel(new_label);
254 label_->setBuffer(buffer());
257 if (new_label != old_label) {
258 label_->updateCommand(new_label);
259 // the label might have been adapted (duplicate)
260 if (new_label != label_->getParam("name")) {
261 new_params.addParam("label", "{" +
262 to_utf8(label_->getParam("name")) + "}", true);
263 p["lstparams"] = from_utf8(new_params.params());
274 //pass everything else up the chain
276 InsetCommand::doDispatch(cur, cmd);
282 void InsetInclude::editIncluded(string const & file)
284 string const ext = support::getExtension(file);
286 FuncRequest fr(LFUN_BUFFER_CHILD_OPEN, file);
289 // tex file or other text file in verbatim mode
290 formats.edit(buffer(),
291 support::makeAbsPath(file, support::onlyPath(buffer().absFileName())),
296 bool InsetInclude::getStatus(Cursor & cur, FuncRequest const & cmd,
297 FuncStatus & flag) const
299 switch (cmd.action) {
301 case LFUN_INSET_EDIT:
302 case LFUN_INSET_MODIFY:
303 flag.setEnabled(true);
307 return InsetCommand::getStatus(cur, cmd, flag);
312 void InsetInclude::setParams(InsetCommandParams const & p)
314 InsetCommand::setParams(p);
317 if (preview_->monitoring())
318 preview_->stopMonitoring();
320 if (type(params()) == INPUT)
321 add_preview(*preview_, *this, buffer());
323 buffer().updateBibfilesCache();
327 docstring InsetInclude::screenLabel() const
331 switch (type(params())) {
333 temp = buffer().B_("Input");
336 temp = buffer().B_("Verbatim Input");
339 temp = buffer().B_("Verbatim Input*");
342 temp = buffer().B_("Include");
345 temp = listings_label_;
348 LASSERT(false, /**/);
353 if (params()["filename"].empty())
356 temp += from_utf8(onlyFilename(to_utf8(params()["filename"])));
362 Buffer * InsetInclude::getChildBuffer(Buffer const & buffer) const
364 InsetCommandParams const & p = params();
365 if (isVerbatim(p) || isListings(p))
368 string const included_file = includedFilename(buffer, p).absFilename();
369 if (!isLyXFilename(included_file))
372 Buffer * childBuffer = loadIfNeeded(buffer);
374 // FIXME: recursive includes
375 return (childBuffer == &buffer) ? 0 : childBuffer;
379 Buffer * InsetInclude::loadIfNeeded(Buffer const & parent) const
381 InsetCommandParams const & p = params();
385 if (isVerbatim(p) || isListings(p))
388 string const parent_filename = parent.absFileName();
389 FileName const included_file = makeAbsPath(to_utf8(p["filename"]),
390 onlyPath(parent_filename));
392 if (!isLyXFilename(included_file.absFilename()))
395 Buffer * child = theBufferList().getBuffer(included_file);
397 // the readonly flag can/will be wrong, not anymore I think.
398 if (!included_file.exists())
401 child = theBufferList().newBuffer(included_file.absFilename());
403 // Buffer creation is not possible.
406 if (!child->loadLyXFile(included_file)) {
407 failedtoload_ = true;
408 //close the buffer we just opened
409 theBufferList().release(child);
413 if (!child->errorList("Parse").empty()) {
414 // FIXME: Do something.
417 child->setParent(&parent);
422 int InsetInclude::latex(odocstream & os, OutputParams const & runparams) const
424 string incfile = to_utf8(params()["filename"]);
426 // Do nothing if no file name has been specified
430 FileName const included_file = includedFilename(buffer(), params());
432 // Check we're not trying to include ourselves.
433 // FIXME RECURSIVE INCLUDE
434 // This isn't sufficient, as the inclusion could be downstream.
435 // But it'll have to do for now.
436 if (isInputOrInclude(params()) &&
437 buffer().absFileName() == included_file.absFilename())
439 Alert::error(_("Recursive input"),
440 bformat(_("Attempted to include file %1$s in itself! "
441 "Ignoring inclusion."), from_utf8(incfile)));
445 Buffer const * const masterBuffer = buffer().masterBuffer();
447 // if incfile is relative, make it relative to the master
449 if (!FileName(incfile).isAbsolute()) {
451 incfile = to_utf8(makeRelPath(from_utf8(included_file.absFilename()),
452 from_utf8(masterBuffer->filePath())));
455 // write it to a file (so far the complete file)
459 if (type(params()) == LISTINGS) {
460 exportfile = incfile;
461 mangled = DocFileName(included_file).mangledFilename();
463 exportfile = changeExtension(incfile, ".tex");
464 mangled = DocFileName(changeExtension(included_file.absFilename(), ".tex")).
468 FileName const writefile(makeAbsPath(mangled, masterBuffer->temppath()));
472 else if (!isValidLaTeXFilename(incfile)) {
473 frontend::Alert::warning(_("Invalid filename"),
474 _("The following filename is likely to cause trouble "
475 "when running the exported file through LaTeX: ") +
478 LYXERR(Debug::LATEX, "incfile:" << incfile);
479 LYXERR(Debug::LATEX, "exportfile:" << exportfile);
480 LYXERR(Debug::LATEX, "writefile:" << writefile);
482 if (runparams.inComment || runparams.dryrun) {
483 //Don't try to load or copy the file if we're
484 //in a comment or doing a dryrun
485 } else if (isInputOrInclude(params()) &&
486 isLyXFilename(included_file.absFilename())) {
487 //if it's a LyX file and we're inputting or including,
488 //try to load it so we can write the associated latex
489 if (!loadIfNeeded(buffer()))
492 Buffer * tmp = theBufferList().getBuffer(included_file);
494 if (tmp->params().baseClass() != masterBuffer->params().baseClass()) {
496 docstring text = bformat(_("Included file `%1$s'\n"
497 "has textclass `%2$s'\n"
498 "while parent file has textclass `%3$s'."),
499 included_file.displayName(),
500 from_utf8(tmp->params().documentClass().name()),
501 from_utf8(masterBuffer->params().documentClass().name()));
502 Alert::warning(_("Different textclasses"), text);
505 // Make sure modules used in child are all included in master
506 //FIXME It might be worth loading the children's modules into the master
507 //over in BufferParams rather than doing this check.
508 LayoutModuleList const masterModules = masterBuffer->params().getModules();
509 LayoutModuleList const childModules = tmp->params().getModules();
510 LayoutModuleList::const_iterator it = childModules.begin();
511 LayoutModuleList::const_iterator end = childModules.end();
512 for (; it != end; ++it) {
513 string const module = *it;
514 LayoutModuleList::const_iterator found =
515 find(masterModules.begin(), masterModules.end(), module);
516 if (found == masterModules.end()) {
517 docstring text = bformat(_("Included file `%1$s'\n"
518 "uses module `%2$s'\n"
519 "which is not used in parent file."),
520 included_file.displayName(), from_utf8(module));
521 Alert::warning(_("Module not found"), text);
525 tmp->markDepClean(masterBuffer->temppath());
527 // FIXME: handle non existing files
528 // FIXME: Second argument is irrelevant!
529 // since only_body is true, makeLaTeXFile will not look at second
530 // argument. Should we set it to string(), or should makeLaTeXFile
531 // make use of it somehow? (JMarc 20031002)
532 // The included file might be written in a different encoding
533 Encoding const * const oldEnc = runparams.encoding;
534 runparams.encoding = &tmp->params().encoding();
535 tmp->makeLaTeXFile(writefile,
536 masterFileName(buffer()).onlyPath().absFilename(),
538 runparams.encoding = oldEnc;
540 // In this case, it's not a LyX file, so we copy the file
541 // to the temp dir, so that .aux files etc. are not created
542 // in the original dir. Files included by this file will be
543 // found via input@path, see ../Buffer.cpp.
544 unsigned long const checksum_in = included_file.checksum();
545 unsigned long const checksum_out = writefile.checksum();
547 if (checksum_in != checksum_out) {
548 if (!included_file.copyTo(writefile)) {
551 to_utf8(bformat(_("Could not copy the file\n%1$s\n"
552 "into the temporary directory."),
553 from_utf8(included_file.absFilename()))));
559 string const tex_format = (runparams.flavor == OutputParams::LATEX) ?
560 "latex" : "pdflatex";
561 if (isVerbatim(params())) {
562 incfile = latex_path(incfile);
564 os << '\\' << from_ascii(params().getCmdName()) << '{'
565 << from_utf8(incfile) << '}';
566 } else if (type(params()) == INPUT) {
567 runparams.exportdata->addExternalFile(tex_format, writefile,
570 // \input wants file with extension (default is .tex)
571 if (!isLyXFilename(included_file.absFilename())) {
572 incfile = latex_path(incfile);
574 os << '\\' << from_ascii(params().getCmdName())
575 << '{' << from_utf8(incfile) << '}';
577 incfile = changeExtension(incfile, ".tex");
578 incfile = latex_path(incfile);
580 os << '\\' << from_ascii(params().getCmdName())
581 << '{' << from_utf8(incfile) << '}';
583 } else if (type(params()) == LISTINGS) {
584 os << '\\' << from_ascii(params().getCmdName());
585 string const opt = to_utf8(params()["lstparams"]);
586 // opt is set in QInclude dialog and should have passed validation.
587 InsetListingsParams params(opt);
588 if (!params.params().empty())
589 os << "[" << from_utf8(params.params()) << "]";
590 os << '{' << from_utf8(incfile) << '}';
592 runparams.exportdata->addExternalFile(tex_format, writefile,
595 // \include don't want extension and demands that the
596 // file really have .tex
597 incfile = changeExtension(incfile, string());
598 incfile = latex_path(incfile);
600 os << '\\' << from_ascii(params().getCmdName()) << '{'
601 << from_utf8(incfile) << '}';
608 int InsetInclude::plaintext(odocstream & os, OutputParams const &) const
610 if (isVerbatim(params()) || isListings(params())) {
611 os << '[' << screenLabel() << '\n';
612 // FIXME: We don't know the encoding of the file, default to UTF-8.
613 os << includedFilename(buffer(), params()).fileContents("UTF-8");
615 return PLAINTEXT_NEWLINE + 1; // one char on a separate line
617 docstring const str = '[' + screenLabel() + ']';
624 int InsetInclude::docbook(odocstream & os, OutputParams const & runparams) const
626 string incfile = to_utf8(params()["filename"]);
628 // Do nothing if no file name has been specified
632 string const included_file = includedFilename(buffer(), params()).absFilename();
634 // Check we're not trying to include ourselves.
635 // FIXME RECURSIVE INCLUDE
636 // This isn't sufficient, as the inclusion could be downstream.
637 // But it'll have to do for now.
638 if (buffer().absFileName() == included_file) {
639 Alert::error(_("Recursive input"),
640 bformat(_("Attempted to include file %1$s in itself! "
641 "Ignoring inclusion."), from_utf8(incfile)));
645 // write it to a file (so far the complete file)
646 string const exportfile = changeExtension(incfile, ".sgml");
647 DocFileName writefile(changeExtension(included_file, ".sgml"));
649 if (loadIfNeeded(buffer())) {
650 Buffer * tmp = theBufferList().getBuffer(FileName(included_file));
652 string const mangled = writefile.mangledFilename();
653 writefile = makeAbsPath(mangled,
654 buffer().masterBuffer()->temppath());
658 LYXERR(Debug::LATEX, "incfile:" << incfile);
659 LYXERR(Debug::LATEX, "exportfile:" << exportfile);
660 LYXERR(Debug::LATEX, "writefile:" << writefile);
662 tmp->makeDocBookFile(writefile, runparams, true);
665 runparams.exportdata->addExternalFile("docbook", writefile,
667 runparams.exportdata->addExternalFile("docbook-xml", writefile,
670 if (isVerbatim(params()) || isListings(params())) {
671 os << "<inlinegraphic fileref=\""
672 << '&' << include_label << ';'
673 << "\" format=\"linespecific\">";
675 os << '&' << include_label << ';';
681 void InsetInclude::validate(LaTeXFeatures & features) const
683 string incfile = to_utf8(params()["filename"]);
686 LASSERT(&buffer() == &features.buffer(), /**/);
688 string const included_file =
689 includedFilename(buffer(), params()).absFilename();
691 if (isLyXFilename(included_file))
692 writefile = changeExtension(included_file, ".sgml");
694 writefile = included_file;
696 if (!features.runparams().nice && !isVerbatim(params()) && !isListings(params())) {
697 incfile = DocFileName(writefile).mangledFilename();
698 writefile = makeAbsPath(incfile,
699 buffer().masterBuffer()->temppath()).absFilename();
702 features.includeFile(include_label, writefile);
704 if (isVerbatim(params()))
705 features.require("verbatim");
706 else if (isListings(params()))
707 features.require("listings");
709 // Here we must do the fun stuff...
710 // Load the file in the include if it needs
712 if (loadIfNeeded(buffer())) {
714 Buffer * const tmp = theBufferList().getBuffer(FileName(included_file));
715 // make sure the buffer isn't us
716 // FIXME RECURSIVE INCLUDES
717 // This is not sufficient, as recursive includes could be
718 // more than a file away. But it will do for now.
719 if (tmp && tmp != &buffer()) {
720 // We must temporarily change features.buffer,
721 // otherwise it would always be the master buffer,
722 // and nested includes would not work.
723 features.setBuffer(*tmp);
724 tmp->validate(features);
725 features.setBuffer(buffer());
731 void InsetInclude::fillWithBibKeys(BiblioInfo & keys,
732 InsetIterator const & /*di*/) const
734 if (loadIfNeeded(buffer())) {
735 string const included_file = includedFilename(buffer(), params()).absFilename();
736 Buffer * tmp = theBufferList().getBuffer(FileName(included_file));
737 BiblioInfo const & newkeys = tmp->localBibInfo();
738 keys.mergeBiblioInfo(newkeys);
743 void InsetInclude::updateBibfilesCache()
745 Buffer * const tmp = getChildBuffer(buffer());
748 tmp->updateBibfilesCache();
749 tmp->setParent(&buffer());
754 support::FileNameList const &
755 InsetInclude::getBibfilesCache(Buffer const & buffer) const
757 Buffer * const tmp = getChildBuffer(buffer);
760 support::FileNameList const & cache = tmp->getBibfilesCache();
761 tmp->setParent(&buffer);
764 static support::FileNameList const empty;
769 void InsetInclude::metrics(MetricsInfo & mi, Dimension & dim) const
771 LASSERT(mi.base.bv, /**/);
773 bool use_preview = false;
774 if (RenderPreview::status() != LyXRC::PREVIEW_OFF) {
775 graphics::PreviewImage const * pimage =
776 preview_->getPreviewImage(mi.base.bv->buffer());
777 use_preview = pimage && pimage->image();
781 preview_->metrics(mi, dim);
785 button_.update(screenLabel(), true);
787 button_.metrics(mi, dim);
790 Box b(0, dim.wid, -dim.asc, dim.des);
795 void InsetInclude::draw(PainterInfo & pi, int x, int y) const
797 LASSERT(pi.base.bv, /**/);
799 bool use_preview = false;
800 if (RenderPreview::status() != LyXRC::PREVIEW_OFF) {
801 graphics::PreviewImage const * pimage =
802 preview_->getPreviewImage(pi.base.bv->buffer());
803 use_preview = pimage && pimage->image();
807 preview_->draw(pi, x, y);
809 button_.draw(pi, x, y);
813 docstring InsetInclude::contextMenu(BufferView const &, int, int) const
815 return from_ascii("context-include");
819 Inset::DisplayType InsetInclude::display() const
821 return type(params()) == INPUT ? Inline : AlignCenter;
830 void InsetInclude::fileChanged() const
832 Buffer const * const buffer = updateFrontend();
836 preview_->removePreview(*buffer);
837 add_preview(*preview_.get(), *this, *buffer);
838 preview_->startLoading(*buffer);
844 bool preview_wanted(InsetCommandParams const & params, Buffer const & buffer)
846 FileName const included_file = includedFilename(buffer, params);
848 return type(params) == INPUT && params.preview() &&
849 included_file.isReadableFile();
853 docstring latexString(InsetInclude const & inset)
856 // We don't need to set runparams.encoding since this will be done
857 // by latex() anyway.
858 OutputParams runparams(0);
859 runparams.flavor = OutputParams::LATEX;
860 inset.latex(os, runparams);
866 void add_preview(RenderMonitoredPreview & renderer, InsetInclude const & inset,
867 Buffer const & buffer)
869 InsetCommandParams const & params = inset.params();
870 if (RenderPreview::status() != LyXRC::PREVIEW_OFF &&
871 preview_wanted(params, buffer)) {
872 renderer.setAbsFile(includedFilename(buffer, params));
873 docstring const snippet = latexString(inset);
874 renderer.addPreview(snippet, buffer);
881 void InsetInclude::addPreview(graphics::PreviewLoader & ploader) const
883 Buffer const & buffer = ploader.buffer();
884 if (!preview_wanted(params(), buffer))
886 preview_->setAbsFile(includedFilename(buffer, params()));
887 docstring const snippet = latexString(*this);
888 preview_->addPreview(snippet, ploader);
892 void InsetInclude::addToToc(DocIterator const & cpit)
894 TocBackend & backend = buffer().tocBackend();
896 if (isListings(params())) {
898 label_->addToToc(cpit);
900 InsetListingsParams p(to_utf8(params()["lstparams"]));
901 string caption = p.getParamValue("caption");
904 Toc & toc = backend.toc("listing");
905 docstring str = convert<docstring>(toc.size() + 1)
906 + ". " + from_utf8(caption);
907 DocIterator pit = cpit;
908 toc.push_back(TocItem(pit, 0, str));
911 Buffer const * const childbuffer = getChildBuffer(buffer());
915 Toc & toc = backend.toc("child");
916 docstring str = childbuffer->fileName().displayName();
917 toc.push_back(TocItem(cpit, 0, str));
919 TocList & toclist = backend.tocs();
920 childbuffer->tocBackend().update();
921 TocList const & childtoclist = childbuffer->tocBackend().tocs();
922 TocList::const_iterator it = childtoclist.begin();
923 TocList::const_iterator const end = childtoclist.end();
924 for(; it != end; ++it)
925 toclist[it->first].insert(toclist[it->first].end(),
926 it->second.begin(), it->second.end());
930 void InsetInclude::updateCommand()
935 docstring old_label = label_->getParam("name");
936 label_->updateCommand(old_label, false);
937 // the label might have been adapted (duplicate)
938 docstring new_label = label_->getParam("name");
939 if (old_label == new_label)
942 // update listings parameters...
943 InsetCommandParams p(INCLUDE_CODE);
945 InsetListingsParams par(to_utf8(params()["lstparams"]));
946 par.addParam("label", "{" + to_utf8(new_label) + "}", true);
947 p["lstparams"] = from_utf8(par.params());
951 void InsetInclude::updateLabels(ParIterator const & it)
953 Buffer const * const childbuffer = getChildBuffer(buffer());
955 childbuffer->updateLabels(Buffer::UpdateChildOnly);
958 if (!isListings(params()))
962 label_->updateLabels(it);
964 InsetListingsParams const par(to_utf8(params()["lstparams"]));
965 if (par.getParamValue("caption").empty()) {
966 listings_label_ = buffer().B_("Program Listing");
969 Buffer const & master = *buffer().masterBuffer();
970 Counters & counters = master.params().documentClass().counters();
971 docstring const cnt = from_ascii("listing");
972 listings_label_ = master.B_("Program Listing");
973 if (counters.hasCounter(cnt)) {
975 listings_label_ += " " + convert<docstring>(counters.value(cnt));