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
31 ControlToc::ControlToc(LyXView & lv, Dialogs & d)
32 : ControlCommand(lv, d, LFUN_TOC_INSERT)
34 d_.showTOC.connect(slot(this, &ControlToc::showInset));
35 d_.createTOC.connect(slot(this, &ControlToc::createInset));
39 void ControlToc::Goto(int const & id) const
41 string const tmp = tostr(id);
42 lv_.getLyXFunc()->Dispatch(LFUN_GOTO_PARAGRAPH, tmp);
46 vector<string> const ControlToc::getTypes() const
50 Buffer::Lists const tmp = lv_.view()->buffer()->getLists();
52 Buffer::Lists::const_iterator cit = tmp.begin();
53 Buffer::Lists::const_iterator end = tmp.end();
55 for (; cit != end; ++cit) {
56 types.push_back(cit->first);
63 Buffer::SingleList const ControlToc::getContents(string const & type) const
65 Buffer::SingleList contents;
67 Buffer::TocItem noContent(0, 0, string());
69 // This shouldn't be possible...
70 if (!lv_.view()->available()) {
71 noContent.str = _("*** No Document ***");
72 contents.push_back(noContent);
76 Buffer::Lists tmp = lv_.view()->buffer()->getLists();
78 Buffer::Lists::iterator it = tmp.find(type);
80 if (it == tmp.end()) {
81 noContent.str = _("*** No Lists ***");
82 contents.push_back(noContent);
93 string getType(string const & cmdName)
97 // It would be nice to have a map to extract this info.
98 // Does one already exist, Lars?
99 if (cmdName == "tableofcontents" )
102 else if (cmdName == "listofalgorithms" )
105 else if (cmdName == "listoffigures" )