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
21 #include "ButtonControllerBase.h"
22 #include "ControlToc.h"
27 #include "support/lstrings.h" // tostr
29 #include "BufferView.h"
34 ControlToc::ControlToc(LyXView & lv, Dialogs & d)
35 : ControlCommand(lv, d, LFUN_TOC_INSERT)
37 d_.showTOC.connect(slot(this, &ControlToc::showInset));
38 d_.createTOC.connect(slot(this, &ControlToc::createInset));
42 void ControlToc::Goto(int const & id) const
44 string const tmp = tostr(id);
45 lv_.getLyXFunc()->dispatch(LFUN_GOTO_PARAGRAPH, tmp);
49 vector<string> const ControlToc::getTypes() const
53 Buffer::Lists const tmp = lv_.view()->buffer()->getLists();
55 Buffer::Lists::const_iterator cit = tmp.begin();
56 Buffer::Lists::const_iterator end = tmp.end();
58 for (; cit != end; ++cit) {
59 types.push_back(cit->first);
66 Buffer::SingleList const ControlToc::getContents(string const & type) const
68 Buffer::SingleList empty_list;
70 // This shouldn't be possible...
71 if (!lv_.view()->available()) {
75 Buffer::Lists tmp = lv_.view()->buffer()->getLists();
77 Buffer::Lists::iterator it = tmp.find(type);
79 if (it == tmp.end()) {
90 string const getType(string const & cmdName)
92 string type = cmdName;
95 if (cmdName == "tableofcontents")