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

Generated by: LCOV version 1.11