chart2/source/inc/Diagram.hxx | 19 ++++++------------ chart2/source/view/main/ChartView.cxx | 35 +++++++++++++++------------------- 2 files changed, 23 insertions(+), 31 deletions(-)
New commits: commit f80376d76c6956c4b6321162cdb94128746420fa Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Mon Apr 18 19:05:45 2022 +0900 Commit: Tomaž Vajngerl <qui...@gmail.com> CommitDate: Mon Apr 18 15:56:21 2022 +0200 chart2: use a constant instead of a function for a contant value Change-Id: I21cbe01732bf78f58b3242669e696fb1f82aa64d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133119 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx index f0d4b8f160e5..f9cfdca743c4 100644 --- a/chart2/source/view/main/ChartView.cxx +++ b/chart2/source/view/main/ChartView.cxx @@ -1795,10 +1795,9 @@ std::shared_ptr< DrawModelWrapper > ChartView::getDrawModelWrapper() namespace { -sal_Int32 lcl_getDiagramTitleSpace() -{ - return 200; //=0,2 cm spacing -} + +constexpr sal_Int32 constDiagramTitleSpace = 200; //=0,2 cm spacing + bool lcl_getPropertySwapXAndYAxis( const rtl::Reference< Diagram >& xDiagram ) { bool bSwapXAndY = false; @@ -1821,7 +1820,7 @@ bool lcl_getPropertySwapXAndYAxis( const rtl::Reference< Diagram >& xDiagram ) return bSwapXAndY; } -} +} // end anonymous namespace sal_Int32 ExplicitValueProvider::getExplicitNumberFormatKeyForAxis( const Reference< chart2::XAxis >& xAxis @@ -1899,28 +1898,28 @@ awt::Rectangle ExplicitValueProvider::AddSubtractAxisTitleSizes( OUString aCID_X( ObjectIdentifier::createClassifiedIdentifierForObject( xTitle_Height, &rModel ) ); nTitleSpaceHeight = pExplicitValueProvider->getRectangleOfObject( aCID_X, true ).Height; if( nTitleSpaceHeight ) - nTitleSpaceHeight+=lcl_getDiagramTitleSpace(); + nTitleSpaceHeight += constDiagramTitleSpace; } if( xTitle_Width.is() ) { OUString aCID_Y( ObjectIdentifier::createClassifiedIdentifierForObject( xTitle_Width, &rModel ) ); nTitleSpaceWidth = pExplicitValueProvider->getRectangleOfObject( aCID_Y, true ).Width; if(nTitleSpaceWidth) - nTitleSpaceWidth+=lcl_getDiagramTitleSpace(); + nTitleSpaceWidth += constDiagramTitleSpace; } if( xSecondTitle_Height.is() ) { OUString aCID_X( ObjectIdentifier::createClassifiedIdentifierForObject( xSecondTitle_Height, &rModel ) ); nSecondTitleSpaceHeight = pExplicitValueProvider->getRectangleOfObject( aCID_X, true ).Height; if( nSecondTitleSpaceHeight ) - nSecondTitleSpaceHeight+=lcl_getDiagramTitleSpace(); + nSecondTitleSpaceHeight += constDiagramTitleSpace; } if( xSecondTitle_Width.is() ) { OUString aCID_Y( ObjectIdentifier::createClassifiedIdentifierForObject( xSecondTitle_Width, &rModel ) ); nSecondTitleSpaceWidth += pExplicitValueProvider->getRectangleOfObject( aCID_Y, true ).Width; if( nSecondTitleSpaceWidth ) - nSecondTitleSpaceWidth+=lcl_getDiagramTitleSpace(); + nSecondTitleSpaceWidth += constDiagramTitleSpace; } if( bSubtract ) { @@ -1942,12 +1941,10 @@ awt::Rectangle ExplicitValueProvider::AddSubtractAxisTitleSizes( return aRet; } -namespace { - -double lcl_getPageLayoutDistancePercentage() +namespace { - return 0.02; -} + +constexpr double constPageLayoutDistancePercentage = 0.02; bool getAvailablePosAndSizeForDiagram( CreateShapeParam2D& rParam, const awt::Size & rPageSize, const uno::Reference< beans::XPropertySet >& xProp) @@ -1955,8 +1952,8 @@ bool getAvailablePosAndSizeForDiagram( rParam.mbUseFixedInnerSize = false; //@todo: we need a size dependent on the axis labels - sal_Int32 nYDistance = static_cast<sal_Int32>(rPageSize.Height*lcl_getPageLayoutDistancePercentage()); - sal_Int32 nXDistance = static_cast<sal_Int32>(rPageSize.Width*lcl_getPageLayoutDistancePercentage()); + sal_Int32 nYDistance = static_cast<sal_Int32>(rPageSize.Height * constPageLayoutDistancePercentage); + sal_Int32 nXDistance = static_cast<sal_Int32>(rPageSize.Width * constPageLayoutDistancePercentage); rParam.maRemainingSpace.X += nXDistance; rParam.maRemainingSpace.Width -= 2*nXDistance; rParam.maRemainingSpace.Y += nYDistance; @@ -2019,8 +2016,8 @@ void changePositionOfAxisTitle( VTitle* pVTitle, TitleAlignment eAlignment awt::Point aNewPosition(0,0); awt::Size aTitleSize = pVTitle->getFinalSize(); - sal_Int32 nYDistance = static_cast<sal_Int32>(rPageSize.Height*lcl_getPageLayoutDistancePercentage()); - sal_Int32 nXDistance = static_cast<sal_Int32>(rPageSize.Width*lcl_getPageLayoutDistancePercentage()); + sal_Int32 nYDistance = static_cast<sal_Int32>(rPageSize.Height * constPageLayoutDistancePercentage); + sal_Int32 nXDistance = static_cast<sal_Int32>(rPageSize.Width * constPageLayoutDistancePercentage); switch( eAlignment ) { case ALIGN_TOP: @@ -2074,7 +2071,7 @@ std::shared_ptr<VTitle> lcl_createTitle( TitleHelper::eTitleType eType std::shared_ptr<VTitle> apVTitle; // #i109336# Improve auto positioning in chart - double fPercentage = lcl_getPageLayoutDistancePercentage(); + double fPercentage = constPageLayoutDistancePercentage; sal_Int32 nXDistance = static_cast< sal_Int32 >( rPageSize.Width * fPercentage ); sal_Int32 nYDistance = static_cast< sal_Int32 >( rPageSize.Height * fPercentage ); if ( eType == TitleHelper::MAIN_TITLE ) commit 5c562a39c901e51c0dd5fef92f7c0ea97fdb2829 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Mon Apr 18 17:41:25 2022 +0900 Commit: Tomaž Vajngerl <qui...@gmail.com> CommitDate: Mon Apr 18 15:56:09 2022 +0200 chart: cleanup member vars in Diagram.hxx Change-Id: I756d570ba932e116bb346f21b5272807e8434939 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133118 Tested-by: Tomaž Vajngerl <qui...@gmail.com> Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> diff --git a/chart2/source/inc/Diagram.hxx b/chart2/source/inc/Diagram.hxx index 07712e93dc65..3c0e31d8be6d 100644 --- a/chart2/source/inc/Diagram.hxx +++ b/chart2/source/inc/Diagram.hxx @@ -166,23 +166,18 @@ private: void fireModifyEvent(); - css::uno::Reference< css::uno::XComponentContext > m_xContext; - + css::uno::Reference<css::uno::XComponentContext> m_xContext; tCoordinateSystemContainerType m_aCoordSystems; - rtl::Reference< Wall > m_xWall; - - rtl::Reference< Wall > m_xFloor; - - css::uno::Reference< css::chart2::XTitle > - m_xTitle; + rtl::Reference<Wall> m_xWall; + rtl::Reference<Wall> m_xFloor; - rtl::Reference< ::chart::Legend > m_xLegend; - - css::uno::Reference< css::chart2::XColorScheme > - m_xColorScheme; + css::uno::Reference<css::chart2::XTitle> m_xTitle; + rtl::Reference<::chart::Legend> m_xLegend; + css::uno::Reference<css::chart2::XColorScheme> m_xColorScheme; rtl::Reference<ModifyEventForwarder> m_xModifyEventForwarder; + }; } // namespace chart