LCOV - code coverage report
Current view: top level - chart2/source/model/main - PageBackground.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 73 0.0 %
Date: 2014-04-14 Functions: 0 29 0.0 %
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             : 
      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           0 : static const OUString lcl_aServiceName( "com.sun.star.comp.chart2.PageBackground" );
      44             : 
      45             : struct StaticPageBackgroundDefaults_Initializer
      46             : {
      47           0 :     ::chart::tPropertyValueMap* operator()()
      48             :     {
      49           0 :         static ::chart::tPropertyValueMap aStaticDefaults;
      50           0 :         lcl_AddDefaultsToMap( aStaticDefaults );
      51           0 :         return &aStaticDefaults;
      52             :     }
      53             : private:
      54           0 :     void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap )
      55             :     {
      56           0 :         ::chart::LinePropertiesHelper::AddDefaultsToMap( rOutMap );
      57           0 :         ::chart::FillProperties::AddDefaultsToMap( rOutMap );
      58             : 
      59             :         // override other defaults
      60           0 :         ::chart::PropertyHelper::setPropertyValue< sal_Int32 >( rOutMap, ::chart::FillProperties::PROP_FILL_COLOR, 0xffffff );
      61           0 :         ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::LinePropertiesHelper::PROP_LINE_STYLE, drawing::LineStyle_NONE );
      62           0 :     }
      63             : };
      64             : 
      65             : struct StaticPageBackgroundDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticPageBackgroundDefaults_Initializer >
      66             : {
      67             : };
      68             : 
      69             : struct StaticPageBackgroundInfoHelper_Initializer
      70             : {
      71           0 :     ::cppu::OPropertyArrayHelper* operator()()
      72             :     {
      73           0 :         static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() );
      74           0 :         return &aPropHelper;
      75             :     }
      76             : 
      77             : private:
      78           0 :     uno::Sequence< Property > lcl_GetPropertySequence()
      79             :     {
      80           0 :         ::std::vector< ::com::sun::star::beans::Property > aProperties;
      81           0 :          ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties );
      82           0 :         ::chart::FillProperties::AddPropertiesToVector( aProperties );
      83           0 :         ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
      84             : 
      85             :         ::std::sort( aProperties.begin(), aProperties.end(),
      86           0 :                      ::chart::PropertyNameLess() );
      87             : 
      88           0 :         return ::chart::ContainerHelper::ContainerToSequence( aProperties );
      89             :     }
      90             : 
      91             : };
      92             : 
      93             : struct StaticPageBackgroundInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticPageBackgroundInfoHelper_Initializer >
      94             : {
      95             : };
      96             : 
      97             : struct StaticPageBackgroundInfo_Initializer
      98             : {
      99           0 :     uno::Reference< beans::XPropertySetInfo >* operator()()
     100             :     {
     101             :         static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
     102           0 :             ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticPageBackgroundInfoHelper::get() ) );
     103           0 :         return &xPropertySetInfo;
     104             :     }
     105             : };
     106             : 
     107             : struct StaticPageBackgroundInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticPageBackgroundInfo_Initializer >
     108             : {
     109             : };
     110             : 
     111             : } // anonymous namespace
     112             : 
     113             : namespace chart
     114             : {
     115             : 
     116           0 : PageBackground::PageBackground( const uno::Reference< uno::XComponentContext > & xContext ) :
     117             :         ::property::OPropertySet( m_aMutex ),
     118             :     m_xContext( xContext ),
     119           0 :     m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
     120           0 : {}
     121             : 
     122           0 : PageBackground::PageBackground( const PageBackground & rOther ) :
     123             :         MutexContainer(),
     124             :         impl::PageBackground_Base(),
     125             :         ::property::OPropertySet( rOther, m_aMutex ),
     126             :     m_xContext( rOther.m_xContext ),
     127           0 :     m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
     128           0 : {}
     129             : 
     130           0 : PageBackground::~PageBackground()
     131           0 : {}
     132             : 
     133             : // ____ XCloneable ____
     134           0 : uno::Reference< util::XCloneable > SAL_CALL PageBackground::createClone()
     135             :     throw (uno::RuntimeException, std::exception)
     136             : {
     137           0 :     return uno::Reference< util::XCloneable >( new PageBackground( *this ));
     138             : }
     139             : 
     140             : // ____ OPropertySet ____
     141           0 : uno::Any PageBackground::GetDefaultValue( sal_Int32 nHandle ) const
     142             :     throw(beans::UnknownPropertyException)
     143             : {
     144           0 :     const tPropertyValueMap& rStaticDefaults = *StaticPageBackgroundDefaults::get();
     145           0 :     tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
     146           0 :     if( aFound == rStaticDefaults.end() )
     147           0 :         return uno::Any();
     148           0 :     return (*aFound).second;
     149             : }
     150             : 
     151           0 : ::cppu::IPropertyArrayHelper & SAL_CALL PageBackground::getInfoHelper()
     152             : {
     153           0 :     return *StaticPageBackgroundInfoHelper::get();
     154             : }
     155             : 
     156             : // ____ XPropertySet ____
     157           0 : uno::Reference< beans::XPropertySetInfo > SAL_CALL PageBackground::getPropertySetInfo()
     158             :     throw (uno::RuntimeException, std::exception)
     159             : {
     160           0 :     return *StaticPageBackgroundInfo::get();
     161             : }
     162             : 
     163             : // ____ XModifyBroadcaster ____
     164           0 : void SAL_CALL PageBackground::addModifyListener( const uno::Reference< util::XModifyListener >& aListener )
     165             :     throw (uno::RuntimeException, std::exception)
     166             : {
     167             :     try
     168             :     {
     169           0 :         uno::Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
     170           0 :         xBroadcaster->addModifyListener( aListener );
     171             :     }
     172           0 :     catch( const uno::Exception & ex )
     173             :     {
     174             :         ASSERT_EXCEPTION( ex );
     175             :     }
     176           0 : }
     177             : 
     178           0 : void SAL_CALL PageBackground::removeModifyListener( const uno::Reference< util::XModifyListener >& aListener )
     179             :     throw (uno::RuntimeException, std::exception)
     180             : {
     181             :     try
     182             :     {
     183           0 :         uno::Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
     184           0 :         xBroadcaster->removeModifyListener( aListener );
     185             :     }
     186           0 :     catch( const uno::Exception & ex )
     187             :     {
     188             :         ASSERT_EXCEPTION( ex );
     189             :     }
     190           0 : }
     191             : 
     192             : // ____ XModifyListener ____
     193           0 : void SAL_CALL PageBackground::modified( const lang::EventObject& aEvent )
     194             :     throw (uno::RuntimeException, std::exception)
     195             : {
     196           0 :     m_xModifyEventForwarder->modified( aEvent );
     197           0 : }
     198             : 
     199             : // ____ XEventListener (base of XModifyListener) ____
     200           0 : void SAL_CALL PageBackground::disposing( const lang::EventObject& /* Source */ )
     201             :     throw (uno::RuntimeException, std::exception)
     202             : {
     203             :     // nothing
     204           0 : }
     205             : 
     206             : // ____ OPropertySet ____
     207           0 : void PageBackground::firePropertyChangeEvent()
     208             : {
     209           0 :     fireModifyEvent();
     210           0 : }
     211             : 
     212           0 : void PageBackground::fireModifyEvent()
     213             : {
     214           0 :     m_xModifyEventForwarder->modified( lang::EventObject( static_cast< uno::XWeak* >( this )));
     215           0 : }
     216             : 
     217           0 : uno::Sequence< OUString > PageBackground::getSupportedServiceNames_Static()
     218             : {
     219           0 :     uno::Sequence< OUString > aServices( 2 );
     220           0 :     aServices[ 0 ] = "com.sun.star.chart2.PageBackground";
     221           0 :     aServices[ 1 ] = "com.sun.star.beans.PropertySet";
     222           0 :     return aServices;
     223             : }
     224             : 
     225             : // implement XServiceInfo methods basing upon getSupportedServiceNames_Static
     226           0 : APPHELPER_XSERVICEINFO_IMPL( PageBackground, lcl_aServiceName );
     227             : 
     228             : using impl::PageBackground_Base;
     229             : 
     230           0 : IMPLEMENT_FORWARD_XINTERFACE2( PageBackground, PageBackground_Base, ::property::OPropertySet )
     231             : 
     232           0 : } //  namespace chart
     233             : 
     234             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10