summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2017-02-21 14:21:31 +0000
committerCaolán McNamara <caolanm@redhat.com>2017-02-21 16:18:06 +0000
commit342238a320b057d2aab401e29a44fc8f96a3da6a (patch)
treef4e2958592c78a19a55bd2fb36d69e92e3b3d7e7
parent1d8fe6a7c6bbaa7d3a5eff8a7a6b5e613bb61b28 (diff)
improve loading submenus from .ui
Change-Id: Ida5382bffa3cee55ffa64fd50d3733a178afa639
-rw-r--r--include/vcl/builder.hxx1
-rw-r--r--vcl/source/window/builder.cxx19
2 files changed, 10 insertions, 10 deletions
diff --git a/include/vcl/builder.hxx b/include/vcl/builder.hxx
index 057737294924..d8de47416fb0 100644
--- a/include/vcl/builder.hxx
+++ b/include/vcl/builder.hxx
@@ -366,6 +366,7 @@ private:
void insertMenuObject(
PopupMenu *pParent,
+ PopupMenu *pSubMenu,
const OString &rClass,
const OString &rID,
stringmap &rProps,
diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx
index f24029d677f7..d6f2d123704a 100644
--- a/vcl/source/window/builder.cxx
+++ b/vcl/source/window/builder.cxx
@@ -2561,6 +2561,7 @@ void VclBuilder::handleMenuObject(PopupMenu *pParent, xmlreader::XmlReader &read
OString sClass;
OString sID;
OString sCustomProperty;
+ PopupMenu *pSubMenu = nullptr;
xmlreader::Span name;
int nsId;
@@ -2607,11 +2608,10 @@ void VclBuilder::handleMenuObject(PopupMenu *pParent, xmlreader::XmlReader &read
{
if (name.equals("child"))
{
- insertMenuObject(pParent, sClass, sID, aProperties, aAccelerators);
- VclPtr<PopupMenu> xSubMenu = VclPtr<PopupMenu>::Create();
- pParent->SetPopupMenu(pParent->GetItemCount(), xSubMenu);
- handleMenuChild(xSubMenu, reader);
- bInserted = true;
+ size_t nChildMenuIdx = m_aMenus.size();
+ handleChild(nullptr, reader);
+ assert(m_aMenus.size() > nChildMenuIdx && "menu not inserted");
+ pSubMenu = m_aMenus[nChildMenuIdx].m_pMenu;
}
else
{
@@ -2635,7 +2635,7 @@ void VclBuilder::handleMenuObject(PopupMenu *pParent, xmlreader::XmlReader &read
if (bInserted)
return;
- insertMenuObject(pParent, sClass, sID, aProperties, aAccelerators);
+ insertMenuObject(pParent, pSubMenu, sClass, sID, aProperties, aAccelerators);
}
void VclBuilder::handleSizeGroup(xmlreader::XmlReader &reader, const OString &rID)
@@ -2736,12 +2736,9 @@ namespace
}
}
-void VclBuilder::insertMenuObject(PopupMenu *pParent, const OString &rClass, const OString &rID,
+void VclBuilder::insertMenuObject(PopupMenu *pParent, PopupMenu *pSubMenu, const OString &rClass, const OString &rID,
stringmap &rProps, accelmap &rAccels)
{
- if (rClass == "GtkMenu")
- return;
-
sal_uInt16 nOldCount = pParent->GetItemCount();
sal_uInt16 nNewId = nOldCount + 1;
@@ -2751,6 +2748,8 @@ void VclBuilder::insertMenuObject(PopupMenu *pParent, const OString &rClass, con
OUString aCommand(OStringToOUString(extractActionName(rProps), RTL_TEXTENCODING_UTF8));
pParent->InsertItem(nNewId, sLabel, MenuItemBits::TEXT, rID);
pParent->SetItemCommand(nNewId, aCommand);
+ if (pSubMenu)
+ pParent->SetPopupMenu(nNewId, pSubMenu);
}
else if (rClass == "GtkCheckMenuItem")
{