From efcae5d85f829618749461617521a076881cc493 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Wed, 29 Mar 2017 14:47:46 -0400 Subject: Split xfa_object.h apart. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This Cl splits the xfa_object.h into individual class header files and fixes the needed includes. Change-Id: Ia011ee9bc5deee5e44b8a956fa54bc2c3849cff0 Reviewed-on: https://pdfium-review.googlesource.com/3254 Reviewed-by: Nicolás Peña Commit-Queue: dsinclair --- BUILD.gn | 9 +- xfa/fxfa/app/cxfa_textlayout.cpp | 2 +- xfa/fxfa/app/xfa_fffield.cpp | 1 + xfa/fxfa/app/xfa_ffnotify.cpp | 1 + xfa/fxfa/app/xfa_fftextedit.cpp | 1 + xfa/fxfa/app/xfa_ffwidgetacc.cpp | 1 + xfa/fxfa/cxfa_ffdoc.cpp | 1 + xfa/fxfa/cxfa_ffdochandler.cpp | 1 + xfa/fxfa/cxfa_ffdocview.cpp | 2 + xfa/fxfa/cxfa_ffpageview.cpp | 1 + xfa/fxfa/cxfa_ffpageview.h | 1 + xfa/fxfa/cxfa_ffwidget.cpp | 1 + xfa/fxfa/cxfa_ffwidget.h | 1 + xfa/fxfa/cxfa_ffwidgethandler.cpp | 1 + xfa/fxfa/cxfa_widgetacc.cpp | 1 + xfa/fxfa/cxfa_widgetacciterator.h | 2 +- xfa/fxfa/fm2js/xfa_fm2jscontext.cpp | 2 + xfa/fxfa/fm2js/xfa_fm2jscontext.h | 2 + xfa/fxfa/parser/cscript_datawindow.cpp | 1 - xfa/fxfa/parser/cscript_datawindow.h | 5 +- xfa/fxfa/parser/cscript_eventpseudomodel.cpp | 1 - xfa/fxfa/parser/cscript_eventpseudomodel.h | 2 +- xfa/fxfa/parser/cscript_hostpseudomodel.cpp | 2 +- xfa/fxfa/parser/cscript_hostpseudomodel.h | 7 +- xfa/fxfa/parser/cscript_layoutpseudomodel.cpp | 3 +- xfa/fxfa/parser/cscript_layoutpseudomodel.h | 4 +- xfa/fxfa/parser/cscript_logpseudomodel.cpp | 1 - xfa/fxfa/parser/cscript_logpseudomodel.h | 5 +- xfa/fxfa/parser/cscript_signaturepseudomodel.cpp | 1 - xfa/fxfa/parser/cscript_signaturepseudomodel.h | 5 +- xfa/fxfa/parser/cxfa_arraynodelist.cpp | 3 +- xfa/fxfa/parser/cxfa_arraynodelist.h | 35 + xfa/fxfa/parser/cxfa_assist.cpp | 2 +- xfa/fxfa/parser/cxfa_attachnodelist.cpp | 12 +- xfa/fxfa/parser/cxfa_attachnodelist.h | 30 + xfa/fxfa/parser/cxfa_bind.cpp | 2 +- xfa/fxfa/parser/cxfa_binditems.cpp | 2 +- xfa/fxfa/parser/cxfa_box.cpp | 2 +- xfa/fxfa/parser/cxfa_calculate.cpp | 2 +- xfa/fxfa/parser/cxfa_caption.cpp | 2 +- xfa/fxfa/parser/cxfa_containerlayoutitem.cpp | 1 + xfa/fxfa/parser/cxfa_contentlayoutitem.cpp | 2 + xfa/fxfa/parser/cxfa_contentlayoutitem.h | 2 + xfa/fxfa/parser/cxfa_data.cpp | 2 +- xfa/fxfa/parser/cxfa_dataexporter.cpp | 3 +- xfa/fxfa/parser/cxfa_dataimporter.cpp | 2 +- xfa/fxfa/parser/cxfa_document.cpp | 3 +- xfa/fxfa/parser/cxfa_document.h | 1 - xfa/fxfa/parser/cxfa_event.cpp | 2 +- xfa/fxfa/parser/cxfa_exdata.cpp | 2 +- xfa/fxfa/parser/cxfa_fill.cpp | 2 +- xfa/fxfa/parser/cxfa_font.cpp | 2 +- xfa/fxfa/parser/cxfa_image.cpp | 2 +- xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp | 3 +- xfa/fxfa/parser/cxfa_layoutitem.cpp | 1 + xfa/fxfa/parser/cxfa_layoutpagemgr.cpp | 5 +- xfa/fxfa/parser/cxfa_layoutprocessor.cpp | 2 +- xfa/fxfa/parser/cxfa_layoutprocessor.h | 1 - xfa/fxfa/parser/cxfa_line.cpp | 2 +- xfa/fxfa/parser/cxfa_localemgr.cpp | 2 +- xfa/fxfa/parser/cxfa_localevalue.cpp | 1 - xfa/fxfa/parser/cxfa_margin.cpp | 2 - xfa/fxfa/parser/cxfa_node.cpp | 6 +- xfa/fxfa/parser/cxfa_node.h | 608 +++++++++++++++ xfa/fxfa/parser/cxfa_nodehelper.cpp | 2 +- xfa/fxfa/parser/cxfa_nodehelper.h | 1 - xfa/fxfa/parser/cxfa_nodelist.cpp | 3 +- xfa/fxfa/parser/cxfa_nodelist.h | 40 + xfa/fxfa/parser/cxfa_nodelocale.cpp | 2 +- xfa/fxfa/parser/cxfa_nodelocale.h | 4 +- xfa/fxfa/parser/cxfa_object.cpp | 40 +- xfa/fxfa/parser/cxfa_object.h | 100 +++ xfa/fxfa/parser/cxfa_occur.cpp | 2 +- xfa/fxfa/parser/cxfa_para.cpp | 2 +- xfa/fxfa/parser/cxfa_resolveprocessor.cpp | 3 +- xfa/fxfa/parser/cxfa_resolveprocessor.h | 1 - xfa/fxfa/parser/cxfa_script.cpp | 2 +- xfa/fxfa/parser/cxfa_scriptcontext.cpp | 5 +- xfa/fxfa/parser/cxfa_simple_parser.cpp | 1 + xfa/fxfa/parser/cxfa_stroke.cpp | 3 +- xfa/fxfa/parser/cxfa_submit.cpp | 2 +- xfa/fxfa/parser/cxfa_text.cpp | 2 +- xfa/fxfa/parser/cxfa_thisproxy.cpp | 12 +- xfa/fxfa/parser/cxfa_thisproxy.h | 27 + xfa/fxfa/parser/cxfa_tooltip.cpp | 2 +- .../cxfa_traversestrategy_xfacontainernode.h | 33 + xfa/fxfa/parser/cxfa_traversestrategy_xfanode.h | 28 + xfa/fxfa/parser/cxfa_validate.cpp | 3 +- xfa/fxfa/parser/cxfa_value.cpp | 2 +- xfa/fxfa/parser/cxfa_widgetdata.cpp | 3 +- xfa/fxfa/parser/cxfa_widgetdata.h | 1 - xfa/fxfa/parser/cxfa_xmllocale.cpp | 1 - xfa/fxfa/parser/cxfa_xmllocale.h | 1 - xfa/fxfa/parser/xfa_basic_data.cpp | 2 +- xfa/fxfa/parser/xfa_basic_data_element_script.cpp | 2 + xfa/fxfa/parser/xfa_document_datamerger_imp.cpp | 4 +- xfa/fxfa/parser/xfa_document_datamerger_imp.h | 5 +- xfa/fxfa/parser/xfa_object.h | 818 --------------------- xfa/fxfa/parser/xfa_utils.cpp | 2 +- 99 files changed, 1062 insertions(+), 918 deletions(-) create mode 100644 xfa/fxfa/parser/cxfa_arraynodelist.h create mode 100644 xfa/fxfa/parser/cxfa_attachnodelist.h create mode 100644 xfa/fxfa/parser/cxfa_node.h create mode 100644 xfa/fxfa/parser/cxfa_nodelist.h create mode 100644 xfa/fxfa/parser/cxfa_object.h create mode 100644 xfa/fxfa/parser/cxfa_thisproxy.h create mode 100644 xfa/fxfa/parser/cxfa_traversestrategy_xfacontainernode.h create mode 100644 xfa/fxfa/parser/cxfa_traversestrategy_xfanode.h delete mode 100644 xfa/fxfa/parser/xfa_object.h diff --git a/BUILD.gn b/BUILD.gn index 562afffac7..4bcc9868d4 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -1626,9 +1626,11 @@ if (pdf_enable_xfa) { "xfa/fxfa/parser/cscript_signaturepseudomodel.h", "xfa/fxfa/parser/cxfa_arc.h", "xfa/fxfa/parser/cxfa_arraynodelist.cpp", + "xfa/fxfa/parser/cxfa_arraynodelist.h", "xfa/fxfa/parser/cxfa_assist.cpp", "xfa/fxfa/parser/cxfa_assist.h", "xfa/fxfa/parser/cxfa_attachnodelist.cpp", + "xfa/fxfa/parser/cxfa_attachnodelist.h", "xfa/fxfa/parser/cxfa_bind.cpp", "xfa/fxfa/parser/cxfa_bind.h", "xfa/fxfa/parser/cxfa_binditems.cpp", @@ -1686,12 +1688,15 @@ if (pdf_enable_xfa) { "xfa/fxfa/parser/cxfa_measurement.cpp", "xfa/fxfa/parser/cxfa_measurement.h", "xfa/fxfa/parser/cxfa_node.cpp", + "xfa/fxfa/parser/cxfa_node.h", "xfa/fxfa/parser/cxfa_nodehelper.cpp", "xfa/fxfa/parser/cxfa_nodehelper.h", "xfa/fxfa/parser/cxfa_nodelist.cpp", + "xfa/fxfa/parser/cxfa_nodelist.h", "xfa/fxfa/parser/cxfa_nodelocale.cpp", "xfa/fxfa/parser/cxfa_nodelocale.h", "xfa/fxfa/parser/cxfa_object.cpp", + "xfa/fxfa/parser/cxfa_object.h", "xfa/fxfa/parser/cxfa_occur.cpp", "xfa/fxfa/parser/cxfa_occur.h", "xfa/fxfa/parser/cxfa_para.cpp", @@ -1712,6 +1717,7 @@ if (pdf_enable_xfa) { "xfa/fxfa/parser/cxfa_text.cpp", "xfa/fxfa/parser/cxfa_text.h", "xfa/fxfa/parser/cxfa_thisproxy.cpp", + "xfa/fxfa/parser/cxfa_thisproxy.h", "xfa/fxfa/parser/cxfa_timezoneprovider.cpp", "xfa/fxfa/parser/cxfa_timezoneprovider.h", "xfa/fxfa/parser/cxfa_tooltip.cpp", @@ -1719,6 +1725,8 @@ if (pdf_enable_xfa) { "xfa/fxfa/parser/cxfa_traversestrategy_contentareacontainerlayoutitem.h", "xfa/fxfa/parser/cxfa_traversestrategy_contentlayoutitem.h", "xfa/fxfa/parser/cxfa_traversestrategy_layoutitem.h", + "xfa/fxfa/parser/cxfa_traversestrategy_xfacontainernode.h", + "xfa/fxfa/parser/cxfa_traversestrategy_xfanode.h", "xfa/fxfa/parser/cxfa_validate.cpp", "xfa/fxfa/parser/cxfa_validate.h", "xfa/fxfa/parser/cxfa_value.cpp", @@ -1743,7 +1751,6 @@ if (pdf_enable_xfa) { "xfa/fxfa/parser/xfa_basic_data_packets.cpp", "xfa/fxfa/parser/xfa_document_datamerger_imp.cpp", "xfa/fxfa/parser/xfa_document_datamerger_imp.h", - "xfa/fxfa/parser/xfa_object.h", "xfa/fxfa/parser/xfa_resolvenode_rs.h", "xfa/fxfa/parser/xfa_utils.cpp", "xfa/fxfa/parser/xfa_utils.h", diff --git a/xfa/fxfa/app/cxfa_textlayout.cpp b/xfa/fxfa/app/cxfa_textlayout.cpp index 0fab077812..c5471971b6 100644 --- a/xfa/fxfa/app/cxfa_textlayout.cpp +++ b/xfa/fxfa/app/cxfa_textlayout.cpp @@ -26,8 +26,8 @@ #include "xfa/fxfa/app/xfa_ffwidgetacc.h" #include "xfa/fxfa/app/xfa_textpiece.h" #include "xfa/fxfa/parser/cxfa_font.h" +#include "xfa/fxfa/parser/cxfa_node.h" #include "xfa/fxfa/parser/cxfa_para.h" -#include "xfa/fxfa/parser/xfa_object.h" #define XFA_LOADERCNTXTFLG_FILTERSPACE 0x001 diff --git a/xfa/fxfa/app/xfa_fffield.cpp b/xfa/fxfa/app/xfa_fffield.cpp index 39109f5f28..4193af82b4 100644 --- a/xfa/fxfa/app/xfa_fffield.cpp +++ b/xfa/fxfa/app/xfa_fffield.cpp @@ -22,6 +22,7 @@ #include "xfa/fxfa/cxfa_ffdocview.h" #include "xfa/fxfa/cxfa_ffpageview.h" #include "xfa/fxfa/cxfa_ffwidget.h" +#include "xfa/fxfa/parser/cxfa_node.h" #include "xfa/fxgraphics/cfx_color.h" #include "xfa/fxgraphics/cfx_path.h" diff --git a/xfa/fxfa/app/xfa_ffnotify.cpp b/xfa/fxfa/app/xfa_ffnotify.cpp index 90648012c6..56562c9403 100644 --- a/xfa/fxfa/app/xfa_ffnotify.cpp +++ b/xfa/fxfa/app/xfa_ffnotify.cpp @@ -30,6 +30,7 @@ #include "xfa/fxfa/cxfa_ffpageview.h" #include "xfa/fxfa/cxfa_ffwidget.h" #include "xfa/fxfa/cxfa_ffwidgethandler.h" +#include "xfa/fxfa/parser/cxfa_node.h" static void XFA_FFDeleteWidgetAcc(void* pData) { delete static_cast(pData); diff --git a/xfa/fxfa/app/xfa_fftextedit.cpp b/xfa/fxfa/app/xfa_fftextedit.cpp index a8f5a3bcd0..e99fefbd73 100644 --- a/xfa/fxfa/app/xfa_fftextedit.cpp +++ b/xfa/fxfa/app/xfa_fftextedit.cpp @@ -27,6 +27,7 @@ #include "xfa/fxfa/cxfa_ffpageview.h" #include "xfa/fxfa/cxfa_ffwidget.h" #include "xfa/fxfa/parser/cxfa_localevalue.h" +#include "xfa/fxfa/parser/cxfa_node.h" CXFA_FFTextEdit::CXFA_FFTextEdit(CXFA_WidgetAcc* pDataAcc) : CXFA_FFField(pDataAcc), m_pOldDelegate(nullptr) {} diff --git a/xfa/fxfa/app/xfa_ffwidgetacc.cpp b/xfa/fxfa/app/xfa_ffwidgetacc.cpp index 98dee06728..ada78921ef 100644 --- a/xfa/fxfa/app/xfa_ffwidgetacc.cpp +++ b/xfa/fxfa/app/xfa_ffwidgetacc.cpp @@ -28,6 +28,7 @@ #include "xfa/fxfa/cxfa_fontmgr.h" #include "xfa/fxfa/parser/cxfa_layoutprocessor.h" #include "xfa/fxfa/parser/cxfa_localevalue.h" +#include "xfa/fxfa/parser/cxfa_node.h" #include "xfa/fxfa/parser/cxfa_scriptcontext.h" #include "xfa/fxfa/parser/xfa_resolvenode_rs.h" diff --git a/xfa/fxfa/cxfa_ffdoc.cpp b/xfa/fxfa/cxfa_ffdoc.cpp index e14500a725..43551008db 100644 --- a/xfa/fxfa/cxfa_ffdoc.cpp +++ b/xfa/fxfa/cxfa_ffdoc.cpp @@ -28,6 +28,7 @@ #include "xfa/fxfa/parser/cxfa_dataexporter.h" #include "xfa/fxfa/parser/cxfa_dataimporter.h" #include "xfa/fxfa/parser/cxfa_document.h" +#include "xfa/fxfa/parser/cxfa_node.h" namespace { diff --git a/xfa/fxfa/cxfa_ffdochandler.cpp b/xfa/fxfa/cxfa_ffdochandler.cpp index a71bb208fa..f926638406 100644 --- a/xfa/fxfa/cxfa_ffdochandler.cpp +++ b/xfa/fxfa/cxfa_ffdochandler.cpp @@ -8,6 +8,7 @@ #include "xfa/fxfa/cxfa_checksumcontext.h" #include "xfa/fxfa/cxfa_ffdoc.h" +#include "xfa/fxfa/parser/cxfa_node.h" #include "xfa/fxfa/parser/cxfa_scriptcontext.h" #include "xfa/fxfa/parser/xfa_resolvenode_rs.h" diff --git a/xfa/fxfa/cxfa_ffdocview.cpp b/xfa/fxfa/cxfa_ffdocview.cpp index 9708e34562..488a31f299 100644 --- a/xfa/fxfa/cxfa_ffdocview.cpp +++ b/xfa/fxfa/cxfa_ffdocview.cpp @@ -36,6 +36,8 @@ #include "xfa/fxfa/parser/cxfa_scriptcontext.h" #include "xfa/fxfa/parser/xfa_resolvenode_rs.h" +#define XFA_CalcRefCount (void*)(uintptr_t) FXBSTR_ID('X', 'F', 'A', 'R') + const XFA_ATTRIBUTEENUM gs_EventActivity[] = { XFA_ATTRIBUTEENUM_Click, XFA_ATTRIBUTEENUM_Change, XFA_ATTRIBUTEENUM_DocClose, XFA_ATTRIBUTEENUM_DocReady, diff --git a/xfa/fxfa/cxfa_ffpageview.cpp b/xfa/fxfa/cxfa_ffpageview.cpp index 4c0b3cf638..0066086d94 100644 --- a/xfa/fxfa/cxfa_ffpageview.cpp +++ b/xfa/fxfa/cxfa_ffpageview.cpp @@ -23,6 +23,7 @@ #include "xfa/fxfa/cxfa_ffdoc.h" #include "xfa/fxfa/cxfa_ffdocview.h" #include "xfa/fxfa/cxfa_ffwidget.h" +#include "xfa/fxfa/parser/cxfa_node.h" namespace { diff --git a/xfa/fxfa/cxfa_ffpageview.h b/xfa/fxfa/cxfa_ffpageview.h index a0aa5227c1..df4fc6d2c1 100644 --- a/xfa/fxfa/cxfa_ffpageview.h +++ b/xfa/fxfa/cxfa_ffpageview.h @@ -12,6 +12,7 @@ #include "xfa/fxfa/parser/cxfa_containerlayoutitem.h" #include "xfa/fxfa/parser/cxfa_contentlayoutitem.h" #include "xfa/fxfa/parser/cxfa_traversestrategy_layoutitem.h" +#include "xfa/fxfa/parser/xfa_utils.h" class CXFA_FFWidget; class CXFA_FFDocView; diff --git a/xfa/fxfa/cxfa_ffwidget.cpp b/xfa/fxfa/cxfa_ffwidget.cpp index a74c6d7057..c815e1ccdc 100644 --- a/xfa/fxfa/cxfa_ffwidget.cpp +++ b/xfa/fxfa/cxfa_ffwidget.cpp @@ -26,6 +26,7 @@ #include "xfa/fxfa/cxfa_ffpageview.h" #include "xfa/fxfa/cxfa_widgetacc.h" #include "xfa/fxfa/parser/cxfa_corner.h" +#include "xfa/fxfa/parser/cxfa_node.h" #include "xfa/fxgraphics/cfx_color.h" #include "xfa/fxgraphics/cfx_graphics.h" #include "xfa/fxgraphics/cfx_path.h" diff --git a/xfa/fxfa/cxfa_ffwidget.h b/xfa/fxfa/cxfa_ffwidget.h index ef3d908221..35a36002c7 100644 --- a/xfa/fxfa/cxfa_ffwidget.h +++ b/xfa/fxfa/cxfa_ffwidget.h @@ -26,6 +26,7 @@ inline float XFA_UnitPx2Pt(float fPx, float fDpi) { } #define XFA_FLOAT_PERCISION 0.001f +#define XFA_CalcData (void*)(uintptr_t) FXBSTR_ID('X', 'F', 'A', 'C') enum XFA_WIDGETITEM { XFA_WIDGETITEM_Parent, diff --git a/xfa/fxfa/cxfa_ffwidgethandler.cpp b/xfa/fxfa/cxfa_ffwidgethandler.cpp index 0af69da016..ffc1c27070 100644 --- a/xfa/fxfa/cxfa_ffwidgethandler.cpp +++ b/xfa/fxfa/cxfa_ffwidgethandler.cpp @@ -16,6 +16,7 @@ #include "xfa/fxfa/cxfa_ffwidget.h" #include "xfa/fxfa/parser/cxfa_layoutprocessor.h" #include "xfa/fxfa/parser/cxfa_measurement.h" +#include "xfa/fxfa/parser/cxfa_node.h" CXFA_FFWidgetHandler::CXFA_FFWidgetHandler(CXFA_FFDocView* pDocView) : m_pDocView(pDocView) {} diff --git a/xfa/fxfa/cxfa_widgetacc.cpp b/xfa/fxfa/cxfa_widgetacc.cpp index 1db2bcef0f..863ab83e73 100644 --- a/xfa/fxfa/cxfa_widgetacc.cpp +++ b/xfa/fxfa/cxfa_widgetacc.cpp @@ -21,6 +21,7 @@ #include "xfa/fxfa/cxfa_fontmgr.h" #include "xfa/fxfa/parser/cxfa_layoutprocessor.h" #include "xfa/fxfa/parser/cxfa_localevalue.h" +#include "xfa/fxfa/parser/cxfa_node.h" #include "xfa/fxfa/parser/cxfa_scriptcontext.h" #include "xfa/fxfa/parser/xfa_utils.h" diff --git a/xfa/fxfa/cxfa_widgetacciterator.h b/xfa/fxfa/cxfa_widgetacciterator.h index 6e9da72941..ab18e833c2 100644 --- a/xfa/fxfa/cxfa_widgetacciterator.h +++ b/xfa/fxfa/cxfa_widgetacciterator.h @@ -7,7 +7,7 @@ #ifndef XFA_FXFA_CXFA_WIDGETACCITERATOR_H_ #define XFA_FXFA_CXFA_WIDGETACCITERATOR_H_ -#include "xfa/fxfa/parser/xfa_object.h" +#include "xfa/fxfa/parser/cxfa_traversestrategy_xfacontainernode.h" class CXFA_Node; class CXFA_WidgetAcc; diff --git a/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp b/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp index 83f65edd4a..5ec6215336 100644 --- a/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp +++ b/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp @@ -21,8 +21,10 @@ #include "xfa/fxfa/fm2js/xfa_program.h" #include "xfa/fxfa/parser/cxfa_document.h" #include "xfa/fxfa/parser/cxfa_localevalue.h" +#include "xfa/fxfa/parser/cxfa_node.h" #include "xfa/fxfa/parser/cxfa_scriptcontext.h" #include "xfa/fxfa/parser/cxfa_timezoneprovider.h" +#include "xfa/fxfa/parser/xfa_utils.h" namespace { diff --git a/xfa/fxfa/fm2js/xfa_fm2jscontext.h b/xfa/fxfa/fm2js/xfa_fm2jscontext.h index 29591f4352..d7f00091ed 100644 --- a/xfa/fxfa/fm2js/xfa_fm2jscontext.h +++ b/xfa/fxfa/fm2js/xfa_fm2jscontext.h @@ -14,6 +14,8 @@ #include "fxjs/cfxjse_context.h" #include "xfa/fxfa/parser/xfa_resolvenode_rs.h" +class CXFA_Document; + class CXFA_FM2JSContext : public CFXJSE_HostObject { public: CXFA_FM2JSContext(v8::Isolate* pScriptIsolate, diff --git a/xfa/fxfa/parser/cscript_datawindow.cpp b/xfa/fxfa/parser/cscript_datawindow.cpp index e7b4d2c56c..e2d9f043d1 100644 --- a/xfa/fxfa/parser/cscript_datawindow.cpp +++ b/xfa/fxfa/parser/cscript_datawindow.cpp @@ -9,7 +9,6 @@ #include "fxjs/cfxjse_arguments.h" #include "xfa/fxfa/parser/cxfa_document.h" #include "xfa/fxfa/parser/cxfa_localemgr.h" -#include "xfa/fxfa/parser/xfa_object.h" #include "xfa/fxfa/parser/xfa_utils.h" CScript_DataWindow::CScript_DataWindow(CXFA_Document* pDocument) diff --git a/xfa/fxfa/parser/cscript_datawindow.h b/xfa/fxfa/parser/cscript_datawindow.h index e41b7fe17d..ae12316891 100644 --- a/xfa/fxfa/parser/cscript_datawindow.h +++ b/xfa/fxfa/parser/cscript_datawindow.h @@ -7,8 +7,9 @@ #ifndef XFA_FXFA_PARSER_CSCRIPT_DATAWINDOW_H_ #define XFA_FXFA_PARSER_CSCRIPT_DATAWINDOW_H_ -#include "fxjs/cfxjse_arguments.h" -#include "xfa/fxfa/parser/xfa_object.h" +#include "xfa/fxfa/parser/cxfa_object.h" + +class CFXJSE_Arguments; class CScript_DataWindow : public CXFA_Object { public: diff --git a/xfa/fxfa/parser/cscript_eventpseudomodel.cpp b/xfa/fxfa/parser/cscript_eventpseudomodel.cpp index 6ce8114a02..c57b0bdc78 100644 --- a/xfa/fxfa/parser/cscript_eventpseudomodel.cpp +++ b/xfa/fxfa/parser/cscript_eventpseudomodel.cpp @@ -13,7 +13,6 @@ #include "xfa/fxfa/parser/cxfa_document.h" #include "xfa/fxfa/parser/cxfa_localemgr.h" #include "xfa/fxfa/parser/cxfa_scriptcontext.h" -#include "xfa/fxfa/parser/xfa_object.h" #include "xfa/fxfa/parser/xfa_utils.h" namespace { diff --git a/xfa/fxfa/parser/cscript_eventpseudomodel.h b/xfa/fxfa/parser/cscript_eventpseudomodel.h index e50c5ac187..dfad255d7e 100644 --- a/xfa/fxfa/parser/cscript_eventpseudomodel.h +++ b/xfa/fxfa/parser/cscript_eventpseudomodel.h @@ -8,7 +8,7 @@ #define XFA_FXFA_PARSER_CSCRIPT_EVENTPSEUDOMODEL_H_ #include "fxjs/cfxjse_arguments.h" -#include "xfa/fxfa/parser/xfa_object.h" +#include "xfa/fxfa/parser/cxfa_object.h" enum class XFA_Event { Change = 0, diff --git a/xfa/fxfa/parser/cscript_hostpseudomodel.cpp b/xfa/fxfa/parser/cscript_hostpseudomodel.cpp index 2bc6787ae3..d2633ec4ae 100644 --- a/xfa/fxfa/parser/cscript_hostpseudomodel.cpp +++ b/xfa/fxfa/parser/cscript_hostpseudomodel.cpp @@ -13,8 +13,8 @@ #include "xfa/fxfa/parser/cxfa_document.h" #include "xfa/fxfa/parser/cxfa_layoutprocessor.h" #include "xfa/fxfa/parser/cxfa_localemgr.h" +#include "xfa/fxfa/parser/cxfa_node.h" #include "xfa/fxfa/parser/cxfa_scriptcontext.h" -#include "xfa/fxfa/parser/xfa_object.h" #include "xfa/fxfa/parser/xfa_resolvenode_rs.h" #include "xfa/fxfa/parser/xfa_utils.h" diff --git a/xfa/fxfa/parser/cscript_hostpseudomodel.h b/xfa/fxfa/parser/cscript_hostpseudomodel.h index c64ad2ed7d..821f88d137 100644 --- a/xfa/fxfa/parser/cscript_hostpseudomodel.h +++ b/xfa/fxfa/parser/cscript_hostpseudomodel.h @@ -7,9 +7,10 @@ #ifndef XFA_FXFA_PARSER_CSCRIPT_HOSTPSEUDOMODEL_H_ #define XFA_FXFA_PARSER_CSCRIPT_HOSTPSEUDOMODEL_H_ -#include "fxjs/cfxjse_arguments.h" -#include "xfa/fxfa/parser/cxfa_document.h" -#include "xfa/fxfa/parser/xfa_object.h" +#include "xfa/fxfa/parser/cxfa_object.h" + +class CFXJSE_Arguments; +class CXFA_Document; class CScript_HostPseudoModel : public CXFA_Object { public: diff --git a/xfa/fxfa/parser/cscript_layoutpseudomodel.cpp b/xfa/fxfa/parser/cscript_layoutpseudomodel.cpp index 842617e6e6..693d4029a3 100644 --- a/xfa/fxfa/parser/cscript_layoutpseudomodel.cpp +++ b/xfa/fxfa/parser/cscript_layoutpseudomodel.cpp @@ -11,6 +11,7 @@ #include "fxjs/cfxjse_arguments.h" #include "third_party/base/stl_util.h" #include "xfa/fxfa/app/xfa_ffnotify.h" +#include "xfa/fxfa/parser/cxfa_arraynodelist.h" #include "xfa/fxfa/parser/cxfa_containerlayoutitem.h" #include "xfa/fxfa/parser/cxfa_contentlayoutitem.h" #include "xfa/fxfa/parser/cxfa_document.h" @@ -18,9 +19,9 @@ #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_node.h" #include "xfa/fxfa/parser/cxfa_scriptcontext.h" #include "xfa/fxfa/parser/cxfa_traversestrategy_contentlayoutitem.h" -#include "xfa/fxfa/parser/xfa_object.h" #include "xfa/fxfa/parser/xfa_utils.h" CScript_LayoutPseudoModel::CScript_LayoutPseudoModel(CXFA_Document* pDocument) diff --git a/xfa/fxfa/parser/cscript_layoutpseudomodel.h b/xfa/fxfa/parser/cscript_layoutpseudomodel.h index a61f927299..ea31a4205e 100644 --- a/xfa/fxfa/parser/cscript_layoutpseudomodel.h +++ b/xfa/fxfa/parser/cscript_layoutpseudomodel.h @@ -9,8 +9,7 @@ #include -#include "fxjs/cfxjse_arguments.h" -#include "xfa/fxfa/parser/xfa_object.h" +#include "xfa/fxfa/parser/cxfa_object.h" enum XFA_LAYOUTMODEL_HWXY { XFA_LAYOUTMODEL_H, @@ -19,6 +18,7 @@ enum XFA_LAYOUTMODEL_HWXY { XFA_LAYOUTMODEL_Y }; +class CFXJSE_Arguments; class CXFA_LayoutProcessor; class CScript_LayoutPseudoModel : public CXFA_Object { diff --git a/xfa/fxfa/parser/cscript_logpseudomodel.cpp b/xfa/fxfa/parser/cscript_logpseudomodel.cpp index f9430f5d75..d9563ac93e 100644 --- a/xfa/fxfa/parser/cscript_logpseudomodel.cpp +++ b/xfa/fxfa/parser/cscript_logpseudomodel.cpp @@ -9,7 +9,6 @@ #include "fxjs/cfxjse_arguments.h" #include "xfa/fxfa/parser/cxfa_document.h" #include "xfa/fxfa/parser/cxfa_localemgr.h" -#include "xfa/fxfa/parser/xfa_object.h" #include "xfa/fxfa/parser/xfa_utils.h" CScript_LogPseudoModel::CScript_LogPseudoModel(CXFA_Document* pDocument) diff --git a/xfa/fxfa/parser/cscript_logpseudomodel.h b/xfa/fxfa/parser/cscript_logpseudomodel.h index 18f9f51ae7..2e465e851b 100644 --- a/xfa/fxfa/parser/cscript_logpseudomodel.h +++ b/xfa/fxfa/parser/cscript_logpseudomodel.h @@ -7,8 +7,9 @@ #ifndef XFA_FXFA_PARSER_CSCRIPT_LOGPSEUDOMODEL_H_ #define XFA_FXFA_PARSER_CSCRIPT_LOGPSEUDOMODEL_H_ -#include "fxjs/cfxjse_arguments.h" -#include "xfa/fxfa/parser/xfa_object.h" +#include "xfa/fxfa/parser/cxfa_object.h" + +class CFXJSE_Arguments; class CScript_LogPseudoModel : public CXFA_Object { public: diff --git a/xfa/fxfa/parser/cscript_signaturepseudomodel.cpp b/xfa/fxfa/parser/cscript_signaturepseudomodel.cpp index 609b5bd318..0886809db1 100644 --- a/xfa/fxfa/parser/cscript_signaturepseudomodel.cpp +++ b/xfa/fxfa/parser/cscript_signaturepseudomodel.cpp @@ -11,7 +11,6 @@ #include "xfa/fxfa/parser/cxfa_document.h" #include "xfa/fxfa/parser/cxfa_localemgr.h" #include "xfa/fxfa/parser/cxfa_scriptcontext.h" -#include "xfa/fxfa/parser/xfa_object.h" #include "xfa/fxfa/parser/xfa_utils.h" CScript_SignaturePseudoModel::CScript_SignaturePseudoModel( diff --git a/xfa/fxfa/parser/cscript_signaturepseudomodel.h b/xfa/fxfa/parser/cscript_signaturepseudomodel.h index 4f9ded0663..ee52744320 100644 --- a/xfa/fxfa/parser/cscript_signaturepseudomodel.h +++ b/xfa/fxfa/parser/cscript_signaturepseudomodel.h @@ -7,8 +7,9 @@ #ifndef XFA_FXFA_PARSER_CSCRIPT_SIGNATUREPSEUDOMODEL_H_ #define XFA_FXFA_PARSER_CSCRIPT_SIGNATUREPSEUDOMODEL_H_ -#include "fxjs/cfxjse_arguments.h" -#include "xfa/fxfa/parser/xfa_object.h" +#include "xfa/fxfa/parser/cxfa_object.h" + +class CFXJSE_Arguments; class CScript_SignaturePseudoModel : public CXFA_Object { public: diff --git a/xfa/fxfa/parser/cxfa_arraynodelist.cpp b/xfa/fxfa/parser/cxfa_arraynodelist.cpp index ff1d1d916b..03966c3c6c 100644 --- a/xfa/fxfa/parser/cxfa_arraynodelist.cpp +++ b/xfa/fxfa/parser/cxfa_arraynodelist.cpp @@ -4,10 +4,11 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com +#include "xfa/fxfa/parser/cxfa_arraynodelist.h" + #include #include "third_party/base/stl_util.h" -#include "xfa/fxfa/parser/xfa_object.h" CXFA_ArrayNodeList::CXFA_ArrayNodeList(CXFA_Document* pDocument) : CXFA_NodeList(pDocument) {} diff --git a/xfa/fxfa/parser/cxfa_arraynodelist.h b/xfa/fxfa/parser/cxfa_arraynodelist.h new file mode 100644 index 0000000000..ba00f3045e --- /dev/null +++ b/xfa/fxfa/parser/cxfa_arraynodelist.h @@ -0,0 +1,35 @@ +// Copyright 2017 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_ARRAYNODELIST_H_ +#define XFA_FXFA_PARSER_CXFA_ARRAYNODELIST_H_ + +#include + +#include "xfa/fxfa/parser/cxfa_nodelist.h" + +class CXFA_Document; +class CXFA_Node; + +class CXFA_ArrayNodeList : public CXFA_NodeList { + public: + explicit CXFA_ArrayNodeList(CXFA_Document* pDocument); + ~CXFA_ArrayNodeList() override; + + // From CXFA_NodeList. + int32_t GetLength() override; + bool Append(CXFA_Node* pNode) override; + bool Insert(CXFA_Node* pNewNode, CXFA_Node* pBeforeNode) override; + bool Remove(CXFA_Node* pNode) override; + CXFA_Node* Item(int32_t iIndex) override; + + void SetArrayNodeList(const std::vector& srcArray); + + private: + std::vector m_array; +}; + +#endif // XFA_FXFA_PARSER_CXFA_ARRAYNODELIST_H_ diff --git a/xfa/fxfa/parser/cxfa_assist.cpp b/xfa/fxfa/parser/cxfa_assist.cpp index 894e729d6d..809081d960 100644 --- a/xfa/fxfa/parser/cxfa_assist.cpp +++ b/xfa/fxfa/parser/cxfa_assist.cpp @@ -6,7 +6,7 @@ #include "xfa/fxfa/parser/cxfa_assist.h" -#include "xfa/fxfa/parser/xfa_object.h" +#include "xfa/fxfa/parser/cxfa_node.h" CXFA_Assist::CXFA_Assist(CXFA_Node* pNode) : CXFA_Data(pNode) {} diff --git a/xfa/fxfa/parser/cxfa_attachnodelist.cpp b/xfa/fxfa/parser/cxfa_attachnodelist.cpp index c23b900af6..9c0b0fd18e 100644 --- a/xfa/fxfa/parser/cxfa_attachnodelist.cpp +++ b/xfa/fxfa/parser/cxfa_attachnodelist.cpp @@ -4,7 +4,9 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#include "xfa/fxfa/parser/xfa_object.h" +#include "xfa/fxfa/parser/cxfa_attachnodelist.h" + +#include "xfa/fxfa/parser/cxfa_node.h" CXFA_AttachNodeList::CXFA_AttachNodeList(CXFA_Document* pDocument, CXFA_Node* pAttachNode) @@ -20,17 +22,17 @@ int32_t CXFA_AttachNodeList::GetLength() { bool CXFA_AttachNodeList::Append(CXFA_Node* pNode) { CXFA_Node* pParent = pNode->GetNodeItem(XFA_NODEITEM_Parent); - if (pParent) { + if (pParent) pParent->RemoveChild(pNode); - } + return m_pAttachNode->InsertChild(pNode); } bool CXFA_AttachNodeList::Insert(CXFA_Node* pNewNode, CXFA_Node* pBeforeNode) { CXFA_Node* pParent = pNewNode->GetNodeItem(XFA_NODEITEM_Parent); - if (pParent) { + if (pParent) pParent->RemoveChild(pNewNode); - } + return m_pAttachNode->InsertChild(pNewNode, pBeforeNode); } diff --git a/xfa/fxfa/parser/cxfa_attachnodelist.h b/xfa/fxfa/parser/cxfa_attachnodelist.h new file mode 100644 index 0000000000..3bb771a476 --- /dev/null +++ b/xfa/fxfa/parser/cxfa_attachnodelist.h @@ -0,0 +1,30 @@ +// Copyright 2017 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_ATTACHNODELIST_H_ +#define XFA_FXFA_PARSER_CXFA_ATTACHNODELIST_H_ + +#include "xfa/fxfa/parser/cxfa_nodelist.h" + +class CXFA_Document; +class CXFA_Node; + +class CXFA_AttachNodeList : public CXFA_NodeList { + public: + CXFA_AttachNodeList(CXFA_Document* pDocument, CXFA_Node* pAttachNode); + + // From CXFA_NodeList. + int32_t GetLength() override; + bool Append(CXFA_Node* pNode) override; + bool Insert(CXFA_Node* pNewNode, CXFA_Node* pBeforeNode) override; + bool Remove(CXFA_Node* pNode) override; + CXFA_Node* Item(int32_t iIndex) override; + + private: + CXFA_Node* m_pAttachNode; +}; + +#endif // XFA_FXFA_PARSER_CXFA_ATTACHNODELIST_H_ diff --git a/xfa/fxfa/parser/cxfa_bind.cpp b/xfa/fxfa/parser/cxfa_bind.cpp index 16efd1f440..aac2c18321 100644 --- a/xfa/fxfa/parser/cxfa_bind.cpp +++ b/xfa/fxfa/parser/cxfa_bind.cpp @@ -6,7 +6,7 @@ #include "xfa/fxfa/parser/cxfa_bind.h" -#include "xfa/fxfa/parser/xfa_object.h" +#include "xfa/fxfa/parser/cxfa_node.h" CXFA_Bind::CXFA_Bind(CXFA_Node* pNode) : CXFA_Data(pNode) {} diff --git a/xfa/fxfa/parser/cxfa_binditems.cpp b/xfa/fxfa/parser/cxfa_binditems.cpp index fdb4f0c376..c3c5cabe4e 100644 --- a/xfa/fxfa/parser/cxfa_binditems.cpp +++ b/xfa/fxfa/parser/cxfa_binditems.cpp @@ -6,7 +6,7 @@ #include "xfa/fxfa/parser/cxfa_binditems.h" -#include "xfa/fxfa/parser/xfa_object.h" +#include "xfa/fxfa/parser/cxfa_node.h" CXFA_BindItems::CXFA_BindItems(CXFA_Node* pNode) : CXFA_Data(pNode) {} diff --git a/xfa/fxfa/parser/cxfa_box.cpp b/xfa/fxfa/parser/cxfa_box.cpp index a6cced5426..300edd01ad 100644 --- a/xfa/fxfa/parser/cxfa_box.cpp +++ b/xfa/fxfa/parser/cxfa_box.cpp @@ -8,7 +8,7 @@ #include "xfa/fxfa/parser/cxfa_corner.h" #include "xfa/fxfa/parser/cxfa_measurement.h" -#include "xfa/fxfa/parser/xfa_object.h" +#include "xfa/fxfa/parser/cxfa_node.h" namespace { diff --git a/xfa/fxfa/parser/cxfa_calculate.cpp b/xfa/fxfa/parser/cxfa_calculate.cpp index d7b1f71caa..bc89d81777 100644 --- a/xfa/fxfa/parser/cxfa_calculate.cpp +++ b/xfa/fxfa/parser/cxfa_calculate.cpp @@ -6,8 +6,8 @@ #include "xfa/fxfa/parser/cxfa_calculate.h" +#include "xfa/fxfa/parser/cxfa_node.h" #include "xfa/fxfa/parser/cxfa_text.h" -#include "xfa/fxfa/parser/xfa_object.h" CXFA_Calculate::CXFA_Calculate(CXFA_Node* pNode) : CXFA_Data(pNode) {} diff --git a/xfa/fxfa/parser/cxfa_caption.cpp b/xfa/fxfa/parser/cxfa_caption.cpp index 5b9365ab16..1be4a206e7 100644 --- a/xfa/fxfa/parser/cxfa_caption.cpp +++ b/xfa/fxfa/parser/cxfa_caption.cpp @@ -7,7 +7,7 @@ #include "xfa/fxfa/parser/cxfa_caption.h" #include "xfa/fxfa/parser/cxfa_measurement.h" -#include "xfa/fxfa/parser/xfa_object.h" +#include "xfa/fxfa/parser/cxfa_node.h" CXFA_Caption::CXFA_Caption(CXFA_Node* pNode) : CXFA_Data(pNode) {} diff --git a/xfa/fxfa/parser/cxfa_containerlayoutitem.cpp b/xfa/fxfa/parser/cxfa_containerlayoutitem.cpp index 5ef29f14cf..cf4e1ce3f3 100644 --- a/xfa/fxfa/parser/cxfa_containerlayoutitem.cpp +++ b/xfa/fxfa/parser/cxfa_containerlayoutitem.cpp @@ -9,6 +9,7 @@ #include "xfa/fxfa/parser/cxfa_layoutpagemgr.h" #include "xfa/fxfa/parser/cxfa_layoutprocessor.h" #include "xfa/fxfa/parser/cxfa_measurement.h" +#include "xfa/fxfa/parser/cxfa_node.h" CXFA_ContainerLayoutItem::CXFA_ContainerLayoutItem(CXFA_Node* pNode) : CXFA_LayoutItem(pNode, false), m_pOldSubform(nullptr) {} diff --git a/xfa/fxfa/parser/cxfa_contentlayoutitem.cpp b/xfa/fxfa/parser/cxfa_contentlayoutitem.cpp index a10a678279..c8acff2b1c 100644 --- a/xfa/fxfa/parser/cxfa_contentlayoutitem.cpp +++ b/xfa/fxfa/parser/cxfa_contentlayoutitem.cpp @@ -6,6 +6,8 @@ #include "xfa/fxfa/parser/cxfa_contentlayoutitem.h" +#include "xfa/fxfa/parser/cxfa_node.h" + CXFA_ContentLayoutItem::CXFA_ContentLayoutItem(CXFA_Node* pNode) : CXFA_LayoutItem(pNode, true), m_pPrev(nullptr), diff --git a/xfa/fxfa/parser/cxfa_contentlayoutitem.h b/xfa/fxfa/parser/cxfa_contentlayoutitem.h index 500d3e4959..9d1fc2abcf 100644 --- a/xfa/fxfa/parser/cxfa_contentlayoutitem.h +++ b/xfa/fxfa/parser/cxfa_contentlayoutitem.h @@ -9,6 +9,8 @@ #include "xfa/fxfa/parser/cxfa_layoutitem.h" +#define XFA_LAYOUTITEMKEY (void*)(uintptr_t) FXBSTR_ID('L', 'Y', 'I', 'M') + class CXFA_ContentLayoutItem : public CXFA_LayoutItem { public: explicit CXFA_ContentLayoutItem(CXFA_Node* pNode); diff --git a/xfa/fxfa/parser/cxfa_data.cpp b/xfa/fxfa/parser/cxfa_data.cpp index 456cc7f223..9f265b41be 100644 --- a/xfa/fxfa/parser/cxfa_data.cpp +++ b/xfa/fxfa/parser/cxfa_data.cpp @@ -8,7 +8,7 @@ #include "core/fxcrt/fx_ext.h" #include "xfa/fxfa/parser/cxfa_measurement.h" -#include "xfa/fxfa/parser/xfa_object.h" +#include "xfa/fxfa/parser/cxfa_node.h" // Static. FX_ARGB CXFA_Data::ToColor(const CFX_WideStringC& wsValue) { diff --git a/xfa/fxfa/parser/cxfa_dataexporter.cpp b/xfa/fxfa/parser/cxfa_dataexporter.cpp index 4d3b039b33..f9553c413f 100644 --- a/xfa/fxfa/parser/cxfa_dataexporter.cpp +++ b/xfa/fxfa/parser/cxfa_dataexporter.cpp @@ -13,8 +13,9 @@ #include "xfa/fde/xml/fde_xml_imp.h" #include "xfa/fgas/crt/fgas_codepage.h" #include "xfa/fxfa/parser/cxfa_document.h" +#include "xfa/fxfa/parser/cxfa_node.h" #include "xfa/fxfa/parser/cxfa_widgetdata.h" -#include "xfa/fxfa/parser/xfa_object.h" +#include "xfa/fxfa/parser/xfa_utils.h" namespace { diff --git a/xfa/fxfa/parser/cxfa_dataimporter.cpp b/xfa/fxfa/parser/cxfa_dataimporter.cpp index 0199028ecd..3ba304d550 100644 --- a/xfa/fxfa/parser/cxfa_dataimporter.cpp +++ b/xfa/fxfa/parser/cxfa_dataimporter.cpp @@ -14,8 +14,8 @@ #include "xfa/fxfa/fxfa.h" #include "xfa/fxfa/fxfa_basic.h" #include "xfa/fxfa/parser/cxfa_document.h" +#include "xfa/fxfa/parser/cxfa_node.h" #include "xfa/fxfa/parser/cxfa_simple_parser.h" -#include "xfa/fxfa/parser/xfa_object.h" CXFA_DataImporter::CXFA_DataImporter(CXFA_Document* pDocument) : m_pDocument(pDocument) { diff --git a/xfa/fxfa/parser/cxfa_document.cpp b/xfa/fxfa/parser/cxfa_document.cpp index 0a4e597c93..165c0a3ee5 100644 --- a/xfa/fxfa/parser/cxfa_document.cpp +++ b/xfa/fxfa/parser/cxfa_document.cpp @@ -16,8 +16,9 @@ #include "xfa/fxfa/parser/cxfa_document_parser.h" #include "xfa/fxfa/parser/cxfa_layoutprocessor.h" #include "xfa/fxfa/parser/cxfa_localemgr.h" +#include "xfa/fxfa/parser/cxfa_node.h" #include "xfa/fxfa/parser/cxfa_scriptcontext.h" -#include "xfa/fxfa/parser/xfa_object.h" +#include "xfa/fxfa/parser/cxfa_traversestrategy_xfanode.h" #include "xfa/fxfa/parser/xfa_resolvenode_rs.h" #include "xfa/fxfa/parser/xfa_utils.h" diff --git a/xfa/fxfa/parser/cxfa_document.h b/xfa/fxfa/parser/cxfa_document.h index 80cdc1bb0c..5d9ec1b430 100644 --- a/xfa/fxfa/parser/cxfa_document.h +++ b/xfa/fxfa/parser/cxfa_document.h @@ -14,7 +14,6 @@ #include "xfa/fxfa/fxfa.h" #include "xfa/fxfa/parser/cxfa_localemgr.h" -#include "xfa/fxfa/parser/xfa_object.h" enum XFA_VERSION { XFA_VERSION_UNKNOWN = 0, diff --git a/xfa/fxfa/parser/cxfa_event.cpp b/xfa/fxfa/parser/cxfa_event.cpp index 1fe03a4935..d7534289b3 100644 --- a/xfa/fxfa/parser/cxfa_event.cpp +++ b/xfa/fxfa/parser/cxfa_event.cpp @@ -6,7 +6,7 @@ #include "xfa/fxfa/parser/cxfa_event.h" -#include "xfa/fxfa/parser/xfa_object.h" +#include "xfa/fxfa/parser/cxfa_node.h" CXFA_Event::CXFA_Event(CXFA_Node* pNode) : CXFA_Data(pNode) {} diff --git a/xfa/fxfa/parser/cxfa_exdata.cpp b/xfa/fxfa/parser/cxfa_exdata.cpp index bf1e930330..ac82b3043c 100644 --- a/xfa/fxfa/parser/cxfa_exdata.cpp +++ b/xfa/fxfa/parser/cxfa_exdata.cpp @@ -6,7 +6,7 @@ #include "xfa/fxfa/parser/cxfa_exdata.h" -#include "xfa/fxfa/parser/xfa_object.h" +#include "xfa/fxfa/parser/cxfa_node.h" CXFA_ExData::CXFA_ExData(CXFA_Node* pNode) : CXFA_Data(pNode) {} diff --git a/xfa/fxfa/parser/cxfa_fill.cpp b/xfa/fxfa/parser/cxfa_fill.cpp index 63949c193d..8621c3c961 100644 --- a/xfa/fxfa/parser/cxfa_fill.cpp +++ b/xfa/fxfa/parser/cxfa_fill.cpp @@ -6,7 +6,7 @@ #include "xfa/fxfa/parser/cxfa_fill.h" -#include "xfa/fxfa/parser/xfa_object.h" +#include "xfa/fxfa/parser/cxfa_node.h" CXFA_Fill::CXFA_Fill(CXFA_Node* pNode) : CXFA_Data(pNode) {} diff --git a/xfa/fxfa/parser/cxfa_font.cpp b/xfa/fxfa/parser/cxfa_font.cpp index f310f76bc6..56e04b75f7 100644 --- a/xfa/fxfa/parser/cxfa_font.cpp +++ b/xfa/fxfa/parser/cxfa_font.cpp @@ -9,7 +9,7 @@ #include "core/fxge/fx_dib.h" #include "xfa/fxfa/parser/cxfa_fill.h" #include "xfa/fxfa/parser/cxfa_measurement.h" -#include "xfa/fxfa/parser/xfa_object.h" +#include "xfa/fxfa/parser/cxfa_node.h" CXFA_Font::CXFA_Font(CXFA_Node* pNode) : CXFA_Data(pNode) {} diff --git a/xfa/fxfa/parser/cxfa_image.cpp b/xfa/fxfa/parser/cxfa_image.cpp index 8cf7fc1e23..8d14d62960 100644 --- a/xfa/fxfa/parser/cxfa_image.cpp +++ b/xfa/fxfa/parser/cxfa_image.cpp @@ -6,7 +6,7 @@ #include "xfa/fxfa/parser/cxfa_image.h" -#include "xfa/fxfa/parser/xfa_object.h" +#include "xfa/fxfa/parser/cxfa_node.h" CXFA_Image::CXFA_Image(CXFA_Node* pNode, bool bDefValue) : CXFA_Data(pNode), m_bDefValue(bDefValue) {} diff --git a/xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp b/xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp index 50be211bb6..8911227f3d 100644 --- a/xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp +++ b/xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp @@ -21,8 +21,9 @@ #include "xfa/fxfa/parser/cxfa_layoutpagemgr.h" #include "xfa/fxfa/parser/cxfa_localemgr.h" #include "xfa/fxfa/parser/cxfa_measurement.h" +#include "xfa/fxfa/parser/cxfa_node.h" #include "xfa/fxfa/parser/cxfa_occur.h" -#include "xfa/fxfa/parser/xfa_object.h" +#include "xfa/fxfa/parser/cxfa_traversestrategy_xfanode.h" #include "xfa/fxfa/parser/xfa_utils.h" namespace { diff --git a/xfa/fxfa/parser/cxfa_layoutitem.cpp b/xfa/fxfa/parser/cxfa_layoutitem.cpp index 5409c4e0c1..b227be9e85 100644 --- a/xfa/fxfa/parser/cxfa_layoutitem.cpp +++ b/xfa/fxfa/parser/cxfa_layoutitem.cpp @@ -10,6 +10,7 @@ #include "xfa/fxfa/parser/cxfa_containerlayoutitem.h" #include "xfa/fxfa/parser/cxfa_contentlayoutitem.h" #include "xfa/fxfa/parser/cxfa_measurement.h" +#include "xfa/fxfa/parser/cxfa_node.h" void XFA_ReleaseLayoutItem(CXFA_LayoutItem* pLayoutItem) { CXFA_LayoutItem* pNode = pLayoutItem->m_pFirstChild; diff --git a/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp b/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp index bee4fe9ae6..b88dca9009 100644 --- a/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp +++ b/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp @@ -15,11 +15,14 @@ #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_node.h" +#include "xfa/fxfa/parser/cxfa_object.h" #include "xfa/fxfa/parser/cxfa_scriptcontext.h" #include "xfa/fxfa/parser/cxfa_traversestrategy_contentareacontainerlayoutitem.h" #include "xfa/fxfa/parser/cxfa_traversestrategy_layoutitem.h" +#include "xfa/fxfa/parser/cxfa_traversestrategy_xfacontainernode.h" +#include "xfa/fxfa/parser/cxfa_traversestrategy_xfanode.h" #include "xfa/fxfa/parser/xfa_document_datamerger_imp.h" -#include "xfa/fxfa/parser/xfa_object.h" #include "xfa/fxfa/parser/xfa_resolvenode_rs.h" #include "xfa/fxfa/parser/xfa_utils.h" diff --git a/xfa/fxfa/parser/cxfa_layoutprocessor.cpp b/xfa/fxfa/parser/cxfa_layoutprocessor.cpp index 10ae66739b..2e919dbc84 100644 --- a/xfa/fxfa/parser/cxfa_layoutprocessor.cpp +++ b/xfa/fxfa/parser/cxfa_layoutprocessor.cpp @@ -14,8 +14,8 @@ #include "xfa/fxfa/parser/cxfa_layoutpagemgr.h" #include "xfa/fxfa/parser/cxfa_localemgr.h" #include "xfa/fxfa/parser/cxfa_measurement.h" +#include "xfa/fxfa/parser/cxfa_node.h" #include "xfa/fxfa/parser/xfa_document_datamerger_imp.h" -#include "xfa/fxfa/parser/xfa_object.h" #include "xfa/fxfa/parser/xfa_utils.h" CXFA_LayoutProcessor::CXFA_LayoutProcessor(CXFA_Document* pDocument) diff --git a/xfa/fxfa/parser/cxfa_layoutprocessor.h b/xfa/fxfa/parser/cxfa_layoutprocessor.h index c6950052a9..75bf2597c5 100644 --- a/xfa/fxfa/parser/cxfa_layoutprocessor.h +++ b/xfa/fxfa/parser/cxfa_layoutprocessor.h @@ -11,7 +11,6 @@ #include #include "core/fxcrt/fx_system.h" -#include "xfa/fxfa/parser/xfa_object.h" class CXFA_ContainerLayoutItem; class CXFA_Document; diff --git a/xfa/fxfa/parser/cxfa_line.cpp b/xfa/fxfa/parser/cxfa_line.cpp index 38de0d8ca8..8be1d25a46 100644 --- a/xfa/fxfa/parser/cxfa_line.cpp +++ b/xfa/fxfa/parser/cxfa_line.cpp @@ -6,7 +6,7 @@ #include "xfa/fxfa/parser/cxfa_line.h" -#include "xfa/fxfa/parser/xfa_object.h" +#include "xfa/fxfa/parser/cxfa_node.h" int32_t CXFA_Line::GetHand() { return m_pNode->GetEnum(XFA_ATTRIBUTE_Hand); diff --git a/xfa/fxfa/parser/cxfa_localemgr.cpp b/xfa/fxfa/parser/cxfa_localemgr.cpp index b9f2615f41..ddcee39b0d 100644 --- a/xfa/fxfa/parser/cxfa_localemgr.cpp +++ b/xfa/fxfa/parser/cxfa_localemgr.cpp @@ -15,9 +15,9 @@ #include "core/fxcrt/fx_xml.h" #include "core/fxge/cfx_gemodule.h" #include "xfa/fxfa/parser/cxfa_document.h" +#include "xfa/fxfa/parser/cxfa_node.h" #include "xfa/fxfa/parser/cxfa_nodelocale.h" #include "xfa/fxfa/parser/cxfa_xmllocale.h" -#include "xfa/fxfa/parser/xfa_object.h" #include "xfa/fxfa/parser/xfa_utils.h" const uint8_t g_enUS_Locale[] = { diff --git a/xfa/fxfa/parser/cxfa_localevalue.cpp b/xfa/fxfa/parser/cxfa_localevalue.cpp index a5238d2c3f..1fd7ac197c 100644 --- a/xfa/fxfa/parser/cxfa_localevalue.cpp +++ b/xfa/fxfa/parser/cxfa_localevalue.cpp @@ -14,7 +14,6 @@ #include "xfa/fgas/localization/cfx_formatstring.h" #include "xfa/fxfa/parser/cxfa_document.h" #include "xfa/fxfa/parser/cxfa_localemgr.h" -#include "xfa/fxfa/parser/xfa_object.h" #include "xfa/fxfa/parser/xfa_utils.h" CXFA_LocaleValue::CXFA_LocaleValue() { diff --git a/xfa/fxfa/parser/cxfa_margin.cpp b/xfa/fxfa/parser/cxfa_margin.cpp index fc4a0f1a63..e3153f2671 100644 --- a/xfa/fxfa/parser/cxfa_margin.cpp +++ b/xfa/fxfa/parser/cxfa_margin.cpp @@ -6,8 +6,6 @@ #include "xfa/fxfa/parser/cxfa_margin.h" -#include "xfa/fxfa/parser/xfa_object.h" - CXFA_Margin::CXFA_Margin(CXFA_Node* pNode) : CXFA_Data(pNode) {} bool CXFA_Margin::GetLeftInset(float& fInset, float fDefInset) const { diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp index a1074b9ef2..86249c0718 100644 --- a/xfa/fxfa/parser/cxfa_node.cpp +++ b/xfa/fxfa/parser/cxfa_node.cpp @@ -4,7 +4,7 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#include "xfa/fxfa/parser/xfa_object.h" +#include "xfa/fxfa/parser/cxfa_node.h" #include #include @@ -20,12 +20,16 @@ #include "xfa/fgas/crt/fgas_codepage.h" #include "xfa/fxfa/app/xfa_ffnotify.h" #include "xfa/fxfa/cxfa_eventparam.h" +#include "xfa/fxfa/cxfa_ffwidget.h" +#include "xfa/fxfa/parser/cxfa_arraynodelist.h" +#include "xfa/fxfa/parser/cxfa_attachnodelist.h" #include "xfa/fxfa/parser/cxfa_document.h" #include "xfa/fxfa/parser/cxfa_layoutprocessor.h" #include "xfa/fxfa/parser/cxfa_measurement.h" #include "xfa/fxfa/parser/cxfa_occur.h" #include "xfa/fxfa/parser/cxfa_scriptcontext.h" #include "xfa/fxfa/parser/cxfa_simple_parser.h" +#include "xfa/fxfa/parser/cxfa_traversestrategy_xfacontainernode.h" #include "xfa/fxfa/parser/xfa_basic_data.h" namespace { diff --git a/xfa/fxfa/parser/cxfa_node.h b/xfa/fxfa/parser/cxfa_node.h new file mode 100644 index 0000000000..970d267ff3 --- /dev/null +++ b/xfa/fxfa/parser/cxfa_node.h @@ -0,0 +1,608 @@ +// Copyright 2017 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_NODE_H_ +#define XFA_FXFA_PARSER_CXFA_NODE_H_ + +#include +#include + +#include "core/fxcrt/fx_string.h" +#include "xfa/fxfa/parser/cxfa_object.h" + +class CFDE_XMLNode; +class CFXJSE_Argument; +class CXFA_WidgetData; + +#define XFA_NODEFILTER_Children 0x01 +#define XFA_NODEFILTER_Properties 0x02 +#define XFA_NODEFILTER_OneOfProperty 0x04 + +enum XFA_NodeFlag { + XFA_NodeFlag_None = 0, + XFA_NodeFlag_Initialized = 1 << 0, + XFA_NodeFlag_HasRemovedChildren = 1 << 1, + XFA_NodeFlag_NeedsInitApp = 1 << 2, + XFA_NodeFlag_BindFormItems = 1 << 3, + XFA_NodeFlag_UserInteractive = 1 << 4, + XFA_NodeFlag_SkipDataBinding = 1 << 5, + XFA_NodeFlag_OwnXMLNode = 1 << 6, + XFA_NodeFlag_UnusedNode = 1 << 7, + XFA_NodeFlag_LayoutGeneratedNode = 1 << 8 +}; + +enum XFA_SOM_MESSAGETYPE { + XFA_SOM_ValidationMessage, + XFA_SOM_FormatMessage, + XFA_SOM_MandatoryMessage +}; + +enum XFA_NODEITEM { + XFA_NODEITEM_Parent, + XFA_NODEITEM_FirstChild, + XFA_NODEITEM_NextSibling, + XFA_NODEITEM_PrevSibling, +}; + +typedef void (*PD_CALLBACK_FREEDATA)(void* pData); +typedef void (*PD_CALLBACK_DUPLICATEDATA)(void*& pData); + +struct XFA_MAPDATABLOCKCALLBACKINFO { + PD_CALLBACK_FREEDATA pFree; + PD_CALLBACK_DUPLICATEDATA pCopy; +}; + +struct XFA_MAPDATABLOCK { + uint8_t* GetData() const { return (uint8_t*)this + sizeof(XFA_MAPDATABLOCK); } + XFA_MAPDATABLOCKCALLBACKINFO* pCallbackInfo; + int32_t iBytes; +}; + +struct XFA_MAPMODULEDATA { + XFA_MAPMODULEDATA(); + ~XFA_MAPMODULEDATA(); + + std::map m_ValueMap; + std::map m_BufferMap; +}; + +class CXFA_Node : public CXFA_Object { + public: + uint32_t GetPacketID() const { return m_ePacket; } + + void SetFlag(uint32_t dwFlag, bool bNotify); + void ClearFlag(uint32_t dwFlag); + + bool IsInitialized() const { return HasFlag(XFA_NodeFlag_Initialized); } + bool IsOwnXMLNode() const { return HasFlag(XFA_NodeFlag_OwnXMLNode); } + bool IsUserInteractive() const { + return HasFlag(XFA_NodeFlag_UserInteractive); + } + bool IsUnusedNode() const { return HasFlag(XFA_NodeFlag_UnusedNode); } + bool IsLayoutGeneratedNode() const { + return HasFlag(XFA_NodeFlag_LayoutGeneratedNode); + } + bool BindsFormItems() const { return HasFlag(XFA_NodeFlag_BindFormItems); } + bool HasRemovedChildren() const { + return HasFlag(XFA_NodeFlag_HasRemovedChildren); + } + bool NeedsInitApp() const { return HasFlag(XFA_NodeFlag_NeedsInitApp); } + + bool IsAttributeInXML(); + bool IsFormContainer() const { + return m_ePacket == XFA_XDPPACKET_Form && IsContainerNode(); + } + void SetXMLMappingNode(CFDE_XMLNode* pXMLNode) { m_pXMLNode = pXMLNode; } + CFDE_XMLNode* GetXMLMappingNode() const { return m_pXMLNode; } + CFDE_XMLNode* CreateXMLMappingNode(); + bool IsNeedSavingXMLNode(); + uint32_t GetNameHash() const { return m_dwNameHash; } + bool IsUnnamed() const { return m_dwNameHash == 0; } + CXFA_Node* GetModelNode(); + void UpdateNameHash(); + bool HasAttribute(XFA_ATTRIBUTE eAttr, bool bCanInherit = false); + bool SetAttribute(XFA_ATTRIBUTE eAttr, + const CFX_WideStringC& wsValue, + bool bNotify = false); + bool GetAttribute(XFA_ATTRIBUTE eAttr, + CFX_WideString& wsValue, + bool bUseDefault = true); + bool SetAttribute(const CFX_WideStringC& wsAttr, + const CFX_WideStringC& wsValue, + bool bNotify = false); + bool GetAttribute(const CFX_WideStringC& wsAttr, + CFX_WideString& wsValue, + bool bUseDefault = true); + bool RemoveAttribute(const CFX_WideStringC& wsAttr); + bool SetContent(const CFX_WideString& wsContent, + const CFX_WideString& wsXMLValue, + bool bNotify = false, + bool bScriptModify = false, + bool bSyncData = true); + bool TryContent(CFX_WideString& wsContent, + bool bScriptModify = false, + bool bProto = true); + CFX_WideString GetContent(); + + bool TryNamespace(CFX_WideString& wsNamespace); + + bool SetBoolean(XFA_ATTRIBUTE eAttr, bool bValue, bool bNotify = false) { + return SetValue(eAttr, XFA_ATTRIBUTETYPE_Boolean, (void*)(uintptr_t)bValue, + bNotify); + } + bool TryBoolean(XFA_ATTRIBUTE eAttr, bool& bValue, bool bUseDefault = true); + bool GetBoolean(XFA_ATTRIBUTE eAttr) { + bool bValue; + return TryBoolean(eAttr, bValue, true) ? bValue : false; + } + bool SetInteger(XFA_ATTRIBUTE eAttr, int32_t iValue, bool bNotify = false) { + return SetValue(eAttr, XFA_ATTRIBUTETYPE_Integer, (void*)(uintptr_t)iValue, + bNotify); + } + bool TryInteger(XFA_ATTRIBUTE eAttr, + int32_t& iValue, + bool bUseDefault = true); + int32_t GetInteger(XFA_ATTRIBUTE eAttr) { + int32_t iValue; + return TryInteger(eAttr, iValue, true) ? iValue : 0; + } + bool SetEnum(XFA_ATTRIBUTE eAttr, + XFA_ATTRIBUTEENUM eValue, + bool bNotify = false) { + return SetValue(eAttr, XFA_ATTRIBUTETYPE_Enum, (void*)(uintptr_t)eValue, + bNotify); + } + bool TryEnum(XFA_ATTRIBUTE eAttr, + XFA_ATTRIBUTEENUM& eValue, + bool bUseDefault = true); + XFA_ATTRIBUTEENUM GetEnum(XFA_ATTRIBUTE eAttr) { + XFA_ATTRIBUTEENUM eValue; + return TryEnum(eAttr, eValue, true) ? eValue : XFA_ATTRIBUTEENUM_Unknown; + } + bool SetCData(XFA_ATTRIBUTE eAttr, + const CFX_WideString& wsValue, + bool bNotify = false, + bool bScriptModify = false); + bool SetAttributeValue(const CFX_WideString& wsValue, + const CFX_WideString& wsXMLValue, + bool bNotify = false, + bool bScriptModify = false); + bool TryCData(XFA_ATTRIBUTE eAttr, + CFX_WideString& wsValue, + bool bUseDefault = true, + bool bProto = true); + bool TryCData(XFA_ATTRIBUTE eAttr, + CFX_WideStringC& wsValue, + bool bUseDefault = true, + bool bProto = true); + CFX_WideStringC GetCData(XFA_ATTRIBUTE eAttr) { + CFX_WideStringC wsValue; + return TryCData(eAttr, wsValue) ? wsValue : CFX_WideStringC(); + } + bool SetMeasure(XFA_ATTRIBUTE eAttr, + CXFA_Measurement mValue, + bool bNotify = false); + bool TryMeasure(XFA_ATTRIBUTE eAttr, + CXFA_Measurement& mValue, + bool bUseDefault = true) const; + CXFA_Measurement GetMeasure(XFA_ATTRIBUTE eAttr) const; + bool SetObject(XFA_ATTRIBUTE eAttr, + void* pData, + XFA_MAPDATABLOCKCALLBACKINFO* pCallbackInfo = nullptr); + bool TryObject(XFA_ATTRIBUTE eAttr, void*& pData); + void* GetObject(XFA_ATTRIBUTE eAttr) { + void* pData; + return TryObject(eAttr, pData) ? pData : nullptr; + } + bool SetUserData(void* pKey, + void* pData, + XFA_MAPDATABLOCKCALLBACKINFO* pCallbackInfo = nullptr); + bool TryUserData(void* pKey, void*& pData, bool bProtoAlso = false); + void* GetUserData(void* pKey, bool bProtoAlso = false) { + void* pData; + return TryUserData(pKey, pData, bProtoAlso) ? pData : nullptr; + } + CXFA_Node* GetProperty(int32_t index, + XFA_Element eType, + bool bCreateProperty = true); + int32_t CountChildren(XFA_Element eType, bool bOnlyChild = false); + CXFA_Node* GetChild(int32_t index, + XFA_Element eType, + bool bOnlyChild = false); + int32_t InsertChild(int32_t index, CXFA_Node* pNode); + bool InsertChild(CXFA_Node* pNode, CXFA_Node* pBeforeNode = nullptr); + bool RemoveChild(CXFA_Node* pNode, bool bNotify = true); + CXFA_Node* Clone(bool bRecursive); + CXFA_Node* GetNodeItem(XFA_NODEITEM eItem) const; + CXFA_Node* GetNodeItem(XFA_NODEITEM eItem, XFA_ObjectType eType) const; + std::vector GetNodeList( + uint32_t dwTypeFilter = XFA_NODEFILTER_Children | + XFA_NODEFILTER_Properties, + XFA_Element eTypeFilter = XFA_Element::Unknown); + CXFA_Node* CreateSamePacketNode(XFA_Element eType, + uint32_t dwFlags = XFA_NodeFlag_Initialized); + CXFA_Node* CloneTemplateToForm(bool bRecursive); + CXFA_Node* GetTemplateNode() const; + void SetTemplateNode(CXFA_Node* pTemplateNode); + CXFA_Node* GetDataDescriptionNode(); + void SetDataDescriptionNode(CXFA_Node* pDataDescriptionNode); + CXFA_Node* GetBindData(); + std::vector GetBindItems(); + int32_t AddBindItem(CXFA_Node* pFormNode); + int32_t RemoveBindItem(CXFA_Node* pFormNode); + bool HasBindItem(); + CXFA_WidgetData* GetWidgetData(); + CXFA_WidgetData* GetContainerWidgetData(); + bool GetLocaleName(CFX_WideString& wsLocaleName); + XFA_ATTRIBUTEENUM GetIntact(); + CXFA_Node* GetFirstChildByName(const CFX_WideStringC& wsNodeName) const; + CXFA_Node* GetFirstChildByName(uint32_t dwNodeNameHash) const; + CXFA_Node* GetFirstChildByClass(XFA_Element eType) const; + CXFA_Node* GetNextSameNameSibling(uint32_t dwNodeNameHash) const; + CXFA_Node* GetNextSameNameSibling(const CFX_WideStringC& wsNodeName) const; + CXFA_Node* GetNextSameClassSibling(XFA_Element eType) const; + int32_t GetNodeSameNameIndex() const; + int32_t GetNodeSameClassIndex() const; + void GetSOMExpression(CFX_WideString& wsSOMExpression); + CXFA_Node* GetInstanceMgrOfSubform(); + + CXFA_Node* GetOccurNode(); + void Script_TreeClass_ResolveNode(CFXJSE_Arguments* pArguments); + void Script_TreeClass_ResolveNodes(CFXJSE_Arguments* pArguments); + void Script_Som_ResolveNodeList(CFXJSE_Value* pValue, + CFX_WideString wsExpression, + uint32_t dwFlag, + CXFA_Node* refNode = nullptr); + void Script_TreeClass_All(CFXJSE_Value* pValue, + bool bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_TreeClass_Nodes(CFXJSE_Value* pValue, + bool bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_TreeClass_ClassAll(CFXJSE_Value* pValue, + bool bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_TreeClass_Parent(CFXJSE_Value* pValue, + bool bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_TreeClass_Index(CFXJSE_Value* pValue, + bool bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_TreeClass_ClassIndex(CFXJSE_Value* pValue, + bool bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_TreeClass_SomExpression(CFXJSE_Value* pValue, + bool bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_NodeClass_ApplyXSL(CFXJSE_Arguments* pArguments); + void Script_NodeClass_AssignNode(CFXJSE_Arguments* pArguments); + void Script_NodeClass_Clone(CFXJSE_Arguments* pArguments); + void Script_NodeClass_GetAttribute(CFXJSE_Arguments* pArguments); + void Script_NodeClass_GetElement(CFXJSE_Arguments* pArguments); + void Script_NodeClass_IsPropertySpecified(CFXJSE_Arguments* pArguments); + void Script_NodeClass_LoadXML(CFXJSE_Arguments* pArguments); + void Script_NodeClass_SaveFilteredXML(CFXJSE_Arguments* pArguments); + void Script_NodeClass_SaveXML(CFXJSE_Arguments* pArguments); + void Script_NodeClass_SetAttribute(CFXJSE_Arguments* pArguments); + void Script_NodeClass_SetElement(CFXJSE_Arguments* pArguments); + void Script_NodeClass_Ns(CFXJSE_Value* pValue, + bool bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_NodeClass_Model(CFXJSE_Value* pValue, + bool bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_NodeClass_IsContainer(CFXJSE_Value* pValue, + bool bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_NodeClass_IsNull(CFXJSE_Value* pValue, + bool bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_NodeClass_OneOfChild(CFXJSE_Value* pValue, + bool bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_ContainerClass_GetDelta(CFXJSE_Arguments* pArguments); + void Script_ContainerClass_GetDeltas(CFXJSE_Arguments* pArguments); + void Script_ModelClass_ClearErrorList(CFXJSE_Arguments* pArguments); + void Script_ModelClass_CreateNode(CFXJSE_Arguments* pArguments); + void Script_ModelClass_IsCompatibleNS(CFXJSE_Arguments* pArguments); + void Script_ModelClass_Context(CFXJSE_Value* pValue, + bool bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_ModelClass_AliasNode(CFXJSE_Value* pValue, + bool bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_WsdlConnection_Execute(CFXJSE_Arguments* pArguments); + void Script_Delta_Restore(CFXJSE_Arguments* pArguments); + void Script_Delta_CurrentValue(CFXJSE_Value* pValue, + bool bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_Delta_SavedValue(CFXJSE_Value* pValue, + bool bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_Delta_Target(CFXJSE_Value* pValue, + bool bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_Attribute_SendAttributeChangeMessage(XFA_ATTRIBUTE eAttribute, + bool bScriptModify); + void Script_Attribute_Integer(CFXJSE_Value* pValue, + bool bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_Attribute_IntegerRead(CFXJSE_Value* pValue, + bool bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_Attribute_BOOL(CFXJSE_Value* pValue, + bool bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_Attribute_BOOLRead(CFXJSE_Value* pValue, + bool bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_Attribute_String(CFXJSE_Value* pValue, + bool bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_Attribute_StringRead(CFXJSE_Value* pValue, + bool bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_Som_ValidationMessage(CFXJSE_Value* pValue, + bool bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_Field_Length(CFXJSE_Value* pValue, + bool bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_Som_DefaultValue(CFXJSE_Value* pValue, + bool bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_Som_DefaultValue_Read(CFXJSE_Value* pValue, + bool bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_Boolean_Value(CFXJSE_Value* pValue, + bool bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_Som_Message(CFXJSE_Value* pValue, + bool bSetting, + XFA_SOM_MESSAGETYPE iMessageType); + void Script_Som_BorderColor(CFXJSE_Value* pValue, + bool bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_Som_BorderWidth(CFXJSE_Value* pValue, + bool bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_Som_FillColor(CFXJSE_Value* pValue, + bool bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_Som_DataNode(CFXJSE_Value* pValue, + bool bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_Som_FontColor(CFXJSE_Value* pValue, + bool bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_Som_Mandatory(CFXJSE_Value* pValue, + bool bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_Som_MandatoryMessage(CFXJSE_Value* pValue, + bool bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_Som_InstanceIndex(CFXJSE_Value* pValue, + bool bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_Draw_DefaultValue(CFXJSE_Value* pValue, + bool bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_Field_DefaultValue(CFXJSE_Value* pValue, + bool bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_Field_EditValue(CFXJSE_Value* pValue, + bool bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_Field_FormatMessage(CFXJSE_Value* pValue, + bool bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_Field_FormattedValue(CFXJSE_Value* pValue, + bool bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_Field_ParentSubform(CFXJSE_Value* pValue, + bool bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_Field_SelectedIndex(CFXJSE_Value* pValue, + bool bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_Field_ClearItems(CFXJSE_Arguments* pArguments); + void Script_Field_ExecEvent(CFXJSE_Arguments* pArguments); + void Script_Field_ExecInitialize(CFXJSE_Arguments* pArguments); + void Script_Field_DeleteItem(CFXJSE_Arguments* pArguments); + void Script_Field_GetSaveItem(CFXJSE_Arguments* pArguments); + void Script_Field_BoundItem(CFXJSE_Arguments* pArguments); + void Script_Field_GetItemState(CFXJSE_Arguments* pArguments); + void Script_Field_ExecCalculate(CFXJSE_Arguments* pArguments); + void Script_Field_SetItems(CFXJSE_Arguments* pArguments); + void Script_Field_GetDisplayItem(CFXJSE_Arguments* pArguments); + void Script_Field_SetItemState(CFXJSE_Arguments* pArguments); + void Script_Field_AddItem(CFXJSE_Arguments* pArguments); + void Script_Field_ExecValidate(CFXJSE_Arguments* pArguments); + void Script_ExclGroup_DefaultAndRawValue(CFXJSE_Value* pValue, + bool bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_ExclGroup_ErrorText(CFXJSE_Value* pValue, + bool bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_ExclGroup_Transient(CFXJSE_Value* pValue, + bool bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_ExclGroup_ExecEvent(CFXJSE_Arguments* pArguments); + void Script_ExclGroup_SelectedMember(CFXJSE_Arguments* pArguments); + void Script_ExclGroup_ExecInitialize(CFXJSE_Arguments* pArguments); + void Script_ExclGroup_ExecCalculate(CFXJSE_Arguments* pArguments); + void Script_ExclGroup_ExecValidate(CFXJSE_Arguments* pArguments); + void Script_Subform_InstanceManager(CFXJSE_Value* pValue, + bool bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_Subform_Locale(CFXJSE_Value* pValue, + bool bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_Subform_ExecEvent(CFXJSE_Arguments* pArguments); + void Script_Subform_ExecInitialize(CFXJSE_Arguments* pArguments); + void Script_Subform_ExecCalculate(CFXJSE_Arguments* pArguments); + void Script_Subform_ExecValidate(CFXJSE_Arguments* pArguments); + void Script_Subform_GetInvalidObjects(CFXJSE_Arguments* pArguments); + + int32_t Subform_and_SubformSet_InstanceIndex(); + void Script_Template_FormNodes(CFXJSE_Arguments* pArguments); + void Script_Template_Remerge(CFXJSE_Arguments* pArguments); + void Script_Template_ExecInitialize(CFXJSE_Arguments* pArguments); + void Script_Template_CreateNode(CFXJSE_Arguments* pArguments); + void Script_Template_Recalculate(CFXJSE_Arguments* pArguments); + void Script_Template_ExecCalculate(CFXJSE_Arguments* pArguments); + void Script_Template_ExecValidate(CFXJSE_Arguments* pArguments); + void Script_Manifest_Evaluate(CFXJSE_Arguments* pArguments); + void Script_InstanceManager_Count(CFXJSE_Value* pValue, + bool bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_InstanceManager_Max(CFXJSE_Value* pValue, + bool bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_InstanceManager_Min(CFXJSE_Value* pValue, + bool bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_InstanceManager_MoveInstance(CFXJSE_Arguments* pArguments); + void Script_InstanceManager_RemoveInstance(CFXJSE_Arguments* pArguments); + void Script_InstanceManager_SetInstances(CFXJSE_Arguments* pArguments); + void Script_InstanceManager_AddInstance(CFXJSE_Arguments* pArguments); + void Script_InstanceManager_InsertInstance(CFXJSE_Arguments* pArguments); + int32_t InstanceManager_SetInstances(int32_t iCount); + int32_t InstanceManager_MoveInstance(int32_t iTo, int32_t iFrom); + void Script_Occur_Max(CFXJSE_Value* pValue, + bool bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_Occur_Min(CFXJSE_Value* pValue, + bool bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_Desc_Metadata(CFXJSE_Arguments* pArguments); + void Script_Form_FormNodes(CFXJSE_Arguments* pArguments); + void Script_Form_Remerge(CFXJSE_Arguments* pArguments); + void Script_Form_ExecInitialize(CFXJSE_Arguments* pArguments); + void Script_Form_Recalculate(CFXJSE_Arguments* pArguments); + void Script_Form_ExecCalculate(CFXJSE_Arguments* pArguments); + void Script_Form_ExecValidate(CFXJSE_Arguments* pArguments); + void Script_Form_Checksum(CFXJSE_Value* pValue, + bool bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_Packet_GetAttribute(CFXJSE_Arguments* pArguments); + void Script_Packet_SetAttribute(CFXJSE_Arguments* pArguments); + void Script_Packet_RemoveAttribute(CFXJSE_Arguments* pArguments); + void Script_Packet_Content(CFXJSE_Value* pValue, + bool bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_Source_Next(CFXJSE_Arguments* pArguments); + void Script_Source_CancelBatch(CFXJSE_Arguments* pArguments); + void Script_Source_First(CFXJSE_Arguments* pArguments); + void Script_Source_UpdateBatch(CFXJSE_Arguments* pArguments); + void Script_Source_Previous(CFXJSE_Arguments* pArguments); + void Script_Source_IsBOF(CFXJSE_Arguments* pArguments); + void Script_Source_IsEOF(CFXJSE_Arguments* pArguments); + void Script_Source_Cancel(CFXJSE_Arguments* pArguments); + void Script_Source_Update(CFXJSE_Arguments* pArguments); + void Script_Source_Open(CFXJSE_Arguments* pArguments); + void Script_Source_Delete(CFXJSE_Arguments* pArguments); + void Script_Source_AddNew(CFXJSE_Arguments* pArguments); + void Script_Source_Requery(CFXJSE_Arguments* pArguments); + void Script_Source_Resync(CFXJSE_Arguments* pArguments); + void Script_Source_Close(CFXJSE_Arguments* pArguments); + void Script_Source_Last(CFXJSE_Arguments* pArguments); + void Script_Source_HasDataChanged(CFXJSE_Arguments* pArguments); + void Script_Source_Db(CFXJSE_Value* pValue, + bool bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_Xfa_This(CFXJSE_Value* pValue, + bool bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_Handler_Version(CFXJSE_Value* pValue, + bool bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_SubmitFormat_Mode(CFXJSE_Value* pValue, + bool bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_Extras_Type(CFXJSE_Value* pValue, + bool bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_Encrypt_Format(CFXJSE_Value* pValue, + bool bSetting, + XFA_ATTRIBUTE eAttribute); + void Script_Script_Stateless(CFXJSE_Value* pValue, + bool bSetting, + XFA_ATTRIBUTE eAttribute); + + private: + friend class CXFA_Document; + + CXFA_Node(CXFA_Document* pDoc, + uint16_t ePacket, + XFA_ObjectType oType, + XFA_Element eType, + const CFX_WideStringC& elementName); + ~CXFA_Node() override; + + bool HasFlag(XFA_NodeFlag dwFlag) const; + CXFA_Node* Deprecated_GetPrevSibling(); + bool SetValue(XFA_ATTRIBUTE eAttr, + XFA_ATTRIBUTETYPE eType, + void* pValue, + bool bNotify); + bool GetValue(XFA_ATTRIBUTE eAttr, + XFA_ATTRIBUTETYPE eType, + bool bUseDefault, + void*& pValue); + void OnRemoved(bool bNotify); + void OnChanging(XFA_ATTRIBUTE eAttr, bool bNotify); + void OnChanged(XFA_ATTRIBUTE eAttr, bool bNotify, bool bScriptModify); + int32_t execSingleEventByName(const CFX_WideStringC& wsEventName, + XFA_Element eType); + bool SetScriptContent(const CFX_WideString& wsContent, + const CFX_WideString& wsXMLValue, + bool bNotify = true, + bool bScriptModify = false, + bool bSyncData = true); + CFX_WideString GetScriptContent(bool bScriptModify = false); + XFA_MAPMODULEDATA* CreateMapModuleData(); + XFA_MAPMODULEDATA* GetMapModuleData() const; + void SetMapModuleValue(void* pKey, void* pValue); + bool GetMapModuleValue(void* pKey, void*& pValue); + void SetMapModuleString(void* pKey, const CFX_WideStringC& wsValue); + bool GetMapModuleString(void* pKey, CFX_WideStringC& wsValue); + void SetMapModuleBuffer( + void* pKey, + void* pValue, + int32_t iBytes, + XFA_MAPDATABLOCKCALLBACKINFO* pCallbackInfo = nullptr); + bool GetMapModuleBuffer(void* pKey, + void*& pValue, + int32_t& iBytes, + bool bProtoAlso = true) const; + bool HasMapModuleKey(void* pKey, bool bProtoAlso = false); + void RemoveMapModuleKey(void* pKey = nullptr); + void MergeAllData(void* pDstModule); + void MoveBufferMapData(CXFA_Node* pDstModule, void* pKey); + void MoveBufferMapData(CXFA_Node* pSrcModule, + CXFA_Node* pDstModule, + void* pKey, + bool bRecursive = false); + + CXFA_Node* m_pNext; + CXFA_Node* m_pChild; + CXFA_Node* m_pLastChild; + CXFA_Node* m_pParent; + CFDE_XMLNode* m_pXMLNode; + uint16_t m_ePacket; + uint16_t m_uNodeFlags; + uint32_t m_dwNameHash; + CXFA_Node* m_pAuxNode; + XFA_MAPMODULEDATA* m_pMapModuleData; + + private: + void ThrowMissingPropertyException(const CFX_WideString& obj, + const CFX_WideString& prop) const; + void ThrowTooManyOccurancesException(const CFX_WideString& obj) const; +}; + +#endif // XFA_FXFA_PARSER_CXFA_NODE_H_ diff --git a/xfa/fxfa/parser/cxfa_nodehelper.cpp b/xfa/fxfa/parser/cxfa_nodehelper.cpp index 6a9904af04..abfca84609 100644 --- a/xfa/fxfa/parser/cxfa_nodehelper.cpp +++ b/xfa/fxfa/parser/cxfa_nodehelper.cpp @@ -9,8 +9,8 @@ #include "core/fxcrt/fx_ext.h" #include "xfa/fxfa/parser/cxfa_document.h" #include "xfa/fxfa/parser/cxfa_localemgr.h" +#include "xfa/fxfa/parser/cxfa_node.h" #include "xfa/fxfa/parser/cxfa_scriptcontext.h" -#include "xfa/fxfa/parser/xfa_object.h" #include "xfa/fxfa/parser/xfa_resolvenode_rs.h" #include "xfa/fxfa/parser/xfa_utils.h" diff --git a/xfa/fxfa/parser/cxfa_nodehelper.h b/xfa/fxfa/parser/cxfa_nodehelper.h index d26ccf64e9..cf6c2f17a0 100644 --- a/xfa/fxfa/parser/cxfa_nodehelper.h +++ b/xfa/fxfa/parser/cxfa_nodehelper.h @@ -9,7 +9,6 @@ #include -#include "xfa/fxfa/parser/xfa_object.h" #include "xfa/fxfa/parser/xfa_resolvenode_rs.h" class CXFA_ScriptContext; diff --git a/xfa/fxfa/parser/cxfa_nodelist.cpp b/xfa/fxfa/parser/cxfa_nodelist.cpp index 97c531f33b..86efb29eba 100644 --- a/xfa/fxfa/parser/cxfa_nodelist.cpp +++ b/xfa/fxfa/parser/cxfa_nodelist.cpp @@ -4,12 +4,13 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#include "xfa/fxfa/parser/xfa_object.h" +#include "xfa/fxfa/parser/cxfa_nodelist.h" #include #include "core/fxcrt/fx_ext.h" #include "xfa/fxfa/parser/cxfa_document.h" +#include "xfa/fxfa/parser/cxfa_node.h" #include "xfa/fxfa/parser/cxfa_scriptcontext.h" CXFA_NodeList::CXFA_NodeList(CXFA_Document* pDocument) diff --git a/xfa/fxfa/parser/cxfa_nodelist.h b/xfa/fxfa/parser/cxfa_nodelist.h new file mode 100644 index 0000000000..6fffb7bb67 --- /dev/null +++ b/xfa/fxfa/parser/cxfa_nodelist.h @@ -0,0 +1,40 @@ +// Copyright 2017 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_NODELIST_H_ +#define XFA_FXFA_PARSER_CXFA_NODELIST_H_ + +#include "xfa/fxfa/fxfa_basic.h" +#include "xfa/fxfa/parser/cxfa_object.h" + +class CXFA_Node; +class CFXJSE_Arguments; +class CFXJSE_Value; + +class CXFA_NodeList : public CXFA_Object { + public: + explicit CXFA_NodeList(CXFA_Document* pDocument); + ~CXFA_NodeList() override; + + CXFA_Node* NamedItem(const CFX_WideStringC& wsName); + virtual int32_t GetLength() = 0; + virtual bool Append(CXFA_Node* pNode) = 0; + virtual bool Insert(CXFA_Node* pNewNode, CXFA_Node* pBeforeNode) = 0; + virtual bool Remove(CXFA_Node* pNode) = 0; + virtual CXFA_Node* Item(int32_t iIndex) = 0; + + void Script_ListClass_Append(CFXJSE_Arguments* pArguments); + void Script_ListClass_Insert(CFXJSE_Arguments* pArguments); + void Script_ListClass_Remove(CFXJSE_Arguments* pArguments); + void Script_ListClass_Item(CFXJSE_Arguments* pArguments); + + void Script_TreelistClass_NamedItem(CFXJSE_Arguments* pArguments); + void Script_ListClass_Length(CFXJSE_Value* pValue, + bool bSetting, + XFA_ATTRIBUTE eAttribute); +}; + +#endif // XFA_FXFA_PARSER_CXFA_NODELIST_H_ diff --git a/xfa/fxfa/parser/cxfa_nodelocale.cpp b/xfa/fxfa/parser/cxfa_nodelocale.cpp index fac3cc3335..1280b61c76 100644 --- a/xfa/fxfa/parser/cxfa_nodelocale.cpp +++ b/xfa/fxfa/parser/cxfa_nodelocale.cpp @@ -11,8 +11,8 @@ #include "core/fxcrt/fx_xml.h" #include "xfa/fxfa/parser/cxfa_document.h" #include "xfa/fxfa/parser/cxfa_localemgr.h" +#include "xfa/fxfa/parser/cxfa_node.h" #include "xfa/fxfa/parser/cxfa_timezoneprovider.h" -#include "xfa/fxfa/parser/xfa_object.h" #include "xfa/fxfa/parser/xfa_utils.h" namespace { diff --git a/xfa/fxfa/parser/cxfa_nodelocale.h b/xfa/fxfa/parser/cxfa_nodelocale.h index 0059d19888..6758ad4eb3 100644 --- a/xfa/fxfa/parser/cxfa_nodelocale.h +++ b/xfa/fxfa/parser/cxfa_nodelocale.h @@ -10,7 +10,9 @@ #include #include "xfa/fgas/localization/fgas_locale.h" -#include "xfa/fxfa/parser/xfa_object.h" +#include "xfa/fxfa/fxfa_basic.h" + +class CXFA_Node; CFX_WideString XFA_PatternToString(FX_LOCALENUMSUBCATEGORY category); diff --git a/xfa/fxfa/parser/cxfa_object.cpp b/xfa/fxfa/parser/cxfa_object.cpp index 4964265b4d..9bbee4ec75 100644 --- a/xfa/fxfa/parser/cxfa_object.cpp +++ b/xfa/fxfa/parser/cxfa_object.cpp @@ -4,12 +4,14 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#include "xfa/fxfa/parser/xfa_object.h" +#include "xfa/fxfa/parser/cxfa_object.h" #include "core/fxcrt/fx_ext.h" #include "fxjs/cfxjse_value.h" #include "xfa/fxfa/app/xfa_ffnotify.h" #include "xfa/fxfa/parser/cxfa_document.h" +#include "xfa/fxfa/parser/cxfa_node.h" +#include "xfa/fxfa/parser/cxfa_nodelist.h" CXFA_Object::CXFA_Object(CXFA_Document* pDocument, XFA_ObjectType objectType, @@ -23,18 +25,6 @@ CXFA_Object::CXFA_Object(CXFA_Document* pDocument, CXFA_Object::~CXFA_Object() {} -CFX_WideStringC CXFA_Object::GetClassName() const { - return m_elementName; -} - -uint32_t CXFA_Object::GetClassHashCode() const { - return m_elementNameHash; -} - -XFA_Element CXFA_Object::GetElementType() const { - return m_elementType; -} - void CXFA_Object::Script_ObjectClass_ClassName(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { @@ -71,3 +61,27 @@ void CXFA_Object::ThrowException(const wchar_t* str, ...) const { va_end(arg_ptr); FXJSE_ThrowMessage(wsMessage.UTF8Encode().AsStringC()); } + +CXFA_Node* CXFA_Object::AsNode() { + return IsNode() ? static_cast(this) : nullptr; +} + +CXFA_NodeList* CXFA_Object::AsNodeList() { + return IsNodeList() ? static_cast(this) : nullptr; +} + +const CXFA_Node* CXFA_Object::AsNode() const { + return IsNode() ? static_cast(this) : nullptr; +} + +const CXFA_NodeList* CXFA_Object::AsNodeList() const { + return IsNodeList() ? static_cast(this) : nullptr; +} + +CXFA_Node* ToNode(CXFA_Object* pObj) { + return pObj ? pObj->AsNode() : nullptr; +} + +const CXFA_Node* ToNode(const CXFA_Object* pObj) { + return pObj ? pObj->AsNode() : nullptr; +} diff --git a/xfa/fxfa/parser/cxfa_object.h b/xfa/fxfa/parser/cxfa_object.h new file mode 100644 index 0000000000..9596453712 --- /dev/null +++ b/xfa/fxfa/parser/cxfa_object.h @@ -0,0 +1,100 @@ +// Copyright 2017 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_OBJECT_H_ +#define XFA_FXFA_PARSER_CXFA_OBJECT_H_ + +#include "core/fxcrt/fx_string.h" +#include "fxjs/fxjse.h" +#include "xfa/fxfa/fxfa_basic.h" + +enum class XFA_ObjectType { + Object, + List, + NodeList, + Node, + NodeC, + NodeV, + ModelNode, + TextNode, + ContainerNode, + ContentNode, + VariablesThis +}; + +class CFXJSE_Value; +class CXFA_Document; +class CXFA_Node; +class CXFA_NodeList; + +class CXFA_Object : public CFXJSE_HostObject { + public: + CXFA_Object(CXFA_Document* pDocument, + XFA_ObjectType objectType, + XFA_Element eType, + const CFX_WideStringC& elementName); + ~CXFA_Object() override; + + CXFA_Document* GetDocument() const { return m_pDocument; } + XFA_ObjectType GetObjectType() const { return m_objectType; } + + bool IsNode() const { + return m_objectType == XFA_ObjectType::Node || + m_objectType == XFA_ObjectType::NodeC || + m_objectType == XFA_ObjectType::NodeV || + m_objectType == XFA_ObjectType::ModelNode || + m_objectType == XFA_ObjectType::TextNode || + m_objectType == XFA_ObjectType::ContainerNode || + m_objectType == XFA_ObjectType::ContentNode || + m_objectType == XFA_ObjectType::VariablesThis; + } + bool IsNodeList() const { return m_objectType == XFA_ObjectType::NodeList; } + bool IsContentNode() const { + return m_objectType == XFA_ObjectType::ContentNode; + } + bool IsContainerNode() const { + return m_objectType == XFA_ObjectType::ContainerNode; + } + bool IsModelNode() const { return m_objectType == XFA_ObjectType::ModelNode; } + bool IsNodeV() const { return m_objectType == XFA_ObjectType::NodeV; } + bool IsVariablesThis() const { + return m_objectType == XFA_ObjectType::VariablesThis; + } + + CXFA_Node* AsNode(); + CXFA_NodeList* AsNodeList(); + + const CXFA_Node* AsNode() const; + const CXFA_NodeList* AsNodeList() const; + + XFA_Element GetElementType() const { return m_elementType; } + CFX_WideStringC GetClassName() const { return m_elementName; } + uint32_t GetClassHashCode() const { return m_elementNameHash; } + + void Script_ObjectClass_ClassName(CFXJSE_Value* pValue, + bool bSetting, + XFA_ATTRIBUTE eAttribute); + + void ThrowInvalidPropertyException() const; + void ThrowArgumentMismatchException() const; + void ThrowIndexOutOfBoundsException() const; + void ThrowParamCountMismatchException(const CFX_WideString& method) const; + + protected: + void ThrowException(const wchar_t* str, ...) const; + + CXFA_Document* const m_pDocument; + const XFA_ObjectType m_objectType; + const XFA_Element m_elementType; + + const uint32_t m_elementNameHash; + const CFX_WideStringC m_elementName; +}; + +CXFA_Node* ToNode(CXFA_Object* pObj); +const CXFA_Node* ToNode(const CXFA_Object* pObj); + +#endif // XFA_FXFA_PARSER_CXFA_OBJECT_H_ diff --git a/xfa/fxfa/parser/cxfa_occur.cpp b/xfa/fxfa/parser/cxfa_occur.cpp index a8994223f9..ddce8d6422 100644 --- a/xfa/fxfa/parser/cxfa_occur.cpp +++ b/xfa/fxfa/parser/cxfa_occur.cpp @@ -6,7 +6,7 @@ #include "xfa/fxfa/parser/cxfa_occur.h" -#include "xfa/fxfa/parser/xfa_object.h" +#include "xfa/fxfa/parser/cxfa_node.h" CXFA_Occur::CXFA_Occur(CXFA_Node* pNode) : CXFA_Data(pNode) {} diff --git a/xfa/fxfa/parser/cxfa_para.cpp b/xfa/fxfa/parser/cxfa_para.cpp index 3fe4b68f05..c3d55f2164 100644 --- a/xfa/fxfa/parser/cxfa_para.cpp +++ b/xfa/fxfa/parser/cxfa_para.cpp @@ -7,7 +7,7 @@ #include "xfa/fxfa/parser/cxfa_para.h" #include "xfa/fxfa/parser/cxfa_measurement.h" -#include "xfa/fxfa/parser/xfa_object.h" +#include "xfa/fxfa/parser/cxfa_node.h" CXFA_Para::CXFA_Para(CXFA_Node* pNode) : CXFA_Data(pNode) {} diff --git a/xfa/fxfa/parser/cxfa_resolveprocessor.cpp b/xfa/fxfa/parser/cxfa_resolveprocessor.cpp index 391e63aac5..51487a1e2b 100644 --- a/xfa/fxfa/parser/cxfa_resolveprocessor.cpp +++ b/xfa/fxfa/parser/cxfa_resolveprocessor.cpp @@ -15,9 +15,10 @@ #include "third_party/base/stl_util.h" #include "xfa/fxfa/parser/cxfa_document.h" #include "xfa/fxfa/parser/cxfa_localemgr.h" +#include "xfa/fxfa/parser/cxfa_node.h" #include "xfa/fxfa/parser/cxfa_nodehelper.h" +#include "xfa/fxfa/parser/cxfa_object.h" #include "xfa/fxfa/parser/cxfa_scriptcontext.h" -#include "xfa/fxfa/parser/xfa_object.h" #include "xfa/fxfa/parser/xfa_resolvenode_rs.h" #include "xfa/fxfa/parser/xfa_utils.h" diff --git a/xfa/fxfa/parser/cxfa_resolveprocessor.h b/xfa/fxfa/parser/cxfa_resolveprocessor.h index a44282a43d..f4eafea023 100644 --- a/xfa/fxfa/parser/cxfa_resolveprocessor.h +++ b/xfa/fxfa/parser/cxfa_resolveprocessor.h @@ -10,7 +10,6 @@ #include #include -#include "xfa/fxfa/parser/xfa_object.h" #include "xfa/fxfa/parser/xfa_resolvenode_rs.h" class CXFA_NodeHelper; diff --git a/xfa/fxfa/parser/cxfa_script.cpp b/xfa/fxfa/parser/cxfa_script.cpp index 16f65f99f4..ccd1997c47 100644 --- a/xfa/fxfa/parser/cxfa_script.cpp +++ b/xfa/fxfa/parser/cxfa_script.cpp @@ -6,7 +6,7 @@ #include "xfa/fxfa/parser/cxfa_script.h" -#include "xfa/fxfa/parser/xfa_object.h" +#include "xfa/fxfa/parser/cxfa_node.h" CXFA_Script::CXFA_Script(CXFA_Node* pNode) : CXFA_Data(pNode) {} diff --git a/xfa/fxfa/parser/cxfa_scriptcontext.cpp b/xfa/fxfa/parser/cxfa_scriptcontext.cpp index d62027ef03..37f59bd71b 100644 --- a/xfa/fxfa/parser/cxfa_scriptcontext.cpp +++ b/xfa/fxfa/parser/cxfa_scriptcontext.cpp @@ -18,10 +18,13 @@ #include "xfa/fxfa/cxfa_eventparam.h" #include "xfa/fxfa/parser/cxfa_document.h" #include "xfa/fxfa/parser/cxfa_localemgr.h" +#include "xfa/fxfa/parser/cxfa_node.h" #include "xfa/fxfa/parser/cxfa_nodehelper.h" +#include "xfa/fxfa/parser/cxfa_nodelist.h" +#include "xfa/fxfa/parser/cxfa_object.h" #include "xfa/fxfa/parser/cxfa_resolveprocessor.h" +#include "xfa/fxfa/parser/cxfa_thisproxy.h" #include "xfa/fxfa/parser/xfa_basic_data.h" -#include "xfa/fxfa/parser/xfa_object.h" #include "xfa/fxfa/parser/xfa_resolvenode_rs.h" #include "xfa/fxfa/parser/xfa_utils.h" diff --git a/xfa/fxfa/parser/cxfa_simple_parser.cpp b/xfa/fxfa/parser/cxfa_simple_parser.cpp index 70791b6932..a4a785c98e 100644 --- a/xfa/fxfa/parser/cxfa_simple_parser.cpp +++ b/xfa/fxfa/parser/cxfa_simple_parser.cpp @@ -14,6 +14,7 @@ #include "xfa/fxfa/cxfa_checksumcontext.h" #include "xfa/fxfa/fxfa.h" #include "xfa/fxfa/parser/cxfa_document.h" +#include "xfa/fxfa/parser/cxfa_node.h" #include "xfa/fxfa/parser/cxfa_widetextread.h" #include "xfa/fxfa/parser/cxfa_xml_parser.h" #include "xfa/fxfa/parser/xfa_basic_data.h" diff --git a/xfa/fxfa/parser/cxfa_stroke.cpp b/xfa/fxfa/parser/cxfa_stroke.cpp index 2faad24a97..2e1ef12ce5 100644 --- a/xfa/fxfa/parser/cxfa_stroke.cpp +++ b/xfa/fxfa/parser/cxfa_stroke.cpp @@ -7,7 +7,8 @@ #include "xfa/fxfa/parser/cxfa_stroke.h" #include "xfa/fxfa/parser/cxfa_measurement.h" -#include "xfa/fxfa/parser/xfa_object.h" +#include "xfa/fxfa/parser/cxfa_node.h" +#include "xfa/fxfa/parser/xfa_utils.h" int32_t CXFA_Stroke::GetPresence() const { return m_pNode ? m_pNode->GetEnum(XFA_ATTRIBUTE_Presence) diff --git a/xfa/fxfa/parser/cxfa_submit.cpp b/xfa/fxfa/parser/cxfa_submit.cpp index 50bef1e811..e390e6314b 100644 --- a/xfa/fxfa/parser/cxfa_submit.cpp +++ b/xfa/fxfa/parser/cxfa_submit.cpp @@ -6,7 +6,7 @@ #include "xfa/fxfa/parser/cxfa_submit.h" -#include "xfa/fxfa/parser/xfa_object.h" +#include "xfa/fxfa/parser/cxfa_node.h" CXFA_Submit::CXFA_Submit(CXFA_Node* pNode) : CXFA_Data(pNode) {} diff --git a/xfa/fxfa/parser/cxfa_text.cpp b/xfa/fxfa/parser/cxfa_text.cpp index fc7d7aa280..192a4deac4 100644 --- a/xfa/fxfa/parser/cxfa_text.cpp +++ b/xfa/fxfa/parser/cxfa_text.cpp @@ -6,7 +6,7 @@ #include "xfa/fxfa/parser/cxfa_text.h" -#include "xfa/fxfa/parser/xfa_object.h" +#include "xfa/fxfa/parser/cxfa_node.h" CXFA_Text::CXFA_Text(CXFA_Node* pNode) : CXFA_Data(pNode) {} diff --git a/xfa/fxfa/parser/cxfa_thisproxy.cpp b/xfa/fxfa/parser/cxfa_thisproxy.cpp index bf6f12c804..2938c1fb3f 100644 --- a/xfa/fxfa/parser/cxfa_thisproxy.cpp +++ b/xfa/fxfa/parser/cxfa_thisproxy.cpp @@ -4,7 +4,9 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#include "xfa/fxfa/parser/xfa_object.h" +#include "xfa/fxfa/parser/cxfa_thisproxy.h" + +#include "xfa/fxfa/parser/cxfa_node.h" CXFA_ThisProxy::CXFA_ThisProxy(CXFA_Node* pThisNode, CXFA_Node* pScriptNode) : CXFA_Object(pThisNode->GetDocument(), @@ -18,11 +20,3 @@ CXFA_ThisProxy::CXFA_ThisProxy(CXFA_Node* pThisNode, CXFA_Node* pScriptNode) } CXFA_ThisProxy::~CXFA_ThisProxy() {} - -CXFA_Node* CXFA_ThisProxy::GetThisNode() const { - return m_pThisNode; -} - -CXFA_Node* CXFA_ThisProxy::GetScriptNode() const { - return m_pScriptNode; -} diff --git a/xfa/fxfa/parser/cxfa_thisproxy.h b/xfa/fxfa/parser/cxfa_thisproxy.h new file mode 100644 index 0000000000..4bb0f5a1b5 --- /dev/null +++ b/xfa/fxfa/parser/cxfa_thisproxy.h @@ -0,0 +1,27 @@ +// Copyright 2017 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_THISPROXY_H_ +#define XFA_FXFA_PARSER_CXFA_THISPROXY_H_ + +#include "xfa/fxfa/parser/cxfa_object.h" + +class CXFA_Node; + +class CXFA_ThisProxy : public CXFA_Object { + public: + CXFA_ThisProxy(CXFA_Node* pThisNode, CXFA_Node* pScriptNode); + ~CXFA_ThisProxy() override; + + CXFA_Node* GetThisNode() const { return m_pThisNode; } + CXFA_Node* GetScriptNode() const { return m_pScriptNode; } + + private: + CXFA_Node* m_pThisNode; + CXFA_Node* m_pScriptNode; +}; + +#endif // XFA_FXFA_PARSER_CXFA_THISPROXY_H_ diff --git a/xfa/fxfa/parser/cxfa_tooltip.cpp b/xfa/fxfa/parser/cxfa_tooltip.cpp index afe0e224af..f3de7aa591 100644 --- a/xfa/fxfa/parser/cxfa_tooltip.cpp +++ b/xfa/fxfa/parser/cxfa_tooltip.cpp @@ -6,7 +6,7 @@ #include "xfa/fxfa/parser/cxfa_tooltip.h" -#include "xfa/fxfa/parser/xfa_object.h" +#include "xfa/fxfa/parser/cxfa_node.h" CXFA_ToolTip::CXFA_ToolTip(CXFA_Node* pNode) : CXFA_Data(pNode) {} diff --git a/xfa/fxfa/parser/cxfa_traversestrategy_xfacontainernode.h b/xfa/fxfa/parser/cxfa_traversestrategy_xfacontainernode.h new file mode 100644 index 0000000000..d507c262fe --- /dev/null +++ b/xfa/fxfa/parser/cxfa_traversestrategy_xfacontainernode.h @@ -0,0 +1,33 @@ +// Copyright 2017 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_TRAVERSESTRATEGY_XFACONTAINERNODE_H_ +#define XFA_FXFA_PARSER_CXFA_TRAVERSESTRATEGY_XFACONTAINERNODE_H_ + +#include "xfa/fxfa/parser/cxfa_node.h" +#include "xfa/fxfa/parser/xfa_utils.h" + +class CXFA_TraverseStrategy_XFAContainerNode { + public: + static CXFA_Node* GetFirstChild(CXFA_Node* pTemplateNode) { + return pTemplateNode->GetNodeItem(XFA_NODEITEM_FirstChild, + XFA_ObjectType::ContainerNode); + } + static CXFA_Node* GetNextSibling(CXFA_Node* pTemplateNode) { + return pTemplateNode->GetNodeItem(XFA_NODEITEM_NextSibling, + XFA_ObjectType::ContainerNode); + } + static CXFA_Node* GetParent(CXFA_Node* pTemplateNode) { + return pTemplateNode->GetNodeItem(XFA_NODEITEM_Parent, + XFA_ObjectType::ContainerNode); + } +}; + +typedef CXFA_NodeIteratorTemplate + CXFA_ContainerIterator; + +#endif // XFA_FXFA_PARSER_CXFA_TRAVERSESTRATEGY_XFACONTAINERNODE_H_ diff --git a/xfa/fxfa/parser/cxfa_traversestrategy_xfanode.h b/xfa/fxfa/parser/cxfa_traversestrategy_xfanode.h new file mode 100644 index 0000000000..b6fb156cb9 --- /dev/null +++ b/xfa/fxfa/parser/cxfa_traversestrategy_xfanode.h @@ -0,0 +1,28 @@ +// Copyright 2017 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_TRAVERSESTRATEGY_XFANODE_H_ +#define XFA_FXFA_PARSER_CXFA_TRAVERSESTRATEGY_XFANODE_H_ + +#include "xfa/fxfa/parser/xfa_utils.h" + +class CXFA_TraverseStrategy_XFANode { + public: + static inline CXFA_Node* GetFirstChild(CXFA_Node* pTemplateNode) { + return pTemplateNode->GetNodeItem(XFA_NODEITEM_FirstChild); + } + static inline CXFA_Node* GetNextSibling(CXFA_Node* pTemplateNode) { + return pTemplateNode->GetNodeItem(XFA_NODEITEM_NextSibling); + } + static inline CXFA_Node* GetParent(CXFA_Node* pTemplateNode) { + return pTemplateNode->GetNodeItem(XFA_NODEITEM_Parent); + } +}; + +typedef CXFA_NodeIteratorTemplate + CXFA_NodeIterator; + +#endif // XFA_FXFA_PARSER_CXFA_TRAVERSESTRATEGY_XFANODE_H_ diff --git a/xfa/fxfa/parser/cxfa_validate.cpp b/xfa/fxfa/parser/cxfa_validate.cpp index 5706d96aaa..712d0f2829 100644 --- a/xfa/fxfa/parser/cxfa_validate.cpp +++ b/xfa/fxfa/parser/cxfa_validate.cpp @@ -6,7 +6,8 @@ #include "xfa/fxfa/parser/cxfa_validate.h" -#include "xfa/fxfa/parser/xfa_object.h" +#include "xfa/fxfa/parser/cxfa_node.h" +#include "xfa/fxfa/parser/xfa_utils.h" CXFA_Validate::CXFA_Validate(CXFA_Node* pNode) : CXFA_Data(pNode) {} diff --git a/xfa/fxfa/parser/cxfa_value.cpp b/xfa/fxfa/parser/cxfa_value.cpp index 4d467aee2c..4f166d5d42 100644 --- a/xfa/fxfa/parser/cxfa_value.cpp +++ b/xfa/fxfa/parser/cxfa_value.cpp @@ -6,7 +6,7 @@ #include "xfa/fxfa/parser/cxfa_value.h" -#include "xfa/fxfa/parser/xfa_object.h" +#include "xfa/fxfa/parser/cxfa_node.h" XFA_Element CXFA_Value::GetChildValueClassID() { if (!m_pNode) diff --git a/xfa/fxfa/parser/cxfa_widgetdata.cpp b/xfa/fxfa/parser/cxfa_widgetdata.cpp index 6da501b4a3..d98b86c086 100644 --- a/xfa/fxfa/parser/cxfa_widgetdata.cpp +++ b/xfa/fxfa/parser/cxfa_widgetdata.cpp @@ -14,7 +14,8 @@ #include "xfa/fxfa/parser/cxfa_event.h" #include "xfa/fxfa/parser/cxfa_localevalue.h" #include "xfa/fxfa/parser/cxfa_measurement.h" -#include "xfa/fxfa/parser/xfa_object.h" +#include "xfa/fxfa/parser/cxfa_node.h" +#include "xfa/fxfa/parser/xfa_utils.h" namespace { diff --git a/xfa/fxfa/parser/cxfa_widgetdata.h b/xfa/fxfa/parser/cxfa_widgetdata.h index 1caecea2b2..fb940f4e20 100644 --- a/xfa/fxfa/parser/cxfa_widgetdata.h +++ b/xfa/fxfa/parser/cxfa_widgetdata.h @@ -21,7 +21,6 @@ #include "xfa/fxfa/parser/cxfa_margin.h" #include "xfa/fxfa/parser/cxfa_para.h" #include "xfa/fxfa/parser/cxfa_validate.h" -#include "xfa/fxfa/parser/xfa_object.h" enum XFA_CHECKSTATE { XFA_CHECKSTATE_On = 0, diff --git a/xfa/fxfa/parser/cxfa_xmllocale.cpp b/xfa/fxfa/parser/cxfa_xmllocale.cpp index cbac7772a2..aa5c942ef3 100644 --- a/xfa/fxfa/parser/cxfa_xmllocale.cpp +++ b/xfa/fxfa/parser/cxfa_xmllocale.cpp @@ -13,7 +13,6 @@ #include "xfa/fxfa/parser/cxfa_localemgr.h" #include "xfa/fxfa/parser/cxfa_nodelocale.h" #include "xfa/fxfa/parser/cxfa_timezoneprovider.h" -#include "xfa/fxfa/parser/xfa_object.h" #include "xfa/fxfa/parser/xfa_utils.h" CXFA_XMLLocale::CXFA_XMLLocale(std::unique_ptr pLocaleData) diff --git a/xfa/fxfa/parser/cxfa_xmllocale.h b/xfa/fxfa/parser/cxfa_xmllocale.h index 7616c115a1..592b0b5bab 100644 --- a/xfa/fxfa/parser/cxfa_xmllocale.h +++ b/xfa/fxfa/parser/cxfa_xmllocale.h @@ -10,7 +10,6 @@ #include #include "xfa/fgas/localization/fgas_locale.h" -#include "xfa/fxfa/parser/xfa_object.h" class CXFA_XMLLocale : public IFX_Locale { public: diff --git a/xfa/fxfa/parser/xfa_basic_data.cpp b/xfa/fxfa/parser/xfa_basic_data.cpp index fecc942c7d..8e2986fecf 100644 --- a/xfa/fxfa/parser/xfa_basic_data.cpp +++ b/xfa/fxfa/parser/xfa_basic_data.cpp @@ -7,7 +7,7 @@ #include "xfa/fxfa/parser/xfa_basic_data.h" #include "xfa/fxfa/fxfa_basic.h" -#include "xfa/fxfa/parser/xfa_object.h" +#include "xfa/fxfa/parser/cxfa_object.h" const XFA_ELEMENTINFO g_XFAElementData[] = { {0x23ee3, L"ps", XFA_Element::Ps, XFA_XDPPACKET_Config, diff --git a/xfa/fxfa/parser/xfa_basic_data_element_script.cpp b/xfa/fxfa/parser/xfa_basic_data_element_script.cpp index 675fb8a39a..bb8a985740 100644 --- a/xfa/fxfa/parser/xfa_basic_data_element_script.cpp +++ b/xfa/fxfa/parser/xfa_basic_data_element_script.cpp @@ -13,6 +13,8 @@ #include "xfa/fxfa/parser/cscript_layoutpseudomodel.h" #include "xfa/fxfa/parser/cscript_logpseudomodel.h" #include "xfa/fxfa/parser/cscript_signaturepseudomodel.h" +#include "xfa/fxfa/parser/cxfa_node.h" +#include "xfa/fxfa/parser/cxfa_nodelist.h" const XFA_SCRIPTHIERARCHY g_XFAScriptIndex[] = { {0, 0, 0, 2, 316}, {0, 0, 2, 2, 316}, {0, 0, 4, 2, 316}, diff --git a/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp b/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp index 7ee11beb01..e54bf4a05f 100644 --- a/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp +++ b/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp @@ -15,9 +15,11 @@ #include "xfa/fxfa/parser/cxfa_document.h" #include "xfa/fxfa/parser/cxfa_layoutprocessor.h" #include "xfa/fxfa/parser/cxfa_localemgr.h" +#include "xfa/fxfa/parser/cxfa_node.h" #include "xfa/fxfa/parser/cxfa_occur.h" #include "xfa/fxfa/parser/cxfa_scriptcontext.h" -#include "xfa/fxfa/parser/xfa_object.h" +#include "xfa/fxfa/parser/cxfa_traversestrategy_xfacontainernode.h" +#include "xfa/fxfa/parser/cxfa_traversestrategy_xfanode.h" #include "xfa/fxfa/parser/xfa_resolvenode_rs.h" #include "xfa/fxfa/parser/xfa_utils.h" diff --git a/xfa/fxfa/parser/xfa_document_datamerger_imp.h b/xfa/fxfa/parser/xfa_document_datamerger_imp.h index 2337502a4f..9e58678867 100644 --- a/xfa/fxfa/parser/xfa_document_datamerger_imp.h +++ b/xfa/fxfa/parser/xfa_document_datamerger_imp.h @@ -9,7 +9,10 @@ #include -#include "xfa/fxfa/parser/xfa_object.h" +#include "xfa/fxfa/fxfa_basic.h" + +class CXFA_Document; +class CXFA_Node; CXFA_Node* XFA_NodeMerge_CloneOrMergeContainer( CXFA_Document* pDocument, diff --git a/xfa/fxfa/parser/xfa_object.h b/xfa/fxfa/parser/xfa_object.h deleted file mode 100644 index 3e98a4747c..0000000000 --- a/xfa/fxfa/parser/xfa_object.h +++ /dev/null @@ -1,818 +0,0 @@ -// Copyright 2014 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_XFA_OBJECT_H_ -#define XFA_FXFA_PARSER_XFA_OBJECT_H_ - -#include -#include - -#include "core/fxcrt/fx_basic.h" -#include "fxjs/cfxjse_arguments.h" -#include "xfa/fde/xml/fde_xml.h" -#include "xfa/fxfa/parser/xfa_utils.h" - -class CXFA_Document; -class CXFA_Node; -class CXFA_NodeList; - -enum class XFA_ObjectType { - Object, - List, - NodeList, - Node, - NodeC, - NodeV, - ModelNode, - TextNode, - ContainerNode, - ContentNode, - VariablesThis -}; - -enum XFA_NodeFlag { - XFA_NodeFlag_None = 0, - XFA_NodeFlag_Initialized = 1 << 0, - XFA_NodeFlag_HasRemovedChildren = 1 << 1, - XFA_NodeFlag_NeedsInitApp = 1 << 2, - XFA_NodeFlag_BindFormItems = 1 << 3, - XFA_NodeFlag_UserInteractive = 1 << 4, - XFA_NodeFlag_SkipDataBinding = 1 << 5, - XFA_NodeFlag_OwnXMLNode = 1 << 6, - XFA_NodeFlag_UnusedNode = 1 << 7, - XFA_NodeFlag_LayoutGeneratedNode = 1 << 8 -}; - -class CXFA_Object : public CFXJSE_HostObject { - public: - CXFA_Object(CXFA_Document* pDocument, - XFA_ObjectType objectType, - XFA_Element eType, - const CFX_WideStringC& elementName); - ~CXFA_Object() override; - - CXFA_Document* GetDocument() const { return m_pDocument; } - XFA_ObjectType GetObjectType() const { return m_objectType; } - - bool IsNode() const { - return m_objectType == XFA_ObjectType::Node || - m_objectType == XFA_ObjectType::NodeC || - m_objectType == XFA_ObjectType::NodeV || - m_objectType == XFA_ObjectType::ModelNode || - m_objectType == XFA_ObjectType::TextNode || - m_objectType == XFA_ObjectType::ContainerNode || - m_objectType == XFA_ObjectType::ContentNode || - m_objectType == XFA_ObjectType::VariablesThis; - } - bool IsNodeList() const { return m_objectType == XFA_ObjectType::NodeList; } - bool IsContentNode() const { - return m_objectType == XFA_ObjectType::ContentNode; - } - bool IsContainerNode() const { - return m_objectType == XFA_ObjectType::ContainerNode; - } - bool IsModelNode() const { return m_objectType == XFA_ObjectType::ModelNode; } - bool IsNodeV() const { return m_objectType == XFA_ObjectType::NodeV; } - bool IsVariablesThis() const { - return m_objectType == XFA_ObjectType::VariablesThis; - } - - CXFA_Node* AsNode(); - CXFA_NodeList* AsNodeList(); - - const CXFA_Node* AsNode() const; - const CXFA_NodeList* AsNodeList() const; - - XFA_Element GetElementType() const; - CFX_WideStringC GetClassName() const; - uint32_t GetClassHashCode() const; - void Script_ObjectClass_ClassName(CFXJSE_Value* pValue, - bool bSetting, - XFA_ATTRIBUTE eAttribute); - - void ThrowInvalidPropertyException() const; - void ThrowArgumentMismatchException() const; - void ThrowIndexOutOfBoundsException() const; - void ThrowParamCountMismatchException(const CFX_WideString& method) const; - - protected: - void ThrowException(const wchar_t* str, ...) const; - - CXFA_Document* const m_pDocument; - const XFA_ObjectType m_objectType; - const XFA_Element m_elementType; - - const uint32_t m_elementNameHash; - const CFX_WideStringC m_elementName; -}; - -#define XFA_NODEFILTER_Children 0x01 -#define XFA_NODEFILTER_Properties 0x02 -#define XFA_NODEFILTER_OneOfProperty 0x04 -#define XFA_CLONEFLAG_Content 0x01 -enum XFA_NODEITEM { - XFA_NODEITEM_Parent, - XFA_NODEITEM_FirstChild, - XFA_NODEITEM_NextSibling, - XFA_NODEITEM_PrevSibling, -}; -enum XFA_SOM_MESSAGETYPE { - XFA_SOM_ValidationMessage, - XFA_SOM_FormatMessage, - XFA_SOM_MandatoryMessage -}; - -typedef void (*PD_CALLBACK_FREEDATA)(void* pData); -typedef void (*PD_CALLBACK_DUPLICATEDATA)(void*& pData); - -struct XFA_MAPDATABLOCKCALLBACKINFO { - PD_CALLBACK_FREEDATA pFree; - PD_CALLBACK_DUPLICATEDATA pCopy; -}; - -struct XFA_MAPDATABLOCK { - uint8_t* GetData() const { return (uint8_t*)this + sizeof(XFA_MAPDATABLOCK); } - XFA_MAPDATABLOCKCALLBACKINFO* pCallbackInfo; - int32_t iBytes; -}; - -struct XFA_MAPMODULEDATA { - XFA_MAPMODULEDATA(); - ~XFA_MAPMODULEDATA(); - - std::map m_ValueMap; - std::map m_BufferMap; -}; - -#define XFA_CalcRefCount (void*)(uintptr_t) FXBSTR_ID('X', 'F', 'A', 'R') -#define XFA_CalcData (void*)(uintptr_t) FXBSTR_ID('X', 'F', 'A', 'C') -#define XFA_LAYOUTITEMKEY (void*)(uintptr_t) FXBSTR_ID('L', 'Y', 'I', 'M') - -class CXFA_Node : public CXFA_Object { - public: - uint32_t GetPacketID() const { return m_ePacket; } - - void SetFlag(uint32_t dwFlag, bool bNotify); - void ClearFlag(uint32_t dwFlag); - - bool IsInitialized() const { return HasFlag(XFA_NodeFlag_Initialized); } - bool IsOwnXMLNode() const { return HasFlag(XFA_NodeFlag_OwnXMLNode); } - bool IsUserInteractive() const { - return HasFlag(XFA_NodeFlag_UserInteractive); - } - bool IsUnusedNode() const { return HasFlag(XFA_NodeFlag_UnusedNode); } - bool IsLayoutGeneratedNode() const { - return HasFlag(XFA_NodeFlag_LayoutGeneratedNode); - } - bool BindsFormItems() const { return HasFlag(XFA_NodeFlag_BindFormItems); } - bool HasRemovedChildren() const { - return HasFlag(XFA_NodeFlag_HasRemovedChildren); - } - bool NeedsInitApp() const { return HasFlag(XFA_NodeFlag_NeedsInitApp); } - - bool IsAttributeInXML(); - bool IsFormContainer() const { - return m_ePacket == XFA_XDPPACKET_Form && IsContainerNode(); - } - void SetXMLMappingNode(CFDE_XMLNode* pXMLNode) { m_pXMLNode = pXMLNode; } - CFDE_XMLNode* GetXMLMappingNode() const { return m_pXMLNode; } - CFDE_XMLNode* CreateXMLMappingNode(); - bool IsNeedSavingXMLNode(); - uint32_t GetNameHash() const { return m_dwNameHash; } - bool IsUnnamed() const { return m_dwNameHash == 0; } - CXFA_Node* GetModelNode(); - void UpdateNameHash(); - bool HasAttribute(XFA_ATTRIBUTE eAttr, bool bCanInherit = false); - bool SetAttribute(XFA_ATTRIBUTE eAttr, - const CFX_WideStringC& wsValue, - bool bNotify = false); - bool GetAttribute(XFA_ATTRIBUTE eAttr, - CFX_WideString& wsValue, - bool bUseDefault = true); - bool SetAttribute(const CFX_WideStringC& wsAttr, - const CFX_WideStringC& wsValue, - bool bNotify = false); - bool GetAttribute(const CFX_WideStringC& wsAttr, - CFX_WideString& wsValue, - bool bUseDefault = true); - bool RemoveAttribute(const CFX_WideStringC& wsAttr); - bool SetContent(const CFX_WideString& wsContent, - const CFX_WideString& wsXMLValue, - bool bNotify = false, - bool bScriptModify = false, - bool bSyncData = true); - bool TryContent(CFX_WideString& wsContent, - bool bScriptModify = false, - bool bProto = true); - CFX_WideString GetContent(); - - bool TryNamespace(CFX_WideString& wsNamespace); - - bool SetBoolean(XFA_ATTRIBUTE eAttr, bool bValue, bool bNotify = false) { - return SetValue(eAttr, XFA_ATTRIBUTETYPE_Boolean, (void*)(uintptr_t)bValue, - bNotify); - } - bool TryBoolean(XFA_ATTRIBUTE eAttr, bool& bValue, bool bUseDefault = true); - bool GetBoolean(XFA_ATTRIBUTE eAttr) { - bool bValue; - return TryBoolean(eAttr, bValue, true) ? bValue : false; - } - bool SetInteger(XFA_ATTRIBUTE eAttr, int32_t iValue, bool bNotify = false) { - return SetValue(eAttr, XFA_ATTRIBUTETYPE_Integer, (void*)(uintptr_t)iValue, - bNotify); - } - bool TryInteger(XFA_ATTRIBUTE eAttr, - int32_t& iValue, - bool bUseDefault = true); - int32_t GetInteger(XFA_ATTRIBUTE eAttr) { - int32_t iValue; - return TryInteger(eAttr, iValue, true) ? iValue : 0; - } - bool SetEnum(XFA_ATTRIBUTE eAttr, - XFA_ATTRIBUTEENUM eValue, - bool bNotify = false) { - return SetValue(eAttr, XFA_ATTRIBUTETYPE_Enum, (void*)(uintptr_t)eValue, - bNotify); - } - bool TryEnum(XFA_ATTRIBUTE eAttr, - XFA_ATTRIBUTEENUM& eValue, - bool bUseDefault = true); - XFA_ATTRIBUTEENUM GetEnum(XFA_ATTRIBUTE eAttr) { - XFA_ATTRIBUTEENUM eValue; - return TryEnum(eAttr, eValue, true) ? eValue : XFA_ATTRIBUTEENUM_Unknown; - } - bool SetCData(XFA_ATTRIBUTE eAttr, - const CFX_WideString& wsValue, - bool bNotify = false, - bool bScriptModify = false); - bool SetAttributeValue(const CFX_WideString& wsValue, - const CFX_WideString& wsXMLValue, - bool bNotify = false, - bool bScriptModify = false); - bool TryCData(XFA_ATTRIBUTE eAttr, - CFX_WideString& wsValue, - bool bUseDefault = true, - bool bProto = true); - bool TryCData(XFA_ATTRIBUTE eAttr, - CFX_WideStringC& wsValue, - bool bUseDefault = true, - bool bProto = true); - CFX_WideStringC GetCData(XFA_ATTRIBUTE eAttr) { - CFX_WideStringC wsValue; - return TryCData(eAttr, wsValue) ? wsValue : CFX_WideStringC(); - } - bool SetMeasure(XFA_ATTRIBUTE eAttr, - CXFA_Measurement mValue, - bool bNotify = false); - bool TryMeasure(XFA_ATTRIBUTE eAttr, - CXFA_Measurement& mValue, - bool bUseDefault = true) const; - CXFA_Measurement GetMeasure(XFA_ATTRIBUTE eAttr) const; - bool SetObject(XFA_ATTRIBUTE eAttr, - void* pData, - XFA_MAPDATABLOCKCALLBACKINFO* pCallbackInfo = nullptr); - bool TryObject(XFA_ATTRIBUTE eAttr, void*& pData); - void* GetObject(XFA_ATTRIBUTE eAttr) { - void* pData; - return TryObject(eAttr, pData) ? pData : nullptr; - } - bool SetUserData(void* pKey, - void* pData, - XFA_MAPDATABLOCKCALLBACKINFO* pCallbackInfo = nullptr); - bool TryUserData(void* pKey, void*& pData, bool bProtoAlso = false); - void* GetUserData(void* pKey, bool bProtoAlso = false) { - void* pData; - return TryUserData(pKey, pData, bProtoAlso) ? pData : nullptr; - } - CXFA_Node* GetProperty(int32_t index, - XFA_Element eType, - bool bCreateProperty = true); - int32_t CountChildren(XFA_Element eType, bool bOnlyChild = false); - CXFA_Node* GetChild(int32_t index, - XFA_Element eType, - bool bOnlyChild = false); - int32_t InsertChild(int32_t index, CXFA_Node* pNode); - bool InsertChild(CXFA_Node* pNode, CXFA_Node* pBeforeNode = nullptr); - bool RemoveChild(CXFA_Node* pNode, bool bNotify = true); - CXFA_Node* Clone(bool bRecursive); - CXFA_Node* GetNodeItem(XFA_NODEITEM eItem) const; - CXFA_Node* GetNodeItem(XFA_NODEITEM eItem, XFA_ObjectType eType) const; - std::vector GetNodeList( - uint32_t dwTypeFilter = XFA_NODEFILTER_Children | - XFA_NODEFILTER_Properties, - XFA_Element eTypeFilter = XFA_Element::Unknown); - CXFA_Node* CreateSamePacketNode(XFA_Element eType, - uint32_t dwFlags = XFA_NodeFlag_Initialized); - CXFA_Node* CloneTemplateToForm(bool bRecursive); - CXFA_Node* GetTemplateNode() const; - void SetTemplateNode(CXFA_Node* pTemplateNode); - CXFA_Node* GetDataDescriptionNode(); - void SetDataDescriptionNode(CXFA_Node* pDataDescriptionNode); - CXFA_Node* GetBindData(); - std::vector GetBindItems(); - int32_t AddBindItem(CXFA_Node* pFormNode); - int32_t RemoveBindItem(CXFA_Node* pFormNode); - bool HasBindItem(); - CXFA_WidgetData* GetWidgetData(); - CXFA_WidgetData* GetContainerWidgetData(); - bool GetLocaleName(CFX_WideString& wsLocaleName); - XFA_ATTRIBUTEENUM GetIntact(); - CXFA_Node* GetFirstChildByName(const CFX_WideStringC& wsNodeName) const; - CXFA_Node* GetFirstChildByName(uint32_t dwNodeNameHash) const; - CXFA_Node* GetFirstChildByClass(XFA_Element eType) const; - CXFA_Node* GetNextSameNameSibling(uint32_t dwNodeNameHash) const; - CXFA_Node* GetNextSameNameSibling(const CFX_WideStringC& wsNodeName) const; - CXFA_Node* GetNextSameClassSibling(XFA_Element eType) const; - int32_t GetNodeSameNameIndex() const; - int32_t GetNodeSameClassIndex() const; - void GetSOMExpression(CFX_WideString& wsSOMExpression); - CXFA_Node* GetInstanceMgrOfSubform(); - - CXFA_Node* GetOccurNode(); - void Script_TreeClass_ResolveNode(CFXJSE_Arguments* pArguments); - void Script_TreeClass_ResolveNodes(CFXJSE_Arguments* pArguments); - void Script_Som_ResolveNodeList(CFXJSE_Value* pValue, - CFX_WideString wsExpression, - uint32_t dwFlag, - CXFA_Node* refNode = nullptr); - void Script_TreeClass_All(CFXJSE_Value* pValue, - bool bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_TreeClass_Nodes(CFXJSE_Value* pValue, - bool bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_TreeClass_ClassAll(CFXJSE_Value* pValue, - bool bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_TreeClass_Parent(CFXJSE_Value* pValue, - bool bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_TreeClass_Index(CFXJSE_Value* pValue, - bool bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_TreeClass_ClassIndex(CFXJSE_Value* pValue, - bool bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_TreeClass_SomExpression(CFXJSE_Value* pValue, - bool bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_NodeClass_ApplyXSL(CFXJSE_Arguments* pArguments); - void Script_NodeClass_AssignNode(CFXJSE_Arguments* pArguments); - void Script_NodeClass_Clone(CFXJSE_Arguments* pArguments); - void Script_NodeClass_GetAttribute(CFXJSE_Arguments* pArguments); - void Script_NodeClass_GetElement(CFXJSE_Arguments* pArguments); - void Script_NodeClass_IsPropertySpecified(CFXJSE_Arguments* pArguments); - void Script_NodeClass_LoadXML(CFXJSE_Arguments* pArguments); - void Script_NodeClass_SaveFilteredXML(CFXJSE_Arguments* pArguments); - void Script_NodeClass_SaveXML(CFXJSE_Arguments* pArguments); - void Script_NodeClass_SetAttribute(CFXJSE_Arguments* pArguments); - void Script_NodeClass_SetElement(CFXJSE_Arguments* pArguments); - void Script_NodeClass_Ns(CFXJSE_Value* pValue, - bool bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_NodeClass_Model(CFXJSE_Value* pValue, - bool bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_NodeClass_IsContainer(CFXJSE_Value* pValue, - bool bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_NodeClass_IsNull(CFXJSE_Value* pValue, - bool bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_NodeClass_OneOfChild(CFXJSE_Value* pValue, - bool bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_ContainerClass_GetDelta(CFXJSE_Arguments* pArguments); - void Script_ContainerClass_GetDeltas(CFXJSE_Arguments* pArguments); - void Script_ModelClass_ClearErrorList(CFXJSE_Arguments* pArguments); - void Script_ModelClass_CreateNode(CFXJSE_Arguments* pArguments); - void Script_ModelClass_IsCompatibleNS(CFXJSE_Arguments* pArguments); - void Script_ModelClass_Context(CFXJSE_Value* pValue, - bool bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_ModelClass_AliasNode(CFXJSE_Value* pValue, - bool bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_WsdlConnection_Execute(CFXJSE_Arguments* pArguments); - void Script_Delta_Restore(CFXJSE_Arguments* pArguments); - void Script_Delta_CurrentValue(CFXJSE_Value* pValue, - bool bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_Delta_SavedValue(CFXJSE_Value* pValue, - bool bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_Delta_Target(CFXJSE_Value* pValue, - bool bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_Attribute_SendAttributeChangeMessage(XFA_ATTRIBUTE eAttribute, - bool bScriptModify); - void Script_Attribute_Integer(CFXJSE_Value* pValue, - bool bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_Attribute_IntegerRead(CFXJSE_Value* pValue, - bool bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_Attribute_BOOL(CFXJSE_Value* pValue, - bool bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_Attribute_BOOLRead(CFXJSE_Value* pValue, - bool bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_Attribute_String(CFXJSE_Value* pValue, - bool bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_Attribute_StringRead(CFXJSE_Value* pValue, - bool bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_Som_ValidationMessage(CFXJSE_Value* pValue, - bool bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_Field_Length(CFXJSE_Value* pValue, - bool bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_Som_DefaultValue(CFXJSE_Value* pValue, - bool bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_Som_DefaultValue_Read(CFXJSE_Value* pValue, - bool bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_Boolean_Value(CFXJSE_Value* pValue, - bool bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_Som_Message(CFXJSE_Value* pValue, - bool bSetting, - XFA_SOM_MESSAGETYPE iMessageType); - void Script_Som_BorderColor(CFXJSE_Value* pValue, - bool bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_Som_BorderWidth(CFXJSE_Value* pValue, - bool bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_Som_FillColor(CFXJSE_Value* pValue, - bool bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_Som_DataNode(CFXJSE_Value* pValue, - bool bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_Som_FontColor(CFXJSE_Value* pValue, - bool bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_Som_Mandatory(CFXJSE_Value* pValue, - bool bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_Som_MandatoryMessage(CFXJSE_Value* pValue, - bool bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_Som_InstanceIndex(CFXJSE_Value* pValue, - bool bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_Draw_DefaultValue(CFXJSE_Value* pValue, - bool bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_Field_DefaultValue(CFXJSE_Value* pValue, - bool bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_Field_EditValue(CFXJSE_Value* pValue, - bool bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_Field_FormatMessage(CFXJSE_Value* pValue, - bool bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_Field_FormattedValue(CFXJSE_Value* pValue, - bool bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_Field_ParentSubform(CFXJSE_Value* pValue, - bool bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_Field_SelectedIndex(CFXJSE_Value* pValue, - bool bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_Field_ClearItems(CFXJSE_Arguments* pArguments); - void Script_Field_ExecEvent(CFXJSE_Arguments* pArguments); - void Script_Field_ExecInitialize(CFXJSE_Arguments* pArguments); - void Script_Field_DeleteItem(CFXJSE_Arguments* pArguments); - void Script_Field_GetSaveItem(CFXJSE_Arguments* pArguments); - void Script_Field_BoundItem(CFXJSE_Arguments* pArguments); - void Script_Field_GetItemState(CFXJSE_Arguments* pArguments); - void Script_Field_ExecCalculate(CFXJSE_Arguments* pArguments); - void Script_Field_SetItems(CFXJSE_Arguments* pArguments); - void Script_Field_GetDisplayItem(CFXJSE_Arguments* pArguments); - void Script_Field_SetItemState(CFXJSE_Arguments* pArguments); - void Script_Field_AddItem(CFXJSE_Arguments* pArguments); - void Script_Field_ExecValidate(CFXJSE_Arguments* pArguments); - void Script_ExclGroup_DefaultAndRawValue(CFXJSE_Value* pValue, - bool bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_ExclGroup_ErrorText(CFXJSE_Value* pValue, - bool bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_ExclGroup_Transient(CFXJSE_Value* pValue, - bool bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_ExclGroup_ExecEvent(CFXJSE_Arguments* pArguments); - void Script_ExclGroup_SelectedMember(CFXJSE_Arguments* pArguments); - void Script_ExclGroup_ExecInitialize(CFXJSE_Arguments* pArguments); - void Script_ExclGroup_ExecCalculate(CFXJSE_Arguments* pArguments); - void Script_ExclGroup_ExecValidate(CFXJSE_Arguments* pArguments); - void Script_Subform_InstanceManager(CFXJSE_Value* pValue, - bool bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_Subform_Locale(CFXJSE_Value* pValue, - bool bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_Subform_ExecEvent(CFXJSE_Arguments* pArguments); - void Script_Subform_ExecInitialize(CFXJSE_Arguments* pArguments); - void Script_Subform_ExecCalculate(CFXJSE_Arguments* pArguments); - void Script_Subform_ExecValidate(CFXJSE_Arguments* pArguments); - void Script_Subform_GetInvalidObjects(CFXJSE_Arguments* pArguments); - - int32_t Subform_and_SubformSet_InstanceIndex(); - void Script_Template_FormNodes(CFXJSE_Arguments* pArguments); - void Script_Template_Remerge(CFXJSE_Arguments* pArguments); - void Script_Template_ExecInitialize(CFXJSE_Arguments* pArguments); - void Script_Template_CreateNode(CFXJSE_Arguments* pArguments); - void Script_Template_Recalculate(CFXJSE_Arguments* pArguments); - void Script_Template_ExecCalculate(CFXJSE_Arguments* pArguments); - void Script_Template_ExecValidate(CFXJSE_Arguments* pArguments); - void Script_Manifest_Evaluate(CFXJSE_Arguments* pArguments); - void Script_InstanceManager_Count(CFXJSE_Value* pValue, - bool bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_InstanceManager_Max(CFXJSE_Value* pValue, - bool bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_InstanceManager_Min(CFXJSE_Value* pValue, - bool bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_InstanceManager_MoveInstance(CFXJSE_Arguments* pArguments); - void Script_InstanceManager_RemoveInstance(CFXJSE_Arguments* pArguments); - void Script_InstanceManager_SetInstances(CFXJSE_Arguments* pArguments); - void Script_InstanceManager_AddInstance(CFXJSE_Arguments* pArguments); - void Script_InstanceManager_InsertInstance(CFXJSE_Arguments* pArguments); - int32_t InstanceManager_SetInstances(int32_t iCount); - int32_t InstanceManager_MoveInstance(int32_t iTo, int32_t iFrom); - void Script_Occur_Max(CFXJSE_Value* pValue, - bool bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_Occur_Min(CFXJSE_Value* pValue, - bool bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_Desc_Metadata(CFXJSE_Arguments* pArguments); - void Script_Form_FormNodes(CFXJSE_Arguments* pArguments); - void Script_Form_Remerge(CFXJSE_Arguments* pArguments); - void Script_Form_ExecInitialize(CFXJSE_Arguments* pArguments); - void Script_Form_Recalculate(CFXJSE_Arguments* pArguments); - void Script_Form_ExecCalculate(CFXJSE_Arguments* pArguments); - void Script_Form_ExecValidate(CFXJSE_Arguments* pArguments); - void Script_Form_Checksum(CFXJSE_Value* pValue, - bool bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_Packet_GetAttribute(CFXJSE_Arguments* pArguments); - void Script_Packet_SetAttribute(CFXJSE_Arguments* pArguments); - void Script_Packet_RemoveAttribute(CFXJSE_Arguments* pArguments); - void Script_Packet_Content(CFXJSE_Value* pValue, - bool bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_Source_Next(CFXJSE_Arguments* pArguments); - void Script_Source_CancelBatch(CFXJSE_Arguments* pArguments); - void Script_Source_First(CFXJSE_Arguments* pArguments); - void Script_Source_UpdateBatch(CFXJSE_Arguments* pArguments); - void Script_Source_Previous(CFXJSE_Arguments* pArguments); - void Script_Source_IsBOF(CFXJSE_Arguments* pArguments); - void Script_Source_IsEOF(CFXJSE_Arguments* pArguments); - void Script_Source_Cancel(CFXJSE_Arguments* pArguments); - void Script_Source_Update(CFXJSE_Arguments* pArguments); - void Script_Source_Open(CFXJSE_Arguments* pArguments); - void Script_Source_Delete(CFXJSE_Arguments* pArguments); - void Script_Source_AddNew(CFXJSE_Arguments* pArguments); - void Script_Source_Requery(CFXJSE_Arguments* pArguments); - void Script_Source_Resync(CFXJSE_Arguments* pArguments); - void Script_Source_Close(CFXJSE_Arguments* pArguments); - void Script_Source_Last(CFXJSE_Arguments* pArguments); - void Script_Source_HasDataChanged(CFXJSE_Arguments* pArguments); - void Script_Source_Db(CFXJSE_Value* pValue, - bool bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_Xfa_This(CFXJSE_Value* pValue, - bool bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_Handler_Version(CFXJSE_Value* pValue, - bool bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_SubmitFormat_Mode(CFXJSE_Value* pValue, - bool bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_Extras_Type(CFXJSE_Value* pValue, - bool bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_Encrypt_Format(CFXJSE_Value* pValue, - bool bSetting, - XFA_ATTRIBUTE eAttribute); - void Script_Script_Stateless(CFXJSE_Value* pValue, - bool bSetting, - XFA_ATTRIBUTE eAttribute); - - private: - friend class CXFA_Document; - - CXFA_Node(CXFA_Document* pDoc, - uint16_t ePacket, - XFA_ObjectType oType, - XFA_Element eType, - const CFX_WideStringC& elementName); - ~CXFA_Node() override; - - bool HasFlag(XFA_NodeFlag dwFlag) const; - CXFA_Node* Deprecated_GetPrevSibling(); - bool SetValue(XFA_ATTRIBUTE eAttr, - XFA_ATTRIBUTETYPE eType, - void* pValue, - bool bNotify); - bool GetValue(XFA_ATTRIBUTE eAttr, - XFA_ATTRIBUTETYPE eType, - bool bUseDefault, - void*& pValue); - void OnRemoved(bool bNotify); - void OnChanging(XFA_ATTRIBUTE eAttr, bool bNotify); - void OnChanged(XFA_ATTRIBUTE eAttr, bool bNotify, bool bScriptModify); - int32_t execSingleEventByName(const CFX_WideStringC& wsEventName, - XFA_Element eType); - bool SetScriptContent(const CFX_WideString& wsContent, - const CFX_WideString& wsXMLValue, - bool bNotify = true, - bool bScriptModify = false, - bool bSyncData = true); - CFX_WideString GetScriptContent(bool bScriptModify = false); - XFA_MAPMODULEDATA* CreateMapModuleData(); - XFA_MAPMODULEDATA* GetMapModuleData() const; - void SetMapModuleValue(void* pKey, void* pValue); - bool GetMapModuleValue(void* pKey, void*& pValue); - void SetMapModuleString(void* pKey, const CFX_WideStringC& wsValue); - bool GetMapModuleString(void* pKey, CFX_WideStringC& wsValue); - void SetMapModuleBuffer( - void* pKey, - void* pValue, - int32_t iBytes, - XFA_MAPDATABLOCKCALLBACKINFO* pCallbackInfo = nullptr); - bool GetMapModuleBuffer(void* pKey, - void*& pValue, - int32_t& iBytes, - bool bProtoAlso = true) const; - bool HasMapModuleKey(void* pKey, bool bProtoAlso = false); - void RemoveMapModuleKey(void* pKey = nullptr); - void MergeAllData(void* pDstModule); - void MoveBufferMapData(CXFA_Node* pDstModule, void* pKey); - void MoveBufferMapData(CXFA_Node* pSrcModule, - CXFA_Node* pDstModule, - void* pKey, - bool bRecursive = false); - - CXFA_Node* m_pNext; - CXFA_Node* m_pChild; - CXFA_Node* m_pLastChild; - CXFA_Node* m_pParent; - CFDE_XMLNode* m_pXMLNode; - uint16_t m_ePacket; - uint16_t m_uNodeFlags; - uint32_t m_dwNameHash; - CXFA_Node* m_pAuxNode; - XFA_MAPMODULEDATA* m_pMapModuleData; - - private: - void ThrowMissingPropertyException(const CFX_WideString& obj, - const CFX_WideString& prop) const; - void ThrowTooManyOccurancesException(const CFX_WideString& obj) const; -}; - -class CXFA_ThisProxy : public CXFA_Object { - public: - CXFA_ThisProxy(CXFA_Node* pThisNode, CXFA_Node* pScriptNode); - ~CXFA_ThisProxy() override; - - CXFA_Node* GetThisNode() const; - CXFA_Node* GetScriptNode() const; - - private: - CXFA_Node* m_pThisNode; - CXFA_Node* m_pScriptNode; -}; - -class CXFA_NodeList : public CXFA_Object { - public: - explicit CXFA_NodeList(CXFA_Document* pDocument); - ~CXFA_NodeList() override; - - CXFA_Node* NamedItem(const CFX_WideStringC& wsName); - virtual int32_t GetLength() = 0; - virtual bool Append(CXFA_Node* pNode) = 0; - virtual bool Insert(CXFA_Node* pNewNode, CXFA_Node* pBeforeNode) = 0; - virtual bool Remove(CXFA_Node* pNode) = 0; - virtual CXFA_Node* Item(int32_t iIndex) = 0; - - void Script_ListClass_Append(CFXJSE_Arguments* pArguments); - void Script_ListClass_Insert(CFXJSE_Arguments* pArguments); - void Script_ListClass_Remove(CFXJSE_Arguments* pArguments); - void Script_ListClass_Item(CFXJSE_Arguments* pArguments); - - void Script_TreelistClass_NamedItem(CFXJSE_Arguments* pArguments); - void Script_ListClass_Length(CFXJSE_Value* pValue, - bool bSetting, - XFA_ATTRIBUTE eAttribute); -}; - -class CXFA_ArrayNodeList : public CXFA_NodeList { - public: - explicit CXFA_ArrayNodeList(CXFA_Document* pDocument); - ~CXFA_ArrayNodeList() override; - - // From CXFA_NodeList. - int32_t GetLength() override; - bool Append(CXFA_Node* pNode) override; - bool Insert(CXFA_Node* pNewNode, CXFA_Node* pBeforeNode) override; - bool Remove(CXFA_Node* pNode) override; - CXFA_Node* Item(int32_t iIndex) override; - - void SetArrayNodeList(const std::vector& srcArray); - - private: - std::vector m_array; -}; - -class CXFA_AttachNodeList : public CXFA_NodeList { - public: - CXFA_AttachNodeList(CXFA_Document* pDocument, CXFA_Node* pAttachNode); - - // From CXFA_NodeList. - int32_t GetLength() override; - bool Append(CXFA_Node* pNode) override; - bool Insert(CXFA_Node* pNewNode, CXFA_Node* pBeforeNode) override; - bool Remove(CXFA_Node* pNode) override; - CXFA_Node* Item(int32_t iIndex) override; - - private: - CXFA_Node* m_pAttachNode; -}; -class CXFA_TraverseStrategy_XFAContainerNode { - public: - static CXFA_Node* GetFirstChild(CXFA_Node* pTemplateNode, - void* pUserData = nullptr) { - return pTemplateNode->GetNodeItem(XFA_NODEITEM_FirstChild, - XFA_ObjectType::ContainerNode); - } - static CXFA_Node* GetNextSibling(CXFA_Node* pTemplateNode, - void* pUserData = nullptr) { - return pTemplateNode->GetNodeItem(XFA_NODEITEM_NextSibling, - XFA_ObjectType::ContainerNode); - } - static CXFA_Node* GetParent(CXFA_Node* pTemplateNode, - void* pUserData = nullptr) { - return pTemplateNode->GetNodeItem(XFA_NODEITEM_Parent, - XFA_ObjectType::ContainerNode); - } -}; -typedef CXFA_NodeIteratorTemplate - CXFA_ContainerIterator; -class CXFA_TraverseStrategy_XFANode { - public: - static inline CXFA_Node* GetFirstChild(CXFA_Node* pTemplateNode) { - return pTemplateNode->GetNodeItem(XFA_NODEITEM_FirstChild); - } - static inline CXFA_Node* GetNextSibling(CXFA_Node* pTemplateNode) { - return pTemplateNode->GetNodeItem(XFA_NODEITEM_NextSibling); - } - static inline CXFA_Node* GetParent(CXFA_Node* pTemplateNode) { - return pTemplateNode->GetNodeItem(XFA_NODEITEM_Parent); - } -}; -typedef CXFA_NodeIteratorTemplate - CXFA_NodeIterator; - -inline CXFA_Node* CXFA_Object::AsNode() { - return IsNode() ? static_cast(this) : nullptr; -} - -inline CXFA_NodeList* CXFA_Object::AsNodeList() { - return IsNodeList() ? static_cast(this) : nullptr; -} - -inline const CXFA_Node* CXFA_Object::AsNode() const { - return IsNode() ? static_cast(this) : nullptr; -} - -inline const CXFA_NodeList* CXFA_Object::AsNodeList() const { - return IsNodeList() ? static_cast(this) : nullptr; -} - -inline CXFA_Node* ToNode(CXFA_Object* pObj) { - return pObj ? pObj->AsNode() : nullptr; -} - -inline const CXFA_Node* ToNode(const CXFA_Object* pObj) { - return pObj ? pObj->AsNode() : nullptr; -} - -#endif // XFA_FXFA_PARSER_XFA_OBJECT_H_ diff --git a/xfa/fxfa/parser/xfa_utils.cpp b/xfa/fxfa/parser/xfa_utils.cpp index fd5728e5f6..1323232f9f 100644 --- a/xfa/fxfa/parser/xfa_utils.cpp +++ b/xfa/fxfa/parser/xfa_utils.cpp @@ -12,8 +12,8 @@ #include "xfa/fxfa/parser/cxfa_localemgr.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/xfa_basic_data.h" -#include "xfa/fxfa/parser/xfa_object.h" namespace { -- cgit v1.2.3