]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insetgraphics.C
Final touch 'inset display()'; fix 'is a bit silly' bug
[lyx.git] / src / insets / insetgraphics.C
index e7b69c6ae8d91562aa50e97b8dd4f75bb703f05f..754f6a6116edc743a726c6b4bcf6b0d6fbd4a846 100644 (file)
@@ -4,7 +4,7 @@
  * Licence details can be found in the file COPYING.
  *
  * \author Baruch Even
- * \author Herbert Voss
+ * \author Herbert Voß
  *
  * Full author contact details are available in file CREDITS.
  */
@@ -53,8 +53,7 @@ TODO
 #include <config.h>
 
 #include "insets/insetgraphics.h"
-#include "insets/insetgraphicsParams.h"
-#include "insets/renderers.h"
+#include "insets/render_graphic.h"
 
 #include "buffer.h"
 #include "BufferView.h"
@@ -65,16 +64,14 @@ TODO
 #include "gettext.h"
 #include "LaTeXFeatures.h"
 #include "latexrunparams.h"
-#include "Lsstream.h"
+#include "lyx_main.h"
 #include "lyxlex.h"
 #include "lyxrc.h"
-#include "paragraph_funcs.h"
-#include "lyxtext.h"
+#include "metricsinfo.h"
 
 #include "frontends/Alert.h"
-#include "frontends/Dialogs.h"
+#include "frontends/LyXView.h"
 
-#include "support/LAssert.h"
 #include "support/filetools.h"
 #include "support/lyxalgo.h" // lyx::count
 #include "support/lyxlib.h" // float_equal
@@ -85,16 +82,32 @@ TODO
 #include <boost/bind.hpp>
 #include <boost/tuple/tuple.hpp>
 
-#include <algorithm> // For the std::max
-
-// set by Exporters
+#include "support/std_sstream.h"
 
 namespace support = lyx::support;
-using namespace lyx::support;
+using lyx::support::AbsolutePath;
+using lyx::support::bformat;
+using lyx::support::ChangeExtension;
+using lyx::support::contains;
+using lyx::support::FileName;
+using lyx::support::float_equal;
+using lyx::support::GetExtension;
+using lyx::support::getExtFromContents;
+using lyx::support::IsFileReadable;
+using lyx::support::LibFileSearch;
+using lyx::support::rtrim;
+using lyx::support::Systemcall;
+using lyx::support::unzipFile;
+using lyx::support::unzippedFileName;
+
+namespace os = lyx::support::os;
 
-using std::ostream;
 using std::endl;
+using std::string;
 using std::auto_ptr;
+using std::istringstream;
+using std::ostream;
+using std::ostringstream;
 
 
 namespace {
@@ -142,7 +155,7 @@ string findTargetFormat(string const & suffix, LatexRunParams const & runparams)
 
 InsetGraphics::InsetGraphics()
        : graphic_label(uniqueID()),
-         graphic_(new GraphicRenderer)
+         graphic_(new RenderGraphic)
 {
        graphic_->connect(boost::bind(&InsetGraphics::statusChanged, this));
 }
@@ -152,7 +165,7 @@ InsetGraphics::InsetGraphics(InsetGraphics const & ig)
        : InsetOld(ig),
          boost::signals::trackable(),
          graphic_label(uniqueID()),
-         graphic_(new GraphicRenderer(*ig.graphic_))
+         graphic_(new RenderGraphic(*ig.graphic_))
 {
        graphic_->connect(boost::bind(&InsetGraphics::statusChanged, this));
        setParams(ig.params());
@@ -171,15 +184,14 @@ InsetGraphics::~InsetGraphics()
 }
 
 
-void InsetGraphics::statusChanged()
+void InsetGraphics::statusChanged() const
 {
-       BufferView * bv = graphic_->view();
-       if (bv)
-               bv->updateInset(this);
+       LyX::cref().updateInset(this);
 }
 
 
-dispatch_result InsetGraphics::localDispatch(FuncRequest const & cmd)
+dispatch_result
+InsetGraphics::priv_dispatch(FuncRequest const & cmd, idx_type &, pos_type &)
 {
        switch (cmd.action) {
        case LFUN_INSET_MODIFY: {
@@ -203,7 +215,7 @@ dispatch_result InsetGraphics::localDispatch(FuncRequest const & cmd)
                return DISPATCHED;
 
        default:
-               return InsetOld::localDispatch(cmd);
+               return UNDISPATCHED;
        }
 }
 
@@ -326,7 +338,7 @@ string const InsetGraphics::createLatexOptions() const
        if (!params().special.empty())
            options << params().special << ",\n";
 
-       string opts = STRCONV(options.str());
+       string opts = options.str();
        // delete last ",\n"
        return opts.substr(0, opts.size() - 2);
 }
@@ -347,7 +359,7 @@ copyToDirIfNeeded(string const & file_in, string const & dir)
 {
        using support::rtrim;
 
-       support::Assert(AbsolutePath(file_in));
+       BOOST_ASSERT(AbsolutePath(file_in));
 
        string const only_path = support::OnlyPath(file_in);
        if (rtrim(support::OnlyPath(file_in) , "/") == rtrim(dir, "/"))
@@ -363,7 +375,7 @@ copyToDirIfNeeded(string const & file_in, string const & dir)
                mangled = FileName(file_in).mangledFilename();
 
        string const file_out = support::MakeAbsPath(mangled, dir);
-       
+
        unsigned long const checksum_in  = support::sum(file_in);
        unsigned long const checksum_out = support::sum(file_out);
 
@@ -432,7 +444,7 @@ string const InsetGraphics::prepareFile(Buffer const & buf,
        if (zipped) {
                CopyStatus status;
                boost::tie(status, temp_file) =
-                       copyToDirIfNeeded(orig_file, buf.tmppath);
+                       copyToDirIfNeeded(orig_file, buf.temppath());
 
                if (status == FAILURE)
                        return orig_file;
@@ -444,7 +456,7 @@ string const InsetGraphics::prepareFile(Buffer const & buf,
                                << "\tunzipped to " << orig_file << endl;
                }
        }
-       
+
        string const from = getExtFromContents(orig_file);
        string const to   = findTargetFormat(from, runparams);
        lyxerr[Debug::GRAPHICS]
@@ -464,7 +476,7 @@ string const InsetGraphics::prepareFile(Buffer const & buf,
        if (lyxrc.use_tempdir) {
                CopyStatus status;
                boost::tie(status, temp_file) =
-                       copyToDirIfNeeded(orig_file, buf.tmppath);
+                       copyToDirIfNeeded(orig_file, buf.temppath());
 
                if (status == FAILURE)
                        return orig_file;
@@ -613,7 +625,7 @@ int InsetGraphics::ascii(Buffer const &, ostream & os, int) const
 
 int InsetGraphics::linuxdoc(Buffer const & buf, ostream & os) const
 {
-       string const file_name = buf.niceFile ?
+       string const file_name = buf.niceFile() ?
                                params().filename.relFilename(buf.filePath()):
                                params().filename.absFilename();
 
@@ -698,7 +710,7 @@ void InsetGraphicsMailer::string2params(string const & in,
        if (in.empty())
                return;
 
-       istringstream data(STRCONV(in));
+       istringstream data(in);
        LyXLex lex(0,0);
        lex.setStream(data);
 
@@ -725,5 +737,5 @@ InsetGraphicsMailer::params2string(InsetGraphicsParams const & params,
        data << name_ << ' ';
        params.Write(data, buffer.filePath());
        data << "\\end_inset\n";
-       return STRCONV(data.str());
+       return data.str();
 }