diff options
Diffstat (limited to 'xfa/fxfa/parser')
-rw-r--r-- | xfa/fxfa/parser/cxfa_attachnodelist.cpp | 2 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_binddata.cpp | 8 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_boxdata.cpp | 4 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_calculatedata.cpp | 10 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_captiondata.cpp | 13 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_document.cpp | 4 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_eventdata.cpp | 6 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_filldata.cpp | 18 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_fontdata.cpp | 4 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_layoutpagemgr.cpp | 20 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_linedata.cpp | 4 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_node.cpp | 6 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_node.h | 10 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_nodelocale.cpp | 17 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_strokedata.cpp | 4 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_validate.cpp | 5 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_widgetdata.cpp | 77 | ||||
-rw-r--r-- | xfa/fxfa/parser/xfa_document_datamerger_imp.cpp | 11 | ||||
-rw-r--r-- | xfa/fxfa/parser/xfa_utils.cpp | 39 |
19 files changed, 163 insertions, 99 deletions
diff --git a/xfa/fxfa/parser/cxfa_attachnodelist.cpp b/xfa/fxfa/parser/cxfa_attachnodelist.cpp index a793e02bc4..0a9be2ed4a 100644 --- a/xfa/fxfa/parser/cxfa_attachnodelist.cpp +++ b/xfa/fxfa/parser/cxfa_attachnodelist.cpp @@ -41,7 +41,7 @@ bool CXFA_AttachNodeList::Remove(CXFA_Node* pNode) { } CXFA_Node* CXFA_AttachNodeList::Item(int32_t iIndex) { - return m_pAttachNode->GetChild( + return m_pAttachNode->GetChild<CXFA_Node>( iIndex, XFA_Element::Unknown, m_pAttachNode->GetElementType() == XFA_Element::Subform); } diff --git a/xfa/fxfa/parser/cxfa_binddata.cpp b/xfa/fxfa/parser/cxfa_binddata.cpp index 62146e3419..7a7e2eef86 100644 --- a/xfa/fxfa/parser/cxfa_binddata.cpp +++ b/xfa/fxfa/parser/cxfa_binddata.cpp @@ -7,12 +7,12 @@ #include "xfa/fxfa/parser/cxfa_binddata.h" #include "xfa/fxfa/parser/cxfa_node.h" +#include "xfa/fxfa/parser/cxfa_picture.h" CXFA_BindData::CXFA_BindData(CXFA_Node* pNode) : CXFA_DataData(pNode) {} WideString CXFA_BindData::GetPicture() { - CXFA_Node* pPicture = m_pNode->GetChild(0, XFA_Element::Picture, false); - if (!pPicture) - return L""; - return pPicture->JSObject()->GetContent(false); + CXFA_Picture* pPicture = + m_pNode->GetChild<CXFA_Picture>(0, XFA_Element::Picture, false); + return pPicture ? pPicture->JSObject()->GetContent(false) : L""; } diff --git a/xfa/fxfa/parser/cxfa_boxdata.cpp b/xfa/fxfa/parser/cxfa_boxdata.cpp index 8f2674cda0..7ada3bf00b 100644 --- a/xfa/fxfa/parser/cxfa_boxdata.cpp +++ b/xfa/fxfa/parser/cxfa_boxdata.cpp @@ -7,6 +7,7 @@ #include "xfa/fxfa/parser/cxfa_boxdata.h" #include "xfa/fxfa/parser/cxfa_cornerdata.h" +#include "xfa/fxfa/parser/cxfa_margin.h" #include "xfa/fxfa/parser/cxfa_measurement.h" #include "xfa/fxfa/parser/cxfa_node.h" @@ -135,7 +136,8 @@ CXFA_FillData CXFA_BoxData::GetFillData(bool bModified) const { CXFA_MarginData CXFA_BoxData::GetMarginData() const { return CXFA_MarginData( - m_pNode ? m_pNode->GetChild(0, XFA_Element::Margin, false) : nullptr); + m_pNode ? m_pNode->GetChild<CXFA_Margin>(0, XFA_Element::Margin, false) + : nullptr); } std::tuple<XFA_AttributeEnum, bool, float> CXFA_BoxData::Get3DStyle() const { diff --git a/xfa/fxfa/parser/cxfa_calculatedata.cpp b/xfa/fxfa/parser/cxfa_calculatedata.cpp index 3d7711d433..f919224687 100644 --- a/xfa/fxfa/parser/cxfa_calculatedata.cpp +++ b/xfa/fxfa/parser/cxfa_calculatedata.cpp @@ -6,6 +6,7 @@ #include "xfa/fxfa/parser/cxfa_calculatedata.h" +#include "xfa/fxfa/parser/cxfa_message.h" #include "xfa/fxfa/parser/cxfa_node.h" #include "xfa/fxfa/parser/cxfa_script.h" #include "xfa/fxfa/parser/cxfa_text.h" @@ -20,16 +21,15 @@ XFA_AttributeEnum CXFA_CalculateData::GetOverride() const { } CXFA_Script* CXFA_CalculateData::GetScript() const { - return static_cast<CXFA_Script*>( - m_pNode->GetChild(0, XFA_Element::Script, false)); + return m_pNode->GetChild<CXFA_Script>(0, XFA_Element::Script, false); } WideString CXFA_CalculateData::GetMessageText() const { - CXFA_Node* pNode = m_pNode->GetChild(0, XFA_Element::Message, false); + CXFA_Message* pNode = + m_pNode->GetChild<CXFA_Message>(0, XFA_Element::Message, false); if (!pNode) return L""; - CXFA_Text* text = - static_cast<CXFA_Text*>(pNode->GetChild(0, XFA_Element::Text, false)); + CXFA_Text* text = pNode->GetChild<CXFA_Text>(0, XFA_Element::Text, false); return text ? text->GetContent() : L""; } diff --git a/xfa/fxfa/parser/cxfa_captiondata.cpp b/xfa/fxfa/parser/cxfa_captiondata.cpp index e48e5f34bb..59dbb2b008 100644 --- a/xfa/fxfa/parser/cxfa_captiondata.cpp +++ b/xfa/fxfa/parser/cxfa_captiondata.cpp @@ -6,6 +6,8 @@ #include "xfa/fxfa/parser/cxfa_captiondata.h" +#include "xfa/fxfa/parser/cxfa_font.h" +#include "xfa/fxfa/parser/cxfa_margin.h" #include "xfa/fxfa/parser/cxfa_measurement.h" #include "xfa/fxfa/parser/cxfa_node.h" #include "xfa/fxfa/parser/cxfa_value.h" @@ -39,16 +41,17 @@ float CXFA_CaptionData::GetReserve() const { CXFA_MarginData CXFA_CaptionData::GetMarginData() const { return CXFA_MarginData( - m_pNode ? m_pNode->GetChild(0, XFA_Element::Margin, false) : nullptr); + m_pNode ? m_pNode->GetChild<CXFA_Margin>(0, XFA_Element::Margin, false) + : nullptr); } CXFA_FontData CXFA_CaptionData::GetFontData() const { - return CXFA_FontData(m_pNode ? m_pNode->GetChild(0, XFA_Element::Font, false) - : nullptr); + return CXFA_FontData( + m_pNode ? m_pNode->GetChild<CXFA_Font>(0, XFA_Element::Font, false) + : nullptr); } CXFA_Value* CXFA_CaptionData::GetValue() const { - return m_pNode ? static_cast<CXFA_Value*>( - m_pNode->GetChild(0, XFA_Element::Value, false)) + return m_pNode ? m_pNode->GetChild<CXFA_Value>(0, XFA_Element::Value, false) : nullptr; } diff --git a/xfa/fxfa/parser/cxfa_document.cpp b/xfa/fxfa/parser/cxfa_document.cpp index e418c839c6..3ba5a44cf9 100644 --- a/xfa/fxfa/parser/cxfa_document.cpp +++ b/xfa/fxfa/parser/cxfa_document.cpp @@ -16,6 +16,7 @@ #include "xfa/fxfa/parser/cscript_logpseudomodel.h" #include "xfa/fxfa/parser/cscript_signaturepseudomodel.h" #include "xfa/fxfa/parser/cxfa_document_parser.h" +#include "xfa/fxfa/parser/cxfa_interactive.h" #include "xfa/fxfa/parser/cxfa_layoutprocessor.h" #include "xfa/fxfa/parser/cxfa_localemgr.h" #include "xfa/fxfa/parser/cxfa_node.h" @@ -261,7 +262,8 @@ bool CXFA_Document::IsInteractive() { if (!pPDF) return false; - CXFA_Node* pFormFiller = pPDF->GetChild(0, XFA_Element::Interactive, false); + CXFA_Interactive* pFormFiller = + pPDF->GetChild<CXFA_Interactive>(0, XFA_Element::Interactive, false); if (pFormFiller) { m_dwDocFlags |= XFA_DOCFLAG_HasInteractive; diff --git a/xfa/fxfa/parser/cxfa_eventdata.cpp b/xfa/fxfa/parser/cxfa_eventdata.cpp index d5b170b734..89dcb4ed2a 100644 --- a/xfa/fxfa/parser/cxfa_eventdata.cpp +++ b/xfa/fxfa/parser/cxfa_eventdata.cpp @@ -33,11 +33,9 @@ WideString CXFA_EventData::GetRef() const { } CXFA_Script* CXFA_EventData::GetScript() const { - return static_cast<CXFA_Script*>( - m_pNode->GetChild(0, XFA_Element::Script, false)); + return m_pNode->GetChild<CXFA_Script>(0, XFA_Element::Script, false); } CXFA_Submit* CXFA_EventData::GetSubmit() const { - return static_cast<CXFA_Submit*>( - m_pNode->GetChild(0, XFA_Element::Submit, false)); + return m_pNode->GetChild<CXFA_Submit>(0, XFA_Element::Submit, false); } diff --git a/xfa/fxfa/parser/cxfa_filldata.cpp b/xfa/fxfa/parser/cxfa_filldata.cpp index 2ea7652784..98df0aa3a4 100644 --- a/xfa/fxfa/parser/cxfa_filldata.cpp +++ b/xfa/fxfa/parser/cxfa_filldata.cpp @@ -6,6 +6,7 @@ #include "xfa/fxfa/parser/cxfa_filldata.h" +#include "xfa/fxfa/parser/cxfa_color.h" #include "xfa/fxfa/parser/cxfa_node.h" CXFA_FillData::CXFA_FillData(CXFA_Node* pNode) : CXFA_DataData(pNode) {} @@ -33,7 +34,8 @@ void CXFA_FillData::SetColor(FX_ARGB color) { } FX_ARGB CXFA_FillData::GetColor(bool bText) const { - if (CXFA_Node* pNode = m_pNode->GetChild(0, XFA_Element::Color, false)) { + if (CXFA_Color* pNode = + m_pNode->GetChild<CXFA_Color>(0, XFA_Element::Color, false)) { pdfium::Optional<WideString> wsColor = pNode->JSObject()->TryCData(XFA_Attribute::Value, false); if (wsColor) @@ -61,8 +63,8 @@ XFA_AttributeEnum CXFA_FillData::GetPatternType() const { } FX_ARGB CXFA_FillData::GetPatternColor() const { - if (CXFA_Node* pColor = - GetPattern()->GetChild(0, XFA_Element::Color, false)) { + if (CXFA_Color* pColor = + GetPattern()->GetChild<CXFA_Color>(0, XFA_Element::Color, false)) { pdfium::Optional<WideString> wsColor = pColor->JSObject()->TryCData(XFA_Attribute::Value, false); if (wsColor) @@ -79,8 +81,8 @@ int32_t CXFA_FillData::GetStippleRate() const { } FX_ARGB CXFA_FillData::GetStippleColor() const { - if (CXFA_Node* pColor = - GetStipple()->GetChild(0, XFA_Element::Color, false)) { + if (CXFA_Color* pColor = + GetStipple()->GetChild<CXFA_Color>(0, XFA_Element::Color, false)) { pdfium::Optional<WideString> wsColor = pColor->JSObject()->TryCData(XFA_Attribute::Value, false); if (wsColor) @@ -97,7 +99,8 @@ XFA_AttributeEnum CXFA_FillData::GetLinearType() const { } FX_ARGB CXFA_FillData::GetLinearColor() const { - if (CXFA_Node* pColor = GetLinear()->GetChild(0, XFA_Element::Color, false)) { + if (CXFA_Color* pColor = + GetLinear()->GetChild<CXFA_Color>(0, XFA_Element::Color, false)) { pdfium::Optional<WideString> wsColor = pColor->JSObject()->TryCData(XFA_Attribute::Value, false); if (wsColor) @@ -114,7 +117,8 @@ bool CXFA_FillData::IsRadialToEdge() const { } FX_ARGB CXFA_FillData::GetRadialColor() const { - if (CXFA_Node* pColor = GetRadial()->GetChild(0, XFA_Element::Color, false)) { + if (CXFA_Color* pColor = + GetRadial()->GetChild<CXFA_Color>(0, XFA_Element::Color, false)) { pdfium::Optional<WideString> wsColor = pColor->JSObject()->TryCData(XFA_Attribute::Value, false); if (wsColor) diff --git a/xfa/fxfa/parser/cxfa_fontdata.cpp b/xfa/fxfa/parser/cxfa_fontdata.cpp index c2b4a79fea..78ff2e89aa 100644 --- a/xfa/fxfa/parser/cxfa_fontdata.cpp +++ b/xfa/fxfa/parser/cxfa_fontdata.cpp @@ -7,6 +7,7 @@ #include "xfa/fxfa/parser/cxfa_fontdata.h" #include "core/fxge/fx_dib.h" +#include "xfa/fxfa/parser/cxfa_fill.h" #include "xfa/fxfa/parser/cxfa_filldata.h" #include "xfa/fxfa/parser/cxfa_measurement.h" #include "xfa/fxfa/parser/cxfa_node.h" @@ -82,6 +83,7 @@ void CXFA_FontData::SetColor(FX_ARGB color) { } FX_ARGB CXFA_FontData::GetColor() const { - CXFA_FillData fillData(m_pNode->GetChild(0, XFA_Element::Fill, false)); + CXFA_FillData fillData( + m_pNode->GetChild<CXFA_Fill>(0, XFA_Element::Fill, false)); return fillData.HasValidNode() ? fillData.GetColor(true) : 0xFF000000; } diff --git a/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp b/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp index 4d70d7d50f..21b3aca235 100644 --- a/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp +++ b/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp @@ -10,12 +10,14 @@ #include "third_party/base/stl_util.h" #include "xfa/fxfa/cxfa_ffnotify.h" #include "xfa/fxfa/parser/cxfa_containerlayoutitem.h" +#include "xfa/fxfa/parser/cxfa_contentarea.h" #include "xfa/fxfa/parser/cxfa_contentlayoutitem.h" #include "xfa/fxfa/parser/cxfa_document.h" #include "xfa/fxfa/parser/cxfa_itemlayoutprocessor.h" #include "xfa/fxfa/parser/cxfa_layoutprocessor.h" #include "xfa/fxfa/parser/cxfa_localemgr.h" #include "xfa/fxfa/parser/cxfa_measurement.h" +#include "xfa/fxfa/parser/cxfa_medium.h" #include "xfa/fxfa/parser/cxfa_node.h" #include "xfa/fxfa/parser/cxfa_nodeiteratortemplate.h" #include "xfa/fxfa/parser/cxfa_object.h" @@ -318,7 +320,8 @@ bool CXFA_LayoutPageMgr::InitLayoutPage(CXFA_Node* pFormNode) { return false; CXFA_Document* pDocument = pTemplateNode->GetDocument(); - pPageArea = m_pTemplatePageSetRoot->GetChild(0, XFA_Element::PageArea, false); + pPageArea = m_pTemplatePageSetRoot->GetChild<CXFA_Node>( + 0, XFA_Element::PageArea, false); if (!pPageArea) { pPageArea = pDocument->CreateNode(m_pTemplatePageSetRoot->GetPacketType(), XFA_Element::PageArea); @@ -328,11 +331,11 @@ bool CXFA_LayoutPageMgr::InitLayoutPage(CXFA_Node* pFormNode) { m_pTemplatePageSetRoot->InsertChild(pPageArea, nullptr); pPageArea->SetFlag(XFA_NodeFlag_Initialized, true); } - CXFA_Node* pContentArea = - pPageArea->GetChild(0, XFA_Element::ContentArea, false); + CXFA_ContentArea* pContentArea = + pPageArea->GetChild<CXFA_ContentArea>(0, XFA_Element::ContentArea, false); if (!pContentArea) { - pContentArea = pDocument->CreateNode(pPageArea->GetPacketType(), - XFA_Element::ContentArea); + pContentArea = static_cast<CXFA_ContentArea*>(pDocument->CreateNode( + pPageArea->GetPacketType(), XFA_Element::ContentArea)); if (!pContentArea) return false; @@ -347,10 +350,11 @@ bool CXFA_LayoutPageMgr::InitLayoutPage(CXFA_Node* pFormNode) { pContentArea->JSObject()->SetMeasure( XFA_Attribute::H, CXFA_Measurement(10.5f, XFA_Unit::In), false); } - CXFA_Node* pMedium = pPageArea->GetChild(0, XFA_Element::Medium, false); + CXFA_Medium* pMedium = + pPageArea->GetChild<CXFA_Medium>(0, XFA_Element::Medium, false); if (!pMedium) { - pMedium = - pDocument->CreateNode(pPageArea->GetPacketType(), XFA_Element::Medium); + pMedium = static_cast<CXFA_Medium*>( + pDocument->CreateNode(pPageArea->GetPacketType(), XFA_Element::Medium)); if (!pContentArea) return false; diff --git a/xfa/fxfa/parser/cxfa_linedata.cpp b/xfa/fxfa/parser/cxfa_linedata.cpp index 47e45c77f5..37f4f2a48f 100644 --- a/xfa/fxfa/parser/cxfa_linedata.cpp +++ b/xfa/fxfa/parser/cxfa_linedata.cpp @@ -6,6 +6,7 @@ #include "xfa/fxfa/parser/cxfa_linedata.h" +#include "xfa/fxfa/parser/cxfa_edge.h" #include "xfa/fxfa/parser/cxfa_node.h" XFA_AttributeEnum CXFA_LineData::GetHand() const { @@ -18,5 +19,6 @@ bool CXFA_LineData::GetSlope() const { } CXFA_EdgeData CXFA_LineData::GetEdgeData() const { - return CXFA_EdgeData(m_pNode->GetChild(0, XFA_Element::Edge, false)); + return CXFA_EdgeData( + m_pNode->GetChild<CXFA_Edge>(0, XFA_Element::Edge, false)); } diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp index bede0a722c..195af08bf7 100644 --- a/xfa/fxfa/parser/cxfa_node.cpp +++ b/xfa/fxfa/parser/cxfa_node.cpp @@ -786,9 +786,9 @@ int32_t CXFA_Node::CountChildren(XFA_Element eType, bool bOnlyChild) { return iCount; } -CXFA_Node* CXFA_Node::GetChild(int32_t index, - XFA_Element eType, - bool bOnlyChild) { +CXFA_Node* CXFA_Node::GetChildInternal(int32_t index, + XFA_Element eType, + bool bOnlyChild) { ASSERT(index > -1); int32_t iCount = 0; diff --git a/xfa/fxfa/parser/cxfa_node.h b/xfa/fxfa/parser/cxfa_node.h index 2b0b476d36..c2c7605e85 100644 --- a/xfa/fxfa/parser/cxfa_node.h +++ b/xfa/fxfa/parser/cxfa_node.h @@ -153,7 +153,12 @@ class CXFA_Node : public CXFA_Object { void UpdateNameHash(); int32_t CountChildren(XFA_Element eType, bool bOnlyChild); - CXFA_Node* GetChild(int32_t index, XFA_Element eType, bool bOnlyChild); + + template <typename T> + T* GetChild(int32_t index, XFA_Element eType, bool bOnlyChild) { + return static_cast<T*>(GetChildInternal(index, eType, bOnlyChild)); + } + int32_t InsertChild(int32_t index, CXFA_Node* pNode); bool InsertChild(CXFA_Node* pNode, CXFA_Node* pBeforeNode); bool RemoveChild(CXFA_Node* pNode, bool bNotify); @@ -225,6 +230,9 @@ class CXFA_Node : public CXFA_Object { void OnRemoved(bool bNotify); pdfium::Optional<void*> GetDefaultValue(XFA_Attribute attr, XFA_AttributeType eType) const; + CXFA_Node* GetChildInternal(int32_t index, + XFA_Element eType, + bool bOnlyChild); const PropertyData* const m_Properties; const AttributeData* const m_Attributes; diff --git a/xfa/fxfa/parser/cxfa_nodelocale.cpp b/xfa/fxfa/parser/cxfa_nodelocale.cpp index 54440d5834..e7bba363cf 100644 --- a/xfa/fxfa/parser/cxfa_nodelocale.cpp +++ b/xfa/fxfa/parser/cxfa_nodelocale.cpp @@ -9,6 +9,8 @@ #include <utility> #include "core/fxcrt/xml/cxml_element.h" +#include "xfa/fxfa/parser/cxfa_calendarsymbols.h" +#include "xfa/fxfa/parser/cxfa_datetimesymbols.h" #include "xfa/fxfa/parser/cxfa_document.h" #include "xfa/fxfa/parser/cxfa_localemgr.h" #include "xfa/fxfa/parser/cxfa_node.h" @@ -69,8 +71,9 @@ WideString CXFA_NodeLocale::GetNumbericSymbol(FX_LOCALENUMSYMBOL eType) const { } WideString CXFA_NodeLocale::GetDateTimeSymbols() const { - CXFA_Node* pSymbols = - m_pLocale ? m_pLocale->GetChild(0, XFA_Element::DateTimeSymbols, false) + CXFA_DateTimeSymbols* pSymbols = + m_pLocale ? m_pLocale->GetChild<CXFA_DateTimeSymbols>( + 0, XFA_Element::DateTimeSymbols, false) : nullptr; return pSymbols ? pSymbols->JSObject()->GetContent(false) : WideString(); } @@ -147,7 +150,7 @@ CXFA_Node* CXFA_NodeLocale::GetNodeByName(CXFA_Node* pParent, WideString CXFA_NodeLocale::GetSymbol(XFA_Element eElement, const WideStringView& symbol_type) const { CXFA_Node* pSymbols = - m_pLocale ? m_pLocale->GetChild(0, eElement, false) : nullptr; + m_pLocale ? m_pLocale->GetChild<CXFA_Node>(0, eElement, false) : nullptr; CXFA_Node* pSymbol = GetNodeByName(pSymbols, symbol_type); return pSymbol ? pSymbol->JSObject()->GetContent(false) : WideString(); } @@ -155,8 +158,9 @@ WideString CXFA_NodeLocale::GetSymbol(XFA_Element eElement, WideString CXFA_NodeLocale::GetCalendarSymbol(XFA_Element eElement, int index, bool bAbbr) const { - CXFA_Node* pCalendar = - m_pLocale ? m_pLocale->GetChild(0, XFA_Element::CalendarSymbols, false) + CXFA_CalendarSymbols* pCalendar = + m_pLocale ? m_pLocale->GetChild<CXFA_CalendarSymbols>( + 0, XFA_Element::CalendarSymbols, false) : nullptr; if (!pCalendar) return WideString(); @@ -164,7 +168,8 @@ WideString CXFA_NodeLocale::GetCalendarSymbol(XFA_Element eElement, CXFA_Node* pNode = pCalendar->GetFirstChildByClass(eElement); for (; pNode; pNode = pNode->GetNextSameClassSibling(eElement)) { if (pNode->JSObject()->GetBoolean(XFA_Attribute::Abbr) == bAbbr) { - CXFA_Node* pSymbol = pNode->GetChild(index, XFA_Element::Unknown, false); + CXFA_Node* pSymbol = + pNode->GetChild<CXFA_Node>(index, XFA_Element::Unknown, false); return pSymbol ? pSymbol->JSObject()->GetContent(false) : WideString(); } } diff --git a/xfa/fxfa/parser/cxfa_strokedata.cpp b/xfa/fxfa/parser/cxfa_strokedata.cpp index 96d2866c37..4c4e810555 100644 --- a/xfa/fxfa/parser/cxfa_strokedata.cpp +++ b/xfa/fxfa/parser/cxfa_strokedata.cpp @@ -6,6 +6,7 @@ #include "xfa/fxfa/parser/cxfa_strokedata.h" +#include "xfa/fxfa/parser/cxfa_color.h" #include "xfa/fxfa/parser/cxfa_measurement.h" #include "xfa/fxfa/parser/cxfa_node.h" #include "xfa/fxfa/parser/xfa_utils.h" @@ -51,7 +52,8 @@ FX_ARGB CXFA_StrokeData::GetColor() const { if (!m_pNode) return 0xFF000000; - CXFA_Node* pNode = m_pNode->GetChild(0, XFA_Element::Color, false); + CXFA_Color* pNode = + m_pNode->GetChild<CXFA_Color>(0, XFA_Element::Color, false); if (!pNode) return 0xFF000000; diff --git a/xfa/fxfa/parser/cxfa_validate.cpp b/xfa/fxfa/parser/cxfa_validate.cpp index 57cf5d4ecf..49f7f1aeff 100644 --- a/xfa/fxfa/parser/cxfa_validate.cpp +++ b/xfa/fxfa/parser/cxfa_validate.cpp @@ -8,6 +8,7 @@ #include "fxjs/xfa/cjx_validate.h" #include "third_party/base/ptr_util.h" +#include "xfa/fxfa/parser/cxfa_picture.h" #include "xfa/fxfa/parser/cxfa_script.h" namespace { @@ -141,10 +142,10 @@ void CXFA_Validate::SetMessageText(const WideString& wsMessageType, } WideString CXFA_Validate::GetPicture() { - CXFA_Node* pNode = GetChild(0, XFA_Element::Picture, false); + CXFA_Picture* pNode = GetChild<CXFA_Picture>(0, XFA_Element::Picture, false); return pNode ? pNode->JSObject()->GetContent(false) : L""; } CXFA_Script* CXFA_Validate::GetScript() { - return static_cast<CXFA_Script*>(GetChild(0, XFA_Element::Script, false)); + return GetChild<CXFA_Script>(0, XFA_Element::Script, false); } diff --git a/xfa/fxfa/parser/cxfa_widgetdata.cpp b/xfa/fxfa/parser/cxfa_widgetdata.cpp index bb1f259d00..38f85e715b 100644 --- a/xfa/fxfa/parser/cxfa_widgetdata.cpp +++ b/xfa/fxfa/parser/cxfa_widgetdata.cpp @@ -10,11 +10,17 @@ #include "core/fxcrt/fx_extension.h" #include "third_party/base/stl_util.h" #include "xfa/fxfa/cxfa_ffnotify.h" +#include "xfa/fxfa/parser/cxfa_comb.h" +#include "xfa/fxfa/parser/cxfa_decimal.h" #include "xfa/fxfa/parser/cxfa_document.h" #include "xfa/fxfa/parser/cxfa_eventdata.h" +#include "xfa/fxfa/parser/cxfa_format.h" +#include "xfa/fxfa/parser/cxfa_items.h" #include "xfa/fxfa/parser/cxfa_localevalue.h" #include "xfa/fxfa/parser/cxfa_measurement.h" #include "xfa/fxfa/parser/cxfa_node.h" +#include "xfa/fxfa/parser/cxfa_picture.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_utils.h" @@ -165,9 +171,12 @@ CXFA_Node* CreateUIChild(CXFA_Node* pNode, XFA_Element& eWidgetType) { switch (pUIChild->GetElementType()) { case XFA_Element::CheckButton: { eValueType = XFA_Element::Text; - if (CXFA_Node* pItems = pNode->GetChild(0, XFA_Element::Items, false)) { - if (CXFA_Node* pItem = pItems->GetChild(0, XFA_Element::Unknown, false)) + 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; } @@ -402,7 +411,8 @@ XFA_AttributeEnum CXFA_WidgetData::GetButtonHighlight() { } bool CXFA_WidgetData::HasButtonRollover() const { - CXFA_Node* pItems = m_pNode->GetChild(0, XFA_Element::Items, false); + CXFA_Items* pItems = + m_pNode->GetChild<CXFA_Items>(0, XFA_Element::Items, false); if (!pItems) return false; @@ -415,7 +425,8 @@ bool CXFA_WidgetData::HasButtonRollover() const { } bool CXFA_WidgetData::HasButtonDown() const { - CXFA_Node* pItems = m_pNode->GetChild(0, XFA_Element::Items, false); + CXFA_Items* pItems = + m_pNode->GetChild<CXFA_Items>(0, XFA_Element::Items, false); if (!pItems) return false; @@ -468,7 +479,8 @@ XFA_CHECKSTATE CXFA_WidgetData::GetCheckState() { if (wsValue.IsEmpty()) return XFA_CHECKSTATE_Off; - if (CXFA_Node* pItems = m_pNode->GetChild(0, XFA_Element::Items, false)) { + if (CXFA_Items* pItems = + m_pNode->GetChild<CXFA_Items>(0, XFA_Element::Items, false)) { CXFA_Node* pText = pItems->GetNodeItem(XFA_NODEITEM_FirstChild); int32_t i = 0; while (pText) { @@ -489,7 +501,8 @@ void CXFA_WidgetData::SetCheckState(XFA_CHECKSTATE eCheckState, bool bNotify) { if (exclGroup.HasValidNode()) { WideString wsValue; if (eCheckState != XFA_CHECKSTATE_Off) { - if (CXFA_Node* pItems = m_pNode->GetChild(0, XFA_Element::Items, false)) { + if (CXFA_Items* pItems = + m_pNode->GetChild<CXFA_Items>(0, XFA_Element::Items, false)) { CXFA_Node* pText = pItems->GetNodeItem(XFA_NODEITEM_FirstChild); if (pText) wsValue = pText->JSObject()->GetContent(false); @@ -501,7 +514,8 @@ void CXFA_WidgetData::SetCheckState(XFA_CHECKSTATE eCheckState, bool bNotify) { if (pChild->GetElementType() != XFA_Element::Field) continue; - CXFA_Node* pItem = pChild->GetChild(0, XFA_Element::Items, false); + CXFA_Items* pItem = + pChild->GetChild<CXFA_Items>(0, XFA_Element::Items, false); if (!pItem) continue; @@ -523,7 +537,8 @@ void CXFA_WidgetData::SetCheckState(XFA_CHECKSTATE eCheckState, bool bNotify) { } exclGroup.SyncValue(wsValue, bNotify); } else { - CXFA_Node* pItems = m_pNode->GetChild(0, XFA_Element::Items, false); + CXFA_Items* pItems = + m_pNode->GetChild<CXFA_Items>(0, XFA_Element::Items, false); if (!pItems) return; @@ -590,7 +605,8 @@ void CXFA_WidgetData::SetSelectedMemberByValue(const WideStringView& wsValue, if (pNode->GetElementType() != XFA_Element::Field) continue; - CXFA_Node* pItem = pNode->GetChild(0, XFA_Element::Items, false); + CXFA_Items* pItem = + pNode->GetChild<CXFA_Items>(0, XFA_Element::Items, false); if (!pItem) continue; @@ -735,7 +751,8 @@ pdfium::Optional<WideString> CXFA_WidgetData::GetChoiceListItem( if (!pItems) return {}; - CXFA_Node* pItem = pItems->GetChild(nIndex, XFA_Element::Unknown, false); + CXFA_Node* pItem = + pItems->GetChild<CXFA_Node>(nIndex, XFA_Element::Unknown, false); if (pItem) return {pItem->JSObject()->GetContent(false)}; return {}; @@ -1024,7 +1041,7 @@ void CXFA_WidgetData::GetItemLabel(const WideStringView& wsValue, return; CXFA_Node* pText = - pLabelItems->GetChild(iSearch, XFA_Element::Unknown, false); + pLabelItems->GetChild<CXFA_Node>(iSearch, XFA_Element::Unknown, false); if (pText) wsLabel = pText->JSObject()->GetContent(false); } @@ -1067,7 +1084,8 @@ WideString CXFA_WidgetData::GetItemValue(const WideStringView& wsLabel) { if (iSearch < 0) return L""; - CXFA_Node* pText = pSaveItems->GetChild(iSearch, XFA_Element::Unknown, false); + CXFA_Node* pText = + pSaveItems->GetChild<CXFA_Node>(iSearch, XFA_Element::Unknown, false); return pText ? pText->JSObject()->GetContent(false) : L""; } @@ -1128,7 +1146,8 @@ pdfium::Optional<int32_t> CXFA_WidgetData::GetNumberOfCells() { CXFA_Node* pUIChild = GetUIChild(); if (!pUIChild) return {}; - if (CXFA_Node* pNode = pUIChild->GetChild(0, XFA_Element::Comb, false)) + if (CXFA_Comb* pNode = + pUIChild->GetChild<CXFA_Comb>(0, XFA_Element::Comb, false)) return {pNode->JSObject()->GetInteger(XFA_Attribute::NumberOfCells)}; return {}; } @@ -1293,7 +1312,8 @@ bool CXFA_WidgetData::IsMultiLine() { } std::pair<XFA_Element, int32_t> CXFA_WidgetData::GetMaxChars() { - if (CXFA_Node* pNode = m_pNode->GetChild(0, XFA_Element::Value, false)) { + if (CXFA_Value* pNode = + m_pNode->GetChild<CXFA_Value>(0, XFA_Element::Value, false)) { if (CXFA_Node* pChild = pNode->GetNodeItem(XFA_NODEITEM_FirstChild)) { switch (pChild->GetElementType()) { case XFA_Element::Text: @@ -1313,11 +1333,13 @@ std::pair<XFA_Element, int32_t> CXFA_WidgetData::GetMaxChars() { } int32_t CXFA_WidgetData::GetFracDigits() { - CXFA_Node* pNode = m_pNode->GetChild(0, XFA_Element::Value, false); + CXFA_Value* pNode = + m_pNode->GetChild<CXFA_Value>(0, XFA_Element::Value, false); if (!pNode) return -1; - CXFA_Node* pChild = pNode->GetChild(0, XFA_Element::Decimal, false); + CXFA_Decimal* pChild = + pNode->GetChild<CXFA_Decimal>(0, XFA_Element::Decimal, false); if (!pChild) return -1; @@ -1327,11 +1349,13 @@ int32_t CXFA_WidgetData::GetFracDigits() { } int32_t CXFA_WidgetData::GetLeadDigits() { - CXFA_Node* pNode = m_pNode->GetChild(0, XFA_Element::Value, false); + CXFA_Value* pNode = + m_pNode->GetChild<CXFA_Value>(0, XFA_Element::Value, false); if (!pNode) return -1; - CXFA_Node* pChild = pNode->GetChild(0, XFA_Element::Decimal, false); + CXFA_Decimal* pChild = + pNode->GetChild<CXFA_Decimal>(0, XFA_Element::Decimal, false); if (!pChild) return -1; @@ -1394,10 +1418,10 @@ WideString CXFA_WidgetData::GetPictureContent(XFA_VALUEPICTURE ePicture) { CXFA_LocaleValue widgetValue = XFA_GetLocaleValue(this); switch (ePicture) { case XFA_VALUEPICTURE_Display: { - if (CXFA_Node* pFormat = - m_pNode->GetChild(0, XFA_Element::Format, false)) { - if (CXFA_Node* pPicture = - pFormat->GetChild(0, XFA_Element::Picture, false)) { + if (CXFA_Format* pFormat = + m_pNode->GetChild<CXFA_Format>(0, XFA_Element::Format, false)) { + if (CXFA_Picture* pPicture = pFormat->GetChild<CXFA_Picture>( + 0, XFA_Element::Picture, false)) { pdfium::Optional<WideString> picture = pPicture->JSObject()->TryContent(false, true); if (picture) @@ -1426,10 +1450,10 @@ WideString CXFA_WidgetData::GetPictureContent(XFA_VALUEPICTURE ePicture) { } } case XFA_VALUEPICTURE_Edit: { - CXFA_Node* pUI = m_pNode->GetChild(0, XFA_Element::Ui, false); + CXFA_Ui* pUI = m_pNode->GetChild<CXFA_Ui>(0, XFA_Element::Ui, false); if (pUI) { - if (CXFA_Node* pPicture = - pUI->GetChild(0, XFA_Element::Picture, false)) { + if (CXFA_Picture* pPicture = + pUI->GetChild<CXFA_Picture>(0, XFA_Element::Picture, false)) { pdfium::Optional<WideString> picture = pPicture->JSObject()->TryContent(false, true); if (picture) @@ -1574,7 +1598,8 @@ WideString CXFA_WidgetData::GetFormatDataValue(const WideString& wsValue) { WideString wsFormattedValue = wsValue; if (IFX_Locale* pLocale = GetLocale()) { ASSERT(GetNode()); - CXFA_Node* pNodeValue = GetNode()->GetChild(0, XFA_Element::Value, false); + CXFA_Value* pNodeValue = + GetNode()->GetChild<CXFA_Value>(0, XFA_Element::Value, false); if (!pNodeValue) return wsValue; diff --git a/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp b/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp index 30d45787f5..22b339aba5 100644 --- a/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp +++ b/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp @@ -16,6 +16,7 @@ #include "third_party/base/logging.h" #include "third_party/base/stl_util.h" #include "xfa/fxfa/parser/cxfa_document.h" +#include "xfa/fxfa/parser/cxfa_items.h" #include "xfa/fxfa/parser/cxfa_layoutprocessor.h" #include "xfa/fxfa/parser/cxfa_localemgr.h" #include "xfa/fxfa/parser/cxfa_node.h" @@ -194,8 +195,8 @@ void CreateDataBinding(CXFA_Node* pFormNode, if (pChild->GetElementType() != XFA_Element::Field) continue; - auto* pValue = static_cast<CXFA_Value*>( - pChild->GetChild(0, XFA_Element::Value, false)); + auto* pValue = + pChild->GetChild<CXFA_Value>(0, XFA_Element::Value, false); if (!pValue) continue; @@ -203,7 +204,8 @@ void CreateDataBinding(CXFA_Node* pFormNode, if (wsValue.IsEmpty()) continue; - CXFA_Node* pItems = pChild->GetChild(0, XFA_Element::Items, false); + CXFA_Items* pItems = + pChild->GetChild<CXFA_Items>(0, XFA_Element::Items, false); if (!pItems) continue; @@ -233,7 +235,8 @@ void CreateDataBinding(CXFA_Node* pFormNode, CXFA_Node* pValue = pChild->JSObject()->GetProperty(0, XFA_Element::Value, true); - CXFA_Node* pItems = pChild->GetChild(0, XFA_Element::Items, false); + CXFA_Items* pItems = + pChild->GetChild<CXFA_Items>(0, XFA_Element::Items, false); CXFA_Node* pText = pItems ? pItems->GetNodeItem(XFA_NODEITEM_FirstChild) : nullptr; if (pText) diff --git a/xfa/fxfa/parser/xfa_utils.cpp b/xfa/fxfa/parser/xfa_utils.cpp index 6706bb64ee..5f00f3e926 100644 --- a/xfa/fxfa/parser/xfa_utils.cpp +++ b/xfa/fxfa/parser/xfa_utils.cpp @@ -22,6 +22,8 @@ #include "xfa/fxfa/parser/cxfa_localevalue.h" #include "xfa/fxfa/parser/cxfa_measurement.h" #include "xfa/fxfa/parser/cxfa_node.h" +#include "xfa/fxfa/parser/cxfa_ui.h" +#include "xfa/fxfa/parser/cxfa_value.h" #include "xfa/fxfa/parser/xfa_basic_data.h" namespace { @@ -422,15 +424,15 @@ int XFA_GetMaxFractionalScale() { } CXFA_LocaleValue XFA_GetLocaleValue(CXFA_WidgetData* pWidgetData) { - CXFA_Node* pNodeValue = - pWidgetData->GetNode()->GetChild(0, XFA_Element::Value, false); - if (!pNodeValue) { + CXFA_Value* pNodeValue = pWidgetData->GetNode()->GetChild<CXFA_Value>( + 0, XFA_Element::Value, false); + if (!pNodeValue) return CXFA_LocaleValue(); - } + CXFA_Node* pValueChild = pNodeValue->GetNodeItem(XFA_NODEITEM_FirstChild); - if (!pValueChild) { + if (!pValueChild) return CXFA_LocaleValue(); - } + int32_t iVTType = XFA_VT_NULL; switch (pValueChild->GetElementType()) { case XFA_Element::Decimal: @@ -564,20 +566,21 @@ void XFA_DataExporter_RegenerateFormFile( } bool XFA_FieldIsMultiListBox(CXFA_Node* pFieldNode) { - bool bRet = false; if (!pFieldNode) - return bRet; - - CXFA_Node* pUIChild = pFieldNode->GetChild(0, XFA_Element::Ui, false); - if (pUIChild) { - CXFA_Node* pFirstChild = pUIChild->GetNodeItem(XFA_NODEITEM_FirstChild); - if (pFirstChild && - pFirstChild->GetElementType() == XFA_Element::ChoiceList) { - bRet = pFirstChild->JSObject()->GetEnum(XFA_Attribute::Open) == - XFA_AttributeEnum::MultiSelect; - } + return false; + + CXFA_Ui* pUIChild = pFieldNode->GetChild<CXFA_Ui>(0, XFA_Element::Ui, false); + if (!pUIChild) + return false; + + CXFA_Node* pFirstChild = pUIChild->GetNodeItem(XFA_NODEITEM_FirstChild); + if (!pFirstChild || + pFirstChild->GetElementType() != XFA_Element::ChoiceList) { + return false; } - return bRet; + + return pFirstChild->JSObject()->GetEnum(XFA_Attribute::Open) == + XFA_AttributeEnum::MultiSelect; } int32_t XFA_MapRotation(int32_t nRotation) { |