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;
84 using std::istringstream;
86 using std::ostringstream;
89 namespace Alert = frontend::Alert;
90 namespace fs = boost::filesystem;
95 docstring const uniqueID()
97 static unsigned int seed = 1000;
98 return "file" + convert<docstring>(++seed);
102 bool isListings(InsetCommandParams const & params)
104 return params.getCmdName() == "lstinputlisting";
110 InsetInclude::InsetInclude(InsetCommandParams const & p)
111 : params_(p), include_label(uniqueID()),
112 preview_(new RenderMonitoredPreview(this)),
115 preview_->fileChanged(boost::bind(&InsetInclude::fileChanged, this));
119 InsetInclude::InsetInclude(InsetInclude const & other)
121 params_(other.params_),
122 include_label(other.include_label),
123 preview_(new RenderMonitoredPreview(this)),
126 preview_->fileChanged(boost::bind(&InsetInclude::fileChanged, this));
130 InsetInclude::~InsetInclude()
132 InsetIncludeMailer(*this).hideDialog();
136 void InsetInclude::doDispatch(Cursor & cur, FuncRequest & cmd)
138 switch (cmd.action) {
140 case LFUN_INSET_MODIFY: {
141 InsetCommandParams p("include");
142 InsetIncludeMailer::string2params(to_utf8(cmd.argument()), p);
143 if (!p.getCmdName().empty()) {
145 InsetListingsParams par_old(params().getOptions());
146 InsetListingsParams par_new(p.getOptions());
147 if (par_old.getParamValue("label") !=
148 par_new.getParamValue("label")
149 && !par_new.getParamValue("label").empty())
150 cur.bv().buffer().changeRefsIfUnique(
151 from_utf8(par_old.getParamValue("label")),
152 from_utf8(par_new.getParamValue("label")),
155 set(p, cur.buffer());
156 cur.buffer().updateBibfilesCache();
162 case LFUN_INSET_DIALOG_UPDATE:
163 InsetIncludeMailer(*this).updateDialog(&cur.bv());
166 case LFUN_MOUSE_RELEASE:
167 if (!cur.selection())
168 InsetIncludeMailer(*this).showDialog(&cur.bv());
172 Inset::doDispatch(cur, cmd);
178 bool InsetInclude::getStatus(Cursor & cur, FuncRequest const & cmd,
179 FuncStatus & flag) const
181 switch (cmd.action) {
183 case LFUN_INSET_MODIFY:
184 case LFUN_INSET_DIALOG_UPDATE:
189 return Inset::getStatus(cur, cmd, flag);
194 InsetCommandParams const & InsetInclude::params() const
202 /// the type of inclusion
212 Types type(InsetCommandParams const & params)
214 string const command_name = params.getCmdName();
216 if (command_name == "input")
218 if (command_name == "verbatiminput")
220 if (command_name == "verbatiminput*")
222 if (command_name == "lstinputlisting")
228 bool isVerbatim(InsetCommandParams const & params)
230 string const command_name = params.getCmdName();
231 return command_name == "verbatiminput" ||
232 command_name == "verbatiminput*";
236 bool isInputOrInclude(InsetCommandParams const & params)
238 Types const t = type(params);
239 return (t == INPUT) || (t == INCLUDE);
243 string const masterFilename(Buffer const & buffer)
245 return buffer.getMasterBuffer()->fileName();
249 string const parentFilename(Buffer const & buffer)
251 return buffer.fileName();
255 FileName const includedFilename(Buffer const & buffer,
256 InsetCommandParams const & params)
258 return makeAbsPath(to_utf8(params["filename"]),
259 onlyPath(parentFilename(buffer)));
263 void add_preview(RenderMonitoredPreview &, InsetInclude const &, Buffer const &);
268 void InsetInclude::set(InsetCommandParams const & p, Buffer const & buffer)
273 if (preview_->monitoring())
274 preview_->stopMonitoring();
276 if (type(params_) == INPUT)
277 add_preview(*preview_, *this, buffer);
281 Inset * InsetInclude::clone() const
283 return new InsetInclude(*this);
287 void InsetInclude::write(Buffer const &, ostream & os) const
293 void InsetInclude::write(ostream & os) const
295 os << "Include " << to_utf8(params_.getCommand()) << '\n'
296 << "preview " << convert<string>(params_.preview()) << '\n';
300 void InsetInclude::read(Buffer const &, Lexer & lex)
306 void InsetInclude::read(Lexer & lex)
310 string const command = lex.getString();
311 params_.scanCommand(command);
316 token = lex.getString();
317 if (token == "\\end_inset")
319 if (token == "preview") {
321 params_.preview(lex.getBool());
323 lex.printError("Unknown parameter name `$$Token' for command " + params_.getCmdName());
325 if (token != "\\end_inset") {
326 lex.printError("Missing \\end_inset at this point. "
332 docstring const InsetInclude::getScreenLabel(Buffer const & buf) const
336 switch (type(params_)) {
338 temp = buf.B_("Input");
341 temp = buf.B_("Verbatim Input");
344 temp = buf.B_("Verbatim Input*");
347 temp = buf.B_("Include");
350 temp = listings_label_;
356 if (params_["filename"].empty())
359 temp += from_utf8(onlyFilename(to_utf8(params_["filename"])));
367 /// return the child buffer if the file is a LyX doc and is loaded
368 Buffer * getChildBuffer(Buffer const & buffer, InsetCommandParams const & params)
370 if (isVerbatim(params) || isListings(params))
373 string const included_file = includedFilename(buffer, params).absFilename();
374 if (!isLyXFilename(included_file))
377 Buffer * childBuffer = theBufferList().getBuffer(included_file);
379 //FIXME RECURSIVE INCLUDES
380 if (childBuffer == & buffer)
388 /// return true if the file is or got loaded.
389 Buffer * loadIfNeeded(Buffer const & parent, InsetCommandParams const & params)
391 if (isVerbatim(params) || isListings(params))
394 string const parent_filename = parent.fileName();
395 FileName const included_file = makeAbsPath(to_utf8(params["filename"]),
396 onlyPath(parent_filename));
398 if (!isLyXFilename(included_file.absFilename()))
401 Buffer * child = theBufferList().getBuffer(included_file.absFilename());
403 // the readonly flag can/will be wrong, not anymore I think.
404 if (!fs::exists(included_file.toFilesystemEncoding()))
407 child = theBufferList().newBuffer(included_file.absFilename());
408 if (!loadLyXFile(child, included_file)) {
409 //close the buffer we just opened
410 theBufferList().close(child, false);
414 child->setParentName(parent_filename);
419 int InsetInclude::latex(Buffer const & buffer, odocstream & os,
420 OutputParams const & runparams) const
422 string incfile(to_utf8(params_["filename"]));
424 // Do nothing if no file name has been specified
428 FileName const included_file(includedFilename(buffer, params_));
430 //Check we're not trying to include ourselves.
431 //FIXME RECURSIVE INCLUDE
432 //This isn't sufficient, as the inclusion could be downstream.
433 //But it'll have to do for now.
434 if (isInputOrInclude(params_) &&
435 buffer.fileName() == included_file.absFilename())
437 Alert::error(_("Recursive input"),
438 bformat(_("Attempted to include file %1$s in itself! "
439 "Ignoring inclusion."), from_utf8(incfile)));
443 Buffer const * const m_buffer = buffer.getMasterBuffer();
445 // if incfile is relative, make it relative to the master
447 if (!absolutePath(incfile)) {
449 incfile = to_utf8(makeRelPath(from_utf8(included_file.absFilename()),
450 from_utf8(m_buffer->filePath())));
453 // write it to a file (so far the complete file)
454 string const exportfile = changeExtension(incfile, ".tex");
455 string const mangled =
456 DocFileName(changeExtension(included_file.absFilename(),".tex")).
458 FileName const writefile(makeAbsPath(mangled, m_buffer->temppath()));
462 else if (!isValidLaTeXFilename(incfile)) {
463 frontend::Alert::warning(_("Invalid filename"),
464 _("The following filename is likely to cause trouble "
465 "when running the exported file through LaTeX: ") +
468 LYXERR(Debug::LATEX) << "incfile:" << incfile << endl;
469 LYXERR(Debug::LATEX) << "exportfile:" << exportfile << endl;
470 LYXERR(Debug::LATEX) << "writefile:" << writefile << endl;
472 if (runparams.inComment || runparams.dryrun) {
473 //Don't try to load or copy the file if we're
474 //in a comment or doing a dryrun
475 } else if (isInputOrInclude(params_) &&
476 isLyXFilename(included_file.absFilename())) {
477 //if it's a LyX file and we're inputting or including,
478 //try to load it so we can write the associated latex
479 if (!loadIfNeeded(buffer, params_))
482 Buffer * tmp = theBufferList().getBuffer(included_file.absFilename());
484 if (tmp->params().getBaseClass() != m_buffer->params().getBaseClass()) {
486 docstring text = bformat(_("Included file `%1$s'\n"
487 "has textclass `%2$s'\n"
488 "while parent file has textclass `%3$s'."),
489 makeDisplayPath(included_file.absFilename()),
490 from_utf8(tmp->params().getTextClass().name()),
491 from_utf8(m_buffer->params().getTextClass().name()));
492 Alert::warning(_("Different textclasses"), text);
496 // Make sure modules used in child are all included in master
497 //FIXME It might be worth loading the children's modules into the master
498 //over in BufferParams rather than doing this check.
499 vector<string> const masterModules = m_buffer->params().getModules();
500 vector<string> const childModules = tmp->params().getModules();
501 vector<string>::const_iterator it = childModules.begin();
502 vector<string>::const_iterator end = childModules.end();
503 for (; it != end; ++it) {
504 string const module = *it;
505 vector<string>::const_iterator found =
506 find(masterModules.begin(), masterModules.end(), module);
507 if (found != masterModules.end()) {
508 docstring text = bformat(_("Included file `%1$s'\n"
509 "uses module `%2$s'\n"
510 "which is not used in parent file."),
511 makeDisplayPath(included_file.absFilename()), from_utf8(module));
512 Alert::warning(_("Module not found"), text);
516 tmp->markDepClean(m_buffer->temppath());
518 // FIXME: handle non existing files
519 // FIXME: Second argument is irrelevant!
520 // since only_body is true, makeLaTeXFile will not look at second
521 // argument. Should we set it to string(), or should makeLaTeXFile
522 // make use of it somehow? (JMarc 20031002)
523 // The included file might be written in a different encoding
524 Encoding const * const oldEnc = runparams.encoding;
525 runparams.encoding = &tmp->params().encoding();
526 tmp->makeLaTeXFile(writefile,
527 onlyPath(masterFilename(buffer)),
529 runparams.encoding = oldEnc;
531 // In this case, it's not a LyX file, so we copy the file
532 // to the temp dir, so that .aux files etc. are not created
533 // in the original dir. Files included by this file will be
534 // found via input@path, see ../Buffer.cpp.
535 unsigned long const checksum_in = sum(included_file);
536 unsigned long const checksum_out = sum(writefile);
538 if (checksum_in != checksum_out) {
539 if (!copy(included_file, writefile)) {
542 << to_utf8(bformat(_("Could not copy the file\n%1$s\n"
543 "into the temporary directory."),
544 from_utf8(included_file.absFilename())))
551 string const tex_format = (runparams.flavor == OutputParams::LATEX) ?
552 "latex" : "pdflatex";
553 if (isVerbatim(params_)) {
554 incfile = latex_path(incfile);
556 os << '\\' << from_ascii(params_.getCmdName()) << '{'
557 << from_utf8(incfile) << '}';
558 } else if (type(params_) == INPUT) {
559 runparams.exportdata->addExternalFile(tex_format, writefile,
562 // \input wants file with extension (default is .tex)
563 if (!isLyXFilename(included_file.absFilename())) {
564 incfile = latex_path(incfile);
566 os << '\\' << from_ascii(params_.getCmdName())
567 << '{' << from_utf8(incfile) << '}';
569 incfile = changeExtension(incfile, ".tex");
570 incfile = latex_path(incfile);
572 os << '\\' << from_ascii(params_.getCmdName())
573 << '{' << from_utf8(incfile) << '}';
575 } else if (type(params_) == LISTINGS) {
576 os << '\\' << from_ascii(params_.getCmdName());
577 string opt = params_.getOptions();
578 // opt is set in QInclude dialog and should have passed validation.
579 InsetListingsParams params(opt);
580 if (!params.params().empty())
581 os << "[" << from_utf8(params.params()) << "]";
582 os << '{' << from_utf8(incfile) << '}';
584 runparams.exportdata->addExternalFile(tex_format, writefile,
587 // \include don't want extension and demands that the
588 // file really have .tex
589 incfile = changeExtension(incfile, string());
590 incfile = latex_path(incfile);
592 os << '\\' << from_ascii(params_.getCmdName()) << '{'
593 << from_utf8(incfile) << '}';
600 int InsetInclude::plaintext(Buffer const & buffer, odocstream & os,
601 OutputParams const &) const
603 if (isVerbatim(params_) || isListings(params_)) {
604 os << '[' << getScreenLabel(buffer) << '\n';
605 // FIXME: We don't know the encoding of the file
606 docstring const str =
607 from_utf8(getFileContents(includedFilename(buffer, params_)));
610 return PLAINTEXT_NEWLINE + 1; // one char on a separate line
612 docstring const str = '[' + getScreenLabel(buffer) + ']';
619 int InsetInclude::docbook(Buffer const & buffer, odocstream & os,
620 OutputParams const & runparams) const
622 string incfile = to_utf8(params_["filename"]);
624 // Do nothing if no file name has been specified
628 string const included_file = includedFilename(buffer, params_).absFilename();
630 //Check we're not trying to include ourselves.
631 //FIXME RECURSIVE INCLUDE
632 //This isn't sufficient, as the inclusion could be downstream.
633 //But it'll have to do for now.
634 if (buffer.fileName() == included_file) {
635 Alert::error(_("Recursive input"),
636 bformat(_("Attempted to include file %1$s in itself! "
637 "Ignoring inclusion."), from_utf8(incfile)));
641 // write it to a file (so far the complete file)
642 string const exportfile = changeExtension(incfile, ".sgml");
643 DocFileName writefile(changeExtension(included_file, ".sgml"));
645 if (loadIfNeeded(buffer, params_)) {
646 Buffer * tmp = theBufferList().getBuffer(included_file);
648 string const mangled = writefile.mangledFilename();
649 writefile = makeAbsPath(mangled,
650 buffer.getMasterBuffer()->temppath());
654 LYXERR(Debug::LATEX) << "incfile:" << incfile << endl;
655 LYXERR(Debug::LATEX) << "exportfile:" << exportfile << endl;
656 LYXERR(Debug::LATEX) << "writefile:" << writefile << endl;
658 tmp->makeDocBookFile(writefile, runparams, true);
661 runparams.exportdata->addExternalFile("docbook", writefile,
663 runparams.exportdata->addExternalFile("docbook-xml", writefile,
666 if (isVerbatim(params_) || isListings(params_)) {
667 os << "<inlinegraphic fileref=\""
668 << '&' << include_label << ';'
669 << "\" format=\"linespecific\">";
671 os << '&' << include_label << ';';
677 void InsetInclude::validate(LaTeXFeatures & features) const
679 string incfile(to_utf8(params_["filename"]));
682 Buffer const & buffer = features.buffer();
684 string const included_file = includedFilename(buffer, params_).absFilename();
686 if (isLyXFilename(included_file))
687 writefile = changeExtension(included_file, ".sgml");
689 writefile = included_file;
691 if (!features.runparams().nice && !isVerbatim(params_) && !isListings(params_)) {
692 incfile = DocFileName(writefile).mangledFilename();
693 writefile = makeAbsPath(incfile,
694 buffer.getMasterBuffer()->temppath()).absFilename();
697 features.includeFile(include_label, writefile);
699 if (isVerbatim(params_))
700 features.require("verbatim");
701 else if (isListings(params_))
702 features.require("listings");
704 // Here we must do the fun stuff...
705 // Load the file in the include if it needs
707 if (loadIfNeeded(buffer, params_)) {
709 Buffer * const tmp = theBufferList().getBuffer(included_file);
710 // make sure the buffer isn't us
711 // FIXME RECURSIVE INCLUDES
712 // This is not sufficient, as recursive includes could be
713 // more than a file away. But it will do for now.
714 if (tmp && tmp != & buffer) {
715 // We must temporarily change features.buffer,
716 // otherwise it would always be the master buffer,
717 // and nested includes would not work.
718 features.setBuffer(*tmp);
719 tmp->validate(features);
720 features.setBuffer(buffer);
726 void InsetInclude::getLabelList(Buffer const & buffer,
727 std::vector<docstring> & list) const
729 if (isListings(params_)) {
730 InsetListingsParams params(params_.getOptions());
731 string label = params.getParamValue("label");
733 list.push_back(from_utf8(label));
735 else if (loadIfNeeded(buffer, params_)) {
736 string const included_file = includedFilename(buffer, params_).absFilename();
737 Buffer * tmp = theBufferList().getBuffer(included_file);
738 tmp->setParentName("");
739 tmp->getLabelList(list);
740 tmp->setParentName(parentFilename(buffer));
745 void InsetInclude::fillWithBibKeys(Buffer const & buffer,
746 BiblioInfo & keys, InsetIterator const & /*di*/) const
748 if (loadIfNeeded(buffer, params_)) {
749 string const included_file = includedFilename(buffer, params_).absFilename();
750 Buffer * tmp = theBufferList().getBuffer(included_file);
751 //FIXME This is kind of a dirty hack and should be made reasonable.
752 tmp->setParentName("");
753 keys.fillWithBibKeys(tmp);
754 tmp->setParentName(parentFilename(buffer));
759 void InsetInclude::updateBibfilesCache(Buffer const & buffer)
761 Buffer * const tmp = getChildBuffer(buffer, params_);
763 tmp->setParentName("");
764 tmp->updateBibfilesCache();
765 tmp->setParentName(parentFilename(buffer));
770 std::vector<FileName> const &
771 InsetInclude::getBibfilesCache(Buffer const & buffer) const
773 Buffer * const tmp = getChildBuffer(buffer, params_);
775 tmp->setParentName("");
776 std::vector<FileName> const & cache = tmp->getBibfilesCache();
777 tmp->setParentName(parentFilename(buffer));
780 static std::vector<FileName> const empty;
785 bool InsetInclude::metrics(MetricsInfo & mi, Dimension & dim) const
787 BOOST_ASSERT(mi.base.bv);
789 bool use_preview = false;
790 if (RenderPreview::status() != LyXRC::PREVIEW_OFF) {
791 graphics::PreviewImage const * pimage =
792 preview_->getPreviewImage(mi.base.bv->buffer());
793 use_preview = pimage && pimage->image();
797 preview_->metrics(mi, dim);
801 button_.update(getScreenLabel(mi.base.bv->buffer()),
804 button_.metrics(mi, dim);
807 Box b(0, dim.wid, -dim.asc, dim.des);
810 bool const changed = dim_ != dim;
816 void InsetInclude::draw(PainterInfo & pi, int x, int y) const
818 setPosCache(pi, x, y);
820 BOOST_ASSERT(pi.base.bv);
822 bool use_preview = false;
823 if (RenderPreview::status() != LyXRC::PREVIEW_OFF) {
824 graphics::PreviewImage const * pimage =
825 preview_->getPreviewImage(pi.base.bv->buffer());
826 use_preview = pimage && pimage->image();
830 preview_->draw(pi, x, y);
832 button_.draw(pi, x, y);
836 Inset::DisplayType InsetInclude::display() const
838 return type(params_) == INPUT ? Inline : AlignCenter;
847 void InsetInclude::fileChanged() const
849 Buffer const * const buffer_ptr = LyX::cref().updateInset(this);
853 Buffer const & buffer = *buffer_ptr;
854 preview_->removePreview(buffer);
855 add_preview(*preview_.get(), *this, buffer);
856 preview_->startLoading(buffer);
862 bool preview_wanted(InsetCommandParams const & params, Buffer const & buffer)
864 FileName const included_file = includedFilename(buffer, params);
866 return type(params) == INPUT && params.preview() &&
867 isFileReadable(included_file);
871 docstring const latex_string(InsetInclude const & inset, Buffer const & buffer)
874 // We don't need to set runparams.encoding since this will be done
875 // by latex() anyway.
876 OutputParams runparams(0);
877 runparams.flavor = OutputParams::LATEX;
878 inset.latex(buffer, os, runparams);
884 void add_preview(RenderMonitoredPreview & renderer, InsetInclude const & inset,
885 Buffer const & buffer)
887 InsetCommandParams const & params = inset.params();
888 if (RenderPreview::status() != LyXRC::PREVIEW_OFF &&
889 preview_wanted(params, buffer)) {
890 renderer.setAbsFile(includedFilename(buffer, params));
891 docstring const snippet = latex_string(inset, buffer);
892 renderer.addPreview(snippet, buffer);
899 void InsetInclude::addPreview(graphics::PreviewLoader & ploader) const
901 Buffer const & buffer = ploader.buffer();
902 if (preview_wanted(params(), buffer)) {
903 preview_->setAbsFile(includedFilename(buffer, params()));
904 docstring const snippet = latex_string(*this, buffer);
905 preview_->addPreview(snippet, ploader);
910 void InsetInclude::addToToc(TocList & toclist, Buffer const & buffer, ParConstIterator const & pit) const
912 if (isListings(params_)) {
913 InsetListingsParams params(params_.getOptions());
914 string caption = params.getParamValue("caption");
915 if (!caption.empty()) {
916 Toc & toc = toclist["listing"];
917 docstring const str = convert<docstring>(toc.size() + 1)
918 + ". " + from_utf8(caption);
919 // This inset does not have a valid ParConstIterator
920 // so it has to use the iterator of its parent paragraph
921 toc.push_back(TocItem(pit, 0, str));
925 Buffer const * const childbuffer = getChildBuffer(buffer, params_);
929 TocList const & childtoclist = childbuffer->tocBackend().tocs();
930 TocList::const_iterator it = childtoclist.begin();
931 TocList::const_iterator const end = childtoclist.end();
932 for(; it != end; ++it)
933 toclist[it->first].insert(toclist[it->first].end(),
934 it->second.begin(), it->second.end());
938 void InsetInclude::updateLabels(Buffer const & buffer,
941 Buffer const * const childbuffer = getChildBuffer(buffer, params_);
943 lyx::updateLabels(*childbuffer, true);
944 else if (isListings(params_)) {
945 InsetListingsParams const par = params_.getOptions();
946 if (par.getParamValue("caption").empty())
947 listings_label_.clear();
949 Counters & counters = buffer.params().getTextClass().counters();
950 docstring const cnt = from_ascii("listing");
951 if (counters.hasCounter(cnt)) {
953 listings_label_ = buffer.B_("Program Listing ") + convert<docstring>(counters.value(cnt));
955 listings_label_ = buffer.B_("Program Listing");
961 string const InsetIncludeMailer::name_("include");
963 InsetIncludeMailer::InsetIncludeMailer(InsetInclude & inset)
968 string const InsetIncludeMailer::inset2string(Buffer const &) const
970 return params2string(inset_.params());
974 void InsetIncludeMailer::string2params(string const & in,
975 InsetCommandParams & params)
981 istringstream data(in);
987 if (!lex || name != name_)
988 return print_mailer_error("InsetIncludeMailer", in, 1, name_);
990 // This is part of the inset proper that is usually swallowed
991 // by Text::readInset
994 if (!lex || id != "Include")
995 return print_mailer_error("InsetIncludeMailer", in, 2, "Include");
997 InsetInclude inset(params);
999 params = inset.params();
1004 InsetIncludeMailer::params2string(InsetCommandParams const & params)
1006 InsetInclude inset(params);
1008 data << name_ << ' ';
1010 data << "\\end_inset\n";