merged tag ooo/OOO330_m14
[LibreOffice.git] / chart2 / source / model / main / Wall.cxx
blob2ad00a4c90ae8140fd9f63964afaae291a558838
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_chart2.hxx"
30 #include "Wall.hxx"
31 #include "macros.hxx"
32 #include "LineProperties.hxx"
33 #include "FillProperties.hxx"
34 #include "UserDefinedProperties.hxx"
35 #include "ContainerHelper.hxx"
36 #include "PropertyHelper.hxx"
37 #include <com/sun/star/beans/PropertyAttribute.hpp>
38 #include <com/sun/star/drawing/FillStyle.hpp>
39 #include <com/sun/star/awt/Gradient.hpp>
40 #include <com/sun/star/drawing/Hatch.hpp>
41 #include <com/sun/star/drawing/LineStyle.hpp>
42 #include <com/sun/star/drawing/LineDash.hpp>
43 #include <com/sun/star/drawing/LineJoint.hpp>
44 #include <rtl/uuid.h>
45 #include <cppuhelper/queryinterface.hxx>
47 #include <vector>
48 #include <algorithm>
50 using namespace ::com::sun::star;
51 using namespace ::com::sun::star::beans::PropertyAttribute;
53 using ::com::sun::star::beans::Property;
54 using ::osl::MutexGuard;
56 namespace
59 static const ::rtl::OUString lcl_aServiceName(
60 RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.chart2.Wall" ));
62 void lcl_AddDefaultsToMap(
63 ::chart::tPropertyValueMap & rOutMap )
65 // override other defaults
66 ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::LineProperties::PROP_LINE_STYLE, drawing::LineStyle_NONE );
69 const uno::Sequence< Property > & lcl_GetPropertySequence()
71 static uno::Sequence< Property > aPropSeq;
73 // /--
74 MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
75 if( 0 == aPropSeq.getLength() )
77 // get properties
78 ::std::vector< ::com::sun::star::beans::Property > aProperties;
79 ::chart::LineProperties::AddPropertiesToVector( aProperties );
80 ::chart::FillProperties::AddPropertiesToVector( aProperties );
81 ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
83 // and sort them for access via bsearch
84 ::std::sort( aProperties.begin(), aProperties.end(),
85 ::chart::PropertyNameLess() );
87 // transfer result to static Sequence
88 aPropSeq = ::chart::ContainerHelper::ContainerToSequence( aProperties );
91 return aPropSeq;
94 ::cppu::IPropertyArrayHelper & lcl_getInfoHelper()
96 static ::cppu::OPropertyArrayHelper aArrayHelper(
97 lcl_GetPropertySequence(),
98 /* bSorted = */ sal_True );
100 return aArrayHelper;
103 } // anonymous namespace
105 // ================================================================================
107 namespace chart
110 Wall::Wall() :
111 ::property::OPropertySet( m_aMutex ),
112 m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
115 Wall::Wall( const Wall & rOther ) :
116 MutexContainer(),
117 impl::Wall_Base(),
118 ::property::OPropertySet( rOther, m_aMutex ),
119 m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
122 Wall::~Wall()
125 // ____ XCloneable ____
126 uno::Reference< util::XCloneable > SAL_CALL Wall::createClone()
127 throw (uno::RuntimeException)
129 return uno::Reference< util::XCloneable >( new Wall( *this ));
132 // ================================================================================
134 // ____ OPropertySet ____
135 uno::Any Wall::GetDefaultValue( sal_Int32 nHandle ) const
136 throw(beans::UnknownPropertyException)
138 static tPropertyValueMap aStaticDefaults;
140 // /--
141 ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
142 if( 0 == aStaticDefaults.size() )
144 // initialize defaults
145 LineProperties::AddDefaultsToMap( aStaticDefaults );
146 FillProperties::AddDefaultsToMap( aStaticDefaults );
148 // initialize defaults
149 // Note: this should be last to override defaults of the previously
150 // added defaults
151 lcl_AddDefaultsToMap( aStaticDefaults );
154 tPropertyValueMap::const_iterator aFound(
155 aStaticDefaults.find( nHandle ));
157 if( aFound == aStaticDefaults.end())
158 return uno::Any();
160 return (*aFound).second;
161 // \--
164 ::cppu::IPropertyArrayHelper & SAL_CALL Wall::getInfoHelper()
166 return lcl_getInfoHelper();
170 // ____ XPropertySet ____
171 uno::Reference< beans::XPropertySetInfo > SAL_CALL
172 Wall::getPropertySetInfo()
173 throw (uno::RuntimeException)
175 static uno::Reference< beans::XPropertySetInfo > xInfo;
177 // /--
178 MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
179 if( !xInfo.is())
181 xInfo = ::cppu::OPropertySetHelper::createPropertySetInfo(
182 getInfoHelper());
185 return xInfo;
186 // \--
189 // ____ XModifyBroadcaster ____
190 void SAL_CALL Wall::addModifyListener( const uno::Reference< util::XModifyListener >& aListener )
191 throw (uno::RuntimeException)
195 uno::Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
196 xBroadcaster->addModifyListener( aListener );
198 catch( const uno::Exception & ex )
200 ASSERT_EXCEPTION( ex );
204 void SAL_CALL Wall::removeModifyListener( const uno::Reference< util::XModifyListener >& aListener )
205 throw (uno::RuntimeException)
209 uno::Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
210 xBroadcaster->removeModifyListener( aListener );
212 catch( const uno::Exception & ex )
214 ASSERT_EXCEPTION( ex );
218 // ____ XModifyListener ____
219 void SAL_CALL Wall::modified( const lang::EventObject& aEvent )
220 throw (uno::RuntimeException)
222 m_xModifyEventForwarder->modified( aEvent );
225 // ____ XEventListener (base of XModifyListener) ____
226 void SAL_CALL Wall::disposing( const lang::EventObject& /* Source */ )
227 throw (uno::RuntimeException)
229 // nothing
232 // ____ OPropertySet ____
233 void Wall::firePropertyChangeEvent()
235 fireModifyEvent();
238 void Wall::fireModifyEvent()
240 m_xModifyEventForwarder->modified( lang::EventObject( static_cast< uno::XWeak* >( this )));
243 // ================================================================================
245 uno::Sequence< ::rtl::OUString > Wall::getSupportedServiceNames_Static()
247 uno::Sequence< ::rtl::OUString > aServices( 2 );
248 aServices[ 0 ] = C2U( "com.sun.star.chart2.Wall" );
249 aServices[ 1 ] = C2U( "com.sun.star.beans.PropertySet" );
250 return aServices;
253 // implement XServiceInfo methods basing upon getSupportedServiceNames_Static
254 APPHELPER_XSERVICEINFO_IMPL( Wall, lcl_aServiceName );
256 using impl::Wall_Base;
258 IMPLEMENT_FORWARD_XINTERFACE2( Wall, Wall_Base, ::property::OPropertySet )
260 } // namespace chart