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