fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / chart2 / source / view / axes / VPolarCoordinateSystem.cxx
blob6e34ab242aa30b913c76bdc9507fd484695c2b5d
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 "VPolarCoordinateSystem.hxx"
21 #include "VPolarGrid.hxx"
22 #include "VPolarAxis.hxx"
23 #include "AxisIndexDefines.hxx"
24 #include "AxisHelper.hxx"
26 namespace chart
28 using namespace ::com::sun::star;
29 using namespace ::com::sun::star::chart2;
30 using ::com::sun::star::uno::Reference;
32 VPolarCoordinateSystem::VPolarCoordinateSystem( const Reference< XCoordinateSystem >& xCooSys )
33 : VCoordinateSystem(xCooSys)
37 VPolarCoordinateSystem::~VPolarCoordinateSystem()
41 //better performance for big data
42 uno::Sequence< sal_Int32 > VPolarCoordinateSystem::getCoordinateSystemResolution(
43 const awt::Size& rPageSize, const awt::Size& rPageResolution )
45 uno::Sequence< sal_Int32 > aResolution( VCoordinateSystem::getCoordinateSystemResolution( rPageSize, rPageResolution) );
47 if( aResolution.getLength() >= 2 )
49 if( this->getPropertySwapXAndYAxis() )
51 aResolution[0]/=2;//radius
52 aResolution[1]*=4;//outer circle resolution
54 else
56 aResolution[0]*=4;//outer circle resolution
57 aResolution[1]/=2;//radius
61 return aResolution;
64 void VPolarCoordinateSystem::createVAxisList(
65 const uno::Reference<chart2::XChartDocument> & xChartDoc
66 , const awt::Size& rFontReferenceSize
67 , const awt::Rectangle& rMaximumSpaceForLabels
70 // note: using xChartDoc itself as XNumberFormatsSupplier would cause
71 // a leak from VPolarAxis due to cyclic reference
72 uno::Reference<util::XNumberFormatsSupplier> const xNumberFormatsSupplier(
73 dynamic_cast<ChartModel&>(*xChartDoc.get()).getNumberFormatsSupplier());
75 m_aAxisMap.clear();
76 sal_Int32 nDimensionCount = m_xCooSysModel->getDimension();
77 sal_Int32 nDimensionIndex = 0;
79 //create angle axis (dimension index 0)
80 for( nDimensionIndex = 0; nDimensionIndex < nDimensionCount; nDimensionIndex++ )
82 sal_Int32 nMaxAxisIndex = m_xCooSysModel->getMaximumAxisIndexByDimension(nDimensionIndex);
83 for( sal_Int32 nAxisIndex = 0; nAxisIndex <= nMaxAxisIndex; nAxisIndex++ )
85 Reference< XAxis > xAxis( this->getAxisByDimension(nDimensionIndex,nAxisIndex) );
86 if(!xAxis.is() || !AxisHelper::shouldAxisBeDisplayed( xAxis, m_xCooSysModel ))
87 continue;
88 AxisProperties aAxisProperties(xAxis,this->getExplicitCategoriesProvider());
89 aAxisProperties.init();
90 if(aAxisProperties.m_bDisplayLabels)
91 aAxisProperties.m_nNumberFormatKey = this->getNumberFormatKeyForAxis(xAxis, xChartDoc);
93 ::boost::shared_ptr< VAxisBase > apVAxis( VPolarAxis::createAxis( aAxisProperties,xNumberFormatsSupplier,nDimensionIndex,nDimensionCount) );
94 tFullAxisIndex aFullAxisIndex( nDimensionIndex, nAxisIndex );
95 m_aAxisMap[aFullAxisIndex] = apVAxis;
97 apVAxis->initAxisLabelProperties(rFontReferenceSize,rMaximumSpaceForLabels);
102 void VPolarCoordinateSystem::initVAxisInList()
104 if(!m_xLogicTargetForAxes.is() || !m_xFinalTarget.is() || !m_xCooSysModel.is() )
105 return;
107 sal_Int32 nDimensionCount = m_xCooSysModel->getDimension();
108 bool bSwapXAndY = this->getPropertySwapXAndYAxis();
110 tVAxisMap::iterator aIt( m_aAxisMap.begin() );
111 tVAxisMap::const_iterator aEnd( m_aAxisMap.end() );
112 for( ; aIt != aEnd; ++aIt )
114 VAxisBase* pVAxis = aIt->second.get();
115 if( pVAxis )
117 sal_Int32 nDimensionIndex = aIt->first.first;
118 sal_Int32 nAxisIndex = aIt->first.second;
119 pVAxis->setExplicitScaleAndIncrement( this->getExplicitScale( nDimensionIndex, nAxisIndex ), this->getExplicitIncrement(nDimensionIndex, nAxisIndex) );
120 pVAxis->initPlotter(m_xLogicTargetForAxes,m_xFinalTarget,m_xShapeFactory
121 , this->createCIDForAxis( getAxisByDimension( nDimensionIndex, nAxisIndex ), nDimensionIndex, nAxisIndex ) );
122 VPolarAxis* pVPolarAxis = dynamic_cast< VPolarAxis* >( pVAxis );
123 if( pVPolarAxis )
124 pVPolarAxis->setIncrements( this->getExplicitIncrements( nDimensionIndex, nAxisIndex ) );
125 if(2==nDimensionCount)
126 pVAxis->setTransformationSceneToScreen( m_aMatrixSceneToScreen );
127 pVAxis->setScales( this->getExplicitScales( nDimensionIndex, nAxisIndex ), bSwapXAndY );
132 void VPolarCoordinateSystem::updateScalesAndIncrementsOnAxes()
134 if(!m_xLogicTargetForAxes.is() || !m_xFinalTarget.is() || !m_xCooSysModel.is() )
135 return;
137 sal_Int32 nDimensionCount = m_xCooSysModel->getDimension();
138 bool bSwapXAndY = this->getPropertySwapXAndYAxis();
140 tVAxisMap::iterator aIt( m_aAxisMap.begin() );
141 tVAxisMap::const_iterator aEnd( m_aAxisMap.end() );
142 for( ; aIt != aEnd; ++aIt )
144 VAxisBase* pVAxis = aIt->second.get();
145 if( pVAxis )
147 sal_Int32 nDimensionIndex = aIt->first.first;
148 sal_Int32 nAxisIndex = aIt->first.second;
149 pVAxis->setExplicitScaleAndIncrement( this->getExplicitScale( nDimensionIndex, nAxisIndex ), this->getExplicitIncrement(nDimensionIndex, nAxisIndex) );
150 VPolarAxis* pVPolarAxis = dynamic_cast< VPolarAxis* >( pVAxis );
151 if( pVPolarAxis )
152 pVPolarAxis->setIncrements( this->getExplicitIncrements( nDimensionIndex, nAxisIndex ) );
153 if(2==nDimensionCount)
154 pVAxis->setTransformationSceneToScreen( m_aMatrixSceneToScreen );
155 pVAxis->setScales( this->getExplicitScales( nDimensionIndex, nAxisIndex ), bSwapXAndY );
160 void VPolarCoordinateSystem::createGridShapes()
162 if(!m_xLogicTargetForGrids.is() || !m_xFinalTarget.is() )
163 return;
165 sal_Int32 nDimensionCount = m_xCooSysModel->getDimension();
166 bool bSwapXAndY = this->getPropertySwapXAndYAxis();
168 for( sal_Int32 nDimensionIndex=0; nDimensionIndex<3; nDimensionIndex++)
170 sal_Int32 nAxisIndex = MAIN_AXIS_INDEX;
172 Reference< XAxis > xAxis( AxisHelper::getAxis( nDimensionIndex, nAxisIndex, m_xCooSysModel ) );
173 if(!xAxis.is() || !AxisHelper::shouldAxisBeDisplayed( xAxis, m_xCooSysModel ))
174 continue;
176 VPolarGrid aGrid(nDimensionIndex,nDimensionCount,getGridListFromAxis( xAxis ));
177 aGrid.setIncrements( this->getExplicitIncrements( nDimensionIndex, nAxisIndex ) );
178 aGrid.initPlotter(m_xLogicTargetForGrids,m_xFinalTarget,m_xShapeFactory
179 , this->createCIDForGrid( xAxis, nDimensionIndex, nAxisIndex ) );
180 if(2==nDimensionCount)
181 aGrid.setTransformationSceneToScreen( m_aMatrixSceneToScreen );
182 aGrid.setScales( this->getExplicitScales( nDimensionIndex, nAxisIndex), bSwapXAndY );
183 aGrid.createShapes();
187 } //namespace chart
189 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */