chart2/source/inc/CommonConverters.hxx      |    7 +
 chart2/source/tools/CommonConverters.cxx    |   28 ++++++
 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     |    5 -
 chart2/source/view/main/PropertyMapper.cxx  |  125 ++++++++++++++++++++++++++++
 chart2/source/view/main/ShapeFactory.cxx    |   36 ++++----
 include/svx/svdobj.hxx                      |    2 
 svx/source/svdraw/svdobj.cxx                |   18 ++++
 svx/source/unodraw/unoshape.cxx             |   14 ---
 12 files changed, 254 insertions(+), 60 deletions(-)

New commits:
commit 0b0934056b47485527442b6366d7fd3274a4601f
Author:     Noel Grandin <noelgran...@gmail.com>
AuthorDate: Tue Jan 4 18:50:01 2022 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Thu Jan 6 07:15:48 2022 +0100

    bypass SvxShape when creating rectangles in chart2
    
    Change-Id: I461449959fffa8948bf4321a6c3114505d87a149
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127997
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/chart2/source/inc/CommonConverters.hxx 
b/chart2/source/inc/CommonConverters.hxx
index 18adcebf7187..989e4002d148 100644
--- a/chart2/source/inc/CommonConverters.hxx
+++ b/chart2/source/inc/CommonConverters.hxx
@@ -29,6 +29,7 @@
 #include <basegfx/matrix/b2dhommatrix.hxx>
 #include <basegfx/point/b3dpoint.hxx>
 #include <basegfx/vector/b3dvector.hxx>
+#include <basegfx/polygon/b2dpolypolygon.hxx>
 #include "charttoolsdllapi.hxx"
 
 namespace com::sun::star::awt { struct Rectangle; }
@@ -112,6 +113,12 @@ OOO_DLLPUBLIC_CHARTTOOLS
 css::drawing::PointSequenceSequence PolyToPointSequence(
                 const css::drawing::PolyPolygonShape3D& rPolyPolygon );
 
+/** PolyPolygonShape3D ->  basegfx::B2DPolyPolygon (2D)
+*/
+OOO_DLLPUBLIC_CHARTTOOLS
+basegfx::B2DPolyPolygon PolyToB2DPolyPolygon(
+                const css::drawing::PolyPolygonShape3D& rPolyPolygon );
+
 /** drawing::PointSequenceSequence + drawing::PointSequenceSequence
 */
 OOO_DLLPUBLIC_CHARTTOOLS
diff --git a/chart2/source/tools/CommonConverters.cxx 
b/chart2/source/tools/CommonConverters.cxx
index 2695d2da3418..43069cd40ad3 100644
--- a/chart2/source/tools/CommonConverters.cxx
+++ b/chart2/source/tools/CommonConverters.cxx
@@ -26,6 +26,7 @@
 #include <com/sun/star/chart2/data/XTextualDataSequence.hpp>
 #include <osl/diagnose.h>
 #include <basegfx/matrix/b3dhommatrix.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
 
 #include <limits>
 
@@ -345,6 +346,33 @@ drawing::PointSequenceSequence PolyToPointSequence(
     return aRet;
 }
 
+basegfx::B2DPolyPolygon PolyToB2DPolyPolygon(
+                const drawing::PolyPolygonShape3D& rPolyPolygon )
+{
+    basegfx::B2DPolyPolygon aRetval;
+
+    for(sal_Int32 nN = 0; nN < rPolyPolygon.SequenceX.getLength(); nN++)
+    {
+        basegfx::B2DPolygon aNewPolygon;
+        sal_Int32 nInnerLength = rPolyPolygon.SequenceX[nN].getLength();
+        if(nInnerLength)
+        {
+            aNewPolygon.reserve(nInnerLength);
+            for( sal_Int32 nM = 0; nM < nInnerLength; nM++)
+            {
+                auto X = 
static_cast<sal_Int32>(rPolyPolygon.SequenceX[nN][nM]);
+                auto Y = 
static_cast<sal_Int32>(rPolyPolygon.SequenceY[nN][nM]);
+                aNewPolygon.append(basegfx::B2DPoint(X, Y));
+            }
+            // check for closed state flag
+            basegfx::utils::checkClosed(aNewPolygon);
+        }
+        aRetval.append(std::move(aNewPolygon));
+    }
+
+    return aRetval;
+}
+
 void appendPointSequence( drawing::PointSequenceSequence& rTarget
                         , drawing::PointSequenceSequence& rAdd )
 {
diff --git a/chart2/source/view/charttypes/AreaChart.cxx 
b/chart2/source/view/charttypes/AreaChart.cxx
index 3972aba068fd..e4864cca63f7 100644
--- a/chart2/source/view/charttypes/AreaChart.cxx
+++ b/chart2/source/view/charttypes/AreaChart.cxx
@@ -501,22 +501,26 @@ bool AreaChart::impl_createArea( VDataSeries* pSeries
     pPosHelper->transformScaledLogicToScene( aPoly );
 
     //create area:
-    rtl::Reference< SvxShape > xShape;
     if(m_nDimension==3)
     {
-        xShape = ShapeFactory::createArea3D( xSeriesGroupShape_Shapes
+        rtl::Reference< SvxShape > 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
     {
-        xShape = ShapeFactory::createArea2D( xSeriesGroupShape_Shapes
+        SdrPathObj* pShape = 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 5fcd1bfc4203..a06303a310b3 100644
--- a/chart2/source/view/charttypes/BarChart.cxx
+++ b/chart2/source/view/charttypes/BarChart.cxx
@@ -788,7 +788,6 @@ void BarChart::createShapes()
                         //create partial point
                         if( !approxEqual(fLowerYValue,fUpperYValue) )
                         {
-                            rtl::Reference< SvxShape >  xShape;
                             if( m_nDimension==3 )
                             {
                                 drawing::Position3D aLogicBottom            
(fLogicX,fLogicYStart,fLogicZ);
@@ -823,9 +822,22 @@ void BarChart::createShapes()
                                 if( fTopHeight < 0 )
                                     fTopHeight *= -1.0;
 
-                                xShape = createDataPoint3D_Bar(
+                                rtl::Reference< SvxShape > 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
                             {
@@ -844,22 +856,22 @@ void BarChart::createShapes()
                                 AddPointToPoly( aPoly, aLeftUpperPoint );
                                 AddPointToPoly( aPoly, drawing::Position3D( 
fLogicX-fLogicBarWidth/2.0,fLowerYValue,fLogicZ) );
                                 pPosHelper->transformScaledLogicToScene( aPoly 
);
-                                xShape = ShapeFactory::createArea2D( 
xSeriesGroupShape_Shapes, aPoly );
-                                PropertyMapper::setMappedProperties( *xShape, 
xDataPointProperties, 
PropertyMapper::getPropertyNameMapForFilledSeriesProperties() );
-                            }
-
-                            if(bHasFillColorMapping)
-                            {
-                                double nPropVal = 
pSeries->getValueByProperty(nPointIndex, "FillColor");
-                                if(!std::isnan(nPropVal))
+                                std::optional<sal_Int32> xFillColor;
+                                if(bHasFillColorMapping)
                                 {
-                                    xShape->setPropertyValue("FillColor", 
uno::Any(static_cast<sal_Int32>(nPropVal)));
+                                    double nPropVal = 
pSeries->getValueByProperty(nPointIndex, "FillColor");
+                                    if(!std::isnan(nPropVal))
+                                        xFillColor = 
static_cast<sal_Int32>(nPropVal);
                                 }
+                                SdrPathObj* pShape = 
ShapeFactory::createArea2D( xSeriesGroupShape_Shapes, aPoly );
+                                
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 cf99d3ab0dae..cd1b6eea193d 100644
--- a/chart2/source/view/charttypes/NetChart.cxx
+++ b/chart2/source/view/charttypes/NetChart.cxx
@@ -222,14 +222,12 @@ bool NetChart::impl_createArea( VDataSeries* pSeries
     pPosHelper->transformScaledLogicToScene( aPoly );
 
     //create area:
-    rtl::Reference<SvxShapePolyPolygon>
-        xShape = ShapeFactory::createArea2D( xSeriesGroupShape_Shapes
-                , aPoly );
-    PropertyMapper::setMappedProperties( *xShape
-                , pSeries->getPropertiesOfSeries()
-                , 
PropertyMapper::getPropertyNameMapForFilledSeriesProperties() );
+    SdrPathObj* pShape = ShapeFactory::createArea2D( xSeriesGroupShape_Shapes
+                            , aPoly );
+    PropertyMapper::setPropertyNameMapForFilledSeriesProperties(pShape
+                , pSeries->getPropertiesOfSeries() );
     //because of this name this line will be used for marking
-    ::chart::ShapeFactory::setShapeName(xShape, "MarkHandles");
+    ::chart::ShapeFactory::setShapeName(pShape, "MarkHandles");
     return true;
 }
 
diff --git a/chart2/source/view/inc/PropertyMapper.hxx 
b/chart2/source/view/inc/PropertyMapper.hxx
index 3f627aae3163..897876128429 100644
--- a/chart2/source/view/inc/PropertyMapper.hxx
+++ b/chart2/source/view/inc/PropertyMapper.hxx
@@ -20,6 +20,7 @@
 
 #include <sal/config.h>
 
+#include <optional>
 #include <unordered_map>
 
 #include <com/sun/star/uno/Sequence.h>
@@ -27,6 +28,7 @@
 
 namespace com::sun::star::beans { class XPropertySet; }
 class SvxShape;
+class SdrPathObj;
 
 namespace chart
 {
@@ -105,6 +107,9 @@ 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 6f9bc6e12ab4..e326b771b2e4 100644
--- a/chart2/source/view/inc/ShapeFactory.hxx
+++ b/chart2/source/view/inc/ShapeFactory.hxx
@@ -40,6 +40,7 @@ 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
 {
@@ -154,7 +155,7 @@ public:
                     , const css::drawing::PolyPolygonShape3D& rPolyPolygon
                     , double fDepth);
 
-    static rtl::Reference<SvxShapePolyPolygon>
+    static SdrPathObj*
         createArea2D( const rtl::Reference<SvxShapeGroupAnyD>& xTarget
                     , const css::drawing::PolyPolygonShape3D& rPolyPolygon);
 
@@ -250,6 +251,8 @@ 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 e9e46998af7a..c54d15a8aa53 100644
--- a/chart2/source/view/main/PropertyMapper.cxx
+++ b/chart2/source/view/main/PropertyMapper.cxx
@@ -22,13 +22,34 @@
 
 #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 <comphelper/sequence.hxx>
 #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
 {
@@ -478,6 +499,110 @@ 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->SetMergedItemSet(*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 afcea1802274..efc7f0d90787 100644
--- a/chart2/source/view/main/ShapeFactory.cxx
+++ b/chart2/source/view/main/ShapeFactory.cxx
@@ -55,6 +55,8 @@
 #include <basegfx/point/b2dpoint.hxx>
 #include <basegfx/matrix/b3dhommatrix.hxx>
 #include <svx/unoprov.hxx>
+#include <svx/svdpage.hxx>
+#include <svx/svdopath.hxx>
 #include <tools/diagnose_ex.h>
 #include <tools/helpers.hxx>
 #include <tools/UnitConversion.hxx>
@@ -1080,7 +1082,7 @@ rtl::Reference<Svx3DExtrudeObject>
 }
 
 
-rtl::Reference<SvxShapePolyPolygon>
+SdrPathObj*
         ShapeFactory::createArea2D( const rtl::Reference<SvxShapeGroupAnyD>& 
xTarget
                     , const drawing::PolyPolygonShape3D& rPolyPolygon )
 {
@@ -1088,30 +1090,24 @@ rtl::Reference<SvxShapePolyPolygon>
         return nullptr;
 
     //create shape
-    rtl::Reference<SvxShapePolyPolygon> xShape = new 
SvxShapePolyPolygon(nullptr);
-    xShape->setShapeKind(OBJ_POLY);
-    xTarget->add(uno::Reference<drawing::XShape>(xShape));
+    SdrPathObj* pPath = new 
SdrPathObj(xTarget->GetSdrObject()->getSdrModelFromSdrObject(), OBJ_POLY);
+    // insert at ZOrder 0, an area should always be behind other shapes
+    xTarget->GetSdrObject()->GetSubList()->InsertObject(pPath, 0);
 
     //set properties
     try
     {
-        //UNO_NAME_POLYGON "Polygon" drawing::PointSequence*
-        drawing::PointSequenceSequence aPoints( 
PolyToPointSequence(rPolyPolygon) );
-
-        //Polygon
-        xShape->SvxShape::setPropertyValue( UNO_NAME_POLYPOLYGON
-            , uno::Any( aPoints ) );
-
-        //ZOrder
-        //an area should always be behind other shapes
-        xShape->SvxShape::setPropertyValue( UNO_NAME_MISC_OBJ_ZORDER
-            , uno::Any( sal_Int32(0) ) );
+        // Polygon
+        basegfx::B2DPolyPolygon aNewPolyPolygon( 
PolyToB2DPolyPolygon(rPolyPolygon) );
+        // tdf#117145 metric of SdrModel is app-specific, metric of UNO API is 
100thmm
+        pPath->ForceMetricToItemPoolMetric(aNewPolyPolygon);
+        pPath->SetPathPoly(aNewPolyPolygon);
     }
     catch( const uno::Exception& )
     {
         TOOLS_WARN_EXCEPTION("chart2", "" );
     }
-    return xShape;
+    return pPath;
 }
 
 static drawing::PolyPolygonShape3D createPolyPolygon_Symbol( const 
drawing::Position3D& rPos
@@ -2381,6 +2377,14 @@ 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 )
 {
diff --git a/include/svx/svdobj.hxx b/include/svx/svdobj.hxx
index 772c46308eb5..6da2f4ad8bfa 100644
--- a/include/svx/svdobj.hxx
+++ b/include/svx/svdobj.hxx
@@ -880,6 +880,8 @@ public:
     const OUString& getHyperlink() const { return msHyperlink; }
     void setHyperlink(const OUString& sHyperlink) { msHyperlink = sHyperlink; }
 
+    void ForceMetricToItemPoolMetric(basegfx::B2DPolyPolygon& rPolyPolygon) 
const noexcept;
+
 protected:
     mutable tools::Rectangle    m_aOutRect;     // surrounding rectangle for 
Paint (incl. LineWidth, ...)
     Point                       m_aAnchor;      // anchor position (Writer)
diff --git a/svx/source/svdraw/svdobj.cxx b/svx/source/svdraw/svdobj.cxx
index e6582e597864..9cd2d1b5cde0 100644
--- a/svx/source/svdraw/svdobj.cxx
+++ b/svx/source/svdraw/svdobj.cxx
@@ -123,6 +123,7 @@
 
 #include <svx/scene3d.hxx>
 #include <rtl/character.hxx>
+#include <tools/UnitConversion.hxx>
 
 using namespace ::com::sun::star;
 
@@ -3149,6 +3150,23 @@ void 
SdrObject::MakeNameUnique(std::unordered_set<OUString>& rNameSet)
     SetName(sName);
 }
 
+void SdrObject::ForceMetricToItemPoolMetric(basegfx::B2DPolyPolygon& 
rPolyPolygon) const noexcept
+{
+    MapUnit eMapUnit(getSdrModelFromSdrObject().GetItemPool().GetMetric(0));
+    if(eMapUnit == MapUnit::Map100thMM)
+        return;
+
+    if (const auto eTo = MapToO3tlLength(eMapUnit); eTo != 
o3tl::Length::invalid)
+    {
+        const double fConvert(o3tl::convert(1.0, o3tl::Length::mm100, eTo));
+        
rPolyPolygon.transform(basegfx::utils::createScaleB2DHomMatrix(fConvert, 
fConvert));
+    }
+    else
+    {
+        OSL_FAIL("Missing unit translation to PoolMetric!");
+    }
+}
+
 SdrObject* SdrObjFactory::CreateObjectFromFactory(SdrModel& rSdrModel, 
SdrInventor nInventor, SdrObjKind nObjIdentifier)
 {
     SdrObjCreatorParams aParams { nInventor, nObjIdentifier, rSdrModel };
diff --git a/svx/source/unodraw/unoshape.cxx b/svx/source/unodraw/unoshape.cxx
index 94a7b2540ec6..0b2535831d39 100644
--- a/svx/source/unodraw/unoshape.cxx
+++ b/svx/source/unodraw/unoshape.cxx
@@ -465,19 +465,7 @@ void 
SvxShape::ForceMetricToItemPoolMetric(basegfx::B2DPolyPolygon& rPolyPolygon
     if(!HasSdrObject())
         return;
 
-    MapUnit 
eMapUnit(GetSdrObject()->getSdrModelFromSdrObject().GetItemPool().GetMetric(0));
-    if(eMapUnit == MapUnit::Map100thMM)
-        return;
-
-    if (const auto eTo = MapToO3tlLength(eMapUnit); eTo != 
o3tl::Length::invalid)
-    {
-        const double fConvert(o3tl::convert(1.0, o3tl::Length::mm100, eTo));
-        
rPolyPolygon.transform(basegfx::utils::createScaleB2DHomMatrix(fConvert, 
fConvert));
-    }
-    else
-    {
-        OSL_FAIL("Missing unit translation to PoolMetric!");
-    }
+    GetSdrObject()->ForceMetricToItemPoolMetric(rPolyPolygon);
 }
 
 void SvxShape::ForceMetricToItemPoolMetric(basegfx::B2DHomMatrix& 
rB2DHomMatrix) const noexcept

Reply via email to