diff options
Diffstat (limited to 'chart2/source/model/template/CandleStickChartType.cxx')
-rw-r--r-- | chart2/source/model/template/CandleStickChartType.cxx | 103 |
1 files changed, 35 insertions, 68 deletions
diff --git a/chart2/source/model/template/CandleStickChartType.cxx b/chart2/source/model/template/CandleStickChartType.cxx index af0c1f04f52b..247a68406808 100644 --- a/chart2/source/model/template/CandleStickChartType.cxx +++ b/chart2/source/model/template/CandleStickChartType.cxx @@ -24,7 +24,7 @@ #include <servicenames_charttypes.hxx> #include <com/sun/star/beans/PropertyAttribute.hpp> #include <cppuhelper/supportsservice.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> namespace com::sun::star::uno { class XComponentContext; } @@ -79,66 +79,17 @@ void lcl_AddPropertiesToVector( | beans::PropertyAttribute::MAYBEDEFAULT ); } -struct StaticCandleStickChartTypeDefaults_Initializer -{ - ::chart::tPropertyValueMap* operator()() - { - static ::chart::tPropertyValueMap aStaticDefaults; - lcl_AddDefaultsToMap( aStaticDefaults ); - return &aStaticDefaults; - } -private: - static void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap ) - { - // must match default in CTOR! - ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CANDLESTICKCHARTTYPE_JAPANESE, false ); - ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CANDLESTICKCHARTTYPE_SHOW_FIRST, false ); - ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CANDLESTICKCHARTTYPE_SHOW_HIGH_LOW, true ); - } -}; - -struct StaticCandleStickChartTypeDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticCandleStickChartTypeDefaults_Initializer > -{ -}; - -struct StaticCandleStickChartTypeInfoHelper_Initializer -{ - ::cppu::OPropertyArrayHelper* operator()() - { - static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() ); - return &aPropHelper; - } - -private: - static Sequence< Property > lcl_GetPropertySequence() - { - std::vector< css::beans::Property > aProperties; - lcl_AddPropertiesToVector( aProperties ); - - std::sort( aProperties.begin(), aProperties.end(), - ::chart::PropertyNameLess() ); - - return comphelper::containerToSequence( aProperties ); - } - -}; - -struct StaticCandleStickChartTypeInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticCandleStickChartTypeInfoHelper_Initializer > -{ -}; - -struct StaticCandleStickChartTypeInfo_Initializer -{ - uno::Reference< beans::XPropertySetInfo >* operator()() - { - static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo( - ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticCandleStickChartTypeInfoHelper::get() ) ); - return &xPropertySetInfo; - } -}; - -struct StaticCandleStickChartTypeInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticCandleStickChartTypeInfo_Initializer > +::cppu::OPropertyArrayHelper& StaticCandleStickChartTypeInfoHelper() { + static ::cppu::OPropertyArrayHelper aPropHelper = []() + { + std::vector< css::beans::Property > aProperties; + lcl_AddPropertiesToVector( aProperties ); + std::sort( aProperties.begin(), aProperties.end(), + ::chart::PropertyNameLess() ); + return comphelper::containerToSequence( aProperties ); + }(); + return aPropHelper; }; } // anonymous namespace @@ -206,6 +157,11 @@ uno::Reference< util::XCloneable > SAL_CALL CandleStickChartType::createClone() return uno::Reference< util::XCloneable >( new CandleStickChartType( *this )); } +rtl::Reference< ChartType > CandleStickChartType::cloneChartType() const +{ + return new CandleStickChartType( *this ); +} + // ____ XChartType ____ OUString SAL_CALL CandleStickChartType::getChartType() { @@ -263,25 +219,36 @@ OUString SAL_CALL CandleStickChartType::getRoleOfSequenceForSeriesLabel() } // ____ OPropertySet ____ -uno::Any CandleStickChartType::GetDefaultValue( sal_Int32 nHandle ) const +void CandleStickChartType::GetDefaultValue( sal_Int32 nHandle, uno::Any& rAny ) const { - const tPropertyValueMap& rStaticDefaults = *StaticCandleStickChartTypeDefaults::get(); - tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) ); - if( aFound == rStaticDefaults.end() ) - return uno::Any(); - return (*aFound).second; + static const ::chart::tPropertyValueMap aStaticDefaults = []() + { + // must match default in CTOR! + ::chart::tPropertyValueMap aTmp; + ::chart::PropertyHelper::setPropertyValueDefault( aTmp, PROP_CANDLESTICKCHARTTYPE_JAPANESE, false ); + ::chart::PropertyHelper::setPropertyValueDefault( aTmp, PROP_CANDLESTICKCHARTTYPE_SHOW_FIRST, false ); + ::chart::PropertyHelper::setPropertyValueDefault( aTmp, PROP_CANDLESTICKCHARTTYPE_SHOW_HIGH_LOW, true ); + return aTmp; + }(); + tPropertyValueMap::const_iterator aFound( aStaticDefaults.find( nHandle ) ); + if( aFound == aStaticDefaults.end() ) + rAny.clear(); + else + rAny = (*aFound).second; } // ____ OPropertySet ____ ::cppu::IPropertyArrayHelper & SAL_CALL CandleStickChartType::getInfoHelper() { - return *StaticCandleStickChartTypeInfoHelper::get(); + return StaticCandleStickChartTypeInfoHelper(); } // ____ XPropertySet ____ Reference< beans::XPropertySetInfo > SAL_CALL CandleStickChartType::getPropertySetInfo() { - return *StaticCandleStickChartTypeInfo::get(); + static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo( + ::cppu::OPropertySetHelper::createPropertySetInfo(StaticCandleStickChartTypeInfoHelper() ) ); + return xPropertySetInfo; } void SAL_CALL CandleStickChartType::setFastPropertyValue_NoBroadcast( |