summaryrefslogtreecommitdiff
path: root/chart2
diff options
context:
space:
mode:
authorTamás Zolnai <tamas.zolnai@collabora.com>2019-11-21 16:13:06 +0100
committerAndras Timar <andras.timar@collabora.com>2020-05-13 18:44:27 +0200
commitdbbe8972b3386b7dbd09ac24ea0f108ad68d815f (patch)
treecb004a7e784cc0689c804c1de830a77f57848cf9 /chart2
parenteef4c4c6b399e5d6814f22277a0d9f33806d5891 (diff)
lok: Chart context menu: Replace tunneled context menu with JS context menu.
Change-Id: I36db90887bff86036093ce0732db6fc6c76e79f6 Reviewed-on: https://gerrit.libreoffice.org/83604 Tested-by: Jenkins Reviewed-by: Tamás Zolnai <tamas.zolnai@collabora.com>
Diffstat (limited to 'chart2')
-rw-r--r--chart2/source/controller/main/ChartController_Window.cxx38
1 files changed, 20 insertions, 18 deletions
diff --git a/chart2/source/controller/main/ChartController_Window.cxx b/chart2/source/controller/main/ChartController_Window.cxx
index 83411df39171..c4f20d871aa7 100644
--- a/chart2/source/controller/main/ChartController_Window.cxx
+++ b/chart2/source/controller/main/ChartController_Window.cxx
@@ -83,6 +83,9 @@
#include <sal/log.hxx>
#include <sfx2/lokhelper.hxx>
+#include <boost/property_tree/json_parser.hpp>
+#include <sfx2/dispatch.hxx>
+#include <LibreOfficeKit/LibreOfficeKitEnums.h>
#define DRGPIX 2 // Drag MinMove in Pixel
@@ -1273,29 +1276,28 @@ void ChartController::execute_Command( const CommandEvent& rCEvt )
if ( !xPopupController.is() || !xPopupMenu.is() )
return;
+ xPopupController->setPopupMenu( xPopupMenu );
+
if (comphelper::LibreOfficeKit::isActive())
{
- PopupMenu* pPopupMenu = static_cast<PopupMenu*>(comphelper::getUnoTunnelImplementation<VCLXMenu>(xPopupMenu)->GetMenu());
- pPopupMenu->SetLOKNotifier(SfxViewShell::Current());
-
- // the context menu expects a position related to the document window,
- // not to the chart window
- SfxInPlaceClient* pIPClient = SfxViewShell::Current()->GetIPClient();
- if (pIPClient)
+ if (SfxViewShell* pViewShell = SfxViewShell::Current())
{
- vcl::Window* pRootWin = pIPClient->GetEditWin();
- if (pRootWin)
- {
- Point aOffset = pChartWindow->GetOffsetPixelFrom(*pRootWin);
- aPos += aOffset;
- }
+ PopupMenu* pPopupMenu = static_cast<PopupMenu*>(comphelper::getUnoTunnelImplementation<VCLXMenu>(xPopupMenu)->GetMenu());
+ boost::property_tree::ptree aMenu = SfxDispatcher::fillPopupMenu(pPopupMenu);
+ 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());
}
}
-
- xPopupController->setPopupMenu( xPopupMenu );
- xPopupMenu->execute( css::uno::Reference< css::awt::XWindowPeer >( m_xFrame->getContainerWindow(), css::uno::UNO_QUERY ),
- css::awt::Rectangle( aPos.X(), aPos.Y(), 0, 0 ),
- css::awt::PopupMenuDirection::EXECUTE_DEFAULT );
+ else
+ {
+ xPopupMenu->execute( css::uno::Reference< css::awt::XWindowPeer >( m_xFrame->getContainerWindow(), css::uno::UNO_QUERY ),
+ css::awt::Rectangle( aPos.X(), aPos.Y(), 0, 0 ),
+ css::awt::PopupMenuDirection::EXECUTE_DEFAULT );
+ }
css::uno::Reference< css::lang::XComponent > xComponent( xPopupController, css::uno::UNO_QUERY );
if ( xComponent.is() )