[Libreoffice-commits] core.git: chart2/source desktop/source
Tamás Zolnai (via logerrit)
logerrit at kemper.freedesktop.org
Sun Nov 24 12:41:49 UTC 2019
chart2/source/controller/main/ChartController_Window.cxx | 38 +++++++--------
desktop/source/lib/init.cxx | 14 ++++-
2 files changed, 32 insertions(+), 20 deletions(-)
New commits:
commit 08d0326cd2125dabb94102adaf06e34fc49974bc
Author: Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Thu Nov 21 16:13:06 2019 +0100
Commit: Tamás Zolnai <tamas.zolnai at collabora.com>
CommitDate: Sun Nov 24 13:40:45 2019 +0100
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 at collabora.com>
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() )
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 9298be14c0dc..a5100da75627 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -3470,7 +3470,7 @@ static void doc_postUnoCommand(LibreOfficeKitDocument* pThis, const char* pComma
}
}
- if (aChartHelper.GetWindow())
+ if (aChartHelper.GetWindow() && aPropertyValuesVector.size() > 0)
{
if (aPropertyValuesVector[0].Name != "Action")
{
@@ -3502,7 +3502,17 @@ static void doc_postUnoCommand(LibreOfficeKitDocument* pThis, const char* pComma
}
bool bResult = false;
- if (bNotifyWhenFinished && pDocument->mpCallbackFlushHandlers.count(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.count(nView))
{
bResult = comphelper::dispatchCommand(aCommand, comphelper::containerToSequence(aPropertyValuesVector),
new DispatchResultListener(pCommand, pDocument->mpCallbackFlushHandlers[nView]));
More information about the Libreoffice-commits
mailing list