summaryrefslogtreecommitdiff
path: root/xfa
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-11-20 21:16:43 +0000
committerChromium commit bot <commit-bot@chromium.org>2017-11-20 21:16:43 +0000
commit1699413c207c228ae7eae3d47e89adacc1146d65 (patch)
tree2a6020ff5b1d658c618ea32a04f86aaa9ee86b72 /xfa
parentef2b74990f4f2a82e279ef5b8a911d89be1e83e2 (diff)
downloadpdfium-1699413c207c228ae7eae3d47e89adacc1146d65.tar.xz
Cleanup return types in CXFA_BoxData
This CL cleans up the return types in CXFA_BoxData to use std::tuple and pdfium::Optional where appropriate. Change-Id: I0790fb43769185fa4cbdd7460411a3d1120e9fa1 Reviewed-on: https://pdfium-review.googlesource.com/18812 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Diffstat (limited to 'xfa')
-rw-r--r--xfa/fxfa/cxfa_ffwidget.cpp20
-rw-r--r--xfa/fxfa/parser/cxfa_boxdata.cpp35
-rw-r--r--xfa/fxfa/parser/cxfa_boxdata.h27
-rw-r--r--xfa/fxfa/parser/cxfa_widgetdata.cpp3
4 files changed, 37 insertions, 48 deletions
diff --git a/xfa/fxfa/cxfa_ffwidget.cpp b/xfa/fxfa/cxfa_ffwidget.cpp
index 6bcf524586..bb2d2e8a1c 100644
--- a/xfa/fxfa/cxfa_ffwidget.cpp
+++ b/xfa/fxfa/cxfa_ffwidget.cpp
@@ -54,16 +54,16 @@ void XFA_BOX_GetPath_Arc(const CXFA_BoxData& boxData,
rtDraw.top = center.y - b;
rtDraw.width = a + a;
rtDraw.height = b + b;
- float startAngle = 0, sweepAngle = 360;
- bool bStart = boxData.GetStartAngle(startAngle);
- bool bEnd = boxData.GetSweepAngle(sweepAngle);
- if (!bStart && !bEnd) {
+ pdfium::Optional<float> startAngle = boxData.GetStartAngle();
+ pdfium::Optional<float> sweepAngle = boxData.GetSweepAngle();
+ if (!startAngle && !sweepAngle) {
fillPath.AddEllipse(rtDraw);
return;
}
- startAngle = -startAngle * FX_PI / 180.0f;
- sweepAngle = -sweepAngle * FX_PI / 180.0f;
- fillPath.AddArc(rtDraw.TopLeft(), rtDraw.Size(), startAngle, sweepAngle);
+
+ fillPath.AddArc(rtDraw.TopLeft(), rtDraw.Size(),
+ -startAngle.value_or(0) * FX_PI / 180.0f,
+ -sweepAngle.value_or(360) * FX_PI / 180.0f);
}
void XFA_BOX_GetPath(const std::vector<CXFA_StrokeData>& strokes,
@@ -560,7 +560,8 @@ void XFA_BOX_StrokeArc(const CXFA_BoxData& boxData,
bool bVisible = false;
float fThickness = 0;
- int32_t i3DType = boxData.Get3DStyle(bVisible, fThickness);
+ int32_t i3DType = 0;
+ std::tie(i3DType, bVisible, fThickness) = boxData.Get3DStyle();
if (i3DType) {
if (bVisible && fThickness >= 0.001f) {
dwFlags |= XFA_DRAWBOX_Lowered3D;
@@ -727,7 +728,8 @@ void XFA_BOX_Stroke_Rect(CXFA_BoxData boxData,
const CFX_Matrix& matrix) {
bool bVisible = false;
float fThickness = 0;
- int32_t i3DType = boxData.Get3DStyle(bVisible, fThickness);
+ int32_t i3DType = 0;
+ std::tie(i3DType, bVisible, fThickness) = boxData.Get3DStyle();
if (i3DType) {
if (!bVisible || fThickness < 0.001f) {
return;
diff --git a/xfa/fxfa/parser/cxfa_boxdata.cpp b/xfa/fxfa/parser/cxfa_boxdata.cpp
index 813a0a6229..5545494aac 100644
--- a/xfa/fxfa/parser/cxfa_boxdata.cpp
+++ b/xfa/fxfa/parser/cxfa_boxdata.cpp
@@ -108,32 +108,26 @@ bool CXFA_BoxData::IsCircular() const {
return m_pNode->JSNode()->GetBoolean(XFA_Attribute::Circular);
}
-bool CXFA_BoxData::GetStartAngle(float& fStartAngle) const {
- fStartAngle = 0;
+pdfium::Optional<float> CXFA_BoxData::GetStartAngle() const {
if (!m_pNode)
- return false;
+ return {};
pdfium::Optional<CXFA_Measurement> measure =
m_pNode->JSNode()->TryMeasure(XFA_Attribute::StartAngle, false);
if (!measure)
- return false;
-
- fStartAngle = measure->GetValue();
- return true;
+ return {};
+ return {measure->GetValue()};
}
-bool CXFA_BoxData::GetSweepAngle(float& fSweepAngle) const {
- fSweepAngle = 360;
+pdfium::Optional<float> CXFA_BoxData::GetSweepAngle() const {
if (!m_pNode)
- return false;
+ return {};
pdfium::Optional<CXFA_Measurement> measure =
m_pNode->JSNode()->TryMeasure(XFA_Attribute::SweepAngle, false);
if (!measure)
- return false;
-
- fSweepAngle = measure->GetValue();
- return true;
+ return {};
+ return {measure->GetValue()};
}
CXFA_FillData CXFA_BoxData::GetFillData(bool bModified) const {
@@ -150,16 +144,15 @@ CXFA_MarginData CXFA_BoxData::GetMarginData() const {
m_pNode ? m_pNode->GetChild(0, XFA_Element::Margin, false) : nullptr);
}
-int32_t CXFA_BoxData::Get3DStyle(bool& bVisible, float& fThickness) const {
+std::tuple<int32_t, bool, float> CXFA_BoxData::Get3DStyle() const {
if (IsArc())
- return 0;
+ return {0, false, 0.0f};
std::vector<CXFA_StrokeData> strokes = GetStrokesInternal(m_pNode, true);
CXFA_StrokeData strokeData(nullptr);
int32_t iType = Style3D(strokes, strokeData);
- if (iType) {
- bVisible = strokeData.IsVisible();
- fThickness = strokeData.GetThickness();
- }
- return iType;
+ if (iType == 0)
+ return {0, false, 0.0f};
+
+ return {iType, strokeData.IsVisible(), strokeData.GetThickness()};
}
diff --git a/xfa/fxfa/parser/cxfa_boxdata.h b/xfa/fxfa/parser/cxfa_boxdata.h
index 14f8b35235..d3d1887719 100644
--- a/xfa/fxfa/parser/cxfa_boxdata.h
+++ b/xfa/fxfa/parser/cxfa_boxdata.h
@@ -7,6 +7,7 @@
#ifndef XFA_FXFA_PARSER_CXFA_BOXDATA_H_
#define XFA_FXFA_PARSER_CXFA_BOXDATA_H_
+#include <tuple>
#include <vector>
#include "core/fxcrt/fx_system.h"
@@ -26,29 +27,21 @@ class CXFA_BoxData : public CXFA_DataData {
bool IsRectangle() const {
return GetElementType() == XFA_Element::Rectangle;
}
+ bool IsCircular() const;
+
int32_t GetHand() const;
int32_t GetPresence() const;
+ std::tuple<int32_t, bool, float> Get3DStyle() const;
+
int32_t CountEdges() const;
CXFA_EdgeData GetEdgeData(int32_t nIndex) const;
- std::vector<CXFA_StrokeData> GetStrokes() const;
- bool IsCircular() const;
- bool GetStartAngle(float& fStartAngle) const;
- float GetStartAngle() const {
- float fStartAngle;
- GetStartAngle(fStartAngle);
- return fStartAngle;
- }
-
- bool GetSweepAngle(float& fSweepAngle) const;
- float GetSweepAngle() const {
- float fSweepAngle;
- GetSweepAngle(fSweepAngle);
- return fSweepAngle;
- }
-
CXFA_FillData GetFillData(bool bModified) const;
CXFA_MarginData GetMarginData() const;
- int32_t Get3DStyle(bool& bVisible, float& fThickness) const;
+
+ std::vector<CXFA_StrokeData> GetStrokes() const;
+
+ pdfium::Optional<float> GetStartAngle() const;
+ pdfium::Optional<float> GetSweepAngle() const;
};
#endif // XFA_FXFA_PARSER_CXFA_BOXDATA_H_
diff --git a/xfa/fxfa/parser/cxfa_widgetdata.cpp b/xfa/fxfa/parser/cxfa_widgetdata.cpp
index 894411760c..cff2d6b004 100644
--- a/xfa/fxfa/parser/cxfa_widgetdata.cpp
+++ b/xfa/fxfa/parser/cxfa_widgetdata.cpp
@@ -379,7 +379,8 @@ CFX_RectF CXFA_WidgetData::GetUIMargin() {
if (borderData) {
bool bVisible = false;
float fThickness = 0;
- borderData.Get3DStyle(bVisible, fThickness);
+ int32_t iType = 0;
+ std::tie(iType, bVisible, fThickness) = borderData.Get3DStyle();
if (!bLeft || !bTop || !bRight || !bBottom) {
std::vector<CXFA_StrokeData> strokes = borderData.GetStrokes();
if (!bTop)