1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_chart2.hxx"
30*cdf0e10cSrcweir #include "VCoordinateSystem.hxx"
31*cdf0e10cSrcweir #include "VCartesianCoordinateSystem.hxx"
32*cdf0e10cSrcweir #include "VPolarCoordinateSystem.hxx"
33*cdf0e10cSrcweir #include "ScaleAutomatism.hxx"
34*cdf0e10cSrcweir #include "VSeriesPlotter.hxx"
35*cdf0e10cSrcweir #include "ShapeFactory.hxx"
36*cdf0e10cSrcweir #include "servicenames_coosystems.hxx"
37*cdf0e10cSrcweir #include "macros.hxx"
38*cdf0e10cSrcweir #include "AxisIndexDefines.hxx"
39*cdf0e10cSrcweir #include "ObjectIdentifier.hxx"
40*cdf0e10cSrcweir #include "ExplicitCategoriesProvider.hxx"
41*cdf0e10cSrcweir #include "AxisHelper.hxx"
42*cdf0e10cSrcweir #include "ContainerHelper.hxx"
43*cdf0e10cSrcweir #include "VAxisBase.hxx"
44*cdf0e10cSrcweir #include "ViewDefines.hxx"
45*cdf0e10cSrcweir #include "DataSeriesHelper.hxx"
46*cdf0e10cSrcweir #include "chartview/ExplicitValueProvider.hxx"
47*cdf0e10cSrcweir #include <com/sun/star/chart2/AxisType.hpp>
48*cdf0e10cSrcweir #include <com/sun/star/chart2/XChartTypeContainer.hpp>
49*cdf0e10cSrcweir #include <com/sun/star/chart2/XDataSeriesContainer.hpp>
50*cdf0e10cSrcweir 
51*cdf0e10cSrcweir // header for define DBG_ASSERT
52*cdf0e10cSrcweir #include <tools/debug.hxx>
53*cdf0e10cSrcweir #include <rtl/math.hxx>
54*cdf0e10cSrcweir 
55*cdf0e10cSrcweir //.............................................................................
56*cdf0e10cSrcweir namespace chart
57*cdf0e10cSrcweir {
58*cdf0e10cSrcweir //.............................................................................
59*cdf0e10cSrcweir using namespace ::com::sun::star;
60*cdf0e10cSrcweir using namespace ::com::sun::star::chart2;
61*cdf0e10cSrcweir using ::com::sun::star::uno::Reference;
62*cdf0e10cSrcweir using ::com::sun::star::uno::Sequence;
63*cdf0e10cSrcweir 
64*cdf0e10cSrcweir VCoordinateSystem* VCoordinateSystem::createCoordinateSystem(
65*cdf0e10cSrcweir             const Reference< XCoordinateSystem >& xCooSysModel )
66*cdf0e10cSrcweir {
67*cdf0e10cSrcweir     if( !xCooSysModel.is() )
68*cdf0e10cSrcweir         return 0;
69*cdf0e10cSrcweir 
70*cdf0e10cSrcweir     rtl::OUString aViewServiceName = xCooSysModel->getViewServiceName();
71*cdf0e10cSrcweir 
72*cdf0e10cSrcweir     //@todo: in future the coordinatesystems should be instanciated via service factory
73*cdf0e10cSrcweir     VCoordinateSystem* pRet=NULL;
74*cdf0e10cSrcweir     if( aViewServiceName.equals( CHART2_COOSYSTEM_CARTESIAN_VIEW_SERVICE_NAME ) )
75*cdf0e10cSrcweir         pRet = new VCartesianCoordinateSystem(xCooSysModel);
76*cdf0e10cSrcweir     else if( aViewServiceName.equals( CHART2_COOSYSTEM_POLAR_VIEW_SERVICE_NAME ) )
77*cdf0e10cSrcweir         pRet = new VPolarCoordinateSystem(xCooSysModel);
78*cdf0e10cSrcweir     if(!pRet)
79*cdf0e10cSrcweir         pRet = new VCoordinateSystem(xCooSysModel);
80*cdf0e10cSrcweir     return pRet;
81*cdf0e10cSrcweir }
82*cdf0e10cSrcweir 
83*cdf0e10cSrcweir VCoordinateSystem::VCoordinateSystem( const Reference< XCoordinateSystem >& xCooSys )
84*cdf0e10cSrcweir     : m_xCooSysModel(xCooSys)
85*cdf0e10cSrcweir     , m_xLogicTargetForGrids(0)
86*cdf0e10cSrcweir     , m_xLogicTargetForAxes(0)
87*cdf0e10cSrcweir     , m_xFinalTarget(0)
88*cdf0e10cSrcweir     , m_xShapeFactory(0)
89*cdf0e10cSrcweir     , m_aMatrixSceneToScreen()
90*cdf0e10cSrcweir     , m_eLeftWallPos(CuboidPlanePosition_Left)
91*cdf0e10cSrcweir     , m_eBackWallPos(CuboidPlanePosition_Back)
92*cdf0e10cSrcweir     , m_eBottomPos(CuboidPlanePosition_Bottom)
93*cdf0e10cSrcweir     , m_aMergedMinimumAndMaximumSupplier()
94*cdf0e10cSrcweir     , m_aExplicitScales(3)
95*cdf0e10cSrcweir     , m_aExplicitIncrements(3)
96*cdf0e10cSrcweir     , m_apExplicitCategoriesProvider(NULL)
97*cdf0e10cSrcweir {
98*cdf0e10cSrcweir     if( !m_xCooSysModel.is() || m_xCooSysModel->getDimension()<3 )
99*cdf0e10cSrcweir     {
100*cdf0e10cSrcweir         m_aExplicitScales[2].Minimum = 1.0;
101*cdf0e10cSrcweir         m_aExplicitScales[2].Maximum = 2.0;
102*cdf0e10cSrcweir         m_aExplicitScales[2].Orientation = AxisOrientation_MATHEMATICAL;
103*cdf0e10cSrcweir     }
104*cdf0e10cSrcweir }
105*cdf0e10cSrcweir VCoordinateSystem::~VCoordinateSystem()
106*cdf0e10cSrcweir {
107*cdf0e10cSrcweir }
108*cdf0e10cSrcweir 
109*cdf0e10cSrcweir void VCoordinateSystem::initPlottingTargets(  const Reference< drawing::XShapes >& xLogicTarget
110*cdf0e10cSrcweir 	   , const Reference< drawing::XShapes >& xFinalTarget
111*cdf0e10cSrcweir 	   , const Reference< lang::XMultiServiceFactory >& xShapeFactory
112*cdf0e10cSrcweir        , Reference< drawing::XShapes >& xLogicTargetForSeriesBehindAxis )
113*cdf0e10cSrcweir 	        throw (uno::RuntimeException)
114*cdf0e10cSrcweir {
115*cdf0e10cSrcweir     DBG_ASSERT(xLogicTarget.is()&&xFinalTarget.is()&&xShapeFactory.is(),"no proper initialization parameters");
116*cdf0e10cSrcweir 	//is only allowed to be called once
117*cdf0e10cSrcweir 
118*cdf0e10cSrcweir     sal_Int32 nDimensionCount = m_xCooSysModel->getDimension();
119*cdf0e10cSrcweir     //create group shape for grids first thus axes are always painted above grids
120*cdf0e10cSrcweir     ShapeFactory aShapeFactory(xShapeFactory);
121*cdf0e10cSrcweir     if(nDimensionCount==2)
122*cdf0e10cSrcweir     {
123*cdf0e10cSrcweir         //create and add to target
124*cdf0e10cSrcweir         m_xLogicTargetForGrids = aShapeFactory.createGroup2D( xLogicTarget );
125*cdf0e10cSrcweir         xLogicTargetForSeriesBehindAxis = aShapeFactory.createGroup2D( xLogicTarget );
126*cdf0e10cSrcweir         m_xLogicTargetForAxes = aShapeFactory.createGroup2D( xLogicTarget );
127*cdf0e10cSrcweir     }
128*cdf0e10cSrcweir     else
129*cdf0e10cSrcweir     {
130*cdf0e10cSrcweir         //create and added to target
131*cdf0e10cSrcweir         m_xLogicTargetForGrids = aShapeFactory.createGroup3D( xLogicTarget );
132*cdf0e10cSrcweir         xLogicTargetForSeriesBehindAxis = aShapeFactory.createGroup3D( xLogicTarget );
133*cdf0e10cSrcweir         m_xLogicTargetForAxes = aShapeFactory.createGroup3D( xLogicTarget );
134*cdf0e10cSrcweir     }
135*cdf0e10cSrcweir 	m_xFinalTarget  = xFinalTarget;
136*cdf0e10cSrcweir 	m_xShapeFactory = xShapeFactory;
137*cdf0e10cSrcweir }
138*cdf0e10cSrcweir 
139*cdf0e10cSrcweir void VCoordinateSystem::setParticle( const rtl::OUString& rCooSysParticle )
140*cdf0e10cSrcweir {
141*cdf0e10cSrcweir     m_aCooSysParticle = rCooSysParticle;
142*cdf0e10cSrcweir }
143*cdf0e10cSrcweir 
144*cdf0e10cSrcweir void VCoordinateSystem::setTransformationSceneToScreen(
145*cdf0e10cSrcweir     const drawing::HomogenMatrix& rMatrix )
146*cdf0e10cSrcweir {
147*cdf0e10cSrcweir     m_aMatrixSceneToScreen = rMatrix;
148*cdf0e10cSrcweir 
149*cdf0e10cSrcweir     //correct transformation for axis
150*cdf0e10cSrcweir     tVAxisMap::iterator aIt( m_aAxisMap.begin() );
151*cdf0e10cSrcweir     tVAxisMap::const_iterator aEnd( m_aAxisMap.end() );
152*cdf0e10cSrcweir     for( ; aIt != aEnd; ++aIt )
153*cdf0e10cSrcweir     {
154*cdf0e10cSrcweir         VAxisBase* pVAxis = aIt->second.get();
155*cdf0e10cSrcweir         if( pVAxis )
156*cdf0e10cSrcweir         {
157*cdf0e10cSrcweir             if(2==pVAxis->getDimensionCount())
158*cdf0e10cSrcweir                 pVAxis->setTransformationSceneToScreen( m_aMatrixSceneToScreen );
159*cdf0e10cSrcweir         }
160*cdf0e10cSrcweir     }
161*cdf0e10cSrcweir }
162*cdf0e10cSrcweir 
163*cdf0e10cSrcweir drawing::HomogenMatrix VCoordinateSystem::getTransformationSceneToScreen()
164*cdf0e10cSrcweir {
165*cdf0e10cSrcweir     return m_aMatrixSceneToScreen;
166*cdf0e10cSrcweir }
167*cdf0e10cSrcweir 
168*cdf0e10cSrcweir //better performance for big data
169*cdf0e10cSrcweir uno::Sequence< sal_Int32 > VCoordinateSystem::getCoordinateSystemResolution(
170*cdf0e10cSrcweir             const awt::Size& rPageSize, const awt::Size& rPageResolution )
171*cdf0e10cSrcweir {
172*cdf0e10cSrcweir     uno::Sequence< sal_Int32 > aResolution(2);
173*cdf0e10cSrcweir 
174*cdf0e10cSrcweir     sal_Int32 nDimensionCount = m_xCooSysModel->getDimension();
175*cdf0e10cSrcweir     if(nDimensionCount>2)
176*cdf0e10cSrcweir         aResolution.realloc(nDimensionCount);
177*cdf0e10cSrcweir     sal_Int32 nN = 0;
178*cdf0e10cSrcweir     for( nN = 0 ;nN<aResolution.getLength(); nN++ )
179*cdf0e10cSrcweir         aResolution[nN]=1000;
180*cdf0e10cSrcweir 
181*cdf0e10cSrcweir     ::basegfx::B3DTuple aScale( BaseGFXHelper::GetScaleFromMatrix(
182*cdf0e10cSrcweir         BaseGFXHelper::HomogenMatrixToB3DHomMatrix(
183*cdf0e10cSrcweir             m_aMatrixSceneToScreen ) ) );
184*cdf0e10cSrcweir 
185*cdf0e10cSrcweir     double fCoosysWidth = static_cast< double >( fabs(aScale.getX()*FIXED_SIZE_FOR_3D_CHART_VOLUME));
186*cdf0e10cSrcweir     double fCoosysHeight = static_cast< double >( fabs(aScale.getY()*FIXED_SIZE_FOR_3D_CHART_VOLUME));
187*cdf0e10cSrcweir 
188*cdf0e10cSrcweir     double fPageWidth = rPageSize.Width;
189*cdf0e10cSrcweir     double fPageHeight = rPageSize.Height;
190*cdf0e10cSrcweir 
191*cdf0e10cSrcweir     //factor 2 to avoid rounding problems
192*cdf0e10cSrcweir     sal_Int32 nXResolution = static_cast<sal_Int32>(2.0*static_cast<double>(rPageResolution.Width)*fCoosysWidth/fPageWidth);
193*cdf0e10cSrcweir     sal_Int32 nYResolution = static_cast<sal_Int32>(2.0*static_cast<double>(rPageResolution.Height)*fCoosysHeight/fPageHeight);
194*cdf0e10cSrcweir 
195*cdf0e10cSrcweir     if( nXResolution < 10 )
196*cdf0e10cSrcweir         nXResolution = 10;
197*cdf0e10cSrcweir     if( nYResolution < 10 )
198*cdf0e10cSrcweir         nYResolution = 10;
199*cdf0e10cSrcweir 
200*cdf0e10cSrcweir     if( this->getPropertySwapXAndYAxis() )
201*cdf0e10cSrcweir         std::swap(nXResolution,nYResolution);
202*cdf0e10cSrcweir 
203*cdf0e10cSrcweir     //2D
204*cdf0e10cSrcweir     if( 2 == aResolution.getLength() )
205*cdf0e10cSrcweir     {
206*cdf0e10cSrcweir         aResolution[0]=nXResolution;
207*cdf0e10cSrcweir         aResolution[1]=nYResolution;
208*cdf0e10cSrcweir     }
209*cdf0e10cSrcweir     else
210*cdf0e10cSrcweir     {
211*cdf0e10cSrcweir         //this maybe can be optimized further ...
212*cdf0e10cSrcweir         sal_Int32 nMaxResolution = std::max( nXResolution, nYResolution );
213*cdf0e10cSrcweir         nMaxResolution*=2;
214*cdf0e10cSrcweir         for( nN = 0 ;nN<aResolution.getLength(); nN++ )
215*cdf0e10cSrcweir             aResolution[nN]=nMaxResolution;
216*cdf0e10cSrcweir     }
217*cdf0e10cSrcweir 
218*cdf0e10cSrcweir     return aResolution;
219*cdf0e10cSrcweir }
220*cdf0e10cSrcweir 
221*cdf0e10cSrcweir Reference< XCoordinateSystem > VCoordinateSystem::getModel() const
222*cdf0e10cSrcweir {
223*cdf0e10cSrcweir     return m_xCooSysModel;
224*cdf0e10cSrcweir }
225*cdf0e10cSrcweir 
226*cdf0e10cSrcweir Reference< XAxis > VCoordinateSystem::getAxisByDimension( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ) const
227*cdf0e10cSrcweir {
228*cdf0e10cSrcweir     if( m_xCooSysModel.is() )
229*cdf0e10cSrcweir         return m_xCooSysModel->getAxisByDimension( nDimensionIndex, nAxisIndex );
230*cdf0e10cSrcweir     return 0;
231*cdf0e10cSrcweir }
232*cdf0e10cSrcweir 
233*cdf0e10cSrcweir Sequence< Reference< beans::XPropertySet > > VCoordinateSystem::getGridListFromAxis( const Reference< XAxis >& xAxis )
234*cdf0e10cSrcweir {
235*cdf0e10cSrcweir     std::vector< Reference< beans::XPropertySet > > aRet;
236*cdf0e10cSrcweir 
237*cdf0e10cSrcweir     if( xAxis.is() )
238*cdf0e10cSrcweir     {
239*cdf0e10cSrcweir         aRet.push_back( xAxis->getGridProperties() );
240*cdf0e10cSrcweir         std::vector< Reference< beans::XPropertySet > > aSubGrids( ContainerHelper::SequenceToVector( xAxis->getSubGridProperties() ) );
241*cdf0e10cSrcweir         aRet.insert( aRet.end(), aSubGrids.begin(), aSubGrids.end() );
242*cdf0e10cSrcweir     }
243*cdf0e10cSrcweir 
244*cdf0e10cSrcweir     return ContainerHelper::ContainerToSequence( aRet );
245*cdf0e10cSrcweir }
246*cdf0e10cSrcweir 
247*cdf0e10cSrcweir void VCoordinateSystem::impl_adjustDimension( sal_Int32& rDimensionIndex ) const
248*cdf0e10cSrcweir {
249*cdf0e10cSrcweir     if( rDimensionIndex<0 )
250*cdf0e10cSrcweir         rDimensionIndex=0;
251*cdf0e10cSrcweir     if( rDimensionIndex>2 )
252*cdf0e10cSrcweir         rDimensionIndex=2;
253*cdf0e10cSrcweir }
254*cdf0e10cSrcweir 
255*cdf0e10cSrcweir void VCoordinateSystem::impl_adjustDimensionAndIndex( sal_Int32& rDimensionIndex, sal_Int32& rAxisIndex ) const
256*cdf0e10cSrcweir {
257*cdf0e10cSrcweir     impl_adjustDimension( rDimensionIndex );
258*cdf0e10cSrcweir 
259*cdf0e10cSrcweir     if( rAxisIndex < 0 || rAxisIndex > this->getMaximumAxisIndexByDimension(rDimensionIndex) )
260*cdf0e10cSrcweir         rAxisIndex = 0;
261*cdf0e10cSrcweir }
262*cdf0e10cSrcweir 
263*cdf0e10cSrcweir void VCoordinateSystem::setExplicitCategoriesProvider( ExplicitCategoriesProvider* pExplicitCategoriesProvider /*takes ownership*/ )
264*cdf0e10cSrcweir {
265*cdf0e10cSrcweir     m_apExplicitCategoriesProvider = ::std::auto_ptr< ExplicitCategoriesProvider >(pExplicitCategoriesProvider);
266*cdf0e10cSrcweir }
267*cdf0e10cSrcweir 
268*cdf0e10cSrcweir ExplicitCategoriesProvider* VCoordinateSystem::getExplicitCategoriesProvider()
269*cdf0e10cSrcweir {
270*cdf0e10cSrcweir     return m_apExplicitCategoriesProvider.get();
271*cdf0e10cSrcweir }
272*cdf0e10cSrcweir 
273*cdf0e10cSrcweir std::vector< ExplicitScaleData > VCoordinateSystem::getExplicitScales( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ) const
274*cdf0e10cSrcweir {
275*cdf0e10cSrcweir     std::vector< ExplicitScaleData > aRet(m_aExplicitScales);
276*cdf0e10cSrcweir 
277*cdf0e10cSrcweir     impl_adjustDimensionAndIndex( nDimensionIndex, nAxisIndex );
278*cdf0e10cSrcweir     aRet[nDimensionIndex]=this->getExplicitScale( nDimensionIndex, nAxisIndex );
279*cdf0e10cSrcweir 
280*cdf0e10cSrcweir     return aRet;
281*cdf0e10cSrcweir }
282*cdf0e10cSrcweir 
283*cdf0e10cSrcweir std::vector< ExplicitIncrementData > VCoordinateSystem::getExplicitIncrements( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ) const
284*cdf0e10cSrcweir {
285*cdf0e10cSrcweir     std::vector< ExplicitIncrementData > aRet(m_aExplicitIncrements);
286*cdf0e10cSrcweir 
287*cdf0e10cSrcweir     impl_adjustDimensionAndIndex( nDimensionIndex, nAxisIndex );
288*cdf0e10cSrcweir     aRet[nDimensionIndex]=this->getExplicitIncrement( nDimensionIndex, nAxisIndex );
289*cdf0e10cSrcweir 
290*cdf0e10cSrcweir     return aRet;
291*cdf0e10cSrcweir }
292*cdf0e10cSrcweir 
293*cdf0e10cSrcweir ExplicitScaleData VCoordinateSystem::getExplicitScale( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ) const
294*cdf0e10cSrcweir {
295*cdf0e10cSrcweir     ExplicitScaleData aRet;
296*cdf0e10cSrcweir 
297*cdf0e10cSrcweir     impl_adjustDimensionAndIndex( nDimensionIndex, nAxisIndex );
298*cdf0e10cSrcweir 
299*cdf0e10cSrcweir     if( nAxisIndex == 0)
300*cdf0e10cSrcweir     {
301*cdf0e10cSrcweir         aRet = m_aExplicitScales[nDimensionIndex];
302*cdf0e10cSrcweir     }
303*cdf0e10cSrcweir     else
304*cdf0e10cSrcweir     {
305*cdf0e10cSrcweir         tFullAxisIndex aFullAxisIndex( nDimensionIndex, nAxisIndex );
306*cdf0e10cSrcweir         tFullExplicitScaleMap::const_iterator aIt = m_aSecondaryExplicitScales.find( aFullAxisIndex );
307*cdf0e10cSrcweir         if( aIt != m_aSecondaryExplicitScales.end() )
308*cdf0e10cSrcweir             aRet = aIt->second;
309*cdf0e10cSrcweir         else
310*cdf0e10cSrcweir             aRet = m_aExplicitScales[nDimensionIndex];
311*cdf0e10cSrcweir     }
312*cdf0e10cSrcweir 
313*cdf0e10cSrcweir     return aRet;
314*cdf0e10cSrcweir }
315*cdf0e10cSrcweir 
316*cdf0e10cSrcweir ExplicitIncrementData VCoordinateSystem::getExplicitIncrement( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ) const
317*cdf0e10cSrcweir {
318*cdf0e10cSrcweir     ExplicitIncrementData aRet;
319*cdf0e10cSrcweir 
320*cdf0e10cSrcweir     impl_adjustDimensionAndIndex( nDimensionIndex, nAxisIndex );
321*cdf0e10cSrcweir 
322*cdf0e10cSrcweir     if( nAxisIndex == 0)
323*cdf0e10cSrcweir     {
324*cdf0e10cSrcweir         aRet = m_aExplicitIncrements[nDimensionIndex];
325*cdf0e10cSrcweir     }
326*cdf0e10cSrcweir     else
327*cdf0e10cSrcweir     {
328*cdf0e10cSrcweir         tFullAxisIndex aFullAxisIndex( nDimensionIndex, nAxisIndex );
329*cdf0e10cSrcweir         tFullExplicitIncrementMap::const_iterator aIt = m_aSecondaryExplicitIncrements.find( aFullAxisIndex );
330*cdf0e10cSrcweir         if( aIt != m_aSecondaryExplicitIncrements.end() )
331*cdf0e10cSrcweir             aRet = aIt->second;
332*cdf0e10cSrcweir         else
333*cdf0e10cSrcweir             aRet = m_aExplicitIncrements[nDimensionIndex];
334*cdf0e10cSrcweir     }
335*cdf0e10cSrcweir 
336*cdf0e10cSrcweir     return aRet;
337*cdf0e10cSrcweir }
338*cdf0e10cSrcweir 
339*cdf0e10cSrcweir rtl::OUString VCoordinateSystem::createCIDForAxis( const Reference< chart2::XAxis >& /* xAxis */, sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex )
340*cdf0e10cSrcweir {
341*cdf0e10cSrcweir     rtl::OUString aAxisParticle( ObjectIdentifier::createParticleForAxis( nDimensionIndex, nAxisIndex ) );
342*cdf0e10cSrcweir     return ObjectIdentifier::createClassifiedIdentifierForParticles( m_aCooSysParticle, aAxisParticle );
343*cdf0e10cSrcweir }
344*cdf0e10cSrcweir rtl::OUString VCoordinateSystem::createCIDForGrid( const Reference< chart2::XAxis >& /* xAxis */, sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex )
345*cdf0e10cSrcweir {
346*cdf0e10cSrcweir     rtl::OUString aGridParticle( ObjectIdentifier::createParticleForGrid( nDimensionIndex, nAxisIndex ) );
347*cdf0e10cSrcweir     return ObjectIdentifier::createClassifiedIdentifierForParticles( m_aCooSysParticle, aGridParticle );
348*cdf0e10cSrcweir }
349*cdf0e10cSrcweir 
350*cdf0e10cSrcweir sal_Int32 VCoordinateSystem::getMaximumAxisIndexByDimension( sal_Int32 nDimensionIndex ) const
351*cdf0e10cSrcweir {
352*cdf0e10cSrcweir     sal_Int32 nRet = 0;
353*cdf0e10cSrcweir     tFullExplicitScaleMap::const_iterator aIt = m_aSecondaryExplicitScales.begin();
354*cdf0e10cSrcweir     tFullExplicitScaleMap::const_iterator aEnd = m_aSecondaryExplicitScales.end();
355*cdf0e10cSrcweir     for(; aIt!=aEnd; ++aIt)
356*cdf0e10cSrcweir     {
357*cdf0e10cSrcweir         if(aIt->first.first==nDimensionIndex)
358*cdf0e10cSrcweir         {
359*cdf0e10cSrcweir             sal_Int32 nLocalIdx = aIt->first.second;
360*cdf0e10cSrcweir             if( nRet < nLocalIdx )
361*cdf0e10cSrcweir                 nRet = nLocalIdx;
362*cdf0e10cSrcweir         }
363*cdf0e10cSrcweir     }
364*cdf0e10cSrcweir     return nRet;
365*cdf0e10cSrcweir }
366*cdf0e10cSrcweir 
367*cdf0e10cSrcweir void VCoordinateSystem::createVAxisList(
368*cdf0e10cSrcweir               const uno::Reference< util::XNumberFormatsSupplier > & /* xNumberFormatsSupplier */
369*cdf0e10cSrcweir             , const awt::Size& /* rFontReferenceSize */
370*cdf0e10cSrcweir             , const awt::Rectangle& /* rMaximumSpaceForLabels */
371*cdf0e10cSrcweir             )
372*cdf0e10cSrcweir {
373*cdf0e10cSrcweir }
374*cdf0e10cSrcweir 
375*cdf0e10cSrcweir void VCoordinateSystem::initVAxisInList()
376*cdf0e10cSrcweir {
377*cdf0e10cSrcweir }
378*cdf0e10cSrcweir void VCoordinateSystem::updateScalesAndIncrementsOnAxes()
379*cdf0e10cSrcweir {
380*cdf0e10cSrcweir }
381*cdf0e10cSrcweir 
382*cdf0e10cSrcweir void VCoordinateSystem::prepareScaleAutomatismForDimensionAndIndex( ScaleAutomatism& rScaleAutomatism, sal_Int32 nDimIndex, sal_Int32 nAxisIndex )
383*cdf0e10cSrcweir {
384*cdf0e10cSrcweir     if( rScaleAutomatism.getScale().AxisType==AxisType::DATE && nDimIndex==0 )
385*cdf0e10cSrcweir     {
386*cdf0e10cSrcweir         sal_Int32 nTimeResolution = ::com::sun::star::chart::TimeUnit::MONTH;
387*cdf0e10cSrcweir         if( !(rScaleAutomatism.getScale().TimeIncrement.TimeResolution >>= nTimeResolution) )
388*cdf0e10cSrcweir         {
389*cdf0e10cSrcweir             nTimeResolution = m_aMergedMinimumAndMaximumSupplier.calculateTimeResolutionOnXAxis();
390*cdf0e10cSrcweir             rScaleAutomatism.setAutomaticTimeResolution( nTimeResolution );
391*cdf0e10cSrcweir         }
392*cdf0e10cSrcweir         m_aMergedMinimumAndMaximumSupplier.setTimeResolutionOnXAxis( nTimeResolution, rScaleAutomatism.getNullDate() );
393*cdf0e10cSrcweir     }
394*cdf0e10cSrcweir 
395*cdf0e10cSrcweir     double fMin = 0.0;
396*cdf0e10cSrcweir     double fMax = 0.0;
397*cdf0e10cSrcweir     ::rtl::math::setInf(&fMin, false);
398*cdf0e10cSrcweir     ::rtl::math::setInf(&fMax, true);
399*cdf0e10cSrcweir     if( 0 == nDimIndex )
400*cdf0e10cSrcweir     {
401*cdf0e10cSrcweir         fMin = m_aMergedMinimumAndMaximumSupplier.getMinimumX();
402*cdf0e10cSrcweir         fMax = m_aMergedMinimumAndMaximumSupplier.getMaximumX();
403*cdf0e10cSrcweir     }
404*cdf0e10cSrcweir     else if( 1 == nDimIndex )
405*cdf0e10cSrcweir     {
406*cdf0e10cSrcweir         ExplicitScaleData aScale = getExplicitScale( 0, 0 );
407*cdf0e10cSrcweir         fMin = m_aMergedMinimumAndMaximumSupplier.getMinimumYInRange(aScale.Minimum,aScale.Maximum, nAxisIndex);
408*cdf0e10cSrcweir         fMax = m_aMergedMinimumAndMaximumSupplier.getMaximumYInRange(aScale.Minimum,aScale.Maximum, nAxisIndex);
409*cdf0e10cSrcweir     }
410*cdf0e10cSrcweir     else if( 2 == nDimIndex )
411*cdf0e10cSrcweir     {
412*cdf0e10cSrcweir         fMin = m_aMergedMinimumAndMaximumSupplier.getMinimumZ();
413*cdf0e10cSrcweir         fMax = m_aMergedMinimumAndMaximumSupplier.getMaximumZ();
414*cdf0e10cSrcweir     }
415*cdf0e10cSrcweir 
416*cdf0e10cSrcweir     //merge our values with those already contained in rScaleAutomatism
417*cdf0e10cSrcweir     rScaleAutomatism.expandValueRange( fMin, fMax );
418*cdf0e10cSrcweir 
419*cdf0e10cSrcweir     rScaleAutomatism.setAutoScalingOptions(
420*cdf0e10cSrcweir         m_aMergedMinimumAndMaximumSupplier.isExpandBorderToIncrementRhythm( nDimIndex ),
421*cdf0e10cSrcweir         m_aMergedMinimumAndMaximumSupplier.isExpandIfValuesCloseToBorder( nDimIndex ),
422*cdf0e10cSrcweir         m_aMergedMinimumAndMaximumSupplier.isExpandWideValuesToZero( nDimIndex ),
423*cdf0e10cSrcweir         m_aMergedMinimumAndMaximumSupplier.isExpandNarrowValuesTowardZero( nDimIndex ) );
424*cdf0e10cSrcweir 
425*cdf0e10cSrcweir     VAxisBase* pVAxis( this->getVAxis( nDimIndex, nAxisIndex ) );
426*cdf0e10cSrcweir     if( pVAxis )
427*cdf0e10cSrcweir         rScaleAutomatism.setMaximumAutoMainIncrementCount( pVAxis->estimateMaximumAutoMainIncrementCount() );
428*cdf0e10cSrcweir }
429*cdf0e10cSrcweir 
430*cdf0e10cSrcweir VAxisBase* VCoordinateSystem::getVAxis( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex )
431*cdf0e10cSrcweir {
432*cdf0e10cSrcweir     VAxisBase* pRet = 0;
433*cdf0e10cSrcweir 
434*cdf0e10cSrcweir     tFullAxisIndex aFullAxisIndex( nDimensionIndex, nAxisIndex );
435*cdf0e10cSrcweir 
436*cdf0e10cSrcweir     tVAxisMap::const_iterator aIt = m_aAxisMap.find( aFullAxisIndex );
437*cdf0e10cSrcweir     if( aIt != m_aAxisMap.end() )
438*cdf0e10cSrcweir         pRet = aIt->second.get();
439*cdf0e10cSrcweir 
440*cdf0e10cSrcweir     return pRet;
441*cdf0e10cSrcweir }
442*cdf0e10cSrcweir 
443*cdf0e10cSrcweir void VCoordinateSystem::setExplicitScaleAndIncrement(
444*cdf0e10cSrcweir           sal_Int32 nDimensionIndex
445*cdf0e10cSrcweir         , sal_Int32 nAxisIndex
446*cdf0e10cSrcweir         , const ExplicitScaleData& rExplicitScale
447*cdf0e10cSrcweir         , const ExplicitIncrementData& rExplicitIncrement )
448*cdf0e10cSrcweir {
449*cdf0e10cSrcweir     impl_adjustDimension( nDimensionIndex );
450*cdf0e10cSrcweir 
451*cdf0e10cSrcweir     if( nAxisIndex==0 )
452*cdf0e10cSrcweir     {
453*cdf0e10cSrcweir         m_aExplicitScales[nDimensionIndex]=rExplicitScale;
454*cdf0e10cSrcweir         m_aExplicitIncrements[nDimensionIndex]=rExplicitIncrement;
455*cdf0e10cSrcweir     }
456*cdf0e10cSrcweir     else
457*cdf0e10cSrcweir     {
458*cdf0e10cSrcweir         tFullAxisIndex aFullAxisIndex( nDimensionIndex, nAxisIndex );
459*cdf0e10cSrcweir         m_aSecondaryExplicitScales[aFullAxisIndex] = rExplicitScale;
460*cdf0e10cSrcweir         m_aSecondaryExplicitIncrements[aFullAxisIndex] = rExplicitIncrement;
461*cdf0e10cSrcweir     }
462*cdf0e10cSrcweir }
463*cdf0e10cSrcweir 
464*cdf0e10cSrcweir void VCoordinateSystem::set3DWallPositions( CuboidPlanePosition eLeftWallPos, CuboidPlanePosition eBackWallPos, CuboidPlanePosition eBottomPos )
465*cdf0e10cSrcweir {
466*cdf0e10cSrcweir     m_eLeftWallPos = eLeftWallPos;
467*cdf0e10cSrcweir     m_eBackWallPos = eBackWallPos;
468*cdf0e10cSrcweir     m_eBottomPos = eBottomPos;
469*cdf0e10cSrcweir }
470*cdf0e10cSrcweir 
471*cdf0e10cSrcweir void VCoordinateSystem::createMaximumAxesLabels()
472*cdf0e10cSrcweir {
473*cdf0e10cSrcweir     tVAxisMap::iterator aIt( m_aAxisMap.begin() );
474*cdf0e10cSrcweir     tVAxisMap::const_iterator aEnd( m_aAxisMap.end() );
475*cdf0e10cSrcweir     for( ; aIt != aEnd; ++aIt )
476*cdf0e10cSrcweir     {
477*cdf0e10cSrcweir         VAxisBase* pVAxis = aIt->second.get();
478*cdf0e10cSrcweir         if( pVAxis )
479*cdf0e10cSrcweir         {
480*cdf0e10cSrcweir             if(2==pVAxis->getDimensionCount())
481*cdf0e10cSrcweir                 pVAxis->setTransformationSceneToScreen( m_aMatrixSceneToScreen );
482*cdf0e10cSrcweir             pVAxis->createMaximumLabels();
483*cdf0e10cSrcweir         }
484*cdf0e10cSrcweir     }
485*cdf0e10cSrcweir }
486*cdf0e10cSrcweir void VCoordinateSystem::createAxesLabels()
487*cdf0e10cSrcweir {
488*cdf0e10cSrcweir     tVAxisMap::iterator aIt( m_aAxisMap.begin() );
489*cdf0e10cSrcweir     tVAxisMap::const_iterator aEnd( m_aAxisMap.end() );
490*cdf0e10cSrcweir     for( ; aIt != aEnd; ++aIt )
491*cdf0e10cSrcweir     {
492*cdf0e10cSrcweir         VAxisBase* pVAxis = aIt->second.get();
493*cdf0e10cSrcweir         if( pVAxis )
494*cdf0e10cSrcweir         {
495*cdf0e10cSrcweir             if(2==pVAxis->getDimensionCount())
496*cdf0e10cSrcweir                 pVAxis->setTransformationSceneToScreen( m_aMatrixSceneToScreen );
497*cdf0e10cSrcweir             pVAxis->createLabels();
498*cdf0e10cSrcweir         }
499*cdf0e10cSrcweir     }
500*cdf0e10cSrcweir }
501*cdf0e10cSrcweir 
502*cdf0e10cSrcweir void VCoordinateSystem::updatePositions()
503*cdf0e10cSrcweir {
504*cdf0e10cSrcweir     tVAxisMap::iterator aIt( m_aAxisMap.begin() );
505*cdf0e10cSrcweir     tVAxisMap::const_iterator aEnd( m_aAxisMap.end() );
506*cdf0e10cSrcweir     for( ; aIt != aEnd; ++aIt )
507*cdf0e10cSrcweir     {
508*cdf0e10cSrcweir         VAxisBase* pVAxis = aIt->second.get();
509*cdf0e10cSrcweir         if( pVAxis )
510*cdf0e10cSrcweir         {
511*cdf0e10cSrcweir             if(2==pVAxis->getDimensionCount())
512*cdf0e10cSrcweir                 pVAxis->setTransformationSceneToScreen( m_aMatrixSceneToScreen );
513*cdf0e10cSrcweir             pVAxis->updatePositions();
514*cdf0e10cSrcweir         }
515*cdf0e10cSrcweir     }
516*cdf0e10cSrcweir }
517*cdf0e10cSrcweir 
518*cdf0e10cSrcweir void VCoordinateSystem::createAxesShapes()
519*cdf0e10cSrcweir {
520*cdf0e10cSrcweir     tVAxisMap::iterator aIt( m_aAxisMap.begin() );
521*cdf0e10cSrcweir     tVAxisMap::const_iterator aEnd( m_aAxisMap.end() );
522*cdf0e10cSrcweir     for( ; aIt != aEnd; ++aIt )
523*cdf0e10cSrcweir     {
524*cdf0e10cSrcweir         VAxisBase* pVAxis = aIt->second.get();
525*cdf0e10cSrcweir         if( pVAxis )
526*cdf0e10cSrcweir         {
527*cdf0e10cSrcweir             if(2==pVAxis->getDimensionCount())
528*cdf0e10cSrcweir                 pVAxis->setTransformationSceneToScreen( m_aMatrixSceneToScreen );
529*cdf0e10cSrcweir 
530*cdf0e10cSrcweir             tFullAxisIndex aFullAxisIndex = aIt->first;
531*cdf0e10cSrcweir             if( aFullAxisIndex.second == 0 )
532*cdf0e10cSrcweir             {
533*cdf0e10cSrcweir                 if( aFullAxisIndex.first == 0 )
534*cdf0e10cSrcweir                 {
535*cdf0e10cSrcweir                     if( AxisType::CATEGORY!=m_aExplicitScales[1].AxisType )
536*cdf0e10cSrcweir                         pVAxis->setExrtaLinePositionAtOtherAxis(
537*cdf0e10cSrcweir                             m_aExplicitScales[1].Origin );
538*cdf0e10cSrcweir                 }
539*cdf0e10cSrcweir                 else if( aFullAxisIndex.first == 1 )
540*cdf0e10cSrcweir                 {
541*cdf0e10cSrcweir                     if( AxisType::CATEGORY!=m_aExplicitScales[0].AxisType )
542*cdf0e10cSrcweir                         pVAxis->setExrtaLinePositionAtOtherAxis(
543*cdf0e10cSrcweir                             m_aExplicitScales[0].Origin );
544*cdf0e10cSrcweir                 }
545*cdf0e10cSrcweir             }
546*cdf0e10cSrcweir 
547*cdf0e10cSrcweir             pVAxis->createShapes();
548*cdf0e10cSrcweir         }
549*cdf0e10cSrcweir     }
550*cdf0e10cSrcweir }
551*cdf0e10cSrcweir void VCoordinateSystem::createGridShapes()
552*cdf0e10cSrcweir {
553*cdf0e10cSrcweir }
554*cdf0e10cSrcweir void VCoordinateSystem::addMinimumAndMaximumSupplier( MinimumAndMaximumSupplier* pMinimumAndMaximumSupplier )
555*cdf0e10cSrcweir {
556*cdf0e10cSrcweir     m_aMergedMinimumAndMaximumSupplier.addMinimumAndMaximumSupplier(pMinimumAndMaximumSupplier);
557*cdf0e10cSrcweir }
558*cdf0e10cSrcweir 
559*cdf0e10cSrcweir bool VCoordinateSystem::hasMinimumAndMaximumSupplier( MinimumAndMaximumSupplier* pMinimumAndMaximumSupplier )
560*cdf0e10cSrcweir {
561*cdf0e10cSrcweir     return m_aMergedMinimumAndMaximumSupplier.hasMinimumAndMaximumSupplier(pMinimumAndMaximumSupplier);
562*cdf0e10cSrcweir }
563*cdf0e10cSrcweir 
564*cdf0e10cSrcweir void VCoordinateSystem::clearMinimumAndMaximumSupplierList()
565*cdf0e10cSrcweir {
566*cdf0e10cSrcweir     m_aMergedMinimumAndMaximumSupplier.clearMinimumAndMaximumSupplierList();
567*cdf0e10cSrcweir }
568*cdf0e10cSrcweir 
569*cdf0e10cSrcweir bool VCoordinateSystem::getPropertySwapXAndYAxis() const
570*cdf0e10cSrcweir {
571*cdf0e10cSrcweir     Reference<beans::XPropertySet> xProp(m_xCooSysModel, uno::UNO_QUERY );
572*cdf0e10cSrcweir     sal_Bool bSwapXAndY = false;
573*cdf0e10cSrcweir     if( xProp.is()) try
574*cdf0e10cSrcweir     {
575*cdf0e10cSrcweir         xProp->getPropertyValue( C2U( "SwapXAndYAxis" ) ) >>= bSwapXAndY;
576*cdf0e10cSrcweir     }
577*cdf0e10cSrcweir     catch( uno::Exception& e )
578*cdf0e10cSrcweir     {
579*cdf0e10cSrcweir         ASSERT_EXCEPTION( e );
580*cdf0e10cSrcweir     }
581*cdf0e10cSrcweir     return bSwapXAndY;
582*cdf0e10cSrcweir }
583*cdf0e10cSrcweir 
584*cdf0e10cSrcweir bool VCoordinateSystem::needSeriesNamesForAxis() const
585*cdf0e10cSrcweir {
586*cdf0e10cSrcweir     return ( m_xCooSysModel.is() && m_xCooSysModel->getDimension() == 3 );
587*cdf0e10cSrcweir }
588*cdf0e10cSrcweir void VCoordinateSystem::setSeriesNamesForAxis( const Sequence< rtl::OUString >& rSeriesNames )
589*cdf0e10cSrcweir {
590*cdf0e10cSrcweir     m_aSeriesNamesForZAxis = rSeriesNames;
591*cdf0e10cSrcweir }
592*cdf0e10cSrcweir 
593*cdf0e10cSrcweir sal_Int32 VCoordinateSystem::getNumberFormatKeyForAxis(
594*cdf0e10cSrcweir         const Reference< chart2::XAxis >& xAxis
595*cdf0e10cSrcweir         , const Reference< util::XNumberFormatsSupplier >& xNumberFormatsSupplier )
596*cdf0e10cSrcweir {
597*cdf0e10cSrcweir     return ExplicitValueProvider::getExplicitNumberFormatKeyForAxis(
598*cdf0e10cSrcweir                 xAxis, m_xCooSysModel, xNumberFormatsSupplier );
599*cdf0e10cSrcweir }
600*cdf0e10cSrcweir 
601*cdf0e10cSrcweir //.............................................................................
602*cdf0e10cSrcweir } //namespace chart
603*cdf0e10cSrcweir //.............................................................................
604