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

Generated by: LCOV version 1.10