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