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