fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / chart2 / source / view / main / PlotterBase.cxx
blob8d1334e128f5a74495f8449d5ea2a50cacea4bbe
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
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>
27 namespace chart
29 using namespace ::com::sun::star;
30 using namespace ::com::sun::star::chart2;
32 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 , m_pPosHelper(NULL)
43 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)
49 OSL_PRECOND(xLogicTarget.is()&&xFinalTarget.is()&&xShapeFactory.is(),"no proper initialization parameters");
50 //is only allowed to be called once
51 m_xLogicTarget = xLogicTarget;
52 m_xFinalTarget = xFinalTarget;
53 m_xShapeFactory = xShapeFactory;
54 m_pShapeFactory = AbstractShapeFactory::getOrCreateShapeFactory(xShapeFactory);
55 m_aCID = rCID;
58 PlotterBase::~PlotterBase()
62 void PlotterBase::setScales( const std::vector< ExplicitScaleData >& rScales, bool bSwapXAndYAxis )
64 if (!m_pPosHelper)
65 return;
67 OSL_PRECOND(m_nDimension<=static_cast<sal_Int32>(rScales.size()),"Dimension of Plotter does not fit two dimension of given scale sequence");
68 m_pPosHelper->setScales( rScales, bSwapXAndYAxis );
71 void PlotterBase::setTransformationSceneToScreen( const drawing::HomogenMatrix& rMatrix)
73 if (!m_pPosHelper)
74 return;
76 OSL_PRECOND(m_nDimension==2,"Set this transformation only in case of 2D");
77 if(m_nDimension!=2)
78 return;
79 m_pPosHelper->setTransformationSceneToScreen( rMatrix );
82 uno::Reference< drawing::XShapes > PlotterBase::createGroupShape(
83 const uno::Reference< drawing::XShapes >& xTarget
84 , const OUString& rName )
86 if(!m_xShapeFactory.is())
87 return NULL;
89 if(m_nDimension==2)
91 //create and add to target
92 return m_pShapeFactory->createGroup2D( xTarget, rName );
94 else
96 //create and added to target
97 return m_pShapeFactory->createGroup3D( xTarget, rName );
101 bool PlotterBase::isValidPosition( const drawing::Position3D& rPos )
103 if( ::rtl::math::isNan(rPos.PositionX) )
104 return false;
105 if( ::rtl::math::isNan(rPos.PositionY) )
106 return false;
107 if( ::rtl::math::isNan(rPos.PositionZ) )
108 return false;
109 if( ::rtl::math::isInf(rPos.PositionX) )
110 return false;
111 if( ::rtl::math::isInf(rPos.PositionY) )
112 return false;
113 if( ::rtl::math::isInf(rPos.PositionZ) )
114 return false;
115 return true;
118 } //namespace chart
120 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */