chart2/source/view/axes/VAxisBase.cxx | 4 +- chart2/source/view/axes/VAxisBase.hxx | 3 - chart2/source/view/axes/VCartesianAxis.cxx | 29 ++++++++--------- chart2/source/view/inc/ShapeFactory.hxx | 4 +- chart2/source/view/main/ShapeFactory.cxx | 47 +++++++++++++---------------- chart2/source/view/main/VTitle.cxx | 2 - 6 files changed, 41 insertions(+), 48 deletions(-)
New commits: commit 5d33befeeb2452f1cfa0404483c71816fcd88314 Author: Noel Grandin <noelgran...@gmail.com> AuthorDate: Sun Jan 2 11:18:35 2022 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Sun Jan 2 17:58:04 2022 +0100 use more SvxShape in chart2 Change-Id: I95342cfa39be2a058ec6c5d106ece6e60bf85520 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127859 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/chart2/source/view/axes/VAxisBase.cxx b/chart2/source/view/axes/VAxisBase.cxx index cfb73df05e82..a7c186745f56 100644 --- a/chart2/source/view/axes/VAxisBase.cxx +++ b/chart2/source/view/axes/VAxisBase.cxx @@ -100,9 +100,9 @@ bool VAxisBase::isComplexCategoryAxis() const return m_aAxisProperties.m_bComplexCategories && m_bUseTextLabels; } -void VAxisBase::recordMaximumTextSize( const Reference< drawing::XShape >& xShape, double fRotationAngleDegree ) +void VAxisBase::recordMaximumTextSize( SvxShape& xShape, double fRotationAngleDegree ) { - if( m_bRecordMaximumTextSize && xShape.is() ) + if( m_bRecordMaximumTextSize ) { awt::Size aSize( ShapeFactory::getSizeAfterRotation( xShape, fRotationAngleDegree ) ); diff --git a/chart2/source/view/axes/VAxisBase.hxx b/chart2/source/view/axes/VAxisBase.hxx index c8a8667770e1..dd7be23e3cc6 100644 --- a/chart2/source/view/axes/VAxisBase.hxx +++ b/chart2/source/view/axes/VAxisBase.hxx @@ -65,8 +65,7 @@ protected: //methods void updateUnscaledValuesAtTicks( TickIter& rIter ); virtual bool prepareShapeCreation(); - void recordMaximumTextSize( const css::uno::Reference< css::drawing::XShape >& xShape - , double fRotationAngleDegree ); + void recordMaximumTextSize( SvxShape& xShape, double fRotationAngleDegree ); bool isDateAxis() const; bool isComplexCategoryAxis() const; diff --git a/chart2/source/view/axes/VCartesianAxis.cxx b/chart2/source/view/axes/VCartesianAxis.cxx index 991b36001253..00020d1f0413 100644 --- a/chart2/source/view/axes/VCartesianAxis.cxx +++ b/chart2/source/view/axes/VCartesianAxis.cxx @@ -73,7 +73,7 @@ VCartesianAxis::~VCartesianAxis() m_pPosHelper = nullptr; } -static void lcl_ResizeTextShapeToFitAvailableSpace( Reference< drawing::XShape > const & xShape2DText, +static void lcl_ResizeTextShapeToFitAvailableSpace( SvxShape& xShape2DText, const AxisLabelProperties& rAxisLabelProperties, const OUString& rLabel, const tNameSequence& rPropNames, @@ -91,7 +91,7 @@ static void lcl_ResizeTextShapeToFitAvailableSpace( Reference< drawing::XShape > return; sal_Int32 nMaxLabelsSize = bIsHorizontalAxis ? rAxisLabelProperties.m_aMaximumSpaceForLabels.Height : rAxisLabelProperties.m_aMaximumSpaceForLabels.Width; - const sal_Int32 nAvgCharWidth = xShape2DText->getSize().Width / rLabel.getLength(); + const sal_Int32 nAvgCharWidth = xShape2DText.getSize().Width / rLabel.getLength(); const sal_Int32 nTextSize = bIsHorizontalAxis ? ShapeFactory::getSizeAfterRotation(xShape2DText, rAxisLabelProperties.fRotationAngleDegree).Height : ShapeFactory::getSizeAfterRotation(xShape2DText, rAxisLabelProperties.fRotationAngleDegree).Width; @@ -144,7 +144,7 @@ static rtl::Reference<SvxShapeText> createSingleLabel( ShapeFactory::createText( xTarget, aLabel, rPropNames, rPropValues, aATransformation ); if( rAxisProperties.m_bLimitSpaceForLabels ) - lcl_ResizeTextShapeToFitAvailableSpace(xShape2DText, rAxisLabelProperties, aLabel, rPropNames, rPropValues, bIsHorizontalAxis); + lcl_ResizeTextShapeToFitAvailableSpace(*xShape2DText, rAxisLabelProperties, aLabel, rPropNames, rPropValues, bIsHorizontalAxis); LabelPositionHelper::correctPositionForRotation( xShape2DText , rAxisProperties.maLabelAlignment.meAlignment, rAxisLabelProperties.fRotationAngleDegree, rAxisProperties.m_bComplexCategories ); @@ -152,14 +152,11 @@ static rtl::Reference<SvxShapeText> createSingleLabel( return xShape2DText; } -static bool lcl_doesShapeOverlapWithTickmark( const Reference< drawing::XShape >& xShape +static bool lcl_doesShapeOverlapWithTickmark( SvxShape& rShape , double fRotationAngleDegree , const basegfx::B2DVector& rTickScreenPosition ) { - if(!xShape.is()) - return false; - - ::basegfx::B2IRectangle aShapeRect = BaseGFXHelper::makeRectangle(xShape->getPosition(), ShapeFactory::getSizeAfterRotation( xShape, fRotationAngleDegree )); + ::basegfx::B2IRectangle aShapeRect = BaseGFXHelper::makeRectangle(rShape.getPosition(), ShapeFactory::getSizeAfterRotation( rShape, fRotationAngleDegree )); basegfx::B2IVector aPosition( static_cast<sal_Int32>( rTickScreenPosition.getX() ) @@ -326,7 +323,7 @@ static B2DVector lcl_getLabelsDistance( TickIter& rIter, const B2DVector& rDista aStaggerDirection.normalize(); sal_Int32 nDistance=0; - Reference< drawing::XShape > xShape2DText; + rtl::Reference< SvxShapeText > xShape2DText; for( TickInfo* pTickInfo = rIter.firstInfo() ; pTickInfo ; pTickInfo = rIter.nextInfo() ) @@ -334,7 +331,7 @@ static B2DVector lcl_getLabelsDistance( TickIter& rIter, const B2DVector& rDista xShape2DText = pTickInfo->xTextShape; if( xShape2DText.is() ) { - awt::Size aSize = ShapeFactory::getSizeAfterRotation( xShape2DText, fRotationAngleDegree ); + awt::Size aSize = ShapeFactory::getSizeAfterRotation( *xShape2DText, fRotationAngleDegree ); if(fabs(aStaggerDirection.getX())>fabs(aStaggerDirection.getY())) nDistance = std::max(nDistance,aSize.Width); else @@ -821,7 +818,7 @@ bool VCartesianAxis::createTextShapes( // neighboring label, try increasing the tick interval (or rhythm // as it's called) and start over. - if( lcl_doesShapeOverlapWithTickmark( pLastVisibleNeighbourTickInfo->xTextShape + if( lcl_doesShapeOverlapWithTickmark( *pLastVisibleNeighbourTickInfo->xTextShape , rAxisLabelProperties.fRotationAngleDegree , pTickInfo->aTickScreenPosition ) ) { @@ -835,7 +832,7 @@ bool VCartesianAxis::createTextShapes( rAxisLabelProperties.eStaggering = AxisLabelStaggering::StaggerEven; pLastVisibleNeighbourTickInfo = pPREPreviousVisibleTickInfo; if( !pLastVisibleNeighbourTickInfo || - !lcl_doesShapeOverlapWithTickmark( pLastVisibleNeighbourTickInfo->xTextShape + !lcl_doesShapeOverlapWithTickmark( *pLastVisibleNeighbourTickInfo->xTextShape , rAxisLabelProperties.fRotationAngleDegree , pTickInfo->aTickScreenPosition ) ) bOverlapsAfterAutoStagger = false; @@ -881,7 +878,7 @@ bool VCartesianAxis::createTextShapes( if(!pTickInfo->xTextShape.is()) continue; - recordMaximumTextSize( pTickInfo->xTextShape, rAxisLabelProperties.fRotationAngleDegree ); + recordMaximumTextSize( *pTickInfo->xTextShape, rAxisLabelProperties.fRotationAngleDegree ); // Label has multiple lines and the words are broken if( nLimitedSpaceForText>0 && !rAxisLabelProperties.bOverlapAllowed @@ -919,7 +916,7 @@ bool VCartesianAxis::createTextShapes( rAxisLabelProperties.eStaggering = AxisLabelStaggering::StaggerEven; pLastVisibleNeighbourTickInfo = pPREPreviousVisibleTickInfo; if( !pLastVisibleNeighbourTickInfo || - !lcl_doesShapeOverlapWithTickmark( pLastVisibleNeighbourTickInfo->xTextShape + !lcl_doesShapeOverlapWithTickmark( *pLastVisibleNeighbourTickInfo->xTextShape , rAxisLabelProperties.fRotationAngleDegree , pTickInfo->aTickScreenPosition ) ) bOverlapsAfterAutoStagger = false; @@ -1010,7 +1007,7 @@ bool VCartesianAxis::createTextShapesSimple( // neighboring label, try increasing the tick interval (or rhythm // as it's called) and start over. - if( lcl_doesShapeOverlapWithTickmark( pLastVisibleNeighbourTickInfo->xTextShape + if( lcl_doesShapeOverlapWithTickmark( *pLastVisibleNeighbourTickInfo->xTextShape , rAxisLabelProperties.fRotationAngleDegree , pTickInfo->aTickScreenPosition ) ) { @@ -1050,7 +1047,7 @@ bool VCartesianAxis::createTextShapesSimple( if(!pTickInfo->xTextShape.is()) continue; - recordMaximumTextSize( pTickInfo->xTextShape, rAxisLabelProperties.fRotationAngleDegree ); + recordMaximumTextSize( *pTickInfo->xTextShape, rAxisLabelProperties.fRotationAngleDegree ); //if NO OVERLAP -> remove overlapping shapes if( pLastVisibleNeighbourTickInfo && !rAxisLabelProperties.bOverlapAllowed ) diff --git a/chart2/source/view/inc/ShapeFactory.hxx b/chart2/source/view/inc/ShapeFactory.hxx index 4d5b258b65e6..42468c1dd3e9 100644 --- a/chart2/source/view/inc/ShapeFactory.hxx +++ b/chart2/source/view/inc/ShapeFactory.hxx @@ -266,10 +266,10 @@ public: , const css::awt::Size& rTargetAreaSize , const css::awt::Size& rObjectSize ); - static ::basegfx::B2IRectangle getRectangleOfShape( SvxShape& xShape ); + static ::basegfx::B2IRectangle getRectangleOfShape( SvxShape& rShape ); static css::awt::Size getSizeAfterRotation( - const css::uno::Reference< css::drawing::XShape >& xShape, double fRotationAngleDegree ); + SvxShape& rShape, double fRotationAngleDegree ); static void removeSubShapes( const css::uno::Reference< css::drawing::XShapes >& xShapes ); diff --git a/chart2/source/view/main/ShapeFactory.cxx b/chart2/source/view/main/ShapeFactory.cxx index a9666084e530..7fd5249ae4d6 100644 --- a/chart2/source/view/main/ShapeFactory.cxx +++ b/chart2/source/view/main/ShapeFactory.cxx @@ -2506,34 +2506,31 @@ awt::Point ShapeFactory::calculateTopLeftPositionToCenterObject( } awt::Size ShapeFactory::getSizeAfterRotation( - const uno::Reference< drawing::XShape >& xShape, double fRotationAngleDegree ) + SvxShape& rShape, double fRotationAngleDegree ) { awt::Size aRet(0,0); - if(xShape.is()) - { - const awt::Size aSize( xShape->getSize() ); + const awt::Size aSize( rShape.getSize() ); - if( fRotationAngleDegree == 0.0 ) - aRet = aSize; - else - { - fRotationAngleDegree = NormAngle360(fRotationAngleDegree); - if(fRotationAngleDegree>270.0) - fRotationAngleDegree=360.0-fRotationAngleDegree; - else if(fRotationAngleDegree>180.0) - fRotationAngleDegree=fRotationAngleDegree-180.0; - else if(fRotationAngleDegree>90.0) - fRotationAngleDegree=180.0-fRotationAngleDegree; - - const double fAnglePi = basegfx::deg2rad(fRotationAngleDegree); - - aRet.Height = static_cast<sal_Int32>( - aSize.Width*std::sin( fAnglePi ) - + aSize.Height*std::cos( fAnglePi )); - aRet.Width = static_cast<sal_Int32>( - aSize.Width*std::cos( fAnglePi ) - + aSize.Height*std::sin( fAnglePi )); - } + if( fRotationAngleDegree == 0.0 ) + aRet = aSize; + else + { + fRotationAngleDegree = NormAngle360(fRotationAngleDegree); + if(fRotationAngleDegree>270.0) + fRotationAngleDegree=360.0-fRotationAngleDegree; + else if(fRotationAngleDegree>180.0) + fRotationAngleDegree=fRotationAngleDegree-180.0; + else if(fRotationAngleDegree>90.0) + fRotationAngleDegree=180.0-fRotationAngleDegree; + + const double fAnglePi = basegfx::deg2rad(fRotationAngleDegree); + + aRet.Height = static_cast<sal_Int32>( + aSize.Width*std::sin( fAnglePi ) + + aSize.Height*std::cos( fAnglePi )); + aRet.Width = static_cast<sal_Int32>( + aSize.Width*std::cos( fAnglePi ) + + aSize.Height*std::sin( fAnglePi )); } return aRet; } diff --git a/chart2/source/view/main/VTitle.cxx b/chart2/source/view/main/VTitle.cxx index fdcf794156f1..d50d11f10a69 100644 --- a/chart2/source/view/main/VTitle.cxx +++ b/chart2/source/view/main/VTitle.cxx @@ -68,7 +68,7 @@ awt::Size VTitle::getUnrotatedSize() const //size before rotation awt::Size VTitle::getFinalSize() const //size after rotation { return ShapeFactory::getSizeAfterRotation( - m_xShape, m_fRotationAngleDegree ); + *m_xShape, m_fRotationAngleDegree ); } void VTitle::changePosition( const awt::Point& rPos )