Update ooo320-m1
[ooovba.git] / chart2 / source / model / template / AreaChartType.cxx
blob3a562f05ba230de581128ea839b860e94e27356a
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: AreaChartType.cxx,v $
10 * $Revision: 1.6 $
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"
33 #include "AreaChartType.hxx"
34 #include "macros.hxx"
35 #include "servicenames_charttypes.hxx"
36 #include "PropertyHelper.hxx"
37 #include "ContainerHelper.hxx"
39 #include <com/sun/star/beans/PropertyAttribute.hpp>
41 using namespace ::com::sun::star;
42 using ::com::sun::star::beans::Property;
43 using ::com::sun::star::uno::Sequence;
45 namespace
48 enum
50 PROP_AREACHARTTYPE_STACKED,
51 PROP_AREACHARTTYPE_PERCENT
54 void lcl_AddPropertiesToVector(
55 ::std::vector< Property > & rOutProperties )
57 rOutProperties.push_back(
58 Property( C2U( "Stacked" ),
59 PROP_AREACHARTTYPE_STACKED,
60 ::getBooleanCppuType(),
61 beans::PropertyAttribute::BOUND
62 | beans::PropertyAttribute::MAYBEDEFAULT ));
63 rOutProperties.push_back(
64 Property( C2U( "Percent" ),
65 PROP_AREACHARTTYPE_PERCENT,
66 ::getBooleanCppuType(),
67 beans::PropertyAttribute::BOUND
68 | beans::PropertyAttribute::MAYBEDEFAULT ));
71 void lcl_AddDefaultsToMap(
72 ::chart::tPropertyValueMap & rOutMap )
74 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_AREACHARTTYPE_STACKED, false );
75 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_AREACHARTTYPE_PERCENT, false );
78 const Sequence< Property > & lcl_GetPropertySequence()
80 static Sequence< Property > aPropSeq;
82 // /--
83 ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
84 if( 0 == aPropSeq.getLength() )
86 // get properties
87 ::std::vector< ::com::sun::star::beans::Property > aProperties;
88 lcl_AddPropertiesToVector( aProperties );
90 // and sort them for access via bsearch
91 ::std::sort( aProperties.begin(), aProperties.end(),
92 ::chart::PropertyNameLess() );
94 // transfer result to static Sequence
95 aPropSeq = ::chart::ContainerHelper::ContainerToSequence( aProperties );
98 return aPropSeq;
101 } // anonymous namespace
103 namespace chart
106 AreaChartType::AreaChartType(
107 const uno::Reference< uno::XComponentContext > & xContext ) :
108 ChartType( xContext )
111 AreaChartType::AreaChartType( const AreaChartType & rOther ) :
112 ChartType( rOther )
115 AreaChartType::~AreaChartType()
118 // ____ XCloneable ____
119 uno::Reference< util::XCloneable > SAL_CALL AreaChartType::createClone()
120 throw (uno::RuntimeException)
122 return uno::Reference< util::XCloneable >( new AreaChartType( *this ));
125 // ____ XChartType ____
126 ::rtl::OUString SAL_CALL AreaChartType::getChartType()
127 throw (uno::RuntimeException)
129 return CHART2_SERVICE_NAME_CHARTTYPE_AREA;
132 // ____ OPropertySet ____
133 uno::Any AreaChartType::GetDefaultValue( sal_Int32 nHandle ) const
134 throw(beans::UnknownPropertyException)
136 static tPropertyValueMap aStaticDefaults;
138 // /--
139 ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
140 if( 0 == aStaticDefaults.size() )
142 // initialize defaults
143 lcl_AddDefaultsToMap( aStaticDefaults );
146 tPropertyValueMap::const_iterator aFound(
147 aStaticDefaults.find( nHandle ));
149 if( aFound == aStaticDefaults.end())
150 return uno::Any();
152 return (*aFound).second;
153 // \--
156 ::cppu::IPropertyArrayHelper & SAL_CALL AreaChartType::getInfoHelper()
158 static ::cppu::OPropertyArrayHelper aArrayHelper( lcl_GetPropertySequence(),
159 /* bSorted = */ sal_True );
161 return aArrayHelper;
164 // ____ XPropertySet ____
165 uno::Reference< beans::XPropertySetInfo > SAL_CALL AreaChartType::getPropertySetInfo()
166 throw (uno::RuntimeException)
168 static uno::Reference< beans::XPropertySetInfo > xInfo;
170 // /--
171 ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
172 if( !xInfo.is())
174 xInfo = ::cppu::OPropertySetHelper::createPropertySetInfo(
175 getInfoHelper());
178 return xInfo;
179 // \--
182 uno::Sequence< ::rtl::OUString > AreaChartType::getSupportedServiceNames_Static()
184 uno::Sequence< ::rtl::OUString > aServices( 2 );
185 aServices[ 0 ] = CHART2_SERVICE_NAME_CHARTTYPE_AREA;
186 aServices[ 1 ] = C2U( "com.sun.star.chart2.ChartType" );
187 return aServices;
190 // implement XServiceInfo methods basing upon getSupportedServiceNames_Static
191 APPHELPER_XSERVICEINFO_IMPL( AreaChartType,
192 C2U( "com.sun.star.comp.chart.AreaChartType" ));
194 } // namespace chart