]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/controllers/ControlToc.C
Add a buffer_path arg to InsetGraphicsMailer's params2string, string2params.
[lyx.git] / src / frontends / controllers / ControlToc.C
index c4eae44f551b0e768aa0bc59610ffcc487964313..f9daa70d044126afba42e1476babbaa3f0fa7602 100644 (file)
-/* This file is part of
- * ====================================================== 
- *
- *           LyX, The Document Processor
- *
- *           Copyright 2001 The LyX Team.
+/**
+ * \file ControlToc.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
  *
- * ======================================================
+ * \author Angus Leeming
  *
- * \file ControlToc.C
- * \author Angus Leeming <a.leeming@ic.ac.uk>
+ * Full author contact details are available in file CREDITS
  */
 
 #include <config.h>
 
-#ifdef __GNUG__
-#pragma implementation
-#endif
-
-#include "ViewBase.h"
-#include "ButtonControllerBase.h"
 #include "ControlToc.h"
-#include "buffer.h"
-#include "Dialogs.h"
-#include "LyXView.h"
-#include "lyxfunc.h"
 #include "support/lstrings.h" // tostr
-#include "gettext.h"
-#include "BufferView.h"
 
 using std::vector;
-using SigC::slot;
 
-ControlToc::ControlToc(LyXView & lv, Dialogs & d)
-       : ControlCommand(lv, d, LFUN_TOC_INSERT)
-{
-       d_.showTOC.connect(slot(this, &ControlToc::showInset));
-       d_.createTOC.connect(slot(this, &ControlToc::createInset));
-}
+class Buffer;
+
+
+ControlToc::ControlToc(Dialog & d)
+       : ControlCommand(d, "toc")
+{}
 
 
-void ControlToc::Goto(int const & id) const
+void ControlToc::goTo(toc::TocItem const & item)
 {
-       string const tmp = tostr(id);
-       lv_.getLyXFunc()->Dispatch(LFUN_GOTO_PARAGRAPH, tmp);
+       item.goTo(kernel().lyxview());
 }
 
 
 vector<string> const ControlToc::getTypes() const
 {
-       vector<string> types;
-
-       Buffer::Lists const tmp = lv_.view()->buffer()->getLists();
-
-       Buffer::Lists::const_iterator cit = tmp.begin();
-       Buffer::Lists::const_iterator end = tmp.end();
-
-       for (; cit != end; ++cit) {
-               types.push_back(cit->first);
-       }
-
-       return types;
+       return toc::getTypes(kernel().buffer());
 }
 
 
-Buffer::SingleList const ControlToc::getContents(string const & type) const
+toc::Toc const ControlToc::getContents(string const & type) const
 {
-       Buffer::SingleList empty_list;
+       toc::Toc empty_list;
 
        // This shouldn't be possible...
-       if (!lv_.view()->available()) {
+       if (!kernel().isBufferAvailable()) {
                return empty_list;
        }
 
-       Buffer::Lists tmp = lv_.view()->buffer()->getLists();
-
-       Buffer::Lists::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 toc 
-{
-
-string const getType(string const & cmdName)
-{
-       string type;
-
-       // It would be nice to have a map to extract this info.
-       // Does one already exist, Lars?
-       if (cmdName == "tableofcontents" )
-               type = "TOC";
-
-       return cmdName;
-}
-} // namespace toc