]> git.lyx.org Git - lyx.git/blob - src/insets/insetexternal.C
setFont rework + some code simplification
[lyx.git] / src / insets / insetexternal.C
1 /**
2  * \file insetexternal.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Asger Alstrup Nielsen
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "insetexternal.h"
14 #include "insets/ExternalSupport.h"
15 #include "insets/ExternalTemplate.h"
16 #include "insets/render_button.h"
17 #include "insets/render_graphic.h"
18 #include "insets/render_preview.h"
19
20 #include "buffer.h"
21 #include "BufferView.h"
22 #include "debug.h"
23 #include "dispatchresult.h"
24 #include "funcrequest.h"
25 #include "gettext.h"
26 #include "LaTeXFeatures.h"
27 #include "lyx_main.h"
28 #include "lyxlex.h"
29 #include "lyxrc.h"
30 #include "metricsinfo.h"
31 #include "outputparams.h"
32
33 #include "frontends/lyx_gui.h"
34 #include "frontends/LyXView.h"
35
36 #include "graphics/PreviewLoader.h"
37
38 #include "support/FileInfo.h"
39 #include "support/filetools.h"
40 #include "support/lstrings.h"
41 #include "support/lyxlib.h"
42 #include "support/tostr.h"
43 #include "support/translator.h"
44
45 #include <boost/bind.hpp>
46
47 #include "support/std_sstream.h"
48
49 namespace support = lyx::support;
50 namespace external = lyx::external;
51 namespace graphics = lyx::graphics;
52
53 using std::endl;
54 using std::string;
55 using std::auto_ptr;
56 using std::istringstream;
57 using std::ostream;
58 using std::ostringstream;
59 using std::vector;
60
61
62 namespace {
63
64 external::DisplayType const defaultDisplayType = external::NoDisplay;
65
66 unsigned int defaultLyxScale = 100;
67
68 } // namespace anon
69
70
71 namespace lyx {
72 namespace external {
73
74 TempName::TempName()
75 {
76         tempname_ = support::tempName(string(), "lyxext");
77         support::unlink(tempname_);
78         // must have an extension for the converter code to work correctly.
79         tempname_ += ".tmp";
80 }
81
82
83 TempName::TempName(TempName const &)
84 {
85         tempname_ = TempName()();
86 }
87
88
89 TempName::~TempName()
90 {
91         support::unlink(tempname_);
92 }
93
94
95 TempName &
96 TempName::operator=(TempName const & other)
97 {
98         if (this != &other)
99                 tempname_ = TempName()();
100         return *this;
101 }
102
103
104 namespace {
105
106 /// The translator between the Display enum and corresponding lyx string.
107 Translator<DisplayType, string> const initTranslator()
108 {
109         Translator<DisplayType, string> translator(DefaultDisplay, "default");
110
111         // Fill the display translator
112         translator.addPair(MonochromeDisplay, "monochrome");
113         translator.addPair(GrayscaleDisplay, "grayscale");
114         translator.addPair(ColorDisplay, "color");
115         translator.addPair(PreviewDisplay, "preview");
116         translator.addPair(NoDisplay, "none");
117
118         return translator;
119 }
120
121 } // namespace anon
122
123
124 Translator<DisplayType, string> const & displayTranslator()
125 {
126         static Translator<DisplayType, string> const translator =
127                 initTranslator();
128         return translator;
129 }
130
131 } // namespace external
132 } // namespace lyx
133
134
135 InsetExternalParams::InsetExternalParams()
136         : display(defaultDisplayType),
137           lyxscale(defaultLyxScale)
138 {}
139
140
141 namespace {
142
143 template <typename T>
144 void clearIfNotFound(T & data, external::TransformID value,
145                      vector<external::TransformID> const & ids)
146 {
147         typedef vector<external::TransformID>::const_iterator
148                 const_iterator;
149
150         const_iterator it  = ids.begin();
151         const_iterator end = ids.end();
152         it = std::find(it, end, value);
153         if (it == end)
154                 data = T();
155 }
156
157 } // namespace anon
158
159
160 void InsetExternalParams::settemplate(string const & name)
161 {
162         templatename_ = name;
163
164         external::TemplateManager const & etm =
165                 external::TemplateManager::get();
166         external::Template const * const et = etm.getTemplateByName(name);
167         if (!et)
168                 // Be safe. Don't lose data.
169                 return;
170
171         // Ascertain which transforms the template supports.
172         // Empty all those that it doesn't.
173         vector<external::TransformID> const & ids = et->transformIds;
174         clearIfNotFound(clipdata,     external::Clip,   ids);
175         clearIfNotFound(extradata,    external::Extra,  ids);
176         clearIfNotFound(resizedata,   external::Resize, ids);
177         clearIfNotFound(rotationdata, external::Rotate, ids);
178 }
179
180
181 void InsetExternalParams::write(Buffer const & buffer, ostream & os) const
182 {
183         os << "External\n"
184            << "\ttemplate " << templatename() << '\n';
185
186         if (!filename.empty())
187                 os << "\tfilename "
188                    << filename.outputFilename(buffer.filePath())
189                    << '\n';
190
191         if (display != defaultDisplayType)
192                 os << "\tdisplay "
193                    << external::displayTranslator().find(display)
194                    << '\n';
195
196         if (lyxscale != defaultLyxScale)
197                 os << "\tlyxscale " << tostr(lyxscale) << '\n';
198
199         if (!clipdata.bbox.empty())
200                 os << "\tboundingBox " << clipdata.bbox << '\n';
201         if (clipdata.clip)
202                 os << "\tclip\n";
203
204         external::ExtraData::const_iterator it  = extradata.begin();
205         external::ExtraData::const_iterator end = extradata.end();
206         for (; it != end; ++it) {
207                 if (!it->second.empty())
208                         os << "\textra " << it->first << " \""
209                            << it->second << "\"\n";
210         }
211
212         if (!rotationdata.no_rotation()) {
213                 os << "\trotateAngle " << rotationdata.angle() << '\n';
214                 if (rotationdata.origin() != external::RotationData::DEFAULT)
215                         os << "\trotateOrigin "
216                            << rotationdata.originString() << '\n';
217         }
218
219         if (!resizedata.no_resize()) {
220                 using support::float_equal;
221
222                 if (!float_equal(resizedata.scale, 0.0, 0.05)) {
223                         if (!float_equal(resizedata.scale, 100.0, 0.05))
224                                 os << "\tscale "
225                                    << resizedata.scale << '\n';
226                 } else {
227                         if (!resizedata.width.zero())
228                                 os << "\twidth "
229                                    << resizedata.width.asString() << '\n';
230                         if (!resizedata.height.zero())
231                                 os << "\theight "
232                                    << resizedata.height.asString() << '\n';
233                 }
234                 if (resizedata.keepAspectRatio)
235                         os << "\tkeepAspectRatio\n";
236         }
237 }
238
239
240 bool InsetExternalParams::read(Buffer const & buffer, LyXLex & lex)
241 {
242         enum ExternalTags {
243                 EX_TEMPLATE = 1,
244                 EX_FILENAME,
245                 EX_DISPLAY,
246                 EX_LYXSCALE,
247                 EX_BOUNDINGBOX,
248                 EX_CLIP,
249                 EX_EXTRA,
250                 EX_HEIGHT,
251                 EX_KEEPASPECTRATIO,
252                 EX_ROTATEANGLE,
253                 EX_ROTATEORIGIN,
254                 EX_SCALE,
255                 EX_WIDTH,
256                 EX_END
257         };
258
259         keyword_item external_tags[] = {
260                 { "\\end_inset",     EX_END },
261                 { "boundingBox",     EX_BOUNDINGBOX },
262                 { "clip",            EX_CLIP },
263                 { "display",         EX_DISPLAY},
264                 { "extra",           EX_EXTRA },
265                 { "filename",        EX_FILENAME},
266                 { "height",          EX_HEIGHT },
267                 { "keepAspectRatio", EX_KEEPASPECTRATIO },
268                 { "lyxscale",        EX_LYXSCALE},
269                 { "rotateAngle",     EX_ROTATEANGLE },
270                 { "rotateOrigin",    EX_ROTATEORIGIN },
271                 { "scale",           EX_SCALE },
272                 { "template",        EX_TEMPLATE },
273                 { "width",           EX_WIDTH }
274         };
275
276         pushpophelper pph(lex, external_tags, EX_END);
277
278         bool found_end  = false;
279         bool read_error = false;
280
281         while (lex.isOK()) {
282                 switch (lex.lex()) {
283                 case EX_TEMPLATE:
284                         lex.next();
285                         templatename_ = lex.getString();
286                         break;
287
288                 case EX_FILENAME: {
289                         lex.next();
290                         string const name = lex.getString();
291                         filename.set(name, buffer.filePath());
292                         break;
293                 }
294
295                 case EX_DISPLAY: {
296                         lex.next();
297                         string const name = lex.getString();
298                         display = external::displayTranslator().find(name);
299                         break;
300                 }
301
302                 case EX_LYXSCALE:
303                         lex.next();
304                         lyxscale = lex.getInteger();
305                         break;
306
307                 case EX_BOUNDINGBOX:
308                         lex.next();
309                         clipdata.bbox.xl = lex.getInteger();
310                         lex.next();
311                         clipdata.bbox.yb = lex.getInteger();
312                         lex.next();
313                         clipdata.bbox.xr = lex.getInteger();
314                         lex.next();
315                         clipdata.bbox.yt = lex.getInteger();
316                         break;
317
318                 case EX_CLIP:
319                         clipdata.clip = true;
320                         break;
321
322                 case EX_EXTRA: {
323                         lex.next();
324                         string const name = lex.getString();
325                         lex.next();
326                         extradata.set(name, lex.getString());
327                         break;
328                 }
329
330                 case EX_HEIGHT:
331                         lex.next();
332                         resizedata.height = LyXLength(lex.getString());
333                         break;
334
335                 case EX_KEEPASPECTRATIO:
336                         resizedata.keepAspectRatio = true;
337                         break;
338
339                 case EX_ROTATEANGLE:
340                         lex.next();
341                         rotationdata.angle(lex.getFloat());
342                         break;
343
344                 case EX_ROTATEORIGIN:
345                         lex.next();
346                         rotationdata.origin(lex.getString());
347                         break;
348
349                 case EX_SCALE:
350                         lex.next();
351                         resizedata.scale = lex.getFloat();
352                         break;
353
354                 case EX_WIDTH:
355                         lex.next();
356                         resizedata.width = LyXLength(lex.getString());
357                         break;
358
359                 case EX_END:
360                         found_end = true;
361                         break;
362
363                 default:
364                         lex.printError("ExternalInset::read: "
365                                        "Wrong tag: $$Token");
366                         read_error = true;
367                         break;
368                 }
369
370                 if (found_end || read_error)
371                         break;
372         }
373
374         if (!found_end)
375                 lex.printError("ExternalInset::read: Missing \\end_inset.");
376
377         // This is a trick to make sure that the data are self-consistent.
378         settemplate(templatename_);
379
380         if (lyxerr.debugging(Debug::EXTERNAL)) {
381                 lyxerr  << "InsetExternalParams::read:\n";
382                 write(buffer, lyxerr);
383         }
384
385         return !read_error;
386 }
387
388
389 InsetExternal::InsetExternal()
390         : renderer_(new RenderButton)
391 {}
392
393
394 InsetExternal::InsetExternal(InsetExternal const & other)
395         : InsetOld(other),
396           boost::signals::trackable(),
397           params_(other.params_),
398           renderer_(other.renderer_->clone())
399 {
400         if (renderer_->asMonitoredPreview() != 0) {
401                 RenderMonitoredPreview * const ptr = renderer_->asMonitoredPreview();
402                 ptr->connect(boost::bind(&InsetExternal::statusChanged, this));
403                 ptr->fileChanged(boost::bind(&InsetExternal::fileChanged, this));
404
405         } else if (renderer_->asGraphic() != 0 ) {
406                 RenderGraphic * const ptr = renderer_->asGraphic();
407                 ptr->connect(boost::bind(&InsetExternal::statusChanged, this));
408         }
409 }
410
411
412 auto_ptr<InsetBase> InsetExternal::clone() const
413 {
414         return auto_ptr<InsetBase>(new InsetExternal(*this));
415 }
416
417
418 InsetExternal::~InsetExternal()
419 {
420         InsetExternalMailer(*this).hideDialog();
421 }
422
423
424 void InsetExternal::statusChanged() const
425 {
426         LyX::cref().updateInset(this);
427 }
428
429
430 DispatchResult
431 InsetExternal::priv_dispatch(FuncRequest const & cmd, idx_type &, pos_type &)
432 {
433         switch (cmd.action) {
434
435         case LFUN_EXTERNAL_EDIT: {
436                 BOOST_ASSERT(cmd.view());
437
438                 Buffer const & buffer = *cmd.view()->buffer();
439                 InsetExternalParams p;
440                 InsetExternalMailer::string2params(cmd.argument, buffer, p);
441                 external::editExternal(p, buffer);
442                 return DispatchResult(true);
443         }
444
445         case LFUN_INSET_MODIFY: {
446                 BOOST_ASSERT(cmd.view());
447
448                 Buffer const & buffer = *cmd.view()->buffer();
449                 InsetExternalParams p;
450                 InsetExternalMailer::string2params(cmd.argument, buffer, p);
451                 setParams(p, buffer);
452                 cmd.view()->update();
453                 return DispatchResult(true, true);
454         }
455
456         case LFUN_INSET_DIALOG_UPDATE:
457                 InsetExternalMailer(*this).updateDialog(cmd.view());
458                 return DispatchResult(true, true);
459
460         case LFUN_MOUSE_RELEASE:
461                 InsetExternalMailer(*this).showDialog(cmd.view());
462                 return DispatchResult(true, true);
463
464         default:
465                 return DispatchResult(false);
466         }
467 }
468
469
470 void InsetExternal::edit(BufferView * bv, bool)
471 {
472         InsetExternalMailer(*this).showDialog(bv);
473 }
474
475
476 void InsetExternal::metrics(MetricsInfo & mi, Dimension & dim) const
477 {
478         renderer_->metrics(mi, dim);
479         dim_ = dim;
480 }
481
482
483 void InsetExternal::draw(PainterInfo & pi, int x, int y) const
484 {
485         renderer_->draw(pi, x, y);
486 }
487
488
489 namespace {
490
491 enum RenderType {
492         RENDERBUTTON,
493         RENDERGRAPHIC,
494         RENDERPREVIEW
495 };
496
497
498 RenderType getRenderType(InsetExternalParams const & p)
499 {
500         if (!external::getTemplatePtr(p) ||
501             p.filename.empty() ||
502             p.display == external::NoDisplay)
503                 return RENDERBUTTON;
504
505         if (p.display == external::PreviewDisplay) {
506                 if (RenderPreview::activated())
507                         return RENDERPREVIEW;
508                 return RENDERBUTTON;
509         }
510
511         if (p.display == external::DefaultDisplay &&
512             lyxrc.display_graphics == graphics::NoDisplay)
513                 return RENDERBUTTON;
514         return RENDERGRAPHIC;
515 }
516
517
518 graphics::Params get_grfx_params(InsetExternalParams const & eparams)
519 {
520         graphics::Params gparams;
521
522         gparams.filename = eparams.filename.absFilename();
523         gparams.scale = eparams.lyxscale;
524         if (eparams.clipdata.clip)
525                 gparams.bb = eparams.clipdata.bbox;
526         gparams.angle = eparams.rotationdata.angle();
527
528         switch (eparams.display) {
529         case external::DefaultDisplay:
530                 gparams.display = graphics::DefaultDisplay;
531                 break;
532         case external::MonochromeDisplay:
533                 gparams.display = graphics::MonochromeDisplay;
534                 break;
535         case external::GrayscaleDisplay:
536                 gparams.display = graphics::GrayscaleDisplay;
537                 break;
538         case external::ColorDisplay:
539                 gparams.display = graphics::ColorDisplay;
540                 break;
541         case external::NoDisplay:
542                 gparams.display = graphics::NoDisplay;
543                 break;
544         default:
545                 BOOST_ASSERT(false);
546         }
547         if (gparams.display == graphics::DefaultDisplay)
548                 gparams.display = lyxrc.display_graphics;
549         // Override the above if we're not using a gui
550         if (!lyx_gui::use_gui)
551                 gparams.display = graphics::NoDisplay;
552
553         return gparams;
554 }
555
556
557 string const getScreenLabel(InsetExternalParams const & params,
558                             Buffer const & buffer)
559 {
560         external::Template const * const ptr =
561                 external::getTemplatePtr(params);
562         if (!ptr)
563                 return support::bformat(_("External template %1$s is not installed"),
564                                         params.templatename());
565         return external::doSubstitution(params, buffer, ptr->guiName);
566 }
567
568 void add_preview(RenderMonitoredPreview &, InsetExternal const &, Buffer const &);
569
570 } // namespace anon
571
572
573 InsetExternalParams const & InsetExternal::params() const
574 {
575         return params_;
576 }
577
578
579 void InsetExternal::setParams(InsetExternalParams const & p,
580                               Buffer const & buffer)
581 {
582         params_ = p;
583
584         switch (getRenderType(params_)) {
585         case RENDERBUTTON: {
586                 RenderButton * button_ptr = renderer_->asButton();
587                 if (!button_ptr) {
588                         renderer_.reset(new RenderButton);
589                         button_ptr = renderer_->asButton();
590                 }
591
592                 button_ptr->update(getScreenLabel(params_, buffer), true);
593                 break;
594
595         } case RENDERGRAPHIC: {
596                 RenderGraphic * graphic_ptr = renderer_->asGraphic();
597                 if (!graphic_ptr) {
598                         renderer_.reset(new RenderGraphic);
599                         graphic_ptr = renderer_->asGraphic();
600                         graphic_ptr->connect(
601                                 boost::bind(&InsetExternal::statusChanged, this));
602                 }
603
604                 graphic_ptr->update(get_grfx_params(params_));
605
606                 break;
607
608         } case RENDERPREVIEW: {
609                 RenderMonitoredPreview * preview_ptr =
610                         renderer_->asMonitoredPreview();
611                 if (!preview_ptr) {
612                         renderer_.reset(new RenderMonitoredPreview);
613                         preview_ptr = renderer_->asMonitoredPreview();
614                         preview_ptr->connect(
615                                 boost::bind(&InsetExternal::statusChanged, this));
616                         preview_ptr->fileChanged(
617                                 boost::bind(&InsetExternal::fileChanged, this));
618                 }
619
620                 if (preview_ptr->monitoring())
621                         preview_ptr->stopMonitoring();
622                 add_preview(*preview_ptr, *this, buffer);
623
624                 break;
625         }
626         }
627 }
628
629
630 void InsetExternal::fileChanged() const
631 {
632         Buffer const * const buffer_ptr = LyX::cref().updateInset(this);
633         if (!buffer_ptr)
634                 return;
635
636         RenderMonitoredPreview * const ptr = renderer_->asMonitoredPreview();
637         BOOST_ASSERT(ptr);
638
639         Buffer const & buffer = *buffer_ptr;
640         ptr->removePreview(buffer);
641         add_preview(*ptr, *this, buffer);
642         ptr->startLoading(buffer);
643 }
644
645
646 void InsetExternal::write(Buffer const & buffer, ostream & os) const
647 {
648         params_.write(buffer, os);
649 }
650
651
652 void InsetExternal::read(Buffer const & buffer, LyXLex & lex)
653 {
654         InsetExternalParams params;
655         if (params.read(buffer, lex))
656                 setParams(params, buffer);
657 }
658
659
660 int InsetExternal::latex(Buffer const & buf, ostream & os,
661                          OutputParams const & runparams) const
662 {
663         // "nice" means that the buffer is exported to LaTeX format but not
664         // run through the LaTeX compiler.
665         // If we're running through the LaTeX compiler, we should write the
666         // generated files in the bufer's temporary directory.
667         bool const external_in_tmpdir =
668                 lyxrc.use_tempdir && !buf.temppath().empty() && !runparams.nice;
669
670         // If the template has specified a PDFLaTeX output, then we try and
671         // use that.
672         if (runparams.flavor == OutputParams::PDFLATEX) {
673                 external::Template const * const et_ptr =
674                         external::getTemplatePtr(params_);
675                 if (!et_ptr)
676                         return 0;
677                 external::Template const & et = *et_ptr;
678
679                 external::Template::Formats::const_iterator cit =
680                         et.formats.find("PDFLaTeX");
681                 if (cit != et.formats.end())
682                         return external::writeExternal(params_, "PDFLaTeX",
683                                              buf, os, external_in_tmpdir);
684         }
685
686         return external::writeExternal(params_, "LaTeX",
687                                        buf, os, external_in_tmpdir);
688 }
689
690
691 int InsetExternal::plaintext(Buffer const & buf, ostream & os,
692                          OutputParams const &) const
693 {
694         return external::writeExternal(params_, "Ascii", buf, os);
695 }
696
697
698 int InsetExternal::linuxdoc(Buffer const & buf, ostream & os,
699                             OutputParams const &) const
700 {
701         return external::writeExternal(params_, "LinuxDoc", buf, os);
702 }
703
704
705 int InsetExternal::docbook(Buffer const & buf, ostream & os,
706                            OutputParams const &) const
707 {
708         return external::writeExternal(params_, "DocBook", buf, os);
709 }
710
711
712 void InsetExternal::validate(LaTeXFeatures & features) const
713 {
714         external::Template const * const et_ptr =
715                 external::getTemplatePtr(params_);
716         if (!et_ptr)
717                 return;
718         external::Template const & et = *et_ptr;
719
720         external::Template::Formats::const_iterator cit =
721                 et.formats.find("LaTeX");
722         if (cit == et.formats.end())
723                 return;
724
725         if (!cit->second.requirement.empty())
726                 features.require(cit->second.requirement);
727
728         external::TemplateManager & etm = external::TemplateManager::get();
729
730         vector<string>::const_iterator it  = cit->second.preambleNames.begin();
731         vector<string>::const_iterator end = cit->second.preambleNames.end();
732         for (; it != end; ++it) {
733                 string const preamble = etm.getPreambleDefByName(*it);
734                 if (!preamble.empty())
735                         features.addExternalPreamble(preamble);
736         }
737 }
738
739
740 //
741 // preview stuff
742 //
743
744 namespace {
745
746 bool preview_wanted(InsetExternalParams const & params)
747 {
748         string const included_file = params.filename.absFilename();
749
750         return params.display == external::PreviewDisplay &&
751                 support::IsFileReadable(included_file);
752 }
753
754
755 string const latex_string(InsetExternal const & inset, Buffer const & buffer)
756 {
757         ostringstream os;
758         OutputParams runparams;
759         runparams.flavor = OutputParams::LATEX;
760         inset.latex(buffer, os, runparams);
761
762         return os.str();
763 }
764
765
766 void add_preview(RenderMonitoredPreview & renderer, InsetExternal const & inset,
767                  Buffer const & buffer)
768 {
769         InsetExternalParams const & params = inset.params();
770         if (RenderPreview::activated() && preview_wanted(params)) {
771                 renderer.setAbsFile(params.filename.absFilename());
772                 string const snippet = latex_string(inset, buffer);
773                 renderer.addPreview(snippet, buffer);
774         }
775 }
776
777 } // namespace anon
778
779
780 void InsetExternal::addPreview(graphics::PreviewLoader & ploader) const
781 {
782         RenderMonitoredPreview * const ptr = renderer_->asMonitoredPreview();
783         if (!ptr)
784                 return;
785
786         if (preview_wanted(params())) {
787                 ptr->setAbsFile(params_.filename.absFilename());
788                 string const snippet = latex_string(*this, ploader.buffer());
789                 ptr->addPreview(snippet, ploader);
790         }
791 }
792
793
794 /// Mailer stuff
795
796 string const InsetExternalMailer::name_("external");
797
798 InsetExternalMailer::InsetExternalMailer(InsetExternal & inset)
799         : inset_(inset)
800 {}
801
802
803 string const InsetExternalMailer::inset2string(Buffer const & buffer) const
804 {
805         return params2string(inset_.params(), buffer);
806 }
807
808
809 void InsetExternalMailer::string2params(string const & in,
810                                         Buffer const & buffer,
811                                         InsetExternalParams & params)
812 {
813         params = InsetExternalParams();
814
815         if (in.empty())
816                 return;
817
818         istringstream data(in);
819         LyXLex lex(0,0);
820         lex.setStream(data);
821
822         if (lex.isOK()) {
823                 lex.next();
824                 string const token = lex.getString();
825                 if (token != name_)
826                         return;
827         }
828
829         // This is part of the inset proper that is usually swallowed
830         // by Buffer::readInset
831         if (lex.isOK()) {
832                 lex.next();
833                 string const token = lex.getString();
834                 if (token != "External")
835                         return;
836         }
837
838         if (lex.isOK()) {
839                 params.read(buffer, lex);
840         }
841 }
842
843
844 string const
845 InsetExternalMailer::params2string(InsetExternalParams const & params,
846                                    Buffer const & buffer)
847 {
848         ostringstream data;
849         data << name_ << ' ';
850         params.write(buffer, data);
851         data << "\\end_inset\n";
852         return data.str();
853 }