LCOV - code coverage report
Current view: top level - chart2/source/model/main - PageBackground.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 62 80 77.5 %
Date: 2015-06-13 12:38:46 Functions: 22 28 78.6 %
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 "PageBackground.hxx"
      21             : #include "macros.hxx"
      22             : #include "LinePropertiesHelper.hxx"
      23             : #include "FillProperties.hxx"
      24             : #include "UserDefinedProperties.hxx"
      25             : #include "ContainerHelper.hxx"
      26             : #include "PropertyHelper.hxx"
      27             : 
      28             : #include <com/sun/star/drawing/LineStyle.hpp>
      29             : #include <rtl/uuid.h>
      30             : #include <cppuhelper/queryinterface.hxx>
      31             : #include <cppuhelper/supportsservice.hxx>
      32             : 
      33             : #include <vector>
      34             : #include <algorithm>
      35             : 
      36             : using namespace ::com::sun::star;
      37             : 
      38             : using ::com::sun::star::beans::Property;
      39             : using ::osl::MutexGuard;
      40             : 
      41             : namespace
      42             : {
      43             : 
      44             : static const char lcl_aServiceName[] = "com.sun.star.comp.chart2.PageBackground";
      45             : 
      46             : struct StaticPageBackgroundDefaults_Initializer
      47             : {
      48          17 :     ::chart::tPropertyValueMap* operator()()
      49             :     {
      50          17 :         static ::chart::tPropertyValueMap aStaticDefaults;
      51          17 :         lcl_AddDefaultsToMap( aStaticDefaults );
      52          17 :         return &aStaticDefaults;
      53             :     }
      54             : private:
      55          17 :     static void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap )
      56             :     {
      57          17 :         ::chart::LinePropertiesHelper::AddDefaultsToMap( rOutMap );
      58          17 :         ::chart::FillProperties::AddDefaultsToMap( rOutMap );
      59             : 
      60             :         // override other defaults
      61          17 :         ::chart::PropertyHelper::setPropertyValue< sal_Int32 >( rOutMap, ::chart::FillProperties::PROP_FILL_COLOR, 0xffffff );
      62          17 :         ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::LinePropertiesHelper::PROP_LINE_STYLE, drawing::LineStyle_NONE );
      63          17 :     }
      64             : };
      65             : 
      66             : struct StaticPageBackgroundDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticPageBackgroundDefaults_Initializer >
      67             : {
      68             : };
      69             : 
      70             : struct StaticPageBackgroundInfoHelper_Initializer
      71             : {
      72          17 :     ::cppu::OPropertyArrayHelper* operator()()
      73             :     {
      74          17 :         static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() );
      75          17 :         return &aPropHelper;
      76             :     }
      77             : 
      78             : private:
      79          17 :     static uno::Sequence< Property > lcl_GetPropertySequence()
      80             :     {
      81          17 :         ::std::vector< ::com::sun::star::beans::Property > aProperties;
      82          17 :          ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties );
      83          17 :         ::chart::FillProperties::AddPropertiesToVector( aProperties );
      84          17 :         ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
      85             : 
      86             :         ::std::sort( aProperties.begin(), aProperties.end(),
      87          17 :                      ::chart::PropertyNameLess() );
      88             : 
      89          17 :         return ::chart::ContainerHelper::ContainerToSequence( aProperties );
      90             :     }
      91             : 
      92             : };
      93             : 
      94             : struct StaticPageBackgroundInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticPageBackgroundInfoHelper_Initializer >
      95             : {
      96             : };
      97             : 
      98             : struct StaticPageBackgroundInfo_Initializer
      99             : {
     100           6 :     uno::Reference< beans::XPropertySetInfo >* operator()()
     101             :     {
     102             :         static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
     103           6 :             ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticPageBackgroundInfoHelper::get() ) );
     104           6 :         return &xPropertySetInfo;
     105             :     }
     106             : };
     107             : 
     108             : struct StaticPageBackgroundInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticPageBackgroundInfo_Initializer >
     109             : {
     110             : };
     111             : 
     112             : } // anonymous namespace
     113             : 
     114             : namespace chart
     115             : {
     116             : 
     117         322 : PageBackground::PageBackground( const uno::Reference< uno::XComponentContext > & xContext ) :
     118             :         ::property::OPropertySet( m_aMutex ),
     119             :     m_xContext( xContext ),
     120         322 :     m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
     121         322 : {}
     122             : 
     123           0 : PageBackground::PageBackground( const PageBackground & rOther ) :
     124             :         MutexContainer(),
     125             :         impl::PageBackground_Base(),
     126             :         ::property::OPropertySet( rOther, m_aMutex ),
     127             :     m_xContext( rOther.m_xContext ),
     128           0 :     m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
     129           0 : {}
     130             : 
     131         644 : PageBackground::~PageBackground()
     132         644 : {}
     133             : 
     134             : // ____ XCloneable ____
     135           0 : uno::Reference< util::XCloneable > SAL_CALL PageBackground::createClone()
     136             :     throw (uno::RuntimeException, std::exception)
     137             : {
     138           0 :     return uno::Reference< util::XCloneable >( new PageBackground( *this ));
     139             : }
     140             : 
     141             : // ____ OPropertySet ____
     142       29575 : uno::Any PageBackground::GetDefaultValue( sal_Int32 nHandle ) const
     143             :     throw(beans::UnknownPropertyException)
     144             : {
     145       29575 :     const tPropertyValueMap& rStaticDefaults = *StaticPageBackgroundDefaults::get();
     146       29575 :     tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
     147       29575 :     if( aFound == rStaticDefaults.end() )
     148        6847 :         return uno::Any();
     149       22728 :     return (*aFound).second;
     150             : }
     151             : 
     152       73927 : ::cppu::IPropertyArrayHelper & SAL_CALL PageBackground::getInfoHelper()
     153             : {
     154       73927 :     return *StaticPageBackgroundInfoHelper::get();
     155             : }
     156             : 
     157             : // ____ XPropertySet ____
     158         165 : uno::Reference< beans::XPropertySetInfo > SAL_CALL PageBackground::getPropertySetInfo()
     159             :     throw (uno::RuntimeException, std::exception)
     160             : {
     161         165 :     return *StaticPageBackgroundInfo::get();
     162             : }
     163             : 
     164             : // ____ XModifyBroadcaster ____
     165         321 : void SAL_CALL PageBackground::addModifyListener( const uno::Reference< util::XModifyListener >& aListener )
     166             :     throw (uno::RuntimeException, std::exception)
     167             : {
     168             :     try
     169             :     {
     170         321 :         uno::Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
     171         321 :         xBroadcaster->addModifyListener( aListener );
     172             :     }
     173           0 :     catch( const uno::Exception & ex )
     174             :     {
     175             :         ASSERT_EXCEPTION( ex );
     176             :     }
     177         321 : }
     178             : 
     179           0 : void SAL_CALL PageBackground::removeModifyListener( const uno::Reference< util::XModifyListener >& aListener )
     180             :     throw (uno::RuntimeException, std::exception)
     181             : {
     182             :     try
     183             :     {
     184           0 :         uno::Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
     185           0 :         xBroadcaster->removeModifyListener( aListener );
     186             :     }
     187           0 :     catch( const uno::Exception & ex )
     188             :     {
     189             :         ASSERT_EXCEPTION( ex );
     190             :     }
     191           0 : }
     192             : 
     193             : // ____ XModifyListener ____
     194           0 : void SAL_CALL PageBackground::modified( const lang::EventObject& aEvent )
     195             :     throw (uno::RuntimeException, std::exception)
     196             : {
     197           0 :     m_xModifyEventForwarder->modified( aEvent );
     198           0 : }
     199             : 
     200             : // ____ XEventListener (base of XModifyListener) ____
     201           0 : void SAL_CALL PageBackground::disposing( const lang::EventObject& /* Source */ )
     202             :     throw (uno::RuntimeException, std::exception)
     203             : {
     204             :     // nothing
     205           0 : }
     206             : 
     207             : // ____ OPropertySet ____
     208         397 : void PageBackground::firePropertyChangeEvent()
     209             : {
     210         397 :     fireModifyEvent();
     211         397 : }
     212             : 
     213         397 : void PageBackground::fireModifyEvent()
     214             : {
     215         397 :     m_xModifyEventForwarder->modified( lang::EventObject( static_cast< uno::XWeak* >( this )));
     216         397 : }
     217             : 
     218           1 : uno::Sequence< OUString > PageBackground::getSupportedServiceNames_Static()
     219             : {
     220           1 :     uno::Sequence< OUString > aServices( 2 );
     221           1 :     aServices[ 0 ] = "com.sun.star.chart2.PageBackground";
     222           1 :     aServices[ 1 ] = "com.sun.star.beans.PropertySet";
     223           1 :     return aServices;
     224             : }
     225             : 
     226             : // implement XServiceInfo methods basing upon getSupportedServiceNames_Static
     227           1 : OUString SAL_CALL PageBackground::getImplementationName()
     228             :     throw( css::uno::RuntimeException, std::exception )
     229             : {
     230           1 :     return getImplementationName_Static();
     231             : }
     232             : 
     233           1 : OUString PageBackground::getImplementationName_Static()
     234             : {
     235           1 :     return OUString(lcl_aServiceName);
     236             : }
     237             : 
     238           0 : sal_Bool SAL_CALL PageBackground::supportsService( const OUString& rServiceName )
     239             :     throw( css::uno::RuntimeException, std::exception )
     240             : {
     241           0 :     return cppu::supportsService(this, rServiceName);
     242             : }
     243             : 
     244           1 : css::uno::Sequence< OUString > SAL_CALL PageBackground::getSupportedServiceNames()
     245             :     throw( css::uno::RuntimeException, std::exception )
     246             : {
     247           1 :     return getSupportedServiceNames_Static();
     248             : }
     249             : 
     250             : using impl::PageBackground_Base;
     251             : 
     252      117162 : IMPLEMENT_FORWARD_XINTERFACE2( PageBackground, PageBackground_Base, ::property::OPropertySet )
     253             : 
     254             : } //  namespace chart
     255             : 
     256             : extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
     257           1 : com_sun_star_comp_chart2_PageBackground_get_implementation(css::uno::XComponentContext *context,
     258             :         css::uno::Sequence<css::uno::Any> const &)
     259             : {
     260           1 :     return cppu::acquire(new ::chart::PageBackground(context));
     261             : }
     262             : 
     263             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11