LCOV - code coverage report
Current view: top level - chart2/source/controller/chartapiwrapper - WrappedScaleTextProperties.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 22 35 62.9 %
Date: 2015-06-13 12:38:46 Functions: 7 8 87.5 %
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 "WrappedScaleTextProperties.hxx"
      21             : #include "FastPropertyIdRanges.hxx"
      22             : #include "macros.hxx"
      23             : 
      24             : #include <com/sun/star/beans/PropertyAttribute.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 WrappedScaleTextProperty : public WrappedProperty
      38             : {
      39             : public:
      40             :     explicit WrappedScaleTextProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact );
      41             :     virtual ~WrappedScaleTextProperty();
      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             : private:
      51             :     ::boost::shared_ptr< Chart2ModelContact >   m_spChart2ModelContact;
      52             : };
      53             : 
      54        3327 : WrappedScaleTextProperty::WrappedScaleTextProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact )
      55             :     : ::chart::WrappedProperty( "ScaleText" , OUString() )
      56        3327 :     , m_spChart2ModelContact( spChart2ModelContact )
      57             : {
      58        3327 : }
      59             : 
      60        6654 : WrappedScaleTextProperty::~WrappedScaleTextProperty()
      61             : {
      62        6654 : }
      63             : 
      64           0 : void WrappedScaleTextProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const
      65             :                 throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
      66             : {
      67             :     static const char aRefSizeName[] = "ReferencePageSize";
      68             : 
      69           0 :     if( xInnerPropertySet.is() )
      70             :     {
      71           0 :         bool bNewValue = false;
      72           0 :         if( ! (rOuterValue >>= bNewValue) )
      73             :         {
      74           0 :             if( rOuterValue.hasValue() )
      75           0 :                 throw lang::IllegalArgumentException( "Property ScaleText requires value of type boolean", 0, 0 );
      76             :         }
      77             : 
      78             :         try
      79             :         {
      80           0 :             if( bNewValue )
      81             :             {
      82           0 :                 awt::Size aRefSize( m_spChart2ModelContact->GetPageSize() );
      83           0 :                 xInnerPropertySet->setPropertyValue( aRefSizeName, uno::makeAny( aRefSize ) );
      84             :             }
      85             :             else
      86           0 :                 xInnerPropertySet->setPropertyValue( aRefSizeName, Any() );
      87             :         }
      88           0 :         catch( const uno::Exception & ex )
      89             :         {
      90             :             ASSERT_EXCEPTION( ex );
      91             :         }
      92             :     }
      93           0 : }
      94             : 
      95        5322 : Any WrappedScaleTextProperty::getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const
      96             :                         throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
      97             : {
      98             :     static const char aRefSizeName[] = "ReferencePageSize";
      99             : 
     100        5322 :     Any aRet( getPropertyDefault( Reference< beans::XPropertyState >( xInnerPropertySet, uno::UNO_QUERY ) ) );
     101        5322 :     if( xInnerPropertySet.is() )
     102             :     {
     103        5322 :         if( xInnerPropertySet->getPropertyValue( aRefSizeName ).hasValue() )
     104           0 :             aRet <<= true;
     105             :         else
     106        5322 :             aRet <<= false;
     107             :     }
     108             : 
     109        5322 :     return aRet;
     110             : }
     111             : 
     112        8652 : Any WrappedScaleTextProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const
     113             :                         throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
     114             : {
     115        8652 :     Any aRet;
     116        8652 :     aRet <<= false;
     117        8652 :     return aRet;
     118             : }
     119             : 
     120             : namespace
     121             : {
     122             : enum
     123             : {
     124             :     PROP_CHART_SCALE_TEXT = FAST_PROPERTY_ID_START_SCALE_TEXT_PROP
     125             : };
     126             : 
     127             : }//anonymous namespace
     128             : 
     129          41 : void WrappedScaleTextProperties::addProperties( ::std::vector< Property > & rOutProperties )
     130             : {
     131             :     rOutProperties.push_back(
     132             :         Property( "ScaleText",
     133             :                   PROP_CHART_SCALE_TEXT,
     134          41 :                   cppu::UnoType<bool>::get(),
     135             :                   beans::PropertyAttribute::MAYBEVOID
     136          82 :                   | beans::PropertyAttribute::MAYBEDEFAULT ));
     137          41 : }
     138             : 
     139        3327 : void WrappedScaleTextProperties::addWrappedProperties( std::vector< WrappedProperty* >& rList
     140             :                                  , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact )
     141             : {
     142        3327 :     rList.push_back( new WrappedScaleTextProperty( spChart2ModelContact ) );
     143        3327 : }
     144             : 
     145             : } //namespace wrapper
     146             : } //namespace chart
     147             : 
     148             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11