/** * \file ControlToc.C * This file is part of LyX, the document processor. * Licence details can be found in the file COPYING. * * \author Angus Leeming * * Full author contact details are available in file CREDITS. */ #include #include #include "ControlToc.h" #include "buffer.h" #include "BufferView.h" #include "bufferparams.h" #include "debug.h" #include "FloatList.h" #include "funcrequest.h" #include "gettext.h" #include "frontends/LyXView.h" #include "support/convert.h" using std::vector; using std::string; class Buffer; namespace lyx { namespace frontend { ControlToc::ControlToc(Dialog & d) : ControlCommand(d, "tableofcontents", "toc") { } bool ControlToc::initialiseParams(string const & data) { update(); return ControlCommand::initialiseParams(data); } void ControlToc::goTo(TocItem const & item) { string const tmp = convert(item.id()); kernel().lyxview().dispatch(FuncRequest(LFUN_PARAGRAPH_GOTO, tmp)); } bool ControlToc::canOutline(string const & type) { return type == "tableofcontents"; } void ControlToc::outlineUp() { kernel().dispatch(FuncRequest(LFUN_OUTLINE_UP)); } void ControlToc::outlineDown() { kernel().dispatch(FuncRequest(LFUN_OUTLINE_DOWN)); } void ControlToc::outlineIn() { kernel().dispatch(FuncRequest(LFUN_OUTLINE_IN)); } void ControlToc::outlineOut() { kernel().dispatch(FuncRequest(LFUN_OUTLINE_OUT)); } vector const & ControlToc::getTypes() const { return kernel().buffer().tocBackend().types(); } void ControlToc::updateBackend() { kernel().buffer().tocBackend().update(); } TocIterator const ControlToc::getCurrentTocItem( string const & type) const { BOOST_ASSERT(kernel().bufferview()); ParConstIterator it(kernel().bufferview()->cursor()); return kernel().buffer().tocBackend().item(type, it); } docstring const ControlToc::getGuiName(string const & type) const { if (type == "tableofcontents") return _("Table of Contents"); FloatList const & floats = kernel().buffer().params().getLyXTextClass().floats(); if (floats.typeExist(type)) return from_utf8(floats.getType(type).name()); else return _(type); } Toc const empty_list; Toc const & ControlToc::getContents(string const & type) const { // This shouldn't be possible... if (!kernel().isBufferAvailable()) { return empty_list; } return kernel().buffer().tocBackend().toc(type); } } // namespace frontend } // namespace lyx