]> git.lyx.org Git - lyx.git/blob - src/insets/insetgraphics.C
bdb569b48241957a6115fb3e1b360eb19a1b3272
[lyx.git] / src / insets / insetgraphics.C
1 /**
2  * \file insetgraphics.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Baruch Even
7  * \author Herbert Voß
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 /*
13 TODO
14
15     * What advanced features the users want to do?
16       Implement them in a non latex dependent way, but a logical way.
17       LyX should translate it to latex or any other fitting format.
18     * Add a way to roll the image file into the file format.
19     * When loading, if the image is not found in the expected place, try
20       to find it in the clipart, or in the same directory with the image.
21     * The image choosing dialog could show thumbnails of the image formats
22       it knows of, thus selection based on the image instead of based on
23       filename.
24     * Add support for the 'picins' package.
25     * Add support for the 'picinpar' package.
26     * Improve support for 'subfigure' - Allow to set the various options
27       that are possible.
28 */
29
30 /* NOTES:
31  * Fileformat:
32  * The filename is kept in  the lyx file in a relative way, so as to allow
33  * moving the document file and its images with no problem.
34  *
35  *
36  * Conversions:
37  *   Postscript output means EPS figures.
38  *
39  *   PDF output is best done with PDF figures if it's a direct conversion
40  *   or PNG figures otherwise.
41  *      Image format
42  *      from        to
43  *      EPS         epstopdf
44  *      PS          ps2pdf
45  *      JPG/PNG     direct
46  *      PDF         direct
47  *      others      PNG
48  */
49
50 #include <config.h>
51
52 #include "insets/insetgraphics.h"
53 #include "insets/render_graphic.h"
54
55 #include "buffer.h"
56 #include "BufferView.h"
57 #include "converter.h"
58 #include "cursor.h"
59 #include "debug.h"
60 #include "dispatchresult.h"
61 #include "format.h"
62 #include "funcrequest.h"
63 #include "gettext.h"
64 #include "LaTeXFeatures.h"
65 #include "lyx_main.h"
66 #include "lyxlex.h"
67 #include "metricsinfo.h"
68 #include "outputparams.h"
69
70 #include "frontends/Alert.h"
71 #include "frontends/LyXView.h"
72
73 #include "support/filetools.h"
74 #include "support/lyxalgo.h" // lyx::count
75 #include "support/lyxlib.h" // float_equal
76 #include "support/os.h"
77 #include "support/systemcall.h"
78 #include "support/tostr.h"
79 #include "support/std_sstream.h"
80
81 #include <boost/bind.hpp>
82 #include <boost/tuple/tuple.hpp>
83
84 namespace support = lyx::support;
85 using lyx::support::AbsolutePath;
86 using lyx::support::bformat;
87 using lyx::support::ChangeExtension;
88 using lyx::support::contains;
89 using lyx::support::FileName;
90 using lyx::support::float_equal;
91 using lyx::support::GetExtension;
92 using lyx::support::getExtFromContents;
93 using lyx::support::IsFileReadable;
94 using lyx::support::LibFileSearch;
95 using lyx::support::rtrim;
96 using lyx::support::Systemcall;
97 using lyx::support::unzipFile;
98 using lyx::support::unzippedFileName;
99
100 namespace os = lyx::support::os;
101
102 using std::endl;
103 using std::string;
104 using std::auto_ptr;
105 using std::istringstream;
106 using std::ostream;
107 using std::ostringstream;
108
109
110 namespace {
111
112 ///////////////////////////////////////////////////////////////////////////
113 int const VersionNumber = 1;
114 ///////////////////////////////////////////////////////////////////////////
115
116 // This function is a utility function
117 // ... that should be with ChangeExtension ...
118 inline
119 string const RemoveExtension(string const & filename)
120 {
121         return ChangeExtension(filename, string());
122 }
123
124
125 string const uniqueID()
126 {
127         static unsigned int seed = 1000;
128         return "graph" + tostr(++seed);
129 }
130
131
132 string findTargetFormat(string const & suffix, OutputParams const & runparams)
133 {
134         // Are we using latex or pdflatex).
135         if (runparams.flavor == OutputParams::PDFLATEX) {
136                 lyxerr[Debug::GRAPHICS] << "findTargetFormat: PDF mode" << endl;
137                 if (contains(suffix, "ps") || suffix == "pdf")
138                         return "pdf";
139                 if (suffix == "jpg")    // pdflatex can use jpeg
140                         return suffix;
141                 return "png";         // and also png
142         }
143         // If it's postscript, we always do eps.
144         lyxerr[Debug::GRAPHICS] << "findTargetFormat: PostScript mode" << endl;
145         if (suffix != "ps")     // any other than ps
146                 return "eps";         // is changed to eps
147         return suffix;          // let ps untouched
148 }
149
150 } // namespace anon
151
152
153 InsetGraphics::InsetGraphics()
154         : graphic_label(uniqueID()),
155           graphic_(new RenderGraphic)
156 {
157         graphic_->connect(boost::bind(&InsetGraphics::statusChanged, this));
158 }
159
160
161 InsetGraphics::InsetGraphics(InsetGraphics const & ig)
162         : InsetOld(ig),
163           boost::signals::trackable(),
164           graphic_label(uniqueID()),
165           graphic_(new RenderGraphic(*ig.graphic_))
166 {
167         graphic_->connect(boost::bind(&InsetGraphics::statusChanged, this));
168         setParams(ig.params());
169 }
170
171
172 auto_ptr<InsetBase> InsetGraphics::clone() const
173 {
174         return auto_ptr<InsetBase>(new InsetGraphics(*this));
175 }
176
177
178 InsetGraphics::~InsetGraphics()
179 {
180         InsetGraphicsMailer(*this).hideDialog();
181 }
182
183
184 void InsetGraphics::statusChanged() const
185 {
186         LyX::cref().updateInset(this);
187 }
188
189
190 void InsetGraphics::priv_dispatch(LCursor & cur, FuncRequest & cmd)
191 {
192         switch (cmd.action) {
193         case LFUN_GRAPHICS_EDIT: {
194                 Buffer const & buffer = *cur.bv().buffer();
195                 InsetGraphicsParams p;
196                 InsetGraphicsMailer::string2params(cmd.argument, buffer, p);
197                 editGraphics(p, buffer);
198                 break;
199         }
200
201         case LFUN_INSET_MODIFY: {
202                 Buffer const & buffer = cur.buffer();
203                 InsetGraphicsParams p;
204                 InsetGraphicsMailer::string2params(cmd.argument, buffer, p);
205                 if (!p.filename.empty()) {
206                         setParams(p);
207                         cur.bv().update();
208                 }
209                 break;
210         }
211
212         case LFUN_INSET_DIALOG_UPDATE:
213                 InsetGraphicsMailer(*this).updateDialog(&cur.bv());
214                 break;
215
216         case LFUN_MOUSE_RELEASE:
217                 InsetGraphicsMailer(*this).showDialog(&cur.bv());
218                 break;
219
220         default:
221                 InsetOld::priv_dispatch(cur, cmd);
222                 break;
223         }
224 }
225
226
227 void InsetGraphics::edit(LCursor & cur, bool)
228 {
229         InsetGraphicsMailer(*this).showDialog(&cur.bv());
230 }
231
232
233 void InsetGraphics::metrics(MetricsInfo & mi, Dimension & dim) const
234 {
235         graphic_->metrics(mi, dim);
236         dim_ = dim;
237 }
238
239
240 void InsetGraphics::draw(PainterInfo & pi, int x, int y) const
241 {
242         setPosCache(pi, x, y);
243         graphic_->draw(pi, x, y);
244 }
245
246
247 InsetOld::EDITABLE InsetGraphics::editable() const
248 {
249         return IS_EDITABLE;
250 }
251
252
253 void InsetGraphics::write(Buffer const & buf, ostream & os) const
254 {
255         os << "Graphics\n";
256         params().Write(os, buf.filePath());
257 }
258
259
260 void InsetGraphics::read(Buffer const & buf, LyXLex & lex)
261 {
262         string const token = lex.getString();
263
264         if (token == "Graphics")
265                 readInsetGraphics(lex, buf.filePath());
266         else
267                 lyxerr[Debug::GRAPHICS] << "Not a Graphics inset!" << endl;
268
269         graphic_->update(params().as_grfxParams());
270 }
271
272
273 void InsetGraphics::readInsetGraphics(LyXLex & lex, string const & bufpath)
274 {
275         bool finished = false;
276
277         while (lex.isOK() && !finished) {
278                 lex.next();
279
280                 string const token = lex.getString();
281                 lyxerr[Debug::GRAPHICS] << "Token: '" << token << '\''
282                                     << endl;
283
284                 if (token.empty()) {
285                         continue;
286                 } else if (token == "\\end_inset") {
287                         finished = true;
288                 } else {
289                         if (!params_.Read(lex, token, bufpath))
290                                 lyxerr << "Unknown token, " << token << ", skipping."
291                                         << std::endl;
292                 }
293         }
294 }
295
296
297 string const InsetGraphics::createLatexOptions() const
298 {
299         // Calculate the options part of the command, we must do it to a string
300         // stream since we might have a trailing comma that we would like to remove
301         // before writing it to the output stream.
302         ostringstream options;
303         if (!params().bb.empty())
304             options << "  bb=" << rtrim(params().bb) << ",\n";
305         if (params().draft)
306             options << "  draft,\n";
307         if (params().clip)
308             options << "  clip,\n";
309         if (!float_equal(params().scale, 0.0, 0.05)) {
310                 if (!float_equal(params().scale, 100.0, 0.05))
311                         options << "  scale=" << params().scale / 100.0
312                                 << ",\n";
313         } else {
314                 if (!params().width.zero())
315                         options << "  width=" << params().width.asLatexString() << ",\n";
316                 if (!params().height.zero())
317                         options << "  height=" << params().height.asLatexString() << ",\n";
318                 if (params().keepAspectRatio)
319                         options << "  keepaspectratio,\n";
320         }
321
322         // Make sure rotation angle is not very close to zero;
323         // a float can be effectively zero but not exactly zero.
324         if (!float_equal(params().rotateAngle, 0, 0.001)) {
325             options << "  angle=" << params().rotateAngle << ",\n";
326             if (!params().rotateOrigin.empty()) {
327                 options << "  origin=" << params().rotateOrigin[0];
328                 if (contains(params().rotateOrigin,"Top"))
329                     options << 't';
330                 else if (contains(params().rotateOrigin,"Bottom"))
331                     options << 'b';
332                 else if (contains(params().rotateOrigin,"Baseline"))
333                     options << 'B';
334                 options << ",\n";
335             }
336         }
337
338         if (!params().special.empty())
339             options << params().special << ",\n";
340
341         string opts = options.str();
342         // delete last ",\n"
343         return opts.substr(0, opts.size() - 2);
344 }
345
346
347 namespace {
348
349 enum CopyStatus {
350         SUCCESS,
351         FAILURE,
352         IDENTICAL_PATHS,
353         IDENTICAL_CONTENTS
354 };
355
356
357 std::pair<CopyStatus, string> const
358 copyToDirIfNeeded(string const & file_in, string const & dir)
359 {
360         using support::rtrim;
361
362         BOOST_ASSERT(AbsolutePath(file_in));
363
364         string const only_path = support::OnlyPath(file_in);
365         if (rtrim(support::OnlyPath(file_in) , "/") == rtrim(dir, "/"))
366                 return std::make_pair(IDENTICAL_PATHS, file_in);
367
368         string mangled;
369         if (support::zippedFile(file_in)) {
370                 string const ext = GetExtension(file_in);
371                 string const unzipped = support::unzippedFileName(file_in);
372                 mangled = FileName(unzipped).mangledFilename();
373                 mangled += "." + ext;
374         } else
375                 mangled = FileName(file_in).mangledFilename();
376
377         string const file_out = support::MakeAbsPath(mangled, dir);
378
379         unsigned long const checksum_in  = support::sum(file_in);
380         unsigned long const checksum_out = support::sum(file_out);
381
382         if (checksum_in == checksum_out)
383                 // Nothing to do...
384                 return std::make_pair(IDENTICAL_CONTENTS, file_out);
385
386         bool const success = support::copy(file_in, file_out);
387         if (!success) {
388                 lyxerr[Debug::GRAPHICS]
389                         << support::bformat(_("Could not copy the file\n%1$s\n"
390                                               "into the temporary directory."),
391                                             file_in)
392                         << std::endl;
393         }
394
395         CopyStatus status = success ? SUCCESS : FAILURE;
396         return std::make_pair(status, file_out);
397 }
398
399
400 string const stripExtensionIfPossible(string const & file, string const & to)
401 {
402         // No conversion is needed. LaTeX can handle the graphic file as is.
403         // This is true even if the orig_file is compressed.
404         if (formats.getFormat(to)->extension() == GetExtension(file))
405                 return RemoveExtension(file);
406         return file;
407 }
408
409 } // namespace anon
410
411
412 string const InsetGraphics::prepareFile(Buffer const & buf,
413                                         OutputParams const & runparams) const
414 {
415         string orig_file = params().filename.absFilename();
416         string const rel_file = params().filename.relFilename(buf.filePath());
417
418         // LaTeX can cope if the graphics file doesn't exist, so just return the
419         // filename.
420         if (!IsFileReadable(orig_file)) {
421                 lyxerr[Debug::GRAPHICS]
422                         << "InsetGraphics::prepareFile\n"
423                         << "No file '" << orig_file << "' can be found!" << endl;
424                 return rel_file;
425         }
426
427         // If the file is compressed and we have specified that it
428         // should not be uncompressed, then just return its name and
429         // let LaTeX do the rest!
430         bool const zipped = params().filename.isZipped();
431
432         if (zipped && params().noUnzip) {
433                 lyxerr[Debug::GRAPHICS]
434                         << "\tpass zipped file to LaTeX but with full path.\n";
435                 // LaTeX needs an absolute path, otherwise the
436                 // coresponding *.eps.bb file isn't found
437                 return orig_file;
438         }
439
440         // temp_file will contain the file for LaTeX to act on if, for example,
441         // we move it to a temp dir or uncompress it.
442         string temp_file = orig_file;
443
444         // We place all temporary files in the master buffer's temp dir.
445         // This is possible because we use mangled file names.
446         // This is necessary for DVI export.
447         string const temp_path = buf.getMasterBuffer()->temppath();
448
449         if (zipped) {
450                 CopyStatus status;
451                 boost::tie(status, temp_file) =
452                         copyToDirIfNeeded(orig_file, temp_path);
453
454                 if (status == FAILURE)
455                         return orig_file;
456
457                 orig_file = unzippedFileName(temp_file);
458                 if (!IsFileReadable(orig_file)) {
459                         unzipFile(temp_file);
460                         lyxerr[Debug::GRAPHICS]
461                                 << "\tunzipped to " << orig_file << endl;
462                 }
463         }
464
465         string const from = getExtFromContents(orig_file);
466         string const to   = findTargetFormat(from, runparams);
467         lyxerr[Debug::GRAPHICS]
468                 << "\t we have: from " << from << " to " << to << '\n';
469
470         // We're going to be running the exported buffer through the LaTeX
471         // compiler, so must ensure that LaTeX can cope with the graphics
472         // file format.
473
474         lyxerr[Debug::GRAPHICS]
475                 << "\tthe orig file is: " << orig_file << endl;
476
477         bool conversion_needed = true;
478         CopyStatus status;
479         boost::tie(status, temp_file) =
480                         copyToDirIfNeeded(orig_file, temp_path);
481
482         if (status == FAILURE)
483                 return orig_file;
484         else if (status == IDENTICAL_CONTENTS)
485                 conversion_needed = false;
486
487         if (from == to)
488                 return stripExtensionIfPossible(temp_file, to);
489
490         string const to_file_base = RemoveExtension(temp_file);
491         string const to_file = ChangeExtension(to_file_base, to);
492
493         // Do we need to perform the conversion?
494         // Yes if to_file does not exist or if temp_file is newer than to_file
495         if (!conversion_needed ||
496             support::compare_timestamps(temp_file, to_file) < 0) {
497                 lyxerr[Debug::GRAPHICS]
498                         << bformat(_("No conversion of %1$s is needed after all"),
499                                    rel_file)
500                         << std::endl;
501                 return to_file_base;
502         }
503
504         lyxerr[Debug::GRAPHICS]
505                 << "\tThe original file is " << orig_file << "\n"
506                 << "\tA copy has been made and convert is to be called with:\n"
507                 << "\tfile to convert = " << temp_file << '\n'
508                 << "\tto_file_base = " << to_file_base << '\n'
509                 << "\t from " << from << " to " << to << '\n';
510
511         // if no special converter defined, then we take the default one
512         // from ImageMagic: convert from:inname.from to:outname.to
513         if (!converters.convert(&buf, temp_file, to_file_base, from, to)) {
514                 string const command =
515                         "sh " + LibFileSearch("scripts", "convertDefault.sh") +
516                                 ' ' + from + ':' + temp_file + ' ' +
517                                 to + ':' + to_file_base + '.' + to;
518                 lyxerr[Debug::GRAPHICS]
519                         << "No converter defined! I use convertDefault.sh:\n\t"
520                         << command << endl;
521                 Systemcall one;
522                 one.startscript(Systemcall::Wait, command);
523                 if (!IsFileReadable(ChangeExtension(to_file_base, to))) {
524                         string str = bformat(_("No information for converting %1$s "
525                                 "format files to %2$s.\n"
526                                 "Try defining a convertor in the preferences."), from, to);
527                         Alert::error(_("Could not convert image"), str);
528                 }
529         }
530
531         return to_file_base;
532 }
533
534
535 int InsetGraphics::latex(Buffer const & buf, ostream & os,
536                          OutputParams const & runparams) const
537 {
538         // The master buffer. This is useful when there are multiple levels
539         // of include files
540         Buffer const * m_buffer = buf.getMasterBuffer();
541
542         // If there is no file specified or not existing,
543         // just output a message about it in the latex output.
544         lyxerr[Debug::GRAPHICS]
545                 << "insetgraphics::latex: Filename = "
546                 << params().filename.absFilename() << endl;
547
548         string const relative_file =
549                 params().filename.relFilename(buf.filePath());
550
551         // A missing (e)ps-extension is no problem for LaTeX, so
552         // we have to test three different cases
553 #ifdef WITH_WARNINGS
554 #warning uh, but can our cache handle it ? no.
555 #endif
556         string const file_ = params().filename.absFilename();
557         bool const file_exists =
558                 !file_.empty() &&
559                 (IsFileReadable(file_) ||               // original
560                  IsFileReadable(file_ + ".eps") ||      // original.eps
561                  IsFileReadable(file_ + ".ps"));        // original.ps
562         string const message = file_exists ?
563                 string() : string("bb = 0 0 200 100, draft, type=eps");
564         // if !message.empty() than there was no existing file
565         // "filename(.(e)ps)" found. In this case LaTeX
566         // draws only a rectangle with the above bb and the
567         // not found filename in it.
568         lyxerr[Debug::GRAPHICS]
569                 << "\tMessage = \"" << message << '\"' << endl;
570
571         // These variables collect all the latex code that should be before and
572         // after the actual includegraphics command.
573         string before;
574         string after;
575         // Do we want subcaptions?
576         if (params().subcaption) {
577                 before += "\\subfigure[" + params().subcaptionText + "]{";
578                 after = '}';
579         }
580         // We never use the starred form, we use the "clip" option instead.
581         before += "\\includegraphics";
582
583         // Write the options if there are any.
584         string const opts = createLatexOptions();
585         lyxerr[Debug::GRAPHICS] << "\tOpts = " << opts << endl;
586
587         if (!opts.empty() && !message.empty())
588                 before += ("[%\n" + opts + ',' + message + ']');
589         else if (!opts.empty() || !message.empty())
590                 before += ("[%\n" + opts + message + ']');
591
592         lyxerr[Debug::GRAPHICS]
593                 << "\tBefore = " << before
594                 << "\n\tafter = " << after << endl;
595
596
597         string latex_str = before + '{';
598         // "nice" means that the buffer is exported to LaTeX format but not
599         //        run through the LaTeX compiler.
600         if (runparams.nice) {
601                 // a relative filename should be relative to the master
602                 // buffer.
603                 latex_str += params().filename.outputFilename(m_buffer->filePath());
604         } else if (file_exists) {
605                 // Make the filename relative to the lyx file
606                 // and remove the extension so the LaTeX will use whatever
607                 // is appropriate (when there are several versions in
608                 // different formats)
609                 latex_str += os::external_path(prepareFile(buf, runparams));
610         } else
611                 latex_str += relative_file + " not found!";
612
613         latex_str += '}' + after;
614         os << latex_str;
615
616         lyxerr[Debug::GRAPHICS] << "InsetGraphics::latex outputting:\n"
617                                 << latex_str << endl;
618         // Return how many newlines we issued.
619         return int(lyx::count(latex_str.begin(), latex_str.end(),'\n') + 1);
620 }
621
622
623 int InsetGraphics::plaintext(Buffer const &, ostream & os,
624                          OutputParams const &) const
625 {
626         // No graphics in ascii output. Possible to use gifscii to convert
627         // images to ascii approximation.
628         // 1. Convert file to ascii using gifscii
629         // 2. Read ascii output file and add it to the output stream.
630         // at least we send the filename
631         os << '<' << bformat(_("Graphics file: %1$s"),
632                              params().filename.absFilename()) << ">\n";
633         return 0;
634 }
635
636
637 int InsetGraphics::linuxdoc(Buffer const & buf, ostream & os,
638                             OutputParams const & runparams) const
639 {
640         string const file_name = runparams.nice ?
641                                 params().filename.relFilename(buf.filePath()):
642                                 params().filename.absFilename();
643
644         os << "<eps file=\"" << file_name << "\">\n";
645         os << "<img src=\"" << file_name << "\">";
646         return 0;
647 }
648
649
650 // For explanation on inserting graphics into DocBook checkout:
651 // http://en.tldp.org/LDP/LDP-Author-Guide/inserting-pictures.html
652 // See also the docbook guide at http://www.docbook.org/
653 int InsetGraphics::docbook(Buffer const &, ostream & os,
654                            OutputParams const &) const
655 {
656         // In DocBook v5.0, the graphic tag will be eliminated from DocBook, will
657         // need to switch to MediaObject. However, for now this is sufficient and
658         // easier to use.
659         os << "<graphic fileref=\"&" << graphic_label << ";\">";
660         return 0;
661 }
662
663
664 void InsetGraphics::validate(LaTeXFeatures & features) const
665 {
666         // If we have no image, we should not require anything.
667         if (params().filename.empty())
668                 return;
669
670         features.includeFile(graphic_label,
671                              RemoveExtension(params().filename.absFilename()));
672
673         features.require("graphicx");
674
675         if (params().subcaption)
676                 features.require("subfigure");
677 }
678
679
680 bool InsetGraphics::setParams(InsetGraphicsParams const & p)
681 {
682         // If nothing is changed, just return and say so.
683         if (params() == p && !p.filename.empty())
684                 return false;
685
686         // Copy the new parameters.
687         params_ = p;
688
689         // Update the display using the new parameters.
690         graphic_->update(params().as_grfxParams());
691
692         // We have changed data, report it.
693         return true;
694 }
695
696
697 InsetGraphicsParams const & InsetGraphics::params() const
698 {
699         return params_;
700 }
701
702
703 void InsetGraphics::editGraphics(InsetGraphicsParams const & p, Buffer const & buffer) const
704 {
705         string const file_with_path = p.filename.absFilename();
706         formats.edit(buffer, file_with_path, getExtFromContents(file_with_path));
707 }
708
709
710 string const InsetGraphicsMailer::name_("graphics");
711
712 InsetGraphicsMailer::InsetGraphicsMailer(InsetGraphics & inset)
713         : inset_(inset)
714 {}
715
716
717 string const InsetGraphicsMailer::inset2string(Buffer const & buffer) const
718 {
719         return params2string(inset_.params(), buffer);
720 }
721
722
723 void InsetGraphicsMailer::string2params(string const & in,
724                                         Buffer const & buffer,
725                                         InsetGraphicsParams & params)
726 {
727         params = InsetGraphicsParams();
728         if (in.empty())
729                 return;
730
731         istringstream data(in);
732         LyXLex lex(0,0);
733         lex.setStream(data);
734
735         string name;
736         lex >> name;
737         if (!lex || name != name_)
738                 return print_mailer_error("InsetGraphicsMailer", in, 1, name_);
739
740         InsetGraphics inset;
741         inset.readInsetGraphics(lex, buffer.filePath());
742         params = inset.params();
743 }
744
745
746 string const
747 InsetGraphicsMailer::params2string(InsetGraphicsParams const & params,
748                                    Buffer const & buffer)
749 {
750         ostringstream data;
751         data << name_ << ' ';
752         params.Write(data, buffer.filePath());
753         data << "\\end_inset\n";
754         return data.str();
755 }