LCOV - code coverage report
Current view: top level - chart2/source/controller/chartapiwrapper - GridWrapper.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 52 63 82.5 %
Date: 2012-08-25 Functions: 15 19 78.9 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 41 89 46.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 "GridWrapper.hxx"
      22                 :            : #include "macros.hxx"
      23                 :            : #include "AxisHelper.hxx"
      24                 :            : #include "Chart2ModelContact.hxx"
      25                 :            : #include "ContainerHelper.hxx"
      26                 :            : #include "AxisIndexDefines.hxx"
      27                 :            : #include <comphelper/InlineContainer.hxx>
      28                 :            : #include <com/sun/star/beans/PropertyAttribute.hpp>
      29                 :            : 
      30                 :            : #include "LineProperties.hxx"
      31                 :            : #include "UserDefinedProperties.hxx"
      32                 :            : #include "WrappedDefaultProperty.hxx"
      33                 :            : 
      34                 :            : #include <algorithm>
      35                 :            : #include <rtl/ustrbuf.hxx>
      36                 :            : #include <rtl/math.hxx>
      37                 :            : 
      38                 :            : using namespace ::com::sun::star;
      39                 :            : using namespace ::com::sun::star::chart2;
      40                 :            : 
      41                 :            : using ::com::sun::star::beans::Property;
      42                 :            : using ::osl::MutexGuard;
      43                 :            : using ::com::sun::star::uno::Reference;
      44                 :            : using ::com::sun::star::uno::Sequence;
      45                 :            : using ::rtl::OUString;
      46                 :            : 
      47                 :            : namespace
      48                 :            : {
      49                 :         16 : static const OUString lcl_aServiceName(
      50                 :            :     RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.chart.Grid" ));
      51                 :            : 
      52                 :            : struct StaticGridWrapperPropertyArray_Initializer
      53                 :            : {
      54                 :          7 :     Sequence< Property >* operator()()
      55                 :            :     {
      56 [ +  - ][ +  - ]:          7 :         static Sequence< Property > aPropSeq( lcl_GetPropertySequence() );
         [ +  - ][ #  # ]
      57                 :          7 :         return &aPropSeq;
      58                 :            :     }
      59                 :            : private:
      60                 :          7 :     Sequence< Property > lcl_GetPropertySequence()
      61                 :            :     {
      62         [ +  - ]:          7 :         ::std::vector< ::com::sun::star::beans::Property > aProperties;
      63         [ +  - ]:          7 :         ::chart::LineProperties::AddPropertiesToVector( aProperties );
      64         [ +  - ]:          7 :         ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
      65                 :            : 
      66                 :            :         ::std::sort( aProperties.begin(), aProperties.end(),
      67         [ +  - ]:          7 :                      ::chart::PropertyNameLess() );
      68                 :            : 
      69         [ +  - ]:          7 :         return ::chart::ContainerHelper::ContainerToSequence( aProperties );
      70                 :            :     }
      71                 :            : };
      72                 :            : 
      73                 :            : struct StaticGridWrapperPropertyArray : public rtl::StaticAggregate< Sequence< Property >, StaticGridWrapperPropertyArray_Initializer >
      74                 :            : {
      75                 :            : };
      76                 :            : 
      77                 :            : } // anonymous namespace
      78                 :            : 
      79                 :            : // --------------------------------------------------------------------------------
      80                 :            : 
      81                 :            : namespace chart
      82                 :            : {
      83                 :            : namespace wrapper
      84                 :            : {
      85                 :            : 
      86                 :         33 : GridWrapper::GridWrapper(
      87                 :            :     tGridType eType, ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) :
      88                 :            :         m_spChart2ModelContact( spChart2ModelContact ),
      89                 :            :         m_aEventListenerContainer( m_aMutex ),
      90 [ +  - ][ +  - ]:         33 :         m_eType( eType )
      91                 :            : {
      92                 :         33 : }
      93                 :            : 
      94 [ +  - ][ +  - ]:         33 : GridWrapper::~GridWrapper()
      95         [ -  + ]:         66 : {}
      96                 :            : 
      97                 :        244 : void GridWrapper::getDimensionAndSubGridBool( tGridType eType, sal_Int32& rnDimensionIndex, bool& rbSubGrid )
      98                 :            : {
      99                 :        244 :     rnDimensionIndex = 1;
     100                 :        244 :     rbSubGrid = false;
     101                 :            : 
     102   [ +  +  -  -  :        244 :     switch( eType )
                -  -  - ]
     103                 :            :     {
     104                 :            :         case X_MAJOR_GRID:
     105                 :         58 :             rnDimensionIndex = 0; rbSubGrid = false; break;
     106                 :            :         case Y_MAJOR_GRID:
     107                 :        186 :             rnDimensionIndex = 1; rbSubGrid = false; break;
     108                 :            :         case Z_MAJOR_GRID:
     109                 :          0 :             rnDimensionIndex = 2; rbSubGrid = false; break;
     110                 :            :         case X_MINOR_GRID:
     111                 :          0 :             rnDimensionIndex = 0; rbSubGrid = true;  break;
     112                 :            :         case Y_MINOR_GRID:
     113                 :          0 :             rnDimensionIndex = 1; rbSubGrid = true;  break;
     114                 :            :         case Z_MINOR_GRID:
     115                 :          0 :             rnDimensionIndex = 2; rbSubGrid = true;  break;
     116                 :            :     }
     117                 :        244 : }
     118                 :            : 
     119                 :            : // ____ XComponent ____
     120                 :         29 : void SAL_CALL GridWrapper::dispose()
     121                 :            :     throw (uno::RuntimeException)
     122                 :            : {
     123         [ +  - ]:         29 :     Reference< uno::XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) );
     124 [ +  - ][ +  - ]:         29 :     m_aEventListenerContainer.disposeAndClear( lang::EventObject( xSource ) );
                 [ +  - ]
     125                 :            : 
     126         [ +  - ]:         29 :     clearWrappedPropertySet();
     127                 :         29 : }
     128                 :            : 
     129                 :          0 : void SAL_CALL GridWrapper::addEventListener(
     130                 :            :     const Reference< lang::XEventListener >& xListener )
     131                 :            :     throw (uno::RuntimeException)
     132                 :            : {
     133                 :          0 :     m_aEventListenerContainer.addInterface( xListener );
     134                 :          0 : }
     135                 :            : 
     136                 :          0 : void SAL_CALL GridWrapper::removeEventListener(
     137                 :            :     const Reference< lang::XEventListener >& aListener )
     138                 :            :     throw (uno::RuntimeException)
     139                 :            : {
     140                 :          0 :     m_aEventListenerContainer.removeInterface( aListener );
     141                 :          0 : }
     142                 :            : 
     143                 :            : // ================================================================================
     144                 :            : 
     145                 :            : // WrappedPropertySet
     146                 :            : 
     147                 :        244 : Reference< beans::XPropertySet > GridWrapper::getInnerPropertySet()
     148                 :            : {
     149                 :        244 :     Reference< beans::XPropertySet > xRet;
     150                 :            :     try
     151                 :            :     {
     152         [ +  - ]:        244 :         Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() );
     153         [ +  - ]:        244 :         uno::Reference< XCoordinateSystem > xCooSys( AxisHelper::getCoordinateSystemByIndex( xDiagram, 0 /*nCooSysIndex*/ ) );
     154                 :            : 
     155                 :        244 :         sal_Int32 nDimensionIndex = 1;
     156                 :        244 :         bool bSubGrid = false;
     157                 :        244 :         getDimensionAndSubGridBool( m_eType, nDimensionIndex, bSubGrid );
     158                 :            : 
     159         [ -  + ]:        244 :         sal_Int32 nSubGridIndex = bSubGrid ? 0 : -1;
     160 [ +  - ][ +  - ]:        244 :         xRet.set( AxisHelper::getGridProperties( xCooSys , nDimensionIndex, MAIN_AXIS_INDEX, nSubGridIndex ) );
                 [ #  # ]
     161                 :            :     }
     162         [ #  # ]:          0 :     catch( const uno::Exception & ex )
     163                 :            :     {
     164                 :            :         ASSERT_EXCEPTION( ex );
     165                 :            :     }
     166                 :        244 :     return xRet;
     167                 :            : }
     168                 :            : 
     169                 :         21 : const Sequence< beans::Property >& GridWrapper::getPropertySequence()
     170                 :            : {
     171                 :         21 :     return *StaticGridWrapperPropertyArray::get();
     172                 :            : }
     173                 :            : 
     174                 :         21 : const std::vector< WrappedProperty* > GridWrapper::createWrappedProperties()
     175                 :            : {
     176                 :         21 :     ::std::vector< ::chart::WrappedProperty* > aWrappedProperties;
     177                 :            : 
     178 [ +  - ][ +  - ]:         21 :     aWrappedProperties.push_back( new WrappedDefaultProperty( "LineColor", "LineColor", uno::makeAny( sal_Int32( 0x000000) ) ) ); // black
         [ +  - ][ +  - ]
     179                 :            : 
     180                 :         21 :     return aWrappedProperties;
     181                 :            : }
     182                 :            : 
     183                 :            : // ================================================================================
     184                 :            : 
     185                 :          2 : Sequence< OUString > GridWrapper::getSupportedServiceNames_Static()
     186                 :            : {
     187                 :          2 :     Sequence< OUString > aServices( 4 );
     188         [ +  - ]:          2 :     aServices[ 0 ] = "com.sun.star.chart.ChartGrid";
     189         [ +  - ]:          2 :     aServices[ 1 ] = "com.sun.star.xml.UserDefinedAttributeSupplier";
     190         [ +  - ]:          2 :     aServices[ 2 ] = "com.sun.star.drawing.LineProperties";
     191         [ +  - ]:          2 :     aServices[ 3 ] = "com.sun.star.beans.PropertySet";
     192                 :            : 
     193                 :          2 :     return aServices;
     194                 :            : }
     195                 :            : 
     196                 :            : // implement XServiceInfo methods basing upon getSupportedServiceNames_Static
     197 [ +  - ][ +  - ]:          8 : APPHELPER_XSERVICEINFO_IMPL( GridWrapper, lcl_aServiceName );
         [ +  + ][ +  - ]
                 [ +  - ]
     198                 :            : 
     199                 :            : } //  namespace wrapper
     200 [ +  - ][ +  - ]:         48 : } //  namespace chart
     201                 :            : 
     202                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10