diff options
Diffstat (limited to 'chart2/source/controller/chartapiwrapper')
44 files changed, 918 insertions, 1035 deletions
diff --git a/chart2/source/controller/chartapiwrapper/AreaWrapper.cxx b/chart2/source/controller/chartapiwrapper/AreaWrapper.cxx index 7cbef7d67e2c..995a0f92cf4d 100644 --- a/chart2/source/controller/chartapiwrapper/AreaWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/AreaWrapper.cxx @@ -20,7 +20,6 @@ #include "AreaWrapper.hxx" #include "Chart2ModelContact.hxx" #include <WrappedDirectStateProperty.hxx> -#include <com/sun/star/chart2/XChartDocument.hpp> #include <comphelper/sequence.hxx> #include <cppuhelper/supportsservice.hxx> @@ -29,51 +28,18 @@ #include <UserDefinedProperties.hxx> #include <algorithm> +#include <utility> using namespace ::com::sun::star; using ::com::sun::star::beans::Property; -using ::osl::MutexGuard; using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::Sequence; -namespace -{ - -struct StaticAreaWrapperPropertyArray_Initializer -{ - Sequence< Property >* operator()() - { - static Sequence< Property > aPropSeq( lcl_GetPropertySequence() ); - return &aPropSeq; - } - -private: - static Sequence< Property > lcl_GetPropertySequence() - { - std::vector< css::beans::Property > aProperties; - ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties ); - ::chart::FillProperties::AddPropertiesToVector( aProperties ); - ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); - - std::sort( aProperties.begin(), aProperties.end(), - ::chart::PropertyNameLess() ); - - return comphelper::containerToSequence( aProperties ); - } -}; - -struct StaticAreaWrapperPropertyArray : public rtl::StaticAggregate< Sequence< Property >, StaticAreaWrapperPropertyArray_Initializer > -{ -}; - -} // anonymous namespace - namespace chart::wrapper { -AreaWrapper::AreaWrapper(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact) - : m_spChart2ModelContact(spChart2ModelContact) - , m_aEventListenerContainer(m_aMutex) +AreaWrapper::AreaWrapper(std::shared_ptr<Chart2ModelContact> spChart2ModelContact) + : m_spChart2ModelContact(std::move(spChart2ModelContact)) { } @@ -110,23 +76,25 @@ OUString SAL_CALL AreaWrapper::getShapeType() // ____ XComponent ____ void SAL_CALL AreaWrapper::dispose() { + std::unique_lock g(m_aMutex); Reference< uno::XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) ); - m_aEventListenerContainer.disposeAndClear( lang::EventObject( xSource ) ); + m_aEventListenerContainer.disposeAndClear( g, lang::EventObject( xSource ) ); - MutexGuard aGuard( m_aMutex); clearWrappedPropertySet(); } void SAL_CALL AreaWrapper::addEventListener( const Reference< lang::XEventListener >& xListener ) { - m_aEventListenerContainer.addInterface( xListener ); + std::unique_lock g(m_aMutex); + m_aEventListenerContainer.addInterface( g, xListener ); } void SAL_CALL AreaWrapper::removeEventListener( const Reference< lang::XEventListener >& aListener ) { - m_aEventListenerContainer.removeInterface( aListener ); + std::unique_lock g(m_aMutex); + m_aEventListenerContainer.removeInterface( g, aListener ); } // WrappedPropertySet @@ -141,7 +109,19 @@ Reference< beans::XPropertySet > AreaWrapper::getInnerPropertySet() const Sequence< beans::Property >& AreaWrapper::getPropertySequence() { - return *StaticAreaWrapperPropertyArray::get(); + static Sequence< Property > aPropSeq = []() + { + std::vector< css::beans::Property > aProperties; + ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties ); + ::chart::FillProperties::AddPropertiesToVector( aProperties ); + ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); + + std::sort( aProperties.begin(), aProperties.end(), + ::chart::PropertyNameLess() ); + + return comphelper::containerToSequence( aProperties ); + }(); + return aPropSeq; } std::vector< std::unique_ptr<WrappedProperty> > AreaWrapper::createWrappedProperties() diff --git a/chart2/source/controller/chartapiwrapper/AreaWrapper.hxx b/chart2/source/controller/chartapiwrapper/AreaWrapper.hxx index 3de57f421313..c150d5bbfcef 100644 --- a/chart2/source/controller/chartapiwrapper/AreaWrapper.hxx +++ b/chart2/source/controller/chartapiwrapper/AreaWrapper.hxx @@ -20,7 +20,7 @@ #include <WrappedPropertySet.hxx> #include <cppuhelper/implbase.hxx> -#include <comphelper/interfacecontainer3.hxx> +#include <comphelper/interfacecontainer4.hxx> #include <com/sun/star/drawing/XShape.hpp> #include <com/sun/star/lang/XComponent.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> @@ -40,7 +40,7 @@ class AreaWrapper : public ::cppu::ImplInheritanceHelper< > { public: - explicit AreaWrapper(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact); + explicit AreaWrapper(std::shared_ptr<Chart2ModelContact> spChart2ModelContact); virtual ~AreaWrapper() override; /// XServiceInfo declarations @@ -72,7 +72,7 @@ protected: private: std::shared_ptr< Chart2ModelContact > m_spChart2ModelContact; - ::comphelper::OInterfaceContainerHelper3<css::lang::XEventListener> m_aEventListenerContainer; + ::comphelper::OInterfaceContainerHelper4<css::lang::XEventListener> m_aEventListenerContainer; }; } // namespace chart::wrapper diff --git a/chart2/source/controller/chartapiwrapper/AxisWrapper.cxx b/chart2/source/controller/chartapiwrapper/AxisWrapper.cxx index db3e413ba919..ea50320e506e 100644 --- a/chart2/source/controller/chartapiwrapper/AxisWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/AxisWrapper.cxx @@ -18,6 +18,7 @@ */ #include "AxisWrapper.hxx" +#include <Axis.hxx> #include <AxisHelper.hxx> #include <TitleHelper.hxx> #include "Chart2ModelContact.hxx" @@ -35,8 +36,6 @@ #include <com/sun/star/chart/ChartAxisLabelPosition.hpp> #include <com/sun/star/chart/ChartAxisMarkPosition.hpp> #include <com/sun/star/chart2/XAxis.hpp> -#include <com/sun/star/chart2/XDiagram.hpp> -#include <com/sun/star/frame/XModel.hpp> #include <CharacterProperties.hxx> #include <LinePropertiesHelper.hxx> @@ -49,7 +48,8 @@ #include "WrappedScaleTextProperties.hxx" #include <algorithm> -#include <tools/diagnose_ex.h> +#include <utility> +#include <comphelper/diagnose_ex.hxx> using namespace ::com::sun::star; using namespace ::com::sun::star::chart2; @@ -335,33 +335,23 @@ void lcl_AddPropertiesToVector( | beans::PropertyAttribute::MAYBEVOID ); } -struct StaticAxisWrapperPropertyArray_Initializer -{ - Sequence< Property >* operator()() - { - static Sequence< Property > aPropSeq( lcl_GetPropertySequence() ); - return &aPropSeq; - } - -private: - static Sequence< Property > lcl_GetPropertySequence() - { - std::vector< css::beans::Property > aProperties; - lcl_AddPropertiesToVector( aProperties ); - ::chart::CharacterProperties::AddPropertiesToVector( aProperties ); - ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties ); - ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); - ::chart::wrapper::WrappedScaleTextProperties::addProperties( aProperties ); - - std::sort( aProperties.begin(), aProperties.end(), - ::chart::PropertyNameLess() ); - - return comphelper::containerToSequence( aProperties ); - } -}; - -struct StaticAxisWrapperPropertyArray : public rtl::StaticAggregate< Sequence< Property >, StaticAxisWrapperPropertyArray_Initializer > +const Sequence< Property >& StaticAxisWrapperPropertyArray() { + static Sequence< Property > aPropSeq = []() + { + std::vector< css::beans::Property > aProperties; + lcl_AddPropertiesToVector( aProperties ); + ::chart::CharacterProperties::AddPropertiesToVector( aProperties ); + ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties ); + ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); + ::chart::wrapper::WrappedScaleTextProperties::addProperties( aProperties ); + + std::sort( aProperties.begin(), aProperties.end(), + ::chart::PropertyNameLess() ); + + return comphelper::containerToSequence( aProperties ); + }(); + return aPropSeq; }; } // anonymous namespace @@ -370,9 +360,8 @@ namespace chart::wrapper { AxisWrapper::AxisWrapper( - tAxisType eType, const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact) : - m_spChart2ModelContact( spChart2ModelContact ), - m_aEventListenerContainer( m_aMutex ), + tAxisType eType, std::shared_ptr<Chart2ModelContact> spChart2ModelContact) : + m_spChart2ModelContact(std::move( spChart2ModelContact )), m_eType( eType ) { } @@ -526,8 +515,9 @@ void AxisWrapper::getDimensionAndMainAxisBool( tAxisType eType, sal_Int32& rnDim // ____ XComponent ____ void SAL_CALL AxisWrapper::dispose() { + std::unique_lock g(m_aMutex); Reference< uno::XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) ); - m_aEventListenerContainer.disposeAndClear( lang::EventObject( xSource ) ); + m_aEventListenerContainer.disposeAndClear( g, lang::EventObject( xSource ) ); DisposeHelper::DisposeAndClear( m_xAxisTitle ); DisposeHelper::DisposeAndClear( m_xMajorGrid ); @@ -539,13 +529,15 @@ void SAL_CALL AxisWrapper::dispose() void SAL_CALL AxisWrapper::addEventListener( const Reference< lang::XEventListener >& xListener ) { - m_aEventListenerContainer.addInterface( xListener ); + std::unique_lock g(m_aMutex); + m_aEventListenerContainer.addInterface( g, xListener ); } void SAL_CALL AxisWrapper::removeEventListener( const Reference< lang::XEventListener >& aListener ) { - m_aEventListenerContainer.removeInterface( aListener ); + std::unique_lock g(m_aMutex); + m_aEventListenerContainer.removeInterface( g, aListener ); } //ReferenceSizePropertyProvider @@ -574,7 +566,7 @@ awt::Size AxisWrapper::getCurrentSizeForReference() Reference< chart2::XAxis > AxisWrapper::getAxis() { - Reference< chart2::XAxis > xAxis; + rtl::Reference< Axis > xAxis; try { sal_Int32 nDimensionIndex = 0; @@ -586,9 +578,8 @@ Reference< chart2::XAxis > AxisWrapper::getAxis() if( !xAxis.is() ) { xAxis = AxisHelper::createAxis( nDimensionIndex, bMainAxis, xDiagram, m_spChart2ModelContact->m_xContext ); - Reference< beans::XPropertySet > xProp( xAxis, uno::UNO_QUERY ); - if( xProp.is() ) - xProp->setPropertyValue("Show", uno::Any( false ) ); + if( xAxis.is() ) + xAxis->setPropertyValue("Show", uno::Any( false ) ); } } catch( const uno::Exception & ) @@ -606,7 +597,7 @@ Reference< beans::XPropertySet > AxisWrapper::getInnerPropertySet() const Sequence< beans::Property >& AxisWrapper::getPropertySequence() { - return *StaticAxisWrapperPropertyArray::get(); + return StaticAxisWrapperPropertyArray(); } std::vector< std::unique_ptr<WrappedProperty> > AxisWrapper::createWrappedProperties() diff --git a/chart2/source/controller/chartapiwrapper/AxisWrapper.hxx b/chart2/source/controller/chartapiwrapper/AxisWrapper.hxx index b421ab331ab6..e70c85b23ff8 100644 --- a/chart2/source/controller/chartapiwrapper/AxisWrapper.hxx +++ b/chart2/source/controller/chartapiwrapper/AxisWrapper.hxx @@ -21,7 +21,7 @@ #include <WrappedPropertySet.hxx> #include "ReferenceSizePropertyProvider.hxx" #include <cppuhelper/implbase.hxx> -#include <comphelper/interfacecontainer3.hxx> +#include <comphelper/interfacecontainer4.hxx> #include <com/sun/star/chart/XAxis.hpp> #include <com/sun/star/drawing/XShape.hpp> #include <com/sun/star/lang/XComponent.hpp> @@ -56,7 +56,7 @@ public: SECOND_Y_AXIS }; - AxisWrapper(tAxisType eType, const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact); + AxisWrapper(tAxisType eType, std::shared_ptr<Chart2ModelContact> spChart2ModelContact); virtual ~AxisWrapper() override; static void getDimensionAndMainAxisBool( tAxisType eType, sal_Int32& rnDimensionIndex, bool& rbMainAxis ); @@ -109,7 +109,7 @@ private: //methods private: //member std::shared_ptr< Chart2ModelContact > m_spChart2ModelContact; - ::comphelper::OInterfaceContainerHelper3<css::lang::XEventListener> m_aEventListenerContainer; + ::comphelper::OInterfaceContainerHelper4<css::lang::XEventListener> m_aEventListenerContainer; tAxisType m_eType; diff --git a/chart2/source/controller/chartapiwrapper/Chart2ModelContact.cxx b/chart2/source/controller/chartapiwrapper/Chart2ModelContact.cxx index aefdc29b1dce..ba286cc62623 100644 --- a/chart2/source/controller/chartapiwrapper/Chart2ModelContact.cxx +++ b/chart2/source/controller/chartapiwrapper/Chart2ModelContact.cxx @@ -19,12 +19,14 @@ #include "Chart2ModelContact.hxx" #include <ChartModelHelper.hxx> +#include <Legend.hxx> #include <LegendHelper.hxx> #include <CommonConverters.hxx> #include <servicenames.hxx> #include <ObjectIdentifier.hxx> #include <chartview/ExplicitValueProvider.hxx> #include <chartview/DrawModelWrapper.hxx> +#include <Axis.hxx> #include <AxisHelper.hxx> #include <ChartView.hxx> #include <DiagramHelper.hxx> @@ -32,8 +34,8 @@ #include <ChartModel.hxx> -#include <comphelper/servicehelper.hxx> -#include <tools/diagnose_ex.h> +#include <com/sun/star/chart2/XDataSeries.hpp> +#include <comphelper/diagnose_ex.hxx> using namespace ::com::sun::star; using namespace ::com::sun::star::chart2; @@ -62,16 +64,11 @@ void Chart2ModelContact::setDocumentModel( ChartModel* pChartModel ) if( !pChartModel ) return; - uno::Reference< container::XNameContainer > xDashTable( pChartModel->createInstance("com.sun.star.drawing.DashTable"), uno::UNO_QUERY ); - uno::Reference< container::XNameContainer > xGradientTable( pChartModel->createInstance("com.sun.star.drawing.GradientTable"), uno::UNO_QUERY ); - uno::Reference< container::XNameContainer > xHatchTable( pChartModel->createInstance("com.sun.star.drawing.HatchTable"), uno::UNO_QUERY ); - uno::Reference< container::XNameContainer > xBitmapTable( pChartModel->createInstance("com.sun.star.drawing.BitmapTable"), uno::UNO_QUERY ); - uno::Reference< container::XNameContainer > xTransparencyGradientTable( pChartModel->createInstance("com.sun.star.drawing.TransparencyGradientTable"), uno::UNO_QUERY ); - m_aTableMap["LineDashName"] = xDashTable; - m_aTableMap["FillGradientName"] = xGradientTable; - m_aTableMap["FillHatchName"] = xHatchTable; - m_aTableMap["FillBitmapName"] = xBitmapTable; - m_aTableMap["FillTransparenceGradientName"] = xTransparencyGradientTable; + m_aTableMap["LineDashName"].set(pChartModel->createInstance("com.sun.star.drawing.DashTable"), uno::UNO_QUERY); + m_aTableMap["FillGradientName"].set(pChartModel->createInstance("com.sun.star.drawing.GradientTable"), uno::UNO_QUERY); + m_aTableMap["FillHatchName"].set(pChartModel->createInstance("com.sun.star.drawing.HatchTable"), uno::UNO_QUERY); + m_aTableMap["FillBitmapName"].set(pChartModel->createInstance("com.sun.star.drawing.BitmapTable"), uno::UNO_QUERY); + m_aTableMap["FillTransparenceGradientName"].set(pChartModel->createInstance("com.sun.star.drawing.TransparencyGradientTable"), uno::UNO_QUERY); } void Chart2ModelContact::clear() @@ -137,7 +134,7 @@ rtl::Reference<SvxDrawPage> Chart2ModelContact::getDrawPage() const } void Chart2ModelContact::getExplicitValuesForAxis( - const Reference< XAxis > & xAxis, + const rtl::Reference< Axis > & xAxis, ExplicitScaleData & rOutExplicitScale, ExplicitIncrementData & rOutExplicitIncrement ) { @@ -150,11 +147,11 @@ void Chart2ModelContact::getExplicitValuesForAxis( } sal_Int32 Chart2ModelContact::getExplicitNumberFormatKeyForAxis( - const Reference< chart2::XAxis >& xAxis ) + const rtl::Reference< ::chart::Axis >& xAxis ) { - Reference< chart2::XCoordinateSystem > xCooSys( + rtl::Reference< BaseCoordinateSystem > xCooSys( AxisHelper::getCoordinateSystemOfAxis( - xAxis, ChartModelHelper::findDiagram( m_xChartModel ) ) ); + xAxis, m_xChartModel.get()->getFirstChartDiagram() ) ); return ExplicitValueProvider::getExplicitNumberFormatKeyForAxis( xAxis, xCooSys , m_xChartModel.get() ); @@ -193,9 +190,9 @@ awt::Rectangle Chart2ModelContact::GetDiagramRectangleIncludingTitle() const awt::Rectangle Chart2ModelContact::GetDiagramRectangleIncludingAxes() const { awt::Rectangle aRect(0,0,0,0); - rtl::Reference< Diagram > xDiagram = ChartModelHelper::findDiagram( m_xChartModel ); + rtl::Reference< Diagram > xDiagram = m_xChartModel.get()->getFirstChartDiagram(); - if( DiagramHelper::getDiagramPositioningMode( xDiagram ) == DiagramPositioningMode_INCLUDING ) + if( xDiagram && xDiagram->getDiagramPositioningMode() == DiagramPositioningMode::Including ) aRect = DiagramHelper::getDiagramRectangleFromModel(m_xChartModel.get()); else { @@ -209,9 +206,9 @@ awt::Rectangle Chart2ModelContact::GetDiagramRectangleIncludingAxes() const awt::Rectangle Chart2ModelContact::GetDiagramRectangleExcludingAxes() const { awt::Rectangle aRect(0,0,0,0); - rtl::Reference< Diagram > xDiagram = ChartModelHelper::findDiagram( m_xChartModel ); + rtl::Reference< Diagram > xDiagram = m_xChartModel.get()->getFirstChartDiagram(); - if( DiagramHelper::getDiagramPositioningMode( xDiagram ) == DiagramPositioningMode_EXCLUDING ) + if( xDiagram && xDiagram->getDiagramPositioningMode() == DiagramPositioningMode::Excluding ) aRect = DiagramHelper::getDiagramRectangleFromModel(m_xChartModel.get()); else { @@ -228,8 +225,8 @@ awt::Size Chart2ModelContact::GetLegendSize() const ExplicitValueProvider* pProvider( getExplicitValueProvider() ); if( pProvider ) { - uno::Reference< chart2::XLegend > xLegend( LegendHelper::getLegend( *m_xChartModel.get() ) ); - OUString aCID( ObjectIdentifier::createClassifiedIdentifierForObject( xLegend, m_xChartModel.get() ) ); + rtl::Reference< Legend > xLegend = LegendHelper::getLegend( *m_xChartModel.get() ); + OUString aCID( ObjectIdentifier::createClassifiedIdentifierForObject( xLegend, m_xChartModel ) ); aSize = ToSize( pProvider->getRectangleOfObject( aCID ) ); } return aSize; @@ -241,8 +238,8 @@ awt::Point Chart2ModelContact::GetLegendPosition() const ExplicitValueProvider* pProvider( getExplicitValueProvider() ); if( pProvider ) { - uno::Reference< chart2::XLegend > xLegend( LegendHelper::getLegend( *m_xChartModel.get() ) ); - OUString aCID( ObjectIdentifier::createClassifiedIdentifierForObject( xLegend, m_xChartModel.get() ) ); + rtl::Reference< Legend > xLegend = LegendHelper::getLegend( *m_xChartModel.get() ); + OUString aCID( ObjectIdentifier::createClassifiedIdentifierForObject( xLegend, m_xChartModel ) ); aPoint = ToPoint( pProvider->getRectangleOfObject( aCID ) ); } return aPoint; @@ -254,7 +251,7 @@ awt::Size Chart2ModelContact::GetTitleSize( const uno::Reference< css::chart2::X ExplicitValueProvider* pProvider( getExplicitValueProvider() ); if( pProvider && xTitle.is() ) { - OUString aCID( ObjectIdentifier::createClassifiedIdentifierForObject( xTitle, m_xChartModel.get() ) ); + OUString aCID( ObjectIdentifier::createClassifiedIdentifierForObject( xTitle, m_xChartModel ) ); aSize = ToSize( pProvider->getRectangleOfObject( aCID ) ); } return aSize; diff --git a/chart2/source/controller/chartapiwrapper/Chart2ModelContact.hxx b/chart2/source/controller/chartapiwrapper/Chart2ModelContact.hxx index 837c09341fd3..261f2686240a 100644 --- a/chart2/source/controller/chartapiwrapper/Chart2ModelContact.hxx +++ b/chart2/source/controller/chartapiwrapper/Chart2ModelContact.hxx @@ -18,7 +18,6 @@ */ #pragma once -#include <cppuhelper/weakref.hxx> #include <com/sun/star/awt/Size.hpp> #include <com/sun/star/awt/Point.hpp> #include <com/sun/star/awt/Rectangle.hpp> @@ -71,12 +70,12 @@ public: case properties are 'auto'. */ void getExplicitValuesForAxis( - const css::uno::Reference< css::chart2::XAxis > & xAxis, + const rtl::Reference< ::chart::Axis > & xAxis, ExplicitScaleData & rOutExplicitScale, ExplicitIncrementData & rOutExplicitIncrement ); sal_Int32 getExplicitNumberFormatKeyForAxis( - const css::uno::Reference< css::chart2::XAxis >& xAxis ); + const rtl::Reference< ::chart::Axis >& xAxis ); static sal_Int32 getExplicitNumberFormatKeyForSeries( const css::uno::Reference< css::chart2::XDataSeries >& xSeries ); diff --git a/chart2/source/controller/chartapiwrapper/ChartDataWrapper.cxx b/chart2/source/controller/chartapiwrapper/ChartDataWrapper.cxx index 3b0a56818e77..7988ef90df94 100644 --- a/chart2/source/controller/chartapiwrapper/ChartDataWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/ChartDataWrapper.cxx @@ -25,12 +25,12 @@ #include <ControllerLockGuard.hxx> #include "Chart2ModelContact.hxx" #include <cppuhelper/supportsservice.hxx> -#include <com/sun/star/chart2/XChartDocument.hpp> #include <com/sun/star/chart/XChartDocument.hpp> #include <float.h> #include <cmath> #include <limits> +#include <utility> #include <osl/diagnose.h> using namespace ::com::sun::star; @@ -121,6 +121,11 @@ struct lcl_AllOperator : public lcl_Operator virtual bool setsCategories( bool /*bDataInColumns*/ ) override { + // Do not force creation of categories, when original has no categories + if (auto pDataWrapper = dynamic_cast<const ChartDataWrapper*>(m_xDataToApply.get())) + if (auto xChartModel = pDataWrapper->getChartModel()) + if (auto xDiagram = xChartModel->getFirstChartDiagram()) + return xDiagram->getCategories().is(); return true; } @@ -177,9 +182,9 @@ struct lcl_DataOperator : public lcl_Operator struct lcl_RowDescriptionsOperator : public lcl_Operator { lcl_RowDescriptionsOperator( const Sequence< OUString >& rRowDescriptions - , const rtl::Reference<::chart::ChartModel>& xChartDoc ) + , rtl::Reference<::chart::ChartModel> xChartDoc ) : m_rRowDescriptions( rRowDescriptions ) - , m_xChartDoc(xChartDoc) + , m_xChartDoc(std::move(xChartDoc)) , m_bDataInColumns(true) { } @@ -208,9 +213,9 @@ struct lcl_RowDescriptionsOperator : public lcl_Operator struct lcl_ComplexRowDescriptionsOperator : public lcl_Operator { lcl_ComplexRowDescriptionsOperator( const Sequence< Sequence< OUString > >& rComplexRowDescriptions - , const rtl::Reference<::chart::ChartModel>& xChartDoc ) + , rtl::Reference<::chart::ChartModel> xChartDoc ) : m_rComplexRowDescriptions( rComplexRowDescriptions ) - , m_xChartDoc(xChartDoc) + , m_xChartDoc(std::move(xChartDoc)) , m_bDataInColumns(true) { } @@ -260,9 +265,9 @@ struct lcl_AnyRowDescriptionsOperator : public lcl_Operator struct lcl_ColumnDescriptionsOperator : public lcl_Operator { lcl_ColumnDescriptionsOperator( const Sequence< OUString >& rColumnDescriptions - , const rtl::Reference<::chart::ChartModel>& xChartDoc ) + , rtl::Reference<::chart::ChartModel> xChartDoc ) : m_rColumnDescriptions( rColumnDescriptions ) - , m_xChartDoc(xChartDoc) + , m_xChartDoc(std::move(xChartDoc)) , m_bDataInColumns(true) { } @@ -291,9 +296,9 @@ struct lcl_ColumnDescriptionsOperator : public lcl_Operator struct lcl_ComplexColumnDescriptionsOperator : public lcl_Operator { lcl_ComplexColumnDescriptionsOperator( const Sequence< Sequence< OUString > >& rComplexColumnDescriptions - , const rtl::Reference<::chart::ChartModel>& xChartDoc ) + , rtl::Reference<::chart::ChartModel> xChartDoc ) : m_rComplexColumnDescriptions( rComplexColumnDescriptions ) - , m_xChartDoc(xChartDoc) + , m_xChartDoc(std::move(xChartDoc)) , m_bDataInColumns(true) { } @@ -364,19 +369,17 @@ struct lcl_DateCategoriesOperator : public lcl_Operator } -ChartDataWrapper::ChartDataWrapper(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact) - : m_spChart2ModelContact(spChart2ModelContact) - , m_aEventListenerContainer(m_aMutex) +ChartDataWrapper::ChartDataWrapper(std::shared_ptr<Chart2ModelContact> spChart2ModelContact) + : m_spChart2ModelContact(std::move(spChart2ModelContact)) { osl_atomic_increment( &m_refCount ); initDataAccess(); osl_atomic_decrement( &m_refCount ); } -ChartDataWrapper::ChartDataWrapper( const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact, +ChartDataWrapper::ChartDataWrapper( std::shared_ptr<Chart2ModelContact> spChart2ModelContact, const Reference< XChartData >& xNewData ) : - m_spChart2ModelContact( spChart2ModelContact ), - m_aEventListenerContainer( m_aMutex ) + m_spChart2ModelContact(std::move( spChart2ModelContact )) { osl_atomic_increment( &m_refCount ); lcl_AllOperator aOperator( xNewData ); @@ -513,13 +516,15 @@ void SAL_CALL ChartDataWrapper::setDateCategories( const Sequence< double >& rDa void SAL_CALL ChartDataWrapper::addChartDataChangeEventListener( const uno::Reference< css::chart::XChartDataChangeEventListener >& aListener ) { - m_aEventListenerContainer.addInterface( aListener ); + std::unique_lock g(m_aMutex); + m_aEventListenerContainer.addInterface( g, aListener ); } void SAL_CALL ChartDataWrapper::removeChartDataChangeEventListener( const uno::Reference< css::chart::XChartDataChangeEventListener >& aListener ) { - m_aEventListenerContainer.removeInterface( aListener ); + std::unique_lock g(m_aMutex); + m_aEventListenerContainer.removeInterface( g, aListener ); } double SAL_CALL ChartDataWrapper::getNotANumber() @@ -537,20 +542,23 @@ sal_Bool SAL_CALL ChartDataWrapper::isNotANumber( double nNumber ) // ____ XComponent ____ void SAL_CALL ChartDataWrapper::dispose() { - m_aEventListenerContainer.disposeAndClear( lang::EventObject( static_cast< ::cppu::OWeakObject* >( this ))); + std::unique_lock g(m_aMutex); + m_aEventListenerContainer.disposeAndClear( g, lang::EventObject( static_cast< ::cppu::OWeakObject* >( this ))); m_xDataAccess=nullptr; } void SAL_CALL ChartDataWrapper::addEventListener( const uno::Reference< lang::XEventListener > & xListener ) { - m_aEventListenerContainer.addInterface( xListener ); + std::unique_lock g(m_aMutex); + m_aEventListenerContainer.addInterface( g, xListener ); } void SAL_CALL ChartDataWrapper::removeEventListener( const uno::Reference< lang::XEventListener >& aListener ) { - m_aEventListenerContainer.removeInterface( aListener ); + std::unique_lock g(m_aMutex); + m_aEventListenerContainer.removeInterface( g, aListener ); } // ____ XEventListener ____ @@ -560,7 +568,8 @@ void SAL_CALL ChartDataWrapper::disposing( const lang::EventObject& /* Source */ void ChartDataWrapper::fireChartDataChangeEvent( css::chart::ChartDataChangeEvent& aEvent ) { - if( ! m_aEventListenerContainer.getLength() ) + std::unique_lock g(m_aMutex); + if( ! m_aEventListenerContainer.getLength(g) ) return; uno::Reference< uno::XInterface > xSrc( static_cast< cppu::OWeakObject* >( this )); @@ -568,7 +577,13 @@ void ChartDataWrapper::fireChartDataChangeEvent( css::chart::ChartDataChangeEven if( xSrc.is() ) aEvent.Source = xSrc; - m_aEventListenerContainer.notifyEach( &css::chart::XChartDataChangeEventListener::chartDataChanged, aEvent ); + m_aEventListenerContainer.forEach( g, + [&aEvent](const uno::Reference<css::lang::XEventListener>& l) + { + uno::Reference<css::chart::XChartDataChangeEventListener> cl(l, uno::UNO_QUERY); + if (cl) + cl->chartDataChanged(aEvent); + }); } void ChartDataWrapper::switchToInternalDataProvider() @@ -647,7 +662,7 @@ void ChartDataWrapper::applyData( lcl_Operator& rDataOperator ) return; uno::Reference< chart2::data::XDataSource > xSource( xDataProvider->createDataSource( aArguments ) ); - uno::Reference< chart2::XDiagram > xDia( xChartDoc->getFirstDiagram() ); + rtl::Reference< Diagram > xDia( xChartDoc->getFirstChartDiagram() ); if( xDia.is() ) xDia->setDiagramData( xSource, aArguments ); @@ -659,7 +674,7 @@ void ChartDataWrapper::applyData( lcl_Operator& rDataOperator ) eStackMode = StackMode::ZStacked; else if( bPercent ) eStackMode = StackMode::YStackedPercent; - DiagramHelper::setStackMode( xDia, eStackMode ); + xDia->setStackMode( eStackMode ); } // notify listeners @@ -688,6 +703,11 @@ css::uno::Sequence< OUString > SAL_CALL ChartDataWrapper::getSupportedServiceNam }; } +rtl::Reference<ChartModel> ChartDataWrapper::getChartModel() const +{ + return m_spChart2ModelContact->getDocumentModel(); +} + } // namespace chart /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/controller/chartapiwrapper/ChartDataWrapper.hxx b/chart2/source/controller/chartapiwrapper/ChartDataWrapper.hxx index dcf7c50ade36..9a44e53b8b12 100644 --- a/chart2/source/controller/chartapiwrapper/ChartDataWrapper.hxx +++ b/chart2/source/controller/chartapiwrapper/ChartDataWrapper.hxx @@ -18,9 +18,10 @@ */ #pragma once -#include <cppuhelper/basemutex.hxx> #include <cppuhelper/implbase.hxx> -#include <comphelper/interfacecontainer2.hxx> +#include <comphelper/interfacecontainer4.hxx> +#include <rtl/ref.hxx> + #include <com/sun/star/chart2/XAnyDescriptionAccess.hpp> #include <com/sun/star/chart/XDateCategories.hpp> #include <com/sun/star/lang/XComponent.hpp> @@ -29,13 +30,17 @@ #include <memory> -namespace chart::wrapper +namespace chart +{ +class ChartModel; + +namespace wrapper { class Chart2ModelContact; struct lcl_Operator; -class ChartDataWrapper final : public cppu::BaseMutex, public +class ChartDataWrapper final : public ::cppu::WeakImplHelper< css::chart2::XAnyDescriptionAccess, css::chart::XDateCategories, @@ -44,8 +49,8 @@ class ChartDataWrapper final : public cppu::BaseMutex, public css::lang::XComponent > { public: - explicit ChartDataWrapper(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact); - ChartDataWrapper(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact + explicit ChartDataWrapper(std::shared_ptr<Chart2ModelContact> spChart2ModelContact); + ChartDataWrapper(std::shared_ptr<Chart2ModelContact> spChart2ModelContact , const css::uno::Reference< css::chart::XChartData >& xNewData ); virtual ~ChartDataWrapper() override; @@ -54,6 +59,8 @@ public: virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override; virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; + rtl::Reference<ChartModel> getChartModel() const; + private: // ____ XDateCategories ____ virtual css::uno::Sequence< double > SAL_CALL getDateCategories() override; @@ -107,12 +114,13 @@ private: void initDataAccess(); void applyData( lcl_Operator& rDataOperator ); + std::mutex m_aMutex; css::uno::Reference< css::chart2::XAnyDescriptionAccess > m_xDataAccess; - std::shared_ptr< Chart2ModelContact > m_spChart2ModelContact; - ::comphelper::OInterfaceContainerHelper2 m_aEventListenerContainer; + ::comphelper::OInterfaceContainerHelper4<css::lang::XEventListener> m_aEventListenerContainer; }; } // namespace chart::wrapper +} // namespace chart /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx b/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx index e75bd16e8e24..51c803a1db0c 100644 --- a/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx @@ -19,11 +19,13 @@ #include <ChartDocumentWrapper.hxx> #include <ChartView.hxx> +#include <ChartViewHelper.hxx> #include <ChartTypeManager.hxx> #include <ChartTypeTemplate.hxx> #include <servicenames.hxx> #include <PropertyHelper.hxx> #include <TitleHelper.hxx> +#include <Legend.hxx> #include <LegendHelper.hxx> #include <ControllerLockGuard.hxx> #include <DisposeHelper.hxx> @@ -35,9 +37,7 @@ #include <ChartModel.hxx> -#include <DiagramHelper.hxx> #include <DataSourceHelper.hxx> -#include <ChartModelHelper.hxx> #include <AxisHelper.hxx> #include <ThreeDHelper.hxx> @@ -51,7 +51,7 @@ #include <cppuhelper/supportsservice.hxx> #include <comphelper/processfactory.hxx> #include <comphelper/sequence.hxx> -#include <comphelper/servicehelper.hxx> +#include <utility> #include <vcl/settings.hxx> #include <com/sun/star/drawing/ShapeCollection.hpp> @@ -59,9 +59,8 @@ #include <com/sun/star/lang/DisposedException.hpp> #include <com/sun/star/lang/XInitialization.hpp> #include <com/sun/star/util/XRefreshable.hpp> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> -#include <vector> #include <algorithm> #include <map> @@ -220,30 +219,20 @@ void lcl_AddPropertiesToVector( beans::PropertyAttribute::MAYBEDEFAULT ); } -struct StaticChartDocumentWrapperPropertyArray_Initializer +const Sequence< Property > & StaticChartDocumentWrapperPropertyArray() { - Sequence< Property >* operator()() - { - static Sequence< Property > aPropSeq( lcl_GetPropertySequence() ); - return &aPropSeq; - } - -private: - static uno::Sequence< Property > lcl_GetPropertySequence() - { - std::vector< css::beans::Property > aProperties; - lcl_AddPropertiesToVector( aProperties ); - - std::sort( aProperties.begin(), aProperties.end(), - ::chart::PropertyNameLess() ); + static Sequence< Property > aPropSeq = []() + { + std::vector< css::beans::Property > aProperties; + lcl_AddPropertiesToVector( aProperties ); - return comphelper::containerToSequence( aProperties ); - } -}; + std::sort( aProperties.begin(), aProperties.end(), + ::chart::PropertyNameLess() ); -struct StaticChartDocumentWrapperPropertyArray : public rtl::StaticAggregate< Sequence< Property >, StaticChartDocumentWrapperPropertyArray_Initializer > -{ -}; + return comphelper::containerToSequence( aProperties ); + }(); + return aPropSeq; +} } // anonymous namespace @@ -256,7 +245,7 @@ namespace { class WrappedDataSourceLabelsInFirstRowProperty : public WrappedProperty { public: - explicit WrappedDataSourceLabelsInFirstRowProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact); + explicit WrappedDataSourceLabelsInFirstRowProperty(std::shared_ptr<Chart2ModelContact> spChart2ModelContact); virtual void setPropertyValue( const css::uno::Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override; @@ -271,9 +260,9 @@ private: //member } -WrappedDataSourceLabelsInFirstRowProperty::WrappedDataSourceLabelsInFirstRowProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact) +WrappedDataSourceLabelsInFirstRowProperty::WrappedDataSourceLabelsInFirstRowProperty(std::shared_ptr<Chart2ModelContact> spChart2ModelContact) : WrappedProperty("DataSourceLabelsInFirstRow",OUString()) - , m_spChart2ModelContact( spChart2ModelContact ) + , m_spChart2ModelContact(std::move( spChart2ModelContact )) { m_aOuterValue = WrappedDataSourceLabelsInFirstRowProperty::getPropertyDefault( nullptr ); } @@ -346,7 +335,7 @@ namespace { class WrappedDataSourceLabelsInFirstColumnProperty : public WrappedProperty { public: - explicit WrappedDataSourceLabelsInFirstColumnProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact); + explicit WrappedDataSourceLabelsInFirstColumnProperty(std::shared_ptr<Chart2ModelContact> spChart2ModelContact); virtual void setPropertyValue( const css::uno::Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override; @@ -361,9 +350,9 @@ private: //member } -WrappedDataSourceLabelsInFirstColumnProperty::WrappedDataSourceLabelsInFirstColumnProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact) +WrappedDataSourceLabelsInFirstColumnProperty::WrappedDataSourceLabelsInFirstColumnProperty(std::shared_ptr<Chart2ModelContact> spChart2ModelContact) : WrappedProperty("DataSourceLabelsInFirstColumn",OUString()) - , m_spChart2ModelContact( spChart2ModelContact ) + , m_spChart2ModelContact(std::move( spChart2ModelContact )) { m_aOuterValue = WrappedDataSourceLabelsInFirstColumnProperty::getPropertyDefault( nullptr ); } @@ -436,7 +425,7 @@ namespace { class WrappedHasLegendProperty : public WrappedProperty { public: - explicit WrappedHasLegendProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact); + explicit WrappedHasLegendProperty(std::shared_ptr<Chart2ModelContact> spChart2ModelContact); virtual void setPropertyValue( const css::uno::Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override; @@ -450,9 +439,9 @@ private: //member } -WrappedHasLegendProperty::WrappedHasLegendProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact) +WrappedHasLegendProperty::WrappedHasLegendProperty(std::shared_ptr<Chart2ModelContact> spChart2ModelContact) : WrappedProperty("HasLegend",OUString()) - , m_spChart2ModelContact( spChart2ModelContact ) + , m_spChart2ModelContact(std::move( spChart2ModelContact )) { } @@ -464,15 +453,14 @@ void WrappedHasLegendProperty::setPropertyValue( const Any& rOuterValue, const R try { - Reference< chart2::XLegend > xLegend( LegendHelper::getLegend( *m_spChart2ModelContact->getDocumentModel(), m_spChart2ModelContact->m_xContext,bNewValue )); + rtl::Reference< Legend > xLegend = LegendHelper::getLegend( *m_spChart2ModelContact->getDocumentModel(), m_spChart2ModelContact->m_xContext,bNewValue ); if(xLegend.is()) { - Reference< beans::XPropertySet > xLegendProp( xLegend, uno::UNO_QUERY_THROW ); bool bOldValue = true; - Any aAOld = xLegendProp->getPropertyValue("Show"); + Any aAOld = xLegend->getPropertyValue("Show"); aAOld >>= bOldValue; if( bOldValue != bNewValue ) - xLegendProp->setPropertyValue("Show", uno::Any( bNewValue )); + xLegend->setPropertyValue("Show", uno::Any( bNewValue )); } } catch (const uno::Exception&) @@ -486,10 +474,10 @@ Any WrappedHasLegendProperty::getPropertyValue( const Reference< beans::XPropert Any aRet; try { - Reference< beans::XPropertySet > xLegendProp( - LegendHelper::getLegend( *m_spChart2ModelContact->getDocumentModel() ), uno::UNO_QUERY ); - if( xLegendProp.is()) - aRet = xLegendProp->getPropertyValue("Show"); + rtl::Reference< Legend > xLegend = + LegendHelper::getLegend( *m_spChart2ModelContact->getDocumentModel() ); + if( xLegend.is()) + aRet = xLegend->getPropertyValue("Show"); else aRet <<= false; } @@ -513,7 +501,7 @@ namespace { class WrappedHasMainTitleProperty : public WrappedProperty { public: - explicit WrappedHasMainTitleProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact); + explicit WrappedHasMainTitleProperty(std::shared_ptr<Chart2ModelContact> spChart2ModelContact); virtual void setPropertyValue( const css::uno::Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override; @@ -527,9 +515,9 @@ private: //member } -WrappedHasMainTitleProperty::WrappedHasMainTitleProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact) +WrappedHasMainTitleProperty::WrappedHasMainTitleProperty(std::shared_ptr<Chart2ModelContact> spChart2ModelContact) : WrappedProperty("HasMainTitle",OUString()) - , m_spChart2ModelContact( spChart2ModelContact ) + , m_spChart2ModelContact(std::move( spChart2ModelContact )) { } @@ -579,7 +567,7 @@ namespace { class WrappedHasSubTitleProperty : public WrappedProperty { public: - explicit WrappedHasSubTitleProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact); + explicit WrappedHasSubTitleProperty(std::shared_ptr<Chart2ModelContact> spChart2ModelContact); virtual void setPropertyValue( const css::uno::Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override; @@ -593,9 +581,9 @@ private: //member } -WrappedHasSubTitleProperty::WrappedHasSubTitleProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact) +WrappedHasSubTitleProperty::WrappedHasSubTitleProperty(std::shared_ptr<Chart2ModelContact> spChart2ModelContact) : WrappedProperty("HasSubTitle",OUString()) - , m_spChart2ModelContact( spChart2ModelContact ) + , m_spChart2ModelContact(std::move( spChart2ModelContact )) { } @@ -653,6 +641,7 @@ ChartDocumentWrapper::~ChartDocumentWrapper() } // ____ XInterface (for new interfaces) ____ +// [-loplugin:unoaggregation] uno::Any SAL_CALL ChartDocumentWrapper::queryInterface( const uno::Type& aType ) { if( m_xDelegator.is()) @@ -864,8 +853,7 @@ Reference< uno::XInterface > SAL_CALL ChartDocumentWrapper::getCurrentSelection( void SAL_CALL ChartDocumentWrapper::dispose() { if( m_bIsDisposed ) - throw lang::DisposedException("ChartDocumentWrapper is disposed", - static_cast< ::cppu::OWeakObject* >( this )); + return; m_bIsDisposed = true; @@ -878,9 +866,9 @@ void SAL_CALL ChartDocumentWrapper::dispose() DisposeHelper::DisposeAndClear( m_xChartData ); DisposeHelper::DisposeAndClear( m_xDiagram ); DisposeHelper::DisposeAndClear( m_xArea ); - m_xChartView.set( nullptr ); - m_xShapeFactory.set( nullptr ); - m_xDelegator.set( nullptr ); + m_xChartView.clear(); + m_xShapeFactory.clear(); + m_xDelegator.clear(); clearWrappedPropertySet(); m_spChart2ModelContact->clear(); @@ -907,7 +895,7 @@ void SAL_CALL ChartDocumentWrapper::dispose() void ChartDocumentWrapper::impl_resetAddIn() { Reference< util::XRefreshable > xAddIn( m_xAddIn ); - m_xAddIn.set( nullptr ); + m_xAddIn.clear(); if( !xAddIn.is() ) return; @@ -1045,11 +1033,10 @@ rtl::Reference<SvxDrawPage> ChartDocumentWrapper::impl_getDrawPage() const namespace { -uno::Reference< lang::XMultiServiceFactory > getShapeFactory(const uno::Reference<uno::XInterface>& xChartView) +uno::Reference< lang::XMultiServiceFactory > getShapeFactory(const rtl::Reference<ChartView>& xChartView) { - auto pProvider = comphelper::getFromUnoTunnel<ExplicitValueProvider>(xChartView); - if( pProvider ) - return pProvider->getDrawModelWrapper()->getShapeFactory(); + if( xChartView ) + return xChartView->getDrawModelWrapper()->getShapeFactory(); return uno::Reference< lang::XMultiServiceFactory >(); } @@ -1189,17 +1176,17 @@ uno::Reference< uno::XInterface > SAL_CALL ChartDocumentWrapper::createInstance( { // locked controllers ControllerLockGuardUNO aCtrlLockGuard( xChartDoc ); - rtl::Reference< Diagram > xDiagram = ChartModelHelper::findDiagram( xChartDoc ); - ThreeDLookScheme e3DScheme = ThreeDHelper::detectScheme( xDiagram ); + rtl::Reference< Diagram > xDiagram = xChartDoc->getFirstChartDiagram(); + ThreeDLookScheme e3DScheme = xDiagram->detectScheme(); rtl::Reference< ::chart::ChartTypeManager > xTemplateManager = xChartDoc->getTypeManager(); - DiagramHelper::tTemplateWithServiceName aTemplateWithService( - DiagramHelper::getTemplateForDiagram( xDiagram, xTemplateManager )); + Diagram::tTemplateWithServiceName aTemplateWithService( + xDiagram->getTemplate( xTemplateManager )); if( aTemplateWithService.xChartTypeTemplate.is()) - aTemplateWithService.xChartTypeTemplate->resetStyles( xDiagram );//#i109371# + aTemplateWithService.xChartTypeTemplate->resetStyles2( xDiagram );//#i109371# xTemplate->changeDiagram( xDiagram ); if( AllSettings::GetMathLayoutRTL() ) AxisHelper::setRTLAxisLayout( AxisHelper::getCoordinateSystemByIndex( xDiagram, 0 ) ); - ThreeDHelper::setScheme( xDiagram, e3DScheme ); + xDiagram->setScheme( e3DScheme ); } else { @@ -1257,7 +1244,7 @@ uno::Reference< uno::XInterface > SAL_CALL ChartDocumentWrapper::createInstance( { if( !m_xShapeFactory.is() && m_xChartView.is() ) { - m_xShapeFactory = getShapeFactory( static_cast<cppu::OWeakObject*>(m_xChartView.get()) ); + m_xShapeFactory = getShapeFactory( m_xChartView ); } else { @@ -1265,7 +1252,7 @@ uno::Reference< uno::XInterface > SAL_CALL ChartDocumentWrapper::createInstance( if(pModel) { m_xChartView = pModel->getChartView(); - m_xShapeFactory = getShapeFactory( static_cast<cppu::OWeakObject*>(m_xChartView.get()) ); + m_xShapeFactory = getShapeFactory( m_xChartView ); } } @@ -1360,21 +1347,35 @@ uno::Any SAL_CALL ChartDocumentWrapper::queryAggregation( const uno::Type& rType void ChartDocumentWrapper::_disposing( const lang::EventObject& rSource ) { if( rSource.Source == m_xTitle ) - m_xTitle.set( nullptr ); + m_xTitle.clear(); else if( rSource.Source == m_xSubTitle ) - m_xSubTitle.set( nullptr ); + m_xSubTitle.clear(); else if( rSource.Source == m_xLegend ) - m_xLegend.set( nullptr ); + m_xLegend.clear(); else if( rSource.Source == m_xChartData ) - m_xChartData.set( nullptr ); + m_xChartData.clear(); else if( rSource.Source == m_xDiagram ) - m_xDiagram.set( nullptr ); + m_xDiagram.clear(); else if( rSource.Source == m_xArea ) - m_xArea.set( nullptr ); + m_xArea.clear(); else if( rSource.Source == m_xAddIn ) - m_xAddIn.set( nullptr ); + m_xAddIn.clear(); else if( rSource.Source == static_cast<cppu::OWeakObject*>(m_xChartView.get()) ) - m_xChartView.set( nullptr ); + m_xChartView.clear(); +} + +// ____ XPropertySet ____ +void SAL_CALL ChartDocumentWrapper::setPropertyValue(const OUString& rPropertyName, const css::uno::Any& rValue) +{ + if (rPropertyName == u"ODFImport_UpdateView") + { + // A hack used at load time to notify the view that it needs an update + // See SchXMLImport::~SchXMLImport + if (auto xChartModel = rValue.query<css::chart2::XChartDocument>()) + ChartViewHelper::setViewToDirtyState_UNO(xChartModel); + return; + } + ChartDocumentWrapper_Base::setPropertyValue(rPropertyName, rValue); } // WrappedPropertySet @@ -1384,7 +1385,7 @@ Reference< beans::XPropertySet > ChartDocumentWrapper::getInnerPropertySet() } const Sequence< beans::Property >& ChartDocumentWrapper::getPropertySequence() { - return *StaticChartDocumentWrapperPropertyArray::get(); + return StaticChartDocumentWrapperPropertyArray(); } std::vector< std::unique_ptr<WrappedProperty> > ChartDocumentWrapper::createWrappedProperties() diff --git a/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx b/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx index e49239935c6d..ac9a53ce331f 100644 --- a/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx @@ -19,8 +19,11 @@ #include "DataSeriesPointWrapper.hxx" #include "Chart2ModelContact.hxx" +#include <ChartType.hxx> #include <ChartTypeHelper.hxx> #include <DiagramHelper.hxx> +#include <DataSeries.hxx> +#include <DataSeriesProperties.hxx> #include <LinePropertiesHelper.hxx> #include <FillProperties.hxx> #include <CharacterProperties.hxx> @@ -37,6 +40,7 @@ #include "WrappedTextRotationProperty.hxx" #include <unonames.hxx> +#include <o3tl/safeint.hxx> #include <rtl/math.hxx> #include <algorithm> @@ -45,6 +49,7 @@ #include <com/sun/star/chart/ChartAxisAssign.hpp> #include <com/sun/star/chart/ChartErrorCategory.hpp> #include <com/sun/star/chart/ChartSymbolType.hpp> +#include <com/sun/star/chart2/XDataSeries.hpp> #include <com/sun/star/drawing/LineJoint.hpp> #include <com/sun/star/drawing/LineStyle.hpp> #include <com/sun/star/drawing/FillStyle.hpp> @@ -55,6 +60,7 @@ using namespace ::com::sun::star; using namespace ::chart::wrapper; +using namespace ::chart::DataSeriesProperties; using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::Sequence; @@ -243,30 +249,16 @@ uno::Sequence< Property > lcl_GetPropertySequence( DataSeriesPointWrapper::eType return comphelper::containerToSequence( aProperties ); } -struct StaticSeriesWrapperPropertyArray_Initializer +const Sequence< Property >& StaticSeriesWrapperPropertyArray() { - Sequence< Property >* operator()() - { - static Sequence< Property > aPropSeq( lcl_GetPropertySequence( DataSeriesPointWrapper::DATA_SERIES ) ); - return &aPropSeq; - } -}; - -struct StaticSeriesWrapperPropertyArray : public rtl::StaticAggregate< Sequence< Property >, StaticSeriesWrapperPropertyArray_Initializer > -{ -}; - -struct StaticPointWrapperPropertyArray_Initializer -{ - Sequence< Property >* operator()() - { - static Sequence< Property > aPropSeq( lcl_GetPropertySequence( DataSeriesPointWrapper::DATA_POINT ) ); - return &aPropSeq; - } + static Sequence< Property > aPropSeq( lcl_GetPropertySequence( DataSeriesPointWrapper::DATA_SERIES ) ); + return aPropSeq; }; -struct StaticPointWrapperPropertyArray : public rtl::StaticAggregate< Sequence< Property >, StaticPointWrapperPropertyArray_Initializer > +const Sequence< Property >& StaticPointWrapperPropertyArray() { + static Sequence< Property > aPropSeq( lcl_GetPropertySequence( DataSeriesPointWrapper::DATA_POINT ) ); + return aPropSeq; }; //PROP_SERIES_ATTACHED_AXIS @@ -303,7 +295,7 @@ Any WrappedAttachedAxisProperty::getPropertyValue( const Reference< beans::XProp { Any aRet; - uno::Reference< chart2::XDataSeries > xDataSeries( xInnerPropertySet, uno::UNO_QUERY ); + rtl::Reference< ::chart::DataSeries > xDataSeries( dynamic_cast<::chart::DataSeries*>(xInnerPropertySet.get()) ); bool bAttachedToMainAxis = ::chart::DiagramHelper::isSeriesAttachedToMainAxis( xDataSeries ); if( bAttachedToMainAxis ) aRet <<= css::chart::ChartAxisAssign::PRIMARY_Y; @@ -314,7 +306,7 @@ Any WrappedAttachedAxisProperty::getPropertyValue( const Reference< beans::XProp void WrappedAttachedAxisProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const { - uno::Reference< chart2::XDataSeries > xDataSeries( xInnerPropertySet, uno::UNO_QUERY ); + rtl::Reference< ::chart::DataSeries > xDataSeries( dynamic_cast<::chart::DataSeries*>(xInnerPropertySet.get()) ); sal_Int32 nChartAxisAssign = css::chart::ChartAxisAssign::PRIMARY_Y; if( ! (rOuterValue >>= nChartAxisAssign) ) @@ -327,7 +319,7 @@ void WrappedAttachedAxisProperty::setPropertyValue( const Any& rOuterValue, cons { rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); if( xDiagram.is() ) - ::chart::DiagramHelper::attachSeriesToAxis( bNewAttachedToMainAxis, xDataSeries, xDiagram, m_spChart2ModelContact->m_xContext, false ); + xDiagram->attachSeriesToAxis( bNewAttachedToMainAxis, xDataSeries, m_spChart2ModelContact->m_xContext, false ); } } @@ -454,9 +446,8 @@ void WrappedLineStyleProperty::setPropertyToDefault( const Reference< beans::XPr namespace chart::wrapper { -DataSeriesPointWrapper::DataSeriesPointWrapper(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact) - : m_spChart2ModelContact( spChart2ModelContact ) - , m_aEventListenerContainer( m_aMutex ) +DataSeriesPointWrapper::DataSeriesPointWrapper( std::shared_ptr<Chart2ModelContact> spChart2ModelContact) + : m_spChart2ModelContact( std::move(spChart2ModelContact) ) , m_eType( DATA_SERIES ) , m_nSeriesIndexInNewAPI( -1 ) , m_nPointIndex( -1 ) @@ -473,7 +464,11 @@ void SAL_CALL DataSeriesPointWrapper::initialize( const uno::Sequence< uno::Any m_nPointIndex = -1; if( aArguments.hasElements() ) { - aArguments[0] >>= m_xDataSeries; + uno::Reference<chart2::XDataSeries> xTmp; + aArguments[0] >>= xTmp; + auto p = dynamic_cast<DataSeries*>(xTmp.get()); + assert(p); + m_xDataSeries = p; if( aArguments.getLength() >= 2 ) aArguments[1] >>= m_nPointIndex; } @@ -493,9 +488,8 @@ void SAL_CALL DataSeriesPointWrapper::initialize( const uno::Sequence< uno::Any DataSeriesPointWrapper::DataSeriesPointWrapper(eType _eType, sal_Int32 nSeriesIndexInNewAPI , sal_Int32 nPointIndex, //ignored for series - const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact) - : m_spChart2ModelContact( spChart2ModelContact ) - , m_aEventListenerContainer( m_aMutex ) + std::shared_ptr<Chart2ModelContact> spChart2ModelContact) + : m_spChart2ModelContact( std::move(spChart2ModelContact) ) , m_eType( _eType ) , m_nSeriesIndexInNewAPI( nSeriesIndexInNewAPI ) , m_nPointIndex( (_eType == DATA_POINT) ? nPointIndex : -1 ) @@ -510,8 +504,9 @@ DataSeriesPointWrapper::~DataSeriesPointWrapper() // ____ XComponent ____ void SAL_CALL DataSeriesPointWrapper::dispose() { + std::unique_lock g(m_aMutex); uno::Reference< uno::XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) ); - m_aEventListenerContainer.disposeAndClear( lang::EventObject( xSource ) ); + m_aEventListenerContainer.disposeAndClear( g, lang::EventObject( xSource ) ); m_xDataSeries.clear(); clearWrappedPropertySet(); @@ -520,13 +515,15 @@ void SAL_CALL DataSeriesPointWrapper::dispose() void SAL_CALL DataSeriesPointWrapper::addEventListener( const uno::Reference< lang::XEventListener >& xListener ) { - m_aEventListenerContainer.addInterface( xListener ); + std::unique_lock g(m_aMutex); + m_aEventListenerContainer.addInterface( g, xListener ); } void SAL_CALL DataSeriesPointWrapper::removeEventListener( const uno::Reference< lang::XEventListener >& aListener ) { - m_aEventListenerContainer.removeInterface( aListener ); + std::unique_lock g(m_aMutex); + m_aEventListenerContainer.removeInterface( g, aListener ); } // ____ XEventListener ____ @@ -536,24 +533,24 @@ void SAL_CALL DataSeriesPointWrapper::disposing( const lang::EventObject& /*Sour bool DataSeriesPointWrapper::isSupportingAreaProperties() { - Reference< chart2::XDataSeries > xSeries( getDataSeries() ); + rtl::Reference< DataSeries > xSeries( getDataSeries() ); rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); - Reference< chart2::XChartType > xChartType( DiagramHelper::getChartTypeOfSeries( xDiagram, xSeries ) ); - sal_Int32 nDimensionCount = DiagramHelper::getDimension( xDiagram ); + rtl::Reference< ::chart::ChartType > xChartType( xDiagram->getChartTypeOfSeries( xSeries ) ); + sal_Int32 nDimensionCount = xDiagram->getDimension(); return ChartTypeHelper::isSupportingAreaProperties( xChartType, nDimensionCount ); } -Reference< chart2::XDataSeries > DataSeriesPointWrapper::getDataSeries() +rtl::Reference< DataSeries > DataSeriesPointWrapper::getDataSeries() { - Reference< chart2::XDataSeries > xSeries( m_xDataSeries ); + rtl::Reference< DataSeries > xSeries = m_xDataSeries; if( !xSeries.is() ) { rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); - std::vector< uno::Reference< chart2::XDataSeries > > aSeriesList( - ::chart::DiagramHelper::getDataSeriesFromDiagram( xDiagram ) ); + std::vector< rtl::Reference< DataSeries > > aSeriesList = + xDiagram->getDataSeries(); - if( m_nSeriesIndexInNewAPI >= 0 && m_nSeriesIndexInNewAPI < static_cast<sal_Int32>(aSeriesList.size()) ) + if( m_nSeriesIndexInNewAPI >= 0 && o3tl::make_unsigned(m_nSeriesIndexInNewAPI) < aSeriesList.size() ) xSeries = aSeriesList[m_nSeriesIndexInNewAPI]; } @@ -564,7 +561,7 @@ Reference< beans::XPropertySet > DataSeriesPointWrapper::getDataPointProperties( { Reference< beans::XPropertySet > xPointProp; - Reference< chart2::XDataSeries > xSeries( getDataSeries() ); + rtl::Reference< DataSeries > xSeries( getDataSeries() ); // may throw an IllegalArgumentException if( xSeries.is() ) @@ -622,9 +619,10 @@ beans::PropertyState SAL_CALL DataSeriesPointWrapper::getPropertyState( const OU { if( rPropertyName == "FillColor") { - Reference< beans::XPropertySet > xSeriesProp( getDataSeries(), uno::UNO_QUERY ); + rtl::Reference< DataSeries > xSeries = getDataSeries(); bool bVaryColorsByPoint = false; - if( xSeriesProp.is() && (xSeriesProp->getPropertyValue("VaryColorsByPoint") >>= bVaryColorsByPoint) + // "VaryColorsByPoint" + if( xSeries.is() && (xSeries->getFastPropertyValue(PROP_DATASERIES_VARY_COLORS_BY_POINT) >>= bVaryColorsByPoint) && bVaryColorsByPoint ) return beans::PropertyState_DIRECT_VALUE; } @@ -683,7 +681,7 @@ Any SAL_CALL DataSeriesPointWrapper::getPropertyDefault( const OUString& rProper if( nHandle > 0 ) { //always take the series current value as default for points - Reference< beans::XPropertySet > xInnerPropertySet( getDataSeries(), uno::UNO_QUERY ); + rtl::Reference< DataSeries > xInnerPropertySet = getDataSeries(); if( xInnerPropertySet.is() ) { const WrappedProperty* pWrappedProperty = getWrappedProperty( rPropertyName ); @@ -704,16 +702,16 @@ Any SAL_CALL DataSeriesPointWrapper::getPropertyDefault( const OUString& rProper Reference< beans::XPropertySet > DataSeriesPointWrapper::getInnerPropertySet() { if( m_eType == DATA_SERIES ) - return Reference< beans::XPropertySet >( getDataSeries(), uno::UNO_QUERY ); + return getDataSeries(); return getDataPointProperties(); } const Sequence< beans::Property >& DataSeriesPointWrapper::getPropertySequence() { if( m_eType == DATA_SERIES ) - return *StaticSeriesWrapperPropertyArray::get(); + return StaticSeriesWrapperPropertyArray(); else - return *StaticPointWrapperPropertyArray::get(); + return StaticPointWrapperPropertyArray(); } std::vector< std::unique_ptr<WrappedProperty> > DataSeriesPointWrapper::createWrappedProperties() @@ -841,9 +839,10 @@ Any SAL_CALL DataSeriesPointWrapper::getPropertyValue( const OUString& rProperty { if( rPropertyName == "FillColor" ) { - Reference< beans::XPropertySet > xSeriesProp( getDataSeries(), uno::UNO_QUERY ); + rtl::Reference< DataSeries > xSeries = getDataSeries(); bool bVaryColorsByPoint = false; - if( xSeriesProp.is() && (xSeriesProp->getPropertyValue("VaryColorsByPoint") >>= bVaryColorsByPoint) + // "VaryColorsByPoint" + if( xSeries.is() && (xSeries->getFastPropertyValue(PROP_DATASERIES_VARY_COLORS_BY_POINT) >>= bVaryColorsByPoint) && bVaryColorsByPoint ) { uno::Reference< beans::XPropertyState > xPointState( DataSeriesPointWrapper::getDataPointProperties(), uno::UNO_QUERY ); diff --git a/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.hxx b/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.hxx index f5fbab3f332b..4c79bb25e9bb 100644 --- a/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.hxx +++ b/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.hxx @@ -21,15 +21,16 @@ #include <WrappedPropertySet.hxx> #include "ReferenceSizePropertyProvider.hxx" #include <cppuhelper/implbase.hxx> -#include <comphelper/interfacecontainer3.hxx> +#include <comphelper/interfacecontainer4.hxx> #include <com/sun/star/lang/XComponent.hpp> #include <com/sun/star/lang/XEventListener.hpp> #include <com/sun/star/lang/XInitialization.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> - +#include <rtl/ref.hxx> #include <memory> namespace com::sun::star::chart2 { class XDataSeries; } +namespace chart { class DataSeries; } namespace chart::wrapper { @@ -54,12 +55,12 @@ public: }; //this constructor needs an initialize call afterwards - explicit DataSeriesPointWrapper(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact); + explicit DataSeriesPointWrapper(std::shared_ptr<Chart2ModelContact> spChart2ModelContact); DataSeriesPointWrapper(eType eType , sal_Int32 nSeriesIndexInNewAPI , sal_Int32 nPointIndex //ignored for series - , const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact); + , std::shared_ptr<Chart2ModelContact> spChart2ModelContact); virtual ~DataSeriesPointWrapper() override; @@ -100,11 +101,11 @@ private: virtual css::uno::Any SAL_CALL getPropertyDefault( const OUString& aPropertyName ) override; //own methods - css::uno::Reference< css::chart2::XDataSeries > getDataSeries(); + rtl::Reference< ::chart::DataSeries > getDataSeries(); css::uno::Reference< css::beans::XPropertySet > getDataPointProperties(); std::shared_ptr< Chart2ModelContact > m_spChart2ModelContact; - ::comphelper::OInterfaceContainerHelper3<css::lang::XEventListener> m_aEventListenerContainer; + ::comphelper::OInterfaceContainerHelper4<css::lang::XEventListener> m_aEventListenerContainer; eType m_eType; sal_Int32 m_nSeriesIndexInNewAPI; @@ -115,7 +116,7 @@ private: //this should only be used, if the DataSeriesPointWrapper is initialized via the XInitialize interface //because a big change in the chartmodel may lead to a dataseriespointer that is not connected to the model anymore //with the indices instead we can always get the new dataseries - css::uno::Reference< css::chart2::XDataSeries > m_xDataSeries; + rtl::Reference< ::chart::DataSeries > m_xDataSeries; }; } // namespace chart::wrapper diff --git a/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx b/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx index d9deba9857d4..2917b989f040 100644 --- a/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx @@ -20,14 +20,18 @@ #include "DiagramWrapper.hxx" #include <servicenames_charttypes.hxx> #include "DataSeriesPointWrapper.hxx" +#include <DataSeriesProperties.hxx> #include "AxisWrapper.hxx" #include "Chart2ModelContact.hxx" #include "WallFloorWrapper.hxx" #include "MinMaxLineWrapper.hxx" #include "UpDownBarWrapper.hxx" +#include <Diagram.hxx> #include <DiagramHelper.hxx> #include <DataSourceHelper.hxx> #include <ChartModelHelper.hxx> +#include <ChartType.hxx> +#include <DataSeries.hxx> #include <WrappedIgnoreProperty.hxx> #include "WrappedAxisAndGridExistenceProperties.hxx" #include "WrappedStatisticProperties.hxx" @@ -50,10 +54,9 @@ #include <com/sun/star/chart/ChartDataRowSource.hpp> #include <com/sun/star/chart2/RelativeSize.hpp> #include <com/sun/star/chart2/RelativePosition.hpp> -#include <com/sun/star/chart2/XChartDocument.hpp> +#include <com/sun/star/chart2/PieChartSubType.hpp> #include <com/sun/star/chart/ChartSolidType.hpp> #include <com/sun/star/lang/IndexOutOfBoundsException.hpp> -#include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <LinePropertiesHelper.hxx> #include <FillProperties.hxx> @@ -64,17 +67,19 @@ #include <map> #include <com/sun/star/lang/XServiceName.hpp> #include <com/sun/star/util/XRefreshable.hpp> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> +#include <o3tl/string_view.hxx> +#include <utility> using namespace ::com::sun::star; using namespace ::chart::wrapper; +using namespace ::chart::DataSeriesProperties; using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::Any; using ::com::sun::star::uno::Sequence; using ::com::sun::star::beans::Property; using ::com::sun::star::chart::XAxis; -using ::osl::MutexGuard; namespace { @@ -98,6 +103,7 @@ enum PROP_DIAGRAM_SORT_BY_X_VALUES, PROP_DIAGRAM_STARTING_ANGLE, + PROP_DIAGRAM_OF_PIE_TYPE, PROP_DIAGRAM_RIGHT_ANGLED_AXES, PROP_DIAGRAM_PERSPECTIVE, @@ -134,9 +140,6 @@ enum PROP_DIAGRAM_HAS_SECOND_Y_AXIS_TITLE, PROP_DIAGRAM_AUTOMATIC_SIZE, - PROP_DIAGRAM_DATATABLEHBORDER, - PROP_DIAGRAM_DATATABLEVBORDER, - PROP_DIAGRAM_DATATABLEOUTLINE, PROP_DIAGRAM_EXTERNALDATA }; @@ -227,6 +230,11 @@ void lcl_AddPropertiesToVector( cppu::UnoType<sal_Int32>::get(), beans::PropertyAttribute::BOUND | beans::PropertyAttribute::MAYBEDEFAULT ); + rOutProperties.emplace_back( "SubPieType", + PROP_DIAGRAM_OF_PIE_TYPE, + cppu::UnoType<chart2::PieChartSubType>::get(), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT ); //new for 3D charts rOutProperties.emplace_back( "RightAngledAxes", @@ -378,21 +386,7 @@ void lcl_AddPropertiesToVector( cppu::UnoType<bool>::get(), beans::PropertyAttribute::BOUND | beans::PropertyAttribute::MAYBEDEFAULT ); - rOutProperties.emplace_back( "DataTableHBorder", - PROP_DIAGRAM_DATATABLEHBORDER, - cppu::UnoType<bool>::get(), - beans::PropertyAttribute::BOUND - | beans::PropertyAttribute::MAYBEDEFAULT ); - rOutProperties.emplace_back( "DataTableVBorder", - PROP_DIAGRAM_DATATABLEVBORDER, - cppu::UnoType<bool>::get(), - beans::PropertyAttribute::BOUND - | beans::PropertyAttribute::MAYBEDEFAULT ); - rOutProperties.emplace_back( "DataTableOutline", - PROP_DIAGRAM_DATATABLEOUTLINE, - cppu::UnoType<bool>::get(), - beans::PropertyAttribute::BOUND - | beans::PropertyAttribute::MAYBEDEFAULT ); + rOutProperties.emplace_back( "ExternalData", PROP_DIAGRAM_EXTERNALDATA, cppu::UnoType<OUString>::get(), @@ -400,45 +394,35 @@ void lcl_AddPropertiesToVector( | beans::PropertyAttribute::MAYBEVOID ); } -struct StaticDiagramWrapperPropertyArray_Initializer -{ - Sequence< Property >* operator()() - { - static Sequence< Property > aPropSeq( lcl_GetPropertySequence() ); - return &aPropSeq; - } - -private: - static uno::Sequence< Property > lcl_GetPropertySequence() - { - std::vector< css::beans::Property > aProperties; - lcl_AddPropertiesToVector( aProperties ); - ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties ); - ::chart::FillProperties::AddPropertiesToVector( aProperties ); - ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); - ::chart::SceneProperties::AddPropertiesToVector( aProperties ); - WrappedStatisticProperties::addProperties( aProperties ); - WrappedSymbolProperties::addProperties( aProperties ); - WrappedDataCaptionProperties::addProperties( aProperties ); - WrappedSplineProperties::addProperties( aProperties ); - WrappedStockProperties::addProperties( aProperties ); - WrappedAutomaticPositionProperties::addProperties( aProperties ); - - std::sort( aProperties.begin(), aProperties.end(), - ::chart::PropertyNameLess() ); - - return comphelper::containerToSequence( aProperties ); - } -}; - -struct StaticDiagramWrapperPropertyArray : public rtl::StaticAggregate< Sequence< Property >, StaticDiagramWrapperPropertyArray_Initializer > +const Sequence< Property >& StaticDiagramWrapperPropertyArray() { + static Sequence< Property > aPropSeq = []() + { + std::vector< css::beans::Property > aProperties; + lcl_AddPropertiesToVector( aProperties ); + ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties ); + ::chart::FillProperties::AddPropertiesToVector( aProperties ); + ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); + ::chart::SceneProperties::AddPropertiesToVector( aProperties ); + WrappedStatisticProperties::addProperties( aProperties ); + WrappedSymbolProperties::addProperties( aProperties ); + WrappedDataCaptionProperties::addProperties( aProperties ); + WrappedSplineProperties::addProperties( aProperties ); + WrappedStockProperties::addProperties( aProperties ); + WrappedAutomaticPositionProperties::addProperties( aProperties ); + + std::sort( aProperties.begin(), aProperties.end(), + ::chart::PropertyNameLess() ); + + return comphelper::containerToSequence( aProperties ); + }(); + return aPropSeq; }; -bool lcl_isXYChart( const Reference< chart2::XDiagram >& rDiagram ) +bool lcl_isXYChart( const rtl::Reference< ::chart::Diagram >& xDiagram ) { bool bRet = false; - Reference< chart2::XChartType > xChartType( ::chart::DiagramHelper::getChartTypeByIndex( rDiagram, 0 ) ); + rtl::Reference< ::chart::ChartType > xChartType( xDiagram->getChartTypeByIndex( 0 ) ); if( xChartType.is() ) { OUString aChartType( xChartType->getChartType() ); @@ -450,7 +434,7 @@ bool lcl_isXYChart( const Reference< chart2::XDiagram >& rDiagram ) sal_Int32 lcl_getNewAPIIndexForOldAPIIndex( sal_Int32 nOldAPIIndex - , const Reference< chart2::XDiagram >& xDiagram ) + , const rtl::Reference< ::chart::Diagram >& xDiagram ) { sal_Int32 nNewAPIIndex = nOldAPIIndex; @@ -460,29 +444,38 @@ sal_Int32 lcl_getNewAPIIndexForOldAPIIndex( nNewAPIIndex -= 1; } - std::vector< uno::Reference< chart2::XDataSeries > > aSeriesList( - ::chart::DiagramHelper::getDataSeriesFromDiagram( xDiagram ) ); + std::vector< rtl::Reference< ::chart::DataSeries > > aSeriesList = + xDiagram->getDataSeries(); if( nNewAPIIndex >= static_cast<sal_Int32>(aSeriesList.size()) ) nNewAPIIndex = -1; return nNewAPIIndex; } -OUString lcl_getDiagramType( const OUString & rTemplateServiceName ) +OUString lcl_getDiagramType( std::u16string_view rTemplateServiceName ) { - static const OUStringLiteral aPrefix(u"com.sun.star.chart2.template."); + static constexpr OUString aPrefix(u"com.sun.star.chart2.template."_ustr); - if( rTemplateServiceName.match( aPrefix )) + if( o3tl::starts_with(rTemplateServiceName, aPrefix) ) { - const OUString aName( rTemplateServiceName.copy( aPrefix.getLength())); + const std::u16string_view aName( rTemplateServiceName.substr( aPrefix.getLength())); // "Area" "StackedArea" "PercentStackedArea" "ThreeDArea" // "StackedThreeDArea" "PercentStackedThreeDArea" - if( aName.indexOf( "Area" ) != -1 ) + if( aName.find( u"Area" ) != std::u16string_view::npos ) return "com.sun.star.chart.AreaDiagram"; + // Handle bar-of-pie and pie-of-pie before simple pie + // "BarOfPie" + if( aName.find( u"BarOfPie" ) != std::u16string_view::npos ) + return "com.sun.star.chart.BarOfPieDiagram"; + + // "PieOfPie" + if( aName.find( u"PieOfPie" ) != std::u16string_view::npos ) + return "com.sun.star.chart.PieOfPieDiagram"; + // "Pie" "PieAllExploded" "ThreeDPie" "ThreeDPieAllExploded" - if( aName.indexOf( "Pie" ) != -1 ) + if( aName.find( u"Pie" ) != std::u16string_view::npos ) return "com.sun.star.chart.PieDiagram"; // "Column" "StackedColumn" "PercentStackedColumn" "ThreeDColumnDeep" @@ -491,33 +484,33 @@ OUString lcl_getDiagramType( const OUString & rTemplateServiceName ) // "PercentStackedBar" "ThreeDBarDeep" "ThreeDBarFlat" // "StackedThreeDBarFlat" "PercentStackedThreeDBarFlat" "ColumnWithLine" // "StackedColumnWithLine" - if( aName.indexOf( "Column" ) != -1 || aName.indexOf( "Bar" ) != -1 ) + if( aName.find( u"Column" ) != std::u16string_view::npos || aName.find( u"Bar" ) != std::u16string_view::npos ) return "com.sun.star.chart.BarDiagram"; // "Donut" "DonutAllExploded" "ThreeDDonut" "ThreeDDonutAllExploded" - if( aName.indexOf( "Donut" ) != -1 ) + if( aName.find( u"Donut" ) != std::u16string_view::npos ) return "com.sun.star.chart.DonutDiagram"; // "ScatterLineSymbol" "ScatterLine" "ScatterSymbol" "ThreeDScatter" - if( aName.indexOf( "Scatter" ) != -1 ) + if( aName.find( u"Scatter" ) != std::u16string_view::npos ) return "com.sun.star.chart.XYDiagram"; // "FilledNet" "StackedFilledNet" "PercentStackedFilledNet" - if( aName.indexOf( "FilledNet" ) != -1 ) + if( aName.find( u"FilledNet" ) != std::u16string_view::npos ) return "com.sun.star.chart.FilledNetDiagram"; // "Net" "NetSymbol" "NetLine" "StackedNet" "StackedNetSymbol" // "StackedNetLine" "PercentStackedNet" "PercentStackedNetSymbol" // "PercentStackedNetLine" - if( aName.indexOf( "Net" ) != -1 ) + if( aName.find( u"Net" ) != std::u16string_view::npos ) return "com.sun.star.chart.NetDiagram"; // "StockLowHighClose" "StockOpenLowHighClose" "StockVolumeLowHighClose" // "StockVolumeOpenLowHighClose" - if( aName.indexOf( "Stock" ) != -1 ) + if( aName.find( u"Stock" ) != std::u16string_view::npos ) return "com.sun.star.chart.StockDiagram"; - if( aName.indexOf( "Bubble" ) != -1 ) + if( aName.find( u"Bubble" ) != std::u16string_view::npos ) return "com.sun.star.chart.BubbleDiagram"; // Note: this must be checked after Bar, Net and Scatter @@ -526,7 +519,7 @@ OUString lcl_getDiagramType( const OUString & rTemplateServiceName ) // "PercentStackedLine" "LineSymbol" "StackedLineSymbol" // "PercentStackedLineSymbol" "ThreeDLine" "StackedThreeDLine" // "PercentStackedThreeDLine" "ThreeDLineDeep" - if( aName.indexOf( "Line" ) != -1 || aName.indexOf( "Symbol" ) != -1 ) + if( aName.find( u"Line" ) != std::u16string_view::npos || aName.find( u"Symbol" ) != std::u16string_view::npos ) return "com.sun.star.chart.LineDiagram"; OSL_FAIL( "unknown template" ); @@ -572,9 +565,8 @@ OUString lcl_getOldChartTypeName( const OUString & rNewChartTypeName ) namespace chart::wrapper { -DiagramWrapper::DiagramWrapper(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact) - : m_spChart2ModelContact(spChart2ModelContact) - , m_aEventListenerContainer(m_aMutex) +DiagramWrapper::DiagramWrapper(std::shared_ptr<Chart2ModelContact> spChart2ModelContact) + : m_spChart2ModelContact(std::move(spChart2ModelContact)) { } @@ -603,26 +595,29 @@ OUString SAL_CALL DiagramWrapper::getDiagramType() } rtl::Reference< ::chart::ChartTypeManager > xChartTypeManager = xChartDoc->getTypeManager(); - DiagramHelper::tTemplateWithServiceName aTemplateAndService = - DiagramHelper::getTemplateForDiagram( xDiagram, xChartTypeManager ); + Diagram::tTemplateWithServiceName aTemplateAndService = + xDiagram->getTemplate( xChartTypeManager ); aRet = lcl_getDiagramType( aTemplateAndService.sServiceName ); } - if( aRet.isEmpty()) + if( !aRet.isEmpty()) + return aRet; + + // none of the standard templates matched + // use first chart type + if (xDiagram) { - // none of the standard templates matched - // use first chart type - Reference< chart2::XChartType > xChartType( DiagramHelper::getChartTypeByIndex( xDiagram, 0 ) ); + rtl::Reference< ChartType > xChartType( xDiagram->getChartTypeByIndex( 0 ) ); if( xChartType.is() ) { aRet = xChartType->getChartType(); if( !aRet.isEmpty() ) aRet = lcl_getOldChartTypeName( aRet ); } - if( aRet.isEmpty()) - aRet = "com.sun.star.chart.BarDiagram"; } + if( aRet.isEmpty()) + aRet = "com.sun.star.chart.BarDiagram"; return aRet; } @@ -1066,9 +1061,8 @@ void SAL_CALL DiagramWrapper::setDefaultIllumination() // ____ XComponent ____ void SAL_CALL DiagramWrapper::dispose() { - m_aEventListenerContainer.disposeAndClear( lang::EventObject( static_cast< ::cppu::OWeakObject* >( this ))); - - MutexGuard aGuard( m_aMutex); + std::unique_lock g(m_aMutex); + m_aEventListenerContainer.disposeAndClear( g, lang::EventObject( static_cast< ::cppu::OWeakObject* >( this ))); DisposeHelper::DisposeAndClear( m_xXAxis ); DisposeHelper::DisposeAndClear( m_xYAxis ); @@ -1087,13 +1081,15 @@ void SAL_CALL DiagramWrapper::dispose() void SAL_CALL DiagramWrapper::addEventListener( const Reference< lang::XEventListener >& xListener ) { - m_aEventListenerContainer.addInterface( xListener ); + std::unique_lock g(m_aMutex); + m_aEventListenerContainer.addInterface( g, xListener ); } void SAL_CALL DiagramWrapper::removeEventListener( const Reference< lang::XEventListener >& aListener ) { - m_aEventListenerContainer.removeInterface( aListener ); + std::unique_lock g(m_aMutex); + m_aEventListenerContainer.removeInterface( g, aListener ); } namespace { @@ -1102,7 +1098,7 @@ namespace { class WrappedDataRowSourceProperty : public WrappedProperty { public: - explicit WrappedDataRowSourceProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact); + explicit WrappedDataRowSourceProperty(std::shared_ptr<Chart2ModelContact> spChart2ModelContact); virtual void setPropertyValue( const css::uno::Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override; @@ -1117,9 +1113,9 @@ private: //member } -WrappedDataRowSourceProperty::WrappedDataRowSourceProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact) +WrappedDataRowSourceProperty::WrappedDataRowSourceProperty(std::shared_ptr<Chart2ModelContact> spChart2ModelContact) : WrappedProperty("DataRowSource",OUString()) - , m_spChart2ModelContact( spChart2ModelContact ) + , m_spChart2ModelContact(std::move( spChart2ModelContact )) { m_aOuterValue = WrappedDataRowSourceProperty::getPropertyDefault( nullptr ); } @@ -1195,7 +1191,7 @@ namespace { class WrappedStackingProperty : public WrappedProperty { public: - WrappedStackingProperty(StackMode eStackMode, const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact); + WrappedStackingProperty(StackMode eStackMode, std::shared_ptr<Chart2ModelContact> spChart2ModelContact); virtual void setPropertyValue( const css::uno::Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override; @@ -1214,9 +1210,9 @@ std::shared_ptr< Chart2ModelContact > m_spChart2ModelContact; } -WrappedStackingProperty::WrappedStackingProperty(StackMode eStackMode, const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact) +WrappedStackingProperty::WrappedStackingProperty(StackMode eStackMode, std::shared_ptr<Chart2ModelContact> spChart2ModelContact) : WrappedProperty(OUString(),OUString()) - , m_spChart2ModelContact( spChart2ModelContact ) + , m_spChart2ModelContact(std::move( spChart2ModelContact )) , m_eStackMode( eStackMode ) { switch( m_eStackMode ) @@ -1240,8 +1236,8 @@ bool WrappedStackingProperty::detectInnerValue( StackMode& eStackMode ) const { bool bHasDetectableInnerValue = false; bool bIsAmbiguous = false; - eStackMode = DiagramHelper::getStackMode( m_spChart2ModelContact->getDiagram() - , bHasDetectableInnerValue, bIsAmbiguous ); + rtl::Reference<Diagram> xDiagram = m_spChart2ModelContact->getDiagram(); + eStackMode = xDiagram ? xDiagram->getStackMode( bHasDetectableInnerValue, bIsAmbiguous ) : StackMode::NONE; return bHasDetectableInnerValue; } @@ -1269,7 +1265,7 @@ void WrappedStackingProperty::setPropertyValue( const Any& rOuterValue, const Re if( xDiagram.is() ) { StackMode eNewStackMode = bNewValue ? m_eStackMode : StackMode::NONE; - DiagramHelper::setStackMode( xDiagram, eNewStackMode ); + xDiagram->setStackMode( eNewStackMode ); } } @@ -1297,7 +1293,7 @@ namespace { class WrappedDim3DProperty : public WrappedProperty { public: - explicit WrappedDim3DProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact); + explicit WrappedDim3DProperty(std::shared_ptr<Chart2ModelContact> spChart2ModelContact); virtual void setPropertyValue( const css::uno::Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override; @@ -1312,9 +1308,9 @@ private: //member } -WrappedDim3DProperty::WrappedDim3DProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact) +WrappedDim3DProperty::WrappedDim3DProperty(std::shared_ptr<Chart2ModelContact> spChart2ModelContact) : WrappedProperty("Dim3D",OUString()) - , m_spChart2ModelContact( spChart2ModelContact ) + , m_spChart2ModelContact(std::move( spChart2ModelContact )) { m_aOuterValue = WrappedDim3DProperty::getPropertyDefault( nullptr ); } @@ -1331,9 +1327,9 @@ void WrappedDim3DProperty::setPropertyValue( const Any& rOuterValue, const Refer if( !xDiagram.is() ) return; - bool bOld3D = DiagramHelper::getDimension( xDiagram ) == 3; + bool bOld3D = xDiagram->getDimension() == 3; if( bOld3D != bNew3D ) - DiagramHelper::setDimension( xDiagram, bNew3D ? 3 : 2 ); + xDiagram->setDimension( bNew3D ? 3 : 2 ); } Any WrappedDim3DProperty::getPropertyValue( const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const @@ -1341,7 +1337,7 @@ Any WrappedDim3DProperty::getPropertyValue( const Reference< beans::XPropertySet rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); if( xDiagram.is() ) { - bool b3D = DiagramHelper::getDimension( xDiagram ) == 3; + bool b3D = xDiagram->getDimension() == 3; m_aOuterValue <<= b3D; } return m_aOuterValue; @@ -1360,7 +1356,7 @@ namespace { class WrappedVerticalProperty : public WrappedProperty { public: - explicit WrappedVerticalProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact); + explicit WrappedVerticalProperty(std::shared_ptr<Chart2ModelContact> spChart2ModelContact); virtual void setPropertyValue( const css::uno::Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override; @@ -1375,9 +1371,9 @@ private: //member } -WrappedVerticalProperty::WrappedVerticalProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact) +WrappedVerticalProperty::WrappedVerticalProperty(std::shared_ptr<Chart2ModelContact> spChart2ModelContact) : WrappedProperty("Vertical",OUString()) - , m_spChart2ModelContact( spChart2ModelContact ) + , m_spChart2ModelContact(std::move( spChart2ModelContact )) { m_aOuterValue = WrappedVerticalProperty::getPropertyDefault( nullptr ); } @@ -1396,9 +1392,9 @@ void WrappedVerticalProperty::setPropertyValue( const Any& rOuterValue, const Re bool bFound = false; bool bAmbiguous = false; - bool bOldVertical = DiagramHelper::getVertical( xDiagram, bFound, bAmbiguous ); + bool bOldVertical = xDiagram->getVertical( bFound, bAmbiguous ); if( bFound && ( bOldVertical != bNewVertical || bAmbiguous ) ) - DiagramHelper::setVertical( xDiagram, bNewVertical ); + xDiagram->setVertical( bNewVertical ); } Any WrappedVerticalProperty::getPropertyValue( const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const @@ -1408,7 +1404,7 @@ Any WrappedVerticalProperty::getPropertyValue( const Reference< beans::XProperty { bool bFound = false; bool bAmbiguous = false; - bool bVertical = DiagramHelper::getVertical( xDiagram, bFound, bAmbiguous ); + bool bVertical = xDiagram->getVertical( bFound, bAmbiguous ); if( bFound ) m_aOuterValue <<= bVertical; } @@ -1428,7 +1424,7 @@ namespace { class WrappedNumberOfLinesProperty : public WrappedProperty { public: - explicit WrappedNumberOfLinesProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact); + explicit WrappedNumberOfLinesProperty(std::shared_ptr<Chart2ModelContact> spChart2ModelContact); virtual void setPropertyValue( const css::uno::Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override; @@ -1446,9 +1442,9 @@ private: //member } -WrappedNumberOfLinesProperty::WrappedNumberOfLinesProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact) +WrappedNumberOfLinesProperty::WrappedNumberOfLinesProperty(std::shared_ptr<Chart2ModelContact> spChart2ModelContact) : WrappedProperty("NumberOfLines",OUString()) - , m_spChart2ModelContact( spChart2ModelContact ) + , m_spChart2ModelContact(std::move( spChart2ModelContact )) , m_aOuterValue( getPropertyDefault(nullptr) ) { } @@ -1461,13 +1457,13 @@ bool WrappedNumberOfLinesProperty::detectInnerValue( uno::Any& rInnerValue ) con rtl::Reference< ChartModel > xChartDoc( m_spChart2ModelContact->getDocumentModel() ); if( xDiagram.is() && xChartDoc.is() ) { - std::vector< uno::Reference< chart2::XDataSeries > > aSeriesVector( - DiagramHelper::getDataSeriesFromDiagram( xDiagram ) ); + std::vector< rtl::Reference< DataSeries > > aSeriesVector = + xDiagram->getDataSeries(); if( !aSeriesVector.empty() ) { rtl::Reference< ::chart::ChartTypeManager > xChartTypeManager = xChartDoc->getTypeManager(); - DiagramHelper::tTemplateWithServiceName aTemplateAndService = - DiagramHelper::getTemplateForDiagram( xDiagram, xChartTypeManager ); + Diagram::tTemplateWithServiceName aTemplateAndService = + xDiagram->getTemplate( xChartTypeManager ); if( aTemplateAndService.sServiceName == "com.sun.star.chart2.template.ColumnWithLine" ) { try @@ -1498,13 +1494,15 @@ void WrappedNumberOfLinesProperty::setPropertyValue( const Any& rOuterValue, con rtl::Reference< ChartModel > xChartDoc( m_spChart2ModelContact->getDocumentModel() ); rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); - sal_Int32 nDimension = ::chart::DiagramHelper::getDimension( xDiagram ); - if( !(xChartDoc.is() && xDiagram.is() && nDimension == 2) ) + if( !xChartDoc || !xDiagram ) + return; + sal_Int32 nDimension = xDiagram->getDimension(); + if( nDimension != 2 ) return; rtl::Reference< ::chart::ChartTypeManager > xChartTypeManager = xChartDoc->getTypeManager(); - DiagramHelper::tTemplateWithServiceName aTemplateAndService = - DiagramHelper::getTemplateForDiagram( xDiagram, xChartTypeManager ); + Diagram::tTemplateWithServiceName aTemplateAndService = + xDiagram->getTemplate( xChartTypeManager ); rtl::Reference< ChartTypeTemplate > xTemplate; if( aTemplateAndService.sServiceName == "com.sun.star.chart2.template.ColumnWithLine" ) @@ -1575,7 +1573,7 @@ namespace { class WrappedAttributedDataPointsProperty : public WrappedProperty { public: - explicit WrappedAttributedDataPointsProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact); + explicit WrappedAttributedDataPointsProperty(std::shared_ptr<Chart2ModelContact> spChart2ModelContact); virtual void setPropertyValue( const css::uno::Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override; @@ -1590,9 +1588,9 @@ private: //member } -WrappedAttributedDataPointsProperty::WrappedAttributedDataPointsProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact) +WrappedAttributedDataPointsProperty::WrappedAttributedDataPointsProperty(std::shared_ptr<Chart2ModelContact> spChart2ModelContact) : WrappedProperty("AttributedDataPoints",OUString()) - , m_spChart2ModelContact( spChart2ModelContact ) + , m_spChart2ModelContact(std::move( spChart2ModelContact )) { m_aOuterValue = WrappedAttributedDataPointsProperty::getPropertyDefault( nullptr ); } @@ -1610,25 +1608,21 @@ void WrappedAttributedDataPointsProperty::setPropertyValue( const Any& rOuterVal if( !xDiagram ) return; - std::vector< Reference< chart2::XDataSeries > > aSeriesVector( - ::chart::DiagramHelper::getDataSeriesFromDiagram( xDiagram ) ); + std::vector< rtl::Reference< DataSeries > > aSeriesVector = + xDiagram->getDataSeries(); sal_Int32 i = 0; for (auto const& series : aSeriesVector) { - Reference< beans::XPropertySet > xProp(series, uno::UNO_QUERY); - if( xProp.is()) + uno::Any aVal; + if( i < aNewValue.getLength() ) + aVal <<= aNewValue[i]; + else { - uno::Any aVal; - if( i < aNewValue.getLength() ) - aVal <<= aNewValue[i]; - else - { - //set empty sequence - uno::Sequence< sal_Int32 > aSeq; - aVal <<= aSeq; - } - xProp->setPropertyValue( "AttributedDataPoints", aVal ); + //set empty sequence + uno::Sequence< sal_Int32 > aSeq; + aVal <<= aSeq; } + series->setFastPropertyValue( PROP_DATASERIES_ATTRIBUTED_DATA_POINTS, aVal ); // "AttributedDataPoints" ++i; } } @@ -1639,23 +1633,19 @@ Any WrappedAttributedDataPointsProperty::getPropertyValue( const Reference< bean if( xDiagram ) { - std::vector< Reference< chart2::XDataSeries > > aSeriesVector( - ::chart::DiagramHelper::getDataSeriesFromDiagram( xDiagram ) ); + std::vector< rtl::Reference< DataSeries > > aSeriesVector = + xDiagram->getDataSeries(); uno::Sequence< uno::Sequence< sal_Int32 > > aResult( aSeriesVector.size() ); auto aResultRange = asNonConstRange(aResult); sal_Int32 i = 0; for (auto const& series : aSeriesVector) { - Reference< beans::XPropertySet > xProp(series, uno::UNO_QUERY); - if( xProp.is()) - { - uno::Any aVal( - xProp->getPropertyValue("AttributedDataPoints")); - uno::Sequence< sal_Int32 > aSeq; - if( aVal >>= aSeq ) - aResultRange[ i ] = aSeq; - } + uno::Any aVal( + series->getFastPropertyValue(PROP_DATASERIES_ATTRIBUTED_DATA_POINTS)); // "AttributedDataPoints" + uno::Sequence< sal_Int32 > aSeq; + if( aVal >>= aSeq ) + aResultRange[ i ] = aSeq; ++i; } m_aOuterValue <<= aResult; @@ -1677,7 +1667,7 @@ namespace { class WrappedSolidTypeProperty : public WrappedProperty { public: - explicit WrappedSolidTypeProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact); + explicit WrappedSolidTypeProperty(std::shared_ptr<Chart2ModelContact> spChart2ModelContact); virtual void setPropertyValue( const css::uno::Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override; @@ -1692,9 +1682,9 @@ private: //member } -WrappedSolidTypeProperty::WrappedSolidTypeProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact) +WrappedSolidTypeProperty::WrappedSolidTypeProperty(std::shared_ptr<Chart2ModelContact> spChart2ModelContact) : WrappedProperty( "SolidType", OUString() ) - , m_spChart2ModelContact( spChart2ModelContact ) + , m_spChart2ModelContact(std::move( spChart2ModelContact )) { m_aOuterValue = WrappedSolidTypeProperty::getPropertyDefault( nullptr ); } @@ -1713,9 +1703,9 @@ void WrappedSolidTypeProperty::setPropertyValue( const Any& rOuterValue, const R bool bFound = false; bool bAmbiguous = false; - sal_Int32 nOldSolidType = DiagramHelper::getGeometry3D( xDiagram, bFound, bAmbiguous ); + sal_Int32 nOldSolidType = xDiagram->getGeometry3D( bFound, bAmbiguous ); if( bFound && ( nOldSolidType != nNewSolidType || bAmbiguous ) ) - DiagramHelper::setGeometry3D( xDiagram, nNewSolidType ); + xDiagram->setGeometry3D( nNewSolidType ); } Any WrappedSolidTypeProperty::getPropertyValue( const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const @@ -1725,7 +1715,7 @@ Any WrappedSolidTypeProperty::getPropertyValue( const Reference< beans::XPropert { bool bFound = false; bool bAmbiguous = false; - sal_Int32 nGeometry = DiagramHelper::getGeometry3D( xDiagram, bFound, bAmbiguous ); + sal_Int32 nGeometry = xDiagram->getGeometry3D( bFound, bAmbiguous ); if( bFound ) m_aOuterValue <<= nGeometry; } @@ -1807,7 +1797,7 @@ namespace { class WrappedIncludeHiddenCellsProperty : public WrappedProperty { public: - explicit WrappedIncludeHiddenCellsProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact); + explicit WrappedIncludeHiddenCellsProperty(std::shared_ptr<Chart2ModelContact> spChart2ModelContact); virtual void setPropertyValue( const css::uno::Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override; virtual Any getPropertyValue(const Reference<beans::XPropertySet>& xInnerPropertySet) const override; @@ -1818,9 +1808,9 @@ private: //member } -WrappedIncludeHiddenCellsProperty::WrappedIncludeHiddenCellsProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact) +WrappedIncludeHiddenCellsProperty::WrappedIncludeHiddenCellsProperty(std::shared_ptr<Chart2ModelContact> spChart2ModelContact) : WrappedProperty("IncludeHiddenCells","IncludeHiddenCells") - , m_spChart2ModelContact( spChart2ModelContact ) + , m_spChart2ModelContact(std::move( spChart2ModelContact )) { } @@ -1859,7 +1849,7 @@ Reference< beans::XPropertySet > DiagramWrapper::getInnerPropertySet() const Sequence< beans::Property >& DiagramWrapper::getPropertySequence() { - return *StaticDiagramWrapperPropertyArray::get(); + return StaticDiagramWrapperPropertyArray(); } std::vector< std::unique_ptr<WrappedProperty> > DiagramWrapper::createWrappedProperties() diff --git a/chart2/source/controller/chartapiwrapper/DiagramWrapper.hxx b/chart2/source/controller/chartapiwrapper/DiagramWrapper.hxx index bef53a739386..3a3a8383de05 100644 --- a/chart2/source/controller/chartapiwrapper/DiagramWrapper.hxx +++ b/chart2/source/controller/chartapiwrapper/DiagramWrapper.hxx @@ -20,7 +20,7 @@ #include <WrappedPropertySet.hxx> -#include <comphelper/interfacecontainer3.hxx> +#include <comphelper/interfacecontainer4.hxx> #include <com/sun/star/chart/XDiagramPositioning.hpp> #include <com/sun/star/chart2/XDiagramProvider.hpp> #include <com/sun/star/chart/XDiagram.hpp> @@ -63,7 +63,7 @@ class DiagramWrapper : public cppu::ImplInheritanceHelper< > { public: - explicit DiagramWrapper(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact); + explicit DiagramWrapper(std::shared_ptr<Chart2ModelContact> spChart2ModelContact); virtual ~DiagramWrapper() override; /// XServiceInfo declarations @@ -186,7 +186,7 @@ protected: private: std::shared_ptr< Chart2ModelContact > m_spChart2ModelContact; - ::comphelper::OInterfaceContainerHelper3<css::lang::XEventListener> m_aEventListenerContainer; + ::comphelper::OInterfaceContainerHelper4<css::lang::XEventListener> m_aEventListenerContainer; css::uno::Reference< css::chart::XAxis > m_xXAxis; diff --git a/chart2/source/controller/chartapiwrapper/GridWrapper.cxx b/chart2/source/controller/chartapiwrapper/GridWrapper.cxx index 0cf33baa5848..5f75aa686a69 100644 --- a/chart2/source/controller/chartapiwrapper/GridWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/GridWrapper.cxx @@ -30,51 +30,20 @@ #include <comphelper/sequence.hxx> #include <cppuhelper/supportsservice.hxx> #include <algorithm> -#include <tools/diagnose_ex.h> +#include <utility> +#include <comphelper/diagnose_ex.hxx> using namespace ::com::sun::star; -using namespace ::com::sun::star::chart2; using ::com::sun::star::beans::Property; using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::Sequence; -namespace -{ - -struct StaticGridWrapperPropertyArray_Initializer -{ - Sequence< Property >* operator()() - { - static Sequence< Property > aPropSeq( lcl_GetPropertySequence() ); - return &aPropSeq; - } -private: - static Sequence< Property > lcl_GetPropertySequence() - { - std::vector< css::beans::Property > aProperties; - ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties ); - ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); - - std::sort( aProperties.begin(), aProperties.end(), - ::chart::PropertyNameLess() ); - - return comphelper::containerToSequence( aProperties ); - } -}; - -struct StaticGridWrapperPropertyArray : public rtl::StaticAggregate< Sequence< Property >, StaticGridWrapperPropertyArray_Initializer > -{ -}; - -} // anonymous namespace - namespace chart::wrapper { -GridWrapper::GridWrapper(tGridType eType, const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact) - : m_spChart2ModelContact(spChart2ModelContact) - , m_aEventListenerContainer(m_aMutex) +GridWrapper::GridWrapper(tGridType eType, std::shared_ptr<Chart2ModelContact> spChart2ModelContact) + : m_spChart2ModelContact(std::move(spChart2ModelContact)) , m_eType(eType) { } @@ -107,8 +76,9 @@ void GridWrapper::getDimensionAndSubGridBool( tGridType eType, sal_Int32& rnDime // ____ XComponent ____ void SAL_CALL GridWrapper::dispose() { + std::unique_lock g(m_aMutex); Reference< uno::XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) ); - m_aEventListenerContainer.disposeAndClear( lang::EventObject( xSource ) ); + m_aEventListenerContainer.disposeAndClear( g, lang::EventObject( xSource ) ); clearWrappedPropertySet(); } @@ -116,13 +86,15 @@ void SAL_CALL GridWrapper::dispose() void SAL_CALL GridWrapper::addEventListener( const Reference< lang::XEventListener >& xListener ) { - m_aEventListenerContainer.addInterface( xListener ); + std::unique_lock g(m_aMutex); + m_aEventListenerContainer.addInterface( g, xListener ); } void SAL_CALL GridWrapper::removeEventListener( const Reference< lang::XEventListener >& aListener ) { - m_aEventListenerContainer.removeInterface( aListener ); + std::unique_lock g(m_aMutex); + m_aEventListenerContainer.removeInterface( g, aListener ); } // WrappedPropertySet @@ -133,14 +105,14 @@ Reference< beans::XPropertySet > GridWrapper::getInnerPropertySet() try { rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); - uno::Reference< XCoordinateSystem > xCooSys( AxisHelper::getCoordinateSystemByIndex( xDiagram, 0 /*nCooSysIndex*/ ) ); + rtl::Reference< BaseCoordinateSystem > xCooSys( AxisHelper::getCoordinateSystemByIndex( xDiagram, 0 /*nCooSysIndex*/ ) ); sal_Int32 nDimensionIndex = 1; bool bSubGrid = false; getDimensionAndSubGridBool( m_eType, nDimensionIndex, bSubGrid ); sal_Int32 nSubGridIndex = bSubGrid ? 0 : -1; - xRet.set( AxisHelper::getGridProperties( xCooSys , nDimensionIndex, MAIN_AXIS_INDEX, nSubGridIndex ) ); + xRet = AxisHelper::getGridProperties( xCooSys , nDimensionIndex, MAIN_AXIS_INDEX, nSubGridIndex ); } catch( const uno::Exception & ) { @@ -151,7 +123,18 @@ Reference< beans::XPropertySet > GridWrapper::getInnerPropertySet() const Sequence< beans::Property >& GridWrapper::getPropertySequence() { - return *StaticGridWrapperPropertyArray::get(); + static Sequence< Property > aPropSeq = []() + { + std::vector< css::beans::Property > aProperties; + ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties ); + ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); + + std::sort( aProperties.begin(), aProperties.end(), + ::chart::PropertyNameLess() ); + + return comphelper::containerToSequence( aProperties ); + }(); + return aPropSeq; } std::vector< std::unique_ptr<WrappedProperty> > GridWrapper::createWrappedProperties() diff --git a/chart2/source/controller/chartapiwrapper/GridWrapper.hxx b/chart2/source/controller/chartapiwrapper/GridWrapper.hxx index 0a16368e9ccf..c978f3bb8d83 100644 --- a/chart2/source/controller/chartapiwrapper/GridWrapper.hxx +++ b/chart2/source/controller/chartapiwrapper/GridWrapper.hxx @@ -20,7 +20,7 @@ #include <WrappedPropertySet.hxx> #include <cppuhelper/implbase.hxx> -#include <comphelper/interfacecontainer3.hxx> +#include <comphelper/interfacecontainer4.hxx> #include <com/sun/star/lang/XComponent.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> @@ -48,7 +48,7 @@ public: Z_MINOR_GRID }; - GridWrapper(tGridType eType, const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact); + GridWrapper(tGridType eType, std::shared_ptr<Chart2ModelContact> spChart2ModelContact); virtual ~GridWrapper() override; static void getDimensionAndSubGridBool( tGridType eType, sal_Int32& rnDimensionIndex, bool& rbSubGrid ); @@ -71,7 +71,7 @@ protected: private: std::shared_ptr< Chart2ModelContact > m_spChart2ModelContact; - ::comphelper::OInterfaceContainerHelper3<css::lang::XEventListener> m_aEventListenerContainer; + ::comphelper::OInterfaceContainerHelper4<css::lang::XEventListener> m_aEventListenerContainer; tGridType m_eType; }; diff --git a/chart2/source/controller/chartapiwrapper/LegendWrapper.cxx b/chart2/source/controller/chartapiwrapper/LegendWrapper.cxx index ca5a25005152..9ec8f02819ef 100644 --- a/chart2/source/controller/chartapiwrapper/LegendWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/LegendWrapper.cxx @@ -26,7 +26,6 @@ #include <com/sun/star/chart2/LegendPosition.hpp> #include <com/sun/star/chart/ChartLegendExpansion.hpp> #include <com/sun/star/chart2/RelativePosition.hpp> -#include <com/sun/star/chart2/XDiagram.hpp> #include <CharacterProperties.hxx> #include <LinePropertiesHelper.hxx> @@ -39,10 +38,10 @@ #include "WrappedScaleTextProperties.hxx" #include <algorithm> +#include <utility> using namespace ::com::sun::star; using ::com::sun::star::beans::Property; -using ::osl::MutexGuard; using ::com::sun::star::uno::Any; using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::Sequence; @@ -225,35 +224,25 @@ void lcl_AddPropertiesToVector( beans::PropertyAttribute::MAYBEDEFAULT ); } -struct StaticLegendWrapperPropertyArray_Initializer -{ - Sequence< Property >* operator()() - { - static Sequence< Property > aPropSeq( lcl_GetPropertySequence() ); - return &aPropSeq; - } - -private: - static Sequence< Property > lcl_GetPropertySequence() - { - std::vector< css::beans::Property > aProperties; - lcl_AddPropertiesToVector( aProperties ); - ::chart::CharacterProperties::AddPropertiesToVector( aProperties ); - ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties ); - ::chart::FillProperties::AddPropertiesToVector( aProperties ); - ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); - ::chart::wrapper::WrappedAutomaticPositionProperties::addProperties( aProperties ); - ::chart::wrapper::WrappedScaleTextProperties::addProperties( aProperties ); - - std::sort( aProperties.begin(), aProperties.end(), - ::chart::PropertyNameLess() ); - - return comphelper::containerToSequence( aProperties ); - } -}; - -struct StaticLegendWrapperPropertyArray : public rtl::StaticAggregate< Sequence< Property >, StaticLegendWrapperPropertyArray_Initializer > +const Sequence< Property >& StaticLegendWrapperPropertyArray() { + static Sequence< Property > aPropSeq = []() + { + std::vector< css::beans::Property > aProperties; + lcl_AddPropertiesToVector( aProperties ); + ::chart::CharacterProperties::AddPropertiesToVector( aProperties ); + ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties ); + ::chart::FillProperties::AddPropertiesToVector( aProperties ); + ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); + ::chart::wrapper::WrappedAutomaticPositionProperties::addProperties( aProperties ); + ::chart::wrapper::WrappedScaleTextProperties::addProperties( aProperties ); + + std::sort( aProperties.begin(), aProperties.end(), + ::chart::PropertyNameLess() ); + + return comphelper::containerToSequence( aProperties ); + }(); + return aPropSeq; }; } // anonymous namespace @@ -261,9 +250,8 @@ struct StaticLegendWrapperPropertyArray : public rtl::StaticAggregate< Sequence< namespace chart::wrapper { -LegendWrapper::LegendWrapper(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact) - : m_spChart2ModelContact(spChart2ModelContact) - , m_aEventListenerContainer(m_aMutex) +LegendWrapper::LegendWrapper(std::shared_ptr<Chart2ModelContact> spChart2ModelContact) + : m_spChart2ModelContact(std::move(spChart2ModelContact)) { } @@ -322,23 +310,25 @@ OUString SAL_CALL LegendWrapper::getShapeType() // ____ XComponent ____ void SAL_CALL LegendWrapper::dispose() { + std::unique_lock g(m_aMutex); Reference< uno::XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) ); - m_aEventListenerContainer.disposeAndClear( lang::EventObject( xSource ) ); + m_aEventListenerContainer.disposeAndClear( g, lang::EventObject( xSource ) ); - MutexGuard aGuard( m_aMutex); clearWrappedPropertySet(); } void SAL_CALL LegendWrapper::addEventListener( const Reference< lang::XEventListener >& xListener ) { - m_aEventListenerContainer.addInterface( xListener ); + std::unique_lock g(m_aMutex); + m_aEventListenerContainer.addInterface( g, xListener ); } void SAL_CALL LegendWrapper::removeEventListener( const Reference< lang::XEventListener >& aListener ) { - m_aEventListenerContainer.removeInterface( aListener ); + std::unique_lock g(m_aMutex); + m_aEventListenerContainer.removeInterface( g, aListener ); } //ReferenceSizePropertyProvider @@ -379,7 +369,7 @@ Reference< beans::XPropertySet > LegendWrapper::getInnerPropertySet() const Sequence< beans::Property >& LegendWrapper::getPropertySequence() { - return *StaticLegendWrapperPropertyArray::get(); + return StaticLegendWrapperPropertyArray(); } std::vector< std::unique_ptr<WrappedProperty> > LegendWrapper::createWrappedProperties() diff --git a/chart2/source/controller/chartapiwrapper/LegendWrapper.hxx b/chart2/source/controller/chartapiwrapper/LegendWrapper.hxx index 128c5fbcf970..5b4deac2a1f9 100644 --- a/chart2/source/controller/chartapiwrapper/LegendWrapper.hxx +++ b/chart2/source/controller/chartapiwrapper/LegendWrapper.hxx @@ -21,7 +21,7 @@ #include <WrappedPropertySet.hxx> #include "ReferenceSizePropertyProvider.hxx" #include <cppuhelper/implbase.hxx> -#include <comphelper/interfacecontainer3.hxx> +#include <comphelper/interfacecontainer4.hxx> #include <com/sun/star/drawing/XShape.hpp> #include <com/sun/star/lang/XComponent.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> @@ -42,7 +42,7 @@ class LegendWrapper : public ::cppu::ImplInheritanceHelper< , public ReferenceSizePropertyProvider { public: - explicit LegendWrapper(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact); + explicit LegendWrapper(std::shared_ptr<Chart2ModelContact> spChart2ModelContact); virtual ~LegendWrapper() override; /// XServiceInfo declarations @@ -79,7 +79,7 @@ protected: private: std::shared_ptr< Chart2ModelContact > m_spChart2ModelContact; - ::comphelper::OInterfaceContainerHelper3<css::lang::XEventListener> m_aEventListenerContainer; + ::comphelper::OInterfaceContainerHelper4<css::lang::XEventListener> m_aEventListenerContainer; }; } // namespace chart::wrapper diff --git a/chart2/source/controller/chartapiwrapper/MinMaxLineWrapper.cxx b/chart2/source/controller/chartapiwrapper/MinMaxLineWrapper.cxx index 516a96b2a042..d0cb5eab6552 100644 --- a/chart2/source/controller/chartapiwrapper/MinMaxLineWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/MinMaxLineWrapper.cxx @@ -19,21 +19,19 @@ #include "MinMaxLineWrapper.hxx" #include "Chart2ModelContact.hxx" -#include <DiagramHelper.hxx> +#include <ChartType.hxx> #include <servicenames_charttypes.hxx> #include <cppuhelper/propshlp.hxx> #include <cppuhelper/supportsservice.hxx> -#include <com/sun/star/chart2/XChartType.hpp> -#include <com/sun/star/chart2/XDataSeriesContainer.hpp> #include <com/sun/star/drawing/LineJoint.hpp> #include <comphelper/sequence.hxx> - +#include <DataSeries.hxx> #include <LinePropertiesHelper.hxx> #include <UserDefinedProperties.hxx> -#include <tools/diagnose_ex.h> +#include <utility> +#include <comphelper/diagnose_ex.hxx> using namespace ::com::sun::star; -using namespace ::com::sun::star::chart2; using ::com::sun::star::beans::Property; using ::com::sun::star::uno::Reference; @@ -43,72 +41,34 @@ using ::com::sun::star::uno::Any; namespace { -struct StaticMinMaxLineWrapperDefaults_Initializer -{ - ::chart::tPropertyValueMap* operator()() - { - static ::chart::tPropertyValueMap aStaticDefaults; - ::chart::LinePropertiesHelper::AddDefaultsToMap( aStaticDefaults ); - return &aStaticDefaults; - } -}; - -struct StaticMinMaxLineWrapperDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticMinMaxLineWrapperDefaults_Initializer > -{ -}; - -struct StaticMinMaxLineWrapperPropertyArray_Initializer +Sequence< Property >& StaticMinMaxLineWrapperPropertyArray() { - Sequence< Property >* operator()() - { - static Sequence< Property > aPropSeq( lcl_GetPropertySequence() ); - return &aPropSeq; - } - -private: - static Sequence< Property > lcl_GetPropertySequence() - { - std::vector< css::beans::Property > aProperties; - - ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties ); - ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); - - std::sort( aProperties.begin(), aProperties.end(), - ::chart::PropertyNameLess() ); - - return comphelper::containerToSequence( aProperties ); - } -}; + static Sequence< Property > aPropSeq = []() + { + std::vector< css::beans::Property > aProperties; -struct StaticMinMaxLineWrapperPropertyArray : public rtl::StaticAggregate< Sequence< Property >, StaticMinMaxLineWrapperPropertyArray_Initializer > -{ -}; + ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties ); + ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); -struct StaticMinMaxLineWrapperInfoHelper_Initializer -{ - ::cppu::OPropertyArrayHelper* operator()() - { - static ::cppu::OPropertyArrayHelper aPropHelper( *StaticMinMaxLineWrapperPropertyArray::get() ); - return &aPropHelper; - } -}; + std::sort( aProperties.begin(), aProperties.end(), + ::chart::PropertyNameLess() ); -struct StaticMinMaxLineWrapperInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticMinMaxLineWrapperInfoHelper_Initializer > -{ + return comphelper::containerToSequence( aProperties ); + }(); + return aPropSeq; }; -struct StaticMinMaxLineWrapperInfo_Initializer +::cppu::OPropertyArrayHelper& StaticMinMaxLineWrapperInfoHelper() { - uno::Reference< beans::XPropertySetInfo >* operator()() - { - static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo( - ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticMinMaxLineWrapperInfoHelper::get() ) ); - return &xPropertySetInfo; - } + static ::cppu::OPropertyArrayHelper aPropHelper( StaticMinMaxLineWrapperPropertyArray() ); + return aPropHelper; }; -struct StaticMinMaxLineWrapperInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticMinMaxLineWrapperInfo_Initializer > +uno::Reference< beans::XPropertySetInfo >& StaticMinMaxLineWrapperInfo() { + static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo( + ::cppu::OPropertySetHelper::createPropertySetInfo( StaticMinMaxLineWrapperInfoHelper() ) ); + return xPropertySetInfo; }; } // anonymous namespace @@ -116,9 +76,8 @@ struct StaticMinMaxLineWrapperInfo : public rtl::StaticAggregate< uno::Reference namespace chart::wrapper { -MinMaxLineWrapper::MinMaxLineWrapper(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact) - : m_spChart2ModelContact( spChart2ModelContact ) - , m_aEventListenerContainer( m_aMutex ) +MinMaxLineWrapper::MinMaxLineWrapper(std::shared_ptr<Chart2ModelContact> spChart2ModelContact) + : m_spChart2ModelContact(std::move( spChart2ModelContact )) , m_aWrappedLineJointProperty( "LineJoint", uno::Any( drawing::LineJoint_NONE )) { } @@ -130,58 +89,53 @@ MinMaxLineWrapper::~MinMaxLineWrapper() // ____ XComponent ____ void SAL_CALL MinMaxLineWrapper::dispose() { + std::unique_lock g(m_aMutex); Reference< uno::XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) ); - m_aEventListenerContainer.disposeAndClear( lang::EventObject( xSource ) ); + m_aEventListenerContainer.disposeAndClear( g, lang::EventObject( xSource ) ); } void SAL_CALL MinMaxLineWrapper::addEventListener( const Reference< lang::XEventListener >& xListener ) { - m_aEventListenerContainer.addInterface( xListener ); + std::unique_lock g(m_aMutex); + m_aEventListenerContainer.addInterface( g, xListener ); } void SAL_CALL MinMaxLineWrapper::removeEventListener( const Reference< lang::XEventListener >& aListener ) { - m_aEventListenerContainer.removeInterface( aListener ); + std::unique_lock g(m_aMutex); + m_aEventListenerContainer.removeInterface( g, aListener ); } //XPropertySet uno::Reference< beans::XPropertySetInfo > SAL_CALL MinMaxLineWrapper::getPropertySetInfo() { - return *StaticMinMaxLineWrapperInfo::get(); + return StaticMinMaxLineWrapperInfo(); } void SAL_CALL MinMaxLineWrapper::setPropertyValue( const OUString& rPropertyName, const uno::Any& rValue ) { - Reference< beans::XPropertySet > xPropSet; - rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); - const Sequence< Reference< chart2::XChartType > > aTypes( - ::chart::DiagramHelper::getChartTypesFromDiagram( xDiagram ) ); - for( Reference< chart2::XChartType > const & xType : aTypes ) + const std::vector< rtl::Reference< ChartType > > & aTypes = xDiagram->getChartTypes(); + for( rtl::Reference< ChartType > const & xType : aTypes ) { if( xType->getChartType() == CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK ) { - Reference< chart2::XDataSeriesContainer > xSeriesContainer(xType,uno::UNO_QUERY); - if( xSeriesContainer.is() ) + const std::vector< rtl::Reference< DataSeries > > & aSeriesSeq( xType->getDataSeries2() ); + if(!aSeriesSeq.empty()) { - Sequence< Reference< chart2::XDataSeries > > aSeriesSeq( xSeriesContainer->getDataSeries() ); - if(aSeriesSeq.hasElements()) + if(aSeriesSeq[0].is()) { - xPropSet.set(aSeriesSeq[0],uno::UNO_QUERY); - if(xPropSet.is()) - { - if( rPropertyName == "LineColor" ) - xPropSet->setPropertyValue( "Color", rValue ); - else if( rPropertyName == "LineTransparence" ) - xPropSet->setPropertyValue( "Transparency", rValue ); - else if( rPropertyName == m_aWrappedLineJointProperty.getOuterName() ) - m_aWrappedLineJointProperty.setPropertyValue( rValue, xPropSet ); - else - xPropSet->setPropertyValue( rPropertyName, rValue ); - return; - } + if( rPropertyName == "LineColor" ) + aSeriesSeq[0]->setPropertyValue( "Color", rValue ); + else if( rPropertyName == "LineTransparence" ) + aSeriesSeq[0]->setPropertyValue( "Transparency", rValue ); + else if( rPropertyName == m_aWrappedLineJointProperty.getOuterName() ) + m_aWrappedLineJointProperty.setPropertyValue( rValue, aSeriesSeq[0] ); + else + aSeriesSeq[0]->setPropertyValue( rPropertyName, rValue ); + return; } } } @@ -191,24 +145,19 @@ uno::Any SAL_CALL MinMaxLineWrapper::getPropertyValue( const OUString& rProperty { Any aRet; - Reference< beans::XPropertySet > xPropSet; + rtl::Reference< DataSeries > xPropSet; rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); - const Sequence< Reference< chart2::XChartType > > aTypes( - ::chart::DiagramHelper::getChartTypesFromDiagram( xDiagram ) ); - for( Reference< chart2::XChartType > const & xType : aTypes ) + const std::vector< rtl::Reference< ChartType > > aTypes = xDiagram->getChartTypes(); + for( rtl::Reference< ChartType > const & xType : aTypes ) { if( xType->getChartType() == CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK ) { - Reference< chart2::XDataSeriesContainer > xSeriesContainer(xType,uno::UNO_QUERY); - if( xSeriesContainer.is() ) + const std::vector< rtl::Reference< DataSeries > > & aSeriesSeq( xType->getDataSeries2() ); + if(!aSeriesSeq.empty()) { - Sequence< Reference< chart2::XDataSeries > > aSeriesSeq( xSeriesContainer->getDataSeries() ); - if(aSeriesSeq.hasElements()) - { - xPropSet.set(aSeriesSeq[0],uno::UNO_QUERY); - break; - } + xPropSet = aSeriesSeq[0]; + break; } } } @@ -332,9 +281,14 @@ void SAL_CALL MinMaxLineWrapper::setPropertyToDefault( const OUString& rProperty uno::Any SAL_CALL MinMaxLineWrapper::getPropertyDefault( const OUString& rPropertyName ) { - const tPropertyValueMap& rStaticDefaults = *StaticMinMaxLineWrapperDefaults::get(); - tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( StaticMinMaxLineWrapperInfoHelper::get()->getHandleByName( rPropertyName ) ) ); - if( aFound == rStaticDefaults.end() ) + static const ::chart::tPropertyValueMap aStaticDefaults = [] + { + ::chart::tPropertyValueMap aTmp; + ::chart::LinePropertiesHelper::AddDefaultsToMap( aTmp ); + return aTmp; + }(); + tPropertyValueMap::const_iterator aFound( aStaticDefaults.find( StaticMinMaxLineWrapperInfoHelper().getHandleByName( rPropertyName ) ) ); + if( aFound == aStaticDefaults.end() ) return uno::Any(); return (*aFound).second; } @@ -343,7 +297,7 @@ uno::Any SAL_CALL MinMaxLineWrapper::getPropertyDefault( const OUString& rProper //getPropertyStates() already declared in XPropertyState void SAL_CALL MinMaxLineWrapper::setAllPropertiesToDefault( ) { - const Sequence< beans::Property >& rPropSeq = *StaticMinMaxLineWrapperPropertyArray::get(); + const Sequence< beans::Property >& rPropSeq = StaticMinMaxLineWrapperPropertyArray(); for(beans::Property const & prop : rPropSeq) { setPropertyToDefault( prop.Name ); diff --git a/chart2/source/controller/chartapiwrapper/MinMaxLineWrapper.hxx b/chart2/source/controller/chartapiwrapper/MinMaxLineWrapper.hxx index 33cabe1743e2..337ca8bdebd7 100644 --- a/chart2/source/controller/chartapiwrapper/MinMaxLineWrapper.hxx +++ b/chart2/source/controller/chartapiwrapper/MinMaxLineWrapper.hxx @@ -19,9 +19,8 @@ #pragma once #include <WrappedIgnoreProperty.hxx> -#include <comphelper/interfacecontainer3.hxx> +#include <comphelper/interfacecontainer4.hxx> -#include <cppuhelper/basemutex.hxx> #include <cppuhelper/implbase.hxx> #include <com/sun/star/beans/XMultiPropertySet.hpp> #include <com/sun/star/beans/XMultiPropertyStates.hpp> @@ -37,8 +36,7 @@ namespace chart::wrapper class Chart2ModelContact; -class MinMaxLineWrapper : public cppu::BaseMutex - , public ::cppu::WeakImplHelper +class MinMaxLineWrapper : public ::cppu::WeakImplHelper < css::lang::XComponent , css::lang::XServiceInfo , css::beans::XPropertySet @@ -48,7 +46,7 @@ class MinMaxLineWrapper : public cppu::BaseMutex > { public: - explicit MinMaxLineWrapper(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact); + explicit MinMaxLineWrapper(std::shared_ptr<Chart2ModelContact> spChart2ModelContact); virtual ~MinMaxLineWrapper() override; /// XServiceInfo declarations @@ -93,8 +91,9 @@ public: virtual css::uno::Sequence< css::uno::Any > SAL_CALL getPropertyDefaults( const css::uno::Sequence< OUString >& aPropertyNames ) override; private: //member + std::mutex m_aMutex; std::shared_ptr< Chart2ModelContact > m_spChart2ModelContact; - ::comphelper::OInterfaceContainerHelper3<css::lang::XEventListener> m_aEventListenerContainer; + ::comphelper::OInterfaceContainerHelper4<css::lang::XEventListener> m_aEventListenerContainer; WrappedIgnoreProperty m_aWrappedLineJointProperty; }; diff --git a/chart2/source/controller/chartapiwrapper/TitleWrapper.cxx b/chart2/source/controller/chartapiwrapper/TitleWrapper.cxx index 074a37778e65..129798d3706f 100644 --- a/chart2/source/controller/chartapiwrapper/TitleWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/TitleWrapper.cxx @@ -26,7 +26,6 @@ #include <com/sun/star/beans/PropertyAttribute.hpp> #include <com/sun/star/chart2/RelativePosition.hpp> #include <com/sun/star/chart2/XTitle.hpp> -#include <com/sun/star/chart2/XChartDocument.hpp> #include <CharacterProperties.hxx> #include <LinePropertiesHelper.hxx> @@ -40,10 +39,10 @@ #include <algorithm> #include <rtl/ustrbuf.hxx> #include <cppuhelper/propshlp.hxx> +#include <utility> using namespace ::com::sun::star; using ::com::sun::star::beans::Property; -using ::osl::MutexGuard; using ::com::sun::star::uno::Any; using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::Sequence; @@ -75,12 +74,12 @@ WrappedTitleStringProperty::WrappedTitleStringProperty( const Reference< uno::XC void WrappedTitleStringProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const { - Reference< chart2::XTitle > xTitle(xInnerPropertySet,uno::UNO_QUERY); - if(xTitle.is()) + Title* pTitle = dynamic_cast<Title*>(xInnerPropertySet.get()); + if(pTitle) { OUString aString; rOuterValue >>= aString; - TitleHelper::setCompleteString( aString, xTitle, m_xContext ); + TitleHelper::setCompleteString( aString, pTitle, m_xContext ); } } Any WrappedTitleStringProperty::getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const @@ -107,6 +106,51 @@ Any WrappedTitleStringProperty::getPropertyDefault( const Reference< beans::XPro namespace { + class WrappedTitleFormStringsProperty : public WrappedProperty + { + public: + explicit WrappedTitleFormStringsProperty(); + + virtual void setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const override; + virtual Any getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const override; + virtual Any getPropertyDefault( const Reference< beans::XPropertyState >& xInnerPropertyState ) const override; + }; + +} + +WrappedTitleFormStringsProperty::WrappedTitleFormStringsProperty() + : ::chart::WrappedProperty( "FormattedStrings", OUString() ) +{ +} + +void WrappedTitleFormStringsProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const +{ + Title* pTitle = dynamic_cast<Title*>(xInnerPropertySet.get()); + if (pTitle) + { + Sequence< Reference< chart2::XFormattedString >> xFormattedStrings; + rOuterValue >>= xFormattedStrings; + TitleHelper::setFormattedString(pTitle, xFormattedStrings); + } +} +Any WrappedTitleFormStringsProperty::getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const +{ + Any aRet(getPropertyDefault(Reference< beans::XPropertyState >(xInnerPropertySet, uno::UNO_QUERY))); + Reference< chart2::XTitle > xTitle(xInnerPropertySet, uno::UNO_QUERY); + if (xTitle.is()) + { + const Sequence< Reference< chart2::XFormattedString > > aStrings(xTitle->getText()); + aRet <<= aStrings; + } + return aRet; +} +Any WrappedTitleFormStringsProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const +{ + return uno::Any(Sequence< Reference< chart2::XFormattedString > >()); //default title is an empty Sequence of XFormattedStrings +} + +namespace { + class WrappedStackedTextProperty : public WrappedProperty { public: @@ -128,6 +172,8 @@ namespace enum { PROP_TITLE_STRING, + PROP_TITLE_FORMATTED_STRINGS, + PROP_TITLE_VISIBLE, PROP_TITLE_TEXT_ROTATION, PROP_TITLE_TEXT_STACKED }; @@ -141,6 +187,18 @@ void lcl_AddPropertiesToVector( beans::PropertyAttribute::BOUND | beans::PropertyAttribute::MAYBEVOID ); + rOutProperties.emplace_back( "FormattedStrings", + PROP_TITLE_FORMATTED_STRINGS, + cppu::UnoType< Sequence< Reference< chart2::XFormattedString >>>::get(), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEVOID ); + + rOutProperties.emplace_back( "Visible", + PROP_TITLE_VISIBLE, + cppu::UnoType<OUString>::get(), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEVOID ); + rOutProperties.emplace_back( "TextRotation", PROP_TITLE_TEXT_ROTATION, cppu::UnoType<sal_Int32>::get(), @@ -153,36 +211,27 @@ void lcl_AddPropertiesToVector( | beans::PropertyAttribute::MAYBEDEFAULT ); } -struct StaticTitleWrapperPropertyArray_Initializer +const Sequence< Property > & StaticTitleWrapperPropertyArray() { - Sequence< Property >* operator()() - { - static Sequence< Property > aPropSeq( lcl_GetPropertySequence() ); - return &aPropSeq; - } - -private: - static Sequence< Property > lcl_GetPropertySequence() - { - std::vector< beans::Property > aProperties; - lcl_AddPropertiesToVector( aProperties ); - ::chart::CharacterProperties::AddPropertiesToVector( aProperties ); - ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties ); - ::chart::FillProperties::AddPropertiesToVector( aProperties ); - ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); - ::chart::wrapper::WrappedAutomaticPositionProperties::addProperties( aProperties ); - ::chart::wrapper::WrappedScaleTextProperties::addProperties( aProperties ); - - std::sort( aProperties.begin(), aProperties.end(), - ::chart::PropertyNameLess() ); - - return comphelper::containerToSequence( aProperties ); - } + static Sequence< Property > aPropSeq = []() + { + std::vector< beans::Property > aProperties; + lcl_AddPropertiesToVector( aProperties ); + ::chart::CharacterProperties::AddPropertiesToVector( aProperties ); + ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties ); + ::chart::FillProperties::AddPropertiesToVector( aProperties ); + ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); + ::chart::wrapper::WrappedAutomaticPositionProperties::addProperties( aProperties ); + ::chart::wrapper::WrappedScaleTextProperties::addProperties( aProperties ); + + std::sort( aProperties.begin(), aProperties.end(), + ::chart::PropertyNameLess() ); + + return comphelper::containerToSequence( aProperties ); + }(); + return aPropSeq; }; -struct StaticTitleWrapperPropertyArray : public rtl::StaticAggregate< Sequence< Property >, StaticTitleWrapperPropertyArray_Initializer > -{ -}; } // anonymous namespace @@ -190,9 +239,8 @@ namespace chart::wrapper { TitleWrapper::TitleWrapper( ::chart::TitleHelper::eTitleType eTitleType, - const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact ) : - m_spChart2ModelContact( spChart2ModelContact ), - m_aEventListenerContainer( m_aMutex ), + std::shared_ptr<Chart2ModelContact> spChart2ModelContact ) : + m_spChart2ModelContact(std::move( spChart2ModelContact )), m_eTitleType(eTitleType) { ControllerLockGuardUNO aCtrlLockGuard( m_spChart2ModelContact->getDocumentModel() ); @@ -244,38 +292,25 @@ OUString SAL_CALL TitleWrapper::getShapeType() // ____ XComponent ____ void SAL_CALL TitleWrapper::dispose() { + std::unique_lock g(m_aMutex); Reference< uno::XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) ); - m_aEventListenerContainer.disposeAndClear( lang::EventObject( xSource ) ); + m_aEventListenerContainer.disposeAndClear( g, lang::EventObject( xSource ) ); - MutexGuard aGuard( m_aMutex); clearWrappedPropertySet(); } void SAL_CALL TitleWrapper::addEventListener( const Reference< lang::XEventListener >& xListener ) { - m_aEventListenerContainer.addInterface( xListener ); + std::unique_lock g(m_aMutex); + m_aEventListenerContainer.addInterface( g, xListener ); } void SAL_CALL TitleWrapper::removeEventListener( const Reference< lang::XEventListener >& aListener ) { - m_aEventListenerContainer.removeInterface( aListener ); -} - -Reference< beans::XPropertySet > TitleWrapper::getFirstCharacterPropertySet() -{ - Reference< beans::XPropertySet > xProp; - - Reference< chart2::XTitle > xTitle( getTitleObject() ); - if( xTitle.is()) - { - Sequence< Reference< chart2::XFormattedString > > aStrings( xTitle->getText()); - if( aStrings.hasElements() ) - xProp.set( aStrings[0], uno::UNO_QUERY ); - } - - return xProp; + std::unique_lock g(m_aMutex); + m_aEventListenerContainer.removeInterface( g, aListener ); } void TitleWrapper::getFastCharacterPropertyValue( sal_Int32 nHandle, Any& rValue ) @@ -283,7 +318,7 @@ void TitleWrapper::getFastCharacterPropertyValue( sal_Int32 nHandle, Any& rValue OSL_ASSERT( FAST_PROPERTY_ID_START_CHAR_PROP <= nHandle && nHandle < CharacterProperties::FAST_PROPERTY_ID_END_CHAR_PROP ); - Reference< beans::XPropertySet > xProp = getFirstCharacterPropertySet(); + Reference< beans::XPropertySet > xProp = getInnerPropertySet(); Reference< beans::XFastPropertySet > xFastProp( xProp, uno::UNO_QUERY ); if(xProp.is()) { @@ -323,6 +358,16 @@ void TitleWrapper::setFastCharacterPropertyValue( else if( xFastPropertySet.is() ) xFastPropertySet->setFastPropertyValue( nHandle, rValue ); } + + Reference< beans::XPropertySet > xInnerProp = getInnerPropertySet(); + Reference< beans::XFastPropertySet > xFastInnerProp( xInnerProp, uno::UNO_QUERY ); + if (xInnerProp.is()) + { + if (pWrappedProperty) + pWrappedProperty->setPropertyValue(rValue, xInnerProp); + else if (xFastInnerProp.is()) + xFastInnerProp->setFastPropertyValue(nHandle, rValue); + } } // WrappedPropertySet @@ -356,7 +401,7 @@ beans::PropertyState SAL_CALL TitleWrapper::getPropertyState( const OUString& rP sal_Int32 nHandle = getInfoHelper().getHandleByName( rPropertyName ); if( CharacterProperties::IsCharacterPropertyHandle( nHandle ) ) { - Reference< beans::XPropertyState > xPropState( getFirstCharacterPropertySet(), uno::UNO_QUERY ); + Reference< beans::XPropertyState > xPropState( getInnerPropertySet(), uno::UNO_QUERY); if( xPropState.is() ) { const WrappedProperty* pWrappedProperty = getWrappedProperty( rPropertyName ); @@ -389,7 +434,7 @@ Any SAL_CALL TitleWrapper::getPropertyDefault( const OUString& rPropertyName ) sal_Int32 nHandle = getInfoHelper().getHandleByName( rPropertyName ); if( CharacterProperties::IsCharacterPropertyHandle( nHandle ) ) { - Reference< beans::XPropertyState > xPropState( getFirstCharacterPropertySet(), uno::UNO_QUERY ); + Reference< beans::XPropertyState > xPropState( getInnerPropertySet(), uno::UNO_QUERY ); if( xPropState.is() ) { const WrappedProperty* pWrappedProperty = getWrappedProperty( rPropertyName ); @@ -410,7 +455,7 @@ void SAL_CALL TitleWrapper::addPropertyChangeListener( const OUString& rProperty sal_Int32 nHandle = getInfoHelper().getHandleByName( rPropertyName ); if( CharacterProperties::IsCharacterPropertyHandle( nHandle ) ) { - Reference< beans::XPropertySet > xPropSet = getFirstCharacterPropertySet(); + Reference< beans::XPropertySet > xPropSet = getInnerPropertySet(); if( xPropSet.is() ) xPropSet->addPropertyChangeListener( rPropertyName, xListener ); } @@ -422,7 +467,7 @@ void SAL_CALL TitleWrapper::removePropertyChangeListener( const OUString& rPrope sal_Int32 nHandle = getInfoHelper().getHandleByName( rPropertyName ); if( CharacterProperties::IsCharacterPropertyHandle( nHandle ) ) { - Reference< beans::XPropertySet > xPropSet = getFirstCharacterPropertySet(); + Reference< beans::XPropertySet > xPropSet = getInnerPropertySet(); if( xPropSet.is() ) xPropSet->removePropertyChangeListener( rPropertyName, xListener ); } @@ -469,7 +514,7 @@ Reference< beans::XPropertySet > TitleWrapper::getInnerPropertySet() const Sequence< beans::Property >& TitleWrapper::getPropertySequence() { - return *StaticTitleWrapperPropertyArray::get(); + return StaticTitleWrapperPropertyArray(); } std::vector< std::unique_ptr<WrappedProperty> > TitleWrapper::createWrappedProperties() @@ -477,6 +522,7 @@ std::vector< std::unique_ptr<WrappedProperty> > TitleWrapper::createWrappedPrope std::vector< std::unique_ptr<WrappedProperty> > aWrappedProperties; aWrappedProperties.emplace_back( new WrappedTitleStringProperty( m_spChart2ModelContact->m_xContext ) ); + aWrappedProperties.emplace_back( new WrappedTitleFormStringsProperty() ); aWrappedProperties.emplace_back( new WrappedTextRotationProperty( true ) ); aWrappedProperties.emplace_back( new WrappedStackedTextProperty() ); WrappedCharacterHeightProperty::addWrappedProperties( aWrappedProperties, this ); diff --git a/chart2/source/controller/chartapiwrapper/TitleWrapper.hxx b/chart2/source/controller/chartapiwrapper/TitleWrapper.hxx index 5cc3ed477d01..aecf5f304231 100644 --- a/chart2/source/controller/chartapiwrapper/TitleWrapper.hxx +++ b/chart2/source/controller/chartapiwrapper/TitleWrapper.hxx @@ -22,7 +22,7 @@ #include "ReferenceSizePropertyProvider.hxx" #include <TitleHelper.hxx> #include <cppuhelper/implbase.hxx> -#include <comphelper/interfacecontainer3.hxx> +#include <comphelper/interfacecontainer4.hxx> #include <com/sun/star/drawing/XShape.hpp> #include <com/sun/star/lang/XComponent.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> @@ -45,7 +45,7 @@ class TitleWrapper final : public ::cppu::ImplInheritanceHelper< { public: TitleWrapper( ::chart::TitleHelper::eTitleType eTitleType, - const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact ); + std::shared_ptr<Chart2ModelContact> spChart2ModelContact ); virtual ~TitleWrapper() override; /// XServiceInfo declarations @@ -100,7 +100,7 @@ private: css::uno::Reference< css::chart2::XTitle > getTitleObject(); std::shared_ptr< Chart2ModelContact > m_spChart2ModelContact; - ::comphelper::OInterfaceContainerHelper3<css::lang::XEventListener> m_aEventListenerContainer; + ::comphelper::OInterfaceContainerHelper4<css::lang::XEventListener> m_aEventListenerContainer; ::chart::TitleHelper::eTitleType m_eTitleType; }; diff --git a/chart2/source/controller/chartapiwrapper/UpDownBarWrapper.cxx b/chart2/source/controller/chartapiwrapper/UpDownBarWrapper.cxx index 2922f91c466b..c63090d81ac8 100644 --- a/chart2/source/controller/chartapiwrapper/UpDownBarWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/UpDownBarWrapper.cxx @@ -19,20 +19,19 @@ #include "UpDownBarWrapper.hxx" #include "Chart2ModelContact.hxx" -#include <DiagramHelper.hxx> +#include <ChartType.hxx> #include <servicenames_charttypes.hxx> #include <cppuhelper/supportsservice.hxx> #include <cppuhelper/propshlp.hxx> -#include <com/sun/star/chart2/XChartType.hpp> #include <comphelper/sequence.hxx> #include <LinePropertiesHelper.hxx> #include <FillProperties.hxx> #include <UserDefinedProperties.hxx> -#include <tools/diagnose_ex.h> +#include <utility> +#include <comphelper/diagnose_ex.hxx> using namespace ::com::sun::star; -using namespace ::com::sun::star::chart2; using ::com::sun::star::beans::Property; using ::com::sun::star::uno::Reference; @@ -42,79 +41,28 @@ using ::com::sun::star::uno::Any; namespace { -struct StaticUpDownBarWrapperPropertyArray_Initializer +const Sequence< Property > & StaticUpDownBarWrapperPropertyArray() { - Sequence< Property >* operator()() - { - static Sequence< Property > aPropSeq( lcl_GetPropertySequence() ); - return &aPropSeq; - } - -private: - static Sequence< Property > lcl_GetPropertySequence() - { - std::vector< css::beans::Property > aProperties; - - ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties ); - ::chart::FillProperties::AddPropertiesToVector( aProperties ); - ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); - - std::sort( aProperties.begin(), aProperties.end(), - ::chart::PropertyNameLess() ); - - return comphelper::containerToSequence( aProperties ); - } -}; - -struct StaticUpDownBarWrapperPropertyArray : public rtl::StaticAggregate< Sequence< Property >, StaticUpDownBarWrapperPropertyArray_Initializer > -{ -}; - -struct StaticUpDownBarWrapperInfoHelper_Initializer -{ - ::cppu::OPropertyArrayHelper* operator()() - { - static ::cppu::OPropertyArrayHelper aPropHelper( *StaticUpDownBarWrapperPropertyArray::get() ); - return &aPropHelper; - } -}; + static Sequence< Property > aPropSeq = []() + { + std::vector< css::beans::Property > aProperties; -struct StaticUpDownBarWrapperInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticUpDownBarWrapperInfoHelper_Initializer > -{ -}; + ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties ); + ::chart::FillProperties::AddPropertiesToVector( aProperties ); + ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); -struct StaticUpDownBarWrapperInfo_Initializer -{ - uno::Reference< beans::XPropertySetInfo >* operator()() - { - static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo( - ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticUpDownBarWrapperInfoHelper::get() ) ); - return &xPropertySetInfo; - } -}; + std::sort( aProperties.begin(), aProperties.end(), + ::chart::PropertyNameLess() ); -struct StaticUpDownBarWrapperInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticUpDownBarWrapperInfo_Initializer > -{ + return comphelper::containerToSequence( aProperties ); + }(); + return aPropSeq; }; -struct StaticUpDownBarWrapperDefaults_Initializer -{ - ::chart::tPropertyValueMap* operator()() - { - static ::chart::tPropertyValueMap aStaticDefaults; - lcl_AddDefaultsToMap( aStaticDefaults ); - return &aStaticDefaults; - } -private: - static void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap ) - { - ::chart::LinePropertiesHelper::AddDefaultsToMap( rOutMap ); - ::chart::FillProperties::AddDefaultsToMap( rOutMap ); - } -}; - -struct StaticUpDownBarWrapperDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticUpDownBarWrapperDefaults_Initializer > +::cppu::OPropertyArrayHelper& StaticUpDownBarWrapperInfoHelper() { + static ::cppu::OPropertyArrayHelper aPropHelper( StaticUpDownBarWrapperPropertyArray() ); + return aPropHelper; }; } // anonymous namespace @@ -123,9 +71,8 @@ namespace chart::wrapper { UpDownBarWrapper::UpDownBarWrapper( - bool bUp, const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact) - : m_spChart2ModelContact( spChart2ModelContact ) - , m_aEventListenerContainer( m_aMutex ) + bool bUp, std::shared_ptr<Chart2ModelContact> spChart2ModelContact) + : m_spChart2ModelContact(std::move( spChart2ModelContact )) , m_aPropertySetName( bUp ? OUString( "WhiteDay" ) : OUString( "BlackDay" )) { } @@ -137,42 +84,44 @@ UpDownBarWrapper::~UpDownBarWrapper() // ____ XComponent ____ void SAL_CALL UpDownBarWrapper::dispose() { + std::unique_lock g(m_aMutex); Reference< uno::XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) ); - m_aEventListenerContainer.disposeAndClear( lang::EventObject( xSource ) ); + m_aEventListenerContainer.disposeAndClear( g, lang::EventObject( xSource ) ); } void SAL_CALL UpDownBarWrapper::addEventListener( const Reference< lang::XEventListener >& xListener ) { - m_aEventListenerContainer.addInterface( xListener ); + std::unique_lock g(m_aMutex); + m_aEventListenerContainer.addInterface( g, xListener ); } void SAL_CALL UpDownBarWrapper::removeEventListener( const Reference< lang::XEventListener >& aListener ) { - m_aEventListenerContainer.removeInterface( aListener ); + std::unique_lock g(m_aMutex); + m_aEventListenerContainer.removeInterface( g, aListener ); } //XPropertySet uno::Reference< beans::XPropertySetInfo > SAL_CALL UpDownBarWrapper::getPropertySetInfo() { - return *StaticUpDownBarWrapperInfo::get(); + static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo( + ::cppu::OPropertySetHelper::createPropertySetInfo(StaticUpDownBarWrapperInfoHelper() ) ); + return xPropertySetInfo; } + void SAL_CALL UpDownBarWrapper::setPropertyValue( const OUString& rPropertyName, const uno::Any& rValue ) { Reference< beans::XPropertySet > xPropSet; - const Sequence< Reference< chart2::XChartType > > aTypes( - ::chart::DiagramHelper::getChartTypesFromDiagram( m_spChart2ModelContact->getDiagram() ) ); - for( Reference< chart2::XChartType > const & xType : aTypes ) + const std::vector< rtl::Reference< ChartType > > aTypes = + m_spChart2ModelContact->getDiagram()->getChartTypes(); + for( rtl::Reference< ChartType > const & xType : aTypes ) { if( xType->getChartType() == CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK ) { - Reference< beans::XPropertySet > xTypeProps( xType, uno::UNO_QUERY ); - if(xTypeProps.is()) - { - xTypeProps->getPropertyValue( m_aPropertySetName ) >>= xPropSet; - } + xType->getPropertyValue( m_aPropertySetName ) >>= xPropSet; } } if(xPropSet.is()) @@ -184,17 +133,13 @@ uno::Any SAL_CALL UpDownBarWrapper::getPropertyValue( const OUString& rPropertyN Reference< beans::XPropertySet > xPropSet; - const Sequence< Reference< chart2::XChartType > > aTypes( - ::chart::DiagramHelper::getChartTypesFromDiagram( m_spChart2ModelContact->getDiagram() ) ); - for( Reference< chart2::XChartType > const & xType : aTypes ) + const std::vector< rtl::Reference< ChartType > > aTypes = + m_spChart2ModelContact->getDiagram()->getChartTypes(); + for( rtl::Reference<ChartType > const & xType : aTypes ) { if( xType->getChartType() == CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK ) { - Reference< beans::XPropertySet > xTypeProps( xType, uno::UNO_QUERY ); - if(xTypeProps.is()) - { - xTypeProps->getPropertyValue( m_aPropertySetName ) >>= xPropSet; - } + xType->getPropertyValue( m_aPropertySetName ) >>= xPropSet; } } if(xPropSet.is()) @@ -299,9 +244,15 @@ void SAL_CALL UpDownBarWrapper::setPropertyToDefault( const OUString& rPropertyN uno::Any SAL_CALL UpDownBarWrapper::getPropertyDefault( const OUString& rPropertyName ) { - const tPropertyValueMap& rStaticDefaults = *StaticUpDownBarWrapperDefaults::get(); - tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( StaticUpDownBarWrapperInfoHelper::get()->getHandleByName( rPropertyName ) ) ); - if( aFound == rStaticDefaults.end() ) + static const ::chart::tPropertyValueMap aStaticDefaults = []() + { + ::chart::tPropertyValueMap aTmp; + ::chart::LinePropertiesHelper::AddDefaultsToMap( aTmp ); + ::chart::FillProperties::AddDefaultsToMap( aTmp ); + return aTmp; + }(); + tPropertyValueMap::const_iterator aFound( aStaticDefaults.find( StaticUpDownBarWrapperInfoHelper().getHandleByName( rPropertyName ) ) ); + if( aFound == aStaticDefaults.end() ) return uno::Any(); return (*aFound).second; } @@ -310,7 +261,7 @@ uno::Any SAL_CALL UpDownBarWrapper::getPropertyDefault( const OUString& rPropert //getPropertyStates() already declared in XPropertyState void SAL_CALL UpDownBarWrapper::setAllPropertiesToDefault( ) { - const Sequence< beans::Property >& rPropSeq = *StaticUpDownBarWrapperPropertyArray::get(); + const Sequence< beans::Property >& rPropSeq = StaticUpDownBarWrapperPropertyArray(); for(beans::Property const & prop : rPropSeq) { setPropertyToDefault( prop.Name ); diff --git a/chart2/source/controller/chartapiwrapper/UpDownBarWrapper.hxx b/chart2/source/controller/chartapiwrapper/UpDownBarWrapper.hxx index 63e1c44db4d8..517a2406fe2c 100644 --- a/chart2/source/controller/chartapiwrapper/UpDownBarWrapper.hxx +++ b/chart2/source/controller/chartapiwrapper/UpDownBarWrapper.hxx @@ -18,9 +18,8 @@ */ #pragma once -#include <comphelper/interfacecontainer3.hxx> +#include <comphelper/interfacecontainer4.hxx> -#include <cppuhelper/basemutex.hxx> #include <cppuhelper/implbase.hxx> #include <com/sun/star/beans/XMultiPropertySet.hpp> #include <com/sun/star/beans/XMultiPropertyStates.hpp> @@ -36,8 +35,7 @@ namespace chart::wrapper class Chart2ModelContact; -class UpDownBarWrapper : public cppu::BaseMutex - , public ::cppu::WeakImplHelper +class UpDownBarWrapper : public ::cppu::WeakImplHelper < css::lang::XComponent , css::lang::XServiceInfo , css::beans::XPropertySet @@ -47,7 +45,7 @@ class UpDownBarWrapper : public cppu::BaseMutex > { public: - UpDownBarWrapper(bool bUp, const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact); + UpDownBarWrapper(bool bUp, std::shared_ptr<Chart2ModelContact> spChart2ModelContact); virtual ~UpDownBarWrapper() override; /// XServiceInfo declarations @@ -94,8 +92,9 @@ public: virtual css::uno::Sequence< css::uno::Any > SAL_CALL getPropertyDefaults( const css::uno::Sequence< OUString >& aPropertyNames ) override; private: //member + std::mutex m_aMutex; std::shared_ptr< Chart2ModelContact > m_spChart2ModelContact; - ::comphelper::OInterfaceContainerHelper3<css::lang::XEventListener> m_aEventListenerContainer; + ::comphelper::OInterfaceContainerHelper4<css::lang::XEventListener> m_aEventListenerContainer; OUString m_aPropertySetName; }; diff --git a/chart2/source/controller/chartapiwrapper/WallFloorWrapper.cxx b/chart2/source/controller/chartapiwrapper/WallFloorWrapper.cxx index 711f68201727..9c8a6f61afb0 100644 --- a/chart2/source/controller/chartapiwrapper/WallFloorWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/WallFloorWrapper.cxx @@ -21,7 +21,6 @@ #include "Chart2ModelContact.hxx" #include <comphelper/sequence.hxx> #include <cppuhelper/supportsservice.hxx> -#include <com/sun/star/chart2/XDiagram.hpp> #include <FillProperties.hxx> #include <LinePropertiesHelper.hxx> @@ -29,54 +28,20 @@ #include <WrappedDirectStateProperty.hxx> #include <algorithm> +#include <utility> using namespace ::com::sun::star; -using namespace ::com::sun::star::chart2; using ::com::sun::star::beans::Property; -using ::osl::MutexGuard; using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::Sequence; -namespace -{ - -struct StaticWallFloorWrapperPropertyArray_Initializer -{ - Sequence< Property >* operator()() - { - static Sequence< Property > aPropSeq( lcl_GetPropertySequence() ); - return &aPropSeq; - } - -private: - static Sequence< Property > lcl_GetPropertySequence() - { - std::vector< css::beans::Property > aProperties; - ::chart::FillProperties::AddPropertiesToVector( aProperties ); - ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties ); - ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); - - std::sort( aProperties.begin(), aProperties.end(), - ::chart::PropertyNameLess() ); - - return comphelper::containerToSequence( aProperties ); - } -}; - -struct StaticWallFloorWrapperPropertyArray : public rtl::StaticAggregate< Sequence< Property >, StaticWallFloorWrapperPropertyArray_Initializer > -{ -}; - -} // anonymous namespace - namespace chart::wrapper { WallFloorWrapper::WallFloorWrapper( bool bWall, - const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact ) : - m_spChart2ModelContact( spChart2ModelContact ), - m_aEventListenerContainer( m_aMutex ), + std::shared_ptr<Chart2ModelContact> spChart2ModelContact ) : + m_spChart2ModelContact(std::move( spChart2ModelContact )), m_bWall( bWall ) { @@ -89,23 +54,25 @@ WallFloorWrapper::~WallFloorWrapper() // ____ XComponent ____ void SAL_CALL WallFloorWrapper::dispose() { + std::unique_lock g(m_aMutex); Reference< uno::XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) ); - m_aEventListenerContainer.disposeAndClear( lang::EventObject( xSource ) ); + m_aEventListenerContainer.disposeAndClear( g, lang::EventObject( xSource ) ); - MutexGuard aGuard( m_aMutex); clearWrappedPropertySet(); } void SAL_CALL WallFloorWrapper::addEventListener( const Reference< lang::XEventListener >& xListener ) { - m_aEventListenerContainer.addInterface( xListener ); + std::unique_lock g(m_aMutex); + m_aEventListenerContainer.addInterface( g, xListener ); } void SAL_CALL WallFloorWrapper::removeEventListener( const Reference< lang::XEventListener >& aListener ) { - m_aEventListenerContainer.removeInterface( aListener ); + std::unique_lock g(m_aMutex); + m_aEventListenerContainer.removeInterface( g, aListener ); } // WrappedPropertySet @@ -127,7 +94,19 @@ Reference< beans::XPropertySet > WallFloorWrapper::getInnerPropertySet() const Sequence< beans::Property >& WallFloorWrapper::getPropertySequence() { - return *StaticWallFloorWrapperPropertyArray::get(); + static Sequence< Property > aPropSeq = []() + { + std::vector< css::beans::Property > aProperties; + ::chart::FillProperties::AddPropertiesToVector( aProperties ); + ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties ); + ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); + + std::sort( aProperties.begin(), aProperties.end(), + ::chart::PropertyNameLess() ); + + return comphelper::containerToSequence( aProperties ); + }(); + return aPropSeq; } std::vector< std::unique_ptr<WrappedProperty> > WallFloorWrapper::createWrappedProperties() diff --git a/chart2/source/controller/chartapiwrapper/WallFloorWrapper.hxx b/chart2/source/controller/chartapiwrapper/WallFloorWrapper.hxx index 3df4a9f1af0b..4a85bd8d5b37 100644 --- a/chart2/source/controller/chartapiwrapper/WallFloorWrapper.hxx +++ b/chart2/source/controller/chartapiwrapper/WallFloorWrapper.hxx @@ -20,7 +20,7 @@ #include <WrappedPropertySet.hxx> #include <cppuhelper/implbase.hxx> -#include <comphelper/interfacecontainer3.hxx> +#include <comphelper/interfacecontainer4.hxx> #include <com/sun/star/lang/XComponent.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> @@ -38,7 +38,7 @@ class WallFloorWrapper : public ::cppu::ImplInheritanceHelper< > { public: - WallFloorWrapper(bool bWall, const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact); + WallFloorWrapper(bool bWall, std::shared_ptr<Chart2ModelContact> spChart2ModelContact); virtual ~WallFloorWrapper() override; /// XServiceInfo declarations @@ -59,7 +59,7 @@ protected: private: std::shared_ptr< Chart2ModelContact > m_spChart2ModelContact; - ::comphelper::OInterfaceContainerHelper3<css::lang::XEventListener> m_aEventListenerContainer; + ::comphelper::OInterfaceContainerHelper4<css::lang::XEventListener> m_aEventListenerContainer; bool m_bWall; }; diff --git a/chart2/source/controller/chartapiwrapper/WrappedAutomaticPositionProperties.cxx b/chart2/source/controller/chartapiwrapper/WrappedAutomaticPositionProperties.cxx index 2bfb5ed42211..b88468c9941e 100644 --- a/chart2/source/controller/chartapiwrapper/WrappedAutomaticPositionProperties.cxx +++ b/chart2/source/controller/chartapiwrapper/WrappedAutomaticPositionProperties.cxx @@ -23,7 +23,7 @@ #include <com/sun/star/beans/PropertyAttribute.hpp> #include <com/sun/star/beans/XPropertyState.hpp> #include <com/sun/star/beans/XPropertySet.hpp> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> using namespace ::com::sun::star; using ::com::sun::star::uno::Any; diff --git a/chart2/source/controller/chartapiwrapper/WrappedAxisAndGridExistenceProperties.cxx b/chart2/source/controller/chartapiwrapper/WrappedAxisAndGridExistenceProperties.cxx index 4895e1c40b9d..2b047ebfaf82 100644 --- a/chart2/source/controller/chartapiwrapper/WrappedAxisAndGridExistenceProperties.cxx +++ b/chart2/source/controller/chartapiwrapper/WrappedAxisAndGridExistenceProperties.cxx @@ -23,13 +23,12 @@ #include "WrappedAxisAndGridExistenceProperties.hxx" #include <com/sun/star/beans/XPropertySet.hpp> -#include <com/sun/star/chart2/XAxis.hpp> -#include <com/sun/star/chart2/XDiagram.hpp> +#include <Axis.hxx> #include <AxisHelper.hxx> #include <WrappedProperty.hxx> #include "Chart2ModelContact.hxx" #include <TitleHelper.hxx> -#include <ChartView.hxx> +#include <utility> #include <osl/diagnose.h> using namespace ::com::sun::star; @@ -45,7 +44,7 @@ class WrappedAxisAndGridExistenceProperty : public WrappedProperty { public: WrappedAxisAndGridExistenceProperty( bool bAxis, bool bMain, sal_Int32 nDimensionIndex - , const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact ); + , std::shared_ptr<Chart2ModelContact> spChart2ModelContact ); virtual void setPropertyValue( const css::uno::Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override; @@ -81,9 +80,9 @@ void WrappedAxisAndGridExistenceProperties::addWrappedProperties( std::vector< s } WrappedAxisAndGridExistenceProperty::WrappedAxisAndGridExistenceProperty( bool bAxis, bool bMain, sal_Int32 nDimensionIndex - , const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact ) + , std::shared_ptr<Chart2ModelContact> spChart2ModelContact ) : WrappedProperty(OUString(),OUString()) - , m_spChart2ModelContact( spChart2ModelContact ) + , m_spChart2ModelContact(std::move( spChart2ModelContact )) , m_bAxis( bAxis ) , m_bMain( bMain ) , m_nDimensionIndex( nDimensionIndex ) @@ -205,7 +204,7 @@ class WrappedAxisTitleExistenceProperty : public WrappedProperty { public: WrappedAxisTitleExistenceProperty( sal_Int32 nTitleIndex - , const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact ); + , std::shared_ptr<Chart2ModelContact> spChart2ModelContact ); virtual void setPropertyValue( const css::uno::Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override; @@ -231,9 +230,9 @@ void WrappedAxisTitleExistenceProperties::addWrappedProperties( std::vector< std } WrappedAxisTitleExistenceProperty::WrappedAxisTitleExistenceProperty(sal_Int32 nTitleIndex - , const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact) + , std::shared_ptr<Chart2ModelContact> spChart2ModelContact) : WrappedProperty(OUString(),OUString()) - , m_spChart2ModelContact( spChart2ModelContact ) + , m_spChart2ModelContact(std::move( spChart2ModelContact )) , m_eTitleType( TitleHelper::Y_AXIS_TITLE ) { switch( nTitleIndex ) @@ -288,7 +287,7 @@ Any WrappedAxisTitleExistenceProperty::getPropertyValue( const Reference< beans: { bool bHasTitle = false; - Reference< chart2::XTitle > xTitle( TitleHelper::getTitle( m_eTitleType, m_spChart2ModelContact->getDocumentModel() ) ); + rtl::Reference< Title > xTitle( TitleHelper::getTitle( m_eTitleType, m_spChart2ModelContact->getDocumentModel() ) ); if( xTitle.is() && !TitleHelper::getCompleteString( xTitle ).isEmpty() ) bHasTitle = true; @@ -311,7 +310,7 @@ class WrappedAxisLabelExistenceProperty : public WrappedProperty { public: WrappedAxisLabelExistenceProperty( bool bMain, sal_Int32 nDimensionIndex - , const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact ); + , std::shared_ptr<Chart2ModelContact> spChart2ModelContact ); virtual void setPropertyValue( const css::uno::Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override; @@ -338,9 +337,9 @@ void WrappedAxisLabelExistenceProperties::addWrappedProperties( std::vector< std } WrappedAxisLabelExistenceProperty::WrappedAxisLabelExistenceProperty(bool bMain, sal_Int32 nDimensionIndex - , const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact) + , std::shared_ptr<Chart2ModelContact> spChart2ModelContact) : WrappedProperty(OUString(),OUString()) - , m_spChart2ModelContact( spChart2ModelContact ) + , m_spChart2ModelContact(std::move( spChart2ModelContact )) , m_bMain( bMain ) , m_nDimensionIndex( nDimensionIndex ) { @@ -372,11 +371,11 @@ void WrappedAxisLabelExistenceProperty::setPropertyValue( const Any& rOuterValue return; rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); - Reference< beans::XPropertySet > xProp( AxisHelper::getAxis( m_nDimensionIndex, m_bMain, xDiagram ), uno::UNO_QUERY ); + rtl::Reference< Axis > xProp = AxisHelper::getAxis( m_nDimensionIndex, m_bMain, xDiagram ); if( !xProp.is() && bNewValue ) { //create axis if needed - xProp.set( AxisHelper::createAxis( m_nDimensionIndex, m_bMain, xDiagram, m_spChart2ModelContact->m_xContext ), uno::UNO_QUERY ); + xProp = AxisHelper::createAxis( m_nDimensionIndex, m_bMain, xDiagram, m_spChart2ModelContact->m_xContext ); if( xProp.is() ) xProp->setPropertyValue( "Show", uno::Any( false ) ); } @@ -388,7 +387,7 @@ Any WrappedAxisLabelExistenceProperty::getPropertyValue( const Reference< beans: { Any aRet; rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); - Reference< beans::XPropertySet > xProp( AxisHelper::getAxis( m_nDimensionIndex, m_bMain, xDiagram ), uno::UNO_QUERY ); + rtl::Reference< Axis > xProp = AxisHelper::getAxis( m_nDimensionIndex, m_bMain, xDiagram ); if( xProp.is() ) aRet = xProp->getPropertyValue( "DisplayLabels" ); else diff --git a/chart2/source/controller/chartapiwrapper/WrappedCharacterHeightProperty.hxx b/chart2/source/controller/chartapiwrapper/WrappedCharacterHeightProperty.hxx index 7eee90a2c209..be9457d0ffd7 100644 --- a/chart2/source/controller/chartapiwrapper/WrappedCharacterHeightProperty.hxx +++ b/chart2/source/controller/chartapiwrapper/WrappedCharacterHeightProperty.hxx @@ -45,7 +45,7 @@ protected: virtual css::uno::Any convertInnerToOuterValue( const css::uno::Any& rInnerValue ) const override; virtual css::uno::Any convertOuterToInnerValue( const css::uno::Any& rOuterValue ) const override; -protected: +private: ReferenceSizePropertyProvider* m_pRefSizePropProvider; }; diff --git a/chart2/source/controller/chartapiwrapper/WrappedGapwidthProperty.cxx b/chart2/source/controller/chartapiwrapper/WrappedGapwidthProperty.cxx index c0f100d335a7..079d25f63bb4 100644 --- a/chart2/source/controller/chartapiwrapper/WrappedGapwidthProperty.cxx +++ b/chart2/source/controller/chartapiwrapper/WrappedGapwidthProperty.cxx @@ -17,10 +17,15 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <sal/config.h> + +#include <cstddef> + #include "WrappedGapwidthProperty.hxx" #include "Chart2ModelContact.hxx" -#include <DiagramHelper.hxx> +#include <ChartType.hxx> #include <tools/long.hxx> +#include <utility> using namespace ::com::sun::star; using ::com::sun::star::uno::Reference; @@ -35,15 +40,15 @@ const sal_Int32 DEFAULT_OVERLAP = 0; WrappedBarPositionProperty_Base::WrappedBarPositionProperty_Base( const OUString& rOuterName - , const OUString& rInnerSequencePropertyName + , OUString aInnerSequencePropertyName , sal_Int32 nDefaultValue - , const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact ) + , std::shared_ptr<Chart2ModelContact> spChart2ModelContact ) : WrappedDefaultProperty( rOuterName, OUString(), uno::Any( nDefaultValue ) ) , m_nDimensionIndex(0) , m_nAxisIndex(0) - , m_spChart2ModelContact( spChart2ModelContact ) + , m_spChart2ModelContact(std::move( spChart2ModelContact )) , m_nDefaultValue( nDefaultValue ) - , m_InnerSequencePropertyName( rInnerSequencePropertyName ) + , m_InnerSequencePropertyName(std::move( aInnerSequencePropertyName )) { } @@ -72,29 +77,25 @@ void WrappedBarPositionProperty_Base::setPropertyValue( const Any& rOuterValue, if( m_nDimensionIndex!=1 ) return; - const Sequence< Reference< chart2::XChartType > > aChartTypeList( DiagramHelper::getChartTypesFromDiagram( xDiagram ) ); - for( Reference< chart2::XChartType > const & chartType : aChartTypeList ) + const std::vector< rtl::Reference< ChartType > > aChartTypeList( xDiagram->getChartTypes() ); + for( rtl::Reference< ChartType > const & chartType : aChartTypeList ) { try { - Reference< beans::XPropertySet > xProp( chartType, uno::UNO_QUERY ); - if( xProp.is() ) + Sequence< sal_Int32 > aBarPositionSequence; + chartType->getPropertyValue( m_InnerSequencePropertyName ) >>= aBarPositionSequence; + + tools::Long nOldLength = aBarPositionSequence.getLength(); + if( nOldLength <= m_nAxisIndex ) + aBarPositionSequence.realloc( m_nAxisIndex+1 ); + auto pBarPositionSequence = aBarPositionSequence.getArray(); + for( sal_Int32 i=nOldLength; i<m_nAxisIndex; i++ ) { - Sequence< sal_Int32 > aBarPositionSequence; - xProp->getPropertyValue( m_InnerSequencePropertyName ) >>= aBarPositionSequence; - - tools::Long nOldLength = aBarPositionSequence.getLength(); - if( nOldLength <= m_nAxisIndex ) - aBarPositionSequence.realloc( m_nAxisIndex+1 ); - auto pBarPositionSequence = aBarPositionSequence.getArray(); - for( sal_Int32 i=nOldLength; i<m_nAxisIndex; i++ ) - { - pBarPositionSequence[i] = m_nDefaultValue; - } - pBarPositionSequence[m_nAxisIndex] = nNewValue; - - xProp->setPropertyValue( m_InnerSequencePropertyName, uno::Any( aBarPositionSequence ) ); + pBarPositionSequence[i] = m_nDefaultValue; } + pBarPositionSequence[m_nAxisIndex] = nNewValue; + + chartType->setPropertyValue( m_InnerSequencePropertyName, uno::Any( aBarPositionSequence ) ); } catch( uno::Exception& e ) { @@ -115,21 +116,17 @@ Any WrappedBarPositionProperty_Base::getPropertyValue( const Reference< beans::X if( m_nDimensionIndex==1 ) { - Sequence< Reference< chart2::XChartType > > aChartTypeList( DiagramHelper::getChartTypesFromDiagram( xDiagram ) ); - for( sal_Int32 nN = 0; nN < aChartTypeList.getLength() && !bInnerValueDetected; nN++ ) + std::vector< rtl::Reference< ChartType > > aChartTypeList = xDiagram->getChartTypes(); + for( std::size_t nN = 0; nN < aChartTypeList.size() && !bInnerValueDetected; nN++ ) { try { - Reference< beans::XPropertySet > xProp( aChartTypeList[nN], uno::UNO_QUERY ); - if( xProp.is() ) + Sequence< sal_Int32 > aBarPositionSequence; + aChartTypeList[nN]->getPropertyValue( m_InnerSequencePropertyName ) >>= aBarPositionSequence; + if( m_nAxisIndex < aBarPositionSequence.getLength() ) { - Sequence< sal_Int32 > aBarPositionSequence; - xProp->getPropertyValue( m_InnerSequencePropertyName ) >>= aBarPositionSequence; - if( m_nAxisIndex < aBarPositionSequence.getLength() ) - { - nInnerValue = aBarPositionSequence[m_nAxisIndex]; - bInnerValueDetected = true; - } + nInnerValue = aBarPositionSequence[m_nAxisIndex]; + bInnerValueDetected = true; } } catch( uno::Exception& e ) diff --git a/chart2/source/controller/chartapiwrapper/WrappedGapwidthProperty.hxx b/chart2/source/controller/chartapiwrapper/WrappedGapwidthProperty.hxx index 550b0ce6ad9d..6ac43e9f7635 100644 --- a/chart2/source/controller/chartapiwrapper/WrappedGapwidthProperty.hxx +++ b/chart2/source/controller/chartapiwrapper/WrappedGapwidthProperty.hxx @@ -32,9 +32,9 @@ class WrappedBarPositionProperty_Base : public WrappedDefaultProperty public: WrappedBarPositionProperty_Base( const OUString& rOuterName - , const OUString& rInnerSequencePropertyName + , OUString aInnerSequencePropertyName , sal_Int32 nDefaultValue - , const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact ); + , std::shared_ptr<Chart2ModelContact> spChart2ModelContact ); virtual ~WrappedBarPositionProperty_Base() override; virtual void setPropertyValue( const css::uno::Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override; @@ -43,7 +43,7 @@ public: void setDimensionAndAxisIndex( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ); -protected: +private: sal_Int32 m_nDimensionIndex; sal_Int32 m_nAxisIndex; std::shared_ptr< Chart2ModelContact > m_spChart2ModelContact; diff --git a/chart2/source/controller/chartapiwrapper/WrappedNumberFormatProperty.cxx b/chart2/source/controller/chartapiwrapper/WrappedNumberFormatProperty.cxx index 1ce277c321ba..0598b4fd377f 100644 --- a/chart2/source/controller/chartapiwrapper/WrappedNumberFormatProperty.cxx +++ b/chart2/source/controller/chartapiwrapper/WrappedNumberFormatProperty.cxx @@ -19,9 +19,10 @@ #include "WrappedNumberFormatProperty.hxx" #include "Chart2ModelContact.hxx" -#include <com/sun/star/chart2/XAxis.hpp> +#include <Axis.hxx> #include <com/sun/star/chart2/XDataSeries.hpp> #include <unonames.hxx> +#include <utility> #include <osl/diagnose.h> using namespace ::com::sun::star; @@ -31,9 +32,9 @@ using ::com::sun::star::uno::Any; namespace chart::wrapper { -WrappedNumberFormatProperty::WrappedNumberFormatProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact) +WrappedNumberFormatProperty::WrappedNumberFormatProperty(std::shared_ptr<Chart2ModelContact> spChart2ModelContact) : WrappedDirectStateProperty( CHART_UNONAME_NUMFMT, CHART_UNONAME_NUMFMT ) - , m_spChart2ModelContact(spChart2ModelContact) + , m_spChart2ModelContact(std::move(spChart2ModelContact)) { } @@ -67,7 +68,8 @@ Any WrappedNumberFormatProperty::getPropertyValue( const Reference< beans::XProp nKey = Chart2ModelContact::getExplicitNumberFormatKeyForSeries( xSeries ); else { - Reference< chart2::XAxis > xAxis( xInnerPropertySet, uno::UNO_QUERY ); + rtl::Reference< Axis > xAxis = dynamic_cast<Axis*>(xInnerPropertySet.get()); + assert(xAxis || !xInnerPropertySet); nKey = m_spChart2ModelContact->getExplicitNumberFormatKeyForAxis( xAxis ); } aRet <<= nKey; diff --git a/chart2/source/controller/chartapiwrapper/WrappedNumberFormatProperty.hxx b/chart2/source/controller/chartapiwrapper/WrappedNumberFormatProperty.hxx index fa4042ceaedf..cf2f706c61c7 100644 --- a/chart2/source/controller/chartapiwrapper/WrappedNumberFormatProperty.hxx +++ b/chart2/source/controller/chartapiwrapper/WrappedNumberFormatProperty.hxx @@ -31,7 +31,7 @@ namespace chart::wrapper class WrappedNumberFormatProperty : public WrappedDirectStateProperty { public: - explicit WrappedNumberFormatProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact); + explicit WrappedNumberFormatProperty(std::shared_ptr<Chart2ModelContact> spChart2ModelContact); virtual ~WrappedNumberFormatProperty() override; virtual void setPropertyValue( const css::uno::Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override; diff --git a/chart2/source/controller/chartapiwrapper/WrappedScaleProperty.cxx b/chart2/source/controller/chartapiwrapper/WrappedScaleProperty.cxx index 27e07256e51d..0edbf16bc9fb 100644 --- a/chart2/source/controller/chartapiwrapper/WrappedScaleProperty.cxx +++ b/chart2/source/controller/chartapiwrapper/WrappedScaleProperty.cxx @@ -20,11 +20,13 @@ #include "WrappedScaleProperty.hxx" #include "Chart2ModelContact.hxx" #include <CommonConverters.hxx> +#include <Axis.hxx> #include <AxisHelper.hxx> #include <com/sun/star/chart2/AxisType.hpp> #include <com/sun/star/chart2/XAxis.hpp> #include <com/sun/star/chart/ChartAxisType.hpp> #include <chartview/ExplicitScaleValues.hxx> +#include <utility> #include <osl/diagnose.h> using namespace ::com::sun::star; @@ -38,9 +40,9 @@ namespace chart::wrapper { WrappedScaleProperty::WrappedScaleProperty(tScaleProperty eScaleProperty - , const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact) + , std::shared_ptr<Chart2ModelContact> spChart2ModelContact) : WrappedProperty(OUString(),OUString()) - , m_spChart2ModelContact( spChart2ModelContact ) + , m_spChart2ModelContact(std::move( spChart2ModelContact )) , m_eScaleProperty( eScaleProperty ) { switch( m_eScaleProperty ) @@ -348,7 +350,7 @@ Any WrappedScaleProperty::getPropertyValue( tScaleProperty eScaleProperty, const { Any aRet( m_aOuterValue ); - Reference< chart2::XAxis > xAxis( xInnerPropertySet, uno::UNO_QUERY ); + rtl::Reference< Axis > xAxis = dynamic_cast<Axis*>(xInnerPropertySet.get()); OSL_ENSURE(xAxis.is(),"need an XAxis"); if(!xAxis.is()) return aRet; diff --git a/chart2/source/controller/chartapiwrapper/WrappedScaleProperty.hxx b/chart2/source/controller/chartapiwrapper/WrappedScaleProperty.hxx index 64e8071b5345..eca52953552d 100644 --- a/chart2/source/controller/chartapiwrapper/WrappedScaleProperty.hxx +++ b/chart2/source/controller/chartapiwrapper/WrappedScaleProperty.hxx @@ -51,7 +51,7 @@ public: , SCALE_PROP_REVERSEDIRECTION }; - WrappedScaleProperty(tScaleProperty eScaleProperty, const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact); + WrappedScaleProperty(tScaleProperty eScaleProperty, std::shared_ptr<Chart2ModelContact> spChart2ModelContact); virtual ~WrappedScaleProperty() override; static void addWrappedProperties( std::vector< std::unique_ptr<WrappedProperty> >& rList, const std::shared_ptr< Chart2ModelContact >& spChart2ModelContact ); diff --git a/chart2/source/controller/chartapiwrapper/WrappedScaleTextProperties.cxx b/chart2/source/controller/chartapiwrapper/WrappedScaleTextProperties.cxx index 8551915d9c88..6e11fbe021a2 100644 --- a/chart2/source/controller/chartapiwrapper/WrappedScaleTextProperties.cxx +++ b/chart2/source/controller/chartapiwrapper/WrappedScaleTextProperties.cxx @@ -25,7 +25,8 @@ #include <com/sun/star/beans/PropertyAttribute.hpp> #include <com/sun/star/beans/XPropertyState.hpp> #include <com/sun/star/beans/XPropertySet.hpp> -#include <tools/diagnose_ex.h> +#include <utility> +#include <comphelper/diagnose_ex.hxx> using namespace ::com::sun::star; using ::com::sun::star::uno::Any; @@ -40,7 +41,7 @@ namespace { class WrappedScaleTextProperty : public WrappedProperty { public: - explicit WrappedScaleTextProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact); + explicit WrappedScaleTextProperty(std::shared_ptr<Chart2ModelContact> spChart2ModelContact); virtual void setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const override; virtual Any getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const override; @@ -52,15 +53,15 @@ private: } -WrappedScaleTextProperty::WrappedScaleTextProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact) +WrappedScaleTextProperty::WrappedScaleTextProperty(std::shared_ptr<Chart2ModelContact> spChart2ModelContact) : ::chart::WrappedProperty( "ScaleText" , OUString() ) - , m_spChart2ModelContact( spChart2ModelContact ) + , m_spChart2ModelContact(std::move( spChart2ModelContact )) { } void WrappedScaleTextProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const { - static constexpr OUStringLiteral aRefSizeName = u"ReferencePageSize"; + static constexpr OUString aRefSizeName = u"ReferencePageSize"_ustr; if( !xInnerPropertySet.is() ) return; diff --git a/chart2/source/controller/chartapiwrapper/WrappedSceneProperty.cxx b/chart2/source/controller/chartapiwrapper/WrappedSceneProperty.cxx index 2430dcba7ac6..5c22750dc17b 100644 --- a/chart2/source/controller/chartapiwrapper/WrappedSceneProperty.cxx +++ b/chart2/source/controller/chartapiwrapper/WrappedSceneProperty.cxx @@ -19,8 +19,8 @@ #include "WrappedSceneProperty.hxx" #include "Chart2ModelContact.hxx" -#include <DiagramHelper.hxx> #include <BaseGFXHelper.hxx> +#include <utility> using namespace ::com::sun::star; using ::com::sun::star::uno::Any; @@ -36,9 +36,9 @@ void WrappedSceneProperty::addWrappedProperties( std::vector< std::unique_ptr<Wr } WrappedD3DTransformMatrixProperty::WrappedD3DTransformMatrixProperty( - const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact ) + std::shared_ptr<Chart2ModelContact> spChart2ModelContact ) : WrappedProperty("D3DTransformMatrix","D3DTransformMatrix") - , m_spChart2ModelContact( spChart2ModelContact ) + , m_spChart2ModelContact(std::move( spChart2ModelContact )) { } @@ -48,7 +48,7 @@ WrappedD3DTransformMatrixProperty::~WrappedD3DTransformMatrixProperty() void WrappedD3DTransformMatrixProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const { - if( DiagramHelper::isPieOrDonutChart( m_spChart2ModelContact->getDiagram() ) ) + if( m_spChart2ModelContact->getDiagram()->isPieOrDonutChart() ) { drawing::HomogenMatrix aHM; if( rOuterValue >>= aHM ) @@ -73,7 +73,7 @@ void WrappedD3DTransformMatrixProperty::setPropertyValue( const Any& rOuterValue Any WrappedD3DTransformMatrixProperty::getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const { - if( DiagramHelper::isPieOrDonutChart( m_spChart2ModelContact->getDiagram() ) ) + if( m_spChart2ModelContact->getDiagram()->isPieOrDonutChart() ) { uno::Any aAMatrix( WrappedProperty::getPropertyValue( xInnerPropertySet ) ); drawing::HomogenMatrix aHM; diff --git a/chart2/source/controller/chartapiwrapper/WrappedSceneProperty.hxx b/chart2/source/controller/chartapiwrapper/WrappedSceneProperty.hxx index 7e6679016537..31ef35abc566 100644 --- a/chart2/source/controller/chartapiwrapper/WrappedSceneProperty.hxx +++ b/chart2/source/controller/chartapiwrapper/WrappedSceneProperty.hxx @@ -39,7 +39,7 @@ class WrappedD3DTransformMatrixProperty : public WrappedProperty { public: explicit WrappedD3DTransformMatrixProperty( - const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact); + std::shared_ptr<Chart2ModelContact> spChart2ModelContact); virtual ~WrappedD3DTransformMatrixProperty() override; virtual void setPropertyValue( const css::uno::Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override; diff --git a/chart2/source/controller/chartapiwrapper/WrappedSeriesAreaOrLineProperty.cxx b/chart2/source/controller/chartapiwrapper/WrappedSeriesAreaOrLineProperty.cxx index 88fa72696c03..5b073ca80152 100644 --- a/chart2/source/controller/chartapiwrapper/WrappedSeriesAreaOrLineProperty.cxx +++ b/chart2/source/controller/chartapiwrapper/WrappedSeriesAreaOrLineProperty.cxx @@ -17,6 +17,8 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <utility> + #include "WrappedSeriesAreaOrLineProperty.hxx" #include "DataSeriesPointWrapper.hxx" @@ -25,13 +27,13 @@ namespace chart::wrapper WrappedSeriesAreaOrLineProperty::WrappedSeriesAreaOrLineProperty( const OUString& rOuterName - , const OUString& rInnerAreaTypeName - , const OUString& rInnerLineTypeName + , OUString aInnerAreaTypeName + , OUString aInnerLineTypeName , DataSeriesPointWrapper* pDataSeriesPointWrapper ) : WrappedProperty( rOuterName, OUString() ) , m_pDataSeriesPointWrapper( pDataSeriesPointWrapper ) - , m_aInnerAreaTypeName( rInnerAreaTypeName ) - , m_aInnerLineTypeName( rInnerLineTypeName ) + , m_aInnerAreaTypeName(std::move( aInnerAreaTypeName )) + , m_aInnerLineTypeName(std::move( aInnerLineTypeName )) { } WrappedSeriesAreaOrLineProperty::~WrappedSeriesAreaOrLineProperty() diff --git a/chart2/source/controller/chartapiwrapper/WrappedSeriesAreaOrLineProperty.hxx b/chart2/source/controller/chartapiwrapper/WrappedSeriesAreaOrLineProperty.hxx index ba77b6939f34..f3561e7361d4 100644 --- a/chart2/source/controller/chartapiwrapper/WrappedSeriesAreaOrLineProperty.hxx +++ b/chart2/source/controller/chartapiwrapper/WrappedSeriesAreaOrLineProperty.hxx @@ -28,7 +28,7 @@ class WrappedSeriesAreaOrLineProperty : public WrappedProperty { public: WrappedSeriesAreaOrLineProperty( const OUString& rOuterName - , const OUString& rInnerAreaTypeName, const OUString& rInnerLineTypeName + , OUString aInnerAreaTypeName, OUString aInnerLineTypeName , DataSeriesPointWrapper* pDataSeriesPointWrapper ); virtual ~WrappedSeriesAreaOrLineProperty() override; diff --git a/chart2/source/controller/chartapiwrapper/WrappedSeriesOrDiagramProperty.hxx b/chart2/source/controller/chartapiwrapper/WrappedSeriesOrDiagramProperty.hxx index 88dc862ea2d9..8b0b54db3d7a 100644 --- a/chart2/source/controller/chartapiwrapper/WrappedSeriesOrDiagramProperty.hxx +++ b/chart2/source/controller/chartapiwrapper/WrappedSeriesOrDiagramProperty.hxx @@ -20,9 +20,10 @@ #include <WrappedProperty.hxx> #include "Chart2ModelContact.hxx" -#include <DiagramHelper.hxx> +#include <DataSeries.hxx> #include <memory> +#include <utility> #include <vector> namespace com::sun::star::chart2 { class XDataSeries; } @@ -46,10 +47,10 @@ public: virtual void setValueToSeries( const css::uno::Reference< css::beans::XPropertySet >& xSeriesPropertySet, const PROPERTYTYPE & aNewValue ) const =0; explicit WrappedSeriesOrDiagramProperty( const OUString& rName, const css::uno::Any& rDefaulValue - , const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact + , std::shared_ptr<Chart2ModelContact> spChart2ModelContact , tSeriesOrDiagramPropertyType ePropertyType ) : WrappedProperty(rName,OUString()) - , m_spChart2ModelContact(spChart2ModelContact) + , m_spChart2ModelContact(std::move(spChart2ModelContact)) , m_aOuterValue(rDefaulValue) , m_aDefaultValue(rDefaulValue) , m_ePropertyType( ePropertyType ) @@ -58,30 +59,31 @@ public: bool detectInnerValue( PROPERTYTYPE& rValue, bool& rHasAmbiguousValue ) const { - bool bHasDetectableInnerValue = false; rHasAmbiguousValue = false; - if( m_ePropertyType == DIAGRAM && - m_spChart2ModelContact ) + if( m_ePropertyType != DIAGRAM || !m_spChart2ModelContact ) + return false; + bool bHasDetectableInnerValue = false; + rtl::Reference<Diagram> xDiagram = m_spChart2ModelContact->getDiagram(); + if (!xDiagram) + return false; + std::vector< rtl::Reference< DataSeries > > aSeriesVector = + xDiagram->getDataSeries(); + for (auto const& series : aSeriesVector) { - std::vector< css::uno::Reference< css::chart2::XDataSeries > > aSeriesVector( - ::chart::DiagramHelper::getDataSeriesFromDiagram( m_spChart2ModelContact->getDiagram() ) ); - for (auto const& series : aSeriesVector) + PROPERTYTYPE aCurValue = getValueFromSeries( series ); + if( !bHasDetectableInnerValue ) + rValue = aCurValue; + else { - PROPERTYTYPE aCurValue = getValueFromSeries( css::uno::Reference< css::beans::XPropertySet >::query(series) ); - if( !bHasDetectableInnerValue ) - rValue = aCurValue; - else + if( rValue != aCurValue ) { - if( rValue != aCurValue ) - { - rHasAmbiguousValue = true; - break; - } - else - rValue = aCurValue; + rHasAmbiguousValue = true; + break; } - bHasDetectableInnerValue = true; + else + rValue = aCurValue; } + bHasDetectableInnerValue = true; } return bHasDetectableInnerValue; } @@ -90,15 +92,11 @@ public: if( m_ePropertyType == DIAGRAM && m_spChart2ModelContact ) { - std::vector< css::uno::Reference< css::chart2::XDataSeries > > aSeriesVector( - ::chart::DiagramHelper::getDataSeriesFromDiagram( m_spChart2ModelContact->getDiagram() ) ); + std::vector< rtl::Reference< DataSeries > > aSeriesVector = + m_spChart2ModelContact->getDiagram()->getDataSeries(); for (auto const& series : aSeriesVector) { - css::uno::Reference< css::beans::XPropertySet > xSeriesPropertySet(series, css::uno::UNO_QUERY); - if( xSeriesPropertySet.is() ) - { - setValueToSeries( xSeriesPropertySet, aNewValue ); - } + setValueToSeries( series, aNewValue ); } } } diff --git a/chart2/source/controller/chartapiwrapper/WrappedSplineProperties.cxx b/chart2/source/controller/chartapiwrapper/WrappedSplineProperties.cxx index 6d088a50bd81..53ce90fa24f9 100644 --- a/chart2/source/controller/chartapiwrapper/WrappedSplineProperties.cxx +++ b/chart2/source/controller/chartapiwrapper/WrappedSplineProperties.cxx @@ -20,7 +20,7 @@ #include "WrappedSplineProperties.hxx" #include "Chart2ModelContact.hxx" #include <FastPropertyIdRanges.hxx> -#include <DiagramHelper.hxx> +#include <ChartType.hxx> #include <WrappedProperty.hxx> #include <unonames.hxx> @@ -29,10 +29,10 @@ #include <com/sun/star/chart2/CurveStyle.hpp> #include <com/sun/star/beans/PropertyAttribute.hpp> #include <com/sun/star/beans/XPropertySet.hpp> +#include <utility> using namespace ::com::sun::star; using ::com::sun::star::uno::Any; -using ::com::sun::star::uno::Sequence; using ::com::sun::star::beans::Property; namespace chart::wrapper @@ -47,32 +47,30 @@ template< typename PROPERTYTYPE > class WrappedSplineProperty : public WrappedProperty { public: - explicit WrappedSplineProperty( const OUString& rOuterName, const OUString& rInnerName + explicit WrappedSplineProperty( const OUString& rOuterName, OUString aInnerName , const css::uno::Any& rDefaulValue - , const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact ) + , std::shared_ptr<Chart2ModelContact> spChart2ModelContact ) : WrappedProperty(rOuterName,OUString()) - , m_spChart2ModelContact(spChart2ModelContact) + , m_spChart2ModelContact(std::move(spChart2ModelContact)) , m_aOuterValue(rDefaulValue) , m_aDefaultValue(rDefaulValue) - , m_aOwnInnerName(rInnerName) + , m_aOwnInnerName(std::move(aInnerName)) { } bool detectInnerValue( PROPERTYTYPE& rValue, bool& rHasAmbiguousValue ) const { - bool bHasDetectableInnerValue = false; rHasAmbiguousValue = false; - Sequence< css::uno::Reference< css::chart2::XChartType > > aChartTypes( - ::chart::DiagramHelper::getChartTypesFromDiagram( m_spChart2ModelContact->getDiagram() ) ); - for( sal_Int32 nN = aChartTypes.getLength(); nN--; ) + rtl::Reference<Diagram> xDiagram = m_spChart2ModelContact->getDiagram(); + if (!xDiagram) + return false; + bool bHasDetectableInnerValue = false; + std::vector< rtl::Reference< ChartType > > aChartTypes = xDiagram->getChartTypes(); + for( sal_Int32 nN = aChartTypes.size(); nN--; ) { try { - uno::Reference<beans::XPropertySet> xChartTypePropertySet(aChartTypes[nN], uno::UNO_QUERY); - if (!xChartTypePropertySet.is()) - continue; - - Any aSingleValue = convertInnerToOuterValue( xChartTypePropertySet->getPropertyValue(m_aOwnInnerName) ); + Any aSingleValue = convertInnerToOuterValue( aChartTypes[nN]->getPropertyValue(m_aOwnInnerName) ); PROPERTYTYPE aCurValue = PROPERTYTYPE(); aSingleValue >>= aCurValue; if( !bHasDetectableInnerValue ) @@ -114,17 +112,13 @@ public: if( !(bHasAmbiguousValue || aNewValue != aOldValue) ) return; - Sequence< css::uno::Reference< css::chart2::XChartType > > aChartTypes( - ::chart::DiagramHelper::getChartTypesFromDiagram( m_spChart2ModelContact->getDiagram() ) ); - for( sal_Int32 nN = aChartTypes.getLength(); nN--; ) + std::vector< rtl::Reference< ChartType > > aChartTypes = + m_spChart2ModelContact->getDiagram()->getChartTypes(); + for( sal_Int32 nN = aChartTypes.size(); nN--; ) { try { - css::uno::Reference< css::beans::XPropertySet > xChartTypePropertySet( aChartTypes[nN], css::uno::UNO_QUERY ); - if( xChartTypePropertySet.is() ) - { - xChartTypePropertySet->setPropertyValue(m_aOwnInnerName,convertOuterToInnerValue(uno::Any(aNewValue))); - } + aChartTypes[nN]->setPropertyValue(m_aOwnInnerName,convertOuterToInnerValue(uno::Any(aNewValue))); } catch( uno::Exception & ex ) { diff --git a/chart2/source/controller/chartapiwrapper/WrappedStatisticProperties.cxx b/chart2/source/controller/chartapiwrapper/WrappedStatisticProperties.cxx index bc83ba60df87..e5278bb5da49 100644 --- a/chart2/source/controller/chartapiwrapper/WrappedStatisticProperties.cxx +++ b/chart2/source/controller/chartapiwrapper/WrappedStatisticProperties.cxx @@ -21,6 +21,7 @@ #include "WrappedSeriesOrDiagramProperty.hxx" #include <FastPropertyIdRanges.hxx> #include <RegressionCurveHelper.hxx> +#include <RegressionCurveModel.hxx> #include <ErrorBar.hxx> #include <StatisticsHelper.hxx> #include <unonames.hxx> @@ -31,7 +32,6 @@ #include <com/sun/star/chart/ErrorBarStyle.hpp> #include <com/sun/star/chart/ChartErrorIndicatorType.hpp> #include <com/sun/star/chart/ChartRegressionCurveType.hpp> -#include <com/sun/star/chart2/XChartDocument.hpp> #include <com/sun/star/chart2/data/XRangeXMLConversion.hpp> #include <com/sun/star/chart2/XRegressionCurveContainer.hpp> #include <utility> @@ -144,8 +144,7 @@ void lcl_ConvertRangeFromXML( lcl_getDataProviderFromContact( spChart2ModelContact ), uno::UNO_QUERY ); if( xConverter.is()) { - OUString aResult = xConverter->convertRangeFromXML( rInOutRange ); - rInOutRange = aResult; + rInOutRange = xConverter->convertRangeFromXML( rInOutRange ); } } } @@ -160,8 +159,7 @@ void lcl_ConvertRangeToXML( lcl_getDataProviderFromContact( spChart2ModelContact ), uno::UNO_QUERY ); if( xConverter.is()) { - OUString aResult = xConverter->convertRangeToXML( rInOutRange ); - rInOutRange = aResult; + rInOutRange = xConverter->convertRangeToXML( rInOutRange ); } } } @@ -840,9 +838,10 @@ css::chart::ChartRegressionCurveType WrappedRegressionCurvesProperty::getValueFr void WrappedRegressionCurvesProperty::setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, const css::chart::ChartRegressionCurveType& aNewValue ) const { uno::Reference< chart2::XRegressionCurveContainer > xRegressionCurveContainer( xSeriesPropertySet, uno::UNO_QUERY ); - uno::Reference< chart2::XRegressionCurve > xRegressionCurve( xSeriesPropertySet, uno::UNO_QUERY ); - - if( xRegressionCurveContainer.is() && xRegressionCurve.is() ) + if (!xRegressionCurveContainer) + return; + rtl::Reference< ::chart::RegressionCurveModel> xRegressionCurve = RegressionCurveHelper::getFirstCurveNotMeanValueLine( xRegressionCurveContainer ); + if( xRegressionCurve.is() ) { SvxChartRegress eNewRegressionType = lcl_getRegressionType( aNewValue ); @@ -906,7 +905,7 @@ Reference< beans::XPropertySet > WrappedStatisticPropertySetProperty::getValueFr { case PROPERTY_SET_TYPE_REGRESSION: if( xRegCnt.is() ) - xResult.set( RegressionCurveHelper::getFirstCurveNotMeanValueLine( xRegCnt ), uno::UNO_QUERY ); + xResult = RegressionCurveHelper::getFirstCurveNotMeanValueLine( xRegCnt ); break; case PROPERTY_SET_TYPE_ERROR_BAR: if( xSeriesPropertySet.is()) @@ -914,7 +913,7 @@ Reference< beans::XPropertySet > WrappedStatisticPropertySetProperty::getValueFr break; case PROPERTY_SET_TYPE_MEAN_VALUE: if( xRegCnt.is() ) - xResult.set( RegressionCurveHelper::getMeanValueLine( xRegCnt ), uno::UNO_QUERY ); + xResult = RegressionCurveHelper::getMeanValueLine( xRegCnt ); break; } diff --git a/chart2/source/controller/chartapiwrapper/WrappedStockProperties.cxx b/chart2/source/controller/chartapiwrapper/WrappedStockProperties.cxx index 3a8068ec984a..093321843018 100644 --- a/chart2/source/controller/chartapiwrapper/WrappedStockProperties.cxx +++ b/chart2/source/controller/chartapiwrapper/WrappedStockProperties.cxx @@ -20,15 +20,14 @@ #include "WrappedStockProperties.hxx" #include "Chart2ModelContact.hxx" #include <FastPropertyIdRanges.hxx> -#include <DiagramHelper.hxx> +#include <DataSeries.hxx> #include <ControllerLockGuard.hxx> #include <WrappedProperty.hxx> -#include <com/sun/star/lang/XMultiServiceFactory.hpp> -#include <com/sun/star/chart2/XChartDocument.hpp> #include <com/sun/star/beans/PropertyAttribute.hpp> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <ChartTypeManager.hxx> #include <ChartTypeTemplate.hxx> +#include <utility> using namespace ::com::sun::star; using ::com::sun::star::uno::Reference; @@ -43,14 +42,14 @@ class WrappedStockProperty : public WrappedProperty { public: explicit WrappedStockProperty( const OUString& rOuterName - , const css::uno::Any& rDefaulValue - , const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact ); + , css::uno::Any aDefaultValue + , std::shared_ptr<Chart2ModelContact> spChart2ModelContact ); void setPropertyValue( const css::uno::Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override; css::uno::Any getPropertyDefault( const css::uno::Reference< css::beans::XPropertyState >& xInnerPropertyState ) const override; - virtual uno::Reference< chart2::XChartTypeTemplate > getNewTemplate( bool bNewValue, const OUString& rCurrentTemplate, const Reference< lang::XMultiServiceFactory >& xFactory ) const = 0; + virtual rtl::Reference< ::chart::ChartTypeTemplate > getNewTemplate( bool bNewValue, const OUString& rCurrentTemplate, const rtl::Reference< ::chart::ChartTypeManager >& xFactory ) const = 0; protected: std::shared_ptr< Chart2ModelContact > m_spChart2ModelContact; @@ -61,11 +60,11 @@ protected: } WrappedStockProperty::WrappedStockProperty( const OUString& rOuterName - , const css::uno::Any& rDefaulValue - , const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact ) + , css::uno::Any aDefaultValue + , std::shared_ptr<Chart2ModelContact> spChart2ModelContact ) : WrappedProperty(rOuterName,OUString()) - , m_spChart2ModelContact(spChart2ModelContact) - , m_aDefaultValue(rDefaulValue) + , m_spChart2ModelContact(std::move(spChart2ModelContact)) + , m_aDefaultValue(std::move(aDefaultValue)) { } @@ -79,15 +78,17 @@ void WrappedStockProperty::setPropertyValue( const css::uno::Any& rOuterValue, c rtl::Reference< ChartModel > xChartDoc( m_spChart2ModelContact->getDocumentModel() ); rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); - sal_Int32 nDimension = ::chart::DiagramHelper::getDimension( xDiagram ); - if( !(xChartDoc.is() && xDiagram.is() && nDimension==2) ) + if( !xChartDoc || !xDiagram ) + return; + sal_Int32 nDimension = xDiagram->getDimension(); + if( nDimension != 2 ) return; rtl::Reference< ::chart::ChartTypeManager > xChartTypeManager = xChartDoc->getTypeManager(); - DiagramHelper::tTemplateWithServiceName aTemplateAndService = - DiagramHelper::getTemplateForDiagram( xDiagram, xChartTypeManager ); + Diagram::tTemplateWithServiceName aTemplateAndService = + xDiagram->getTemplate( xChartTypeManager ); - uno::Reference< chart2::XChartTypeTemplate > xTemplate = + rtl::Reference< ::chart::ChartTypeTemplate > xTemplate = getNewTemplate( bNewValue, aTemplateAndService.sServiceName, xChartTypeManager ); if(!xTemplate.is()) @@ -119,7 +120,7 @@ public: css::uno::Any getPropertyValue( const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override; - uno::Reference< chart2::XChartTypeTemplate > getNewTemplate( bool bNewValue, const OUString& rCurrentTemplate, const Reference< lang::XMultiServiceFactory >& xFactory ) const override; + rtl::Reference< ::chart::ChartTypeTemplate > getNewTemplate( bool bNewValue, const OUString& rCurrentTemplate, const rtl::Reference< ::chart::ChartTypeManager >& xFactory ) const override; }; } @@ -135,13 +136,13 @@ css::uno::Any WrappedVolumeProperty::getPropertyValue( const css::uno::Reference rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); if( xDiagram.is() && xChartDoc.is() ) { - std::vector< uno::Reference< chart2::XDataSeries > > aSeriesVector( - DiagramHelper::getDataSeriesFromDiagram( xDiagram ) ); + std::vector< rtl::Reference< DataSeries > > aSeriesVector = + xDiagram->getDataSeries(); if( !aSeriesVector.empty() ) { rtl::Reference< ::chart::ChartTypeManager > xChartTypeManager = xChartDoc->getTypeManager(); - DiagramHelper::tTemplateWithServiceName aTemplateAndService = - DiagramHelper::getTemplateForDiagram( xDiagram, xChartTypeManager ); + Diagram::tTemplateWithServiceName aTemplateAndService = + xDiagram->getTemplate( xChartTypeManager ); if( aTemplateAndService.sServiceName == "com.sun.star.chart2.template.StockVolumeLowHighClose" || aTemplateAndService.sServiceName == "com.sun.star.chart2.template.StockVolumeOpenLowHighClose" ) @@ -155,9 +156,9 @@ css::uno::Any WrappedVolumeProperty::getPropertyValue( const css::uno::Reference return m_aOuterValue; } -uno::Reference< chart2::XChartTypeTemplate > WrappedVolumeProperty::getNewTemplate( bool bNewValue, const OUString& rCurrentTemplate, const Reference< lang::XMultiServiceFactory >& xFactory ) const +rtl::Reference< ::chart::ChartTypeTemplate > WrappedVolumeProperty::getNewTemplate( bool bNewValue, const OUString& rCurrentTemplate, const rtl::Reference< ::chart::ChartTypeManager >& xFactory ) const { - uno::Reference< chart2::XChartTypeTemplate > xTemplate; + rtl::Reference< ::chart::ChartTypeTemplate > xTemplate; if(!xFactory.is()) return xTemplate; @@ -165,16 +166,16 @@ uno::Reference< chart2::XChartTypeTemplate > WrappedVolumeProperty::getNewTempla if( bNewValue ) //add volume { if( rCurrentTemplate == "com.sun.star.chart2.template.StockLowHighClose" ) - xTemplate.set( xFactory->createInstance( "com.sun.star.chart2.template.StockVolumeLowHighClose" ), uno::UNO_QUERY ); + xTemplate = xFactory->createTemplate( "com.sun.star.chart2.template.StockVolumeLowHighClose" ); else if( rCurrentTemplate == "com.sun.star.chart2.template.StockOpenLowHighClose" ) - xTemplate.set( xFactory->createInstance( "com.sun.star.chart2.template.StockVolumeOpenLowHighClose" ), uno::UNO_QUERY ); + xTemplate = xFactory->createTemplate( "com.sun.star.chart2.template.StockVolumeOpenLowHighClose" ); } else //remove volume { if( rCurrentTemplate == "com.sun.star.chart2.template.StockVolumeLowHighClose" ) - xTemplate.set( xFactory->createInstance( "com.sun.star.chart2.template.StockLowHighClose" ), uno::UNO_QUERY ); + xTemplate = xFactory->createTemplate( "com.sun.star.chart2.template.StockLowHighClose" ); else if( rCurrentTemplate == "com.sun.star.chart2.template.StockVolumeOpenLowHighClose" ) - xTemplate.set( xFactory->createInstance( "com.sun.star.chart2.template.StockOpenLowHighClose" ), uno::UNO_QUERY ); + xTemplate = xFactory->createTemplate( "com.sun.star.chart2.template.StockOpenLowHighClose" ); } return xTemplate; } @@ -188,7 +189,7 @@ public: css::uno::Any getPropertyValue( const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override; - uno::Reference< chart2::XChartTypeTemplate > getNewTemplate( bool bNewValue, const OUString& rCurrentTemplate, const Reference< lang::XMultiServiceFactory >& xFactory ) const override; + rtl::Reference< ::chart::ChartTypeTemplate > getNewTemplate( bool bNewValue, const OUString& rCurrentTemplate, const rtl::Reference< ChartTypeManager >& xFactory ) const override; }; } @@ -204,13 +205,13 @@ css::uno::Any WrappedUpDownProperty::getPropertyValue( const css::uno::Reference rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); if( xDiagram.is() && xChartDoc.is() ) { - std::vector< uno::Reference< chart2::XDataSeries > > aSeriesVector( - DiagramHelper::getDataSeriesFromDiagram( xDiagram ) ); + std::vector< rtl::Reference< DataSeries > > aSeriesVector = + xDiagram->getDataSeries(); if( !aSeriesVector.empty() ) { rtl::Reference< ::chart::ChartTypeManager > xChartTypeManager = xChartDoc->getTypeManager(); - DiagramHelper::tTemplateWithServiceName aTemplateAndService = - DiagramHelper::getTemplateForDiagram( xDiagram, xChartTypeManager ); + Diagram::tTemplateWithServiceName aTemplateAndService = + xDiagram->getTemplate( xChartTypeManager ); if( aTemplateAndService.sServiceName == "com.sun.star.chart2.template.StockOpenLowHighClose" || aTemplateAndService.sServiceName == "com.sun.star.chart2.template.StockVolumeOpenLowHighClose" ) @@ -223,22 +224,22 @@ css::uno::Any WrappedUpDownProperty::getPropertyValue( const css::uno::Reference } return m_aOuterValue; } -uno::Reference< chart2::XChartTypeTemplate > WrappedUpDownProperty::getNewTemplate( bool bNewValue, const OUString& rCurrentTemplate, const Reference< lang::XMultiServiceFactory >& xFactory ) const +rtl::Reference< ::chart::ChartTypeTemplate > WrappedUpDownProperty::getNewTemplate( bool bNewValue, const OUString& rCurrentTemplate, const rtl::Reference< ChartTypeManager >& xFactory ) const { - uno::Reference< chart2::XChartTypeTemplate > xTemplate; + rtl::Reference< ::chart::ChartTypeTemplate > xTemplate; if( bNewValue ) //add open series { if( rCurrentTemplate == "com.sun.star.chart2.template.StockLowHighClose" ) - xTemplate.set( xFactory->createInstance( "com.sun.star.chart2.template.StockOpenLowHighClose" ), uno::UNO_QUERY ); + xTemplate = xFactory->createTemplate( "com.sun.star.chart2.template.StockOpenLowHighClose" ); else if( rCurrentTemplate == "com.sun.star.chart2.template.StockVolumeLowHighClose" ) - xTemplate.set( xFactory->createInstance( "com.sun.star.chart2.template.StockVolumeOpenLowHighClose" ), uno::UNO_QUERY ); + xTemplate = xFactory->createTemplate( "com.sun.star.chart2.template.StockVolumeOpenLowHighClose" ); } else //remove open series { if( rCurrentTemplate == "com.sun.star.chart2.template.StockOpenLowHighClose" ) - xTemplate.set( xFactory->createInstance( "com.sun.star.chart2.template.StockLowHighClose" ), uno::UNO_QUERY ); + xTemplate = xFactory->createTemplate( "com.sun.star.chart2.template.StockLowHighClose" ); else if( rCurrentTemplate == "com.sun.star.chart2.template.StockVolumeOpenLowHighClose" ) - xTemplate.set( xFactory->createInstance( "com.sun.star.chart2.template.StockVolumeLowHighClose" ), uno::UNO_QUERY ); + xTemplate = xFactory->createTemplate( "com.sun.star.chart2.template.StockVolumeLowHighClose" ); } return xTemplate; } diff --git a/chart2/source/controller/chartapiwrapper/WrappedSymbolProperties.cxx b/chart2/source/controller/chartapiwrapper/WrappedSymbolProperties.cxx index 484861b68338..79c45ea1d888 100644 --- a/chart2/source/controller/chartapiwrapper/WrappedSymbolProperties.cxx +++ b/chart2/source/controller/chartapiwrapper/WrappedSymbolProperties.cxx @@ -20,6 +20,7 @@ #include "WrappedSymbolProperties.hxx" #include "WrappedSeriesOrDiagramProperty.hxx" #include <FastPropertyIdRanges.hxx> +#include <ChartType.hxx> #include <ChartTypeHelper.hxx> #include <com/sun/star/chart2/Symbol.hpp> #include <com/sun/star/chart2/SymbolStyle.hpp> @@ -31,7 +32,7 @@ #include <vcl/GraphicLoader.hxx> #include <vcl/graph.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> using namespace ::com::sun::star; using ::com::sun::star::uno::Any; @@ -285,8 +286,8 @@ beans::PropertyState WrappedSymbolTypeProperty::getPropertyState( const Referenc m_spChart2ModelContact) { rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); - Reference< chart2::XDataSeries > xSeries( xInnerPropertyState, uno::UNO_QUERY ); - Reference< chart2::XChartType > xChartType( DiagramHelper::getChartTypeOfSeries( xDiagram, xSeries ) ); + rtl::Reference< ::chart::DataSeries > xSeries( dynamic_cast<DataSeries*>(xInnerPropertyState.get()) ); + rtl::Reference< ChartType > xChartType( xDiagram->getChartTypeOfSeries( xSeries ) ); if( ChartTypeHelper::isSupportingSymbolProperties( xChartType, 2 ) ) return beans::PropertyState_DIRECT_VALUE; } |