LCOV - code coverage report
Current view: top level - chart2/source/controller/chartapiwrapper - WrappedNumberFormatProperty.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 35 43 81.4 %
Date: 2014-11-03 Functions: 10 12 83.3 %
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             : #include <unonames.hxx>
      23             : 
      24             : using namespace ::com::sun::star;
      25             : using ::com::sun::star::uno::Reference;
      26             : using ::com::sun::star::uno::Any;
      27             : 
      28             : namespace chart
      29             : {
      30             : namespace wrapper
      31             : {
      32             : 
      33        4214 : WrappedNumberFormatProperty::WrappedNumberFormatProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact )
      34             :         : WrappedDirectStateProperty( CHART_UNONAME_NUMFMT, CHART_UNONAME_NUMFMT )
      35        4214 :         , m_spChart2ModelContact(spChart2ModelContact)
      36             : {
      37        4214 : }
      38             : 
      39        8428 : WrappedNumberFormatProperty::~WrappedNumberFormatProperty()
      40             : {
      41        8428 : }
      42             : 
      43        1076 : void WrappedNumberFormatProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const
      44             :                 throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
      45             : {
      46        1076 :     sal_Int32 nFormat = 0;
      47        1076 :     if( ! (rOuterValue >>= nFormat) )
      48           0 :         throw lang::IllegalArgumentException( "Property 'NumberFormat' requires value of type sal_Int32", 0, 0 );
      49             : 
      50        1076 :     if(xInnerPropertySet.is())
      51        1076 :         xInnerPropertySet->setPropertyValue(getInnerName(), this->convertOuterToInnerValue(rOuterValue));
      52        1076 : }
      53             : 
      54       10394 : Any WrappedNumberFormatProperty::getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const
      55             :                         throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
      56             : {
      57       10394 :     if( !xInnerPropertySet.is() )
      58             :     {
      59             :         OSL_FAIL("missing xInnerPropertySet in WrappedNumberFormatProperty::getPropertyValue");
      60           0 :         return Any();
      61             :     }
      62       10394 :     Any aRet( xInnerPropertySet->getPropertyValue(getInnerName()));
      63       10394 :     if( !aRet.hasValue() )
      64             :     {
      65        3172 :         sal_Int32 nKey = 0;
      66        3172 :         Reference< chart2::XDataSeries > xSeries( xInnerPropertySet, uno::UNO_QUERY );
      67        3172 :         if( xSeries.is() )
      68         536 :             nKey = m_spChart2ModelContact->getExplicitNumberFormatKeyForSeries( xSeries );
      69             :         else
      70             :         {
      71        2636 :             Reference< chart2::XAxis > xAxis( xInnerPropertySet, uno::UNO_QUERY );
      72        2636 :             nKey = m_spChart2ModelContact->getExplicitNumberFormatKeyForAxis( xAxis );
      73             :         }
      74        3172 :         aRet <<= nKey;
      75             :     }
      76       10394 :     return aRet;
      77             : }
      78             : 
      79           0 : Any WrappedNumberFormatProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const
      80             :                         throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
      81             : {
      82           0 :     return uno::makeAny( sal_Int32( 0 ) );
      83             : }
      84             : 
      85        4214 : WrappedLinkNumberFormatProperty::WrappedLinkNumberFormatProperty( const boost::shared_ptr<Chart2ModelContact>& pChart2ModelContact ) :
      86             :     WrappedDirectStateProperty(CHART_UNONAME_LINK_TO_SRC_NUMFMT, CHART_UNONAME_LINK_TO_SRC_NUMFMT),
      87        4214 :     m_pChart2ModelContact(pChart2ModelContact)
      88             : {
      89        4214 : }
      90             : 
      91        8428 : WrappedLinkNumberFormatProperty::~WrappedLinkNumberFormatProperty()
      92             : {
      93        8428 : }
      94             : 
      95         840 : void WrappedLinkNumberFormatProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const
      96             :                 throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
      97             : {
      98         840 :     if( !xInnerPropertySet.is() )
      99             :     {
     100             :         OSL_FAIL("missing xInnerPropertySet in WrappedNumberFormatProperty::setPropertyValue");
     101         840 :         return;
     102             :     }
     103             : 
     104         840 :     xInnerPropertySet->setPropertyValue(getInnerName(), rOuterValue);
     105             : }
     106             : 
     107        5202 : Any WrappedLinkNumberFormatProperty::getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const
     108             :                         throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
     109             : {
     110        5202 :     if( !xInnerPropertySet.is() )
     111             :     {
     112             :         OSL_FAIL("missing xInnerPropertySet in WrappedNumberFormatProperty::getPropertyValue");
     113           0 :         return getPropertyDefault(0);
     114             :     }
     115             : 
     116        5202 :     return xInnerPropertySet->getPropertyValue(getInnerName());
     117             : }
     118             : 
     119           0 : Any WrappedLinkNumberFormatProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const
     120             :                         throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
     121             : {
     122           0 :     bool bLink = true;
     123           0 :     return uno::makeAny( bLink );
     124             : }
     125             : 
     126             : } //namespace wrapper
     127             : } //namespace chart
     128             : 
     129             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10