1*cde9e8dcSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*cde9e8dcSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*cde9e8dcSAndrew Rist * or more contributor license agreements. See the NOTICE file
5*cde9e8dcSAndrew Rist * distributed with this work for additional information
6*cde9e8dcSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*cde9e8dcSAndrew Rist * to you under the Apache License, Version 2.0 (the
8*cde9e8dcSAndrew Rist * "License"); you may not use this file except in compliance
9*cde9e8dcSAndrew Rist * with the License. You may obtain a copy of the License at
10*cde9e8dcSAndrew Rist *
11*cde9e8dcSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*cde9e8dcSAndrew Rist *
13*cde9e8dcSAndrew Rist * Unless required by applicable law or agreed to in writing,
14*cde9e8dcSAndrew Rist * software distributed under the License is distributed on an
15*cde9e8dcSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*cde9e8dcSAndrew Rist * KIND, either express or implied. See the License for the
17*cde9e8dcSAndrew Rist * specific language governing permissions and limitations
18*cde9e8dcSAndrew Rist * under the License.
19*cde9e8dcSAndrew Rist *
20*cde9e8dcSAndrew Rist *************************************************************/
21*cde9e8dcSAndrew Rist
22*cde9e8dcSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_chart2.hxx"
26cdf0e10cSrcweir #include "VCartesianCoordinateSystem.hxx"
27cdf0e10cSrcweir #include "VCartesianGrid.hxx"
28cdf0e10cSrcweir #include "VCartesianAxis.hxx"
29cdf0e10cSrcweir #include "macros.hxx"
30cdf0e10cSrcweir #include "AxisIndexDefines.hxx"
31cdf0e10cSrcweir #include "AxisHelper.hxx"
32cdf0e10cSrcweir #include "ChartTypeHelper.hxx"
33cdf0e10cSrcweir
34cdf0e10cSrcweir //for auto_ptr
35cdf0e10cSrcweir #include <memory>
36cdf0e10cSrcweir
37cdf0e10cSrcweir //.............................................................................
38cdf0e10cSrcweir namespace chart
39cdf0e10cSrcweir {
40cdf0e10cSrcweir //.............................................................................
41cdf0e10cSrcweir using namespace ::com::sun::star;
42cdf0e10cSrcweir using namespace ::com::sun::star::chart2;
43cdf0e10cSrcweir using ::com::sun::star::uno::Reference;
44cdf0e10cSrcweir
45cdf0e10cSrcweir //.............................................................................
46cdf0e10cSrcweir
47cdf0e10cSrcweir class TextualDataProvider : public ::cppu::WeakImplHelper1<
48cdf0e10cSrcweir ::com::sun::star::chart2::data::XTextualDataSequence
49cdf0e10cSrcweir >
50cdf0e10cSrcweir {
51cdf0e10cSrcweir public:
TextualDataProvider(const uno::Sequence<::rtl::OUString> & rTextSequence)52cdf0e10cSrcweir TextualDataProvider( const uno::Sequence< ::rtl::OUString >& rTextSequence )
53cdf0e10cSrcweir : m_aTextSequence( rTextSequence )
54cdf0e10cSrcweir {
55cdf0e10cSrcweir }
~TextualDataProvider()56cdf0e10cSrcweir virtual ~TextualDataProvider()
57cdf0e10cSrcweir {
58cdf0e10cSrcweir }
59cdf0e10cSrcweir
60cdf0e10cSrcweir //XTextualDataSequence
getTextualData()61cdf0e10cSrcweir virtual uno::Sequence< ::rtl::OUString > SAL_CALL getTextualData()
62cdf0e10cSrcweir throw ( uno::RuntimeException)
63cdf0e10cSrcweir {
64cdf0e10cSrcweir return m_aTextSequence;
65cdf0e10cSrcweir }
66cdf0e10cSrcweir
67cdf0e10cSrcweir private: //member
68cdf0e10cSrcweir uno::Sequence< ::rtl::OUString > m_aTextSequence;
69cdf0e10cSrcweir };
70cdf0e10cSrcweir
71cdf0e10cSrcweir //.............................................................................
72cdf0e10cSrcweir
VCartesianCoordinateSystem(const Reference<XCoordinateSystem> & xCooSys)73cdf0e10cSrcweir VCartesianCoordinateSystem::VCartesianCoordinateSystem( const Reference< XCoordinateSystem >& xCooSys )
74cdf0e10cSrcweir : VCoordinateSystem(xCooSys)
75cdf0e10cSrcweir {
76cdf0e10cSrcweir }
77cdf0e10cSrcweir
~VCartesianCoordinateSystem()78cdf0e10cSrcweir VCartesianCoordinateSystem::~VCartesianCoordinateSystem()
79cdf0e10cSrcweir {
80cdf0e10cSrcweir }
81cdf0e10cSrcweir
createGridShapes()82cdf0e10cSrcweir void VCartesianCoordinateSystem::createGridShapes()
83cdf0e10cSrcweir {
84cdf0e10cSrcweir if(!m_xLogicTargetForGrids.is() || !m_xFinalTarget.is() )
85cdf0e10cSrcweir return;
86cdf0e10cSrcweir
87cdf0e10cSrcweir sal_Int32 nDimensionCount = m_xCooSysModel->getDimension();
88cdf0e10cSrcweir bool bSwapXAndY = this->getPropertySwapXAndYAxis();
89cdf0e10cSrcweir
90cdf0e10cSrcweir for( sal_Int32 nDimensionIndex=0; nDimensionIndex<3; nDimensionIndex++)
91cdf0e10cSrcweir {
92cdf0e10cSrcweir sal_Int32 nAxisIndex = MAIN_AXIS_INDEX;
93cdf0e10cSrcweir Reference< XAxis > xAxis( AxisHelper::getAxis( nDimensionIndex, nAxisIndex, m_xCooSysModel ) );
94cdf0e10cSrcweir if(!xAxis.is() || !AxisHelper::shouldAxisBeDisplayed( xAxis, m_xCooSysModel ))
95cdf0e10cSrcweir continue;
96cdf0e10cSrcweir
97cdf0e10cSrcweir VCartesianGrid aGrid(nDimensionIndex,nDimensionCount,this->getGridListFromAxis( xAxis ));
98cdf0e10cSrcweir aGrid.setExplicitScaleAndIncrement( this->getExplicitScale(nDimensionIndex,nAxisIndex)
99cdf0e10cSrcweir , this->getExplicitIncrement(nDimensionIndex,nAxisIndex) );
100cdf0e10cSrcweir aGrid.set3DWallPositions( m_eLeftWallPos, m_eBackWallPos, m_eBottomPos );
101cdf0e10cSrcweir
102cdf0e10cSrcweir aGrid.initPlotter(m_xLogicTargetForGrids,m_xFinalTarget,m_xShapeFactory
103cdf0e10cSrcweir , this->createCIDForGrid( xAxis,nDimensionIndex,nAxisIndex ) );
104cdf0e10cSrcweir if(2==nDimensionCount)
105cdf0e10cSrcweir aGrid.setTransformationSceneToScreen( m_aMatrixSceneToScreen );
106cdf0e10cSrcweir aGrid.setScales( this->getExplicitScales(nDimensionIndex,nAxisIndex), bSwapXAndY );
107cdf0e10cSrcweir aGrid.createShapes();
108cdf0e10cSrcweir }
109cdf0e10cSrcweir }
110cdf0e10cSrcweir
createVAxisList(const uno::Reference<util::XNumberFormatsSupplier> & xNumberFormatsSupplier,const awt::Size & rFontReferenceSize,const awt::Rectangle & rMaximumSpaceForLabels)111cdf0e10cSrcweir void VCartesianCoordinateSystem::createVAxisList(
112cdf0e10cSrcweir const uno::Reference< util::XNumberFormatsSupplier > & xNumberFormatsSupplier
113cdf0e10cSrcweir , const awt::Size& rFontReferenceSize
114cdf0e10cSrcweir , const awt::Rectangle& rMaximumSpaceForLabels
115cdf0e10cSrcweir )
116cdf0e10cSrcweir {
117cdf0e10cSrcweir m_aAxisMap.clear();
118cdf0e10cSrcweir
119cdf0e10cSrcweir //if(!m_xLogicTargetForAxes.is() || !m_xFinalTarget.is() || !m_xCooSysModel.is() )
120cdf0e10cSrcweir // return;
121cdf0e10cSrcweir
122cdf0e10cSrcweir sal_Int32 nDimensionCount = m_xCooSysModel->getDimension();
123cdf0e10cSrcweir bool bSwapXAndY = this->getPropertySwapXAndYAxis();
124cdf0e10cSrcweir
125cdf0e10cSrcweir if(nDimensionCount<=0)
126cdf0e10cSrcweir return;
127cdf0e10cSrcweir
128cdf0e10cSrcweir sal_Int32 nDimensionIndex = 0;
129cdf0e10cSrcweir
130cdf0e10cSrcweir for( nDimensionIndex = 0; nDimensionIndex < nDimensionCount; nDimensionIndex++ )
131cdf0e10cSrcweir {
132cdf0e10cSrcweir sal_Int32 nMaxAxisIndex = m_xCooSysModel->getMaximumAxisIndexByDimension(nDimensionIndex);
133cdf0e10cSrcweir for( sal_Int32 nAxisIndex = 0; nAxisIndex <= nMaxAxisIndex; nAxisIndex++ )
134cdf0e10cSrcweir {
135cdf0e10cSrcweir Reference< XAxis > xAxis = this->getAxisByDimension(nDimensionIndex,nAxisIndex);
136cdf0e10cSrcweir if(!xAxis.is() || !AxisHelper::shouldAxisBeDisplayed( xAxis, m_xCooSysModel ))
137cdf0e10cSrcweir continue;
138cdf0e10cSrcweir
139cdf0e10cSrcweir AxisProperties aAxisProperties(xAxis,this->getExplicitCategoriesProvider());
140cdf0e10cSrcweir aAxisProperties.m_nDimensionIndex = nDimensionIndex;
141cdf0e10cSrcweir aAxisProperties.m_bSwapXAndY = bSwapXAndY;
142cdf0e10cSrcweir aAxisProperties.m_bIsMainAxis = (nAxisIndex==0);
143cdf0e10cSrcweir Reference< XAxis > xCrossingMainAxis( AxisHelper::getCrossingMainAxis( xAxis, m_xCooSysModel ) );
144cdf0e10cSrcweir if( xCrossingMainAxis.is() )
145cdf0e10cSrcweir {
146cdf0e10cSrcweir ScaleData aCrossingScale( xCrossingMainAxis->getScaleData() );
147cdf0e10cSrcweir aAxisProperties.m_bCrossingAxisHasReverseDirection = (AxisOrientation_REVERSE==aCrossingScale.Orientation);
148cdf0e10cSrcweir
149cdf0e10cSrcweir if( aCrossingScale.AxisType == AxisType::CATEGORY )
150cdf0e10cSrcweir aAxisProperties.m_bCrossingAxisIsCategoryAxes = true;
151cdf0e10cSrcweir }
152cdf0e10cSrcweir
153cdf0e10cSrcweir if( nDimensionIndex == 2 )
154cdf0e10cSrcweir {
155cdf0e10cSrcweir aAxisProperties.m_xAxisTextProvider = new TextualDataProvider( m_aSeriesNamesForZAxis );
156cdf0e10cSrcweir
157cdf0e10cSrcweir //for the z axis copy the positioning properties from the x axis (or from the y axis for swapped coordinate systems)
158cdf0e10cSrcweir Reference< XAxis > xSisterAxis( AxisHelper::getCrossingMainAxis( xCrossingMainAxis, m_xCooSysModel ) );
159cdf0e10cSrcweir aAxisProperties.initAxisPositioning( Reference< beans::XPropertySet >( xSisterAxis, uno::UNO_QUERY) );
160cdf0e10cSrcweir }
161cdf0e10cSrcweir aAxisProperties.init(true);
162cdf0e10cSrcweir if(aAxisProperties.m_bDisplayLabels)
163cdf0e10cSrcweir aAxisProperties.m_nNumberFormatKey = this->getNumberFormatKeyForAxis( xAxis, xNumberFormatsSupplier );
164cdf0e10cSrcweir //-------------------
165cdf0e10cSrcweir ::boost::shared_ptr< VAxisBase > apVAxis( new VCartesianAxis(aAxisProperties,xNumberFormatsSupplier,nDimensionIndex,nDimensionCount) );
166cdf0e10cSrcweir tFullAxisIndex aFullAxisIndex( nDimensionIndex, nAxisIndex );
167cdf0e10cSrcweir m_aAxisMap[aFullAxisIndex] = apVAxis;
168cdf0e10cSrcweir apVAxis->set3DWallPositions( m_eLeftWallPos, m_eBackWallPos, m_eBottomPos );
169cdf0e10cSrcweir
170cdf0e10cSrcweir apVAxis->initAxisLabelProperties(rFontReferenceSize,rMaximumSpaceForLabels);
171cdf0e10cSrcweir }
172cdf0e10cSrcweir }
173cdf0e10cSrcweir }
174cdf0e10cSrcweir
initVAxisInList()175cdf0e10cSrcweir void VCartesianCoordinateSystem::initVAxisInList()
176cdf0e10cSrcweir {
177cdf0e10cSrcweir if(!m_xLogicTargetForAxes.is() || !m_xFinalTarget.is() || !m_xCooSysModel.is() )
178cdf0e10cSrcweir return;
179cdf0e10cSrcweir
180cdf0e10cSrcweir sal_Int32 nDimensionCount = m_xCooSysModel->getDimension();
181cdf0e10cSrcweir bool bSwapXAndY = this->getPropertySwapXAndYAxis();
182cdf0e10cSrcweir
183cdf0e10cSrcweir tVAxisMap::iterator aIt( m_aAxisMap.begin() );
184cdf0e10cSrcweir tVAxisMap::const_iterator aEnd( m_aAxisMap.end() );
185cdf0e10cSrcweir for( ; aIt != aEnd; ++aIt )
186cdf0e10cSrcweir {
187cdf0e10cSrcweir VAxisBase* pVAxis = aIt->second.get();
188cdf0e10cSrcweir if( pVAxis )
189cdf0e10cSrcweir {
190cdf0e10cSrcweir sal_Int32 nDimensionIndex = aIt->first.first;
191cdf0e10cSrcweir sal_Int32 nAxisIndex = aIt->first.second;
192cdf0e10cSrcweir pVAxis->setExplicitScaleAndIncrement( this->getExplicitScale( nDimensionIndex, nAxisIndex ), this->getExplicitIncrement( nDimensionIndex, nAxisIndex ) );
193cdf0e10cSrcweir pVAxis->initPlotter(m_xLogicTargetForAxes,m_xFinalTarget,m_xShapeFactory
194cdf0e10cSrcweir , this->createCIDForAxis( getAxisByDimension( nDimensionIndex, nAxisIndex ), nDimensionIndex, nAxisIndex ) );
195cdf0e10cSrcweir if(2==nDimensionCount)
196cdf0e10cSrcweir pVAxis->setTransformationSceneToScreen( m_aMatrixSceneToScreen );
197cdf0e10cSrcweir pVAxis->setScales( this->getExplicitScales(nDimensionIndex,nAxisIndex), bSwapXAndY );
198cdf0e10cSrcweir }
199cdf0e10cSrcweir }
200cdf0e10cSrcweir }
201cdf0e10cSrcweir
updateScalesAndIncrementsOnAxes()202cdf0e10cSrcweir void VCartesianCoordinateSystem::updateScalesAndIncrementsOnAxes()
203cdf0e10cSrcweir {
204cdf0e10cSrcweir if(!m_xLogicTargetForAxes.is() || !m_xFinalTarget.is() || !m_xCooSysModel.is() )
205cdf0e10cSrcweir return;
206cdf0e10cSrcweir
207cdf0e10cSrcweir sal_Int32 nDimensionCount = m_xCooSysModel->getDimension();
208cdf0e10cSrcweir bool bSwapXAndY = this->getPropertySwapXAndYAxis();
209cdf0e10cSrcweir
210cdf0e10cSrcweir tVAxisMap::iterator aIt( m_aAxisMap.begin() );
211cdf0e10cSrcweir tVAxisMap::const_iterator aEnd( m_aAxisMap.end() );
212cdf0e10cSrcweir for( ; aIt != aEnd; ++aIt )
213cdf0e10cSrcweir {
214cdf0e10cSrcweir VAxisBase* pVAxis = aIt->second.get();
215cdf0e10cSrcweir if( pVAxis )
216cdf0e10cSrcweir {
217cdf0e10cSrcweir sal_Int32 nDimensionIndex = aIt->first.first;
218cdf0e10cSrcweir sal_Int32 nAxisIndex = aIt->first.second;
219cdf0e10cSrcweir pVAxis->setExplicitScaleAndIncrement( this->getExplicitScale( nDimensionIndex, nAxisIndex ), this->getExplicitIncrement( nDimensionIndex, nAxisIndex ) );
220cdf0e10cSrcweir if(2==nDimensionCount)
221cdf0e10cSrcweir pVAxis->setTransformationSceneToScreen( m_aMatrixSceneToScreen );
222cdf0e10cSrcweir pVAxis->setScales( this->getExplicitScales(nDimensionIndex,nAxisIndex), bSwapXAndY );
223cdf0e10cSrcweir }
224cdf0e10cSrcweir }
225cdf0e10cSrcweir }
226cdf0e10cSrcweir
227cdf0e10cSrcweir //.............................................................................
228cdf0e10cSrcweir } //namespace chart
229cdf0e10cSrcweir //.............................................................................
230