chart2/source/view/axes/VCartesianAxis.cxx | 6 - chart2/source/view/axes/VCartesianGrid.cxx | 6 - chart2/source/view/axes/VPolarAngleAxis.cxx | 2 chart2/source/view/axes/VPolarGrid.cxx | 4 chart2/source/view/charttypes/AreaChart.cxx | 2 chart2/source/view/charttypes/BarChart.cxx | 2 chart2/source/view/charttypes/CandleStickChart.cxx | 14 +-- chart2/source/view/charttypes/NetChart.cxx | 4 chart2/source/view/charttypes/PieChart.cxx | 4 chart2/source/view/charttypes/VSeriesPlotter.cxx | 8 - chart2/source/view/inc/ShapeFactory.hxx | 4 chart2/source/view/inc/VSeriesPlotter.hxx | 2 chart2/source/view/main/ShapeFactory.cxx | 95 +++++++++------------ chart2/source/view/main/VLegendSymbolFactory.cxx | 9 - 14 files changed, 74 insertions(+), 88 deletions(-)
New commits: commit 4155a29e379f2b86af2fda447019b08ab9ca4418 Author: Noel Grandin <noelgran...@gmail.com> AuthorDate: Thu Dec 30 13:06:34 2021 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Fri Dec 31 08:04:34 2021 +0100 use concrete types in chart2, createLine2D Change-Id: I7e93bd51e7b02e72e56367a5fd027d3a129ee541 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127761 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 2aa2cbf68728..263bc125742a 100644 --- a/chart2/source/view/axes/VCartesianAxis.cxx +++ b/chart2/source/view/axes/VCartesianAxis.cxx @@ -1849,7 +1849,7 @@ void VCartesianAxis::createTickMarkLineShapes( TickInfoArrayType& rTickInfos, co , m_aAxisProperties.maLabelAlignment.mfInnerTickDirection, rTickmarkProperties, !bTicksAtLabels ); } aPoints.realloc(nN); - m_pShapeFactory->createLine2D( m_xGroupShape_Shapes, aPoints + ShapeFactory::createLine2D( m_xGroupShape_Shapes, aPoints , &rTickmarkProperties.aLineProperties ); } @@ -1939,7 +1939,7 @@ void VCartesianAxis::createShapes() { drawing::PointSequenceSequence aPoints(1); apTickFactory2D->createPointSequenceForAxisMainLine( aPoints ); - Reference< drawing::XShape > xShape = m_pShapeFactory->createLine2D( + rtl::Reference<SvxShapePolyPolygon> xShape = ShapeFactory::createLine2D( m_xGroupShape_Shapes, aPoints , &m_aAxisProperties.m_aLineProperties ); //because of this name this line will be used for marking the axis @@ -1958,7 +1958,7 @@ void VCartesianAxis::createShapes() drawing::PointSequenceSequence aPoints{{ {static_cast<sal_Int32>(aStart.getX()), static_cast<sal_Int32>(aStart.getY())}, {static_cast<sal_Int32>(aEnd.getX()), static_cast<sal_Int32>(aEnd.getY())} }}; - m_pShapeFactory->createLine2D( + ShapeFactory::createLine2D( m_xGroupShape_Shapes, aPoints, &m_aAxisProperties.m_aLineProperties ); } } diff --git a/chart2/source/view/axes/VCartesianGrid.cxx b/chart2/source/view/axes/VCartesianGrid.cxx index a520f34cff75..2201904a5307 100644 --- a/chart2/source/view/axes/VCartesianGrid.cxx +++ b/chart2/source/view/axes/VCartesianGrid.cxx @@ -259,7 +259,7 @@ void VCartesianGrid::createShapes() nRealPointCount++; } aPoints.realloc(nRealPointCount); - m_pShapeFactory->createLine2D( xTarget, aPoints, &aLinePropertiesList[nDepth] ); + ShapeFactory::createLine2D( xTarget, aPoints, &aLinePropertiesList[nDepth] ); //prepare polygon for handle shape: drawing::PointSequenceSequence aHandlesPoints(1); @@ -272,8 +272,8 @@ void VCartesianGrid::createShapes() //create handle shape: VLineProperties aHandleLineProperties; aHandleLineProperties.LineStyle <<= drawing::LineStyle_NONE; - Reference< drawing::XShape > xHandleShape = - m_pShapeFactory->createLine2D( xTarget, aHandlesPoints, &aHandleLineProperties ); + rtl::Reference<SvxShapePolyPolygon> xHandleShape = + ShapeFactory::createLine2D( xTarget, aHandlesPoints, &aHandleLineProperties ); ::chart::ShapeFactory::setShapeName( xHandleShape, "HandlesOnly" ); } else //if(2!=m_nDimension) diff --git a/chart2/source/view/axes/VPolarAngleAxis.cxx b/chart2/source/view/axes/VPolarAngleAxis.cxx index de85566cd022..2223f32b6ead 100644 --- a/chart2/source/view/axes/VPolarAngleAxis.cxx +++ b/chart2/source/view/axes/VPolarAngleAxis.cxx @@ -193,7 +193,7 @@ void VPolarAngleAxis::createShapes() //create axis main lines drawing::PointSequenceSequence aPoints(1); VPolarGrid::createLinePointSequence_ForAngleAxis( aPoints, m_aAllTickInfos, m_aIncrement, m_aScale, m_pPosHelper.get(), fLogicRadius, fLogicZ ); - uno::Reference< drawing::XShape > xShape = m_pShapeFactory->createLine2D( + rtl::Reference<SvxShapePolyPolygon> xShape = ShapeFactory::createLine2D( m_xGroupShape_Shapes, aPoints, &m_aAxisProperties.m_aLineProperties ); //because of this name this line will be used for marking the axis ::chart::ShapeFactory::setShapeName( xShape, "MarkHandles" ); diff --git a/chart2/source/view/axes/VPolarGrid.cxx b/chart2/source/view/axes/VPolarGrid.cxx index 25fcb6f55d6e..79f3cb66d787 100644 --- a/chart2/source/view/axes/VPolarGrid.cxx +++ b/chart2/source/view/axes/VPolarGrid.cxx @@ -146,7 +146,7 @@ void VPolarGrid::create2DAngleGrid( const Reference< drawing::XShapes >& xLogicT appendPointSequence( aAllPoints, aPoints ); } - Reference< drawing::XShape > xShape = m_pShapeFactory->createLine2D( + rtl::Reference<SvxShapePolyPolygon> xShape = ShapeFactory::createLine2D( xMainTarget, aAllPoints, &rLinePropertiesList[nDepth] ); //because of this name this line will be used for marking m_pShapeFactory->setShapeName( xShape, "MarkHandles" ); @@ -208,7 +208,7 @@ void VPolarGrid::create2DRadiusGrid( const Reference< drawing::XShapes >& xLogic appendPointSequence( aAllPoints, aPoints ); } - Reference< drawing::XShape > xShape = m_pShapeFactory->createLine2D( + rtl::Reference<SvxShapePolyPolygon> xShape = ShapeFactory::createLine2D( xTarget, aAllPoints, &rLinePropertiesList[nDepth] ); //because of this name this line will be used for marking ::chart::ShapeFactory::setShapeName( xShape, "MarkHandles" ); diff --git a/chart2/source/view/charttypes/AreaChart.cxx b/chart2/source/view/charttypes/AreaChart.cxx index d6e97b1bdabb..4d06dc41bc27 100644 --- a/chart2/source/view/charttypes/AreaChart.cxx +++ b/chart2/source/view/charttypes/AreaChart.cxx @@ -434,7 +434,7 @@ bool AreaChart::impl_createLine( VDataSeries* pSeries } else //m_nDimension!=3 { - xShape = m_pShapeFactory->createLine2D( xSeriesGroupShape_Shapes + xShape = ShapeFactory::createLine2D( xSeriesGroupShape_Shapes , PolyToPointSequence( aPoly ) ); setMappedProperties( xShape , pSeries->getPropertiesOfSeries() diff --git a/chart2/source/view/charttypes/BarChart.cxx b/chart2/source/view/charttypes/BarChart.cxx index 9b2beb354689..f41770fb67dc 100644 --- a/chart2/source/view/charttypes/BarChart.cxx +++ b/chart2/source/view/charttypes/BarChart.cxx @@ -955,7 +955,7 @@ void BarChart::createShapes() uno::Reference< drawing::XShapes > xSeriesGroupShape_Shapes( getSeriesGroupShape(pSeries.get(), xSeriesTarget) ); - uno::Reference< drawing::XShape > xShape( m_pShapeFactory->createLine2D( + rtl::Reference<SvxShapePolyPolygon> xShape( ShapeFactory::createLine2D( xSeriesGroupShape_Shapes, PolyToPointSequence( aPoly ) ) ); setMappedProperties( xShape, pSeries->getPropertiesOfSeries() , PropertyMapper::getPropertyNameMapForFilledSeriesProperties() ); diff --git a/chart2/source/view/charttypes/CandleStickChart.cxx b/chart2/source/view/charttypes/CandleStickChart.cxx index d767cb2bce50..8f270e3dec07 100644 --- a/chart2/source/view/charttypes/CandleStickChart.cxx +++ b/chart2/source/view/charttypes/CandleStickChart.cxx @@ -221,8 +221,8 @@ void CandleStickChart::createShapes() AddPointToPoly( aPoly, aPosMiddleMinimum, nLineIndex); AddPointToPoly( aPoly, aPosMiddleMaximum, nLineIndex); - uno::Reference< drawing::XShape > xShape = - m_pShapeFactory->createLine2D( xPointGroupShape_Shapes, + rtl::Reference<SvxShapePolyPolygon> xShape = + ShapeFactory::createLine2D( xPointGroupShape_Shapes, PolyToPointSequence(aPoly)); setMappedProperties( xShape, xPointProp, PropertyMapper::getPropertyNameMapForLineSeriesProperties() ); } @@ -270,14 +270,10 @@ void CandleStickChart::createShapes() if( aPoly.SequenceX.hasElements() ) { - uno::Reference< drawing::XShape > xShape = - m_pShapeFactory->createLine2D( xPointGroupShape_Shapes, + rtl::Reference<SvxShapePolyPolygon> xShape = + ShapeFactory::createLine2D( xPointGroupShape_Shapes, PolyToPointSequence(aPoly) ); - uno::Reference< beans::XPropertySet > xProp( xShape, uno::UNO_QUERY ); - if(xProp.is()) - { - setMappedProperties( xShape, xPointProp, PropertyMapper::getPropertyNameMapForLineSeriesProperties() ); - } + setMappedProperties( xShape, xPointProp, PropertyMapper::getPropertyNameMapForLineSeriesProperties() ); } } diff --git a/chart2/source/view/charttypes/NetChart.cxx b/chart2/source/view/charttypes/NetChart.cxx index 129ccc8feffc..425898514ac7 100644 --- a/chart2/source/view/charttypes/NetChart.cxx +++ b/chart2/source/view/charttypes/NetChart.cxx @@ -150,9 +150,9 @@ bool NetChart::impl_createLine( VDataSeries* pSeries pPosHelper->transformScaledLogicToScene( aPoly ); //create line: - uno::Reference< drawing::XShape > xShape; + rtl::Reference<SvxShapePolyPolygon> xShape; { - xShape = m_pShapeFactory->createLine2D( xSeriesGroupShape_Shapes + xShape = ShapeFactory::createLine2D( xSeriesGroupShape_Shapes , PolyToPointSequence( aPoly ) ); setMappedProperties( xShape , pSeries->getPropertiesOfSeries() diff --git a/chart2/source/view/charttypes/PieChart.cxx b/chart2/source/view/charttypes/PieChart.cxx index 0a9a2f1b5af8..89250699e95c 100644 --- a/chart2/source/view/charttypes/PieChart.cxx +++ b/chart2/source/view/charttypes/PieChart.cxx @@ -531,7 +531,7 @@ void PieChart::createTextLabelShape( if (nColor != -1) aVLineProperties.Color <<= nColor; } - m_pShapeFactory->createLine2D(xTextTarget, aPoints, &aVLineProperties); + ShapeFactory::createLine2D(xTextTarget, aPoints, &aVLineProperties); } } } @@ -1303,7 +1303,7 @@ void PieChart::rearrangeLabelToAvoidOverlapIfRequested( const awt::Size& rPageSi if( nColor != -1 )//automatic font color does not work for lines -> fallback to black aVLineProperties.Color <<= nColor; } - m_pShapeFactory->createLine2D( labelInfo.xTextTarget, aPoints, &aVLineProperties ); + ShapeFactory::createLine2D( labelInfo.xTextTarget, aPoints, &aVLineProperties ); } } } diff --git a/chart2/source/view/charttypes/VSeriesPlotter.cxx b/chart2/source/view/charttypes/VSeriesPlotter.cxx index d49127e44cd5..c497d6063880 100644 --- a/chart2/source/view/charttypes/VSeriesPlotter.cxx +++ b/chart2/source/view/charttypes/VSeriesPlotter.cxx @@ -739,7 +739,7 @@ uno::Reference< drawing::XShape > VSeriesPlotter::createDataLabel( const uno::Re drawing::PointSequenceSequence aPoints{ { {nX1, nY1}, {nX2, nY2} } }; VLineProperties aVLineProperties; - m_pShapeFactory->createLine2D(xTarget, aPoints, &aVLineProperties); + ShapeFactory::createLine2D(xTarget, aPoints, &aVLineProperties); } } } @@ -1088,7 +1088,7 @@ void VSeriesPlotter::createErrorBar( lcl_AddErrorBottomLine( aPositive, aMainDirection, aPoly, nSequenceIndex ); } - uno::Reference< drawing::XShape > xShape = m_pShapeFactory->createLine2D( xTarget, PolyToPointSequence( aPoly) ); + rtl::Reference<SvxShapePolyPolygon> xShape = ShapeFactory::createLine2D( xTarget, PolyToPointSequence( aPoly) ); setMappedProperties( xShape, xErrorBarProperties, PropertyMapper::getPropertyNameMapForLineProperties() ); } catch( const uno::Exception & ) @@ -1108,7 +1108,7 @@ void VSeriesPlotter::addErrorBorder( sal_Int32 nSequenceIndex = 0; AddPointToPoly( aPoly, rPos0, nSequenceIndex ); AddPointToPoly( aPoly, rPos1, nSequenceIndex ); - uno::Reference< drawing::XShape > xShape = m_pShapeFactory->createLine2D( + rtl::Reference<SvxShapePolyPolygon> xShape = ShapeFactory::createLine2D( rTarget, PolyToPointSequence( aPoly) ); setMappedProperties( xShape, rErrorBorderProp, PropertyMapper::getPropertyNameMapForLineProperties() ); @@ -1442,7 +1442,7 @@ void VSeriesPlotter::createRegressionCurvesShapes( VDataSeries const & rVDataSer //create an extra group shape for each curve for selection handling uno::Reference< drawing::XShapes > xRegressionGroupShapes = createGroupShape( xTarget, rVDataSeries.getDataCurveCID( nN, bAverageLine ) ); - uno::Reference< drawing::XShape > xShape = m_pShapeFactory->createLine2D( + rtl::Reference<SvxShapePolyPolygon> xShape = ShapeFactory::createLine2D( xRegressionGroupShapes, PolyToPointSequence( aRegressionPoly ), &aVLineProperties ); ShapeFactory::setShapeName( xShape, "MarkHandles" ); aDefaultPos = xShape->getPosition(); diff --git a/chart2/source/view/inc/ShapeFactory.hxx b/chart2/source/view/inc/ShapeFactory.hxx index 698847350b3d..7f9bde623afa 100644 --- a/chart2/source/view/inc/ShapeFactory.hxx +++ b/chart2/source/view/inc/ShapeFactory.hxx @@ -167,12 +167,12 @@ public: , const css::drawing::Direction3D& rSize , const css::uno::Reference< css::graphic::XGraphic >& xGraphic ); - css::uno::Reference< css::drawing::XShape > + static rtl::Reference<SvxShapePolyPolygon> createLine2D( const css::uno::Reference< css::drawing::XShapes >& xTarget , const css::drawing::PointSequenceSequence& rPoints , const VLineProperties* pLineProperties = nullptr ); - css::uno::Reference< css::drawing::XShape > + static rtl::Reference<SvxShapePolyPolygon> createLine ( const css::uno::Reference< css::drawing::XShapes >& xTarget, const css::awt::Size& rSize, const css::awt::Point& rPosition ); diff --git a/chart2/source/view/inc/VSeriesPlotter.hxx b/chart2/source/view/inc/VSeriesPlotter.hxx index 2033942a3eb2..806132237127 100644 --- a/chart2/source/view/inc/VSeriesPlotter.hxx +++ b/chart2/source/view/inc/VSeriesPlotter.hxx @@ -367,7 +367,7 @@ protected: , bool bUseYErrorData ); - void addErrorBorder( + static void addErrorBorder( const css::drawing::Position3D& rPos0 , const css::drawing::Position3D& rPos1 , const css::uno::Reference< css::drawing::XShapes >& rTarget diff --git a/chart2/source/view/main/ShapeFactory.cxx b/chart2/source/view/main/ShapeFactory.cxx index fadf4edac3ab..4ee4bf704973 100644 --- a/chart2/source/view/main/ShapeFactory.cxx +++ b/chart2/source/view/main/ShapeFactory.cxx @@ -1911,7 +1911,7 @@ uno::Reference< drawing::XShape > return xShape; } -uno::Reference< drawing::XShape > +rtl::Reference<SvxShapePolyPolygon> ShapeFactory::createLine2D( const uno::Reference< drawing::XShapes >& xTarget , const drawing::PointSequenceSequence& rPoints , const VLineProperties* pLineProperties ) @@ -1923,71 +1923,64 @@ uno::Reference< drawing::XShape > return nullptr; //create shape - uno::Reference< drawing::XShape > xShape( - m_xShapeFactory->createInstance( - "com.sun.star.drawing.PolyLineShape" ), uno::UNO_QUERY ); + rtl::Reference<SvxShapePolyPolygon> xShape = new SvxShapePolyPolygon(nullptr); + xShape->setShapeKind(OBJ_PLIN); xTarget->add(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 - { - //Polygon - xProp->setPropertyValue( UNO_NAME_POLYPOLYGON - , uno::Any( rPoints ) ); + //Polygon + xShape->SvxShape::setPropertyValue( UNO_NAME_POLYPOLYGON + , uno::Any( rPoints ) ); - if(pLineProperties) - { - //Transparency - if(pLineProperties->Transparence.hasValue()) - xProp->setPropertyValue( UNO_NAME_LINETRANSPARENCE - , pLineProperties->Transparence ); - - //LineStyle - if(pLineProperties->LineStyle.hasValue()) - xProp->setPropertyValue( UNO_NAME_LINESTYLE - , pLineProperties->LineStyle ); - - //LineWidth - if(pLineProperties->Width.hasValue()) - xProp->setPropertyValue( UNO_NAME_LINEWIDTH - , pLineProperties->Width ); - - //LineColor - if(pLineProperties->Color.hasValue()) - xProp->setPropertyValue( UNO_NAME_LINECOLOR - , pLineProperties->Color ); - - //LineDashName - if(pLineProperties->DashName.hasValue()) - xProp->setPropertyValue( "LineDashName" - , pLineProperties->DashName ); - - //LineCap - if(pLineProperties->LineCap.hasValue()) - xProp->setPropertyValue( UNO_NAME_LINECAP - , pLineProperties->LineCap ); - } - } - catch( const uno::Exception& ) + if(pLineProperties) { - TOOLS_WARN_EXCEPTION("chart2", "" ); + //Transparency + if(pLineProperties->Transparence.hasValue()) + xShape->SvxShape::setPropertyValue( UNO_NAME_LINETRANSPARENCE + , pLineProperties->Transparence ); + + //LineStyle + if(pLineProperties->LineStyle.hasValue()) + xShape->SvxShape::setPropertyValue( UNO_NAME_LINESTYLE + , pLineProperties->LineStyle ); + + //LineWidth + if(pLineProperties->Width.hasValue()) + xShape->SvxShape::setPropertyValue( UNO_NAME_LINEWIDTH + , pLineProperties->Width ); + + //LineColor + if(pLineProperties->Color.hasValue()) + xShape->SvxShape::setPropertyValue( UNO_NAME_LINECOLOR + , pLineProperties->Color ); + + //LineDashName + if(pLineProperties->DashName.hasValue()) + xShape->SvxShape::setPropertyValue( "LineDashName" + , pLineProperties->DashName ); + + //LineCap + if(pLineProperties->LineCap.hasValue()) + xShape->SvxShape::setPropertyValue( UNO_NAME_LINECAP + , pLineProperties->LineCap ); } } + catch( const uno::Exception& ) + { + TOOLS_WARN_EXCEPTION("chart2", "" ); + } return xShape; } -uno::Reference< drawing::XShape > +rtl::Reference<SvxShapePolyPolygon> ShapeFactory::createLine ( const uno::Reference< drawing::XShapes >& xTarget, const awt::Size& rSize, const awt::Point& rPosition ) { //create shape - uno::Reference< drawing::XShape > xShape( - m_xShapeFactory->createInstance( - "com.sun.star.drawing.LineShape" ), uno::UNO_QUERY ); + rtl::Reference<SvxShapePolyPolygon> xShape = new SvxShapePolyPolygon(nullptr); + xShape->setShapeKind(OBJ_LINE); 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 b2abd2183430..2dca3e12a3b9 100644 --- a/chart2/source/view/main/VLegendSymbolFactory.cxx +++ b/chart2/source/view/main/VLegendSymbolFactory.cxx @@ -119,13 +119,10 @@ rtl::Reference< SvxShapeGroup > VLegendSymbolFactory::createSymbol( { if( eStyle == LegendSymbolStyle::Line ) { - Reference< drawing::XShape > xLine = - pShapeFactory->createLine( xResultGroup, awt::Size( rEntryKeyAspectRatio.Width, 0 ), + rtl::Reference<SvxShapePolyPolygon> xLine = + ShapeFactory::createLine( xResultGroup, awt::Size( rEntryKeyAspectRatio.Width, 0 ), awt::Point( 0, rEntryKeyAspectRatio.Height/2 )); - if( xLine.is()) - { - lcl_setPropertiesToShape( xLegendEntryProperties, xLine, ePropertyType, rEntryKeyAspectRatio ); - } + lcl_setPropertiesToShape( xLegendEntryProperties, xLine, ePropertyType, rEntryKeyAspectRatio ); Reference< drawing::XShape > xSymbol; const sal_Int32 nSize = std::min(rEntryKeyAspectRatio.Width,rEntryKeyAspectRatio.Height);