X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FMenuBackend.C;h=5944a2264f9631015bed901e9bc62fdea5a31d53;hb=35204f8f33d7400a5fefeffea533fb4cb4097211;hp=8fe76f10870cd2e69c282af8b6efdbfe449cdf47;hpb=ec30adf554b658fd5286ba3ed1d43d40a621c3a8;p=lyx.git diff --git a/src/MenuBackend.C b/src/MenuBackend.C index 8fe76f1087..5944a2264f 100644 --- a/src/MenuBackend.C +++ b/src/MenuBackend.C @@ -35,7 +35,8 @@ #include "lyx_main.h" // for lastfiles #include "lyxfunc.h" #include "lyxlex.h" -#include "toc.h" +#include "paragraph.h" +#include "TocBackend.h" #include "ToolbarBackend.h" #include "support/filetools.h" @@ -633,22 +634,22 @@ void expandCharStyleInsert(Menu & tomenu, Buffer const * buf) Menu::size_type const max_number_of_items = 25; void expandToc2(Menu & tomenu, - lyx::toc::Toc const & toc_list, - lyx::toc::Toc::size_type from, - lyx::toc::Toc::size_type to, int depth) + Toc const & toc_list, + Toc::size_type from, + Toc::size_type to, int depth) { int shortcut_count = 0; // check whether depth is smaller than the smallest depth in toc. int min_depth = 1000; - for (lyx::toc::Toc::size_type i = from; i < to; ++i) + for (Toc::size_type i = from; i < to; ++i) min_depth = std::min(min_depth, toc_list[i].depth()); if (min_depth > depth) depth = min_depth; if (to - from <= max_number_of_items) { - for (lyx::toc::Toc::size_type i = from; i < to; ++i) { + for (Toc::size_type i = from; i < to; ++i) { docstring label(4 * max(0, toc_list[i].depth() - depth), char_type(' ')); label += limit_string_length(toc_list[i].str()); if (toc_list[i].depth() == depth @@ -660,9 +661,9 @@ void expandToc2(Menu & tomenu, FuncRequest(toc_list[i].action()))); } } else { - lyx::toc::Toc::size_type pos = from; + Toc::size_type pos = from; while (pos < to) { - lyx::toc::Toc::size_type new_pos = pos + 1; + Toc::size_type new_pos = pos + 1; while (new_pos < to && toc_list[new_pos].depth() > depth) ++new_pos; @@ -704,19 +705,28 @@ void expandToc(Menu & tomenu, Buffer const * buf) return; } + // Add an entry for the master doc if this is a child doc + Buffer const * const master = buf->getMasterBuffer(); + if (buf != master) { + ParIterator const pit = par_iterator_begin(master->inset()); + string const arg = convert(pit->id()); + FuncRequest f(LFUN_PARAGRAPH_GOTO, arg); + tomenu.add(MenuItem(MenuItem::Command, _("Master Document"), f)); + } + FloatList const & floatlist = buf->params().getLyXTextClass().floats(); - lyx::toc::TocList const & toc_list = lyx::toc::getTocList(*buf); - lyx::toc::TocList::const_iterator cit = toc_list.begin(); - lyx::toc::TocList::const_iterator end = toc_list.end(); + TocList const & toc_list = buf->tocBackend().tocs(); + TocList::const_iterator cit = toc_list.begin(); + TocList::const_iterator end = toc_list.end(); for (; cit != end; ++cit) { // Handle this later - if (cit->first == "TOC") + if (cit->first == "tableofcontents") continue; // All the rest is for floats auto_ptr menu(new Menu); - lyx::toc::Toc::const_iterator ccit = cit->second.begin(); - lyx::toc::Toc::const_iterator eend = cit->second.end(); + TocIterator ccit = cit->second.begin(); + TocIterator eend = cit->second.end(); for (; ccit != eend; ++ccit) { docstring const label = limit_string_length(ccit->str()); menu->add(MenuItem(MenuItem::Command, @@ -730,7 +740,7 @@ void expandToc(Menu & tomenu, Buffer const * buf) } // Handle normal TOC - cit = toc_list.find("TOC"); + cit = toc_list.find("tableofcontents"); if (cit == end) { tomenu.addWithStatusCheck(MenuItem(MenuItem::Command, _("No Table of contents"),