]> git.lyx.org Git - features.git/commitdiff
move floatlist to textclass
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Tue, 27 Aug 2002 15:51:19 +0000 (15:51 +0000)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Tue, 27 Aug 2002 15:51:19 +0000 (15:51 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@5124 a592a061-630c-0410-9148-cb99ea01b6c8

18 files changed:
po/POTFILES.in
src/BufferView_pimpl.C
src/ChangeLog
src/FloatList.C
src/FloatList.h
src/LaTeXFeatures.C
src/MenuBackend.C
src/factory.C
src/frontends/controllers/ChangeLog
src/frontends/controllers/ControlFloat.C
src/insets/ChangeLog
src/insets/insetcaption.C
src/insets/insetfloat.C
src/insets/insetfloat.h
src/insets/insetfloatlist.C
src/lyxtextclass.C
src/lyxtextclass.h
src/text2.C

index 0736ed59c6c5fdd18cace8a490e7fb0e134d63d6..ca6ca71010c61182409b0fd7fcb5b657ebb642e5 100644 (file)
@@ -8,6 +8,7 @@ src/converter.C
 src/CutAndPaste.C
 src/debug.C
 src/exporter.C
+src/ext_l10n.h
 src/FloatList.C
 src/frontends/controllers/biblio.C
 src/frontends/controllers/ButtonController.h
index 0579df09eb80ff5b19b71700a7a93421683c88dd..737d6aaea2483700f2a6ef8aecab3dde69d1350c 100644 (file)
@@ -1725,7 +1725,7 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & ev)
        break;
 
        case LFUN_FLOAT_LIST:
-               if (floatList.typeExist(ev.argument)) {
+               if (tclass.floats().typeExist(ev.argument)) {
                        Inset * inset = new InsetFloatList(ev.argument);
                        if (!insertInset(inset, tclass.defaultLayoutName()))
                                delete inset;
index 0d6883f3694b8e614751700cd4b101be6a273df1..415aad0a8da73cc28dfce15433623069feb083c9 100644 (file)
@@ -1,3 +1,22 @@
+2002-08-27  Jean-Marc Lasgouttes  <lasgouttes@freesurf.fr>
+
+       * factory.C (createInset): use LyXTextClass::floats
+
+       * MenuBackend.C (expandFloatListInsert): 
+       (expandFloatInsert): 
+       (expandToc): 
+
+       * text2.C (setCounter): 
+
+       * LaTeXFeatures.C (useFloat): 
+       (getFloatDefinitions): 
+
+       * BufferView_pimpl.C (dispatch): use LyXTextClass::floats()
+
+       * lyxtextclass.[Ch]: rename layoutlist to layoutlist_; add
+       floatlist_, with accessor floats().
+
+       * FloatList.h: remove global FloatList
 
 2002-08-26  André Pönitz <poenitz@gmx.net>
 
index fd724fdb18eb142b31b8b568bb5ec6ddebe228f4..932eda5e8650b5914ee96f184e1b56ba5ee42156 100644 (file)
@@ -104,6 +104,3 @@ FloatList::const_iterator FloatList::operator[](string const & t) const
        return list.find(t);
 }
 
-
-// The global floatlist
-FloatList floatList;
index 42aca7bc29d5dd2861d7b2a8e0646dd344b6a65a..150399dc377006953139588b63d3f61e464de123 100644 (file)
@@ -49,7 +49,4 @@ private:
        List list;
 };
 
-///
-extern FloatList floatList;
-
 #endif
index 143bbdfa3876918b470c9df533cfc1ad9b021f54..7174eb91c86d7566456b86ad3ce281ea3fe6bdc1 100644 (file)
@@ -110,7 +110,7 @@ void LaTeXFeatures::useFloat(string const & name)
        // We only need float.sty if we use non builtin floats, or if we
        // use the "H" modifier. This includes modified table and
        // figure floats. (Lgb)
-       Floating const & fl = floatList.getType(name);
+       Floating const & fl = params.getLyXTextClass().floats().getType(name);
        if (!fl.type().empty() && !fl.builtin()) {
                require("float");
        }
@@ -425,6 +425,8 @@ BufferParams const & LaTeXFeatures::bufferParams() const
 
 void LaTeXFeatures::getFloatDefinitions(ostream & os) const
 {
+       FloatList const & floats = params.getLyXTextClass().floats();
+       
        // Here we will output the code to create the needed float styles.
        // We will try to do this as minimal as possible.
        // \floatstyle{ruled}
@@ -434,7 +436,7 @@ void LaTeXFeatures::getFloatDefinitions(ostream & os) const
        UsedFloats::const_iterator end = usedFloats.end();
        // ostringstream floats;
        for (; cit != end; ++cit) {
-               Floating const & fl = floatList.getType((*cit));
+               Floating const & fl = floats.getType((*cit));
 
                // For builtin floats we do nothing.
                if (fl.builtin()) continue;
index 30eadba0b24af63ae751109a22ff59c70d825f34..055924da53c899d5870954ebce5bccbea5d5315e 100644 (file)
@@ -24,6 +24,7 @@
 #include "lastfiles.h"
 #include "lyx_main.h" // for lastfiles
 #include "bufferlist.h"
+#include "buffer.h"
 #include "converter.h"
 #include "exporter.h"
 #include "importer.h"
@@ -386,10 +387,17 @@ void expandFormats(MenuItem::Kind kind, Menu & tomenu, Buffer const * buf)
 }
 
 
-void expandFloatListInsert(Menu & tomenu)
+void expandFloatListInsert(Menu & tomenu, Buffer const * buf)
 {
-       FloatList::const_iterator cit = floatList.begin();
-       FloatList::const_iterator end = floatList.end();
+       if (!buf) {
+               tomenu.add(MenuItem(MenuItem::Command,
+                                   _("No Documents Open!"), LFUN_NOACTION));
+               return;
+       }
+
+       FloatList const & floats = buf->params.getLyXTextClass().floats();
+       FloatList::const_iterator cit = floats.begin();
+       FloatList::const_iterator end = floats.end();
        for (; cit != end; ++cit) {
                int const action =  lyxaction
                        .getPseudoAction(LFUN_FLOAT_LIST, cit->second.type());
@@ -400,10 +408,17 @@ void expandFloatListInsert(Menu & tomenu)
 }
 
 
-void expandFloatInsert(Menu & tomenu)
+void expandFloatInsert(Menu & tomenu, Buffer const * buf)
 {
-       FloatList::const_iterator cit = floatList.begin();
-       FloatList::const_iterator end = floatList.end();
+       if (!buf) {
+               tomenu.add(MenuItem(MenuItem::Command,
+                                   _("No Documents Open!"), LFUN_NOACTION));
+               return;
+       }
+
+       FloatList const & floats = buf->params.getLyXTextClass().floats();
+       FloatList::const_iterator cit = floats.begin();
+       FloatList::const_iterator end = floats.end();
        for (; cit != end; ++cit) {
                // normal float
                int const action =
@@ -465,6 +480,7 @@ void expandToc2(Menu & tomenu, toc::Toc const & toc_list,
 
 void expandToc(Menu & tomenu, Buffer const * buf)
 {
+       FloatList const & floats = buf->params.getLyXTextClass().floats();
        toc::TocList toc_list = toc::getTocList(buf);
        toc::TocList::const_iterator cit = toc_list.begin();
        toc::TocList::const_iterator end = toc_list.end();
@@ -482,7 +498,7 @@ void expandToc(Menu & tomenu, Buffer const * buf)
                                           label, ccit->action()));
                }
                MenuItem item(MenuItem::Submenu,
-                             floatList[cit->first]->second.name());
+                             floats[cit->first]->second.name());
                item.submenu(menu);
                tomenu.add(item);
        }
@@ -523,11 +539,11 @@ void MenuBackend::expand(Menu const & frommenu, Menu & tomenu,
                        break;
 
                case MenuItem::FloatListInsert:
-                       expandFloatListInsert(tomenu);
+                       expandFloatListInsert(tomenu, buf);
                        break;
 
                case MenuItem::FloatInsert:
-                       expandFloatInsert(tomenu);
+                       expandFloatInsert(tomenu, buf);
                        break;
 
                case MenuItem::Toc:
index 6decdacca262703730c5a757259199a88d18615e..54d08fa2ea7b80edb2c304fa63b030407df5b118 100644 (file)
@@ -46,17 +46,17 @@ Inset * createInset(FuncRequest const & cmd)
                        return new InsetOptArg(params);
 
                case LFUN_INSET_FLOAT:
-                       // check if the float type exist
-                       if (floatList.typeExist(cmd.argument))
+                       // check if the float type exists
+                       if (params.getLyXTextClass().floats().typeExist(cmd.argument))
                                return new InsetFloat(params, cmd.argument);
                        lyxerr << "Non-existent float type: " << cmd.argument << endl;
                        return 0;
 
                case LFUN_INSET_WIDE_FLOAT:
-                       // check if the float type exist
-                       if (floatList.typeExist(cmd.argument)) {
+                       // check if the float type exists
+                       if (params.getLyXTextClass().floats().typeExist(cmd.argument)) {
                                InsetFloat * p = new InsetFloat(params, cmd.argument);
-                               p->wide(true);
+                               p->wide(true, params);
                        }
                        lyxerr << "Non-existent float type: " << cmd.argument << endl;
                        return 0;
index 3bfff59d44698047b38ecf5f65f3dfcdf3893dc9..c08dc43e834827e2fb00eeed2cd92130db4f382d 100644 (file)
@@ -1,3 +1,7 @@
+2002-08-27  Jean-Marc Lasgouttes  <lasgouttes@freesurf.fr>
+
+       * ControlFloat.C (applyParamsToInset): wide() now has two arguments
+
 2002-08-23  Rob Lahaye  <lahaye@snu.ac.kr>
 
        * ControlGraphics.C: make rotationOrigin's default ("leftBaseline") the
index 2eb6cc47d54545a4a309678838ce56af5f41762d..40d34b295c84187639c8502204bacf4642e8493c 100644 (file)
@@ -17,6 +17,7 @@
 
 #include "ControlFloat.h"
 #include "BufferView.h"
+#include "buffer.h"
 
 
 ControlFloat::ControlFloat(LyXView & lv, Dialogs & d)
@@ -27,7 +28,7 @@ ControlFloat::ControlFloat(LyXView & lv, Dialogs & d)
 void ControlFloat::applyParamsToInset()
 {
        inset()->placement(params().placement);
-       inset()->wide(params().wide);
+       inset()->wide(params().wide, bufferview()->buffer()->params);
        bufferview()->updateInset(inset(), true);
 
 }
index 7d6c7c704381c66a2215d71252924dc02d65783c..e32525a51e7bf5cc4460f711f09ab195c5809c89 100644 (file)
@@ -1,3 +1,14 @@
+2002-08-27  Jean-Marc Lasgouttes  <lasgouttes@freesurf.fr>
+
+       * insetfloat.C (wide): add BufferParams parameter
+
+       * insetfloatlist.C (read): 
+       (latex): 
+       (getScreenLabel): 
+       * insetfloat.C (latex): 
+       (floatname): 
+       * insetcaption.C (draw): use LyXTextClass::floats()
+
 2002-08-26  Lars Gullik Bjønnes  <larsbj@birdstep.com>
 
        * insetoptarg.h: add std:: qualifier.
index 494d69bd017af9d3c6d8a27746f0f5e249634c01..78a883bce5029f56a4dcf9b34b3e4a56822b71e1 100644 (file)
@@ -18,6 +18,7 @@
 #include "frontends/Painter.h"
 #include "frontends/font_metrics.h"
 #include "BufferView.h"
+#include "buffer.h"
 #include "FloatList.h"
 #include "insets/insetfloat.h"
 #include "debug.h"
@@ -79,7 +80,9 @@ void InsetCaption::draw(BufferView * bv, LyXFont const & f,
        Inset * i1 = owner();
        Inset * i2 = i1 ? i1->owner() : 0;
        string const type = static_cast<InsetFloat *>(i2)->type();
-       string const fl = i2 ? floatList.getType(type).name() : N_("Float");
+       FloatList const & floats =
+               bv->buffer()->params.getLyXTextClass().floats();
+       string const fl = i2 ? floats.getType(type).name() : N_("Float");
 
        // Discover the number...
        // ...
index 2bfb0aa9272e4482857adecd9e08919cc6883d2a..328e3566799fcea6fa50427642257635be08eb36 100644 (file)
@@ -106,10 +106,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 +123,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 +186,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 +226,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,7 +235,7 @@ 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_;
@@ -313,12 +315,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 += "*";
index 2dcc45f9ef998c0909b1bf29f19207d971765df7..792d9f7872b009854a984c68a7ddfa56dd6a1219 100644 (file)
@@ -63,7 +63,7 @@ public:
        ///
        string const & placement() const;
        ///
-       void wide(bool w);
+       void wide(bool w, BufferParams const &);
        ///
        bool wide() const;
        ///
index 33251b1350b12a70d643ca6606dd2c44a1fe128e..6562e74bd2a59ef8ad587cb5ad724f7a42af00b4 100644 (file)
@@ -11,6 +11,7 @@
 #include "frontends/Dialogs.h"
 #include "frontends/LyXView.h"
 #include "BufferView.h"
+#include "buffer.h"
 #include "toc.h"
 #include "gettext.h"
 #include "debug.h"
@@ -33,10 +34,11 @@ InsetFloatList::InsetFloatList(string const & type)
 }
 
 
-string const InsetFloatList::getScreenLabel(Buffer const *) const
+string const InsetFloatList::getScreenLabel(Buffer const * buf) const
 {
-       FloatList::const_iterator it = floatList[getCmdName()];
-       if (it != floatList.end())
+       FloatList const & floats = buf->params.getLyXTextClass().floats();
+       FloatList::const_iterator it = floats[getCmdName()];
+       if (it != floats.end())
                return _(it->second.listName());
        else
                return _("ERROR: Nonexistent float type!");
@@ -55,14 +57,15 @@ void InsetFloatList::write(Buffer const *, ostream & os) const
 }
 
 
-void InsetFloatList::read(Buffer const *, LyXLex & lex)
+void InsetFloatList::read(Buffer const * buf, LyXLex & lex)
 {
+       FloatList const & floats = buf->params.getLyXTextClass().floats();
        string token;
 
        if (lex.eatLine()) {
                setCmdName(lex.getString());
                lyxerr[Debug::INSETS] << "FloatList::float_type: " << getCmdName() << endl;
-               if (!floatList.typeExist(getCmdName()))
+               if (!floats.typeExist(getCmdName()))
                        lex.printError("InsetFloatList: Unknown float type: `$$Token'");
        } else
                lex.printError("InsetFloatList: Parse error: `$$Token'");
@@ -91,11 +94,12 @@ void InsetFloatList::edit(BufferView * bv, bool)
 }
 
 
-int InsetFloatList::latex(Buffer const *, ostream & os, bool, bool) const
+int InsetFloatList::latex(Buffer const * buf, ostream & os, bool, bool) const
 {
-       FloatList::const_iterator cit = floatList[getCmdName()];
+       FloatList const & floats = buf->params.getLyXTextClass().floats();
+       FloatList::const_iterator cit = floats[getCmdName()];
 
-       if (cit != floatList.end()) {
+       if (cit != floats.end()) {
                if (cit->second.builtin()) {
                        // Only two different types allowed here:
                        string const type = cit->second.type();
index a86ef7e28dd5b58ca5dfed66838d95d36416b3bf..63c6f92bb8c290e9ce28c91f6535c83ecda300d7 100644 (file)
@@ -204,7 +204,7 @@ bool LyXTextClass::Read(string const & filename, bool merge)
                                        LyXLayout lay;
                                        lay.setName(name);
                                        if (!(error = do_readStyle(lexrc, lay)))
-                                               layoutlist.push_back(boost::shared_ptr<LyXLayout>(new LyXLayout(lay)));
+                                               layoutlist_.push_back(boost::shared_ptr<LyXLayout>(new LyXLayout(lay)));
                                        if (defaultlayout_.empty()) {
                                                // We do not have a default
                                                // layout yet, so we choose
@@ -517,9 +517,9 @@ bool LyXTextClass::hasLayout(string const & n) const
 {
        string const name = (n.empty() ? defaultLayoutName() : n);
 
-       return find_if(layoutlist.begin(), layoutlist.end(),
+       return find_if(layoutlist_.begin(), layoutlist_.end(),
                       compare_name(name))
-               != layoutlist.end();
+               != layoutlist_.end();
 }
 
 
@@ -536,14 +536,14 @@ LyXLayout_ptr const & LyXTextClass::operator[](string const & n) const
        static LayoutList::difference_type lastLayoutIndex;
 
        if (name == lastLayoutName)
-               return layoutlist[lastLayoutIndex];
+               return layoutlist_[lastLayoutIndex];
 
        LayoutList::const_iterator cit =
-               find_if(layoutlist.begin(),
-                       layoutlist.end(),
+               find_if(layoutlist_.begin(),
+                       layoutlist_.end(),
                        compare_name(name));
 
-       if (cit == layoutlist.end()) {
+       if (cit == layoutlist_.end()) {
                lyxerr << "We failed to find the layout '" << name
                       << "' in the layout list. You MUST investigate!"
                       << endl;
@@ -553,7 +553,7 @@ LyXLayout_ptr const & LyXTextClass::operator[](string const & n) const
        }
 
        lastLayoutName = name;
-       lastLayoutIndex = std::distance(layoutlist.begin(), cit);
+       lastLayoutIndex = std::distance(layoutlist_.begin(), cit);
 
        return (*cit);
 }
@@ -565,12 +565,12 @@ bool LyXTextClass::delete_layout(string const & name)
                return false;
 
        LayoutList::iterator it =
-               remove_if(layoutlist.begin(), layoutlist.end(),
+               remove_if(layoutlist_.begin(), layoutlist_.end(),
                          compare_name(name));
 
-       LayoutList::iterator end = layoutlist.end();
+       LayoutList::iterator end = layoutlist_.end();
        bool const ret = (it != end);
-       layoutlist.erase(it, end);
+       layoutlist_.erase(it, end);
        return ret;
 }
 
@@ -597,6 +597,18 @@ bool LyXTextClass::load() const
 }
 
 
+FloatList & LyXTextClass::floats()
+{
+       return floatlist_;
+}
+
+
+FloatList const & LyXTextClass::floats() const
+{
+       return floatlist_;
+}
+
+
 string const LyXTextClass::defaultLayoutName() const
 {
        // This really should come from the actual layout... (Lgb)
@@ -703,7 +715,7 @@ int LyXTextClass::maxcounter() const
 
 int LyXTextClass::size() const
 {
-       return layoutlist.size();
+       return layoutlist_.size();
 }
 
 
index 1a8a6e8633563dd1d35ab843c3a799c235180685..2d1021f792d438591087ed20f1887b4a27c2f246 100644 (file)
@@ -19,6 +19,7 @@
 #include "lyxlayout.h"
 #include "LString.h"
 #include "lyxlayout_ptr_fwd.h"
+#include "FloatList.h"
 
 #include "support/types.h"
 
@@ -40,9 +41,9 @@ public:
                      string const & = string());
 
        ///
-       const_iterator begin() const { return layoutlist.begin(); }
+       const_iterator begin() const { return layoutlist_.begin(); }
        ///
-       const_iterator end() const { return layoutlist.end(); }
+       const_iterator end() const { return layoutlist_.end(); }
 
        ///
        bool Read(string const & filename, bool merge = false);
@@ -61,6 +62,11 @@ public:
        /// Sees to that the textclass structure has been loaded
        bool load() const;
 
+       /// the list of floats defined in the class
+       FloatList & floats();
+       /// the list of floats defined in the class
+       FloatList const & floats() const;
+
        ///
        string const defaultLayoutName() const;
        ///
@@ -179,7 +185,10 @@ private:
        int maxcounter_; // add approp. signedness
 
        ///
-       LayoutList layoutlist;
+       LayoutList layoutlist_;
+
+       ///
+       FloatList floatlist_;
 
        /// Has this layout file been loaded yet?
        mutable bool loaded;
index 91097ed2781685ff590249566c2c0d54b276818c..228a5039c65bbe70b09fc362a5e7569c35e4d0d8 100644 (file)
@@ -1351,7 +1351,7 @@ void LyXText::setCounter(Buffer const * buf, Paragraph * par) const
 
                        if (isOK) {
                                Floating const & fl
-                                       = floatList.getType(static_cast<InsetFloat*>(in)->type());
+                                       = textclass.floats().getType(static_cast<InsetFloat*>(in)->type());
 
                                buf->counters().step(fl.name());