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_Scale.hxx" 31*cdf0e10cSrcweir #include "tp_Scale.hrc" 32*cdf0e10cSrcweir 33*cdf0e10cSrcweir #include "ResId.hxx" 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/chart2/AxisType.hpp> 64*cdf0e10cSrcweir 65*cdf0e10cSrcweir using namespace ::com::sun::star; 66*cdf0e10cSrcweir 67*cdf0e10cSrcweir //............................................................................. 68*cdf0e10cSrcweir namespace chart 69*cdf0e10cSrcweir { 70*cdf0e10cSrcweir //............................................................................. 71*cdf0e10cSrcweir 72*cdf0e10cSrcweir namespace 73*cdf0e10cSrcweir { 74*cdf0e10cSrcweir 75*cdf0e10cSrcweir void lcl_placeControlAtX( Control& rControl, long nNewXPos ) 76*cdf0e10cSrcweir { 77*cdf0e10cSrcweir Point aPos( rControl.GetPosPixel() ); 78*cdf0e10cSrcweir aPos.X() = nNewXPos; 79*cdf0e10cSrcweir rControl.SetPosPixel(aPos); 80*cdf0e10cSrcweir } 81*cdf0e10cSrcweir 82*cdf0e10cSrcweir void lcl_placeControlAtY( Control& rControl, long nNewYPos ) 83*cdf0e10cSrcweir { 84*cdf0e10cSrcweir Point aPos( rControl.GetPosPixel() ); 85*cdf0e10cSrcweir aPos.Y() = nNewYPos; 86*cdf0e10cSrcweir rControl.SetPosPixel(aPos); 87*cdf0e10cSrcweir } 88*cdf0e10cSrcweir 89*cdf0e10cSrcweir void lcl_shiftControls( Control& rEdit, Control& rAuto, long nNewXPos ) 90*cdf0e10cSrcweir { 91*cdf0e10cSrcweir Point aPos( rEdit.GetPosPixel() ); 92*cdf0e10cSrcweir long nShift = nNewXPos - aPos.X(); 93*cdf0e10cSrcweir aPos.X() = nNewXPos; 94*cdf0e10cSrcweir rEdit.SetPosPixel(aPos); 95*cdf0e10cSrcweir 96*cdf0e10cSrcweir aPos = rAuto.GetPosPixel(); 97*cdf0e10cSrcweir aPos.X() += nShift; 98*cdf0e10cSrcweir rAuto.SetPosPixel(aPos); 99*cdf0e10cSrcweir } 100*cdf0e10cSrcweir 101*cdf0e10cSrcweir long lcl_getLabelDistance( Control& rControl ) 102*cdf0e10cSrcweir { 103*cdf0e10cSrcweir return rControl.LogicToPixel( Size(RSC_SP_CTRL_DESC_X, 0), MapMode(MAP_APPFONT) ).Width(); 104*cdf0e10cSrcweir } 105*cdf0e10cSrcweir 106*cdf0e10cSrcweir void lcl_setValue( FormattedField& rFmtField, double fValue ) 107*cdf0e10cSrcweir { 108*cdf0e10cSrcweir rFmtField.SetValue( fValue ); 109*cdf0e10cSrcweir rFmtField.SetDefaultValue( fValue ); 110*cdf0e10cSrcweir } 111*cdf0e10cSrcweir 112*cdf0e10cSrcweir } 113*cdf0e10cSrcweir 114*cdf0e10cSrcweir ScaleTabPage::ScaleTabPage(Window* pWindow,const SfxItemSet& rInAttrs) : 115*cdf0e10cSrcweir SfxTabPage(pWindow, SchResId(TP_SCALE), rInAttrs), 116*cdf0e10cSrcweir 117*cdf0e10cSrcweir aFlScale(this, SchResId(FL_SCALE)), 118*cdf0e10cSrcweir 119*cdf0e10cSrcweir aCbxReverse(this, SchResId(CBX_REVERSE)), 120*cdf0e10cSrcweir aCbxLogarithm(this, SchResId(CBX_LOGARITHM)), 121*cdf0e10cSrcweir 122*cdf0e10cSrcweir m_aTxt_AxisType(this, SchResId (TXT_AXIS_TYPE)), 123*cdf0e10cSrcweir m_aLB_AxisType(this, SchResId(LB_AXIS_TYPE)), 124*cdf0e10cSrcweir 125*cdf0e10cSrcweir aTxtMin (this, SchResId (TXT_MIN)), 126*cdf0e10cSrcweir aFmtFldMin(this, SchResId(EDT_MIN)), 127*cdf0e10cSrcweir aCbxAutoMin(this, SchResId(CBX_AUTO_MIN)), 128*cdf0e10cSrcweir 129*cdf0e10cSrcweir aTxtMax(this, SchResId (TXT_MAX)), 130*cdf0e10cSrcweir aFmtFldMax(this, SchResId(EDT_MAX)), 131*cdf0e10cSrcweir aCbxAutoMax(this, SchResId(CBX_AUTO_MAX)), 132*cdf0e10cSrcweir 133*cdf0e10cSrcweir m_aTxt_TimeResolution(this, SchResId (TXT_TIME_RESOLUTION)), 134*cdf0e10cSrcweir m_aLB_TimeResolution(this, SchResId(LB_TIME_RESOLUTION)), 135*cdf0e10cSrcweir m_aCbx_AutoTimeResolution(this, SchResId(CBX_AUTO_TIME_RESOLUTION)), 136*cdf0e10cSrcweir 137*cdf0e10cSrcweir aTxtMain (this, SchResId (TXT_STEP_MAIN)), 138*cdf0e10cSrcweir aFmtFldStepMain(this, SchResId(EDT_STEP_MAIN)), 139*cdf0e10cSrcweir m_aMt_MainDateStep(this, SchResId(MT_MAIN_DATE_STEP)), 140*cdf0e10cSrcweir m_aLB_MainTimeUnit(this, SchResId(LB_MAIN_TIME_UNIT)), 141*cdf0e10cSrcweir aCbxAutoStepMain(this, SchResId(CBX_AUTO_STEP_MAIN)), 142*cdf0e10cSrcweir 143*cdf0e10cSrcweir aTxtHelpCount (this, SchResId (TXT_STEP_HELP_COUNT)), 144*cdf0e10cSrcweir aTxtHelp (this, SchResId (TXT_STEP_HELP)), 145*cdf0e10cSrcweir aMtStepHelp (this, SchResId (MT_STEPHELP)), 146*cdf0e10cSrcweir m_aLB_HelpTimeUnit(this, SchResId(LB_HELP_TIME_UNIT)), 147*cdf0e10cSrcweir aCbxAutoStepHelp(this, SchResId(CBX_AUTO_STEP_HELP)), 148*cdf0e10cSrcweir 149*cdf0e10cSrcweir aTxtOrigin (this, SchResId (TXT_ORIGIN)), 150*cdf0e10cSrcweir aFmtFldOrigin(this, SchResId(EDT_ORIGIN)), 151*cdf0e10cSrcweir aCbxAutoOrigin(this, SchResId(CBX_AUTO_ORIGIN)), 152*cdf0e10cSrcweir 153*cdf0e10cSrcweir fMin(0.0), 154*cdf0e10cSrcweir fMax(0.0), 155*cdf0e10cSrcweir fStepMain(0.0), 156*cdf0e10cSrcweir nStepHelp(0), 157*cdf0e10cSrcweir fOrigin(0.0), 158*cdf0e10cSrcweir m_nTimeResolution(1), 159*cdf0e10cSrcweir m_nMainTimeUnit(1), 160*cdf0e10cSrcweir m_nHelpTimeUnit(1), 161*cdf0e10cSrcweir m_nAxisType(chart2::AxisType::REALNUMBER), 162*cdf0e10cSrcweir m_bAllowDateAxis(false), 163*cdf0e10cSrcweir pNumFormatter(NULL), 164*cdf0e10cSrcweir m_bShowAxisOrigin(false) 165*cdf0e10cSrcweir { 166*cdf0e10cSrcweir FreeResource(); 167*cdf0e10cSrcweir SetExchangeSupport(); 168*cdf0e10cSrcweir 169*cdf0e10cSrcweir aCbxAutoMin.SetClickHdl(LINK(this, ScaleTabPage, EnableValueHdl)); 170*cdf0e10cSrcweir aCbxAutoMax.SetClickHdl(LINK(this, ScaleTabPage, EnableValueHdl)); 171*cdf0e10cSrcweir aCbxAutoStepMain.SetClickHdl(LINK(this, ScaleTabPage, EnableValueHdl)); 172*cdf0e10cSrcweir aCbxAutoStepHelp.SetClickHdl(LINK(this, ScaleTabPage, EnableValueHdl)); 173*cdf0e10cSrcweir aCbxAutoOrigin.SetClickHdl(LINK(this, ScaleTabPage, EnableValueHdl)); 174*cdf0e10cSrcweir m_aCbx_AutoTimeResolution.SetClickHdl(LINK(this, ScaleTabPage, EnableValueHdl)); 175*cdf0e10cSrcweir 176*cdf0e10cSrcweir m_aLB_AxisType.SetDropDownLineCount(3); 177*cdf0e10cSrcweir m_aLB_AxisType.SetSelectHdl(LINK(this, ScaleTabPage, SelectAxisTypeHdl)); 178*cdf0e10cSrcweir 179*cdf0e10cSrcweir m_aLB_TimeResolution.SetDropDownLineCount(3); 180*cdf0e10cSrcweir m_aLB_MainTimeUnit.SetDropDownLineCount(3); 181*cdf0e10cSrcweir m_aLB_HelpTimeUnit.SetDropDownLineCount(3); 182*cdf0e10cSrcweir 183*cdf0e10cSrcweir aFmtFldMin.SetModifyHdl(LINK(this, ScaleTabPage, FmtFieldModifiedHdl)); 184*cdf0e10cSrcweir aFmtFldMax.SetModifyHdl(LINK(this, ScaleTabPage, FmtFieldModifiedHdl)); 185*cdf0e10cSrcweir aFmtFldStepMain.SetModifyHdl(LINK(this, ScaleTabPage, FmtFieldModifiedHdl)); 186*cdf0e10cSrcweir aFmtFldOrigin.SetModifyHdl(LINK(this, ScaleTabPage, FmtFieldModifiedHdl)); 187*cdf0e10cSrcweir } 188*cdf0e10cSrcweir 189*cdf0e10cSrcweir IMPL_LINK( ScaleTabPage, FmtFieldModifiedHdl, FormattedField*, pFmtFied ) 190*cdf0e10cSrcweir { 191*cdf0e10cSrcweir if( pFmtFied ) 192*cdf0e10cSrcweir pFmtFied->SetDefaultValue( pFmtFied->GetValue() ); 193*cdf0e10cSrcweir return 0; 194*cdf0e10cSrcweir } 195*cdf0e10cSrcweir 196*cdf0e10cSrcweir void ScaleTabPage::StateChanged( StateChangedType nType ) 197*cdf0e10cSrcweir { 198*cdf0e10cSrcweir TabPage::StateChanged( nType ); 199*cdf0e10cSrcweir 200*cdf0e10cSrcweir if( nType == STATE_CHANGE_INITSHOW ) 201*cdf0e10cSrcweir AdjustControlPositions(); 202*cdf0e10cSrcweir } 203*cdf0e10cSrcweir 204*cdf0e10cSrcweir void ScaleTabPage::AdjustControlPositions() 205*cdf0e10cSrcweir { 206*cdf0e10cSrcweir //optimize position of the controls 207*cdf0e10cSrcweir long nLabelWidth = ::std::max( aTxtMin.CalcMinimumSize().Width(), aTxtMax.CalcMinimumSize().Width() ); 208*cdf0e10cSrcweir nLabelWidth = ::std::max( aTxtMain.CalcMinimumSize().Width(), nLabelWidth ); 209*cdf0e10cSrcweir nLabelWidth = ::std::max( aTxtHelp.CalcMinimumSize().Width(), nLabelWidth ); 210*cdf0e10cSrcweir nLabelWidth = ::std::max( aTxtHelpCount.CalcMinimumSize().Width(), nLabelWidth ); 211*cdf0e10cSrcweir nLabelWidth = ::std::max( aTxtOrigin.CalcMinimumSize().Width(), nLabelWidth ); 212*cdf0e10cSrcweir nLabelWidth = ::std::max( m_aTxt_TimeResolution.CalcMinimumSize().Width(), nLabelWidth ); 213*cdf0e10cSrcweir nLabelWidth = ::std::max( m_aTxt_AxisType.CalcMinimumSize().Width(), nLabelWidth ); 214*cdf0e10cSrcweir nLabelWidth+=1; 215*cdf0e10cSrcweir 216*cdf0e10cSrcweir long nLabelDistance = lcl_getLabelDistance(aTxtMin); 217*cdf0e10cSrcweir long nNewXPos = aTxtMin.GetPosPixel().X() + nLabelWidth + nLabelDistance; 218*cdf0e10cSrcweir 219*cdf0e10cSrcweir //ensure that the auto checkboxes are wide enough and have correct size for calculation 220*cdf0e10cSrcweir aCbxAutoMin.SetSizePixel( aCbxAutoMin.CalcMinimumSize() ); 221*cdf0e10cSrcweir aCbxAutoMax.SetSizePixel( aCbxAutoMax.CalcMinimumSize() ); 222*cdf0e10cSrcweir aCbxAutoStepMain.SetSizePixel( aCbxAutoStepMain.CalcMinimumSize() ); 223*cdf0e10cSrcweir aCbxAutoStepHelp.SetSizePixel( aCbxAutoStepHelp.CalcMinimumSize() ); 224*cdf0e10cSrcweir aCbxAutoOrigin.SetSizePixel( aCbxAutoOrigin.CalcMinimumSize() ); 225*cdf0e10cSrcweir m_aCbx_AutoTimeResolution.SetSizePixel( m_aCbx_AutoTimeResolution.CalcMinimumSize() ); 226*cdf0e10cSrcweir 227*cdf0e10cSrcweir //ensure new pos is ok 228*cdf0e10cSrcweir long nWidthOfOtherControls = m_aLB_MainTimeUnit.GetPosPixel().X() + m_aLB_MainTimeUnit.GetSizePixel().Width() - aFmtFldMin.GetPosPixel().X(); 229*cdf0e10cSrcweir long nDialogWidth = GetSizePixel().Width(); 230*cdf0e10cSrcweir 231*cdf0e10cSrcweir long nLeftSpace = nDialogWidth - nNewXPos - nWidthOfOtherControls; 232*cdf0e10cSrcweir if(nLeftSpace>=0) 233*cdf0e10cSrcweir { 234*cdf0e10cSrcweir Size aSize( aTxtMin.GetSizePixel() ); 235*cdf0e10cSrcweir aSize.Width() = nLabelWidth; 236*cdf0e10cSrcweir aTxtMin.SetSizePixel(aSize); 237*cdf0e10cSrcweir aTxtMax.SetSizePixel(aSize); 238*cdf0e10cSrcweir aTxtMain.SetSizePixel(aSize); 239*cdf0e10cSrcweir aTxtHelp.SetSizePixel(aSize); 240*cdf0e10cSrcweir aTxtHelpCount.SetSizePixel(aSize); 241*cdf0e10cSrcweir aTxtOrigin.SetSizePixel(aSize); 242*cdf0e10cSrcweir m_aTxt_TimeResolution.SetSizePixel(aSize); 243*cdf0e10cSrcweir m_aTxt_AxisType.SetSizePixel(aSize); 244*cdf0e10cSrcweir 245*cdf0e10cSrcweir long nOrgAutoCheckX = aCbxAutoMin.GetPosPixel().X(); 246*cdf0e10cSrcweir lcl_placeControlAtX( aCbxAutoStepMain, nOrgAutoCheckX ); 247*cdf0e10cSrcweir lcl_placeControlAtX( aCbxAutoStepHelp, nOrgAutoCheckX ); 248*cdf0e10cSrcweir 249*cdf0e10cSrcweir lcl_shiftControls( aFmtFldMin, aCbxAutoMin, nNewXPos ); 250*cdf0e10cSrcweir lcl_shiftControls( aFmtFldMax, aCbxAutoMax, nNewXPos ); 251*cdf0e10cSrcweir lcl_shiftControls( aFmtFldStepMain, aCbxAutoStepMain, nNewXPos ); 252*cdf0e10cSrcweir lcl_placeControlAtX( m_aMt_MainDateStep, aFmtFldStepMain.GetPosPixel().X() ); 253*cdf0e10cSrcweir lcl_shiftControls( aMtStepHelp, aCbxAutoStepHelp, nNewXPos ); 254*cdf0e10cSrcweir lcl_shiftControls( aFmtFldOrigin, aCbxAutoOrigin, nNewXPos ); 255*cdf0e10cSrcweir lcl_shiftControls( m_aLB_TimeResolution, m_aCbx_AutoTimeResolution, nNewXPos ); 256*cdf0e10cSrcweir lcl_placeControlAtX( m_aLB_AxisType, nNewXPos ); 257*cdf0e10cSrcweir 258*cdf0e10cSrcweir nNewXPos = aCbxAutoStepMain.GetPosPixel().X() + aCbxAutoStepMain.GetSizePixel().Width() + nLabelDistance; 259*cdf0e10cSrcweir lcl_placeControlAtX( m_aLB_MainTimeUnit, nNewXPos ); 260*cdf0e10cSrcweir lcl_placeControlAtX( m_aLB_HelpTimeUnit, nNewXPos ); 261*cdf0e10cSrcweir } 262*cdf0e10cSrcweir PlaceIntervalControlsAccordingToAxisType(); 263*cdf0e10cSrcweir } 264*cdf0e10cSrcweir 265*cdf0e10cSrcweir void ScaleTabPage::PlaceIntervalControlsAccordingToAxisType() 266*cdf0e10cSrcweir { 267*cdf0e10cSrcweir long nMinX = std::min( aCbxAutoStepMain.GetPosPixel().X(), m_aLB_MainTimeUnit.GetPosPixel().X() ); 268*cdf0e10cSrcweir long nLabelDistance = lcl_getLabelDistance(aTxtMin); 269*cdf0e10cSrcweir long nListWidth = m_aLB_MainTimeUnit.GetSizePixel().Width(); 270*cdf0e10cSrcweir 271*cdf0e10cSrcweir if( chart2::AxisType::DATE == m_nAxisType ) 272*cdf0e10cSrcweir { 273*cdf0e10cSrcweir lcl_placeControlAtX( m_aLB_MainTimeUnit, nMinX ); 274*cdf0e10cSrcweir lcl_placeControlAtX( m_aLB_HelpTimeUnit, nMinX ); 275*cdf0e10cSrcweir long nSecondX = nMinX + nListWidth + nLabelDistance; 276*cdf0e10cSrcweir lcl_placeControlAtX( aCbxAutoStepMain, nSecondX ); 277*cdf0e10cSrcweir lcl_placeControlAtX( aCbxAutoStepHelp, nSecondX ); 278*cdf0e10cSrcweir 279*cdf0e10cSrcweir long nOne = m_aMt_MainDateStep.LogicToPixel( Size(0, 1), MapMode(MAP_APPFONT) ).Height(); 280*cdf0e10cSrcweir 281*cdf0e10cSrcweir long nYMajor = m_aMt_MainDateStep.GetPosPixel().Y(); 282*cdf0e10cSrcweir lcl_placeControlAtY( aCbxAutoStepMain , nYMajor+(3*nOne)); 283*cdf0e10cSrcweir lcl_placeControlAtY( aTxtMain , nYMajor+nOne+nOne); 284*cdf0e10cSrcweir 285*cdf0e10cSrcweir long nYMinor = m_aLB_HelpTimeUnit.GetPosPixel().Y(); 286*cdf0e10cSrcweir lcl_placeControlAtY( aMtStepHelp , nYMinor ); 287*cdf0e10cSrcweir lcl_placeControlAtY( aCbxAutoStepHelp , nYMinor+(3*nOne)); 288*cdf0e10cSrcweir } 289*cdf0e10cSrcweir else 290*cdf0e10cSrcweir { 291*cdf0e10cSrcweir lcl_placeControlAtX( aCbxAutoStepMain, nMinX ); 292*cdf0e10cSrcweir lcl_placeControlAtX( aCbxAutoStepHelp, nMinX ); 293*cdf0e10cSrcweir long nSecondX = nMinX + aCbxAutoStepMain.GetSizePixel().Width() + nLabelDistance; 294*cdf0e10cSrcweir long nSecondXMax = GetSizePixel().Width() - nListWidth; 295*cdf0e10cSrcweir if( nSecondX > nSecondXMax ) 296*cdf0e10cSrcweir nSecondX = nSecondXMax; 297*cdf0e10cSrcweir lcl_placeControlAtX( m_aLB_MainTimeUnit, nSecondX ); 298*cdf0e10cSrcweir lcl_placeControlAtX( m_aLB_HelpTimeUnit, nSecondX ); 299*cdf0e10cSrcweir } 300*cdf0e10cSrcweir } 301*cdf0e10cSrcweir 302*cdf0e10cSrcweir void ScaleTabPage::EnableControls() 303*cdf0e10cSrcweir { 304*cdf0e10cSrcweir bool bValueAxis = chart2::AxisType::REALNUMBER == m_nAxisType || chart2::AxisType::PERCENT == m_nAxisType || chart2::AxisType::DATE == m_nAxisType; 305*cdf0e10cSrcweir bool bDateAxis = chart2::AxisType::DATE == m_nAxisType; 306*cdf0e10cSrcweir 307*cdf0e10cSrcweir m_aTxt_AxisType.Show(m_bAllowDateAxis); 308*cdf0e10cSrcweir m_aLB_AxisType.Show(m_bAllowDateAxis); 309*cdf0e10cSrcweir 310*cdf0e10cSrcweir aCbxLogarithm.Show( bValueAxis && !bDateAxis ); 311*cdf0e10cSrcweir aTxtMin.Show( bValueAxis ); 312*cdf0e10cSrcweir aFmtFldMin.Show( bValueAxis ); 313*cdf0e10cSrcweir aCbxAutoMin.Show( bValueAxis ); 314*cdf0e10cSrcweir aTxtMax.Show( bValueAxis ); 315*cdf0e10cSrcweir aFmtFldMax.Show( bValueAxis ); 316*cdf0e10cSrcweir aCbxAutoMax.Show( bValueAxis ); 317*cdf0e10cSrcweir aTxtMain.Show( bValueAxis ); 318*cdf0e10cSrcweir aFmtFldStepMain.Show( bValueAxis ); 319*cdf0e10cSrcweir aCbxAutoStepMain.Show( bValueAxis ); 320*cdf0e10cSrcweir aTxtHelp.Show( bValueAxis ); 321*cdf0e10cSrcweir aTxtHelpCount.Show( bValueAxis ); 322*cdf0e10cSrcweir aMtStepHelp.Show( bValueAxis ); 323*cdf0e10cSrcweir aCbxAutoStepHelp.Show( bValueAxis ); 324*cdf0e10cSrcweir 325*cdf0e10cSrcweir aTxtOrigin.Show( m_bShowAxisOrigin && bValueAxis ); 326*cdf0e10cSrcweir aFmtFldOrigin.Show( m_bShowAxisOrigin && bValueAxis ); 327*cdf0e10cSrcweir aCbxAutoOrigin.Show( m_bShowAxisOrigin && bValueAxis ); 328*cdf0e10cSrcweir 329*cdf0e10cSrcweir aTxtHelpCount.Show( bValueAxis && !bDateAxis ); 330*cdf0e10cSrcweir aTxtHelp.Show( bDateAxis ); 331*cdf0e10cSrcweir 332*cdf0e10cSrcweir m_aTxt_TimeResolution.Show( bDateAxis ); 333*cdf0e10cSrcweir m_aLB_TimeResolution.Show( bDateAxis ); 334*cdf0e10cSrcweir m_aCbx_AutoTimeResolution.Show( bDateAxis ); 335*cdf0e10cSrcweir 336*cdf0e10cSrcweir bool bWasDateAxis = m_aMt_MainDateStep.IsVisible(); 337*cdf0e10cSrcweir if( bWasDateAxis != bDateAxis ) 338*cdf0e10cSrcweir { 339*cdf0e10cSrcweir //transport value from one to other control 340*cdf0e10cSrcweir if( bWasDateAxis ) 341*cdf0e10cSrcweir lcl_setValue( aFmtFldStepMain, m_aMt_MainDateStep.GetValue() ); 342*cdf0e10cSrcweir else 343*cdf0e10cSrcweir m_aMt_MainDateStep.SetValue( static_cast<sal_Int32>(aFmtFldStepMain.GetValue()) ); 344*cdf0e10cSrcweir } 345*cdf0e10cSrcweir aFmtFldStepMain.Show( bValueAxis && !bDateAxis ); 346*cdf0e10cSrcweir m_aMt_MainDateStep.Show( bDateAxis ); 347*cdf0e10cSrcweir 348*cdf0e10cSrcweir m_aLB_MainTimeUnit.Show( bDateAxis ); 349*cdf0e10cSrcweir m_aLB_HelpTimeUnit.Show( bDateAxis ); 350*cdf0e10cSrcweir 351*cdf0e10cSrcweir EnableValueHdl(&aCbxAutoMin); 352*cdf0e10cSrcweir EnableValueHdl(&aCbxAutoMax); 353*cdf0e10cSrcweir EnableValueHdl(&aCbxAutoStepMain); 354*cdf0e10cSrcweir EnableValueHdl(&aCbxAutoStepHelp); 355*cdf0e10cSrcweir EnableValueHdl(&aCbxAutoOrigin); 356*cdf0e10cSrcweir EnableValueHdl(&m_aCbx_AutoTimeResolution); 357*cdf0e10cSrcweir } 358*cdf0e10cSrcweir 359*cdf0e10cSrcweir IMPL_LINK( ScaleTabPage, EnableValueHdl, CheckBox *, pCbx ) 360*cdf0e10cSrcweir { 361*cdf0e10cSrcweir bool bEnable = pCbx && !pCbx->IsChecked() && pCbx->IsEnabled(); 362*cdf0e10cSrcweir if (pCbx == &aCbxAutoMin) 363*cdf0e10cSrcweir { 364*cdf0e10cSrcweir aFmtFldMin.Enable( bEnable ); 365*cdf0e10cSrcweir } 366*cdf0e10cSrcweir else if (pCbx == &aCbxAutoMax) 367*cdf0e10cSrcweir { 368*cdf0e10cSrcweir aFmtFldMax.Enable( bEnable ); 369*cdf0e10cSrcweir } 370*cdf0e10cSrcweir else if (pCbx == &aCbxAutoStepMain) 371*cdf0e10cSrcweir { 372*cdf0e10cSrcweir aFmtFldStepMain.Enable( bEnable ); 373*cdf0e10cSrcweir m_aMt_MainDateStep.Enable( bEnable ); 374*cdf0e10cSrcweir m_aLB_MainTimeUnit.Enable( bEnable ); 375*cdf0e10cSrcweir } 376*cdf0e10cSrcweir else if (pCbx == &aCbxAutoStepHelp) 377*cdf0e10cSrcweir { 378*cdf0e10cSrcweir aMtStepHelp.Enable( bEnable ); 379*cdf0e10cSrcweir m_aLB_HelpTimeUnit.Enable( bEnable ); 380*cdf0e10cSrcweir } 381*cdf0e10cSrcweir else if (pCbx == &m_aCbx_AutoTimeResolution) 382*cdf0e10cSrcweir { 383*cdf0e10cSrcweir m_aLB_TimeResolution.Enable( bEnable ); 384*cdf0e10cSrcweir } 385*cdf0e10cSrcweir else if (pCbx == &aCbxAutoOrigin) 386*cdf0e10cSrcweir { 387*cdf0e10cSrcweir aFmtFldOrigin.Enable( bEnable ); 388*cdf0e10cSrcweir } 389*cdf0e10cSrcweir return 0; 390*cdf0e10cSrcweir } 391*cdf0e10cSrcweir 392*cdf0e10cSrcweir enum AxisTypeListBoxEntry 393*cdf0e10cSrcweir { 394*cdf0e10cSrcweir TYPE_AUTO=0, 395*cdf0e10cSrcweir TYPE_TEXT=1, 396*cdf0e10cSrcweir TYPE_DATE=2 397*cdf0e10cSrcweir }; 398*cdf0e10cSrcweir 399*cdf0e10cSrcweir IMPL_LINK( ScaleTabPage, SelectAxisTypeHdl, void *, EMPTYARG ) 400*cdf0e10cSrcweir { 401*cdf0e10cSrcweir sal_uInt16 nPos = m_aLB_AxisType.GetSelectEntryPos(); 402*cdf0e10cSrcweir if( nPos==TYPE_DATE ) 403*cdf0e10cSrcweir m_nAxisType = chart2::AxisType::DATE; 404*cdf0e10cSrcweir else 405*cdf0e10cSrcweir m_nAxisType = chart2::AxisType::CATEGORY; 406*cdf0e10cSrcweir if( chart2::AxisType::DATE == m_nAxisType ) 407*cdf0e10cSrcweir aCbxLogarithm.Check(false); 408*cdf0e10cSrcweir EnableControls(); 409*cdf0e10cSrcweir PlaceIntervalControlsAccordingToAxisType(); 410*cdf0e10cSrcweir SetNumFormat(); 411*cdf0e10cSrcweir return 0; 412*cdf0e10cSrcweir } 413*cdf0e10cSrcweir 414*cdf0e10cSrcweir SfxTabPage* ScaleTabPage::Create(Window* pWindow,const SfxItemSet& rOutAttrs) 415*cdf0e10cSrcweir { 416*cdf0e10cSrcweir return new ScaleTabPage(pWindow, rOutAttrs); 417*cdf0e10cSrcweir } 418*cdf0e10cSrcweir 419*cdf0e10cSrcweir sal_Bool ScaleTabPage::FillItemSet(SfxItemSet& rOutAttrs) 420*cdf0e10cSrcweir { 421*cdf0e10cSrcweir DBG_ASSERT( pNumFormatter, "No NumberFormatter available" ); 422*cdf0e10cSrcweir 423*cdf0e10cSrcweir rOutAttrs.Put(SfxInt32Item(SCHATTR_AXISTYPE, m_nAxisType)); 424*cdf0e10cSrcweir if(m_bAllowDateAxis) 425*cdf0e10cSrcweir rOutAttrs.Put(SfxBoolItem(SCHATTR_AXIS_AUTO_DATEAXIS, TYPE_AUTO==m_aLB_AxisType.GetSelectEntryPos())); 426*cdf0e10cSrcweir 427*cdf0e10cSrcweir bool bAutoScale = false; 428*cdf0e10cSrcweir if( m_nAxisType==chart2::AxisType::CATEGORY ) 429*cdf0e10cSrcweir bAutoScale = true;//reset scaling for category charts 430*cdf0e10cSrcweir 431*cdf0e10cSrcweir rOutAttrs.Put(SfxBoolItem(SCHATTR_AXIS_AUTO_MIN ,bAutoScale || aCbxAutoMin.IsChecked())); 432*cdf0e10cSrcweir rOutAttrs.Put(SfxBoolItem(SCHATTR_AXIS_AUTO_MAX ,bAutoScale || aCbxAutoMax.IsChecked())); 433*cdf0e10cSrcweir rOutAttrs.Put(SfxBoolItem(SCHATTR_AXIS_AUTO_STEP_HELP,bAutoScale || aCbxAutoStepHelp.IsChecked())); 434*cdf0e10cSrcweir rOutAttrs.Put(SfxBoolItem(SCHATTR_AXIS_AUTO_ORIGIN ,bAutoScale || aCbxAutoOrigin.IsChecked())); 435*cdf0e10cSrcweir rOutAttrs.Put(SfxBoolItem(SCHATTR_AXIS_LOGARITHM ,aCbxLogarithm.IsChecked())); 436*cdf0e10cSrcweir rOutAttrs.Put(SfxBoolItem(SCHATTR_AXIS_REVERSE ,aCbxReverse.IsChecked())); 437*cdf0e10cSrcweir rOutAttrs.Put(SvxDoubleItem(fMax , SCHATTR_AXIS_MAX)); 438*cdf0e10cSrcweir rOutAttrs.Put(SvxDoubleItem(fMin , SCHATTR_AXIS_MIN)); 439*cdf0e10cSrcweir rOutAttrs.Put(SfxInt32Item(SCHATTR_AXIS_STEP_HELP, nStepHelp)); 440*cdf0e10cSrcweir rOutAttrs.Put(SvxDoubleItem(fOrigin , SCHATTR_AXIS_ORIGIN)); 441*cdf0e10cSrcweir 442*cdf0e10cSrcweir rOutAttrs.Put(SfxBoolItem(SCHATTR_AXIS_AUTO_STEP_MAIN,bAutoScale || aCbxAutoStepMain.IsChecked())); 443*cdf0e10cSrcweir rOutAttrs.Put(SvxDoubleItem(fStepMain,SCHATTR_AXIS_STEP_MAIN)); 444*cdf0e10cSrcweir 445*cdf0e10cSrcweir rOutAttrs.Put(SfxBoolItem(SCHATTR_AXIS_AUTO_TIME_RESOLUTION,bAutoScale || m_aCbx_AutoTimeResolution.IsChecked())); 446*cdf0e10cSrcweir rOutAttrs.Put(SfxInt32Item(SCHATTR_AXIS_TIME_RESOLUTION,m_nTimeResolution)); 447*cdf0e10cSrcweir 448*cdf0e10cSrcweir rOutAttrs.Put(SfxInt32Item(SCHATTR_AXIS_MAIN_TIME_UNIT,m_nMainTimeUnit)); 449*cdf0e10cSrcweir rOutAttrs.Put(SfxInt32Item(SCHATTR_AXIS_HELP_TIME_UNIT,m_nHelpTimeUnit)); 450*cdf0e10cSrcweir 451*cdf0e10cSrcweir return sal_True; 452*cdf0e10cSrcweir } 453*cdf0e10cSrcweir 454*cdf0e10cSrcweir void ScaleTabPage::Reset(const SfxItemSet& rInAttrs) 455*cdf0e10cSrcweir { 456*cdf0e10cSrcweir DBG_ASSERT( pNumFormatter, "No NumberFormatter available" ); 457*cdf0e10cSrcweir if(!pNumFormatter) 458*cdf0e10cSrcweir return; 459*cdf0e10cSrcweir 460*cdf0e10cSrcweir const SfxPoolItem *pPoolItem = NULL; 461*cdf0e10cSrcweir if (rInAttrs.GetItemState(SCHATTR_AXIS_ALLOW_DATEAXIS, sal_True, &pPoolItem) == SFX_ITEM_SET) 462*cdf0e10cSrcweir m_bAllowDateAxis = (bool) ((const SfxBoolItem*)pPoolItem)->GetValue(); 463*cdf0e10cSrcweir m_nAxisType=chart2::AxisType::REALNUMBER; 464*cdf0e10cSrcweir if (rInAttrs.GetItemState(SCHATTR_AXISTYPE, sal_True, &pPoolItem) == SFX_ITEM_SET) 465*cdf0e10cSrcweir m_nAxisType = (int) ((const SfxInt32Item*)pPoolItem)->GetValue(); 466*cdf0e10cSrcweir if( m_nAxisType==chart2::AxisType::DATE && !m_bAllowDateAxis ) 467*cdf0e10cSrcweir m_nAxisType=chart2::AxisType::CATEGORY; 468*cdf0e10cSrcweir if( m_bAllowDateAxis ) 469*cdf0e10cSrcweir { 470*cdf0e10cSrcweir bool bAutoDateAxis = false; 471*cdf0e10cSrcweir if (rInAttrs.GetItemState(SCHATTR_AXIS_AUTO_DATEAXIS, sal_True, &pPoolItem) == SFX_ITEM_SET) 472*cdf0e10cSrcweir bAutoDateAxis = (bool) ((const SfxBoolItem*)pPoolItem)->GetValue(); 473*cdf0e10cSrcweir 474*cdf0e10cSrcweir sal_uInt16 nPos = 0; 475*cdf0e10cSrcweir if( m_nAxisType==chart2::AxisType::DATE ) 476*cdf0e10cSrcweir nPos=TYPE_DATE; 477*cdf0e10cSrcweir else if( bAutoDateAxis ) 478*cdf0e10cSrcweir nPos=TYPE_AUTO; 479*cdf0e10cSrcweir else 480*cdf0e10cSrcweir nPos=TYPE_TEXT; 481*cdf0e10cSrcweir m_aLB_AxisType.SelectEntryPos( nPos ); 482*cdf0e10cSrcweir } 483*cdf0e10cSrcweir 484*cdf0e10cSrcweir if( m_bAllowDateAxis ) 485*cdf0e10cSrcweir aCbxReverse.SetHelpId("chart2:CheckBox:TP_SCALE:CBX_REVERSE:MayBeDateAxis"); 486*cdf0e10cSrcweir else if( m_nAxisType==chart2::AxisType::CATEGORY || m_nAxisType==chart2::AxisType::SERIES ) 487*cdf0e10cSrcweir aCbxReverse.SetHelpId("chart2:CheckBox:TP_SCALE:CBX_REVERSE:Category"); 488*cdf0e10cSrcweir 489*cdf0e10cSrcweir PlaceIntervalControlsAccordingToAxisType(); 490*cdf0e10cSrcweir 491*cdf0e10cSrcweir aCbxAutoMin.Check( true ); 492*cdf0e10cSrcweir aCbxAutoMax.Check( true ); 493*cdf0e10cSrcweir aCbxAutoStepMain.Check( true ); 494*cdf0e10cSrcweir aCbxAutoStepHelp.Check( true ); 495*cdf0e10cSrcweir aCbxAutoOrigin.Check( true ); 496*cdf0e10cSrcweir m_aCbx_AutoTimeResolution.Check( true ); 497*cdf0e10cSrcweir 498*cdf0e10cSrcweir if (rInAttrs.GetItemState(SCHATTR_AXIS_AUTO_MIN,sal_True,&pPoolItem) == SFX_ITEM_SET) 499*cdf0e10cSrcweir aCbxAutoMin.Check(((const SfxBoolItem*)pPoolItem)->GetValue()); 500*cdf0e10cSrcweir 501*cdf0e10cSrcweir if (rInAttrs.GetItemState(SCHATTR_AXIS_MIN,sal_True, &pPoolItem) == SFX_ITEM_SET) 502*cdf0e10cSrcweir { 503*cdf0e10cSrcweir fMin = ((const SvxDoubleItem*)pPoolItem)->GetValue(); 504*cdf0e10cSrcweir lcl_setValue( aFmtFldMin, fMin ); 505*cdf0e10cSrcweir } 506*cdf0e10cSrcweir 507*cdf0e10cSrcweir if (rInAttrs.GetItemState(SCHATTR_AXIS_AUTO_MAX,sal_True, &pPoolItem) == SFX_ITEM_SET) 508*cdf0e10cSrcweir aCbxAutoMax.Check(((const SfxBoolItem*)pPoolItem)->GetValue()); 509*cdf0e10cSrcweir 510*cdf0e10cSrcweir if (rInAttrs.GetItemState(SCHATTR_AXIS_MAX,sal_True, &pPoolItem) == SFX_ITEM_SET) 511*cdf0e10cSrcweir { 512*cdf0e10cSrcweir fMax = ((const SvxDoubleItem*)pPoolItem)->GetValue(); 513*cdf0e10cSrcweir lcl_setValue( aFmtFldMax, fMax ); 514*cdf0e10cSrcweir } 515*cdf0e10cSrcweir 516*cdf0e10cSrcweir if (rInAttrs.GetItemState(SCHATTR_AXIS_AUTO_STEP_MAIN,sal_True, &pPoolItem) == SFX_ITEM_SET) 517*cdf0e10cSrcweir aCbxAutoStepMain.Check(((const SfxBoolItem*)pPoolItem)->GetValue()); 518*cdf0e10cSrcweir 519*cdf0e10cSrcweir if (rInAttrs.GetItemState(SCHATTR_AXIS_STEP_MAIN,sal_True, &pPoolItem) == SFX_ITEM_SET) 520*cdf0e10cSrcweir { 521*cdf0e10cSrcweir fStepMain = ((const SvxDoubleItem*)pPoolItem)->GetValue(); 522*cdf0e10cSrcweir lcl_setValue( aFmtFldStepMain, fStepMain ); 523*cdf0e10cSrcweir m_aMt_MainDateStep.SetValue( static_cast<sal_Int32>(fStepMain) ); 524*cdf0e10cSrcweir } 525*cdf0e10cSrcweir if (rInAttrs.GetItemState(SCHATTR_AXIS_AUTO_STEP_HELP,sal_True, &pPoolItem) == SFX_ITEM_SET) 526*cdf0e10cSrcweir aCbxAutoStepHelp.Check(((const SfxBoolItem*)pPoolItem)->GetValue()); 527*cdf0e10cSrcweir if (rInAttrs.GetItemState(SCHATTR_AXIS_LOGARITHM,sal_True, &pPoolItem) == SFX_ITEM_SET) 528*cdf0e10cSrcweir aCbxLogarithm.Check(((const SfxBoolItem*)pPoolItem)->GetValue()); 529*cdf0e10cSrcweir if (rInAttrs.GetItemState(SCHATTR_AXIS_REVERSE,sal_True, &pPoolItem) == SFX_ITEM_SET) 530*cdf0e10cSrcweir aCbxReverse.Check(((const SfxBoolItem*)pPoolItem)->GetValue()); 531*cdf0e10cSrcweir if (rInAttrs.GetItemState(SCHATTR_AXIS_STEP_HELP,sal_True, &pPoolItem) == SFX_ITEM_SET) 532*cdf0e10cSrcweir { 533*cdf0e10cSrcweir nStepHelp = ((const SfxInt32Item*)pPoolItem)->GetValue(); 534*cdf0e10cSrcweir aMtStepHelp.SetValue( nStepHelp ); 535*cdf0e10cSrcweir } 536*cdf0e10cSrcweir if (rInAttrs.GetItemState(SCHATTR_AXIS_AUTO_ORIGIN,sal_True, &pPoolItem) == SFX_ITEM_SET) 537*cdf0e10cSrcweir aCbxAutoOrigin.Check(((const SfxBoolItem*)pPoolItem)->GetValue()); 538*cdf0e10cSrcweir if (rInAttrs.GetItemState(SCHATTR_AXIS_ORIGIN,sal_True, &pPoolItem) == SFX_ITEM_SET) 539*cdf0e10cSrcweir { 540*cdf0e10cSrcweir fOrigin = ((const SvxDoubleItem*)pPoolItem)->GetValue(); 541*cdf0e10cSrcweir lcl_setValue( aFmtFldOrigin, fOrigin ); 542*cdf0e10cSrcweir } 543*cdf0e10cSrcweir 544*cdf0e10cSrcweir if (rInAttrs.GetItemState(SCHATTR_AXIS_AUTO_TIME_RESOLUTION,sal_True, &pPoolItem) == SFX_ITEM_SET) 545*cdf0e10cSrcweir m_aCbx_AutoTimeResolution.Check(((const SfxBoolItem*)pPoolItem)->GetValue()); 546*cdf0e10cSrcweir if (rInAttrs.GetItemState(SCHATTR_AXIS_TIME_RESOLUTION,sal_True, &pPoolItem) == SFX_ITEM_SET) 547*cdf0e10cSrcweir { 548*cdf0e10cSrcweir m_nTimeResolution = ((const SfxInt32Item*)pPoolItem)->GetValue(); 549*cdf0e10cSrcweir m_aLB_TimeResolution.SelectEntryPos( m_nTimeResolution ); 550*cdf0e10cSrcweir } 551*cdf0e10cSrcweir 552*cdf0e10cSrcweir if (rInAttrs.GetItemState(SCHATTR_AXIS_MAIN_TIME_UNIT,sal_True, &pPoolItem) == SFX_ITEM_SET) 553*cdf0e10cSrcweir { 554*cdf0e10cSrcweir m_nMainTimeUnit = ((const SfxInt32Item*)pPoolItem)->GetValue(); 555*cdf0e10cSrcweir m_aLB_MainTimeUnit.SelectEntryPos( m_nMainTimeUnit ); 556*cdf0e10cSrcweir } 557*cdf0e10cSrcweir if (rInAttrs.GetItemState(SCHATTR_AXIS_HELP_TIME_UNIT,sal_True, &pPoolItem) == SFX_ITEM_SET) 558*cdf0e10cSrcweir { 559*cdf0e10cSrcweir m_nHelpTimeUnit = ((const SfxInt32Item*)pPoolItem)->GetValue(); 560*cdf0e10cSrcweir m_aLB_HelpTimeUnit.SelectEntryPos( m_nHelpTimeUnit ); 561*cdf0e10cSrcweir } 562*cdf0e10cSrcweir 563*cdf0e10cSrcweir EnableControls(); 564*cdf0e10cSrcweir SetNumFormat(); 565*cdf0e10cSrcweir } 566*cdf0e10cSrcweir 567*cdf0e10cSrcweir int ScaleTabPage::DeactivatePage(SfxItemSet* pItemSet) 568*cdf0e10cSrcweir { 569*cdf0e10cSrcweir if( !pNumFormatter ) 570*cdf0e10cSrcweir { 571*cdf0e10cSrcweir DBG_ERROR( "No NumberFormatter available" ); 572*cdf0e10cSrcweir return LEAVE_PAGE; 573*cdf0e10cSrcweir } 574*cdf0e10cSrcweir 575*cdf0e10cSrcweir bool bDateAxis = chart2::AxisType::DATE == m_nAxisType; 576*cdf0e10cSrcweir 577*cdf0e10cSrcweir sal_uInt32 nIndex = pNumFormatter->GetStandardIndex(LANGUAGE_SYSTEM); 578*cdf0e10cSrcweir const SfxPoolItem *pPoolItem = NULL; 579*cdf0e10cSrcweir if( GetItemSet().GetItemState( SID_ATTR_NUMBERFORMAT_VALUE, sal_True, &pPoolItem ) == SFX_ITEM_SET ) 580*cdf0e10cSrcweir nIndex = static_cast< sal_uInt32 >( static_cast< const SfxInt32Item* >(pPoolItem)->GetValue()); 581*cdf0e10cSrcweir else 582*cdf0e10cSrcweir { 583*cdf0e10cSrcweir OSL_ENSURE( false, "Using Standard Language" ); 584*cdf0e10cSrcweir } 585*cdf0e10cSrcweir 586*cdf0e10cSrcweir Control* pControl = NULL; 587*cdf0e10cSrcweir sal_uInt16 nErrStrId = 0; 588*cdf0e10cSrcweir double fDummy; 589*cdf0e10cSrcweir 590*cdf0e10cSrcweir fMax = aFmtFldMax.GetValue(); 591*cdf0e10cSrcweir fMin = aFmtFldMin.GetValue(); 592*cdf0e10cSrcweir fOrigin = aFmtFldOrigin.GetValue(); 593*cdf0e10cSrcweir fStepMain = bDateAxis ? m_aMt_MainDateStep.GetValue() : aFmtFldStepMain.GetValue(); 594*cdf0e10cSrcweir nStepHelp = static_cast< sal_Int32 >( aMtStepHelp.GetValue()); 595*cdf0e10cSrcweir m_nTimeResolution = m_aLB_TimeResolution.GetSelectEntryPos(); 596*cdf0e10cSrcweir m_nMainTimeUnit = m_aLB_MainTimeUnit.GetSelectEntryPos(); 597*cdf0e10cSrcweir m_nHelpTimeUnit = m_aLB_HelpTimeUnit.GetSelectEntryPos(); 598*cdf0e10cSrcweir 599*cdf0e10cSrcweir if( chart2::AxisType::REALNUMBER != m_nAxisType ) 600*cdf0e10cSrcweir aCbxLogarithm.Show( false ); 601*cdf0e10cSrcweir 602*cdf0e10cSrcweir //check wich entries need user action 603*cdf0e10cSrcweir 604*cdf0e10cSrcweir if ( aCbxLogarithm.IsChecked() && 605*cdf0e10cSrcweir ( ( !aCbxAutoMin.IsChecked() && fMin <= 0.0 ) 606*cdf0e10cSrcweir || ( !aCbxAutoMax.IsChecked() && fMax <= 0.0 ) ) ) 607*cdf0e10cSrcweir { 608*cdf0e10cSrcweir pControl = &aFmtFldMin; 609*cdf0e10cSrcweir nErrStrId = STR_BAD_LOGARITHM; 610*cdf0e10cSrcweir } 611*cdf0e10cSrcweir else if (!aCbxAutoMax.IsChecked() && !aCbxAutoMin.IsChecked() && 612*cdf0e10cSrcweir fMin >= fMax) 613*cdf0e10cSrcweir { 614*cdf0e10cSrcweir pControl = &aFmtFldMin; 615*cdf0e10cSrcweir nErrStrId = STR_MIN_GREATER_MAX; 616*cdf0e10cSrcweir } 617*cdf0e10cSrcweir else if (!aCbxAutoStepMain.IsChecked() && fStepMain <= 0) 618*cdf0e10cSrcweir { 619*cdf0e10cSrcweir pControl = &aFmtFldStepMain; 620*cdf0e10cSrcweir nErrStrId = STR_STEP_GT_ZERO; 621*cdf0e10cSrcweir } 622*cdf0e10cSrcweir // check for entries that cannot be parsed for the current number format 623*cdf0e10cSrcweir else if ( aFmtFldMin.IsModified() 624*cdf0e10cSrcweir && !aCbxAutoMin.IsChecked() 625*cdf0e10cSrcweir && !pNumFormatter->IsNumberFormat(aFmtFldMin.GetText(), nIndex, fDummy)) 626*cdf0e10cSrcweir { 627*cdf0e10cSrcweir pControl = &aFmtFldMin; 628*cdf0e10cSrcweir nErrStrId = STR_INVALID_NUMBER; 629*cdf0e10cSrcweir } 630*cdf0e10cSrcweir else if (aFmtFldMax.IsModified() && !aCbxAutoMax.IsChecked() && 631*cdf0e10cSrcweir !pNumFormatter->IsNumberFormat(aFmtFldMax.GetText(), 632*cdf0e10cSrcweir nIndex, fDummy)) 633*cdf0e10cSrcweir { 634*cdf0e10cSrcweir pControl = &aFmtFldMax; 635*cdf0e10cSrcweir nErrStrId = STR_INVALID_NUMBER; 636*cdf0e10cSrcweir } 637*cdf0e10cSrcweir else if ( !bDateAxis && aFmtFldStepMain.IsModified() && !aCbxAutoStepMain.IsChecked() && 638*cdf0e10cSrcweir !pNumFormatter->IsNumberFormat(aFmtFldStepMain.GetText(), 639*cdf0e10cSrcweir nIndex, fDummy)) 640*cdf0e10cSrcweir { 641*cdf0e10cSrcweir pControl = &aFmtFldStepMain; 642*cdf0e10cSrcweir nErrStrId = STR_STEP_GT_ZERO; 643*cdf0e10cSrcweir } 644*cdf0e10cSrcweir else if (aFmtFldOrigin.IsModified() && !aCbxAutoOrigin.IsChecked() && 645*cdf0e10cSrcweir !pNumFormatter->IsNumberFormat(aFmtFldOrigin.GetText(), 646*cdf0e10cSrcweir nIndex, fDummy)) 647*cdf0e10cSrcweir { 648*cdf0e10cSrcweir pControl = &aFmtFldOrigin; 649*cdf0e10cSrcweir nErrStrId = STR_INVALID_NUMBER; 650*cdf0e10cSrcweir } 651*cdf0e10cSrcweir else if (!aCbxAutoStepMain.IsChecked() && fStepMain <= 0.0) 652*cdf0e10cSrcweir { 653*cdf0e10cSrcweir pControl = &aFmtFldStepMain; 654*cdf0e10cSrcweir nErrStrId = STR_STEP_GT_ZERO; 655*cdf0e10cSrcweir } 656*cdf0e10cSrcweir else if( bDateAxis ) 657*cdf0e10cSrcweir { 658*cdf0e10cSrcweir if( !aCbxAutoStepMain.IsChecked() && !aCbxAutoStepHelp.IsChecked() ) 659*cdf0e10cSrcweir { 660*cdf0e10cSrcweir if( m_nHelpTimeUnit > m_nMainTimeUnit ) 661*cdf0e10cSrcweir { 662*cdf0e10cSrcweir pControl = &m_aLB_MainTimeUnit; 663*cdf0e10cSrcweir nErrStrId = STR_INVALID_INTERVALS; 664*cdf0e10cSrcweir } 665*cdf0e10cSrcweir else if( m_nHelpTimeUnit == m_nMainTimeUnit && nStepHelp > fStepMain ) 666*cdf0e10cSrcweir { 667*cdf0e10cSrcweir pControl = &m_aLB_MainTimeUnit; 668*cdf0e10cSrcweir nErrStrId = STR_INVALID_INTERVALS; 669*cdf0e10cSrcweir } 670*cdf0e10cSrcweir } 671*cdf0e10cSrcweir if( !nErrStrId && !m_aCbx_AutoTimeResolution.IsChecked() ) 672*cdf0e10cSrcweir { 673*cdf0e10cSrcweir if( (!aCbxAutoStepMain.IsChecked() && m_nTimeResolution > m_nMainTimeUnit ) 674*cdf0e10cSrcweir || 675*cdf0e10cSrcweir (!aCbxAutoStepHelp.IsChecked() && m_nTimeResolution > m_nHelpTimeUnit ) 676*cdf0e10cSrcweir ) 677*cdf0e10cSrcweir { 678*cdf0e10cSrcweir pControl = &m_aLB_TimeResolution; 679*cdf0e10cSrcweir nErrStrId = STR_INVALID_TIME_UNIT; 680*cdf0e10cSrcweir } 681*cdf0e10cSrcweir } 682*cdf0e10cSrcweir } 683*cdf0e10cSrcweir 684*cdf0e10cSrcweir if( ShowWarning( nErrStrId, pControl ) ) 685*cdf0e10cSrcweir return KEEP_PAGE; 686*cdf0e10cSrcweir 687*cdf0e10cSrcweir if( pItemSet ) 688*cdf0e10cSrcweir FillItemSet( *pItemSet ); 689*cdf0e10cSrcweir 690*cdf0e10cSrcweir return LEAVE_PAGE; 691*cdf0e10cSrcweir } 692*cdf0e10cSrcweir 693*cdf0e10cSrcweir void ScaleTabPage::SetNumFormatter( SvNumberFormatter* pFormatter ) 694*cdf0e10cSrcweir { 695*cdf0e10cSrcweir pNumFormatter = pFormatter; 696*cdf0e10cSrcweir aFmtFldMax.SetFormatter( pNumFormatter ); 697*cdf0e10cSrcweir aFmtFldMin.SetFormatter( pNumFormatter ); 698*cdf0e10cSrcweir aFmtFldStepMain.SetFormatter( pNumFormatter ); 699*cdf0e10cSrcweir aFmtFldOrigin.SetFormatter( pNumFormatter ); 700*cdf0e10cSrcweir 701*cdf0e10cSrcweir // #101318#, #i6278# allow more decimal places than the output format. As 702*cdf0e10cSrcweir // the numbers shown in the edit fields are used for input, it makes more 703*cdf0e10cSrcweir // sense to display the values in the input format rather than the output 704*cdf0e10cSrcweir // format. 705*cdf0e10cSrcweir aFmtFldMax.UseInputStringForFormatting(); 706*cdf0e10cSrcweir aFmtFldMin.UseInputStringForFormatting(); 707*cdf0e10cSrcweir aFmtFldStepMain.UseInputStringForFormatting(); 708*cdf0e10cSrcweir aFmtFldOrigin.UseInputStringForFormatting(); 709*cdf0e10cSrcweir 710*cdf0e10cSrcweir SetNumFormat(); 711*cdf0e10cSrcweir } 712*cdf0e10cSrcweir 713*cdf0e10cSrcweir void ScaleTabPage::SetNumFormat() 714*cdf0e10cSrcweir { 715*cdf0e10cSrcweir const SfxPoolItem *pPoolItem = NULL; 716*cdf0e10cSrcweir 717*cdf0e10cSrcweir if( GetItemSet().GetItemState( SID_ATTR_NUMBERFORMAT_VALUE, sal_True, &pPoolItem ) == SFX_ITEM_SET ) 718*cdf0e10cSrcweir { 719*cdf0e10cSrcweir sal_uLong nFmt = (sal_uLong)((const SfxInt32Item*)pPoolItem)->GetValue(); 720*cdf0e10cSrcweir 721*cdf0e10cSrcweir aFmtFldMax.SetFormatKey( nFmt ); 722*cdf0e10cSrcweir aFmtFldMin.SetFormatKey( nFmt ); 723*cdf0e10cSrcweir aFmtFldOrigin.SetFormatKey( nFmt ); 724*cdf0e10cSrcweir 725*cdf0e10cSrcweir if( pNumFormatter ) 726*cdf0e10cSrcweir { 727*cdf0e10cSrcweir short eType = pNumFormatter->GetType( nFmt ); 728*cdf0e10cSrcweir if( eType == NUMBERFORMAT_DATE ) 729*cdf0e10cSrcweir { 730*cdf0e10cSrcweir // for intervals use standard format for dates (so you can enter a number of days) 731*cdf0e10cSrcweir const SvNumberformat* pFormat = pNumFormatter->GetEntry( nFmt ); 732*cdf0e10cSrcweir if( pFormat ) 733*cdf0e10cSrcweir nFmt = pNumFormatter->GetStandardIndex( pFormat->GetLanguage()); 734*cdf0e10cSrcweir else 735*cdf0e10cSrcweir nFmt = pNumFormatter->GetStandardIndex(); 736*cdf0e10cSrcweir } 737*cdf0e10cSrcweir else if( eType == NUMBERFORMAT_DATETIME ) 738*cdf0e10cSrcweir { 739*cdf0e10cSrcweir // for intervals use time format for date times 740*cdf0e10cSrcweir const SvNumberformat* pFormat = pNumFormatter->GetEntry( nFmt ); 741*cdf0e10cSrcweir if( pFormat ) 742*cdf0e10cSrcweir nFmt = pNumFormatter->GetStandardFormat( NUMBERFORMAT_TIME, pFormat->GetLanguage() ); 743*cdf0e10cSrcweir else 744*cdf0e10cSrcweir nFmt = pNumFormatter->GetStandardFormat( NUMBERFORMAT_TIME ); 745*cdf0e10cSrcweir } 746*cdf0e10cSrcweir 747*cdf0e10cSrcweir if( chart2::AxisType::DATE == m_nAxisType && ( eType != NUMBERFORMAT_DATE && eType != NUMBERFORMAT_DATETIME) ) 748*cdf0e10cSrcweir { 749*cdf0e10cSrcweir const SvNumberformat* pFormat = pNumFormatter->GetEntry( nFmt ); 750*cdf0e10cSrcweir if( pFormat ) 751*cdf0e10cSrcweir nFmt = pNumFormatter->GetStandardFormat( NUMBERFORMAT_DATE, pFormat->GetLanguage() ); 752*cdf0e10cSrcweir else 753*cdf0e10cSrcweir nFmt = pNumFormatter->GetStandardFormat( NUMBERFORMAT_DATE ); 754*cdf0e10cSrcweir 755*cdf0e10cSrcweir aFmtFldMax.SetFormatKey( nFmt ); 756*cdf0e10cSrcweir aFmtFldMin.SetFormatKey( nFmt ); 757*cdf0e10cSrcweir aFmtFldOrigin.SetFormatKey( nFmt ); 758*cdf0e10cSrcweir } 759*cdf0e10cSrcweir } 760*cdf0e10cSrcweir 761*cdf0e10cSrcweir aFmtFldStepMain.SetFormatKey( nFmt ); 762*cdf0e10cSrcweir } 763*cdf0e10cSrcweir } 764*cdf0e10cSrcweir 765*cdf0e10cSrcweir void ScaleTabPage::ShowAxisOrigin( bool bShowOrigin ) 766*cdf0e10cSrcweir { 767*cdf0e10cSrcweir m_bShowAxisOrigin = bShowOrigin; 768*cdf0e10cSrcweir if( !AxisHelper::isAxisPositioningEnabled() ) 769*cdf0e10cSrcweir m_bShowAxisOrigin = true; 770*cdf0e10cSrcweir } 771*cdf0e10cSrcweir 772*cdf0e10cSrcweir bool ScaleTabPage::ShowWarning( sal_uInt16 nResIdMessage, Control* pControl /* = NULL */ ) 773*cdf0e10cSrcweir { 774*cdf0e10cSrcweir if( nResIdMessage == 0 ) 775*cdf0e10cSrcweir return false; 776*cdf0e10cSrcweir 777*cdf0e10cSrcweir WarningBox( this, WinBits( WB_OK ), String( SchResId( nResIdMessage ))).Execute(); 778*cdf0e10cSrcweir if( pControl ) 779*cdf0e10cSrcweir { 780*cdf0e10cSrcweir pControl->GrabFocus(); 781*cdf0e10cSrcweir Edit* pEdit = dynamic_cast<Edit*>(pControl); 782*cdf0e10cSrcweir if(pEdit) 783*cdf0e10cSrcweir pEdit->SetSelection( Selection( 0, SELECTION_MAX )); 784*cdf0e10cSrcweir } 785*cdf0e10cSrcweir return true; 786*cdf0e10cSrcweir } 787*cdf0e10cSrcweir 788*cdf0e10cSrcweir //............................................................................. 789*cdf0e10cSrcweir } //namespace chart 790*cdf0e10cSrcweir //............................................................................. 791