]> git.lyx.org Git - features.git/commitdiff
Small clean-up of the PreviewedInset interface.
authorAngus Leeming <leeming@lyx.org>
Tue, 16 Sep 2003 15:43:00 +0000 (15:43 +0000)
committerAngus Leeming <leeming@lyx.org>
Tue, 16 Sep 2003 15:43:00 +0000 (15:43 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7778 a592a061-630c-0410-9148-cb99ea01b6c8

src/graphics/ChangeLog
src/graphics/PreviewedInset.C
src/graphics/PreviewedInset.h
src/insets/ChangeLog
src/insets/insetinclude.C
src/mathed/ChangeLog
src/mathed/formula.C

index ca84c77669059aaa1441ccac11ade4ab638e90d1..b65440d09b8c97d0df070eee0ea715d6ac491128 100644 (file)
@@ -1,3 +1,9 @@
+2003-09-16  Angus Leeming  <leeming@lyx.org>
+
+       * PreviewedInset.[Ch] (c-tor) move out of line.
+       (d-tor): make private.
+       (inset): return a const reference rather than a non-const pointer.
+
 2003-09-16  Angus Leeming  <leeming@lyx.org>
 
        * GraphicsImage.h: separate interface from implementation. Make all the
index a6447602475e8567273d909228ade224962942c3..85e4c95c31c9f0351f5f80a5d1e2e3e40a55e870 100644 (file)
@@ -35,6 +35,11 @@ bool PreviewedInset::activated()
 }
 
 
+PreviewedInset::PreviewedInset(InsetOld & inset)
+       : inset_(inset), pimage_(0)
+{}
+
+
 BufferView * PreviewedInset::view() const
 {
        return inset_.view();
@@ -121,7 +126,7 @@ void PreviewedInset::imageReady(PreviewImage const & pimage) const
        pimage_ = &pimage;
 
        if (view())
-               view()->updateInset(inset());
+               view()->updateInset(&inset());
 }
 
 } // namespace graphics
index 31c6691faa607a85b33fd68733e35fc1b3e654cd..33c46eae14c72e399e5e45996169f2427f4965d5 100644 (file)
@@ -9,7 +9,7 @@
  * Full author contact details are available in file CREDITS.
  *
  * lyx::graphics::PreviewedInset is an abstract base class that can help
- * insets to generate previews. The daughter class must instantiate three small
+ * insets to generate previews. The daughter class must instantiate two small
  * methods. The Inset would own an instance of this daughter class.
  */
 
@@ -35,9 +35,7 @@ public:
        static bool activated();
 
        ///
-       PreviewedInset(InsetOld & inset) : inset_(inset), pimage_(0) {}
-       ///
-       virtual ~PreviewedInset() {}
+       PreviewedInset(InsetOld & inset);
 
        /** Find the PreviewLoader, add a LaTeX snippet to it and
         *  start the loading process.
@@ -58,11 +56,13 @@ public:
        bool previewReady() const;
 
        /// If !previewReady() returns 0.
-       PreviewImage const * pimage() const { return pimage_; }
+       PreviewImage const * pimage() const;
 
 protected:
+       ///
+       virtual ~PreviewedInset() {}
        /// Allow the daughter classes to cast up to the parent inset.
-       InsetOld * inset() const { return &inset_; }
+       InsetOld const & inset() const;
        ///
        BufferView * view() const;
 
@@ -86,6 +86,20 @@ private:
        boost::signals::connection connection_;
 };
 
+
+inline
+PreviewImage const * PreviewedInset::pimage() const
+{
+       return pimage_;
+}
+
+
+inline
+InsetOld const & PreviewedInset::inset() const
+{
+       return inset_;
+}
+
 } // namespace graphics
 } // namespace lyx
 
index 3261834a19a2caeb4e1f0996f5353fb7a42a47a5..32a1d5c6ac5cd36247cbc115a3948cf75cd9e126 100644 (file)
@@ -1,3 +1,7 @@
+2003-09-16  Angus Leeming  <leeming@lyx.org>
+
+       * insetinclude.C (PreviewImpl::parent): return a const reference.
+
 2003-09-16  Angus Leeming  <leeming@lyx.org>
 
        * insetcollapsable.[Ch]: make all member variables, except for 'inset', private.
index 240653195126cd1f0257425e040848b6273b0304..7a4d006d23867be5e24f8caefc32660b0bc938a3 100644 (file)
@@ -74,8 +74,8 @@ public:
        ///
        string const latexString() const;
        ///
-       InsetInclude & parent() const {
-               return *static_cast<InsetInclude*>(inset());
+       InsetInclude const & parent() const {
+               return dynamic_cast<InsetInclude const &>(inset());
        }
 
        ///
index eb68e3c0fbd6eb34327663309f0188059da4bc3f..ad85d89e9f5e6fcbd2e5f4cd8c4f79989efd798e 100644 (file)
@@ -1,3 +1,7 @@
+2003-09-16  Angus Leeming  <leeming@lyx.org>
+
+       * formula.C (PreviewImpl::parent): return a const reference.
+
 2003-09-16  Angus Leeming  <leeming@lyx.org>
 
        * formula.C:
index f8d37f9727725d61e522c071fddff984d1527392..b4fe5e2176cca17ec07d88753623a49af7876cad 100644 (file)
@@ -48,9 +48,9 @@ private:
        ///
        string const latexString() const;
        ///
-       InsetFormula & parent() const
+       InsetFormula const & parent() const
        {
-               return *static_cast<InsetFormula*>(inset());
+               return dynamic_cast<InsetFormula const &>(inset());
        }
 };