1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "PageBackground.hxx"
21 #include <LinePropertiesHelper.hxx>
22 #include <FillProperties.hxx>
23 #include <UserDefinedProperties.hxx>
24 #include <PropertyHelper.hxx>
25 #include <ModifyListenerHelper.hxx>
27 #include <com/sun/star/drawing/LineStyle.hpp>
28 #include <cppuhelper/supportsservice.hxx>
29 #include <tools/diagnose_ex.h>
34 namespace com::sun::star::uno
{ class XComponentContext
; }
36 using namespace ::com::sun::star
;
38 using ::com::sun::star::beans::Property
;
43 struct StaticPageBackgroundDefaults_Initializer
45 ::chart::tPropertyValueMap
* operator()()
47 static ::chart::tPropertyValueMap aStaticDefaults
;
48 lcl_AddDefaultsToMap( aStaticDefaults
);
49 return &aStaticDefaults
;
52 static void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap
& rOutMap
)
54 ::chart::LinePropertiesHelper::AddDefaultsToMap( rOutMap
);
55 ::chart::FillProperties::AddDefaultsToMap( rOutMap
);
57 // override other defaults
58 ::chart::PropertyHelper::setPropertyValue
< sal_Int32
>( rOutMap
, ::chart::FillProperties::PROP_FILL_COLOR
, 0xffffff );
59 ::chart::PropertyHelper::setPropertyValue( rOutMap
, ::chart::LinePropertiesHelper::PROP_LINE_STYLE
, drawing::LineStyle_NONE
);
63 struct StaticPageBackgroundDefaults
: public rtl::StaticAggregate
< ::chart::tPropertyValueMap
, StaticPageBackgroundDefaults_Initializer
>
67 struct StaticPageBackgroundInfoHelper_Initializer
69 ::cppu::OPropertyArrayHelper
* operator()()
71 static ::cppu::OPropertyArrayHelper
aPropHelper( lcl_GetPropertySequence() );
76 static uno::Sequence
< Property
> lcl_GetPropertySequence()
78 std::vector
< css::beans::Property
> aProperties
;
79 ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties
);
80 ::chart::FillProperties::AddPropertiesToVector( aProperties
);
81 ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties
);
83 std::sort( aProperties
.begin(), aProperties
.end(),
84 ::chart::PropertyNameLess() );
86 return comphelper::containerToSequence( aProperties
);
91 struct StaticPageBackgroundInfoHelper
: public rtl::StaticAggregate
< ::cppu::OPropertyArrayHelper
, StaticPageBackgroundInfoHelper_Initializer
>
95 struct StaticPageBackgroundInfo_Initializer
97 uno::Reference
< beans::XPropertySetInfo
>* operator()()
99 static uno::Reference
< beans::XPropertySetInfo
> xPropertySetInfo(
100 ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticPageBackgroundInfoHelper::get() ) );
101 return &xPropertySetInfo
;
105 struct StaticPageBackgroundInfo
: public rtl::StaticAggregate
< uno::Reference
< beans::XPropertySetInfo
>, StaticPageBackgroundInfo_Initializer
>
109 } // anonymous namespace
114 PageBackground::PageBackground() :
115 ::property::OPropertySet( m_aMutex
),
116 m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
119 PageBackground::PageBackground( const PageBackground
& rOther
) :
120 impl::PageBackground_Base(rOther
),
121 ::property::OPropertySet( rOther
, m_aMutex
),
122 m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
125 PageBackground::~PageBackground()
128 // ____ XCloneable ____
129 uno::Reference
< util::XCloneable
> SAL_CALL
PageBackground::createClone()
131 return uno::Reference
< util::XCloneable
>( new PageBackground( *this ));
134 // ____ OPropertySet ____
135 uno::Any
PageBackground::GetDefaultValue( sal_Int32 nHandle
) const
137 const tPropertyValueMap
& rStaticDefaults
= *StaticPageBackgroundDefaults::get();
138 tPropertyValueMap::const_iterator
aFound( rStaticDefaults
.find( nHandle
) );
139 if( aFound
== rStaticDefaults
.end() )
141 return (*aFound
).second
;
144 ::cppu::IPropertyArrayHelper
& SAL_CALL
PageBackground::getInfoHelper()
146 return *StaticPageBackgroundInfoHelper::get();
149 // ____ XPropertySet ____
150 uno::Reference
< beans::XPropertySetInfo
> SAL_CALL
PageBackground::getPropertySetInfo()
152 return *StaticPageBackgroundInfo::get();
155 // ____ XModifyBroadcaster ____
156 void SAL_CALL
PageBackground::addModifyListener( const uno::Reference
< util::XModifyListener
>& aListener
)
160 uno::Reference
< util::XModifyBroadcaster
> xBroadcaster( m_xModifyEventForwarder
, uno::UNO_QUERY_THROW
);
161 xBroadcaster
->addModifyListener( aListener
);
163 catch( const uno::Exception
& )
165 DBG_UNHANDLED_EXCEPTION("chart2");
169 void SAL_CALL
PageBackground::removeModifyListener( const uno::Reference
< util::XModifyListener
>& aListener
)
173 uno::Reference
< util::XModifyBroadcaster
> xBroadcaster( m_xModifyEventForwarder
, uno::UNO_QUERY_THROW
);
174 xBroadcaster
->removeModifyListener( aListener
);
176 catch( const uno::Exception
& )
178 DBG_UNHANDLED_EXCEPTION("chart2");
182 // ____ XModifyListener ____
183 void SAL_CALL
PageBackground::modified( const lang::EventObject
& aEvent
)
185 m_xModifyEventForwarder
->modified( aEvent
);
188 // ____ XEventListener (base of XModifyListener) ____
189 void SAL_CALL
PageBackground::disposing( const lang::EventObject
& /* Source */ )
194 // ____ OPropertySet ____
195 void PageBackground::firePropertyChangeEvent()
197 m_xModifyEventForwarder
->modified( lang::EventObject( static_cast< uno::XWeak
* >( this )));
200 OUString SAL_CALL
PageBackground::getImplementationName()
202 return "com.sun.star.comp.chart2.PageBackground";
205 sal_Bool SAL_CALL
PageBackground::supportsService( const OUString
& rServiceName
)
207 return cppu::supportsService(this, rServiceName
);
210 css::uno::Sequence
< OUString
> SAL_CALL
PageBackground::getSupportedServiceNames()
213 "com.sun.star.chart2.PageBackground",
214 "com.sun.star.beans.PropertySet" };
217 using impl::PageBackground_Base
;
219 IMPLEMENT_FORWARD_XINTERFACE2( PageBackground
, PageBackground_Base
, ::property::OPropertySet
)
223 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
224 com_sun_star_comp_chart2_PageBackground_get_implementation(css::uno::XComponentContext
*,
225 css::uno::Sequence
<css::uno::Any
> const &)
227 return cppu::acquire(new ::chart::PageBackground
);
230 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */