From a371f5de634195785c9e4b90118049b3c8260ac6 Mon Sep 17 00:00:00 2001 From: Markus Mohrhard Date: Fri, 25 Apr 2014 19:49:09 +0200 Subject: fix missing service factory during import, related fdo#74333, cp#1000057 Change-Id: I2cce561587d82b0434ef2d3e65e5d35b7ff99260 --- chart2/inc/ChartModel.hxx | 3 ++ .../chartapiwrapper/ChartDocumentWrapper.cxx | 33 ++++++++++++++++++---- chart2/source/model/main/ChartModel.cxx | 5 ++++ 3 files changed, 35 insertions(+), 6 deletions(-) diff --git a/chart2/inc/ChartModel.hxx b/chart2/inc/ChartModel.hxx index d62628fafd5e..38735d983f6f 100644 --- a/chart2/inc/ChartModel.hxx +++ b/chart2/inc/ChartModel.hxx @@ -581,12 +581,15 @@ public: ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier > getNumberFormatsSupplier(); + com::sun::star::uno::Reference< com::sun::star::uno::XInterface > getChartView(); + bool isTimeBased() const; void setTimeBased(bool bTimeBased); void getNextTimePoint(); void setTimeBasedRange(sal_Int32 nStart, sal_Int32 nEnd); +private: sal_Int32 mnStart; sal_Int32 mnEnd; bool bSet; diff --git a/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx b/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx index f68cd670d1a5..5e27717b8dc2 100644 --- a/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx @@ -1147,6 +1147,24 @@ uno::Reference< drawing::XDrawPage > ChartDocumentWrapper::impl_getDrawPage() co return m_spChart2ModelContact->getDrawPage(); } +namespace { + +uno::Reference< lang::XMultiServiceFactory > getShapeFactory(uno::Reference xChartView) +{ + Reference< lang::XUnoTunnel> xUnoTunnel(xChartView,uno::UNO_QUERY); + if(xUnoTunnel.is()) + { + ExplicitValueProvider* pProvider = reinterpret_cast(xUnoTunnel->getSomething( + ExplicitValueProvider::getUnoTunnelId() )); + if( pProvider ) + return pProvider->getDrawModelWrapper()->getShapeFactory(); + + } + return uno::Reference< lang::XMultiServiceFactory >(); +} + +} + // ____ XMultiServiceFactory ____ uno::Reference< uno::XInterface > SAL_CALL ChartDocumentWrapper::createInstance( const OUString& aServiceSpecifier ) @@ -1385,15 +1403,18 @@ uno::Reference< uno::XInterface > SAL_CALL ChartDocumentWrapper::createInstance( { if( !m_xShapeFactory.is() && m_xChartView.is() ) { - Reference< lang::XUnoTunnel> xUnoTunnel(m_xChartView,uno::UNO_QUERY); - if(xUnoTunnel.is()) + m_xShapeFactory = getShapeFactory( m_xChartView ); + } + else + { + ChartModel* pModel = m_spChart2ModelContact->getModel(); + if(pModel) { - ExplicitValueProvider* pProvider = reinterpret_cast(xUnoTunnel->getSomething( - ExplicitValueProvider::getUnoTunnelId() )); - if( pProvider ) - m_xShapeFactory.set( pProvider->getDrawModelWrapper()->getShapeFactory() ); + m_xChartView = pModel->getChartView(); + m_xShapeFactory = getShapeFactory( m_xChartView ); } } + if( m_xShapeFactory.is() ) { xResult = m_xShapeFactory->createInstance( aServiceSpecifier ); diff --git a/chart2/source/model/main/ChartModel.cxx b/chart2/source/model/main/ChartModel.cxx index 1b725ac05afc..e386d7f41a79 100644 --- a/chart2/source/model/main/ChartModel.cxx +++ b/chart2/source/model/main/ChartModel.cxx @@ -1402,6 +1402,11 @@ void ChartModel::setTimeBasedRange(sal_Int32 nStart, sal_Int32 nEnd) mbTimeBased = true; } +uno::Reference< uno::XInterface > ChartModel::getChartView() +{ + return xChartView; +} + } // namespace chart /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit v1.2.3