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

Generated by: LCOV version 1.10