diff options
Diffstat (limited to 'chart2/source/model/main/PageBackground.cxx')
-rw-r--r-- | chart2/source/model/main/PageBackground.cxx | 118 |
1 files changed, 53 insertions, 65 deletions
diff --git a/chart2/source/model/main/PageBackground.cxx b/chart2/source/model/main/PageBackground.cxx index 9f51469ca9cb..deae689d7a2b 100644 --- a/chart2/source/model/main/PageBackground.cxx +++ b/chart2/source/model/main/PageBackground.cxx @@ -18,15 +18,17 @@ */ #include "PageBackground.hxx" +#include <comphelper/lok.hxx> #include <LinePropertiesHelper.hxx> #include <FillProperties.hxx> #include <UserDefinedProperties.hxx> #include <PropertyHelper.hxx> #include <ModifyListenerHelper.hxx> +#include <svtools/colorcfg.hxx> +#include <sfx2/viewsh.hxx> #include <com/sun/star/drawing/LineStyle.hpp> #include <cppuhelper/supportsservice.hxx> -#include <tools/diagnose_ex.h> #include <vector> #include <algorithm> @@ -40,70 +42,47 @@ using ::com::sun::star::beans::Property; namespace { -struct StaticPageBackgroundDefaults_Initializer -{ - ::chart::tPropertyValueMap* operator()() - { - static ::chart::tPropertyValueMap aStaticDefaults; - lcl_AddDefaultsToMap( aStaticDefaults ); - return &aStaticDefaults; - } -private: - static void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap ) - { - ::chart::LinePropertiesHelper::AddDefaultsToMap( rOutMap ); - ::chart::FillProperties::AddDefaultsToMap( rOutMap ); - - // override other defaults - ::chart::PropertyHelper::setPropertyValue< sal_Int32 >( rOutMap, ::chart::FillProperties::PROP_FILL_COLOR, 0xffffff ); - ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::LinePropertiesHelper::PROP_LINE_STYLE, drawing::LineStyle_NONE ); - } +const ::chart::tPropertyValueMap& StaticPageBackgroundDefaults() +{ + static ::chart::tPropertyValueMap aStaticDefaults = []() + { + ::chart::tPropertyValueMap aTmp; + ::chart::LinePropertiesHelper::AddDefaultsToMap( aTmp ); + ::chart::FillProperties::AddDefaultsToMap( aTmp ); + + // override other defaults + Color aDocColor = COL_WHITE; + if (comphelper::LibreOfficeKit::isActive()) { + aDocColor = COL_AUTO; + } else { + if (SfxViewShell* pCurrentSh = SfxViewShell::Current()) { + aDocColor = pCurrentSh->GetColorConfigColor(svtools::DOCCOLOR); + } else { + aDocColor = svtools::ColorConfig().GetColorValue(svtools::DOCCOLOR).nColor; + } + } + ::chart::PropertyHelper::setPropertyValue( aTmp, ::chart::FillProperties::PROP_FILL_COLOR, aDocColor ); + ::chart::PropertyHelper::setPropertyValue( aTmp, ::chart::LinePropertiesHelper::PROP_LINE_STYLE, drawing::LineStyle_NONE ); + return aTmp; + }(); + return aStaticDefaults; }; -struct StaticPageBackgroundDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticPageBackgroundDefaults_Initializer > +::cppu::OPropertyArrayHelper& StaticPageBackgroundInfoHelper() { -}; - -struct StaticPageBackgroundInfoHelper_Initializer -{ - ::cppu::OPropertyArrayHelper* operator()() - { - static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() ); - return &aPropHelper; - } - -private: - static uno::Sequence< Property > lcl_GetPropertySequence() - { - std::vector< css::beans::Property > aProperties; - ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties ); - ::chart::FillProperties::AddPropertiesToVector( aProperties ); - ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); - - std::sort( aProperties.begin(), aProperties.end(), - ::chart::PropertyNameLess() ); + static ::cppu::OPropertyArrayHelper aPropHelper = []() + { + std::vector< css::beans::Property > aProperties; + ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties ); + ::chart::FillProperties::AddPropertiesToVector( aProperties ); + ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); - return comphelper::containerToSequence( aProperties ); - } + std::sort( aProperties.begin(), aProperties.end(), + ::chart::PropertyNameLess() ); -}; - -struct StaticPageBackgroundInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticPageBackgroundInfoHelper_Initializer > -{ -}; - -struct StaticPageBackgroundInfo_Initializer -{ - uno::Reference< beans::XPropertySetInfo >* operator()() - { - static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo( - ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticPageBackgroundInfoHelper::get() ) ); - return &xPropertySetInfo; - } -}; - -struct StaticPageBackgroundInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticPageBackgroundInfo_Initializer > -{ + return comphelper::containerToSequence( aProperties ); + }(); + return aPropHelper; }; } // anonymous namespace @@ -112,19 +91,26 @@ namespace chart { PageBackground::PageBackground() : - ::property::OPropertySet( m_aMutex ), m_xModifyEventForwarder( new ModifyEventForwarder() ) {} PageBackground::PageBackground( const PageBackground & rOther ) : impl::PageBackground_Base(rOther), - ::property::OPropertySet( rOther, m_aMutex ), + ::property::OPropertySet( rOther ), m_xModifyEventForwarder( new ModifyEventForwarder() ) {} PageBackground::~PageBackground() {} +// ____ XTypeProvider ____ +uno::Sequence< css::uno::Type > SAL_CALL PageBackground::getTypes() +{ + return ::comphelper::concatSequences( + impl::PageBackground_Base::getTypes(), + ::property::OPropertySet::getTypes()); +} + // ____ XCloneable ____ uno::Reference< util::XCloneable > SAL_CALL PageBackground::createClone() { @@ -134,7 +120,7 @@ uno::Reference< util::XCloneable > SAL_CALL PageBackground::createClone() // ____ OPropertySet ____ void PageBackground::GetDefaultValue( sal_Int32 nHandle, uno::Any& rAny ) const { - const tPropertyValueMap& rStaticDefaults = *StaticPageBackgroundDefaults::get(); + const tPropertyValueMap& rStaticDefaults = StaticPageBackgroundDefaults(); tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) ); if( aFound == rStaticDefaults.end() ) rAny.clear(); @@ -144,13 +130,15 @@ void PageBackground::GetDefaultValue( sal_Int32 nHandle, uno::Any& rAny ) const ::cppu::IPropertyArrayHelper & SAL_CALL PageBackground::getInfoHelper() { - return *StaticPageBackgroundInfoHelper::get(); + return StaticPageBackgroundInfoHelper(); } // ____ XPropertySet ____ uno::Reference< beans::XPropertySetInfo > SAL_CALL PageBackground::getPropertySetInfo() { - return *StaticPageBackgroundInfo::get(); + static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo( + ::cppu::OPropertySetHelper::createPropertySetInfo(StaticPageBackgroundInfoHelper() ) ); + return xPropertySetInfo; } // ____ XModifyBroadcaster ____ |