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 "VAxisProperties.hxx" 31*cdf0e10cSrcweir #include "macros.hxx" 32*cdf0e10cSrcweir #include "ViewDefines.hxx" 33*cdf0e10cSrcweir #include "CommonConverters.hxx" 34*cdf0e10cSrcweir #include "AxisHelper.hxx" 35*cdf0e10cSrcweir #include "DiagramHelper.hxx" 36*cdf0e10cSrcweir #include "ChartModelHelper.hxx" 37*cdf0e10cSrcweir 38*cdf0e10cSrcweir #include <tools/color.hxx> 39*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp> 40*cdf0e10cSrcweir #include <com/sun/star/chart/ChartAxisArrangeOrderType.hpp> 41*cdf0e10cSrcweir #include <com/sun/star/drawing/LineStyle.hpp> 42*cdf0e10cSrcweir #include <com/sun/star/text/WritingMode2.hpp> 43*cdf0e10cSrcweir 44*cdf0e10cSrcweir //............................................................................. 45*cdf0e10cSrcweir namespace chart 46*cdf0e10cSrcweir { 47*cdf0e10cSrcweir //............................................................................. 48*cdf0e10cSrcweir using namespace ::com::sun::star; 49*cdf0e10cSrcweir using namespace ::com::sun::star::chart2; 50*cdf0e10cSrcweir 51*cdf0e10cSrcweir sal_Int32 lcl_calcTickLengthForDepth(sal_Int32 nDepth,sal_Int32 nTickmarkStyle) 52*cdf0e10cSrcweir { 53*cdf0e10cSrcweir sal_Int32 nWidth = AXIS2D_TICKLENGTH; //@maybefuturetodo this length could be offered by the model 54*cdf0e10cSrcweir double fPercent = 1.0; 55*cdf0e10cSrcweir switch(nDepth) 56*cdf0e10cSrcweir { 57*cdf0e10cSrcweir case 0: 58*cdf0e10cSrcweir fPercent = 1.0; 59*cdf0e10cSrcweir break; 60*cdf0e10cSrcweir case 1: 61*cdf0e10cSrcweir fPercent = 0.75;//percentage like in the old chart 62*cdf0e10cSrcweir break; 63*cdf0e10cSrcweir case 2: 64*cdf0e10cSrcweir fPercent = 0.5; 65*cdf0e10cSrcweir break; 66*cdf0e10cSrcweir default: 67*cdf0e10cSrcweir fPercent = 0.3; 68*cdf0e10cSrcweir break; 69*cdf0e10cSrcweir } 70*cdf0e10cSrcweir if(nTickmarkStyle==3)//inner and outer tickmarks 71*cdf0e10cSrcweir fPercent*=2.0; 72*cdf0e10cSrcweir return static_cast<sal_Int32>(nWidth*fPercent); 73*cdf0e10cSrcweir } 74*cdf0e10cSrcweir 75*cdf0e10cSrcweir double lcl_getTickOffset(sal_Int32 nLength,sal_Int32 nTickmarkStyle) 76*cdf0e10cSrcweir { 77*cdf0e10cSrcweir double fPercent = 0.0; //0<=fPercent<=1 78*cdf0e10cSrcweir //0.0: completly inner 79*cdf0e10cSrcweir //1.0: completly outer 80*cdf0e10cSrcweir //0.5: half and half 81*cdf0e10cSrcweir 82*cdf0e10cSrcweir /* 83*cdf0e10cSrcweir nTickmarkStyle: 84*cdf0e10cSrcweir 1: inner tickmarks 85*cdf0e10cSrcweir 2: outer tickmarks 86*cdf0e10cSrcweir 3: inner and outer tickmarks 87*cdf0e10cSrcweir */ 88*cdf0e10cSrcweir switch(nTickmarkStyle) 89*cdf0e10cSrcweir { 90*cdf0e10cSrcweir case 1: 91*cdf0e10cSrcweir fPercent = 0.0; 92*cdf0e10cSrcweir break; 93*cdf0e10cSrcweir case 2: 94*cdf0e10cSrcweir fPercent = 1.0; 95*cdf0e10cSrcweir break; 96*cdf0e10cSrcweir default: 97*cdf0e10cSrcweir fPercent = 0.5; 98*cdf0e10cSrcweir break; 99*cdf0e10cSrcweir } 100*cdf0e10cSrcweir return fPercent*nLength; 101*cdf0e10cSrcweir } 102*cdf0e10cSrcweir 103*cdf0e10cSrcweir VLineProperties AxisProperties::makeLinePropertiesForDepth( sal_Int32 /* nDepth */ ) const 104*cdf0e10cSrcweir { 105*cdf0e10cSrcweir //@todo get this from somewhere; maybe for each subincrement 106*cdf0e10cSrcweir //so far the model does not offer different settings for each tick depth 107*cdf0e10cSrcweir return m_aLineProperties; 108*cdf0e10cSrcweir } 109*cdf0e10cSrcweir 110*cdf0e10cSrcweir TickmarkProperties AxisProperties::makeTickmarkProperties( 111*cdf0e10cSrcweir sal_Int32 nDepth ) const 112*cdf0e10cSrcweir { 113*cdf0e10cSrcweir /* 114*cdf0e10cSrcweir nTickmarkStyle: 115*cdf0e10cSrcweir 1: inner tickmarks 116*cdf0e10cSrcweir 2: outer tickmarks 117*cdf0e10cSrcweir 3: inner and outer tickmarks 118*cdf0e10cSrcweir */ 119*cdf0e10cSrcweir sal_Int32 nTickmarkStyle = 1; 120*cdf0e10cSrcweir if(nDepth==0) 121*cdf0e10cSrcweir { 122*cdf0e10cSrcweir nTickmarkStyle = m_nMajorTickmarks; 123*cdf0e10cSrcweir if(!nTickmarkStyle) 124*cdf0e10cSrcweir { 125*cdf0e10cSrcweir //create major tickmarks as if they were minor tickmarks 126*cdf0e10cSrcweir nDepth = 1; 127*cdf0e10cSrcweir nTickmarkStyle = m_nMinorTickmarks; 128*cdf0e10cSrcweir } 129*cdf0e10cSrcweir } 130*cdf0e10cSrcweir else if( nDepth==1) 131*cdf0e10cSrcweir { 132*cdf0e10cSrcweir nTickmarkStyle = m_nMinorTickmarks; 133*cdf0e10cSrcweir } 134*cdf0e10cSrcweir 135*cdf0e10cSrcweir if( m_fInnerDirectionSign == 0.0 ) 136*cdf0e10cSrcweir { 137*cdf0e10cSrcweir if( nTickmarkStyle != 0 ) 138*cdf0e10cSrcweir nTickmarkStyle = 3; //inner and outer tickmarks 139*cdf0e10cSrcweir } 140*cdf0e10cSrcweir 141*cdf0e10cSrcweir TickmarkProperties aTickmarkProperties; 142*cdf0e10cSrcweir aTickmarkProperties.Length = lcl_calcTickLengthForDepth(nDepth,nTickmarkStyle); 143*cdf0e10cSrcweir aTickmarkProperties.RelativePos = static_cast<sal_Int32>(lcl_getTickOffset(aTickmarkProperties.Length,nTickmarkStyle)); 144*cdf0e10cSrcweir aTickmarkProperties.aLineProperties = this->makeLinePropertiesForDepth( nDepth ); 145*cdf0e10cSrcweir return aTickmarkProperties; 146*cdf0e10cSrcweir } 147*cdf0e10cSrcweir 148*cdf0e10cSrcweir TickmarkProperties AxisProperties::makeTickmarkPropertiesForComplexCategories( 149*cdf0e10cSrcweir sal_Int32 nTickLength, sal_Int32 nTickStartDistanceToAxis, sal_Int32 /*nTextLevel*/ ) const 150*cdf0e10cSrcweir { 151*cdf0e10cSrcweir sal_Int32 nTickmarkStyle = (m_fLabelDirectionSign==m_fInnerDirectionSign) ? 2/*outside*/ : 1/*inside*/; 152*cdf0e10cSrcweir 153*cdf0e10cSrcweir TickmarkProperties aTickmarkProperties; 154*cdf0e10cSrcweir aTickmarkProperties.Length = nTickLength;// + nTextLevel*( lcl_calcTickLengthForDepth(0,nTickmarkStyle) ); 155*cdf0e10cSrcweir aTickmarkProperties.RelativePos = static_cast<sal_Int32>(lcl_getTickOffset(aTickmarkProperties.Length+nTickStartDistanceToAxis,nTickmarkStyle)); 156*cdf0e10cSrcweir aTickmarkProperties.aLineProperties = this->makeLinePropertiesForDepth( 0 ); 157*cdf0e10cSrcweir return aTickmarkProperties; 158*cdf0e10cSrcweir } 159*cdf0e10cSrcweir 160*cdf0e10cSrcweir TickmarkProperties AxisProperties::getBiggestTickmarkProperties() 161*cdf0e10cSrcweir { 162*cdf0e10cSrcweir TickmarkProperties aTickmarkProperties; 163*cdf0e10cSrcweir sal_Int32 nDepth = 0; 164*cdf0e10cSrcweir sal_Int32 nTickmarkStyle = 3;//inner and outer tickmarks 165*cdf0e10cSrcweir aTickmarkProperties.Length = lcl_calcTickLengthForDepth( nDepth,nTickmarkStyle ); 166*cdf0e10cSrcweir aTickmarkProperties.RelativePos = static_cast<sal_Int32>( lcl_getTickOffset( aTickmarkProperties.Length, nTickmarkStyle ) ); 167*cdf0e10cSrcweir return aTickmarkProperties; 168*cdf0e10cSrcweir } 169*cdf0e10cSrcweir 170*cdf0e10cSrcweir //-------------------------------------------------------------------------- 171*cdf0e10cSrcweir 172*cdf0e10cSrcweir AxisProperties::AxisProperties( const uno::Reference< XAxis >& xAxisModel 173*cdf0e10cSrcweir , ExplicitCategoriesProvider* pExplicitCategoriesProvider ) 174*cdf0e10cSrcweir : m_xAxisModel(xAxisModel) 175*cdf0e10cSrcweir , m_nDimensionIndex(0) 176*cdf0e10cSrcweir , m_bIsMainAxis(true) 177*cdf0e10cSrcweir , m_bSwapXAndY(false) 178*cdf0e10cSrcweir , m_eCrossoverType( ::com::sun::star::chart::ChartAxisPosition_ZERO ) 179*cdf0e10cSrcweir , m_eLabelPos( ::com::sun::star::chart::ChartAxisLabelPosition_NEAR_AXIS ) 180*cdf0e10cSrcweir , m_eTickmarkPos( ::com::sun::star::chart::ChartAxisMarkPosition_AT_LABELS_AND_AXIS ) 181*cdf0e10cSrcweir , m_pfMainLinePositionAtOtherAxis(NULL) 182*cdf0e10cSrcweir , m_pfExrtaLinePositionAtOtherAxis(NULL) 183*cdf0e10cSrcweir , m_bCrossingAxisHasReverseDirection(false) 184*cdf0e10cSrcweir , m_bCrossingAxisIsCategoryAxes(false) 185*cdf0e10cSrcweir , m_fLabelDirectionSign(1.0) 186*cdf0e10cSrcweir , m_fInnerDirectionSign(1.0) 187*cdf0e10cSrcweir , m_aLabelAlignment(LABEL_ALIGN_RIGHT_TOP) 188*cdf0e10cSrcweir , m_bDisplayLabels( true ) 189*cdf0e10cSrcweir , m_nNumberFormatKey(0) 190*cdf0e10cSrcweir , m_nMajorTickmarks(1) 191*cdf0e10cSrcweir , m_nMinorTickmarks(1) 192*cdf0e10cSrcweir , m_aTickmarkPropertiesList() 193*cdf0e10cSrcweir , m_aLineProperties() 194*cdf0e10cSrcweir //for category axes 195*cdf0e10cSrcweir , m_nAxisType(AxisType::REALNUMBER) 196*cdf0e10cSrcweir , m_bComplexCategories(false) 197*cdf0e10cSrcweir , m_pExplicitCategoriesProvider(pExplicitCategoriesProvider) 198*cdf0e10cSrcweir , m_xAxisTextProvider(0) 199*cdf0e10cSrcweir { 200*cdf0e10cSrcweir } 201*cdf0e10cSrcweir 202*cdf0e10cSrcweir AxisProperties::AxisProperties( const AxisProperties& rAxisProperties ) 203*cdf0e10cSrcweir : m_xAxisModel( rAxisProperties.m_xAxisModel ) 204*cdf0e10cSrcweir , m_nDimensionIndex( m_nDimensionIndex ) 205*cdf0e10cSrcweir , m_bIsMainAxis( rAxisProperties.m_bIsMainAxis ) 206*cdf0e10cSrcweir , m_bSwapXAndY( rAxisProperties.m_bSwapXAndY ) 207*cdf0e10cSrcweir , m_eCrossoverType( rAxisProperties.m_eCrossoverType ) 208*cdf0e10cSrcweir , m_eLabelPos( rAxisProperties.m_eLabelPos ) 209*cdf0e10cSrcweir , m_eTickmarkPos( rAxisProperties.m_eTickmarkPos ) 210*cdf0e10cSrcweir , m_pfMainLinePositionAtOtherAxis( NULL ) 211*cdf0e10cSrcweir , m_pfExrtaLinePositionAtOtherAxis( NULL ) 212*cdf0e10cSrcweir , m_bCrossingAxisHasReverseDirection( rAxisProperties.m_bCrossingAxisHasReverseDirection ) 213*cdf0e10cSrcweir , m_bCrossingAxisIsCategoryAxes( rAxisProperties.m_bCrossingAxisIsCategoryAxes ) 214*cdf0e10cSrcweir , m_fLabelDirectionSign( rAxisProperties.m_fLabelDirectionSign ) 215*cdf0e10cSrcweir , m_fInnerDirectionSign( rAxisProperties.m_fInnerDirectionSign ) 216*cdf0e10cSrcweir , m_aLabelAlignment( rAxisProperties.m_aLabelAlignment ) 217*cdf0e10cSrcweir , m_bDisplayLabels( rAxisProperties.m_bDisplayLabels ) 218*cdf0e10cSrcweir , m_nNumberFormatKey( rAxisProperties.m_nNumberFormatKey ) 219*cdf0e10cSrcweir , m_nMajorTickmarks( rAxisProperties.m_nMajorTickmarks ) 220*cdf0e10cSrcweir , m_nMinorTickmarks( rAxisProperties.m_nMinorTickmarks ) 221*cdf0e10cSrcweir , m_aTickmarkPropertiesList( rAxisProperties.m_aTickmarkPropertiesList ) 222*cdf0e10cSrcweir , m_aLineProperties( rAxisProperties.m_aLineProperties ) 223*cdf0e10cSrcweir //for category axes 224*cdf0e10cSrcweir , m_nAxisType( rAxisProperties.m_nAxisType ) 225*cdf0e10cSrcweir , m_bComplexCategories( rAxisProperties.m_bComplexCategories ) 226*cdf0e10cSrcweir , m_pExplicitCategoriesProvider( rAxisProperties.m_pExplicitCategoriesProvider ) 227*cdf0e10cSrcweir , m_xAxisTextProvider( rAxisProperties.m_xAxisTextProvider ) 228*cdf0e10cSrcweir { 229*cdf0e10cSrcweir if( rAxisProperties.m_pfMainLinePositionAtOtherAxis ) 230*cdf0e10cSrcweir m_pfMainLinePositionAtOtherAxis = new double(*rAxisProperties.m_pfMainLinePositionAtOtherAxis); 231*cdf0e10cSrcweir if( rAxisProperties.m_pfExrtaLinePositionAtOtherAxis ) 232*cdf0e10cSrcweir m_pfExrtaLinePositionAtOtherAxis = new double (*rAxisProperties.m_pfExrtaLinePositionAtOtherAxis); 233*cdf0e10cSrcweir } 234*cdf0e10cSrcweir 235*cdf0e10cSrcweir AxisProperties::~AxisProperties() 236*cdf0e10cSrcweir { 237*cdf0e10cSrcweir delete m_pfMainLinePositionAtOtherAxis; 238*cdf0e10cSrcweir delete m_pfExrtaLinePositionAtOtherAxis; 239*cdf0e10cSrcweir } 240*cdf0e10cSrcweir 241*cdf0e10cSrcweir LabelAlignment lcl_getLabelAlignmentForZAxis( const AxisProperties& rAxisProperties ) 242*cdf0e10cSrcweir { 243*cdf0e10cSrcweir LabelAlignment aRet( LABEL_ALIGN_RIGHT ); 244*cdf0e10cSrcweir if( rAxisProperties.m_fLabelDirectionSign<0 ) 245*cdf0e10cSrcweir aRet = LABEL_ALIGN_LEFT; 246*cdf0e10cSrcweir return aRet; 247*cdf0e10cSrcweir } 248*cdf0e10cSrcweir 249*cdf0e10cSrcweir LabelAlignment lcl_getLabelAlignmentForYAxis( const AxisProperties& rAxisProperties ) 250*cdf0e10cSrcweir { 251*cdf0e10cSrcweir LabelAlignment aRet( LABEL_ALIGN_RIGHT ); 252*cdf0e10cSrcweir if( rAxisProperties.m_fLabelDirectionSign<0 ) 253*cdf0e10cSrcweir aRet = LABEL_ALIGN_LEFT; 254*cdf0e10cSrcweir return aRet; 255*cdf0e10cSrcweir } 256*cdf0e10cSrcweir 257*cdf0e10cSrcweir LabelAlignment lcl_getLabelAlignmentForXAxis( const AxisProperties& rAxisProperties ) 258*cdf0e10cSrcweir { 259*cdf0e10cSrcweir LabelAlignment aRet( LABEL_ALIGN_BOTTOM ); 260*cdf0e10cSrcweir if( rAxisProperties.m_fLabelDirectionSign<0 ) 261*cdf0e10cSrcweir aRet = LABEL_ALIGN_TOP; 262*cdf0e10cSrcweir return aRet; 263*cdf0e10cSrcweir } 264*cdf0e10cSrcweir 265*cdf0e10cSrcweir void AxisProperties::initAxisPositioning( const uno::Reference< beans::XPropertySet >& xAxisProp ) 266*cdf0e10cSrcweir { 267*cdf0e10cSrcweir if( !xAxisProp.is() ) 268*cdf0e10cSrcweir return; 269*cdf0e10cSrcweir try 270*cdf0e10cSrcweir { 271*cdf0e10cSrcweir if( AxisHelper::isAxisPositioningEnabled() ) 272*cdf0e10cSrcweir { 273*cdf0e10cSrcweir xAxisProp->getPropertyValue(C2U( "CrossoverPosition" )) >>= m_eCrossoverType; 274*cdf0e10cSrcweir if( ::com::sun::star::chart::ChartAxisPosition_VALUE == m_eCrossoverType ) 275*cdf0e10cSrcweir { 276*cdf0e10cSrcweir double fValue = 0.0; 277*cdf0e10cSrcweir xAxisProp->getPropertyValue(C2U( "CrossoverValue" )) >>= fValue; 278*cdf0e10cSrcweir 279*cdf0e10cSrcweir if( m_bCrossingAxisIsCategoryAxes ) 280*cdf0e10cSrcweir fValue = ::rtl::math::round(fValue); 281*cdf0e10cSrcweir m_pfMainLinePositionAtOtherAxis = new double(fValue); 282*cdf0e10cSrcweir } 283*cdf0e10cSrcweir else if( ::com::sun::star::chart::ChartAxisPosition_ZERO == m_eCrossoverType ) 284*cdf0e10cSrcweir m_pfMainLinePositionAtOtherAxis = new double(0.0); 285*cdf0e10cSrcweir 286*cdf0e10cSrcweir xAxisProp->getPropertyValue(C2U( "LabelPosition" )) >>= m_eLabelPos; 287*cdf0e10cSrcweir xAxisProp->getPropertyValue(C2U( "MarkPosition" )) >>= m_eTickmarkPos; 288*cdf0e10cSrcweir } 289*cdf0e10cSrcweir else 290*cdf0e10cSrcweir { 291*cdf0e10cSrcweir m_eCrossoverType = ::com::sun::star::chart::ChartAxisPosition_START; 292*cdf0e10cSrcweir if( m_bIsMainAxis == m_bCrossingAxisHasReverseDirection ) 293*cdf0e10cSrcweir m_eCrossoverType = ::com::sun::star::chart::ChartAxisPosition_END; 294*cdf0e10cSrcweir m_eLabelPos = ::com::sun::star::chart::ChartAxisLabelPosition_NEAR_AXIS; 295*cdf0e10cSrcweir m_eTickmarkPos = ::com::sun::star::chart::ChartAxisMarkPosition_AT_LABELS; 296*cdf0e10cSrcweir } 297*cdf0e10cSrcweir } 298*cdf0e10cSrcweir catch( uno::Exception& e ) 299*cdf0e10cSrcweir { 300*cdf0e10cSrcweir ASSERT_EXCEPTION( e ); 301*cdf0e10cSrcweir } 302*cdf0e10cSrcweir } 303*cdf0e10cSrcweir 304*cdf0e10cSrcweir void AxisProperties::init( bool bCartesian ) 305*cdf0e10cSrcweir { 306*cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xProp = 307*cdf0e10cSrcweir uno::Reference<beans::XPropertySet>::query( this->m_xAxisModel ); 308*cdf0e10cSrcweir if( !xProp.is() ) 309*cdf0e10cSrcweir return; 310*cdf0e10cSrcweir 311*cdf0e10cSrcweir if( m_nDimensionIndex<2 ) 312*cdf0e10cSrcweir initAxisPositioning( xProp ); 313*cdf0e10cSrcweir 314*cdf0e10cSrcweir ScaleData aScaleData = m_xAxisModel->getScaleData(); 315*cdf0e10cSrcweir if( m_nDimensionIndex==0 ) 316*cdf0e10cSrcweir AxisHelper::checkDateAxis( aScaleData, m_pExplicitCategoriesProvider, bCartesian ); 317*cdf0e10cSrcweir m_nAxisType = aScaleData.AxisType; 318*cdf0e10cSrcweir 319*cdf0e10cSrcweir if( bCartesian ) 320*cdf0e10cSrcweir { 321*cdf0e10cSrcweir if( m_nDimensionIndex == 0 && m_nAxisType == AxisType::CATEGORY 322*cdf0e10cSrcweir && m_pExplicitCategoriesProvider && m_pExplicitCategoriesProvider->hasComplexCategories() ) 323*cdf0e10cSrcweir m_bComplexCategories = true; 324*cdf0e10cSrcweir 325*cdf0e10cSrcweir if( ::com::sun::star::chart::ChartAxisPosition_END == m_eCrossoverType ) 326*cdf0e10cSrcweir m_fInnerDirectionSign = m_bCrossingAxisHasReverseDirection ? 1 : -1; 327*cdf0e10cSrcweir else 328*cdf0e10cSrcweir m_fInnerDirectionSign = m_bCrossingAxisHasReverseDirection ? -1 : 1; 329*cdf0e10cSrcweir 330*cdf0e10cSrcweir if( ::com::sun::star::chart::ChartAxisLabelPosition_NEAR_AXIS == m_eLabelPos ) 331*cdf0e10cSrcweir m_fLabelDirectionSign = m_fInnerDirectionSign; 332*cdf0e10cSrcweir else if( ::com::sun::star::chart::ChartAxisLabelPosition_NEAR_AXIS_OTHER_SIDE == m_eLabelPos ) 333*cdf0e10cSrcweir m_fLabelDirectionSign = -m_fInnerDirectionSign; 334*cdf0e10cSrcweir else if( ::com::sun::star::chart::ChartAxisLabelPosition_OUTSIDE_START == m_eLabelPos ) 335*cdf0e10cSrcweir m_fLabelDirectionSign = m_bCrossingAxisHasReverseDirection ? -1 : 1; 336*cdf0e10cSrcweir else if( ::com::sun::star::chart::ChartAxisLabelPosition_OUTSIDE_END == m_eLabelPos ) 337*cdf0e10cSrcweir m_fLabelDirectionSign = m_bCrossingAxisHasReverseDirection ? 1 : -1; 338*cdf0e10cSrcweir 339*cdf0e10cSrcweir if( m_nDimensionIndex==2 ) 340*cdf0e10cSrcweir m_aLabelAlignment = lcl_getLabelAlignmentForZAxis(*this); 341*cdf0e10cSrcweir else 342*cdf0e10cSrcweir { 343*cdf0e10cSrcweir bool bIsYAxisPosition = (m_nDimensionIndex==1 && !m_bSwapXAndY) 344*cdf0e10cSrcweir || (m_nDimensionIndex==0 && m_bSwapXAndY); 345*cdf0e10cSrcweir if( bIsYAxisPosition ) 346*cdf0e10cSrcweir { 347*cdf0e10cSrcweir m_fLabelDirectionSign*=-1; 348*cdf0e10cSrcweir m_fInnerDirectionSign*=-1; 349*cdf0e10cSrcweir } 350*cdf0e10cSrcweir 351*cdf0e10cSrcweir if( bIsYAxisPosition ) 352*cdf0e10cSrcweir m_aLabelAlignment = lcl_getLabelAlignmentForYAxis(*this); 353*cdf0e10cSrcweir else 354*cdf0e10cSrcweir m_aLabelAlignment = lcl_getLabelAlignmentForXAxis(*this); 355*cdf0e10cSrcweir } 356*cdf0e10cSrcweir } 357*cdf0e10cSrcweir 358*cdf0e10cSrcweir try 359*cdf0e10cSrcweir { 360*cdf0e10cSrcweir //init LineProperties 361*cdf0e10cSrcweir m_aLineProperties.initFromPropertySet( xProp ); 362*cdf0e10cSrcweir 363*cdf0e10cSrcweir //init display labels 364*cdf0e10cSrcweir xProp->getPropertyValue( C2U( "DisplayLabels" ) ) >>= m_bDisplayLabels; 365*cdf0e10cSrcweir 366*cdf0e10cSrcweir //init TickmarkProperties 367*cdf0e10cSrcweir xProp->getPropertyValue( C2U( "MajorTickmarks" ) ) >>= m_nMajorTickmarks; 368*cdf0e10cSrcweir xProp->getPropertyValue( C2U( "MinorTickmarks" ) ) >>= m_nMinorTickmarks; 369*cdf0e10cSrcweir 370*cdf0e10cSrcweir sal_Int32 nMaxDepth = 0; 371*cdf0e10cSrcweir if(m_nMinorTickmarks!=0) 372*cdf0e10cSrcweir nMaxDepth=2; 373*cdf0e10cSrcweir else if(m_nMajorTickmarks!=0) 374*cdf0e10cSrcweir nMaxDepth=1; 375*cdf0e10cSrcweir 376*cdf0e10cSrcweir this->m_aTickmarkPropertiesList.clear(); 377*cdf0e10cSrcweir for( sal_Int32 nDepth=0; nDepth<nMaxDepth; nDepth++ ) 378*cdf0e10cSrcweir { 379*cdf0e10cSrcweir TickmarkProperties aTickmarkProperties = this->makeTickmarkProperties( nDepth ); 380*cdf0e10cSrcweir this->m_aTickmarkPropertiesList.push_back( aTickmarkProperties ); 381*cdf0e10cSrcweir } 382*cdf0e10cSrcweir } 383*cdf0e10cSrcweir catch( uno::Exception& e ) 384*cdf0e10cSrcweir { 385*cdf0e10cSrcweir ASSERT_EXCEPTION( e ); 386*cdf0e10cSrcweir } 387*cdf0e10cSrcweir } 388*cdf0e10cSrcweir 389*cdf0e10cSrcweir //----------------------------------------------------------------------------- 390*cdf0e10cSrcweir 391*cdf0e10cSrcweir AxisLabelProperties::AxisLabelProperties() 392*cdf0e10cSrcweir : m_aFontReferenceSize( ChartModelHelper::getDefaultPageSize() ) 393*cdf0e10cSrcweir , m_aMaximumSpaceForLabels( 0 , 0, m_aFontReferenceSize.Width, m_aFontReferenceSize.Height ) 394*cdf0e10cSrcweir , nNumberFormatKey(0) 395*cdf0e10cSrcweir , eStaggering( SIDE_BY_SIDE ) 396*cdf0e10cSrcweir , bLineBreakAllowed( false ) 397*cdf0e10cSrcweir , bOverlapAllowed( false ) 398*cdf0e10cSrcweir , bStackCharacters( false ) 399*cdf0e10cSrcweir , fRotationAngleDegree( 0.0 ) 400*cdf0e10cSrcweir , nRhythm( 1 ) 401*cdf0e10cSrcweir , bRhythmIsFix(false) 402*cdf0e10cSrcweir { 403*cdf0e10cSrcweir /* 404*cdf0e10cSrcweir aLocale.Language = C2U( "en" ); 405*cdf0e10cSrcweir aLocale.Country = C2U( "US" ); 406*cdf0e10cSrcweir 407*cdf0e10cSrcweir //aLocale.Language = C2U( "ar" ); 408*cdf0e10cSrcweir //aLocale.Country = C2U( "IR" ); 409*cdf0e10cSrcweir 410*cdf0e10cSrcweir //aLocale.Language = C2U( "ja" ); 411*cdf0e10cSrcweir //aLocale.Country = C2U( "JP" ); 412*cdf0e10cSrcweir */ 413*cdf0e10cSrcweir } 414*cdf0e10cSrcweir 415*cdf0e10cSrcweir void AxisLabelProperties::init( const uno::Reference< XAxis >& xAxisModel ) 416*cdf0e10cSrcweir { 417*cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xProp = 418*cdf0e10cSrcweir uno::Reference<beans::XPropertySet>::query( xAxisModel ); 419*cdf0e10cSrcweir if(xProp.is()) 420*cdf0e10cSrcweir { 421*cdf0e10cSrcweir try 422*cdf0e10cSrcweir { 423*cdf0e10cSrcweir xProp->getPropertyValue( C2U( "TextBreak" ) ) >>= this->bLineBreakAllowed; 424*cdf0e10cSrcweir xProp->getPropertyValue( C2U( "TextOverlap" ) ) >>= this->bOverlapAllowed; 425*cdf0e10cSrcweir xProp->getPropertyValue( C2U( "StackCharacters" ) ) >>= this->bStackCharacters; 426*cdf0e10cSrcweir xProp->getPropertyValue( C2U( "TextRotation" ) ) >>= this->fRotationAngleDegree; 427*cdf0e10cSrcweir 428*cdf0e10cSrcweir ::com::sun::star::chart::ChartAxisArrangeOrderType eArrangeOrder; 429*cdf0e10cSrcweir xProp->getPropertyValue( C2U( "ArrangeOrder" ) ) >>= eArrangeOrder; 430*cdf0e10cSrcweir switch(eArrangeOrder) 431*cdf0e10cSrcweir { 432*cdf0e10cSrcweir case ::com::sun::star::chart::ChartAxisArrangeOrderType_SIDE_BY_SIDE: 433*cdf0e10cSrcweir this->eStaggering = SIDE_BY_SIDE; 434*cdf0e10cSrcweir break; 435*cdf0e10cSrcweir case ::com::sun::star::chart::ChartAxisArrangeOrderType_STAGGER_EVEN: 436*cdf0e10cSrcweir this->eStaggering = STAGGER_EVEN; 437*cdf0e10cSrcweir break; 438*cdf0e10cSrcweir case ::com::sun::star::chart::ChartAxisArrangeOrderType_STAGGER_ODD: 439*cdf0e10cSrcweir this->eStaggering = STAGGER_ODD; 440*cdf0e10cSrcweir break; 441*cdf0e10cSrcweir default: 442*cdf0e10cSrcweir this->eStaggering = STAGGER_AUTO; 443*cdf0e10cSrcweir break; 444*cdf0e10cSrcweir } 445*cdf0e10cSrcweir } 446*cdf0e10cSrcweir catch( uno::Exception& e ) 447*cdf0e10cSrcweir { 448*cdf0e10cSrcweir ASSERT_EXCEPTION( e ); 449*cdf0e10cSrcweir } 450*cdf0e10cSrcweir } 451*cdf0e10cSrcweir } 452*cdf0e10cSrcweir 453*cdf0e10cSrcweir /* 454*cdf0e10cSrcweir sal_Int16 getSwappedWritingMode( sal_Int16 nWritingMode ) 455*cdf0e10cSrcweir { 456*cdf0e10cSrcweir //LR_TB == LT 457*cdf0e10cSrcweir //RL_TB == RT (Arabic, Hebrew) 458*cdf0e10cSrcweir //TB_RL == TR (Japanese, Chinese, Korean) 459*cdf0e10cSrcweir // ?? TL (Mongolian) see also text::WritingMode2 460*cdf0e10cSrcweir 461*cdf0e10cSrcweir switch(nWritingMode) 462*cdf0e10cSrcweir { 463*cdf0e10cSrcweir case text::WritingMode2::RL_TB: 464*cdf0e10cSrcweir return text::WritingMode2::TB_RL; 465*cdf0e10cSrcweir case text::WritingMode2::TB_RL: 466*cdf0e10cSrcweir return text::WritingMode2::RL_TB; 467*cdf0e10cSrcweir case text::WritingMode2::LR_TB: 468*cdf0e10cSrcweir return text::WritingMode2::TB_LR; 469*cdf0e10cSrcweir default: 470*cdf0e10cSrcweir return text::WritingMode2::LR_TB; 471*cdf0e10cSrcweir } 472*cdf0e10cSrcweir } 473*cdf0e10cSrcweir */ 474*cdf0e10cSrcweir 475*cdf0e10cSrcweir sal_Bool AxisLabelProperties::getIsStaggered() const 476*cdf0e10cSrcweir { 477*cdf0e10cSrcweir if( STAGGER_ODD == eStaggering || STAGGER_EVEN == eStaggering ) 478*cdf0e10cSrcweir return sal_True; 479*cdf0e10cSrcweir return sal_False; 480*cdf0e10cSrcweir } 481*cdf0e10cSrcweir 482*cdf0e10cSrcweir //............................................................................. 483*cdf0e10cSrcweir } //namespace chart 484*cdf0e10cSrcweir //............................................................................. 485