1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #ifndef INCLUDED_SLIDESHOW_SOURCE_ENGINE_SLIDE_SHAPEMANAGERIMPL_HXX
20 #define INCLUDED_SLIDESHOW_SOURCE_ENGINE_SLIDE_SHAPEMANAGERIMPL_HXX
22 #include <com/sun/star/drawing/XDrawPage.hpp>
23 #include <com/sun/star/uno/Reference.hxx>
25 #include <comphelper/interfacecontainer3.hxx>
27 #include <subsettableshapemanager.hxx>
28 #include <eventmultiplexer.hxx>
29 #include "layermanager.hxx"
30 #include <viewupdate.hxx>
31 #include <shapemaps.hxx>
32 #include <cursormanager.hxx>
33 #include <hyperlinkarea.hxx>
34 #include <listenercontainer.hxx>
35 #include <shapelistenereventhandler.hxx>
36 #include <mouseeventhandler.hxx>
42 namespace slideshow::internal
{
44 /** Listener class for shape events
46 This helper class registers itself on each view, and
47 broadcasts the XShapeEventListener events. The mouse motion
48 events are needed for setting the shape cursor.
50 class ShapeManagerImpl
: public SubsettableShapeManager
,
51 public ShapeListenerEventHandler
,
52 public MouseEventHandler
,
54 public std::enable_shared_from_this
<ShapeManagerImpl
>
57 /** Create a shape event broadcaster
59 @param rEventMultiplexer
60 The slideshow-global event source, where this class
61 registers its event handlers.
63 ShapeManagerImpl( EventMultiplexer
& rMultiplexer
,
64 LayerManagerSharedPtr xLayerManager
,
65 CursorManager
& rCursorManager
,
66 const ShapeEventListenerMap
& rGlobalListenersMap
,
67 const ShapeCursorMap
& rGlobalCursorMap
,
68 const css::uno::Reference
<css::drawing::XDrawPage
>& xDrawPage
);
70 /// Forbid copy construction
71 ShapeManagerImpl(const ShapeManagerImpl
&) = delete;
73 /// Forbid copy assignment
74 ShapeManagerImpl
& operator=(const ShapeManagerImpl
&) = delete;
76 /** Enables event listening.
78 The initial slide content on the background layer
79 is already rendered (e.g. from a previous slide
84 /** Disables event listening.
88 // Disposable interface
91 virtual void dispose() override
;
95 // MouseEventHandler interface
98 virtual bool handleMousePressed(
99 css::awt::MouseEvent
const& evt
) override
;
100 virtual bool handleMouseReleased(
101 css::awt::MouseEvent
const& evt
) override
;
102 virtual bool handleMouseDragged(
103 css::awt::MouseEvent
const& evt
) override
;
104 virtual bool handleMouseMoved(
105 css::awt::MouseEvent
const& evt
) override
;
108 // ViewUpdate interface
111 virtual bool update() override
;
112 virtual bool needsUpdate() const override
;
115 // ShapeManager interface
118 virtual void enterAnimationMode( const AnimatableShapeSharedPtr
& rShape
) override
;
119 virtual void leaveAnimationMode( const AnimatableShapeSharedPtr
& rShape
) override
;
120 virtual void notifyShapeUpdate( const ShapeSharedPtr
& rShape
) override
;
121 virtual ShapeSharedPtr
lookupShape(
122 css::uno::Reference
< css::drawing::XShape
> const & xShape
) const override
;
123 virtual const XShapeToShapeMap
& getXShapeToShapeMap() const override
;
124 virtual void addHyperlinkArea( const HyperlinkAreaSharedPtr
& rArea
) override
;
127 // SubsettableShapeManager interface
130 virtual AttributableShapeSharedPtr
getSubsetShape(
131 const AttributableShapeSharedPtr
& rOrigShape
,
132 const DocTreeNode
& rTreeNode
) override
;
133 virtual void revokeSubset(
134 const AttributableShapeSharedPtr
& rOrigShape
,
135 const AttributableShapeSharedPtr
& rSubsetShape
) override
;
137 virtual void addIntrinsicAnimationHandler(
138 const IntrinsicAnimationEventHandlerSharedPtr
& rHandler
) override
;
139 virtual void removeIntrinsicAnimationHandler(
140 const IntrinsicAnimationEventHandlerSharedPtr
& rHandler
) override
;
141 virtual void notifyIntrinsicAnimationsEnabled() override
;
142 virtual void notifyIntrinsicAnimationsDisabled() override
;
145 // ShapeListenerEventHandler
148 virtual bool listenerAdded( const css::uno::Reference
< css::drawing::XShape
>& xShape
) override
;
150 virtual bool listenerRemoved( const css::uno::Reference
< css::drawing::XShape
>& xShape
) override
;
152 void cursorChanged( const css::uno::Reference
< css::drawing::XShape
>& xShape
,
156 OUString
checkForHyperlink( ::basegfx::B2DPoint
const& hitPos
)const;
157 OUString
checkForImageMap( css::awt::MouseEvent
const& evt
) const;
160 typedef std::map
<ShapeSharedPtr
,
161 std::shared_ptr
< ::comphelper::OInterfaceContainerHelper3
<css::presentation::XShapeEventListener
> >,
162 Shape::lessThanShape
> ShapeToListenersMap
;
163 typedef std::map
<ShapeSharedPtr
, sal_Int16
,
164 Shape::lessThanShape
> ShapeToCursorMap
;
165 typedef std::set
<HyperlinkAreaSharedPtr
,
166 HyperlinkArea::lessThanArea
> AreaSet
;
168 typedef ThreadUnsafeListenerContainer
<
169 IntrinsicAnimationEventHandlerSharedPtr
,
170 std::vector
<IntrinsicAnimationEventHandlerSharedPtr
> > ImplIntrinsicAnimationEventHandlers
;
172 EventMultiplexer
& mrMultiplexer
;
173 LayerManagerSharedPtr mpLayerManager
;
174 CursorManager
& mrCursorManager
;
175 const ShapeEventListenerMap
& mrGlobalListenersMap
;
176 const ShapeCursorMap
& mrGlobalCursorMap
;
177 ShapeToListenersMap maShapeListenerMap
;
178 ShapeToCursorMap maShapeCursorMap
;
179 AreaSet maHyperlinkShapes
;
180 ImplIntrinsicAnimationEventHandlers maIntrinsicAnimationEventHandlers
;
182 const css::uno::Reference
<css::drawing::XDrawPage
> mxDrawPage
;
185 } // namespace presentation::internal
187 #endif // INCLUDED_SLIDESHOW_SOURCE_ENGINE_SLIDE_SHAPEMANAGERIMPL_HXX
189 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */