From 90d9386825b872a0b668eac5dff3e268fa7ad16c Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Tue, 30 Jan 2018 21:38:40 +0000 Subject: Shuffle more code out of CXFA_Node This CL moves more code out of the CXFA_Node class and into specific subclasses. Change-Id: Idca36f251431bf7efd4da045aeabf097ab23f0ce Reviewed-on: https://pdfium-review.googlesource.com/24714 Reviewed-by: Ryan Harrison Commit-Queue: dsinclair --- xfa/fxfa/parser/cxfa_button.cpp | 4 ++++ xfa/fxfa/parser/cxfa_button.h | 2 ++ xfa/fxfa/parser/cxfa_checkbutton.cpp | 4 ++++ xfa/fxfa/parser/cxfa_checkbutton.h | 1 + xfa/fxfa/parser/cxfa_node.cpp | 34 +++++++--------------------------- xfa/fxfa/parser/cxfa_node.h | 3 --- xfa/fxfa/parser/cxfa_passwordedit.cpp | 4 ++++ xfa/fxfa/parser/cxfa_passwordedit.h | 1 + 8 files changed, 23 insertions(+), 30 deletions(-) (limited to 'xfa/fxfa/parser') diff --git a/xfa/fxfa/parser/cxfa_button.cpp b/xfa/fxfa/parser/cxfa_button.cpp index 7b56d2b712..4a951b3ee9 100644 --- a/xfa/fxfa/parser/cxfa_button.cpp +++ b/xfa/fxfa/parser/cxfa_button.cpp @@ -41,3 +41,7 @@ CXFA_Button::~CXFA_Button() {} XFA_FFWidgetType CXFA_Button::GetDefaultFFWidgetType() const { return XFA_FFWidgetType::kButton; } + +XFA_AttributeEnum CXFA_Button::GetHighlight() { + return JSObject()->GetEnum(XFA_Attribute::Highlight); +} diff --git a/xfa/fxfa/parser/cxfa_button.h b/xfa/fxfa/parser/cxfa_button.h index 75d62a6159..cea685fa4e 100644 --- a/xfa/fxfa/parser/cxfa_button.h +++ b/xfa/fxfa/parser/cxfa_button.h @@ -15,6 +15,8 @@ class CXFA_Button : public CXFA_Node { ~CXFA_Button() override; XFA_FFWidgetType GetDefaultFFWidgetType() const override; + + XFA_AttributeEnum GetHighlight(); }; #endif // XFA_FXFA_PARSER_CXFA_BUTTON_H_ diff --git a/xfa/fxfa/parser/cxfa_checkbutton.cpp b/xfa/fxfa/parser/cxfa_checkbutton.cpp index 59afe5ac98..6b5fa8fada 100644 --- a/xfa/fxfa/parser/cxfa_checkbutton.cpp +++ b/xfa/fxfa/parser/cxfa_checkbutton.cpp @@ -55,3 +55,7 @@ bool CXFA_CheckButton::IsRound() { XFA_AttributeEnum CXFA_CheckButton::GetMark() { return JSObject()->GetEnum(XFA_Attribute::Mark); } + +bool CXFA_CheckButton::IsAllowNeutral() { + return JSObject()->GetBoolean(XFA_Attribute::AllowNeutral); +} diff --git a/xfa/fxfa/parser/cxfa_checkbutton.h b/xfa/fxfa/parser/cxfa_checkbutton.h index b603dd0ca1..e239a46ecb 100644 --- a/xfa/fxfa/parser/cxfa_checkbutton.h +++ b/xfa/fxfa/parser/cxfa_checkbutton.h @@ -17,6 +17,7 @@ class CXFA_CheckButton : public CXFA_Node { XFA_FFWidgetType GetDefaultFFWidgetType() const override; bool IsRound(); + bool IsAllowNeutral(); XFA_AttributeEnum GetMark(); }; diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp index 0c28f4b5c6..451c98f8f0 100644 --- a/xfa/fxfa/parser/cxfa_node.cpp +++ b/xfa/fxfa/parser/cxfa_node.cpp @@ -3523,13 +3523,6 @@ RetainPtr CXFA_Node::GetFDEFont(CXFA_FFDoc* doc) { dwFontStyle); } -XFA_AttributeEnum CXFA_Node::GetButtonHighlight() { - CXFA_Node* pUIChild = GetUIChildNode(); - if (pUIChild) - return pUIChild->JSObject()->GetEnum(XFA_Attribute::Highlight); - return XFA_AttributeEnum::Inverted; -} - bool CXFA_Node::HasButtonRollover() { CXFA_Items* pItems = GetChild(0, XFA_Element::Items, false); if (!pItems) @@ -3571,12 +3564,6 @@ float CXFA_Node::GetCheckButtonSize() { return CXFA_Measurement(10, XFA_Unit::Pt).ToUnit(XFA_Unit::Pt); } -bool CXFA_Node::IsAllowNeutral() { - CXFA_Node* pUIChild = GetUIChildNode(); - return pUIChild && - pUIChild->JSObject()->GetBoolean(XFA_Attribute::AllowNeutral); -} - XFA_CHECKSTATE CXFA_Node::GetCheckState() { WideString wsValue = GetRawValue(); if (wsValue.IsEmpty()) @@ -4232,12 +4219,6 @@ Optional CXFA_Node::GetNumberOfCells() { return {}; } -WideString CXFA_Node::GetPasswordChar() { - CXFA_Node* pUIChild = GetUIChildNode(); - return pUIChild ? pUIChild->JSObject()->GetCData(XFA_Attribute::PasswordChar) - : L"*"; -} - bool CXFA_Node::IsMultiLine() { CXFA_Node* pUIChild = GetUIChildNode(); return pUIChild && pUIChild->JSObject()->GetBoolean(XFA_Attribute::MultiLine); @@ -4327,13 +4308,11 @@ bool CXFA_Node::SetValue(XFA_VALUEPICTURE eValueType, bSyncData = true; } - } else { - if (eType == XFA_Element::NumericEdit) { - if (wsNewText != L"0") - wsNewText = NumericLimit(wsNewText, GetLeadDigits(), GetFracDigits()); + } else if (eType == XFA_Element::NumericEdit) { + if (wsNewText != L"0") + wsNewText = NumericLimit(wsNewText, GetLeadDigits(), GetFracDigits()); - bSyncData = true; - } + bSyncData = true; } if (eType != XFA_Element::NumericEdit || bSyncData) SyncValue(wsNewText, true); @@ -4432,7 +4411,7 @@ WideString CXFA_Node::GetValue(XFA_VALUEPICTURE eValueType) { if (!pNode) return wsValue; - switch (GetUIChildNode()->GetElementType()) { + switch (pNode->GetElementType()) { case XFA_Element::ChoiceList: { if (eValueType == XFA_VALUEPICTURE_Display) { int32_t iSelItemIndex = GetSelectedItem(0); @@ -4441,7 +4420,8 @@ WideString CXFA_Node::GetValue(XFA_VALUEPICTURE eValueType) { wsPicture.clear(); } } - } break; + break; + } case XFA_Element::NumericEdit: if (eValueType != XFA_VALUEPICTURE_Raw && wsPicture.IsEmpty()) { IFX_Locale* pLocale = GetLocale(); diff --git a/xfa/fxfa/parser/cxfa_node.h b/xfa/fxfa/parser/cxfa_node.h index 819b2f9a40..dfe5ab0127 100644 --- a/xfa/fxfa/parser/cxfa_node.h +++ b/xfa/fxfa/parser/cxfa_node.h @@ -310,11 +310,9 @@ class CXFA_Node : public CXFA_Object { RetainPtr GetFDEFont(CXFA_FFDoc* doc); bool IsListBox(); - bool IsAllowNeutral(); bool IsRadioButton(); bool IsMultiLine(); - XFA_AttributeEnum GetButtonHighlight(); bool HasButtonRollover(); bool HasButtonDown(); @@ -375,7 +373,6 @@ class CXFA_Node : public CXFA_Object { WideString GetFormatDataValue(const WideString& wsValue); WideString NormalizeNumStr(const WideString& wsValue); - WideString GetPasswordChar(); std::pair GetMaxChars(); int32_t GetFracDigits(); int32_t GetLeadDigits(); diff --git a/xfa/fxfa/parser/cxfa_passwordedit.cpp b/xfa/fxfa/parser/cxfa_passwordedit.cpp index 68267af183..6d38c344fe 100644 --- a/xfa/fxfa/parser/cxfa_passwordedit.cpp +++ b/xfa/fxfa/parser/cxfa_passwordedit.cpp @@ -43,3 +43,7 @@ CXFA_PasswordEdit::~CXFA_PasswordEdit() {} XFA_FFWidgetType CXFA_PasswordEdit::GetDefaultFFWidgetType() const { return XFA_FFWidgetType::kPasswordEdit; } + +WideString CXFA_PasswordEdit::GetPasswordChar() { + return JSObject()->GetCData(XFA_Attribute::PasswordChar); +} diff --git a/xfa/fxfa/parser/cxfa_passwordedit.h b/xfa/fxfa/parser/cxfa_passwordedit.h index e390aaa2b1..6c8e8e5856 100644 --- a/xfa/fxfa/parser/cxfa_passwordedit.h +++ b/xfa/fxfa/parser/cxfa_passwordedit.h @@ -15,6 +15,7 @@ class CXFA_PasswordEdit : public CXFA_Node { ~CXFA_PasswordEdit() override; XFA_FFWidgetType GetDefaultFFWidgetType() const override; + WideString GetPasswordChar(); }; #endif // XFA_FXFA_PARSER_CXFA_PASSWORDEDIT_H_ -- cgit v1.2.3