+
+void expandFloatListInsert(Menu & tomenu, Buffer const * buf)
+{
+ if (!buf) {
+ tomenu.add(MenuItem(MenuItem::Command,
+ _("No Documents Open!"), LFUN_NOACTION));
+ return;
+ }
+
+ FloatList const & floats = buf->params.getLyXTextClass().floats();
+ FloatList::const_iterator cit = floats.begin();
+ FloatList::const_iterator end = floats.end();
+ for (; cit != end; ++cit) {
+ int const action = lyxaction
+ .getPseudoAction(LFUN_FLOAT_LIST, cit->second.type());
+ tomenu.add(MenuItem(MenuItem::Command,
+ _(cit->second.listName()),
+ action));
+ }
+}
+
+
+void expandFloatInsert(Menu & tomenu, Buffer const * buf)
+{
+ if (!buf) {
+ tomenu.add(MenuItem(MenuItem::Command,
+ _("No Documents Open!"), LFUN_NOACTION));
+ return;
+ }
+
+ FloatList const & floats = buf->params.getLyXTextClass().floats();
+ FloatList::const_iterator cit = floats.begin();
+ FloatList::const_iterator end = floats.end();
+ for (; cit != end; ++cit) {
+ // normal float
+ int const action =
+ lyxaction.getPseudoAction(LFUN_INSET_FLOAT,
+ cit->second.type());
+ string const label = _(cit->second.name());
+ tomenu.add(MenuItem(MenuItem::Command, label, action));
+ }
+}
+
+
+Menu::size_type const max_number_of_items = 25;
+
+void expandToc2(Menu & tomenu, toc::Toc const & toc_list,
+ toc::Toc::size_type from, toc::Toc::size_type to, int depth)
+{
+ int shortcut_count = 0;
+ if (to - from <= max_number_of_items) {
+ for (toc::Toc::size_type i = from; i < to; ++i) {
+ int const action = toc_list[i].action();
+ string label(4 * max(0, toc_list[i].depth - depth),' ');
+ label += limit_string_length(toc_list[i].str);
+ if (toc_list[i].depth == depth
+ && ++shortcut_count <= 9) {
+ label += '|' + tostr(shortcut_count);
+ }
+ tomenu.add(MenuItem(MenuItem::Command, label, action));
+ }
+ } else {
+ toc::Toc::size_type pos = from;
+ while (pos < to) {
+ toc::Toc::size_type new_pos = pos + 1;
+ while (new_pos < to &&
+ toc_list[new_pos].depth > depth)
+ ++new_pos;
+
+ int const action = toc_list[pos].action();
+ string label(4 * max(0, toc_list[pos].depth - depth), ' ');
+ label += limit_string_length(toc_list[pos].str);
+ if (toc_list[pos].depth == depth &&
+ ++shortcut_count <= 9)
+ label += '|' + tostr(shortcut_count);
+
+ if (new_pos == pos + 1) {