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