chart2/inc/ChartView.hxx | 2 - chart2/source/controller/main/ObjectHierarchy.cxx | 10 ++++--- chart2/source/inc/chartview/ExplicitValueProvider.hxx | 3 +- chart2/source/view/axes/VCartesianAxis.cxx | 2 - chart2/source/view/charttypes/AreaChart.cxx | 3 -- chart2/source/view/charttypes/BubbleChart.cxx | 3 -- chart2/source/view/charttypes/NetChart.cxx | 3 -- chart2/source/view/charttypes/PieChart.cxx | 22 +++++++---------- chart2/source/view/charttypes/PieChart.hxx | 4 +-- chart2/source/view/main/ChartView.cxx | 23 +++++++++++------- 10 files changed, 39 insertions(+), 36 deletions(-)
New commits: commit 5dfe561cffe6e2a41a76ee78244b16bdb80b0892 Author: Noel Grandin <noelgran...@gmail.com> AuthorDate: Wed Feb 9 19:02:42 2022 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Thu Feb 10 07:50:12 2022 +0100 use more concrete types in chart2, SvxShape Change-Id: Ieadcd95d7d75d925b2c5528ba231d4686d4fcb7d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129738 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/chart2/source/view/axes/VCartesianAxis.cxx b/chart2/source/view/axes/VCartesianAxis.cxx index 8e7b3a1e728e..cb053a7ce986 100644 --- a/chart2/source/view/axes/VCartesianAxis.cxx +++ b/chart2/source/view/axes/VCartesianAxis.cxx @@ -202,7 +202,7 @@ static bool doesOverlap( const rtl::Reference<SvxShapeText>& xShape1 static void removeShapesAtWrongRhythm( TickIter& rIter , sal_Int32 nCorrectRhythm , sal_Int32 nMaxTickToCheck - , const Reference< drawing::XShapes >& xTarget ) + , const rtl::Reference< SvxShapeGroupAnyD >& xTarget ) { sal_Int32 nTick = 0; for( TickInfo* pTickInfo = rIter.firstInfo() diff --git a/chart2/source/view/charttypes/AreaChart.cxx b/chart2/source/view/charttypes/AreaChart.cxx index 0dd77b97d7b7..9160ad8d93ee 100644 --- a/chart2/source/view/charttypes/AreaChart.cxx +++ b/chart2/source/view/charttypes/AreaChart.cxx @@ -799,7 +799,6 @@ void AreaChart::createShapes() pSeries->getPointCID_Stub(), nIndex ); rtl::Reference<SvxShapeGroupAnyD> xPointGroupShape_Shapes( createGroupShape(xSeriesGroupShape_Shapes,aPointCID) ); - uno::Reference<drawing::XShape> xPointGroupShape_Shape( static_cast<cppu::OWeakObject*>(xPointGroupShape_Shapes.get()), uno::UNO_QUERY ); { nCreatedPoints++; @@ -921,7 +920,7 @@ void AreaChart::createShapes() //remove PointGroupShape if empty if(!xPointGroupShape_Shapes->getCount()) - xSeriesGroupShape_Shapes->remove(xPointGroupShape_Shape); + xSeriesGroupShape_Shapes->remove(xPointGroupShape_Shapes); } }//next series in x slot (next y slot) diff --git a/chart2/source/view/charttypes/BubbleChart.cxx b/chart2/source/view/charttypes/BubbleChart.cxx index bf97f39c5061..803cf73b20d4 100644 --- a/chart2/source/view/charttypes/BubbleChart.cxx +++ b/chart2/source/view/charttypes/BubbleChart.cxx @@ -262,7 +262,6 @@ void BubbleChart::createShapes() pSeries->getPointCID_Stub(), nIndex ); rtl::Reference<SvxShapeGroupAnyD> xPointGroupShape_Shapes( createGroupShape(xSeriesGroupShape_Shapes,aPointCID) ); - uno::Reference<drawing::XShape> xPointGroupShape_Shape = xPointGroupShape_Shapes; { nCreatedPoints++; @@ -346,7 +345,7 @@ void BubbleChart::createShapes() //remove PointGroupShape if empty if(!xPointGroupShape_Shapes->getCount()) - xSeriesGroupShape_Shapes->remove(xPointGroupShape_Shape); + xSeriesGroupShape_Shapes->remove(xPointGroupShape_Shapes); }//next series in x slot (next y slot) }//next x slot diff --git a/chart2/source/view/charttypes/NetChart.cxx b/chart2/source/view/charttypes/NetChart.cxx index ed2b0e8387d0..1e23ad7f6ce9 100644 --- a/chart2/source/view/charttypes/NetChart.cxx +++ b/chart2/source/view/charttypes/NetChart.cxx @@ -529,7 +529,6 @@ void NetChart::createShapes() pSeries->getPointCID_Stub(), nIndex ); rtl::Reference<SvxShapeGroupAnyD> xPointGroupShape_Shapes( createGroupShape(xSeriesGroupShape_Shapes,aPointCID) ); - uno::Reference<drawing::XShape> xPointGroupShape_Shape( xPointGroupShape_Shapes ); { //create data point @@ -627,7 +626,7 @@ void NetChart::createShapes() //remove PointGroupShape if empty if(!xPointGroupShape_Shapes->getCount()) - xSeriesGroupShape_Shapes->remove(xPointGroupShape_Shape); + xSeriesGroupShape_Shapes->remove(xPointGroupShape_Shapes); }//next series in x slot (next y slot) }//next x slot diff --git a/chart2/source/view/charttypes/PieChart.cxx b/chart2/source/view/charttypes/PieChart.cxx index d05f10070598..cf1bfde1c294 100644 --- a/chart2/source/view/charttypes/PieChart.cxx +++ b/chart2/source/view/charttypes/PieChart.cxx @@ -105,7 +105,7 @@ struct PieChart::ShapeParam namespace { -::basegfx::B2IRectangle lcl_getRect(const uno::Reference<drawing::XShape>& xShape) +::basegfx::B2IRectangle lcl_getRect(const rtl::Reference<SvxShape>& xShape) { ::basegfx::B2IRectangle aRect; if (xShape.is()) @@ -402,13 +402,13 @@ void PieChart::createTextLabelShape( ///a new `PieLabelInfo` instance is initialized with all the info related to ///the current label in order to simplify later label position rearrangement; - uno::Reference< container::XChild > xChild( aPieLabelInfo.xTextShape, uno::UNO_QUERY ); + rtl::Reference< SvxShape > xChild = aPieLabelInfo.xTextShape; ///text shape could be empty; in that case there is no need to add label info if( !xChild.is() ) return; - aPieLabelInfo.xLabelGroupShape.set( xChild->getParent(), uno::UNO_QUERY ); + aPieLabelInfo.xLabelGroupShape = dynamic_cast<SvxShapeGroupAnyD*>(xChild->getParent().get()); if (bMovementAllowed && !m_bUseRings) { @@ -456,12 +456,11 @@ void PieChart::createTextLabelShape( aPieLabelInfo.xTextShape = createDataLabel(xTextTarget, rSeries, nPointIndex, nVal, rParam.mfLogicYSum, aScreenPosition2D, eAlignment, 0, nTextMaximumFrameWidth); - xChild.clear(); - xChild.set(uno::Reference<container::XChild>(aPieLabelInfo.xTextShape, uno::UNO_QUERY)); + xChild = aPieLabelInfo.xTextShape; if (!xChild.is()) return; - aPieLabelInfo.xLabelGroupShape.set(xChild->getParent(), uno::UNO_QUERY); + aPieLabelInfo.xLabelGroupShape = dynamic_cast<SvxShapeGroupAnyD*>(xChild->getParent().get()); } } @@ -519,13 +518,11 @@ void PieChart::createTextLabelShape( { drawing::PointSequenceSequence aPoints{ { {nX1, nY1}, {nX2, nY2} } }; - uno::Reference<beans::XPropertySet> xProp(aPieLabelInfo.xTextShape, - uno::UNO_QUERY); VLineProperties aVLineProperties; - if (xProp.is()) + if (aPieLabelInfo.xTextShape.is()) { sal_Int32 nColor = 0; - xProp->getPropertyValue("CharColor") >>= nColor; + aPieLabelInfo.xTextShape->SvxShape::getPropertyValue("CharColor") >>= nColor; //automatic font color does not work for lines -> fallback to black if (nColor != -1) aVLineProperties.Color <<= nColor; @@ -1290,11 +1287,10 @@ void PieChart::rearrangeLabelToAvoidOverlapIfRequested( const awt::Size& rPageSi drawing::PointSequenceSequence aPoints{ { {nX1, nY1}, {nX2, nY2} } }; - uno::Reference< beans::XPropertySet > xProp( labelInfo.xTextShape, uno::UNO_QUERY); - if( xProp.is() ) + if( labelInfo.xTextShape.is() ) { sal_Int32 nColor = 0; - xProp->getPropertyValue("CharColor") >>= nColor; + labelInfo.xTextShape->SvxShape::getPropertyValue("CharColor") >>= nColor; if( nColor != -1 )//automatic font color does not work for lines -> fallback to black aVLineProperties.Color <<= nColor; } diff --git a/chart2/source/view/charttypes/PieChart.hxx b/chart2/source/view/charttypes/PieChart.hxx index cb6b92dddae7..c990cc6e4a13 100644 --- a/chart2/source/view/charttypes/PieChart.hxx +++ b/chart2/source/view/charttypes/PieChart.hxx @@ -119,8 +119,8 @@ private: //member bool moveAwayFrom( const PieLabelInfo* pFix, const css::awt::Size& rPageSize , bool bMoveHalfWay, bool bMoveClockwise ); - css::uno::Reference< css::drawing::XShape > xTextShape; - css::uno::Reference< css::drawing::XShape > xLabelGroupShape; + rtl::Reference< SvxShapeText > xTextShape; + rtl::Reference< SvxShapeGroupAnyD > xLabelGroupShape; ::basegfx::B2IVector aFirstPosition; ::basegfx::B2IVector aOuterPosition; ::basegfx::B2IVector aOrigin; commit 5477193c9ca425509d529fb20dcb0db6a66b5d08 Author: Noel Grandin <noelgran...@gmail.com> AuthorDate: Wed Feb 9 18:47:17 2022 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Thu Feb 10 07:49:56 2022 +0100 use more concrete types in chart2, SvxShape Change-Id: I9ae954f8efaec31d5b848c633e66adb62a13f3f4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129737 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/chart2/inc/ChartView.hxx b/chart2/inc/ChartView.hxx index 228d24bc19fe..4d50c7693d4f 100644 --- a/chart2/inc/ChartView.hxx +++ b/chart2/inc/ChartView.hxx @@ -121,7 +121,7 @@ public: css::uno::Reference< css::chart2::XAxis > xAxis , ExplicitScaleData& rExplicitScale , ExplicitIncrementData& rExplicitIncrement ) override; - virtual css::uno::Reference< css::drawing::XShape > + virtual rtl::Reference< SvxShape > getShapeForCID( const OUString& rObjectCID ) override; virtual css::awt::Rectangle getRectangleOfObject( const OUString& rObjectCID, bool bSnapRect=false ) override; diff --git a/chart2/source/controller/main/ObjectHierarchy.cxx b/chart2/source/controller/main/ObjectHierarchy.cxx index 0472cf23e9a6..cba33e832180 100644 --- a/chart2/source/controller/main/ObjectHierarchy.cxx +++ b/chart2/source/controller/main/ObjectHierarchy.cxx @@ -203,8 +203,9 @@ void ObjectHierarchy::createLegendTree( // iterate over child shapes of legend and search for matching CIDs if( m_pExplicitValueProvider ) { - Reference< container::XIndexAccess > xLegendShapeContainer( - m_pExplicitValueProvider->getShapeForCID( aLegendOID.getObjectCID() ), uno::UNO_QUERY ); + rtl::Reference< SvxShapeGroupAnyD > xLegendShapeContainer = + dynamic_cast<SvxShapeGroupAnyD*>( + m_pExplicitValueProvider->getShapeForCID( aLegendOID.getObjectCID() ).get() ); ObjectHierarchy::tChildContainer aLegendEntryOIDs; lcl_getChildOIDs( aLegendEntryOIDs, xLegendShapeContainer ); @@ -394,8 +395,9 @@ void ObjectHierarchy::createDataSeriesTree( // iterate over child shapes of legend and search for matching CIDs if( m_pExplicitValueProvider ) { - Reference< container::XIndexAccess > xSeriesShapeContainer( - m_pExplicitValueProvider->getShapeForCID( aSeriesOID.getObjectCID() ), uno::UNO_QUERY ); + rtl::Reference< SvxShapeGroupAnyD > xSeriesShapeContainer = + dynamic_cast<SvxShapeGroupAnyD*>( + m_pExplicitValueProvider->getShapeForCID( aSeriesOID.getObjectCID() ).get() ); lcl_getChildOIDs( aSeriesSubContainer, xSeriesShapeContainer ); } diff --git a/chart2/source/inc/chartview/ExplicitValueProvider.hxx b/chart2/source/inc/chartview/ExplicitValueProvider.hxx index e77df0ddcf3d..3e599a0cf9ab 100644 --- a/chart2/source/inc/chartview/ExplicitValueProvider.hxx +++ b/chart2/source/inc/chartview/ExplicitValueProvider.hxx @@ -38,6 +38,7 @@ namespace com::sun::star::uno { class XInterface; } namespace com::sun::star::uno { template <typename > class Reference; } namespace com::sun::star::uno { template <typename > class Sequence; } namespace com::sun::star::util { class XNumberFormatsSupplier; } +class SvxShape; namespace chart { @@ -64,7 +65,7 @@ public: virtual css::awt::Rectangle getDiagramRectangleExcludingAxes()=0; - virtual css::uno::Reference< css::drawing::XShape > + virtual rtl::Reference< SvxShape > getShapeForCID( const OUString& rObjectCID )=0; virtual std::shared_ptr< DrawModelWrapper > getDrawModelWrapper() = 0; diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx index a0b09a86202c..56955f4c8f8b 100644 --- a/chart2/source/view/main/ChartView.cxx +++ b/chart2/source/view/main/ChartView.cxx @@ -1707,13 +1707,17 @@ SdrPage* ChartView::getSdrPage() return nullptr; } -uno::Reference< drawing::XShape > ChartView::getShapeForCID( const OUString& rObjectCID ) +rtl::Reference< SvxShape > ChartView::getShapeForCID( const OUString& rObjectCID ) { SolarMutexGuard aSolarGuard; SdrObject* pObj = DrawModelWrapper::getNamedSdrObject( rObjectCID, this->getSdrPage() ); - if( pObj ) - return uno::Reference< drawing::XShape >( pObj->getUnoShape(), uno::UNO_QUERY); - return nullptr; + if( !pObj ) + return nullptr; + + uno::Reference< drawing::XShape > xShape = pObj->getUnoShape(); + rtl::Reference<SvxShape> xShape2 = dynamic_cast<SvxShape*>(xShape.get()); + assert(xShape2 || !xShape); + return xShape2; } awt::Rectangle ChartView::getDiagramRectangleExcludingAxes() @@ -1727,7 +1731,7 @@ awt::Rectangle ChartView::getRectangleOfObject( const OUString& rObjectCID, bool impl_updateView(); awt::Rectangle aRet; - uno::Reference< drawing::XShape > xShape( getShapeForCID(rObjectCID) ); + rtl::Reference< SvxShape > xShape = getShapeForCID(rObjectCID); if(xShape.is()) { //special handling for axis for old api: @@ -1736,7 +1740,7 @@ awt::Rectangle ChartView::getRectangleOfObject( const OUString& rObjectCID, bool if( eObjectType == OBJECTTYPE_AXIS || eObjectType == OBJECTTYPE_DIAGRAM ) { SolarMutexGuard aSolarGuard; - SdrObject* pRootSdrObject = SdrObject::getSdrObjectFromXShape( xShape ); + SdrObject* pRootSdrObject = xShape->GetSdrObject(); if( pRootSdrObject ) { SdrObjList* pRootList = pRootSdrObject->GetSubList(); @@ -1747,7 +1751,10 @@ awt::Rectangle ChartView::getRectangleOfObject( const OUString& rObjectCID, bool aShapeName = "PlotAreaIncludingAxes"; SdrObject* pShape = DrawModelWrapper::getNamedSdrObject( aShapeName, pRootList ); if( pShape ) - xShape.set( pShape->getUnoShape(), uno::UNO_QUERY); + { + xShape = dynamic_cast<SvxShape*>(pShape->getUnoShape().get()); + assert(xShape); + } } } } @@ -1758,7 +1765,7 @@ awt::Rectangle ChartView::getRectangleOfObject( const OUString& rObjectCID, bool if( bSnapRect ) { //for rotated objects the shape size and position differs from the visible rectangle - SdrObject* pSdrObject = SdrObject::getSdrObjectFromXShape( xShape ); + SdrObject* pSdrObject = xShape->GetSdrObject(); if( pSdrObject ) { tools::Rectangle aSnapRect( pSdrObject->GetSnapRect() );