LCOV - code coverage report
Current view: top level - chart2/source/controller/chartapiwrapper - WrappedAutomaticPositionProperties.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 33 37 89.2 %
Date: 2012-08-25 Functions: 9 9 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 16 50 32.0 %

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

Generated by: LCOV version 1.10