]> git.lyx.org Git - lyx.git/blob - src/insets/insetgraphics.C
Herbert's bugfix patch
[lyx.git] / src / insets / insetgraphics.C
1 /* This file is part of
2  * ====================================================== 
3  * 
4  *           LyX, The Document Processor
5  *       
6  *           Copyright 1995-2002 the LyX Team.
7  *           
8  * \author Baruch Even
9  * \author Herbert Voss <voss@lyx.org>
10  * ====================================================== */
11
12 /*
13 Known BUGS:
14     
15     * If the image is from the clipart, and the document is moved to another
16        directory, the user is screwed. Need a way to handle it.
17        This amounts to a problem of when to use relative or absolute file paths
18        We should probably use what the user asks to use... but when he chooses
19        by the file dialog we normally get an absolute path and this may not be 
20        what the user meant.
21        [Note that browseRelFile in helper_funcs.* provides a file name
22         which is relative if it is at reference path (here puffer path)
23         level or below, and an absolute path if the file name is not a
24         `natural' relative file name. In any case,
25             MakeAbsPath(filename, buf->filePath())
26         is guaranteed to provide the correct absolute path. This is what is
27         done know for include insets. Feel free to ask me -- JMarc
28         14/01/2002]
29         
30         * If we are trying to create a file in a read-only directory and there
31                 are graphics that need converting, the converting will fail because
32                 it is done in-place, into the same directory as the original image.
33                 This needs to be fixed in the src/converter.C file
34                 [ This is presumed to be fixed, needs testing.]
35
36         * We do not dither or resize the image in a WYSIWYM way, we load it at
37                 its original size and color, resizing is done in the final output,
38                 but not in the LyX window.
39
40 TODO Before initial production release:
41     * Replace insetfig everywhere
42         * Search for comments of the form
43             // INSET_GRAPHICS: remove this when InsetFig is thrown.
44           And act upon them. Make sure not to remove InsetFig code for the 
45                   1.2.0 release, only afterwards, after deployment shows InsetGraphics
46                   to be ok.
47         * What advanced features the users want to do?
48             Implement them in a non latex dependent way, but a logical way.
49             LyX should translate it to latex or any other fitting format.
50     * Add a way to roll the image file into the file format.
51     * When loading, if the image is not found in the expected place, try
52        to find it in the clipart, or in the same directory with the image.
53     * Keep a tab on the image file, if it changes, update the lyx view.
54         * The image choosing dialog could show thumbnails of the image formats
55           it knows of, thus selection based on the image instead of based on
56           filename.
57         * Add support for the 'picins' package.
58         * Add support for the 'picinpar' package.
59         * Improve support for 'subfigure' - Allow to set the various options
60                 that are possible.
61  */
62
63 /* NOTES:
64  * Fileformat:
65  * Current version is 1 (inset file format version), when changing it
66  * it should be changed in the Write() function when writing in one place
67  * and when reading one should change the version check and the error message.
68  * The filename is kept in  the lyx file in a relative way, so as to allow
69  * moving the document file and its images with no problem.
70  * 
71  *
72  * Conversions:
73  *   Postscript output means EPS figures.
74  *
75  *   PDF output is best done with PDF figures if it's a direct conversion
76  *   or PNG figures otherwise.
77  *      Image format
78  *      from        to
79  *      EPS         epstopdf
80  *      PS          ps2pdf
81  *      JPG/PNG     direct
82  *      PDF         direct
83  *      others      PNG
84  */
85
86 #include <config.h> 
87
88 #ifdef __GNUG__
89 #pragma implementation
90 #endif 
91
92 #include "insets/insetgraphics.h"
93 #include "insets/insetgraphicsParams.h"
94 #include "graphics/GraphicsCache.h"
95 #include "graphics/GraphicsCacheItem.h"
96
97 #include "frontends/Dialogs.h"
98 #include "frontends/Alert.h"
99 #include "LyXView.h"
100 #include "buffer.h"
101 #include "BufferView.h"
102 #include "converter.h"
103 #include "frontends/support/LyXImage.h"
104 #include "Painter.h"
105 #include "lyx_gui_misc.h"
106 #include "support/FileInfo.h"
107 #include "support/filetools.h"
108 #include "frontends/controllers/helper_funcs.h"
109 #include "support/lyxlib.h"
110 #include "lyxtext.h"
111 #include "lyxrc.h"
112 #include "font.h" // For the lyxfont class.
113 #include "fstream" // for ifstream in isEPS
114 #include <algorithm> // For the std::max
115 #include "support/lyxmanip.h"
116 #include "debug.h"
117 #include "gettext.h"
118
119 extern string system_tempdir;
120
121 using std::ifstream;
122 using std::ostream;
123 using std::endl;
124
125 ///////////////////////////////////////////////////////////////////////////
126 int const VersionNumber = 1;
127 ///////////////////////////////////////////////////////////////////////////
128
129 // This function is a utility function
130 // ... that should be with ChangeExtension ...
131 inline
132 string const RemoveExtension(string const & filename)
133 {
134         return ChangeExtension(filename, string());
135 }
136
137
138 // Initialize only those variables that do not have a constructor.
139 InsetGraphics::InsetGraphics()
140         : cacheHandle(0), imageLoaded(false)
141 {}
142
143
144 InsetGraphics::InsetGraphics(InsetGraphics const & ig, bool same_id)
145         : Inset(), SigC::Object()
146         , cacheHandle(ig.cacheHandle)
147         , imageLoaded(ig.imageLoaded)
148 {
149         setParams(ig.getParams());
150         if (same_id)
151                 id_ = ig.id_;
152 }
153
154
155 InsetGraphics::~InsetGraphics()
156 {
157         // Emits the hide signal to the dialog connected (if any)
158         hideDialog();
159 }
160
161
162 string const InsetGraphics::statusMessage() const
163 {
164         string msg;
165         if (cacheHandle.get()) {
166                 switch (cacheHandle->getImageStatus()) {
167                 case GraphicsCacheItem::UnknownError:
168                         msg = _("Unknown Error");
169                         break;
170                 case GraphicsCacheItem::Loading:
171                         msg = _("Loading...");
172                         break;
173                 case GraphicsCacheItem::ErrorReading:
174                         msg = _("Error reading");
175                         break;
176                 case GraphicsCacheItem::Converting:
177                         msg = _("Converting Image");
178                         break;
179                 case GraphicsCacheItem::ErrorConverting:
180                         msg = _("Error converting");
181                         break;
182                 case GraphicsCacheItem::Loaded:
183                         // No message to write.
184                         break;
185                 }
186         }
187         return msg;
188 }
189
190
191 int InsetGraphics::ascent(BufferView *, LyXFont const &) const
192 {
193         LyXImage * pixmap = 0;
194         if (cacheHandle.get() && (pixmap = cacheHandle->getImage()))
195                 return pixmap->getHeight();
196         else
197                 return 50;
198 }
199
200
201 int InsetGraphics::descent(BufferView *, LyXFont const &) const
202 {
203         // this is not true if viewport is used and clip is not.
204         return 0;
205 }
206
207
208 int InsetGraphics::width(BufferView *, LyXFont const & font) const
209 {
210         LyXImage * pixmap = 0;
211         
212         if (cacheHandle.get() && (pixmap = cacheHandle->getImage()))
213                 return pixmap->getWidth();
214         else {
215                 int font_width = 0;
216
217                 LyXFont msgFont(font);
218                 msgFont.setFamily(LyXFont::SANS_FAMILY);
219
220                 string const justname = OnlyFilename (params.filename);
221                 if (!justname.empty()) {
222                         msgFont.setSize(LyXFont::SIZE_FOOTNOTE);
223                         font_width = lyxfont::width(justname, msgFont);
224                 }
225
226                 string const msg = statusMessage();
227                 if (!msg.empty()) {
228                         msgFont.setSize(LyXFont::SIZE_TINY);
229                         int const msg_width = lyxfont::width(msg, msgFont);
230                         font_width = std::max(font_width, msg_width);
231                 }
232                 
233                 return std::max(50, font_width + 15);
234         }
235 }
236
237
238 void InsetGraphics::draw(BufferView * bv, LyXFont const & font,
239                          int baseline, float & x, bool) const
240 {
241         Painter & paint = bv->painter();
242
243         int ldescent = descent(bv, font);
244         int lascent = ascent(bv, font);
245         int lwidth = width(bv, font);
246
247         // Make sure x is updated upon exit from this routine
248         int old_x = int(x);
249         x += lwidth;
250
251         // This will draw the graphics. If the graphics has not been loaded yet,
252         // we draw just a rectangle.
253         if (imageLoaded) {
254
255                 paint.image(old_x + 2, baseline - lascent,
256                             lwidth - 4, lascent + ldescent,
257                             cacheHandle->getImage());
258         } else {        
259                 // Get the image status, default to unknown error.
260                 GraphicsCacheItem::ImageStatus status = GraphicsCacheItem::UnknownError;
261                 if (lyxrc.use_gui && params.display != InsetGraphicsParams::NONE &&
262                     cacheHandle.get())
263                         status = cacheHandle->getImageStatus();
264                 // Check if the image is now ready.
265                 if (status == GraphicsCacheItem::Loaded) {
266                         imageLoaded = true;
267                         // Tell BufferView we need to be updated!
268                         bv->text->status(bv, LyXText::CHANGED_IN_DRAW);
269                         return;
270                 }
271                 paint.rectangle(old_x + 2, baseline - lascent,
272                                 lwidth - 4,
273                                 lascent + ldescent);
274                 // Print the file name.
275                 LyXFont msgFont(font);
276                 msgFont.setFamily(LyXFont::SANS_FAMILY);
277                 string const justname = OnlyFilename (params.filename);
278                 if (!justname.empty()) {
279                         msgFont.setSize(LyXFont::SIZE_FOOTNOTE);
280                         paint.text(old_x + 8, 
281                                    baseline - lyxfont::maxAscent(msgFont) - 4,
282                                    justname, msgFont);
283                 }
284                 // Print the message.
285                 string const msg = statusMessage();
286                 if (!msg.empty()) {
287                         msgFont.setSize(LyXFont::SIZE_TINY);
288                         paint.text(old_x + 8, baseline - 4, msg, msgFont);
289                 }
290         }
291 }
292
293
294 void InsetGraphics::edit(BufferView *bv, int, int, unsigned int)
295 {
296         bv->owner()->getDialogs()->showGraphics(this);
297 }
298
299
300 void InsetGraphics::edit(BufferView * bv, bool)
301 {
302         edit(bv, 0, 0, 0);
303 }
304
305
306 Inset::EDITABLE InsetGraphics::editable() const
307 {
308         return IS_EDITABLE;
309 }
310
311
312 void InsetGraphics::write(Buffer const * buf, ostream & os) const
313 {
314         os << "Graphics FormatVersion " << VersionNumber << '\n';
315         params.Write(buf, os);
316 }
317
318
319 void InsetGraphics::read(Buffer const * buf, LyXLex & lex)
320 {
321         string const token = lex.getString();
322
323         if (token == "Graphics")
324                 readInsetGraphics(buf, lex);
325         else if (token == "Figure") // Compatibility reading of FigInset figures.
326                 readFigInset(buf, lex);
327         else
328                 lyxerr[Debug::INFO] << "Not a Graphics or Figure inset!\n";
329
330         updateInset();
331 }
332
333 void InsetGraphics::readInsetGraphics(Buffer const * buf, LyXLex & lex)
334 {
335         bool finished = false;
336
337         while (lex.isOK() && !finished) {
338                 lex.next();
339
340                 string const token = lex.getString();
341                 lyxerr[Debug::INFO] << "Token: '" << token << '\'' 
342                                     << std::endl;
343
344                 if (token.empty()) {
345                         continue;
346                 } else if (token == "\\end_inset") {
347                         finished = true;
348                 } else if (token == "FormatVersion") {
349                         lex.next();
350                         int version = lex.getInteger();
351                         if (version > VersionNumber)
352                                 lyxerr
353                                 << "This document was created with a newer Graphics widget"
354                                 ", You should use a newer version of LyX to read this"
355                                 " file."
356                                 << std::endl;
357                         // TODO: Possibly open up a dialog?
358                 }
359                 else {
360                         if (! params.Read(buf, lex, token))
361                                 lyxerr << "Unknown token, " << token << ", skipping." 
362                                         << std::endl;
363                 }
364         }
365 }
366
367 // FormatVersion < 1.0  (LyX < 1.2)
368 void InsetGraphics::readFigInset(Buffer const * buf, LyXLex & lex)
369 {
370         std::vector<string> const oldUnits =
371                 getVectorFromString("pt,cm,in,p%,c%");
372         bool finished = false;
373         // set the display default      
374         if (lyxrc.display_graphics == "mono") 
375             params.display = InsetGraphicsParams::MONOCHROME;
376         else if (lyxrc.display_graphics == "gray") 
377             params.display = InsetGraphicsParams::GRAYSCALE;
378         else if (lyxrc.display_graphics == "color") 
379             params.display = InsetGraphicsParams::COLOR;
380         else
381             params.display = InsetGraphicsParams::NONE;
382         while (lex.isOK() && !finished) {
383                 lex.next();
384
385                 string const token = lex.getString();
386                 lyxerr[Debug::INFO] << "Token: " << token << endl;
387                 
388                 if (token.empty())
389                         continue;
390                 else if (token == "\\end_inset") {
391                         finished = true;
392                 } else if (token == "file") {
393                         if (lex.next()) {
394                                 string const name = lex.getString();
395                                 string const path = buf->filePath();
396                                 params.filename = MakeAbsPath(name, path);
397                         }
398                 } else if (token == "extra") {
399                         if (lex.next());
400                         // kept for backwards compability. Delete in 0.13.x
401                 } else if (token == "subcaption") {
402                         if (lex.eatLine())
403                                 params.subcaptionText = lex.getString();
404                         params.subcaption = true;
405                 } else if (token == "label") {
406                         if (lex.next());
407                         // kept for backwards compability. Delete in 0.13.x
408                 } else if (token == "angle") {
409                         if (lex.next())
410                                 params.rotate = true;
411                                 params.rotateAngle = lex.getFloat();
412                 } else if (token == "size") {
413                         if (lex.next())
414                                 params.lyxwidth = LyXLength(lex.getString()+"pt");
415                         if (lex.next())
416                                 params.lyxheight = LyXLength(lex.getString()+"pt");
417                 } else if (token == "flags") {
418                         if (lex.next())
419                                 switch (lex.getInteger()) {
420                                 case 1: params.display = InsetGraphicsParams::MONOCHROME; 
421                                     break;
422                                 case 2: params.display = InsetGraphicsParams::GRAYSCALE; 
423                                     break;
424                                 case 3: params.display = InsetGraphicsParams::COLOR; 
425                                     break;
426                                 }
427                 } else if (token == "subfigure") {
428                         params.subcaption = true;
429                 } else if (token == "width") {
430                     if (lex.next()) {
431                         int i = lex.getInteger();
432                         if (lex.next()) {
433                             if (i == 5) {
434                                 params.scale = lex.getInteger();
435                                 params.size_type = InsetGraphicsParams::SCALE;
436                             } else {
437                                 params.width = LyXLength(lex.getString()+oldUnits[i]);
438                                 params.size_type = InsetGraphicsParams::WH;
439                             }
440                         }
441                     }
442                 } else if (token == "height") {
443                     if (lex.next()) {
444                         int i = lex.getInteger();
445                         if (lex.next()) {
446                             params.height = LyXLength(lex.getString()+oldUnits[i]);
447                             params.size_type = InsetGraphicsParams::WH;
448                         }
449                     }
450                 }
451         }
452 }
453
454 string const InsetGraphics::createLatexOptions() const
455 {
456         // Calculate the options part of the command, we must do it to a string
457         // stream since we might have a trailing comma that we would like to remove
458         // before writing it to the output stream.
459         ostringstream options;
460         if (!params.bb.empty())
461             options << "  bb=" << strip(params.bb) << ",\n";
462         if (params.draft)
463             options << "  draft,\n";
464         if (params.clip)
465             options << "  clip,\n";
466         if (params.size_type == InsetGraphicsParams::WH) {
467             if (!params.width.zero())
468                 options << "  width=" << params.width.asLatexString() << ",\n";
469             if (!params.height.zero())
470                 options << "  height=" << params.height.asLatexString() << ",\n";
471         } else if (params.size_type == InsetGraphicsParams::SCALE) {
472             if (params.scale > 0)
473                 options << "  scale=" << double(params.scale)/100.0 << ",\n";
474         }
475         if (params.keepAspectRatio)
476             options << "  keepaspectratio,\n";
477         // Make sure it's not very close to zero, a float can be effectively
478         // zero but not exactly zero.
479         if (!lyx::float_equal(params.rotateAngle, 0, 0.001) && params.rotate) {
480             options << "  angle=" << params.rotateAngle << ",\n";
481             if (!params.rotateOrigin.empty()) {
482                 options << "  origin=" << params.rotateOrigin[0];
483                 if (contains(params.rotateOrigin,"Top"))
484                     options << 't';
485                 else if (contains(params.rotateOrigin,"Bottom"))
486                     options << 'b';
487                 else if (contains(params.rotateOrigin,"Baseline"))
488                     options << 'B';
489                 options << ",\n";
490             }
491         }
492         if (!params.special.empty())
493             options << params.special << ",\n";
494         string opts = options.str().c_str();
495         return opts.substr(0,opts.size()-2);    // delete last ",\n"
496 }
497
498 namespace {
499 string decideOutputImageFormat(string const & suffix)
500 {
501         // lyxrc.pdf_mode means:
502         // Are we creating a PDF or a PS file?
503         // (Should actually mean, are we using latex or pdflatex).      
504         lyxerr << "decideOutput::lyxrc.pdf_mode = " << lyxrc.pdf_mode << "\n";
505         if (lyxrc.pdf_mode) {
506                 if (contains(suffix,"ps") || suffix == "pdf")
507                         return "pdf";
508                 else if (suffix == "jpg")
509                         return suffix;
510                 else
511                         return "png";
512         }
513         // If it's postscript, we always do eps.
514         lyxerr << "decideOutput: we have PostScript mode\n";
515         if (suffix != "ps")
516             return "eps";
517         else
518             return "ps";
519 }
520
521 } // Anon. namespace
522
523 string const InsetGraphics::prepareFile(Buffer const *buf) const
524 {
525         // do_convert = Do we need to convert the file?
526         // nice = Do we create a nice version?
527         //        This is used when exporting the latex file only.
528         // if (!do_convert)
529         //   return original filename
530         // if (!nice)
531         //   convert_place = temp directory
532         //   return new filename in temp directory
533         // else
534         //   convert_place = original file directory
535         //   return original filename without the extension
536         //
537         // first check if file is viewed in LyX. First local
538         // than global
539         if ((params.display == InsetGraphicsParams::NONE) || 
540             ((params.display == InsetGraphicsParams::DEFAULT) &&
541             (lyxrc.display_graphics == "no"))) {
542                 lyxerr << "InsetGraphics::no converting of: " << params.filename << "\n";
543                 return params.filename;
544         }
545         // if it's a zipped one, than let LaTeX do the rest!!!
546         if (zippedFile(params.filename)) {
547             lyxerr << "InsetGraphics::prepareFilter(zippedFile): return " 
548                     << params.filename << endl;
549             return params.filename;
550         }
551         // now we have unzipped files
552         // Get the extension (format) of the original file.
553         // we handle it like a virtual one, so we can have
554         // different extensions with the same type.
555         string const extension = getExtFromContents(params.filename);
556         // Are we creating a PDF or a PS file?
557         // (Should actually mean, are we usind latex or pdflatex).
558         string const image_target = decideOutputImageFormat(extension);
559         if (extension == image_target)
560                 return params.filename;
561         if (!IsFileReadable(params.filename)) {
562                 Alert::alert(_("File") + params.filename,
563                            _("isn't readable or doesn't exists!"));
564                 return params.filename;
565         }
566         string outfile;
567         if (!buf->niceFile) {
568                 string const temp = AddName(buf->tmppath, params.filename);
569                 lyxerr << "temp = " << temp << "\n";
570                 outfile = RemoveExtension(temp);
571         } else {
572                 string const path = buf->filePath();
573                 string const relname = MakeRelPath(params.filename, path);
574                 outfile = RemoveExtension(relname);
575         }
576         lyxerr << "buf::tmppath = " << buf->tmppath << "\n";
577         lyxerr << "filename = " << params.filename << "\n";
578         lyxerr << "outfile = " << outfile << endl;
579         converters.convert(buf, params.filename, outfile, extension, image_target);
580         return outfile;
581 }
582
583
584 int InsetGraphics::latex(Buffer const *buf, ostream & os,
585                          bool /*fragile*/, bool/*fs*/) const
586 {
587         // If there is no file specified, just output a message about it in
588         // the latex output.
589         if (params.filename.empty()) {
590                 os  << "\\fbox{\\rule[-0.5in]{0pt}{1in}"
591                         << _("empty figure path") << "}\n";
592                 return 1; // One end of line marker added to the stream.
593         }
594         // Keep count of newlines that we issued.
595         int newlines = 0;
596         // This variables collect all the latex code that should be before and
597         // after the actual includegraphics command.
598         string before;
599         string after;
600         // Do we want subcaptions?
601         if (params.subcaption) {
602                 before += "\\subfigure[" + params.subcaptionText + "]{";
603                 after = '}' + after;
604         }
605         // We never use the starred form, we use the "clip" option instead.
606         os << before << "\\includegraphics";
607         // Write the options if there are any.
608         string const opts = createLatexOptions();
609         if (!opts.empty()) {
610                 os << "[%\n" << opts << ']';
611         }
612         // Make the filename relative to the lyx file
613         // and remove the extension so the LaTeX will use whatever is
614         // appropriate (when there are several versions in different formats)
615         string const filename = prepareFile(buf);
616         os << '{' << filename << '}' << after;
617         // Return how many newlines we issued.
618         return newlines;
619 }
620
621
622 int InsetGraphics::ascii(Buffer const *, ostream & os, int) const
623 {
624         // No graphics in ascii output. Possible to use gifscii to convert
625         // images to ascii approximation.
626         // 1. Convert file to ascii using gifscii
627         // 2. Read ascii output file and add it to the output stream.
628         // at least we send the filename
629         os << '<' << _("Graphicfile:") << params.filename << ">\n";
630         return 0;
631 }
632
633
634 int InsetGraphics::linuxdoc(Buffer const *, ostream &) const
635 {
636         // No graphics in LinuxDoc output. Should check how/what to add.
637         return 0;
638 }
639
640
641 // For explanation on inserting graphics into DocBook checkout:
642 // http://linuxdoc.org/LDP/LDP-Author-Guide/inserting-pictures.html
643 // See also the docbook guide at http://www.docbook.org/
644 int InsetGraphics::docbook(Buffer const * buf, ostream & os) const
645 {
646         // Change the path to be relative to the main file.
647         string const buffer_dir = buf->filePath();
648         string filename = RemoveExtension(
649                 MakeRelPath(params.filename, buffer_dir));
650
651         if (suffixIs(filename, ".eps"))
652                 filename.erase(filename.length() - 4);
653
654         // In DocBook v5.0, the graphic tag will be eliminated from DocBook, will 
655         // need to switch to MediaObject. However, for now this is sufficient and 
656         // easier to use.
657         os << "<graphic fileref=\"" << filename << "\"></graphic>";
658         return 0;
659 }
660
661
662 void InsetGraphics::validate(LaTeXFeatures & features) const
663 {
664         // If we have no image, we should not require anything.
665         if (params.filename.empty())
666                 return ;
667
668         features.require("graphicx");
669
670         if (params.subcaption)
671                 features.require("subfigure");
672 }
673
674
675 // Update the inset after parameters changed (read from file or changed in
676 // dialog.
677 void InsetGraphics::updateInset() const
678 {
679         GraphicsCache & gc = GraphicsCache::getInstance();
680         boost::shared_ptr<GraphicsCacheItem> temp(0);
681
682         // We do it this way so that in the face of some error, we will still
683         // be in a valid state.
684         InsetGraphicsParams::DisplayType local_display = params.display;
685         if (local_display == InsetGraphicsParams::DEFAULT) {
686                 if (lyxrc.display_graphics == "mono")
687                         local_display = InsetGraphicsParams::MONOCHROME;
688                 else if (lyxrc.display_graphics == "gray")
689                         local_display = InsetGraphicsParams::GRAYSCALE;
690                 else if (lyxrc.display_graphics == "color")
691                         local_display = InsetGraphicsParams::COLOR;
692                 else
693                         local_display = InsetGraphicsParams::NONE;
694         }
695
696         if (!params.filename.empty() && lyxrc.use_gui &&
697             local_display != InsetGraphicsParams::NONE) {
698                 temp = gc.addFile(params.filename);
699         }
700
701         // Mark the image as unloaded so that it gets updated.
702         imageLoaded = false;
703
704         cacheHandle = temp;
705 }
706
707
708 bool InsetGraphics::setParams(InsetGraphicsParams const & p)
709 {
710         // If nothing is changed, just return and say so.
711         if (params == p)
712                 return false;
713
714         // Copy the new parameters.
715         params = p;
716
717         // Update the inset with the new parameters.
718         updateInset();
719
720         // We have changed data, report it.
721         return true;
722 }
723
724
725 InsetGraphicsParams InsetGraphics::getParams() const
726 {
727         return params;
728 }
729
730
731 Inset * InsetGraphics::clone(Buffer const &, bool same_id) const
732 {
733         return new InsetGraphics(*this, same_id);
734 }
735