LCOV - code coverage report
Current view: top level - libreoffice/chart2/source/model/main - PageBackground.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 47 73 64.4 %
Date: 2012-12-27 Functions: 18 29 62.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 "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           1 : static const ::rtl::OUString lcl_aServiceName(
      44             :     RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.chart2.PageBackground" ));
      45             : 
      46             : struct StaticPageBackgroundDefaults_Initializer
      47             : {
      48           1 :     ::chart::tPropertyValueMap* operator()()
      49             :     {
      50           1 :         static ::chart::tPropertyValueMap aStaticDefaults;
      51           1 :         lcl_AddDefaultsToMap( aStaticDefaults );
      52           1 :         return &aStaticDefaults;
      53             :     }
      54             : private:
      55           1 :     void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap )
      56             :     {
      57           1 :         ::chart::LineProperties::AddDefaultsToMap( rOutMap );
      58           1 :         ::chart::FillProperties::AddDefaultsToMap( rOutMap );
      59             : 
      60             :         // override other defaults
      61           1 :         ::chart::PropertyHelper::setPropertyValue< sal_Int32 >( rOutMap, ::chart::FillProperties::PROP_FILL_COLOR, 0xffffff );
      62           1 :         ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::LineProperties::PROP_LINE_STYLE, drawing::LineStyle_NONE );
      63           1 :     }
      64             : };
      65             : 
      66             : struct StaticPageBackgroundDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticPageBackgroundDefaults_Initializer >
      67             : {
      68             : };
      69             : 
      70             : struct StaticPageBackgroundInfoHelper_Initializer
      71             : {
      72           1 :     ::cppu::OPropertyArrayHelper* operator()()
      73             :     {
      74           1 :         static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() );
      75           1 :         return &aPropHelper;
      76             :     }
      77             : 
      78             : private:
      79           1 :     uno::Sequence< Property > lcl_GetPropertySequence()
      80             :     {
      81           1 :         ::std::vector< ::com::sun::star::beans::Property > aProperties;
      82           1 :          ::chart::LineProperties::AddPropertiesToVector( aProperties );
      83           1 :         ::chart::FillProperties::AddPropertiesToVector( aProperties );
      84           1 :         ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
      85             : 
      86             :         ::std::sort( aProperties.begin(), aProperties.end(),
      87           1 :                      ::chart::PropertyNameLess() );
      88             : 
      89           1 :         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          41 : PageBackground::PageBackground( const uno::Reference< uno::XComponentContext > & xContext ) :
     120             :         ::property::OPropertySet( m_aMutex ),
     121             :     m_xContext( xContext ),
     122          41 :     m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
     123          41 : {}
     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          82 : PageBackground::~PageBackground()
     134          82 : {}
     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        1382 : uno::Any PageBackground::GetDefaultValue( sal_Int32 nHandle ) const
     147             :     throw(beans::UnknownPropertyException)
     148             : {
     149        1382 :     const tPropertyValueMap& rStaticDefaults = *StaticPageBackgroundDefaults::get();
     150        1382 :     tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
     151        1382 :     if( aFound == rStaticDefaults.end() )
     152         286 :         return uno::Any();
     153        1096 :     return (*aFound).second;
     154             : }
     155             : 
     156        2284 : ::cppu::IPropertyArrayHelper & SAL_CALL PageBackground::getInfoHelper()
     157             : {
     158        2284 :     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          41 : void SAL_CALL PageBackground::addModifyListener( const uno::Reference< util::XModifyListener >& aListener )
     170             :     throw (uno::RuntimeException)
     171             : {
     172             :     try
     173             :     {
     174          41 :         uno::Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
     175          41 :         xBroadcaster->addModifyListener( aListener );
     176             :     }
     177           0 :     catch( const uno::Exception & ex )
     178             :     {
     179             :         ASSERT_EXCEPTION( ex );
     180             :     }
     181          41 : }
     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          80 : void PageBackground::firePropertyChangeEvent()
     213             : {
     214          80 :     fireModifyEvent();
     215          80 : }
     216             : 
     217          80 : void PageBackground::fireModifyEvent()
     218             : {
     219          80 :     m_xModifyEventForwarder->modified( lang::EventObject( static_cast< uno::XWeak* >( this )));
     220          80 : }
     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          16 : APPHELPER_XSERVICEINFO_IMPL( PageBackground, lcl_aServiceName );
     234             : 
     235             : using impl::PageBackground_Base;
     236             : 
     237        1724 : IMPLEMENT_FORWARD_XINTERFACE2( PageBackground, PageBackground_Base, ::property::OPropertySet )
     238             : 
     239           3 : } //  namespace chart
     240             : 
     241             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10