1 /* This file is part of
2 * ======================================================
4 * LyX, The Document Processor
6 * Copyright 2001 The LyX Team.
8 * ======================================================
11 * \author Angus Leeming <a.leeming@ic.ac.uk>
17 #pragma implementation
20 #include "ControlToc.h"
22 #include "ButtonControllerBase.h"
27 #include "BufferView.h"
29 #include "frontends/LyXView.h"
31 #include "support/lstrings.h" // tostr
33 #include <boost/bind.hpp>
37 ControlToc::ControlToc(LyXView & lv, Dialogs & d)
38 : ControlCommand(lv, d, LFUN_TOC_INSERT)
40 d_.showTOC = boost::bind(&ControlToc::showInset, this, _1);
41 d_.createTOC = boost::bind(&ControlToc::createInset, this, _1);
45 void ControlToc::Goto(int const & id) const
47 string const tmp = tostr(id);
48 lv_.getLyXFunc()->dispatch(LFUN_GOTO_PARAGRAPH, tmp);
52 vector<string> const ControlToc::getTypes() const
56 Buffer::Lists const tmp = lv_.view()->buffer()->getLists();
58 Buffer::Lists::const_iterator cit = tmp.begin();
59 Buffer::Lists::const_iterator end = tmp.end();
61 for (; cit != end; ++cit) {
62 types.push_back(cit->first);
69 Buffer::SingleList const ControlToc::getContents(string const & type) const
71 Buffer::SingleList empty_list;
73 // This shouldn't be possible...
74 if (!lv_.view()->available()) {
78 Buffer::Lists tmp = lv_.view()->buffer()->getLists();
80 Buffer::Lists::iterator it = tmp.find(type);
82 if (it == tmp.end()) {
93 string const getType(string const & cmdName)
95 string type = cmdName;
98 if (cmdName == "tableofcontents")