]> git.lyx.org Git - lyx.git/blob - src/insets/insetinclude.C
Much better performance when using natbib (bug 2460):
[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 true if the file is or got loaded.
305 bool loadIfNeeded(Buffer const & buffer, InsetCommandParams const & params)
306 {
307         if (isVerbatim(params))
308                 return false;
309
310         string const included_file = includedFilename(buffer, params);
311         if (!isLyXFilename(included_file))
312                 return false;
313
314         Buffer * buf = bufferlist.getBuffer(included_file);
315         if (!buf) {
316                 // the readonly flag can/will be wrong, not anymore I think.
317                 if (!fs::exists(included_file))
318                         return false;
319                 buf = bufferlist.newBuffer(included_file);
320                 if (!loadLyXFile(buf, included_file))
321                         return false;
322         }
323         if (buf)
324                 buf->setParentName(parentFilename(buffer));
325         return buf != 0;
326 }
327
328
329 } // namespace anon
330
331
332 int InsetInclude::latex(Buffer const & buffer, ostream & os,
333                         OutputParams const & runparams) const
334 {
335         string incfile(params_.getContents());
336
337         // Do nothing if no file name has been specified
338         if (incfile.empty())
339                 return 0;
340
341         string const included_file = includedFilename(buffer, params_);
342         Buffer const * const m_buffer = buffer.getMasterBuffer();
343
344         // if incfile is relative, make it relative to the master
345         // buffer directory.
346         if (!absolutePath(incfile)) {
347                 incfile = makeRelPath(included_file,
348                                       m_buffer->filePath());
349         }
350
351         // write it to a file (so far the complete file)
352         string const exportfile = changeExtension(incfile, ".tex");
353         string const mangled = FileName(changeExtension(included_file,
354                                                         ".tex")).mangledFilename();
355         string const writefile = makeAbsPath(mangled, m_buffer->temppath());
356
357         if (!runparams.nice)
358                 incfile = mangled;
359         lyxerr[Debug::LATEX] << "incfile:" << incfile << endl;
360         lyxerr[Debug::LATEX] << "exportfile:" << exportfile << endl;
361         lyxerr[Debug::LATEX] << "writefile:" << writefile << endl;
362
363         if (runparams.inComment || runparams.dryrun)
364                 // Don't try to load or copy the file
365                 ;
366         else if (loadIfNeeded(buffer, params_)) {
367                 Buffer * tmp = bufferlist.getBuffer(included_file);
368
369                 if (tmp->params().textclass != m_buffer->params().textclass) {
370                         string text = bformat(_("Included file `%1$s'\n"
371                                                 "has textclass `%2$s'\n"
372                                                 "while parent file has textclass `%3$s'."),
373                                               makeDisplayPath(included_file),
374                                               tmp->params().getLyXTextClass().name(),
375                                               m_buffer->params().getLyXTextClass().name());
376                         Alert::warning(_("Different textclasses"), text);
377                         //return 0;
378                 }
379
380                 tmp->markDepClean(m_buffer->temppath());
381
382 #ifdef WITH_WARNINGS
383 #warning handle non existing files
384 #warning Second argument is irrelevant!
385 // since only_body is true, makeLaTeXFile will not look at second
386 // argument. Should we set it to string(), or should makeLaTeXFile
387 // make use of it somehow? (JMarc 20031002)
388 #endif
389                 tmp->makeLaTeXFile(writefile,
390                                    onlyPath(masterFilename(buffer)),
391                                    runparams, false);
392         } else {
393                 // Copy the file to the temp dir, so that .aux files etc.
394                 // are not created in the original dir. Files included by
395                 // this file will be found via input@path, see ../buffer.C.
396                 unsigned long const checksum_in  = sum(included_file);
397                 unsigned long const checksum_out = sum(writefile);
398
399                 if (checksum_in != checksum_out) {
400                         if (!copy(included_file, writefile)) {
401                                 lyxerr[Debug::LATEX]
402                                         << bformat(_("Could not copy the file\n%1$s\n"
403                                                      "into the temporary directory."),
404                                                    included_file)
405                                         << endl;
406                                 return 0;
407                         }
408                 }
409         }
410
411         string const tex_format = (runparams.flavor == OutputParams::LATEX) ?
412                         "latex" : "pdflatex";
413         if (isVerbatim(params_)) {
414                 incfile = latex_path(incfile);
415                 os << '\\' << params_.getCmdName() << '{' << incfile << '}';
416         } else if (type(params_) == INPUT) {
417                 runparams.exportdata->addExternalFile(tex_format, writefile,
418                                                       exportfile);
419
420                 // \input wants file with extension (default is .tex)
421                 if (!isLyXFilename(included_file)) {
422                         incfile = latex_path(incfile);
423                         os << '\\' << params_.getCmdName() << '{' << incfile << '}';
424                 } else {
425                 incfile = changeExtension(incfile, ".tex");
426                 incfile = latex_path(incfile);
427                         os << '\\' << params_.getCmdName() << '{'
428                            << incfile
429                            <<  '}';
430                 }
431         } else {
432                 runparams.exportdata->addExternalFile(tex_format, writefile,
433                                                       exportfile);
434
435                 // \include don't want extension and demands that the
436                 // file really have .tex
437                 incfile = changeExtension(incfile, string());
438                 incfile = latex_path(incfile);
439                 os << '\\' << params_.getCmdName() << '{'
440                    << incfile
441                    << '}';
442         }
443
444         return 0;
445 }
446
447
448 int InsetInclude::plaintext(Buffer const & buffer, ostream & os,
449                         OutputParams const &) const
450 {
451         if (isVerbatim(params_))
452                 os << getFileContents(includedFilename(buffer, params_));
453         return 0;
454 }
455
456
457 int InsetInclude::linuxdoc(Buffer const & buffer, ostream & os,
458                            OutputParams const & runparams) const
459 {
460         string incfile(params_.getContents());
461
462         // Do nothing if no file name has been specified
463         if (incfile.empty())
464                 return 0;
465
466         string const included_file = includedFilename(buffer, params_);
467
468         // write it to a file (so far the complete file)
469         string const exportfile = changeExtension(incfile, ".sgml");
470         string writefile = changeExtension(included_file, ".sgml");
471
472         if (loadIfNeeded(buffer, params_)) {
473                 Buffer * tmp = bufferlist.getBuffer(included_file);
474
475                 writefile = makeAbsPath(FileName(writefile).mangledFilename(),
476                                         buffer.getMasterBuffer()->temppath());
477                 if (!runparams.nice)
478                         incfile = writefile;
479
480                 lyxerr[Debug::LATEX] << "incfile:" << incfile << endl;
481                 lyxerr[Debug::LATEX] << "exportfile:" << exportfile << endl;
482                 lyxerr[Debug::LATEX] << "writefile:" << writefile << endl;
483
484                 tmp->makeLinuxDocFile(writefile, runparams, true);
485         }
486
487         if (isVerbatim(params_)) {
488                 os << "<![CDATA["
489                    << getFileContents(included_file)
490                    << "]]>";
491         } else {
492                 runparams.exportdata->addExternalFile("linuxdoc", writefile,
493                                                       exportfile);
494                 os << '&' << include_label << ';';
495         }
496
497         return 0;
498 }
499
500
501 int InsetInclude::docbook(Buffer const & buffer, ostream & os,
502                           OutputParams const & runparams) const
503 {
504         string incfile(params_.getContents());
505
506         // Do nothing if no file name has been specified
507         if (incfile.empty())
508                 return 0;
509
510         string const included_file = includedFilename(buffer, params_);
511
512         // write it to a file (so far the complete file)
513         string const exportfile = changeExtension(incfile, ".sgml");
514         string writefile = changeExtension(included_file, ".sgml");
515
516         if (loadIfNeeded(buffer, params_)) {
517                 Buffer * tmp = bufferlist.getBuffer(included_file);
518
519                 string const mangled = FileName(writefile).mangledFilename();
520                 writefile = makeAbsPath(mangled,
521                                         buffer.getMasterBuffer()->temppath());
522                 if (!runparams.nice)
523                         incfile = mangled;
524
525                 lyxerr[Debug::LATEX] << "incfile:" << incfile << endl;
526                 lyxerr[Debug::LATEX] << "exportfile:" << exportfile << endl;
527                 lyxerr[Debug::LATEX] << "writefile:" << writefile << endl;
528
529                 tmp->makeDocBookFile(writefile, runparams, true);
530         }
531
532         runparams.exportdata->addExternalFile("docbook", writefile,
533                                               exportfile);
534         runparams.exportdata->addExternalFile("docbook-xml", writefile,
535                                               exportfile);
536
537         if (isVerbatim(params_)) {
538                 os << "<inlinegraphic fileref=\""
539                    << '&' << include_label << ';'
540                    << "\" format=\"linespecific\">";
541         } else
542                 os << '&' << include_label << ';';
543
544         return 0;
545 }
546
547
548 void InsetInclude::validate(LaTeXFeatures & features) const
549 {
550         string incfile(params_.getContents());
551         string writefile;
552
553         Buffer const & buffer = features.buffer();
554
555         string const included_file = includedFilename(buffer, params_);
556
557         if (isLyXFilename(included_file))
558                 writefile = changeExtension(included_file, ".sgml");
559         else
560                 writefile = included_file;
561
562         if (!features.runparams().nice && !isVerbatim(params_)) {
563                 incfile = FileName(writefile).mangledFilename();
564                 writefile = makeAbsPath(incfile,
565                                         buffer.getMasterBuffer()->temppath());
566         }
567
568         features.includeFile(include_label, writefile);
569
570         if (isVerbatim(params_))
571                 features.require("verbatim");
572
573         // Here we must do the fun stuff...
574         // Load the file in the include if it needs
575         // to be loaded:
576         if (loadIfNeeded(buffer, params_)) {
577                 // a file got loaded
578                 Buffer * const tmp = bufferlist.getBuffer(included_file);
579                 if (tmp) {
580                         // We must temporarily change features.buffer,
581                         // otherwise it would always be the master buffer,
582                         // and nested includes would not work.
583                         features.setBuffer(*tmp);
584                         tmp->validate(features);
585                         features.setBuffer(buffer);
586                 }
587         }
588 }
589
590
591 void InsetInclude::getLabelList(Buffer const & buffer,
592                                 std::vector<string> & list) const
593 {
594         if (loadIfNeeded(buffer, params_)) {
595                 string const included_file = includedFilename(buffer, params_);
596                 Buffer * tmp = bufferlist.getBuffer(included_file);
597                 tmp->setParentName("");
598                 tmp->getLabelList(list);
599                 tmp->setParentName(parentFilename(buffer));
600         }
601 }
602
603
604 void InsetInclude::fillWithBibKeys(Buffer const & buffer,
605                                    std::vector<std::pair<string,string> > & keys) const
606 {
607         if (loadIfNeeded(buffer, params_)) {
608                 string const included_file = includedFilename(buffer, params_);
609                 Buffer * tmp = bufferlist.getBuffer(included_file);
610                 tmp->setParentName("");
611                 tmp->fillWithBibKeys(keys);
612                 tmp->setParentName(parentFilename(buffer));
613         }
614 }
615
616
617 void InsetInclude::updateBibfilesCache(Buffer const & buffer)
618 {
619         if (loadIfNeeded(buffer, params_)) {
620                 string const included_file = includedFilename(buffer, params_);
621                 Buffer * tmp = bufferlist.getBuffer(included_file);
622                 tmp->setParentName("");
623                 tmp->updateBibfilesCache();
624                 tmp->setParentName(parentFilename(buffer));
625         }
626 }
627
628
629 std::vector<string> const &
630 InsetInclude::getBibfilesCache(Buffer const & buffer) const
631 {
632         if (loadIfNeeded(buffer, params_)) {
633                 string const included_file = includedFilename(buffer, params_);
634                 Buffer * tmp = bufferlist.getBuffer(included_file);
635                 tmp->setParentName("");
636                 std::vector<string> const & cache = tmp->getBibfilesCache();
637                 tmp->setParentName(parentFilename(buffer));
638                 return cache;
639         }
640         static std::vector<string> const empty;
641         return empty;
642 }
643
644
645 void InsetInclude::metrics(MetricsInfo & mi, Dimension & dim) const
646 {
647         BOOST_ASSERT(mi.base.bv && mi.base.bv->buffer());
648
649         bool use_preview = false;
650         if (RenderPreview::status() != LyXRC::PREVIEW_OFF) {
651                 lyx::graphics::PreviewImage const * pimage =
652                         preview_->getPreviewImage(*mi.base.bv->buffer());
653                 use_preview = pimage && pimage->image();
654         }
655
656         if (use_preview) {
657                 preview_->metrics(mi, dim);
658         } else {
659                 if (!set_label_) {
660                         set_label_ = true;
661                         button_.update(getScreenLabel(*mi.base.bv->buffer()),
662                                        true);
663                 }
664                 button_.metrics(mi, dim);
665         }
666
667         Box b(0, dim.wid, -dim.asc, dim.des);
668         button_.setBox(b);
669
670         dim_ = dim;
671 }
672
673
674 void InsetInclude::draw(PainterInfo & pi, int x, int y) const
675 {
676         setPosCache(pi, x, y);
677
678         BOOST_ASSERT(pi.base.bv && pi.base.bv->buffer());
679
680         bool use_preview = false;
681         if (RenderPreview::status() != LyXRC::PREVIEW_OFF) {
682                 lyx::graphics::PreviewImage const * pimage =
683                         preview_->getPreviewImage(*pi.base.bv->buffer());
684                 use_preview = pimage && pimage->image();
685         }
686
687         if (use_preview)
688                 preview_->draw(pi, x, y);
689         else
690                 button_.draw(pi, x, y);
691 }
692
693 bool InsetInclude::display() const
694 {
695         return type(params_) != INPUT;
696 }
697
698
699
700 //
701 // preview stuff
702 //
703
704 void InsetInclude::fileChanged() const
705 {
706         Buffer const * const buffer_ptr = LyX::cref().updateInset(this);
707         if (!buffer_ptr)
708                 return;
709
710         Buffer const & buffer = *buffer_ptr;
711         preview_->removePreview(buffer);
712         add_preview(*preview_.get(), *this, buffer);
713         preview_->startLoading(buffer);
714 }
715
716
717 namespace {
718
719 bool preview_wanted(InsetCommandParams const & params, Buffer const & buffer)
720 {
721         string const included_file = includedFilename(buffer, params);
722
723         return type(params) == INPUT && params.preview() &&
724                 isFileReadable(included_file);
725 }
726
727
728 string const latex_string(InsetInclude const & inset, Buffer const & buffer)
729 {
730         ostringstream os;
731         OutputParams runparams;
732         runparams.flavor = OutputParams::LATEX;
733         inset.latex(buffer, os, runparams);
734
735         return os.str();
736 }
737
738
739 void add_preview(RenderMonitoredPreview & renderer, InsetInclude const & inset,
740                  Buffer const & buffer)
741 {
742         InsetCommandParams const & params = inset.params();
743         if (RenderPreview::status() != LyXRC::PREVIEW_OFF &&
744             preview_wanted(params, buffer)) {
745                 renderer.setAbsFile(includedFilename(buffer, params));
746                 string const snippet = latex_string(inset, buffer);
747                 renderer.addPreview(snippet, buffer);
748         }
749 }
750
751 } // namespace anon
752
753
754 void InsetInclude::addPreview(lyx::graphics::PreviewLoader & ploader) const
755 {
756         Buffer const & buffer = ploader.buffer();
757         if (preview_wanted(params(), buffer)) {
758                 preview_->setAbsFile(includedFilename(buffer, params()));
759                 string const snippet = latex_string(*this, buffer);
760                 preview_->addPreview(snippet, ploader);
761         }
762 }
763
764
765 string const InsetIncludeMailer::name_("include");
766
767 InsetIncludeMailer::InsetIncludeMailer(InsetInclude & inset)
768         : inset_(inset)
769 {}
770
771
772 string const InsetIncludeMailer::inset2string(Buffer const &) const
773 {
774         return params2string(inset_.params());
775 }
776
777
778 void InsetIncludeMailer::string2params(string const & in,
779                                        InsetCommandParams & params)
780 {
781         params = InsetCommandParams();
782         if (in.empty())
783                 return;
784
785         istringstream data(in);
786         LyXLex lex(0,0);
787         lex.setStream(data);
788
789         string name;
790         lex >> name;
791         if (!lex || name != name_)
792                 return print_mailer_error("InsetIncludeMailer", in, 1, name_);
793
794         // This is part of the inset proper that is usually swallowed
795         // by LyXText::readInset
796         string id;
797         lex >> id;
798         if (!lex || id != "Include")
799                 return print_mailer_error("InsetIncludeMailer", in, 2, "Include");
800
801         InsetInclude inset(params);
802         inset.read(lex);
803         params = inset.params();
804 }
805
806
807 string const
808 InsetIncludeMailer::params2string(InsetCommandParams const & params)
809 {
810         InsetInclude inset(params);
811         ostringstream data;
812         data << name_ << ' ';
813         inset.write(data);
814         data << "\\end_inset\n";
815         return data.str();
816 }