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 contents;
69 Buffer::TocItem noContent(0, 0, string());
71 // This shouldn't be possible...
72 if (!lv_.view()->available()) {
73 noContent.str = _("*** No Document ***");
74 contents.push_back(noContent);
78 Buffer::Lists tmp = lv_.view()->buffer()->getLists();
80 Buffer::Lists::iterator it = tmp.find(type);
82 if (it == tmp.end()) {
83 noContent.str = _("*** No Lists ***");
84 contents.push_back(noContent);
95 string const getType(string const & cmdName)
99 // It would be nice to have a map to extract this info.
100 // Does one already exist, Lars?
101 if (cmdName == "tableofcontents" )