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 "tp_AxisPositions.hxx" 31*cdf0e10cSrcweir 32*cdf0e10cSrcweir #include "ResId.hxx" 33*cdf0e10cSrcweir #include "TabPages.hrc" 34*cdf0e10cSrcweir #include "Strings.hrc" 35*cdf0e10cSrcweir #include "chartview/ChartSfxItemIds.hxx" 36*cdf0e10cSrcweir #include "NoWarningThisInCTOR.hxx" 37*cdf0e10cSrcweir #include "AxisHelper.hxx" 38*cdf0e10cSrcweir 39*cdf0e10cSrcweir #ifndef _SVX_SVXIDS_HRC 40*cdf0e10cSrcweir #include <svx/svxids.hrc> 41*cdf0e10cSrcweir #endif 42*cdf0e10cSrcweir #include <rtl/math.hxx> 43*cdf0e10cSrcweir // header for class SvxDoubleItem 44*cdf0e10cSrcweir #include <svx/chrtitem.hxx> 45*cdf0e10cSrcweir // header for class SfxBoolItem 46*cdf0e10cSrcweir #include <svl/eitem.hxx> 47*cdf0e10cSrcweir // header for SfxInt32Item 48*cdf0e10cSrcweir #include <svl/intitem.hxx> 49*cdf0e10cSrcweir 50*cdf0e10cSrcweir // header for class WarningBox 51*cdf0e10cSrcweir #include <vcl/msgbox.hxx> 52*cdf0e10cSrcweir 53*cdf0e10cSrcweir // header for class SvNumberformat 54*cdf0e10cSrcweir #ifndef _ZFORMAT_HXX 55*cdf0e10cSrcweir #ifndef _ZFORLIST_DECLARE_TABLE 56*cdf0e10cSrcweir #define _ZFORLIST_DECLARE_TABLE 57*cdf0e10cSrcweir #endif 58*cdf0e10cSrcweir #include <svl/zformat.hxx> 59*cdf0e10cSrcweir #endif 60*cdf0e10cSrcweir 61*cdf0e10cSrcweir #include <svtools/controldims.hrc> 62*cdf0e10cSrcweir 63*cdf0e10cSrcweir #include <com/sun/star/chart/ChartAxisPosition.hpp> 64*cdf0e10cSrcweir #include <com/sun/star/chart2/AxisType.hpp> 65*cdf0e10cSrcweir 66*cdf0e10cSrcweir using namespace ::com::sun::star; 67*cdf0e10cSrcweir 68*cdf0e10cSrcweir //............................................................................. 69*cdf0e10cSrcweir namespace chart 70*cdf0e10cSrcweir { 71*cdf0e10cSrcweir //............................................................................. 72*cdf0e10cSrcweir 73*cdf0e10cSrcweir namespace 74*cdf0e10cSrcweir { 75*cdf0e10cSrcweir void lcl_newXPos( Control& rControl, long nXPos ) 76*cdf0e10cSrcweir { 77*cdf0e10cSrcweir Point aPos( rControl.GetPosPixel() ); 78*cdf0e10cSrcweir aPos.X() = nXPos; 79*cdf0e10cSrcweir rControl.SetPosPixel(aPos); 80*cdf0e10cSrcweir } 81*cdf0e10cSrcweir 82*cdf0e10cSrcweir void lcl_shiftY( Control& rControl, long nYDiff ) 83*cdf0e10cSrcweir { 84*cdf0e10cSrcweir Point aPos( rControl.GetPosPixel() ); 85*cdf0e10cSrcweir aPos.Y() += nYDiff; 86*cdf0e10cSrcweir rControl.SetPosPixel(aPos); 87*cdf0e10cSrcweir } 88*cdf0e10cSrcweir 89*cdf0e10cSrcweir } 90*cdf0e10cSrcweir 91*cdf0e10cSrcweir AxisPositionsTabPage::AxisPositionsTabPage(Window* pWindow,const SfxItemSet& rInAttrs) 92*cdf0e10cSrcweir : SfxTabPage(pWindow, SchResId(TP_AXIS_POSITIONS), rInAttrs) 93*cdf0e10cSrcweir 94*cdf0e10cSrcweir , m_aFL_AxisLine(this,SchResId(FL_AXIS_LINE)) 95*cdf0e10cSrcweir , m_aFT_CrossesAt(this,SchResId(FT_CROSSES_OTHER_AXIS_AT)) 96*cdf0e10cSrcweir , m_aLB_CrossesAt(this,SchResId(LB_CROSSES_OTHER_AXIS_AT)) 97*cdf0e10cSrcweir , m_aED_CrossesAt(this,SchResId(EDT_CROSSES_OTHER_AXIS_AT)) 98*cdf0e10cSrcweir , m_aED_CrossesAtCategory(this,SchResId(EDT_CROSSES_OTHER_AXIS_AT_CATEGORY)) 99*cdf0e10cSrcweir , m_aCB_AxisBetweenCategories(this, SchResId(CB_AXIS_BETWEEN_CATEGORIES)) 100*cdf0e10cSrcweir 101*cdf0e10cSrcweir , m_aFL_Labels(this,SchResId(FL_LABELS)) 102*cdf0e10cSrcweir , m_aFT_PlaceLabels( this, SchResId( FT_PLACE_LABELS ) ) 103*cdf0e10cSrcweir , m_aLB_PlaceLabels( this, SchResId( LB_PLACE_LABELS ) ) 104*cdf0e10cSrcweir , m_aFT_LabelDistance( this, SchResId( FT_AXIS_LABEL_DISTANCE ) ) 105*cdf0e10cSrcweir , m_aED_LabelDistance( this, SchResId( EDT_AXIS_LABEL_DISTANCE ) ) 106*cdf0e10cSrcweir 107*cdf0e10cSrcweir , m_aFL_Ticks(this,SchResId(FL_TICKS)) 108*cdf0e10cSrcweir , m_aFT_Major(this,SchResId(FT_MAJOR)) 109*cdf0e10cSrcweir , m_aCB_TicksInner(this,SchResId(CB_TICKS_INNER)) 110*cdf0e10cSrcweir , m_aCB_TicksOuter(this,SchResId(CB_TICKS_OUTER)) 111*cdf0e10cSrcweir , m_aFT_Minor(this,SchResId(FT_MINOR)) 112*cdf0e10cSrcweir , m_aCB_MinorInner(this,SchResId(CB_MINOR_INNER)) 113*cdf0e10cSrcweir , m_aCB_MinorOuter(this,SchResId(CB_MINOR_OUTER)) 114*cdf0e10cSrcweir 115*cdf0e10cSrcweir , m_aFL_Vertical(this,SchResId(FL_VERTICAL)) 116*cdf0e10cSrcweir , m_aFT_PlaceTicks(this,SchResId(FT_PLACE_TICKS)) 117*cdf0e10cSrcweir , m_aLB_PlaceTicks(this,SchResId(LB_PLACE_TICKS)) 118*cdf0e10cSrcweir 119*cdf0e10cSrcweir , m_aFL_Grids(this,SchResId(FL_GRIDS)) 120*cdf0e10cSrcweir , m_aCB_MajorGrid(this,SchResId(CB_MAJOR_GRID)) 121*cdf0e10cSrcweir , m_aPB_MajorGrid(this,SchResId(PB_MAJOR_GRID)) 122*cdf0e10cSrcweir , m_aCB_MinorGrid(this,SchResId(CB_MINOR_GRID)) 123*cdf0e10cSrcweir , m_aPB_MinorGrid(this,SchResId(PB_MINOR_GRID)) 124*cdf0e10cSrcweir 125*cdf0e10cSrcweir , m_pNumFormatter(NULL) 126*cdf0e10cSrcweir , m_bCrossingAxisIsCategoryAxis(false) 127*cdf0e10cSrcweir , m_aCategories() 128*cdf0e10cSrcweir { 129*cdf0e10cSrcweir FreeResource(); 130*cdf0e10cSrcweir SetExchangeSupport(); 131*cdf0e10cSrcweir 132*cdf0e10cSrcweir const long nDialogWidth = GetSizePixel().Width(); 133*cdf0e10cSrcweir const long nDistance = LogicToPixel( Size(RSC_SP_CTRL_X, 0), MapMode(MAP_APPFONT) ).Width(); 134*cdf0e10cSrcweir 135*cdf0e10cSrcweir //axis line controls 136*cdf0e10cSrcweir { 137*cdf0e10cSrcweir if( m_aFT_CrossesAt.CalcMinimumSize().Width() < m_aFT_CrossesAt.GetSizePixel().Width() ) 138*cdf0e10cSrcweir { 139*cdf0e10cSrcweir m_aFT_CrossesAt.SetSizePixel(m_aFT_CrossesAt.CalcMinimumSize()); 140*cdf0e10cSrcweir long nXPos = m_aFT_CrossesAt.GetPosPixel().X() + m_aFT_CrossesAt.GetSizePixel().Width() + nDistance; 141*cdf0e10cSrcweir lcl_newXPos( m_aLB_CrossesAt, nXPos ); 142*cdf0e10cSrcweir 143*cdf0e10cSrcweir nXPos += m_aLB_CrossesAt.GetSizePixel().Width() + nDistance; 144*cdf0e10cSrcweir lcl_newXPos( m_aED_CrossesAt, nXPos ); 145*cdf0e10cSrcweir lcl_newXPos( m_aED_CrossesAtCategory, nXPos ); 146*cdf0e10cSrcweir } 147*cdf0e10cSrcweir } 148*cdf0e10cSrcweir 149*cdf0e10cSrcweir long nFixTextHeight = m_aFT_PlaceLabels.GetSizePixel().Height(); 150*cdf0e10cSrcweir long nLabelPlacementWidth = m_aFT_PlaceLabels.CalcMinimumSize().Width(); 151*cdf0e10cSrcweir long nMarkPlacementWidth = m_aFT_PlaceTicks.CalcMinimumSize().Width(); 152*cdf0e10cSrcweir 153*cdf0e10cSrcweir 154*cdf0e10cSrcweir long nWidth_0 = ::std::max( m_aFT_Major.CalcMinimumSize().Width(), m_aFT_Minor.CalcMinimumSize().Width() ); 155*cdf0e10cSrcweir nWidth_0 = ::std::max( nWidth_0, nLabelPlacementWidth ); 156*cdf0e10cSrcweir nWidth_0 = ::std::max( nWidth_0, nMarkPlacementWidth ); 157*cdf0e10cSrcweir nLabelPlacementWidth = nMarkPlacementWidth = nWidth_0; 158*cdf0e10cSrcweir 159*cdf0e10cSrcweir //label placement 160*cdf0e10cSrcweir { 161*cdf0e10cSrcweir m_aFT_PlaceLabels.SetSizePixel( Size( nLabelPlacementWidth, nFixTextHeight ) ); 162*cdf0e10cSrcweir long nXPos = m_aFT_PlaceLabels.GetPosPixel().X() + nLabelPlacementWidth + nDistance; 163*cdf0e10cSrcweir lcl_newXPos( m_aLB_PlaceLabels, nXPos ); 164*cdf0e10cSrcweir m_aLB_PlaceLabels.SetSizePixel(m_aLB_PlaceLabels.CalcMinimumSize()); 165*cdf0e10cSrcweir } 166*cdf0e10cSrcweir 167*cdf0e10cSrcweir //tickmark placement 168*cdf0e10cSrcweir { 169*cdf0e10cSrcweir m_aFT_PlaceTicks.SetSizePixel( Size( nMarkPlacementWidth, nFixTextHeight ) ); 170*cdf0e10cSrcweir long nXPos = m_aFT_PlaceTicks.GetPosPixel().X() + nMarkPlacementWidth + nDistance; 171*cdf0e10cSrcweir lcl_newXPos( m_aLB_PlaceTicks, nXPos ); 172*cdf0e10cSrcweir m_aLB_PlaceTicks.SetSizePixel( m_aLB_PlaceTicks.CalcMinimumSize() ); 173*cdf0e10cSrcweir } 174*cdf0e10cSrcweir 175*cdf0e10cSrcweir //tickmark controls 176*cdf0e10cSrcweir { 177*cdf0e10cSrcweir long nWidth_1 = ::std::max( m_aCB_TicksInner.CalcMinimumSize().Width(), m_aCB_MinorInner.CalcMinimumSize().Width() ); 178*cdf0e10cSrcweir long nWidth_2 = ::std::max( m_aCB_TicksOuter.CalcMinimumSize().Width(), m_aCB_MinorOuter.CalcMinimumSize().Width() ); 179*cdf0e10cSrcweir 180*cdf0e10cSrcweir long nLeftSpace = nDialogWidth - nWidth_0 - nWidth_1 - nWidth_2 - 3*nDistance; 181*cdf0e10cSrcweir 182*cdf0e10cSrcweir if(nLeftSpace>=0) 183*cdf0e10cSrcweir { 184*cdf0e10cSrcweir m_aFT_Major.SetSizePixel(m_aFT_Major.CalcMinimumSize()); 185*cdf0e10cSrcweir m_aFT_Minor.SetSizePixel(m_aFT_Minor.CalcMinimumSize()); 186*cdf0e10cSrcweir 187*cdf0e10cSrcweir m_aCB_TicksInner.SetSizePixel( m_aCB_TicksInner.CalcMinimumSize() ); 188*cdf0e10cSrcweir m_aCB_MinorInner.SetSizePixel( m_aCB_MinorInner.CalcMinimumSize() ); 189*cdf0e10cSrcweir 190*cdf0e10cSrcweir m_aCB_TicksOuter.SetSizePixel( m_aCB_TicksOuter.CalcMinimumSize() ); 191*cdf0e10cSrcweir m_aCB_MinorOuter.SetSizePixel( m_aCB_MinorOuter.CalcMinimumSize() ); 192*cdf0e10cSrcweir 193*cdf0e10cSrcweir long nXPos = m_aFT_Major.GetPosPixel().X() + nWidth_0 + nDistance; 194*cdf0e10cSrcweir lcl_newXPos( m_aCB_TicksInner, nXPos ); 195*cdf0e10cSrcweir lcl_newXPos( m_aCB_MinorInner, nXPos ); 196*cdf0e10cSrcweir 197*cdf0e10cSrcweir nXPos += nWidth_1 + nDistance; 198*cdf0e10cSrcweir lcl_newXPos( m_aCB_TicksOuter, nXPos ); 199*cdf0e10cSrcweir lcl_newXPos( m_aCB_MinorOuter, nXPos ); 200*cdf0e10cSrcweir 201*cdf0e10cSrcweir nXPos += nWidth_2 + nDistance; 202*cdf0e10cSrcweir lcl_newXPos( m_aFL_Vertical, nXPos ); 203*cdf0e10cSrcweir } 204*cdf0e10cSrcweir } 205*cdf0e10cSrcweir 206*cdf0e10cSrcweir //right alignement of listboxes: 207*cdf0e10cSrcweir { 208*cdf0e10cSrcweir long nLabelRightBorder = m_aLB_PlaceLabels.GetPosPixel().X() + m_aLB_PlaceLabels.GetSizePixel().Width(); 209*cdf0e10cSrcweir long nTickmarksRightBorder = m_aLB_PlaceTicks.GetPosPixel().X() + m_aLB_PlaceTicks.GetSizePixel().Width(); 210*cdf0e10cSrcweir 211*cdf0e10cSrcweir long nNewRightBorder = ::std::max( m_aLB_CrossesAt.GetPosPixel().X() + m_aLB_CrossesAt.GetSizePixel().Width(), nLabelRightBorder); 212*cdf0e10cSrcweir nNewRightBorder = ::std::max( nTickmarksRightBorder, nNewRightBorder ); 213*cdf0e10cSrcweir 214*cdf0e10cSrcweir long nListBoxHeight = m_aLB_PlaceLabels.GetSizePixel().Height(); 215*cdf0e10cSrcweir m_aLB_PlaceLabels.SetSizePixel( Size( m_aLB_PlaceLabels.GetSizePixel().Width()+nNewRightBorder-nLabelRightBorder, nListBoxHeight ) ); 216*cdf0e10cSrcweir m_aLB_PlaceTicks.SetSizePixel( Size( m_aLB_PlaceTicks.GetSizePixel().Width()+nNewRightBorder-nTickmarksRightBorder, nListBoxHeight ) ); 217*cdf0e10cSrcweir } 218*cdf0e10cSrcweir 219*cdf0e10cSrcweir m_aLB_CrossesAt.SetSelectHdl( LINK( this, AxisPositionsTabPage, CrossesAtSelectHdl ) ); 220*cdf0e10cSrcweir m_aLB_CrossesAt.SetDropDownLineCount( m_aLB_CrossesAt.GetEntryCount() ); 221*cdf0e10cSrcweir 222*cdf0e10cSrcweir m_aLB_PlaceLabels.SetSelectHdl( LINK( this, AxisPositionsTabPage, PlaceLabelsSelectHdl ) ); 223*cdf0e10cSrcweir m_aLB_PlaceLabels.SetDropDownLineCount( m_aLB_PlaceLabels.GetEntryCount() ); 224*cdf0e10cSrcweir m_aLB_PlaceTicks.SetDropDownLineCount( m_aLB_PlaceTicks.GetEntryCount() ); 225*cdf0e10cSrcweir m_aCB_TicksInner.SetAccessibleRelationLabeledBy(&m_aFT_Major); 226*cdf0e10cSrcweir m_aCB_TicksOuter.SetAccessibleRelationLabeledBy(&m_aFT_Major); 227*cdf0e10cSrcweir m_aCB_MinorInner.SetAccessibleRelationLabeledBy(&m_aFT_Minor); 228*cdf0e10cSrcweir m_aCB_MinorOuter.SetAccessibleRelationLabeledBy(&m_aFT_Minor); 229*cdf0e10cSrcweir } 230*cdf0e10cSrcweir 231*cdf0e10cSrcweir SfxTabPage* AxisPositionsTabPage::Create(Window* pWindow,const SfxItemSet& rOutAttrs) 232*cdf0e10cSrcweir { 233*cdf0e10cSrcweir return new AxisPositionsTabPage(pWindow, rOutAttrs); 234*cdf0e10cSrcweir } 235*cdf0e10cSrcweir 236*cdf0e10cSrcweir sal_Bool AxisPositionsTabPage::FillItemSet(SfxItemSet& rOutAttrs) 237*cdf0e10cSrcweir { 238*cdf0e10cSrcweir // axis line 239*cdf0e10cSrcweir sal_uInt16 nPos = m_aLB_CrossesAt.GetSelectEntryPos(); 240*cdf0e10cSrcweir rOutAttrs.Put( SfxInt32Item( SCHATTR_AXIS_POSITION, nPos+1 )); 241*cdf0e10cSrcweir if( 2==nPos ) 242*cdf0e10cSrcweir { 243*cdf0e10cSrcweir double fCrossover = m_aED_CrossesAt.GetValue(); 244*cdf0e10cSrcweir if( m_bCrossingAxisIsCategoryAxis ) 245*cdf0e10cSrcweir fCrossover = m_aED_CrossesAtCategory.GetSelectEntryPos()+1; 246*cdf0e10cSrcweir rOutAttrs.Put(SvxDoubleItem(fCrossover,SCHATTR_AXIS_POSITION_VALUE)); 247*cdf0e10cSrcweir } 248*cdf0e10cSrcweir 249*cdf0e10cSrcweir // labels 250*cdf0e10cSrcweir sal_uInt16 nLabelPos = m_aLB_PlaceLabels.GetSelectEntryPos(); 251*cdf0e10cSrcweir if( nLabelPos != LISTBOX_ENTRY_NOTFOUND ) 252*cdf0e10cSrcweir rOutAttrs.Put( SfxInt32Item( SCHATTR_AXIS_LABEL_POSITION, nLabelPos )); 253*cdf0e10cSrcweir 254*cdf0e10cSrcweir // tick marks 255*cdf0e10cSrcweir long nTicks=0; 256*cdf0e10cSrcweir long nMinorTicks=0; 257*cdf0e10cSrcweir 258*cdf0e10cSrcweir if(m_aCB_MinorInner.IsChecked()) 259*cdf0e10cSrcweir nMinorTicks|=CHAXIS_MARK_INNER; 260*cdf0e10cSrcweir if(m_aCB_MinorOuter.IsChecked()) 261*cdf0e10cSrcweir nMinorTicks|=CHAXIS_MARK_OUTER; 262*cdf0e10cSrcweir if(m_aCB_TicksInner.IsChecked()) 263*cdf0e10cSrcweir nTicks|=CHAXIS_MARK_INNER; 264*cdf0e10cSrcweir if(m_aCB_TicksOuter.IsChecked()) 265*cdf0e10cSrcweir nTicks|=CHAXIS_MARK_OUTER; 266*cdf0e10cSrcweir 267*cdf0e10cSrcweir rOutAttrs.Put(SfxInt32Item(SCHATTR_AXIS_TICKS,nTicks)); 268*cdf0e10cSrcweir rOutAttrs.Put(SfxInt32Item(SCHATTR_AXIS_HELPTICKS,nMinorTicks)); 269*cdf0e10cSrcweir 270*cdf0e10cSrcweir sal_uInt16 nMarkPos = m_aLB_PlaceTicks.GetSelectEntryPos(); 271*cdf0e10cSrcweir if( nMarkPos != LISTBOX_ENTRY_NOTFOUND ) 272*cdf0e10cSrcweir rOutAttrs.Put( SfxInt32Item( SCHATTR_AXIS_MARK_POSITION, nMarkPos )); 273*cdf0e10cSrcweir 274*cdf0e10cSrcweir return sal_True; 275*cdf0e10cSrcweir } 276*cdf0e10cSrcweir 277*cdf0e10cSrcweir void AxisPositionsTabPage::Reset(const SfxItemSet& rInAttrs) 278*cdf0e10cSrcweir { 279*cdf0e10cSrcweir //init and enable controls 280*cdf0e10cSrcweir m_aED_CrossesAt.Show( !m_bCrossingAxisIsCategoryAxis ); 281*cdf0e10cSrcweir m_aED_CrossesAtCategory.Show( m_bCrossingAxisIsCategoryAxis ); 282*cdf0e10cSrcweir const sal_Int32 nMaxCount = LISTBOX_ENTRY_NOTFOUND; 283*cdf0e10cSrcweir if( m_bCrossingAxisIsCategoryAxis ) 284*cdf0e10cSrcweir { 285*cdf0e10cSrcweir for( sal_Int32 nN=0; nN<m_aCategories.getLength() && nN<nMaxCount; nN++ ) 286*cdf0e10cSrcweir m_aED_CrossesAtCategory.InsertEntry( m_aCategories[nN] ); 287*cdf0e10cSrcweir 288*cdf0e10cSrcweir sal_uInt16 nCount = m_aED_CrossesAtCategory.GetEntryCount(); 289*cdf0e10cSrcweir if( nCount>30 ) 290*cdf0e10cSrcweir nCount=30; 291*cdf0e10cSrcweir m_aED_CrossesAtCategory.SetDropDownLineCount( nCount ); 292*cdf0e10cSrcweir } 293*cdf0e10cSrcweir 294*cdf0e10cSrcweir if( m_aLB_CrossesAt.GetEntryCount() > 3 ) 295*cdf0e10cSrcweir { 296*cdf0e10cSrcweir if( m_bCrossingAxisIsCategoryAxis ) 297*cdf0e10cSrcweir m_aLB_CrossesAt.RemoveEntry(2); 298*cdf0e10cSrcweir else 299*cdf0e10cSrcweir m_aLB_CrossesAt.RemoveEntry(3); 300*cdf0e10cSrcweir } 301*cdf0e10cSrcweir 302*cdf0e10cSrcweir //fill controls 303*cdf0e10cSrcweir const SfxPoolItem *pPoolItem = NULL; 304*cdf0e10cSrcweir 305*cdf0e10cSrcweir //axis line 306*cdf0e10cSrcweir if(rInAttrs.GetItemState(SCHATTR_AXIS_POSITION,sal_True, &pPoolItem)== SFX_ITEM_SET) 307*cdf0e10cSrcweir { 308*cdf0e10cSrcweir bool bZero = false; 309*cdf0e10cSrcweir sal_uInt16 nPos = (sal_uInt16)static_cast< const SfxInt32Item * >( pPoolItem )->GetValue(); 310*cdf0e10cSrcweir if(nPos==0) 311*cdf0e10cSrcweir { 312*cdf0e10cSrcweir //switch to value 313*cdf0e10cSrcweir bZero = true; 314*cdf0e10cSrcweir nPos = 2; 315*cdf0e10cSrcweir } 316*cdf0e10cSrcweir else 317*cdf0e10cSrcweir nPos--; 318*cdf0e10cSrcweir 319*cdf0e10cSrcweir if( nPos < m_aLB_CrossesAt.GetEntryCount() ) 320*cdf0e10cSrcweir m_aLB_CrossesAt.SelectEntryPos( nPos ); 321*cdf0e10cSrcweir CrossesAtSelectHdl( (void*)0 ); 322*cdf0e10cSrcweir 323*cdf0e10cSrcweir if( rInAttrs.GetItemState(SCHATTR_AXIS_POSITION_VALUE,sal_True, &pPoolItem)== SFX_ITEM_SET || bZero ) 324*cdf0e10cSrcweir { 325*cdf0e10cSrcweir double fCrossover = 0.0; 326*cdf0e10cSrcweir if( !bZero ) 327*cdf0e10cSrcweir fCrossover = (((const SvxDoubleItem*)pPoolItem)->GetValue()); 328*cdf0e10cSrcweir if( m_bCrossingAxisIsCategoryAxis ) 329*cdf0e10cSrcweir m_aED_CrossesAtCategory.SelectEntryPos( static_cast<sal_uInt16>(::rtl::math::round(fCrossover-1.0)) ); 330*cdf0e10cSrcweir else 331*cdf0e10cSrcweir m_aED_CrossesAt.SetValue(fCrossover); 332*cdf0e10cSrcweir } 333*cdf0e10cSrcweir else 334*cdf0e10cSrcweir { 335*cdf0e10cSrcweir m_aED_CrossesAtCategory.SetNoSelection(); 336*cdf0e10cSrcweir m_aED_CrossesAt.SetTextValue(XubString()); 337*cdf0e10cSrcweir } 338*cdf0e10cSrcweir } 339*cdf0e10cSrcweir else 340*cdf0e10cSrcweir { 341*cdf0e10cSrcweir m_aLB_CrossesAt.SetNoSelection(); 342*cdf0e10cSrcweir m_aED_CrossesAt.Enable( sal_False ); 343*cdf0e10cSrcweir } 344*cdf0e10cSrcweir 345*cdf0e10cSrcweir // Labels 346*cdf0e10cSrcweir if( rInAttrs.GetItemState( SCHATTR_AXIS_LABEL_POSITION, sal_False, &pPoolItem ) == SFX_ITEM_SET ) 347*cdf0e10cSrcweir { 348*cdf0e10cSrcweir sal_uInt16 nPos = (sal_uInt16)static_cast< const SfxInt32Item * >( pPoolItem )->GetValue(); 349*cdf0e10cSrcweir if( nPos < m_aLB_PlaceLabels.GetEntryCount() ) 350*cdf0e10cSrcweir m_aLB_PlaceLabels.SelectEntryPos( nPos ); 351*cdf0e10cSrcweir } 352*cdf0e10cSrcweir else 353*cdf0e10cSrcweir m_aLB_PlaceLabels.SetNoSelection(); 354*cdf0e10cSrcweir PlaceLabelsSelectHdl( (void*)0 ); 355*cdf0e10cSrcweir 356*cdf0e10cSrcweir // Tick marks 357*cdf0e10cSrcweir long nTicks=0,nMinorTicks=0; 358*cdf0e10cSrcweir if(rInAttrs.GetItemState(SCHATTR_AXIS_TICKS,sal_True, &pPoolItem)== SFX_ITEM_SET) 359*cdf0e10cSrcweir nTicks=((const SfxInt32Item*)pPoolItem)->GetValue(); 360*cdf0e10cSrcweir if(rInAttrs.GetItemState(SCHATTR_AXIS_HELPTICKS,sal_True, &pPoolItem)== SFX_ITEM_SET) 361*cdf0e10cSrcweir nMinorTicks=((const SfxInt32Item*)pPoolItem)->GetValue(); 362*cdf0e10cSrcweir 363*cdf0e10cSrcweir m_aCB_TicksInner.Check(sal_Bool(nTicks&CHAXIS_MARK_INNER)); 364*cdf0e10cSrcweir m_aCB_TicksOuter.Check(sal_Bool(nTicks&CHAXIS_MARK_OUTER)); 365*cdf0e10cSrcweir m_aCB_MinorInner.Check(sal_Bool(nMinorTicks&CHAXIS_MARK_INNER)); 366*cdf0e10cSrcweir m_aCB_MinorOuter.Check(sal_Bool(nMinorTicks&CHAXIS_MARK_OUTER)); 367*cdf0e10cSrcweir 368*cdf0e10cSrcweir // Tick position 369*cdf0e10cSrcweir if( rInAttrs.GetItemState( SCHATTR_AXIS_MARK_POSITION, sal_False, &pPoolItem ) == SFX_ITEM_SET ) 370*cdf0e10cSrcweir { 371*cdf0e10cSrcweir sal_uInt16 nPos = (sal_uInt16)static_cast< const SfxInt32Item * >( pPoolItem )->GetValue(); 372*cdf0e10cSrcweir if( nPos < m_aLB_PlaceTicks.GetEntryCount() ) 373*cdf0e10cSrcweir m_aLB_PlaceTicks.SelectEntryPos( nPos ); 374*cdf0e10cSrcweir } 375*cdf0e10cSrcweir else 376*cdf0e10cSrcweir m_aLB_PlaceTicks.SetNoSelection(); 377*cdf0e10cSrcweir 378*cdf0e10cSrcweir 379*cdf0e10cSrcweir if( !m_bSupportAxisPositioning ) 380*cdf0e10cSrcweir { 381*cdf0e10cSrcweir m_aFL_AxisLine.Show(false); 382*cdf0e10cSrcweir m_aFT_CrossesAt.Show(false); 383*cdf0e10cSrcweir m_aLB_CrossesAt.Show(false); 384*cdf0e10cSrcweir m_aED_CrossesAt.Show(false); 385*cdf0e10cSrcweir m_aED_CrossesAtCategory.Show(false); 386*cdf0e10cSrcweir m_aCB_AxisBetweenCategories.Show(false); 387*cdf0e10cSrcweir 388*cdf0e10cSrcweir m_aFL_Labels.Show(false); 389*cdf0e10cSrcweir m_aFT_PlaceLabels.Show(false); 390*cdf0e10cSrcweir m_aLB_PlaceLabels.Show(false); 391*cdf0e10cSrcweir m_aFT_LabelDistance.Show(false); 392*cdf0e10cSrcweir m_aED_LabelDistance.Show(false); 393*cdf0e10cSrcweir 394*cdf0e10cSrcweir m_aFL_Vertical.Show(false); 395*cdf0e10cSrcweir m_aFT_PlaceTicks.Show(false); 396*cdf0e10cSrcweir m_aLB_PlaceTicks.Show(false); 397*cdf0e10cSrcweir 398*cdf0e10cSrcweir long nYDiff = m_aFL_AxisLine.GetPosPixel().Y() - m_aFL_Ticks.GetPosPixel().Y(); 399*cdf0e10cSrcweir lcl_shiftY( m_aFL_Ticks, nYDiff ); 400*cdf0e10cSrcweir lcl_shiftY( m_aFT_Major, nYDiff ); 401*cdf0e10cSrcweir lcl_shiftY( m_aCB_TicksInner, nYDiff ); 402*cdf0e10cSrcweir lcl_shiftY( m_aCB_TicksOuter, nYDiff ); 403*cdf0e10cSrcweir 404*cdf0e10cSrcweir lcl_shiftY( m_aFT_Minor, nYDiff ); 405*cdf0e10cSrcweir lcl_shiftY( m_aCB_MinorInner, nYDiff ); 406*cdf0e10cSrcweir lcl_shiftY( m_aCB_MinorOuter, nYDiff ); 407*cdf0e10cSrcweir } 408*cdf0e10cSrcweir else if( !AxisHelper::isAxisPositioningEnabled() ) 409*cdf0e10cSrcweir { 410*cdf0e10cSrcweir m_aFL_AxisLine.Enable(false); 411*cdf0e10cSrcweir m_aFT_CrossesAt.Enable(false); 412*cdf0e10cSrcweir m_aLB_CrossesAt.Enable(false); 413*cdf0e10cSrcweir m_aED_CrossesAt.Enable(false); 414*cdf0e10cSrcweir m_aED_CrossesAtCategory.Enable(false); 415*cdf0e10cSrcweir m_aCB_AxisBetweenCategories.Enable(false); 416*cdf0e10cSrcweir 417*cdf0e10cSrcweir m_aFL_Labels.Enable(false); 418*cdf0e10cSrcweir m_aFT_PlaceLabels.Enable(false); 419*cdf0e10cSrcweir m_aLB_PlaceLabels.Enable(false); 420*cdf0e10cSrcweir m_aFT_LabelDistance.Enable(false); 421*cdf0e10cSrcweir m_aED_LabelDistance.Enable(false); 422*cdf0e10cSrcweir 423*cdf0e10cSrcweir m_aFL_Vertical.Enable(false); 424*cdf0e10cSrcweir m_aFT_PlaceTicks.Enable(false); 425*cdf0e10cSrcweir m_aLB_PlaceTicks.Enable(false); 426*cdf0e10cSrcweir 427*cdf0e10cSrcweir //todo: maybe set a special help id to all those controls 428*cdf0e10cSrcweir } 429*cdf0e10cSrcweir } 430*cdf0e10cSrcweir 431*cdf0e10cSrcweir int AxisPositionsTabPage::DeactivatePage(SfxItemSet* pItemSet) 432*cdf0e10cSrcweir { 433*cdf0e10cSrcweir if( pItemSet ) 434*cdf0e10cSrcweir FillItemSet( *pItemSet ); 435*cdf0e10cSrcweir 436*cdf0e10cSrcweir return LEAVE_PAGE; 437*cdf0e10cSrcweir } 438*cdf0e10cSrcweir 439*cdf0e10cSrcweir void AxisPositionsTabPage::SetNumFormatter( SvNumberFormatter* pFormatter ) 440*cdf0e10cSrcweir { 441*cdf0e10cSrcweir m_pNumFormatter = pFormatter; 442*cdf0e10cSrcweir m_aED_CrossesAt.SetFormatter( m_pNumFormatter ); 443*cdf0e10cSrcweir m_aED_CrossesAt.UseInputStringForFormatting(); 444*cdf0e10cSrcweir 445*cdf0e10cSrcweir const SfxPoolItem *pPoolItem = NULL; 446*cdf0e10cSrcweir if( GetItemSet().GetItemState( SCHATTR_AXIS_CROSSING_MAIN_AXIS_NUMBERFORMAT, sal_True, &pPoolItem ) == SFX_ITEM_SET ) 447*cdf0e10cSrcweir { 448*cdf0e10cSrcweir sal_uLong nFmt = (sal_uLong)((const SfxInt32Item*)pPoolItem)->GetValue(); 449*cdf0e10cSrcweir m_aED_CrossesAt.SetFormatKey( nFmt ); 450*cdf0e10cSrcweir } 451*cdf0e10cSrcweir } 452*cdf0e10cSrcweir 453*cdf0e10cSrcweir void AxisPositionsTabPage::SetCrossingAxisIsCategoryAxis( bool bCrossingAxisIsCategoryAxis ) 454*cdf0e10cSrcweir { 455*cdf0e10cSrcweir m_bCrossingAxisIsCategoryAxis = bCrossingAxisIsCategoryAxis; 456*cdf0e10cSrcweir } 457*cdf0e10cSrcweir 458*cdf0e10cSrcweir void AxisPositionsTabPage::SetCategories( const ::com::sun::star::uno::Sequence< rtl::OUString >& rCategories ) 459*cdf0e10cSrcweir { 460*cdf0e10cSrcweir m_aCategories = rCategories; 461*cdf0e10cSrcweir } 462*cdf0e10cSrcweir 463*cdf0e10cSrcweir void AxisPositionsTabPage::SupportAxisPositioning( bool bSupportAxisPositioning ) 464*cdf0e10cSrcweir { 465*cdf0e10cSrcweir m_bSupportAxisPositioning = bSupportAxisPositioning; 466*cdf0e10cSrcweir } 467*cdf0e10cSrcweir 468*cdf0e10cSrcweir IMPL_LINK ( AxisPositionsTabPage, CrossesAtSelectHdl, void *, EMPTYARG ) 469*cdf0e10cSrcweir { 470*cdf0e10cSrcweir sal_uInt16 nPos = m_aLB_CrossesAt.GetSelectEntryPos(); 471*cdf0e10cSrcweir m_aED_CrossesAt.Show( (2==nPos) && !m_bCrossingAxisIsCategoryAxis ); 472*cdf0e10cSrcweir m_aED_CrossesAtCategory.Show( (2==nPos) && m_bCrossingAxisIsCategoryAxis ); 473*cdf0e10cSrcweir 474*cdf0e10cSrcweir if(! m_aED_CrossesAt.GetText().Len() ) 475*cdf0e10cSrcweir m_aED_CrossesAt.SetValue(0.0); 476*cdf0e10cSrcweir if( 0 == m_aED_CrossesAtCategory.GetSelectEntryCount() ) 477*cdf0e10cSrcweir m_aED_CrossesAtCategory.SelectEntryPos(0); 478*cdf0e10cSrcweir 479*cdf0e10cSrcweir PlaceLabelsSelectHdl( (void*)0 ); 480*cdf0e10cSrcweir return 0; 481*cdf0e10cSrcweir } 482*cdf0e10cSrcweir 483*cdf0e10cSrcweir IMPL_LINK ( AxisPositionsTabPage, PlaceLabelsSelectHdl, void *, EMPTYARG ) 484*cdf0e10cSrcweir { 485*cdf0e10cSrcweir sal_uInt16 nLabelPos = m_aLB_PlaceLabels.GetSelectEntryPos(); 486*cdf0e10cSrcweir 487*cdf0e10cSrcweir bool bEnableTickmarkPlacement = (nLabelPos>1); 488*cdf0e10cSrcweir if( bEnableTickmarkPlacement ) 489*cdf0e10cSrcweir { 490*cdf0e10cSrcweir sal_uInt16 nAxisPos = m_aLB_CrossesAt.GetSelectEntryPos(); 491*cdf0e10cSrcweir if( nLabelPos-2 == nAxisPos ) 492*cdf0e10cSrcweir bEnableTickmarkPlacement=false; 493*cdf0e10cSrcweir } 494*cdf0e10cSrcweir m_aFT_PlaceTicks.Enable(bEnableTickmarkPlacement); 495*cdf0e10cSrcweir m_aLB_PlaceTicks.Enable(bEnableTickmarkPlacement); 496*cdf0e10cSrcweir 497*cdf0e10cSrcweir return 0; 498*cdf0e10cSrcweir } 499*cdf0e10cSrcweir 500*cdf0e10cSrcweir //............................................................................. 501*cdf0e10cSrcweir } //namespace chart 502*cdf0e10cSrcweir //............................................................................. 503