LCOV - code coverage report
Current view: top level - chart2/source/model/template - BubbleChartTypeTemplate.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 21 78 26.9 %
Date: 2012-08-25 Functions: 11 31 35.5 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 18 148 12.2 %

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

Generated by: LCOV version 1.10