LCOV - code coverage report
Current view: top level - chart2/source/controller/chartapiwrapper - WrappedAutomaticPositionProperties.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 35 37 94.6 %
Date: 2014-11-03 Functions: 9 9 100.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 "WrappedAutomaticPositionProperties.hxx"
      21             : #include "FastPropertyIdRanges.hxx"
      22             : #include "macros.hxx"
      23             : #include <com/sun/star/beans/PropertyAttribute.hpp>
      24             : #include <com/sun/star/chart2/RelativePosition.hpp>
      25             : 
      26             : using namespace ::com::sun::star;
      27             : using ::com::sun::star::uno::Any;
      28             : using ::com::sun::star::uno::Reference;
      29             : using ::com::sun::star::uno::Sequence;
      30             : using ::com::sun::star::beans::Property;
      31             : 
      32             : namespace chart
      33             : {
      34             : namespace wrapper
      35             : {
      36             : 
      37             : class WrappedAutomaticPositionProperty : public WrappedProperty
      38             : {
      39             : public:
      40             :     WrappedAutomaticPositionProperty();
      41             :     virtual ~WrappedAutomaticPositionProperty();
      42             : 
      43             :     virtual void setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const
      44             :                                     throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) SAL_OVERRIDE;
      45             :     virtual Any getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const
      46             :                                     throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) SAL_OVERRIDE;
      47             :     virtual Any getPropertyDefault( const Reference< beans::XPropertyState >& xInnerPropertyState ) const
      48             :                                     throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) SAL_OVERRIDE;
      49             : };
      50             : 
      51        1134 : WrappedAutomaticPositionProperty::WrappedAutomaticPositionProperty()
      52        1134 :     : ::chart::WrappedProperty( "AutomaticPosition" , OUString() )
      53             : {
      54        1134 : }
      55        2268 : WrappedAutomaticPositionProperty::~WrappedAutomaticPositionProperty()
      56             : {
      57        2268 : }
      58             : 
      59         526 : void WrappedAutomaticPositionProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const
      60             :                 throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
      61             : {
      62         526 :     if( xInnerPropertySet.is() )
      63             :     {
      64         526 :         bool bNewValue = true;
      65         526 :         if( ! (rOuterValue >>= bNewValue) )
      66           0 :             throw lang::IllegalArgumentException( "Property AutomaticPosition requires value of type boolean", 0, 0 );
      67             : 
      68             :         try
      69             :         {
      70         526 :             if( bNewValue )
      71             :             {
      72         524 :                 Any aRelativePosition( xInnerPropertySet->getPropertyValue( "RelativePosition" ) );
      73         524 :                 if( aRelativePosition.hasValue() )
      74         288 :                     xInnerPropertySet->setPropertyValue( "RelativePosition", Any() );
      75             :             }
      76             :         }
      77           0 :         catch( const uno::Exception & ex )
      78             :         {
      79             :             ASSERT_EXCEPTION( ex );
      80             :         }
      81             :     }
      82         526 : }
      83             : 
      84        4820 : Any WrappedAutomaticPositionProperty::getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const
      85             :                         throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
      86             : {
      87        4820 :     Any aRet( getPropertyDefault( Reference< beans::XPropertyState >( xInnerPropertySet, uno::UNO_QUERY ) ) );
      88        4820 :     if( xInnerPropertySet.is() )
      89             :     {
      90        4804 :         Any aRelativePosition( xInnerPropertySet->getPropertyValue( "RelativePosition" ) );
      91        4804 :         if( !aRelativePosition.hasValue() )
      92        4780 :             aRet <<= true;
      93             :     }
      94        4820 :     return aRet;
      95             : }
      96             : 
      97        7232 : Any WrappedAutomaticPositionProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const
      98             :                         throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
      99             : {
     100        7232 :     Any aRet;
     101        7232 :     aRet <<= false;
     102        7232 :     return aRet;
     103             : }
     104             : 
     105             : namespace
     106             : {
     107             : enum
     108             : {
     109             :     PROP_CHART_AUTOMATIC_POSITION = FAST_PROPERTY_ID_START_CHART_AUTOPOSITION_PROP
     110             : };
     111             : 
     112        1134 : void lcl_addWrappedProperties( std::vector< WrappedProperty* >& rList )
     113             : {
     114        1134 :     rList.push_back( new WrappedAutomaticPositionProperty() );
     115        1134 : }
     116             : 
     117             : }//anonymous namespace
     118             : 
     119          58 : void WrappedAutomaticPositionProperties::addProperties( ::std::vector< Property > & rOutProperties )
     120             : {
     121             :     rOutProperties.push_back(
     122             :         Property( "AutomaticPosition",
     123             :                   PROP_CHART_AUTOMATIC_POSITION,
     124          58 :                   ::getBooleanCppuType(),
     125             :                   beans::PropertyAttribute::BOUND
     126         116 :                   | beans::PropertyAttribute::MAYBEDEFAULT ));
     127          58 : }
     128             : 
     129        1134 : void WrappedAutomaticPositionProperties::addWrappedProperties( std::vector< WrappedProperty* >& rList )
     130             : {
     131        1134 :     lcl_addWrappedProperties( rList );
     132        1134 : }
     133             : 
     134             : } //namespace wrapper
     135             : } //namespace chart
     136             : 
     137             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10