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