LCOV - code coverage report
Current view: top level - libreoffice/chart2/source/model/template - ColumnChartType.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 45 56 80.4 %
Date: 2012-12-17 Functions: 13 20 65.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 "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             : 
      27             : using namespace ::com::sun::star;
      28             : using ::com::sun::star::uno::Sequence;
      29             : using ::com::sun::star::beans::Property;
      30             : 
      31             : //-----------------------------------------------------------------------------
      32             : 
      33             : namespace
      34             : {
      35             : 
      36             : enum
      37             : {
      38             :     PROP_BARCHARTTYPE_OVERLAP_SEQUENCE,
      39             :     PROP_BARCHARTTYPE_GAPWIDTH_SEQUENCE
      40             : };
      41             : 
      42           2 : void lcl_AddPropertiesToVector(
      43             :     ::std::vector< Property > & rOutProperties )
      44             : {
      45             :     rOutProperties.push_back(
      46             :         Property( C2U( "OverlapSequence" ),
      47             :                   PROP_BARCHARTTYPE_OVERLAP_SEQUENCE,
      48           2 :                   ::getCppuType( reinterpret_cast< const Sequence< sal_Int32 > * >(0)),
      49             :                   beans::PropertyAttribute::BOUND
      50           4 :                   | beans::PropertyAttribute::MAYBEDEFAULT ));
      51             : 
      52             :     rOutProperties.push_back(
      53             :         Property( C2U( "GapwidthSequence" ),
      54             :                   PROP_BARCHARTTYPE_GAPWIDTH_SEQUENCE,
      55           2 :                   ::getCppuType( reinterpret_cast< const Sequence< sal_Int32 > * >(0)),
      56             :                   beans::PropertyAttribute::BOUND
      57           4 :                   | beans::PropertyAttribute::MAYBEDEFAULT ));
      58           2 : }
      59             : 
      60             : struct StaticColumnChartTypeDefaults_Initializer
      61             : {
      62           2 :     ::chart::tPropertyValueMap* operator()()
      63             :     {
      64           2 :         static ::chart::tPropertyValueMap aStaticDefaults;
      65           2 :         lcl_AddDefaultsToMap( aStaticDefaults );
      66           2 :         return &aStaticDefaults;
      67             :     }
      68             : private:
      69           2 :     void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap )
      70             :     {
      71           2 :         Sequence< sal_Int32 > aSeq(2);
      72             : 
      73           2 :         aSeq[0] = aSeq[1] = 0;
      74           2 :         ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_BARCHARTTYPE_OVERLAP_SEQUENCE, aSeq );
      75             : 
      76           2 :         aSeq[0] = aSeq[1] = 100;
      77           2 :         ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_BARCHARTTYPE_GAPWIDTH_SEQUENCE, aSeq );
      78           2 :     }
      79             : };
      80             : 
      81             : struct StaticColumnChartTypeDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticColumnChartTypeDefaults_Initializer >
      82             : {
      83             : };
      84             : 
      85             : struct StaticColumnChartTypeInfoHelper_Initializer
      86             : {
      87           2 :     ::cppu::OPropertyArrayHelper* operator()()
      88             :     {
      89           2 :         static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() );
      90           2 :         return &aPropHelper;
      91             :     }
      92             : 
      93             : private:
      94           2 :     Sequence< Property > lcl_GetPropertySequence()
      95             :     {
      96           2 :         ::std::vector< ::com::sun::star::beans::Property > aProperties;
      97           2 :         lcl_AddPropertiesToVector( aProperties );
      98             : 
      99             :         ::std::sort( aProperties.begin(), aProperties.end(),
     100           2 :                      ::chart::PropertyNameLess() );
     101             : 
     102           2 :         return ::chart::ContainerHelper::ContainerToSequence( aProperties );
     103             :     }
     104             : 
     105             : };
     106             : 
     107             : struct StaticColumnChartTypeInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticColumnChartTypeInfoHelper_Initializer >
     108             : {
     109             : };
     110             : 
     111             : struct StaticColumnChartTypeInfo_Initializer
     112             : {
     113           0 :     uno::Reference< beans::XPropertySetInfo >* operator()()
     114             :     {
     115             :         static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
     116           0 :             ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticColumnChartTypeInfoHelper::get() ) );
     117           0 :         return &xPropertySetInfo;
     118             :     }
     119             : };
     120             : 
     121             : struct StaticColumnChartTypeInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticColumnChartTypeInfo_Initializer >
     122             : {
     123             : };
     124             : 
     125             : } // anonymous namespace
     126             : 
     127             : namespace chart
     128             : {
     129             : 
     130         578 : ColumnChartType::ColumnChartType(
     131             :     const uno::Reference< uno::XComponentContext > & xContext ) :
     132         578 :         ChartType( xContext )
     133         578 : {}
     134             : 
     135           0 : ColumnChartType::ColumnChartType( const ColumnChartType & rOther ) :
     136           0 :         ChartType( rOther )
     137             : {
     138           0 : }
     139             : 
     140        1156 : ColumnChartType::~ColumnChartType()
     141        1156 : {}
     142             : 
     143             : // ____ XCloneable ____
     144           0 : uno::Reference< util::XCloneable > SAL_CALL ColumnChartType::createClone()
     145             :     throw (uno::RuntimeException)
     146             : {
     147           0 :     return uno::Reference< util::XCloneable >( new ColumnChartType( *this ));
     148             : }
     149             : 
     150             : // ____ XChartType ____
     151        4428 : ::rtl::OUString SAL_CALL ColumnChartType::getChartType()
     152             :     throw (uno::RuntimeException)
     153             : {
     154        4428 :     return CHART2_SERVICE_NAME_CHARTTYPE_COLUMN;
     155             : }
     156             : 
     157             : // ____ OPropertySet ____
     158         176 : uno::Any ColumnChartType::GetDefaultValue( sal_Int32 nHandle ) const
     159             :     throw(beans::UnknownPropertyException)
     160             : {
     161         176 :     const tPropertyValueMap& rStaticDefaults = *StaticColumnChartTypeDefaults::get();
     162         176 :     tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
     163         176 :     if( aFound == rStaticDefaults.end() )
     164           0 :         return uno::Any();
     165         176 :     return (*aFound).second;
     166             : }
     167             : 
     168         348 : ::cppu::IPropertyArrayHelper & SAL_CALL ColumnChartType::getInfoHelper()
     169             : {
     170         348 :     return *StaticColumnChartTypeInfoHelper::get();
     171             : }
     172             : 
     173             : // ____ XPropertySet ____
     174           0 : uno::Reference< beans::XPropertySetInfo > SAL_CALL ColumnChartType::getPropertySetInfo()
     175             :     throw (uno::RuntimeException)
     176             : {
     177           0 :     return *StaticColumnChartTypeInfo::get();
     178             : }
     179             : 
     180             : 
     181           2 : uno::Sequence< ::rtl::OUString > ColumnChartType::getSupportedServiceNames_Static()
     182             : {
     183           2 :     uno::Sequence< ::rtl::OUString > aServices( 2 );
     184           2 :     aServices[ 0 ] = CHART2_SERVICE_NAME_CHARTTYPE_COLUMN;
     185           2 :     aServices[ 1 ] = C2U( "com.sun.star.chart2.ChartType" );
     186           2 :     return aServices;
     187             : }
     188             : 
     189             : // implement XServiceInfo methods basing upon getSupportedServiceNames_Static
     190          12 : APPHELPER_XSERVICEINFO_IMPL( ColumnChartType,
     191             :                              C2U( "com.sun.star.comp.chart.ColumnChartType" ));
     192             : 
     193             : } //  namespace chart
     194             : 
     195             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10