[Libreoffice-commits] core.git: slideshow/source

Sarper Akdemir (via logerrit) logerrit at kemper.freedesktop.org
Tue Jun 30 21:51:00 UTC 2020


 slideshow/source/engine/slide/layermanager.cxx            |    7 +++
 slideshow/source/engine/slide/layermanager.hxx            |   28 +++++++++-----
 slideshow/source/engine/slide/shapemanagerimpl.cxx        |    6 +++
 slideshow/source/engine/slide/shapemanagerimpl.hxx        |    1 
 slideshow/source/engine/slide/targetpropertiescreator.cxx |   10 ++---
 slideshow/source/inc/shapemanager.hxx                     |   14 +++++++
 6 files changed, 50 insertions(+), 16 deletions(-)

New commits:
commit 7394ac17f3c8bdbb1cb3402a08ba7749906f6793
Author:     Sarper Akdemir <q.sarperakdemir at gmail.com>
AuthorDate: Wed Jun 10 02:11:36 2020 +0300
Commit:     Thorsten Behrens <Thorsten.Behrens at CIB.de>
CommitDate: Tue Jun 30 23:50:18 2020 +0200

    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 at CIB.de>

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


More information about the Libreoffice-commits mailing list