LCOV - code coverage report
Current view: top level - chart2/source/model/template - ColumnChartType.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 62 70 88.6 %
Date: 2015-06-13 12:38:46 Functions: 19 22 86.4 %
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 "ColumnChartType.hxx"
      21             : #include "macros.hxx"
      22             : #include "servicenames_charttypes.hxx"
      23             : #include "PropertyHelper.hxx"
      24             : #include "ContainerHelper.hxx"
      25             : #include <com/sun/star/beans/PropertyAttribute.hpp>
      26             : #include <cppuhelper/supportsservice.hxx>
      27             : 
      28             : using namespace ::com::sun::star;
      29             : using ::com::sun::star::uno::Sequence;
      30             : using ::com::sun::star::beans::Property;
      31             : 
      32             : namespace
      33             : {
      34             : 
      35             : enum
      36             : {
      37             :     PROP_BARCHARTTYPE_OVERLAP_SEQUENCE,
      38             :     PROP_BARCHARTTYPE_GAPWIDTH_SEQUENCE
      39             : };
      40             : 
      41          14 : void lcl_AddPropertiesToVector(
      42             :     ::std::vector< Property > & rOutProperties )
      43             : {
      44             :     rOutProperties.push_back(
      45             :         Property( "OverlapSequence",
      46             :                   PROP_BARCHARTTYPE_OVERLAP_SEQUENCE,
      47          14 :                   cppu::UnoType<Sequence< sal_Int32 >>::get(),
      48             :                   beans::PropertyAttribute::BOUND
      49          28 :                   | beans::PropertyAttribute::MAYBEDEFAULT ));
      50             : 
      51             :     rOutProperties.push_back(
      52             :         Property( "GapwidthSequence",
      53             :                   PROP_BARCHARTTYPE_GAPWIDTH_SEQUENCE,
      54          14 :                   cppu::UnoType<Sequence< sal_Int32 >>::get(),
      55             :                   beans::PropertyAttribute::BOUND
      56          28 :                   | beans::PropertyAttribute::MAYBEDEFAULT ));
      57          14 : }
      58             : 
      59             : struct StaticColumnChartTypeDefaults_Initializer
      60             : {
      61          14 :     ::chart::tPropertyValueMap* operator()()
      62             :     {
      63          14 :         static ::chart::tPropertyValueMap aStaticDefaults;
      64          14 :         lcl_AddDefaultsToMap( aStaticDefaults );
      65          14 :         return &aStaticDefaults;
      66             :     }
      67             : private:
      68          14 :     static void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap )
      69             :     {
      70          14 :         Sequence< sal_Int32 > aSeq(2);
      71             : 
      72          14 :         aSeq[0] = aSeq[1] = 0;
      73          14 :         ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_BARCHARTTYPE_OVERLAP_SEQUENCE, aSeq );
      74             : 
      75          14 :         aSeq[0] = aSeq[1] = 100;
      76          14 :         ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_BARCHARTTYPE_GAPWIDTH_SEQUENCE, aSeq );
      77          14 :     }
      78             : };
      79             : 
      80             : struct StaticColumnChartTypeDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticColumnChartTypeDefaults_Initializer >
      81             : {
      82             : };
      83             : 
      84             : struct StaticColumnChartTypeInfoHelper_Initializer
      85             : {
      86          14 :     ::cppu::OPropertyArrayHelper* operator()()
      87             :     {
      88          14 :         static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() );
      89          14 :         return &aPropHelper;
      90             :     }
      91             : 
      92             : private:
      93          14 :     static Sequence< Property > lcl_GetPropertySequence()
      94             :     {
      95          14 :         ::std::vector< ::com::sun::star::beans::Property > aProperties;
      96          14 :         lcl_AddPropertiesToVector( aProperties );
      97             : 
      98             :         ::std::sort( aProperties.begin(), aProperties.end(),
      99          14 :                      ::chart::PropertyNameLess() );
     100             : 
     101          14 :         return ::chart::ContainerHelper::ContainerToSequence( aProperties );
     102             :     }
     103             : 
     104             : };
     105             : 
     106             : struct StaticColumnChartTypeInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticColumnChartTypeInfoHelper_Initializer >
     107             : {
     108             : };
     109             : 
     110             : struct StaticColumnChartTypeInfo_Initializer
     111             : {
     112           5 :     uno::Reference< beans::XPropertySetInfo >* operator()()
     113             :     {
     114             :         static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
     115           5 :             ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticColumnChartTypeInfoHelper::get() ) );
     116           5 :         return &xPropertySetInfo;
     117             :     }
     118             : };
     119             : 
     120             : struct StaticColumnChartTypeInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticColumnChartTypeInfo_Initializer >
     121             : {
     122             : };
     123             : 
     124             : } // anonymous namespace
     125             : 
     126             : namespace chart
     127             : {
     128             : 
     129       17752 : ColumnChartType::ColumnChartType(
     130             :     const uno::Reference< uno::XComponentContext > & xContext ) :
     131       17752 :         ChartType( xContext )
     132       17752 : {}
     133             : 
     134           0 : ColumnChartType::ColumnChartType( const ColumnChartType & rOther ) :
     135           0 :         ChartType( rOther )
     136             : {
     137           0 : }
     138             : 
     139       35478 : ColumnChartType::~ColumnChartType()
     140       35478 : {}
     141             : 
     142             : // ____ XCloneable ____
     143           0 : uno::Reference< util::XCloneable > SAL_CALL ColumnChartType::createClone()
     144             :     throw (uno::RuntimeException, std::exception)
     145             : {
     146           0 :     return uno::Reference< util::XCloneable >( new ColumnChartType( *this ));
     147             : }
     148             : 
     149             : // ____ XChartType ____
     150      112261 : OUString SAL_CALL ColumnChartType::getChartType()
     151             :     throw (uno::RuntimeException, std::exception)
     152             : {
     153      112261 :     return OUString(CHART2_SERVICE_NAME_CHARTTYPE_COLUMN);
     154             : }
     155             : 
     156         421 : uno::Sequence< OUString > ColumnChartType::getSupportedPropertyRoles()
     157             :     throw (uno::RuntimeException, std::exception)
     158             : {
     159         421 :     uno::Sequence< OUString > aPropRoles(2);
     160         421 :     aPropRoles[0] = "FillColor";
     161         421 :     aPropRoles[1] = "BorderColor";
     162             : 
     163         421 :     return aPropRoles;
     164             : }
     165             : 
     166             : // ____ OPropertySet ____
     167        1951 : uno::Any ColumnChartType::GetDefaultValue( sal_Int32 nHandle ) const
     168             :     throw(beans::UnknownPropertyException)
     169             : {
     170        1951 :     const tPropertyValueMap& rStaticDefaults = *StaticColumnChartTypeDefaults::get();
     171        1951 :     tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
     172        1951 :     if( aFound == rStaticDefaults.end() )
     173           0 :         return uno::Any();
     174        1951 :     return (*aFound).second;
     175             : }
     176             : 
     177        8735 : ::cppu::IPropertyArrayHelper & SAL_CALL ColumnChartType::getInfoHelper()
     178             : {
     179        8735 :     return *StaticColumnChartTypeInfoHelper::get();
     180             : }
     181             : 
     182             : // ____ XPropertySet ____
     183          91 : uno::Reference< beans::XPropertySetInfo > SAL_CALL ColumnChartType::getPropertySetInfo()
     184             :     throw (uno::RuntimeException, std::exception)
     185             : {
     186          91 :     return *StaticColumnChartTypeInfo::get();
     187             : }
     188             : 
     189           1 : uno::Sequence< OUString > ColumnChartType::getSupportedServiceNames_Static()
     190             : {
     191           1 :     uno::Sequence< OUString > aServices( 2 );
     192           1 :     aServices[ 0 ] = CHART2_SERVICE_NAME_CHARTTYPE_COLUMN;
     193           1 :     aServices[ 1 ] = "com.sun.star.chart2.ChartType";
     194           1 :     return aServices;
     195             : }
     196             : 
     197             : // implement XServiceInfo methods basing upon getSupportedServiceNames_Static
     198           1 : OUString SAL_CALL ColumnChartType::getImplementationName()
     199             :     throw( css::uno::RuntimeException, std::exception )
     200             : {
     201           1 :     return getImplementationName_Static();
     202             : }
     203             : 
     204           1 : OUString ColumnChartType::getImplementationName_Static()
     205             : {
     206           1 :     return OUString("com.sun.star.comp.chart.ColumnChartType");
     207             : }
     208             : 
     209           0 : sal_Bool SAL_CALL ColumnChartType::supportsService( const OUString& rServiceName )
     210             :     throw( css::uno::RuntimeException, std::exception )
     211             : {
     212           0 :     return cppu::supportsService(this, rServiceName);
     213             : }
     214             : 
     215           1 : css::uno::Sequence< OUString > SAL_CALL ColumnChartType::getSupportedServiceNames()
     216             :     throw( css::uno::RuntimeException, std::exception )
     217             : {
     218           1 :     return getSupportedServiceNames_Static();
     219             : }
     220             : 
     221             : } //  namespace chart
     222             : 
     223             : extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
     224       17752 : com_sun_star_comp_chart_ColumnChartType_get_implementation(css::uno::XComponentContext *context,
     225             :         css::uno::Sequence<css::uno::Any> const &)
     226             : {
     227       17752 :     return cppu::acquire(new ::chart::ColumnChartType(context));
     228             : }
     229             : 
     230             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11