1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: PlotterBase.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_chart2.hxx"
33 #include "PlotterBase.hxx"
34 #include "PlottingPositionHelper.hxx"
35 #include "ShapeFactory.hxx"
36 #include <rtl/math.hxx>
37 #include <com/sun/star/chart2/DataPointLabel.hpp>
38 #include <tools/debug.hxx>
40 //.............................................................................
43 //.............................................................................
44 using namespace ::com::sun::star
;
45 using namespace ::com::sun::star::chart2
;
47 //-----------------------------------------------------------------------------
48 //-----------------------------------------------------------------------------
49 //-----------------------------------------------------------------------------
51 PlotterBase::PlotterBase( sal_Int32 nDimensionCount
)
52 : m_xLogicTarget(NULL
)
53 , m_xFinalTarget(NULL
)
54 , m_xShapeFactory(NULL
)
55 , m_pShapeFactory(NULL
)
57 , m_nDimension(nDimensionCount
)
62 void SAL_CALL PlotterBase
63 ::initPlotter( const uno::Reference
< drawing::XShapes
>& xLogicTarget
64 , const uno::Reference
< drawing::XShapes
>& xFinalTarget
65 , const uno::Reference
< lang::XMultiServiceFactory
>& xShapeFactory
66 , const rtl::OUString
& rCID
)
67 throw (uno::RuntimeException
)
69 DBG_ASSERT(xLogicTarget
.is()&&xFinalTarget
.is()&&xShapeFactory
.is(),"no proper initialization parameters");
70 //is only allowed to be called once
71 m_xLogicTarget
= xLogicTarget
;
72 m_xFinalTarget
= xFinalTarget
;
73 m_xShapeFactory
= xShapeFactory
;
74 m_pShapeFactory
= new ShapeFactory(xShapeFactory
);
78 PlotterBase::~PlotterBase()
80 delete m_pShapeFactory
;
83 void SAL_CALL
PlotterBase::setScales( const uno::Sequence
< ExplicitScaleData
>& rScales
84 , sal_Bool bSwapXAndYAxis
)
85 throw (uno::RuntimeException
)
87 DBG_ASSERT(m_nDimension
<=rScales
.getLength(),"Dimension of Plotter does not fit two dimension of given scale sequence");
88 m_pPosHelper
->setScales( rScales
, bSwapXAndYAxis
);
92 void PlotterBase::setTransformationSceneToScreen( const drawing::HomogenMatrix
& rMatrix
)
94 DBG_ASSERT(m_nDimension
==2,"Set this transformation only in case of 2D");
97 m_pPosHelper
->setTransformationSceneToScreen( rMatrix
);
100 uno::Reference
< drawing::XShapes
> PlotterBase::createGroupShape(
101 const uno::Reference
< drawing::XShapes
>& xTarget
102 , ::rtl::OUString rName
)
104 if(!m_xShapeFactory
.is())
109 //create and add to target
110 return m_pShapeFactory
->createGroup2D( xTarget
, rName
);
114 //create and added to target
115 return m_pShapeFactory
->createGroup3D( xTarget
, rName
);
119 bool PlotterBase::isValidPosition( const drawing::Position3D
& rPos
)
121 if( ::rtl::math::isNan(rPos
.PositionX
) )
123 if( ::rtl::math::isNan(rPos
.PositionY
) )
125 if( ::rtl::math::isNan(rPos
.PositionZ
) )
127 if( ::rtl::math::isInf(rPos
.PositionX
) )
129 if( ::rtl::math::isInf(rPos
.PositionY
) )
131 if( ::rtl::math::isInf(rPos
.PositionZ
) )
136 //.............................................................................
138 //.............................................................................