From 6b85c0adf8050c1eba89f2115dc5151a7507369f Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Sat, 1 Jan 2022 09:18:54 +0200 Subject: use concrete types in chart2, createCircle Change-Id: I42810d2a77e860e8a911288db8556043f7ed1d3c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127836 Tested-by: Jenkins Reviewed-by: Noel Grandin --- chart2/source/view/charttypes/BubbleChart.cxx | 8 +++--- chart2/source/view/inc/ShapeFactory.hxx | 4 +-- chart2/source/view/main/ShapeFactory.cxx | 31 +++++++++--------------- chart2/source/view/main/VLegendSymbolFactory.cxx | 10 +++----- include/svx/unoshape.hxx | 2 +- 5 files changed, 21 insertions(+), 34 deletions(-) diff --git a/chart2/source/view/charttypes/BubbleChart.cxx b/chart2/source/view/charttypes/BubbleChart.cxx index 8f526f465ea6..afdd0c4c9594 100644 --- a/chart2/source/view/charttypes/BubbleChart.cxx +++ b/chart2/source/view/charttypes/BubbleChart.cxx @@ -271,7 +271,7 @@ void BubbleChart::createShapes() //create data point drawing::Direction3D aSymbolSize = transformToScreenBubbleSize( fBubbleSize ); - uno::Reference xShape = m_pShapeFactory->createCircle2D( xPointGroupShape_Shapes + rtl::Reference xShape = ShapeFactory::createCircle2D( xPointGroupShape_Shapes , aScenePosition, aSymbolSize ); setMappedProperties( xShape @@ -283,8 +283,7 @@ void BubbleChart::createShapes() double nPropVal = pSeries->getValueByProperty(nIndex, "FillColor"); if(!std::isnan(nPropVal)) { - uno::Reference< beans::XPropertySet > xProps( xShape, uno::UNO_QUERY_THROW ); - xProps->setPropertyValue("FillColor", uno::Any(static_cast(nPropVal))); + xShape->SvxShape::setPropertyValue("FillColor", uno::Any(static_cast(nPropVal))); } } if(bHasBorderColorMapping) @@ -292,8 +291,7 @@ void BubbleChart::createShapes() double nPropVal = pSeries->getValueByProperty(nIndex, "LineColor"); if(!std::isnan(nPropVal)) { - uno::Reference< beans::XPropertySet > xProps( xShape, uno::UNO_QUERY_THROW ); - xProps->setPropertyValue("LineColor", uno::Any(static_cast(nPropVal))); + xShape->SvxShape::setPropertyValue("LineColor", uno::Any(static_cast(nPropVal))); } } diff --git a/chart2/source/view/inc/ShapeFactory.hxx b/chart2/source/view/inc/ShapeFactory.hxx index a2b91b3e83f1..523bf48b5922 100644 --- a/chart2/source/view/inc/ShapeFactory.hxx +++ b/chart2/source/view/inc/ShapeFactory.hxx @@ -181,12 +181,12 @@ public: , const css::drawing::PolyPolygonShape3D& rPoints , const VLineProperties& rLineProperties ); - css::uno::Reference< css::drawing::XShape > + static rtl::Reference createCircle2D( const css::uno::Reference< css::drawing::XShapes >& xTarget , const css::drawing::Position3D& rPos , const css::drawing::Direction3D& rSize ); - css::uno::Reference< css::drawing::XShape > + static rtl::Reference createCircle( const css::uno::Reference< css::drawing::XShapes >& xTarget , const css::awt::Size& rSize , const css::awt::Point& rPosition ); diff --git a/chart2/source/view/main/ShapeFactory.cxx b/chart2/source/view/main/ShapeFactory.cxx index 90019cc51de0..f58098e128b7 100644 --- a/chart2/source/view/main/ShapeFactory.cxx +++ b/chart2/source/view/main/ShapeFactory.cxx @@ -1776,7 +1776,7 @@ rtl::Reference return nullptr; } -uno::Reference< drawing::XShape > +rtl::Reference ShapeFactory::createCircle2D( const uno::Reference< drawing::XShapes >& xTarget , const drawing::Position3D& rPosition , const drawing::Direction3D& rSize ) @@ -1785,9 +1785,8 @@ uno::Reference< drawing::XShape > return nullptr; //create shape - uno::Reference< drawing::XShape > xShape( - m_xShapeFactory->createInstance( - "com.sun.star.drawing.EllipseShape" ), uno::UNO_QUERY ); + rtl::Reference xShape = new SvxShapeCircle(nullptr); + xShape->setShapeKind(OBJ_CIRC); xTarget->add(xShape); try @@ -1805,30 +1804,24 @@ uno::Reference< drawing::XShape > } //set properties - uno::Reference< beans::XPropertySet > xProp( xShape, uno::UNO_QUERY ); - OSL_ENSURE(xProp.is(), "created shape offers no XPropertySet"); - if( xProp.is()) + try { - try - { - xProp->setPropertyValue( UNO_NAME_CIRCKIND, uno::Any( drawing::CircleKind_FULL ) ); - } - catch( const uno::Exception& ) - { - TOOLS_WARN_EXCEPTION("chart2", "" ); - } + xShape->SvxShape::setPropertyValue( UNO_NAME_CIRCKIND, uno::Any( drawing::CircleKind_FULL ) ); + } + catch( const uno::Exception& ) + { + TOOLS_WARN_EXCEPTION("chart2", "" ); } return xShape; } -uno::Reference< drawing::XShape > +rtl::Reference ShapeFactory::createCircle( const uno::Reference< drawing::XShapes >& xTarget , const awt::Size& rSize , const awt::Point& rPosition ) { - uno::Reference< drawing::XShape > xShape( - m_xShapeFactory->createInstance( - "com.sun.star.drawing.EllipseShape" ), uno::UNO_QUERY ); + rtl::Reference xShape = new SvxShapeCircle(nullptr); + xShape->setShapeKind(OBJ_CIRC); xTarget->add(xShape); xShape->setSize( rSize ); xShape->setPosition( rPosition ); diff --git a/chart2/source/view/main/VLegendSymbolFactory.cxx b/chart2/source/view/main/VLegendSymbolFactory.cxx index 2dca3e12a3b9..02138aac1103 100644 --- a/chart2/source/view/main/VLegendSymbolFactory.cxx +++ b/chart2/source/view/main/VLegendSymbolFactory.cxx @@ -104,7 +104,6 @@ rtl::Reference< SvxShapeGroup > VLegendSymbolFactory::createSymbol( if( ! (rSymbolContainer.is() && xShapeFactory.is())) return xResult; - ShapeFactory* pShapeFactory = ShapeFactory::getOrCreateShapeFactory(xShapeFactory); xResult = ShapeFactory::createGroup2D( rSymbolContainer ); if( ! xResult) return xResult; @@ -163,13 +162,10 @@ rtl::Reference< SvxShapeGroup > VLegendSymbolFactory::createSymbol( else if( eStyle == LegendSymbolStyle::Circle ) { sal_Int32 nSize = std::min( rEntryKeyAspectRatio.Width, rEntryKeyAspectRatio.Height ); - Reference< drawing::XShape > xShape = - pShapeFactory->createCircle( xResultGroup, awt::Size( nSize, nSize ), + rtl::Reference xShape = + ShapeFactory::createCircle( xResultGroup, awt::Size( nSize, nSize ), awt::Point( rEntryKeyAspectRatio.Width/2-nSize/2, rEntryKeyAspectRatio.Height/2-nSize/2 )); - if( xShape.is() ) - { - lcl_setPropertiesToShape( xLegendEntryProperties, xShape, ePropertyType, awt::Size(0,0) ); // PropertyType::FilledSeries ); - } + lcl_setPropertiesToShape( xLegendEntryProperties, xShape, ePropertyType, awt::Size(0,0) ); // PropertyType::FilledSeries ); } else // eStyle == LegendSymbolStyle::Box { diff --git a/include/svx/unoshape.hxx b/include/svx/unoshape.hxx index cbc26fd98333..03f7b4c66189 100644 --- a/include/svx/unoshape.hxx +++ b/include/svx/unoshape.hxx @@ -574,7 +574,7 @@ public: class SvxShapeCircle final : public SvxShapeText { public: - SvxShapeCircle(SdrObject* pObj); + SVXCORE_DLLPUBLIC SvxShapeCircle(SdrObject* pObj); virtual ~SvxShapeCircle() noexcept override; }; -- cgit