7#include "xfa/fxfa/parser/cxfa_measurement.h"
11#include "core/fxcrt/fx_extension.h"
12#include "third_party/base/notreached.h"
16constexpr float kPtToInch = 72;
17constexpr float kPtToCm = kPtToInch / 2.54f;
18constexpr float kPtToMm = kPtToCm / 10;
19constexpr float kPtToMp = 0.001f;
20constexpr float kPtToPc = 12;
37 if (wsMeasure.Front() == L'=')
38 wsMeasure = wsMeasure.Substr(1);
40 if (wsMeasure.IsEmpty()) {
46 float fValue = FXSYS_wcstof(wsMeasure.unterminated_c_str(),
47 wsMeasure.GetLength(), &nUsedLen);
48 if (!isfinite(fValue))
80 return ToUnitInternal(eUnit, &f) ? f : 0;
118 *fValue /= kPtToInch;
130 NOTREACHED_NORETURN();
136 if (wsUnit.EqualsASCII(
"mm"))
138 if (wsUnit.EqualsASCII(
"pt"))
140 if (wsUnit.EqualsASCII(
"in"))
142 if (wsUnit.EqualsASCII(
"cm"))
144 if (wsUnit.EqualsASCII(
"pc"))
146 if (wsUnit.EqualsASCII(
"mp"))
148 if (wsUnit.EqualsASCII(
"em"))
150 if (wsUnit.EqualsASCII(
"%"))
CXFA_Measurement(float fValue, XFA_Unit eUnit)
void Set(float fValue, XFA_Unit eUnit)
CXFA_Measurement(WideStringView wsMeasure)
float ToUnit(XFA_Unit eUnit) const
static XFA_Unit GetUnitFromString(WideStringView wsUnit)
WideString ToString() const
static WideString Format(const wchar_t *pFormat,...)