LCOV - code coverage report
Current view: top level - chart2/source/controller/chartapiwrapper - UpDownBarWrapper.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 159 0.0 %
Date: 2014-04-14 Functions: 0 39 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 "UpDownBarWrapper.hxx"
      21             : #include "macros.hxx"
      22             : #include "Chart2ModelContact.hxx"
      23             : #include "DiagramHelper.hxx"
      24             : #include "servicenames_charttypes.hxx"
      25             : #include "ContainerHelper.hxx"
      26             : #include <com/sun/star/chart2/XChartType.hpp>
      27             : #include <com/sun/star/chart2/XDataSeriesContainer.hpp>
      28             : 
      29             : #include "LinePropertiesHelper.hxx"
      30             : #include "FillProperties.hxx"
      31             : #include "UserDefinedProperties.hxx"
      32             : 
      33             : using namespace ::com::sun::star;
      34             : using namespace ::com::sun::star::chart2;
      35             : 
      36             : using ::com::sun::star::beans::Property;
      37             : using ::osl::MutexGuard;
      38             : using ::com::sun::star::uno::Reference;
      39             : using ::com::sun::star::uno::Sequence;
      40             : using ::com::sun::star::uno::Any;
      41             : 
      42             : namespace
      43             : {
      44           0 : static const OUString lcl_aServiceName("com.sun.star.comp.chart.ChartArea");
      45             : 
      46             : struct StaticUpDownBarWrapperPropertyArray_Initializer
      47             : {
      48           0 :     Sequence< Property >* operator()()
      49             :     {
      50           0 :         static Sequence< Property > aPropSeq( lcl_GetPropertySequence() );
      51           0 :         return &aPropSeq;
      52             :     }
      53             : 
      54             : private:
      55           0 :     Sequence< Property > lcl_GetPropertySequence()
      56             :     {
      57           0 :         ::std::vector< ::com::sun::star::beans::Property > aProperties;
      58             : 
      59           0 :         ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties );
      60           0 :         ::chart::FillProperties::AddPropertiesToVector( aProperties );
      61           0 :         ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
      62             : 
      63             :         ::std::sort( aProperties.begin(), aProperties.end(),
      64           0 :                      ::chart::PropertyNameLess() );
      65             : 
      66           0 :         return ::chart::ContainerHelper::ContainerToSequence( aProperties );
      67             :     }
      68             : };
      69             : 
      70             : struct StaticUpDownBarWrapperPropertyArray : public rtl::StaticAggregate< Sequence< Property >, StaticUpDownBarWrapperPropertyArray_Initializer >
      71             : {
      72             : };
      73             : 
      74             : struct StaticUpDownBarWrapperInfoHelper_Initializer
      75             : {
      76           0 :     ::cppu::OPropertyArrayHelper* operator()()
      77             :     {
      78           0 :         static ::cppu::OPropertyArrayHelper aPropHelper( *StaticUpDownBarWrapperPropertyArray::get() );
      79           0 :         return &aPropHelper;
      80             :     }
      81             : };
      82             : 
      83             : struct StaticUpDownBarWrapperInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticUpDownBarWrapperInfoHelper_Initializer >
      84             : {
      85             : };
      86             : 
      87             : struct StaticUpDownBarWrapperInfo_Initializer
      88             : {
      89           0 :     uno::Reference< beans::XPropertySetInfo >* operator()()
      90             :     {
      91             :         static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
      92           0 :             ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticUpDownBarWrapperInfoHelper::get() ) );
      93           0 :         return &xPropertySetInfo;
      94             :     }
      95             : };
      96             : 
      97             : struct StaticUpDownBarWrapperInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticUpDownBarWrapperInfo_Initializer >
      98             : {
      99             : };
     100             : 
     101             : struct StaticUpDownBarWrapperDefaults_Initializer
     102             : {
     103           0 :     ::chart::tPropertyValueMap* operator()()
     104             :     {
     105           0 :         static ::chart::tPropertyValueMap aStaticDefaults;
     106           0 :         lcl_AddDefaultsToMap( aStaticDefaults );
     107           0 :         return &aStaticDefaults;
     108             :     }
     109             : private:
     110           0 :     void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap )
     111             :     {
     112           0 :         ::chart::LinePropertiesHelper::AddDefaultsToMap( rOutMap );
     113           0 :         ::chart::FillProperties::AddDefaultsToMap( rOutMap );
     114           0 :     }
     115             : };
     116             : 
     117             : struct StaticUpDownBarWrapperDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticUpDownBarWrapperDefaults_Initializer >
     118             : {
     119             : };
     120             : 
     121             : } // anonymous namespace
     122             : 
     123             : namespace chart
     124             : {
     125             : namespace wrapper
     126             : {
     127             : 
     128           0 : UpDownBarWrapper::UpDownBarWrapper(
     129             :     bool bUp, ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact )
     130             :         : m_spChart2ModelContact( spChart2ModelContact )
     131             :         , m_aEventListenerContainer( m_aMutex )
     132           0 :         , m_aPropertySetName( bUp ? OUString( "WhiteDay" ) : OUString( "BlackDay" ))
     133             : {
     134           0 : }
     135             : 
     136           0 : UpDownBarWrapper::~UpDownBarWrapper()
     137             : {
     138           0 : }
     139             : 
     140             : // ____ XComponent ____
     141           0 : void SAL_CALL UpDownBarWrapper::dispose()
     142             :     throw (uno::RuntimeException, std::exception)
     143             : {
     144           0 :     Reference< uno::XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) );
     145           0 :     m_aEventListenerContainer.disposeAndClear( lang::EventObject( xSource ) );
     146           0 : }
     147             : 
     148           0 : void SAL_CALL UpDownBarWrapper::addEventListener(
     149             :     const Reference< lang::XEventListener >& xListener )
     150             :     throw (uno::RuntimeException, std::exception)
     151             : {
     152           0 :     m_aEventListenerContainer.addInterface( xListener );
     153           0 : }
     154             : 
     155           0 : void SAL_CALL UpDownBarWrapper::removeEventListener(
     156             :     const Reference< lang::XEventListener >& aListener )
     157             :     throw (uno::RuntimeException, std::exception)
     158             : {
     159           0 :     m_aEventListenerContainer.removeInterface( aListener );
     160           0 : }
     161             : 
     162           0 : ::cppu::IPropertyArrayHelper& UpDownBarWrapper::getInfoHelper()
     163             : {
     164           0 :     return *StaticUpDownBarWrapperInfoHelper::get();
     165             : }
     166             : 
     167             : //XPropertySet
     168           0 : uno::Reference< beans::XPropertySetInfo > SAL_CALL UpDownBarWrapper::getPropertySetInfo()
     169             :                     throw (uno::RuntimeException, std::exception)
     170             : {
     171           0 :     return *StaticUpDownBarWrapperInfo::get();
     172             : }
     173           0 : void SAL_CALL UpDownBarWrapper::setPropertyValue( const OUString& rPropertyName, const uno::Any& rValue )
     174             :                     throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
     175             : {
     176           0 :     Reference< beans::XPropertySet > xPropSet(0);
     177             : 
     178             :     Sequence< Reference< chart2::XChartType > > aTypes(
     179           0 :             ::chart::DiagramHelper::getChartTypesFromDiagram( m_spChart2ModelContact->getChart2Diagram() ) );
     180           0 :     for( sal_Int32 nN = 0; nN < aTypes.getLength(); nN++ )
     181             :     {
     182           0 :         Reference< chart2::XChartType > xType( aTypes[nN] );
     183           0 :         if( xType->getChartType().equals(CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK) )
     184             :         {
     185           0 :             Reference< beans::XPropertySet > xTypeProps( aTypes[nN], uno::UNO_QUERY );
     186           0 :             if(xTypeProps.is())
     187             :             {
     188           0 :                 xTypeProps->getPropertyValue( m_aPropertySetName ) >>= xPropSet;
     189           0 :             }
     190             :         }
     191           0 :     }
     192           0 :     if(xPropSet.is())
     193           0 :         xPropSet->setPropertyValue( rPropertyName, rValue );
     194           0 : }
     195           0 : uno::Any SAL_CALL UpDownBarWrapper::getPropertyValue( const OUString& rPropertyName )
     196             :                     throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
     197             : {
     198           0 :     Any aRet;
     199             : 
     200           0 :     Reference< beans::XPropertySet > xPropSet(0);
     201             : 
     202             :     Sequence< Reference< chart2::XChartType > > aTypes(
     203           0 :             ::chart::DiagramHelper::getChartTypesFromDiagram( m_spChart2ModelContact->getChart2Diagram() ) );
     204           0 :     for( sal_Int32 nN = 0; nN < aTypes.getLength(); nN++ )
     205             :     {
     206           0 :         Reference< chart2::XChartType > xType( aTypes[nN] );
     207           0 :         if( xType->getChartType().equals(CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK) )
     208             :         {
     209           0 :             Reference< beans::XPropertySet > xTypeProps( aTypes[nN], uno::UNO_QUERY );
     210           0 :             if(xTypeProps.is())
     211             :             {
     212           0 :                 xTypeProps->getPropertyValue( m_aPropertySetName ) >>= xPropSet;
     213           0 :             }
     214             :         }
     215           0 :     }
     216           0 :     if(xPropSet.is())
     217           0 :         aRet = xPropSet->getPropertyValue( rPropertyName );
     218           0 :     return aRet;
     219             : }
     220             : 
     221           0 : void SAL_CALL UpDownBarWrapper::addPropertyChangeListener( const OUString& /*aPropertyName*/, const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/ )
     222             :                     throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
     223             : {
     224             :     OSL_FAIL("not implemented");
     225           0 : }
     226           0 : void SAL_CALL UpDownBarWrapper::removePropertyChangeListener( const OUString& /*aPropertyName*/, const uno::Reference< beans::XPropertyChangeListener >& /*aListener*/ )
     227             :                     throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
     228             : {
     229             :     OSL_FAIL("not implemented");
     230           0 : }
     231           0 : void SAL_CALL UpDownBarWrapper::addVetoableChangeListener( const OUString& /*PropertyName*/, const uno::Reference< beans::XVetoableChangeListener >& /*aListener*/ )
     232             :                     throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
     233             : {
     234             :     OSL_FAIL("not implemented");
     235           0 : }
     236           0 : void SAL_CALL UpDownBarWrapper::removeVetoableChangeListener( const OUString& /*PropertyName*/, const uno::Reference< beans::XVetoableChangeListener >& /*aListener*/ )
     237             :                     throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
     238             : {
     239             :     OSL_FAIL("not implemented");
     240           0 : }
     241             : 
     242             : //XMultiPropertySet
     243             : //getPropertySetInfo() already declared in XPropertySet
     244           0 : void SAL_CALL UpDownBarWrapper::setPropertyValues( const uno::Sequence< OUString >& rNameSeq, const uno::Sequence< uno::Any >& rValueSeq )
     245             :                     throw (beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
     246             : {
     247           0 :     sal_Int32 nMinCount = std::min( rValueSeq.getLength(), rNameSeq.getLength() );
     248           0 :     for(sal_Int32 nN=0; nN<nMinCount; nN++)
     249             :     {
     250           0 :         OUString aPropertyName( rNameSeq[nN] );
     251             :         try
     252             :         {
     253           0 :             this->setPropertyValue( aPropertyName, rValueSeq[nN] );
     254             :         }
     255           0 :         catch( const beans::UnknownPropertyException& ex )
     256             :         {
     257             :             ASSERT_EXCEPTION( ex );
     258             :         }
     259           0 :     }
     260             :     //todo: store unknown properties elsewhere
     261           0 : }
     262           0 : uno::Sequence< uno::Any > SAL_CALL UpDownBarWrapper::getPropertyValues( const uno::Sequence< OUString >& rNameSeq )
     263             :                     throw (uno::RuntimeException, std::exception)
     264             : {
     265           0 :     Sequence< Any > aRetSeq;
     266           0 :     if( rNameSeq.getLength() )
     267             :     {
     268           0 :         aRetSeq.realloc( rNameSeq.getLength() );
     269           0 :         for(sal_Int32 nN=0; nN<rNameSeq.getLength(); nN++)
     270             :         {
     271           0 :             OUString aPropertyName( rNameSeq[nN] );
     272           0 :             aRetSeq[nN] = this->getPropertyValue( aPropertyName );
     273           0 :         }
     274             :     }
     275           0 :     return aRetSeq;
     276             : }
     277           0 : void SAL_CALL UpDownBarWrapper::addPropertiesChangeListener( const uno::Sequence< OUString >& /* aPropertyNames */, const uno::Reference< beans::XPropertiesChangeListener >& /* xListener */ )
     278             :                     throw (uno::RuntimeException, std::exception)
     279             : {
     280             :     OSL_FAIL("not implemented");
     281           0 : }
     282           0 : void SAL_CALL UpDownBarWrapper::removePropertiesChangeListener( const uno::Reference< beans::XPropertiesChangeListener >& /* xListener */ )
     283             :                     throw (uno::RuntimeException, std::exception)
     284             : {
     285             :     OSL_FAIL("not implemented");
     286           0 : }
     287           0 : void SAL_CALL UpDownBarWrapper::firePropertiesChangeEvent( const uno::Sequence< OUString >& /* aPropertyNames */, const uno::Reference< beans::XPropertiesChangeListener >& /* xListener */ )
     288             :                     throw (uno::RuntimeException, std::exception)
     289             : {
     290             :     OSL_FAIL("not implemented");
     291           0 : }
     292             : 
     293             : //XPropertyState
     294           0 : beans::PropertyState SAL_CALL UpDownBarWrapper::getPropertyState( const OUString& rPropertyName )
     295             :                     throw (beans::UnknownPropertyException, uno::RuntimeException, std::exception)
     296             : {
     297           0 :     uno::Any aDefault( this->getPropertyDefault( rPropertyName ) );
     298           0 :     uno::Any aValue( this->getPropertyValue( rPropertyName ) );
     299             : 
     300           0 :     if( aDefault == aValue )
     301           0 :         return beans::PropertyState_DEFAULT_VALUE;
     302             : 
     303           0 :     return beans::PropertyState_DIRECT_VALUE;
     304             : }
     305           0 : uno::Sequence< beans::PropertyState > SAL_CALL UpDownBarWrapper::getPropertyStates( const uno::Sequence< OUString >& rNameSeq )
     306             :                     throw (beans::UnknownPropertyException, uno::RuntimeException, std::exception)
     307             : {
     308           0 :     Sequence< beans::PropertyState > aRetSeq;
     309           0 :     if( rNameSeq.getLength() )
     310             :     {
     311           0 :         aRetSeq.realloc( rNameSeq.getLength() );
     312           0 :         for(sal_Int32 nN=0; nN<rNameSeq.getLength(); nN++)
     313             :         {
     314           0 :             OUString aPropertyName( rNameSeq[nN] );
     315           0 :             aRetSeq[nN] = this->getPropertyState( aPropertyName );
     316           0 :         }
     317             :     }
     318           0 :     return aRetSeq;
     319             : }
     320           0 : void SAL_CALL UpDownBarWrapper::setPropertyToDefault( const OUString& rPropertyName )
     321             :                     throw (beans::UnknownPropertyException, uno::RuntimeException, std::exception)
     322             : {
     323           0 :     this->setPropertyValue( rPropertyName, this->getPropertyDefault(rPropertyName) );
     324           0 : }
     325             : 
     326           0 : uno::Any SAL_CALL UpDownBarWrapper::getPropertyDefault( const OUString& rPropertyName )
     327             :                     throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
     328             : {
     329           0 :     const tPropertyValueMap& rStaticDefaults = *StaticUpDownBarWrapperDefaults::get();
     330           0 :     tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( getInfoHelper().getHandleByName( rPropertyName ) ) );
     331           0 :     if( aFound == rStaticDefaults.end() )
     332           0 :         return uno::Any();
     333           0 :     return (*aFound).second;
     334             : }
     335             : 
     336             : //XMultiPropertyStates
     337             : //getPropertyStates() already declared in XPropertyState
     338           0 : void SAL_CALL UpDownBarWrapper::setAllPropertiesToDefault(  )
     339             :                     throw (uno::RuntimeException, std::exception)
     340             : {
     341           0 :     const Sequence< beans::Property >& rPropSeq = *StaticUpDownBarWrapperPropertyArray::get();
     342           0 :     for(sal_Int32 nN=0; nN<rPropSeq.getLength(); nN++)
     343             :     {
     344           0 :         OUString aPropertyName( rPropSeq[nN].Name );
     345           0 :         this->setPropertyToDefault( aPropertyName );
     346           0 :     }
     347           0 : }
     348           0 : void SAL_CALL UpDownBarWrapper::setPropertiesToDefault( const uno::Sequence< OUString >& rNameSeq )
     349             :                     throw (beans::UnknownPropertyException, uno::RuntimeException, std::exception)
     350             : {
     351           0 :     for(sal_Int32 nN=0; nN<rNameSeq.getLength(); nN++)
     352             :     {
     353           0 :         OUString aPropertyName( rNameSeq[nN] );
     354           0 :         this->setPropertyToDefault( aPropertyName );
     355           0 :     }
     356           0 : }
     357           0 : uno::Sequence< uno::Any > SAL_CALL UpDownBarWrapper::getPropertyDefaults( const uno::Sequence< OUString >& rNameSeq )
     358             :                     throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
     359             : {
     360           0 :     Sequence< Any > aRetSeq;
     361           0 :     if( rNameSeq.getLength() )
     362             :     {
     363           0 :         aRetSeq.realloc( rNameSeq.getLength() );
     364           0 :         for(sal_Int32 nN=0; nN<rNameSeq.getLength(); nN++)
     365             :         {
     366           0 :             OUString aPropertyName( rNameSeq[nN] );
     367           0 :             aRetSeq[nN] = this->getPropertyDefault( aPropertyName );
     368           0 :         }
     369             :     }
     370           0 :     return aRetSeq;
     371             : }
     372             : 
     373           0 : Sequence< OUString > UpDownBarWrapper::getSupportedServiceNames_Static()
     374             : {
     375           0 :     Sequence< OUString > aServices( 4 );
     376           0 :     aServices[ 0 ] = "com.sun.star.chart.ChartArea";
     377           0 :     aServices[ 1 ] = "com.sun.star.drawing.LineProperties";
     378           0 :     aServices[ 2 ] = "com.sun.star.drawing.FillProperties";
     379           0 :     aServices[ 3 ] = "com.sun.star.xml.UserDefinedAttributesSupplier";
     380             : 
     381           0 :     return aServices;
     382             : }
     383             : 
     384             : // implement XServiceInfo methods basing upon getSupportedServiceNames_Static
     385           0 : APPHELPER_XSERVICEINFO_IMPL( UpDownBarWrapper, lcl_aServiceName );
     386             : 
     387             : } //  namespace wrapper
     388           0 : } //  namespace chart
     389             : 
     390             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10