LCOV - code coverage report
Current view: top level - chart2/source/controller/chartapiwrapper - WrappedGapwidthProperty.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 61 69 88.4 %
Date: 2012-08-25 Functions: 11 12 91.7 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 54 116 46.6 %

           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 "WrappedGapwidthProperty.hxx"
      22                 :            : #include "macros.hxx"
      23                 :            : #include "DiagramHelper.hxx"
      24                 :            : 
      25                 :            : using namespace ::com::sun::star;
      26                 :            : using ::com::sun::star::uno::Reference;
      27                 :            : using ::com::sun::star::uno::Sequence;
      28                 :            : using ::com::sun::star::uno::Any;
      29                 :            : using ::rtl::OUString;
      30                 :            : 
      31                 :            : 
      32                 :            : //.............................................................................
      33                 :            : namespace chart
      34                 :            : {
      35                 :            : namespace wrapper
      36                 :            : {
      37                 :            : 
      38                 :            : const sal_Int32 DEFAULT_GAPWIDTH = 100;
      39                 :            : const sal_Int32 DEFAULT_OVERLAP = 0;
      40                 :            : 
      41                 :            : //-----------------------------------------------------------------------------
      42                 :            : 
      43                 :         56 : WrappedBarPositionProperty_Base::WrappedBarPositionProperty_Base(
      44                 :            :                   const ::rtl::OUString& rOuterName
      45                 :            :                 , const ::rtl::OUString& rInnerSequencePropertyName
      46                 :            :                 , sal_Int32 nDefaultValue
      47                 :            :                 , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact )
      48                 :            :             : WrappedDefaultProperty( rOuterName, rtl::OUString(), uno::makeAny( nDefaultValue ) )
      49                 :            :             , m_nDimensionIndex(0)
      50                 :            :             , m_nAxisIndex(0)
      51                 :            :             , m_spChart2ModelContact( spChart2ModelContact )
      52                 :            :             , m_nDefaultValue( nDefaultValue )
      53 [ +  - ][ +  - ]:         56 :             , m_InnerSequencePropertyName( rInnerSequencePropertyName )
      54                 :            : {
      55                 :         56 : }
      56                 :            : 
      57                 :         56 : void WrappedBarPositionProperty_Base::setDimensionAndAxisIndex( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex )
      58                 :            : {
      59                 :         56 :     m_nDimensionIndex = nDimensionIndex;
      60                 :         56 :     m_nAxisIndex = nAxisIndex;
      61                 :         56 : }
      62                 :            : 
      63         [ +  - ]:         56 : WrappedBarPositionProperty_Base::~WrappedBarPositionProperty_Base()
      64                 :            : {
      65         [ -  + ]:         56 : }
      66                 :            : 
      67                 :         24 : void WrappedBarPositionProperty_Base::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const
      68                 :            :                 throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
      69                 :            : {
      70                 :         24 :     sal_Int32 nNewValue = 0;
      71         [ -  + ]:         24 :     if( ! (rOuterValue >>= nNewValue) )
      72 [ #  # ][ #  # ]:          0 :         throw lang::IllegalArgumentException( "GapWidth and Overlap property require value of type sal_Int32", 0, 0 );
      73                 :            : 
      74                 :         24 :     m_aOuterValue = rOuterValue;
      75                 :            : 
      76         [ +  - ]:         24 :     Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() );
      77         [ -  + ]:         24 :     if( !xDiagram.is() )
      78                 :         24 :         return;
      79                 :            : 
      80         [ +  - ]:         24 :     if( m_nDimensionIndex==1 )
      81                 :            :     {
      82         [ +  - ]:         24 :         Sequence< Reference< chart2::XChartType > > aChartTypeList( DiagramHelper::getChartTypesFromDiagram( xDiagram ) );
      83         [ +  + ]:         48 :         for( sal_Int32 nN = 0; nN < aChartTypeList.getLength(); nN++ )
      84                 :            :         {
      85                 :            :             try
      86                 :            :             {
      87 [ +  - ][ +  - ]:         24 :                 Reference< beans::XPropertySet > xProp( aChartTypeList[nN], uno::UNO_QUERY );
      88         [ +  - ]:         24 :                 if( xProp.is() )
      89                 :            :                 {
      90         [ +  - ]:         24 :                     Sequence< sal_Int32 > aBarPositionSequence;
      91 [ +  - ][ +  - ]:         24 :                     xProp->getPropertyValue( m_InnerSequencePropertyName ) >>= aBarPositionSequence;
                 [ +  - ]
      92                 :            : 
      93                 :         24 :                     long nOldLength = aBarPositionSequence.getLength();
      94         [ -  + ]:         24 :                     if( nOldLength <= m_nAxisIndex  )
      95                 :            :                     {
      96         [ #  # ]:          0 :                         aBarPositionSequence.realloc( m_nAxisIndex+1 );
      97         [ #  # ]:          0 :                         for( sal_Int32 i=nOldLength; i<m_nAxisIndex; i++ )
      98                 :            :                         {
      99         [ #  # ]:          0 :                             aBarPositionSequence[i] = m_nDefaultValue;
     100                 :            :                         }
     101                 :            :                     }
     102         [ +  - ]:         24 :                     aBarPositionSequence[m_nAxisIndex] = nNewValue;
     103                 :            : 
     104 [ +  - ][ +  - ]:         24 :                     xProp->setPropertyValue( m_InnerSequencePropertyName, uno::makeAny( aBarPositionSequence ) );
         [ +  - ][ +  - ]
     105         [ #  # ]:         24 :                 }
     106                 :            :             }
     107         [ #  # ]:          0 :             catch( uno::Exception& e )
     108                 :            :             {
     109                 :            :                 //the above properties are not supported by all charttypes (only by column and bar)
     110                 :            :                 //in that cases this exception is ok
     111                 :          0 :                 e.Context.is();//to have debug information without compilation warnings
     112                 :            :             }
     113         [ +  - ]:         24 :         }
     114         [ +  - ]:         24 :     }
     115                 :            : }
     116                 :            : 
     117                 :        136 : Any WrappedBarPositionProperty_Base::getPropertyValue( const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const
     118                 :            :                         throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
     119                 :            : {
     120         [ +  - ]:        136 :     Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() );
     121         [ +  - ]:        136 :     if( xDiagram.is() )
     122                 :            :     {
     123                 :        136 :         bool bInnerValueDetected = false;
     124                 :        136 :         sal_Int32 nInnerValue = m_nDefaultValue;
     125                 :            : 
     126         [ +  + ]:        136 :         if( m_nDimensionIndex==1 )
     127                 :            :         {
     128         [ +  - ]:         64 :             Sequence< Reference< chart2::XChartType > > aChartTypeList( DiagramHelper::getChartTypesFromDiagram( xDiagram ) );
     129 [ +  + ][ +  - ]:        128 :             for( sal_Int32 nN = 0; nN < aChartTypeList.getLength() && !bInnerValueDetected; nN++ )
                 [ +  + ]
     130                 :            :             {
     131                 :            :                 try
     132                 :            :                 {
     133 [ +  - ][ +  - ]:         64 :                     Reference< beans::XPropertySet > xProp( aChartTypeList[nN], uno::UNO_QUERY );
     134         [ +  - ]:         64 :                     if( xProp.is() )
     135                 :            :                     {
     136         [ +  - ]:         64 :                         Sequence< sal_Int32 > aBarPositionSequence;
     137 [ +  - ][ +  - ]:         64 :                         xProp->getPropertyValue( m_InnerSequencePropertyName ) >>= aBarPositionSequence;
                 [ +  - ]
     138         [ +  - ]:         64 :                         if( m_nAxisIndex < aBarPositionSequence.getLength() )
     139                 :            :                         {
     140         [ +  - ]:         64 :                             nInnerValue = aBarPositionSequence[m_nAxisIndex];
     141                 :         64 :                             bInnerValueDetected = true;
     142         [ +  - ]:         64 :                         }
     143         [ #  # ]:         64 :                     }
     144                 :            :                 }
     145         [ #  # ]:          0 :                 catch( uno::Exception& e )
     146                 :            :                 {
     147                 :            :                     //the above properties are not supported by all charttypes (only by column and bar)
     148                 :            :                     //in that cases this exception is ok
     149                 :          0 :                     e.Context.is();//to have debug information without compilation warnings
     150                 :            :                 }
     151         [ +  - ]:         64 :             }
     152                 :            :         }
     153         [ +  + ]:        136 :         if( bInnerValueDetected )
     154                 :            :         {
     155         [ +  - ]:        136 :             m_aOuterValue <<= nInnerValue;
     156                 :            :         }
     157                 :            :     }
     158                 :        136 :     return m_aOuterValue;
     159                 :            : }
     160                 :            : 
     161                 :            : //-----------------------------------------------------------------------------
     162                 :            : 
     163                 :         28 : WrappedGapwidthProperty::WrappedGapwidthProperty(
     164                 :            :         ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact )
     165         [ +  - ]:         28 :     : WrappedBarPositionProperty_Base( "GapWidth", "GapwidthSequence", DEFAULT_GAPWIDTH, spChart2ModelContact )
     166                 :            : {
     167                 :         28 : }
     168                 :         28 : WrappedGapwidthProperty::~WrappedGapwidthProperty()
     169                 :            : {
     170         [ -  + ]:         56 : }
     171                 :            : 
     172                 :            : //-----------------------------------------------------------------------------
     173                 :            : 
     174                 :         28 : WrappedBarOverlapProperty::WrappedBarOverlapProperty(
     175                 :            :         ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact )
     176         [ +  - ]:         28 :     : WrappedBarPositionProperty_Base( "Overlap", "OverlapSequence", DEFAULT_OVERLAP, spChart2ModelContact )
     177                 :            : {
     178                 :         28 : }
     179                 :         28 : WrappedBarOverlapProperty::~WrappedBarOverlapProperty()
     180                 :            : {
     181         [ -  + ]:         56 : }
     182                 :            : 
     183                 :            : } //  namespace wrapper
     184                 :            : } //  namespace chart
     185                 :            : //.............................................................................
     186                 :            : 
     187                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10