update dev300-m58
[ooovba.git] / chart2 / source / model / template / BubbleChartType.cxx
blob87c070ceb6e341ce773cea220eea3e36edcec7ab
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: ,v $
10 * $Revision: $
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 "BubbleChartType.hxx"
34 #include "PropertyHelper.hxx"
35 #include "macros.hxx"
36 #include "servicenames_charttypes.hxx"
37 #include "ContainerHelper.hxx"
38 #include "CartesianCoordinateSystem.hxx"
39 #include "AxisHelper.hxx"
40 #include "AxisIndexDefines.hxx"
41 #include <com/sun/star/beans/PropertyAttribute.hpp>
42 #include <com/sun/star/chart2/AxisType.hpp>
43 #include <com/sun/star/chart2/CurveStyle.hpp>
45 using namespace ::com::sun::star;
47 using ::rtl::OUString;
48 using ::com::sun::star::beans::Property;
49 using ::com::sun::star::uno::Sequence;
50 using ::com::sun::star::uno::Reference;
51 using ::com::sun::star::uno::Any;
52 using ::osl::MutexGuard;
54 namespace
57 void lcl_AddPropertiesToVector(
58 ::std::vector< Property > & /*rOutProperties*/ )
62 void lcl_AddDefaultsToMap(
63 ::chart::tPropertyValueMap & /*rOutMap*/ )
67 const Sequence< Property > & lcl_GetPropertySequence()
69 static Sequence< Property > aPropSeq;
71 // /--
72 ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
73 if( 0 == aPropSeq.getLength() )
75 // get properties
76 ::std::vector< ::com::sun::star::beans::Property > aProperties;
77 lcl_AddPropertiesToVector( aProperties );
79 // and sort them for access via bsearch
80 ::std::sort( aProperties.begin(), aProperties.end(),
81 ::chart::PropertyNameLess() );
83 // transfer result to static Sequence
84 aPropSeq = ::chart::ContainerHelper::ContainerToSequence( aProperties );
87 return aPropSeq;
90 } // anonymous namespace
92 namespace chart
95 BubbleChartType::BubbleChartType(
96 const uno::Reference< uno::XComponentContext > & xContext )
97 : ChartType( xContext )
101 BubbleChartType::BubbleChartType( const BubbleChartType & rOther ) :
102 ChartType( rOther )
106 BubbleChartType::~BubbleChartType()
109 // ____ XCloneable ____
110 uno::Reference< util::XCloneable > SAL_CALL BubbleChartType::createClone()
111 throw (uno::RuntimeException)
113 return uno::Reference< util::XCloneable >( new BubbleChartType( *this ));
116 // ____ XChartType ____
117 Reference< chart2::XCoordinateSystem > SAL_CALL
118 BubbleChartType::createCoordinateSystem( ::sal_Int32 DimensionCount )
119 throw (lang::IllegalArgumentException,
120 uno::RuntimeException)
122 Reference< chart2::XCoordinateSystem > xResult(
123 new CartesianCoordinateSystem(
124 GetComponentContext(), DimensionCount, /* bSwapXAndYAxis */ sal_False ));
126 for( sal_Int32 i=0; i<DimensionCount; ++i )
128 Reference< chart2::XAxis > xAxis( xResult->getAxisByDimension( i, MAIN_AXIS_INDEX ) );
129 if( !xAxis.is() )
131 OSL_ENSURE(false,"a created coordinate system should have an axis for each dimension");
132 continue;
135 chart2::ScaleData aScaleData = xAxis->getScaleData();
136 aScaleData.Orientation = chart2::AxisOrientation_MATHEMATICAL;
137 aScaleData.Scaling = AxisHelper::createLinearScaling();
139 if( i == 2 )
140 aScaleData.AxisType = chart2::AxisType::SERIES;
141 else
142 aScaleData.AxisType = chart2::AxisType::REALNUMBER;
144 xAxis->setScaleData( aScaleData );
147 return xResult;
150 ::rtl::OUString SAL_CALL BubbleChartType::getChartType()
151 throw (uno::RuntimeException)
153 return CHART2_SERVICE_NAME_CHARTTYPE_BUBBLE;
156 uno::Sequence< ::rtl::OUString > SAL_CALL BubbleChartType::getSupportedMandatoryRoles()
157 throw (uno::RuntimeException)
159 static uno::Sequence< ::rtl::OUString > aMandRolesSeq;
161 if( aMandRolesSeq.getLength() == 0 )
163 aMandRolesSeq.realloc( 4 );
164 aMandRolesSeq[0] = C2U( "label" );
165 aMandRolesSeq[1] = C2U( "values-x" );
166 aMandRolesSeq[2] = C2U( "values-y" );
167 aMandRolesSeq[3] = C2U( "values-size" );
170 return aMandRolesSeq;
173 OUString SAL_CALL BubbleChartType::getRoleOfSequenceForSeriesLabel()
174 throw (uno::RuntimeException)
176 return C2U( "values-size" );
179 // ____ OPropertySet ____
180 uno::Any BubbleChartType::GetDefaultValue( sal_Int32 nHandle ) const
181 throw(beans::UnknownPropertyException)
183 static tPropertyValueMap aStaticDefaults;
185 // /--
186 ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
187 if( 0 == aStaticDefaults.size() )
189 // initialize defaults
190 lcl_AddDefaultsToMap( aStaticDefaults );
193 tPropertyValueMap::const_iterator aFound(
194 aStaticDefaults.find( nHandle ));
196 if( aFound == aStaticDefaults.end())
197 return uno::Any();
199 return (*aFound).second;
200 // \--
203 // ____ OPropertySet ____
204 ::cppu::IPropertyArrayHelper & SAL_CALL BubbleChartType::getInfoHelper()
206 static ::cppu::OPropertyArrayHelper aArrayHelper( lcl_GetPropertySequence(),
207 /* bSorted = */ sal_True );
209 return aArrayHelper;
213 // ____ XPropertySet ____
214 uno::Reference< beans::XPropertySetInfo > SAL_CALL
215 BubbleChartType::getPropertySetInfo()
216 throw (uno::RuntimeException)
218 static uno::Reference< beans::XPropertySetInfo > xInfo;
220 // /--
221 ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
222 if( !xInfo.is())
224 xInfo = ::cppu::OPropertySetHelper::createPropertySetInfo(
225 getInfoHelper());
228 return xInfo;
229 // \--
232 uno::Sequence< ::rtl::OUString > BubbleChartType::getSupportedServiceNames_Static()
234 uno::Sequence< ::rtl::OUString > aServices( 3 );
235 aServices[ 0 ] = CHART2_SERVICE_NAME_CHARTTYPE_BUBBLE;
236 aServices[ 1 ] = C2U( "com.sun.star.chart2.ChartType" );
237 aServices[ 2 ] = C2U( "com.sun.star.beans.PropertySet" );
238 return aServices;
241 // implement XServiceInfo methods basing upon getSupportedServiceNames_Static
242 APPHELPER_XSERVICEINFO_IMPL( BubbleChartType,
243 C2U( "com.sun.star.comp.chart.BubbleChartType" ));
245 } // namespace chart