1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef _LONGCURR_HXX 25 #define _LONGCURR_HXX 26 27 #include <vcl/dllapi.h> 28 #include <tools/bigint.hxx> 29 #ifndef _FIELD_HXX 30 #include <vcl/field.hxx> 31 #endif 32 33 class LocaleDataWrapper; 34 35 // ------------------------- 36 // - LongCurrencyFormatter - 37 // ------------------------- 38 39 class VCL_DLLPUBLIC LongCurrencyFormatter : public FormatterBase 40 { 41 private: 42 SAL_DLLPRIVATE friend sal_Bool ImplLongCurrencyReformat( const XubString&, BigInt, BigInt, sal_uInt16, const LocaleDataWrapper&, XubString&, LongCurrencyFormatter& ); 43 SAL_DLLPRIVATE void ImpInit(); 44 45 protected: 46 BigInt mnFieldValue; 47 BigInt mnLastValue; 48 BigInt mnMin; 49 BigInt mnMax; 50 BigInt mnCorrectedValue; 51 String maCurrencySymbol; 52 sal_uInt16 mnType; 53 sal_uInt16 mnDecimalDigits; 54 sal_Bool mbThousandSep; 55 56 LongCurrencyFormatter(); 57 SAL_DLLPRIVATE void ImplLoadRes( const ResId& rResId ); 58 59 public: 60 ~LongCurrencyFormatter(); 61 62 virtual void Reformat(); 63 virtual void ReformatAll(); 64 65 void SetUseThousandSep( sal_Bool b ); IsUseThousandSep() const66 sal_Bool IsUseThousandSep() const { return mbThousandSep; } 67 68 void SetCurrencySymbol( const String& rStr ); 69 String GetCurrencySymbol() const; 70 71 void SetMin( BigInt nNewMin ); GetMin() const72 BigInt GetMin() const { return mnMin; } 73 void SetMax( BigInt nNewMax ); GetMax() const74 BigInt GetMax() const { return mnMax; } 75 76 void SetDecimalDigits( sal_uInt16 nDigits ); 77 sal_uInt16 GetDecimalDigits() const; 78 void SetValue( BigInt nNewValue ); 79 void SetUserValue( BigInt nNewValue ); 80 BigInt GetValue() const; 81 sal_Bool IsValueModified() const; 82 83 void SetEmptyValue(); IsEmptyValue() const84 sal_Bool IsEmptyValue() const { return !GetField()->GetText().Len(); } 85 GetCorrectedValue() const86 BigInt GetCorrectedValue() const { return mnCorrectedValue; } 87 88 BigInt Normalize( BigInt nValue ) const; 89 BigInt Denormalize( BigInt nValue ) const; 90 }; 91 92 // --------------------- 93 // - LongCurrencyField - 94 // --------------------- 95 96 class VCL_DLLPUBLIC LongCurrencyField : public SpinField, public LongCurrencyFormatter 97 { 98 //#if 0 // _SOLAR__PRIVATE 99 friend void ImplNewLongCurrencyFieldValue( LongCurrencyField*, BigInt ); 100 //#endif 101 102 private: 103 BigInt mnSpinSize; 104 BigInt mnFirst; 105 BigInt mnLast; 106 107 protected: 108 SAL_DLLPRIVATE void ImplLoadRes( const ResId& rResId ); 109 110 public: 111 LongCurrencyField( Window* pParent, WinBits nWinStyle ); 112 LongCurrencyField( Window* pParent, const ResId& rResId ); 113 ~LongCurrencyField(); 114 115 long PreNotify( NotifyEvent& rNEvt ); 116 long Notify( NotifyEvent& rNEvt ); 117 118 void Modify(); 119 void Up(); 120 void Down(); 121 void First(); 122 void Last(); 123 SetFirst(BigInt nNewFirst)124 void SetFirst( BigInt nNewFirst ) { mnFirst = nNewFirst; } GetFirst() const125 BigInt GetFirst() const { return mnFirst; } SetLast(BigInt nNewLast)126 void SetLast( BigInt nNewLast ) { mnLast = nNewLast; } GetLast() const127 BigInt GetLast() const { return mnLast; } SetSpinSize(BigInt nNewSize)128 void SetSpinSize( BigInt nNewSize ) { mnSpinSize = nNewSize; } GetSpinSize() const129 BigInt GetSpinSize() const { return mnSpinSize; } 130 }; 131 132 // ------------------- 133 // - LongCurrencyBox - 134 // ------------------- 135 136 class VCL_DLLPUBLIC LongCurrencyBox : public ComboBox, public LongCurrencyFormatter 137 { 138 public: 139 LongCurrencyBox( Window* pParent, WinBits nWinStyle ); 140 LongCurrencyBox( Window* pParent, const ResId& rResId ); 141 ~LongCurrencyBox(); 142 143 long PreNotify( NotifyEvent& rNEvt ); 144 long Notify( NotifyEvent& rNEvt ); 145 146 void Modify(); 147 void ReformatAll(); 148 149 void InsertValue( BigInt nValue, 150 sal_uInt16 nPos = COMBOBOX_APPEND ); 151 void RemoveValue( BigInt nValue ); GetValue() const152 BigInt GetValue() const 153 { return LongCurrencyFormatter::GetValue(); } 154 BigInt GetValue( sal_uInt16 nPos ) const; 155 sal_uInt16 GetValuePos( BigInt nValue ) const; 156 }; 157 158 #endif // _LONGCURR_HXX 159