diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2023-03-28 15:00:11 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2023-03-29 08:44:44 +0000 |
commit | 5e482317a0b140b11220554753e30ccfd53385ee (patch) | |
tree | 3e6992c055cbd8d211990f5d88e4b887d4e96f06 /chart2/source/model/main | |
parent | cfe339efd5f306452bc78ae4121867dc9b07b95a (diff) |
use more concrete types in chart2
Change-Id: Ifd3bce5fc22371559203da673ca98913bc742c21
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149674
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'chart2/source/model/main')
-rw-r--r-- | chart2/source/model/main/Axis.cxx | 68 | ||||
-rw-r--r-- | chart2/source/model/main/GridProperties.cxx | 2 | ||||
-rw-r--r-- | chart2/source/model/main/GridProperties.hxx | 98 |
3 files changed, 33 insertions, 135 deletions
diff --git a/chart2/source/model/main/Axis.cxx b/chart2/source/model/main/Axis.cxx index 923eaf0416d0..6ee948968369 100644 --- a/chart2/source/model/main/Axis.cxx +++ b/chart2/source/model/main/Axis.cxx @@ -18,7 +18,7 @@ */ #include <Axis.hxx> -#include "GridProperties.hxx" +#include <GridProperties.hxx> #include <CharacterProperties.hxx> #include <LinePropertiesHelper.hxx> #include <UserDefinedProperties.hxx> @@ -258,31 +258,16 @@ const ::chart::tPropertyValueMap & StaticAxisDefaults() return aPropHelper; }; -typedef uno::Reference< beans::XPropertySet > lcl_tSubGridType; - -void lcl_CloneSubGrids( - const uno::Sequence< lcl_tSubGridType > & rSource, uno::Sequence< lcl_tSubGridType > & rDestination ) +std::vector< rtl::Reference< ::chart::GridProperties > > lcl_CloneSubGrids( + const std::vector< rtl::Reference< ::chart::GridProperties > > & rSource ) { - rDestination.realloc( rSource.getLength()); - lcl_tSubGridType * pDestBegin = rDestination.getArray(); - lcl_tSubGridType * pDestEnd = pDestBegin + rDestination.getLength(); - lcl_tSubGridType * pDestIt = pDestBegin; - - for( Reference< beans::XPropertySet > const & i : rSource ) + std::vector< rtl::Reference< ::chart::GridProperties > > aDestination; + aDestination.reserve( rSource.size()); + for( rtl::Reference< ::chart::GridProperties > const & i : rSource ) { - Reference< beans::XPropertySet > xSubGrid( i ); - if( xSubGrid.is()) - { - Reference< util::XCloneable > xCloneable( xSubGrid, uno::UNO_QUERY ); - if( xCloneable.is()) - xSubGrid.set( xCloneable->createClone(), uno::UNO_QUERY ); - } - - (*pDestIt) = xSubGrid; - OSL_ASSERT( pDestIt != pDestEnd ); - ++pDestIt; + aDestination.push_back(new ::chart::GridProperties(*i)); } - OSL_ASSERT( pDestIt == pDestEnd ); + return aDestination; } } // anonymous namespace @@ -314,16 +299,17 @@ Axis::Axis( const Axis & rOther ) : m_xModifyEventForwarder( new ModifyEventForwarder() ), m_aScaleData( rOther.m_aScaleData ) { - m_xGrid.set( CloneHelper::CreateRefClone< beans::XPropertySet >()( rOther.m_xGrid )); + if (rOther.m_xGrid) + m_xGrid = new ::chart::GridProperties(*rOther.m_xGrid); if( m_xGrid.is()) ModifyListenerHelper::addListener( m_xGrid, m_xModifyEventForwarder ); if( m_aScaleData.Categories.is()) ModifyListenerHelper::addListener( m_aScaleData.Categories, m_xModifyEventForwarder ); - if( rOther.m_aSubGridProperties.hasElements() ) - lcl_CloneSubGrids( rOther.m_aSubGridProperties, m_aSubGridProperties ); - ModifyListenerHelper::addListenerToAllSequenceElements( m_aSubGridProperties, m_xModifyEventForwarder ); + if( !rOther.m_aSubGridProperties.empty() ) + m_aSubGridProperties = lcl_CloneSubGrids( rOther.m_aSubGridProperties ); + ModifyListenerHelper::addListenerToAllElements( m_aSubGridProperties, m_xModifyEventForwarder ); if ( rOther.m_xTitle ) m_xTitle = new Title( *rOther.m_xTitle ); @@ -343,7 +329,7 @@ Axis::~Axis() try { ModifyListenerHelper::removeListener( m_xGrid, m_xModifyEventForwarder ); - ModifyListenerHelper::removeListenerFromAllSequenceElements( m_aSubGridProperties, m_xModifyEventForwarder ); + ModifyListenerHelper::removeListenerFromAllElements( m_aSubGridProperties, m_xModifyEventForwarder ); ModifyListenerHelper::removeListener( m_xTitle, m_xModifyEventForwarder ); if( m_aScaleData.Categories.is()) { @@ -356,7 +342,7 @@ Axis::~Axis() DBG_UNHANDLED_EXCEPTION("chart2"); } - m_aSubGridProperties.realloc(0); + m_aSubGridProperties.clear(); m_xGrid = nullptr; m_xTitle = nullptr; } @@ -365,32 +351,31 @@ void Axis::AllocateSubGrids() { Reference< util::XModifyListener > xModifyEventForwarder; Reference< lang::XEventListener > xEventListener; - std::vector< Reference< beans::XPropertySet > > aOldBroadcasters; - std::vector< Reference< beans::XPropertySet > > aNewBroadcasters; + std::vector< rtl::Reference< GridProperties > > aOldBroadcasters; + std::vector< rtl::Reference< GridProperties > > aNewBroadcasters; { MutexGuard aGuard( m_aMutex ); xModifyEventForwarder = m_xModifyEventForwarder; xEventListener = this; sal_Int32 nNewSubIncCount = m_aScaleData.IncrementData.SubIncrements.getLength(); - sal_Int32 nOldSubIncCount = m_aSubGridProperties.getLength(); + sal_Int32 nOldSubIncCount = m_aSubGridProperties.size(); if( nOldSubIncCount > nNewSubIncCount ) { // remove superfluous entries for( sal_Int32 i = nNewSubIncCount; i < nOldSubIncCount; ++i ) aOldBroadcasters.push_back( m_aSubGridProperties[ i ] ); - m_aSubGridProperties.realloc( nNewSubIncCount ); + m_aSubGridProperties.resize( nNewSubIncCount ); } else if( nOldSubIncCount < nNewSubIncCount ) { - m_aSubGridProperties.realloc( nNewSubIncCount ); - auto pSubGridProperties = m_aSubGridProperties.getArray(); + m_aSubGridProperties.resize( nNewSubIncCount ); // allocate new entries for( sal_Int32 i = nOldSubIncCount; i < nNewSubIncCount; ++i ) { - pSubGridProperties[ i ] = new GridProperties(); + m_aSubGridProperties[ i ] = new GridProperties(); LinePropertiesHelper::SetLineInvisible( m_aSubGridProperties[ i ] ); LinePropertiesHelper::SetLineColor( m_aSubGridProperties[ i ], static_cast<sal_Int32>(0xdddddd) ); //gray2 aNewBroadcasters.push_back( m_aSubGridProperties[ i ] ); @@ -445,9 +430,20 @@ Reference< beans::XPropertySet > SAL_CALL Axis::getGridProperties() MutexGuard aGuard( m_aMutex ); return m_xGrid; } +rtl::Reference< ::chart::GridProperties > Axis::getGridProperties2() +{ + MutexGuard aGuard( m_aMutex ); + return m_xGrid; +} Sequence< Reference< beans::XPropertySet > > SAL_CALL Axis::getSubGridProperties() { MutexGuard aGuard( m_aMutex ); + return comphelper::containerToSequence<Reference< beans::XPropertySet >>(m_aSubGridProperties); +} + +std::vector< rtl::Reference< GridProperties > > Axis::getSubGridProperties2() +{ + MutexGuard aGuard( m_aMutex ); return m_aSubGridProperties; } diff --git a/chart2/source/model/main/GridProperties.cxx b/chart2/source/model/main/GridProperties.cxx index f2ebcb725edb..a495f631f7e2 100644 --- a/chart2/source/model/main/GridProperties.cxx +++ b/chart2/source/model/main/GridProperties.cxx @@ -17,7 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include "GridProperties.hxx" +#include <GridProperties.hxx> #include <LinePropertiesHelper.hxx> #include <UserDefinedProperties.hxx> #include <PropertyHelper.hxx> diff --git a/chart2/source/model/main/GridProperties.hxx b/chart2/source/model/main/GridProperties.hxx deleted file mode 100644 index 930ea9c90674..000000000000 --- a/chart2/source/model/main/GridProperties.hxx +++ /dev/null @@ -1,98 +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 <comphelper/uno3.hxx> -#include <com/sun/star/lang/XServiceInfo.hpp> -#include <com/sun/star/util/XCloneable.hpp> -#include <ModifyListenerHelper.hxx> - -#include <OPropertySet.hxx> - -namespace chart -{ - -namespace impl -{ -typedef ::cppu::WeakImplHelper< - css::lang::XServiceInfo, - css::util::XCloneable, - css::util::XModifyBroadcaster, - css::util::XModifyListener > - GridProperties_Base; -} - -class GridProperties final : - public impl::GridProperties_Base, - public ::property::OPropertySet -{ -public: - explicit GridProperties(); - virtual ~GridProperties() override; - - /// XServiceInfo declarations - 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; - - /// merge XInterface implementations - DECLARE_XINTERFACE() - /// merge XTypeProvider implementations - DECLARE_XTYPEPROVIDER() - -private: - explicit GridProperties( const GridProperties & rOther ); - - // ____ OPropertySet ____ - virtual void GetDefaultValue( sal_Int32 nHandle, css::uno::Any& rAny ) const override; - - virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override; - - // ____ XPropertySet ____ - virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL - getPropertySetInfo() override; - - // ____ XCloneable ____ - virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone() 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; - - // ____ OPropertySet ____ - virtual void firePropertyChangeEvent() override; - using OPropertySet::disposing; - - rtl::Reference<ModifyEventForwarder> m_xModifyEventForwarder; -}; - -} // namespace chart - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |