LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/chart2/source/model/template - BubbleChartTypeTemplate.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 21 78 26.9 %
Date: 2013-07-09 Functions: 11 31 35.5 %
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 "BubbleChartTypeTemplate.hxx"
      21             : #include "macros.hxx"
      22             : #include "BubbleDataInterpreter.hxx"
      23             : #include "CartesianCoordinateSystem.hxx"
      24             : #include "Scaling.hxx"
      25             : #include "DiagramHelper.hxx"
      26             : #include "servicenames_charttypes.hxx"
      27             : #include "ContainerHelper.hxx"
      28             : #include "DataSeriesHelper.hxx"
      29             : #include <com/sun/star/drawing/LineStyle.hpp>
      30             : #include "PropertyHelper.hxx"
      31             : #include <com/sun/star/beans/PropertyAttribute.hpp>
      32             : 
      33             : #include <algorithm>
      34             : 
      35             : using namespace ::com::sun::star;
      36             : 
      37             : using ::com::sun::star::uno::Reference;
      38             : using ::com::sun::star::uno::Sequence;
      39             : using ::com::sun::star::beans::Property;
      40             : using ::com::sun::star::uno::Any;
      41             : using ::osl::MutexGuard;
      42             : 
      43             : namespace
      44             : {
      45             : 
      46          11 : static const OUString lcl_aServiceName( "com.sun.star.chart2.BubbleChartTypeTemplate" );
      47             : 
      48           0 : void lcl_AddPropertiesToVector(
      49             :     ::std::vector< Property > & /*rOutProperties*/ )
      50             : {
      51           0 : }
      52             : 
      53             : struct StaticBubbleChartTypeTemplateDefaults_Initializer
      54             : {
      55           0 :     ::chart::tPropertyValueMap* operator()()
      56             :     {
      57           0 :         static ::chart::tPropertyValueMap aStaticDefaults;
      58           0 :         return &aStaticDefaults;
      59             :     }
      60             : };
      61             : 
      62             : struct StaticBubbleChartTypeTemplateDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticBubbleChartTypeTemplateDefaults_Initializer >
      63             : {
      64             : };
      65             : 
      66             : struct StaticBubbleChartTypeTemplateInfoHelper_Initializer
      67             : {
      68           0 :     ::cppu::OPropertyArrayHelper* operator()()
      69             :     {
      70           0 :         static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() );
      71           0 :         return &aPropHelper;
      72             :     }
      73             : 
      74             : private:
      75           0 :     Sequence< Property > lcl_GetPropertySequence()
      76             :     {
      77           0 :         ::std::vector< ::com::sun::star::beans::Property > aProperties;
      78           0 :         lcl_AddPropertiesToVector( aProperties );
      79             : 
      80             :         ::std::sort( aProperties.begin(), aProperties.end(),
      81           0 :                      ::chart::PropertyNameLess() );
      82             : 
      83           0 :         return ::chart::ContainerHelper::ContainerToSequence( aProperties );
      84             :     }
      85             : 
      86             : };
      87             : 
      88             : struct StaticBubbleChartTypeTemplateInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticBubbleChartTypeTemplateInfoHelper_Initializer >
      89             : {
      90             : };
      91             : 
      92             : struct StaticBubbleChartTypeTemplateInfo_Initializer
      93             : {
      94           0 :     uno::Reference< beans::XPropertySetInfo >* operator()()
      95             :     {
      96             :         static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
      97           0 :             ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticBubbleChartTypeTemplateInfoHelper::get() ) );
      98           0 :         return &xPropertySetInfo;
      99             :     }
     100             : };
     101             : 
     102             : struct StaticBubbleChartTypeTemplateInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticBubbleChartTypeTemplateInfo_Initializer >
     103             : {
     104             : };
     105             : 
     106             : } // anonymous namespace
     107             : 
     108             : namespace chart
     109             : {
     110             : 
     111         119 : BubbleChartTypeTemplate::BubbleChartTypeTemplate(
     112             :     Reference<
     113             :         uno::XComponentContext > const & xContext,
     114             :     const OUString & rServiceName ) :
     115             :         ChartTypeTemplate( xContext, rServiceName ),
     116         119 :         ::property::OPropertySet( m_aMutex )
     117             : {
     118         119 : }
     119             : 
     120         238 : BubbleChartTypeTemplate::~BubbleChartTypeTemplate()
     121         238 : {}
     122             : 
     123             : // ____ OPropertySet ____
     124           0 : uno::Any BubbleChartTypeTemplate::GetDefaultValue( sal_Int32 nHandle ) const
     125             :     throw(beans::UnknownPropertyException)
     126             : {
     127           0 :     const tPropertyValueMap& rStaticDefaults = *StaticBubbleChartTypeTemplateDefaults::get();
     128           0 :     tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
     129           0 :     if( aFound == rStaticDefaults.end() )
     130           0 :         return uno::Any();
     131           0 :     return (*aFound).second;
     132             : }
     133             : 
     134           0 : ::cppu::IPropertyArrayHelper & SAL_CALL BubbleChartTypeTemplate::getInfoHelper()
     135             : {
     136           0 :     return *StaticBubbleChartTypeTemplateInfoHelper::get();
     137             : }
     138             : 
     139             : // ____ XPropertySet ____
     140           0 : uno::Reference< beans::XPropertySetInfo > SAL_CALL BubbleChartTypeTemplate::getPropertySetInfo()
     141             :     throw (uno::RuntimeException)
     142             : {
     143           0 :     return *StaticBubbleChartTypeTemplateInfo::get();
     144             : }
     145             : 
     146         119 : sal_Int32 BubbleChartTypeTemplate::getDimension() const
     147             : {
     148         119 :     return 2;
     149             : }
     150             : 
     151           0 : StackMode BubbleChartTypeTemplate::getStackMode( sal_Int32 /* nChartTypeIndex */ ) const
     152             : {
     153           0 :     return StackMode_NONE;
     154             : }
     155             : 
     156           0 : void SAL_CALL BubbleChartTypeTemplate::applyStyle(
     157             :     const Reference< chart2::XDataSeries >& xSeries,
     158             :     ::sal_Int32 nChartTypeIndex,
     159             :     ::sal_Int32 nSeriesIndex,
     160             :     ::sal_Int32 nSeriesCount )
     161             :     throw (uno::RuntimeException)
     162             : {
     163           0 :     ChartTypeTemplate::applyStyle( xSeries, nChartTypeIndex, nSeriesIndex, nSeriesCount );
     164           0 :     DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, "BorderStyle", uno::makeAny( drawing::LineStyle_NONE ) );
     165             : 
     166             :     try
     167             :     {
     168             :     }
     169             :     catch( uno::Exception & ex )
     170             :     {
     171             :         ASSERT_EXCEPTION( ex );
     172             :     }
     173           0 : }
     174             : 
     175             : // ____ XChartTypeTemplate ____
     176           0 : sal_Bool SAL_CALL BubbleChartTypeTemplate::supportsCategories()
     177             :     throw (uno::RuntimeException)
     178             : {
     179           0 :     return false;
     180             : }
     181             : 
     182         119 : sal_Bool SAL_CALL BubbleChartTypeTemplate::matchesTemplate(
     183             :     const Reference< chart2::XDiagram >& xDiagram,
     184             :     sal_Bool bAdaptProperties )
     185             :     throw (uno::RuntimeException)
     186             : {
     187         119 :     sal_Bool bResult = ChartTypeTemplate::matchesTemplate( xDiagram, bAdaptProperties );
     188             : 
     189         119 :     if( bResult )
     190             :     {
     191             :         ::std::vector< Reference< chart2::XDataSeries > > aSeriesVec(
     192           0 :             DiagramHelper::getDataSeriesFromDiagram( xDiagram ));
     193             : 
     194           0 :         for( ::std::vector< Reference< chart2::XDataSeries > >::const_iterator aIt =
     195           0 :                  aSeriesVec.begin(); aIt != aSeriesVec.end(); ++aIt )
     196             :         {
     197             :             try
     198             :             {
     199             :             }
     200             :             catch( uno::Exception & ex )
     201             :             {
     202             :                 ASSERT_EXCEPTION( ex );
     203             :             }
     204           0 :         }
     205             :     }
     206             : 
     207             :     // adapt curve style, spline order and resolution
     208             :     if( bResult && bAdaptProperties )
     209             :     {
     210             :         try
     211             :         {
     212             :         }
     213             :         catch( uno::Exception & ex )
     214             :         {
     215             :             ASSERT_EXCEPTION( ex );
     216             :         }
     217             :     }
     218             : 
     219         119 :     return bResult;
     220             : }
     221             : 
     222           0 : Reference< chart2::XChartType > BubbleChartTypeTemplate::getChartTypeForIndex( sal_Int32 /*nChartTypeIndex*/ )
     223             : {
     224           0 :     Reference< chart2::XChartType > xResult;
     225             : 
     226             :     try
     227             :     {
     228             :         Reference< lang::XMultiServiceFactory > xFact(
     229           0 :             GetComponentContext()->getServiceManager(), uno::UNO_QUERY_THROW );
     230           0 :         xResult.set( xFact->createInstance(
     231           0 :                          CHART2_SERVICE_NAME_CHARTTYPE_BUBBLE ), uno::UNO_QUERY_THROW );
     232             :     }
     233           0 :     catch( const uno::Exception & ex )
     234             :     {
     235             :         ASSERT_EXCEPTION( ex );
     236             :     }
     237             : 
     238           0 :     return xResult;
     239             : }
     240             : 
     241         119 : Reference< chart2::XChartType > SAL_CALL BubbleChartTypeTemplate::getChartTypeForNewSeries(
     242             :         const uno::Sequence< Reference< chart2::XChartType > >& aFormerlyUsedChartTypes )
     243             :     throw (uno::RuntimeException)
     244             : {
     245         119 :     Reference< chart2::XChartType > xResult;
     246             : 
     247             :     try
     248             :     {
     249             :         Reference< lang::XMultiServiceFactory > xFact(
     250         119 :             GetComponentContext()->getServiceManager(), uno::UNO_QUERY_THROW );
     251         119 :         xResult.set( xFact->createInstance(
     252         119 :                          CHART2_SERVICE_NAME_CHARTTYPE_BUBBLE ), uno::UNO_QUERY_THROW );
     253             : 
     254         119 :         ChartTypeTemplate::copyPropertiesFromOldToNewCoordianteSystem( aFormerlyUsedChartTypes, xResult );
     255             :     }
     256           0 :     catch( const uno::Exception & ex )
     257             :     {
     258             :         ASSERT_EXCEPTION( ex );
     259             :     }
     260             : 
     261         119 :     return xResult;
     262             : }
     263             : 
     264           0 : Reference< chart2::XDataInterpreter > SAL_CALL BubbleChartTypeTemplate::getDataInterpreter()
     265             :     throw (uno::RuntimeException)
     266             : {
     267           0 :     if( ! m_xDataInterpreter.is())
     268           0 :         m_xDataInterpreter.set( new BubbleDataInterpreter( GetComponentContext()) );
     269             : 
     270           0 :     return m_xDataInterpreter;
     271             : }
     272             : 
     273             : // ----------------------------------------
     274             : 
     275           0 : Sequence< OUString > BubbleChartTypeTemplate::getSupportedServiceNames_Static()
     276             : {
     277           0 :     Sequence< OUString > aServices( 2 );
     278           0 :     aServices[ 0 ] = lcl_aServiceName;
     279           0 :     aServices[ 1 ] = "com.sun.star.chart2.ChartTypeTemplate";
     280           0 :     return aServices;
     281             : }
     282             : 
     283             : // implement XServiceInfo methods basing upon getSupportedServiceNames_Static
     284           0 : APPHELPER_XSERVICEINFO_IMPL( BubbleChartTypeTemplate, lcl_aServiceName );
     285             : 
     286         952 : IMPLEMENT_FORWARD_XINTERFACE2( BubbleChartTypeTemplate, ChartTypeTemplate, OPropertySet )
     287           0 : IMPLEMENT_FORWARD_XTYPEPROVIDER2( BubbleChartTypeTemplate, ChartTypeTemplate, OPropertySet )
     288             : 
     289          33 : } //  namespace chart
     290             : 
     291             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10