#include <config.h>
#include "insets/insetgraphics.h"
-#include "insets/renderers.h"
+#include "insets/render_graphic.h"
#include "buffer.h"
#include "BufferView.h"
#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/lyxalgo.h" // lyx::count
using lyx::support::getExtFromContents;
using lyx::support::IsFileReadable;
using lyx::support::LibFileSearch;
-using lyx::support::os;
using lyx::support::rtrim;
using lyx::support::Systemcall;
using lyx::support::unzipFile;
using lyx::support::unzippedFileName;
-using std::endl;
+namespace os = lyx::support::os;
+using std::endl;
+using std::string;
using std::auto_ptr;
using std::istringstream;
using std::ostream;
InsetGraphics::InsetGraphics()
: graphic_label(uniqueID()),
- graphic_(new GraphicRenderer)
+ graphic_(new RenderGraphic)
{
graphic_->connect(boost::bind(&InsetGraphics::statusChanged, this));
}
: 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());
}
-void InsetGraphics::statusChanged()
+void InsetGraphics::cache(BufferView * view) const
+{
+ BOOST_ASSERT(view);
+ view_ = view->owner()->view();
+}
+
+BufferView * InsetGraphics::view() const
+{
+ return view_.lock().get();
+}
+
+
+void InsetGraphics::statusChanged() const
{
- BufferView * bv = graphic_->view();
+ BufferView * bv = view();
if (bv)
bv->updateInset(this);
}
return DISPATCHED;
default:
- return InsetOld::localDispatch(cmd);
+ return UNDISPATCHED;
}
}
void InsetGraphics::draw(PainterInfo & pi, int x, int y) const
{
+ cache(pi.base.bv);
graphic_->draw(pi, x, y);
}
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);
}
if (in.empty())
return;
- istringstream data(STRCONV(in));
+ istringstream data(in);
LyXLex lex(0,0);
lex.setStream(data);
data << name_ << ' ';
params.Write(data, buffer.filePath());
data << "\\end_inset\n";
- return STRCONV(data.str());
+ return data.str();
}