]> git.lyx.org Git - features.git/commitdiff
fix bad InsetWrap cast
authorJohn Levon <levon@movementarian.org>
Tue, 6 May 2003 06:16:59 +0000 (06:16 +0000)
committerJohn Levon <levon@movementarian.org>
Tue, 6 May 2003 06:16:59 +0000 (06:16 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6936 a592a061-630c-0410-9148-cb99ea01b6c8

src/ChangeLog
src/insets/ChangeLog
src/insets/insetcaption.C
src/insets/insetfloat.C
src/insets/insetfloat.h
src/text2.C

index 903eb5b7ab4cea902e7b0626952b3067a283ee4c..5a76c667b1792052be243e65bedd4f0c350a0ec9 100644 (file)
@@ -1,3 +1,6 @@
+2003-05-06  John Levon  <levon@movementarian.org>
+
+       * text2.C: don't cast wrap inset to float
 
 2003-05-05 André Pönitz <poenitz@gmx.net>
 
index 8f663e758a6b3c5095ebf11b1aba7facd90371ff..6e0ebbe8af7294e9d9c422070aeccf3b49f416b7 100644 (file)
@@ -1,3 +1,9 @@
+2003-05-06  John Levon  <levon@movementarian.org>
+
+       * insetcaption.C: don't cast wrap inset to InsetFloat
+
+       * insetfloat.h:
+       * insetfloat.C: remove unneeded type() function
 
 2003-05-05 André Pönitz <poenitz@gmx.net>
 
index 892c1e6132b29640da23d21f013f6e15e65a4440..236017a9c67ce1a565f83eac66f0815e35f5707b 100644 (file)
 #include "buffer.h"
 #include "FloatList.h"
 #include "insets/insetfloat.h"
+#include "insets/insetwrap.h"
 #include "debug.h"
 #include "gettext.h"
 #include "support/lstrings.h"
-
+#include "support/LAssert.h"
 #include "support/BoostFormat.h"
 
 using std::ostream;
@@ -78,7 +79,14 @@ void InsetCaption::draw(BufferView * bv, LyXFont const & f,
        // belongs to.
        Inset * i1 = owner();
        Inset * i2 = i1 ? i1->owner() : 0;
-       string const type = static_cast<InsetFloat *>(i2)->type();
+       string type;
+       if (i2->lyxCode() == FLOAT_CODE)
+               type = static_cast<InsetFloat *>(i2)->params().type;
+       else if (i2->lyxCode() == WRAP_CODE)
+               type = static_cast<InsetWrap *>(i2)->params().type;
+       else
+               lyx::Assert(0);
+
        FloatList const & floats =
                bv->buffer()->params.getLyXTextClass().floats();
        string const fl = i2 ? floats.getType(type).name() : N_("Float");
index 4b4e8202ba035d36a03a4ed10ad42430b445e557..93a5dd0a97c15763863bbdcf3105ec48dfcc546b 100644 (file)
@@ -342,12 +342,6 @@ bool InsetFloat::showInsetDialog(BufferView * bv) const
 }
 
 
-string const & InsetFloat::type() const
-{
-       return params_.type;
-}
-
-
 void InsetFloat::wide(bool w, BufferParams const & bp)
 {
        params_.wide = w;
@@ -372,7 +366,7 @@ void InsetFloat::addToToc(toc::TocList & toclist, Buffer const * buf) const
                Paragraph * tmp = *pit;
 
                if (tmp->layout()->name() == caplayout) {
-                       string const name = floatname(type(), buf->params);
+                       string const name = floatname(params_.type, buf->params);
                        string const str =
                                tostr(toclist[name].size() + 1)
                                + ". " + tmp->asString(buf, false);
index 7eb8a54e314c48fba5e4f7420e8b36d60d1f8c7b..8658f5a6c94166c1ba2430f9b8875ad7655756b2 100644 (file)
@@ -70,8 +70,6 @@ public:
            insets that may contain several paragraphs */
        bool noFontChange() const { return true; }
        ///
-       string const & type() const;
-       ///
        void wide(bool w, BufferParams const &);
        ///
        void addToToc(toc::TocList &, Buffer const *) const;
index 8ae8109bbd4e8c73272312d9c406bc5be4c02c2f..cbb515d11666fbe1c5af2021f3840617713fb60a 100644 (file)
@@ -34,6 +34,7 @@
 
 #include "insets/insetbibitem.h"
 #include "insets/insetfloat.h"
+#include "insets/insetwrap.h"
 
 #include "support/LAssert.h"
 #include "support/textutils.h"
@@ -1173,8 +1174,16 @@ void LyXText::setCounter(Buffer const * buf, ParagraphList::iterator pit)
                        }
 
                        if (isOK) {
-                               Floating const & fl
-                                       = textclass.floats().getType(static_cast<InsetFloat*>(in)->type());
+                               string type;
+
+                               if (in->lyxCode() == Inset::FLOAT_CODE)
+                                       type = static_cast<InsetFloat*>(in)->params().type;
+                               else if (in->lyxCode() == Inset::WRAP_CODE)
+                                       type = static_cast<InsetWrap*>(in)->params().type;
+                               else
+                                       lyx::Assert(0);
+
+                               Floating const & fl = textclass.floats().getType(type);
 
                                textclass.counters().step(fl.type());