]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insetfloat.C
Make it compile when USE_BOOST_FORMAT is unset
[lyx.git] / src / insets / insetfloat.C
index 837ff845e5890d051ce8e513d3916f236159299e..75a6746df9a33bd9a80e8be472d59b0e669e8044 100644 (file)
@@ -1,12 +1,13 @@
-/* This file is part of
- * ======================================================
+/**
+ * \file insetfloat.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
  *
- *           LyX, The Document Processor
+ * \author Jürgen Vigna
+ * \author Lars Gullik Bjønnes
  *
- *          Copyright 1998-2001 The LyX Team.
- *
- * ====================================================== */
-
+ * Full author contact details are available in file CREDITS
+ */
 #include <config.h>
 
 #ifdef __GNUG__
@@ -29,6 +30,7 @@
 #include "frontends/LyXView.h"
 #include "frontends/Dialogs.h"
 #include "lyxlex.h"
+#include "iterators.h"
 
 using std::ostream;
 using std::endl;
@@ -106,10 +108,11 @@ namespace {
 // of the float (JMarc)
 string const caplayout("Caption");
 
-string floatname(string const & type)
+string floatname(string const & type, BufferParams const & bp)
 {
-       FloatList::const_iterator it = floatList[type];
-       if (it == floatList.end())
+       FloatList const & floats = bp.getLyXTextClass().floats();
+       FloatList::const_iterator it = floats[type];
+       if (it == floats.end())
                return type;
 
        return _(it->second.name());
@@ -122,7 +125,7 @@ InsetFloat::InsetFloat(BufferParams const & bp, string const & type)
        : InsetCollapsable(bp), wide_(false)
 {
        string lab(_("float: "));
-       lab += floatname(type);
+       lab += floatname(type, bp);
        setLabel(lab);
        LyXFont font(LyXFont::ALL_SANE);
        font.decSize();
@@ -185,9 +188,9 @@ void InsetFloat::read(Buffer const * buf, LyXLex & lex)
                        lex.next();
                        string const tmptoken = lex.getString();
                        if (tmptoken == "true")
-                               wide(true);
+                               wide(true, buf->params);
                        else
-                               wide(false);
+                               wide(false, buf->params);
                } else {
                        lyxerr << "InsetFloat::Read:: Missing wide!"
                               << endl;
@@ -225,6 +228,7 @@ string const InsetFloat::editMessage() const
 int InsetFloat::latex(Buffer const * buf,
                      ostream & os, bool fragile, bool fp) const
 {
+       FloatList const & floats = buf->params.getLyXTextClass().floats();
        string const tmptype = (wide_ ? floatType_ + "*" : floatType_);
        // Figure out the float placement to use.
        // From lowest to highest:
@@ -233,11 +237,12 @@ int InsetFloat::latex(Buffer const * buf,
        // - specific float placement
        string placement;
        string const buf_placement = buf->params.float_placement;
-       string const def_placement = floatList.defaultPlacement(floatType_);
+       string const def_placement = floats.defaultPlacement(floatType_);
        if (!floatPlacement_.empty()
            && floatPlacement_ != def_placement) {
                placement = floatPlacement_;
-       } else if (!buf_placement.empty()
+       } else if (floatPlacement_.empty() 
+                  && !buf_placement.empty()
                   && buf_placement != def_placement) {
                placement = buf_placement;
        }
@@ -287,7 +292,7 @@ bool InsetFloat::insetAllowed(Inset::Code code) const
 bool InsetFloat::showInsetDialog(BufferView * bv) const
 {
        if (!inset.showInsetDialog(bv)) {
-               bv->owner()->getDialogs()->showFloat(const_cast<InsetFloat *>(this));
+               bv->owner()->getDialogs().showFloat(const_cast<InsetFloat *>(this));
        }
        return true;
 }
@@ -313,12 +318,12 @@ string const & InsetFloat::placement() const
 }
 
 
-void InsetFloat::wide(bool w)
+void InsetFloat::wide(bool w, BufferParams const & bp)
 {
        wide_ = w;
 
        string lab(_("float:"));
-       lab += floatname(floatType_);
+       lab += floatname(floatType_, bp);
 
        if (wide_)
                lab += "*";
@@ -335,11 +340,13 @@ bool InsetFloat::wide() const
 
 void InsetFloat::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) {
+       ParIterator pit(inset.paragraph());
+       ParIterator end;
+
+       // Find a caption layout in one of the (child inset's) pars
+       for (; pit != end; ++pit) {
+               Paragraph * tmp = *pit;
                if (tmp->layout()->name() == caplayout) {
                        string const str =
                                tostr(toclist[type()].size() + 1)
@@ -347,6 +354,5 @@ void InsetFloat::addToToc(toc::TocList & toclist, Buffer const * buf) const
                        toc::TocItem const item(tmp, 0 , str);
                        toclist[type()].push_back(item);
                }
-               tmp = tmp->next();
        }
 }