From ae94ed1ffca7ec7fa86f3fd650dbee74db0565d6 Mon Sep 17 00:00:00 2001 From: Samuel Mehrbrodt Date: Mon, 26 Aug 2019 22:04:37 +0200 Subject: tdf#74045 Make ImageMaps in slideshow clickable Change-Id: I151983ce34a58c0f0d4b1e912f43525de4c0ad28 Reviewed-on: https://gerrit.libreoffice.org/78157 Tested-by: Jenkins Reviewed-by: Samuel Mehrbrodt --- slideshow/source/engine/slide/shapemanagerimpl.cxx | 50 +++++++++++++++++++--- slideshow/source/engine/slide/shapemanagerimpl.hxx | 7 ++- slideshow/source/engine/slide/slideimpl.cxx | 3 +- 3 files changed, 53 insertions(+), 7 deletions(-) (limited to 'slideshow/source') diff --git a/slideshow/source/engine/slide/shapemanagerimpl.cxx b/slideshow/source/engine/slide/shapemanagerimpl.cxx index d498e50cf90f..54be9f9daf60 100644 --- a/slideshow/source/engine/slide/shapemanagerimpl.cxx +++ b/slideshow/source/engine/slide/shapemanagerimpl.cxx @@ -17,17 +17,26 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ - +#include +#include #include #include #include #include +#include +#include +#include +#include +#include #include "shapemanagerimpl.hxx" #include -using namespace com::sun::star; +using namespace css; +using namespace css::uno; +using namespace css::drawing; +using namespace css::system; namespace slideshow { namespace internal { @@ -36,7 +45,8 @@ ShapeManagerImpl::ShapeManagerImpl( EventMultiplexer& rMultiplexer, LayerManagerSharedPtr const& rLayerManager, CursorManager& rCursorManager, const ShapeEventListenerMap& rGlobalListenersMap, - const ShapeCursorMap& rGlobalCursorMap ): + const ShapeCursorMap& rGlobalCursorMap, + const Reference& xDrawPage ): mrMultiplexer(rMultiplexer), mpLayerManager(rLayerManager), mrCursorManager(rCursorManager), @@ -45,7 +55,8 @@ ShapeManagerImpl::ShapeManagerImpl( EventMultiplexer& rMultiplexer, maShapeListenerMap(), maShapeCursorMap(), maHyperlinkShapes(), - mbEnabled(false) + mbEnabled(false), + mxDrawPage(xDrawPage) { } @@ -126,6 +137,17 @@ bool ShapeManagerImpl::handleMouseReleased( awt::MouseEvent const& e ) return true; // event consumed } + // tdf#74045 Handle ImageMaps + OUString const imageMapLink(checkForImageMap(e)); + if (!imageMapLink.isEmpty()) + { + Reference exec( + SystemShellExecute::create(comphelper::getProcessComponentContext())); + exec->execute(imageMapLink, OUString(), SystemShellExecuteFlags::URIS_ONLY); + + return true; + } + // find matching shape (scan reversely, to coarsely match // paint order) auto aCurrBroadcaster = std::find_if(maShapeListenerMap.rbegin(), maShapeListenerMap.rend(), @@ -172,7 +194,7 @@ bool ShapeManagerImpl::handleMouseMoved( const awt::MouseEvent& e ) const ::basegfx::B2DPoint aPosition( e.X, e.Y ); sal_Int16 nNewCursor(-1); - if( !checkForHyperlink(aPosition).isEmpty() ) + if( !checkForHyperlink(aPosition).isEmpty() || !checkForImageMap(e).isEmpty() ) { nNewCursor = awt::SystemPointer::REFHAND; } @@ -362,6 +384,24 @@ OUString ShapeManagerImpl::checkForHyperlink( basegfx::B2DPoint const& hitPos ) return OUString(); } +OUString ShapeManagerImpl::checkForImageMap( awt::MouseEvent const& evt ) const +{ + for (sal_Int32 i = 0; i < mxDrawPage->getCount(); i++) + { + Reference xShape(mxDrawPage->getByIndex(i), UNO_QUERY_THROW); + SvxShape* pShape = comphelper::getUnoTunnelImplementation(xShape); + SdrObject* pObj = pShape ? pShape->GetSdrObject() : nullptr; + if (!pObj) + continue; + const IMapObject* pIMapObj = SvxIMapInfo::GetHitIMapObject(pObj, Point(evt.X, evt.Y)); + if (pIMapObj && !pIMapObj->GetURL().isEmpty()) + { + return pIMapObj->GetURL(); + } + } + return OUString(); +} + void ShapeManagerImpl::addIntrinsicAnimationHandler( const IntrinsicAnimationEventHandlerSharedPtr& rHandler ) { maIntrinsicAnimationEventHandlers.add( rHandler ); diff --git a/slideshow/source/engine/slide/shapemanagerimpl.hxx b/slideshow/source/engine/slide/shapemanagerimpl.hxx index e4634064bc0c..9da754102429 100644 --- a/slideshow/source/engine/slide/shapemanagerimpl.hxx +++ b/slideshow/source/engine/slide/shapemanagerimpl.hxx @@ -20,6 +20,8 @@ #define INCLUDED_SLIDESHOW_SOURCE_ENGINE_SLIDE_SHAPEMANAGERIMPL_HXX #include +#include +#include #include #include @@ -64,7 +66,8 @@ public: LayerManagerSharedPtr const& rLayerManager, CursorManager& rCursorManager, const ShapeEventListenerMap& rGlobalListenersMap, - const ShapeCursorMap& rGlobalCursorMap ); + const ShapeCursorMap& rGlobalCursorMap, + const css::uno::Reference& xDrawPage); /// Forbid copy construction ShapeManagerImpl(const ShapeManagerImpl&) = delete; @@ -154,6 +157,7 @@ private: OUString checkForHyperlink( ::basegfx::B2DPoint const& hitPos )const; + OUString checkForImageMap( css::awt::MouseEvent const& evt ) const; typedef std::map mxDrawPage; }; } // namespace internal diff --git a/slideshow/source/engine/slide/slideimpl.cxx b/slideshow/source/engine/slide/slideimpl.cxx index f49e884b3d67..b23ad397093e 100644 --- a/slideshow/source/engine/slide/slideimpl.cxx +++ b/slideshow/source/engine/slide/slideimpl.cxx @@ -333,7 +333,8 @@ SlideImpl::SlideImpl( const uno::Reference< drawing::XDrawPage >& xDra mpLayerManager, rCursorManager, rShapeListenerMap, - rShapeCursorMap)), + rShapeCursorMap, + xDrawPage)), mpSubsettableShapeManager( mpShapeManager ), maContext( mpSubsettableShapeManager, rEventQueue, -- cgit