include/svx/svdobj.hxx                             |   21 +++++++++++
 svx/inc/sdr/primitive2d/sdrpathprimitive2d.hxx     |   18 +++++++++-
 svx/source/customshapes/EnhancedCustomShape2d.cxx  |   26 +++++---------
 svx/source/sdr/contact/viewcontactofsdrpathobj.cxx |   28 +++++++++++++++
 svx/source/sdr/primitive2d/sdrpathprimitive2d.cxx  |   37 ++++++++++++++++-----
 svx/source/svdraw/svdobj.cxx                       |    3 +
 6 files changed, 106 insertions(+), 27 deletions(-)

New commits:
commit 3e4f8b728c8030bc01a0fb3fca6a7ae4ac577742
Author: Armin Le Grand <armin.le.gr...@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 2f9542659cb0..0a16b0a0a5ec 100644
--- a/include/svx/svdobj.hxx
+++ b/include/svx/svdobj.hxx
@@ -270,11 +270,32 @@ public:
 class SvxShape;
 class SVX_DLLPUBLIC SdrObject: public SfxListener, public virtual 
tools::WeakBase
 {
+private:
     friend class                SdrObjListIter;
     friend class                SdrVirtObj;
     friend class                SdrRectObj;
     friend class                SdrDelayBroadcastObjectChange;
 
+    // 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; }
+
 public:
     SdrObject();
 
diff --git a/svx/inc/sdr/primitive2d/sdrpathprimitive2d.hxx 
b/svx/inc/sdr/primitive2d/sdrpathprimitive2d.hxx
index b60e9b3df565..e165344b26c1 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 void create2DDecomposition(Primitive2DContainer& 
rContainer, 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 a7f7f0c975e7..43ed2c77d63f 100644
--- a/svx/source/customshapes/EnhancedCustomShape2d.cxx
+++ b/svx/source/customshapes/EnhancedCustomShape2d.cxx
@@ -1963,22 +1963,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);
 
@@ -2335,6 +2319,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 2f203971ad4f..c3033bf71337 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 tools::Rectangle& 
rSnapRect(pFillGeometryDefiningShape->GetSnapRect());
+
+                    aUnitDefinitionPolyPolygon.append(
+                        basegfx::utils::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 37d4f5850b05..804cccf67e80 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
@@ -107,11 +125,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)
         {
         }
 
@@ -122,6 +142,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 612f01ab4d1f..40e936de5239 100644
--- a/svx/source/svdraw/svdobj.cxx
+++ b/svx/source/svdraw/svdobj.cxx
@@ -285,7 +285,8 @@ void SdrObject::SetBoundRectDirty()
 
 
 SdrObject::SdrObject() :
-    pPage(nullptr)
+    mpFillGeometryDefiningShape(nullptr)
+    ,pPage(nullptr)
     ,pModel(nullptr)
     ,pUserCall(nullptr)
     ,pPlusData(nullptr)
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to