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