LCOV - code coverage report
Current view: top level - chart2/source/controller/chartapiwrapper - WrappedNumberFormatProperty.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 71 0.0 %
Date: 2014-04-14 Functions: 0 12 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 "WrappedNumberFormatProperty.hxx"
      21             : #include "macros.hxx"
      22             : 
      23             : using namespace ::com::sun::star;
      24             : using ::com::sun::star::uno::Reference;
      25             : using ::com::sun::star::uno::Any;
      26             : 
      27             : namespace chart
      28             : {
      29             : namespace wrapper
      30             : {
      31             : 
      32           0 : WrappedNumberFormatProperty::WrappedNumberFormatProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact )
      33             :         : WrappedDirectStateProperty( "NumberFormat", "NumberFormat" )
      34             :         , m_spChart2ModelContact(spChart2ModelContact)
      35           0 :         , m_pWrappedLinkNumberFormatProperty(NULL)
      36             : {
      37           0 :     m_aOuterValue = getPropertyDefault( 0 );
      38           0 : }
      39             : 
      40           0 : WrappedNumberFormatProperty::~WrappedNumberFormatProperty()
      41             : {
      42           0 :     if( m_pWrappedLinkNumberFormatProperty )
      43             :     {
      44           0 :         if( m_pWrappedLinkNumberFormatProperty->m_pWrappedNumberFormatProperty == this )
      45           0 :             m_pWrappedLinkNumberFormatProperty->m_pWrappedNumberFormatProperty = 0;
      46             :     }
      47           0 : }
      48             : 
      49           0 : void WrappedNumberFormatProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const
      50             :                 throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
      51             : {
      52           0 :     sal_Int32 nFormat = 0;
      53           0 :     if( ! (rOuterValue >>= nFormat) )
      54           0 :         throw lang::IllegalArgumentException( "Property 'NumberFormat' requires value of type sal_Int32", 0, 0 );
      55             : 
      56           0 :     m_aOuterValue = rOuterValue;
      57           0 :     if(xInnerPropertySet.is())
      58             :     {
      59           0 :         bool bUseSourceFormat = !xInnerPropertySet->getPropertyValue( "NumberFormat" ).hasValue();
      60           0 :         if( bUseSourceFormat )
      61             :         {
      62           0 :             uno::Reference< chart2::XChartDocument > xChartDoc( m_spChart2ModelContact->getChart2Document() );
      63           0 :             if( xChartDoc.is() && xChartDoc->hasInternalDataProvider() )
      64           0 :                 bUseSourceFormat = false;
      65             :         }
      66           0 :         if( !bUseSourceFormat )
      67           0 :             xInnerPropertySet->setPropertyValue( m_aInnerName, this->convertOuterToInnerValue( rOuterValue ) );
      68             :     }
      69           0 : }
      70             : 
      71           0 : Any WrappedNumberFormatProperty::getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const
      72             :                         throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
      73             : {
      74           0 :     if( !xInnerPropertySet.is() )
      75             :     {
      76             :         OSL_FAIL("missing xInnerPropertySet in WrappedNumberFormatProperty::getPropertyValue");
      77           0 :         return Any();
      78             :     }
      79           0 :     Any aRet( xInnerPropertySet->getPropertyValue( m_aInnerName ));
      80           0 :     if( !aRet.hasValue() )
      81             :     {
      82           0 :         sal_Int32 nKey = 0;
      83           0 :         Reference< chart2::XDataSeries > xSeries( xInnerPropertySet, uno::UNO_QUERY );
      84           0 :         if( xSeries.is() )
      85           0 :             nKey = m_spChart2ModelContact->getExplicitNumberFormatKeyForSeries( xSeries );
      86             :         else
      87             :         {
      88           0 :             Reference< chart2::XAxis > xAxis( xInnerPropertySet, uno::UNO_QUERY );
      89           0 :             nKey = m_spChart2ModelContact->getExplicitNumberFormatKeyForAxis( xAxis );
      90             :         }
      91           0 :         aRet <<= nKey;
      92             :     }
      93           0 :     return aRet;
      94             : }
      95             : 
      96           0 : Any WrappedNumberFormatProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const
      97             :                         throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
      98             : {
      99           0 :     return uno::makeAny( sal_Int32( 0 ) );
     100             : }
     101             : 
     102           0 : WrappedLinkNumberFormatProperty::WrappedLinkNumberFormatProperty( WrappedNumberFormatProperty* pWrappedNumberFormatProperty )
     103             :     : WrappedProperty( "LinkNumberFormatToSource", OUString() )
     104           0 :         , m_pWrappedNumberFormatProperty( pWrappedNumberFormatProperty )
     105             : {
     106           0 :     if( m_pWrappedNumberFormatProperty )
     107             :     {
     108           0 :         m_pWrappedNumberFormatProperty->m_pWrappedLinkNumberFormatProperty = this;
     109             :     }
     110           0 : }
     111             : 
     112           0 : WrappedLinkNumberFormatProperty::~WrappedLinkNumberFormatProperty()
     113             : {
     114           0 :     if( m_pWrappedNumberFormatProperty )
     115             :     {
     116           0 :         if( m_pWrappedNumberFormatProperty->m_pWrappedLinkNumberFormatProperty == this )
     117           0 :             m_pWrappedNumberFormatProperty->m_pWrappedLinkNumberFormatProperty = 0;
     118             :     }
     119           0 : }
     120             : 
     121           0 : void WrappedLinkNumberFormatProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const
     122             :                 throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
     123             : {
     124           0 :     if( !xInnerPropertySet.is() )
     125             :     {
     126             :         OSL_FAIL("missing xInnerPropertySet in WrappedNumberFormatProperty::setPropertyValue");
     127           0 :         return;
     128             :     }
     129             : 
     130           0 :     bool bLinkFormat = false;
     131           0 :     if( rOuterValue >>= bLinkFormat )
     132             :     {
     133           0 :         Any aValue;
     134           0 :         if( bLinkFormat )
     135             :         {
     136           0 :             if( m_pWrappedNumberFormatProperty )
     137             :             {
     138           0 :                 uno::Reference< chart2::XChartDocument > xChartDoc( m_pWrappedNumberFormatProperty->m_spChart2ModelContact->getChart2Document() );
     139           0 :                 if( xChartDoc.is() && xChartDoc->hasInternalDataProvider() )
     140           0 :                     return;
     141             :             }
     142             :         }
     143             :         else
     144             :         {
     145           0 :             if( m_pWrappedNumberFormatProperty )
     146             :             {
     147           0 :                 aValue = m_pWrappedNumberFormatProperty->getPropertyValue( xInnerPropertySet );
     148             :             }
     149             :             else
     150           0 :                 aValue <<= sal_Int32( 0 );
     151             :         }
     152             : 
     153           0 :         xInnerPropertySet->setPropertyValue( "NumberFormat", aValue );
     154             :     }
     155             : }
     156             : 
     157           0 : Any WrappedLinkNumberFormatProperty::getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const
     158             :                         throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
     159             : {
     160           0 :     if( !xInnerPropertySet.is() )
     161             :     {
     162             :         OSL_FAIL("missing xInnerPropertySet in WrappedNumberFormatProperty::getPropertyValue");
     163           0 :         return getPropertyDefault(0);
     164             :     }
     165           0 :     bool bLink = ! xInnerPropertySet->getPropertyValue( "NumberFormat" ).hasValue();
     166           0 :     return uno::makeAny( bLink );
     167             : }
     168             : 
     169           0 : Any WrappedLinkNumberFormatProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const
     170             :                         throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
     171             : {
     172           0 :     bool bLink = true;
     173           0 :     return uno::makeAny( bLink );
     174             : }
     175             : 
     176             : } //namespace wrapper
     177             : } //namespace chart
     178             : 
     179             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10