fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / chart2 / source / model / template / BubbleChartType.cxx
blob4b494b7943bc31c8b5dc64557fd2806b94ac8ecf
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "BubbleChartType.hxx"
21 #include "PropertyHelper.hxx"
22 #include "macros.hxx"
23 #include "servicenames_charttypes.hxx"
24 #include "ContainerHelper.hxx"
25 #include "CartesianCoordinateSystem.hxx"
26 #include "AxisHelper.hxx"
27 #include "AxisIndexDefines.hxx"
28 #include <com/sun/star/beans/PropertyAttribute.hpp>
29 #include <com/sun/star/chart2/AxisType.hpp>
30 #include <com/sun/star/chart2/CurveStyle.hpp>
31 #include <cppuhelper/supportsservice.hxx>
33 using namespace ::com::sun::star;
35 using ::com::sun::star::beans::Property;
36 using ::com::sun::star::uno::Sequence;
37 using ::com::sun::star::uno::Reference;
38 using ::com::sun::star::uno::Any;
39 using ::osl::MutexGuard;
41 namespace
44 struct StaticBubbleChartTypeDefaults_Initializer
46 ::chart::tPropertyValueMap* operator()()
48 static ::chart::tPropertyValueMap aStaticDefaults;
49 return &aStaticDefaults;
53 struct StaticBubbleChartTypeDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticBubbleChartTypeDefaults_Initializer >
57 struct StaticBubbleChartTypeInfoHelper_Initializer
59 ::cppu::OPropertyArrayHelper* operator()()
61 static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() );
62 return &aPropHelper;
65 private:
66 static Sequence< Property > lcl_GetPropertySequence()
68 ::std::vector< ::com::sun::star::beans::Property > aProperties;
70 ::std::sort( aProperties.begin(), aProperties.end(),
71 ::chart::PropertyNameLess() );
73 return ::chart::ContainerHelper::ContainerToSequence( aProperties );
77 struct StaticBubbleChartTypeInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticBubbleChartTypeInfoHelper_Initializer >
81 struct StaticBubbleChartTypeInfo_Initializer
83 uno::Reference< beans::XPropertySetInfo >* operator()()
85 static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
86 ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticBubbleChartTypeInfoHelper::get() ) );
87 return &xPropertySetInfo;
91 struct StaticBubbleChartTypeInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticBubbleChartTypeInfo_Initializer >
95 } // anonymous namespace
97 namespace chart
100 BubbleChartType::BubbleChartType(
101 const uno::Reference< uno::XComponentContext > & xContext )
102 : ChartType( xContext )
106 BubbleChartType::BubbleChartType( const BubbleChartType & rOther ) :
107 ChartType( rOther )
111 BubbleChartType::~BubbleChartType()
114 // ____ XCloneable ____
115 uno::Reference< util::XCloneable > SAL_CALL BubbleChartType::createClone()
116 throw (uno::RuntimeException, std::exception)
118 return uno::Reference< util::XCloneable >( new BubbleChartType( *this ));
121 // ____ XChartType ____
122 Reference< chart2::XCoordinateSystem > SAL_CALL
123 BubbleChartType::createCoordinateSystem( ::sal_Int32 DimensionCount )
124 throw (lang::IllegalArgumentException,
125 uno::RuntimeException, std::exception)
127 Reference< chart2::XCoordinateSystem > xResult(
128 new CartesianCoordinateSystem(
129 GetComponentContext(), DimensionCount, /* bSwapXAndYAxis */ false ));
131 for( sal_Int32 i=0; i<DimensionCount; ++i )
133 Reference< chart2::XAxis > xAxis( xResult->getAxisByDimension( i, MAIN_AXIS_INDEX ) );
134 if( !xAxis.is() )
136 OSL_FAIL("a created coordinate system should have an axis for each dimension");
137 continue;
140 chart2::ScaleData aScaleData = xAxis->getScaleData();
141 aScaleData.Orientation = chart2::AxisOrientation_MATHEMATICAL;
142 aScaleData.Scaling = AxisHelper::createLinearScaling();
144 if( i == 2 )
145 aScaleData.AxisType = chart2::AxisType::SERIES;
146 else
147 aScaleData.AxisType = chart2::AxisType::REALNUMBER;
149 xAxis->setScaleData( aScaleData );
152 return xResult;
155 OUString SAL_CALL BubbleChartType::getChartType()
156 throw (uno::RuntimeException, std::exception)
158 return OUString(CHART2_SERVICE_NAME_CHARTTYPE_BUBBLE);
161 uno::Sequence< OUString > SAL_CALL BubbleChartType::getSupportedMandatoryRoles()
162 throw (uno::RuntimeException, std::exception)
164 uno::Sequence< OUString > aMandRolesSeq(4);
165 aMandRolesSeq[0] = "label";
166 aMandRolesSeq[1] = "values-x";
167 aMandRolesSeq[2] = "values-y";
168 aMandRolesSeq[3] = "values-size";
169 return aMandRolesSeq;
172 uno::Sequence< OUString > SAL_CALL BubbleChartType::getSupportedPropertyRoles()
173 throw(com::sun::star::uno::RuntimeException, std::exception)
175 uno::Sequence< OUString > aPropertyRoles(2);
176 aPropertyRoles[0] = "FillColor";
177 aPropertyRoles[1] = "BorderColor";
178 return aPropertyRoles;
181 OUString SAL_CALL BubbleChartType::getRoleOfSequenceForSeriesLabel()
182 throw (uno::RuntimeException, std::exception)
184 return OUString("values-size");
187 // ____ OPropertySet ____
188 uno::Any BubbleChartType::GetDefaultValue( sal_Int32 nHandle ) const
189 throw(beans::UnknownPropertyException)
191 const tPropertyValueMap& rStaticDefaults = *StaticBubbleChartTypeDefaults::get();
192 tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
193 if( aFound == rStaticDefaults.end() )
194 return uno::Any();
195 return (*aFound).second;
198 // ____ OPropertySet ____
199 ::cppu::IPropertyArrayHelper & SAL_CALL BubbleChartType::getInfoHelper()
201 return *StaticBubbleChartTypeInfoHelper::get();
204 // ____ XPropertySet ____
205 uno::Reference< beans::XPropertySetInfo > SAL_CALL BubbleChartType::getPropertySetInfo()
206 throw (uno::RuntimeException, std::exception)
208 return *StaticBubbleChartTypeInfo::get();
211 uno::Sequence< OUString > BubbleChartType::getSupportedServiceNames_Static()
213 uno::Sequence< OUString > aServices( 3 );
214 aServices[ 0 ] = CHART2_SERVICE_NAME_CHARTTYPE_BUBBLE;
215 aServices[ 1 ] = "com.sun.star.chart2.ChartType";
216 aServices[ 2 ] = "com.sun.star.beans.PropertySet";
217 return aServices;
220 // implement XServiceInfo methods basing upon getSupportedServiceNames_Static
221 OUString SAL_CALL BubbleChartType::getImplementationName()
222 throw( css::uno::RuntimeException, std::exception )
224 return getImplementationName_Static();
227 OUString BubbleChartType::getImplementationName_Static()
229 return OUString("com.sun.star.comp.chart.BubbleChartType");
232 sal_Bool SAL_CALL BubbleChartType::supportsService( const OUString& rServiceName )
233 throw( css::uno::RuntimeException, std::exception )
235 return cppu::supportsService(this, rServiceName);
238 css::uno::Sequence< OUString > SAL_CALL BubbleChartType::getSupportedServiceNames()
239 throw( css::uno::RuntimeException, std::exception )
241 return getSupportedServiceNames_Static();
244 } // namespace chart
246 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
247 com_sun_star_comp_chart_BubbleChartType_get_implementation(css::uno::XComponentContext *context,
248 css::uno::Sequence<css::uno::Any> const &)
250 return cppu::acquire(new ::chart::BubbleChartType(context));
253 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */