LCOV - code coverage report
Current view: top level - chart2/source/model/template - NetChartType.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 47 58 81.0 %
Date: 2014-11-03 Functions: 15 23 65.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 "NetChartType.hxx"
      21             : #include "PropertyHelper.hxx"
      22             : #include "macros.hxx"
      23             : #include "PolarCoordinateSystem.hxx"
      24             : #include "servicenames_charttypes.hxx"
      25             : #include "ContainerHelper.hxx"
      26             : #include "AxisIndexDefines.hxx"
      27             : #include "AxisHelper.hxx"
      28             : 
      29             : #include <com/sun/star/beans/PropertyAttribute.hpp>
      30             : #include <com/sun/star/chart2/AxisType.hpp>
      31             : 
      32             : using namespace ::com::sun::star;
      33             : using namespace ::com::sun::star::chart2;
      34             : 
      35             : using ::com::sun::star::beans::Property;
      36             : using ::com::sun::star::uno::Sequence;
      37             : using ::com::sun::star::uno::Reference;
      38             : using ::com::sun::star::uno::Any;
      39             : using ::osl::MutexGuard;
      40             : 
      41             : namespace chart
      42             : {
      43             : 
      44       35482 : NetChartType_Base::NetChartType_Base(
      45             :     const uno::Reference< uno::XComponentContext > & xContext ) :
      46       35482 :         ChartType( xContext )
      47       35482 : {}
      48             : 
      49           0 : NetChartType_Base::NetChartType_Base( const NetChartType_Base & rOther ) :
      50           0 :         ChartType( rOther )
      51             : {
      52           0 : }
      53             : 
      54       35482 : NetChartType_Base::~NetChartType_Base()
      55       35482 : {}
      56             : 
      57             : Reference< XCoordinateSystem > SAL_CALL
      58           4 :     NetChartType_Base::createCoordinateSystem( ::sal_Int32 DimensionCount )
      59             :     throw (lang::IllegalArgumentException,
      60             :            uno::RuntimeException, std::exception)
      61             : {
      62           4 :     if( DimensionCount != 2 )
      63             :         throw lang::IllegalArgumentException(
      64             :             "NetChart must be two-dimensional",
      65           0 :             static_cast< ::cppu::OWeakObject* >( this ), 0 );
      66             : 
      67             :     Reference< XCoordinateSystem > xResult(
      68             :         new PolarCoordinateSystem(
      69           4 :             GetComponentContext(), DimensionCount, /* bSwapXAndYAxis */ false ));
      70             : 
      71           8 :     Reference< XAxis > xAxis( xResult->getAxisByDimension( 0, MAIN_AXIS_INDEX ) );
      72           4 :     if( xAxis.is() )
      73             :     {
      74           4 :         ScaleData aScaleData = xAxis->getScaleData();
      75           4 :         aScaleData.Scaling = AxisHelper::createLinearScaling();
      76           4 :         aScaleData.AxisType = AxisType::CATEGORY;
      77           4 :         aScaleData.Orientation = AxisOrientation_MATHEMATICAL;
      78           4 :         xAxis->setScaleData( aScaleData );
      79             :     }
      80             : 
      81           4 :     xAxis = xResult->getAxisByDimension( 1, MAIN_AXIS_INDEX );
      82           4 :     if( xAxis.is() )
      83             :     {
      84           4 :         ScaleData aScaleData = xAxis->getScaleData();
      85           4 :         aScaleData.Orientation = AxisOrientation_MATHEMATICAL;
      86           4 :         aScaleData.AxisType = AxisType::REALNUMBER;
      87           4 :         xAxis->setScaleData( aScaleData );
      88             :     }
      89             : 
      90           8 :     return xResult;
      91             : }
      92             : 
      93             : // ____ OPropertySet ____
      94           0 : uno::Any NetChartType_Base::GetDefaultValue( sal_Int32 /*nHandle*/ ) const
      95             :     throw(beans::UnknownPropertyException)
      96             : {
      97           0 :     return uno::Any();
      98             : }
      99             : 
     100             : namespace
     101             : {
     102             : 
     103             : struct StaticNetChartTypeInfoHelper_Initializer
     104             : {
     105           2 :     ::cppu::OPropertyArrayHelper* operator()()
     106             :     {
     107             :         // using assignment for broken gcc 3.3
     108             :         static ::cppu::OPropertyArrayHelper aPropHelper = ::cppu::OPropertyArrayHelper(
     109           2 :             Sequence< beans::Property >() );
     110           2 :         return &aPropHelper;
     111             :     }
     112             : };
     113             : 
     114             : struct StaticNetChartTypeInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticNetChartTypeInfoHelper_Initializer >
     115             : {
     116             : };
     117             : 
     118             : struct StaticNetChartTypeInfo_Initializer
     119             : {
     120           2 :     uno::Reference< beans::XPropertySetInfo >* operator()()
     121             :     {
     122             :         static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
     123           2 :             ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticNetChartTypeInfoHelper::get() ) );
     124           2 :         return &xPropertySetInfo;
     125             :     }
     126             : };
     127             : 
     128             : struct StaticNetChartTypeInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticNetChartTypeInfo_Initializer >
     129             : {
     130             : };
     131             : 
     132             : }
     133             : 
     134             : // ____ OPropertySet ____
     135         336 : ::cppu::IPropertyArrayHelper & SAL_CALL NetChartType_Base::getInfoHelper()
     136             : {
     137         336 :     return *StaticNetChartTypeInfoHelper::get();
     138             : }
     139             : 
     140             : // ____ XPropertySet ____
     141           4 : uno::Reference< beans::XPropertySetInfo > SAL_CALL NetChartType_Base::getPropertySetInfo()
     142             :     throw (uno::RuntimeException, std::exception)
     143             : {
     144           4 :     return *StaticNetChartTypeInfo::get();
     145             : }
     146             : 
     147       26214 : NetChartType::NetChartType(
     148             :     const uno::Reference< uno::XComponentContext > & xContext ) :
     149       26214 :         NetChartType_Base( xContext )
     150       26214 : {}
     151             : 
     152           0 : NetChartType::NetChartType( const NetChartType & rOther ) :
     153           0 :         NetChartType_Base( rOther )
     154             : {
     155           0 : }
     156             : 
     157       52428 : NetChartType::~NetChartType()
     158       52428 : {}
     159             : 
     160             : // ____ XCloneable ____
     161           0 : uno::Reference< util::XCloneable > SAL_CALL NetChartType::createClone()
     162             :     throw (uno::RuntimeException, std::exception)
     163             : {
     164           0 :     return uno::Reference< util::XCloneable >( new NetChartType( *this ));
     165             : }
     166             : 
     167             : // ____ XChartType ____
     168       52428 : OUString SAL_CALL NetChartType::getChartType()
     169             :     throw (uno::RuntimeException, std::exception)
     170             : {
     171       52428 :     return CHART2_SERVICE_NAME_CHARTTYPE_NET;
     172             : }
     173             : 
     174          14 : uno::Sequence< OUString > NetChartType::getSupportedServiceNames_Static()
     175             : {
     176          14 :     uno::Sequence< OUString > aServices( 3 );
     177          14 :     aServices[ 0 ] = CHART2_SERVICE_NAME_CHARTTYPE_NET;
     178          14 :     aServices[ 1 ] = "com.sun.star.chart2.ChartType";
     179          14 :     aServices[ 2 ] = "com.sun.star.beans.PropertySet";
     180          14 :     return aServices;
     181             : }
     182             : 
     183             : // implement XServiceInfo methods basing upon getSupportedServiceNames_Static
     184         236 : APPHELPER_XSERVICEINFO_IMPL( NetChartType,
     185             :                              OUString("com.sun.star.comp.chart.NetChartType") );
     186             : 
     187         108 : } //  namespace chart
     188             : 
     189             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10