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

Generated by: LCOV version 1.11