]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/controllers/ControlToc.C
fix crash due to invalidated iterator
[lyx.git] / src / frontends / controllers / ControlToc.C
index c393d544b5ad03ce47ceeef2d4994c7f1661e398..f64cb4ad62c98e864f5a62651207f0f1d66f3dec 100644 (file)
@@ -5,25 +5,30 @@
  *
  * \author Angus Leeming
  *
- * Full author contact details are available in file CREDITS
+ * Full author contact details are available in file CREDITS.
  */
 
 #include <config.h>
 
 #include "ControlToc.h"
-#include "support/lstrings.h" // tostr
+#include "gettext.h"
 
 using std::vector;
+using std::string;
+
 
 class Buffer;
 
+namespace lyx {
+namespace frontend {
+
 
 ControlToc::ControlToc(Dialog & d)
        : ControlCommand(d, "toc")
 {}
 
 
-void ControlToc::goTo(lyx::toc::TocItem const & item)
+void ControlToc::goTo(toc::TocItem const & item)
 {
        item.goTo(kernel().lyxview());
 }
@@ -31,24 +36,36 @@ void ControlToc::goTo(lyx::toc::TocItem const & item)
 
 vector<string> const ControlToc::getTypes() const
 {
-       return lyx::toc::getTypes(kernel().buffer());
+       return toc::getTypes(kernel().buffer());
 }
 
 
-lyx::toc::Toc const ControlToc::getContents(string const & type) const
+string const ControlToc::getGuiName(string const & type) const
 {
-       lyx::toc::Toc empty_list;
+       if (type == "TOC")
+               return _("Table of Contents");
+       else
+               return _(toc::getGuiName(type, kernel().buffer()));
+}
+
+
+toc::Toc const ControlToc::getContents(string const & type) const
+{
+       toc::Toc empty_list;
 
        // This shouldn't be possible...
        if (!kernel().isBufferAvailable()) {
                return empty_list;
        }
 
-       lyx::toc::TocList tmp = lyx::toc::getTocList(kernel().buffer());
-       lyx::toc::TocList::iterator it = tmp.find(type);
+       toc::TocList tmp = toc::getTocList(kernel().buffer());
+       toc::TocList::iterator it = tmp.find(type);
        if (it == tmp.end()) {
                return empty_list;
        }
 
        return it->second;
 }
+
+} // namespace frontend
+} // namespace lyx