]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insetgraphics.C
Prevent an assert when opening the citation dialog if the bibtex
[lyx.git] / src / insets / insetgraphics.C
index 4c3774fb52aec6c8822246543decdba4c6d2cfa5..4a025357c98d4cc4bec63d749f64de4341e6cff4 100644 (file)
@@ -64,11 +64,11 @@ TODO
 #include "funcrequest.h"
 #include "gettext.h"
 #include "LaTeXFeatures.h"
-#include "latexrunparams.h"
 #include "lyx_main.h"
 #include "lyxlex.h"
 #include "lyxrc.h"
 #include "metricsinfo.h"
+#include "outputparams.h"
 
 #include "frontends/Alert.h"
 #include "frontends/LyXView.h"
@@ -133,10 +133,10 @@ string const uniqueID()
 }
 
 
-string findTargetFormat(string const & suffix, LatexRunParams const & runparams)
+string findTargetFormat(string const & suffix, OutputParams const & runparams)
 {
        // Are we using latex or pdflatex).
-       if (runparams.flavor == LatexRunParams::PDFLATEX) {
+       if (runparams.flavor == OutputParams::PDFLATEX) {
                lyxerr[Debug::GRAPHICS] << "findTargetFormat: PDF mode" << endl;
                if (contains(suffix, "ps") || suffix == "pdf")
                        return "pdf";
@@ -201,26 +201,31 @@ InsetGraphics::priv_dispatch(FuncRequest const & cmd, idx_type &, pos_type &)
                InsetGraphicsMailer::string2params(cmd.argument, buffer, p);
                if (!p.filename.empty()) {
                        setParams(p);
-                       cmd.view()->updateInset(this);
+                       cmd.view()->update();
                }
-               return DispatchResult(DISPATCHED);
+               return DispatchResult(true, true);
        }
 
        case LFUN_INSET_DIALOG_UPDATE:
                InsetGraphicsMailer(*this).updateDialog(cmd.view());
-               return DispatchResult(DISPATCHED);
+               return DispatchResult(true, true);
 
-       case LFUN_INSET_EDIT:
        case LFUN_MOUSE_RELEASE:
                InsetGraphicsMailer(*this).showDialog(cmd.view());
-               return DispatchResult(DISPATCHED);
+               return DispatchResult(true, true);
 
        default:
-               return DispatchResult(UNDISPATCHED);
+               return DispatchResult(false);
        }
 }
 
 
+void InsetGraphics::edit(BufferView * bv, bool)
+{
+       InsetGraphicsMailer(*this).showDialog(bv);
+}
+
+
 void InsetGraphics::metrics(MetricsInfo & mi, Dimension & dim) const
 {
        graphic_->metrics(mi, dim);
@@ -230,6 +235,8 @@ void InsetGraphics::metrics(MetricsInfo & mi, Dimension & dim) const
 
 void InsetGraphics::draw(PainterInfo & pi, int x, int y) const
 {
+       xo_ = x;
+       yo_ = y;
        graphic_->draw(pi, x, y);
 }
 
@@ -411,7 +418,7 @@ string const stripExtensionIfPossible(string const & file, string const & to)
 
 
 string const InsetGraphics::prepareFile(Buffer const & buf,
-                                       LatexRunParams const & runparams) const
+                                       OutputParams const & runparams) const
 {
        string orig_file = params().filename.absFilename();
        string const rel_file = params().filename.relFilename(buf.filePath());
@@ -534,7 +541,7 @@ string const InsetGraphics::prepareFile(Buffer const & buf,
 
 
 int InsetGraphics::latex(Buffer const & buf, ostream & os,
-                        LatexRunParams const & runparams) const
+                        OutputParams const & runparams) const
 {
        // If there is no file specified or not existing,
        // just output a message about it in the latex output.
@@ -611,7 +618,8 @@ int InsetGraphics::latex(Buffer const & buf, ostream & os,
 }
 
 
-int InsetGraphics::ascii(Buffer const &, ostream & os, int) const
+int InsetGraphics::plaintext(Buffer const &, ostream & os,
+                        OutputParams const &) const
 {
        // No graphics in ascii output. Possible to use gifscii to convert
        // images to ascii approximation.
@@ -624,7 +632,8 @@ int InsetGraphics::ascii(Buffer const &, ostream & os, int) const
 }
 
 
-int InsetGraphics::linuxdoc(Buffer const & buf, ostream & os) const
+int InsetGraphics::linuxdoc(Buffer const & buf, ostream & os,
+                           OutputParams const &) const
 {
        string const file_name = buf.niceFile() ?
                                params().filename.relFilename(buf.filePath()):
@@ -640,7 +649,7 @@ int InsetGraphics::linuxdoc(Buffer const & buf, ostream & os) const
 // http://en.tldp.org/LDP/LDP-Author-Guide/inserting-pictures.html
 // See also the docbook guide at http://www.docbook.org/
 int InsetGraphics::docbook(Buffer const &, ostream & os,
-                          bool /*mixcont*/) const
+                          OutputParams const &) const
 {
        // In DocBook v5.0, the graphic tag will be eliminated from DocBook, will
        // need to switch to MediaObject. However, for now this is sufficient and