summaryrefslogtreecommitdiff
path: root/slideshow
diff options
context:
space:
mode:
authorSarper Akdemir <q.sarperakdemir@gmail.com>2020-06-10 02:11:36 +0300
committerThorsten Behrens <Thorsten.Behrens@CIB.de>2020-06-30 23:50:18 +0200
commit7394ac17f3c8bdbb1cb3402a08ba7749906f6793 (patch)
tree07d1432722a9b28ea1d93245d359a5c42120aeb5 /slideshow
parent57e8d6837c8bb72bb44930d78b9764789be80124 (diff)
adding XShapeToShapeMapSharedPtr getter to ShapeManager
Refactoring XShapeHash in layermanager as XShapeToShapeMap and XShapeHash in targetpropertiescreator as XShapeToNamedValuesMap. This refactoring describes what the types are more clearly and stops violating one define rule in the desired implementation. And adding getter getXShapeToShapeMap to ShapeManager to enable Animation::start() to access Shapes and XShapes of the current slide. Change-Id: I78d510ae43888fd6cf0f037e224b24f91b263b00 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95967 Tested-by: Jenkins Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
Diffstat (limited to 'slideshow')
-rw-r--r--slideshow/source/engine/slide/layermanager.cxx7
-rw-r--r--slideshow/source/engine/slide/layermanager.hxx28
-rw-r--r--slideshow/source/engine/slide/shapemanagerimpl.cxx6
-rw-r--r--slideshow/source/engine/slide/shapemanagerimpl.hxx1
-rw-r--r--slideshow/source/engine/slide/targetpropertiescreator.cxx10
-rw-r--r--slideshow/source/inc/shapemanager.hxx14
6 files changed, 50 insertions, 16 deletions
diff --git a/slideshow/source/engine/slide/layermanager.cxx b/slideshow/source/engine/slide/layermanager.cxx
index a69f42d31372..35131ccb1a22 100644
--- a/slideshow/source/engine/slide/layermanager.cxx
+++ b/slideshow/source/engine/slide/layermanager.cxx
@@ -302,7 +302,7 @@ namespace slideshow::internal
{
ENSURE_OR_THROW( xShape.is(), "LayerManager::lookupShape(): invalid Shape" );
- const XShapeHash::const_iterator aIter( maXShapeHash.find( xShape ));
+ const XShapeToShapeMap::const_iterator aIter( maXShapeHash.find( xShape ));
if( aIter == maXShapeHash.end() )
return ShapeSharedPtr(); // not found
@@ -341,6 +341,11 @@ namespace slideshow::internal
return pSubset;
}
+ const XShapeToShapeMap& LayerManager::getXShapeToShapeMap() const
+ {
+ return maXShapeHash;
+ }
+
void LayerManager::revokeSubset( const AttributableShapeSharedPtr& rOrigShape,
const AttributableShapeSharedPtr& rSubsetShape )
{
diff --git a/slideshow/source/engine/slide/layermanager.hxx b/slideshow/source/engine/slide/layermanager.hxx
index 0f2844ced967..ec95e08f364c 100644
--- a/slideshow/source/engine/slide/layermanager.hxx
+++ b/slideshow/source/engine/slide/layermanager.hxx
@@ -38,6 +38,16 @@ namespace slideshow
{
namespace internal
{
+ /** A hash map which maps the XShape to the corresponding Shape object.
+
+ Provides quicker lookup than ShapeSet for simple mappings
+ */
+ typedef std::unordered_map<
+ css::uno::Reference< css::drawing::XShape >,
+ ShapeSharedPtr,
+ hash< css::uno::Reference< css::drawing::XShape > >
+ > XShapeToShapeMap;
+
/* Definition of Layermanager class */
/** This class manages all of a slide's layers (and shapes)
@@ -132,6 +142,13 @@ namespace slideshow
AttributableShapeSharedPtr getSubsetShape( const AttributableShapeSharedPtr& rOrigShape,
const DocTreeNode& rTreeNode );
+ /** Get a map that maps all Shapes with their XShape reference as the key
+ *
+ * @return an unordered map that contains all shapes in the
+ * current page with their XShape reference as the key
+ */
+ const XShapeToShapeMap& getXShapeToShapeMap() const;
+
/** Revoke a previously queried subset shape.
With this method, a previously requested subset shape
@@ -219,15 +236,6 @@ namespace slideshow
bool renderTo( const ::cppcanvas::CanvasSharedPtr& rTargetCanvas ) const;
private:
- /** A hash map which maps the XShape to the corresponding Shape object.
-
- Provides quicker lookup than ShapeSet for simple mappings
- */
- typedef std::unordered_map<
- css::uno::Reference< css::drawing::XShape >,
- ShapeSharedPtr,
- hash< css::uno::Reference< css::drawing::XShape > >
- > XShapeHash;
class ShapeComparator
{
@@ -311,7 +319,7 @@ namespace slideshow
/** Contains all shapes with their XShape reference as the key
*/
- XShapeHash maXShapeHash;
+ XShapeToShapeMap maXShapeHash;
/** Set of shapes this LayerManager own
diff --git a/slideshow/source/engine/slide/shapemanagerimpl.cxx b/slideshow/source/engine/slide/shapemanagerimpl.cxx
index 7863f7e7412b..17f21926ac2f 100644
--- a/slideshow/source/engine/slide/shapemanagerimpl.cxx
+++ b/slideshow/source/engine/slide/shapemanagerimpl.cxx
@@ -267,6 +267,12 @@ ShapeSharedPtr ShapeManagerImpl::lookupShape( uno::Reference< drawing::XShape >
return ShapeSharedPtr();
}
+const XShapeToShapeMap& ShapeManagerImpl::getXShapeToShapeMap() const
+{
+ assert( mpLayerManager );
+ return mpLayerManager->getXShapeToShapeMap();
+}
+
void ShapeManagerImpl::addHyperlinkArea( const HyperlinkAreaSharedPtr& rArea )
{
maHyperlinkShapes.insert(rArea);
diff --git a/slideshow/source/engine/slide/shapemanagerimpl.hxx b/slideshow/source/engine/slide/shapemanagerimpl.hxx
index 9730975630b0..f084320cac99 100644
--- a/slideshow/source/engine/slide/shapemanagerimpl.hxx
+++ b/slideshow/source/engine/slide/shapemanagerimpl.hxx
@@ -120,6 +120,7 @@ private:
virtual void notifyShapeUpdate( const ShapeSharedPtr& rShape ) override;
virtual ShapeSharedPtr lookupShape(
css::uno::Reference< css::drawing::XShape > const & xShape ) const override;
+ virtual const XShapeToShapeMap& getXShapeToShapeMap() const override;
virtual void addHyperlinkArea( const HyperlinkAreaSharedPtr& rArea ) override;
diff --git a/slideshow/source/engine/slide/targetpropertiescreator.cxx b/slideshow/source/engine/slide/targetpropertiescreator.cxx
index 7a70b8b63352..b159bc6c2778 100644
--- a/slideshow/source/engine/slide/targetpropertiescreator.cxx
+++ b/slideshow/source/engine/slide/targetpropertiescreator.cxx
@@ -85,14 +85,14 @@ namespace slideshow::internal
};
// A hash map which maps a XShape to the corresponding vector of initial properties
- typedef std::unordered_map< ShapeHashKey, VectorOfNamedValues, ShapeKeyHasher > XShapeHash;
+ typedef std::unordered_map< ShapeHashKey, VectorOfNamedValues, ShapeKeyHasher > XShapeToNamedValuesMap;
class NodeFunctor
{
public:
explicit NodeFunctor(
- XShapeHash& rShapeHash,
+ XShapeToNamedValuesMap& rShapeHash,
bool bInitial )
: mrShapeHash( rShapeHash ),
mxTargetShape(),
@@ -101,7 +101,7 @@ namespace slideshow::internal
{
}
- NodeFunctor( XShapeHash& rShapeHash,
+ NodeFunctor( XShapeToNamedValuesMap& rShapeHash,
const uno::Reference< drawing::XShape >& rTargetShape,
sal_Int16 nParagraphIndex,
bool bInitial) :
@@ -307,7 +307,7 @@ namespace slideshow::internal
}
private:
- XShapeHash& mrShapeHash;
+ XShapeToNamedValuesMap& mrShapeHash;
uno::Reference< drawing::XShape > mxTargetShape;
sal_Int16 mnParagraphIndex;
@@ -324,7 +324,7 @@ namespace slideshow::internal
{
// scan all nodes for visibility changes, and record first
// 'visibility=true' for each shape
- XShapeHash aShapeHash( 101 );
+ XShapeToNamedValuesMap aShapeHash( 101 );
NodeFunctor aFunctor(
aShapeHash,
diff --git a/slideshow/source/inc/shapemanager.hxx b/slideshow/source/inc/shapemanager.hxx
index ef2e40de6466..db7febb110b7 100644
--- a/slideshow/source/inc/shapemanager.hxx
+++ b/slideshow/source/inc/shapemanager.hxx
@@ -23,6 +23,8 @@
#include "disposable.hxx"
#include <com/sun/star/uno/Reference.hxx>
#include <memory>
+#include <unordered_map>
+#include "tools.hxx"
namespace com::sun::star::drawing { class XShape; }
@@ -35,6 +37,11 @@ namespace slideshow
class HyperlinkArea;
class AnimatableShape;
class Shape;
+ typedef std::unordered_map<
+ css::uno::Reference< css::drawing::XShape >,
+ ShapeSharedPtr,
+ hash< css::uno::Reference< css::drawing::XShape > >
+ > XShapeToShapeMap;
typedef ::std::shared_ptr< AnimatableShape > AnimatableShapeSharedPtr;
typedef ::std::shared_ptr< Shape > ShapeSharedPtr;
typedef std::shared_ptr< HyperlinkArea > HyperlinkAreaSharedPtr;
@@ -92,6 +99,13 @@ namespace slideshow
virtual ShapeSharedPtr lookupShape(
css::uno::Reference< css::drawing::XShape > const & xShape ) const = 0;
+ /** Get a map that maps all Shapes with their XShape reference as the key
+ *
+ * @return an unordered map that contains all shapes in the
+ * current page with their XShape reference as the key
+ */
+ virtual const XShapeToShapeMap& getXShapeToShapeMap() const = 0;
+
/** Register given shape as a hyperlink target
@param rArea