diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2022-05-22 20:19:31 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-05-23 11:58:54 +0200 |
commit | 8d00d5f36454e202586df4e2dafb12c7195b7a1f (patch) | |
tree | c1ff4565feecd2282c5814c0c93ddcc22f42b266 /chart2/source | |
parent | 0c17712465b07e8a7ebe078b00123965b112f0ac (diff) |
instantiate Title directly in chart
which simplifies some code
Change-Id: I0c9aa212334a3dedd8a54f8deda6100d93b0be70
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134743
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'chart2/source')
-rw-r--r-- | chart2/source/inc/Title.hxx (renamed from chart2/source/model/main/Title.hxx) | 4 | ||||
-rw-r--r-- | chart2/source/model/main/Title.cxx | 2 | ||||
-rw-r--r-- | chart2/source/tools/TitleHelper.cxx | 104 |
3 files changed, 51 insertions, 59 deletions
diff --git a/chart2/source/model/main/Title.hxx b/chart2/source/inc/Title.hxx index 426fd5ef4219..091c558dba44 100644 --- a/chart2/source/model/main/Title.hxx +++ b/chart2/source/inc/Title.hxx @@ -18,14 +18,14 @@ */ #pragma once -#include <OPropertySet.hxx> +#include "OPropertySet.hxx" #include <cppuhelper/basemutex.hxx> #include <cppuhelper/implbase.hxx> #include <comphelper/uno3.hxx> #include <com/sun/star/chart2/XTitle.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/util/XCloneable.hpp> -#include <ModifyListenerHelper.hxx> +#include "ModifyListenerHelper.hxx" namespace chart { diff --git a/chart2/source/model/main/Title.cxx b/chart2/source/model/main/Title.cxx index ab32d7a306e6..98004e30a2d4 100644 --- a/chart2/source/model/main/Title.cxx +++ b/chart2/source/model/main/Title.cxx @@ -17,7 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include "Title.hxx" +#include <Title.hxx> #include <LinePropertiesHelper.hxx> #include <FillProperties.hxx> #include <CloneHelper.hxx> diff --git a/chart2/source/tools/TitleHelper.cxx b/chart2/source/tools/TitleHelper.cxx index ece3ec239d1b..943adace7913 100644 --- a/chart2/source/tools/TitleHelper.cxx +++ b/chart2/source/tools/TitleHelper.cxx @@ -18,6 +18,7 @@ */ #include <TitleHelper.hxx> +#include <Title.hxx> #include <ChartModel.hxx> #include <ChartModelHelper.hxx> #include <Axis.hxx> @@ -197,7 +198,7 @@ uno::Reference< XTitle > TitleHelper::createTitle( , const uno::Reference< uno::XComponentContext > & xContext , ReferenceSizeProvider * pRefSizeProvider ) { - uno::Reference< XTitle > xTitle; + rtl::Reference< ::chart::Title > xTitle; uno::Reference< XTitled > xTitled( lcl_getTitleParent( eTitleType, xModel ) ); if( !xTitled.is() ) @@ -226,71 +227,62 @@ uno::Reference< XTitle > TitleHelper::createTitle( { rtl::Reference< Diagram > xDiagram( ChartModelHelper::findDiagram( xModel ) ); - xTitle.set( xContext->getServiceManager()->createInstanceWithContext( - "com.sun.star.chart2.Title", - xContext ), uno::UNO_QUERY ); + xTitle = new ::chart::Title(); - if(xTitle.is()) + // default char height (main: 13.0 == default) + float fDefaultCharHeightSub = 11.0; + float fDefaultCharHeightAxis = 9.0; + switch( eTitleType ) { - // default char height (main: 13.0 == default) - float fDefaultCharHeightSub = 11.0; - float fDefaultCharHeightAxis = 9.0; - switch( eTitleType ) - { - case TitleHelper::SUB_TITLE: - TitleHelper::setCompleteString( - rTitleText, xTitle, xContext, & fDefaultCharHeightSub ); - break; - case TitleHelper::X_AXIS_TITLE: - case TitleHelper::Y_AXIS_TITLE: - case TitleHelper::Z_AXIS_TITLE: - case TitleHelper::TITLE_AT_STANDARD_X_AXIS_POSITION: - case TitleHelper::TITLE_AT_STANDARD_Y_AXIS_POSITION: - case TitleHelper::SECONDARY_X_AXIS_TITLE: - case TitleHelper::SECONDARY_Y_AXIS_TITLE: - TitleHelper::setCompleteString( - rTitleText, xTitle, xContext, & fDefaultCharHeightAxis ); - break; - default: - TitleHelper::setCompleteString( rTitleText, xTitle, xContext ); - break; - } + case TitleHelper::SUB_TITLE: + TitleHelper::setCompleteString( + rTitleText, xTitle, xContext, & fDefaultCharHeightSub ); + break; + case TitleHelper::X_AXIS_TITLE: + case TitleHelper::Y_AXIS_TITLE: + case TitleHelper::Z_AXIS_TITLE: + case TitleHelper::TITLE_AT_STANDARD_X_AXIS_POSITION: + case TitleHelper::TITLE_AT_STANDARD_Y_AXIS_POSITION: + case TitleHelper::SECONDARY_X_AXIS_TITLE: + case TitleHelper::SECONDARY_Y_AXIS_TITLE: + TitleHelper::setCompleteString( + rTitleText, xTitle, xContext, & fDefaultCharHeightAxis ); + break; + default: + TitleHelper::setCompleteString( rTitleText, xTitle, xContext ); + break; + } - // set/clear autoscale - if( pRefSizeProvider ) - pRefSizeProvider->setValuesAtTitle( xTitle ); + // set/clear autoscale + if( pRefSizeProvider ) + pRefSizeProvider->setValuesAtTitle( xTitle ); - xTitled->setTitleObject( xTitle ); + xTitled->setTitleObject( xTitle ); - //default rotation 90 degree for y axis title in normal coordinatesystems or for x axis title for swapped coordinatesystems - if( eTitleType == TitleHelper::X_AXIS_TITLE || - eTitleType == TitleHelper::Y_AXIS_TITLE || - eTitleType == TitleHelper::SECONDARY_X_AXIS_TITLE || - eTitleType == TitleHelper::SECONDARY_Y_AXIS_TITLE ) + //default rotation 90 degree for y axis title in normal coordinatesystems or for x axis title for swapped coordinatesystems + if( eTitleType == TitleHelper::X_AXIS_TITLE || + eTitleType == TitleHelper::Y_AXIS_TITLE || + eTitleType == TitleHelper::SECONDARY_X_AXIS_TITLE || + eTitleType == TitleHelper::SECONDARY_Y_AXIS_TITLE ) + { + try { - try - { - bool bDummy = false; - bool bIsVertical = DiagramHelper::getVertical( xDiagram, bDummy, bDummy ); - - Reference< beans::XPropertySet > xTitleProps( xTitle, uno::UNO_QUERY ); - if( xTitleProps.is() ) - { - if( (!bIsVertical && eTitleType == TitleHelper::Y_AXIS_TITLE) - || (bIsVertical && eTitleType == TitleHelper::X_AXIS_TITLE) - || (!bIsVertical && eTitleType == TitleHelper::SECONDARY_Y_AXIS_TITLE) - || (bIsVertical && eTitleType == TitleHelper::SECONDARY_X_AXIS_TITLE) ) - { - xTitleProps->setPropertyValue( "TextRotation", uno::Any( 90.0 )); - } - } - } - catch( const uno::Exception & ) + bool bDummy = false; + bool bIsVertical = DiagramHelper::getVertical( xDiagram, bDummy, bDummy ); + + if( (!bIsVertical && eTitleType == TitleHelper::Y_AXIS_TITLE) + || (bIsVertical && eTitleType == TitleHelper::X_AXIS_TITLE) + || (!bIsVertical && eTitleType == TitleHelper::SECONDARY_Y_AXIS_TITLE) + || (bIsVertical && eTitleType == TitleHelper::SECONDARY_X_AXIS_TITLE) ) { - DBG_UNHANDLED_EXCEPTION("chart2"); + xTitle->setPropertyValue( "TextRotation", uno::Any( 90.0 )); } } + catch( const uno::Exception & ) + { + DBG_UNHANDLED_EXCEPTION("chart2"); + } } } return xTitle; |