xref: /aoo4110/main/chart2/source/model/main/Wall.cxx (revision b1cdbd2c)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_chart2.hxx"
26 #include "Wall.hxx"
27 #include "macros.hxx"
28 #include "LineProperties.hxx"
29 #include "FillProperties.hxx"
30 #include "UserDefinedProperties.hxx"
31 #include "ContainerHelper.hxx"
32 #include "PropertyHelper.hxx"
33 #include <com/sun/star/beans/PropertyAttribute.hpp>
34 #include <com/sun/star/drawing/FillStyle.hpp>
35 #include <com/sun/star/awt/Gradient.hpp>
36 #include <com/sun/star/drawing/Hatch.hpp>
37 #include <com/sun/star/drawing/LineStyle.hpp>
38 #include <com/sun/star/drawing/LineDash.hpp>
39 #include <com/sun/star/drawing/LineJoint.hpp>
40 #include <rtl/uuid.h>
41 #include <cppuhelper/queryinterface.hxx>
42 
43 #include <vector>
44 #include <algorithm>
45 
46 using namespace ::com::sun::star;
47 using namespace ::com::sun::star::beans::PropertyAttribute;
48 
49 using ::com::sun::star::beans::Property;
50 using ::osl::MutexGuard;
51 
52 namespace
53 {
54 
55 static const ::rtl::OUString lcl_aServiceName(
56     RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.chart2.Wall" ));
57 
58 struct StaticWallDefaults_Initializer
59 {
operator ()__anonb4cbf0770111::StaticWallDefaults_Initializer60     ::chart::tPropertyValueMap* operator()()
61     {
62         static ::chart::tPropertyValueMap aStaticDefaults;
63         lcl_AddDefaultsToMap( aStaticDefaults );
64         return &aStaticDefaults;
65     }
66 private:
lcl_AddDefaultsToMap__anonb4cbf0770111::StaticWallDefaults_Initializer67     void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap )
68     {
69         ::chart::LineProperties::AddDefaultsToMap( rOutMap );
70         ::chart::FillProperties::AddDefaultsToMap( rOutMap );
71 
72         // override other defaults
73         ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::LineProperties::PROP_LINE_STYLE, drawing::LineStyle_NONE );
74     }
75 };
76 
77 struct StaticWallDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticWallDefaults_Initializer >
78 {
79 };
80 
81 struct StaticWallInfoHelper_Initializer
82 {
operator ()__anonb4cbf0770111::StaticWallInfoHelper_Initializer83     ::cppu::OPropertyArrayHelper* operator()()
84     {
85         static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() );
86         return &aPropHelper;
87     }
88 
89 private:
lcl_GetPropertySequence__anonb4cbf0770111::StaticWallInfoHelper_Initializer90     uno::Sequence< Property > lcl_GetPropertySequence()
91     {
92         ::std::vector< ::com::sun::star::beans::Property > aProperties;
93         ::chart::LineProperties::AddPropertiesToVector( aProperties );
94         ::chart::FillProperties::AddPropertiesToVector( aProperties );
95         ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
96 
97         ::std::sort( aProperties.begin(), aProperties.end(),
98                      ::chart::PropertyNameLess() );
99 
100         return ::chart::ContainerHelper::ContainerToSequence( aProperties );
101     }
102 
103 };
104 
105 struct StaticWallInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticWallInfoHelper_Initializer >
106 {
107 };
108 
109 struct StaticWallInfo_Initializer
110 {
operator ()__anonb4cbf0770111::StaticWallInfo_Initializer111     uno::Reference< beans::XPropertySetInfo >* operator()()
112     {
113         static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
114             ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticWallInfoHelper::get() ) );
115         return &xPropertySetInfo;
116     }
117 };
118 
119 struct StaticWallInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticWallInfo_Initializer >
120 {
121 };
122 
123 } // anonymous namespace
124 
125 // ================================================================================
126 
127 namespace chart
128 {
129 
Wall()130 Wall::Wall() :
131         ::property::OPropertySet( m_aMutex ),
132     m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
133 {}
134 
Wall(const Wall & rOther)135 Wall::Wall( const Wall & rOther ) :
136         MutexContainer(),
137         impl::Wall_Base(),
138         ::property::OPropertySet( rOther, m_aMutex ),
139     m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
140 {}
141 
~Wall()142 Wall::~Wall()
143 {}
144 
145 // ____ XCloneable ____
createClone()146 uno::Reference< util::XCloneable > SAL_CALL Wall::createClone()
147     throw (uno::RuntimeException)
148 {
149     return uno::Reference< util::XCloneable >( new Wall( *this ));
150 }
151 
152 // ================================================================================
153 
154 // ____ OPropertySet ____
GetDefaultValue(sal_Int32 nHandle) const155 uno::Any Wall::GetDefaultValue( sal_Int32 nHandle ) const
156     throw(beans::UnknownPropertyException)
157 {
158     const tPropertyValueMap& rStaticDefaults = *StaticWallDefaults::get();
159     tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
160     if( aFound == rStaticDefaults.end() )
161         return uno::Any();
162     return (*aFound).second;
163 }
164 
getInfoHelper()165 ::cppu::IPropertyArrayHelper & SAL_CALL Wall::getInfoHelper()
166 {
167     return *StaticWallInfoHelper::get();
168 }
169 
170 // ____ XPropertySet ____
getPropertySetInfo()171 uno::Reference< beans::XPropertySetInfo > SAL_CALL Wall::getPropertySetInfo()
172     throw (uno::RuntimeException)
173 {
174     return *StaticWallInfo::get();
175 }
176 
177 // ____ XModifyBroadcaster ____
addModifyListener(const uno::Reference<util::XModifyListener> & aListener)178 void SAL_CALL Wall::addModifyListener( const uno::Reference< util::XModifyListener >& aListener )
179     throw (uno::RuntimeException)
180 {
181     try
182     {
183         uno::Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
184         xBroadcaster->addModifyListener( aListener );
185     }
186     catch( const uno::Exception & ex )
187     {
188         ASSERT_EXCEPTION( ex );
189     }
190 }
191 
removeModifyListener(const uno::Reference<util::XModifyListener> & aListener)192 void SAL_CALL Wall::removeModifyListener( const uno::Reference< util::XModifyListener >& aListener )
193     throw (uno::RuntimeException)
194 {
195     try
196     {
197         uno::Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
198         xBroadcaster->removeModifyListener( aListener );
199     }
200     catch( const uno::Exception & ex )
201     {
202         ASSERT_EXCEPTION( ex );
203     }
204 }
205 
206 // ____ XModifyListener ____
modified(const lang::EventObject & aEvent)207 void SAL_CALL Wall::modified( const lang::EventObject& aEvent )
208     throw (uno::RuntimeException)
209 {
210     m_xModifyEventForwarder->modified( aEvent );
211 }
212 
213 // ____ XEventListener (base of XModifyListener) ____
disposing(const lang::EventObject &)214 void SAL_CALL Wall::disposing( const lang::EventObject& /* Source */ )
215     throw (uno::RuntimeException)
216 {
217     // nothing
218 }
219 
220 // ____ OPropertySet ____
firePropertyChangeEvent()221 void Wall::firePropertyChangeEvent()
222 {
223     fireModifyEvent();
224 }
225 
fireModifyEvent()226 void Wall::fireModifyEvent()
227 {
228     m_xModifyEventForwarder->modified( lang::EventObject( static_cast< uno::XWeak* >( this )));
229 }
230 
231 // ================================================================================
232 
getSupportedServiceNames_Static()233 uno::Sequence< ::rtl::OUString > Wall::getSupportedServiceNames_Static()
234 {
235     uno::Sequence< ::rtl::OUString > aServices( 2 );
236     aServices[ 0 ] = C2U( "com.sun.star.chart2.Wall" );
237     aServices[ 1 ] = C2U( "com.sun.star.beans.PropertySet" );
238     return aServices;
239 }
240 
241 // implement XServiceInfo methods basing upon getSupportedServiceNames_Static
242 APPHELPER_XSERVICEINFO_IMPL( Wall, lcl_aServiceName );
243 
244 using impl::Wall_Base;
245 
246 IMPLEMENT_FORWARD_XINTERFACE2( Wall, Wall_Base, ::property::OPropertySet )
247 
248 } //  namespace chart
249