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 "StockChartTypeTemplate.hxx"
27 #include "macros.hxx"
28 #include "DataSeriesHelper.hxx"
29 #include "StockDataInterpreter.hxx"
30 #include "CartesianCoordinateSystem.hxx"
31 #include "AxisHelper.hxx"
32 #include "DiagramHelper.hxx"
33 #include "servicenames_charttypes.hxx"
34 #include "servicenames_coosystems.hxx"
35 #include "ContainerHelper.hxx"
36 #include "AxisIndexDefines.hxx"
37 #include <com/sun/star/chart2/AxisType.hpp>
38 #include <com/sun/star/chart2/data/XDataSource.hpp>
39 #include <com/sun/star/chart2/XChartTypeContainer.hpp>
40 #include <com/sun/star/chart2/XDataSeriesContainer.hpp>
41 #include "PropertyHelper.hxx"
42 #include <com/sun/star/beans/PropertyAttribute.hpp>
43 #include <com/sun/star/drawing/LineStyle.hpp>
44
45 #include <vector>
46 #include <algorithm>
47
48 using namespace ::com::sun::star;
49 using namespace ::com::sun::star::chart2;
50
51 using ::com::sun::star::uno::Reference;
52 using ::com::sun::star::uno::Sequence;
53 using ::rtl::OUString;
54 using ::com::sun::star::beans::Property;
55 using ::com::sun::star::uno::Any;
56 using ::osl::MutexGuard;
57
58 // ----------------------------------------
59 namespace
60 {
61
62 static const OUString lcl_aServiceName(
63 RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.chart2.StockChartTypeTemplate" ));
64
65 enum
66 {
67 PROP_STOCKCHARTTYPE_TEMPLATE_VOLUME,
68 PROP_STOCKCHARTTYPE_TEMPLATE_OPEN,
69 PROP_STOCKCHARTTYPE_TEMPLATE_LOW_HIGH,
70 PROP_STOCKCHARTTYPE_TEMPLATE_JAPANESE
71 };
72
lcl_AddPropertiesToVector(::std::vector<Property> & rOutProperties)73 void lcl_AddPropertiesToVector(
74 ::std::vector< Property > & rOutProperties )
75 {
76 rOutProperties.push_back(
77 Property( C2U( "Volume" ),
78 PROP_STOCKCHARTTYPE_TEMPLATE_VOLUME,
79 ::getBooleanCppuType(),
80 beans::PropertyAttribute::BOUND
81 | beans::PropertyAttribute::MAYBEDEFAULT ));
82 rOutProperties.push_back(
83 Property( C2U( "Open" ),
84 PROP_STOCKCHARTTYPE_TEMPLATE_OPEN,
85 ::getBooleanCppuType(),
86 beans::PropertyAttribute::BOUND
87 | beans::PropertyAttribute::MAYBEDEFAULT ));
88 rOutProperties.push_back(
89 Property( C2U( "LowHigh" ),
90 PROP_STOCKCHARTTYPE_TEMPLATE_LOW_HIGH,
91 ::getBooleanCppuType(),
92 beans::PropertyAttribute::BOUND
93 | beans::PropertyAttribute::MAYBEDEFAULT ));
94 rOutProperties.push_back(
95 Property( C2U( "Japanese" ),
96 PROP_STOCKCHARTTYPE_TEMPLATE_JAPANESE,
97 ::getBooleanCppuType(),
98 beans::PropertyAttribute::BOUND
99 | beans::PropertyAttribute::MAYBEDEFAULT ));
100 }
101
102 struct StaticStockChartTypeTemplateDefaults_Initializer
103 {
operator ()__anon96250b890111::StaticStockChartTypeTemplateDefaults_Initializer104 ::chart::tPropertyValueMap* operator()()
105 {
106 static ::chart::tPropertyValueMap aStaticDefaults;
107 lcl_AddDefaultsToMap( aStaticDefaults );
108 return &aStaticDefaults;
109 }
110 private:
lcl_AddDefaultsToMap__anon96250b890111::StaticStockChartTypeTemplateDefaults_Initializer111 void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap )
112 {
113 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_STOCKCHARTTYPE_TEMPLATE_VOLUME, false );
114 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_STOCKCHARTTYPE_TEMPLATE_OPEN, false );
115 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_STOCKCHARTTYPE_TEMPLATE_LOW_HIGH, true );
116 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_STOCKCHARTTYPE_TEMPLATE_JAPANESE, false );
117 }
118 };
119
120 struct StaticStockChartTypeTemplateDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticStockChartTypeTemplateDefaults_Initializer >
121 {
122 };
123
124 struct StaticStockChartTypeTemplateInfoHelper_Initializer
125 {
operator ()__anon96250b890111::StaticStockChartTypeTemplateInfoHelper_Initializer126 ::cppu::OPropertyArrayHelper* operator()()
127 {
128 static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() );
129 return &aPropHelper;
130 }
131
132 private:
lcl_GetPropertySequence__anon96250b890111::StaticStockChartTypeTemplateInfoHelper_Initializer133 Sequence< Property > lcl_GetPropertySequence()
134 {
135 ::std::vector< ::com::sun::star::beans::Property > aProperties;
136 lcl_AddPropertiesToVector( aProperties );
137
138 ::std::sort( aProperties.begin(), aProperties.end(),
139 ::chart::PropertyNameLess() );
140
141 return ::chart::ContainerHelper::ContainerToSequence( aProperties );
142 }
143 };
144
145 struct StaticStockChartTypeTemplateInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticStockChartTypeTemplateInfoHelper_Initializer >
146 {
147 };
148
149 struct StaticStockChartTypeTemplateInfo_Initializer
150 {
operator ()__anon96250b890111::StaticStockChartTypeTemplateInfo_Initializer151 uno::Reference< beans::XPropertySetInfo >* operator()()
152 {
153 static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
154 ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticStockChartTypeTemplateInfoHelper::get() ) );
155 return &xPropertySetInfo;
156 }
157 };
158
159 struct StaticStockChartTypeTemplateInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticStockChartTypeTemplateInfo_Initializer >
160 {
161 };
162
163 } // anonymous namespace
164 // ----------------------------------------
165
166 namespace chart
167 {
168
StockChartTypeTemplate(uno::Reference<uno::XComponentContext> const & xContext,const::rtl::OUString & rServiceName,StockVariant eVariant,bool bJapaneseStyle)169 StockChartTypeTemplate::StockChartTypeTemplate(
170 uno::Reference<
171 uno::XComponentContext > const & xContext,
172 const ::rtl::OUString & rServiceName,
173 StockVariant eVariant,
174 bool bJapaneseStyle ) :
175 ChartTypeTemplate( xContext, rServiceName ),
176 ::property::OPropertySet( m_aMutex ),
177 m_eStockVariant( eVariant )
178 {
179 setFastPropertyValue_NoBroadcast(
180 PROP_STOCKCHARTTYPE_TEMPLATE_OPEN,
181 uno::makeAny( ( eVariant == OPEN_LOW_HI_CLOSE ||
182 eVariant == VOL_OPEN_LOW_HI_CLOSE )));
183 setFastPropertyValue_NoBroadcast(
184 PROP_STOCKCHARTTYPE_TEMPLATE_VOLUME,
185 uno::makeAny( ( eVariant == VOL_LOW_HI_CLOSE ||
186 eVariant == VOL_OPEN_LOW_HI_CLOSE )));
187 setFastPropertyValue_NoBroadcast(
188 PROP_STOCKCHARTTYPE_TEMPLATE_JAPANESE,
189 uno::makeAny( bJapaneseStyle ));
190 }
191
~StockChartTypeTemplate()192 StockChartTypeTemplate::~StockChartTypeTemplate()
193 {}
194 // ____ OPropertySet ____
GetDefaultValue(sal_Int32 nHandle) const195 uno::Any StockChartTypeTemplate::GetDefaultValue( sal_Int32 nHandle ) const
196 throw(beans::UnknownPropertyException)
197 {
198 const tPropertyValueMap& rStaticDefaults = *StaticStockChartTypeTemplateDefaults::get();
199 tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
200 if( aFound == rStaticDefaults.end() )
201 return uno::Any();
202 return (*aFound).second;
203 }
204
getInfoHelper()205 ::cppu::IPropertyArrayHelper & SAL_CALL StockChartTypeTemplate::getInfoHelper()
206 {
207 return *StaticStockChartTypeTemplateInfoHelper::get();
208 }
209
210 // ____ XPropertySet ____
getPropertySetInfo()211 uno::Reference< beans::XPropertySetInfo > SAL_CALL StockChartTypeTemplate::getPropertySetInfo()
212 throw (uno::RuntimeException)
213 {
214 return *StaticStockChartTypeTemplateInfo::get();
215 }
216
getAxisCountByDimension(sal_Int32 nDimension)217 sal_Int32 StockChartTypeTemplate::getAxisCountByDimension( sal_Int32 nDimension )
218 {
219 // one x-axis
220 if( nDimension <= 0 )
221 return 1;
222 // no further axes
223 if( nDimension >= 2 )
224 return 0;
225
226 // one or two y-axes depending on volume
227 OSL_ASSERT( nDimension == 1 );
228 bool bHasVolume = false;
229 getFastPropertyValue( PROP_STOCKCHARTTYPE_TEMPLATE_VOLUME ) >>= bHasVolume;
230 return bHasVolume ? 2 : 1;
231 }
232
applyStyle(const Reference<chart2::XDataSeries> & xSeries,::sal_Int32 nChartTypeIndex,::sal_Int32 nSeriesIndex,::sal_Int32 nSeriesCount)233 void SAL_CALL StockChartTypeTemplate::applyStyle(
234 const Reference< chart2::XDataSeries >& xSeries,
235 ::sal_Int32 nChartTypeIndex,
236 ::sal_Int32 nSeriesIndex,
237 ::sal_Int32 nSeriesCount )
238 throw (uno::RuntimeException)
239 {
240 ChartTypeTemplate::applyStyle( xSeries, nChartTypeIndex, nSeriesIndex, nSeriesCount );
241 try
242 {
243 sal_Int32 nNewAxisIndex = 0;
244
245 bool bHasVolume = false;
246 getFastPropertyValue( PROP_STOCKCHARTTYPE_TEMPLATE_VOLUME ) >>= bHasVolume;
247 if( bHasVolume )
248 {
249 if( nChartTypeIndex != 0 )
250 nNewAxisIndex = 1;
251 }
252
253 Reference< beans::XPropertySet > xProp( xSeries, uno::UNO_QUERY );
254 if( xProp.is() )
255 xProp->setPropertyValue( C2U("AttachedAxisIndex"), uno::makeAny( nNewAxisIndex ) );
256
257 if( bHasVolume && nChartTypeIndex==0 )
258 {
259 //switch lines off for volume bars
260 DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, C2U( "BorderStyle" ), uno::makeAny( drawing::LineStyle_NONE ) );
261 }
262 else
263 {
264 //ensure that lines are on
265 if( xProp.is() )
266 {
267 drawing::LineStyle eStyle = drawing::LineStyle_NONE;
268 xProp->getPropertyValue( C2U("LineStyle") ) >>= eStyle;
269 if( eStyle == drawing::LineStyle_NONE )
270 xProp->setPropertyValue( C2U("LineStyle"), uno::makeAny( drawing::LineStyle_SOLID ));
271 }
272 }
273
274 }
275 catch( uno::Exception & ex )
276 {
277 ASSERT_EXCEPTION( ex );
278 }
279 }
280
resetStyles(const Reference<chart2::XDiagram> & xDiagram)281 void SAL_CALL StockChartTypeTemplate::resetStyles(
282 const Reference< chart2::XDiagram >& xDiagram )
283 throw (uno::RuntimeException)
284 {
285 ChartTypeTemplate::resetStyles( xDiagram );
286 if( getDimension() == 3 )
287 {
288 ::std::vector< Reference< chart2::XDataSeries > > aSeriesVec(
289 DiagramHelper::getDataSeriesFromDiagram( xDiagram ));
290 for( ::std::vector< Reference< chart2::XDataSeries > >::iterator aIt( aSeriesVec.begin());
291 aIt != aSeriesVec.end(); ++aIt )
292 {
293 Reference< beans::XPropertySet > xProp( *aIt, uno::UNO_QUERY );
294 if( xProp.is() )
295 xProp->setPropertyValue( C2U("AttachedAxisIndex"), uno::makeAny( sal_Int32(0) ) );
296 }
297 }
298
299 DiagramHelper::setVertical( xDiagram, false );
300 }
301
getChartTypeForIndex(sal_Int32 nChartTypeIndex)302 Reference< XChartType > StockChartTypeTemplate::getChartTypeForIndex( sal_Int32 nChartTypeIndex )
303 {
304 Reference< XChartType > xCT;
305 Reference< lang::XMultiServiceFactory > xFact(
306 GetComponentContext()->getServiceManager(), uno::UNO_QUERY );
307 if(xFact.is())
308 {
309 bool bHasVolume = false;
310 getFastPropertyValue( PROP_STOCKCHARTTYPE_TEMPLATE_VOLUME ) >>= bHasVolume;
311 if( bHasVolume )
312 {
313 if( nChartTypeIndex == 0 )
314 xCT.set( xFact->createInstance( CHART2_SERVICE_NAME_CHARTTYPE_COLUMN ), uno::UNO_QUERY );
315 else if( nChartTypeIndex == 1 )
316 xCT.set( xFact->createInstance( CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK ), uno::UNO_QUERY );
317 else
318 xCT.set( xFact->createInstance( CHART2_SERVICE_NAME_CHARTTYPE_LINE ), uno::UNO_QUERY );
319 }
320 else
321 {
322 if( nChartTypeIndex == 0 )
323 xCT.set( xFact->createInstance( CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK ), uno::UNO_QUERY );
324 else
325 xCT.set( xFact->createInstance( CHART2_SERVICE_NAME_CHARTTYPE_LINE ), uno::UNO_QUERY );
326 }
327 }
328 return xCT;
329 }
330
createChartTypes(const Sequence<Sequence<Reference<XDataSeries>>> & aSeriesSeq,const Sequence<Reference<XCoordinateSystem>> & rCoordSys,const Sequence<Reference<XChartType>> &)331 void StockChartTypeTemplate::createChartTypes(
332 const Sequence< Sequence< Reference< XDataSeries > > > & aSeriesSeq,
333 const Sequence< Reference< XCoordinateSystem > > & rCoordSys,
334 const Sequence< Reference< XChartType > >& /* aOldChartTypesSeq */ )
335 {
336 if( rCoordSys.getLength() < 1 )
337 return;
338
339 try
340 {
341 Reference< lang::XMultiServiceFactory > xFact(
342 GetComponentContext()->getServiceManager(), uno::UNO_QUERY_THROW );
343 bool bHasVolume = false;
344 bool bShowFirst = false;
345 bool bJapaneseStyle = false;
346 bool bShowHighLow = true;
347
348 getFastPropertyValue( PROP_STOCKCHARTTYPE_TEMPLATE_VOLUME ) >>= bHasVolume;
349 getFastPropertyValue( PROP_STOCKCHARTTYPE_TEMPLATE_OPEN ) >>= bShowFirst;
350 getFastPropertyValue( PROP_STOCKCHARTTYPE_TEMPLATE_JAPANESE ) >>= bJapaneseStyle;
351 getFastPropertyValue( PROP_STOCKCHARTTYPE_TEMPLATE_LOW_HIGH ) >>= bShowHighLow;
352
353 sal_Int32 nSeriesIndex = 0;
354
355 std::vector< Reference< chart2::XChartType > > aChartTypeVec;
356 // Bars (Volume)
357 // -------------
358 if( bHasVolume )
359 {
360 // chart type
361 Reference< XChartType > xCT(
362 xFact->createInstance(
363 CHART2_SERVICE_NAME_CHARTTYPE_COLUMN ), uno::UNO_QUERY_THROW );
364 aChartTypeVec.push_back( xCT );
365
366 if( aSeriesSeq.getLength() > nSeriesIndex &&
367 aSeriesSeq[nSeriesIndex].getLength() > 0 )
368 {
369 Reference< XDataSeriesContainer > xDSCnt( xCT, uno::UNO_QUERY_THROW );
370 xDSCnt->setDataSeries( aSeriesSeq[ nSeriesIndex ] );
371 }
372 ++nSeriesIndex;
373 }
374
375 Reference< XChartType > xCT(
376 xFact->createInstance(
377 CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK ), uno::UNO_QUERY_THROW );
378 aChartTypeVec.push_back( xCT );
379
380 Reference< beans::XPropertySet > xCTProp( xCT, uno::UNO_QUERY );
381 if( xCTProp.is())
382 {
383 xCTProp->setPropertyValue( C2U("Japanese"), uno::makeAny( bJapaneseStyle ));
384 xCTProp->setPropertyValue( C2U("ShowFirst"), uno::makeAny( bShowFirst ));
385 xCTProp->setPropertyValue( C2U("ShowHighLow"), uno::makeAny( bShowHighLow ));
386 }
387
388 if( aSeriesSeq.getLength() > nSeriesIndex &&
389 aSeriesSeq[ nSeriesIndex ].getLength() > 0 )
390 {
391 Reference< XDataSeriesContainer > xDSCnt( xCT, uno::UNO_QUERY_THROW );
392 xDSCnt->setDataSeries( aSeriesSeq[ nSeriesIndex ] );
393 }
394 ++nSeriesIndex;
395
396 // Lines (remaining series)
397 // ------------------------
398 if( aSeriesSeq.getLength() > nSeriesIndex &&
399 aSeriesSeq[ nSeriesIndex ].getLength() > 0 )
400 {
401 xCT.set(
402 xFact->createInstance(
403 CHART2_SERVICE_NAME_CHARTTYPE_LINE ), uno::UNO_QUERY_THROW );
404 aChartTypeVec.push_back( xCT );
405
406 Reference< XDataSeriesContainer > xDSCnt( xCT, uno::UNO_QUERY_THROW );
407 xDSCnt->setDataSeries( aSeriesSeq[ nSeriesIndex ] );
408 }
409
410 Reference< XChartTypeContainer > xCTCnt( rCoordSys[ 0 ], uno::UNO_QUERY_THROW );
411 xCTCnt->setChartTypes( ::chart::ContainerHelper::ContainerToSequence(aChartTypeVec) );
412 }
413 catch( uno::Exception & ex )
414 {
415 ASSERT_EXCEPTION( ex );
416 }
417 }
418
419 // ____ XChartTypeTemplate ____
matchesTemplate(const uno::Reference<XDiagram> & xDiagram,sal_Bool)420 sal_Bool SAL_CALL StockChartTypeTemplate::matchesTemplate(
421 const uno::Reference< XDiagram >& xDiagram,
422 sal_Bool /* bAdaptProperties */ )
423 throw (uno::RuntimeException)
424 {
425 sal_Bool bResult = sal_False;
426
427 if( ! xDiagram.is())
428 return bResult;
429
430 try
431 {
432 sal_Bool bHasVolume = false, bHasOpenValue = false, bHasJapaneseStyle = false;
433
434 getFastPropertyValue( PROP_STOCKCHARTTYPE_TEMPLATE_VOLUME ) >>= bHasVolume;
435 getFastPropertyValue( PROP_STOCKCHARTTYPE_TEMPLATE_OPEN ) >>= bHasOpenValue;
436 getFastPropertyValue( PROP_STOCKCHARTTYPE_TEMPLATE_JAPANESE ) >>= bHasJapaneseStyle;
437
438 Reference< chart2::XChartType > xVolumeChartType;
439 Reference< chart2::XChartType > xCandleStickChartType;
440 Reference< chart2::XChartType > xLineChartType;
441 sal_Int32 nNumberOfChartTypes = 0;
442
443 Reference< XCoordinateSystemContainer > xCooSysCnt(
444 xDiagram, uno::UNO_QUERY_THROW );
445 Sequence< Reference< XCoordinateSystem > > aCooSysSeq(
446 xCooSysCnt->getCoordinateSystems());
447 for( sal_Int32 i=0; i<aCooSysSeq.getLength(); ++i )
448 {
449 Reference< XChartTypeContainer > xCTCnt( aCooSysSeq[i], uno::UNO_QUERY_THROW );
450 Sequence< Reference< XChartType > > aChartTypeSeq( xCTCnt->getChartTypes());
451 for( sal_Int32 j=0; j<aChartTypeSeq.getLength(); ++j )
452 {
453 if( aChartTypeSeq[j].is())
454 {
455 ++nNumberOfChartTypes;
456 if( nNumberOfChartTypes > 3 )
457 break;
458 OUString aCTService = aChartTypeSeq[j]->getChartType();
459 if( aCTService.equals( CHART2_SERVICE_NAME_CHARTTYPE_COLUMN ))
460 xVolumeChartType.set( aChartTypeSeq[j] );
461 else if( aCTService.equals( CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK ))
462 xCandleStickChartType.set( aChartTypeSeq[j] );
463 else if( aCTService.equals( CHART2_SERVICE_NAME_CHARTTYPE_LINE ))
464 xLineChartType.set( aChartTypeSeq[j] );
465 }
466 }
467 if( nNumberOfChartTypes > 3 )
468 break;
469 }
470
471 if( xCandleStickChartType.is() &&
472 ( ( bHasVolume &&
473 xVolumeChartType.is() ) ||
474 ( ! bHasVolume &&
475 ! xVolumeChartType.is() )))
476 {
477 bResult = true;
478
479 // check for japanese style
480 Reference< beans::XPropertySet > xCTProp( xCandleStickChartType, uno::UNO_QUERY );
481 if( xCTProp.is())
482 {
483 sal_Bool bJapaneseProp = sal_False;
484 xCTProp->getPropertyValue( C2U("Japanese")) >>= bJapaneseProp;
485 bResult = bResult && ( bHasJapaneseStyle == bJapaneseProp );
486
487 // in old chart japanese == showFirst
488 sal_Bool bShowFirstProp = sal_False;
489 xCTProp->getPropertyValue( C2U("ShowFirst")) >>= bShowFirstProp;
490 bResult = bResult && ( bHasOpenValue == bShowFirstProp );
491 }
492 }
493 }
494 catch( uno::Exception & ex )
495 {
496 ASSERT_EXCEPTION( ex );
497 }
498
499 return bResult;
500 }
501
getChartTypeForNewSeries(const uno::Sequence<Reference<chart2::XChartType>> & aFormerlyUsedChartTypes)502 Reference< XChartType > SAL_CALL StockChartTypeTemplate::getChartTypeForNewSeries(
503 const uno::Sequence< Reference< chart2::XChartType > >& aFormerlyUsedChartTypes )
504 throw (uno::RuntimeException)
505 {
506 Reference< chart2::XChartType > xResult;
507
508 try
509 {
510 Reference< lang::XMultiServiceFactory > xFact(
511 GetComponentContext()->getServiceManager(), uno::UNO_QUERY_THROW );
512 xResult.set( xFact->createInstance(
513 CHART2_SERVICE_NAME_CHARTTYPE_LINE ), uno::UNO_QUERY_THROW );
514 ChartTypeTemplate::copyPropertiesFromOldToNewCoordianteSystem( aFormerlyUsedChartTypes, xResult );
515 }
516 catch( uno::Exception & ex )
517 {
518 ASSERT_EXCEPTION( ex );
519 }
520
521 return xResult;
522 }
523
getDataInterpreter()524 Reference< XDataInterpreter > SAL_CALL StockChartTypeTemplate::getDataInterpreter()
525 throw (uno::RuntimeException)
526 {
527 if( ! m_xDataInterpreter.is())
528 m_xDataInterpreter.set( new StockDataInterpreter( m_eStockVariant, GetComponentContext() ) );
529
530 return m_xDataInterpreter;
531 }
532
533 // ----------------------------------------
534
getSupportedServiceNames_Static()535 Sequence< OUString > StockChartTypeTemplate::getSupportedServiceNames_Static()
536 {
537 Sequence< OUString > aServices( 2 );
538 aServices[ 0 ] = lcl_aServiceName;
539 aServices[ 1 ] = C2U( "com.sun.star.chart2.ChartTypeTemplate" );
540 return aServices;
541 }
542
543 // implement XServiceInfo methods basing upon getSupportedServiceNames_Static
544 APPHELPER_XSERVICEINFO_IMPL( StockChartTypeTemplate, lcl_aServiceName );
545
546 IMPLEMENT_FORWARD_XINTERFACE2( StockChartTypeTemplate, ChartTypeTemplate, OPropertySet )
547 IMPLEMENT_FORWARD_XTYPEPROVIDER2( StockChartTypeTemplate, ChartTypeTemplate, OPropertySet )
548
549 } // namespace chart
550