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
33 ControlToc::ControlToc(LyXView & lv, Dialogs & d)
34 : ControlCommand(lv, d, LFUN_TOC_INSERT)
36 d_.showTOC.connect(slot(this, &ControlToc::showInset));
37 d_.createTOC.connect(slot(this, &ControlToc::createInset));
41 void ControlToc::Goto(int const & id) const
43 string const tmp = tostr(id);
44 lv_.getLyXFunc()->Dispatch(LFUN_GOTO_PARAGRAPH, tmp);
48 vector<string> const ControlToc::getTypes() const
52 Buffer::Lists const tmp = lv_.view()->buffer()->getLists();
54 Buffer::Lists::const_iterator cit = tmp.begin();
55 Buffer::Lists::const_iterator end = tmp.end();
57 for (; cit != end; ++cit) {
58 types.push_back(cit->first);
65 Buffer::SingleList const ControlToc::getContents(string const & type) const
67 Buffer::SingleList empty_list;
69 // This shouldn't be possible...
70 if (!lv_.view()->available()) {
74 Buffer::Lists tmp = lv_.view()->buffer()->getLists();
76 Buffer::Lists::iterator it = tmp.find(type);
78 if (it == tmp.end()) {
89 string const getType(string const & cmdName)
93 // It would be nice to have a map to extract this info.
94 // Does one already exist, Lars?
95 if (cmdName == "tableofcontents" )