]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insetfloatlist.C
use more specific smart_ptr headers
[lyx.git] / src / insets / insetfloatlist.C
index b51064490b5b1f910fc329fa6d60943d11dcadee..7c146848c2179004318197eec0d3ffb9fae5dcf0 100644 (file)
@@ -6,6 +6,7 @@
 
 #include "insetfloatlist.h"
 #include "FloatList.h"
+#include "LaTeXFeatures.h"
 #include "frontends/Dialogs.h"
 #include "LyXView.h"
 #include "BufferView.h"
 #include "gettext.h"
 #include "debug.h"
 
+
+using std::ostream;
 using std::endl;
 
+
 InsetFloatList::InsetFloatList()
        : InsetCommand(InsetCommandParams())
 {
 }
 
+
 InsetFloatList::InsetFloatList(string const & type)
        : InsetCommand(InsetCommandParams())
 {
@@ -28,14 +32,13 @@ InsetFloatList::InsetFloatList(string const & type)
 }
 
 
-string const InsetFloatList::getScreenLabel(Buffer const *) const 
+string const InsetFloatList::getScreenLabel(Buffer const *) const
 {
-       string const guiName = floatList[getCmdName()]->second.name();
-       if (!guiName.empty()) {
-               string const res = guiName + _(" List");
-               return res;
-       }
-       return _("ERROR: Nonexistent float type!");
+       FloatList::const_iterator it = floatList[getCmdName()];
+       if (it != floatList.end())
+               return _(it->second.listName());
+       else
+               return _("ERROR: Nonexistent float type!");
 }
 
 
@@ -45,19 +48,21 @@ Inset::Code InsetFloatList::lyxCode() const
 }
 
 
-void InsetFloatList::write(Buffer const *, std::ostream & os) const
+void InsetFloatList::write(Buffer const *, ostream & os) const
 {
        os << "FloatList " << getCmdName() << "\n";
 }
 
 
-void InsetFloatList::read(Buffer const *, LyXLex & lex) 
+void InsetFloatList::read(Buffer const *, LyXLex & lex)
 {
        string token;
 
        if (lex.eatLine()) {
                setCmdName(lex.getString());
-               lyxerr << "FloatList::float_type: " << getCmdName() << endl;
+               lyxerr[Debug::INSETS] << "FloatList::float_type: " << getCmdName() << endl;
+               if (!floatList.typeExist(getCmdName()))
+                       lex.printError("InsetFloatList: Unknown float type: `$$Token'");
        } else
                lex.printError("InsetFloatList: Parse error: `$$Token'");
        while (lex.isOK()) {
@@ -85,7 +90,7 @@ void InsetFloatList::edit(BufferView * bv, bool)
 }
 
 
-int InsetFloatList::latex(Buffer const *, std::ostream & os, bool, bool) const
+int InsetFloatList::latex(Buffer const *, ostream & os, bool, bool) const
 {
        FloatList::const_iterator cit = floatList[getCmdName()];
 
@@ -102,7 +107,7 @@ int InsetFloatList::latex(Buffer const *, std::ostream & os, bool, bool) const
                        }
                } else {
                        os << "\\listof{" << getCmdName() << "}{"
-                          << _("List of ") << cit->second.name() << "}\n";
+                          << cit->second.listName() << "}\n";
                }
        } else {
                os << "%%\\listof{" << getCmdName() << "}{"
@@ -112,7 +117,7 @@ int InsetFloatList::latex(Buffer const *, std::ostream & os, bool, bool) const
 }
 
 
-int InsetFloatList::ascii(Buffer const * buffer, std::ostream & os, int) const
+int InsetFloatList::ascii(Buffer const * buffer, ostream & os, int) const
 {
        os << getScreenLabel(buffer) << "\n\n";
 
@@ -130,3 +135,9 @@ int InsetFloatList::ascii(Buffer const * buffer, std::ostream & os, int) const
        os << "\n";
        return 0;
 }
+
+
+void InsetFloatList::validate(LaTeXFeatures & features) const
+{
+       features.useFloat(getCmdName());
+}