LCOV - code coverage report
Current view: top level - chart2/source/model/main - PageBackground.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 47 73 64.4 %
Date: 2012-08-25 Functions: 18 29 62.1 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 37 122 30.3 %

           Branch data     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 "LineProperties.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                 :            : 
      32                 :            : #include <vector>
      33                 :            : #include <algorithm>
      34                 :            : 
      35                 :            : using namespace ::com::sun::star;
      36                 :            : 
      37                 :            : using ::com::sun::star::beans::Property;
      38                 :            : using ::osl::MutexGuard;
      39                 :            : 
      40                 :            : namespace
      41                 :            : {
      42                 :            : 
      43                 :         16 : static const ::rtl::OUString lcl_aServiceName(
      44                 :            :     RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.chart2.PageBackground" ));
      45                 :            : 
      46                 :            : struct StaticPageBackgroundDefaults_Initializer
      47                 :            : {
      48                 :         12 :     ::chart::tPropertyValueMap* operator()()
      49                 :            :     {
      50 [ +  - ][ +  - ]:         12 :         static ::chart::tPropertyValueMap aStaticDefaults;
         [ +  - ][ #  # ]
      51                 :         12 :         lcl_AddDefaultsToMap( aStaticDefaults );
      52                 :         12 :         return &aStaticDefaults;
      53                 :            :     }
      54                 :            : private:
      55                 :         12 :     void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap )
      56                 :            :     {
      57                 :         12 :         ::chart::LineProperties::AddDefaultsToMap( rOutMap );
      58                 :         12 :         ::chart::FillProperties::AddDefaultsToMap( rOutMap );
      59                 :            : 
      60                 :            :         // override other defaults
      61         [ +  - ]:         12 :         ::chart::PropertyHelper::setPropertyValue< sal_Int32 >( rOutMap, ::chart::FillProperties::PROP_FILL_COLOR, 0xffffff );
      62         [ +  - ]:         12 :         ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::LineProperties::PROP_LINE_STYLE, drawing::LineStyle_NONE );
      63                 :         12 :     }
      64                 :            : };
      65                 :            : 
      66                 :            : struct StaticPageBackgroundDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticPageBackgroundDefaults_Initializer >
      67                 :            : {
      68                 :            : };
      69                 :            : 
      70                 :            : struct StaticPageBackgroundInfoHelper_Initializer
      71                 :            : {
      72                 :         12 :     ::cppu::OPropertyArrayHelper* operator()()
      73                 :            :     {
      74 [ +  - ][ +  - ]:         12 :         static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() );
         [ +  - ][ +  - ]
         [ +  - ][ #  # ]
      75                 :         12 :         return &aPropHelper;
      76                 :            :     }
      77                 :            : 
      78                 :            : private:
      79                 :         12 :     uno::Sequence< Property > lcl_GetPropertySequence()
      80                 :            :     {
      81         [ +  - ]:         12 :         ::std::vector< ::com::sun::star::beans::Property > aProperties;
      82         [ +  - ]:         12 :          ::chart::LineProperties::AddPropertiesToVector( aProperties );
      83         [ +  - ]:         12 :         ::chart::FillProperties::AddPropertiesToVector( aProperties );
      84         [ +  - ]:         12 :         ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
      85                 :            : 
      86                 :            :         ::std::sort( aProperties.begin(), aProperties.end(),
      87         [ +  - ]:         12 :                      ::chart::PropertyNameLess() );
      88                 :            : 
      89         [ +  - ]:         12 :         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                 :          0 :     uno::Reference< beans::XPropertySetInfo >* operator()()
     101                 :            :     {
     102                 :            :         static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
     103 [ #  # ][ #  # ]:          0 :             ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticPageBackgroundInfoHelper::get() ) );
         [ #  # ][ #  # ]
                 [ #  # ]
     104                 :          0 :         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                 :            : // ================================================================================
     115                 :            : 
     116                 :            : namespace chart
     117                 :            : {
     118                 :            : 
     119                 :         56 : PageBackground::PageBackground( const uno::Reference< uno::XComponentContext > & xContext ) :
     120                 :            :         ::property::OPropertySet( m_aMutex ),
     121                 :            :     m_xContext( xContext ),
     122 [ +  - ][ +  - ]:         56 :     m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
                 [ +  - ]
     123                 :         56 : {}
     124                 :            : 
     125                 :          0 : PageBackground::PageBackground( const PageBackground & rOther ) :
     126                 :            :         MutexContainer(),
     127                 :            :         impl::PageBackground_Base(),
     128                 :            :         ::property::OPropertySet( rOther, m_aMutex ),
     129                 :            :     m_xContext( rOther.m_xContext ),
     130 [ #  # ][ #  # ]:          0 :     m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
                 [ #  # ]
     131                 :          0 : {}
     132                 :            : 
     133 [ +  - ][ +  - ]:         56 : PageBackground::~PageBackground()
     134         [ -  + ]:        112 : {}
     135                 :            : 
     136                 :            : // ____ XCloneable ____
     137                 :          0 : uno::Reference< util::XCloneable > SAL_CALL PageBackground::createClone()
     138                 :            :     throw (uno::RuntimeException)
     139                 :            : {
     140 [ #  # ][ #  # ]:          0 :     return uno::Reference< util::XCloneable >( new PageBackground( *this ));
     141                 :            : }
     142                 :            : 
     143                 :            : // ================================================================================
     144                 :            : 
     145                 :            : // ____ OPropertySet ____
     146                 :      24277 : uno::Any PageBackground::GetDefaultValue( sal_Int32 nHandle ) const
     147                 :            :     throw(beans::UnknownPropertyException)
     148                 :            : {
     149         [ +  - ]:      24277 :     const tPropertyValueMap& rStaticDefaults = *StaticPageBackgroundDefaults::get();
     150         [ +  - ]:      24277 :     tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
     151         [ +  + ]:      24277 :     if( aFound == rStaticDefaults.end() )
     152                 :       5756 :         return uno::Any();
     153                 :      24277 :     return (*aFound).second;
     154                 :            : }
     155                 :            : 
     156                 :      52382 : ::cppu::IPropertyArrayHelper & SAL_CALL PageBackground::getInfoHelper()
     157                 :            : {
     158                 :      52382 :     return *StaticPageBackgroundInfoHelper::get();
     159                 :            : }
     160                 :            : 
     161                 :            : // ____ XPropertySet ____
     162                 :          0 : uno::Reference< beans::XPropertySetInfo > SAL_CALL PageBackground::getPropertySetInfo()
     163                 :            :     throw (uno::RuntimeException)
     164                 :            : {
     165                 :          0 :     return *StaticPageBackgroundInfo::get();
     166                 :            : }
     167                 :            : 
     168                 :            : // ____ XModifyBroadcaster ____
     169                 :         56 : void SAL_CALL PageBackground::addModifyListener( const uno::Reference< util::XModifyListener >& aListener )
     170                 :            :     throw (uno::RuntimeException)
     171                 :            : {
     172                 :            :     try
     173                 :            :     {
     174         [ +  - ]:         56 :         uno::Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
     175 [ +  - ][ +  - ]:         56 :         xBroadcaster->addModifyListener( aListener );
                 [ #  # ]
     176                 :            :     }
     177                 :          0 :     catch( const uno::Exception & ex )
     178                 :            :     {
     179                 :            :         ASSERT_EXCEPTION( ex );
     180                 :            :     }
     181                 :         56 : }
     182                 :            : 
     183                 :          0 : void SAL_CALL PageBackground::removeModifyListener( const uno::Reference< util::XModifyListener >& aListener )
     184                 :            :     throw (uno::RuntimeException)
     185                 :            : {
     186                 :            :     try
     187                 :            :     {
     188         [ #  # ]:          0 :         uno::Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
     189 [ #  # ][ #  # ]:          0 :         xBroadcaster->removeModifyListener( aListener );
                 [ #  # ]
     190                 :            :     }
     191                 :          0 :     catch( const uno::Exception & ex )
     192                 :            :     {
     193                 :            :         ASSERT_EXCEPTION( ex );
     194                 :            :     }
     195                 :          0 : }
     196                 :            : 
     197                 :            : // ____ XModifyListener ____
     198                 :          0 : void SAL_CALL PageBackground::modified( const lang::EventObject& aEvent )
     199                 :            :     throw (uno::RuntimeException)
     200                 :            : {
     201                 :          0 :     m_xModifyEventForwarder->modified( aEvent );
     202                 :          0 : }
     203                 :            : 
     204                 :            : // ____ XEventListener (base of XModifyListener) ____
     205                 :          0 : void SAL_CALL PageBackground::disposing( const lang::EventObject& /* Source */ )
     206                 :            :     throw (uno::RuntimeException)
     207                 :            : {
     208                 :            :     // nothing
     209                 :          0 : }
     210                 :            : 
     211                 :            : // ____ OPropertySet ____
     212                 :        118 : void PageBackground::firePropertyChangeEvent()
     213                 :            : {
     214                 :        118 :     fireModifyEvent();
     215                 :        118 : }
     216                 :            : 
     217                 :        118 : void PageBackground::fireModifyEvent()
     218                 :            : {
     219 [ +  - ][ +  - ]:        118 :     m_xModifyEventForwarder->modified( lang::EventObject( static_cast< uno::XWeak* >( this )));
                 [ +  - ]
     220                 :        118 : }
     221                 :            : 
     222                 :            : // ================================================================================
     223                 :            : 
     224                 :          0 : uno::Sequence< ::rtl::OUString > PageBackground::getSupportedServiceNames_Static()
     225                 :            : {
     226                 :          0 :     uno::Sequence< ::rtl::OUString > aServices( 2 );
     227 [ #  # ][ #  # ]:          0 :     aServices[ 0 ] = C2U( "com.sun.star.chart2.PageBackground" );
     228 [ #  # ][ #  # ]:          0 :     aServices[ 1 ] = C2U( "com.sun.star.beans.PropertySet" );
     229                 :          0 :     return aServices;
     230                 :            : }
     231                 :            : 
     232                 :            : // implement XServiceInfo methods basing upon getSupportedServiceNames_Static
     233 [ #  # ][ #  # ]:        173 : APPHELPER_XSERVICEINFO_IMPL( PageBackground, lcl_aServiceName );
         [ #  # ][ #  # ]
                 [ #  # ]
     234                 :            : 
     235                 :            : using impl::PageBackground_Base;
     236                 :            : 
     237 [ +  + ][ +  - ]:       7332 : IMPLEMENT_FORWARD_XINTERFACE2( PageBackground, PageBackground_Base, ::property::OPropertySet )
     238                 :            : 
     239 [ +  - ][ +  - ]:         48 : } //  namespace chart
     240                 :            : 
     241                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10