diff options
-rw-r--r-- | chart2/source/controller/main/ChartController_Window.cxx | 38 | ||||
-rw-r--r-- | desktop/source/lib/init.cxx | 14 |
2 files changed, 32 insertions, 20 deletions
diff --git a/chart2/source/controller/main/ChartController_Window.cxx b/chart2/source/controller/main/ChartController_Window.cxx index 9a0c19544c70..6c9ba58839fb 100644 --- a/chart2/source/controller/main/ChartController_Window.cxx +++ b/chart2/source/controller/main/ChartController_Window.cxx @@ -84,6 +84,9 @@ #include <comphelper/lok.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*>(VCLXMenu::GetImplementation(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*>(VCLXMenu::GetImplementation( 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() ) diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 5a9cd839fd0c..9f4dfa961a20 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -3476,7 +3476,7 @@ static void doc_postUnoCommand(LibreOfficeKitDocument* pThis, const char* pComma } } - if (aChartHelper.GetWindow()) + if (aChartHelper.GetWindow() && aPropertyValuesVector.size() > 0) { if (aPropertyValuesVector[0].Name != "Action") { @@ -3509,7 +3509,17 @@ static void doc_postUnoCommand(LibreOfficeKitDocument* pThis, const char* pComma } bool bResult = false; - if (bNotifyWhenFinished && pDocument->mpCallbackFlushHandlers[nView]) + LokChartHelper aChartHelper(SfxViewShell::Current()); + + if (aChartHelper.GetWindow() ) + { + util::URL aCommandURL; + aCommandURL.Path = aCommand.copy(5); + css::uno::Reference<css::frame::XDispatch>& aChartDispatcher = aChartHelper.GetXDispatcher(); + aChartDispatcher->dispatch(aCommandURL, comphelper::containerToSequence(aPropertyValuesVector)); + return; + } + else if (bNotifyWhenFinished && pDocument->mpCallbackFlushHandlers[nView]) { bResult = comphelper::dispatchCommand(aCommand, comphelper::containerToSequence(aPropertyValuesVector), new DispatchResultListener(pCommand, pDocument->mpCallbackFlushHandlers[nView])); |