LCOV - code coverage report
Current view: top level - libreoffice/chart2/source/model/template - StockChartTypeTemplate.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 2 221 0.9 %
Date: 2012-12-17 Functions: 2 32 6.2 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10