summaryrefslogtreecommitdiff
path: root/xfa/fxfa/parser/cxfa_box.cpp
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2018-01-03 15:52:41 -0500
committerChromium commit bot <commit-bot@chromium.org>2018-01-03 21:12:00 +0000
commitbf1cf346ba28a9eab0d2ea490868c51040ee2bc4 (patch)
treec1986792d22464cb308fb4d29980fea25c688362 /xfa/fxfa/parser/cxfa_box.cpp
parentfa50df5605a14ca4c9ba440506685981f1c8b04b (diff)
downloadpdfium-bf1cf346ba28a9eab0d2ea490868c51040ee2bc4.tar.xz
Convert CXFA_StrokeData to CXFA_Stroke
This CL changes CXFA_StrokeData to CXFA_Stroke and changes the inheritance form CXFA_DataData to CXFA_Node. The CXFA_EdgeData and CXFA_CornerData classes are removed and the node equivalents are changed to inherit from CXFA_Stroke. Change-Id: I8aa4365a8ed79c29c3a4c34879abe898a188b7de Reviewed-on: https://pdfium-review.googlesource.com/22151 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
Diffstat (limited to 'xfa/fxfa/parser/cxfa_box.cpp')
-rw-r--r--xfa/fxfa/parser/cxfa_box.cpp71
1 files changed, 36 insertions, 35 deletions
diff --git a/xfa/fxfa/parser/cxfa_box.cpp b/xfa/fxfa/parser/cxfa_box.cpp
index 544a21dcc0..78362020da 100644
--- a/xfa/fxfa/parser/cxfa_box.cpp
+++ b/xfa/fxfa/parser/cxfa_box.cpp
@@ -9,7 +9,6 @@
#include <utility>
#include "xfa/fxfa/parser/cxfa_corner.h"
-#include "xfa/fxfa/parser/cxfa_cornerdata.h"
#include "xfa/fxfa/parser/cxfa_edge.h"
#include "xfa/fxfa/parser/cxfa_fill.h"
#include "xfa/fxfa/parser/cxfa_margin.h"
@@ -18,32 +17,31 @@
namespace {
-XFA_AttributeEnum Style3D(const std::vector<CXFA_StrokeData>& strokes,
- CXFA_StrokeData& strokeData) {
+std::pair<XFA_AttributeEnum, CXFA_Stroke*> Style3D(
+ const std::vector<CXFA_Stroke*>& strokes) {
if (strokes.empty())
- return XFA_AttributeEnum::Unknown;
+ return {XFA_AttributeEnum::Unknown, nullptr};
- strokeData = strokes[0];
+ CXFA_Stroke* stroke = strokes[0];
for (size_t i = 1; i < strokes.size(); i++) {
- CXFA_StrokeData find = strokes[i];
- if (!find.HasValidNode())
+ CXFA_Stroke* find = strokes[i];
+ if (!find)
continue;
-
- if (!strokeData.HasValidNode())
- strokeData = find;
- else if (strokeData.GetStrokeType() != find.GetStrokeType())
- strokeData = find;
+ if (!stroke)
+ stroke = find;
+ else if (stroke->GetStrokeType() != find->GetStrokeType())
+ stroke = find;
break;
}
- XFA_AttributeEnum iType = strokeData.GetStrokeType();
+ XFA_AttributeEnum iType = stroke->GetStrokeType();
if (iType == XFA_AttributeEnum::Lowered ||
iType == XFA_AttributeEnum::Raised ||
iType == XFA_AttributeEnum::Etched ||
iType == XFA_AttributeEnum::Embossed) {
- return iType;
+ return {iType, stroke};
}
- return XFA_AttributeEnum::Unknown;
+ return {XFA_AttributeEnum::Unknown, stroke};
}
} // namespace
@@ -83,12 +81,12 @@ int32_t CXFA_Box::CountEdges() {
return CountChildren(XFA_Element::Edge, false);
}
-CXFA_EdgeData CXFA_Box::GetEdgeData(int32_t nIndex) {
- return CXFA_EdgeData(JSObject()->GetProperty<CXFA_Edge>(
- nIndex, XFA_Element::Edge, nIndex == 0));
+CXFA_Edge* CXFA_Box::GetEdge(int32_t nIndex) {
+ return JSObject()->GetProperty<CXFA_Edge>(nIndex, XFA_Element::Edge,
+ nIndex == 0);
}
-std::vector<CXFA_StrokeData> CXFA_Box::GetStrokes() {
+std::vector<CXFA_Stroke*> CXFA_Box::GetStrokes() {
return GetStrokesInternal(false);
}
@@ -118,24 +116,26 @@ std::tuple<XFA_AttributeEnum, bool, float> CXFA_Box::Get3DStyle() {
if (IsArc())
return {XFA_AttributeEnum::Unknown, false, 0.0f};
- std::vector<CXFA_StrokeData> strokes = GetStrokesInternal(true);
- CXFA_StrokeData strokeData(nullptr);
- XFA_AttributeEnum iType = Style3D(strokes, strokeData);
+ std::vector<CXFA_Stroke*> strokes = GetStrokesInternal(true);
+ CXFA_Stroke* stroke;
+ XFA_AttributeEnum iType;
+
+ std::tie(iType, stroke) = Style3D(strokes);
if (iType == XFA_AttributeEnum::Unknown)
return {XFA_AttributeEnum::Unknown, false, 0.0f};
- return {iType, strokeData.IsVisible(), strokeData.GetThickness()};
+ return {iType, stroke->IsVisible(), stroke->GetThickness()};
}
-std::vector<CXFA_StrokeData> CXFA_Box::GetStrokesInternal(bool bNull) {
- std::vector<CXFA_StrokeData> strokes;
+std::vector<CXFA_Stroke*> CXFA_Box::GetStrokesInternal(bool bNull) {
+ std::vector<CXFA_Stroke*> strokes;
strokes.resize(8);
- int32_t i, j;
- for (i = 0, j = 0; i < 4; i++) {
- CXFA_CornerData cornerData = CXFA_CornerData(
- JSObject()->GetProperty<CXFA_Corner>(i, XFA_Element::Corner, i == 0));
- if (cornerData.HasValidNode() || i == 0) {
- strokes[j] = cornerData;
+
+ for (int32_t i = 0, j = 0; i < 4; i++) {
+ CXFA_Corner* corner =
+ JSObject()->GetProperty<CXFA_Corner>(i, XFA_Element::Corner, i == 0);
+ if (corner || i == 0) {
+ strokes[j] = corner;
} else if (!bNull) {
if (i == 1 || i == 2)
strokes[j] = strokes[0];
@@ -143,10 +143,11 @@ std::vector<CXFA_StrokeData> CXFA_Box::GetStrokesInternal(bool bNull) {
strokes[j] = strokes[2];
}
j++;
- CXFA_EdgeData edgeData = CXFA_EdgeData(
- JSObject()->GetProperty<CXFA_Edge>(i, XFA_Element::Edge, i == 0));
- if (edgeData.HasValidNode() || i == 0) {
- strokes[j] = edgeData;
+
+ CXFA_Edge* edge =
+ JSObject()->GetProperty<CXFA_Edge>(i, XFA_Element::Edge, i == 0);
+ if (edge || i == 0) {
+ strokes[j] = edge;
} else if (!bNull) {
if (i == 1 || i == 2)
strokes[j] = strokes[1];