summaryrefslogtreecommitdiff
path: root/chart2/source/controller/main
diff options
context:
space:
mode:
authorTamás Zolnai <tamas.zolnai@collabora.com>2019-11-21 16:13:06 +0100
committerTamás Zolnai <tamas.zolnai@collabora.com>2019-11-23 15:38:44 +0100
commit33d3d9dacb8a2f962048cd7ab701380824ae0e21 (patch)
tree4f24f7f9956f7f966e1086edd26e8c4ea1a7d480 /chart2/source/controller/main
parent62a76cc8d6c94b43c1360e436685f031129e5ab1 (diff)
lok: Chart context menu: Replace tunneled context menu with JS context menu.
Change-Id: I36db90887bff86036093ce0732db6fc6c76e79f6
Diffstat (limited to 'chart2/source/controller/main')
-rw-r--r--chart2/source/controller/main/ChartController_Window.cxx36
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() )