nss: upgrade to release 3.73
[LibreOffice.git] / chart2 / source / view / axes / VPolarCoordinateSystem.cxx
blob1fee8417544420ff57d22e95a23b5a777f3631fe
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>
25 #include <ChartModel.hxx>
26 #include <com/sun/star/chart2/XCoordinateSystem.hpp>
28 namespace chart
30 using namespace ::com::sun::star;
31 using namespace ::com::sun::star::chart2;
32 using ::com::sun::star::uno::Reference;
34 VPolarCoordinateSystem::VPolarCoordinateSystem( const Reference< XCoordinateSystem >& xCooSys )
35 : VCoordinateSystem(xCooSys)
39 VPolarCoordinateSystem::~VPolarCoordinateSystem()
43 //better performance for big data
44 uno::Sequence< sal_Int32 > VPolarCoordinateSystem::getCoordinateSystemResolution(
45 const awt::Size& rPageSize, const awt::Size& rPageResolution )
47 uno::Sequence< sal_Int32 > aResolution( VCoordinateSystem::getCoordinateSystemResolution( rPageSize, rPageResolution) );
49 if( aResolution.getLength() >= 2 )
51 if( getPropertySwapXAndYAxis() )
53 aResolution[0]/=2;//radius
54 aResolution[1]*=4;//outer circle resolution
56 else
58 aResolution[0]*=4;//outer circle resolution
59 aResolution[1]/=2;//radius
63 return aResolution;
66 void VPolarCoordinateSystem::createVAxisList(
67 const uno::Reference<chart2::XChartDocument> & xChartDoc
68 , const awt::Size& rFontReferenceSize
69 , const awt::Rectangle& rMaximumSpaceForLabels
70 , bool //bLimitSpaceForLabels
73 // note: using xChartDoc itself as XNumberFormatsSupplier would cause
74 // a leak from VPolarAxis due to cyclic reference
75 uno::Reference<util::XNumberFormatsSupplier> const xNumberFormatsSupplier(
76 dynamic_cast<ChartModel&>(*xChartDoc).getNumberFormatsSupplier());
78 m_aAxisMap.clear();
79 sal_Int32 nDimensionCount = m_xCooSysModel->getDimension();
80 sal_Int32 nDimensionIndex = 0;
82 //create angle axis (dimension index 0)
83 for( nDimensionIndex = 0; nDimensionIndex < nDimensionCount; nDimensionIndex++ )
85 sal_Int32 nMaxAxisIndex = m_xCooSysModel->getMaximumAxisIndexByDimension(nDimensionIndex);
86 for( sal_Int32 nAxisIndex = 0; nAxisIndex <= nMaxAxisIndex; nAxisIndex++ )
88 Reference< XAxis > xAxis( getAxisByDimension(nDimensionIndex,nAxisIndex) );
89 if(!xAxis.is() || !AxisHelper::shouldAxisBeDisplayed( xAxis, m_xCooSysModel ))
90 continue;
91 AxisProperties aAxisProperties(xAxis,getExplicitCategoriesProvider());
92 aAxisProperties.init();
93 if(aAxisProperties.m_bDisplayLabels)
94 aAxisProperties.m_nNumberFormatKey = getNumberFormatKeyForAxis(xAxis, xChartDoc);
96 std::shared_ptr< VAxisBase > apVAxis( VPolarAxis::createAxis( aAxisProperties,xNumberFormatsSupplier,nDimensionIndex,nDimensionCount) );
97 tFullAxisIndex aFullAxisIndex( nDimensionIndex, nAxisIndex );
98 m_aAxisMap[aFullAxisIndex] = apVAxis;
100 apVAxis->initAxisLabelProperties(rFontReferenceSize,rMaximumSpaceForLabels);
105 void VPolarCoordinateSystem::initVAxisInList()
107 if(!m_xLogicTargetForAxes.is() || !m_xFinalTarget.is() || !m_xCooSysModel.is() )
108 return;
110 sal_Int32 nDimensionCount = m_xCooSysModel->getDimension();
111 bool bSwapXAndY = getPropertySwapXAndYAxis();
113 for (auto const& elem : m_aAxisMap)
115 VAxisBase* pVAxis = elem.second.get();
116 if( pVAxis )
118 sal_Int32 nDimensionIndex = elem.first.first;
119 sal_Int32 nAxisIndex = elem.first.second;
120 pVAxis->setExplicitScaleAndIncrement( getExplicitScale( nDimensionIndex, nAxisIndex ), getExplicitIncrement(nDimensionIndex, nAxisIndex) );
121 pVAxis->initPlotter(m_xLogicTargetForAxes,m_xFinalTarget,m_xShapeFactory
122 , createCIDForAxis( nDimensionIndex, nAxisIndex ) );
123 VPolarAxis* pVPolarAxis = dynamic_cast< VPolarAxis* >( pVAxis );
124 if( pVPolarAxis )
125 pVPolarAxis->setIncrements( getExplicitIncrements( nDimensionIndex, nAxisIndex ) );
126 if(nDimensionCount==2)
127 pVAxis->setTransformationSceneToScreen( m_aMatrixSceneToScreen );
128 pVAxis->setScales( getExplicitScales( nDimensionIndex, nAxisIndex ), bSwapXAndY );
133 void VPolarCoordinateSystem::updateScalesAndIncrementsOnAxes()
135 if(!m_xLogicTargetForAxes.is() || !m_xFinalTarget.is() || !m_xCooSysModel.is() )
136 return;
138 sal_Int32 nDimensionCount = m_xCooSysModel->getDimension();
139 bool bSwapXAndY = getPropertySwapXAndYAxis();
141 for (auto const& elem : m_aAxisMap)
143 VAxisBase* pVAxis = elem.second.get();
144 if( pVAxis )
146 sal_Int32 nDimensionIndex = elem.first.first;
147 sal_Int32 nAxisIndex = elem.first.second;
148 pVAxis->setExplicitScaleAndIncrement( getExplicitScale( nDimensionIndex, nAxisIndex ), getExplicitIncrement(nDimensionIndex, nAxisIndex) );
149 VPolarAxis* pVPolarAxis = dynamic_cast< VPolarAxis* >( pVAxis );
150 if( pVPolarAxis )
151 pVPolarAxis->setIncrements( getExplicitIncrements( nDimensionIndex, nAxisIndex ) );
152 if(nDimensionCount==2)
153 pVAxis->setTransformationSceneToScreen( m_aMatrixSceneToScreen );
154 pVAxis->setScales( getExplicitScales( nDimensionIndex, nAxisIndex ), bSwapXAndY );
159 void VPolarCoordinateSystem::createGridShapes()
161 if(!m_xLogicTargetForGrids.is() || !m_xFinalTarget.is() )
162 return;
164 sal_Int32 nDimensionCount = m_xCooSysModel->getDimension();
165 bool bSwapXAndY = getPropertySwapXAndYAxis();
167 for( sal_Int32 nDimensionIndex=0; nDimensionIndex<3; nDimensionIndex++)
169 sal_Int32 nAxisIndex = MAIN_AXIS_INDEX;
171 Reference< XAxis > xAxis( AxisHelper::getAxis( nDimensionIndex, nAxisIndex, m_xCooSysModel ) );
172 if(!xAxis.is() || !AxisHelper::shouldAxisBeDisplayed( xAxis, m_xCooSysModel ))
173 continue;
175 VPolarGrid aGrid(nDimensionIndex,nDimensionCount,getGridListFromAxis( xAxis ));
176 aGrid.setIncrements( getExplicitIncrements( nDimensionIndex, nAxisIndex ) );
177 aGrid.initPlotter(m_xLogicTargetForGrids,m_xFinalTarget,m_xShapeFactory
178 , createCIDForGrid( nDimensionIndex, nAxisIndex ) );
179 if(nDimensionCount==2)
180 aGrid.setTransformationSceneToScreen( m_aMatrixSceneToScreen );
181 aGrid.setScales( getExplicitScales( nDimensionIndex, nAxisIndex), bSwapXAndY );
182 aGrid.createShapes();
186 } //namespace chart
188 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */