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"
25 #include "support/lstrings.h" // tostr
30 ControlToc::ControlToc(LyXView & lv, Dialogs & d)
31 : ControlCommand(lv, d, LFUN_TOC_INSERT)
33 d_.showTOC.connect(slot(this, &ControlToc::showInset));
34 d_.createTOC.connect(slot(this, &ControlToc::createInset));
38 void ControlToc::Goto(int const & id) const
40 string const tmp = tostr(id);
41 lv_.getLyXFunc()->Dispatch(LFUN_GOTO_PARAGRAPH, tmp);
45 vector<string> const ControlToc::getTypes() const
49 Buffer::Lists const tmp = lv_.view()->buffer()->getLists();
51 Buffer::Lists::const_iterator cit = tmp.begin();
52 Buffer::Lists::const_iterator end = tmp.end();
54 for (; cit != end; ++cit) {
55 types.push_back(cit->first.c_str());
62 Buffer::SingleList const ControlToc::getContents(string const & type) const
64 Buffer::SingleList contents;
66 Buffer::TocItem noContent(0, 0, string());
68 // This shouldn't be possible...
69 if (!lv_.view()->available()) {
70 noContent.str = _("*** No Document ***");
71 contents.push_back(noContent);
75 Buffer::Lists tmp = lv_.view()->buffer()->getLists();
77 Buffer::Lists::iterator it = tmp.find(type);
79 if (it == tmp.end()) {
80 noContent.str = _("*** No Lists ***");
81 contents.push_back(noContent);
92 string getType(string const & cmdName)
96 // It would be nice to have a map to extract this info.
97 // Does one already exist, Lars?
98 if (cmdName == "tableofcontents" )
101 else if (cmdName == "listofalgorithms" )
104 else if (cmdName == "listoffigures" )