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