diff options
Diffstat (limited to 'chart2/source/controller/chartapiwrapper/GridWrapper.cxx')
-rw-r--r-- | chart2/source/controller/chartapiwrapper/GridWrapper.cxx | 82 |
1 files changed, 33 insertions, 49 deletions
diff --git a/chart2/source/controller/chartapiwrapper/GridWrapper.cxx b/chart2/source/controller/chartapiwrapper/GridWrapper.cxx index 649086a1a458..4931b661cc53 100644 --- a/chart2/source/controller/chartapiwrapper/GridWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/GridWrapper.cxx @@ -21,6 +21,7 @@ #include <AxisHelper.hxx> #include "Chart2ModelContact.hxx" #include <AxisIndexDefines.hxx> +#include <BaseCoordinateSystem.hxx> #include <LinePropertiesHelper.hxx> #include <UserDefinedProperties.hxx> @@ -29,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) { } @@ -106,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(); } @@ -115,31 +86,33 @@ 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 Reference< beans::XPropertySet > GridWrapper::getInnerPropertySet() { - Reference< beans::XPropertySet > xRet; + rtl::Reference< GridProperties > xRet; try { - Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); - uno::Reference< XCoordinateSystem > xCooSys( AxisHelper::getCoordinateSystemByIndex( xDiagram, 0 /*nCooSysIndex*/ ) ); + rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); + 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 & ) { @@ -150,21 +123,32 @@ 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() { std::vector< std::unique_ptr<WrappedProperty> > aWrappedProperties; - aWrappedProperties.emplace_back( new WrappedDefaultProperty( "LineColor", "LineColor", uno::Any( sal_Int32( 0x000000) ) ) ); // black + aWrappedProperties.emplace_back( new WrappedDefaultProperty( u"LineColor"_ustr, u"LineColor"_ustr, uno::Any( sal_Int32( 0x000000) ) ) ); // black return aWrappedProperties; } OUString SAL_CALL GridWrapper::getImplementationName() { - return "com.sun.star.comp.chart.Grid"; + return u"com.sun.star.comp.chart.Grid"_ustr; } sal_Bool SAL_CALL GridWrapper::supportsService( const OUString& rServiceName ) @@ -175,10 +159,10 @@ sal_Bool SAL_CALL GridWrapper::supportsService( const OUString& rServiceName ) css::uno::Sequence< OUString > SAL_CALL GridWrapper::getSupportedServiceNames() { return { - "com.sun.star.chart.ChartGrid", - "com.sun.star.xml.UserDefinedAttributesSupplier", - "com.sun.star.drawing.LineProperties", - "com.sun.star.beans.PropertySet" + u"com.sun.star.chart.ChartGrid"_ustr, + u"com.sun.star.xml.UserDefinedAttributesSupplier"_ustr, + u"com.sun.star.drawing.LineProperties"_ustr, + u"com.sun.star.beans.PropertySet"_ustr }; } |