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