LCOV - code coverage report
Current view: top level - chart2/source/tools - WrappedProperty.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 42 50 84.0 %
Date: 2014-04-11 Functions: 11 12 91.7 %
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 "WrappedProperty.hxx"
      21             : #include "macros.hxx"
      22             : #include <com/sun/star/drawing/LineStyle.hpp>
      23             : 
      24             : using namespace ::com::sun::star;
      25             : using ::com::sun::star::uno::Any;
      26             : using ::com::sun::star::uno::Reference;
      27             : 
      28             : namespace chart
      29             : {
      30             : 
      31      120973 : WrappedProperty::WrappedProperty( const OUString& rOuterName, const OUString& rInnerName)
      32             :                          : m_aOuterName( rOuterName )
      33      120973 :                          , m_aInnerName( rInnerName )
      34             : {
      35      120973 : }
      36      159676 : WrappedProperty::~WrappedProperty()
      37             : {
      38      159676 : }
      39             : 
      40      121145 : const OUString& WrappedProperty::getOuterName() const
      41             : {
      42      121145 :     return m_aOuterName;
      43             : }
      44             : 
      45       99123 : OUString WrappedProperty::getInnerName() const
      46             : {
      47       99123 :     return m_aInnerName;
      48             : }
      49             : 
      50       51139 : Any WrappedProperty::convertInnerToOuterValue( const Any& rInnerValue ) const
      51             : {
      52       51139 :     return rInnerValue;
      53             : }
      54        2784 : Any WrappedProperty::convertOuterToInnerValue( const Any& rOuterValue ) const
      55             : {
      56        2784 :     return rOuterValue;
      57             : }
      58             : 
      59        2556 : void WrappedProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const
      60             :                 throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
      61             : {
      62        2556 :     if(xInnerPropertySet.is())
      63        2556 :         xInnerPropertySet->setPropertyValue( this->getInnerName(), this->convertOuterToInnerValue( rOuterValue ) );
      64        2556 : }
      65             : 
      66       45361 : Any WrappedProperty::getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const
      67             :                         throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
      68             : {
      69       45361 :     Any aRet;
      70       45361 :     if( xInnerPropertySet.is() )
      71             :     {
      72       45361 :         aRet = xInnerPropertySet->getPropertyValue( this->getInnerName() );
      73       45361 :         aRet = this->convertInnerToOuterValue( aRet );
      74             :     }
      75       45361 :     return aRet;
      76             : }
      77             : 
      78           0 : void WrappedProperty::setPropertyToDefault( const Reference< beans::XPropertyState >& xInnerPropertyState ) const
      79             :                         throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)
      80             : {
      81           0 :     if( xInnerPropertyState.is() && !this->getInnerName().isEmpty() )
      82           0 :         xInnerPropertyState->setPropertyToDefault(this->getInnerName());
      83             :     else
      84             :     {
      85           0 :         Reference< beans::XPropertySet > xInnerProp( xInnerPropertyState, uno::UNO_QUERY );
      86           0 :         setPropertyValue( getPropertyDefault( xInnerPropertyState ), xInnerProp );
      87             :     }
      88           0 : }
      89             : 
      90        6342 : Any WrappedProperty::getPropertyDefault( const Reference< beans::XPropertyState >& xInnerPropertyState ) const
      91             :                         throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
      92             : {
      93        6342 :     Any aRet;
      94        6342 :     if( xInnerPropertyState.is() )
      95             :     {
      96        6342 :         aRet = xInnerPropertyState->getPropertyDefault( this->getInnerName() );
      97        6342 :         aRet = this->convertInnerToOuterValue( aRet );
      98             :     }
      99        6342 :     return aRet;
     100             : }
     101             : 
     102       56980 : beans::PropertyState WrappedProperty::getPropertyState( const Reference< beans::XPropertyState >& xInnerPropertyState ) const
     103             :                         throw (beans::UnknownPropertyException, uno::RuntimeException)
     104             : {
     105       56980 :     beans::PropertyState aState = beans::PropertyState_DIRECT_VALUE;
     106       56980 :     OUString aInnerName( this->getInnerName() );
     107       56980 :     if( xInnerPropertyState.is() && !aInnerName.isEmpty() )
     108       29742 :         aState = xInnerPropertyState->getPropertyState( aInnerName );
     109             :     else
     110             :     {
     111             :         try
     112             :         {
     113       27238 :             Reference< beans::XPropertySet > xInnerProp( xInnerPropertyState, uno::UNO_QUERY );
     114       54476 :             uno::Any aValue = this->getPropertyValue( xInnerProp );
     115       27238 :             if( !aValue.hasValue() )
     116           0 :                 aState = beans::PropertyState_DEFAULT_VALUE;
     117             :             else
     118             :             {
     119       27238 :                 uno::Any aDefault = this->getPropertyDefault( xInnerPropertyState );
     120       27238 :                 if( aValue == aDefault )
     121       18512 :                     aState = beans::PropertyState_DEFAULT_VALUE;
     122       27238 :             }
     123             :         }
     124           0 :         catch( const beans::UnknownPropertyException& ex )
     125             :         {
     126             :             ASSERT_EXCEPTION( ex );
     127             :         }
     128             :     }
     129       56980 :     return aState;
     130             : }
     131             : 
     132             : } //namespace chart
     133             : 
     134             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10