LCOV - code coverage report
Current view: top level - chart2/source/tools - WrappedProperty.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 50 0.0 %
Date: 2014-04-14 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             : #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           0 : WrappedProperty::WrappedProperty( const OUString& rOuterName, const OUString& rInnerName)
      32             :                          : m_aOuterName( rOuterName )
      33           0 :                          , m_aInnerName( rInnerName )
      34             : {
      35           0 : }
      36           0 : WrappedProperty::~WrappedProperty()
      37             : {
      38           0 : }
      39             : 
      40           0 : const OUString& WrappedProperty::getOuterName() const
      41             : {
      42           0 :     return m_aOuterName;
      43             : }
      44             : 
      45           0 : OUString WrappedProperty::getInnerName() const
      46             : {
      47           0 :     return m_aInnerName;
      48             : }
      49             : 
      50           0 : Any WrappedProperty::convertInnerToOuterValue( const Any& rInnerValue ) const
      51             : {
      52           0 :     return rInnerValue;
      53             : }
      54           0 : Any WrappedProperty::convertOuterToInnerValue( const Any& rOuterValue ) const
      55             : {
      56           0 :     return rOuterValue;
      57             : }
      58             : 
      59           0 : 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           0 :     if(xInnerPropertySet.is())
      63           0 :         xInnerPropertySet->setPropertyValue( this->getInnerName(), this->convertOuterToInnerValue( rOuterValue ) );
      64           0 : }
      65             : 
      66           0 : Any WrappedProperty::getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const
      67             :                         throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
      68             : {
      69           0 :     Any aRet;
      70           0 :     if( xInnerPropertySet.is() )
      71             :     {
      72           0 :         aRet = xInnerPropertySet->getPropertyValue( this->getInnerName() );
      73           0 :         aRet = this->convertInnerToOuterValue( aRet );
      74             :     }
      75           0 :     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           0 : Any WrappedProperty::getPropertyDefault( const Reference< beans::XPropertyState >& xInnerPropertyState ) const
      91             :                         throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
      92             : {
      93           0 :     Any aRet;
      94           0 :     if( xInnerPropertyState.is() )
      95             :     {
      96           0 :         aRet = xInnerPropertyState->getPropertyDefault( this->getInnerName() );
      97           0 :         aRet = this->convertInnerToOuterValue( aRet );
      98             :     }
      99           0 :     return aRet;
     100             : }
     101             : 
     102           0 : beans::PropertyState WrappedProperty::getPropertyState( const Reference< beans::XPropertyState >& xInnerPropertyState ) const
     103             :                         throw (beans::UnknownPropertyException, uno::RuntimeException)
     104             : {
     105           0 :     beans::PropertyState aState = beans::PropertyState_DIRECT_VALUE;
     106           0 :     OUString aInnerName( this->getInnerName() );
     107           0 :     if( xInnerPropertyState.is() && !aInnerName.isEmpty() )
     108           0 :         aState = xInnerPropertyState->getPropertyState( aInnerName );
     109             :     else
     110             :     {
     111             :         try
     112             :         {
     113           0 :             Reference< beans::XPropertySet > xInnerProp( xInnerPropertyState, uno::UNO_QUERY );
     114           0 :             uno::Any aValue = this->getPropertyValue( xInnerProp );
     115           0 :             if( !aValue.hasValue() )
     116           0 :                 aState = beans::PropertyState_DEFAULT_VALUE;
     117             :             else
     118             :             {
     119           0 :                 uno::Any aDefault = this->getPropertyDefault( xInnerPropertyState );
     120           0 :                 if( aValue == aDefault )
     121           0 :                     aState = beans::PropertyState_DEFAULT_VALUE;
     122           0 :             }
     123             :         }
     124           0 :         catch( const beans::UnknownPropertyException& ex )
     125             :         {
     126             :             ASSERT_EXCEPTION( ex );
     127             :         }
     128             :     }
     129           0 :     return aState;
     130             : }
     131             : 
     132             : } //namespace chart
     133             : 
     134             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10