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