summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--xfa/fxfa/parser/cxfa_margindata.cpp44
-rw-r--r--xfa/fxfa/parser/cxfa_margindata.h8
-rw-r--r--xfa/fxfa/parser/cxfa_widgetdata.cpp32
3 files changed, 42 insertions, 42 deletions
diff --git a/xfa/fxfa/parser/cxfa_margindata.cpp b/xfa/fxfa/parser/cxfa_margindata.cpp
index 4eedaeb7e7..3af8352263 100644
--- a/xfa/fxfa/parser/cxfa_margindata.cpp
+++ b/xfa/fxfa/parser/cxfa_margindata.cpp
@@ -9,41 +9,45 @@
CXFA_MarginData::CXFA_MarginData(CXFA_Node* pNode) : CXFA_DataData(pNode) {}
float CXFA_MarginData::GetLeftInset() const {
- float left = 0;
- TryLeftInset(left);
- return left;
+ return TryLeftInset().value_or(0);
}
float CXFA_MarginData::GetTopInset() const {
- float top = 0;
- TryTopInset(top);
- return top;
+ return TryTopInset().value_or(0);
}
float CXFA_MarginData::GetRightInset() const {
- float right = 0;
- TryRightInset(right);
- return right;
+ return TryRightInset().value_or(0);
}
float CXFA_MarginData::GetBottomInset() const {
- float bottom = 0;
- TryBottomInset(bottom);
- return bottom;
+ return TryBottomInset().value_or(0);
}
-bool CXFA_MarginData::TryLeftInset(float& fInset) const {
- return TryMeasure(XFA_Attribute::LeftInset, fInset);
+pdfium::Optional<float> CXFA_MarginData::TryLeftInset() const {
+ float value = 0;
+ if (TryMeasure(XFA_Attribute::LeftInset, value))
+ return {value};
+ return {};
}
-bool CXFA_MarginData::TryTopInset(float& fInset) const {
- return TryMeasure(XFA_Attribute::TopInset, fInset);
+pdfium::Optional<float> CXFA_MarginData::TryTopInset() const {
+ float value = 0;
+ if (TryMeasure(XFA_Attribute::TopInset, value))
+ return {value};
+ return {};
}
-bool CXFA_MarginData::TryRightInset(float& fInset) const {
- return TryMeasure(XFA_Attribute::RightInset, fInset);
+pdfium::Optional<float> CXFA_MarginData::TryRightInset() const {
+ float value = 0;
+ if (TryMeasure(XFA_Attribute::RightInset, value))
+ return {value};
+ return {};
}
-bool CXFA_MarginData::TryBottomInset(float& fInset) const {
- return TryMeasure(XFA_Attribute::BottomInset, fInset);
+pdfium::Optional<float> CXFA_MarginData::TryBottomInset() const {
+ float value = 0;
+ if (TryMeasure(XFA_Attribute::BottomInset, value))
+ return {value};
+ return {};
}
diff --git a/xfa/fxfa/parser/cxfa_margindata.h b/xfa/fxfa/parser/cxfa_margindata.h
index 1a8b4d8be1..069aa7cc2d 100644
--- a/xfa/fxfa/parser/cxfa_margindata.h
+++ b/xfa/fxfa/parser/cxfa_margindata.h
@@ -21,10 +21,10 @@ class CXFA_MarginData : public CXFA_DataData {
float GetRightInset() const;
float GetBottomInset() const;
- bool TryLeftInset(float& fInset) const;
- bool TryTopInset(float& fInset) const;
- bool TryRightInset(float& fInset) const;
- bool TryBottomInset(float& fInset) const;
+ pdfium::Optional<float> TryLeftInset() const;
+ pdfium::Optional<float> TryTopInset() const;
+ pdfium::Optional<float> TryRightInset() const;
+ pdfium::Optional<float> TryBottomInset() const;
};
#endif // XFA_FXFA_PARSER_CXFA_MARGINDATA_H_
diff --git a/xfa/fxfa/parser/cxfa_widgetdata.cpp b/xfa/fxfa/parser/cxfa_widgetdata.cpp
index 98e81f3c2b..1828854500 100644
--- a/xfa/fxfa/parser/cxfa_widgetdata.cpp
+++ b/xfa/fxfa/parser/cxfa_widgetdata.cpp
@@ -373,32 +373,28 @@ CFX_RectF CXFA_WidgetData::GetUIMargin() {
return CFX_RectF();
}
- float fLeftInset = 0;
- float fTopInset = 0;
- float fRightInset = 0;
- float fBottomInset = 0;
- bool bLeft = mgUI.TryLeftInset(fLeftInset);
- bool bTop = mgUI.TryTopInset(fTopInset);
- bool bRight = mgUI.TryRightInset(fRightInset);
- bool bBottom = mgUI.TryBottomInset(fBottomInset);
+ pdfium::Optional<float> left = mgUI.TryLeftInset();
+ pdfium::Optional<float> top = mgUI.TryTopInset();
+ pdfium::Optional<float> right = mgUI.TryRightInset();
+ pdfium::Optional<float> bottom = mgUI.TryBottomInset();
if (borderData.HasValidNode()) {
bool bVisible = false;
float fThickness = 0;
int32_t iType = 0;
std::tie(iType, bVisible, fThickness) = borderData.Get3DStyle();
- if (!bLeft || !bTop || !bRight || !bBottom) {
+ if (!left || !top || !right || !bottom) {
std::vector<CXFA_StrokeData> strokes = borderData.GetStrokes();
- if (!bTop)
- fTopInset = GetEdgeThickness(strokes, bVisible, 0);
- if (!bRight)
- fRightInset = GetEdgeThickness(strokes, bVisible, 1);
- if (!bBottom)
- fBottomInset = GetEdgeThickness(strokes, bVisible, 2);
- if (!bLeft)
- fLeftInset = GetEdgeThickness(strokes, bVisible, 3);
+ if (!top)
+ top = GetEdgeThickness(strokes, bVisible, 0);
+ if (!right)
+ right = GetEdgeThickness(strokes, bVisible, 1);
+ if (!bottom)
+ bottom = GetEdgeThickness(strokes, bVisible, 2);
+ if (!left)
+ left = GetEdgeThickness(strokes, bVisible, 3);
}
}
- return CFX_RectF(fLeftInset, fTopInset, fRightInset, fBottomInset);
+ return CFX_RectF(*left, *top, *right, *bottom);
}
XFA_ATTRIBUTEENUM CXFA_WidgetData::GetButtonHighlight() {