chart2/source/view/charttypes/CandleStickChart.cxx |   17 ++---
 chart2/source/view/diagram/VDiagram.cxx            |   50 +++++++----------
 chart2/source/view/inc/ShapeFactory.hxx            |    8 +-
 chart2/source/view/inc/VDiagram.hxx                |    3 -
 chart2/source/view/main/ChartView.cxx              |   16 ++---
 chart2/source/view/main/ShapeFactory.cxx           |   60 +++++++++------------
 chart2/source/view/main/VLegend.cxx                |    3 -
 chart2/source/view/main/VLegendSymbolFactory.cxx   |    4 -
 include/svx/unoshape.hxx                           |    2 
 osx/soffice.xcodeproj/project.pbxproj              |    2 
 10 files changed, 74 insertions(+), 91 deletions(-)

New commits:
commit 3bf767b1312cd691d9f7d59f661f43c60998c728
Author:     Noel Grandin <noelgran...@gmail.com>
AuthorDate: Wed Dec 29 20:53:33 2021 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Thu Dec 30 08:25:43 2021 +0100

    use concrete types in chart2, SvxShapeRect
    
    Change-Id: Ibd537ed709be237e00715057c162dd9197759373
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127722
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/chart2/source/view/charttypes/CandleStickChart.cxx 
b/chart2/source/view/charttypes/CandleStickChart.cxx
index f7c8253ef1b3..d767cb2bce50 100644
--- a/chart2/source/view/charttypes/CandleStickChart.cxx
+++ b/chart2/source/view/charttypes/CandleStickChart.cxx
@@ -239,19 +239,16 @@ void CandleStickChart::createShapes()
                         tNameSequence aNames;
                         tAnySequence aValues;
 
-                        uno::Reference< drawing::XShape > xShape =
-                            m_pShapeFactory->createRectangle( xLossGainTarget,
+                        rtl::Reference<SvxShapeRect> xShape =
+                            ShapeFactory::createRectangle( xLossGainTarget,
                                     aAWTSize, Position3DToAWTPoint( 
aPosLeftFirst ),
                                     aNames, aValues);
 
-                        uno::Reference< beans::XPropertySet > xProp( xShape, 
uno::UNO_QUERY );
-                        if(xProp.is())
-                        {
-                            if(bBlack)
-                                PropertyMapper::setMultiProperties( 
aBlackBox_Names, aBlackBox_Values, xProp );
-                            else
-                                PropertyMapper::setMultiProperties( 
aWhiteBox_Names, aWhiteBox_Values, xProp );
-                        }
+                        uno::Reference< beans::XPropertySet > xProp( 
static_cast<cppu::OWeakObject*>(xShape.get()), uno::UNO_QUERY_THROW );
+                        if(bBlack)
+                            PropertyMapper::setMultiProperties( 
aBlackBox_Names, aBlackBox_Values, xProp );
+                        else
+                            PropertyMapper::setMultiProperties( 
aWhiteBox_Names, aWhiteBox_Values, xProp );
                     }
                     else
                     {
diff --git a/chart2/source/view/diagram/VDiagram.cxx 
b/chart2/source/view/diagram/VDiagram.cxx
index 91fa4b936080..b00a0e4f36ef 100644
--- a/chart2/source/view/diagram/VDiagram.cxx
+++ b/chart2/source/view/diagram/VDiagram.cxx
@@ -157,41 +157,35 @@ void VDiagram::createShapes_2d()
 
     //add back wall
     {
-        ShapeFactory* pShapeFactory = 
ShapeFactory::getOrCreateShapeFactory(m_xShapeFactory);
-        m_xWall2D = pShapeFactory->createRectangle(
-                xGroupForWall );
+        m_xWall2D = ShapeFactory::createRectangle( xGroupForWall );
 
-        uno::Reference< beans::XPropertySet > xProp( m_xWall2D, uno::UNO_QUERY 
);
-        if( xProp.is())
+        uno::Reference< beans::XPropertySet > xProp( 
static_cast<cppu::OWeakObject*>(m_xWall2D.get()), uno::UNO_QUERY_THROW );
+        try
         {
-            try
+            OSL_ENSURE( m_xDiagram.is(), "Invalid Diagram model" );
+            if( m_xDiagram.is() )
             {
-                OSL_ENSURE( m_xDiagram.is(), "Invalid Diagram model" );
-                if( m_xDiagram.is() )
-                {
-                    uno::Reference< beans::XPropertySet > xWallProp( 
m_xDiagram->getWall());
-                    if( xWallProp.is())
-                        PropertyMapper::setMappedProperties( xProp, xWallProp, 
PropertyMapper::getPropertyNameMapForFillAndLineProperties() );
-                }
-                if( !bAddFloorAndWall )
-                {
-                    //we always need this object as dummy object for correct 
scene dimensions
-                    //but it should not be visible in this case:
-                    ShapeFactory::makeShapeInvisible( m_xWall2D );
-                }
-                else
-                {
-                    //CID for selection handling
-                    OUString aWallCID( 
ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_DIAGRAM_WALL, u"" ) 
);//@todo read CID from model
-                    xProp->setPropertyValue( UNO_NAME_MISC_OBJ_NAME, uno::Any( 
aWallCID ) );
-                }
+                uno::Reference< beans::XPropertySet > xWallProp( 
m_xDiagram->getWall());
+                if( xWallProp.is())
+                    PropertyMapper::setMappedProperties( xProp, xWallProp, 
PropertyMapper::getPropertyNameMapForFillAndLineProperties() );
             }
-            catch( const uno::Exception& )
+            if( !bAddFloorAndWall )
             {
-                TOOLS_WARN_EXCEPTION("chart2", "" );
+                //we always need this object as dummy object for correct scene 
dimensions
+                //but it should not be visible in this case:
+                ShapeFactory::makeShapeInvisible( m_xWall2D );
+            }
+            else
+            {
+                //CID for selection handling
+                OUString aWallCID( 
ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_DIAGRAM_WALL, u"" ) 
);//@todo read CID from model
+                m_xWall2D->SvxShape::setPropertyValue( UNO_NAME_MISC_OBJ_NAME, 
uno::Any( aWallCID ) );
             }
         }
-
+        catch( const uno::Exception& )
+        {
+            TOOLS_WARN_EXCEPTION("chart2", "" );
+        }
     }
 
     //position and size for diagram
diff --git a/chart2/source/view/inc/ShapeFactory.hxx 
b/chart2/source/view/inc/ShapeFactory.hxx
index 8f3072cb1313..cba783dd8886 100644
--- a/chart2/source/view/inc/ShapeFactory.hxx
+++ b/chart2/source/view/inc/ShapeFactory.hxx
@@ -214,12 +214,12 @@ public:
                 const css::uno::Reference< css::beans::XPropertySet > & 
xTextProperties,
                 double nRotation, const OUString& aName, sal_Int32 
nTextMaxWidth );
 
-    css::uno::Reference< css::drawing::XShape >
+    static rtl::Reference<SvxShapeRect>
         createInvisibleRectangle(
             const css::uno::Reference< css::drawing::XShapes >& xTarget
           , const css::awt::Size& rSize );
 
-    css::uno::Reference< css::drawing::XShape >
+    static rtl::Reference<SvxShapeRect>
         createRectangle(
             const css::uno::Reference< css::drawing::XShapes >& xTarget,
             const css::awt::Size& rSize,
@@ -228,11 +228,11 @@ public:
             const tAnySequence& rPropValues,
             StackPosition ePos = StackPosition::Top );
 
-    css::uno::Reference< css::drawing::XShape >
+    static rtl::Reference<SvxShapeRect>
         createRectangle(
             const css::uno::Reference< css::drawing::XShapes >& xTarget );
 
-    css::uno::Reference< css::drawing::XShapes >
+    static css::uno::Reference< css::drawing::XShapes >
          getOrCreateChartRootShape( const css::uno::Reference<
             css::drawing::XDrawPage>& xPage );
 
diff --git a/chart2/source/view/inc/VDiagram.hxx 
b/chart2/source/view/inc/VDiagram.hxx
index ee7aea46b168..757cc1ec61cf 100644
--- a/chart2/source/view/inc/VDiagram.hxx
+++ b/chart2/source/view/inc/VDiagram.hxx
@@ -23,6 +23,7 @@
 #include <com/sun/star/drawing/Direction3D.hpp>
 #include <com/sun/star/awt/Size.hpp>
 #include <com/sun/star/awt/Point.hpp>
+#include <svx/unoshape.hxx>
 
 namespace com::sun::star::beans { class XPropertySet; }
 namespace com::sun::star::chart2 { class XDiagram; }
@@ -93,7 +94,7 @@ private: //members
     css::uno::Reference< css::drawing::XShape >   m_xOuterGroupShape;
     // this is an additional inner shape that represents the coordinate region 
-  that is - where to place data points
     css::uno::Reference< css::drawing::XShape >   m_xCoordinateRegionShape;
-    css::uno::Reference< css::drawing::XShape >   m_xWall2D;
+    rtl::Reference<SvxShapeRect> m_xWall2D;
 
     sal_Int32                                                               
m_nDimensionCount;
     css::uno::Reference< css::chart2::XDiagram >                               
 m_xDiagram;
diff --git a/chart2/source/view/main/ChartView.cxx 
b/chart2/source/view/main/ChartView.cxx
index 8b602c64f78e..326a57a06fc0 100644
--- a/chart2/source/view/main/ChartView.cxx
+++ b/chart2/source/view/main/ChartView.cxx
@@ -1014,8 +1014,8 @@ struct CreateShapeParam2D
     std::shared_ptr<VTitle> mpVTitleSecondX;
     std::shared_ptr<VTitle> mpVTitleSecondY;
 
-    css::uno::Reference<css::drawing::XShape> mxMarkHandles;
-    css::uno::Reference<css::drawing::XShape> mxPlotAreaWithAxes;
+    rtl::Reference<SvxShapeRect> mxMarkHandles;
+    rtl::Reference<SvxShapeRect> mxPlotAreaWithAxes;
 
     css::uno::Reference<css::drawing::XShapes> mxDiagramWithAxesShapes;
 
@@ -2321,8 +2321,7 @@ void formatPage(
         tAnySequence aValues;
         PropertyMapper::getMultiPropertyListsFromValueMap( aNames, aValues, 
aNameValueMap );
 
-        ShapeFactory* pShapeFactory = 
ShapeFactory::getOrCreateShapeFactory(xShapeFactory);
-        pShapeFactory->createRectangle(
+        ShapeFactory::createRectangle(
             xTarget, rPageSize, awt::Point(0, 0), aNames, aValues);
     }
     catch( const uno::Exception & )
@@ -2416,9 +2415,8 @@ void ChartView::createShapes()
 
     awt::Size aPageSize = mrChartModel.getVisualAreaSize( 
embed::Aspects::MSOLE_CONTENT );
 
-    ShapeFactory* pShapeFactory = 
ShapeFactory::getOrCreateShapeFactory(m_xShapeFactory);
     if(!mxRootShape.is())
-        mxRootShape = pShapeFactory->getOrCreateChartRootShape( m_xDrawPage );
+        mxRootShape = ShapeFactory::getOrCreateChartRootShape( m_xDrawPage );
 
     SdrPage* pPage = ChartView::getSdrPage();
     if(pPage) //it is necessary to use the implementation here as the uno page 
does not provide a propertyset
@@ -2887,8 +2885,6 @@ IMPL_LINK_NOARG(ChartView, UpdateTimeBased, Timer *, void)
 
 void ChartView::createShapes2D( const awt::Size& rPageSize )
 {
-    ShapeFactory* pShapeFactory = 
ShapeFactory::getOrCreateShapeFactory(m_xShapeFactory);
-
     // todo: it would be nicer to just pass the page m_xDrawPage and format it,
     // but the draw page does not support XPropertySet
     formatPage( mrChartModel, rPageSize, mxRootShape, m_xShapeFactory );
@@ -2910,11 +2906,11 @@ void ChartView::createShapes2D( const awt::Size& 
rPageSize )
     uno::Reference< drawing::XShapes > 
xDiagramPlusAxesPlusMarkHandlesGroup_Shapes(
             ShapeFactory::createGroup2D(mxRootShape,aDiagramCID) );
 
-    aParam.mxMarkHandles = pShapeFactory->createInvisibleRectangle(
+    aParam.mxMarkHandles = ShapeFactory::createInvisibleRectangle(
         xDiagramPlusAxesPlusMarkHandlesGroup_Shapes, awt::Size(0,0));
     ShapeFactory::setShapeName(aParam.mxMarkHandles, "MarkHandles");
 
-    aParam.mxPlotAreaWithAxes = pShapeFactory->createInvisibleRectangle(
+    aParam.mxPlotAreaWithAxes = ShapeFactory::createInvisibleRectangle(
         xDiagramPlusAxesPlusMarkHandlesGroup_Shapes, awt::Size(0, 0));
     ShapeFactory::setShapeName(aParam.mxPlotAreaWithAxes, 
"PlotAreaIncludingAxes");
 
diff --git a/chart2/source/view/main/ShapeFactory.cxx 
b/chart2/source/view/main/ShapeFactory.cxx
index 0e0ea450f9b8..310907405cda 100644
--- a/chart2/source/view/main/ShapeFactory.cxx
+++ b/chart2/source/view/main/ShapeFactory.cxx
@@ -91,8 +91,9 @@ uno::Reference< drawing::XShapes > 
ShapeFactory::getOrCreateChartRootShape(
 
     // Create a new root shape and set it to the bottom of the page.  The root
     // shape is identified by having the name com.sun.star.chart2.shapes.
-    uno::Reference<drawing::XShape> xShape(
-        m_xShapeFactory->createInstance("com.sun.star.drawing.GroupShape"), 
uno::UNO_QUERY);
+    rtl::Reference<SvxShapeGroup> xShapeGroup = new SvxShapeGroup(nullptr, 
nullptr);
+    xShapeGroup->setShapeKind(OBJ_GRUP);
+    uno::Reference<drawing::XShape> 
xShape(static_cast<cppu::OWeakObject*>(xShapeGroup.get()), uno::UNO_QUERY);
     uno::Reference<drawing::XShapes2> xShapes2(xDrawPage, 
uno::UNO_QUERY_THROW);
     xShapes2->addBottom(xShape);
 
@@ -2053,7 +2054,7 @@ uno::Reference< drawing::XShape >
     return xShape;
 }
 
-uno::Reference< drawing::XShape > ShapeFactory::createInvisibleRectangle(
+rtl::Reference<SvxShapeRect> ShapeFactory::createInvisibleRectangle(
             const uno::Reference< drawing::XShapes >& xTarget
             , const awt::Size& rSize )
 {
@@ -2062,14 +2063,11 @@ uno::Reference< drawing::XShape > 
ShapeFactory::createInvisibleRectangle(
         if(!xTarget.is())
             return nullptr;
 
-        uno::Reference< drawing::XShape > xShape( 
m_xShapeFactory->createInstance(
-                "com.sun.star.drawing.RectangleShape"), uno::UNO_QUERY );
-        if( xShape.is())
-        {
-            xTarget->add( xShape );
-            ShapeFactory::makeShapeInvisible( xShape );
-            xShape->setSize( rSize );
-        }
+        rtl::Reference<SvxShapeRect> xShape = new SvxShapeRect(nullptr);
+        xShape->setShapeKind(OBJ_RECT);
+        xTarget->add( xShape );
+        ShapeFactory::makeShapeInvisible( xShape );
+        xShape->setSize( rSize );
         return xShape;
     }
     catch( const uno::Exception & )
@@ -2079,7 +2077,7 @@ uno::Reference< drawing::XShape > 
ShapeFactory::createInvisibleRectangle(
     return nullptr;
 }
 
-uno::Reference< drawing::XShape > ShapeFactory::createRectangle(
+rtl::Reference<SvxShapeRect> ShapeFactory::createRectangle(
     const uno::Reference< drawing::XShapes >& xTarget,
     const awt::Size& rSize,
     const awt::Point& rPosition,
@@ -2087,35 +2085,31 @@ uno::Reference< drawing::XShape > 
ShapeFactory::createRectangle(
     const tAnySequence& rPropValues,
     StackPosition ePos )
 {
-    uno::Reference< drawing::XShape > xShape( m_xShapeFactory->createInstance(
-                "com.sun.star.drawing.RectangleShape"), uno::UNO_QUERY );
-    if( xShape.is())
+    rtl::Reference<SvxShapeRect> xShape = new SvxShapeRect(nullptr);
+    xShape->setShapeKind(OBJ_RECT);
+    if (ePos == StackPosition::Bottom)
     {
-        if (ePos == StackPosition::Bottom)
-        {
-            uno::Reference<drawing::XShapes2> xTarget2(xTarget, 
uno::UNO_QUERY);
-            if (xTarget2.is())
-                xTarget2->addBottom(xShape);
-        }
-        else
-            xTarget->add(xShape);
-
-        xShape->setPosition( rPosition );
-        xShape->setSize( rSize );
-        uno::Reference< beans::XPropertySet > xPropSet( xShape, 
uno::UNO_QUERY_THROW );
-        PropertyMapper::setMultiProperties( rPropNames, rPropValues, xPropSet 
);
+        uno::Reference<drawing::XShapes2> xTarget2(xTarget, uno::UNO_QUERY);
+        if (xTarget2.is())
+            xTarget2->addBottom(xShape);
     }
+    else
+        xTarget->add(xShape);
+
+    xShape->setPosition( rPosition );
+    xShape->setSize( rSize );
+    uno::Reference< beans::XPropertySet > xPropSet( 
static_cast<cppu::OWeakObject*>(xShape.get()), uno::UNO_QUERY_THROW );
+    PropertyMapper::setMultiProperties( rPropNames, rPropValues, xPropSet );
 
     return xShape;
 }
 
-uno::Reference< drawing::XShape >
+rtl::Reference<SvxShapeRect>
     ShapeFactory::createRectangle(
-            const uno::Reference<
-            drawing::XShapes >& xTarget )
+            const uno::Reference< drawing::XShapes >& xTarget )
 {
-    uno::Reference< drawing::XShape > xShape( m_xShapeFactory->createInstance(
-                "com.sun.star.drawing.RectangleShape"), uno::UNO_QUERY );
+    rtl::Reference<SvxShapeRect> xShape = new SvxShapeRect(nullptr);
+    xShape->setShapeKind(OBJ_RECT);
     xTarget->add( xShape );
 
     return xShape;
diff --git a/chart2/source/view/main/VLegend.cxx 
b/chart2/source/view/main/VLegend.cxx
index 2e7ddbf8f4f3..0837dc0581fa 100644
--- a/chart2/source/view/main/VLegend.cxx
+++ b/chart2/source/view/main/VLegend.cxx
@@ -929,7 +929,6 @@ void VLegend::createShapes(
     try
     {
         //create shape and add to page
-        ShapeFactory* pShapeFactory = 
ShapeFactory::getOrCreateShapeFactory(m_xShapeFactory);
         OUString aLegendParticle( ObjectIdentifier::createParticleForLegend( 
mrModel ) );
         m_xShape = ShapeFactory::createGroup2D( m_xTarget,
                     ObjectIdentifier::createClassifiedIdentifierForParticle( 
aLegendParticle ) );
@@ -1040,7 +1039,7 @@ void VLegend::createShapes(
                     pButton->createShapes(xModelPage);
                 }
 
-                Reference<drawing::XShape> xBorder = 
pShapeFactory->createRectangle(
+                rtl::Reference<SvxShapeRect> xBorder = 
ShapeFactory::createRectangle(
                     xLegendContainer, aLegendSize, awt::Point(0, 0), 
aLineFillProperties.first,
                     aLineFillProperties.second, 
ShapeFactory::StackPosition::Bottom);
 
diff --git a/chart2/source/view/main/VLegendSymbolFactory.cxx 
b/chart2/source/view/main/VLegendSymbolFactory.cxx
index 655c63850c05..70931e9ff7fd 100644
--- a/chart2/source/view/main/VLegendSymbolFactory.cxx
+++ b/chart2/source/view/main/VLegendSymbolFactory.cxx
@@ -112,7 +112,7 @@ rtl::Reference< SvxShapeGroup > 
VLegendSymbolFactory::createSymbol(
     Reference< drawing::XShapes > xResultGroup( 
static_cast<cppu::OWeakObject*>(xResult.get()), uno::UNO_QUERY_THROW );
 
     // add an invisible square box to maintain aspect ratio
-    pShapeFactory->createInvisibleRectangle( xResultGroup, 
rEntryKeyAspectRatio );
+    ShapeFactory::createInvisibleRectangle( xResultGroup, rEntryKeyAspectRatio 
);
 
     // create symbol
     try
@@ -183,7 +183,7 @@ rtl::Reference< SvxShapeGroup > 
VLegendSymbolFactory::createSymbol(
             getPropNamesAndValues( xLegendEntryProperties, aPropNames, 
aPropValues,
                     ePropertyType, awt::Size(0,0) );// 
PropertyType::FilledSeries
 
-            pShapeFactory->createRectangle( xResultGroup,
+            ShapeFactory::createRectangle( xResultGroup,
                         rEntryKeyAspectRatio, awt::Point( 0, 0 ),
                         aPropNames, aPropValues );
         }
diff --git a/include/svx/unoshape.hxx b/include/svx/unoshape.hxx
index 51422fd9dfd6..fdf1f5de1b61 100644
--- a/include/svx/unoshape.hxx
+++ b/include/svx/unoshape.hxx
@@ -397,7 +397,7 @@ public:
 class SvxShapeRect final : public SvxShapeText
 {
 public:
-    SvxShapeRect(SdrObject* pObj);
+    SVXCORE_DLLPUBLIC SvxShapeRect(SdrObject* pObj);
     virtual ~SvxShapeRect() noexcept override;
 
     // XInterface
diff --git a/osx/soffice.xcodeproj/project.pbxproj 
b/osx/soffice.xcodeproj/project.pbxproj
index e540ccf9d73a..7c38c37538f7 100644
--- a/osx/soffice.xcodeproj/project.pbxproj
+++ b/osx/soffice.xcodeproj/project.pbxproj
@@ -8,6 +8,7 @@
 
 /* Begin PBXFileReference section */
                456E58CF277CB9C700FA12D2 /* unoshap2.cxx */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; 
name = unoshap2.cxx; path = ../svx/source/unodraw/unoshap2.cxx; sourceTree = 
"<group>"; };
+               456E58D1277CC33E00FA12D2 /* unopage.cxx */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; 
name = unopage.cxx; path = ../svx/source/unodraw/unopage.cxx; sourceTree = 
"<group>"; };
                BE017B8725AF2ABE00244ED8 /* autostyl.cxx */ = {isa = 
PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = autostyl.cxx; 
path = ../sc/source/ui/docshell/autostyl.cxx; sourceTree = "<group>"; };
                BE017B8825AF2ABE00244ED8 /* servobj.cxx */ = {isa = 
PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = servobj.cxx; 
path = ../sc/source/ui/docshell/servobj.cxx; sourceTree = "<group>"; };
                BE017B8925AF2ABE00244ED8 /* docsh4.cxx */ = {isa = 
PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = docsh4.cxx; 
path = ../sc/source/ui/docshell/docsh4.cxx; sourceTree = "<group>"; };
@@ -963,6 +964,7 @@
                456E58D0277CB9DE00FA12D2 /* unodraw */ = {
                        isa = PBXGroup;
                        children = (
+                               456E58D1277CC33E00FA12D2 /* unopage.cxx */,
                                456E58CF277CB9C700FA12D2 /* unoshap2.cxx */,
                        );
                        name = unodraw;

Reply via email to