[Libreoffice-commits] core.git: Branch 'private/swe/libreoffice-5-2+backports' - 3 commits - include/svx sc/qa svx/inc svx/source

Armin Le Grand (CIB) Armin.Le.Grand at cib.de
Wed Mar 21 14:08:16 UTC 2018


 include/svx/EnhancedCustomShape2d.hxx              |   23 +-
 include/svx/svdobj.hxx                             |   21 ++
 include/svx/svdopath.hxx                           |    7 
 sc/qa/unit/tiledrendering/data/shape.ods           |binary
 svx/inc/sdr/primitive2d/sdrpathprimitive2d.hxx     |   18 +
 svx/source/customshapes/EnhancedCustomShape2d.cxx  |  219 ++++++++++++---------
 svx/source/sdr/contact/viewcontactofsdrpathobj.cxx |   28 ++
 svx/source/sdr/primitive2d/sdrpathprimitive2d.cxx  |   37 ++-
 svx/source/svdraw/svdobj.cxx                       |    5 
 svx/source/svdraw/svdopath.cxx                     |    8 
 10 files changed, 251 insertions(+), 115 deletions(-)

New commits:
commit 673c0c9418c6937cb33378d3a91b494b73f8c735
Author: Armin Le Grand <Armin.Le.Grand at cib.de (CIB)>
Date:   Sat Mar 17 18:20:10 2018 +0100

    OperationSmiley: Adapted TestDocument
    
    The OperationSmiley fix is about removing the old hack
    that for CustomShapes in top-left and bottom-right points
    were added. In the ScTiledRenderingTest::testGraphicInvalidate
    UnitTest using this document exactly that top-left wrong polygon
    was hit which is now no longer there. The used shape was an
    ellipse, so this makes a difference - there *is* no geometry
    in the top-left corner of this shape. To fix that, I exchanged
    the ellipe CustomShape with a rectangle CustomShape. That way,
    the old hit behaviour will be replicated.
    
    Change-Id: I4b96ad79ba91166f097207226577d34087625589

diff --git a/sc/qa/unit/tiledrendering/data/shape.ods b/sc/qa/unit/tiledrendering/data/shape.ods
new file mode 100755
index 000000000000..36da8a70c1cd
Binary files /dev/null and b/sc/qa/unit/tiledrendering/data/shape.ods differ
commit 67ba3505a86f06bcfdc9949bb5342344ed1e0aac
Author: Armin Le Grand <Armin.Le.Grand at cib.de (CIB)>
Date:   Fri Feb 23 16:57:41 2018 +0100

    OperationSmiley: Added support for using same FillGeometry
    
    It is now possible to use a single FillGeometry to fill objects that
    are made of multiple filled objects (e.g. CustomShapes) so that
    they look as using a single fill. This is used for CustomShapes,
    but may later be 'extended' to be used for more cases. The basic
    functionality was already in the primitives, but had to be added
    to SDrObject due to these being used for CustomShapeVisualization
    (currently - would be better to change this to primitives, too).
    
    Change-Id: I1d9fb158191a9ec663e46f3911213be2f3d88986

diff --git a/include/svx/svdobj.hxx b/include/svx/svdobj.hxx
index efc3bb220c66..3899295bbfd5 100644
--- a/include/svx/svdobj.hxx
+++ b/include/svx/svdobj.hxx
@@ -261,6 +261,27 @@ class SvxShape;
 class SVX_DLLPUBLIC SdrObject: public SfxListener, public tools::WeakBase< SdrObject >
 {
 private:
+    // OperationSmiley: Allow at each SdrObject to set a FillGeometryDefiningShape,
+    // so that for SdrObjects where this is set, the definition of a defined FillStyle
+    // will use this, but the local geometry will be filled. This allows to fill
+    // multiple shapes with a unified fill, e.g think about CustomShapes.
+    // Currently this is *only* used for CustomShapes, but may be developed to get a
+    // common mechanism - usages for it are easy to be found. The current limitation
+    // to CustomShapes allows to to think about these SdrObjects to 'vanish' during the
+    // lifetime of 'this' - the SdrObjects without SdrPage and SdrModel are used as helper
+    // objects for SdrObjCustomShape and thus their lifetime is limited to the lifetime
+    // of this local object. For unifying this mechanism, some weak reference of
+    // SdrObjects would have to be thought about (not easy with the current implementation).
+    // So - allow *only* EnhancedCustomShape2d (which creates the visualizations for
+    // SdrObjCustomShape) to set this. Already allow unified read to use it - thus already
+    // allowing to implement as standard case for all kinds of SdrObjects.
+    friend class EnhancedCustomShape2d;
+    const SdrObject*            mpFillGeometryDefiningShape;
+    void setFillGeometryDefiningShape(const SdrObject* pNew) { mpFillGeometryDefiningShape = pNew; }
+public:
+    const SdrObject* getFillGeometryDefiningShape() const { return mpFillGeometryDefiningShape; }
+
+private:
     struct Impl;
     Impl* mpImpl;
 
diff --git a/svx/inc/sdr/primitive2d/sdrpathprimitive2d.hxx b/svx/inc/sdr/primitive2d/sdrpathprimitive2d.hxx
index 035a183f66f5..126eaaa2cc2a 100644
--- a/svx/inc/sdr/primitive2d/sdrpathprimitive2d.hxx
+++ b/svx/inc/sdr/primitive2d/sdrpathprimitive2d.hxx
@@ -40,20 +40,36 @@ namespace drawinglayer
             attribute::SdrLineFillShadowTextAttribute   maSdrLFSTAttribute;
             basegfx::B2DPolyPolygon                     maUnitPolyPolygon;
 
+            // OperationSmiley: Added to be able to define a FillGeometry different from local
+            // geometry. It is ignored when empty and/or equal to UnitPolyPolygon.
+            // If used and there is a fill, object's geomery (maUnitPolyPolygon) will be filled,
+            // but UnitDefinitionPolyPolygon will be used to define the FillStyle. Thus when
+            // using the 'same' UnitDefinitionPolyPolygon for multiple definitions,
+            // all filled stuff using it will fit seamless together.
+            // 'same' is in quotes since it is a UnitPolygon, so being relative to the
+            // unit polygon of the local geometry (UnitPolyPolygon). The definition is complete
+            // when applying the also given transfomation (maTransform)
+            basegfx::B2DPolyPolygon                     maUnitDefinitionPolyPolygon;
+
         protected:
             // local decomposition.
             virtual Primitive2DContainer create2DDecomposition(const geometry::ViewInformation2D& aViewInformation) const override;
 
         public:
+            // OperationSmiley: Extended to UnitDefinitionPolyPolygon, but when needed
+            // a 2nd version without can be defined that just does not set the
+            // maUnitDefinitionPolyPolygon or set equal to UnitPolyPolygon
             SdrPathPrimitive2D(
                 const basegfx::B2DHomMatrix& rTransform,
                 const attribute::SdrLineFillShadowTextAttribute& rSdrLFSTAttribute,
-                const basegfx::B2DPolyPolygon& rUnitPolyPolygon);
+                const basegfx::B2DPolyPolygon& rUnitPolyPolygon,
+                const basegfx::B2DPolyPolygon& rUnitDefinitionPolyPolygon);
 
             // data access
             const basegfx::B2DHomMatrix& getTransform() const { return maTransform; }
             const attribute::SdrLineFillShadowTextAttribute& getSdrLFSTAttribute() const { return maSdrLFSTAttribute; }
             const basegfx::B2DPolyPolygon& getUnitPolyPolygon() const { return maUnitPolyPolygon; }
+            const basegfx::B2DPolyPolygon& getUnitDefinitionPolyPolygon() const { return maUnitDefinitionPolyPolygon; }
 
             // compare operator
             virtual bool operator==(const BasePrimitive2D& rPrimitive) const override;
diff --git a/svx/source/customshapes/EnhancedCustomShape2d.cxx b/svx/source/customshapes/EnhancedCustomShape2d.cxx
index 8cafce039b42..b481c2263fa0 100644
--- a/svx/source/customshapes/EnhancedCustomShape2d.cxx
+++ b/svx/source/customshapes/EnhancedCustomShape2d.cxx
@@ -1891,22 +1891,6 @@ void EnhancedCustomShape2d::CreateSubPath(
 
     if(aNewB2DPolyPolygon.count())
     {
-        if( !bLineGeometryNeededOnly )
-        {
-            // hack aNewB2DPolyPolygon to fill logic rect - this is
-            // needed to produce gradient fills that look like mso
-            aNewB2DPolygon.clear();
-            aNewB2DPolygon.append(basegfx::B2DPoint(0,0));
-            aNewB2DPolygon.setClosed(true);
-            aNewB2DPolyPolygon.append(aNewB2DPolygon);
-
-            aNewB2DPolygon.clear();
-            aNewB2DPolygon.append(basegfx::B2DPoint(aLogicRect.GetWidth(),
-                                                    aLogicRect.GetHeight()));
-            aNewB2DPolygon.setClosed(true);
-            aNewB2DPolyPolygon.append(aNewB2DPolygon);
-        }
-
         // #i37011#
         bool bForceCreateTwoObjects(false);
 
@@ -2263,6 +2247,16 @@ SdrObject* EnhancedCustomShape2d::CreatePathObj( bool bLineGeometryNeededOnly )
                         rCustomShapeSet,
                         nColorIndex,
                         nColorCount);
+
+                    // OperationSmiley: when we have access to the SdrObjCustomShape and the
+                    // CustomShape is built with more than a single filled Geometry, use it
+                    // to define that all helper geometites defined here (SdrObjects currently)
+                    // will use the same FillGeometryDefinition (from the referenced SdrObjCustomShape).
+                    // This will all same-filled objects look like filled smoothly with the same style.
+                    if(pCustomShapeObj)
+                    {
+                        pObj->setFillGeometryDefiningShape(pCustomShapeObj);
+                    }
                 }
             }
 
diff --git a/svx/source/sdr/contact/viewcontactofsdrpathobj.cxx b/svx/source/sdr/contact/viewcontactofsdrpathobj.cxx
index 78455f4038f8..4f72e6c4169f 100644
--- a/svx/source/sdr/contact/viewcontactofsdrpathobj.cxx
+++ b/svx/source/sdr/contact/viewcontactofsdrpathobj.cxx
@@ -83,6 +83,7 @@ namespace sdr
 
             // prepare object transformation and unit polygon (direct model data)
             basegfx::B2DHomMatrix aObjectMatrix;
+            basegfx::B2DPolyPolygon aUnitDefinitionPolyPolygon;
             bool bIsLine(
                 !aUnitPolyPolygon.areControlPointsUsed()
                 && 1 == nPolyCount
@@ -166,6 +167,30 @@ namespace sdr
                 basegfx::B2DHomMatrix aInverse(aObjectMatrix);
                 aInverse.invert();
                 aUnitPolyPolygon.transform(aInverse);
+
+                // OperationSmiley: Check if a FillGeometryDefiningShape is set
+                const SdrObject* pFillGeometryDefiningShape(GetPathObj().getFillGeometryDefiningShape());
+
+                if(nullptr != pFillGeometryDefiningShape)
+                {
+                    // If yes, get it's BoundRange and use as defining Geometry for the FillStyle.
+                    // If no, aUnitDefinitionPolyPolygon will just be empty and thus be interpreted
+                    // as unused.
+                    // Using SnapRect will make the FillDefinition to always be extended e.g.
+                    // for rotated/sheared objects.
+                    const Rectangle& rSnapRect(pFillGeometryDefiningShape->GetSnapRect());
+
+                    aUnitDefinitionPolyPolygon.append(
+                        basegfx::tools::createPolygonFromRect(
+                            basegfx::B2DRange(
+                                rSnapRect.Left(), rSnapRect.Top(),
+                                rSnapRect.Right(), rSnapRect.Bottom())));
+
+                    // use same coordinate system as the shape geometry -> this
+                    // makes it relative to shape's unit geometry and thus freely
+                    // transformable with the shape
+                    aUnitDefinitionPolyPolygon.transform(aInverse);
+                }
             }
 
             // create primitive. Always create primitives to allow the decomposition of
@@ -174,7 +199,8 @@ namespace sdr
                 new drawinglayer::primitive2d::SdrPathPrimitive2D(
                     aObjectMatrix,
                     aAttribute,
-                    aUnitPolyPolygon));
+                    aUnitPolyPolygon,
+                    aUnitDefinitionPolyPolygon));
 
             return drawinglayer::primitive2d::Primitive2DContainer { xReference };
         }
diff --git a/svx/source/sdr/primitive2d/sdrpathprimitive2d.cxx b/svx/source/sdr/primitive2d/sdrpathprimitive2d.cxx
index 8abcd06555b2..f2276ec789df 100644
--- a/svx/source/sdr/primitive2d/sdrpathprimitive2d.cxx
+++ b/svx/source/sdr/primitive2d/sdrpathprimitive2d.cxx
@@ -43,13 +43,31 @@ namespace drawinglayer
                 // #i108255# no need to use correctOrientations here; target is
                 // straight visualisation
                 basegfx::B2DPolyPolygon aTransformed(getUnitPolyPolygon());
-
                 aTransformed.transform(getTransform());
-                aRetval.push_back(
-                    createPolyPolygonFillPrimitive(
-                        aTransformed,
-                        getSdrLFSTAttribute().getFill(),
-                        getSdrLFSTAttribute().getFillFloatTransGradient()));
+
+                // OperationSmiley: Check if a UnitDefinitionPolyPolygon is set
+                if(getUnitDefinitionPolyPolygon().count()
+                    && getUnitDefinitionPolyPolygon() != getUnitPolyPolygon())
+                {
+                    // if yes, use the B2DRange of it's transformed form
+                    basegfx::B2DPolyPolygon aTransformedDefinition(getUnitDefinitionPolyPolygon());
+                    aTransformedDefinition.transform(getTransform());
+
+                    aRetval.push_back(
+                        createPolyPolygonFillPrimitive(
+                            aTransformed,
+                            aTransformedDefinition.getB2DRange(),
+                            getSdrLFSTAttribute().getFill(),
+                            getSdrLFSTAttribute().getFillFloatTransGradient()));
+                }
+                else
+                {
+                    aRetval.push_back(
+                        createPolyPolygonFillPrimitive(
+                            aTransformed,
+                            getSdrLFSTAttribute().getFill(),
+                            getSdrLFSTAttribute().getFillFloatTransGradient()));
+                }
             }
 
             // add line
@@ -108,11 +126,13 @@ namespace drawinglayer
         SdrPathPrimitive2D::SdrPathPrimitive2D(
             const basegfx::B2DHomMatrix& rTransform,
             const attribute::SdrLineFillShadowTextAttribute& rSdrLFSTAttribute,
-            const basegfx::B2DPolyPolygon& rUnitPolyPolygon)
+            const basegfx::B2DPolyPolygon& rUnitPolyPolygon,
+            const basegfx::B2DPolyPolygon& rUnitDefinitionPolyPolygon)
         :   BufferedDecompositionPrimitive2D(),
             maTransform(rTransform),
             maSdrLFSTAttribute(rSdrLFSTAttribute),
-            maUnitPolyPolygon(rUnitPolyPolygon)
+            maUnitPolyPolygon(rUnitPolyPolygon),
+            maUnitDefinitionPolyPolygon(rUnitDefinitionPolyPolygon)
         {
         }
 
@@ -123,6 +143,7 @@ namespace drawinglayer
                 const SdrPathPrimitive2D& rCompare = static_cast<const SdrPathPrimitive2D&>(rPrimitive);
 
                 return (getUnitPolyPolygon() == rCompare.getUnitPolyPolygon()
+                    && getUnitDefinitionPolyPolygon() == rCompare.getUnitDefinitionPolyPolygon()
                     && getTransform() == rCompare.getTransform()
                     && getSdrLFSTAttribute() == rCompare.getSdrLFSTAttribute());
             }
diff --git a/svx/source/svdraw/svdobj.cxx b/svx/source/svdraw/svdobj.cxx
index daf0e77209e4..ea668691a417 100644
--- a/svx/source/svdraw/svdobj.cxx
+++ b/svx/source/svdraw/svdobj.cxx
@@ -290,8 +290,9 @@ void SdrObject::SetBoundRectDirty()
 
 
 SdrObject::SdrObject() :
-    mpImpl(new Impl),
-    mpProperties(nullptr)
+    mpFillGeometryDefiningShape(nullptr)
+    ,mpImpl(new Impl)
+    ,mpProperties(nullptr)
     ,mpViewContact(nullptr)
     ,pObjList(nullptr)
     ,pPage(nullptr)
commit f95ae08de255f8aa5ba0a69c1fca4b640d4da475
Author: Armin Le Grand <Armin.Le.Grand at cib.de (CIB)>
Date:   Thu Feb 22 11:14:31 2018 +0100

    OperationSmiley: Remove brightness from SdrPathObj
    
    There was a member at SdrPathObj called mdBrightness only for
    holding a blend value during creation of SdrPathObjs for
    CustomShape visualization. This has nothing to do on the
    model data, move it to where it belongs
    
    Change-Id: Iee101f90a1275ce1ed97e8e8d0ccf7084c83d4f6

diff --git a/include/svx/EnhancedCustomShape2d.hxx b/include/svx/EnhancedCustomShape2d.hxx
index c1f5ea99eb63..939ff2365290 100644
--- a/include/svx/EnhancedCustomShape2d.hxx
+++ b/include/svx/EnhancedCustomShape2d.hxx
@@ -130,16 +130,23 @@ class SVX_DLLPUBLIC EnhancedCustomShape2d : public SfxItemSet
         SAL_DLLPRIVATE bool     SetAdjustValueAsDouble( const double& rValue, const sal_Int32 nIndex );
         SAL_DLLPRIVATE sal_Int32 GetLuminanceChange( sal_uInt32 nIndex ) const;
         SAL_DLLPRIVATE Color    GetColorData( const Color& rFillColor, sal_uInt32 nIndex, double dBrightness ) const;
-        SAL_DLLPRIVATE void     AdaptObjColor(SdrPathObj& rObj, const SfxItemSet& rCustomShapeSet,
-                                                  sal_uInt32& nColorIndex, sal_uInt32 nColorCount);
-        SAL_DLLPRIVATE void     GetParameter( double& rParameterReturnValue,  const css::drawing::EnhancedCustomShapeParameter&,
-                                                  const bool bReplaceGeoWidth, const bool bReplaceGeoHeight ) const;
+        SAL_DLLPRIVATE void AdaptObjColor(
+            SdrPathObj& rObj,
+            double dBrightness,
+            const SfxItemSet& rCustomShapeSet,
+            sal_uInt32& nColorIndex,
+            sal_uInt32 nColorCount);
         SAL_DLLPRIVATE Point    GetPoint( const css::drawing::EnhancedCustomShapeParameterPair&,
                                                     const bool bScale = true, const bool bReplaceGeoSize = false ) const;
-
-        SAL_DLLPRIVATE void     CreateSubPath( sal_uInt16& rSrcPt, sal_uInt16& rSegmentInd, std::vector< SdrPathObj* >& rObjectList,
-                                                   bool bLineGeometryNeededOnly, bool bSortFilledObjectsToBack,
-                                                   sal_Int32 nIndex );
+        SAL_DLLPRIVATE void     GetParameter( double& rParameterReturnValue,  const css::drawing::EnhancedCustomShapeParameter&,
+                                                  const bool bReplaceGeoWidth, const bool bReplaceGeoHeight ) const;
+        SAL_DLLPRIVATE void CreateSubPath(
+            sal_Int32& rSrcPt,
+            sal_Int32& rSegmentInd,
+            std::vector< std::pair< SdrPathObj*, double> >& rObjectList,
+            bool bLineGeometryNeededOnly,
+            bool bSortFilledObjectsToBack,
+            sal_Int32 nIndex);
         SAL_DLLPRIVATE SdrObject* CreatePathObj( bool bLineGeometryNeededOnly );
         SAL_DLLPRIVATE void     ApplyShapeAttributes( const SdrCustomShapeGeometryItem& rItem );
 
diff --git a/include/svx/svdopath.hxx b/include/svx/svdopath.hxx
index ccdb218aaf8c..ff59b2050d58 100644
--- a/include/svx/svdopath.hxx
+++ b/include/svx/svdopath.hxx
@@ -55,9 +55,6 @@ protected:
     // for isolation of old Drag/Create code
     ImpPathForDragAndCreate*    mpDAC;
 
-    // brightness - used in EnhancedCustomShapes2d.cxx for DARKEN[LESS] and LIGHTEN[LESS] segments implementation
-    double mdBrightness;
-
     // helper functions for GET, SET, INS etc. PNT
     void ImpSetClosed(bool bClose);
     void ImpForceKind();
@@ -67,10 +64,8 @@ protected:
 
 public:
     virtual void SetRectsDirty(bool bNotMyself = false) override;
-    double GetBrightness() { return mdBrightness; }
-
     SdrPathObj(SdrObjKind eNewKind);
-    SdrPathObj(SdrObjKind eNewKind, const basegfx::B2DPolyPolygon& rPathPoly, double dBrightness = 1.0);
+    SdrPathObj(SdrObjKind eNewKind, const basegfx::B2DPolyPolygon& rPathPoly);
     virtual ~SdrPathObj();
 
     virtual void TakeObjInfo(SdrObjTransformInfoRec& rInfo) const override;
diff --git a/svx/source/customshapes/EnhancedCustomShape2d.cxx b/svx/source/customshapes/EnhancedCustomShape2d.cxx
index d63095410477..8cafce039b42 100644
--- a/svx/source/customshapes/EnhancedCustomShape2d.cxx
+++ b/svx/source/customshapes/EnhancedCustomShape2d.cxx
@@ -1376,10 +1376,13 @@ static basegfx::B2DPolygon CreateArc( const Rectangle& rRect, const Point& rStar
     return aRetval;
 }
 
-void EnhancedCustomShape2d::CreateSubPath( sal_uInt16& rSrcPt, sal_uInt16& rSegmentInd, std::vector< SdrPathObj* >& rObjectList,
-                                           const bool bLineGeometryNeededOnly,
-                                           const bool bSortFilledObjectsToBack,
-                                           sal_Int32 nIndex )
+void EnhancedCustomShape2d::CreateSubPath(
+    sal_Int32& rSrcPt,
+    sal_Int32& rSegmentInd,
+    std::vector< std::pair< SdrPathObj*, double> >& rObjectList,
+    const bool bLineGeometryNeededOnly,
+    const bool bSortFilledObjectsToBack,
+    sal_Int32 nIndex)
 {
     bool bNoFill = false;
     bool bNoStroke = false;
@@ -1925,12 +1928,12 @@ void EnhancedCustomShape2d::CreateSubPath( sal_uInt16& rSrcPt, sal_uInt16& rSegm
             {
                 basegfx::B2DPolyPolygon aClosedPolyPolygon(aNewB2DPolyPolygon);
                 aClosedPolyPolygon.setClosed(true);
-                SdrPathObj* pFill = new SdrPathObj(OBJ_POLY, aClosedPolyPolygon, dBrightness);
+                SdrPathObj* pFill = new SdrPathObj(OBJ_POLY, aClosedPolyPolygon);
                 SfxItemSet aTempSet(*this);
                 aTempSet.Put(makeSdrShadowItem(false));
                 aTempSet.Put(XLineStyleItem(drawing::LineStyle_NONE));
                 pFill->SetMergedItemSet(aTempSet);
-                rObjectList.push_back(pFill);
+                rObjectList.push_back(std::pair< SdrPathObj*, double >(pFill, dBrightness));
             }
 
             if(!bNoStroke)
@@ -1941,12 +1944,12 @@ void EnhancedCustomShape2d::CreateSubPath( sal_uInt16& rSrcPt, sal_uInt16& rSegm
                 // Thus, use a type that fits the polygon
                 SdrPathObj* pStroke = new SdrPathObj(
                     aNewB2DPolyPolygon.isClosed() ? OBJ_POLY : OBJ_PLIN,
-                    aNewB2DPolyPolygon, dBrightness);
+                    aNewB2DPolyPolygon);
                 SfxItemSet aTempSet(*this);
                 aTempSet.Put(makeSdrShadowItem(false));
                 aTempSet.Put(XFillStyleItem(drawing::FillStyle_NONE));
                 pStroke->SetMergedItemSet(aTempSet);
-                rObjectList.push_back(pStroke);
+                rObjectList.push_back(std::pair< SdrPathObj*, double >(pStroke, dBrightness));
             }
         }
         else
@@ -1960,13 +1963,13 @@ void EnhancedCustomShape2d::CreateSubPath( sal_uInt16& rSrcPt, sal_uInt16& rSegm
                 // see comment above about OBJ_PLIN
                 pObj = new SdrPathObj(
                     aNewB2DPolyPolygon.isClosed() ? OBJ_POLY : OBJ_PLIN,
-                    aNewB2DPolyPolygon, dBrightness);
+                    aNewB2DPolyPolygon);
                 aTempSet.Put(XFillStyleItem(drawing::FillStyle_NONE));
             }
             else
             {
                 aNewB2DPolyPolygon.setClosed(true);
-                pObj = new SdrPathObj(OBJ_POLY, aNewB2DPolyPolygon, dBrightness);
+                pObj = new SdrPathObj(OBJ_POLY, aNewB2DPolyPolygon);
             }
 
             if(bNoStroke)
@@ -1977,13 +1980,16 @@ void EnhancedCustomShape2d::CreateSubPath( sal_uInt16& rSrcPt, sal_uInt16& rSegm
             if(pObj)
             {
                 pObj->SetMergedItemSet(aTempSet);
-                rObjectList.push_back(pObj);
+                rObjectList.push_back(std::pair< SdrPathObj*, double >(pObj, dBrightness));
             }
         }
     }
 }
 
-void CorrectCalloutArrows( MSO_SPT eSpType, sal_uInt32 nLineObjectCount, std::vector< SdrPathObj* >& vObjectList )
+void CorrectCalloutArrows(
+    MSO_SPT eSpType,
+    sal_uInt32 nLineObjectCount,
+    std::vector< std::pair< SdrPathObj*, double> >& vObjectList )
 {
     bool bAccent = false;
     switch( eSpType )
@@ -2000,10 +2006,12 @@ void CorrectCalloutArrows( MSO_SPT eSpType, sal_uInt32 nLineObjectCount, std::ve
         case mso_sptAccentCallout90 :
         case mso_sptAccentBorderCallout90 :
         {
-            sal_uInt32 i, nLine = 0;
-            for ( i = 0; i < vObjectList.size(); i++ )
+            sal_uInt32 nLine = 0;
+
+            for ( std::pair< SdrPathObj*, double >& rCandidate : vObjectList )
             {
-                SdrPathObj* pObj( vObjectList[ i ] );
+                SdrPathObj* pObj(rCandidate.first);
+
                 if(pObj->IsLine())
                 {
                     nLine++;
@@ -2025,10 +2033,12 @@ void CorrectCalloutArrows( MSO_SPT eSpType, sal_uInt32 nLineObjectCount, std::ve
         case mso_sptCallout2 :
         case mso_sptBorderCallout2 :
         {
-            sal_uInt32 i, nLine = 0;
-            for ( i = 0; i < vObjectList.size(); i++ )
+            sal_uInt32 nLine = 0;
+
+            for ( std::pair< SdrPathObj*, double >& rCandidate : vObjectList )
             {
-                SdrPathObj* pObj( vObjectList[ i ] );
+                SdrPathObj* pObj(rCandidate.first);
+
                 if(pObj->IsLine())
                 {
                     nLine++;
@@ -2051,10 +2061,12 @@ void CorrectCalloutArrows( MSO_SPT eSpType, sal_uInt32 nLineObjectCount, std::ve
         case mso_sptCallout3 :
         case mso_sptBorderCallout3 :
         {
-            sal_uInt32 i, nLine = 0;
-            for ( i = 0; i < vObjectList.size(); i++ )
+            sal_uInt32 nLine = 0;
+
+            for ( std::pair< SdrPathObj*, double >& rCandidate : vObjectList )
             {
-                SdrPathObj* pObj( vObjectList[ i ] );
+                SdrPathObj* pObj(rCandidate.first);
+
                 if(pObj->IsLine())
                 {
                     if ( nLine )
@@ -2073,8 +2085,12 @@ void CorrectCalloutArrows( MSO_SPT eSpType, sal_uInt32 nLineObjectCount, std::ve
     }
 }
 
-void EnhancedCustomShape2d::AdaptObjColor(SdrPathObj& rObj, const SfxItemSet& rCustomShapeSet,
-                                          sal_uInt32& nColorIndex, sal_uInt32 nColorCount)
+void EnhancedCustomShape2d::AdaptObjColor(
+    SdrPathObj& rObj,
+    double dBrightness,
+    const SfxItemSet& rCustomShapeSet,
+    sal_uInt32& nColorIndex,
+    sal_uInt32 nColorCount)
 {
     if ( !rObj.IsLine() )
     {
@@ -2085,11 +2101,13 @@ void EnhancedCustomShape2d::AdaptObjColor(SdrPathObj& rObj, const SfxItemSet& rC
             case drawing::FillStyle_SOLID:
             {
                 Color aFillColor;
-                if ( nColorCount || rObj.GetBrightness() != 1.0 )
+
+                if ( nColorCount || 0.0 != dBrightness )
                 {
                     aFillColor = GetColorData(
-                        static_cast<const XFillColorItem&>(rCustomShapeSet.Get( XATTR_FILLCOLOR )).GetColorValue(),
-                        std::min(nColorIndex, nColorCount-1), rObj.GetBrightness() );
+                        static_cast<const XFillColorItem&>(rCustomShapeSet.Get(XATTR_FILLCOLOR)).GetColorValue(),
+                        std::min(nColorIndex, nColorCount-1),
+                        dBrightness );
                     rObj.SetMergedItem( XFillColorItem( "", aFillColor ) );
                 }
                 break;
@@ -2097,16 +2115,19 @@ void EnhancedCustomShape2d::AdaptObjColor(SdrPathObj& rObj, const SfxItemSet& rC
             case drawing::FillStyle_GRADIENT:
             {
                 XGradient aXGradient(static_cast<const XFillGradientItem&>(rObj.GetMergedItem(XATTR_FILLGRADIENT)).GetGradientValue());
-                if ( nColorCount || rObj.GetBrightness() != 1.0 )
+
+                if ( nColorCount || 0.0 != dBrightness )
                 {
                     aXGradient.SetStartColor(
                         GetColorData(
                             aXGradient.GetStartColor(),
-                            std::min(nColorIndex, nColorCount-1), rObj.GetBrightness() ));
+                            std::min(nColorIndex, nColorCount-1),
+                            dBrightness ));
                     aXGradient.SetEndColor(
                         GetColorData(
                             aXGradient.GetEndColor(),
-                            std::min(nColorIndex, nColorCount-1), rObj.GetBrightness() ));
+                            std::min(nColorIndex, nColorCount-1),
+                            dBrightness ));
                 }
 
                 rObj.SetMergedItem( XFillGradientItem( "", aXGradient ) );
@@ -2114,13 +2135,15 @@ void EnhancedCustomShape2d::AdaptObjColor(SdrPathObj& rObj, const SfxItemSet& rC
             }
             case drawing::FillStyle_HATCH:
             {
-                XHatch aXHatch(static_cast<const XFillHatchItem&>(rObj.GetMergedItem(XATTR_FILLHATCH)).GetHatchValue());
-                if ( nColorCount || rObj.GetBrightness() != 1.0 )
+                XHatch aXHatch(static_cast< const XFillHatchItem& >(rObj.GetMergedItem(XATTR_FILLHATCH)).GetHatchValue());
+
+                if ( nColorCount || 0.0 != dBrightness )
                 {
                     aXHatch.SetColor(
                         GetColorData(
                             aXHatch.GetColor(),
-                            std::min(nColorIndex, nColorCount-1), rObj.GetBrightness() ));
+                            std::min(nColorIndex, nColorCount-1),
+                            dBrightness ));
                 }
 
                 rObj.SetMergedItem( XFillHatchItem( "", aXHatch ) );
@@ -2128,7 +2151,7 @@ void EnhancedCustomShape2d::AdaptObjColor(SdrPathObj& rObj, const SfxItemSet& rC
             }
             case drawing::FillStyle_BITMAP:
             {
-                if ( nColorCount || rObj.GetBrightness() != 1.0 )
+                if ( nColorCount || 0.0 != dBrightness )
                 {
                     Bitmap aBitmap(static_cast<const XFillBitmapItem&>(rObj.GetMergedItem(XATTR_FILLBITMAP)).GetGraphicObject().GetGraphic().GetBitmapEx().GetBitmap());
 
@@ -2150,47 +2173,58 @@ void EnhancedCustomShape2d::AdaptObjColor(SdrPathObj& rObj, const SfxItemSet& rC
 
 SdrObject* EnhancedCustomShape2d::CreatePathObj( bool bLineGeometryNeededOnly )
 {
-    sal_Int32 nCoordSize = seqCoordinates.getLength();
+    const sal_Int32 nCoordSize(seqCoordinates.getLength());
+
     if ( !nCoordSize )
+    {
         return nullptr;
+    }
 
-    sal_uInt16 nSrcPt = 0;
-    sal_uInt16 nSegmentInd = 0;
-
-    std::vector< SdrPathObj* > vObjectList;
-    bool bSortFilledObjectsToBack = SortFilledObjectsToBackByDefault( eSpType );
-
-    sal_Int32 nSubPathIndex = 0;
+    std::vector< std::pair< SdrPathObj*, double > > vObjectList;
+    const bool bSortFilledObjectsToBack(SortFilledObjectsToBackByDefault(eSpType));
+    sal_Int32 nSubPathIndex(0);
+    sal_Int32 nSrcPt(0);
+    sal_Int32 nSegmentInd(0);
+    SdrObject* pRet(nullptr);
 
     while( nSegmentInd <= seqSegments.getLength() )
     {
-        CreateSubPath( nSrcPt, nSegmentInd, vObjectList, bLineGeometryNeededOnly, bSortFilledObjectsToBack, nSubPathIndex );
-        nSubPathIndex ++;
+        CreateSubPath(
+            nSrcPt,
+            nSegmentInd,
+            vObjectList,
+            bLineGeometryNeededOnly,
+            bSortFilledObjectsToBack,
+            nSubPathIndex);
+        nSubPathIndex++;
     }
 
-    SdrObject* pRet = nullptr;
-
     if ( !vObjectList.empty() )
     {
-        const SfxItemSet& rCustomShapeSet = pCustomShapeObj->GetMergedItemSet();
-        sal_uInt32      nColorCount = nColorData >> 28;
-        sal_uInt32      nColorIndex = 0;
+        const SfxItemSet& rCustomShapeSet(pCustomShapeObj->GetMergedItemSet());
+        const sal_uInt32 nColorCount(nColorData >> 28);
+        sal_uInt32 nColorIndex(0);
 
         // #i37011# remove invisible objects
         if(!vObjectList.empty())
         {
-            std::vector< SdrPathObj* > vTempList;
+            std::vector< std::pair< SdrPathObj*, double> > vTempList;
 
-            for(SdrPathObj* pObj : vObjectList)
+            for ( std::pair< SdrPathObj*, double >& rCandidate : vObjectList )
             {
-                const drawing::LineStyle eLineStyle =static_cast<const XLineStyleItem&>(pObj->GetMergedItem(XATTR_LINESTYLE)).GetValue();
-                const drawing::FillStyle eFillStyle = static_cast<const XFillStyleItem&>(pObj->GetMergedItem(XATTR_FILLSTYLE)).GetValue();
+                SdrPathObj* pObj(rCandidate.first);
+                const drawing::LineStyle eLineStyle(static_cast<const XLineStyleItem&>(pObj->GetMergedItem(XATTR_LINESTYLE)).GetValue());
+                const drawing::FillStyle eFillStyle(static_cast<const XFillStyleItem&>(pObj->GetMergedItem(XATTR_FILLSTYLE)).GetValue());
 
                 // #i40600# if bLineGeometryNeededOnly is set, linestyle does not matter
-                if( !bLineGeometryNeededOnly && ( drawing::LineStyle_NONE == eLineStyle ) && ( drawing::FillStyle_NONE == eFillStyle ) )
+                if(!bLineGeometryNeededOnly && (drawing::LineStyle_NONE == eLineStyle) && (drawing::FillStyle_NONE == eFillStyle))
+                {
                     delete pObj;
+                }
                 else
-                    vTempList.push_back(pObj);
+                {
+                    vTempList.push_back(rCandidate);
+                }
             }
 
             vObjectList = vTempList;
@@ -2199,16 +2233,23 @@ SdrObject* EnhancedCustomShape2d::CreatePathObj( bool bLineGeometryNeededOnly )
         if(1L == vObjectList.size())
         {
             // a single object, correct some values
-            AdaptObjColor(*vObjectList[0L],rCustomShapeSet,nColorIndex,nColorCount);
+            AdaptObjColor(
+                *vObjectList.begin()->first,
+                vObjectList.begin()->second,
+                rCustomShapeSet,
+                nColorIndex,
+                nColorCount);
         }
         else
         {
-            sal_Int32 nLineObjectCount = 0;
-            sal_Int32 nAreaObjectCount = 0;
+            sal_Int32 nLineObjectCount(0);
+            sal_Int32 nAreaObjectCount(0);
 
             // correct some values and collect content data
-            for (SdrPathObj* pObj : vObjectList)
+            for ( std::pair< SdrPathObj*, double >& rCandidate : vObjectList )
             {
+                SdrPathObj* pObj(rCandidate.first);
+
                 if(pObj->IsLine())
                 {
                     nLineObjectCount++;
@@ -2216,34 +2257,48 @@ SdrObject* EnhancedCustomShape2d::CreatePathObj( bool bLineGeometryNeededOnly )
                 else
                 {
                     nAreaObjectCount++;
-                    AdaptObjColor(*pObj,rCustomShapeSet,nColorIndex,nColorCount);
+                    AdaptObjColor(
+                        *pObj,
+                        rCandidate.second,
+                        rCustomShapeSet,
+                        nColorIndex,
+                        nColorCount);
                 }
             }
 
             // #i88870# correct line arrows for callouts
             if ( nLineObjectCount )
-                CorrectCalloutArrows( eSpType, nLineObjectCount, vObjectList );
+            {
+                CorrectCalloutArrows(
+                    eSpType,
+                    nLineObjectCount,
+                    vObjectList);
+            }
 
             // sort objects so that filled ones are in front. Necessary
             // for some strange objects
-            if ( bSortFilledObjectsToBack )
+            if(bSortFilledObjectsToBack)
             {
-                std::vector< SdrPathObj* > vTempList;
+                std::vector< std::pair< SdrPathObj*, double> > vTempList;
                 vTempList.reserve(vObjectList.size());
 
-                for (SdrPathObj* pObj : vObjectList)
+                for ( std::pair< SdrPathObj*, double >& rCandidate : vObjectList )
                 {
+                    SdrPathObj* pObj(rCandidate.first);
+
                     if ( !pObj->IsLine() )
                     {
-                        vTempList.push_back(pObj);
+                        vTempList.push_back(rCandidate);
                     }
                 }
 
-                for (SdrPathObj* pObj : vObjectList)
+                for ( std::pair< SdrPathObj*, double >& rCandidate : vObjectList )
                 {
+                    SdrPathObj* pObj(rCandidate.first);
+
                     if ( pObj->IsLine() )
                     {
-                        vTempList.push_back(pObj);
+                        vTempList.push_back(rCandidate);
                     }
                 }
 
@@ -2260,14 +2315,16 @@ SdrObject* EnhancedCustomShape2d::CreatePathObj( bool bLineGeometryNeededOnly )
         {
             pRet = new SdrObjGroup;
 
-            for (SdrPathObj* pObj : vObjectList)
+            for ( std::pair< SdrPathObj*, double >& rCandidate : vObjectList )
             {
+                SdrPathObj* pObj(rCandidate.first);
+
                 pRet->GetSubList()->NbcInsertObject(pObj);
             }
         }
         else if(1 == vObjectList.size())
         {
-            pRet = vObjectList[0L];
+            pRet = vObjectList.begin()->first;
         }
 
         if(pRet)
diff --git a/svx/source/svdraw/svdopath.cxx b/svx/source/svdraw/svdopath.cxx
index fdc9c9c63a5d..c148e5bf1989 100644
--- a/svx/source/svdraw/svdopath.cxx
+++ b/svx/source/svdraw/svdopath.cxx
@@ -1662,17 +1662,15 @@ sdr::contact::ViewContact* SdrPathObj::CreateObjectSpecificViewContact()
 
 SdrPathObj::SdrPathObj(SdrObjKind eNewKind)
 :   meKind(eNewKind),
-    mpDAC(nullptr),
-    mdBrightness(1.0)
+    mpDAC(nullptr)
 {
     bClosedObj = IsClosed();
 }
 
-SdrPathObj::SdrPathObj(SdrObjKind eNewKind, const basegfx::B2DPolyPolygon& rPathPoly, double dBrightness)
+SdrPathObj::SdrPathObj(SdrObjKind eNewKind, const basegfx::B2DPolyPolygon& rPathPoly)
 :   maPathPolygon(rPathPoly),
     meKind(eNewKind),
-    mpDAC(nullptr),
-    mdBrightness(dBrightness)
+    mpDAC(nullptr)
 {
     bClosedObj = IsClosed();
     ImpForceKind();


More information about the Libreoffice-commits mailing list