]> git.lyx.org Git - features.git/commitdiff
Fix insetwrap
authorDekel Tsur <dekelts@tau.ac.il>
Tue, 24 Sep 2002 18:36:20 +0000 (18:36 +0000)
committerDekel Tsur <dekelts@tau.ac.il>
Tue, 24 Sep 2002 18:36:20 +0000 (18:36 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@5339 a592a061-630c-0410-9148-cb99ea01b6c8

src/ChangeLog
src/insets/ChangeLog
src/insets/insetwrap.C
src/insets/insetwrap.h
src/toc.C

index 629bbaad7c0548a754feeabedf2706b7731c952c..c00f0420a73e9798a6bfced4f0b3c71d05aa4fc4 100644 (file)
@@ -1,3 +1,7 @@
+2002-09-24  Dekel Tsur  <dekelts@tau.ac.il>
+
+       * toc.C (getTocList): Get TOC from InsetWrap.
+
 2002-09-16  John Levon  <levon@movementarian.org>
 
        * lyxfunc.C: check tabular for cut/copy too
index 38a0424d7b3aa21ca44eefc7781c1cffb08c6258..c57b4aee50fd73e3b0582fc09af928c50293b948 100644 (file)
@@ -1,3 +1,8 @@
+2002-09-24  Dekel Tsur  <dekelts@tau.ac.il>
+
+       * insetwrap.C (addToToc): New method.
+       (InsetWrap): Set layout to caption.
+
 2002-09-24  Lars Gullik Bjønnes  <larsbj@gullik.net>
 
        * Makefile.am (INCLUDES): loose SIGC_INCLUDES
index ae39aac22b5df21c5b6c355cc4e0af3140eed660..67d5639c7f1fbf5984a0ba92ece028500c5a211a 100644 (file)
 #include "frontends/LyXView.h"
 #include "frontends/Dialogs.h"
 #include "lyxlex.h"
+#include "FloatList.h"
 
 using std::ostream;
 using std::endl;
 
+namespace {
+
+// this should not be hardcoded, but be part of the definition
+// of the float (JMarc)
+string const caplayout("Caption");
+string floatname(string const & type, BufferParams const & bp)
+{
+       FloatList const & floats = bp.getLyXTextClass().floats();
+       FloatList::const_iterator it = floats[type];
+       if (it == floats.end())
+               return type;
+
+       return _(it->second.name());
+}
+
+} // namespace anon
+
 
 InsetWrap::InsetWrap(BufferParams const & bp, string const & type)
        : InsetCollapsable(bp), width_(50, LyXLength::PCW)
 {
-       string lab(_("wrap"));
-       lab += type;
+       string lab(_("wrap"));
+       lab += floatname(type, bp);
        setLabel(lab);
        LyXFont font(LyXFont::ALL_SANE);
        font.decSize();
@@ -46,6 +64,9 @@ InsetWrap::InsetWrap(BufferParams const & bp, string const & type)
        setLabelFont(font);
        Type_ = type;
        setInsetName(type);
+       LyXTextClass const & tclass = bp.getLyXTextClass();
+       if (tclass.hasLayout(caplayout))
+               inset.paragraph()->layout(tclass[caplayout]);
 }
 
 
@@ -229,3 +250,22 @@ bool InsetWrap::showInsetDialog(BufferView * bv) const
        }
        return true;
 }
+
+
+void InsetWrap::addToToc(toc::TocList & toclist, Buffer const * buf) const
+{
+       // Now find the caption in the float...
+       // We now tranverse the paragraphs of
+       // the inset...
+       Paragraph * tmp = inset.paragraph();
+       while (tmp) {
+               if (tmp->layout()->name() == caplayout) {
+                       string const str =
+                               tostr(toclist[type()].size() + 1)
+                               + ". " + tmp->asString(buf, false);
+                       toc::TocItem const item(tmp, 0 , str);
+                       toclist[type()].push_back(item);
+               }
+               tmp = tmp->next();
+       }
+}
index 4ddc3e8b41001fdc51bd3ff2ef4c8534410588f7..189928aefb665d998c1efd256b398b0c6ed97ef4 100644 (file)
@@ -16,6 +16,7 @@
 #endif
 
 #include "insetcollapsable.h"
+#include "toc.h"
 #include "lyxlength.h"
 
 #include <boost/signals/signal0.hpp>
@@ -64,6 +65,8 @@ public:
        ///
        string const & placement() const;
        ///
+       void addToToc(toc::TocList &, Buffer const *) const;
+       ///
        bool  showInsetDialog(BufferView *) const;
        ///
        boost::signal0<void> hideDialog;
index 685108a81bab1028e89f3188ce915fdb39c61d45..676f8d43a6208f28e81e29f7350b155f91cb5886 100644 (file)
--- a/src/toc.C
+++ b/src/toc.C
@@ -26,6 +26,7 @@
 #include "LyXAction.h"
 #include "paragraph.h"
 #include "insets/insetfloat.h"
+#include "insets/insetwrap.h"
 #include "debug.h"
 
 using std::vector;
@@ -91,7 +92,7 @@ TocList const getTocList(Buffer const * buf)
                }
 
                // For each paragraph, traverse its insets and look for
-               // FLOAT_CODE
+               // FLOAT_CODE or WRAP_CODE
                InsetList::iterator it = par->insetlist.begin();
                InsetList::iterator end = par->insetlist.end();
                for (; it != end; ++it) {
@@ -99,6 +100,10 @@ TocList const getTocList(Buffer const * buf)
                                InsetFloat * il =
                                        static_cast<InsetFloat*>(it.getInset());
                                il->addToToc(toclist, buf);
+                       } else if (it.getInset()->lyxCode() == Inset::WRAP_CODE) {
+                               InsetWrap * il =
+                                       static_cast<InsetWrap*>(it.getInset());
+                               il->addToToc(toclist, buf);
                        }
                }