chart2/source/inc/ControllerLockGuard.hxx | 9 +++++---- chart2/source/inc/ReferenceSizeProvider.hxx | 8 +++++--- chart2/source/inc/RegressionCurveHelper.hxx | 4 +++- chart2/source/model/main/ChartModel.cxx | 6 +++--- chart2/source/tools/AxisHelper.cxx | 2 +- chart2/source/tools/ControllerLockGuard.cxx | 4 ++-- chart2/source/tools/DataSourceHelper.cxx | 4 +++- chart2/source/tools/DiagramHelper.cxx | 12 +++++++++--- chart2/source/tools/ReferenceSizeProvider.cxx | 12 ++++++------ chart2/source/tools/RegressionCurveHelper.cxx | 3 ++- 10 files changed, 39 insertions(+), 25 deletions(-)
New commits: commit 379a9e76ef5cbe7dd17641745cd07b85b5852a0b Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Mon Jan 24 09:12:07 2022 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Mon Jan 24 14:09:15 2022 +0100 use more concrete types in chart2, ChartModel Change-Id: I621cc667d914ddfbfc84a9dd5a71bc76d411954b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128847 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/chart2/source/inc/ControllerLockGuard.hxx b/chart2/source/inc/ControllerLockGuard.hxx index c84e87af36ad..78958eb90648 100644 --- a/chart2/source/inc/ControllerLockGuard.hxx +++ b/chart2/source/inc/ControllerLockGuard.hxx @@ -20,6 +20,7 @@ #include "charttoolsdllapi.hxx" #include <com/sun/star/uno/Reference.h> +#include <rtl/ref.hxx> namespace chart { @@ -39,11 +40,11 @@ namespace chart class OOO_DLLPUBLIC_CHARTTOOLS ControllerLockGuardUNO { public: - explicit ControllerLockGuardUNO(const css::uno::Reference<css::frame::XModel>& xModel); + explicit ControllerLockGuardUNO(const rtl::Reference<::chart::ChartModel>& xModel); ~ControllerLockGuardUNO(); private: - css::uno::Reference<css::frame::XModel> mxModel; + rtl::Reference<::chart::ChartModel> mxModel; }; class ControllerLockGuard @@ -65,14 +66,14 @@ private: class OOO_DLLPUBLIC_CHARTTOOLS ControllerLockHelper { public: - explicit ControllerLockHelper(const css::uno::Reference<css::frame::XModel>& xModel); + explicit ControllerLockHelper(const rtl::Reference<::chart::ChartModel>& xModel); ~ControllerLockHelper(); SAL_DLLPRIVATE void lockControllers(); SAL_DLLPRIVATE void unlockControllers(); private: - css::uno::Reference<css::frame::XModel> m_xModel; + rtl::Reference<::chart::ChartModel> m_xModel; }; /** This guard calls lockControllers at the given ControllerLockHelper in the diff --git a/chart2/source/inc/ReferenceSizeProvider.hxx b/chart2/source/inc/ReferenceSizeProvider.hxx index 3db11e5327b1..eb8fa534b472 100644 --- a/chart2/source/inc/ReferenceSizeProvider.hxx +++ b/chart2/source/inc/ReferenceSizeProvider.hxx @@ -21,6 +21,7 @@ #include <com/sun/star/uno/Reference.hxx> #include <com/sun/star/awt/Size.hpp> #include "charttoolsdllapi.hxx" +#include <rtl/ref.hxx> namespace com::sun::star { namespace chart2 { @@ -35,6 +36,7 @@ namespace com::sun::star { namespace chart { +class ChartModel; class OOO_DLLPUBLIC_CHARTTOOLS ReferenceSizeProvider { @@ -50,7 +52,7 @@ public: ReferenceSizeProvider( css::awt::Size aPageSize, - const css::uno::Reference< css::chart2::XChartDocument > & xChartDoc ); + const rtl::Reference<::chart::ChartModel> & xChartDoc ); const css::awt::Size& getPageSize() const { return m_aPageSize;} @@ -63,7 +65,7 @@ public: with state NO, AUTO_RESIZE_AMBIGUOUS is returned. */ static AutoResizeState getAutoResizeState( - const css::uno::Reference< css::chart2::XChartDocument > & xChartDoc ); + const rtl::Reference<::chart::ChartModel> & xChartDoc ); /** sets or resets the auto-resize at all objects that support this feature for text to the opposite of the current setting. If the current state @@ -119,7 +121,7 @@ private: AutoResizeState & rInOutState ); css::awt::Size m_aPageSize; - css::uno::Reference< css::chart2::XChartDocument > m_xChartDoc; + rtl::Reference<::chart::ChartModel> m_xChartDoc; bool m_bUseAutoScale; }; diff --git a/chart2/source/inc/RegressionCurveHelper.hxx b/chart2/source/inc/RegressionCurveHelper.hxx index 83fc72e65649..318b29d7db36 100644 --- a/chart2/source/inc/RegressionCurveHelper.hxx +++ b/chart2/source/inc/RegressionCurveHelper.hxx @@ -20,6 +20,7 @@ #include <svx/chrtitem.hxx> #include "charttoolsdllapi.hxx" +#include <rtl/ref.hxx> #include <vector> @@ -31,6 +32,7 @@ namespace com::sun::star::chart2 { class XRegressionCurveCalculator; } namespace com::sun::star::chart2 { class XRegressionCurveContainer; } namespace com::sun::star::chart2::data { class XDataSource; } namespace com::sun::star::frame { class XModel; } +namespace chart { class ChartModel; } namespace chart::RegressionCurveHelper { @@ -144,7 +146,7 @@ namespace chart::RegressionCurveHelper OOO_DLLPUBLIC_CHARTTOOLS void initializeCurveCalculator( const css::uno::Reference<css::chart2::XRegressionCurveCalculator>& xOutCurveCalculator, const css::uno::Reference<css::chart2::XDataSeries>& xSeries, - const css::uno::Reference<css::frame::XModel>& xModel ); + const rtl::Reference<::chart::ChartModel>& xModel ); OOO_DLLPUBLIC_CHARTTOOLS OUString getUINameForRegressionCurve( const css::uno::Reference<css::chart2::XRegressionCurve>& xCurve ); diff --git a/chart2/source/model/main/ChartModel.cxx b/chart2/source/model/main/ChartModel.cxx index 5105459f7a14..afc61decaa78 100644 --- a/chart2/source/model/main/ChartModel.cxx +++ b/chart2/source/model/main/ChartModel.cxx @@ -862,12 +862,12 @@ void SAL_CALL ChartModel::setArguments( const Sequence< beans::PropertyValue >& Sequence< OUString > SAL_CALL ChartModel::getUsedRangeRepresentations() { - return DataSourceHelper::getUsedDataRanges( Reference< frame::XModel >(this)); + return DataSourceHelper::getUsedDataRanges( this ); } Reference< chart2::data::XDataSource > SAL_CALL ChartModel::getUsedData() { - return DataSourceHelper::getUsedData( Reference< chart2::XChartDocument >(this)); + return DataSourceHelper::getUsedData( *this ); } Reference< chart2::data::XRangeHighlighter > SAL_CALL ChartModel::getRangeHighlighter() @@ -1247,7 +1247,7 @@ void SAL_CALL ChartModel::setParent( const Reference< uno::XInterface >& Parent uno::Sequence< Reference< chart2::data::XLabeledDataSequence > > SAL_CALL ChartModel::getDataSequences() { Reference< chart2::data::XDataSource > xSource( - DataSourceHelper::getUsedData( uno::Reference< frame::XModel >(this) ) ); + DataSourceHelper::getUsedData( *this ) ); if( xSource.is()) return xSource->getDataSequences(); diff --git a/chart2/source/tools/AxisHelper.cxx b/chart2/source/tools/AxisHelper.cxx index 25054aa2482c..3dbbffbe1544 100644 --- a/chart2/source/tools/AxisHelper.cxx +++ b/chart2/source/tools/AxisHelper.cxx @@ -189,7 +189,7 @@ sal_Int32 AxisHelper::getExplicitNumberFormatKeyForAxis( } else { - Reference< data::XDataSource > xSource( DataSourceHelper::getUsedData( Reference< XChartDocument >(xChartDoc) ) ); + Reference< data::XDataSource > xSource( DataSourceHelper::getUsedData( *xChartDoc ) ); if( xSource.is() ) { std::vector< Reference< chart2::data::XLabeledDataSequence > > aXValues( diff --git a/chart2/source/tools/ControllerLockGuard.cxx b/chart2/source/tools/ControllerLockGuard.cxx index 7719755e9aff..9ae942a5a5ff 100644 --- a/chart2/source/tools/ControllerLockGuard.cxx +++ b/chart2/source/tools/ControllerLockGuard.cxx @@ -27,7 +27,7 @@ using ::com::sun::star::uno::Reference; namespace chart { -ControllerLockGuardUNO::ControllerLockGuardUNO( const uno::Reference< frame::XModel >& xModel ) : +ControllerLockGuardUNO::ControllerLockGuardUNO( const rtl::Reference<::chart::ChartModel>& xModel ) : mxModel( xModel ) { mxModel->lockControllers(); @@ -49,7 +49,7 @@ ControllerLockGuard::~ControllerLockGuard() mrModel.unlockControllers(); } -ControllerLockHelper::ControllerLockHelper( const Reference< frame::XModel > & xModel ) : +ControllerLockHelper::ControllerLockHelper( const rtl::Reference<::chart::ChartModel> & xModel ) : m_xModel( xModel ) {} diff --git a/chart2/source/tools/DataSourceHelper.cxx b/chart2/source/tools/DataSourceHelper.cxx index 627d94416d63..851204c70a75 100644 --- a/chart2/source/tools/DataSourceHelper.cxx +++ b/chart2/source/tools/DataSourceHelper.cxx @@ -450,7 +450,9 @@ void DataSourceHelper::setRangeSegmentation( if( !xDataSource.is() ) return; - ControllerLockGuardUNO aCtrlLockGuard( xChartModel ); + auto pModel = dynamic_cast<ChartModel*>(xChartModel.get()); + assert(pModel); + ControllerLockGuardUNO aCtrlLockGuard( pModel ); xDiagram->setDiagramData( xDataSource, aArguments ); } diff --git a/chart2/source/tools/DiagramHelper.cxx b/chart2/source/tools/DiagramHelper.cxx index f7440c8ec1c0..d55ce0873967 100644 --- a/chart2/source/tools/DiagramHelper.cxx +++ b/chart2/source/tools/DiagramHelper.cxx @@ -1024,7 +1024,9 @@ void DiagramHelper::switchToDateCategories( const Reference< XChartDocument >& x { if(xChartDoc.is()) { - ControllerLockGuardUNO aCtrlLockGuard( xChartDoc ); + auto pModel = dynamic_cast<ChartModel*>(xChartDoc.get()); + assert(pModel); + ControllerLockGuardUNO aCtrlLockGuard( pModel ); Reference< chart2::XCoordinateSystem > xCooSys( ChartModelHelper::getFirstCoordinateSystem( xChartDoc ) ); if( xCooSys.is() ) @@ -1039,7 +1041,9 @@ void DiagramHelper::switchToTextCategories( const Reference< XChartDocument >& x { if(xChartDoc.is()) { - ControllerLockGuardUNO aCtrlLockGuard( xChartDoc ); + auto pModel = dynamic_cast<ChartModel*>(xChartDoc.get()); + assert(pModel); + ControllerLockGuardUNO aCtrlLockGuard( pModel ); Reference< chart2::XCoordinateSystem > xCooSys( ChartModelHelper::getFirstCoordinateSystem( xChartDoc ) ); if( xCooSys.is() ) @@ -1546,7 +1550,9 @@ static void lcl_ensureRange0to1( double& rValue ) bool DiagramHelper::setDiagramPositioning( const uno::Reference< frame::XModel >& xChartModel, const awt::Rectangle& rPosRect /*100th mm*/ ) { - ControllerLockGuardUNO aCtrlLockGuard( xChartModel ); + auto pModel = dynamic_cast<ChartModel*>(xChartModel.get()); + assert(pModel); + ControllerLockGuardUNO aCtrlLockGuard( pModel ); bool bChanged = false; awt::Size aPageSize( ChartModelHelper::getPageSize(xChartModel) ); diff --git a/chart2/source/tools/ReferenceSizeProvider.cxx b/chart2/source/tools/ReferenceSizeProvider.cxx index ba9b497dac20..46dfb1d593f8 100644 --- a/chart2/source/tools/ReferenceSizeProvider.cxx +++ b/chart2/source/tools/ReferenceSizeProvider.cxx @@ -20,6 +20,7 @@ #include <ReferenceSizeProvider.hxx> #include <RelativeSizeHelper.hxx> #include <ChartModelHelper.hxx> +#include <ChartModel.hxx> #include <DiagramHelper.hxx> #include <Diagram.hxx> #include <AxisHelper.hxx> @@ -42,7 +43,7 @@ namespace chart ReferenceSizeProvider::ReferenceSizeProvider( awt::Size aPageSize, - const Reference< XChartDocument > & xChartDoc ) : + const rtl::Reference<::chart::ChartModel> & xChartDoc ) : m_aPageSize( aPageSize ), m_xChartDoc( xChartDoc ), m_bUseAutoScale( getAutoResizeState( xChartDoc ) == AUTO_RESIZE_YES ) @@ -218,14 +219,13 @@ void ReferenceSizeProvider::impl_getAutoResizeFromTitled( with state NO, AUTO_RESIZE_AMBIGUOUS is returned. */ ReferenceSizeProvider::AutoResizeState ReferenceSizeProvider::getAutoResizeState( - const Reference< XChartDocument > & xChartDoc ) + const rtl::Reference<::chart::ChartModel> & xChartDoc ) { AutoResizeState eResult = AUTO_RESIZE_UNKNOWN; // Main Title - Reference< XTitled > xDocTitled( xChartDoc, uno::UNO_QUERY ); - if( xDocTitled.is()) - impl_getAutoResizeFromTitled( xDocTitled, eResult ); + if( xChartDoc.is()) + impl_getAutoResizeFromTitled( xChartDoc, eResult ); if( eResult == AUTO_RESIZE_AMBIGUOUS ) return eResult; @@ -315,7 +315,7 @@ void ReferenceSizeProvider::setAutoResizeState( ReferenceSizeProvider::AutoResiz m_bUseAutoScale = (eNewState == AUTO_RESIZE_YES); // Main Title - impl_setValuesAtTitled( Reference< XTitled >( m_xChartDoc, uno::UNO_QUERY )); + impl_setValuesAtTitled( m_xChartDoc ); // diagram is needed by the rest of the objects Reference< XDiagram > xDiagram = ChartModelHelper::findDiagram( m_xChartDoc ); diff --git a/chart2/source/tools/RegressionCurveHelper.cxx b/chart2/source/tools/RegressionCurveHelper.cxx index 4c7a1e53394b..52ab1e1785e9 100644 --- a/chart2/source/tools/RegressionCurveHelper.cxx +++ b/chart2/source/tools/RegressionCurveHelper.cxx @@ -29,6 +29,7 @@ #include "RegressionCurveModel.hxx" #include <ChartTypeHelper.hxx> #include <ChartType.hxx> +#include <ChartModel.hxx> #include <ChartModelHelper.hxx> #include <ResId.hxx> #include <strings.hrc> @@ -229,7 +230,7 @@ void RegressionCurveHelper::initializeCurveCalculator( void RegressionCurveHelper::initializeCurveCalculator( const Reference< XRegressionCurveCalculator > & xOutCurveCalculator, const Reference< XDataSeries > & xSeries, - const Reference< frame::XModel > & xModel ) + const rtl::Reference<::chart::ChartModel> & xModel ) { sal_Int32 nAxisType = ChartTypeHelper::getAxisType( ChartModelHelper::getChartTypeOfSeries( xModel, xSeries ), 0 ); // x-axis