diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2022-01-19 21:02:51 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-01-22 16:08:05 +0100 |
commit | 8a728ac6cf7d8d032eb93f486618458b7814d42b (patch) | |
tree | d20de8154c46e5208f0405093c0e9b41889b8a23 /chart2/source/model | |
parent | Mysql/MariaDB: Clean mysqlc_keys + remove using (diff) | |
download | core-8a728ac6cf7d8d032eb93f486618458b7814d42b.tar.gz core-8a728ac6cf7d8d032eb93f486618458b7814d42b.zip |
use more concrete types in chart2, ChartType
Change-Id: Ibd299e2e8d82169706d810af98c29d684809c320
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128741
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'chart2/source/model')
33 files changed, 175 insertions, 201 deletions
diff --git a/chart2/source/model/main/BaseCoordinateSystem.cxx b/chart2/source/model/main/BaseCoordinateSystem.cxx index 3729c32bd281..6717c3005047 100644 --- a/chart2/source/model/main/BaseCoordinateSystem.cxx +++ b/chart2/source/model/main/BaseCoordinateSystem.cxx @@ -23,6 +23,7 @@ #include <CloneHelper.hxx> #include <ModifyListenerHelper.hxx> #include "Axis.hxx" +#include <ChartType.hxx> #include <com/sun/star/chart2/AxisType.hpp> #include <com/sun/star/container/NoSuchElementException.hpp> #include <com/sun/star/lang/IndexOutOfBoundsException.hpp> @@ -159,11 +160,13 @@ BaseCoordinateSystem::BaseCoordinateSystem( tAxisVecVecType::size_type nN=0; for( nN=0; nN<m_aAllAxis.size(); nN++ ) CloneHelper::CloneRefVector<chart2::XAxis>( rSource.m_aAllAxis[nN], m_aAllAxis[nN] ); - CloneHelper::CloneRefVector<chart2::XChartType>( rSource.m_aChartTypes, m_aChartTypes ); + for (const auto & rxChartType : rSource.m_aChartTypes) + m_aChartTypes.push_back(rxChartType->cloneChartType()); for( nN=0; nN<m_aAllAxis.size(); nN++ ) ModifyListenerHelper::addListenerToAllElements( m_aAllAxis[nN], m_xModifyEventForwarder ); - ModifyListenerHelper::addListenerToAllElements( m_aChartTypes, m_xModifyEventForwarder ); + for (const auto & rxChartType : m_aChartTypes) + rxChartType->addModifyListener( m_xModifyEventForwarder ); } BaseCoordinateSystem::~BaseCoordinateSystem() @@ -172,7 +175,8 @@ BaseCoordinateSystem::~BaseCoordinateSystem() { for(const tAxisVecVecType::value_type & i : m_aAllAxis) ModifyListenerHelper::removeListenerFromAllElements( i, m_xModifyEventForwarder ); - ModifyListenerHelper::removeListenerFromAllElements( m_aChartTypes, m_xModifyEventForwarder ); + for (const auto & rxChartType : m_aChartTypes) + rxChartType->removeModifyListener( m_xModifyEventForwarder ); } catch( const uno::Exception & ) { @@ -243,19 +247,23 @@ sal_Int32 SAL_CALL BaseCoordinateSystem::getMaximumAxisIndexByDimension( sal_Int // ____ XChartTypeContainer ____ void SAL_CALL BaseCoordinateSystem::addChartType( const Reference< chart2::XChartType >& aChartType ) { - if( std::find( m_aChartTypes.begin(), m_aChartTypes.end(), aChartType ) + auto pChartType = dynamic_cast<ChartType*>(aChartType.get()); + assert(pChartType); + + if( std::find( m_aChartTypes.begin(), m_aChartTypes.end(), pChartType ) != m_aChartTypes.end()) throw lang::IllegalArgumentException("type not found", static_cast<cppu::OWeakObject*>(this), 1); - m_aChartTypes.push_back( aChartType ); + m_aChartTypes.push_back( pChartType ); ModifyListenerHelper::addListener( aChartType, m_xModifyEventForwarder ); fireModifyEvent(); } void SAL_CALL BaseCoordinateSystem::removeChartType( const Reference< chart2::XChartType >& aChartType ) { - std::vector< uno::Reference< chart2::XChartType > >::iterator - aIt( std::find( m_aChartTypes.begin(), m_aChartTypes.end(), aChartType )); + auto pChartType = dynamic_cast<ChartType*>(aChartType.get()); + assert(pChartType); + auto aIt( std::find( m_aChartTypes.begin(), m_aChartTypes.end(), pChartType )); if( aIt == m_aChartTypes.end()) throw container::NoSuchElementException( "The given chart type is no element of the container", @@ -268,14 +276,21 @@ void SAL_CALL BaseCoordinateSystem::removeChartType( const Reference< chart2::XC Sequence< Reference< chart2::XChartType > > SAL_CALL BaseCoordinateSystem::getChartTypes() { - return comphelper::containerToSequence( m_aChartTypes ); + return comphelper::containerToSequence< Reference< chart2::XChartType > >( m_aChartTypes ); } void SAL_CALL BaseCoordinateSystem::setChartTypes( const Sequence< Reference< chart2::XChartType > >& aChartTypes ) { - ModifyListenerHelper::removeListenerFromAllElements( m_aChartTypes, m_xModifyEventForwarder ); - m_aChartTypes = comphelper::sequenceToContainer<std::vector< css::uno::Reference< css::chart2::XChartType > >>( aChartTypes ); - ModifyListenerHelper::addListenerToAllElements( m_aChartTypes, m_xModifyEventForwarder ); + for (auto const & aChartType : m_aChartTypes) + aChartType->removeModifyListener( m_xModifyEventForwarder ); + m_aChartTypes.clear(); + for (auto const & aChartType : aChartTypes) + { + auto pChartType = dynamic_cast<ChartType*>(aChartType.get()); + assert(pChartType); + m_aChartTypes.push_back(pChartType); + pChartType->addModifyListener( m_xModifyEventForwarder ); + } fireModifyEvent(); } diff --git a/chart2/source/model/template/AreaChartType.cxx b/chart2/source/model/template/AreaChartType.cxx index 840bdba036d7..b0581ddc8837 100644 --- a/chart2/source/model/template/AreaChartType.cxx +++ b/chart2/source/model/template/AreaChartType.cxx @@ -44,6 +44,11 @@ uno::Reference< util::XCloneable > SAL_CALL AreaChartType::createClone() return uno::Reference< util::XCloneable >( new AreaChartType( *this )); } +rtl::Reference< ChartType > AreaChartType::cloneChartType() const +{ + return new AreaChartType( *this ); +} + // ____ XChartType ____ OUString SAL_CALL AreaChartType::getChartType() { diff --git a/chart2/source/model/template/AreaChartType.hxx b/chart2/source/model/template/AreaChartType.hxx index fdd2df3a234b..8ca01e1f3afd 100644 --- a/chart2/source/model/template/AreaChartType.hxx +++ b/chart2/source/model/template/AreaChartType.hxx @@ -18,7 +18,7 @@ */ #pragma once -#include "ChartType.hxx" +#include <ChartType.hxx> namespace chart { @@ -36,6 +36,8 @@ public: virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; + virtual rtl::Reference<ChartType> cloneChartType() const override; + private: explicit AreaChartType( const AreaChartType & rOther ); diff --git a/chart2/source/model/template/BarChartType.cxx b/chart2/source/model/template/BarChartType.cxx index d32aa6efeca3..2a94db82ba2a 100644 --- a/chart2/source/model/template/BarChartType.cxx +++ b/chart2/source/model/template/BarChartType.cxx @@ -45,6 +45,11 @@ uno::Reference< util::XCloneable > SAL_CALL BarChartType::createClone() return uno::Reference< util::XCloneable >( new BarChartType( *this )); } +rtl::Reference< ChartType > BarChartType::cloneChartType() const +{ + return new BarChartType( *this ); +} + // ____ XChartType ____ OUString SAL_CALL BarChartType::getChartType() { diff --git a/chart2/source/model/template/BarChartType.hxx b/chart2/source/model/template/BarChartType.hxx index 62ed9aa0c2a2..cceaf05777f0 100644 --- a/chart2/source/model/template/BarChartType.hxx +++ b/chart2/source/model/template/BarChartType.hxx @@ -18,7 +18,7 @@ */ #pragma once -#include "ChartType.hxx" +#include <ChartType.hxx> namespace chart { @@ -36,6 +36,8 @@ public: virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; + virtual rtl::Reference<ChartType> cloneChartType() const override; + private: explicit BarChartType( const BarChartType & rOther ); diff --git a/chart2/source/model/template/BubbleChartType.cxx b/chart2/source/model/template/BubbleChartType.cxx index d0fc66213a97..c2d7d367ea65 100644 --- a/chart2/source/model/template/BubbleChartType.cxx +++ b/chart2/source/model/template/BubbleChartType.cxx @@ -109,6 +109,11 @@ uno::Reference< util::XCloneable > SAL_CALL BubbleChartType::createClone() return uno::Reference< util::XCloneable >( new BubbleChartType( *this )); } +rtl::Reference< ChartType > BubbleChartType::cloneChartType() const +{ + return new BubbleChartType( *this ); +} + // ____ XChartType ____ Reference< chart2::XCoordinateSystem > SAL_CALL BubbleChartType::createCoordinateSystem( ::sal_Int32 DimensionCount ) diff --git a/chart2/source/model/template/BubbleChartType.hxx b/chart2/source/model/template/BubbleChartType.hxx index 4be938b66a88..10e82ae6a662 100644 --- a/chart2/source/model/template/BubbleChartType.hxx +++ b/chart2/source/model/template/BubbleChartType.hxx @@ -18,7 +18,7 @@ */ #pragma once -#include "ChartType.hxx" +#include <ChartType.hxx> namespace chart { @@ -36,6 +36,8 @@ public: virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; + virtual rtl::Reference<ChartType> cloneChartType() const override; + private: explicit BubbleChartType( const BubbleChartType & rOther ); diff --git a/chart2/source/model/template/CandleStickChartType.cxx b/chart2/source/model/template/CandleStickChartType.cxx index 065b8d8ca736..553a137486c9 100644 --- a/chart2/source/model/template/CandleStickChartType.cxx +++ b/chart2/source/model/template/CandleStickChartType.cxx @@ -206,6 +206,11 @@ uno::Reference< util::XCloneable > SAL_CALL CandleStickChartType::createClone() return uno::Reference< util::XCloneable >( new CandleStickChartType( *this )); } +rtl::Reference< ChartType > CandleStickChartType::cloneChartType() const +{ + return new CandleStickChartType( *this ); +} + // ____ XChartType ____ OUString SAL_CALL CandleStickChartType::getChartType() { diff --git a/chart2/source/model/template/CandleStickChartType.hxx b/chart2/source/model/template/CandleStickChartType.hxx index eac57a5b6496..e7610750758f 100644 --- a/chart2/source/model/template/CandleStickChartType.hxx +++ b/chart2/source/model/template/CandleStickChartType.hxx @@ -18,7 +18,7 @@ */ #pragma once -#include "ChartType.hxx" +#include <ChartType.hxx> namespace chart { @@ -38,6 +38,8 @@ public: virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; + virtual rtl::Reference<ChartType> cloneChartType() const override; + private: explicit CandleStickChartType( const CandleStickChartType & rOther ); diff --git a/chart2/source/model/template/ChartType.cxx b/chart2/source/model/template/ChartType.cxx index b93c36806096..aa0a17453f25 100644 --- a/chart2/source/model/template/ChartType.cxx +++ b/chart2/source/model/template/ChartType.cxx @@ -17,7 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include "ChartType.hxx" +#include <ChartType.hxx> #include <CartesianCoordinateSystem.hxx> #include <AxisHelper.hxx> #include <CloneHelper.hxx> diff --git a/chart2/source/model/template/ChartType.hxx b/chart2/source/model/template/ChartType.hxx deleted file mode 100644 index 74e8bcb14300..000000000000 --- a/chart2/source/model/template/ChartType.hxx +++ /dev/null @@ -1,137 +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 <OPropertySet.hxx> -#include <cppuhelper/basemutex.hxx> -#include <cppuhelper/implbase.hxx> -#include <comphelper/uno3.hxx> -#include <com/sun/star/lang/XServiceInfo.hpp> -#include <com/sun/star/chart2/XChartType.hpp> -#include <com/sun/star/chart2/XDataSeriesContainer.hpp> -#include <com/sun/star/util/XCloneable.hpp> -#include <com/sun/star/util/XModifyBroadcaster.hpp> -#include <com/sun/star/util/XModifyListener.hpp> - -#include <vector> - -namespace chart -{ - -namespace impl -{ -typedef ::cppu::WeakImplHelper< - css::lang::XServiceInfo, - css::chart2::XChartType, - css::chart2::XDataSeriesContainer, - css::util::XCloneable, - css::util::XModifyBroadcaster, - css::util::XModifyListener > - ChartType_Base; -} - -class ChartType : - public cppu::BaseMutex, - public impl::ChartType_Base, - public ::property::OPropertySet -{ -public: - explicit ChartType(); - virtual ~ChartType() override; - - /// merge XInterface implementations - DECLARE_XINTERFACE() - -protected: - explicit ChartType( const ChartType & rOther ); - - // ____ XChartType ____ - // still abstract ! implement ! - virtual OUString SAL_CALL getChartType() override = 0; - virtual css::uno::Reference< css::chart2::XCoordinateSystem > SAL_CALL - createCoordinateSystem( ::sal_Int32 DimensionCount ) override; - virtual css::uno::Sequence< OUString > SAL_CALL - getSupportedMandatoryRoles() override; - virtual css::uno::Sequence< OUString > SAL_CALL - getSupportedOptionalRoles() override; - virtual OUString SAL_CALL getRoleOfSequenceForSeriesLabel() override; - virtual css::uno::Sequence< OUString > SAL_CALL - getSupportedPropertyRoles() override; - - // ____ XDataSeriesContainer ____ - virtual void SAL_CALL addDataSeries( - const css::uno::Reference< css::chart2::XDataSeries >& aDataSeries ) override; - virtual void SAL_CALL removeDataSeries( - const css::uno::Reference< css::chart2::XDataSeries >& aDataSeries ) override; - virtual css::uno::Sequence< css::uno::Reference< css::chart2::XDataSeries > > SAL_CALL getDataSeries() override; - virtual void SAL_CALL setDataSeries( - const css::uno::Sequence< css::uno::Reference< css::chart2::XDataSeries > >& aDataSeries ) override; - - // ____ XModifyBroadcaster ____ - virtual void SAL_CALL addModifyListener( - const css::uno::Reference< css::util::XModifyListener >& aListener ) override; - virtual void SAL_CALL removeModifyListener( - const css::uno::Reference< css::util::XModifyListener >& aListener ) override; - - // ____ XModifyListener ____ - virtual void SAL_CALL modified( - const css::lang::EventObject& aEvent ) override; - - // ____ XEventListener (base of XModifyListener) ____ - virtual void SAL_CALL disposing( - const css::lang::EventObject& Source ) override; - - void fireModifyEvent(); - - // ____ OPropertySet ____ - virtual void GetDefaultValue( sal_Int32 nHandle, css::uno::Any& rAny ) const override; - virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override; - - virtual void firePropertyChangeEvent() override; - using OPropertySet::disposing; - - // ____ XPropertySet ____ - virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL - getPropertySetInfo() override; - - /// merge XTypeProvider implementations - DECLARE_XTYPEPROVIDER() - -protected: - css::uno::Reference< css::util::XModifyListener > - const m_xModifyEventForwarder; - -private: - void impl_addDataSeriesWithoutNotification( - const css::uno::Reference< css::chart2::XDataSeries >& aDataSeries ); - -private: - typedef - std::vector< css::uno::Reference< css::chart2::XDataSeries > > tDataSeriesContainerType; - - // --- mutable members: the following members need mutex guard --- - - tDataSeriesContainerType m_aDataSeries; - - bool m_bNotifyChanges; -}; - -} // namespace chart - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/model/template/ChartTypeTemplate.cxx b/chart2/source/model/template/ChartTypeTemplate.cxx index e6eb5e27e069..eaecc8230fa2 100644 --- a/chart2/source/model/template/ChartTypeTemplate.cxx +++ b/chart2/source/model/template/ChartTypeTemplate.cxx @@ -21,6 +21,7 @@ #include "DataInterpreter.hxx" #include <CommonConverters.hxx> #include <ChartTypeHelper.hxx> +#include <ChartType.hxx> #include <AxisHelper.hxx> #include <DiagramHelper.hxx> @@ -161,7 +162,7 @@ uno::Reference< XDiagram > SAL_CALL ChartTypeTemplate::createDiagramByDataSource for( auto const & j : i ) lcl_applyDefaultStyle( j, nCount++, xDia ); - Sequence< Reference< XChartType > > aOldChartTypesSeq; + std::vector< rtl::Reference< ChartType > > aOldChartTypesSeq; FillDiagram( xDia, aData.Series, aData.Categories, aOldChartTypesSeq ); } catch( const uno::Exception & ) @@ -225,8 +226,8 @@ void SAL_CALL ChartTypeTemplate::changeDiagram( const uno::Reference< XDiagram > } // remove charttype groups from all coordinate systems - Sequence< Reference< XChartType > > aOldChartTypesSeq( - DiagramHelper::getChartTypesFromDiagram(xDiagram) ); + std::vector< rtl::Reference< ChartType > > aOldChartTypesSeq = + DiagramHelper::getChartTypesFromDiagram(xDiagram); Reference< XCoordinateSystemContainer > xCoordSysCnt( xDiagram, uno::UNO_QUERY ); OSL_ASSERT( xCoordSysCnt.is()); @@ -286,13 +287,12 @@ void SAL_CALL ChartTypeTemplate::changeDiagramData( // categories DiagramHelper::setCategoriesToDiagram( aData.Categories, xDiagram, true, supportsCategories() ); - Sequence< Reference< XChartType > > aChartTypes( - DiagramHelper::getChartTypesFromDiagram( xDiagram )); - sal_Int32 nMax = std::min( aChartTypes.getLength(), aSeriesSeq.getLength()); + std::vector< rtl::Reference< ChartType > > aChartTypes = + DiagramHelper::getChartTypesFromDiagram( xDiagram ); + sal_Int32 nMax = std::min( static_cast<sal_Int32>(aChartTypes.size()), aSeriesSeq.getLength()); for( i=0; i<nMax; ++i ) { - Reference< XDataSeriesContainer > xDSCnt( aChartTypes[i], uno::UNO_QUERY_THROW ); - xDSCnt->setDataSeries( aSeriesSeq[i] ); + aChartTypes[i]->setDataSeries( aSeriesSeq[i] ); } } catch( const uno::Exception & ) @@ -748,11 +748,19 @@ sal_Int32 ChartTypeTemplate::getAxisCountByDimension( sal_Int32 nDimension ) return (nDimension < getDimension()) ? 1 : 0; } +rtl::Reference< ChartType > ChartTypeTemplate::getChartTypeForNewSeries( const std::vector< rtl::Reference< ChartType > >& aFormerlyUsedChartTypes ) +{ + uno::Reference<XChartType> xChartType = getChartTypeForNewSeries(comphelper::containerToSequence<uno::Reference<XChartType>>(aFormerlyUsedChartTypes)); + auto pChartType = dynamic_cast<ChartType*>(xChartType.get()); + assert(!xChartType || pChartType); + return pChartType; +} + void ChartTypeTemplate::FillDiagram( const Reference< XDiagram >& xDiagram, const Sequence< Sequence< Reference< XDataSeries > > >& aSeriesSeq, const Reference< data::XLabeledDataSequence >& xCategories, - const Sequence< Reference< XChartType > >& aOldChartTypesSeq ) + const std::vector< rtl::Reference< ChartType > >& aOldChartTypesSeq ) { adaptDiagram( xDiagram ); @@ -779,7 +787,7 @@ void ChartTypeTemplate::FillDiagram( void ChartTypeTemplate::createChartTypes( const Sequence< Sequence< Reference< XDataSeries > > > & aSeriesSeq, const Sequence< Reference< XCoordinateSystem > > & rCoordSys, - const Sequence< Reference< XChartType > >& aOldChartTypesSeq ) + const std::vector< rtl::Reference< ChartType > >& aOldChartTypesSeq ) { if( ! rCoordSys.hasElements() || ! rCoordSys[0].is() ) @@ -788,11 +796,11 @@ void ChartTypeTemplate::createChartTypes( try { sal_Int32 nCooSysIdx=0; - Reference< XChartType > xCT; + rtl::Reference< ChartType > xCT; if( !aSeriesSeq.hasElements() ) { // we need a new chart type - xCT.set( getChartTypeForNewSeries( aOldChartTypesSeq )); + xCT = getChartTypeForNewSeries( aOldChartTypesSeq ); Reference< XChartTypeContainer > xCTCnt( rCoordSys[nCooSysIdx], uno::UNO_QUERY_THROW ); xCTCnt->setChartTypes({ xCT }); } @@ -803,7 +811,7 @@ void ChartTypeTemplate::createChartTypes( if( nSeriesIdx == nCooSysIdx ) { // we need a new chart type - xCT.set( getChartTypeForNewSeries( aOldChartTypesSeq )); + xCT = getChartTypeForNewSeries( aOldChartTypesSeq ); Reference< XChartTypeContainer > xCTCnt( rCoordSys[nCooSysIdx], uno::UNO_QUERY_THROW ); Sequence< Reference< XChartType > > aCTSeq( xCTCnt->getChartTypes()); if( aCTSeq.hasElements()) @@ -814,21 +822,19 @@ void ChartTypeTemplate::createChartTypes( else xCTCnt->addChartType( xCT ); - Reference< chart2::XDataSeriesContainer > xDSCnt( xCT, uno::UNO_QUERY_THROW ); - xDSCnt->setDataSeries( aSeriesSeq[nSeriesIdx] ); + xCT->setDataSeries( aSeriesSeq[nSeriesIdx] ); } else { // reuse existing chart type OSL_ASSERT( xCT.is()); - Reference< chart2::XDataSeriesContainer > xDSCnt( xCT, uno::UNO_QUERY_THROW ); - Sequence< Reference< XDataSeries > > aNewSeriesSeq( xDSCnt->getDataSeries()); + Sequence< Reference< XDataSeries > > aNewSeriesSeq( xCT->getDataSeries()); sal_Int32 nNewStartIndex = aNewSeriesSeq.getLength(); aNewSeriesSeq.realloc( nNewStartIndex + aSeriesSeq[nSeriesIdx].getLength() ); std::copy( aSeriesSeq[nSeriesIdx].begin(), aSeriesSeq[nSeriesIdx].end(), aNewSeriesSeq.getArray() + nNewStartIndex ); - xDSCnt->setDataSeries( aNewSeriesSeq ); + xCT->setDataSeries( aNewSeriesSeq ); } // spread the series over the available coordinate systems @@ -867,6 +873,30 @@ void ChartTypeTemplate::copyPropertiesFromOldToNewCoordinateSystem( comphelper::copyProperties( xSource, xDestination ); } +void ChartTypeTemplate::copyPropertiesFromOldToNewCoordinateSystem( + const std::vector< rtl::Reference< ChartType > > & rOldChartTypesSeq, + const Reference< XChartType > & xNewChartType ) +{ + Reference< beans::XPropertySet > xDestination( xNewChartType, uno::UNO_QUERY ); + if( !xDestination.is() ) + return; + + OUString aNewChartType( xNewChartType->getChartType() ); + + Reference< beans::XPropertySet > xSource; + for( rtl::Reference< ChartType > const & xOldType : rOldChartTypesSeq ) + { + if( xOldType.is() && xOldType->getChartType() == aNewChartType ) + { + xSource = xOldType; + if( xSource.is() ) + break; + } + } + if( xSource.is() ) + comphelper::copyProperties( xSource, xDestination ); +} + } // namespace chart /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/model/template/ColumnChartType.cxx b/chart2/source/model/template/ColumnChartType.cxx index 3553e289985e..50fdca0e1dbc 100644 --- a/chart2/source/model/template/ColumnChartType.cxx +++ b/chart2/source/model/template/ColumnChartType.cxx @@ -139,6 +139,11 @@ uno::Reference< util::XCloneable > SAL_CALL ColumnChartType::createClone() return uno::Reference< util::XCloneable >( new ColumnChartType( *this )); } +rtl::Reference< ChartType > ColumnChartType::cloneChartType() const +{ + return new ColumnChartType( *this ); +} + // ____ XChartType ____ OUString SAL_CALL ColumnChartType::getChartType() { diff --git a/chart2/source/model/template/ColumnChartType.hxx b/chart2/source/model/template/ColumnChartType.hxx index d304092cbfc0..2c6b3d762321 100644 --- a/chart2/source/model/template/ColumnChartType.hxx +++ b/chart2/source/model/template/ColumnChartType.hxx @@ -18,7 +18,7 @@ */ #pragma once -#include "ChartType.hxx" +#include <ChartType.hxx> namespace chart { @@ -36,6 +36,8 @@ public: virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; + virtual rtl::Reference<ChartType> cloneChartType() const override; + private: explicit ColumnChartType( const ColumnChartType & rOther ); diff --git a/chart2/source/model/template/ColumnLineChartTypeTemplate.cxx b/chart2/source/model/template/ColumnLineChartTypeTemplate.cxx index fad59386b2b3..e0ab9a713903 100644 --- a/chart2/source/model/template/ColumnLineChartTypeTemplate.cxx +++ b/chart2/source/model/template/ColumnLineChartTypeTemplate.cxx @@ -160,7 +160,7 @@ uno::Reference< beans::XPropertySetInfo > SAL_CALL ColumnLineChartTypeTemplate:: void ColumnLineChartTypeTemplate::createChartTypes( const Sequence< Sequence< Reference< XDataSeries > > > & aSeriesSeq, const Sequence< Reference< XCoordinateSystem > > & rCoordSys, - const Sequence< Reference< XChartType > >& aOldChartTypesSeq ) + const std::vector< rtl::Reference< ChartType > >& aOldChartTypesSeq ) { if( ! rCoordSys.hasElements() || ! rCoordSys[0].is() ) diff --git a/chart2/source/model/template/ColumnLineChartTypeTemplate.hxx b/chart2/source/model/template/ColumnLineChartTypeTemplate.hxx index d112b81f58ad..8bb28db244de 100644 --- a/chart2/source/model/template/ColumnLineChartTypeTemplate.hxx +++ b/chart2/source/model/template/ColumnLineChartTypeTemplate.hxx @@ -78,9 +78,7 @@ protected: const css::uno::Sequence< css::uno::Reference< css::chart2::XCoordinateSystem > > & rCoordSys, - const css::uno::Sequence< - css::uno::Reference< - css::chart2::XChartType > > & aOldChartTypesSeq + const std::vector< rtl::Reference< ChartType > > & aOldChartTypesSeq ) override; virtual css::uno::Reference< css::chart2::XChartType > diff --git a/chart2/source/model/template/FilledNetChartType.cxx b/chart2/source/model/template/FilledNetChartType.cxx index 3179317daee5..6ec39d983516 100644 --- a/chart2/source/model/template/FilledNetChartType.cxx +++ b/chart2/source/model/template/FilledNetChartType.cxx @@ -48,6 +48,11 @@ uno::Reference< util::XCloneable > SAL_CALL FilledNetChartType::createClone() return uno::Reference< util::XCloneable >( new FilledNetChartType( *this )); } +rtl::Reference< ChartType > FilledNetChartType::cloneChartType() const +{ + return new FilledNetChartType( *this ); +} + // ____ XChartType ____ OUString SAL_CALL FilledNetChartType::getChartType() { diff --git a/chart2/source/model/template/FilledNetChartType.hxx b/chart2/source/model/template/FilledNetChartType.hxx index 0ca41b60ba55..b2d239aeca36 100644 --- a/chart2/source/model/template/FilledNetChartType.hxx +++ b/chart2/source/model/template/FilledNetChartType.hxx @@ -32,6 +32,8 @@ public: virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override; virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override; + virtual rtl::Reference<ChartType> cloneChartType() const override; + private: explicit FilledNetChartType(const FilledNetChartType& rOther); diff --git a/chart2/source/model/template/LineChartType.cxx b/chart2/source/model/template/LineChartType.cxx index f0d595f27102..8edccdfb858e 100644 --- a/chart2/source/model/template/LineChartType.cxx +++ b/chart2/source/model/template/LineChartType.cxx @@ -151,6 +151,11 @@ uno::Reference< util::XCloneable > SAL_CALL LineChartType::createClone() return uno::Reference< util::XCloneable >( new LineChartType( *this )); } +rtl::Reference< ChartType > LineChartType::cloneChartType() const +{ + return new LineChartType( *this ); +} + // ____ XChartType ____ OUString SAL_CALL LineChartType::getChartType() { diff --git a/chart2/source/model/template/LineChartType.hxx b/chart2/source/model/template/LineChartType.hxx index a655670d852e..4c44cca9c349 100644 --- a/chart2/source/model/template/LineChartType.hxx +++ b/chart2/source/model/template/LineChartType.hxx @@ -18,7 +18,7 @@ */ #pragma once -#include "ChartType.hxx" +#include <ChartType.hxx> namespace chart { @@ -36,6 +36,8 @@ public: virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; + virtual rtl::Reference<ChartType> cloneChartType() const override; + private: explicit LineChartType( const LineChartType & rOther ); diff --git a/chart2/source/model/template/LineChartTypeTemplate.cxx b/chart2/source/model/template/LineChartTypeTemplate.cxx index bbde1bebc3f1..dc243571393f 100644 --- a/chart2/source/model/template/LineChartTypeTemplate.cxx +++ b/chart2/source/model/template/LineChartTypeTemplate.cxx @@ -22,6 +22,7 @@ #include <servicenames_charttypes.hxx> #include <DataSeriesHelper.hxx> #include <PropertyHelper.hxx> +#include <ChartType.hxx> #include <unonames.hxx> #include <com/sun/star/chart2/CurveStyle.hpp> @@ -267,12 +268,11 @@ sal_Bool SAL_CALL LineChartTypeTemplate::matchesTemplate( { try { - uno::Reference< beans::XPropertySet > xChartTypeProp( - DiagramHelper::getChartTypeByIndex( xDiagram, 0 ), - uno::UNO_QUERY_THROW ); - setFastPropertyValue_NoBroadcast( PROP_LINECHARTTYPE_TEMPLATE_CURVE_STYLE, xChartTypeProp->getPropertyValue(CHART_UNONAME_CURVE_STYLE) ); - setFastPropertyValue_NoBroadcast( PROP_LINECHARTTYPE_TEMPLATE_CURVE_RESOLUTION, xChartTypeProp->getPropertyValue(CHART_UNONAME_CURVE_RESOLUTION) ); - setFastPropertyValue_NoBroadcast( PROP_LINECHARTTYPE_TEMPLATE_SPLINE_ORDER, xChartTypeProp->getPropertyValue(CHART_UNONAME_SPLINE_ORDER) ); + rtl::Reference< ChartType > xChartType = + DiagramHelper::getChartTypeByIndex( xDiagram, 0 ); + setFastPropertyValue_NoBroadcast( PROP_LINECHARTTYPE_TEMPLATE_CURVE_STYLE, xChartType->getPropertyValue(CHART_UNONAME_CURVE_STYLE) ); + setFastPropertyValue_NoBroadcast( PROP_LINECHARTTYPE_TEMPLATE_CURVE_RESOLUTION, xChartType->getPropertyValue(CHART_UNONAME_CURVE_RESOLUTION) ); + setFastPropertyValue_NoBroadcast( PROP_LINECHARTTYPE_TEMPLATE_SPLINE_ORDER, xChartType->getPropertyValue(CHART_UNONAME_SPLINE_ORDER) ); } catch( const uno::Exception & ) { diff --git a/chart2/source/model/template/NetChartType.cxx b/chart2/source/model/template/NetChartType.cxx index 8aecbec7b60c..971befddfca9 100644 --- a/chart2/source/model/template/NetChartType.cxx +++ b/chart2/source/model/template/NetChartType.cxx @@ -147,6 +147,11 @@ uno::Reference< util::XCloneable > SAL_CALL NetChartType::createClone() return uno::Reference< util::XCloneable >( new NetChartType( *this )); } +rtl::Reference< ChartType > NetChartType::cloneChartType() const +{ + return new NetChartType( *this ); +} + // ____ XChartType ____ OUString SAL_CALL NetChartType::getChartType() { diff --git a/chart2/source/model/template/NetChartType.hxx b/chart2/source/model/template/NetChartType.hxx index 7f1c16d60dd8..d9875be541a3 100644 --- a/chart2/source/model/template/NetChartType.hxx +++ b/chart2/source/model/template/NetChartType.hxx @@ -18,7 +18,7 @@ */ #pragma once -#include "ChartType.hxx" +#include <ChartType.hxx> namespace chart { @@ -59,6 +59,8 @@ public: virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; + virtual rtl::Reference<ChartType> cloneChartType() const override; + private: explicit NetChartType( const NetChartType & rOther ); diff --git a/chart2/source/model/template/NetChartTypeTemplate.cxx b/chart2/source/model/template/NetChartTypeTemplate.cxx index fed499cb3970..880b6841a7d5 100644 --- a/chart2/source/model/template/NetChartTypeTemplate.cxx +++ b/chart2/source/model/template/NetChartTypeTemplate.cxx @@ -21,6 +21,7 @@ #include <DiagramHelper.hxx> #include <servicenames_charttypes.hxx> #include <DataSeriesHelper.hxx> +#include <ChartType.hxx> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/chart2/SymbolStyle.hpp> #include <com/sun/star/chart2/Symbol.hpp> @@ -87,8 +88,8 @@ sal_Bool SAL_CALL NetChartTypeTemplate::matchesTemplate( { bool bResult = ChartTypeTemplate::matchesTemplate( xDiagram, bAdaptProperties ); - uno::Reference< beans::XPropertySet > xChartTypeProp( - DiagramHelper::getChartTypeByIndex( xDiagram, 0 ), uno::UNO_QUERY_THROW ); + rtl::Reference< ChartType > xChartType = + DiagramHelper::getChartTypeByIndex( xDiagram, 0 ); if( bResult ) { diff --git a/chart2/source/model/template/PieChartType.cxx b/chart2/source/model/template/PieChartType.cxx index 777fb55c316d..1208283fcc1e 100644 --- a/chart2/source/model/template/PieChartType.cxx +++ b/chart2/source/model/template/PieChartType.cxx @@ -139,6 +139,11 @@ uno::Reference< util::XCloneable > SAL_CALL PieChartType::createClone() return uno::Reference< util::XCloneable >( new PieChartType( *this )); } +rtl::Reference< ChartType > PieChartType::cloneChartType() const +{ + return new PieChartType( *this ); +} + // ____ XChartType ____ OUString SAL_CALL PieChartType::getChartType() { diff --git a/chart2/source/model/template/PieChartType.hxx b/chart2/source/model/template/PieChartType.hxx index c3164d4308a6..0ecc0160393c 100644 --- a/chart2/source/model/template/PieChartType.hxx +++ b/chart2/source/model/template/PieChartType.hxx @@ -18,7 +18,7 @@ */ #pragma once -#include "ChartType.hxx" +#include <ChartType.hxx> namespace chart { @@ -36,6 +36,8 @@ public: virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; + virtual rtl::Reference<ChartType> cloneChartType() const override; + private: explicit PieChartType( const PieChartType & rOther ); diff --git a/chart2/source/model/template/PieChartTypeTemplate.cxx b/chart2/source/model/template/PieChartTypeTemplate.cxx index 218ee48ff520..6d87cee6628b 100644 --- a/chart2/source/model/template/PieChartTypeTemplate.cxx +++ b/chart2/source/model/template/PieChartTypeTemplate.cxx @@ -19,6 +19,7 @@ #include "PieChartTypeTemplate.hxx" #include <CommonConverters.hxx> +#include <ChartType.hxx> #include <DiagramHelper.hxx> #include <servicenames_charttypes.hxx> #include <DataSeriesHelper.hxx> @@ -274,7 +275,7 @@ void PieChartTypeTemplate::adaptScales( void PieChartTypeTemplate::createChartTypes( const Sequence< Sequence< Reference< chart2::XDataSeries > > > & aSeriesSeq, const Sequence< Reference< chart2::XCoordinateSystem > > & rCoordSys, - const Sequence< Reference< chart2::XChartType > >& /* aOldChartTypesSeq */ ) + const std::vector< rtl::Reference< ChartType > >& /* aOldChartTypesSeq */ ) { if( ! rCoordSys.hasElements() || ! rCoordSys[0].is() ) @@ -391,8 +392,8 @@ sal_Bool SAL_CALL PieChartTypeTemplate::matchesTemplate( //check UseRings if( bResult ) { - uno::Reference< beans::XPropertySet > xCTProp( - DiagramHelper::getChartTypeByIndex( xDiagram, 0 ), uno::UNO_QUERY_THROW ); + rtl::Reference< ChartType > xCTProp = + DiagramHelper::getChartTypeByIndex( xDiagram, 0 ); bool bUseRings = false; if( xCTProp->getPropertyValue( "UseRings") >>= bUseRings ) { diff --git a/chart2/source/model/template/PieChartTypeTemplate.hxx b/chart2/source/model/template/PieChartTypeTemplate.hxx index c749be57447a..b4a010b17647 100644 --- a/chart2/source/model/template/PieChartTypeTemplate.hxx +++ b/chart2/source/model/template/PieChartTypeTemplate.hxx @@ -94,9 +94,7 @@ protected: const css::uno::Sequence< css::uno::Reference< css::chart2::XCoordinateSystem > > & rCoordSys, - const css::uno::Sequence< - css::uno::Reference< - css::chart2::XChartType > > & aOldChartTypesSeq + const std::vector< rtl::Reference< ChartType > > & aOldChartTypesSeq ) override; virtual css::uno::Reference< css::chart2::XChartType > diff --git a/chart2/source/model/template/ScatterChartType.cxx b/chart2/source/model/template/ScatterChartType.cxx index 4693df06d674..63d46fed23b9 100644 --- a/chart2/source/model/template/ScatterChartType.cxx +++ b/chart2/source/model/template/ScatterChartType.cxx @@ -154,6 +154,11 @@ uno::Reference< util::XCloneable > SAL_CALL ScatterChartType::createClone() return uno::Reference< util::XCloneable >( new ScatterChartType( *this )); } +rtl::Reference< ChartType > ScatterChartType::cloneChartType() const +{ + return new ScatterChartType( *this ); +} + // ____ XChartType ____ Reference< chart2::XCoordinateSystem > SAL_CALL ScatterChartType::createCoordinateSystem( ::sal_Int32 DimensionCount ) diff --git a/chart2/source/model/template/ScatterChartType.hxx b/chart2/source/model/template/ScatterChartType.hxx index da14efb0df3f..03750e5d8f2a 100644 --- a/chart2/source/model/template/ScatterChartType.hxx +++ b/chart2/source/model/template/ScatterChartType.hxx @@ -18,7 +18,7 @@ */ #pragma once -#include "ChartType.hxx" +#include <ChartType.hxx> namespace chart { @@ -36,6 +36,8 @@ public: virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; + virtual rtl::Reference<ChartType> cloneChartType() const override; + private: explicit ScatterChartType( const ScatterChartType & rOther ); diff --git a/chart2/source/model/template/ScatterChartTypeTemplate.cxx b/chart2/source/model/template/ScatterChartTypeTemplate.cxx index cf22e22c6d55..c6caa7aa4724 100644 --- a/chart2/source/model/template/ScatterChartTypeTemplate.cxx +++ b/chart2/source/model/template/ScatterChartTypeTemplate.cxx @@ -19,6 +19,7 @@ #include "ScatterChartTypeTemplate.hxx" #include "XYDataInterpreter.hxx" +#include <ChartType.hxx> #include <DiagramHelper.hxx> #include <servicenames_charttypes.hxx> #include <DataSeriesHelper.hxx> @@ -297,9 +298,8 @@ sal_Bool SAL_CALL ScatterChartTypeTemplate::matchesTemplate( { try { - uno::Reference< beans::XPropertySet > xChartTypeProp( - DiagramHelper::getChartTypeByIndex( xDiagram, 0 ), - uno::UNO_QUERY_THROW ); + rtl::Reference< ChartType > xChartTypeProp = + DiagramHelper::getChartTypeByIndex( xDiagram, 0 ); setFastPropertyValue_NoBroadcast( PROP_SCATTERCHARTTYPE_TEMPLATE_CURVE_STYLE, xChartTypeProp->getPropertyValue(CHART_UNONAME_CURVE_STYLE) ); setFastPropertyValue_NoBroadcast( PROP_SCATTERCHARTTYPE_TEMPLATE_CURVE_RESOLUTION, xChartTypeProp->getPropertyValue(CHART_UNONAME_CURVE_RESOLUTION) ); setFastPropertyValue_NoBroadcast( PROP_SCATTERCHARTTYPE_TEMPLATE_SPLINE_ORDER, xChartTypeProp->getPropertyValue(CHART_UNONAME_SPLINE_ORDER) ); diff --git a/chart2/source/model/template/StockChartTypeTemplate.cxx b/chart2/source/model/template/StockChartTypeTemplate.cxx index 3cd5ec0e5c92..c1ee6d341d60 100644 --- a/chart2/source/model/template/StockChartTypeTemplate.cxx +++ b/chart2/source/model/template/StockChartTypeTemplate.cxx @@ -281,7 +281,7 @@ Reference< XChartType > StockChartTypeTemplate::getChartTypeForIndex( sal_Int32 void StockChartTypeTemplate::createChartTypes( const Sequence< Sequence< Reference< XDataSeries > > > & aSeriesSeq, const Sequence< Reference< XCoordinateSystem > > & rCoordSys, - const Sequence< Reference< XChartType > >& /* aOldChartTypesSeq */ ) + const std::vector< rtl::Reference< ChartType > >& /* aOldChartTypesSeq */ ) { if( !rCoordSys.hasElements() ) return; diff --git a/chart2/source/model/template/StockChartTypeTemplate.hxx b/chart2/source/model/template/StockChartTypeTemplate.hxx index 99eb7da8c8cf..a16fd26efbe5 100644 --- a/chart2/source/model/template/StockChartTypeTemplate.hxx +++ b/chart2/source/model/template/StockChartTypeTemplate.hxx @@ -98,9 +98,7 @@ protected: const css::uno::Sequence< css::uno::Reference< css::chart2::XCoordinateSystem > > & rCoordSys, - const css::uno::Sequence< - css::uno::Reference< - css::chart2::XChartType > > & aOldChartTypesSeq + const std::vector< rtl::Reference< ChartType > > & aOldChartTypesSeq ) override; virtual css::uno::Reference< css::chart2::XChartType > |