Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
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"
28 :
29 : #include <cppuhelper/supportsservice.hxx>
30 : #include <com/sun/star/beans/PropertyAttribute.hpp>
31 : #include <com/sun/star/chart2/AxisType.hpp>
32 :
33 : using namespace ::com::sun::star;
34 : using namespace ::com::sun::star::chart2;
35 :
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;
41 :
42 : namespace chart
43 : {
44 :
45 16775 : NetChartType_Base::NetChartType_Base(
46 : const uno::Reference< uno::XComponentContext > & xContext ) :
47 16775 : ChartType( xContext )
48 16775 : {}
49 :
50 0 : NetChartType_Base::NetChartType_Base( const NetChartType_Base & rOther ) :
51 0 : ChartType( rOther )
52 : {
53 0 : }
54 :
55 16775 : NetChartType_Base::~NetChartType_Base()
56 16775 : {}
57 :
58 : Reference< XCoordinateSystem > SAL_CALL
59 1 : NetChartType_Base::createCoordinateSystem( ::sal_Int32 DimensionCount )
60 : throw (lang::IllegalArgumentException,
61 : uno::RuntimeException, std::exception)
62 : {
63 1 : if( DimensionCount != 2 )
64 : throw lang::IllegalArgumentException(
65 : "NetChart must be two-dimensional",
66 0 : static_cast< ::cppu::OWeakObject* >( this ), 0 );
67 :
68 : Reference< XCoordinateSystem > xResult(
69 : new PolarCoordinateSystem(
70 1 : GetComponentContext(), DimensionCount, /* bSwapXAndYAxis */ false ));
71 :
72 2 : Reference< XAxis > xAxis( xResult->getAxisByDimension( 0, MAIN_AXIS_INDEX ) );
73 1 : if( xAxis.is() )
74 : {
75 1 : ScaleData aScaleData = xAxis->getScaleData();
76 1 : aScaleData.Scaling = AxisHelper::createLinearScaling();
77 1 : aScaleData.AxisType = AxisType::CATEGORY;
78 1 : aScaleData.Orientation = AxisOrientation_MATHEMATICAL;
79 1 : xAxis->setScaleData( aScaleData );
80 : }
81 :
82 1 : xAxis = xResult->getAxisByDimension( 1, MAIN_AXIS_INDEX );
83 1 : if( xAxis.is() )
84 : {
85 1 : ScaleData aScaleData = xAxis->getScaleData();
86 1 : aScaleData.Orientation = AxisOrientation_MATHEMATICAL;
87 1 : aScaleData.AxisType = AxisType::REALNUMBER;
88 1 : xAxis->setScaleData( aScaleData );
89 : }
90 :
91 2 : return xResult;
92 : }
93 :
94 : // ____ OPropertySet ____
95 0 : uno::Any NetChartType_Base::GetDefaultValue( sal_Int32 /*nHandle*/ ) const
96 : throw(beans::UnknownPropertyException)
97 : {
98 0 : return uno::Any();
99 : }
100 :
101 : namespace
102 : {
103 :
104 : struct StaticNetChartTypeInfoHelper_Initializer
105 : {
106 1 : ::cppu::OPropertyArrayHelper* operator()()
107 : {
108 : // using assignment for broken gcc 3.3
109 : static ::cppu::OPropertyArrayHelper aPropHelper = ::cppu::OPropertyArrayHelper(
110 1 : Sequence< beans::Property >() );
111 1 : return &aPropHelper;
112 : }
113 : };
114 :
115 : struct StaticNetChartTypeInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticNetChartTypeInfoHelper_Initializer >
116 : {
117 : };
118 :
119 : struct StaticNetChartTypeInfo_Initializer
120 : {
121 1 : uno::Reference< beans::XPropertySetInfo >* operator()()
122 : {
123 : static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
124 1 : ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticNetChartTypeInfoHelper::get() ) );
125 1 : return &xPropertySetInfo;
126 : }
127 : };
128 :
129 : struct StaticNetChartTypeInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticNetChartTypeInfo_Initializer >
130 : {
131 : };
132 :
133 : }
134 :
135 : // ____ OPropertySet ____
136 168 : ::cppu::IPropertyArrayHelper & SAL_CALL NetChartType_Base::getInfoHelper()
137 : {
138 168 : return *StaticNetChartTypeInfoHelper::get();
139 : }
140 :
141 : // ____ XPropertySet ____
142 2 : uno::Reference< beans::XPropertySetInfo > SAL_CALL NetChartType_Base::getPropertySetInfo()
143 : throw (uno::RuntimeException, std::exception)
144 : {
145 2 : return *StaticNetChartTypeInfo::get();
146 : }
147 :
148 12433 : NetChartType::NetChartType(
149 : const uno::Reference< uno::XComponentContext > & xContext ) :
150 12433 : NetChartType_Base( xContext )
151 12433 : {}
152 :
153 0 : NetChartType::NetChartType( const NetChartType & rOther ) :
154 0 : NetChartType_Base( rOther )
155 : {
156 0 : }
157 :
158 24866 : NetChartType::~NetChartType()
159 24866 : {}
160 :
161 : // ____ XCloneable ____
162 0 : uno::Reference< util::XCloneable > SAL_CALL NetChartType::createClone()
163 : throw (uno::RuntimeException, std::exception)
164 : {
165 0 : return uno::Reference< util::XCloneable >( new NetChartType( *this ));
166 : }
167 :
168 : // ____ XChartType ____
169 24864 : OUString SAL_CALL NetChartType::getChartType()
170 : throw (uno::RuntimeException, std::exception)
171 : {
172 24864 : return OUString(CHART2_SERVICE_NAME_CHARTTYPE_NET);
173 : }
174 :
175 1 : uno::Sequence< OUString > NetChartType::getSupportedServiceNames_Static()
176 : {
177 1 : uno::Sequence< OUString > aServices( 3 );
178 1 : aServices[ 0 ] = CHART2_SERVICE_NAME_CHARTTYPE_NET;
179 1 : aServices[ 1 ] = "com.sun.star.chart2.ChartType";
180 1 : aServices[ 2 ] = "com.sun.star.beans.PropertySet";
181 1 : return aServices;
182 : }
183 :
184 : // implement XServiceInfo methods basing upon getSupportedServiceNames_Static
185 1 : OUString SAL_CALL NetChartType::getImplementationName()
186 : throw( css::uno::RuntimeException, std::exception )
187 : {
188 1 : return getImplementationName_Static();
189 : }
190 :
191 1 : OUString NetChartType::getImplementationName_Static()
192 : {
193 1 : return OUString("com.sun.star.comp.chart.NetChartType");
194 : }
195 :
196 0 : sal_Bool SAL_CALL NetChartType::supportsService( const OUString& rServiceName )
197 : throw( css::uno::RuntimeException, std::exception )
198 : {
199 0 : return cppu::supportsService(this, rServiceName);
200 : }
201 :
202 1 : css::uno::Sequence< OUString > SAL_CALL NetChartType::getSupportedServiceNames()
203 : throw( css::uno::RuntimeException, std::exception )
204 : {
205 1 : return getSupportedServiceNames_Static();
206 : }
207 :
208 : } // namespace chart
209 :
210 : extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
211 12433 : com_sun_star_comp_chart_NetChartType_get_implementation(css::uno::XComponentContext *context,
212 : css::uno::Sequence<css::uno::Any> const &)
213 : {
214 12433 : return cppu::acquire(new ::chart::NetChartType(context));
215 : }
216 :
217 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|