fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / chart2 / source / view / axes / VPolarRadiusAxis.cxx
blobf5d99924487ee54a0eb255da004c467e9b98a63f
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 "VPolarRadiusAxis.hxx"
21 #include "VCartesianAxis.hxx"
22 #include "PlottingPositionHelper.hxx"
23 #include "CommonConverters.hxx"
24 #include "Tickmarks_Equidistant.hxx"
25 #include <rtl/math.hxx>
27 namespace chart
29 using namespace ::com::sun::star;
30 using namespace ::com::sun::star::chart2;
31 using namespace ::rtl::math;
33 VPolarRadiusAxis::VPolarRadiusAxis( const AxisProperties& rAxisProperties
34 , const uno::Reference< util::XNumberFormatsSupplier >& xNumberFormatsSupplier
35 , sal_Int32 nDimensionCount )
36 : VPolarAxis( rAxisProperties, xNumberFormatsSupplier, 1/*nDimensionIndex*/, nDimensionCount )
38 m_aAxisProperties.maLabelAlignment.mfLabelDirection = 0.0;
39 m_aAxisProperties.maLabelAlignment.mfInnerTickDirection = 0.0;
40 m_aAxisProperties.maLabelAlignment.meAlignment = LABEL_ALIGN_RIGHT;
41 m_aAxisProperties.m_bIsMainAxis=false;
42 m_aAxisProperties.init();
44 m_apAxisWithLabels.reset( new VCartesianAxis(
45 m_aAxisProperties,xNumberFormatsSupplier,1/*nDimensionIndex*/,nDimensionCount
46 ,new PolarPlottingPositionHelper() ) );
49 VPolarRadiusAxis::~VPolarRadiusAxis()
51 delete m_pPosHelper;
52 m_pPosHelper = NULL;
55 void VPolarRadiusAxis::setTransformationSceneToScreen( const drawing::HomogenMatrix& rMatrix)
57 VPolarAxis::setTransformationSceneToScreen( rMatrix );
58 m_apAxisWithLabels->setTransformationSceneToScreen( rMatrix );
61 void VPolarRadiusAxis::setExplicitScaleAndIncrement(
62 const ExplicitScaleData& rScale
63 , const ExplicitIncrementData& rIncrement )
64 throw (uno::RuntimeException)
66 VPolarAxis::setExplicitScaleAndIncrement( rScale, rIncrement );
67 m_apAxisWithLabels->setExplicitScaleAndIncrement( rScale, rIncrement );
70 void VPolarRadiusAxis::initPlotter( const uno::Reference< drawing::XShapes >& xLogicTarget
71 , const uno::Reference< drawing::XShapes >& xFinalTarget
72 , const uno::Reference< lang::XMultiServiceFactory >& xShapeFactory
73 , const OUString& rCID )
74 throw (uno::RuntimeException)
76 VPolarAxis::initPlotter( xLogicTarget, xFinalTarget, xShapeFactory, rCID );
77 m_apAxisWithLabels->initPlotter( xLogicTarget, xFinalTarget, xShapeFactory, rCID );
80 void VPolarRadiusAxis::setScales( const std::vector< ExplicitScaleData >& rScales, bool bSwapXAndYAxis )
82 VPolarAxis::setScales( rScales, bSwapXAndYAxis );
83 m_apAxisWithLabels->setScales( rScales, bSwapXAndYAxis );
86 void VPolarRadiusAxis::initAxisLabelProperties( const ::com::sun::star::awt::Size& rFontReferenceSize
87 , const ::com::sun::star::awt::Rectangle& rMaximumSpaceForLabels )
89 VPolarAxis::initAxisLabelProperties( rFontReferenceSize, rMaximumSpaceForLabels );
90 m_apAxisWithLabels->initAxisLabelProperties( rFontReferenceSize, rMaximumSpaceForLabels );
93 sal_Int32 VPolarRadiusAxis::estimateMaximumAutoMainIncrementCount()
95 return 2;
98 bool VPolarRadiusAxis::prepareShapeCreation()
100 //returns true if all is ready for further shape creation and any shapes need to be created
101 if( !isAnythingToDraw() )
102 return false;
104 if( m_xGroupShape_Shapes.is() )
105 return true;
107 return true;
110 void VPolarRadiusAxis::createMaximumLabels()
112 m_apAxisWithLabels->createMaximumLabels();
115 void VPolarRadiusAxis::updatePositions()
117 m_apAxisWithLabels->updatePositions();
120 void VPolarRadiusAxis::createLabels()
122 m_apAxisWithLabels->createLabels();
125 void VPolarRadiusAxis::createShapes()
127 if( !prepareShapeCreation() )
128 return;
130 const ExplicitScaleData& rAngleScale = m_pPosHelper->getScales()[0];
131 const ExplicitIncrementData& rAngleIncrement = m_aIncrements[0];
133 TickInfoArraysType aAngleTickInfos;
134 TickFactory aAngleTickFactory( rAngleScale, rAngleIncrement );
135 aAngleTickFactory.getAllTicks( aAngleTickInfos );
137 uno::Reference< XScaling > xInverseScaling( NULL );
138 if( rAngleScale.Scaling.is() )
139 xInverseScaling = rAngleScale.Scaling->getInverseScaling();
141 AxisProperties aAxisProperties(m_aAxisProperties);
143 sal_Int32 nTick = 0;
144 EquidistantTickIter aIter( aAngleTickInfos, rAngleIncrement, 0, 0 );
145 for( TickInfo* pTickInfo = aIter.firstInfo()
146 ; pTickInfo; pTickInfo = aIter.nextInfo(), nTick++ )
148 if( nTick == 0 )
150 m_apAxisWithLabels->createShapes();
151 continue;
154 //xxxxx pTickInfo->updateUnscaledValue( xInverseScaling );
155 aAxisProperties.m_pfMainLinePositionAtOtherAxis.reset(pTickInfo->getUnscaledTickValue());
156 aAxisProperties.m_bDisplayLabels=false;
158 VCartesianAxis aAxis(aAxisProperties,m_xNumberFormatsSupplier
159 ,1,2,new PolarPlottingPositionHelper());
160 aAxis.setExplicitScaleAndIncrement( m_aScale, m_aIncrement );
161 aAxis.initPlotter(m_xLogicTarget,m_xFinalTarget,m_xShapeFactory, m_aCID );
162 aAxis.setTransformationSceneToScreen( B3DHomMatrixToHomogenMatrix( m_aMatrixScreenToScene ) );
163 aAxis.setScales( m_pPosHelper->getScales(), false );
164 aAxis.initAxisLabelProperties(m_aAxisLabelProperties.m_aFontReferenceSize,m_aAxisLabelProperties.m_aMaximumSpaceForLabels);
165 aAxis.createShapes();
169 } //namespace chart
171 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */