From 27a9cc2098ea14544521ab6336036f4110ca0da1 Mon Sep 17 00:00:00 2001 From: Angus Leeming Date: Tue, 16 Sep 2003 15:43:00 +0000 Subject: [PATCH] Small clean-up of the PreviewedInset interface. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7778 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/graphics/ChangeLog | 6 ++++++ src/graphics/PreviewedInset.C | 7 ++++++- src/graphics/PreviewedInset.h | 26 ++++++++++++++++++++------ src/insets/ChangeLog | 4 ++++ src/insets/insetinclude.C | 4 ++-- src/mathed/ChangeLog | 4 ++++ src/mathed/formula.C | 4 ++-- 7 files changed, 44 insertions(+), 11 deletions(-) diff --git a/src/graphics/ChangeLog b/src/graphics/ChangeLog index ca84c77669..b65440d09b 100644 --- a/src/graphics/ChangeLog +++ b/src/graphics/ChangeLog @@ -1,3 +1,9 @@ +2003-09-16 Angus Leeming + + * 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 * GraphicsImage.h: separate interface from implementation. Make all the diff --git a/src/graphics/PreviewedInset.C b/src/graphics/PreviewedInset.C index a644760247..85e4c95c31 100644 --- a/src/graphics/PreviewedInset.C +++ b/src/graphics/PreviewedInset.C @@ -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 diff --git a/src/graphics/PreviewedInset.h b/src/graphics/PreviewedInset.h index 31c6691faa..33c46eae14 100644 --- a/src/graphics/PreviewedInset.h +++ b/src/graphics/PreviewedInset.h @@ -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 diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index 3261834a19..32a1d5c6ac 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,7 @@ +2003-09-16 Angus Leeming + + * insetinclude.C (PreviewImpl::parent): return a const reference. + 2003-09-16 Angus Leeming * insetcollapsable.[Ch]: make all member variables, except for 'inset', private. diff --git a/src/insets/insetinclude.C b/src/insets/insetinclude.C index 2406531951..7a4d006d23 100644 --- a/src/insets/insetinclude.C +++ b/src/insets/insetinclude.C @@ -74,8 +74,8 @@ public: /// string const latexString() const; /// - InsetInclude & parent() const { - return *static_cast(inset()); + InsetInclude const & parent() const { + return dynamic_cast(inset()); } /// diff --git a/src/mathed/ChangeLog b/src/mathed/ChangeLog index eb68e3c0fb..ad85d89e9f 100644 --- a/src/mathed/ChangeLog +++ b/src/mathed/ChangeLog @@ -1,3 +1,7 @@ +2003-09-16 Angus Leeming + + * formula.C (PreviewImpl::parent): return a const reference. + 2003-09-16 Angus Leeming * formula.C: diff --git a/src/mathed/formula.C b/src/mathed/formula.C index f8d37f9727..b4fe5e2176 100644 --- a/src/mathed/formula.C +++ b/src/mathed/formula.C @@ -48,9 +48,9 @@ private: /// string const latexString() const; /// - InsetFormula & parent() const + InsetFormula const & parent() const { - return *static_cast(inset()); + return dynamic_cast(inset()); } };