summaryrefslogtreecommitdiff
path: root/chart2/source/tools/RegressionEquation.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'chart2/source/tools/RegressionEquation.cxx')
-rwxr-xr-x[-rw-r--r--]chart2/source/tools/RegressionEquation.cxx132
1 files changed, 63 insertions, 69 deletions
diff --git a/chart2/source/tools/RegressionEquation.cxx b/chart2/source/tools/RegressionEquation.cxx
index ea16e5b7702a..cc9156569a8f 100644..100755
--- a/chart2/source/tools/RegressionEquation.cxx
+++ b/chart2/source/tools/RegressionEquation.cxx
@@ -118,32 +118,51 @@ void lcl_AddPropertiesToVector(
| beans::PropertyAttribute::MAYBEVOID ));
}
-void lcl_AddDefaultsToMap(
- ::chart::tPropertyValueMap & rOutMap )
+struct StaticRegressionEquationDefaults_Initializer
{
- ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_EQUATION_SHOW, false );
- ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_EQUATION_SHOW_CORRELATION_COEFF, false );
-// ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_EQUATION_SEPARATOR, ::rtl::OUString( sal_Unicode( '\n' )));
-
- // override other defaults
- ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::FillProperties::PROP_FILL_STYLE, drawing::FillStyle_NONE );
- ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::LineProperties::PROP_LINE_STYLE, drawing::LineStyle_NONE );
-
- float fDefaultCharHeight = 10.0;
- ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::CharacterProperties::PROP_CHAR_CHAR_HEIGHT, fDefaultCharHeight );
- ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::CharacterProperties::PROP_CHAR_ASIAN_CHAR_HEIGHT, fDefaultCharHeight );
- ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::CharacterProperties::PROP_CHAR_COMPLEX_CHAR_HEIGHT, fDefaultCharHeight );
-}
+ ::chart::tPropertyValueMap* operator()()
+ {
+ static ::chart::tPropertyValueMap aStaticDefaults;
+ lcl_AddDefaultsToMap( aStaticDefaults );
+ return &aStaticDefaults;
+ }
+private:
+ void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap )
+ {
+ ::chart::LineProperties::AddDefaultsToMap( rOutMap );
+ ::chart::FillProperties::AddDefaultsToMap( rOutMap );
+ ::chart::CharacterProperties::AddDefaultsToMap( rOutMap );
+
+ ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_EQUATION_SHOW, false );
+ ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_EQUATION_SHOW_CORRELATION_COEFF, false );
+ //::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_EQUATION_SEPARATOR, ::rtl::OUString( sal_Unicode( '\n' )));
+
+ // override other defaults
+ ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::FillProperties::PROP_FILL_STYLE, drawing::FillStyle_NONE );
+ ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::LineProperties::PROP_LINE_STYLE, drawing::LineStyle_NONE );
+
+ float fDefaultCharHeight = 10.0;
+ ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::CharacterProperties::PROP_CHAR_CHAR_HEIGHT, fDefaultCharHeight );
+ ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::CharacterProperties::PROP_CHAR_ASIAN_CHAR_HEIGHT, fDefaultCharHeight );
+ ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::CharacterProperties::PROP_CHAR_COMPLEX_CHAR_HEIGHT, fDefaultCharHeight );
+ }
+};
-const uno::Sequence< Property > & lcl_GetPropertySequence()
+struct StaticRegressionEquationDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticRegressionEquationDefaults_Initializer >
{
- static uno::Sequence< Property > aPropSeq;
+};
- // /--
- MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
- if( 0 == aPropSeq.getLength() )
+struct StaticRegressionEquationInfoHelper_Initializer
+{
+ ::cppu::OPropertyArrayHelper* operator()()
+ {
+ static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() );
+ return &aPropHelper;
+ }
+
+private:
+ uno::Sequence< Property > lcl_GetPropertySequence()
{
- // get properties
::std::vector< ::com::sun::star::beans::Property > aProperties;
lcl_AddPropertiesToVector( aProperties );
::chart::LineProperties::AddPropertiesToVector( aProperties );
@@ -151,25 +170,31 @@ const uno::Sequence< Property > & lcl_GetPropertySequence()
::chart::CharacterProperties::AddPropertiesToVector( aProperties );
::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
- // and sort them for access via bsearch
::std::sort( aProperties.begin(), aProperties.end(),
::chart::PropertyNameLess() );
- // transfer result to static Sequence
- aPropSeq = ::chart::ContainerHelper::ContainerToSequence( aProperties );
+ return ::chart::ContainerHelper::ContainerToSequence( aProperties );
}
- return aPropSeq;
-}
+};
-::cppu::IPropertyArrayHelper & lcl_getInfoHelper()
+struct StaticRegressionEquationInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticRegressionEquationInfoHelper_Initializer >
{
- static ::cppu::OPropertyArrayHelper aArrayHelper(
- lcl_GetPropertySequence(),
- /* bSorted = */ sal_True );
+};
- return aArrayHelper;
-}
+struct StaticRegressionEquationInfo_Initializer
+{
+ uno::Reference< beans::XPropertySetInfo >* operator()()
+ {
+ static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
+ ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticRegressionEquationInfoHelper::get() ) );
+ return &xPropertySetInfo;
+ }
+};
+
+struct StaticRegressionEquationInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticRegressionEquationInfo_Initializer >
+{
+};
} // anonymous namespace
@@ -206,56 +231,25 @@ uno::Reference< util::XCloneable > SAL_CALL RegressionEquation::createClone()
uno::Any RegressionEquation::GetDefaultValue( sal_Int32 nHandle ) const
throw(beans::UnknownPropertyException)
{
- static tPropertyValueMap aStaticDefaults;
-
- // /--
- ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
- if( 0 == aStaticDefaults.size() )
- {
- // initialize defaults
- LineProperties::AddDefaultsToMap( aStaticDefaults );
- FillProperties::AddDefaultsToMap( aStaticDefaults );
- CharacterProperties::AddDefaultsToMap( aStaticDefaults );
-
- // overrides a line property
- lcl_AddDefaultsToMap( aStaticDefaults );
- }
-
- tPropertyValueMap::const_iterator aFound(
- aStaticDefaults.find( nHandle ));
-
- if( aFound == aStaticDefaults.end())
+ const tPropertyValueMap& rStaticDefaults = *StaticRegressionEquationDefaults::get();
+ tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
+ if( aFound == rStaticDefaults.end() )
return uno::Any();
-
return (*aFound).second;
- // \--
}
::cppu::IPropertyArrayHelper & SAL_CALL RegressionEquation::getInfoHelper()
{
- return lcl_getInfoHelper();
+ return *StaticRegressionEquationInfoHelper::get();
}
// ____ XPropertySet ____
-Reference< beans::XPropertySetInfo > SAL_CALL
- RegressionEquation::getPropertySetInfo()
+Reference< beans::XPropertySetInfo > SAL_CALL RegressionEquation::getPropertySetInfo()
throw (uno::RuntimeException)
{
- static Reference< beans::XPropertySetInfo > xInfo;
-
- // /--
- ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
- if( !xInfo.is())
- {
- xInfo = ::cppu::OPropertySetHelper::createPropertySetInfo(
- lcl_getInfoHelper());
- }
-
- return xInfo;
- // \--
+ return *StaticRegressionEquationInfo::get();
}
-
// ____ XModifyBroadcaster ____
void SAL_CALL RegressionEquation::addModifyListener( const uno::Reference< util::XModifyListener >& aListener )
throw (uno::RuntimeException)