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"
31 #include "GridProperties.hxx"
32 #include "LineProperties.hxx"
33 #include "UserDefinedProperties.hxx"
34 #include "PropertyHelper.hxx"
36 #include "ContainerHelper.hxx"
37 #include <com/sun/star/style/XStyle.hpp>
38 #include <com/sun/star/beans/PropertyAttribute.hpp>
39 #include <com/sun/star/beans/XPropertySet.hpp>
40 #include <com/sun/star/uno/Sequence.hxx>
42 using namespace ::com::sun::star
;
44 using ::com::sun::star::uno::Reference
;
45 using ::com::sun::star::uno::Sequence
;
46 using ::com::sun::star::beans::Property
;
47 using ::osl::MutexGuard
;
48 using ::rtl::OUString
;
50 // ____________________________________________________________
55 static const ::rtl::OUString
lcl_aServiceName(
56 RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.chart2.GridProperties" ));
63 void lcl_AddPropertiesToVector(
64 ::std::vector
< Property
> & rOutProperties
)
66 rOutProperties
.push_back(
67 Property( C2U( "Show" ),
69 ::getBooleanCppuType(),
70 beans::PropertyAttribute::BOUND
71 | beans::PropertyAttribute::MAYBEDEFAULT
));
74 void lcl_addDefaultsToMap( ::chart::tPropertyValueMap
& rOutMap
)
76 ::chart::LineProperties::AddDefaultsToMap( rOutMap
);
78 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap
, PROP_GRID_SHOW
, false );
80 // override other defaults
81 ::chart::PropertyHelper::setPropertyValue
< sal_Int32
>(
82 rOutMap
, ::chart::LineProperties::PROP_LINE_COLOR
, 0xb3b3b3 ); // gray30
85 const Sequence
< Property
> & lcl_getPropertySequence()
87 static Sequence
< Property
> aPropSeq
;
90 MutexGuard
aGuard( ::osl::Mutex::getGlobalMutex() );
91 if( 0 == aPropSeq
.getLength() )
94 ::std::vector
< Property
> aProperties
;
95 lcl_AddPropertiesToVector( aProperties
);
96 ::chart::LineProperties::AddPropertiesToVector( aProperties
);
97 ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties
);
99 // and sort them for access via bsearch
100 ::std::sort( aProperties
.begin(), aProperties
.end(),
101 ::chart::PropertyNameLess() );
103 // transfer result to static Sequence
104 aPropSeq
= ::chart::ContainerHelper::ContainerToSequence( aProperties
);
110 ::cppu::IPropertyArrayHelper
& lcl_getInfoHelper()
112 static ::cppu::OPropertyArrayHelper
aArrayHelper(
113 lcl_getPropertySequence(),
114 /* bSorted = */ sal_True
);
119 } // anonymous namespace
121 // ____________________________________________________________
126 GridProperties::GridProperties( Reference
< uno::XComponentContext
> const & /* xContext */ ) :
127 ::property::OPropertySet( m_aMutex
),
128 m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
132 GridProperties::GridProperties() :
133 ::property::OPropertySet( m_aMutex
),
134 m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
137 GridProperties::GridProperties( const GridProperties
& rOther
) :
139 impl::GridProperties_Base(),
140 ::property::OPropertySet( rOther
, m_aMutex
),
141 m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
145 GridProperties::~GridProperties()
148 // ____ OPropertySet ____
149 uno::Any
GridProperties::GetDefaultValue( sal_Int32 nHandle
) const
150 throw(beans::UnknownPropertyException
)
152 static tPropertyValueMap aStaticDefaults
;
155 ::osl::MutexGuard
aGuard( ::osl::Mutex::getGlobalMutex() );
156 if( 0 == aStaticDefaults
.size() )
157 lcl_addDefaultsToMap( aStaticDefaults
);
159 tPropertyValueMap::const_iterator
aFound(
160 aStaticDefaults
.find( nHandle
));
162 if( aFound
== aStaticDefaults
.end())
165 return (*aFound
).second
;
169 ::cppu::IPropertyArrayHelper
& SAL_CALL
GridProperties::getInfoHelper()
171 return lcl_getInfoHelper();
174 // ____ XPropertySet ____
175 Reference
< beans::XPropertySetInfo
> SAL_CALL
176 GridProperties::getPropertySetInfo()
177 throw (uno::RuntimeException
)
179 static Reference
< beans::XPropertySetInfo
> xInfo
;
182 ::osl::MutexGuard
aGuard( ::osl::Mutex::getGlobalMutex() );
185 xInfo
= ::cppu::OPropertySetHelper::createPropertySetInfo(
186 lcl_getInfoHelper());
193 // ____ XCloneable ____
194 uno::Reference
< util::XCloneable
> SAL_CALL
GridProperties::createClone()
195 throw (uno::RuntimeException
)
197 return uno::Reference
< util::XCloneable
>( new GridProperties( *this ));
200 // ____ XModifyBroadcaster ____
201 void SAL_CALL
GridProperties::addModifyListener( const Reference
< util::XModifyListener
>& aListener
)
202 throw (uno::RuntimeException
)
206 Reference
< util::XModifyBroadcaster
> xBroadcaster( m_xModifyEventForwarder
, uno::UNO_QUERY_THROW
);
207 xBroadcaster
->addModifyListener( aListener
);
209 catch( const uno::Exception
& ex
)
211 ASSERT_EXCEPTION( ex
);
215 void SAL_CALL
GridProperties::removeModifyListener( const Reference
< util::XModifyListener
>& aListener
)
216 throw (uno::RuntimeException
)
220 Reference
< util::XModifyBroadcaster
> xBroadcaster( m_xModifyEventForwarder
, uno::UNO_QUERY_THROW
);
221 xBroadcaster
->removeModifyListener( aListener
);
223 catch( const uno::Exception
& ex
)
225 ASSERT_EXCEPTION( ex
);
229 // ____ XModifyListener ____
230 void SAL_CALL
GridProperties::modified( const lang::EventObject
& aEvent
)
231 throw (uno::RuntimeException
)
233 m_xModifyEventForwarder
->modified( aEvent
);
236 // ____ XEventListener (base of XModifyListener) ____
237 void SAL_CALL
GridProperties::disposing( const lang::EventObject
& /* Source */ )
238 throw (uno::RuntimeException
)
243 // ____ OPropertySet ____
244 void GridProperties::firePropertyChangeEvent()
249 void GridProperties::fireModifyEvent()
251 m_xModifyEventForwarder
->modified( lang::EventObject( static_cast< uno::XWeak
* >( this )));
254 // ================================================================================
256 Sequence
< OUString
> GridProperties::getSupportedServiceNames_Static()
258 Sequence
< OUString
> aServices( 2 );
259 aServices
[ 0 ] = C2U( "com.sun.star.chart2.GridProperties" );
260 aServices
[ 1 ] = C2U( "com.sun.star.beans.PropertySet" );
264 // implement XServiceInfo methods basing upon getSupportedServiceNames_Static
265 APPHELPER_XSERVICEINFO_IMPL( GridProperties
, lcl_aServiceName
);
267 // needed by MSC compiler
268 using impl::GridProperties_Base
;
270 IMPLEMENT_FORWARD_XINTERFACE2( GridProperties
, GridProperties_Base
, ::property::OPropertySet
)
271 IMPLEMENT_FORWARD_XTYPEPROVIDER2( GridProperties
, GridProperties_Base
, ::property::OPropertySet
)