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

Generated by: LCOV version 1.10