summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--BUILD.gn6
-rw-r--r--fxjs/xfa/cjx_object.cpp9
-rw-r--r--xfa/fwl/theme/cfwl_edittp.cpp9
-rw-r--r--xfa/fxfa/cxfa_ffline.cpp15
-rw-r--r--xfa/fxfa/cxfa_ffpushbutton.cpp3
-rw-r--r--xfa/fxfa/cxfa_ffwidget.cpp164
-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
21 files changed, 353 insertions, 372 deletions
diff --git a/BUILD.gn b/BUILD.gn
index f85934d39d..f9ab1077ac 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -2193,7 +2193,6 @@ if (pdf_enable_xfa) {
"xfa/fxfa/parser/cxfa_copies.h",
"xfa/fxfa/parser/cxfa_corner.cpp",
"xfa/fxfa/parser/cxfa_corner.h",
- "xfa/fxfa/parser/cxfa_cornerdata.h",
"xfa/fxfa/parser/cxfa_creator.cpp",
"xfa/fxfa/parser/cxfa_creator.h",
"xfa/fxfa/parser/cxfa_currencysymbol.cpp",
@@ -2272,7 +2271,6 @@ if (pdf_enable_xfa) {
"xfa/fxfa/parser/cxfa_dynamicrender.h",
"xfa/fxfa/parser/cxfa_edge.cpp",
"xfa/fxfa/parser/cxfa_edge.h",
- "xfa/fxfa/parser/cxfa_edgedata.h",
"xfa/fxfa/parser/cxfa_effectiveinputpolicy.cpp",
"xfa/fxfa/parser/cxfa_effectiveinputpolicy.h",
"xfa/fxfa/parser/cxfa_effectiveoutputpolicy.cpp",
@@ -2636,8 +2634,8 @@ if (pdf_enable_xfa) {
"xfa/fxfa/parser/cxfa_startpage.h",
"xfa/fxfa/parser/cxfa_stipple.cpp",
"xfa/fxfa/parser/cxfa_stipple.h",
- "xfa/fxfa/parser/cxfa_strokedata.cpp",
- "xfa/fxfa/parser/cxfa_strokedata.h",
+ "xfa/fxfa/parser/cxfa_stroke.cpp",
+ "xfa/fxfa/parser/cxfa_stroke.h",
"xfa/fxfa/parser/cxfa_subform.cpp",
"xfa/fxfa/parser/cxfa_subform.h",
"xfa/fxfa/parser/cxfa_subformset.cpp",
diff --git a/fxjs/xfa/cjx_object.cpp b/fxjs/xfa/cjx_object.cpp
index aa9a16956e..a6ae86ef9f 100644
--- a/fxjs/xfa/cjx_object.cpp
+++ b/fxjs/xfa/cjx_object.cpp
@@ -23,6 +23,7 @@
#include "xfa/fxfa/cxfa_ffwidget.h"
#include "xfa/fxfa/parser/cxfa_border.h"
#include "xfa/fxfa/parser/cxfa_document.h"
+#include "xfa/fxfa/parser/cxfa_edge.h"
#include "xfa/fxfa/parser/cxfa_filldata.h"
#include "xfa/fxfa/parser/cxfa_layoutprocessor.h"
#include "xfa/fxfa/parser/cxfa_measurement.h"
@@ -1378,12 +1379,12 @@ void CJX_Object::Script_Som_BorderColor(CFXJSE_Value* pValue,
std::tie(r, g, b) = StrToRGB(pValue->ToWideString());
FX_ARGB rgb = ArgbEncode(100, r, g, b);
for (int32_t i = 0; i < iSize; ++i)
- border->GetEdgeData(i).SetColor(rgb);
+ border->GetEdge(i)->SetColor(rgb);
return;
}
- FX_ARGB color = border->GetEdgeData(0).GetColor();
+ FX_ARGB color = border->GetEdge(0)->GetColor();
int32_t a;
int32_t r;
int32_t g;
@@ -1401,14 +1402,14 @@ void CJX_Object::Script_Som_BorderWidth(CFXJSE_Value* pValue,
CXFA_Border* border = widget_data_->GetBorder(true);
if (bSetting) {
- CXFA_Measurement thickness = border->GetEdgeData(0).GetMSThickness();
+ CXFA_Measurement thickness = border->GetEdge(0)->GetMSThickness();
pValue->SetString(thickness.ToString().UTF8Encode().AsStringView());
return;
}
WideString wsThickness = pValue->ToWideString();
for (int32_t i = 0; i < border->CountEdges(); ++i) {
- border->GetEdgeData(i).SetMSThickness(
+ border->GetEdge(i)->SetMSThickness(
CXFA_Measurement(wsThickness.AsStringView()));
}
}
diff --git a/xfa/fwl/theme/cfwl_edittp.cpp b/xfa/fwl/theme/cfwl_edittp.cpp
index ad9bf02038..59a2ff07d9 100644
--- a/xfa/fwl/theme/cfwl_edittp.cpp
+++ b/xfa/fwl/theme/cfwl_edittp.cpp
@@ -12,6 +12,7 @@
#include "xfa/fxfa/cxfa_ffwidget.h"
#include "xfa/fxfa/cxfa_fwltheme.h"
#include "xfa/fxfa/parser/cxfa_border.h"
+#include "xfa/fxfa/parser/cxfa_edge.h"
#include "xfa/fxgraphics/cxfa_gecolor.h"
#include "xfa/fxgraphics/cxfa_gepath.h"
@@ -26,10 +27,10 @@ void CFWL_EditTP::DrawBackground(CFWL_ThemeBackground* pParams) {
FX_ARGB cr = 0xFF000000;
float fWidth = 1.0f;
if (borderUI) {
- CXFA_EdgeData edgeData = borderUI->GetEdgeData(0);
- if (edgeData.HasValidNode()) {
- cr = edgeData.GetColor();
- fWidth = edgeData.GetThickness();
+ CXFA_Edge* edge = borderUI->GetEdge(0);
+ if (edge) {
+ cr = edge->GetColor();
+ fWidth = edge->GetThickness();
}
}
pParams->m_pGraphics->SetStrokeColor(CXFA_GEColor(cr));
diff --git a/xfa/fxfa/cxfa_ffline.cpp b/xfa/fxfa/cxfa_ffline.cpp
index bbe928f91a..c1bcc26b27 100644
--- a/xfa/fxfa/cxfa_ffline.cpp
+++ b/xfa/fxfa/cxfa_ffline.cpp
@@ -6,6 +6,7 @@
#include "xfa/fxfa/cxfa_ffline.h"
+#include "xfa/fxfa/parser/cxfa_edge.h"
#include "xfa/fxfa/parser/cxfa_value.h"
#include "xfa/fxgraphics/cxfa_gecolor.h"
#include "xfa/fxgraphics/cxfa_gepath.h"
@@ -94,15 +95,15 @@ void CXFA_FFLine::RenderWidget(CXFA_Graphics* pGS,
float fLineWidth = 1.0f;
XFA_AttributeEnum iStrokeType = XFA_AttributeEnum::Unknown;
XFA_AttributeEnum iCap = XFA_AttributeEnum::Unknown;
- CXFA_EdgeData edgeData = lineData.GetEdgeData();
- if (edgeData.HasValidNode()) {
- if (!edgeData.IsVisible())
+ CXFA_Edge* edge = lineData.GetEdge();
+ if (edge) {
+ if (!edge->IsVisible())
return;
- lineColor = edgeData.GetColor();
- iStrokeType = edgeData.GetStrokeType();
- fLineWidth = edgeData.GetThickness();
- iCap = edgeData.GetCapType();
+ lineColor = edge->GetColor();
+ iStrokeType = edge->GetStrokeType();
+ fLineWidth = edge->GetThickness();
+ iCap = edge->GetCapType();
}
CFX_Matrix mtRotate = GetRotateMatrix();
diff --git a/xfa/fxfa/cxfa_ffpushbutton.cpp b/xfa/fxfa/cxfa_ffpushbutton.cpp
index 9db0c25bbc..0e8548411c 100644
--- a/xfa/fxfa/cxfa_ffpushbutton.cpp
+++ b/xfa/fxfa/cxfa_ffpushbutton.cpp
@@ -20,6 +20,7 @@
#include "xfa/fxfa/cxfa_textprovider.h"
#include "xfa/fxfa/parser/cxfa_border.h"
#include "xfa/fxfa/parser/cxfa_caption.h"
+#include "xfa/fxfa/parser/cxfa_edge.h"
#include "xfa/fxgraphics/cxfa_gecolor.h"
#include "xfa/fxgraphics/cxfa_gepath.h"
@@ -119,7 +120,7 @@ bool CXFA_FFPushButton::PerformLayout() {
float CXFA_FFPushButton::GetLineWidth() {
CXFA_Border* border = m_pDataAcc->GetBorder(false);
if (border && border->GetPresence() == XFA_AttributeEnum::Visible)
- return border->GetEdgeData(0).GetThickness();
+ return border->GetEdge(0)->GetThickness();
return 0;
}
diff --git a/xfa/fxfa/cxfa_ffwidget.cpp b/xfa/fxfa/cxfa_ffwidget.cpp
index 4b5806f505..f82f6aba66 100644
--- a/xfa/fxfa/cxfa_ffwidget.cpp
+++ b/xfa/fxfa/cxfa_ffwidget.cpp
@@ -32,7 +32,8 @@
#include "xfa/fxfa/cxfa_widgetacc.h"
#include "xfa/fxfa/parser/cxfa_border.h"
#include "xfa/fxfa/parser/cxfa_box.h"
-#include "xfa/fxfa/parser/cxfa_cornerdata.h"
+#include "xfa/fxfa/parser/cxfa_corner.h"
+#include "xfa/fxfa/parser/cxfa_edge.h"
#include "xfa/fxfa/parser/cxfa_margin.h"
#include "xfa/fxfa/parser/cxfa_node.h"
#include "xfa/fxgraphics/cxfa_gecolor.h"
@@ -70,40 +71,42 @@ void XFA_BOX_GetPath_Arc(CXFA_Box* box,
-sweepAngle.value_or(360) * FX_PI / 180.0f);
}
-void XFA_BOX_GetPath(const std::vector<CXFA_StrokeData>& strokes,
+void XFA_BOX_GetPath(const std::vector<CXFA_Stroke*>& strokes,
CFX_RectF rtWidget,
CXFA_GEPath& path,
int32_t nIndex,
bool bStart,
bool bCorner) {
ASSERT(nIndex >= 0 && nIndex < 8);
+
int32_t n = (nIndex & 1) ? nIndex - 1 : nIndex;
- CXFA_CornerData cornerData1(strokes[n].GetNode());
- CXFA_CornerData cornerData2(strokes[(n + 2) % 8].GetNode());
- float fRadius1 = bCorner ? cornerData1.GetRadius() : 0.0f;
- float fRadius2 = bCorner ? cornerData2.GetRadius() : 0.0f;
- bool bInverted = cornerData1.IsInverted();
+ auto* corner1 = static_cast<CXFA_Corner*>(strokes[n]);
+ auto* corner2 = static_cast<CXFA_Corner*>(strokes[(n + 2) % 8]);
+ float fRadius1 = bCorner ? corner1->GetRadius() : 0.0f;
+ float fRadius2 = bCorner ? corner2->GetRadius() : 0.0f;
+ bool bInverted = corner1->IsInverted();
float offsetY = 0.0f;
float offsetX = 0.0f;
- bool bRound = cornerData1.GetJoinType() == XFA_AttributeEnum::Round;
+ bool bRound = corner1->GetJoinType() == XFA_AttributeEnum::Round;
float halfAfter = 0.0f;
float halfBefore = 0.0f;
- CXFA_StrokeData strokeData = strokes[nIndex];
- if (strokeData.IsCorner()) {
- CXFA_StrokeData strokeBeforeData = strokes[(nIndex + 1 * 8 - 1) % 8];
- CXFA_StrokeData strokeAfterData = strokes[nIndex + 1];
- if (strokeData.IsInverted()) {
- if (!strokeData.SameStyles(strokeBeforeData, 0))
- halfBefore = strokeBeforeData.GetThickness() / 2;
- if (!strokeData.SameStyles(strokeAfterData, 0))
- halfAfter = strokeAfterData.GetThickness() / 2;
+
+ CXFA_Stroke* stroke = strokes[nIndex];
+ if (stroke->IsCorner()) {
+ CXFA_Stroke* strokeBefore = strokes[(nIndex + 1 * 8 - 1) % 8];
+ CXFA_Stroke* strokeAfter = strokes[nIndex + 1];
+ if (stroke->IsInverted()) {
+ if (!stroke->SameStyles(strokeBefore, 0))
+ halfBefore = strokeBefore->GetThickness() / 2;
+ if (!stroke->SameStyles(strokeAfter, 0))
+ halfAfter = strokeAfter->GetThickness() / 2;
}
} else {
- CXFA_StrokeData strokeBeforeData = strokes[(nIndex + 8 - 2) % 8];
- CXFA_StrokeData strokeAfterData = strokes[(nIndex + 2) % 8];
+ CXFA_Stroke* strokeBefore = strokes[(nIndex + 8 - 2) % 8];
+ CXFA_Stroke* strokeAfter = strokes[(nIndex + 2) % 8];
if (!bRound && !bInverted) {
- halfBefore = strokeBeforeData.GetThickness() / 2;
- halfAfter = strokeAfterData.GetThickness() / 2;
+ halfBefore = strokeBefore->GetThickness() / 2;
+ halfAfter = strokeAfter->GetThickness() / 2;
}
}
@@ -239,12 +242,12 @@ void XFA_BOX_GetPath(const std::vector<CXFA_StrokeData>& strokes,
}
void XFA_BOX_GetFillPath(CXFA_Box* box,
- const std::vector<CXFA_StrokeData>& strokes,
+ const std::vector<CXFA_Stroke*>& strokes,
CFX_RectF rtWidget,
CXFA_GEPath& fillPath,
uint16_t dwFlags) {
if (box->IsArc() || (dwFlags & XFA_DRAWBOX_ForceRound) != 0) {
- float fThickness = std::fmax(0.0, box->GetEdgeData(0).GetThickness());
+ float fThickness = std::fmax(0.0, box->GetEdge(0)->GetThickness());
float fHalf = fThickness / 2;
XFA_AttributeEnum iHand = box->GetHand();
if (iHand == XFA_AttributeEnum::Left)
@@ -257,35 +260,32 @@ void XFA_BOX_GetFillPath(CXFA_Box* box,
}
bool bSameStyles = true;
- CXFA_StrokeData strokeData1 = strokes[0];
+ CXFA_Stroke* stroke1 = strokes[0];
for (int32_t i = 1; i < 8; i++) {
- CXFA_StrokeData strokeData2 = strokes[i];
- if (!strokeData1.SameStyles(strokeData2, 0)) {
+ CXFA_Stroke* stroke2 = strokes[i];
+ if (!stroke1->SameStyles(stroke2, 0)) {
bSameStyles = false;
break;
}
- strokeData1 = strokeData2;
+ stroke1 = stroke2;
}
if (bSameStyles) {
- strokeData1 = strokes[0];
+ stroke1 = strokes[0];
for (int32_t i = 2; i < 8; i += 2) {
- CXFA_StrokeData strokeData2 = strokes[i];
- if (!strokeData1.SameStyles(
- strokeData2,
- XFA_STROKE_SAMESTYLE_NoPresence | XFA_STROKE_SAMESTYLE_Corner)) {
+ CXFA_Stroke* stroke2 = strokes[i];
+ if (!stroke1->SameStyles(stroke2, XFA_STROKE_SAMESTYLE_NoPresence |
+ XFA_STROKE_SAMESTYLE_Corner)) {
bSameStyles = false;
break;
}
- strokeData1 = strokeData2;
+ stroke1 = stroke2;
}
if (bSameStyles) {
- strokeData1 = strokes[0];
- if (strokeData1.IsInverted()) {
+ stroke1 = strokes[0];
+ if (stroke1->IsInverted())
bSameStyles = false;
- }
- if (strokeData1.GetJoinType() != XFA_AttributeEnum::Square) {
+ if (stroke1->GetJoinType() != XFA_AttributeEnum::Square)
bSameStyles = false;
- }
}
}
if (bSameStyles) {
@@ -302,12 +302,12 @@ void XFA_BOX_GetFillPath(CXFA_Box* box,
float nx = 1.0f;
float ny = 1.0f;
CFX_PointF cp1, cp2;
- CXFA_CornerData cornerData1(strokes[i].GetNode());
- CXFA_CornerData cornerData2(strokes[(i + 2) % 8].GetNode());
- float fRadius1 = cornerData1.GetRadius();
- float fRadius2 = cornerData2.GetRadius();
- bool bInverted = cornerData1.IsInverted();
- bool bRound = cornerData1.GetJoinType() == XFA_AttributeEnum::Round;
+ auto* corner1 = static_cast<CXFA_Corner*>(strokes[i]);
+ auto* corner2 = static_cast<CXFA_Corner*>(strokes[(i + 2) % 8]);
+ float fRadius1 = corner1->GetRadius();
+ float fRadius2 = corner2->GetRadius();
+ bool bInverted = corner1->IsInverted();
+ bool bRound = corner1->GetJoinType() == XFA_AttributeEnum::Round;
if (bRound) {
sy = FX_PI / 2;
}
@@ -480,7 +480,7 @@ void XFA_BOX_Fill_Linear(CXFA_Box* box,
}
void XFA_BOX_Fill(CXFA_Box* box,
- const std::vector<CXFA_StrokeData>& strokes,
+ const std::vector<CXFA_Stroke*>& strokes,
CXFA_Graphics* pGS,
const CFX_RectF& rtWidget,
const CFX_Matrix& matrix,
@@ -526,27 +526,27 @@ void XFA_BOX_Fill(CXFA_Box* box,
pGS->RestoreGraphState();
}
-void XFA_BOX_StrokePath(const CXFA_StrokeData& strokeData,
+void XFA_BOX_StrokePath(CXFA_Stroke* stroke,
CXFA_GEPath* pPath,
CXFA_Graphics* pGS,
const CFX_Matrix& matrix) {
- if (!strokeData.HasValidNode() || !strokeData.IsVisible())
+ if (!stroke || !stroke->IsVisible())
return;
- float fThickness = strokeData.GetThickness();
+ float fThickness = stroke->GetThickness();
if (fThickness < 0.001f)
return;
pGS->SaveGraphState();
- if (strokeData.IsCorner() && fThickness > 2 * strokeData.GetRadius())
- fThickness = 2 * strokeData.GetRadius();
+ if (stroke->IsCorner() && fThickness > 2 * stroke->GetRadius())
+ fThickness = 2 * stroke->GetRadius();
pGS->SetLineWidth(fThickness);
pGS->EnableActOnDash();
pGS->SetLineCap(CFX_GraphStateData::LineCapButt);
- XFA_StrokeTypeSetLineDash(pGS, strokeData.GetStrokeType(),
+ XFA_StrokeTypeSetLineDash(pGS, stroke->GetStrokeType(),
XFA_AttributeEnum::Butt);
- pGS->SetStrokeColor(CXFA_GEColor(strokeData.GetColor()));
+ pGS->SetStrokeColor(CXFA_GEColor(stroke->GetColor()));
pGS->StrokePath(pPath, &matrix);
pGS->RestoreGraphState();
}
@@ -556,8 +556,8 @@ void XFA_BOX_StrokeArc(CXFA_Box* box,
CFX_RectF rtWidget,
const CFX_Matrix& matrix,
uint32_t dwFlags) {
- CXFA_EdgeData edgeData = box->GetEdgeData(0);
- if (!edgeData.HasValidNode() || !edgeData.IsVisible())
+ CXFA_Edge* edge = box->GetEdge(0);
+ if (!edge || !edge->IsVisible())
return;
bool bVisible;
@@ -569,7 +569,7 @@ void XFA_BOX_StrokeArc(CXFA_Box* box,
dwFlags |= XFA_DRAWBOX_Lowered3D;
}
}
- float fHalf = edgeData.GetThickness() / 2;
+ float fHalf = edge->GetThickness() / 2;
if (fHalf < 0) {
fHalf = 0;
}
@@ -587,7 +587,7 @@ void XFA_BOX_StrokeArc(CXFA_Box* box,
CXFA_GEPath arcPath;
XFA_BOX_GetPath_Arc(box, rtWidget, arcPath, dwFlags);
- XFA_BOX_StrokePath(edgeData, &arcPath, pGS, matrix);
+ XFA_BOX_StrokePath(edge, &arcPath, pGS, matrix);
return;
}
pGS->SaveGraphState();
@@ -725,7 +725,7 @@ void XFA_BOX_Stroke_3DRect_Embossed(CXFA_Graphics* pGS,
}
void XFA_BOX_Stroke_Rect(CXFA_Box* box,
- const std::vector<CXFA_StrokeData>& strokes,
+ const std::vector<CXFA_Stroke*>& strokes,
CXFA_Graphics* pGS,
CFX_RectF rtWidget,
const CFX_Matrix& matrix) {
@@ -758,53 +758,53 @@ void XFA_BOX_Stroke_Rect(CXFA_Box* box,
}
bool bClose = false;
bool bSameStyles = true;
- CXFA_StrokeData strokeData1 = strokes[0];
+ CXFA_Stroke* stroke1 = strokes[0];
for (int32_t i = 1; i < 8; i++) {
- CXFA_StrokeData strokeData2 = strokes[i];
- if (!strokeData1.SameStyles(strokeData2, 0)) {
+ CXFA_Stroke* stroke2 = strokes[i];
+ if (!stroke1->SameStyles(stroke2, 0)) {
bSameStyles = false;
break;
}
- strokeData1 = strokeData2;
+ stroke1 = stroke2;
}
if (bSameStyles) {
- strokeData1 = strokes[0];
+ stroke1 = strokes[0];
bClose = true;
for (int32_t i = 2; i < 8; i += 2) {
- CXFA_StrokeData strokeData2 = strokes[i];
- if (!strokeData1.SameStyles(
- strokeData2,
- XFA_STROKE_SAMESTYLE_NoPresence | XFA_STROKE_SAMESTYLE_Corner)) {
+ CXFA_Stroke* stroke2 = strokes[i];
+ if (!stroke1->SameStyles(stroke2, XFA_STROKE_SAMESTYLE_NoPresence |
+ XFA_STROKE_SAMESTYLE_Corner)) {
bSameStyles = false;
break;
}
- strokeData1 = strokeData2;
+ stroke1 = stroke2;
}
if (bSameStyles) {
- strokeData1 = strokes[0];
- if (strokeData1.IsInverted())
+ stroke1 = strokes[0];
+ if (stroke1->IsInverted())
bSameStyles = false;
- if (strokeData1.GetJoinType() != XFA_AttributeEnum::Square)
+ if (stroke1->GetJoinType() != XFA_AttributeEnum::Square)
bSameStyles = false;
}
}
bool bStart = true;
CXFA_GEPath path;
for (int32_t i = 0; i < 8; i++) {
- CXFA_StrokeData strokeData = strokes[i];
- if ((i % 1) == 0 && strokeData.GetRadius() < 0) {
+ CXFA_Stroke* stroke = strokes[i];
+ if ((i % 1) == 0 && stroke->GetRadius() < 0) {
bool bEmpty = path.IsEmpty();
if (!bEmpty) {
- XFA_BOX_StrokePath(strokeData, &path, pGS, matrix);
+ XFA_BOX_StrokePath(stroke, &path, pGS, matrix);
path.Clear();
}
bStart = true;
continue;
}
XFA_BOX_GetPath(strokes, rtWidget, path, i, bStart, !bSameStyles);
- bStart = !strokeData.SameStyles(strokes[(i + 1) % 8], 0);
+
+ bStart = !stroke->SameStyles(strokes[(i + 1) % 8], 0);
if (bStart) {
- XFA_BOX_StrokePath(strokeData, &path, pGS, matrix);
+ XFA_BOX_StrokePath(stroke, &path, pGS, matrix);
path.Clear();
}
}
@@ -818,7 +818,7 @@ void XFA_BOX_Stroke_Rect(CXFA_Box* box,
}
void XFA_BOX_Stroke(CXFA_Box* box,
- const std::vector<CXFA_StrokeData>& strokes,
+ const std::vector<CXFA_Stroke*>& strokes,
CXFA_Graphics* pGS,
CFX_RectF rtWidget,
const CFX_Matrix& matrix,
@@ -827,19 +827,19 @@ void XFA_BOX_Stroke(CXFA_Box* box,
XFA_BOX_StrokeArc(box, pGS, rtWidget, matrix, dwFlags);
return;
}
+
bool bVisible = false;
for (int32_t j = 0; j < 4; j++) {
- if (strokes[j * 2 + 1].IsVisible()) {
+ if (strokes[j * 2 + 1]->IsVisible()) {
bVisible = true;
break;
}
}
- if (!bVisible) {
+ if (!bVisible)
return;
- }
+
for (int32_t i = 1; i < 8; i += 2) {
- float fThickness =
- std::fmax(0.0, CXFA_EdgeData(strokes[i].GetNode()).GetThickness());
+ float fThickness = std::fmax(0.0, strokes[i]->GetThickness());
float fHalf = fThickness / 2;
XFA_AttributeEnum iHand = box->GetHand();
switch (i) {
@@ -893,7 +893,7 @@ void XFA_DrawBox(CXFA_Box* box,
eType != XFA_Element::Rectangle) {
return;
}
- std::vector<CXFA_StrokeData> strokes;
+ std::vector<CXFA_Stroke*> strokes;
if (!(dwFlags & XFA_DRAWBOX_ForceRound) && eType != XFA_Element::Arc)
strokes = box->GetStrokes();
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)