summaryrefslogtreecommitdiff
path: root/sfx2/source
diff options
context:
space:
mode:
authorJan Holesovsky <kendy@collabora.com>2016-04-08 09:15:55 +0200
committerAshod Nakashian <ashod.nakashian@collabora.co.uk>2016-07-12 22:06:32 -0400
commit4efa3f1a5426dd53b33c4cef6b2f9d44df17519b (patch)
tree8aacbe7168ed0051a2349c4e961a645a93c35805 /sfx2/source
parente6e379a2b637792a89fab369e759c7c920531990 (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 (cherry picked from commit 788616fe7ce7c56d9dcfccafdd3e1f55036aa8a7)
Diffstat (limited to 'sfx2/source')
-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 e493302d97b9..cf1e2b10f43b 100644
--- a/sfx2/source/control/dispatch.cxx
+++ b/sfx2/source/control/dispatch.cxx
@@ -182,57 +182,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())