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

Generated by: LCOV version 1.10