LCOV - code coverage report
Current view: top level - chart2/source/view/main - PlotterBase.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 34 42 81.0 %
Date: 2014-11-03 Functions: 7 8 87.5 %
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 "PlotterBase.hxx"
      21             : #include "PlottingPositionHelper.hxx"
      22             : #include "AbstractShapeFactory.hxx"
      23             : #include <rtl/math.hxx>
      24             : #include <com/sun/star/chart2/DataPointLabel.hpp>
      25             : 
      26             : namespace chart
      27             : {
      28             : using namespace ::com::sun::star;
      29             : using namespace ::com::sun::star::chart2;
      30             : 
      31        2728 : PlotterBase::PlotterBase( sal_Int32 nDimensionCount )
      32             :         : m_xLogicTarget(NULL)
      33             :         , m_xFinalTarget(NULL)
      34             :         , m_xShapeFactory(NULL)
      35             :         , m_pShapeFactory(NULL)
      36             :         , m_aCID()
      37             :         , m_nDimension(nDimensionCount)
      38        2728 :         , m_pPosHelper(NULL)
      39             : {
      40        2728 : }
      41             : 
      42        2728 : void PlotterBase::initPlotter(  const uno::Reference< drawing::XShapes >& xLogicTarget
      43             :        , const uno::Reference< drawing::XShapes >& xFinalTarget
      44             :        , const uno::Reference< lang::XMultiServiceFactory >& xShapeFactory
      45             :        , const OUString& rCID )
      46             :             throw (uno::RuntimeException)
      47             : {
      48             :     OSL_PRECOND(xLogicTarget.is()&&xFinalTarget.is()&&xShapeFactory.is(),"no proper initialization parameters");
      49             :     //is only allowed to be called once
      50        2728 :     m_xLogicTarget  = xLogicTarget;
      51        2728 :     m_xFinalTarget  = xFinalTarget;
      52        2728 :     m_xShapeFactory = xShapeFactory;
      53        2728 :     m_pShapeFactory = AbstractShapeFactory::getOrCreateShapeFactory(xShapeFactory);
      54        2728 :     m_aCID = rCID;
      55        2728 : }
      56             : 
      57        2680 : PlotterBase::~PlotterBase()
      58             : {
      59        2680 : }
      60             : 
      61        4333 : void PlotterBase::setScales( const std::vector< ExplicitScaleData >& rScales, bool bSwapXAndYAxis )
      62             : {
      63        4333 :     if (!m_pPosHelper)
      64        4333 :         return;
      65             : 
      66             :     OSL_PRECOND(m_nDimension<=static_cast<sal_Int32>(rScales.size()),"Dimension of Plotter does not fit two dimension of given scale sequence");
      67        4333 :     m_pPosHelper->setScales( rScales, bSwapXAndYAxis );
      68             : }
      69             : 
      70       11401 : void PlotterBase::setTransformationSceneToScreen( const drawing::HomogenMatrix& rMatrix)
      71             : {
      72       11401 :     if (!m_pPosHelper)
      73           0 :         return;
      74             : 
      75             :     OSL_PRECOND(m_nDimension==2,"Set this transformation only in case of 2D");
      76       11401 :     if(m_nDimension!=2)
      77           0 :         return;
      78       11401 :     m_pPosHelper->setTransformationSceneToScreen( rMatrix );
      79             : }
      80             : 
      81        8309 : uno::Reference< drawing::XShapes > PlotterBase::createGroupShape(
      82             :             const uno::Reference< drawing::XShapes >& xTarget
      83             :             , const OUString& rName )
      84             : {
      85        8309 :     if(!m_xShapeFactory.is())
      86           0 :         return NULL;
      87             : 
      88        8309 :     if(m_nDimension==2)
      89             :     {
      90             :         //create and add to target
      91        7162 :         return m_pShapeFactory->createGroup2D( xTarget, rName );
      92             :     }
      93             :     else
      94             :     {
      95             :         //create and added to target
      96        1147 :         return m_pShapeFactory->createGroup3D( xTarget, rName );
      97             :     }
      98             : }
      99             : 
     100        2817 : bool PlotterBase::isValidPosition( const drawing::Position3D& rPos )
     101             : {
     102        2817 :     if( ::rtl::math::isNan(rPos.PositionX) )
     103           9 :         return false;
     104        2808 :     if( ::rtl::math::isNan(rPos.PositionY) )
     105           0 :         return false;
     106        2808 :     if( ::rtl::math::isNan(rPos.PositionZ) )
     107           0 :         return false;
     108        2808 :     if( ::rtl::math::isInf(rPos.PositionX) )
     109           0 :         return false;
     110        2808 :     if( ::rtl::math::isInf(rPos.PositionY) )
     111           0 :         return false;
     112        2808 :     if( ::rtl::math::isInf(rPos.PositionZ) )
     113           0 :         return false;
     114        2808 :     return true;
     115             : }
     116             : 
     117             : } //namespace chart
     118             : 
     119             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10