update dev300-m58
[ooovba.git] / chart2 / source / model / template / ColumnChartType.cxx
blobed5aea88ae68b34b67986eee2ee7b97194c806f2
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: ColumnChartType.cxx,v $
10 * $Revision: 1.7 $
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 "ColumnChartType.hxx"
34 #include "macros.hxx"
35 #include "servicenames_charttypes.hxx"
36 #include "PropertyHelper.hxx"
37 #include "ContainerHelper.hxx"
38 #include <com/sun/star/beans/PropertyAttribute.hpp>
40 using namespace ::com::sun::star;
41 using ::com::sun::star::uno::Sequence;
42 using ::com::sun::star::beans::Property;
44 //-----------------------------------------------------------------------------
46 namespace
49 enum
51 PROP_BARCHARTTYPE_OVERLAP_SEQUENCE,
52 PROP_BARCHARTTYPE_GAPWIDTH_SEQUENCE
55 void lcl_AddPropertiesToVector(
56 ::std::vector< Property > & rOutProperties )
58 rOutProperties.push_back(
59 Property( C2U( "OverlapSequence" ),
60 PROP_BARCHARTTYPE_OVERLAP_SEQUENCE,
61 ::getCppuType( reinterpret_cast< const Sequence< sal_Int32 > * >(0)),
62 beans::PropertyAttribute::BOUND
63 | beans::PropertyAttribute::MAYBEDEFAULT ));
65 rOutProperties.push_back(
66 Property( C2U( "GapwidthSequence" ),
67 PROP_BARCHARTTYPE_GAPWIDTH_SEQUENCE,
68 ::getCppuType( reinterpret_cast< const Sequence< sal_Int32 > * >(0)),
69 beans::PropertyAttribute::BOUND
70 | beans::PropertyAttribute::MAYBEDEFAULT ));
73 void lcl_AddDefaultsToMap(
74 ::chart::tPropertyValueMap & rOutMap )
76 Sequence< sal_Int32 > aSeq(2);
78 aSeq[0] = aSeq[1] = 0;
79 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_BARCHARTTYPE_OVERLAP_SEQUENCE, aSeq );
81 aSeq[0] = aSeq[1] = 100;
82 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_BARCHARTTYPE_GAPWIDTH_SEQUENCE, aSeq );
85 const Sequence< Property > & lcl_GetPropertySequence()
87 static Sequence< Property > aPropSeq;
89 // /--
90 ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
91 if( 0 == aPropSeq.getLength() )
93 // get properties
94 ::std::vector< ::com::sun::star::beans::Property > aProperties;
95 lcl_AddPropertiesToVector( aProperties );
97 // and sort them for access via bsearch
98 ::std::sort( aProperties.begin(), aProperties.end(),
99 ::chart::PropertyNameLess() );
101 // transfer result to static Sequence
102 aPropSeq = ::chart::ContainerHelper::ContainerToSequence( aProperties );
105 return aPropSeq;
108 } // anonymous namespace
110 namespace chart
113 ColumnChartType::ColumnChartType(
114 const uno::Reference< uno::XComponentContext > & xContext ) :
115 ChartType( xContext )
118 ColumnChartType::ColumnChartType( const ColumnChartType & rOther ) :
119 ChartType( rOther )
123 ColumnChartType::~ColumnChartType()
126 // ____ XCloneable ____
127 uno::Reference< util::XCloneable > SAL_CALL ColumnChartType::createClone()
128 throw (uno::RuntimeException)
130 return uno::Reference< util::XCloneable >( new ColumnChartType( *this ));
133 // ____ XChartType ____
134 ::rtl::OUString SAL_CALL ColumnChartType::getChartType()
135 throw (uno::RuntimeException)
137 return CHART2_SERVICE_NAME_CHARTTYPE_COLUMN;
140 // ____ OPropertySet ____
141 uno::Any ColumnChartType::GetDefaultValue( sal_Int32 nHandle ) const
142 throw(beans::UnknownPropertyException)
144 static tPropertyValueMap aStaticDefaults;
146 // /--
147 ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
148 if( 0 == aStaticDefaults.size() )
150 // initialize defaults
151 lcl_AddDefaultsToMap( aStaticDefaults );
154 tPropertyValueMap::const_iterator aFound(
155 aStaticDefaults.find( nHandle ));
157 if( aFound == aStaticDefaults.end())
158 return uno::Any();
160 return (*aFound).second;
161 // \--
164 ::cppu::IPropertyArrayHelper & SAL_CALL ColumnChartType::getInfoHelper()
166 static ::cppu::OPropertyArrayHelper aArrayHelper( lcl_GetPropertySequence(),
167 /* bSorted = */ sal_True );
168 return aArrayHelper;
172 // ____ XPropertySet ____
173 uno::Reference< beans::XPropertySetInfo > SAL_CALL
174 ColumnChartType::getPropertySetInfo()
175 throw (uno::RuntimeException)
177 static uno::Reference< beans::XPropertySetInfo > xInfo;
179 // /--
180 ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
181 if( !xInfo.is())
183 xInfo = ::cppu::OPropertySetHelper::createPropertySetInfo(
184 getInfoHelper());
187 return xInfo;
188 // \--
193 uno::Sequence< ::rtl::OUString > ColumnChartType::getSupportedServiceNames_Static()
195 uno::Sequence< ::rtl::OUString > aServices( 2 );
196 aServices[ 0 ] = CHART2_SERVICE_NAME_CHARTTYPE_COLUMN;
197 aServices[ 1 ] = C2U( "com.sun.star.chart2.ChartType" );
198 return aServices;
201 // implement XServiceInfo methods basing upon getSupportedServiceNames_Static
202 APPHELPER_XSERVICEINFO_IMPL( ColumnChartType,
203 C2U( "com.sun.star.comp.chart.ColumnChartType" ));
205 } // namespace chart