1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_chart2.hxx"
26 #include "BubbleChartType.hxx"
27 #include "PropertyHelper.hxx"
28 #include "macros.hxx"
29 #include "servicenames_charttypes.hxx"
30 #include "ContainerHelper.hxx"
31 #include "CartesianCoordinateSystem.hxx"
32 #include "AxisHelper.hxx"
33 #include "AxisIndexDefines.hxx"
34 #include <com/sun/star/beans/PropertyAttribute.hpp>
35 #include <com/sun/star/chart2/AxisType.hpp>
36 #include <com/sun/star/chart2/CurveStyle.hpp>
37
38 using namespace ::com::sun::star;
39
40 using ::rtl::OUString;
41 using ::com::sun::star::beans::Property;
42 using ::com::sun::star::uno::Sequence;
43 using ::com::sun::star::uno::Reference;
44 using ::com::sun::star::uno::Any;
45 using ::osl::MutexGuard;
46
47 namespace
48 {
49
lcl_AddPropertiesToVector(::std::vector<Property> &)50 void lcl_AddPropertiesToVector(
51 ::std::vector< Property > & /*rOutProperties*/ )
52 {
53 }
54
55 struct StaticBubbleChartTypeDefaults_Initializer
56 {
operator ()__anon587c20fe0111::StaticBubbleChartTypeDefaults_Initializer57 ::chart::tPropertyValueMap* operator()()
58 {
59 static ::chart::tPropertyValueMap aStaticDefaults;
60 lcl_AddDefaultsToMap( aStaticDefaults );
61 return &aStaticDefaults;
62 }
63 private:
lcl_AddDefaultsToMap__anon587c20fe0111::StaticBubbleChartTypeDefaults_Initializer64 void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & /*rOutMap*/ )
65 {
66 }
67 };
68
69 struct StaticBubbleChartTypeDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticBubbleChartTypeDefaults_Initializer >
70 {
71 };
72
73 struct StaticBubbleChartTypeInfoHelper_Initializer
74 {
operator ()__anon587c20fe0111::StaticBubbleChartTypeInfoHelper_Initializer75 ::cppu::OPropertyArrayHelper* operator()()
76 {
77 static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() );
78 return &aPropHelper;
79 }
80
81 private:
lcl_GetPropertySequence__anon587c20fe0111::StaticBubbleChartTypeInfoHelper_Initializer82 Sequence< Property > lcl_GetPropertySequence()
83 {
84 ::std::vector< ::com::sun::star::beans::Property > aProperties;
85 lcl_AddPropertiesToVector( aProperties );
86
87 ::std::sort( aProperties.begin(), aProperties.end(),
88 ::chart::PropertyNameLess() );
89
90 return ::chart::ContainerHelper::ContainerToSequence( aProperties );
91 }
92 };
93
94 struct StaticBubbleChartTypeInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticBubbleChartTypeInfoHelper_Initializer >
95 {
96 };
97
98 struct StaticBubbleChartTypeInfo_Initializer
99 {
operator ()__anon587c20fe0111::StaticBubbleChartTypeInfo_Initializer100 uno::Reference< beans::XPropertySetInfo >* operator()()
101 {
102 static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
103 ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticBubbleChartTypeInfoHelper::get() ) );
104 return &xPropertySetInfo;
105 }
106 };
107
108 struct StaticBubbleChartTypeInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticBubbleChartTypeInfo_Initializer >
109 {
110 };
111
112 } // anonymous namespace
113
114 namespace chart
115 {
116
BubbleChartType(const uno::Reference<uno::XComponentContext> & xContext)117 BubbleChartType::BubbleChartType(
118 const uno::Reference< uno::XComponentContext > & xContext )
119 : ChartType( xContext )
120 {
121 }
122
BubbleChartType(const BubbleChartType & rOther)123 BubbleChartType::BubbleChartType( const BubbleChartType & rOther ) :
124 ChartType( rOther )
125 {
126 }
127
~BubbleChartType()128 BubbleChartType::~BubbleChartType()
129 {}
130
131 // ____ XCloneable ____
createClone()132 uno::Reference< util::XCloneable > SAL_CALL BubbleChartType::createClone()
133 throw (uno::RuntimeException)
134 {
135 return uno::Reference< util::XCloneable >( new BubbleChartType( *this ));
136 }
137
138 // ____ XChartType ____
139 Reference< chart2::XCoordinateSystem > SAL_CALL
createCoordinateSystem(::sal_Int32 DimensionCount)140 BubbleChartType::createCoordinateSystem( ::sal_Int32 DimensionCount )
141 throw (lang::IllegalArgumentException,
142 uno::RuntimeException)
143 {
144 Reference< chart2::XCoordinateSystem > xResult(
145 new CartesianCoordinateSystem(
146 GetComponentContext(), DimensionCount, /* bSwapXAndYAxis */ sal_False ));
147
148 for( sal_Int32 i=0; i<DimensionCount; ++i )
149 {
150 Reference< chart2::XAxis > xAxis( xResult->getAxisByDimension( i, MAIN_AXIS_INDEX ) );
151 if( !xAxis.is() )
152 {
153 OSL_ENSURE(false,"a created coordinate system should have an axis for each dimension");
154 continue;
155 }
156
157 chart2::ScaleData aScaleData = xAxis->getScaleData();
158 aScaleData.Orientation = chart2::AxisOrientation_MATHEMATICAL;
159 aScaleData.Scaling = AxisHelper::createLinearScaling();
160
161 if( i == 2 )
162 aScaleData.AxisType = chart2::AxisType::SERIES;
163 else
164 aScaleData.AxisType = chart2::AxisType::REALNUMBER;
165
166 xAxis->setScaleData( aScaleData );
167 }
168
169 return xResult;
170 }
171
getChartType()172 ::rtl::OUString SAL_CALL BubbleChartType::getChartType()
173 throw (uno::RuntimeException)
174 {
175 return CHART2_SERVICE_NAME_CHARTTYPE_BUBBLE;
176 }
177
getSupportedMandatoryRoles()178 uno::Sequence< ::rtl::OUString > SAL_CALL BubbleChartType::getSupportedMandatoryRoles()
179 throw (uno::RuntimeException)
180 {
181 static uno::Sequence< ::rtl::OUString > aMandRolesSeq;
182
183 if( aMandRolesSeq.getLength() == 0 )
184 {
185 aMandRolesSeq.realloc( 4 );
186 aMandRolesSeq[0] = C2U( "label" );
187 aMandRolesSeq[1] = C2U( "values-x" );
188 aMandRolesSeq[2] = C2U( "values-y" );
189 aMandRolesSeq[3] = C2U( "values-size" );
190 }
191
192 return aMandRolesSeq;
193 }
194
getRoleOfSequenceForSeriesLabel()195 OUString SAL_CALL BubbleChartType::getRoleOfSequenceForSeriesLabel()
196 throw (uno::RuntimeException)
197 {
198 return C2U( "values-size" );
199 }
200
201 // ____ OPropertySet ____
GetDefaultValue(sal_Int32 nHandle) const202 uno::Any BubbleChartType::GetDefaultValue( sal_Int32 nHandle ) const
203 throw(beans::UnknownPropertyException)
204 {
205 const tPropertyValueMap& rStaticDefaults = *StaticBubbleChartTypeDefaults::get();
206 tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
207 if( aFound == rStaticDefaults.end() )
208 return uno::Any();
209 return (*aFound).second;
210 }
211
212 // ____ OPropertySet ____
getInfoHelper()213 ::cppu::IPropertyArrayHelper & SAL_CALL BubbleChartType::getInfoHelper()
214 {
215 return *StaticBubbleChartTypeInfoHelper::get();
216 }
217
218 // ____ XPropertySet ____
getPropertySetInfo()219 uno::Reference< beans::XPropertySetInfo > SAL_CALL BubbleChartType::getPropertySetInfo()
220 throw (uno::RuntimeException)
221 {
222 return *StaticBubbleChartTypeInfo::get();
223 }
224
getSupportedServiceNames_Static()225 uno::Sequence< ::rtl::OUString > BubbleChartType::getSupportedServiceNames_Static()
226 {
227 uno::Sequence< ::rtl::OUString > aServices( 3 );
228 aServices[ 0 ] = CHART2_SERVICE_NAME_CHARTTYPE_BUBBLE;
229 aServices[ 1 ] = C2U( "com.sun.star.chart2.ChartType" );
230 aServices[ 2 ] = C2U( "com.sun.star.beans.PropertySet" );
231 return aServices;
232 }
233
234 // implement XServiceInfo methods basing upon getSupportedServiceNames_Static
235 APPHELPER_XSERVICEINFO_IMPL( BubbleChartType,
236 C2U( "com.sun.star.comp.chart.BubbleChartType" ));
237
238 } // namespace chart
239