summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorJan Holesovsky <kendy@collabora.com>2016-04-08 09:15:55 +0200
committerJan Holesovsky <kendy@collabora.com>2016-04-08 09:43:56 +0200
commit788616fe7ce7c56d9dcfccafdd3e1f55036aa8a7 (patch)
treeb8ebed7fd934e0c10d80d6b8e213a413a26ffa24 /sfx2
parent610db8d5d0500aed2ca6d4da822cf70746b44d49 (diff)
lok context menu: Expose the disabled commands too.
OTOH, don't show choices that don't have the .uno: command, we have no way to handle them. Change-Id: I0df6ffe2049bbf11ba4b8931164be6a3381d3916
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/source/control/dispatch.cxx51
1 files changed, 19 insertions, 32 deletions
diff --git a/sfx2/source/control/dispatch.cxx b/sfx2/source/control/dispatch.cxx
index 7782459d5186..15681da2ac11 100644
--- a/sfx2/source/control/dispatch.cxx
+++ b/sfx2/source/control/dispatch.cxx
@@ -181,57 +181,44 @@ namespace {
const OUString aItemText = pMenu->GetItemText(nItemId);
Menu* pPopupSubmenu = pMenu->GetPopupMenu(nItemId);
- if (!pMenu->IsItemEnabled(nItemId))
- continue;
-
if (!aItemText.isEmpty())
- aItemTree.put("text", std::string(aItemText.toUtf8().getStr()));
+ aItemTree.put("text", aItemText.toUtf8().getStr());
if (pPopupSubmenu)
{
boost::property_tree::ptree aSubmenu = fillPopupMenu(pPopupSubmenu);
- if (!aSubmenu.empty())
- {
- aItemTree.put("type", "menu");
- aItemTree.push_back(std::make_pair("menu", aSubmenu));
- }
- else
- aItemTree.clear();
+ if (aSubmenu.empty())
+ continue;
+
+ aItemTree.put("type", "menu");
+ aItemTree.push_back(std::make_pair("menu", aSubmenu));
}
else
{
- if (!aCommandURL.isEmpty())
- {
- aItemTree.put("type", "command");
- aItemTree.put("command", std::string(aCommandURL.toUtf8().getStr()));
- }
+ // no point in exposing choices that don't have the .uno:
+ // command
+ if (aCommandURL.isEmpty())
+ continue;
+
+ aItemTree.put("type", "command");
+ aItemTree.put("command", aCommandURL.toUtf8().getStr());
}
+ aItemTree.put("enabled", pMenu->IsItemEnabled(nItemId));
+
MenuItemBits aItemBits = pMenu->GetItemBits(nItemId);
- bool bHasChecks = false;
+ bool bHasChecks = true;
if (aItemBits & MenuItemBits::CHECKABLE)
- {
aItemTree.put("checktype", "checkmark");
- bHasChecks = true;
- }
else if (aItemBits & MenuItemBits::RADIOCHECK)
- {
aItemTree.put("checktype", "radio");
- bHasChecks = true;
- }
else if (aItemBits & MenuItemBits::AUTOCHECK)
- {
aItemTree.put("checktype", "auto");
- bHasChecks = true;
- }
+ else
+ bHasChecks = false;
if (bHasChecks)
- {
- if (pMenu->IsItemChecked(nItemId))
- aItemTree.put("checked", "true");
- else
- aItemTree.put("checked", "false");
- }
+ aItemTree.put("checked", pMenu->IsItemChecked(nItemId));
}
if (!aItemTree.empty())