1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_chart2.hxx"
26 #include "NetChartType.hxx"
27 #include "PropertyHelper.hxx"
28 #include "macros.hxx"
29 #include "PolarCoordinateSystem.hxx"
30 #include "servicenames_charttypes.hxx"
31 #include "ContainerHelper.hxx"
32 #include "AxisIndexDefines.hxx"
33 #include "AxisHelper.hxx"
34 
35 #include <com/sun/star/beans/PropertyAttribute.hpp>
36 #include <com/sun/star/chart2/AxisType.hpp>
37 
38 using namespace ::com::sun::star;
39 using namespace ::com::sun::star::chart2;
40 
41 using ::rtl::OUString;
42 using ::com::sun::star::beans::Property;
43 using ::com::sun::star::uno::Sequence;
44 using ::com::sun::star::uno::Reference;
45 using ::com::sun::star::uno::Any;
46 using ::osl::MutexGuard;
47 
48 namespace chart
49 {
50 
NetChartType_Base(const uno::Reference<uno::XComponentContext> & xContext)51 NetChartType_Base::NetChartType_Base(
52     const uno::Reference< uno::XComponentContext > & xContext ) :
53         ChartType( xContext )
54 {}
55 
NetChartType_Base(const NetChartType_Base & rOther)56 NetChartType_Base::NetChartType_Base( const NetChartType_Base & rOther ) :
57         ChartType( rOther )
58 {
59 }
60 
~NetChartType_Base()61 NetChartType_Base::~NetChartType_Base()
62 {}
63 
64 Reference< XCoordinateSystem > SAL_CALL
createCoordinateSystem(::sal_Int32 DimensionCount)65     NetChartType_Base::createCoordinateSystem( ::sal_Int32 DimensionCount )
66     throw (lang::IllegalArgumentException,
67            uno::RuntimeException)
68 {
69     if( DimensionCount != 2 )
70         throw lang::IllegalArgumentException(
71             C2U( "NetChart must be two-dimensional" ),
72             static_cast< ::cppu::OWeakObject* >( this ), 0 );
73 
74     Reference< XCoordinateSystem > xResult(
75         new PolarCoordinateSystem(
76             GetComponentContext(), DimensionCount, /* bSwapXAndYAxis */ sal_False ));
77 
78     Reference< XAxis > xAxis( xResult->getAxisByDimension( 0, MAIN_AXIS_INDEX ) );
79     if( xAxis.is() )
80     {
81         ScaleData aScaleData = xAxis->getScaleData();
82         aScaleData.Scaling = AxisHelper::createLinearScaling();
83         aScaleData.AxisType = AxisType::CATEGORY;
84         aScaleData.Orientation = AxisOrientation_MATHEMATICAL;
85         xAxis->setScaleData( aScaleData );
86     }
87 
88     xAxis = xResult->getAxisByDimension( 1, MAIN_AXIS_INDEX );
89     if( xAxis.is() )
90     {
91         ScaleData aScaleData = xAxis->getScaleData();
92         aScaleData.Orientation = AxisOrientation_MATHEMATICAL;
93         aScaleData.AxisType = AxisType::REALNUMBER;
94         xAxis->setScaleData( aScaleData );
95     }
96 
97     return xResult;
98 }
99 
100 // ____ OPropertySet ____
GetDefaultValue(sal_Int32) const101 uno::Any NetChartType_Base::GetDefaultValue( sal_Int32 /*nHandle*/ ) const
102     throw(beans::UnknownPropertyException)
103 {
104     return uno::Any();
105 }
106 
107 namespace
108 {
109 
110 struct StaticNetChartTypeInfoHelper_Initializer
111 {
operator ()chart::__anon812cf6790111::StaticNetChartTypeInfoHelper_Initializer112     ::cppu::OPropertyArrayHelper* operator()()
113     {
114         // using assignment for broken gcc 3.3
115         static ::cppu::OPropertyArrayHelper aPropHelper = ::cppu::OPropertyArrayHelper(
116             Sequence< beans::Property >() );
117         return &aPropHelper;
118     }
119 };
120 
121 struct StaticNetChartTypeInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticNetChartTypeInfoHelper_Initializer >
122 {
123 };
124 
125 struct StaticNetChartTypeInfo_Initializer
126 {
operator ()chart::__anon812cf6790111::StaticNetChartTypeInfo_Initializer127     uno::Reference< beans::XPropertySetInfo >* operator()()
128     {
129         static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
130             ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticNetChartTypeInfoHelper::get() ) );
131         return &xPropertySetInfo;
132     }
133 };
134 
135 struct StaticNetChartTypeInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticNetChartTypeInfo_Initializer >
136 {
137 };
138 
139 }
140 
141 // ____ OPropertySet ____
getInfoHelper()142 ::cppu::IPropertyArrayHelper & SAL_CALL NetChartType_Base::getInfoHelper()
143 {
144     return *StaticNetChartTypeInfoHelper::get();
145 }
146 
147 // ____ XPropertySet ____
getPropertySetInfo()148 uno::Reference< beans::XPropertySetInfo > SAL_CALL NetChartType_Base::getPropertySetInfo()
149     throw (uno::RuntimeException)
150 {
151     return *StaticNetChartTypeInfo::get();
152 }
153 
154 //-----------------------------------------------------------------------------
155 
NetChartType(const uno::Reference<uno::XComponentContext> & xContext)156 NetChartType::NetChartType(
157     const uno::Reference< uno::XComponentContext > & xContext ) :
158         NetChartType_Base( xContext )
159 {}
160 
NetChartType(const NetChartType & rOther)161 NetChartType::NetChartType( const NetChartType & rOther ) :
162         NetChartType_Base( rOther )
163 {
164 }
165 
~NetChartType()166 NetChartType::~NetChartType()
167 {}
168 
169 // ____ XCloneable ____
createClone()170 uno::Reference< util::XCloneable > SAL_CALL NetChartType::createClone()
171     throw (uno::RuntimeException)
172 {
173     return uno::Reference< util::XCloneable >( new NetChartType( *this ));
174 }
175 
176 // ____ XChartType ____
getChartType()177 ::rtl::OUString SAL_CALL NetChartType::getChartType()
178     throw (uno::RuntimeException)
179 {
180     return CHART2_SERVICE_NAME_CHARTTYPE_NET;
181 }
182 
getSupportedServiceNames_Static()183 uno::Sequence< ::rtl::OUString > NetChartType::getSupportedServiceNames_Static()
184 {
185     uno::Sequence< ::rtl::OUString > aServices( 3 );
186     aServices[ 0 ] = CHART2_SERVICE_NAME_CHARTTYPE_NET;
187     aServices[ 1 ] = C2U( "com.sun.star.chart2.ChartType" );
188     aServices[ 2 ] = C2U( "com.sun.star.beans.PropertySet" );
189     return aServices;
190 }
191 
192 // implement XServiceInfo methods basing upon getSupportedServiceNames_Static
193 APPHELPER_XSERVICEINFO_IMPL( NetChartType,
194                              C2U( "com.sun.star.comp.chart.NetChartType" ));
195 
196 } //  namespace chart
197