fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / chart2 / source / model / main / PageBackground.cxx
blobab3ceb0b3935cb20267587aedce5b27a202f858e
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 "macros.hxx"
22 #include "LinePropertiesHelper.hxx"
23 #include "FillProperties.hxx"
24 #include "UserDefinedProperties.hxx"
25 #include "ContainerHelper.hxx"
26 #include "PropertyHelper.hxx"
28 #include <com/sun/star/drawing/LineStyle.hpp>
29 #include <rtl/uuid.h>
30 #include <cppuhelper/queryinterface.hxx>
31 #include <cppuhelper/supportsservice.hxx>
33 #include <vector>
34 #include <algorithm>
36 using namespace ::com::sun::star;
38 using ::com::sun::star::beans::Property;
39 using ::osl::MutexGuard;
41 namespace
44 static const char lcl_aServiceName[] = "com.sun.star.comp.chart2.PageBackground";
46 struct StaticPageBackgroundDefaults_Initializer
48 ::chart::tPropertyValueMap* operator()()
50 static ::chart::tPropertyValueMap aStaticDefaults;
51 lcl_AddDefaultsToMap( aStaticDefaults );
52 return &aStaticDefaults;
54 private:
55 static void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap )
57 ::chart::LinePropertiesHelper::AddDefaultsToMap( rOutMap );
58 ::chart::FillProperties::AddDefaultsToMap( rOutMap );
60 // override other defaults
61 ::chart::PropertyHelper::setPropertyValue< sal_Int32 >( rOutMap, ::chart::FillProperties::PROP_FILL_COLOR, 0xffffff );
62 ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::LinePropertiesHelper::PROP_LINE_STYLE, drawing::LineStyle_NONE );
66 struct StaticPageBackgroundDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticPageBackgroundDefaults_Initializer >
70 struct StaticPageBackgroundInfoHelper_Initializer
72 ::cppu::OPropertyArrayHelper* operator()()
74 static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() );
75 return &aPropHelper;
78 private:
79 static uno::Sequence< Property > lcl_GetPropertySequence()
81 ::std::vector< ::com::sun::star::beans::Property > aProperties;
82 ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties );
83 ::chart::FillProperties::AddPropertiesToVector( aProperties );
84 ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
86 ::std::sort( aProperties.begin(), aProperties.end(),
87 ::chart::PropertyNameLess() );
89 return ::chart::ContainerHelper::ContainerToSequence( aProperties );
94 struct StaticPageBackgroundInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticPageBackgroundInfoHelper_Initializer >
98 struct StaticPageBackgroundInfo_Initializer
100 uno::Reference< beans::XPropertySetInfo >* operator()()
102 static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
103 ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticPageBackgroundInfoHelper::get() ) );
104 return &xPropertySetInfo;
108 struct StaticPageBackgroundInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticPageBackgroundInfo_Initializer >
112 } // anonymous namespace
114 namespace chart
117 PageBackground::PageBackground( const uno::Reference< uno::XComponentContext > & xContext ) :
118 ::property::OPropertySet( m_aMutex ),
119 m_xContext( xContext ),
120 m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
123 PageBackground::PageBackground( const PageBackground & rOther ) :
124 MutexContainer(),
125 impl::PageBackground_Base(),
126 ::property::OPropertySet( rOther, m_aMutex ),
127 m_xContext( rOther.m_xContext ),
128 m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
131 PageBackground::~PageBackground()
134 // ____ XCloneable ____
135 uno::Reference< util::XCloneable > SAL_CALL PageBackground::createClone()
136 throw (uno::RuntimeException, std::exception)
138 return uno::Reference< util::XCloneable >( new PageBackground( *this ));
141 // ____ OPropertySet ____
142 uno::Any PageBackground::GetDefaultValue( sal_Int32 nHandle ) const
143 throw(beans::UnknownPropertyException)
145 const tPropertyValueMap& rStaticDefaults = *StaticPageBackgroundDefaults::get();
146 tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
147 if( aFound == rStaticDefaults.end() )
148 return uno::Any();
149 return (*aFound).second;
152 ::cppu::IPropertyArrayHelper & SAL_CALL PageBackground::getInfoHelper()
154 return *StaticPageBackgroundInfoHelper::get();
157 // ____ XPropertySet ____
158 uno::Reference< beans::XPropertySetInfo > SAL_CALL PageBackground::getPropertySetInfo()
159 throw (uno::RuntimeException, std::exception)
161 return *StaticPageBackgroundInfo::get();
164 // ____ XModifyBroadcaster ____
165 void SAL_CALL PageBackground::addModifyListener( const uno::Reference< util::XModifyListener >& aListener )
166 throw (uno::RuntimeException, std::exception)
170 uno::Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
171 xBroadcaster->addModifyListener( aListener );
173 catch( const uno::Exception & ex )
175 ASSERT_EXCEPTION( ex );
179 void SAL_CALL PageBackground::removeModifyListener( const uno::Reference< util::XModifyListener >& aListener )
180 throw (uno::RuntimeException, std::exception)
184 uno::Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
185 xBroadcaster->removeModifyListener( aListener );
187 catch( const uno::Exception & ex )
189 ASSERT_EXCEPTION( ex );
193 // ____ XModifyListener ____
194 void SAL_CALL PageBackground::modified( const lang::EventObject& aEvent )
195 throw (uno::RuntimeException, std::exception)
197 m_xModifyEventForwarder->modified( aEvent );
200 // ____ XEventListener (base of XModifyListener) ____
201 void SAL_CALL PageBackground::disposing( const lang::EventObject& /* Source */ )
202 throw (uno::RuntimeException, std::exception)
204 // nothing
207 // ____ OPropertySet ____
208 void PageBackground::firePropertyChangeEvent()
210 fireModifyEvent();
213 void PageBackground::fireModifyEvent()
215 m_xModifyEventForwarder->modified( lang::EventObject( static_cast< uno::XWeak* >( this )));
218 uno::Sequence< OUString > PageBackground::getSupportedServiceNames_Static()
220 uno::Sequence< OUString > aServices( 2 );
221 aServices[ 0 ] = "com.sun.star.chart2.PageBackground";
222 aServices[ 1 ] = "com.sun.star.beans.PropertySet";
223 return aServices;
226 // implement XServiceInfo methods basing upon getSupportedServiceNames_Static
227 OUString SAL_CALL PageBackground::getImplementationName()
228 throw( css::uno::RuntimeException, std::exception )
230 return getImplementationName_Static();
233 OUString PageBackground::getImplementationName_Static()
235 return OUString(lcl_aServiceName);
238 sal_Bool SAL_CALL PageBackground::supportsService( const OUString& rServiceName )
239 throw( css::uno::RuntimeException, std::exception )
241 return cppu::supportsService(this, rServiceName);
244 css::uno::Sequence< OUString > SAL_CALL PageBackground::getSupportedServiceNames()
245 throw( css::uno::RuntimeException, std::exception )
247 return getSupportedServiceNames_Static();
250 using impl::PageBackground_Base;
252 IMPLEMENT_FORWARD_XINTERFACE2( PageBackground, PageBackground_Base, ::property::OPropertySet )
254 } // namespace chart
256 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
257 com_sun_star_comp_chart2_PageBackground_get_implementation(css::uno::XComponentContext *context,
258 css::uno::Sequence<css::uno::Any> const &)
260 return cppu::acquire(new ::chart::PageBackground(context));
263 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */