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

Generated by: LCOV version 1.10