#include "gettext.h"
#include "importer.h"
#include "kbmap.h"
-#include "lastfiles.h"
+#include "session.h"
#include "LyXAction.h"
#include "lyx_main.h" // for lastfiles
#include "lyxfunc.h"
using lyx::support::compare_ascii_no_case;
using lyx::support::contains;
-using lyx::support::MakeDisplayPath;
+using lyx::support::makeDisplayPath;
using lyx::support::token;
using boost::bind;
void expandLastfiles(Menu & tomenu, LyXView const * view)
{
- LastFiles const & lastfiles = LyX::cref().lastfiles();
+ lyx::Session::LastFiles const & lf = LyX::cref().session().lastFiles();
+ lyx::Session::LastFiles::const_iterator lfit = lf.begin();
int ii = 1;
- LastFiles::const_iterator lfit = lastfiles.begin();
- LastFiles::const_iterator end = lastfiles.end();
- for (; lfit != end && ii < 10; ++lfit, ++ii) {
+ for (; lfit != lf.end() && ii < 10; ++lfit, ++ii) {
string const label = convert<string>(ii) + ". "
- + MakeDisplayPath((*lfit), 30)
+ + makeDisplayPath((*lfit), 30)
+ '|' + convert<string>(ii);
tomenu.add(MenuItem(MenuItem::Command, label, FuncRequest(LFUN_FILE_OPEN, (*lfit))), view);
}
Strings::const_iterator docit = names.begin();
Strings::const_iterator end = names.end();
for (; docit != end; ++docit, ++ii) {
- string label = MakeDisplayPath(*docit, 20);
+ string label = makeDisplayPath(*docit, 20);
if (ii < 10)
label = convert<string>(ii) + ". " + label + '|' + convert<string>(ii);
tomenu.add(MenuItem(MenuItem::Command, label, FuncRequest(LFUN_SWITCHBUFFER, *docit)), view);
action = LFUN_IMPORT;
break;
case MenuItem::ViewFormats:
- formats = Exporter::GetExportableFormats(*view->buffer(), true);
+ formats = Exporter::getExportableFormats(*view->buffer(), true);
action = LFUN_PREVIEW;
break;
case MenuItem::UpdateFormats:
- formats = Exporter::GetExportableFormats(*view->buffer(), true);
+ formats = Exporter::getExportableFormats(*view->buffer(), true);
action = LFUN_UPDATE;
break;
default:
- formats = Exporter::GetExportableFormats(*view->buffer(), false);
+ formats = Exporter::getExportableFormats(*view->buffer(), false);
action = LFUN_EXPORT;
}
sort(formats.begin(), formats.end(), compare_format());
else if ((*fit)->name() == "textparagraph")
label = _("Plain Text as Paragraphs");
label += "...";
+ } else if (kind == MenuItem::ExportFormats) {
+ // exporting to LyX does not make sense
+ // FIXME: Introduce noexport flag
+ if ((*fit)->name() == "lyx")
+ continue;
}
if (!(*fit)->shortcut().empty())
label += '|' + (*fit)->shortcut();
// 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 (lyx::toc::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;
// know that all the entries in a TOC will be have status_ ==
// OK, so we avoid this unnecessary overhead (JMarc)
- if (!view->buffer()) {
+
+ Buffer const * buf = view->buffer();
+ if (!buf) {
tomenu.add(MenuItem(MenuItem::Command,
_("No Documents Open!"),
FuncRequest(LFUN_NOACTION)),
return;
}
- lyx::toc::TocList toc_list = lyx::toc::getTocList(*view->buffer());
+ FloatList const & floatlist = buf->params().getLyXTextClass().floats();
+ lyx::toc::TocList toc_list = lyx::toc::getTocList(*buf);
lyx::toc::TocList::const_iterator cit = toc_list.begin();
lyx::toc::TocList::const_iterator end = toc_list.end();
for (; cit != end; ++cit) {
label,
FuncRequest(ccit->action())));
}
- string const & floatName = cit->first;
- // Is the _(...) really needed here? (Lgb)
+ string const & floatName = floatlist.getType(cit->first).listName();
MenuItem item(MenuItem::Submenu, _(floatName));
item.submenu(menu.release());
tomenu.add(item);
if (!view || !view->buffer())
return;
- BufferParams const & params = view->buffer()->params();
+ BufferParams const & params = view->buffer()->getMasterBuffer()->params();
- std::list<Branch>::const_iterator cit = params.branchlist().begin();
- std::list<Branch>::const_iterator end = params.branchlist().end();
+ BranchList::const_iterator cit = params.branchlist().begin();
+ BranchList::const_iterator end = params.branchlist().end();
for (int ii = 1; cit != end; ++cit, ++ii) {
string label = cit->getBranch();
void MenuBackend::expand(Menu const & frommenu, Menu & tomenu,
LyXView const * view) const
{
+ if (!tomenu.empty())
+ tomenu.clear();
+
for (Menu::const_iterator cit = frommenu.begin();
cit != frommenu.end() ; ++cit) {
switch (cit->kind()) {