[Libreoffice-commits] core.git: Branch 'private/quwex/gsoc-box2d-experimental' - slideshow/source

Sarper Akdemir (via logerrit) logerrit at kemper.freedesktop.org
Sat Aug 15 21:05:02 UTC 2020


 slideshow/source/engine/box2dtools.cxx           |   26 ++++++++++++++++++++++-
 slideshow/source/engine/shapes/shapeimporter.cxx |    1 
 slideshow/source/inc/shape.hxx                   |    3 --
 3 files changed, 26 insertions(+), 4 deletions(-)

New commits:
commit fd14e44cae952e4e03152a8d13ee2190e1423c99
Author:     Sarper Akdemir <q.sarperakdemir at gmail.com>
AuthorDate: Sun Aug 16 00:03:43 2020 +0300
Commit:     Sarper Akdemir <q.sarperakdemir at gmail.com>
CommitDate: Sun Aug 16 00:03:43 2020 +0300

    fix group shape crash for physics animations
    
    Change-Id: Icc4f69246b9fab69d2a1d96743a7b85a95d65dc7

diff --git a/slideshow/source/engine/box2dtools.cxx b/slideshow/source/engine/box2dtools.cxx
index d1ef96f154ca..860b0f37e791 100644
--- a/slideshow/source/engine/box2dtools.cxx
+++ b/slideshow/source/engine/box2dtools.cxx
@@ -18,6 +18,9 @@
 
 #include <svx/svdobj.hxx>
 #include <svx/svdoashp.hxx>
+#include <svx/svdogrp.hxx>
+
+#include <svx/unoapi.hxx>
 
 #define BOX2D_SLIDE_SIZE_IN_METERS 100.00f
 #define DEFAULT_BOUNCINESS 0.1
@@ -401,11 +404,32 @@ void box2DWorld::initateAllShapesAsStaticBodies(
     mbShapesInitialized = true;
     auto aXShapeToShapeMap = pShapeManager->getXShapeToShapeMap();
 
+    std::unordered_map<css::uno::Reference<css::drawing::XShape>, bool> aXShapeBelongsToAGroup;
+
+    // iterate over the shapes in the current slide and flag them if they belong to a group
+    for (auto aIt = aXShapeToShapeMap.begin(); aIt != aXShapeToShapeMap.end(); aIt++)
+    {
+        slideshow::internal::ShapeSharedPtr pShape = aIt->second;
+        SdrObject* pTemp = SdrObject::getSdrObjectFromXShape(pShape->getXShape());
+        if (pShape->isForeground() && pTemp && pTemp->IsGroupObject())
+        {
+            SdrObjList* aObjList = pTemp->GetSubList();
+            const size_t nObjCount(aObjList->GetObjCount());
+
+            for (size_t nObjIndex = 0; nObjIndex < nObjCount; ++nObjIndex)
+            {
+                SdrObject* pGroupMember(aObjList->GetObj(nObjIndex));
+                aXShapeBelongsToAGroup.insert(
+                    std::make_pair(GetXShapeForSdrObject(pGroupMember), true));
+            }
+        }
+    }
+
     // iterate over shapes in the current slide
     for (auto aIt = aXShapeToShapeMap.begin(); aIt != aXShapeToShapeMap.end(); aIt++)
     {
         slideshow::internal::ShapeSharedPtr pShape = aIt->second;
-        if (pShape->isForeground())
+        if (pShape->isForeground() && !aXShapeBelongsToAGroup[pShape->getXShape()])
         {
             Box2DBodySharedPtr pBox2DBody = createStaticBody(pShape);
 
diff --git a/slideshow/source/engine/shapes/shapeimporter.cxx b/slideshow/source/engine/shapes/shapeimporter.cxx
index 8f2abded678d..b1b1b3417269 100644
--- a/slideshow/source/engine/shapes/shapeimporter.cxx
+++ b/slideshow/source/engine/shapes/shapeimporter.cxx
@@ -495,7 +495,6 @@ ShapeSharedPtr ShapeImporter::importShape() // throw (ShapeLoadFailedException)
         }
         if( bIsGroupShape && pRet )
         {
-            pRet->setIsForeground(false);
             // push new group on the stack: group traversal
             maShapesStack.push( XShapesEntry( pRet ) );
         }
diff --git a/slideshow/source/inc/shape.hxx b/slideshow/source/inc/shape.hxx
index 1638e87c08a7..0e6533fca6fe 100644
--- a/slideshow/source/inc/shape.hxx
+++ b/slideshow/source/inc/shape.hxx
@@ -269,8 +269,7 @@ namespace slideshow
         private:
             /** Flag to check whether the shape belongs to the foreground.
 
-                For instance, it is false if the shape belongs to the master slide or
-                a group shape.
+                For instance, it is false if the shape belongs to the master slide.
              */
             bool mbIsForeground;
         };


More information about the Libreoffice-commits mailing list