}
-void Menu::read(LyXLex & lex)
+Menu & Menu::read(LyXLex & lex)
{
enum Menutags {
md_item = 1,
}
}
lex.popTable();
+ return *this;
}
lex.printTable(lyxerr);
bool quit = false;
+ bool menubar = false;
while (lex.IsOK() && !quit) {
switch(lex.lex()) {
+ case md_menubar:
+ menubar = true;
+ // fallback to md_menu
case md_menu: {
lex.next();
string name = lex.GetString();
- Menu menu(name, false);
- menu.read(lex);
- add(menu);
- break;
- }
- case md_menubar: {
- lex.next();
- string name = lex.GetString();
- Menu menubar(name, true);
- menubar.read(lex);
- add(menubar);
+ if (hasMenu(name)) {
+ if (getMenu(name).menubar() == menubar) {
+ getMenu(name).read(lex);
+ } else {
+ lex.printError("Cannot append to menu `$$Token' unless it is of the same type");
+ return;
+ }
+ } else {
+ Menu menu(name, menubar);
+ menu.read(lex);
+ add(menu);
+ }
+ menubar = false;
break;
}
case md_endmenuset:
bool MenuBackend::hasMenu(string const & name) const
{
- for (const_iterator cit = begin(); cit != end(); ++cit) {
+ const_iterator mend = end();
+ for (const_iterator cit = begin(); cit != mend; ++cit) {
if ((*cit).name() == name)
return true;
}
Menu const & MenuBackend::getMenu(string const & name) const
{
- for (const_iterator cit = begin(); cit != end(); ++cit) {
+ const_iterator mend = end();
+ for (const_iterator cit = begin(); cit != mend; ++cit) {
if ((*cit).name() == name)
return (*cit);
}
Assert(false); // we actually require the name to exist.
return menulist_.front();
}
+
+
+Menu & MenuBackend::getMenu(string const & name)
+{
+ MenuList::iterator end = menulist_.end();
+ for (MenuList::iterator cit = menulist_.begin();
+ cit != end; ++cit) {
+ if ((*cit).name() == name)
+ return (*cit);
+ }
+ Assert(false); // we actually require the name to exist.
+ return menulist_.front();
+}
+