merged tag ooo/OOO330_m14
[LibreOffice.git] / chart2 / source / model / template / ColumnChartType.cxx
blobaa11d77e8995cd0bff851c7033b9803a632a626a
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"
30 #include "ColumnChartType.hxx"
31 #include "macros.hxx"
32 #include "servicenames_charttypes.hxx"
33 #include "PropertyHelper.hxx"
34 #include "ContainerHelper.hxx"
35 #include <com/sun/star/beans/PropertyAttribute.hpp>
37 using namespace ::com::sun::star;
38 using ::com::sun::star::uno::Sequence;
39 using ::com::sun::star::beans::Property;
41 //-----------------------------------------------------------------------------
43 namespace
46 enum
48 PROP_BARCHARTTYPE_OVERLAP_SEQUENCE,
49 PROP_BARCHARTTYPE_GAPWIDTH_SEQUENCE
52 void lcl_AddPropertiesToVector(
53 ::std::vector< Property > & rOutProperties )
55 rOutProperties.push_back(
56 Property( C2U( "OverlapSequence" ),
57 PROP_BARCHARTTYPE_OVERLAP_SEQUENCE,
58 ::getCppuType( reinterpret_cast< const Sequence< sal_Int32 > * >(0)),
59 beans::PropertyAttribute::BOUND
60 | beans::PropertyAttribute::MAYBEDEFAULT ));
62 rOutProperties.push_back(
63 Property( C2U( "GapwidthSequence" ),
64 PROP_BARCHARTTYPE_GAPWIDTH_SEQUENCE,
65 ::getCppuType( reinterpret_cast< const Sequence< sal_Int32 > * >(0)),
66 beans::PropertyAttribute::BOUND
67 | beans::PropertyAttribute::MAYBEDEFAULT ));
70 void lcl_AddDefaultsToMap(
71 ::chart::tPropertyValueMap & rOutMap )
73 Sequence< sal_Int32 > aSeq(2);
75 aSeq[0] = aSeq[1] = 0;
76 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_BARCHARTTYPE_OVERLAP_SEQUENCE, aSeq );
78 aSeq[0] = aSeq[1] = 100;
79 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_BARCHARTTYPE_GAPWIDTH_SEQUENCE, aSeq );
82 const Sequence< Property > & lcl_GetPropertySequence()
84 static Sequence< Property > aPropSeq;
86 // /--
87 ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
88 if( 0 == aPropSeq.getLength() )
90 // get properties
91 ::std::vector< ::com::sun::star::beans::Property > aProperties;
92 lcl_AddPropertiesToVector( aProperties );
94 // and sort them for access via bsearch
95 ::std::sort( aProperties.begin(), aProperties.end(),
96 ::chart::PropertyNameLess() );
98 // transfer result to static Sequence
99 aPropSeq = ::chart::ContainerHelper::ContainerToSequence( aProperties );
102 return aPropSeq;
105 } // anonymous namespace
107 namespace chart
110 ColumnChartType::ColumnChartType(
111 const uno::Reference< uno::XComponentContext > & xContext ) :
112 ChartType( xContext )
115 ColumnChartType::ColumnChartType( const ColumnChartType & rOther ) :
116 ChartType( rOther )
120 ColumnChartType::~ColumnChartType()
123 // ____ XCloneable ____
124 uno::Reference< util::XCloneable > SAL_CALL ColumnChartType::createClone()
125 throw (uno::RuntimeException)
127 return uno::Reference< util::XCloneable >( new ColumnChartType( *this ));
130 // ____ XChartType ____
131 ::rtl::OUString SAL_CALL ColumnChartType::getChartType()
132 throw (uno::RuntimeException)
134 return CHART2_SERVICE_NAME_CHARTTYPE_COLUMN;
137 // ____ OPropertySet ____
138 uno::Any ColumnChartType::GetDefaultValue( sal_Int32 nHandle ) const
139 throw(beans::UnknownPropertyException)
141 static tPropertyValueMap aStaticDefaults;
143 // /--
144 ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
145 if( 0 == aStaticDefaults.size() )
147 // initialize defaults
148 lcl_AddDefaultsToMap( aStaticDefaults );
151 tPropertyValueMap::const_iterator aFound(
152 aStaticDefaults.find( nHandle ));
154 if( aFound == aStaticDefaults.end())
155 return uno::Any();
157 return (*aFound).second;
158 // \--
161 ::cppu::IPropertyArrayHelper & SAL_CALL ColumnChartType::getInfoHelper()
163 static ::cppu::OPropertyArrayHelper aArrayHelper( lcl_GetPropertySequence(),
164 /* bSorted = */ sal_True );
165 return aArrayHelper;
169 // ____ XPropertySet ____
170 uno::Reference< beans::XPropertySetInfo > SAL_CALL
171 ColumnChartType::getPropertySetInfo()
172 throw (uno::RuntimeException)
174 static uno::Reference< beans::XPropertySetInfo > xInfo;
176 // /--
177 ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
178 if( !xInfo.is())
180 xInfo = ::cppu::OPropertySetHelper::createPropertySetInfo(
181 getInfoHelper());
184 return xInfo;
185 // \--
190 uno::Sequence< ::rtl::OUString > ColumnChartType::getSupportedServiceNames_Static()
192 uno::Sequence< ::rtl::OUString > aServices( 2 );
193 aServices[ 0 ] = CHART2_SERVICE_NAME_CHARTTYPE_COLUMN;
194 aServices[ 1 ] = C2U( "com.sun.star.chart2.ChartType" );
195 return aServices;
198 // implement XServiceInfo methods basing upon getSupportedServiceNames_Static
199 APPHELPER_XSERVICEINFO_IMPL( ColumnChartType,
200 C2U( "com.sun.star.comp.chart.ColumnChartType" ));
202 } // namespace chart