]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ControlToc.C
5 new lfuns, move all apply code out of ControlDocument and into the core.
[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 #include "ControlToc.h"
14
15 using std::vector;
16 using std::string;
17
18
19 class Buffer;
20
21
22 ControlToc::ControlToc(Dialog & d)
23         : ControlCommand(d, "toc")
24 {}
25
26
27 void ControlToc::goTo(lyx::toc::TocItem const & item)
28 {
29         item.goTo(kernel().lyxview());
30 }
31
32
33 vector<string> const ControlToc::getTypes() const
34 {
35         return lyx::toc::getTypes(kernel().buffer());
36 }
37
38
39 lyx::toc::Toc const ControlToc::getContents(string const & type) const
40 {
41         lyx::toc::Toc empty_list;
42
43         // This shouldn't be possible...
44         if (!kernel().isBufferAvailable()) {
45                 return empty_list;
46         }
47
48         lyx::toc::TocList tmp = lyx::toc::getTocList(kernel().buffer());
49         lyx::toc::TocList::iterator it = tmp.find(type);
50         if (it == tmp.end()) {
51                 return empty_list;
52         }
53
54         return it->second;
55 }