• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2016 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 
7 #ifndef XFA_FXFA_PARSER_CXFA_MEASUREMENT_H_
8 #define XFA_FXFA_PARSER_CXFA_MEASUREMENT_H_
9 
10 #include "core/fxcrt/fx_string.h"
11 #include "core/fxcrt/fx_system.h"
12 #include "xfa/fxfa/fxfa_basic.h"
13 
14 class CXFA_Measurement {
15  public:
16   explicit CXFA_Measurement(const WideStringView& wsMeasure);
17   CXFA_Measurement();
18   CXFA_Measurement(float fValue, XFA_Unit eUnit);
19 
20   static XFA_Unit GetUnitFromString(const WideStringView& wsUnit);
21 
Set(float fValue,XFA_Unit eUnit)22   void Set(float fValue, XFA_Unit eUnit) {
23     m_fValue = fValue;
24     m_eUnit = eUnit;
25   }
26 
GetUnit()27   XFA_Unit GetUnit() const { return m_eUnit; }
GetValue()28   float GetValue() const { return m_fValue; }
29 
30   WideString ToString() const;
31   float ToUnit(XFA_Unit eUnit) const;
32 
33  private:
34   void SetString(const WideStringView& wsMeasure);
35   bool ToUnitInternal(XFA_Unit eUnit, float* fValue) const;
36 
37   float m_fValue;
38   XFA_Unit m_eUnit;
39 };
40 
41 #endif  // XFA_FXFA_PARSER_CXFA_MEASUREMENT_H_
42