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