LCOV - code coverage report
Current view: top level - chart2/source/view/axes - VCartesianCoordinateSystem.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 101 101 100.0 %
Date: 2012-08-25 Functions: 11 11 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 126 218 57.8 %

           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                 :            : #include "VCartesianCoordinateSystem.hxx"
      21                 :            : #include "VCartesianGrid.hxx"
      22                 :            : #include "VCartesianAxis.hxx"
      23                 :            : #include "macros.hxx"
      24                 :            : #include "AxisIndexDefines.hxx"
      25                 :            : #include "AxisHelper.hxx"
      26                 :            : #include "ChartTypeHelper.hxx"
      27                 :            : 
      28                 :            : //for auto_ptr
      29                 :            : #include <memory>
      30                 :            : 
      31                 :            : //.............................................................................
      32                 :            : namespace chart
      33                 :            : {
      34                 :            : //.............................................................................
      35                 :            : using namespace ::com::sun::star;
      36                 :            : using namespace ::com::sun::star::chart2;
      37                 :            : using ::com::sun::star::uno::Reference;
      38                 :            : 
      39                 :            : //.............................................................................
      40                 :            : 
      41                 :            : class TextualDataProvider : public ::cppu::WeakImplHelper1<
      42                 :            :         ::com::sun::star::chart2::data::XTextualDataSequence
      43                 :            :         >
      44                 :            : {
      45                 :            : public:
      46                 :         14 :     TextualDataProvider( const uno::Sequence< ::rtl::OUString >& rTextSequence )
      47         [ +  - ]:         14 :         : m_aTextSequence( rTextSequence )
      48                 :            :     {
      49                 :         14 :     }
      50                 :         28 :     virtual ~TextualDataProvider()
      51         [ +  - ]:         14 :     {
      52         [ -  + ]:         28 :     }
      53                 :            : 
      54                 :            :     //XTextualDataSequence
      55                 :         14 :     virtual uno::Sequence< ::rtl::OUString > SAL_CALL getTextualData()
      56                 :            :         throw ( uno::RuntimeException)
      57                 :            :     {
      58                 :         14 :         return m_aTextSequence;
      59                 :            :     }
      60                 :            : 
      61                 :            : private: //member
      62                 :            :     uno::Sequence< ::rtl::OUString > m_aTextSequence;
      63                 :            : };
      64                 :            : 
      65                 :            : //.............................................................................
      66                 :            : 
      67                 :        962 : VCartesianCoordinateSystem::VCartesianCoordinateSystem( const Reference< XCoordinateSystem >& xCooSys )
      68                 :        962 :     : VCoordinateSystem(xCooSys)
      69                 :            : {
      70                 :        962 : }
      71                 :            : 
      72                 :        962 : VCartesianCoordinateSystem::~VCartesianCoordinateSystem()
      73                 :            : {
      74         [ -  + ]:       1924 : }
      75                 :            : 
      76                 :        962 : void VCartesianCoordinateSystem::createGridShapes()
      77                 :            : {
      78 [ +  - ][ -  + ]:        962 :     if(!m_xLogicTargetForGrids.is() || !m_xFinalTarget.is() )
                 [ -  + ]
      79                 :        962 :         return;
      80                 :            : 
      81                 :        962 :     sal_Int32 nDimensionCount = m_xCooSysModel->getDimension();
      82                 :        962 :     bool bSwapXAndY = this->getPropertySwapXAndYAxis();
      83                 :            : 
      84         [ +  + ]:       3848 :     for( sal_Int32 nDimensionIndex=0; nDimensionIndex<3; nDimensionIndex++)
      85                 :            :     {
      86                 :       2886 :         sal_Int32 nAxisIndex = MAIN_AXIS_INDEX;
      87         [ +  - ]:       2886 :         Reference< XAxis > xAxis( AxisHelper::getAxis( nDimensionIndex, nAxisIndex, m_xCooSysModel ) );
      88 [ +  + ][ +  - ]:       2886 :         if(!xAxis.is() || !AxisHelper::shouldAxisBeDisplayed( xAxis, m_xCooSysModel ))
         [ -  + ][ +  + ]
      89                 :        948 :             continue;
      90                 :            : 
      91 [ +  - ][ +  - ]:       1938 :         VCartesianGrid aGrid(nDimensionIndex,nDimensionCount,this->getGridListFromAxis( xAxis ));
                 [ +  - ]
      92                 :            :         aGrid.setExplicitScaleAndIncrement( this->getExplicitScale(nDimensionIndex,nAxisIndex)
      93 [ +  - ][ +  - ]:       1938 :                             , this->getExplicitIncrement(nDimensionIndex,nAxisIndex) );
         [ +  - ][ +  - ]
      94         [ +  - ]:       1938 :         aGrid.set3DWallPositions( m_eLeftWallPos, m_eBackWallPos, m_eBottomPos );
      95                 :            : 
      96                 :            :         aGrid.initPlotter(m_xLogicTargetForGrids,m_xFinalTarget,m_xShapeFactory
      97 [ +  - ][ +  - ]:       1938 :             , this->createCIDForGrid( xAxis,nDimensionIndex,nAxisIndex ) );
      98         [ +  + ]:       1938 :         if(2==nDimensionCount)
      99         [ +  - ]:       1896 :             aGrid.setTransformationSceneToScreen( m_aMatrixSceneToScreen );
     100 [ +  - ][ +  - ]:       1938 :         aGrid.setScales( this->getExplicitScales(nDimensionIndex,nAxisIndex), bSwapXAndY );
     101         [ +  - ]:       1938 :         aGrid.createShapes();
     102 [ +  - ][ +  + ]:       2886 :     }
     103                 :            : }
     104                 :            : 
     105                 :        962 : void VCartesianCoordinateSystem::createVAxisList(
     106                 :            :               const uno::Reference< util::XNumberFormatsSupplier > & xNumberFormatsSupplier
     107                 :            :             , const awt::Size& rFontReferenceSize
     108                 :            :             , const awt::Rectangle& rMaximumSpaceForLabels
     109                 :            :             )
     110                 :            : {
     111                 :        962 :     m_aAxisMap.clear();
     112                 :            : 
     113 [ +  - ][ +  - ]:        962 :     sal_Int32 nDimensionCount = m_xCooSysModel->getDimension();
     114         [ +  - ]:        962 :     bool bSwapXAndY = this->getPropertySwapXAndYAxis();
     115                 :            : 
     116         [ +  - ]:        962 :     if(nDimensionCount<=0)
     117                 :        962 :         return;
     118                 :            : 
     119                 :        962 :     sal_Int32 nDimensionIndex = 0;
     120                 :            : 
     121         [ +  + ]:       2900 :     for( nDimensionIndex = 0; nDimensionIndex < nDimensionCount; nDimensionIndex++ )
     122                 :            :     {
     123 [ +  - ][ +  - ]:       1938 :         sal_Int32 nMaxAxisIndex = m_xCooSysModel->getMaximumAxisIndexByDimension(nDimensionIndex);
     124         [ +  + ]:       3890 :         for( sal_Int32 nAxisIndex = 0; nAxisIndex <= nMaxAxisIndex; nAxisIndex++ )
     125                 :            :         {
     126         [ +  - ]:       1952 :             Reference< XAxis > xAxis = this->getAxisByDimension(nDimensionIndex,nAxisIndex);
     127 [ +  - ][ +  - ]:       1952 :             if(!xAxis.is() || !AxisHelper::shouldAxisBeDisplayed( xAxis, m_xCooSysModel ))
         [ +  + ][ +  + ]
     128                 :         14 :                 continue;
     129                 :            : 
     130 [ +  - ][ +  - ]:       1938 :             AxisProperties aAxisProperties(xAxis,this->getExplicitCategoriesProvider());
     131                 :       1938 :             aAxisProperties.m_nDimensionIndex = nDimensionIndex;
     132                 :       1938 :             aAxisProperties.m_bSwapXAndY = bSwapXAndY;
     133                 :       1938 :             aAxisProperties.m_bIsMainAxis = (nAxisIndex==0);
     134         [ +  - ]:       1938 :             Reference< XAxis > xCrossingMainAxis( AxisHelper::getCrossingMainAxis( xAxis, m_xCooSysModel ) );
     135         [ +  - ]:       1938 :             if( xCrossingMainAxis.is() )
     136                 :            :             {
     137 [ +  - ][ +  - ]:       1938 :                 ScaleData aCrossingScale( xCrossingMainAxis->getScaleData() );
     138                 :       1938 :                 aAxisProperties.m_bCrossingAxisHasReverseDirection = (AxisOrientation_REVERSE==aCrossingScale.Orientation);
     139                 :            : 
     140         [ +  + ]:       1938 :                 if( aCrossingScale.AxisType == AxisType::CATEGORY )
     141         [ +  - ]:       1938 :                     aAxisProperties.m_bCrossingAxisIsCategoryAxes = true;
     142                 :            :             }
     143                 :            : 
     144         [ +  + ]:       1938 :             if( nDimensionIndex == 2 )
     145                 :            :             {
     146 [ +  - ][ +  - ]:         14 :                 aAxisProperties.m_xAxisTextProvider = new TextualDataProvider( m_aSeriesNamesForZAxis );
                 [ +  - ]
     147                 :            : 
     148                 :            :                 //for the z axis copy the positioning properties from the x axis (or from the y axis for swapped coordinate systems)
     149         [ +  - ]:         14 :                 Reference< XAxis > xSisterAxis( AxisHelper::getCrossingMainAxis( xCrossingMainAxis, m_xCooSysModel ) );
     150 [ +  - ][ +  - ]:         14 :                 aAxisProperties.initAxisPositioning( Reference< beans::XPropertySet >( xSisterAxis, uno::UNO_QUERY) );
     151                 :            :             }
     152         [ +  - ]:       1938 :             aAxisProperties.init(true);
     153         [ +  + ]:       1938 :             if(aAxisProperties.m_bDisplayLabels)
     154         [ +  - ]:       1781 :                 aAxisProperties.m_nNumberFormatKey = this->getNumberFormatKeyForAxis( xAxis, xNumberFormatsSupplier );
     155                 :            : 
     156 [ +  - ][ +  - ]:       1938 :             ::boost::shared_ptr< VAxisBase > apVAxis( new VCartesianAxis(aAxisProperties,xNumberFormatsSupplier,nDimensionIndex,nDimensionCount) );
                 [ +  - ]
     157         [ +  - ]:       1938 :             tFullAxisIndex aFullAxisIndex( nDimensionIndex, nAxisIndex );
     158 [ +  - ][ +  - ]:       1938 :             m_aAxisMap[aFullAxisIndex] = apVAxis;
     159         [ +  - ]:       1938 :             apVAxis->set3DWallPositions( m_eLeftWallPos, m_eBackWallPos, m_eBottomPos );
     160                 :            : 
     161         [ +  - ]:       1938 :             apVAxis->initAxisLabelProperties(rFontReferenceSize,rMaximumSpaceForLabels);
     162 [ +  - ][ +  - ]:       1952 :         }
                 [ +  + ]
     163                 :            :     }
     164                 :            : }
     165                 :            : 
     166                 :        962 : void VCartesianCoordinateSystem::initVAxisInList()
     167                 :            : {
     168 [ +  - ][ +  - ]:        962 :     if(!m_xLogicTargetForAxes.is() || !m_xFinalTarget.is() || !m_xCooSysModel.is() )
         [ -  + ][ +  - ]
     169                 :        962 :         return;
     170                 :            : 
     171 [ +  - ][ +  - ]:        962 :     sal_Int32 nDimensionCount = m_xCooSysModel->getDimension();
     172         [ +  - ]:        962 :     bool bSwapXAndY = this->getPropertySwapXAndYAxis();
     173                 :            : 
     174                 :        962 :     tVAxisMap::iterator aIt( m_aAxisMap.begin() );
     175                 :        962 :     tVAxisMap::const_iterator aEnd( m_aAxisMap.end() );
     176         [ +  + ]:       2900 :     for( ; aIt != aEnd; ++aIt )
     177                 :            :     {
     178                 :       1938 :         VAxisBase* pVAxis = aIt->second.get();
     179         [ +  - ]:       1938 :         if( pVAxis )
     180                 :            :         {
     181                 :       1938 :             sal_Int32 nDimensionIndex = aIt->first.first;
     182                 :       1938 :             sal_Int32 nAxisIndex = aIt->first.second;
     183 [ +  - ][ +  - ]:       1938 :             pVAxis->setExplicitScaleAndIncrement( this->getExplicitScale( nDimensionIndex, nAxisIndex ), this->getExplicitIncrement( nDimensionIndex, nAxisIndex ) );
         [ +  - ][ +  - ]
     184                 :            :             pVAxis->initPlotter(m_xLogicTargetForAxes,m_xFinalTarget,m_xShapeFactory
     185 [ +  - ][ +  - ]:       1938 :                 , this->createCIDForAxis( getAxisByDimension( nDimensionIndex, nAxisIndex ), nDimensionIndex, nAxisIndex ) );
                 [ +  - ]
     186         [ +  + ]:       1938 :             if(2==nDimensionCount)
     187         [ +  - ]:       1896 :                 pVAxis->setTransformationSceneToScreen( m_aMatrixSceneToScreen );
     188 [ +  - ][ +  - ]:       1938 :             pVAxis->setScales( this->getExplicitScales(nDimensionIndex,nAxisIndex), bSwapXAndY );
     189                 :            :         }
     190                 :            :     }
     191                 :            : }
     192                 :            : 
     193                 :        962 : void VCartesianCoordinateSystem::updateScalesAndIncrementsOnAxes()
     194                 :            : {
     195 [ +  - ][ +  - ]:        962 :     if(!m_xLogicTargetForAxes.is() || !m_xFinalTarget.is() || !m_xCooSysModel.is() )
         [ -  + ][ +  - ]
     196                 :        962 :         return;
     197                 :            : 
     198 [ +  - ][ +  - ]:        962 :     sal_Int32 nDimensionCount = m_xCooSysModel->getDimension();
     199         [ +  - ]:        962 :     bool bSwapXAndY = this->getPropertySwapXAndYAxis();
     200                 :            : 
     201                 :        962 :     tVAxisMap::iterator aIt( m_aAxisMap.begin() );
     202                 :        962 :     tVAxisMap::const_iterator aEnd( m_aAxisMap.end() );
     203         [ +  + ]:       2900 :     for( ; aIt != aEnd; ++aIt )
     204                 :            :     {
     205                 :       1938 :         VAxisBase* pVAxis = aIt->second.get();
     206         [ +  - ]:       1938 :         if( pVAxis )
     207                 :            :         {
     208                 :       1938 :             sal_Int32 nDimensionIndex = aIt->first.first;
     209                 :       1938 :             sal_Int32 nAxisIndex = aIt->first.second;
     210 [ +  - ][ +  - ]:       1938 :             pVAxis->setExplicitScaleAndIncrement( this->getExplicitScale( nDimensionIndex, nAxisIndex ), this->getExplicitIncrement( nDimensionIndex, nAxisIndex ) );
         [ +  - ][ +  - ]
     211         [ +  + ]:       1938 :             if(2==nDimensionCount)
     212         [ +  - ]:       1896 :                 pVAxis->setTransformationSceneToScreen( m_aMatrixSceneToScreen );
     213 [ +  - ][ +  - ]:       1938 :             pVAxis->setScales( this->getExplicitScales(nDimensionIndex,nAxisIndex), bSwapXAndY );
     214                 :            :         }
     215                 :            :     }
     216                 :            : }
     217                 :            : 
     218                 :            : //.............................................................................
     219                 :            : } //namespace chart
     220                 :            : //.............................................................................
     221                 :            : 
     222                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10