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

Generated by: LCOV version 1.10