LCOV - code coverage report
Current view: top level - chart2/source/model/main - Wall.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 52 64 81.2 %
Date: 2015-06-13 12:38:46 Functions: 18 22 81.8 %
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 "Wall.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             : #include <com/sun/star/beans/PropertyAttribute.hpp>
      28             : #include <com/sun/star/drawing/FillStyle.hpp>
      29             : #include <com/sun/star/awt/Gradient.hpp>
      30             : #include <com/sun/star/drawing/Hatch.hpp>
      31             : #include <com/sun/star/drawing/LineStyle.hpp>
      32             : #include <com/sun/star/drawing/LineDash.hpp>
      33             : #include <com/sun/star/drawing/LineJoint.hpp>
      34             : #include <rtl/uuid.h>
      35             : #include <cppuhelper/queryinterface.hxx>
      36             : 
      37             : #include <vector>
      38             : #include <algorithm>
      39             : 
      40             : using namespace ::com::sun::star;
      41             : using namespace ::com::sun::star::beans::PropertyAttribute;
      42             : 
      43             : using ::com::sun::star::beans::Property;
      44             : using ::osl::MutexGuard;
      45             : 
      46             : namespace
      47             : {
      48             : 
      49             : struct StaticWallDefaults_Initializer
      50             : {
      51          16 :     ::chart::tPropertyValueMap* operator()()
      52             :     {
      53          16 :         static ::chart::tPropertyValueMap aStaticDefaults;
      54          16 :         lcl_AddDefaultsToMap( aStaticDefaults );
      55          16 :         return &aStaticDefaults;
      56             :     }
      57             : private:
      58          16 :     static void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap )
      59             :     {
      60          16 :         ::chart::LinePropertiesHelper::AddDefaultsToMap( rOutMap );
      61          16 :         ::chart::FillProperties::AddDefaultsToMap( rOutMap );
      62             : 
      63             :         // override other defaults
      64          16 :         ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::LinePropertiesHelper::PROP_LINE_STYLE, drawing::LineStyle_NONE );
      65          16 :     }
      66             : };
      67             : 
      68             : struct StaticWallDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticWallDefaults_Initializer >
      69             : {
      70             : };
      71             : 
      72             : struct StaticWallInfoHelper_Initializer
      73             : {
      74          16 :     ::cppu::OPropertyArrayHelper* operator()()
      75             :     {
      76          16 :         static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() );
      77          16 :         return &aPropHelper;
      78             :     }
      79             : 
      80             : private:
      81          16 :     static uno::Sequence< Property > lcl_GetPropertySequence()
      82             :     {
      83          16 :         ::std::vector< ::com::sun::star::beans::Property > aProperties;
      84          16 :         ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties );
      85          16 :         ::chart::FillProperties::AddPropertiesToVector( aProperties );
      86          16 :         ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
      87             : 
      88             :         ::std::sort( aProperties.begin(), aProperties.end(),
      89          16 :                      ::chart::PropertyNameLess() );
      90             : 
      91          16 :         return ::chart::ContainerHelper::ContainerToSequence( aProperties );
      92             :     }
      93             : 
      94             : };
      95             : 
      96             : struct StaticWallInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticWallInfoHelper_Initializer >
      97             : {
      98             : };
      99             : 
     100             : struct StaticWallInfo_Initializer
     101             : {
     102           6 :     uno::Reference< beans::XPropertySetInfo >* operator()()
     103             :     {
     104             :         static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
     105           6 :             ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticWallInfoHelper::get() ) );
     106           6 :         return &xPropertySetInfo;
     107             :     }
     108             : };
     109             : 
     110             : struct StaticWallInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticWallInfo_Initializer >
     111             : {
     112             : };
     113             : 
     114             : } // anonymous namespace
     115             : 
     116             : namespace chart
     117             : {
     118             : 
     119         508 : Wall::Wall() :
     120             :         ::property::OPropertySet( m_aMutex ),
     121         508 :     m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
     122         508 : {}
     123             : 
     124           0 : Wall::Wall( const Wall & rOther ) :
     125             :         MutexContainer(),
     126             :         impl::Wall_Base(),
     127             :         ::property::OPropertySet( rOther, m_aMutex ),
     128           0 :     m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
     129           0 : {}
     130             : 
     131        1016 : Wall::~Wall()
     132        1016 : {}
     133             : 
     134             : // ____ XCloneable ____
     135           0 : uno::Reference< util::XCloneable > SAL_CALL Wall::createClone()
     136             :     throw (uno::RuntimeException, std::exception)
     137             : {
     138           0 :     return uno::Reference< util::XCloneable >( new Wall( *this ));
     139             : }
     140             : 
     141             : // ____ OPropertySet ____
     142       28052 : uno::Any Wall::GetDefaultValue( sal_Int32 nHandle ) const
     143             :     throw(beans::UnknownPropertyException)
     144             : {
     145       28052 :     const tPropertyValueMap& rStaticDefaults = *StaticWallDefaults::get();
     146       28052 :     tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
     147       28052 :     if( aFound == rStaticDefaults.end() )
     148        6761 :         return uno::Any();
     149       21291 :     return (*aFound).second;
     150             : }
     151             : 
     152       93040 : ::cppu::IPropertyArrayHelper & SAL_CALL Wall::getInfoHelper()
     153             : {
     154       93040 :     return *StaticWallInfoHelper::get();
     155             : }
     156             : 
     157             : // ____ XPropertySet ____
     158         189 : uno::Reference< beans::XPropertySetInfo > SAL_CALL Wall::getPropertySetInfo()
     159             :     throw (uno::RuntimeException, std::exception)
     160             : {
     161         189 :     return *StaticWallInfo::get();
     162             : }
     163             : 
     164             : // ____ XModifyBroadcaster ____
     165         508 : void SAL_CALL Wall::addModifyListener( const uno::Reference< util::XModifyListener >& aListener )
     166             :     throw (uno::RuntimeException, std::exception)
     167             : {
     168             :     try
     169             :     {
     170         508 :         uno::Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
     171         508 :         xBroadcaster->addModifyListener( aListener );
     172             :     }
     173           0 :     catch( const uno::Exception & ex )
     174             :     {
     175             :         ASSERT_EXCEPTION( ex );
     176             :     }
     177         508 : }
     178             : 
     179         508 : void SAL_CALL Wall::removeModifyListener( const uno::Reference< util::XModifyListener >& aListener )
     180             :     throw (uno::RuntimeException, std::exception)
     181             : {
     182             :     try
     183             :     {
     184         508 :         uno::Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
     185         508 :         xBroadcaster->removeModifyListener( aListener );
     186             :     }
     187           0 :     catch( const uno::Exception & ex )
     188             :     {
     189             :         ASSERT_EXCEPTION( ex );
     190             :     }
     191         508 : }
     192             : 
     193             : // ____ XModifyListener ____
     194           0 : void SAL_CALL Wall::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 Wall::disposing( const lang::EventObject& /* Source */ )
     202             :     throw (uno::RuntimeException, std::exception)
     203             : {
     204             :     // nothing
     205           0 : }
     206             : 
     207             : // ____ OPropertySet ____
     208         909 : void Wall::firePropertyChangeEvent()
     209             : {
     210         909 :     fireModifyEvent();
     211         909 : }
     212             : 
     213         909 : void Wall::fireModifyEvent()
     214             : {
     215         909 :     m_xModifyEventForwarder->modified( lang::EventObject( static_cast< uno::XWeak* >( this )));
     216         909 : }
     217             : 
     218             : using impl::Wall_Base;
     219             : 
     220      295209 : IMPLEMENT_FORWARD_XINTERFACE2( Wall, Wall_Base, ::property::OPropertySet )
     221             : 
     222             : } //  namespace chart
     223             : 
     224             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11