1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef _LONGCURR_HXX 29 #define _LONGCURR_HXX 30 31 #include <vcl/dllapi.h> 32 #include <tools/bigint.hxx> 33 #ifndef _FIELD_HXX 34 #include <vcl/field.hxx> 35 #endif 36 37 class LocaleDataWrapper; 38 39 // ------------------------- 40 // - LongCurrencyFormatter - 41 // ------------------------- 42 43 class VCL_DLLPUBLIC LongCurrencyFormatter : public FormatterBase 44 { 45 private: 46 SAL_DLLPRIVATE friend sal_Bool ImplLongCurrencyReformat( const XubString&, BigInt, BigInt, sal_uInt16, const LocaleDataWrapper&, XubString&, LongCurrencyFormatter& ); 47 SAL_DLLPRIVATE void ImpInit(); 48 49 protected: 50 BigInt mnFieldValue; 51 BigInt mnLastValue; 52 BigInt mnMin; 53 BigInt mnMax; 54 BigInt mnCorrectedValue; 55 String maCurrencySymbol; 56 sal_uInt16 mnType; 57 sal_uInt16 mnDecimalDigits; 58 sal_Bool mbThousandSep; 59 60 LongCurrencyFormatter(); 61 SAL_DLLPRIVATE void ImplLoadRes( const ResId& rResId ); 62 63 public: 64 ~LongCurrencyFormatter(); 65 66 virtual void Reformat(); 67 virtual void ReformatAll(); 68 69 void SetUseThousandSep( sal_Bool b ); 70 sal_Bool IsUseThousandSep() const { return mbThousandSep; } 71 72 void SetCurrencySymbol( const String& rStr ); 73 String GetCurrencySymbol() const; 74 75 void SetMin( BigInt nNewMin ); 76 BigInt GetMin() const { return mnMin; } 77 void SetMax( BigInt nNewMax ); 78 BigInt GetMax() const { return mnMax; } 79 80 void SetDecimalDigits( sal_uInt16 nDigits ); 81 sal_uInt16 GetDecimalDigits() const; 82 void SetValue( BigInt nNewValue ); 83 void SetUserValue( BigInt nNewValue ); 84 BigInt GetValue() const; 85 sal_Bool IsValueModified() const; 86 87 void SetEmptyValue(); 88 sal_Bool IsEmptyValue() const { return !GetField()->GetText().Len(); } 89 90 BigInt GetCorrectedValue() const { return mnCorrectedValue; } 91 92 BigInt Normalize( BigInt nValue ) const; 93 BigInt Denormalize( BigInt nValue ) const; 94 }; 95 96 // --------------------- 97 // - LongCurrencyField - 98 // --------------------- 99 100 class VCL_DLLPUBLIC LongCurrencyField : public SpinField, public LongCurrencyFormatter 101 { 102 //#if 0 // _SOLAR__PRIVATE 103 friend void ImplNewLongCurrencyFieldValue( LongCurrencyField*, BigInt ); 104 //#endif 105 106 private: 107 BigInt mnSpinSize; 108 BigInt mnFirst; 109 BigInt mnLast; 110 111 protected: 112 SAL_DLLPRIVATE void ImplLoadRes( const ResId& rResId ); 113 114 public: 115 LongCurrencyField( Window* pParent, WinBits nWinStyle ); 116 LongCurrencyField( Window* pParent, const ResId& rResId ); 117 ~LongCurrencyField(); 118 119 long PreNotify( NotifyEvent& rNEvt ); 120 long Notify( NotifyEvent& rNEvt ); 121 122 void Modify(); 123 void Up(); 124 void Down(); 125 void First(); 126 void Last(); 127 128 void SetFirst( BigInt nNewFirst ) { mnFirst = nNewFirst; } 129 BigInt GetFirst() const { return mnFirst; } 130 void SetLast( BigInt nNewLast ) { mnLast = nNewLast; } 131 BigInt GetLast() const { return mnLast; } 132 void SetSpinSize( BigInt nNewSize ) { mnSpinSize = nNewSize; } 133 BigInt GetSpinSize() const { return mnSpinSize; } 134 }; 135 136 // ------------------- 137 // - LongCurrencyBox - 138 // ------------------- 139 140 class VCL_DLLPUBLIC LongCurrencyBox : public ComboBox, public LongCurrencyFormatter 141 { 142 public: 143 LongCurrencyBox( Window* pParent, WinBits nWinStyle ); 144 LongCurrencyBox( Window* pParent, const ResId& rResId ); 145 ~LongCurrencyBox(); 146 147 long PreNotify( NotifyEvent& rNEvt ); 148 long Notify( NotifyEvent& rNEvt ); 149 150 void Modify(); 151 void ReformatAll(); 152 153 void InsertValue( BigInt nValue, 154 sal_uInt16 nPos = COMBOBOX_APPEND ); 155 void RemoveValue( BigInt nValue ); 156 BigInt GetValue() const 157 { return LongCurrencyFormatter::GetValue(); } 158 BigInt GetValue( sal_uInt16 nPos ) const; 159 sal_uInt16 GetValuePos( BigInt nValue ) const; 160 }; 161 162 #endif // _LONGCURR_HXX 163