LCOV - code coverage report
Current view: top level - libreoffice/chart2/source/model/main - GridProperties.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 54 80 67.5 %
Date: 2012-12-27 Functions: 20 33 60.6 %
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             : 
      21             : #include "GridProperties.hxx"
      22             : #include "LineProperties.hxx"
      23             : #include "UserDefinedProperties.hxx"
      24             : #include "PropertyHelper.hxx"
      25             : #include "macros.hxx"
      26             : #include "ContainerHelper.hxx"
      27             : #include <com/sun/star/style/XStyle.hpp>
      28             : #include <com/sun/star/beans/PropertyAttribute.hpp>
      29             : #include <com/sun/star/beans/XPropertySet.hpp>
      30             : #include <com/sun/star/uno/Sequence.hxx>
      31             : 
      32             : using namespace ::com::sun::star;
      33             : 
      34             : using ::com::sun::star::uno::Reference;
      35             : using ::com::sun::star::uno::Sequence;
      36             : using ::com::sun::star::beans::Property;
      37             : using ::osl::MutexGuard;
      38             : using ::rtl::OUString;
      39             : 
      40             : // ____________________________________________________________
      41             : 
      42             : namespace
      43             : {
      44             : 
      45           1 : static const ::rtl::OUString lcl_aServiceName(
      46             :     RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.chart2.GridProperties" ));
      47             : 
      48             : enum
      49             : {
      50             :     PROP_GRID_SHOW
      51             : };
      52             : 
      53           1 : void lcl_AddPropertiesToVector(
      54             :     ::std::vector< Property > & rOutProperties )
      55             : {
      56             :     rOutProperties.push_back(
      57             :         Property( C2U( "Show" ),
      58             :                   PROP_GRID_SHOW,
      59           1 :                   ::getBooleanCppuType(),
      60             :                   beans::PropertyAttribute::BOUND
      61           2 :                   | beans::PropertyAttribute::MAYBEDEFAULT ));
      62           1 : }
      63             : 
      64             : struct StaticGridDefaults_Initializer
      65             : {
      66           1 :     ::chart::tPropertyValueMap* operator()()
      67             :     {
      68           1 :         static ::chart::tPropertyValueMap aStaticDefaults;
      69           1 :         lcl_AddDefaultsToMap( aStaticDefaults );
      70           1 :         return &aStaticDefaults;
      71             :     }
      72             : private:
      73           1 :     void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap )
      74             :     {
      75           1 :         ::chart::LineProperties::AddDefaultsToMap( rOutMap );
      76             : 
      77           1 :         ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_GRID_SHOW, false );
      78             : 
      79             :         // override other defaults
      80             :         ::chart::PropertyHelper::setPropertyValue< sal_Int32 >(
      81           1 :             rOutMap, ::chart::LineProperties::PROP_LINE_COLOR, 0xb3b3b3 );  // gray30
      82           1 :     }
      83             : };
      84             : 
      85             : struct StaticGridDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticGridDefaults_Initializer >
      86             : {
      87             : };
      88             : 
      89             : struct StaticGridInfoHelper_Initializer
      90             : {
      91           1 :     ::cppu::OPropertyArrayHelper* operator()()
      92             :     {
      93           1 :         static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() );
      94           1 :         return &aPropHelper;
      95             :     }
      96             : 
      97             : private:
      98           1 :     Sequence< Property > lcl_GetPropertySequence()
      99             :     {
     100           1 :         ::std::vector< Property > aProperties;
     101           1 :         lcl_AddPropertiesToVector( aProperties );
     102           1 :         ::chart::LineProperties::AddPropertiesToVector( aProperties );
     103           1 :         ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
     104             : 
     105             :         ::std::sort( aProperties.begin(), aProperties.end(),
     106           1 :                      ::chart::PropertyNameLess() );
     107             : 
     108           1 :         return ::chart::ContainerHelper::ContainerToSequence( aProperties );
     109             :     }
     110             : 
     111             : 
     112             : };
     113             : 
     114             : struct StaticGridInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticGridInfoHelper_Initializer >
     115             : {
     116             : };
     117             : 
     118             : struct StaticGridInfo_Initializer
     119             : {
     120           0 :     uno::Reference< beans::XPropertySetInfo >* operator()()
     121             :     {
     122             :         static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
     123           0 :             ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticGridInfoHelper::get() ) );
     124           0 :         return &xPropertySetInfo;
     125             :     }
     126             : };
     127             : 
     128             : struct StaticGridInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticGridInfo_Initializer >
     129             : {
     130             : };
     131             : 
     132             : } // anonymous namespace
     133             : 
     134             : // ____________________________________________________________
     135             : 
     136             : namespace chart
     137             : {
     138             : 
     139           0 : GridProperties::GridProperties( Reference< uno::XComponentContext > const & /* xContext */ ) :
     140             :         ::property::OPropertySet( m_aMutex ),
     141           0 :     m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
     142             : {
     143           0 : }
     144             : 
     145         484 : GridProperties::GridProperties() :
     146             :         ::property::OPropertySet( m_aMutex ),
     147         484 :     m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
     148         484 : {}
     149             : 
     150           0 : GridProperties::GridProperties( const GridProperties & rOther ) :
     151             :         MutexContainer(),
     152             :         impl::GridProperties_Base(),
     153             :         ::property::OPropertySet( rOther, m_aMutex ),
     154           0 :     m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
     155             : {
     156           0 : }
     157             : 
     158         968 : GridProperties::~GridProperties()
     159         968 : {}
     160             : 
     161             : // ____ OPropertySet ____
     162        1474 : uno::Any GridProperties::GetDefaultValue( sal_Int32 nHandle ) const
     163             :     throw(beans::UnknownPropertyException)
     164             : {
     165        1474 :     const tPropertyValueMap& rStaticDefaults = *StaticGridDefaults::get();
     166        1474 :     tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
     167        1474 :     if( aFound == rStaticDefaults.end() )
     168          43 :         return uno::Any();
     169        1431 :     return (*aFound).second;
     170             : }
     171             : 
     172        2729 : ::cppu::IPropertyArrayHelper & SAL_CALL GridProperties::getInfoHelper()
     173             : {
     174        2729 :     return *StaticGridInfoHelper::get();
     175             : }
     176             : 
     177             : // ____ XPropertySet ____
     178           0 : Reference< beans::XPropertySetInfo > SAL_CALL GridProperties::getPropertySetInfo()
     179             :     throw (uno::RuntimeException)
     180             : {
     181           0 :     return *StaticGridInfo::get();
     182             : }
     183             : 
     184             : // ____ XCloneable ____
     185           0 : uno::Reference< util::XCloneable > SAL_CALL GridProperties::createClone()
     186             :     throw (uno::RuntimeException)
     187             : {
     188           0 :     return uno::Reference< util::XCloneable >( new GridProperties( *this ));
     189             : }
     190             : 
     191             : // ____ XModifyBroadcaster ____
     192         484 : void SAL_CALL GridProperties::addModifyListener( const Reference< util::XModifyListener >& aListener )
     193             :     throw (uno::RuntimeException)
     194             : {
     195             :     try
     196             :     {
     197         484 :         Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
     198         484 :         xBroadcaster->addModifyListener( aListener );
     199             :     }
     200           0 :     catch( const uno::Exception & ex )
     201             :     {
     202             :         ASSERT_EXCEPTION( ex );
     203             :     }
     204         484 : }
     205             : 
     206         484 : void SAL_CALL GridProperties::removeModifyListener( const Reference< util::XModifyListener >& aListener )
     207             :     throw (uno::RuntimeException)
     208             : {
     209             :     try
     210             :     {
     211         484 :         Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
     212         484 :         xBroadcaster->removeModifyListener( aListener );
     213             :     }
     214           0 :     catch( const uno::Exception & ex )
     215             :     {
     216             :         ASSERT_EXCEPTION( ex );
     217             :     }
     218         484 : }
     219             : 
     220             : // ____ XModifyListener ____
     221           0 : void SAL_CALL GridProperties::modified( const lang::EventObject& aEvent )
     222             :     throw (uno::RuntimeException)
     223             : {
     224           0 :     m_xModifyEventForwarder->modified( aEvent );
     225           0 : }
     226             : 
     227             : // ____ XEventListener (base of XModifyListener) ____
     228           0 : void SAL_CALL GridProperties::disposing( const lang::EventObject& /* Source */ )
     229             :     throw (uno::RuntimeException)
     230             : {
     231             :     // nothing
     232           0 : }
     233             : 
     234             : // ____ OPropertySet ____
     235         445 : void GridProperties::firePropertyChangeEvent()
     236             : {
     237         445 :     fireModifyEvent();
     238         445 : }
     239             : 
     240         445 : void GridProperties::fireModifyEvent()
     241             : {
     242         445 :     m_xModifyEventForwarder->modified( lang::EventObject( static_cast< uno::XWeak* >( this )));
     243         445 : }
     244             : 
     245             : // ================================================================================
     246             : 
     247           0 : Sequence< OUString > GridProperties::getSupportedServiceNames_Static()
     248             : {
     249           0 :     Sequence< OUString > aServices( 2 );
     250           0 :     aServices[ 0 ] = C2U( "com.sun.star.chart2.GridProperties" );
     251           0 :     aServices[ 1 ] = C2U( "com.sun.star.beans.PropertySet" );
     252           0 :     return aServices;
     253             : }
     254             : 
     255             : // implement XServiceInfo methods basing upon getSupportedServiceNames_Static
     256          16 : APPHELPER_XSERVICEINFO_IMPL( GridProperties, lcl_aServiceName );
     257             : 
     258             : // needed by MSC compiler
     259             : using impl::GridProperties_Base;
     260             : 
     261       11535 : IMPLEMENT_FORWARD_XINTERFACE2( GridProperties, GridProperties_Base, ::property::OPropertySet )
     262           0 : IMPLEMENT_FORWARD_XTYPEPROVIDER2( GridProperties, GridProperties_Base, ::property::OPropertySet )
     263             : 
     264           3 : } //  namespace chart
     265             : 
     266             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10