1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20 #include "BubbleChartType.hxx"
21 #include <PropertyHelper.hxx>
22 #include <servicenames_charttypes.hxx>
23 #include <CartesianCoordinateSystem.hxx>
24 #include <AxisHelper.hxx>
25 #include <AxisIndexDefines.hxx>
26 #include <com/sun/star/chart2/AxisType.hpp>
27 #include <cppuhelper/supportsservice.hxx>
28
29 using namespace ::com::sun::star;
30
31 using ::com::sun::star::beans::Property;
32 using ::com::sun::star::uno::Sequence;
33 using ::com::sun::star::uno::Reference;
34
35 namespace
36 {
37
38 struct StaticBubbleChartTypeDefaults_Initializer
39 {
operator ()__anon423699e40111::StaticBubbleChartTypeDefaults_Initializer40 ::chart::tPropertyValueMap* operator()()
41 {
42 static ::chart::tPropertyValueMap aStaticDefaults;
43 return &aStaticDefaults;
44 }
45 };
46
47 struct StaticBubbleChartTypeDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticBubbleChartTypeDefaults_Initializer >
48 {
49 };
50
51 struct StaticBubbleChartTypeInfoHelper_Initializer
52 {
operator ()__anon423699e40111::StaticBubbleChartTypeInfoHelper_Initializer53 ::cppu::OPropertyArrayHelper* operator()()
54 {
55 static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() );
56 return &aPropHelper;
57 }
58
59 private:
lcl_GetPropertySequence__anon423699e40111::StaticBubbleChartTypeInfoHelper_Initializer60 static Sequence< Property > lcl_GetPropertySequence()
61 {
62 std::vector< css::beans::Property > aProperties;
63
64 std::sort( aProperties.begin(), aProperties.end(),
65 ::chart::PropertyNameLess() );
66
67 return comphelper::containerToSequence( aProperties );
68 }
69 };
70
71 struct StaticBubbleChartTypeInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticBubbleChartTypeInfoHelper_Initializer >
72 {
73 };
74
75 struct StaticBubbleChartTypeInfo_Initializer
76 {
operator ()__anon423699e40111::StaticBubbleChartTypeInfo_Initializer77 uno::Reference< beans::XPropertySetInfo >* operator()()
78 {
79 static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
80 ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticBubbleChartTypeInfoHelper::get() ) );
81 return &xPropertySetInfo;
82 }
83 };
84
85 struct StaticBubbleChartTypeInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticBubbleChartTypeInfo_Initializer >
86 {
87 };
88
89 } // anonymous namespace
90
91 namespace chart
92 {
93
BubbleChartType()94 BubbleChartType::BubbleChartType()
95 {
96 }
97
BubbleChartType(const BubbleChartType & rOther)98 BubbleChartType::BubbleChartType( const BubbleChartType & rOther ) :
99 ChartType( rOther )
100 {
101 }
102
~BubbleChartType()103 BubbleChartType::~BubbleChartType()
104 {}
105
106 // ____ XCloneable ____
createClone()107 uno::Reference< util::XCloneable > SAL_CALL BubbleChartType::createClone()
108 {
109 return uno::Reference< util::XCloneable >( new BubbleChartType( *this ));
110 }
111
112 // ____ XChartType ____
113 Reference< chart2::XCoordinateSystem > SAL_CALL
createCoordinateSystem(::sal_Int32 DimensionCount)114 BubbleChartType::createCoordinateSystem( ::sal_Int32 DimensionCount )
115 {
116 Reference< chart2::XCoordinateSystem > xResult(
117 new CartesianCoordinateSystem( DimensionCount ));
118
119 for( sal_Int32 i=0; i<DimensionCount; ++i )
120 {
121 Reference< chart2::XAxis > xAxis( xResult->getAxisByDimension( i, MAIN_AXIS_INDEX ) );
122 if( !xAxis.is() )
123 {
124 OSL_FAIL("a created coordinate system should have an axis for each dimension");
125 continue;
126 }
127
128 chart2::ScaleData aScaleData = xAxis->getScaleData();
129 aScaleData.Orientation = chart2::AxisOrientation_MATHEMATICAL;
130 aScaleData.Scaling = AxisHelper::createLinearScaling();
131
132 if( i == 2 )
133 aScaleData.AxisType = chart2::AxisType::SERIES;
134 else
135 aScaleData.AxisType = chart2::AxisType::REALNUMBER;
136
137 xAxis->setScaleData( aScaleData );
138 }
139
140 return xResult;
141 }
142
getChartType()143 OUString SAL_CALL BubbleChartType::getChartType()
144 {
145 return CHART2_SERVICE_NAME_CHARTTYPE_BUBBLE;
146 }
147
getSupportedMandatoryRoles()148 uno::Sequence< OUString > SAL_CALL BubbleChartType::getSupportedMandatoryRoles()
149 {
150 uno::Sequence< OUString > aMandRolesSeq(4);
151 aMandRolesSeq[0] = "label";
152 aMandRolesSeq[1] = "values-x";
153 aMandRolesSeq[2] = "values-y";
154 aMandRolesSeq[3] = "values-size";
155 return aMandRolesSeq;
156 }
157
getSupportedPropertyRoles()158 uno::Sequence< OUString > SAL_CALL BubbleChartType::getSupportedPropertyRoles()
159 {
160 uno::Sequence< OUString > aPropertyRoles(2);
161 aPropertyRoles[0] = "FillColor";
162 aPropertyRoles[1] = "BorderColor";
163 return aPropertyRoles;
164 }
165
getRoleOfSequenceForSeriesLabel()166 OUString SAL_CALL BubbleChartType::getRoleOfSequenceForSeriesLabel()
167 {
168 return "values-size";
169 }
170
171 // ____ OPropertySet ____
GetDefaultValue(sal_Int32 nHandle) const172 uno::Any BubbleChartType::GetDefaultValue( sal_Int32 nHandle ) const
173 {
174 const tPropertyValueMap& rStaticDefaults = *StaticBubbleChartTypeDefaults::get();
175 tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
176 if( aFound == rStaticDefaults.end() )
177 return uno::Any();
178 return (*aFound).second;
179 }
180
181 // ____ OPropertySet ____
getInfoHelper()182 ::cppu::IPropertyArrayHelper & SAL_CALL BubbleChartType::getInfoHelper()
183 {
184 return *StaticBubbleChartTypeInfoHelper::get();
185 }
186
187 // ____ XPropertySet ____
getPropertySetInfo()188 uno::Reference< beans::XPropertySetInfo > SAL_CALL BubbleChartType::getPropertySetInfo()
189 {
190 return *StaticBubbleChartTypeInfo::get();
191 }
192
getImplementationName()193 OUString SAL_CALL BubbleChartType::getImplementationName()
194 {
195 return "com.sun.star.comp.chart.BubbleChartType";
196 }
197
supportsService(const OUString & rServiceName)198 sal_Bool SAL_CALL BubbleChartType::supportsService( const OUString& rServiceName )
199 {
200 return cppu::supportsService(this, rServiceName);
201 }
202
getSupportedServiceNames()203 css::uno::Sequence< OUString > SAL_CALL BubbleChartType::getSupportedServiceNames()
204 {
205 return {
206 CHART2_SERVICE_NAME_CHARTTYPE_BUBBLE,
207 "com.sun.star.chart2.ChartType",
208 "com.sun.star.beans.PropertySet" };
209 }
210
211 } // namespace chart
212
213 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
com_sun_star_comp_chart_BubbleChartType_get_implementation(css::uno::XComponentContext *,css::uno::Sequence<css::uno::Any> const &)214 com_sun_star_comp_chart_BubbleChartType_get_implementation(css::uno::XComponentContext * /*context*/,
215 css::uno::Sequence<css::uno::Any> const &)
216 {
217 return cppu::acquire(new ::chart::BubbleChartType);
218 }
219
220 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
221