summaryrefslogtreecommitdiff
path: root/xfa/fxfa/parser/cxfa_widgetdata.cpp
diff options
context:
space:
mode:
authordsinclair <dsinclair@chromium.org>2016-07-11 06:46:59 -0700
committerCommit bot <commit-bot@chromium.org>2016-07-11 06:47:00 -0700
commitd1cf239fa6be42baa02028efd1617d5af27d82e1 (patch)
treeb365ce948adbea9f655623db4e2ca7797ee5d14f /xfa/fxfa/parser/cxfa_widgetdata.cpp
parent3ecdbffbf3b812fe262ca1b8a6eec6187195ddd9 (diff)
downloadpdfium-d1cf239fa6be42baa02028efd1617d5af27d82e1.tar.xz
Cleanup redundant method names.
This CL cleans up a bunch of method names which are redundant with the class names or code location. Review-Url: https://codereview.chromium.org/2132513003
Diffstat (limited to 'xfa/fxfa/parser/cxfa_widgetdata.cpp')
-rw-r--r--xfa/fxfa/parser/cxfa_widgetdata.cpp138
1 files changed, 137 insertions, 1 deletions
diff --git a/xfa/fxfa/parser/cxfa_widgetdata.cpp b/xfa/fxfa/parser/cxfa_widgetdata.cpp
index 1dd78e198f..f372c51f2c 100644
--- a/xfa/fxfa/parser/cxfa_widgetdata.cpp
+++ b/xfa/fxfa/parser/cxfa_widgetdata.cpp
@@ -70,6 +70,142 @@ FX_BOOL SplitDateTime(const CFX_WideString& wsDateTime,
return TRUE;
}
+CXFA_Node* CreateUIChild(CXFA_Node* pNode, XFA_Element& eWidgetType) {
+ XFA_Element eType = pNode->GetElementType();
+ eWidgetType = eType;
+ if (eType != XFA_Element::Field && eType != XFA_Element::Draw)
+ return nullptr;
+
+ eWidgetType = XFA_Element::Unknown;
+ XFA_Element eUIType = XFA_Element::Unknown;
+ CXFA_Value defValue(pNode->GetProperty(0, XFA_Element::Value, TRUE));
+ XFA_Element eValueType = defValue.GetChildValueClassID();
+ 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_Node* pUI = pNode->GetProperty(0, XFA_Element::Ui, TRUE);
+ CXFA_Node* pChild = pUI->GetNodeItem(XFA_NODEITEM_FirstChild);
+ for (; pChild; pChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling)) {
+ XFA_Element eChildType = pChild->GetElementType();
+ if (eChildType == XFA_Element::Extras ||
+ eChildType == XFA_Element::Picture) {
+ continue;
+ }
+ const XFA_PROPERTY* pProperty = XFA_GetPropertyOfElement(
+ XFA_Element::Ui, eChildType, XFA_XDPPACKET_Form);
+ if (pProperty && (pProperty->uFlags & 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;
+ defValue.GetNode()->GetProperty(0, XFA_Element::Text, TRUE);
+ }
+ return pUI->GetProperty(0, eUIType, TRUE);
+ }
+
+ if (eUIType != XFA_Element::Unknown)
+ return pUIChild;
+
+ switch (pUIChild->GetElementType()) {
+ case XFA_Element::CheckButton: {
+ eValueType = XFA_Element::Text;
+ if (CXFA_Node* pItems = pNode->GetChild(0, XFA_Element::Items)) {
+ if (CXFA_Node* pItem = pItems->GetChild(0, XFA_Element::Unknown))
+ 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->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;
+ }
+ defValue.GetNode()->GetProperty(0, eValueType, TRUE);
+
+ return pUIChild;
+}
+
} // namespace
CXFA_WidgetData::CXFA_WidgetData(CXFA_Node* pNode)
@@ -81,7 +217,7 @@ CXFA_WidgetData::CXFA_WidgetData(CXFA_Node* pNode)
CXFA_Node* CXFA_WidgetData::GetUIChild() {
if (m_eUIType == XFA_Element::Unknown)
- m_pUiChildNode = XFA_CreateUIChild(m_pNode, m_eUIType);
+ m_pUiChildNode = CreateUIChild(m_pNode, m_eUIType);
return m_pUiChildNode;
}