1 // Copyright 2016 The PDFium Authors 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/widestring.h" 11 #include "xfa/fxfa/fxfa_basic.h" 12 13 class CXFA_Measurement { 14 public: 15 explicit CXFA_Measurement(WideStringView wsMeasure); 16 CXFA_Measurement(); 17 CXFA_Measurement(float fValue, XFA_Unit eUnit); 18 19 static XFA_Unit GetUnitFromString(WideStringView wsUnit); 20 Set(float fValue,XFA_Unit eUnit)21 void Set(float fValue, XFA_Unit eUnit) { 22 m_fValue = fValue; 23 m_eUnit = eUnit; 24 } 25 GetUnit()26 XFA_Unit GetUnit() const { return m_eUnit; } GetValue()27 float GetValue() const { return m_fValue; } 28 29 WideString ToString() const; 30 float ToUnit(XFA_Unit eUnit) const; 31 32 private: 33 void SetString(WideStringView wsMeasure); 34 bool ToUnitInternal(XFA_Unit eUnit, float* fValue) const; 35 36 float m_fValue = 0.0f; 37 XFA_Unit m_eUnit = XFA_Unit::Percent; 38 }; 39 40 #endif // XFA_FXFA_PARSER_CXFA_MEASUREMENT_H_ 41