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