From e13dd9546e27bdc3b894718fc2993f99722ea9f1 Mon Sep 17 00:00:00 2001 From: Sarper Akdemir Date: Wed, 10 Jun 2020 02:33:22 +0300 Subject: Add Shape mbIsForeground flag and getters and setters for it mbIsForeground is a flag that is set false if a shape is known to not belong to the foreground. It is set to false while shapes are being imported and the shape belongs to the master slide or is a group shape, right now. Change-Id: Id9738fc943f32a1e1a6e1888d179e69fd60bd022 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95968 Tested-by: Jenkins Reviewed-by: Thorsten Behrens --- slideshow/source/engine/shapes/backgroundshape.cxx | 1 + slideshow/source/engine/shapes/shapeimporter.cxx | 1 + slideshow/source/engine/slide/slideimpl.cxx | 3 +++ slideshow/source/inc/shape.hxx | 28 +++++++++++++++++++++- 4 files changed, 32 insertions(+), 1 deletion(-) diff --git a/slideshow/source/engine/shapes/backgroundshape.cxx b/slideshow/source/engine/shapes/backgroundshape.cxx index 88d48b7e72e9..093502815eaf 100644 --- a/slideshow/source/engine/shapes/backgroundshape.cxx +++ b/slideshow/source/engine/shapes/backgroundshape.cxx @@ -83,6 +83,7 @@ namespace slideshow::internal virtual ::basegfx::B2DRectangle getUpdateArea() const override; virtual bool isVisible() const override; virtual double getPriority() const override; + virtual bool isForeground() const override { return false; } virtual bool isBackgroundDetached() const override; diff --git a/slideshow/source/engine/shapes/shapeimporter.cxx b/slideshow/source/engine/shapes/shapeimporter.cxx index b1b1b3417269..8f2abded678d 100644 --- a/slideshow/source/engine/shapes/shapeimporter.cxx +++ b/slideshow/source/engine/shapes/shapeimporter.cxx @@ -495,6 +495,7 @@ 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/engine/slide/slideimpl.cxx b/slideshow/source/engine/slide/slideimpl.cxx index 0805d084e9fa..a9120c6da829 100644 --- a/slideshow/source/engine/slide/slideimpl.cxx +++ b/slideshow/source/engine/slide/slideimpl.cxx @@ -981,7 +981,10 @@ bool SlideImpl::loadShapes() ShapeSharedPtr const& rShape( aMPShapesFunctor.importShape() ); if( rShape ) + { + rShape->setIsForeground(false); mpLayerManager->addShape( rShape ); + } } addPolygons(aMPShapesFunctor.getPolygons()); diff --git a/slideshow/source/inc/shape.hxx b/slideshow/source/inc/shape.hxx index 9b6099462ab6..1638e87c08a7 100644 --- a/slideshow/source/inc/shape.hxx +++ b/slideshow/source/inc/shape.hxx @@ -52,7 +52,7 @@ namespace slideshow class Shape { public: - Shape() = default; + Shape() : mbIsForeground(true) {} virtual ~Shape() {} Shape(const Shape&) = delete; Shape& operator=(const Shape&) = delete; @@ -204,6 +204,24 @@ namespace slideshow */ virtual bool isBackgroundDetached() const = 0; + /** Check whether the shape belongs to the foreground + + For instance, if the shape is in the master slide + it does not belong to the foreground. + + @return true if the shape is on the foreground + */ + virtual bool isForeground() const { return mbIsForeground; }; + + /** + Set the flag that holds wheter the shape is + in the foreground or not + + @param bIsForeground + Shape is on the foreground + */ + virtual void setIsForeground( const bool bIsForeground ) { mbIsForeground = bIsForeground; }; + // Misc @@ -247,6 +265,14 @@ 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. + */ + bool mbIsForeground; }; /** A set which contains all shapes in an ordered fashion. -- cgit