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

Generated by: LCOV version 1.10