chart2/source/view/charttypes/AreaChart.cxx |   20 +---
 chart2/source/view/charttypes/BarChart.cxx  |   42 +++------
 chart2/source/view/charttypes/NetChart.cxx  |   12 +-
 chart2/source/view/inc/PropertyMapper.hxx   |    5 -
 chart2/source/view/inc/ShapeFactory.hxx     |    8 -
 chart2/source/view/main/PropertyMapper.cxx  |  125 ----------------------------
 chart2/source/view/main/ShapeFactory.cxx    |   21 ----
 7 files changed, 36 insertions(+), 197 deletions(-)

New commits:
commit 417feeff2c547f2675e3bfcea639faf7fd140e7f
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Tue Feb 1 14:16:33 2022 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Thu Feb 3 10:54:40 2022 +0100

    tdf#147027 Cannot display pattern, gradient or hatch fill in bar or area 
chart
    
    this partially reverts
        commit 0b0934056b47485527442b6366d7fd3274a4601f
        Author: Noel Grandin <noelgran...@gmail.com>
        Date:   Tue Jan 4 18:50:01 2022 +0200
        bypass SvxShape when creating rectangles in chart2
    
    specifically the part responsible for setting all the style-related
    properties on the SdrPathObj.
    
    There is just too much logic to re-implement in bypassing SvxShape. And
    the logic is spread out over several different classes/methods and
    overrides, so getting it perfect is pretty much impossible.
    
    Change-Id: I7dbae95dda780e7fa40c4e0798e6c199e4eaf41c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129282
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/chart2/source/view/charttypes/AreaChart.cxx 
b/chart2/source/view/charttypes/AreaChart.cxx
index 3bb573da8538..0dd77b97d7b7 100644
--- a/chart2/source/view/charttypes/AreaChart.cxx
+++ b/chart2/source/view/charttypes/AreaChart.cxx
@@ -457,26 +457,22 @@ bool AreaChart::impl_createArea( VDataSeries* pSeries
     pPosHelper->transformScaledLogicToScene( aPoly );
 
     //create area:
+    rtl::Reference< SvxShape > xShape;
     if(m_nDimension==3)
     {
-        rtl::Reference< SvxShape > xShape = ShapeFactory::createArea3D( 
xSeriesGroupShape_Shapes
+        xShape = ShapeFactory::createArea3D( xSeriesGroupShape_Shapes
                 , aPoly, getTransformedDepth() );
-        PropertyMapper::setMappedProperties( *xShape
-                    , pSeries->getPropertiesOfSeries()
-                    , 
PropertyMapper::getPropertyNameMapForFilledSeriesProperties() );
-        //because of this name this line will be used for marking
-        ShapeFactory::setShapeName(xShape, "MarkHandles");
     }
     else //m_nDimension!=3
     {
-        SdrPathObj* pShape = ShapeFactory::createArea2D( 
xSeriesGroupShape_Shapes
+        xShape = ShapeFactory::createArea2D( xSeriesGroupShape_Shapes
                 , aPoly );
-        PropertyMapper::setPropertyNameMapForFilledSeriesProperties(
-                    pShape
-                    , pSeries->getPropertiesOfSeries());
-        //because of this name this line will be used for marking
-        ShapeFactory::setShapeName(pShape, "MarkHandles");
     }
+    PropertyMapper::setMappedProperties( *xShape
+                , pSeries->getPropertiesOfSeries()
+                , 
PropertyMapper::getPropertyNameMapForFilledSeriesProperties() );
+    //because of this name this line will be used for marking
+    ::chart::ShapeFactory::setShapeName(xShape, "MarkHandles");
     return true;
 }
 
diff --git a/chart2/source/view/charttypes/BarChart.cxx 
b/chart2/source/view/charttypes/BarChart.cxx
index f2dbf0d2422c..c09548e5f17e 100644
--- a/chart2/source/view/charttypes/BarChart.cxx
+++ b/chart2/source/view/charttypes/BarChart.cxx
@@ -859,6 +859,7 @@ void BarChart::doXSlot(
             //create partial point
             if( !approxEqual(fLowerYValue,fUpperYValue) )
             {
+                rtl::Reference< SvxShape >  xShape;
                 if( m_nDimension==3 )
                 {
                     drawing::Position3D aLogicBottom            
(fLogicX,fLogicYStart,fLogicZ);
@@ -893,22 +894,9 @@ void BarChart::doXSlot(
                     if( fTopHeight < 0 )
                         fTopHeight *= -1.0;
 
-                    rtl::Reference< SvxShape > xShape = createDataPoint3D_Bar(
+                    xShape = createDataPoint3D_Bar(
                         xSeriesGroupShape_Shapes, aTransformedBottom, aSize, 
fTopHeight, nRotateZAngleHundredthDegree
                         , xDataPointProperties, nGeometry3D );
-
-                    if(bHasFillColorMapping)
-                    {
-                        double nPropVal = 
pSeries->getValueByProperty(nPointIndex, "FillColor");
-                        if(!std::isnan(nPropVal))
-                        {
-                            xShape->setPropertyValue("FillColor", 
uno::Any(static_cast<sal_Int32>(nPropVal)));
-                        }
-                    }
-                    //set name/classified ObjectID (CID)
-                    ShapeFactory::setShapeName(xShape
-                        , ObjectIdentifier::createPointCID(
-                            pSeries->getPointCID_Stub(),nPointIndex) );
                 }
                 else //m_nDimension!=3
                 {
@@ -925,22 +913,22 @@ void BarChart::doXSlot(
                     AddPointToPoly( aPoly, aLeftUpperPoint );
                     AddPointToPoly( aPoly, drawing::Position3D( 
fLogicX-fLogicBarWidth/2.0,fLowerYValue,fLogicZ) );
                     pPosHelper->transformScaledLogicToScene( aPoly );
-                    std::optional<sal_Int32> xFillColor;
-                    if(bHasFillColorMapping)
+                    xShape = ShapeFactory::createArea2D( 
xSeriesGroupShape_Shapes, aPoly );
+                    PropertyMapper::setMappedProperties( *xShape, 
xDataPointProperties, 
PropertyMapper::getPropertyNameMapForFilledSeriesProperties() );
+                }
+
+                if(bHasFillColorMapping)
+                {
+                    double nPropVal = pSeries->getValueByProperty(nPointIndex, 
"FillColor");
+                    if(!std::isnan(nPropVal))
                     {
-                        double nPropVal = 
pSeries->getValueByProperty(nPointIndex, "FillColor");
-                        if(!std::isnan(nPropVal))
-                            xFillColor = static_cast<sal_Int32>(nPropVal);
+                        xShape->setPropertyValue("FillColor", 
uno::Any(static_cast<sal_Int32>(nPropVal)));
                     }
-                    SdrPathObj* pShape = ShapeFactory::createArea2D( 
xSeriesGroupShape_Shapes, aPoly, /*bSetZOrderToZero*/false );
-                    
PropertyMapper::setPropertyNameMapForFilledSeriesProperties(pShape, 
xDataPointProperties, xFillColor);
-
-                    //set name/classified ObjectID (CID)
-                    ShapeFactory::setShapeName(pShape
-                        , ObjectIdentifier::createPointCID(
-                            pSeries->getPointCID_Stub(),nPointIndex) );
                 }
-
+                //set name/classified ObjectID (CID)
+                ShapeFactory::setShapeName(xShape
+                    , ObjectIdentifier::createPointCID(
+                        pSeries->getPointCID_Stub(),nPointIndex) );
             }
 
             //create error bar
diff --git a/chart2/source/view/charttypes/NetChart.cxx 
b/chart2/source/view/charttypes/NetChart.cxx
index ada893b8d152..ed2b0e8387d0 100644
--- a/chart2/source/view/charttypes/NetChart.cxx
+++ b/chart2/source/view/charttypes/NetChart.cxx
@@ -222,12 +222,14 @@ bool NetChart::impl_createArea( VDataSeries* pSeries
     pPosHelper->transformScaledLogicToScene( aPoly );
 
     //create area:
-    SdrPathObj* pShape = ShapeFactory::createArea2D( xSeriesGroupShape_Shapes
-                            , aPoly );
-    PropertyMapper::setPropertyNameMapForFilledSeriesProperties(pShape
-                , pSeries->getPropertiesOfSeries() );
+    rtl::Reference<SvxShapePolyPolygon>
+        xShape = ShapeFactory::createArea2D( xSeriesGroupShape_Shapes
+                , aPoly );
+    PropertyMapper::setMappedProperties( *xShape
+                , pSeries->getPropertiesOfSeries()
+                , 
PropertyMapper::getPropertyNameMapForFilledSeriesProperties() );
     //because of this name this line will be used for marking
-    ::chart::ShapeFactory::setShapeName(pShape, "MarkHandles");
+    ::chart::ShapeFactory::setShapeName(xShape, "MarkHandles");
     return true;
 }
 
diff --git a/chart2/source/view/inc/PropertyMapper.hxx 
b/chart2/source/view/inc/PropertyMapper.hxx
index 652a6a05131c..c4d9a1fa2577 100644
--- a/chart2/source/view/inc/PropertyMapper.hxx
+++ b/chart2/source/view/inc/PropertyMapper.hxx
@@ -20,7 +20,6 @@
 
 #include <sal/config.h>
 
-#include <optional>
 #include <unordered_map>
 
 #include <com/sun/star/uno/Sequence.h>
@@ -28,7 +27,6 @@
 
 namespace com::sun::star::beans { class XPropertySet; }
 class SvxShape;
-class SdrPathObj;
 
 namespace chart
 {
@@ -102,9 +100,6 @@ public:
     static const tPropertyNameMap& getPropertyNameMapForTextShapeProperties();
 
     static const tPropertyNameMap& 
getPropertyNameMapForFilledSeriesProperties();
-    static void setPropertyNameMapForFilledSeriesProperties(SdrPathObj* pShape,
-                    const css::uno::Reference< css::beans::XPropertySet >& 
xSource,
-                    std::optional<sal_Int32> xFillColor = {});
     static const tPropertyNameMap& getPropertyNameMapForLineSeriesProperties();
     static const tPropertyNameMap& getPropertyNameMapForTextLabelProperties();
 
diff --git a/chart2/source/view/inc/ShapeFactory.hxx 
b/chart2/source/view/inc/ShapeFactory.hxx
index c9e7aab8384a..86ae5411d086 100644
--- a/chart2/source/view/inc/ShapeFactory.hxx
+++ b/chart2/source/view/inc/ShapeFactory.hxx
@@ -40,7 +40,6 @@ namespace com::sun::star::drawing { struct Position3D; }
 namespace com::sun::star::graphic { class XGraphic; }
 namespace com::sun::star::lang { class XMultiServiceFactory; }
 namespace com::sun::star::drawing { struct Direction3D; }
-class SdrPathObj;
 
 namespace chart
 {
@@ -148,10 +147,9 @@ public:
                     , const 
std::vector<std::vector<css::drawing::Position3D>>& rPolyPolygon
                     , double fDepth);
 
-    static SdrPathObj*
+    static rtl::Reference<SvxShapePolyPolygon>
         createArea2D( const rtl::Reference<SvxShapeGroupAnyD>& xTarget
-                    , const 
std::vector<std::vector<css::drawing::Position3D>>& rPolyPolygon
-                    , bool bSetZOrderToZero = true);
+                    , const 
std::vector<std::vector<css::drawing::Position3D>>& rPolyPolygon);
 
     static rtl::Reference<SvxShapePolyPolygon>
         createSymbol2D( const rtl::Reference<SvxShapeGroupAnyD>& xTarget
@@ -249,8 +247,6 @@ public:
 
     static void setShapeName( const rtl::Reference< SvxShape >& xShape
             , const OUString& rName );
-    static void setShapeName( SdrPathObj* pPath
-            , const OUString& rName );
 
     static OUString getShapeName( const css::uno::Reference< 
css::drawing::XShape >& xShape );
 
diff --git a/chart2/source/view/main/PropertyMapper.cxx 
b/chart2/source/view/main/PropertyMapper.cxx
index d7c1dd8f1c99..ec49c032d61d 100644
--- a/chart2/source/view/main/PropertyMapper.cxx
+++ b/chart2/source/view/main/PropertyMapper.cxx
@@ -22,33 +22,12 @@
 
 #include <com/sun/star/beans/XMultiPropertySet.hpp>
 #include <com/sun/star/beans/XPropertySet.hpp>
-#include <com/sun/star/drawing/BitmapMode.hpp>
 #include <com/sun/star/drawing/TextVerticalAdjust.hpp>
 #include <com/sun/star/drawing/TextHorizontalAdjust.hpp>
-#include <com/sun/star/drawing/FillStyle.hpp>
 #include <com/sun/star/drawing/LineJoint.hpp>
-#include <com/sun/star/drawing/LineStyle.hpp>
-#include <com/sun/star/drawing/RectanglePoint.hpp>
 #include <com/sun/star/style/ParagraphAdjust.hpp>
 #include <tools/diagnose_ex.h>
 #include <svx/unoshape.hxx>
-#include <svx/svdopath.hxx>
-#include <svx/xfillit0.hxx>
-#include <svx/xflbckit.hxx>
-#include <svx/xflbmpit.hxx>
-#include <svx/xflbmsli.hxx>
-#include <svx/xflbmsxy.hxx>
-#include <svx/xflbmtit.hxx>
-#include <svx/xflboxy.hxx>
-#include <svx/xflbstit.hxx>
-#include <svx/xflbtoxy.hxx>
-#include <svx/xflclit.hxx>
-#include <svx/xfltrit.hxx>
-#include <svx/xlineit0.hxx>
-#include <svx/xlncapit.hxx>
-#include <svx/xlnclit.hxx>
-#include <svx/xlntrit.hxx>
-#include <svx/xlnwtit.hxx>
 
 namespace chart
 {
@@ -496,110 +475,6 @@ const tPropertyNameMap& 
PropertyMapper::getPropertyNameMapForFilledSeriesPropert
     return s_aShapePropertyMapForFilledSeriesProperties;
 }
 
-void PropertyMapper::setPropertyNameMapForFilledSeriesProperties(SdrPathObj* 
pShape
-        , const uno::Reference< beans::XPropertySet >& xSource
-        , std::optional<sal_Int32> xFillColor)
-{
-    //shape property -- chart model object property
-    static tPropertyNameMap s_aShapePropertyMapForFilledSeriesProperties{
-        {"FillBackground",               "FillBackground"},
-        {"FillBitmapName",               "FillBitmapName"},
-        {"FillColor",                    "Color"},
-        {"FillGradientName",             "GradientName"},
-        {"FillGradientStepCount",        "GradientStepCount"},
-        {"FillHatchName",                "HatchName"},
-        {"FillStyle",                    "FillStyle"},
-        {"FillTransparence",             "Transparency"},
-        {"FillTransparenceGradientName", "TransparencyGradientName"},
-        //bitmap properties
-        {"FillBitmapMode",               "FillBitmapMode"},
-        {"FillBitmapSizeX",              "FillBitmapSizeX"},
-        {"FillBitmapSizeY",              "FillBitmapSizeY"},
-        {"FillBitmapLogicalSize",        "FillBitmapLogicalSize"},
-        {"FillBitmapOffsetX",            "FillBitmapOffsetX"},
-        {"FillBitmapOffsetY",            "FillBitmapOffsetY"},
-        {"FillBitmapRectanglePoint",     "FillBitmapRectanglePoint"},
-        {"FillBitmapPositionOffsetX",    "FillBitmapPositionOffsetX"},
-        {"FillBitmapPositionOffsetY",    "FillBitmapPositionOffsetY"},
-        //line properties
-        {"LineColor",                    "BorderColor"},
-        {"LineDashName",                 "BorderDashName"},
-        {"LineStyle",                    "BorderStyle"},
-        {"LineTransparence",             "BorderTransparency"},
-        {"LineWidth",                    "BorderWidth"},
-        {"LineCap",                      "LineCap"}};
-    std::optional<SfxItemSet> xOptionSet;
-    for (auto const& elem : s_aShapePropertyMapForFilledSeriesProperties)
-    {
-        const OUString & rSource = elem.second;
-        try
-        {
-            uno::Any aAny( xSource->getPropertyValue(rSource) );
-            //do not set empty anys because of performance (otherwise 
SdrAttrObj::ItemChange will take much longer)
-            if( !aAny.hasValue() )
-                continue;
-            if (!xOptionSet)
-                xOptionSet.emplace(pShape->GetObjectItemPool());
-            if (rSource == "FillBackground")
-                xOptionSet->Put(XFillBackgroundItem(aAny.get<bool>()));
-            else if (rSource == "Color")
-                xOptionSet->Put(XFillColorItem(OUString(), 
Color(ColorTransparency, aAny.get<sal_Int32>())));
-            else if (rSource == "FillStyle")
-                
xOptionSet->Put(XFillStyleItem(aAny.get<css::drawing::FillStyle>()));
-            else if (rSource == "Transparency")
-                xOptionSet->Put(XFillTransparenceItem(aAny.get<sal_uInt16>()));
-            else if (rSource == "FillBitmapMode")
-            {
-                drawing::BitmapMode aMode;
-                aAny >>= aMode;
-                xOptionSet->Put( XFillBmpTileItem( aMode == 
drawing::BitmapMode_REPEAT ) );
-                xOptionSet->Put( XFillBmpStretchItem( aMode == 
drawing::BitmapMode_STRETCH ) );
-            }
-            else if (rSource == "FillBitmapSizeX")
-                xOptionSet->Put(XFillBmpSizeXItem(aAny.get<sal_Int32>()));
-            else if (rSource == "FillBitmapSizeY")
-                xOptionSet->Put(XFillBmpSizeYItem(aAny.get<sal_Int32>()));
-            else if (rSource == "FillBitmapLogicalSize")
-                xOptionSet->Put(XFillBmpSizeLogItem(aAny.get<bool>()));
-            else if (rSource == "FillBitmapPositionOffsetX")
-                xOptionSet->Put(XFillBmpPosOffsetXItem(aAny.get<sal_Int32>()));
-            else if (rSource == "FillBitmapPositionOffsetY")
-                xOptionSet->Put(XFillBmpPosOffsetYItem(aAny.get<sal_Int32>()));
-            else if (rSource == "FillBitmapRectanglePoint")
-                
xOptionSet->Put(XFillBmpPosItem(static_cast<RectPoint>(aAny.get<css::drawing::RectanglePoint>())));
-            else if (rSource == "FillBitmapOffsetX")
-                
xOptionSet->Put(XFillBmpTileOffsetXItem(aAny.get<sal_Int32>()));
-            else if (rSource == "FillBitmapOffsetY")
-                
xOptionSet->Put(XFillBmpTileOffsetYItem(aAny.get<sal_Int32>()));
-            else if (rSource == "BorderColor")
-                xOptionSet->Put(XLineColorItem(OUString(), 
Color(ColorTransparency, aAny.get<sal_Int32>())));
-            else if (rSource == "BorderStyle")
-                
xOptionSet->Put(XLineStyleItem(aAny.get<css::drawing::LineStyle>()));
-            else if (rSource == "BorderTransparency")
-                xOptionSet->Put(XLineTransparenceItem(aAny.get<sal_uInt16>()));
-            else if (rSource == "BorderWidth")
-                xOptionSet->Put(XLineWidthItem(aAny.get<sal_Int32>()));
-            else if (rSource == "LineCap")
-                
xOptionSet->Put(XLineCapItem(aAny.get<css::drawing::LineCap>()));
-            else
-                SAL_WARN("chart2", "forgot this one " << rSource);
-        }
-        catch( const uno::Exception& )
-        {
-            TOOLS_WARN_EXCEPTION("chart2", "" );
-        }
-    }
-    if (xFillColor)
-    {
-        if (!xOptionSet)
-            xOptionSet.emplace(pShape->GetObjectItemPool());
-        xOptionSet->Put(XFillColorItem(OUString(), Color(ColorTransparency, 
*xFillColor)));
-    }
-    if (xOptionSet)
-        pShape->GetProperties().SetObjectItemSet(*xOptionSet);
-
-}
-
 void PropertyMapper::setMultiProperties(
                   const tNameSequence& rNames
                 , const tAnySequence&  rValues
diff --git a/chart2/source/view/main/ShapeFactory.cxx 
b/chart2/source/view/main/ShapeFactory.cxx
index c44988d58774..f9fde5fcae69 100644
--- a/chart2/source/view/main/ShapeFactory.cxx
+++ b/chart2/source/view/main/ShapeFactory.cxx
@@ -1107,21 +1107,16 @@ rtl::Reference<Svx3DExtrudeObject>
     return xShape;
 }
 
-SdrPathObj*
+rtl::Reference<SvxShapePolyPolygon>
         ShapeFactory::createArea2D( const rtl::Reference<SvxShapeGroupAnyD>& 
xTarget
-                    , const 
std::vector<std::vector<css::drawing::Position3D>>& rPolyPolygon
-                    , bool bSetZOrderToZero )
+                    , const 
std::vector<std::vector<css::drawing::Position3D>>& rPolyPolygon )
 {
     if( !xTarget.is() )
         return nullptr;
 
     //create shape
     SdrPathObj* pPath = new 
SdrPathObj(xTarget->GetSdrObject()->getSdrModelFromSdrObject(), 
SdrObjKind::Polygon);
-    if (bSetZOrderToZero)
-        // insert at ZOrder 0, an area should always be behind other shapes
-        xTarget->GetSdrObject()->GetSubList()->InsertObject(pPath, 0);
-    else
-        xTarget->GetSdrObject()->GetSubList()->InsertObject(pPath);
+    xTarget->GetSdrObject()->GetSubList()->InsertObject(pPath);
 
     //set properties
     try
@@ -1136,7 +1131,7 @@ SdrPathObj*
     {
         TOOLS_WARN_EXCEPTION("chart2", "" );
     }
-    return pPath;
+    return static_cast<SvxShapePolyPolygon*>(pPath->getUnoShape().get());
 }
 
 static drawing::PolyPolygonShape3D createPolyPolygon_Symbol( const 
drawing::Position3D& rPos
@@ -2467,14 +2462,6 @@ void ShapeFactory::makeShapeInvisible( const 
rtl::Reference< SvxShape >& xShape
 
 // set a name/CID at a shape (is used for selection handling)
 
-void ShapeFactory::setShapeName( SdrPathObj* pShape
-                               , const OUString& rName )
-{
-    if(!pShape)
-        return;
-    pShape->SetName(rName);
-}
-
 void ShapeFactory::setShapeName( const rtl::Reference< SvxShape >& xShape
                                , const OUString& rName )
 {

Reply via email to