chart2/source/view/charttypes/BarChart.cxx |    4 -
 chart2/source/view/inc/ShapeFactory.hxx    |    8 +-
 chart2/source/view/main/ShapeFactory.cxx   |   92 +++++++++++++----------------
 include/svx/unoshape.hxx                   |    2 
 4 files changed, 50 insertions(+), 56 deletions(-)

New commits:
commit 042bfbddfd134f3e2fefc144f3c06cef61813278
Author:     Noel Grandin <[email protected]>
AuthorDate: Thu Dec 30 08:20:30 2021 +0200
Commit:     Noel Grandin <[email protected]>
CommitDate: Thu Dec 30 13:33:04 2021 +0100

    use concrete types in chart2, Svx3DLatheObject
    
    Change-Id: I3c007cc5b70e6a7b854438b9b2558229f5a5c73f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127728
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <[email protected]>

diff --git a/chart2/source/view/charttypes/BarChart.cxx 
b/chart2/source/view/charttypes/BarChart.cxx
index 3099be4350cb..0af39bafc348 100644
--- a/chart2/source/view/charttypes/BarChart.cxx
+++ b/chart2/source/view/charttypes/BarChart.cxx
@@ -323,10 +323,10 @@ uno::Reference< drawing::XShape > 
BarChart::createDataPoint3D_Bar(
     switch( nGeometry3D )
     {
         case DataPointGeometry3D::CYLINDER:
-            xShape = m_pShapeFactory->createCylinder( xTarget, rPosition, 
rSize, nRotateZAngleHundredthDegree );
+            xShape = ShapeFactory::createCylinder( xTarget, rPosition, rSize, 
nRotateZAngleHundredthDegree );
             break;
         case DataPointGeometry3D::CONE:
-            xShape = m_pShapeFactory->createCone( xTarget, rPosition, rSize, 
fTopHeight, nRotateZAngleHundredthDegree );
+            xShape = ShapeFactory::createCone( xTarget, rPosition, rSize, 
fTopHeight, nRotateZAngleHundredthDegree );
             break;
         case DataPointGeometry3D::PYRAMID:
             xShape = m_pShapeFactory->createPyramid( xTarget, rPosition, 
rSize, fTopHeight, nRotateZAngleHundredthDegree>0
diff --git a/chart2/source/view/inc/ShapeFactory.hxx 
b/chart2/source/view/inc/ShapeFactory.hxx
index e01b4cdc2e68..4f8f6ebdfa25 100644
--- a/chart2/source/view/inc/ShapeFactory.hxx
+++ b/chart2/source/view/inc/ShapeFactory.hxx
@@ -99,13 +99,13 @@ public:
                         , const tPropertyNameMap& rPropertyNameMap
                         , bool bRounded = false);
 
-    css::uno::Reference< css::drawing::XShape >
+    static rtl::Reference<Svx3DLatheObject>
         createCylinder(   const css::uno::Reference< css::drawing::XShapes >& 
xTarget
                         , const css::drawing::Position3D& rPosition
                         , const css::drawing::Direction3D& rSize
                         , sal_Int32 nRotateZAngleHundredthDegree );
 
-    css::uno::Reference< css::drawing::XShape >
+    rtl::Reference<Svx3DSceneObject>
         createPyramid(    const css::uno::Reference< css::drawing::XShapes >& 
xTarget
                         , const css::drawing::Position3D& rPosition
                         , const css::drawing::Direction3D& rSize
@@ -114,7 +114,7 @@ public:
                         , const css::uno::Reference< css::beans::XPropertySet 
>& xSourceProp
                         , const tPropertyNameMap& rPropertyNameMap);
 
-    css::uno::Reference< css::drawing::XShape >
+    static rtl::Reference<Svx3DLatheObject>
         createCone(       const css::uno::Reference< css::drawing::XShapes >& 
xTarget
                         , const css::drawing::Position3D& rPosition
                         , const css::drawing::Direction3D& rSize
@@ -284,7 +284,7 @@ private:
                     , const css::drawing::Direction3D& rSize, sal_Int32 
nRotateZAngleHundredthDegree
                     , bool bRounded );
 
-    css::uno::Reference< css::drawing::XShape >
+    static rtl::Reference<Svx3DLatheObject>
         impl_createConeOrCylinder( const css::uno::Reference< 
css::drawing::XShapes >& xTarget
                     , const css::drawing::Position3D& rPosition
                     , const css::drawing::Direction3D& rSize
diff --git a/chart2/source/view/main/ShapeFactory.cxx 
b/chart2/source/view/main/ShapeFactory.cxx
index 14ac22fece68..695b39968621 100644
--- a/chart2/source/view/main/ShapeFactory.cxx
+++ b/chart2/source/view/main/ShapeFactory.cxx
@@ -449,7 +449,7 @@ rtl::Reference<Svx3DExtrudeObject>
     return xShape;
 }
 
-uno::Reference<drawing::XShape>
+rtl::Reference<Svx3DLatheObject>
         ShapeFactory::createCylinder(
             const uno::Reference<drawing::XShapes>& xTarget
           , const drawing::Position3D& rPosition, const drawing::Direction3D& 
rSize
@@ -459,7 +459,7 @@ uno::Reference<drawing::XShape>
               xTarget, rPosition, rSize, 0.0, nRotateZAngleHundredthDegree, 
true );
 }
 
-uno::Reference<drawing::XShape>
+rtl::Reference<Svx3DSceneObject>
         ShapeFactory::createPyramid(
             const uno::Reference<drawing::XShapes>& xTarget
           , const drawing::Position3D& rPosition, const drawing::Direction3D& 
rSize
@@ -470,7 +470,7 @@ uno::Reference<drawing::XShape>
     if( !xTarget.is() )
         return nullptr;
 
-    Reference< drawing::XShapes > xGroup( ShapeFactory::createGroup3D( xTarget 
) );
+    rtl::Reference<Svx3DSceneObject> xGroup( ShapeFactory::createGroup3D( 
xTarget ) );
 
     bool bDoubleSided = false;
     short nRotatedTexture = 0;
@@ -616,10 +616,10 @@ uno::Reference<drawing::XShape>
     ShapeFactory::createStripe( xGroup, aStripe4, xSourceProp, 
rPropertyNameMap, bDoubleSided, nRotatedTexture, bFlatNormals );
     ShapeFactory::createStripe( xGroup, aStripeBottom, xSourceProp, 
rPropertyNameMap, bDoubleSided, nRotatedTexture, bFlatNormals );
 
-    return Reference< drawing::XShape >( xGroup, uno::UNO_QUERY );
+    return xGroup;
 }
 
-uno::Reference<drawing::XShape>
+rtl::Reference<Svx3DLatheObject>
         ShapeFactory::createCone(
             const uno::Reference<drawing::XShapes>& xTarget
           , const drawing::Position3D& rPosition, const drawing::Direction3D& 
rSize
@@ -628,7 +628,7 @@ uno::Reference<drawing::XShape>
     return impl_createConeOrCylinder( xTarget, rPosition, rSize, fTopHeight, 
nRotateZAngleHundredthDegree, false );
 }
 
-uno::Reference<drawing::XShape>
+rtl::Reference<Svx3DLatheObject>
         ShapeFactory::impl_createConeOrCylinder(
               const uno::Reference<drawing::XShapes>& xTarget
             , const drawing::Position3D& rPosition, const 
drawing::Direction3D& rSize
@@ -639,9 +639,8 @@ uno::Reference<drawing::XShape>
         return nullptr;
 
     //create shape
-    uno::Reference< drawing::XShape > xShape(
-            m_xShapeFactory->createInstance(
-            "com.sun.star.drawing.Shape3DLatheObject" ), uno::UNO_QUERY );
+    rtl::Reference<Svx3DLatheObject> xShape = new Svx3DLatheObject(nullptr);
+    xShape->setShapeKind(E3D_LATHEOBJ_ID | E3D_INVENTOR_FLAG);
     xTarget->add(xShape);
 
     double fWidth      = rSize.DirectionX/2.0; //The depth will be corrected 
within Matrix
@@ -649,50 +648,45 @@ uno::Reference<drawing::XShape>
     double fHeight     = rSize.DirectionY;
 
     //set properties
-    uno::Reference<beans::XMultiPropertySet> xMultiPropertySet(xShape, 
uno::UNO_QUERY);
-    OSL_ENSURE(xMultiPropertySet.is(), "created shape offers no 
XMultiPropertySet");
-    if (xMultiPropertySet.is())
+    try
     {
-        try
-        {
-            //Polygon
-            sal_Int32 nVerticalSegmentCount = 0;
-            uno::Any aPPolygon = bCylinder
-                ? createPolyPolygon_Cylinder(fHeight, fRadius, 
nVerticalSegmentCount)
-                : createPolyPolygon_Cone(fHeight, fRadius, fTopHeight, 
nVerticalSegmentCount);
-
-            //Matrix for position
-            basegfx::B3DHomMatrix aHomMatrix;
-            if (nRotateZAngleHundredthDegree != 0)
-                
aHomMatrix.rotate(0.0,0.0,-basegfx::deg2rad<100>(nRotateZAngleHundredthDegree));
-            //stretch the symmetric objects to given depth
-            aHomMatrix.scale(1.0,1.0,rSize.DirectionZ/rSize.DirectionX);
-            aHomMatrix.translate(rPosition.PositionX, rPosition.PositionY, 
rPosition.PositionZ);
+        //Polygon
+        sal_Int32 nVerticalSegmentCount = 0;
+        uno::Any aPPolygon = bCylinder
+            ? createPolyPolygon_Cylinder(fHeight, fRadius, 
nVerticalSegmentCount)
+            : createPolyPolygon_Cone(fHeight, fRadius, fTopHeight, 
nVerticalSegmentCount);
 
-            uno::Sequence<OUString> aPropertyNames{
-                UNO_NAME_3D_PERCENT_DIAGONAL,
-                UNO_NAME_3D_POLYPOLYGON3D,
-                UNO_NAME_3D_TRANSFORM_MATRIX,
-                UNO_NAME_3D_HORZ_SEGS,
-                UNO_NAME_3D_VERT_SEGS,
-                UNO_NAME_3D_REDUCED_LINE_GEOMETRY
-            };
+        //Matrix for position
+        basegfx::B3DHomMatrix aHomMatrix;
+        if (nRotateZAngleHundredthDegree != 0)
+            
aHomMatrix.rotate(0.0,0.0,-basegfx::deg2rad<100>(nRotateZAngleHundredthDegree));
+        //stretch the symmetric objects to given depth
+        aHomMatrix.scale(1.0,1.0,rSize.DirectionZ/rSize.DirectionX);
+        aHomMatrix.translate(rPosition.PositionX, rPosition.PositionY, 
rPosition.PositionZ);
 
-            uno::Sequence<uno::Any> aPropertyValues {
-                uno::Any(sal_Int16(5)),  // PercentDiagonal
-                aPPolygon,               // Polygon
-                uno::Any(B3DHomMatrixToHomogenMatrix(aHomMatrix)), // Matrix
-                uno::Any(CHART_3DOBJECT_SEGMENTCOUNT), // Horizontal Segments
-                uno::Any(nVerticalSegmentCount),       // Vertical Segments
-                uno::Any(true)                         // Reduced lines
-            };
+        uno::Sequence<OUString> aPropertyNames{
+            UNO_NAME_3D_PERCENT_DIAGONAL,
+            UNO_NAME_3D_POLYPOLYGON3D,
+            UNO_NAME_3D_TRANSFORM_MATRIX,
+            UNO_NAME_3D_HORZ_SEGS,
+            UNO_NAME_3D_VERT_SEGS,
+            UNO_NAME_3D_REDUCED_LINE_GEOMETRY
+        };
 
-            xMultiPropertySet->setPropertyValues(aPropertyNames, 
aPropertyValues);
-        }
-        catch( const uno::Exception& )
-        {
-            TOOLS_WARN_EXCEPTION("chart2", "" );
-        }
+        uno::Sequence<uno::Any> aPropertyValues {
+            uno::Any(sal_Int16(5)),  // PercentDiagonal
+            aPPolygon,               // Polygon
+            uno::Any(B3DHomMatrixToHomogenMatrix(aHomMatrix)), // Matrix
+            uno::Any(CHART_3DOBJECT_SEGMENTCOUNT), // Horizontal Segments
+            uno::Any(nVerticalSegmentCount),       // Vertical Segments
+            uno::Any(true)                         // Reduced lines
+        };
+
+        xShape->setPropertyValues(aPropertyNames, aPropertyValues);
+    }
+    catch( const uno::Exception& )
+    {
+        TOOLS_WARN_EXCEPTION("chart2", "" );
     }
     return xShape;
 }
diff --git a/include/svx/unoshape.hxx b/include/svx/unoshape.hxx
index 1112cf5e044e..13df4873fc40 100644
--- a/include/svx/unoshape.hxx
+++ b/include/svx/unoshape.hxx
@@ -744,7 +744,7 @@ class Svx3DLatheObject final : public SvxShape
     virtual bool getPropertyValueImpl( const OUString& rName, const 
SfxItemPropertyMapEntry* pProperty, css::uno::Any& rValue ) override;
 
 public:
-    Svx3DLatheObject(SdrObject* pObj);
+    SVXCORE_DLLPUBLIC Svx3DLatheObject(SdrObject* pObj);
     virtual ~Svx3DLatheObject() noexcept override;
 
     // XServiceInfo

Reply via email to