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

Generated by: LCOV version 1.10