Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 : #ifndef _PRCNTFLD_HXX
20 : #define _PRCNTFLD_HXX
21 :
22 : #include <vcl/field.hxx>
23 : #include "swdllapi.h"
24 :
25 0 : class SW_DLLPUBLIC PercentField : public MetricField
26 : {
27 : sal_Int64 nRefValue; // 100% value for conversion (in Twips)
28 : sal_Int64 nOldMax;
29 : sal_Int64 nOldMin;
30 : sal_Int64 nOldSpinSize;
31 : sal_Int64 nOldBaseValue;
32 : sal_Int64 nLastPercent;
33 : sal_Int64 nLastValue;
34 : sal_uInt16 nOldDigits;
35 : FieldUnit eOldUnit;
36 : sal_Bool bLockAutoCalculation; //prevent recalcution of percent values when the
37 : //reference value is changed
38 :
39 : SW_DLLPRIVATE sal_Int64 ImpPower10(sal_uInt16 n);
40 :
41 : using MetricField::SetValue;
42 : using MetricField::GetValue;
43 : using MetricFormatter::SetUserValue;
44 : using MetricFormatter::SetBaseValue;
45 : using MetricFormatter::SetMax;
46 : using MetricFormatter::SetMin;
47 : using NumericFormatter::IsValueModified;
48 :
49 : public:
50 :
51 : virtual void SetValue(sal_Int64 nNewValue, FieldUnit eInUnit = FUNIT_NONE);
52 :
53 : PercentField( Window* pWin, const ResId& rResId );
54 :
55 : void SetPrcntValue(sal_Int64 nNewValue, FieldUnit eInUnit = FUNIT_NONE);
56 :
57 : void SetUserValue(sal_Int64 nNewValue, FieldUnit eInUnit = FUNIT_NONE);
58 :
59 : void SetBaseValue(sal_Int64 nNewValue, FieldUnit eInUnit = FUNIT_NONE);
60 :
61 : sal_Int64 GetValue(FieldUnit eOutUnit = FUNIT_NONE);
62 :
63 : sal_Bool IsValueModified();
64 :
65 : //using NumericFormatter::SetMax;
66 : void SetMax(sal_Int64 nNewMax, FieldUnit eInUnit = FUNIT_NONE);
67 :
68 : //using NumericFormatter::SetMin;
69 : void SetMin(sal_Int64 nNewMin, FieldUnit eInUnit = FUNIT_NONE);
70 :
71 : sal_Int64 NormalizePercent(sal_Int64 nValue);
72 : sal_Int64 DenormalizePercent(sal_Int64 nValue);
73 :
74 : void SetRefValue(sal_Int64 nValue);
75 : inline sal_Int64 GetRefValue() const { return nRefValue; }
76 : sal_Int64 GetRealValue(FieldUnit eOutUnit = FUNIT_NONE);
77 :
78 : sal_Int64 Convert(sal_Int64 nValue, FieldUnit eInUnit, FieldUnit eOutUnit);
79 :
80 : void ShowPercent(sal_Bool bPercent);
81 :
82 : sal_uInt16 GetOldDigits() const {return nOldDigits;}
83 :
84 0 : void LockAutoCalculation(sal_Bool bLock) {bLockAutoCalculation = bLock;}
85 : sal_Bool IsAutoCalculationLocked()const {return bLockAutoCalculation;}
86 : };
87 :
88 : #endif // _PRCNTFLD_HXX
89 :
90 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|