]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ControlToc.C
This file is part of LyX, the document processor.
[lyx.git] / src / frontends / controllers / ControlToc.C
1 /**
2  * \file ControlToc.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Angus Leeming
7  *
8  * Full author contact details are available in file CREDITS
9  */
10
11 #include <config.h>
12
13 #ifdef __GNUG__
14 #pragma implementation
15 #endif
16
17 #include "ControlToc.h"
18 #include "toc.h"
19
20 #include "support/lstrings.h" // tostr
21
22 using std::vector;
23
24 class Buffer;
25
26 ControlToc::ControlToc(LyXView & lv, Dialogs & d)
27         : ControlCommand(lv, d, LFUN_TOC_INSERT)
28 {}
29
30
31 void ControlToc::goTo(toc::TocItem const & item) const
32 {
33         item.goTo(lv_);
34 }
35
36
37 vector<string> const ControlToc::getTypes() const
38 {
39         return toc::getTypes(buffer());
40 }
41
42
43 toc::Toc const ControlToc::getContents(string const & type) const
44 {
45         toc::Toc empty_list;
46
47         // This shouldn't be possible...
48         if (!bufferIsAvailable()) {
49                 return empty_list;
50         }
51
52         toc::TocList tmp = toc::getTocList(buffer());
53         toc::TocList::iterator it = tmp.find(type);
54         if (it == tmp.end()) {
55                 return empty_list;
56         }
57
58         return it->second;
59 }