LibreOffice Module slideshow (master) 1
layermanager.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#ifndef INCLUDED_SLIDESHOW_SOURCE_ENGINE_SLIDE_LAYERMANAGER_HXX
21#define INCLUDED_SLIDESHOW_SOURCE_ENGINE_SLIDE_LAYERMANAGER_HXX
22
23#include <unoviewcontainer.hxx>
24#include <attributableshape.hxx>
25#include "layer.hxx"
26#include <tools.hxx>
27
28#include <memory>
29#include <map>
30#include <unordered_map>
31#include <vector>
32
33namespace basegfx {
34 class B2DRange;
35}
36
37namespace slideshow::internal
38 {
43 typedef std::unordered_map<
44 css::uno::Reference< css::drawing::XShape >,
46 hash< css::uno::Reference< css::drawing::XShape > >
48
49 /* Definition of Layermanager class */
50
64 {
65 public:
76 LayerManager( const UnoViewContainer& rViews,
77 bool bDisableAnimationZOrder );
78
80 LayerManager(const LayerManager&) = delete;
81
84
91 void activate();
92
101 void deactivate();
102
103 // From ViewEventHandler, forwarded by SlideImpl
105 void viewAdded( const UnoViewSharedPtr& rView );
107 void viewRemoved( const UnoViewSharedPtr& rView );
108 void viewChanged( const UnoViewSharedPtr& rView );
109 void viewsChanged();
110
115 void addShape( const ShapeSharedPtr& rShape );
116
121 bool removeShape( const ShapeSharedPtr& rShape );
122
132 ShapeSharedPtr lookupShape( const css::uno::Reference< css::drawing::XShape >& xShape ) const;
133
141 const DocTreeNode& rTreeNode );
142
149
163 void revokeSubset( const AttributableShapeSharedPtr& rOrigShape,
164 const AttributableShapeSharedPtr& rSubsetShape );
165
172 void enterAnimationMode( const AnimatableShapeSharedPtr& rShape );
173
180 void leaveAnimationMode( const AnimatableShapeSharedPtr& rShape );
181
195 void notifyShapeUpdate( const ShapeSharedPtr& rShape);
196
203 bool isUpdatePending() const;
204
221 bool update();
222
234 bool renderTo( const ::cppcanvas::CanvasSharedPtr& rTargetCanvas ) const;
235
236 private:
237
239 {
240 public:
241 bool operator() (const ShapeSharedPtr& rpS1, const ShapeSharedPtr& rpS2 ) const
242 {
243 return Shape::lessThanShape::compare(rpS1.get(), rpS2.get());
244 }
245 };
248 private:
249 typedef ::std::map< ShapeSharedPtr, LayerWeakPtr, ShapeComparator > LayerShapeMap;
250
251
253 void addUpdateArea( ShapeSharedPtr const& rShape );
254
256
273 void commitLayerChanges( std::size_t nCurrLayerIndex,
274 LayerShapeMap::const_iterator aFirstLayerShape,
275 const LayerShapeMap::const_iterator& aEndLayerShapes );
276
279 void putShape2BackgroundLayer( LayerShapeMap::value_type& rShapeEntry );
280
289 void updateShapeLayers( bool bBackgroundLayerPainted );
290
293 void implAddShape( const ShapeSharedPtr& rShape );
294
297 void implRemoveShape( const ShapeSharedPtr& rShape );
298
305 template<typename LayerFunc,
306 typename ShapeFunc> void manageViews( LayerFunc layerFunc,
307 ShapeFunc shapeFunc );
308
309 bool updateSprites();
310
313
315 ::std::vector< LayerSharedPtr >
317
321
331
338 ::std::set< ShapeSharedPtr >
340
343
346
349
355 };
356
357 typedef ::std::shared_ptr< LayerManager > LayerManagerSharedPtr;
358
359}
360
361#endif // INCLUDED_SLIDESHOW_SOURCE_ENGINE_SLIDE_LAYERMANAGER_HXX
362
363/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
This class represents kind of a DOM tree node for shape text.
Definition: doctreenode.hxx:45
bool operator()(const ShapeSharedPtr &rpS1, const ShapeSharedPtr &rpS2) const
This class manages all of a slide's layers (and shapes)
void implRemoveShape(const ShapeSharedPtr &rShape)
Common stuff when removing a shape.
LayerManager(const LayerManager &)=delete
Forbid copy construction.
bool mbDisableAnimationZOrder
When true, all sprite animations run in the foreground.
void viewAdded(const UnoViewSharedPtr &rView)
Notify new view added to UnoViewContainer.
bool renderTo(const ::cppcanvas::CanvasSharedPtr &rTargetCanvas) const
Render the content to given canvas.
void updateShapeLayers(bool bBackgroundLayerPainted)
Commits any pending layer reorg, due to shapes either entering or leaving animation mode.
::std::map< ShapeSharedPtr, LayerWeakPtr, ShapeComparator > LayerShapeMap
Set of all shapes.
void deactivate()
Deactivate the LayerManager.
void commitLayerChanges(std::size_t nCurrLayerIndex, LayerShapeMap::const_iterator aFirstLayerShape, const LayerShapeMap::const_iterator &aEndLayerShapes)
Push changes from updateShapeLayerAssociations() to current layer.
const UnoViewContainer & mrViews
Registered views.
ShapeSharedPtr lookupShape(const css::uno::Reference< css::drawing::XShape > &xShape) const
Lookup a Shape from an XShape model object.
LayerShapeMap maAllShapes
Set of shapes this LayerManager own.
AttributableShapeSharedPtr getSubsetShape(const AttributableShapeSharedPtr &rOrigShape, const DocTreeNode &rTreeNode)
Query a subset of the given original shape.
void notifyShapeUpdate(const ShapeSharedPtr &rShape)
Notify that a shape needs an update.
void revokeSubset(const AttributableShapeSharedPtr &rOrigShape, const AttributableShapeSharedPtr &rSubsetShape)
Revoke a previously queried subset shape.
void manageViews(LayerFunc layerFunc, ShapeFunc shapeFunc)
Add or remove views.
void activate()
Activate the LayerManager.
void leaveAnimationMode(const AnimatableShapeSharedPtr &rShape)
Notify the LayerManager that the given Shape is no longer animated.
void addUpdateArea(ShapeSharedPtr const &rShape)
Adds shape area to containing layer's damage area.
LayerManager & operator=(const LayerManager &)=delete
Forbid copy assignment.
void implAddShape(const ShapeSharedPtr &rShape)
Common stuff when adding a shape.
void enterAnimationMode(const AnimatableShapeSharedPtr &rShape)
Notify the LayerManager that the given Shape starts an animation now.
bool mbLayerAssociationDirty
sal_True, if shapes might need to move to different layer
LayerSharedPtr createForegroundLayer() const
::std::vector< LayerSharedPtr > maLayers
All layers of this object. Vector owns the layers.
const XShapeToShapeMap & getXShapeToShapeMap() const
Get a map that maps all Shapes with their XShape reference as the key.
bool update()
Update the content.
LayerManager(const UnoViewContainer &rViews, bool bDisableAnimationZOrder)
Create a new layer manager for the given page bounds.
bool isUpdatePending() const
Check whether any update operations are pending.
void addShape(const ShapeSharedPtr &rShape)
Add the shape to this object.
void viewRemoved(const UnoViewSharedPtr &rView)
Notify view removed from UnoViewContainer.
void putShape2BackgroundLayer(LayerShapeMap::value_type &rShapeEntry)
Init Shape layers with background layer.
XShapeToShapeMap maXShapeHash
Contains all shapes with their XShape reference as the key.
bool mbActive
sal_False when deactivated
::std::set< ShapeSharedPtr > maUpdateShapes
Set of shapes that have requested an update.
sal_Int32 mnActiveSprites
Number of shape sprites currently active on this LayerManager.
void viewChanged(const UnoViewSharedPtr &rView)
bool removeShape(const ShapeSharedPtr &rShape)
Remove shape from this object.
::std::shared_ptr< AnimatableShape > AnimatableShapeSharedPtr
::std::shared_ptr< LayerManager > LayerManagerSharedPtr
::std::shared_ptr< Layer > LayerSharedPtr
Definition: layer.hxx:36
::std::shared_ptr< AttributableShape > AttributableShapeSharedPtr
std::unordered_map< css::uno::Reference< css::drawing::XShape >, ShapeSharedPtr, hash< css::uno::Reference< css::drawing::XShape > > > XShapeToShapeMap
A hash map which maps the XShape to the corresponding Shape object.
::std::shared_ptr< Shape > ShapeSharedPtr
std::shared_ptr< UnoView > UnoViewSharedPtr
static bool compare(const Shape *pLHS, const Shape *pRHS)
Definition: shape.hxx:251