merged tag ooo/OOO330_m14
[LibreOffice.git] / chart2 / source / model / template / NetChartType.cxx
blobddf001b2a6e4961a6e31e19f91b60ccb409dc2d8
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_chart2.hxx"
30 #include "NetChartType.hxx"
31 #include "PropertyHelper.hxx"
32 #include "macros.hxx"
33 #include "PolarCoordinateSystem.hxx"
34 #include "servicenames_charttypes.hxx"
35 #include "ContainerHelper.hxx"
36 #include "AxisIndexDefines.hxx"
37 #include "AxisHelper.hxx"
39 #include <com/sun/star/beans/PropertyAttribute.hpp>
40 #include <com/sun/star/chart2/AxisType.hpp>
42 using namespace ::com::sun::star;
43 using namespace ::com::sun::star::chart2;
45 using ::rtl::OUString;
46 using ::com::sun::star::beans::Property;
47 using ::com::sun::star::uno::Sequence;
48 using ::com::sun::star::uno::Reference;
49 using ::com::sun::star::uno::Any;
50 using ::osl::MutexGuard;
52 namespace chart
55 NetChartType_Base::NetChartType_Base(
56 const uno::Reference< uno::XComponentContext > & xContext ) :
57 ChartType( xContext )
60 NetChartType_Base::NetChartType_Base( const NetChartType_Base & rOther ) :
61 ChartType( rOther )
65 NetChartType_Base::~NetChartType_Base()
68 Reference< XCoordinateSystem > SAL_CALL
69 NetChartType_Base::createCoordinateSystem( ::sal_Int32 DimensionCount )
70 throw (lang::IllegalArgumentException,
71 uno::RuntimeException)
73 if( DimensionCount != 2 )
74 throw lang::IllegalArgumentException(
75 C2U( "NetChart must be two-dimensional" ),
76 static_cast< ::cppu::OWeakObject* >( this ), 0 );
78 Reference< XCoordinateSystem > xResult(
79 new PolarCoordinateSystem(
80 GetComponentContext(), DimensionCount, /* bSwapXAndYAxis */ sal_False ));
82 Reference< XAxis > xAxis( xResult->getAxisByDimension( 0, MAIN_AXIS_INDEX ) );
83 if( xAxis.is() )
85 ScaleData aScaleData = xAxis->getScaleData();
86 aScaleData.Scaling = AxisHelper::createLinearScaling();
87 aScaleData.AxisType = AxisType::CATEGORY;
88 aScaleData.Orientation = AxisOrientation_MATHEMATICAL;
89 xAxis->setScaleData( aScaleData );
92 xAxis = xResult->getAxisByDimension( 1, MAIN_AXIS_INDEX );
93 if( xAxis.is() )
95 ScaleData aScaleData = xAxis->getScaleData();
96 aScaleData.Orientation = AxisOrientation_MATHEMATICAL;
97 aScaleData.AxisType = AxisType::REALNUMBER;
98 xAxis->setScaleData( aScaleData );
101 return xResult;
104 // ____ OPropertySet ____
105 uno::Any NetChartType_Base::GetDefaultValue( sal_Int32 /*nHandle*/ ) const
106 throw(beans::UnknownPropertyException)
108 return uno::Any();
111 // ____ OPropertySet ____
112 ::cppu::IPropertyArrayHelper & SAL_CALL NetChartType_Base::getInfoHelper()
114 uno::Sequence< beans::Property > aProps;
115 static ::cppu::OPropertyArrayHelper aArrayHelper(aProps);
116 return aArrayHelper;
119 // ____ XPropertySet ____
120 uno::Reference< beans::XPropertySetInfo > SAL_CALL
121 NetChartType_Base::getPropertySetInfo()
122 throw (uno::RuntimeException)
124 static uno::Reference< beans::XPropertySetInfo > xInfo;
126 // /--
127 ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
128 if( !xInfo.is())
130 xInfo = ::cppu::OPropertySetHelper::createPropertySetInfo(
131 getInfoHelper());
134 return xInfo;
135 // \--
138 //-----------------------------------------------------------------------------
140 NetChartType::NetChartType(
141 const uno::Reference< uno::XComponentContext > & xContext ) :
142 NetChartType_Base( xContext )
145 NetChartType::NetChartType( const NetChartType & rOther ) :
146 NetChartType_Base( rOther )
150 NetChartType::~NetChartType()
153 // ____ XCloneable ____
154 uno::Reference< util::XCloneable > SAL_CALL NetChartType::createClone()
155 throw (uno::RuntimeException)
157 return uno::Reference< util::XCloneable >( new NetChartType( *this ));
160 // ____ XChartType ____
161 ::rtl::OUString SAL_CALL NetChartType::getChartType()
162 throw (uno::RuntimeException)
164 return CHART2_SERVICE_NAME_CHARTTYPE_NET;
167 uno::Sequence< ::rtl::OUString > NetChartType::getSupportedServiceNames_Static()
169 uno::Sequence< ::rtl::OUString > aServices( 3 );
170 aServices[ 0 ] = CHART2_SERVICE_NAME_CHARTTYPE_NET;
171 aServices[ 1 ] = C2U( "com.sun.star.chart2.ChartType" );
172 aServices[ 2 ] = C2U( "com.sun.star.beans.PropertySet" );
173 return aServices;
176 // implement XServiceInfo methods basing upon getSupportedServiceNames_Static
177 APPHELPER_XSERVICEINFO_IMPL( NetChartType,
178 C2U( "com.sun.star.comp.chart.NetChartType" ));
180 } // namespace chart