summaryrefslogtreecommitdiff
path: root/xfa/fxfa
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2018-01-03 12:01:24 -0500
committerChromium commit bot <commit-bot@chromium.org>2018-01-03 18:20:01 +0000
commit39628b04bc86461426f2dcf5a568f5e9e70ad997 (patch)
treea0cf6c494a74b83e93a5cc526ab5897a08e3d743 /xfa/fxfa
parent9647614a5dcd00d50aacf4e000fd23a5ebb13931 (diff)
downloadpdfium-39628b04bc86461426f2dcf5a568f5e9e70ad997.tar.xz
Change CXFA_BoxData to CXFA_Box
This CL renames CXFA_BoxData to CXFA_Box and sets it to inhert from CXFA_Node instead of CXFA_DataData. The CXFA_BoxData subclasses, CXFA_RectangleData, CXFA_BorderData and CXFA_ArcData classes are removed and the nodes now inherit from CXFA_Box. Change-Id: Ia0df7d56535b5d90be29f040180a5d5fc55a64e0 Reviewed-on: https://pdfium-review.googlesource.com/22091 Reviewed-by: Ryan Harrison <rharrison@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'xfa/fxfa')
-rw-r--r--xfa/fxfa/cxfa_ffarc.cpp3
-rw-r--r--xfa/fxfa/cxfa_ffbarcode.cpp3
-rw-r--r--xfa/fxfa/cxfa_ffcheckbutton.cpp9
-rw-r--r--xfa/fxfa/cxfa_fffield.cpp9
-rw-r--r--xfa/fxfa/cxfa_ffimageedit.cpp3
-rw-r--r--xfa/fxfa/cxfa_ffpushbutton.cpp10
-rw-r--r--xfa/fxfa/cxfa_ffrectangle.cpp3
-rw-r--r--xfa/fxfa/cxfa_ffsignature.cpp3
-rw-r--r--xfa/fxfa/cxfa_ffwidget.cpp98
-rw-r--r--xfa/fxfa/cxfa_ffwidget.h5
-rw-r--r--xfa/fxfa/cxfa_widgetacc.h1
-rw-r--r--xfa/fxfa/parser/cxfa_arc.cpp18
-rw-r--r--xfa/fxfa/parser/cxfa_arc.h4
-rw-r--r--xfa/fxfa/parser/cxfa_arcdata.h19
-rw-r--r--xfa/fxfa/parser/cxfa_border.cpp18
-rw-r--r--xfa/fxfa/parser/cxfa_border.h4
-rw-r--r--xfa/fxfa/parser/cxfa_borderdata.h19
-rw-r--r--xfa/fxfa/parser/cxfa_box.cpp159
-rw-r--r--xfa/fxfa/parser/cxfa_box.h57
-rw-r--r--xfa/fxfa/parser/cxfa_boxdata.cpp158
-rw-r--r--xfa/fxfa/parser/cxfa_boxdata.h43
-rw-r--r--xfa/fxfa/parser/cxfa_rectangle.cpp18
-rw-r--r--xfa/fxfa/parser/cxfa_rectangle.h4
-rw-r--r--xfa/fxfa/parser/cxfa_rectangledata.h19
-rw-r--r--xfa/fxfa/parser/cxfa_value.cpp10
-rw-r--r--xfa/fxfa/parser/cxfa_value.h9
-rw-r--r--xfa/fxfa/parser/cxfa_widgetdata.cpp27
-rw-r--r--xfa/fxfa/parser/cxfa_widgetdata.h6
28 files changed, 351 insertions, 388 deletions
diff --git a/xfa/fxfa/cxfa_ffarc.cpp b/xfa/fxfa/cxfa_ffarc.cpp
index e670ba9785..95a64e7c61 100644
--- a/xfa/fxfa/cxfa_ffarc.cpp
+++ b/xfa/fxfa/cxfa_ffarc.cpp
@@ -6,6 +6,7 @@
#include "xfa/fxfa/cxfa_ffarc.h"
+#include "xfa/fxfa/parser/cxfa_arc.h"
#include "xfa/fxfa/parser/cxfa_value.h"
CXFA_FFArc::CXFA_FFArc(CXFA_WidgetAcc* pDataAcc) : CXFA_FFDraw(pDataAcc) {}
@@ -30,5 +31,5 @@ void CXFA_FFArc::RenderWidget(CXFA_Graphics* pGS,
CFX_Matrix mtRotate = GetRotateMatrix();
mtRotate.Concat(matrix);
- DrawBorder(pGS, value->GetArcData(), rtArc, mtRotate);
+ DrawBorder(pGS, value->GetArc(), rtArc, mtRotate);
}
diff --git a/xfa/fxfa/cxfa_ffbarcode.cpp b/xfa/fxfa/cxfa_ffbarcode.cpp
index 29c6d85e89..a7a66afa49 100644
--- a/xfa/fxfa/cxfa_ffbarcode.cpp
+++ b/xfa/fxfa/cxfa_ffbarcode.cpp
@@ -17,6 +17,7 @@
#include "xfa/fxfa/cxfa_ffpageview.h"
#include "xfa/fxfa/cxfa_ffwidget.h"
#include "xfa/fxfa/cxfa_fwladapterwidgetmgr.h"
+#include "xfa/fxfa/parser/cxfa_border.h"
namespace {
@@ -145,7 +146,7 @@ void CXFA_FFBarcode::RenderWidget(CXFA_Graphics* pGS,
mtRotate.Concat(matrix);
CXFA_FFWidget::RenderWidget(pGS, mtRotate, dwStatus);
- DrawBorder(pGS, m_pDataAcc->GetUIBorderData(), m_rtUI, mtRotate);
+ DrawBorder(pGS, m_pDataAcc->GetUIBorder(), m_rtUI, mtRotate);
RenderCaption(pGS, &mtRotate);
CFX_RectF rtWidget = m_pNormalWidget->GetWidgetRect();
diff --git a/xfa/fxfa/cxfa_ffcheckbutton.cpp b/xfa/fxfa/cxfa_ffcheckbutton.cpp
index 00369784e1..9083a254a1 100644
--- a/xfa/fxfa/cxfa_ffcheckbutton.cpp
+++ b/xfa/fxfa/cxfa_ffcheckbutton.cpp
@@ -19,6 +19,7 @@
#include "xfa/fxfa/cxfa_fffield.h"
#include "xfa/fxfa/cxfa_ffpageview.h"
#include "xfa/fxfa/cxfa_ffwidget.h"
+#include "xfa/fxfa/parser/cxfa_border.h"
#include "xfa/fxfa/parser/cxfa_para.h"
CXFA_FFCheckButton::CXFA_FFCheckButton(CXFA_WidgetAcc* pDataAcc)
@@ -171,9 +172,9 @@ bool CXFA_FFCheckButton::PerformLayout() {
m_rtUI.height = fCheckSize;
AddUIMargin(iCapPlacement);
m_rtCheckBox = m_rtUI;
- CXFA_BorderData borderUIData = m_pDataAcc->GetUIBorderData();
- if (borderUIData.HasValidNode()) {
- CXFA_Margin* borderMargin = borderUIData.GetMargin();
+ CXFA_Border* borderUI = m_pDataAcc->GetUIBorder();
+ if (borderUI) {
+ CXFA_Margin* borderMargin = borderUI->GetMargin();
if (borderMargin)
XFA_RectWidthoutMargin(m_rtUI, borderMargin);
}
@@ -233,7 +234,7 @@ void CXFA_FFCheckButton::RenderWidget(CXFA_Graphics* pGS,
CXFA_FFWidget::RenderWidget(pGS, mtRotate, dwStatus);
DrawBorderWithFlags(
- pGS, m_pDataAcc->GetUIBorderData(), m_rtUI, mtRotate,
+ pGS, m_pDataAcc->GetUIBorder(), m_rtUI, mtRotate,
m_pDataAcc->IsCheckButtonRound() ? XFA_DRAWBOX_ForceRound : 0);
RenderCaption(pGS, &mtRotate);
DrawHighlight(pGS, &mtRotate, dwStatus, m_pDataAcc->IsCheckButtonRound());
diff --git a/xfa/fxfa/cxfa_fffield.cpp b/xfa/fxfa/cxfa_fffield.cpp
index 75bd064e29..678b9f0d9a 100644
--- a/xfa/fxfa/cxfa_fffield.cpp
+++ b/xfa/fxfa/cxfa_fffield.cpp
@@ -22,6 +22,7 @@
#include "xfa/fxfa/cxfa_ffwidget.h"
#include "xfa/fxfa/cxfa_fwltheme.h"
#include "xfa/fxfa/cxfa_textlayout.h"
+#include "xfa/fxfa/parser/cxfa_border.h"
#include "xfa/fxfa/parser/cxfa_calculate.h"
#include "xfa/fxfa/parser/cxfa_margin.h"
#include "xfa/fxfa/parser/cxfa_node.h"
@@ -68,7 +69,7 @@ void CXFA_FFField::RenderWidget(CXFA_Graphics* pGS,
mtRotate.Concat(matrix);
CXFA_FFWidget::RenderWidget(pGS, mtRotate, dwStatus);
- DrawBorder(pGS, m_pDataAcc->GetUIBorderData(), m_rtUI, mtRotate);
+ DrawBorder(pGS, m_pDataAcc->GetUIBorder(), m_rtUI, mtRotate);
RenderCaption(pGS, &mtRotate);
DrawHighlight(pGS, &mtRotate, dwStatus, false);
@@ -264,9 +265,9 @@ void CXFA_FFField::CapPlacement() {
break;
}
- CXFA_BorderData borderUIData = m_pDataAcc->GetUIBorderData();
- if (borderUIData.HasValidNode()) {
- CXFA_Margin* borderMargin = borderUIData.GetMargin();
+ CXFA_Border* borderUI = m_pDataAcc->GetUIBorder();
+ if (borderUI) {
+ CXFA_Margin* borderMargin = borderUI->GetMargin();
if (borderMargin)
XFA_RectWidthoutMargin(m_rtUI, borderMargin);
}
diff --git a/xfa/fxfa/cxfa_ffimageedit.cpp b/xfa/fxfa/cxfa_ffimageedit.cpp
index 3705241baf..b3e9ee3383 100644
--- a/xfa/fxfa/cxfa_ffimageedit.cpp
+++ b/xfa/fxfa/cxfa_ffimageedit.cpp
@@ -18,6 +18,7 @@
#include "xfa/fxfa/cxfa_fffield.h"
#include "xfa/fxfa/cxfa_ffpageview.h"
#include "xfa/fxfa/cxfa_ffwidget.h"
+#include "xfa/fxfa/parser/cxfa_border.h"
#include "xfa/fxfa/parser/cxfa_para.h"
#include "xfa/fxfa/parser/cxfa_value.h"
@@ -63,7 +64,7 @@ void CXFA_FFImageEdit::RenderWidget(CXFA_Graphics* pGS,
mtRotate.Concat(matrix);
CXFA_FFWidget::RenderWidget(pGS, mtRotate, dwStatus);
- DrawBorder(pGS, m_pDataAcc->GetUIBorderData(), m_rtUI, mtRotate);
+ DrawBorder(pGS, m_pDataAcc->GetUIBorder(), m_rtUI, mtRotate);
RenderCaption(pGS, &mtRotate);
RetainPtr<CFX_DIBitmap> pDIBitmap = m_pDataAcc->GetImageEditImage();
if (!pDIBitmap)
diff --git a/xfa/fxfa/cxfa_ffpushbutton.cpp b/xfa/fxfa/cxfa_ffpushbutton.cpp
index 914b350767..8358ba0dac 100644
--- a/xfa/fxfa/cxfa_ffpushbutton.cpp
+++ b/xfa/fxfa/cxfa_ffpushbutton.cpp
@@ -18,6 +18,7 @@
#include "xfa/fxfa/cxfa_ffwidget.h"
#include "xfa/fxfa/cxfa_textlayout.h"
#include "xfa/fxfa/cxfa_textprovider.h"
+#include "xfa/fxfa/parser/cxfa_border.h"
#include "xfa/fxgraphics/cxfa_gecolor.h"
#include "xfa/fxgraphics/cxfa_gepath.h"
@@ -115,12 +116,9 @@ bool CXFA_FFPushButton::PerformLayout() {
return true;
}
float CXFA_FFPushButton::GetLineWidth() {
- CXFA_BorderData borderData = m_pDataAcc->GetBorderData(false);
- if (borderData.HasValidNode() &&
- borderData.GetPresence() == XFA_AttributeEnum::Visible) {
- return borderData.GetEdgeData(0).GetThickness();
- }
-
+ CXFA_Border* border = m_pDataAcc->GetBorder(false);
+ if (border && border->GetPresence() == XFA_AttributeEnum::Visible)
+ return border->GetEdgeData(0).GetThickness();
return 0;
}
diff --git a/xfa/fxfa/cxfa_ffrectangle.cpp b/xfa/fxfa/cxfa_ffrectangle.cpp
index 080488418d..1ccb75c1c3 100644
--- a/xfa/fxfa/cxfa_ffrectangle.cpp
+++ b/xfa/fxfa/cxfa_ffrectangle.cpp
@@ -6,6 +6,7 @@
#include "xfa/fxfa/cxfa_ffrectangle.h"
+#include "xfa/fxfa/parser/cxfa_rectangle.h"
#include "xfa/fxfa/parser/cxfa_value.h"
CXFA_FFRectangle::CXFA_FFRectangle(CXFA_WidgetAcc* pDataAcc)
@@ -31,5 +32,5 @@ void CXFA_FFRectangle::RenderWidget(CXFA_Graphics* pGS,
CFX_Matrix mtRotate = GetRotateMatrix();
mtRotate.Concat(matrix);
- DrawBorder(pGS, value->GetRectangleData(), rect, mtRotate);
+ DrawBorder(pGS, value->GetRectangle(), rect, mtRotate);
}
diff --git a/xfa/fxfa/cxfa_ffsignature.cpp b/xfa/fxfa/cxfa_ffsignature.cpp
index 3aeddfd970..4501c6d2c1 100644
--- a/xfa/fxfa/cxfa_ffsignature.cpp
+++ b/xfa/fxfa/cxfa_ffsignature.cpp
@@ -10,6 +10,7 @@
#include "xfa/fxfa/cxfa_fffield.h"
#include "xfa/fxfa/cxfa_ffpageview.h"
#include "xfa/fxfa/cxfa_ffwidget.h"
+#include "xfa/fxfa/parser/cxfa_border.h"
CXFA_FFSignature::CXFA_FFSignature(CXFA_WidgetAcc* pDataAcc)
: CXFA_FFField(pDataAcc) {}
@@ -31,7 +32,7 @@ void CXFA_FFSignature::RenderWidget(CXFA_Graphics* pGS,
CXFA_FFWidget::RenderWidget(pGS, mtRotate, dwStatus);
- DrawBorder(pGS, m_pDataAcc->GetUIBorderData(), m_rtUI, mtRotate);
+ DrawBorder(pGS, m_pDataAcc->GetUIBorder(), m_rtUI, mtRotate);
RenderCaption(pGS, &mtRotate);
DrawHighlight(pGS, &mtRotate, dwStatus, false);
}
diff --git a/xfa/fxfa/cxfa_ffwidget.cpp b/xfa/fxfa/cxfa_ffwidget.cpp
index 9367301175..4b5806f505 100644
--- a/xfa/fxfa/cxfa_ffwidget.cpp
+++ b/xfa/fxfa/cxfa_ffwidget.cpp
@@ -30,6 +30,8 @@
#include "xfa/fxfa/cxfa_ffpageview.h"
#include "xfa/fxfa/cxfa_textlayout.h"
#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_margin.h"
#include "xfa/fxfa/parser/cxfa_node.h"
@@ -41,14 +43,14 @@
namespace {
-void XFA_BOX_GetPath_Arc(const CXFA_BoxData& boxData,
+void XFA_BOX_GetPath_Arc(CXFA_Box* box,
CFX_RectF rtDraw,
CXFA_GEPath& fillPath,
uint32_t dwFlags) {
float a, b;
a = rtDraw.width / 2.0f;
b = rtDraw.height / 2.0f;
- if (boxData.IsCircular() || (dwFlags & XFA_DRAWBOX_ForceRound) != 0)
+ if (box->IsCircular() || (dwFlags & XFA_DRAWBOX_ForceRound) != 0)
a = b = std::min(a, b);
CFX_PointF center = rtDraw.Center();
@@ -56,8 +58,8 @@ void XFA_BOX_GetPath_Arc(const CXFA_BoxData& boxData,
rtDraw.top = center.y - b;
rtDraw.width = a + a;
rtDraw.height = b + b;
- pdfium::Optional<int32_t> startAngle = boxData.GetStartAngle();
- pdfium::Optional<int32_t> sweepAngle = boxData.GetSweepAngle();
+ pdfium::Optional<int32_t> startAngle = box->GetStartAngle();
+ pdfium::Optional<int32_t> sweepAngle = box->GetSweepAngle();
if (!startAngle && !sweepAngle) {
fillPath.AddEllipse(rtDraw);
return;
@@ -236,21 +238,21 @@ void XFA_BOX_GetPath(const std::vector<CXFA_StrokeData>& strokes,
}
}
-void XFA_BOX_GetFillPath(const CXFA_BoxData& boxData,
+void XFA_BOX_GetFillPath(CXFA_Box* box,
const std::vector<CXFA_StrokeData>& strokes,
CFX_RectF rtWidget,
CXFA_GEPath& fillPath,
uint16_t dwFlags) {
- if (boxData.IsArc() || (dwFlags & XFA_DRAWBOX_ForceRound) != 0) {
- float fThickness = std::fmax(0.0, boxData.GetEdgeData(0).GetThickness());
+ if (box->IsArc() || (dwFlags & XFA_DRAWBOX_ForceRound) != 0) {
+ float fThickness = std::fmax(0.0, box->GetEdgeData(0).GetThickness());
float fHalf = fThickness / 2;
- XFA_AttributeEnum iHand = boxData.GetHand();
+ XFA_AttributeEnum iHand = box->GetHand();
if (iHand == XFA_AttributeEnum::Left)
rtWidget.Inflate(fHalf, fHalf);
else if (iHand == XFA_AttributeEnum::Right)
rtWidget.Deflate(fHalf, fHalf);
- XFA_BOX_GetPath_Arc(boxData, rtWidget, fillPath, dwFlags);
+ XFA_BOX_GetPath_Arc(box, rtWidget, fillPath, dwFlags);
return;
}
@@ -386,12 +388,12 @@ void XFA_BOX_GetFillPath(const CXFA_BoxData& boxData,
}
}
-void XFA_BOX_Fill_Radial(const CXFA_BoxData& boxData,
+void XFA_BOX_Fill_Radial(CXFA_Box* box,
CXFA_Graphics* pGS,
CXFA_GEPath& fillPath,
CFX_RectF rtFill,
const CFX_Matrix& matrix) {
- CXFA_FillData fillData = boxData.GetFillData(false);
+ CXFA_FillData fillData = box->GetFillData(false);
FX_ARGB crStart = fillData.GetColor(false);
FX_ARGB crEnd = fillData.GetRadialColor();
if (!fillData.IsRadialToEdge())
@@ -406,12 +408,12 @@ void XFA_BOX_Fill_Radial(const CXFA_BoxData& boxData,
pGS->FillPath(&fillPath, FXFILL_WINDING, &matrix);
}
-void XFA_BOX_Fill_Pattern(const CXFA_BoxData& boxData,
+void XFA_BOX_Fill_Pattern(CXFA_Box* box,
CXFA_Graphics* pGS,
CXFA_GEPath& fillPath,
CFX_RectF rtFill,
const CFX_Matrix& matrix) {
- CXFA_FillData fillData = boxData.GetFillData(false);
+ CXFA_FillData fillData = box->GetFillData(false);
FX_ARGB crStart = fillData.GetColor(false);
FX_ARGB crEnd = fillData.GetPatternColor();
FX_HatchStyle iHatch = FX_HatchStyle::Cross;
@@ -440,12 +442,12 @@ void XFA_BOX_Fill_Pattern(const CXFA_BoxData& boxData,
pGS->FillPath(&fillPath, FXFILL_WINDING, &matrix);
}
-void XFA_BOX_Fill_Linear(const CXFA_BoxData& boxData,
+void XFA_BOX_Fill_Linear(CXFA_Box* box,
CXFA_Graphics* pGS,
CXFA_GEPath& fillPath,
CFX_RectF rtFill,
const CFX_Matrix& matrix) {
- CXFA_FillData fillData = boxData.GetFillData(false);
+ CXFA_FillData fillData = box->GetFillData(false);
FX_ARGB crStart = fillData.GetColor(false);
FX_ARGB crEnd = fillData.GetLinearColor();
@@ -477,31 +479,31 @@ void XFA_BOX_Fill_Linear(const CXFA_BoxData& boxData,
pGS->FillPath(&fillPath, FXFILL_WINDING, &matrix);
}
-void XFA_BOX_Fill(const CXFA_BoxData& boxData,
+void XFA_BOX_Fill(CXFA_Box* box,
const std::vector<CXFA_StrokeData>& strokes,
CXFA_Graphics* pGS,
const CFX_RectF& rtWidget,
const CFX_Matrix& matrix,
uint32_t dwFlags) {
- CXFA_FillData fillData = boxData.GetFillData(false);
+ CXFA_FillData fillData = box->GetFillData(false);
if (!fillData.HasValidNode() || !fillData.IsVisible())
return;
pGS->SaveGraphState();
CXFA_GEPath fillPath;
- XFA_BOX_GetFillPath(boxData, strokes, rtWidget, fillPath,
+ XFA_BOX_GetFillPath(box, strokes, rtWidget, fillPath,
(dwFlags & XFA_DRAWBOX_ForceRound) != 0);
fillPath.Close();
XFA_Element eType = fillData.GetFillType();
switch (eType) {
case XFA_Element::Radial:
- XFA_BOX_Fill_Radial(boxData, pGS, fillPath, rtWidget, matrix);
+ XFA_BOX_Fill_Radial(box, pGS, fillPath, rtWidget, matrix);
break;
case XFA_Element::Pattern:
- XFA_BOX_Fill_Pattern(boxData, pGS, fillPath, rtWidget, matrix);
+ XFA_BOX_Fill_Pattern(box, pGS, fillPath, rtWidget, matrix);
break;
case XFA_Element::Linear:
- XFA_BOX_Fill_Linear(boxData, pGS, fillPath, rtWidget, matrix);
+ XFA_BOX_Fill_Linear(box, pGS, fillPath, rtWidget, matrix);
break;
default: {
FX_ARGB cr;
@@ -549,19 +551,19 @@ void XFA_BOX_StrokePath(const CXFA_StrokeData& strokeData,
pGS->RestoreGraphState();
}
-void XFA_BOX_StrokeArc(const CXFA_BoxData& boxData,
+void XFA_BOX_StrokeArc(CXFA_Box* box,
CXFA_Graphics* pGS,
CFX_RectF rtWidget,
const CFX_Matrix& matrix,
uint32_t dwFlags) {
- CXFA_EdgeData edgeData = boxData.GetEdgeData(0);
+ CXFA_EdgeData edgeData = box->GetEdgeData(0);
if (!edgeData.HasValidNode() || !edgeData.IsVisible())
return;
bool bVisible;
float fThickness;
XFA_AttributeEnum i3DType;
- std::tie(i3DType, bVisible, fThickness) = boxData.Get3DStyle();
+ std::tie(i3DType, bVisible, fThickness) = box->Get3DStyle();
if (i3DType != XFA_AttributeEnum::Unknown) {
if (bVisible && fThickness >= 0.001f) {
dwFlags |= XFA_DRAWBOX_Lowered3D;
@@ -572,7 +574,7 @@ void XFA_BOX_StrokeArc(const CXFA_BoxData& boxData,
fHalf = 0;
}
- XFA_AttributeEnum iHand = boxData.GetHand();
+ XFA_AttributeEnum iHand = box->GetHand();
if (iHand == XFA_AttributeEnum::Left) {
rtWidget.Inflate(fHalf, fHalf);
} else if (iHand == XFA_AttributeEnum::Right) {
@@ -584,7 +586,7 @@ void XFA_BOX_StrokeArc(const CXFA_BoxData& boxData,
return;
CXFA_GEPath arcPath;
- XFA_BOX_GetPath_Arc(boxData, rtWidget, arcPath, dwFlags);
+ XFA_BOX_GetPath_Arc(box, rtWidget, arcPath, dwFlags);
XFA_BOX_StrokePath(edgeData, &arcPath, pGS, matrix);
return;
}
@@ -722,7 +724,7 @@ void XFA_BOX_Stroke_3DRect_Embossed(CXFA_Graphics* pGS,
XFA_Draw3DRect(pGS, rtInner, fHalfWidth, matrix, 0xFF000000, 0xFF808080);
}
-void XFA_BOX_Stroke_Rect(CXFA_BoxData boxData,
+void XFA_BOX_Stroke_Rect(CXFA_Box* box,
const std::vector<CXFA_StrokeData>& strokes,
CXFA_Graphics* pGS,
CFX_RectF rtWidget,
@@ -730,7 +732,7 @@ void XFA_BOX_Stroke_Rect(CXFA_BoxData boxData,
bool bVisible;
float fThickness;
XFA_AttributeEnum i3DType;
- std::tie(i3DType, bVisible, fThickness) = boxData.Get3DStyle();
+ std::tie(i3DType, bVisible, fThickness) = box->Get3DStyle();
if (i3DType != XFA_AttributeEnum::Unknown) {
if (!bVisible || fThickness < 0.001f) {
return;
@@ -815,14 +817,14 @@ void XFA_BOX_Stroke_Rect(CXFA_BoxData boxData,
}
}
-void XFA_BOX_Stroke(CXFA_BoxData boxData,
+void XFA_BOX_Stroke(CXFA_Box* box,
const std::vector<CXFA_StrokeData>& strokes,
CXFA_Graphics* pGS,
CFX_RectF rtWidget,
const CFX_Matrix& matrix,
uint32_t dwFlags) {
- if (boxData.IsArc() || (dwFlags & XFA_DRAWBOX_ForceRound) != 0) {
- XFA_BOX_StrokeArc(boxData, pGS, rtWidget, matrix, dwFlags);
+ if (box->IsArc() || (dwFlags & XFA_DRAWBOX_ForceRound) != 0) {
+ XFA_BOX_StrokeArc(box, pGS, rtWidget, matrix, dwFlags);
return;
}
bool bVisible = false;
@@ -839,7 +841,7 @@ void XFA_BOX_Stroke(CXFA_BoxData boxData,
float fThickness =
std::fmax(0.0, CXFA_EdgeData(strokes[i].GetNode()).GetThickness());
float fHalf = fThickness / 2;
- XFA_AttributeEnum iHand = boxData.GetHand();
+ XFA_AttributeEnum iHand = box->GetHand();
switch (i) {
case 1:
if (iHand == XFA_AttributeEnum::Left) {
@@ -875,30 +877,28 @@ void XFA_BOX_Stroke(CXFA_BoxData boxData,
break;
}
}
- XFA_BOX_Stroke_Rect(boxData, strokes, pGS, rtWidget, matrix);
+ XFA_BOX_Stroke_Rect(box, strokes, pGS, rtWidget, matrix);
}
-void XFA_DrawBox(CXFA_BoxData boxData,
+void XFA_DrawBox(CXFA_Box* box,
CXFA_Graphics* pGS,
const CFX_RectF& rtWidget,
const CFX_Matrix& matrix,
uint32_t dwFlags) {
- if (!boxData.HasValidNode() ||
- boxData.GetPresence() != XFA_AttributeEnum::Visible) {
+ if (!box || box->GetPresence() != XFA_AttributeEnum::Visible)
return;
- }
- XFA_Element eType = boxData.GetElementType();
+ XFA_Element eType = box->GetElementType();
if (eType != XFA_Element::Arc && eType != XFA_Element::Border &&
eType != XFA_Element::Rectangle) {
return;
}
std::vector<CXFA_StrokeData> strokes;
if (!(dwFlags & XFA_DRAWBOX_ForceRound) && eType != XFA_Element::Arc)
- strokes = boxData.GetStrokes();
+ strokes = box->GetStrokes();
- XFA_BOX_Fill(boxData, strokes, pGS, rtWidget, matrix, dwFlags);
- XFA_BOX_Stroke(boxData, strokes, pGS, rtWidget, matrix, dwFlags);
+ XFA_BOX_Fill(box, strokes, pGS, rtWidget, matrix, dwFlags);
+ XFA_BOX_Stroke(box, strokes, pGS, rtWidget, matrix, dwFlags);
}
bool IsFXCodecErrorStatus(FXCODEC_STATUS status) {
@@ -985,17 +985,17 @@ void CXFA_FFWidget::RenderWidget(CXFA_Graphics* pGS,
if (!IsMatchVisibleStatus(dwStatus))
return;
- CXFA_BorderData borderData = m_pDataAcc->GetBorderData(false);
- if (!borderData.HasValidNode())
+ CXFA_Border* border = m_pDataAcc->GetBorder(false);
+ if (!border)
return;
CFX_RectF rtBorder = GetRectWithoutRotate();
- CXFA_Margin* margin = borderData.GetMargin();
+ CXFA_Margin* margin = border->GetMargin();
if (margin)
XFA_RectWidthoutMargin(rtBorder, margin);
rtBorder.Normalize();
- DrawBorder(pGS, borderData, rtBorder, matrix);
+ DrawBorder(pGS, border, rtBorder, matrix);
}
bool CXFA_FFWidget::IsLoaded() {
@@ -1016,18 +1016,18 @@ bool CXFA_FFWidget::UpdateFWLData() {
void CXFA_FFWidget::UpdateWidgetProperty() {}
void CXFA_FFWidget::DrawBorder(CXFA_Graphics* pGS,
- const CXFA_BoxData& boxData,
+ CXFA_Box* box,
const CFX_RectF& rtBorder,
const CFX_Matrix& matrix) {
- XFA_DrawBox(boxData, pGS, rtBorder, matrix, 0);
+ XFA_DrawBox(box, pGS, rtBorder, matrix, 0);
}
void CXFA_FFWidget::DrawBorderWithFlags(CXFA_Graphics* pGS,
- const CXFA_BoxData& boxData,
+ CXFA_Box* box,
const CFX_RectF& rtBorder,
const CFX_Matrix& matrix,
uint32_t dwFlags) {
- XFA_DrawBox(boxData, pGS, rtBorder, matrix, dwFlags);
+ XFA_DrawBox(box, pGS, rtBorder, matrix, dwFlags);
}
void CXFA_FFWidget::AddInvalidateRect() {
diff --git a/xfa/fxfa/cxfa_ffwidget.h b/xfa/fxfa/cxfa_ffwidget.h
index ac3d985094..757d6db5d9 100644
--- a/xfa/fxfa/cxfa_ffwidget.h
+++ b/xfa/fxfa/cxfa_ffwidget.h
@@ -15,6 +15,7 @@
#include "xfa/fxfa/fxfa.h"
#include "xfa/fxfa/parser/cxfa_contentlayoutitem.h"
+class CXFA_Box;
class CXFA_FFPageView;
class CXFA_FFDocView;
class CXFA_FFDoc;
@@ -164,11 +165,11 @@ class CXFA_FFWidget : public CXFA_ContentLayoutItem {
virtual bool PtInActiveRect(const CFX_PointF& point);
void DrawBorder(CXFA_Graphics* pGS,
- const CXFA_BoxData& boxData,
+ CXFA_Box* box,
const CFX_RectF& rtBorder,
const CFX_Matrix& matrix);
void DrawBorderWithFlags(CXFA_Graphics* pGS,
- const CXFA_BoxData& boxData,
+ CXFA_Box* box,
const CFX_RectF& rtBorder,
const CFX_Matrix& matrix,
uint32_t dwFlags);
diff --git a/xfa/fxfa/cxfa_widgetacc.h b/xfa/fxfa/cxfa_widgetacc.h
index 35bed64db1..65cd51747f 100644
--- a/xfa/fxfa/cxfa_widgetacc.h
+++ b/xfa/fxfa/cxfa_widgetacc.h
@@ -14,7 +14,6 @@
#include "core/fxcrt/retain_ptr.h"
#include "core/fxge/dib/cfx_dibitmap.h"
#include "core/fxge/fx_dib.h"
-#include "xfa/fxfa/parser/cxfa_boxdata.h"
#include "xfa/fxfa/parser/cxfa_eventdata.h"
#include "xfa/fxfa/parser/cxfa_imagedata.h"
#include "xfa/fxfa/parser/cxfa_widgetdata.h"
diff --git a/xfa/fxfa/parser/cxfa_arc.cpp b/xfa/fxfa/parser/cxfa_arc.cpp
index 2a06ba6f32..9fb89a5b40 100644
--- a/xfa/fxfa/parser/cxfa_arc.cpp
+++ b/xfa/fxfa/parser/cxfa_arc.cpp
@@ -30,14 +30,14 @@ constexpr wchar_t kName[] = L"arc";
} // namespace
CXFA_Arc::CXFA_Arc(CXFA_Document* doc, XFA_PacketType packet)
- : CXFA_Node(doc,
- packet,
- (XFA_XDPPACKET_Template | XFA_XDPPACKET_Form),
- XFA_ObjectType::Node,
- XFA_Element::Arc,
- kPropertyData,
- kAttributeData,
- kName,
- pdfium::MakeUnique<CJX_Arc>(this)) {}
+ : CXFA_Box(doc,
+ packet,
+ (XFA_XDPPACKET_Template | XFA_XDPPACKET_Form),
+ XFA_ObjectType::Node,
+ XFA_Element::Arc,
+ kPropertyData,
+ kAttributeData,
+ kName,
+ pdfium::MakeUnique<CJX_Arc>(this)) {}
CXFA_Arc::~CXFA_Arc() {}
diff --git a/xfa/fxfa/parser/cxfa_arc.h b/xfa/fxfa/parser/cxfa_arc.h
index 6e838f802a..fd903aa249 100644
--- a/xfa/fxfa/parser/cxfa_arc.h
+++ b/xfa/fxfa/parser/cxfa_arc.h
@@ -7,9 +7,9 @@
#ifndef XFA_FXFA_PARSER_CXFA_ARC_H_
#define XFA_FXFA_PARSER_CXFA_ARC_H_
-#include "xfa/fxfa/parser/cxfa_node.h"
+#include "xfa/fxfa/parser/cxfa_box.h"
-class CXFA_Arc : public CXFA_Node {
+class CXFA_Arc : public CXFA_Box {
public:
CXFA_Arc(CXFA_Document* doc, XFA_PacketType packet);
~CXFA_Arc() override;
diff --git a/xfa/fxfa/parser/cxfa_arcdata.h b/xfa/fxfa/parser/cxfa_arcdata.h
deleted file mode 100644
index 9c1272e9c6..0000000000
--- a/xfa/fxfa/parser/cxfa_arcdata.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_ARCDATA_H_
-#define XFA_FXFA_PARSER_CXFA_ARCDATA_H_
-
-#include "xfa/fxfa/parser/cxfa_boxdata.h"
-
-class CXFA_Node;
-
-class CXFA_ArcData : public CXFA_BoxData {
- public:
- explicit CXFA_ArcData(CXFA_Node* pNode) : CXFA_BoxData(pNode) {}
-};
-
-#endif // XFA_FXFA_PARSER_CXFA_ARCDATA_H_
diff --git a/xfa/fxfa/parser/cxfa_border.cpp b/xfa/fxfa/parser/cxfa_border.cpp
index 8f22892814..c58fbe316d 100644
--- a/xfa/fxfa/parser/cxfa_border.cpp
+++ b/xfa/fxfa/parser/cxfa_border.cpp
@@ -33,14 +33,14 @@ constexpr wchar_t kName[] = L"border";
} // namespace
CXFA_Border::CXFA_Border(CXFA_Document* doc, XFA_PacketType packet)
- : CXFA_Node(doc,
- packet,
- (XFA_XDPPACKET_Template | XFA_XDPPACKET_Form),
- XFA_ObjectType::Node,
- XFA_Element::Border,
- kPropertyData,
- kAttributeData,
- kName,
- pdfium::MakeUnique<CJX_Border>(this)) {}
+ : CXFA_Box(doc,
+ packet,
+ (XFA_XDPPACKET_Template | XFA_XDPPACKET_Form),
+ XFA_ObjectType::Node,
+ XFA_Element::Border,
+ kPropertyData,
+ kAttributeData,
+ kName,
+ pdfium::MakeUnique<CJX_Border>(this)) {}
CXFA_Border::~CXFA_Border() {}
diff --git a/xfa/fxfa/parser/cxfa_border.h b/xfa/fxfa/parser/cxfa_border.h
index 041999bb3e..8e947e3438 100644
--- a/xfa/fxfa/parser/cxfa_border.h
+++ b/xfa/fxfa/parser/cxfa_border.h
@@ -7,9 +7,9 @@
#ifndef XFA_FXFA_PARSER_CXFA_BORDER_H_
#define XFA_FXFA_PARSER_CXFA_BORDER_H_
-#include "xfa/fxfa/parser/cxfa_node.h"
+#include "xfa/fxfa/parser/cxfa_box.h"
-class CXFA_Border : public CXFA_Node {
+class CXFA_Border : public CXFA_Box {
public:
CXFA_Border(CXFA_Document* doc, XFA_PacketType packet);
~CXFA_Border() override;
diff --git a/xfa/fxfa/parser/cxfa_borderdata.h b/xfa/fxfa/parser/cxfa_borderdata.h
deleted file mode 100644
index aba7d3dd1a..0000000000
--- a/xfa/fxfa/parser/cxfa_borderdata.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_BORDERDATA_H_
-#define XFA_FXFA_PARSER_CXFA_BORDERDATA_H_
-
-#include "xfa/fxfa/parser/cxfa_boxdata.h"
-
-class CXFA_Node;
-
-class CXFA_BorderData : public CXFA_BoxData {
- public:
- explicit CXFA_BorderData(CXFA_Node* pNode) : CXFA_BoxData(pNode) {}
-};
-
-#endif // XFA_FXFA_PARSER_CXFA_BORDERDATA_H_
diff --git a/xfa/fxfa/parser/cxfa_box.cpp b/xfa/fxfa/parser/cxfa_box.cpp
new file mode 100644
index 0000000000..544a21dcc0
--- /dev/null
+++ b/xfa/fxfa/parser/cxfa_box.cpp
@@ -0,0 +1,159 @@
+// 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_box.h"
+
+#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"
+#include "xfa/fxfa/parser/cxfa_measurement.h"
+#include "xfa/fxfa/parser/cxfa_node.h"
+
+namespace {
+
+XFA_AttributeEnum Style3D(const std::vector<CXFA_StrokeData>& strokes,
+ CXFA_StrokeData& strokeData) {
+ if (strokes.empty())
+ return XFA_AttributeEnum::Unknown;
+
+ strokeData = strokes[0];
+ for (size_t i = 1; i < strokes.size(); i++) {
+ CXFA_StrokeData find = strokes[i];
+ if (!find.HasValidNode())
+ continue;
+
+ if (!strokeData.HasValidNode())
+ strokeData = find;
+ else if (strokeData.GetStrokeType() != find.GetStrokeType())
+ strokeData = find;
+ break;
+ }
+
+ XFA_AttributeEnum iType = strokeData.GetStrokeType();
+ if (iType == XFA_AttributeEnum::Lowered ||
+ iType == XFA_AttributeEnum::Raised ||
+ iType == XFA_AttributeEnum::Etched ||
+ iType == XFA_AttributeEnum::Embossed) {
+ return iType;
+ }
+ return XFA_AttributeEnum::Unknown;
+}
+
+} // namespace
+
+CXFA_Box::CXFA_Box(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_Box::~CXFA_Box() = default;
+
+XFA_AttributeEnum CXFA_Box::GetHand() {
+ return JSObject()->GetEnum(XFA_Attribute::Hand);
+}
+
+XFA_AttributeEnum CXFA_Box::GetPresence() {
+ return JSObject()
+ ->TryEnum(XFA_Attribute::Presence, true)
+ .value_or(XFA_AttributeEnum::Visible);
+}
+
+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));
+}
+
+std::vector<CXFA_StrokeData> CXFA_Box::GetStrokes() {
+ return GetStrokesInternal(false);
+}
+
+bool CXFA_Box::IsCircular() {
+ return JSObject()->GetBoolean(XFA_Attribute::Circular);
+}
+
+pdfium::Optional<int32_t> CXFA_Box::GetStartAngle() {
+ return JSObject()->TryInteger(XFA_Attribute::StartAngle, false);
+}
+
+pdfium::Optional<int32_t> CXFA_Box::GetSweepAngle() {
+ return JSObject()->TryInteger(XFA_Attribute::SweepAngle, false);
+}
+
+CXFA_FillData CXFA_Box::GetFillData(bool bModified) {
+ CXFA_Node* pFillNode =
+ JSObject()->GetProperty<CXFA_Fill>(0, XFA_Element::Fill, bModified);
+ return CXFA_FillData(pFillNode);
+}
+
+CXFA_Margin* CXFA_Box::GetMargin() {
+ return GetChild<CXFA_Margin>(0, XFA_Element::Margin, false);
+}
+
+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);
+ if (iType == XFA_AttributeEnum::Unknown)
+ return {XFA_AttributeEnum::Unknown, false, 0.0f};
+
+ return {iType, strokeData.IsVisible(), strokeData.GetThickness()};
+}
+
+std::vector<CXFA_StrokeData> CXFA_Box::GetStrokesInternal(bool bNull) {
+ std::vector<CXFA_StrokeData> 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;
+ } else if (!bNull) {
+ if (i == 1 || i == 2)
+ strokes[j] = strokes[0];
+ else
+ 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;
+ } else if (!bNull) {
+ if (i == 1 || i == 2)
+ strokes[j] = strokes[1];
+ else
+ strokes[j] = strokes[3];
+ }
+ j++;
+ }
+ return strokes;
+}
diff --git a/xfa/fxfa/parser/cxfa_box.h b/xfa/fxfa/parser/cxfa_box.h
new file mode 100644
index 0000000000..5d9ee4c6fd
--- /dev/null
+++ b/xfa/fxfa/parser/cxfa_box.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_BOX_H_
+#define XFA_FXFA_PARSER_CXFA_BOX_H_
+
+#include <memory>
+#include <tuple>
+#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_Margin;
+
+class CXFA_Box : public CXFA_Node {
+ public:
+ ~CXFA_Box() override;
+
+ bool IsArc() const { return GetElementType() == XFA_Element::Arc; }
+ bool IsCircular();
+
+ XFA_AttributeEnum GetHand();
+ XFA_AttributeEnum GetPresence();
+ std::tuple<XFA_AttributeEnum, bool, float> Get3DStyle();
+
+ int32_t CountEdges();
+ CXFA_EdgeData GetEdgeData(int32_t nIndex);
+ CXFA_FillData GetFillData(bool bModified);
+ CXFA_Margin* GetMargin();
+
+ std::vector<CXFA_StrokeData> GetStrokes();
+
+ pdfium::Optional<int32_t> GetStartAngle();
+ pdfium::Optional<int32_t> GetSweepAngle();
+
+ protected:
+ CXFA_Box(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);
+
+ private:
+ std::vector<CXFA_StrokeData> GetStrokesInternal(bool bNull);
+};
+
+#endif // XFA_FXFA_PARSER_CXFA_BOX_H_
diff --git a/xfa/fxfa/parser/cxfa_boxdata.cpp b/xfa/fxfa/parser/cxfa_boxdata.cpp
deleted file mode 100644
index 31fefbf93d..0000000000
--- a/xfa/fxfa/parser/cxfa_boxdata.cpp
+++ /dev/null
@@ -1,158 +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_boxdata.h"
-
-#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"
-#include "xfa/fxfa/parser/cxfa_measurement.h"
-#include "xfa/fxfa/parser/cxfa_node.h"
-
-namespace {
-
-std::vector<CXFA_StrokeData> GetStrokesInternal(CXFA_Node* pNode, bool bNull) {
- if (!pNode)
- return {};
-
- std::vector<CXFA_StrokeData> strokes;
- strokes.resize(8);
- int32_t i, j;
- for (i = 0, j = 0; i < 4; i++) {
- CXFA_CornerData cornerData =
- CXFA_CornerData(pNode->JSObject()->GetProperty<CXFA_Corner>(
- i, XFA_Element::Corner, i == 0));
- if (cornerData.HasValidNode() || i == 0) {
- strokes[j] = cornerData;
- } else if (!bNull) {
- if (i == 1 || i == 2)
- strokes[j] = strokes[0];
- else
- strokes[j] = strokes[2];
- }
- j++;
- CXFA_EdgeData edgeData =
- CXFA_EdgeData(pNode->JSObject()->GetProperty<CXFA_Edge>(
- i, XFA_Element::Edge, i == 0));
- if (edgeData.HasValidNode() || i == 0) {
- strokes[j] = edgeData;
- } else if (!bNull) {
- if (i == 1 || i == 2)
- strokes[j] = strokes[1];
- else
- strokes[j] = strokes[3];
- }
- j++;
- }
- return strokes;
-}
-
-static XFA_AttributeEnum Style3D(const std::vector<CXFA_StrokeData>& strokes,
- CXFA_StrokeData& strokeData) {
- if (strokes.empty())
- return XFA_AttributeEnum::Unknown;
-
- strokeData = strokes[0];
- for (size_t i = 1; i < strokes.size(); i++) {
- CXFA_StrokeData find = strokes[i];
- if (!find.HasValidNode())
- continue;
-
- if (!strokeData.HasValidNode())
- strokeData = find;
- else if (strokeData.GetStrokeType() != find.GetStrokeType())
- strokeData = find;
- break;
- }
-
- XFA_AttributeEnum iType = strokeData.GetStrokeType();
- if (iType == XFA_AttributeEnum::Lowered ||
- iType == XFA_AttributeEnum::Raised ||
- iType == XFA_AttributeEnum::Etched ||
- iType == XFA_AttributeEnum::Embossed) {
- return iType;
- }
- return XFA_AttributeEnum::Unknown;
-}
-
-} // namespace
-
-XFA_AttributeEnum CXFA_BoxData::GetHand() const {
- if (!m_pNode)
- return XFA_AttributeEnum::Even;
- return m_pNode->JSObject()->GetEnum(XFA_Attribute::Hand);
-}
-
-XFA_AttributeEnum CXFA_BoxData::GetPresence() const {
- if (!m_pNode)
- return XFA_AttributeEnum::Hidden;
- return m_pNode->JSObject()
- ->TryEnum(XFA_Attribute::Presence, true)
- .value_or(XFA_AttributeEnum::Visible);
-}
-
-int32_t CXFA_BoxData::CountEdges() const {
- if (!m_pNode)
- return 0;
- return m_pNode->CountChildren(XFA_Element::Edge, false);
-}
-
-CXFA_EdgeData CXFA_BoxData::GetEdgeData(int32_t nIndex) const {
- return CXFA_EdgeData(m_pNode ? m_pNode->JSObject()->GetProperty<CXFA_Edge>(
- nIndex, XFA_Element::Edge, nIndex == 0)
- : nullptr);
-}
-
-std::vector<CXFA_StrokeData> CXFA_BoxData::GetStrokes() const {
- return GetStrokesInternal(m_pNode, false);
-}
-
-bool CXFA_BoxData::IsCircular() const {
- if (!m_pNode)
- return false;
- return m_pNode->JSObject()->GetBoolean(XFA_Attribute::Circular);
-}
-
-pdfium::Optional<int32_t> CXFA_BoxData::GetStartAngle() const {
- if (!m_pNode)
- return {};
- return m_pNode->JSObject()->TryInteger(XFA_Attribute::StartAngle, false);
-}
-
-pdfium::Optional<int32_t> CXFA_BoxData::GetSweepAngle() const {
- if (!m_pNode)
- return {};
- return m_pNode->JSObject()->TryInteger(XFA_Attribute::SweepAngle, false);
-}
-
-CXFA_FillData CXFA_BoxData::GetFillData(bool bModified) const {
- if (!m_pNode)
- return CXFA_FillData(nullptr);
-
- CXFA_Node* pFillNode = m_pNode->JSObject()->GetProperty<CXFA_Fill>(
- 0, XFA_Element::Fill, bModified);
- return CXFA_FillData(pFillNode);
-}
-
-CXFA_Margin* CXFA_BoxData::GetMargin() const {
- return m_pNode ? m_pNode->GetChild<CXFA_Margin>(0, XFA_Element::Margin, false)
- : nullptr;
-}
-
-std::tuple<XFA_AttributeEnum, bool, float> CXFA_BoxData::Get3DStyle() const {
- if (IsArc())
- return {XFA_AttributeEnum::Unknown, false, 0.0f};
-
- std::vector<CXFA_StrokeData> strokes = GetStrokesInternal(m_pNode, true);
- CXFA_StrokeData strokeData(nullptr);
- XFA_AttributeEnum iType = Style3D(strokes, strokeData);
- if (iType == XFA_AttributeEnum::Unknown)
- return {XFA_AttributeEnum::Unknown, 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
deleted file mode 100644
index c44065f67e..0000000000
--- a/xfa/fxfa/parser/cxfa_boxdata.h
+++ /dev/null
@@ -1,43 +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_BOXDATA_H_
-#define XFA_FXFA_PARSER_CXFA_BOXDATA_H_
-
-#include <tuple>
-#include <vector>
-
-#include "core/fxcrt/fx_system.h"
-#include "xfa/fxfa/parser/cxfa_datadata.h"
-#include "xfa/fxfa/parser/cxfa_edgedata.h"
-#include "xfa/fxfa/parser/cxfa_filldata.h"
-
-class CXFA_Margin;
-class CXFA_Node;
-
-class CXFA_BoxData : public CXFA_DataData {
- public:
- explicit CXFA_BoxData(CXFA_Node* pNode) : CXFA_DataData(pNode) {}
-
- bool IsArc() const { return GetElementType() == XFA_Element::Arc; }
- bool IsCircular() const;
-
- XFA_AttributeEnum GetHand() const;
- XFA_AttributeEnum GetPresence() const;
- std::tuple<XFA_AttributeEnum, bool, float> Get3DStyle() const;
-
- int32_t CountEdges() const;
- CXFA_EdgeData GetEdgeData(int32_t nIndex) const;
- CXFA_FillData GetFillData(bool bModified) const;
- CXFA_Margin* GetMargin() const;
-
- std::vector<CXFA_StrokeData> GetStrokes() const;
-
- pdfium::Optional<int32_t> GetStartAngle() const;
- pdfium::Optional<int32_t> GetSweepAngle() const;
-};
-
-#endif // XFA_FXFA_PARSER_CXFA_BOXDATA_H_
diff --git a/xfa/fxfa/parser/cxfa_rectangle.cpp b/xfa/fxfa/parser/cxfa_rectangle.cpp
index c3efcfd23b..01a204d149 100644
--- a/xfa/fxfa/parser/cxfa_rectangle.cpp
+++ b/xfa/fxfa/parser/cxfa_rectangle.cpp
@@ -28,14 +28,14 @@ constexpr wchar_t kName[] = L"rectangle";
} // namespace
CXFA_Rectangle::CXFA_Rectangle(CXFA_Document* doc, XFA_PacketType packet)
- : CXFA_Node(doc,
- packet,
- (XFA_XDPPACKET_Template | XFA_XDPPACKET_Form),
- XFA_ObjectType::Node,
- XFA_Element::Rectangle,
- kPropertyData,
- kAttributeData,
- kName,
- pdfium::MakeUnique<CJX_Rectangle>(this)) {}
+ : CXFA_Box(doc,
+ packet,
+ (XFA_XDPPACKET_Template | XFA_XDPPACKET_Form),
+ XFA_ObjectType::Node,
+ XFA_Element::Rectangle,
+ kPropertyData,
+ kAttributeData,
+ kName,
+ pdfium::MakeUnique<CJX_Rectangle>(this)) {}
CXFA_Rectangle::~CXFA_Rectangle() {}
diff --git a/xfa/fxfa/parser/cxfa_rectangle.h b/xfa/fxfa/parser/cxfa_rectangle.h
index 1cb472053c..85e0a8ad65 100644
--- a/xfa/fxfa/parser/cxfa_rectangle.h
+++ b/xfa/fxfa/parser/cxfa_rectangle.h
@@ -7,9 +7,9 @@
#ifndef XFA_FXFA_PARSER_CXFA_RECTANGLE_H_
#define XFA_FXFA_PARSER_CXFA_RECTANGLE_H_
-#include "xfa/fxfa/parser/cxfa_node.h"
+#include "xfa/fxfa/parser/cxfa_box.h"
-class CXFA_Rectangle : public CXFA_Node {
+class CXFA_Rectangle : public CXFA_Box {
public:
CXFA_Rectangle(CXFA_Document* doc, XFA_PacketType packet);
~CXFA_Rectangle() override;
diff --git a/xfa/fxfa/parser/cxfa_rectangledata.h b/xfa/fxfa/parser/cxfa_rectangledata.h
deleted file mode 100644
index f0abadc3b6..0000000000
--- a/xfa/fxfa/parser/cxfa_rectangledata.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_RECTANGLEDATA_H_
-#define XFA_FXFA_PARSER_CXFA_RECTANGLEDATA_H_
-
-#include "xfa/fxfa/parser/cxfa_boxdata.h"
-
-class CXFA_Node;
-
-class CXFA_RectangleData : public CXFA_BoxData {
- public:
- explicit CXFA_RectangleData(CXFA_Node* pNode) : CXFA_BoxData(pNode) {}
-};
-
-#endif // XFA_FXFA_PARSER_CXFA_RECTANGLEDATA_H_
diff --git a/xfa/fxfa/parser/cxfa_value.cpp b/xfa/fxfa/parser/cxfa_value.cpp
index d4911c56db..d2c92067af 100644
--- a/xfa/fxfa/parser/cxfa_value.cpp
+++ b/xfa/fxfa/parser/cxfa_value.cpp
@@ -8,6 +8,8 @@
#include "fxjs/xfa/cjx_value.h"
#include "third_party/base/ptr_util.h"
+#include "xfa/fxfa/parser/cxfa_arc.h"
+#include "xfa/fxfa/parser/cxfa_rectangle.h"
namespace {
@@ -63,16 +65,16 @@ WideString CXFA_Value::GetChildValueContent() const {
return pNode->JSObject()->TryContent(false, true).value_or(L"");
}
-CXFA_ArcData CXFA_Value::GetArcData() const {
- return CXFA_ArcData(GetNodeItem(XFA_NODEITEM_FirstChild));
+CXFA_Arc* CXFA_Value::GetArc() const {
+ return static_cast<CXFA_Arc*>(GetNodeItem(XFA_NODEITEM_FirstChild));
}
CXFA_LineData CXFA_Value::GetLineData() const {
return CXFA_LineData(GetNodeItem(XFA_NODEITEM_FirstChild));
}
-CXFA_RectangleData CXFA_Value::GetRectangleData() const {
- return CXFA_RectangleData(GetNodeItem(XFA_NODEITEM_FirstChild));
+CXFA_Rectangle* CXFA_Value::GetRectangle() const {
+ return static_cast<CXFA_Rectangle*>(GetNodeItem(XFA_NODEITEM_FirstChild));
}
CXFA_Text* CXFA_Value::GetText() const {
diff --git a/xfa/fxfa/parser/cxfa_value.h b/xfa/fxfa/parser/cxfa_value.h
index f510446d11..5a9e10d086 100644
--- a/xfa/fxfa/parser/cxfa_value.h
+++ b/xfa/fxfa/parser/cxfa_value.h
@@ -8,15 +8,16 @@
#define XFA_FXFA_PARSER_CXFA_VALUE_H_
#include "core/fxcrt/fx_string.h"
-#include "xfa/fxfa/parser/cxfa_arcdata.h"
#include "xfa/fxfa/parser/cxfa_datadata.h"
#include "xfa/fxfa/parser/cxfa_exdatadata.h"
#include "xfa/fxfa/parser/cxfa_imagedata.h"
#include "xfa/fxfa/parser/cxfa_linedata.h"
#include "xfa/fxfa/parser/cxfa_node.h"
-#include "xfa/fxfa/parser/cxfa_rectangledata.h"
#include "xfa/fxfa/parser/cxfa_text.h"
+class CXFA_Arc;
+class CXFA_Rectangle;
+
class CXFA_Value : public CXFA_Node {
public:
CXFA_Value(CXFA_Document* doc, XFA_PacketType packet);
@@ -24,9 +25,9 @@ class CXFA_Value : public CXFA_Node {
XFA_Element GetChildValueClassID() const;
WideString GetChildValueContent() const;
- CXFA_ArcData GetArcData() const;
+ CXFA_Arc* GetArc() const;
CXFA_LineData GetLineData() const;
- CXFA_RectangleData GetRectangleData() const;
+ CXFA_Rectangle* GetRectangle() const;
CXFA_Text* GetText() const;
CXFA_ExDataData GetExData() const;
CXFA_ImageData GetImageData() const;
diff --git a/xfa/fxfa/parser/cxfa_widgetdata.cpp b/xfa/fxfa/parser/cxfa_widgetdata.cpp
index 0f31fbafaa..8fef4b4418 100644
--- a/xfa/fxfa/parser/cxfa_widgetdata.cpp
+++ b/xfa/fxfa/parser/cxfa_widgetdata.cpp
@@ -260,9 +260,9 @@ int32_t CXFA_WidgetData::GetRotate() const {
return degrees ? XFA_MapRotation(*degrees) / 90 * 90 : 0;
}
-CXFA_BorderData CXFA_WidgetData::GetBorderData(bool bModified) {
- return CXFA_BorderData(m_pNode->JSObject()->GetProperty<CXFA_Border>(
- 0, XFA_Element::Border, bModified));
+CXFA_Border* CXFA_WidgetData::GetBorder(bool bModified) {
+ return m_pNode->JSObject()->GetProperty<CXFA_Border>(0, XFA_Element::Border,
+ bModified);
}
CXFA_CaptionData CXFA_WidgetData::GetCaptionData() {
@@ -363,12 +363,11 @@ pdfium::Optional<float> CXFA_WidgetData::TryMaxHeight() {
return TryMeasureAsFloat(XFA_Attribute::MaxH);
}
-CXFA_BorderData CXFA_WidgetData::GetUIBorderData() {
+CXFA_Border* CXFA_WidgetData::GetUIBorder() {
CXFA_Node* pUIChild = GetUIChild();
- return CXFA_BorderData(pUIChild
- ? pUIChild->JSObject()->GetProperty<CXFA_Border>(
- 0, XFA_Element::Border, false)
- : nullptr);
+ return pUIChild ? pUIChild->JSObject()->GetProperty<CXFA_Border>(
+ 0, XFA_Element::Border, false)
+ : nullptr;
}
CFX_RectF CXFA_WidgetData::GetUIMargin() {
@@ -382,23 +381,21 @@ CFX_RectF CXFA_WidgetData::GetUIMargin() {
if (!mgUI)
return CFX_RectF();
- CXFA_BorderData borderData = GetUIBorderData();
- if (borderData.HasValidNode() &&
- borderData.GetPresence() != XFA_AttributeEnum::Visible) {
+ CXFA_Border* border = GetUIBorder();
+ if (border && border->GetPresence() != XFA_AttributeEnum::Visible)
return CFX_RectF();
- }
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()) {
+ if (border) {
bool bVisible = false;
float fThickness = 0;
XFA_AttributeEnum iType = XFA_AttributeEnum::Unknown;
- std::tie(iType, bVisible, fThickness) = borderData.Get3DStyle();
+ std::tie(iType, bVisible, fThickness) = border->Get3DStyle();
if (!left || !top || !right || !bottom) {
- std::vector<CXFA_StrokeData> strokes = borderData.GetStrokes();
+ std::vector<CXFA_StrokeData> strokes = border->GetStrokes();
if (!top)
top = GetEdgeThickness(strokes, bVisible, 0);
if (!right)
diff --git a/xfa/fxfa/parser/cxfa_widgetdata.h b/xfa/fxfa/parser/cxfa_widgetdata.h
index e2dbfbfafd..d8dee8a2a3 100644
--- a/xfa/fxfa/parser/cxfa_widgetdata.h
+++ b/xfa/fxfa/parser/cxfa_widgetdata.h
@@ -15,7 +15,6 @@
#include "core/fxcrt/fx_system.h"
#include "fxbarcode/BC_Library.h"
#include "xfa/fxfa/parser/cxfa_binddata.h"
-#include "xfa/fxfa/parser/cxfa_borderdata.h"
#include "xfa/fxfa/parser/cxfa_captiondata.h"
#include "xfa/fxfa/parser/cxfa_datadata.h"
#include "xfa/fxfa/parser/cxfa_fontdata.h"
@@ -33,6 +32,7 @@ enum XFA_VALUEPICTURE {
XFA_VALUEPICTURE_DataBind,
};
+class CXFA_Border;
class CXFA_Calculate;
class CXFA_Margin;
class CXFA_Node;
@@ -58,7 +58,7 @@ class CXFA_WidgetData : public CXFA_DataData {
bool IsChoiceListAllowTextEntry();
bool IsMultiLine();
- CXFA_BorderData GetBorderData(bool bModified);
+ CXFA_Border* GetBorder(bool bModified);
CXFA_CaptionData GetCaptionData();
CXFA_FontData GetFontData(bool bModified);
CXFA_Margin* GetMargin();
@@ -67,7 +67,7 @@ class CXFA_WidgetData : public CXFA_DataData {
CXFA_Value* GetFormValue();
CXFA_Calculate* GetCalculate();
CXFA_Validate* GetValidate(bool bModified);
- CXFA_BorderData GetUIBorderData();
+ CXFA_Border* GetUIBorder();
std::vector<CXFA_Node*> GetEventByActivity(XFA_AttributeEnum iActivity,
bool bIsFormReady);