LCOV - code coverage report
Current view: top level - libreoffice/chart2/source/controller/chartapiwrapper - WrappedGapwidthProperty.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 69 0.0 %
Date: 2012-12-27 Functions: 0 12 0.0 %
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 "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           0 : 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           0 :             , m_InnerSequencePropertyName( rInnerSequencePropertyName )
      54             : {
      55           0 : }
      56             : 
      57           0 : void WrappedBarPositionProperty_Base::setDimensionAndAxisIndex( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex )
      58             : {
      59           0 :     m_nDimensionIndex = nDimensionIndex;
      60           0 :     m_nAxisIndex = nAxisIndex;
      61           0 : }
      62             : 
      63           0 : WrappedBarPositionProperty_Base::~WrappedBarPositionProperty_Base()
      64             : {
      65           0 : }
      66             : 
      67           0 : 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           0 :     sal_Int32 nNewValue = 0;
      71           0 :     if( ! (rOuterValue >>= nNewValue) )
      72           0 :         throw lang::IllegalArgumentException( "GapWidth and Overlap property require value of type sal_Int32", 0, 0 );
      73             : 
      74           0 :     m_aOuterValue = rOuterValue;
      75             : 
      76           0 :     Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() );
      77           0 :     if( !xDiagram.is() )
      78           0 :         return;
      79             : 
      80           0 :     if( m_nDimensionIndex==1 )
      81             :     {
      82           0 :         Sequence< Reference< chart2::XChartType > > aChartTypeList( DiagramHelper::getChartTypesFromDiagram( xDiagram ) );
      83           0 :         for( sal_Int32 nN = 0; nN < aChartTypeList.getLength(); nN++ )
      84             :         {
      85             :             try
      86             :             {
      87           0 :                 Reference< beans::XPropertySet > xProp( aChartTypeList[nN], uno::UNO_QUERY );
      88           0 :                 if( xProp.is() )
      89             :                 {
      90           0 :                     Sequence< sal_Int32 > aBarPositionSequence;
      91           0 :                     xProp->getPropertyValue( m_InnerSequencePropertyName ) >>= aBarPositionSequence;
      92             : 
      93           0 :                     long nOldLength = aBarPositionSequence.getLength();
      94           0 :                     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           0 :                     aBarPositionSequence[m_nAxisIndex] = nNewValue;
     103             : 
     104           0 :                     xProp->setPropertyValue( m_InnerSequencePropertyName, uno::makeAny( aBarPositionSequence ) );
     105           0 :                 }
     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           0 :         }
     114           0 :     }
     115             : }
     116             : 
     117           0 : Any WrappedBarPositionProperty_Base::getPropertyValue( const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const
     118             :                         throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
     119             : {
     120           0 :     Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() );
     121           0 :     if( xDiagram.is() )
     122             :     {
     123           0 :         bool bInnerValueDetected = false;
     124           0 :         sal_Int32 nInnerValue = m_nDefaultValue;
     125             : 
     126           0 :         if( m_nDimensionIndex==1 )
     127             :         {
     128           0 :             Sequence< Reference< chart2::XChartType > > aChartTypeList( DiagramHelper::getChartTypesFromDiagram( xDiagram ) );
     129           0 :             for( sal_Int32 nN = 0; nN < aChartTypeList.getLength() && !bInnerValueDetected; nN++ )
     130             :             {
     131             :                 try
     132             :                 {
     133           0 :                     Reference< beans::XPropertySet > xProp( aChartTypeList[nN], uno::UNO_QUERY );
     134           0 :                     if( xProp.is() )
     135             :                     {
     136           0 :                         Sequence< sal_Int32 > aBarPositionSequence;
     137           0 :                         xProp->getPropertyValue( m_InnerSequencePropertyName ) >>= aBarPositionSequence;
     138           0 :                         if( m_nAxisIndex < aBarPositionSequence.getLength() )
     139             :                         {
     140           0 :                             nInnerValue = aBarPositionSequence[m_nAxisIndex];
     141           0 :                             bInnerValueDetected = true;
     142           0 :                         }
     143           0 :                     }
     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           0 :             }
     152             :         }
     153           0 :         if( bInnerValueDetected )
     154             :         {
     155           0 :             m_aOuterValue <<= nInnerValue;
     156             :         }
     157             :     }
     158           0 :     return m_aOuterValue;
     159             : }
     160             : 
     161             : //-----------------------------------------------------------------------------
     162             : 
     163           0 : WrappedGapwidthProperty::WrappedGapwidthProperty(
     164             :         ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact )
     165           0 :     : WrappedBarPositionProperty_Base( "GapWidth", "GapwidthSequence", DEFAULT_GAPWIDTH, spChart2ModelContact )
     166             : {
     167           0 : }
     168           0 : WrappedGapwidthProperty::~WrappedGapwidthProperty()
     169             : {
     170           0 : }
     171             : 
     172             : //-----------------------------------------------------------------------------
     173             : 
     174           0 : WrappedBarOverlapProperty::WrappedBarOverlapProperty(
     175             :         ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact )
     176           0 :     : WrappedBarPositionProperty_Base( "Overlap", "OverlapSequence", DEFAULT_OVERLAP, spChart2ModelContact )
     177             : {
     178           0 : }
     179           0 : WrappedBarOverlapProperty::~WrappedBarOverlapProperty()
     180             : {
     181           0 : }
     182             : 
     183             : } //  namespace wrapper
     184             : } //  namespace chart
     185             : //.............................................................................
     186             : 
     187             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10