fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / chart2 / source / model / main / Wall.cxx
blobef1b9e38988b038e119206b96673f2783b6fc66b
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 "Wall.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"
27 #include <com/sun/star/beans/PropertyAttribute.hpp>
28 #include <com/sun/star/drawing/FillStyle.hpp>
29 #include <com/sun/star/awt/Gradient.hpp>
30 #include <com/sun/star/drawing/Hatch.hpp>
31 #include <com/sun/star/drawing/LineStyle.hpp>
32 #include <com/sun/star/drawing/LineDash.hpp>
33 #include <com/sun/star/drawing/LineJoint.hpp>
34 #include <rtl/uuid.h>
35 #include <cppuhelper/queryinterface.hxx>
37 #include <vector>
38 #include <algorithm>
40 using namespace ::com::sun::star;
41 using namespace ::com::sun::star::beans::PropertyAttribute;
43 using ::com::sun::star::beans::Property;
44 using ::osl::MutexGuard;
46 namespace
49 struct StaticWallDefaults_Initializer
51 ::chart::tPropertyValueMap* operator()()
53 static ::chart::tPropertyValueMap aStaticDefaults;
54 lcl_AddDefaultsToMap( aStaticDefaults );
55 return &aStaticDefaults;
57 private:
58 static void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap )
60 ::chart::LinePropertiesHelper::AddDefaultsToMap( rOutMap );
61 ::chart::FillProperties::AddDefaultsToMap( rOutMap );
63 // override other defaults
64 ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::LinePropertiesHelper::PROP_LINE_STYLE, drawing::LineStyle_NONE );
68 struct StaticWallDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticWallDefaults_Initializer >
72 struct StaticWallInfoHelper_Initializer
74 ::cppu::OPropertyArrayHelper* operator()()
76 static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() );
77 return &aPropHelper;
80 private:
81 static uno::Sequence< Property > lcl_GetPropertySequence()
83 ::std::vector< ::com::sun::star::beans::Property > aProperties;
84 ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties );
85 ::chart::FillProperties::AddPropertiesToVector( aProperties );
86 ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
88 ::std::sort( aProperties.begin(), aProperties.end(),
89 ::chart::PropertyNameLess() );
91 return ::chart::ContainerHelper::ContainerToSequence( aProperties );
96 struct StaticWallInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticWallInfoHelper_Initializer >
100 struct StaticWallInfo_Initializer
102 uno::Reference< beans::XPropertySetInfo >* operator()()
104 static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
105 ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticWallInfoHelper::get() ) );
106 return &xPropertySetInfo;
110 struct StaticWallInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticWallInfo_Initializer >
114 } // anonymous namespace
116 namespace chart
119 Wall::Wall() :
120 ::property::OPropertySet( m_aMutex ),
121 m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
124 Wall::Wall( const Wall & rOther ) :
125 MutexContainer(),
126 impl::Wall_Base(),
127 ::property::OPropertySet( rOther, m_aMutex ),
128 m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
131 Wall::~Wall()
134 // ____ XCloneable ____
135 uno::Reference< util::XCloneable > SAL_CALL Wall::createClone()
136 throw (uno::RuntimeException, std::exception)
138 return uno::Reference< util::XCloneable >( new Wall( *this ));
141 // ____ OPropertySet ____
142 uno::Any Wall::GetDefaultValue( sal_Int32 nHandle ) const
143 throw(beans::UnknownPropertyException)
145 const tPropertyValueMap& rStaticDefaults = *StaticWallDefaults::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 Wall::getInfoHelper()
154 return *StaticWallInfoHelper::get();
157 // ____ XPropertySet ____
158 uno::Reference< beans::XPropertySetInfo > SAL_CALL Wall::getPropertySetInfo()
159 throw (uno::RuntimeException, std::exception)
161 return *StaticWallInfo::get();
164 // ____ XModifyBroadcaster ____
165 void SAL_CALL Wall::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 Wall::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 Wall::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 Wall::disposing( const lang::EventObject& /* Source */ )
202 throw (uno::RuntimeException, std::exception)
204 // nothing
207 // ____ OPropertySet ____
208 void Wall::firePropertyChangeEvent()
210 fireModifyEvent();
213 void Wall::fireModifyEvent()
215 m_xModifyEventForwarder->modified( lang::EventObject( static_cast< uno::XWeak* >( this )));
218 using impl::Wall_Base;
220 IMPLEMENT_FORWARD_XINTERFACE2( Wall, Wall_Base, ::property::OPropertySet )
222 } // namespace chart
224 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */