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 <basegfx/numeric/ftools.hxx> 31*cdf0e10cSrcweir 32*cdf0e10cSrcweir #include "VCartesianAxis.hxx" 33*cdf0e10cSrcweir #include "PlottingPositionHelper.hxx" 34*cdf0e10cSrcweir #include "ShapeFactory.hxx" 35*cdf0e10cSrcweir #include "CommonConverters.hxx" 36*cdf0e10cSrcweir #include "macros.hxx" 37*cdf0e10cSrcweir #include "ViewDefines.hxx" 38*cdf0e10cSrcweir #include "PropertyMapper.hxx" 39*cdf0e10cSrcweir #include "NumberFormatterWrapper.hxx" 40*cdf0e10cSrcweir #include "LabelPositionHelper.hxx" 41*cdf0e10cSrcweir #include "TrueGuard.hxx" 42*cdf0e10cSrcweir #include "BaseGFXHelper.hxx" 43*cdf0e10cSrcweir #include "AxisHelper.hxx" 44*cdf0e10cSrcweir #include "Tickmarks_Equidistant.hxx" 45*cdf0e10cSrcweir 46*cdf0e10cSrcweir #include <rtl/math.hxx> 47*cdf0e10cSrcweir #include <tools/color.hxx> 48*cdf0e10cSrcweir #include <tools/debug.hxx> 49*cdf0e10cSrcweir #include <com/sun/star/text/XText.hpp> 50*cdf0e10cSrcweir #include <com/sun/star/text/WritingMode2.hpp> 51*cdf0e10cSrcweir #include <editeng/unoprnms.hxx> 52*cdf0e10cSrcweir #include <svx/unoshape.hxx> 53*cdf0e10cSrcweir #include <svx/unoshtxt.hxx> 54*cdf0e10cSrcweir 55*cdf0e10cSrcweir #include <algorithm> 56*cdf0e10cSrcweir #include <memory> 57*cdf0e10cSrcweir 58*cdf0e10cSrcweir //............................................................................. 59*cdf0e10cSrcweir namespace chart 60*cdf0e10cSrcweir { 61*cdf0e10cSrcweir //............................................................................. 62*cdf0e10cSrcweir using namespace ::com::sun::star; 63*cdf0e10cSrcweir using namespace ::com::sun::star::chart2; 64*cdf0e10cSrcweir using namespace ::rtl::math; 65*cdf0e10cSrcweir using ::com::sun::star::uno::Reference; 66*cdf0e10cSrcweir 67*cdf0e10cSrcweir //----------------------------------------------------------------------------- 68*cdf0e10cSrcweir //----------------------------------------------------------------------------- 69*cdf0e10cSrcweir //----------------------------------------------------------------------------- 70*cdf0e10cSrcweir 71*cdf0e10cSrcweir VCartesianAxis::VCartesianAxis( const AxisProperties& rAxisProperties 72*cdf0e10cSrcweir , const Reference< util::XNumberFormatsSupplier >& xNumberFormatsSupplier 73*cdf0e10cSrcweir , sal_Int32 nDimensionIndex, sal_Int32 nDimensionCount 74*cdf0e10cSrcweir , PlottingPositionHelper* pPosHelper )//takes ownership 75*cdf0e10cSrcweir : VAxisBase( nDimensionIndex, nDimensionCount, rAxisProperties, xNumberFormatsSupplier ) 76*cdf0e10cSrcweir { 77*cdf0e10cSrcweir if( pPosHelper ) 78*cdf0e10cSrcweir m_pPosHelper = pPosHelper; 79*cdf0e10cSrcweir else 80*cdf0e10cSrcweir m_pPosHelper = new PlottingPositionHelper(); 81*cdf0e10cSrcweir } 82*cdf0e10cSrcweir 83*cdf0e10cSrcweir VCartesianAxis::~VCartesianAxis() 84*cdf0e10cSrcweir { 85*cdf0e10cSrcweir delete m_pPosHelper; 86*cdf0e10cSrcweir m_pPosHelper = NULL; 87*cdf0e10cSrcweir } 88*cdf0e10cSrcweir 89*cdf0e10cSrcweir //----------------------------------------------------------------------------- 90*cdf0e10cSrcweir //----------------------------------------------------------------------------- 91*cdf0e10cSrcweir 92*cdf0e10cSrcweir Reference< drawing::XShape > createSingleLabel( 93*cdf0e10cSrcweir const Reference< lang::XMultiServiceFactory>& xShapeFactory 94*cdf0e10cSrcweir , const Reference< drawing::XShapes >& xTarget 95*cdf0e10cSrcweir , const awt::Point& rAnchorScreenPosition2D 96*cdf0e10cSrcweir , const rtl::OUString& rLabel 97*cdf0e10cSrcweir , const AxisLabelProperties& rAxisLabelProperties 98*cdf0e10cSrcweir , const AxisProperties& rAxisProperties 99*cdf0e10cSrcweir , const tNameSequence& rPropNames 100*cdf0e10cSrcweir , const tAnySequence& rPropValues 101*cdf0e10cSrcweir ) 102*cdf0e10cSrcweir { 103*cdf0e10cSrcweir if(!rLabel.getLength()) 104*cdf0e10cSrcweir return 0; 105*cdf0e10cSrcweir 106*cdf0e10cSrcweir // #i78696# use mathematically correct rotation now 107*cdf0e10cSrcweir const double fRotationAnglePi(rAxisLabelProperties.fRotationAngleDegree * (F_PI / -180.0)); 108*cdf0e10cSrcweir uno::Any aATransformation = ShapeFactory::makeTransformation( rAnchorScreenPosition2D, fRotationAnglePi ); 109*cdf0e10cSrcweir rtl::OUString aLabel = ShapeFactory::getStackedString( rLabel, rAxisLabelProperties.bStackCharacters ); 110*cdf0e10cSrcweir 111*cdf0e10cSrcweir Reference< drawing::XShape > xShape2DText = ShapeFactory(xShapeFactory) 112*cdf0e10cSrcweir .createText( xTarget, aLabel, rPropNames, rPropValues, aATransformation ); 113*cdf0e10cSrcweir 114*cdf0e10cSrcweir //correctPositionForRotation 115*cdf0e10cSrcweir LabelPositionHelper::correctPositionForRotation( xShape2DText 116*cdf0e10cSrcweir , rAxisProperties.m_aLabelAlignment, rAxisLabelProperties.fRotationAngleDegree, rAxisProperties.m_bComplexCategories ); 117*cdf0e10cSrcweir 118*cdf0e10cSrcweir return xShape2DText; 119*cdf0e10cSrcweir } 120*cdf0e10cSrcweir 121*cdf0e10cSrcweir bool lcl_doesShapeOverlapWithTickmark( const Reference< drawing::XShape >& xShape 122*cdf0e10cSrcweir , double fRotationAngleDegree 123*cdf0e10cSrcweir , const basegfx::B2DVector& rTickScreenPosition 124*cdf0e10cSrcweir , bool bIsHorizontalAxis, bool bIsVerticalAxis ) 125*cdf0e10cSrcweir { 126*cdf0e10cSrcweir if(!xShape.is()) 127*cdf0e10cSrcweir return false; 128*cdf0e10cSrcweir 129*cdf0e10cSrcweir ::basegfx::B2IRectangle aShapeRect = BaseGFXHelper::makeRectangle(xShape->getPosition(),ShapeFactory::getSizeAfterRotation( xShape, fRotationAngleDegree )); 130*cdf0e10cSrcweir 131*cdf0e10cSrcweir if( bIsVerticalAxis ) 132*cdf0e10cSrcweir { 133*cdf0e10cSrcweir return ( (rTickScreenPosition.getY() >= aShapeRect.getMinY()) 134*cdf0e10cSrcweir && (rTickScreenPosition.getY() <= aShapeRect.getMaxY()) ); 135*cdf0e10cSrcweir } 136*cdf0e10cSrcweir if( bIsHorizontalAxis ) 137*cdf0e10cSrcweir { 138*cdf0e10cSrcweir return ( (rTickScreenPosition.getX() >= aShapeRect.getMinX()) 139*cdf0e10cSrcweir && (rTickScreenPosition.getX() <= aShapeRect.getMaxX()) ); 140*cdf0e10cSrcweir } 141*cdf0e10cSrcweir 142*cdf0e10cSrcweir basegfx::B2IVector aPosition( 143*cdf0e10cSrcweir static_cast<sal_Int32>( rTickScreenPosition.getX() ) 144*cdf0e10cSrcweir , static_cast<sal_Int32>( rTickScreenPosition.getY() ) ); 145*cdf0e10cSrcweir return aShapeRect.isInside(aPosition); 146*cdf0e10cSrcweir } 147*cdf0e10cSrcweir 148*cdf0e10cSrcweir bool doesOverlap( const Reference< drawing::XShape >& xShape1 149*cdf0e10cSrcweir , const Reference< drawing::XShape >& xShape2 150*cdf0e10cSrcweir , double fRotationAngleDegree ) 151*cdf0e10cSrcweir { 152*cdf0e10cSrcweir if( !xShape1.is() || !xShape2.is() ) 153*cdf0e10cSrcweir return false; 154*cdf0e10cSrcweir 155*cdf0e10cSrcweir ::basegfx::B2IRectangle aRect1( BaseGFXHelper::makeRectangle(xShape1->getPosition(),ShapeFactory::getSizeAfterRotation( xShape1, fRotationAngleDegree ))); 156*cdf0e10cSrcweir ::basegfx::B2IRectangle aRect2( BaseGFXHelper::makeRectangle(xShape2->getPosition(),ShapeFactory::getSizeAfterRotation( xShape2, fRotationAngleDegree ))); 157*cdf0e10cSrcweir return aRect1.overlaps(aRect2); 158*cdf0e10cSrcweir } 159*cdf0e10cSrcweir 160*cdf0e10cSrcweir void removeShapesAtWrongRhythm( TickIter& rIter 161*cdf0e10cSrcweir , sal_Int32 nCorrectRhythm 162*cdf0e10cSrcweir , sal_Int32 nMaxTickToCheck 163*cdf0e10cSrcweir , const Reference< drawing::XShapes >& xTarget ) 164*cdf0e10cSrcweir { 165*cdf0e10cSrcweir sal_Int32 nTick = 0; 166*cdf0e10cSrcweir for( TickInfo* pTickInfo = rIter.firstInfo() 167*cdf0e10cSrcweir ; pTickInfo && nTick <= nMaxTickToCheck 168*cdf0e10cSrcweir ; pTickInfo = rIter.nextInfo(), nTick++ ) 169*cdf0e10cSrcweir { 170*cdf0e10cSrcweir //remove labels which does not fit into the rhythm 171*cdf0e10cSrcweir if( nTick%nCorrectRhythm != 0) 172*cdf0e10cSrcweir { 173*cdf0e10cSrcweir if(pTickInfo->xTextShape.is()) 174*cdf0e10cSrcweir { 175*cdf0e10cSrcweir xTarget->remove(pTickInfo->xTextShape); 176*cdf0e10cSrcweir pTickInfo->xTextShape = NULL; 177*cdf0e10cSrcweir } 178*cdf0e10cSrcweir } 179*cdf0e10cSrcweir } 180*cdf0e10cSrcweir } 181*cdf0e10cSrcweir 182*cdf0e10cSrcweir class LabelIterator : public TickIter 183*cdf0e10cSrcweir { 184*cdf0e10cSrcweir //this Iterator iterates over existing text labels 185*cdf0e10cSrcweir 186*cdf0e10cSrcweir //if the labels are staggered and bInnerLine is true 187*cdf0e10cSrcweir //we iterate only through the labels which are lying more inside the diagram 188*cdf0e10cSrcweir 189*cdf0e10cSrcweir //if the labels are staggered and bInnerLine is false 190*cdf0e10cSrcweir //we iterate only through the labels which are lying more outside the diagram 191*cdf0e10cSrcweir 192*cdf0e10cSrcweir //if the labels are not staggered 193*cdf0e10cSrcweir //we iterate through all labels 194*cdf0e10cSrcweir 195*cdf0e10cSrcweir public: 196*cdf0e10cSrcweir LabelIterator( ::std::vector< TickInfo >& rTickInfoVector 197*cdf0e10cSrcweir , const AxisLabelStaggering eAxisLabelStaggering 198*cdf0e10cSrcweir , bool bInnerLine ); 199*cdf0e10cSrcweir 200*cdf0e10cSrcweir virtual TickInfo* firstInfo(); 201*cdf0e10cSrcweir virtual TickInfo* nextInfo(); 202*cdf0e10cSrcweir 203*cdf0e10cSrcweir private: //methods 204*cdf0e10cSrcweir LabelIterator(); 205*cdf0e10cSrcweir 206*cdf0e10cSrcweir private: //member 207*cdf0e10cSrcweir PureTickIter m_aPureTickIter; 208*cdf0e10cSrcweir const AxisLabelStaggering m_eAxisLabelStaggering; 209*cdf0e10cSrcweir bool m_bInnerLine; 210*cdf0e10cSrcweir }; 211*cdf0e10cSrcweir 212*cdf0e10cSrcweir LabelIterator::LabelIterator( ::std::vector< TickInfo >& rTickInfoVector 213*cdf0e10cSrcweir , const AxisLabelStaggering eAxisLabelStaggering 214*cdf0e10cSrcweir , bool bInnerLine ) 215*cdf0e10cSrcweir : m_aPureTickIter( rTickInfoVector ) 216*cdf0e10cSrcweir , m_eAxisLabelStaggering(eAxisLabelStaggering) 217*cdf0e10cSrcweir , m_bInnerLine(bInnerLine) 218*cdf0e10cSrcweir { 219*cdf0e10cSrcweir } 220*cdf0e10cSrcweir 221*cdf0e10cSrcweir TickInfo* LabelIterator::firstInfo() 222*cdf0e10cSrcweir { 223*cdf0e10cSrcweir TickInfo* pTickInfo = m_aPureTickIter.firstInfo(); 224*cdf0e10cSrcweir while( pTickInfo && !pTickInfo->xTextShape.is() ) 225*cdf0e10cSrcweir pTickInfo = m_aPureTickIter.nextInfo(); 226*cdf0e10cSrcweir if(!pTickInfo) 227*cdf0e10cSrcweir return NULL; 228*cdf0e10cSrcweir if( (STAGGER_EVEN==m_eAxisLabelStaggering && m_bInnerLine) 229*cdf0e10cSrcweir || 230*cdf0e10cSrcweir (STAGGER_ODD==m_eAxisLabelStaggering && !m_bInnerLine) 231*cdf0e10cSrcweir ) 232*cdf0e10cSrcweir { 233*cdf0e10cSrcweir //skip first label 234*cdf0e10cSrcweir do 235*cdf0e10cSrcweir pTickInfo = m_aPureTickIter.nextInfo(); 236*cdf0e10cSrcweir while( pTickInfo && !pTickInfo->xTextShape.is() ); 237*cdf0e10cSrcweir } 238*cdf0e10cSrcweir if(!pTickInfo) 239*cdf0e10cSrcweir return NULL; 240*cdf0e10cSrcweir return pTickInfo; 241*cdf0e10cSrcweir } 242*cdf0e10cSrcweir 243*cdf0e10cSrcweir TickInfo* LabelIterator::nextInfo() 244*cdf0e10cSrcweir { 245*cdf0e10cSrcweir TickInfo* pTickInfo = NULL; 246*cdf0e10cSrcweir //get next label 247*cdf0e10cSrcweir do 248*cdf0e10cSrcweir pTickInfo = m_aPureTickIter.nextInfo(); 249*cdf0e10cSrcweir while( pTickInfo && !pTickInfo->xTextShape.is() ); 250*cdf0e10cSrcweir 251*cdf0e10cSrcweir if( STAGGER_EVEN==m_eAxisLabelStaggering 252*cdf0e10cSrcweir || STAGGER_ODD==m_eAxisLabelStaggering ) 253*cdf0e10cSrcweir { 254*cdf0e10cSrcweir //skip one label 255*cdf0e10cSrcweir do 256*cdf0e10cSrcweir pTickInfo = m_aPureTickIter.nextInfo(); 257*cdf0e10cSrcweir while( pTickInfo && !pTickInfo->xTextShape.is() ); 258*cdf0e10cSrcweir } 259*cdf0e10cSrcweir return pTickInfo; 260*cdf0e10cSrcweir } 261*cdf0e10cSrcweir 262*cdf0e10cSrcweir B2DVector lcl_getLabelsDistance( TickIter& rIter, const B2DVector& rDistanceTickToText, double fRotationAngleDegree ) 263*cdf0e10cSrcweir { 264*cdf0e10cSrcweir //calculates the height or width of a line of labels 265*cdf0e10cSrcweir //thus a following line of labels can be shifted for that distance 266*cdf0e10cSrcweir 267*cdf0e10cSrcweir B2DVector aRet(0,0); 268*cdf0e10cSrcweir 269*cdf0e10cSrcweir sal_Int32 nDistanceTickToText = static_cast<sal_Int32>( rDistanceTickToText.getLength() ); 270*cdf0e10cSrcweir if( nDistanceTickToText==0.0) 271*cdf0e10cSrcweir return aRet; 272*cdf0e10cSrcweir 273*cdf0e10cSrcweir B2DVector aStaggerDirection(rDistanceTickToText); 274*cdf0e10cSrcweir aStaggerDirection.normalize(); 275*cdf0e10cSrcweir 276*cdf0e10cSrcweir sal_Int32 nDistance=0; 277*cdf0e10cSrcweir Reference< drawing::XShape > xShape2DText(NULL); 278*cdf0e10cSrcweir for( TickInfo* pTickInfo = rIter.firstInfo() 279*cdf0e10cSrcweir ; pTickInfo 280*cdf0e10cSrcweir ; pTickInfo = rIter.nextInfo() ) 281*cdf0e10cSrcweir { 282*cdf0e10cSrcweir xShape2DText = pTickInfo->xTextShape; 283*cdf0e10cSrcweir if( xShape2DText.is() ) 284*cdf0e10cSrcweir { 285*cdf0e10cSrcweir awt::Size aSize = ShapeFactory::getSizeAfterRotation( xShape2DText, fRotationAngleDegree ); 286*cdf0e10cSrcweir if(fabs(aStaggerDirection.getX())>fabs(aStaggerDirection.getY())) 287*cdf0e10cSrcweir nDistance = ::std::max(nDistance,aSize.Width); 288*cdf0e10cSrcweir else 289*cdf0e10cSrcweir nDistance = ::std::max(nDistance,aSize.Height); 290*cdf0e10cSrcweir } 291*cdf0e10cSrcweir } 292*cdf0e10cSrcweir 293*cdf0e10cSrcweir aRet = aStaggerDirection*nDistance; 294*cdf0e10cSrcweir 295*cdf0e10cSrcweir //add extra distance for vertical distance 296*cdf0e10cSrcweir if(fabs(aStaggerDirection.getX())>fabs(aStaggerDirection.getY())) 297*cdf0e10cSrcweir aRet += rDistanceTickToText; 298*cdf0e10cSrcweir 299*cdf0e10cSrcweir return aRet; 300*cdf0e10cSrcweir } 301*cdf0e10cSrcweir 302*cdf0e10cSrcweir void lcl_shiftLables( TickIter& rIter, const B2DVector& rStaggerDistance ) 303*cdf0e10cSrcweir { 304*cdf0e10cSrcweir if(rStaggerDistance.getLength()==0.0) 305*cdf0e10cSrcweir return; 306*cdf0e10cSrcweir Reference< drawing::XShape > xShape2DText(NULL); 307*cdf0e10cSrcweir for( TickInfo* pTickInfo = rIter.firstInfo() 308*cdf0e10cSrcweir ; pTickInfo 309*cdf0e10cSrcweir ; pTickInfo = rIter.nextInfo() ) 310*cdf0e10cSrcweir { 311*cdf0e10cSrcweir xShape2DText = pTickInfo->xTextShape; 312*cdf0e10cSrcweir if( xShape2DText.is() ) 313*cdf0e10cSrcweir { 314*cdf0e10cSrcweir awt::Point aPos = xShape2DText->getPosition(); 315*cdf0e10cSrcweir aPos.X += static_cast<sal_Int32>(rStaggerDistance.getX()); 316*cdf0e10cSrcweir aPos.Y += static_cast<sal_Int32>(rStaggerDistance.getY()); 317*cdf0e10cSrcweir xShape2DText->setPosition( aPos ); 318*cdf0e10cSrcweir } 319*cdf0e10cSrcweir } 320*cdf0e10cSrcweir } 321*cdf0e10cSrcweir 322*cdf0e10cSrcweir bool lcl_hasWordBreak( const Reference< drawing::XShape >& rxShape ) 323*cdf0e10cSrcweir { 324*cdf0e10cSrcweir if ( rxShape.is() ) 325*cdf0e10cSrcweir { 326*cdf0e10cSrcweir SvxShape* pShape = SvxShape::getImplementation( rxShape ); 327*cdf0e10cSrcweir SvxShapeText* pShapeText = dynamic_cast< SvxShapeText* >( pShape ); 328*cdf0e10cSrcweir if ( pShapeText ) 329*cdf0e10cSrcweir { 330*cdf0e10cSrcweir SvxTextEditSource* pTextEditSource = dynamic_cast< SvxTextEditSource* >( pShapeText->GetEditSource() ); 331*cdf0e10cSrcweir if ( pTextEditSource ) 332*cdf0e10cSrcweir { 333*cdf0e10cSrcweir pTextEditSource->UpdateOutliner(); 334*cdf0e10cSrcweir SvxTextForwarder* pTextForwarder = pTextEditSource->GetTextForwarder(); 335*cdf0e10cSrcweir if ( pTextForwarder ) 336*cdf0e10cSrcweir { 337*cdf0e10cSrcweir sal_uInt16 nParaCount = pTextForwarder->GetParagraphCount(); 338*cdf0e10cSrcweir for ( sal_uInt16 nPara = 0; nPara < nParaCount; ++nPara ) 339*cdf0e10cSrcweir { 340*cdf0e10cSrcweir sal_uInt16 nLineCount = pTextForwarder->GetLineCount( nPara ); 341*cdf0e10cSrcweir for ( sal_uInt16 nLine = 0; nLine < nLineCount; ++nLine ) 342*cdf0e10cSrcweir { 343*cdf0e10cSrcweir sal_uInt16 nLineStart = 0; 344*cdf0e10cSrcweir sal_uInt16 nLineEnd = 0; 345*cdf0e10cSrcweir pTextForwarder->GetLineBoundaries( nLineStart, nLineEnd, nPara, nLine ); 346*cdf0e10cSrcweir sal_uInt16 nWordStart = 0; 347*cdf0e10cSrcweir sal_uInt16 nWordEnd = 0; 348*cdf0e10cSrcweir if ( pTextForwarder->GetWordIndices( nPara, nLineStart, nWordStart, nWordEnd ) && 349*cdf0e10cSrcweir ( nWordStart != nLineStart ) ) 350*cdf0e10cSrcweir { 351*cdf0e10cSrcweir return true; 352*cdf0e10cSrcweir } 353*cdf0e10cSrcweir } 354*cdf0e10cSrcweir } 355*cdf0e10cSrcweir } 356*cdf0e10cSrcweir } 357*cdf0e10cSrcweir } 358*cdf0e10cSrcweir } 359*cdf0e10cSrcweir 360*cdf0e10cSrcweir return false; 361*cdf0e10cSrcweir } 362*cdf0e10cSrcweir 363*cdf0e10cSrcweir class MaxLabelTickIter : public TickIter 364*cdf0e10cSrcweir { 365*cdf0e10cSrcweir //iterate over first two and last two labels and the longest label 366*cdf0e10cSrcweir public: 367*cdf0e10cSrcweir MaxLabelTickIter( ::std::vector< TickInfo >& rTickInfoVector 368*cdf0e10cSrcweir , sal_Int32 nLongestLabelIndex ); 369*cdf0e10cSrcweir virtual ~MaxLabelTickIter(); 370*cdf0e10cSrcweir 371*cdf0e10cSrcweir virtual TickInfo* firstInfo(); 372*cdf0e10cSrcweir virtual TickInfo* nextInfo(); 373*cdf0e10cSrcweir 374*cdf0e10cSrcweir private: 375*cdf0e10cSrcweir ::std::vector< TickInfo >& m_rTickInfoVector; 376*cdf0e10cSrcweir ::std::vector< sal_Int32 > m_aValidIndices; 377*cdf0e10cSrcweir sal_Int32 m_nCurrentIndex; 378*cdf0e10cSrcweir }; 379*cdf0e10cSrcweir 380*cdf0e10cSrcweir MaxLabelTickIter::MaxLabelTickIter( ::std::vector< TickInfo >& rTickInfoVector 381*cdf0e10cSrcweir , sal_Int32 nLongestLabelIndex ) 382*cdf0e10cSrcweir : m_rTickInfoVector(rTickInfoVector) 383*cdf0e10cSrcweir , m_nCurrentIndex(0) 384*cdf0e10cSrcweir { 385*cdf0e10cSrcweir sal_Int32 nMaxIndex = m_rTickInfoVector.size()-1; 386*cdf0e10cSrcweir if( nLongestLabelIndex<0 || nLongestLabelIndex>=nMaxIndex-1 ) 387*cdf0e10cSrcweir nLongestLabelIndex = 0; 388*cdf0e10cSrcweir 389*cdf0e10cSrcweir if( nMaxIndex>=0 ) 390*cdf0e10cSrcweir m_aValidIndices.push_back(0); 391*cdf0e10cSrcweir if( nMaxIndex>=1 ) 392*cdf0e10cSrcweir m_aValidIndices.push_back(1); 393*cdf0e10cSrcweir if( nLongestLabelIndex>1 ) 394*cdf0e10cSrcweir m_aValidIndices.push_back(nLongestLabelIndex); 395*cdf0e10cSrcweir if( nMaxIndex > 2 ) 396*cdf0e10cSrcweir m_aValidIndices.push_back(nMaxIndex-1); 397*cdf0e10cSrcweir if( nMaxIndex > 1 ) 398*cdf0e10cSrcweir m_aValidIndices.push_back(nMaxIndex); 399*cdf0e10cSrcweir } 400*cdf0e10cSrcweir MaxLabelTickIter::~MaxLabelTickIter() 401*cdf0e10cSrcweir { 402*cdf0e10cSrcweir } 403*cdf0e10cSrcweir 404*cdf0e10cSrcweir TickInfo* MaxLabelTickIter::firstInfo() 405*cdf0e10cSrcweir { 406*cdf0e10cSrcweir m_nCurrentIndex = 0; 407*cdf0e10cSrcweir if( m_nCurrentIndex < static_cast<sal_Int32>(m_aValidIndices.size()) ) 408*cdf0e10cSrcweir return &m_rTickInfoVector[m_aValidIndices[m_nCurrentIndex]]; 409*cdf0e10cSrcweir return 0; 410*cdf0e10cSrcweir } 411*cdf0e10cSrcweir 412*cdf0e10cSrcweir TickInfo* MaxLabelTickIter::nextInfo() 413*cdf0e10cSrcweir { 414*cdf0e10cSrcweir m_nCurrentIndex++; 415*cdf0e10cSrcweir if( m_nCurrentIndex>=0 && m_nCurrentIndex<static_cast<sal_Int32>(m_aValidIndices.size()) ) 416*cdf0e10cSrcweir return &m_rTickInfoVector[m_aValidIndices[m_nCurrentIndex]]; 417*cdf0e10cSrcweir return 0; 418*cdf0e10cSrcweir } 419*cdf0e10cSrcweir 420*cdf0e10cSrcweir bool VCartesianAxis::isBreakOfLabelsAllowed( const AxisLabelProperties& rAxisLabelProperties 421*cdf0e10cSrcweir , bool bIsHorizontalAxis ) 422*cdf0e10cSrcweir { 423*cdf0e10cSrcweir if( m_aTextLabels.getLength() > 100 ) 424*cdf0e10cSrcweir return false; 425*cdf0e10cSrcweir if( !rAxisLabelProperties.bLineBreakAllowed ) 426*cdf0e10cSrcweir return false; 427*cdf0e10cSrcweir if( rAxisLabelProperties.bStackCharacters ) 428*cdf0e10cSrcweir return false; 429*cdf0e10cSrcweir //no break for value axis 430*cdf0e10cSrcweir if( !m_bUseTextLabels ) 431*cdf0e10cSrcweir return false; 432*cdf0e10cSrcweir if( !::rtl::math::approxEqual( rAxisLabelProperties.fRotationAngleDegree, 0.0 ) ) 433*cdf0e10cSrcweir return false; 434*cdf0e10cSrcweir //break only for horizontal axis 435*cdf0e10cSrcweir return bIsHorizontalAxis; 436*cdf0e10cSrcweir } 437*cdf0e10cSrcweir 438*cdf0e10cSrcweir bool VCartesianAxis::isAutoStaggeringOfLabelsAllowed( const AxisLabelProperties& rAxisLabelProperties 439*cdf0e10cSrcweir , bool bIsHorizontalAxis, bool bIsVerticalAxis ) 440*cdf0e10cSrcweir { 441*cdf0e10cSrcweir if( rAxisLabelProperties.eStaggering != STAGGER_AUTO ) 442*cdf0e10cSrcweir return false; 443*cdf0e10cSrcweir if( rAxisLabelProperties.bOverlapAllowed ) 444*cdf0e10cSrcweir return false; 445*cdf0e10cSrcweir if( rAxisLabelProperties.bLineBreakAllowed ) //auto line break or auto staggering, doing both automatisms they may conflict... 446*cdf0e10cSrcweir return false; 447*cdf0e10cSrcweir if( !::rtl::math::approxEqual( rAxisLabelProperties.fRotationAngleDegree, 0.0 ) ) 448*cdf0e10cSrcweir return false; 449*cdf0e10cSrcweir //automatic staggering only for horizontal axis with horizontal text 450*cdf0e10cSrcweir //or vertical axis with vertical text 451*cdf0e10cSrcweir if( bIsHorizontalAxis ) 452*cdf0e10cSrcweir return !rAxisLabelProperties.bStackCharacters; 453*cdf0e10cSrcweir if( bIsVerticalAxis ) 454*cdf0e10cSrcweir return rAxisLabelProperties.bStackCharacters; 455*cdf0e10cSrcweir return false; 456*cdf0e10cSrcweir } 457*cdf0e10cSrcweir 458*cdf0e10cSrcweir struct ComplexCategoryPlacement 459*cdf0e10cSrcweir { 460*cdf0e10cSrcweir rtl::OUString Text; 461*cdf0e10cSrcweir sal_Int32 Count; 462*cdf0e10cSrcweir double TickValue; 463*cdf0e10cSrcweir 464*cdf0e10cSrcweir ComplexCategoryPlacement( const rtl::OUString& rText, sal_Int32 nCount, double fTickValue ) 465*cdf0e10cSrcweir : Text(rText), Count(nCount), TickValue(fTickValue) 466*cdf0e10cSrcweir {} 467*cdf0e10cSrcweir }; 468*cdf0e10cSrcweir 469*cdf0e10cSrcweir void VCartesianAxis::createAllTickInfosFromComplexCategories( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos, bool bShiftedPosition ) 470*cdf0e10cSrcweir { 471*cdf0e10cSrcweir //no minor tickmarks will be generated! 472*cdf0e10cSrcweir //order is: inner labels first , outer labels last (that is different to all other TickIter cases) 473*cdf0e10cSrcweir if(!bShiftedPosition) 474*cdf0e10cSrcweir { 475*cdf0e10cSrcweir rAllTickInfos.clear(); 476*cdf0e10cSrcweir sal_Int32 nLevel=0; 477*cdf0e10cSrcweir sal_Int32 nLevelCount = m_aAxisProperties.m_pExplicitCategoriesProvider->getCategoryLevelCount(); 478*cdf0e10cSrcweir for( ; nLevel<nLevelCount; nLevel++ ) 479*cdf0e10cSrcweir { 480*cdf0e10cSrcweir ::std::vector< TickInfo > aTickInfoVector; 481*cdf0e10cSrcweir std::vector< ComplexCategory > aComplexCategories( m_aAxisProperties.m_pExplicitCategoriesProvider->getCategoriesByLevel( nLevel ) ); 482*cdf0e10cSrcweir sal_Int32 nCatIndex = 0; 483*cdf0e10cSrcweir std::vector< ComplexCategory >::const_iterator aIt(aComplexCategories.begin()); 484*cdf0e10cSrcweir std::vector< ComplexCategory >::const_iterator aEnd(aComplexCategories.end()); 485*cdf0e10cSrcweir for(;aIt!=aEnd;++aIt) 486*cdf0e10cSrcweir { 487*cdf0e10cSrcweir TickInfo aTickInfo(0); 488*cdf0e10cSrcweir ComplexCategory aCat(*aIt); 489*cdf0e10cSrcweir sal_Int32 nCount = aCat.Count; 490*cdf0e10cSrcweir if( nCatIndex + 1.0 + nCount >= m_aScale.Maximum ) 491*cdf0e10cSrcweir { 492*cdf0e10cSrcweir nCount = static_cast<sal_Int32>(m_aScale.Maximum - 1.0 - nCatIndex); 493*cdf0e10cSrcweir if( nCount <= 0 ) 494*cdf0e10cSrcweir nCount = 1; 495*cdf0e10cSrcweir } 496*cdf0e10cSrcweir aTickInfo.fScaledTickValue = nCatIndex + 1.0 + nCount/2.0; 497*cdf0e10cSrcweir aTickInfo.nFactorForLimitedTextWidth = nCount; 498*cdf0e10cSrcweir aTickInfo.aText = aCat.Text; 499*cdf0e10cSrcweir aTickInfoVector.push_back(aTickInfo); 500*cdf0e10cSrcweir nCatIndex += nCount; 501*cdf0e10cSrcweir if( nCatIndex + 1.0 >= m_aScale.Maximum ) 502*cdf0e10cSrcweir break; 503*cdf0e10cSrcweir } 504*cdf0e10cSrcweir rAllTickInfos.push_back(aTickInfoVector); 505*cdf0e10cSrcweir } 506*cdf0e10cSrcweir } 507*cdf0e10cSrcweir else //bShiftedPosition==false 508*cdf0e10cSrcweir { 509*cdf0e10cSrcweir rAllTickInfos.clear(); 510*cdf0e10cSrcweir sal_Int32 nLevel=0; 511*cdf0e10cSrcweir sal_Int32 nLevelCount = m_aAxisProperties.m_pExplicitCategoriesProvider->getCategoryLevelCount(); 512*cdf0e10cSrcweir for( ; nLevel<nLevelCount; nLevel++ ) 513*cdf0e10cSrcweir { 514*cdf0e10cSrcweir ::std::vector< TickInfo > aTickInfoVector; 515*cdf0e10cSrcweir std::vector< ComplexCategory > aComplexCategories( m_aAxisProperties.m_pExplicitCategoriesProvider->getCategoriesByLevel( nLevel ) ); 516*cdf0e10cSrcweir sal_Int32 nCatIndex = 0; 517*cdf0e10cSrcweir std::vector< ComplexCategory >::const_iterator aIt(aComplexCategories.begin()); 518*cdf0e10cSrcweir std::vector< ComplexCategory >::const_iterator aEnd(aComplexCategories.end()); 519*cdf0e10cSrcweir for(;aIt!=aEnd;++aIt) 520*cdf0e10cSrcweir { 521*cdf0e10cSrcweir TickInfo aTickInfo(0); 522*cdf0e10cSrcweir ComplexCategory aCat(*aIt); 523*cdf0e10cSrcweir aTickInfo.fScaledTickValue = nCatIndex + 1.0; 524*cdf0e10cSrcweir aTickInfoVector.push_back(aTickInfo); 525*cdf0e10cSrcweir nCatIndex += aCat.Count; 526*cdf0e10cSrcweir if( nCatIndex + 1.0 > m_aScale.Maximum ) 527*cdf0e10cSrcweir break; 528*cdf0e10cSrcweir } 529*cdf0e10cSrcweir //fill up with single ticks until maximum scale 530*cdf0e10cSrcweir while( nCatIndex + 1.0 < m_aScale.Maximum ) 531*cdf0e10cSrcweir { 532*cdf0e10cSrcweir TickInfo aTickInfo(0); 533*cdf0e10cSrcweir aTickInfo.fScaledTickValue = nCatIndex + 1.0; 534*cdf0e10cSrcweir aTickInfoVector.push_back(aTickInfo); 535*cdf0e10cSrcweir nCatIndex ++; 536*cdf0e10cSrcweir if( nLevel>0 ) 537*cdf0e10cSrcweir break; 538*cdf0e10cSrcweir } 539*cdf0e10cSrcweir //add an additional tick at the end 540*cdf0e10cSrcweir { 541*cdf0e10cSrcweir TickInfo aTickInfo(0); 542*cdf0e10cSrcweir aTickInfo.fScaledTickValue = m_aScale.Maximum; 543*cdf0e10cSrcweir aTickInfoVector.push_back(aTickInfo); 544*cdf0e10cSrcweir } 545*cdf0e10cSrcweir rAllTickInfos.push_back(aTickInfoVector); 546*cdf0e10cSrcweir } 547*cdf0e10cSrcweir } 548*cdf0e10cSrcweir } 549*cdf0e10cSrcweir 550*cdf0e10cSrcweir void VCartesianAxis::createAllTickInfos( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos ) 551*cdf0e10cSrcweir { 552*cdf0e10cSrcweir if( isComplexCategoryAxis() ) 553*cdf0e10cSrcweir createAllTickInfosFromComplexCategories( rAllTickInfos, false ); 554*cdf0e10cSrcweir else 555*cdf0e10cSrcweir VAxisBase::createAllTickInfos(rAllTickInfos); 556*cdf0e10cSrcweir } 557*cdf0e10cSrcweir 558*cdf0e10cSrcweir ::std::auto_ptr< TickIter > VCartesianAxis::createLabelTickIterator( sal_Int32 nTextLevel ) 559*cdf0e10cSrcweir { 560*cdf0e10cSrcweir if( nTextLevel>=0 && nTextLevel < static_cast< sal_Int32 >(m_aAllTickInfos.size()) ) 561*cdf0e10cSrcweir return ::std::auto_ptr< TickIter >( new PureTickIter( m_aAllTickInfos[nTextLevel] ) ); 562*cdf0e10cSrcweir return ::std::auto_ptr< TickIter >(); 563*cdf0e10cSrcweir } 564*cdf0e10cSrcweir ::std::auto_ptr< TickIter > VCartesianAxis::createMaximumLabelTickIterator( sal_Int32 nTextLevel ) 565*cdf0e10cSrcweir { 566*cdf0e10cSrcweir if( isComplexCategoryAxis() || isDateAxis() ) 567*cdf0e10cSrcweir { 568*cdf0e10cSrcweir return createLabelTickIterator( nTextLevel ); //mmmm maybe todo: create less than all texts here 569*cdf0e10cSrcweir } 570*cdf0e10cSrcweir else 571*cdf0e10cSrcweir { 572*cdf0e10cSrcweir if(nTextLevel==0) 573*cdf0e10cSrcweir { 574*cdf0e10cSrcweir if( !m_aAllTickInfos.empty() ) 575*cdf0e10cSrcweir { 576*cdf0e10cSrcweir sal_Int32 nLongestLabelIndex = m_bUseTextLabels ? this->getIndexOfLongestLabel( m_aTextLabels ) : 0; 577*cdf0e10cSrcweir return ::std::auto_ptr< TickIter >( new MaxLabelTickIter( m_aAllTickInfos[0], nLongestLabelIndex ) ); 578*cdf0e10cSrcweir } 579*cdf0e10cSrcweir } 580*cdf0e10cSrcweir } 581*cdf0e10cSrcweir return ::std::auto_ptr< TickIter >(); 582*cdf0e10cSrcweir } 583*cdf0e10cSrcweir 584*cdf0e10cSrcweir sal_Int32 VCartesianAxis::getTextLevelCount() const 585*cdf0e10cSrcweir { 586*cdf0e10cSrcweir sal_Int32 nTextLevelCount = 1; 587*cdf0e10cSrcweir if( isComplexCategoryAxis() ) 588*cdf0e10cSrcweir nTextLevelCount = m_aAxisProperties.m_pExplicitCategoriesProvider->getCategoryLevelCount(); 589*cdf0e10cSrcweir return nTextLevelCount; 590*cdf0e10cSrcweir } 591*cdf0e10cSrcweir 592*cdf0e10cSrcweir bool VCartesianAxis::createTextShapes( 593*cdf0e10cSrcweir const Reference< drawing::XShapes >& xTarget 594*cdf0e10cSrcweir , TickIter& rTickIter 595*cdf0e10cSrcweir , AxisLabelProperties& rAxisLabelProperties 596*cdf0e10cSrcweir , TickFactory_2D* pTickFactory 597*cdf0e10cSrcweir , sal_Int32 nScreenDistanceBetweenTicks ) 598*cdf0e10cSrcweir { 599*cdf0e10cSrcweir //returns true if the text shapes have been created succesfully 600*cdf0e10cSrcweir //otherwise false - in this case the AxisLabelProperties have changed 601*cdf0e10cSrcweir //and contain new instructions for the next try for text shape creation 602*cdf0e10cSrcweir 603*cdf0e10cSrcweir Reference< XScaling > xInverseScaling( NULL ); 604*cdf0e10cSrcweir if( m_aScale.Scaling.is() ) 605*cdf0e10cSrcweir xInverseScaling = m_aScale.Scaling->getInverseScaling(); 606*cdf0e10cSrcweir 607*cdf0e10cSrcweir FixedNumberFormatter aFixedNumberFormatter( 608*cdf0e10cSrcweir m_xNumberFormatsSupplier, rAxisLabelProperties.nNumberFormatKey ); 609*cdf0e10cSrcweir 610*cdf0e10cSrcweir const bool bIsHorizontalAxis = pTickFactory->isHorizontalAxis(); 611*cdf0e10cSrcweir const bool bIsVerticalAxis = pTickFactory->isVerticalAxis(); 612*cdf0e10cSrcweir bool bIsStaggered = rAxisLabelProperties.getIsStaggered(); 613*cdf0e10cSrcweir B2DVector aTextToTickDistance( pTickFactory->getDistanceAxisTickToText( m_aAxisProperties, true ) ); 614*cdf0e10cSrcweir sal_Int32 nLimitedSpaceForText = -1; 615*cdf0e10cSrcweir if( isBreakOfLabelsAllowed( rAxisLabelProperties, bIsHorizontalAxis ) ) 616*cdf0e10cSrcweir { 617*cdf0e10cSrcweir nLimitedSpaceForText = nScreenDistanceBetweenTicks; 618*cdf0e10cSrcweir if( bIsStaggered ) 619*cdf0e10cSrcweir nLimitedSpaceForText *= 2; 620*cdf0e10cSrcweir 621*cdf0e10cSrcweir if( nLimitedSpaceForText > 0 ) 622*cdf0e10cSrcweir { //reduce space for a small amount to have a visible distance between the labels: 623*cdf0e10cSrcweir sal_Int32 nReduce = (nLimitedSpaceForText*5)/100; 624*cdf0e10cSrcweir if(!nReduce) 625*cdf0e10cSrcweir nReduce = 1; 626*cdf0e10cSrcweir nLimitedSpaceForText -= nReduce; 627*cdf0e10cSrcweir } 628*cdf0e10cSrcweir } 629*cdf0e10cSrcweir 630*cdf0e10cSrcweir std::vector< ComplexCategoryPlacement > aComplexCategoryPlacements; 631*cdf0e10cSrcweir uno::Sequence< rtl::OUString >* pCategories = 0; 632*cdf0e10cSrcweir if( m_bUseTextLabels && !m_aAxisProperties.m_bComplexCategories ) 633*cdf0e10cSrcweir pCategories = &m_aTextLabels; 634*cdf0e10cSrcweir 635*cdf0e10cSrcweir TickInfo* pPreviousVisibleTickInfo = NULL; 636*cdf0e10cSrcweir TickInfo* pPREPreviousVisibleTickInfo = NULL; 637*cdf0e10cSrcweir TickInfo* pLastVisibleNeighbourTickInfo = NULL; 638*cdf0e10cSrcweir 639*cdf0e10cSrcweir //------------------------------------------------ 640*cdf0e10cSrcweir //prepare properties for multipropertyset-interface of shape 641*cdf0e10cSrcweir tNameSequence aPropNames; 642*cdf0e10cSrcweir tAnySequence aPropValues; 643*cdf0e10cSrcweir 644*cdf0e10cSrcweir bool bLimitedHeight = fabs(aTextToTickDistance.getX()) > fabs(aTextToTickDistance.getY()); 645*cdf0e10cSrcweir Reference< beans::XPropertySet > xProps( m_aAxisProperties.m_xAxisModel, uno::UNO_QUERY ); 646*cdf0e10cSrcweir PropertyMapper::getTextLabelMultiPropertyLists( xProps, aPropNames, aPropValues, false 647*cdf0e10cSrcweir , nLimitedSpaceForText, bLimitedHeight ); 648*cdf0e10cSrcweir LabelPositionHelper::doDynamicFontResize( aPropValues, aPropNames, xProps 649*cdf0e10cSrcweir , m_aAxisLabelProperties.m_aFontReferenceSize ); 650*cdf0e10cSrcweir LabelPositionHelper::changeTextAdjustment( aPropValues, aPropNames, m_aAxisProperties.m_aLabelAlignment ); 651*cdf0e10cSrcweir 652*cdf0e10cSrcweir uno::Any* pColorAny = PropertyMapper::getValuePointer(aPropValues,aPropNames,C2U("CharColor")); 653*cdf0e10cSrcweir sal_Int32 nColor = Color( COL_AUTO ).GetColor(); 654*cdf0e10cSrcweir if(pColorAny) 655*cdf0e10cSrcweir *pColorAny >>= nColor; 656*cdf0e10cSrcweir 657*cdf0e10cSrcweir uno::Any* pLimitedSpaceAny = PropertyMapper::getValuePointerForLimitedSpace(aPropValues,aPropNames,bLimitedHeight); 658*cdf0e10cSrcweir //------------------------------------------------ 659*cdf0e10cSrcweir 660*cdf0e10cSrcweir sal_Int32 nTick = 0; 661*cdf0e10cSrcweir for( TickInfo* pTickInfo = rTickIter.firstInfo() 662*cdf0e10cSrcweir ; pTickInfo 663*cdf0e10cSrcweir ; pTickInfo = rTickIter.nextInfo(), nTick++ ) 664*cdf0e10cSrcweir { 665*cdf0e10cSrcweir pLastVisibleNeighbourTickInfo = bIsStaggered ? 666*cdf0e10cSrcweir pPREPreviousVisibleTickInfo : pPreviousVisibleTickInfo; 667*cdf0e10cSrcweir 668*cdf0e10cSrcweir //don't create labels which does not fit into the rhythm 669*cdf0e10cSrcweir if( nTick%rAxisLabelProperties.nRhythm != 0) 670*cdf0e10cSrcweir continue; 671*cdf0e10cSrcweir 672*cdf0e10cSrcweir //don't create labels for invisible ticks 673*cdf0e10cSrcweir if( !pTickInfo->bPaintIt ) 674*cdf0e10cSrcweir continue; 675*cdf0e10cSrcweir 676*cdf0e10cSrcweir //if NO OVERLAP -> don't create labels where the tick overlaps 677*cdf0e10cSrcweir //with the text of the last neighbour tickmark 678*cdf0e10cSrcweir if( pLastVisibleNeighbourTickInfo && !rAxisLabelProperties.bOverlapAllowed ) 679*cdf0e10cSrcweir { 680*cdf0e10cSrcweir if( lcl_doesShapeOverlapWithTickmark( pLastVisibleNeighbourTickInfo->xTextShape 681*cdf0e10cSrcweir , rAxisLabelProperties.fRotationAngleDegree 682*cdf0e10cSrcweir , pTickInfo->aTickScreenPosition 683*cdf0e10cSrcweir , bIsHorizontalAxis, bIsVerticalAxis ) ) 684*cdf0e10cSrcweir { 685*cdf0e10cSrcweir bool bOverlapAlsoAfterSwitchingOnAutoStaggering = true; 686*cdf0e10cSrcweir if( !bIsStaggered && isAutoStaggeringOfLabelsAllowed( rAxisLabelProperties, bIsHorizontalAxis, bIsVerticalAxis ) ) 687*cdf0e10cSrcweir { 688*cdf0e10cSrcweir bIsStaggered = true; 689*cdf0e10cSrcweir rAxisLabelProperties.eStaggering = STAGGER_EVEN; 690*cdf0e10cSrcweir pLastVisibleNeighbourTickInfo = pPREPreviousVisibleTickInfo; 691*cdf0e10cSrcweir if( !pLastVisibleNeighbourTickInfo || 692*cdf0e10cSrcweir !lcl_doesShapeOverlapWithTickmark( pLastVisibleNeighbourTickInfo->xTextShape 693*cdf0e10cSrcweir , rAxisLabelProperties.fRotationAngleDegree 694*cdf0e10cSrcweir , pTickInfo->aTickScreenPosition 695*cdf0e10cSrcweir , bIsHorizontalAxis, bIsVerticalAxis ) ) 696*cdf0e10cSrcweir bOverlapAlsoAfterSwitchingOnAutoStaggering = false; 697*cdf0e10cSrcweir } 698*cdf0e10cSrcweir if( bOverlapAlsoAfterSwitchingOnAutoStaggering ) 699*cdf0e10cSrcweir { 700*cdf0e10cSrcweir if( rAxisLabelProperties.bRhythmIsFix ) 701*cdf0e10cSrcweir continue; 702*cdf0e10cSrcweir rAxisLabelProperties.nRhythm++; 703*cdf0e10cSrcweir removeShapesAtWrongRhythm( rTickIter, rAxisLabelProperties.nRhythm, nTick, xTarget ); 704*cdf0e10cSrcweir return false; 705*cdf0e10cSrcweir } 706*cdf0e10cSrcweir } 707*cdf0e10cSrcweir } 708*cdf0e10cSrcweir 709*cdf0e10cSrcweir //xxxxx pTickInfo->updateUnscaledValue( xInverseScaling ); 710*cdf0e10cSrcweir 711*cdf0e10cSrcweir bool bHasExtraColor=false; 712*cdf0e10cSrcweir sal_Int32 nExtraColor=0; 713*cdf0e10cSrcweir 714*cdf0e10cSrcweir rtl::OUString aLabel; 715*cdf0e10cSrcweir if(pCategories) 716*cdf0e10cSrcweir { 717*cdf0e10cSrcweir sal_Int32 nIndex = static_cast< sal_Int32 >(pTickInfo->getUnscaledTickValue()) - 1; //first category (index 0) matches with real number 1.0 718*cdf0e10cSrcweir if( nIndex>=0 && nIndex<pCategories->getLength() ) 719*cdf0e10cSrcweir aLabel = (*pCategories)[nIndex]; 720*cdf0e10cSrcweir } 721*cdf0e10cSrcweir else if( m_aAxisProperties.m_bComplexCategories ) 722*cdf0e10cSrcweir { 723*cdf0e10cSrcweir aLabel = pTickInfo->aText; 724*cdf0e10cSrcweir } 725*cdf0e10cSrcweir else 726*cdf0e10cSrcweir aLabel = aFixedNumberFormatter.getFormattedString( pTickInfo->getUnscaledTickValue(), nExtraColor, bHasExtraColor ); 727*cdf0e10cSrcweir 728*cdf0e10cSrcweir if(pColorAny) 729*cdf0e10cSrcweir *pColorAny = uno::makeAny(bHasExtraColor?nExtraColor:nColor); 730*cdf0e10cSrcweir if(pLimitedSpaceAny) 731*cdf0e10cSrcweir *pLimitedSpaceAny = uno::makeAny(sal_Int32(nLimitedSpaceForText*pTickInfo->nFactorForLimitedTextWidth)); 732*cdf0e10cSrcweir 733*cdf0e10cSrcweir B2DVector aTickScreenPos2D( pTickInfo->aTickScreenPosition ); 734*cdf0e10cSrcweir aTickScreenPos2D += aTextToTickDistance; 735*cdf0e10cSrcweir awt::Point aAnchorScreenPosition2D( 736*cdf0e10cSrcweir static_cast<sal_Int32>(aTickScreenPos2D.getX()) 737*cdf0e10cSrcweir ,static_cast<sal_Int32>(aTickScreenPos2D.getY())); 738*cdf0e10cSrcweir 739*cdf0e10cSrcweir //create single label 740*cdf0e10cSrcweir if(!pTickInfo->xTextShape.is()) 741*cdf0e10cSrcweir pTickInfo->xTextShape = createSingleLabel( m_xShapeFactory, xTarget 742*cdf0e10cSrcweir , aAnchorScreenPosition2D, aLabel 743*cdf0e10cSrcweir , rAxisLabelProperties, m_aAxisProperties 744*cdf0e10cSrcweir , aPropNames, aPropValues ); 745*cdf0e10cSrcweir if(!pTickInfo->xTextShape.is()) 746*cdf0e10cSrcweir continue; 747*cdf0e10cSrcweir 748*cdf0e10cSrcweir recordMaximumTextSize( pTickInfo->xTextShape, rAxisLabelProperties.fRotationAngleDegree ); 749*cdf0e10cSrcweir 750*cdf0e10cSrcweir //better rotate if single words are broken apart 751*cdf0e10cSrcweir if( nLimitedSpaceForText>0 && !rAxisLabelProperties.bOverlapAllowed 752*cdf0e10cSrcweir && ::rtl::math::approxEqual( rAxisLabelProperties.fRotationAngleDegree, 0.0 ) 753*cdf0e10cSrcweir && m_aAxisProperties.m_bComplexCategories 754*cdf0e10cSrcweir && lcl_hasWordBreak( pTickInfo->xTextShape ) ) 755*cdf0e10cSrcweir { 756*cdf0e10cSrcweir rAxisLabelProperties.fRotationAngleDegree = 90; 757*cdf0e10cSrcweir rAxisLabelProperties.bLineBreakAllowed = false; 758*cdf0e10cSrcweir m_aAxisLabelProperties.fRotationAngleDegree = rAxisLabelProperties.fRotationAngleDegree; 759*cdf0e10cSrcweir removeTextShapesFromTicks(); 760*cdf0e10cSrcweir return false; 761*cdf0e10cSrcweir } 762*cdf0e10cSrcweir 763*cdf0e10cSrcweir //if NO OVERLAP -> remove overlapping shapes 764*cdf0e10cSrcweir if( pLastVisibleNeighbourTickInfo && !rAxisLabelProperties.bOverlapAllowed ) 765*cdf0e10cSrcweir { 766*cdf0e10cSrcweir if( doesOverlap( pLastVisibleNeighbourTickInfo->xTextShape, pTickInfo->xTextShape, rAxisLabelProperties.fRotationAngleDegree ) ) 767*cdf0e10cSrcweir { 768*cdf0e10cSrcweir bool bOverlapAlsoAfterSwitchingOnAutoStaggering = true; 769*cdf0e10cSrcweir if( !bIsStaggered && isAutoStaggeringOfLabelsAllowed( rAxisLabelProperties, bIsHorizontalAxis, bIsVerticalAxis ) ) 770*cdf0e10cSrcweir { 771*cdf0e10cSrcweir bIsStaggered = true; 772*cdf0e10cSrcweir rAxisLabelProperties.eStaggering = STAGGER_EVEN; 773*cdf0e10cSrcweir pLastVisibleNeighbourTickInfo = pPREPreviousVisibleTickInfo; 774*cdf0e10cSrcweir if( !pLastVisibleNeighbourTickInfo || 775*cdf0e10cSrcweir !lcl_doesShapeOverlapWithTickmark( pLastVisibleNeighbourTickInfo->xTextShape 776*cdf0e10cSrcweir , rAxisLabelProperties.fRotationAngleDegree 777*cdf0e10cSrcweir , pTickInfo->aTickScreenPosition 778*cdf0e10cSrcweir , bIsHorizontalAxis, bIsVerticalAxis ) ) 779*cdf0e10cSrcweir bOverlapAlsoAfterSwitchingOnAutoStaggering = false; 780*cdf0e10cSrcweir } 781*cdf0e10cSrcweir if( bOverlapAlsoAfterSwitchingOnAutoStaggering ) 782*cdf0e10cSrcweir { 783*cdf0e10cSrcweir if( rAxisLabelProperties.bRhythmIsFix ) 784*cdf0e10cSrcweir { 785*cdf0e10cSrcweir xTarget->remove(pTickInfo->xTextShape); 786*cdf0e10cSrcweir pTickInfo->xTextShape = NULL; 787*cdf0e10cSrcweir continue; 788*cdf0e10cSrcweir } 789*cdf0e10cSrcweir rAxisLabelProperties.nRhythm++; 790*cdf0e10cSrcweir removeShapesAtWrongRhythm( rTickIter, rAxisLabelProperties.nRhythm, nTick, xTarget ); 791*cdf0e10cSrcweir return false; 792*cdf0e10cSrcweir } 793*cdf0e10cSrcweir } 794*cdf0e10cSrcweir } 795*cdf0e10cSrcweir 796*cdf0e10cSrcweir pPREPreviousVisibleTickInfo = pPreviousVisibleTickInfo; 797*cdf0e10cSrcweir pPreviousVisibleTickInfo = pTickInfo; 798*cdf0e10cSrcweir } 799*cdf0e10cSrcweir return true; 800*cdf0e10cSrcweir } 801*cdf0e10cSrcweir 802*cdf0e10cSrcweir drawing::PointSequenceSequence lcl_makePointSequence( B2DVector& rStart, B2DVector& rEnd ) 803*cdf0e10cSrcweir { 804*cdf0e10cSrcweir drawing::PointSequenceSequence aPoints(1); 805*cdf0e10cSrcweir aPoints[0].realloc(2); 806*cdf0e10cSrcweir aPoints[0][0].X = static_cast<sal_Int32>(rStart.getX()); 807*cdf0e10cSrcweir aPoints[0][0].Y = static_cast<sal_Int32>(rStart.getY()); 808*cdf0e10cSrcweir aPoints[0][1].X = static_cast<sal_Int32>(rEnd.getX()); 809*cdf0e10cSrcweir aPoints[0][1].Y = static_cast<sal_Int32>(rEnd.getY()); 810*cdf0e10cSrcweir return aPoints; 811*cdf0e10cSrcweir } 812*cdf0e10cSrcweir 813*cdf0e10cSrcweir double VCartesianAxis::getLogicValueWhereMainLineCrossesOtherAxis() const 814*cdf0e10cSrcweir { 815*cdf0e10cSrcweir double fMin = (m_nDimensionIndex==1) ? m_pPosHelper->getLogicMinX() : m_pPosHelper->getLogicMinY(); 816*cdf0e10cSrcweir double fMax = (m_nDimensionIndex==1) ? m_pPosHelper->getLogicMaxX() : m_pPosHelper->getLogicMaxY(); 817*cdf0e10cSrcweir 818*cdf0e10cSrcweir double fCrossesOtherAxis; 819*cdf0e10cSrcweir if(m_aAxisProperties.m_pfMainLinePositionAtOtherAxis) 820*cdf0e10cSrcweir fCrossesOtherAxis = *m_aAxisProperties.m_pfMainLinePositionAtOtherAxis; 821*cdf0e10cSrcweir else 822*cdf0e10cSrcweir { 823*cdf0e10cSrcweir if( ::com::sun::star::chart::ChartAxisPosition_END == m_aAxisProperties.m_eCrossoverType ) 824*cdf0e10cSrcweir fCrossesOtherAxis = fMax; 825*cdf0e10cSrcweir else 826*cdf0e10cSrcweir fCrossesOtherAxis = fMin; 827*cdf0e10cSrcweir } 828*cdf0e10cSrcweir return fCrossesOtherAxis; 829*cdf0e10cSrcweir } 830*cdf0e10cSrcweir 831*cdf0e10cSrcweir double VCartesianAxis::getLogicValueWhereLabelLineCrossesOtherAxis() const 832*cdf0e10cSrcweir { 833*cdf0e10cSrcweir double fMin = (m_nDimensionIndex==1) ? m_pPosHelper->getLogicMinX() : m_pPosHelper->getLogicMinY(); 834*cdf0e10cSrcweir double fMax = (m_nDimensionIndex==1) ? m_pPosHelper->getLogicMaxX() : m_pPosHelper->getLogicMaxY(); 835*cdf0e10cSrcweir 836*cdf0e10cSrcweir double fCrossesOtherAxis; 837*cdf0e10cSrcweir if( ::com::sun::star::chart::ChartAxisLabelPosition_OUTSIDE_START == m_aAxisProperties.m_eLabelPos ) 838*cdf0e10cSrcweir fCrossesOtherAxis = fMin; 839*cdf0e10cSrcweir else if( ::com::sun::star::chart::ChartAxisLabelPosition_OUTSIDE_END == m_aAxisProperties.m_eLabelPos ) 840*cdf0e10cSrcweir fCrossesOtherAxis = fMax; 841*cdf0e10cSrcweir else 842*cdf0e10cSrcweir fCrossesOtherAxis = getLogicValueWhereMainLineCrossesOtherAxis(); 843*cdf0e10cSrcweir return fCrossesOtherAxis; 844*cdf0e10cSrcweir } 845*cdf0e10cSrcweir 846*cdf0e10cSrcweir bool VCartesianAxis::getLogicValueWhereExtraLineCrossesOtherAxis( double& fCrossesOtherAxis ) const 847*cdf0e10cSrcweir { 848*cdf0e10cSrcweir if( !m_aAxisProperties.m_pfExrtaLinePositionAtOtherAxis ) 849*cdf0e10cSrcweir return false; 850*cdf0e10cSrcweir double fMin = (m_nDimensionIndex==1) ? m_pPosHelper->getLogicMinX() : m_pPosHelper->getLogicMinY(); 851*cdf0e10cSrcweir double fMax = (m_nDimensionIndex==1) ? m_pPosHelper->getLogicMaxX() : m_pPosHelper->getLogicMaxY(); 852*cdf0e10cSrcweir if( *m_aAxisProperties.m_pfExrtaLinePositionAtOtherAxis <= fMin 853*cdf0e10cSrcweir || *m_aAxisProperties.m_pfExrtaLinePositionAtOtherAxis >= fMax ) 854*cdf0e10cSrcweir return false; 855*cdf0e10cSrcweir fCrossesOtherAxis = *m_aAxisProperties.m_pfExrtaLinePositionAtOtherAxis; 856*cdf0e10cSrcweir return true; 857*cdf0e10cSrcweir } 858*cdf0e10cSrcweir 859*cdf0e10cSrcweir B2DVector VCartesianAxis::getScreenPosition( double fLogicX, double fLogicY, double fLogicZ ) const 860*cdf0e10cSrcweir { 861*cdf0e10cSrcweir B2DVector aRet(0,0); 862*cdf0e10cSrcweir 863*cdf0e10cSrcweir if( m_pPosHelper ) 864*cdf0e10cSrcweir { 865*cdf0e10cSrcweir drawing::Position3D aScenePos = m_pPosHelper->transformLogicToScene( fLogicX, fLogicY, fLogicZ, true ); 866*cdf0e10cSrcweir if(3==m_nDimension) 867*cdf0e10cSrcweir { 868*cdf0e10cSrcweir if( m_xLogicTarget.is() && m_pPosHelper && m_pShapeFactory ) 869*cdf0e10cSrcweir { 870*cdf0e10cSrcweir tPropertyNameMap aDummyPropertyNameMap; 871*cdf0e10cSrcweir Reference< drawing::XShape > xShape3DAnchor = m_pShapeFactory->createCube( m_xLogicTarget 872*cdf0e10cSrcweir , aScenePos,drawing::Direction3D(1,1,1), 0, 0, aDummyPropertyNameMap); 873*cdf0e10cSrcweir awt::Point a2DPos = xShape3DAnchor->getPosition(); //get 2D position from xShape3DAnchor 874*cdf0e10cSrcweir m_xLogicTarget->remove(xShape3DAnchor); 875*cdf0e10cSrcweir aRet.setX( a2DPos.X ); 876*cdf0e10cSrcweir aRet.setY( a2DPos.Y ); 877*cdf0e10cSrcweir } 878*cdf0e10cSrcweir else 879*cdf0e10cSrcweir { 880*cdf0e10cSrcweir DBG_ERROR("cannot calculate scrren position in VCartesianAxis::getScreenPosition"); 881*cdf0e10cSrcweir } 882*cdf0e10cSrcweir } 883*cdf0e10cSrcweir else 884*cdf0e10cSrcweir { 885*cdf0e10cSrcweir aRet.setX( aScenePos.PositionX ); 886*cdf0e10cSrcweir aRet.setY( aScenePos.PositionY ); 887*cdf0e10cSrcweir } 888*cdf0e10cSrcweir } 889*cdf0e10cSrcweir 890*cdf0e10cSrcweir return aRet; 891*cdf0e10cSrcweir } 892*cdf0e10cSrcweir 893*cdf0e10cSrcweir VCartesianAxis::ScreenPosAndLogicPos VCartesianAxis::getScreenPosAndLogicPos( double fLogicX_, double fLogicY_, double fLogicZ_ ) const 894*cdf0e10cSrcweir { 895*cdf0e10cSrcweir ScreenPosAndLogicPos aRet; 896*cdf0e10cSrcweir aRet.fLogicX = fLogicX_; 897*cdf0e10cSrcweir aRet.fLogicY = fLogicY_; 898*cdf0e10cSrcweir aRet.fLogicZ = fLogicZ_; 899*cdf0e10cSrcweir aRet.aScreenPos = getScreenPosition( fLogicX_, fLogicY_, fLogicZ_ ); 900*cdf0e10cSrcweir return aRet; 901*cdf0e10cSrcweir } 902*cdf0e10cSrcweir 903*cdf0e10cSrcweir typedef ::std::vector< VCartesianAxis::ScreenPosAndLogicPos > tScreenPosAndLogicPosList; 904*cdf0e10cSrcweir struct lcl_LessXPos : ::std::binary_function< VCartesianAxis::ScreenPosAndLogicPos, VCartesianAxis::ScreenPosAndLogicPos, bool > 905*cdf0e10cSrcweir { 906*cdf0e10cSrcweir inline bool operator() ( const VCartesianAxis::ScreenPosAndLogicPos& rPos1, const VCartesianAxis::ScreenPosAndLogicPos& rPos2 ) 907*cdf0e10cSrcweir { 908*cdf0e10cSrcweir return ( rPos1.aScreenPos.getX() < rPos2.aScreenPos.getX() ); 909*cdf0e10cSrcweir } 910*cdf0e10cSrcweir }; 911*cdf0e10cSrcweir 912*cdf0e10cSrcweir struct lcl_GreaterYPos : ::std::binary_function< VCartesianAxis::ScreenPosAndLogicPos, VCartesianAxis::ScreenPosAndLogicPos, bool > 913*cdf0e10cSrcweir { 914*cdf0e10cSrcweir inline bool operator() ( const VCartesianAxis::ScreenPosAndLogicPos& rPos1, const VCartesianAxis::ScreenPosAndLogicPos& rPos2 ) 915*cdf0e10cSrcweir { 916*cdf0e10cSrcweir return ( rPos1.aScreenPos.getY() > rPos2.aScreenPos.getY() ); 917*cdf0e10cSrcweir } 918*cdf0e10cSrcweir }; 919*cdf0e10cSrcweir 920*cdf0e10cSrcweir void VCartesianAxis::get2DAxisMainLine( B2DVector& rStart, B2DVector& rEnd, double fCrossesOtherAxis ) 921*cdf0e10cSrcweir { 922*cdf0e10cSrcweir //m_aAxisProperties might get updated and changed here because 923*cdf0e10cSrcweir // the label alignmant and inner direction sign depends exactly of the choice of the axis line position which is made here in this method 924*cdf0e10cSrcweir 925*cdf0e10cSrcweir double fMinX = m_pPosHelper->getLogicMinX(); 926*cdf0e10cSrcweir double fMinY = m_pPosHelper->getLogicMinY(); 927*cdf0e10cSrcweir double fMinZ = m_pPosHelper->getLogicMinZ(); 928*cdf0e10cSrcweir double fMaxX = m_pPosHelper->getLogicMaxX(); 929*cdf0e10cSrcweir double fMaxY = m_pPosHelper->getLogicMaxY(); 930*cdf0e10cSrcweir double fMaxZ = m_pPosHelper->getLogicMaxZ(); 931*cdf0e10cSrcweir 932*cdf0e10cSrcweir double fXStart = fMinX; 933*cdf0e10cSrcweir double fYStart = fMinY; 934*cdf0e10cSrcweir double fZStart = fMinZ; 935*cdf0e10cSrcweir double fXEnd = fXStart; 936*cdf0e10cSrcweir double fYEnd = fYStart; 937*cdf0e10cSrcweir double fZEnd = fZStart; 938*cdf0e10cSrcweir 939*cdf0e10cSrcweir double fXOnXPlane = fMinX; 940*cdf0e10cSrcweir double fXOther = fMaxX; 941*cdf0e10cSrcweir int nDifferentValue = !m_pPosHelper->isMathematicalOrientationX() ? -1 : 1; 942*cdf0e10cSrcweir if( !m_pPosHelper->isSwapXAndY() ) 943*cdf0e10cSrcweir nDifferentValue *= (CuboidPlanePosition_Left != m_eLeftWallPos) ? -1 : 1; 944*cdf0e10cSrcweir else 945*cdf0e10cSrcweir nDifferentValue *= (CuboidPlanePosition_Bottom != m_eBottomPos) ? -1 : 1; 946*cdf0e10cSrcweir if( nDifferentValue<0 ) 947*cdf0e10cSrcweir { 948*cdf0e10cSrcweir fXOnXPlane = fMaxX; 949*cdf0e10cSrcweir fXOther = fMinX; 950*cdf0e10cSrcweir } 951*cdf0e10cSrcweir 952*cdf0e10cSrcweir double fYOnYPlane = fMinY; 953*cdf0e10cSrcweir double fYOther = fMaxY; 954*cdf0e10cSrcweir nDifferentValue = !m_pPosHelper->isMathematicalOrientationY() ? -1 : 1; 955*cdf0e10cSrcweir if( !m_pPosHelper->isSwapXAndY() ) 956*cdf0e10cSrcweir nDifferentValue *= (CuboidPlanePosition_Bottom != m_eBottomPos) ? -1 : 1; 957*cdf0e10cSrcweir else 958*cdf0e10cSrcweir nDifferentValue *= (CuboidPlanePosition_Left != m_eLeftWallPos) ? -1 : 1; 959*cdf0e10cSrcweir if( nDifferentValue<0 ) 960*cdf0e10cSrcweir { 961*cdf0e10cSrcweir fYOnYPlane = fMaxY; 962*cdf0e10cSrcweir fYOther = fMinY; 963*cdf0e10cSrcweir } 964*cdf0e10cSrcweir 965*cdf0e10cSrcweir double fZOnZPlane = fMaxZ; 966*cdf0e10cSrcweir double fZOther = fMinZ; 967*cdf0e10cSrcweir nDifferentValue = !m_pPosHelper->isMathematicalOrientationZ() ? -1 : 1; 968*cdf0e10cSrcweir nDifferentValue *= (CuboidPlanePosition_Back != m_eBackWallPos) ? -1 : 1; 969*cdf0e10cSrcweir if( nDifferentValue<0 ) 970*cdf0e10cSrcweir { 971*cdf0e10cSrcweir fZOnZPlane = fMinZ; 972*cdf0e10cSrcweir fZOther = fMaxZ; 973*cdf0e10cSrcweir } 974*cdf0e10cSrcweir 975*cdf0e10cSrcweir if( 0==m_nDimensionIndex ) //x-axis 976*cdf0e10cSrcweir { 977*cdf0e10cSrcweir if( fCrossesOtherAxis < fMinY ) 978*cdf0e10cSrcweir fCrossesOtherAxis = fMinY; 979*cdf0e10cSrcweir else if( fCrossesOtherAxis > fMaxY ) 980*cdf0e10cSrcweir fCrossesOtherAxis = fMaxY; 981*cdf0e10cSrcweir 982*cdf0e10cSrcweir fYStart = fYEnd = fCrossesOtherAxis; 983*cdf0e10cSrcweir fXEnd=m_pPosHelper->getLogicMaxX(); 984*cdf0e10cSrcweir 985*cdf0e10cSrcweir if(3==m_nDimension) 986*cdf0e10cSrcweir { 987*cdf0e10cSrcweir if( AxisHelper::isAxisPositioningEnabled() ) 988*cdf0e10cSrcweir { 989*cdf0e10cSrcweir if( ::rtl::math::approxEqual( fYOther, fYStart) ) 990*cdf0e10cSrcweir fZStart = fZEnd = fZOnZPlane; 991*cdf0e10cSrcweir else 992*cdf0e10cSrcweir fZStart = fZEnd = fZOther; 993*cdf0e10cSrcweir } 994*cdf0e10cSrcweir else 995*cdf0e10cSrcweir { 996*cdf0e10cSrcweir rStart = getScreenPosition( fXStart, fYStart, fZStart ); 997*cdf0e10cSrcweir rEnd = getScreenPosition( fXEnd, fYEnd, fZEnd ); 998*cdf0e10cSrcweir 999*cdf0e10cSrcweir double fDeltaX = rEnd.getX() - rStart.getX(); 1000*cdf0e10cSrcweir double fDeltaY = rEnd.getY() - rStart.getY(); 1001*cdf0e10cSrcweir 1002*cdf0e10cSrcweir //only those points are candidates which are lying on exactly one wall as these are outer edges 1003*cdf0e10cSrcweir tScreenPosAndLogicPosList aPosList; 1004*cdf0e10cSrcweir aPosList.push_back( getScreenPosAndLogicPos( fMinX, fYOnYPlane, fZOther ) ); 1005*cdf0e10cSrcweir aPosList.push_back( getScreenPosAndLogicPos( fMinX, fYOther, fZOnZPlane ) ); 1006*cdf0e10cSrcweir 1007*cdf0e10cSrcweir if( fabs(fDeltaY) > fabs(fDeltaX) ) 1008*cdf0e10cSrcweir { 1009*cdf0e10cSrcweir m_aAxisProperties.m_aLabelAlignment = LABEL_ALIGN_LEFT; 1010*cdf0e10cSrcweir //choose most left positions 1011*cdf0e10cSrcweir ::std::sort( aPosList.begin(), aPosList.end(), lcl_LessXPos() ); 1012*cdf0e10cSrcweir m_aAxisProperties.m_fLabelDirectionSign = fDeltaY<0 ? -1 : 1; 1013*cdf0e10cSrcweir } 1014*cdf0e10cSrcweir else 1015*cdf0e10cSrcweir { 1016*cdf0e10cSrcweir m_aAxisProperties.m_aLabelAlignment = LABEL_ALIGN_BOTTOM; 1017*cdf0e10cSrcweir //choose most bottom positions 1018*cdf0e10cSrcweir ::std::sort( aPosList.begin(), aPosList.end(), lcl_GreaterYPos() ); 1019*cdf0e10cSrcweir m_aAxisProperties.m_fLabelDirectionSign = fDeltaX<0 ? -1 : 1; 1020*cdf0e10cSrcweir } 1021*cdf0e10cSrcweir ScreenPosAndLogicPos aBestPos( aPosList[0] ); 1022*cdf0e10cSrcweir fYStart = fYEnd = aBestPos.fLogicY; 1023*cdf0e10cSrcweir fZStart = fZEnd = aBestPos.fLogicZ; 1024*cdf0e10cSrcweir if( !m_pPosHelper->isMathematicalOrientationX() ) 1025*cdf0e10cSrcweir m_aAxisProperties.m_fLabelDirectionSign *= -1; 1026*cdf0e10cSrcweir } 1027*cdf0e10cSrcweir }//end 3D x axis 1028*cdf0e10cSrcweir } 1029*cdf0e10cSrcweir else if( 1==m_nDimensionIndex ) //y-axis 1030*cdf0e10cSrcweir { 1031*cdf0e10cSrcweir if( fCrossesOtherAxis < fMinX ) 1032*cdf0e10cSrcweir fCrossesOtherAxis = fMinX; 1033*cdf0e10cSrcweir else if( fCrossesOtherAxis > fMaxX ) 1034*cdf0e10cSrcweir fCrossesOtherAxis = fMaxX; 1035*cdf0e10cSrcweir 1036*cdf0e10cSrcweir fXStart = fXEnd = fCrossesOtherAxis; 1037*cdf0e10cSrcweir fYEnd=m_pPosHelper->getLogicMaxY(); 1038*cdf0e10cSrcweir 1039*cdf0e10cSrcweir if(3==m_nDimension) 1040*cdf0e10cSrcweir { 1041*cdf0e10cSrcweir if( AxisHelper::isAxisPositioningEnabled() ) 1042*cdf0e10cSrcweir { 1043*cdf0e10cSrcweir if( ::rtl::math::approxEqual( fXOther, fXStart) ) 1044*cdf0e10cSrcweir fZStart = fZEnd = fZOnZPlane; 1045*cdf0e10cSrcweir else 1046*cdf0e10cSrcweir fZStart = fZEnd = fZOther; 1047*cdf0e10cSrcweir } 1048*cdf0e10cSrcweir else 1049*cdf0e10cSrcweir { 1050*cdf0e10cSrcweir rStart = getScreenPosition( fXStart, fYStart, fZStart ); 1051*cdf0e10cSrcweir rEnd = getScreenPosition( fXEnd, fYEnd, fZEnd ); 1052*cdf0e10cSrcweir 1053*cdf0e10cSrcweir double fDeltaX = rEnd.getX() - rStart.getX(); 1054*cdf0e10cSrcweir double fDeltaY = rEnd.getY() - rStart.getY(); 1055*cdf0e10cSrcweir 1056*cdf0e10cSrcweir //only those points are candidates which are lying on exactly one wall as these are outer edges 1057*cdf0e10cSrcweir tScreenPosAndLogicPosList aPosList; 1058*cdf0e10cSrcweir aPosList.push_back( getScreenPosAndLogicPos( fXOnXPlane, fMinY, fZOther ) ); 1059*cdf0e10cSrcweir aPosList.push_back( getScreenPosAndLogicPos( fXOther, fMinY, fZOnZPlane ) ); 1060*cdf0e10cSrcweir 1061*cdf0e10cSrcweir if( fabs(fDeltaY) > fabs(fDeltaX) ) 1062*cdf0e10cSrcweir { 1063*cdf0e10cSrcweir m_aAxisProperties.m_aLabelAlignment = LABEL_ALIGN_LEFT; 1064*cdf0e10cSrcweir //choose most left positions 1065*cdf0e10cSrcweir ::std::sort( aPosList.begin(), aPosList.end(), lcl_LessXPos() ); 1066*cdf0e10cSrcweir m_aAxisProperties.m_fLabelDirectionSign = fDeltaY<0 ? -1 : 1; 1067*cdf0e10cSrcweir } 1068*cdf0e10cSrcweir else 1069*cdf0e10cSrcweir { 1070*cdf0e10cSrcweir m_aAxisProperties.m_aLabelAlignment = LABEL_ALIGN_BOTTOM; 1071*cdf0e10cSrcweir //choose most bottom positions 1072*cdf0e10cSrcweir ::std::sort( aPosList.begin(), aPosList.end(), lcl_GreaterYPos() ); 1073*cdf0e10cSrcweir m_aAxisProperties.m_fLabelDirectionSign = fDeltaX<0 ? -1 : 1; 1074*cdf0e10cSrcweir } 1075*cdf0e10cSrcweir ScreenPosAndLogicPos aBestPos( aPosList[0] ); 1076*cdf0e10cSrcweir fXStart = fXEnd = aBestPos.fLogicX; 1077*cdf0e10cSrcweir fZStart = fZEnd = aBestPos.fLogicZ; 1078*cdf0e10cSrcweir if( !m_pPosHelper->isMathematicalOrientationY() ) 1079*cdf0e10cSrcweir m_aAxisProperties.m_fLabelDirectionSign *= -1; 1080*cdf0e10cSrcweir } 1081*cdf0e10cSrcweir }//end 3D y axis 1082*cdf0e10cSrcweir } 1083*cdf0e10cSrcweir else //z-axis 1084*cdf0e10cSrcweir { 1085*cdf0e10cSrcweir fZEnd = m_pPosHelper->getLogicMaxZ(); 1086*cdf0e10cSrcweir if( AxisHelper::isAxisPositioningEnabled() ) 1087*cdf0e10cSrcweir { 1088*cdf0e10cSrcweir if( !m_aAxisProperties.m_bSwapXAndY ) 1089*cdf0e10cSrcweir { 1090*cdf0e10cSrcweir if( fCrossesOtherAxis < fMinY ) 1091*cdf0e10cSrcweir fCrossesOtherAxis = fMinY; 1092*cdf0e10cSrcweir else if( fCrossesOtherAxis > fMaxY ) 1093*cdf0e10cSrcweir fCrossesOtherAxis = fMaxY; 1094*cdf0e10cSrcweir fYStart = fYEnd = fCrossesOtherAxis; 1095*cdf0e10cSrcweir 1096*cdf0e10cSrcweir if( ::rtl::math::approxEqual( fYOther, fYStart) ) 1097*cdf0e10cSrcweir fXStart = fXEnd = fXOnXPlane; 1098*cdf0e10cSrcweir else 1099*cdf0e10cSrcweir fXStart = fXEnd = fXOther; 1100*cdf0e10cSrcweir } 1101*cdf0e10cSrcweir else 1102*cdf0e10cSrcweir { 1103*cdf0e10cSrcweir if( fCrossesOtherAxis < fMinX ) 1104*cdf0e10cSrcweir fCrossesOtherAxis = fMinX; 1105*cdf0e10cSrcweir else if( fCrossesOtherAxis > fMaxX ) 1106*cdf0e10cSrcweir fCrossesOtherAxis = fMaxX; 1107*cdf0e10cSrcweir fXStart = fXEnd = fCrossesOtherAxis; 1108*cdf0e10cSrcweir 1109*cdf0e10cSrcweir if( ::rtl::math::approxEqual( fXOther, fXStart) ) 1110*cdf0e10cSrcweir fYStart = fYEnd = fYOnYPlane; 1111*cdf0e10cSrcweir else 1112*cdf0e10cSrcweir fYStart = fYEnd = fYOther; 1113*cdf0e10cSrcweir } 1114*cdf0e10cSrcweir } 1115*cdf0e10cSrcweir else 1116*cdf0e10cSrcweir { 1117*cdf0e10cSrcweir if( !m_pPosHelper->isSwapXAndY() ) 1118*cdf0e10cSrcweir { 1119*cdf0e10cSrcweir fXStart = fXEnd = m_pPosHelper->isMathematicalOrientationX() ? m_pPosHelper->getLogicMaxX() : m_pPosHelper->getLogicMinX(); 1120*cdf0e10cSrcweir fYStart = fYEnd = m_pPosHelper->isMathematicalOrientationY() ? m_pPosHelper->getLogicMinY() : m_pPosHelper->getLogicMaxY(); 1121*cdf0e10cSrcweir } 1122*cdf0e10cSrcweir else 1123*cdf0e10cSrcweir { 1124*cdf0e10cSrcweir fXStart = fXEnd = m_pPosHelper->isMathematicalOrientationX() ? m_pPosHelper->getLogicMinX() : m_pPosHelper->getLogicMaxX(); 1125*cdf0e10cSrcweir fYStart = fYEnd = m_pPosHelper->isMathematicalOrientationY() ? m_pPosHelper->getLogicMaxY() : m_pPosHelper->getLogicMinY(); 1126*cdf0e10cSrcweir } 1127*cdf0e10cSrcweir 1128*cdf0e10cSrcweir if(3==m_nDimension) 1129*cdf0e10cSrcweir { 1130*cdf0e10cSrcweir rStart = getScreenPosition( fXStart, fYStart, fZStart ); 1131*cdf0e10cSrcweir rEnd = getScreenPosition( fXEnd, fYEnd, fZEnd ); 1132*cdf0e10cSrcweir 1133*cdf0e10cSrcweir double fDeltaX = rEnd.getX() - rStart.getX(); 1134*cdf0e10cSrcweir 1135*cdf0e10cSrcweir //only those points are candidates which are lying on exactly one wall as these are outer edges 1136*cdf0e10cSrcweir tScreenPosAndLogicPosList aPosList; 1137*cdf0e10cSrcweir aPosList.push_back( getScreenPosAndLogicPos( fXOther, fYOnYPlane, fMinZ ) ); 1138*cdf0e10cSrcweir aPosList.push_back( getScreenPosAndLogicPos( fXOnXPlane, fYOther, fMinZ ) ); 1139*cdf0e10cSrcweir 1140*cdf0e10cSrcweir ::std::sort( aPosList.begin(), aPosList.end(), lcl_GreaterYPos() ); 1141*cdf0e10cSrcweir ScreenPosAndLogicPos aBestPos( aPosList[0] ); 1142*cdf0e10cSrcweir ScreenPosAndLogicPos aNotSoGoodPos( aPosList[1] ); 1143*cdf0e10cSrcweir 1144*cdf0e10cSrcweir //choose most bottom positions 1145*cdf0e10cSrcweir if( !::rtl::math::approxEqual( fDeltaX, 0.0 ) ) // prefere left-right algnments 1146*cdf0e10cSrcweir { 1147*cdf0e10cSrcweir if( aBestPos.aScreenPos.getX() > aNotSoGoodPos.aScreenPos.getX() ) 1148*cdf0e10cSrcweir m_aAxisProperties.m_aLabelAlignment = LABEL_ALIGN_RIGHT; 1149*cdf0e10cSrcweir else 1150*cdf0e10cSrcweir m_aAxisProperties.m_aLabelAlignment = LABEL_ALIGN_LEFT; 1151*cdf0e10cSrcweir } 1152*cdf0e10cSrcweir else 1153*cdf0e10cSrcweir { 1154*cdf0e10cSrcweir if( aBestPos.aScreenPos.getY() > aNotSoGoodPos.aScreenPos.getY() ) 1155*cdf0e10cSrcweir m_aAxisProperties.m_aLabelAlignment = LABEL_ALIGN_BOTTOM; 1156*cdf0e10cSrcweir else 1157*cdf0e10cSrcweir m_aAxisProperties.m_aLabelAlignment = LABEL_ALIGN_TOP; 1158*cdf0e10cSrcweir } 1159*cdf0e10cSrcweir 1160*cdf0e10cSrcweir m_aAxisProperties.m_fLabelDirectionSign = fDeltaX<0 ? -1 : 1; 1161*cdf0e10cSrcweir if( !m_pPosHelper->isMathematicalOrientationZ() ) 1162*cdf0e10cSrcweir m_aAxisProperties.m_fLabelDirectionSign *= -1; 1163*cdf0e10cSrcweir 1164*cdf0e10cSrcweir fXStart = fXEnd = aBestPos.fLogicX; 1165*cdf0e10cSrcweir fYStart = fYEnd = aBestPos.fLogicY; 1166*cdf0e10cSrcweir } 1167*cdf0e10cSrcweir }//end 3D z axis 1168*cdf0e10cSrcweir } 1169*cdf0e10cSrcweir 1170*cdf0e10cSrcweir rStart = getScreenPosition( fXStart, fYStart, fZStart ); 1171*cdf0e10cSrcweir rEnd = getScreenPosition( fXEnd, fYEnd, fZEnd ); 1172*cdf0e10cSrcweir 1173*cdf0e10cSrcweir if(3==m_nDimension && !AxisHelper::isAxisPositioningEnabled() ) 1174*cdf0e10cSrcweir m_aAxisProperties.m_fInnerDirectionSign = m_aAxisProperties.m_fLabelDirectionSign;//to behave like before 1175*cdf0e10cSrcweir 1176*cdf0e10cSrcweir if(3==m_nDimension && AxisHelper::isAxisPositioningEnabled() ) 1177*cdf0e10cSrcweir { 1178*cdf0e10cSrcweir double fDeltaX = rEnd.getX() - rStart.getX(); 1179*cdf0e10cSrcweir double fDeltaY = rEnd.getY() - rStart.getY(); 1180*cdf0e10cSrcweir 1181*cdf0e10cSrcweir if( 2==m_nDimensionIndex ) 1182*cdf0e10cSrcweir { 1183*cdf0e10cSrcweir if( m_eLeftWallPos != CuboidPlanePosition_Left ) 1184*cdf0e10cSrcweir { 1185*cdf0e10cSrcweir m_aAxisProperties.m_fLabelDirectionSign *= -1.0; 1186*cdf0e10cSrcweir m_aAxisProperties.m_fInnerDirectionSign *= -1.0; 1187*cdf0e10cSrcweir } 1188*cdf0e10cSrcweir 1189*cdf0e10cSrcweir m_aAxisProperties.m_aLabelAlignment = 1190*cdf0e10cSrcweir ( m_aAxisProperties.m_fLabelDirectionSign<0 ) ? 1191*cdf0e10cSrcweir LABEL_ALIGN_LEFT : LABEL_ALIGN_RIGHT; 1192*cdf0e10cSrcweir 1193*cdf0e10cSrcweir if( ( fDeltaY<0 && m_aScale.Orientation == AxisOrientation_REVERSE ) || 1194*cdf0e10cSrcweir ( fDeltaY>0 && m_aScale.Orientation == AxisOrientation_MATHEMATICAL ) ) 1195*cdf0e10cSrcweir m_aAxisProperties.m_aLabelAlignment = 1196*cdf0e10cSrcweir ( m_aAxisProperties.m_aLabelAlignment==LABEL_ALIGN_RIGHT ) ? 1197*cdf0e10cSrcweir LABEL_ALIGN_LEFT : LABEL_ALIGN_RIGHT; 1198*cdf0e10cSrcweir } 1199*cdf0e10cSrcweir else if( fabs(fDeltaY) > fabs(fDeltaX) ) 1200*cdf0e10cSrcweir { 1201*cdf0e10cSrcweir if( m_eBackWallPos != CuboidPlanePosition_Back ) 1202*cdf0e10cSrcweir { 1203*cdf0e10cSrcweir m_aAxisProperties.m_fLabelDirectionSign *= -1.0; 1204*cdf0e10cSrcweir m_aAxisProperties.m_fInnerDirectionSign *= -1.0; 1205*cdf0e10cSrcweir } 1206*cdf0e10cSrcweir 1207*cdf0e10cSrcweir m_aAxisProperties.m_aLabelAlignment = 1208*cdf0e10cSrcweir ( m_aAxisProperties.m_fLabelDirectionSign<0 ) ? 1209*cdf0e10cSrcweir LABEL_ALIGN_LEFT : LABEL_ALIGN_RIGHT; 1210*cdf0e10cSrcweir 1211*cdf0e10cSrcweir if( ( fDeltaY<0 && m_aScale.Orientation == AxisOrientation_REVERSE ) || 1212*cdf0e10cSrcweir ( fDeltaY>0 && m_aScale.Orientation == AxisOrientation_MATHEMATICAL ) ) 1213*cdf0e10cSrcweir m_aAxisProperties.m_aLabelAlignment = 1214*cdf0e10cSrcweir ( m_aAxisProperties.m_aLabelAlignment==LABEL_ALIGN_RIGHT ) ? 1215*cdf0e10cSrcweir LABEL_ALIGN_LEFT : LABEL_ALIGN_RIGHT; 1216*cdf0e10cSrcweir } 1217*cdf0e10cSrcweir else 1218*cdf0e10cSrcweir { 1219*cdf0e10cSrcweir if( m_eBackWallPos != CuboidPlanePosition_Back ) 1220*cdf0e10cSrcweir { 1221*cdf0e10cSrcweir m_aAxisProperties.m_fLabelDirectionSign *= -1.0; 1222*cdf0e10cSrcweir m_aAxisProperties.m_fInnerDirectionSign *= -1.0; 1223*cdf0e10cSrcweir } 1224*cdf0e10cSrcweir 1225*cdf0e10cSrcweir m_aAxisProperties.m_aLabelAlignment = 1226*cdf0e10cSrcweir ( m_aAxisProperties.m_fLabelDirectionSign<0 ) ? 1227*cdf0e10cSrcweir LABEL_ALIGN_TOP : LABEL_ALIGN_BOTTOM; 1228*cdf0e10cSrcweir 1229*cdf0e10cSrcweir if( ( fDeltaX>0 && m_aScale.Orientation == AxisOrientation_REVERSE ) || 1230*cdf0e10cSrcweir ( fDeltaX<0 && m_aScale.Orientation == AxisOrientation_MATHEMATICAL ) ) 1231*cdf0e10cSrcweir m_aAxisProperties.m_aLabelAlignment = 1232*cdf0e10cSrcweir ( m_aAxisProperties.m_aLabelAlignment==LABEL_ALIGN_TOP ) ? 1233*cdf0e10cSrcweir LABEL_ALIGN_BOTTOM : LABEL_ALIGN_TOP; 1234*cdf0e10cSrcweir } 1235*cdf0e10cSrcweir } 1236*cdf0e10cSrcweir } 1237*cdf0e10cSrcweir 1238*cdf0e10cSrcweir TickFactory* VCartesianAxis::createTickFactory() 1239*cdf0e10cSrcweir { 1240*cdf0e10cSrcweir return createTickFactory2D(); 1241*cdf0e10cSrcweir } 1242*cdf0e10cSrcweir 1243*cdf0e10cSrcweir TickFactory_2D* VCartesianAxis::createTickFactory2D() 1244*cdf0e10cSrcweir { 1245*cdf0e10cSrcweir B2DVector aStart, aEnd; 1246*cdf0e10cSrcweir this->get2DAxisMainLine( aStart, aEnd, this->getLogicValueWhereMainLineCrossesOtherAxis() ); 1247*cdf0e10cSrcweir 1248*cdf0e10cSrcweir B2DVector aLabelLineStart, aLabelLineEnd; 1249*cdf0e10cSrcweir this->get2DAxisMainLine( aLabelLineStart, aLabelLineEnd, this->getLogicValueWhereLabelLineCrossesOtherAxis() ); 1250*cdf0e10cSrcweir 1251*cdf0e10cSrcweir return new TickFactory_2D( m_aScale, m_aIncrement, aStart, aEnd, aLabelLineStart-aStart ); 1252*cdf0e10cSrcweir } 1253*cdf0e10cSrcweir 1254*cdf0e10cSrcweir void lcl_hideIdenticalScreenValues( TickIter& rTickIter ) 1255*cdf0e10cSrcweir { 1256*cdf0e10cSrcweir TickInfo* pPreviousTickInfo = rTickIter.firstInfo(); 1257*cdf0e10cSrcweir if(!pPreviousTickInfo) 1258*cdf0e10cSrcweir return; 1259*cdf0e10cSrcweir pPreviousTickInfo->bPaintIt = true; 1260*cdf0e10cSrcweir for( TickInfo* pTickInfo = rTickIter.nextInfo(); pTickInfo; pTickInfo = rTickIter.nextInfo()) 1261*cdf0e10cSrcweir { 1262*cdf0e10cSrcweir pTickInfo->bPaintIt = 1263*cdf0e10cSrcweir ( static_cast<sal_Int32>(pTickInfo->aTickScreenPosition.getX()) 1264*cdf0e10cSrcweir != static_cast<sal_Int32>(pPreviousTickInfo->aTickScreenPosition.getX()) ) 1265*cdf0e10cSrcweir || 1266*cdf0e10cSrcweir ( static_cast<sal_Int32>(pTickInfo->aTickScreenPosition.getY()) 1267*cdf0e10cSrcweir != static_cast<sal_Int32>(pPreviousTickInfo->aTickScreenPosition.getY()) ); 1268*cdf0e10cSrcweir pPreviousTickInfo = pTickInfo; 1269*cdf0e10cSrcweir } 1270*cdf0e10cSrcweir } 1271*cdf0e10cSrcweir 1272*cdf0e10cSrcweir //'hide' tickmarks with identical screen values in aAllTickInfos 1273*cdf0e10cSrcweir void VCartesianAxis::hideIdenticalScreenValues( ::std::vector< ::std::vector< TickInfo > >& rTickInfos ) const 1274*cdf0e10cSrcweir { 1275*cdf0e10cSrcweir if( isComplexCategoryAxis() || isDateAxis() ) 1276*cdf0e10cSrcweir { 1277*cdf0e10cSrcweir sal_Int32 nCount = rTickInfos.size(); 1278*cdf0e10cSrcweir for( sal_Int32 nN=0; nN<nCount; nN++ ) 1279*cdf0e10cSrcweir { 1280*cdf0e10cSrcweir PureTickIter aTickIter( rTickInfos[nN] ); 1281*cdf0e10cSrcweir lcl_hideIdenticalScreenValues( aTickIter ); 1282*cdf0e10cSrcweir } 1283*cdf0e10cSrcweir } 1284*cdf0e10cSrcweir else 1285*cdf0e10cSrcweir { 1286*cdf0e10cSrcweir EquidistantTickIter aTickIter( rTickInfos, m_aIncrement, 0, -1 ); 1287*cdf0e10cSrcweir lcl_hideIdenticalScreenValues( aTickIter ); 1288*cdf0e10cSrcweir } 1289*cdf0e10cSrcweir } 1290*cdf0e10cSrcweir 1291*cdf0e10cSrcweir sal_Int32 VCartesianAxis::estimateMaximumAutoMainIncrementCount() 1292*cdf0e10cSrcweir { 1293*cdf0e10cSrcweir sal_Int32 nRet = 10; 1294*cdf0e10cSrcweir 1295*cdf0e10cSrcweir if( m_nMaximumTextWidthSoFar==0 && m_nMaximumTextHeightSoFar==0 ) 1296*cdf0e10cSrcweir return nRet; 1297*cdf0e10cSrcweir 1298*cdf0e10cSrcweir B2DVector aStart, aEnd; 1299*cdf0e10cSrcweir this->get2DAxisMainLine( aStart, aEnd, this->getLogicValueWhereMainLineCrossesOtherAxis() ); 1300*cdf0e10cSrcweir 1301*cdf0e10cSrcweir sal_Int32 nMaxHeight = static_cast<sal_Int32>(fabs(aEnd.getY()-aStart.getY())); 1302*cdf0e10cSrcweir sal_Int32 nMaxWidth = static_cast<sal_Int32>(fabs(aEnd.getX()-aStart.getX())); 1303*cdf0e10cSrcweir 1304*cdf0e10cSrcweir sal_Int32 nTotalAvailable = nMaxHeight; 1305*cdf0e10cSrcweir sal_Int32 nSingleNeeded = m_nMaximumTextHeightSoFar; 1306*cdf0e10cSrcweir 1307*cdf0e10cSrcweir //for horizontal axis: 1308*cdf0e10cSrcweir if( (m_nDimensionIndex == 0 && !m_aAxisProperties.m_bSwapXAndY) 1309*cdf0e10cSrcweir || (m_nDimensionIndex == 1 && m_aAxisProperties.m_bSwapXAndY) ) 1310*cdf0e10cSrcweir { 1311*cdf0e10cSrcweir nTotalAvailable = nMaxWidth; 1312*cdf0e10cSrcweir nSingleNeeded = m_nMaximumTextWidthSoFar; 1313*cdf0e10cSrcweir } 1314*cdf0e10cSrcweir 1315*cdf0e10cSrcweir if( nSingleNeeded>0 ) 1316*cdf0e10cSrcweir nRet = nTotalAvailable/nSingleNeeded; 1317*cdf0e10cSrcweir 1318*cdf0e10cSrcweir return nRet; 1319*cdf0e10cSrcweir } 1320*cdf0e10cSrcweir 1321*cdf0e10cSrcweir void VCartesianAxis::doStaggeringOfLabels( const AxisLabelProperties& rAxisLabelProperties, TickFactory_2D* pTickFactory2D ) 1322*cdf0e10cSrcweir { 1323*cdf0e10cSrcweir if( !pTickFactory2D ) 1324*cdf0e10cSrcweir return; 1325*cdf0e10cSrcweir 1326*cdf0e10cSrcweir if( isComplexCategoryAxis() ) 1327*cdf0e10cSrcweir { 1328*cdf0e10cSrcweir sal_Int32 nTextLevelCount = getTextLevelCount(); 1329*cdf0e10cSrcweir B2DVector aCummulatedLabelsDistance(0,0); 1330*cdf0e10cSrcweir for( sal_Int32 nTextLevel=0; nTextLevel<nTextLevelCount; nTextLevel++ ) 1331*cdf0e10cSrcweir { 1332*cdf0e10cSrcweir ::std::auto_ptr< TickIter > apTickIter = createLabelTickIterator( nTextLevel ); 1333*cdf0e10cSrcweir if(apTickIter.get()) 1334*cdf0e10cSrcweir { 1335*cdf0e10cSrcweir double fRotationAngleDegree = m_aAxisLabelProperties.fRotationAngleDegree; 1336*cdf0e10cSrcweir if( nTextLevel>0 ) 1337*cdf0e10cSrcweir { 1338*cdf0e10cSrcweir lcl_shiftLables( *apTickIter.get(), aCummulatedLabelsDistance ); 1339*cdf0e10cSrcweir fRotationAngleDegree = 0.0; 1340*cdf0e10cSrcweir } 1341*cdf0e10cSrcweir aCummulatedLabelsDistance += lcl_getLabelsDistance( *apTickIter.get() 1342*cdf0e10cSrcweir , pTickFactory2D->getDistanceAxisTickToText( m_aAxisProperties ) 1343*cdf0e10cSrcweir , fRotationAngleDegree ); 1344*cdf0e10cSrcweir } 1345*cdf0e10cSrcweir } 1346*cdf0e10cSrcweir } 1347*cdf0e10cSrcweir else if( rAxisLabelProperties.getIsStaggered() ) 1348*cdf0e10cSrcweir { 1349*cdf0e10cSrcweir if( !m_aAllTickInfos.empty() ) 1350*cdf0e10cSrcweir { 1351*cdf0e10cSrcweir LabelIterator aInnerIter( m_aAllTickInfos[0], rAxisLabelProperties.eStaggering, true ); 1352*cdf0e10cSrcweir LabelIterator aOuterIter( m_aAllTickInfos[0], rAxisLabelProperties.eStaggering, false ); 1353*cdf0e10cSrcweir 1354*cdf0e10cSrcweir lcl_shiftLables( aOuterIter 1355*cdf0e10cSrcweir , lcl_getLabelsDistance( aInnerIter 1356*cdf0e10cSrcweir , pTickFactory2D->getDistanceAxisTickToText( m_aAxisProperties ), 0.0 ) ); 1357*cdf0e10cSrcweir } 1358*cdf0e10cSrcweir } 1359*cdf0e10cSrcweir } 1360*cdf0e10cSrcweir 1361*cdf0e10cSrcweir void VCartesianAxis::createLabels() 1362*cdf0e10cSrcweir { 1363*cdf0e10cSrcweir if( !prepareShapeCreation() ) 1364*cdf0e10cSrcweir return; 1365*cdf0e10cSrcweir 1366*cdf0e10cSrcweir //----------------------------------------- 1367*cdf0e10cSrcweir //create labels 1368*cdf0e10cSrcweir if( m_aAxisProperties.m_bDisplayLabels ) 1369*cdf0e10cSrcweir { 1370*cdf0e10cSrcweir std::auto_ptr< TickFactory_2D > apTickFactory2D( this->createTickFactory2D() ); 1371*cdf0e10cSrcweir TickFactory_2D* pTickFactory2D = apTickFactory2D.get(); 1372*cdf0e10cSrcweir if( !pTickFactory2D ) 1373*cdf0e10cSrcweir return; 1374*cdf0e10cSrcweir 1375*cdf0e10cSrcweir //----------------------------------------- 1376*cdf0e10cSrcweir //get the transformed screen values for all tickmarks in aAllTickInfos 1377*cdf0e10cSrcweir pTickFactory2D->updateScreenValues( m_aAllTickInfos ); 1378*cdf0e10cSrcweir //----------------------------------------- 1379*cdf0e10cSrcweir //'hide' tickmarks with identical screen values in aAllTickInfos 1380*cdf0e10cSrcweir hideIdenticalScreenValues( m_aAllTickInfos ); 1381*cdf0e10cSrcweir 1382*cdf0e10cSrcweir removeTextShapesFromTicks(); 1383*cdf0e10cSrcweir 1384*cdf0e10cSrcweir //create tick mark text shapes 1385*cdf0e10cSrcweir sal_Int32 nTextLevelCount = getTextLevelCount(); 1386*cdf0e10cSrcweir sal_Int32 nScreenDistanceBetweenTicks = -1; 1387*cdf0e10cSrcweir for( sal_Int32 nTextLevel=0; nTextLevel<nTextLevelCount; nTextLevel++ ) 1388*cdf0e10cSrcweir { 1389*cdf0e10cSrcweir ::std::auto_ptr< TickIter > apTickIter = createLabelTickIterator( nTextLevel ); 1390*cdf0e10cSrcweir if(apTickIter.get()) 1391*cdf0e10cSrcweir { 1392*cdf0e10cSrcweir if(nTextLevel==0) 1393*cdf0e10cSrcweir { 1394*cdf0e10cSrcweir nScreenDistanceBetweenTicks = TickFactory_2D::getTickScreenDistance( *apTickIter.get() ); 1395*cdf0e10cSrcweir if( nTextLevelCount>1 ) 1396*cdf0e10cSrcweir nScreenDistanceBetweenTicks*=2; //the above used tick iter does contain also the sub ticks -> thus the given distance is only the half 1397*cdf0e10cSrcweir } 1398*cdf0e10cSrcweir 1399*cdf0e10cSrcweir AxisLabelProperties aComplexProps(m_aAxisLabelProperties); 1400*cdf0e10cSrcweir if( m_aAxisProperties.m_bComplexCategories ) 1401*cdf0e10cSrcweir { 1402*cdf0e10cSrcweir if( nTextLevel==0 ) 1403*cdf0e10cSrcweir { 1404*cdf0e10cSrcweir aComplexProps.bLineBreakAllowed = true; 1405*cdf0e10cSrcweir aComplexProps.bOverlapAllowed = !::rtl::math::approxEqual( aComplexProps.fRotationAngleDegree, 0.0 ); 1406*cdf0e10cSrcweir } 1407*cdf0e10cSrcweir else 1408*cdf0e10cSrcweir { 1409*cdf0e10cSrcweir aComplexProps.bOverlapAllowed = true; 1410*cdf0e10cSrcweir aComplexProps.bRhythmIsFix = true; 1411*cdf0e10cSrcweir aComplexProps.nRhythm = 1; 1412*cdf0e10cSrcweir aComplexProps.fRotationAngleDegree = 0.0; 1413*cdf0e10cSrcweir } 1414*cdf0e10cSrcweir } 1415*cdf0e10cSrcweir AxisLabelProperties& rAxisLabelProperties = m_aAxisProperties.m_bComplexCategories ? aComplexProps : m_aAxisLabelProperties; 1416*cdf0e10cSrcweir while( !createTextShapes( m_xTextTarget, *apTickIter.get(), rAxisLabelProperties, pTickFactory2D, nScreenDistanceBetweenTicks ) ) 1417*cdf0e10cSrcweir { 1418*cdf0e10cSrcweir }; 1419*cdf0e10cSrcweir } 1420*cdf0e10cSrcweir } 1421*cdf0e10cSrcweir doStaggeringOfLabels( m_aAxisLabelProperties, pTickFactory2D ); 1422*cdf0e10cSrcweir } 1423*cdf0e10cSrcweir } 1424*cdf0e10cSrcweir 1425*cdf0e10cSrcweir void VCartesianAxis::createMaximumLabels() 1426*cdf0e10cSrcweir { 1427*cdf0e10cSrcweir TrueGuard aRecordMaximumTextSize(m_bRecordMaximumTextSize); 1428*cdf0e10cSrcweir 1429*cdf0e10cSrcweir if( !prepareShapeCreation() ) 1430*cdf0e10cSrcweir return; 1431*cdf0e10cSrcweir 1432*cdf0e10cSrcweir //----------------------------------------- 1433*cdf0e10cSrcweir //create labels 1434*cdf0e10cSrcweir if( m_aAxisProperties.m_bDisplayLabels ) 1435*cdf0e10cSrcweir { 1436*cdf0e10cSrcweir std::auto_ptr< TickFactory_2D > apTickFactory2D( this->createTickFactory2D() ); 1437*cdf0e10cSrcweir TickFactory_2D* pTickFactory2D = apTickFactory2D.get(); 1438*cdf0e10cSrcweir if( !pTickFactory2D ) 1439*cdf0e10cSrcweir return; 1440*cdf0e10cSrcweir 1441*cdf0e10cSrcweir //----------------------------------------- 1442*cdf0e10cSrcweir //get the transformed screen values for all tickmarks in aAllTickInfos 1443*cdf0e10cSrcweir pTickFactory2D->updateScreenValues( m_aAllTickInfos ); 1444*cdf0e10cSrcweir 1445*cdf0e10cSrcweir //create tick mark text shapes 1446*cdf0e10cSrcweir //@todo: iterate through all tick depth wich should be labeled 1447*cdf0e10cSrcweir 1448*cdf0e10cSrcweir AxisLabelProperties aAxisLabelProperties( m_aAxisLabelProperties ); 1449*cdf0e10cSrcweir if( isAutoStaggeringOfLabelsAllowed( aAxisLabelProperties, pTickFactory2D->isHorizontalAxis(), pTickFactory2D->isVerticalAxis() ) ) 1450*cdf0e10cSrcweir aAxisLabelProperties.eStaggering = STAGGER_EVEN; 1451*cdf0e10cSrcweir aAxisLabelProperties.bOverlapAllowed = true; 1452*cdf0e10cSrcweir aAxisLabelProperties.bLineBreakAllowed = false; 1453*cdf0e10cSrcweir sal_Int32 nTextLevelCount = getTextLevelCount(); 1454*cdf0e10cSrcweir for( sal_Int32 nTextLevel=0; nTextLevel<nTextLevelCount; nTextLevel++ ) 1455*cdf0e10cSrcweir { 1456*cdf0e10cSrcweir ::std::auto_ptr< TickIter > apTickIter = createMaximumLabelTickIterator( nTextLevel ); 1457*cdf0e10cSrcweir if(apTickIter.get()) 1458*cdf0e10cSrcweir { 1459*cdf0e10cSrcweir while( !createTextShapes( m_xTextTarget, *apTickIter.get(), aAxisLabelProperties, pTickFactory2D, -1 ) ) 1460*cdf0e10cSrcweir { 1461*cdf0e10cSrcweir }; 1462*cdf0e10cSrcweir } 1463*cdf0e10cSrcweir } 1464*cdf0e10cSrcweir doStaggeringOfLabels( aAxisLabelProperties, pTickFactory2D ); 1465*cdf0e10cSrcweir } 1466*cdf0e10cSrcweir } 1467*cdf0e10cSrcweir 1468*cdf0e10cSrcweir void VCartesianAxis::updatePositions() 1469*cdf0e10cSrcweir { 1470*cdf0e10cSrcweir //----------------------------------------- 1471*cdf0e10cSrcweir //update positions of labels 1472*cdf0e10cSrcweir if( m_aAxisProperties.m_bDisplayLabels ) 1473*cdf0e10cSrcweir { 1474*cdf0e10cSrcweir std::auto_ptr< TickFactory_2D > apTickFactory2D( this->createTickFactory2D() ); 1475*cdf0e10cSrcweir TickFactory_2D* pTickFactory2D = apTickFactory2D.get(); 1476*cdf0e10cSrcweir if( !pTickFactory2D ) 1477*cdf0e10cSrcweir return; 1478*cdf0e10cSrcweir 1479*cdf0e10cSrcweir //----------------------------------------- 1480*cdf0e10cSrcweir //update positions of all existing text shapes 1481*cdf0e10cSrcweir pTickFactory2D->updateScreenValues( m_aAllTickInfos ); 1482*cdf0e10cSrcweir 1483*cdf0e10cSrcweir ::std::vector< ::std::vector< TickInfo > >::iterator aDepthIter = m_aAllTickInfos.begin(); 1484*cdf0e10cSrcweir const ::std::vector< ::std::vector< TickInfo > >::const_iterator aDepthEnd = m_aAllTickInfos.end(); 1485*cdf0e10cSrcweir for( sal_Int32 nDepth=0; aDepthIter != aDepthEnd; aDepthIter++, nDepth++ ) 1486*cdf0e10cSrcweir { 1487*cdf0e10cSrcweir ::std::vector< TickInfo >::iterator aTickIter = aDepthIter->begin(); 1488*cdf0e10cSrcweir const ::std::vector< TickInfo >::const_iterator aTickEnd = aDepthIter->end(); 1489*cdf0e10cSrcweir for( ; aTickIter != aTickEnd; aTickIter++ ) 1490*cdf0e10cSrcweir { 1491*cdf0e10cSrcweir TickInfo& rTickInfo = (*aTickIter); 1492*cdf0e10cSrcweir Reference< drawing::XShape > xShape2DText( rTickInfo.xTextShape ); 1493*cdf0e10cSrcweir if( xShape2DText.is() ) 1494*cdf0e10cSrcweir { 1495*cdf0e10cSrcweir B2DVector aTextToTickDistance( pTickFactory2D->getDistanceAxisTickToText( m_aAxisProperties, true ) ); 1496*cdf0e10cSrcweir B2DVector aTickScreenPos2D( rTickInfo.aTickScreenPosition ); 1497*cdf0e10cSrcweir aTickScreenPos2D += aTextToTickDistance; 1498*cdf0e10cSrcweir awt::Point aAnchorScreenPosition2D( 1499*cdf0e10cSrcweir static_cast<sal_Int32>(aTickScreenPos2D.getX()) 1500*cdf0e10cSrcweir ,static_cast<sal_Int32>(aTickScreenPos2D.getY())); 1501*cdf0e10cSrcweir 1502*cdf0e10cSrcweir double fRotationAngleDegree = m_aAxisLabelProperties.fRotationAngleDegree; 1503*cdf0e10cSrcweir if( nDepth>0 ) 1504*cdf0e10cSrcweir fRotationAngleDegree = 0.0; 1505*cdf0e10cSrcweir 1506*cdf0e10cSrcweir // #i78696# use mathematically correct rotation now 1507*cdf0e10cSrcweir const double fRotationAnglePi(fRotationAngleDegree * (F_PI / -180.0)); 1508*cdf0e10cSrcweir uno::Any aATransformation = ShapeFactory::makeTransformation(aAnchorScreenPosition2D, fRotationAnglePi); 1509*cdf0e10cSrcweir 1510*cdf0e10cSrcweir //set new position 1511*cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xProp( xShape2DText, uno::UNO_QUERY ); 1512*cdf0e10cSrcweir if( xProp.is() ) 1513*cdf0e10cSrcweir { 1514*cdf0e10cSrcweir try 1515*cdf0e10cSrcweir { 1516*cdf0e10cSrcweir xProp->setPropertyValue( C2U( "Transformation" ), aATransformation ); 1517*cdf0e10cSrcweir } 1518*cdf0e10cSrcweir catch( uno::Exception& e ) 1519*cdf0e10cSrcweir { 1520*cdf0e10cSrcweir ASSERT_EXCEPTION( e ); 1521*cdf0e10cSrcweir } 1522*cdf0e10cSrcweir } 1523*cdf0e10cSrcweir 1524*cdf0e10cSrcweir //correctPositionForRotation 1525*cdf0e10cSrcweir LabelPositionHelper::correctPositionForRotation( xShape2DText 1526*cdf0e10cSrcweir , m_aAxisProperties.m_aLabelAlignment, fRotationAngleDegree, m_aAxisProperties.m_bComplexCategories ); 1527*cdf0e10cSrcweir } 1528*cdf0e10cSrcweir } 1529*cdf0e10cSrcweir } 1530*cdf0e10cSrcweir 1531*cdf0e10cSrcweir doStaggeringOfLabels( m_aAxisLabelProperties, pTickFactory2D ); 1532*cdf0e10cSrcweir } 1533*cdf0e10cSrcweir } 1534*cdf0e10cSrcweir 1535*cdf0e10cSrcweir void VCartesianAxis::createTickMarkLineShapes( ::std::vector< TickInfo >& rTickInfos, const TickmarkProperties& rTickmarkProperties, TickFactory_2D& rTickFactory2D, bool bOnlyAtLabels ) 1536*cdf0e10cSrcweir { 1537*cdf0e10cSrcweir sal_Int32 nPointCount = rTickInfos.size(); 1538*cdf0e10cSrcweir drawing::PointSequenceSequence aPoints(2*nPointCount); 1539*cdf0e10cSrcweir 1540*cdf0e10cSrcweir ::std::vector< TickInfo >::const_iterator aTickIter = rTickInfos.begin(); 1541*cdf0e10cSrcweir const ::std::vector< TickInfo >::const_iterator aTickEnd = rTickInfos.end(); 1542*cdf0e10cSrcweir sal_Int32 nN = 0; 1543*cdf0e10cSrcweir for( ; aTickIter != aTickEnd; aTickIter++ ) 1544*cdf0e10cSrcweir { 1545*cdf0e10cSrcweir if( !(*aTickIter).bPaintIt ) 1546*cdf0e10cSrcweir continue; 1547*cdf0e10cSrcweir 1548*cdf0e10cSrcweir bool bTicksAtLabels = ( m_aAxisProperties.m_eTickmarkPos != ::com::sun::star::chart::ChartAxisMarkPosition_AT_AXIS ); 1549*cdf0e10cSrcweir double fInnerDirectionSign = m_aAxisProperties.m_fInnerDirectionSign; 1550*cdf0e10cSrcweir if( bTicksAtLabels && m_aAxisProperties.m_eLabelPos == ::com::sun::star::chart::ChartAxisLabelPosition_OUTSIDE_END ) 1551*cdf0e10cSrcweir fInnerDirectionSign *= -1.0; 1552*cdf0e10cSrcweir bTicksAtLabels = bTicksAtLabels || bOnlyAtLabels; 1553*cdf0e10cSrcweir //add ticks at labels: 1554*cdf0e10cSrcweir rTickFactory2D.addPointSequenceForTickLine( aPoints, nN++, (*aTickIter).fScaledTickValue 1555*cdf0e10cSrcweir , fInnerDirectionSign , rTickmarkProperties, bTicksAtLabels ); 1556*cdf0e10cSrcweir //add ticks at axis (without lables): 1557*cdf0e10cSrcweir if( !bOnlyAtLabels && m_aAxisProperties.m_eTickmarkPos == ::com::sun::star::chart::ChartAxisMarkPosition_AT_LABELS_AND_AXIS ) 1558*cdf0e10cSrcweir rTickFactory2D.addPointSequenceForTickLine( aPoints, nN++, (*aTickIter).fScaledTickValue 1559*cdf0e10cSrcweir , m_aAxisProperties.m_fInnerDirectionSign, rTickmarkProperties, !bTicksAtLabels ); 1560*cdf0e10cSrcweir } 1561*cdf0e10cSrcweir aPoints.realloc(nN); 1562*cdf0e10cSrcweir m_pShapeFactory->createLine2D( m_xGroupShape_Shapes, aPoints 1563*cdf0e10cSrcweir , &rTickmarkProperties.aLineProperties ); 1564*cdf0e10cSrcweir } 1565*cdf0e10cSrcweir 1566*cdf0e10cSrcweir void VCartesianAxis::createShapes() 1567*cdf0e10cSrcweir { 1568*cdf0e10cSrcweir if( !prepareShapeCreation() ) 1569*cdf0e10cSrcweir return; 1570*cdf0e10cSrcweir 1571*cdf0e10cSrcweir std::auto_ptr< TickFactory_2D > apTickFactory2D( this->createTickFactory2D() ); 1572*cdf0e10cSrcweir TickFactory_2D* pTickFactory2D = apTickFactory2D.get(); 1573*cdf0e10cSrcweir if( !pTickFactory2D ) 1574*cdf0e10cSrcweir return; 1575*cdf0e10cSrcweir 1576*cdf0e10cSrcweir //----------------------------------------- 1577*cdf0e10cSrcweir //create line shapes 1578*cdf0e10cSrcweir if(2==m_nDimension) 1579*cdf0e10cSrcweir { 1580*cdf0e10cSrcweir //----------------------------------------- 1581*cdf0e10cSrcweir //create extra long ticks to separate complex categories (create them only there where the labels are) 1582*cdf0e10cSrcweir if( isComplexCategoryAxis() ) 1583*cdf0e10cSrcweir { 1584*cdf0e10cSrcweir ::std::vector< ::std::vector< TickInfo > > aComplexTickInfos; 1585*cdf0e10cSrcweir createAllTickInfosFromComplexCategories( aComplexTickInfos, true ); 1586*cdf0e10cSrcweir pTickFactory2D->updateScreenValues( aComplexTickInfos ); 1587*cdf0e10cSrcweir hideIdenticalScreenValues( aComplexTickInfos ); 1588*cdf0e10cSrcweir 1589*cdf0e10cSrcweir ::std::vector<TickmarkProperties> aTickmarkPropertiesList; 1590*cdf0e10cSrcweir static bool bIncludeSpaceBetweenTickAndText = false; 1591*cdf0e10cSrcweir sal_Int32 nOffset = static_cast<sal_Int32>(pTickFactory2D->getDistanceAxisTickToText( m_aAxisProperties, false, bIncludeSpaceBetweenTickAndText ).getLength()); 1592*cdf0e10cSrcweir sal_Int32 nTextLevelCount = getTextLevelCount(); 1593*cdf0e10cSrcweir for( sal_Int32 nTextLevel=0; nTextLevel<nTextLevelCount; nTextLevel++ ) 1594*cdf0e10cSrcweir { 1595*cdf0e10cSrcweir ::std::auto_ptr< TickIter > apTickIter = createLabelTickIterator( nTextLevel ); 1596*cdf0e10cSrcweir if( apTickIter.get() ) 1597*cdf0e10cSrcweir { 1598*cdf0e10cSrcweir double fRotationAngleDegree = m_aAxisLabelProperties.fRotationAngleDegree; 1599*cdf0e10cSrcweir if( nTextLevel>0 ) 1600*cdf0e10cSrcweir fRotationAngleDegree = 0.0; 1601*cdf0e10cSrcweir B2DVector aLabelsDistance( lcl_getLabelsDistance( *apTickIter.get(), pTickFactory2D->getDistanceAxisTickToText( m_aAxisProperties, false ), fRotationAngleDegree ) ); 1602*cdf0e10cSrcweir sal_Int32 nCurrentLength = static_cast<sal_Int32>(aLabelsDistance.getLength()); 1603*cdf0e10cSrcweir aTickmarkPropertiesList.push_back( m_aAxisProperties.makeTickmarkPropertiesForComplexCategories( nOffset + nCurrentLength, 0, nTextLevel ) ); 1604*cdf0e10cSrcweir nOffset += nCurrentLength; 1605*cdf0e10cSrcweir } 1606*cdf0e10cSrcweir } 1607*cdf0e10cSrcweir 1608*cdf0e10cSrcweir sal_Int32 nTickmarkPropertiesCount = aTickmarkPropertiesList.size(); 1609*cdf0e10cSrcweir ::std::vector< ::std::vector< TickInfo > >::iterator aDepthIter = aComplexTickInfos.begin(); 1610*cdf0e10cSrcweir const ::std::vector< ::std::vector< TickInfo > >::const_iterator aDepthEnd = aComplexTickInfos.end(); 1611*cdf0e10cSrcweir for( sal_Int32 nDepth=0; aDepthIter != aDepthEnd && nDepth < nTickmarkPropertiesCount; aDepthIter++, nDepth++ ) 1612*cdf0e10cSrcweir { 1613*cdf0e10cSrcweir if(nDepth==0 && !m_aAxisProperties.m_nMajorTickmarks) 1614*cdf0e10cSrcweir continue; 1615*cdf0e10cSrcweir createTickMarkLineShapes( *aDepthIter, aTickmarkPropertiesList[nDepth], *pTickFactory2D, true /*bOnlyAtLabels*/ ); 1616*cdf0e10cSrcweir } 1617*cdf0e10cSrcweir } 1618*cdf0e10cSrcweir //----------------------------------------- 1619*cdf0e10cSrcweir //create normal ticks for major and minor intervals 1620*cdf0e10cSrcweir { 1621*cdf0e10cSrcweir ::std::vector< ::std::vector< TickInfo > > aUnshiftedTickInfos; 1622*cdf0e10cSrcweir if( m_aScale.ShiftedCategoryPosition )// if ShiftedCategoryPosition==true the tickmarks in m_aAllTickInfos are shifted 1623*cdf0e10cSrcweir { 1624*cdf0e10cSrcweir pTickFactory2D->getAllTicks( aUnshiftedTickInfos ); 1625*cdf0e10cSrcweir pTickFactory2D->updateScreenValues( aUnshiftedTickInfos ); 1626*cdf0e10cSrcweir hideIdenticalScreenValues( aUnshiftedTickInfos ); 1627*cdf0e10cSrcweir } 1628*cdf0e10cSrcweir ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos = m_aScale.ShiftedCategoryPosition ? aUnshiftedTickInfos : m_aAllTickInfos; 1629*cdf0e10cSrcweir 1630*cdf0e10cSrcweir ::std::vector< ::std::vector< TickInfo > >::iterator aDepthIter = rAllTickInfos.begin(); 1631*cdf0e10cSrcweir const ::std::vector< ::std::vector< TickInfo > >::const_iterator aDepthEnd = rAllTickInfos.end(); 1632*cdf0e10cSrcweir if(aDepthIter == aDepthEnd)//no tickmarks at all 1633*cdf0e10cSrcweir return; 1634*cdf0e10cSrcweir 1635*cdf0e10cSrcweir sal_Int32 nTickmarkPropertiesCount = m_aAxisProperties.m_aTickmarkPropertiesList.size(); 1636*cdf0e10cSrcweir for( sal_Int32 nDepth=0; aDepthIter != aDepthEnd && nDepth < nTickmarkPropertiesCount; aDepthIter++, nDepth++ ) 1637*cdf0e10cSrcweir createTickMarkLineShapes( *aDepthIter, m_aAxisProperties.m_aTickmarkPropertiesList[nDepth], *pTickFactory2D, false /*bOnlyAtLabels*/ ); 1638*cdf0e10cSrcweir } 1639*cdf0e10cSrcweir //----------------------------------------- 1640*cdf0e10cSrcweir //create axis main lines 1641*cdf0e10cSrcweir //it serves also as the handle shape for the axis selection 1642*cdf0e10cSrcweir { 1643*cdf0e10cSrcweir drawing::PointSequenceSequence aPoints(1); 1644*cdf0e10cSrcweir apTickFactory2D->createPointSequenceForAxisMainLine( aPoints ); 1645*cdf0e10cSrcweir Reference< drawing::XShape > xShape = m_pShapeFactory->createLine2D( 1646*cdf0e10cSrcweir m_xGroupShape_Shapes, aPoints 1647*cdf0e10cSrcweir , &m_aAxisProperties.m_aLineProperties ); 1648*cdf0e10cSrcweir //because of this name this line will be used for marking the axis 1649*cdf0e10cSrcweir m_pShapeFactory->setShapeName( xShape, C2U("MarkHandles") ); 1650*cdf0e10cSrcweir } 1651*cdf0e10cSrcweir //----------------------------------------- 1652*cdf0e10cSrcweir //create an additional line at NULL 1653*cdf0e10cSrcweir if( !AxisHelper::isAxisPositioningEnabled() ) 1654*cdf0e10cSrcweir { 1655*cdf0e10cSrcweir double fExtraLineCrossesOtherAxis; 1656*cdf0e10cSrcweir if( getLogicValueWhereExtraLineCrossesOtherAxis(fExtraLineCrossesOtherAxis) ) 1657*cdf0e10cSrcweir { 1658*cdf0e10cSrcweir B2DVector aStart, aEnd; 1659*cdf0e10cSrcweir this->get2DAxisMainLine( aStart, aEnd, fExtraLineCrossesOtherAxis ); 1660*cdf0e10cSrcweir drawing::PointSequenceSequence aPoints( lcl_makePointSequence(aStart,aEnd) ); 1661*cdf0e10cSrcweir Reference< drawing::XShape > xShape = m_pShapeFactory->createLine2D( 1662*cdf0e10cSrcweir m_xGroupShape_Shapes, aPoints, &m_aAxisProperties.m_aLineProperties ); 1663*cdf0e10cSrcweir } 1664*cdf0e10cSrcweir } 1665*cdf0e10cSrcweir } 1666*cdf0e10cSrcweir 1667*cdf0e10cSrcweir //createLabels(); 1668*cdf0e10cSrcweir } 1669*cdf0e10cSrcweir 1670*cdf0e10cSrcweir //............................................................................. 1671*cdf0e10cSrcweir } //namespace chart 1672*cdf0e10cSrcweir //............................................................................. 1673