chart2/inc/ChartModel.hxx | 4 - chart2/inc/ChartView.hxx | 2 chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx | 21 ++++------ chart2/source/controller/inc/ChartDocumentWrapper.hxx | 3 - chart2/source/model/main/ChartModel.cxx | 6 +- 5 files changed, 19 insertions(+), 17 deletions(-)
New commits: commit fe37aa64ff79abcd3aeedeb03d8d74798225a367 Author: Noel Grandin <noelgran...@gmail.com> AuthorDate: Sat Jan 15 13:45:44 2022 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Sat Jan 15 15:43:59 2022 +0100 use more concrete types in chart2, ChartView Change-Id: I7316d01d08eb1d9d482937fdd87bd34e2ae7e3c6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128461 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/chart2/inc/ChartModel.hxx b/chart2/inc/ChartModel.hxx index 8f1defa197be..b3d1d3f42ce9 100644 --- a/chart2/inc/ChartModel.hxx +++ b/chart2/inc/ChartModel.hxx @@ -120,7 +120,7 @@ private: bool mbTimeBased; - rtl::Reference<ChartView> mxChartView; + mutable rtl::Reference<ChartView> mxChartView; OUString m_aResource; css::uno::Sequence< css::beans::PropertyValue > m_aMediaDescriptor; @@ -454,7 +454,7 @@ public: css::uno::Reference< css::util::XNumberFormatsSupplier > const & getNumberFormatsSupplier(); - css::uno::Reference< css::uno::XInterface > getChartView() const; + ChartView* getChartView() const; bool isTimeBased() const { return mbTimeBased;} diff --git a/chart2/inc/ChartView.hxx b/chart2/inc/ChartView.hxx index 27408b53f844..46dd1da17975 100644 --- a/chart2/inc/ChartView.hxx +++ b/chart2/inc/ChartView.hxx @@ -114,7 +114,7 @@ public: virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; // ___lang::XInitialization___ - virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) override; + virtual OOO_DLLPUBLIC_CHARTVIEW void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) override; // ___ExplicitValueProvider___ virtual bool getExplicitValuesForAxis( diff --git a/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx b/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx index a4e494c9e5cb..aa5d09c2c99a 100644 --- a/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx @@ -18,6 +18,7 @@ */ #include <ChartDocumentWrapper.hxx> +#include <ChartView.hxx> #include <servicenames.hxx> #include <PropertyHelper.hxx> #include <TitleHelper.hxx> @@ -1242,19 +1243,17 @@ uno::Reference< uno::XInterface > SAL_CALL ChartDocumentWrapper::createInstance( { if( !m_xChartView.is() ) { - Reference< lang::XMultiServiceFactory > xFact( - m_spChart2ModelContact->m_xContext->getServiceManager(), uno::UNO_QUERY_THROW ); - Reference< lang::XInitialization > xViewInit( xFact->createInstance( - CHART_VIEW_SERVICE_NAME ), uno::UNO_QUERY ); - if(xViewInit.is()) + ChartModel* pModel = m_spChart2ModelContact->getModel(); + ChartView* pChartView = pModel->getChartView(); + if(pChartView) { try { - m_xChartView = xViewInit; + m_xChartView = pChartView; Sequence< Any > aArguments{ Any(Reference<frame::XModel>(this)), Any(true) }; // bRefreshAddIn - xViewInit->initialize(aArguments); + pChartView->initialize(aArguments); } catch (const uno::Exception&) { @@ -1262,7 +1261,7 @@ uno::Reference< uno::XInterface > SAL_CALL ChartDocumentWrapper::createInstance( } } } - xResult.set( m_xChartView ); + xResult.set( static_cast<cppu::OWeakObject*>(m_xChartView.get()) ); bServiceFound = true; } else @@ -1272,7 +1271,7 @@ uno::Reference< uno::XInterface > SAL_CALL ChartDocumentWrapper::createInstance( { if( !m_xShapeFactory.is() && m_xChartView.is() ) { - m_xShapeFactory = getShapeFactory( m_xChartView ); + m_xShapeFactory = getShapeFactory( static_cast<cppu::OWeakObject*>(m_xChartView.get()) ); } else { @@ -1280,7 +1279,7 @@ uno::Reference< uno::XInterface > SAL_CALL ChartDocumentWrapper::createInstance( if(pModel) { m_xChartView = pModel->getChartView(); - m_xShapeFactory = getShapeFactory( m_xChartView ); + m_xShapeFactory = getShapeFactory( static_cast<cppu::OWeakObject*>(m_xChartView.get()) ); } } @@ -1386,7 +1385,7 @@ void ChartDocumentWrapper::_disposing( const lang::EventObject& rSource ) m_xArea.set( nullptr ); else if( rSource.Source == m_xAddIn ) m_xAddIn.set( nullptr ); - else if( rSource.Source == m_xChartView ) + else if( rSource.Source == static_cast<cppu::OWeakObject*>(m_xChartView.get()) ) m_xChartView.set( nullptr ); } diff --git a/chart2/source/controller/inc/ChartDocumentWrapper.hxx b/chart2/source/controller/inc/ChartDocumentWrapper.hxx index 563575a4b667..d8d5e034b2fa 100644 --- a/chart2/source/controller/inc/ChartDocumentWrapper.hxx +++ b/chart2/source/controller/inc/ChartDocumentWrapper.hxx @@ -32,6 +32,7 @@ namespace com::sun::star::uno { class XComponentContext; } namespace com::sun::star::util { class XRefreshable; } +namespace chart { class ChartView; } namespace chart::wrapper { @@ -157,7 +158,7 @@ private: //member OUString m_aBaseDiagram; bool m_bUpdateAddIn; - css::uno::Reference< css::uno::XInterface > m_xChartView; + rtl::Reference< ChartView > m_xChartView; css::uno::Reference< css::lang::XMultiServiceFactory> m_xShapeFactory; diff --git a/chart2/source/model/main/ChartModel.cxx b/chart2/source/model/main/ChartModel.cxx index 4c67110264ed..f1582aec9289 100644 --- a/chart2/source/model/main/ChartModel.cxx +++ b/chart2/source/model/main/ChartModel.cxx @@ -188,9 +188,11 @@ void SAL_CALL ChartModel::initialize( const Sequence< Any >& /*rArguments*/ ) //support argument "DocumentRecoverySupport"? } -css::uno::Reference< css::uno::XInterface > ChartModel::getChartView() const +ChartView* ChartModel::getChartView() const { - return static_cast< ::cppu::OWeakObject* >( mxChartView.get() ); + if(!mxChartView.is()) + mxChartView = new ChartView( m_xContext, const_cast<ChartModel&>(*this)); + return mxChartView.get(); } // private methods