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_vcl.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include <sot/object.hxx> 32*cdf0e10cSrcweir #define _TOOLS_BIGINT 33*cdf0e10cSrcweir #include <sot/factory.hxx> 34*cdf0e10cSrcweir #include <tools/debug.hxx> 35*cdf0e10cSrcweir #include <tools/bigint.hxx> 36*cdf0e10cSrcweir 37*cdf0e10cSrcweir #include <tools/rc.h> 38*cdf0e10cSrcweir 39*cdf0e10cSrcweir #include <vcl/event.hxx> 40*cdf0e10cSrcweir #include <vcl/svapp.hxx> 41*cdf0e10cSrcweir #include <vcl/longcurr.hxx> 42*cdf0e10cSrcweir 43*cdf0e10cSrcweir #include <svdata.hxx> 44*cdf0e10cSrcweir 45*cdf0e10cSrcweir #include <unotools/localedatawrapper.hxx> 46*cdf0e10cSrcweir 47*cdf0e10cSrcweir 48*cdf0e10cSrcweir // ======================================================================= 49*cdf0e10cSrcweir 50*cdf0e10cSrcweir #define FORMAT_LONGCURRENCY 4 51*cdf0e10cSrcweir 52*cdf0e10cSrcweir // ======================================================================= 53*cdf0e10cSrcweir 54*cdf0e10cSrcweir static BigInt ImplPower10( sal_uInt16 n ) 55*cdf0e10cSrcweir { 56*cdf0e10cSrcweir sal_uInt16 i; 57*cdf0e10cSrcweir BigInt nValue = 1; 58*cdf0e10cSrcweir 59*cdf0e10cSrcweir for ( i=0; i < n; i++ ) 60*cdf0e10cSrcweir nValue *= 10; 61*cdf0e10cSrcweir 62*cdf0e10cSrcweir return nValue; 63*cdf0e10cSrcweir } 64*cdf0e10cSrcweir 65*cdf0e10cSrcweir // ----------------------------------------------------------------------- 66*cdf0e10cSrcweir 67*cdf0e10cSrcweir static XubString ImplGetCurr( const LocaleDataWrapper& rLocaleDataWrapper, const BigInt &rNumber, sal_uInt16 nDigits, const String& rCurrSymbol, sal_Bool bShowThousandSep ) 68*cdf0e10cSrcweir { 69*cdf0e10cSrcweir DBG_ASSERT( nDigits < 10, "LongCurrency duerfen nur maximal 9 Nachkommastellen haben" ); 70*cdf0e10cSrcweir 71*cdf0e10cSrcweir if ( rNumber.IsZero() || (long)rNumber ) 72*cdf0e10cSrcweir return rLocaleDataWrapper.getCurr( (long)rNumber, nDigits, rCurrSymbol, bShowThousandSep ); 73*cdf0e10cSrcweir 74*cdf0e10cSrcweir BigInt aTmp( ImplPower10( nDigits ) ); 75*cdf0e10cSrcweir BigInt aInteger( rNumber ); 76*cdf0e10cSrcweir aInteger.Abs(); 77*cdf0e10cSrcweir aInteger /= aTmp; 78*cdf0e10cSrcweir BigInt aFraction( rNumber ); 79*cdf0e10cSrcweir aFraction.Abs(); 80*cdf0e10cSrcweir aFraction %= aTmp; 81*cdf0e10cSrcweir if ( !aInteger.IsZero() ) 82*cdf0e10cSrcweir { 83*cdf0e10cSrcweir aFraction += aTmp; 84*cdf0e10cSrcweir aTmp = 1000000000L; 85*cdf0e10cSrcweir } 86*cdf0e10cSrcweir if ( rNumber.IsNeg() ) 87*cdf0e10cSrcweir aFraction *= -1; 88*cdf0e10cSrcweir 89*cdf0e10cSrcweir XubString aTemplate = rLocaleDataWrapper.getCurr( (long)aFraction, nDigits, rCurrSymbol, bShowThousandSep ); 90*cdf0e10cSrcweir while( !aInteger.IsZero() ) 91*cdf0e10cSrcweir { 92*cdf0e10cSrcweir aFraction = aInteger; 93*cdf0e10cSrcweir aFraction %= aTmp; 94*cdf0e10cSrcweir aInteger /= aTmp; 95*cdf0e10cSrcweir if( !aInteger.IsZero() ) 96*cdf0e10cSrcweir aFraction += aTmp; 97*cdf0e10cSrcweir 98*cdf0e10cSrcweir XubString aFractionStr = rLocaleDataWrapper.getNum( (long)aFraction, 0 ); 99*cdf0e10cSrcweir 100*cdf0e10cSrcweir xub_StrLen nSPos = aTemplate.Search( '1' ); 101*cdf0e10cSrcweir if ( aFractionStr.Len() == 1 ) 102*cdf0e10cSrcweir aTemplate.SetChar( nSPos, aFractionStr.GetChar( 0 ) ); 103*cdf0e10cSrcweir else 104*cdf0e10cSrcweir { 105*cdf0e10cSrcweir aTemplate.Erase( nSPos, 1 ); 106*cdf0e10cSrcweir aTemplate.Insert( aFractionStr, nSPos ); 107*cdf0e10cSrcweir } 108*cdf0e10cSrcweir } 109*cdf0e10cSrcweir 110*cdf0e10cSrcweir return aTemplate; 111*cdf0e10cSrcweir } 112*cdf0e10cSrcweir 113*cdf0e10cSrcweir // ----------------------------------------------------------------------- 114*cdf0e10cSrcweir 115*cdf0e10cSrcweir static sal_Bool ImplNumericProcessKeyInput( Edit*, const KeyEvent& rKEvt, 116*cdf0e10cSrcweir sal_Bool bStrictFormat, sal_Bool bThousandSep, 117*cdf0e10cSrcweir const LocaleDataWrapper& rLocaleDataWrapper ) 118*cdf0e10cSrcweir { 119*cdf0e10cSrcweir if ( !bStrictFormat ) 120*cdf0e10cSrcweir return sal_False; 121*cdf0e10cSrcweir else 122*cdf0e10cSrcweir { 123*cdf0e10cSrcweir sal_Unicode cChar = rKEvt.GetCharCode(); 124*cdf0e10cSrcweir sal_uInt16 nGroup = rKEvt.GetKeyCode().GetGroup(); 125*cdf0e10cSrcweir 126*cdf0e10cSrcweir if ( (nGroup == KEYGROUP_FKEYS) || (nGroup == KEYGROUP_CURSOR) || 127*cdf0e10cSrcweir (nGroup == KEYGROUP_MISC) || 128*cdf0e10cSrcweir ((cChar >= '0') && (cChar <= '9')) || 129*cdf0e10cSrcweir (bThousandSep && (cChar == rLocaleDataWrapper.getNumThousandSep())) || 130*cdf0e10cSrcweir (cChar == rLocaleDataWrapper.getNumDecimalSep() ) || 131*cdf0e10cSrcweir (cChar == '-') ) 132*cdf0e10cSrcweir return sal_False; 133*cdf0e10cSrcweir else 134*cdf0e10cSrcweir return sal_True; 135*cdf0e10cSrcweir } 136*cdf0e10cSrcweir } 137*cdf0e10cSrcweir 138*cdf0e10cSrcweir // ----------------------------------------------------------------------- 139*cdf0e10cSrcweir 140*cdf0e10cSrcweir static sal_Bool ImplNumericGetValue( const XubString& rStr, BigInt& rValue, 141*cdf0e10cSrcweir sal_uInt16 nDecDigits, const LocaleDataWrapper& rLocaleDataWrapper, 142*cdf0e10cSrcweir sal_Bool bCurrency = sal_False ) 143*cdf0e10cSrcweir { 144*cdf0e10cSrcweir XubString aStr = rStr; 145*cdf0e10cSrcweir XubString aStr1; 146*cdf0e10cSrcweir XubString aStr2; 147*cdf0e10cSrcweir sal_uInt16 nDecPos; 148*cdf0e10cSrcweir sal_Bool bNegative = sal_False; 149*cdf0e10cSrcweir xub_StrLen i; 150*cdf0e10cSrcweir 151*cdf0e10cSrcweir // Reaktion auf leeren String 152*cdf0e10cSrcweir if ( !rStr.Len() ) 153*cdf0e10cSrcweir return sal_False; 154*cdf0e10cSrcweir 155*cdf0e10cSrcweir // Fuehrende und nachfolgende Leerzeichen entfernen 156*cdf0e10cSrcweir aStr.EraseLeadingAndTrailingChars( ' ' ); 157*cdf0e10cSrcweir 158*cdf0e10cSrcweir // Position des Dezimalpunktes suchen 159*cdf0e10cSrcweir nDecPos = aStr.Search( rLocaleDataWrapper.getNumDecimalSep() ); 160*cdf0e10cSrcweir 161*cdf0e10cSrcweir if ( nDecPos != STRING_NOTFOUND ) 162*cdf0e10cSrcweir { 163*cdf0e10cSrcweir aStr1 = aStr.Copy( 0, nDecPos ); 164*cdf0e10cSrcweir aStr2 = aStr.Copy( nDecPos+1 ); 165*cdf0e10cSrcweir } 166*cdf0e10cSrcweir else 167*cdf0e10cSrcweir aStr1 = aStr; 168*cdf0e10cSrcweir 169*cdf0e10cSrcweir // Negativ ? 170*cdf0e10cSrcweir if ( bCurrency ) 171*cdf0e10cSrcweir { 172*cdf0e10cSrcweir if ( (aStr.GetChar( 0 ) == '(') && (aStr.GetChar( aStr.Len()-1 ) == ')') ) 173*cdf0e10cSrcweir bNegative = sal_True; 174*cdf0e10cSrcweir if ( !bNegative ) 175*cdf0e10cSrcweir { 176*cdf0e10cSrcweir for ( i=0; i < aStr.Len(); i++ ) 177*cdf0e10cSrcweir { 178*cdf0e10cSrcweir if ( (aStr.GetChar( i ) >= '0') && (aStr.GetChar( i ) <= '9') ) 179*cdf0e10cSrcweir break; 180*cdf0e10cSrcweir else if ( aStr.GetChar( i ) == '-' ) 181*cdf0e10cSrcweir { 182*cdf0e10cSrcweir bNegative = sal_True; 183*cdf0e10cSrcweir break; 184*cdf0e10cSrcweir } 185*cdf0e10cSrcweir } 186*cdf0e10cSrcweir } 187*cdf0e10cSrcweir if ( !bNegative && bCurrency && aStr.Len() ) 188*cdf0e10cSrcweir { 189*cdf0e10cSrcweir sal_uInt16 nFormat = rLocaleDataWrapper.getCurrNegativeFormat(); 190*cdf0e10cSrcweir if ( (nFormat == 3) || (nFormat == 6) || 191*cdf0e10cSrcweir (nFormat == 7) || (nFormat == 10) ) 192*cdf0e10cSrcweir { 193*cdf0e10cSrcweir for ( i = (sal_uInt16)(aStr.Len()-1); i > 0; i++ ) 194*cdf0e10cSrcweir { 195*cdf0e10cSrcweir if ( (aStr.GetChar( i ) >= '0') && (aStr.GetChar( i ) <= '9') ) 196*cdf0e10cSrcweir break; 197*cdf0e10cSrcweir else if ( aStr.GetChar( i ) == '-' ) 198*cdf0e10cSrcweir { 199*cdf0e10cSrcweir bNegative = sal_True; 200*cdf0e10cSrcweir break; 201*cdf0e10cSrcweir } 202*cdf0e10cSrcweir } 203*cdf0e10cSrcweir } 204*cdf0e10cSrcweir } 205*cdf0e10cSrcweir } 206*cdf0e10cSrcweir else 207*cdf0e10cSrcweir { 208*cdf0e10cSrcweir if ( aStr1.GetChar( 0 ) == '-' ) 209*cdf0e10cSrcweir bNegative = sal_True; 210*cdf0e10cSrcweir } 211*cdf0e10cSrcweir 212*cdf0e10cSrcweir // Alle unerwuenschten Zeichen rauswerfen 213*cdf0e10cSrcweir for ( i=0; i < aStr1.Len(); ) 214*cdf0e10cSrcweir { 215*cdf0e10cSrcweir if ( (aStr1.GetChar( i ) >= '0') && (aStr1.GetChar( i ) <= '9') ) 216*cdf0e10cSrcweir i++; 217*cdf0e10cSrcweir else 218*cdf0e10cSrcweir aStr1.Erase( i, 1 ); 219*cdf0e10cSrcweir } 220*cdf0e10cSrcweir for ( i=0; i < aStr2.Len(); ) 221*cdf0e10cSrcweir { 222*cdf0e10cSrcweir if ( (aStr2.GetChar( i ) >= '0') && (aStr2.GetChar( i ) <= '9') ) 223*cdf0e10cSrcweir i++; 224*cdf0e10cSrcweir else 225*cdf0e10cSrcweir aStr2.Erase( i, 1 ); 226*cdf0e10cSrcweir } 227*cdf0e10cSrcweir 228*cdf0e10cSrcweir if ( !aStr1.Len() && !aStr2.Len() ) 229*cdf0e10cSrcweir return sal_False; 230*cdf0e10cSrcweir 231*cdf0e10cSrcweir if ( !aStr1.Len() ) 232*cdf0e10cSrcweir aStr1.Insert( '0' ); 233*cdf0e10cSrcweir if ( bNegative ) 234*cdf0e10cSrcweir aStr1.Insert( '-', 0 ); 235*cdf0e10cSrcweir 236*cdf0e10cSrcweir // Nachkommateil zurechtstutzen und dabei runden 237*cdf0e10cSrcweir sal_Bool bRound = sal_False; 238*cdf0e10cSrcweir if ( aStr2.Len() > nDecDigits ) 239*cdf0e10cSrcweir { 240*cdf0e10cSrcweir if ( aStr2.GetChar( nDecDigits ) >= '5' ) 241*cdf0e10cSrcweir bRound = sal_True; 242*cdf0e10cSrcweir aStr2.Erase( nDecDigits ); 243*cdf0e10cSrcweir } 244*cdf0e10cSrcweir if ( aStr2.Len() < nDecDigits ) 245*cdf0e10cSrcweir aStr2.Expand( nDecDigits, '0' ); 246*cdf0e10cSrcweir 247*cdf0e10cSrcweir aStr = aStr1; 248*cdf0e10cSrcweir aStr += aStr2; 249*cdf0e10cSrcweir 250*cdf0e10cSrcweir // Bereichsueberpruefung 251*cdf0e10cSrcweir BigInt nValue( aStr ); 252*cdf0e10cSrcweir if ( bRound ) 253*cdf0e10cSrcweir { 254*cdf0e10cSrcweir if ( !bNegative ) 255*cdf0e10cSrcweir nValue+=1; 256*cdf0e10cSrcweir else 257*cdf0e10cSrcweir nValue-=1; 258*cdf0e10cSrcweir } 259*cdf0e10cSrcweir 260*cdf0e10cSrcweir rValue = nValue; 261*cdf0e10cSrcweir 262*cdf0e10cSrcweir return sal_True; 263*cdf0e10cSrcweir } 264*cdf0e10cSrcweir 265*cdf0e10cSrcweir // ======================================================================= 266*cdf0e10cSrcweir 267*cdf0e10cSrcweir static sal_Bool ImplLongCurrencyProcessKeyInput( Edit* pEdit, const KeyEvent& rKEvt, 268*cdf0e10cSrcweir sal_Bool, sal_Bool bUseThousandSep, const LocaleDataWrapper& rLocaleDataWrapper ) 269*cdf0e10cSrcweir { 270*cdf0e10cSrcweir // Es gibt hier kein sinnvolles StrictFormat, also alle 271*cdf0e10cSrcweir // Zeichen erlauben 272*cdf0e10cSrcweir return ImplNumericProcessKeyInput( pEdit, rKEvt, sal_False, bUseThousandSep, rLocaleDataWrapper ); 273*cdf0e10cSrcweir } 274*cdf0e10cSrcweir 275*cdf0e10cSrcweir // ----------------------------------------------------------------------- 276*cdf0e10cSrcweir 277*cdf0e10cSrcweir inline sal_Bool ImplLongCurrencyGetValue( const XubString& rStr, BigInt& rValue, 278*cdf0e10cSrcweir sal_uInt16 nDecDigits, const LocaleDataWrapper& rLocaleDataWrapper ) 279*cdf0e10cSrcweir { 280*cdf0e10cSrcweir // Zahlenwert holen 281*cdf0e10cSrcweir return ImplNumericGetValue( rStr, rValue, nDecDigits, rLocaleDataWrapper, sal_True ); 282*cdf0e10cSrcweir } 283*cdf0e10cSrcweir 284*cdf0e10cSrcweir // ----------------------------------------------------------------------- 285*cdf0e10cSrcweir 286*cdf0e10cSrcweir sal_Bool ImplLongCurrencyReformat( const XubString& rStr, BigInt nMin, BigInt nMax, 287*cdf0e10cSrcweir sal_uInt16 nDecDigits, 288*cdf0e10cSrcweir const LocaleDataWrapper& rLocaleDataWrapper, String& rOutStr, 289*cdf0e10cSrcweir LongCurrencyFormatter& rFormatter ) 290*cdf0e10cSrcweir { 291*cdf0e10cSrcweir BigInt nValue; 292*cdf0e10cSrcweir if ( !ImplNumericGetValue( rStr, nValue, nDecDigits, rLocaleDataWrapper, sal_True ) ) 293*cdf0e10cSrcweir return sal_True; 294*cdf0e10cSrcweir else 295*cdf0e10cSrcweir { 296*cdf0e10cSrcweir BigInt nTempVal = nValue; 297*cdf0e10cSrcweir if ( nTempVal > nMax ) 298*cdf0e10cSrcweir nTempVal = nMax; 299*cdf0e10cSrcweir else if ( nTempVal < nMin ) 300*cdf0e10cSrcweir nTempVal = nMin; 301*cdf0e10cSrcweir 302*cdf0e10cSrcweir if ( rFormatter.GetErrorHdl().IsSet() && (nValue != nTempVal) ) 303*cdf0e10cSrcweir { 304*cdf0e10cSrcweir rFormatter.mnCorrectedValue = nTempVal; 305*cdf0e10cSrcweir if ( !rFormatter.GetErrorHdl().Call( &rFormatter ) ) 306*cdf0e10cSrcweir { 307*cdf0e10cSrcweir rFormatter.mnCorrectedValue = 0; 308*cdf0e10cSrcweir return sal_False; 309*cdf0e10cSrcweir } 310*cdf0e10cSrcweir else 311*cdf0e10cSrcweir { 312*cdf0e10cSrcweir rFormatter.mnCorrectedValue = 0; 313*cdf0e10cSrcweir } 314*cdf0e10cSrcweir } 315*cdf0e10cSrcweir 316*cdf0e10cSrcweir rOutStr = ImplGetCurr( rLocaleDataWrapper, nTempVal, nDecDigits, rFormatter.GetCurrencySymbol(), rFormatter.IsUseThousandSep() ); 317*cdf0e10cSrcweir return sal_True; 318*cdf0e10cSrcweir } 319*cdf0e10cSrcweir } 320*cdf0e10cSrcweir 321*cdf0e10cSrcweir 322*cdf0e10cSrcweir // ======================================================================= 323*cdf0e10cSrcweir 324*cdf0e10cSrcweir void LongCurrencyFormatter::ImpInit() 325*cdf0e10cSrcweir { 326*cdf0e10cSrcweir mnFieldValue = 0; 327*cdf0e10cSrcweir mnLastValue = 0; 328*cdf0e10cSrcweir mnMin = 0; 329*cdf0e10cSrcweir mnMax = 0x7FFFFFFF; 330*cdf0e10cSrcweir mnMax *= 0x7FFFFFFF; 331*cdf0e10cSrcweir mnCorrectedValue = 0; 332*cdf0e10cSrcweir mnDecimalDigits = 0; 333*cdf0e10cSrcweir mnType = FORMAT_LONGCURRENCY; 334*cdf0e10cSrcweir mbThousandSep = sal_True; 335*cdf0e10cSrcweir SetDecimalDigits( 0 ); 336*cdf0e10cSrcweir } 337*cdf0e10cSrcweir 338*cdf0e10cSrcweir // ----------------------------------------------------------------------- 339*cdf0e10cSrcweir 340*cdf0e10cSrcweir LongCurrencyFormatter::LongCurrencyFormatter() 341*cdf0e10cSrcweir { 342*cdf0e10cSrcweir ImpInit(); 343*cdf0e10cSrcweir } 344*cdf0e10cSrcweir 345*cdf0e10cSrcweir // ----------------------------------------------------------------------- 346*cdf0e10cSrcweir 347*cdf0e10cSrcweir void LongCurrencyFormatter::ImplLoadRes( const ResId& rResId ) 348*cdf0e10cSrcweir { 349*cdf0e10cSrcweir ImpInit(); 350*cdf0e10cSrcweir 351*cdf0e10cSrcweir ResMgr* pMgr = rResId.GetResMgr(); 352*cdf0e10cSrcweir if( pMgr ) 353*cdf0e10cSrcweir { 354*cdf0e10cSrcweir sal_uLong nMask = pMgr->ReadLong(); 355*cdf0e10cSrcweir 356*cdf0e10cSrcweir if ( NUMERICFORMATTER_MIN & nMask ) 357*cdf0e10cSrcweir mnMin = pMgr->ReadLong(); 358*cdf0e10cSrcweir 359*cdf0e10cSrcweir if ( NUMERICFORMATTER_MAX & nMask ) 360*cdf0e10cSrcweir mnMax = pMgr->ReadLong(); 361*cdf0e10cSrcweir 362*cdf0e10cSrcweir if ( NUMERICFORMATTER_STRICTFORMAT & nMask ) 363*cdf0e10cSrcweir SetStrictFormat( (sal_Bool)pMgr->ReadShort() ); 364*cdf0e10cSrcweir 365*cdf0e10cSrcweir if ( NUMERICFORMATTER_DECIMALDIGITS & nMask ) 366*cdf0e10cSrcweir SetDecimalDigits( pMgr->ReadShort() ); 367*cdf0e10cSrcweir 368*cdf0e10cSrcweir if ( NUMERICFORMATTER_VALUE & nMask ) 369*cdf0e10cSrcweir { 370*cdf0e10cSrcweir mnFieldValue = pMgr->ReadLong(); 371*cdf0e10cSrcweir if ( mnFieldValue > mnMax ) 372*cdf0e10cSrcweir mnFieldValue = mnMax; 373*cdf0e10cSrcweir else if ( mnFieldValue < mnMin ) 374*cdf0e10cSrcweir mnFieldValue = mnMin; 375*cdf0e10cSrcweir mnLastValue = mnFieldValue; 376*cdf0e10cSrcweir } 377*cdf0e10cSrcweir } 378*cdf0e10cSrcweir } 379*cdf0e10cSrcweir 380*cdf0e10cSrcweir // ----------------------------------------------------------------------- 381*cdf0e10cSrcweir 382*cdf0e10cSrcweir LongCurrencyFormatter::~LongCurrencyFormatter() 383*cdf0e10cSrcweir { 384*cdf0e10cSrcweir } 385*cdf0e10cSrcweir 386*cdf0e10cSrcweir // ----------------------------------------------------------------------- 387*cdf0e10cSrcweir 388*cdf0e10cSrcweir void LongCurrencyFormatter::SetCurrencySymbol( const String& rStr ) 389*cdf0e10cSrcweir { 390*cdf0e10cSrcweir maCurrencySymbol= rStr; 391*cdf0e10cSrcweir ReformatAll(); 392*cdf0e10cSrcweir } 393*cdf0e10cSrcweir 394*cdf0e10cSrcweir // ----------------------------------------------------------------------- 395*cdf0e10cSrcweir 396*cdf0e10cSrcweir String LongCurrencyFormatter::GetCurrencySymbol() const 397*cdf0e10cSrcweir { 398*cdf0e10cSrcweir return maCurrencySymbol.Len() ? maCurrencySymbol : GetLocaleDataWrapper().getCurrSymbol(); 399*cdf0e10cSrcweir } 400*cdf0e10cSrcweir 401*cdf0e10cSrcweir // ----------------------------------------------------------------------- 402*cdf0e10cSrcweir 403*cdf0e10cSrcweir void LongCurrencyFormatter::SetValue( BigInt nNewValue ) 404*cdf0e10cSrcweir { 405*cdf0e10cSrcweir SetUserValue( nNewValue ); 406*cdf0e10cSrcweir mnFieldValue = mnLastValue; 407*cdf0e10cSrcweir SetEmptyFieldValueData( sal_False ); 408*cdf0e10cSrcweir } 409*cdf0e10cSrcweir 410*cdf0e10cSrcweir // ----------------------------------------------------------------------- 411*cdf0e10cSrcweir 412*cdf0e10cSrcweir void LongCurrencyFormatter::SetUserValue( BigInt nNewValue ) 413*cdf0e10cSrcweir { 414*cdf0e10cSrcweir if ( nNewValue > mnMax ) 415*cdf0e10cSrcweir nNewValue = mnMax; 416*cdf0e10cSrcweir else if ( nNewValue < mnMin ) 417*cdf0e10cSrcweir nNewValue = mnMin; 418*cdf0e10cSrcweir mnLastValue = nNewValue; 419*cdf0e10cSrcweir 420*cdf0e10cSrcweir if ( !GetField() ) 421*cdf0e10cSrcweir return; 422*cdf0e10cSrcweir 423*cdf0e10cSrcweir XubString aStr = ImplGetCurr( GetLocaleDataWrapper(), nNewValue, GetDecimalDigits(), GetCurrencySymbol(), IsUseThousandSep() ); 424*cdf0e10cSrcweir if ( GetField()->HasFocus() ) 425*cdf0e10cSrcweir { 426*cdf0e10cSrcweir Selection aSelection = GetField()->GetSelection(); 427*cdf0e10cSrcweir GetField()->SetText( aStr ); 428*cdf0e10cSrcweir GetField()->SetSelection( aSelection ); 429*cdf0e10cSrcweir } 430*cdf0e10cSrcweir else 431*cdf0e10cSrcweir GetField()->SetText( aStr ); 432*cdf0e10cSrcweir MarkToBeReformatted( sal_False ); 433*cdf0e10cSrcweir } 434*cdf0e10cSrcweir 435*cdf0e10cSrcweir // ----------------------------------------------------------------------- 436*cdf0e10cSrcweir 437*cdf0e10cSrcweir BigInt LongCurrencyFormatter::GetValue() const 438*cdf0e10cSrcweir { 439*cdf0e10cSrcweir if ( !GetField() ) 440*cdf0e10cSrcweir return 0; 441*cdf0e10cSrcweir 442*cdf0e10cSrcweir BigInt nTempValue; 443*cdf0e10cSrcweir if ( ImplLongCurrencyGetValue( GetField()->GetText(), nTempValue, GetDecimalDigits(), GetLocaleDataWrapper() ) ) 444*cdf0e10cSrcweir { 445*cdf0e10cSrcweir if ( nTempValue > mnMax ) 446*cdf0e10cSrcweir nTempValue = mnMax; 447*cdf0e10cSrcweir else if ( nTempValue < mnMin ) 448*cdf0e10cSrcweir nTempValue = mnMin; 449*cdf0e10cSrcweir return nTempValue; 450*cdf0e10cSrcweir } 451*cdf0e10cSrcweir else 452*cdf0e10cSrcweir return mnLastValue; 453*cdf0e10cSrcweir } 454*cdf0e10cSrcweir 455*cdf0e10cSrcweir // ----------------------------------------------------------------------- 456*cdf0e10cSrcweir 457*cdf0e10cSrcweir void LongCurrencyFormatter::Reformat() 458*cdf0e10cSrcweir { 459*cdf0e10cSrcweir if ( !GetField() ) 460*cdf0e10cSrcweir return; 461*cdf0e10cSrcweir 462*cdf0e10cSrcweir if ( !GetField()->GetText().Len() && ImplGetEmptyFieldValue() ) 463*cdf0e10cSrcweir return; 464*cdf0e10cSrcweir 465*cdf0e10cSrcweir XubString aStr; 466*cdf0e10cSrcweir sal_Bool bOK = ImplLongCurrencyReformat( GetField()->GetText(), mnMin, mnMax, 467*cdf0e10cSrcweir GetDecimalDigits(), GetLocaleDataWrapper(), aStr, *this ); 468*cdf0e10cSrcweir if ( !bOK ) 469*cdf0e10cSrcweir return; 470*cdf0e10cSrcweir 471*cdf0e10cSrcweir if ( aStr.Len() ) 472*cdf0e10cSrcweir { 473*cdf0e10cSrcweir GetField()->SetText( aStr ); 474*cdf0e10cSrcweir MarkToBeReformatted( sal_False ); 475*cdf0e10cSrcweir ImplLongCurrencyGetValue( aStr, mnLastValue, GetDecimalDigits(), GetLocaleDataWrapper() ); 476*cdf0e10cSrcweir } 477*cdf0e10cSrcweir else 478*cdf0e10cSrcweir SetValue( mnLastValue ); 479*cdf0e10cSrcweir } 480*cdf0e10cSrcweir 481*cdf0e10cSrcweir // ----------------------------------------------------------------------- 482*cdf0e10cSrcweir 483*cdf0e10cSrcweir void LongCurrencyFormatter::ReformatAll() 484*cdf0e10cSrcweir { 485*cdf0e10cSrcweir Reformat(); 486*cdf0e10cSrcweir } 487*cdf0e10cSrcweir 488*cdf0e10cSrcweir // ----------------------------------------------------------------------- 489*cdf0e10cSrcweir 490*cdf0e10cSrcweir void LongCurrencyFormatter::SetMin( BigInt nNewMin ) 491*cdf0e10cSrcweir { 492*cdf0e10cSrcweir mnMin = nNewMin; 493*cdf0e10cSrcweir ReformatAll(); 494*cdf0e10cSrcweir } 495*cdf0e10cSrcweir 496*cdf0e10cSrcweir // ----------------------------------------------------------------------- 497*cdf0e10cSrcweir 498*cdf0e10cSrcweir void LongCurrencyFormatter::SetMax( BigInt nNewMax ) 499*cdf0e10cSrcweir { 500*cdf0e10cSrcweir mnMax = nNewMax; 501*cdf0e10cSrcweir ReformatAll(); 502*cdf0e10cSrcweir } 503*cdf0e10cSrcweir 504*cdf0e10cSrcweir // ----------------------------------------------------------------------- 505*cdf0e10cSrcweir 506*cdf0e10cSrcweir void LongCurrencyFormatter::SetUseThousandSep( sal_Bool b ) 507*cdf0e10cSrcweir { 508*cdf0e10cSrcweir mbThousandSep = b; 509*cdf0e10cSrcweir ReformatAll(); 510*cdf0e10cSrcweir } 511*cdf0e10cSrcweir 512*cdf0e10cSrcweir 513*cdf0e10cSrcweir // ----------------------------------------------------------------------- 514*cdf0e10cSrcweir 515*cdf0e10cSrcweir void LongCurrencyFormatter::SetDecimalDigits( sal_uInt16 nDigits ) 516*cdf0e10cSrcweir { 517*cdf0e10cSrcweir // DBG_ASSERT( nDigits < 10, "LongCurrency duerfen nur maximal 9 Nachkommastellen haben" ); 518*cdf0e10cSrcweir 519*cdf0e10cSrcweir if ( nDigits > 9 ) 520*cdf0e10cSrcweir nDigits = 9; 521*cdf0e10cSrcweir 522*cdf0e10cSrcweir mnDecimalDigits = nDigits; 523*cdf0e10cSrcweir ReformatAll(); 524*cdf0e10cSrcweir } 525*cdf0e10cSrcweir 526*cdf0e10cSrcweir // ----------------------------------------------------------------------- 527*cdf0e10cSrcweir 528*cdf0e10cSrcweir sal_uInt16 LongCurrencyFormatter::GetDecimalDigits() const 529*cdf0e10cSrcweir { 530*cdf0e10cSrcweir return mnDecimalDigits; 531*cdf0e10cSrcweir } 532*cdf0e10cSrcweir 533*cdf0e10cSrcweir // ----------------------------------------------------------------------- 534*cdf0e10cSrcweir 535*cdf0e10cSrcweir sal_Bool LongCurrencyFormatter::IsValueModified() const 536*cdf0e10cSrcweir { 537*cdf0e10cSrcweir if ( ImplGetEmptyFieldValue() ) 538*cdf0e10cSrcweir return !IsEmptyValue(); 539*cdf0e10cSrcweir else if ( GetValue() != mnFieldValue ) 540*cdf0e10cSrcweir return sal_True; 541*cdf0e10cSrcweir else 542*cdf0e10cSrcweir return sal_False; 543*cdf0e10cSrcweir } 544*cdf0e10cSrcweir 545*cdf0e10cSrcweir // ----------------------------------------------------------------------- 546*cdf0e10cSrcweir 547*cdf0e10cSrcweir void LongCurrencyFormatter::SetEmptyValue() 548*cdf0e10cSrcweir { 549*cdf0e10cSrcweir GetField()->SetText( ImplGetSVEmptyStr() ); 550*cdf0e10cSrcweir SetEmptyFieldValueData( sal_True ); 551*cdf0e10cSrcweir } 552*cdf0e10cSrcweir 553*cdf0e10cSrcweir // ----------------------------------------------------------------------- 554*cdf0e10cSrcweir 555*cdf0e10cSrcweir BigInt LongCurrencyFormatter::Normalize( BigInt nValue ) const 556*cdf0e10cSrcweir { 557*cdf0e10cSrcweir return (nValue * ImplPower10( GetDecimalDigits() ) ); 558*cdf0e10cSrcweir } 559*cdf0e10cSrcweir 560*cdf0e10cSrcweir // ----------------------------------------------------------------------- 561*cdf0e10cSrcweir 562*cdf0e10cSrcweir BigInt LongCurrencyFormatter::Denormalize( BigInt nValue ) const 563*cdf0e10cSrcweir { 564*cdf0e10cSrcweir BigInt nFactor = ImplPower10( GetDecimalDigits() ); 565*cdf0e10cSrcweir BigInt nTmp = nFactor; 566*cdf0e10cSrcweir nTmp /= 2; 567*cdf0e10cSrcweir nTmp += nValue; 568*cdf0e10cSrcweir nTmp /= nFactor; 569*cdf0e10cSrcweir return nTmp; 570*cdf0e10cSrcweir } 571*cdf0e10cSrcweir 572*cdf0e10cSrcweir // ======================================================================= 573*cdf0e10cSrcweir 574*cdf0e10cSrcweir void ImplNewLongCurrencyFieldValue( LongCurrencyField* pField, BigInt nNewValue ) 575*cdf0e10cSrcweir { 576*cdf0e10cSrcweir Selection aSelect = pField->GetSelection(); 577*cdf0e10cSrcweir aSelect.Justify(); 578*cdf0e10cSrcweir XubString aText = pField->GetText(); 579*cdf0e10cSrcweir sal_Bool bLastSelected = ((xub_StrLen)aSelect.Max() == aText.Len()) ? sal_True : sal_False; 580*cdf0e10cSrcweir 581*cdf0e10cSrcweir BigInt nOldLastValue = pField->mnLastValue; 582*cdf0e10cSrcweir pField->SetUserValue( nNewValue ); 583*cdf0e10cSrcweir pField->mnLastValue = nOldLastValue; 584*cdf0e10cSrcweir 585*cdf0e10cSrcweir if ( bLastSelected ) 586*cdf0e10cSrcweir { 587*cdf0e10cSrcweir if ( !aSelect.Len() ) 588*cdf0e10cSrcweir aSelect.Min() = SELECTION_MAX; 589*cdf0e10cSrcweir aSelect.Max() = SELECTION_MAX; 590*cdf0e10cSrcweir } 591*cdf0e10cSrcweir pField->SetSelection( aSelect ); 592*cdf0e10cSrcweir pField->SetModifyFlag(); 593*cdf0e10cSrcweir pField->Modify(); 594*cdf0e10cSrcweir } 595*cdf0e10cSrcweir 596*cdf0e10cSrcweir // ======================================================================= 597*cdf0e10cSrcweir 598*cdf0e10cSrcweir LongCurrencyField::LongCurrencyField( Window* pParent, WinBits nWinStyle ) : 599*cdf0e10cSrcweir SpinField( pParent, nWinStyle ) 600*cdf0e10cSrcweir { 601*cdf0e10cSrcweir SetField( this ); 602*cdf0e10cSrcweir mnSpinSize = 1; 603*cdf0e10cSrcweir mnFirst = mnMin; 604*cdf0e10cSrcweir mnLast = mnMax; 605*cdf0e10cSrcweir 606*cdf0e10cSrcweir Reformat(); 607*cdf0e10cSrcweir } 608*cdf0e10cSrcweir 609*cdf0e10cSrcweir // ----------------------------------------------------------------------- 610*cdf0e10cSrcweir 611*cdf0e10cSrcweir LongCurrencyField::LongCurrencyField( Window* pParent, const ResId& rResId ) : 612*cdf0e10cSrcweir SpinField( WINDOW_NUMERICFIELD ) 613*cdf0e10cSrcweir { 614*cdf0e10cSrcweir rResId.SetRT( RSC_NUMERICFIELD ); 615*cdf0e10cSrcweir WinBits nStyle = ImplInitRes( rResId ) ; 616*cdf0e10cSrcweir SpinField::ImplInit( pParent, nStyle ); 617*cdf0e10cSrcweir 618*cdf0e10cSrcweir SetField( this ); 619*cdf0e10cSrcweir mnSpinSize = 1; 620*cdf0e10cSrcweir mnFirst = mnMin; 621*cdf0e10cSrcweir mnLast = mnMax; 622*cdf0e10cSrcweir 623*cdf0e10cSrcweir Reformat(); 624*cdf0e10cSrcweir 625*cdf0e10cSrcweir if ( !(nStyle & WB_HIDE) ) 626*cdf0e10cSrcweir Show(); 627*cdf0e10cSrcweir } 628*cdf0e10cSrcweir 629*cdf0e10cSrcweir // ----------------------------------------------------------------------- 630*cdf0e10cSrcweir 631*cdf0e10cSrcweir void LongCurrencyField::ImplLoadRes( const ResId& rResId ) 632*cdf0e10cSrcweir { 633*cdf0e10cSrcweir SpinField::ImplLoadRes( rResId ); 634*cdf0e10cSrcweir LongCurrencyFormatter::ImplLoadRes( ResId( (RSHEADER_TYPE *)GetClassRes(), *rResId.GetResMgr() ) ); 635*cdf0e10cSrcweir 636*cdf0e10cSrcweir sal_uLong nMask = ReadLongRes(); 637*cdf0e10cSrcweir if ( CURRENCYFIELD_FIRST & nMask ) 638*cdf0e10cSrcweir mnFirst = ReadLongRes(); 639*cdf0e10cSrcweir 640*cdf0e10cSrcweir if ( CURRENCYFIELD_LAST & nMask ) 641*cdf0e10cSrcweir mnLast = ReadLongRes(); 642*cdf0e10cSrcweir 643*cdf0e10cSrcweir if ( CURRENCYFIELD_SPINSIZE & nMask ) 644*cdf0e10cSrcweir mnSpinSize = ReadLongRes(); 645*cdf0e10cSrcweir } 646*cdf0e10cSrcweir 647*cdf0e10cSrcweir // ----------------------------------------------------------------------- 648*cdf0e10cSrcweir 649*cdf0e10cSrcweir LongCurrencyField::~LongCurrencyField() 650*cdf0e10cSrcweir { 651*cdf0e10cSrcweir } 652*cdf0e10cSrcweir 653*cdf0e10cSrcweir // ----------------------------------------------------------------------- 654*cdf0e10cSrcweir 655*cdf0e10cSrcweir long LongCurrencyField::PreNotify( NotifyEvent& rNEvt ) 656*cdf0e10cSrcweir { 657*cdf0e10cSrcweir if( rNEvt.GetType() == EVENT_KEYINPUT ) 658*cdf0e10cSrcweir { 659*cdf0e10cSrcweir if ( ImplLongCurrencyProcessKeyInput( GetField(), *rNEvt.GetKeyEvent(), IsStrictFormat(), IsUseThousandSep(), GetLocaleDataWrapper() ) ) 660*cdf0e10cSrcweir return 1; 661*cdf0e10cSrcweir } 662*cdf0e10cSrcweir return SpinField::PreNotify( rNEvt ); 663*cdf0e10cSrcweir } 664*cdf0e10cSrcweir 665*cdf0e10cSrcweir // ----------------------------------------------------------------------- 666*cdf0e10cSrcweir 667*cdf0e10cSrcweir long LongCurrencyField::Notify( NotifyEvent& rNEvt ) 668*cdf0e10cSrcweir { 669*cdf0e10cSrcweir if( rNEvt.GetType() == EVENT_GETFOCUS ) 670*cdf0e10cSrcweir { 671*cdf0e10cSrcweir MarkToBeReformatted( sal_False ); 672*cdf0e10cSrcweir } 673*cdf0e10cSrcweir else if( rNEvt.GetType() == EVENT_LOSEFOCUS ) 674*cdf0e10cSrcweir { 675*cdf0e10cSrcweir if ( MustBeReformatted() ) 676*cdf0e10cSrcweir { 677*cdf0e10cSrcweir Reformat(); 678*cdf0e10cSrcweir SpinField::Modify(); 679*cdf0e10cSrcweir } 680*cdf0e10cSrcweir } 681*cdf0e10cSrcweir return SpinField::Notify( rNEvt ); 682*cdf0e10cSrcweir } 683*cdf0e10cSrcweir 684*cdf0e10cSrcweir // ----------------------------------------------------------------------- 685*cdf0e10cSrcweir 686*cdf0e10cSrcweir void LongCurrencyField::Modify() 687*cdf0e10cSrcweir { 688*cdf0e10cSrcweir MarkToBeReformatted( sal_True ); 689*cdf0e10cSrcweir SpinField::Modify(); 690*cdf0e10cSrcweir } 691*cdf0e10cSrcweir 692*cdf0e10cSrcweir // ----------------------------------------------------------------------- 693*cdf0e10cSrcweir 694*cdf0e10cSrcweir void LongCurrencyField::Up() 695*cdf0e10cSrcweir { 696*cdf0e10cSrcweir BigInt nValue = GetValue(); 697*cdf0e10cSrcweir nValue += mnSpinSize; 698*cdf0e10cSrcweir if ( nValue > mnMax ) 699*cdf0e10cSrcweir nValue = mnMax; 700*cdf0e10cSrcweir 701*cdf0e10cSrcweir ImplNewLongCurrencyFieldValue( this, nValue ); 702*cdf0e10cSrcweir SpinField::Up(); 703*cdf0e10cSrcweir } 704*cdf0e10cSrcweir 705*cdf0e10cSrcweir // ----------------------------------------------------------------------- 706*cdf0e10cSrcweir 707*cdf0e10cSrcweir void LongCurrencyField::Down() 708*cdf0e10cSrcweir { 709*cdf0e10cSrcweir BigInt nValue = GetValue(); 710*cdf0e10cSrcweir nValue -= mnSpinSize; 711*cdf0e10cSrcweir if ( nValue < mnMin ) 712*cdf0e10cSrcweir nValue = mnMin; 713*cdf0e10cSrcweir 714*cdf0e10cSrcweir ImplNewLongCurrencyFieldValue( this, nValue ); 715*cdf0e10cSrcweir SpinField::Down(); 716*cdf0e10cSrcweir } 717*cdf0e10cSrcweir 718*cdf0e10cSrcweir // ----------------------------------------------------------------------- 719*cdf0e10cSrcweir 720*cdf0e10cSrcweir void LongCurrencyField::First() 721*cdf0e10cSrcweir { 722*cdf0e10cSrcweir ImplNewLongCurrencyFieldValue( this, mnFirst ); 723*cdf0e10cSrcweir SpinField::First(); 724*cdf0e10cSrcweir } 725*cdf0e10cSrcweir 726*cdf0e10cSrcweir // ----------------------------------------------------------------------- 727*cdf0e10cSrcweir 728*cdf0e10cSrcweir void LongCurrencyField::Last() 729*cdf0e10cSrcweir { 730*cdf0e10cSrcweir ImplNewLongCurrencyFieldValue( this, mnLast ); 731*cdf0e10cSrcweir SpinField::Last(); 732*cdf0e10cSrcweir } 733*cdf0e10cSrcweir 734*cdf0e10cSrcweir // ======================================================================= 735*cdf0e10cSrcweir 736*cdf0e10cSrcweir LongCurrencyBox::LongCurrencyBox( Window* pParent, WinBits nWinStyle ) : 737*cdf0e10cSrcweir ComboBox( pParent, nWinStyle ) 738*cdf0e10cSrcweir { 739*cdf0e10cSrcweir SetField( this ); 740*cdf0e10cSrcweir Reformat(); 741*cdf0e10cSrcweir } 742*cdf0e10cSrcweir 743*cdf0e10cSrcweir // ----------------------------------------------------------------------- 744*cdf0e10cSrcweir 745*cdf0e10cSrcweir LongCurrencyBox::LongCurrencyBox( Window* pParent, const ResId& rResId ) : 746*cdf0e10cSrcweir ComboBox( WINDOW_NUMERICFIELD ) 747*cdf0e10cSrcweir { 748*cdf0e10cSrcweir SetField( this ); 749*cdf0e10cSrcweir WinBits nStyle = ImplInitRes( rResId ) ; 750*cdf0e10cSrcweir ComboBox::ImplLoadRes( rResId ); 751*cdf0e10cSrcweir ImplInit( pParent, nStyle ); 752*cdf0e10cSrcweir LongCurrencyFormatter::ImplLoadRes( rResId ); 753*cdf0e10cSrcweir Reformat(); 754*cdf0e10cSrcweir 755*cdf0e10cSrcweir if ( !(nStyle & WB_HIDE) ) 756*cdf0e10cSrcweir Show(); 757*cdf0e10cSrcweir } 758*cdf0e10cSrcweir 759*cdf0e10cSrcweir // ----------------------------------------------------------------------- 760*cdf0e10cSrcweir 761*cdf0e10cSrcweir LongCurrencyBox::~LongCurrencyBox() 762*cdf0e10cSrcweir { 763*cdf0e10cSrcweir } 764*cdf0e10cSrcweir 765*cdf0e10cSrcweir // ----------------------------------------------------------------------- 766*cdf0e10cSrcweir 767*cdf0e10cSrcweir long LongCurrencyBox::PreNotify( NotifyEvent& rNEvt ) 768*cdf0e10cSrcweir { 769*cdf0e10cSrcweir if( rNEvt.GetType() == EVENT_KEYINPUT ) 770*cdf0e10cSrcweir { 771*cdf0e10cSrcweir if ( ImplLongCurrencyProcessKeyInput( GetField(), *rNEvt.GetKeyEvent(), IsStrictFormat(), IsUseThousandSep(), GetLocaleDataWrapper() ) ) 772*cdf0e10cSrcweir return 1; 773*cdf0e10cSrcweir } 774*cdf0e10cSrcweir return ComboBox::PreNotify( rNEvt ); 775*cdf0e10cSrcweir } 776*cdf0e10cSrcweir 777*cdf0e10cSrcweir // ----------------------------------------------------------------------- 778*cdf0e10cSrcweir 779*cdf0e10cSrcweir long LongCurrencyBox::Notify( NotifyEvent& rNEvt ) 780*cdf0e10cSrcweir { 781*cdf0e10cSrcweir if( rNEvt.GetType() == EVENT_GETFOCUS ) 782*cdf0e10cSrcweir { 783*cdf0e10cSrcweir MarkToBeReformatted( sal_False ); 784*cdf0e10cSrcweir } 785*cdf0e10cSrcweir else if( rNEvt.GetType() == EVENT_LOSEFOCUS ) 786*cdf0e10cSrcweir { 787*cdf0e10cSrcweir if ( MustBeReformatted() ) 788*cdf0e10cSrcweir { 789*cdf0e10cSrcweir Reformat(); 790*cdf0e10cSrcweir ComboBox::Modify(); 791*cdf0e10cSrcweir } 792*cdf0e10cSrcweir } 793*cdf0e10cSrcweir return ComboBox::Notify( rNEvt ); 794*cdf0e10cSrcweir } 795*cdf0e10cSrcweir 796*cdf0e10cSrcweir // ----------------------------------------------------------------------- 797*cdf0e10cSrcweir 798*cdf0e10cSrcweir void LongCurrencyBox::Modify() 799*cdf0e10cSrcweir { 800*cdf0e10cSrcweir MarkToBeReformatted( sal_True ); 801*cdf0e10cSrcweir ComboBox::Modify(); 802*cdf0e10cSrcweir } 803*cdf0e10cSrcweir 804*cdf0e10cSrcweir // ----------------------------------------------------------------------- 805*cdf0e10cSrcweir 806*cdf0e10cSrcweir void LongCurrencyBox::ReformatAll() 807*cdf0e10cSrcweir { 808*cdf0e10cSrcweir XubString aStr; 809*cdf0e10cSrcweir SetUpdateMode( sal_False ); 810*cdf0e10cSrcweir sal_uInt16 nEntryCount = GetEntryCount(); 811*cdf0e10cSrcweir for ( sal_uInt16 i=0; i < nEntryCount; i++ ) 812*cdf0e10cSrcweir { 813*cdf0e10cSrcweir ImplLongCurrencyReformat( GetEntry( i ), mnMin, mnMax, 814*cdf0e10cSrcweir GetDecimalDigits(), GetLocaleDataWrapper(), 815*cdf0e10cSrcweir aStr, *this ); 816*cdf0e10cSrcweir RemoveEntry( i ); 817*cdf0e10cSrcweir InsertEntry( aStr, i ); 818*cdf0e10cSrcweir } 819*cdf0e10cSrcweir LongCurrencyFormatter::Reformat(); 820*cdf0e10cSrcweir SetUpdateMode( sal_True ); 821*cdf0e10cSrcweir } 822*cdf0e10cSrcweir 823*cdf0e10cSrcweir // ----------------------------------------------------------------------- 824*cdf0e10cSrcweir 825*cdf0e10cSrcweir void LongCurrencyBox::InsertValue( BigInt nValue, sal_uInt16 nPos ) 826*cdf0e10cSrcweir { 827*cdf0e10cSrcweir XubString aStr = ImplGetCurr( GetLocaleDataWrapper(), nValue, GetDecimalDigits(), GetCurrencySymbol(), IsUseThousandSep() ); 828*cdf0e10cSrcweir ComboBox::InsertEntry( aStr, nPos ); 829*cdf0e10cSrcweir } 830*cdf0e10cSrcweir 831*cdf0e10cSrcweir // ----------------------------------------------------------------------- 832*cdf0e10cSrcweir 833*cdf0e10cSrcweir void LongCurrencyBox::RemoveValue( BigInt nValue ) 834*cdf0e10cSrcweir { 835*cdf0e10cSrcweir XubString aStr = ImplGetCurr( GetLocaleDataWrapper(), nValue, GetDecimalDigits(), GetCurrencySymbol(), IsUseThousandSep() ); 836*cdf0e10cSrcweir ComboBox::RemoveEntry( aStr ); 837*cdf0e10cSrcweir } 838*cdf0e10cSrcweir 839*cdf0e10cSrcweir // ----------------------------------------------------------------------- 840*cdf0e10cSrcweir 841*cdf0e10cSrcweir BigInt LongCurrencyBox::GetValue( sal_uInt16 nPos ) const 842*cdf0e10cSrcweir { 843*cdf0e10cSrcweir BigInt nValue = 0; 844*cdf0e10cSrcweir ImplLongCurrencyGetValue( ComboBox::GetEntry( nPos ), nValue, 845*cdf0e10cSrcweir GetDecimalDigits(), GetLocaleDataWrapper() ); 846*cdf0e10cSrcweir return nValue; 847*cdf0e10cSrcweir } 848*cdf0e10cSrcweir 849*cdf0e10cSrcweir // ----------------------------------------------------------------------- 850*cdf0e10cSrcweir 851*cdf0e10cSrcweir sal_uInt16 LongCurrencyBox::GetValuePos( BigInt nValue ) const 852*cdf0e10cSrcweir { 853*cdf0e10cSrcweir XubString aStr = ImplGetCurr( GetLocaleDataWrapper(), nValue, GetDecimalDigits(), GetCurrencySymbol(), IsUseThousandSep() ); 854*cdf0e10cSrcweir return ComboBox::GetEntryPos( aStr ); 855*cdf0e10cSrcweir } 856*cdf0e10cSrcweir 857*cdf0e10cSrcweir // ======================================================================= 858