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

Generated by: LCOV version 1.10