fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / chart2 / source / model / template / NetChartType.cxx
blobfc745a6077a1b4419742a0e5f12a5eedd4a371fa
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 "PropertyHelper.hxx"
22 #include "macros.hxx"
23 #include "PolarCoordinateSystem.hxx"
24 #include "servicenames_charttypes.hxx"
25 #include "ContainerHelper.hxx"
26 #include "AxisIndexDefines.hxx"
27 #include "AxisHelper.hxx"
29 #include <cppuhelper/supportsservice.hxx>
30 #include <com/sun/star/beans/PropertyAttribute.hpp>
31 #include <com/sun/star/chart2/AxisType.hpp>
33 using namespace ::com::sun::star;
34 using namespace ::com::sun::star::chart2;
36 using ::com::sun::star::beans::Property;
37 using ::com::sun::star::uno::Sequence;
38 using ::com::sun::star::uno::Reference;
39 using ::com::sun::star::uno::Any;
40 using ::osl::MutexGuard;
42 namespace chart
45 NetChartType_Base::NetChartType_Base(
46 const uno::Reference< uno::XComponentContext > & xContext ) :
47 ChartType( xContext )
50 NetChartType_Base::NetChartType_Base( const NetChartType_Base & rOther ) :
51 ChartType( rOther )
55 NetChartType_Base::~NetChartType_Base()
58 Reference< XCoordinateSystem > SAL_CALL
59 NetChartType_Base::createCoordinateSystem( ::sal_Int32 DimensionCount )
60 throw (lang::IllegalArgumentException,
61 uno::RuntimeException, std::exception)
63 if( DimensionCount != 2 )
64 throw lang::IllegalArgumentException(
65 "NetChart must be two-dimensional",
66 static_cast< ::cppu::OWeakObject* >( this ), 0 );
68 Reference< XCoordinateSystem > xResult(
69 new PolarCoordinateSystem(
70 GetComponentContext(), DimensionCount, /* bSwapXAndYAxis */ false ));
72 Reference< XAxis > xAxis( xResult->getAxisByDimension( 0, MAIN_AXIS_INDEX ) );
73 if( xAxis.is() )
75 ScaleData aScaleData = xAxis->getScaleData();
76 aScaleData.Scaling = AxisHelper::createLinearScaling();
77 aScaleData.AxisType = AxisType::CATEGORY;
78 aScaleData.Orientation = AxisOrientation_MATHEMATICAL;
79 xAxis->setScaleData( aScaleData );
82 xAxis = xResult->getAxisByDimension( 1, MAIN_AXIS_INDEX );
83 if( xAxis.is() )
85 ScaleData aScaleData = xAxis->getScaleData();
86 aScaleData.Orientation = AxisOrientation_MATHEMATICAL;
87 aScaleData.AxisType = AxisType::REALNUMBER;
88 xAxis->setScaleData( aScaleData );
91 return xResult;
94 // ____ OPropertySet ____
95 uno::Any NetChartType_Base::GetDefaultValue( sal_Int32 /*nHandle*/ ) const
96 throw(beans::UnknownPropertyException)
98 return uno::Any();
101 namespace
104 struct StaticNetChartTypeInfoHelper_Initializer
106 ::cppu::OPropertyArrayHelper* operator()()
108 // using assignment for broken gcc 3.3
109 static ::cppu::OPropertyArrayHelper aPropHelper = ::cppu::OPropertyArrayHelper(
110 Sequence< beans::Property >() );
111 return &aPropHelper;
115 struct StaticNetChartTypeInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticNetChartTypeInfoHelper_Initializer >
119 struct StaticNetChartTypeInfo_Initializer
121 uno::Reference< beans::XPropertySetInfo >* operator()()
123 static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
124 ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticNetChartTypeInfoHelper::get() ) );
125 return &xPropertySetInfo;
129 struct StaticNetChartTypeInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticNetChartTypeInfo_Initializer >
135 // ____ OPropertySet ____
136 ::cppu::IPropertyArrayHelper & SAL_CALL NetChartType_Base::getInfoHelper()
138 return *StaticNetChartTypeInfoHelper::get();
141 // ____ XPropertySet ____
142 uno::Reference< beans::XPropertySetInfo > SAL_CALL NetChartType_Base::getPropertySetInfo()
143 throw (uno::RuntimeException, std::exception)
145 return *StaticNetChartTypeInfo::get();
148 NetChartType::NetChartType(
149 const uno::Reference< uno::XComponentContext > & xContext ) :
150 NetChartType_Base( xContext )
153 NetChartType::NetChartType( const NetChartType & rOther ) :
154 NetChartType_Base( rOther )
158 NetChartType::~NetChartType()
161 // ____ XCloneable ____
162 uno::Reference< util::XCloneable > SAL_CALL NetChartType::createClone()
163 throw (uno::RuntimeException, std::exception)
165 return uno::Reference< util::XCloneable >( new NetChartType( *this ));
168 // ____ XChartType ____
169 OUString SAL_CALL NetChartType::getChartType()
170 throw (uno::RuntimeException, std::exception)
172 return OUString(CHART2_SERVICE_NAME_CHARTTYPE_NET);
175 uno::Sequence< OUString > NetChartType::getSupportedServiceNames_Static()
177 uno::Sequence< OUString > aServices( 3 );
178 aServices[ 0 ] = CHART2_SERVICE_NAME_CHARTTYPE_NET;
179 aServices[ 1 ] = "com.sun.star.chart2.ChartType";
180 aServices[ 2 ] = "com.sun.star.beans.PropertySet";
181 return aServices;
184 // implement XServiceInfo methods basing upon getSupportedServiceNames_Static
185 OUString SAL_CALL NetChartType::getImplementationName()
186 throw( css::uno::RuntimeException, std::exception )
188 return getImplementationName_Static();
191 OUString NetChartType::getImplementationName_Static()
193 return OUString("com.sun.star.comp.chart.NetChartType");
196 sal_Bool SAL_CALL NetChartType::supportsService( const OUString& rServiceName )
197 throw( css::uno::RuntimeException, std::exception )
199 return cppu::supportsService(this, rServiceName);
202 css::uno::Sequence< OUString > SAL_CALL NetChartType::getSupportedServiceNames()
203 throw( css::uno::RuntimeException, std::exception )
205 return getSupportedServiceNames_Static();
208 } // namespace chart
210 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
211 com_sun_star_comp_chart_NetChartType_get_implementation(css::uno::XComponentContext *context,
212 css::uno::Sequence<css::uno::Any> const &)
214 return cppu::acquire(new ::chart::NetChartType(context));
217 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */