]> git.lyx.org Git - lyx.git/commitdiff
Minimise the use of the BufferView cache. The only things left using it
authorAngus Leeming <leeming@lyx.org>
Sun, 12 Oct 2003 18:54:12 +0000 (18:54 +0000)
committerAngus Leeming <leeming@lyx.org>
Sun, 12 Oct 2003 18:54:12 +0000 (18:54 +0000)
are InsetFormula, InsetExternal, InsetGraphic and InsetInclude that all
need to inform the BufferView of their changed status when the graphic
is loaded.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7897 a592a061-630c-0410-9148-cb99ea01b6c8

26 files changed:
src/insets/ChangeLog
src/insets/Makefile.am
src/insets/inset.h
src/insets/insetbase.h
src/insets/insetcollapsable.C
src/insets/insetcollapsable.h
src/insets/insetcommand.C
src/insets/insetcommand.h
src/insets/insetexternal.C
src/insets/insetexternal.h
src/insets/insetgraphics.C
src/insets/insetgraphics.h
src/insets/insetinclude.C
src/insets/insetinclude.h
src/insets/insetlabel.C
src/insets/insetlabel.h
src/insets/render_base.C [deleted file]
src/insets/render_base.h
src/insets/render_button.C
src/insets/render_graphic.C
src/mathed/ChangeLog
src/mathed/formula.C
src/mathed/formulabase.C
src/mathed/formulabase.h
src/mathed/math_inset.C
src/mathed/math_inset.h

index 38579700720e714b9e34089f63f2745d28a43c38..761f360f582b5014a2e6d0d2a11228635d6ba6de 100644 (file)
@@ -1,3 +1,29 @@
+2003-10-12  Angus Leeming  <leeming@lyx.org>
+
+       * renderbase.h (view, view_): removed.
+       * renderbase.C: removed.
+       * Makefile.am: remove render_base.C. The shortest lived file in history?
+
+       * renderbutton.C (draw):
+       * render_graphic.C (draw): don't cache the BufferView.
+
+       * insetabase.h (cache, view): removed.
+
+       * inset.h (generatePreview) removed.
+
+       * insetcallapsable.[Ch] (cache, view, view_): removed.
+
+       * insetcollapsable.C (draw): don't cache the BufferView.
+
+       * insetcommand.[Ch] (view): removed.
+
+       * insetexternal.[Ch] (cache, view, view_):
+       * insetgraphics.[Ch] (cache, view, view_):
+       * insetinclude.[Ch] (cache, view, view_): added. Cache the BufferView.
+
+       * insetlabel.C: small clean-up. Don't use the BufferView cache, view(),
+       when you have direct access to it. In fact, don't use the cache at all.
+
 2003-10-10  Angus Leeming  <leeming@lyx.org>
 
        * insetinclude.C (metrics): use preview_->metrics.
@@ -43,7 +69,7 @@
 
        * insetinclude.[Ch]: mods to PreviewImpl due to the changes to
        PreviewedInset.
-       
+
 2003-10-09  Angus Leeming  <leeming@lyx.org>
 
        * insetinclude.C (metrics, draw, restartLoading): pass a buffer arg
index 7c8ea08619d2403f1d53ea9676eae4199a176190..48a5776bbe14563752c57f60894f27e652d75f84 100644 (file)
@@ -19,7 +19,6 @@ libinsets_la_SOURCES = \
        ExternalTemplate.h \
        ExternalTransforms.C \
        ExternalTransforms.h \
-       render_base.C \
        render_base.h \
        render_button.C \
        render_button.h \
index bc653185ea22a6c0032e6adb0a68f51db7aeb230..cad92c891f3910f48b1d790dcd98e79e5aae1e3e 100644 (file)
@@ -300,15 +300,6 @@ public:
         *  defaults to empty.
         */
        virtual void addPreview(lyx::graphics::PreviewLoader &) const {}
-
-       /** Find the PreviewLoader, add a LaTeX snippet to it and
-        *  start the loading process.
-        *
-        *  Most insets have no interest in this capability, so the method
-        *  defaults to empty.
-        */
-       virtual void generatePreview(Buffer const &) const {}
-
 protected:
        ///
        mutable int top_x;
index b771a11da7cd0ecda72f6d1d85ba2e6333fb54fa..f261618f9b2888024269bfd5c34ead4624e09182 100644 (file)
@@ -95,10 +95,6 @@ public:
        /// draw inset and update (xo, yo)-cache
        virtual void draw(PainterInfo & pi, int x, int y) const = 0;
 
-       /// Methods to cache and retrieve a cached BufferView.
-       virtual void cache(BufferView *) const {}
-       ///
-       virtual BufferView * view() const { return 0; }
        /// request "external features"
        virtual void validate(LaTeXFeatures &) const {}
        /// Appends \c list with all labels found within this inset.
index 5b6e09acf712beca2a3d3de94e886b8eba8230e6..59c66883b2fb417540838485cd1e6c3798e20f66 100644 (file)
@@ -138,9 +138,6 @@ void InsetCollapsable::draw_collapsed(PainterInfo & pi, int x, int y) const
 
 void InsetCollapsable::draw(PainterInfo & pi, int x, int y, bool inlined) const
 {
-       BOOST_ASSERT(pi.base.bv);
-       cache(pi.base.bv);
-
        Dimension dim_collapsed;
        dimension_collapsed(dim_collapsed);
 
@@ -562,15 +559,3 @@ void InsetCollapsable::addPreview(PreviewLoader & loader) const
 {
        inset.addPreview(loader);
 }
-
-
-void InsetCollapsable::cache(BufferView * bv) const
-{
-       view_ = bv->owner()->view();
-}
-
-
-BufferView * InsetCollapsable::view() const
-{
-       return view_.lock().get();
-}
index 859e78866fc82fc62379b610b6f211bfd4bc8685..e455544895910e18165fef4065715d4c45ab5582 100644 (file)
@@ -20,8 +20,6 @@
 #include "box.h"
 #include "lyxfont.h"
 
-#include <boost/weak_ptr.hpp>
-
 class Painter;
 class LyXText;
 class Paragraph;
@@ -149,11 +147,6 @@ public:
        void addPreview(lyx::graphics::PreviewLoader &) const;
 
 protected:
-       ///
-       virtual void cache(BufferView *) const;
-       ///
-       virtual BufferView * view() const;
-
        ///
        void dimension_collapsed(Dimension &) const;
        ///
@@ -197,8 +190,6 @@ private:
        bool in_update;
        ///
        mutable bool first_after_edit;
-       ///
-       mutable boost::weak_ptr<BufferView> view_;
 };
 
 
index acc2033c2c29baa1d54c2d2a7d0cee2d42a19862..b39930f7e3b067998d229d5125051da90f65e227 100644 (file)
@@ -33,12 +33,6 @@ InsetCommand::InsetCommand(InsetCommandParams const & p)
 {}
 
 
-BufferView * InsetCommand::view() const
-{
-       return button_.view();
-}
-
-
 void InsetCommand::metrics(MetricsInfo & mi, Dimension & dim) const
 {
        if (!set_label_) {
index 992a1df3083eb74be4c3e0c5cbc271d8e9c37a0d..32129d039b0d7300e96acdca6ea8fdc786651154 100644 (file)
@@ -80,8 +80,6 @@ protected:
        void setOptions(std::string const & o) { p_.setOptions(o); }
        ///
        void setParams(InsetCommandParams const &);
-       ///
-       virtual BufferView * view() const;
        /// This should provide the text for the button
        virtual std::string const getScreenLabel(Buffer const &) const = 0;
 
index 7d41bb29b2007c621602a41e56403b0334dce1b9..2fb0b6b2d44a482f5267ff06e6656edaa97f2a41 100644 (file)
 #include "latexrunparams.h"
 #include "lyxlex.h"
 #include "lyxrc.h"
+#include "metricsinfo.h"
 
 #include "frontends/lyx_gui.h"
+#include "frontends/LyXView.h"
 
 #include "support/lstrings.h"
 #include "support/lyxlib.h"
@@ -388,9 +390,21 @@ InsetExternal::~InsetExternal()
 }
 
 
+void InsetExternal::cache(BufferView * view) const
+{
+       BOOST_ASSERT(view);
+       view_ = view->owner()->view();
+}
+
+BufferView * InsetExternal::view() const
+{
+       return view_.lock().get();
+}
+
+
 void InsetExternal::statusChanged() const
 {
-       BufferView * const bv = renderer_->view();
+       BufferView * const bv = view();
        if (bv)
                bv->updateInset(this);
 }
@@ -445,6 +459,7 @@ void InsetExternal::metrics(MetricsInfo & mi, Dimension & dim) const
 
 void InsetExternal::draw(PainterInfo & pi, int x, int y) const
 {
+       cache(pi.base.bv);
        renderer_->draw(pi, x, y);
 }
 
index 93d0e678c075fffde003f5a689a184c063b3aff8..31d2b9ae330af3627a17f2271c17ea74277980cc 100644 (file)
@@ -21,6 +21,7 @@
 
 #include <boost/scoped_ptr.hpp>
 #include <boost/signals/trackable.hpp>
+#include <boost/weak_ptr.hpp>
 
 
 /** No two InsetExternalParams variables can have the same temporary file.
@@ -128,6 +129,8 @@ public:
        void setParams(InsetExternalParams const &, Buffer const &);
 
 private:
+       void cache(BufferView *) const;
+       BufferView * view() const;
        /** This method is connected to the graphics loader, so we are
         *  informed when the image has been loaded.
         */
@@ -137,6 +140,9 @@ private:
        InsetExternalParams params_;
        /// The thing that actually draws the image on LyX's screen.
        boost::scoped_ptr<RenderBase> renderer_;
+
+       /// Cached
+       mutable boost::weak_ptr<BufferView> view_;
 };
 
 
index f3c3493c264fda958bd4beff04abe234fe2287fa..6cc2a3415d3a4ee213d0d407de77b70c6b6c360a 100644 (file)
@@ -66,8 +66,10 @@ 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/lyxalgo.h" // lyx::count
@@ -181,9 +183,21 @@ InsetGraphics::~InsetGraphics()
 }
 
 
+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);
 }
@@ -227,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);
 }
 
index c9e1887cebfc70b2ddd69d921a08a0ddac5938b7..2ac1afc35b75fe2fe44f4cfa5b2631b61d867cef 100644 (file)
@@ -18,6 +18,7 @@
 
 #include <boost/scoped_ptr.hpp>
 #include <boost/signals/trackable.hpp>
+#include <boost/weak_ptr.hpp>
 
 
 class Dialogs;
@@ -38,8 +39,6 @@ public:
        ///
        void metrics(MetricsInfo &, Dimension &) const;
        ///
-       void draw(PainterInfo & pi, int x, int y) const;
-       ///
        EDITABLE editable() const;
        ///
        void write(Buffer const &, std::ostream &) const;
@@ -77,11 +76,16 @@ public:
 
        /// Get the inset parameters, used by the GUIndependent dialog.
        InsetGraphicsParams const & params() const;
+       ///
+       void draw(PainterInfo & pi, int x, int y) const;
 
 private:
        ///
        friend class InsetGraphicsMailer;
 
+       void cache(BufferView *) const;
+       BufferView * view() const;
+
        /** This method is connected to the graphics loader, so we are
         *  informed when the image has been loaded.
         */
@@ -105,6 +109,9 @@ private:
 
        /// The thing that actually draws the image on LyX's screen.
        boost::scoped_ptr<RenderGraphic> const graphic_;
+
+       /// Cached
+       mutable boost::weak_ptr<BufferView> view_;
 };
 
 
index 3dea3f35859e6305444d38e5715bb6ed4dd0a4b6..5d4dee35bb03da97a94d282438a3e34142fc5514 100644 (file)
@@ -25,6 +25,7 @@
 #include "lyxlex.h"
 #include "metricsinfo.h"
 
+#include "frontends/LyXView.h"
 #include "frontends/Painter.h"
 
 #include "graphics/PreviewImage.h"
@@ -557,9 +558,15 @@ void InsetInclude::draw(PainterInfo & pi, int x, int y) const
 }
 
 
+void InsetInclude::cache(BufferView * view) const
+{
+       BOOST_ASSERT(view);
+       view_ = view->owner()->view();
+}
+
 BufferView * InsetInclude::view() const
 {
-       return button_.view();
+       return view_.lock().get();
 }
 
 
index 96256d2026c57b9de37c93af2d521857b99a781c..9fda837950f9518eb284da4648b61f7e719a6882 100644 (file)
@@ -16,6 +16,7 @@
 #include "insetcommandparams.h"
 #include "render_button.h"
 #include <boost/scoped_ptr.hpp>
+#include <boost/weak_ptr.hpp>
 
 
 class Buffer;
@@ -42,8 +43,6 @@ public:
        void metrics(MetricsInfo & mi, Dimension & dim) const;
        ///
        void draw(PainterInfo & pi, int x, int y) const;
-       ///
-       virtual BufferView * view() const;
 
        /// get the parameters
        InsetCommandParams const & params(void) const;
@@ -83,6 +82,9 @@ public:
        void addPreview(lyx::graphics::PreviewLoader &) const;
 
 private:
+       void cache(BufferView *) const;
+       BufferView * view() const;
+
        /// Slot receiving a signal that the preview is ready to display.
        void statusChanged() const;
        /** Slot receiving a signal that the external file has changed
@@ -90,7 +92,6 @@ private:
         */
        void fileChanged() const;
 
-       
        friend class InsetIncludeMailer;
 
        /// set the parameters
@@ -111,6 +112,7 @@ private:
        boost::scoped_ptr<RenderMonitoredPreview> const preview_;
 
        /// cache
+       mutable boost::weak_ptr<BufferView> view_;
        mutable bool set_label_;
        mutable RenderButton button_;
 };
index a310f30d83d2fb6bfbac128e4f133939f61c1f29..ac056649d781e79c458a62d6fc7e3d19bbf6955b 100644 (file)
@@ -15,6 +15,8 @@
 #include "BufferView.h"
 #include "funcrequest.h"
 
+#include "frontends/LyXView.h"
+
 #include "support/lstrings.h"
 
 #include "support/std_ostream.h"
@@ -36,18 +38,33 @@ InsetLabel::~InsetLabel()
 }
 
 
+std::auto_ptr<InsetBase> InsetLabel::clone() const
+{
+       return std::auto_ptr<InsetBase>(new InsetLabel(params()));
+}
+
+
 void InsetLabel::getLabelList(Buffer const &, std::vector<string> & list) const
 {
        list.push_back(getContents());
 }
 
 
+string const InsetLabel::getScreenLabel(Buffer const &) const
+{
+       return getContents();
+}
+
+
 dispatch_result InsetLabel::localDispatch(FuncRequest const & cmd)
 {
+       BOOST_ASSERT(cmd.view());
+       BufferView * const bv = cmd.view();
+
        switch (cmd.action) {
 
        case LFUN_INSET_EDIT:
-               InsetCommandMailer("label", *this).showDialog(cmd.view());
+               InsetCommandMailer("label", *this).showDialog(bv);
                return DISPATCHED;
                break;
 
@@ -58,13 +75,13 @@ dispatch_result InsetLabel::localDispatch(FuncRequest const & cmd)
                        return UNDISPATCHED;
 
                bool clean = true;
-               if (view() && p.getContents() != params().getContents()) {
-                       clean = view()->ChangeRefsIfUnique(params().getContents(),
-                                                          p.getContents());
+               if (bv && p.getContents() != params().getContents()) {
+                       clean = bv->ChangeRefsIfUnique(params().getContents(),
+                                                      p.getContents());
                }
 
                setParams(p);
-               cmd.view()->updateInset(this);
+               bv->updateInset(this);
                return DISPATCHED;
        }
 
index 2fe34f0b1f1487aa362ec4feec499590e572d0da..c9db1eea302c6ef34df34707cc0932a3d5feb22e 100644 (file)
@@ -14,6 +14,7 @@
 
 
 #include "insetcommand.h"
+#include <boost/weak_ptr.hpp>
 
 class InsetLabel : public InsetCommand {
 public:
@@ -22,13 +23,11 @@ public:
        ///
        ~InsetLabel();
        ///
-       virtual std::auto_ptr<InsetBase> clone() const {
-               return std::auto_ptr<InsetBase>(new InsetLabel(params()));
-       }
+       std::auto_ptr<InsetBase> clone() const;
        ///
        virtual dispatch_result localDispatch(FuncRequest const & cmd);
        ///
-       std::string const getScreenLabel(Buffer const &) const { return getContents(); }
+       std::string const getScreenLabel(Buffer const &) const;
        ///
        EDITABLE editable() const { return IS_EDITABLE; }
        ///
diff --git a/src/insets/render_base.C b/src/insets/render_base.C
deleted file mode 100644 (file)
index 1f3ea2c..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-/**
- * \file render_base.C
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Angus Leeming
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "render_base.h"
-
-#include "BufferView.h"
-
-
-BufferView * RenderBase::view() const
-{
-       return view_.lock().get();
-}
index 2fbb97775a49c09dab4161aaa977e42bbc21e970..20285f5fd8c5c6d8b3da2555cc91ce3b38f0b6c9 100644 (file)
@@ -14,9 +14,6 @@
 
 #include "dimension.h"
 
-#include <boost/weak_ptr.hpp>
-
-class BufferView;
 class MetricsInfo;
 class PainterInfo;
 
@@ -32,16 +29,12 @@ public:
        /// draw inset and update (xo, yo)-cache
        virtual void draw(PainterInfo & pi, int x, int y) const = 0;
 
-       /// An accessor function to the cached store.
-       BufferView * view() const;
-
 protected:
        RenderBase() {}
        RenderBase(RenderBase const &) {}
        void operator=(RenderBase const &) {}
 
-       /// These are cached variables (are not copied).
-       mutable boost::weak_ptr<BufferView> view_;
+       /// Cached
        mutable Dimension dim_;
 };
 
index fd794b02d5653d9b1f2612c67033685d0d691806..3200ac5b8651ea4e3c288fd124d7099752117921 100644 (file)
 
 #include "render_button.h"
 
-#include "BufferView.h"
 #include "LColor.h"
 #include "metricsinfo.h"
 
 #include "frontends/font_metrics.h"
-#include "frontends/LyXView.h"
 #include "frontends/Painter.h"
 
 using std::string;
@@ -57,9 +55,6 @@ void RenderButton::metrics(MetricsInfo &, Dimension & dim) const
 
 void RenderButton::draw(PainterInfo & pi, int x, int y) const
 {
-       BOOST_ASSERT(pi.base.bv);
-       view_ = pi.base.bv->owner()->view();
-
        // Draw it as a box with the LaTeX text
        LyXFont font(LyXFont::ALL_SANE);
        font.setColor(LColor::command);
index cab82d915fe9dbf54a6cfa1ee09617a59052fbd6..52186bc9f4c78c28bb508d72fb38e89359059ee2 100644 (file)
 
 #include "insets/inset.h"
 
-#include "BufferView.h"
 #include "gettext.h"
 #include "LColor.h"
 #include "metricsinfo.h"
 
 #include "frontends/font_metrics.h"
-#include "frontends/LyXView.h"
 #include "frontends/Painter.h"
 
 #include "graphics/GraphicsImage.h"
@@ -156,9 +154,6 @@ void RenderGraphic::metrics(MetricsInfo & mi, Dimension & dim) const
 
 void RenderGraphic::draw(PainterInfo & pi, int x, int y) const
 {
-       BOOST_ASSERT(pi.base.bv);
-       view_ = pi.base.bv->owner()->view();
-
        if (params_.display != lyx::graphics::NoDisplay &&
            loader_.status() == lyx::graphics::WaitingToLoad)
                loader_.startLoading();
index 0d7ced68c9bc84259e42c2c9315101b8dc1b89dc..c182932080dac48ff6c1e3b2c44d80e2d2563864 100644 (file)
@@ -1,3 +1,12 @@
+2003-10-12  Angus Leeming  <leeming@lyx.org>
+
+       * formulabase.[Ch] (cache): added.
+       (view): make protected.
+       (view_): store as a boost::weak_ptr.
+       (generatePreview): added this virtual function. Moved from inset.h.
+
+       * math_inset.[Ch] (view): removed.
+
 2003-10-10  Angus Leeming  <leeming@lyx.org>
 
        * command_inset.h:trivial changes ButtonRenderer -> RenderButton.
index 798f1695a251f744c3391769eaea82f0b5c5f4cf..cd977f24358fe82ba792818f53c69d86befb2c34 100644 (file)
@@ -180,9 +180,7 @@ void InsetFormula::read(Buffer const &, LyXLex & lex)
 
 void InsetFormula::draw(PainterInfo & pi, int x, int y) const
 {
-       BOOST_ASSERT(pi.base.bv);
-       BufferView * bv = pi.base.bv;
-       cache(bv);
+       cache(pi.base.bv);
 
        // The previews are drawn only when we're not editing the inset.
        bool const editing_inset = mathcursor && mathcursor->formula() == this;
@@ -197,7 +195,7 @@ void InsetFormula::draw(PainterInfo & pi, int x, int y) const
                // one pixel gap in front
                preview_->draw(pi, x + 1, y);
        } else {
-               PainterInfo p(bv);
+               PainterInfo p(pi.base.bv);
                p.base.style = LM_ST_TEXT;
                p.base.font  = pi.base.font;
                p.base.font.setColor(LColor::math);
@@ -248,9 +246,6 @@ bool InsetFormula::insetAllowed(InsetOld::Code code) const
 
 void InsetFormula::metrics(MetricsInfo & m, Dimension & dim) const
 {
-       BOOST_ASSERT(m.base.bv);
-       view_ = m.base.bv;
-
        bool const editing_inset = mathcursor && mathcursor->formula() == this;
        bool const use_preview = !editing_inset && preview_->previewReady();
 
index c03799c3a594aef4da8b1791a21ae0a7326e2ba4..ffdd3e4726b084c9710afac07bd6a58883fb9847 100644 (file)
@@ -75,7 +75,7 @@ bool openNewInset(BufferView * bv, UpdatableInset * new_inset)
 
 
 InsetFormulaBase::InsetFormulaBase()
-       : view_(0), xo_(0), yo_(0)
+       : xo_(0), yo_(0)
 {
        // This is needed as long the math parser is not re-entrant
        initMath();
@@ -139,9 +139,15 @@ void InsetFormulaBase::handleFont2(BufferView * bv, string const & arg)
 
 
 
+void InsetFormulaBase::cache(BufferView * view) const
+{
+       BOOST_ASSERT(view);
+       view_ = view->owner()->view();
+}
+
 BufferView * InsetFormulaBase::view() const
 {
-       return view_;
+       return view_.lock().get();
 }
 
 
index 6c3d8dc269d3bb7bc5d2753627d2319317361fd1..c00a9a4da0b7380c4449cfc1fbfaaa44c8a7d9f2 100644 (file)
@@ -15,6 +15,7 @@
 #define INSET_FORMULABASE_H
 
 #include "insets/updatableinset.h"
+#include <boost/weak_ptr.hpp>
 
 
 class Buffer;
@@ -66,9 +67,6 @@ public:
        ///
        virtual MathAtom & par() = 0;
        ///
-       // And shouldn't this really return a shared_ptr<BufferView> instead?
-       BufferView * view() const;
-
        ///
        virtual bool searchForward(BufferView *, std::string const &,
                                   bool = true, bool = false);
@@ -101,11 +99,19 @@ private:
        dispatch_result lfunMouseMotion(FuncRequest const &);
 
 protected:
-       ///
-       //mutable boost::weak_ptr<BufferView> view_;
-       mutable BufferView * view_;
+       void cache(BufferView *) const;
+       BufferView * view() const;
 
 protected:
+
+       /** Find the PreviewLoader, add a LaTeX snippet to it and
+        *  start the loading process.
+        *
+        *  Most insets have no interest in this capability, so the method
+        *  defaults to empty.
+        */
+       virtual void generatePreview(Buffer const &) const {}
+
        ///
        void handleFont(BufferView * bv, std::string const & arg, std::string const & font);
        ///
@@ -115,6 +121,9 @@ protected:
        mutable int xo_;
        ///
        mutable int yo_;
+private:
+       // Cache
+       mutable boost::weak_ptr<BufferView> view_;
 };
 
 // We don't really mess want around with mathed stuff outside mathed.
index f52a6edd7bd00ddd0797df3e3cb8c45e478404b2..bf181510c91285614edfb35b1fa567ba91b1c0ac 100644 (file)
 #include <config.h>
 
 #include "math_inset.h"
+#include "math_data.h"
 #include "math_mathmlstream.h"
-#include "math_cursor.h"
 #include "debug.h"
 
-#include "formulabase.h"
-
-
 using std::string;
 using std::ostream;
 using std::endl;
 
 
-BufferView * MathInset::view() const
-{
-       return mathcursor ? mathcursor->formula()->view() : 0;
-}
-
-
 MathInset::size_type MathInset::nargs() const
 {
        return 0;
index 981a5e5b1afafc052c84608ac0fb440e89b90971..e9aaa63bda7cdaf870ac558d2071816b187651fc 100644 (file)
@@ -256,10 +256,6 @@ public:
        virtual std::string fileInsetLabel() const;
        /// usually the latex name
        virtual std::string name() const;
-
-protected:
-       /// a dirty hack
-       BufferView * view() const;
 };
 
 std::ostream & operator<<(std::ostream &, MathAtom const &);