diff options
Diffstat (limited to 'xfa/fxfa/parser/cxfa_measurement.cpp')
-rw-r--r-- | xfa/fxfa/parser/cxfa_measurement.cpp | 74 |
1 files changed, 37 insertions, 37 deletions
diff --git a/xfa/fxfa/parser/cxfa_measurement.cpp b/xfa/fxfa/parser/cxfa_measurement.cpp index 24b5ba2f59..053f9d1c47 100644 --- a/xfa/fxfa/parser/cxfa_measurement.cpp +++ b/xfa/fxfa/parser/cxfa_measurement.cpp @@ -23,52 +23,52 @@ CXFA_Measurement::CXFA_Measurement(const WideStringView& wsMeasure) { } CXFA_Measurement::CXFA_Measurement() { - Set(-1, XFA_UNIT_Unknown); + Set(-1, XFA_Unit::Unknown); } -CXFA_Measurement::CXFA_Measurement(float fValue, XFA_UNIT eUnit) { +CXFA_Measurement::CXFA_Measurement(float fValue, XFA_Unit eUnit) { Set(fValue, eUnit); } void CXFA_Measurement::SetString(const WideStringView& wsMeasure) { if (wsMeasure.IsEmpty()) { m_fValue = 0; - m_eUnit = XFA_UNIT_Unknown; + m_eUnit = XFA_Unit::Unknown; return; } int32_t iUsedLen = 0; int32_t iOffset = (wsMeasure[0] == L'=') ? 1 : 0; float fValue = FXSYS_wcstof(wsMeasure.unterminated_c_str() + iOffset, wsMeasure.GetLength() - iOffset, &iUsedLen); - XFA_UNIT eUnit = GetUnitFromString( + XFA_Unit eUnit = GetUnitFromString( wsMeasure.Right(wsMeasure.GetLength() - (iOffset + iUsedLen))); Set(fValue, eUnit); } bool CXFA_Measurement::ToString(WideString* wsMeasure) const { switch (GetUnit()) { - case XFA_UNIT_Mm: + case XFA_Unit::Mm: wsMeasure->Format(L"%.8gmm", GetValue()); return true; - case XFA_UNIT_Pt: + case XFA_Unit::Pt: wsMeasure->Format(L"%.8gpt", GetValue()); return true; - case XFA_UNIT_In: + case XFA_Unit::In: wsMeasure->Format(L"%.8gin", GetValue()); return true; - case XFA_UNIT_Cm: + case XFA_Unit::Cm: wsMeasure->Format(L"%.8gcm", GetValue()); return true; - case XFA_UNIT_Mp: + case XFA_Unit::Mp: wsMeasure->Format(L"%.8gmp", GetValue()); return true; - case XFA_UNIT_Pc: + case XFA_Unit::Pc: wsMeasure->Format(L"%.8gpc", GetValue()); return true; - case XFA_UNIT_Em: + case XFA_Unit::Em: wsMeasure->Format(L"%.8gem", GetValue()); return true; - case XFA_UNIT_Percent: + case XFA_Unit::Percent: wsMeasure->Format(L"%.8g%%", GetValue()); return true; default: @@ -77,33 +77,33 @@ bool CXFA_Measurement::ToString(WideString* wsMeasure) const { } } -float CXFA_Measurement::ToUnit(XFA_UNIT eUnit) const { +float CXFA_Measurement::ToUnit(XFA_Unit eUnit) const { float f; return ToUnitInternal(eUnit, &f) ? f : 0; } -bool CXFA_Measurement::ToUnitInternal(XFA_UNIT eUnit, float* fValue) const { +bool CXFA_Measurement::ToUnitInternal(XFA_Unit eUnit, float* fValue) const { *fValue = GetValue(); - XFA_UNIT eFrom = GetUnit(); + XFA_Unit eFrom = GetUnit(); if (eFrom == eUnit) return true; switch (eFrom) { - case XFA_UNIT_Pt: + case XFA_Unit::Pt: break; - case XFA_UNIT_Mm: + case XFA_Unit::Mm: *fValue *= kPtToMm; break; - case XFA_UNIT_In: + case XFA_Unit::In: *fValue *= kPtToInch; break; - case XFA_UNIT_Cm: + case XFA_Unit::Cm: *fValue *= kPtToCm; break; - case XFA_UNIT_Mp: + case XFA_Unit::Mp: *fValue *= kPtToMp; break; - case XFA_UNIT_Pc: + case XFA_Unit::Pc: *fValue *= kPtToPc; break; default: @@ -111,21 +111,21 @@ bool CXFA_Measurement::ToUnitInternal(XFA_UNIT eUnit, float* fValue) const { return false; } switch (eUnit) { - case XFA_UNIT_Pt: + case XFA_Unit::Pt: return true; - case XFA_UNIT_Mm: + case XFA_Unit::Mm: *fValue /= kPtToMm; return true; - case XFA_UNIT_In: + case XFA_Unit::In: *fValue /= kPtToInch; return true; - case XFA_UNIT_Cm: + case XFA_Unit::Cm: *fValue /= kPtToCm; return true; - case XFA_UNIT_Mp: + case XFA_Unit::Mp: *fValue /= kPtToMp; return true; - case XFA_UNIT_Pc: + case XFA_Unit::Pc: *fValue /= kPtToPc; return true; default: @@ -135,22 +135,22 @@ bool CXFA_Measurement::ToUnitInternal(XFA_UNIT eUnit, float* fValue) const { } // static -XFA_UNIT CXFA_Measurement::GetUnitFromString(const WideStringView& wsUnit) { +XFA_Unit CXFA_Measurement::GetUnitFromString(const WideStringView& wsUnit) { if (wsUnit == L"mm") - return XFA_UNIT_Mm; + return XFA_Unit::Mm; if (wsUnit == L"pt") - return XFA_UNIT_Pt; + return XFA_Unit::Pt; if (wsUnit == L"in") - return XFA_UNIT_In; + return XFA_Unit::In; if (wsUnit == L"cm") - return XFA_UNIT_Cm; + return XFA_Unit::Cm; if (wsUnit == L"pc") - return XFA_UNIT_Pc; + return XFA_Unit::Pc; if (wsUnit == L"mp") - return XFA_UNIT_Mp; + return XFA_Unit::Mp; if (wsUnit == L"em") - return XFA_UNIT_Em; + return XFA_Unit::Em; if (wsUnit == L"%") - return XFA_UNIT_Percent; - return XFA_UNIT_Unknown; + return XFA_Unit::Percent; + return XFA_Unit::Unknown; } |