diff options
Diffstat (limited to 'chart2/source/controller')
-rw-r--r-- | chart2/source/controller/main/ChartController_Window.cxx | 36 |
1 files changed, 19 insertions, 17 deletions
diff --git a/chart2/source/controller/main/ChartController_Window.cxx b/chart2/source/controller/main/ChartController_Window.cxx index 83411df39171..ab04c1a941ec 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 @@ -1275,27 +1278,26 @@ void ChartController::execute_Command( const CommandEvent& rCEvt ) 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()); } } + else + { - 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 ); + 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 ); + } css::uno::Reference< css::lang::XComponent > xComponent( xPopupController, css::uno::UNO_QUERY ); if ( xComponent.is() ) |