diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2022-01-15 13:45:44 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-01-15 15:43:59 +0100 |
commit | fe37aa64ff79abcd3aeedeb03d8d74798225a367 (patch) | |
tree | 157c0b7bd8fb1c1753995f9dfea741b2b61470d5 /chart2/source | |
parent | abb6978cabd3ef5d0bf086a388af7be6e144907e (diff) |
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.grandin@collabora.co.uk>
Diffstat (limited to 'chart2/source')
-rw-r--r-- | chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx | 21 | ||||
-rw-r--r-- | chart2/source/controller/inc/ChartDocumentWrapper.hxx | 3 | ||||
-rw-r--r-- | chart2/source/model/main/ChartModel.cxx | 6 |
3 files changed, 16 insertions, 14 deletions
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 |