LCOV - code coverage report
Current view: top level - chart2/source/model/template - LineChartType.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 51 57 89.5 %
Date: 2014-04-11 Functions: 15 20 75.0 %
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 "LineChartType.hxx"
      21             : #include "PropertyHelper.hxx"
      22             : #include "macros.hxx"
      23             : #include "servicenames_charttypes.hxx"
      24             : #include "ContainerHelper.hxx"
      25             : #include <unonames.hxx>
      26             : 
      27             : #include <com/sun/star/beans/PropertyAttribute.hpp>
      28             : #include <com/sun/star/chart2/CurveStyle.hpp>
      29             : 
      30             : using namespace ::com::sun::star;
      31             : 
      32             : using ::com::sun::star::beans::Property;
      33             : using ::com::sun::star::uno::Sequence;
      34             : using ::com::sun::star::uno::Reference;
      35             : using ::com::sun::star::uno::Any;
      36             : using ::osl::MutexGuard;
      37             : 
      38             : namespace
      39             : {
      40             : 
      41             : enum
      42             : {
      43             :     PROP_LINECHARTTYPE_CURVE_STYLE,
      44             :     PROP_LINECHARTTYPE_CURVE_RESOLUTION,
      45             :     PROP_LINECHARTTYPE_SPLINE_ORDER
      46             : };
      47             : 
      48           5 : void lcl_AddPropertiesToVector(
      49             :     ::std::vector< Property > & rOutProperties )
      50             : {
      51             :     rOutProperties.push_back(
      52             :         Property( CHART_UNONAME_CURVE_STYLE,
      53             :                   PROP_LINECHARTTYPE_CURVE_STYLE,
      54           5 :                   ::getCppuType( reinterpret_cast< const chart2::CurveStyle * >(0)),
      55             :                   beans::PropertyAttribute::BOUND
      56          10 :                   | beans::PropertyAttribute::MAYBEDEFAULT ));
      57             : 
      58             :     rOutProperties.push_back(
      59             :         Property( CHART_UNONAME_CURVE_RESOLUTION,
      60             :                   PROP_LINECHARTTYPE_CURVE_RESOLUTION,
      61           5 :                   ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)),
      62             :                   beans::PropertyAttribute::BOUND
      63          10 :                   | beans::PropertyAttribute::MAYBEDEFAULT ));
      64             :     rOutProperties.push_back(
      65             :         Property( CHART_UNONAME_SPLINE_ORDER,
      66             :                   PROP_LINECHARTTYPE_SPLINE_ORDER,
      67           5 :                   ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)),
      68             :                   beans::PropertyAttribute::BOUND
      69          10 :                   | beans::PropertyAttribute::MAYBEDEFAULT ));
      70           5 : }
      71             : 
      72             : struct StaticLineChartTypeDefaults_Initializer
      73             : {
      74           5 :     ::chart::tPropertyValueMap* operator()()
      75             :     {
      76           5 :         static ::chart::tPropertyValueMap aStaticDefaults;
      77           5 :         lcl_AddDefaultsToMap( aStaticDefaults );
      78           5 :         return &aStaticDefaults;
      79             :     }
      80             : private:
      81           5 :     void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap )
      82             :     {
      83           5 :         ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_LINECHARTTYPE_CURVE_STYLE, ::chart2::CurveStyle_LINES );
      84           5 :         ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_LINECHARTTYPE_CURVE_RESOLUTION, 20 );
      85             : 
      86             :         // todo: check whether order 3 means polygons of order 3 or 2. (see
      87             :         // http://www.people.nnov.ru/fractal/Splines/Basis.htm )
      88           5 :         ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_LINECHARTTYPE_SPLINE_ORDER, 3 );
      89           5 :     }
      90             : };
      91             : 
      92             : struct StaticLineChartTypeDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticLineChartTypeDefaults_Initializer >
      93             : {
      94             : };
      95             : 
      96             : struct StaticLineChartTypeInfoHelper_Initializer
      97             : {
      98           5 :     ::cppu::OPropertyArrayHelper* operator()()
      99             :     {
     100           5 :         static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() );
     101           5 :         return &aPropHelper;
     102             :     }
     103             : 
     104             : private:
     105           5 :     Sequence< Property > lcl_GetPropertySequence()
     106             :     {
     107           5 :         ::std::vector< ::com::sun::star::beans::Property > aProperties;
     108           5 :         lcl_AddPropertiesToVector( aProperties );
     109             : 
     110             :         ::std::sort( aProperties.begin(), aProperties.end(),
     111           5 :                      ::chart::PropertyNameLess() );
     112             : 
     113           5 :         return ::chart::ContainerHelper::ContainerToSequence( aProperties );
     114             :     }
     115             : 
     116             : };
     117             : 
     118             : struct StaticLineChartTypeInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticLineChartTypeInfoHelper_Initializer >
     119             : {
     120             : };
     121             : 
     122             : struct StaticLineChartTypeInfo_Initializer
     123             : {
     124           1 :     uno::Reference< beans::XPropertySetInfo >* operator()()
     125             :     {
     126             :         static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
     127           1 :             ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticLineChartTypeInfoHelper::get() ) );
     128           1 :         return &xPropertySetInfo;
     129             :     }
     130             : };
     131             : 
     132             : struct StaticLineChartTypeInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticLineChartTypeInfo_Initializer >
     133             : {
     134             : };
     135             : 
     136             : } // anonymous namespace
     137             : 
     138             : namespace chart
     139             : {
     140             : 
     141       11319 : LineChartType::LineChartType(
     142             :     const uno::Reference< uno::XComponentContext > & xContext ) :
     143       11319 :         ChartType( xContext )
     144             : {
     145       11319 : }
     146             : 
     147           0 : LineChartType::LineChartType( const LineChartType & rOther ) :
     148           0 :         ChartType( rOther )
     149             : {
     150           0 : }
     151             : 
     152       22622 : LineChartType::~LineChartType()
     153       22622 : {}
     154             : 
     155             : // ____ XCloneable ____
     156           0 : uno::Reference< util::XCloneable > SAL_CALL LineChartType::createClone()
     157             :     throw (uno::RuntimeException, std::exception)
     158             : {
     159           0 :     return uno::Reference< util::XCloneable >( new LineChartType( *this ));
     160             : }
     161             : 
     162             : // ____ XChartType ____
     163       27879 : OUString SAL_CALL LineChartType::getChartType()
     164             :     throw (uno::RuntimeException, std::exception)
     165             : {
     166       27879 :     return CHART2_SERVICE_NAME_CHARTTYPE_LINE;
     167             : }
     168             : 
     169             : // ____ OPropertySet ____
     170       34344 : uno::Any LineChartType::GetDefaultValue( sal_Int32 nHandle ) const
     171             :     throw(beans::UnknownPropertyException)
     172             : {
     173       34344 :     const tPropertyValueMap& rStaticDefaults = *StaticLineChartTypeDefaults::get();
     174       34344 :     tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
     175       34344 :     if( aFound == rStaticDefaults.end() )
     176           0 :         return uno::Any();
     177       34344 :     return (*aFound).second;
     178             : }
     179             : 
     180       68818 : ::cppu::IPropertyArrayHelper & SAL_CALL LineChartType::getInfoHelper()
     181             : {
     182       68818 :     return *StaticLineChartTypeInfoHelper::get();
     183             : }
     184             : 
     185             : // ____ XPropertySet ____
     186           5 : uno::Reference< beans::XPropertySetInfo > SAL_CALL LineChartType::getPropertySetInfo()
     187             :     throw (uno::RuntimeException, std::exception)
     188             : {
     189           5 :     return *StaticLineChartTypeInfo::get();
     190             : }
     191             : 
     192           6 : uno::Sequence< OUString > LineChartType::getSupportedServiceNames_Static()
     193             : {
     194           6 :     uno::Sequence< OUString > aServices( 3 );
     195           6 :     aServices[ 0 ] = CHART2_SERVICE_NAME_CHARTTYPE_LINE;
     196           6 :     aServices[ 1 ] = "com.sun.star.chart2.ChartType";
     197           6 :     aServices[ 2 ] = "com.sun.star.beans.PropertySet";
     198           6 :     return aServices;
     199             : }
     200             : 
     201             : // implement XServiceInfo methods basing upon getSupportedServiceNames_Static
     202         107 : APPHELPER_XSERVICEINFO_IMPL( LineChartType,
     203             :                              OUString("com.sun.star.comp.chart.LineChartType") );
     204             : 
     205             : } //  namespace chart
     206             : 
     207             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10