diff options
author | Tamás Zolnai <tamas.zolnai@collabora.com> | 2019-11-21 16:13:06 +0100 |
---|---|---|
committer | Tamás Zolnai <tamas.zolnai@collabora.com> | 2019-11-24 13:40:45 +0100 |
commit | 08d0326cd2125dabb94102adaf06e34fc49974bc (patch) | |
tree | 4dbcb51ec0b7fcb04828d2a51f2b3f1eddcc7115 /chart2 | |
parent | 822181788ec011418ac0ce95c57ea70feb4769f1 (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.cxx | 38 |
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() ) |