LCOV - code coverage report
Current view: top level - chart2/source/controller/chartapiwrapper - WrappedScaleTextProperties.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 23 37 62.2 %
Date: 2012-08-25 Functions: 7 8 87.5 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 19 70 27.1 %

           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 "WrappedScaleTextProperties.hxx"
      22                 :            : #include "FastPropertyIdRanges.hxx"
      23                 :            : #include "macros.hxx"
      24                 :            : 
      25                 :            : #include <com/sun/star/beans/PropertyAttribute.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 WrappedScaleTextProperty : public WrappedProperty
      41                 :            : {
      42                 :            : public:
      43                 :            :     WrappedScaleTextProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact );
      44                 :            :     virtual ~WrappedScaleTextProperty();
      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                 :            : private:
      54                 :            :     ::boost::shared_ptr< Chart2ModelContact >   m_spChart2ModelContact;
      55                 :            : };
      56                 :            : 
      57                 :        151 : WrappedScaleTextProperty::WrappedScaleTextProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact )
      58                 :            :     : ::chart::WrappedProperty( "ScaleText" , rtl::OUString() )
      59 [ +  - ][ +  - ]:        151 :     , m_spChart2ModelContact( spChart2ModelContact )
      60                 :            : {
      61                 :        151 : }
      62                 :            : 
      63         [ +  - ]:        151 : WrappedScaleTextProperty::~WrappedScaleTextProperty()
      64                 :            : {
      65         [ -  + ]:        302 : }
      66                 :            : 
      67                 :          0 : void WrappedScaleTextProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const
      68                 :            :                 throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
      69                 :            : {
      70 [ #  # ][ #  # ]:          0 :     static const OUString aRefSizeName( "ReferencePageSize" );
      71                 :            : 
      72         [ #  # ]:          0 :     if( xInnerPropertySet.is() )
      73                 :            :     {
      74                 :          0 :         bool bNewValue = false;
      75         [ #  # ]:          0 :         if( ! (rOuterValue >>= bNewValue) )
      76                 :            :         {
      77         [ #  # ]:          0 :             if( rOuterValue.hasValue() )
      78 [ #  # ][ #  # ]:          0 :                 throw lang::IllegalArgumentException( "Property ScaleText requires value of type boolean", 0, 0 );
      79                 :            :         }
      80                 :            : 
      81                 :            :         try
      82                 :            :         {
      83         [ #  # ]:          0 :             if( bNewValue )
      84                 :            :             {
      85         [ #  # ]:          0 :                 awt::Size aRefSize( m_spChart2ModelContact->GetPageSize() );
      86 [ #  # ][ #  # ]:          0 :                 xInnerPropertySet->setPropertyValue( aRefSizeName, uno::makeAny( aRefSize ) );
                 [ #  # ]
      87                 :            :             }
      88                 :            :             else
      89 [ #  # ][ #  # ]:          0 :                 xInnerPropertySet->setPropertyValue( aRefSizeName, Any() );
                 [ #  # ]
      90                 :            :         }
      91         [ #  # ]:          0 :         catch( const uno::Exception & ex )
      92                 :            :         {
      93                 :            :             ASSERT_EXCEPTION( ex );
      94                 :            :         }
      95                 :            :     }
      96                 :          0 : }
      97                 :            : 
      98                 :        128 : Any WrappedScaleTextProperty::getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const
      99                 :            :                         throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
     100                 :            : {
     101 [ +  + ][ +  - ]:        128 :     static const OUString aRefSizeName( "ReferencePageSize" );
     102                 :            : 
     103         [ +  - ]:        128 :     Any aRet( getPropertyDefault( Reference< beans::XPropertyState >( xInnerPropertySet, uno::UNO_QUERY ) ) );
     104         [ +  - ]:        128 :     if( xInnerPropertySet.is() )
     105                 :            :     {
     106 [ +  - ][ +  - ]:        128 :         if( xInnerPropertySet->getPropertyValue( aRefSizeName ).hasValue() )
                 [ -  + ]
     107         [ #  # ]:          0 :             aRet <<= true;
     108                 :            :         else
     109         [ +  - ]:        128 :             aRet <<= false;
     110                 :            :     }
     111                 :            : 
     112                 :        128 :     return aRet;
     113                 :            : }
     114                 :            : 
     115                 :        256 : Any WrappedScaleTextProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const
     116                 :            :                         throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
     117                 :            : {
     118                 :        256 :     Any aRet;
     119         [ +  - ]:        256 :     aRet <<= false;
     120                 :        256 :     return aRet;
     121                 :            : }
     122                 :            : 
     123                 :            : namespace
     124                 :            : {
     125                 :            : enum
     126                 :            : {
     127                 :            :     PROP_CHART_SCALE_TEXT = FAST_PROPERTY_ID_START_SCALE_TEXT_PROP
     128                 :            : };
     129                 :            : 
     130                 :            : }//anonymous namespace
     131                 :            : 
     132                 :            : //-----------------------------------------------------------------------------
     133                 :         25 : void WrappedScaleTextProperties::addProperties( ::std::vector< Property > & rOutProperties )
     134                 :            : {
     135                 :            :     rOutProperties.push_back(
     136                 :            :         Property( "ScaleText",
     137                 :            :                   PROP_CHART_SCALE_TEXT,
     138         [ +  - ]:         25 :                   ::getBooleanCppuType(),
     139                 :            :                   beans::PropertyAttribute::MAYBEVOID
     140         [ +  - ]:         25 :                   | beans::PropertyAttribute::MAYBEDEFAULT ));
     141                 :         25 : }
     142                 :            : 
     143                 :            : //-----------------------------------------------------------------------------
     144                 :            : 
     145                 :        151 : void WrappedScaleTextProperties::addWrappedProperties( std::vector< WrappedProperty* >& rList
     146                 :            :                                  , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact )
     147                 :            : {
     148 [ +  - ][ +  - ]:        151 :     rList.push_back( new WrappedScaleTextProperty( spChart2ModelContact ) );
                 [ +  - ]
     149                 :        151 : }
     150                 :            : 
     151                 :            : } //namespace wrapper
     152                 :            : } //namespace chart
     153                 :            : //.............................................................................
     154                 :            : 
     155                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10