diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-01-18 15:21:16 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-01-18 18:11:03 +0100 |
commit | aa06241b9c90cd41bed804bd1d55233b28f03886 (patch) | |
tree | 4bd1254768e19d17f876c011327fa6a0127fee8b /chart2/source/model | |
parent | Use "smart" INetURLObject ctor for user input right away (diff) | |
download | core-aa06241b9c90cd41bed804bd1d55233b28f03886.tar.gz core-aa06241b9c90cd41bed804bd1d55233b28f03886.zip |
use more concrete types in chart2, ChartTypeManager
Change-Id: If5055256c3e3a20ab1a30e9c8bf46f453785e80c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128557
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'chart2/source/model')
-rw-r--r-- | chart2/source/model/inc/ChartTypeManager.hxx | 70 | ||||
-rw-r--r-- | chart2/source/model/main/ChartModel.cxx | 16 | ||||
-rw-r--r-- | chart2/source/model/main/ChartModel_Persistence.cxx | 5 | ||||
-rw-r--r-- | chart2/source/model/main/Diagram.cxx | 4 |
4 files changed, 13 insertions, 82 deletions
diff --git a/chart2/source/model/inc/ChartTypeManager.hxx b/chart2/source/model/inc/ChartTypeManager.hxx deleted file mode 100644 index 244ea507234a..000000000000 --- a/chart2/source/model/inc/ChartTypeManager.hxx +++ /dev/null @@ -1,70 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ -#pragma once - -#include <cppuhelper/implbase.hxx> -#include <com/sun/star/lang/XMultiServiceFactory.hpp> -#include <com/sun/star/lang/XServiceInfo.hpp> -#include <com/sun/star/chart2/XChartTypeManager.hpp> - -namespace com::sun::star::uno { class XComponentContext; } - -namespace chart -{ - -class ChartTypeManager final : - public ::cppu::WeakImplHelper< - css::lang::XServiceInfo, - css::lang::XMultiServiceFactory, - css::chart2::XChartTypeManager > -{ -public: - explicit ChartTypeManager( - css::uno::Reference< css::uno::XComponentContext > const & xContext ); - virtual ~ChartTypeManager() override; - - virtual OUString SAL_CALL - getImplementationName() - override; - virtual sal_Bool SAL_CALL - supportsService( const OUString& ServiceName ) - override; - virtual css::uno::Sequence< OUString > SAL_CALL - getSupportedServiceNames() - override; - -protected: - // ____ XMultiServiceFactory ____ - virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstance( const OUString& aServiceSpecifier ) override; - virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstanceWithArguments( - const OUString& ServiceSpecifier, - const css::uno::Sequence< css::uno::Any >& Arguments ) override; - virtual css::uno::Sequence< OUString > SAL_CALL getAvailableServiceNames() override; - - // ____ XChartTypeManager ____ - // currently empty - -private: - css::uno::Reference< css::uno::XComponentContext > - m_xContext; -}; - -} // namespace chart - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/model/main/ChartModel.cxx b/chart2/source/model/main/ChartModel.cxx index 0e494311a32e..6d75a433ebf9 100644 --- a/chart2/source/model/main/ChartModel.cxx +++ b/chart2/source/model/main/ChartModel.cxx @@ -18,6 +18,7 @@ */ #include <ChartModel.hxx> +#include <ChartTypeManager.hxx> #include <servicenames.hxx> #include <DataSourceHelper.hxx> #include <ChartModelHelper.hxx> @@ -110,8 +111,7 @@ ChartModel::ChartModel(uno::Reference<uno::XComponentContext > const & xContext) { ModifyListenerHelper::addListener( m_xPageBackground, this ); - m_xChartTypeManager.set( xContext->getServiceManager()->createInstanceWithContext( - "com.sun.star.chart2.ChartTypeManager", m_xContext ), uno::UNO_QUERY ); + m_xChartTypeManager = new ::chart::ChartTypeManager( m_xContext ); } osl_atomic_decrement(&m_refCount); } @@ -152,7 +152,7 @@ ChartModel::ChartModel( const ChartModel & rOther ) Reference< chart2::XTitle > xNewTitle = CreateRefClone< chart2::XTitle >()( rOther.m_xTitle ); rtl::Reference< ::chart::Diagram > xNewDiagram = new ::chart::Diagram( *rOther.m_xDiagram ); Reference< beans::XPropertySet > xNewPageBackground = CreateRefClone< beans::XPropertySet >()( rOther.m_xPageBackground ); - Reference< chart2::XChartTypeManager > xChartTypeManager = CreateRefClone< chart2::XChartTypeManager >()( rOther.m_xChartTypeManager ); + rtl::Reference< ::chart::ChartTypeManager > xChartTypeManager; // does not implement XCloneable Reference< container::XNameAccess > xXMLNamespaceMap = CreateRefClone< container::XNameAccess >()( rOther.m_xXMLNamespaceMap ); { @@ -540,7 +540,7 @@ void SAL_CALL ChartModel::dispose() m_xInternalDataProvider.clear(); m_xNumberFormatsSupplier.clear(); DisposeHelper::DisposeAndClear( m_xOwnNumberFormatsSupplier ); - DisposeHelper::DisposeAndClear( m_xChartTypeManager ); + m_xChartTypeManager.clear(); m_xDiagram.clear(); DisposeHelper::DisposeAndClear( m_xTitle ); DisposeHelper::DisposeAndClear( m_xPageBackground ); @@ -896,9 +896,8 @@ Reference<awt::XRequestCallback> SAL_CALL ChartModel::getPopupRequest() Reference< chart2::XChartTypeTemplate > ChartModel::impl_createDefaultChartTypeTemplate() { Reference< chart2::XChartTypeTemplate > xTemplate; - Reference< lang::XMultiServiceFactory > xFact( m_xChartTypeManager, uno::UNO_QUERY ); - if( xFact.is() ) - xTemplate.set( xFact->createInstance( "com.sun.star.chart2.template.Column" ), uno::UNO_QUERY ); + if( m_xChartTypeManager.is() ) + xTemplate.set( m_xChartTypeManager->createInstance( "com.sun.star.chart2.template.Column" ), uno::UNO_QUERY ); return xTemplate; } @@ -906,7 +905,8 @@ void SAL_CALL ChartModel::setChartTypeManager( const uno::Reference< chart2::XCh { { MutexGuard aGuard( m_aModelMutex ); - m_xChartTypeManager = xNewManager; + m_xChartTypeManager = dynamic_cast<::chart::ChartTypeManager*>(xNewManager.get()); + assert(!xNewManager || m_xChartTypeManager); } setModified( true ); } diff --git a/chart2/source/model/main/ChartModel_Persistence.cxx b/chart2/source/model/main/ChartModel_Persistence.cxx index b246aa18f2b1..2bd9327babe5 100644 --- a/chart2/source/model/main/ChartModel_Persistence.cxx +++ b/chart2/source/model/main/ChartModel_Persistence.cxx @@ -22,6 +22,7 @@ #include <MediaDescriptorHelper.hxx> #include <ChartViewHelper.hxx> #include <ChartModelHelper.hxx> +#include <ChartTypeManager.hxx> #include <DataSourceHelper.hxx> #include <AxisHelper.hxx> #include <ThreeDHelper.hxx> @@ -724,10 +725,10 @@ void SAL_CALL ChartModel::modified( const lang::EventObject& rEvenObject) DataSourceHelper::createArguments("PivotChart", uno::Sequence<sal_Int32>(), true, true, true); Reference<chart2::data::XDataSource> xDataSource(xDataProvider->createDataSource(aArguments)); - Reference<lang::XMultiServiceFactory> xFactory(getChartTypeManager(), uno::UNO_QUERY); + rtl::Reference< ::chart::ChartTypeManager > xChartTypeManager = getTypeManager(); Reference<chart2::XDiagram> xDiagram(getFirstDiagram()); - DiagramHelper::tTemplateWithServiceName aTemplateAndService = DiagramHelper::getTemplateForDiagram(xDiagram, xFactory); + DiagramHelper::tTemplateWithServiceName aTemplateAndService = DiagramHelper::getTemplateForDiagram(xDiagram, xChartTypeManager); css::uno::Reference<css::chart2::XChartTypeTemplate> xChartTypeTemplate(aTemplateAndService.first); xChartTypeTemplate->changeDiagramData(xDiagram, xDataSource, aArguments); } diff --git a/chart2/source/model/main/Diagram.cxx b/chart2/source/model/main/Diagram.cxx index 7e85f9353395..c813831ef465 100644 --- a/chart2/source/model/main/Diagram.cxx +++ b/chart2/source/model/main/Diagram.cxx @@ -18,6 +18,7 @@ */ #include <Diagram.hxx> +#include <ChartTypeManager.hxx> #include <PropertyHelper.hxx> #include "Wall.hxx" #include <ModifyListenerHelper.hxx> @@ -394,8 +395,7 @@ void SAL_CALL Diagram::setDiagramData( const Reference< chart2::data::XDataSource >& xDataSource, const Sequence< beans::PropertyValue >& aArguments ) { - uno::Reference< lang::XMultiServiceFactory > xChartTypeManager( m_xContext->getServiceManager()->createInstanceWithContext( - "com.sun.star.chart2.ChartTypeManager", m_xContext ), uno::UNO_QUERY ); + rtl::Reference< ::chart::ChartTypeManager > xChartTypeManager = new ::chart::ChartTypeManager( m_xContext ); DiagramHelper::tTemplateWithServiceName aTemplateAndService = DiagramHelper::getTemplateForDiagram( this, xChartTypeManager ); uno::Reference< chart2::XChartTypeTemplate > xTemplate( aTemplateAndService.first ); if( !xTemplate.is() ) |