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 "BubbleChartTypeTemplate.hxx"
27 #include "macros.hxx"
28 #include "BubbleDataInterpreter.hxx"
29 #include "CartesianCoordinateSystem.hxx"
30 #include "Scaling.hxx"
31 #include "DiagramHelper.hxx"
32 #include "servicenames_charttypes.hxx"
33 #include "ContainerHelper.hxx"
34 #include "DataSeriesHelper.hxx"
35 #include <com/sun/star/drawing/LineStyle.hpp>
36 #include "PropertyHelper.hxx"
37 #include <com/sun/star/beans/PropertyAttribute.hpp>
38
39 #include <algorithm>
40
41 using namespace ::com::sun::star;
42
43 using ::com::sun::star::uno::Reference;
44 using ::com::sun::star::uno::Sequence;
45 using ::rtl::OUString;
46 using ::com::sun::star::beans::Property;
47 using ::com::sun::star::uno::Reference;
48 using ::com::sun::star::uno::Any;
49 using ::osl::MutexGuard;
50
51 namespace
52 {
53
54 static const OUString lcl_aServiceName(
55 RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.chart2.BubbleChartTypeTemplate" ));
56
lcl_AddPropertiesToVector(::std::vector<Property> &)57 void lcl_AddPropertiesToVector(
58 ::std::vector< Property > & /*rOutProperties*/ )
59 {
60 }
61
62 struct StaticBubbleChartTypeTemplateDefaults_Initializer
63 {
operator ()__anon114050b10111::StaticBubbleChartTypeTemplateDefaults_Initializer64 ::chart::tPropertyValueMap* operator()()
65 {
66 static ::chart::tPropertyValueMap aStaticDefaults;
67 lcl_AddDefaultsToMap( aStaticDefaults );
68 return &aStaticDefaults;
69 }
70 private:
lcl_AddDefaultsToMap__anon114050b10111::StaticBubbleChartTypeTemplateDefaults_Initializer71 void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & /*rOutMap*/ )
72 {
73 }
74 };
75
76 struct StaticBubbleChartTypeTemplateDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticBubbleChartTypeTemplateDefaults_Initializer >
77 {
78 };
79
80 struct StaticBubbleChartTypeTemplateInfoHelper_Initializer
81 {
operator ()__anon114050b10111::StaticBubbleChartTypeTemplateInfoHelper_Initializer82 ::cppu::OPropertyArrayHelper* operator()()
83 {
84 static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() );
85 return &aPropHelper;
86 }
87
88 private:
lcl_GetPropertySequence__anon114050b10111::StaticBubbleChartTypeTemplateInfoHelper_Initializer89 Sequence< Property > lcl_GetPropertySequence()
90 {
91 ::std::vector< ::com::sun::star::beans::Property > aProperties;
92 lcl_AddPropertiesToVector( aProperties );
93
94 ::std::sort( aProperties.begin(), aProperties.end(),
95 ::chart::PropertyNameLess() );
96
97 return ::chart::ContainerHelper::ContainerToSequence( aProperties );
98 }
99
100 };
101
102 struct StaticBubbleChartTypeTemplateInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticBubbleChartTypeTemplateInfoHelper_Initializer >
103 {
104 };
105
106 struct StaticBubbleChartTypeTemplateInfo_Initializer
107 {
operator ()__anon114050b10111::StaticBubbleChartTypeTemplateInfo_Initializer108 uno::Reference< beans::XPropertySetInfo >* operator()()
109 {
110 static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
111 ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticBubbleChartTypeTemplateInfoHelper::get() ) );
112 return &xPropertySetInfo;
113 }
114 };
115
116 struct StaticBubbleChartTypeTemplateInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticBubbleChartTypeTemplateInfo_Initializer >
117 {
118 };
119
120 } // anonymous namespace
121
122 namespace chart
123 {
124
BubbleChartTypeTemplate(Reference<uno::XComponentContext> const & xContext,const OUString & rServiceName)125 BubbleChartTypeTemplate::BubbleChartTypeTemplate(
126 Reference<
127 uno::XComponentContext > const & xContext,
128 const OUString & rServiceName ) :
129 ChartTypeTemplate( xContext, rServiceName ),
130 ::property::OPropertySet( m_aMutex )
131 {
132 }
133
~BubbleChartTypeTemplate()134 BubbleChartTypeTemplate::~BubbleChartTypeTemplate()
135 {}
136
137 // ____ OPropertySet ____
GetDefaultValue(sal_Int32 nHandle) const138 uno::Any BubbleChartTypeTemplate::GetDefaultValue( sal_Int32 nHandle ) const
139 throw(beans::UnknownPropertyException)
140 {
141 const tPropertyValueMap& rStaticDefaults = *StaticBubbleChartTypeTemplateDefaults::get();
142 tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
143 if( aFound == rStaticDefaults.end() )
144 return uno::Any();
145 return (*aFound).second;
146 }
147
getInfoHelper()148 ::cppu::IPropertyArrayHelper & SAL_CALL BubbleChartTypeTemplate::getInfoHelper()
149 {
150 return *StaticBubbleChartTypeTemplateInfoHelper::get();
151 }
152
153 // ____ XPropertySet ____
getPropertySetInfo()154 uno::Reference< beans::XPropertySetInfo > SAL_CALL BubbleChartTypeTemplate::getPropertySetInfo()
155 throw (uno::RuntimeException)
156 {
157 return *StaticBubbleChartTypeTemplateInfo::get();
158 }
159
getDimension() const160 sal_Int32 BubbleChartTypeTemplate::getDimension() const
161 {
162 return 2;
163 }
164
getStackMode(sal_Int32) const165 StackMode BubbleChartTypeTemplate::getStackMode( sal_Int32 /* nChartTypeIndex */ ) const
166 {
167 return StackMode_NONE;
168 }
169
applyStyle(const Reference<chart2::XDataSeries> & xSeries,::sal_Int32 nChartTypeIndex,::sal_Int32 nSeriesIndex,::sal_Int32 nSeriesCount)170 void SAL_CALL BubbleChartTypeTemplate::applyStyle(
171 const Reference< chart2::XDataSeries >& xSeries,
172 ::sal_Int32 nChartTypeIndex,
173 ::sal_Int32 nSeriesIndex,
174 ::sal_Int32 nSeriesCount )
175 throw (uno::RuntimeException)
176 {
177 ChartTypeTemplate::applyStyle( xSeries, nChartTypeIndex, nSeriesIndex, nSeriesCount );
178 DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, C2U( "BorderStyle" ), uno::makeAny( drawing::LineStyle_NONE ) );
179
180 try
181 {
182 }
183 catch( uno::Exception & ex )
184 {
185 ASSERT_EXCEPTION( ex );
186 }
187 }
188
189 // ____ XChartTypeTemplate ____
supportsCategories()190 sal_Bool SAL_CALL BubbleChartTypeTemplate::supportsCategories()
191 throw (uno::RuntimeException)
192 {
193 return false;
194 }
195
matchesTemplate(const Reference<chart2::XDiagram> & xDiagram,sal_Bool bAdaptProperties)196 sal_Bool SAL_CALL BubbleChartTypeTemplate::matchesTemplate(
197 const Reference< chart2::XDiagram >& xDiagram,
198 sal_Bool bAdaptProperties )
199 throw (uno::RuntimeException)
200 {
201 sal_Bool bResult = ChartTypeTemplate::matchesTemplate( xDiagram, bAdaptProperties );
202
203 if( bResult )
204 {
205 ::std::vector< Reference< chart2::XDataSeries > > aSeriesVec(
206 DiagramHelper::getDataSeriesFromDiagram( xDiagram ));
207
208 for( ::std::vector< Reference< chart2::XDataSeries > >::const_iterator aIt =
209 aSeriesVec.begin(); aIt != aSeriesVec.end(); ++aIt )
210 {
211 try
212 {
213 }
214 catch( uno::Exception & ex )
215 {
216 ASSERT_EXCEPTION( ex );
217 }
218 }
219 }
220
221 // adapt curve style, spline order and resolution
222 if( bResult && bAdaptProperties )
223 {
224 try
225 {
226 }
227 catch( uno::Exception & ex )
228 {
229 ASSERT_EXCEPTION( ex );
230 }
231 }
232
233 return bResult;
234 }
235
getChartTypeForIndex(sal_Int32)236 Reference< chart2::XChartType > BubbleChartTypeTemplate::getChartTypeForIndex( sal_Int32 /*nChartTypeIndex*/ )
237 {
238 Reference< chart2::XChartType > xResult;
239
240 try
241 {
242 Reference< lang::XMultiServiceFactory > xFact(
243 GetComponentContext()->getServiceManager(), uno::UNO_QUERY_THROW );
244 xResult.set( xFact->createInstance(
245 CHART2_SERVICE_NAME_CHARTTYPE_BUBBLE ), uno::UNO_QUERY_THROW );
246 }
247 catch( uno::Exception & ex )
248 {
249 ASSERT_EXCEPTION( ex );
250 }
251
252 return xResult;
253 }
254
getChartTypeForNewSeries(const uno::Sequence<Reference<chart2::XChartType>> & aFormerlyUsedChartTypes)255 Reference< chart2::XChartType > SAL_CALL BubbleChartTypeTemplate::getChartTypeForNewSeries(
256 const uno::Sequence< Reference< chart2::XChartType > >& aFormerlyUsedChartTypes )
257 throw (uno::RuntimeException)
258 {
259 Reference< chart2::XChartType > xResult;
260
261 try
262 {
263 Reference< lang::XMultiServiceFactory > xFact(
264 GetComponentContext()->getServiceManager(), uno::UNO_QUERY_THROW );
265 xResult.set( xFact->createInstance(
266 CHART2_SERVICE_NAME_CHARTTYPE_BUBBLE ), uno::UNO_QUERY_THROW );
267
268 ChartTypeTemplate::copyPropertiesFromOldToNewCoordianteSystem( aFormerlyUsedChartTypes, xResult );
269 }
270 catch( uno::Exception & ex )
271 {
272 ASSERT_EXCEPTION( ex );
273 }
274
275 return xResult;
276 }
277
getDataInterpreter()278 Reference< chart2::XDataInterpreter > SAL_CALL BubbleChartTypeTemplate::getDataInterpreter()
279 throw (uno::RuntimeException)
280 {
281 if( ! m_xDataInterpreter.is())
282 m_xDataInterpreter.set( new BubbleDataInterpreter( GetComponentContext()) );
283
284 return m_xDataInterpreter;
285 }
286
287 // ----------------------------------------
288
getSupportedServiceNames_Static()289 Sequence< OUString > BubbleChartTypeTemplate::getSupportedServiceNames_Static()
290 {
291 Sequence< OUString > aServices( 2 );
292 aServices[ 0 ] = lcl_aServiceName;
293 aServices[ 1 ] = C2U( "com.sun.star.chart2.ChartTypeTemplate" );
294 return aServices;
295 }
296
297 // implement XServiceInfo methods basing upon getSupportedServiceNames_Static
298 APPHELPER_XSERVICEINFO_IMPL( BubbleChartTypeTemplate, lcl_aServiceName );
299
300 IMPLEMENT_FORWARD_XINTERFACE2( BubbleChartTypeTemplate, ChartTypeTemplate, OPropertySet )
301 IMPLEMENT_FORWARD_XTYPEPROVIDER2( BubbleChartTypeTemplate, ChartTypeTemplate, OPropertySet )
302
303 } // namespace chart
304