xref: /aoo41x/main/sw/source/ui/inc/prcntfld.hxx (revision cdf0e10c)
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 #ifndef _PRCNTFLD_HXX
28 #define _PRCNTFLD_HXX
29 
30 #ifndef _FIELD_HXX //autogen
31 #include <vcl/field.hxx>
32 #endif
33 #include "swdllapi.h"
34 
35 class SW_DLLPUBLIC PercentField : public MetricField
36 {
37     sal_Int64   nRefValue;      // 100%-Wert fuer Umrechnung (in Twips)
38     sal_Int64   nOldMax;
39     sal_Int64   nOldMin;
40     sal_Int64   nOldSpinSize;
41     sal_Int64   nOldBaseValue;
42     sal_Int64   nLastPercent;
43     sal_Int64   nLastValue;
44 	sal_uInt16		nOldDigits;
45 	FieldUnit	eOldUnit;
46     sal_Bool    bLockAutoCalculation; //prevent recalcution of percent values when the
47                                         //reference value is changed
48 
49     SW_DLLPRIVATE sal_Int64      ImpPower10(sal_uInt16 n);
50 
51     using MetricField::SetValue;
52     using MetricField::GetValue;
53     using MetricFormatter::SetUserValue;
54     using MetricFormatter::SetBaseValue;
55     using MetricFormatter::SetMax;
56     using MetricFormatter::SetMin;
57     using NumericFormatter::IsValueModified;
58 
59 public:
60 
61     virtual void  SetValue(sal_Int64 nNewValue, FieldUnit eInUnit = FUNIT_NONE);
62 
63 	PercentField( Window* pWin, const ResId& rResId );
64 
65     void        SetPrcntValue(sal_Int64 nNewValue, FieldUnit eInUnit = FUNIT_NONE);
66 
67     void        SetUserValue(sal_Int64 nNewValue, FieldUnit eInUnit = FUNIT_NONE);
68 
69     void        SetBaseValue(sal_Int64 nNewValue, FieldUnit eInUnit = FUNIT_NONE);
70 
71     sal_Int64        GetValue(FieldUnit eOutUnit = FUNIT_NONE);
72 
73 	sal_Bool		IsValueModified();
74 
75 	//using NumericFormatter::SetMax;
76     void        SetMax(sal_Int64 nNewMax, FieldUnit eInUnit = FUNIT_NONE);
77 
78 	//using NumericFormatter::SetMin;
79     void        SetMin(sal_Int64 nNewMin, FieldUnit eInUnit = FUNIT_NONE);
80 
81     sal_Int64        NormalizePercent(sal_Int64 nValue);
82     sal_Int64        DenormalizePercent(sal_Int64 nValue);
83 
84     void        SetRefValue(sal_Int64 nValue);
85     inline sal_Int64 GetRefValue() const { return nRefValue; }
86     sal_Int64   GetRealValue(FieldUnit eOutUnit = FUNIT_NONE);
87 
88     sal_Int64   Convert(sal_Int64 nValue, FieldUnit eInUnit, FieldUnit eOutUnit);
89 
90 	void		ShowPercent(sal_Bool bPercent);
91 
92 	sal_uInt16		GetOldDigits() const {return nOldDigits;}
93 
94     void        LockAutoCalculation(sal_Bool bLock) {bLockAutoCalculation = bLock;}
95     sal_Bool    IsAutoCalculationLocked()const {return bLockAutoCalculation;}
96 };
97 
98 #endif // _PRCNTFLD_HXX
99 
100