summaryrefslogtreecommitdiff
path: root/xfa
diff options
context:
space:
mode:
Diffstat (limited to 'xfa')
-rw-r--r--xfa/fwl/theme/cfwl_edittp.cpp2
-rw-r--r--xfa/fxfa/cxfa_ffbarcode.cpp2
-rw-r--r--xfa/fxfa/cxfa_ffcheckbutton.cpp8
-rw-r--r--xfa/fxfa/cxfa_fffield.cpp20
-rw-r--r--xfa/fxfa/cxfa_ffimageedit.cpp4
-rw-r--r--xfa/fxfa/cxfa_ffnotify.cpp23
-rw-r--r--xfa/fxfa/cxfa_ffnotify.h4
-rw-r--r--xfa/fxfa/cxfa_ffpageview.cpp6
-rw-r--r--xfa/fxfa/cxfa_ffsignature.cpp2
-rw-r--r--xfa/fxfa/cxfa_fftextedit.cpp14
-rw-r--r--xfa/fxfa/cxfa_fwltheme.cpp11
-rw-r--r--xfa/fxfa/cxfa_textprovider.cpp2
-rw-r--r--xfa/fxfa/cxfa_widgetacc.cpp285
-rw-r--r--xfa/fxfa/cxfa_widgetacc.h8
-rw-r--r--xfa/fxfa/parser/cxfa_node.cpp265
-rw-r--r--xfa/fxfa/parser/cxfa_node.h7
-rw-r--r--xfa/fxfa/parser/xfa_document_datamerger_imp.cpp8
-rw-r--r--xfa/fxfa/parser/xfa_utils.cpp6
18 files changed, 328 insertions, 349 deletions
diff --git a/xfa/fwl/theme/cfwl_edittp.cpp b/xfa/fwl/theme/cfwl_edittp.cpp
index 40e74b2dfb..700d78131f 100644
--- a/xfa/fwl/theme/cfwl_edittp.cpp
+++ b/xfa/fwl/theme/cfwl_edittp.cpp
@@ -25,7 +25,7 @@ void CFWL_EditTP::DrawBackground(CFWL_ThemeBackground* pParams) {
CXFA_FFWidget* pWidget = XFA_ThemeGetOuterWidget(pParams->m_pWidget);
ASSERT(pWidget->GetNode()->IsWidgetReady());
- CXFA_Border* borderUI = pWidget->GetNode()->GetWidgetAcc()->GetUIBorder();
+ CXFA_Border* borderUI = pWidget->GetNode()->GetUIBorder();
FX_ARGB cr = 0xFF000000;
float fWidth = 1.0f;
if (borderUI) {
diff --git a/xfa/fxfa/cxfa_ffbarcode.cpp b/xfa/fxfa/cxfa_ffbarcode.cpp
index 3ed57b9c28..86b06185e4 100644
--- a/xfa/fxfa/cxfa_ffbarcode.cpp
+++ b/xfa/fxfa/cxfa_ffbarcode.cpp
@@ -146,7 +146,7 @@ void CXFA_FFBarcode::RenderWidget(CXFA_Graphics* pGS,
mtRotate.Concat(matrix);
CXFA_FFWidget::RenderWidget(pGS, mtRotate, dwStatus);
- DrawBorder(pGS, m_pNode->GetWidgetAcc()->GetUIBorder(), m_rtUI, mtRotate);
+ DrawBorder(pGS, m_pNode->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 89af82cdac..858cbf4a5e 100644
--- a/xfa/fxfa/cxfa_ffcheckbutton.cpp
+++ b/xfa/fxfa/cxfa_ffcheckbutton.cpp
@@ -173,7 +173,7 @@ bool CXFA_FFCheckButton::PerformLayout() {
m_rtUI.height = fCheckSize;
AddUIMargin(iCapPlacement);
m_rtCheckBox = m_rtUI;
- CXFA_Border* borderUI = m_pNode->GetWidgetAcc()->GetUIBorder();
+ CXFA_Border* borderUI = m_pNode->GetUIBorder();
if (borderUI) {
CXFA_Margin* borderMargin = borderUI->GetMarginIfExists();
if (borderMargin)
@@ -201,7 +201,7 @@ void CXFA_FFCheckButton::CapLeftRightPlacement(
}
void CXFA_FFCheckButton::AddUIMargin(XFA_AttributeEnum iCapPlacement) {
- CFX_RectF rtUIMargin = m_pNode->GetWidgetAcc()->GetUIMargin();
+ CFX_RectF rtUIMargin = m_pNode->GetUIMargin();
m_rtUI.top -= rtUIMargin.top / 2 - rtUIMargin.height / 2;
float fLeftAddRight = rtUIMargin.left + rtUIMargin.width;
@@ -234,8 +234,8 @@ void CXFA_FFCheckButton::RenderWidget(CXFA_Graphics* pGS,
mtRotate.Concat(matrix);
CXFA_FFWidget::RenderWidget(pGS, mtRotate, dwStatus);
- DrawBorderWithFlag(pGS, m_pNode->GetWidgetAcc()->GetUIBorder(), m_rtUI,
- mtRotate, m_pNode->GetWidgetAcc()->IsCheckButtonRound());
+ DrawBorderWithFlag(pGS, m_pNode->GetUIBorder(), m_rtUI, mtRotate,
+ m_pNode->GetWidgetAcc()->IsCheckButtonRound());
RenderCaption(pGS, &mtRotate);
DrawHighlight(pGS, &mtRotate, dwStatus,
m_pNode->GetWidgetAcc()->IsCheckButtonRound());
diff --git a/xfa/fxfa/cxfa_fffield.cpp b/xfa/fxfa/cxfa_fffield.cpp
index cd4359d7eb..c7d54762f5 100644
--- a/xfa/fxfa/cxfa_fffield.cpp
+++ b/xfa/fxfa/cxfa_fffield.cpp
@@ -49,7 +49,7 @@ CFX_RectF CXFA_FFField::GetBBox(uint32_t dwStatus, bool bDrawFocus) {
if (!bDrawFocus)
return CXFA_FFWidget::GetBBox(dwStatus);
- XFA_Element type = m_pNode->GetWidgetAcc()->GetUIType();
+ XFA_Element type = m_pNode->GetUIType();
if (type != XFA_Element::Button && type != XFA_Element::CheckButton &&
type != XFA_Element::ImageEdit && type != XFA_Element::Signature &&
type != XFA_Element::ChoiceList) {
@@ -69,7 +69,7 @@ void CXFA_FFField::RenderWidget(CXFA_Graphics* pGS,
mtRotate.Concat(matrix);
CXFA_FFWidget::RenderWidget(pGS, mtRotate, dwStatus);
- DrawBorder(pGS, m_pNode->GetWidgetAcc()->GetUIBorder(), m_rtUI, mtRotate);
+ DrawBorder(pGS, m_pNode->GetUIBorder(), m_rtUI, mtRotate);
RenderCaption(pGS, &mtRotate);
DrawHighlight(pGS, &mtRotate, dwStatus, false);
@@ -136,7 +136,7 @@ void CXFA_FFField::UnloadWidget() {
}
void CXFA_FFField::SetEditScrollOffset() {
- XFA_Element eType = m_pNode->GetWidgetAcc()->GetUIType();
+ XFA_Element eType = m_pNode->GetUIType();
if (eType != XFA_Element::TextEdit && eType != XFA_Element::NumericEdit &&
eType != XFA_Element::PasswordEdit) {
return;
@@ -144,10 +144,8 @@ void CXFA_FFField::SetEditScrollOffset() {
float fScrollOffset = 0;
CXFA_FFField* pPrev = ToField(GetPrev());
- if (pPrev) {
- CFX_RectF rtMargin = m_pNode->GetWidgetAcc()->GetUIMargin();
- fScrollOffset = -rtMargin.top;
- }
+ if (pPrev)
+ fScrollOffset = -(m_pNode->GetUIMargin().top);
while (pPrev) {
fScrollOffset += pPrev->m_rtUI.height;
@@ -267,7 +265,7 @@ void CXFA_FFField::CapPlacement() {
break;
}
- CXFA_Border* borderUI = m_pNode->GetWidgetAcc()->GetUIBorder();
+ CXFA_Border* borderUI = m_pNode->GetUIBorder();
if (borderUI) {
CXFA_Margin* borderMargin = borderUI->GetMarginIfExists();
if (borderMargin)
@@ -279,7 +277,7 @@ void CXFA_FFField::CapPlacement() {
void CXFA_FFField::CapTopBottomPlacement(const CXFA_Margin* margin,
const CFX_RectF& rtWidget,
XFA_AttributeEnum iCapPlacement) {
- CFX_RectF rtUIMargin = m_pNode->GetWidgetAcc()->GetUIMargin();
+ CFX_RectF rtUIMargin = m_pNode->GetUIMargin();
m_rtCaption.left += rtUIMargin.left;
if (margin) {
XFA_RectWithoutMargin(m_rtCaption, margin);
@@ -305,7 +303,7 @@ void CXFA_FFField::CapTopBottomPlacement(const CXFA_Margin* margin,
void CXFA_FFField::CapLeftRightPlacement(const CXFA_Margin* margin,
const CFX_RectF& rtWidget,
XFA_AttributeEnum iCapPlacement) {
- CFX_RectF rtUIMargin = m_pNode->GetWidgetAcc()->GetUIMargin();
+ CFX_RectF rtUIMargin = m_pNode->GetUIMargin();
m_rtCaption.top += rtUIMargin.top;
m_rtCaption.height -= rtUIMargin.top;
if (margin) {
@@ -336,7 +334,7 @@ void CXFA_FFField::UpdateFWL() {
}
uint32_t CXFA_FFField::UpdateUIProperty() {
- CXFA_Node* pUiNode = m_pNode->GetWidgetAcc()->GetUIChild();
+ CXFA_Node* pUiNode = m_pNode->GetUIChild();
if (pUiNode && pUiNode->GetElementType() == XFA_Element::DefaultUi)
return FWL_STYLEEXT_EDT_ReadOnly;
return 0;
diff --git a/xfa/fxfa/cxfa_ffimageedit.cpp b/xfa/fxfa/cxfa_ffimageedit.cpp
index 0e97559e6a..229fe9219e 100644
--- a/xfa/fxfa/cxfa_ffimageedit.cpp
+++ b/xfa/fxfa/cxfa_ffimageedit.cpp
@@ -65,7 +65,7 @@ void CXFA_FFImageEdit::RenderWidget(CXFA_Graphics* pGS,
mtRotate.Concat(matrix);
CXFA_FFWidget::RenderWidget(pGS, mtRotate, dwStatus);
- DrawBorder(pGS, m_pNode->GetWidgetAcc()->GetUIBorder(), m_rtUI, mtRotate);
+ DrawBorder(pGS, m_pNode->GetUIBorder(), m_rtUI, mtRotate);
RenderCaption(pGS, &mtRotate);
RetainPtr<CFX_DIBitmap> pDIBitmap =
m_pNode->GetWidgetAcc()->GetImageEditImage();
@@ -117,7 +117,7 @@ void CXFA_FFImageEdit::SetFWLRect() {
if (!m_pNormalWidget)
return;
- CFX_RectF rtUIMargin = m_pNode->GetWidgetAcc()->GetUIMargin();
+ CFX_RectF rtUIMargin = m_pNode->GetUIMargin();
CFX_RectF rtImage(m_rtUI);
rtImage.Deflate(rtUIMargin.left, rtUIMargin.top, rtUIMargin.width,
rtUIMargin.height);
diff --git a/xfa/fxfa/cxfa_ffnotify.cpp b/xfa/fxfa/cxfa_ffnotify.cpp
index 301a8ecf04..7d9f1c6fa5 100644
--- a/xfa/fxfa/cxfa_ffnotify.cpp
+++ b/xfa/fxfa/cxfa_ffnotify.cpp
@@ -63,18 +63,17 @@ void CXFA_FFNotify::OnPageEvent(CXFA_ContainerLayoutItem* pSender,
pDocView->OnPageEvent(pSender, dwEvent);
}
-void CXFA_FFNotify::OnWidgetListItemAdded(CXFA_WidgetAcc* pSender,
+void CXFA_FFNotify::OnWidgetListItemAdded(CXFA_Node* pSender,
const wchar_t* pLabel,
const wchar_t* pValue,
int32_t iIndex) {
if (pSender->GetUIType() != XFA_Element::ChoiceList)
return;
- CXFA_FFWidget* pWidget =
- m_pDoc->GetDocView()->GetWidgetForNode(pSender->GetNode());
- for (; pWidget; pWidget = pSender->GetNextWidget(pWidget)) {
+ CXFA_FFWidget* pWidget = m_pDoc->GetDocView()->GetWidgetForNode(pSender);
+ for (; pWidget; pWidget = pSender->GetWidgetAcc()->GetNextWidget(pWidget)) {
if (pWidget->IsLoaded()) {
- if (pSender->IsListBox())
+ if (pSender->GetWidgetAcc()->IsListBox())
ToListBox(pWidget)->InsertItem(pLabel, iIndex);
else
ToComboBox(pWidget)->InsertItem(pLabel, iIndex);
@@ -82,16 +81,15 @@ void CXFA_FFNotify::OnWidgetListItemAdded(CXFA_WidgetAcc* pSender,
}
}
-void CXFA_FFNotify::OnWidgetListItemRemoved(CXFA_WidgetAcc* pSender,
+void CXFA_FFNotify::OnWidgetListItemRemoved(CXFA_Node* pSender,
int32_t iIndex) {
if (pSender->GetUIType() != XFA_Element::ChoiceList)
return;
- CXFA_FFWidget* pWidget =
- m_pDoc->GetDocView()->GetWidgetForNode(pSender->GetNode());
- for (; pWidget; pWidget = pSender->GetNextWidget(pWidget)) {
+ CXFA_FFWidget* pWidget = m_pDoc->GetDocView()->GetWidgetForNode(pSender);
+ for (; pWidget; pWidget = pSender->GetWidgetAcc()->GetNextWidget(pWidget)) {
if (pWidget->IsLoaded()) {
- if (pSender->IsListBox())
+ if (pSender->GetWidgetAcc()->IsListBox())
ToListBox(pWidget)->DeleteItem(iIndex);
else
ToComboBox(pWidget)->DeleteItem(iIndex);
@@ -121,7 +119,7 @@ CXFA_ContentLayoutItem* CXFA_FFNotify::OnCreateContentLayoutItem(
return new CXFA_ContentLayoutItem(pNode);
CXFA_FFWidget* pWidget;
- switch (pNode->GetWidgetAcc()->GetUIType()) {
+ switch (pNode->GetUIType()) {
case XFA_Element::Barcode:
pWidget = new CXFA_FFBarcode(pNode);
break;
@@ -272,8 +270,7 @@ CXFA_FFWidget* CXFA_FFNotify::GetHWidget(CXFA_LayoutItem* pLayoutItem) {
}
void CXFA_FFNotify::OpenDropDownList(CXFA_FFWidget* hWidget) {
- if (hWidget->GetNode()->GetWidgetAcc()->GetUIType() !=
- XFA_Element::ChoiceList)
+ if (hWidget->GetNode()->GetUIType() != XFA_Element::ChoiceList)
return;
CXFA_FFDocView* pDocView = m_pDoc->GetDocView();
diff --git a/xfa/fxfa/cxfa_ffnotify.h b/xfa/fxfa/cxfa_ffnotify.h
index 924a060210..4086b0adb3 100644
--- a/xfa/fxfa/cxfa_ffnotify.h
+++ b/xfa/fxfa/cxfa_ffnotify.h
@@ -21,11 +21,11 @@ class CXFA_FFNotify {
void OnPageEvent(CXFA_ContainerLayoutItem* pSender, uint32_t dwEvent);
- void OnWidgetListItemAdded(CXFA_WidgetAcc* pSender,
+ void OnWidgetListItemAdded(CXFA_Node* pSender,
const wchar_t* pLabel,
const wchar_t* pValue,
int32_t iIndex);
- void OnWidgetListItemRemoved(CXFA_WidgetAcc* pSender, int32_t iIndex);
+ void OnWidgetListItemRemoved(CXFA_Node* pSender, int32_t iIndex);
// Node events
void OnNodeReady(CXFA_Node* pNode);
diff --git a/xfa/fxfa/cxfa_ffpageview.cpp b/xfa/fxfa/cxfa_ffpageview.cpp
index fe1fbb517f..72fe3f4b88 100644
--- a/xfa/fxfa/cxfa_ffpageview.cpp
+++ b/xfa/fxfa/cxfa_ffpageview.cpp
@@ -344,8 +344,8 @@ void CXFA_FFTabOrderPageWidgetIterator::CreateTabOrderWidgetArray() {
nWidgetCount) {
if (!pdfium::ContainsValue(m_TabOrderWidgetArray, hWidget)) {
m_TabOrderWidgetArray.push_back(hWidget);
- CXFA_WidgetAcc* pWidgetAcc = hWidget->GetNode()->GetWidgetAcc();
- if (pWidgetAcc->GetUIType() == XFA_Element::ExclGroup) {
+ CXFA_Node* pNode = hWidget->GetNode();
+ if (pNode->GetUIType() == XFA_Element::ExclGroup) {
auto it = std::find(SpaceOrderWidgetArray.begin(),
SpaceOrderWidgetArray.end(), hWidget);
int32_t iWidgetIndex = it != SpaceOrderWidgetArray.end()
@@ -354,7 +354,7 @@ void CXFA_FFTabOrderPageWidgetIterator::CreateTabOrderWidgetArray() {
while (true) {
CXFA_FFWidget* radio =
SpaceOrderWidgetArray[iWidgetIndex % nWidgetCount];
- if (radio->GetNode()->GetExclGroupIfExists() != pWidgetAcc->GetNode())
+ if (radio->GetNode()->GetExclGroupIfExists() != pNode)
break;
if (!pdfium::ContainsValue(m_TabOrderWidgetArray, hWidget))
m_TabOrderWidgetArray.push_back(radio);
diff --git a/xfa/fxfa/cxfa_ffsignature.cpp b/xfa/fxfa/cxfa_ffsignature.cpp
index 6e56b38ad1..6911facce1 100644
--- a/xfa/fxfa/cxfa_ffsignature.cpp
+++ b/xfa/fxfa/cxfa_ffsignature.cpp
@@ -31,7 +31,7 @@ void CXFA_FFSignature::RenderWidget(CXFA_Graphics* pGS,
CXFA_FFWidget::RenderWidget(pGS, mtRotate, dwStatus);
- DrawBorder(pGS, m_pNode->GetWidgetAcc()->GetUIBorder(), m_rtUI, mtRotate);
+ DrawBorder(pGS, m_pNode->GetUIBorder(), m_rtUI, mtRotate);
RenderCaption(pGS, &mtRotate);
DrawHighlight(pGS, &mtRotate, dwStatus, false);
}
diff --git a/xfa/fxfa/cxfa_fftextedit.cpp b/xfa/fxfa/cxfa_fftextedit.cpp
index fad9a9b37a..19405d2d2a 100644
--- a/xfa/fxfa/cxfa_fftextedit.cpp
+++ b/xfa/fxfa/cxfa_fftextedit.cpp
@@ -193,15 +193,14 @@ bool CXFA_FFTextEdit::CommitData() {
}
void CXFA_FFTextEdit::ValidateNumberField(const WideString& wsText) {
- CXFA_WidgetAcc* pAcc = GetNode()->GetWidgetAcc();
- if (!pAcc || pAcc->GetUIType() != XFA_Element::NumericEdit)
+ if (GetNode()->GetUIType() != XFA_Element::NumericEdit)
return;
IXFA_AppProvider* pAppProvider = GetApp()->GetAppProvider();
if (!pAppProvider)
return;
- WideString wsSomField = pAcc->GetNode()->GetSOMExpression();
+ WideString wsSomField = GetNode()->GetSOMExpression();
pAppProvider->MsgBox(WideString::Format(L"%ls can not contain %ls",
wsText.c_str(), wsSomField.c_str()),
pAppProvider->GetAppTitle(), XFA_MBICON_Error,
@@ -260,7 +259,7 @@ bool CXFA_FFTextEdit::UpdateFWLData() {
eType = XFA_VALUEPICTURE_Edit;
bool bUpdate = false;
- if (m_pNode->GetWidgetAcc()->GetUIType() == XFA_Element::TextEdit &&
+ if (m_pNode->GetUIType() == XFA_Element::TextEdit &&
!m_pNode->GetWidgetAcc()->GetNumberOfCells()) {
XFA_Element elementType;
int32_t iMaxChars;
@@ -271,7 +270,7 @@ bool CXFA_FFTextEdit::UpdateFWLData() {
pEdit->SetLimit(iMaxChars);
bUpdate = true;
}
- } else if (m_pNode->GetWidgetAcc()->GetUIType() == XFA_Element::Barcode) {
+ } else if (m_pNode->GetUIType() == XFA_Element::Barcode) {
int32_t nDataLen = 0;
if (eType == XFA_VALUEPICTURE_Edit)
nDataLen = m_pNode->GetBarcodeAttribute_DataLength().value_or(0);
@@ -302,7 +301,7 @@ void CXFA_FFTextEdit::OnTextChanged(CFWL_Widget* pWidget,
eParam.m_pTarget = m_pNode->GetWidgetAcc();
eParam.m_wsPrevText = wsPrevText;
CFWL_Edit* pEdit = static_cast<CFWL_Edit*>(m_pNormalWidget.get());
- if (m_pNode->GetWidgetAcc()->GetUIType() == XFA_Element::DateTimeEdit) {
+ if (m_pNode->GetUIType() == XFA_Element::DateTimeEdit) {
CFWL_DateTimePicker* pDateTime = (CFWL_DateTimePicker*)pEdit;
eParam.m_wsNewText = pDateTime->GetEditText();
if (pDateTime->HasSelection()) {
@@ -326,8 +325,7 @@ void CXFA_FFTextEdit::OnTextFull(CFWL_Widget* pWidget) {
}
bool CXFA_FFTextEdit::CheckWord(const ByteStringView& sWord) {
- return sWord.IsEmpty() ||
- m_pNode->GetWidgetAcc()->GetUIType() != XFA_Element::TextEdit;
+ return sWord.IsEmpty() || m_pNode->GetUIType() != XFA_Element::TextEdit;
}
void CXFA_FFTextEdit::OnProcessMessage(CFWL_Message* pMessage) {
diff --git a/xfa/fxfa/cxfa_fwltheme.cpp b/xfa/fxfa/cxfa_fwltheme.cpp
index 920968269f..c7c521ea66 100644
--- a/xfa/fxfa/cxfa_fwltheme.cpp
+++ b/xfa/fxfa/cxfa_fwltheme.cpp
@@ -147,18 +147,17 @@ void CXFA_FWLTheme::DrawText(CFWL_ThemeText* pParams) {
}
CFX_RectF CXFA_FWLTheme::GetUIMargin(CFWL_ThemePart* pThemePart) const {
- CFX_RectF rect;
CXFA_FFWidget* pWidget = XFA_ThemeGetOuterWidget(pThemePart->m_pWidget);
if (!pWidget)
- return rect;
+ return CFX_RectF();
CXFA_LayoutItem* pItem = pWidget;
- CXFA_WidgetAcc* pWidgetAcc = pWidget->GetNode()->GetWidgetAcc();
- rect = pWidgetAcc->GetUIMargin();
- CXFA_Para* para = pWidgetAcc->GetNode()->GetParaIfExists();
+ CXFA_Node* pNode = pWidget->GetNode();
+ CFX_RectF rect = pNode->GetUIMargin();
+ CXFA_Para* para = pNode->GetParaIfExists();
if (para) {
rect.left += para->GetMarginLeft();
- if (pWidgetAcc->IsMultiLine())
+ if (pNode->GetWidgetAcc()->IsMultiLine())
rect.width += para->GetMarginRight();
}
if (!pItem->GetPrev()) {
diff --git a/xfa/fxfa/cxfa_textprovider.cpp b/xfa/fxfa/cxfa_textprovider.cpp
index a2da41ca40..6e5db65b57 100644
--- a/xfa/fxfa/cxfa_textprovider.cpp
+++ b/xfa/fxfa/cxfa_textprovider.cpp
@@ -136,7 +136,7 @@ CXFA_Font* CXFA_TextProvider::GetFontIfExists() {
}
bool CXFA_TextProvider::IsCheckButtonAndAutoWidth() {
- XFA_Element eType = m_pWidgetAcc->GetUIType();
+ XFA_Element eType = m_pWidgetAcc->GetNode()->GetUIType();
if (eType != XFA_Element::CheckButton)
return false;
return !m_pWidgetAcc->GetNode()->TryWidth();
diff --git a/xfa/fxfa/cxfa_widgetacc.cpp b/xfa/fxfa/cxfa_widgetacc.cpp
index b7b51ba03b..49ccade894 100644
--- a/xfa/fxfa/cxfa_widgetacc.cpp
+++ b/xfa/fxfa/cxfa_widgetacc.cpp
@@ -319,21 +319,6 @@ class CXFA_ImageEditData : public CXFA_FieldLayoutData {
int32_t m_iImageYDpi;
};
-float GetEdgeThickness(const std::vector<CXFA_Stroke*>& strokes,
- bool b3DStyle,
- int32_t nIndex) {
- float fThickness = 0;
-
- CXFA_Stroke* stroke = strokes[nIndex * 2 + 1];
- if (stroke->IsVisible()) {
- if (nIndex == 0)
- fThickness += 2.5f;
-
- fThickness += stroke->GetThickness() * (b3DStyle ? 4 : 2);
- }
- return fThickness;
-}
-
bool SplitDateTime(const WideString& wsDateTime,
WideString& wsDate,
WideString& wsTime) {
@@ -361,170 +346,18 @@ bool SplitDateTime(const WideString& wsDateTime,
return true;
}
-std::pair<XFA_Element, CXFA_Node*> CreateUIChild(CXFA_Node* pNode) {
- XFA_Element eType = pNode->GetElementType();
- XFA_Element eWidgetType = eType;
- if (eType != XFA_Element::Field && eType != XFA_Element::Draw)
- return {eWidgetType, nullptr};
-
- eWidgetType = XFA_Element::Unknown;
- XFA_Element eUIType = XFA_Element::Unknown;
- auto* defValue =
- pNode->JSObject()->GetOrCreateProperty<CXFA_Value>(0, XFA_Element::Value);
- XFA_Element eValueType =
- defValue ? defValue->GetChildValueClassID() : XFA_Element::Unknown;
- switch (eValueType) {
- case XFA_Element::Boolean:
- eUIType = XFA_Element::CheckButton;
- break;
- case XFA_Element::Integer:
- case XFA_Element::Decimal:
- case XFA_Element::Float:
- eUIType = XFA_Element::NumericEdit;
- break;
- case XFA_Element::ExData:
- case XFA_Element::Text:
- eUIType = XFA_Element::TextEdit;
- eWidgetType = XFA_Element::Text;
- break;
- case XFA_Element::Date:
- case XFA_Element::Time:
- case XFA_Element::DateTime:
- eUIType = XFA_Element::DateTimeEdit;
- break;
- case XFA_Element::Image:
- eUIType = XFA_Element::ImageEdit;
- eWidgetType = XFA_Element::Image;
- break;
- case XFA_Element::Arc:
- case XFA_Element::Line:
- case XFA_Element::Rectangle:
- eUIType = XFA_Element::DefaultUi;
- eWidgetType = eValueType;
- break;
- default:
- break;
- }
-
- CXFA_Node* pUIChild = nullptr;
- CXFA_Ui* pUI =
- pNode->JSObject()->GetOrCreateProperty<CXFA_Ui>(0, XFA_Element::Ui);
- CXFA_Node* pChild = pUI ? pUI->GetFirstChild() : nullptr;
- for (; pChild; pChild = pChild->GetNextSibling()) {
- XFA_Element eChildType = pChild->GetElementType();
- if (eChildType == XFA_Element::Extras ||
- eChildType == XFA_Element::Picture) {
- continue;
- }
-
- auto node = CXFA_Node::Create(pChild->GetDocument(), XFA_Element::Ui,
- XFA_PacketType::Form);
- if (node && node->HasPropertyFlags(eChildType, XFA_PROPERTYFLAG_OneOf)) {
- pUIChild = pChild;
- break;
- }
- }
-
- if (eType == XFA_Element::Draw) {
- XFA_Element eDraw =
- pUIChild ? pUIChild->GetElementType() : XFA_Element::Unknown;
- switch (eDraw) {
- case XFA_Element::TextEdit:
- eWidgetType = XFA_Element::Text;
- break;
- case XFA_Element::ImageEdit:
- eWidgetType = XFA_Element::Image;
- break;
- default:
- eWidgetType = eWidgetType == XFA_Element::Unknown ? XFA_Element::Text
- : eWidgetType;
- break;
- }
- } else {
- if (pUIChild && pUIChild->GetElementType() == XFA_Element::DefaultUi) {
- eWidgetType = XFA_Element::TextEdit;
- } else {
- eWidgetType =
- pUIChild ? pUIChild->GetElementType()
- : (eUIType == XFA_Element::Unknown ? XFA_Element::TextEdit
- : eUIType);
- }
- }
-
- if (!pUIChild) {
- if (eUIType == XFA_Element::Unknown) {
- eUIType = XFA_Element::TextEdit;
- if (defValue) {
- defValue->JSObject()->GetOrCreateProperty<CXFA_Text>(0,
- XFA_Element::Text);
- }
- }
- return {eWidgetType,
- pUI ? pUI->JSObject()->GetOrCreateProperty<CXFA_Node>(0, eUIType)
- : nullptr};
- }
-
- if (eUIType != XFA_Element::Unknown)
- return {eWidgetType, pUIChild};
-
- switch (pUIChild->GetElementType()) {
- case XFA_Element::CheckButton: {
- eValueType = XFA_Element::Text;
- if (CXFA_Items* pItems =
- pNode->GetChild<CXFA_Items>(0, XFA_Element::Items, false)) {
- if (CXFA_Node* pItem =
- pItems->GetChild<CXFA_Node>(0, XFA_Element::Unknown, false)) {
- eValueType = pItem->GetElementType();
- }
- }
- break;
- }
- case XFA_Element::DateTimeEdit:
- eValueType = XFA_Element::DateTime;
- break;
- case XFA_Element::ImageEdit:
- eValueType = XFA_Element::Image;
- break;
- case XFA_Element::NumericEdit:
- eValueType = XFA_Element::Float;
- break;
- case XFA_Element::ChoiceList: {
- eValueType = (pUIChild->JSObject()->GetEnum(XFA_Attribute::Open) ==
- XFA_AttributeEnum::MultiSelect)
- ? XFA_Element::ExData
- : XFA_Element::Text;
- break;
- }
- case XFA_Element::Barcode:
- case XFA_Element::Button:
- case XFA_Element::PasswordEdit:
- case XFA_Element::Signature:
- case XFA_Element::TextEdit:
- default:
- eValueType = XFA_Element::Text;
- break;
- }
- if (defValue)
- defValue->JSObject()->GetOrCreateProperty<CXFA_Node>(0, eValueType);
-
- return {eWidgetType, pUIChild};
-}
-
} // namespace
CXFA_WidgetAcc::CXFA_WidgetAcc(CXFA_Node* pNode)
: m_bIsNull(true),
m_bPreNull(true),
- m_pUiChildNode(nullptr),
- m_eUIType(XFA_Element::Unknown),
m_pNode(pNode) {}
CXFA_WidgetAcc::~CXFA_WidgetAcc() = default;
void CXFA_WidgetAcc::ResetData() {
WideString wsValue;
- XFA_Element eUIType = GetUIType();
- switch (eUIType) {
+ switch (m_pNode->GetUIType()) {
case XFA_Element::ImageEdit: {
CXFA_Value* imageValue = m_pNode->GetDefaultValueIfExists();
CXFA_Image* image = imageValue ? imageValue->GetImageIfExists() : nullptr;
@@ -627,7 +460,8 @@ void CXFA_WidgetAcc::UpdateUIDisplay(CXFA_FFDocView* docView,
CXFA_FFWidget* pWidget = docView->GetWidgetForNode(m_pNode);
for (; pWidget; pWidget = GetNextWidget(pWidget)) {
if (pWidget == pExcept || !pWidget->IsLoaded() ||
- (GetUIType() != XFA_Element::CheckButton && pWidget->IsFocused())) {
+ (m_pNode->GetUIType() != XFA_Element::CheckButton &&
+ pWidget->IsFocused())) {
continue;
}
pWidget->UpdateFWLData();
@@ -642,7 +476,7 @@ void CXFA_WidgetAcc::CalcCaptionSize(CXFA_FFDoc* doc, CFX_SizeF& szCap) {
LoadCaption(doc);
- XFA_Element eUIType = GetUIType();
+ XFA_Element eUIType = m_pNode->GetUIType();
XFA_AttributeEnum iCapPlacement = caption->GetPlacementType();
float fCapReserve = caption->GetReserve();
const bool bVert = iCapPlacement == XFA_AttributeEnum::Top ||
@@ -699,7 +533,7 @@ bool CXFA_WidgetAcc::CalculateFieldAutoSize(CXFA_FFDoc* doc, CFX_SizeF& size) {
CFX_SizeF szCap;
CalcCaptionSize(doc, szCap);
- CFX_RectF rtUIMargin = GetUIMargin();
+ CFX_RectF rtUIMargin = m_pNode->GetUIMargin();
size.width += rtUIMargin.left + rtUIMargin.width;
size.height += rtUIMargin.top + rtUIMargin.height;
if (szCap.width > 0 && szCap.height > 0) {
@@ -790,7 +624,7 @@ void CXFA_WidgetAcc::CalculateTextContentSize(CXFA_FFDoc* doc,
FDE_TextStyle dwStyles;
dwStyles.last_line_height_ = true;
- if (GetUIType() == XFA_Element::TextEdit && IsMultiLine())
+ if (m_pNode->GetUIType() == XFA_Element::TextEdit && IsMultiLine())
dwStyles.line_wrap_ = true;
pTextOut->SetStyles(dwStyles);
@@ -820,7 +654,7 @@ bool CXFA_WidgetAcc::CalculateTextEditAutoSize(CXFA_FFDoc* doc,
break;
}
}
- CFX_RectF rtUIMargin = GetUIMargin();
+ CFX_RectF rtUIMargin = m_pNode->GetUIMargin();
size.width -= rtUIMargin.left + rtUIMargin.width;
CXFA_Margin* margin = m_pNode->GetMarginIfExists();
if (margin)
@@ -1009,7 +843,7 @@ void CXFA_WidgetAcc::StartWidgetLayout(CXFA_FFDoc* doc,
float& fCalcHeight) {
InitLayoutData();
- XFA_Element eUIType = GetUIType();
+ XFA_Element eUIType = m_pNode->GetUIType();
if (eUIType == XFA_Element::Text) {
m_pLayoutData->m_fWidgetHeight = m_pNode->TryHeight().value_or(-1);
StartTextLayout(doc, fCalcWidth, fCalcHeight);
@@ -1095,7 +929,7 @@ void CXFA_WidgetAcc::CalculateAccWidthAndHeight(CXFA_FFDoc* doc,
bool CXFA_WidgetAcc::FindSplitPos(CXFA_FFDocView* docView,
int32_t iBlockIndex,
float& fCalcHeight) {
- XFA_Element eUIType = GetUIType();
+ XFA_Element eUIType = m_pNode->GetUIType();
if (eUIType == XFA_Element::Subform)
return false;
@@ -1115,7 +949,7 @@ bool CXFA_WidgetAcc::FindSplitPos(CXFA_FFDocView* docView,
fBottomInset = margin->GetBottomInset();
}
- CFX_RectF rtUIMargin = GetUIMargin();
+ CFX_RectF rtUIMargin = m_pNode->GetUIMargin();
fTopInset += rtUIMargin.top;
fBottomInset += rtUIMargin.width;
}
@@ -1326,7 +1160,7 @@ void CXFA_WidgetAcc::InitLayoutData() {
if (m_pLayoutData)
return;
- switch (GetUIType()) {
+ switch (m_pNode->GetUIType()) {
case XFA_Element::Text:
m_pLayoutData = pdfium::MakeUnique<CXFA_TextLayoutData>();
return;
@@ -1458,17 +1292,6 @@ RetainPtr<CFGAS_GEFont> CXFA_WidgetAcc::GetFDEFont(CXFA_FFDoc* doc) {
dwFontStyle);
}
-CXFA_Node* CXFA_WidgetAcc::GetUIChild() {
- if (m_eUIType == XFA_Element::Unknown)
- std::tie(m_eUIType, m_pUiChildNode) = CreateUIChild(m_pNode);
- return m_pUiChildNode;
-}
-
-XFA_Element CXFA_WidgetAcc::GetUIType() {
- GetUIChild();
- return m_eUIType;
-}
-
bool CXFA_WidgetAcc::IsOpenAccess() const {
return m_pNode && m_pNode->IsOpenAccess();
}
@@ -1497,55 +1320,8 @@ std::vector<CXFA_Event*> CXFA_WidgetAcc::GetEventByActivity(
return events;
}
-CXFA_Border* CXFA_WidgetAcc::GetUIBorder() {
- CXFA_Node* pUIChild = GetUIChild();
- return pUIChild ? pUIChild->JSObject()->GetProperty<CXFA_Border>(
- 0, XFA_Element::Border)
- : nullptr;
-}
-
-CFX_RectF CXFA_WidgetAcc::GetUIMargin() {
- CXFA_Node* pUIChild = GetUIChild();
- CXFA_Margin* mgUI = nullptr;
- if (pUIChild) {
- mgUI =
- pUIChild->JSObject()->GetProperty<CXFA_Margin>(0, XFA_Element::Margin);
- }
-
- if (!mgUI)
- return CFX_RectF();
-
- CXFA_Border* border = GetUIBorder();
- if (border && border->GetPresence() != XFA_AttributeEnum::Visible)
- return CFX_RectF();
-
- Optional<float> left = mgUI->TryLeftInset();
- Optional<float> top = mgUI->TryTopInset();
- Optional<float> right = mgUI->TryRightInset();
- Optional<float> bottom = mgUI->TryBottomInset();
- if (border) {
- bool bVisible = false;
- float fThickness = 0;
- XFA_AttributeEnum iType = XFA_AttributeEnum::Unknown;
- std::tie(iType, bVisible, fThickness) = border->Get3DStyle();
- if (!left || !top || !right || !bottom) {
- std::vector<CXFA_Stroke*> strokes = border->GetStrokes();
- if (!top)
- top = GetEdgeThickness(strokes, bVisible, 0);
- if (!right)
- right = GetEdgeThickness(strokes, bVisible, 1);
- if (!bottom)
- bottom = GetEdgeThickness(strokes, bVisible, 2);
- if (!left)
- left = GetEdgeThickness(strokes, bVisible, 3);
- }
- }
- return CFX_RectF(left.value_or(0.0), top.value_or(0.0), right.value_or(0.0),
- bottom.value_or(0.0));
-}
-
XFA_AttributeEnum CXFA_WidgetAcc::GetButtonHighlight() {
- CXFA_Node* pUIChild = GetUIChild();
+ CXFA_Node* pUIChild = m_pNode->GetUIChild();
if (pUIChild)
return pUIChild->JSObject()->GetEnum(XFA_Attribute::Highlight);
return XFA_AttributeEnum::Inverted;
@@ -1580,7 +1356,7 @@ bool CXFA_WidgetAcc::HasButtonDown() const {
}
bool CXFA_WidgetAcc::IsCheckButtonRound() {
- CXFA_Node* pUIChild = GetUIChild();
+ CXFA_Node* pUIChild = m_pNode->GetUIChild();
if (pUIChild)
return pUIChild->JSObject()->GetEnum(XFA_Attribute::Shape) ==
XFA_AttributeEnum::Round;
@@ -1588,7 +1364,7 @@ bool CXFA_WidgetAcc::IsCheckButtonRound() {
}
XFA_AttributeEnum CXFA_WidgetAcc::GetCheckButtonMark() {
- CXFA_Node* pUIChild = GetUIChild();
+ CXFA_Node* pUIChild = m_pNode->GetUIChild();
if (pUIChild)
return pUIChild->JSObject()->GetEnum(XFA_Attribute::Mark);
return XFA_AttributeEnum::Default;
@@ -1600,7 +1376,7 @@ bool CXFA_WidgetAcc::IsRadioButton() {
}
float CXFA_WidgetAcc::GetCheckButtonSize() {
- CXFA_Node* pUIChild = GetUIChild();
+ CXFA_Node* pUIChild = m_pNode->GetUIChild();
if (pUIChild) {
return pUIChild->JSObject()
->GetMeasure(XFA_Attribute::Size)
@@ -1610,7 +1386,7 @@ float CXFA_WidgetAcc::GetCheckButtonSize() {
}
bool CXFA_WidgetAcc::IsAllowNeutral() {
- CXFA_Node* pUIChild = GetUIChild();
+ CXFA_Node* pUIChild = m_pNode->GetUIChild();
return pUIChild &&
pUIChild->JSObject()->GetBoolean(XFA_Attribute::AllowNeutral);
}
@@ -1797,7 +1573,7 @@ CXFA_Node* CXFA_WidgetAcc::GetExclGroupNextMember(CXFA_Node* pNode) {
}
bool CXFA_WidgetAcc::IsChoiceListCommitOnSelect() {
- CXFA_Node* pUIChild = GetUIChild();
+ CXFA_Node* pUIChild = m_pNode->GetUIChild();
if (pUIChild) {
return pUIChild->JSObject()->GetEnum(XFA_Attribute::CommitOn) ==
XFA_AttributeEnum::Select;
@@ -1806,12 +1582,12 @@ bool CXFA_WidgetAcc::IsChoiceListCommitOnSelect() {
}
bool CXFA_WidgetAcc::IsChoiceListAllowTextEntry() {
- CXFA_Node* pUIChild = GetUIChild();
+ CXFA_Node* pUIChild = m_pNode->GetUIChild();
return pUIChild && pUIChild->JSObject()->GetBoolean(XFA_Attribute::TextEntry);
}
bool CXFA_WidgetAcc::IsChoiceListMultiSelect() {
- CXFA_Node* pUIChild = GetUIChild();
+ CXFA_Node* pUIChild = m_pNode->GetUIChild();
if (pUIChild) {
return pUIChild->JSObject()->GetEnum(XFA_Attribute::Open) ==
XFA_AttributeEnum::MultiSelect;
@@ -1820,7 +1596,7 @@ bool CXFA_WidgetAcc::IsChoiceListMultiSelect() {
}
bool CXFA_WidgetAcc::IsListBox() {
- CXFA_Node* pUIChild = GetUIChild();
+ CXFA_Node* pUIChild = m_pNode->GetUIChild();
if (!pUIChild)
return false;
@@ -2129,7 +1905,7 @@ void CXFA_WidgetAcc::InsertItem(const WideString& wsLabel,
return;
m_pNode->GetDocument()->GetNotify()->OnWidgetListItemAdded(
- this, wsLabel.c_str(), wsValue.c_str(), nIndex);
+ m_pNode, wsLabel.c_str(), wsValue.c_str(), nIndex);
}
void CXFA_WidgetAcc::GetItemLabel(const WideStringView& wsValue,
@@ -2251,12 +2027,13 @@ bool CXFA_WidgetAcc::DeleteItem(int32_t nIndex,
}
}
if (bNotify)
- m_pNode->GetDocument()->GetNotify()->OnWidgetListItemRemoved(this, nIndex);
+ m_pNode->GetDocument()->GetNotify()->OnWidgetListItemRemoved(m_pNode,
+ nIndex);
return true;
}
bool CXFA_WidgetAcc::IsHorizontalScrollPolicyOff() {
- CXFA_Node* pUIChild = GetUIChild();
+ CXFA_Node* pUIChild = m_pNode->GetUIChild();
if (pUIChild) {
return pUIChild->JSObject()->GetEnum(XFA_Attribute::HScrollPolicy) ==
XFA_AttributeEnum::Off;
@@ -2265,7 +2042,7 @@ bool CXFA_WidgetAcc::IsHorizontalScrollPolicyOff() {
}
bool CXFA_WidgetAcc::IsVerticalScrollPolicyOff() {
- CXFA_Node* pUIChild = GetUIChild();
+ CXFA_Node* pUIChild = m_pNode->GetUIChild();
if (pUIChild) {
return pUIChild->JSObject()->GetEnum(XFA_Attribute::VScrollPolicy) ==
XFA_AttributeEnum::Off;
@@ -2274,7 +2051,7 @@ bool CXFA_WidgetAcc::IsVerticalScrollPolicyOff() {
}
Optional<int32_t> CXFA_WidgetAcc::GetNumberOfCells() {
- CXFA_Node* pUIChild = GetUIChild();
+ CXFA_Node* pUIChild = m_pNode->GetUIChild();
if (!pUIChild)
return {};
if (CXFA_Comb* pNode =
@@ -2284,13 +2061,13 @@ Optional<int32_t> CXFA_WidgetAcc::GetNumberOfCells() {
}
WideString CXFA_WidgetAcc::GetPasswordChar() {
- CXFA_Node* pUIChild = GetUIChild();
+ CXFA_Node* pUIChild = m_pNode->GetUIChild();
return pUIChild ? pUIChild->JSObject()->GetCData(XFA_Attribute::PasswordChar)
: L"*";
}
bool CXFA_WidgetAcc::IsMultiLine() {
- CXFA_Node* pUIChild = GetUIChild();
+ CXFA_Node* pUIChild = m_pNode->GetUIChild();
return pUIChild && pUIChild->JSObject()->GetBoolean(XFA_Attribute::MultiLine);
}
@@ -2361,7 +2138,7 @@ bool CXFA_WidgetAcc::SetValue(XFA_VALUEPICTURE eValueType,
WideString wsPicture = GetPictureContent(eValueType);
bool bValidate = true;
bool bSyncData = false;
- CXFA_Node* pNode = GetUIChild();
+ CXFA_Node* pNode = m_pNode->GetUIChild();
if (!pNode)
return true;
@@ -2488,11 +2265,11 @@ WideString CXFA_WidgetAcc::GetValue(XFA_VALUEPICTURE eValueType) {
GetItemLabel(wsValue.AsStringView(), wsValue);
WideString wsPicture = GetPictureContent(eValueType);
- CXFA_Node* pNode = GetUIChild();
+ CXFA_Node* pNode = m_pNode->GetUIChild();
if (!pNode)
return wsValue;
- switch (GetUIChild()->GetElementType()) {
+ switch (m_pNode->GetUIChild()->GetElementType()) {
case XFA_Element::ChoiceList: {
if (eValueType == XFA_VALUEPICTURE_Display) {
int32_t iSelItemIndex = GetSelectedItem(0);
diff --git a/xfa/fxfa/cxfa_widgetacc.h b/xfa/fxfa/cxfa_widgetacc.h
index f21ace9d95..ac885cb2f2 100644
--- a/xfa/fxfa/cxfa_widgetacc.h
+++ b/xfa/fxfa/cxfa_widgetacc.h
@@ -93,10 +93,6 @@ class CXFA_WidgetAcc {
CXFA_Node* GetNode() const { return m_pNode; }
- CXFA_Node* GetUIChild();
- XFA_Element GetUIType();
- CFX_RectF GetUIMargin();
-
bool IsOpenAccess() const;
bool IsListBox();
bool IsAllowNeutral();
@@ -104,8 +100,6 @@ class CXFA_WidgetAcc {
bool IsChoiceListAllowTextEntry();
bool IsMultiLine();
- CXFA_Border* GetUIBorder();
-
std::vector<CXFA_Event*> GetEventByActivity(XFA_AttributeEnum iActivity,
bool bIsFormReady);
@@ -221,8 +215,6 @@ class CXFA_WidgetAcc {
std::unique_ptr<CXFA_WidgetLayoutData> m_pLayoutData;
bool m_bIsNull;
bool m_bPreNull;
- CXFA_Node* m_pUiChildNode;
- XFA_Element m_eUIType;
CXFA_Node* m_pNode;
};
diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp
index 1d2af4c858..935392373a 100644
--- a/xfa/fxfa/parser/cxfa_node.cpp
+++ b/xfa/fxfa/parser/cxfa_node.cpp
@@ -40,6 +40,7 @@
#include "xfa/fxfa/parser/cxfa_document.h"
#include "xfa/fxfa/parser/cxfa_event.h"
#include "xfa/fxfa/parser/cxfa_font.h"
+#include "xfa/fxfa/parser/cxfa_items.h"
#include "xfa/fxfa/parser/cxfa_keep.h"
#include "xfa/fxfa/parser/cxfa_layoutprocessor.h"
#include "xfa/fxfa/parser/cxfa_localevalue.h"
@@ -49,8 +50,10 @@
#include "xfa/fxfa/parser/cxfa_occur.h"
#include "xfa/fxfa/parser/cxfa_para.h"
#include "xfa/fxfa/parser/cxfa_simple_parser.h"
+#include "xfa/fxfa/parser/cxfa_stroke.h"
#include "xfa/fxfa/parser/cxfa_subform.h"
#include "xfa/fxfa/parser/cxfa_traversestrategy_xfacontainernode.h"
+#include "xfa/fxfa/parser/cxfa_ui.h"
#include "xfa/fxfa/parser/cxfa_validate.h"
#include "xfa/fxfa/parser/cxfa_value.h"
#include "xfa/fxfa/parser/xfa_basic_data.h"
@@ -150,6 +153,170 @@ void ReorderDataNodes(const std::set<CXFA_Node*>& sSet1,
}
}
+std::pair<XFA_Element, CXFA_Node*> CreateUIChild(CXFA_Node* pNode) {
+ XFA_Element eType = pNode->GetElementType();
+ XFA_Element eWidgetType = eType;
+ if (eType != XFA_Element::Field && eType != XFA_Element::Draw)
+ return {eWidgetType, nullptr};
+
+ eWidgetType = XFA_Element::Unknown;
+ XFA_Element eUIType = XFA_Element::Unknown;
+ auto* defValue =
+ pNode->JSObject()->GetOrCreateProperty<CXFA_Value>(0, XFA_Element::Value);
+ XFA_Element eValueType =
+ defValue ? defValue->GetChildValueClassID() : XFA_Element::Unknown;
+ switch (eValueType) {
+ case XFA_Element::Boolean:
+ eUIType = XFA_Element::CheckButton;
+ break;
+ case XFA_Element::Integer:
+ case XFA_Element::Decimal:
+ case XFA_Element::Float:
+ eUIType = XFA_Element::NumericEdit;
+ break;
+ case XFA_Element::ExData:
+ case XFA_Element::Text:
+ eUIType = XFA_Element::TextEdit;
+ eWidgetType = XFA_Element::Text;
+ break;
+ case XFA_Element::Date:
+ case XFA_Element::Time:
+ case XFA_Element::DateTime:
+ eUIType = XFA_Element::DateTimeEdit;
+ break;
+ case XFA_Element::Image:
+ eUIType = XFA_Element::ImageEdit;
+ eWidgetType = XFA_Element::Image;
+ break;
+ case XFA_Element::Arc:
+ case XFA_Element::Line:
+ case XFA_Element::Rectangle:
+ eUIType = XFA_Element::DefaultUi;
+ eWidgetType = eValueType;
+ break;
+ default:
+ break;
+ }
+
+ CXFA_Node* pUIChild = nullptr;
+ CXFA_Ui* pUI =
+ pNode->JSObject()->GetOrCreateProperty<CXFA_Ui>(0, XFA_Element::Ui);
+ CXFA_Node* pChild = pUI ? pUI->GetFirstChild() : nullptr;
+ for (; pChild; pChild = pChild->GetNextSibling()) {
+ XFA_Element eChildType = pChild->GetElementType();
+ if (eChildType == XFA_Element::Extras ||
+ eChildType == XFA_Element::Picture) {
+ continue;
+ }
+
+ auto node = CXFA_Node::Create(pChild->GetDocument(), XFA_Element::Ui,
+ XFA_PacketType::Form);
+ if (node && node->HasPropertyFlags(eChildType, XFA_PROPERTYFLAG_OneOf)) {
+ pUIChild = pChild;
+ break;
+ }
+ }
+
+ if (eType == XFA_Element::Draw) {
+ XFA_Element eDraw =
+ pUIChild ? pUIChild->GetElementType() : XFA_Element::Unknown;
+ switch (eDraw) {
+ case XFA_Element::TextEdit:
+ eWidgetType = XFA_Element::Text;
+ break;
+ case XFA_Element::ImageEdit:
+ eWidgetType = XFA_Element::Image;
+ break;
+ default:
+ eWidgetType = eWidgetType == XFA_Element::Unknown ? XFA_Element::Text
+ : eWidgetType;
+ break;
+ }
+ } else {
+ if (pUIChild && pUIChild->GetElementType() == XFA_Element::DefaultUi) {
+ eWidgetType = XFA_Element::TextEdit;
+ } else {
+ eWidgetType =
+ pUIChild ? pUIChild->GetElementType()
+ : (eUIType == XFA_Element::Unknown ? XFA_Element::TextEdit
+ : eUIType);
+ }
+ }
+
+ if (!pUIChild) {
+ if (eUIType == XFA_Element::Unknown) {
+ eUIType = XFA_Element::TextEdit;
+ if (defValue) {
+ defValue->JSObject()->GetOrCreateProperty<CXFA_Text>(0,
+ XFA_Element::Text);
+ }
+ }
+ return {eWidgetType,
+ pUI ? pUI->JSObject()->GetOrCreateProperty<CXFA_Node>(0, eUIType)
+ : nullptr};
+ }
+
+ if (eUIType != XFA_Element::Unknown)
+ return {eWidgetType, pUIChild};
+
+ switch (pUIChild->GetElementType()) {
+ case XFA_Element::CheckButton: {
+ eValueType = XFA_Element::Text;
+ if (CXFA_Items* pItems =
+ pNode->GetChild<CXFA_Items>(0, XFA_Element::Items, false)) {
+ if (CXFA_Node* pItem =
+ pItems->GetChild<CXFA_Node>(0, XFA_Element::Unknown, false)) {
+ eValueType = pItem->GetElementType();
+ }
+ }
+ break;
+ }
+ case XFA_Element::DateTimeEdit:
+ eValueType = XFA_Element::DateTime;
+ break;
+ case XFA_Element::ImageEdit:
+ eValueType = XFA_Element::Image;
+ break;
+ case XFA_Element::NumericEdit:
+ eValueType = XFA_Element::Float;
+ break;
+ case XFA_Element::ChoiceList: {
+ eValueType = (pUIChild->JSObject()->GetEnum(XFA_Attribute::Open) ==
+ XFA_AttributeEnum::MultiSelect)
+ ? XFA_Element::ExData
+ : XFA_Element::Text;
+ break;
+ }
+ case XFA_Element::Barcode:
+ case XFA_Element::Button:
+ case XFA_Element::PasswordEdit:
+ case XFA_Element::Signature:
+ case XFA_Element::TextEdit:
+ default:
+ eValueType = XFA_Element::Text;
+ break;
+ }
+ if (defValue)
+ defValue->JSObject()->GetOrCreateProperty<CXFA_Node>(0, eValueType);
+
+ return {eWidgetType, pUIChild};
+}
+
+float GetEdgeThickness(const std::vector<CXFA_Stroke*>& strokes,
+ bool b3DStyle,
+ int32_t nIndex) {
+ float fThickness = 0;
+
+ CXFA_Stroke* stroke = strokes[nIndex * 2 + 1];
+ if (stroke->IsVisible()) {
+ if (nIndex == 0)
+ fThickness += 2.5f;
+
+ fThickness += stroke->GetThickness() * (b3DStyle ? 4 : 2);
+ }
+ return fThickness;
+}
+
} // namespace
// static
@@ -2059,7 +2226,7 @@ std::pair<int32_t, bool> CXFA_Node::ExecuteBoolScript(
}
WideString CXFA_Node::GetBarcodeType() {
- CXFA_Node* pUIChild = GetWidgetAcc()->GetUIChild();
+ CXFA_Node* pUIChild = GetUIChild();
return pUIChild
? WideString(pUIChild->JSObject()->GetCData(XFA_Attribute::Type))
: WideString();
@@ -2067,8 +2234,7 @@ WideString CXFA_Node::GetBarcodeType() {
Optional<BC_CHAR_ENCODING> CXFA_Node::GetBarcodeAttribute_CharEncoding() {
Optional<WideString> wsCharEncoding =
- GetWidgetAcc()->GetUIChild()->JSObject()->TryCData(
- XFA_Attribute::CharEncoding, true);
+ GetUIChild()->JSObject()->TryCData(XFA_Attribute::CharEncoding, true);
if (!wsCharEncoding)
return {};
if (wsCharEncoding->CompareNoCase(L"UTF-16"))
@@ -2080,8 +2246,7 @@ Optional<BC_CHAR_ENCODING> CXFA_Node::GetBarcodeAttribute_CharEncoding() {
Optional<bool> CXFA_Node::GetBarcodeAttribute_Checksum() {
Optional<XFA_AttributeEnum> checksum =
- GetWidgetAcc()->GetUIChild()->JSObject()->TryEnum(XFA_Attribute::Checksum,
- true);
+ GetUIChild()->JSObject()->TryEnum(XFA_Attribute::Checksum, true);
if (!checksum)
return {};
@@ -2101,8 +2266,7 @@ Optional<bool> CXFA_Node::GetBarcodeAttribute_Checksum() {
Optional<int32_t> CXFA_Node::GetBarcodeAttribute_DataLength() {
Optional<WideString> wsDataLength =
- GetWidgetAcc()->GetUIChild()->JSObject()->TryCData(
- XFA_Attribute::DataLength, true);
+ GetUIChild()->JSObject()->TryCData(XFA_Attribute::DataLength, true);
if (!wsDataLength)
return {};
@@ -2111,8 +2275,7 @@ Optional<int32_t> CXFA_Node::GetBarcodeAttribute_DataLength() {
Optional<char> CXFA_Node::GetBarcodeAttribute_StartChar() {
Optional<WideString> wsStartEndChar =
- GetWidgetAcc()->GetUIChild()->JSObject()->TryCData(
- XFA_Attribute::StartChar, true);
+ GetUIChild()->JSObject()->TryCData(XFA_Attribute::StartChar, true);
if (!wsStartEndChar || wsStartEndChar->IsEmpty())
return {};
@@ -2121,8 +2284,7 @@ Optional<char> CXFA_Node::GetBarcodeAttribute_StartChar() {
Optional<char> CXFA_Node::GetBarcodeAttribute_EndChar() {
Optional<WideString> wsStartEndChar =
- GetWidgetAcc()->GetUIChild()->JSObject()->TryCData(XFA_Attribute::EndChar,
- true);
+ GetUIChild()->JSObject()->TryCData(XFA_Attribute::EndChar, true);
if (!wsStartEndChar || wsStartEndChar->IsEmpty())
return {};
@@ -2130,9 +2292,8 @@ Optional<char> CXFA_Node::GetBarcodeAttribute_EndChar() {
}
Optional<int32_t> CXFA_Node::GetBarcodeAttribute_ECLevel() {
- Optional<WideString> wsECLevel =
- GetWidgetAcc()->GetUIChild()->JSObject()->TryCData(
- XFA_Attribute::ErrorCorrectionLevel, true);
+ Optional<WideString> wsECLevel = GetUIChild()->JSObject()->TryCData(
+ XFA_Attribute::ErrorCorrectionLevel, true);
if (!wsECLevel)
return {};
return {FXSYS_wtoi(wsECLevel->c_str())};
@@ -2140,8 +2301,7 @@ Optional<int32_t> CXFA_Node::GetBarcodeAttribute_ECLevel() {
Optional<int32_t> CXFA_Node::GetBarcodeAttribute_ModuleWidth() {
Optional<CXFA_Measurement> moduleWidthHeight =
- GetWidgetAcc()->GetUIChild()->JSObject()->TryMeasure(
- XFA_Attribute::ModuleWidth, true);
+ GetUIChild()->JSObject()->TryMeasure(XFA_Attribute::ModuleWidth, true);
if (!moduleWidthHeight)
return {};
@@ -2150,8 +2310,7 @@ Optional<int32_t> CXFA_Node::GetBarcodeAttribute_ModuleWidth() {
Optional<int32_t> CXFA_Node::GetBarcodeAttribute_ModuleHeight() {
Optional<CXFA_Measurement> moduleWidthHeight =
- GetWidgetAcc()->GetUIChild()->JSObject()->TryMeasure(
- XFA_Attribute::ModuleHeight, true);
+ GetUIChild()->JSObject()->TryMeasure(XFA_Attribute::ModuleHeight, true);
if (!moduleWidthHeight)
return {};
@@ -2159,14 +2318,13 @@ Optional<int32_t> CXFA_Node::GetBarcodeAttribute_ModuleHeight() {
}
Optional<bool> CXFA_Node::GetBarcodeAttribute_PrintChecksum() {
- return GetWidgetAcc()->GetUIChild()->JSObject()->TryBoolean(
- XFA_Attribute::PrintCheckDigit, true);
+ return GetUIChild()->JSObject()->TryBoolean(XFA_Attribute::PrintCheckDigit,
+ true);
}
Optional<BC_TEXT_LOC> CXFA_Node::GetBarcodeAttribute_TextLocation() {
Optional<XFA_AttributeEnum> textLocation =
- GetWidgetAcc()->GetUIChild()->JSObject()->TryEnum(
- XFA_Attribute::TextLocation, true);
+ GetUIChild()->JSObject()->TryEnum(XFA_Attribute::TextLocation, true);
if (!textLocation)
return {};
@@ -2188,14 +2346,12 @@ Optional<BC_TEXT_LOC> CXFA_Node::GetBarcodeAttribute_TextLocation() {
}
Optional<bool> CXFA_Node::GetBarcodeAttribute_Truncate() {
- return GetWidgetAcc()->GetUIChild()->JSObject()->TryBoolean(
- XFA_Attribute::Truncate, true);
+ return GetUIChild()->JSObject()->TryBoolean(XFA_Attribute::Truncate, true);
}
Optional<int8_t> CXFA_Node::GetBarcodeAttribute_WideNarrowRatio() {
Optional<WideString> wsWideNarrowRatio =
- GetWidgetAcc()->GetUIChild()->JSObject()->TryCData(
- XFA_Attribute::WideNarrowRatio, true);
+ GetUIChild()->JSObject()->TryCData(XFA_Attribute::WideNarrowRatio, true);
if (!wsWideNarrowRatio)
return {};
@@ -2213,3 +2369,60 @@ Optional<int8_t> CXFA_Node::GetBarcodeAttribute_WideNarrowRatio() {
float result = static_cast<float>(fA) / static_cast<float>(fB);
return {static_cast<int8_t>(result)};
}
+
+CXFA_Node* CXFA_Node::GetUIChild() {
+ if (m_eUIType == XFA_Element::Unknown)
+ std::tie(m_eUIType, m_pUiChildNode) = CreateUIChild(this);
+ return m_pUiChildNode;
+}
+
+XFA_Element CXFA_Node::GetUIType() {
+ GetUIChild();
+ return m_eUIType;
+}
+
+CXFA_Border* CXFA_Node::GetUIBorder() {
+ CXFA_Node* pUIChild = GetUIChild();
+ return pUIChild ? pUIChild->JSObject()->GetProperty<CXFA_Border>(
+ 0, XFA_Element::Border)
+ : nullptr;
+}
+
+CFX_RectF CXFA_Node::GetUIMargin() {
+ CXFA_Node* pUIChild = GetUIChild();
+ if (!pUIChild)
+ return CFX_RectF();
+
+ CXFA_Margin* mgUI =
+ pUIChild->JSObject()->GetProperty<CXFA_Margin>(0, XFA_Element::Margin);
+ if (!mgUI)
+ return CFX_RectF();
+
+ CXFA_Border* border = GetUIBorder();
+ if (border && border->GetPresence() != XFA_AttributeEnum::Visible)
+ return CFX_RectF();
+
+ Optional<float> left = mgUI->TryLeftInset();
+ Optional<float> top = mgUI->TryTopInset();
+ Optional<float> right = mgUI->TryRightInset();
+ Optional<float> bottom = mgUI->TryBottomInset();
+ if (border) {
+ bool bVisible = false;
+ float fThickness = 0;
+ XFA_AttributeEnum iType = XFA_AttributeEnum::Unknown;
+ std::tie(iType, bVisible, fThickness) = border->Get3DStyle();
+ if (!left || !top || !right || !bottom) {
+ std::vector<CXFA_Stroke*> strokes = border->GetStrokes();
+ if (!top)
+ top = GetEdgeThickness(strokes, bVisible, 0);
+ if (!right)
+ right = GetEdgeThickness(strokes, bVisible, 1);
+ if (!bottom)
+ bottom = GetEdgeThickness(strokes, bVisible, 2);
+ if (!left)
+ left = GetEdgeThickness(strokes, bVisible, 3);
+ }
+ }
+ return CFX_RectF(left.value_or(0.0), top.value_or(0.0), right.value_or(0.0),
+ bottom.value_or(0.0));
+}
diff --git a/xfa/fxfa/parser/cxfa_node.h b/xfa/fxfa/parser/cxfa_node.h
index c08a9affdd..4fae752ea0 100644
--- a/xfa/fxfa/parser/cxfa_node.h
+++ b/xfa/fxfa/parser/cxfa_node.h
@@ -294,6 +294,11 @@ class CXFA_Node : public CXFA_Object {
Optional<bool> GetBarcodeAttribute_Truncate();
Optional<int8_t> GetBarcodeAttribute_WideNarrowRatio();
+ CXFA_Node* GetUIChild();
+ XFA_Element GetUIType();
+ CFX_RectF GetUIMargin();
+ CXFA_Border* GetUIBorder();
+
protected:
CXFA_Node(CXFA_Document* pDoc,
XFA_PacketType ePacket,
@@ -357,6 +362,8 @@ class CXFA_Node : public CXFA_Object {
uint32_t m_dwNameHash;
CXFA_Node* m_pAuxNode;
std::vector<UnownedPtr<CXFA_Node>> binding_nodes_;
+ CXFA_Node* m_pUiChildNode = nullptr;
+ XFA_Element m_eUIType = XFA_Element::Unknown;
};
#endif // XFA_FXFA_PARSER_CXFA_NODE_H_
diff --git a/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp b/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp
index 422ba4e58a..05846f2e3f 100644
--- a/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp
+++ b/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp
@@ -71,7 +71,8 @@ CXFA_Node* FormValueNode_CreateChild(CXFA_Node* pValueNode, XFA_Element iType) {
void FormValueNode_MatchNoneCreateChild(CXFA_Node* pFormNode) {
ASSERT(pFormNode->IsWidgetReady());
- pFormNode->GetWidgetAcc()->GetUIType();
+ // GetUIChild has the side effect of creating the UI child.
+ pFormNode->GetUIChild();
}
bool FormValueNode_SetChildContent(CXFA_Node* pValueNode,
@@ -133,12 +134,11 @@ void CreateDataBinding(CXFA_Node* pFormNode,
ASSERT(pFormNode->IsWidgetReady());
CXFA_WidgetAcc* pWidgetAcc = pFormNode->GetWidgetAcc();
- XFA_Element eUIType = pWidgetAcc->GetUIType();
auto* defValue = pFormNode->JSObject()->GetOrCreateProperty<CXFA_Value>(
0, XFA_Element::Value);
if (!bDataToForm) {
WideString wsValue;
- switch (eUIType) {
+ switch (pFormNode->GetUIType()) {
case XFA_Element::ImageEdit: {
CXFA_Image* image = defValue ? defValue->GetImageIfExists() : nullptr;
WideString wsContentType;
@@ -289,7 +289,7 @@ void CreateDataBinding(CXFA_Node* pFormNode,
pDataNode->JSObject()->SetAttributeValue(wsNormalizeValue, wsXMLValue, false,
false);
- switch (eUIType) {
+ switch (pFormNode->GetUIType()) {
case XFA_Element::ImageEdit: {
FormValueNode_SetChildContent(defValue, wsNormalizeValue,
XFA_Element::Image);
diff --git a/xfa/fxfa/parser/xfa_utils.cpp b/xfa/fxfa/parser/xfa_utils.cpp
index 5d2f222a3b..226aaed83b 100644
--- a/xfa/fxfa/parser/xfa_utils.cpp
+++ b/xfa/fxfa/parser/xfa_utils.cpp
@@ -142,11 +142,9 @@ bool ContentNodeNeedtoExport(CXFA_Node* pContentNode) {
CXFA_Node* pGrandParentNode = pParentNode->GetParent();
if (!pGrandParentNode || !pGrandParentNode->IsContainerNode())
return true;
- if (pGrandParentNode->GetBindData())
+ if (!pGrandParentNode->GetBindData())
return false;
-
- XFA_Element eUIType = pGrandParentNode->GetWidgetAcc()->GetUIType();
- if (eUIType == XFA_Element::PasswordEdit)
+ if (pGrandParentNode->GetUIType() == XFA_Element::PasswordEdit)
return false;
return true;
}