]> git.lyx.org Git - lyx.git/blob - src/insets/insetinclude.C
Prevent automatic opening of child docs because of natbib labels
[lyx.git] / src / insets / insetinclude.C
1 /**
2  * \file insetinclude.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Lars Gullik Bjønnes
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "insetinclude.h"
14
15 #include "buffer.h"
16 #include "buffer_funcs.h"
17 #include "bufferlist.h"
18 #include "bufferparams.h"
19 #include "BufferView.h"
20 #include "cursor.h"
21 #include "debug.h"
22 #include "dispatchresult.h"
23 #include "exporter.h"
24 #include "funcrequest.h"
25 #include "FuncStatus.h"
26 #include "gettext.h"
27 #include "LaTeXFeatures.h"
28 #include "lyx_main.h"
29 #include "lyxrc.h"
30 #include "lyxlex.h"
31 #include "metricsinfo.h"
32 #include "outputparams.h"
33
34 #include "frontends/Alert.h"
35 #include "frontends/LyXView.h"
36 #include "frontends/Painter.h"
37
38 #include "graphics/PreviewImage.h"
39 #include "graphics/PreviewLoader.h"
40
41 #include "insets/render_preview.h"
42
43 #include "support/filename.h"
44 #include "support/filetools.h"
45 #include "support/lstrings.h" // contains
46 #include "support/lyxlib.h"
47 #include "support/convert.h"
48
49 #include <boost/bind.hpp>
50 #include <boost/filesystem/operations.hpp>
51
52 #include "support/std_ostream.h"
53
54 #include <sstream>
55
56 using lyx::support::addName;
57 using lyx::support::absolutePath;
58 using lyx::support::bformat;
59 using lyx::support::changeExtension;
60 using lyx::support::contains;
61 using lyx::support::copy;
62 using lyx::support::FileName;
63 using lyx::support::getFileContents;
64 using lyx::support::isFileReadable;
65 using lyx::support::isLyXFilename;
66 using lyx::support::latex_path;
67 using lyx::support::makeAbsPath;
68 using lyx::support::makeDisplayPath;
69 using lyx::support::makeRelPath;
70 using lyx::support::onlyFilename;
71 using lyx::support::onlyPath;
72 using lyx::support::subst;
73 using lyx::support::sum;
74
75 using std::endl;
76 using std::string;
77 using std::auto_ptr;
78 using std::istringstream;
79 using std::ostream;
80 using std::ostringstream;
81
82 namespace fs = boost::filesystem;
83
84 extern BufferList bufferlist;
85
86
87 namespace {
88
89 string const uniqueID()
90 {
91         static unsigned int seed = 1000;
92         return "file" + convert<string>(++seed);
93 }
94
95 } // namespace anon
96
97
98 InsetInclude::InsetInclude(InsetCommandParams const & p)
99         : params_(p), include_label(uniqueID()),
100           preview_(new RenderMonitoredPreview(this)),
101           set_label_(false)
102 {
103         preview_->fileChanged(boost::bind(&InsetInclude::fileChanged, this));
104 }
105
106
107 InsetInclude::InsetInclude(InsetInclude const & other)
108         : InsetOld(other),
109           params_(other.params_),
110           include_label(other.include_label),
111           preview_(new RenderMonitoredPreview(this)),
112           set_label_(false)
113 {
114         preview_->fileChanged(boost::bind(&InsetInclude::fileChanged, this));
115 }
116
117
118 InsetInclude::~InsetInclude()
119 {
120         InsetIncludeMailer(*this).hideDialog();
121 }
122
123
124 void InsetInclude::doDispatch(LCursor & cur, FuncRequest & cmd)
125 {
126         switch (cmd.action) {
127
128         case LFUN_INSET_MODIFY: {
129                 InsetCommandParams p;
130                 InsetIncludeMailer::string2params(cmd.argument, p);
131                 if (!p.getCmdName().empty()) {
132                         set(p, cur.buffer());
133                         cur.buffer().updateBibfilesCache();
134                 } else
135                         cur.noUpdate();
136                 break;
137         }
138
139         case LFUN_INSET_DIALOG_UPDATE:
140                 InsetIncludeMailer(*this).updateDialog(&cur.bv());
141                 break;
142
143         case LFUN_MOUSE_RELEASE:
144         case LFUN_INSET_DIALOG_SHOW:
145                 InsetIncludeMailer(*this).showDialog(&cur.bv());
146                 break;
147
148         default:
149                 InsetBase::doDispatch(cur, cmd);
150                 break;
151         }
152 }
153
154
155 bool InsetInclude::getStatus(LCursor & cur, FuncRequest const & cmd,
156                 FuncStatus & flag) const
157 {
158         switch (cmd.action) {
159
160         case LFUN_INSET_MODIFY:
161         case LFUN_INSET_DIALOG_UPDATE:
162         case LFUN_INSET_DIALOG_SHOW:
163                 flag.enabled(true);
164                 return true;
165
166         default:
167                 return InsetBase::getStatus(cur, cmd, flag);
168         }
169 }
170
171
172 InsetCommandParams const & InsetInclude::params() const
173 {
174         return params_;
175 }
176
177
178 namespace {
179
180 /// the type of inclusion
181 enum Types {
182         INCLUDE = 0,
183         VERB = 1,
184         INPUT = 2,
185         VERBAST = 3
186 };
187
188
189 Types type(InsetCommandParams const & params)
190 {
191         string const command_name = params.getCmdName();
192
193         if (command_name == "input")
194                 return INPUT;
195         if  (command_name == "verbatiminput")
196                 return VERB;
197         if  (command_name == "verbatiminput*")
198                 return VERBAST;
199         return INCLUDE;
200 }
201
202
203 bool isVerbatim(InsetCommandParams const & params)
204 {
205         string const command_name = params.getCmdName();
206         return command_name == "verbatiminput" ||
207                 command_name == "verbatiminput*";
208 }
209
210
211 string const masterFilename(Buffer const & buffer)
212 {
213         return buffer.getMasterBuffer()->fileName();
214 }
215
216
217 string const parentFilename(Buffer const & buffer)
218 {
219         return buffer.fileName();
220 }
221
222
223 string const includedFilename(Buffer const & buffer,
224                               InsetCommandParams const & params)
225 {
226         return makeAbsPath(params.getContents(),
227                            onlyPath(parentFilename(buffer)));
228 }
229
230
231 void add_preview(RenderMonitoredPreview &, InsetInclude const &, Buffer const &);
232
233 } // namespace anon
234
235
236 void InsetInclude::set(InsetCommandParams const & p, Buffer const & buffer)
237 {
238         params_ = p;
239         set_label_ = false;
240
241         if (preview_->monitoring())
242                 preview_->stopMonitoring();
243
244         if (type(params_) == INPUT)
245                 add_preview(*preview_, *this, buffer);
246 }
247
248
249 auto_ptr<InsetBase> InsetInclude::doClone() const
250 {
251         return auto_ptr<InsetBase>(new InsetInclude(*this));
252 }
253
254
255 void InsetInclude::write(Buffer const &, ostream & os) const
256 {
257         write(os);
258 }
259
260
261 void InsetInclude::write(ostream & os) const
262 {
263         os << "Include " << params_.getCommand() << '\n'
264            << "preview " << convert<string>(params_.preview()) << '\n';
265 }
266
267
268 void InsetInclude::read(Buffer const &, LyXLex & lex)
269 {
270         read(lex);
271 }
272
273
274 void InsetInclude::read(LyXLex & lex)
275 {
276         params_.read(lex);
277 }
278
279
280 string const InsetInclude::getScreenLabel(Buffer const &) const
281 {
282         string temp;
283
284         switch (type(params_)) {
285                 case INPUT: temp += _("Input"); break;
286                 case VERB: temp += _("Verbatim Input"); break;
287                 case VERBAST: temp += _("Verbatim Input*"); break;
288                 case INCLUDE: temp += _("Include"); break;
289         }
290
291         temp += ": ";
292
293         if (params_.getContents().empty())
294                 temp += "???";
295         else
296                 temp += onlyFilename(params_.getContents());
297
298         return temp;
299 }
300
301
302 namespace {
303
304 /// return the child buffer if the file is a LyX doc and is loaded
305 Buffer * getChildBuffer(Buffer const & buffer, InsetCommandParams const & params)
306 {
307         if (isVerbatim(params))
308                 return 0;
309
310         string const included_file = includedFilename(buffer, params);
311         if (!isLyXFilename(included_file))
312                 return 0;
313
314         return bufferlist.getBuffer(included_file);
315 }
316
317
318 /// return true if the file is or got loaded.
319 bool loadIfNeeded(Buffer const & buffer, InsetCommandParams const & params)
320 {
321         if (isVerbatim(params))
322                 return false;
323
324         string const included_file = includedFilename(buffer, params);
325         if (!isLyXFilename(included_file))
326                 return false;
327
328         Buffer * buf = bufferlist.getBuffer(included_file);
329         if (!buf) {
330                 // the readonly flag can/will be wrong, not anymore I think.
331                 if (!fs::exists(included_file))
332                         return false;
333                 buf = bufferlist.newBuffer(included_file);
334                 if (!loadLyXFile(buf, included_file))
335                         return false;
336         }
337         if (buf)
338                 buf->setParentName(parentFilename(buffer));
339         return buf != 0;
340 }
341
342
343 } // namespace anon
344
345
346 int InsetInclude::latex(Buffer const & buffer, ostream & os,
347                         OutputParams const & runparams) const
348 {
349         string incfile(params_.getContents());
350
351         // Do nothing if no file name has been specified
352         if (incfile.empty())
353                 return 0;
354
355         string const included_file = includedFilename(buffer, params_);
356         Buffer const * const m_buffer = buffer.getMasterBuffer();
357
358         // if incfile is relative, make it relative to the master
359         // buffer directory.
360         if (!absolutePath(incfile)) {
361                 incfile = makeRelPath(included_file,
362                                       m_buffer->filePath());
363         }
364
365         // write it to a file (so far the complete file)
366         string const exportfile = changeExtension(incfile, ".tex");
367         string const mangled = FileName(changeExtension(included_file,
368                                                         ".tex")).mangledFilename();
369         string const writefile = makeAbsPath(mangled, m_buffer->temppath());
370
371         if (!runparams.nice)
372                 incfile = mangled;
373         lyxerr[Debug::LATEX] << "incfile:" << incfile << endl;
374         lyxerr[Debug::LATEX] << "exportfile:" << exportfile << endl;
375         lyxerr[Debug::LATEX] << "writefile:" << writefile << endl;
376
377         if (runparams.inComment || runparams.dryrun)
378                 // Don't try to load or copy the file
379                 ;
380         else if (loadIfNeeded(buffer, params_)) {
381                 Buffer * tmp = bufferlist.getBuffer(included_file);
382
383                 if (tmp->params().textclass != m_buffer->params().textclass) {
384                         string text = bformat(_("Included file `%1$s'\n"
385                                                 "has textclass `%2$s'\n"
386                                                 "while parent file has textclass `%3$s'."),
387                                               makeDisplayPath(included_file),
388                                               tmp->params().getLyXTextClass().name(),
389                                               m_buffer->params().getLyXTextClass().name());
390                         Alert::warning(_("Different textclasses"), text);
391                         //return 0;
392                 }
393
394                 tmp->markDepClean(m_buffer->temppath());
395
396 #ifdef WITH_WARNINGS
397 #warning handle non existing files
398 #warning Second argument is irrelevant!
399 // since only_body is true, makeLaTeXFile will not look at second
400 // argument. Should we set it to string(), or should makeLaTeXFile
401 // make use of it somehow? (JMarc 20031002)
402 #endif
403                 tmp->makeLaTeXFile(writefile,
404                                    onlyPath(masterFilename(buffer)),
405                                    runparams, false);
406         } else {
407                 // Copy the file to the temp dir, so that .aux files etc.
408                 // are not created in the original dir. Files included by
409                 // this file will be found via input@path, see ../buffer.C.
410                 unsigned long const checksum_in  = sum(included_file);
411                 unsigned long const checksum_out = sum(writefile);
412
413                 if (checksum_in != checksum_out) {
414                         if (!copy(included_file, writefile)) {
415                                 lyxerr[Debug::LATEX]
416                                         << bformat(_("Could not copy the file\n%1$s\n"
417                                                      "into the temporary directory."),
418                                                    included_file)
419                                         << endl;
420                                 return 0;
421                         }
422                 }
423         }
424
425         string const tex_format = (runparams.flavor == OutputParams::LATEX) ?
426                         "latex" : "pdflatex";
427         if (isVerbatim(params_)) {
428                 incfile = latex_path(incfile);
429                 os << '\\' << params_.getCmdName() << '{' << incfile << '}';
430         } else if (type(params_) == INPUT) {
431                 runparams.exportdata->addExternalFile(tex_format, writefile,
432                                                       exportfile);
433
434                 // \input wants file with extension (default is .tex)
435                 if (!isLyXFilename(included_file)) {
436                         incfile = latex_path(incfile);
437                         os << '\\' << params_.getCmdName() << '{' << incfile << '}';
438                 } else {
439                 incfile = changeExtension(incfile, ".tex");
440                 incfile = latex_path(incfile);
441                         os << '\\' << params_.getCmdName() << '{'
442                            << incfile
443                            <<  '}';
444                 }
445         } else {
446                 runparams.exportdata->addExternalFile(tex_format, writefile,
447                                                       exportfile);
448
449                 // \include don't want extension and demands that the
450                 // file really have .tex
451                 incfile = changeExtension(incfile, string());
452                 incfile = latex_path(incfile);
453                 os << '\\' << params_.getCmdName() << '{'
454                    << incfile
455                    << '}';
456         }
457
458         return 0;
459 }
460
461
462 int InsetInclude::plaintext(Buffer const & buffer, ostream & os,
463                         OutputParams const &) const
464 {
465         if (isVerbatim(params_))
466                 os << getFileContents(includedFilename(buffer, params_));
467         return 0;
468 }
469
470
471 int InsetInclude::linuxdoc(Buffer const & buffer, ostream & os,
472                            OutputParams const & runparams) const
473 {
474         string incfile(params_.getContents());
475
476         // Do nothing if no file name has been specified
477         if (incfile.empty())
478                 return 0;
479
480         string const included_file = includedFilename(buffer, params_);
481
482         // write it to a file (so far the complete file)
483         string const exportfile = changeExtension(incfile, ".sgml");
484         string writefile = changeExtension(included_file, ".sgml");
485
486         if (loadIfNeeded(buffer, params_)) {
487                 Buffer * tmp = bufferlist.getBuffer(included_file);
488
489                 writefile = makeAbsPath(FileName(writefile).mangledFilename(),
490                                         buffer.getMasterBuffer()->temppath());
491                 if (!runparams.nice)
492                         incfile = writefile;
493
494                 lyxerr[Debug::LATEX] << "incfile:" << incfile << endl;
495                 lyxerr[Debug::LATEX] << "exportfile:" << exportfile << endl;
496                 lyxerr[Debug::LATEX] << "writefile:" << writefile << endl;
497
498                 tmp->makeLinuxDocFile(writefile, runparams, true);
499         }
500
501         if (isVerbatim(params_)) {
502                 os << "<![CDATA["
503                    << getFileContents(included_file)
504                    << "]]>";
505         } else {
506                 runparams.exportdata->addExternalFile("linuxdoc", writefile,
507                                                       exportfile);
508                 os << '&' << include_label << ';';
509         }
510
511         return 0;
512 }
513
514
515 int InsetInclude::docbook(Buffer const & buffer, ostream & os,
516                           OutputParams const & runparams) const
517 {
518         string incfile(params_.getContents());
519
520         // Do nothing if no file name has been specified
521         if (incfile.empty())
522                 return 0;
523
524         string const included_file = includedFilename(buffer, params_);
525
526         // write it to a file (so far the complete file)
527         string const exportfile = changeExtension(incfile, ".sgml");
528         string writefile = changeExtension(included_file, ".sgml");
529
530         if (loadIfNeeded(buffer, params_)) {
531                 Buffer * tmp = bufferlist.getBuffer(included_file);
532
533                 string const mangled = FileName(writefile).mangledFilename();
534                 writefile = makeAbsPath(mangled,
535                                         buffer.getMasterBuffer()->temppath());
536                 if (!runparams.nice)
537                         incfile = mangled;
538
539                 lyxerr[Debug::LATEX] << "incfile:" << incfile << endl;
540                 lyxerr[Debug::LATEX] << "exportfile:" << exportfile << endl;
541                 lyxerr[Debug::LATEX] << "writefile:" << writefile << endl;
542
543                 tmp->makeDocBookFile(writefile, runparams, true);
544         }
545
546         runparams.exportdata->addExternalFile("docbook", writefile,
547                                               exportfile);
548         runparams.exportdata->addExternalFile("docbook-xml", writefile,
549                                               exportfile);
550
551         if (isVerbatim(params_)) {
552                 os << "<inlinegraphic fileref=\""
553                    << '&' << include_label << ';'
554                    << "\" format=\"linespecific\">";
555         } else
556                 os << '&' << include_label << ';';
557
558         return 0;
559 }
560
561
562 void InsetInclude::validate(LaTeXFeatures & features) const
563 {
564         string incfile(params_.getContents());
565         string writefile;
566
567         Buffer const & buffer = features.buffer();
568
569         string const included_file = includedFilename(buffer, params_);
570
571         if (isLyXFilename(included_file))
572                 writefile = changeExtension(included_file, ".sgml");
573         else
574                 writefile = included_file;
575
576         if (!features.runparams().nice && !isVerbatim(params_)) {
577                 incfile = FileName(writefile).mangledFilename();
578                 writefile = makeAbsPath(incfile,
579                                         buffer.getMasterBuffer()->temppath());
580         }
581
582         features.includeFile(include_label, writefile);
583
584         if (isVerbatim(params_))
585                 features.require("verbatim");
586
587         // Here we must do the fun stuff...
588         // Load the file in the include if it needs
589         // to be loaded:
590         if (loadIfNeeded(buffer, params_)) {
591                 // a file got loaded
592                 Buffer * const tmp = bufferlist.getBuffer(included_file);
593                 if (tmp) {
594                         // We must temporarily change features.buffer,
595                         // otherwise it would always be the master buffer,
596                         // and nested includes would not work.
597                         features.setBuffer(*tmp);
598                         tmp->validate(features);
599                         features.setBuffer(buffer);
600                 }
601         }
602 }
603
604
605 void InsetInclude::getLabelList(Buffer const & buffer,
606                                 std::vector<string> & list) const
607 {
608         if (loadIfNeeded(buffer, params_)) {
609                 string const included_file = includedFilename(buffer, params_);
610                 Buffer * tmp = bufferlist.getBuffer(included_file);
611                 tmp->setParentName("");
612                 tmp->getLabelList(list);
613                 tmp->setParentName(parentFilename(buffer));
614         }
615 }
616
617
618 void InsetInclude::fillWithBibKeys(Buffer const & buffer,
619                                    std::vector<std::pair<string,string> > & keys) const
620 {
621         if (loadIfNeeded(buffer, params_)) {
622                 string const included_file = includedFilename(buffer, params_);
623                 Buffer * tmp = bufferlist.getBuffer(included_file);
624                 tmp->setParentName("");
625                 tmp->fillWithBibKeys(keys);
626                 tmp->setParentName(parentFilename(buffer));
627         }
628 }
629
630
631 void InsetInclude::updateBibfilesCache(Buffer const & buffer)
632 {
633         Buffer * const tmp = getChildBuffer(buffer, params_);
634         if (tmp) {
635                 tmp->setParentName("");
636                 tmp->updateBibfilesCache();
637                 tmp->setParentName(parentFilename(buffer));
638         }
639 }
640
641
642 std::vector<string> const &
643 InsetInclude::getBibfilesCache(Buffer const & buffer) const
644 {
645         Buffer * const tmp = getChildBuffer(buffer, params_);
646         if (tmp) {
647                 tmp->setParentName("");
648                 std::vector<string> const & cache = tmp->getBibfilesCache();
649                 tmp->setParentName(parentFilename(buffer));
650                 return cache;
651         }
652         static std::vector<string> const empty;
653         return empty;
654 }
655
656
657 void InsetInclude::metrics(MetricsInfo & mi, Dimension & dim) const
658 {
659         BOOST_ASSERT(mi.base.bv && mi.base.bv->buffer());
660
661         bool use_preview = false;
662         if (RenderPreview::status() != LyXRC::PREVIEW_OFF) {
663                 lyx::graphics::PreviewImage const * pimage =
664                         preview_->getPreviewImage(*mi.base.bv->buffer());
665                 use_preview = pimage && pimage->image();
666         }
667
668         if (use_preview) {
669                 preview_->metrics(mi, dim);
670         } else {
671                 if (!set_label_) {
672                         set_label_ = true;
673                         button_.update(getScreenLabel(*mi.base.bv->buffer()),
674                                        true);
675                 }
676                 button_.metrics(mi, dim);
677         }
678
679         Box b(0, dim.wid, -dim.asc, dim.des);
680         button_.setBox(b);
681
682         dim_ = dim;
683 }
684
685
686 void InsetInclude::draw(PainterInfo & pi, int x, int y) const
687 {
688         setPosCache(pi, x, y);
689
690         BOOST_ASSERT(pi.base.bv && pi.base.bv->buffer());
691
692         bool use_preview = false;
693         if (RenderPreview::status() != LyXRC::PREVIEW_OFF) {
694                 lyx::graphics::PreviewImage const * pimage =
695                         preview_->getPreviewImage(*pi.base.bv->buffer());
696                 use_preview = pimage && pimage->image();
697         }
698
699         if (use_preview)
700                 preview_->draw(pi, x, y);
701         else
702                 button_.draw(pi, x, y);
703 }
704
705 bool InsetInclude::display() const
706 {
707         return type(params_) != INPUT;
708 }
709
710
711
712 //
713 // preview stuff
714 //
715
716 void InsetInclude::fileChanged() const
717 {
718         Buffer const * const buffer_ptr = LyX::cref().updateInset(this);
719         if (!buffer_ptr)
720                 return;
721
722         Buffer const & buffer = *buffer_ptr;
723         preview_->removePreview(buffer);
724         add_preview(*preview_.get(), *this, buffer);
725         preview_->startLoading(buffer);
726 }
727
728
729 namespace {
730
731 bool preview_wanted(InsetCommandParams const & params, Buffer const & buffer)
732 {
733         string const included_file = includedFilename(buffer, params);
734
735         return type(params) == INPUT && params.preview() &&
736                 isFileReadable(included_file);
737 }
738
739
740 string const latex_string(InsetInclude const & inset, Buffer const & buffer)
741 {
742         ostringstream os;
743         OutputParams runparams;
744         runparams.flavor = OutputParams::LATEX;
745         inset.latex(buffer, os, runparams);
746
747         return os.str();
748 }
749
750
751 void add_preview(RenderMonitoredPreview & renderer, InsetInclude const & inset,
752                  Buffer const & buffer)
753 {
754         InsetCommandParams const & params = inset.params();
755         if (RenderPreview::status() != LyXRC::PREVIEW_OFF &&
756             preview_wanted(params, buffer)) {
757                 renderer.setAbsFile(includedFilename(buffer, params));
758                 string const snippet = latex_string(inset, buffer);
759                 renderer.addPreview(snippet, buffer);
760         }
761 }
762
763 } // namespace anon
764
765
766 void InsetInclude::addPreview(lyx::graphics::PreviewLoader & ploader) const
767 {
768         Buffer const & buffer = ploader.buffer();
769         if (preview_wanted(params(), buffer)) {
770                 preview_->setAbsFile(includedFilename(buffer, params()));
771                 string const snippet = latex_string(*this, buffer);
772                 preview_->addPreview(snippet, ploader);
773         }
774 }
775
776
777 string const InsetIncludeMailer::name_("include");
778
779 InsetIncludeMailer::InsetIncludeMailer(InsetInclude & inset)
780         : inset_(inset)
781 {}
782
783
784 string const InsetIncludeMailer::inset2string(Buffer const &) const
785 {
786         return params2string(inset_.params());
787 }
788
789
790 void InsetIncludeMailer::string2params(string const & in,
791                                        InsetCommandParams & params)
792 {
793         params = InsetCommandParams();
794         if (in.empty())
795                 return;
796
797         istringstream data(in);
798         LyXLex lex(0,0);
799         lex.setStream(data);
800
801         string name;
802         lex >> name;
803         if (!lex || name != name_)
804                 return print_mailer_error("InsetIncludeMailer", in, 1, name_);
805
806         // This is part of the inset proper that is usually swallowed
807         // by LyXText::readInset
808         string id;
809         lex >> id;
810         if (!lex || id != "Include")
811                 return print_mailer_error("InsetIncludeMailer", in, 2, "Include");
812
813         InsetInclude inset(params);
814         inset.read(lex);
815         params = inset.params();
816 }
817
818
819 string const
820 InsetIncludeMailer::params2string(InsetCommandParams const & params)
821 {
822         InsetInclude inset(params);
823         ostringstream data;
824         data << name_ << ' ';
825         inset.write(data);
826         data << "\\end_inset\n";
827         return data.str();
828 }