]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insetgraphics.C
ws changes only
[lyx.git] / src / insets / insetgraphics.C
index 2cf6305551d4df8f20c36e84d0672fefbe5e0bd6..43128342690f21076c3a5ac11d9cf0ae9afff393 100644 (file)
@@ -53,7 +53,7 @@ TODO
 #include <config.h>
 
 #include "insets/insetgraphics.h"
-#include "insets/renderers.h"
+#include "insets/render_graphic.h"
 
 #include "buffer.h"
 #include "BufferView.h"
@@ -66,11 +66,12 @@ TODO
 #include "latexrunparams.h"
 #include "lyxlex.h"
 #include "lyxrc.h"
+#include "metricsinfo.h"
 
 #include "frontends/Alert.h"
+#include "frontends/LyXView.h"
 
 #include "support/filetools.h"
-#include "support/LAssert.h"
 #include "support/lyxalgo.h" // lyx::count
 #include "support/lyxlib.h" // float_equal
 #include "support/os.h"
@@ -83,9 +84,25 @@ TODO
 #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::endl;
+using std::string;
 using std::auto_ptr;
 using std::istringstream;
 using std::ostream;
@@ -137,7 +154,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));
 }
@@ -147,7 +164,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());
@@ -166,9 +183,21 @@ InsetGraphics::~InsetGraphics()
 }
 
 
-void InsetGraphics::statusChanged()
+void InsetGraphics::cache(BufferView * view) const
 {
-       BufferView * bv = graphic_->view();
+       BOOST_ASSERT(view);
+       view_ = view->owner()->view();
+}
+
+BufferView * InsetGraphics::view() const
+{
+       return view_.lock().get();
+}
+
+
+void InsetGraphics::statusChanged() const
+{
+       BufferView * bv = view();
        if (bv)
                bv->updateInset(this);
 }
@@ -198,7 +227,7 @@ dispatch_result InsetGraphics::localDispatch(FuncRequest const & cmd)
                return DISPATCHED;
 
        default:
-               return InsetOld::localDispatch(cmd);
+               return UNDISPATCHED;
        }
 }
 
@@ -212,6 +241,7 @@ void InsetGraphics::metrics(MetricsInfo & mi, Dimension & dim) const
 
 void InsetGraphics::draw(PainterInfo & pi, int x, int y) const
 {
+       cache(pi.base.bv);
        graphic_->draw(pi, x, y);
 }
 
@@ -321,7 +351,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);
 }
@@ -342,7 +372,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, "/"))
@@ -358,7 +388,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);
 
@@ -439,7 +469,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]
@@ -693,7 +723,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);
 
@@ -720,5 +750,5 @@ InsetGraphicsMailer::params2string(InsetGraphicsParams const & params,
        data << name_ << ' ';
        params.Write(data, buffer.filePath());
        data << "\\end_inset\n";
-       return STRCONV(data.str());
+       return data.str();
 }