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
8 * Full author contact details are available in file CREDITS.
13 #include "InsetInclude.h"
16 #include "buffer_funcs.h"
17 #include "BufferList.h"
18 #include "BufferParams.h"
19 #include "BufferView.h"
22 #include "DispatchResult.h"
24 #include "FuncRequest.h"
25 #include "FuncStatus.h"
27 #include "LaTeXFeatures.h"
31 #include "MetricsInfo.h"
32 #include "OutputParams.h"
33 #include "TocBackend.h"
35 #include "frontends/alert.h"
36 #include "frontends/Painter.h"
38 #include "graphics/PreviewImage.h"
39 #include "graphics/PreviewLoader.h"
41 #include "insets/RenderPreview.h"
42 #include "insets/InsetListingsParams.h"
44 #include "support/filetools.h"
45 #include "support/lstrings.h" // contains
46 #include "support/lyxalgo.h"
47 #include "support/lyxlib.h"
48 #include "support/convert.h"
50 #include <boost/bind.hpp>
51 #include <boost/filesystem/operations.hpp>
56 // Implementation is in LyX.cpp
57 extern void dispatch(FuncRequest const & action);
59 using support::addName;
60 using support::absolutePath;
61 using support::bformat;
62 using support::changeExtension;
63 using support::contains;
65 using support::DocFileName;
66 using support::FileName;
67 using support::getFileContents;
68 using support::getVectorFromString;
69 using support::isFileReadable;
70 using support::isLyXFilename;
71 using support::isValidLaTeXFilename;
72 using support::latex_path;
73 using support::makeAbsPath;
74 using support::makeDisplayPath;
75 using support::makeRelPath;
76 using support::onlyFilename;
77 using support::onlyPath;
78 using support::prefixIs;
85 using std::istringstream;
87 using std::ostringstream;
90 namespace Alert = frontend::Alert;
91 namespace fs = boost::filesystem;
96 docstring const uniqueID()
98 static unsigned int seed = 1000;
99 return "file" + convert<docstring>(++seed);
103 bool isListings(InsetCommandParams const & params)
105 return params.getCmdName() == "lstinputlisting";
111 InsetInclude::InsetInclude(InsetCommandParams const & p)
112 : params_(p), include_label(uniqueID()),
113 preview_(new RenderMonitoredPreview(this)),
116 preview_->fileChanged(boost::bind(&InsetInclude::fileChanged, this));
120 InsetInclude::InsetInclude(InsetInclude const & other)
122 params_(other.params_),
123 include_label(other.include_label),
124 preview_(new RenderMonitoredPreview(this)),
127 preview_->fileChanged(boost::bind(&InsetInclude::fileChanged, this));
131 InsetInclude::~InsetInclude()
133 InsetIncludeMailer(*this).hideDialog();
137 void InsetInclude::doDispatch(Cursor & cur, FuncRequest & cmd)
139 switch (cmd.action) {
141 case LFUN_INSET_MODIFY: {
142 InsetCommandParams p("include");
143 InsetIncludeMailer::string2params(to_utf8(cmd.argument()), p);
144 if (!p.getCmdName().empty()) {
146 InsetListingsParams par_old(params().getOptions());
147 InsetListingsParams par_new(p.getOptions());
148 if (par_old.getParamValue("label") !=
149 par_new.getParamValue("label")
150 && !par_new.getParamValue("label").empty())
151 cur.bv().buffer().changeRefsIfUnique(
152 from_utf8(par_old.getParamValue("label")),
153 from_utf8(par_new.getParamValue("label")),
156 set(p, cur.buffer());
157 cur.buffer().updateBibfilesCache();
163 case LFUN_INSET_DIALOG_UPDATE:
164 InsetIncludeMailer(*this).updateDialog(&cur.bv());
167 case LFUN_MOUSE_RELEASE:
168 if (!cur.selection())
169 InsetIncludeMailer(*this).showDialog(&cur.bv());
173 Inset::doDispatch(cur, cmd);
179 bool InsetInclude::getStatus(Cursor & cur, FuncRequest const & cmd,
180 FuncStatus & flag) const
182 switch (cmd.action) {
184 case LFUN_INSET_MODIFY:
185 case LFUN_INSET_DIALOG_UPDATE:
190 return Inset::getStatus(cur, cmd, flag);
195 InsetCommandParams const & InsetInclude::params() const
203 /// the type of inclusion
213 Types type(InsetCommandParams const & params)
215 string const command_name = params.getCmdName();
217 if (command_name == "input")
219 if (command_name == "verbatiminput")
221 if (command_name == "verbatiminput*")
223 if (command_name == "lstinputlisting")
229 bool isVerbatim(InsetCommandParams const & params)
231 string const command_name = params.getCmdName();
232 return command_name == "verbatiminput" ||
233 command_name == "verbatiminput*";
237 bool isInputOrInclude(InsetCommandParams const & params)
239 Types const t = type(params);
240 return (t == INPUT) || (t == INCLUDE);
244 string const masterFilename(Buffer const & buffer)
246 return buffer.getMasterBuffer()->fileName();
250 string const parentFilename(Buffer const & buffer)
252 return buffer.fileName();
256 FileName const includedFilename(Buffer const & buffer,
257 InsetCommandParams const & params)
259 return makeAbsPath(to_utf8(params["filename"]),
260 onlyPath(parentFilename(buffer)));
264 void add_preview(RenderMonitoredPreview &, InsetInclude const &, Buffer const &);
269 void InsetInclude::set(InsetCommandParams const & p, Buffer const & buffer)
274 if (preview_->monitoring())
275 preview_->stopMonitoring();
277 if (type(params_) == INPUT)
278 add_preview(*preview_, *this, buffer);
282 Inset * InsetInclude::clone() const
284 return new InsetInclude(*this);
288 void InsetInclude::write(Buffer const &, ostream & os) const
294 void InsetInclude::write(ostream & os) const
296 os << "Include " << to_utf8(params_.getCommand()) << '\n'
297 << "preview " << convert<string>(params_.preview()) << '\n';
301 void InsetInclude::read(Buffer const &, Lexer & lex)
307 void InsetInclude::read(Lexer & lex)
311 string const command = lex.getString();
312 params_.scanCommand(command);
317 token = lex.getString();
318 if (token == "\\end_inset")
320 if (token == "preview") {
322 params_.preview(lex.getBool());
324 lex.printError("Unknown parameter name `$$Token' for command " + params_.getCmdName());
326 if (token != "\\end_inset") {
327 lex.printError("Missing \\end_inset at this point. "
333 docstring const InsetInclude::getScreenLabel(Buffer const & buf) const
337 switch (type(params_)) {
339 temp = buf.B_("Input");
342 temp = buf.B_("Verbatim Input");
345 temp = buf.B_("Verbatim Input*");
348 temp = buf.B_("Include");
351 temp = listings_label_;
357 if (params_["filename"].empty())
360 temp += from_utf8(onlyFilename(to_utf8(params_["filename"])));
368 /// return the child buffer if the file is a LyX doc and is loaded
369 Buffer * getChildBuffer(Buffer const & buffer, InsetCommandParams const & params)
371 if (isVerbatim(params) || isListings(params))
374 string const included_file = includedFilename(buffer, params).absFilename();
375 if (!isLyXFilename(included_file))
378 Buffer * childBuffer = theBufferList().getBuffer(included_file);
380 //FIXME RECURSIVE INCLUDES
381 if (childBuffer == & buffer)
389 /// return true if the file is or got loaded.
390 Buffer * loadIfNeeded(Buffer const & parent, InsetCommandParams const & params)
392 if (isVerbatim(params) || isListings(params))
395 string const parent_filename = parent.fileName();
396 FileName const included_file = makeAbsPath(to_utf8(params["filename"]),
397 onlyPath(parent_filename));
399 if (!isLyXFilename(included_file.absFilename()))
402 Buffer * child = theBufferList().getBuffer(included_file.absFilename());
404 // the readonly flag can/will be wrong, not anymore I think.
405 if (!fs::exists(included_file.toFilesystemEncoding()))
408 child = theBufferList().newBuffer(included_file.absFilename());
409 if (!loadLyXFile(child, included_file)) {
410 //close the buffer we just opened
411 theBufferList().close(child, false);
415 child->setParentName(parent_filename);
420 int InsetInclude::latex(Buffer const & buffer, odocstream & os,
421 OutputParams const & runparams) const
423 string incfile(to_utf8(params_["filename"]));
425 // Do nothing if no file name has been specified
429 FileName const included_file(includedFilename(buffer, params_));
431 //Check we're not trying to include ourselves.
432 //FIXME RECURSIVE INCLUDE
433 //This isn't sufficient, as the inclusion could be downstream.
434 //But it'll have to do for now.
435 if (isInputOrInclude(params_) &&
436 buffer.fileName() == included_file.absFilename())
438 Alert::error(_("Recursive input"),
439 bformat(_("Attempted to include file %1$s in itself! "
440 "Ignoring inclusion."), from_utf8(incfile)));
444 Buffer const * const m_buffer = buffer.getMasterBuffer();
446 // if incfile is relative, make it relative to the master
448 if (!absolutePath(incfile)) {
450 incfile = to_utf8(makeRelPath(from_utf8(included_file.absFilename()),
451 from_utf8(m_buffer->filePath())));
454 // write it to a file (so far the complete file)
455 string const exportfile = changeExtension(incfile, ".tex");
456 string const mangled =
457 DocFileName(changeExtension(included_file.absFilename(),".tex")).
459 FileName const writefile(makeAbsPath(mangled, m_buffer->temppath()));
463 else if (!isValidLaTeXFilename(incfile)) {
464 frontend::Alert::warning(_("Invalid filename"),
465 _("The following filename is likely to cause trouble "
466 "when running the exported file through LaTeX: ") +
469 LYXERR(Debug::LATEX) << "incfile:" << incfile << endl;
470 LYXERR(Debug::LATEX) << "exportfile:" << exportfile << endl;
471 LYXERR(Debug::LATEX) << "writefile:" << writefile << endl;
473 if (runparams.inComment || runparams.dryrun) {
474 //Don't try to load or copy the file if we're
475 //in a comment or doing a dryrun
476 } else if (isInputOrInclude(params_) &&
477 isLyXFilename(included_file.absFilename())) {
478 //if it's a LyX file and we're inputting or including,
479 //try to load it so we can write the associated latex
480 if (!loadIfNeeded(buffer, params_))
483 Buffer * tmp = theBufferList().getBuffer(included_file.absFilename());
485 if (tmp->params().getBaseClass() != m_buffer->params().getBaseClass()) {
487 docstring text = bformat(_("Included file `%1$s'\n"
488 "has textclass `%2$s'\n"
489 "while parent file has textclass `%3$s'."),
490 makeDisplayPath(included_file.absFilename()),
491 from_utf8(tmp->params().getTextClass().name()),
492 from_utf8(m_buffer->params().getTextClass().name()));
493 Alert::warning(_("Different textclasses"), text);
497 // Make sure modules used in child are all included in master
498 //FIXME It might be worth loading the children's modules into the master
499 //over in BufferParams rather than doing this check.
500 vector<string> const masterModules = m_buffer->params().getModules();
501 vector<string> const childModules = tmp->params().getModules();
502 vector<string>::const_iterator it = childModules.begin();
503 vector<string>::const_iterator end = childModules.end();
504 for (; it != end; ++it) {
505 string const module = *it;
506 vector<string>::const_iterator found =
507 find(masterModules.begin(), masterModules.end(), module);
508 if (found != masterModules.end()) {
509 docstring text = bformat(_("Included file `%1$s'\n"
510 "uses module `%2$s'\n"
511 "which is not used in parent file."),
512 makeDisplayPath(included_file.absFilename()), from_utf8(module));
513 Alert::warning(_("Module not found"), text);
517 tmp->markDepClean(m_buffer->temppath());
519 // FIXME: handle non existing files
520 // FIXME: Second argument is irrelevant!
521 // since only_body is true, makeLaTeXFile will not look at second
522 // argument. Should we set it to string(), or should makeLaTeXFile
523 // make use of it somehow? (JMarc 20031002)
524 // The included file might be written in a different encoding
525 Encoding const * const oldEnc = runparams.encoding;
526 runparams.encoding = &tmp->params().encoding();
527 tmp->makeLaTeXFile(writefile,
528 onlyPath(masterFilename(buffer)),
530 runparams.encoding = oldEnc;
532 // In this case, it's not a LyX file, so we copy the file
533 // to the temp dir, so that .aux files etc. are not created
534 // in the original dir. Files included by this file will be
535 // found via input@path, see ../Buffer.cpp.
536 unsigned long const checksum_in = sum(included_file);
537 unsigned long const checksum_out = sum(writefile);
539 if (checksum_in != checksum_out) {
540 if (!copy(included_file, writefile)) {
543 << to_utf8(bformat(_("Could not copy the file\n%1$s\n"
544 "into the temporary directory."),
545 from_utf8(included_file.absFilename())))
552 string const tex_format = (runparams.flavor == OutputParams::LATEX) ?
553 "latex" : "pdflatex";
554 if (isVerbatim(params_)) {
555 incfile = latex_path(incfile);
557 os << '\\' << from_ascii(params_.getCmdName()) << '{'
558 << from_utf8(incfile) << '}';
559 } else if (type(params_) == INPUT) {
560 runparams.exportdata->addExternalFile(tex_format, writefile,
563 // \input wants file with extension (default is .tex)
564 if (!isLyXFilename(included_file.absFilename())) {
565 incfile = latex_path(incfile);
567 os << '\\' << from_ascii(params_.getCmdName())
568 << '{' << from_utf8(incfile) << '}';
570 incfile = changeExtension(incfile, ".tex");
571 incfile = latex_path(incfile);
573 os << '\\' << from_ascii(params_.getCmdName())
574 << '{' << from_utf8(incfile) << '}';
576 } else if (type(params_) == LISTINGS) {
577 os << '\\' << from_ascii(params_.getCmdName());
578 string opt = params_.getOptions();
579 // opt is set in QInclude dialog and should have passed validation.
580 InsetListingsParams params(opt);
581 if (!params.params().empty())
582 os << "[" << from_utf8(params.params()) << "]";
583 os << '{' << from_utf8(incfile) << '}';
585 runparams.exportdata->addExternalFile(tex_format, writefile,
588 // \include don't want extension and demands that the
589 // file really have .tex
590 incfile = changeExtension(incfile, string());
591 incfile = latex_path(incfile);
593 os << '\\' << from_ascii(params_.getCmdName()) << '{'
594 << from_utf8(incfile) << '}';
601 int InsetInclude::plaintext(Buffer const & buffer, odocstream & os,
602 OutputParams const &) const
604 if (isVerbatim(params_) || isListings(params_)) {
605 os << '[' << getScreenLabel(buffer) << '\n';
606 // FIXME: We don't know the encoding of the file
607 docstring const str =
608 from_utf8(getFileContents(includedFilename(buffer, params_)));
611 return PLAINTEXT_NEWLINE + 1; // one char on a separate line
613 docstring const str = '[' + getScreenLabel(buffer) + ']';
620 int InsetInclude::docbook(Buffer const & buffer, odocstream & os,
621 OutputParams const & runparams) const
623 string incfile = to_utf8(params_["filename"]);
625 // Do nothing if no file name has been specified
629 string const included_file = includedFilename(buffer, params_).absFilename();
631 //Check we're not trying to include ourselves.
632 //FIXME RECURSIVE INCLUDE
633 //This isn't sufficient, as the inclusion could be downstream.
634 //But it'll have to do for now.
635 if (buffer.fileName() == included_file) {
636 Alert::error(_("Recursive input"),
637 bformat(_("Attempted to include file %1$s in itself! "
638 "Ignoring inclusion."), from_utf8(incfile)));
642 // write it to a file (so far the complete file)
643 string const exportfile = changeExtension(incfile, ".sgml");
644 DocFileName writefile(changeExtension(included_file, ".sgml"));
646 if (loadIfNeeded(buffer, params_)) {
647 Buffer * tmp = theBufferList().getBuffer(included_file);
649 string const mangled = writefile.mangledFilename();
650 writefile = makeAbsPath(mangled,
651 buffer.getMasterBuffer()->temppath());
655 LYXERR(Debug::LATEX) << "incfile:" << incfile << endl;
656 LYXERR(Debug::LATEX) << "exportfile:" << exportfile << endl;
657 LYXERR(Debug::LATEX) << "writefile:" << writefile << endl;
659 tmp->makeDocBookFile(writefile, runparams, true);
662 runparams.exportdata->addExternalFile("docbook", writefile,
664 runparams.exportdata->addExternalFile("docbook-xml", writefile,
667 if (isVerbatim(params_) || isListings(params_)) {
668 os << "<inlinegraphic fileref=\""
669 << '&' << include_label << ';'
670 << "\" format=\"linespecific\">";
672 os << '&' << include_label << ';';
678 void InsetInclude::validate(LaTeXFeatures & features) const
680 string incfile(to_utf8(params_["filename"]));
683 Buffer const & buffer = features.buffer();
685 string const included_file = includedFilename(buffer, params_).absFilename();
687 if (isLyXFilename(included_file))
688 writefile = changeExtension(included_file, ".sgml");
690 writefile = included_file;
692 if (!features.runparams().nice && !isVerbatim(params_) && !isListings(params_)) {
693 incfile = DocFileName(writefile).mangledFilename();
694 writefile = makeAbsPath(incfile,
695 buffer.getMasterBuffer()->temppath()).absFilename();
698 features.includeFile(include_label, writefile);
700 if (isVerbatim(params_))
701 features.require("verbatim");
702 else if (isListings(params_))
703 features.require("listings");
705 // Here we must do the fun stuff...
706 // Load the file in the include if it needs
708 if (loadIfNeeded(buffer, params_)) {
710 Buffer * const tmp = theBufferList().getBuffer(included_file);
711 // make sure the buffer isn't us
712 // FIXME RECURSIVE INCLUDES
713 // This is not sufficient, as recursive includes could be
714 // more than a file away. But it will do for now.
715 if (tmp && tmp != & buffer) {
716 // We must temporarily change features.buffer,
717 // otherwise it would always be the master buffer,
718 // and nested includes would not work.
719 features.setBuffer(*tmp);
720 tmp->validate(features);
721 features.setBuffer(buffer);
727 void InsetInclude::getLabelList(Buffer const & buffer,
728 std::vector<docstring> & list) const
730 if (isListings(params_)) {
731 InsetListingsParams params(params_.getOptions());
732 string label = params.getParamValue("label");
734 list.push_back(from_utf8(label));
736 else if (loadIfNeeded(buffer, params_)) {
737 string const included_file = includedFilename(buffer, params_).absFilename();
738 Buffer * tmp = theBufferList().getBuffer(included_file);
739 tmp->setParentName("");
740 tmp->getLabelList(list);
741 tmp->setParentName(parentFilename(buffer));
746 void InsetInclude::fillWithBibKeys(Buffer const & buffer,
747 BiblioInfo & keys, InsetIterator const & /*di*/) const
749 if (loadIfNeeded(buffer, params_)) {
750 string const included_file = includedFilename(buffer, params_).absFilename();
751 Buffer * tmp = theBufferList().getBuffer(included_file);
752 //FIXME This is kind of a dirty hack and should be made reasonable.
753 tmp->setParentName("");
754 keys.fillWithBibKeys(tmp);
755 tmp->setParentName(parentFilename(buffer));
760 void InsetInclude::updateBibfilesCache(Buffer const & buffer)
762 Buffer * const tmp = getChildBuffer(buffer, params_);
764 tmp->setParentName("");
765 tmp->updateBibfilesCache();
766 tmp->setParentName(parentFilename(buffer));
771 std::vector<FileName> const &
772 InsetInclude::getBibfilesCache(Buffer const & buffer) const
774 Buffer * const tmp = getChildBuffer(buffer, params_);
776 tmp->setParentName("");
777 std::vector<FileName> const & cache = tmp->getBibfilesCache();
778 tmp->setParentName(parentFilename(buffer));
781 static std::vector<FileName> const empty;
786 bool InsetInclude::metrics(MetricsInfo & mi, Dimension & dim) const
788 BOOST_ASSERT(mi.base.bv);
790 bool use_preview = false;
791 if (RenderPreview::status() != LyXRC::PREVIEW_OFF) {
792 graphics::PreviewImage const * pimage =
793 preview_->getPreviewImage(mi.base.bv->buffer());
794 use_preview = pimage && pimage->image();
798 preview_->metrics(mi, dim);
802 button_.update(getScreenLabel(mi.base.bv->buffer()),
805 button_.metrics(mi, dim);
808 Box b(0, dim.wid, -dim.asc, dim.des);
811 bool const changed = dim_ != dim;
817 void InsetInclude::draw(PainterInfo & pi, int x, int y) const
819 setPosCache(pi, x, y);
821 BOOST_ASSERT(pi.base.bv);
823 bool use_preview = false;
824 if (RenderPreview::status() != LyXRC::PREVIEW_OFF) {
825 graphics::PreviewImage const * pimage =
826 preview_->getPreviewImage(pi.base.bv->buffer());
827 use_preview = pimage && pimage->image();
831 preview_->draw(pi, x, y);
833 button_.draw(pi, x, y);
837 Inset::DisplayType InsetInclude::display() const
839 return type(params_) == INPUT ? Inline : AlignCenter;
848 void InsetInclude::fileChanged() const
850 Buffer const * const buffer_ptr = LyX::cref().updateInset(this);
854 Buffer const & buffer = *buffer_ptr;
855 preview_->removePreview(buffer);
856 add_preview(*preview_.get(), *this, buffer);
857 preview_->startLoading(buffer);
863 bool preview_wanted(InsetCommandParams const & params, Buffer const & buffer)
865 FileName const included_file = includedFilename(buffer, params);
867 return type(params) == INPUT && params.preview() &&
868 isFileReadable(included_file);
872 docstring const latex_string(InsetInclude const & inset, Buffer const & buffer)
875 // We don't need to set runparams.encoding since this will be done
876 // by latex() anyway.
877 OutputParams runparams(0);
878 runparams.flavor = OutputParams::LATEX;
879 inset.latex(buffer, os, runparams);
885 void add_preview(RenderMonitoredPreview & renderer, InsetInclude const & inset,
886 Buffer const & buffer)
888 InsetCommandParams const & params = inset.params();
889 if (RenderPreview::status() != LyXRC::PREVIEW_OFF &&
890 preview_wanted(params, buffer)) {
891 renderer.setAbsFile(includedFilename(buffer, params));
892 docstring const snippet = latex_string(inset, buffer);
893 renderer.addPreview(snippet, buffer);
900 void InsetInclude::addPreview(graphics::PreviewLoader & ploader) const
902 Buffer const & buffer = ploader.buffer();
903 if (preview_wanted(params(), buffer)) {
904 preview_->setAbsFile(includedFilename(buffer, params()));
905 docstring const snippet = latex_string(*this, buffer);
906 preview_->addPreview(snippet, ploader);
911 void InsetInclude::addToToc(TocList & toclist, Buffer const & buffer, ParConstIterator const & pit) const
913 if (isListings(params_)) {
914 InsetListingsParams params(params_.getOptions());
915 string caption = params.getParamValue("caption");
916 if (!caption.empty()) {
917 Toc & toc = toclist["listing"];
918 docstring const str = convert<docstring>(toc.size() + 1)
919 + ". " + from_utf8(caption);
920 // This inset does not have a valid ParConstIterator
921 // so it has to use the iterator of its parent paragraph
922 toc.push_back(TocItem(pit, 0, str));
926 Buffer const * const childbuffer = getChildBuffer(buffer, params_);
930 TocList const & childtoclist = childbuffer->tocBackend().tocs();
931 TocList::const_iterator it = childtoclist.begin();
932 TocList::const_iterator const end = childtoclist.end();
933 for(; it != end; ++it)
934 toclist[it->first].insert(toclist[it->first].end(),
935 it->second.begin(), it->second.end());
939 void InsetInclude::updateLabels(Buffer const & buffer,
942 Buffer const * const childbuffer = getChildBuffer(buffer, params_);
944 lyx::updateLabels(*childbuffer, true);
945 else if (isListings(params_)) {
946 InsetListingsParams const par = params_.getOptions();
947 if (par.getParamValue("caption").empty())
948 listings_label_.clear();
950 Counters & counters = buffer.params().getTextClass().counters();
951 docstring const cnt = from_ascii("listing");
952 if (counters.hasCounter(cnt)) {
954 listings_label_ = buffer.B_("Program Listing ") + convert<docstring>(counters.value(cnt));
956 listings_label_ = buffer.B_("Program Listing");
962 void InsetInclude::registerEmbeddedFiles(Buffer const & buffer,
963 EmbeddedFiles & files) const
965 // include and input are temprarily not considered.
966 if (isVerbatim(params_) || isListings(params_))
967 files.registerFile(includedFilename(buffer, params_).absFilename(),
972 string const InsetIncludeMailer::name_("include");
974 InsetIncludeMailer::InsetIncludeMailer(InsetInclude & inset)
979 string const InsetIncludeMailer::inset2string(Buffer const &) const
981 return params2string(inset_.params());
985 void InsetIncludeMailer::string2params(string const & in,
986 InsetCommandParams & params)
992 istringstream data(in);
998 if (!lex || name != name_)
999 return print_mailer_error("InsetIncludeMailer", in, 1, name_);
1001 // This is part of the inset proper that is usually swallowed
1002 // by Text::readInset
1005 if (!lex || id != "Include")
1006 return print_mailer_error("InsetIncludeMailer", in, 2, "Include");
1008 InsetInclude inset(params);
1010 params = inset.params();
1015 InsetIncludeMailer::params2string(InsetCommandParams const & params)
1017 InsetInclude inset(params);
1019 data << name_ << ' ';
1021 data << "\\end_inset\n";