LCOV - code coverage report
Current view: top level - chart2/source/model/template - BubbleChartType.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 14 74 18.9 %
Date: 2014-04-11 Functions: 6 23 26.1 %
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 "BubbleChartType.hxx"
      21             : #include "PropertyHelper.hxx"
      22             : #include "macros.hxx"
      23             : #include "servicenames_charttypes.hxx"
      24             : #include "ContainerHelper.hxx"
      25             : #include "CartesianCoordinateSystem.hxx"
      26             : #include "AxisHelper.hxx"
      27             : #include "AxisIndexDefines.hxx"
      28             : #include <com/sun/star/beans/PropertyAttribute.hpp>
      29             : #include <com/sun/star/chart2/AxisType.hpp>
      30             : #include <com/sun/star/chart2/CurveStyle.hpp>
      31             : 
      32             : using namespace ::com::sun::star;
      33             : 
      34             : using ::com::sun::star::beans::Property;
      35             : using ::com::sun::star::uno::Sequence;
      36             : using ::com::sun::star::uno::Reference;
      37             : using ::com::sun::star::uno::Any;
      38             : using ::osl::MutexGuard;
      39             : 
      40             : namespace
      41             : {
      42             : 
      43           0 : void lcl_AddPropertiesToVector(
      44             :     ::std::vector< Property > & /*rOutProperties*/ )
      45             : {
      46           0 : }
      47             : 
      48             : struct StaticBubbleChartTypeDefaults_Initializer
      49             : {
      50           0 :     ::chart::tPropertyValueMap* operator()()
      51             :     {
      52           0 :         static ::chart::tPropertyValueMap aStaticDefaults;
      53           0 :         return &aStaticDefaults;
      54             :     }
      55             : };
      56             : 
      57             : struct StaticBubbleChartTypeDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticBubbleChartTypeDefaults_Initializer >
      58             : {
      59             : };
      60             : 
      61             : struct StaticBubbleChartTypeInfoHelper_Initializer
      62             : {
      63           0 :     ::cppu::OPropertyArrayHelper* operator()()
      64             :     {
      65           0 :         static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() );
      66           0 :         return &aPropHelper;
      67             :     }
      68             : 
      69             : private:
      70           0 :     Sequence< Property > lcl_GetPropertySequence()
      71             :     {
      72           0 :         ::std::vector< ::com::sun::star::beans::Property > aProperties;
      73           0 :         lcl_AddPropertiesToVector( aProperties );
      74             : 
      75             :         ::std::sort( aProperties.begin(), aProperties.end(),
      76           0 :                      ::chart::PropertyNameLess() );
      77             : 
      78           0 :         return ::chart::ContainerHelper::ContainerToSequence( aProperties );
      79             :     }
      80             : };
      81             : 
      82             : struct StaticBubbleChartTypeInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticBubbleChartTypeInfoHelper_Initializer >
      83             : {
      84             : };
      85             : 
      86             : struct StaticBubbleChartTypeInfo_Initializer
      87             : {
      88           0 :     uno::Reference< beans::XPropertySetInfo >* operator()()
      89             :     {
      90             :         static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
      91           0 :             ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticBubbleChartTypeInfoHelper::get() ) );
      92           0 :         return &xPropertySetInfo;
      93             :     }
      94             : };
      95             : 
      96             : struct StaticBubbleChartTypeInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticBubbleChartTypeInfo_Initializer >
      97             : {
      98             : };
      99             : 
     100             : } // anonymous namespace
     101             : 
     102             : namespace chart
     103             : {
     104             : 
     105        1750 : BubbleChartType::BubbleChartType(
     106             :     const uno::Reference< uno::XComponentContext > & xContext )
     107        1750 :     : ChartType( xContext )
     108             : {
     109        1750 : }
     110             : 
     111           0 : BubbleChartType::BubbleChartType( const BubbleChartType & rOther ) :
     112           0 :         ChartType( rOther )
     113             : {
     114           0 : }
     115             : 
     116        3500 : BubbleChartType::~BubbleChartType()
     117        3500 : {}
     118             : 
     119             : // ____ XCloneable ____
     120           0 : uno::Reference< util::XCloneable > SAL_CALL BubbleChartType::createClone()
     121             :     throw (uno::RuntimeException, std::exception)
     122             : {
     123           0 :     return uno::Reference< util::XCloneable >( new BubbleChartType( *this ));
     124             : }
     125             : 
     126             : // ____ XChartType ____
     127             : Reference< chart2::XCoordinateSystem > SAL_CALL
     128           0 :     BubbleChartType::createCoordinateSystem( ::sal_Int32 DimensionCount )
     129             :     throw (lang::IllegalArgumentException,
     130             :            uno::RuntimeException, std::exception)
     131             : {
     132             :     Reference< chart2::XCoordinateSystem > xResult(
     133             :         new CartesianCoordinateSystem(
     134           0 :             GetComponentContext(), DimensionCount, /* bSwapXAndYAxis */ sal_False ));
     135             : 
     136           0 :     for( sal_Int32 i=0; i<DimensionCount; ++i )
     137             :     {
     138           0 :         Reference< chart2::XAxis > xAxis( xResult->getAxisByDimension( i, MAIN_AXIS_INDEX ) );
     139           0 :         if( !xAxis.is() )
     140             :         {
     141             :             OSL_FAIL("a created coordinate system should have an axis for each dimension");
     142           0 :             continue;
     143             :         }
     144             : 
     145           0 :         chart2::ScaleData aScaleData = xAxis->getScaleData();
     146           0 :         aScaleData.Orientation = chart2::AxisOrientation_MATHEMATICAL;
     147           0 :         aScaleData.Scaling = AxisHelper::createLinearScaling();
     148             : 
     149           0 :         if( i == 2  )
     150           0 :             aScaleData.AxisType = chart2::AxisType::SERIES;
     151             :         else
     152           0 :             aScaleData.AxisType = chart2::AxisType::REALNUMBER;
     153             : 
     154           0 :         xAxis->setScaleData( aScaleData );
     155           0 :     }
     156             : 
     157           0 :     return xResult;
     158             : }
     159             : 
     160        3500 : OUString SAL_CALL BubbleChartType::getChartType()
     161             :     throw (uno::RuntimeException, std::exception)
     162             : {
     163        3500 :     return CHART2_SERVICE_NAME_CHARTTYPE_BUBBLE;
     164             : }
     165             : 
     166           0 : uno::Sequence< OUString > SAL_CALL BubbleChartType::getSupportedMandatoryRoles()
     167             :     throw (uno::RuntimeException, std::exception)
     168             : {
     169           0 :     uno::Sequence< OUString > aMandRolesSeq(4);
     170           0 :     aMandRolesSeq[0] = "label";
     171           0 :     aMandRolesSeq[1] = "values-x";
     172           0 :     aMandRolesSeq[2] = "values-y";
     173           0 :     aMandRolesSeq[3] = "values-size";
     174           0 :     return aMandRolesSeq;
     175             : }
     176             : 
     177           0 : uno::Sequence< OUString > SAL_CALL BubbleChartType::getSupportedPropertyRoles()
     178             :     throw(com::sun::star::uno::RuntimeException, std::exception)
     179             : {
     180           0 :     uno::Sequence< OUString > aPropertyRoles(2);
     181           0 :     aPropertyRoles[0] = "FillColor";
     182           0 :     aPropertyRoles[1] = "BorderColor";
     183           0 :     return aPropertyRoles;
     184             : }
     185             : 
     186           0 : OUString SAL_CALL BubbleChartType::getRoleOfSequenceForSeriesLabel()
     187             :     throw (uno::RuntimeException, std::exception)
     188             : {
     189           0 :     return OUString("values-size");
     190             : }
     191             : 
     192             : // ____ OPropertySet ____
     193           0 : uno::Any BubbleChartType::GetDefaultValue( sal_Int32 nHandle ) const
     194             :     throw(beans::UnknownPropertyException)
     195             : {
     196           0 :     const tPropertyValueMap& rStaticDefaults = *StaticBubbleChartTypeDefaults::get();
     197           0 :     tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
     198           0 :     if( aFound == rStaticDefaults.end() )
     199           0 :         return uno::Any();
     200           0 :     return (*aFound).second;
     201             : }
     202             : 
     203             : // ____ OPropertySet ____
     204           0 : ::cppu::IPropertyArrayHelper & SAL_CALL BubbleChartType::getInfoHelper()
     205             : {
     206           0 :     return *StaticBubbleChartTypeInfoHelper::get();
     207             : }
     208             : 
     209             : // ____ XPropertySet ____
     210           0 : uno::Reference< beans::XPropertySetInfo > SAL_CALL BubbleChartType::getPropertySetInfo()
     211             :     throw (uno::RuntimeException, std::exception)
     212             : {
     213           0 :     return *StaticBubbleChartTypeInfo::get();
     214             : }
     215             : 
     216          11 : uno::Sequence< OUString > BubbleChartType::getSupportedServiceNames_Static()
     217             : {
     218          11 :     uno::Sequence< OUString > aServices( 3 );
     219          11 :     aServices[ 0 ] = CHART2_SERVICE_NAME_CHARTTYPE_BUBBLE;
     220          11 :     aServices[ 1 ] = "com.sun.star.chart2.ChartType";
     221          11 :     aServices[ 2 ] = "com.sun.star.beans.PropertySet";
     222          11 :     return aServices;
     223             : }
     224             : 
     225             : // implement XServiceInfo methods basing upon getSupportedServiceNames_Static
     226         107 : APPHELPER_XSERVICEINFO_IMPL( BubbleChartType,
     227             :                              OUString("com.sun.star.comp.chart.BubbleChartType") );
     228             : 
     229             : } //  namespace chart
     230             : 
     231             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10