diff options
Diffstat (limited to 'fxjs')
-rw-r--r-- | fxjs/xfa/cjx_object.cpp | 8 | ||||
-rw-r--r-- | fxjs/xfa/cjx_object.h | 1 |
2 files changed, 9 insertions, 0 deletions
diff --git a/fxjs/xfa/cjx_object.cpp b/fxjs/xfa/cjx_object.cpp index 304b861dcf..b1e3030020 100644 --- a/fxjs/xfa/cjx_object.cpp +++ b/fxjs/xfa/cjx_object.cpp @@ -431,6 +431,14 @@ pdfium::Optional<CXFA_Measurement> CJX_Object::TryMeasure( return ToNode(GetXFAObject())->GetDefaultMeasurement(eAttr); } +pdfium::Optional<float> CJX_Object::TryMeasureAsFloat( + XFA_Attribute attr) const { + pdfium::Optional<CXFA_Measurement> measure = TryMeasure(attr, false); + if (measure) + return {measure->ToUnit(XFA_Unit::Pt)}; + return {}; +} + CXFA_Measurement CJX_Object::GetMeasure(XFA_Attribute eAttr) const { return TryMeasure(eAttr, true).value_or(CXFA_Measurement()); } diff --git a/fxjs/xfa/cjx_object.h b/fxjs/xfa/cjx_object.h index f6ce3ccfb8..32bb01f3f6 100644 --- a/fxjs/xfa/cjx_object.h +++ b/fxjs/xfa/cjx_object.h @@ -197,6 +197,7 @@ class CJX_Object { pdfium::Optional<CXFA_Measurement> TryMeasure(XFA_Attribute eAttr, bool bUseDefault) const; + pdfium::Optional<float> TryMeasureAsFloat(XFA_Attribute attr) const; bool SetMeasure(XFA_Attribute eAttr, CXFA_Measurement mValue, bool bNotify); CXFA_Measurement GetMeasure(XFA_Attribute eAttr) const; |