chart2/source/model/inc/Diagram.hxx | 26 +++++++------------------ chart2/source/view/main/ChartView.cxx | 35 +++++++++++++++------------------- 2 files changed, 24 insertions(+), 37 deletions(-)
New commits: commit 280321962f16b6fe953e9e1def5ea81ddc255932 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Mon Apr 18 19:05:45 2022 +0900 Commit: Tomaž Vajngerl <qui...@gmail.com> CommitDate: Tue Apr 19 07:40:31 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> (cherry picked from commit f80376d76c6956c4b6321162cdb94128746420fa) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133157 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx index 8a5f3b17d33c..666ea63fd213 100644 --- a/chart2/source/view/main/ChartView.cxx +++ b/chart2/source/view/main/ChartView.cxx @@ -1809,10 +1809,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 uno::Reference< XDiagram >& xDiagram ) { bool bSwapXAndY = false; @@ -1837,7 +1836,7 @@ bool lcl_getPropertySwapXAndYAxis( const uno::Reference< XDiagram >& xDiagram ) return bSwapXAndY; } -} +} // end anonymous namespace sal_Int32 ExplicitValueProvider::getExplicitNumberFormatKeyForAxis( const Reference< chart2::XAxis >& xAxis @@ -1915,28 +1914,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 ) { @@ -1958,12 +1957,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) @@ -1971,8 +1968,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; @@ -2035,8 +2032,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: @@ -2091,7 +2088,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 c32676fc8f61411da120eb1b39eae97b28b45783 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Mon Apr 18 17:41:25 2022 +0900 Commit: Tomaž Vajngerl <qui...@gmail.com> CommitDate: Tue Apr 19 07:40:17 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> (cherry picked from commit 5c562a39c901e51c0dd5fef92f7c0ea97fdb2829) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133156 diff --git a/chart2/source/model/inc/Diagram.hxx b/chart2/source/model/inc/Diagram.hxx index 4e32b48b895c..ff3b836bc93f 100644 --- a/chart2/source/model/inc/Diagram.hxx +++ b/chart2/source/model/inc/Diagram.hxx @@ -151,30 +151,20 @@ private: void fireModifyEvent(); - css::uno::Reference< css::uno::XComponentContext > m_xContext; + css::uno::Reference<css::uno::XComponentContext> m_xContext; typedef - std::vector< css::uno::Reference< css::chart2::XCoordinateSystem > > + std::vector<css::uno::Reference<css::chart2::XCoordinateSystem>> tCoordinateSystemContainerType; tCoordinateSystemContainerType m_aCoordSystems; - css::uno::Reference< css::beans::XPropertySet > - m_xWall; - - css::uno::Reference< css::beans::XPropertySet > - m_xFloor; - - css::uno::Reference< css::chart2::XTitle > - m_xTitle; - - css::uno::Reference< css::chart2::XLegend > - m_xLegend; - - css::uno::Reference< css::chart2::XColorScheme > - m_xColorScheme; - - css::uno::Reference< css::util::XModifyListener > m_xModifyEventForwarder; + css::uno::Reference<css::beans::XPropertySet> m_xWall; + css::uno::Reference<css::beans::XPropertySet> m_xFloor; + css::uno::Reference<css::chart2::XTitle> m_xTitle; + css::uno::Reference<css::chart2::XLegend> m_xLegend; + css::uno::Reference<css::chart2::XColorScheme> m_xColorScheme; + css::uno::Reference<css::util::XModifyListener> m_xModifyEventForwarder; }; } // namespace chart