3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Angus Leeming
8 * Full author contact details are available in file CREDITS.
15 #include "ControlToc.h"
17 #include "BufferView.h"
18 #include "bufferparams.h"
20 #include "FloatList.h"
21 #include "funcrequest.h"
24 #include "frontends/LyXView.h"
26 #include "support/convert.h"
38 ControlToc::ControlToc(Dialog & d)
39 : ControlCommand(d, "tableofcontents", "toc")
43 void ControlToc::goTo(TocItem const & item)
45 string const tmp = convert<string>(item.id());
46 kernel().lyxview().dispatch(FuncRequest(LFUN_PARAGRAPH_GOTO, tmp));
50 bool ControlToc::canOutline(string const & type)
52 return type == "tableofcontents";
56 void ControlToc::outlineUp()
58 kernel().dispatch(FuncRequest(LFUN_OUTLINE_UP));
62 void ControlToc::outlineDown()
64 kernel().dispatch(FuncRequest(LFUN_OUTLINE_DOWN));
68 void ControlToc::outlineIn()
70 kernel().dispatch(FuncRequest(LFUN_OUTLINE_IN));
74 void ControlToc::outlineOut()
76 kernel().dispatch(FuncRequest(LFUN_OUTLINE_OUT));
80 vector<string> const & ControlToc::getTypes() const
82 return kernel().buffer().tocBackend().types();
86 TocIterator const ControlToc::getCurrentTocItem(
87 string const & type) const
89 BOOST_ASSERT(kernel().bufferview());
91 ParConstIterator it(kernel().bufferview()->cursor());
92 return kernel().buffer().tocBackend().item(type, it);
96 string const ControlToc::getGuiName(string const & type) const
98 if (type == "tableofcontents")
99 return lyx::to_utf8(_("Table of Contents"));
101 FloatList const & floats =
102 kernel().buffer().params().getLyXTextClass().floats();
103 if (floats.typeExist(type))
104 return floats.getType(type).name();
106 return lyx::to_utf8(_(type));
110 Toc const empty_list;
112 Toc const & ControlToc::getContents(string const & type) const
114 // This shouldn't be possible...
115 if (!kernel().isBufferAvailable()) {
119 return kernel().buffer().tocBackend().toc(type);
122 } // namespace frontend