summaryrefslogtreecommitdiff
path: root/slideshow
diff options
context:
space:
mode:
authorSarper Akdemir <q.sarperakdemir@gmail.com>2020-08-16 00:03:43 +0300
committerThorsten Behrens <Thorsten.Behrens@CIB.de>2020-08-22 18:58:47 +0200
commit5edbac1b8c8b7aad36a0f2b1c5cacc8d6fd5fb44 (patch)
treeed54338969f9a6ccf886b8db1ee581568c4647ac /slideshow
parent5ac88d12b377f64ff36551bfb3cf95a4a23a167d (diff)
fix group shape crash for physics animations
Group shapes are now considered as foreground objects. Physics animations now do not create individual bodies for shapes that are part of a group but instead create one body that represent all of them. Change-Id: I27819c853af75aff93636c99f216a67ef18791d6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101174 Tested-by: Jenkins Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
Diffstat (limited to 'slideshow')
-rw-r--r--slideshow/source/engine/box2dtools.cxx29
-rw-r--r--slideshow/source/engine/shapes/shapeimporter.cxx1
-rw-r--r--slideshow/source/inc/shape.hxx3
3 files changed, 29 insertions, 4 deletions
diff --git a/slideshow/source/engine/box2dtools.cxx b/slideshow/source/engine/box2dtools.cxx
index 845363501ca4..402a71542dd3 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
constexpr double fDefaultStaticBodyBounciness(0.1);
@@ -403,12 +406,36 @@ void box2DWorld::initateAllShapesAsStaticBodies(
mbShapesInitialized = true;
auto aXShapeToShapeMap = pShapeManager->getXShapeToShapeMap();
- // iterate over shapes in the current slide
+ 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;
if (pShape->isForeground())
{
+ SdrObject* pTemp = SdrObject::getSdrObjectFromXShape(pShape->getXShape());
+ if (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() && !aXShapeBelongsToAGroup[pShape->getXShape()])
+ {
Box2DBodySharedPtr pBox2DBody = createStaticBody(pShape);
mpXShapeToBodyMap.insert(std::make_pair(pShape->getXShape(), pBox2DBody));
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 6f0ee040d965..bbd2988e0254 100644
--- a/slideshow/source/inc/shape.hxx
+++ b/slideshow/source/inc/shape.hxx
@@ -267,8 +267,7 @@ namespace slideshow::internal
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;
};