]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ControlToc.C
Extracted from r14281
[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 <sstream>
12
13 #include <config.h>
14
15 #include "ControlToc.h"
16 #include "funcrequest.h"
17 #include "gettext.h"
18 #include "BufferView.h"
19 #include "debug.h"
20
21 using std::vector;
22 using std::string;
23
24
25 class Buffer;
26
27 namespace lyx {
28 namespace frontend {
29
30
31 ControlToc::ControlToc(Dialog & d)
32         : ControlCommand(d, "toc")
33 {}
34
35
36 void ControlToc::goTo(toc::TocItem const & item)
37 {
38         item.goTo(kernel().lyxview());
39 }
40
41
42 bool ControlToc::canOutline(string const & type)
43 {
44         return type == "TOC";
45 }
46
47
48 void ControlToc::outlineUp()
49 {
50         kernel().dispatch(FuncRequest(LFUN_OUTLINE_UP));
51 }
52
53
54 void ControlToc::outlineDown()
55 {
56         kernel().dispatch(FuncRequest(LFUN_OUTLINE_DOWN));
57 }
58
59
60 void ControlToc::outlineIn()
61 {
62         kernel().dispatch(FuncRequest(LFUN_OUTLINE_IN));
63 }
64
65
66 void ControlToc::outlineOut()
67 {
68         kernel().dispatch(FuncRequest(LFUN_OUTLINE_OUT));
69 }
70
71
72 vector<string> const & ControlToc::getTypes() const
73 {
74         return toc::getTypes(kernel().buffer());
75 }
76
77
78 toc::TocIterator const ControlToc::getCurrentTocItem(
79         string const & type) const
80 {
81         BOOST_ASSERT(kernel().bufferview());
82
83         return toc::getCurrentTocItem(kernel().buffer(),
84                 kernel().bufferview()->cursor(), type);
85 }
86
87
88 string const ControlToc::getGuiName(string const & type) const
89 {
90         if (type == "TOC")
91                 return _("Table of Contents");
92         else
93                 return _(toc::getGuiName(type, kernel().buffer()));
94 }
95
96
97 toc::Toc const empty_list;
98
99 toc::Toc const & ControlToc::getContents(string const & type) const
100 {
101         // This shouldn't be possible...
102         if (!kernel().isBufferAvailable()) {
103                 return empty_list;
104         }
105
106         return toc::getToc(kernel().buffer(), type);
107 }
108
109 } // namespace frontend
110 } // namespace lyx