Kaydet (Commit) 788616fe authored tarafından Jan Holesovsky's avatar Jan Holesovsky

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
üst 610db8d5
......@@ -293,15 +293,22 @@ typedef enum
/**
* Context menu structure
*
* Returns the structure of context menu
* Returns the structure of context menu. Contains all the separators &
* submenus, example of the returned structure:
*
* {
* "menu": [
* {"text": "label text", "type": "command | separator | menu",
* "command | menu": "..." },
* ...
* ]
* "menu": [
* { "text": "label text1", "type": "command", "command": ".uno:Something1", "enabled": "true" },
* { "text": "label text2", "type": "command", "command": ".uno:Something2", "enabled": "false" },
* { "type": "separator" },
* { "text": "label text2", "type": "menu", "menu": [ { ... }, { ... }, ... ] },
* ...
* ]
* }
*
* The 'command' can additionally have a checkable status, like:
*
* {"text": "label text3", "type": "command", "command": ".uno:Something3", "checktype": "checkmark|radio|auto", "checked": "true|false"}
*/
LOK_CALLBACK_CONTEXT_MENU,
......
......@@ -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())
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment