summaryrefslogtreecommitdiff
path: root/xfa/fxfa/parser
diff options
context:
space:
mode:
Diffstat (limited to 'xfa/fxfa/parser')
-rw-r--r--xfa/fxfa/parser/cxfa_box.cpp71
-rw-r--r--xfa/fxfa/parser/cxfa_box.h9
-rw-r--r--xfa/fxfa/parser/cxfa_corner.cpp17
-rw-r--r--xfa/fxfa/parser/cxfa_corner.h4
-rw-r--r--xfa/fxfa/parser/cxfa_cornerdata.h19
-rw-r--r--xfa/fxfa/parser/cxfa_edge.cpp18
-rw-r--r--xfa/fxfa/parser/cxfa_edge.h4
-rw-r--r--xfa/fxfa/parser/cxfa_edgedata.h19
-rw-r--r--xfa/fxfa/parser/cxfa_linedata.cpp5
-rw-r--r--xfa/fxfa/parser/cxfa_linedata.h4
-rw-r--r--xfa/fxfa/parser/cxfa_stroke.cpp119
-rw-r--r--xfa/fxfa/parser/cxfa_stroke.h57
-rw-r--r--xfa/fxfa/parser/cxfa_strokedata.cpp117
-rw-r--r--xfa/fxfa/parser/cxfa_strokedata.h46
-rw-r--r--xfa/fxfa/parser/cxfa_widgetdata.cpp10
15 files changed, 249 insertions, 270 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];
diff --git a/xfa/fxfa/parser/cxfa_box.h b/xfa/fxfa/parser/cxfa_box.h
index 5d9ee4c6fd..dbc07c603d 100644
--- a/xfa/fxfa/parser/cxfa_box.h
+++ b/xfa/fxfa/parser/cxfa_box.h
@@ -12,11 +12,12 @@
#include <vector>
#include "xfa/fxfa/parser/cxfa_datadata.h"
-#include "xfa/fxfa/parser/cxfa_edgedata.h"
#include "xfa/fxfa/parser/cxfa_filldata.h"
#include "xfa/fxfa/parser/cxfa_node.h"
+class CXFA_Edge;
class CXFA_Margin;
+class CXFA_Stroke;
class CXFA_Box : public CXFA_Node {
public:
@@ -30,11 +31,11 @@ class CXFA_Box : public CXFA_Node {
std::tuple<XFA_AttributeEnum, bool, float> Get3DStyle();
int32_t CountEdges();
- CXFA_EdgeData GetEdgeData(int32_t nIndex);
+ CXFA_Edge* GetEdge(int32_t nIndex);
CXFA_FillData GetFillData(bool bModified);
CXFA_Margin* GetMargin();
- std::vector<CXFA_StrokeData> GetStrokes();
+ std::vector<CXFA_Stroke*> GetStrokes();
pdfium::Optional<int32_t> GetStartAngle();
pdfium::Optional<int32_t> GetSweepAngle();
@@ -51,7 +52,7 @@ class CXFA_Box : public CXFA_Node {
std::unique_ptr<CJX_Object> js_node);
private:
- std::vector<CXFA_StrokeData> GetStrokesInternal(bool bNull);
+ std::vector<CXFA_Stroke*> GetStrokesInternal(bool bNull);
};
#endif // XFA_FXFA_PARSER_CXFA_BOX_H_
diff --git a/xfa/fxfa/parser/cxfa_corner.cpp b/xfa/fxfa/parser/cxfa_corner.cpp
index f1757a0180..0cd3ef4fbc 100644
--- a/xfa/fxfa/parser/cxfa_corner.cpp
+++ b/xfa/fxfa/parser/cxfa_corner.cpp
@@ -34,13 +34,14 @@ constexpr wchar_t kName[] = L"corner";
} // namespace
CXFA_Corner::CXFA_Corner(CXFA_Document* doc, XFA_PacketType packet)
- : CXFA_Node(doc,
- packet,
- (XFA_XDPPACKET_Template | XFA_XDPPACKET_Form),
- XFA_ObjectType::Node,
- XFA_Element::Corner,
- kPropertyData,
- kAttributeData,
- kName) {}
+ : CXFA_Stroke(doc,
+ packet,
+ (XFA_XDPPACKET_Template | XFA_XDPPACKET_Form),
+ XFA_ObjectType::Node,
+ XFA_Element::Corner,
+ kPropertyData,
+ kAttributeData,
+ kName,
+ pdfium::MakeUnique<CJX_Corner>(this)) {}
CXFA_Corner::~CXFA_Corner() {}
diff --git a/xfa/fxfa/parser/cxfa_corner.h b/xfa/fxfa/parser/cxfa_corner.h
index df21984332..1042729bcc 100644
--- a/xfa/fxfa/parser/cxfa_corner.h
+++ b/xfa/fxfa/parser/cxfa_corner.h
@@ -7,9 +7,9 @@
#ifndef XFA_FXFA_PARSER_CXFA_CORNER_H_
#define XFA_FXFA_PARSER_CXFA_CORNER_H_
-#include "xfa/fxfa/parser/cxfa_node.h"
+#include "xfa/fxfa/parser/cxfa_stroke.h"
-class CXFA_Corner : public CXFA_Node {
+class CXFA_Corner : public CXFA_Stroke {
public:
CXFA_Corner(CXFA_Document* doc, XFA_PacketType packet);
~CXFA_Corner() override;
diff --git a/xfa/fxfa/parser/cxfa_cornerdata.h b/xfa/fxfa/parser/cxfa_cornerdata.h
deleted file mode 100644
index fd17bd5c89..0000000000
--- a/xfa/fxfa/parser/cxfa_cornerdata.h
+++ /dev/null
@@ -1,19 +0,0 @@
-// Copyright 2016 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef XFA_FXFA_PARSER_CXFA_CORNERDATA_H_
-#define XFA_FXFA_PARSER_CXFA_CORNERDATA_H_
-
-#include "xfa/fxfa/parser/cxfa_strokedata.h"
-
-class CXFA_Node;
-
-class CXFA_CornerData : public CXFA_StrokeData {
- public:
- explicit CXFA_CornerData(CXFA_Node* pNode) : CXFA_StrokeData(pNode) {}
-};
-
-#endif // XFA_FXFA_PARSER_CXFA_CORNERDATA_H_
diff --git a/xfa/fxfa/parser/cxfa_edge.cpp b/xfa/fxfa/parser/cxfa_edge.cpp
index 5eb969cc9f..65e599cc59 100644
--- a/xfa/fxfa/parser/cxfa_edge.cpp
+++ b/xfa/fxfa/parser/cxfa_edge.cpp
@@ -32,14 +32,14 @@ constexpr wchar_t kName[] = L"edge";
} // namespace
CXFA_Edge::CXFA_Edge(CXFA_Document* doc, XFA_PacketType packet)
- : CXFA_Node(doc,
- packet,
- (XFA_XDPPACKET_Template | XFA_XDPPACKET_Form),
- XFA_ObjectType::Node,
- XFA_Element::Edge,
- kPropertyData,
- kAttributeData,
- kName,
- pdfium::MakeUnique<CJX_Edge>(this)) {}
+ : CXFA_Stroke(doc,
+ packet,
+ (XFA_XDPPACKET_Template | XFA_XDPPACKET_Form),
+ XFA_ObjectType::Node,
+ XFA_Element::Edge,
+ kPropertyData,
+ kAttributeData,
+ kName,
+ pdfium::MakeUnique<CJX_Edge>(this)) {}
CXFA_Edge::~CXFA_Edge() {}
diff --git a/xfa/fxfa/parser/cxfa_edge.h b/xfa/fxfa/parser/cxfa_edge.h
index 135ea2a628..8bf9f6ea28 100644
--- a/xfa/fxfa/parser/cxfa_edge.h
+++ b/xfa/fxfa/parser/cxfa_edge.h
@@ -7,9 +7,9 @@
#ifndef XFA_FXFA_PARSER_CXFA_EDGE_H_
#define XFA_FXFA_PARSER_CXFA_EDGE_H_
-#include "xfa/fxfa/parser/cxfa_node.h"
+#include "xfa/fxfa/parser/cxfa_stroke.h"
-class CXFA_Edge : public CXFA_Node {
+class CXFA_Edge : public CXFA_Stroke {
public:
CXFA_Edge(CXFA_Document* doc, XFA_PacketType packet);
~CXFA_Edge() override;
diff --git a/xfa/fxfa/parser/cxfa_edgedata.h b/xfa/fxfa/parser/cxfa_edgedata.h
deleted file mode 100644
index 2a55814a31..0000000000
--- a/xfa/fxfa/parser/cxfa_edgedata.h
+++ /dev/null
@@ -1,19 +0,0 @@
-// Copyright 2016 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef XFA_FXFA_PARSER_CXFA_EDGEDATA_H_
-#define XFA_FXFA_PARSER_CXFA_EDGEDATA_H_
-
-#include "xfa/fxfa/parser/cxfa_strokedata.h"
-
-class CXFA_Node;
-
-class CXFA_EdgeData : public CXFA_StrokeData {
- public:
- explicit CXFA_EdgeData(CXFA_Node* pNode) : CXFA_StrokeData(pNode) {}
-};
-
-#endif // XFA_FXFA_PARSER_CXFA_EDGEDATA_H_
diff --git a/xfa/fxfa/parser/cxfa_linedata.cpp b/xfa/fxfa/parser/cxfa_linedata.cpp
index 37f4f2a48f..2c191e041c 100644
--- a/xfa/fxfa/parser/cxfa_linedata.cpp
+++ b/xfa/fxfa/parser/cxfa_linedata.cpp
@@ -18,7 +18,6 @@ bool CXFA_LineData::GetSlope() const {
XFA_AttributeEnum::Slash;
}
-CXFA_EdgeData CXFA_LineData::GetEdgeData() const {
- return CXFA_EdgeData(
- m_pNode->GetChild<CXFA_Edge>(0, XFA_Element::Edge, false));
+CXFA_Edge* CXFA_LineData::GetEdge() const {
+ return m_pNode->GetChild<CXFA_Edge>(0, XFA_Element::Edge, false);
}
diff --git a/xfa/fxfa/parser/cxfa_linedata.h b/xfa/fxfa/parser/cxfa_linedata.h
index c1cc1e468c..b97210a953 100644
--- a/xfa/fxfa/parser/cxfa_linedata.h
+++ b/xfa/fxfa/parser/cxfa_linedata.h
@@ -9,8 +9,8 @@
#include "core/fxcrt/fx_system.h"
#include "xfa/fxfa/parser/cxfa_datadata.h"
-#include "xfa/fxfa/parser/cxfa_edgedata.h"
+class CXFA_Edge;
class CXFA_Node;
class CXFA_LineData : public CXFA_DataData {
@@ -19,7 +19,7 @@ class CXFA_LineData : public CXFA_DataData {
XFA_AttributeEnum GetHand() const;
bool GetSlope() const;
- CXFA_EdgeData GetEdgeData() const;
+ CXFA_Edge* GetEdge() const;
};
#endif // XFA_FXFA_PARSER_CXFA_LINEDATA_H_
diff --git a/xfa/fxfa/parser/cxfa_stroke.cpp b/xfa/fxfa/parser/cxfa_stroke.cpp
new file mode 100644
index 0000000000..3b8e37a728
--- /dev/null
+++ b/xfa/fxfa/parser/cxfa_stroke.cpp
@@ -0,0 +1,119 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "xfa/fxfa/parser/cxfa_stroke.h"
+
+#include <utility>
+
+#include "xfa/fxfa/parser/cxfa_color.h"
+#include "xfa/fxfa/parser/cxfa_measurement.h"
+#include "xfa/fxfa/parser/cxfa_node.h"
+#include "xfa/fxfa/parser/xfa_utils.h"
+
+CXFA_Stroke::CXFA_Stroke(CXFA_Document* pDoc,
+ XFA_PacketType ePacket,
+ uint32_t validPackets,
+ XFA_ObjectType oType,
+ XFA_Element eType,
+ const PropertyData* properties,
+ const AttributeData* attributes,
+ const WideStringView& elementName,
+ std::unique_ptr<CJX_Object> js_node)
+ : CXFA_Node(pDoc,
+ ePacket,
+ validPackets,
+ oType,
+ eType,
+ properties,
+ attributes,
+ elementName,
+ std::move(js_node)) {}
+
+CXFA_Stroke::~CXFA_Stroke() = default;
+
+bool CXFA_Stroke::IsVisible() {
+ XFA_AttributeEnum presence = JSObject()
+ ->TryEnum(XFA_Attribute::Presence, true)
+ .value_or(XFA_AttributeEnum::Visible);
+ return presence == XFA_AttributeEnum::Visible;
+}
+
+XFA_AttributeEnum CXFA_Stroke::GetCapType() {
+ return JSObject()->GetEnum(XFA_Attribute::Cap);
+}
+
+XFA_AttributeEnum CXFA_Stroke::GetStrokeType() {
+ return JSObject()->GetEnum(XFA_Attribute::Stroke);
+}
+
+float CXFA_Stroke::GetThickness() const {
+ return GetMSThickness().ToUnit(XFA_Unit::Pt);
+}
+
+CXFA_Measurement CXFA_Stroke::GetMSThickness() const {
+ return JSObject()->GetMeasure(XFA_Attribute::Thickness);
+}
+
+void CXFA_Stroke::SetMSThickness(CXFA_Measurement msThinkness) {
+ JSObject()->SetMeasure(XFA_Attribute::Thickness, msThinkness, false);
+}
+
+FX_ARGB CXFA_Stroke::GetColor() {
+ CXFA_Color* pNode = GetChild<CXFA_Color>(0, XFA_Element::Color, false);
+ if (!pNode)
+ return 0xFF000000;
+
+ return CXFA_DataData::ToColor(
+ pNode->JSObject()->GetCData(XFA_Attribute::Value).AsStringView());
+}
+
+void CXFA_Stroke::SetColor(FX_ARGB argb) {
+ CXFA_Color* pNode =
+ JSObject()->GetProperty<CXFA_Color>(0, XFA_Element::Color, true);
+ int a;
+ int r;
+ int g;
+ int b;
+ std::tie(a, r, g, b) = ArgbDecode(argb);
+ pNode->JSObject()->SetCData(XFA_Attribute::Value,
+ WideString::Format(L"%d,%d,%d", r, g, b), false,
+ false);
+}
+
+XFA_AttributeEnum CXFA_Stroke::GetJoinType() {
+ return JSObject()->GetEnum(XFA_Attribute::Join);
+}
+
+bool CXFA_Stroke::IsInverted() {
+ return JSObject()->GetBoolean(XFA_Attribute::Inverted);
+}
+
+float CXFA_Stroke::GetRadius() const {
+ return JSObject()
+ ->TryMeasure(XFA_Attribute::Radius, true)
+ .value_or(CXFA_Measurement(0, XFA_Unit::In))
+ .ToUnit(XFA_Unit::Pt);
+}
+
+bool CXFA_Stroke::SameStyles(CXFA_Stroke* stroke, uint32_t dwFlags) {
+ if (this == stroke)
+ return true;
+ if (fabs(GetThickness() - stroke->GetThickness()) >= 0.01f)
+ return false;
+ if ((dwFlags & XFA_STROKE_SAMESTYLE_NoPresence) == 0 &&
+ IsVisible() != stroke->IsVisible()) {
+ return false;
+ }
+ if (GetStrokeType() != stroke->GetStrokeType())
+ return false;
+ if (GetColor() != stroke->GetColor())
+ return false;
+ if ((dwFlags & XFA_STROKE_SAMESTYLE_Corner) != 0 &&
+ fabs(GetRadius() - stroke->GetRadius()) >= 0.01f) {
+ return false;
+ }
+ return true;
+}
diff --git a/xfa/fxfa/parser/cxfa_stroke.h b/xfa/fxfa/parser/cxfa_stroke.h
new file mode 100644
index 0000000000..42b7ec0c20
--- /dev/null
+++ b/xfa/fxfa/parser/cxfa_stroke.h
@@ -0,0 +1,57 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef XFA_FXFA_PARSER_CXFA_STROKE_H_
+#define XFA_FXFA_PARSER_CXFA_STROKE_H_
+
+#include <memory>
+
+#include "core/fxge/fx_dib.h"
+#include "xfa/fxfa/fxfa_basic.h"
+#include "xfa/fxfa/parser/cxfa_node.h"
+
+enum StrokeSameStyle {
+ XFA_STROKE_SAMESTYLE_NoPresence = 1,
+ XFA_STROKE_SAMESTYLE_Corner = 2
+};
+
+class CXFA_Node;
+
+class CXFA_Stroke : public CXFA_Node {
+ public:
+ ~CXFA_Stroke() override;
+
+ bool IsCorner() const { return GetElementType() == XFA_Element::Corner; }
+ bool IsVisible();
+ bool IsInverted();
+
+ XFA_AttributeEnum GetCapType();
+ XFA_AttributeEnum GetStrokeType();
+ XFA_AttributeEnum GetJoinType();
+ float GetRadius() const;
+ float GetThickness() const;
+
+ CXFA_Measurement GetMSThickness() const;
+ void SetMSThickness(CXFA_Measurement msThinkness);
+
+ FX_ARGB GetColor();
+ void SetColor(FX_ARGB argb);
+
+ bool SameStyles(CXFA_Stroke* stroke, uint32_t dwFlags);
+
+ protected:
+ CXFA_Stroke(CXFA_Document* pDoc,
+ XFA_PacketType ePacket,
+ uint32_t validPackets,
+ XFA_ObjectType oType,
+ XFA_Element eType,
+ const PropertyData* properties,
+ const AttributeData* attributes,
+ const WideStringView& elementName,
+ std::unique_ptr<CJX_Object> js_node);
+};
+
+#endif // XFA_FXFA_PARSER_CXFA_STROKE_H_
diff --git a/xfa/fxfa/parser/cxfa_strokedata.cpp b/xfa/fxfa/parser/cxfa_strokedata.cpp
deleted file mode 100644
index 7886730d39..0000000000
--- a/xfa/fxfa/parser/cxfa_strokedata.cpp
+++ /dev/null
@@ -1,117 +0,0 @@
-// Copyright 2016 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#include "xfa/fxfa/parser/cxfa_strokedata.h"
-
-#include "xfa/fxfa/parser/cxfa_color.h"
-#include "xfa/fxfa/parser/cxfa_measurement.h"
-#include "xfa/fxfa/parser/cxfa_node.h"
-#include "xfa/fxfa/parser/xfa_utils.h"
-
-bool CXFA_StrokeData::IsVisible() const {
- if (!m_pNode)
- return false;
-
- XFA_AttributeEnum presence = m_pNode->JSObject()
- ->TryEnum(XFA_Attribute::Presence, true)
- .value_or(XFA_AttributeEnum::Visible);
- return presence == XFA_AttributeEnum::Visible;
-}
-
-XFA_AttributeEnum CXFA_StrokeData::GetCapType() const {
- if (!m_pNode)
- return XFA_AttributeEnum::Square;
- return m_pNode->JSObject()->GetEnum(XFA_Attribute::Cap);
-}
-
-XFA_AttributeEnum CXFA_StrokeData::GetStrokeType() const {
- return m_pNode ? m_pNode->JSObject()->GetEnum(XFA_Attribute::Stroke)
- : XFA_AttributeEnum::Solid;
-}
-
-float CXFA_StrokeData::GetThickness() const {
- return GetMSThickness().ToUnit(XFA_Unit::Pt);
-}
-
-CXFA_Measurement CXFA_StrokeData::GetMSThickness() const {
- return m_pNode ? m_pNode->JSObject()->GetMeasure(XFA_Attribute::Thickness)
- : CXFA_Measurement(0.5, XFA_Unit::Pt);
-}
-
-void CXFA_StrokeData::SetMSThickness(CXFA_Measurement msThinkness) {
- if (!m_pNode)
- return;
-
- m_pNode->JSObject()->SetMeasure(XFA_Attribute::Thickness, msThinkness, false);
-}
-
-FX_ARGB CXFA_StrokeData::GetColor() const {
- if (!m_pNode)
- return 0xFF000000;
-
- CXFA_Color* pNode =
- m_pNode->GetChild<CXFA_Color>(0, XFA_Element::Color, false);
- if (!pNode)
- return 0xFF000000;
-
- return CXFA_DataData::ToColor(
- pNode->JSObject()->GetCData(XFA_Attribute::Value).AsStringView());
-}
-
-void CXFA_StrokeData::SetColor(FX_ARGB argb) {
- if (!m_pNode)
- return;
-
- CXFA_Color* pNode =
- m_pNode->JSObject()->GetProperty<CXFA_Color>(0, XFA_Element::Color, true);
- int a;
- int r;
- int g;
- int b;
- std::tie(a, r, g, b) = ArgbDecode(argb);
- pNode->JSObject()->SetCData(XFA_Attribute::Value,
- WideString::Format(L"%d,%d,%d", r, g, b), false,
- false);
-}
-
-XFA_AttributeEnum CXFA_StrokeData::GetJoinType() const {
- return m_pNode ? m_pNode->JSObject()->GetEnum(XFA_Attribute::Join)
- : XFA_AttributeEnum::Square;
-}
-
-bool CXFA_StrokeData::IsInverted() const {
- return m_pNode ? m_pNode->JSObject()->GetBoolean(XFA_Attribute::Inverted)
- : false;
-}
-
-float CXFA_StrokeData::GetRadius() const {
- return m_pNode ? m_pNode->JSObject()
- ->TryMeasure(XFA_Attribute::Radius, true)
- .value_or(CXFA_Measurement(0, XFA_Unit::In))
- .ToUnit(XFA_Unit::Pt)
- : 0;
-}
-
-bool CXFA_StrokeData::SameStyles(CXFA_StrokeData stroke,
- uint32_t dwFlags) const {
- if (m_pNode == stroke.GetNode())
- return true;
- if (fabs(GetThickness() - stroke.GetThickness()) >= 0.01f)
- return false;
- if ((dwFlags & XFA_STROKE_SAMESTYLE_NoPresence) == 0 &&
- IsVisible() != stroke.IsVisible()) {
- return false;
- }
- if (GetStrokeType() != stroke.GetStrokeType())
- return false;
- if (GetColor() != stroke.GetColor())
- return false;
- if ((dwFlags & XFA_STROKE_SAMESTYLE_Corner) != 0 &&
- fabs(GetRadius() - stroke.GetRadius()) >= 0.01f) {
- return false;
- }
- return true;
-}
diff --git a/xfa/fxfa/parser/cxfa_strokedata.h b/xfa/fxfa/parser/cxfa_strokedata.h
deleted file mode 100644
index 5ac7820239..0000000000
--- a/xfa/fxfa/parser/cxfa_strokedata.h
+++ /dev/null
@@ -1,46 +0,0 @@
-// Copyright 2016 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef XFA_FXFA_PARSER_CXFA_STROKEDATA_H_
-#define XFA_FXFA_PARSER_CXFA_STROKEDATA_H_
-
-#include "core/fxcrt/fx_system.h"
-#include "core/fxge/fx_dib.h"
-#include "xfa/fxfa/fxfa_basic.h"
-#include "xfa/fxfa/parser/cxfa_datadata.h"
-
-enum StrokeSameStyle {
- XFA_STROKE_SAMESTYLE_NoPresence = 1,
- XFA_STROKE_SAMESTYLE_Corner = 2
-};
-
-class CXFA_Node;
-
-class CXFA_StrokeData : public CXFA_DataData {
- public:
- CXFA_StrokeData() : CXFA_StrokeData(nullptr) {}
- explicit CXFA_StrokeData(CXFA_Node* pNode) : CXFA_DataData(pNode) {}
-
- bool IsCorner() const { return GetElementType() == XFA_Element::Corner; }
- bool IsVisible() const;
- bool IsInverted() const;
-
- XFA_AttributeEnum GetCapType() const;
- XFA_AttributeEnum GetStrokeType() const;
- XFA_AttributeEnum GetJoinType() const;
- float GetRadius() const;
- float GetThickness() const;
-
- CXFA_Measurement GetMSThickness() const;
- void SetMSThickness(CXFA_Measurement msThinkness);
-
- FX_ARGB GetColor() const;
- void SetColor(FX_ARGB argb);
-
- bool SameStyles(CXFA_StrokeData stroke, uint32_t dwFlags) const;
-};
-
-#endif // XFA_FXFA_PARSER_CXFA_STROKEDATA_H_
diff --git a/xfa/fxfa/parser/cxfa_widgetdata.cpp b/xfa/fxfa/parser/cxfa_widgetdata.cpp
index 1351c77be2..a7f157d0a2 100644
--- a/xfa/fxfa/parser/cxfa_widgetdata.cpp
+++ b/xfa/fxfa/parser/cxfa_widgetdata.cpp
@@ -27,6 +27,7 @@
#include "xfa/fxfa/parser/cxfa_node.h"
#include "xfa/fxfa/parser/cxfa_para.h"
#include "xfa/fxfa/parser/cxfa_picture.h"
+#include "xfa/fxfa/parser/cxfa_stroke.h"
#include "xfa/fxfa/parser/cxfa_ui.h"
#include "xfa/fxfa/parser/cxfa_validate.h"
#include "xfa/fxfa/parser/cxfa_value.h"
@@ -34,16 +35,17 @@
namespace {
-float GetEdgeThickness(const std::vector<CXFA_StrokeData>& strokes,
+float GetEdgeThickness(const std::vector<CXFA_Stroke*>& strokes,
bool b3DStyle,
int32_t nIndex) {
float fThickness = 0;
- if (strokes[nIndex * 2 + 1].IsVisible()) {
+ CXFA_Stroke* stroke = strokes[nIndex * 2 + 1];
+ if (stroke->IsVisible()) {
if (nIndex == 0)
fThickness += 2.5f;
- fThickness += strokes[nIndex * 2 + 1].GetThickness() * (b3DStyle ? 4 : 2);
+ fThickness += stroke->GetThickness() * (b3DStyle ? 4 : 2);
}
return fThickness;
}
@@ -395,7 +397,7 @@ CFX_RectF CXFA_WidgetData::GetUIMargin() {
XFA_AttributeEnum iType = XFA_AttributeEnum::Unknown;
std::tie(iType, bVisible, fThickness) = border->Get3DStyle();
if (!left || !top || !right || !bottom) {
- std::vector<CXFA_StrokeData> strokes = border->GetStrokes();
+ std::vector<CXFA_Stroke*> strokes = border->GetStrokes();
if (!top)
top = GetEdgeThickness(strokes, bVisible, 0);
if (!right)