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_sc.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #ifdef SC_DLLIMPLEMENTATION 32*cdf0e10cSrcweir #undef SC_DLLIMPLEMENTATION 33*cdf0e10cSrcweir #endif 34*cdf0e10cSrcweir 35*cdf0e10cSrcweir 36*cdf0e10cSrcweir #include "dpgroupdlg.hxx" 37*cdf0e10cSrcweir #ifndef SC_DPGROUPDLG_HRC 38*cdf0e10cSrcweir #include "dpgroupdlg.hrc" 39*cdf0e10cSrcweir #endif 40*cdf0e10cSrcweir #include <tools/resary.hxx> 41*cdf0e10cSrcweir #include "scresid.hxx" 42*cdf0e10cSrcweir #ifndef SC_SC_HRC 43*cdf0e10cSrcweir #include "sc.hrc" 44*cdf0e10cSrcweir #endif 45*cdf0e10cSrcweir #include <com/sun/star/sheet/DataPilotFieldGroupBy.hpp> 46*cdf0e10cSrcweir 47*cdf0e10cSrcweir // ============================================================================ 48*cdf0e10cSrcweir 49*cdf0e10cSrcweir namespace { 50*cdf0e10cSrcweir 51*cdf0e10cSrcweir /** Date part flags in order of the list box entries. */ 52*cdf0e10cSrcweir static const sal_Int32 spnDateParts[] = 53*cdf0e10cSrcweir { 54*cdf0e10cSrcweir com::sun::star::sheet::DataPilotFieldGroupBy::SECONDS, 55*cdf0e10cSrcweir com::sun::star::sheet::DataPilotFieldGroupBy::MINUTES, 56*cdf0e10cSrcweir com::sun::star::sheet::DataPilotFieldGroupBy::HOURS, 57*cdf0e10cSrcweir com::sun::star::sheet::DataPilotFieldGroupBy::DAYS, 58*cdf0e10cSrcweir com::sun::star::sheet::DataPilotFieldGroupBy::MONTHS, 59*cdf0e10cSrcweir com::sun::star::sheet::DataPilotFieldGroupBy::QUARTERS, 60*cdf0e10cSrcweir com::sun::star::sheet::DataPilotFieldGroupBy::YEARS 61*cdf0e10cSrcweir }; 62*cdf0e10cSrcweir 63*cdf0e10cSrcweir } // namespace 64*cdf0e10cSrcweir 65*cdf0e10cSrcweir // ============================================================================ 66*cdf0e10cSrcweir 67*cdf0e10cSrcweir ScDPGroupEditHelper::ScDPGroupEditHelper( RadioButton& rRbAuto, RadioButton& rRbMan, Edit& rEdValue ) : 68*cdf0e10cSrcweir mrRbAuto( rRbAuto ), 69*cdf0e10cSrcweir mrRbMan( rRbMan ), 70*cdf0e10cSrcweir mrEdValue( rEdValue ) 71*cdf0e10cSrcweir { 72*cdf0e10cSrcweir mrRbAuto.SetClickHdl( LINK( this, ScDPGroupEditHelper, ClickHdl ) ); 73*cdf0e10cSrcweir mrRbMan.SetClickHdl( LINK( this, ScDPGroupEditHelper, ClickHdl ) ); 74*cdf0e10cSrcweir } 75*cdf0e10cSrcweir 76*cdf0e10cSrcweir bool ScDPGroupEditHelper::IsAuto() const 77*cdf0e10cSrcweir { 78*cdf0e10cSrcweir return mrRbAuto.IsChecked(); 79*cdf0e10cSrcweir } 80*cdf0e10cSrcweir 81*cdf0e10cSrcweir double ScDPGroupEditHelper::GetValue() const 82*cdf0e10cSrcweir { 83*cdf0e10cSrcweir double fValue; 84*cdf0e10cSrcweir if( !ImplGetValue( fValue ) ) 85*cdf0e10cSrcweir fValue = 0.0; 86*cdf0e10cSrcweir return fValue; 87*cdf0e10cSrcweir } 88*cdf0e10cSrcweir 89*cdf0e10cSrcweir void ScDPGroupEditHelper::SetValue( bool bAuto, double fValue ) 90*cdf0e10cSrcweir { 91*cdf0e10cSrcweir if( bAuto ) 92*cdf0e10cSrcweir { 93*cdf0e10cSrcweir mrRbAuto.Check(); 94*cdf0e10cSrcweir ClickHdl( &mrRbAuto ); 95*cdf0e10cSrcweir } 96*cdf0e10cSrcweir else 97*cdf0e10cSrcweir { 98*cdf0e10cSrcweir mrRbMan.Check(); 99*cdf0e10cSrcweir ClickHdl( &mrRbMan ); 100*cdf0e10cSrcweir } 101*cdf0e10cSrcweir ImplSetValue( fValue ); 102*cdf0e10cSrcweir } 103*cdf0e10cSrcweir 104*cdf0e10cSrcweir IMPL_LINK( ScDPGroupEditHelper, ClickHdl, RadioButton*, pButton ) 105*cdf0e10cSrcweir { 106*cdf0e10cSrcweir if( pButton == &mrRbAuto ) 107*cdf0e10cSrcweir { 108*cdf0e10cSrcweir // disable edit field on clicking "automatic" radio button 109*cdf0e10cSrcweir mrEdValue.Disable(); 110*cdf0e10cSrcweir } 111*cdf0e10cSrcweir else if( pButton == &mrRbMan ) 112*cdf0e10cSrcweir { 113*cdf0e10cSrcweir // enable and set focus to edit field on clicking "manual" radio button 114*cdf0e10cSrcweir mrEdValue.Enable(); 115*cdf0e10cSrcweir mrEdValue.GrabFocus(); 116*cdf0e10cSrcweir } 117*cdf0e10cSrcweir return 0; 118*cdf0e10cSrcweir } 119*cdf0e10cSrcweir 120*cdf0e10cSrcweir // ---------------------------------------------------------------------------- 121*cdf0e10cSrcweir 122*cdf0e10cSrcweir ScDPNumGroupEditHelper::ScDPNumGroupEditHelper( 123*cdf0e10cSrcweir RadioButton& rRbAuto, RadioButton& rRbMan, ScDoubleField& rEdValue ) : 124*cdf0e10cSrcweir ScDPGroupEditHelper( rRbAuto, rRbMan, rEdValue ), 125*cdf0e10cSrcweir mrEdValue( rEdValue ) 126*cdf0e10cSrcweir { 127*cdf0e10cSrcweir } 128*cdf0e10cSrcweir 129*cdf0e10cSrcweir bool ScDPNumGroupEditHelper::ImplGetValue( double& rfValue ) const 130*cdf0e10cSrcweir { 131*cdf0e10cSrcweir return mrEdValue.GetValue( rfValue ); 132*cdf0e10cSrcweir } 133*cdf0e10cSrcweir 134*cdf0e10cSrcweir void ScDPNumGroupEditHelper::ImplSetValue( double fValue ) 135*cdf0e10cSrcweir { 136*cdf0e10cSrcweir mrEdValue.SetValue( fValue ); 137*cdf0e10cSrcweir } 138*cdf0e10cSrcweir 139*cdf0e10cSrcweir // ---------------------------------------------------------------------------- 140*cdf0e10cSrcweir 141*cdf0e10cSrcweir ScDPDateGroupEditHelper::ScDPDateGroupEditHelper( 142*cdf0e10cSrcweir RadioButton& rRbAuto, RadioButton& rRbMan, DateField& rEdValue, const Date& rNullDate ) : 143*cdf0e10cSrcweir ScDPGroupEditHelper( rRbAuto, rRbMan, rEdValue ), 144*cdf0e10cSrcweir mrEdValue( rEdValue ), 145*cdf0e10cSrcweir maNullDate( rNullDate ) 146*cdf0e10cSrcweir { 147*cdf0e10cSrcweir } 148*cdf0e10cSrcweir 149*cdf0e10cSrcweir bool ScDPDateGroupEditHelper::ImplGetValue( double& rfValue ) const 150*cdf0e10cSrcweir { 151*cdf0e10cSrcweir rfValue = mrEdValue.GetDate() - maNullDate; 152*cdf0e10cSrcweir return true; 153*cdf0e10cSrcweir } 154*cdf0e10cSrcweir 155*cdf0e10cSrcweir void ScDPDateGroupEditHelper::ImplSetValue( double fValue ) 156*cdf0e10cSrcweir { 157*cdf0e10cSrcweir Date aDate( maNullDate ); 158*cdf0e10cSrcweir aDate += static_cast< sal_Int32 >( fValue ); 159*cdf0e10cSrcweir mrEdValue.SetDate( aDate ); 160*cdf0e10cSrcweir } 161*cdf0e10cSrcweir 162*cdf0e10cSrcweir // ============================================================================ 163*cdf0e10cSrcweir // ============================================================================ 164*cdf0e10cSrcweir 165*cdf0e10cSrcweir ScDPNumGroupDlg::ScDPNumGroupDlg( Window* pParent, const ScDPNumGroupInfo& rInfo ) : 166*cdf0e10cSrcweir ModalDialog ( pParent, ScResId( RID_SCDLG_DPNUMGROUP ) ), 167*cdf0e10cSrcweir maFlStart ( this, ScResId( FL_START ) ), 168*cdf0e10cSrcweir maRbAutoStart ( this, ScResId( RB_AUTOSTART ) ), 169*cdf0e10cSrcweir maRbManStart ( this, ScResId( RB_MANSTART ) ), 170*cdf0e10cSrcweir maEdStart ( this, ScResId( ED_START ) ), 171*cdf0e10cSrcweir maFlEnd ( this, ScResId( FL_END ) ), 172*cdf0e10cSrcweir maRbAutoEnd ( this, ScResId( RB_AUTOEND ) ), 173*cdf0e10cSrcweir maRbManEnd ( this, ScResId( RB_MANEND ) ), 174*cdf0e10cSrcweir maEdEnd ( this, ScResId( ED_END ) ), 175*cdf0e10cSrcweir maFlBy ( this, ScResId( FL_BY ) ), 176*cdf0e10cSrcweir maEdBy ( this, ScResId( ED_BY ) ), 177*cdf0e10cSrcweir maBtnOk ( this, ScResId( BTN_OK ) ), 178*cdf0e10cSrcweir maBtnCancel ( this, ScResId( BTN_CANCEL ) ), 179*cdf0e10cSrcweir maBtnHelp ( this, ScResId( BTN_HELP ) ), 180*cdf0e10cSrcweir maStartHelper ( maRbAutoStart, maRbManStart, maEdStart ), 181*cdf0e10cSrcweir maEndHelper ( maRbAutoEnd, maRbManEnd, maEdEnd ) 182*cdf0e10cSrcweir { 183*cdf0e10cSrcweir FreeResource(); 184*cdf0e10cSrcweir 185*cdf0e10cSrcweir maStartHelper.SetValue( rInfo.AutoStart, rInfo.Start ); 186*cdf0e10cSrcweir maEndHelper.SetValue( rInfo.AutoEnd, rInfo.End ); 187*cdf0e10cSrcweir maEdBy.SetValue( (rInfo.Step <= 0.0) ? 1.0 : rInfo.Step ); 188*cdf0e10cSrcweir 189*cdf0e10cSrcweir /* Set the initial focus, currently it is somewhere after calling all the radio 190*cdf0e10cSrcweir button click handlers. Now the first enabled editable control is focused. */ 191*cdf0e10cSrcweir if( maEdStart.IsEnabled() ) 192*cdf0e10cSrcweir maEdStart.GrabFocus(); 193*cdf0e10cSrcweir else if( maEdEnd.IsEnabled() ) 194*cdf0e10cSrcweir maEdEnd.GrabFocus(); 195*cdf0e10cSrcweir else 196*cdf0e10cSrcweir maEdBy.GrabFocus(); 197*cdf0e10cSrcweir } 198*cdf0e10cSrcweir 199*cdf0e10cSrcweir ScDPNumGroupInfo ScDPNumGroupDlg::GetGroupInfo() const 200*cdf0e10cSrcweir { 201*cdf0e10cSrcweir ScDPNumGroupInfo aInfo; 202*cdf0e10cSrcweir aInfo.Enable = sal_True; 203*cdf0e10cSrcweir aInfo.DateValues = sal_False; 204*cdf0e10cSrcweir aInfo.AutoStart = maStartHelper.IsAuto(); 205*cdf0e10cSrcweir aInfo.AutoEnd = maEndHelper.IsAuto(); 206*cdf0e10cSrcweir 207*cdf0e10cSrcweir // get values and silently auto-correct them, if they are not valid 208*cdf0e10cSrcweir // TODO: error messages in OK event? 209*cdf0e10cSrcweir aInfo.Start = maStartHelper.GetValue(); 210*cdf0e10cSrcweir aInfo.End = maEndHelper.GetValue(); 211*cdf0e10cSrcweir if( !maEdBy.GetValue( aInfo.Step ) || (aInfo.Step <= 0.0) ) 212*cdf0e10cSrcweir aInfo.Step = 1.0; 213*cdf0e10cSrcweir if( aInfo.End <= aInfo.Start ) 214*cdf0e10cSrcweir aInfo.End = aInfo.Start + aInfo.Step; 215*cdf0e10cSrcweir 216*cdf0e10cSrcweir return aInfo; 217*cdf0e10cSrcweir } 218*cdf0e10cSrcweir 219*cdf0e10cSrcweir // ============================================================================ 220*cdf0e10cSrcweir 221*cdf0e10cSrcweir ScDPDateGroupDlg::ScDPDateGroupDlg( Window* pParent, 222*cdf0e10cSrcweir const ScDPNumGroupInfo& rInfo, sal_Int32 nDatePart, const Date& rNullDate ) : 223*cdf0e10cSrcweir ModalDialog ( pParent, ScResId( RID_SCDLG_DPDATEGROUP ) ), 224*cdf0e10cSrcweir maFlStart ( this, ScResId( FL_START ) ), 225*cdf0e10cSrcweir maRbAutoStart ( this, ScResId( RB_AUTOSTART ) ), 226*cdf0e10cSrcweir maRbManStart ( this, ScResId( RB_MANSTART ) ), 227*cdf0e10cSrcweir maEdStart ( this, ScResId( ED_START ) ), 228*cdf0e10cSrcweir maFlEnd ( this, ScResId( FL_END ) ), 229*cdf0e10cSrcweir maRbAutoEnd ( this, ScResId( RB_AUTOEND ) ), 230*cdf0e10cSrcweir maRbManEnd ( this, ScResId( RB_MANEND ) ), 231*cdf0e10cSrcweir maEdEnd ( this, ScResId( ED_END ) ), 232*cdf0e10cSrcweir maFlBy ( this, ScResId( FL_BY ) ), 233*cdf0e10cSrcweir maRbNumDays ( this, ScResId( RB_NUMDAYS ) ), 234*cdf0e10cSrcweir maRbUnits ( this, ScResId( RB_UNITS ) ), 235*cdf0e10cSrcweir maEdNumDays ( this, ScResId( ED_NUMDAYS ) ), 236*cdf0e10cSrcweir maLbUnits ( this, ScResId( LB_UNITS ) ), 237*cdf0e10cSrcweir maBtnOk ( this, ScResId( BTN_OK ) ), 238*cdf0e10cSrcweir maBtnCancel ( this, ScResId( BTN_CANCEL ) ), 239*cdf0e10cSrcweir maBtnHelp ( this, ScResId( BTN_HELP ) ), 240*cdf0e10cSrcweir maStartHelper ( maRbAutoStart, maRbManStart, maEdStart, rNullDate ), 241*cdf0e10cSrcweir maEndHelper ( maRbAutoEnd, maRbManEnd, maEdEnd, rNullDate ) 242*cdf0e10cSrcweir { 243*cdf0e10cSrcweir maLbUnits.SetHelpId( HID_SC_DPDATEGROUP_LB ); 244*cdf0e10cSrcweir ResStringArray aArr( ScResId( STR_UNITS ) ); 245*cdf0e10cSrcweir for( sal_uInt16 nIdx = 0, nCount = sal::static_int_cast<sal_uInt16>(aArr.Count()); nIdx < nCount; ++nIdx ) 246*cdf0e10cSrcweir maLbUnits.InsertEntry( aArr.GetString( nIdx ) ); 247*cdf0e10cSrcweir 248*cdf0e10cSrcweir FreeResource(); 249*cdf0e10cSrcweir 250*cdf0e10cSrcweir maEdStart.SetShowDateCentury( sal_True ); 251*cdf0e10cSrcweir maEdEnd.SetShowDateCentury( sal_True ); 252*cdf0e10cSrcweir 253*cdf0e10cSrcweir maStartHelper.SetValue( rInfo.AutoStart, rInfo.Start ); 254*cdf0e10cSrcweir maEndHelper.SetValue( rInfo.AutoEnd, rInfo.End ); 255*cdf0e10cSrcweir 256*cdf0e10cSrcweir if( nDatePart == 0 ) 257*cdf0e10cSrcweir nDatePart = com::sun::star::sheet::DataPilotFieldGroupBy::MONTHS; 258*cdf0e10cSrcweir for( sal_uLong nIdx = 0, nCount = maLbUnits.GetEntryCount(); nIdx < nCount; ++nIdx ) 259*cdf0e10cSrcweir maLbUnits.CheckEntryPos( static_cast< sal_uInt16 >( nIdx ), (nDatePart & spnDateParts[ nIdx ]) != 0 ); 260*cdf0e10cSrcweir 261*cdf0e10cSrcweir if( rInfo.DateValues ) 262*cdf0e10cSrcweir { 263*cdf0e10cSrcweir maRbNumDays.Check(); 264*cdf0e10cSrcweir ClickHdl( &maRbNumDays ); 265*cdf0e10cSrcweir 266*cdf0e10cSrcweir double fNumDays = rInfo.Step; 267*cdf0e10cSrcweir if( fNumDays < 1.0 ) 268*cdf0e10cSrcweir fNumDays = 1.0; 269*cdf0e10cSrcweir else if( fNumDays > 32767.0 ) 270*cdf0e10cSrcweir fNumDays = 32767.0; 271*cdf0e10cSrcweir maEdNumDays.SetValue( static_cast< long >( fNumDays ) ); 272*cdf0e10cSrcweir } 273*cdf0e10cSrcweir else 274*cdf0e10cSrcweir { 275*cdf0e10cSrcweir maRbUnits.Check(); 276*cdf0e10cSrcweir ClickHdl( &maRbUnits ); 277*cdf0e10cSrcweir } 278*cdf0e10cSrcweir 279*cdf0e10cSrcweir /* Set the initial focus, currently it is somewhere after calling all the radio 280*cdf0e10cSrcweir button click handlers. Now the first enabled editable control is focused. */ 281*cdf0e10cSrcweir if( maEdStart.IsEnabled() ) 282*cdf0e10cSrcweir maEdStart.GrabFocus(); 283*cdf0e10cSrcweir else if( maEdEnd.IsEnabled() ) 284*cdf0e10cSrcweir maEdEnd.GrabFocus(); 285*cdf0e10cSrcweir else if( maEdNumDays.IsEnabled() ) 286*cdf0e10cSrcweir maEdNumDays.GrabFocus(); 287*cdf0e10cSrcweir else if( maLbUnits.IsEnabled() ) 288*cdf0e10cSrcweir maLbUnits.GrabFocus(); 289*cdf0e10cSrcweir 290*cdf0e10cSrcweir maRbNumDays.SetClickHdl( LINK( this, ScDPDateGroupDlg, ClickHdl ) ); 291*cdf0e10cSrcweir maRbUnits.SetClickHdl( LINK( this, ScDPDateGroupDlg, ClickHdl ) ); 292*cdf0e10cSrcweir maLbUnits.SetCheckButtonHdl( LINK( this, ScDPDateGroupDlg, CheckHdl ) ); 293*cdf0e10cSrcweir } 294*cdf0e10cSrcweir 295*cdf0e10cSrcweir ScDPNumGroupInfo ScDPDateGroupDlg::GetGroupInfo() const 296*cdf0e10cSrcweir { 297*cdf0e10cSrcweir ScDPNumGroupInfo aInfo; 298*cdf0e10cSrcweir aInfo.Enable = sal_True; 299*cdf0e10cSrcweir aInfo.DateValues = maRbNumDays.IsChecked(); 300*cdf0e10cSrcweir aInfo.AutoStart = maStartHelper.IsAuto(); 301*cdf0e10cSrcweir aInfo.AutoEnd = maEndHelper.IsAuto(); 302*cdf0e10cSrcweir 303*cdf0e10cSrcweir // get values and silently auto-correct them, if they are not valid 304*cdf0e10cSrcweir // TODO: error messages in OK event? 305*cdf0e10cSrcweir aInfo.Start = maStartHelper.GetValue(); 306*cdf0e10cSrcweir aInfo.End = maEndHelper.GetValue(); 307*cdf0e10cSrcweir sal_Int64 nNumDays = maEdNumDays.GetValue(); 308*cdf0e10cSrcweir aInfo.Step = static_cast<double>( aInfo.DateValues ? nNumDays : 0L ); 309*cdf0e10cSrcweir if( aInfo.End <= aInfo.Start ) 310*cdf0e10cSrcweir aInfo.End = aInfo.Start + nNumDays; 311*cdf0e10cSrcweir 312*cdf0e10cSrcweir return aInfo; 313*cdf0e10cSrcweir } 314*cdf0e10cSrcweir 315*cdf0e10cSrcweir sal_Int32 ScDPDateGroupDlg::GetDatePart() const 316*cdf0e10cSrcweir { 317*cdf0e10cSrcweir // return DAYS for special "number of days" mode 318*cdf0e10cSrcweir if( maRbNumDays.IsChecked() ) 319*cdf0e10cSrcweir return com::sun::star::sheet::DataPilotFieldGroupBy::DAYS; 320*cdf0e10cSrcweir 321*cdf0e10cSrcweir // return listbox contents for "units" mode 322*cdf0e10cSrcweir sal_Int32 nDatePart = 0; 323*cdf0e10cSrcweir for( sal_uLong nIdx = 0, nCount = maLbUnits.GetEntryCount(); nIdx < nCount; ++nIdx ) 324*cdf0e10cSrcweir if( maLbUnits.IsChecked( static_cast< sal_uInt16 >( nIdx ) ) ) 325*cdf0e10cSrcweir nDatePart |= spnDateParts[ nIdx ]; 326*cdf0e10cSrcweir return nDatePart; 327*cdf0e10cSrcweir } 328*cdf0e10cSrcweir 329*cdf0e10cSrcweir IMPL_LINK( ScDPDateGroupDlg, ClickHdl, RadioButton*, pButton ) 330*cdf0e10cSrcweir { 331*cdf0e10cSrcweir if( pButton == &maRbNumDays ) 332*cdf0e10cSrcweir { 333*cdf0e10cSrcweir maLbUnits.Disable(); 334*cdf0e10cSrcweir // enable and set focus to edit field on clicking "num of days" radio button 335*cdf0e10cSrcweir maEdNumDays.Enable(); 336*cdf0e10cSrcweir maEdNumDays.GrabFocus(); 337*cdf0e10cSrcweir maBtnOk.Enable(); 338*cdf0e10cSrcweir } 339*cdf0e10cSrcweir else if( pButton == &maRbUnits ) 340*cdf0e10cSrcweir { 341*cdf0e10cSrcweir maEdNumDays.Disable(); 342*cdf0e10cSrcweir // enable and set focus to listbox on clicking "units" radio button 343*cdf0e10cSrcweir maLbUnits.Enable(); 344*cdf0e10cSrcweir maLbUnits.GrabFocus(); 345*cdf0e10cSrcweir // disable OK button if no date part selected 346*cdf0e10cSrcweir CheckHdl( &maLbUnits ); 347*cdf0e10cSrcweir } 348*cdf0e10cSrcweir return 0; 349*cdf0e10cSrcweir } 350*cdf0e10cSrcweir 351*cdf0e10cSrcweir IMPL_LINK( ScDPDateGroupDlg, CheckHdl, SvxCheckListBox*, pListBox ) 352*cdf0e10cSrcweir { 353*cdf0e10cSrcweir // enable/disable OK button on modifying check list box 354*cdf0e10cSrcweir if( pListBox == &maLbUnits ) 355*cdf0e10cSrcweir maBtnOk.Enable( maLbUnits.GetCheckedEntryCount() > 0 ); 356*cdf0e10cSrcweir return 0; 357*cdf0e10cSrcweir } 358*cdf0e10cSrcweir 359*cdf0e10cSrcweir // ============================================================================ 360*cdf0e10cSrcweir 361