slideshow/CppunitTest_slideshow.mk | 2 slideshow/Library_slideshow.mk | 1 slideshow/source/engine/slide/shapemanagerimpl.cxx | 50 ++++++++++++++++++--- slideshow/source/engine/slide/shapemanagerimpl.hxx | 7 ++ slideshow/source/engine/slide/slideimpl.cxx | 3 - 5 files changed, 56 insertions(+), 7 deletions(-)
New commits: commit ae94ed1ffca7ec7fa86f3fd650dbee74db0565d6 Author: Samuel Mehrbrodt <samuel.mehrbr...@cib.de> AuthorDate: Mon Aug 26 22:04:37 2019 +0200 Commit: Samuel Mehrbrodt <samuel.mehrbr...@cib.de> CommitDate: Tue Aug 27 21:58:17 2019 +0200 tdf#74045 Make ImageMaps in slideshow clickable Change-Id: I151983ce34a58c0f0d4b1e912f43525de4c0ad28 Reviewed-on: https://gerrit.libreoffice.org/78157 Tested-by: Jenkins Reviewed-by: Samuel Mehrbrodt <samuel.mehrbr...@cib.de> diff --git a/slideshow/CppunitTest_slideshow.mk b/slideshow/CppunitTest_slideshow.mk index d72a0409d63b..030a4baa1fa5 100644 --- a/slideshow/CppunitTest_slideshow.mk +++ b/slideshow/CppunitTest_slideshow.mk @@ -29,6 +29,8 @@ $(eval $(call gb_CppunitTest_use_libraries,slideshow,\ sal \ salhelper \ svt \ + svx \ + svxcore \ tl \ utl \ vcl \ diff --git a/slideshow/Library_slideshow.mk b/slideshow/Library_slideshow.mk index d1526754a1fb..0b9583011115 100644 --- a/slideshow/Library_slideshow.mk +++ b/slideshow/Library_slideshow.mk @@ -48,6 +48,7 @@ $(eval $(call gb_Library_use_libraries,slideshow,\ sal \ salhelper \ svt \ + svxcore \ tl \ utl \ vcl \ 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 <comphelper/processfactory.hxx> +#include <comphelper/servicehelper.hxx> #include <tools/diagnose_ex.h> #include <com/sun/star/awt/MouseButton.hpp> #include <com/sun/star/awt/SystemPointer.hpp> #include <com/sun/star/presentation/XShapeEventListener.hpp> +#include <com/sun/star/system/SystemShellExecute.hpp> +#include <com/sun/star/system/SystemShellExecuteFlags.hpp> +#include <com/sun/star/system/XSystemShellExecute.hpp> +#include <svx/unoshape.hxx> +#include <svx/ImageMapInfo.hxx> #include "shapemanagerimpl.hxx" #include <functional> -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>& 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<XSystemShellExecute> 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> xShape(mxDrawPage->getByIndex(i), UNO_QUERY_THROW); + SvxShape* pShape = comphelper::getUnoTunnelImplementation<SvxShape>(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 <cppuhelper/interfacecontainer.h> +#include <com/sun/star/drawing/XDrawPage.hpp> +#include <com/sun/star/uno/Reference.hxx> #include <com/sun/star/presentation/XShapeEventListener.hpp> #include <shape.hxx> @@ -64,7 +66,8 @@ public: LayerManagerSharedPtr const& rLayerManager, CursorManager& rCursorManager, const ShapeEventListenerMap& rGlobalListenersMap, - const ShapeCursorMap& rGlobalCursorMap ); + const ShapeCursorMap& rGlobalCursorMap, + const css::uno::Reference<css::drawing::XDrawPage>& 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<ShapeSharedPtr, @@ -178,6 +182,7 @@ private: AreaSet maHyperlinkShapes; ImplIntrinsicAnimationEventHandlers maIntrinsicAnimationEventHandlers; bool mbEnabled; + const css::uno::Reference<css::drawing::XDrawPage> 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, _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits