LCOV - code coverage report
Current view: top level - chart2/source/controller/chartapiwrapper - WrappedAutomaticPositionProperties.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 35 37 94.6 %
Date: 2015-06-13 12:38:46 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         600 : WrappedAutomaticPositionProperty::WrappedAutomaticPositionProperty()
      52         600 :     : ::chart::WrappedProperty( "AutomaticPosition" , OUString() )
      53             : {
      54         600 : }
      55        1200 : WrappedAutomaticPositionProperty::~WrappedAutomaticPositionProperty()
      56             : {
      57        1200 : }
      58             : 
      59         183 : 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         183 :     if( xInnerPropertySet.is() )
      63             :     {
      64         183 :         bool bNewValue = true;
      65         183 :         if( ! (rOuterValue >>= bNewValue) )
      66           0 :             throw lang::IllegalArgumentException( "Property AutomaticPosition requires value of type boolean", 0, 0 );
      67             : 
      68             :         try
      69             :         {
      70         183 :             if( bNewValue )
      71             :             {
      72         182 :                 Any aRelativePosition( xInnerPropertySet->getPropertyValue( "RelativePosition" ) );
      73         182 :                 if( aRelativePosition.hasValue() )
      74         100 :                     xInnerPropertySet->setPropertyValue( "RelativePosition", Any() );
      75             :             }
      76             :         }
      77           0 :         catch( const uno::Exception & ex )
      78             :         {
      79             :             ASSERT_EXCEPTION( ex );
      80             :         }
      81             :     }
      82         183 : }
      83             : 
      84        2602 : Any WrappedAutomaticPositionProperty::getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const
      85             :                         throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
      86             : {
      87        2602 :     Any aRet( getPropertyDefault( Reference< beans::XPropertyState >( xInnerPropertySet, uno::UNO_QUERY ) ) );
      88        2602 :     if( xInnerPropertySet.is() )
      89             :     {
      90        2600 :         Any aRelativePosition( xInnerPropertySet->getPropertyValue( "RelativePosition" ) );
      91        2600 :         if( !aRelativePosition.hasValue() )
      92        2582 :             aRet <<= true;
      93             :     }
      94        2602 :     return aRet;
      95             : }
      96             : 
      97        3910 : Any WrappedAutomaticPositionProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const
      98             :                         throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
      99             : {
     100        3910 :     Any aRet;
     101        3910 :     aRet <<= false;
     102        3910 :     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         600 : void lcl_addWrappedProperties( std::vector< WrappedProperty* >& rList )
     113             : {
     114         600 :     rList.push_back( new WrappedAutomaticPositionProperty() );
     115         600 : }
     116             : 
     117             : }//anonymous namespace
     118             : 
     119          30 : void WrappedAutomaticPositionProperties::addProperties( ::std::vector< Property > & rOutProperties )
     120             : {
     121             :     rOutProperties.push_back(
     122             :         Property( "AutomaticPosition",
     123             :                   PROP_CHART_AUTOMATIC_POSITION,
     124          30 :                   cppu::UnoType<bool>::get(),
     125             :                   beans::PropertyAttribute::BOUND
     126          60 :                   | beans::PropertyAttribute::MAYBEDEFAULT ));
     127          30 : }
     128             : 
     129         600 : void WrappedAutomaticPositionProperties::addWrappedProperties( std::vector< WrappedProperty* >& rList )
     130             : {
     131         600 :     lcl_addWrappedProperties( rList );
     132         600 : }
     133             : 
     134             : } //namespace wrapper
     135             : } //namespace chart
     136             : 
     137             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11