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

Generated by: LCOV version 1.11