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

Generated by: LCOV version 1.10