1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: Wall.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_chart2.hxx"
35 #include "LineProperties.hxx"
36 #include "FillProperties.hxx"
37 #include "UserDefinedProperties.hxx"
38 #include "ContainerHelper.hxx"
39 #include "PropertyHelper.hxx"
40 #include <com/sun/star/beans/PropertyAttribute.hpp>
41 #include <com/sun/star/drawing/FillStyle.hpp>
42 #include <com/sun/star/awt/Gradient.hpp>
43 #include <com/sun/star/drawing/Hatch.hpp>
44 #include <com/sun/star/drawing/LineStyle.hpp>
45 #include <com/sun/star/drawing/LineDash.hpp>
46 #include <com/sun/star/drawing/LineJoint.hpp>
48 #include <cppuhelper/queryinterface.hxx>
53 using namespace ::com::sun::star
;
54 using namespace ::com::sun::star::beans::PropertyAttribute
;
56 using ::com::sun::star::beans::Property
;
57 using ::osl::MutexGuard
;
62 static const ::rtl::OUString
lcl_aServiceName(
63 RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.chart2.Wall" ));
65 void lcl_AddDefaultsToMap(
66 ::chart::tPropertyValueMap
& rOutMap
)
68 // override other defaults
69 ::chart::PropertyHelper::setPropertyValue( rOutMap
, ::chart::LineProperties::PROP_LINE_STYLE
, drawing::LineStyle_NONE
);
72 const uno::Sequence
< Property
> & lcl_GetPropertySequence()
74 static uno::Sequence
< Property
> aPropSeq
;
77 MutexGuard
aGuard( ::osl::Mutex::getGlobalMutex() );
78 if( 0 == aPropSeq
.getLength() )
81 ::std::vector
< ::com::sun::star::beans::Property
> aProperties
;
82 ::chart::LineProperties::AddPropertiesToVector( aProperties
);
83 ::chart::FillProperties::AddPropertiesToVector( aProperties
);
84 ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties
);
86 // and sort them for access via bsearch
87 ::std::sort( aProperties
.begin(), aProperties
.end(),
88 ::chart::PropertyNameLess() );
90 // transfer result to static Sequence
91 aPropSeq
= ::chart::ContainerHelper::ContainerToSequence( aProperties
);
97 ::cppu::IPropertyArrayHelper
& lcl_getInfoHelper()
99 static ::cppu::OPropertyArrayHelper
aArrayHelper(
100 lcl_GetPropertySequence(),
101 /* bSorted = */ sal_True
);
106 } // anonymous namespace
108 // ================================================================================
114 ::property::OPropertySet( m_aMutex
),
115 m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
118 Wall::Wall( const Wall
& rOther
) :
121 ::property::OPropertySet( rOther
, m_aMutex
),
122 m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
128 // ____ XCloneable ____
129 uno::Reference
< util::XCloneable
> SAL_CALL
Wall::createClone()
130 throw (uno::RuntimeException
)
132 return uno::Reference
< util::XCloneable
>( new Wall( *this ));
135 // ================================================================================
137 // ____ OPropertySet ____
138 uno::Any
Wall::GetDefaultValue( sal_Int32 nHandle
) const
139 throw(beans::UnknownPropertyException
)
141 static tPropertyValueMap aStaticDefaults
;
144 ::osl::MutexGuard
aGuard( ::osl::Mutex::getGlobalMutex() );
145 if( 0 == aStaticDefaults
.size() )
147 // initialize defaults
148 LineProperties::AddDefaultsToMap( aStaticDefaults
);
149 FillProperties::AddDefaultsToMap( aStaticDefaults
);
151 // initialize defaults
152 // Note: this should be last to override defaults of the previously
154 lcl_AddDefaultsToMap( aStaticDefaults
);
157 tPropertyValueMap::const_iterator
aFound(
158 aStaticDefaults
.find( nHandle
));
160 if( aFound
== aStaticDefaults
.end())
163 return (*aFound
).second
;
167 ::cppu::IPropertyArrayHelper
& SAL_CALL
Wall::getInfoHelper()
169 return lcl_getInfoHelper();
173 // ____ XPropertySet ____
174 uno::Reference
< beans::XPropertySetInfo
> SAL_CALL
175 Wall::getPropertySetInfo()
176 throw (uno::RuntimeException
)
178 static uno::Reference
< beans::XPropertySetInfo
> xInfo
;
181 MutexGuard
aGuard( ::osl::Mutex::getGlobalMutex() );
184 xInfo
= ::cppu::OPropertySetHelper::createPropertySetInfo(
192 // ____ XModifyBroadcaster ____
193 void SAL_CALL
Wall::addModifyListener( const uno::Reference
< util::XModifyListener
>& aListener
)
194 throw (uno::RuntimeException
)
198 uno::Reference
< util::XModifyBroadcaster
> xBroadcaster( m_xModifyEventForwarder
, uno::UNO_QUERY_THROW
);
199 xBroadcaster
->addModifyListener( aListener
);
201 catch( const uno::Exception
& ex
)
203 ASSERT_EXCEPTION( ex
);
207 void SAL_CALL
Wall::removeModifyListener( const uno::Reference
< util::XModifyListener
>& aListener
)
208 throw (uno::RuntimeException
)
212 uno::Reference
< util::XModifyBroadcaster
> xBroadcaster( m_xModifyEventForwarder
, uno::UNO_QUERY_THROW
);
213 xBroadcaster
->removeModifyListener( aListener
);
215 catch( const uno::Exception
& ex
)
217 ASSERT_EXCEPTION( ex
);
221 // ____ XModifyListener ____
222 void SAL_CALL
Wall::modified( const lang::EventObject
& aEvent
)
223 throw (uno::RuntimeException
)
225 m_xModifyEventForwarder
->modified( aEvent
);
228 // ____ XEventListener (base of XModifyListener) ____
229 void SAL_CALL
Wall::disposing( const lang::EventObject
& /* Source */ )
230 throw (uno::RuntimeException
)
235 // ____ OPropertySet ____
236 void Wall::firePropertyChangeEvent()
241 void Wall::fireModifyEvent()
243 m_xModifyEventForwarder
->modified( lang::EventObject( static_cast< uno::XWeak
* >( this )));
246 // ================================================================================
248 uno::Sequence
< ::rtl::OUString
> Wall::getSupportedServiceNames_Static()
250 uno::Sequence
< ::rtl::OUString
> aServices( 2 );
251 aServices
[ 0 ] = C2U( "com.sun.star.chart2.Wall" );
252 aServices
[ 1 ] = C2U( "com.sun.star.beans.PropertySet" );
256 // implement XServiceInfo methods basing upon getSupportedServiceNames_Static
257 APPHELPER_XSERVICEINFO_IMPL( Wall
, lcl_aServiceName
);
259 using impl::Wall_Base
;
261 IMPLEMENT_FORWARD_XINTERFACE2( Wall
, Wall_Base
, ::property::OPropertySet
)