[Libreoffice-commits] core.git: editeng/source
Caolán McNamara (via logerrit)
logerrit at kemper.freedesktop.org
Thu Dec 17 21:01:54 UTC 2020
editeng/source/editeng/editview.cxx | 80 ++++++++++++++++++++++++++----------
1 file changed, 59 insertions(+), 21 deletions(-)
New commits:
commit 493429cc91d41b719d446e43415f43fb9fa5aee4
Author: Caolán McNamara <caolanm at redhat.com>
AuthorDate: Thu Dec 17 15:49:23 2020 +0000
Commit: Caolán McNamara <caolanm at redhat.com>
CommitDate: Thu Dec 17 22:01:15 2020 +0100
drop dumping intermediate popup menu and go straight to boost::property_tree
Change-Id: I1209cf14cd23adee9ecf01b73bfcc95b80dea07a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107887
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/editeng/source/editeng/editview.cxx b/editeng/source/editeng/editview.cxx
index 00be3ff442ef..491c88670f44 100644
--- a/editeng/source/editeng/editview.cxx
+++ b/editeng/source/editeng/editview.cxx
@@ -880,33 +880,71 @@ static void LOKSendSpellPopupMenu(Menu* pMenu, LanguageType nGuessLangWord,
if (!comphelper::LibreOfficeKit::isActive())
return;
- // First we need to set item commands for the context menu.
- OUString aTmpWord( SvtLanguageTable::GetLanguageString( nGuessLangWord ) );
- OUString aTmpPara( SvtLanguageTable::GetLanguageString( nGuessLangPara ) );
+ // Generate the menu structure and send it to the client code.
+ SfxViewShell* pViewShell = SfxViewShell::Current();
+ if (!pViewShell)
+ return;
- pMenu->SetItemCommand(pMenu->GetItemId("ignore"), ".uno:SpellCheckIgnoreAll?Type:string=Spelling");
- pMenu->SetItemCommand(MN_WORDLANGUAGE, ".uno:LanguageStatus?Language:string=Current_" + aTmpWord);
- pMenu->SetItemCommand(MN_PARALANGUAGE, ".uno:LanguageStatus?Language:string=Paragraph_" + aTmpPara);
+ boost::property_tree::ptree aMenu;
- for(int i = 0; i < nSuggestions; ++i)
+ boost::property_tree::ptree aItemTree;
+ if (nSuggestions)
{
- sal_uInt16 nItemId = MN_ALTSTART + i;
- OUString sCommandString = ".uno:SpellCheckApplySuggestion?ApplyRule:string=Spelling_" + pMenu->GetItemText(nItemId);
- pMenu->SetItemCommand(nItemId, sCommandString);
+ for(int i = 0; i < nSuggestions; ++i)
+ {
+ sal_uInt16 nItemId = MN_ALTSTART + i;
+ OUString sText = pMenu->GetItemText(nItemId);
+ aItemTree.put("text", sText.toUtf8().getStr());
+ aItemTree.put("type", "command");
+ OUString sCommandString = ".uno:SpellCheckApplySuggestion?ApplyRule:string=Spelling_" + sText;
+ aItemTree.put("command", sCommandString.toUtf8().getStr());
+ aItemTree.put("enabled", pMenu->IsItemEnabled(nItemId));
+ aMenu.push_back(std::make_pair("", aItemTree));
+ aItemTree.clear();
+ }
+
+ aItemTree.put("type", "separator");
+ aMenu.push_back(std::make_pair("", aItemTree));
+ aItemTree.clear();
}
- // Then we generate the menu structure and send it to the client code.
- if (SfxViewShell* pViewShell = SfxViewShell::Current())
- {
- boost::property_tree::ptree aMenu = SfxDispatcher::fillPopupMenu(pMenu);
- boost::property_tree::ptree aRoot;
- aRoot.add_child("menu", aMenu);
+ // First we need to set item commands for the context menu.
+ OUString aTmpWord( SvtLanguageTable::GetLanguageString( nGuessLangWord ) );
+ OUString aTmpPara( SvtLanguageTable::GetLanguageString( nGuessLangPara ) );
- std::stringstream aStream;
- boost::property_tree::write_json(aStream, aRoot, true);
- pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_CONTEXT_MENU, aStream.str().c_str());
- return;
- }
+ aItemTree.put("text", pMenu->GetItemText(pMenu->GetItemId("ignore")).toUtf8().getStr());
+ aItemTree.put("type", "command");
+ aItemTree.put("command", ".uno:SpellCheckIgnoreAll?Type:string=Spelling");
+ aItemTree.put("enabled", pMenu->IsItemEnabled(pMenu->GetItemId("ignore")));
+ aMenu.push_back(std::make_pair("", aItemTree));
+ aItemTree.clear();
+
+ aItemTree.put("type", "separator");
+ aMenu.push_back(std::make_pair("", aItemTree));
+ aItemTree.clear();
+
+ aItemTree.put("text", pMenu->GetItemText(MN_WORDLANGUAGE).toUtf8().getStr());
+ aItemTree.put("type", "command");
+ OUString sCommandString = ".uno:LanguageStatus?Language:string=Current_" + aTmpWord;
+ aItemTree.put("command", sCommandString.toUtf8().getStr());
+ aItemTree.put("enabled", pMenu->IsItemEnabled(MN_WORDLANGUAGE));
+ aMenu.push_back(std::make_pair("", aItemTree));
+ aItemTree.clear();
+
+ aItemTree.put("text", pMenu->GetItemText(MN_PARALANGUAGE).toUtf8().getStr());
+ aItemTree.put("type", "command");
+ sCommandString = ".uno:LanguageStatus?Language:string=Paragraph_" + aTmpPara;
+ aItemTree.put("command", sCommandString.toUtf8().getStr());
+ aItemTree.put("enabled", pMenu->IsItemEnabled(MN_PARALANGUAGE));
+ aMenu.push_back(std::make_pair("", aItemTree));
+ aItemTree.clear();
+
+ boost::property_tree::ptree aRoot;
+ aRoot.add_child("menu", aMenu);
+
+ std::stringstream aStream;
+ boost::property_tree::write_json(aStream, aRoot, true);
+ pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_CONTEXT_MENU, aStream.str().c_str());
}
void EditView::ExecuteSpellPopup( const Point& rPosPixel, Link<SpellCallbackInfo&,void> const * pCallBack )
More information about the Libreoffice-commits
mailing list