diff options
Diffstat (limited to 'chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx')
-rw-r--r-- | chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx | 99 |
1 files changed, 49 insertions, 50 deletions
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 ); |