cid#1607171 Data race condition
[LibreOffice.git] / chart2 / source / model / template / NetChartType.cxx
blobb1bed1b605ca94c811032cd93d4bc9acf65de855
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 "NetChartType.hxx"
21 #include <PolarCoordinateSystem.hxx>
22 #include <servicenames_charttypes.hxx>
23 #include <AxisIndexDefines.hxx>
24 #include <AxisHelper.hxx>
25 #include <Axis.hxx>
27 #include <cppuhelper/supportsservice.hxx>
28 #include <com/sun/star/chart2/AxisType.hpp>
30 using namespace ::com::sun::star;
31 using namespace ::com::sun::star::chart2;
33 using ::com::sun::star::beans::Property;
34 using ::com::sun::star::uno::Sequence;
35 using ::com::sun::star::uno::Reference;
37 namespace chart
40 NetChartType_Base::NetChartType_Base()
43 NetChartType_Base::NetChartType_Base( const NetChartType_Base & rOther ) :
44 ChartType( rOther )
48 NetChartType_Base::~NetChartType_Base()
51 rtl::Reference< ::chart::BaseCoordinateSystem >
52 NetChartType_Base::createCoordinateSystem2( sal_Int32 DimensionCount )
54 if( DimensionCount != 2 )
55 throw lang::IllegalArgumentException(
56 u"NetChart must be two-dimensional"_ustr,
57 static_cast< ::cppu::OWeakObject* >( this ), 0 );
59 rtl::Reference< PolarCoordinateSystem > xResult =
60 new PolarCoordinateSystem( DimensionCount );
62 rtl::Reference< Axis > xAxis = xResult->getAxisByDimension2( 0, MAIN_AXIS_INDEX );
63 if( xAxis.is() )
65 ScaleData aScaleData = xAxis->getScaleData();
66 aScaleData.Scaling = AxisHelper::createLinearScaling();
67 aScaleData.AxisType = AxisType::CATEGORY;
68 aScaleData.Orientation = AxisOrientation_MATHEMATICAL;
69 xAxis->setScaleData( aScaleData );
72 xAxis = xResult->getAxisByDimension2( 1, MAIN_AXIS_INDEX );
73 if( xAxis.is() )
75 ScaleData aScaleData = xAxis->getScaleData();
76 aScaleData.Orientation = AxisOrientation_MATHEMATICAL;
77 aScaleData.AxisType = AxisType::REALNUMBER;
78 xAxis->setScaleData( aScaleData );
81 return xResult;
84 // ____ OPropertySet ____
85 void NetChartType_Base::GetDefaultValue( sal_Int32 /*nHandle*/, uno::Any& rAny ) const
87 rAny.clear();
90 namespace
93 ::cppu::OPropertyArrayHelper& StaticNetChartTypeInfoHelper()
95 static ::cppu::OPropertyArrayHelper aPropHelper(Sequence< beans::Property >{});
96 return aPropHelper;
99 uno::Reference< beans::XPropertySetInfo >& StaticNetChartTypeInfo()
101 static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
102 ::cppu::OPropertySetHelper::createPropertySetInfo(StaticNetChartTypeInfoHelper() ) );
103 return xPropertySetInfo;
108 // ____ OPropertySet ____
109 ::cppu::IPropertyArrayHelper & SAL_CALL NetChartType_Base::getInfoHelper()
111 return StaticNetChartTypeInfoHelper();
114 // ____ XPropertySet ____
115 uno::Reference< beans::XPropertySetInfo > SAL_CALL NetChartType_Base::getPropertySetInfo()
117 return StaticNetChartTypeInfo();
120 NetChartType::NetChartType()
123 NetChartType::NetChartType( const NetChartType & rOther ) :
124 NetChartType_Base( rOther )
128 NetChartType::~NetChartType()
131 // ____ XCloneable ____
132 uno::Reference< util::XCloneable > SAL_CALL NetChartType::createClone()
134 return uno::Reference< util::XCloneable >( new NetChartType( *this ));
137 rtl::Reference< ChartType > NetChartType::cloneChartType() const
139 return new NetChartType( *this );
142 // ____ XChartType ____
143 OUString SAL_CALL NetChartType::getChartType()
145 return CHART2_SERVICE_NAME_CHARTTYPE_NET;
148 OUString SAL_CALL NetChartType::getImplementationName()
150 return u"com.sun.star.comp.chart.NetChartType"_ustr;
153 sal_Bool SAL_CALL NetChartType::supportsService( const OUString& rServiceName )
155 return cppu::supportsService(this, rServiceName);
158 css::uno::Sequence< OUString > SAL_CALL NetChartType::getSupportedServiceNames()
160 return {
161 CHART2_SERVICE_NAME_CHARTTYPE_NET,
162 u"com.sun.star.chart2.ChartType"_ustr,
163 u"com.sun.star.beans.PropertySet"_ustr };
166 } // namespace chart
168 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
169 com_sun_star_comp_chart_NetChartType_get_implementation(css::uno::XComponentContext * /*context*/,
170 css::uno::Sequence<css::uno::Any> const &)
172 return cppu::acquire(new ::chart::NetChartType);
175 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */