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")
44 bool ControlToc::initialiseParams(string const & data)
47 return ControlCommand::initialiseParams(data);
50 void ControlToc::goTo(TocItem const & item)
52 string const tmp = convert<string>(item.id());
53 kernel().lyxview().dispatch(FuncRequest(LFUN_PARAGRAPH_GOTO, tmp));
57 bool ControlToc::canOutline(string const & type)
59 return type == "tableofcontents";
63 void ControlToc::outlineUp()
65 kernel().dispatch(FuncRequest(LFUN_OUTLINE_UP));
69 void ControlToc::outlineDown()
71 kernel().dispatch(FuncRequest(LFUN_OUTLINE_DOWN));
75 void ControlToc::outlineIn()
77 kernel().dispatch(FuncRequest(LFUN_OUTLINE_IN));
81 void ControlToc::outlineOut()
83 kernel().dispatch(FuncRequest(LFUN_OUTLINE_OUT));
87 vector<string> const & ControlToc::getTypes() const
89 return kernel().buffer().tocBackend().types();
93 void ControlToc::updateBackend()
95 kernel().buffer().tocBackend().update();
99 TocIterator const ControlToc::getCurrentTocItem(
100 string const & type) const
102 BOOST_ASSERT(kernel().bufferview());
104 ParConstIterator it(kernel().bufferview()->cursor());
105 return kernel().buffer().tocBackend().item(type, it);
109 docstring const ControlToc::getGuiName(string const & type) const
111 if (type == "tableofcontents")
112 return _("Table of Contents");
114 FloatList const & floats =
115 kernel().buffer().params().getLyXTextClass().floats();
116 if (floats.typeExist(type))
117 return from_utf8(floats.getType(type).name());
123 Toc const empty_list;
125 Toc const & ControlToc::getContents(string const & type) const
127 // This shouldn't be possible...
128 if (!kernel().isBufferAvailable()) {
132 return kernel().buffer().tocBackend().toc(type);
135 } // namespace frontend