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 "BubbleChartType.hxx"
31 #include "PropertyHelper.hxx"
33 #include "servicenames_charttypes.hxx"
34 #include "ContainerHelper.hxx"
35 #include "CartesianCoordinateSystem.hxx"
36 #include "AxisHelper.hxx"
37 #include "AxisIndexDefines.hxx"
38 #include <com/sun/star/beans/PropertyAttribute.hpp>
39 #include <com/sun/star/chart2/AxisType.hpp>
40 #include <com/sun/star/chart2/CurveStyle.hpp>
42 using namespace ::com::sun::star
;
44 using ::rtl::OUString
;
45 using ::com::sun::star::beans::Property
;
46 using ::com::sun::star::uno::Sequence
;
47 using ::com::sun::star::uno::Reference
;
48 using ::com::sun::star::uno::Any
;
49 using ::osl::MutexGuard
;
54 void lcl_AddPropertiesToVector(
55 ::std::vector
< Property
> & /*rOutProperties*/ )
59 void lcl_AddDefaultsToMap(
60 ::chart::tPropertyValueMap
& /*rOutMap*/ )
64 const Sequence
< Property
> & lcl_GetPropertySequence()
66 static Sequence
< Property
> aPropSeq
;
69 ::osl::MutexGuard
aGuard( ::osl::Mutex::getGlobalMutex() );
70 if( 0 == aPropSeq
.getLength() )
73 ::std::vector
< ::com::sun::star::beans::Property
> aProperties
;
74 lcl_AddPropertiesToVector( aProperties
);
76 // and sort them for access via bsearch
77 ::std::sort( aProperties
.begin(), aProperties
.end(),
78 ::chart::PropertyNameLess() );
80 // transfer result to static Sequence
81 aPropSeq
= ::chart::ContainerHelper::ContainerToSequence( aProperties
);
87 } // anonymous namespace
92 BubbleChartType::BubbleChartType(
93 const uno::Reference
< uno::XComponentContext
> & xContext
)
94 : ChartType( xContext
)
98 BubbleChartType::BubbleChartType( const BubbleChartType
& rOther
) :
103 BubbleChartType::~BubbleChartType()
106 // ____ XCloneable ____
107 uno::Reference
< util::XCloneable
> SAL_CALL
BubbleChartType::createClone()
108 throw (uno::RuntimeException
)
110 return uno::Reference
< util::XCloneable
>( new BubbleChartType( *this ));
113 // ____ XChartType ____
114 Reference
< chart2::XCoordinateSystem
> SAL_CALL
115 BubbleChartType::createCoordinateSystem( ::sal_Int32 DimensionCount
)
116 throw (lang::IllegalArgumentException
,
117 uno::RuntimeException
)
119 Reference
< chart2::XCoordinateSystem
> xResult(
120 new CartesianCoordinateSystem(
121 GetComponentContext(), DimensionCount
, /* bSwapXAndYAxis */ sal_False
));
123 for( sal_Int32 i
=0; i
<DimensionCount
; ++i
)
125 Reference
< chart2::XAxis
> xAxis( xResult
->getAxisByDimension( i
, MAIN_AXIS_INDEX
) );
128 OSL_ENSURE(false,"a created coordinate system should have an axis for each dimension");
132 chart2::ScaleData aScaleData
= xAxis
->getScaleData();
133 aScaleData
.Orientation
= chart2::AxisOrientation_MATHEMATICAL
;
134 aScaleData
.Scaling
= AxisHelper::createLinearScaling();
137 aScaleData
.AxisType
= chart2::AxisType::SERIES
;
139 aScaleData
.AxisType
= chart2::AxisType::REALNUMBER
;
141 xAxis
->setScaleData( aScaleData
);
147 ::rtl::OUString SAL_CALL
BubbleChartType::getChartType()
148 throw (uno::RuntimeException
)
150 return CHART2_SERVICE_NAME_CHARTTYPE_BUBBLE
;
153 uno::Sequence
< ::rtl::OUString
> SAL_CALL
BubbleChartType::getSupportedMandatoryRoles()
154 throw (uno::RuntimeException
)
156 static uno::Sequence
< ::rtl::OUString
> aMandRolesSeq
;
158 if( aMandRolesSeq
.getLength() == 0 )
160 aMandRolesSeq
.realloc( 4 );
161 aMandRolesSeq
[0] = C2U( "label" );
162 aMandRolesSeq
[1] = C2U( "values-x" );
163 aMandRolesSeq
[2] = C2U( "values-y" );
164 aMandRolesSeq
[3] = C2U( "values-size" );
167 return aMandRolesSeq
;
170 OUString SAL_CALL
BubbleChartType::getRoleOfSequenceForSeriesLabel()
171 throw (uno::RuntimeException
)
173 return C2U( "values-size" );
176 // ____ OPropertySet ____
177 uno::Any
BubbleChartType::GetDefaultValue( sal_Int32 nHandle
) const
178 throw(beans::UnknownPropertyException
)
180 static tPropertyValueMap aStaticDefaults
;
183 ::osl::MutexGuard
aGuard( ::osl::Mutex::getGlobalMutex() );
184 if( 0 == aStaticDefaults
.size() )
186 // initialize defaults
187 lcl_AddDefaultsToMap( aStaticDefaults
);
190 tPropertyValueMap::const_iterator
aFound(
191 aStaticDefaults
.find( nHandle
));
193 if( aFound
== aStaticDefaults
.end())
196 return (*aFound
).second
;
200 // ____ OPropertySet ____
201 ::cppu::IPropertyArrayHelper
& SAL_CALL
BubbleChartType::getInfoHelper()
203 static ::cppu::OPropertyArrayHelper
aArrayHelper( lcl_GetPropertySequence(),
204 /* bSorted = */ sal_True
);
210 // ____ XPropertySet ____
211 uno::Reference
< beans::XPropertySetInfo
> SAL_CALL
212 BubbleChartType::getPropertySetInfo()
213 throw (uno::RuntimeException
)
215 static uno::Reference
< beans::XPropertySetInfo
> xInfo
;
218 ::osl::MutexGuard
aGuard( ::osl::Mutex::getGlobalMutex() );
221 xInfo
= ::cppu::OPropertySetHelper::createPropertySetInfo(
229 uno::Sequence
< ::rtl::OUString
> BubbleChartType::getSupportedServiceNames_Static()
231 uno::Sequence
< ::rtl::OUString
> aServices( 3 );
232 aServices
[ 0 ] = CHART2_SERVICE_NAME_CHARTTYPE_BUBBLE
;
233 aServices
[ 1 ] = C2U( "com.sun.star.chart2.ChartType" );
234 aServices
[ 2 ] = C2U( "com.sun.star.beans.PropertySet" );
238 // implement XServiceInfo methods basing upon getSupportedServiceNames_Static
239 APPHELPER_XSERVICEINFO_IMPL( BubbleChartType
,
240 C2U( "com.sun.star.comp.chart.BubbleChartType" ));