]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ControlToc.C
include sys/time.h
[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
14 #include "ControlToc.h"
15 #include "toc.h"
16
17 #include "support/lstrings.h" // tostr
18
19 using std::vector;
20
21 class Buffer;
22
23
24 ControlToc::ControlToc(LyXView & lv, Dialogs & d)
25         : ControlCommand(lv, d, LFUN_TOC_INSERT)
26 {}
27
28
29 void ControlToc::goTo(toc::TocItem const & item) const
30 {
31         item.goTo(lv_);
32 }
33
34
35 vector<string> const ControlToc::getTypes() const
36 {
37         return toc::getTypes(buffer());
38 }
39
40
41 toc::Toc const ControlToc::getContents(string const & type) const
42 {
43         toc::Toc empty_list;
44
45         // This shouldn't be possible...
46         if (!bufferIsAvailable()) {
47                 return empty_list;
48         }
49
50         toc::TocList tmp = toc::getTocList(buffer());
51         toc::TocList::iterator it = tmp.find(type);
52         if (it == tmp.end()) {
53                 return empty_list;
54         }
55
56         return it->second;
57 }