fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / chart2 / source / model / main / GridProperties.cxx
blob5aa3f35301feed7f8680a15f63cba818fcc44138
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 "GridProperties.hxx"
21 #include "LinePropertiesHelper.hxx"
22 #include "UserDefinedProperties.hxx"
23 #include "PropertyHelper.hxx"
24 #include "macros.hxx"
25 #include "ContainerHelper.hxx"
26 #include <com/sun/star/style/XStyle.hpp>
27 #include <com/sun/star/beans/PropertyAttribute.hpp>
28 #include <com/sun/star/beans/XPropertySet.hpp>
29 #include <com/sun/star/uno/Sequence.hxx>
30 #include <cppuhelper/supportsservice.hxx>
32 using namespace ::com::sun::star;
34 using ::com::sun::star::uno::Reference;
35 using ::com::sun::star::uno::Sequence;
36 using ::com::sun::star::beans::Property;
37 using ::osl::MutexGuard;
39 namespace
42 static const char lcl_aServiceName[] = "com.sun.star.comp.chart2.GridProperties";
44 enum
46 PROP_GRID_SHOW
49 void lcl_AddPropertiesToVector(
50 ::std::vector< Property > & rOutProperties )
52 rOutProperties.push_back(
53 Property( "Show",
54 PROP_GRID_SHOW,
55 cppu::UnoType<bool>::get(),
56 beans::PropertyAttribute::BOUND
57 | beans::PropertyAttribute::MAYBEDEFAULT ));
60 struct StaticGridDefaults_Initializer
62 ::chart::tPropertyValueMap* operator()()
64 static ::chart::tPropertyValueMap aStaticDefaults;
65 lcl_AddDefaultsToMap( aStaticDefaults );
66 return &aStaticDefaults;
68 private:
69 static void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap )
71 ::chart::LinePropertiesHelper::AddDefaultsToMap( rOutMap );
73 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_GRID_SHOW, false );
75 // override other defaults
76 ::chart::PropertyHelper::setPropertyValue< sal_Int32 >(
77 rOutMap, ::chart::LinePropertiesHelper::PROP_LINE_COLOR, 0xb3b3b3 ); // gray30
81 struct StaticGridDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticGridDefaults_Initializer >
85 struct StaticGridInfoHelper_Initializer
87 ::cppu::OPropertyArrayHelper* operator()()
89 static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() );
90 return &aPropHelper;
93 private:
94 static Sequence< Property > lcl_GetPropertySequence()
96 ::std::vector< Property > aProperties;
97 lcl_AddPropertiesToVector( aProperties );
98 ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties );
99 ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
101 ::std::sort( aProperties.begin(), aProperties.end(),
102 ::chart::PropertyNameLess() );
104 return ::chart::ContainerHelper::ContainerToSequence( aProperties );
109 struct StaticGridInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticGridInfoHelper_Initializer >
113 struct StaticGridInfo_Initializer
115 uno::Reference< beans::XPropertySetInfo >* operator()()
117 static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
118 ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticGridInfoHelper::get() ) );
119 return &xPropertySetInfo;
123 struct StaticGridInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticGridInfo_Initializer >
127 } // anonymous namespace
129 namespace chart
132 GridProperties::GridProperties( Reference< uno::XComponentContext > const & /* xContext */ ) :
133 ::property::OPropertySet( m_aMutex ),
134 m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
138 GridProperties::GridProperties() :
139 ::property::OPropertySet( m_aMutex ),
140 m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
143 GridProperties::GridProperties( const GridProperties & rOther ) :
144 MutexContainer(),
145 impl::GridProperties_Base(),
146 ::property::OPropertySet( rOther, m_aMutex ),
147 m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
151 GridProperties::~GridProperties()
154 // ____ OPropertySet ____
155 uno::Any GridProperties::GetDefaultValue( sal_Int32 nHandle ) const
156 throw(beans::UnknownPropertyException)
158 const tPropertyValueMap& rStaticDefaults = *StaticGridDefaults::get();
159 tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
160 if( aFound == rStaticDefaults.end() )
161 return uno::Any();
162 return (*aFound).second;
165 ::cppu::IPropertyArrayHelper & SAL_CALL GridProperties::getInfoHelper()
167 return *StaticGridInfoHelper::get();
170 // ____ XPropertySet ____
171 Reference< beans::XPropertySetInfo > SAL_CALL GridProperties::getPropertySetInfo()
172 throw (uno::RuntimeException, std::exception)
174 return *StaticGridInfo::get();
177 // ____ XCloneable ____
178 uno::Reference< util::XCloneable > SAL_CALL GridProperties::createClone()
179 throw (uno::RuntimeException, std::exception)
181 return uno::Reference< util::XCloneable >( new GridProperties( *this ));
184 // ____ XModifyBroadcaster ____
185 void SAL_CALL GridProperties::addModifyListener( const Reference< util::XModifyListener >& aListener )
186 throw (uno::RuntimeException, std::exception)
190 Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
191 xBroadcaster->addModifyListener( aListener );
193 catch( const uno::Exception & ex )
195 ASSERT_EXCEPTION( ex );
199 void SAL_CALL GridProperties::removeModifyListener( const Reference< util::XModifyListener >& aListener )
200 throw (uno::RuntimeException, std::exception)
204 Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
205 xBroadcaster->removeModifyListener( aListener );
207 catch( const uno::Exception & ex )
209 ASSERT_EXCEPTION( ex );
213 // ____ XModifyListener ____
214 void SAL_CALL GridProperties::modified( const lang::EventObject& aEvent )
215 throw (uno::RuntimeException, std::exception)
217 m_xModifyEventForwarder->modified( aEvent );
220 // ____ XEventListener (base of XModifyListener) ____
221 void SAL_CALL GridProperties::disposing( const lang::EventObject& /* Source */ )
222 throw (uno::RuntimeException, std::exception)
224 // nothing
227 // ____ OPropertySet ____
228 void GridProperties::firePropertyChangeEvent()
230 fireModifyEvent();
233 void GridProperties::fireModifyEvent()
235 m_xModifyEventForwarder->modified( lang::EventObject( static_cast< uno::XWeak* >( this )));
238 Sequence< OUString > GridProperties::getSupportedServiceNames_Static()
240 Sequence< OUString > aServices( 2 );
241 aServices[ 0 ] = "com.sun.star.chart2.GridProperties";
242 aServices[ 1 ] = "com.sun.star.beans.PropertySet";
243 return aServices;
246 // implement XServiceInfo methods basing upon getSupportedServiceNames_Static
247 OUString SAL_CALL GridProperties::getImplementationName()
248 throw( css::uno::RuntimeException, std::exception )
250 return getImplementationName_Static();
253 OUString GridProperties::getImplementationName_Static()
255 return OUString(lcl_aServiceName);
258 sal_Bool SAL_CALL GridProperties::supportsService( const OUString& rServiceName )
259 throw( css::uno::RuntimeException, std::exception )
261 return cppu::supportsService(this, rServiceName);
264 css::uno::Sequence< OUString > SAL_CALL GridProperties::getSupportedServiceNames()
265 throw( css::uno::RuntimeException, std::exception )
267 return getSupportedServiceNames_Static();
270 // needed by MSC compiler
271 using impl::GridProperties_Base;
273 IMPLEMENT_FORWARD_XINTERFACE2( GridProperties, GridProperties_Base, ::property::OPropertySet )
274 IMPLEMENT_FORWARD_XTYPEPROVIDER2( GridProperties, GridProperties_Base, ::property::OPropertySet )
276 } // namespace chart
278 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
279 com_sun_star_comp_chart2_GridProperties_get_implementation(css::uno::XComponentContext *context,
280 css::uno::Sequence<css::uno::Any> const &)
282 return cppu::acquire(new ::chart::GridProperties(context));
285 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */