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 <cppuhelper/interfacecontainer.h>
23 #include <com/sun/star/presentation/XShapeEventListener.hpp>
26 #include <subsettableshapemanager.hxx>
27 #include <eventmultiplexer.hxx>
28 #include "layermanager.hxx"
29 #include <viewupdate.hxx>
30 #include <shapemaps.hxx>
31 #include <cursormanager.hxx>
32 #include <hyperlinkarea.hxx>
33 #include <listenercontainer.hxx>
34 #include <shapelistenereventhandler.hxx>
35 #include <mouseeventhandler.hxx>
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
const& rLayerManager
,
65 CursorManager
& rCursorManager
,
66 const ShapeEventListenerMap
& rGlobalListenersMap
,
67 const ShapeCursorMap
& rGlobalCursorMap
);
69 /// Forbid copy construction
70 ShapeManagerImpl(const ShapeManagerImpl
&) = delete;
72 /// Forbid copy assignment
73 ShapeManagerImpl
& operator=(const ShapeManagerImpl
&) = delete;
75 /** Enables event listening.
77 The initial slide content on the background layer
78 is already rendered (e.g. from a previous slide
83 /** Disables event listening.
87 // Disposable interface
90 virtual void dispose() override
;
94 // MouseEventHandler interface
97 virtual bool handleMousePressed(
98 css::awt::MouseEvent
const& evt
) override
;
99 virtual bool handleMouseReleased(
100 css::awt::MouseEvent
const& evt
) override
;
101 virtual bool handleMouseDragged(
102 css::awt::MouseEvent
const& evt
) override
;
103 virtual bool handleMouseMoved(
104 css::awt::MouseEvent
const& evt
) override
;
107 // ViewUpdate interface
110 virtual bool update() override
;
111 virtual bool needsUpdate() const override
;
114 // ShapeManager interface
117 virtual void enterAnimationMode( const AnimatableShapeSharedPtr
& rShape
) override
;
118 virtual void leaveAnimationMode( const AnimatableShapeSharedPtr
& rShape
) override
;
119 virtual void notifyShapeUpdate( const ShapeSharedPtr
& rShape
) override
;
120 virtual ShapeSharedPtr
lookupShape(
121 css::uno::Reference
< css::drawing::XShape
> const & xShape
) const override
;
122 virtual void addHyperlinkArea( const std::shared_ptr
<HyperlinkArea
>& rArea
) override
;
125 // SubsettableShapeManager interface
128 virtual std::shared_ptr
<AttributableShape
> getSubsetShape(
129 const std::shared_ptr
<AttributableShape
>& rOrigShape
,
130 const DocTreeNode
& rTreeNode
) override
;
131 virtual void revokeSubset(
132 const std::shared_ptr
<AttributableShape
>& rOrigShape
,
133 const std::shared_ptr
<AttributableShape
>& rSubsetShape
) override
;
135 virtual void addIntrinsicAnimationHandler(
136 const IntrinsicAnimationEventHandlerSharedPtr
& rHandler
) override
;
137 virtual void removeIntrinsicAnimationHandler(
138 const IntrinsicAnimationEventHandlerSharedPtr
& rHandler
) override
;
139 virtual void notifyIntrinsicAnimationsEnabled() override
;
140 virtual void notifyIntrinsicAnimationsDisabled() override
;
143 // ShapeListenerEventHandler
146 virtual bool listenerAdded( const css::uno::Reference
< css::presentation::XShapeEventListener
>& xListener
,
147 const css::uno::Reference
< css::drawing::XShape
>& xShape
) override
;
149 virtual bool listenerRemoved( const css::uno::Reference
< css::presentation::XShapeEventListener
>& xListener
,
150 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;
159 typedef std::map
<ShapeSharedPtr
,
160 std::shared_ptr
< ::comphelper::OInterfaceContainerHelper2
>,
161 Shape::lessThanShape
> ShapeToListenersMap
;
162 typedef std::map
<ShapeSharedPtr
, sal_Int16
,
163 Shape::lessThanShape
> ShapeToCursorMap
;
164 typedef std::set
<HyperlinkAreaSharedPtr
,
165 HyperlinkArea::lessThanArea
> AreaSet
;
167 typedef ThreadUnsafeListenerContainer
<
168 IntrinsicAnimationEventHandlerSharedPtr
,
169 std::vector
<IntrinsicAnimationEventHandlerSharedPtr
> > ImplIntrinsicAnimationEventHandlers
;
171 EventMultiplexer
& mrMultiplexer
;
172 LayerManagerSharedPtr mpLayerManager
;
173 CursorManager
& mrCursorManager
;
174 const ShapeEventListenerMap
& mrGlobalListenersMap
;
175 const ShapeCursorMap
& mrGlobalCursorMap
;
176 ShapeToListenersMap maShapeListenerMap
;
177 ShapeToCursorMap maShapeCursorMap
;
178 AreaSet maHyperlinkShapes
;
179 ImplIntrinsicAnimationEventHandlers maIntrinsicAnimationEventHandlers
;
183 } // namespace internal
184 } // namespace presentation
186 #endif // INCLUDED_SLIDESHOW_SOURCE_ENGINE_SLIDE_SHAPEMANAGERIMPL_HXX
188 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */