1 /* This file is part of
2 * ======================================================
4 * LyX, The Document Processor
6 * Copyright 1995-2002 the LyX Team.
9 * \author Herbert Voss <voss@lyx.org>
10 * ====================================================== */
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
22 Note that browseRelFile in helper_funcs.* provides a file name
23 which is relative if it is at reference path (here puffer path)
24 level or below, and an absolute path if the file name is not a
25 `natural' relative file name. In any case,
26 MakeAbsPath(filename, buf->filePath())
27 is guaranteed to provide the correct absolute path. This is what is
28 done know for include insets. Feel free to ask me -- JMarc
31 TODO Before initial production release:
33 * What advanced features the users want to do?
34 Implement them in a non latex dependent way, but a logical way.
35 LyX should translate it to latex or any other fitting format.
36 * Add a way to roll the image file into the file format.
37 * When loading, if the image is not found in the expected place, try
38 to find it in the clipart, or in the same directory with the image.
39 * Keep a tab on the image file, if it changes, update the lyx view.
40 * The image choosing dialog could show thumbnails of the image formats
41 it knows of, thus selection based on the image instead of based on
43 * Add support for the 'picins' package.
44 * Add support for the 'picinpar' package.
45 * Improve support for 'subfigure' - Allow to set the various options
51 * Current version is 1 (inset file format version), when changing it
52 * it should be changed in the Write() function when writing in one place
53 * and when reading one should change the version check and the error message.
54 * The filename is kept in the lyx file in a relative way, so as to allow
55 * moving the document file and its images with no problem.
59 * Postscript output means EPS figures.
61 * PDF output is best done with PDF figures if it's a direct conversion
62 * or PNG figures otherwise.
75 #pragma implementation
78 #include "insets/insetgraphics.h"
79 #include "insets/insetgraphicsParams.h"
81 #include "graphics/GraphicsLoader.h"
82 #include "graphics/GraphicsImage.h"
83 #include "graphics/GraphicsParams.h"
85 #include "frontends/LyXView.h"
88 #include "BufferView.h"
89 #include "converter.h"
90 #include "frontends/Painter.h"
92 #include "frontends/font_metrics.h"
95 #include "LaTeXFeatures.h"
97 #include "frontends/Dialogs.h"
98 #include "frontends/Alert.h"
99 #include "frontends/controllers/helper_funcs.h" // getVectorFromString
101 #include "support/LAssert.h"
102 #include "support/filetools.h"
103 #include "support/lyxalgo.h" // lyx::count
104 #include "support/path.h"
105 #include "support/systemcall.h"
106 #include "support/os.h"
108 #include <boost/bind.hpp>
109 #include <boost/signals/trackable.hpp>
111 #include <algorithm> // For the std::max
114 extern BufferView * current_view;
116 extern string system_tempdir;
121 ///////////////////////////////////////////////////////////////////////////
122 int const VersionNumber = 1;
123 ///////////////////////////////////////////////////////////////////////////
127 // This function is a utility function
128 // ... that should be with ChangeExtension ...
130 string const RemoveExtension(string const & filename)
132 return ChangeExtension(filename, string());
140 string const uniqueID()
142 static unsigned int seed = 1000;
145 ost << "graph" << ++seed;
147 // Needed if we use lyxstring.
148 return ost.str().c_str();
154 struct InsetGraphics::Cache : boost::signals::trackable
157 Cache(InsetGraphics &);
159 void update(string const & file_with_path);
168 InsetGraphics & parent_;
172 InsetGraphics::Cache::Cache(InsetGraphics & p)
173 : old_ascent(0), parent_(p)
175 loader.connect(boost::bind(&InsetGraphics::statusChanged, &parent_));
179 void InsetGraphics::Cache::update(string const & file_with_path)
181 lyx::Assert(!file_with_path.empty());
183 string const path = OnlyPath(file_with_path);
184 loader.reset(file_with_path, parent_.params().as_grfxParams(path));
188 InsetGraphics::InsetGraphics()
189 : graphic_label(uniqueID()),
190 cache_(new Cache(*this))
194 InsetGraphics::InsetGraphics(InsetGraphics const & ig,
195 string const & filepath,
197 : Inset(ig, same_id),
198 graphic_label(uniqueID()),
199 cache_(new Cache(*this))
201 setParams(ig.params(), filepath);
205 InsetGraphics::~InsetGraphics()
207 // Emits the hide signal to the dialog connected (if any)
212 string const InsetGraphics::statusMessage() const
216 switch (cache_->loader.status()) {
217 case grfx::WaitingToLoad:
218 msg = _("Waiting for draw request to start loading...");
221 msg = _("Loading...");
223 case grfx::Converting:
224 msg = _("Converting to loadable format...");
227 msg = _("Loaded into memory. Must now generate pixmap.");
229 case grfx::ScalingEtc:
230 msg = _("Scaling etc...");
233 msg = _("Ready to display");
235 case grfx::ErrorNoFile:
236 msg = _("No file found!");
238 case grfx::ErrorConverting:
239 msg = _("Error converting to loadable format");
241 case grfx::ErrorLoading:
242 msg = _("Error loading file into memory");
244 case grfx::ErrorGeneratingPixmap:
245 msg = _("Error generating the pixmap");
247 case grfx::ErrorUnknown:
256 bool InsetGraphics::imageIsDrawable() const
258 if (!cache_->loader.image() || cache_->loader.status() != grfx::Ready)
261 return cache_->loader.image()->isDrawable();
265 int InsetGraphics::ascent(BufferView *, LyXFont const &) const
267 cache_->old_ascent = 50;
268 if (imageIsDrawable())
269 cache_->old_ascent = cache_->loader.image()->getHeight();
270 return cache_->old_ascent;
274 int InsetGraphics::descent(BufferView *, LyXFont const &) const
280 int InsetGraphics::width(BufferView *, LyXFont const & font) const
282 if (imageIsDrawable())
283 return cache_->loader.image()->getWidth();
287 LyXFont msgFont(font);
288 msgFont.setFamily(LyXFont::SANS_FAMILY);
290 string const justname = OnlyFilename (params().filename);
291 if (!justname.empty()) {
292 msgFont.setSize(LyXFont::SIZE_FOOTNOTE);
293 font_width = font_metrics::width(justname, msgFont);
296 string const msg = statusMessage();
298 msgFont.setSize(LyXFont::SIZE_TINY);
299 int const msg_width = font_metrics::width(msg, msgFont);
300 font_width = std::max(font_width, msg_width);
303 return std::max(50, font_width + 15);
308 void InsetGraphics::draw(BufferView * bv, LyXFont const & font,
309 int baseline, float & x, bool) const
311 int oasc = cache_->old_ascent;
313 int ldescent = descent(bv, font);
314 int lascent = ascent(bv, font);
315 int lwidth = width(bv, font);
317 // we may have changed while someone other was drawing us so better
318 // to not draw anything as we surely call to redraw ourself soon.
319 // This is not a nice thing to do and should be fixed properly somehow.
320 // But I still don't know the best way to go. So let's do this like this
321 // for now (Jug 20020311)
322 if (lascent != oasc) {
326 // Make sure now that x is updated upon exit from this routine
330 if (cache_->loader.status() == grfx::WaitingToLoad) {
331 cache_->loader.startLoading(*this, *bv);
334 // This will draw the graphics. If the graphics has not been loaded yet,
335 // we draw just a rectangle.
336 Painter & paint = bv->painter();
338 if (imageIsDrawable()) {
339 paint.image(old_x + 2, baseline - lascent,
340 lwidth - 4, lascent + ldescent,
341 *cache_->loader.image());
345 paint.rectangle(old_x + 2, baseline - lascent,
349 // Print the file name.
350 LyXFont msgFont(font);
351 msgFont.setFamily(LyXFont::SANS_FAMILY);
352 string const justname = OnlyFilename (params().filename);
353 if (!justname.empty()) {
354 msgFont.setSize(LyXFont::SIZE_FOOTNOTE);
355 paint.text(old_x + 8,
356 baseline - font_metrics::maxAscent(msgFont) - 4,
360 // Print the message.
361 string const msg = statusMessage();
363 msgFont.setSize(LyXFont::SIZE_TINY);
364 paint.text(old_x + 8, baseline - 4, msg, msgFont);
368 // the status message may mean we changed size, so indicate
369 // we need a row redraw
371 if (old_status_ != grfx::ErrorUnknown && old_status_ != cached_status_) {
372 bv->getLyXText()->status(bv, LyXText::CHANGED_IN_DRAW);
376 // Reset the cache, ready for the next draw request
378 cached_status_ = grfx::ErrorUnknown;
379 cached_image_.reset();
380 cache_filled_ = false;
385 void InsetGraphics::edit(BufferView *bv, int, int, mouse_button::state)
387 bv->owner()->getDialogs()->showGraphics(this);
391 void InsetGraphics::edit(BufferView * bv, bool)
393 edit(bv, 0, 0, mouse_button::none);
397 Inset::EDITABLE InsetGraphics::editable() const
403 void InsetGraphics::write(Buffer const *, ostream & os) const
405 os << "Graphics FormatVersion " << VersionNumber << '\n';
410 void InsetGraphics::read(Buffer const * buf, LyXLex & lex)
412 string const token = lex.getString();
414 if (token == "Graphics")
415 readInsetGraphics(lex);
416 else if (token == "Figure") // Compatibility reading of FigInset figures.
419 lyxerr[Debug::GRAPHICS] << "Not a Graphics or Figure inset!\n";
421 cache_->update(MakeAbsPath(params().filename, buf->filePath()));
425 void InsetGraphics::readInsetGraphics(LyXLex & lex)
427 bool finished = false;
429 while (lex.isOK() && !finished) {
432 string const token = lex.getString();
433 lyxerr[Debug::GRAPHICS] << "Token: '" << token << '\''
438 } else if (token == "\\end_inset") {
440 } else if (token == "FormatVersion") {
442 int version = lex.getInteger();
443 if (version > VersionNumber)
445 << "This document was created with a newer Graphics widget"
446 ", You should use a newer version of LyX to read this"
449 // TODO: Possibly open up a dialog?
452 if (! params_.Read(lex, token))
453 lyxerr << "Unknown token, " << token << ", skipping."
459 // FormatVersion < 1.0 (LyX < 1.2)
460 void InsetGraphics::readFigInset(LyXLex & lex)
462 std::vector<string> const oldUnits =
463 getVectorFromString("pt,cm,in,p%,c%");
464 bool finished = false;
465 // set the display default
466 if (lyxrc.display_graphics == "mono")
467 params_.display = InsetGraphicsParams::MONOCHROME;
468 else if (lyxrc.display_graphics == "gray")
469 params_.display = InsetGraphicsParams::GRAYSCALE;
470 else if (lyxrc.display_graphics == "color")
471 params_.display = InsetGraphicsParams::COLOR;
473 params_.display = InsetGraphicsParams::NONE;
474 while (lex.isOK() && !finished) {
477 string const token = lex.getString();
478 lyxerr[Debug::GRAPHICS] << "Token: " << token << endl;
482 else if (token == "\\end_inset") {
484 } else if (token == "file") {
486 params_.filename = lex.getString();
488 } else if (token == "extra") {
490 // kept for backwards compability. Delete in 0.13.x
491 } else if (token == "subcaption") {
493 params_.subcaptionText = lex.getString();
494 } else if (token == "label") {
496 // kept for backwards compability. Delete in 0.13.x
497 } else if (token == "angle") {
499 params_.rotate = true;
500 params_.rotateAngle = lex.getFloat();
502 } else if (token == "size") {
504 params_.lyxwidth = LyXLength(lex.getString()+"pt");
506 params_.lyxheight = LyXLength(lex.getString()+"pt");
507 params_.lyxsize_type = InsetGraphicsParams::WH;
508 } else if (token == "flags") {
510 switch (lex.getInteger()) {
511 case 1: params_.display = InsetGraphicsParams::MONOCHROME;
513 case 2: params_.display = InsetGraphicsParams::GRAYSCALE;
515 case 3: params_.display = InsetGraphicsParams::COLOR;
518 } else if (token == "subfigure") {
519 params_.subcaption = true;
520 } else if (token == "width") {
522 int i = lex.getInteger();
525 params_.scale = lex.getInteger();
526 params_.size_type = InsetGraphicsParams::SCALE;
528 params_.width = LyXLength(lex.getString()+oldUnits[i]);
529 params_.size_type = InsetGraphicsParams::WH;
533 } else if (token == "height") {
535 int i = lex.getInteger();
537 params_.height = LyXLength(lex.getString()+oldUnits[i]);
538 params_.size_type = InsetGraphicsParams::WH;
545 string const InsetGraphics::createLatexOptions() const
547 // Calculate the options part of the command, we must do it to a string
548 // stream since we might have a trailing comma that we would like to remove
549 // before writing it to the output stream.
550 ostringstream options;
551 if (!params().bb.empty())
552 options << " bb=" << strip(params().bb) << ",\n";
554 options << " draft,\n";
556 options << " clip,\n";
557 if (params().size_type == InsetGraphicsParams::WH) {
558 if (!params().width.zero())
559 options << " width=" << params().width.asLatexString() << ",\n";
560 if (!params().height.zero())
561 options << " height=" << params().height.asLatexString() << ",\n";
562 } else if (params().size_type == InsetGraphicsParams::SCALE) {
563 if (params().scale > 0)
564 options << " scale=" << double(params().scale)/100.0 << ",\n";
566 if (params().keepAspectRatio)
567 options << " keepaspectratio,\n";
568 // Make sure it's not very close to zero, a float can be effectively
569 // zero but not exactly zero.
570 if (!lyx::float_equal(params().rotateAngle, 0, 0.001) && params().rotate) {
571 options << " angle=" << params().rotateAngle << ",\n";
572 if (!params().rotateOrigin.empty()) {
573 options << " origin=" << params().rotateOrigin[0];
574 if (contains(params().rotateOrigin,"Top"))
576 else if (contains(params().rotateOrigin,"Bottom"))
578 else if (contains(params().rotateOrigin,"Baseline"))
583 if (!params().special.empty())
584 options << params().special << ",\n";
585 string opts = options.str().c_str();
586 return opts.substr(0,opts.size()-2); // delete last ",\n"
590 string findTargetFormat(string const & suffix)
592 // lyxrc.pdf_mode means:
593 // Are we creating a PDF or a PS file?
594 // (Should actually mean, are we using latex or pdflatex).
595 if (lyxrc.pdf_mode) {
596 lyxerr[Debug::GRAPHICS] << "findTargetFormat: PDF mode\n";
597 if (contains(suffix,"ps") || suffix == "pdf")
599 else if (suffix == "jpg") // pdflatex can use jpeg
602 return "png"; // and also png
604 // If it's postscript, we always do eps.
605 lyxerr[Debug::GRAPHICS] << "findTargetFormat: PostScript mode\n";
606 if (suffix != "ps") // any other than ps
607 return "eps"; // is changed to eps
609 return suffix; // let ps untouched
615 string const InsetGraphics::prepareFile(Buffer const *buf) const
617 // LaTeX can cope if the graphics file doesn't exist, so just return the
619 string const orig_file = params().filename;
620 string orig_file_with_path =
621 MakeAbsPath(orig_file, buf->filePath());
622 lyxerr[Debug::GRAPHICS] << "[InsetGraphics::prepareFile] orig_file = "
623 << orig_file << "\n\twith path: "
624 << orig_file_with_path << endl;
626 if (!IsFileReadable(orig_file_with_path))
629 // If the file is compressed and we have specified that it should not be
630 // uncompressed, then just return its name and let LaTeX do the rest!
632 // maybe that other zip extensions also be useful, especially the
633 // ones that may be declared in texmf/tex/latex/config/graphics.cfg.
635 /* -----------snip-------------
636 {\DeclareGraphicsRule{.pz}{eps}{.bb}{}%
637 \DeclareGraphicsRule{.eps.Z}{eps}{.eps.bb}{}%
638 \DeclareGraphicsRule{.ps.Z}{eps}{.ps.bb}{}%
639 \DeclareGraphicsRule{.ps.gz}{eps}{.ps.bb}{}%
640 \DeclareGraphicsRule{.eps.gz}{eps}{.eps.bb}{}}}%
641 -----------snip-------------*/
643 bool const zipped = zippedFile(orig_file_with_path);
645 lyxerr[Debug::GRAPHICS] << "\twe have a zipped file ("
646 << getExtFromContents(orig_file_with_path) << ")\n";
647 if (params().noUnzip && zipped) {
648 lyxerr[Debug::GRAPHICS]
649 << "\tpass file unzipped to LaTeX but with full path.\n";
650 // latex needs an absolue path, otherwise the coresponding
651 // *.eps.bb file isn't found
652 return orig_file_with_path;
655 string temp_file(orig_file);
656 // Uncompress the file if necessary. If it has been uncompressed in
657 // a previous call to prepareFile, do nothing.
659 temp_file = MakeAbsPath(OnlyFilename(temp_file), buf->tmppath);
660 lyxerr[Debug::GRAPHICS]
661 << "\ttemp_file: " << temp_file << endl;
662 if (!IsFileReadable(temp_file)) {
663 bool const success = lyx::copy(orig_file_with_path, temp_file);
664 lyxerr[Debug::GRAPHICS]
665 << "\tCopying zipped file from "
666 << orig_file_with_path << " to " << temp_file
667 << (success ? " succeeded\n" : " failed\n");
669 lyxerr[Debug::GRAPHICS]
670 << "\tzipped file " << temp_file
671 << " exists! Maybe no tempdir ...\n";
672 orig_file_with_path = unzipFile(temp_file);
673 lyxerr[Debug::GRAPHICS]
674 << "\tunzipped to " << orig_file_with_path << endl;
676 string const from = getExtFromContents(orig_file_with_path);
678 // "nice" means that the buffer is exported to LaTeX format but not
679 // run through the LaTeX compiler.
681 // no conversion needed!
682 // Return the original filename as is, because we do not know
683 // what the user decide.
687 // We're going to be running the exported buffer through the LaTeX
688 // compiler, so must ensure that LaTeX can cope with the graphics
691 // Perform all these manipulations on a temporary file if possible.
692 // If we are not using a temp dir, then temp_file contains the
694 // to allow files with the same name in different dirs
695 // we manipulate the original file "any.dir/file.ext"
696 // to "any_dir_file.ext"! changing the dots in the
697 // dirname is important for the use of ChangeExtension
698 lyxerr[Debug::GRAPHICS]
699 << "\tthe orig file is: " << orig_file_with_path << endl;
701 if (lyxrc.use_tempdir) {
702 string const ext_tmp = GetExtension(orig_file_with_path);
705 ChangeExtension(orig_file_with_path, string()), "/", "_");
706 // without dots and again with ext
707 temp_file = ChangeExtension(
708 subst(temp_file, ".", "_"), ext_tmp);
709 // now we have any_dir_file.ext
710 temp_file = MakeAbsPath(temp_file, buf->tmppath);
711 lyxerr[Debug::GRAPHICS]
712 << "\tchanged to: " << temp_file << endl;
714 // if the file doen't exists, copy it into the tempdi
715 if (!IsFileReadable(temp_file)) {
716 bool const success = lyx::copy(orig_file_with_path, temp_file);
717 lyxerr[Debug::GRAPHICS]
718 << "\tcopying from " << orig_file_with_path << " to "
720 << (success ? " succeeded\n" : " failed\n");
722 Alert::alert(_("Cannot copy file"), orig_file_with_path,
729 string const to = findTargetFormat(from);
730 lyxerr[Debug::GRAPHICS]
731 << "\t we have: from " << from << " to " << to << '\n';
733 // No conversion is needed. LaTeX can handle the graphic file as is.
734 // This is true even if the orig_file is compressed. We have to return
735 // the orig_file_with_path, maybe it is a zipped one
736 if (lyxrc.use_tempdir)
737 return RemoveExtension(temp_file);
738 return RemoveExtension(orig_file_with_path);
741 string const outfile_base = RemoveExtension(temp_file);
742 lyxerr[Debug::GRAPHICS]
743 << "\tThe original file is " << orig_file << "\n"
744 << "\tA copy has been made and convert is to be called with:\n"
745 << "\tfile to convert = " << temp_file << '\n'
746 << "\toutfile_base = " << outfile_base << '\n'
747 << "\t from " << from << " to " << to << '\n';
749 // if no special converter defined, than we take the default one
750 // from ImageMagic: convert from:inname.from to:outname.to
751 if (!converters.convert(buf, temp_file, outfile_base, from, to)) {
752 string const command =
754 from + ':' + temp_file + ' ' +
755 to + ':' + outfile_base + '.' + to;
756 lyxerr[Debug::GRAPHICS]
757 << "No converter defined! I use convert from ImageMagic:\n\t"
760 one.startscript(Systemcall::Wait, command);
761 if (!IsFileReadable(ChangeExtension(outfile_base, to)))
762 Alert::alert(_("Cannot convert Image (not existing file?)"),
763 _("No information for converting from ")
764 + from + _(" to ") + to);
767 return RemoveExtension(temp_file);
771 int InsetGraphics::latex(Buffer const *buf, ostream & os,
772 bool /*fragile*/, bool/*fs*/) const
774 // If there is no file specified or not existing,
775 // just output a message about it in the latex output.
776 lyxerr[Debug::GRAPHICS]
777 << "insetgraphics::latex: Filename = "
778 << params().filename << endl;
780 // A missing (e)ps-extension is no problem for LaTeX, so
781 // we have to test three different cases
782 string const file_(MakeAbsPath(params().filename, buf->filePath()));
783 bool const file_exists =
785 (IsFileReadable(file_) || // original
786 IsFileReadable(file_ + ".eps") || // original.eps
787 IsFileReadable(file_ + ".ps")); // original.ps
788 string const message = file_exists ?
789 string() : string("bb = 0 0 200 100, draft, type=eps]");
790 // if !message.empty() than there was no existing file
791 // "filename(.(e)ps)" found. In this case LaTeX
792 // draws only a rectangle with the above bb and the
793 // not found filename in it.
794 lyxerr[Debug::GRAPHICS]
795 << "\tMessage = \"" << message << '\"' << endl;
797 // These variables collect all the latex code that should be before and
798 // after the actual includegraphics command.
801 // Do we want subcaptions?
802 if (params().subcaption) {
803 before += "\\subfigure[" + params().subcaptionText + "]{";
806 // We never use the starred form, we use the "clip" option instead.
807 before += "\\includegraphics";
809 // Write the options if there are any.
810 string const opts = createLatexOptions();
811 lyxerr[Debug::GRAPHICS] << "\tOpts = " << opts << endl;
813 if (!opts.empty() && !message.empty())
814 before += ("[%\n" + opts + ',' + message);
815 else if (!message.empty())
816 before += ("[%\n" + message);
817 else if (!opts.empty())
818 before += ("[%\n" + opts + ']');
820 lyxerr[Debug::GRAPHICS]
821 << "\tBefore = " << before
822 << "\n\tafter = " << after << endl;
824 // Make the filename relative to the lyx file
825 // and remove the extension so the LaTeX will use whatever is
826 // appropriate (when there are several versions in different formats)
827 string const latex_str = message.empty() ?
828 (before + '{' + os::external_path(prepareFile(buf)) + '}' + after) :
829 (before + '{' + params().filename + " not found!}" + after);
832 // Return how many newlines we issued.
834 int(lyx::count(latex_str.begin(), latex_str.end(),'\n') + 1);
840 int InsetGraphics::ascii(Buffer const *, ostream & os, int) const
842 // No graphics in ascii output. Possible to use gifscii to convert
843 // images to ascii approximation.
844 // 1. Convert file to ascii using gifscii
845 // 2. Read ascii output file and add it to the output stream.
846 // at least we send the filename
847 os << '<' << _("Graphic file:") << params().filename << ">\n";
852 int InsetGraphics::linuxdoc(Buffer const *, ostream &) const
854 // No graphics in LinuxDoc output. Should check how/what to add.
859 // For explanation on inserting graphics into DocBook checkout:
860 // http://linuxdoc.org/LDP/LDP-Author-Guide/inserting-pictures.html
861 // See also the docbook guide at http://www.docbook.org/
862 int InsetGraphics::docbook(Buffer const *, ostream & os,
863 bool /*mixcont*/) const
865 // In DocBook v5.0, the graphic tag will be eliminated from DocBook, will
866 // need to switch to MediaObject. However, for now this is sufficient and
868 os << "<graphic fileref=\"&" << graphic_label << ";\">";
873 void InsetGraphics::validate(LaTeXFeatures & features) const
875 // If we have no image, we should not require anything.
876 if (params().filename.empty())
879 features.includeFile(graphic_label, RemoveExtension(params().filename));
881 features.require("graphicx");
883 if (params().subcaption)
884 features.require("subfigure");
888 void InsetGraphics::statusChanged()
890 current_view->updateInset(this, false);
894 bool InsetGraphics::setParams(InsetGraphicsParams const & p,
895 string const & filepath)
897 // If nothing is changed, just return and say so.
898 if (params() == p && !p.filename.empty()) {
902 // Copy the new parameters.
905 // Update the inset with the new parameters.
906 cache_->update(MakeAbsPath(params().filename, filepath));
908 // We have changed data, report it.
913 InsetGraphicsParams const & InsetGraphics::params() const
919 Inset * InsetGraphics::clone(Buffer const & buffer, bool same_id) const
921 return new InsetGraphics(*this, buffer.filePath(), same_id);