diff options
Diffstat (limited to 'chart2/source/model/template/LineChartType.cxx')
-rw-r--r-- | chart2/source/model/template/LineChartType.cxx | 127 |
1 files changed, 51 insertions, 76 deletions
diff --git a/chart2/source/model/template/LineChartType.cxx b/chart2/source/model/template/LineChartType.cxx index 64b2fe9c146f..e9d7cf808e53 100644 --- a/chart2/source/model/template/LineChartType.cxx +++ b/chart2/source/model/template/LineChartType.cxx @@ -43,90 +43,59 @@ enum PROP_LINECHARTTYPE_SPLINE_ORDER }; -void lcl_AddPropertiesToVector( - std::vector< Property > & rOutProperties ) +::chart::tPropertyValueMap& StaticLineChartTypeDefaults() +{ + static ::chart::tPropertyValueMap aStaticDefaults = + []() + { + ::chart::tPropertyValueMap aOutMap; + ::chart::PropertyHelper::setPropertyValueDefault( aOutMap, PROP_LINECHARTTYPE_CURVE_STYLE, ::chart2::CurveStyle_LINES ); + ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( aOutMap, PROP_LINECHARTTYPE_CURVE_RESOLUTION, 20 ); + + // todo: check whether order 3 means polygons of order 3 or 2. (see + // http://www.people.nnov.ru/fractal/Splines/Basis.htm ) + ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( aOutMap, PROP_LINECHARTTYPE_SPLINE_ORDER, 3 ); + return aOutMap; + }(); + return aStaticDefaults; +} + +::cppu::OPropertyArrayHelper& StaticLineChartTypeInfoHelper() { - rOutProperties.emplace_back( CHART_UNONAME_CURVE_STYLE, + static ::cppu::OPropertyArrayHelper aPropHelper( + []() + { + std::vector< css::beans::Property > aProperties { + { CHART_UNONAME_CURVE_STYLE, PROP_LINECHARTTYPE_CURVE_STYLE, cppu::UnoType<chart2::CurveStyle>::get(), beans::PropertyAttribute::BOUND - | beans::PropertyAttribute::MAYBEDEFAULT ); - - rOutProperties.emplace_back( CHART_UNONAME_CURVE_RESOLUTION, + | beans::PropertyAttribute::MAYBEDEFAULT }, + { CHART_UNONAME_CURVE_RESOLUTION, PROP_LINECHARTTYPE_CURVE_RESOLUTION, cppu::UnoType<sal_Int32>::get(), beans::PropertyAttribute::BOUND - | beans::PropertyAttribute::MAYBEDEFAULT ); - rOutProperties.emplace_back( CHART_UNONAME_SPLINE_ORDER, + | beans::PropertyAttribute::MAYBEDEFAULT }, + { CHART_UNONAME_SPLINE_ORDER, PROP_LINECHARTTYPE_SPLINE_ORDER, cppu::UnoType<sal_Int32>::get(), beans::PropertyAttribute::BOUND - | beans::PropertyAttribute::MAYBEDEFAULT ); -} - -struct StaticLineChartTypeDefaults_Initializer -{ - ::chart::tPropertyValueMap* operator()() - { - static ::chart::tPropertyValueMap aStaticDefaults; - lcl_AddDefaultsToMap( aStaticDefaults ); - return &aStaticDefaults; - } -private: - static void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap ) - { - ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_LINECHARTTYPE_CURVE_STYLE, ::chart2::CurveStyle_LINES ); - ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_LINECHARTTYPE_CURVE_RESOLUTION, 20 ); - - // todo: check whether order 3 means polygons of order 3 or 2. (see - // http://www.people.nnov.ru/fractal/Splines/Basis.htm ) - ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_LINECHARTTYPE_SPLINE_ORDER, 3 ); - } -}; - -struct StaticLineChartTypeDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticLineChartTypeDefaults_Initializer > -{ -}; - -struct StaticLineChartTypeInfoHelper_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() ); + | beans::PropertyAttribute::MAYBEDEFAULT } }; - return comphelper::containerToSequence( aProperties ); - } + std::sort( aProperties.begin(), aProperties.end(), + ::chart::PropertyNameLess() ); -}; - -struct StaticLineChartTypeInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticLineChartTypeInfoHelper_Initializer > -{ -}; - -struct StaticLineChartTypeInfo_Initializer -{ - uno::Reference< beans::XPropertySetInfo >* operator()() - { - static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo( - ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticLineChartTypeInfoHelper::get() ) ); - return &xPropertySetInfo; - } -}; + return comphelper::containerToSequence( aProperties ); + }()); + return aPropHelper; +} -struct StaticLineChartTypeInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticLineChartTypeInfo_Initializer > +uno::Reference< beans::XPropertySetInfo >& StaticLineChartTypeInfo() { -}; + static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo( + ::cppu::OPropertySetHelper::createPropertySetInfo(StaticLineChartTypeInfoHelper() ) ); + return xPropertySetInfo; +} } // anonymous namespace @@ -151,6 +120,11 @@ uno::Reference< util::XCloneable > SAL_CALL LineChartType::createClone() return uno::Reference< util::XCloneable >( new LineChartType( *this )); } +rtl::Reference< ChartType > LineChartType::cloneChartType() const +{ + return new LineChartType( *this ); +} + // ____ XChartType ____ OUString SAL_CALL LineChartType::getChartType() { @@ -158,24 +132,25 @@ OUString SAL_CALL LineChartType::getChartType() } // ____ OPropertySet ____ -uno::Any LineChartType::GetDefaultValue( sal_Int32 nHandle ) const +void LineChartType::GetDefaultValue( sal_Int32 nHandle, uno::Any& rAny ) const { - const tPropertyValueMap& rStaticDefaults = *StaticLineChartTypeDefaults::get(); + const tPropertyValueMap& rStaticDefaults = StaticLineChartTypeDefaults(); tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) ); if( aFound == rStaticDefaults.end() ) - return uno::Any(); - return (*aFound).second; + rAny.clear(); + else + rAny = (*aFound).second; } ::cppu::IPropertyArrayHelper & SAL_CALL LineChartType::getInfoHelper() { - return *StaticLineChartTypeInfoHelper::get(); + return StaticLineChartTypeInfoHelper(); } // ____ XPropertySet ____ uno::Reference< beans::XPropertySetInfo > SAL_CALL LineChartType::getPropertySetInfo() { - return *StaticLineChartTypeInfo::get(); + return StaticLineChartTypeInfo(); } OUString SAL_CALL LineChartType::getImplementationName() |