From 80c487809858b74783a00e05cc8164edf4b1307c Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Thu, 23 Mar 2017 12:11:20 -0400 Subject: Cleanup some xfa/fxfa code. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This CL moves the .h files to have names corresponding to the contained classes. The .cpp files are moved alongside the .h files. Any extra classes in the .h files have been split into their own files. Change-Id: I14b4efc02417f0df946500e87b6c502e77020db8 Reviewed-on: https://pdfium-review.googlesource.com/3160 Reviewed-by: Tom Sepez Reviewed-by: Nicolás Peña Commit-Queue: dsinclair --- BUILD.gn | 56 +- fpdfsdk/cpdfsdk_annothandlermgr.cpp | 4 +- fpdfsdk/cpdfsdk_interform.cpp | 6 +- fpdfsdk/cpdfsdk_pageview.cpp | 8 +- fpdfsdk/cpdfsdk_widget.cpp | 8 +- fpdfsdk/cpdfsdk_xfawidget.cpp | 2 +- fpdfsdk/cpdfsdk_xfawidgethandler.cpp | 8 +- fpdfsdk/fpdfformfill.cpp | 6 +- fpdfsdk/fpdfsave.cpp | 9 +- fpdfsdk/fpdfxfa/cpdfxfa_context.cpp | 13 +- fpdfsdk/fpdfxfa/cpdfxfa_context.h | 2 +- fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp | 7 +- fpdfsdk/fpdfxfa/cpdfxfa_page.cpp | 4 +- xfa/fde/xml/cfx_saxreader.cpp | 2 +- xfa/fgas/font/cfgas_gefont.cpp | 2 +- xfa/fwl/cfwl_edit.cpp | 4 +- xfa/fwl/cfwl_timer.cpp | 2 +- xfa/fwl/cfwl_widget.cpp | 2 +- xfa/fwl/cfwl_widgetmgr.cpp | 2 +- xfa/fwl/theme/cfwl_edittp.cpp | 2 +- xfa/fxfa/DEPS | 3 + xfa/fxfa/app/DEPS | 3 - xfa/fxfa/app/cxfa_eventparam.cpp | 46 - xfa/fxfa/app/cxfa_textparser.cpp | 6 +- xfa/fxfa/app/xfa_checksum.cpp | 269 ---- xfa/fxfa/app/xfa_ffapp.cpp | 162 -- xfa/fxfa/app/xfa_ffapp_unittest.cpp | 87 -- xfa/fxfa/app/xfa_ffbarcode.cpp | 4 +- xfa/fxfa/app/xfa_ffbarcode.h | 2 +- xfa/fxfa/app/xfa_ffcheckbutton.cpp | 10 +- xfa/fxfa/app/xfa_ffcheckbutton.h | 2 +- xfa/fxfa/app/xfa_ffchoicelist.cpp | 8 +- xfa/fxfa/app/xfa_ffchoicelist.h | 2 +- xfa/fxfa/app/xfa_ffdoc.cpp | 430 ------ xfa/fxfa/app/xfa_ffdochandler.cpp | 60 - xfa/fxfa/app/xfa_ffdocview.cpp | 836 ----------- xfa/fxfa/app/xfa_ffdraw.cpp | 8 +- xfa/fxfa/app/xfa_ffdraw.h | 4 +- xfa/fxfa/app/xfa_ffexclgroup.cpp | 8 +- xfa/fxfa/app/xfa_ffexclgroup.h | 4 +- xfa/fxfa/app/xfa_fffield.cpp | 10 +- xfa/fxfa/app/xfa_fffield.h | 4 +- xfa/fxfa/app/xfa_ffimage.cpp | 8 +- xfa/fxfa/app/xfa_ffimageedit.cpp | 8 +- xfa/fxfa/app/xfa_ffnotify.cpp | 12 +- xfa/fxfa/app/xfa_ffpageview.cpp | 459 ------ xfa/fxfa/app/xfa_ffpath.cpp | 8 +- xfa/fxfa/app/xfa_ffpushbutton.cpp | 6 +- xfa/fxfa/app/xfa_ffsignature.cpp | 6 +- xfa/fxfa/app/xfa_ffsubform.cpp | 8 +- xfa/fxfa/app/xfa_ffsubform.h | 4 +- xfa/fxfa/app/xfa_fftext.cpp | 8 +- xfa/fxfa/app/xfa_fftextedit.cpp | 10 +- xfa/fxfa/app/xfa_ffwidget.cpp | 2048 ------------------------- xfa/fxfa/app/xfa_ffwidgetacc.cpp | 1498 +------------------ xfa/fxfa/app/xfa_ffwidgetacc.h | 2 +- xfa/fxfa/app/xfa_ffwidgethandler.cpp | 524 ------- xfa/fxfa/app/xfa_fontmgr.cpp | 2055 -------------------------- xfa/fxfa/app/xfa_fwladapter.cpp | 2 +- xfa/fxfa/app/xfa_fwltheme.cpp | 4 +- xfa/fxfa/app/xfa_fwltheme.h | 2 +- xfa/fxfa/app/xfa_rendercontext.cpp | 70 - xfa/fxfa/cxfa_checksumcontext.cpp | 151 ++ xfa/fxfa/cxfa_checksumcontext.h | 34 + xfa/fxfa/cxfa_deffontmgr.cpp | 77 + xfa/fxfa/cxfa_deffontmgr.h | 37 + xfa/fxfa/cxfa_eventparam.cpp | 46 + xfa/fxfa/cxfa_ffapp.cpp | 162 ++ xfa/fxfa/cxfa_ffapp.h | 86 ++ xfa/fxfa/cxfa_ffapp_unitest.cpp | 87 ++ xfa/fxfa/cxfa_ffdoc.cpp | 430 ++++++ xfa/fxfa/cxfa_ffdoc.h | 73 + xfa/fxfa/cxfa_ffdochandler.cpp | 60 + xfa/fxfa/cxfa_ffdochandler.h | 29 + xfa/fxfa/cxfa_ffdocview.cpp | 790 ++++++++++ xfa/fxfa/cxfa_ffdocview.h | 135 ++ xfa/fxfa/cxfa_ffpageview.cpp | 459 ++++++ xfa/fxfa/cxfa_ffpageview.h | 107 ++ xfa/fxfa/cxfa_ffwidget.cpp | 2048 +++++++++++++++++++++++++ xfa/fxfa/cxfa_ffwidget.h | 190 +++ xfa/fxfa/cxfa_ffwidgethandler.cpp | 523 +++++++ xfa/fxfa/cxfa_ffwidgethandler.h | 119 ++ xfa/fxfa/cxfa_fontmgr.cpp | 1797 ++++++++++++++++++++++ xfa/fxfa/cxfa_fontmgr.h | 56 + xfa/fxfa/cxfa_pdffontmgr.cpp | 208 +++ xfa/fxfa/cxfa_pdffontmgr.h | 57 + xfa/fxfa/cxfa_rendercontext.cpp | 70 + xfa/fxfa/cxfa_rendercontext.h | 45 + xfa/fxfa/cxfa_saxcontext.h | 19 + xfa/fxfa/cxfa_saxreaderhandler.cpp | 129 ++ xfa/fxfa/cxfa_saxreaderhandler.h | 49 + xfa/fxfa/cxfa_widgetacc.cpp | 1549 +++++++++++++++++++ xfa/fxfa/cxfa_widgetacc.h | 121 ++ xfa/fxfa/cxfa_widgetacciterator.cpp | 56 + xfa/fxfa/cxfa_widgetacciterator.h | 34 + xfa/fxfa/fxfa.h | 2 +- xfa/fxfa/fxfa_widget.h | 121 -- xfa/fxfa/parser/cscript_eventpseudomodel.cpp | 2 +- xfa/fxfa/parser/cxfa_simple_parser.cpp | 2 +- xfa/fxfa/xfa_checksum.h | 80 - xfa/fxfa/xfa_ffapp.h | 86 -- xfa/fxfa/xfa_ffdoc.h | 73 - xfa/fxfa/xfa_ffdochandler.h | 31 - xfa/fxfa/xfa_ffdocview.h | 153 -- xfa/fxfa/xfa_ffpageview.h | 107 -- xfa/fxfa/xfa_ffwidget.h | 190 --- xfa/fxfa/xfa_ffwidgethandler.h | 119 -- xfa/fxfa/xfa_fontmgr.h | 103 -- xfa/fxfa/xfa_rendercontext.h | 45 - 109 files changed, 10006 insertions(+), 9800 deletions(-) delete mode 100644 xfa/fxfa/app/cxfa_eventparam.cpp delete mode 100644 xfa/fxfa/app/xfa_checksum.cpp delete mode 100644 xfa/fxfa/app/xfa_ffapp.cpp delete mode 100644 xfa/fxfa/app/xfa_ffapp_unittest.cpp delete mode 100644 xfa/fxfa/app/xfa_ffdoc.cpp delete mode 100644 xfa/fxfa/app/xfa_ffdochandler.cpp delete mode 100644 xfa/fxfa/app/xfa_ffdocview.cpp delete mode 100644 xfa/fxfa/app/xfa_ffpageview.cpp delete mode 100644 xfa/fxfa/app/xfa_ffwidget.cpp delete mode 100644 xfa/fxfa/app/xfa_ffwidgethandler.cpp delete mode 100644 xfa/fxfa/app/xfa_fontmgr.cpp delete mode 100644 xfa/fxfa/app/xfa_rendercontext.cpp create mode 100644 xfa/fxfa/cxfa_checksumcontext.cpp create mode 100644 xfa/fxfa/cxfa_checksumcontext.h create mode 100644 xfa/fxfa/cxfa_deffontmgr.cpp create mode 100644 xfa/fxfa/cxfa_deffontmgr.h create mode 100644 xfa/fxfa/cxfa_eventparam.cpp create mode 100644 xfa/fxfa/cxfa_ffapp.cpp create mode 100644 xfa/fxfa/cxfa_ffapp.h create mode 100644 xfa/fxfa/cxfa_ffapp_unitest.cpp create mode 100644 xfa/fxfa/cxfa_ffdoc.cpp create mode 100644 xfa/fxfa/cxfa_ffdoc.h create mode 100644 xfa/fxfa/cxfa_ffdochandler.cpp create mode 100644 xfa/fxfa/cxfa_ffdochandler.h create mode 100644 xfa/fxfa/cxfa_ffdocview.cpp create mode 100644 xfa/fxfa/cxfa_ffdocview.h create mode 100644 xfa/fxfa/cxfa_ffpageview.cpp create mode 100644 xfa/fxfa/cxfa_ffpageview.h create mode 100644 xfa/fxfa/cxfa_ffwidget.cpp create mode 100644 xfa/fxfa/cxfa_ffwidget.h create mode 100644 xfa/fxfa/cxfa_ffwidgethandler.cpp create mode 100644 xfa/fxfa/cxfa_ffwidgethandler.h create mode 100644 xfa/fxfa/cxfa_fontmgr.cpp create mode 100644 xfa/fxfa/cxfa_fontmgr.h create mode 100644 xfa/fxfa/cxfa_pdffontmgr.cpp create mode 100644 xfa/fxfa/cxfa_pdffontmgr.h create mode 100644 xfa/fxfa/cxfa_rendercontext.cpp create mode 100644 xfa/fxfa/cxfa_rendercontext.h create mode 100644 xfa/fxfa/cxfa_saxcontext.h create mode 100644 xfa/fxfa/cxfa_saxreaderhandler.cpp create mode 100644 xfa/fxfa/cxfa_saxreaderhandler.h create mode 100644 xfa/fxfa/cxfa_widgetacc.cpp create mode 100644 xfa/fxfa/cxfa_widgetacc.h create mode 100644 xfa/fxfa/cxfa_widgetacciterator.cpp create mode 100644 xfa/fxfa/cxfa_widgetacciterator.h delete mode 100644 xfa/fxfa/fxfa_widget.h delete mode 100644 xfa/fxfa/xfa_checksum.h delete mode 100644 xfa/fxfa/xfa_ffapp.h delete mode 100644 xfa/fxfa/xfa_ffdoc.h delete mode 100644 xfa/fxfa/xfa_ffdochandler.h delete mode 100644 xfa/fxfa/xfa_ffdocview.h delete mode 100644 xfa/fxfa/xfa_ffpageview.h delete mode 100644 xfa/fxfa/xfa_ffwidget.h delete mode 100644 xfa/fxfa/xfa_ffwidgethandler.h delete mode 100644 xfa/fxfa/xfa_fontmgr.h delete mode 100644 xfa/fxfa/xfa_rendercontext.h diff --git a/BUILD.gn b/BUILD.gn index 2ddfbf70ae..e4bf45ddfa 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -1503,7 +1503,6 @@ if (pdf_enable_xfa) { "xfa/fxbarcode/utils.h", "xfa/fxfa/app/cxfa_csstagprovider.cpp", "xfa/fxfa/app/cxfa_csstagprovider.h", - "xfa/fxfa/app/cxfa_eventparam.cpp", "xfa/fxfa/app/cxfa_linkuserdata.cpp", "xfa/fxfa/app/cxfa_linkuserdata.h", "xfa/fxfa/app/cxfa_loadercontext.cpp", @@ -1520,17 +1519,12 @@ if (pdf_enable_xfa) { "xfa/fxfa/app/cxfa_texttabstopscontext.h", "xfa/fxfa/app/cxfa_textuserdata.cpp", "xfa/fxfa/app/cxfa_textuserdata.h", - "xfa/fxfa/app/xfa_checksum.cpp", - "xfa/fxfa/app/xfa_ffapp.cpp", "xfa/fxfa/app/xfa_ffbarcode.cpp", "xfa/fxfa/app/xfa_ffbarcode.h", "xfa/fxfa/app/xfa_ffcheckbutton.cpp", "xfa/fxfa/app/xfa_ffcheckbutton.h", "xfa/fxfa/app/xfa_ffchoicelist.cpp", "xfa/fxfa/app/xfa_ffchoicelist.h", - "xfa/fxfa/app/xfa_ffdoc.cpp", - "xfa/fxfa/app/xfa_ffdochandler.cpp", - "xfa/fxfa/app/xfa_ffdocview.cpp", "xfa/fxfa/app/xfa_ffdraw.cpp", "xfa/fxfa/app/xfa_ffdraw.h", "xfa/fxfa/app/xfa_ffexclgroup.cpp", @@ -1543,7 +1537,6 @@ if (pdf_enable_xfa) { "xfa/fxfa/app/xfa_ffimageedit.h", "xfa/fxfa/app/xfa_ffnotify.cpp", "xfa/fxfa/app/xfa_ffnotify.h", - "xfa/fxfa/app/xfa_ffpageview.cpp", "xfa/fxfa/app/xfa_ffpath.cpp", "xfa/fxfa/app/xfa_ffpath.h", "xfa/fxfa/app/xfa_ffpushbutton.cpp", @@ -1556,19 +1549,47 @@ if (pdf_enable_xfa) { "xfa/fxfa/app/xfa_fftext.h", "xfa/fxfa/app/xfa_fftextedit.cpp", "xfa/fxfa/app/xfa_fftextedit.h", - "xfa/fxfa/app/xfa_ffwidget.cpp", "xfa/fxfa/app/xfa_ffwidgetacc.cpp", "xfa/fxfa/app/xfa_ffwidgetacc.h", - "xfa/fxfa/app/xfa_ffwidgethandler.cpp", - "xfa/fxfa/app/xfa_fontmgr.cpp", "xfa/fxfa/app/xfa_fwladapter.cpp", "xfa/fxfa/app/xfa_fwladapter.h", "xfa/fxfa/app/xfa_fwltheme.cpp", "xfa/fxfa/app/xfa_fwltheme.h", - "xfa/fxfa/app/xfa_rendercontext.cpp", "xfa/fxfa/app/xfa_textpiece.cpp", "xfa/fxfa/app/xfa_textpiece.h", + "xfa/fxfa/cxfa_checksumcontext.cpp", + "xfa/fxfa/cxfa_checksumcontext.h", + "xfa/fxfa/cxfa_deffontmgr.cpp", + "xfa/fxfa/cxfa_deffontmgr.h", + "xfa/fxfa/cxfa_eventparam.cpp", "xfa/fxfa/cxfa_eventparam.h", + "xfa/fxfa/cxfa_ffapp.cpp", + "xfa/fxfa/cxfa_ffapp.h", + "xfa/fxfa/cxfa_ffdoc.cpp", + "xfa/fxfa/cxfa_ffdoc.h", + "xfa/fxfa/cxfa_ffdochandler.cpp", + "xfa/fxfa/cxfa_ffdochandler.h", + "xfa/fxfa/cxfa_ffdocview.cpp", + "xfa/fxfa/cxfa_ffdocview.h", + "xfa/fxfa/cxfa_ffpageview.cpp", + "xfa/fxfa/cxfa_ffpageview.h", + "xfa/fxfa/cxfa_ffwidget.cpp", + "xfa/fxfa/cxfa_ffwidget.h", + "xfa/fxfa/cxfa_ffwidgethandler.cpp", + "xfa/fxfa/cxfa_ffwidgethandler.h", + "xfa/fxfa/cxfa_fontmgr.cpp", + "xfa/fxfa/cxfa_fontmgr.h", + "xfa/fxfa/cxfa_pdffontmgr.cpp", + "xfa/fxfa/cxfa_pdffontmgr.h", + "xfa/fxfa/cxfa_rendercontext.cpp", + "xfa/fxfa/cxfa_rendercontext.h", + "xfa/fxfa/cxfa_saxcontext.h", + "xfa/fxfa/cxfa_saxreaderhandler.cpp", + "xfa/fxfa/cxfa_saxreaderhandler.h", + "xfa/fxfa/cxfa_widgetacc.cpp", + "xfa/fxfa/cxfa_widgetacc.h", + "xfa/fxfa/cxfa_widgetacciterator.cpp", + "xfa/fxfa/cxfa_widgetacciterator.h", "xfa/fxfa/fm2js/xfa_error.cpp", "xfa/fxfa/fm2js/xfa_error.h", "xfa/fxfa/fm2js/xfa_expression.cpp", @@ -1585,7 +1606,6 @@ if (pdf_enable_xfa) { "xfa/fxfa/fm2js/xfa_simpleexpression.h", "xfa/fxfa/fxfa.h", "xfa/fxfa/fxfa_basic.h", - "xfa/fxfa/fxfa_widget.h", "xfa/fxfa/parser/cscript_datawindow.cpp", "xfa/fxfa/parser/cscript_datawindow.h", "xfa/fxfa/parser/cscript_eventpseudomodel.cpp", @@ -1716,16 +1736,6 @@ if (pdf_enable_xfa) { "xfa/fxfa/parser/xfa_resolvenode_rs.h", "xfa/fxfa/parser/xfa_utils.cpp", "xfa/fxfa/parser/xfa_utils.h", - "xfa/fxfa/xfa_checksum.h", - "xfa/fxfa/xfa_ffapp.h", - "xfa/fxfa/xfa_ffdoc.h", - "xfa/fxfa/xfa_ffdochandler.h", - "xfa/fxfa/xfa_ffdocview.h", - "xfa/fxfa/xfa_ffpageview.h", - "xfa/fxfa/xfa_ffwidget.h", - "xfa/fxfa/xfa_ffwidgethandler.h", - "xfa/fxfa/xfa_fontmgr.h", - "xfa/fxfa/xfa_rendercontext.h", "xfa/fxgraphics/cfx_color.cpp", "xfa/fxgraphics/cfx_color.h", "xfa/fxgraphics/cfx_graphics.cpp", @@ -1809,7 +1819,7 @@ test("pdfium_unittests") { "xfa/fgas/layout/fgas_rtfbreak_unittest.cpp", "xfa/fxbarcode/pdf417/BC_PDF417HighLevelEncoder_unittest.cpp", "xfa/fxfa/app/cxfa_textparser_unittest.cpp", - "xfa/fxfa/app/xfa_ffapp_unittest.cpp", + "xfa/fxfa/cxfa_ffapp_unitest.cpp", "xfa/fxfa/fm2js/xfa_simpleexpression_unittest.cpp", "xfa/fxfa/parser/xfa_utils_unittest.cpp", ] diff --git a/fpdfsdk/cpdfsdk_annothandlermgr.cpp b/fpdfsdk/cpdfsdk_annothandlermgr.cpp index c4990674de..287ee11a4d 100644 --- a/fpdfsdk/cpdfsdk_annothandlermgr.cpp +++ b/fpdfsdk/cpdfsdk_annothandlermgr.cpp @@ -21,8 +21,8 @@ #ifdef PDF_ENABLE_XFA #include "fpdfsdk/cpdfsdk_xfawidgethandler.h" #include "fpdfsdk/fpdfxfa/cpdfxfa_page.h" -#include "xfa/fxfa/xfa_ffpageview.h" -#include "xfa/fxfa/xfa_ffwidget.h" +#include "xfa/fxfa/cxfa_ffpageview.h" +#include "xfa/fxfa/cxfa_ffwidget.h" #endif // PDF_ENABLE_XFA CPDFSDK_AnnotHandlerMgr::CPDFSDK_AnnotHandlerMgr( diff --git a/fpdfsdk/cpdfsdk_interform.cpp b/fpdfsdk/cpdfsdk_interform.cpp index 1dbffa4a5a..a16ec93c7a 100644 --- a/fpdfsdk/cpdfsdk_interform.cpp +++ b/fpdfsdk/cpdfsdk_interform.cpp @@ -40,9 +40,9 @@ #include "fpdfsdk/fpdfxfa/cpdfxfa_context.h" #include "fpdfsdk/fpdfxfa/cxfa_fwladaptertimermgr.h" #include "xfa/fxfa/cxfa_eventparam.h" -#include "xfa/fxfa/xfa_ffdocview.h" -#include "xfa/fxfa/xfa_ffwidget.h" -#include "xfa/fxfa/xfa_ffwidgethandler.h" +#include "xfa/fxfa/cxfa_ffdocview.h" +#include "xfa/fxfa/cxfa_ffwidget.h" +#include "xfa/fxfa/cxfa_ffwidgethandler.h" #endif // PDF_ENABLE_XFA CPDFSDK_InterForm::CPDFSDK_InterForm(CPDFSDK_FormFillEnvironment* pFormFillEnv) diff --git a/fpdfsdk/cpdfsdk_pageview.cpp b/fpdfsdk/cpdfsdk_pageview.cpp index a1a02ef185..7a8e2665c3 100644 --- a/fpdfsdk/cpdfsdk_pageview.cpp +++ b/fpdfsdk/cpdfsdk_pageview.cpp @@ -22,10 +22,10 @@ #ifdef PDF_ENABLE_XFA #include "fpdfsdk/fpdfxfa/cpdfxfa_page.h" -#include "xfa/fxfa/xfa_ffdocview.h" -#include "xfa/fxfa/xfa_ffpageview.h" -#include "xfa/fxfa/xfa_ffwidgethandler.h" -#include "xfa/fxfa/xfa_rendercontext.h" +#include "xfa/fxfa/cxfa_ffdocview.h" +#include "xfa/fxfa/cxfa_ffpageview.h" +#include "xfa/fxfa/cxfa_ffwidgethandler.h" +#include "xfa/fxfa/cxfa_rendercontext.h" #include "xfa/fxgraphics/cfx_graphics.h" #endif // PDF_ENABLE_XFA diff --git a/fpdfsdk/cpdfsdk_widget.cpp b/fpdfsdk/cpdfsdk_widget.cpp index ccfee05575..d3000c6c06 100644 --- a/fpdfsdk/cpdfsdk_widget.cpp +++ b/fpdfsdk/cpdfsdk_widget.cpp @@ -35,10 +35,10 @@ #ifdef PDF_ENABLE_XFA #include "fpdfsdk/fpdfxfa/cpdfxfa_context.h" #include "xfa/fxfa/cxfa_eventparam.h" -#include "xfa/fxfa/fxfa_widget.h" -#include "xfa/fxfa/xfa_ffdocview.h" -#include "xfa/fxfa/xfa_ffwidget.h" -#include "xfa/fxfa/xfa_ffwidgethandler.h" +#include "xfa/fxfa/cxfa_ffdocview.h" +#include "xfa/fxfa/cxfa_ffwidget.h" +#include "xfa/fxfa/cxfa_ffwidgethandler.h" +#include "xfa/fxfa/cxfa_widgetacc.h" #endif // PDF_ENABLE_XFA namespace { diff --git a/fpdfsdk/cpdfsdk_xfawidget.cpp b/fpdfsdk/cpdfsdk_xfawidget.cpp index b30e5f3ac2..902ff2a2e8 100644 --- a/fpdfsdk/cpdfsdk_xfawidget.cpp +++ b/fpdfsdk/cpdfsdk_xfawidget.cpp @@ -7,7 +7,7 @@ #include "fpdfsdk/cpdfsdk_xfawidget.h" #include "fpdfsdk/ipdfsdk_annothandler.h" -#include "xfa/fxfa/xfa_ffwidget.h" +#include "xfa/fxfa/cxfa_ffwidget.h" CPDFSDK_XFAWidget::CPDFSDK_XFAWidget(CXFA_FFWidget* pAnnot, CPDFSDK_PageView* pPageView, diff --git a/fpdfsdk/cpdfsdk_xfawidgethandler.cpp b/fpdfsdk/cpdfsdk_xfawidgethandler.cpp index 653eb8ae43..5e258bc4e5 100644 --- a/fpdfsdk/cpdfsdk_xfawidgethandler.cpp +++ b/fpdfsdk/cpdfsdk_xfawidgethandler.cpp @@ -15,11 +15,11 @@ #include "fpdfsdk/fpdfxfa/cpdfxfa_context.h" #include "xfa/fwl/cfwl_app.h" #include "xfa/fwl/fwl_widgethit.h" +#include "xfa/fxfa/cxfa_ffdocview.h" +#include "xfa/fxfa/cxfa_ffpageview.h" +#include "xfa/fxfa/cxfa_ffwidget.h" +#include "xfa/fxfa/cxfa_ffwidgethandler.h" #include "xfa/fxfa/fxfa_basic.h" -#include "xfa/fxfa/xfa_ffdocview.h" -#include "xfa/fxfa/xfa_ffpageview.h" -#include "xfa/fxfa/xfa_ffwidget.h" -#include "xfa/fxfa/xfa_ffwidgethandler.h" #include "xfa/fxgraphics/cfx_graphics.h" CPDFSDK_XFAWidgetHandler::CPDFSDK_XFAWidgetHandler( diff --git a/fpdfsdk/fpdfformfill.cpp b/fpdfsdk/fpdfformfill.cpp index c664d70c57..c2bbeff7e3 100644 --- a/fpdfsdk/fpdfformfill.cpp +++ b/fpdfsdk/fpdfformfill.cpp @@ -29,9 +29,9 @@ #ifdef PDF_ENABLE_XFA #include "fpdfsdk/fpdfxfa/cpdfxfa_context.h" #include "fpdfsdk/fpdfxfa/cpdfxfa_page.h" -#include "xfa/fxfa/xfa_ffdocview.h" -#include "xfa/fxfa/xfa_ffpageview.h" -#include "xfa/fxfa/xfa_ffwidget.h" +#include "xfa/fxfa/cxfa_ffdocview.h" +#include "xfa/fxfa/cxfa_ffpageview.h" +#include "xfa/fxfa/cxfa_ffwidget.h" static_assert(static_cast(XFA_DocType::PDF) == DOCTYPE_PDF, "PDF doctype must match"); diff --git a/fpdfsdk/fpdfsave.cpp b/fpdfsdk/fpdfsave.cpp index bc67cbba23..fe764f5e1f 100644 --- a/fpdfsdk/fpdfsave.cpp +++ b/fpdfsdk/fpdfsave.cpp @@ -24,11 +24,12 @@ #include "fpdfsdk/fpdfxfa/cpdfxfa_context.h" #include "fpdfsdk/fpdfxfa/cxfa_fwladaptertimermgr.h" #include "public/fpdf_formfill.h" +#include "xfa/fxfa/cxfa_checksumcontext.h" #include "xfa/fxfa/cxfa_eventparam.h" -#include "xfa/fxfa/xfa_checksum.h" -#include "xfa/fxfa/xfa_ffapp.h" -#include "xfa/fxfa/xfa_ffdocview.h" -#include "xfa/fxfa/xfa_ffwidgethandler.h" +#include "xfa/fxfa/cxfa_ffapp.h" +#include "xfa/fxfa/cxfa_ffdocview.h" +#include "xfa/fxfa/cxfa_ffwidgethandler.h" +#include "xfa/fxfa/cxfa_widgetacciterator.h" #endif #if _FX_OS_ == _FX_ANDROID_ diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp b/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp index 8d2996f1de..57735426e7 100644 --- a/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp +++ b/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp @@ -20,13 +20,14 @@ #include "public/fpdf_formfill.h" #include "third_party/base/ptr_util.h" #include "third_party/base/stl_util.h" +#include "xfa/fxfa/cxfa_deffontmgr.h" #include "xfa/fxfa/cxfa_eventparam.h" -#include "xfa/fxfa/xfa_ffapp.h" -#include "xfa/fxfa/xfa_ffdoc.h" -#include "xfa/fxfa/xfa_ffdocview.h" -#include "xfa/fxfa/xfa_ffpageview.h" -#include "xfa/fxfa/xfa_ffwidgethandler.h" -#include "xfa/fxfa/xfa_fontmgr.h" +#include "xfa/fxfa/cxfa_ffapp.h" +#include "xfa/fxfa/cxfa_ffdoc.h" +#include "xfa/fxfa/cxfa_ffdocview.h" +#include "xfa/fxfa/cxfa_ffpageview.h" +#include "xfa/fxfa/cxfa_ffwidgethandler.h" +#include "xfa/fxfa/cxfa_fontmgr.h" #ifndef _WIN32 extern void SetLastError(int err); diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_context.h b/fpdfsdk/fpdfxfa/cpdfxfa_context.h index 65e54566e8..8e6b2198af 100644 --- a/fpdfsdk/fpdfxfa/cpdfxfa_context.h +++ b/fpdfsdk/fpdfxfa/cpdfxfa_context.h @@ -11,7 +11,7 @@ #include #include "fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.h" -#include "xfa/fxfa/xfa_ffdoc.h" +#include "xfa/fxfa/cxfa_ffdoc.h" class CJS_Runtime; class CPDFSDK_FormFillEnvironment; diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp b/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp index 44d59c69df..45c5d9255b 100644 --- a/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp +++ b/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp @@ -18,9 +18,10 @@ #include "fpdfsdk/fpdfxfa/cpdfxfa_context.h" #include "fpdfsdk/fpdfxfa/cpdfxfa_page.h" #include "fpdfsdk/javascript/ijs_runtime.h" -#include "xfa/fxfa/xfa_ffdocview.h" -#include "xfa/fxfa/xfa_ffwidget.h" -#include "xfa/fxfa/xfa_ffwidgethandler.h" +#include "xfa/fxfa/cxfa_ffdocview.h" +#include "xfa/fxfa/cxfa_ffwidget.h" +#include "xfa/fxfa/cxfa_ffwidgethandler.h" +#include "xfa/fxfa/cxfa_widgetacciterator.h" #define IDS_XFA_Validate_Input \ "At least one required field was empty. Please fill in the required " \ diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_page.cpp b/fpdfsdk/fpdfxfa/cpdfxfa_page.cpp index 508cf7a15f..e5ab9d357f 100644 --- a/fpdfsdk/fpdfxfa/cpdfxfa_page.cpp +++ b/fpdfsdk/fpdfxfa/cpdfxfa_page.cpp @@ -13,8 +13,8 @@ #include "fpdfsdk/fsdk_define.h" #include "public/fpdf_formfill.h" #include "third_party/base/ptr_util.h" -#include "xfa/fxfa/xfa_ffdocview.h" -#include "xfa/fxfa/xfa_ffpageview.h" +#include "xfa/fxfa/cxfa_ffdocview.h" +#include "xfa/fxfa/cxfa_ffpageview.h" CPDFXFA_Page::CPDFXFA_Page(CPDFXFA_Context* pContext, int page_index) : m_pXFAPageView(nullptr), diff --git a/xfa/fde/xml/cfx_saxreader.cpp b/xfa/fde/xml/cfx_saxreader.cpp index dfef595f8d..50f65731f7 100644 --- a/xfa/fde/xml/cfx_saxreader.cpp +++ b/xfa/fde/xml/cfx_saxreader.cpp @@ -11,7 +11,7 @@ #include "third_party/base/ptr_util.h" #include "third_party/base/stl_util.h" -#include "xfa/fxfa/xfa_checksum.h" +#include "xfa/fxfa/cxfa_saxreaderhandler.h" enum class CFX_SaxMode { Text = 0, diff --git a/xfa/fgas/font/cfgas_gefont.cpp b/xfa/fgas/font/cfgas_gefont.cpp index 769ce36417..7abc3bccb0 100644 --- a/xfa/fgas/font/cfgas_gefont.cpp +++ b/xfa/fgas/font/cfgas_gefont.cpp @@ -15,7 +15,7 @@ #include "third_party/base/ptr_util.h" #include "xfa/fgas/crt/fgas_codepage.h" #include "xfa/fgas/font/fgas_fontutils.h" -#include "xfa/fxfa/xfa_fontmgr.h" +#include "xfa/fxfa/cxfa_fontmgr.h" // static CFX_RetainPtr CFGAS_GEFont::LoadFont(const wchar_t* pszFontFamily, diff --git a/xfa/fwl/cfwl_edit.cpp b/xfa/fwl/cfwl_edit.cpp index 58f8affb66..4af2eb0282 100644 --- a/xfa/fwl/cfwl_edit.cpp +++ b/xfa/fwl/cfwl_edit.cpp @@ -30,8 +30,8 @@ #include "xfa/fwl/cfwl_themepart.h" #include "xfa/fwl/cfwl_widgetmgr.h" #include "xfa/fwl/ifwl_themeprovider.h" -#include "xfa/fxfa/xfa_ffdoc.h" -#include "xfa/fxfa/xfa_ffwidget.h" +#include "xfa/fxfa/cxfa_ffdoc.h" +#include "xfa/fxfa/cxfa_ffwidget.h" #include "xfa/fxgraphics/cfx_path.h" namespace { diff --git a/xfa/fwl/cfwl_timer.cpp b/xfa/fwl/cfwl_timer.cpp index c7214a4f72..0cd3b2b768 100644 --- a/xfa/fwl/cfwl_timer.cpp +++ b/xfa/fwl/cfwl_timer.cpp @@ -10,7 +10,7 @@ #include "xfa/fwl/cfwl_timerinfo.h" #include "xfa/fwl/cfwl_widget.h" #include "xfa/fwl/ifwl_adaptertimermgr.h" -#include "xfa/fxfa/xfa_ffapp.h" +#include "xfa/fxfa/cxfa_ffapp.h" CFWL_TimerInfo* CFWL_Timer::StartTimer(uint32_t dwElapse, bool bImmediately) { const CFWL_App* pApp = m_pWidget->GetOwnerApp(); diff --git a/xfa/fwl/cfwl_widget.cpp b/xfa/fwl/cfwl_widget.cpp index f3ca6c012a..f168ad127c 100644 --- a/xfa/fwl/cfwl_widget.cpp +++ b/xfa/fwl/cfwl_widget.cpp @@ -28,7 +28,7 @@ #include "xfa/fwl/cfwl_themetext.h" #include "xfa/fwl/cfwl_widgetmgr.h" #include "xfa/fwl/ifwl_themeprovider.h" -#include "xfa/fxfa/xfa_ffapp.h" +#include "xfa/fxfa/cxfa_ffapp.h" #define FWL_STYLEEXT_MNU_Vert (1L << 0) #define FWL_WGT_CalcHeight 2048 diff --git a/xfa/fwl/cfwl_widgetmgr.cpp b/xfa/fwl/cfwl_widgetmgr.cpp index d87556e158..55299677a3 100644 --- a/xfa/fwl/cfwl_widgetmgr.cpp +++ b/xfa/fwl/cfwl_widgetmgr.cpp @@ -13,7 +13,7 @@ #include "xfa/fwl/cfwl_form.h" #include "xfa/fwl/cfwl_notedriver.h" #include "xfa/fxfa/app/xfa_fwladapter.h" -#include "xfa/fxfa/xfa_ffapp.h" +#include "xfa/fxfa/cxfa_ffapp.h" namespace { diff --git a/xfa/fwl/theme/cfwl_edittp.cpp b/xfa/fwl/theme/cfwl_edittp.cpp index ebc23bf129..138a99e59d 100644 --- a/xfa/fwl/theme/cfwl_edittp.cpp +++ b/xfa/fwl/theme/cfwl_edittp.cpp @@ -10,7 +10,7 @@ #include "xfa/fwl/cfwl_themebackground.h" #include "xfa/fwl/cfwl_widget.h" #include "xfa/fxfa/app/xfa_fwltheme.h" -#include "xfa/fxfa/xfa_ffwidget.h" +#include "xfa/fxfa/cxfa_ffwidget.h" #include "xfa/fxgraphics/cfx_color.h" #include "xfa/fxgraphics/cfx_path.h" diff --git a/xfa/fxfa/DEPS b/xfa/fxfa/DEPS index 93a9acbc13..97e9f52afa 100644 --- a/xfa/fxfa/DEPS +++ b/xfa/fxfa/DEPS @@ -1,5 +1,8 @@ include_rules = [ '+core/fdrm/crypto', + '+core/fpdfapi/font', + '+core/fpdfapi/page', + '+core/fpdfdoc', '+core/fxcodec', '+fxjs', ] diff --git a/xfa/fxfa/app/DEPS b/xfa/fxfa/app/DEPS index 5c72d1d0b2..f722184c91 100644 --- a/xfa/fxfa/app/DEPS +++ b/xfa/fxfa/app/DEPS @@ -1,6 +1,3 @@ include_rules = [ '+core/fdrm/crypto', - '+core/fpdfapi/font', - '+core/fpdfapi/page', - '+core/fpdfdoc', ] diff --git a/xfa/fxfa/app/cxfa_eventparam.cpp b/xfa/fxfa/app/cxfa_eventparam.cpp deleted file mode 100644 index bd6742f4dd..0000000000 --- a/xfa/fxfa/app/cxfa_eventparam.cpp +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2016 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 - -#include "xfa/fxfa/cxfa_eventparam.h" - -#include "xfa/fxfa/fxfa.h" - -CXFA_EventParam::CXFA_EventParam() - : m_pTarget(nullptr), - m_eType(XFA_EVENT_Unknown), - m_bCancelAction(false), - m_iCommitKey(0), - m_bKeyDown(false), - m_bModifier(false), - m_bReenter(false), - m_iSelEnd(0), - m_iSelStart(0), - m_bShift(false), - m_bIsFormReady(false) {} - -CXFA_EventParam::~CXFA_EventParam() {} - -CXFA_EventParam::CXFA_EventParam(const CXFA_EventParam& other) = default; - -void CXFA_EventParam::Reset() { - m_wsChange.clear(); - m_bCancelAction = false; - m_iCommitKey = 0; - m_wsFullText.clear(); - m_bKeyDown = false; - m_bModifier = false; - m_wsNewContentType.clear(); - m_wsNewText.clear(); - m_wsPrevContentType.clear(); - m_wsPrevText.clear(); - m_bReenter = false; - m_iSelEnd = 0; - m_iSelStart = 0; - m_bShift = false; - m_wsSoapFaultCode.clear(); - m_wsSoapFaultString.clear(); - m_bIsFormReady = false; -} diff --git a/xfa/fxfa/app/cxfa_textparser.cpp b/xfa/fxfa/app/cxfa_textparser.cpp index 546348083e..65155f989c 100644 --- a/xfa/fxfa/app/cxfa_textparser.cpp +++ b/xfa/fxfa/app/cxfa_textparser.cpp @@ -21,10 +21,10 @@ #include "xfa/fxfa/app/cxfa_textparsecontext.h" #include "xfa/fxfa/app/cxfa_texttabstopscontext.h" #include "xfa/fxfa/app/xfa_ffwidgetacc.h" +#include "xfa/fxfa/cxfa_ffapp.h" +#include "xfa/fxfa/cxfa_ffdoc.h" +#include "xfa/fxfa/cxfa_fontmgr.h" #include "xfa/fxfa/parser/cxfa_measurement.h" -#include "xfa/fxfa/xfa_ffapp.h" -#include "xfa/fxfa/xfa_ffdoc.h" -#include "xfa/fxfa/xfa_fontmgr.h" namespace { diff --git a/xfa/fxfa/app/xfa_checksum.cpp b/xfa/fxfa/app/xfa_checksum.cpp deleted file mode 100644 index a06fed870c..0000000000 --- a/xfa/fxfa/app/xfa_checksum.cpp +++ /dev/null @@ -1,269 +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 - -#include "xfa/fxfa/xfa_checksum.h" - -#include "core/fdrm/crypto/fx_crypt.h" -#include "third_party/base/ptr_util.h" - -namespace { - -struct FX_BASE64DATA { - uint32_t data1 : 2; - uint32_t data2 : 6; - uint32_t data3 : 4; - uint32_t data4 : 4; - uint32_t data5 : 6; - uint32_t data6 : 2; - uint32_t data7 : 8; -}; - -const char g_FXBase64EncoderMap[64] = { - 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', - 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', - 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', - 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', - '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/', -}; - -void Base64EncodePiece(const FX_BASE64DATA& src, int32_t iBytes, char dst[4]) { - dst[0] = g_FXBase64EncoderMap[src.data2]; - uint32_t b = src.data1 << 4; - if (iBytes > 1) { - b |= src.data4; - } - dst[1] = g_FXBase64EncoderMap[b]; - if (iBytes > 1) { - b = src.data3 << 2; - if (iBytes > 2) { - b |= src.data6; - } - dst[2] = g_FXBase64EncoderMap[b]; - if (iBytes > 2) { - dst[3] = g_FXBase64EncoderMap[src.data5]; - } else { - dst[3] = '='; - } - } else { - dst[2] = dst[3] = '='; - } -} - -int32_t Base64EncodeA(const uint8_t* pSrc, int32_t iSrcLen, char* pDst) { - ASSERT(pSrc); - if (iSrcLen < 1) { - return 0; - } - if (!pDst) { - int32_t iDstLen = iSrcLen / 3 * 4; - if ((iSrcLen % 3) != 0) { - iDstLen += 4; - } - return iDstLen; - } - FX_BASE64DATA srcData; - int32_t iBytes = 3; - char* pDstEnd = pDst; - while (iSrcLen > 0) { - if (iSrcLen > 2) { - ((uint8_t*)&srcData)[0] = *pSrc++; - ((uint8_t*)&srcData)[1] = *pSrc++; - ((uint8_t*)&srcData)[2] = *pSrc++; - iSrcLen -= 3; - } else { - *((uint32_t*)&srcData) = 0; - ((uint8_t*)&srcData)[0] = *pSrc++; - if (iSrcLen > 1) { - ((uint8_t*)&srcData)[1] = *pSrc++; - } - iBytes = iSrcLen; - iSrcLen = 0; - } - Base64EncodePiece(srcData, iBytes, pDstEnd); - pDstEnd += 4; - } - return pDstEnd - pDst; -} - -} // namespace - -CXFA_SAXReaderHandler::CXFA_SAXReaderHandler(CXFA_ChecksumContext* pContext) - : m_pContext(pContext) { - ASSERT(m_pContext); -} -CXFA_SAXReaderHandler::~CXFA_SAXReaderHandler() {} -CXFA_SAXContext* CXFA_SAXReaderHandler::OnTagEnter( - const CFX_ByteStringC& bsTagName, - CFX_SAXItem::Type eType, - uint32_t dwStartPos) { - UpdateChecksum(true); - if (eType != CFX_SAXItem::Type::Tag && - eType != CFX_SAXItem::Type::Instruction) { - return nullptr; - } - m_SAXContext.m_eNode = eType; - CFX_ByteTextBuf& textBuf = m_SAXContext.m_TextBuf; - textBuf << "<"; - if (eType == CFX_SAXItem::Type::Instruction) { - textBuf << "?"; - } - textBuf << bsTagName; - m_SAXContext.m_bsTagName = bsTagName; - return &m_SAXContext; -} - -void CXFA_SAXReaderHandler::OnTagAttribute(CXFA_SAXContext* pTag, - const CFX_ByteStringC& bsAttri, - const CFX_ByteStringC& bsValue) { - if (!pTag) - return; - - pTag->m_TextBuf << " " << bsAttri << "=\"" << bsValue << "\""; -} - -void CXFA_SAXReaderHandler::OnTagBreak(CXFA_SAXContext* pTag) { - if (!pTag) - return; - - pTag->m_TextBuf << ">"; - UpdateChecksum(false); -} - -void CXFA_SAXReaderHandler::OnTagData(CXFA_SAXContext* pTag, - CFX_SAXItem::Type eType, - const CFX_ByteStringC& bsData, - uint32_t dwStartPos) { - if (!pTag) - return; - - CFX_ByteTextBuf& textBuf = pTag->m_TextBuf; - if (eType == CFX_SAXItem::Type::CharData) - textBuf << ""; -} - -void CXFA_SAXReaderHandler::OnTagClose(CXFA_SAXContext* pTag, - uint32_t dwEndPos) { - if (!pTag) - return; - - CFX_ByteTextBuf& textBuf = pTag->m_TextBuf; - if (pTag->m_eNode == CFX_SAXItem::Type::Instruction) - textBuf << "?>"; - else if (pTag->m_eNode == CFX_SAXItem::Type::Tag) - textBuf << ">m_bsTagName.AsStringC() << ">"; - - UpdateChecksum(false); -} - -void CXFA_SAXReaderHandler::OnTagEnd(CXFA_SAXContext* pTag, - const CFX_ByteStringC& bsTagName, - uint32_t dwEndPos) { - if (!pTag) - return; - - pTag->m_TextBuf << ""; - UpdateChecksum(false); -} - -void CXFA_SAXReaderHandler::OnTargetData(CXFA_SAXContext* pTag, - CFX_SAXItem::Type eType, - const CFX_ByteStringC& bsData, - uint32_t dwStartPos) { - if (!pTag && eType != CFX_SAXItem::Type::Comment) - return; - - if (eType == CFX_SAXItem::Type::Comment) { - m_SAXContext.m_TextBuf << ""; - UpdateChecksum(false); - } else { - pTag->m_TextBuf << " " << bsData; - } -} - -void CXFA_SAXReaderHandler::UpdateChecksum(bool bCheckSpace) { - int32_t iLength = m_SAXContext.m_TextBuf.GetLength(); - if (iLength < 1) { - return; - } - uint8_t* pBuffer = m_SAXContext.m_TextBuf.GetBuffer(); - bool bUpdata = true; - if (bCheckSpace) { - bUpdata = false; - for (int32_t i = 0; i < iLength; i++) { - bUpdata = (pBuffer[i] > 0x20); - if (bUpdata) { - break; - } - } - } - if (bUpdata) { - m_pContext->Update(CFX_ByteStringC(pBuffer, iLength)); - } - m_SAXContext.m_TextBuf.Clear(); -} - -CXFA_ChecksumContext::CXFA_ChecksumContext() {} - -CXFA_ChecksumContext::~CXFA_ChecksumContext() {} - -void CXFA_ChecksumContext::StartChecksum() { - FinishChecksum(); - m_pByteContext = pdfium::MakeUnique(); - CRYPT_SHA1Start(m_pByteContext.get()); - m_bsChecksum.clear(); - m_pSAXReader = pdfium::MakeUnique(); -} - -bool CXFA_ChecksumContext::UpdateChecksum( - const CFX_RetainPtr& pSrcFile, - FX_FILESIZE offset, - size_t size) { - if (!m_pSAXReader || !pSrcFile) - return false; - - if (size < 1) - size = pSrcFile->GetSize(); - - CXFA_SAXReaderHandler handler(this); - m_pSAXReader->SetHandler(&handler); - if (m_pSAXReader->StartParse( - pSrcFile, (uint32_t)offset, (uint32_t)size, - CFX_SaxParseMode_NotSkipSpace | CFX_SaxParseMode_NotConvert_amp | - CFX_SaxParseMode_NotConvert_lt | CFX_SaxParseMode_NotConvert_gt | - CFX_SaxParseMode_NotConvert_sharp) < 0) { - return false; - } - return m_pSAXReader->ContinueParse(nullptr) > 99; -} - -void CXFA_ChecksumContext::FinishChecksum() { - m_pSAXReader.reset(); - if (m_pByteContext) { - uint8_t digest[20]; - FXSYS_memset(digest, 0, 20); - CRYPT_SHA1Finish(m_pByteContext.get(), digest); - int32_t nLen = Base64EncodeA(digest, 20, nullptr); - char* pBuffer = m_bsChecksum.GetBuffer(nLen); - Base64EncodeA(digest, 20, pBuffer); - m_bsChecksum.ReleaseBuffer(nLen); - m_pByteContext.reset(); - } -} - -CFX_ByteString CXFA_ChecksumContext::GetChecksum() const { - return m_bsChecksum; -} - -void CXFA_ChecksumContext::Update(const CFX_ByteStringC& bsText) { - if (!m_pByteContext) - return; - - CRYPT_SHA1Update(m_pByteContext.get(), bsText.raw_str(), bsText.GetLength()); -} diff --git a/xfa/fxfa/app/xfa_ffapp.cpp b/xfa/fxfa/app/xfa_ffapp.cpp deleted file mode 100644 index 219f06e4ff..0000000000 --- a/xfa/fxfa/app/xfa_ffapp.cpp +++ /dev/null @@ -1,162 +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 - -#include "xfa/fxfa/xfa_ffapp.h" - -#include -#include -#include -#include - -#include "third_party/base/ptr_util.h" -#include "third_party/base/stl_util.h" -#include "xfa/fgas/font/cfgas_fontmgr.h" -#include "xfa/fwl/cfwl_notedriver.h" -#include "xfa/fwl/cfwl_widgetmgr.h" -#include "xfa/fxfa/app/xfa_fwladapter.h" -#include "xfa/fxfa/app/xfa_fwltheme.h" -#include "xfa/fxfa/xfa_ffdoc.h" -#include "xfa/fxfa/xfa_ffdochandler.h" -#include "xfa/fxfa/xfa_ffwidgethandler.h" -#include "xfa/fxfa/xfa_fontmgr.h" - -namespace { - -class CXFA_FileRead : public IFX_SeekableReadStream { - public: - explicit CXFA_FileRead(const std::vector& streams); - ~CXFA_FileRead() override; - - // IFX_SeekableReadStream - FX_FILESIZE GetSize() override; - bool ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override; - - private: - std::vector> m_Data; -}; - -CXFA_FileRead::CXFA_FileRead(const std::vector& streams) { - for (CPDF_Stream* pStream : streams) { - m_Data.push_back(pdfium::MakeUnique()); - m_Data.back()->LoadAllData(pStream); - } -} - -CXFA_FileRead::~CXFA_FileRead() {} - -FX_FILESIZE CXFA_FileRead::GetSize() { - uint32_t dwSize = 0; - for (const auto& acc : m_Data) - dwSize += acc->GetSize(); - return dwSize; -} - -bool CXFA_FileRead::ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) { - int32_t iCount = pdfium::CollectionSize(m_Data); - int32_t index = 0; - while (index < iCount) { - const auto& acc = m_Data[index]; - FX_FILESIZE dwSize = acc->GetSize(); - if (offset < dwSize) - break; - - offset -= dwSize; - index++; - } - while (index < iCount) { - const auto& acc = m_Data[index]; - uint32_t dwSize = acc->GetSize(); - size_t dwRead = std::min(size, static_cast(dwSize - offset)); - FXSYS_memcpy(buffer, acc->GetData() + offset, dwRead); - size -= dwRead; - if (size == 0) - return true; - - buffer = (uint8_t*)buffer + dwRead; - offset = 0; - index++; - } - return false; -} - -} // namespace - -CFX_RetainPtr MakeSeekableReadStream( - const std::vector& streams) { - return CFX_RetainPtr(new CXFA_FileRead(streams)); -} - -CXFA_FFApp::CXFA_FFApp(IXFA_AppProvider* pProvider) - : m_pProvider(pProvider), - m_pWidgetMgrDelegate(nullptr), - m_pFWLApp(new CFWL_App(this)) {} - -CXFA_FFApp::~CXFA_FFApp() {} - -CXFA_FFDocHandler* CXFA_FFApp::GetDocHandler() { - if (!m_pDocHandler) - m_pDocHandler = pdfium::MakeUnique(); - return m_pDocHandler.get(); -} - -std::unique_ptr CXFA_FFApp::CreateDoc( - IXFA_DocEnvironment* pDocEnvironment, - CPDF_Document* pPDFDoc) { - if (!pPDFDoc) - return nullptr; - - auto pDoc = pdfium::MakeUnique(this, pDocEnvironment); - if (!pDoc->OpenDoc(pPDFDoc)) - return nullptr; - - return pDoc; -} - -void CXFA_FFApp::SetDefaultFontMgr(std::unique_ptr pFontMgr) { - if (!m_pFontMgr) - m_pFontMgr = pdfium::MakeUnique(); - m_pFontMgr->SetDefFontMgr(std::move(pFontMgr)); -} - -CXFA_FontMgr* CXFA_FFApp::GetXFAFontMgr() const { - return m_pFontMgr.get(); -} - -CFGAS_FontMgr* CXFA_FFApp::GetFDEFontMgr() { - if (!m_pFDEFontMgr) { -#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ - m_pFDEFontMgr = CFGAS_FontMgr::Create(FX_GetDefFontEnumerator()); -#else - m_pFontSource = pdfium::MakeUnique(); - m_pFDEFontMgr = CFGAS_FontMgr::Create(m_pFontSource.get()); -#endif - } - return m_pFDEFontMgr.get(); -} - -CXFA_FWLTheme* CXFA_FFApp::GetFWLTheme() { - if (!m_pFWLTheme) - m_pFWLTheme = pdfium::MakeUnique(this); - return m_pFWLTheme.get(); -} - -CXFA_FWLAdapterWidgetMgr* CXFA_FFApp::GetWidgetMgr( - CFWL_WidgetMgrDelegate* pDelegate) { - if (!m_pAdapterWidgetMgr) { - m_pAdapterWidgetMgr = pdfium::MakeUnique(); - pDelegate->OnSetCapability(FWL_WGTMGR_DisableForm); - m_pWidgetMgrDelegate = pDelegate; - } - return m_pAdapterWidgetMgr.get(); -} - -IFWL_AdapterTimerMgr* CXFA_FFApp::GetTimerMgr() const { - return m_pProvider->GetTimerMgr(); -} - -void CXFA_FFApp::ClearEventTargets() { - m_pFWLApp->GetNoteDriver()->ClearEventTargets(false); -} diff --git a/xfa/fxfa/app/xfa_ffapp_unittest.cpp b/xfa/fxfa/app/xfa_ffapp_unittest.cpp deleted file mode 100644 index b0879012b4..0000000000 --- a/xfa/fxfa/app/xfa_ffapp_unittest.cpp +++ /dev/null @@ -1,87 +0,0 @@ -// Copyright 2016 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. - -#include "xfa/fxfa/xfa_ffapp.h" - -#include -#include - -#include "core/fpdfapi/parser/cpdf_dictionary.h" -#include "core/fpdfapi/parser/cpdf_stream.h" -#include "core/fxcrt/fx_memory.h" -#include "testing/gtest/include/gtest/gtest.h" -#include "third_party/base/ptr_util.h" - -TEST(CXFAFileRead, NoStreams) { - std::vector streams; - CFX_RetainPtr fileread = - MakeSeekableReadStream(streams); - - uint8_t output_buffer[16]; - memset(output_buffer, 0xbd, sizeof(output_buffer)); - EXPECT_FALSE(fileread->ReadBlock(output_buffer, 0, 0)); - EXPECT_EQ(0xbd, output_buffer[0]); -} - -TEST(CXFAFileRead, EmptyStreams) { - std::vector streams; - auto stream1 = pdfium::MakeUnique(); - streams.push_back(stream1.get()); - CFX_RetainPtr fileread = - MakeSeekableReadStream(streams); - - uint8_t output_buffer[16]; - memset(output_buffer, 0xbd, sizeof(output_buffer)); - EXPECT_FALSE(fileread->ReadBlock(output_buffer, 0, 0)); - EXPECT_EQ(0xbd, output_buffer[0]); -} - -TEST(CXFAFileRead, NormalStreams) { - std::vector streams; - auto stream1 = pdfium::MakeUnique(); - auto stream2 = pdfium::MakeUnique(); - auto stream3 = pdfium::MakeUnique(); - - // 16 chars total. - stream1->InitStream(reinterpret_cast("one t"), 5, - pdfium::MakeUnique()); - stream2->InitStream(reinterpret_cast("wo "), 3, - pdfium::MakeUnique()); - stream3->InitStream(reinterpret_cast("three!!!"), 8, - pdfium::MakeUnique()); - - streams.push_back(stream1.get()); - streams.push_back(stream2.get()); - streams.push_back(stream3.get()); - CFX_RetainPtr fileread = - MakeSeekableReadStream(streams); - - uint8_t output_buffer[16]; - memset(output_buffer, 0xbd, sizeof(output_buffer)); - EXPECT_TRUE(fileread->ReadBlock(output_buffer, 0, 0)); - EXPECT_EQ(0xbd, output_buffer[0]); - - memset(output_buffer, 0xbd, sizeof(output_buffer)); - EXPECT_TRUE(fileread->ReadBlock(output_buffer, 1, 0)); - EXPECT_EQ(0xbd, output_buffer[0]); - - memset(output_buffer, 0xbd, sizeof(output_buffer)); - EXPECT_TRUE(fileread->ReadBlock(output_buffer, 0, 1)); - EXPECT_EQ(0, memcmp(output_buffer, "o", 1)); - EXPECT_EQ(0xbd, output_buffer[1]); - - memset(output_buffer, 0xbd, sizeof(output_buffer)); - EXPECT_TRUE(fileread->ReadBlock(output_buffer, 0, sizeof(output_buffer))); - EXPECT_EQ(0, memcmp(output_buffer, "one two three!!!", 16)); - - memset(output_buffer, 0xbd, sizeof(output_buffer)); - EXPECT_TRUE(fileread->ReadBlock(output_buffer, 2, 10)); - EXPECT_EQ(0, memcmp(output_buffer, "e two thre", 10)); - EXPECT_EQ(0xbd, output_buffer[11]); - - memset(output_buffer, 0xbd, sizeof(output_buffer)); - EXPECT_FALSE(fileread->ReadBlock(output_buffer, 1, sizeof(output_buffer))); - EXPECT_EQ(0, memcmp(output_buffer, "ne two three!!!", 15)); - EXPECT_EQ(0xbd, output_buffer[15]); -} diff --git a/xfa/fxfa/app/xfa_ffbarcode.cpp b/xfa/fxfa/app/xfa_ffbarcode.cpp index 6b13069ed2..72adb3c96b 100644 --- a/xfa/fxfa/app/xfa_ffbarcode.cpp +++ b/xfa/fxfa/app/xfa_ffbarcode.cpp @@ -13,8 +13,8 @@ #include "xfa/fxfa/app/xfa_fffield.h" #include "xfa/fxfa/app/xfa_fftextedit.h" #include "xfa/fxfa/app/xfa_fwladapter.h" -#include "xfa/fxfa/xfa_ffpageview.h" -#include "xfa/fxfa/xfa_ffwidget.h" +#include "xfa/fxfa/cxfa_ffpageview.h" +#include "xfa/fxfa/cxfa_ffwidget.h" namespace { diff --git a/xfa/fxfa/app/xfa_ffbarcode.h b/xfa/fxfa/app/xfa_ffbarcode.h index 1f11be6da7..6d93e1b682 100644 --- a/xfa/fxfa/app/xfa_ffbarcode.h +++ b/xfa/fxfa/app/xfa_ffbarcode.h @@ -9,7 +9,7 @@ #include "xfa/fxbarcode/BC_Library.h" #include "xfa/fxfa/app/xfa_fftextedit.h" -#include "xfa/fxfa/xfa_ffpageview.h" +#include "xfa/fxfa/cxfa_ffpageview.h" class CXFA_FFBarcode : public CXFA_FFTextEdit { public: diff --git a/xfa/fxfa/app/xfa_ffcheckbutton.cpp b/xfa/fxfa/app/xfa_ffcheckbutton.cpp index 22fdb3d9df..9f003ad3a1 100644 --- a/xfa/fxfa/app/xfa_ffcheckbutton.cpp +++ b/xfa/fxfa/app/xfa_ffcheckbutton.cpp @@ -12,11 +12,11 @@ #include "xfa/fwl/cfwl_widgetmgr.h" #include "xfa/fxfa/app/xfa_ffexclgroup.h" #include "xfa/fxfa/app/xfa_fffield.h" -#include "xfa/fxfa/xfa_ffapp.h" -#include "xfa/fxfa/xfa_ffdoc.h" -#include "xfa/fxfa/xfa_ffdocview.h" -#include "xfa/fxfa/xfa_ffpageview.h" -#include "xfa/fxfa/xfa_ffwidget.h" +#include "xfa/fxfa/cxfa_ffapp.h" +#include "xfa/fxfa/cxfa_ffdoc.h" +#include "xfa/fxfa/cxfa_ffdocview.h" +#include "xfa/fxfa/cxfa_ffpageview.h" +#include "xfa/fxfa/cxfa_ffwidget.h" CXFA_FFCheckButton::CXFA_FFCheckButton(CXFA_WidgetAcc* pDataAcc) : CXFA_FFField(pDataAcc), m_pOldDelegate(nullptr) {} diff --git a/xfa/fxfa/app/xfa_ffcheckbutton.h b/xfa/fxfa/app/xfa_ffcheckbutton.h index 2c0acd6e3e..ea8ff923a7 100644 --- a/xfa/fxfa/app/xfa_ffcheckbutton.h +++ b/xfa/fxfa/app/xfa_ffcheckbutton.h @@ -8,7 +8,7 @@ #define XFA_FXFA_APP_XFA_FFCHECKBUTTON_H_ #include "xfa/fxfa/app/xfa_fffield.h" -#include "xfa/fxfa/xfa_ffpageview.h" +#include "xfa/fxfa/cxfa_ffpageview.h" class CXFA_FFCheckButton : public CXFA_FFField { public: diff --git a/xfa/fxfa/app/xfa_ffchoicelist.cpp b/xfa/fxfa/app/xfa_ffchoicelist.cpp index 66b52fec40..460964532e 100644 --- a/xfa/fxfa/app/xfa_ffchoicelist.cpp +++ b/xfa/fxfa/app/xfa_ffchoicelist.cpp @@ -20,10 +20,10 @@ #include "xfa/fxfa/app/xfa_fffield.h" #include "xfa/fxfa/app/xfa_fwladapter.h" #include "xfa/fxfa/cxfa_eventparam.h" -#include "xfa/fxfa/xfa_ffdoc.h" -#include "xfa/fxfa/xfa_ffdocview.h" -#include "xfa/fxfa/xfa_ffpageview.h" -#include "xfa/fxfa/xfa_ffwidget.h" +#include "xfa/fxfa/cxfa_ffdoc.h" +#include "xfa/fxfa/cxfa_ffdocview.h" +#include "xfa/fxfa/cxfa_ffpageview.h" +#include "xfa/fxfa/cxfa_ffwidget.h" CXFA_FFListBox::CXFA_FFListBox(CXFA_WidgetAcc* pDataAcc) : CXFA_FFField(pDataAcc), m_pOldDelegate(nullptr) {} diff --git a/xfa/fxfa/app/xfa_ffchoicelist.h b/xfa/fxfa/app/xfa_ffchoicelist.h index e89366ad13..231381444b 100644 --- a/xfa/fxfa/app/xfa_ffchoicelist.h +++ b/xfa/fxfa/app/xfa_ffchoicelist.h @@ -8,7 +8,7 @@ #define XFA_FXFA_APP_XFA_FFCHOICELIST_H_ #include "xfa/fxfa/app/xfa_fffield.h" -#include "xfa/fxfa/xfa_ffpageview.h" +#include "xfa/fxfa/cxfa_ffpageview.h" class CXFA_FFListBox : public CXFA_FFField { public: diff --git a/xfa/fxfa/app/xfa_ffdoc.cpp b/xfa/fxfa/app/xfa_ffdoc.cpp deleted file mode 100644 index ba1f5d8124..0000000000 --- a/xfa/fxfa/app/xfa_ffdoc.cpp +++ /dev/null @@ -1,430 +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 - -#include "xfa/fxfa/xfa_ffdoc.h" - -#include -#include -#include - -#include "core/fpdfapi/parser/cpdf_array.h" -#include "core/fpdfapi/parser/cpdf_document.h" -#include "core/fpdfapi/parser/fpdf_parser_decode.h" -#include "core/fpdfdoc/cpdf_nametree.h" -#include "core/fxcrt/fx_ext.h" -#include "core/fxcrt/fx_memory.h" -#include "third_party/base/ptr_util.h" -#include "xfa/fde/xml/fde_xml_imp.h" -#include "xfa/fwl/cfwl_notedriver.h" -#include "xfa/fxfa/app/xfa_ffnotify.h" -#include "xfa/fxfa/parser/cxfa_dataexporter.h" -#include "xfa/fxfa/parser/cxfa_dataimporter.h" -#include "xfa/fxfa/parser/cxfa_document.h" -#include "xfa/fxfa/xfa_checksum.h" -#include "xfa/fxfa/xfa_ffapp.h" -#include "xfa/fxfa/xfa_ffdocview.h" -#include "xfa/fxfa/xfa_ffwidget.h" -#include "xfa/fxfa/xfa_fontmgr.h" - -namespace { - -struct FX_BASE64DATA { - uint32_t data1 : 2; - uint32_t data2 : 6; - uint32_t data3 : 4; - uint32_t data4 : 4; - uint32_t data5 : 6; - uint32_t data6 : 2; - uint32_t data7 : 8; -}; - -const uint8_t kStartValuesRemoved = 43; -const uint8_t kDecoderMapSize = 80; -const uint8_t g_FXBase64DecoderMap[kDecoderMapSize] = { - 0x3E, 0xFF, 0xFF, 0xFF, 0x3F, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, - 0x3B, 0x3C, 0x3D, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x01, - 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, - 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, - 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, - 0x2C, 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, -}; - -uint8_t base64DecoderValue(uint8_t val) { - if (val < kStartValuesRemoved || val >= kStartValuesRemoved + kDecoderMapSize) - return 0xFF; - return g_FXBase64DecoderMap[val - kStartValuesRemoved]; -} - -void Base64DecodePiece(const char src[4], - int32_t iChars, - FX_BASE64DATA& dst, - int32_t& iBytes) { - ASSERT(iChars > 0 && iChars < 5); - iBytes = 1; - dst.data2 = base64DecoderValue(static_cast(src[0])); - if (iChars > 1) { - uint8_t b = base64DecoderValue(static_cast(src[1])); - dst.data1 = b >> 4; - dst.data4 = b; - if (iChars > 2) { - iBytes = 2; - b = base64DecoderValue(static_cast(src[2])); - dst.data3 = b >> 2; - dst.data6 = b; - if (iChars > 3) { - iBytes = 3; - dst.data5 = base64DecoderValue(static_cast(src[3])); - } else { - dst.data5 = 0; - } - } else { - dst.data3 = 0; - } - } else { - dst.data1 = 0; - } -} - -int32_t Base64DecodeW(const wchar_t* pSrc, int32_t iSrcLen, uint8_t* pDst) { - ASSERT(pSrc); - if (iSrcLen < 1) { - return 0; - } - while (iSrcLen > 0 && pSrc[iSrcLen - 1] == '=') { - iSrcLen--; - } - if (iSrcLen < 1) { - return 0; - } - if (!pDst) { - int32_t iDstLen = iSrcLen / 4 * 3; - iSrcLen %= 4; - if (iSrcLen == 1) { - iDstLen += 1; - } else if (iSrcLen == 2) { - iDstLen += 1; - } else if (iSrcLen == 3) { - iDstLen += 2; - } - return iDstLen; - } - char srcData[4]; - FX_BASE64DATA dstData; - int32_t iChars = 4, iBytes; - uint8_t* pDstEnd = pDst; - while (iSrcLen > 0) { - if (iSrcLen > 3) { - srcData[0] = (char)*pSrc++; - srcData[1] = (char)*pSrc++; - srcData[2] = (char)*pSrc++; - srcData[3] = (char)*pSrc++; - iSrcLen -= 4; - } else { - *((uint32_t*)&dstData) = 0; - *((uint32_t*)srcData) = 0; - srcData[0] = (char)*pSrc++; - if (iSrcLen > 1) { - srcData[1] = (char)*pSrc++; - } - if (iSrcLen > 2) { - srcData[2] = (char)*pSrc++; - } - iChars = iSrcLen; - iSrcLen = 0; - } - Base64DecodePiece(srcData, iChars, dstData, iBytes); - *pDstEnd++ = ((uint8_t*)&dstData)[0]; - if (iBytes > 1) { - *pDstEnd++ = ((uint8_t*)&dstData)[1]; - } - if (iBytes > 2) { - *pDstEnd++ = ((uint8_t*)&dstData)[2]; - } - } - return pDstEnd - pDst; -} - -} // namespace - -CXFA_FFDoc::CXFA_FFDoc(CXFA_FFApp* pApp, IXFA_DocEnvironment* pDocEnvironment) - : m_pDocEnvironment(pDocEnvironment), - m_pDocumentParser(nullptr), - m_pApp(pApp), - m_pNotify(nullptr), - m_pPDFDoc(nullptr), - m_dwDocType(XFA_DocType::Static) {} - -CXFA_FFDoc::~CXFA_FFDoc() { - CloseDoc(); -} - -int32_t CXFA_FFDoc::StartLoad() { - m_pNotify = pdfium::MakeUnique(this); - m_pDocumentParser = pdfium::MakeUnique(m_pNotify.get()); - return m_pDocumentParser->StartParse(m_pStream, XFA_XDPPACKET_XDP); -} - -bool XFA_GetPDFContentsFromPDFXML(CFDE_XMLNode* pPDFElement, - uint8_t*& pByteBuffer, - int32_t& iBufferSize) { - CFDE_XMLElement* pDocumentElement = nullptr; - for (CFDE_XMLNode* pXMLNode = - pPDFElement->GetNodeItem(CFDE_XMLNode::FirstChild); - pXMLNode; pXMLNode = pXMLNode->GetNodeItem(CFDE_XMLNode::NextSibling)) { - if (pXMLNode->GetType() == FDE_XMLNODE_Element) { - CFX_WideString wsTagName; - CFDE_XMLElement* pXMLElement = static_cast(pXMLNode); - pXMLElement->GetTagName(wsTagName); - if (wsTagName == L"document") { - pDocumentElement = pXMLElement; - break; - } - } - } - if (!pDocumentElement) { - return false; - } - CFDE_XMLElement* pChunkElement = nullptr; - for (CFDE_XMLNode* pXMLNode = - pDocumentElement->GetNodeItem(CFDE_XMLNode::FirstChild); - pXMLNode; pXMLNode = pXMLNode->GetNodeItem(CFDE_XMLNode::NextSibling)) { - if (pXMLNode->GetType() == FDE_XMLNODE_Element) { - CFX_WideString wsTagName; - CFDE_XMLElement* pXMLElement = static_cast(pXMLNode); - pXMLElement->GetTagName(wsTagName); - if (wsTagName == L"chunk") { - pChunkElement = pXMLElement; - break; - } - } - } - if (!pChunkElement) { - return false; - } - CFX_WideString wsPDFContent; - pChunkElement->GetTextData(wsPDFContent); - iBufferSize = - Base64DecodeW(wsPDFContent.c_str(), wsPDFContent.GetLength(), nullptr); - pByteBuffer = FX_Alloc(uint8_t, iBufferSize + 1); - pByteBuffer[iBufferSize] = '0'; // FIXME: I bet this is wrong. - Base64DecodeW(wsPDFContent.c_str(), wsPDFContent.GetLength(), pByteBuffer); - return true; -} -void XFA_XPDPacket_MergeRootNode(CXFA_Node* pOriginRoot, CXFA_Node* pNewRoot) { - CXFA_Node* pChildNode = pNewRoot->GetNodeItem(XFA_NODEITEM_FirstChild); - while (pChildNode) { - CXFA_Node* pOriginChild = - pOriginRoot->GetFirstChildByName(pChildNode->GetNameHash()); - if (pOriginChild) { - pChildNode = pChildNode->GetNodeItem(XFA_NODEITEM_NextSibling); - } else { - CXFA_Node* pNextSibling = - pChildNode->GetNodeItem(XFA_NODEITEM_NextSibling); - pNewRoot->RemoveChild(pChildNode); - pOriginRoot->InsertChild(pChildNode); - pChildNode = pNextSibling; - pNextSibling = nullptr; - } - } -} - -int32_t CXFA_FFDoc::DoLoad(IFX_Pause* pPause) { - int32_t iStatus = m_pDocumentParser->DoParse(pPause); - if (iStatus == XFA_PARSESTATUS_Done && !m_pPDFDoc) - return XFA_PARSESTATUS_SyntaxErr; - return iStatus; -} - -void CXFA_FFDoc::StopLoad() { - m_pApp->GetXFAFontMgr()->LoadDocFonts(this); - m_dwDocType = XFA_DocType::Static; - CXFA_Node* pConfig = ToNode( - m_pDocumentParser->GetDocument()->GetXFAObject(XFA_HASHCODE_Config)); - if (!pConfig) - return; - - CXFA_Node* pAcrobat = pConfig->GetFirstChildByClass(XFA_Element::Acrobat); - if (!pAcrobat) - return; - - CXFA_Node* pAcrobat7 = pAcrobat->GetFirstChildByClass(XFA_Element::Acrobat7); - if (!pAcrobat7) - return; - - CXFA_Node* pDynamicRender = - pAcrobat7->GetFirstChildByClass(XFA_Element::DynamicRender); - if (!pDynamicRender) - return; - - CFX_WideString wsType; - if (pDynamicRender->TryContent(wsType) && wsType == L"required") - m_dwDocType = XFA_DocType::Dynamic; -} - -CXFA_FFDocView* CXFA_FFDoc::CreateDocView() { - if (!m_DocView) - m_DocView = pdfium::MakeUnique(this); - - return m_DocView.get(); -} - -CXFA_FFDocView* CXFA_FFDoc::GetDocView(CXFA_LayoutProcessor* pLayout) { - return m_DocView && m_DocView->GetXFALayout() == pLayout ? m_DocView.get() - : nullptr; -} - -CXFA_FFDocView* CXFA_FFDoc::GetDocView() { - return m_DocView.get(); -} - -bool CXFA_FFDoc::OpenDoc(const CFX_RetainPtr& pStream) { - m_pStream = pStream; - return true; -} - -bool CXFA_FFDoc::OpenDoc(CPDF_Document* pPDFDoc) { - if (!pPDFDoc) - return false; - - CPDF_Dictionary* pRoot = pPDFDoc->GetRoot(); - if (!pRoot) - return false; - - CPDF_Dictionary* pAcroForm = pRoot->GetDictFor("AcroForm"); - if (!pAcroForm) - return false; - - CPDF_Object* pElementXFA = pAcroForm->GetDirectObjectFor("XFA"); - if (!pElementXFA) - return false; - - std::vector xfaStreams; - if (pElementXFA->IsArray()) { - CPDF_Array* pXFAArray = (CPDF_Array*)pElementXFA; - for (size_t i = 0; i < pXFAArray->GetCount() / 2; i++) { - if (CPDF_Stream* pStream = pXFAArray->GetStreamAt(i * 2 + 1)) - xfaStreams.push_back(pStream); - } - } else if (pElementXFA->IsStream()) { - xfaStreams.push_back((CPDF_Stream*)pElementXFA); - } - if (xfaStreams.empty()) - return false; - - m_pPDFDoc = pPDFDoc; - m_pStream = MakeSeekableReadStream(xfaStreams); - return true; -} - -bool CXFA_FFDoc::CloseDoc() { - if (m_DocView) - m_DocView->RunDocClose(); - - CXFA_Document* doc = - m_pDocumentParser ? m_pDocumentParser->GetDocument() : nullptr; - if (doc) - doc->ClearLayoutData(); - - m_DocView.reset(); - m_pNotify.reset(nullptr); - m_pApp->GetXFAFontMgr()->ReleaseDocFonts(this); - - for (const auto& pair : m_HashToDibDpiMap) - delete pair.second.pDibSource; - - m_HashToDibDpiMap.clear(); - m_pApp->ClearEventTargets(); - return true; -} - -CPDF_Document* CXFA_FFDoc::GetPDFDoc() { - return m_pPDFDoc; -} - -CFX_DIBitmap* CXFA_FFDoc::GetPDFNamedImage(const CFX_WideStringC& wsName, - int32_t& iImageXDpi, - int32_t& iImageYDpi) { - if (!m_pPDFDoc) - return nullptr; - - uint32_t dwHash = FX_HashCode_GetW(wsName, false); - auto it = m_HashToDibDpiMap.find(dwHash); - if (it != m_HashToDibDpiMap.end()) { - iImageXDpi = it->second.iImageXDpi; - iImageYDpi = it->second.iImageYDpi; - return static_cast(it->second.pDibSource); - } - - CPDF_Dictionary* pRoot = m_pPDFDoc->GetRoot(); - if (!pRoot) - return nullptr; - - CPDF_Dictionary* pNames = pRoot->GetDictFor("Names"); - if (!pNames) - return nullptr; - - CPDF_Dictionary* pXFAImages = pNames->GetDictFor("XFAImages"); - if (!pXFAImages) - return nullptr; - - CPDF_NameTree nametree(pXFAImages); - CFX_ByteString bsName = PDF_EncodeText(wsName.c_str(), wsName.GetLength()); - CPDF_Object* pObject = nametree.LookupValue(bsName); - if (!pObject) { - for (size_t i = 0; i < nametree.GetCount(); i++) { - CFX_ByteString bsTemp; - CPDF_Object* pTempObject = nametree.LookupValue(i, bsTemp); - if (bsTemp == bsName) { - pObject = pTempObject; - break; - } - } - } - - CPDF_Stream* pStream = ToStream(pObject); - if (!pStream) - return nullptr; - - CPDF_StreamAcc streamAcc; - streamAcc.LoadAllData(pStream); - - CFX_RetainPtr pImageFileRead = - IFX_MemoryStream::Create((uint8_t*)streamAcc.GetData(), - streamAcc.GetSize()); - - CFX_DIBitmap* pDibSource = XFA_LoadImageFromBuffer( - pImageFileRead, FXCODEC_IMAGE_UNKNOWN, iImageXDpi, iImageYDpi); - m_HashToDibDpiMap[dwHash] = {pDibSource, iImageXDpi, iImageYDpi}; - return pDibSource; -} - -bool CXFA_FFDoc::SavePackage( - XFA_HashCode code, - const CFX_RetainPtr& pFile, - CXFA_ChecksumContext* pCSContext) { - CXFA_Document* doc = m_pDocumentParser->GetDocument(); - std::unique_ptr pExport(new CXFA_DataExporter(doc)); - CXFA_Node* pNode = code == XFA_HASHCODE_Xfa ? doc->GetRoot() - : ToNode(doc->GetXFAObject(code)); - if (!pNode) - return !!pExport->Export(pFile); - - CFX_ByteString bsChecksum; - if (pCSContext) - bsChecksum = pCSContext->GetChecksum(); - - return !!pExport->Export( - pFile, pNode, 0, bsChecksum.GetLength() ? bsChecksum.c_str() : nullptr); -} - -bool CXFA_FFDoc::ImportData( - const CFX_RetainPtr& pStream, - bool bXDP) { - auto importer = - pdfium::MakeUnique(m_pDocumentParser->GetDocument()); - return importer->ImportData(pStream); -} diff --git a/xfa/fxfa/app/xfa_ffdochandler.cpp b/xfa/fxfa/app/xfa_ffdochandler.cpp deleted file mode 100644 index db73531ccc..0000000000 --- a/xfa/fxfa/app/xfa_ffdochandler.cpp +++ /dev/null @@ -1,60 +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 - -#include "xfa/fxfa/xfa_ffdochandler.h" - -#include "xfa/fxfa/parser/cxfa_scriptcontext.h" -#include "xfa/fxfa/parser/xfa_resolvenode_rs.h" -#include "xfa/fxfa/xfa_checksum.h" -#include "xfa/fxfa/xfa_ffdoc.h" - -CXFA_FFDocHandler::CXFA_FFDocHandler() {} - -CXFA_FFDocHandler::~CXFA_FFDocHandler() {} - -CFXJSE_Value* CXFA_FFDocHandler::GetXFAScriptObject(CXFA_FFDoc* hDoc) { - CXFA_Document* pXFADoc = hDoc->GetXFADoc(); - if (!pXFADoc) - return nullptr; - - CXFA_ScriptContext* pScriptContext = pXFADoc->GetScriptContext(); - if (!pScriptContext) - return nullptr; - return pScriptContext->GetJSValueFromMap(pXFADoc->GetRoot()); -} - -XFA_ATTRIBUTEENUM CXFA_FFDocHandler::GetRestoreState(CXFA_FFDoc* hDoc) { - CXFA_Document* pXFADoc = hDoc->GetXFADoc(); - if (!pXFADoc) - return XFA_ATTRIBUTEENUM_Unknown; - - CXFA_Node* pForm = ToNode(pXFADoc->GetXFAObject(XFA_HASHCODE_Form)); - if (!pForm) - return XFA_ATTRIBUTEENUM_Unknown; - - CXFA_Node* pSubForm = pForm->GetFirstChildByClass(XFA_Element::Subform); - if (!pSubForm) - return XFA_ATTRIBUTEENUM_Unknown; - return pSubForm->GetEnum(XFA_ATTRIBUTE_RestoreState); -} - -bool CXFA_FFDocHandler::RunDocScript(CXFA_FFDoc* hDoc, - XFA_SCRIPTTYPE eScriptType, - const CFX_WideStringC& wsScript, - CFXJSE_Value* pRetValue, - CFXJSE_Value* pThisValue) { - CXFA_Document* pXFADoc = hDoc->GetXFADoc(); - if (!pXFADoc) - return false; - - CXFA_ScriptContext* pScriptContext = pXFADoc->GetScriptContext(); - if (!pScriptContext) - return false; - - return pScriptContext->RunScript( - (XFA_SCRIPTLANGTYPE)eScriptType, wsScript, pRetValue, - pThisValue ? CXFA_ScriptContext::ToObject(pThisValue, nullptr) : nullptr); -} diff --git a/xfa/fxfa/app/xfa_ffdocview.cpp b/xfa/fxfa/app/xfa_ffdocview.cpp deleted file mode 100644 index f4ea3afdd8..0000000000 --- a/xfa/fxfa/app/xfa_ffdocview.cpp +++ /dev/null @@ -1,836 +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 - -#include "xfa/fxfa/xfa_ffdocview.h" - -#include "core/fxcrt/fx_ext.h" -#include "third_party/base/ptr_util.h" -#include "third_party/base/stl_util.h" -#include "xfa/fxfa/app/xfa_ffbarcode.h" -#include "xfa/fxfa/app/xfa_ffcheckbutton.h" -#include "xfa/fxfa/app/xfa_ffchoicelist.h" -#include "xfa/fxfa/app/xfa_ffdraw.h" -#include "xfa/fxfa/app/xfa_ffexclgroup.h" -#include "xfa/fxfa/app/xfa_fffield.h" -#include "xfa/fxfa/app/xfa_ffimage.h" -#include "xfa/fxfa/app/xfa_ffimageedit.h" -#include "xfa/fxfa/app/xfa_ffpath.h" -#include "xfa/fxfa/app/xfa_ffpushbutton.h" -#include "xfa/fxfa/app/xfa_ffsignature.h" -#include "xfa/fxfa/app/xfa_ffsubform.h" -#include "xfa/fxfa/app/xfa_fftext.h" -#include "xfa/fxfa/app/xfa_fftextedit.h" -#include "xfa/fxfa/app/xfa_ffwidgetacc.h" -#include "xfa/fxfa/app/xfa_fwladapter.h" -#include "xfa/fxfa/parser/cxfa_binditems.h" -#include "xfa/fxfa/parser/cxfa_layoutprocessor.h" -#include "xfa/fxfa/parser/cxfa_scriptcontext.h" -#include "xfa/fxfa/parser/xfa_resolvenode_rs.h" -#include "xfa/fxfa/xfa_ffapp.h" -#include "xfa/fxfa/xfa_ffdoc.h" -#include "xfa/fxfa/xfa_ffpageview.h" -#include "xfa/fxfa/xfa_ffwidget.h" -#include "xfa/fxfa/xfa_ffwidgethandler.h" - -const XFA_ATTRIBUTEENUM gs_EventActivity[] = { - XFA_ATTRIBUTEENUM_Click, XFA_ATTRIBUTEENUM_Change, - XFA_ATTRIBUTEENUM_DocClose, XFA_ATTRIBUTEENUM_DocReady, - XFA_ATTRIBUTEENUM_Enter, XFA_ATTRIBUTEENUM_Exit, - XFA_ATTRIBUTEENUM_Full, XFA_ATTRIBUTEENUM_IndexChange, - XFA_ATTRIBUTEENUM_Initialize, XFA_ATTRIBUTEENUM_MouseDown, - XFA_ATTRIBUTEENUM_MouseEnter, XFA_ATTRIBUTEENUM_MouseExit, - XFA_ATTRIBUTEENUM_MouseUp, XFA_ATTRIBUTEENUM_PostExecute, - XFA_ATTRIBUTEENUM_PostOpen, XFA_ATTRIBUTEENUM_PostPrint, - XFA_ATTRIBUTEENUM_PostSave, XFA_ATTRIBUTEENUM_PostSign, - XFA_ATTRIBUTEENUM_PostSubmit, XFA_ATTRIBUTEENUM_PreExecute, - XFA_ATTRIBUTEENUM_PreOpen, XFA_ATTRIBUTEENUM_PrePrint, - XFA_ATTRIBUTEENUM_PreSave, XFA_ATTRIBUTEENUM_PreSign, - XFA_ATTRIBUTEENUM_PreSubmit, XFA_ATTRIBUTEENUM_Ready, - XFA_ATTRIBUTEENUM_Unknown, -}; - -CXFA_FFDocView::CXFA_FFDocView(CXFA_FFDoc* pDoc) - : m_bLayoutEvent(false), - m_pListFocusWidget(nullptr), - m_bInLayoutStatus(false), - m_pDoc(pDoc), - m_pXFADocLayout(nullptr), - m_pFocusAcc(nullptr), - m_pFocusWidget(nullptr), - m_pOldFocusWidget(nullptr), - m_iStatus(XFA_DOCVIEW_LAYOUTSTATUS_None), - m_iLock(0) {} - -CXFA_FFDocView::~CXFA_FFDocView() { - DestroyDocView(); -} - -void CXFA_FFDocView::InitLayout(CXFA_Node* pNode) { - RunBindItems(); - ExecEventActivityByDeepFirst(pNode, XFA_EVENT_Initialize, false, true, - nullptr); - ExecEventActivityByDeepFirst(pNode, XFA_EVENT_IndexChange, false, true, - nullptr); -} -int32_t CXFA_FFDocView::StartLayout(int32_t iStartPage) { - m_iStatus = XFA_DOCVIEW_LAYOUTSTATUS_Start; - m_pDoc->GetXFADoc()->DoProtoMerge(); - m_pDoc->GetXFADoc()->DoDataMerge(); - m_pXFADocLayout = GetXFALayout(); - int32_t iStatus = m_pXFADocLayout->StartLayout(); - if (iStatus < 0) { - return iStatus; - } - CXFA_Node* pRootItem = - ToNode(m_pDoc->GetXFADoc()->GetXFAObject(XFA_HASHCODE_Form)); - if (!pRootItem) { - return iStatus; - } - InitLayout(pRootItem); - InitCalculate(pRootItem); - InitValidate(pRootItem); - ExecEventActivityByDeepFirst(pRootItem, XFA_EVENT_Ready, true, true, nullptr); - m_iStatus = XFA_DOCVIEW_LAYOUTSTATUS_Start; - return iStatus; -} -int32_t CXFA_FFDocView::DoLayout(IFX_Pause* pPause) { - int32_t iStatus = 100; - iStatus = m_pXFADocLayout->DoLayout(pPause); - if (iStatus != 100) { - return iStatus; - } - m_iStatus = XFA_DOCVIEW_LAYOUTSTATUS_Doing; - return iStatus; -} -void CXFA_FFDocView::StopLayout() { - CXFA_Node* pRootItem = - ToNode(m_pDoc->GetXFADoc()->GetXFAObject(XFA_HASHCODE_Form)); - if (!pRootItem) { - return; - } - CXFA_Node* pSubformNode = pRootItem->GetChild(0, XFA_Element::Subform); - if (!pSubformNode) { - return; - } - CXFA_Node* pPageSetNode = - pSubformNode->GetFirstChildByClass(XFA_Element::PageSet); - if (!pPageSetNode) { - return; - } - RunCalculateWidgets(); - RunValidate(); - InitLayout(pPageSetNode); - InitCalculate(pPageSetNode); - InitValidate(pPageSetNode); - ExecEventActivityByDeepFirst(pPageSetNode, XFA_EVENT_Ready, true, true, - nullptr); - ExecEventActivityByDeepFirst(pRootItem, XFA_EVENT_Ready, false, true, - nullptr); - ExecEventActivityByDeepFirst(pRootItem, XFA_EVENT_DocReady, false, true, - nullptr); - RunCalculateWidgets(); - RunValidate(); - if (RunLayout()) { - ExecEventActivityByDeepFirst(pRootItem, XFA_EVENT_Ready, false, true, - nullptr); - } - m_CalculateAccs.clear(); - if (m_pFocusAcc && !m_pFocusWidget) { - SetFocusWidgetAcc(m_pFocusAcc); - } - m_iStatus = XFA_DOCVIEW_LAYOUTSTATUS_End; -} -int32_t CXFA_FFDocView::GetLayoutStatus() { - return m_iStatus; -} -void CXFA_FFDocView::ShowNullTestMsg() { - int32_t iCount = pdfium::CollectionSize(m_arrNullTestMsg); - CXFA_FFApp* pApp = m_pDoc->GetApp(); - IXFA_AppProvider* pAppProvider = pApp->GetAppProvider(); - if (pAppProvider && iCount) { - int32_t iRemain = iCount > 7 ? iCount - 7 : 0; - iCount -= iRemain; - CFX_WideString wsMsg; - for (int32_t i = 0; i < iCount; i++) { - wsMsg += m_arrNullTestMsg[i] + L"\n"; - } - if (iRemain > 0) { - CFX_WideString wsTemp; - wsTemp.Format( - L"Message limit exceeded. Remaining %d " - L"validation errors not reported.", - iRemain); - wsMsg += L"\n" + wsTemp; - } - pAppProvider->MsgBox(wsMsg, pAppProvider->GetAppTitle(), XFA_MBICON_Status, - XFA_MB_OK); - } - m_arrNullTestMsg.clear(); -} - -void CXFA_FFDocView::UpdateDocView() { - if (IsUpdateLocked()) - return; - - LockUpdate(); - for (CXFA_Node* pNode : m_NewAddedNodes) { - InitCalculate(pNode); - InitValidate(pNode); - ExecEventActivityByDeepFirst(pNode, XFA_EVENT_Ready, true, true, nullptr); - } - m_NewAddedNodes.clear(); - RunSubformIndexChange(); - RunCalculateWidgets(); - RunValidate(); - ShowNullTestMsg(); - if (RunLayout() && m_bLayoutEvent) - RunEventLayoutReady(); - - m_bLayoutEvent = false; - m_CalculateAccs.clear(); - RunInvalidate(); - UnlockUpdate(); -} - -int32_t CXFA_FFDocView::CountPageViews() { - if (!m_pXFADocLayout) { - return 0; - } - return m_pXFADocLayout->CountPages(); -} -CXFA_FFPageView* CXFA_FFDocView::GetPageView(int32_t nIndex) { - if (!m_pXFADocLayout) { - return nullptr; - } - return static_cast(m_pXFADocLayout->GetPage(nIndex)); -} - -CXFA_LayoutProcessor* CXFA_FFDocView::GetXFALayout() const { - return m_pDoc->GetXFADoc()->GetDocLayout(); -} -bool CXFA_FFDocView::ResetSingleWidgetAccData(CXFA_WidgetAcc* pWidgetAcc) { - CXFA_Node* pNode = pWidgetAcc->GetNode(); - XFA_Element eType = pNode->GetElementType(); - if (eType != XFA_Element::Field && eType != XFA_Element::ExclGroup) { - return false; - } - pWidgetAcc->ResetData(); - pWidgetAcc->UpdateUIDisplay(); - if (CXFA_Validate validate = pWidgetAcc->GetValidate()) { - AddValidateWidget(pWidgetAcc); - validate.GetNode()->SetFlag(XFA_NodeFlag_NeedsInitApp, false); - } - return true; -} -void CXFA_FFDocView::ResetWidgetData(CXFA_WidgetAcc* pWidgetAcc) { - m_bLayoutEvent = true; - bool bChanged = false; - CXFA_Node* pFormNode = nullptr; - if (pWidgetAcc) { - bChanged = ResetSingleWidgetAccData(pWidgetAcc); - pFormNode = pWidgetAcc->GetNode(); - } else { - pFormNode = GetRootSubform(); - } - if (!pFormNode) { - return; - } - if (pFormNode->GetElementType() != XFA_Element::Field && - pFormNode->GetElementType() != XFA_Element::ExclGroup) { - CXFA_WidgetAccIterator Iterator(this, pFormNode); - while (CXFA_WidgetAcc* pAcc = Iterator.MoveToNext()) { - bChanged |= ResetSingleWidgetAccData(pAcc); - if (pAcc->GetNode()->GetElementType() == XFA_Element::ExclGroup) { - Iterator.SkipTree(); - } - } - } - if (bChanged) { - m_pDoc->GetDocEnvironment()->SetChangeMark(m_pDoc); - } -} -int32_t CXFA_FFDocView::ProcessWidgetEvent(CXFA_EventParam* pParam, - CXFA_WidgetAcc* pWidgetAcc) { - if (!pParam) - return XFA_EVENTERROR_Error; - - if (pParam->m_eType == XFA_EVENT_Validate) { - CFX_WideString wsValidateStr(L"preSubmit"); - CXFA_Node* pConfigItem = - ToNode(m_pDoc->GetXFADoc()->GetXFAObject(XFA_HASHCODE_Config)); - if (pConfigItem) { - CXFA_Node* pValidateNode = nullptr; - CXFA_Node* pAcrobatNode = pConfigItem->GetChild(0, XFA_Element::Acrobat); - pValidateNode = pAcrobatNode - ? pAcrobatNode->GetChild(0, XFA_Element::Validate) - : nullptr; - if (!pValidateNode) { - CXFA_Node* pPresentNode = - pConfigItem->GetChild(0, XFA_Element::Present); - pValidateNode = pPresentNode - ? pPresentNode->GetChild(0, XFA_Element::Validate) - : nullptr; - } - if (pValidateNode) - wsValidateStr = pValidateNode->GetContent(); - } - - if (wsValidateStr.Find(L"preSubmit") == -1) - return XFA_EVENTERROR_Success; - } - - CXFA_Node* pNode = pWidgetAcc ? pWidgetAcc->GetNode() : nullptr; - if (!pNode) { - CXFA_Node* pRootItem = - ToNode(m_pDoc->GetXFADoc()->GetXFAObject(XFA_HASHCODE_Form)); - if (!pRootItem) - return XFA_EVENTERROR_Error; - - pNode = pRootItem->GetChild(0, XFA_Element::Subform); - } - ExecEventActivityByDeepFirst(pNode, pParam->m_eType, pParam->m_bIsFormReady, - true, nullptr); - return XFA_EVENTERROR_Success; -} - -CXFA_FFWidgetHandler* CXFA_FFDocView::GetWidgetHandler() { - if (!m_pWidgetHandler) - m_pWidgetHandler = pdfium::MakeUnique(this); - - return m_pWidgetHandler.get(); -} - -CXFA_WidgetAccIterator* CXFA_FFDocView::CreateWidgetAccIterator( - XFA_WIDGETORDER eOrder) { - CXFA_Node* pFormRoot = GetRootSubform(); - return pFormRoot ? new CXFA_WidgetAccIterator(this, pFormRoot) : nullptr; -} -CXFA_FFWidget* CXFA_FFDocView::GetFocusWidget() { - return m_pFocusWidget; -} -void CXFA_FFDocView::KillFocus() { - if (m_pFocusWidget && - (m_pFocusWidget->GetStatus() & XFA_WidgetStatus_Focused)) { - (m_pFocusWidget)->OnKillFocus(nullptr); - } - m_pFocusAcc = nullptr; - m_pFocusWidget = nullptr; - m_pOldFocusWidget = nullptr; -} -bool CXFA_FFDocView::SetFocus(CXFA_FFWidget* hWidget) { - CXFA_FFWidget* pNewFocus = hWidget; - if (m_pOldFocusWidget == pNewFocus) { - return false; - } - CXFA_FFWidget* pOldFocus = m_pOldFocusWidget; - m_pOldFocusWidget = pNewFocus; - if (pOldFocus) { - if (m_pFocusWidget != m_pOldFocusWidget && - (pOldFocus->GetStatus() & XFA_WidgetStatus_Focused)) { - m_pFocusWidget = pOldFocus; - pOldFocus->OnKillFocus(pNewFocus); - } else if ((pOldFocus->GetStatus() & XFA_WidgetStatus_Visible)) { - if (!pOldFocus->IsLoaded()) { - pOldFocus->LoadWidget(); - } - pOldFocus->OnSetFocus(m_pFocusWidget); - m_pFocusWidget = pOldFocus; - pOldFocus->OnKillFocus(pNewFocus); - } - } - if (m_pFocusWidget == m_pOldFocusWidget) { - return false; - } - pNewFocus = m_pOldFocusWidget; - if (m_pListFocusWidget && pNewFocus == m_pListFocusWidget) { - m_pFocusAcc = nullptr; - m_pFocusWidget = nullptr; - m_pListFocusWidget = nullptr; - m_pOldFocusWidget = nullptr; - return false; - } - if (pNewFocus && (pNewFocus->GetStatus() & XFA_WidgetStatus_Visible)) { - if (!pNewFocus->IsLoaded()) { - pNewFocus->LoadWidget(); - } - pNewFocus->OnSetFocus(m_pFocusWidget); - } - m_pFocusAcc = pNewFocus ? pNewFocus->GetDataAcc() : nullptr; - m_pFocusWidget = pNewFocus; - m_pOldFocusWidget = m_pFocusWidget; - return true; -} -CXFA_WidgetAcc* CXFA_FFDocView::GetFocusWidgetAcc() { - return m_pFocusAcc; -} -void CXFA_FFDocView::SetFocusWidgetAcc(CXFA_WidgetAcc* pWidgetAcc) { - CXFA_FFWidget* pNewFocus = - pWidgetAcc ? pWidgetAcc->GetNextWidget(nullptr) : nullptr; - if (SetFocus(pNewFocus)) { - m_pFocusAcc = pWidgetAcc; - if (m_iStatus == XFA_DOCVIEW_LAYOUTSTATUS_End) { - m_pDoc->GetDocEnvironment()->SetFocusWidget(m_pDoc, m_pFocusWidget); - } - } -} -void CXFA_FFDocView::DeleteLayoutItem(CXFA_FFWidget* pWidget) { - if (m_pFocusAcc == pWidget->GetDataAcc()) { - m_pFocusAcc = nullptr; - m_pFocusWidget = nullptr; - m_pOldFocusWidget = nullptr; - } -} -static int32_t XFA_ProcessEvent(CXFA_FFDocView* pDocView, - CXFA_WidgetAcc* pWidgetAcc, - CXFA_EventParam* pParam) { - if (!pParam || pParam->m_eType == XFA_EVENT_Unknown) { - return XFA_EVENTERROR_NotExist; - } - if (!pWidgetAcc || pWidgetAcc->GetElementType() == XFA_Element::Draw) { - return XFA_EVENTERROR_NotExist; - } - switch (pParam->m_eType) { - case XFA_EVENT_Calculate: - return pWidgetAcc->ProcessCalculate(); - case XFA_EVENT_Validate: - if (((CXFA_FFDoc*)pDocView->GetDoc()) - ->GetDocEnvironment() - ->IsValidationsEnabled(pDocView->GetDoc())) { - return pWidgetAcc->ProcessValidate(0x01); - } - return XFA_EVENTERROR_Disabled; - case XFA_EVENT_InitCalculate: { - CXFA_Calculate calc = pWidgetAcc->GetCalculate(); - if (!calc) { - return XFA_EVENTERROR_NotExist; - } - if (pWidgetAcc->GetNode()->IsUserInteractive()) - return XFA_EVENTERROR_Disabled; - - CXFA_Script script = calc.GetScript(); - return pWidgetAcc->ExecuteScript(script, pParam); - } - default: - break; - } - int32_t iRet = - pWidgetAcc->ProcessEvent(gs_EventActivity[pParam->m_eType], pParam); - return iRet; -} -int32_t CXFA_FFDocView::ExecEventActivityByDeepFirst(CXFA_Node* pFormNode, - XFA_EVENTTYPE eEventType, - bool bIsFormReady, - bool bRecursive, - CXFA_Node* pExclude) { - int32_t iRet = XFA_EVENTERROR_NotExist; - if (pFormNode == pExclude) { - return iRet; - } - XFA_Element elementType = pFormNode->GetElementType(); - if (elementType == XFA_Element::Field) { - if (eEventType == XFA_EVENT_IndexChange) { - return iRet; - } - CXFA_WidgetAcc* pWidgetAcc = (CXFA_WidgetAcc*)pFormNode->GetWidgetData(); - if (!pWidgetAcc) { - return iRet; - } - CXFA_EventParam eParam; - eParam.m_eType = eEventType; - eParam.m_pTarget = pWidgetAcc; - eParam.m_bIsFormReady = bIsFormReady; - return XFA_ProcessEvent(this, pWidgetAcc, &eParam); - } - if (bRecursive) { - for (CXFA_Node* pNode = pFormNode->GetNodeItem( - XFA_NODEITEM_FirstChild, XFA_ObjectType::ContainerNode); - pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling, - XFA_ObjectType::ContainerNode)) { - elementType = pNode->GetElementType(); - if (elementType != XFA_Element::Variables && - elementType != XFA_Element::Draw) { - iRet |= ExecEventActivityByDeepFirst(pNode, eEventType, bIsFormReady, - bRecursive, pExclude); - } - } - } - CXFA_WidgetAcc* pWidgetAcc = (CXFA_WidgetAcc*)pFormNode->GetWidgetData(); - if (!pWidgetAcc) { - return iRet; - } - CXFA_EventParam eParam; - eParam.m_eType = eEventType; - eParam.m_pTarget = pWidgetAcc; - eParam.m_bIsFormReady = bIsFormReady; - iRet |= XFA_ProcessEvent(this, pWidgetAcc, &eParam); - return iRet; -} - -CXFA_FFWidget* CXFA_FFDocView::GetWidgetByName(const CFX_WideString& wsName, - CXFA_FFWidget* pRefWidget) { - CXFA_WidgetAcc* pRefAcc = pRefWidget ? pRefWidget->GetDataAcc() : nullptr; - CXFA_WidgetAcc* pAcc = GetWidgetAccByName(wsName, pRefAcc); - return pAcc ? pAcc->GetNextWidget(nullptr) : nullptr; -} - -CXFA_WidgetAcc* CXFA_FFDocView::GetWidgetAccByName( - const CFX_WideString& wsName, - CXFA_WidgetAcc* pRefWidgetAcc) { - CFX_WideString wsExpression; - uint32_t dwStyle = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties | - XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_Parent; - CXFA_ScriptContext* pScriptContext = m_pDoc->GetXFADoc()->GetScriptContext(); - if (!pScriptContext) { - return nullptr; - } - CXFA_Node* refNode = nullptr; - if (pRefWidgetAcc) { - refNode = pRefWidgetAcc->GetNode(); - wsExpression = wsName; - } else { - wsExpression = L"$form." + wsName; - } - XFA_RESOLVENODE_RS resoveNodeRS; - int32_t iRet = pScriptContext->ResolveObjects( - refNode, wsExpression.AsStringC(), resoveNodeRS, dwStyle); - if (iRet < 1) { - return nullptr; - } - if (resoveNodeRS.dwFlags == XFA_RESOVENODE_RSTYPE_Nodes) { - CXFA_Node* pNode = resoveNodeRS.objects.front()->AsNode(); - if (pNode) - return static_cast(pNode->GetWidgetData()); - } - return nullptr; -} - -void CXFA_FFDocView::OnPageEvent(CXFA_ContainerLayoutItem* pSender, - uint32_t dwEvent) { - CXFA_FFPageView* pFFPageView = static_cast(pSender); - m_pDoc->GetDocEnvironment()->PageViewEvent(pFFPageView, dwEvent); -} - -void CXFA_FFDocView::LockUpdate() { - m_iLock++; -} -void CXFA_FFDocView::UnlockUpdate() { - m_iLock--; -} -bool CXFA_FFDocView::IsUpdateLocked() { - return m_iLock > 0; -} -void CXFA_FFDocView::ClearInvalidateList() { - m_mapPageInvalidate.clear(); -} -void CXFA_FFDocView::AddInvalidateRect(CXFA_FFWidget* pWidget, - const CFX_RectF& rtInvalidate) { - AddInvalidateRect(pWidget->GetPageView(), rtInvalidate); -} - -void CXFA_FFDocView::AddInvalidateRect(CXFA_FFPageView* pPageView, - const CFX_RectF& rtInvalidate) { - if (m_mapPageInvalidate[pPageView]) { - m_mapPageInvalidate[pPageView]->Union(rtInvalidate); - return; - } - m_mapPageInvalidate[pPageView] = pdfium::MakeUnique(rtInvalidate); -} - -void CXFA_FFDocView::RunInvalidate() { - for (const auto& pair : m_mapPageInvalidate) - m_pDoc->GetDocEnvironment()->InvalidateRect(pair.first, *pair.second); - m_mapPageInvalidate.clear(); -} - -bool CXFA_FFDocView::RunLayout() { - LockUpdate(); - m_bInLayoutStatus = true; - if (!m_pXFADocLayout->IncrementLayout() && - m_pXFADocLayout->StartLayout() < 100) { - m_pXFADocLayout->DoLayout(); - UnlockUpdate(); - m_bInLayoutStatus = false; - m_pDoc->GetDocEnvironment()->PageViewEvent(nullptr, - XFA_PAGEVIEWEVENT_StopLayout); - return true; - } - m_bInLayoutStatus = false; - m_pDoc->GetDocEnvironment()->PageViewEvent(nullptr, - XFA_PAGEVIEWEVENT_StopLayout); - UnlockUpdate(); - return false; -} - -void CXFA_FFDocView::RunSubformIndexChange() { - for (CXFA_Node* pSubformNode : m_IndexChangedSubforms) { - CXFA_WidgetAcc* pWidgetAcc = - static_cast(pSubformNode->GetWidgetData()); - if (!pWidgetAcc) - continue; - - CXFA_EventParam eParam; - eParam.m_eType = XFA_EVENT_IndexChange; - eParam.m_pTarget = pWidgetAcc; - pWidgetAcc->ProcessEvent(XFA_ATTRIBUTEENUM_IndexChange, &eParam); - } - m_IndexChangedSubforms.clear(); -} - -void CXFA_FFDocView::AddNewFormNode(CXFA_Node* pNode) { - m_NewAddedNodes.push_back(pNode); - InitLayout(pNode); -} - -void CXFA_FFDocView::AddIndexChangedSubform(CXFA_Node* pNode) { - ASSERT(pNode->GetElementType() == XFA_Element::Subform); - m_IndexChangedSubforms.push_back(pNode); -} - -void CXFA_FFDocView::RunDocClose() { - CXFA_Node* pRootItem = - ToNode(m_pDoc->GetXFADoc()->GetXFAObject(XFA_HASHCODE_Form)); - if (!pRootItem) { - return; - } - ExecEventActivityByDeepFirst(pRootItem, XFA_EVENT_DocClose, false, true, - nullptr); -} - -void CXFA_FFDocView::DestroyDocView() { - ClearInvalidateList(); - m_iStatus = XFA_DOCVIEW_LAYOUTSTATUS_None; - m_iLock = 0; - m_ValidateAccs.clear(); - m_BindItems.clear(); - m_CalculateAccs.clear(); -} - -bool CXFA_FFDocView::IsStaticNotify() { - return m_pDoc->GetDocType() == XFA_DocType::Static; -} - -void CXFA_FFDocView::AddCalculateWidgetAcc(CXFA_WidgetAcc* pWidgetAcc) { - CXFA_WidgetAcc* pCurrentAcc = - !m_CalculateAccs.empty() ? m_CalculateAccs.back() : nullptr; - if (pCurrentAcc != pWidgetAcc) - m_CalculateAccs.push_back(pWidgetAcc); -} - -void CXFA_FFDocView::AddCalculateNodeNotify(CXFA_Node* pNodeChange) { - auto* pGlobalData = - static_cast(pNodeChange->GetUserData(XFA_CalcData)); - if (!pGlobalData) - return; - - for (auto* pResultAcc : pGlobalData->m_Globals) { - if (!pResultAcc->GetNode()->HasRemovedChildren()) - AddCalculateWidgetAcc(pResultAcc); - } -} - -void CXFA_FFDocView::RunCalculateRecursive(int32_t& iIndex) { - while (iIndex < pdfium::CollectionSize(m_CalculateAccs)) { - CXFA_WidgetAcc* pCurAcc = m_CalculateAccs[iIndex]; - AddCalculateNodeNotify(pCurAcc->GetNode()); - int32_t iRefCount = - (int32_t)(uintptr_t)pCurAcc->GetNode()->GetUserData(XFA_CalcRefCount); - iRefCount++; - pCurAcc->GetNode()->SetUserData(XFA_CalcRefCount, - (void*)(uintptr_t)iRefCount); - if (iRefCount > 11) { - break; - } - if ((pCurAcc->ProcessCalculate()) == XFA_EVENTERROR_Success) { - AddValidateWidget(pCurAcc); - } - iIndex++; - RunCalculateRecursive(iIndex); - } -} - -int32_t CXFA_FFDocView::RunCalculateWidgets() { - if (!m_pDoc->GetDocEnvironment()->IsCalculationsEnabled(m_pDoc)) { - return XFA_EVENTERROR_Disabled; - } - int32_t iCounts = pdfium::CollectionSize(m_CalculateAccs); - int32_t iIndex = 0; - if (iCounts > 0) - RunCalculateRecursive(iIndex); - - for (CXFA_WidgetAcc* pCurAcc : m_CalculateAccs) - pCurAcc->GetNode()->SetUserData(XFA_CalcRefCount, (void*)(uintptr_t)0); - - m_CalculateAccs.clear(); - return XFA_EVENTERROR_Success; -} - -void CXFA_FFDocView::AddValidateWidget(CXFA_WidgetAcc* pWidget) { - if (!pdfium::ContainsValue(m_ValidateAccs, pWidget)) - m_ValidateAccs.push_back(pWidget); -} - -bool CXFA_FFDocView::InitCalculate(CXFA_Node* pNode) { - ExecEventActivityByDeepFirst(pNode, XFA_EVENT_InitCalculate, false, true, - nullptr); - return true; -} - -bool CXFA_FFDocView::InitValidate(CXFA_Node* pNode) { - if (!m_pDoc->GetDocEnvironment()->IsValidationsEnabled(m_pDoc)) - return false; - - ExecEventActivityByDeepFirst(pNode, XFA_EVENT_Validate, false, true, nullptr); - m_ValidateAccs.clear(); - return true; -} - -bool CXFA_FFDocView::RunValidate() { - if (!m_pDoc->GetDocEnvironment()->IsValidationsEnabled(m_pDoc)) - return false; - - for (CXFA_WidgetAcc* pAcc : m_ValidateAccs) { - if (!pAcc->GetNode()->HasRemovedChildren()) - pAcc->ProcessValidate(); - } - m_ValidateAccs.clear(); - return true; -} -bool CXFA_FFDocView::RunEventLayoutReady() { - CXFA_Node* pRootItem = - ToNode(m_pDoc->GetXFADoc()->GetXFAObject(XFA_HASHCODE_Form)); - if (!pRootItem) { - return false; - } - ExecEventActivityByDeepFirst(pRootItem, XFA_EVENT_Ready, false, true, - nullptr); - RunLayout(); - return true; -} - -void CXFA_FFDocView::RunBindItems() { - for (auto* item : m_BindItems) { - if (item->HasRemovedChildren()) - continue; - - CXFA_Node* pWidgetNode = item->GetNodeItem(XFA_NODEITEM_Parent); - CXFA_WidgetAcc* pAcc = - static_cast(pWidgetNode->GetWidgetData()); - if (!pAcc) - continue; - - CXFA_BindItems binditems(item); - CXFA_ScriptContext* pScriptContext = - pWidgetNode->GetDocument()->GetScriptContext(); - CFX_WideStringC wsRef; - binditems.GetRef(wsRef); - uint32_t dwStyle = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties | - XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_Parent | - XFA_RESOLVENODE_ALL; - XFA_RESOLVENODE_RS rs; - pScriptContext->ResolveObjects(pWidgetNode, wsRef, rs, dwStyle); - pAcc->DeleteItem(-1); - if (rs.dwFlags != XFA_RESOVENODE_RSTYPE_Nodes || rs.objects.empty()) - continue; - - CFX_WideStringC wsValueRef, wsLabelRef; - binditems.GetValueRef(wsValueRef); - binditems.GetLabelRef(wsLabelRef); - const bool bUseValue = wsLabelRef.IsEmpty() || wsLabelRef == wsValueRef; - const bool bLabelUseContent = wsLabelRef.IsEmpty() || wsLabelRef == L"$"; - const bool bValueUseContent = wsValueRef.IsEmpty() || wsValueRef == L"$"; - CFX_WideString wsValue; - CFX_WideString wsLabel; - uint32_t uValueHash = FX_HashCode_GetW(wsValueRef, false); - for (CXFA_Object* refObject : rs.objects) { - CXFA_Node* refNode = refObject->AsNode(); - if (!refNode) - continue; - if (bValueUseContent) { - wsValue = refNode->GetContent(); - } else { - CXFA_Node* nodeValue = refNode->GetFirstChildByName(uValueHash); - wsValue = nodeValue ? nodeValue->GetContent() : refNode->GetContent(); - } - if (!bUseValue) { - if (bLabelUseContent) { - wsLabel = refNode->GetContent(); - } else { - CXFA_Node* nodeLabel = refNode->GetFirstChildByName(wsLabelRef); - if (nodeLabel) - wsLabel = nodeLabel->GetContent(); - } - } else { - wsLabel = wsValue; - } - pAcc->InsertItem(wsLabel, wsValue); - } - } - m_BindItems.clear(); -} - -void CXFA_FFDocView::SetChangeMark() { - if (m_iStatus < XFA_DOCVIEW_LAYOUTSTATUS_End) { - return; - } - m_pDoc->GetDocEnvironment()->SetChangeMark(m_pDoc); -} -CXFA_Node* CXFA_FFDocView::GetRootSubform() { - CXFA_Node* pFormPacketNode = - ToNode(m_pDoc->GetXFADoc()->GetXFAObject(XFA_HASHCODE_Form)); - if (!pFormPacketNode) { - return nullptr; - } - return pFormPacketNode->GetFirstChildByClass(XFA_Element::Subform); -} - -CXFA_WidgetAccIterator::CXFA_WidgetAccIterator(CXFA_FFDocView* pDocView, - CXFA_Node* pTravelRoot) - : m_ContentIterator(pTravelRoot), - m_pDocView(pDocView), - m_pCurWidgetAcc(nullptr) {} - -CXFA_WidgetAccIterator::~CXFA_WidgetAccIterator() {} -void CXFA_WidgetAccIterator::Reset() { - m_pCurWidgetAcc = nullptr; - m_ContentIterator.Reset(); -} - -CXFA_WidgetAcc* CXFA_WidgetAccIterator::MoveToFirst() { - return nullptr; -} - -CXFA_WidgetAcc* CXFA_WidgetAccIterator::MoveToLast() { - return nullptr; -} - -CXFA_WidgetAcc* CXFA_WidgetAccIterator::MoveToNext() { - CXFA_Node* pItem = m_pCurWidgetAcc ? m_ContentIterator.MoveToNext() - : m_ContentIterator.GetCurrent(); - while (pItem) { - m_pCurWidgetAcc = static_cast(pItem->GetWidgetData()); - if (m_pCurWidgetAcc) - return m_pCurWidgetAcc; - pItem = m_ContentIterator.MoveToNext(); - } - return nullptr; -} - -CXFA_WidgetAcc* CXFA_WidgetAccIterator::MoveToPrevious() { - return nullptr; -} - -CXFA_WidgetAcc* CXFA_WidgetAccIterator::GetCurrentWidgetAcc() { - return nullptr; -} - -bool CXFA_WidgetAccIterator::SetCurrentWidgetAcc(CXFA_WidgetAcc* hWidget) { - return false; -} - -void CXFA_WidgetAccIterator::SkipTree() { - m_ContentIterator.SkipChildrenAndMoveToNext(); - m_pCurWidgetAcc = nullptr; -} diff --git a/xfa/fxfa/app/xfa_ffdraw.cpp b/xfa/fxfa/app/xfa_ffdraw.cpp index 37095ddb49..8742b83c5b 100644 --- a/xfa/fxfa/app/xfa_ffdraw.cpp +++ b/xfa/fxfa/app/xfa_ffdraw.cpp @@ -6,10 +6,10 @@ #include "xfa/fxfa/app/xfa_ffdraw.h" -#include "xfa/fxfa/xfa_ffapp.h" -#include "xfa/fxfa/xfa_ffdoc.h" -#include "xfa/fxfa/xfa_ffpageview.h" -#include "xfa/fxfa/xfa_ffwidget.h" +#include "xfa/fxfa/cxfa_ffapp.h" +#include "xfa/fxfa/cxfa_ffdoc.h" +#include "xfa/fxfa/cxfa_ffpageview.h" +#include "xfa/fxfa/cxfa_ffwidget.h" CXFA_FFDraw::CXFA_FFDraw(CXFA_WidgetAcc* pDataAcc) : CXFA_FFWidget(pDataAcc) {} diff --git a/xfa/fxfa/app/xfa_ffdraw.h b/xfa/fxfa/app/xfa_ffdraw.h index 0212dcca0a..bcd74f204c 100644 --- a/xfa/fxfa/app/xfa_ffdraw.h +++ b/xfa/fxfa/app/xfa_ffdraw.h @@ -7,8 +7,8 @@ #ifndef XFA_FXFA_APP_XFA_FFDRAW_H_ #define XFA_FXFA_APP_XFA_FFDRAW_H_ -#include "xfa/fxfa/xfa_ffpageview.h" -#include "xfa/fxfa/xfa_ffwidget.h" +#include "xfa/fxfa/cxfa_ffpageview.h" +#include "xfa/fxfa/cxfa_ffwidget.h" class CXFA_FFDraw : public CXFA_FFWidget { public: diff --git a/xfa/fxfa/app/xfa_ffexclgroup.cpp b/xfa/fxfa/app/xfa_ffexclgroup.cpp index 7d63daddbc..9f2560f82f 100644 --- a/xfa/fxfa/app/xfa_ffexclgroup.cpp +++ b/xfa/fxfa/app/xfa_ffexclgroup.cpp @@ -6,10 +6,10 @@ #include "xfa/fxfa/app/xfa_ffexclgroup.h" -#include "xfa/fxfa/xfa_ffapp.h" -#include "xfa/fxfa/xfa_ffdoc.h" -#include "xfa/fxfa/xfa_ffpageview.h" -#include "xfa/fxfa/xfa_ffwidget.h" +#include "xfa/fxfa/cxfa_ffapp.h" +#include "xfa/fxfa/cxfa_ffdoc.h" +#include "xfa/fxfa/cxfa_ffpageview.h" +#include "xfa/fxfa/cxfa_ffwidget.h" CXFA_FFExclGroup::CXFA_FFExclGroup(CXFA_WidgetAcc* pDataAcc) : CXFA_FFWidget(pDataAcc) {} diff --git a/xfa/fxfa/app/xfa_ffexclgroup.h b/xfa/fxfa/app/xfa_ffexclgroup.h index 12a13aea92..a14894566c 100644 --- a/xfa/fxfa/app/xfa_ffexclgroup.h +++ b/xfa/fxfa/app/xfa_ffexclgroup.h @@ -7,8 +7,8 @@ #ifndef XFA_FXFA_APP_XFA_FFEXCLGROUP_H_ #define XFA_FXFA_APP_XFA_FFEXCLGROUP_H_ -#include "xfa/fxfa/xfa_ffpageview.h" -#include "xfa/fxfa/xfa_ffwidget.h" +#include "xfa/fxfa/cxfa_ffpageview.h" +#include "xfa/fxfa/cxfa_ffwidget.h" class CXFA_FFExclGroup : public CXFA_FFWidget { public: diff --git a/xfa/fxfa/app/xfa_fffield.cpp b/xfa/fxfa/app/xfa_fffield.cpp index 06763be094..39109f5f28 100644 --- a/xfa/fxfa/app/xfa_fffield.cpp +++ b/xfa/fxfa/app/xfa_fffield.cpp @@ -17,11 +17,11 @@ #include "xfa/fwl/cfwl_widgetmgr.h" #include "xfa/fxfa/app/cxfa_textlayout.h" #include "xfa/fxfa/app/xfa_fwltheme.h" -#include "xfa/fxfa/xfa_ffapp.h" -#include "xfa/fxfa/xfa_ffdoc.h" -#include "xfa/fxfa/xfa_ffdocview.h" -#include "xfa/fxfa/xfa_ffpageview.h" -#include "xfa/fxfa/xfa_ffwidget.h" +#include "xfa/fxfa/cxfa_ffapp.h" +#include "xfa/fxfa/cxfa_ffdoc.h" +#include "xfa/fxfa/cxfa_ffdocview.h" +#include "xfa/fxfa/cxfa_ffpageview.h" +#include "xfa/fxfa/cxfa_ffwidget.h" #include "xfa/fxgraphics/cfx_color.h" #include "xfa/fxgraphics/cfx_path.h" diff --git a/xfa/fxfa/app/xfa_fffield.h b/xfa/fxfa/app/xfa_fffield.h index f10ce61738..0e9ac8661c 100644 --- a/xfa/fxfa/app/xfa_fffield.h +++ b/xfa/fxfa/app/xfa_fffield.h @@ -9,8 +9,8 @@ #include "xfa/fwl/cfwl_widget.h" #include "xfa/fwl/ifwl_widgetdelegate.h" -#include "xfa/fxfa/xfa_ffpageview.h" -#include "xfa/fxfa/xfa_ffwidget.h" +#include "xfa/fxfa/cxfa_ffpageview.h" +#include "xfa/fxfa/cxfa_ffwidget.h" #define XFA_MINUI_HEIGHT 4.32f #define XFA_DEFAULTUI_HEIGHT 2.0f diff --git a/xfa/fxfa/app/xfa_ffimage.cpp b/xfa/fxfa/app/xfa_ffimage.cpp index a613221ea6..81188c14d1 100644 --- a/xfa/fxfa/app/xfa_ffimage.cpp +++ b/xfa/fxfa/app/xfa_ffimage.cpp @@ -7,10 +7,10 @@ #include "xfa/fxfa/app/xfa_ffimage.h" #include "xfa/fxfa/app/xfa_ffdraw.h" -#include "xfa/fxfa/xfa_ffapp.h" -#include "xfa/fxfa/xfa_ffdoc.h" -#include "xfa/fxfa/xfa_ffpageview.h" -#include "xfa/fxfa/xfa_ffwidget.h" +#include "xfa/fxfa/cxfa_ffapp.h" +#include "xfa/fxfa/cxfa_ffdoc.h" +#include "xfa/fxfa/cxfa_ffpageview.h" +#include "xfa/fxfa/cxfa_ffwidget.h" CXFA_FFImage::CXFA_FFImage(CXFA_WidgetAcc* pDataAcc) : CXFA_FFDraw(pDataAcc) {} diff --git a/xfa/fxfa/app/xfa_ffimageedit.cpp b/xfa/fxfa/app/xfa_ffimageedit.cpp index 01d29eed41..b776579152 100644 --- a/xfa/fxfa/app/xfa_ffimageedit.cpp +++ b/xfa/fxfa/app/xfa_ffimageedit.cpp @@ -11,10 +11,10 @@ #include "xfa/fwl/cfwl_notedriver.h" #include "xfa/fwl/cfwl_picturebox.h" #include "xfa/fxfa/app/xfa_fffield.h" -#include "xfa/fxfa/xfa_ffdoc.h" -#include "xfa/fxfa/xfa_ffdocview.h" -#include "xfa/fxfa/xfa_ffpageview.h" -#include "xfa/fxfa/xfa_ffwidget.h" +#include "xfa/fxfa/cxfa_ffdoc.h" +#include "xfa/fxfa/cxfa_ffdocview.h" +#include "xfa/fxfa/cxfa_ffpageview.h" +#include "xfa/fxfa/cxfa_ffwidget.h" CXFA_FFImageEdit::CXFA_FFImageEdit(CXFA_WidgetAcc* pDataAcc) : CXFA_FFField(pDataAcc), m_pOldDelegate(nullptr) {} diff --git a/xfa/fxfa/app/xfa_ffnotify.cpp b/xfa/fxfa/app/xfa_ffnotify.cpp index fb154d8a9a..90648012c6 100644 --- a/xfa/fxfa/app/xfa_ffnotify.cpp +++ b/xfa/fxfa/app/xfa_ffnotify.cpp @@ -24,12 +24,12 @@ #include "xfa/fxfa/app/xfa_fftextedit.h" #include "xfa/fxfa/app/xfa_ffwidgetacc.h" #include "xfa/fxfa/app/xfa_fwladapter.h" -#include "xfa/fxfa/xfa_ffapp.h" -#include "xfa/fxfa/xfa_ffdoc.h" -#include "xfa/fxfa/xfa_ffdocview.h" -#include "xfa/fxfa/xfa_ffpageview.h" -#include "xfa/fxfa/xfa_ffwidget.h" -#include "xfa/fxfa/xfa_ffwidgethandler.h" +#include "xfa/fxfa/cxfa_ffapp.h" +#include "xfa/fxfa/cxfa_ffdoc.h" +#include "xfa/fxfa/cxfa_ffdocview.h" +#include "xfa/fxfa/cxfa_ffpageview.h" +#include "xfa/fxfa/cxfa_ffwidget.h" +#include "xfa/fxfa/cxfa_ffwidgethandler.h" static void XFA_FFDeleteWidgetAcc(void* pData) { delete static_cast(pData); diff --git a/xfa/fxfa/app/xfa_ffpageview.cpp b/xfa/fxfa/app/xfa_ffpageview.cpp deleted file mode 100644 index d54e1472a1..0000000000 --- a/xfa/fxfa/app/xfa_ffpageview.cpp +++ /dev/null @@ -1,459 +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 - -#include "xfa/fxfa/xfa_ffpageview.h" - -#include -#include - -#include "third_party/base/ptr_util.h" -#include "third_party/base/stl_util.h" -#include "xfa/fde/fde_render.h" -#include "xfa/fxfa/app/xfa_ffcheckbutton.h" -#include "xfa/fxfa/app/xfa_ffchoicelist.h" -#include "xfa/fxfa/app/xfa_fffield.h" -#include "xfa/fxfa/app/xfa_ffimageedit.h" -#include "xfa/fxfa/app/xfa_ffpushbutton.h" -#include "xfa/fxfa/app/xfa_fftextedit.h" -#include "xfa/fxfa/app/xfa_fwladapter.h" -#include "xfa/fxfa/xfa_ffdoc.h" -#include "xfa/fxfa/xfa_ffdocview.h" -#include "xfa/fxfa/xfa_ffwidget.h" - -namespace { - -CFX_Matrix GetPageMatrix(const CFX_RectF& docPageRect, - const CFX_Rect& devicePageRect, - int32_t iRotate, - uint32_t dwCoordinatesType) { - ASSERT(iRotate >= 0 && iRotate <= 3); - - bool bFlipX = (dwCoordinatesType & 0x01) != 0; - bool bFlipY = (dwCoordinatesType & 0x02) != 0; - CFX_Matrix m((bFlipX ? -1.0f : 1.0f), 0, 0, (bFlipY ? -1.0f : 1.0f), 0, 0); - if (iRotate == 0 || iRotate == 2) { - m.a *= (float)devicePageRect.width / docPageRect.width; - m.d *= (float)devicePageRect.height / docPageRect.height; - } else { - m.a *= (float)devicePageRect.height / docPageRect.width; - m.d *= (float)devicePageRect.width / docPageRect.height; - } - m.Rotate(iRotate * 1.57079632675f); - switch (iRotate) { - case 0: - m.e = bFlipX ? (float)devicePageRect.right() : (float)devicePageRect.left; - m.f = bFlipY ? (float)devicePageRect.bottom() : (float)devicePageRect.top; - break; - case 1: - m.e = bFlipY ? (float)devicePageRect.left : (float)devicePageRect.right(); - m.f = bFlipX ? (float)devicePageRect.bottom() : (float)devicePageRect.top; - break; - case 2: - m.e = bFlipX ? (float)devicePageRect.left : (float)devicePageRect.right(); - m.f = bFlipY ? (float)devicePageRect.top : (float)devicePageRect.bottom(); - break; - case 3: - m.e = bFlipY ? (float)devicePageRect.right() : (float)devicePageRect.left; - m.f = bFlipX ? (float)devicePageRect.top : (float)devicePageRect.bottom(); - break; - default: - break; - } - return m; -} - -bool PageWidgetFilter(CXFA_FFWidget* pWidget, - uint32_t dwFilter, - bool bTraversal, - bool bIgnorerelevant) { - CXFA_WidgetAcc* pWidgetAcc = pWidget->GetDataAcc(); - - if (!!(dwFilter & XFA_WidgetStatus_Focused) && - pWidgetAcc->GetElementType() != XFA_Element::Field) { - return false; - } - - uint32_t dwStatus = pWidget->GetStatus(); - if (bTraversal && (dwStatus & XFA_WidgetStatus_Disabled)) - return false; - if (bIgnorerelevant) - return !!(dwStatus & XFA_WidgetStatus_Visible); - - dwFilter &= (XFA_WidgetStatus_Visible | XFA_WidgetStatus_Viewable | - XFA_WidgetStatus_Printable); - return (dwFilter & dwStatus) == dwFilter; -} - -bool IsLayoutElement(XFA_Element eElement, bool bLayoutContainer) { - switch (eElement) { - case XFA_Element::Draw: - case XFA_Element::Field: - case XFA_Element::InstanceManager: - return !bLayoutContainer; - case XFA_Element::Area: - case XFA_Element::Subform: - case XFA_Element::ExclGroup: - case XFA_Element::SubformSet: - case XFA_Element::PageArea: - case XFA_Element::Form: - return true; - default: - return false; - } -} - -} // namespace - -CXFA_FFPageView::CXFA_FFPageView(CXFA_FFDocView* pDocView, CXFA_Node* pPageArea) - : CXFA_ContainerLayoutItem(pPageArea), m_pDocView(pDocView) {} - -CXFA_FFPageView::~CXFA_FFPageView() {} - -CXFA_FFDocView* CXFA_FFPageView::GetDocView() const { - return m_pDocView; -} - -CFX_RectF CXFA_FFPageView::GetPageViewRect() const { - return CFX_RectF(0, 0, GetPageSize()); -} - -CFX_Matrix CXFA_FFPageView::GetDisplayMatrix(const CFX_Rect& rtDisp, - int32_t iRotate) const { - return GetPageMatrix(CFX_RectF(0, 0, GetPageSize()), rtDisp, iRotate, 0); -} - -IXFA_WidgetIterator* CXFA_FFPageView::CreateWidgetIterator( - uint32_t dwTraverseWay, - uint32_t dwWidgetFilter) { - switch (dwTraverseWay) { - case XFA_TRAVERSEWAY_Tranvalse: - return new CXFA_FFTabOrderPageWidgetIterator(this, dwWidgetFilter); - case XFA_TRAVERSEWAY_Form: - return new CXFA_FFPageWidgetIterator(this, dwWidgetFilter); - } - return nullptr; -} - -CXFA_FFPageWidgetIterator::CXFA_FFPageWidgetIterator(CXFA_FFPageView* pPageView, - uint32_t dwFilter) - : m_pPageView(pPageView), m_dwFilter(dwFilter), m_sIterator(pPageView) { - m_bIgnorerelevant = - m_pPageView->GetDocView()->GetDoc()->GetXFADoc()->GetCurVersionMode() < - XFA_VERSION_205; -} - -CXFA_FFPageWidgetIterator::~CXFA_FFPageWidgetIterator() {} - -void CXFA_FFPageWidgetIterator::Reset() { - m_sIterator.Reset(); -} -CXFA_FFWidget* CXFA_FFPageWidgetIterator::MoveToFirst() { - m_sIterator.Reset(); - for (CXFA_LayoutItem* pLayoutItem = m_sIterator.GetCurrent(); pLayoutItem; - pLayoutItem = m_sIterator.MoveToNext()) { - if (CXFA_FFWidget* hWidget = GetWidget(pLayoutItem)) { - return hWidget; - } - } - return nullptr; -} -CXFA_FFWidget* CXFA_FFPageWidgetIterator::MoveToLast() { - m_sIterator.SetCurrent(nullptr); - return MoveToPrevious(); -} -CXFA_FFWidget* CXFA_FFPageWidgetIterator::MoveToNext() { - for (CXFA_LayoutItem* pLayoutItem = m_sIterator.MoveToNext(); pLayoutItem; - pLayoutItem = m_sIterator.MoveToNext()) { - if (CXFA_FFWidget* hWidget = GetWidget(pLayoutItem)) { - return hWidget; - } - } - return nullptr; -} -CXFA_FFWidget* CXFA_FFPageWidgetIterator::MoveToPrevious() { - for (CXFA_LayoutItem* pLayoutItem = m_sIterator.MoveToPrev(); pLayoutItem; - pLayoutItem = m_sIterator.MoveToPrev()) { - if (CXFA_FFWidget* hWidget = GetWidget(pLayoutItem)) { - return hWidget; - } - } - return nullptr; -} -CXFA_FFWidget* CXFA_FFPageWidgetIterator::GetCurrentWidget() { - CXFA_LayoutItem* pLayoutItem = m_sIterator.GetCurrent(); - return pLayoutItem ? XFA_GetWidgetFromLayoutItem(pLayoutItem) : nullptr; -} -bool CXFA_FFPageWidgetIterator::SetCurrentWidget(CXFA_FFWidget* hWidget) { - return hWidget && m_sIterator.SetCurrent(hWidget); -} -CXFA_FFWidget* CXFA_FFPageWidgetIterator::GetWidget( - CXFA_LayoutItem* pLayoutItem) { - if (CXFA_FFWidget* pWidget = XFA_GetWidgetFromLayoutItem(pLayoutItem)) { - if (!PageWidgetFilter(pWidget, m_dwFilter, false, m_bIgnorerelevant)) { - return nullptr; - } - if (!pWidget->IsLoaded() && - (pWidget->GetStatus() & XFA_WidgetStatus_Visible) != 0) { - pWidget->LoadWidget(); - } - return pWidget; - } - return nullptr; -} - -CXFA_FFTabOrderPageWidgetIterator::CXFA_FFTabOrderPageWidgetIterator( - CXFA_FFPageView* pPageView, - uint32_t dwFilter) - : m_pPageView(pPageView), m_dwFilter(dwFilter), m_iCurWidget(-1) { - m_bIgnorerelevant = - m_pPageView->GetDocView()->GetDoc()->GetXFADoc()->GetCurVersionMode() < - XFA_VERSION_205; - Reset(); -} - -CXFA_FFTabOrderPageWidgetIterator::~CXFA_FFTabOrderPageWidgetIterator() {} - -void CXFA_FFTabOrderPageWidgetIterator::Reset() { - CreateTabOrderWidgetArray(); - m_iCurWidget = -1; -} - -CXFA_FFWidget* CXFA_FFTabOrderPageWidgetIterator::MoveToFirst() { - for (int32_t i = 0; - i < pdfium::CollectionSize(m_TabOrderWidgetArray); i++) { - if (PageWidgetFilter(m_TabOrderWidgetArray[i], m_dwFilter, true, - m_bIgnorerelevant)) { - m_iCurWidget = i; - return m_TabOrderWidgetArray[m_iCurWidget]; - } - } - return nullptr; -} - -CXFA_FFWidget* CXFA_FFTabOrderPageWidgetIterator::MoveToLast() { - for (int32_t i = pdfium::CollectionSize(m_TabOrderWidgetArray) - 1; - i >= 0; i--) { - if (PageWidgetFilter(m_TabOrderWidgetArray[i], m_dwFilter, true, - m_bIgnorerelevant)) { - m_iCurWidget = i; - return m_TabOrderWidgetArray[m_iCurWidget]; - } - } - return nullptr; -} - -CXFA_FFWidget* CXFA_FFTabOrderPageWidgetIterator::MoveToNext() { - for (int32_t i = m_iCurWidget + 1; - i < pdfium::CollectionSize(m_TabOrderWidgetArray); i++) { - if (PageWidgetFilter(m_TabOrderWidgetArray[i], m_dwFilter, true, - m_bIgnorerelevant)) { - m_iCurWidget = i; - return m_TabOrderWidgetArray[m_iCurWidget]; - } - } - m_iCurWidget = -1; - return nullptr; -} - -CXFA_FFWidget* CXFA_FFTabOrderPageWidgetIterator::MoveToPrevious() { - for (int32_t i = m_iCurWidget - 1; i >= 0; i--) { - if (PageWidgetFilter(m_TabOrderWidgetArray[i], m_dwFilter, true, - m_bIgnorerelevant)) { - m_iCurWidget = i; - return m_TabOrderWidgetArray[m_iCurWidget]; - } - } - m_iCurWidget = -1; - return nullptr; -} - -CXFA_FFWidget* CXFA_FFTabOrderPageWidgetIterator::GetCurrentWidget() { - return m_iCurWidget >= 0 ? m_TabOrderWidgetArray[m_iCurWidget] : nullptr; -} - -bool CXFA_FFTabOrderPageWidgetIterator::SetCurrentWidget( - CXFA_FFWidget* hWidget) { - auto it = std::find(m_TabOrderWidgetArray.begin(), - m_TabOrderWidgetArray.end(), hWidget); - if (it == m_TabOrderWidgetArray.end()) - return false; - - m_iCurWidget = it - m_TabOrderWidgetArray.begin(); - return true; -} - -CXFA_FFWidget* CXFA_FFTabOrderPageWidgetIterator::GetTraverseWidget( - CXFA_FFWidget* pWidget) { - CXFA_WidgetAcc* pAcc = pWidget->GetDataAcc(); - CXFA_Node* pTraversal = pAcc->GetNode()->GetChild(0, XFA_Element::Traversal); - if (pTraversal) { - CXFA_Node* pTraverse = pTraversal->GetChild(0, XFA_Element::Traverse); - if (pTraverse) { - CFX_WideString wsTraverseWidgetName; - if (pTraverse->GetAttribute(XFA_ATTRIBUTE_Ref, wsTraverseWidgetName)) { - return FindWidgetByName(wsTraverseWidgetName, pWidget); - } - } - } - return nullptr; -} -CXFA_FFWidget* CXFA_FFTabOrderPageWidgetIterator::FindWidgetByName( - const CFX_WideString& wsWidgetName, - CXFA_FFWidget* pRefWidget) { - return pRefWidget->GetDocView()->GetWidgetByName(wsWidgetName, pRefWidget); -} - -void CXFA_FFTabOrderPageWidgetIterator::CreateTabOrderWidgetArray() { - m_TabOrderWidgetArray.clear(); - - std::vector SpaceOrderWidgetArray; - CreateSpaceOrderWidgetArray(&SpaceOrderWidgetArray); - if (SpaceOrderWidgetArray.empty()) - return; - - int32_t nWidgetCount = pdfium::CollectionSize(SpaceOrderWidgetArray); - CXFA_FFWidget* hWidget = SpaceOrderWidgetArray[0]; - while (pdfium::CollectionSize(m_TabOrderWidgetArray) < - nWidgetCount) { - if (!pdfium::ContainsValue(m_TabOrderWidgetArray, hWidget)) { - m_TabOrderWidgetArray.push_back(hWidget); - CXFA_WidgetAcc* pWidgetAcc = hWidget->GetDataAcc(); - if (pWidgetAcc->GetUIType() == XFA_Element::ExclGroup) { - auto it = std::find(SpaceOrderWidgetArray.begin(), - SpaceOrderWidgetArray.end(), hWidget); - int32_t iWidgetIndex = it != SpaceOrderWidgetArray.end() - ? it - SpaceOrderWidgetArray.begin() + 1 - : 0; - while (true) { - CXFA_FFWidget* pRadio = - SpaceOrderWidgetArray[iWidgetIndex % nWidgetCount]; - if (pRadio->GetDataAcc()->GetExclGroup() != pWidgetAcc) { - break; - } - if (!pdfium::ContainsValue(m_TabOrderWidgetArray, hWidget)) { - m_TabOrderWidgetArray.push_back(pRadio); - } - iWidgetIndex++; - } - } - if (CXFA_FFWidget* hTraverseWidget = GetTraverseWidget(hWidget)) { - hWidget = hTraverseWidget; - continue; - } - } - auto it = std::find(SpaceOrderWidgetArray.begin(), - SpaceOrderWidgetArray.end(), hWidget); - int32_t iWidgetIndex = it != SpaceOrderWidgetArray.end() - ? it - SpaceOrderWidgetArray.begin() + 1 - : 0; - hWidget = SpaceOrderWidgetArray[iWidgetIndex % nWidgetCount]; - } -} - -static int32_t XFA_TabOrderWidgetComparator(const void* phWidget1, - const void* phWidget2) { - auto* param1 = *static_cast(const_cast(phWidget1)); - auto* param2 = *static_cast(const_cast(phWidget2)); - CFX_RectF rt1 = param1->m_pWidget->GetWidgetRect(); - CFX_RectF rt2 = param2->m_pWidget->GetWidgetRect(); - float x1 = rt1.left, y1 = rt1.top, x2 = rt2.left, y2 = rt2.top; - if (y1 < y2 || (y1 - y2 < XFA_FLOAT_PERCISION && x1 < x2)) - return -1; - return 1; -} - -void CXFA_FFTabOrderPageWidgetIterator::OrderContainer( - CXFA_LayoutItemIterator* sIterator, - CXFA_LayoutItem* pContainerItem, - CXFA_TabParam* pContainer, - bool& bCurrentItem, - bool& bContentArea, - bool bMarsterPage) { - CFX_ArrayTemplate tabParams; - CXFA_LayoutItem* pSearchItem = sIterator->MoveToNext(); - while (pSearchItem) { - if (!pSearchItem->IsContentLayoutItem()) { - bContentArea = true; - pSearchItem = sIterator->MoveToNext(); - continue; - } - if (bMarsterPage && bContentArea) { - break; - } - if (bMarsterPage || bContentArea) { - CXFA_FFWidget* hWidget = GetWidget(pSearchItem); - if (!hWidget) { - pSearchItem = sIterator->MoveToNext(); - continue; - } - if (pContainerItem && (pSearchItem->GetParent() != pContainerItem)) { - bCurrentItem = true; - break; - } - CXFA_TabParam* pParam = new CXFA_TabParam; - pParam->m_pWidget = hWidget; - tabParams.Add(pParam); - if (IsLayoutElement(pSearchItem->GetFormNode()->GetElementType(), true)) { - OrderContainer(sIterator, pSearchItem, pParam, bCurrentItem, - bContentArea, bMarsterPage); - } - } - if (bCurrentItem) { - pSearchItem = sIterator->GetCurrent(); - bCurrentItem = false; - } else { - pSearchItem = sIterator->MoveToNext(); - } - } - int32_t iChildren = tabParams.GetSize(); - if (iChildren > 1) { - FXSYS_qsort(tabParams.GetData(), iChildren, sizeof(void*), - XFA_TabOrderWidgetComparator); - } - for (int32_t iStart = 0; iStart < iChildren; iStart++) { - std::unique_ptr pParam(tabParams[iStart]); - pContainer->m_Children.push_back(pParam->m_pWidget); - pContainer->m_Children.insert(pContainer->m_Children.end(), - pParam->m_Children.begin(), - pParam->m_Children.end()); - } - tabParams.RemoveAll(); -} -void CXFA_FFTabOrderPageWidgetIterator::CreateSpaceOrderWidgetArray( - std::vector* WidgetArray) { - CXFA_LayoutItemIterator sIterator(m_pPageView); - auto pParam = pdfium::MakeUnique(); - bool bCurrentItem = false; - bool bContentArea = false; - OrderContainer(&sIterator, nullptr, pParam.get(), bCurrentItem, bContentArea); - WidgetArray->insert(WidgetArray->end(), pParam->m_Children.begin(), - pParam->m_Children.end()); - - sIterator.Reset(); - bCurrentItem = false; - bContentArea = false; - pParam->m_Children.clear(); - OrderContainer(&sIterator, nullptr, pParam.get(), bCurrentItem, bContentArea, - true); - WidgetArray->insert(WidgetArray->end(), pParam->m_Children.begin(), - pParam->m_Children.end()); -} - -CXFA_FFWidget* CXFA_FFTabOrderPageWidgetIterator::GetWidget( - CXFA_LayoutItem* pLayoutItem) { - if (CXFA_FFWidget* pWidget = XFA_GetWidgetFromLayoutItem(pLayoutItem)) { - if (!pWidget->IsLoaded() && - (pWidget->GetStatus() & XFA_WidgetStatus_Visible)) { - pWidget->LoadWidget(); - } - return pWidget; - } - return nullptr; -} - -CXFA_TabParam::CXFA_TabParam() : m_pWidget(nullptr) {} - -CXFA_TabParam::~CXFA_TabParam() {} diff --git a/xfa/fxfa/app/xfa_ffpath.cpp b/xfa/fxfa/app/xfa_ffpath.cpp index 186d1b1dbd..854a028aac 100644 --- a/xfa/fxfa/app/xfa_ffpath.cpp +++ b/xfa/fxfa/app/xfa_ffpath.cpp @@ -7,10 +7,10 @@ #include "xfa/fxfa/app/xfa_ffpath.h" #include "xfa/fxfa/app/xfa_ffdraw.h" -#include "xfa/fxfa/xfa_ffapp.h" -#include "xfa/fxfa/xfa_ffdoc.h" -#include "xfa/fxfa/xfa_ffpageview.h" -#include "xfa/fxfa/xfa_ffwidget.h" +#include "xfa/fxfa/cxfa_ffapp.h" +#include "xfa/fxfa/cxfa_ffdoc.h" +#include "xfa/fxfa/cxfa_ffpageview.h" +#include "xfa/fxfa/cxfa_ffwidget.h" #include "xfa/fxgraphics/cfx_color.h" #include "xfa/fxgraphics/cfx_path.h" diff --git a/xfa/fxfa/app/xfa_ffpushbutton.cpp b/xfa/fxfa/app/xfa_ffpushbutton.cpp index 2233c5a6bb..fa5c0dc9a1 100644 --- a/xfa/fxfa/app/xfa_ffpushbutton.cpp +++ b/xfa/fxfa/app/xfa_ffpushbutton.cpp @@ -12,9 +12,9 @@ #include "xfa/fxfa/app/cxfa_textlayout.h" #include "xfa/fxfa/app/xfa_fffield.h" #include "xfa/fxfa/app/xfa_ffwidgetacc.h" -#include "xfa/fxfa/xfa_ffapp.h" -#include "xfa/fxfa/xfa_ffpageview.h" -#include "xfa/fxfa/xfa_ffwidget.h" +#include "xfa/fxfa/cxfa_ffapp.h" +#include "xfa/fxfa/cxfa_ffpageview.h" +#include "xfa/fxfa/cxfa_ffwidget.h" #include "xfa/fxgraphics/cfx_color.h" #include "xfa/fxgraphics/cfx_path.h" diff --git a/xfa/fxfa/app/xfa_ffsignature.cpp b/xfa/fxfa/app/xfa_ffsignature.cpp index bf2bba3adf..edc34336c6 100644 --- a/xfa/fxfa/app/xfa_ffsignature.cpp +++ b/xfa/fxfa/app/xfa_ffsignature.cpp @@ -7,9 +7,9 @@ #include "xfa/fxfa/app/xfa_ffsignature.h" #include "xfa/fxfa/app/xfa_fffield.h" -#include "xfa/fxfa/xfa_ffdoc.h" -#include "xfa/fxfa/xfa_ffpageview.h" -#include "xfa/fxfa/xfa_ffwidget.h" +#include "xfa/fxfa/cxfa_ffdoc.h" +#include "xfa/fxfa/cxfa_ffpageview.h" +#include "xfa/fxfa/cxfa_ffwidget.h" CXFA_FFSignature::CXFA_FFSignature(CXFA_WidgetAcc* pDataAcc) : CXFA_FFField(pDataAcc) {} diff --git a/xfa/fxfa/app/xfa_ffsubform.cpp b/xfa/fxfa/app/xfa_ffsubform.cpp index 0b479f4d4c..d008c5b4f9 100644 --- a/xfa/fxfa/app/xfa_ffsubform.cpp +++ b/xfa/fxfa/app/xfa_ffsubform.cpp @@ -6,10 +6,10 @@ #include "xfa/fxfa/app/xfa_ffsubform.h" -#include "xfa/fxfa/xfa_ffapp.h" -#include "xfa/fxfa/xfa_ffdoc.h" -#include "xfa/fxfa/xfa_ffpageview.h" -#include "xfa/fxfa/xfa_ffwidget.h" +#include "xfa/fxfa/cxfa_ffapp.h" +#include "xfa/fxfa/cxfa_ffdoc.h" +#include "xfa/fxfa/cxfa_ffpageview.h" +#include "xfa/fxfa/cxfa_ffwidget.h" CXFA_FFSubForm::CXFA_FFSubForm(CXFA_WidgetAcc* pDataAcc) : CXFA_FFWidget(pDataAcc) {} diff --git a/xfa/fxfa/app/xfa_ffsubform.h b/xfa/fxfa/app/xfa_ffsubform.h index e6b77a8b33..c87688fdce 100644 --- a/xfa/fxfa/app/xfa_ffsubform.h +++ b/xfa/fxfa/app/xfa_ffsubform.h @@ -7,8 +7,8 @@ #ifndef XFA_FXFA_APP_XFA_FFSUBFORM_H_ #define XFA_FXFA_APP_XFA_FFSUBFORM_H_ -#include "xfa/fxfa/xfa_ffpageview.h" -#include "xfa/fxfa/xfa_ffwidget.h" +#include "xfa/fxfa/cxfa_ffpageview.h" +#include "xfa/fxfa/cxfa_ffwidget.h" class CXFA_FFSubForm : public CXFA_FFWidget { public: diff --git a/xfa/fxfa/app/xfa_fftext.cpp b/xfa/fxfa/app/xfa_fftext.cpp index c4b533f855..a314803f31 100644 --- a/xfa/fxfa/app/xfa_fftext.cpp +++ b/xfa/fxfa/app/xfa_fftext.cpp @@ -13,10 +13,10 @@ #include "xfa/fxfa/app/cxfa_textlayout.h" #include "xfa/fxfa/app/xfa_ffdraw.h" #include "xfa/fxfa/app/xfa_textpiece.h" -#include "xfa/fxfa/xfa_ffapp.h" -#include "xfa/fxfa/xfa_ffdoc.h" -#include "xfa/fxfa/xfa_ffpageview.h" -#include "xfa/fxfa/xfa_ffwidget.h" +#include "xfa/fxfa/cxfa_ffapp.h" +#include "xfa/fxfa/cxfa_ffdoc.h" +#include "xfa/fxfa/cxfa_ffpageview.h" +#include "xfa/fxfa/cxfa_ffwidget.h" #include "xfa/fxgraphics/cfx_graphics.h" CXFA_FFText::CXFA_FFText(CXFA_WidgetAcc* pDataAcc) : CXFA_FFDraw(pDataAcc) {} diff --git a/xfa/fxfa/app/xfa_fftextedit.cpp b/xfa/fxfa/app/xfa_fftextedit.cpp index b4560c88ed..34c037441e 100644 --- a/xfa/fxfa/app/xfa_fftextedit.cpp +++ b/xfa/fxfa/app/xfa_fftextedit.cpp @@ -21,12 +21,12 @@ #include "xfa/fxfa/app/xfa_fffield.h" #include "xfa/fxfa/app/xfa_fwladapter.h" #include "xfa/fxfa/cxfa_eventparam.h" +#include "xfa/fxfa/cxfa_ffapp.h" +#include "xfa/fxfa/cxfa_ffdoc.h" +#include "xfa/fxfa/cxfa_ffdocview.h" +#include "xfa/fxfa/cxfa_ffpageview.h" +#include "xfa/fxfa/cxfa_ffwidget.h" #include "xfa/fxfa/parser/xfa_localevalue.h" -#include "xfa/fxfa/xfa_ffapp.h" -#include "xfa/fxfa/xfa_ffdoc.h" -#include "xfa/fxfa/xfa_ffdocview.h" -#include "xfa/fxfa/xfa_ffpageview.h" -#include "xfa/fxfa/xfa_ffwidget.h" CXFA_FFTextEdit::CXFA_FFTextEdit(CXFA_WidgetAcc* pDataAcc) : CXFA_FFField(pDataAcc), m_pOldDelegate(nullptr) {} diff --git a/xfa/fxfa/app/xfa_ffwidget.cpp b/xfa/fxfa/app/xfa_ffwidget.cpp deleted file mode 100644 index 2d52982293..0000000000 --- a/xfa/fxfa/app/xfa_ffwidget.cpp +++ /dev/null @@ -1,2048 +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 - -#include "xfa/fxfa/xfa_ffwidget.h" - -#include -#include -#include - -#include "core/fpdfapi/page/cpdf_pageobjectholder.h" -#include "core/fxcodec/codec/ccodec_progressivedecoder.h" -#include "core/fxcodec/fx_codec.h" -#include "core/fxcrt/cfx_maybe_owned.h" -#include "core/fxge/cfx_gemodule.h" -#include "core/fxge/cfx_pathdata.h" -#include "core/fxge/cfx_renderdevice.h" -#include "xfa/fwl/fwl_widgethit.h" -#include "xfa/fxfa/app/cxfa_textlayout.h" -#include "xfa/fxfa/cxfa_eventparam.h" -#include "xfa/fxfa/fxfa_widget.h" -#include "xfa/fxfa/parser/cxfa_corner.h" -#include "xfa/fxfa/xfa_ffapp.h" -#include "xfa/fxfa/xfa_ffdoc.h" -#include "xfa/fxfa/xfa_ffdocview.h" -#include "xfa/fxfa/xfa_ffpageview.h" -#include "xfa/fxgraphics/cfx_color.h" -#include "xfa/fxgraphics/cfx_graphics.h" -#include "xfa/fxgraphics/cfx_path.h" -#include "xfa/fxgraphics/cfx_pattern.h" -#include "xfa/fxgraphics/cfx_shading.h" - -CXFA_FFWidget::CXFA_FFWidget(CXFA_WidgetAcc* pDataAcc) - : CXFA_ContentLayoutItem(pDataAcc->GetNode()), - m_pPageView(nullptr), - m_pDataAcc(pDataAcc) {} - -CXFA_FFWidget::~CXFA_FFWidget() {} - -const CFWL_App* CXFA_FFWidget::GetFWLApp() { - return GetPageView()->GetDocView()->GetDoc()->GetApp()->GetFWLApp(); -} - -CFX_RectF CXFA_FFWidget::GetWidgetRect() { - if ((m_dwStatus & XFA_WidgetStatus_RectCached) == 0) - RecacheWidgetRect(); - return m_rtWidget; -} - -CFX_RectF CXFA_FFWidget::RecacheWidgetRect() { - m_dwStatus |= XFA_WidgetStatus_RectCached; - m_rtWidget = GetRect(false); - return m_rtWidget; -} - -CFX_RectF CXFA_FFWidget::GetRectWithoutRotate() { - CFX_RectF rtWidget = GetWidgetRect(); - float fValue = 0; - switch (m_pDataAcc->GetRotate()) { - case 90: - rtWidget.top = rtWidget.bottom(); - fValue = rtWidget.width; - rtWidget.width = rtWidget.height; - rtWidget.height = fValue; - break; - case 180: - rtWidget.left = rtWidget.right(); - rtWidget.top = rtWidget.bottom(); - break; - case 270: - rtWidget.left = rtWidget.right(); - fValue = rtWidget.width; - rtWidget.width = rtWidget.height; - rtWidget.height = fValue; - break; - } - return rtWidget; -} - -uint32_t CXFA_FFWidget::GetStatus() { - return m_dwStatus; -} - -void CXFA_FFWidget::ModifyStatus(uint32_t dwAdded, uint32_t dwRemoved) { - m_dwStatus = (m_dwStatus & ~dwRemoved) | dwAdded; -} - -CFX_RectF CXFA_FFWidget::GetBBox(uint32_t dwStatus, bool bDrawFocus) { - if (bDrawFocus || !m_pPageView) - return CFX_RectF(); - return m_pPageView->GetPageViewRect(); -} - -CXFA_WidgetAcc* CXFA_FFWidget::GetDataAcc() { - return m_pDataAcc; -} - -bool CXFA_FFWidget::GetToolTip(CFX_WideString& wsToolTip) { - if (CXFA_Assist assist = m_pDataAcc->GetAssist()) { - if (CXFA_ToolTip toolTip = assist.GetToolTip()) { - return toolTip.GetTip(wsToolTip); - } - } - return GetCaptionText(wsToolTip); -} - -void CXFA_FFWidget::RenderWidget(CFX_Graphics* pGS, - CFX_Matrix* pMatrix, - uint32_t dwStatus) { - if (!IsMatchVisibleStatus(dwStatus)) - return; - - CXFA_Border border = m_pDataAcc->GetBorder(); - if (!border) - return; - - CFX_RectF rtBorder = GetRectWithoutRotate(); - CXFA_Margin margin = border.GetMargin(); - if (margin) - XFA_RectWidthoutMargin(rtBorder, margin); - - rtBorder.Normalize(); - DrawBorder(pGS, border, rtBorder, pMatrix); -} - -bool CXFA_FFWidget::IsLoaded() { - return !!m_pPageView; -} -bool CXFA_FFWidget::LoadWidget() { - PerformLayout(); - return true; -} -void CXFA_FFWidget::UnloadWidget() {} -bool CXFA_FFWidget::PerformLayout() { - RecacheWidgetRect(); - return true; -} -bool CXFA_FFWidget::UpdateFWLData() { - return false; -} -void CXFA_FFWidget::UpdateWidgetProperty() {} -void CXFA_FFWidget::DrawBorder(CFX_Graphics* pGS, - CXFA_Box box, - const CFX_RectF& rtBorder, - CFX_Matrix* pMatrix, - uint32_t dwFlags) { - XFA_DrawBox(box, pGS, rtBorder, pMatrix, dwFlags); -} - -void CXFA_FFWidget::InvalidateWidget(const CFX_RectF* pRect) { - if (pRect) { - GetDoc()->GetDocEnvironment()->InvalidateRect(m_pPageView, *pRect); - return; - } - - CFX_RectF rtWidget = GetBBox(XFA_WidgetStatus_Focused); - rtWidget.Inflate(2, 2); - GetDoc()->GetDocEnvironment()->InvalidateRect(m_pPageView, rtWidget); -} - -void CXFA_FFWidget::AddInvalidateRect(const CFX_RectF* pRect) { - CFX_RectF rtWidget; - if (pRect) { - rtWidget = *pRect; - } else { - rtWidget = GetBBox(XFA_WidgetStatus_Focused); - rtWidget.Inflate(2, 2); - } - m_pDocView->AddInvalidateRect(m_pPageView, rtWidget); -} - -bool CXFA_FFWidget::GetCaptionText(CFX_WideString& wsCap) { - CXFA_TextLayout* pCapTextlayout = m_pDataAcc->GetCaptionTextLayout(); - if (!pCapTextlayout) { - return false; - } - pCapTextlayout->GetText(wsCap); - return true; -} - -bool CXFA_FFWidget::IsFocused() { - return !!(m_dwStatus & XFA_WidgetStatus_Focused); -} - -bool CXFA_FFWidget::OnMouseEnter() { - return false; -} - -bool CXFA_FFWidget::OnMouseExit() { - return false; -} - -bool CXFA_FFWidget::OnLButtonDown(uint32_t dwFlags, const CFX_PointF& point) { - return false; -} - -bool CXFA_FFWidget::OnLButtonUp(uint32_t dwFlags, const CFX_PointF& point) { - return false; -} - -bool CXFA_FFWidget::OnLButtonDblClk(uint32_t dwFlags, const CFX_PointF& point) { - return false; -} - -bool CXFA_FFWidget::OnMouseMove(uint32_t dwFlags, const CFX_PointF& point) { - return false; -} - -bool CXFA_FFWidget::OnMouseWheel(uint32_t dwFlags, - int16_t zDelta, - const CFX_PointF& point) { - return false; -} - -bool CXFA_FFWidget::OnRButtonDown(uint32_t dwFlags, const CFX_PointF& point) { - return false; -} - -bool CXFA_FFWidget::OnRButtonUp(uint32_t dwFlags, const CFX_PointF& point) { - return false; -} - -bool CXFA_FFWidget::OnRButtonDblClk(uint32_t dwFlags, const CFX_PointF& point) { - return false; -} - -bool CXFA_FFWidget::OnSetFocus(CXFA_FFWidget* pOldWidget) { - CXFA_FFWidget* pParent = GetParent(); - if (pParent && !pParent->IsAncestorOf(pOldWidget)) { - pParent->OnSetFocus(pOldWidget); - } - m_dwStatus |= XFA_WidgetStatus_Focused; - CXFA_EventParam eParam; - eParam.m_eType = XFA_EVENT_Enter; - eParam.m_pTarget = m_pDataAcc; - m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Enter, &eParam); - return true; -} - -bool CXFA_FFWidget::OnKillFocus(CXFA_FFWidget* pNewWidget) { - m_dwStatus &= ~XFA_WidgetStatus_Focused; - EventKillFocus(); - if (pNewWidget) { - CXFA_FFWidget* pParent = GetParent(); - if (pParent && !pParent->IsAncestorOf(pNewWidget)) { - pParent->OnKillFocus(pNewWidget); - } - } - return true; -} - -bool CXFA_FFWidget::OnKeyDown(uint32_t dwKeyCode, uint32_t dwFlags) { - return false; -} - -bool CXFA_FFWidget::OnKeyUp(uint32_t dwKeyCode, uint32_t dwFlags) { - return false; -} - -bool CXFA_FFWidget::OnChar(uint32_t dwChar, uint32_t dwFlags) { - return false; -} - -FWL_WidgetHit CXFA_FFWidget::OnHitTest(const CFX_PointF& point) { - return FWL_WidgetHit::Unknown; -} - -bool CXFA_FFWidget::OnSetCursor(const CFX_PointF& point) { - return false; -} - -bool CXFA_FFWidget::CanUndo() { - return false; -} - -bool CXFA_FFWidget::CanRedo() { - return false; -} - -bool CXFA_FFWidget::Undo() { - return false; -} - -bool CXFA_FFWidget::Redo() { - return false; -} - -bool CXFA_FFWidget::CanCopy() { - return false; -} - -bool CXFA_FFWidget::CanCut() { - return false; -} - -bool CXFA_FFWidget::CanPaste() { - return false; -} - -bool CXFA_FFWidget::CanSelectAll() { - return false; -} - -bool CXFA_FFWidget::CanDelete() { - return CanCut(); -} - -bool CXFA_FFWidget::CanDeSelect() { - return CanCopy(); -} - -bool CXFA_FFWidget::Copy(CFX_WideString& wsCopy) { - return false; -} - -bool CXFA_FFWidget::Cut(CFX_WideString& wsCut) { - return false; -} - -bool CXFA_FFWidget::Paste(const CFX_WideString& wsPaste) { - return false; -} - -void CXFA_FFWidget::SelectAll() {} - -void CXFA_FFWidget::Delete() {} - -void CXFA_FFWidget::DeSelect() {} - -bool CXFA_FFWidget::GetSuggestWords(CFX_PointF pointf, - std::vector& sSuggest) { - return false; -} -bool CXFA_FFWidget::ReplaceSpellCheckWord(CFX_PointF pointf, - const CFX_ByteStringC& bsReplace) { - return false; -} - -CFX_PointF CXFA_FFWidget::Rotate2Normal(const CFX_PointF& point) { - CFX_Matrix mt = GetRotateMatrix(); - if (mt.IsIdentity()) - return point; - - CFX_Matrix mtReverse; - mtReverse.SetReverse(mt); - return mtReverse.Transform(point); -} - -static void XFA_GetMatrix(CFX_Matrix& m, - int32_t iRotate, - XFA_ATTRIBUTEENUM at, - const CFX_RectF& rt) { - if (!iRotate) { - return; - } - float fAnchorX = 0; - float fAnchorY = 0; - switch (at) { - case XFA_ATTRIBUTEENUM_TopLeft: - fAnchorX = rt.left, fAnchorY = rt.top; - break; - case XFA_ATTRIBUTEENUM_TopCenter: - fAnchorX = (rt.left + rt.right()) / 2, fAnchorY = rt.top; - break; - case XFA_ATTRIBUTEENUM_TopRight: - fAnchorX = rt.right(), fAnchorY = rt.top; - break; - case XFA_ATTRIBUTEENUM_MiddleLeft: - fAnchorX = rt.left, fAnchorY = (rt.top + rt.bottom()) / 2; - break; - case XFA_ATTRIBUTEENUM_MiddleCenter: - fAnchorX = (rt.left + rt.right()) / 2, - fAnchorY = (rt.top + rt.bottom()) / 2; - break; - case XFA_ATTRIBUTEENUM_MiddleRight: - fAnchorX = rt.right(), fAnchorY = (rt.top + rt.bottom()) / 2; - break; - case XFA_ATTRIBUTEENUM_BottomLeft: - fAnchorX = rt.left, fAnchorY = rt.bottom(); - break; - case XFA_ATTRIBUTEENUM_BottomCenter: - fAnchorX = (rt.left + rt.right()) / 2, fAnchorY = rt.bottom(); - break; - case XFA_ATTRIBUTEENUM_BottomRight: - fAnchorX = rt.right(), fAnchorY = rt.bottom(); - break; - default: - break; - } - switch (iRotate) { - case 90: - m.a = 0, m.b = -1, m.c = 1, m.d = 0, m.e = fAnchorX - fAnchorY, - m.f = fAnchorX + fAnchorY; - break; - case 180: - m.a = -1, m.b = 0, m.c = 0, m.d = -1, m.e = fAnchorX * 2, - m.f = fAnchorY * 2; - break; - case 270: - m.a = 0, m.b = 1, m.c = -1, m.d = 0, m.e = fAnchorX + fAnchorY, - m.f = fAnchorY - fAnchorX; - break; - } -} - -CFX_Matrix CXFA_FFWidget::GetRotateMatrix() { - CFX_Matrix mt; - int32_t iRotate = m_pDataAcc->GetRotate(); - if (!iRotate) - return mt; - - CFX_RectF rcWidget = GetRectWithoutRotate(); - XFA_ATTRIBUTEENUM at = XFA_ATTRIBUTEENUM_TopLeft; - XFA_GetMatrix(mt, iRotate, at, rcWidget); - - return mt; -} - -bool CXFA_FFWidget::IsLayoutRectEmpty() { - CFX_RectF rtLayout = GetRectWithoutRotate(); - return rtLayout.width < 0.1f && rtLayout.height < 0.1f; -} -CXFA_FFWidget* CXFA_FFWidget::GetParent() { - CXFA_Node* pParentNode = - m_pDataAcc->GetNode()->GetNodeItem(XFA_NODEITEM_Parent); - if (pParentNode) { - CXFA_WidgetAcc* pParentWidgetAcc = - static_cast(pParentNode->GetWidgetData()); - if (pParentWidgetAcc) { - return pParentWidgetAcc->GetNextWidget(nullptr); - } - } - return nullptr; -} - -bool CXFA_FFWidget::IsAncestorOf(CXFA_FFWidget* pWidget) { - if (!pWidget) - return false; - - CXFA_Node* pNode = m_pDataAcc->GetNode(); - CXFA_Node* pChildNode = pWidget->GetDataAcc()->GetNode(); - while (pChildNode) { - if (pChildNode == pNode) - return true; - - pChildNode = pChildNode->GetNodeItem(XFA_NODEITEM_Parent); - } - return false; -} - -bool CXFA_FFWidget::PtInActiveRect(const CFX_PointF& point) { - return GetWidgetRect().Contains(point); -} - -CXFA_FFDocView* CXFA_FFWidget::GetDocView() { - return m_pDocView; -} - -void CXFA_FFWidget::SetDocView(CXFA_FFDocView* pDocView) { - m_pDocView = pDocView; -} - -CXFA_FFDoc* CXFA_FFWidget::GetDoc() { - return m_pDocView->GetDoc(); -} - -CXFA_FFApp* CXFA_FFWidget::GetApp() { - return GetDoc()->GetApp(); -} - -IXFA_AppProvider* CXFA_FFWidget::GetAppProvider() { - return GetApp()->GetAppProvider(); -} - -bool CXFA_FFWidget::IsMatchVisibleStatus(uint32_t dwStatus) { - return !!(m_dwStatus & XFA_WidgetStatus_Visible); -} - -void CXFA_FFWidget::EventKillFocus() { - if (m_dwStatus & XFA_WidgetStatus_Access) { - m_dwStatus &= ~XFA_WidgetStatus_Access; - return; - } - CXFA_EventParam eParam; - eParam.m_eType = XFA_EVENT_Exit; - eParam.m_pTarget = m_pDataAcc; - m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Exit, &eParam); -} -bool CXFA_FFWidget::IsButtonDown() { - return (m_dwStatus & XFA_WidgetStatus_ButtonDown) != 0; -} -void CXFA_FFWidget::SetButtonDown(bool bSet) { - bSet ? m_dwStatus |= XFA_WidgetStatus_ButtonDown - : m_dwStatus &= ~XFA_WidgetStatus_ButtonDown; -} -int32_t XFA_StrokeTypeSetLineDash(CFX_Graphics* pGraphics, - int32_t iStrokeType, - int32_t iCapType) { - switch (iStrokeType) { - case XFA_ATTRIBUTEENUM_DashDot: { - float dashArray[] = {4, 1, 2, 1}; - if (iCapType != XFA_ATTRIBUTEENUM_Butt) { - dashArray[1] = 2; - dashArray[3] = 2; - } - pGraphics->SetLineDash(0, dashArray, 4); - return FX_DASHSTYLE_DashDot; - } - case XFA_ATTRIBUTEENUM_DashDotDot: { - float dashArray[] = {4, 1, 2, 1, 2, 1}; - if (iCapType != XFA_ATTRIBUTEENUM_Butt) { - dashArray[1] = 2; - dashArray[3] = 2; - dashArray[5] = 2; - } - pGraphics->SetLineDash(0, dashArray, 6); - return FX_DASHSTYLE_DashDotDot; - } - case XFA_ATTRIBUTEENUM_Dashed: { - float dashArray[] = {5, 1}; - if (iCapType != XFA_ATTRIBUTEENUM_Butt) { - dashArray[1] = 2; - } - pGraphics->SetLineDash(0, dashArray, 2); - return FX_DASHSTYLE_Dash; - } - case XFA_ATTRIBUTEENUM_Dotted: { - float dashArray[] = {2, 1}; - if (iCapType != XFA_ATTRIBUTEENUM_Butt) { - dashArray[1] = 2; - } - pGraphics->SetLineDash(0, dashArray, 2); - return FX_DASHSTYLE_Dot; - } - default: - break; - } - pGraphics->SetLineDash(FX_DASHSTYLE_Solid); - return FX_DASHSTYLE_Solid; -} -CFX_GraphStateData::LineCap XFA_LineCapToFXGE(int32_t iLineCap) { - switch (iLineCap) { - case XFA_ATTRIBUTEENUM_Round: - return CFX_GraphStateData::LineCapRound; - case XFA_ATTRIBUTEENUM_Butt: - return CFX_GraphStateData::LineCapButt; - default: - break; - } - return CFX_GraphStateData::LineCapSquare; -} - -class CXFA_ImageRenderer { - public: - CXFA_ImageRenderer(); - ~CXFA_ImageRenderer(); - - bool Start(CFX_RenderDevice* pDevice, - CFX_DIBSource* pDIBSource, - FX_ARGB bitmap_argb, - int bitmap_alpha, - const CFX_Matrix* pImage2Device, - uint32_t flags, - int blendType = FXDIB_BLEND_NORMAL); - bool Continue(IFX_Pause* pPause); - - protected: - bool StartDIBSource(); - void CompositeDIBitmap(CFX_DIBitmap* pDIBitmap, - int left, - int top, - FX_ARGB mask_argb, - int bitmap_alpha, - int blend_mode, - int Transparency); - - CFX_RenderDevice* m_pDevice; - int m_Status; - CFX_Matrix m_ImageMatrix; - CFX_DIBSource* m_pDIBSource; - std::unique_ptr m_pCloneConvert; - int m_BitmapAlpha; - FX_ARGB m_FillArgb; - uint32_t m_Flags; - std::unique_ptr m_pTransformer; - void* m_DeviceHandle; - int32_t m_BlendType; - bool m_Result; - bool m_bPrint; -}; - -CXFA_ImageRenderer::CXFA_ImageRenderer() - : m_pDevice(nullptr), - m_Status(0), - m_pDIBSource(nullptr), - m_BitmapAlpha(255), - m_FillArgb(0), - m_Flags(0), - m_DeviceHandle(nullptr), - m_BlendType(FXDIB_BLEND_NORMAL), - m_Result(true), - m_bPrint(false) {} - -CXFA_ImageRenderer::~CXFA_ImageRenderer() { - if (m_DeviceHandle) - m_pDevice->CancelDIBits(m_DeviceHandle); -} - -bool CXFA_ImageRenderer::Start(CFX_RenderDevice* pDevice, - CFX_DIBSource* pDIBSource, - FX_ARGB bitmap_argb, - int bitmap_alpha, - const CFX_Matrix* pImage2Device, - uint32_t flags, - int blendType) { - m_pDevice = pDevice; - m_pDIBSource = pDIBSource; - m_FillArgb = bitmap_argb; - m_BitmapAlpha = bitmap_alpha; - m_ImageMatrix = *pImage2Device; - m_Flags = flags; - m_BlendType = blendType; - return StartDIBSource(); -} - -bool CXFA_ImageRenderer::StartDIBSource() { - if (m_pDevice->StartDIBitsWithBlend(m_pDIBSource, m_BitmapAlpha, m_FillArgb, - &m_ImageMatrix, m_Flags, m_DeviceHandle, - m_BlendType)) { - if (m_DeviceHandle) { - m_Status = 3; - return true; - } - return false; - } - CFX_FloatRect image_rect_f = m_ImageMatrix.GetUnitRect(); - FX_RECT image_rect = image_rect_f.GetOuterRect(); - int dest_width = image_rect.Width(); - int dest_height = image_rect.Height(); - if ((FXSYS_fabs(m_ImageMatrix.b) >= 0.5f || m_ImageMatrix.a == 0) || - (FXSYS_fabs(m_ImageMatrix.c) >= 0.5f || m_ImageMatrix.d == 0)) { - if (m_bPrint && !(m_pDevice->GetRenderCaps() & FXRC_BLEND_MODE)) { - m_Result = false; - return false; - } - CFX_DIBSource* pDib = m_pDIBSource; - if (m_pDIBSource->HasAlpha() && - !(m_pDevice->GetRenderCaps() & FXRC_ALPHA_IMAGE) && - !(m_pDevice->GetRenderCaps() & FXRC_GET_BITS)) { - m_pCloneConvert = m_pDIBSource->CloneConvert(FXDIB_Rgb); - if (!m_pCloneConvert) { - m_Result = false; - return false; - } - pDib = m_pCloneConvert.get(); - } - FX_RECT clip_box = m_pDevice->GetClipBox(); - clip_box.Intersect(image_rect); - m_Status = 2; - m_pTransformer.reset( - new CFX_ImageTransformer(pDib, &m_ImageMatrix, m_Flags, &clip_box)); - m_pTransformer->Start(); - return true; - } - if (m_ImageMatrix.a < 0) { - dest_width = -dest_width; - } - if (m_ImageMatrix.d > 0) { - dest_height = -dest_height; - } - int dest_left, dest_top; - dest_left = dest_width > 0 ? image_rect.left : image_rect.right; - dest_top = dest_height > 0 ? image_rect.top : image_rect.bottom; - if (m_pDIBSource->IsOpaqueImage() && m_BitmapAlpha == 255) { - if (m_pDevice->StretchDIBitsWithFlagsAndBlend( - m_pDIBSource, dest_left, dest_top, dest_width, dest_height, m_Flags, - m_BlendType)) { - return false; - } - } - if (m_pDIBSource->IsAlphaMask()) { - if (m_BitmapAlpha != 255) { - m_FillArgb = FXARGB_MUL_ALPHA(m_FillArgb, m_BitmapAlpha); - } - if (m_pDevice->StretchBitMaskWithFlags(m_pDIBSource, dest_left, dest_top, - dest_width, dest_height, m_FillArgb, - m_Flags)) { - return false; - } - } - if (m_bPrint && !(m_pDevice->GetRenderCaps() & FXRC_BLEND_MODE)) { - m_Result = false; - return true; - } - FX_RECT clip_box = m_pDevice->GetClipBox(); - FX_RECT dest_rect = clip_box; - dest_rect.Intersect(image_rect); - FX_RECT dest_clip( - dest_rect.left - image_rect.left, dest_rect.top - image_rect.top, - dest_rect.right - image_rect.left, dest_rect.bottom - image_rect.top); - std::unique_ptr pStretched( - m_pDIBSource->StretchTo(dest_width, dest_height, m_Flags, &dest_clip)); - if (pStretched) { - CompositeDIBitmap(pStretched.get(), dest_rect.left, dest_rect.top, - m_FillArgb, m_BitmapAlpha, m_BlendType, false); - } - return false; -} - -bool CXFA_ImageRenderer::Continue(IFX_Pause* pPause) { - if (m_Status == 2) { - if (m_pTransformer->Continue(pPause)) - return true; - - std::unique_ptr pBitmap(m_pTransformer->DetachBitmap()); - if (!pBitmap) - return false; - - if (pBitmap->IsAlphaMask()) { - if (m_BitmapAlpha != 255) - m_FillArgb = FXARGB_MUL_ALPHA(m_FillArgb, m_BitmapAlpha); - m_Result = - m_pDevice->SetBitMask(pBitmap.get(), m_pTransformer->result().left, - m_pTransformer->result().top, m_FillArgb); - } else { - if (m_BitmapAlpha != 255) - pBitmap->MultiplyAlpha(m_BitmapAlpha); - m_Result = m_pDevice->SetDIBitsWithBlend( - pBitmap.get(), m_pTransformer->result().left, - m_pTransformer->result().top, m_BlendType); - } - return false; - } - if (m_Status == 3) - return m_pDevice->ContinueDIBits(m_DeviceHandle, pPause); - - return false; -} - -void CXFA_ImageRenderer::CompositeDIBitmap(CFX_DIBitmap* pDIBitmap, - int left, - int top, - FX_ARGB mask_argb, - int bitmap_alpha, - int blend_mode, - int Transparency) { - if (!pDIBitmap) { - return; - } - bool bIsolated = !!(Transparency & PDFTRANS_ISOLATED); - bool bGroup = !!(Transparency & PDFTRANS_GROUP); - if (blend_mode == FXDIB_BLEND_NORMAL) { - if (!pDIBitmap->IsAlphaMask()) { - if (bitmap_alpha < 255) { - pDIBitmap->MultiplyAlpha(bitmap_alpha); - } - if (m_pDevice->SetDIBits(pDIBitmap, left, top)) { - return; - } - } else { - uint32_t fill_argb = (mask_argb); - if (bitmap_alpha < 255) { - ((uint8_t*)&fill_argb)[3] = - ((uint8_t*)&fill_argb)[3] * bitmap_alpha / 255; - } - if (m_pDevice->SetBitMask(pDIBitmap, left, top, fill_argb)) { - return; - } - } - } - bool bBackAlphaRequired = blend_mode && bIsolated; - bool bGetBackGround = - ((m_pDevice->GetRenderCaps() & FXRC_ALPHA_OUTPUT)) || - (!(m_pDevice->GetRenderCaps() & FXRC_ALPHA_OUTPUT) && - (m_pDevice->GetRenderCaps() & FXRC_GET_BITS) && !bBackAlphaRequired); - if (bGetBackGround) { - if (bIsolated || !bGroup) { - if (pDIBitmap->IsAlphaMask()) { - return; - } - m_pDevice->SetDIBitsWithBlend(pDIBitmap, left, top, blend_mode); - } else { - FX_RECT rect(left, top, left + pDIBitmap->GetWidth(), - top + pDIBitmap->GetHeight()); - rect.Intersect(m_pDevice->GetClipBox()); - CFX_MaybeOwned pClone; - if (m_pDevice->GetBackDrop() && m_pDevice->GetBitmap()) { - pClone = m_pDevice->GetBackDrop()->Clone(&rect); - CFX_DIBitmap* pForeBitmap = m_pDevice->GetBitmap(); - pClone->CompositeBitmap(0, 0, pClone->GetWidth(), pClone->GetHeight(), - pForeBitmap, rect.left, rect.top); - left = left >= 0 ? 0 : left; - top = top >= 0 ? 0 : top; - if (!pDIBitmap->IsAlphaMask()) - pClone->CompositeBitmap(0, 0, pClone->GetWidth(), pClone->GetHeight(), - pDIBitmap, left, top, blend_mode); - else - pClone->CompositeMask(0, 0, pClone->GetWidth(), pClone->GetHeight(), - pDIBitmap, mask_argb, left, top, blend_mode); - } else { - pClone = pDIBitmap; - } - if (m_pDevice->GetBackDrop()) { - m_pDevice->SetDIBits(pClone.Get(), rect.left, rect.top); - } else { - if (pDIBitmap->IsAlphaMask()) - return; - m_pDevice->SetDIBitsWithBlend(pDIBitmap, rect.left, rect.top, - blend_mode); - } - } - return; - } - if (!pDIBitmap->HasAlpha() || - (m_pDevice->GetRenderCaps() & FXRC_ALPHA_IMAGE)) { - return; - } - std::unique_ptr pCloneConvert = - pDIBitmap->CloneConvert(FXDIB_Rgb); - if (!pCloneConvert) - return; - - CXFA_ImageRenderer imageRender; - if (!imageRender.Start(m_pDevice, pCloneConvert.get(), m_FillArgb, - m_BitmapAlpha, &m_ImageMatrix, m_Flags)) { - return; - } - while (imageRender.Continue(nullptr)) - continue; -} - -void XFA_DrawImage(CFX_Graphics* pGS, - const CFX_RectF& rtImage, - CFX_Matrix* pMatrix, - CFX_DIBitmap* pDIBitmap, - int32_t iAspect, - int32_t iImageXDpi, - int32_t iImageYDpi, - int32_t iHorzAlign, - int32_t iVertAlign) { - if (rtImage.IsEmpty()) - return; - if (!pDIBitmap || !pDIBitmap->GetBuffer()) - return; - - CFX_RectF rtFit( - rtImage.TopLeft(), - XFA_UnitPx2Pt((float)pDIBitmap->GetWidth(), (float)iImageXDpi), - XFA_UnitPx2Pt((float)pDIBitmap->GetHeight(), (float)iImageYDpi)); - switch (iAspect) { - case XFA_ATTRIBUTEENUM_Fit: { - float f1 = rtImage.height / rtFit.height; - float f2 = rtImage.width / rtFit.width; - f1 = std::min(f1, f2); - rtFit.height = rtFit.height * f1; - rtFit.width = rtFit.width * f1; - } break; - case XFA_ATTRIBUTEENUM_Actual: - break; - case XFA_ATTRIBUTEENUM_Height: { - float f1 = rtImage.height / rtFit.height; - rtFit.height = rtImage.height; - rtFit.width = f1 * rtFit.width; - } break; - case XFA_ATTRIBUTEENUM_None: - rtFit.height = rtImage.height; - rtFit.width = rtImage.width; - break; - case XFA_ATTRIBUTEENUM_Width: { - float f1 = rtImage.width / rtFit.width; - rtFit.width = rtImage.width; - rtFit.height = rtFit.height * f1; - } break; - } - if (iHorzAlign == XFA_ATTRIBUTEENUM_Center) { - rtFit.left += (rtImage.width - rtFit.width) / 2; - } else if (iHorzAlign == XFA_ATTRIBUTEENUM_Right) { - rtFit.left = rtImage.right() - rtFit.width; - } - if (iVertAlign == XFA_ATTRIBUTEENUM_Middle) { - rtFit.top += (rtImage.height - rtFit.height) / 2; - } else if (iVertAlign == XFA_ATTRIBUTEENUM_Bottom) { - rtFit.top = rtImage.bottom() - rtImage.height; - } - CFX_RenderDevice* pRenderDevice = pGS->GetRenderDevice(); - pRenderDevice->SaveState(); - - CFX_PathData path; - path.AppendRect(rtImage.left, rtImage.bottom(), rtImage.right(), rtImage.top); - pRenderDevice->SetClip_PathFill(&path, pMatrix, FXFILL_WINDING); - - CFX_Matrix mtImage(1, 0, 0, -1, 0, 1); - mtImage.Concat( - CFX_Matrix(rtFit.width, 0, 0, rtFit.height, rtFit.left, rtFit.top)); - mtImage.Concat(*pMatrix); - - CXFA_ImageRenderer imageRender; - bool bRet = imageRender.Start(pRenderDevice, pDIBitmap, 0, 255, &mtImage, - FXDIB_INTERPOL); - while (bRet) - bRet = imageRender.Continue(nullptr); - - pRenderDevice->RestoreState(false); -} - -static const uint8_t g_inv_base64[128] = { - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 62, 255, - 255, 255, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 255, 255, - 255, 255, 255, 255, 255, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, - 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, - 25, 255, 255, 255, 255, 255, 255, 26, 27, 28, 29, 30, 31, 32, 33, - 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, - 49, 50, 51, 255, 255, 255, 255, 255, -}; - -static uint8_t* XFA_RemoveBase64Whitespace(const uint8_t* pStr, int32_t iLen) { - uint8_t* pCP; - int32_t i = 0, j = 0; - if (iLen == 0) { - iLen = FXSYS_strlen((char*)pStr); - } - pCP = FX_Alloc(uint8_t, iLen + 1); - for (; i < iLen; i++) { - if ((pStr[i] & 128) == 0) { - if (g_inv_base64[pStr[i]] != 0xFF || pStr[i] == '=') { - pCP[j++] = pStr[i]; - } - } - } - pCP[j] = '\0'; - return pCP; -} -static int32_t XFA_Base64Decode(const char* pStr, uint8_t* pOutBuffer) { - if (!pStr) { - return 0; - } - uint8_t* pBuffer = - XFA_RemoveBase64Whitespace((uint8_t*)pStr, FXSYS_strlen((char*)pStr)); - if (!pBuffer) { - return 0; - } - int32_t iLen = FXSYS_strlen((char*)pBuffer); - int32_t i = 0, j = 0; - uint32_t dwLimb = 0; - for (; i + 3 < iLen; i += 4) { - if (pBuffer[i] == '=' || pBuffer[i + 1] == '=' || pBuffer[i + 2] == '=' || - pBuffer[i + 3] == '=') { - if (pBuffer[i] == '=' || pBuffer[i + 1] == '=') { - break; - } - if (pBuffer[i + 2] == '=') { - dwLimb = ((uint32_t)g_inv_base64[pBuffer[i]] << 6) | - ((uint32_t)g_inv_base64[pBuffer[i + 1]]); - pOutBuffer[j] = (uint8_t)(dwLimb >> 4) & 0xFF; - j++; - } else { - dwLimb = ((uint32_t)g_inv_base64[pBuffer[i]] << 12) | - ((uint32_t)g_inv_base64[pBuffer[i + 1]] << 6) | - ((uint32_t)g_inv_base64[pBuffer[i + 2]]); - pOutBuffer[j] = (uint8_t)(dwLimb >> 10) & 0xFF; - pOutBuffer[j + 1] = (uint8_t)(dwLimb >> 2) & 0xFF; - j += 2; - } - } else { - dwLimb = ((uint32_t)g_inv_base64[pBuffer[i]] << 18) | - ((uint32_t)g_inv_base64[pBuffer[i + 1]] << 12) | - ((uint32_t)g_inv_base64[pBuffer[i + 2]] << 6) | - ((uint32_t)g_inv_base64[pBuffer[i + 3]]); - pOutBuffer[j] = (uint8_t)(dwLimb >> 16) & 0xff; - pOutBuffer[j + 1] = (uint8_t)(dwLimb >> 8) & 0xff; - pOutBuffer[j + 2] = (uint8_t)(dwLimb)&0xff; - j += 3; - } - } - FX_Free(pBuffer); - return j; -} - -static const char g_base64_chars[] = - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; - -char* XFA_Base64Encode(const uint8_t* buf, int32_t buf_len) { - char* out = nullptr; - int i, j; - uint32_t limb; - out = FX_Alloc(char, ((buf_len * 8 + 5) / 6) + 5); - for (i = 0, j = 0, limb = 0; i + 2 < buf_len; i += 3, j += 4) { - limb = ((uint32_t)buf[i] << 16) | ((uint32_t)buf[i + 1] << 8) | - ((uint32_t)buf[i + 2]); - out[j] = g_base64_chars[(limb >> 18) & 63]; - out[j + 1] = g_base64_chars[(limb >> 12) & 63]; - out[j + 2] = g_base64_chars[(limb >> 6) & 63]; - out[j + 3] = g_base64_chars[(limb)&63]; - } - switch (buf_len - i) { - case 0: - break; - case 1: - limb = ((uint32_t)buf[i]); - out[j++] = g_base64_chars[(limb >> 2) & 63]; - out[j++] = g_base64_chars[(limb << 4) & 63]; - out[j++] = '='; - out[j++] = '='; - break; - case 2: - limb = ((uint32_t)buf[i] << 8) | ((uint32_t)buf[i + 1]); - out[j++] = g_base64_chars[(limb >> 10) & 63]; - out[j++] = g_base64_chars[(limb >> 4) & 63]; - out[j++] = g_base64_chars[(limb << 2) & 63]; - out[j++] = '='; - break; - default: - break; - } - out[j] = '\0'; - return out; -} -FXCODEC_IMAGE_TYPE XFA_GetImageType(const CFX_WideString& wsType) { - CFX_WideString wsContentType(wsType); - wsContentType.MakeLower(); - if (wsContentType == L"image/jpg") - return FXCODEC_IMAGE_JPG; - if (wsContentType == L"image/png") - return FXCODEC_IMAGE_PNG; - if (wsContentType == L"image/gif") - return FXCODEC_IMAGE_GIF; - if (wsContentType == L"image/bmp") - return FXCODEC_IMAGE_BMP; - if (wsContentType == L"image/tif") - return FXCODEC_IMAGE_TIF; - return FXCODEC_IMAGE_UNKNOWN; -} -CFX_DIBitmap* XFA_LoadImageData(CXFA_FFDoc* pDoc, - CXFA_Image* pImage, - bool& bNameImage, - int32_t& iImageXDpi, - int32_t& iImageYDpi) { - CFX_WideString wsHref; - pImage->GetHref(wsHref); - CFX_WideString wsImage; - pImage->GetContent(wsImage); - if (wsHref.IsEmpty() && wsImage.IsEmpty()) { - return nullptr; - } - CFX_WideString wsContentType; - pImage->GetContentType(wsContentType); - FXCODEC_IMAGE_TYPE type = XFA_GetImageType(wsContentType); - CFX_ByteString bsContent; - uint8_t* pImageBuffer = nullptr; - CFX_RetainPtr pImageFileRead; - if (wsImage.GetLength() > 0) { - XFA_ATTRIBUTEENUM iEncoding = - (XFA_ATTRIBUTEENUM)pImage->GetTransferEncoding(); - if (iEncoding == XFA_ATTRIBUTEENUM_Base64) { - CFX_ByteString bsData = wsImage.UTF8Encode(); - int32_t iLength = bsData.GetLength(); - pImageBuffer = FX_Alloc(uint8_t, iLength); - int32_t iRead = XFA_Base64Decode(bsData.c_str(), pImageBuffer); - if (iRead > 0) { - pImageFileRead = IFX_MemoryStream::Create(pImageBuffer, iRead); - } - } else { - bsContent = CFX_ByteString::FromUnicode(wsImage); - pImageFileRead = IFX_MemoryStream::Create( - const_cast(bsContent.raw_str()), bsContent.GetLength()); - } - } else { - CFX_WideString wsURL = wsHref; - if (wsURL.Left(7) != L"http://" && wsURL.Left(6) != L"ftp://") { - CFX_DIBitmap* pBitmap = - pDoc->GetPDFNamedImage(wsURL.AsStringC(), iImageXDpi, iImageYDpi); - if (pBitmap) { - bNameImage = true; - return pBitmap; - } - } - pImageFileRead = pDoc->GetDocEnvironment()->OpenLinkedFile(pDoc, wsURL); - } - if (!pImageFileRead) { - FX_Free(pImageBuffer); - return nullptr; - } - bNameImage = false; - CFX_DIBitmap* pBitmap = - XFA_LoadImageFromBuffer(pImageFileRead, type, iImageXDpi, iImageYDpi); - FX_Free(pImageBuffer); - return pBitmap; -} -static FXDIB_Format XFA_GetDIBFormat(FXCODEC_IMAGE_TYPE type, - int32_t iComponents, - int32_t iBitsPerComponent) { - FXDIB_Format dibFormat = FXDIB_Argb; - switch (type) { - case FXCODEC_IMAGE_BMP: - case FXCODEC_IMAGE_JPG: - case FXCODEC_IMAGE_TIF: { - dibFormat = FXDIB_Rgb32; - int32_t bpp = iComponents * iBitsPerComponent; - if (bpp <= 24) { - dibFormat = FXDIB_Rgb; - } - } break; - case FXCODEC_IMAGE_PNG: - default: - break; - } - return dibFormat; -} - -CFX_DIBitmap* XFA_LoadImageFromBuffer( - const CFX_RetainPtr& pImageFileRead, - FXCODEC_IMAGE_TYPE type, - int32_t& iImageXDpi, - int32_t& iImageYDpi) { - CFX_GEModule* pGeModule = CFX_GEModule::Get(); - if (!pGeModule) - return nullptr; - - CCodec_ModuleMgr* pCodecMgr = pGeModule->GetCodecModule(); - if (!pCodecMgr) - return nullptr; - - CFX_DIBAttribute dibAttr; - CFX_DIBitmap* pBitmap = nullptr; - std::unique_ptr pProgressiveDecoder = - pCodecMgr->CreateProgressiveDecoder(); - pProgressiveDecoder->LoadImageInfo(pImageFileRead, type, &dibAttr, false); - switch (dibAttr.m_wDPIUnit) { - case FXCODEC_RESUNIT_CENTIMETER: - dibAttr.m_nXDPI = (int32_t)(dibAttr.m_nXDPI * 2.54f); - dibAttr.m_nYDPI = (int32_t)(dibAttr.m_nYDPI * 2.54f); - break; - case FXCODEC_RESUNIT_METER: - dibAttr.m_nXDPI = (int32_t)(dibAttr.m_nXDPI / (float)100 * 2.54f); - dibAttr.m_nYDPI = (int32_t)(dibAttr.m_nYDPI / (float)100 * 2.54f); - break; - default: - break; - } - iImageXDpi = dibAttr.m_nXDPI > 1 ? dibAttr.m_nXDPI : (96); - iImageYDpi = dibAttr.m_nYDPI > 1 ? dibAttr.m_nYDPI : (96); - if (pProgressiveDecoder->GetWidth() > 0 && - pProgressiveDecoder->GetHeight() > 0) { - type = pProgressiveDecoder->GetType(); - int32_t iComponents = pProgressiveDecoder->GetNumComponents(); - int32_t iBpc = pProgressiveDecoder->GetBPC(); - FXDIB_Format dibFormat = XFA_GetDIBFormat(type, iComponents, iBpc); - pBitmap = new CFX_DIBitmap(); - pBitmap->Create(pProgressiveDecoder->GetWidth(), - pProgressiveDecoder->GetHeight(), dibFormat); - pBitmap->Clear(0xffffffff); - int32_t nFrames; - if ((pProgressiveDecoder->GetFrames(nFrames) == - FXCODEC_STATUS_DECODE_READY) && - (nFrames > 0)) { - pProgressiveDecoder->StartDecode(pBitmap, 0, 0, pBitmap->GetWidth(), - pBitmap->GetHeight()); - pProgressiveDecoder->ContinueDecode(); - } - } - return pBitmap; -} - -void XFA_RectWidthoutMargin(CFX_RectF& rt, const CXFA_Margin& mg, bool bUI) { - if (!mg) { - return; - } - float fLeftInset, fTopInset, fRightInset, fBottomInset; - mg.GetLeftInset(fLeftInset); - mg.GetTopInset(fTopInset); - mg.GetRightInset(fRightInset); - mg.GetBottomInset(fBottomInset); - rt.Deflate(fLeftInset, fTopInset, fRightInset, fBottomInset); -} -CXFA_FFWidget* XFA_GetWidgetFromLayoutItem(CXFA_LayoutItem* pLayoutItem) { - if (XFA_IsCreateWidget(pLayoutItem->GetFormNode()->GetElementType())) - return static_cast(pLayoutItem); - return nullptr; -} -bool XFA_IsCreateWidget(XFA_Element eType) { - return eType == XFA_Element::Field || eType == XFA_Element::Draw || - eType == XFA_Element::Subform || eType == XFA_Element::ExclGroup; -} -static void XFA_BOX_GetPath_Arc(CXFA_Box box, - CFX_RectF rtDraw, - CFX_Path& fillPath, - uint32_t dwFlags) { - float a, b; - a = rtDraw.width / 2.0f; - b = rtDraw.height / 2.0f; - if (box.IsCircular() || (dwFlags & XFA_DRAWBOX_ForceRound) != 0) { - a = b = std::min(a, b); - } - CFX_PointF center = rtDraw.Center(); - rtDraw.left = center.x - a; - rtDraw.top = center.y - b; - rtDraw.width = a + a; - rtDraw.height = b + b; - float startAngle = 0, sweepAngle = 360; - bool bStart = box.GetStartAngle(startAngle); - bool bEnd = box.GetSweepAngle(sweepAngle); - if (!bStart && !bEnd) { - fillPath.AddEllipse(rtDraw); - return; - } - startAngle = -startAngle * FX_PI / 180.0f; - sweepAngle = -sweepAngle * FX_PI / 180.0f; - fillPath.AddArc(rtDraw.TopLeft(), rtDraw.Size(), startAngle, sweepAngle); -} - -static void XFA_BOX_GetPath(CXFA_Box box, - const std::vector& strokes, - CFX_RectF rtWidget, - CFX_Path& path, - int32_t nIndex, - bool bStart, - bool bCorner) { - ASSERT(nIndex >= 0 && nIndex < 8); - int32_t n = (nIndex & 1) ? nIndex - 1 : nIndex; - CXFA_Corner corner1(strokes[n].GetNode()); - CXFA_Corner corner2(strokes[(n + 2) % 8].GetNode()); - float fRadius1 = bCorner ? corner1.GetRadius() : 0.0f; - float fRadius2 = bCorner ? corner2.GetRadius() : 0.0f; - bool bInverted = corner1.IsInverted(); - float offsetY = 0.0f; - float offsetX = 0.0f; - bool bRound = corner1.GetJoinType() == XFA_ATTRIBUTEENUM_Round; - float halfAfter = 0.0f; - float halfBefore = 0.0f; - CXFA_Stroke stroke = strokes[nIndex]; - if (stroke.IsCorner()) { - CXFA_Stroke edgeBefore = strokes[(nIndex + 1 * 8 - 1) % 8]; - CXFA_Stroke edgeAfter = strokes[nIndex + 1]; - if (stroke.IsInverted()) { - if (!stroke.SameStyles(edgeBefore)) { - halfBefore = edgeBefore.GetThickness() / 2; - } - if (!stroke.SameStyles(edgeAfter)) { - halfAfter = edgeAfter.GetThickness() / 2; - } - } - } else { - CXFA_Stroke edgeBefore = strokes[(nIndex + 8 - 2) % 8]; - CXFA_Stroke edgeAfter = strokes[(nIndex + 2) % 8]; - if (!bRound && !bInverted) { - halfBefore = edgeBefore.GetThickness() / 2; - halfAfter = edgeAfter.GetThickness() / 2; - } - } - float offsetEX = 0.0f; - float offsetEY = 0.0f; - float sx = 0.0f; - float sy = 0.0f; - float vx = 1.0f; - float vy = 1.0f; - float nx = 1.0f; - float ny = 1.0f; - CFX_PointF cpStart; - CFX_PointF cp1; - CFX_PointF cp2; - if (bRound) { - sy = FX_PI / 2; - } - switch (nIndex) { - case 0: - case 1: - cp1 = rtWidget.TopLeft(); - cp2 = rtWidget.TopRight(); - if (nIndex == 0) { - cpStart.x = cp1.x - halfBefore; - cpStart.y = cp1.y + fRadius1, offsetY = -halfAfter; - } else { - cpStart.x = cp1.x + fRadius1 - halfBefore, cpStart.y = cp1.y, - offsetEX = halfAfter; - } - vx = 1, vy = 1; - nx = -1, ny = 0; - if (bRound) { - sx = bInverted ? FX_PI / 2 : FX_PI; - } else { - sx = 1, sy = 0; - } - break; - case 2: - case 3: - cp1 = rtWidget.TopRight(); - cp2 = rtWidget.BottomRight(); - if (nIndex == 2) { - cpStart.x = cp1.x - fRadius1, cpStart.y = cp1.y - halfBefore, - offsetX = halfAfter; - } else { - cpStart.x = cp1.x, cpStart.y = cp1.y + fRadius1 - halfBefore, - offsetEY = halfAfter; - } - vx = -1, vy = 1; - nx = 0, ny = -1; - if (bRound) { - sx = bInverted ? FX_PI : FX_PI * 3 / 2; - } else { - sx = 0, sy = 1; - } - break; - case 4: - case 5: - cp1 = rtWidget.BottomRight(); - cp2 = rtWidget.BottomLeft(); - if (nIndex == 4) { - cpStart.x = cp1.x + halfBefore, cpStart.y = cp1.y - fRadius1, - offsetY = halfAfter; - } else { - cpStart.x = cp1.x - fRadius1 + halfBefore, cpStart.y = cp1.y, - offsetEX = -halfAfter; - } - vx = -1, vy = -1; - nx = 1, ny = 0; - if (bRound) { - sx = bInverted ? FX_PI * 3 / 2 : 0; - } else { - sx = -1, sy = 0; - } - break; - case 6: - case 7: - cp1 = rtWidget.BottomLeft(); - cp2 = rtWidget.TopLeft(); - if (nIndex == 6) { - cpStart.x = cp1.x + fRadius1, cpStart.y = cp1.y + halfBefore, - offsetX = -halfAfter; - } else { - cpStart.x = cp1.x, cpStart.y = cp1.y - fRadius1 + halfBefore, - offsetEY = -halfAfter; - } - vx = 1; - vy = -1; - nx = 0; - ny = 1; - if (bRound) { - sx = bInverted ? 0 : FX_PI / 2; - } else { - sx = 0; - sy = -1; - } - break; - } - if (bStart) { - path.MoveTo(cpStart); - } - if (nIndex & 1) { - path.LineTo(CFX_PointF(cp2.x + fRadius2 * nx + offsetEX, - cp2.y + fRadius2 * ny + offsetEY)); - return; - } - if (bRound) { - if (fRadius1 < 0) - sx -= FX_PI; - if (bInverted) - sy *= -1; - - CFX_RectF rtRadius(cp1.x + offsetX * 2, cp1.y + offsetY * 2, - fRadius1 * 2 * vx - offsetX * 2, - fRadius1 * 2 * vy - offsetY * 2); - rtRadius.Normalize(); - if (bInverted) - rtRadius.Offset(-fRadius1 * vx, -fRadius1 * vy); - - path.ArcTo(rtRadius.TopLeft(), rtRadius.Size(), sx, sy); - } else { - CFX_PointF cp; - if (bInverted) { - cp.x = cp1.x + fRadius1 * vx; - cp.y = cp1.y + fRadius1 * vy; - } else { - cp = cp1; - } - path.LineTo(cp); - path.LineTo(CFX_PointF(cp1.x + fRadius1 * sx + offsetX, - cp1.y + fRadius1 * sy + offsetY)); - } -} -static void XFA_BOX_GetFillPath(CXFA_Box box, - const std::vector& strokes, - CFX_RectF rtWidget, - CFX_Path& fillPath, - uint16_t dwFlags) { - if (box.IsArc() || (dwFlags & XFA_DRAWBOX_ForceRound) != 0) { - CXFA_Edge edge = box.GetEdge(0); - float fThickness = edge.GetThickness(); - if (fThickness < 0) { - fThickness = 0; - } - float fHalf = fThickness / 2; - int32_t iHand = box.GetHand(); - if (iHand == XFA_ATTRIBUTEENUM_Left) { - rtWidget.Inflate(fHalf, fHalf); - } else if (iHand == XFA_ATTRIBUTEENUM_Right) { - rtWidget.Deflate(fHalf, fHalf); - } - XFA_BOX_GetPath_Arc(box, rtWidget, fillPath, dwFlags); - return; - } - bool bSameStyles = true; - CXFA_Stroke stroke1 = strokes[0]; - for (int32_t i = 1; i < 8; i++) { - CXFA_Stroke stroke2 = strokes[i]; - if (!stroke1.SameStyles(stroke2)) { - bSameStyles = false; - break; - } - stroke1 = stroke2; - } - if (bSameStyles) { - stroke1 = strokes[0]; - for (int32_t i = 2; i < 8; i += 2) { - CXFA_Stroke stroke2 = strokes[i]; - if (!stroke1.SameStyles(stroke2, XFA_STROKE_SAMESTYLE_NoPresence | - XFA_STROKE_SAMESTYLE_Corner)) { - bSameStyles = false; - break; - } - stroke1 = stroke2; - } - if (bSameStyles) { - stroke1 = strokes[0]; - if (stroke1.IsInverted()) { - bSameStyles = false; - } - if (stroke1.GetJoinType() != XFA_ATTRIBUTEENUM_Square) { - bSameStyles = false; - } - } - } - if (bSameStyles) { - fillPath.AddRectangle(rtWidget.left, rtWidget.top, rtWidget.width, - rtWidget.height); - return; - } - - for (int32_t i = 0; i < 8; i += 2) { - float sx = 0.0f; - float sy = 0.0f; - float vx = 1.0f; - float vy = 1.0f; - float nx = 1.0f; - float ny = 1.0f; - CFX_PointF cp1, cp2; - CXFA_Corner corner1(strokes[i].GetNode()); - CXFA_Corner corner2(strokes[(i + 2) % 8].GetNode()); - float fRadius1 = corner1.GetRadius(); - float fRadius2 = corner2.GetRadius(); - bool bInverted = corner1.IsInverted(); - bool bRound = corner1.GetJoinType() == XFA_ATTRIBUTEENUM_Round; - if (bRound) { - sy = FX_PI / 2; - } - switch (i) { - case 0: - cp1 = rtWidget.TopLeft(); - cp2 = rtWidget.TopRight(); - vx = 1, vy = 1; - nx = -1, ny = 0; - if (bRound) { - sx = bInverted ? FX_PI / 2 : FX_PI; - } else { - sx = 1, sy = 0; - } - break; - case 2: - cp1 = rtWidget.TopRight(); - cp2 = rtWidget.BottomRight(); - vx = -1, vy = 1; - nx = 0, ny = -1; - if (bRound) { - sx = bInverted ? FX_PI : FX_PI * 3 / 2; - } else { - sx = 0, sy = 1; - } - break; - case 4: - cp1 = rtWidget.BottomRight(); - cp2 = rtWidget.BottomLeft(); - vx = -1, vy = -1; - nx = 1, ny = 0; - if (bRound) { - sx = bInverted ? FX_PI * 3 / 2 : 0; - } else { - sx = -1, sy = 0; - } - break; - case 6: - cp1 = rtWidget.BottomLeft(); - cp2 = rtWidget.TopLeft(); - vx = 1, vy = -1; - nx = 0, ny = 1; - if (bRound) { - sx = bInverted ? 0 : FX_PI / 2; - } else { - sx = 0; - sy = -1; - } - break; - } - if (i == 0) - fillPath.MoveTo(CFX_PointF(cp1.x, cp1.y + fRadius1)); - - if (bRound) { - if (fRadius1 < 0) - sx -= FX_PI; - if (bInverted) - sy *= -1; - - CFX_RectF rtRadius(cp1.x, cp1.y, fRadius1 * 2 * vx, fRadius1 * 2 * vy); - rtRadius.Normalize(); - if (bInverted) - rtRadius.Offset(-fRadius1 * vx, -fRadius1 * vy); - - fillPath.ArcTo(rtRadius.TopLeft(), rtRadius.Size(), sx, sy); - } else { - CFX_PointF cp; - if (bInverted) { - cp.x = cp1.x + fRadius1 * vx; - cp.y = cp1.y + fRadius1 * vy; - } else { - cp = cp1; - } - fillPath.LineTo(cp); - fillPath.LineTo(CFX_PointF(cp1.x + fRadius1 * sx, cp1.y + fRadius1 * sy)); - } - fillPath.LineTo(CFX_PointF(cp2.x + fRadius2 * nx, cp2.y + fRadius2 * ny)); - } -} -static void XFA_BOX_Fill_Radial(CXFA_Box box, - CFX_Graphics* pGS, - CFX_Path& fillPath, - CFX_RectF rtFill, - CFX_Matrix* pMatrix) { - CXFA_Fill fill = box.GetFill(); - FX_ARGB crStart, crEnd; - crStart = fill.GetColor(); - int32_t iType = fill.GetRadial(crEnd); - if (iType != XFA_ATTRIBUTEENUM_ToEdge) { - FX_ARGB temp = crEnd; - crEnd = crStart; - crStart = temp; - } - CFX_Shading shading(rtFill.Center(), rtFill.Center(), 0, - FXSYS_sqrt(rtFill.Width() * rtFill.Width() + - rtFill.Height() * rtFill.Height()) / - 2, - true, true, crStart, crEnd); - CFX_Color cr(&shading); - pGS->SetFillColor(&cr); - pGS->FillPath(&fillPath, FXFILL_WINDING, pMatrix); -} -static void XFA_BOX_Fill_Pattern(CXFA_Box box, - CFX_Graphics* pGS, - CFX_Path& fillPath, - CFX_RectF rtFill, - CFX_Matrix* pMatrix) { - CXFA_Fill fill = box.GetFill(); - FX_ARGB crStart, crEnd; - crStart = fill.GetColor(); - int32_t iType = fill.GetPattern(crEnd); - FX_HatchStyle iHatch = FX_HatchStyle::Cross; - switch (iType) { - case XFA_ATTRIBUTEENUM_CrossDiagonal: - iHatch = FX_HatchStyle::DiagonalCross; - break; - case XFA_ATTRIBUTEENUM_DiagonalLeft: - iHatch = FX_HatchStyle::ForwardDiagonal; - break; - case XFA_ATTRIBUTEENUM_DiagonalRight: - iHatch = FX_HatchStyle::BackwardDiagonal; - break; - case XFA_ATTRIBUTEENUM_Horizontal: - iHatch = FX_HatchStyle::Horizontal; - break; - case XFA_ATTRIBUTEENUM_Vertical: - iHatch = FX_HatchStyle::Vertical; - break; - default: - break; - } - - CFX_Pattern pattern(iHatch, crEnd, crStart); - CFX_Color cr(&pattern, 0x0); - pGS->SetFillColor(&cr); - pGS->FillPath(&fillPath, FXFILL_WINDING, pMatrix); -} -static void XFA_BOX_Fill_Linear(CXFA_Box box, - CFX_Graphics* pGS, - CFX_Path& fillPath, - CFX_RectF rtFill, - CFX_Matrix* pMatrix) { - CXFA_Fill fill = box.GetFill(); - FX_ARGB crStart = fill.GetColor(); - FX_ARGB crEnd; - int32_t iType = fill.GetLinear(crEnd); - CFX_PointF ptStart; - CFX_PointF ptEnd; - switch (iType) { - case XFA_ATTRIBUTEENUM_ToRight: - ptStart = CFX_PointF(rtFill.left, rtFill.top); - ptEnd = CFX_PointF(rtFill.right(), rtFill.top); - break; - case XFA_ATTRIBUTEENUM_ToBottom: - ptStart = CFX_PointF(rtFill.left, rtFill.top); - ptEnd = CFX_PointF(rtFill.left, rtFill.bottom()); - break; - case XFA_ATTRIBUTEENUM_ToLeft: - ptStart = CFX_PointF(rtFill.right(), rtFill.top); - ptEnd = CFX_PointF(rtFill.left, rtFill.top); - break; - case XFA_ATTRIBUTEENUM_ToTop: - ptStart = CFX_PointF(rtFill.left, rtFill.bottom()); - ptEnd = CFX_PointF(rtFill.left, rtFill.top); - break; - default: - break; - } - CFX_Shading shading(ptStart, ptEnd, false, false, crStart, crEnd); - CFX_Color cr(&shading); - pGS->SetFillColor(&cr); - pGS->FillPath(&fillPath, FXFILL_WINDING, pMatrix); -} -static void XFA_BOX_Fill(CXFA_Box box, - const std::vector& strokes, - CFX_Graphics* pGS, - const CFX_RectF& rtWidget, - CFX_Matrix* pMatrix, - uint32_t dwFlags) { - CXFA_Fill fill = box.GetFill(); - if (!fill || fill.GetPresence() != XFA_ATTRIBUTEENUM_Visible) - return; - - pGS->SaveGraphState(); - CFX_Path fillPath; - XFA_BOX_GetFillPath(box, strokes, rtWidget, fillPath, - (dwFlags & XFA_DRAWBOX_ForceRound) != 0); - fillPath.Close(); - XFA_Element eType = fill.GetFillType(); - switch (eType) { - case XFA_Element::Radial: - XFA_BOX_Fill_Radial(box, pGS, fillPath, rtWidget, pMatrix); - break; - case XFA_Element::Pattern: - XFA_BOX_Fill_Pattern(box, pGS, fillPath, rtWidget, pMatrix); - break; - case XFA_Element::Linear: - XFA_BOX_Fill_Linear(box, pGS, fillPath, rtWidget, pMatrix); - break; - default: { - FX_ARGB cr; - if (eType == XFA_Element::Stipple) { - int32_t iRate = fill.GetStipple(cr); - if (iRate == 0) { - iRate = 100; - } - int32_t a = 0; - FX_COLORREF rgb; - ArgbDecode(cr, a, rgb); - cr = ArgbEncode(iRate * a / 100, rgb); - } else { - cr = fill.GetColor(); - } - CFX_Color fillColor(cr); - pGS->SetFillColor(&fillColor); - pGS->FillPath(&fillPath, FXFILL_WINDING, pMatrix); - } break; - } - pGS->RestoreGraphState(); -} -static void XFA_BOX_StrokePath(CXFA_Stroke stroke, - CFX_Path* pPath, - CFX_Graphics* pGS, - CFX_Matrix* pMatrix) { - if (!stroke || !stroke.IsVisible()) { - return; - } - float fThickness = stroke.GetThickness(); - if (fThickness < 0.001f) { - return; - } - pGS->SaveGraphState(); - if (stroke.IsCorner() && fThickness > 2 * stroke.GetRadius()) { - fThickness = 2 * stroke.GetRadius(); - } - pGS->SetLineWidth(fThickness, true); - pGS->SetLineCap(CFX_GraphStateData::LineCapButt); - XFA_StrokeTypeSetLineDash(pGS, stroke.GetStrokeType(), - XFA_ATTRIBUTEENUM_Butt); - CFX_Color fxColor(stroke.GetColor()); - pGS->SetStrokeColor(&fxColor); - pGS->StrokePath(pPath, pMatrix); - pGS->RestoreGraphState(); -} -static void XFA_BOX_StrokeArc(CXFA_Box box, - CFX_Graphics* pGS, - CFX_RectF rtWidget, - CFX_Matrix* pMatrix, - uint32_t dwFlags) { - CXFA_Edge edge = box.GetEdge(0); - if (!edge || !edge.IsVisible()) { - return; - } - bool bVisible = false; - float fThickness = 0; - int32_t i3DType = box.Get3DStyle(bVisible, fThickness); - if (i3DType) { - if (bVisible && fThickness >= 0.001f) { - dwFlags |= XFA_DRAWBOX_Lowered3D; - } - } - float fHalf = edge.GetThickness() / 2; - if (fHalf < 0) { - fHalf = 0; - } - int32_t iHand = box.GetHand(); - if (iHand == XFA_ATTRIBUTEENUM_Left) { - rtWidget.Inflate(fHalf, fHalf); - } else if (iHand == XFA_ATTRIBUTEENUM_Right) { - rtWidget.Deflate(fHalf, fHalf); - } - if ((dwFlags & XFA_DRAWBOX_ForceRound) == 0 || - (dwFlags & XFA_DRAWBOX_Lowered3D) == 0) { - if (fHalf < 0.001f) - return; - - CFX_Path arcPath; - XFA_BOX_GetPath_Arc(box, rtWidget, arcPath, dwFlags); - XFA_BOX_StrokePath(edge, &arcPath, pGS, pMatrix); - return; - } - pGS->SaveGraphState(); - pGS->SetLineWidth(fHalf); - - float a, b; - a = rtWidget.width / 2.0f; - b = rtWidget.height / 2.0f; - if (dwFlags & XFA_DRAWBOX_ForceRound) { - a = std::min(a, b); - b = a; - } - - CFX_PointF center = rtWidget.Center(); - rtWidget.left = center.x - a; - rtWidget.top = center.y - b; - rtWidget.width = a + a; - rtWidget.height = b + b; - - float startAngle = 0, sweepAngle = 360; - startAngle = startAngle * FX_PI / 180.0f; - sweepAngle = -sweepAngle * FX_PI / 180.0f; - - CFX_Path arcPath; - arcPath.AddArc(rtWidget.TopLeft(), rtWidget.Size(), 3.0f * FX_PI / 4.0f, - FX_PI); - - CFX_Color cr(0xFF808080); - pGS->SetStrokeColor(&cr); - pGS->StrokePath(&arcPath, pMatrix); - arcPath.Clear(); - arcPath.AddArc(rtWidget.TopLeft(), rtWidget.Size(), -1.0f * FX_PI / 4.0f, - FX_PI); - - cr.Set(0xFFFFFFFF); - pGS->SetStrokeColor(&cr); - pGS->StrokePath(&arcPath, pMatrix); - rtWidget.Deflate(fHalf, fHalf); - arcPath.Clear(); - arcPath.AddArc(rtWidget.TopLeft(), rtWidget.Size(), 3.0f * FX_PI / 4.0f, - FX_PI); - - cr.Set(0xFF404040); - pGS->SetStrokeColor(&cr); - pGS->StrokePath(&arcPath, pMatrix); - arcPath.Clear(); - arcPath.AddArc(rtWidget.TopLeft(), rtWidget.Size(), -1.0f * FX_PI / 4.0f, - FX_PI); - - cr.Set(0xFFC0C0C0); - pGS->SetStrokeColor(&cr); - pGS->StrokePath(&arcPath, pMatrix); - pGS->RestoreGraphState(); -} -static void XFA_Draw3DRect(CFX_Graphics* pGraphic, - const CFX_RectF& rt, - float fLineWidth, - CFX_Matrix* pMatrix, - FX_ARGB argbTopLeft, - FX_ARGB argbBottomRight) { - CFX_Color crLT(argbTopLeft); - pGraphic->SetFillColor(&crLT); - float fBottom = rt.bottom(); - float fRight = rt.right(); - CFX_Path pathLT; - pathLT.MoveTo(CFX_PointF(rt.left, fBottom)); - pathLT.LineTo(CFX_PointF(rt.left, rt.top)); - pathLT.LineTo(CFX_PointF(fRight, rt.top)); - pathLT.LineTo(CFX_PointF(fRight - fLineWidth, rt.top + fLineWidth)); - pathLT.LineTo(CFX_PointF(rt.left + fLineWidth, rt.top + fLineWidth)); - pathLT.LineTo(CFX_PointF(rt.left + fLineWidth, fBottom - fLineWidth)); - pathLT.LineTo(CFX_PointF(rt.left, fBottom)); - pGraphic->FillPath(&pathLT, FXFILL_WINDING, pMatrix); - - CFX_Color crRB(argbBottomRight); - pGraphic->SetFillColor(&crRB); - - CFX_Path pathRB; - pathRB.MoveTo(CFX_PointF(fRight, rt.top)); - pathRB.LineTo(CFX_PointF(fRight, fBottom)); - pathRB.LineTo(CFX_PointF(rt.left, fBottom)); - pathRB.LineTo(CFX_PointF(rt.left + fLineWidth, fBottom - fLineWidth)); - pathRB.LineTo(CFX_PointF(fRight - fLineWidth, fBottom - fLineWidth)); - pathRB.LineTo(CFX_PointF(fRight - fLineWidth, rt.top + fLineWidth)); - pathRB.LineTo(CFX_PointF(fRight, rt.top)); - pGraphic->FillPath(&pathRB, FXFILL_WINDING, pMatrix); -} -static void XFA_BOX_Stroke_3DRect_Lowered(CFX_Graphics* pGS, - CFX_RectF rt, - float fThickness, - CFX_Matrix* pMatrix) { - float fHalfWidth = fThickness / 2.0f; - CFX_RectF rtInner(rt); - rtInner.Deflate(fHalfWidth, fHalfWidth); - CFX_Color cr(0xFF000000); - pGS->SetFillColor(&cr); - CFX_Path path; - path.AddRectangle(rt.left, rt.top, rt.width, rt.height); - path.AddRectangle(rtInner.left, rtInner.top, rtInner.width, rtInner.height); - pGS->FillPath(&path, FXFILL_ALTERNATE, pMatrix); - XFA_Draw3DRect(pGS, rtInner, fHalfWidth, pMatrix, 0xFF808080, 0xFFC0C0C0); -} -static void XFA_BOX_Stroke_3DRect_Raised(CFX_Graphics* pGS, - CFX_RectF rt, - float fThickness, - CFX_Matrix* pMatrix) { - float fHalfWidth = fThickness / 2.0f; - CFX_RectF rtInner(rt); - rtInner.Deflate(fHalfWidth, fHalfWidth); - CFX_Color cr(0xFF000000); - pGS->SetFillColor(&cr); - CFX_Path path; - path.AddRectangle(rt.left, rt.top, rt.width, rt.height); - path.AddRectangle(rtInner.left, rtInner.top, rtInner.width, rtInner.height); - pGS->FillPath(&path, FXFILL_ALTERNATE, pMatrix); - XFA_Draw3DRect(pGS, rtInner, fHalfWidth, pMatrix, 0xFFFFFFFF, 0xFF808080); -} -static void XFA_BOX_Stroke_3DRect_Etched(CFX_Graphics* pGS, - CFX_RectF rt, - float fThickness, - CFX_Matrix* pMatrix) { - float fHalfWidth = fThickness / 2.0f; - XFA_Draw3DRect(pGS, rt, fThickness, pMatrix, 0xFF808080, 0xFFFFFFFF); - CFX_RectF rtInner(rt); - rtInner.Deflate(fHalfWidth, fHalfWidth); - XFA_Draw3DRect(pGS, rtInner, fHalfWidth, pMatrix, 0xFFFFFFFF, 0xFF808080); -} -static void XFA_BOX_Stroke_3DRect_Embossed(CFX_Graphics* pGS, - CFX_RectF rt, - float fThickness, - CFX_Matrix* pMatrix) { - float fHalfWidth = fThickness / 2.0f; - XFA_Draw3DRect(pGS, rt, fThickness, pMatrix, 0xFF808080, 0xFF000000); - CFX_RectF rtInner(rt); - rtInner.Deflate(fHalfWidth, fHalfWidth); - XFA_Draw3DRect(pGS, rtInner, fHalfWidth, pMatrix, 0xFF000000, 0xFF808080); -} -static void XFA_BOX_Stroke_Rect(CXFA_Box box, - const std::vector& strokes, - CFX_Graphics* pGS, - CFX_RectF rtWidget, - CFX_Matrix* pMatrix) { - bool bVisible = false; - float fThickness = 0; - int32_t i3DType = box.Get3DStyle(bVisible, fThickness); - if (i3DType) { - if (!bVisible || fThickness < 0.001f) { - return; - } - switch (i3DType) { - case XFA_ATTRIBUTEENUM_Lowered: - XFA_BOX_Stroke_3DRect_Lowered(pGS, rtWidget, fThickness, pMatrix); - break; - case XFA_ATTRIBUTEENUM_Raised: - XFA_BOX_Stroke_3DRect_Raised(pGS, rtWidget, fThickness, pMatrix); - break; - case XFA_ATTRIBUTEENUM_Etched: - XFA_BOX_Stroke_3DRect_Etched(pGS, rtWidget, fThickness, pMatrix); - break; - case XFA_ATTRIBUTEENUM_Embossed: - XFA_BOX_Stroke_3DRect_Embossed(pGS, rtWidget, fThickness, pMatrix); - break; - } - return; - } - bool bClose = false; - bool bSameStyles = true; - CXFA_Stroke stroke1 = strokes[0]; - for (int32_t i = 1; i < 8; i++) { - CXFA_Stroke stroke2 = strokes[i]; - if (!stroke1.SameStyles(stroke2)) { - bSameStyles = false; - break; - } - stroke1 = stroke2; - } - if (bSameStyles) { - stroke1 = strokes[0]; - bClose = true; - for (int32_t i = 2; i < 8; i += 2) { - CXFA_Stroke stroke2 = strokes[i]; - if (!stroke1.SameStyles(stroke2, XFA_STROKE_SAMESTYLE_NoPresence | - XFA_STROKE_SAMESTYLE_Corner)) { - bSameStyles = false; - break; - } - stroke1 = stroke2; - } - if (bSameStyles) { - stroke1 = strokes[0]; - if (stroke1.IsInverted()) - bSameStyles = false; - if (stroke1.GetJoinType() != XFA_ATTRIBUTEENUM_Square) - bSameStyles = false; - } - } - bool bStart = true; - CFX_Path path; - for (int32_t i = 0; i < 8; i++) { - CXFA_Stroke stroke = strokes[i]; - if ((i % 1) == 0 && stroke.GetRadius() < 0) { - bool bEmpty = path.IsEmpty(); - if (!bEmpty) { - XFA_BOX_StrokePath(stroke, &path, pGS, pMatrix); - path.Clear(); - } - bStart = true; - continue; - } - XFA_BOX_GetPath(box, strokes, rtWidget, path, i, bStart, !bSameStyles); - CXFA_Stroke stroke2 = strokes[(i + 1) % 8]; - bStart = !stroke.SameStyles(stroke2); - if (bStart) { - XFA_BOX_StrokePath(stroke, &path, pGS, pMatrix); - path.Clear(); - } - } - bool bEmpty = path.IsEmpty(); - if (!bEmpty) { - if (bClose) { - path.Close(); - } - XFA_BOX_StrokePath(strokes[7], &path, pGS, pMatrix); - } -} -static void XFA_BOX_Stroke(CXFA_Box box, - const std::vector& strokes, - CFX_Graphics* pGS, - CFX_RectF rtWidget, - CFX_Matrix* pMatrix, - uint32_t dwFlags) { - if (box.IsArc() || (dwFlags & XFA_DRAWBOX_ForceRound) != 0) { - XFA_BOX_StrokeArc(box, pGS, rtWidget, pMatrix, dwFlags); - return; - } - bool bVisible = false; - for (int32_t j = 0; j < 4; j++) { - if (strokes[j * 2 + 1].IsVisible()) { - bVisible = true; - break; - } - } - if (!bVisible) { - return; - } - for (int32_t i = 1; i < 8; i += 2) { - CXFA_Edge edge(strokes[i].GetNode()); - float fThickness = edge.GetThickness(); - if (fThickness < 0) { - fThickness = 0; - } - float fHalf = fThickness / 2; - int32_t iHand = box.GetHand(); - switch (i) { - case 1: - if (iHand == XFA_ATTRIBUTEENUM_Left) { - rtWidget.top -= fHalf; - rtWidget.height += fHalf; - } else if (iHand == XFA_ATTRIBUTEENUM_Right) { - rtWidget.top += fHalf; - rtWidget.height -= fHalf; - } - break; - case 3: - if (iHand == XFA_ATTRIBUTEENUM_Left) { - rtWidget.width += fHalf; - } else if (iHand == XFA_ATTRIBUTEENUM_Right) { - rtWidget.width -= fHalf; - } - break; - case 5: - if (iHand == XFA_ATTRIBUTEENUM_Left) { - rtWidget.height += fHalf; - } else if (iHand == XFA_ATTRIBUTEENUM_Right) { - rtWidget.height -= fHalf; - } - break; - case 7: - if (iHand == XFA_ATTRIBUTEENUM_Left) { - rtWidget.left -= fHalf; - rtWidget.width += fHalf; - } else if (iHand == XFA_ATTRIBUTEENUM_Right) { - rtWidget.left += fHalf; - rtWidget.width -= fHalf; - } - break; - } - } - XFA_BOX_Stroke_Rect(box, strokes, pGS, rtWidget, pMatrix); -} -void XFA_DrawBox(CXFA_Box box, - CFX_Graphics* pGS, - const CFX_RectF& rtWidget, - CFX_Matrix* pMatrix, - uint32_t dwFlags) { - if (!box || box.GetPresence() != XFA_ATTRIBUTEENUM_Visible) - return; - - XFA_Element eType = box.GetElementType(); - if (eType != XFA_Element::Arc && eType != XFA_Element::Border && - eType != XFA_Element::Rectangle) { - return; - } - std::vector strokes; - if (!(dwFlags & XFA_DRAWBOX_ForceRound) && eType != XFA_Element::Arc) - box.GetStrokes(&strokes); - - XFA_BOX_Fill(box, strokes, pGS, rtWidget, pMatrix, dwFlags); - XFA_BOX_Stroke(box, strokes, pGS, rtWidget, pMatrix, dwFlags); -} - -CXFA_CalcData::CXFA_CalcData() : m_iRefCount(0) {} - -CXFA_CalcData::~CXFA_CalcData() {} diff --git a/xfa/fxfa/app/xfa_ffwidgetacc.cpp b/xfa/fxfa/app/xfa_ffwidgetacc.cpp index 4afd5e8023..9b531ed4fc 100644 --- a/xfa/fxfa/app/xfa_ffwidgetacc.cpp +++ b/xfa/fxfa/app/xfa_ffwidgetacc.cpp @@ -20,1503 +20,17 @@ #include "xfa/fxfa/app/xfa_fffield.h" #include "xfa/fxfa/app/xfa_fwladapter.h" #include "xfa/fxfa/cxfa_eventparam.h" +#include "xfa/fxfa/cxfa_ffapp.h" +#include "xfa/fxfa/cxfa_ffdoc.h" +#include "xfa/fxfa/cxfa_ffdocview.h" +#include "xfa/fxfa/cxfa_ffpageview.h" +#include "xfa/fxfa/cxfa_ffwidget.h" +#include "xfa/fxfa/cxfa_fontmgr.h" #include "xfa/fxfa/parser/cxfa_layoutprocessor.h" #include "xfa/fxfa/parser/cxfa_scriptcontext.h" #include "xfa/fxfa/parser/xfa_localevalue.h" #include "xfa/fxfa/parser/xfa_resolvenode_rs.h" -#include "xfa/fxfa/xfa_ffapp.h" -#include "xfa/fxfa/xfa_ffdoc.h" -#include "xfa/fxfa/xfa_ffdocview.h" -#include "xfa/fxfa/xfa_ffpageview.h" -#include "xfa/fxfa/xfa_ffwidget.h" -#include "xfa/fxfa/xfa_fontmgr.h" -static void XFA_FFDeleteCalcData(void* pData) { - if (pData) { - delete ((CXFA_CalcData*)pData); - } -} - -static XFA_MAPDATABLOCKCALLBACKINFO gs_XFADeleteCalcData = { - XFA_FFDeleteCalcData, nullptr}; - -class CXFA_WidgetLayoutData { - public: - CXFA_WidgetLayoutData() : m_fWidgetHeight(-1) {} - virtual ~CXFA_WidgetLayoutData() {} - - float m_fWidgetHeight; -}; - -class CXFA_TextLayoutData : public CXFA_WidgetLayoutData { - public: - CXFA_TextLayoutData() {} - ~CXFA_TextLayoutData() override {} - - CXFA_TextLayout* GetTextLayout() const { return m_pTextLayout.get(); } - CXFA_TextProvider* GetTextProvider() const { return m_pTextProvider.get(); } - - void LoadText(CXFA_WidgetAcc* pAcc) { - if (m_pTextLayout) - return; - - m_pTextProvider = - pdfium::MakeUnique(pAcc, XFA_TEXTPROVIDERTYPE_Text); - m_pTextLayout = pdfium::MakeUnique(m_pTextProvider.get()); - } - - private: - std::unique_ptr m_pTextLayout; - std::unique_ptr m_pTextProvider; -}; - -class CXFA_ImageLayoutData : public CXFA_WidgetLayoutData { - public: - CXFA_ImageLayoutData() - : m_pDIBitmap(nullptr), - m_bNamedImage(false), - m_iImageXDpi(0), - m_iImageYDpi(0) {} - - ~CXFA_ImageLayoutData() override { - if (m_pDIBitmap && !m_bNamedImage) - delete m_pDIBitmap; - } - - bool LoadImageData(CXFA_WidgetAcc* pAcc) { - if (m_pDIBitmap) - return true; - - CXFA_Value value = pAcc->GetFormValue(); - if (!value) - return false; - - CXFA_Image imageObj = value.GetImage(); - if (!imageObj) - return false; - - CXFA_FFDoc* pFFDoc = pAcc->GetDoc(); - pAcc->SetImageImage(XFA_LoadImageData(pFFDoc, &imageObj, m_bNamedImage, - m_iImageXDpi, m_iImageYDpi)); - return !!m_pDIBitmap; - } - - CFX_DIBitmap* m_pDIBitmap; - bool m_bNamedImage; - int32_t m_iImageXDpi; - int32_t m_iImageYDpi; -}; - -class CXFA_FieldLayoutData : public CXFA_WidgetLayoutData { - public: - CXFA_FieldLayoutData() {} - ~CXFA_FieldLayoutData() override {} - - bool LoadCaption(CXFA_WidgetAcc* pAcc) { - if (m_pCapTextLayout) - return true; - CXFA_Caption caption = pAcc->GetCaption(); - if (!caption || caption.GetPresence() == XFA_ATTRIBUTEENUM_Hidden) - return false; - m_pCapTextProvider.reset( - new CXFA_TextProvider(pAcc, XFA_TEXTPROVIDERTYPE_Caption)); - m_pCapTextLayout = - pdfium::MakeUnique(m_pCapTextProvider.get()); - return true; - } - - std::unique_ptr m_pCapTextLayout; - std::unique_ptr m_pCapTextProvider; - std::unique_ptr m_pTextOut; - std::vector m_FieldSplitArray; -}; - -class CXFA_TextEditData : public CXFA_FieldLayoutData { - public: -}; - -class CXFA_ImageEditData : public CXFA_FieldLayoutData { - public: - CXFA_ImageEditData() - : m_pDIBitmap(nullptr), - m_bNamedImage(false), - m_iImageXDpi(0), - m_iImageYDpi(0) {} - - ~CXFA_ImageEditData() override { - if (m_pDIBitmap && !m_bNamedImage) - delete m_pDIBitmap; - } - - bool LoadImageData(CXFA_WidgetAcc* pAcc) { - if (m_pDIBitmap) - return true; - - CXFA_Value value = pAcc->GetFormValue(); - if (!value) - return false; - - CXFA_Image imageObj = value.GetImage(); - CXFA_FFDoc* pFFDoc = pAcc->GetDoc(); - pAcc->SetImageEditImage(XFA_LoadImageData(pFFDoc, &imageObj, m_bNamedImage, - m_iImageXDpi, m_iImageYDpi)); - return !!m_pDIBitmap; - } - - CFX_DIBitmap* m_pDIBitmap; - bool m_bNamedImage; - int32_t m_iImageXDpi; - int32_t m_iImageYDpi; -}; - -CXFA_WidgetAcc::CXFA_WidgetAcc(CXFA_FFDocView* pDocView, CXFA_Node* pNode) - : CXFA_WidgetData(pNode), - m_pDocView(pDocView), - m_nRecursionDepth(0) {} - -CXFA_WidgetAcc::~CXFA_WidgetAcc() {} - -bool CXFA_WidgetAcc::GetName(CFX_WideString& wsName, int32_t iNameType) { - if (iNameType == 0) { - m_pNode->TryCData(XFA_ATTRIBUTE_Name, wsName); - return !wsName.IsEmpty(); - } - m_pNode->GetSOMExpression(wsName); - if (iNameType == 2 && wsName.GetLength() >= 15) { - CFX_WideStringC wsPre = L"xfa[0].form[0]."; - if (wsPre == CFX_WideStringC(wsName.c_str(), wsPre.GetLength())) { - wsName.Delete(0, wsPre.GetLength()); - } - } - return true; -} -CXFA_Node* CXFA_WidgetAcc::GetDatasets() { - return m_pNode->GetBindData(); -} -bool CXFA_WidgetAcc::ProcessValueChanged() { - m_pDocView->AddValidateWidget(this); - m_pDocView->AddCalculateWidgetAcc(this); - m_pDocView->RunCalculateWidgets(); - m_pDocView->RunValidate(); - return true; -} -void CXFA_WidgetAcc::ResetData() { - CFX_WideString wsValue; - XFA_Element eUIType = GetUIType(); - switch (eUIType) { - case XFA_Element::ImageEdit: { - CXFA_Value imageValue = GetDefaultValue(); - CXFA_Image image = imageValue.GetImage(); - CFX_WideString wsContentType, wsHref; - if (image) { - image.GetContent(wsValue); - image.GetContentType(wsContentType); - image.GetHref(wsHref); - } - SetImageEdit(wsContentType, wsHref, wsValue); - } break; - case XFA_Element::ExclGroup: { - CXFA_Node* pNextChild = m_pNode->GetNodeItem( - XFA_NODEITEM_FirstChild, XFA_ObjectType::ContainerNode); - while (pNextChild) { - CXFA_Node* pChild = pNextChild; - CXFA_WidgetAcc* pAcc = - static_cast(pChild->GetWidgetData()); - if (!pAcc) { - continue; - } - CXFA_Value defValue(nullptr); - if (wsValue.IsEmpty() && (defValue = pAcc->GetDefaultValue())) { - defValue.GetChildValueContent(wsValue); - SetValue(wsValue, XFA_VALUEPICTURE_Raw); - pAcc->SetValue(wsValue, XFA_VALUEPICTURE_Raw); - } else { - CXFA_Node* pItems = pChild->GetChild(0, XFA_Element::Items); - if (!pItems) { - continue; - } - CFX_WideString itemText; - if (pItems->CountChildren(XFA_Element::Unknown) > 1) { - itemText = pItems->GetChild(1, XFA_Element::Unknown)->GetContent(); - } - pAcc->SetValue(itemText, XFA_VALUEPICTURE_Raw); - } - pNextChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling, - XFA_ObjectType::ContainerNode); - } - } break; - case XFA_Element::ChoiceList: - ClearAllSelections(); - default: - if (CXFA_Value defValue = GetDefaultValue()) { - defValue.GetChildValueContent(wsValue); - } - SetValue(wsValue, XFA_VALUEPICTURE_Raw); - break; - } -} -void CXFA_WidgetAcc::SetImageEdit(const CFX_WideString& wsContentType, - const CFX_WideString& wsHref, - const CFX_WideString& wsData) { - CXFA_Image image = GetFormValue().GetImage(); - if (image) { - image.SetContentType(CFX_WideString(wsContentType)); - image.SetHref(wsHref); - } - CFX_WideString wsFormatValue(wsData); - GetFormatDataValue(wsData, wsFormatValue); - m_pNode->SetContent(wsData, wsFormatValue, true); - CXFA_Node* pBind = GetDatasets(); - if (!pBind) { - image.SetTransferEncoding(XFA_ATTRIBUTEENUM_Base64); - return; - } - pBind->SetCData(XFA_ATTRIBUTE_ContentType, wsContentType); - CXFA_Node* pHrefNode = pBind->GetNodeItem(XFA_NODEITEM_FirstChild); - if (pHrefNode) { - pHrefNode->SetCData(XFA_ATTRIBUTE_Value, wsHref); - } else { - CFDE_XMLNode* pXMLNode = pBind->GetXMLMappingNode(); - ASSERT(pXMLNode && pXMLNode->GetType() == FDE_XMLNODE_Element); - static_cast(pXMLNode)->SetString(L"href", wsHref); - } -} - -CXFA_WidgetAcc* CXFA_WidgetAcc::GetExclGroup() { - CXFA_Node* pExcl = m_pNode->GetNodeItem(XFA_NODEITEM_Parent); - if (!pExcl || pExcl->GetElementType() != XFA_Element::ExclGroup) { - return nullptr; - } - return static_cast(pExcl->GetWidgetData()); -} -CXFA_FFDocView* CXFA_WidgetAcc::GetDocView() { - return m_pDocView; -} -CXFA_FFDoc* CXFA_WidgetAcc::GetDoc() { - return m_pDocView->GetDoc(); -} -CXFA_FFApp* CXFA_WidgetAcc::GetApp() { - return GetDoc()->GetApp(); -} -IXFA_AppProvider* CXFA_WidgetAcc::GetAppProvider() { - return GetApp()->GetAppProvider(); -} -int32_t CXFA_WidgetAcc::ProcessEvent(int32_t iActivity, - CXFA_EventParam* pEventParam) { - if (GetElementType() == XFA_Element::Draw) - return XFA_EVENTERROR_NotExist; - - std::vector eventArray = - GetEventByActivity(iActivity, pEventParam->m_bIsFormReady); - bool first = true; - int32_t iRet = XFA_EVENTERROR_NotExist; - for (CXFA_Node* pNode : eventArray) { - int32_t result = ProcessEvent(CXFA_Event(pNode), pEventParam); - if (first || result == XFA_EVENTERROR_Success) - iRet = result; - first = false; - } - return iRet; -} -int32_t CXFA_WidgetAcc::ProcessEvent(const CXFA_Event& event, - CXFA_EventParam* pEventParam) { - if (!event) - return XFA_EVENTERROR_NotExist; - - switch (event.GetEventType()) { - case XFA_Element::Execute: - break; - case XFA_Element::Script: - return ExecuteScript(event.GetScript(), pEventParam); - case XFA_Element::SignData: - break; - case XFA_Element::Submit: - return GetDoc()->GetDocEnvironment()->SubmitData(GetDoc(), - event.GetSubmit()); - default: - break; - } - return XFA_EVENTERROR_NotExist; -} - -int32_t CXFA_WidgetAcc::ProcessCalculate() { - if (GetElementType() == XFA_Element::Draw) - return XFA_EVENTERROR_NotExist; - - CXFA_Calculate calc = GetCalculate(); - if (!calc) - return XFA_EVENTERROR_NotExist; - if (GetNode()->IsUserInteractive()) - return XFA_EVENTERROR_Disabled; - - CXFA_EventParam EventParam; - EventParam.m_eType = XFA_EVENT_Calculate; - CXFA_Script script = calc.GetScript(); - int32_t iRet = ExecuteScript(script, &EventParam); - if (iRet != XFA_EVENTERROR_Success) - return iRet; - - if (GetRawValue() != EventParam.m_wsResult) { - SetValue(EventParam.m_wsResult, XFA_VALUEPICTURE_Raw); - UpdateUIDisplay(); - } - return XFA_EVENTERROR_Success; -} - -void CXFA_WidgetAcc::ProcessScriptTestValidate(CXFA_Validate validate, - int32_t iRet, - CFXJSE_Value* pRetValue, - bool bVersionFlag) { - if (iRet == XFA_EVENTERROR_Success && pRetValue) { - if (pRetValue->IsBoolean() && !pRetValue->ToBoolean()) { - IXFA_AppProvider* pAppProvider = GetAppProvider(); - if (!pAppProvider) { - return; - } - CFX_WideString wsTitle = pAppProvider->GetAppTitle(); - CFX_WideString wsScriptMsg; - validate.GetScriptMessageText(wsScriptMsg); - int32_t eScriptTest = validate.GetScriptTest(); - if (eScriptTest == XFA_ATTRIBUTEENUM_Warning) { - if (GetNode()->IsUserInteractive()) - return; - if (wsScriptMsg.IsEmpty()) - wsScriptMsg = GetValidateMessage(false, bVersionFlag); - - if (bVersionFlag) { - pAppProvider->MsgBox(wsScriptMsg, wsTitle, XFA_MBICON_Warning, - XFA_MB_OK); - return; - } - if (pAppProvider->MsgBox(wsScriptMsg, wsTitle, XFA_MBICON_Warning, - XFA_MB_YesNo) == XFA_IDYes) { - GetNode()->SetFlag(XFA_NodeFlag_UserInteractive, false); - } - } else { - if (wsScriptMsg.IsEmpty()) - wsScriptMsg = GetValidateMessage(true, bVersionFlag); - pAppProvider->MsgBox(wsScriptMsg, wsTitle, XFA_MBICON_Error, XFA_MB_OK); - } - } - } -} -int32_t CXFA_WidgetAcc::ProcessFormatTestValidate(CXFA_Validate validate, - bool bVersionFlag) { - CFX_WideString wsRawValue = GetRawValue(); - if (!wsRawValue.IsEmpty()) { - CFX_WideString wsPicture; - validate.GetPicture(wsPicture); - if (wsPicture.IsEmpty()) { - return XFA_EVENTERROR_NotExist; - } - IFX_Locale* pLocale = GetLocal(); - if (!pLocale) { - return XFA_EVENTERROR_NotExist; - } - CXFA_LocaleValue lcValue = XFA_GetLocaleValue(this); - if (!lcValue.ValidateValue(lcValue.GetValue(), wsPicture, pLocale)) { - IXFA_AppProvider* pAppProvider = GetAppProvider(); - if (!pAppProvider) { - return XFA_EVENTERROR_NotExist; - } - CFX_WideString wsFormatMsg; - validate.GetFormatMessageText(wsFormatMsg); - CFX_WideString wsTitle = pAppProvider->GetAppTitle(); - int32_t eFormatTest = validate.GetFormatTest(); - if (eFormatTest == XFA_ATTRIBUTEENUM_Error) { - if (wsFormatMsg.IsEmpty()) - wsFormatMsg = GetValidateMessage(true, bVersionFlag); - pAppProvider->MsgBox(wsFormatMsg, wsTitle, XFA_MBICON_Error, XFA_MB_OK); - return XFA_EVENTERROR_Success; - } - if (GetNode()->IsUserInteractive()) - return XFA_EVENTERROR_NotExist; - if (wsFormatMsg.IsEmpty()) - wsFormatMsg = GetValidateMessage(false, bVersionFlag); - - if (bVersionFlag) { - pAppProvider->MsgBox(wsFormatMsg, wsTitle, XFA_MBICON_Warning, - XFA_MB_OK); - return XFA_EVENTERROR_Success; - } - if (pAppProvider->MsgBox(wsFormatMsg, wsTitle, XFA_MBICON_Warning, - XFA_MB_YesNo) == XFA_IDYes) { - GetNode()->SetFlag(XFA_NodeFlag_UserInteractive, false); - } - return XFA_EVENTERROR_Success; - } - } - return XFA_EVENTERROR_NotExist; -} -int32_t CXFA_WidgetAcc::ProcessNullTestValidate(CXFA_Validate validate, - int32_t iFlags, - bool bVersionFlag) { - CFX_WideString wsValue; - GetValue(wsValue, XFA_VALUEPICTURE_Raw); - if (!wsValue.IsEmpty()) { - return XFA_EVENTERROR_Success; - } - if (m_bIsNull && (m_bPreNull == m_bIsNull)) { - return XFA_EVENTERROR_Success; - } - int32_t eNullTest = validate.GetNullTest(); - CFX_WideString wsNullMsg; - validate.GetNullMessageText(wsNullMsg); - if (iFlags & 0x01) { - int32_t iRet = XFA_EVENTERROR_Success; - if (eNullTest != XFA_ATTRIBUTEENUM_Disabled) { - iRet = XFA_EVENTERROR_Error; - } - if (!wsNullMsg.IsEmpty()) { - if (eNullTest != XFA_ATTRIBUTEENUM_Disabled) { - m_pDocView->m_arrNullTestMsg.push_back(wsNullMsg); - return XFA_EVENTERROR_Error; - } - return XFA_EVENTERROR_Success; - } - return iRet; - } - if (wsNullMsg.IsEmpty() && bVersionFlag && - eNullTest != XFA_ATTRIBUTEENUM_Disabled) { - return XFA_EVENTERROR_Error; - } - IXFA_AppProvider* pAppProvider = GetAppProvider(); - if (!pAppProvider) { - return XFA_EVENTERROR_NotExist; - } - CFX_WideString wsCaptionName; - CFX_WideString wsTitle = pAppProvider->GetAppTitle(); - switch (eNullTest) { - case XFA_ATTRIBUTEENUM_Error: { - if (wsNullMsg.IsEmpty()) { - wsCaptionName = GetValidateCaptionName(bVersionFlag); - wsNullMsg.Format(L"%s cannot be blank.", wsCaptionName.c_str()); - } - pAppProvider->MsgBox(wsNullMsg, wsTitle, XFA_MBICON_Status, XFA_MB_OK); - return XFA_EVENTERROR_Error; - } - case XFA_ATTRIBUTEENUM_Warning: { - if (GetNode()->IsUserInteractive()) - return true; - - if (wsNullMsg.IsEmpty()) { - wsCaptionName = GetValidateCaptionName(bVersionFlag); - wsNullMsg.Format( - L"%s cannot be blank. To ignore validations for %s, click Ignore.", - wsCaptionName.c_str(), wsCaptionName.c_str()); - } - if (pAppProvider->MsgBox(wsNullMsg, wsTitle, XFA_MBICON_Warning, - XFA_MB_YesNo) == XFA_IDYes) { - GetNode()->SetFlag(XFA_NodeFlag_UserInteractive, false); - } - return XFA_EVENTERROR_Error; - } - case XFA_ATTRIBUTEENUM_Disabled: - default: - break; - } - return XFA_EVENTERROR_Success; -} - -CFX_WideString CXFA_WidgetAcc::GetValidateCaptionName(bool bVersionFlag) { - CFX_WideString wsCaptionName; - - if (!bVersionFlag) { - if (CXFA_Caption caption = GetCaption()) { - if (CXFA_Value capValue = caption.GetValue()) { - if (CXFA_Text capText = capValue.GetText()) - capText.GetContent(wsCaptionName); - } - } - } - if (wsCaptionName.IsEmpty()) - GetName(wsCaptionName); - - return wsCaptionName; -} - -CFX_WideString CXFA_WidgetAcc::GetValidateMessage(bool bError, - bool bVersionFlag) { - CFX_WideString wsCaptionName = GetValidateCaptionName(bVersionFlag); - CFX_WideString wsMessage; - if (bVersionFlag) { - wsMessage.Format(L"%s validation failed", wsCaptionName.c_str()); - return wsMessage; - } - if (bError) { - wsMessage.Format(L"The value you entered for %s is invalid.", - wsCaptionName.c_str()); - return wsMessage; - } - wsMessage.Format( - L"The value you entered for %s is invalid. To ignore " - L"validations for %s, click Ignore.", - wsCaptionName.c_str(), wsCaptionName.c_str()); - return wsMessage; -} - -int32_t CXFA_WidgetAcc::ProcessValidate(int32_t iFlags) { - if (GetElementType() == XFA_Element::Draw) { - return XFA_EVENTERROR_NotExist; - } - CXFA_Validate validate = GetValidate(); - if (!validate) { - return XFA_EVENTERROR_NotExist; - } - bool bInitDoc = validate.GetNode()->NeedsInitApp(); - bool bStatus = m_pDocView->GetLayoutStatus() < XFA_DOCVIEW_LAYOUTSTATUS_End; - int32_t iFormat = 0; - CFXJSE_Value* pRetValue = nullptr; - int32_t iRet = XFA_EVENTERROR_NotExist; - CXFA_Script script = validate.GetScript(); - if (script) { - CXFA_EventParam eParam; - eParam.m_eType = XFA_EVENT_Validate; - eParam.m_pTarget = this; - iRet = ExecuteScript(script, &eParam, - ((bInitDoc || bStatus) && GetRawValue().IsEmpty()) - ? nullptr - : &pRetValue); - } - XFA_VERSION version = GetDoc()->GetXFADoc()->GetCurVersionMode(); - bool bVersionFlag = false; - if (version < XFA_VERSION_208) { - bVersionFlag = true; - } - if (bInitDoc) { - validate.GetNode()->ClearFlag(XFA_NodeFlag_NeedsInitApp); - } else { - iFormat = ProcessFormatTestValidate(validate, bVersionFlag); - if (!bVersionFlag) { - bVersionFlag = GetDoc()->GetXFADoc()->HasFlag(XFA_DOCFLAG_Scripting); - } - iRet |= ProcessNullTestValidate(validate, iFlags, bVersionFlag); - } - if (iFormat != XFA_EVENTERROR_Success) { - ProcessScriptTestValidate(validate, iRet, pRetValue, bVersionFlag); - } - delete pRetValue; - - return iRet | iFormat; -} -int32_t CXFA_WidgetAcc::ExecuteScript(CXFA_Script script, - CXFA_EventParam* pEventParam, - CFXJSE_Value** pRetValue) { - static const uint32_t MAX_RECURSION_DEPTH = 2; - if (m_nRecursionDepth > MAX_RECURSION_DEPTH) - return XFA_EVENTERROR_Success; - ASSERT(pEventParam); - if (!script) { - return XFA_EVENTERROR_NotExist; - } - if (script.GetRunAt() == XFA_ATTRIBUTEENUM_Server) { - return XFA_EVENTERROR_Disabled; - } - CFX_WideString wsExpression; - script.GetExpression(wsExpression); - if (wsExpression.IsEmpty()) { - return XFA_EVENTERROR_NotExist; - } - XFA_SCRIPTTYPE eScriptType = script.GetContentType(); - if (eScriptType == XFA_SCRIPTTYPE_Unkown) { - return XFA_EVENTERROR_Success; - } - CXFA_FFDoc* pDoc = GetDoc(); - CXFA_ScriptContext* pContext = pDoc->GetXFADoc()->GetScriptContext(); - pContext->SetEventParam(*pEventParam); - pContext->SetRunAtType((XFA_ATTRIBUTEENUM)script.GetRunAt()); - std::vector refNodes; - if (pEventParam->m_eType == XFA_EVENT_InitCalculate || - pEventParam->m_eType == XFA_EVENT_Calculate) { - pContext->SetNodesOfRunScript(&refNodes); - } - std::unique_ptr pTmpRetValue( - new CFXJSE_Value(pContext->GetRuntime())); - ++m_nRecursionDepth; - bool bRet = pContext->RunScript((XFA_SCRIPTLANGTYPE)eScriptType, - wsExpression.AsStringC(), pTmpRetValue.get(), - m_pNode); - --m_nRecursionDepth; - int32_t iRet = XFA_EVENTERROR_Error; - if (bRet) { - iRet = XFA_EVENTERROR_Success; - if (pEventParam->m_eType == XFA_EVENT_Calculate || - pEventParam->m_eType == XFA_EVENT_InitCalculate) { - if (!pTmpRetValue->IsUndefined()) { - if (!pTmpRetValue->IsNull()) - pEventParam->m_wsResult = pTmpRetValue->ToWideString(); - - iRet = XFA_EVENTERROR_Success; - } else { - iRet = XFA_EVENTERROR_Error; - } - if (pEventParam->m_eType == XFA_EVENT_InitCalculate) { - if ((iRet == XFA_EVENTERROR_Success) && - (GetRawValue() != pEventParam->m_wsResult)) { - SetValue(pEventParam->m_wsResult, XFA_VALUEPICTURE_Raw); - m_pDocView->AddValidateWidget(this); - } - } - for (CXFA_Node* pRefNode : refNodes) { - if (static_cast(pRefNode->GetWidgetData()) == this) - continue; - - auto* pGlobalData = - static_cast(pRefNode->GetUserData(XFA_CalcData)); - if (!pGlobalData) { - pGlobalData = new CXFA_CalcData; - pRefNode->SetUserData(XFA_CalcData, pGlobalData, - &gs_XFADeleteCalcData); - } - if (!pdfium::ContainsValue(pGlobalData->m_Globals, this)) - pGlobalData->m_Globals.push_back(this); - } - } - } - if (pRetValue) - *pRetValue = pTmpRetValue.release(); - - pContext->SetNodesOfRunScript(nullptr); - return iRet; -} -CXFA_FFWidget* CXFA_WidgetAcc::GetNextWidget(CXFA_FFWidget* pWidget) { - CXFA_LayoutItem* pLayout = nullptr; - if (pWidget) { - pLayout = pWidget->GetNext(); - } else { - pLayout = m_pDocView->GetXFALayout()->GetLayoutItem(m_pNode); - } - return static_cast(pLayout); -} -void CXFA_WidgetAcc::UpdateUIDisplay(CXFA_FFWidget* pExcept) { - CXFA_FFWidget* pWidget = nullptr; - while ((pWidget = GetNextWidget(pWidget)) != nullptr) { - if (pWidget == pExcept || !pWidget->IsLoaded() || - (GetUIType() != XFA_Element::CheckButton && pWidget->IsFocused())) { - continue; - } - pWidget->UpdateFWLData(); - pWidget->AddInvalidateRect(); - } -} - -void CXFA_WidgetAcc::CalcCaptionSize(CFX_SizeF& szCap) { - CXFA_Caption caption = GetCaption(); - if (!caption || caption.GetPresence() != XFA_ATTRIBUTEENUM_Visible) { - return; - } - LoadCaption(); - XFA_Element eUIType = GetUIType(); - int32_t iCapPlacement = caption.GetPlacementType(); - float fCapReserve = caption.GetReserve(); - const bool bVert = iCapPlacement == XFA_ATTRIBUTEENUM_Top || - iCapPlacement == XFA_ATTRIBUTEENUM_Bottom; - const bool bReserveExit = fCapReserve > 0.01; - CXFA_TextLayout* pCapTextLayout = - static_cast(m_pLayoutData.get()) - ->m_pCapTextLayout.get(); - if (pCapTextLayout) { - if (!bVert && eUIType != XFA_Element::Button) { - szCap.width = fCapReserve; - } - CFX_SizeF minSize; - pCapTextLayout->CalcSize(minSize, szCap, szCap); - if (bReserveExit) { - bVert ? szCap.height = fCapReserve : szCap.width = fCapReserve; - } - } else { - float fFontSize = 10.0f; - if (CXFA_Font font = caption.GetFont()) { - fFontSize = font.GetFontSize(); - } else if (CXFA_Font widgetfont = GetFont()) { - fFontSize = widgetfont.GetFontSize(); - } - if (bVert) { - szCap.height = fCapReserve > 0 ? fCapReserve : fFontSize; - } else { - szCap.width = fCapReserve > 0 ? fCapReserve : 0; - szCap.height = fFontSize; - } - } - if (CXFA_Margin mgCap = caption.GetMargin()) { - float fLeftInset, fTopInset, fRightInset, fBottomInset; - mgCap.GetLeftInset(fLeftInset); - mgCap.GetTopInset(fTopInset); - mgCap.GetRightInset(fRightInset); - mgCap.GetBottomInset(fBottomInset); - if (bReserveExit) { - bVert ? (szCap.width += fLeftInset + fRightInset) - : (szCap.height += fTopInset + fBottomInset); - } else { - szCap.width += fLeftInset + fRightInset; - szCap.height += fTopInset + fBottomInset; - } - } -} -bool CXFA_WidgetAcc::CalculateFieldAutoSize(CFX_SizeF& size) { - CFX_SizeF szCap; - CalcCaptionSize(szCap); - CFX_RectF rtUIMargin = GetUIMargin(); - size.width += rtUIMargin.left + rtUIMargin.width; - size.height += rtUIMargin.top + rtUIMargin.height; - if (szCap.width > 0 && szCap.height > 0) { - int32_t iCapPlacement = GetCaption().GetPlacementType(); - switch (iCapPlacement) { - case XFA_ATTRIBUTEENUM_Left: - case XFA_ATTRIBUTEENUM_Right: - case XFA_ATTRIBUTEENUM_Inline: { - size.width += szCap.width; - size.height = std::max(size.height, szCap.height); - } break; - case XFA_ATTRIBUTEENUM_Top: - case XFA_ATTRIBUTEENUM_Bottom: { - size.height += szCap.height; - size.width = std::max(size.width, szCap.width); - } - default: - break; - } - } - return CalculateWidgetAutoSize(size); -} -bool CXFA_WidgetAcc::CalculateWidgetAutoSize(CFX_SizeF& size) { - CXFA_Margin mgWidget = GetMargin(); - if (mgWidget) { - float fLeftInset, fTopInset, fRightInset, fBottomInset; - mgWidget.GetLeftInset(fLeftInset); - mgWidget.GetTopInset(fTopInset); - mgWidget.GetRightInset(fRightInset); - mgWidget.GetBottomInset(fBottomInset); - size.width += fLeftInset + fRightInset; - size.height += fTopInset + fBottomInset; - } - CXFA_Para para = GetPara(); - if (para) - size.width += para.GetMarginLeft() + para.GetTextIndent(); - - float fVal = 0; - float fMin = 0; - float fMax = 0; - if (GetWidth(fVal)) { - size.width = fVal; - } else { - if (GetMinWidth(fMin)) - size.width = std::max(size.width, fMin); - if (GetMaxWidth(fMax) && fMax > 0) - size.width = std::min(size.width, fMax); - } - fVal = 0; - fMin = 0; - fMax = 0; - if (GetHeight(fVal)) { - size.height = fVal; - } else { - if (GetMinHeight(fMin)) - size.height = std::max(size.height, fMin); - if (GetMaxHeight(fMax) && fMax > 0) - size.height = std::min(size.height, fMax); - } - return true; -} - -void CXFA_WidgetAcc::CalculateTextContentSize(CFX_SizeF& size) { - float fFontSize = GetFontSize(); - CFX_WideString wsText; - GetValue(wsText, XFA_VALUEPICTURE_Display); - if (wsText.IsEmpty()) { - size.height += fFontSize; - return; - } - - wchar_t wcEnter = '\n'; - wchar_t wsLast = wsText.GetAt(wsText.GetLength() - 1); - if (wsLast == wcEnter) { - wsText = wsText + wcEnter; - } - - CXFA_FieldLayoutData* layoutData = - static_cast(m_pLayoutData.get()); - if (!layoutData->m_pTextOut) { - layoutData->m_pTextOut = pdfium::MakeUnique(); - CFDE_TextOut* pTextOut = layoutData->m_pTextOut.get(); - pTextOut->SetFont(GetFDEFont()); - pTextOut->SetFontSize(fFontSize); - pTextOut->SetLineBreakTolerance(fFontSize * 0.2f); - pTextOut->SetLineSpace(GetLineHeight()); - uint32_t dwStyles = FDE_TTOSTYLE_LastLineHeight; - if (GetUIType() == XFA_Element::TextEdit && IsMultiLine()) { - dwStyles |= FDE_TTOSTYLE_LineWrap; - } - pTextOut->SetStyles(dwStyles); - } - layoutData->m_pTextOut->CalcLogicSize(wsText.c_str(), wsText.GetLength(), - size); -} -bool CXFA_WidgetAcc::CalculateTextEditAutoSize(CFX_SizeF& size) { - if (size.width > 0) { - CFX_SizeF szOrz = size; - CFX_SizeF szCap; - CalcCaptionSize(szCap); - bool bCapExit = szCap.width > 0.01 && szCap.height > 0.01; - int32_t iCapPlacement = XFA_ATTRIBUTEENUM_Unknown; - if (bCapExit) { - iCapPlacement = GetCaption().GetPlacementType(); - switch (iCapPlacement) { - case XFA_ATTRIBUTEENUM_Left: - case XFA_ATTRIBUTEENUM_Right: - case XFA_ATTRIBUTEENUM_Inline: { - size.width -= szCap.width; - } - default: - break; - } - } - CFX_RectF rtUIMargin = GetUIMargin(); - size.width -= rtUIMargin.left + rtUIMargin.width; - CXFA_Margin mgWidget = GetMargin(); - if (mgWidget) { - float fLeftInset, fRightInset; - mgWidget.GetLeftInset(fLeftInset); - mgWidget.GetRightInset(fRightInset); - size.width -= fLeftInset + fRightInset; - } - CalculateTextContentSize(size); - size.height += rtUIMargin.top + rtUIMargin.height; - if (bCapExit) { - switch (iCapPlacement) { - case XFA_ATTRIBUTEENUM_Left: - case XFA_ATTRIBUTEENUM_Right: - case XFA_ATTRIBUTEENUM_Inline: { - size.height = std::max(size.height, szCap.height); - } break; - case XFA_ATTRIBUTEENUM_Top: - case XFA_ATTRIBUTEENUM_Bottom: { - size.height += szCap.height; - } - default: - break; - } - } - size.width = szOrz.width; - return CalculateWidgetAutoSize(size); - } - CalculateTextContentSize(size); - return CalculateFieldAutoSize(size); -} -bool CXFA_WidgetAcc::CalculateCheckButtonAutoSize(CFX_SizeF& size) { - float fCheckSize = GetCheckButtonSize(); - size = CFX_SizeF(fCheckSize, fCheckSize); - return CalculateFieldAutoSize(size); -} -bool CXFA_WidgetAcc::CalculatePushButtonAutoSize(CFX_SizeF& size) { - CalcCaptionSize(size); - return CalculateWidgetAutoSize(size); -} -bool CXFA_WidgetAcc::CalculateImageAutoSize(CFX_SizeF& size) { - if (!GetImageImage()) { - LoadImageImage(); - } - size.clear(); - if (CFX_DIBitmap* pBitmap = GetImageImage()) { - int32_t iImageXDpi = 0; - int32_t iImageYDpi = 0; - GetImageDpi(iImageXDpi, iImageYDpi); - CFX_RectF rtImage( - 0, 0, XFA_UnitPx2Pt((float)pBitmap->GetWidth(), (float)iImageXDpi), - XFA_UnitPx2Pt((float)pBitmap->GetHeight(), (float)iImageYDpi)); - - CFX_RectF rtFit; - if (GetWidth(rtFit.width)) { - GetWidthWithoutMargin(rtFit.width); - } else { - rtFit.width = rtImage.width; - } - if (GetHeight(rtFit.height)) { - GetHeightWithoutMargin(rtFit.height); - } else { - rtFit.height = rtImage.height; - } - size = rtFit.Size(); - } - return CalculateWidgetAutoSize(size); -} -bool CXFA_WidgetAcc::CalculateImageEditAutoSize(CFX_SizeF& size) { - if (!GetImageEditImage()) { - LoadImageEditImage(); - } - size.clear(); - if (CFX_DIBitmap* pBitmap = GetImageEditImage()) { - int32_t iImageXDpi = 0; - int32_t iImageYDpi = 0; - GetImageEditDpi(iImageXDpi, iImageYDpi); - CFX_RectF rtImage( - 0, 0, XFA_UnitPx2Pt((float)pBitmap->GetWidth(), (float)iImageXDpi), - XFA_UnitPx2Pt((float)pBitmap->GetHeight(), (float)iImageYDpi)); - - CFX_RectF rtFit; - if (GetWidth(rtFit.width)) { - GetWidthWithoutMargin(rtFit.width); - } else { - rtFit.width = rtImage.width; - } - if (GetHeight(rtFit.height)) { - GetHeightWithoutMargin(rtFit.height); - } else { - rtFit.height = rtImage.height; - } - size.width = rtFit.width; - size.height = rtFit.height; - } - return CalculateFieldAutoSize(size); -} -bool CXFA_WidgetAcc::LoadImageImage() { - InitLayoutData(); - return static_cast(m_pLayoutData.get()) - ->LoadImageData(this); -} -bool CXFA_WidgetAcc::LoadImageEditImage() { - InitLayoutData(); - return static_cast(m_pLayoutData.get()) - ->LoadImageData(this); -} -void CXFA_WidgetAcc::GetImageDpi(int32_t& iImageXDpi, int32_t& iImageYDpi) { - CXFA_ImageLayoutData* pData = - static_cast(m_pLayoutData.get()); - iImageXDpi = pData->m_iImageXDpi; - iImageYDpi = pData->m_iImageYDpi; -} -void CXFA_WidgetAcc::GetImageEditDpi(int32_t& iImageXDpi, int32_t& iImageYDpi) { - CXFA_ImageEditData* pData = - static_cast(m_pLayoutData.get()); - iImageXDpi = pData->m_iImageXDpi; - iImageYDpi = pData->m_iImageYDpi; -} -bool CXFA_WidgetAcc::CalculateTextAutoSize(CFX_SizeF& size) { - LoadText(); - CXFA_TextLayout* pTextLayout = - static_cast(m_pLayoutData.get())->GetTextLayout(); - if (pTextLayout) { - size.width = pTextLayout->StartLayout(size.width); - size.height = pTextLayout->GetLayoutHeight(); - } - return CalculateWidgetAutoSize(size); -} -void CXFA_WidgetAcc::LoadText() { - InitLayoutData(); - static_cast(m_pLayoutData.get())->LoadText(this); -} -float CXFA_WidgetAcc::CalculateWidgetAutoWidth(float fWidthCalc) { - CXFA_Margin mgWidget = GetMargin(); - if (mgWidget) { - float fLeftInset, fRightInset; - mgWidget.GetLeftInset(fLeftInset); - mgWidget.GetRightInset(fRightInset); - fWidthCalc += fLeftInset + fRightInset; - } - float fMin = 0, fMax = 0; - if (GetMinWidth(fMin)) { - fWidthCalc = std::max(fWidthCalc, fMin); - } - if (GetMaxWidth(fMax) && fMax > 0) { - fWidthCalc = std::min(fWidthCalc, fMax); - } - return fWidthCalc; -} -float CXFA_WidgetAcc::GetWidthWithoutMargin(float fWidthCalc) { - CXFA_Margin mgWidget = GetMargin(); - if (mgWidget) { - float fLeftInset, fRightInset; - mgWidget.GetLeftInset(fLeftInset); - mgWidget.GetRightInset(fRightInset); - fWidthCalc -= fLeftInset + fRightInset; - } - return fWidthCalc; -} -float CXFA_WidgetAcc::CalculateWidgetAutoHeight(float fHeightCalc) { - CXFA_Margin mgWidget = GetMargin(); - if (mgWidget) { - float fTopInset, fBottomInset; - mgWidget.GetTopInset(fTopInset); - mgWidget.GetBottomInset(fBottomInset); - fHeightCalc += fTopInset + fBottomInset; - } - float fMin = 0, fMax = 0; - if (GetMinHeight(fMin)) { - fHeightCalc = std::max(fHeightCalc, fMin); - } - if (GetMaxHeight(fMax) && fMax > 0) { - fHeightCalc = std::min(fHeightCalc, fMax); - } - return fHeightCalc; -} -float CXFA_WidgetAcc::GetHeightWithoutMargin(float fHeightCalc) { - CXFA_Margin mgWidget = GetMargin(); - if (mgWidget) { - float fTopInset, fBottomInset; - mgWidget.GetTopInset(fTopInset); - mgWidget.GetBottomInset(fBottomInset); - fHeightCalc -= fTopInset + fBottomInset; - } - return fHeightCalc; -} -void CXFA_WidgetAcc::StartWidgetLayout(float& fCalcWidth, float& fCalcHeight) { - InitLayoutData(); - XFA_Element eUIType = GetUIType(); - if (eUIType == XFA_Element::Text) { - m_pLayoutData->m_fWidgetHeight = -1; - GetHeight(m_pLayoutData->m_fWidgetHeight); - StartTextLayout(fCalcWidth, fCalcHeight); - return; - } - if (fCalcWidth > 0 && fCalcHeight > 0) { - return; - } - m_pLayoutData->m_fWidgetHeight = -1; - float fWidth = 0; - if (fCalcWidth > 0 && fCalcHeight < 0) { - if (!GetHeight(fCalcHeight)) { - CalculateAccWidthAndHeight(eUIType, fCalcWidth, fCalcHeight); - } - m_pLayoutData->m_fWidgetHeight = fCalcHeight; - return; - } - if (fCalcWidth < 0 && fCalcHeight < 0) { - if (!GetWidth(fWidth) || !GetHeight(fCalcHeight)) { - CalculateAccWidthAndHeight(eUIType, fWidth, fCalcHeight); - } - fCalcWidth = fWidth; - } - m_pLayoutData->m_fWidgetHeight = fCalcHeight; -} -void CXFA_WidgetAcc::CalculateAccWidthAndHeight(XFA_Element eUIType, - float& fWidth, - float& fCalcHeight) { - CFX_SizeF sz(fWidth, m_pLayoutData->m_fWidgetHeight); - switch (eUIType) { - case XFA_Element::Barcode: - case XFA_Element::ChoiceList: - case XFA_Element::Signature: - CalculateFieldAutoSize(sz); - break; - case XFA_Element::ImageEdit: - CalculateImageEditAutoSize(sz); - break; - case XFA_Element::Button: - CalculatePushButtonAutoSize(sz); - break; - case XFA_Element::CheckButton: - CalculateCheckButtonAutoSize(sz); - break; - case XFA_Element::DateTimeEdit: - case XFA_Element::NumericEdit: - case XFA_Element::PasswordEdit: - case XFA_Element::TextEdit: - CalculateTextEditAutoSize(sz); - break; - case XFA_Element::Image: - CalculateImageAutoSize(sz); - break; - case XFA_Element::Arc: - case XFA_Element::Line: - case XFA_Element::Rectangle: - case XFA_Element::Subform: - case XFA_Element::ExclGroup: - CalculateWidgetAutoSize(sz); - break; - default: - break; - } - fWidth = sz.width; - m_pLayoutData->m_fWidgetHeight = sz.height; - fCalcHeight = sz.height; -} -bool CXFA_WidgetAcc::FindSplitPos(int32_t iBlockIndex, float& fCalcHeight) { - XFA_Element eUIType = GetUIType(); - if (eUIType == XFA_Element::Subform) { - return false; - } - if (eUIType != XFA_Element::Text && eUIType != XFA_Element::TextEdit && - eUIType != XFA_Element::NumericEdit && - eUIType != XFA_Element::PasswordEdit) { - fCalcHeight = 0; - return true; - } - float fTopInset = 0; - float fBottomInset = 0; - if (iBlockIndex == 0) { - CXFA_Margin mgWidget = GetMargin(); - if (mgWidget) { - mgWidget.GetTopInset(fTopInset); - mgWidget.GetBottomInset(fBottomInset); - } - CFX_RectF rtUIMargin = GetUIMargin(); - fTopInset += rtUIMargin.top; - fBottomInset += rtUIMargin.width; - } - if (eUIType == XFA_Element::Text) { - float fHeight = fCalcHeight; - if (iBlockIndex == 0) { - fCalcHeight = fCalcHeight - fTopInset; - if (fCalcHeight < 0) { - fCalcHeight = 0; - } - } - CXFA_TextLayout* pTextLayout = - static_cast(m_pLayoutData.get())->GetTextLayout(); - pTextLayout->DoLayout(iBlockIndex, fCalcHeight, fCalcHeight, - m_pLayoutData->m_fWidgetHeight - fTopInset); - if (fCalcHeight != 0) { - if (iBlockIndex == 0) { - fCalcHeight = fCalcHeight + fTopInset; - } - if (fabs(fHeight - fCalcHeight) < XFA_FLOAT_PERCISION) { - return false; - } - } - return true; - } - XFA_ATTRIBUTEENUM iCapPlacement = XFA_ATTRIBUTEENUM_Unknown; - float fCapReserve = 0; - if (iBlockIndex == 0) { - CXFA_Caption caption = GetCaption(); - if (caption && caption.GetPresence() != XFA_ATTRIBUTEENUM_Hidden) { - iCapPlacement = (XFA_ATTRIBUTEENUM)caption.GetPlacementType(); - fCapReserve = caption.GetReserve(); - } - if (iCapPlacement == XFA_ATTRIBUTEENUM_Top && - fCalcHeight < fCapReserve + fTopInset) { - fCalcHeight = 0; - return true; - } - if (iCapPlacement == XFA_ATTRIBUTEENUM_Bottom && - m_pLayoutData->m_fWidgetHeight - fCapReserve - fBottomInset) { - fCalcHeight = 0; - return true; - } - if (iCapPlacement != XFA_ATTRIBUTEENUM_Top) { - fCapReserve = 0; - } - } - CXFA_FieldLayoutData* pFieldData = - static_cast(m_pLayoutData.get()); - int32_t iLinesCount = 0; - float fHeight = m_pLayoutData->m_fWidgetHeight; - CFX_WideString wsText; - GetValue(wsText, XFA_VALUEPICTURE_Display); - if (wsText.IsEmpty()) { - iLinesCount = 1; - } else { - if (!pFieldData->m_pTextOut) { - float fWidth = 0; - GetWidth(fWidth); - CalculateAccWidthAndHeight(eUIType, fWidth, fHeight); - } - iLinesCount = pFieldData->m_pTextOut->GetTotalLines(); - } - std::vector* pFieldArray = &pFieldData->m_FieldSplitArray; - int32_t iFieldSplitCount = pdfium::CollectionSize(*pFieldArray); - for (int32_t i = 0; i < iBlockIndex * 3; i += 3) { - iLinesCount -= (int32_t)(*pFieldArray)[i + 1]; - fHeight -= (*pFieldArray)[i + 2]; - } - if (iLinesCount == 0) { - return false; - } - float fLineHeight = GetLineHeight(); - float fFontSize = GetFontSize(); - float fTextHeight = iLinesCount * fLineHeight - fLineHeight + fFontSize; - float fSpaceAbove = 0; - float fStartOffset = 0; - if (fHeight > 0.1f && iBlockIndex == 0) { - fStartOffset = fTopInset; - fHeight -= (fTopInset + fBottomInset); - if (CXFA_Para para = GetPara()) { - fSpaceAbove = para.GetSpaceAbove(); - float fSpaceBelow = para.GetSpaceBelow(); - fHeight -= (fSpaceAbove + fSpaceBelow); - switch (para.GetVerticalAlign()) { - case XFA_ATTRIBUTEENUM_Top: - fStartOffset += fSpaceAbove; - break; - case XFA_ATTRIBUTEENUM_Middle: - fStartOffset += ((fHeight - fTextHeight) / 2 + fSpaceAbove); - break; - case XFA_ATTRIBUTEENUM_Bottom: - fStartOffset += (fHeight - fTextHeight + fSpaceAbove); - break; - } - } - if (fStartOffset < 0.1f) - fStartOffset = 0; - } - for (int32_t i = iBlockIndex - 1; iBlockIndex > 0 && i < iBlockIndex; i++) { - fStartOffset = (*pFieldArray)[i * 3] - (*pFieldArray)[i * 3 + 2]; - if (fStartOffset < 0.1f) - fStartOffset = 0; - } - if (iFieldSplitCount / 3 == (iBlockIndex + 1)) { - (*pFieldArray)[0] = fStartOffset; - } else { - pFieldArray->push_back(fStartOffset); - } - XFA_VERSION version = GetDoc()->GetXFADoc()->GetCurVersionMode(); - bool bCanSplitNoContent = false; - XFA_ATTRIBUTEENUM eLayoutMode; - GetNode() - ->GetNodeItem(XFA_NODEITEM_Parent) - ->TryEnum(XFA_ATTRIBUTE_Layout, eLayoutMode, true); - if ((eLayoutMode == XFA_ATTRIBUTEENUM_Position || - eLayoutMode == XFA_ATTRIBUTEENUM_Tb || - eLayoutMode == XFA_ATTRIBUTEENUM_Row || - eLayoutMode == XFA_ATTRIBUTEENUM_Table) && - version > XFA_VERSION_208) { - bCanSplitNoContent = true; - } - if ((eLayoutMode == XFA_ATTRIBUTEENUM_Tb || - eLayoutMode == XFA_ATTRIBUTEENUM_Row || - eLayoutMode == XFA_ATTRIBUTEENUM_Table) && - version <= XFA_VERSION_208) { - if (fStartOffset < fCalcHeight) { - bCanSplitNoContent = true; - } else { - fCalcHeight = 0; - return true; - } - } - if (bCanSplitNoContent) { - if ((fCalcHeight - fTopInset - fSpaceAbove < fLineHeight)) { - fCalcHeight = 0; - return true; - } - if (fStartOffset + XFA_FLOAT_PERCISION >= fCalcHeight) { - if (iFieldSplitCount / 3 == (iBlockIndex + 1)) { - (*pFieldArray)[iBlockIndex * 3 + 1] = 0; - (*pFieldArray)[iBlockIndex * 3 + 2] = fCalcHeight; - } else { - pFieldArray->push_back(0); - pFieldArray->push_back(fCalcHeight); - } - return false; - } - if (fCalcHeight - fStartOffset < fLineHeight) { - fCalcHeight = fStartOffset; - if (iFieldSplitCount / 3 == (iBlockIndex + 1)) { - (*pFieldArray)[iBlockIndex * 3 + 1] = 0; - (*pFieldArray)[iBlockIndex * 3 + 2] = fCalcHeight; - } else { - pFieldArray->push_back(0); - pFieldArray->push_back(fCalcHeight); - } - return true; - } - float fTextNum = - fCalcHeight + XFA_FLOAT_PERCISION - fCapReserve - fStartOffset; - int32_t iLineNum = - (int32_t)((fTextNum + (fLineHeight - fFontSize)) / fLineHeight); - if (iLineNum >= iLinesCount) { - if (fCalcHeight - fStartOffset - fTextHeight >= fFontSize) { - if (iFieldSplitCount / 3 == (iBlockIndex + 1)) { - (*pFieldArray)[iBlockIndex * 3 + 1] = (float)iLinesCount; - (*pFieldArray)[iBlockIndex * 3 + 2] = fCalcHeight; - } else { - pFieldArray->push_back((float)iLinesCount); - pFieldArray->push_back(fCalcHeight); - } - return false; - } - if (fHeight - fStartOffset - fTextHeight < fFontSize) { - iLineNum -= 1; - if (iLineNum == 0) { - fCalcHeight = 0; - return true; - } - } else { - iLineNum = (int32_t)(fTextNum / fLineHeight); - } - } - if (iLineNum > 0) { - float fSplitHeight = iLineNum * fLineHeight + fCapReserve + fStartOffset; - if (iFieldSplitCount / 3 == (iBlockIndex + 1)) { - (*pFieldArray)[iBlockIndex * 3 + 1] = (float)iLineNum; - (*pFieldArray)[iBlockIndex * 3 + 2] = fSplitHeight; - } else { - pFieldArray->push_back((float)iLineNum); - pFieldArray->push_back(fSplitHeight); - } - if (fabs(fSplitHeight - fCalcHeight) < XFA_FLOAT_PERCISION) { - return false; - } - fCalcHeight = fSplitHeight; - return true; - } - } - fCalcHeight = 0; - return true; -} -void CXFA_WidgetAcc::InitLayoutData() { - if (m_pLayoutData) { - return; - } - switch (GetUIType()) { - case XFA_Element::Text: - m_pLayoutData = pdfium::MakeUnique(); - return; - case XFA_Element::TextEdit: - m_pLayoutData = pdfium::MakeUnique(); - return; - case XFA_Element::Image: - m_pLayoutData = pdfium::MakeUnique(); - return; - case XFA_Element::ImageEdit: - m_pLayoutData = pdfium::MakeUnique(); - return; - default: - break; - } - if (GetElementType() == XFA_Element::Field) { - m_pLayoutData = pdfium::MakeUnique(); - return; - } - m_pLayoutData = pdfium::MakeUnique(); -} - -void CXFA_WidgetAcc::StartTextLayout(float& fCalcWidth, float& fCalcHeight) { - LoadText(); - CXFA_TextLayout* pTextLayout = - static_cast(m_pLayoutData.get())->GetTextLayout(); - float fTextHeight = 0; - if (fCalcWidth > 0 && fCalcHeight > 0) { - float fWidth = GetWidthWithoutMargin(fCalcWidth); - pTextLayout->StartLayout(fWidth); - fTextHeight = fCalcHeight; - fTextHeight = GetHeightWithoutMargin(fTextHeight); - pTextLayout->DoLayout(0, fTextHeight, -1, fTextHeight); - return; - } - if (fCalcWidth > 0 && fCalcHeight < 0) { - float fWidth = GetWidthWithoutMargin(fCalcWidth); - pTextLayout->StartLayout(fWidth); - } - if (fCalcWidth < 0 && fCalcHeight < 0) { - float fMaxWidth = -1; - bool bRet = GetWidth(fMaxWidth); - if (bRet) { - float fWidth = GetWidthWithoutMargin(fMaxWidth); - pTextLayout->StartLayout(fWidth); - } else { - float fWidth = pTextLayout->StartLayout(fMaxWidth); - fMaxWidth = CalculateWidgetAutoWidth(fWidth); - fWidth = GetWidthWithoutMargin(fMaxWidth); - pTextLayout->StartLayout(fWidth); - } - fCalcWidth = fMaxWidth; - } - if (m_pLayoutData->m_fWidgetHeight < 0) { - m_pLayoutData->m_fWidgetHeight = pTextLayout->GetLayoutHeight(); - m_pLayoutData->m_fWidgetHeight = - CalculateWidgetAutoHeight(m_pLayoutData->m_fWidgetHeight); - } - fTextHeight = m_pLayoutData->m_fWidgetHeight; - fTextHeight = GetHeightWithoutMargin(fTextHeight); - pTextLayout->DoLayout(0, fTextHeight, -1, fTextHeight); - fCalcHeight = m_pLayoutData->m_fWidgetHeight; -} -bool CXFA_WidgetAcc::LoadCaption() { - InitLayoutData(); - return static_cast(m_pLayoutData.get()) - ->LoadCaption(this); -} -CXFA_TextLayout* CXFA_WidgetAcc::GetCaptionTextLayout() { - return m_pLayoutData - ? static_cast(m_pLayoutData.get()) - ->m_pCapTextLayout.get() - : nullptr; -} -CXFA_TextLayout* CXFA_WidgetAcc::GetTextLayout() { - return m_pLayoutData - ? static_cast(m_pLayoutData.get()) - ->GetTextLayout() - : nullptr; -} -CFX_DIBitmap* CXFA_WidgetAcc::GetImageImage() { - return m_pLayoutData - ? static_cast(m_pLayoutData.get()) - ->m_pDIBitmap - : nullptr; -} -CFX_DIBitmap* CXFA_WidgetAcc::GetImageEditImage() { - return m_pLayoutData - ? static_cast(m_pLayoutData.get()) - ->m_pDIBitmap - : nullptr; -} - -void CXFA_WidgetAcc::SetImageImage(CFX_DIBitmap* newImage) { - CXFA_ImageLayoutData* pData = - static_cast(m_pLayoutData.get()); - if (pData->m_pDIBitmap == newImage) - return; - - if (pData->m_pDIBitmap && !pData->m_bNamedImage) - delete pData->m_pDIBitmap; - - pData->m_pDIBitmap = newImage; -} - -void CXFA_WidgetAcc::SetImageEditImage(CFX_DIBitmap* newImage) { - CXFA_ImageEditData* pData = - static_cast(m_pLayoutData.get()); - if (pData->m_pDIBitmap == newImage) - return; - - if (pData->m_pDIBitmap && !pData->m_bNamedImage) - delete pData->m_pDIBitmap; - - pData->m_pDIBitmap = newImage; -} - -CXFA_WidgetLayoutData* CXFA_WidgetAcc::GetWidgetLayoutData() { - return m_pLayoutData.get(); -} - -CFX_RetainPtr CXFA_WidgetAcc::GetFDEFont() { - CFX_WideStringC wsFontName = L"Courier"; - uint32_t dwFontStyle = 0; - if (CXFA_Font font = GetFont()) { - if (font.IsBold()) - dwFontStyle |= FX_FONTSTYLE_Bold; - if (font.IsItalic()) - dwFontStyle |= FX_FONTSTYLE_Italic; - font.GetTypeface(wsFontName); - } - - auto* pDoc = GetDoc(); - return pDoc->GetApp()->GetXFAFontMgr()->GetFont(pDoc, wsFontName, - dwFontStyle); -} -float CXFA_WidgetAcc::GetFontSize() { - float fFontSize = 10.0f; - if (CXFA_Font font = GetFont()) { - fFontSize = font.GetFontSize(); - } - return fFontSize < 0.1f ? 10.0f : fFontSize; -} -float CXFA_WidgetAcc::GetLineHeight() { - float fLineHeight = 0; - if (CXFA_Para para = GetPara()) { - fLineHeight = para.GetLineHeight(); - } - if (fLineHeight < 1) { - fLineHeight = GetFontSize() * 1.2f; - } - return fLineHeight; -} -FX_ARGB CXFA_WidgetAcc::GetTextColor() { - if (CXFA_Font font = GetFont()) { - return font.GetColor(); - } - return 0xFF000000; -} CXFA_Node* CXFA_TextProvider::GetTextNode(bool& bRichText) { bRichText = false; if (m_pTextNode) { diff --git a/xfa/fxfa/app/xfa_ffwidgetacc.h b/xfa/fxfa/app/xfa_ffwidgetacc.h index 2daa35e6cd..8cb66e2dc5 100644 --- a/xfa/fxfa/app/xfa_ffwidgetacc.h +++ b/xfa/fxfa/app/xfa_ffwidgetacc.h @@ -9,7 +9,7 @@ #include "core/fxcrt/fx_string.h" #include "xfa/fxfa/app/cxfa_textlayout.h" -#include "xfa/fxfa/fxfa_widget.h" +#include "xfa/fxfa/cxfa_widgetacc.h" #include "xfa/fxfa/parser/cxfa_font.h" #include "xfa/fxfa/parser/cxfa_para.h" diff --git a/xfa/fxfa/app/xfa_ffwidgethandler.cpp b/xfa/fxfa/app/xfa_ffwidgethandler.cpp deleted file mode 100644 index 8ecc4565e1..0000000000 --- a/xfa/fxfa/app/xfa_ffwidgethandler.cpp +++ /dev/null @@ -1,524 +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 - -#include "xfa/fxfa/xfa_ffwidgethandler.h" - -#include - -#include "xfa/fxfa/app/xfa_ffchoicelist.h" -#include "xfa/fxfa/app/xfa_fffield.h" -#include "xfa/fxfa/app/xfa_fwladapter.h" -#include "xfa/fxfa/parser/cxfa_layoutprocessor.h" -#include "xfa/fxfa/parser/cxfa_measurement.h" -#include "xfa/fxfa/xfa_ffdoc.h" -#include "xfa/fxfa/xfa_ffdocview.h" -#include "xfa/fxfa/xfa_ffwidget.h" - -CXFA_FFWidgetHandler::CXFA_FFWidgetHandler(CXFA_FFDocView* pDocView) - : m_pDocView(pDocView) {} - -CXFA_FFWidgetHandler::~CXFA_FFWidgetHandler() {} - -bool CXFA_FFWidgetHandler::OnMouseEnter(CXFA_FFWidget* hWidget) { - m_pDocView->LockUpdate(); - bool bRet = hWidget->OnMouseEnter(); - m_pDocView->UnlockUpdate(); - m_pDocView->UpdateDocView(); - return bRet; -} - -bool CXFA_FFWidgetHandler::OnMouseExit(CXFA_FFWidget* hWidget) { - m_pDocView->LockUpdate(); - bool bRet = hWidget->OnMouseExit(); - m_pDocView->UnlockUpdate(); - m_pDocView->UpdateDocView(); - return bRet; -} - -bool CXFA_FFWidgetHandler::OnLButtonDown(CXFA_FFWidget* hWidget, - uint32_t dwFlags, - const CFX_PointF& point) { - m_pDocView->LockUpdate(); - bool bRet = hWidget->OnLButtonDown(dwFlags, hWidget->Rotate2Normal(point)); - if (bRet && m_pDocView->SetFocus(hWidget)) { - m_pDocView->GetDoc()->GetDocEnvironment()->SetFocusWidget( - m_pDocView->GetDoc(), hWidget); - } - m_pDocView->UnlockUpdate(); - m_pDocView->UpdateDocView(); - return bRet; -} - -bool CXFA_FFWidgetHandler::OnLButtonUp(CXFA_FFWidget* hWidget, - uint32_t dwFlags, - const CFX_PointF& point) { - m_pDocView->LockUpdate(); - m_pDocView->m_bLayoutEvent = true; - bool bRet = hWidget->OnLButtonUp(dwFlags, hWidget->Rotate2Normal(point)); - m_pDocView->UnlockUpdate(); - m_pDocView->UpdateDocView(); - return bRet; -} - -bool CXFA_FFWidgetHandler::OnLButtonDblClk(CXFA_FFWidget* hWidget, - uint32_t dwFlags, - const CFX_PointF& point) { - bool bRet = hWidget->OnLButtonDblClk(dwFlags, hWidget->Rotate2Normal(point)); - m_pDocView->RunInvalidate(); - return bRet; -} - -bool CXFA_FFWidgetHandler::OnMouseMove(CXFA_FFWidget* hWidget, - uint32_t dwFlags, - const CFX_PointF& point) { - bool bRet = hWidget->OnMouseMove(dwFlags, hWidget->Rotate2Normal(point)); - m_pDocView->RunInvalidate(); - return bRet; -} - -bool CXFA_FFWidgetHandler::OnMouseWheel(CXFA_FFWidget* hWidget, - uint32_t dwFlags, - int16_t zDelta, - const CFX_PointF& point) { - bool bRet = - hWidget->OnMouseWheel(dwFlags, zDelta, hWidget->Rotate2Normal(point)); - m_pDocView->RunInvalidate(); - return bRet; -} - -bool CXFA_FFWidgetHandler::OnRButtonDown(CXFA_FFWidget* hWidget, - uint32_t dwFlags, - const CFX_PointF& point) { - bool bRet = hWidget->OnRButtonDown(dwFlags, hWidget->Rotate2Normal(point)); - if (bRet && m_pDocView->SetFocus(hWidget)) { - m_pDocView->GetDoc()->GetDocEnvironment()->SetFocusWidget( - m_pDocView->GetDoc(), hWidget); - } - m_pDocView->RunInvalidate(); - return bRet; -} - -bool CXFA_FFWidgetHandler::OnRButtonUp(CXFA_FFWidget* hWidget, - uint32_t dwFlags, - const CFX_PointF& point) { - bool bRet = hWidget->OnRButtonUp(dwFlags, hWidget->Rotate2Normal(point)); - m_pDocView->RunInvalidate(); - return bRet; -} - -bool CXFA_FFWidgetHandler::OnRButtonDblClk(CXFA_FFWidget* hWidget, - uint32_t dwFlags, - const CFX_PointF& point) { - bool bRet = hWidget->OnRButtonDblClk(dwFlags, hWidget->Rotate2Normal(point)); - m_pDocView->RunInvalidate(); - return bRet; -} - -bool CXFA_FFWidgetHandler::OnKeyDown(CXFA_FFWidget* hWidget, - uint32_t dwKeyCode, - uint32_t dwFlags) { - bool bRet = hWidget->OnKeyDown(dwKeyCode, dwFlags); - m_pDocView->RunInvalidate(); - m_pDocView->UpdateDocView(); - return bRet; -} - -bool CXFA_FFWidgetHandler::OnKeyUp(CXFA_FFWidget* hWidget, - uint32_t dwKeyCode, - uint32_t dwFlags) { - bool bRet = hWidget->OnKeyUp(dwKeyCode, dwFlags); - m_pDocView->RunInvalidate(); - return bRet; -} - -bool CXFA_FFWidgetHandler::OnChar(CXFA_FFWidget* hWidget, - uint32_t dwChar, - uint32_t dwFlags) { - bool bRet = hWidget->OnChar(dwChar, dwFlags); - m_pDocView->RunInvalidate(); - return bRet; -} - -FWL_WidgetHit CXFA_FFWidgetHandler::OnHitTest(CXFA_FFWidget* hWidget, - const CFX_PointF& point) { - if (!(hWidget->GetStatus() & XFA_WidgetStatus_Visible)) - return FWL_WidgetHit::Unknown; - return hWidget->OnHitTest(hWidget->Rotate2Normal(point)); -} - -bool CXFA_FFWidgetHandler::OnSetCursor(CXFA_FFWidget* hWidget, - const CFX_PointF& point) { - return hWidget->OnSetCursor(hWidget->Rotate2Normal(point)); -} - -void CXFA_FFWidgetHandler::RenderWidget(CXFA_FFWidget* hWidget, - CFX_Graphics* pGS, - CFX_Matrix* pMatrix, - bool bHighlight) { - hWidget->RenderWidget(pGS, pMatrix, - bHighlight ? XFA_WidgetStatus_Highlight : 0); -} - -bool CXFA_FFWidgetHandler::HasEvent(CXFA_WidgetAcc* pWidgetAcc, - XFA_EVENTTYPE eEventType) { - if (eEventType == XFA_EVENT_Unknown) - return false; - - if (!pWidgetAcc || pWidgetAcc->GetElementType() == XFA_Element::Draw) - return false; - - switch (eEventType) { - case XFA_EVENT_Calculate: { - CXFA_Calculate calc = pWidgetAcc->GetCalculate(); - return calc && calc.GetScript(); - } - case XFA_EVENT_Validate: { - CXFA_Validate val = pWidgetAcc->GetValidate(); - return val && val.GetScript(); - } - default: - break; - } - return !pWidgetAcc->GetEventByActivity(gs_EventActivity[eEventType]).empty(); -} - -int32_t CXFA_FFWidgetHandler::ProcessEvent(CXFA_WidgetAcc* pWidgetAcc, - CXFA_EventParam* pParam) { - if (!pParam || pParam->m_eType == XFA_EVENT_Unknown) - return XFA_EVENTERROR_NotExist; - if (!pWidgetAcc || pWidgetAcc->GetElementType() == XFA_Element::Draw) - return XFA_EVENTERROR_NotExist; - - switch (pParam->m_eType) { - case XFA_EVENT_Calculate: - return pWidgetAcc->ProcessCalculate(); - case XFA_EVENT_Validate: - if (m_pDocView->GetDoc()->GetDocEnvironment()->IsValidationsEnabled( - m_pDocView->GetDoc())) { - return pWidgetAcc->ProcessValidate(); - } - return XFA_EVENTERROR_Disabled; - case XFA_EVENT_InitCalculate: { - CXFA_Calculate calc = pWidgetAcc->GetCalculate(); - if (!calc) - return XFA_EVENTERROR_NotExist; - if (pWidgetAcc->GetNode()->IsUserInteractive()) - return XFA_EVENTERROR_Disabled; - - CXFA_Script script = calc.GetScript(); - return pWidgetAcc->ExecuteScript(script, pParam); - } - default: - break; - } - int32_t iRet = - pWidgetAcc->ProcessEvent(gs_EventActivity[pParam->m_eType], pParam); - return iRet; -} - -CXFA_FFWidget* CXFA_FFWidgetHandler::CreateWidget(CXFA_FFWidget* hParent, - XFA_WIDGETTYPE eType, - CXFA_FFWidget* hBefore) { - CXFA_Node* pParentFormItem = - hParent ? hParent->GetDataAcc()->GetNode() : nullptr; - CXFA_Node* pBeforeFormItem = - hBefore ? hBefore->GetDataAcc()->GetNode() : nullptr; - CXFA_Node* pNewFormItem = - CreateWidgetFormItem(eType, pParentFormItem, pBeforeFormItem); - if (!pNewFormItem) - return nullptr; - - pNewFormItem->GetTemplateNode()->SetFlag(XFA_NodeFlag_Initialized, true); - pNewFormItem->SetFlag(XFA_NodeFlag_Initialized, true); - m_pDocView->RunLayout(); - CXFA_LayoutItem* pLayout = - m_pDocView->GetXFALayout()->GetLayoutItem(pNewFormItem); - return static_cast(pLayout); -} - -CXFA_Node* CXFA_FFWidgetHandler::CreateWidgetFormItem( - XFA_WIDGETTYPE eType, - CXFA_Node* pParent, - CXFA_Node* pBefore) const { - switch (eType) { - case XFA_WIDGETTYPE_Barcode: - return nullptr; - case XFA_WIDGETTYPE_PushButton: - return CreatePushButton(pParent, pBefore); - case XFA_WIDGETTYPE_CheckButton: - return CreateCheckButton(pParent, pBefore); - case XFA_WIDGETTYPE_ExcludeGroup: - return CreateExclGroup(pParent, pBefore); - case XFA_WIDGETTYPE_RadioButton: - return CreateRadioButton(pParent, pBefore); - case XFA_WIDGETTYPE_Arc: - return CreateArc(pParent, pBefore); - case XFA_WIDGETTYPE_Rectangle: - return CreateRectangle(pParent, pBefore); - case XFA_WIDGETTYPE_Image: - return CreateImage(pParent, pBefore); - case XFA_WIDGETTYPE_Line: - return CreateLine(pParent, pBefore); - case XFA_WIDGETTYPE_Text: - return CreateText(pParent, pBefore); - case XFA_WIDGETTYPE_DatetimeEdit: - return CreateDatetimeEdit(pParent, pBefore); - case XFA_WIDGETTYPE_DecimalField: - return CreateDecimalField(pParent, pBefore); - case XFA_WIDGETTYPE_NumericField: - return CreateNumericField(pParent, pBefore); - case XFA_WIDGETTYPE_Signature: - return CreateSignature(pParent, pBefore); - case XFA_WIDGETTYPE_TextEdit: - return CreateTextEdit(pParent, pBefore); - case XFA_WIDGETTYPE_DropdownList: - return CreateDropdownList(pParent, pBefore); - case XFA_WIDGETTYPE_ListBox: - return CreateListBox(pParent, pBefore); - case XFA_WIDGETTYPE_ImageField: - return CreateImageField(pParent, pBefore); - case XFA_WIDGETTYPE_PasswordEdit: - return CreatePasswordEdit(pParent, pBefore); - case XFA_WIDGETTYPE_Subform: - return CreateSubform(pParent, pBefore); - default: - return nullptr; - } -} - -CXFA_Node* CXFA_FFWidgetHandler::CreatePushButton(CXFA_Node* pParent, - CXFA_Node* pBefore) const { - CXFA_Node* pField = CreateField(XFA_Element::Button, pParent, pBefore); - CXFA_Node* pCaption = CreateCopyNode(XFA_Element::Caption, pField); - CXFA_Node* pValue = CreateCopyNode(XFA_Element::Value, pCaption); - CXFA_Node* pText = CreateCopyNode(XFA_Element::Text, pValue); - pText->SetContent(L"Button", L"Button", false); - - CXFA_Node* pPara = CreateCopyNode(XFA_Element::Para, pCaption); - pPara->SetEnum(XFA_ATTRIBUTE_VAlign, XFA_ATTRIBUTEENUM_Middle, false); - pPara->SetEnum(XFA_ATTRIBUTE_HAlign, XFA_ATTRIBUTEENUM_Center, false); - CreateFontNode(pCaption); - - CXFA_Node* pBorder = CreateCopyNode(XFA_Element::Border, pField); - pBorder->SetEnum(XFA_ATTRIBUTE_Hand, XFA_ATTRIBUTEENUM_Right, false); - - CXFA_Node* pEdge = CreateCopyNode(XFA_Element::Edge, pBorder); - pEdge->SetEnum(XFA_ATTRIBUTE_Stroke, XFA_ATTRIBUTEENUM_Raised, false); - - CXFA_Node* pFill = CreateCopyNode(XFA_Element::Fill, pBorder); - CXFA_Node* pColor = CreateCopyNode(XFA_Element::Color, pFill); - pColor->SetCData(XFA_ATTRIBUTE_Value, L"212, 208, 200", false); - - CXFA_Node* pBind = CreateCopyNode(XFA_Element::Bind, pField); - pBind->SetEnum(XFA_ATTRIBUTE_Match, XFA_ATTRIBUTEENUM_None); - - return pField; -} - -CXFA_Node* CXFA_FFWidgetHandler::CreateCheckButton(CXFA_Node* pParent, - CXFA_Node* pBefore) const { - return CreateField(XFA_Element::CheckButton, pParent, pBefore); -} - -CXFA_Node* CXFA_FFWidgetHandler::CreateExclGroup(CXFA_Node* pParent, - CXFA_Node* pBefore) const { - return CreateFormItem(XFA_Element::ExclGroup, pParent, pBefore); -} - -CXFA_Node* CXFA_FFWidgetHandler::CreateRadioButton(CXFA_Node* pParent, - CXFA_Node* pBefore) const { - CXFA_Node* pField = CreateField(XFA_Element::CheckButton, pParent, pBefore); - CXFA_Node* pUi = pField->GetFirstChildByClass(XFA_Element::Ui); - CXFA_Node* pWidget = pUi->GetFirstChildByClass(XFA_Element::CheckButton); - pWidget->SetEnum(XFA_ATTRIBUTE_Shape, XFA_ATTRIBUTEENUM_Round); - return pField; -} - -CXFA_Node* CXFA_FFWidgetHandler::CreateDatetimeEdit(CXFA_Node* pParent, - CXFA_Node* pBefore) const { - CXFA_Node* pField = CreateField(XFA_Element::DateTimeEdit, pParent, pBefore); - CreateValueNode(XFA_Element::Date, pField); - return pField; -} - -CXFA_Node* CXFA_FFWidgetHandler::CreateDecimalField(CXFA_Node* pParent, - CXFA_Node* pBefore) const { - CXFA_Node* pField = CreateNumericField(pParent, pBefore); - CreateValueNode(XFA_Element::Decimal, pField); - return pField; -} - -CXFA_Node* CXFA_FFWidgetHandler::CreateNumericField(CXFA_Node* pParent, - CXFA_Node* pBefore) const { - return CreateField(XFA_Element::NumericEdit, pParent, pBefore); -} - -CXFA_Node* CXFA_FFWidgetHandler::CreateSignature(CXFA_Node* pParent, - CXFA_Node* pBefore) const { - return CreateField(XFA_Element::Signature, pParent, pBefore); -} - -CXFA_Node* CXFA_FFWidgetHandler::CreateTextEdit(CXFA_Node* pParent, - CXFA_Node* pBefore) const { - return CreateField(XFA_Element::TextEdit, pParent, pBefore); -} - -CXFA_Node* CXFA_FFWidgetHandler::CreateDropdownList(CXFA_Node* pParent, - CXFA_Node* pBefore) const { - return CreateField(XFA_Element::ChoiceList, pParent, pBefore); -} - -CXFA_Node* CXFA_FFWidgetHandler::CreateListBox(CXFA_Node* pParent, - CXFA_Node* pBefore) const { - CXFA_Node* pField = CreateDropdownList(pParent, pBefore); - CXFA_Node* pUi = pField->GetNodeItem(XFA_NODEITEM_FirstChild); - CXFA_Node* pListBox = pUi->GetNodeItem(XFA_NODEITEM_FirstChild); - pListBox->SetEnum(XFA_ATTRIBUTE_Open, XFA_ATTRIBUTEENUM_Always); - pListBox->SetEnum(XFA_ATTRIBUTE_CommitOn, XFA_ATTRIBUTEENUM_Exit); - return pField; -} - -CXFA_Node* CXFA_FFWidgetHandler::CreateImageField(CXFA_Node* pParent, - CXFA_Node* pBefore) const { - return CreateField(XFA_Element::ImageEdit, pParent, pBefore); -} - -CXFA_Node* CXFA_FFWidgetHandler::CreatePasswordEdit(CXFA_Node* pParent, - CXFA_Node* pBefore) const { - CXFA_Node* pField = CreateField(XFA_Element::PasswordEdit, pParent, pBefore); - CXFA_Node* pBind = CreateCopyNode(XFA_Element::Bind, pField); - pBind->SetEnum(XFA_ATTRIBUTE_Match, XFA_ATTRIBUTEENUM_None, false); - return pField; -} - -CXFA_Node* CXFA_FFWidgetHandler::CreateField(XFA_Element eElement, - CXFA_Node* pParent, - CXFA_Node* pBefore) const { - CXFA_Node* pField = CreateFormItem(XFA_Element::Field, pParent, pBefore); - CreateCopyNode(eElement, CreateCopyNode(XFA_Element::Ui, pField)); - CreateFontNode(pField); - return pField; -} - -CXFA_Node* CXFA_FFWidgetHandler::CreateArc(CXFA_Node* pParent, - CXFA_Node* pBefore) const { - return CreateDraw(XFA_Element::Arc, pParent, pBefore); -} - -CXFA_Node* CXFA_FFWidgetHandler::CreateRectangle(CXFA_Node* pParent, - CXFA_Node* pBefore) const { - return CreateDraw(XFA_Element::Rectangle, pParent, pBefore); -} - -CXFA_Node* CXFA_FFWidgetHandler::CreateImage(CXFA_Node* pParent, - CXFA_Node* pBefore) const { - CXFA_Node* pField = CreateDraw(XFA_Element::Image, pParent, pBefore); - CreateCopyNode(XFA_Element::ImageEdit, - CreateCopyNode(XFA_Element::Ui, pField)); - return pField; -} - -CXFA_Node* CXFA_FFWidgetHandler::CreateLine(CXFA_Node* pParent, - CXFA_Node* pBefore) const { - return CreateDraw(XFA_Element::Line, pParent, pBefore); -} - -CXFA_Node* CXFA_FFWidgetHandler::CreateText(CXFA_Node* pParent, - CXFA_Node* pBefore) const { - CXFA_Node* pField = CreateDraw(XFA_Element::Text, pParent, pBefore); - CreateCopyNode(XFA_Element::TextEdit, - CreateCopyNode(XFA_Element::Ui, pField)); - CreateFontNode(pField); - return pField; -} - -CXFA_Node* CXFA_FFWidgetHandler::CreateDraw(XFA_Element eElement, - CXFA_Node* pParent, - CXFA_Node* pBefore) const { - CXFA_Node* pDraw = CreateFormItem(XFA_Element::Draw, pParent, pBefore); - CreateValueNode(eElement, pDraw); - return pDraw; -} - -CXFA_Node* CXFA_FFWidgetHandler::CreateSubform(CXFA_Node* pParent, - CXFA_Node* pBefore) const { - return CreateFormItem(XFA_Element::Subform, pParent, pBefore); -} - -CXFA_Node* CXFA_FFWidgetHandler::CreateFormItem(XFA_Element eElement, - CXFA_Node* pParent, - CXFA_Node* pBefore) const { - CXFA_Node* pTemplateParent = pParent ? pParent->GetTemplateNode() : nullptr; - CXFA_Node* pNewFormItem = pTemplateParent->CloneTemplateToForm(false); - if (pParent) - pParent->InsertChild(pNewFormItem, pBefore); - return pNewFormItem; -} - -CXFA_Node* CXFA_FFWidgetHandler::CreateCopyNode(XFA_Element eElement, - CXFA_Node* pParent, - CXFA_Node* pBefore) const { - CXFA_Node* pTemplateParent = pParent ? pParent->GetTemplateNode() : nullptr; - CXFA_Node* pNewNode = - CreateTemplateNode(eElement, pTemplateParent, - pBefore ? pBefore->GetTemplateNode() : nullptr) - ->Clone(false); - if (pParent) - pParent->InsertChild(pNewNode, pBefore); - return pNewNode; -} - -CXFA_Node* CXFA_FFWidgetHandler::CreateTemplateNode(XFA_Element eElement, - CXFA_Node* pParent, - CXFA_Node* pBefore) const { - CXFA_Document* pXFADoc = GetXFADoc(); - CXFA_Node* pNewTemplateNode = - pXFADoc->CreateNode(XFA_XDPPACKET_Template, eElement); - if (pParent) - pParent->InsertChild(pNewTemplateNode, pBefore); - return pNewTemplateNode; -} - -CXFA_Node* CXFA_FFWidgetHandler::CreateFontNode(CXFA_Node* pParent) const { - CXFA_Node* pFont = CreateCopyNode(XFA_Element::Font, pParent); - pFont->SetCData(XFA_ATTRIBUTE_Typeface, L"Myriad Pro", false); - return pFont; -} - -CXFA_Node* CXFA_FFWidgetHandler::CreateMarginNode(CXFA_Node* pParent, - uint32_t dwFlags, - float fInsets[4]) const { - CXFA_Node* pMargin = CreateCopyNode(XFA_Element::Margin, pParent); - if (dwFlags & 0x01) - pMargin->SetMeasure(XFA_ATTRIBUTE_LeftInset, - CXFA_Measurement(fInsets[0], XFA_UNIT_Pt), false); - if (dwFlags & 0x02) - pMargin->SetMeasure(XFA_ATTRIBUTE_TopInset, - CXFA_Measurement(fInsets[1], XFA_UNIT_Pt), false); - if (dwFlags & 0x04) - pMargin->SetMeasure(XFA_ATTRIBUTE_RightInset, - CXFA_Measurement(fInsets[2], XFA_UNIT_Pt), false); - if (dwFlags & 0x08) - pMargin->SetMeasure(XFA_ATTRIBUTE_BottomInset, - CXFA_Measurement(fInsets[3], XFA_UNIT_Pt), false); - return pMargin; -} - -CXFA_Node* CXFA_FFWidgetHandler::CreateValueNode(XFA_Element eValue, - CXFA_Node* pParent) const { - CXFA_Node* pValue = CreateCopyNode(XFA_Element::Value, pParent); - CreateCopyNode(eValue, pValue); - return pValue; -} - -CXFA_Document* CXFA_FFWidgetHandler::GetObjFactory() const { - return GetXFADoc(); -} - -CXFA_Document* CXFA_FFWidgetHandler::GetXFADoc() const { - return m_pDocView->GetDoc()->GetXFADoc(); -} - diff --git a/xfa/fxfa/app/xfa_fontmgr.cpp b/xfa/fxfa/app/xfa_fontmgr.cpp deleted file mode 100644 index d7e34fb944..0000000000 --- a/xfa/fxfa/app/xfa_fontmgr.cpp +++ /dev/null @@ -1,2055 +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 - -#include "xfa/fxfa/xfa_fontmgr.h" - -#include -#include -#include - -#include "core/fpdfapi/font/cpdf_font.h" -#include "core/fpdfapi/parser/cpdf_dictionary.h" -#include "core/fpdfapi/parser/cpdf_document.h" -#include "third_party/base/ptr_util.h" -#include "xfa/fgas/font/cfgas_gefont.h" -#include "xfa/fxfa/xfa_ffapp.h" -#include "xfa/fxfa/xfa_ffdoc.h" - -namespace { - -// The 5 names per entry are: PsName, Normal, Bold, Italic, BoldItalic. -const char* const g_XFAPDFFontName[][5] = { - {"Adobe PI Std", "AdobePIStd", "AdobePIStd", "AdobePIStd", "AdobePIStd"}, - {"Myriad Pro Light", "MyriadPro-Light", "MyriadPro-Semibold", - "MyriadPro-LightIt", "MyriadPro-SemiboldIt"}, -}; - -#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ -const XFA_FONTINFO g_XFAFontsMap[] = { - {0x01d5d33e, L"SimSun", L"Arial", 0, 936}, - {0x01e4f102, L"YouYuan", L"Arial", 1, 936}, - {0x030549dc, L"LiSu", L"Arial", 1, 936}, - {0x032edd44, L"Simhei", L"Arial", 1, 936}, - {0x03eac6fc, L"PoorRichard-Regular", L"Arial", 2, 1252}, - {0x03ed90e6, L"Nina", L"Arial", 0, 1252}, - {0x077b56b3, L"KingsoftPhoneticPlain", L"Arial", 0, 1252}, - {0x078ed524, L"MicrosoftSansSerif", L"Arial", 0, 1252}, - {0x089b18a9, L"Arial", L"Arial", 0, 1252}, - {0x0b2cad72, L"MonotypeCorsiva", L"Arial", 8, 1252}, - {0x0bb003e7, L"Kartika", L"Arial", 2, 1252}, - {0x0bb469df, L"VinerHandITC", L"Arial", 8, 1252}, - {0x0bc1a851, L"SegoeUI", L"Arial", 0, 1252}, - {0x0c112ebd, L"KozukaGothicPro-VIM", L"Arial", 0, 1252}, - {0x0cfcb9c1, L"AdobeThai", L"Kokila,Arial Narrow", 0, 847}, - {0x0e7de0f9, L"Playbill", L"Arial", 0, 1252}, - {0x0eff47c3, L"STHupo", L"Arial", 0, 936}, - {0x107ad374, L"Constantia", L"Arial", 2, 1252}, - {0x12194c2d, L"KunstlerScript", L"Arial", 8, 1252}, - {0x135ef6a1, L"MinionProSmBd", - L"Bell MT,Corbel,Times New Roman,Cambria,Berlin Sans FB", 0, 1252}, - {0x158c4049, L"Garamond", L"Arial", 2, 1252}, - {0x160ecb24, L"STZhongsong", L"Arial", 0, 936}, - {0x161ed07e, L"MSGothic", L"Arial", 1, 1252}, - {0x171d1ed1, L"SnapITC-Regular", L"Arial", 0, 1252}, - {0x18d1188f, L"Cambria", L"Arial", 2, 1252}, - {0x18eaf350, L"ArialUnicodeMS", L"Arial", 0, 936}, - {0x1a92d115, L"MingLiU", L"Arial", 1, 1252}, - {0x1cc217c6, L"TrebuchetMS", L"Arial", 0, 1252}, - {0x1d649596, L"BasemicTimes", L"Arial", 0, 1252}, - {0x1e34ee60, L"BellMT", L"Arial", 2, 1252}, - {0x1eb36945, L"CooperBlack", L"Arial", 2, 1252}, - {0x1ef7787d, L"BatangChe", L"Arial", 1, 1252}, - {0x20b3bd3a, L"BrushScriptMT", L"Arial", 8, 1252}, - {0x220877aa, L"Candara", L"Arial", 0, 1252}, - {0x22135007, L"FreestyleScript-Regular", L"Arial", 8, 1252}, - {0x251059c3, L"Chiller", L"Arial", 0, 1252}, - {0x25bed6dd, L"MSReferenceSansSerif", L"Arial", 0, 1252}, - {0x28154c81, L"Parchment-Regular", L"Arial", 8, 1252}, - {0x29711eb9, L"STLiti", L"Arial", 0, 936}, - {0x2b1993b4, L"Basemic", L"Arial", 0, 1252}, - {0x2b316339, L"NiagaraSolid-Reg", L"Arial", 0, 1252}, - {0x2c147529, L"FootlightMTLight", L"Arial", 0, 1252}, - {0x2c198928, L"HarlowSolid", L"Arial", 0, 1252}, - {0x2c6ac6b2, L"LucidaBright", L"Arial", 2, 1252}, - {0x2c9f38e2, L"KozukaMinchoPro-VIR", L"Arial", 0, 1252}, - {0x2d5a47b0, L"STCaiyun", L"Arial", 0, 936}, - {0x2def26bf, L"BernardMT-Condensed", L"Arial", 0, 1252}, - {0x2fd8930b, L"KozukaMinchoPr6NR", L"Arial", 0, 1252}, - {0x3115525a, L"FangSong_GB2312", L"Arial", 0, 1252}, - {0x31327817, L"MyriadPro", - L"Calibri,Corbel,Candara,Cambria Math,Franklin Gothic Medium,Arial " - L"Narrow,Times New Roman", - 0, 1252}, - {0x32244975, L"Helvetica", L"Arial", 0, 1252}, - {0x32ac995c, L"Terminal", L"Arial", 0, 1252}, - {0x338d648a, L"NiagaraEngraved-Reg", L"Arial", 0, 1252}, - {0x33bb65f2, L"Sylfaen", L"Arial", 2, 1252}, - {0x3402c30e, L"MSPMincho", L"Arial", 2, 1252}, - {0x3412bf31, L"SimSun-PUA", L"Arial", 0, 936}, - {0x36eb39b9, L"BerlinSansFB", L"Arial", 0, 1252}, - {0x36f42055, L"UniversATT", L"Microsoft Sans Serif", 0, 1252}, - {0x3864c4f6, L"HighTowerText", L"Arial", 2, 1252}, - {0x3a257d03, L"FangSong_GB2312", L"Arial", 0, 1252}, - {0x3cdae668, L"FreestyleScript", L"Arial", 8, 1252}, - {0x3d55aed7, L"Jokerman", L"Arial", 0, 1252}, - {0x3d5b4385, L"PMingLiU", L"Arial", 2, 1252}, - {0x3d9b7669, L"EstrangeloEdessa", L"Arial", 0, 1252}, - {0x3e532d74, L"FranklinGothicMedium", L"Arial", 0, 1252}, - {0x3e6aa32d, L"NSimSun", L"Arial", 1, 936}, - {0x3f6c36a8, L"Gautami", L"Arial", 0, 1252}, - {0x3ff32662, L"Chiller-Regular", L"Arial", 0, 1252}, - {0x409de312, L"ModernNo.20", L"Arial", 2, 1252}, - {0x41443c5e, L"Georgia", L"Arial", 2, 1252}, - {0x4160ade5, L"BellGothicStdBlack", - L"Arial,Arial Unicode MS,Book Antiqua,Dotum,Georgia", 0, 1252}, - {0x421976c4, L"Modern-Regular", L"Arial", 2, 1252}, - {0x422a7252, L"Stencil", L"Arial", 0, 1252}, - {0x42c8554f, L"Fixedsys", L"Arial", 0, 1252}, - {0x435cb41d, L"Roman", L"Arial", 0, 1252}, - {0x47882383, L"CourierNew", L"Arial", 1, 1252}, - {0x480a2338, L"BerlinSansFBDemi", L"Arial", 0, 1252}, - {0x480bf7a4, L"CourierStd", L"Courier New,Verdana", 0, 1252}, - {0x481ad6ed, L"VladimirScript", L"Arial", 8, 1252}, - {0x4911577a, L"YouYuan", L"Arial", 1, 936}, - {0x4a788d72, L"STXingkai", L"Arial", 0, 936}, - {0x4bf88566, L"SegoeCondensed", L"Arial", 0, 1252}, - {0x4ccf51a4, L"BerlinSansFB-Reg", L"Arial", 0, 1252}, - {0x4ea967ce, L"GulimChe", L"Arial", 1, 1252}, - {0x4f68bd79, L"LetterGothicStd", L"Courier New,Verdana", 0, 1252}, - {0x51a0d0e6, L"KozukaGothicPr6NM", L"Arial", 0, 1252}, - {0x531b3dea, L"BasemicSymbol", L"Arial", 0, 1252}, - {0x5333fd39, L"CalifornianFB-Reg", L"Arial", 2, 1252}, - {0x53561a54, L"FZYTK--GBK1-0", L"Arial", 0, 936}, - {0x55e0dde6, L"LucidaSansTypewriter", L"Arial", 0, 1252}, - {0x574d4d3d, L"AdobeArabic", L"Arial Narrow", 0, 1252}, - {0x5792e759, L"STKaiti", L"Arial", 0, 936}, - {0x5921978e, L"LucidaSansUnicode", L"Arial", 0, 1252}, - {0x594e2da4, L"Vrinda", L"Arial", 0, 1252}, - {0x59baa9a2, L"KaiTi_GB2312", L"Arial", 0, 1252}, - {0x5cfedf4f, L"BaskOldFace", L"Arial", 0, 1252}, - {0x5f97921c, L"AdobeMyungjoStdM", - L"Batang,Bookman Old Style,Consolas,STZhongsong", 0, 936}, - {0x5fefbfad, L"Batang", L"Arial", 2, 1252}, - {0x605342b9, L"DotumChe", L"Arial", 1, 1252}, - {0x608c5f9a, L"KaiTi_GB2312", L"Arial", 0, 936}, - {0x61efd0d1, L"MaturaMTScriptCapitals", L"Arial", 0, 1252}, - {0x626608a9, L"MVBoli", L"Arial", 0, 1252}, - {0x630501a3, L"SmallFonts", L"Arial", 0, 1252}, - {0x65d0e2a9, L"FZYTK--GBK1-0", L"Arial", 0, 936}, - {0x669f29e1, L"FZSTK--GBK1-0", L"Arial", 0, 936}, - {0x673a9e5f, L"Tunga", L"Arial", 0, 1252}, - {0x691aa4ce, L"NiagaraSolid", L"Arial", 0, 1252}, - {0x696259b7, L"Corbel", L"Arial", 0, 1252}, - {0x696ee9be, L"STXihei", L"Arial", 0, 936}, - {0x6c59cf69, L"Dotum", L"Arial", 0, 1252}, - {0x707fa561, L"Gungsuh", L"Arial", 2, 1252}, - {0x71416bb2, L"ZWAdobeF", L"Arial", 0, 1252}, - {0x71b41801, L"Verdana", L"Arial", 0, 1252}, - {0x73f25e4c, L"PalatinoLinotype", L"Arial", 0, 1252}, - {0x73f4d19f, L"NiagaraEngraved", L"Arial", 0, 1252}, - {0x74001694, L"MyriadProBlack", L"Book Antiqua,Constantia,Dotum,Georgia", 0, - 1252}, - {0x74b14d8f, L"Haettenschweiler", L"Arial", 0, 1252}, - {0x74cb44ee, L"NSimSun", L"Arial", 1, 936}, - {0x76b4d7ff, L"Shruti", L"Arial", 0, 1252}, - {0x788b3533, L"Webdings", L"Arial", 6, 42}, - {0x797dde99, L"MSSerif", L"Arial", 0, 1252}, - {0x7a0f9e9e, L"MSMincho", L"Arial", 1, 1252}, - {0x7b439caf, L"OldEnglishTextMT", L"Arial", 0, 1252}, - {0x8213a433, L"LucidaSans-Typewriter", L"Arial", 0, 1252}, - {0x82fec929, L"AdobeSongStdL", - L"Centaur,Calibri,STSong,Bell MT,Garamond,Times New Roman", 0, 936}, - {0x83581825, L"Modern", L"Arial", 0, 1252}, - {0x835a2823, L"Algerian", L"Arial", 0, 1252}, - {0x83dab9f5, L"Script", L"Arial", 0, 1252}, - {0x847b56da, L"Tahoma", L"Arial", 0, 1252}, - {0x8a783cb2, L"SimSun-PUA", L"Arial", 0, 1252}, - {0x8b5cac0e, L"Onyx", L"Arial", 0, 1252}, - {0x8c6a499e, L"Gulim", L"Arial", 0, 1252}, - {0x8e0af790, L"JuiceITC", L"Arial", 0, 1252}, - {0x8e8d43b2, L"Centaur", L"Arial", 2, 1252}, - {0x8ee4dcca, L"BookshelfSymbol7", L"Arial", 0, 1252}, - {0x90794800, L"BellGothicStdLight", L"Bell MT,Calibri,Times New Roman", 0, - 1252}, - {0x909b516a, L"Century", L"Arial", 2, 1252}, - {0x92ae370d, L"MSOutlook", L"Arial", 4, 42}, - {0x93c9fbf1, L"LucidaFax", L"Arial", 2, 1252}, - {0x9565085e, L"BookAntiqua", L"Arial", 2, 1252}, - {0x9856d95d, L"AdobeMingStdL", L"Arial,Arial Unicode MS,Cambria,BatangChe", - 0, 949}, - {0x9bbadd6b, L"ColonnaMT", L"Arial", 0, 1252}, - {0x9cbd16a4, L"ShowcardGothic-Reg", L"Arial", 0, 1252}, - {0x9d73008e, L"MSSansSerif", L"Arial", 0, 1252}, - {0xa0607db1, L"GungsuhChe", L"Arial", 1, 1252}, - {0xa0bcf6a1, L"LatinWide", L"Arial", 2, 1252}, - {0xa1429b36, L"Symbol", L"Arial", 6, 42}, - {0xa1fa5abc, L"Wingdings2", L"Arial", 6, 42}, - {0xa1fa5abd, L"Wingdings3", L"Arial", 6, 42}, - {0xa427bad4, L"InformalRoman-Regular", L"Arial", 8, 1252}, - {0xa8b92ece, L"FZSTK--GBK1-0", L"Arial", 0, 936}, - {0xa8d83ece, L"CalifornianFB", L"Arial", 2, 1252}, - {0xaa3e082c, L"Kingsoft-Phonetic", L"Arial", 0, 1252}, - {0xaa6bcabe, L"HarlowSolidItalic", L"Arial", 0, 1252}, - {0xade5337c, L"MSUIGothic", L"Arial", 0, 1252}, - {0xb08dd941, L"WideLatin", L"Arial", 2, 1252}, - {0xb207f05d, L"PoorRichard", L"Arial", 2, 1252}, - {0xb3bc492f, L"JuiceITC-Regular", L"Arial", 0, 1252}, - {0xb5545399, L"Marlett", L"Arial", 4, 42}, - {0xb5dd1ebb, L"BritannicBold", L"Arial", 0, 1252}, - {0xb699c1c5, L"LucidaCalligraphy-Italic", L"Arial", 0, 1252}, - {0xb725d629, L"TimesNewRoman", L"Arial", 2, 1252}, - {0xb7eaebeb, L"AdobeHeitiStdR", L"Batang,Century,Dotum", 0, 936}, - {0xbd29c486, L"BerlinSansFBDemi-Bold", L"Arial", 0, 1252}, - {0xbe8a8db4, L"BookshelfSymbolSeven", L"Arial", 0, 1252}, - {0xc16c0118, L"AdobeHebrew", L"Bell MT,Berlin Sans FB,Calibri", 0, 1252}, - {0xc318b0af, L"MyriadProLight", L"Calibri,STFangsong,Times New Roman", 0, - 1252}, - {0xc65e5659, L"CambriaMath", L"Arial", 2, 1252}, - {0xc75c8f05, L"LucidaConsole", L"Arial", 1, 1252}, - {0xca7c35d6, L"Calibri", L"Arial", 0, 1252}, - {0xcb053f53, L"MicrosoftYaHei", L"Arial", 0, 936}, - {0xcb7190f9, L"Magneto-Bold", L"Arial", 0, 1252}, - {0xcca00cc5, L"System", L"Arial", 0, 1252}, - {0xccad6f76, L"Jokerman-Regular", L"Arial", 0, 1252}, - {0xccc5818c, L"EuroSign", L"Arial", 0, 1252}, - {0xcf3d7234, L"LucidaHandwriting-Italic", L"Arial", 0, 1252}, - {0xcf7b8fdb, L"MinionPro", - L"Bell MT,Corbel,Times New Roman,Cambria,Berlin Sans FB", 0, 1252}, - {0xcfe5755f, L"Simhei", L"Arial", 1, 936}, - {0xd011f4ee, L"MSPGothic", L"Arial", 0, 1252}, - {0xd060e7ef, L"Vivaldi", L"Arial", 8, 1252}, - {0xd07edec1, L"FranklinGothic-Medium", L"Arial", 0, 1252}, - {0xd107243f, L"SimSun", L"Arial", 0, 936}, - {0xd1881562, L"ArialNarrow", L"Arial Narrow", 0, 1252}, - {0xd22b7dce, L"BodoniMTPosterCompressed", L"Arial", 0, 1252}, - {0xd22bfa60, L"ComicSansMS", L"Arial", 8, 1252}, - {0xd3bd0e35, L"Bauhaus93", L"Arial", 0, 1252}, - {0xd429ee7a, L"STFangsong", L"Arial", 0, 936}, - {0xd6679c12, L"BernardMTCondensed", L"Arial", 0, 1252}, - {0xd8e8a027, L"LucidaSans", L"Arial", 0, 1252}, - {0xd9fe7761, L"HighTowerText-Reg", L"Arial", 2, 1252}, - {0xda7e551e, L"STSong", L"Arial", 0, 936}, - {0xdaa6842d, L"STZhongsong", L"Arial", 0, 936}, - {0xdaaab93f, L"STFangsong", L"Arial", 0, 936}, - {0xdaeb0713, L"STSong", L"Arial", 0, 936}, - {0xdafedbef, L"STCaiyun", L"Arial", 0, 936}, - {0xdb00a3d9, L"Broadway", L"Arial", 0, 1252}, - {0xdb1f5ad4, L"STXinwei", L"Arial", 0, 936}, - {0xdb326e7f, L"STKaiti", L"Arial", 0, 936}, - {0xdb69595a, L"STHupo", L"Arial", 0, 936}, - {0xdba0082c, L"STXihei", L"Arial", 0, 936}, - {0xdbd0ab18, L"STXingkai", L"Arial", 0, 936}, - {0xdc1a7db1, L"STLiti", L"Arial", 0, 936}, - {0xdc33075f, L"KristenITC-Regular", L"Arial", 8, 1252}, - {0xdcc7009c, L"Harrington", L"Arial", 0, 1252}, - {0xdd712466, L"ArialBlack", L"Arial", 0, 1252}, - {0xdde87b3e, L"Impact", L"Arial", 0, 1252}, - {0xdf69fb32, L"SnapITC", L"Arial", 0, 1252}, - {0xdf8b25e8, L"CenturyGothic", L"Arial", 0, 1252}, - {0xe0f705c0, L"KristenITC", L"Arial", 8, 1252}, - {0xe1427573, L"Raavi", L"Arial", 0, 1252}, - {0xe2cea0cb, L"Magneto", L"Arial", 0, 1252}, - {0xe36a9e17, L"Ravie", L"Arial", 0, 1252}, - {0xe433f8e2, L"Parchment", L"Arial", 8, 1252}, - {0xe43dff4a, L"Wingdings", L"Arial", 4, 42}, - {0xe4e2c405, L"MTExtra", L"Arial", 6, 42}, - {0xe618cc35, L"InformalRoman", L"Arial", 8, 1252}, - {0xe6c27ffc, L"Mistral", L"Arial", 8, 1252}, - {0xe7ebf4b9, L"Courier", L"Courier New", 0, 1252}, - {0xe8bc4a9d, L"MSReferenceSpecialty", L"Arial", 0, 1252}, - {0xe90fb013, L"TempusSansITC", L"Arial", 0, 1252}, - {0xec637b42, L"Consolas", L"Verdana", 1, 1252}, - {0xed3a683b, L"STXinwei", L"Arial", 0, 936}, - {0xef264cd1, L"LucidaHandwriting", L"Arial", 0, 1252}, - {0xf086bca2, L"BaskervilleOldFace", L"Arial", 0, 1252}, - {0xf1028030, L"Mangal", L"Arial", 2, 1252}, - {0xf1da7eb9, L"ShowcardGothic", L"Arial", 0, 1252}, - {0xf210f06a, L"ArialMT", L"Arial", 0, 1252}, - {0xf477f16a, L"Latha", L"Arial", 0, 1252}, - {0xf616f3dd, L"LiSu", L"Arial", 1, 936}, - {0xfa479aa6, L"MicrosoftYaHei", L"Arial", 0, 936}, - {0xfcd19697, L"BookmanOldStyle", L"Arial", 0, 1252}, - {0xfe209a82, L"LucidaCalligraphy", L"Arial", 0, 1252}, - {0xfef135f8, L"AdobeHeitiStd-Regular", L"Batang,Century,Dotum", 0, 936}, -}; -#elif _FXM_PLATFORM_ == _FXM_PLATFORM_LINUX_ -const XFA_FONTINFO g_XFAFontsMap[] = { - {0x01d5d33e, L"SimSun", - L"WenQuanYi Zen Hei Mono,AR PL UMing CN,AR PL UMing HK,AR PL UMing TW,AR " - L"PL UMing TW MBE", - 0, 936}, - {0x01e4f102, L"YouYuan", - L"WenQuanYi Zen Hei Mono,AR PL UMing CN,AR PL UMing HK,AR PL UMing TW,AR " - L"PL UMing TW MBE", - 1, 936}, - {0x030549dc, L"LiSu", - L"WenQuanYi Zen Hei,WenQuanYi Zen Hei Sharp,WenQuanYi Zen Hei " - L"Mono,WenQuanYi Micro Hei", - 1, 936}, - {0x032edd44, L"Simhei", - L"WenQuanYi Zen Hei,WenQuanYi Zen Hei Sharp,WenQuanYi Zen Hei " - L"Mono,WenQuanYi Micro Hei", - 1, 936}, - {0x03eac6fc, L"PoorRichard-Regular", L"Droid Sans Japanese,FreeSerif", 2, - 1252}, - {0x03ed90e6, L"Nina", L"FreeSerif", 0, 1252}, - {0x077b56b3, L"KingsoftPhoneticPlain", - L"Tibetan Machine Uni,LKLUG,Samyak Gujarati,Droid Sans Thai,Droid Sans " - L"Armenian,Untitled1,utkal,Lohit Oriya", - 0, 1252}, - {0x078ed524, L"MicrosoftSansSerif", - L"Droid Sans Japanese,FreeSerif,WenQuanYi Micro Hei", 0, 1252}, - {0x089b18a9, L"Arial", - L"Droid Sans Japanese,DejaVu Sans Condensed,FreeSerif,WenQuanYi Micro Hei", - 0, 1252}, - {0x0b2cad72, L"MonotypeCorsiva", L"Droid Sans Japanese,FreeSerif", 8, 1252}, - {0x0bb003e7, L"Kartika", - L"FreeSans,Liberation Sans,Liberation Sans Narrow,Nimbus Sans " - L"L,Garuda,FreeSerif,WenQuanYi Micro Hei", - 2, 1252}, - {0x0bb469df, L"VinerHandITC", - L"Droid Sans Japanese,Ubuntu,Liberation Sans,Liberation Serif", 8, 1252}, - {0x0bc1a851, L"SegoeUI", L"Droid Sans Japanese,DejaVu Sans", 0, 1252}, - {0x0c112ebd, L"KozukaGothicPro-VIM", L"FreeSerif", 0, 1252}, - {0x0cfcb9c1, L"AdobeThai", L"Droid Sans Japanese,Waree", 0, 847}, - {0x0e7de0f9, L"Playbill", - L"KacstQurn,Droid Arabic Naskh,Droid Sans Ethiopic,mry_KacstQurn,Droid " - L"Sans Ethiopic,Droid Sans Japanese,FreeSerif", - 0, 1252}, - {0x0eff47c3, L"STHupo", L"AR PL UKai HK,AR PL UMing HK,AR PL UKai CN", 0, - 936}, - {0x107ad374, L"Constantia", - L"Droid Sans Japanese,FreeSerif,WenQuanYi Micro Hei,Ubuntu", 2, 1252}, - {0x12194c2d, L"KunstlerScript", L"Droid Sans Japanese,Liberation Serif", 8, - 1252}, - {0x135ef6a1, L"MinionProSmBd", L"Liberation Serif", 0, 1252}, - {0x158c4049, L"Garamond", - L"Droid Sans Japanese,Liberation Serif,Ubuntu,FreeSerif", 2, 1252}, - {0x160ecb24, L"STZhongsong", - L"WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei,WenQuanYi Zen Hei " - L"Sharp,WenQuanYi Micro Hei", - 0, 936}, - {0x161ed07e, L"MSGothic", - L"WenQuanYi Micro Hei Mono,WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei,AR PL " - L"UMing CN,AR PL UMing HK,AR PL UMing TW", - 1, 1252}, - {0x171d1ed1, L"SnapITC-Regular", - L"Liberation Sans Narrow,Ubuntu Condensed,Nimbus Sans L,DejaVu Sans", 0, - 1252}, - {0x18d1188f, L"Cambria", L"Droid Sans Japanese,FreeSerif,FreeMono", 2, - 1252}, - {0x18eaf350, L"ArialUnicodeMS", - L"WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei,WenQuanYi Zen Hei " - L"Sharp,WenQuanYi Micro Hei", - 0, 936}, - {0x1a92d115, L"MingLiU", - L"WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei,WenQuanYi Zen Hei " - L"Sharp,WenQuanYi Micro Hei", - 1, 1252}, - {0x1cc217c6, L"TrebuchetMS", - L"Droid Sans Japanese,Liberation Serif,FreeSerif,Ubuntu", 0, 1252}, - {0x1d649596, L"BasemicTimes", - L"Liberation Serif,Times New Roman,Droid Sans Japanese,FreeSerif,Ubuntu", - 0, 1252}, - {0x1e34ee60, L"BellMT", - L"KacstQurn,Droid Sans Japanese,Ubuntu,Liberation Serif", 2, 1252}, - {0x1eb36945, L"CooperBlack", - L"KacstQurn,Droid Sans Japanese,FreeMono,Liberation Mono, WenQuanYi Micro " - L"Hei Mono", - 2, 1252}, - {0x1ef7787d, L"BatangChe", - L"WenQuanYi Zen Hei Mono,AR PL UMing CN,AR PL UMing HK,AR PL UMing " - L"TW,WenQuanYi Zen Hei,WenQuanYi Micro Hei", - 1, 1252}, - {0x20b3bd3a, L"BrushScriptMT", - L"KacstQurn,Droid Arabic Naskh,Droid Sans Ethiopic,Droid Sans " - L"Japanese,URW Chancery L,Liberation Sans", - 8, 1252}, - {0x220877aa, L"Candara", L"Droid Sans Japanese,DejaVu Sans", 0, 1252}, - {0x22135007, L"FreestyleScript-Regular", - L"KacstQurn,Droid Sans Japanese,Liberation Sans", 8, 1252}, - {0x251059c3, L"Chiller", - L"KacstQurn,Droid Arabic Naskh,Droid Sans Ethiopic,Droid Sans " - L"Japanese,Liberation Sans", - 0, 1252}, - {0x25bed6dd, L"MSReferenceSansSerif", - L"DejaVu Sans Condensed,Ubuntu Condensed,Droid Sans Japanese,AR PL UKai " - L"HK", - 0, 1252}, - {0x28154c81, L"Parchment-Regular", L"Droid Sans Japanese,Liberation Sans", - 8, 1252}, - {0x29711eb9, L"STLiti", L"AR PL UKai HK", 0, 936}, - {0x2b1993b4, L"Basemic", - L"Liberation Serif,Droid Sans Japanese,Liberation Sans", 0, 1252}, - {0x2b316339, L"NiagaraSolid-Reg", L"Droid Sans Japanese,Liberation Sans", 0, - 1252}, - {0x2c147529, L"FootlightMTLight", - L"KacstQurn,Droid Sans Japanese,Liberation Sans", 0, 1252}, - {0x2c198928, L"HarlowSolid", - L"KacstQurn,Droid Sans Japanese,Liberation Sans", 0, 1252}, - {0x2c6ac6b2, L"LucidaBright", - L"KacstQurn,Droid Arabic Naskh,Droid Sans Ethiopic,mry_KacstQurn,Droid " - L"Sans Japanese,Liberation Sans", - 2, 1252}, - {0x2c9f38e2, L"KozukaMinchoPro-VIR", L"DejaVu Sans", 0, 1252}, - {0x2d5a47b0, L"STCaiyun", L"AR PL UKai HK", 0, 936}, - {0x2def26bf, L"BernardMT-Condensed", - L"KacstQurn,Droid Sans Japanese,DejaVu Serif", 0, 1252}, - {0x2fd8930b, L"KozukaMinchoPr6NR", L"DejaVu Serif", 0, 1252}, - {0x3115525a, L"FangSong_GB2312", - L"WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei,WenQuanYi Zen Hei " - L"Sharp,WenQuanYi Micro Hei", - 0, 1252}, - {0x31327817, L"MyriadPro", - L"Ubuntu Condensed,Droid Sans Japanese, FreeSerif", 0, 1252}, - {0x32244975, L"Helvetica", - L"Ubuntu,DejaVu Sans Condensed,Liberation Sans,Liberation Sans " - L"Narrow,Nimbus Sans L", - 0, 1252}, - {0x32ac995c, L"Terminal", L"DejaVu Serif", 0, 1252}, - {0x338d648a, L"NiagaraEngraved-Reg", L"Droid Sans Japanese,DejaVu Serif", 0, - 1252}, - {0x33bb65f2, L"Sylfaen", L"Droid Sans Japanese,DejaVu Sans", 2, 1252}, - {0x3402c30e, L"MSPMincho", - L"WenQuanYi Zen Hei Mono,AR PL UMing CN,AR PL UMing HK,AR PL UMing TW", 2, - 1252}, - {0x3412bf31, L"SimSun-PUA", - L"WenQuanYi Zen Hei Mono,AR PL UMing CN,AR PL UMing CN,AR PL UMing HK", 0, - 936}, - {0x36eb39b9, L"BerlinSansFB", - L"Droid Sans Japanese,Liberation Serif,Ubuntu,FreeSerif", 0, 1252}, - {0x36f42055, L"UniversATT", L"Microsoft Sans Serif", 0, 1252}, - {0x3864c4f6, L"HighTowerText", L"Droid Sans Japanese,DejaVu Serif", 2, - 1252}, - {0x3a257d03, L"FangSong_GB2312", - L"WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei", 0, 1252}, - {0x3c7d1d07, L"Garamond3LTStd", - L"Droid Sans Japanese,Ubuntu Condensed,DejaVu Sans Condensed,Liberation " - L"Serif,Ubuntu,FreeSerif", - 2, 1252}, - {0x3cdae668, L"FreestyleScript", - L"KacstQurn,Droid Sans Japanese,DejaVu Sans", 8, 1252}, - {0x3d55aed7, L"Jokerman", L"Droid Sans Japanese,DejaVu Sans", 0, 1252}, - {0x3d5b4385, L"PMingLiU", - L"WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei,WenQuanYi Zen Hei " - L"Sharp,WenQuanYi Micro Hei", - 2, 1252}, - {0x3d9b7669, L"EstrangeloEdessa", L"Droid Sans Japanese,DejaVu Sans", 0, - 1252}, - {0x3e532d74, L"FranklinGothicMedium", L"Droid Sans Japanese,Ubuntu", 0, - 1252}, - {0x3e6aa32d, L"NSimSun", - L"WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei,WenQuanYi Zen Hei " - L"Sharp,WenQuanYi Micro Hei", - 1, 936}, - {0x3f6c36a8, L"Gautami", - L"Droid Arabic Naskh,Droid Sans Ethiopic, mry_KacstQurn,Droid Sans " - L"Japanese,FreeSans", - 0, 1252}, - {0x3ff32662, L"Chiller-Regular", - L"KacstQurn,Droid Arabic Naskh,Droid Sans Ethiopic,FreeSans", 0, 1252}, - {0x409de312, L"ModernNo.20", - L"KacstQurn,Droid Sans Japanese,Nimbus Sans L,Nimbus Sans L,FreeSans", 2, - 1252}, - {0x41443c5e, L"Georgia", L"Droid Sans Japanese,FreeSans", 2, 1252}, - {0x4160ade5, L"BellGothicStdBlack", L"FreeSans", 0, 1252}, - {0x421976c4, L"Modern-Regular", L"FreeSans", 2, 1252}, - {0x422a7252, L"Stencil", L"Droid Sans Japanese,FreeSans,Liberation Sans", 0, - 1252}, - {0x42c8554f, L"Fixedsys", L"FreeSerif", 0, 1252}, - {0x435cb41d, L"Roman", L"FreeSerif", 0, 1252}, - {0x47882383, L"CourierNew", - L"FreeMono,WenQuanYi Micro Hei Mono,AR PL UKai CN,AR PL UKai HK,AR PL " - L"UKai TW,AR PL UKai TW MBE,DejaVu Sans", - 1, 1252}, - {0x480a2338, L"BerlinSansFBDemi", L"Droid Sans Japanese,Liberation Serif", - 0, 1252}, - {0x480bf7a4, L"CourierStd", L"DejaVu Sans", 0, 1252}, - {0x481ad6ed, L"VladimirScript", L"Droid Sans Japanese,DejaVu Serif", 8, - 1252}, - {0x4911577a, L"YouYuan", - L"WenQuanYi Zen Hei Mono,AR PL UMing CN,AR PL UMing HK,AR PL UMing TW", 1, - 936}, - {0x4a788d72, L"STXingkai", L"AR PL UKai HK,AR PL UMing HK,AR PL UKai CN", 0, - 936}, - {0x4bf88566, L"SegoeCondensed", L"FreeSerif", 0, 1252}, - {0x4ccf51a4, L"BerlinSansFB-Reg", L"Droid Sans Japanese,Liberation Serif", - 0, 1252}, - {0x4ea967ce, L"GulimChe", - L"WenQuanYi Zen Hei Mono,AR PL UKai CN,AR PL UKai HK,AR PL UKai TW,AR PL " - L"UKai TW MBE", - 1, 1252}, - {0x4f68bd79, L"LetterGothicStd", - L"FreeMono,Liberation Mono,Andale Mono,WenQuanYi Micro Hei Mono", 0, 1252}, - {0x51a0d0e6, L"KozukaGothicPr6NM", L"FreeSerif", 0, 1252}, - {0x531b3dea, L"BasemicSymbol", L"FreeSerif", 0, 1252}, - {0x5333fd39, L"CalifornianFB-Reg", - L"Droid Sans Japanese,URW Chancery L,FreeSerif", 2, 1252}, - {0x53561a54, L"FZYTK--GBK1-0", - L"WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei,WenQuanYi Zen Hei " - L"Sharp,WenQuanYi Micro Hei", - 0, 936}, - {0x55e0dde6, L"LucidaSansTypewriter", - L"Ubuntu Mono,DejaVu Sans Mono,Nimbus Mono L,Liberation Mono,Courier 10 " - L"Pitch,FreeMono", - 0, 1252}, - {0x574d4d3d, L"AdobeArabic", L"Droid Sans Japanese,DejaVu Sans", 0, 1252}, - {0x5792e759, L"STKaiti", L"WenQuanYi Micro Hei Mono", 0, 936}, - {0x5921978e, L"LucidaSansUnicode", L"Droid Sans Japanese,DejaVu Sans", 0, - 1252}, - {0x594e2da4, L"Vrinda", - L"Droid Arabic Naskh,Droid Sans Ethiopic,Droid Arabic " - L"Naskh,mry_KacstQurn,Droid Sans Japanese,FreeSans,FreeSerif", - 0, 1252}, - {0x59baa9a2, L"KaiTi_GB2312", - L"WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei,WenQuanYi Zen Hei " - L"Sharp,WenQuanYi Micro Hei", - 0, 1252}, - {0x5cfedf4f, L"BaskOldFace", - L"KacstQurn,Droid Sans Japanese,Ubuntu,Liberation Serif", 0, 1252}, - {0x5e16ac91, L"TrajanPro", - L"Nimbus Sans L,AR PL UMing HK,AR PL UKai HK,AR PL UMing TW,AR PL UMing " - L"TW MBE,DejaVu Sans,DejaVu Serif", - 0, 1252}, - {0x5f388196, L"ITCLegacySansStdMedium", - L"Liberation Serif,FreeSerif,FreeSans,Ubuntu", 0, 1252}, - {0x5f97921c, L"AdobeMyungjoStdM", - L"WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei,WenQuanYi Zen Hei " - L"Sharp,WenQuanYi Micro Hei", - 0, 936}, - {0x5fefbfad, L"Batang", - L"WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei,WenQuanYi Zen Hei " - L"Sharp,WenQuanYi Micro Hei", - 2, 1252}, - {0x605342b9, L"DotumChe", - L"WenQuanYi Zen Hei Mono,AR PL UMing CN,AR PL UMing HK,AR PL UMing TW", 1, - 1252}, - {0x608c5f9a, L"KaiTi_GB2312", - L"WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei,WenQuanYi Zen Hei " - L"Sharp,WenQuanYi Micro Hei", - 0, 936}, - {0x61efd0d1, L"MaturaMTScriptCapitals", - L"KacstQurn,Droid Arabic Naskh,Droid Sans Ethiopic,mry_KacstQurn,Droid " - L"Sans Japanese,DejaVu Serif,DejaVu Sans", - 0, 1252}, - {0x626608a9, L"MVBoli", - L"Droid Arabic Naskh,Droid Sans Ethiopic,mry_KacstQurn,Droid Sans " - L"Ethiopic,Droid Sans Japanese,DejaVu Sans", - 0, 1252}, - {0x630501a3, L"SmallFonts", L"DejaVu Serif", 0, 1252}, - {0x65d0e2a9, L"FZYTK--GBK1-0", - L"WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei,WenQuanYi Zen Hei " - L"Sharp,WenQuanYi Micro Hei", - 0, 936}, - {0x669f29e1, L"FZSTK--GBK1-0", - L"AR PL UMing CN,AR PL UKai CN, AR PL UMing HK", 0, 936}, - {0x673a9e5f, L"Tunga", - L"Droid Arabic Naskh,Droid Sans Ethiopic,mry_KacstQurn,Droid Sans " - L"Japanese,DejaVu Serif", - 0, 1252}, - {0x691aa4ce, L"NiagaraSolid", L"Droid Sans Japanese,DejaVu Serif", 0, 1252}, - {0x696259b7, L"Corbel", L"Droid Sans Japanese,DejaVu Sans", 0, 1252}, - {0x696ee9be, L"STXihei", L"WenQuanYi Micro Hei Mono", 0, 936}, - {0x6c59cf69, L"Dotum", L"WenQuanYi Zen Hei Mono", 0, 1252}, - {0x707fa561, L"Gungsuh", L"WenQuanYi Zen Hei Mono", 2, 1252}, - {0x71416bb2, L"ZWAdobeF", - L"KacstArt,KacstBookm,KacstDecorative,KacstDigital,KacstFarsi,KacstLetter," - L"KacstOffice,Dingbats,FreeSerif", - 0, 1252}, - {0x71b41801, L"Verdana", - L"DejaVu Sans Condensed,Ubuntu Condensed,Droid Sans Japanese,DejaVu Sans", - 0, 1252}, - {0x73f25e4c, L"PalatinoLinotype", L"Droid Sans Japanese,FreeSerif", 0, - 1252}, - {0x73f4d19f, L"NiagaraEngraved", L"Droid Sans Japanese,FreeSerif", 0, 1252}, - {0x74001694, L"MyriadProBlack", L"Droid Sans Japanese,AR PL UKai HK", 0, - 1252}, - {0x74b14d8f, L"Haettenschweiler", L"Droid Sans Japanese,DejaVu Serif", 0, - 1252}, - {0x74cb44ee, L"NSimSun", L"WenQuanYi Zen Hei Mono", 1, 936}, - {0x76b4d7ff, L"Shruti", - L"Droid Arabic Naskh,Droid Sans Ethiopic,mry_KacstQurn,Droid Sans " - L"Japanese,FreeSans", - 0, 1252}, - {0x788b3533, L"Webdings", L"FreeSans", 6, 42}, - {0x797dde99, L"MSSerif", L"FreeSans", 0, 1252}, - {0x7a0f9e9e, L"MSMincho", - L"WenQuanYi Micro Hei Mono,AR PL UMing CN,AR PL UMing HK,AR PL UMing TW", - 1, 1252}, - {0x7b439caf, L"OldEnglishTextMT", - L"Droid Sans Japanese,Liberation Sans,Ubuntu", 0, 1252}, - {0x8213a433, L"LucidaSans-Typewriter", - L"Ubuntu Mono,Liberation Mono,DejaVu Sans Mono", 0, 1252}, - {0x82fec929, L"AdobeSongStdL", - L"WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei,WenQuanYi Zen Hei " - L"Sharp,WenQuanYi Micro Hei", - 0, 936}, - {0x83581825, L"Modern", L"FreeSans", 0, 1252}, - {0x835a2823, L"Algerian", - L"KacstQurn,Droid Sans Japanese,FreeSans,Liberation Sans,Ubuntu", 0, 1252}, - {0x83dab9f5, L"Script", L"FreeSans", 0, 1252}, - {0x847b56da, L"Tahoma", - L"Droid Sans Japanese,DejaVu Sans Condensed,FreeSerif", 0, 1252}, - {0x8a783cb2, L"SimSun-PUA", - L"WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei,WenQuanYi Zen Hei " - L"Sharp,WenQuanYi Micro Hei", - 0, 1252}, - {0x8b5cac0e, L"Onyx", L"Droid Sans Japanese,Liberation Sans", 0, 1252}, - {0x8c6a499e, L"Gulim", - L"WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei,WenQuanYi Zen Hei " - L"Sharp,WenQuanYi Micro Hei", - 0, 1252}, - {0x8e0af790, L"JuiceITC", L"Droid Sans Japanese,Liberation Sans", 0, 1252}, - {0x8e8d43b2, L"Centaur", - L"KacstQurn,Droid Sans Japanese,Khmer OS,Khmer OS System", 2, 1252}, - {0x8ee4dcca, L"BookshelfSymbol7", L"Liberation Sans", 0, 1252}, - {0x90794800, L"BellGothicStdLight", L"Liberation Sans", 0, 1252}, - {0x909b516a, L"Century", - L"Droid Sans Japanese,Liberation Sans,Liberation Mono,Liberation Serif", 2, - 1252}, - {0x92ae370d, L"MSOutlook", L"Liberation Sans", 4, 42}, - {0x93c9fbf1, L"LucidaFax", - L"KacstQurn,Droid Arabic Naskh,Droid Sans " - L"Ethiopic,mry_KacstQurn,Liberation Sans", - 2, 1252}, - {0x9565085e, L"BookAntiqua", - L"Droid Sans Japanese,Liberation Sans,Liberation Serif", 2, 1252}, - {0x9856d95d, L"AdobeMingStdL", L"AR PL UMing HK", 0, 949}, - {0x9bbadd6b, L"ColonnaMT", - L"KacstQurn,Droid Sans Japanese,Khmer OS,Khmer OS System", 0, 1252}, - {0x9cbd16a4, L"ShowcardGothic-Reg", - L"Droid Sans Japanese,Liberation Sans,Ubuntu", 0, 1252}, - {0x9d73008e, L"MSSansSerif", L"FreeSerif", 0, 1252}, - {0xa0607db1, L"GungsuhChe", - L"WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei,WenQuanYi Zen Hei " - L"Sharp,WenQuanYi Micro Hei", - 1, 1252}, - {0xa0bcf6a1, L"LatinWide", L"FreeSerif", 2, 1252}, - {0xa1429b36, L"Symbol", L"FreeSerif", 6, 42}, - {0xa1fa5abc, L"Wingdings2", L"FreeSerif", 6, 42}, - {0xa1fa5abd, L"Wingdings3", L"FreeSerif", 6, 42}, - {0xa427bad4, L"InformalRoman-Regular", - L"Droid Arabic Naskh,Droid Sans Ethiopic,mry_KacstQurn,Droid Sans " - L"Japanese,FreeSerif", - 8, 1252}, - {0xa8b92ece, L"FZSTK--GBK1-0", L"AR PL UMing CN", 0, 936}, - {0xa8d83ece, L"CalifornianFB", L"Droid Sans Japanese,FreeSerif", 2, 1252}, - {0xaa3e082c, L"Kingsoft-Phonetic", - L"Tibetan Machine Uni,LKLUG,Samyak Gujarati,Droid Sans " - L"Thai,utkal,Kedage,Mallige,AR PL UKai CN", - 0, 1252}, - {0xaa6bcabe, L"HarlowSolidItalic", - L"KacstQurn,Droid Sans Japanese,Liberation Serif", 0, 1252}, - {0xade5337c, L"MSUIGothic", - L"WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei,WenQuanYi Zen Hei " - L"Sharp,WenQuanYi Micro Hei", - 0, 1252}, - {0xb08dd941, L"WideLatin", - L"KacstQurn,Droid Arabic Naskh,Droid Sans Ethiopic,mry_KacstQurn,Droid " - L"Sans Japanese,Liberation Serif", - 2, 1252}, - {0xb12765e0, L"ITCLegacySansStdBook", - L"AR PL UMing HK,AR PL UKai HK,FreeSerif,Ubuntu,FreeSans", 0, 1252}, - {0xb207f05d, L"PoorRichard", L"Droid Sans Japanese,Liberation Serif", 2, - 1252}, - {0xb3bc492f, L"JuiceITC-Regular", L"Droid Sans Japanese,Liberation Serif", - 0, 1252}, - {0xb5545399, L"Marlett", L"Liberation Serif", 4, 42}, - {0xb5dd1ebb, L"BritannicBold", - L"KacstQurn,Droid Arabic Naskh,Droid Sans " - L"Ethiopic,mry_KacstQurn,Liberation Serif", - 0, 1252}, - {0xb699c1c5, L"LucidaCalligraphy-Italic", - L"KacstQurn,Droid Arabic Naskh,Droid Sans Ethiopic,mry_KacstQurn,Droid " - L"Sans Japanese,DejaVu Serif", - 0, 1252}, - {0xb725d629, L"TimesNewRoman", L"Droid Sans Japanese,Liberation Sans", 2, - 1252}, - {0xb7eaebeb, L"AdobeHeitiStdR", - L"WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei,WenQuanYi Zen Hei " - L"Sharp,WenQuanYi Micro Hei", - 0, 936}, - {0xbd29c486, L"BerlinSansFBDemi-Bold", L"Droid Sans Japanese,DejaVu Serif", - 0, 1252}, - {0xbe8a8db4, L"BookshelfSymbolSeven", L"DejaVu Sans", 0, 1252}, - {0xc16c0118, L"AdobeHebrew", L"Droid Sans Japanese,Ubuntu,Liberation Serif", - 0, 1252}, - {0xc318b0af, L"MyriadProLight", - L"Droid Sans Japanese,AR PL UKai HK,AR PL UMing HK,AR PL UKai CN", 0, - 1252}, - {0xc65e5659, L"CambriaMath", L"Droid Sans Japanese,FreeSerif,FreeMono", 2, - 1252}, - {0xc75c8f05, L"LucidaConsole", - L"Liberation Mono,DejaVu Sans Mono,FreeMono,WenQuanYi Micro Hei Mono", 1, - 1252}, - {0xca7c35d6, L"Calibri", L"Droid Sans Japanese,DejaVu Sans", 0, 1252}, - {0xcb053f53, L"MicrosoftYaHei", - L"WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei,WenQuanYi Zen Hei " - L"Sharp,WenQuanYi Micro Hei", - 0, 936}, - {0xcb7190f9, L"Magneto-Bold", - L"Droid Arabic Naskh,Droid Sans Ethiopic,mry_KacstQurn,Droid Sans " - L"Japanese,DejaVu Serif", - 0, 1252}, - {0xcca00cc5, L"System", L"DejaVu Sans", 0, 1252}, - {0xccad6f76, L"Jokerman-Regular", L"Droid Sans Japanese,DejaVu Sans", 0, - 1252}, - {0xccc5818c, L"EuroSign", L"DejaVu Serif", 0, 1252}, - {0xcf3d7234, L"LucidaHandwriting-Italic", - L"Liberation Sans Narrow,Ubuntu Condensed,Nimbus Sans L,DejaVu Serif", 0, - 1252}, - {0xcf7b8fdb, L"MinionPro", L"DejaVu Sans", 0, 1252}, - {0xcfe5755f, L"Simhei", - L"WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei,WenQuanYi Zen Hei " - L"Sharp,WenQuanYi Micro Hei", - 1, 936}, - {0xd011f4ee, L"MSPGothic", - L"WenQuanYi Zen Hei Mono,AR PL UMing CN,AR PL UMing HK,AR PL UMing TW", 0, - 1252}, - {0xd060e7ef, L"Vivaldi", - L"KacstQurn,Droid Sans Japanese,Liberation Sans,Ubuntu", 8, 1252}, - {0xd07edec1, L"FranklinGothic-Medium", L"Droid Sans Japanese,Ubuntu", 0, - 1252}, - {0xd107243f, L"SimSun", L"WenQuanYi Zen Hei Mono", 0, 936}, - {0xd1881562, L"ArialNarrow", - L"Liberation Sans Narrow,Droid Sans Japanese,FreeSerif", 0, 1252}, - {0xd22b7dce, L"BodoniMTPosterCompressed", - L"Droid Sans Japanese,DejaVu Serif", 0, 1252}, - {0xd22bfa60, L"ComicSansMS", - L"Droid Sans Japanese,FreeMono,Liberation Mono", 8, 1252}, - {0xd3bd0e35, L"Bauhaus93", - L"KacstQurn,Droid Sans Japanese,Liberation Sans,Ubuntu", 0, 1252}, - {0xd429ee7a, L"STFangsong", L"WenQuanYi Micro Hei Mono", 0, 936}, - {0xd6679c12, L"BernardMTCondensed", - L"KacstQurn,Droid Sans Japanese,Nimbus Sans L,URW Chancery " - L"L,KacstOne,Liberation Sans", - 0, 1252}, - {0xd8e8a027, L"LucidaSans", - L"Liberation Sans Narrow,Nimbus Sans L,KacstQurn,Droid Arabic Naskh,Droid " - L"Sans Ethiopic,DejaVu Serif Condensed,Liberation Mono,Ubuntu", - 0, 1252}, - {0xd9fe7761, L"HighTowerText-Reg", - L"Droid Sans Japanese,Ubuntu,Liberation Serif", 2, 1252}, - {0xda7e551e, L"STSong", L"WenQuanYi Micro Hei Mono", 0, 936}, - {0xdaa6842d, L"STZhongsong", - L"WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei,WenQuanYi Zen Hei " - L"Sharp,WenQuanYi Micro Hei", - 0, 936}, - {0xdaaab93f, L"STFangsong", - L"WenQuanYi Micro Hei Mono,WenQuanYi Zen Hei Mono,WenQuanYi Zen " - L"Hei,WenQuanYi Zen Hei Sharp", - 0, 936}, - {0xdaeb0713, L"STSong", - L"WenQuanYi Micro Hei Mono,WenQuanYi Zen Hei Mono,WenQuanYi Zen " - L"Hei,WenQuanYi Zen Hei Sharp", - 0, 936}, - {0xdafedbef, L"STCaiyun", L"AR PL UKai HK,AR PL UMing HK,AR PL UKai CN", 0, - 936}, - {0xdb00a3d9, L"Broadway", - L"KacstQurn,Droid Sans Japanese,DejaVu Sans,FreeMono,Liberation Mono", 0, - 1252}, - {0xdb1f5ad4, L"STXinwei", L"AR PL UKai HK,AR PL UMing HK,AR PL UKai CN", 0, - 936}, - {0xdb326e7f, L"STKaiti", - L"WenQuanYi Micro Hei Mono,WenQuanYi Zen Hei Mono,WenQuanYi Zen " - L"Hei,WenQuanYi Zen Hei Sharp", - 0, 936}, - {0xdb69595a, L"STHupo", - L"WenQuanYi Micro Hei Mono,WenQuanYi Zen Hei Mono,WenQuanYi Zen " - L"Hei,WenQuanYi Zen Hei Sharp", - 0, 936}, - {0xdba0082c, L"STXihei", - L" WenQuanYi Micro Hei Mono,WenQuanYi Zen Hei Mono,WenQuanYi Zen " - L"Hei,WenQuanYi Zen Hei Sharp", - 0, 936}, - {0xdbd0ab18, L"STXingkai", L"AR PL UKai HK,AR PL UMing HK,AR PL UKai CN", 0, - 936}, - {0xdc1a7db1, L"STLiti", L"AR PL UKai HK,AR PL UMing HK,AR PL UKai CN", 0, - 936}, - {0xdc33075f, L"KristenITC-Regular", - L"Droid Arabic Naskh,Droid Sans Ethiopic,mry_KacstQurn,DejaVu Sans " - L"Condensed,Ubuntu,Liberation Sans", - 8, 1252}, - {0xdcc7009c, L"Harrington", - L"KacstQurn,Droid Sans Japanese,Liberation Serif,FreeSerif,Ubuntu", 0, - 1252}, - {0xdd712466, L"ArialBlack", - L"Droid Sans Japanese,DejaVu Sans,DejaVu Serif,FreeMono", 0, 1252}, - {0xdde87b3e, L"Impact", L"Droid Sans Japanese,DejaVu Serif", 0, 1252}, - {0xdf69fb32, L"SnapITC", - L"Liberation Sans Narrow,Ubuntu Condensed,DejaVu Sans,DejaVu " - L"Serif,FreeMono", - 0, 1252}, - {0xdf8b25e8, L"CenturyGothic", - L"Droid Sans Japanese,Liberation Mono,Liberation Sans,Liberation Serif", 0, - 1252}, - {0xe0f705c0, L"KristenITC", - L"Droid Arabic Naskh,Droid Sans Ethiopic,mry_KacstQurn,DejaVu Sans " - L"Condensed,Ubuntu,Liberation Sans", - 8, 1252}, - {0xe1427573, L"Raavi", - L"Droid Arabic Naskh,Droid Sans " - L"Ethiopic,mry_KacstQurn,FreeSerif,Liberation Serif,Khmer OS", - 0, 1252}, - {0xe2cea0cb, L"Magneto", - L"Droid Arabic Naskh,Droid Sans Ethiopic,mry_KacstQurn,DejaVu " - L"Serif,DejaVu Serif Condensed,DejaVu Sans", - 0, 1252}, - {0xe36a9e17, L"Ravie", - L"Droid Arabic Naskh,Droid Sans Ethiopic,mry_KacstQurn,DejaVu " - L"Serif,DejaVu Sans,FreeMono", - 0, 1252}, - {0xe433f8e2, L"Parchment", L"Droid Sans Japanese,DejaVu Serif", 8, 1252}, - {0xe43dff4a, L"Wingdings", L"DejaVu Serif", 4, 42}, - {0xe4e2c405, L"MTExtra", L"DejaVu Serif", 6, 42}, - {0xe618cc35, L"InformalRoman", - L"Droid Arabic Naskh,Droid Sans Ethiopic,mry_KacstQurn,Droid Sans " - L"Japanese,Nimbus Sans L,DejaVu Sans Condensed,Ubuntu,Liberation Sans", - 8, 1252}, - {0xe6c27ffc, L"Mistral", L"Droid Sans Japanese,DejaVu Serif", 8, 1252}, - {0xe7ebf4b9, L"Courier", L"DejaVu Sans,DejaVu Sans Condensed,FreeSerif", 0, - 1252}, - {0xe8bc4a9d, L"MSReferenceSpecialty", L"DejaVu Serif", 0, 1252}, - {0xe90fb013, L"TempusSansITC", - L"Droid Sans Japanese,Ubuntu,Liberation Serif,FreeSerif", 0, 1252}, - {0xec637b42, L"Consolas", - L"DejaVu Sans Condensed,AR PL UKai CN,AR PL UKai HK,AR PL UKai " - L"TW,FreeSerif,FreeSans", - 1, 1252}, - {0xed3a683b, L"STXinwei", L"AR PL UKai HK,AR PL UMing HK,AR PL UKai CN", 0, - 936}, - {0xef264cd1, L"LucidaHandwriting", - L"Liberation Sans Narrow,Ubuntu Condensed,Nimbus Sans " - L"L,KacstQurn,Liberation Mono", - 0, 1252}, - {0xf086bca2, L"BaskervilleOldFace", - L"KacstQurn,Droid Sans Japanese,Liberation Serif,Ubuntu,FreeSerif", 0, - 1252}, - {0xf1028030, L"Mangal", - L"FreeSans,TSCu_Paranar,Garuda,Liberation Sans,Liberation Sans " - L"Narrow,Nimbus Sans L", - 2, 1252}, - {0xf1da7eb9, L"ShowcardGothic", - L"Droid Sans Japanese,DejaVu Serif Condensed,DejaVu Sans " - L"Condensed,Liberation Sans,Ubuntu", - 0, 1252}, - {0xf210f06a, L"ArialMT", - L"Liberation Sans,Liberation Sans Narrow,FreeSans,Nimbus Sans L,Khmer OS " - L"System,Khmer OS", - 0, 1252}, - {0xf477f16a, L"Latha", - L"Liberation Sans Narrow,Nimbus Sans L,Droid Arabic " - L"Naskh,mry_KacstQurn,FreeSerif,Nimbus Sans L", - 0, 1252}, - {0xf616f3dd, L"LiSu", - L"WenQuanYi Zen Hei Mono,AR PL UMing CN,AR PL UMing HK,AR PL UMing TW,AR " - L"PL UMing TW MBE", - 1, 936}, - {0xfa479aa6, L"MicrosoftYaHei", - L"WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei,WenQuanYi Zen Hei " - L"Sharp,WenQuanYi Micro Hei", - 0, 936}, - {0xfcd19697, L"BookmanOldStyle", - L"Droid Sans Japanese,Liberation Mono,Liberation Sans,Liberation Serif", 0, - 1252}, - {0xfe209a82, L"LucidaCalligraphy", - L"KacstQurn,Droid Arabic Naskh,Droid Sans Ethiopic,mry_KacstQurn,Droid " - L"Sans Japanese,DejaVu Serif,DejaVu Sans,FreeMono", - 0, 1252}, - {0xfef135f8, L"AdobeHeitiStd-Regular", - L"WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei,WenQuanYi Zen Hei " - L"Sharp,WenQuanYi Micro Hei", - 0, 936}, -}; -#elif _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ -const XFA_FONTINFO g_XFAFontsMap[] = { - {0x01d5d33e, L"SimSun", L"STHeiti,Heiti TC,STFangsong", 0, 936}, - {0x01e4f102, L"YouYuan", L"STHeiti,Heiti TC,STFangsong", 1, 936}, - {0x030549dc, L"LiSu", L"STHeiti,Heiti TC,STFangsong", 1, 936}, - {0x032edd44, L"Simhei", L"STHeiti,Heiti TC,STFangsong", 1, 936}, - {0x03eac6fc, L"PoorRichard-Regular", - L"Noteworthy,Avenir Next Condensed,Impact", 2, 1252}, - {0x03ed90e6, L"Nina", L"Microsoft Sans Serif", 0, 1252}, - {0x077b56b3, L"KingsoftPhoneticPlain", - L"LastResort,Apple " - L"Chancery,STIXVariants,STIXSizeOneSym,STIXSizeOneSym,Apple Braille", - 0, 1252}, - {0x078ed524, L"MicrosoftSansSerif", L"Songti SC,Apple Symbols", 0, 1252}, - {0x089b18a9, L"Arial", - L"Arial Unicode MS,Microsoft Sans Serif,Apple Symbols", 0, 1252}, - {0x0b2cad72, L"MonotypeCorsiva", L"Arial Narrow,Impact", 8, 1252}, - {0x0bb003e7, L"Kartika", - L"Arial Unicode MS,Microsoft Sans Serif,Arial Narrow,Damascus", 2, 1252}, - {0x0bb469df, L"VinerHandITC", L"Comic Sans MS,Songti SC,STSong", 8, 1252}, - {0x0bc1a851, L"SegoeUI", L"Apple Symbols", 0, 1252}, - {0x0c112ebd, L"KozukaGothicPro-VIM", L"Microsoft Sans Serif,Apple Symbols", - 0, 1252}, - {0x0cfcb9c1, L"AdobeThai", L"Avenir Next Condensed Ultra Light", 0, 847}, - {0x0e7de0f9, L"Playbill", L"STIXNonUnicode", 0, 1252}, - {0x0eff47c3, L"STHupo", L"Kaiti SC,Songti SC,STHeiti", 0, 936}, - {0x107ad374, L"Constantia", L"Arial Unicode MS,Palatino,Baskerville", 2, - 1252}, - {0x12194c2d, L"KunstlerScript", - L"Avenir Next Condensed Demi Bold,Arial Narrow", 8, 1252}, - {0x135ef6a1, L"MinionProSmBd", L"Microsoft Sans Serif,Apple Symbols", 0, - 1252}, - {0x158c4049, L"Garamond", L"Impact,Arial Narrow", 2, 1252}, - {0x160ecb24, L"STZhongsong", L"STFangsong,Songti SC", 0, 936}, - {0x161ed07e, L"MSGothic", - L"WenQuanYi Zen Hei Mono,AR PL UMing CN,AR PL UMing HK,AR PL UMing " - L"TW,Microsoft Sans Serif,Apple Symbols", - 1, 1252}, - {0x171d1ed1, L"SnapITC-Regular", L"STHeiti,Arial Black", 0, 1252}, - {0x18d1188f, L"Cambria", L"Arial Unicode MS", 2, 1252}, - {0x18eaf350, L"ArialUnicodeMS", L"Microsoft Sans Serif,Apple Symbols", 0, - 936}, - {0x1a92d115, L"MingLiU", L"Heiti SC,STHeiti", 1, 1252}, - {0x1cc217c6, L"TrebuchetMS", L"Damascus,Impact,Arial Narrow", 0, 1252}, - {0x1d649596, L"BasemicTimes", L"Liberation Serif,Impact,Arial Narrow", 0, - 1252}, - {0x1e34ee60, L"BellMT", - L"Papyrus,STIXNonUnicode,Microsoft Sans Serif,Avenir Light", 2, 1252}, - {0x1eb36945, L"CooperBlack", - L"Marion,STIXNonUnicode,Arial Rounded MT Bold,Lucida Grande", 2, 1252}, - {0x1ef7787d, L"BatangChe", - L"WenQuanYi Zen Hei Mono,AR PL UMing CN,,AR PL UMing HK,AR PL UMing TW,AR " - L"PL UMing TW MBE,Arial Unicode MS,Heiti TC", - 1, 1252}, - {0x20b3bd3a, L"BrushScriptMT", - L"STIXNonUnicode,Damascus,Arial Narrow,Avenir Next Condensed,Cochin", 8, - 1252}, - {0x220877aa, L"Candara", L"Cochin,Baskerville,Marion", 0, 1252}, - {0x22135007, L"FreestyleScript-Regular", - L"STIXNonUnicode,Nadeem,Zapf Dingbats", 8, 1252}, - {0x251059c3, L"Chiller", - L"Zapf Dingbats,Damascus,STIXNonUnicode,Papyrus,KufiStandardGK,Baghdad", 0, - 1252}, - {0x25bed6dd, L"MSReferenceSansSerif", - L"Tahoma,Apple Symbols,Apple LiGothic,Arial Unicode MS,Lucida " - L"Grande,Microsoft Sans Serif", - 0, 1252}, - {0x28154c81, L"Parchment-Regular", L"Microsoft Sans Serif,Apple Symbols", 8, - 1252}, - {0x29711eb9, L"STLiti", L"Kaiti SC,Songti SC", 0, 936}, - {0x2b1993b4, L"Basemic", L"Impact,Arial Narrow", 0, 1252}, - {0x2b316339, L"NiagaraSolid-Reg", L"Microsoft Sans Serif,Apple Symbols", 0, - 1252}, - {0x2c147529, L"FootlightMTLight", - L"STIXNonUnicode,Avenir Next Condensed Heavy,PT Sans,Noteworthy", 0, 1252}, - {0x2c198928, L"HarlowSolid", - L"Avenir Medium,Avenir Next Medium,Arial Unicode MS", 0, 1252}, - {0x2c6ac6b2, L"LucidaBright", - L"PT Sans Narrow,Papyrus,Damascus,STIXNonUnicode,Arial Rounded MT " - L"Bold,Comic Sans MS,Avenir Next", - 2, 1252}, - {0x2c9f38e2, L"KozukaMinchoPro-VIR", L"Microsoft Sans Serif,Apple Symbols", - 0, 1252}, - {0x2d5a47b0, L"STCaiyun", L"Kaiti SC,Songti SC", 0, 936}, - {0x2def26bf, L"BernardMT-Condensed", - L"Impact,Avenir Next Condensed Demi Bold,American Typewriter", 0, 1252}, - {0x2fd8930b, L"KozukaMinchoPr6NR", L"Microsoft Sans Serif,Apple Symbols", 0, - 1252}, - {0x3115525a, L"FangSong_GB2312", L"Hiragino Sans GB,STHeiti", 0, 1252}, - {0x31327817, L"MyriadPro", L"Microsoft Sans Serif,Apple Symbols", 0, 1252}, - {0x32244975, L"Helvetica", - L"Arial Narrow,Arial Unicode MS,Damascus,STIXNonUnicode", 0, 1252}, - {0x32ac995c, L"Terminal", L"Microsoft Sans Serif,Apple Symbols", 0, 1252}, - {0x338d648a, L"NiagaraEngraved-Reg", L"Microsoft Sans Serif,Apple Symbols", - 0, 1252}, - {0x33bb65f2, L"Sylfaen", L"Arial Unicode MS,Marion", 2, 1252}, - {0x3402c30e, L"MSPMincho", L"Arial Unicode MS,Apple SD Gothic Neo", 2, - 1252}, - {0x3412bf31, L"SimSun-PUA", L"STHeiti,Heiti TC,STFangsong", 0, 936}, - {0x36eb39b9, L"BerlinSansFB", L"American Typewriter,Impact", 0, 1252}, - {0x36f42055, L"UniversATT", L"Microsoft Sans Serif", 0, 1252}, - {0x3864c4f6, L"HighTowerText", L"STIXGeneral,.Helvetica Neue Desk UI", 2, - 1252}, - {0x3a257d03, L"FangSong_GB2312", L"Hiragino Sans GB,STHeiti", 0, 1252}, - {0x3cdae668, L"FreestyleScript", L"Nadeem,Zapf Dingbats,STIXNonUnicode", 8, - 1252}, - {0x3d55aed7, L"Jokerman", - L"Papyrus,Lucida Grande,Heiti TC,American Typewriter", 0, 1252}, - {0x3d5b4385, L"PMingLiU", L"Heiti SC,STHeiti", 2, 1252}, - {0x3d9b7669, L"EstrangeloEdessa", L"American Typewriter,Marion", 0, 1252}, - {0x3e532d74, L"FranklinGothicMedium", L"Impact,Arial Narrow", 0, 1252}, - {0x3e6aa32d, L"NSimSun", L"STHeiti,STFangsong", 1, 936}, - {0x3f6c36a8, L"Gautami", - L"Damascus,STIXNonUnicode,STIXGeneral,American Typewriter", 0, 1252}, - {0x3ff32662, L"Chiller-Regular", L"Papyrus,KufiStandardGK,Baghdad", 0, - 1252}, - {0x409de312, L"ModernNo.20", L"Avenir Next Condensed,Impact", 2, 1252}, - {0x41443c5e, L"Georgia", L".Helvetica Neue Desk UI,Arial Unicode MS", 2, - 1252}, - {0x4160ade5, L"BellGothicStdBlack", L"Microsoft Sans Serif,Apple Symbols", - 0, 1252}, - {0x421976c4, L"Modern-Regular", L"Impact", 2, 1252}, - {0x422a7252, L"Stencil", L"STIXNonUnicode,Songti SC,Georgia,Baskerville", 0, - 1252}, - {0x42c8554f, L"Fixedsys", L"Microsoft Sans Serif,Apple Symbols", 0, 1252}, - {0x435cb41d, L"Roman", L"Arial Narrow", 0, 1252}, - {0x47882383, L"CourierNew", L"PCMyungjo,Osaka,Arial Unicode MS,Songti SC", - 1, 1252}, - {0x480a2338, L"BerlinSansFBDemi", - L"STIXNonUnicode,American Typewriter,Avenir Next Condensed Heavy", 0, - 1252}, - {0x480bf7a4, L"CourierStd", L"Courier New", 0, 1252}, - {0x481ad6ed, L"VladimirScript", - L"STIXNonUnicode,Avenir Next Condensed,Impact", 8, 1252}, - {0x4911577a, L"YouYuan", L"STHeiti,Heiti TC", 1, 936}, - {0x4a788d72, L"STXingkai", L"Kaiti SC,Songti SC", 0, 936}, - {0x4bf88566, L"SegoeCondensed", L"Microsoft Sans Serif,Apple Symbols", 0, - 1252}, - {0x4ccf51a4, L"BerlinSansFB-Reg", - L"STIXNonUnicode,American Typewriter,Impact", 0, 1252}, - {0x4ea967ce, L"GulimChe", L"Arial Unicode MS,Heiti TC,STFangsong", 1, 1252}, - {0x4f68bd79, L"LetterGothicStd", - L"Courier New,Andale Mono,Ayuthaya,PCMyungjo,Osaka", 0, 1252}, - {0x51a0d0e6, L"KozukaGothicPr6NM", L"Microsoft Sans Serif,Apple Symbols", 0, - 1252}, - {0x531b3dea, L"BasemicSymbol", L"Microsoft Sans Serif,Apple Symbols", 0, - 1252}, - {0x5333fd39, L"CalifornianFB-Reg", - L"American Typewriter,Avenir Next Condensed,Impact", 2, 1252}, - {0x53561a54, L"FZYTK--GBK1-0", L"STFangsong,Songti SC,STSong", 0, 936}, - {0x55e0dde6, L"LucidaSansTypewriter", L"Menlo,Courier New,Andale Mono", 0, - 1252}, - {0x574d4d3d, L"AdobeArabic", L"Arial Narrow", 0, 1252}, - {0x5792e759, L"STKaiti", L"Songti SC,Arial Unicode MS", 0, 936}, - {0x5921978e, L"LucidaSansUnicode", L"Lucida Grande,Arial Unicode MS,Menlo", - 0, 1252}, - {0x594e2da4, L"Vrinda", L"Geeza Pro,Damascus,STIXGeneral,Gill Sans", 0, - 1252}, - {0x59baa9a2, L"KaiTi_GB2312", L"Hiragino Sans GB,STHeiti", 0, 1252}, - {0x5cfedf4f, L"BaskOldFace", - L"Avenir Next Condensed Heavy,PT Sans,Avenir Next Condensed", 0, 1252}, - {0x5e16ac91, L"TrajanPro", L"Arial Narrow,PT Sans Narrow,Damascus", 0, - 1252}, - {0x5f97921c, L"AdobeMyungjoStdM", - L"AppleMyungjo,AppleGothic,Arial Unicode MS", 0, 936}, - {0x5fefbfad, L"Batang", L"Arial Unicode MS,Songti SC", 2, 1252}, - {0x605342b9, L"DotumChe", L"Arial Unicode MS,Heiti TC", 1, 1252}, - {0x608c5f9a, L"KaiTi_GB2312", L"Hiragino Sans GB,STHeiti,Heiti TC", 0, 936}, - {0x61efd0d1, L"MaturaMTScriptCapitals", - L"Kokonor,Damascus,STIXNonUnicode,STHeiti,Arial Black,Avenir Next Heavy", - 0, 1252}, - {0x626608a9, L"MVBoli", - L"Apple Braille,Geeza Pro,Microsoft Sans Serif,Apple Symbols", 0, 1252}, - {0x630501a3, L"SmallFonts", L"Microsoft Sans Serif,Apple Symbols", 0, 1252}, - {0x65d0e2a9, L"FZYTK--GBK1-0", L"STFangsong,Songti SC,STSong", 0, 936}, - {0x669f29e1, L"FZSTK--GBK1-0", L"STHeiti,Heiti TC", 0, 936}, - {0x673a9e5f, L"Tunga", - L"Damascus,STIXNonUnicode,Avenir Next Condensed,Avenir Next Condensed " - L"Ultra Light,Futura", - 0, 1252}, - {0x691aa4ce, L"NiagaraSolid", L"Microsoft Sans Serif,Apple Symbols", 0, - 1252}, - {0x696259b7, L"Corbel", L"Cochin,Baskerville,Marion", 0, 1252}, - {0x696ee9be, L"STXihei", L"STHeiti,Heiti TC,Songti SC,Arial Unicode MS", 0, - 936}, - {0x6c59cf69, L"Dotum", L"Arial Unicode MS,Songti SC", 0, 1252}, - {0x707fa561, L"Gungsuh", L"Arial Unicode MS,Heiti TC", 2, 1252}, - {0x71416bb2, L"ZWAdobeF", - L"STIXSizeFourSym,STIXSizeThreeSym,STIXSizeTwoSym,STIXSizeOneSym", 0, - 1252}, - {0x71b41801, L"Verdana", - L"Tahoma,Marion,Apple Symbols,.Helvetica Neue Desk UI,Lucida " - L"Grande,Courier New", - 0, 1252}, - {0x73f25e4c, L"PalatinoLinotype", L"Palatino,Arial Unicode MS", 0, 1252}, - {0x73f4d19f, L"NiagaraEngraved", L"Microsoft Sans Serif,Apple Symbols", 0, - 1252}, - {0x74001694, L"MyriadProBlack", L"Palatino,Baskerville,Marion,Cochin", 0, - 1252}, - {0x74b14d8f, L"Haettenschweiler", L"Microsoft Sans Serif,Apple Symbols", 0, - 1252}, - {0x74cb44ee, L"NSimSun", L"STHeiti,Heiti TC,STFangsong", 1, 936}, - {0x76b4d7ff, L"Shruti", - L"Damascus,STIXNonUnicode,Arial Unicode MS,American Typewriter", 0, 1252}, - {0x788b3533, L"Webdings", L"Microsoft Sans Serif,Apple Symbols", 6, 42}, - {0x797dde99, L"MSSerif", L"Microsoft Sans Serif,Apple Symbols", 0, 1252}, - {0x7a0f9e9e, L"MSMincho", - L"WenQuanYi Zen Hei Mono,AR PL UMing CN,AR PL UMing HK,AR PL UMing TW,AR " - L"PL UMing TW MBE,Arial Unicode MS,Apple SD Gothic Neo", - 1, 1252}, - {0x7b439caf, L"OldEnglishTextMT", - L"STIXNonUnicode,Arial Unicode MS,Baskerville,Avenir Next Medium", 0, - 1252}, - {0x8213a433, L"LucidaSans-Typewriter", - L"Comic Sans MS,Avenir Next,Arial Rounded MT Bold", 0, 1252}, - {0x82fec929, L"AdobeSongStdL", L"Heiti TC,STHeiti", 0, 936}, - {0x83581825, L"Modern", L"Avenir Next Condensed,Impact", 0, 1252}, - {0x835a2823, L"Algerian", - L"STIXNonUnicode,Baskerville,Avenir Next Medium,American Typewriter", 0, - 1252}, - {0x83dab9f5, L"Script", L"Arial Narrow", 0, 1252}, - {0x847b56da, L"Tahoma", L"Songti SC,Apple Symbols", 0, 1252}, - {0x8a783cb2, L"SimSun-PUA", L"STHeiti,Heiti TC,STFangsong", 0, 1252}, - {0x8b5cac0e, L"Onyx", L"Microsoft Sans Serif,Apple Symbols", 0, 1252}, - {0x8c6a499e, L"Gulim", L"Arial Unicode MS,Songti SC", 0, 1252}, - {0x8e0af790, L"JuiceITC", L"Nadeem,Al Bayan", 0, 1252}, - {0x8e8d43b2, L"Centaur", L"Avenir Next Condensed,Noteworthy,Impact", 2, - 1252}, - {0x8ee4dcca, L"BookshelfSymbol7", L"Microsoft Sans Serif,Apple Symbols", 0, - 1252}, - {0x90794800, L"BellGothicStdLight", L"Microsoft Sans Serif,Apple Symbols", - 0, 1252}, - {0x909b516a, L"Century", L"Damascus,Andale Mono,Songti SC,Arial Unicode MS", - 2, 1252}, - {0x92ae370d, L"MSOutlook", L"Microsoft Sans Serif,Apple Symbols", 4, 42}, - {0x93c9fbf1, L"LucidaFax", - L"PT Sans Narrow,Papyrus,Kokonor,Geeza Pro,Arial Rounded MT Bold,Lucida " - L"Grande,Futura", - 2, 1252}, - {0x9565085e, L"BookAntiqua", L"Palatino,Microsoft Sans Serif,Apple Symbols", - 2, 1252}, - {0x9856d95d, L"AdobeMingStdL", L"AHiragino Sans GB,Heiti TC,STHeiti", 0, - 949}, - {0x9bbadd6b, L"ColonnaMT", L"Noteworthy,Avenir Next Condensed,Impact", 0, - 1252}, - {0x9cbd16a4, L"ShowcardGothic-Reg", - L"Arial Unicode MS,Georgia,American Typewriter", 0, 1252}, - {0x9d73008e, L"MSSansSerif", L"Songti SC,Apple Symbols", 0, 1252}, - {0xa0607db1, L"GungsuhChe", - L"WenQuanYi Zen Hei Mono,AR PL UMing CN,AR PL UMing HK,AR PL UMing TW,AR " - L"PL UMing TW MBE,Arial Unicode MS,Heiti TC,STFangsong", - 1, 1252}, - {0xa0bcf6a1, L"LatinWide", L"Zapfino,Arial Black,STHeiti", 2, 1252}, - {0xa1429b36, L"Symbol", L"Microsoft Sans Serif,Apple Symbols", 6, 42}, - {0xa1fa5abc, L"Wingdings2", L"Microsoft Sans Serif,Apple Symbols", 6, 42}, - {0xa1fa5abd, L"Wingdings3", L"Microsoft Sans Serif,Apple Symbols", 6, 42}, - {0xa427bad4, L"InformalRoman-Regular", - L"STIXNonUnicode,Arial Narrow,Avenir Next Condensed Demi Bold", 8, 1252}, - {0xa8b92ece, L"FZSTK--GBK1-0", L"STHeiti,Heiti TC,STFangsong", 0, 936}, - {0xa8d83ece, L"CalifornianFB", - L"American Typewriter,Avenir Next Condensed,Impact", 2, 1252}, - {0xaa3e082c, L"Kingsoft-Phonetic", - L"STIXVariants,STIXSizeOneSym,Apple Braille", 0, 1252}, - {0xaa6bcabe, L"HarlowSolidItalic", - L"STIXNonUnicode,Avenir Medium,Avenir Next Medium,Arial Unicode MS", 0, - 1252}, - {0xade5337c, L"MSUIGothic", L"Arial Unicode MS,Apple SD Gothic Neo", 0, - 1252}, - {0xb08dd941, L"WideLatin", - L"Marion,Papyrus,Nanum Pen Script,Zapf Dingbats,Damascus,Zapfino,Arial " - L"Black,STHeiti", - 2, 1252}, - {0xb12765e0, L"ITCLegacySansStdBook", - L"LastResort,.Helvetica Neue Desk UI,Arial Unicode MS,Palatino", 0, 1252}, - {0xb207f05d, L"PoorRichard", L"Noteworthy,Avenir Next Condensed,Impact", 2, - 1252}, - {0xb3bc492f, L"JuiceITC-Regular", L"Nadeem,Al Bayan,STIXNonUnicode", 0, - 1252}, - {0xb5545399, L"Marlett", L"Microsoft Sans Serif,Apple Symbols", 4, 42}, - {0xb5dd1ebb, L"BritannicBold", - L"Damascus,STIXNonUnicode,Avenir Next Condensed Heavy,PT Sans", 0, 1252}, - {0xb699c1c5, L"LucidaCalligraphy-Italic", L"STHeiti,Arial Black", 0, 1252}, - {0xb725d629, L"TimesNewRoman", L"Microsoft Sans Serif,Apple Symbols", 2, - 1252}, - {0xb7eaebeb, L"AdobeHeitiStdR", L"Heiti TC,STHeiti", 0, 936}, - {0xbd29c486, L"BerlinSansFBDemi-Bold", - L"American Typewriter,Avenir Next Condensed Heavy", 0, 1252}, - {0xbe8a8db4, L"BookshelfSymbolSeven", L"Microsoft Sans Serif,Apple Symbols", - 0, 1252}, - {0xc16c0118, L"AdobeHebrew", - L".Helvetica Neue Desk UI,Palatino,American Typewriter", 0, 1252}, - {0xc318b0af, L"MyriadProLight", L"Palatino,Baskerville,Marion", 0, 1252}, - {0xc65e5659, L"CambriaMath", L"Arial Unicode MS", 2, 1252}, - {0xc75c8f05, L"LucidaConsole", L"Courier New,Menlo,Andale Mono", 1, 1252}, - {0xca7c35d6, L"Calibri", L"Apple Symbols,HeadLineA", 0, 1252}, - {0xcb053f53, L"MicrosoftYaHei", L"Arial Unicode MS", 0, 936}, - {0xcb7190f9, L"Magneto-Bold", L"Lucida Grande", 0, 1252}, - {0xcca00cc5, L"System", L"Microsoft Sans Serif,Apple Symbols", 0, 1252}, - {0xccad6f76, L"Jokerman-Regular", L"Lucida Grande", 0, 1252}, - {0xccc5818c, L"EuroSign", L"Microsoft Sans Serif,Apple Symbols", 0, 1252}, - {0xcf3d7234, L"LucidaHandwriting-Italic", - L"Microsoft Sans Serif,Apple Symbols", 0, 1252}, - {0xcf7b8fdb, L"MinionPro", - L"Bell MT,Corbel,Times New Roman,Cambria,Berlin Sans FB", 0, 1252}, - {0xcfe5755f, L"Simhei", L"STHeiti,Heiti TC,STFangsong", 1, 936}, - {0xd011f4ee, L"MSPGothic", L"Arial Unicode MS,Apple SD Gothic Neo", 0, - 1252}, - {0xd060e7ef, L"Vivaldi", - L"STIXNonUnicode,Arial Unicode MS,Avenir Medium,Avenir Next Medium", 8, - 1252}, - {0xd07edec1, L"FranklinGothic-Medium", L"Impact,Arial Narrow", 0, 1252}, - {0xd107243f, L"SimSun", L"STHeiti,Heiti TC,STFangsong", 0, 936}, - {0xd1881562, L"ArialNarrow", L"PT Sans Narrow,Apple Symbols", 0, 1252}, - {0xd22b7dce, L"BodoniMTPosterCompressed", - L"Microsoft Sans Serif,Apple Symbols", 0, 1252}, - {0xd22bfa60, L"ComicSansMS", - L"Damascus,Georgia,.Helvetica Neue Desk UI,Lucida Grande,Arial Unicode MS", - 8, 1252}, - {0xd3bd0e35, L"Bauhaus93", - L"STIXNonUnicode,Arial Unicode MS,Avenir Next,Avenir", 0, 1252}, - {0xd429ee7a, L"STFangsong", L"Songti SC,Arial Unicode MS", 0, 936}, - {0xd6679c12, L"BernardMTCondensed", - L"Impact,Avenir Next Condensed Demi Bold", 0, 1252}, - {0xd8e8a027, L"LucidaSans", - L"Arial Narrow,Khmer MN,Kokonor,Damascus,Microsoft Sans Serif,Apple " - L"Symbols", - 0, 1252}, - {0xd9fe7761, L"HighTowerText-Reg", - L"STIXGeneral,.Helvetica Neue Desk UI,Trebuchet MS", 2, 1252}, - {0xda7e551e, L"STSong", L"Arial Unicode MS", 0, 936}, - {0xdaa6842d, L"STZhongsong", L"STFangsong,Songti SC,STSong", 0, 936}, - {0xdaaab93f, L"STFangsong", L"Songti SC,Arial Unicode MS", 0, 936}, - {0xdaeb0713, L"STSong", L"Songti SC,Arial Unicode MS", 0, 936}, - {0xdafedbef, L"STCaiyun", L"Kaiti SC,Songti SC,STHeiti", 0, 936}, - {0xdb00a3d9, L"Broadway", - L"Papyrus,STIXNonUnicode,Arial Black,Avenir Next Heavy,Heiti TC", 0, 1252}, - {0xdb1f5ad4, L"STXinwei", L"Kaiti SC,Songti SC,STHeiti", 0, 936}, - {0xdb326e7f, L"STKaiti", L"Songti SC,Arial Unicode MS", 0, 936}, - {0xdb69595a, L"STHupo", L"Kaiti SC,Songti SC,STHeiti", 0, 936}, - {0xdba0082c, L"STXihei", L"Songti SC,Arial Unicode MS", 0, 936}, - {0xdbd0ab18, L"STXingkai", L"Kaiti SC,Songti SC", 0, 936}, - {0xdc1a7db1, L"STLiti", L"Kaiti SC,Songti SC", 0, 936}, - {0xdc33075f, L"KristenITC-Regular", - L"STIXNonUnicode,Damascus,Songti SC,STSong", 8, 1252}, - {0xdcc7009c, L"Harrington", - L"STIXNonUnicode,Avenir Next Condensed Heavy,Noteworthy", 0, 1252}, - {0xdd712466, L"ArialBlack", L"Geeza Pro,Damascus,Songti SC,STSong", 0, - 1252}, - {0xdde87b3e, L"Impact", L"Arial Narrow,Marion", 0, 1252}, - {0xdf69fb32, L"SnapITC", - L"Arial Narrow,PT Sans Narrow,Marion,STHeiti,Arial Black", 0, 1252}, - {0xdf8b25e8, L"CenturyGothic", - L"Damascus,Andale Mono,Songti SC,Arial Unicode MS", 0, 1252}, - {0xe0f705c0, L"KristenITC", L"Songti SC,STSong", 8, 1252}, - {0xe1427573, L"Raavi", - L"Damascus,STIXNonUnicode,Marion,Papyrus,Avenir Next Condensed " - L"Heavy,American Typewriter", - 0, 1252}, - {0xe2cea0cb, L"Magneto", - L"STIXNonUnicode,Damascus,Geeza Pro,Lucida Grande,Georgia,Heiti TC", 0, - 1252}, - {0xe36a9e17, L"Ravie", L"STHeiti,Arial Black", 0, 1252}, - {0xe433f8e2, L"Parchment", L"Microsoft Sans Serif,Apple Symbols", 8, 1252}, - {0xe43dff4a, L"Wingdings", L"Microsoft Sans Serif,Apple Symbols", 4, 42}, - {0xe4e2c405, L"MTExtra", L"Microsoft Sans Serif,Apple Symbols", 6, 42}, - {0xe618cc35, L"InformalRoman", L"Arial Narrow", 8, 1252}, - {0xe6c27ffc, L"Mistral", L"Apple Symbols", 8, 1252}, - {0xe7ebf4b9, L"Courier", L"Courier New", 0, 1252}, - {0xe8bc4a9d, L"MSReferenceSpecialty", L"Microsoft Sans Serif,Apple Symbols", - 0, 1252}, - {0xe90fb013, L"TempusSansITC", - L"STIXNonUnicode,Microsoft Sans Serif,Avenir Light", 0, 1252}, - {0xec637b42, L"Consolas", - L"AR PL UKai CN,AR PL UKai HK,AR PL UKai TW,AR PL UKai TW MBE,AR PL UMing " - L"CN,AR PL UMing HK,Microsoft Sans Serif,Tahoma", - 1, 1252}, - {0xed3a683b, L"STXinwei", L"Kaiti SC,Songti SC,", 0, 936}, - {0xef264cd1, L"LucidaHandwriting", - L"Arial Narrow,Avenir Next Condensed Demi Bold,Avenir Next " - L"Condensed,Avenir Next Condensed Medium,STHeiti,Arial Black", - 0, 1252}, - {0xf086bca2, L"BaskervilleOldFace", - L"STIXNonUnicode,Avenir Next Condensed Heavy,PT Sans", 0, 1252}, - {0xf1028030, L"Mangal", - L"Arial Unicode MS,Microsoft Sans Serif,Arial Narrow,Tahoma", 2, 1252}, - {0xf1da7eb9, L"ShowcardGothic", - L"Papyrus,Arial Unicode MS,Georgia,American Typewriter", 0, 1252}, - {0xf210f06a, L"ArialMT", - L"Arial Unicode MS,Arial Narrow,STIXNonUnicode,Damascus,Avenir Next " - L"Condensed Demi Bold,Avenir Next Condensed Medium,Avenir Next Condensed", - 0, 1252}, - {0xf477f16a, L"Latha", - L"Arial Narrow,Damascus,STIXNonUnicode,American Typewriter", 0, 1252}, - {0xf616f3dd, L"LiSu", L"STHeiti,Heiti TC,STFangsong", 1, 936}, - {0xfa479aa6, L"MicrosoftYaHei", L"Arial Unicode MS", 0, 936}, - {0xfcd19697, L"BookmanOldStyle", - L"Geeza Pro,Damascus,Andale Mono,Songti SC,Arial Unicode MS", 0, 1252}, - {0xfe209a82, L"LucidaCalligraphy", - L"Kokonor,Damascus,STIXNonUnicode,STHeiti,Arial Black", 0, 1252}, - {0xfef135f8, L"AdobeHeitiStd-Regular", L"Heiti TC,STHeiti", 0, 936}, -}; -#elif _FXM_PLATFORM_ == _FXM_PLATFORM_ANDROID_ -const XFA_FONTINFO g_XFAFontsMap[] = { - {0x01d5d33e, L"SimSun", L"Droid Sans Fallback", 0, 936}, - {0x01e4f102, L"YouYuan", L"Droid Sans Fallback", 1, 936}, - {0x030549dc, L"LiSu", L"Droid Sans Fallback", 1, 936}, - {0x032edd44, L"Simhei", L"Droid Sans Fallback", 1, 936}, - {0x03eac6fc, L"PoorRichard-Regular", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback,Droid Arabic " - L"Naskh,Droid Sans Ethiopic", - 2, 1252}, - {0x03ed90e6, L"Nina", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x077b56b3, L"KingsoftPhoneticPlain", - L"Droid Sans Thai,Droid Sans Armenian,Droid Arabic Naskh,Droid Sans " - L"Ethiopic,Droid Sans Fallback", - 0, 1252}, - {0x078ed524, L"MicrosoftSansSerif", L"Droid Sans Fallback", 0, 1252}, - {0x089b18a9, L"Arial", L"Droid Sans Fallback", 0, 1252}, - {0x0b2cad72, L"MonotypeCorsiva", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 8, 1252}, - {0x0bb003e7, L"Kartika", - L"Droid Arabic Naskh,Droid Sans Ethiopic,Roboto,Droid Serif,Droid Sans " - L"Mono", - 2, 1252}, - {0x0bb469df, L"VinerHandITC", - L"Droid Serif,Roboto,Droid Sans Mono,Droid Sans Fallback", 8, 1252}, - {0x0bc1a851, L"SegoeUI", L"Droid Sans Fallback", 0, 1252}, - {0x0c112ebd, L"KozukaGothicPro-VIM", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x0cfcb9c1, L"AdobeThai", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 847}, - {0x0e7de0f9, L"Playbill", - L"Droid Arabic Naskh,Droid Sans Ethiopic,Roboto,Droid Serif,Droid Sans " - L"Mono", - 0, 1252}, - {0x0eff47c3, L"STHupo", L"Droid Sans Fallback", 0, 936}, - {0x107ad374, L"Constantia", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 2, 1252}, - {0x12194c2d, L"KunstlerScript", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 8, 1252}, - {0x135ef6a1, L"MinionProSmBd", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x158c4049, L"Garamond", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 2, 1252}, - {0x160ecb24, L"STZhongsong", L"Droid Sans Fallback", 0, 936}, - {0x161ed07e, L"MSGothic", L"Droid Sans Fallback", 1, 1252}, - {0x171d1ed1, L"SnapITC-Regular", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x18d1188f, L"Cambria", L"Droid Sans Fallback", 2, 1252}, - {0x18eaf350, L"ArialUnicodeMS", L"Droid Sans Fallback", 0, 936}, - {0x1a92d115, L"MingLiU", L"Droid Sans Fallback", 1, 1252}, - {0x1cc217c6, L"TrebuchetMS", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x1d649596, L"BasemicTimes", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x1e34ee60, L"BellMT", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 2, 1252}, - {0x1eb36945, L"CooperBlack", - L"Droid Serif,Roboto,Droid Sans Mono,Droid Sans Fallback", 2, 1252}, - {0x1ef7787d, L"BatangChe", L"Droid Sans Fallback", 1, 1252}, - {0x20b3bd3a, L"BrushScriptMT", L"Droid Arabic Naskh,Droid Sans Ethiopic", 8, - 1252}, - {0x220877aa, L"Candara", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x22135007, L"FreestyleScript-Regular", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 8, 1252}, - {0x251059c3, L"Chiller", - L"Droid Arabic Naskh,Droid Sans Ethiopic,Roboto,Droid Serif", 0, 1252}, - {0x25bed6dd, L"MSReferenceSansSerif", L"Droid Sans Fallback", 0, 1252}, - {0x28154c81, L"Parchment-Regular", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 8, 1252}, - {0x29711eb9, L"STLiti", L"Droid Sans Fallback", 0, 936}, - {0x2b1993b4, L"Basemic", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x2b316339, L"NiagaraSolid-Reg", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x2c147529, L"FootlightMTLight", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x2c198928, L"HarlowSolid", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x2c6ac6b2, L"LucidaBright", - L"Droid Arabic Naskh,Droid Sans Ethiopic,Droid Serif,Roboto", 2, 1252}, - {0x2c9f38e2, L"KozukaMinchoPro-VIR", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x2d5a47b0, L"STCaiyun", L"Droid Sans Fallback", 0, 936}, - {0x2def26bf, L"BernardMT-Condensed", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x2fd8930b, L"KozukaMinchoPr6NR", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x3115525a, L"FangSong_GB2312", L"Droid Sans Fallback", 0, 1252}, - {0x31327817, L"MyriadPro", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x32244975, L"Helvetica", - L"Droid Arabic Naskh,Droid Sans Ethiopic,Droid Serif,Roboto", 0, 1252}, - {0x32ac995c, L"Terminal", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x338d648a, L"NiagaraEngraved-Reg", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x33bb65f2, L"Sylfaen", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 2, 1252}, - {0x3402c30e, L"MSPMincho", L"Droid Sans Fallback", 2, 1252}, - {0x3412bf31, L"SimSun-PUA", L"Droid Sans Fallback", 0, 936}, - {0x36eb39b9, L"BerlinSansFB", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x36f42055, L"UniversATT", L"Microsoft Sans Serif", 0, 1252}, - {0x3864c4f6, L"HighTowerText", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 2, 1252}, - {0x3a257d03, L"FangSong_GB2312", L"Droid Sans Fallback", 0, 1252}, - {0x3cdae668, L"FreestyleScript", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 8, 1252}, - {0x3d55aed7, L"Jokerman", - L"Droid Serif,Roboto,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x3d5b4385, L"PMingLiU", L"Droid Sans Fallback", 2, 1252}, - {0x3d9b7669, L"EstrangeloEdessa", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x3e532d74, L"FranklinGothicMedium", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x3e6aa32d, L"NSimSun", L"Droid Sans Fallback", 1, 936}, - {0x3f6c36a8, L"Gautami", - L"Droid Arabic Naskh,Droid Sans Ethiopic,Roboto,Droid Serif,Droid Sans " - L"Mono,Droid Sans Fallback", - 0, 1252}, - {0x3ff32662, L"Chiller-Regular", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x409de312, L"ModernNo.20", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 2, 1252}, - {0x41443c5e, L"Georgia", - L"Droid Serif,Roboto,Droid Sans Mono,Droid Sans Fallback", 2, 1252}, - {0x4160ade5, L"BellGothicStdBlack", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x421976c4, L"Modern-Regular", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 2, 1252}, - {0x422a7252, L"Stencil", - L"Droid Serif,Roboto,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x42c8554f, L"Fixedsys", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x435cb41d, L"Roman", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x47882383, L"CourierNew", L"Droid Sans Fallback", 1, 1252}, - {0x480a2338, L"BerlinSansFBDemi", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x480bf7a4, L"CourierStd", L"Droid Sans Fallback", 0, 1252}, - {0x481ad6ed, L"VladimirScript", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 8, 1252}, - {0x4911577a, L"YouYuan", L"Droid Sans Fallback", 1, 936}, - {0x4a788d72, L"STXingkai", L"Droid Sans Fallback", 0, 936}, - {0x4bf88566, L"SegoeCondensed", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x4ccf51a4, L"BerlinSansFB-Reg", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x4ea967ce, L"GulimChe", L"Droid Sans Fallback", 1, 1252}, - {0x4f68bd79, L"LetterGothicStd", - L"Droid Sans Mono,Droid Arabic Naskh,Droid Sans Ethiopic,Droid Sans " - L"Mono,Droid Serif,Droid Sans Fallback", - 0, 1252}, - {0x51a0d0e6, L"KozukaGothicPr6NM", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x531b3dea, L"BasemicSymbol", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x5333fd39, L"CalifornianFB-Reg", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 2, 1252}, - {0x53561a54, L"FZYTK--GBK1-0", L"Droid Sans Fallback", 0, 936}, - {0x55e0dde6, L"LucidaSansTypewriter", - L"Droid Sans Mono,Droid Arabic Naskh,Droid Sans Ethiopic", 0, 1252}, - {0x574d4d3d, L"AdobeArabic", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x5792e759, L"STKaiti", L"Droid Sans Fallback", 0, 936}, - {0x5921978e, L"LucidaSansUnicode", L"Droid Sans Fallback", 0, 1252}, - {0x594e2da4, L"Vrinda", - L"Droid Arabic Naskh,Droid Sans Ethiopic,Roboto,Droid Serif,Droid Sans " - L"Mono", - 0, 1252}, - {0x59baa9a2, L"KaiTi_GB2312", L"Droid Sans Fallback", 0, 1252}, - {0x5cfedf4f, L"BaskOldFace", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x5f97921c, L"AdobeMyungjoStdM", L"Droid Sans Fallback", 0, 936}, - {0x5fefbfad, L"Batang", L"Droid Sans Fallback", 2, 1252}, - {0x605342b9, L"DotumChe", L"Droid Sans Fallback", 1, 1252}, - {0x608c5f9a, L"KaiTi_GB2312", L"Droid Sans Fallback", 0, 936}, - {0x61efd0d1, L"MaturaMTScriptCapitals", - L"Droid Arabic Naskh,Droid Sans Ethiopic,Droid Serif,Roboto,Droid Sans " - L"Mono", - 0, 1252}, - {0x626608a9, L"MVBoli", - L"Droid Arabic Naskh,Droid Sans Ethiopic,Droid Serif,Roboto,Droid Sans " - L"Mono", - 0, 1252}, - {0x630501a3, L"SmallFonts", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x65d0e2a9, L"FZYTK--GBK1-0", L"Droid Sans Fallback", 0, 936}, - {0x669f29e1, L"FZSTK--GBK1-0", L"Droid Sans Fallback", 0, 936}, - {0x673a9e5f, L"Tunga", - L"Droid Arabic Naskh,Droid Sans Ethiopic,Roboto,Droid Serif,Droid Sans " - L"Mono,Droid Sans Fallback", - 0, 1252}, - {0x691aa4ce, L"NiagaraSolid", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x696259b7, L"Corbel", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x696ee9be, L"STXihei", L"Droid Sans Fallback", 0, 936}, - {0x6c59cf69, L"Dotum", L"Droid Sans Fallback", 0, 1252}, - {0x707fa561, L"Gungsuh", L"Droid Sans Fallback", 2, 1252}, - {0x71416bb2, L"ZWAdobeF", - L"Droid Arabic Naskh,Droid Sans Armenian,Droid Sans Ethiopic,Droid Sans " - L"Georgian,Droid Sans Hebrew,Droid Sans Thai", - 0, 1252}, - {0x71b41801, L"Verdana", - L"Droid Serif,Roboto,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x73f25e4c, L"PalatinoLinotype", L"Droid Sans Fallback", 0, 1252}, - {0x73f4d19f, L"NiagaraEngraved", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x74001694, L"MyriadProBlack", L"Book Antiqua,Constantia,Dotum,Georgia", 0, - 1252}, - {0x74b14d8f, L"Haettenschweiler", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x74cb44ee, L"NSimSun", L"Droid Sans Fallback", 1, 936}, - {0x76b4d7ff, L"Shruti", - L"Droid Arabic Naskh,Droid Sans Ethiopic,Roboto,Droid Serif,Droid Sans " - L"Mono", - 0, 1252}, - {0x788b3533, L"Webdings", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 6, 42}, - {0x797dde99, L"MSSerif", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x7a0f9e9e, L"MSMincho", L"Droid Sans Fallback", 1, 1252}, - {0x7b439caf, L"OldEnglishTextMT", - L"Droid Serif,Roboto,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x8213a433, L"LucidaSans-Typewriter", - L"Droid Sans Mono,Droid Serif,Roboto,Droid Sans Fallback", 0, 1252}, - {0x82fec929, L"AdobeSongStdL", L"Droid Sans Fallback", 0, 936}, - {0x83581825, L"Modern", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x835a2823, L"Algerian", - L"Droid Serif,Roboto,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x83dab9f5, L"Script", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x847b56da, L"Tahoma", L"Droid Sans Fallback", 0, 1252}, - {0x8a783cb2, L"SimSun-PUA", L"Droid Sans Fallback", 0, 1252}, - {0x8b5cac0e, L"Onyx", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x8c6a499e, L"Gulim", L"Droid Sans Fallback", 0, 1252}, - {0x8e0af790, L"JuiceITC", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x8e8d43b2, L"Centaur", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 2, 1252}, - {0x8ee4dcca, L"BookshelfSymbol7", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x90794800, L"BellGothicStdLight", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x909b516a, L"Century", - L"Droid Serif,Roboto,Droid Sans Mono,Droid Sans Fallback", 2, 1252}, - {0x92ae370d, L"MSOutlook", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 4, 42}, - {0x93c9fbf1, L"LucidaFax", - L"Droid Arabic Naskh,Droid Sans Ethiopic,Droid Serif,Roboto,Droid Sans " - L"Mono", - 2, 1252}, - {0x9565085e, L"BookAntiqua", - L"Droid Serif,Roboto,Droid Sans Mono,Droid Sans Fallback", 2, 1252}, - {0x9856d95d, L"AdobeMingStdL", L"Droid Sans Fallback", 0, 949}, - {0x9bbadd6b, L"ColonnaMT", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0x9cbd16a4, L"ShowcardGothic-Reg", - L"Droid Serif,Roboto,Droid Sans Mono,Droid Sans Fallbac", 0, 1252}, - {0x9d73008e, L"MSSansSerif", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0xa0607db1, L"GungsuhChe", L"Droid Sans Fallback", 1, 1252}, - {0xa0bcf6a1, L"LatinWide", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 2, 1252}, - {0xa1429b36, L"Symbol", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 6, 42}, - {0xa1fa5abc, L"Wingdings2", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 6, 42}, - {0xa1fa5abd, L"Wingdings3", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 6, 42}, - {0xa427bad4, L"InformalRoman-Regular", - L"Droid Arabic Naskh,Droid Sans Ethiopic", 8, 1252}, - {0xa8b92ece, L"FZSTK--GBK1-0", L"Droid Sans Fallback", 0, 936}, - {0xa8d83ece, L"CalifornianFB", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 2, 1252}, - {0xaa3e082c, L"Kingsoft-Phonetic", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0xaa6bcabe, L"HarlowSolidItalic", - L"Droid Serif,Roboto,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0xade5337c, L"MSUIGothic", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0xb08dd941, L"WideLatin", - L"Droid Arabic Naskh,Droid Sans Ethiopic,Droid Serif,Roboto,Droid Sans " - L"Mono", - 2, 1252}, - {0xb207f05d, L"PoorRichard", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 2, 1252}, - {0xb3bc492f, L"JuiceITC-Regular", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0xb5545399, L"Marlett", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 4, 42}, - {0xb5dd1ebb, L"BritannicBold", L"Droid Arabic Naskh,Droid Sans Ethiopic", 0, - 1252}, - {0xb699c1c5, L"LucidaCalligraphy-Italic", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0xb725d629, L"TimesNewRoman", L"Droid Sans Fallback", 2, 1252}, - {0xb7eaebeb, L"AdobeHeitiStdR", L"Droid Sans Fallback", 0, 936}, - {0xbd29c486, L"BerlinSansFBDemi-Bold", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0xbe8a8db4, L"BookshelfSymbolSeven", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0xc16c0118, L"AdobeHebrew", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback,Droid Arabic " - L"Naskh,Droid Sans Ethiopic", - 0, 1252}, - {0xc318b0af, L"MyriadProLight", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0xc65e5659, L"CambriaMath", L"Droid Sans Fallback", 2, 1252}, - {0xc75c8f05, L"LucidaConsole", - L"Droid Sans Mono,Droid Serif,Roboto,Droid Sans Fallback", 1, 1252}, - {0xca7c35d6, L"Calibri", L"Droid Sans Fallback", 0, 1252}, - {0xcb053f53, L"MicrosoftYaHei", L"Droid Sans Fallback", 0, 936}, - {0xcb7190f9, L"Magneto-Bold", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0xcca00cc5, L"System", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0xccad6f76, L"Jokerman-Regular", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0xccc5818c, L"EuroSign", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0xcf3d7234, L"LucidaHandwriting-Italic", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0xcf7b8fdb, L"MinionPro", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0xcfe5755f, L"Simhei", L"Droid Sans Fallback", 1, 936}, - {0xd011f4ee, L"MSPGothic", L"Droid Sans Fallback", 0, 1252}, - {0xd060e7ef, L"Vivaldi", - L"Droid Serif,Roboto,Droid Sans Mono,Droid Sans Fallback", 8, 1252}, - {0xd07edec1, L"FranklinGothic-Medium", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0xd107243f, L"SimSun", L"Droid Sans Fallback", 0, 936}, - {0xd1881562, L"ArialNarrow", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0xd22b7dce, L"BodoniMTPosterCompressed", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0xd22bfa60, L"ComicSansMS", L"Droid Serif,Roboto,Droid Sans Fallback", 8, - 1252}, - {0xd3bd0e35, L"Bauhaus93", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0xd429ee7a, L"STFangsong", L"Droid Sans Fallback", 0, 936}, - {0xd6679c12, L"BernardMTCondensed", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0xd8e8a027, L"LucidaSans", - L"Droid Arabic Naskh,Droid Sans Ethiopic,Droid Serif,Roboto", 0, 1252}, - {0xd9fe7761, L"HighTowerText-Reg", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 2, 1252}, - {0xda7e551e, L"STSong", L"Droid Sans Fallback", 0, 936}, - {0xdaa6842d, L"STZhongsong", L"Droid Sans Fallback", 0, 936}, - {0xdaaab93f, L"STFangsong", L"Droid Sans Fallback", 0, 936}, - {0xdaeb0713, L"STSong", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 936}, - {0xdafedbef, L"STCaiyun", L"Droid Sans Fallback", 0, 936}, - {0xdb00a3d9, L"Broadway", - L"Droid Serif,Roboto,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0xdb1f5ad4, L"STXinwei", L"Droid Sans Fallback", 0, 936}, - {0xdb326e7f, L"STKaiti", L"Droid Sans Fallback", 0, 936}, - {0xdb69595a, L"STHupo", L"Droid Sans Fallback", 0, 936}, - {0xdba0082c, L"STXihei", L"Droid Sans Fallback", 0, 936}, - {0xdbd0ab18, L"STXingkai", L"Droid Sans Fallback", 0, 936}, - {0xdc1a7db1, L"STLiti", L"Droid Sans Fallback", 0, 936}, - {0xdc33075f, L"KristenITC-Regular", - L"Droid Arabic Naskh,Droid Sans Ethiopic,Droid Serif,Roboto", 8, 1252}, - {0xdcc7009c, L"Harrington", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0xdd712466, L"ArialBlack", - L"Droid Serif,Roboto,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0xdde87b3e, L"Impact", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0xdf69fb32, L"SnapITC", - L"Droid Arabic Naskh,Droid Sans Ethiopic,Droid Serif,Roboto,Droid Sans " - L"Mono", - 0, 1252}, - {0xdf8b25e8, L"CenturyGothic", - L"Droid Serif,Roboto,Droid Serif,Droid Sans Mono", 0, 1252}, - {0xe0f705c0, L"KristenITC", - L"Droid Arabic Naskh,Droid Sans Ethiopic,Droid Serif,Roboto", 8, 1252}, - {0xe1427573, L"Raavi", - L"Droid Arabic Naskh,Droid Sans Ethiopic,Roboto,Droid Serif,Droid Sans " - L"Mono", - 0, 1252}, - {0xe2cea0cb, L"Magneto", - L"Droid Arabic Naskh,Droid Sans Ethiopic,Droid Serif,Roboto,Droid Sans " - L"Mono", - 0, 1252}, - {0xe36a9e17, L"Ravie", - L"Droid Arabic Naskh,Droid Sans Ethiopic,Roboto,Droid Serif,Droid Sans " - L"Mono", - 0, 1252}, - {0xe433f8e2, L"Parchment", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 8, 1252}, - {0xe43dff4a, L"Wingdings", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 4, 42}, - {0xe4e2c405, L"MTExtra", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 6, 42}, - {0xe618cc35, L"InformalRoman", - L"Droid Arabic Naskh,Droid Sans Ethiopic,Roboto,Droid Serif", 8, 1252}, - {0xe6c27ffc, L"Mistral", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 8, 1252}, - {0xe7ebf4b9, L"Courier", L"Droid Sans Fallback", 0, 1252}, - {0xe8bc4a9d, L"MSReferenceSpecialty", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0xe90fb013, L"TempusSansITC", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0xec637b42, L"Consolas", L"Droid Sans Fallback", 1, 1252}, - {0xed3a683b, L"STXinwei", L"Droid Sans Fallback", 0, 936}, - {0xef264cd1, L"LucidaHandwriting", - L"Droid Arabic Naskh,Droid Sans Ethiopic,Droid Serif,Roboto,Droid Sans " - L"Mono", - 0, 1252}, - {0xf086bca2, L"BaskervilleOldFace", - L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0xf1028030, L"Mangal", - L"Droid Arabic Naskh,Droid Sans Ethiopic,Droid Serif,Roboto,Droid Sans " - L"Mono", - 2, 1252}, - {0xf1da7eb9, L"ShowcardGothic", - L"Droid Serif,Roboto,Droid Sans Mono,Droid Sans Fallbac", 0, 1252}, - {0xf210f06a, L"ArialMT", - L"Droid Arabic Naskh,Droid Sans Ethiopic,Roboto,Droid Serif", 0, 1252}, - {0xf477f16a, L"Latha", - L"Droid Arabic Naskh,Droid Sans Ethiopic,Roboto,Droid Serif,Droid Sans " - L"Mono", - 0, 1252}, - {0xf616f3dd, L"LiSu", L"Droid Sans Fallback", 1, 936}, - {0xfa479aa6, L"MicrosoftYaHei", L"Droid Sans Fallback", 0, 936}, - {0xfcd19697, L"BookmanOldStyle", - L"Droid Serif,Roboto,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, - {0xfe209a82, L"LucidaCalligraphy", - L"Droid Arabic Naskh,Droid Sans Ethiopic,Droid Serif,Roboto,Droid Sans " - L"Mono", - 0, 1252}, - {0xfef135f8, L"AdobeHeitiStd-Regular", L"Droid Sans Fallback", 0, 936}, -}; -#endif - -CFX_WideString XFA_LocalFontNameToEnglishName( - const CFX_WideStringC& wsLocalName) { - uint32_t dwLocalNameHash = FX_HashCode_GetW(wsLocalName, true); - const XFA_FONTINFO* pEnd = g_XFAFontsMap + FX_ArraySize(g_XFAFontsMap); - const XFA_FONTINFO* pFontInfo = - std::lower_bound(g_XFAFontsMap, pEnd, dwLocalNameHash, - [](const XFA_FONTINFO& entry, uint32_t hash) { - return entry.dwFontNameHash < hash; - }); - if (pFontInfo < pEnd && pFontInfo->dwFontNameHash == dwLocalNameHash) - return pFontInfo->pPsName; - return CFX_WideString(wsLocalName); -} - -const XFA_FONTINFO* XFA_GetFontINFOByFontName( - const CFX_WideStringC& wsFontName) { - CFX_WideString wsFontNameTemp(wsFontName); - wsFontNameTemp.Remove(L' '); - uint32_t dwCurFontNameHash = - FX_HashCode_GetW(wsFontNameTemp.AsStringC(), true); - const XFA_FONTINFO* pEnd = g_XFAFontsMap + FX_ArraySize(g_XFAFontsMap); - const XFA_FONTINFO* pFontInfo = - std::lower_bound(g_XFAFontsMap, pEnd, dwCurFontNameHash, - [](const XFA_FONTINFO& entry, uint32_t hash) { - return entry.dwFontNameHash < hash; - }); - if (pFontInfo < pEnd && pFontInfo->dwFontNameHash == dwCurFontNameHash) - return pFontInfo; - return nullptr; -} - -} // namespace - -CXFA_DefFontMgr::CXFA_DefFontMgr() {} - -CXFA_DefFontMgr::~CXFA_DefFontMgr() {} - -CFX_RetainPtr CXFA_DefFontMgr::GetFont( - CXFA_FFDoc* hDoc, - const CFX_WideStringC& wsFontFamily, - uint32_t dwFontStyles, - uint16_t wCodePage) { - CFX_WideString wsFontName(wsFontFamily); - CFGAS_FontMgr* pFDEFontMgr = hDoc->GetApp()->GetFDEFontMgr(); - CFX_RetainPtr pFont = - pFDEFontMgr->LoadFont(wsFontName.c_str(), dwFontStyles, wCodePage); - if (!pFont) { - const XFA_FONTINFO* pCurFont = - XFA_GetFontINFOByFontName(wsFontName.AsStringC()); - if (pCurFont && pCurFont->pReplaceFont) { - uint32_t dwStyle = 0; - if (dwFontStyles & FX_FONTSTYLE_Bold) { - dwStyle |= FX_FONTSTYLE_Bold; - } - if (dwFontStyles & FX_FONTSTYLE_Italic) { - dwStyle |= FX_FONTSTYLE_Italic; - } - const wchar_t* pReplace = pCurFont->pReplaceFont; - int32_t iLength = FXSYS_wcslen(pReplace); - while (iLength > 0) { - const wchar_t* pNameText = pReplace; - while (*pNameText != L',' && iLength > 0) { - pNameText++; - iLength--; - } - CFX_WideString wsReplace = - CFX_WideString(pReplace, pNameText - pReplace); - pFont = pFDEFontMgr->LoadFont(wsReplace.c_str(), dwStyle, wCodePage); - if (pFont) - break; - - iLength--; - pNameText++; - pReplace = pNameText; - } - } - } - if (pFont) - m_CacheFonts.push_back(pFont); - return pFont; -} - -CFX_RetainPtr CXFA_DefFontMgr::GetDefaultFont( - CXFA_FFDoc* hDoc, - const CFX_WideStringC& wsFontFamily, - uint32_t dwFontStyles, - uint16_t wCodePage) { - CFGAS_FontMgr* pFDEFontMgr = hDoc->GetApp()->GetFDEFontMgr(); - CFX_RetainPtr pFont = - pFDEFontMgr->LoadFont(L"Arial Narrow", dwFontStyles, wCodePage); - if (!pFont) { - pFont = pFDEFontMgr->LoadFont(static_cast(nullptr), - dwFontStyles, wCodePage); - } - if (pFont) - m_CacheFonts.push_back(pFont); - return pFont; -} - -CXFA_PDFFontMgr::CXFA_PDFFontMgr(CXFA_FFDoc* pDoc) : m_pDoc(pDoc) {} - -CXFA_PDFFontMgr::~CXFA_PDFFontMgr() {} - -CFX_RetainPtr CXFA_PDFFontMgr::FindFont( - const CFX_ByteString& strPsName, - bool bBold, - bool bItalic, - CPDF_Font** pDstPDFFont, - bool bStrictMatch) { - CPDF_Document* pDoc = m_pDoc->GetPDFDoc(); - if (!pDoc) - return nullptr; - - CPDF_Dictionary* pFontSetDict = - pDoc->GetRoot()->GetDictFor("AcroForm")->GetDictFor("DR"); - if (!pFontSetDict) - return nullptr; - - pFontSetDict = pFontSetDict->GetDictFor("Font"); - if (!pFontSetDict) - return nullptr; - - CFX_ByteString name = strPsName; - name.Remove(' '); - CFGAS_FontMgr* pFDEFontMgr = m_pDoc->GetApp()->GetFDEFontMgr(); - for (const auto& it : *pFontSetDict) { - const CFX_ByteString& key = it.first; - CPDF_Object* pObj = it.second.get(); - if (!PsNameMatchDRFontName(name.AsStringC(), bBold, bItalic, key, - bStrictMatch)) { - continue; - } - CPDF_Dictionary* pFontDict = ToDictionary(pObj->GetDirect()); - if (!pFontDict || pFontDict->GetStringFor("Type") != "Font") { - return nullptr; - } - CPDF_Font* pPDFFont = pDoc->LoadFont(pFontDict); - if (!pPDFFont) { - return nullptr; - } - if (!pPDFFont->IsEmbedded()) { - *pDstPDFFont = pPDFFont; - return nullptr; - } - return CFGAS_GEFont::LoadFont(&pPDFFont->m_Font, pFDEFontMgr); - } - return nullptr; -} - -CFX_RetainPtr CXFA_PDFFontMgr::GetFont( - const CFX_WideStringC& wsFontFamily, - uint32_t dwFontStyles, - CPDF_Font** pPDFFont, - bool bStrictMatch) { - uint32_t dwHashCode = FX_HashCode_GetW(wsFontFamily, false); - CFX_ByteString strKey; - strKey.Format("%u%u", dwHashCode, dwFontStyles); - auto it = m_FontMap.find(strKey); - if (it != m_FontMap.end()) - return it->second; - CFX_ByteString bsPsName = - CFX_ByteString::FromUnicode(CFX_WideString(wsFontFamily)); - bool bBold = (dwFontStyles & FX_FONTSTYLE_Bold) == FX_FONTSTYLE_Bold; - bool bItalic = (dwFontStyles & FX_FONTSTYLE_Italic) == FX_FONTSTYLE_Italic; - CFX_ByteString strFontName = PsNameToFontName(bsPsName, bBold, bItalic); - CFX_RetainPtr pFont = - FindFont(strFontName, bBold, bItalic, pPDFFont, bStrictMatch); - if (pFont) - m_FontMap[strKey] = pFont; - return pFont; -} - -CFX_ByteString CXFA_PDFFontMgr::PsNameToFontName( - const CFX_ByteString& strPsName, - bool bBold, - bool bItalic) { - for (size_t i = 0; i < FX_ArraySize(g_XFAPDFFontName); ++i) { - if (strPsName == g_XFAPDFFontName[i][0]) { - size_t index = 1; - if (bBold) - ++index; - if (bItalic) - index += 2; - return g_XFAPDFFontName[i][index]; - } - } - return strPsName; -} - -bool CXFA_PDFFontMgr::PsNameMatchDRFontName(const CFX_ByteStringC& bsPsName, - bool bBold, - bool bItalic, - const CFX_ByteString& bsDRFontName, - bool bStrictMatch) { - CFX_ByteString bsDRName = bsDRFontName; - bsDRName.Remove('-'); - int32_t iPsLen = bsPsName.GetLength(); - int32_t nIndex = bsDRName.Find(bsPsName); - if (nIndex != -1 && !bStrictMatch) - return true; - - if (nIndex != 0) - return false; - - int32_t iDifferLength = bsDRName.GetLength() - iPsLen; - if (iDifferLength > 1 || (bBold || bItalic)) { - int32_t iBoldIndex = bsDRName.Find("Bold"); - bool bBoldFont = iBoldIndex > 0; - if (bBold != bBoldFont) - return false; - - if (bBoldFont) { - iDifferLength = - std::min(iDifferLength - 4, bsDRName.GetLength() - iBoldIndex - 4); - } - bool bItalicFont = true; - if (bsDRName.Find("Italic") > 0) { - iDifferLength -= 6; - } else if (bsDRName.Find("It") > 0) { - iDifferLength -= 2; - } else if (bsDRName.Find("Oblique") > 0) { - iDifferLength -= 7; - } else { - bItalicFont = false; - } - if (bItalic != bItalicFont) - return false; - - if (iDifferLength > 1) { - CFX_ByteString bsDRTailer = bsDRName.Right(iDifferLength); - if (bsDRTailer == "MT" || bsDRTailer == "PSMT" || - bsDRTailer == "Regular" || bsDRTailer == "Reg") { - return true; - } - if (bBoldFont || bItalicFont) - return false; - - bool bMatch = false; - switch (bsPsName.GetAt(iPsLen - 1)) { - case 'L': { - if (bsDRName.Right(5) == "Light") { - bMatch = true; - } - } break; - case 'R': { - if (bsDRName.Right(7) == "Regular" || bsDRName.Right(3) == "Reg") { - bMatch = true; - } - } break; - case 'M': { - if (bsDRName.Right(5) == "Medium") { - bMatch = true; - } - } break; - default: - break; - } - return bMatch; - } - } - return true; -} - -bool CXFA_PDFFontMgr::GetCharWidth(const CFX_RetainPtr& pFont, - wchar_t wUnicode, - bool bCharCode, - int32_t* pWidth) { - if (wUnicode != 0x20 || bCharCode) - return false; - - auto it = m_FDE2PDFFont.find(pFont); - if (it == m_FDE2PDFFont.end()) - return false; - - CPDF_Font* pPDFFont = it->second; - *pWidth = pPDFFont->GetCharWidthF(pPDFFont->CharCodeFromUnicode(wUnicode)); - return true; -} - -void CXFA_PDFFontMgr::SetFont(const CFX_RetainPtr& pFont, - CPDF_Font* pPDFFont) { - m_FDE2PDFFont[pFont] = pPDFFont; -} - -CXFA_FontMgr::CXFA_FontMgr() {} - -CXFA_FontMgr::~CXFA_FontMgr() {} - -CFX_RetainPtr CXFA_FontMgr::GetFont( - CXFA_FFDoc* hDoc, - const CFX_WideStringC& wsFontFamily, - uint32_t dwFontStyles, - uint16_t wCodePage) { - uint32_t dwHash = FX_HashCode_GetW(wsFontFamily, false); - CFX_ByteString bsKey; - bsKey.Format("%u%u%u", dwHash, dwFontStyles, wCodePage); - auto iter = m_FontMap.find(bsKey); - if (iter != m_FontMap.end()) - return iter->second; - - CFX_WideString wsEnglishName = XFA_LocalFontNameToEnglishName(wsFontFamily); - auto it = m_PDFFontMgrMap.find(hDoc); - CXFA_PDFFontMgr* pMgr = - it != m_PDFFontMgrMap.end() ? it->second.get() : nullptr; - CPDF_Font* pPDFFont = nullptr; - CFX_RetainPtr pFont; - if (pMgr) { - pFont = - pMgr->GetFont(wsEnglishName.AsStringC(), dwFontStyles, &pPDFFont, true); - if (pFont) - return pFont; - } - if (!pFont && m_pDefFontMgr) - pFont = m_pDefFontMgr->GetFont(hDoc, wsFontFamily, dwFontStyles, wCodePage); - - if (!pFont && pMgr) { - pPDFFont = nullptr; - pFont = pMgr->GetFont(wsEnglishName.AsStringC(), dwFontStyles, &pPDFFont, - false); - if (pFont) - return pFont; - } - if (!pFont && m_pDefFontMgr) { - pFont = m_pDefFontMgr->GetDefaultFont(hDoc, wsFontFamily, dwFontStyles, - wCodePage); - } - if (pFont) { - if (pPDFFont) { - pMgr->SetFont(pFont, pPDFFont); - pFont->SetFontProvider(pMgr); - } - m_FontMap[bsKey] = pFont; - } - return pFont; -} - -void CXFA_FontMgr::LoadDocFonts(CXFA_FFDoc* hDoc) { - if (!m_PDFFontMgrMap[hDoc]) - m_PDFFontMgrMap[hDoc] = pdfium::MakeUnique(hDoc); -} - -void CXFA_FontMgr::ReleaseDocFonts(CXFA_FFDoc* hDoc) { - m_PDFFontMgrMap.erase(hDoc); -} - -void CXFA_FontMgr::SetDefFontMgr(std::unique_ptr pFontMgr) { - m_pDefFontMgr = std::move(pFontMgr); -} diff --git a/xfa/fxfa/app/xfa_fwladapter.cpp b/xfa/fxfa/app/xfa_fwladapter.cpp index af578fcf8f..3cf6e5e8fd 100644 --- a/xfa/fxfa/app/xfa_fwladapter.cpp +++ b/xfa/fxfa/app/xfa_fwladapter.cpp @@ -7,7 +7,7 @@ #include "xfa/fxfa/app/xfa_fwladapter.h" #include "xfa/fxfa/app/xfa_fffield.h" -#include "xfa/fxfa/xfa_ffdoc.h" +#include "xfa/fxfa/cxfa_ffdoc.h" CXFA_FWLAdapterWidgetMgr::CXFA_FWLAdapterWidgetMgr() {} diff --git a/xfa/fxfa/app/xfa_fwltheme.cpp b/xfa/fxfa/app/xfa_fwltheme.cpp index 5ea2a0c6c7..b7f23e3e9f 100644 --- a/xfa/fxfa/app/xfa_fwltheme.cpp +++ b/xfa/fxfa/app/xfa_fwltheme.cpp @@ -22,8 +22,8 @@ #include "xfa/fwl/cfwl_scrollbar.h" #include "xfa/fwl/cfwl_themebackground.h" #include "xfa/fwl/cfwl_themetext.h" -#include "xfa/fxfa/xfa_ffapp.h" -#include "xfa/fxfa/xfa_ffwidget.h" +#include "xfa/fxfa/cxfa_ffapp.h" +#include "xfa/fxfa/cxfa_ffwidget.h" #include "xfa/fxgraphics/cfx_color.h" namespace { diff --git a/xfa/fxfa/app/xfa_fwltheme.h b/xfa/fxfa/app/xfa_fwltheme.h index a8efad0ccf..33ea8e80a5 100644 --- a/xfa/fxfa/app/xfa_fwltheme.h +++ b/xfa/fxfa/app/xfa_fwltheme.h @@ -22,7 +22,7 @@ #include "xfa/fwl/theme/cfwl_pushbuttontp.h" #include "xfa/fwl/theme/cfwl_scrollbartp.h" #include "xfa/fwl/theme/cfwl_widgettp.h" -#include "xfa/fxfa/xfa_ffapp.h" +#include "xfa/fxfa/cxfa_ffapp.h" class CXFA_FWLTheme final : public IFWL_ThemeProvider { public: diff --git a/xfa/fxfa/app/xfa_rendercontext.cpp b/xfa/fxfa/app/xfa_rendercontext.cpp deleted file mode 100644 index a855105e3d..0000000000 --- a/xfa/fxfa/app/xfa_rendercontext.cpp +++ /dev/null @@ -1,70 +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 - -#include "xfa/fxfa/xfa_rendercontext.h" - -#include "xfa/fxfa/xfa_ffpageview.h" -#include "xfa/fxfa/xfa_ffwidget.h" -#include "xfa/fxgraphics/cfx_graphics.h" - -namespace { - -const int32_t kMaxCount = 30; - -} // namsepace - -CXFA_RenderContext::CXFA_RenderContext() - : m_pWidget(nullptr), m_pPageView(nullptr), m_pGS(nullptr), m_dwStatus(0) { - m_matrix.SetIdentity(); - m_rtClipRect.Reset(); -} - -CXFA_RenderContext::~CXFA_RenderContext() {} - -int32_t CXFA_RenderContext::StartRender(CXFA_FFPageView* pPageView, - CFX_Graphics* pGS, - const CFX_Matrix& matrix, - const CXFA_RenderOptions& options) { - m_pPageView = pPageView; - m_pGS = pGS; - m_matrix = matrix; - m_options = options; - - CFX_Matrix mtRes; - mtRes.SetReverse(matrix); - m_rtClipRect = pGS->GetClipRect(); - mtRes.TransformRect(m_rtClipRect); - m_dwStatus = m_options.m_bHighlight ? XFA_WidgetStatus_Highlight : 0; - uint32_t dwFilterType = XFA_WidgetStatus_Visible | - (m_options.m_bPrint ? XFA_WidgetStatus_Printable - : XFA_WidgetStatus_Viewable); - m_pWidgetIterator.reset( - m_pPageView->CreateWidgetIterator(XFA_TRAVERSEWAY_Form, dwFilterType)); - m_pWidget = m_pWidgetIterator->MoveToNext(); - return XFA_RENDERSTATUS_Ready; -} - -int32_t CXFA_RenderContext::DoRender(IFX_Pause* pPause) { - int32_t iCount = 0; - while (m_pWidget) { - CXFA_FFWidget* pWidget = m_pWidget; - CFX_RectF rtWidgetBox = pWidget->GetBBox(XFA_WidgetStatus_Visible); - rtWidgetBox.width += 1; - rtWidgetBox.height += 1; - if (rtWidgetBox.IntersectWith(m_rtClipRect)) - pWidget->RenderWidget(m_pGS, &m_matrix, m_dwStatus); - - m_pWidget = m_pWidgetIterator->MoveToNext(); - iCount++; - if (iCount > kMaxCount && pPause && pPause->NeedToPauseNow()) - return XFA_RENDERSTATUS_ToBeContinued; - } - return XFA_RENDERSTATUS_Done; -} - -void CXFA_RenderContext::StopRender() { - m_pWidgetIterator.reset(); -} diff --git a/xfa/fxfa/cxfa_checksumcontext.cpp b/xfa/fxfa/cxfa_checksumcontext.cpp new file mode 100644 index 0000000000..a59bdb16bf --- /dev/null +++ b/xfa/fxfa/cxfa_checksumcontext.cpp @@ -0,0 +1,151 @@ +// 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 + +#include "xfa/fxfa/cxfa_checksumcontext.h" + +#include "core/fdrm/crypto/fx_crypt.h" +#include "third_party/base/ptr_util.h" +#include "xfa/fxfa/cxfa_saxreaderhandler.h" + +namespace { + +struct FX_BASE64DATA { + uint32_t data1 : 2; + uint32_t data2 : 6; + uint32_t data3 : 4; + uint32_t data4 : 4; + uint32_t data5 : 6; + uint32_t data6 : 2; + uint32_t data7 : 8; +}; + +const char g_FXBase64EncoderMap[64] = { + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', + 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', + 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', + 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/', +}; + +void Base64EncodePiece(const FX_BASE64DATA& src, int32_t iBytes, char dst[4]) { + dst[0] = g_FXBase64EncoderMap[src.data2]; + uint32_t b = src.data1 << 4; + if (iBytes > 1) { + b |= src.data4; + } + dst[1] = g_FXBase64EncoderMap[b]; + if (iBytes > 1) { + b = src.data3 << 2; + if (iBytes > 2) { + b |= src.data6; + } + dst[2] = g_FXBase64EncoderMap[b]; + if (iBytes > 2) { + dst[3] = g_FXBase64EncoderMap[src.data5]; + } else { + dst[3] = '='; + } + } else { + dst[2] = dst[3] = '='; + } +} + +int32_t Base64EncodeA(const uint8_t* pSrc, int32_t iSrcLen, char* pDst) { + ASSERT(pSrc); + if (iSrcLen < 1) { + return 0; + } + if (!pDst) { + int32_t iDstLen = iSrcLen / 3 * 4; + if ((iSrcLen % 3) != 0) { + iDstLen += 4; + } + return iDstLen; + } + FX_BASE64DATA srcData; + int32_t iBytes = 3; + char* pDstEnd = pDst; + while (iSrcLen > 0) { + if (iSrcLen > 2) { + ((uint8_t*)&srcData)[0] = *pSrc++; + ((uint8_t*)&srcData)[1] = *pSrc++; + ((uint8_t*)&srcData)[2] = *pSrc++; + iSrcLen -= 3; + } else { + *((uint32_t*)&srcData) = 0; + ((uint8_t*)&srcData)[0] = *pSrc++; + if (iSrcLen > 1) { + ((uint8_t*)&srcData)[1] = *pSrc++; + } + iBytes = iSrcLen; + iSrcLen = 0; + } + Base64EncodePiece(srcData, iBytes, pDstEnd); + pDstEnd += 4; + } + return pDstEnd - pDst; +} + +} // namespace + +CXFA_ChecksumContext::CXFA_ChecksumContext() {} + +CXFA_ChecksumContext::~CXFA_ChecksumContext() {} + +void CXFA_ChecksumContext::StartChecksum() { + FinishChecksum(); + m_pByteContext = pdfium::MakeUnique(); + CRYPT_SHA1Start(m_pByteContext.get()); + m_bsChecksum.clear(); + m_pSAXReader = pdfium::MakeUnique(); +} + +bool CXFA_ChecksumContext::UpdateChecksum( + const CFX_RetainPtr& pSrcFile, + FX_FILESIZE offset, + size_t size) { + if (!m_pSAXReader || !pSrcFile) + return false; + + if (size < 1) + size = pSrcFile->GetSize(); + + CXFA_SAXReaderHandler handler(this); + m_pSAXReader->SetHandler(&handler); + if (m_pSAXReader->StartParse( + pSrcFile, (uint32_t)offset, (uint32_t)size, + CFX_SaxParseMode_NotSkipSpace | CFX_SaxParseMode_NotConvert_amp | + CFX_SaxParseMode_NotConvert_lt | CFX_SaxParseMode_NotConvert_gt | + CFX_SaxParseMode_NotConvert_sharp) < 0) { + return false; + } + return m_pSAXReader->ContinueParse(nullptr) > 99; +} + +void CXFA_ChecksumContext::FinishChecksum() { + m_pSAXReader.reset(); + if (m_pByteContext) { + uint8_t digest[20]; + FXSYS_memset(digest, 0, 20); + CRYPT_SHA1Finish(m_pByteContext.get(), digest); + int32_t nLen = Base64EncodeA(digest, 20, nullptr); + char* pBuffer = m_bsChecksum.GetBuffer(nLen); + Base64EncodeA(digest, 20, pBuffer); + m_bsChecksum.ReleaseBuffer(nLen); + m_pByteContext.reset(); + } +} + +CFX_ByteString CXFA_ChecksumContext::GetChecksum() const { + return m_bsChecksum; +} + +void CXFA_ChecksumContext::Update(const CFX_ByteStringC& bsText) { + if (!m_pByteContext) + return; + + CRYPT_SHA1Update(m_pByteContext.get(), bsText.raw_str(), bsText.GetLength()); +} diff --git a/xfa/fxfa/cxfa_checksumcontext.h b/xfa/fxfa/cxfa_checksumcontext.h new file mode 100644 index 0000000000..ca1b53007e --- /dev/null +++ b/xfa/fxfa/cxfa_checksumcontext.h @@ -0,0 +1,34 @@ +// 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_CXFA_CHECKSUMCONTEXT_H_ +#define XFA_FXFA_CXFA_CHECKSUMCONTEXT_H_ + +#include + +#include "core/fdrm/crypto/fx_crypt.h" +#include "xfa/fde/xml/cfx_saxreader.h" + +class CXFA_ChecksumContext { + public: + CXFA_ChecksumContext(); + ~CXFA_ChecksumContext(); + + void StartChecksum(); + void Update(const CFX_ByteStringC& bsText); + bool UpdateChecksum(const CFX_RetainPtr& pSrcFile, + FX_FILESIZE offset = 0, + size_t size = 0); + void FinishChecksum(); + CFX_ByteString GetChecksum() const; + + private: + std::unique_ptr m_pSAXReader; + std::unique_ptr m_pByteContext; + CFX_ByteString m_bsChecksum; +}; + +#endif // XFA_FXFA_CXFA_CHECKSUMCONTEXT_H_ diff --git a/xfa/fxfa/cxfa_deffontmgr.cpp b/xfa/fxfa/cxfa_deffontmgr.cpp new file mode 100644 index 0000000000..db730677b5 --- /dev/null +++ b/xfa/fxfa/cxfa_deffontmgr.cpp @@ -0,0 +1,77 @@ +// 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 + +#include "xfa/fxfa/cxfa_deffontmgr.h" + +#include "xfa/fxfa/cxfa_ffapp.h" +#include "xfa/fxfa/cxfa_ffdoc.h" +#include "xfa/fxfa/cxfa_fontmgr.h" + +CXFA_DefFontMgr::CXFA_DefFontMgr() {} + +CXFA_DefFontMgr::~CXFA_DefFontMgr() {} + +CFX_RetainPtr CXFA_DefFontMgr::GetFont( + CXFA_FFDoc* hDoc, + const CFX_WideStringC& wsFontFamily, + uint32_t dwFontStyles, + uint16_t wCodePage) { + CFX_WideString wsFontName(wsFontFamily); + CFGAS_FontMgr* pFDEFontMgr = hDoc->GetApp()->GetFDEFontMgr(); + CFX_RetainPtr pFont = + pFDEFontMgr->LoadFont(wsFontName.c_str(), dwFontStyles, wCodePage); + if (!pFont) { + const XFA_FONTINFO* pCurFont = + XFA_GetFontINFOByFontName(wsFontName.AsStringC()); + if (pCurFont && pCurFont->pReplaceFont) { + uint32_t dwStyle = 0; + if (dwFontStyles & FX_FONTSTYLE_Bold) { + dwStyle |= FX_FONTSTYLE_Bold; + } + if (dwFontStyles & FX_FONTSTYLE_Italic) { + dwStyle |= FX_FONTSTYLE_Italic; + } + const wchar_t* pReplace = pCurFont->pReplaceFont; + int32_t iLength = FXSYS_wcslen(pReplace); + while (iLength > 0) { + const wchar_t* pNameText = pReplace; + while (*pNameText != L',' && iLength > 0) { + pNameText++; + iLength--; + } + CFX_WideString wsReplace = + CFX_WideString(pReplace, pNameText - pReplace); + pFont = pFDEFontMgr->LoadFont(wsReplace.c_str(), dwStyle, wCodePage); + if (pFont) + break; + + iLength--; + pNameText++; + pReplace = pNameText; + } + } + } + if (pFont) + m_CacheFonts.push_back(pFont); + return pFont; +} + +CFX_RetainPtr CXFA_DefFontMgr::GetDefaultFont( + CXFA_FFDoc* hDoc, + const CFX_WideStringC& wsFontFamily, + uint32_t dwFontStyles, + uint16_t wCodePage) { + CFGAS_FontMgr* pFDEFontMgr = hDoc->GetApp()->GetFDEFontMgr(); + CFX_RetainPtr pFont = + pFDEFontMgr->LoadFont(L"Arial Narrow", dwFontStyles, wCodePage); + if (!pFont) { + pFont = pFDEFontMgr->LoadFont(static_cast(nullptr), + dwFontStyles, wCodePage); + } + if (pFont) + m_CacheFonts.push_back(pFont); + return pFont; +} diff --git a/xfa/fxfa/cxfa_deffontmgr.h b/xfa/fxfa/cxfa_deffontmgr.h new file mode 100644 index 0000000000..5f50ffb08d --- /dev/null +++ b/xfa/fxfa/cxfa_deffontmgr.h @@ -0,0 +1,37 @@ +// 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_CXFA_DEFFONTMGR_H_ +#define XFA_FXFA_CXFA_DEFFONTMGR_H_ + +#include + +#include "core/fxcrt/cfx_retain_ptr.h" +#include "core/fxcrt/fx_string.h" +#include "xfa/fgas/font/cfgas_gefont.h" + +class CXFA_FFDoc; + +class CXFA_DefFontMgr { + public: + CXFA_DefFontMgr(); + ~CXFA_DefFontMgr(); + + CFX_RetainPtr GetFont(CXFA_FFDoc* hDoc, + const CFX_WideStringC& wsFontFamily, + uint32_t dwFontStyles, + uint16_t wCodePage = 0xFFFF); + CFX_RetainPtr GetDefaultFont( + CXFA_FFDoc* hDoc, + const CFX_WideStringC& wsFontFamily, + uint32_t dwFontStyles, + uint16_t wCodePage = 0xFFFF); + + private: + std::vector> m_CacheFonts; +}; + +#endif // XFA_FXFA_CXFA_DEFFONTMGR_H_ diff --git a/xfa/fxfa/cxfa_eventparam.cpp b/xfa/fxfa/cxfa_eventparam.cpp new file mode 100644 index 0000000000..bd6742f4dd --- /dev/null +++ b/xfa/fxfa/cxfa_eventparam.cpp @@ -0,0 +1,46 @@ +// Copyright 2016 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 + +#include "xfa/fxfa/cxfa_eventparam.h" + +#include "xfa/fxfa/fxfa.h" + +CXFA_EventParam::CXFA_EventParam() + : m_pTarget(nullptr), + m_eType(XFA_EVENT_Unknown), + m_bCancelAction(false), + m_iCommitKey(0), + m_bKeyDown(false), + m_bModifier(false), + m_bReenter(false), + m_iSelEnd(0), + m_iSelStart(0), + m_bShift(false), + m_bIsFormReady(false) {} + +CXFA_EventParam::~CXFA_EventParam() {} + +CXFA_EventParam::CXFA_EventParam(const CXFA_EventParam& other) = default; + +void CXFA_EventParam::Reset() { + m_wsChange.clear(); + m_bCancelAction = false; + m_iCommitKey = 0; + m_wsFullText.clear(); + m_bKeyDown = false; + m_bModifier = false; + m_wsNewContentType.clear(); + m_wsNewText.clear(); + m_wsPrevContentType.clear(); + m_wsPrevText.clear(); + m_bReenter = false; + m_iSelEnd = 0; + m_iSelStart = 0; + m_bShift = false; + m_wsSoapFaultCode.clear(); + m_wsSoapFaultString.clear(); + m_bIsFormReady = false; +} diff --git a/xfa/fxfa/cxfa_ffapp.cpp b/xfa/fxfa/cxfa_ffapp.cpp new file mode 100644 index 0000000000..40341ad90c --- /dev/null +++ b/xfa/fxfa/cxfa_ffapp.cpp @@ -0,0 +1,162 @@ +// 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 + +#include "xfa/fxfa/cxfa_ffapp.h" + +#include +#include +#include +#include + +#include "third_party/base/ptr_util.h" +#include "third_party/base/stl_util.h" +#include "xfa/fgas/font/cfgas_fontmgr.h" +#include "xfa/fwl/cfwl_notedriver.h" +#include "xfa/fwl/cfwl_widgetmgr.h" +#include "xfa/fxfa/app/xfa_fwladapter.h" +#include "xfa/fxfa/app/xfa_fwltheme.h" +#include "xfa/fxfa/cxfa_ffdoc.h" +#include "xfa/fxfa/cxfa_ffdochandler.h" +#include "xfa/fxfa/cxfa_ffwidgethandler.h" +#include "xfa/fxfa/cxfa_fontmgr.h" + +namespace { + +class CXFA_FileRead : public IFX_SeekableReadStream { + public: + explicit CXFA_FileRead(const std::vector& streams); + ~CXFA_FileRead() override; + + // IFX_SeekableReadStream + FX_FILESIZE GetSize() override; + bool ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override; + + private: + std::vector> m_Data; +}; + +CXFA_FileRead::CXFA_FileRead(const std::vector& streams) { + for (CPDF_Stream* pStream : streams) { + m_Data.push_back(pdfium::MakeUnique()); + m_Data.back()->LoadAllData(pStream); + } +} + +CXFA_FileRead::~CXFA_FileRead() {} + +FX_FILESIZE CXFA_FileRead::GetSize() { + uint32_t dwSize = 0; + for (const auto& acc : m_Data) + dwSize += acc->GetSize(); + return dwSize; +} + +bool CXFA_FileRead::ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) { + int32_t iCount = pdfium::CollectionSize(m_Data); + int32_t index = 0; + while (index < iCount) { + const auto& acc = m_Data[index]; + FX_FILESIZE dwSize = acc->GetSize(); + if (offset < dwSize) + break; + + offset -= dwSize; + index++; + } + while (index < iCount) { + const auto& acc = m_Data[index]; + uint32_t dwSize = acc->GetSize(); + size_t dwRead = std::min(size, static_cast(dwSize - offset)); + FXSYS_memcpy(buffer, acc->GetData() + offset, dwRead); + size -= dwRead; + if (size == 0) + return true; + + buffer = (uint8_t*)buffer + dwRead; + offset = 0; + index++; + } + return false; +} + +} // namespace + +CFX_RetainPtr MakeSeekableReadStream( + const std::vector& streams) { + return CFX_RetainPtr(new CXFA_FileRead(streams)); +} + +CXFA_FFApp::CXFA_FFApp(IXFA_AppProvider* pProvider) + : m_pProvider(pProvider), + m_pWidgetMgrDelegate(nullptr), + m_pFWLApp(new CFWL_App(this)) {} + +CXFA_FFApp::~CXFA_FFApp() {} + +CXFA_FFDocHandler* CXFA_FFApp::GetDocHandler() { + if (!m_pDocHandler) + m_pDocHandler = pdfium::MakeUnique(); + return m_pDocHandler.get(); +} + +std::unique_ptr CXFA_FFApp::CreateDoc( + IXFA_DocEnvironment* pDocEnvironment, + CPDF_Document* pPDFDoc) { + if (!pPDFDoc) + return nullptr; + + auto pDoc = pdfium::MakeUnique(this, pDocEnvironment); + if (!pDoc->OpenDoc(pPDFDoc)) + return nullptr; + + return pDoc; +} + +void CXFA_FFApp::SetDefaultFontMgr(std::unique_ptr pFontMgr) { + if (!m_pFontMgr) + m_pFontMgr = pdfium::MakeUnique(); + m_pFontMgr->SetDefFontMgr(std::move(pFontMgr)); +} + +CXFA_FontMgr* CXFA_FFApp::GetXFAFontMgr() const { + return m_pFontMgr.get(); +} + +CFGAS_FontMgr* CXFA_FFApp::GetFDEFontMgr() { + if (!m_pFDEFontMgr) { +#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ + m_pFDEFontMgr = CFGAS_FontMgr::Create(FX_GetDefFontEnumerator()); +#else + m_pFontSource = pdfium::MakeUnique(); + m_pFDEFontMgr = CFGAS_FontMgr::Create(m_pFontSource.get()); +#endif + } + return m_pFDEFontMgr.get(); +} + +CXFA_FWLTheme* CXFA_FFApp::GetFWLTheme() { + if (!m_pFWLTheme) + m_pFWLTheme = pdfium::MakeUnique(this); + return m_pFWLTheme.get(); +} + +CXFA_FWLAdapterWidgetMgr* CXFA_FFApp::GetWidgetMgr( + CFWL_WidgetMgrDelegate* pDelegate) { + if (!m_pAdapterWidgetMgr) { + m_pAdapterWidgetMgr = pdfium::MakeUnique(); + pDelegate->OnSetCapability(FWL_WGTMGR_DisableForm); + m_pWidgetMgrDelegate = pDelegate; + } + return m_pAdapterWidgetMgr.get(); +} + +IFWL_AdapterTimerMgr* CXFA_FFApp::GetTimerMgr() const { + return m_pProvider->GetTimerMgr(); +} + +void CXFA_FFApp::ClearEventTargets() { + m_pFWLApp->GetNoteDriver()->ClearEventTargets(false); +} diff --git a/xfa/fxfa/cxfa_ffapp.h b/xfa/fxfa/cxfa_ffapp.h new file mode 100644 index 0000000000..01235d655b --- /dev/null +++ b/xfa/fxfa/cxfa_ffapp.h @@ -0,0 +1,86 @@ +// 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_CXFA_FFAPP_H_ +#define XFA_FXFA_CXFA_FFAPP_H_ + +#include +#include + +#include "core/fpdfapi/parser/cpdf_stream.h" +#include "core/fpdfapi/parser/cpdf_stream_acc.h" +#include "core/fxcrt/cfx_retain_ptr.h" +#include "xfa/fgas/font/cfgas_fontmgr.h" +#include "xfa/fwl/cfwl_app.h" +#include "xfa/fxfa/fxfa.h" + +class CXFA_DefFontMgr; +class CXFA_FWLAdapterWidgetMgr; +class CXFA_FWLTheme; +class CXFA_FFDocHandler; +class CXFA_FontMgr; +class IFWL_AdapterTimerMgr; +class CFWL_WidgetMgrDelegate; + +// Layering prevents fxcrt from knowing about CPDF_Streams; this could go +// in fpdfsdk, but it is XFA-Only. +CFX_RetainPtr MakeSeekableReadStream( + const std::vector& streams); + +class CXFA_FFApp { + public: + explicit CXFA_FFApp(IXFA_AppProvider* pProvider); + ~CXFA_FFApp(); + + std::unique_ptr CreateDoc(IXFA_DocEnvironment* pDocEnvironment, + CPDF_Document* pPDFDoc); + void SetDefaultFontMgr(std::unique_ptr pFontMgr); + + CXFA_FFDocHandler* GetDocHandler(); + CXFA_FWLAdapterWidgetMgr* GetWidgetMgr(CFWL_WidgetMgrDelegate* pDelegate); + CFGAS_FontMgr* GetFDEFontMgr(); + CXFA_FWLTheme* GetFWLTheme(); + + IXFA_AppProvider* GetAppProvider() const { return m_pProvider; } + const CFWL_App* GetFWLApp() const { return m_pFWLApp.get(); } + IFWL_AdapterTimerMgr* GetTimerMgr() const; + CXFA_FontMgr* GetXFAFontMgr() const; + CFWL_WidgetMgrDelegate* GetWidgetMgrDelegate() const { + return m_pWidgetMgrDelegate; + } + + void ClearEventTargets(); + + private: + std::unique_ptr m_pDocHandler; + IXFA_AppProvider* const m_pProvider; + + // The fonts stored in the font manager may have been created by the default + // font manager. The GEFont::LoadFont call takes the manager as a param and + // stores it internally. When you destroy the GEFont it tries to unregister + // from the font manager and if the default font manager was destroyed first + // get get a use-after-free. The m_pFWLTheme can try to cleanup a GEFont + // when it frees, so make sure it gets cleaned up first. That requires + // m_pFWLApp to be cleaned up as well. + // + // TODO(dsinclair): The GEFont should have the FontMgr as the pointer instead + // of the DEFFontMgr so this goes away. Bug 561. + std::unique_ptr m_pFDEFontMgr; + std::unique_ptr m_pFontMgr; + +#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ + std::unique_ptr m_pFontSource; +#endif + std::unique_ptr m_pAdapterWidgetMgr; + CFWL_WidgetMgrDelegate* m_pWidgetMgrDelegate; // not owned. + + // |m_pFWLApp| has to be released first, then |m_pFWLTheme| since the former + // may refers to theme manager and the latter refers to font manager. + std::unique_ptr m_pFWLTheme; + std::unique_ptr m_pFWLApp; +}; + +#endif // XFA_FXFA_CXFA_FFAPP_H_ diff --git a/xfa/fxfa/cxfa_ffapp_unitest.cpp b/xfa/fxfa/cxfa_ffapp_unitest.cpp new file mode 100644 index 0000000000..e8accdfeb2 --- /dev/null +++ b/xfa/fxfa/cxfa_ffapp_unitest.cpp @@ -0,0 +1,87 @@ +// Copyright 2016 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. + +#include "xfa/fxfa/cxfa_ffapp.h" + +#include +#include + +#include "core/fpdfapi/parser/cpdf_dictionary.h" +#include "core/fpdfapi/parser/cpdf_stream.h" +#include "core/fxcrt/fx_memory.h" +#include "testing/gtest/include/gtest/gtest.h" +#include "third_party/base/ptr_util.h" + +TEST(CXFAFileRead, NoStreams) { + std::vector streams; + CFX_RetainPtr fileread = + MakeSeekableReadStream(streams); + + uint8_t output_buffer[16]; + memset(output_buffer, 0xbd, sizeof(output_buffer)); + EXPECT_FALSE(fileread->ReadBlock(output_buffer, 0, 0)); + EXPECT_EQ(0xbd, output_buffer[0]); +} + +TEST(CXFAFileRead, EmptyStreams) { + std::vector streams; + auto stream1 = pdfium::MakeUnique(); + streams.push_back(stream1.get()); + CFX_RetainPtr fileread = + MakeSeekableReadStream(streams); + + uint8_t output_buffer[16]; + memset(output_buffer, 0xbd, sizeof(output_buffer)); + EXPECT_FALSE(fileread->ReadBlock(output_buffer, 0, 0)); + EXPECT_EQ(0xbd, output_buffer[0]); +} + +TEST(CXFAFileRead, NormalStreams) { + std::vector streams; + auto stream1 = pdfium::MakeUnique(); + auto stream2 = pdfium::MakeUnique(); + auto stream3 = pdfium::MakeUnique(); + + // 16 chars total. + stream1->InitStream(reinterpret_cast("one t"), 5, + pdfium::MakeUnique()); + stream2->InitStream(reinterpret_cast("wo "), 3, + pdfium::MakeUnique()); + stream3->InitStream(reinterpret_cast("three!!!"), 8, + pdfium::MakeUnique()); + + streams.push_back(stream1.get()); + streams.push_back(stream2.get()); + streams.push_back(stream3.get()); + CFX_RetainPtr fileread = + MakeSeekableReadStream(streams); + + uint8_t output_buffer[16]; + memset(output_buffer, 0xbd, sizeof(output_buffer)); + EXPECT_TRUE(fileread->ReadBlock(output_buffer, 0, 0)); + EXPECT_EQ(0xbd, output_buffer[0]); + + memset(output_buffer, 0xbd, sizeof(output_buffer)); + EXPECT_TRUE(fileread->ReadBlock(output_buffer, 1, 0)); + EXPECT_EQ(0xbd, output_buffer[0]); + + memset(output_buffer, 0xbd, sizeof(output_buffer)); + EXPECT_TRUE(fileread->ReadBlock(output_buffer, 0, 1)); + EXPECT_EQ(0, memcmp(output_buffer, "o", 1)); + EXPECT_EQ(0xbd, output_buffer[1]); + + memset(output_buffer, 0xbd, sizeof(output_buffer)); + EXPECT_TRUE(fileread->ReadBlock(output_buffer, 0, sizeof(output_buffer))); + EXPECT_EQ(0, memcmp(output_buffer, "one two three!!!", 16)); + + memset(output_buffer, 0xbd, sizeof(output_buffer)); + EXPECT_TRUE(fileread->ReadBlock(output_buffer, 2, 10)); + EXPECT_EQ(0, memcmp(output_buffer, "e two thre", 10)); + EXPECT_EQ(0xbd, output_buffer[11]); + + memset(output_buffer, 0xbd, sizeof(output_buffer)); + EXPECT_FALSE(fileread->ReadBlock(output_buffer, 1, sizeof(output_buffer))); + EXPECT_EQ(0, memcmp(output_buffer, "ne two three!!!", 15)); + EXPECT_EQ(0xbd, output_buffer[15]); +} diff --git a/xfa/fxfa/cxfa_ffdoc.cpp b/xfa/fxfa/cxfa_ffdoc.cpp new file mode 100644 index 0000000000..fdeacf7f0f --- /dev/null +++ b/xfa/fxfa/cxfa_ffdoc.cpp @@ -0,0 +1,430 @@ +// 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 + +#include "xfa/fxfa/cxfa_ffdoc.h" + +#include +#include +#include + +#include "core/fpdfapi/parser/cpdf_array.h" +#include "core/fpdfapi/parser/cpdf_document.h" +#include "core/fpdfapi/parser/fpdf_parser_decode.h" +#include "core/fpdfdoc/cpdf_nametree.h" +#include "core/fxcrt/fx_ext.h" +#include "core/fxcrt/fx_memory.h" +#include "third_party/base/ptr_util.h" +#include "xfa/fde/xml/fde_xml_imp.h" +#include "xfa/fwl/cfwl_notedriver.h" +#include "xfa/fxfa/app/xfa_ffnotify.h" +#include "xfa/fxfa/cxfa_checksumcontext.h" +#include "xfa/fxfa/cxfa_ffapp.h" +#include "xfa/fxfa/cxfa_ffdocview.h" +#include "xfa/fxfa/cxfa_ffwidget.h" +#include "xfa/fxfa/cxfa_fontmgr.h" +#include "xfa/fxfa/parser/cxfa_dataexporter.h" +#include "xfa/fxfa/parser/cxfa_dataimporter.h" +#include "xfa/fxfa/parser/cxfa_document.h" + +namespace { + +struct FX_BASE64DATA { + uint32_t data1 : 2; + uint32_t data2 : 6; + uint32_t data3 : 4; + uint32_t data4 : 4; + uint32_t data5 : 6; + uint32_t data6 : 2; + uint32_t data7 : 8; +}; + +const uint8_t kStartValuesRemoved = 43; +const uint8_t kDecoderMapSize = 80; +const uint8_t g_FXBase64DecoderMap[kDecoderMapSize] = { + 0x3E, 0xFF, 0xFF, 0xFF, 0x3F, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, + 0x3B, 0x3C, 0x3D, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x01, + 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, + 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, + 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, + 0x2C, 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, +}; + +uint8_t base64DecoderValue(uint8_t val) { + if (val < kStartValuesRemoved || val >= kStartValuesRemoved + kDecoderMapSize) + return 0xFF; + return g_FXBase64DecoderMap[val - kStartValuesRemoved]; +} + +void Base64DecodePiece(const char src[4], + int32_t iChars, + FX_BASE64DATA& dst, + int32_t& iBytes) { + ASSERT(iChars > 0 && iChars < 5); + iBytes = 1; + dst.data2 = base64DecoderValue(static_cast(src[0])); + if (iChars > 1) { + uint8_t b = base64DecoderValue(static_cast(src[1])); + dst.data1 = b >> 4; + dst.data4 = b; + if (iChars > 2) { + iBytes = 2; + b = base64DecoderValue(static_cast(src[2])); + dst.data3 = b >> 2; + dst.data6 = b; + if (iChars > 3) { + iBytes = 3; + dst.data5 = base64DecoderValue(static_cast(src[3])); + } else { + dst.data5 = 0; + } + } else { + dst.data3 = 0; + } + } else { + dst.data1 = 0; + } +} + +int32_t Base64DecodeW(const wchar_t* pSrc, int32_t iSrcLen, uint8_t* pDst) { + ASSERT(pSrc); + if (iSrcLen < 1) { + return 0; + } + while (iSrcLen > 0 && pSrc[iSrcLen - 1] == '=') { + iSrcLen--; + } + if (iSrcLen < 1) { + return 0; + } + if (!pDst) { + int32_t iDstLen = iSrcLen / 4 * 3; + iSrcLen %= 4; + if (iSrcLen == 1) { + iDstLen += 1; + } else if (iSrcLen == 2) { + iDstLen += 1; + } else if (iSrcLen == 3) { + iDstLen += 2; + } + return iDstLen; + } + char srcData[4]; + FX_BASE64DATA dstData; + int32_t iChars = 4, iBytes; + uint8_t* pDstEnd = pDst; + while (iSrcLen > 0) { + if (iSrcLen > 3) { + srcData[0] = (char)*pSrc++; + srcData[1] = (char)*pSrc++; + srcData[2] = (char)*pSrc++; + srcData[3] = (char)*pSrc++; + iSrcLen -= 4; + } else { + *((uint32_t*)&dstData) = 0; + *((uint32_t*)srcData) = 0; + srcData[0] = (char)*pSrc++; + if (iSrcLen > 1) { + srcData[1] = (char)*pSrc++; + } + if (iSrcLen > 2) { + srcData[2] = (char)*pSrc++; + } + iChars = iSrcLen; + iSrcLen = 0; + } + Base64DecodePiece(srcData, iChars, dstData, iBytes); + *pDstEnd++ = ((uint8_t*)&dstData)[0]; + if (iBytes > 1) { + *pDstEnd++ = ((uint8_t*)&dstData)[1]; + } + if (iBytes > 2) { + *pDstEnd++ = ((uint8_t*)&dstData)[2]; + } + } + return pDstEnd - pDst; +} + +} // namespace + +CXFA_FFDoc::CXFA_FFDoc(CXFA_FFApp* pApp, IXFA_DocEnvironment* pDocEnvironment) + : m_pDocEnvironment(pDocEnvironment), + m_pDocumentParser(nullptr), + m_pApp(pApp), + m_pNotify(nullptr), + m_pPDFDoc(nullptr), + m_dwDocType(XFA_DocType::Static) {} + +CXFA_FFDoc::~CXFA_FFDoc() { + CloseDoc(); +} + +int32_t CXFA_FFDoc::StartLoad() { + m_pNotify = pdfium::MakeUnique(this); + m_pDocumentParser = pdfium::MakeUnique(m_pNotify.get()); + return m_pDocumentParser->StartParse(m_pStream, XFA_XDPPACKET_XDP); +} + +bool XFA_GetPDFContentsFromPDFXML(CFDE_XMLNode* pPDFElement, + uint8_t*& pByteBuffer, + int32_t& iBufferSize) { + CFDE_XMLElement* pDocumentElement = nullptr; + for (CFDE_XMLNode* pXMLNode = + pPDFElement->GetNodeItem(CFDE_XMLNode::FirstChild); + pXMLNode; pXMLNode = pXMLNode->GetNodeItem(CFDE_XMLNode::NextSibling)) { + if (pXMLNode->GetType() == FDE_XMLNODE_Element) { + CFX_WideString wsTagName; + CFDE_XMLElement* pXMLElement = static_cast(pXMLNode); + pXMLElement->GetTagName(wsTagName); + if (wsTagName == L"document") { + pDocumentElement = pXMLElement; + break; + } + } + } + if (!pDocumentElement) { + return false; + } + CFDE_XMLElement* pChunkElement = nullptr; + for (CFDE_XMLNode* pXMLNode = + pDocumentElement->GetNodeItem(CFDE_XMLNode::FirstChild); + pXMLNode; pXMLNode = pXMLNode->GetNodeItem(CFDE_XMLNode::NextSibling)) { + if (pXMLNode->GetType() == FDE_XMLNODE_Element) { + CFX_WideString wsTagName; + CFDE_XMLElement* pXMLElement = static_cast(pXMLNode); + pXMLElement->GetTagName(wsTagName); + if (wsTagName == L"chunk") { + pChunkElement = pXMLElement; + break; + } + } + } + if (!pChunkElement) { + return false; + } + CFX_WideString wsPDFContent; + pChunkElement->GetTextData(wsPDFContent); + iBufferSize = + Base64DecodeW(wsPDFContent.c_str(), wsPDFContent.GetLength(), nullptr); + pByteBuffer = FX_Alloc(uint8_t, iBufferSize + 1); + pByteBuffer[iBufferSize] = '0'; // FIXME: I bet this is wrong. + Base64DecodeW(wsPDFContent.c_str(), wsPDFContent.GetLength(), pByteBuffer); + return true; +} +void XFA_XPDPacket_MergeRootNode(CXFA_Node* pOriginRoot, CXFA_Node* pNewRoot) { + CXFA_Node* pChildNode = pNewRoot->GetNodeItem(XFA_NODEITEM_FirstChild); + while (pChildNode) { + CXFA_Node* pOriginChild = + pOriginRoot->GetFirstChildByName(pChildNode->GetNameHash()); + if (pOriginChild) { + pChildNode = pChildNode->GetNodeItem(XFA_NODEITEM_NextSibling); + } else { + CXFA_Node* pNextSibling = + pChildNode->GetNodeItem(XFA_NODEITEM_NextSibling); + pNewRoot->RemoveChild(pChildNode); + pOriginRoot->InsertChild(pChildNode); + pChildNode = pNextSibling; + pNextSibling = nullptr; + } + } +} + +int32_t CXFA_FFDoc::DoLoad(IFX_Pause* pPause) { + int32_t iStatus = m_pDocumentParser->DoParse(pPause); + if (iStatus == XFA_PARSESTATUS_Done && !m_pPDFDoc) + return XFA_PARSESTATUS_SyntaxErr; + return iStatus; +} + +void CXFA_FFDoc::StopLoad() { + m_pApp->GetXFAFontMgr()->LoadDocFonts(this); + m_dwDocType = XFA_DocType::Static; + CXFA_Node* pConfig = ToNode( + m_pDocumentParser->GetDocument()->GetXFAObject(XFA_HASHCODE_Config)); + if (!pConfig) + return; + + CXFA_Node* pAcrobat = pConfig->GetFirstChildByClass(XFA_Element::Acrobat); + if (!pAcrobat) + return; + + CXFA_Node* pAcrobat7 = pAcrobat->GetFirstChildByClass(XFA_Element::Acrobat7); + if (!pAcrobat7) + return; + + CXFA_Node* pDynamicRender = + pAcrobat7->GetFirstChildByClass(XFA_Element::DynamicRender); + if (!pDynamicRender) + return; + + CFX_WideString wsType; + if (pDynamicRender->TryContent(wsType) && wsType == L"required") + m_dwDocType = XFA_DocType::Dynamic; +} + +CXFA_FFDocView* CXFA_FFDoc::CreateDocView() { + if (!m_DocView) + m_DocView = pdfium::MakeUnique(this); + + return m_DocView.get(); +} + +CXFA_FFDocView* CXFA_FFDoc::GetDocView(CXFA_LayoutProcessor* pLayout) { + return m_DocView && m_DocView->GetXFALayout() == pLayout ? m_DocView.get() + : nullptr; +} + +CXFA_FFDocView* CXFA_FFDoc::GetDocView() { + return m_DocView.get(); +} + +bool CXFA_FFDoc::OpenDoc(const CFX_RetainPtr& pStream) { + m_pStream = pStream; + return true; +} + +bool CXFA_FFDoc::OpenDoc(CPDF_Document* pPDFDoc) { + if (!pPDFDoc) + return false; + + CPDF_Dictionary* pRoot = pPDFDoc->GetRoot(); + if (!pRoot) + return false; + + CPDF_Dictionary* pAcroForm = pRoot->GetDictFor("AcroForm"); + if (!pAcroForm) + return false; + + CPDF_Object* pElementXFA = pAcroForm->GetDirectObjectFor("XFA"); + if (!pElementXFA) + return false; + + std::vector xfaStreams; + if (pElementXFA->IsArray()) { + CPDF_Array* pXFAArray = (CPDF_Array*)pElementXFA; + for (size_t i = 0; i < pXFAArray->GetCount() / 2; i++) { + if (CPDF_Stream* pStream = pXFAArray->GetStreamAt(i * 2 + 1)) + xfaStreams.push_back(pStream); + } + } else if (pElementXFA->IsStream()) { + xfaStreams.push_back((CPDF_Stream*)pElementXFA); + } + if (xfaStreams.empty()) + return false; + + m_pPDFDoc = pPDFDoc; + m_pStream = MakeSeekableReadStream(xfaStreams); + return true; +} + +bool CXFA_FFDoc::CloseDoc() { + if (m_DocView) + m_DocView->RunDocClose(); + + CXFA_Document* doc = + m_pDocumentParser ? m_pDocumentParser->GetDocument() : nullptr; + if (doc) + doc->ClearLayoutData(); + + m_DocView.reset(); + m_pNotify.reset(nullptr); + m_pApp->GetXFAFontMgr()->ReleaseDocFonts(this); + + for (const auto& pair : m_HashToDibDpiMap) + delete pair.second.pDibSource; + + m_HashToDibDpiMap.clear(); + m_pApp->ClearEventTargets(); + return true; +} + +CPDF_Document* CXFA_FFDoc::GetPDFDoc() { + return m_pPDFDoc; +} + +CFX_DIBitmap* CXFA_FFDoc::GetPDFNamedImage(const CFX_WideStringC& wsName, + int32_t& iImageXDpi, + int32_t& iImageYDpi) { + if (!m_pPDFDoc) + return nullptr; + + uint32_t dwHash = FX_HashCode_GetW(wsName, false); + auto it = m_HashToDibDpiMap.find(dwHash); + if (it != m_HashToDibDpiMap.end()) { + iImageXDpi = it->second.iImageXDpi; + iImageYDpi = it->second.iImageYDpi; + return static_cast(it->second.pDibSource); + } + + CPDF_Dictionary* pRoot = m_pPDFDoc->GetRoot(); + if (!pRoot) + return nullptr; + + CPDF_Dictionary* pNames = pRoot->GetDictFor("Names"); + if (!pNames) + return nullptr; + + CPDF_Dictionary* pXFAImages = pNames->GetDictFor("XFAImages"); + if (!pXFAImages) + return nullptr; + + CPDF_NameTree nametree(pXFAImages); + CFX_ByteString bsName = PDF_EncodeText(wsName.c_str(), wsName.GetLength()); + CPDF_Object* pObject = nametree.LookupValue(bsName); + if (!pObject) { + for (size_t i = 0; i < nametree.GetCount(); i++) { + CFX_ByteString bsTemp; + CPDF_Object* pTempObject = nametree.LookupValue(i, bsTemp); + if (bsTemp == bsName) { + pObject = pTempObject; + break; + } + } + } + + CPDF_Stream* pStream = ToStream(pObject); + if (!pStream) + return nullptr; + + CPDF_StreamAcc streamAcc; + streamAcc.LoadAllData(pStream); + + CFX_RetainPtr pImageFileRead = + IFX_MemoryStream::Create((uint8_t*)streamAcc.GetData(), + streamAcc.GetSize()); + + CFX_DIBitmap* pDibSource = XFA_LoadImageFromBuffer( + pImageFileRead, FXCODEC_IMAGE_UNKNOWN, iImageXDpi, iImageYDpi); + m_HashToDibDpiMap[dwHash] = {pDibSource, iImageXDpi, iImageYDpi}; + return pDibSource; +} + +bool CXFA_FFDoc::SavePackage( + XFA_HashCode code, + const CFX_RetainPtr& pFile, + CXFA_ChecksumContext* pCSContext) { + CXFA_Document* doc = m_pDocumentParser->GetDocument(); + std::unique_ptr pExport(new CXFA_DataExporter(doc)); + CXFA_Node* pNode = code == XFA_HASHCODE_Xfa ? doc->GetRoot() + : ToNode(doc->GetXFAObject(code)); + if (!pNode) + return !!pExport->Export(pFile); + + CFX_ByteString bsChecksum; + if (pCSContext) + bsChecksum = pCSContext->GetChecksum(); + + return !!pExport->Export( + pFile, pNode, 0, bsChecksum.GetLength() ? bsChecksum.c_str() : nullptr); +} + +bool CXFA_FFDoc::ImportData( + const CFX_RetainPtr& pStream, + bool bXDP) { + auto importer = + pdfium::MakeUnique(m_pDocumentParser->GetDocument()); + return importer->ImportData(pStream); +} diff --git a/xfa/fxfa/cxfa_ffdoc.h b/xfa/fxfa/cxfa_ffdoc.h new file mode 100644 index 0000000000..1d46387a5e --- /dev/null +++ b/xfa/fxfa/cxfa_ffdoc.h @@ -0,0 +1,73 @@ +// 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_CXFA_FFDOC_H_ +#define XFA_FXFA_CXFA_FFDOC_H_ + +#include +#include + +#include "xfa/fxfa/fxfa.h" +#include "xfa/fxfa/parser/cxfa_document.h" +#include "xfa/fxfa/parser/cxfa_document_parser.h" + +class CXFA_ChecksumContext; +class CXFA_FFApp; +class CXFA_FFNotify; +class CXFA_FFDocView; + +struct FX_IMAGEDIB_AND_DPI { + CFX_DIBSource* pDibSource; + int32_t iImageXDpi; + int32_t iImageYDpi; +}; + +class CXFA_FFDoc { + public: + CXFA_FFDoc(CXFA_FFApp* pApp, IXFA_DocEnvironment* pDocEnvironment); + ~CXFA_FFDoc(); + + IXFA_DocEnvironment* GetDocEnvironment() const { return m_pDocEnvironment; } + XFA_DocType GetDocType() const { return m_dwDocType; } + + int32_t StartLoad(); + int32_t DoLoad(IFX_Pause* pPause = nullptr); + void StopLoad(); + + CXFA_FFDocView* CreateDocView(); + + bool OpenDoc(const CFX_RetainPtr& pStream); + bool OpenDoc(CPDF_Document* pPDFDoc); + bool CloseDoc(); + + CXFA_Document* GetXFADoc() { return m_pDocumentParser->GetDocument(); } + CXFA_FFApp* GetApp() { return m_pApp; } + CXFA_FFDocView* GetDocView(CXFA_LayoutProcessor* pLayout); + CXFA_FFDocView* GetDocView(); + CPDF_Document* GetPDFDoc(); + CFX_DIBitmap* GetPDFNamedImage(const CFX_WideStringC& wsName, + int32_t& iImageXDpi, + int32_t& iImageYDpi); + + bool SavePackage(XFA_HashCode code, + const CFX_RetainPtr& pFile, + CXFA_ChecksumContext* pCSContext); + bool ImportData(const CFX_RetainPtr& pStream, + bool bXDP = true); + + private: + IXFA_DocEnvironment* const m_pDocEnvironment; + std::unique_ptr m_pDocumentParser; + CFX_RetainPtr m_pStream; + CXFA_FFApp* m_pApp; + std::unique_ptr m_pNotify; + CPDF_Document* m_pPDFDoc; + std::map m_HashToDibDpiMap; + std::unique_ptr m_DocView; + XFA_DocType m_dwDocType; +}; + +#endif // XFA_FXFA_CXFA_FFDOC_H_ diff --git a/xfa/fxfa/cxfa_ffdochandler.cpp b/xfa/fxfa/cxfa_ffdochandler.cpp new file mode 100644 index 0000000000..a71bb208fa --- /dev/null +++ b/xfa/fxfa/cxfa_ffdochandler.cpp @@ -0,0 +1,60 @@ +// 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 + +#include "xfa/fxfa/cxfa_ffdochandler.h" + +#include "xfa/fxfa/cxfa_checksumcontext.h" +#include "xfa/fxfa/cxfa_ffdoc.h" +#include "xfa/fxfa/parser/cxfa_scriptcontext.h" +#include "xfa/fxfa/parser/xfa_resolvenode_rs.h" + +CXFA_FFDocHandler::CXFA_FFDocHandler() {} + +CXFA_FFDocHandler::~CXFA_FFDocHandler() {} + +CFXJSE_Value* CXFA_FFDocHandler::GetXFAScriptObject(CXFA_FFDoc* hDoc) { + CXFA_Document* pXFADoc = hDoc->GetXFADoc(); + if (!pXFADoc) + return nullptr; + + CXFA_ScriptContext* pScriptContext = pXFADoc->GetScriptContext(); + if (!pScriptContext) + return nullptr; + return pScriptContext->GetJSValueFromMap(pXFADoc->GetRoot()); +} + +XFA_ATTRIBUTEENUM CXFA_FFDocHandler::GetRestoreState(CXFA_FFDoc* hDoc) { + CXFA_Document* pXFADoc = hDoc->GetXFADoc(); + if (!pXFADoc) + return XFA_ATTRIBUTEENUM_Unknown; + + CXFA_Node* pForm = ToNode(pXFADoc->GetXFAObject(XFA_HASHCODE_Form)); + if (!pForm) + return XFA_ATTRIBUTEENUM_Unknown; + + CXFA_Node* pSubForm = pForm->GetFirstChildByClass(XFA_Element::Subform); + if (!pSubForm) + return XFA_ATTRIBUTEENUM_Unknown; + return pSubForm->GetEnum(XFA_ATTRIBUTE_RestoreState); +} + +bool CXFA_FFDocHandler::RunDocScript(CXFA_FFDoc* hDoc, + XFA_SCRIPTTYPE eScriptType, + const CFX_WideStringC& wsScript, + CFXJSE_Value* pRetValue, + CFXJSE_Value* pThisValue) { + CXFA_Document* pXFADoc = hDoc->GetXFADoc(); + if (!pXFADoc) + return false; + + CXFA_ScriptContext* pScriptContext = pXFADoc->GetScriptContext(); + if (!pScriptContext) + return false; + + return pScriptContext->RunScript( + (XFA_SCRIPTLANGTYPE)eScriptType, wsScript, pRetValue, + pThisValue ? CXFA_ScriptContext::ToObject(pThisValue, nullptr) : nullptr); +} diff --git a/xfa/fxfa/cxfa_ffdochandler.h b/xfa/fxfa/cxfa_ffdochandler.h new file mode 100644 index 0000000000..b54c36c1d7 --- /dev/null +++ b/xfa/fxfa/cxfa_ffdochandler.h @@ -0,0 +1,29 @@ +// 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_CXFA_FFDOCHANDLER_H_ +#define XFA_FXFA_CXFA_FFDOCHANDLER_H_ + +#include "xfa/fxfa/fxfa.h" + +class CXFA_ChecksumContext; + +class CXFA_FFDocHandler { + public: + CXFA_FFDocHandler(); + ~CXFA_FFDocHandler(); + + CFXJSE_Value* GetXFAScriptObject(CXFA_FFDoc* hDoc); + XFA_ATTRIBUTEENUM GetRestoreState(CXFA_FFDoc* hDoc); + + bool RunDocScript(CXFA_FFDoc* hDoc, + XFA_SCRIPTTYPE eScriptType, + const CFX_WideStringC& wsScript, + CFXJSE_Value* pRetValue, + CFXJSE_Value* pThisObject); +}; + +#endif // XFA_FXFA_CXFA_FFDOCHANDLER_H_ diff --git a/xfa/fxfa/cxfa_ffdocview.cpp b/xfa/fxfa/cxfa_ffdocview.cpp new file mode 100644 index 0000000000..9708e34562 --- /dev/null +++ b/xfa/fxfa/cxfa_ffdocview.cpp @@ -0,0 +1,790 @@ +// 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 + +#include "xfa/fxfa/cxfa_ffdocview.h" + +#include "core/fxcrt/fx_ext.h" +#include "third_party/base/ptr_util.h" +#include "third_party/base/stl_util.h" +#include "xfa/fxfa/app/xfa_ffbarcode.h" +#include "xfa/fxfa/app/xfa_ffcheckbutton.h" +#include "xfa/fxfa/app/xfa_ffchoicelist.h" +#include "xfa/fxfa/app/xfa_ffdraw.h" +#include "xfa/fxfa/app/xfa_ffexclgroup.h" +#include "xfa/fxfa/app/xfa_fffield.h" +#include "xfa/fxfa/app/xfa_ffimage.h" +#include "xfa/fxfa/app/xfa_ffimageedit.h" +#include "xfa/fxfa/app/xfa_ffpath.h" +#include "xfa/fxfa/app/xfa_ffpushbutton.h" +#include "xfa/fxfa/app/xfa_ffsignature.h" +#include "xfa/fxfa/app/xfa_ffsubform.h" +#include "xfa/fxfa/app/xfa_fftext.h" +#include "xfa/fxfa/app/xfa_fftextedit.h" +#include "xfa/fxfa/app/xfa_ffwidgetacc.h" +#include "xfa/fxfa/app/xfa_fwladapter.h" +#include "xfa/fxfa/cxfa_ffapp.h" +#include "xfa/fxfa/cxfa_ffdoc.h" +#include "xfa/fxfa/cxfa_ffpageview.h" +#include "xfa/fxfa/cxfa_ffwidget.h" +#include "xfa/fxfa/cxfa_ffwidgethandler.h" +#include "xfa/fxfa/cxfa_widgetacciterator.h" +#include "xfa/fxfa/parser/cxfa_binditems.h" +#include "xfa/fxfa/parser/cxfa_layoutprocessor.h" +#include "xfa/fxfa/parser/cxfa_scriptcontext.h" +#include "xfa/fxfa/parser/xfa_resolvenode_rs.h" + +const XFA_ATTRIBUTEENUM gs_EventActivity[] = { + XFA_ATTRIBUTEENUM_Click, XFA_ATTRIBUTEENUM_Change, + XFA_ATTRIBUTEENUM_DocClose, XFA_ATTRIBUTEENUM_DocReady, + XFA_ATTRIBUTEENUM_Enter, XFA_ATTRIBUTEENUM_Exit, + XFA_ATTRIBUTEENUM_Full, XFA_ATTRIBUTEENUM_IndexChange, + XFA_ATTRIBUTEENUM_Initialize, XFA_ATTRIBUTEENUM_MouseDown, + XFA_ATTRIBUTEENUM_MouseEnter, XFA_ATTRIBUTEENUM_MouseExit, + XFA_ATTRIBUTEENUM_MouseUp, XFA_ATTRIBUTEENUM_PostExecute, + XFA_ATTRIBUTEENUM_PostOpen, XFA_ATTRIBUTEENUM_PostPrint, + XFA_ATTRIBUTEENUM_PostSave, XFA_ATTRIBUTEENUM_PostSign, + XFA_ATTRIBUTEENUM_PostSubmit, XFA_ATTRIBUTEENUM_PreExecute, + XFA_ATTRIBUTEENUM_PreOpen, XFA_ATTRIBUTEENUM_PrePrint, + XFA_ATTRIBUTEENUM_PreSave, XFA_ATTRIBUTEENUM_PreSign, + XFA_ATTRIBUTEENUM_PreSubmit, XFA_ATTRIBUTEENUM_Ready, + XFA_ATTRIBUTEENUM_Unknown, +}; + +CXFA_FFDocView::CXFA_FFDocView(CXFA_FFDoc* pDoc) + : m_bLayoutEvent(false), + m_pListFocusWidget(nullptr), + m_bInLayoutStatus(false), + m_pDoc(pDoc), + m_pXFADocLayout(nullptr), + m_pFocusAcc(nullptr), + m_pFocusWidget(nullptr), + m_pOldFocusWidget(nullptr), + m_iStatus(XFA_DOCVIEW_LAYOUTSTATUS_None), + m_iLock(0) {} + +CXFA_FFDocView::~CXFA_FFDocView() { + DestroyDocView(); +} + +void CXFA_FFDocView::InitLayout(CXFA_Node* pNode) { + RunBindItems(); + ExecEventActivityByDeepFirst(pNode, XFA_EVENT_Initialize, false, true, + nullptr); + ExecEventActivityByDeepFirst(pNode, XFA_EVENT_IndexChange, false, true, + nullptr); +} +int32_t CXFA_FFDocView::StartLayout(int32_t iStartPage) { + m_iStatus = XFA_DOCVIEW_LAYOUTSTATUS_Start; + m_pDoc->GetXFADoc()->DoProtoMerge(); + m_pDoc->GetXFADoc()->DoDataMerge(); + m_pXFADocLayout = GetXFALayout(); + int32_t iStatus = m_pXFADocLayout->StartLayout(); + if (iStatus < 0) { + return iStatus; + } + CXFA_Node* pRootItem = + ToNode(m_pDoc->GetXFADoc()->GetXFAObject(XFA_HASHCODE_Form)); + if (!pRootItem) { + return iStatus; + } + InitLayout(pRootItem); + InitCalculate(pRootItem); + InitValidate(pRootItem); + ExecEventActivityByDeepFirst(pRootItem, XFA_EVENT_Ready, true, true, nullptr); + m_iStatus = XFA_DOCVIEW_LAYOUTSTATUS_Start; + return iStatus; +} +int32_t CXFA_FFDocView::DoLayout(IFX_Pause* pPause) { + int32_t iStatus = 100; + iStatus = m_pXFADocLayout->DoLayout(pPause); + if (iStatus != 100) { + return iStatus; + } + m_iStatus = XFA_DOCVIEW_LAYOUTSTATUS_Doing; + return iStatus; +} +void CXFA_FFDocView::StopLayout() { + CXFA_Node* pRootItem = + ToNode(m_pDoc->GetXFADoc()->GetXFAObject(XFA_HASHCODE_Form)); + if (!pRootItem) { + return; + } + CXFA_Node* pSubformNode = pRootItem->GetChild(0, XFA_Element::Subform); + if (!pSubformNode) { + return; + } + CXFA_Node* pPageSetNode = + pSubformNode->GetFirstChildByClass(XFA_Element::PageSet); + if (!pPageSetNode) { + return; + } + RunCalculateWidgets(); + RunValidate(); + InitLayout(pPageSetNode); + InitCalculate(pPageSetNode); + InitValidate(pPageSetNode); + ExecEventActivityByDeepFirst(pPageSetNode, XFA_EVENT_Ready, true, true, + nullptr); + ExecEventActivityByDeepFirst(pRootItem, XFA_EVENT_Ready, false, true, + nullptr); + ExecEventActivityByDeepFirst(pRootItem, XFA_EVENT_DocReady, false, true, + nullptr); + RunCalculateWidgets(); + RunValidate(); + if (RunLayout()) { + ExecEventActivityByDeepFirst(pRootItem, XFA_EVENT_Ready, false, true, + nullptr); + } + m_CalculateAccs.clear(); + if (m_pFocusAcc && !m_pFocusWidget) { + SetFocusWidgetAcc(m_pFocusAcc); + } + m_iStatus = XFA_DOCVIEW_LAYOUTSTATUS_End; +} +int32_t CXFA_FFDocView::GetLayoutStatus() { + return m_iStatus; +} +void CXFA_FFDocView::ShowNullTestMsg() { + int32_t iCount = pdfium::CollectionSize(m_arrNullTestMsg); + CXFA_FFApp* pApp = m_pDoc->GetApp(); + IXFA_AppProvider* pAppProvider = pApp->GetAppProvider(); + if (pAppProvider && iCount) { + int32_t iRemain = iCount > 7 ? iCount - 7 : 0; + iCount -= iRemain; + CFX_WideString wsMsg; + for (int32_t i = 0; i < iCount; i++) { + wsMsg += m_arrNullTestMsg[i] + L"\n"; + } + if (iRemain > 0) { + CFX_WideString wsTemp; + wsTemp.Format( + L"Message limit exceeded. Remaining %d " + L"validation errors not reported.", + iRemain); + wsMsg += L"\n" + wsTemp; + } + pAppProvider->MsgBox(wsMsg, pAppProvider->GetAppTitle(), XFA_MBICON_Status, + XFA_MB_OK); + } + m_arrNullTestMsg.clear(); +} + +void CXFA_FFDocView::UpdateDocView() { + if (IsUpdateLocked()) + return; + + LockUpdate(); + for (CXFA_Node* pNode : m_NewAddedNodes) { + InitCalculate(pNode); + InitValidate(pNode); + ExecEventActivityByDeepFirst(pNode, XFA_EVENT_Ready, true, true, nullptr); + } + m_NewAddedNodes.clear(); + RunSubformIndexChange(); + RunCalculateWidgets(); + RunValidate(); + ShowNullTestMsg(); + if (RunLayout() && m_bLayoutEvent) + RunEventLayoutReady(); + + m_bLayoutEvent = false; + m_CalculateAccs.clear(); + RunInvalidate(); + UnlockUpdate(); +} + +int32_t CXFA_FFDocView::CountPageViews() { + if (!m_pXFADocLayout) { + return 0; + } + return m_pXFADocLayout->CountPages(); +} +CXFA_FFPageView* CXFA_FFDocView::GetPageView(int32_t nIndex) { + if (!m_pXFADocLayout) { + return nullptr; + } + return static_cast(m_pXFADocLayout->GetPage(nIndex)); +} + +CXFA_LayoutProcessor* CXFA_FFDocView::GetXFALayout() const { + return m_pDoc->GetXFADoc()->GetDocLayout(); +} +bool CXFA_FFDocView::ResetSingleWidgetAccData(CXFA_WidgetAcc* pWidgetAcc) { + CXFA_Node* pNode = pWidgetAcc->GetNode(); + XFA_Element eType = pNode->GetElementType(); + if (eType != XFA_Element::Field && eType != XFA_Element::ExclGroup) { + return false; + } + pWidgetAcc->ResetData(); + pWidgetAcc->UpdateUIDisplay(); + if (CXFA_Validate validate = pWidgetAcc->GetValidate()) { + AddValidateWidget(pWidgetAcc); + validate.GetNode()->SetFlag(XFA_NodeFlag_NeedsInitApp, false); + } + return true; +} +void CXFA_FFDocView::ResetWidgetData(CXFA_WidgetAcc* pWidgetAcc) { + m_bLayoutEvent = true; + bool bChanged = false; + CXFA_Node* pFormNode = nullptr; + if (pWidgetAcc) { + bChanged = ResetSingleWidgetAccData(pWidgetAcc); + pFormNode = pWidgetAcc->GetNode(); + } else { + pFormNode = GetRootSubform(); + } + if (!pFormNode) { + return; + } + if (pFormNode->GetElementType() != XFA_Element::Field && + pFormNode->GetElementType() != XFA_Element::ExclGroup) { + CXFA_WidgetAccIterator Iterator(pFormNode); + while (CXFA_WidgetAcc* pAcc = Iterator.MoveToNext()) { + bChanged |= ResetSingleWidgetAccData(pAcc); + if (pAcc->GetNode()->GetElementType() == XFA_Element::ExclGroup) { + Iterator.SkipTree(); + } + } + } + if (bChanged) { + m_pDoc->GetDocEnvironment()->SetChangeMark(m_pDoc); + } +} +int32_t CXFA_FFDocView::ProcessWidgetEvent(CXFA_EventParam* pParam, + CXFA_WidgetAcc* pWidgetAcc) { + if (!pParam) + return XFA_EVENTERROR_Error; + + if (pParam->m_eType == XFA_EVENT_Validate) { + CFX_WideString wsValidateStr(L"preSubmit"); + CXFA_Node* pConfigItem = + ToNode(m_pDoc->GetXFADoc()->GetXFAObject(XFA_HASHCODE_Config)); + if (pConfigItem) { + CXFA_Node* pValidateNode = nullptr; + CXFA_Node* pAcrobatNode = pConfigItem->GetChild(0, XFA_Element::Acrobat); + pValidateNode = pAcrobatNode + ? pAcrobatNode->GetChild(0, XFA_Element::Validate) + : nullptr; + if (!pValidateNode) { + CXFA_Node* pPresentNode = + pConfigItem->GetChild(0, XFA_Element::Present); + pValidateNode = pPresentNode + ? pPresentNode->GetChild(0, XFA_Element::Validate) + : nullptr; + } + if (pValidateNode) + wsValidateStr = pValidateNode->GetContent(); + } + + if (wsValidateStr.Find(L"preSubmit") == -1) + return XFA_EVENTERROR_Success; + } + + CXFA_Node* pNode = pWidgetAcc ? pWidgetAcc->GetNode() : nullptr; + if (!pNode) { + CXFA_Node* pRootItem = + ToNode(m_pDoc->GetXFADoc()->GetXFAObject(XFA_HASHCODE_Form)); + if (!pRootItem) + return XFA_EVENTERROR_Error; + + pNode = pRootItem->GetChild(0, XFA_Element::Subform); + } + ExecEventActivityByDeepFirst(pNode, pParam->m_eType, pParam->m_bIsFormReady, + true, nullptr); + return XFA_EVENTERROR_Success; +} + +CXFA_FFWidgetHandler* CXFA_FFDocView::GetWidgetHandler() { + if (!m_pWidgetHandler) + m_pWidgetHandler = pdfium::MakeUnique(this); + + return m_pWidgetHandler.get(); +} + +CXFA_WidgetAccIterator* CXFA_FFDocView::CreateWidgetAccIterator( + XFA_WIDGETORDER eOrder) { + CXFA_Node* pFormRoot = GetRootSubform(); + return pFormRoot ? new CXFA_WidgetAccIterator(pFormRoot) : nullptr; +} + +CXFA_FFWidget* CXFA_FFDocView::GetFocusWidget() { + return m_pFocusWidget; +} + +void CXFA_FFDocView::KillFocus() { + if (m_pFocusWidget && + (m_pFocusWidget->GetStatus() & XFA_WidgetStatus_Focused)) { + (m_pFocusWidget)->OnKillFocus(nullptr); + } + m_pFocusAcc = nullptr; + m_pFocusWidget = nullptr; + m_pOldFocusWidget = nullptr; +} +bool CXFA_FFDocView::SetFocus(CXFA_FFWidget* hWidget) { + CXFA_FFWidget* pNewFocus = hWidget; + if (m_pOldFocusWidget == pNewFocus) { + return false; + } + CXFA_FFWidget* pOldFocus = m_pOldFocusWidget; + m_pOldFocusWidget = pNewFocus; + if (pOldFocus) { + if (m_pFocusWidget != m_pOldFocusWidget && + (pOldFocus->GetStatus() & XFA_WidgetStatus_Focused)) { + m_pFocusWidget = pOldFocus; + pOldFocus->OnKillFocus(pNewFocus); + } else if ((pOldFocus->GetStatus() & XFA_WidgetStatus_Visible)) { + if (!pOldFocus->IsLoaded()) { + pOldFocus->LoadWidget(); + } + pOldFocus->OnSetFocus(m_pFocusWidget); + m_pFocusWidget = pOldFocus; + pOldFocus->OnKillFocus(pNewFocus); + } + } + if (m_pFocusWidget == m_pOldFocusWidget) { + return false; + } + pNewFocus = m_pOldFocusWidget; + if (m_pListFocusWidget && pNewFocus == m_pListFocusWidget) { + m_pFocusAcc = nullptr; + m_pFocusWidget = nullptr; + m_pListFocusWidget = nullptr; + m_pOldFocusWidget = nullptr; + return false; + } + if (pNewFocus && (pNewFocus->GetStatus() & XFA_WidgetStatus_Visible)) { + if (!pNewFocus->IsLoaded()) { + pNewFocus->LoadWidget(); + } + pNewFocus->OnSetFocus(m_pFocusWidget); + } + m_pFocusAcc = pNewFocus ? pNewFocus->GetDataAcc() : nullptr; + m_pFocusWidget = pNewFocus; + m_pOldFocusWidget = m_pFocusWidget; + return true; +} +CXFA_WidgetAcc* CXFA_FFDocView::GetFocusWidgetAcc() { + return m_pFocusAcc; +} +void CXFA_FFDocView::SetFocusWidgetAcc(CXFA_WidgetAcc* pWidgetAcc) { + CXFA_FFWidget* pNewFocus = + pWidgetAcc ? pWidgetAcc->GetNextWidget(nullptr) : nullptr; + if (SetFocus(pNewFocus)) { + m_pFocusAcc = pWidgetAcc; + if (m_iStatus == XFA_DOCVIEW_LAYOUTSTATUS_End) { + m_pDoc->GetDocEnvironment()->SetFocusWidget(m_pDoc, m_pFocusWidget); + } + } +} +void CXFA_FFDocView::DeleteLayoutItem(CXFA_FFWidget* pWidget) { + if (m_pFocusAcc == pWidget->GetDataAcc()) { + m_pFocusAcc = nullptr; + m_pFocusWidget = nullptr; + m_pOldFocusWidget = nullptr; + } +} +static int32_t XFA_ProcessEvent(CXFA_FFDocView* pDocView, + CXFA_WidgetAcc* pWidgetAcc, + CXFA_EventParam* pParam) { + if (!pParam || pParam->m_eType == XFA_EVENT_Unknown) { + return XFA_EVENTERROR_NotExist; + } + if (!pWidgetAcc || pWidgetAcc->GetElementType() == XFA_Element::Draw) { + return XFA_EVENTERROR_NotExist; + } + switch (pParam->m_eType) { + case XFA_EVENT_Calculate: + return pWidgetAcc->ProcessCalculate(); + case XFA_EVENT_Validate: + if (((CXFA_FFDoc*)pDocView->GetDoc()) + ->GetDocEnvironment() + ->IsValidationsEnabled(pDocView->GetDoc())) { + return pWidgetAcc->ProcessValidate(0x01); + } + return XFA_EVENTERROR_Disabled; + case XFA_EVENT_InitCalculate: { + CXFA_Calculate calc = pWidgetAcc->GetCalculate(); + if (!calc) { + return XFA_EVENTERROR_NotExist; + } + if (pWidgetAcc->GetNode()->IsUserInteractive()) + return XFA_EVENTERROR_Disabled; + + CXFA_Script script = calc.GetScript(); + return pWidgetAcc->ExecuteScript(script, pParam); + } + default: + break; + } + int32_t iRet = + pWidgetAcc->ProcessEvent(gs_EventActivity[pParam->m_eType], pParam); + return iRet; +} +int32_t CXFA_FFDocView::ExecEventActivityByDeepFirst(CXFA_Node* pFormNode, + XFA_EVENTTYPE eEventType, + bool bIsFormReady, + bool bRecursive, + CXFA_Node* pExclude) { + int32_t iRet = XFA_EVENTERROR_NotExist; + if (pFormNode == pExclude) { + return iRet; + } + XFA_Element elementType = pFormNode->GetElementType(); + if (elementType == XFA_Element::Field) { + if (eEventType == XFA_EVENT_IndexChange) { + return iRet; + } + CXFA_WidgetAcc* pWidgetAcc = (CXFA_WidgetAcc*)pFormNode->GetWidgetData(); + if (!pWidgetAcc) { + return iRet; + } + CXFA_EventParam eParam; + eParam.m_eType = eEventType; + eParam.m_pTarget = pWidgetAcc; + eParam.m_bIsFormReady = bIsFormReady; + return XFA_ProcessEvent(this, pWidgetAcc, &eParam); + } + if (bRecursive) { + for (CXFA_Node* pNode = pFormNode->GetNodeItem( + XFA_NODEITEM_FirstChild, XFA_ObjectType::ContainerNode); + pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling, + XFA_ObjectType::ContainerNode)) { + elementType = pNode->GetElementType(); + if (elementType != XFA_Element::Variables && + elementType != XFA_Element::Draw) { + iRet |= ExecEventActivityByDeepFirst(pNode, eEventType, bIsFormReady, + bRecursive, pExclude); + } + } + } + CXFA_WidgetAcc* pWidgetAcc = (CXFA_WidgetAcc*)pFormNode->GetWidgetData(); + if (!pWidgetAcc) { + return iRet; + } + CXFA_EventParam eParam; + eParam.m_eType = eEventType; + eParam.m_pTarget = pWidgetAcc; + eParam.m_bIsFormReady = bIsFormReady; + iRet |= XFA_ProcessEvent(this, pWidgetAcc, &eParam); + return iRet; +} + +CXFA_FFWidget* CXFA_FFDocView::GetWidgetByName(const CFX_WideString& wsName, + CXFA_FFWidget* pRefWidget) { + CXFA_WidgetAcc* pRefAcc = pRefWidget ? pRefWidget->GetDataAcc() : nullptr; + CXFA_WidgetAcc* pAcc = GetWidgetAccByName(wsName, pRefAcc); + return pAcc ? pAcc->GetNextWidget(nullptr) : nullptr; +} + +CXFA_WidgetAcc* CXFA_FFDocView::GetWidgetAccByName( + const CFX_WideString& wsName, + CXFA_WidgetAcc* pRefWidgetAcc) { + CFX_WideString wsExpression; + uint32_t dwStyle = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties | + XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_Parent; + CXFA_ScriptContext* pScriptContext = m_pDoc->GetXFADoc()->GetScriptContext(); + if (!pScriptContext) { + return nullptr; + } + CXFA_Node* refNode = nullptr; + if (pRefWidgetAcc) { + refNode = pRefWidgetAcc->GetNode(); + wsExpression = wsName; + } else { + wsExpression = L"$form." + wsName; + } + XFA_RESOLVENODE_RS resoveNodeRS; + int32_t iRet = pScriptContext->ResolveObjects( + refNode, wsExpression.AsStringC(), resoveNodeRS, dwStyle); + if (iRet < 1) { + return nullptr; + } + if (resoveNodeRS.dwFlags == XFA_RESOVENODE_RSTYPE_Nodes) { + CXFA_Node* pNode = resoveNodeRS.objects.front()->AsNode(); + if (pNode) + return static_cast(pNode->GetWidgetData()); + } + return nullptr; +} + +void CXFA_FFDocView::OnPageEvent(CXFA_ContainerLayoutItem* pSender, + uint32_t dwEvent) { + CXFA_FFPageView* pFFPageView = static_cast(pSender); + m_pDoc->GetDocEnvironment()->PageViewEvent(pFFPageView, dwEvent); +} + +void CXFA_FFDocView::LockUpdate() { + m_iLock++; +} +void CXFA_FFDocView::UnlockUpdate() { + m_iLock--; +} +bool CXFA_FFDocView::IsUpdateLocked() { + return m_iLock > 0; +} +void CXFA_FFDocView::ClearInvalidateList() { + m_mapPageInvalidate.clear(); +} +void CXFA_FFDocView::AddInvalidateRect(CXFA_FFWidget* pWidget, + const CFX_RectF& rtInvalidate) { + AddInvalidateRect(pWidget->GetPageView(), rtInvalidate); +} + +void CXFA_FFDocView::AddInvalidateRect(CXFA_FFPageView* pPageView, + const CFX_RectF& rtInvalidate) { + if (m_mapPageInvalidate[pPageView]) { + m_mapPageInvalidate[pPageView]->Union(rtInvalidate); + return; + } + m_mapPageInvalidate[pPageView] = pdfium::MakeUnique(rtInvalidate); +} + +void CXFA_FFDocView::RunInvalidate() { + for (const auto& pair : m_mapPageInvalidate) + m_pDoc->GetDocEnvironment()->InvalidateRect(pair.first, *pair.second); + m_mapPageInvalidate.clear(); +} + +bool CXFA_FFDocView::RunLayout() { + LockUpdate(); + m_bInLayoutStatus = true; + if (!m_pXFADocLayout->IncrementLayout() && + m_pXFADocLayout->StartLayout() < 100) { + m_pXFADocLayout->DoLayout(); + UnlockUpdate(); + m_bInLayoutStatus = false; + m_pDoc->GetDocEnvironment()->PageViewEvent(nullptr, + XFA_PAGEVIEWEVENT_StopLayout); + return true; + } + m_bInLayoutStatus = false; + m_pDoc->GetDocEnvironment()->PageViewEvent(nullptr, + XFA_PAGEVIEWEVENT_StopLayout); + UnlockUpdate(); + return false; +} + +void CXFA_FFDocView::RunSubformIndexChange() { + for (CXFA_Node* pSubformNode : m_IndexChangedSubforms) { + CXFA_WidgetAcc* pWidgetAcc = + static_cast(pSubformNode->GetWidgetData()); + if (!pWidgetAcc) + continue; + + CXFA_EventParam eParam; + eParam.m_eType = XFA_EVENT_IndexChange; + eParam.m_pTarget = pWidgetAcc; + pWidgetAcc->ProcessEvent(XFA_ATTRIBUTEENUM_IndexChange, &eParam); + } + m_IndexChangedSubforms.clear(); +} + +void CXFA_FFDocView::AddNewFormNode(CXFA_Node* pNode) { + m_NewAddedNodes.push_back(pNode); + InitLayout(pNode); +} + +void CXFA_FFDocView::AddIndexChangedSubform(CXFA_Node* pNode) { + ASSERT(pNode->GetElementType() == XFA_Element::Subform); + m_IndexChangedSubforms.push_back(pNode); +} + +void CXFA_FFDocView::RunDocClose() { + CXFA_Node* pRootItem = + ToNode(m_pDoc->GetXFADoc()->GetXFAObject(XFA_HASHCODE_Form)); + if (!pRootItem) { + return; + } + ExecEventActivityByDeepFirst(pRootItem, XFA_EVENT_DocClose, false, true, + nullptr); +} + +void CXFA_FFDocView::DestroyDocView() { + ClearInvalidateList(); + m_iStatus = XFA_DOCVIEW_LAYOUTSTATUS_None; + m_iLock = 0; + m_ValidateAccs.clear(); + m_BindItems.clear(); + m_CalculateAccs.clear(); +} + +bool CXFA_FFDocView::IsStaticNotify() { + return m_pDoc->GetDocType() == XFA_DocType::Static; +} + +void CXFA_FFDocView::AddCalculateWidgetAcc(CXFA_WidgetAcc* pWidgetAcc) { + CXFA_WidgetAcc* pCurrentAcc = + !m_CalculateAccs.empty() ? m_CalculateAccs.back() : nullptr; + if (pCurrentAcc != pWidgetAcc) + m_CalculateAccs.push_back(pWidgetAcc); +} + +void CXFA_FFDocView::AddCalculateNodeNotify(CXFA_Node* pNodeChange) { + auto* pGlobalData = + static_cast(pNodeChange->GetUserData(XFA_CalcData)); + if (!pGlobalData) + return; + + for (auto* pResultAcc : pGlobalData->m_Globals) { + if (!pResultAcc->GetNode()->HasRemovedChildren()) + AddCalculateWidgetAcc(pResultAcc); + } +} + +void CXFA_FFDocView::RunCalculateRecursive(int32_t& iIndex) { + while (iIndex < pdfium::CollectionSize(m_CalculateAccs)) { + CXFA_WidgetAcc* pCurAcc = m_CalculateAccs[iIndex]; + AddCalculateNodeNotify(pCurAcc->GetNode()); + int32_t iRefCount = + (int32_t)(uintptr_t)pCurAcc->GetNode()->GetUserData(XFA_CalcRefCount); + iRefCount++; + pCurAcc->GetNode()->SetUserData(XFA_CalcRefCount, + (void*)(uintptr_t)iRefCount); + if (iRefCount > 11) { + break; + } + if ((pCurAcc->ProcessCalculate()) == XFA_EVENTERROR_Success) { + AddValidateWidget(pCurAcc); + } + iIndex++; + RunCalculateRecursive(iIndex); + } +} + +int32_t CXFA_FFDocView::RunCalculateWidgets() { + if (!m_pDoc->GetDocEnvironment()->IsCalculationsEnabled(m_pDoc)) { + return XFA_EVENTERROR_Disabled; + } + int32_t iCounts = pdfium::CollectionSize(m_CalculateAccs); + int32_t iIndex = 0; + if (iCounts > 0) + RunCalculateRecursive(iIndex); + + for (CXFA_WidgetAcc* pCurAcc : m_CalculateAccs) + pCurAcc->GetNode()->SetUserData(XFA_CalcRefCount, (void*)(uintptr_t)0); + + m_CalculateAccs.clear(); + return XFA_EVENTERROR_Success; +} + +void CXFA_FFDocView::AddValidateWidget(CXFA_WidgetAcc* pWidget) { + if (!pdfium::ContainsValue(m_ValidateAccs, pWidget)) + m_ValidateAccs.push_back(pWidget); +} + +bool CXFA_FFDocView::InitCalculate(CXFA_Node* pNode) { + ExecEventActivityByDeepFirst(pNode, XFA_EVENT_InitCalculate, false, true, + nullptr); + return true; +} + +bool CXFA_FFDocView::InitValidate(CXFA_Node* pNode) { + if (!m_pDoc->GetDocEnvironment()->IsValidationsEnabled(m_pDoc)) + return false; + + ExecEventActivityByDeepFirst(pNode, XFA_EVENT_Validate, false, true, nullptr); + m_ValidateAccs.clear(); + return true; +} + +bool CXFA_FFDocView::RunValidate() { + if (!m_pDoc->GetDocEnvironment()->IsValidationsEnabled(m_pDoc)) + return false; + + for (CXFA_WidgetAcc* pAcc : m_ValidateAccs) { + if (!pAcc->GetNode()->HasRemovedChildren()) + pAcc->ProcessValidate(); + } + m_ValidateAccs.clear(); + return true; +} +bool CXFA_FFDocView::RunEventLayoutReady() { + CXFA_Node* pRootItem = + ToNode(m_pDoc->GetXFADoc()->GetXFAObject(XFA_HASHCODE_Form)); + if (!pRootItem) { + return false; + } + ExecEventActivityByDeepFirst(pRootItem, XFA_EVENT_Ready, false, true, + nullptr); + RunLayout(); + return true; +} + +void CXFA_FFDocView::RunBindItems() { + for (auto* item : m_BindItems) { + if (item->HasRemovedChildren()) + continue; + + CXFA_Node* pWidgetNode = item->GetNodeItem(XFA_NODEITEM_Parent); + CXFA_WidgetAcc* pAcc = + static_cast(pWidgetNode->GetWidgetData()); + if (!pAcc) + continue; + + CXFA_BindItems binditems(item); + CXFA_ScriptContext* pScriptContext = + pWidgetNode->GetDocument()->GetScriptContext(); + CFX_WideStringC wsRef; + binditems.GetRef(wsRef); + uint32_t dwStyle = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties | + XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_Parent | + XFA_RESOLVENODE_ALL; + XFA_RESOLVENODE_RS rs; + pScriptContext->ResolveObjects(pWidgetNode, wsRef, rs, dwStyle); + pAcc->DeleteItem(-1); + if (rs.dwFlags != XFA_RESOVENODE_RSTYPE_Nodes || rs.objects.empty()) + continue; + + CFX_WideStringC wsValueRef, wsLabelRef; + binditems.GetValueRef(wsValueRef); + binditems.GetLabelRef(wsLabelRef); + const bool bUseValue = wsLabelRef.IsEmpty() || wsLabelRef == wsValueRef; + const bool bLabelUseContent = wsLabelRef.IsEmpty() || wsLabelRef == L"$"; + const bool bValueUseContent = wsValueRef.IsEmpty() || wsValueRef == L"$"; + CFX_WideString wsValue; + CFX_WideString wsLabel; + uint32_t uValueHash = FX_HashCode_GetW(wsValueRef, false); + for (CXFA_Object* refObject : rs.objects) { + CXFA_Node* refNode = refObject->AsNode(); + if (!refNode) + continue; + if (bValueUseContent) { + wsValue = refNode->GetContent(); + } else { + CXFA_Node* nodeValue = refNode->GetFirstChildByName(uValueHash); + wsValue = nodeValue ? nodeValue->GetContent() : refNode->GetContent(); + } + if (!bUseValue) { + if (bLabelUseContent) { + wsLabel = refNode->GetContent(); + } else { + CXFA_Node* nodeLabel = refNode->GetFirstChildByName(wsLabelRef); + if (nodeLabel) + wsLabel = nodeLabel->GetContent(); + } + } else { + wsLabel = wsValue; + } + pAcc->InsertItem(wsLabel, wsValue); + } + } + m_BindItems.clear(); +} + +void CXFA_FFDocView::SetChangeMark() { + if (m_iStatus < XFA_DOCVIEW_LAYOUTSTATUS_End) { + return; + } + m_pDoc->GetDocEnvironment()->SetChangeMark(m_pDoc); +} +CXFA_Node* CXFA_FFDocView::GetRootSubform() { + CXFA_Node* pFormPacketNode = + ToNode(m_pDoc->GetXFADoc()->GetXFAObject(XFA_HASHCODE_Form)); + if (!pFormPacketNode) { + return nullptr; + } + return pFormPacketNode->GetFirstChildByClass(XFA_Element::Subform); +} diff --git a/xfa/fxfa/cxfa_ffdocview.h b/xfa/fxfa/cxfa_ffdocview.h new file mode 100644 index 0000000000..05ed9d7086 --- /dev/null +++ b/xfa/fxfa/cxfa_ffdocview.h @@ -0,0 +1,135 @@ +// 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_CXFA_FFDOCVIEW_H_ +#define XFA_FXFA_CXFA_FFDOCVIEW_H_ + +#include +#include +#include + +#include "xfa/fxfa/cxfa_eventparam.h" +#include "xfa/fxfa/cxfa_ffdoc.h" + +class CXFA_FFWidgetHandler; +class CXFA_FFDoc; +class CXFA_FFWidget; +class CXFA_WidgetAccIterator; + +extern const XFA_ATTRIBUTEENUM gs_EventActivity[]; +enum XFA_DOCVIEW_LAYOUTSTATUS { + XFA_DOCVIEW_LAYOUTSTATUS_None, + XFA_DOCVIEW_LAYOUTSTATUS_Start, + XFA_DOCVIEW_LAYOUTSTATUS_FormInitialize, + XFA_DOCVIEW_LAYOUTSTATUS_FormInitCalculate, + XFA_DOCVIEW_LAYOUTSTATUS_FormInitValidate, + XFA_DOCVIEW_LAYOUTSTATUS_FormFormReady, + XFA_DOCVIEW_LAYOUTSTATUS_Doing, + XFA_DOCVIEW_LAYOUTSTATUS_PagesetInitialize, + XFA_DOCVIEW_LAYOUTSTATUS_PagesetInitCalculate, + XFA_DOCVIEW_LAYOUTSTATUS_PagesetInitValidate, + XFA_DOCVIEW_LAYOUTSTATUS_PagesetFormReady, + XFA_DOCVIEW_LAYOUTSTATUS_LayoutReady, + XFA_DOCVIEW_LAYOUTSTATUS_DocReady, + XFA_DOCVIEW_LAYOUTSTATUS_End +}; + +class CXFA_FFDocView { + public: + explicit CXFA_FFDocView(CXFA_FFDoc* pDoc); + ~CXFA_FFDocView(); + + CXFA_FFDoc* GetDoc() { return m_pDoc; } + int32_t StartLayout(int32_t iStartPage = 0); + int32_t DoLayout(IFX_Pause* pPause); + void StopLayout(); + int32_t GetLayoutStatus(); + void UpdateDocView(); + int32_t CountPageViews(); + CXFA_FFPageView* GetPageView(int32_t nIndex); + + void ResetWidgetData(CXFA_WidgetAcc* pWidgetAcc); + int32_t ProcessWidgetEvent(CXFA_EventParam* pParam, + CXFA_WidgetAcc* pWidgetAcc); + CXFA_FFWidgetHandler* GetWidgetHandler(); + CXFA_WidgetAccIterator* CreateWidgetAccIterator( + XFA_WIDGETORDER eOrder = XFA_WIDGETORDER_PreOrder); + CXFA_FFWidget* GetFocusWidget(); + void KillFocus(); + bool SetFocus(CXFA_FFWidget* hWidget); + CXFA_FFWidget* GetWidgetByName(const CFX_WideString& wsName, + CXFA_FFWidget* pRefWidget); + CXFA_WidgetAcc* GetWidgetAccByName(const CFX_WideString& wsName, + CXFA_WidgetAcc* pRefWidgetAcc); + CXFA_LayoutProcessor* GetXFALayout() const; + void OnPageEvent(CXFA_ContainerLayoutItem* pSender, uint32_t dwEvent); + void LockUpdate(); + void UnlockUpdate(); + bool IsUpdateLocked(); + void ClearInvalidateList(); + void AddInvalidateRect(CXFA_FFWidget* pWidget, const CFX_RectF& rtInvalidate); + void AddInvalidateRect(CXFA_FFPageView* pPageView, + const CFX_RectF& rtInvalidate); + void RunInvalidate(); + void RunDocClose(); + void DestroyDocView(); + + bool InitValidate(CXFA_Node* pNode); + bool RunValidate(); + + void SetChangeMark(); + + void AddValidateWidget(CXFA_WidgetAcc* pWidget); + void AddCalculateNodeNotify(CXFA_Node* pNodeChange); + void AddCalculateWidgetAcc(CXFA_WidgetAcc* pWidgetAcc); + int32_t RunCalculateWidgets(); + bool IsStaticNotify(); + bool RunLayout(); + void RunSubformIndexChange(); + void AddNewFormNode(CXFA_Node* pNode); + void AddIndexChangedSubform(CXFA_Node* pNode); + CXFA_WidgetAcc* GetFocusWidgetAcc(); + void SetFocusWidgetAcc(CXFA_WidgetAcc* pWidgetAcc); + void DeleteLayoutItem(CXFA_FFWidget* pWidget); + int32_t ExecEventActivityByDeepFirst(CXFA_Node* pFormNode, + XFA_EVENTTYPE eEventType, + bool bIsFormReady, + bool bRecursive, + CXFA_Node* pExclude); + bool m_bLayoutEvent; + std::vector m_arrNullTestMsg; + CXFA_FFWidget* m_pListFocusWidget; + bool m_bInLayoutStatus; + + private: + friend class CXFA_FFNotify; + + bool RunEventLayoutReady(); + void RunBindItems(); + bool InitCalculate(CXFA_Node* pNode); + void InitLayout(CXFA_Node* pNode); + void RunCalculateRecursive(int32_t& iIndex); + void ShowNullTestMsg(); + bool ResetSingleWidgetAccData(CXFA_WidgetAcc* pWidgetAcc); + CXFA_Node* GetRootSubform(); + + CXFA_FFDoc* const m_pDoc; + std::unique_ptr m_pWidgetHandler; + CXFA_LayoutProcessor* m_pXFADocLayout; // not owned. + CXFA_WidgetAcc* m_pFocusAcc; // not owned. + CXFA_FFWidget* m_pFocusWidget; // not owned. + CXFA_FFWidget* m_pOldFocusWidget; // not owned. + std::map> m_mapPageInvalidate; + std::vector m_ValidateAccs; + std::vector m_CalculateAccs; + std::vector m_BindItems; + std::vector m_NewAddedNodes; + std::vector m_IndexChangedSubforms; + XFA_DOCVIEW_LAYOUTSTATUS m_iStatus; + int32_t m_iLock; +}; + +#endif // XFA_FXFA_CXFA_FFDOCVIEW_H_ diff --git a/xfa/fxfa/cxfa_ffpageview.cpp b/xfa/fxfa/cxfa_ffpageview.cpp new file mode 100644 index 0000000000..3eda5a1d4a --- /dev/null +++ b/xfa/fxfa/cxfa_ffpageview.cpp @@ -0,0 +1,459 @@ +// 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 + +#include "xfa/fxfa/cxfa_ffpageview.h" + +#include +#include + +#include "third_party/base/ptr_util.h" +#include "third_party/base/stl_util.h" +#include "xfa/fde/fde_render.h" +#include "xfa/fxfa/app/xfa_ffcheckbutton.h" +#include "xfa/fxfa/app/xfa_ffchoicelist.h" +#include "xfa/fxfa/app/xfa_fffield.h" +#include "xfa/fxfa/app/xfa_ffimageedit.h" +#include "xfa/fxfa/app/xfa_ffpushbutton.h" +#include "xfa/fxfa/app/xfa_fftextedit.h" +#include "xfa/fxfa/app/xfa_fwladapter.h" +#include "xfa/fxfa/cxfa_ffdoc.h" +#include "xfa/fxfa/cxfa_ffdocview.h" +#include "xfa/fxfa/cxfa_ffwidget.h" + +namespace { + +CFX_Matrix GetPageMatrix(const CFX_RectF& docPageRect, + const CFX_Rect& devicePageRect, + int32_t iRotate, + uint32_t dwCoordinatesType) { + ASSERT(iRotate >= 0 && iRotate <= 3); + + bool bFlipX = (dwCoordinatesType & 0x01) != 0; + bool bFlipY = (dwCoordinatesType & 0x02) != 0; + CFX_Matrix m((bFlipX ? -1.0f : 1.0f), 0, 0, (bFlipY ? -1.0f : 1.0f), 0, 0); + if (iRotate == 0 || iRotate == 2) { + m.a *= (float)devicePageRect.width / docPageRect.width; + m.d *= (float)devicePageRect.height / docPageRect.height; + } else { + m.a *= (float)devicePageRect.height / docPageRect.width; + m.d *= (float)devicePageRect.width / docPageRect.height; + } + m.Rotate(iRotate * 1.57079632675f); + switch (iRotate) { + case 0: + m.e = bFlipX ? (float)devicePageRect.right() : (float)devicePageRect.left; + m.f = bFlipY ? (float)devicePageRect.bottom() : (float)devicePageRect.top; + break; + case 1: + m.e = bFlipY ? (float)devicePageRect.left : (float)devicePageRect.right(); + m.f = bFlipX ? (float)devicePageRect.bottom() : (float)devicePageRect.top; + break; + case 2: + m.e = bFlipX ? (float)devicePageRect.left : (float)devicePageRect.right(); + m.f = bFlipY ? (float)devicePageRect.top : (float)devicePageRect.bottom(); + break; + case 3: + m.e = bFlipY ? (float)devicePageRect.right() : (float)devicePageRect.left; + m.f = bFlipX ? (float)devicePageRect.top : (float)devicePageRect.bottom(); + break; + default: + break; + } + return m; +} + +bool PageWidgetFilter(CXFA_FFWidget* pWidget, + uint32_t dwFilter, + bool bTraversal, + bool bIgnorerelevant) { + CXFA_WidgetAcc* pWidgetAcc = pWidget->GetDataAcc(); + + if (!!(dwFilter & XFA_WidgetStatus_Focused) && + pWidgetAcc->GetElementType() != XFA_Element::Field) { + return false; + } + + uint32_t dwStatus = pWidget->GetStatus(); + if (bTraversal && (dwStatus & XFA_WidgetStatus_Disabled)) + return false; + if (bIgnorerelevant) + return !!(dwStatus & XFA_WidgetStatus_Visible); + + dwFilter &= (XFA_WidgetStatus_Visible | XFA_WidgetStatus_Viewable | + XFA_WidgetStatus_Printable); + return (dwFilter & dwStatus) == dwFilter; +} + +bool IsLayoutElement(XFA_Element eElement, bool bLayoutContainer) { + switch (eElement) { + case XFA_Element::Draw: + case XFA_Element::Field: + case XFA_Element::InstanceManager: + return !bLayoutContainer; + case XFA_Element::Area: + case XFA_Element::Subform: + case XFA_Element::ExclGroup: + case XFA_Element::SubformSet: + case XFA_Element::PageArea: + case XFA_Element::Form: + return true; + default: + return false; + } +} + +} // namespace + +CXFA_FFPageView::CXFA_FFPageView(CXFA_FFDocView* pDocView, CXFA_Node* pPageArea) + : CXFA_ContainerLayoutItem(pPageArea), m_pDocView(pDocView) {} + +CXFA_FFPageView::~CXFA_FFPageView() {} + +CXFA_FFDocView* CXFA_FFPageView::GetDocView() const { + return m_pDocView; +} + +CFX_RectF CXFA_FFPageView::GetPageViewRect() const { + return CFX_RectF(0, 0, GetPageSize()); +} + +CFX_Matrix CXFA_FFPageView::GetDisplayMatrix(const CFX_Rect& rtDisp, + int32_t iRotate) const { + return GetPageMatrix(CFX_RectF(0, 0, GetPageSize()), rtDisp, iRotate, 0); +} + +IXFA_WidgetIterator* CXFA_FFPageView::CreateWidgetIterator( + uint32_t dwTraverseWay, + uint32_t dwWidgetFilter) { + switch (dwTraverseWay) { + case XFA_TRAVERSEWAY_Tranvalse: + return new CXFA_FFTabOrderPageWidgetIterator(this, dwWidgetFilter); + case XFA_TRAVERSEWAY_Form: + return new CXFA_FFPageWidgetIterator(this, dwWidgetFilter); + } + return nullptr; +} + +CXFA_FFPageWidgetIterator::CXFA_FFPageWidgetIterator(CXFA_FFPageView* pPageView, + uint32_t dwFilter) + : m_pPageView(pPageView), m_dwFilter(dwFilter), m_sIterator(pPageView) { + m_bIgnorerelevant = + m_pPageView->GetDocView()->GetDoc()->GetXFADoc()->GetCurVersionMode() < + XFA_VERSION_205; +} + +CXFA_FFPageWidgetIterator::~CXFA_FFPageWidgetIterator() {} + +void CXFA_FFPageWidgetIterator::Reset() { + m_sIterator.Reset(); +} +CXFA_FFWidget* CXFA_FFPageWidgetIterator::MoveToFirst() { + m_sIterator.Reset(); + for (CXFA_LayoutItem* pLayoutItem = m_sIterator.GetCurrent(); pLayoutItem; + pLayoutItem = m_sIterator.MoveToNext()) { + if (CXFA_FFWidget* hWidget = GetWidget(pLayoutItem)) { + return hWidget; + } + } + return nullptr; +} +CXFA_FFWidget* CXFA_FFPageWidgetIterator::MoveToLast() { + m_sIterator.SetCurrent(nullptr); + return MoveToPrevious(); +} +CXFA_FFWidget* CXFA_FFPageWidgetIterator::MoveToNext() { + for (CXFA_LayoutItem* pLayoutItem = m_sIterator.MoveToNext(); pLayoutItem; + pLayoutItem = m_sIterator.MoveToNext()) { + if (CXFA_FFWidget* hWidget = GetWidget(pLayoutItem)) { + return hWidget; + } + } + return nullptr; +} +CXFA_FFWidget* CXFA_FFPageWidgetIterator::MoveToPrevious() { + for (CXFA_LayoutItem* pLayoutItem = m_sIterator.MoveToPrev(); pLayoutItem; + pLayoutItem = m_sIterator.MoveToPrev()) { + if (CXFA_FFWidget* hWidget = GetWidget(pLayoutItem)) { + return hWidget; + } + } + return nullptr; +} +CXFA_FFWidget* CXFA_FFPageWidgetIterator::GetCurrentWidget() { + CXFA_LayoutItem* pLayoutItem = m_sIterator.GetCurrent(); + return pLayoutItem ? XFA_GetWidgetFromLayoutItem(pLayoutItem) : nullptr; +} +bool CXFA_FFPageWidgetIterator::SetCurrentWidget(CXFA_FFWidget* hWidget) { + return hWidget && m_sIterator.SetCurrent(hWidget); +} +CXFA_FFWidget* CXFA_FFPageWidgetIterator::GetWidget( + CXFA_LayoutItem* pLayoutItem) { + if (CXFA_FFWidget* pWidget = XFA_GetWidgetFromLayoutItem(pLayoutItem)) { + if (!PageWidgetFilter(pWidget, m_dwFilter, false, m_bIgnorerelevant)) { + return nullptr; + } + if (!pWidget->IsLoaded() && + (pWidget->GetStatus() & XFA_WidgetStatus_Visible) != 0) { + pWidget->LoadWidget(); + } + return pWidget; + } + return nullptr; +} + +CXFA_FFTabOrderPageWidgetIterator::CXFA_FFTabOrderPageWidgetIterator( + CXFA_FFPageView* pPageView, + uint32_t dwFilter) + : m_pPageView(pPageView), m_dwFilter(dwFilter), m_iCurWidget(-1) { + m_bIgnorerelevant = + m_pPageView->GetDocView()->GetDoc()->GetXFADoc()->GetCurVersionMode() < + XFA_VERSION_205; + Reset(); +} + +CXFA_FFTabOrderPageWidgetIterator::~CXFA_FFTabOrderPageWidgetIterator() {} + +void CXFA_FFTabOrderPageWidgetIterator::Reset() { + CreateTabOrderWidgetArray(); + m_iCurWidget = -1; +} + +CXFA_FFWidget* CXFA_FFTabOrderPageWidgetIterator::MoveToFirst() { + for (int32_t i = 0; + i < pdfium::CollectionSize(m_TabOrderWidgetArray); i++) { + if (PageWidgetFilter(m_TabOrderWidgetArray[i], m_dwFilter, true, + m_bIgnorerelevant)) { + m_iCurWidget = i; + return m_TabOrderWidgetArray[m_iCurWidget]; + } + } + return nullptr; +} + +CXFA_FFWidget* CXFA_FFTabOrderPageWidgetIterator::MoveToLast() { + for (int32_t i = pdfium::CollectionSize(m_TabOrderWidgetArray) - 1; + i >= 0; i--) { + if (PageWidgetFilter(m_TabOrderWidgetArray[i], m_dwFilter, true, + m_bIgnorerelevant)) { + m_iCurWidget = i; + return m_TabOrderWidgetArray[m_iCurWidget]; + } + } + return nullptr; +} + +CXFA_FFWidget* CXFA_FFTabOrderPageWidgetIterator::MoveToNext() { + for (int32_t i = m_iCurWidget + 1; + i < pdfium::CollectionSize(m_TabOrderWidgetArray); i++) { + if (PageWidgetFilter(m_TabOrderWidgetArray[i], m_dwFilter, true, + m_bIgnorerelevant)) { + m_iCurWidget = i; + return m_TabOrderWidgetArray[m_iCurWidget]; + } + } + m_iCurWidget = -1; + return nullptr; +} + +CXFA_FFWidget* CXFA_FFTabOrderPageWidgetIterator::MoveToPrevious() { + for (int32_t i = m_iCurWidget - 1; i >= 0; i--) { + if (PageWidgetFilter(m_TabOrderWidgetArray[i], m_dwFilter, true, + m_bIgnorerelevant)) { + m_iCurWidget = i; + return m_TabOrderWidgetArray[m_iCurWidget]; + } + } + m_iCurWidget = -1; + return nullptr; +} + +CXFA_FFWidget* CXFA_FFTabOrderPageWidgetIterator::GetCurrentWidget() { + return m_iCurWidget >= 0 ? m_TabOrderWidgetArray[m_iCurWidget] : nullptr; +} + +bool CXFA_FFTabOrderPageWidgetIterator::SetCurrentWidget( + CXFA_FFWidget* hWidget) { + auto it = std::find(m_TabOrderWidgetArray.begin(), + m_TabOrderWidgetArray.end(), hWidget); + if (it == m_TabOrderWidgetArray.end()) + return false; + + m_iCurWidget = it - m_TabOrderWidgetArray.begin(); + return true; +} + +CXFA_FFWidget* CXFA_FFTabOrderPageWidgetIterator::GetTraverseWidget( + CXFA_FFWidget* pWidget) { + CXFA_WidgetAcc* pAcc = pWidget->GetDataAcc(); + CXFA_Node* pTraversal = pAcc->GetNode()->GetChild(0, XFA_Element::Traversal); + if (pTraversal) { + CXFA_Node* pTraverse = pTraversal->GetChild(0, XFA_Element::Traverse); + if (pTraverse) { + CFX_WideString wsTraverseWidgetName; + if (pTraverse->GetAttribute(XFA_ATTRIBUTE_Ref, wsTraverseWidgetName)) { + return FindWidgetByName(wsTraverseWidgetName, pWidget); + } + } + } + return nullptr; +} +CXFA_FFWidget* CXFA_FFTabOrderPageWidgetIterator::FindWidgetByName( + const CFX_WideString& wsWidgetName, + CXFA_FFWidget* pRefWidget) { + return pRefWidget->GetDocView()->GetWidgetByName(wsWidgetName, pRefWidget); +} + +void CXFA_FFTabOrderPageWidgetIterator::CreateTabOrderWidgetArray() { + m_TabOrderWidgetArray.clear(); + + std::vector SpaceOrderWidgetArray; + CreateSpaceOrderWidgetArray(&SpaceOrderWidgetArray); + if (SpaceOrderWidgetArray.empty()) + return; + + int32_t nWidgetCount = pdfium::CollectionSize(SpaceOrderWidgetArray); + CXFA_FFWidget* hWidget = SpaceOrderWidgetArray[0]; + while (pdfium::CollectionSize(m_TabOrderWidgetArray) < + nWidgetCount) { + if (!pdfium::ContainsValue(m_TabOrderWidgetArray, hWidget)) { + m_TabOrderWidgetArray.push_back(hWidget); + CXFA_WidgetAcc* pWidgetAcc = hWidget->GetDataAcc(); + if (pWidgetAcc->GetUIType() == XFA_Element::ExclGroup) { + auto it = std::find(SpaceOrderWidgetArray.begin(), + SpaceOrderWidgetArray.end(), hWidget); + int32_t iWidgetIndex = it != SpaceOrderWidgetArray.end() + ? it - SpaceOrderWidgetArray.begin() + 1 + : 0; + while (true) { + CXFA_FFWidget* pRadio = + SpaceOrderWidgetArray[iWidgetIndex % nWidgetCount]; + if (pRadio->GetDataAcc()->GetExclGroup() != pWidgetAcc) { + break; + } + if (!pdfium::ContainsValue(m_TabOrderWidgetArray, hWidget)) { + m_TabOrderWidgetArray.push_back(pRadio); + } + iWidgetIndex++; + } + } + if (CXFA_FFWidget* hTraverseWidget = GetTraverseWidget(hWidget)) { + hWidget = hTraverseWidget; + continue; + } + } + auto it = std::find(SpaceOrderWidgetArray.begin(), + SpaceOrderWidgetArray.end(), hWidget); + int32_t iWidgetIndex = it != SpaceOrderWidgetArray.end() + ? it - SpaceOrderWidgetArray.begin() + 1 + : 0; + hWidget = SpaceOrderWidgetArray[iWidgetIndex % nWidgetCount]; + } +} + +static int32_t XFA_TabOrderWidgetComparator(const void* phWidget1, + const void* phWidget2) { + auto* param1 = *static_cast(const_cast(phWidget1)); + auto* param2 = *static_cast(const_cast(phWidget2)); + CFX_RectF rt1 = param1->m_pWidget->GetWidgetRect(); + CFX_RectF rt2 = param2->m_pWidget->GetWidgetRect(); + float x1 = rt1.left, y1 = rt1.top, x2 = rt2.left, y2 = rt2.top; + if (y1 < y2 || (y1 - y2 < XFA_FLOAT_PERCISION && x1 < x2)) + return -1; + return 1; +} + +void CXFA_FFTabOrderPageWidgetIterator::OrderContainer( + CXFA_LayoutItemIterator* sIterator, + CXFA_LayoutItem* pContainerItem, + CXFA_TabParam* pContainer, + bool& bCurrentItem, + bool& bContentArea, + bool bMarsterPage) { + CFX_ArrayTemplate tabParams; + CXFA_LayoutItem* pSearchItem = sIterator->MoveToNext(); + while (pSearchItem) { + if (!pSearchItem->IsContentLayoutItem()) { + bContentArea = true; + pSearchItem = sIterator->MoveToNext(); + continue; + } + if (bMarsterPage && bContentArea) { + break; + } + if (bMarsterPage || bContentArea) { + CXFA_FFWidget* hWidget = GetWidget(pSearchItem); + if (!hWidget) { + pSearchItem = sIterator->MoveToNext(); + continue; + } + if (pContainerItem && (pSearchItem->GetParent() != pContainerItem)) { + bCurrentItem = true; + break; + } + CXFA_TabParam* pParam = new CXFA_TabParam; + pParam->m_pWidget = hWidget; + tabParams.Add(pParam); + if (IsLayoutElement(pSearchItem->GetFormNode()->GetElementType(), true)) { + OrderContainer(sIterator, pSearchItem, pParam, bCurrentItem, + bContentArea, bMarsterPage); + } + } + if (bCurrentItem) { + pSearchItem = sIterator->GetCurrent(); + bCurrentItem = false; + } else { + pSearchItem = sIterator->MoveToNext(); + } + } + int32_t iChildren = tabParams.GetSize(); + if (iChildren > 1) { + FXSYS_qsort(tabParams.GetData(), iChildren, sizeof(void*), + XFA_TabOrderWidgetComparator); + } + for (int32_t iStart = 0; iStart < iChildren; iStart++) { + std::unique_ptr pParam(tabParams[iStart]); + pContainer->m_Children.push_back(pParam->m_pWidget); + pContainer->m_Children.insert(pContainer->m_Children.end(), + pParam->m_Children.begin(), + pParam->m_Children.end()); + } + tabParams.RemoveAll(); +} +void CXFA_FFTabOrderPageWidgetIterator::CreateSpaceOrderWidgetArray( + std::vector* WidgetArray) { + CXFA_LayoutItemIterator sIterator(m_pPageView); + auto pParam = pdfium::MakeUnique(); + bool bCurrentItem = false; + bool bContentArea = false; + OrderContainer(&sIterator, nullptr, pParam.get(), bCurrentItem, bContentArea); + WidgetArray->insert(WidgetArray->end(), pParam->m_Children.begin(), + pParam->m_Children.end()); + + sIterator.Reset(); + bCurrentItem = false; + bContentArea = false; + pParam->m_Children.clear(); + OrderContainer(&sIterator, nullptr, pParam.get(), bCurrentItem, bContentArea, + true); + WidgetArray->insert(WidgetArray->end(), pParam->m_Children.begin(), + pParam->m_Children.end()); +} + +CXFA_FFWidget* CXFA_FFTabOrderPageWidgetIterator::GetWidget( + CXFA_LayoutItem* pLayoutItem) { + if (CXFA_FFWidget* pWidget = XFA_GetWidgetFromLayoutItem(pLayoutItem)) { + if (!pWidget->IsLoaded() && + (pWidget->GetStatus() & XFA_WidgetStatus_Visible)) { + pWidget->LoadWidget(); + } + return pWidget; + } + return nullptr; +} + +CXFA_TabParam::CXFA_TabParam() : m_pWidget(nullptr) {} + +CXFA_TabParam::~CXFA_TabParam() {} diff --git a/xfa/fxfa/cxfa_ffpageview.h b/xfa/fxfa/cxfa_ffpageview.h new file mode 100644 index 0000000000..ee1b4e37df --- /dev/null +++ b/xfa/fxfa/cxfa_ffpageview.h @@ -0,0 +1,107 @@ +// Copyrig 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_CXFA_FFPAGEVIEW_H_ +#define XFA_FXFA_CXFA_FFPAGEVIEW_H_ + +#include + +#include "xfa/fxfa/parser/cxfa_containerlayoutitem.h" +#include "xfa/fxfa/parser/cxfa_contentlayoutitem.h" +#include "xfa/fxfa/parser/cxfa_traversestrategy_layoutitem.h" + +class CXFA_FFWidget; +class CXFA_FFDocView; + +class CXFA_FFPageView : public CXFA_ContainerLayoutItem { + public: + CXFA_FFPageView(CXFA_FFDocView* pDocView, CXFA_Node* pPageArea); + ~CXFA_FFPageView() override; + + CXFA_FFDocView* GetDocView() const; + CFX_RectF GetPageViewRect() const; + CFX_Matrix GetDisplayMatrix(const CFX_Rect& rtDisp, int32_t iRotate) const; + IXFA_WidgetIterator* CreateWidgetIterator( + uint32_t dwTraverseWay = XFA_TRAVERSEWAY_Form, + uint32_t dwWidgetFilter = XFA_WidgetStatus_Visible | + XFA_WidgetStatus_Viewable); + + protected: + CXFA_FFDocView* const m_pDocView; +}; + +typedef CXFA_NodeIteratorTemplate + CXFA_LayoutItemIterator; + +class CXFA_FFPageWidgetIterator : public IXFA_WidgetIterator { + public: + CXFA_FFPageWidgetIterator(CXFA_FFPageView* pPageView, uint32_t dwFilter); + ~CXFA_FFPageWidgetIterator() override; + + void Reset() override; + CXFA_FFWidget* MoveToFirst() override; + CXFA_FFWidget* MoveToLast() override; + CXFA_FFWidget* MoveToNext() override; + CXFA_FFWidget* MoveToPrevious() override; + CXFA_FFWidget* GetCurrentWidget() override; + bool SetCurrentWidget(CXFA_FFWidget* hWidget) override; + + protected: + CXFA_FFWidget* GetWidget(CXFA_LayoutItem* pLayoutItem); + + CXFA_FFPageView* m_pPageView; + CXFA_FFWidget* m_hCurWidget; + uint32_t m_dwFilter; + bool m_bIgnorerelevant; + CXFA_LayoutItemIterator m_sIterator; +}; + +class CXFA_TabParam { + public: + CXFA_TabParam(); + ~CXFA_TabParam(); + + CXFA_FFWidget* m_pWidget; + std::vector m_Children; +}; + +class CXFA_FFTabOrderPageWidgetIterator : public IXFA_WidgetIterator { + public: + CXFA_FFTabOrderPageWidgetIterator(CXFA_FFPageView* pPageView, + uint32_t dwFilter); + ~CXFA_FFTabOrderPageWidgetIterator() override; + + void Reset() override; + CXFA_FFWidget* MoveToFirst() override; + CXFA_FFWidget* MoveToLast() override; + CXFA_FFWidget* MoveToNext() override; + CXFA_FFWidget* MoveToPrevious() override; + CXFA_FFWidget* GetCurrentWidget() override; + bool SetCurrentWidget(CXFA_FFWidget* hWidget) override; + + protected: + CXFA_FFWidget* GetTraverseWidget(CXFA_FFWidget* pWidget); + CXFA_FFWidget* FindWidgetByName(const CFX_WideString& wsWidgetName, + CXFA_FFWidget* pRefWidget); + void CreateTabOrderWidgetArray(); + void CreateSpaceOrderWidgetArray(std::vector* WidgetArray); + CXFA_FFWidget* GetWidget(CXFA_LayoutItem* pLayoutItem); + void OrderContainer(CXFA_LayoutItemIterator* sIterator, + CXFA_LayoutItem* pContainerItem, + CXFA_TabParam* pContainer, + bool& bCurrentItem, + bool& bContentArea, + bool bMarsterPage = false); + + std::vector m_TabOrderWidgetArray; + CXFA_FFPageView* m_pPageView; + uint32_t m_dwFilter; + int32_t m_iCurWidget; + bool m_bIgnorerelevant; +}; + +#endif // XFA_FXFA_CXFA_FFPAGEVIEW_H_ diff --git a/xfa/fxfa/cxfa_ffwidget.cpp b/xfa/fxfa/cxfa_ffwidget.cpp new file mode 100644 index 0000000000..504ce70ad9 --- /dev/null +++ b/xfa/fxfa/cxfa_ffwidget.cpp @@ -0,0 +1,2048 @@ +// 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 + +#include "xfa/fxfa/cxfa_ffwidget.h" + +#include +#include +#include + +#include "core/fpdfapi/page/cpdf_pageobjectholder.h" +#include "core/fxcodec/codec/ccodec_progressivedecoder.h" +#include "core/fxcodec/fx_codec.h" +#include "core/fxcrt/cfx_maybe_owned.h" +#include "core/fxge/cfx_gemodule.h" +#include "core/fxge/cfx_pathdata.h" +#include "core/fxge/cfx_renderdevice.h" +#include "xfa/fwl/fwl_widgethit.h" +#include "xfa/fxfa/app/cxfa_textlayout.h" +#include "xfa/fxfa/cxfa_eventparam.h" +#include "xfa/fxfa/cxfa_ffapp.h" +#include "xfa/fxfa/cxfa_ffdoc.h" +#include "xfa/fxfa/cxfa_ffdocview.h" +#include "xfa/fxfa/cxfa_ffpageview.h" +#include "xfa/fxfa/cxfa_widgetacc.h" +#include "xfa/fxfa/parser/cxfa_corner.h" +#include "xfa/fxgraphics/cfx_color.h" +#include "xfa/fxgraphics/cfx_graphics.h" +#include "xfa/fxgraphics/cfx_path.h" +#include "xfa/fxgraphics/cfx_pattern.h" +#include "xfa/fxgraphics/cfx_shading.h" + +CXFA_FFWidget::CXFA_FFWidget(CXFA_WidgetAcc* pDataAcc) + : CXFA_ContentLayoutItem(pDataAcc->GetNode()), + m_pPageView(nullptr), + m_pDataAcc(pDataAcc) {} + +CXFA_FFWidget::~CXFA_FFWidget() {} + +const CFWL_App* CXFA_FFWidget::GetFWLApp() { + return GetPageView()->GetDocView()->GetDoc()->GetApp()->GetFWLApp(); +} + +CFX_RectF CXFA_FFWidget::GetWidgetRect() { + if ((m_dwStatus & XFA_WidgetStatus_RectCached) == 0) + RecacheWidgetRect(); + return m_rtWidget; +} + +CFX_RectF CXFA_FFWidget::RecacheWidgetRect() { + m_dwStatus |= XFA_WidgetStatus_RectCached; + m_rtWidget = GetRect(false); + return m_rtWidget; +} + +CFX_RectF CXFA_FFWidget::GetRectWithoutRotate() { + CFX_RectF rtWidget = GetWidgetRect(); + float fValue = 0; + switch (m_pDataAcc->GetRotate()) { + case 90: + rtWidget.top = rtWidget.bottom(); + fValue = rtWidget.width; + rtWidget.width = rtWidget.height; + rtWidget.height = fValue; + break; + case 180: + rtWidget.left = rtWidget.right(); + rtWidget.top = rtWidget.bottom(); + break; + case 270: + rtWidget.left = rtWidget.right(); + fValue = rtWidget.width; + rtWidget.width = rtWidget.height; + rtWidget.height = fValue; + break; + } + return rtWidget; +} + +uint32_t CXFA_FFWidget::GetStatus() { + return m_dwStatus; +} + +void CXFA_FFWidget::ModifyStatus(uint32_t dwAdded, uint32_t dwRemoved) { + m_dwStatus = (m_dwStatus & ~dwRemoved) | dwAdded; +} + +CFX_RectF CXFA_FFWidget::GetBBox(uint32_t dwStatus, bool bDrawFocus) { + if (bDrawFocus || !m_pPageView) + return CFX_RectF(); + return m_pPageView->GetPageViewRect(); +} + +CXFA_WidgetAcc* CXFA_FFWidget::GetDataAcc() { + return m_pDataAcc; +} + +bool CXFA_FFWidget::GetToolTip(CFX_WideString& wsToolTip) { + if (CXFA_Assist assist = m_pDataAcc->GetAssist()) { + if (CXFA_ToolTip toolTip = assist.GetToolTip()) { + return toolTip.GetTip(wsToolTip); + } + } + return GetCaptionText(wsToolTip); +} + +void CXFA_FFWidget::RenderWidget(CFX_Graphics* pGS, + CFX_Matrix* pMatrix, + uint32_t dwStatus) { + if (!IsMatchVisibleStatus(dwStatus)) + return; + + CXFA_Border border = m_pDataAcc->GetBorder(); + if (!border) + return; + + CFX_RectF rtBorder = GetRectWithoutRotate(); + CXFA_Margin margin = border.GetMargin(); + if (margin) + XFA_RectWidthoutMargin(rtBorder, margin); + + rtBorder.Normalize(); + DrawBorder(pGS, border, rtBorder, pMatrix); +} + +bool CXFA_FFWidget::IsLoaded() { + return !!m_pPageView; +} +bool CXFA_FFWidget::LoadWidget() { + PerformLayout(); + return true; +} +void CXFA_FFWidget::UnloadWidget() {} +bool CXFA_FFWidget::PerformLayout() { + RecacheWidgetRect(); + return true; +} +bool CXFA_FFWidget::UpdateFWLData() { + return false; +} +void CXFA_FFWidget::UpdateWidgetProperty() {} +void CXFA_FFWidget::DrawBorder(CFX_Graphics* pGS, + CXFA_Box box, + const CFX_RectF& rtBorder, + CFX_Matrix* pMatrix, + uint32_t dwFlags) { + XFA_DrawBox(box, pGS, rtBorder, pMatrix, dwFlags); +} + +void CXFA_FFWidget::InvalidateWidget(const CFX_RectF* pRect) { + if (pRect) { + GetDoc()->GetDocEnvironment()->InvalidateRect(m_pPageView, *pRect); + return; + } + + CFX_RectF rtWidget = GetBBox(XFA_WidgetStatus_Focused); + rtWidget.Inflate(2, 2); + GetDoc()->GetDocEnvironment()->InvalidateRect(m_pPageView, rtWidget); +} + +void CXFA_FFWidget::AddInvalidateRect(const CFX_RectF* pRect) { + CFX_RectF rtWidget; + if (pRect) { + rtWidget = *pRect; + } else { + rtWidget = GetBBox(XFA_WidgetStatus_Focused); + rtWidget.Inflate(2, 2); + } + m_pDocView->AddInvalidateRect(m_pPageView, rtWidget); +} + +bool CXFA_FFWidget::GetCaptionText(CFX_WideString& wsCap) { + CXFA_TextLayout* pCapTextlayout = m_pDataAcc->GetCaptionTextLayout(); + if (!pCapTextlayout) { + return false; + } + pCapTextlayout->GetText(wsCap); + return true; +} + +bool CXFA_FFWidget::IsFocused() { + return !!(m_dwStatus & XFA_WidgetStatus_Focused); +} + +bool CXFA_FFWidget::OnMouseEnter() { + return false; +} + +bool CXFA_FFWidget::OnMouseExit() { + return false; +} + +bool CXFA_FFWidget::OnLButtonDown(uint32_t dwFlags, const CFX_PointF& point) { + return false; +} + +bool CXFA_FFWidget::OnLButtonUp(uint32_t dwFlags, const CFX_PointF& point) { + return false; +} + +bool CXFA_FFWidget::OnLButtonDblClk(uint32_t dwFlags, const CFX_PointF& point) { + return false; +} + +bool CXFA_FFWidget::OnMouseMove(uint32_t dwFlags, const CFX_PointF& point) { + return false; +} + +bool CXFA_FFWidget::OnMouseWheel(uint32_t dwFlags, + int16_t zDelta, + const CFX_PointF& point) { + return false; +} + +bool CXFA_FFWidget::OnRButtonDown(uint32_t dwFlags, const CFX_PointF& point) { + return false; +} + +bool CXFA_FFWidget::OnRButtonUp(uint32_t dwFlags, const CFX_PointF& point) { + return false; +} + +bool CXFA_FFWidget::OnRButtonDblClk(uint32_t dwFlags, const CFX_PointF& point) { + return false; +} + +bool CXFA_FFWidget::OnSetFocus(CXFA_FFWidget* pOldWidget) { + CXFA_FFWidget* pParent = GetParent(); + if (pParent && !pParent->IsAncestorOf(pOldWidget)) { + pParent->OnSetFocus(pOldWidget); + } + m_dwStatus |= XFA_WidgetStatus_Focused; + CXFA_EventParam eParam; + eParam.m_eType = XFA_EVENT_Enter; + eParam.m_pTarget = m_pDataAcc; + m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Enter, &eParam); + return true; +} + +bool CXFA_FFWidget::OnKillFocus(CXFA_FFWidget* pNewWidget) { + m_dwStatus &= ~XFA_WidgetStatus_Focused; + EventKillFocus(); + if (pNewWidget) { + CXFA_FFWidget* pParent = GetParent(); + if (pParent && !pParent->IsAncestorOf(pNewWidget)) { + pParent->OnKillFocus(pNewWidget); + } + } + return true; +} + +bool CXFA_FFWidget::OnKeyDown(uint32_t dwKeyCode, uint32_t dwFlags) { + return false; +} + +bool CXFA_FFWidget::OnKeyUp(uint32_t dwKeyCode, uint32_t dwFlags) { + return false; +} + +bool CXFA_FFWidget::OnChar(uint32_t dwChar, uint32_t dwFlags) { + return false; +} + +FWL_WidgetHit CXFA_FFWidget::OnHitTest(const CFX_PointF& point) { + return FWL_WidgetHit::Unknown; +} + +bool CXFA_FFWidget::OnSetCursor(const CFX_PointF& point) { + return false; +} + +bool CXFA_FFWidget::CanUndo() { + return false; +} + +bool CXFA_FFWidget::CanRedo() { + return false; +} + +bool CXFA_FFWidget::Undo() { + return false; +} + +bool CXFA_FFWidget::Redo() { + return false; +} + +bool CXFA_FFWidget::CanCopy() { + return false; +} + +bool CXFA_FFWidget::CanCut() { + return false; +} + +bool CXFA_FFWidget::CanPaste() { + return false; +} + +bool CXFA_FFWidget::CanSelectAll() { + return false; +} + +bool CXFA_FFWidget::CanDelete() { + return CanCut(); +} + +bool CXFA_FFWidget::CanDeSelect() { + return CanCopy(); +} + +bool CXFA_FFWidget::Copy(CFX_WideString& wsCopy) { + return false; +} + +bool CXFA_FFWidget::Cut(CFX_WideString& wsCut) { + return false; +} + +bool CXFA_FFWidget::Paste(const CFX_WideString& wsPaste) { + return false; +} + +void CXFA_FFWidget::SelectAll() {} + +void CXFA_FFWidget::Delete() {} + +void CXFA_FFWidget::DeSelect() {} + +bool CXFA_FFWidget::GetSuggestWords(CFX_PointF pointf, + std::vector& sSuggest) { + return false; +} +bool CXFA_FFWidget::ReplaceSpellCheckWord(CFX_PointF pointf, + const CFX_ByteStringC& bsReplace) { + return false; +} + +CFX_PointF CXFA_FFWidget::Rotate2Normal(const CFX_PointF& point) { + CFX_Matrix mt = GetRotateMatrix(); + if (mt.IsIdentity()) + return point; + + CFX_Matrix mtReverse; + mtReverse.SetReverse(mt); + return mtReverse.Transform(point); +} + +static void XFA_GetMatrix(CFX_Matrix& m, + int32_t iRotate, + XFA_ATTRIBUTEENUM at, + const CFX_RectF& rt) { + if (!iRotate) { + return; + } + float fAnchorX = 0; + float fAnchorY = 0; + switch (at) { + case XFA_ATTRIBUTEENUM_TopLeft: + fAnchorX = rt.left, fAnchorY = rt.top; + break; + case XFA_ATTRIBUTEENUM_TopCenter: + fAnchorX = (rt.left + rt.right()) / 2, fAnchorY = rt.top; + break; + case XFA_ATTRIBUTEENUM_TopRight: + fAnchorX = rt.right(), fAnchorY = rt.top; + break; + case XFA_ATTRIBUTEENUM_MiddleLeft: + fAnchorX = rt.left, fAnchorY = (rt.top + rt.bottom()) / 2; + break; + case XFA_ATTRIBUTEENUM_MiddleCenter: + fAnchorX = (rt.left + rt.right()) / 2, + fAnchorY = (rt.top + rt.bottom()) / 2; + break; + case XFA_ATTRIBUTEENUM_MiddleRight: + fAnchorX = rt.right(), fAnchorY = (rt.top + rt.bottom()) / 2; + break; + case XFA_ATTRIBUTEENUM_BottomLeft: + fAnchorX = rt.left, fAnchorY = rt.bottom(); + break; + case XFA_ATTRIBUTEENUM_BottomCenter: + fAnchorX = (rt.left + rt.right()) / 2, fAnchorY = rt.bottom(); + break; + case XFA_ATTRIBUTEENUM_BottomRight: + fAnchorX = rt.right(), fAnchorY = rt.bottom(); + break; + default: + break; + } + switch (iRotate) { + case 90: + m.a = 0, m.b = -1, m.c = 1, m.d = 0, m.e = fAnchorX - fAnchorY, + m.f = fAnchorX + fAnchorY; + break; + case 180: + m.a = -1, m.b = 0, m.c = 0, m.d = -1, m.e = fAnchorX * 2, + m.f = fAnchorY * 2; + break; + case 270: + m.a = 0, m.b = 1, m.c = -1, m.d = 0, m.e = fAnchorX + fAnchorY, + m.f = fAnchorY - fAnchorX; + break; + } +} + +CFX_Matrix CXFA_FFWidget::GetRotateMatrix() { + CFX_Matrix mt; + int32_t iRotate = m_pDataAcc->GetRotate(); + if (!iRotate) + return mt; + + CFX_RectF rcWidget = GetRectWithoutRotate(); + XFA_ATTRIBUTEENUM at = XFA_ATTRIBUTEENUM_TopLeft; + XFA_GetMatrix(mt, iRotate, at, rcWidget); + + return mt; +} + +bool CXFA_FFWidget::IsLayoutRectEmpty() { + CFX_RectF rtLayout = GetRectWithoutRotate(); + return rtLayout.width < 0.1f && rtLayout.height < 0.1f; +} +CXFA_FFWidget* CXFA_FFWidget::GetParent() { + CXFA_Node* pParentNode = + m_pDataAcc->GetNode()->GetNodeItem(XFA_NODEITEM_Parent); + if (pParentNode) { + CXFA_WidgetAcc* pParentWidgetAcc = + static_cast(pParentNode->GetWidgetData()); + if (pParentWidgetAcc) { + return pParentWidgetAcc->GetNextWidget(nullptr); + } + } + return nullptr; +} + +bool CXFA_FFWidget::IsAncestorOf(CXFA_FFWidget* pWidget) { + if (!pWidget) + return false; + + CXFA_Node* pNode = m_pDataAcc->GetNode(); + CXFA_Node* pChildNode = pWidget->GetDataAcc()->GetNode(); + while (pChildNode) { + if (pChildNode == pNode) + return true; + + pChildNode = pChildNode->GetNodeItem(XFA_NODEITEM_Parent); + } + return false; +} + +bool CXFA_FFWidget::PtInActiveRect(const CFX_PointF& point) { + return GetWidgetRect().Contains(point); +} + +CXFA_FFDocView* CXFA_FFWidget::GetDocView() { + return m_pDocView; +} + +void CXFA_FFWidget::SetDocView(CXFA_FFDocView* pDocView) { + m_pDocView = pDocView; +} + +CXFA_FFDoc* CXFA_FFWidget::GetDoc() { + return m_pDocView->GetDoc(); +} + +CXFA_FFApp* CXFA_FFWidget::GetApp() { + return GetDoc()->GetApp(); +} + +IXFA_AppProvider* CXFA_FFWidget::GetAppProvider() { + return GetApp()->GetAppProvider(); +} + +bool CXFA_FFWidget::IsMatchVisibleStatus(uint32_t dwStatus) { + return !!(m_dwStatus & XFA_WidgetStatus_Visible); +} + +void CXFA_FFWidget::EventKillFocus() { + if (m_dwStatus & XFA_WidgetStatus_Access) { + m_dwStatus &= ~XFA_WidgetStatus_Access; + return; + } + CXFA_EventParam eParam; + eParam.m_eType = XFA_EVENT_Exit; + eParam.m_pTarget = m_pDataAcc; + m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Exit, &eParam); +} +bool CXFA_FFWidget::IsButtonDown() { + return (m_dwStatus & XFA_WidgetStatus_ButtonDown) != 0; +} +void CXFA_FFWidget::SetButtonDown(bool bSet) { + bSet ? m_dwStatus |= XFA_WidgetStatus_ButtonDown + : m_dwStatus &= ~XFA_WidgetStatus_ButtonDown; +} +int32_t XFA_StrokeTypeSetLineDash(CFX_Graphics* pGraphics, + int32_t iStrokeType, + int32_t iCapType) { + switch (iStrokeType) { + case XFA_ATTRIBUTEENUM_DashDot: { + float dashArray[] = {4, 1, 2, 1}; + if (iCapType != XFA_ATTRIBUTEENUM_Butt) { + dashArray[1] = 2; + dashArray[3] = 2; + } + pGraphics->SetLineDash(0, dashArray, 4); + return FX_DASHSTYLE_DashDot; + } + case XFA_ATTRIBUTEENUM_DashDotDot: { + float dashArray[] = {4, 1, 2, 1, 2, 1}; + if (iCapType != XFA_ATTRIBUTEENUM_Butt) { + dashArray[1] = 2; + dashArray[3] = 2; + dashArray[5] = 2; + } + pGraphics->SetLineDash(0, dashArray, 6); + return FX_DASHSTYLE_DashDotDot; + } + case XFA_ATTRIBUTEENUM_Dashed: { + float dashArray[] = {5, 1}; + if (iCapType != XFA_ATTRIBUTEENUM_Butt) { + dashArray[1] = 2; + } + pGraphics->SetLineDash(0, dashArray, 2); + return FX_DASHSTYLE_Dash; + } + case XFA_ATTRIBUTEENUM_Dotted: { + float dashArray[] = {2, 1}; + if (iCapType != XFA_ATTRIBUTEENUM_Butt) { + dashArray[1] = 2; + } + pGraphics->SetLineDash(0, dashArray, 2); + return FX_DASHSTYLE_Dot; + } + default: + break; + } + pGraphics->SetLineDash(FX_DASHSTYLE_Solid); + return FX_DASHSTYLE_Solid; +} +CFX_GraphStateData::LineCap XFA_LineCapToFXGE(int32_t iLineCap) { + switch (iLineCap) { + case XFA_ATTRIBUTEENUM_Round: + return CFX_GraphStateData::LineCapRound; + case XFA_ATTRIBUTEENUM_Butt: + return CFX_GraphStateData::LineCapButt; + default: + break; + } + return CFX_GraphStateData::LineCapSquare; +} + +class CXFA_ImageRenderer { + public: + CXFA_ImageRenderer(); + ~CXFA_ImageRenderer(); + + bool Start(CFX_RenderDevice* pDevice, + CFX_DIBSource* pDIBSource, + FX_ARGB bitmap_argb, + int bitmap_alpha, + const CFX_Matrix* pImage2Device, + uint32_t flags, + int blendType = FXDIB_BLEND_NORMAL); + bool Continue(IFX_Pause* pPause); + + protected: + bool StartDIBSource(); + void CompositeDIBitmap(CFX_DIBitmap* pDIBitmap, + int left, + int top, + FX_ARGB mask_argb, + int bitmap_alpha, + int blend_mode, + int Transparency); + + CFX_RenderDevice* m_pDevice; + int m_Status; + CFX_Matrix m_ImageMatrix; + CFX_DIBSource* m_pDIBSource; + std::unique_ptr m_pCloneConvert; + int m_BitmapAlpha; + FX_ARGB m_FillArgb; + uint32_t m_Flags; + std::unique_ptr m_pTransformer; + void* m_DeviceHandle; + int32_t m_BlendType; + bool m_Result; + bool m_bPrint; +}; + +CXFA_ImageRenderer::CXFA_ImageRenderer() + : m_pDevice(nullptr), + m_Status(0), + m_pDIBSource(nullptr), + m_BitmapAlpha(255), + m_FillArgb(0), + m_Flags(0), + m_DeviceHandle(nullptr), + m_BlendType(FXDIB_BLEND_NORMAL), + m_Result(true), + m_bPrint(false) {} + +CXFA_ImageRenderer::~CXFA_ImageRenderer() { + if (m_DeviceHandle) + m_pDevice->CancelDIBits(m_DeviceHandle); +} + +bool CXFA_ImageRenderer::Start(CFX_RenderDevice* pDevice, + CFX_DIBSource* pDIBSource, + FX_ARGB bitmap_argb, + int bitmap_alpha, + const CFX_Matrix* pImage2Device, + uint32_t flags, + int blendType) { + m_pDevice = pDevice; + m_pDIBSource = pDIBSource; + m_FillArgb = bitmap_argb; + m_BitmapAlpha = bitmap_alpha; + m_ImageMatrix = *pImage2Device; + m_Flags = flags; + m_BlendType = blendType; + return StartDIBSource(); +} + +bool CXFA_ImageRenderer::StartDIBSource() { + if (m_pDevice->StartDIBitsWithBlend(m_pDIBSource, m_BitmapAlpha, m_FillArgb, + &m_ImageMatrix, m_Flags, m_DeviceHandle, + m_BlendType)) { + if (m_DeviceHandle) { + m_Status = 3; + return true; + } + return false; + } + CFX_FloatRect image_rect_f = m_ImageMatrix.GetUnitRect(); + FX_RECT image_rect = image_rect_f.GetOuterRect(); + int dest_width = image_rect.Width(); + int dest_height = image_rect.Height(); + if ((FXSYS_fabs(m_ImageMatrix.b) >= 0.5f || m_ImageMatrix.a == 0) || + (FXSYS_fabs(m_ImageMatrix.c) >= 0.5f || m_ImageMatrix.d == 0)) { + if (m_bPrint && !(m_pDevice->GetRenderCaps() & FXRC_BLEND_MODE)) { + m_Result = false; + return false; + } + CFX_DIBSource* pDib = m_pDIBSource; + if (m_pDIBSource->HasAlpha() && + !(m_pDevice->GetRenderCaps() & FXRC_ALPHA_IMAGE) && + !(m_pDevice->GetRenderCaps() & FXRC_GET_BITS)) { + m_pCloneConvert = m_pDIBSource->CloneConvert(FXDIB_Rgb); + if (!m_pCloneConvert) { + m_Result = false; + return false; + } + pDib = m_pCloneConvert.get(); + } + FX_RECT clip_box = m_pDevice->GetClipBox(); + clip_box.Intersect(image_rect); + m_Status = 2; + m_pTransformer.reset( + new CFX_ImageTransformer(pDib, &m_ImageMatrix, m_Flags, &clip_box)); + m_pTransformer->Start(); + return true; + } + if (m_ImageMatrix.a < 0) { + dest_width = -dest_width; + } + if (m_ImageMatrix.d > 0) { + dest_height = -dest_height; + } + int dest_left, dest_top; + dest_left = dest_width > 0 ? image_rect.left : image_rect.right; + dest_top = dest_height > 0 ? image_rect.top : image_rect.bottom; + if (m_pDIBSource->IsOpaqueImage() && m_BitmapAlpha == 255) { + if (m_pDevice->StretchDIBitsWithFlagsAndBlend( + m_pDIBSource, dest_left, dest_top, dest_width, dest_height, m_Flags, + m_BlendType)) { + return false; + } + } + if (m_pDIBSource->IsAlphaMask()) { + if (m_BitmapAlpha != 255) { + m_FillArgb = FXARGB_MUL_ALPHA(m_FillArgb, m_BitmapAlpha); + } + if (m_pDevice->StretchBitMaskWithFlags(m_pDIBSource, dest_left, dest_top, + dest_width, dest_height, m_FillArgb, + m_Flags)) { + return false; + } + } + if (m_bPrint && !(m_pDevice->GetRenderCaps() & FXRC_BLEND_MODE)) { + m_Result = false; + return true; + } + FX_RECT clip_box = m_pDevice->GetClipBox(); + FX_RECT dest_rect = clip_box; + dest_rect.Intersect(image_rect); + FX_RECT dest_clip( + dest_rect.left - image_rect.left, dest_rect.top - image_rect.top, + dest_rect.right - image_rect.left, dest_rect.bottom - image_rect.top); + std::unique_ptr pStretched( + m_pDIBSource->StretchTo(dest_width, dest_height, m_Flags, &dest_clip)); + if (pStretched) { + CompositeDIBitmap(pStretched.get(), dest_rect.left, dest_rect.top, + m_FillArgb, m_BitmapAlpha, m_BlendType, false); + } + return false; +} + +bool CXFA_ImageRenderer::Continue(IFX_Pause* pPause) { + if (m_Status == 2) { + if (m_pTransformer->Continue(pPause)) + return true; + + std::unique_ptr pBitmap(m_pTransformer->DetachBitmap()); + if (!pBitmap) + return false; + + if (pBitmap->IsAlphaMask()) { + if (m_BitmapAlpha != 255) + m_FillArgb = FXARGB_MUL_ALPHA(m_FillArgb, m_BitmapAlpha); + m_Result = + m_pDevice->SetBitMask(pBitmap.get(), m_pTransformer->result().left, + m_pTransformer->result().top, m_FillArgb); + } else { + if (m_BitmapAlpha != 255) + pBitmap->MultiplyAlpha(m_BitmapAlpha); + m_Result = m_pDevice->SetDIBitsWithBlend( + pBitmap.get(), m_pTransformer->result().left, + m_pTransformer->result().top, m_BlendType); + } + return false; + } + if (m_Status == 3) + return m_pDevice->ContinueDIBits(m_DeviceHandle, pPause); + + return false; +} + +void CXFA_ImageRenderer::CompositeDIBitmap(CFX_DIBitmap* pDIBitmap, + int left, + int top, + FX_ARGB mask_argb, + int bitmap_alpha, + int blend_mode, + int Transparency) { + if (!pDIBitmap) { + return; + } + bool bIsolated = !!(Transparency & PDFTRANS_ISOLATED); + bool bGroup = !!(Transparency & PDFTRANS_GROUP); + if (blend_mode == FXDIB_BLEND_NORMAL) { + if (!pDIBitmap->IsAlphaMask()) { + if (bitmap_alpha < 255) { + pDIBitmap->MultiplyAlpha(bitmap_alpha); + } + if (m_pDevice->SetDIBits(pDIBitmap, left, top)) { + return; + } + } else { + uint32_t fill_argb = (mask_argb); + if (bitmap_alpha < 255) { + ((uint8_t*)&fill_argb)[3] = + ((uint8_t*)&fill_argb)[3] * bitmap_alpha / 255; + } + if (m_pDevice->SetBitMask(pDIBitmap, left, top, fill_argb)) { + return; + } + } + } + bool bBackAlphaRequired = blend_mode && bIsolated; + bool bGetBackGround = + ((m_pDevice->GetRenderCaps() & FXRC_ALPHA_OUTPUT)) || + (!(m_pDevice->GetRenderCaps() & FXRC_ALPHA_OUTPUT) && + (m_pDevice->GetRenderCaps() & FXRC_GET_BITS) && !bBackAlphaRequired); + if (bGetBackGround) { + if (bIsolated || !bGroup) { + if (pDIBitmap->IsAlphaMask()) { + return; + } + m_pDevice->SetDIBitsWithBlend(pDIBitmap, left, top, blend_mode); + } else { + FX_RECT rect(left, top, left + pDIBitmap->GetWidth(), + top + pDIBitmap->GetHeight()); + rect.Intersect(m_pDevice->GetClipBox()); + CFX_MaybeOwned pClone; + if (m_pDevice->GetBackDrop() && m_pDevice->GetBitmap()) { + pClone = m_pDevice->GetBackDrop()->Clone(&rect); + CFX_DIBitmap* pForeBitmap = m_pDevice->GetBitmap(); + pClone->CompositeBitmap(0, 0, pClone->GetWidth(), pClone->GetHeight(), + pForeBitmap, rect.left, rect.top); + left = left >= 0 ? 0 : left; + top = top >= 0 ? 0 : top; + if (!pDIBitmap->IsAlphaMask()) + pClone->CompositeBitmap(0, 0, pClone->GetWidth(), pClone->GetHeight(), + pDIBitmap, left, top, blend_mode); + else + pClone->CompositeMask(0, 0, pClone->GetWidth(), pClone->GetHeight(), + pDIBitmap, mask_argb, left, top, blend_mode); + } else { + pClone = pDIBitmap; + } + if (m_pDevice->GetBackDrop()) { + m_pDevice->SetDIBits(pClone.Get(), rect.left, rect.top); + } else { + if (pDIBitmap->IsAlphaMask()) + return; + m_pDevice->SetDIBitsWithBlend(pDIBitmap, rect.left, rect.top, + blend_mode); + } + } + return; + } + if (!pDIBitmap->HasAlpha() || + (m_pDevice->GetRenderCaps() & FXRC_ALPHA_IMAGE)) { + return; + } + std::unique_ptr pCloneConvert = + pDIBitmap->CloneConvert(FXDIB_Rgb); + if (!pCloneConvert) + return; + + CXFA_ImageRenderer imageRender; + if (!imageRender.Start(m_pDevice, pCloneConvert.get(), m_FillArgb, + m_BitmapAlpha, &m_ImageMatrix, m_Flags)) { + return; + } + while (imageRender.Continue(nullptr)) + continue; +} + +void XFA_DrawImage(CFX_Graphics* pGS, + const CFX_RectF& rtImage, + CFX_Matrix* pMatrix, + CFX_DIBitmap* pDIBitmap, + int32_t iAspect, + int32_t iImageXDpi, + int32_t iImageYDpi, + int32_t iHorzAlign, + int32_t iVertAlign) { + if (rtImage.IsEmpty()) + return; + if (!pDIBitmap || !pDIBitmap->GetBuffer()) + return; + + CFX_RectF rtFit( + rtImage.TopLeft(), + XFA_UnitPx2Pt((float)pDIBitmap->GetWidth(), (float)iImageXDpi), + XFA_UnitPx2Pt((float)pDIBitmap->GetHeight(), (float)iImageYDpi)); + switch (iAspect) { + case XFA_ATTRIBUTEENUM_Fit: { + float f1 = rtImage.height / rtFit.height; + float f2 = rtImage.width / rtFit.width; + f1 = std::min(f1, f2); + rtFit.height = rtFit.height * f1; + rtFit.width = rtFit.width * f1; + } break; + case XFA_ATTRIBUTEENUM_Actual: + break; + case XFA_ATTRIBUTEENUM_Height: { + float f1 = rtImage.height / rtFit.height; + rtFit.height = rtImage.height; + rtFit.width = f1 * rtFit.width; + } break; + case XFA_ATTRIBUTEENUM_None: + rtFit.height = rtImage.height; + rtFit.width = rtImage.width; + break; + case XFA_ATTRIBUTEENUM_Width: { + float f1 = rtImage.width / rtFit.width; + rtFit.width = rtImage.width; + rtFit.height = rtFit.height * f1; + } break; + } + if (iHorzAlign == XFA_ATTRIBUTEENUM_Center) { + rtFit.left += (rtImage.width - rtFit.width) / 2; + } else if (iHorzAlign == XFA_ATTRIBUTEENUM_Right) { + rtFit.left = rtImage.right() - rtFit.width; + } + if (iVertAlign == XFA_ATTRIBUTEENUM_Middle) { + rtFit.top += (rtImage.height - rtFit.height) / 2; + } else if (iVertAlign == XFA_ATTRIBUTEENUM_Bottom) { + rtFit.top = rtImage.bottom() - rtImage.height; + } + CFX_RenderDevice* pRenderDevice = pGS->GetRenderDevice(); + pRenderDevice->SaveState(); + + CFX_PathData path; + path.AppendRect(rtImage.left, rtImage.bottom(), rtImage.right(), rtImage.top); + pRenderDevice->SetClip_PathFill(&path, pMatrix, FXFILL_WINDING); + + CFX_Matrix mtImage(1, 0, 0, -1, 0, 1); + mtImage.Concat( + CFX_Matrix(rtFit.width, 0, 0, rtFit.height, rtFit.left, rtFit.top)); + mtImage.Concat(*pMatrix); + + CXFA_ImageRenderer imageRender; + bool bRet = imageRender.Start(pRenderDevice, pDIBitmap, 0, 255, &mtImage, + FXDIB_INTERPOL); + while (bRet) + bRet = imageRender.Continue(nullptr); + + pRenderDevice->RestoreState(false); +} + +static const uint8_t g_inv_base64[128] = { + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 62, 255, + 255, 255, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 255, 255, + 255, 255, 255, 255, 255, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, + 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 255, 255, 255, 255, 255, 255, 26, 27, 28, 29, 30, 31, 32, 33, + 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, + 49, 50, 51, 255, 255, 255, 255, 255, +}; + +static uint8_t* XFA_RemoveBase64Whitespace(const uint8_t* pStr, int32_t iLen) { + uint8_t* pCP; + int32_t i = 0, j = 0; + if (iLen == 0) { + iLen = FXSYS_strlen((char*)pStr); + } + pCP = FX_Alloc(uint8_t, iLen + 1); + for (; i < iLen; i++) { + if ((pStr[i] & 128) == 0) { + if (g_inv_base64[pStr[i]] != 0xFF || pStr[i] == '=') { + pCP[j++] = pStr[i]; + } + } + } + pCP[j] = '\0'; + return pCP; +} +static int32_t XFA_Base64Decode(const char* pStr, uint8_t* pOutBuffer) { + if (!pStr) { + return 0; + } + uint8_t* pBuffer = + XFA_RemoveBase64Whitespace((uint8_t*)pStr, FXSYS_strlen((char*)pStr)); + if (!pBuffer) { + return 0; + } + int32_t iLen = FXSYS_strlen((char*)pBuffer); + int32_t i = 0, j = 0; + uint32_t dwLimb = 0; + for (; i + 3 < iLen; i += 4) { + if (pBuffer[i] == '=' || pBuffer[i + 1] == '=' || pBuffer[i + 2] == '=' || + pBuffer[i + 3] == '=') { + if (pBuffer[i] == '=' || pBuffer[i + 1] == '=') { + break; + } + if (pBuffer[i + 2] == '=') { + dwLimb = ((uint32_t)g_inv_base64[pBuffer[i]] << 6) | + ((uint32_t)g_inv_base64[pBuffer[i + 1]]); + pOutBuffer[j] = (uint8_t)(dwLimb >> 4) & 0xFF; + j++; + } else { + dwLimb = ((uint32_t)g_inv_base64[pBuffer[i]] << 12) | + ((uint32_t)g_inv_base64[pBuffer[i + 1]] << 6) | + ((uint32_t)g_inv_base64[pBuffer[i + 2]]); + pOutBuffer[j] = (uint8_t)(dwLimb >> 10) & 0xFF; + pOutBuffer[j + 1] = (uint8_t)(dwLimb >> 2) & 0xFF; + j += 2; + } + } else { + dwLimb = ((uint32_t)g_inv_base64[pBuffer[i]] << 18) | + ((uint32_t)g_inv_base64[pBuffer[i + 1]] << 12) | + ((uint32_t)g_inv_base64[pBuffer[i + 2]] << 6) | + ((uint32_t)g_inv_base64[pBuffer[i + 3]]); + pOutBuffer[j] = (uint8_t)(dwLimb >> 16) & 0xff; + pOutBuffer[j + 1] = (uint8_t)(dwLimb >> 8) & 0xff; + pOutBuffer[j + 2] = (uint8_t)(dwLimb)&0xff; + j += 3; + } + } + FX_Free(pBuffer); + return j; +} + +static const char g_base64_chars[] = + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; + +char* XFA_Base64Encode(const uint8_t* buf, int32_t buf_len) { + char* out = nullptr; + int i, j; + uint32_t limb; + out = FX_Alloc(char, ((buf_len * 8 + 5) / 6) + 5); + for (i = 0, j = 0, limb = 0; i + 2 < buf_len; i += 3, j += 4) { + limb = ((uint32_t)buf[i] << 16) | ((uint32_t)buf[i + 1] << 8) | + ((uint32_t)buf[i + 2]); + out[j] = g_base64_chars[(limb >> 18) & 63]; + out[j + 1] = g_base64_chars[(limb >> 12) & 63]; + out[j + 2] = g_base64_chars[(limb >> 6) & 63]; + out[j + 3] = g_base64_chars[(limb)&63]; + } + switch (buf_len - i) { + case 0: + break; + case 1: + limb = ((uint32_t)buf[i]); + out[j++] = g_base64_chars[(limb >> 2) & 63]; + out[j++] = g_base64_chars[(limb << 4) & 63]; + out[j++] = '='; + out[j++] = '='; + break; + case 2: + limb = ((uint32_t)buf[i] << 8) | ((uint32_t)buf[i + 1]); + out[j++] = g_base64_chars[(limb >> 10) & 63]; + out[j++] = g_base64_chars[(limb >> 4) & 63]; + out[j++] = g_base64_chars[(limb << 2) & 63]; + out[j++] = '='; + break; + default: + break; + } + out[j] = '\0'; + return out; +} +FXCODEC_IMAGE_TYPE XFA_GetImageType(const CFX_WideString& wsType) { + CFX_WideString wsContentType(wsType); + wsContentType.MakeLower(); + if (wsContentType == L"image/jpg") + return FXCODEC_IMAGE_JPG; + if (wsContentType == L"image/png") + return FXCODEC_IMAGE_PNG; + if (wsContentType == L"image/gif") + return FXCODEC_IMAGE_GIF; + if (wsContentType == L"image/bmp") + return FXCODEC_IMAGE_BMP; + if (wsContentType == L"image/tif") + return FXCODEC_IMAGE_TIF; + return FXCODEC_IMAGE_UNKNOWN; +} +CFX_DIBitmap* XFA_LoadImageData(CXFA_FFDoc* pDoc, + CXFA_Image* pImage, + bool& bNameImage, + int32_t& iImageXDpi, + int32_t& iImageYDpi) { + CFX_WideString wsHref; + pImage->GetHref(wsHref); + CFX_WideString wsImage; + pImage->GetContent(wsImage); + if (wsHref.IsEmpty() && wsImage.IsEmpty()) { + return nullptr; + } + CFX_WideString wsContentType; + pImage->GetContentType(wsContentType); + FXCODEC_IMAGE_TYPE type = XFA_GetImageType(wsContentType); + CFX_ByteString bsContent; + uint8_t* pImageBuffer = nullptr; + CFX_RetainPtr pImageFileRead; + if (wsImage.GetLength() > 0) { + XFA_ATTRIBUTEENUM iEncoding = + (XFA_ATTRIBUTEENUM)pImage->GetTransferEncoding(); + if (iEncoding == XFA_ATTRIBUTEENUM_Base64) { + CFX_ByteString bsData = wsImage.UTF8Encode(); + int32_t iLength = bsData.GetLength(); + pImageBuffer = FX_Alloc(uint8_t, iLength); + int32_t iRead = XFA_Base64Decode(bsData.c_str(), pImageBuffer); + if (iRead > 0) { + pImageFileRead = IFX_MemoryStream::Create(pImageBuffer, iRead); + } + } else { + bsContent = CFX_ByteString::FromUnicode(wsImage); + pImageFileRead = IFX_MemoryStream::Create( + const_cast(bsContent.raw_str()), bsContent.GetLength()); + } + } else { + CFX_WideString wsURL = wsHref; + if (wsURL.Left(7) != L"http://" && wsURL.Left(6) != L"ftp://") { + CFX_DIBitmap* pBitmap = + pDoc->GetPDFNamedImage(wsURL.AsStringC(), iImageXDpi, iImageYDpi); + if (pBitmap) { + bNameImage = true; + return pBitmap; + } + } + pImageFileRead = pDoc->GetDocEnvironment()->OpenLinkedFile(pDoc, wsURL); + } + if (!pImageFileRead) { + FX_Free(pImageBuffer); + return nullptr; + } + bNameImage = false; + CFX_DIBitmap* pBitmap = + XFA_LoadImageFromBuffer(pImageFileRead, type, iImageXDpi, iImageYDpi); + FX_Free(pImageBuffer); + return pBitmap; +} +static FXDIB_Format XFA_GetDIBFormat(FXCODEC_IMAGE_TYPE type, + int32_t iComponents, + int32_t iBitsPerComponent) { + FXDIB_Format dibFormat = FXDIB_Argb; + switch (type) { + case FXCODEC_IMAGE_BMP: + case FXCODEC_IMAGE_JPG: + case FXCODEC_IMAGE_TIF: { + dibFormat = FXDIB_Rgb32; + int32_t bpp = iComponents * iBitsPerComponent; + if (bpp <= 24) { + dibFormat = FXDIB_Rgb; + } + } break; + case FXCODEC_IMAGE_PNG: + default: + break; + } + return dibFormat; +} + +CFX_DIBitmap* XFA_LoadImageFromBuffer( + const CFX_RetainPtr& pImageFileRead, + FXCODEC_IMAGE_TYPE type, + int32_t& iImageXDpi, + int32_t& iImageYDpi) { + CFX_GEModule* pGeModule = CFX_GEModule::Get(); + if (!pGeModule) + return nullptr; + + CCodec_ModuleMgr* pCodecMgr = pGeModule->GetCodecModule(); + if (!pCodecMgr) + return nullptr; + + CFX_DIBAttribute dibAttr; + CFX_DIBitmap* pBitmap = nullptr; + std::unique_ptr pProgressiveDecoder = + pCodecMgr->CreateProgressiveDecoder(); + pProgressiveDecoder->LoadImageInfo(pImageFileRead, type, &dibAttr, false); + switch (dibAttr.m_wDPIUnit) { + case FXCODEC_RESUNIT_CENTIMETER: + dibAttr.m_nXDPI = (int32_t)(dibAttr.m_nXDPI * 2.54f); + dibAttr.m_nYDPI = (int32_t)(dibAttr.m_nYDPI * 2.54f); + break; + case FXCODEC_RESUNIT_METER: + dibAttr.m_nXDPI = (int32_t)(dibAttr.m_nXDPI / (float)100 * 2.54f); + dibAttr.m_nYDPI = (int32_t)(dibAttr.m_nYDPI / (float)100 * 2.54f); + break; + default: + break; + } + iImageXDpi = dibAttr.m_nXDPI > 1 ? dibAttr.m_nXDPI : (96); + iImageYDpi = dibAttr.m_nYDPI > 1 ? dibAttr.m_nYDPI : (96); + if (pProgressiveDecoder->GetWidth() > 0 && + pProgressiveDecoder->GetHeight() > 0) { + type = pProgressiveDecoder->GetType(); + int32_t iComponents = pProgressiveDecoder->GetNumComponents(); + int32_t iBpc = pProgressiveDecoder->GetBPC(); + FXDIB_Format dibFormat = XFA_GetDIBFormat(type, iComponents, iBpc); + pBitmap = new CFX_DIBitmap(); + pBitmap->Create(pProgressiveDecoder->GetWidth(), + pProgressiveDecoder->GetHeight(), dibFormat); + pBitmap->Clear(0xffffffff); + int32_t nFrames; + if ((pProgressiveDecoder->GetFrames(nFrames) == + FXCODEC_STATUS_DECODE_READY) && + (nFrames > 0)) { + pProgressiveDecoder->StartDecode(pBitmap, 0, 0, pBitmap->GetWidth(), + pBitmap->GetHeight()); + pProgressiveDecoder->ContinueDecode(); + } + } + return pBitmap; +} + +void XFA_RectWidthoutMargin(CFX_RectF& rt, const CXFA_Margin& mg, bool bUI) { + if (!mg) { + return; + } + float fLeftInset, fTopInset, fRightInset, fBottomInset; + mg.GetLeftInset(fLeftInset); + mg.GetTopInset(fTopInset); + mg.GetRightInset(fRightInset); + mg.GetBottomInset(fBottomInset); + rt.Deflate(fLeftInset, fTopInset, fRightInset, fBottomInset); +} +CXFA_FFWidget* XFA_GetWidgetFromLayoutItem(CXFA_LayoutItem* pLayoutItem) { + if (XFA_IsCreateWidget(pLayoutItem->GetFormNode()->GetElementType())) + return static_cast(pLayoutItem); + return nullptr; +} +bool XFA_IsCreateWidget(XFA_Element eType) { + return eType == XFA_Element::Field || eType == XFA_Element::Draw || + eType == XFA_Element::Subform || eType == XFA_Element::ExclGroup; +} +static void XFA_BOX_GetPath_Arc(CXFA_Box box, + CFX_RectF rtDraw, + CFX_Path& fillPath, + uint32_t dwFlags) { + float a, b; + a = rtDraw.width / 2.0f; + b = rtDraw.height / 2.0f; + if (box.IsCircular() || (dwFlags & XFA_DRAWBOX_ForceRound) != 0) { + a = b = std::min(a, b); + } + CFX_PointF center = rtDraw.Center(); + rtDraw.left = center.x - a; + rtDraw.top = center.y - b; + rtDraw.width = a + a; + rtDraw.height = b + b; + float startAngle = 0, sweepAngle = 360; + bool bStart = box.GetStartAngle(startAngle); + bool bEnd = box.GetSweepAngle(sweepAngle); + if (!bStart && !bEnd) { + fillPath.AddEllipse(rtDraw); + return; + } + startAngle = -startAngle * FX_PI / 180.0f; + sweepAngle = -sweepAngle * FX_PI / 180.0f; + fillPath.AddArc(rtDraw.TopLeft(), rtDraw.Size(), startAngle, sweepAngle); +} + +static void XFA_BOX_GetPath(CXFA_Box box, + const std::vector& strokes, + CFX_RectF rtWidget, + CFX_Path& path, + int32_t nIndex, + bool bStart, + bool bCorner) { + ASSERT(nIndex >= 0 && nIndex < 8); + int32_t n = (nIndex & 1) ? nIndex - 1 : nIndex; + CXFA_Corner corner1(strokes[n].GetNode()); + CXFA_Corner corner2(strokes[(n + 2) % 8].GetNode()); + float fRadius1 = bCorner ? corner1.GetRadius() : 0.0f; + float fRadius2 = bCorner ? corner2.GetRadius() : 0.0f; + bool bInverted = corner1.IsInverted(); + float offsetY = 0.0f; + float offsetX = 0.0f; + bool bRound = corner1.GetJoinType() == XFA_ATTRIBUTEENUM_Round; + float halfAfter = 0.0f; + float halfBefore = 0.0f; + CXFA_Stroke stroke = strokes[nIndex]; + if (stroke.IsCorner()) { + CXFA_Stroke edgeBefore = strokes[(nIndex + 1 * 8 - 1) % 8]; + CXFA_Stroke edgeAfter = strokes[nIndex + 1]; + if (stroke.IsInverted()) { + if (!stroke.SameStyles(edgeBefore)) { + halfBefore = edgeBefore.GetThickness() / 2; + } + if (!stroke.SameStyles(edgeAfter)) { + halfAfter = edgeAfter.GetThickness() / 2; + } + } + } else { + CXFA_Stroke edgeBefore = strokes[(nIndex + 8 - 2) % 8]; + CXFA_Stroke edgeAfter = strokes[(nIndex + 2) % 8]; + if (!bRound && !bInverted) { + halfBefore = edgeBefore.GetThickness() / 2; + halfAfter = edgeAfter.GetThickness() / 2; + } + } + float offsetEX = 0.0f; + float offsetEY = 0.0f; + float sx = 0.0f; + float sy = 0.0f; + float vx = 1.0f; + float vy = 1.0f; + float nx = 1.0f; + float ny = 1.0f; + CFX_PointF cpStart; + CFX_PointF cp1; + CFX_PointF cp2; + if (bRound) { + sy = FX_PI / 2; + } + switch (nIndex) { + case 0: + case 1: + cp1 = rtWidget.TopLeft(); + cp2 = rtWidget.TopRight(); + if (nIndex == 0) { + cpStart.x = cp1.x - halfBefore; + cpStart.y = cp1.y + fRadius1, offsetY = -halfAfter; + } else { + cpStart.x = cp1.x + fRadius1 - halfBefore, cpStart.y = cp1.y, + offsetEX = halfAfter; + } + vx = 1, vy = 1; + nx = -1, ny = 0; + if (bRound) { + sx = bInverted ? FX_PI / 2 : FX_PI; + } else { + sx = 1, sy = 0; + } + break; + case 2: + case 3: + cp1 = rtWidget.TopRight(); + cp2 = rtWidget.BottomRight(); + if (nIndex == 2) { + cpStart.x = cp1.x - fRadius1, cpStart.y = cp1.y - halfBefore, + offsetX = halfAfter; + } else { + cpStart.x = cp1.x, cpStart.y = cp1.y + fRadius1 - halfBefore, + offsetEY = halfAfter; + } + vx = -1, vy = 1; + nx = 0, ny = -1; + if (bRound) { + sx = bInverted ? FX_PI : FX_PI * 3 / 2; + } else { + sx = 0, sy = 1; + } + break; + case 4: + case 5: + cp1 = rtWidget.BottomRight(); + cp2 = rtWidget.BottomLeft(); + if (nIndex == 4) { + cpStart.x = cp1.x + halfBefore, cpStart.y = cp1.y - fRadius1, + offsetY = halfAfter; + } else { + cpStart.x = cp1.x - fRadius1 + halfBefore, cpStart.y = cp1.y, + offsetEX = -halfAfter; + } + vx = -1, vy = -1; + nx = 1, ny = 0; + if (bRound) { + sx = bInverted ? FX_PI * 3 / 2 : 0; + } else { + sx = -1, sy = 0; + } + break; + case 6: + case 7: + cp1 = rtWidget.BottomLeft(); + cp2 = rtWidget.TopLeft(); + if (nIndex == 6) { + cpStart.x = cp1.x + fRadius1, cpStart.y = cp1.y + halfBefore, + offsetX = -halfAfter; + } else { + cpStart.x = cp1.x, cpStart.y = cp1.y - fRadius1 + halfBefore, + offsetEY = -halfAfter; + } + vx = 1; + vy = -1; + nx = 0; + ny = 1; + if (bRound) { + sx = bInverted ? 0 : FX_PI / 2; + } else { + sx = 0; + sy = -1; + } + break; + } + if (bStart) { + path.MoveTo(cpStart); + } + if (nIndex & 1) { + path.LineTo(CFX_PointF(cp2.x + fRadius2 * nx + offsetEX, + cp2.y + fRadius2 * ny + offsetEY)); + return; + } + if (bRound) { + if (fRadius1 < 0) + sx -= FX_PI; + if (bInverted) + sy *= -1; + + CFX_RectF rtRadius(cp1.x + offsetX * 2, cp1.y + offsetY * 2, + fRadius1 * 2 * vx - offsetX * 2, + fRadius1 * 2 * vy - offsetY * 2); + rtRadius.Normalize(); + if (bInverted) + rtRadius.Offset(-fRadius1 * vx, -fRadius1 * vy); + + path.ArcTo(rtRadius.TopLeft(), rtRadius.Size(), sx, sy); + } else { + CFX_PointF cp; + if (bInverted) { + cp.x = cp1.x + fRadius1 * vx; + cp.y = cp1.y + fRadius1 * vy; + } else { + cp = cp1; + } + path.LineTo(cp); + path.LineTo(CFX_PointF(cp1.x + fRadius1 * sx + offsetX, + cp1.y + fRadius1 * sy + offsetY)); + } +} +static void XFA_BOX_GetFillPath(CXFA_Box box, + const std::vector& strokes, + CFX_RectF rtWidget, + CFX_Path& fillPath, + uint16_t dwFlags) { + if (box.IsArc() || (dwFlags & XFA_DRAWBOX_ForceRound) != 0) { + CXFA_Edge edge = box.GetEdge(0); + float fThickness = edge.GetThickness(); + if (fThickness < 0) { + fThickness = 0; + } + float fHalf = fThickness / 2; + int32_t iHand = box.GetHand(); + if (iHand == XFA_ATTRIBUTEENUM_Left) { + rtWidget.Inflate(fHalf, fHalf); + } else if (iHand == XFA_ATTRIBUTEENUM_Right) { + rtWidget.Deflate(fHalf, fHalf); + } + XFA_BOX_GetPath_Arc(box, rtWidget, fillPath, dwFlags); + return; + } + bool bSameStyles = true; + CXFA_Stroke stroke1 = strokes[0]; + for (int32_t i = 1; i < 8; i++) { + CXFA_Stroke stroke2 = strokes[i]; + if (!stroke1.SameStyles(stroke2)) { + bSameStyles = false; + break; + } + stroke1 = stroke2; + } + if (bSameStyles) { + stroke1 = strokes[0]; + for (int32_t i = 2; i < 8; i += 2) { + CXFA_Stroke stroke2 = strokes[i]; + if (!stroke1.SameStyles(stroke2, XFA_STROKE_SAMESTYLE_NoPresence | + XFA_STROKE_SAMESTYLE_Corner)) { + bSameStyles = false; + break; + } + stroke1 = stroke2; + } + if (bSameStyles) { + stroke1 = strokes[0]; + if (stroke1.IsInverted()) { + bSameStyles = false; + } + if (stroke1.GetJoinType() != XFA_ATTRIBUTEENUM_Square) { + bSameStyles = false; + } + } + } + if (bSameStyles) { + fillPath.AddRectangle(rtWidget.left, rtWidget.top, rtWidget.width, + rtWidget.height); + return; + } + + for (int32_t i = 0; i < 8; i += 2) { + float sx = 0.0f; + float sy = 0.0f; + float vx = 1.0f; + float vy = 1.0f; + float nx = 1.0f; + float ny = 1.0f; + CFX_PointF cp1, cp2; + CXFA_Corner corner1(strokes[i].GetNode()); + CXFA_Corner corner2(strokes[(i + 2) % 8].GetNode()); + float fRadius1 = corner1.GetRadius(); + float fRadius2 = corner2.GetRadius(); + bool bInverted = corner1.IsInverted(); + bool bRound = corner1.GetJoinType() == XFA_ATTRIBUTEENUM_Round; + if (bRound) { + sy = FX_PI / 2; + } + switch (i) { + case 0: + cp1 = rtWidget.TopLeft(); + cp2 = rtWidget.TopRight(); + vx = 1, vy = 1; + nx = -1, ny = 0; + if (bRound) { + sx = bInverted ? FX_PI / 2 : FX_PI; + } else { + sx = 1, sy = 0; + } + break; + case 2: + cp1 = rtWidget.TopRight(); + cp2 = rtWidget.BottomRight(); + vx = -1, vy = 1; + nx = 0, ny = -1; + if (bRound) { + sx = bInverted ? FX_PI : FX_PI * 3 / 2; + } else { + sx = 0, sy = 1; + } + break; + case 4: + cp1 = rtWidget.BottomRight(); + cp2 = rtWidget.BottomLeft(); + vx = -1, vy = -1; + nx = 1, ny = 0; + if (bRound) { + sx = bInverted ? FX_PI * 3 / 2 : 0; + } else { + sx = -1, sy = 0; + } + break; + case 6: + cp1 = rtWidget.BottomLeft(); + cp2 = rtWidget.TopLeft(); + vx = 1, vy = -1; + nx = 0, ny = 1; + if (bRound) { + sx = bInverted ? 0 : FX_PI / 2; + } else { + sx = 0; + sy = -1; + } + break; + } + if (i == 0) + fillPath.MoveTo(CFX_PointF(cp1.x, cp1.y + fRadius1)); + + if (bRound) { + if (fRadius1 < 0) + sx -= FX_PI; + if (bInverted) + sy *= -1; + + CFX_RectF rtRadius(cp1.x, cp1.y, fRadius1 * 2 * vx, fRadius1 * 2 * vy); + rtRadius.Normalize(); + if (bInverted) + rtRadius.Offset(-fRadius1 * vx, -fRadius1 * vy); + + fillPath.ArcTo(rtRadius.TopLeft(), rtRadius.Size(), sx, sy); + } else { + CFX_PointF cp; + if (bInverted) { + cp.x = cp1.x + fRadius1 * vx; + cp.y = cp1.y + fRadius1 * vy; + } else { + cp = cp1; + } + fillPath.LineTo(cp); + fillPath.LineTo(CFX_PointF(cp1.x + fRadius1 * sx, cp1.y + fRadius1 * sy)); + } + fillPath.LineTo(CFX_PointF(cp2.x + fRadius2 * nx, cp2.y + fRadius2 * ny)); + } +} +static void XFA_BOX_Fill_Radial(CXFA_Box box, + CFX_Graphics* pGS, + CFX_Path& fillPath, + CFX_RectF rtFill, + CFX_Matrix* pMatrix) { + CXFA_Fill fill = box.GetFill(); + FX_ARGB crStart, crEnd; + crStart = fill.GetColor(); + int32_t iType = fill.GetRadial(crEnd); + if (iType != XFA_ATTRIBUTEENUM_ToEdge) { + FX_ARGB temp = crEnd; + crEnd = crStart; + crStart = temp; + } + CFX_Shading shading(rtFill.Center(), rtFill.Center(), 0, + FXSYS_sqrt(rtFill.Width() * rtFill.Width() + + rtFill.Height() * rtFill.Height()) / + 2, + true, true, crStart, crEnd); + CFX_Color cr(&shading); + pGS->SetFillColor(&cr); + pGS->FillPath(&fillPath, FXFILL_WINDING, pMatrix); +} +static void XFA_BOX_Fill_Pattern(CXFA_Box box, + CFX_Graphics* pGS, + CFX_Path& fillPath, + CFX_RectF rtFill, + CFX_Matrix* pMatrix) { + CXFA_Fill fill = box.GetFill(); + FX_ARGB crStart, crEnd; + crStart = fill.GetColor(); + int32_t iType = fill.GetPattern(crEnd); + FX_HatchStyle iHatch = FX_HatchStyle::Cross; + switch (iType) { + case XFA_ATTRIBUTEENUM_CrossDiagonal: + iHatch = FX_HatchStyle::DiagonalCross; + break; + case XFA_ATTRIBUTEENUM_DiagonalLeft: + iHatch = FX_HatchStyle::ForwardDiagonal; + break; + case XFA_ATTRIBUTEENUM_DiagonalRight: + iHatch = FX_HatchStyle::BackwardDiagonal; + break; + case XFA_ATTRIBUTEENUM_Horizontal: + iHatch = FX_HatchStyle::Horizontal; + break; + case XFA_ATTRIBUTEENUM_Vertical: + iHatch = FX_HatchStyle::Vertical; + break; + default: + break; + } + + CFX_Pattern pattern(iHatch, crEnd, crStart); + CFX_Color cr(&pattern, 0x0); + pGS->SetFillColor(&cr); + pGS->FillPath(&fillPath, FXFILL_WINDING, pMatrix); +} +static void XFA_BOX_Fill_Linear(CXFA_Box box, + CFX_Graphics* pGS, + CFX_Path& fillPath, + CFX_RectF rtFill, + CFX_Matrix* pMatrix) { + CXFA_Fill fill = box.GetFill(); + FX_ARGB crStart = fill.GetColor(); + FX_ARGB crEnd; + int32_t iType = fill.GetLinear(crEnd); + CFX_PointF ptStart; + CFX_PointF ptEnd; + switch (iType) { + case XFA_ATTRIBUTEENUM_ToRight: + ptStart = CFX_PointF(rtFill.left, rtFill.top); + ptEnd = CFX_PointF(rtFill.right(), rtFill.top); + break; + case XFA_ATTRIBUTEENUM_ToBottom: + ptStart = CFX_PointF(rtFill.left, rtFill.top); + ptEnd = CFX_PointF(rtFill.left, rtFill.bottom()); + break; + case XFA_ATTRIBUTEENUM_ToLeft: + ptStart = CFX_PointF(rtFill.right(), rtFill.top); + ptEnd = CFX_PointF(rtFill.left, rtFill.top); + break; + case XFA_ATTRIBUTEENUM_ToTop: + ptStart = CFX_PointF(rtFill.left, rtFill.bottom()); + ptEnd = CFX_PointF(rtFill.left, rtFill.top); + break; + default: + break; + } + CFX_Shading shading(ptStart, ptEnd, false, false, crStart, crEnd); + CFX_Color cr(&shading); + pGS->SetFillColor(&cr); + pGS->FillPath(&fillPath, FXFILL_WINDING, pMatrix); +} +static void XFA_BOX_Fill(CXFA_Box box, + const std::vector& strokes, + CFX_Graphics* pGS, + const CFX_RectF& rtWidget, + CFX_Matrix* pMatrix, + uint32_t dwFlags) { + CXFA_Fill fill = box.GetFill(); + if (!fill || fill.GetPresence() != XFA_ATTRIBUTEENUM_Visible) + return; + + pGS->SaveGraphState(); + CFX_Path fillPath; + XFA_BOX_GetFillPath(box, strokes, rtWidget, fillPath, + (dwFlags & XFA_DRAWBOX_ForceRound) != 0); + fillPath.Close(); + XFA_Element eType = fill.GetFillType(); + switch (eType) { + case XFA_Element::Radial: + XFA_BOX_Fill_Radial(box, pGS, fillPath, rtWidget, pMatrix); + break; + case XFA_Element::Pattern: + XFA_BOX_Fill_Pattern(box, pGS, fillPath, rtWidget, pMatrix); + break; + case XFA_Element::Linear: + XFA_BOX_Fill_Linear(box, pGS, fillPath, rtWidget, pMatrix); + break; + default: { + FX_ARGB cr; + if (eType == XFA_Element::Stipple) { + int32_t iRate = fill.GetStipple(cr); + if (iRate == 0) { + iRate = 100; + } + int32_t a = 0; + FX_COLORREF rgb; + ArgbDecode(cr, a, rgb); + cr = ArgbEncode(iRate * a / 100, rgb); + } else { + cr = fill.GetColor(); + } + CFX_Color fillColor(cr); + pGS->SetFillColor(&fillColor); + pGS->FillPath(&fillPath, FXFILL_WINDING, pMatrix); + } break; + } + pGS->RestoreGraphState(); +} +static void XFA_BOX_StrokePath(CXFA_Stroke stroke, + CFX_Path* pPath, + CFX_Graphics* pGS, + CFX_Matrix* pMatrix) { + if (!stroke || !stroke.IsVisible()) { + return; + } + float fThickness = stroke.GetThickness(); + if (fThickness < 0.001f) { + return; + } + pGS->SaveGraphState(); + if (stroke.IsCorner() && fThickness > 2 * stroke.GetRadius()) { + fThickness = 2 * stroke.GetRadius(); + } + pGS->SetLineWidth(fThickness, true); + pGS->SetLineCap(CFX_GraphStateData::LineCapButt); + XFA_StrokeTypeSetLineDash(pGS, stroke.GetStrokeType(), + XFA_ATTRIBUTEENUM_Butt); + CFX_Color fxColor(stroke.GetColor()); + pGS->SetStrokeColor(&fxColor); + pGS->StrokePath(pPath, pMatrix); + pGS->RestoreGraphState(); +} +static void XFA_BOX_StrokeArc(CXFA_Box box, + CFX_Graphics* pGS, + CFX_RectF rtWidget, + CFX_Matrix* pMatrix, + uint32_t dwFlags) { + CXFA_Edge edge = box.GetEdge(0); + if (!edge || !edge.IsVisible()) { + return; + } + bool bVisible = false; + float fThickness = 0; + int32_t i3DType = box.Get3DStyle(bVisible, fThickness); + if (i3DType) { + if (bVisible && fThickness >= 0.001f) { + dwFlags |= XFA_DRAWBOX_Lowered3D; + } + } + float fHalf = edge.GetThickness() / 2; + if (fHalf < 0) { + fHalf = 0; + } + int32_t iHand = box.GetHand(); + if (iHand == XFA_ATTRIBUTEENUM_Left) { + rtWidget.Inflate(fHalf, fHalf); + } else if (iHand == XFA_ATTRIBUTEENUM_Right) { + rtWidget.Deflate(fHalf, fHalf); + } + if ((dwFlags & XFA_DRAWBOX_ForceRound) == 0 || + (dwFlags & XFA_DRAWBOX_Lowered3D) == 0) { + if (fHalf < 0.001f) + return; + + CFX_Path arcPath; + XFA_BOX_GetPath_Arc(box, rtWidget, arcPath, dwFlags); + XFA_BOX_StrokePath(edge, &arcPath, pGS, pMatrix); + return; + } + pGS->SaveGraphState(); + pGS->SetLineWidth(fHalf); + + float a, b; + a = rtWidget.width / 2.0f; + b = rtWidget.height / 2.0f; + if (dwFlags & XFA_DRAWBOX_ForceRound) { + a = std::min(a, b); + b = a; + } + + CFX_PointF center = rtWidget.Center(); + rtWidget.left = center.x - a; + rtWidget.top = center.y - b; + rtWidget.width = a + a; + rtWidget.height = b + b; + + float startAngle = 0, sweepAngle = 360; + startAngle = startAngle * FX_PI / 180.0f; + sweepAngle = -sweepAngle * FX_PI / 180.0f; + + CFX_Path arcPath; + arcPath.AddArc(rtWidget.TopLeft(), rtWidget.Size(), 3.0f * FX_PI / 4.0f, + FX_PI); + + CFX_Color cr(0xFF808080); + pGS->SetStrokeColor(&cr); + pGS->StrokePath(&arcPath, pMatrix); + arcPath.Clear(); + arcPath.AddArc(rtWidget.TopLeft(), rtWidget.Size(), -1.0f * FX_PI / 4.0f, + FX_PI); + + cr.Set(0xFFFFFFFF); + pGS->SetStrokeColor(&cr); + pGS->StrokePath(&arcPath, pMatrix); + rtWidget.Deflate(fHalf, fHalf); + arcPath.Clear(); + arcPath.AddArc(rtWidget.TopLeft(), rtWidget.Size(), 3.0f * FX_PI / 4.0f, + FX_PI); + + cr.Set(0xFF404040); + pGS->SetStrokeColor(&cr); + pGS->StrokePath(&arcPath, pMatrix); + arcPath.Clear(); + arcPath.AddArc(rtWidget.TopLeft(), rtWidget.Size(), -1.0f * FX_PI / 4.0f, + FX_PI); + + cr.Set(0xFFC0C0C0); + pGS->SetStrokeColor(&cr); + pGS->StrokePath(&arcPath, pMatrix); + pGS->RestoreGraphState(); +} +static void XFA_Draw3DRect(CFX_Graphics* pGraphic, + const CFX_RectF& rt, + float fLineWidth, + CFX_Matrix* pMatrix, + FX_ARGB argbTopLeft, + FX_ARGB argbBottomRight) { + CFX_Color crLT(argbTopLeft); + pGraphic->SetFillColor(&crLT); + float fBottom = rt.bottom(); + float fRight = rt.right(); + CFX_Path pathLT; + pathLT.MoveTo(CFX_PointF(rt.left, fBottom)); + pathLT.LineTo(CFX_PointF(rt.left, rt.top)); + pathLT.LineTo(CFX_PointF(fRight, rt.top)); + pathLT.LineTo(CFX_PointF(fRight - fLineWidth, rt.top + fLineWidth)); + pathLT.LineTo(CFX_PointF(rt.left + fLineWidth, rt.top + fLineWidth)); + pathLT.LineTo(CFX_PointF(rt.left + fLineWidth, fBottom - fLineWidth)); + pathLT.LineTo(CFX_PointF(rt.left, fBottom)); + pGraphic->FillPath(&pathLT, FXFILL_WINDING, pMatrix); + + CFX_Color crRB(argbBottomRight); + pGraphic->SetFillColor(&crRB); + + CFX_Path pathRB; + pathRB.MoveTo(CFX_PointF(fRight, rt.top)); + pathRB.LineTo(CFX_PointF(fRight, fBottom)); + pathRB.LineTo(CFX_PointF(rt.left, fBottom)); + pathRB.LineTo(CFX_PointF(rt.left + fLineWidth, fBottom - fLineWidth)); + pathRB.LineTo(CFX_PointF(fRight - fLineWidth, fBottom - fLineWidth)); + pathRB.LineTo(CFX_PointF(fRight - fLineWidth, rt.top + fLineWidth)); + pathRB.LineTo(CFX_PointF(fRight, rt.top)); + pGraphic->FillPath(&pathRB, FXFILL_WINDING, pMatrix); +} +static void XFA_BOX_Stroke_3DRect_Lowered(CFX_Graphics* pGS, + CFX_RectF rt, + float fThickness, + CFX_Matrix* pMatrix) { + float fHalfWidth = fThickness / 2.0f; + CFX_RectF rtInner(rt); + rtInner.Deflate(fHalfWidth, fHalfWidth); + CFX_Color cr(0xFF000000); + pGS->SetFillColor(&cr); + CFX_Path path; + path.AddRectangle(rt.left, rt.top, rt.width, rt.height); + path.AddRectangle(rtInner.left, rtInner.top, rtInner.width, rtInner.height); + pGS->FillPath(&path, FXFILL_ALTERNATE, pMatrix); + XFA_Draw3DRect(pGS, rtInner, fHalfWidth, pMatrix, 0xFF808080, 0xFFC0C0C0); +} +static void XFA_BOX_Stroke_3DRect_Raised(CFX_Graphics* pGS, + CFX_RectF rt, + float fThickness, + CFX_Matrix* pMatrix) { + float fHalfWidth = fThickness / 2.0f; + CFX_RectF rtInner(rt); + rtInner.Deflate(fHalfWidth, fHalfWidth); + CFX_Color cr(0xFF000000); + pGS->SetFillColor(&cr); + CFX_Path path; + path.AddRectangle(rt.left, rt.top, rt.width, rt.height); + path.AddRectangle(rtInner.left, rtInner.top, rtInner.width, rtInner.height); + pGS->FillPath(&path, FXFILL_ALTERNATE, pMatrix); + XFA_Draw3DRect(pGS, rtInner, fHalfWidth, pMatrix, 0xFFFFFFFF, 0xFF808080); +} +static void XFA_BOX_Stroke_3DRect_Etched(CFX_Graphics* pGS, + CFX_RectF rt, + float fThickness, + CFX_Matrix* pMatrix) { + float fHalfWidth = fThickness / 2.0f; + XFA_Draw3DRect(pGS, rt, fThickness, pMatrix, 0xFF808080, 0xFFFFFFFF); + CFX_RectF rtInner(rt); + rtInner.Deflate(fHalfWidth, fHalfWidth); + XFA_Draw3DRect(pGS, rtInner, fHalfWidth, pMatrix, 0xFFFFFFFF, 0xFF808080); +} +static void XFA_BOX_Stroke_3DRect_Embossed(CFX_Graphics* pGS, + CFX_RectF rt, + float fThickness, + CFX_Matrix* pMatrix) { + float fHalfWidth = fThickness / 2.0f; + XFA_Draw3DRect(pGS, rt, fThickness, pMatrix, 0xFF808080, 0xFF000000); + CFX_RectF rtInner(rt); + rtInner.Deflate(fHalfWidth, fHalfWidth); + XFA_Draw3DRect(pGS, rtInner, fHalfWidth, pMatrix, 0xFF000000, 0xFF808080); +} +static void XFA_BOX_Stroke_Rect(CXFA_Box box, + const std::vector& strokes, + CFX_Graphics* pGS, + CFX_RectF rtWidget, + CFX_Matrix* pMatrix) { + bool bVisible = false; + float fThickness = 0; + int32_t i3DType = box.Get3DStyle(bVisible, fThickness); + if (i3DType) { + if (!bVisible || fThickness < 0.001f) { + return; + } + switch (i3DType) { + case XFA_ATTRIBUTEENUM_Lowered: + XFA_BOX_Stroke_3DRect_Lowered(pGS, rtWidget, fThickness, pMatrix); + break; + case XFA_ATTRIBUTEENUM_Raised: + XFA_BOX_Stroke_3DRect_Raised(pGS, rtWidget, fThickness, pMatrix); + break; + case XFA_ATTRIBUTEENUM_Etched: + XFA_BOX_Stroke_3DRect_Etched(pGS, rtWidget, fThickness, pMatrix); + break; + case XFA_ATTRIBUTEENUM_Embossed: + XFA_BOX_Stroke_3DRect_Embossed(pGS, rtWidget, fThickness, pMatrix); + break; + } + return; + } + bool bClose = false; + bool bSameStyles = true; + CXFA_Stroke stroke1 = strokes[0]; + for (int32_t i = 1; i < 8; i++) { + CXFA_Stroke stroke2 = strokes[i]; + if (!stroke1.SameStyles(stroke2)) { + bSameStyles = false; + break; + } + stroke1 = stroke2; + } + if (bSameStyles) { + stroke1 = strokes[0]; + bClose = true; + for (int32_t i = 2; i < 8; i += 2) { + CXFA_Stroke stroke2 = strokes[i]; + if (!stroke1.SameStyles(stroke2, XFA_STROKE_SAMESTYLE_NoPresence | + XFA_STROKE_SAMESTYLE_Corner)) { + bSameStyles = false; + break; + } + stroke1 = stroke2; + } + if (bSameStyles) { + stroke1 = strokes[0]; + if (stroke1.IsInverted()) + bSameStyles = false; + if (stroke1.GetJoinType() != XFA_ATTRIBUTEENUM_Square) + bSameStyles = false; + } + } + bool bStart = true; + CFX_Path path; + for (int32_t i = 0; i < 8; i++) { + CXFA_Stroke stroke = strokes[i]; + if ((i % 1) == 0 && stroke.GetRadius() < 0) { + bool bEmpty = path.IsEmpty(); + if (!bEmpty) { + XFA_BOX_StrokePath(stroke, &path, pGS, pMatrix); + path.Clear(); + } + bStart = true; + continue; + } + XFA_BOX_GetPath(box, strokes, rtWidget, path, i, bStart, !bSameStyles); + CXFA_Stroke stroke2 = strokes[(i + 1) % 8]; + bStart = !stroke.SameStyles(stroke2); + if (bStart) { + XFA_BOX_StrokePath(stroke, &path, pGS, pMatrix); + path.Clear(); + } + } + bool bEmpty = path.IsEmpty(); + if (!bEmpty) { + if (bClose) { + path.Close(); + } + XFA_BOX_StrokePath(strokes[7], &path, pGS, pMatrix); + } +} +static void XFA_BOX_Stroke(CXFA_Box box, + const std::vector& strokes, + CFX_Graphics* pGS, + CFX_RectF rtWidget, + CFX_Matrix* pMatrix, + uint32_t dwFlags) { + if (box.IsArc() || (dwFlags & XFA_DRAWBOX_ForceRound) != 0) { + XFA_BOX_StrokeArc(box, pGS, rtWidget, pMatrix, dwFlags); + return; + } + bool bVisible = false; + for (int32_t j = 0; j < 4; j++) { + if (strokes[j * 2 + 1].IsVisible()) { + bVisible = true; + break; + } + } + if (!bVisible) { + return; + } + for (int32_t i = 1; i < 8; i += 2) { + CXFA_Edge edge(strokes[i].GetNode()); + float fThickness = edge.GetThickness(); + if (fThickness < 0) { + fThickness = 0; + } + float fHalf = fThickness / 2; + int32_t iHand = box.GetHand(); + switch (i) { + case 1: + if (iHand == XFA_ATTRIBUTEENUM_Left) { + rtWidget.top -= fHalf; + rtWidget.height += fHalf; + } else if (iHand == XFA_ATTRIBUTEENUM_Right) { + rtWidget.top += fHalf; + rtWidget.height -= fHalf; + } + break; + case 3: + if (iHand == XFA_ATTRIBUTEENUM_Left) { + rtWidget.width += fHalf; + } else if (iHand == XFA_ATTRIBUTEENUM_Right) { + rtWidget.width -= fHalf; + } + break; + case 5: + if (iHand == XFA_ATTRIBUTEENUM_Left) { + rtWidget.height += fHalf; + } else if (iHand == XFA_ATTRIBUTEENUM_Right) { + rtWidget.height -= fHalf; + } + break; + case 7: + if (iHand == XFA_ATTRIBUTEENUM_Left) { + rtWidget.left -= fHalf; + rtWidget.width += fHalf; + } else if (iHand == XFA_ATTRIBUTEENUM_Right) { + rtWidget.left += fHalf; + rtWidget.width -= fHalf; + } + break; + } + } + XFA_BOX_Stroke_Rect(box, strokes, pGS, rtWidget, pMatrix); +} +void XFA_DrawBox(CXFA_Box box, + CFX_Graphics* pGS, + const CFX_RectF& rtWidget, + CFX_Matrix* pMatrix, + uint32_t dwFlags) { + if (!box || box.GetPresence() != XFA_ATTRIBUTEENUM_Visible) + return; + + XFA_Element eType = box.GetElementType(); + if (eType != XFA_Element::Arc && eType != XFA_Element::Border && + eType != XFA_Element::Rectangle) { + return; + } + std::vector strokes; + if (!(dwFlags & XFA_DRAWBOX_ForceRound) && eType != XFA_Element::Arc) + box.GetStrokes(&strokes); + + XFA_BOX_Fill(box, strokes, pGS, rtWidget, pMatrix, dwFlags); + XFA_BOX_Stroke(box, strokes, pGS, rtWidget, pMatrix, dwFlags); +} + +CXFA_CalcData::CXFA_CalcData() : m_iRefCount(0) {} + +CXFA_CalcData::~CXFA_CalcData() {} diff --git a/xfa/fxfa/cxfa_ffwidget.h b/xfa/fxfa/cxfa_ffwidget.h new file mode 100644 index 0000000000..02a7b21b15 --- /dev/null +++ b/xfa/fxfa/cxfa_ffwidget.h @@ -0,0 +1,190 @@ +// 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_CXFA_FFWIDGET_H_ +#define XFA_FXFA_CXFA_FFWIDGET_H_ + +#include + +#include "core/fxcodec/fx_codec_def.h" +#include "core/fxge/cfx_graphstatedata.h" +#include "xfa/fwl/cfwl_app.h" +#include "xfa/fxfa/fxfa.h" +#include "xfa/fxfa/parser/cxfa_contentlayoutitem.h" + +class CXFA_FFPageView; +class CXFA_FFDocView; +class CXFA_FFDoc; +class CXFA_FFApp; +enum class FWL_WidgetHit; + +inline float XFA_UnitPx2Pt(float fPx, float fDpi) { + return fPx * 72.0f / fDpi; +} + +#define XFA_FLOAT_PERCISION 0.001f + +enum XFA_WIDGETITEM { + XFA_WIDGETITEM_Parent, + XFA_WIDGETITEM_FirstChild, + XFA_WIDGETITEM_NextSibling, + XFA_WIDGETITEM_PrevSibling, +}; + +int32_t XFA_StrokeTypeSetLineDash(CFX_Graphics* pGraphics, + int32_t iStrokeType, + int32_t iCapType); +CFX_GraphStateData::LineCap XFA_LineCapToFXGE(int32_t iLineCap); +void XFA_DrawImage(CFX_Graphics* pGS, + const CFX_RectF& rtImage, + CFX_Matrix* pMatrix, + CFX_DIBitmap* pDIBitmap, + int32_t iAspect, + int32_t iImageXDpi, + int32_t iImageYDpi, + int32_t iHorzAlign = XFA_ATTRIBUTEENUM_Left, + int32_t iVertAlign = XFA_ATTRIBUTEENUM_Top); + +CFX_DIBitmap* XFA_LoadImageData(CXFA_FFDoc* pDoc, + CXFA_Image* pImage, + bool& bNameImage, + int32_t& iImageXDpi, + int32_t& iImageYDpi); + +CFX_DIBitmap* XFA_LoadImageFromBuffer( + const CFX_RetainPtr& pImageFileRead, + FXCODEC_IMAGE_TYPE type, + int32_t& iImageXDpi, + int32_t& iImageYDpi); + +FXCODEC_IMAGE_TYPE XFA_GetImageType(const CFX_WideString& wsType); +char* XFA_Base64Encode(const uint8_t* buf, int32_t buf_len); +void XFA_RectWidthoutMargin(CFX_RectF& rt, + const CXFA_Margin& mg, + bool bUI = false); +CXFA_FFWidget* XFA_GetWidgetFromLayoutItem(CXFA_LayoutItem* pLayoutItem); +bool XFA_IsCreateWidget(XFA_Element iType); +#define XFA_DRAWBOX_ForceRound 1 +#define XFA_DRAWBOX_Lowered3D 2 +void XFA_DrawBox(CXFA_Box box, + CFX_Graphics* pGS, + const CFX_RectF& rtWidget, + CFX_Matrix* pMatrix, + uint32_t dwFlags = 0); + +class CXFA_CalcData { + public: + CXFA_CalcData(); + ~CXFA_CalcData(); + + std::vector m_Globals; + int32_t m_iRefCount; +}; + +class CXFA_FFWidget : public CXFA_ContentLayoutItem { + public: + explicit CXFA_FFWidget(CXFA_WidgetAcc* pDataAcc); + ~CXFA_FFWidget() override; + + virtual CFX_RectF GetBBox(uint32_t dwStatus, bool bDrawFocus = false); + virtual void RenderWidget(CFX_Graphics* pGS, + CFX_Matrix* pMatrix, + uint32_t dwStatus); + virtual bool IsLoaded(); + virtual bool LoadWidget(); + virtual void UnloadWidget(); + virtual bool PerformLayout(); + virtual bool UpdateFWLData(); + virtual void UpdateWidgetProperty(); + virtual bool OnMouseEnter(); + virtual bool OnMouseExit(); + virtual bool OnLButtonDown(uint32_t dwFlags, const CFX_PointF& point); + virtual bool OnLButtonUp(uint32_t dwFlags, const CFX_PointF& point); + virtual bool OnLButtonDblClk(uint32_t dwFlags, const CFX_PointF& point); + virtual bool OnMouseMove(uint32_t dwFlags, const CFX_PointF& point); + virtual bool OnMouseWheel(uint32_t dwFlags, + int16_t zDelta, + const CFX_PointF& point); + virtual bool OnRButtonDown(uint32_t dwFlags, const CFX_PointF& point); + virtual bool OnRButtonUp(uint32_t dwFlags, const CFX_PointF& point); + virtual bool OnRButtonDblClk(uint32_t dwFlags, const CFX_PointF& point); + + virtual bool OnSetFocus(CXFA_FFWidget* pOldWidget); + virtual bool OnKillFocus(CXFA_FFWidget* pNewWidget); + virtual bool OnKeyDown(uint32_t dwKeyCode, uint32_t dwFlags); + virtual bool OnKeyUp(uint32_t dwKeyCode, uint32_t dwFlags); + virtual bool OnChar(uint32_t dwChar, uint32_t dwFlags); + virtual FWL_WidgetHit OnHitTest(const CFX_PointF& point); + virtual bool OnSetCursor(const CFX_PointF& point); + virtual bool CanUndo(); + virtual bool CanRedo(); + virtual bool Undo(); + virtual bool Redo(); + virtual bool CanCopy(); + virtual bool CanCut(); + virtual bool CanPaste(); + virtual bool CanSelectAll(); + virtual bool CanDelete(); + virtual bool CanDeSelect(); + virtual bool Copy(CFX_WideString& wsCopy); + virtual bool Cut(CFX_WideString& wsCut); + virtual bool Paste(const CFX_WideString& wsPaste); + virtual void SelectAll(); + virtual void Delete(); + virtual void DeSelect(); + virtual bool GetSuggestWords(CFX_PointF pointf, + std::vector& sSuggest); + virtual bool ReplaceSpellCheckWord(CFX_PointF pointf, + const CFX_ByteStringC& bsReplace); + + CXFA_FFPageView* GetPageView() const { return m_pPageView; } + void SetPageView(CXFA_FFPageView* pPageView) { m_pPageView = pPageView; } + CFX_RectF GetWidgetRect(); + CFX_RectF RecacheWidgetRect(); + uint32_t GetStatus(); + void ModifyStatus(uint32_t dwAdded, uint32_t dwRemoved); + + CXFA_WidgetAcc* GetDataAcc(); + bool GetToolTip(CFX_WideString& wsToolTip); + + CXFA_FFDocView* GetDocView(); + void SetDocView(CXFA_FFDocView* pDocView); + CXFA_FFDoc* GetDoc(); + CXFA_FFApp* GetApp(); + IXFA_AppProvider* GetAppProvider(); + void InvalidateWidget(const CFX_RectF* pRect = nullptr); + void AddInvalidateRect(const CFX_RectF* pRect = nullptr); + bool GetCaptionText(CFX_WideString& wsCap); + bool IsFocused(); + CFX_PointF Rotate2Normal(const CFX_PointF& point); + CFX_Matrix GetRotateMatrix(); + bool IsLayoutRectEmpty(); + CXFA_FFWidget* GetParent(); + bool IsAncestorOf(CXFA_FFWidget* pWidget); + const CFWL_App* GetFWLApp(); + + protected: + virtual bool PtInActiveRect(const CFX_PointF& point); + + void DrawBorder(CFX_Graphics* pGS, + CXFA_Box box, + const CFX_RectF& rtBorder, + CFX_Matrix* pMatrix, + uint32_t dwFlags = 0); + + CFX_RectF GetRectWithoutRotate(); + bool IsMatchVisibleStatus(uint32_t dwStatus); + void EventKillFocus(); + bool IsButtonDown(); + void SetButtonDown(bool bSet); + + CXFA_FFDocView* m_pDocView; + CXFA_FFPageView* m_pPageView; + CXFA_WidgetAcc* m_pDataAcc; + CFX_RectF m_rtWidget; +}; + +#endif // XFA_FXFA_CXFA_FFWIDGET_H_ diff --git a/xfa/fxfa/cxfa_ffwidgethandler.cpp b/xfa/fxfa/cxfa_ffwidgethandler.cpp new file mode 100644 index 0000000000..0af69da016 --- /dev/null +++ b/xfa/fxfa/cxfa_ffwidgethandler.cpp @@ -0,0 +1,523 @@ +// 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 + +#include "xfa/fxfa/cxfa_ffwidgethandler.h" + +#include + +#include "xfa/fxfa/app/xfa_ffchoicelist.h" +#include "xfa/fxfa/app/xfa_fffield.h" +#include "xfa/fxfa/app/xfa_fwladapter.h" +#include "xfa/fxfa/cxfa_ffdoc.h" +#include "xfa/fxfa/cxfa_ffdocview.h" +#include "xfa/fxfa/cxfa_ffwidget.h" +#include "xfa/fxfa/parser/cxfa_layoutprocessor.h" +#include "xfa/fxfa/parser/cxfa_measurement.h" + +CXFA_FFWidgetHandler::CXFA_FFWidgetHandler(CXFA_FFDocView* pDocView) + : m_pDocView(pDocView) {} + +CXFA_FFWidgetHandler::~CXFA_FFWidgetHandler() {} + +bool CXFA_FFWidgetHandler::OnMouseEnter(CXFA_FFWidget* hWidget) { + m_pDocView->LockUpdate(); + bool bRet = hWidget->OnMouseEnter(); + m_pDocView->UnlockUpdate(); + m_pDocView->UpdateDocView(); + return bRet; +} + +bool CXFA_FFWidgetHandler::OnMouseExit(CXFA_FFWidget* hWidget) { + m_pDocView->LockUpdate(); + bool bRet = hWidget->OnMouseExit(); + m_pDocView->UnlockUpdate(); + m_pDocView->UpdateDocView(); + return bRet; +} + +bool CXFA_FFWidgetHandler::OnLButtonDown(CXFA_FFWidget* hWidget, + uint32_t dwFlags, + const CFX_PointF& point) { + m_pDocView->LockUpdate(); + bool bRet = hWidget->OnLButtonDown(dwFlags, hWidget->Rotate2Normal(point)); + if (bRet && m_pDocView->SetFocus(hWidget)) { + m_pDocView->GetDoc()->GetDocEnvironment()->SetFocusWidget( + m_pDocView->GetDoc(), hWidget); + } + m_pDocView->UnlockUpdate(); + m_pDocView->UpdateDocView(); + return bRet; +} + +bool CXFA_FFWidgetHandler::OnLButtonUp(CXFA_FFWidget* hWidget, + uint32_t dwFlags, + const CFX_PointF& point) { + m_pDocView->LockUpdate(); + m_pDocView->m_bLayoutEvent = true; + bool bRet = hWidget->OnLButtonUp(dwFlags, hWidget->Rotate2Normal(point)); + m_pDocView->UnlockUpdate(); + m_pDocView->UpdateDocView(); + return bRet; +} + +bool CXFA_FFWidgetHandler::OnLButtonDblClk(CXFA_FFWidget* hWidget, + uint32_t dwFlags, + const CFX_PointF& point) { + bool bRet = hWidget->OnLButtonDblClk(dwFlags, hWidget->Rotate2Normal(point)); + m_pDocView->RunInvalidate(); + return bRet; +} + +bool CXFA_FFWidgetHandler::OnMouseMove(CXFA_FFWidget* hWidget, + uint32_t dwFlags, + const CFX_PointF& point) { + bool bRet = hWidget->OnMouseMove(dwFlags, hWidget->Rotate2Normal(point)); + m_pDocView->RunInvalidate(); + return bRet; +} + +bool CXFA_FFWidgetHandler::OnMouseWheel(CXFA_FFWidget* hWidget, + uint32_t dwFlags, + int16_t zDelta, + const CFX_PointF& point) { + bool bRet = + hWidget->OnMouseWheel(dwFlags, zDelta, hWidget->Rotate2Normal(point)); + m_pDocView->RunInvalidate(); + return bRet; +} + +bool CXFA_FFWidgetHandler::OnRButtonDown(CXFA_FFWidget* hWidget, + uint32_t dwFlags, + const CFX_PointF& point) { + bool bRet = hWidget->OnRButtonDown(dwFlags, hWidget->Rotate2Normal(point)); + if (bRet && m_pDocView->SetFocus(hWidget)) { + m_pDocView->GetDoc()->GetDocEnvironment()->SetFocusWidget( + m_pDocView->GetDoc(), hWidget); + } + m_pDocView->RunInvalidate(); + return bRet; +} + +bool CXFA_FFWidgetHandler::OnRButtonUp(CXFA_FFWidget* hWidget, + uint32_t dwFlags, + const CFX_PointF& point) { + bool bRet = hWidget->OnRButtonUp(dwFlags, hWidget->Rotate2Normal(point)); + m_pDocView->RunInvalidate(); + return bRet; +} + +bool CXFA_FFWidgetHandler::OnRButtonDblClk(CXFA_FFWidget* hWidget, + uint32_t dwFlags, + const CFX_PointF& point) { + bool bRet = hWidget->OnRButtonDblClk(dwFlags, hWidget->Rotate2Normal(point)); + m_pDocView->RunInvalidate(); + return bRet; +} + +bool CXFA_FFWidgetHandler::OnKeyDown(CXFA_FFWidget* hWidget, + uint32_t dwKeyCode, + uint32_t dwFlags) { + bool bRet = hWidget->OnKeyDown(dwKeyCode, dwFlags); + m_pDocView->RunInvalidate(); + m_pDocView->UpdateDocView(); + return bRet; +} + +bool CXFA_FFWidgetHandler::OnKeyUp(CXFA_FFWidget* hWidget, + uint32_t dwKeyCode, + uint32_t dwFlags) { + bool bRet = hWidget->OnKeyUp(dwKeyCode, dwFlags); + m_pDocView->RunInvalidate(); + return bRet; +} + +bool CXFA_FFWidgetHandler::OnChar(CXFA_FFWidget* hWidget, + uint32_t dwChar, + uint32_t dwFlags) { + bool bRet = hWidget->OnChar(dwChar, dwFlags); + m_pDocView->RunInvalidate(); + return bRet; +} + +FWL_WidgetHit CXFA_FFWidgetHandler::OnHitTest(CXFA_FFWidget* hWidget, + const CFX_PointF& point) { + if (!(hWidget->GetStatus() & XFA_WidgetStatus_Visible)) + return FWL_WidgetHit::Unknown; + return hWidget->OnHitTest(hWidget->Rotate2Normal(point)); +} + +bool CXFA_FFWidgetHandler::OnSetCursor(CXFA_FFWidget* hWidget, + const CFX_PointF& point) { + return hWidget->OnSetCursor(hWidget->Rotate2Normal(point)); +} + +void CXFA_FFWidgetHandler::RenderWidget(CXFA_FFWidget* hWidget, + CFX_Graphics* pGS, + CFX_Matrix* pMatrix, + bool bHighlight) { + hWidget->RenderWidget(pGS, pMatrix, + bHighlight ? XFA_WidgetStatus_Highlight : 0); +} + +bool CXFA_FFWidgetHandler::HasEvent(CXFA_WidgetAcc* pWidgetAcc, + XFA_EVENTTYPE eEventType) { + if (eEventType == XFA_EVENT_Unknown) + return false; + + if (!pWidgetAcc || pWidgetAcc->GetElementType() == XFA_Element::Draw) + return false; + + switch (eEventType) { + case XFA_EVENT_Calculate: { + CXFA_Calculate calc = pWidgetAcc->GetCalculate(); + return calc && calc.GetScript(); + } + case XFA_EVENT_Validate: { + CXFA_Validate val = pWidgetAcc->GetValidate(); + return val && val.GetScript(); + } + default: + break; + } + return !pWidgetAcc->GetEventByActivity(gs_EventActivity[eEventType]).empty(); +} + +int32_t CXFA_FFWidgetHandler::ProcessEvent(CXFA_WidgetAcc* pWidgetAcc, + CXFA_EventParam* pParam) { + if (!pParam || pParam->m_eType == XFA_EVENT_Unknown) + return XFA_EVENTERROR_NotExist; + if (!pWidgetAcc || pWidgetAcc->GetElementType() == XFA_Element::Draw) + return XFA_EVENTERROR_NotExist; + + switch (pParam->m_eType) { + case XFA_EVENT_Calculate: + return pWidgetAcc->ProcessCalculate(); + case XFA_EVENT_Validate: + if (m_pDocView->GetDoc()->GetDocEnvironment()->IsValidationsEnabled( + m_pDocView->GetDoc())) { + return pWidgetAcc->ProcessValidate(); + } + return XFA_EVENTERROR_Disabled; + case XFA_EVENT_InitCalculate: { + CXFA_Calculate calc = pWidgetAcc->GetCalculate(); + if (!calc) + return XFA_EVENTERROR_NotExist; + if (pWidgetAcc->GetNode()->IsUserInteractive()) + return XFA_EVENTERROR_Disabled; + + CXFA_Script script = calc.GetScript(); + return pWidgetAcc->ExecuteScript(script, pParam); + } + default: + break; + } + int32_t iRet = + pWidgetAcc->ProcessEvent(gs_EventActivity[pParam->m_eType], pParam); + return iRet; +} + +CXFA_FFWidget* CXFA_FFWidgetHandler::CreateWidget(CXFA_FFWidget* hParent, + XFA_WIDGETTYPE eType, + CXFA_FFWidget* hBefore) { + CXFA_Node* pParentFormItem = + hParent ? hParent->GetDataAcc()->GetNode() : nullptr; + CXFA_Node* pBeforeFormItem = + hBefore ? hBefore->GetDataAcc()->GetNode() : nullptr; + CXFA_Node* pNewFormItem = + CreateWidgetFormItem(eType, pParentFormItem, pBeforeFormItem); + if (!pNewFormItem) + return nullptr; + + pNewFormItem->GetTemplateNode()->SetFlag(XFA_NodeFlag_Initialized, true); + pNewFormItem->SetFlag(XFA_NodeFlag_Initialized, true); + m_pDocView->RunLayout(); + CXFA_LayoutItem* pLayout = + m_pDocView->GetXFALayout()->GetLayoutItem(pNewFormItem); + return static_cast(pLayout); +} + +CXFA_Node* CXFA_FFWidgetHandler::CreateWidgetFormItem( + XFA_WIDGETTYPE eType, + CXFA_Node* pParent, + CXFA_Node* pBefore) const { + switch (eType) { + case XFA_WIDGETTYPE_Barcode: + return nullptr; + case XFA_WIDGETTYPE_PushButton: + return CreatePushButton(pParent, pBefore); + case XFA_WIDGETTYPE_CheckButton: + return CreateCheckButton(pParent, pBefore); + case XFA_WIDGETTYPE_ExcludeGroup: + return CreateExclGroup(pParent, pBefore); + case XFA_WIDGETTYPE_RadioButton: + return CreateRadioButton(pParent, pBefore); + case XFA_WIDGETTYPE_Arc: + return CreateArc(pParent, pBefore); + case XFA_WIDGETTYPE_Rectangle: + return CreateRectangle(pParent, pBefore); + case XFA_WIDGETTYPE_Image: + return CreateImage(pParent, pBefore); + case XFA_WIDGETTYPE_Line: + return CreateLine(pParent, pBefore); + case XFA_WIDGETTYPE_Text: + return CreateText(pParent, pBefore); + case XFA_WIDGETTYPE_DatetimeEdit: + return CreateDatetimeEdit(pParent, pBefore); + case XFA_WIDGETTYPE_DecimalField: + return CreateDecimalField(pParent, pBefore); + case XFA_WIDGETTYPE_NumericField: + return CreateNumericField(pParent, pBefore); + case XFA_WIDGETTYPE_Signature: + return CreateSignature(pParent, pBefore); + case XFA_WIDGETTYPE_TextEdit: + return CreateTextEdit(pParent, pBefore); + case XFA_WIDGETTYPE_DropdownList: + return CreateDropdownList(pParent, pBefore); + case XFA_WIDGETTYPE_ListBox: + return CreateListBox(pParent, pBefore); + case XFA_WIDGETTYPE_ImageField: + return CreateImageField(pParent, pBefore); + case XFA_WIDGETTYPE_PasswordEdit: + return CreatePasswordEdit(pParent, pBefore); + case XFA_WIDGETTYPE_Subform: + return CreateSubform(pParent, pBefore); + default: + return nullptr; + } +} + +CXFA_Node* CXFA_FFWidgetHandler::CreatePushButton(CXFA_Node* pParent, + CXFA_Node* pBefore) const { + CXFA_Node* pField = CreateField(XFA_Element::Button, pParent, pBefore); + CXFA_Node* pCaption = CreateCopyNode(XFA_Element::Caption, pField); + CXFA_Node* pValue = CreateCopyNode(XFA_Element::Value, pCaption); + CXFA_Node* pText = CreateCopyNode(XFA_Element::Text, pValue); + pText->SetContent(L"Button", L"Button", false); + + CXFA_Node* pPara = CreateCopyNode(XFA_Element::Para, pCaption); + pPara->SetEnum(XFA_ATTRIBUTE_VAlign, XFA_ATTRIBUTEENUM_Middle, false); + pPara->SetEnum(XFA_ATTRIBUTE_HAlign, XFA_ATTRIBUTEENUM_Center, false); + CreateFontNode(pCaption); + + CXFA_Node* pBorder = CreateCopyNode(XFA_Element::Border, pField); + pBorder->SetEnum(XFA_ATTRIBUTE_Hand, XFA_ATTRIBUTEENUM_Right, false); + + CXFA_Node* pEdge = CreateCopyNode(XFA_Element::Edge, pBorder); + pEdge->SetEnum(XFA_ATTRIBUTE_Stroke, XFA_ATTRIBUTEENUM_Raised, false); + + CXFA_Node* pFill = CreateCopyNode(XFA_Element::Fill, pBorder); + CXFA_Node* pColor = CreateCopyNode(XFA_Element::Color, pFill); + pColor->SetCData(XFA_ATTRIBUTE_Value, L"212, 208, 200", false); + + CXFA_Node* pBind = CreateCopyNode(XFA_Element::Bind, pField); + pBind->SetEnum(XFA_ATTRIBUTE_Match, XFA_ATTRIBUTEENUM_None); + + return pField; +} + +CXFA_Node* CXFA_FFWidgetHandler::CreateCheckButton(CXFA_Node* pParent, + CXFA_Node* pBefore) const { + return CreateField(XFA_Element::CheckButton, pParent, pBefore); +} + +CXFA_Node* CXFA_FFWidgetHandler::CreateExclGroup(CXFA_Node* pParent, + CXFA_Node* pBefore) const { + return CreateFormItem(XFA_Element::ExclGroup, pParent, pBefore); +} + +CXFA_Node* CXFA_FFWidgetHandler::CreateRadioButton(CXFA_Node* pParent, + CXFA_Node* pBefore) const { + CXFA_Node* pField = CreateField(XFA_Element::CheckButton, pParent, pBefore); + CXFA_Node* pUi = pField->GetFirstChildByClass(XFA_Element::Ui); + CXFA_Node* pWidget = pUi->GetFirstChildByClass(XFA_Element::CheckButton); + pWidget->SetEnum(XFA_ATTRIBUTE_Shape, XFA_ATTRIBUTEENUM_Round); + return pField; +} + +CXFA_Node* CXFA_FFWidgetHandler::CreateDatetimeEdit(CXFA_Node* pParent, + CXFA_Node* pBefore) const { + CXFA_Node* pField = CreateField(XFA_Element::DateTimeEdit, pParent, pBefore); + CreateValueNode(XFA_Element::Date, pField); + return pField; +} + +CXFA_Node* CXFA_FFWidgetHandler::CreateDecimalField(CXFA_Node* pParent, + CXFA_Node* pBefore) const { + CXFA_Node* pField = CreateNumericField(pParent, pBefore); + CreateValueNode(XFA_Element::Decimal, pField); + return pField; +} + +CXFA_Node* CXFA_FFWidgetHandler::CreateNumericField(CXFA_Node* pParent, + CXFA_Node* pBefore) const { + return CreateField(XFA_Element::NumericEdit, pParent, pBefore); +} + +CXFA_Node* CXFA_FFWidgetHandler::CreateSignature(CXFA_Node* pParent, + CXFA_Node* pBefore) const { + return CreateField(XFA_Element::Signature, pParent, pBefore); +} + +CXFA_Node* CXFA_FFWidgetHandler::CreateTextEdit(CXFA_Node* pParent, + CXFA_Node* pBefore) const { + return CreateField(XFA_Element::TextEdit, pParent, pBefore); +} + +CXFA_Node* CXFA_FFWidgetHandler::CreateDropdownList(CXFA_Node* pParent, + CXFA_Node* pBefore) const { + return CreateField(XFA_Element::ChoiceList, pParent, pBefore); +} + +CXFA_Node* CXFA_FFWidgetHandler::CreateListBox(CXFA_Node* pParent, + CXFA_Node* pBefore) const { + CXFA_Node* pField = CreateDropdownList(pParent, pBefore); + CXFA_Node* pUi = pField->GetNodeItem(XFA_NODEITEM_FirstChild); + CXFA_Node* pListBox = pUi->GetNodeItem(XFA_NODEITEM_FirstChild); + pListBox->SetEnum(XFA_ATTRIBUTE_Open, XFA_ATTRIBUTEENUM_Always); + pListBox->SetEnum(XFA_ATTRIBUTE_CommitOn, XFA_ATTRIBUTEENUM_Exit); + return pField; +} + +CXFA_Node* CXFA_FFWidgetHandler::CreateImageField(CXFA_Node* pParent, + CXFA_Node* pBefore) const { + return CreateField(XFA_Element::ImageEdit, pParent, pBefore); +} + +CXFA_Node* CXFA_FFWidgetHandler::CreatePasswordEdit(CXFA_Node* pParent, + CXFA_Node* pBefore) const { + CXFA_Node* pField = CreateField(XFA_Element::PasswordEdit, pParent, pBefore); + CXFA_Node* pBind = CreateCopyNode(XFA_Element::Bind, pField); + pBind->SetEnum(XFA_ATTRIBUTE_Match, XFA_ATTRIBUTEENUM_None, false); + return pField; +} + +CXFA_Node* CXFA_FFWidgetHandler::CreateField(XFA_Element eElement, + CXFA_Node* pParent, + CXFA_Node* pBefore) const { + CXFA_Node* pField = CreateFormItem(XFA_Element::Field, pParent, pBefore); + CreateCopyNode(eElement, CreateCopyNode(XFA_Element::Ui, pField)); + CreateFontNode(pField); + return pField; +} + +CXFA_Node* CXFA_FFWidgetHandler::CreateArc(CXFA_Node* pParent, + CXFA_Node* pBefore) const { + return CreateDraw(XFA_Element::Arc, pParent, pBefore); +} + +CXFA_Node* CXFA_FFWidgetHandler::CreateRectangle(CXFA_Node* pParent, + CXFA_Node* pBefore) const { + return CreateDraw(XFA_Element::Rectangle, pParent, pBefore); +} + +CXFA_Node* CXFA_FFWidgetHandler::CreateImage(CXFA_Node* pParent, + CXFA_Node* pBefore) const { + CXFA_Node* pField = CreateDraw(XFA_Element::Image, pParent, pBefore); + CreateCopyNode(XFA_Element::ImageEdit, + CreateCopyNode(XFA_Element::Ui, pField)); + return pField; +} + +CXFA_Node* CXFA_FFWidgetHandler::CreateLine(CXFA_Node* pParent, + CXFA_Node* pBefore) const { + return CreateDraw(XFA_Element::Line, pParent, pBefore); +} + +CXFA_Node* CXFA_FFWidgetHandler::CreateText(CXFA_Node* pParent, + CXFA_Node* pBefore) const { + CXFA_Node* pField = CreateDraw(XFA_Element::Text, pParent, pBefore); + CreateCopyNode(XFA_Element::TextEdit, + CreateCopyNode(XFA_Element::Ui, pField)); + CreateFontNode(pField); + return pField; +} + +CXFA_Node* CXFA_FFWidgetHandler::CreateDraw(XFA_Element eElement, + CXFA_Node* pParent, + CXFA_Node* pBefore) const { + CXFA_Node* pDraw = CreateFormItem(XFA_Element::Draw, pParent, pBefore); + CreateValueNode(eElement, pDraw); + return pDraw; +} + +CXFA_Node* CXFA_FFWidgetHandler::CreateSubform(CXFA_Node* pParent, + CXFA_Node* pBefore) const { + return CreateFormItem(XFA_Element::Subform, pParent, pBefore); +} + +CXFA_Node* CXFA_FFWidgetHandler::CreateFormItem(XFA_Element eElement, + CXFA_Node* pParent, + CXFA_Node* pBefore) const { + CXFA_Node* pTemplateParent = pParent ? pParent->GetTemplateNode() : nullptr; + CXFA_Node* pNewFormItem = pTemplateParent->CloneTemplateToForm(false); + if (pParent) + pParent->InsertChild(pNewFormItem, pBefore); + return pNewFormItem; +} + +CXFA_Node* CXFA_FFWidgetHandler::CreateCopyNode(XFA_Element eElement, + CXFA_Node* pParent, + CXFA_Node* pBefore) const { + CXFA_Node* pTemplateParent = pParent ? pParent->GetTemplateNode() : nullptr; + CXFA_Node* pNewNode = + CreateTemplateNode(eElement, pTemplateParent, + pBefore ? pBefore->GetTemplateNode() : nullptr) + ->Clone(false); + if (pParent) + pParent->InsertChild(pNewNode, pBefore); + return pNewNode; +} + +CXFA_Node* CXFA_FFWidgetHandler::CreateTemplateNode(XFA_Element eElement, + CXFA_Node* pParent, + CXFA_Node* pBefore) const { + CXFA_Document* pXFADoc = GetXFADoc(); + CXFA_Node* pNewTemplateNode = + pXFADoc->CreateNode(XFA_XDPPACKET_Template, eElement); + if (pParent) + pParent->InsertChild(pNewTemplateNode, pBefore); + return pNewTemplateNode; +} + +CXFA_Node* CXFA_FFWidgetHandler::CreateFontNode(CXFA_Node* pParent) const { + CXFA_Node* pFont = CreateCopyNode(XFA_Element::Font, pParent); + pFont->SetCData(XFA_ATTRIBUTE_Typeface, L"Myriad Pro", false); + return pFont; +} + +CXFA_Node* CXFA_FFWidgetHandler::CreateMarginNode(CXFA_Node* pParent, + uint32_t dwFlags, + float fInsets[4]) const { + CXFA_Node* pMargin = CreateCopyNode(XFA_Element::Margin, pParent); + if (dwFlags & 0x01) + pMargin->SetMeasure(XFA_ATTRIBUTE_LeftInset, + CXFA_Measurement(fInsets[0], XFA_UNIT_Pt), false); + if (dwFlags & 0x02) + pMargin->SetMeasure(XFA_ATTRIBUTE_TopInset, + CXFA_Measurement(fInsets[1], XFA_UNIT_Pt), false); + if (dwFlags & 0x04) + pMargin->SetMeasure(XFA_ATTRIBUTE_RightInset, + CXFA_Measurement(fInsets[2], XFA_UNIT_Pt), false); + if (dwFlags & 0x08) + pMargin->SetMeasure(XFA_ATTRIBUTE_BottomInset, + CXFA_Measurement(fInsets[3], XFA_UNIT_Pt), false); + return pMargin; +} + +CXFA_Node* CXFA_FFWidgetHandler::CreateValueNode(XFA_Element eValue, + CXFA_Node* pParent) const { + CXFA_Node* pValue = CreateCopyNode(XFA_Element::Value, pParent); + CreateCopyNode(eValue, pValue); + return pValue; +} + +CXFA_Document* CXFA_FFWidgetHandler::GetObjFactory() const { + return GetXFADoc(); +} + +CXFA_Document* CXFA_FFWidgetHandler::GetXFADoc() const { + return m_pDocView->GetDoc()->GetXFADoc(); +} diff --git a/xfa/fxfa/cxfa_ffwidgethandler.h b/xfa/fxfa/cxfa_ffwidgethandler.h new file mode 100644 index 0000000000..8f44dbbd45 --- /dev/null +++ b/xfa/fxfa/cxfa_ffwidgethandler.h @@ -0,0 +1,119 @@ +// 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_CXFA_FFWIDGETHANDLER_H_ +#define XFA_FXFA_CXFA_FFWIDGETHANDLER_H_ + +#include + +#include "xfa/fxfa/cxfa_eventparam.h" +#include "xfa/fxfa/fxfa.h" +#include "xfa/fxfa/parser/cxfa_document.h" + +class CXFA_FFDocView; +enum class FWL_WidgetHit; + +class CXFA_FFWidgetHandler { + public: + explicit CXFA_FFWidgetHandler(CXFA_FFDocView* pDocView); + ~CXFA_FFWidgetHandler(); + + CXFA_FFWidget* CreateWidget(CXFA_FFWidget* hParent, + XFA_WIDGETTYPE eType, + CXFA_FFWidget* hBefore = nullptr); + + bool OnMouseEnter(CXFA_FFWidget* hWidget); + bool OnMouseExit(CXFA_FFWidget* hWidget); + bool OnLButtonDown(CXFA_FFWidget* hWidget, + uint32_t dwFlags, + const CFX_PointF& point); + bool OnLButtonUp(CXFA_FFWidget* hWidget, + uint32_t dwFlags, + const CFX_PointF& point); + bool OnLButtonDblClk(CXFA_FFWidget* hWidget, + uint32_t dwFlags, + const CFX_PointF& point); + bool OnMouseMove(CXFA_FFWidget* hWidget, + uint32_t dwFlags, + const CFX_PointF& point); + bool OnMouseWheel(CXFA_FFWidget* hWidget, + uint32_t dwFlags, + int16_t zDelta, + const CFX_PointF& point); + bool OnRButtonDown(CXFA_FFWidget* hWidget, + uint32_t dwFlags, + const CFX_PointF& point); + bool OnRButtonUp(CXFA_FFWidget* hWidget, + uint32_t dwFlags, + const CFX_PointF& point); + bool OnRButtonDblClk(CXFA_FFWidget* hWidget, + uint32_t dwFlags, + const CFX_PointF& point); + + bool OnKeyDown(CXFA_FFWidget* hWidget, uint32_t dwKeyCode, uint32_t dwFlags); + bool OnKeyUp(CXFA_FFWidget* hWidget, uint32_t dwKeyCode, uint32_t dwFlags); + bool OnChar(CXFA_FFWidget* hWidget, uint32_t dwChar, uint32_t dwFlags); + FWL_WidgetHit OnHitTest(CXFA_FFWidget* hWidget, const CFX_PointF& point); + bool OnSetCursor(CXFA_FFWidget* hWidget, const CFX_PointF& point); + void RenderWidget(CXFA_FFWidget* hWidget, + CFX_Graphics* pGS, + CFX_Matrix* pMatrix, + bool bHighlight); + bool HasEvent(CXFA_WidgetAcc* pWidgetAcc, XFA_EVENTTYPE eEventType); + int32_t ProcessEvent(CXFA_WidgetAcc* pWidgetAcc, CXFA_EventParam* pParam); + + private: + CXFA_Node* CreateWidgetFormItem(XFA_WIDGETTYPE eType, + CXFA_Node* pParent, + CXFA_Node* pBefore) const; + + CXFA_Node* CreatePushButton(CXFA_Node* pParent, CXFA_Node* pBefore) const; + CXFA_Node* CreateCheckButton(CXFA_Node* pParent, CXFA_Node* pBefore) const; + CXFA_Node* CreateExclGroup(CXFA_Node* pParent, CXFA_Node* pBefore) const; + CXFA_Node* CreateRadioButton(CXFA_Node* pParent, CXFA_Node* pBefore) const; + CXFA_Node* CreateDatetimeEdit(CXFA_Node* pParent, CXFA_Node* pBefore) const; + CXFA_Node* CreateDecimalField(CXFA_Node* pParent, CXFA_Node* pBefore) const; + CXFA_Node* CreateNumericField(CXFA_Node* pParent, CXFA_Node* pBefore) const; + CXFA_Node* CreateSignature(CXFA_Node* pParent, CXFA_Node* pBefore) const; + CXFA_Node* CreateTextEdit(CXFA_Node* pParent, CXFA_Node* pBefore) const; + CXFA_Node* CreateDropdownList(CXFA_Node* pParent, CXFA_Node* pBefore) const; + CXFA_Node* CreateListBox(CXFA_Node* pParent, CXFA_Node* pBefore) const; + CXFA_Node* CreateImageField(CXFA_Node* pParent, CXFA_Node* pBefore) const; + CXFA_Node* CreatePasswordEdit(CXFA_Node* pParent, CXFA_Node* pBefore) const; + CXFA_Node* CreateField(XFA_Element eElement, + CXFA_Node* pParent, + CXFA_Node* pBefore) const; + CXFA_Node* CreateArc(CXFA_Node* pParent, CXFA_Node* pBefore) const; + CXFA_Node* CreateRectangle(CXFA_Node* pParent, CXFA_Node* pBefore) const; + CXFA_Node* CreateImage(CXFA_Node* pParent, CXFA_Node* pBefore) const; + CXFA_Node* CreateLine(CXFA_Node* pParent, CXFA_Node* pBefore) const; + CXFA_Node* CreateText(CXFA_Node* pParent, CXFA_Node* pBefore) const; + CXFA_Node* CreateDraw(XFA_Element eElement, + CXFA_Node* pParent, + CXFA_Node* pBefore) const; + + CXFA_Node* CreateSubform(CXFA_Node* pParent, CXFA_Node* pBefore) const; + CXFA_Node* CreateFormItem(XFA_Element eElement, + CXFA_Node* pParent, + CXFA_Node* pBefore) const; + CXFA_Node* CreateCopyNode(XFA_Element eElement, + CXFA_Node* pParent, + CXFA_Node* pBefore = nullptr) const; + CXFA_Node* CreateTemplateNode(XFA_Element eElement, + CXFA_Node* pParent, + CXFA_Node* pBefore) const; + CXFA_Node* CreateFontNode(CXFA_Node* pParent) const; + CXFA_Node* CreateMarginNode(CXFA_Node* pParent, + uint32_t dwFlags, + float fInsets[4]) const; + CXFA_Node* CreateValueNode(XFA_Element eValue, CXFA_Node* pParent) const; + CXFA_Document* GetObjFactory() const; + CXFA_Document* GetXFADoc() const; + + CXFA_FFDocView* m_pDocView; +}; + +#endif // XFA_FXFA_CXFA_FFWIDGETHANDLER_H_ diff --git a/xfa/fxfa/cxfa_fontmgr.cpp b/xfa/fxfa/cxfa_fontmgr.cpp new file mode 100644 index 0000000000..81e296f8a4 --- /dev/null +++ b/xfa/fxfa/cxfa_fontmgr.cpp @@ -0,0 +1,1797 @@ +// 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 + +#include "xfa/fxfa/cxfa_fontmgr.h" + +#include +#include +#include + +#include "core/fpdfapi/font/cpdf_font.h" +#include "core/fpdfapi/parser/cpdf_dictionary.h" +#include "core/fpdfapi/parser/cpdf_document.h" +#include "third_party/base/ptr_util.h" +#include "xfa/fgas/font/cfgas_gefont.h" +#include "xfa/fxfa/cxfa_ffapp.h" +#include "xfa/fxfa/cxfa_ffdoc.h" + +namespace { + +#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ +const XFA_FONTINFO g_XFAFontsMap[] = { + {0x01d5d33e, L"SimSun", L"Arial", 0, 936}, + {0x01e4f102, L"YouYuan", L"Arial", 1, 936}, + {0x030549dc, L"LiSu", L"Arial", 1, 936}, + {0x032edd44, L"Simhei", L"Arial", 1, 936}, + {0x03eac6fc, L"PoorRichard-Regular", L"Arial", 2, 1252}, + {0x03ed90e6, L"Nina", L"Arial", 0, 1252}, + {0x077b56b3, L"KingsoftPhoneticPlain", L"Arial", 0, 1252}, + {0x078ed524, L"MicrosoftSansSerif", L"Arial", 0, 1252}, + {0x089b18a9, L"Arial", L"Arial", 0, 1252}, + {0x0b2cad72, L"MonotypeCorsiva", L"Arial", 8, 1252}, + {0x0bb003e7, L"Kartika", L"Arial", 2, 1252}, + {0x0bb469df, L"VinerHandITC", L"Arial", 8, 1252}, + {0x0bc1a851, L"SegoeUI", L"Arial", 0, 1252}, + {0x0c112ebd, L"KozukaGothicPro-VIM", L"Arial", 0, 1252}, + {0x0cfcb9c1, L"AdobeThai", L"Kokila,Arial Narrow", 0, 847}, + {0x0e7de0f9, L"Playbill", L"Arial", 0, 1252}, + {0x0eff47c3, L"STHupo", L"Arial", 0, 936}, + {0x107ad374, L"Constantia", L"Arial", 2, 1252}, + {0x12194c2d, L"KunstlerScript", L"Arial", 8, 1252}, + {0x135ef6a1, L"MinionProSmBd", + L"Bell MT,Corbel,Times New Roman,Cambria,Berlin Sans FB", 0, 1252}, + {0x158c4049, L"Garamond", L"Arial", 2, 1252}, + {0x160ecb24, L"STZhongsong", L"Arial", 0, 936}, + {0x161ed07e, L"MSGothic", L"Arial", 1, 1252}, + {0x171d1ed1, L"SnapITC-Regular", L"Arial", 0, 1252}, + {0x18d1188f, L"Cambria", L"Arial", 2, 1252}, + {0x18eaf350, L"ArialUnicodeMS", L"Arial", 0, 936}, + {0x1a92d115, L"MingLiU", L"Arial", 1, 1252}, + {0x1cc217c6, L"TrebuchetMS", L"Arial", 0, 1252}, + {0x1d649596, L"BasemicTimes", L"Arial", 0, 1252}, + {0x1e34ee60, L"BellMT", L"Arial", 2, 1252}, + {0x1eb36945, L"CooperBlack", L"Arial", 2, 1252}, + {0x1ef7787d, L"BatangChe", L"Arial", 1, 1252}, + {0x20b3bd3a, L"BrushScriptMT", L"Arial", 8, 1252}, + {0x220877aa, L"Candara", L"Arial", 0, 1252}, + {0x22135007, L"FreestyleScript-Regular", L"Arial", 8, 1252}, + {0x251059c3, L"Chiller", L"Arial", 0, 1252}, + {0x25bed6dd, L"MSReferenceSansSerif", L"Arial", 0, 1252}, + {0x28154c81, L"Parchment-Regular", L"Arial", 8, 1252}, + {0x29711eb9, L"STLiti", L"Arial", 0, 936}, + {0x2b1993b4, L"Basemic", L"Arial", 0, 1252}, + {0x2b316339, L"NiagaraSolid-Reg", L"Arial", 0, 1252}, + {0x2c147529, L"FootlightMTLight", L"Arial", 0, 1252}, + {0x2c198928, L"HarlowSolid", L"Arial", 0, 1252}, + {0x2c6ac6b2, L"LucidaBright", L"Arial", 2, 1252}, + {0x2c9f38e2, L"KozukaMinchoPro-VIR", L"Arial", 0, 1252}, + {0x2d5a47b0, L"STCaiyun", L"Arial", 0, 936}, + {0x2def26bf, L"BernardMT-Condensed", L"Arial", 0, 1252}, + {0x2fd8930b, L"KozukaMinchoPr6NR", L"Arial", 0, 1252}, + {0x3115525a, L"FangSong_GB2312", L"Arial", 0, 1252}, + {0x31327817, L"MyriadPro", + L"Calibri,Corbel,Candara,Cambria Math,Franklin Gothic Medium,Arial " + L"Narrow,Times New Roman", + 0, 1252}, + {0x32244975, L"Helvetica", L"Arial", 0, 1252}, + {0x32ac995c, L"Terminal", L"Arial", 0, 1252}, + {0x338d648a, L"NiagaraEngraved-Reg", L"Arial", 0, 1252}, + {0x33bb65f2, L"Sylfaen", L"Arial", 2, 1252}, + {0x3402c30e, L"MSPMincho", L"Arial", 2, 1252}, + {0x3412bf31, L"SimSun-PUA", L"Arial", 0, 936}, + {0x36eb39b9, L"BerlinSansFB", L"Arial", 0, 1252}, + {0x36f42055, L"UniversATT", L"Microsoft Sans Serif", 0, 1252}, + {0x3864c4f6, L"HighTowerText", L"Arial", 2, 1252}, + {0x3a257d03, L"FangSong_GB2312", L"Arial", 0, 1252}, + {0x3cdae668, L"FreestyleScript", L"Arial", 8, 1252}, + {0x3d55aed7, L"Jokerman", L"Arial", 0, 1252}, + {0x3d5b4385, L"PMingLiU", L"Arial", 2, 1252}, + {0x3d9b7669, L"EstrangeloEdessa", L"Arial", 0, 1252}, + {0x3e532d74, L"FranklinGothicMedium", L"Arial", 0, 1252}, + {0x3e6aa32d, L"NSimSun", L"Arial", 1, 936}, + {0x3f6c36a8, L"Gautami", L"Arial", 0, 1252}, + {0x3ff32662, L"Chiller-Regular", L"Arial", 0, 1252}, + {0x409de312, L"ModernNo.20", L"Arial", 2, 1252}, + {0x41443c5e, L"Georgia", L"Arial", 2, 1252}, + {0x4160ade5, L"BellGothicStdBlack", + L"Arial,Arial Unicode MS,Book Antiqua,Dotum,Georgia", 0, 1252}, + {0x421976c4, L"Modern-Regular", L"Arial", 2, 1252}, + {0x422a7252, L"Stencil", L"Arial", 0, 1252}, + {0x42c8554f, L"Fixedsys", L"Arial", 0, 1252}, + {0x435cb41d, L"Roman", L"Arial", 0, 1252}, + {0x47882383, L"CourierNew", L"Arial", 1, 1252}, + {0x480a2338, L"BerlinSansFBDemi", L"Arial", 0, 1252}, + {0x480bf7a4, L"CourierStd", L"Courier New,Verdana", 0, 1252}, + {0x481ad6ed, L"VladimirScript", L"Arial", 8, 1252}, + {0x4911577a, L"YouYuan", L"Arial", 1, 936}, + {0x4a788d72, L"STXingkai", L"Arial", 0, 936}, + {0x4bf88566, L"SegoeCondensed", L"Arial", 0, 1252}, + {0x4ccf51a4, L"BerlinSansFB-Reg", L"Arial", 0, 1252}, + {0x4ea967ce, L"GulimChe", L"Arial", 1, 1252}, + {0x4f68bd79, L"LetterGothicStd", L"Courier New,Verdana", 0, 1252}, + {0x51a0d0e6, L"KozukaGothicPr6NM", L"Arial", 0, 1252}, + {0x531b3dea, L"BasemicSymbol", L"Arial", 0, 1252}, + {0x5333fd39, L"CalifornianFB-Reg", L"Arial", 2, 1252}, + {0x53561a54, L"FZYTK--GBK1-0", L"Arial", 0, 936}, + {0x55e0dde6, L"LucidaSansTypewriter", L"Arial", 0, 1252}, + {0x574d4d3d, L"AdobeArabic", L"Arial Narrow", 0, 1252}, + {0x5792e759, L"STKaiti", L"Arial", 0, 936}, + {0x5921978e, L"LucidaSansUnicode", L"Arial", 0, 1252}, + {0x594e2da4, L"Vrinda", L"Arial", 0, 1252}, + {0x59baa9a2, L"KaiTi_GB2312", L"Arial", 0, 1252}, + {0x5cfedf4f, L"BaskOldFace", L"Arial", 0, 1252}, + {0x5f97921c, L"AdobeMyungjoStdM", + L"Batang,Bookman Old Style,Consolas,STZhongsong", 0, 936}, + {0x5fefbfad, L"Batang", L"Arial", 2, 1252}, + {0x605342b9, L"DotumChe", L"Arial", 1, 1252}, + {0x608c5f9a, L"KaiTi_GB2312", L"Arial", 0, 936}, + {0x61efd0d1, L"MaturaMTScriptCapitals", L"Arial", 0, 1252}, + {0x626608a9, L"MVBoli", L"Arial", 0, 1252}, + {0x630501a3, L"SmallFonts", L"Arial", 0, 1252}, + {0x65d0e2a9, L"FZYTK--GBK1-0", L"Arial", 0, 936}, + {0x669f29e1, L"FZSTK--GBK1-0", L"Arial", 0, 936}, + {0x673a9e5f, L"Tunga", L"Arial", 0, 1252}, + {0x691aa4ce, L"NiagaraSolid", L"Arial", 0, 1252}, + {0x696259b7, L"Corbel", L"Arial", 0, 1252}, + {0x696ee9be, L"STXihei", L"Arial", 0, 936}, + {0x6c59cf69, L"Dotum", L"Arial", 0, 1252}, + {0x707fa561, L"Gungsuh", L"Arial", 2, 1252}, + {0x71416bb2, L"ZWAdobeF", L"Arial", 0, 1252}, + {0x71b41801, L"Verdana", L"Arial", 0, 1252}, + {0x73f25e4c, L"PalatinoLinotype", L"Arial", 0, 1252}, + {0x73f4d19f, L"NiagaraEngraved", L"Arial", 0, 1252}, + {0x74001694, L"MyriadProBlack", L"Book Antiqua,Constantia,Dotum,Georgia", 0, + 1252}, + {0x74b14d8f, L"Haettenschweiler", L"Arial", 0, 1252}, + {0x74cb44ee, L"NSimSun", L"Arial", 1, 936}, + {0x76b4d7ff, L"Shruti", L"Arial", 0, 1252}, + {0x788b3533, L"Webdings", L"Arial", 6, 42}, + {0x797dde99, L"MSSerif", L"Arial", 0, 1252}, + {0x7a0f9e9e, L"MSMincho", L"Arial", 1, 1252}, + {0x7b439caf, L"OldEnglishTextMT", L"Arial", 0, 1252}, + {0x8213a433, L"LucidaSans-Typewriter", L"Arial", 0, 1252}, + {0x82fec929, L"AdobeSongStdL", + L"Centaur,Calibri,STSong,Bell MT,Garamond,Times New Roman", 0, 936}, + {0x83581825, L"Modern", L"Arial", 0, 1252}, + {0x835a2823, L"Algerian", L"Arial", 0, 1252}, + {0x83dab9f5, L"Script", L"Arial", 0, 1252}, + {0x847b56da, L"Tahoma", L"Arial", 0, 1252}, + {0x8a783cb2, L"SimSun-PUA", L"Arial", 0, 1252}, + {0x8b5cac0e, L"Onyx", L"Arial", 0, 1252}, + {0x8c6a499e, L"Gulim", L"Arial", 0, 1252}, + {0x8e0af790, L"JuiceITC", L"Arial", 0, 1252}, + {0x8e8d43b2, L"Centaur", L"Arial", 2, 1252}, + {0x8ee4dcca, L"BookshelfSymbol7", L"Arial", 0, 1252}, + {0x90794800, L"BellGothicStdLight", L"Bell MT,Calibri,Times New Roman", 0, + 1252}, + {0x909b516a, L"Century", L"Arial", 2, 1252}, + {0x92ae370d, L"MSOutlook", L"Arial", 4, 42}, + {0x93c9fbf1, L"LucidaFax", L"Arial", 2, 1252}, + {0x9565085e, L"BookAntiqua", L"Arial", 2, 1252}, + {0x9856d95d, L"AdobeMingStdL", L"Arial,Arial Unicode MS,Cambria,BatangChe", + 0, 949}, + {0x9bbadd6b, L"ColonnaMT", L"Arial", 0, 1252}, + {0x9cbd16a4, L"ShowcardGothic-Reg", L"Arial", 0, 1252}, + {0x9d73008e, L"MSSansSerif", L"Arial", 0, 1252}, + {0xa0607db1, L"GungsuhChe", L"Arial", 1, 1252}, + {0xa0bcf6a1, L"LatinWide", L"Arial", 2, 1252}, + {0xa1429b36, L"Symbol", L"Arial", 6, 42}, + {0xa1fa5abc, L"Wingdings2", L"Arial", 6, 42}, + {0xa1fa5abd, L"Wingdings3", L"Arial", 6, 42}, + {0xa427bad4, L"InformalRoman-Regular", L"Arial", 8, 1252}, + {0xa8b92ece, L"FZSTK--GBK1-0", L"Arial", 0, 936}, + {0xa8d83ece, L"CalifornianFB", L"Arial", 2, 1252}, + {0xaa3e082c, L"Kingsoft-Phonetic", L"Arial", 0, 1252}, + {0xaa6bcabe, L"HarlowSolidItalic", L"Arial", 0, 1252}, + {0xade5337c, L"MSUIGothic", L"Arial", 0, 1252}, + {0xb08dd941, L"WideLatin", L"Arial", 2, 1252}, + {0xb207f05d, L"PoorRichard", L"Arial", 2, 1252}, + {0xb3bc492f, L"JuiceITC-Regular", L"Arial", 0, 1252}, + {0xb5545399, L"Marlett", L"Arial", 4, 42}, + {0xb5dd1ebb, L"BritannicBold", L"Arial", 0, 1252}, + {0xb699c1c5, L"LucidaCalligraphy-Italic", L"Arial", 0, 1252}, + {0xb725d629, L"TimesNewRoman", L"Arial", 2, 1252}, + {0xb7eaebeb, L"AdobeHeitiStdR", L"Batang,Century,Dotum", 0, 936}, + {0xbd29c486, L"BerlinSansFBDemi-Bold", L"Arial", 0, 1252}, + {0xbe8a8db4, L"BookshelfSymbolSeven", L"Arial", 0, 1252}, + {0xc16c0118, L"AdobeHebrew", L"Bell MT,Berlin Sans FB,Calibri", 0, 1252}, + {0xc318b0af, L"MyriadProLight", L"Calibri,STFangsong,Times New Roman", 0, + 1252}, + {0xc65e5659, L"CambriaMath", L"Arial", 2, 1252}, + {0xc75c8f05, L"LucidaConsole", L"Arial", 1, 1252}, + {0xca7c35d6, L"Calibri", L"Arial", 0, 1252}, + {0xcb053f53, L"MicrosoftYaHei", L"Arial", 0, 936}, + {0xcb7190f9, L"Magneto-Bold", L"Arial", 0, 1252}, + {0xcca00cc5, L"System", L"Arial", 0, 1252}, + {0xccad6f76, L"Jokerman-Regular", L"Arial", 0, 1252}, + {0xccc5818c, L"EuroSign", L"Arial", 0, 1252}, + {0xcf3d7234, L"LucidaHandwriting-Italic", L"Arial", 0, 1252}, + {0xcf7b8fdb, L"MinionPro", + L"Bell MT,Corbel,Times New Roman,Cambria,Berlin Sans FB", 0, 1252}, + {0xcfe5755f, L"Simhei", L"Arial", 1, 936}, + {0xd011f4ee, L"MSPGothic", L"Arial", 0, 1252}, + {0xd060e7ef, L"Vivaldi", L"Arial", 8, 1252}, + {0xd07edec1, L"FranklinGothic-Medium", L"Arial", 0, 1252}, + {0xd107243f, L"SimSun", L"Arial", 0, 936}, + {0xd1881562, L"ArialNarrow", L"Arial Narrow", 0, 1252}, + {0xd22b7dce, L"BodoniMTPosterCompressed", L"Arial", 0, 1252}, + {0xd22bfa60, L"ComicSansMS", L"Arial", 8, 1252}, + {0xd3bd0e35, L"Bauhaus93", L"Arial", 0, 1252}, + {0xd429ee7a, L"STFangsong", L"Arial", 0, 936}, + {0xd6679c12, L"BernardMTCondensed", L"Arial", 0, 1252}, + {0xd8e8a027, L"LucidaSans", L"Arial", 0, 1252}, + {0xd9fe7761, L"HighTowerText-Reg", L"Arial", 2, 1252}, + {0xda7e551e, L"STSong", L"Arial", 0, 936}, + {0xdaa6842d, L"STZhongsong", L"Arial", 0, 936}, + {0xdaaab93f, L"STFangsong", L"Arial", 0, 936}, + {0xdaeb0713, L"STSong", L"Arial", 0, 936}, + {0xdafedbef, L"STCaiyun", L"Arial", 0, 936}, + {0xdb00a3d9, L"Broadway", L"Arial", 0, 1252}, + {0xdb1f5ad4, L"STXinwei", L"Arial", 0, 936}, + {0xdb326e7f, L"STKaiti", L"Arial", 0, 936}, + {0xdb69595a, L"STHupo", L"Arial", 0, 936}, + {0xdba0082c, L"STXihei", L"Arial", 0, 936}, + {0xdbd0ab18, L"STXingkai", L"Arial", 0, 936}, + {0xdc1a7db1, L"STLiti", L"Arial", 0, 936}, + {0xdc33075f, L"KristenITC-Regular", L"Arial", 8, 1252}, + {0xdcc7009c, L"Harrington", L"Arial", 0, 1252}, + {0xdd712466, L"ArialBlack", L"Arial", 0, 1252}, + {0xdde87b3e, L"Impact", L"Arial", 0, 1252}, + {0xdf69fb32, L"SnapITC", L"Arial", 0, 1252}, + {0xdf8b25e8, L"CenturyGothic", L"Arial", 0, 1252}, + {0xe0f705c0, L"KristenITC", L"Arial", 8, 1252}, + {0xe1427573, L"Raavi", L"Arial", 0, 1252}, + {0xe2cea0cb, L"Magneto", L"Arial", 0, 1252}, + {0xe36a9e17, L"Ravie", L"Arial", 0, 1252}, + {0xe433f8e2, L"Parchment", L"Arial", 8, 1252}, + {0xe43dff4a, L"Wingdings", L"Arial", 4, 42}, + {0xe4e2c405, L"MTExtra", L"Arial", 6, 42}, + {0xe618cc35, L"InformalRoman", L"Arial", 8, 1252}, + {0xe6c27ffc, L"Mistral", L"Arial", 8, 1252}, + {0xe7ebf4b9, L"Courier", L"Courier New", 0, 1252}, + {0xe8bc4a9d, L"MSReferenceSpecialty", L"Arial", 0, 1252}, + {0xe90fb013, L"TempusSansITC", L"Arial", 0, 1252}, + {0xec637b42, L"Consolas", L"Verdana", 1, 1252}, + {0xed3a683b, L"STXinwei", L"Arial", 0, 936}, + {0xef264cd1, L"LucidaHandwriting", L"Arial", 0, 1252}, + {0xf086bca2, L"BaskervilleOldFace", L"Arial", 0, 1252}, + {0xf1028030, L"Mangal", L"Arial", 2, 1252}, + {0xf1da7eb9, L"ShowcardGothic", L"Arial", 0, 1252}, + {0xf210f06a, L"ArialMT", L"Arial", 0, 1252}, + {0xf477f16a, L"Latha", L"Arial", 0, 1252}, + {0xf616f3dd, L"LiSu", L"Arial", 1, 936}, + {0xfa479aa6, L"MicrosoftYaHei", L"Arial", 0, 936}, + {0xfcd19697, L"BookmanOldStyle", L"Arial", 0, 1252}, + {0xfe209a82, L"LucidaCalligraphy", L"Arial", 0, 1252}, + {0xfef135f8, L"AdobeHeitiStd-Regular", L"Batang,Century,Dotum", 0, 936}, +}; +#elif _FXM_PLATFORM_ == _FXM_PLATFORM_LINUX_ +const XFA_FONTINFO g_XFAFontsMap[] = { + {0x01d5d33e, L"SimSun", + L"WenQuanYi Zen Hei Mono,AR PL UMing CN,AR PL UMing HK,AR PL UMing TW,AR " + L"PL UMing TW MBE", + 0, 936}, + {0x01e4f102, L"YouYuan", + L"WenQuanYi Zen Hei Mono,AR PL UMing CN,AR PL UMing HK,AR PL UMing TW,AR " + L"PL UMing TW MBE", + 1, 936}, + {0x030549dc, L"LiSu", + L"WenQuanYi Zen Hei,WenQuanYi Zen Hei Sharp,WenQuanYi Zen Hei " + L"Mono,WenQuanYi Micro Hei", + 1, 936}, + {0x032edd44, L"Simhei", + L"WenQuanYi Zen Hei,WenQuanYi Zen Hei Sharp,WenQuanYi Zen Hei " + L"Mono,WenQuanYi Micro Hei", + 1, 936}, + {0x03eac6fc, L"PoorRichard-Regular", L"Droid Sans Japanese,FreeSerif", 2, + 1252}, + {0x03ed90e6, L"Nina", L"FreeSerif", 0, 1252}, + {0x077b56b3, L"KingsoftPhoneticPlain", + L"Tibetan Machine Uni,LKLUG,Samyak Gujarati,Droid Sans Thai,Droid Sans " + L"Armenian,Untitled1,utkal,Lohit Oriya", + 0, 1252}, + {0x078ed524, L"MicrosoftSansSerif", + L"Droid Sans Japanese,FreeSerif,WenQuanYi Micro Hei", 0, 1252}, + {0x089b18a9, L"Arial", + L"Droid Sans Japanese,DejaVu Sans Condensed,FreeSerif,WenQuanYi Micro Hei", + 0, 1252}, + {0x0b2cad72, L"MonotypeCorsiva", L"Droid Sans Japanese,FreeSerif", 8, 1252}, + {0x0bb003e7, L"Kartika", + L"FreeSans,Liberation Sans,Liberation Sans Narrow,Nimbus Sans " + L"L,Garuda,FreeSerif,WenQuanYi Micro Hei", + 2, 1252}, + {0x0bb469df, L"VinerHandITC", + L"Droid Sans Japanese,Ubuntu,Liberation Sans,Liberation Serif", 8, 1252}, + {0x0bc1a851, L"SegoeUI", L"Droid Sans Japanese,DejaVu Sans", 0, 1252}, + {0x0c112ebd, L"KozukaGothicPro-VIM", L"FreeSerif", 0, 1252}, + {0x0cfcb9c1, L"AdobeThai", L"Droid Sans Japanese,Waree", 0, 847}, + {0x0e7de0f9, L"Playbill", + L"KacstQurn,Droid Arabic Naskh,Droid Sans Ethiopic,mry_KacstQurn,Droid " + L"Sans Ethiopic,Droid Sans Japanese,FreeSerif", + 0, 1252}, + {0x0eff47c3, L"STHupo", L"AR PL UKai HK,AR PL UMing HK,AR PL UKai CN", 0, + 936}, + {0x107ad374, L"Constantia", + L"Droid Sans Japanese,FreeSerif,WenQuanYi Micro Hei,Ubuntu", 2, 1252}, + {0x12194c2d, L"KunstlerScript", L"Droid Sans Japanese,Liberation Serif", 8, + 1252}, + {0x135ef6a1, L"MinionProSmBd", L"Liberation Serif", 0, 1252}, + {0x158c4049, L"Garamond", + L"Droid Sans Japanese,Liberation Serif,Ubuntu,FreeSerif", 2, 1252}, + {0x160ecb24, L"STZhongsong", + L"WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei,WenQuanYi Zen Hei " + L"Sharp,WenQuanYi Micro Hei", + 0, 936}, + {0x161ed07e, L"MSGothic", + L"WenQuanYi Micro Hei Mono,WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei,AR PL " + L"UMing CN,AR PL UMing HK,AR PL UMing TW", + 1, 1252}, + {0x171d1ed1, L"SnapITC-Regular", + L"Liberation Sans Narrow,Ubuntu Condensed,Nimbus Sans L,DejaVu Sans", 0, + 1252}, + {0x18d1188f, L"Cambria", L"Droid Sans Japanese,FreeSerif,FreeMono", 2, + 1252}, + {0x18eaf350, L"ArialUnicodeMS", + L"WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei,WenQuanYi Zen Hei " + L"Sharp,WenQuanYi Micro Hei", + 0, 936}, + {0x1a92d115, L"MingLiU", + L"WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei,WenQuanYi Zen Hei " + L"Sharp,WenQuanYi Micro Hei", + 1, 1252}, + {0x1cc217c6, L"TrebuchetMS", + L"Droid Sans Japanese,Liberation Serif,FreeSerif,Ubuntu", 0, 1252}, + {0x1d649596, L"BasemicTimes", + L"Liberation Serif,Times New Roman,Droid Sans Japanese,FreeSerif,Ubuntu", + 0, 1252}, + {0x1e34ee60, L"BellMT", + L"KacstQurn,Droid Sans Japanese,Ubuntu,Liberation Serif", 2, 1252}, + {0x1eb36945, L"CooperBlack", + L"KacstQurn,Droid Sans Japanese,FreeMono,Liberation Mono, WenQuanYi Micro " + L"Hei Mono", + 2, 1252}, + {0x1ef7787d, L"BatangChe", + L"WenQuanYi Zen Hei Mono,AR PL UMing CN,AR PL UMing HK,AR PL UMing " + L"TW,WenQuanYi Zen Hei,WenQuanYi Micro Hei", + 1, 1252}, + {0x20b3bd3a, L"BrushScriptMT", + L"KacstQurn,Droid Arabic Naskh,Droid Sans Ethiopic,Droid Sans " + L"Japanese,URW Chancery L,Liberation Sans", + 8, 1252}, + {0x220877aa, L"Candara", L"Droid Sans Japanese,DejaVu Sans", 0, 1252}, + {0x22135007, L"FreestyleScript-Regular", + L"KacstQurn,Droid Sans Japanese,Liberation Sans", 8, 1252}, + {0x251059c3, L"Chiller", + L"KacstQurn,Droid Arabic Naskh,Droid Sans Ethiopic,Droid Sans " + L"Japanese,Liberation Sans", + 0, 1252}, + {0x25bed6dd, L"MSReferenceSansSerif", + L"DejaVu Sans Condensed,Ubuntu Condensed,Droid Sans Japanese,AR PL UKai " + L"HK", + 0, 1252}, + {0x28154c81, L"Parchment-Regular", L"Droid Sans Japanese,Liberation Sans", + 8, 1252}, + {0x29711eb9, L"STLiti", L"AR PL UKai HK", 0, 936}, + {0x2b1993b4, L"Basemic", + L"Liberation Serif,Droid Sans Japanese,Liberation Sans", 0, 1252}, + {0x2b316339, L"NiagaraSolid-Reg", L"Droid Sans Japanese,Liberation Sans", 0, + 1252}, + {0x2c147529, L"FootlightMTLight", + L"KacstQurn,Droid Sans Japanese,Liberation Sans", 0, 1252}, + {0x2c198928, L"HarlowSolid", + L"KacstQurn,Droid Sans Japanese,Liberation Sans", 0, 1252}, + {0x2c6ac6b2, L"LucidaBright", + L"KacstQurn,Droid Arabic Naskh,Droid Sans Ethiopic,mry_KacstQurn,Droid " + L"Sans Japanese,Liberation Sans", + 2, 1252}, + {0x2c9f38e2, L"KozukaMinchoPro-VIR", L"DejaVu Sans", 0, 1252}, + {0x2d5a47b0, L"STCaiyun", L"AR PL UKai HK", 0, 936}, + {0x2def26bf, L"BernardMT-Condensed", + L"KacstQurn,Droid Sans Japanese,DejaVu Serif", 0, 1252}, + {0x2fd8930b, L"KozukaMinchoPr6NR", L"DejaVu Serif", 0, 1252}, + {0x3115525a, L"FangSong_GB2312", + L"WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei,WenQuanYi Zen Hei " + L"Sharp,WenQuanYi Micro Hei", + 0, 1252}, + {0x31327817, L"MyriadPro", + L"Ubuntu Condensed,Droid Sans Japanese, FreeSerif", 0, 1252}, + {0x32244975, L"Helvetica", + L"Ubuntu,DejaVu Sans Condensed,Liberation Sans,Liberation Sans " + L"Narrow,Nimbus Sans L", + 0, 1252}, + {0x32ac995c, L"Terminal", L"DejaVu Serif", 0, 1252}, + {0x338d648a, L"NiagaraEngraved-Reg", L"Droid Sans Japanese,DejaVu Serif", 0, + 1252}, + {0x33bb65f2, L"Sylfaen", L"Droid Sans Japanese,DejaVu Sans", 2, 1252}, + {0x3402c30e, L"MSPMincho", + L"WenQuanYi Zen Hei Mono,AR PL UMing CN,AR PL UMing HK,AR PL UMing TW", 2, + 1252}, + {0x3412bf31, L"SimSun-PUA", + L"WenQuanYi Zen Hei Mono,AR PL UMing CN,AR PL UMing CN,AR PL UMing HK", 0, + 936}, + {0x36eb39b9, L"BerlinSansFB", + L"Droid Sans Japanese,Liberation Serif,Ubuntu,FreeSerif", 0, 1252}, + {0x36f42055, L"UniversATT", L"Microsoft Sans Serif", 0, 1252}, + {0x3864c4f6, L"HighTowerText", L"Droid Sans Japanese,DejaVu Serif", 2, + 1252}, + {0x3a257d03, L"FangSong_GB2312", + L"WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei", 0, 1252}, + {0x3c7d1d07, L"Garamond3LTStd", + L"Droid Sans Japanese,Ubuntu Condensed,DejaVu Sans Condensed,Liberation " + L"Serif,Ubuntu,FreeSerif", + 2, 1252}, + {0x3cdae668, L"FreestyleScript", + L"KacstQurn,Droid Sans Japanese,DejaVu Sans", 8, 1252}, + {0x3d55aed7, L"Jokerman", L"Droid Sans Japanese,DejaVu Sans", 0, 1252}, + {0x3d5b4385, L"PMingLiU", + L"WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei,WenQuanYi Zen Hei " + L"Sharp,WenQuanYi Micro Hei", + 2, 1252}, + {0x3d9b7669, L"EstrangeloEdessa", L"Droid Sans Japanese,DejaVu Sans", 0, + 1252}, + {0x3e532d74, L"FranklinGothicMedium", L"Droid Sans Japanese,Ubuntu", 0, + 1252}, + {0x3e6aa32d, L"NSimSun", + L"WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei,WenQuanYi Zen Hei " + L"Sharp,WenQuanYi Micro Hei", + 1, 936}, + {0x3f6c36a8, L"Gautami", + L"Droid Arabic Naskh,Droid Sans Ethiopic, mry_KacstQurn,Droid Sans " + L"Japanese,FreeSans", + 0, 1252}, + {0x3ff32662, L"Chiller-Regular", + L"KacstQurn,Droid Arabic Naskh,Droid Sans Ethiopic,FreeSans", 0, 1252}, + {0x409de312, L"ModernNo.20", + L"KacstQurn,Droid Sans Japanese,Nimbus Sans L,Nimbus Sans L,FreeSans", 2, + 1252}, + {0x41443c5e, L"Georgia", L"Droid Sans Japanese,FreeSans", 2, 1252}, + {0x4160ade5, L"BellGothicStdBlack", L"FreeSans", 0, 1252}, + {0x421976c4, L"Modern-Regular", L"FreeSans", 2, 1252}, + {0x422a7252, L"Stencil", L"Droid Sans Japanese,FreeSans,Liberation Sans", 0, + 1252}, + {0x42c8554f, L"Fixedsys", L"FreeSerif", 0, 1252}, + {0x435cb41d, L"Roman", L"FreeSerif", 0, 1252}, + {0x47882383, L"CourierNew", + L"FreeMono,WenQuanYi Micro Hei Mono,AR PL UKai CN,AR PL UKai HK,AR PL " + L"UKai TW,AR PL UKai TW MBE,DejaVu Sans", + 1, 1252}, + {0x480a2338, L"BerlinSansFBDemi", L"Droid Sans Japanese,Liberation Serif", + 0, 1252}, + {0x480bf7a4, L"CourierStd", L"DejaVu Sans", 0, 1252}, + {0x481ad6ed, L"VladimirScript", L"Droid Sans Japanese,DejaVu Serif", 8, + 1252}, + {0x4911577a, L"YouYuan", + L"WenQuanYi Zen Hei Mono,AR PL UMing CN,AR PL UMing HK,AR PL UMing TW", 1, + 936}, + {0x4a788d72, L"STXingkai", L"AR PL UKai HK,AR PL UMing HK,AR PL UKai CN", 0, + 936}, + {0x4bf88566, L"SegoeCondensed", L"FreeSerif", 0, 1252}, + {0x4ccf51a4, L"BerlinSansFB-Reg", L"Droid Sans Japanese,Liberation Serif", + 0, 1252}, + {0x4ea967ce, L"GulimChe", + L"WenQuanYi Zen Hei Mono,AR PL UKai CN,AR PL UKai HK,AR PL UKai TW,AR PL " + L"UKai TW MBE", + 1, 1252}, + {0x4f68bd79, L"LetterGothicStd", + L"FreeMono,Liberation Mono,Andale Mono,WenQuanYi Micro Hei Mono", 0, 1252}, + {0x51a0d0e6, L"KozukaGothicPr6NM", L"FreeSerif", 0, 1252}, + {0x531b3dea, L"BasemicSymbol", L"FreeSerif", 0, 1252}, + {0x5333fd39, L"CalifornianFB-Reg", + L"Droid Sans Japanese,URW Chancery L,FreeSerif", 2, 1252}, + {0x53561a54, L"FZYTK--GBK1-0", + L"WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei,WenQuanYi Zen Hei " + L"Sharp,WenQuanYi Micro Hei", + 0, 936}, + {0x55e0dde6, L"LucidaSansTypewriter", + L"Ubuntu Mono,DejaVu Sans Mono,Nimbus Mono L,Liberation Mono,Courier 10 " + L"Pitch,FreeMono", + 0, 1252}, + {0x574d4d3d, L"AdobeArabic", L"Droid Sans Japanese,DejaVu Sans", 0, 1252}, + {0x5792e759, L"STKaiti", L"WenQuanYi Micro Hei Mono", 0, 936}, + {0x5921978e, L"LucidaSansUnicode", L"Droid Sans Japanese,DejaVu Sans", 0, + 1252}, + {0x594e2da4, L"Vrinda", + L"Droid Arabic Naskh,Droid Sans Ethiopic,Droid Arabic " + L"Naskh,mry_KacstQurn,Droid Sans Japanese,FreeSans,FreeSerif", + 0, 1252}, + {0x59baa9a2, L"KaiTi_GB2312", + L"WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei,WenQuanYi Zen Hei " + L"Sharp,WenQuanYi Micro Hei", + 0, 1252}, + {0x5cfedf4f, L"BaskOldFace", + L"KacstQurn,Droid Sans Japanese,Ubuntu,Liberation Serif", 0, 1252}, + {0x5e16ac91, L"TrajanPro", + L"Nimbus Sans L,AR PL UMing HK,AR PL UKai HK,AR PL UMing TW,AR PL UMing " + L"TW MBE,DejaVu Sans,DejaVu Serif", + 0, 1252}, + {0x5f388196, L"ITCLegacySansStdMedium", + L"Liberation Serif,FreeSerif,FreeSans,Ubuntu", 0, 1252}, + {0x5f97921c, L"AdobeMyungjoStdM", + L"WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei,WenQuanYi Zen Hei " + L"Sharp,WenQuanYi Micro Hei", + 0, 936}, + {0x5fefbfad, L"Batang", + L"WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei,WenQuanYi Zen Hei " + L"Sharp,WenQuanYi Micro Hei", + 2, 1252}, + {0x605342b9, L"DotumChe", + L"WenQuanYi Zen Hei Mono,AR PL UMing CN,AR PL UMing HK,AR PL UMing TW", 1, + 1252}, + {0x608c5f9a, L"KaiTi_GB2312", + L"WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei,WenQuanYi Zen Hei " + L"Sharp,WenQuanYi Micro Hei", + 0, 936}, + {0x61efd0d1, L"MaturaMTScriptCapitals", + L"KacstQurn,Droid Arabic Naskh,Droid Sans Ethiopic,mry_KacstQurn,Droid " + L"Sans Japanese,DejaVu Serif,DejaVu Sans", + 0, 1252}, + {0x626608a9, L"MVBoli", + L"Droid Arabic Naskh,Droid Sans Ethiopic,mry_KacstQurn,Droid Sans " + L"Ethiopic,Droid Sans Japanese,DejaVu Sans", + 0, 1252}, + {0x630501a3, L"SmallFonts", L"DejaVu Serif", 0, 1252}, + {0x65d0e2a9, L"FZYTK--GBK1-0", + L"WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei,WenQuanYi Zen Hei " + L"Sharp,WenQuanYi Micro Hei", + 0, 936}, + {0x669f29e1, L"FZSTK--GBK1-0", + L"AR PL UMing CN,AR PL UKai CN, AR PL UMing HK", 0, 936}, + {0x673a9e5f, L"Tunga", + L"Droid Arabic Naskh,Droid Sans Ethiopic,mry_KacstQurn,Droid Sans " + L"Japanese,DejaVu Serif", + 0, 1252}, + {0x691aa4ce, L"NiagaraSolid", L"Droid Sans Japanese,DejaVu Serif", 0, 1252}, + {0x696259b7, L"Corbel", L"Droid Sans Japanese,DejaVu Sans", 0, 1252}, + {0x696ee9be, L"STXihei", L"WenQuanYi Micro Hei Mono", 0, 936}, + {0x6c59cf69, L"Dotum", L"WenQuanYi Zen Hei Mono", 0, 1252}, + {0x707fa561, L"Gungsuh", L"WenQuanYi Zen Hei Mono", 2, 1252}, + {0x71416bb2, L"ZWAdobeF", + L"KacstArt,KacstBookm,KacstDecorative,KacstDigital,KacstFarsi,KacstLetter," + L"KacstOffice,Dingbats,FreeSerif", + 0, 1252}, + {0x71b41801, L"Verdana", + L"DejaVu Sans Condensed,Ubuntu Condensed,Droid Sans Japanese,DejaVu Sans", + 0, 1252}, + {0x73f25e4c, L"PalatinoLinotype", L"Droid Sans Japanese,FreeSerif", 0, + 1252}, + {0x73f4d19f, L"NiagaraEngraved", L"Droid Sans Japanese,FreeSerif", 0, 1252}, + {0x74001694, L"MyriadProBlack", L"Droid Sans Japanese,AR PL UKai HK", 0, + 1252}, + {0x74b14d8f, L"Haettenschweiler", L"Droid Sans Japanese,DejaVu Serif", 0, + 1252}, + {0x74cb44ee, L"NSimSun", L"WenQuanYi Zen Hei Mono", 1, 936}, + {0x76b4d7ff, L"Shruti", + L"Droid Arabic Naskh,Droid Sans Ethiopic,mry_KacstQurn,Droid Sans " + L"Japanese,FreeSans", + 0, 1252}, + {0x788b3533, L"Webdings", L"FreeSans", 6, 42}, + {0x797dde99, L"MSSerif", L"FreeSans", 0, 1252}, + {0x7a0f9e9e, L"MSMincho", + L"WenQuanYi Micro Hei Mono,AR PL UMing CN,AR PL UMing HK,AR PL UMing TW", + 1, 1252}, + {0x7b439caf, L"OldEnglishTextMT", + L"Droid Sans Japanese,Liberation Sans,Ubuntu", 0, 1252}, + {0x8213a433, L"LucidaSans-Typewriter", + L"Ubuntu Mono,Liberation Mono,DejaVu Sans Mono", 0, 1252}, + {0x82fec929, L"AdobeSongStdL", + L"WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei,WenQuanYi Zen Hei " + L"Sharp,WenQuanYi Micro Hei", + 0, 936}, + {0x83581825, L"Modern", L"FreeSans", 0, 1252}, + {0x835a2823, L"Algerian", + L"KacstQurn,Droid Sans Japanese,FreeSans,Liberation Sans,Ubuntu", 0, 1252}, + {0x83dab9f5, L"Script", L"FreeSans", 0, 1252}, + {0x847b56da, L"Tahoma", + L"Droid Sans Japanese,DejaVu Sans Condensed,FreeSerif", 0, 1252}, + {0x8a783cb2, L"SimSun-PUA", + L"WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei,WenQuanYi Zen Hei " + L"Sharp,WenQuanYi Micro Hei", + 0, 1252}, + {0x8b5cac0e, L"Onyx", L"Droid Sans Japanese,Liberation Sans", 0, 1252}, + {0x8c6a499e, L"Gulim", + L"WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei,WenQuanYi Zen Hei " + L"Sharp,WenQuanYi Micro Hei", + 0, 1252}, + {0x8e0af790, L"JuiceITC", L"Droid Sans Japanese,Liberation Sans", 0, 1252}, + {0x8e8d43b2, L"Centaur", + L"KacstQurn,Droid Sans Japanese,Khmer OS,Khmer OS System", 2, 1252}, + {0x8ee4dcca, L"BookshelfSymbol7", L"Liberation Sans", 0, 1252}, + {0x90794800, L"BellGothicStdLight", L"Liberation Sans", 0, 1252}, + {0x909b516a, L"Century", + L"Droid Sans Japanese,Liberation Sans,Liberation Mono,Liberation Serif", 2, + 1252}, + {0x92ae370d, L"MSOutlook", L"Liberation Sans", 4, 42}, + {0x93c9fbf1, L"LucidaFax", + L"KacstQurn,Droid Arabic Naskh,Droid Sans " + L"Ethiopic,mry_KacstQurn,Liberation Sans", + 2, 1252}, + {0x9565085e, L"BookAntiqua", + L"Droid Sans Japanese,Liberation Sans,Liberation Serif", 2, 1252}, + {0x9856d95d, L"AdobeMingStdL", L"AR PL UMing HK", 0, 949}, + {0x9bbadd6b, L"ColonnaMT", + L"KacstQurn,Droid Sans Japanese,Khmer OS,Khmer OS System", 0, 1252}, + {0x9cbd16a4, L"ShowcardGothic-Reg", + L"Droid Sans Japanese,Liberation Sans,Ubuntu", 0, 1252}, + {0x9d73008e, L"MSSansSerif", L"FreeSerif", 0, 1252}, + {0xa0607db1, L"GungsuhChe", + L"WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei,WenQuanYi Zen Hei " + L"Sharp,WenQuanYi Micro Hei", + 1, 1252}, + {0xa0bcf6a1, L"LatinWide", L"FreeSerif", 2, 1252}, + {0xa1429b36, L"Symbol", L"FreeSerif", 6, 42}, + {0xa1fa5abc, L"Wingdings2", L"FreeSerif", 6, 42}, + {0xa1fa5abd, L"Wingdings3", L"FreeSerif", 6, 42}, + {0xa427bad4, L"InformalRoman-Regular", + L"Droid Arabic Naskh,Droid Sans Ethiopic,mry_KacstQurn,Droid Sans " + L"Japanese,FreeSerif", + 8, 1252}, + {0xa8b92ece, L"FZSTK--GBK1-0", L"AR PL UMing CN", 0, 936}, + {0xa8d83ece, L"CalifornianFB", L"Droid Sans Japanese,FreeSerif", 2, 1252}, + {0xaa3e082c, L"Kingsoft-Phonetic", + L"Tibetan Machine Uni,LKLUG,Samyak Gujarati,Droid Sans " + L"Thai,utkal,Kedage,Mallige,AR PL UKai CN", + 0, 1252}, + {0xaa6bcabe, L"HarlowSolidItalic", + L"KacstQurn,Droid Sans Japanese,Liberation Serif", 0, 1252}, + {0xade5337c, L"MSUIGothic", + L"WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei,WenQuanYi Zen Hei " + L"Sharp,WenQuanYi Micro Hei", + 0, 1252}, + {0xb08dd941, L"WideLatin", + L"KacstQurn,Droid Arabic Naskh,Droid Sans Ethiopic,mry_KacstQurn,Droid " + L"Sans Japanese,Liberation Serif", + 2, 1252}, + {0xb12765e0, L"ITCLegacySansStdBook", + L"AR PL UMing HK,AR PL UKai HK,FreeSerif,Ubuntu,FreeSans", 0, 1252}, + {0xb207f05d, L"PoorRichard", L"Droid Sans Japanese,Liberation Serif", 2, + 1252}, + {0xb3bc492f, L"JuiceITC-Regular", L"Droid Sans Japanese,Liberation Serif", + 0, 1252}, + {0xb5545399, L"Marlett", L"Liberation Serif", 4, 42}, + {0xb5dd1ebb, L"BritannicBold", + L"KacstQurn,Droid Arabic Naskh,Droid Sans " + L"Ethiopic,mry_KacstQurn,Liberation Serif", + 0, 1252}, + {0xb699c1c5, L"LucidaCalligraphy-Italic", + L"KacstQurn,Droid Arabic Naskh,Droid Sans Ethiopic,mry_KacstQurn,Droid " + L"Sans Japanese,DejaVu Serif", + 0, 1252}, + {0xb725d629, L"TimesNewRoman", L"Droid Sans Japanese,Liberation Sans", 2, + 1252}, + {0xb7eaebeb, L"AdobeHeitiStdR", + L"WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei,WenQuanYi Zen Hei " + L"Sharp,WenQuanYi Micro Hei", + 0, 936}, + {0xbd29c486, L"BerlinSansFBDemi-Bold", L"Droid Sans Japanese,DejaVu Serif", + 0, 1252}, + {0xbe8a8db4, L"BookshelfSymbolSeven", L"DejaVu Sans", 0, 1252}, + {0xc16c0118, L"AdobeHebrew", L"Droid Sans Japanese,Ubuntu,Liberation Serif", + 0, 1252}, + {0xc318b0af, L"MyriadProLight", + L"Droid Sans Japanese,AR PL UKai HK,AR PL UMing HK,AR PL UKai CN", 0, + 1252}, + {0xc65e5659, L"CambriaMath", L"Droid Sans Japanese,FreeSerif,FreeMono", 2, + 1252}, + {0xc75c8f05, L"LucidaConsole", + L"Liberation Mono,DejaVu Sans Mono,FreeMono,WenQuanYi Micro Hei Mono", 1, + 1252}, + {0xca7c35d6, L"Calibri", L"Droid Sans Japanese,DejaVu Sans", 0, 1252}, + {0xcb053f53, L"MicrosoftYaHei", + L"WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei,WenQuanYi Zen Hei " + L"Sharp,WenQuanYi Micro Hei", + 0, 936}, + {0xcb7190f9, L"Magneto-Bold", + L"Droid Arabic Naskh,Droid Sans Ethiopic,mry_KacstQurn,Droid Sans " + L"Japanese,DejaVu Serif", + 0, 1252}, + {0xcca00cc5, L"System", L"DejaVu Sans", 0, 1252}, + {0xccad6f76, L"Jokerman-Regular", L"Droid Sans Japanese,DejaVu Sans", 0, + 1252}, + {0xccc5818c, L"EuroSign", L"DejaVu Serif", 0, 1252}, + {0xcf3d7234, L"LucidaHandwriting-Italic", + L"Liberation Sans Narrow,Ubuntu Condensed,Nimbus Sans L,DejaVu Serif", 0, + 1252}, + {0xcf7b8fdb, L"MinionPro", L"DejaVu Sans", 0, 1252}, + {0xcfe5755f, L"Simhei", + L"WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei,WenQuanYi Zen Hei " + L"Sharp,WenQuanYi Micro Hei", + 1, 936}, + {0xd011f4ee, L"MSPGothic", + L"WenQuanYi Zen Hei Mono,AR PL UMing CN,AR PL UMing HK,AR PL UMing TW", 0, + 1252}, + {0xd060e7ef, L"Vivaldi", + L"KacstQurn,Droid Sans Japanese,Liberation Sans,Ubuntu", 8, 1252}, + {0xd07edec1, L"FranklinGothic-Medium", L"Droid Sans Japanese,Ubuntu", 0, + 1252}, + {0xd107243f, L"SimSun", L"WenQuanYi Zen Hei Mono", 0, 936}, + {0xd1881562, L"ArialNarrow", + L"Liberation Sans Narrow,Droid Sans Japanese,FreeSerif", 0, 1252}, + {0xd22b7dce, L"BodoniMTPosterCompressed", + L"Droid Sans Japanese,DejaVu Serif", 0, 1252}, + {0xd22bfa60, L"ComicSansMS", + L"Droid Sans Japanese,FreeMono,Liberation Mono", 8, 1252}, + {0xd3bd0e35, L"Bauhaus93", + L"KacstQurn,Droid Sans Japanese,Liberation Sans,Ubuntu", 0, 1252}, + {0xd429ee7a, L"STFangsong", L"WenQuanYi Micro Hei Mono", 0, 936}, + {0xd6679c12, L"BernardMTCondensed", + L"KacstQurn,Droid Sans Japanese,Nimbus Sans L,URW Chancery " + L"L,KacstOne,Liberation Sans", + 0, 1252}, + {0xd8e8a027, L"LucidaSans", + L"Liberation Sans Narrow,Nimbus Sans L,KacstQurn,Droid Arabic Naskh,Droid " + L"Sans Ethiopic,DejaVu Serif Condensed,Liberation Mono,Ubuntu", + 0, 1252}, + {0xd9fe7761, L"HighTowerText-Reg", + L"Droid Sans Japanese,Ubuntu,Liberation Serif", 2, 1252}, + {0xda7e551e, L"STSong", L"WenQuanYi Micro Hei Mono", 0, 936}, + {0xdaa6842d, L"STZhongsong", + L"WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei,WenQuanYi Zen Hei " + L"Sharp,WenQuanYi Micro Hei", + 0, 936}, + {0xdaaab93f, L"STFangsong", + L"WenQuanYi Micro Hei Mono,WenQuanYi Zen Hei Mono,WenQuanYi Zen " + L"Hei,WenQuanYi Zen Hei Sharp", + 0, 936}, + {0xdaeb0713, L"STSong", + L"WenQuanYi Micro Hei Mono,WenQuanYi Zen Hei Mono,WenQuanYi Zen " + L"Hei,WenQuanYi Zen Hei Sharp", + 0, 936}, + {0xdafedbef, L"STCaiyun", L"AR PL UKai HK,AR PL UMing HK,AR PL UKai CN", 0, + 936}, + {0xdb00a3d9, L"Broadway", + L"KacstQurn,Droid Sans Japanese,DejaVu Sans,FreeMono,Liberation Mono", 0, + 1252}, + {0xdb1f5ad4, L"STXinwei", L"AR PL UKai HK,AR PL UMing HK,AR PL UKai CN", 0, + 936}, + {0xdb326e7f, L"STKaiti", + L"WenQuanYi Micro Hei Mono,WenQuanYi Zen Hei Mono,WenQuanYi Zen " + L"Hei,WenQuanYi Zen Hei Sharp", + 0, 936}, + {0xdb69595a, L"STHupo", + L"WenQuanYi Micro Hei Mono,WenQuanYi Zen Hei Mono,WenQuanYi Zen " + L"Hei,WenQuanYi Zen Hei Sharp", + 0, 936}, + {0xdba0082c, L"STXihei", + L" WenQuanYi Micro Hei Mono,WenQuanYi Zen Hei Mono,WenQuanYi Zen " + L"Hei,WenQuanYi Zen Hei Sharp", + 0, 936}, + {0xdbd0ab18, L"STXingkai", L"AR PL UKai HK,AR PL UMing HK,AR PL UKai CN", 0, + 936}, + {0xdc1a7db1, L"STLiti", L"AR PL UKai HK,AR PL UMing HK,AR PL UKai CN", 0, + 936}, + {0xdc33075f, L"KristenITC-Regular", + L"Droid Arabic Naskh,Droid Sans Ethiopic,mry_KacstQurn,DejaVu Sans " + L"Condensed,Ubuntu,Liberation Sans", + 8, 1252}, + {0xdcc7009c, L"Harrington", + L"KacstQurn,Droid Sans Japanese,Liberation Serif,FreeSerif,Ubuntu", 0, + 1252}, + {0xdd712466, L"ArialBlack", + L"Droid Sans Japanese,DejaVu Sans,DejaVu Serif,FreeMono", 0, 1252}, + {0xdde87b3e, L"Impact", L"Droid Sans Japanese,DejaVu Serif", 0, 1252}, + {0xdf69fb32, L"SnapITC", + L"Liberation Sans Narrow,Ubuntu Condensed,DejaVu Sans,DejaVu " + L"Serif,FreeMono", + 0, 1252}, + {0xdf8b25e8, L"CenturyGothic", + L"Droid Sans Japanese,Liberation Mono,Liberation Sans,Liberation Serif", 0, + 1252}, + {0xe0f705c0, L"KristenITC", + L"Droid Arabic Naskh,Droid Sans Ethiopic,mry_KacstQurn,DejaVu Sans " + L"Condensed,Ubuntu,Liberation Sans", + 8, 1252}, + {0xe1427573, L"Raavi", + L"Droid Arabic Naskh,Droid Sans " + L"Ethiopic,mry_KacstQurn,FreeSerif,Liberation Serif,Khmer OS", + 0, 1252}, + {0xe2cea0cb, L"Magneto", + L"Droid Arabic Naskh,Droid Sans Ethiopic,mry_KacstQurn,DejaVu " + L"Serif,DejaVu Serif Condensed,DejaVu Sans", + 0, 1252}, + {0xe36a9e17, L"Ravie", + L"Droid Arabic Naskh,Droid Sans Ethiopic,mry_KacstQurn,DejaVu " + L"Serif,DejaVu Sans,FreeMono", + 0, 1252}, + {0xe433f8e2, L"Parchment", L"Droid Sans Japanese,DejaVu Serif", 8, 1252}, + {0xe43dff4a, L"Wingdings", L"DejaVu Serif", 4, 42}, + {0xe4e2c405, L"MTExtra", L"DejaVu Serif", 6, 42}, + {0xe618cc35, L"InformalRoman", + L"Droid Arabic Naskh,Droid Sans Ethiopic,mry_KacstQurn,Droid Sans " + L"Japanese,Nimbus Sans L,DejaVu Sans Condensed,Ubuntu,Liberation Sans", + 8, 1252}, + {0xe6c27ffc, L"Mistral", L"Droid Sans Japanese,DejaVu Serif", 8, 1252}, + {0xe7ebf4b9, L"Courier", L"DejaVu Sans,DejaVu Sans Condensed,FreeSerif", 0, + 1252}, + {0xe8bc4a9d, L"MSReferenceSpecialty", L"DejaVu Serif", 0, 1252}, + {0xe90fb013, L"TempusSansITC", + L"Droid Sans Japanese,Ubuntu,Liberation Serif,FreeSerif", 0, 1252}, + {0xec637b42, L"Consolas", + L"DejaVu Sans Condensed,AR PL UKai CN,AR PL UKai HK,AR PL UKai " + L"TW,FreeSerif,FreeSans", + 1, 1252}, + {0xed3a683b, L"STXinwei", L"AR PL UKai HK,AR PL UMing HK,AR PL UKai CN", 0, + 936}, + {0xef264cd1, L"LucidaHandwriting", + L"Liberation Sans Narrow,Ubuntu Condensed,Nimbus Sans " + L"L,KacstQurn,Liberation Mono", + 0, 1252}, + {0xf086bca2, L"BaskervilleOldFace", + L"KacstQurn,Droid Sans Japanese,Liberation Serif,Ubuntu,FreeSerif", 0, + 1252}, + {0xf1028030, L"Mangal", + L"FreeSans,TSCu_Paranar,Garuda,Liberation Sans,Liberation Sans " + L"Narrow,Nimbus Sans L", + 2, 1252}, + {0xf1da7eb9, L"ShowcardGothic", + L"Droid Sans Japanese,DejaVu Serif Condensed,DejaVu Sans " + L"Condensed,Liberation Sans,Ubuntu", + 0, 1252}, + {0xf210f06a, L"ArialMT", + L"Liberation Sans,Liberation Sans Narrow,FreeSans,Nimbus Sans L,Khmer OS " + L"System,Khmer OS", + 0, 1252}, + {0xf477f16a, L"Latha", + L"Liberation Sans Narrow,Nimbus Sans L,Droid Arabic " + L"Naskh,mry_KacstQurn,FreeSerif,Nimbus Sans L", + 0, 1252}, + {0xf616f3dd, L"LiSu", + L"WenQuanYi Zen Hei Mono,AR PL UMing CN,AR PL UMing HK,AR PL UMing TW,AR " + L"PL UMing TW MBE", + 1, 936}, + {0xfa479aa6, L"MicrosoftYaHei", + L"WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei,WenQuanYi Zen Hei " + L"Sharp,WenQuanYi Micro Hei", + 0, 936}, + {0xfcd19697, L"BookmanOldStyle", + L"Droid Sans Japanese,Liberation Mono,Liberation Sans,Liberation Serif", 0, + 1252}, + {0xfe209a82, L"LucidaCalligraphy", + L"KacstQurn,Droid Arabic Naskh,Droid Sans Ethiopic,mry_KacstQurn,Droid " + L"Sans Japanese,DejaVu Serif,DejaVu Sans,FreeMono", + 0, 1252}, + {0xfef135f8, L"AdobeHeitiStd-Regular", + L"WenQuanYi Zen Hei Mono,WenQuanYi Zen Hei,WenQuanYi Zen Hei " + L"Sharp,WenQuanYi Micro Hei", + 0, 936}, +}; +#elif _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ +const XFA_FONTINFO g_XFAFontsMap[] = { + {0x01d5d33e, L"SimSun", L"STHeiti,Heiti TC,STFangsong", 0, 936}, + {0x01e4f102, L"YouYuan", L"STHeiti,Heiti TC,STFangsong", 1, 936}, + {0x030549dc, L"LiSu", L"STHeiti,Heiti TC,STFangsong", 1, 936}, + {0x032edd44, L"Simhei", L"STHeiti,Heiti TC,STFangsong", 1, 936}, + {0x03eac6fc, L"PoorRichard-Regular", + L"Noteworthy,Avenir Next Condensed,Impact", 2, 1252}, + {0x03ed90e6, L"Nina", L"Microsoft Sans Serif", 0, 1252}, + {0x077b56b3, L"KingsoftPhoneticPlain", + L"LastResort,Apple " + L"Chancery,STIXVariants,STIXSizeOneSym,STIXSizeOneSym,Apple Braille", + 0, 1252}, + {0x078ed524, L"MicrosoftSansSerif", L"Songti SC,Apple Symbols", 0, 1252}, + {0x089b18a9, L"Arial", + L"Arial Unicode MS,Microsoft Sans Serif,Apple Symbols", 0, 1252}, + {0x0b2cad72, L"MonotypeCorsiva", L"Arial Narrow,Impact", 8, 1252}, + {0x0bb003e7, L"Kartika", + L"Arial Unicode MS,Microsoft Sans Serif,Arial Narrow,Damascus", 2, 1252}, + {0x0bb469df, L"VinerHandITC", L"Comic Sans MS,Songti SC,STSong", 8, 1252}, + {0x0bc1a851, L"SegoeUI", L"Apple Symbols", 0, 1252}, + {0x0c112ebd, L"KozukaGothicPro-VIM", L"Microsoft Sans Serif,Apple Symbols", + 0, 1252}, + {0x0cfcb9c1, L"AdobeThai", L"Avenir Next Condensed Ultra Light", 0, 847}, + {0x0e7de0f9, L"Playbill", L"STIXNonUnicode", 0, 1252}, + {0x0eff47c3, L"STHupo", L"Kaiti SC,Songti SC,STHeiti", 0, 936}, + {0x107ad374, L"Constantia", L"Arial Unicode MS,Palatino,Baskerville", 2, + 1252}, + {0x12194c2d, L"KunstlerScript", + L"Avenir Next Condensed Demi Bold,Arial Narrow", 8, 1252}, + {0x135ef6a1, L"MinionProSmBd", L"Microsoft Sans Serif,Apple Symbols", 0, + 1252}, + {0x158c4049, L"Garamond", L"Impact,Arial Narrow", 2, 1252}, + {0x160ecb24, L"STZhongsong", L"STFangsong,Songti SC", 0, 936}, + {0x161ed07e, L"MSGothic", + L"WenQuanYi Zen Hei Mono,AR PL UMing CN,AR PL UMing HK,AR PL UMing " + L"TW,Microsoft Sans Serif,Apple Symbols", + 1, 1252}, + {0x171d1ed1, L"SnapITC-Regular", L"STHeiti,Arial Black", 0, 1252}, + {0x18d1188f, L"Cambria", L"Arial Unicode MS", 2, 1252}, + {0x18eaf350, L"ArialUnicodeMS", L"Microsoft Sans Serif,Apple Symbols", 0, + 936}, + {0x1a92d115, L"MingLiU", L"Heiti SC,STHeiti", 1, 1252}, + {0x1cc217c6, L"TrebuchetMS", L"Damascus,Impact,Arial Narrow", 0, 1252}, + {0x1d649596, L"BasemicTimes", L"Liberation Serif,Impact,Arial Narrow", 0, + 1252}, + {0x1e34ee60, L"BellMT", + L"Papyrus,STIXNonUnicode,Microsoft Sans Serif,Avenir Light", 2, 1252}, + {0x1eb36945, L"CooperBlack", + L"Marion,STIXNonUnicode,Arial Rounded MT Bold,Lucida Grande", 2, 1252}, + {0x1ef7787d, L"BatangChe", + L"WenQuanYi Zen Hei Mono,AR PL UMing CN,,AR PL UMing HK,AR PL UMing TW,AR " + L"PL UMing TW MBE,Arial Unicode MS,Heiti TC", + 1, 1252}, + {0x20b3bd3a, L"BrushScriptMT", + L"STIXNonUnicode,Damascus,Arial Narrow,Avenir Next Condensed,Cochin", 8, + 1252}, + {0x220877aa, L"Candara", L"Cochin,Baskerville,Marion", 0, 1252}, + {0x22135007, L"FreestyleScript-Regular", + L"STIXNonUnicode,Nadeem,Zapf Dingbats", 8, 1252}, + {0x251059c3, L"Chiller", + L"Zapf Dingbats,Damascus,STIXNonUnicode,Papyrus,KufiStandardGK,Baghdad", 0, + 1252}, + {0x25bed6dd, L"MSReferenceSansSerif", + L"Tahoma,Apple Symbols,Apple LiGothic,Arial Unicode MS,Lucida " + L"Grande,Microsoft Sans Serif", + 0, 1252}, + {0x28154c81, L"Parchment-Regular", L"Microsoft Sans Serif,Apple Symbols", 8, + 1252}, + {0x29711eb9, L"STLiti", L"Kaiti SC,Songti SC", 0, 936}, + {0x2b1993b4, L"Basemic", L"Impact,Arial Narrow", 0, 1252}, + {0x2b316339, L"NiagaraSolid-Reg", L"Microsoft Sans Serif,Apple Symbols", 0, + 1252}, + {0x2c147529, L"FootlightMTLight", + L"STIXNonUnicode,Avenir Next Condensed Heavy,PT Sans,Noteworthy", 0, 1252}, + {0x2c198928, L"HarlowSolid", + L"Avenir Medium,Avenir Next Medium,Arial Unicode MS", 0, 1252}, + {0x2c6ac6b2, L"LucidaBright", + L"PT Sans Narrow,Papyrus,Damascus,STIXNonUnicode,Arial Rounded MT " + L"Bold,Comic Sans MS,Avenir Next", + 2, 1252}, + {0x2c9f38e2, L"KozukaMinchoPro-VIR", L"Microsoft Sans Serif,Apple Symbols", + 0, 1252}, + {0x2d5a47b0, L"STCaiyun", L"Kaiti SC,Songti SC", 0, 936}, + {0x2def26bf, L"BernardMT-Condensed", + L"Impact,Avenir Next Condensed Demi Bold,American Typewriter", 0, 1252}, + {0x2fd8930b, L"KozukaMinchoPr6NR", L"Microsoft Sans Serif,Apple Symbols", 0, + 1252}, + {0x3115525a, L"FangSong_GB2312", L"Hiragino Sans GB,STHeiti", 0, 1252}, + {0x31327817, L"MyriadPro", L"Microsoft Sans Serif,Apple Symbols", 0, 1252}, + {0x32244975, L"Helvetica", + L"Arial Narrow,Arial Unicode MS,Damascus,STIXNonUnicode", 0, 1252}, + {0x32ac995c, L"Terminal", L"Microsoft Sans Serif,Apple Symbols", 0, 1252}, + {0x338d648a, L"NiagaraEngraved-Reg", L"Microsoft Sans Serif,Apple Symbols", + 0, 1252}, + {0x33bb65f2, L"Sylfaen", L"Arial Unicode MS,Marion", 2, 1252}, + {0x3402c30e, L"MSPMincho", L"Arial Unicode MS,Apple SD Gothic Neo", 2, + 1252}, + {0x3412bf31, L"SimSun-PUA", L"STHeiti,Heiti TC,STFangsong", 0, 936}, + {0x36eb39b9, L"BerlinSansFB", L"American Typewriter,Impact", 0, 1252}, + {0x36f42055, L"UniversATT", L"Microsoft Sans Serif", 0, 1252}, + {0x3864c4f6, L"HighTowerText", L"STIXGeneral,.Helvetica Neue Desk UI", 2, + 1252}, + {0x3a257d03, L"FangSong_GB2312", L"Hiragino Sans GB,STHeiti", 0, 1252}, + {0x3cdae668, L"FreestyleScript", L"Nadeem,Zapf Dingbats,STIXNonUnicode", 8, + 1252}, + {0x3d55aed7, L"Jokerman", + L"Papyrus,Lucida Grande,Heiti TC,American Typewriter", 0, 1252}, + {0x3d5b4385, L"PMingLiU", L"Heiti SC,STHeiti", 2, 1252}, + {0x3d9b7669, L"EstrangeloEdessa", L"American Typewriter,Marion", 0, 1252}, + {0x3e532d74, L"FranklinGothicMedium", L"Impact,Arial Narrow", 0, 1252}, + {0x3e6aa32d, L"NSimSun", L"STHeiti,STFangsong", 1, 936}, + {0x3f6c36a8, L"Gautami", + L"Damascus,STIXNonUnicode,STIXGeneral,American Typewriter", 0, 1252}, + {0x3ff32662, L"Chiller-Regular", L"Papyrus,KufiStandardGK,Baghdad", 0, + 1252}, + {0x409de312, L"ModernNo.20", L"Avenir Next Condensed,Impact", 2, 1252}, + {0x41443c5e, L"Georgia", L".Helvetica Neue Desk UI,Arial Unicode MS", 2, + 1252}, + {0x4160ade5, L"BellGothicStdBlack", L"Microsoft Sans Serif,Apple Symbols", + 0, 1252}, + {0x421976c4, L"Modern-Regular", L"Impact", 2, 1252}, + {0x422a7252, L"Stencil", L"STIXNonUnicode,Songti SC,Georgia,Baskerville", 0, + 1252}, + {0x42c8554f, L"Fixedsys", L"Microsoft Sans Serif,Apple Symbols", 0, 1252}, + {0x435cb41d, L"Roman", L"Arial Narrow", 0, 1252}, + {0x47882383, L"CourierNew", L"PCMyungjo,Osaka,Arial Unicode MS,Songti SC", + 1, 1252}, + {0x480a2338, L"BerlinSansFBDemi", + L"STIXNonUnicode,American Typewriter,Avenir Next Condensed Heavy", 0, + 1252}, + {0x480bf7a4, L"CourierStd", L"Courier New", 0, 1252}, + {0x481ad6ed, L"VladimirScript", + L"STIXNonUnicode,Avenir Next Condensed,Impact", 8, 1252}, + {0x4911577a, L"YouYuan", L"STHeiti,Heiti TC", 1, 936}, + {0x4a788d72, L"STXingkai", L"Kaiti SC,Songti SC", 0, 936}, + {0x4bf88566, L"SegoeCondensed", L"Microsoft Sans Serif,Apple Symbols", 0, + 1252}, + {0x4ccf51a4, L"BerlinSansFB-Reg", + L"STIXNonUnicode,American Typewriter,Impact", 0, 1252}, + {0x4ea967ce, L"GulimChe", L"Arial Unicode MS,Heiti TC,STFangsong", 1, 1252}, + {0x4f68bd79, L"LetterGothicStd", + L"Courier New,Andale Mono,Ayuthaya,PCMyungjo,Osaka", 0, 1252}, + {0x51a0d0e6, L"KozukaGothicPr6NM", L"Microsoft Sans Serif,Apple Symbols", 0, + 1252}, + {0x531b3dea, L"BasemicSymbol", L"Microsoft Sans Serif,Apple Symbols", 0, + 1252}, + {0x5333fd39, L"CalifornianFB-Reg", + L"American Typewriter,Avenir Next Condensed,Impact", 2, 1252}, + {0x53561a54, L"FZYTK--GBK1-0", L"STFangsong,Songti SC,STSong", 0, 936}, + {0x55e0dde6, L"LucidaSansTypewriter", L"Menlo,Courier New,Andale Mono", 0, + 1252}, + {0x574d4d3d, L"AdobeArabic", L"Arial Narrow", 0, 1252}, + {0x5792e759, L"STKaiti", L"Songti SC,Arial Unicode MS", 0, 936}, + {0x5921978e, L"LucidaSansUnicode", L"Lucida Grande,Arial Unicode MS,Menlo", + 0, 1252}, + {0x594e2da4, L"Vrinda", L"Geeza Pro,Damascus,STIXGeneral,Gill Sans", 0, + 1252}, + {0x59baa9a2, L"KaiTi_GB2312", L"Hiragino Sans GB,STHeiti", 0, 1252}, + {0x5cfedf4f, L"BaskOldFace", + L"Avenir Next Condensed Heavy,PT Sans,Avenir Next Condensed", 0, 1252}, + {0x5e16ac91, L"TrajanPro", L"Arial Narrow,PT Sans Narrow,Damascus", 0, + 1252}, + {0x5f97921c, L"AdobeMyungjoStdM", + L"AppleMyungjo,AppleGothic,Arial Unicode MS", 0, 936}, + {0x5fefbfad, L"Batang", L"Arial Unicode MS,Songti SC", 2, 1252}, + {0x605342b9, L"DotumChe", L"Arial Unicode MS,Heiti TC", 1, 1252}, + {0x608c5f9a, L"KaiTi_GB2312", L"Hiragino Sans GB,STHeiti,Heiti TC", 0, 936}, + {0x61efd0d1, L"MaturaMTScriptCapitals", + L"Kokonor,Damascus,STIXNonUnicode,STHeiti,Arial Black,Avenir Next Heavy", + 0, 1252}, + {0x626608a9, L"MVBoli", + L"Apple Braille,Geeza Pro,Microsoft Sans Serif,Apple Symbols", 0, 1252}, + {0x630501a3, L"SmallFonts", L"Microsoft Sans Serif,Apple Symbols", 0, 1252}, + {0x65d0e2a9, L"FZYTK--GBK1-0", L"STFangsong,Songti SC,STSong", 0, 936}, + {0x669f29e1, L"FZSTK--GBK1-0", L"STHeiti,Heiti TC", 0, 936}, + {0x673a9e5f, L"Tunga", + L"Damascus,STIXNonUnicode,Avenir Next Condensed,Avenir Next Condensed " + L"Ultra Light,Futura", + 0, 1252}, + {0x691aa4ce, L"NiagaraSolid", L"Microsoft Sans Serif,Apple Symbols", 0, + 1252}, + {0x696259b7, L"Corbel", L"Cochin,Baskerville,Marion", 0, 1252}, + {0x696ee9be, L"STXihei", L"STHeiti,Heiti TC,Songti SC,Arial Unicode MS", 0, + 936}, + {0x6c59cf69, L"Dotum", L"Arial Unicode MS,Songti SC", 0, 1252}, + {0x707fa561, L"Gungsuh", L"Arial Unicode MS,Heiti TC", 2, 1252}, + {0x71416bb2, L"ZWAdobeF", + L"STIXSizeFourSym,STIXSizeThreeSym,STIXSizeTwoSym,STIXSizeOneSym", 0, + 1252}, + {0x71b41801, L"Verdana", + L"Tahoma,Marion,Apple Symbols,.Helvetica Neue Desk UI,Lucida " + L"Grande,Courier New", + 0, 1252}, + {0x73f25e4c, L"PalatinoLinotype", L"Palatino,Arial Unicode MS", 0, 1252}, + {0x73f4d19f, L"NiagaraEngraved", L"Microsoft Sans Serif,Apple Symbols", 0, + 1252}, + {0x74001694, L"MyriadProBlack", L"Palatino,Baskerville,Marion,Cochin", 0, + 1252}, + {0x74b14d8f, L"Haettenschweiler", L"Microsoft Sans Serif,Apple Symbols", 0, + 1252}, + {0x74cb44ee, L"NSimSun", L"STHeiti,Heiti TC,STFangsong", 1, 936}, + {0x76b4d7ff, L"Shruti", + L"Damascus,STIXNonUnicode,Arial Unicode MS,American Typewriter", 0, 1252}, + {0x788b3533, L"Webdings", L"Microsoft Sans Serif,Apple Symbols", 6, 42}, + {0x797dde99, L"MSSerif", L"Microsoft Sans Serif,Apple Symbols", 0, 1252}, + {0x7a0f9e9e, L"MSMincho", + L"WenQuanYi Zen Hei Mono,AR PL UMing CN,AR PL UMing HK,AR PL UMing TW,AR " + L"PL UMing TW MBE,Arial Unicode MS,Apple SD Gothic Neo", + 1, 1252}, + {0x7b439caf, L"OldEnglishTextMT", + L"STIXNonUnicode,Arial Unicode MS,Baskerville,Avenir Next Medium", 0, + 1252}, + {0x8213a433, L"LucidaSans-Typewriter", + L"Comic Sans MS,Avenir Next,Arial Rounded MT Bold", 0, 1252}, + {0x82fec929, L"AdobeSongStdL", L"Heiti TC,STHeiti", 0, 936}, + {0x83581825, L"Modern", L"Avenir Next Condensed,Impact", 0, 1252}, + {0x835a2823, L"Algerian", + L"STIXNonUnicode,Baskerville,Avenir Next Medium,American Typewriter", 0, + 1252}, + {0x83dab9f5, L"Script", L"Arial Narrow", 0, 1252}, + {0x847b56da, L"Tahoma", L"Songti SC,Apple Symbols", 0, 1252}, + {0x8a783cb2, L"SimSun-PUA", L"STHeiti,Heiti TC,STFangsong", 0, 1252}, + {0x8b5cac0e, L"Onyx", L"Microsoft Sans Serif,Apple Symbols", 0, 1252}, + {0x8c6a499e, L"Gulim", L"Arial Unicode MS,Songti SC", 0, 1252}, + {0x8e0af790, L"JuiceITC", L"Nadeem,Al Bayan", 0, 1252}, + {0x8e8d43b2, L"Centaur", L"Avenir Next Condensed,Noteworthy,Impact", 2, + 1252}, + {0x8ee4dcca, L"BookshelfSymbol7", L"Microsoft Sans Serif,Apple Symbols", 0, + 1252}, + {0x90794800, L"BellGothicStdLight", L"Microsoft Sans Serif,Apple Symbols", + 0, 1252}, + {0x909b516a, L"Century", L"Damascus,Andale Mono,Songti SC,Arial Unicode MS", + 2, 1252}, + {0x92ae370d, L"MSOutlook", L"Microsoft Sans Serif,Apple Symbols", 4, 42}, + {0x93c9fbf1, L"LucidaFax", + L"PT Sans Narrow,Papyrus,Kokonor,Geeza Pro,Arial Rounded MT Bold,Lucida " + L"Grande,Futura", + 2, 1252}, + {0x9565085e, L"BookAntiqua", L"Palatino,Microsoft Sans Serif,Apple Symbols", + 2, 1252}, + {0x9856d95d, L"AdobeMingStdL", L"AHiragino Sans GB,Heiti TC,STHeiti", 0, + 949}, + {0x9bbadd6b, L"ColonnaMT", L"Noteworthy,Avenir Next Condensed,Impact", 0, + 1252}, + {0x9cbd16a4, L"ShowcardGothic-Reg", + L"Arial Unicode MS,Georgia,American Typewriter", 0, 1252}, + {0x9d73008e, L"MSSansSerif", L"Songti SC,Apple Symbols", 0, 1252}, + {0xa0607db1, L"GungsuhChe", + L"WenQuanYi Zen Hei Mono,AR PL UMing CN,AR PL UMing HK,AR PL UMing TW,AR " + L"PL UMing TW MBE,Arial Unicode MS,Heiti TC,STFangsong", + 1, 1252}, + {0xa0bcf6a1, L"LatinWide", L"Zapfino,Arial Black,STHeiti", 2, 1252}, + {0xa1429b36, L"Symbol", L"Microsoft Sans Serif,Apple Symbols", 6, 42}, + {0xa1fa5abc, L"Wingdings2", L"Microsoft Sans Serif,Apple Symbols", 6, 42}, + {0xa1fa5abd, L"Wingdings3", L"Microsoft Sans Serif,Apple Symbols", 6, 42}, + {0xa427bad4, L"InformalRoman-Regular", + L"STIXNonUnicode,Arial Narrow,Avenir Next Condensed Demi Bold", 8, 1252}, + {0xa8b92ece, L"FZSTK--GBK1-0", L"STHeiti,Heiti TC,STFangsong", 0, 936}, + {0xa8d83ece, L"CalifornianFB", + L"American Typewriter,Avenir Next Condensed,Impact", 2, 1252}, + {0xaa3e082c, L"Kingsoft-Phonetic", + L"STIXVariants,STIXSizeOneSym,Apple Braille", 0, 1252}, + {0xaa6bcabe, L"HarlowSolidItalic", + L"STIXNonUnicode,Avenir Medium,Avenir Next Medium,Arial Unicode MS", 0, + 1252}, + {0xade5337c, L"MSUIGothic", L"Arial Unicode MS,Apple SD Gothic Neo", 0, + 1252}, + {0xb08dd941, L"WideLatin", + L"Marion,Papyrus,Nanum Pen Script,Zapf Dingbats,Damascus,Zapfino,Arial " + L"Black,STHeiti", + 2, 1252}, + {0xb12765e0, L"ITCLegacySansStdBook", + L"LastResort,.Helvetica Neue Desk UI,Arial Unicode MS,Palatino", 0, 1252}, + {0xb207f05d, L"PoorRichard", L"Noteworthy,Avenir Next Condensed,Impact", 2, + 1252}, + {0xb3bc492f, L"JuiceITC-Regular", L"Nadeem,Al Bayan,STIXNonUnicode", 0, + 1252}, + {0xb5545399, L"Marlett", L"Microsoft Sans Serif,Apple Symbols", 4, 42}, + {0xb5dd1ebb, L"BritannicBold", + L"Damascus,STIXNonUnicode,Avenir Next Condensed Heavy,PT Sans", 0, 1252}, + {0xb699c1c5, L"LucidaCalligraphy-Italic", L"STHeiti,Arial Black", 0, 1252}, + {0xb725d629, L"TimesNewRoman", L"Microsoft Sans Serif,Apple Symbols", 2, + 1252}, + {0xb7eaebeb, L"AdobeHeitiStdR", L"Heiti TC,STHeiti", 0, 936}, + {0xbd29c486, L"BerlinSansFBDemi-Bold", + L"American Typewriter,Avenir Next Condensed Heavy", 0, 1252}, + {0xbe8a8db4, L"BookshelfSymbolSeven", L"Microsoft Sans Serif,Apple Symbols", + 0, 1252}, + {0xc16c0118, L"AdobeHebrew", + L".Helvetica Neue Desk UI,Palatino,American Typewriter", 0, 1252}, + {0xc318b0af, L"MyriadProLight", L"Palatino,Baskerville,Marion", 0, 1252}, + {0xc65e5659, L"CambriaMath", L"Arial Unicode MS", 2, 1252}, + {0xc75c8f05, L"LucidaConsole", L"Courier New,Menlo,Andale Mono", 1, 1252}, + {0xca7c35d6, L"Calibri", L"Apple Symbols,HeadLineA", 0, 1252}, + {0xcb053f53, L"MicrosoftYaHei", L"Arial Unicode MS", 0, 936}, + {0xcb7190f9, L"Magneto-Bold", L"Lucida Grande", 0, 1252}, + {0xcca00cc5, L"System", L"Microsoft Sans Serif,Apple Symbols", 0, 1252}, + {0xccad6f76, L"Jokerman-Regular", L"Lucida Grande", 0, 1252}, + {0xccc5818c, L"EuroSign", L"Microsoft Sans Serif,Apple Symbols", 0, 1252}, + {0xcf3d7234, L"LucidaHandwriting-Italic", + L"Microsoft Sans Serif,Apple Symbols", 0, 1252}, + {0xcf7b8fdb, L"MinionPro", + L"Bell MT,Corbel,Times New Roman,Cambria,Berlin Sans FB", 0, 1252}, + {0xcfe5755f, L"Simhei", L"STHeiti,Heiti TC,STFangsong", 1, 936}, + {0xd011f4ee, L"MSPGothic", L"Arial Unicode MS,Apple SD Gothic Neo", 0, + 1252}, + {0xd060e7ef, L"Vivaldi", + L"STIXNonUnicode,Arial Unicode MS,Avenir Medium,Avenir Next Medium", 8, + 1252}, + {0xd07edec1, L"FranklinGothic-Medium", L"Impact,Arial Narrow", 0, 1252}, + {0xd107243f, L"SimSun", L"STHeiti,Heiti TC,STFangsong", 0, 936}, + {0xd1881562, L"ArialNarrow", L"PT Sans Narrow,Apple Symbols", 0, 1252}, + {0xd22b7dce, L"BodoniMTPosterCompressed", + L"Microsoft Sans Serif,Apple Symbols", 0, 1252}, + {0xd22bfa60, L"ComicSansMS", + L"Damascus,Georgia,.Helvetica Neue Desk UI,Lucida Grande,Arial Unicode MS", + 8, 1252}, + {0xd3bd0e35, L"Bauhaus93", + L"STIXNonUnicode,Arial Unicode MS,Avenir Next,Avenir", 0, 1252}, + {0xd429ee7a, L"STFangsong", L"Songti SC,Arial Unicode MS", 0, 936}, + {0xd6679c12, L"BernardMTCondensed", + L"Impact,Avenir Next Condensed Demi Bold", 0, 1252}, + {0xd8e8a027, L"LucidaSans", + L"Arial Narrow,Khmer MN,Kokonor,Damascus,Microsoft Sans Serif,Apple " + L"Symbols", + 0, 1252}, + {0xd9fe7761, L"HighTowerText-Reg", + L"STIXGeneral,.Helvetica Neue Desk UI,Trebuchet MS", 2, 1252}, + {0xda7e551e, L"STSong", L"Arial Unicode MS", 0, 936}, + {0xdaa6842d, L"STZhongsong", L"STFangsong,Songti SC,STSong", 0, 936}, + {0xdaaab93f, L"STFangsong", L"Songti SC,Arial Unicode MS", 0, 936}, + {0xdaeb0713, L"STSong", L"Songti SC,Arial Unicode MS", 0, 936}, + {0xdafedbef, L"STCaiyun", L"Kaiti SC,Songti SC,STHeiti", 0, 936}, + {0xdb00a3d9, L"Broadway", + L"Papyrus,STIXNonUnicode,Arial Black,Avenir Next Heavy,Heiti TC", 0, 1252}, + {0xdb1f5ad4, L"STXinwei", L"Kaiti SC,Songti SC,STHeiti", 0, 936}, + {0xdb326e7f, L"STKaiti", L"Songti SC,Arial Unicode MS", 0, 936}, + {0xdb69595a, L"STHupo", L"Kaiti SC,Songti SC,STHeiti", 0, 936}, + {0xdba0082c, L"STXihei", L"Songti SC,Arial Unicode MS", 0, 936}, + {0xdbd0ab18, L"STXingkai", L"Kaiti SC,Songti SC", 0, 936}, + {0xdc1a7db1, L"STLiti", L"Kaiti SC,Songti SC", 0, 936}, + {0xdc33075f, L"KristenITC-Regular", + L"STIXNonUnicode,Damascus,Songti SC,STSong", 8, 1252}, + {0xdcc7009c, L"Harrington", + L"STIXNonUnicode,Avenir Next Condensed Heavy,Noteworthy", 0, 1252}, + {0xdd712466, L"ArialBlack", L"Geeza Pro,Damascus,Songti SC,STSong", 0, + 1252}, + {0xdde87b3e, L"Impact", L"Arial Narrow,Marion", 0, 1252}, + {0xdf69fb32, L"SnapITC", + L"Arial Narrow,PT Sans Narrow,Marion,STHeiti,Arial Black", 0, 1252}, + {0xdf8b25e8, L"CenturyGothic", + L"Damascus,Andale Mono,Songti SC,Arial Unicode MS", 0, 1252}, + {0xe0f705c0, L"KristenITC", L"Songti SC,STSong", 8, 1252}, + {0xe1427573, L"Raavi", + L"Damascus,STIXNonUnicode,Marion,Papyrus,Avenir Next Condensed " + L"Heavy,American Typewriter", + 0, 1252}, + {0xe2cea0cb, L"Magneto", + L"STIXNonUnicode,Damascus,Geeza Pro,Lucida Grande,Georgia,Heiti TC", 0, + 1252}, + {0xe36a9e17, L"Ravie", L"STHeiti,Arial Black", 0, 1252}, + {0xe433f8e2, L"Parchment", L"Microsoft Sans Serif,Apple Symbols", 8, 1252}, + {0xe43dff4a, L"Wingdings", L"Microsoft Sans Serif,Apple Symbols", 4, 42}, + {0xe4e2c405, L"MTExtra", L"Microsoft Sans Serif,Apple Symbols", 6, 42}, + {0xe618cc35, L"InformalRoman", L"Arial Narrow", 8, 1252}, + {0xe6c27ffc, L"Mistral", L"Apple Symbols", 8, 1252}, + {0xe7ebf4b9, L"Courier", L"Courier New", 0, 1252}, + {0xe8bc4a9d, L"MSReferenceSpecialty", L"Microsoft Sans Serif,Apple Symbols", + 0, 1252}, + {0xe90fb013, L"TempusSansITC", + L"STIXNonUnicode,Microsoft Sans Serif,Avenir Light", 0, 1252}, + {0xec637b42, L"Consolas", + L"AR PL UKai CN,AR PL UKai HK,AR PL UKai TW,AR PL UKai TW MBE,AR PL UMing " + L"CN,AR PL UMing HK,Microsoft Sans Serif,Tahoma", + 1, 1252}, + {0xed3a683b, L"STXinwei", L"Kaiti SC,Songti SC,", 0, 936}, + {0xef264cd1, L"LucidaHandwriting", + L"Arial Narrow,Avenir Next Condensed Demi Bold,Avenir Next " + L"Condensed,Avenir Next Condensed Medium,STHeiti,Arial Black", + 0, 1252}, + {0xf086bca2, L"BaskervilleOldFace", + L"STIXNonUnicode,Avenir Next Condensed Heavy,PT Sans", 0, 1252}, + {0xf1028030, L"Mangal", + L"Arial Unicode MS,Microsoft Sans Serif,Arial Narrow,Tahoma", 2, 1252}, + {0xf1da7eb9, L"ShowcardGothic", + L"Papyrus,Arial Unicode MS,Georgia,American Typewriter", 0, 1252}, + {0xf210f06a, L"ArialMT", + L"Arial Unicode MS,Arial Narrow,STIXNonUnicode,Damascus,Avenir Next " + L"Condensed Demi Bold,Avenir Next Condensed Medium,Avenir Next Condensed", + 0, 1252}, + {0xf477f16a, L"Latha", + L"Arial Narrow,Damascus,STIXNonUnicode,American Typewriter", 0, 1252}, + {0xf616f3dd, L"LiSu", L"STHeiti,Heiti TC,STFangsong", 1, 936}, + {0xfa479aa6, L"MicrosoftYaHei", L"Arial Unicode MS", 0, 936}, + {0xfcd19697, L"BookmanOldStyle", + L"Geeza Pro,Damascus,Andale Mono,Songti SC,Arial Unicode MS", 0, 1252}, + {0xfe209a82, L"LucidaCalligraphy", + L"Kokonor,Damascus,STIXNonUnicode,STHeiti,Arial Black", 0, 1252}, + {0xfef135f8, L"AdobeHeitiStd-Regular", L"Heiti TC,STHeiti", 0, 936}, +}; +#elif _FXM_PLATFORM_ == _FXM_PLATFORM_ANDROID_ +const XFA_FONTINFO g_XFAFontsMap[] = { + {0x01d5d33e, L"SimSun", L"Droid Sans Fallback", 0, 936}, + {0x01e4f102, L"YouYuan", L"Droid Sans Fallback", 1, 936}, + {0x030549dc, L"LiSu", L"Droid Sans Fallback", 1, 936}, + {0x032edd44, L"Simhei", L"Droid Sans Fallback", 1, 936}, + {0x03eac6fc, L"PoorRichard-Regular", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback,Droid Arabic " + L"Naskh,Droid Sans Ethiopic", + 2, 1252}, + {0x03ed90e6, L"Nina", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x077b56b3, L"KingsoftPhoneticPlain", + L"Droid Sans Thai,Droid Sans Armenian,Droid Arabic Naskh,Droid Sans " + L"Ethiopic,Droid Sans Fallback", + 0, 1252}, + {0x078ed524, L"MicrosoftSansSerif", L"Droid Sans Fallback", 0, 1252}, + {0x089b18a9, L"Arial", L"Droid Sans Fallback", 0, 1252}, + {0x0b2cad72, L"MonotypeCorsiva", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 8, 1252}, + {0x0bb003e7, L"Kartika", + L"Droid Arabic Naskh,Droid Sans Ethiopic,Roboto,Droid Serif,Droid Sans " + L"Mono", + 2, 1252}, + {0x0bb469df, L"VinerHandITC", + L"Droid Serif,Roboto,Droid Sans Mono,Droid Sans Fallback", 8, 1252}, + {0x0bc1a851, L"SegoeUI", L"Droid Sans Fallback", 0, 1252}, + {0x0c112ebd, L"KozukaGothicPro-VIM", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x0cfcb9c1, L"AdobeThai", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 847}, + {0x0e7de0f9, L"Playbill", + L"Droid Arabic Naskh,Droid Sans Ethiopic,Roboto,Droid Serif,Droid Sans " + L"Mono", + 0, 1252}, + {0x0eff47c3, L"STHupo", L"Droid Sans Fallback", 0, 936}, + {0x107ad374, L"Constantia", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 2, 1252}, + {0x12194c2d, L"KunstlerScript", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 8, 1252}, + {0x135ef6a1, L"MinionProSmBd", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x158c4049, L"Garamond", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 2, 1252}, + {0x160ecb24, L"STZhongsong", L"Droid Sans Fallback", 0, 936}, + {0x161ed07e, L"MSGothic", L"Droid Sans Fallback", 1, 1252}, + {0x171d1ed1, L"SnapITC-Regular", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x18d1188f, L"Cambria", L"Droid Sans Fallback", 2, 1252}, + {0x18eaf350, L"ArialUnicodeMS", L"Droid Sans Fallback", 0, 936}, + {0x1a92d115, L"MingLiU", L"Droid Sans Fallback", 1, 1252}, + {0x1cc217c6, L"TrebuchetMS", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x1d649596, L"BasemicTimes", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x1e34ee60, L"BellMT", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 2, 1252}, + {0x1eb36945, L"CooperBlack", + L"Droid Serif,Roboto,Droid Sans Mono,Droid Sans Fallback", 2, 1252}, + {0x1ef7787d, L"BatangChe", L"Droid Sans Fallback", 1, 1252}, + {0x20b3bd3a, L"BrushScriptMT", L"Droid Arabic Naskh,Droid Sans Ethiopic", 8, + 1252}, + {0x220877aa, L"Candara", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x22135007, L"FreestyleScript-Regular", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 8, 1252}, + {0x251059c3, L"Chiller", + L"Droid Arabic Naskh,Droid Sans Ethiopic,Roboto,Droid Serif", 0, 1252}, + {0x25bed6dd, L"MSReferenceSansSerif", L"Droid Sans Fallback", 0, 1252}, + {0x28154c81, L"Parchment-Regular", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 8, 1252}, + {0x29711eb9, L"STLiti", L"Droid Sans Fallback", 0, 936}, + {0x2b1993b4, L"Basemic", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x2b316339, L"NiagaraSolid-Reg", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x2c147529, L"FootlightMTLight", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x2c198928, L"HarlowSolid", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x2c6ac6b2, L"LucidaBright", + L"Droid Arabic Naskh,Droid Sans Ethiopic,Droid Serif,Roboto", 2, 1252}, + {0x2c9f38e2, L"KozukaMinchoPro-VIR", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x2d5a47b0, L"STCaiyun", L"Droid Sans Fallback", 0, 936}, + {0x2def26bf, L"BernardMT-Condensed", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x2fd8930b, L"KozukaMinchoPr6NR", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x3115525a, L"FangSong_GB2312", L"Droid Sans Fallback", 0, 1252}, + {0x31327817, L"MyriadPro", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x32244975, L"Helvetica", + L"Droid Arabic Naskh,Droid Sans Ethiopic,Droid Serif,Roboto", 0, 1252}, + {0x32ac995c, L"Terminal", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x338d648a, L"NiagaraEngraved-Reg", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x33bb65f2, L"Sylfaen", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 2, 1252}, + {0x3402c30e, L"MSPMincho", L"Droid Sans Fallback", 2, 1252}, + {0x3412bf31, L"SimSun-PUA", L"Droid Sans Fallback", 0, 936}, + {0x36eb39b9, L"BerlinSansFB", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x36f42055, L"UniversATT", L"Microsoft Sans Serif", 0, 1252}, + {0x3864c4f6, L"HighTowerText", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 2, 1252}, + {0x3a257d03, L"FangSong_GB2312", L"Droid Sans Fallback", 0, 1252}, + {0x3cdae668, L"FreestyleScript", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 8, 1252}, + {0x3d55aed7, L"Jokerman", + L"Droid Serif,Roboto,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x3d5b4385, L"PMingLiU", L"Droid Sans Fallback", 2, 1252}, + {0x3d9b7669, L"EstrangeloEdessa", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x3e532d74, L"FranklinGothicMedium", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x3e6aa32d, L"NSimSun", L"Droid Sans Fallback", 1, 936}, + {0x3f6c36a8, L"Gautami", + L"Droid Arabic Naskh,Droid Sans Ethiopic,Roboto,Droid Serif,Droid Sans " + L"Mono,Droid Sans Fallback", + 0, 1252}, + {0x3ff32662, L"Chiller-Regular", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x409de312, L"ModernNo.20", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 2, 1252}, + {0x41443c5e, L"Georgia", + L"Droid Serif,Roboto,Droid Sans Mono,Droid Sans Fallback", 2, 1252}, + {0x4160ade5, L"BellGothicStdBlack", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x421976c4, L"Modern-Regular", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 2, 1252}, + {0x422a7252, L"Stencil", + L"Droid Serif,Roboto,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x42c8554f, L"Fixedsys", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x435cb41d, L"Roman", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x47882383, L"CourierNew", L"Droid Sans Fallback", 1, 1252}, + {0x480a2338, L"BerlinSansFBDemi", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x480bf7a4, L"CourierStd", L"Droid Sans Fallback", 0, 1252}, + {0x481ad6ed, L"VladimirScript", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 8, 1252}, + {0x4911577a, L"YouYuan", L"Droid Sans Fallback", 1, 936}, + {0x4a788d72, L"STXingkai", L"Droid Sans Fallback", 0, 936}, + {0x4bf88566, L"SegoeCondensed", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x4ccf51a4, L"BerlinSansFB-Reg", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x4ea967ce, L"GulimChe", L"Droid Sans Fallback", 1, 1252}, + {0x4f68bd79, L"LetterGothicStd", + L"Droid Sans Mono,Droid Arabic Naskh,Droid Sans Ethiopic,Droid Sans " + L"Mono,Droid Serif,Droid Sans Fallback", + 0, 1252}, + {0x51a0d0e6, L"KozukaGothicPr6NM", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x531b3dea, L"BasemicSymbol", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x5333fd39, L"CalifornianFB-Reg", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 2, 1252}, + {0x53561a54, L"FZYTK--GBK1-0", L"Droid Sans Fallback", 0, 936}, + {0x55e0dde6, L"LucidaSansTypewriter", + L"Droid Sans Mono,Droid Arabic Naskh,Droid Sans Ethiopic", 0, 1252}, + {0x574d4d3d, L"AdobeArabic", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x5792e759, L"STKaiti", L"Droid Sans Fallback", 0, 936}, + {0x5921978e, L"LucidaSansUnicode", L"Droid Sans Fallback", 0, 1252}, + {0x594e2da4, L"Vrinda", + L"Droid Arabic Naskh,Droid Sans Ethiopic,Roboto,Droid Serif,Droid Sans " + L"Mono", + 0, 1252}, + {0x59baa9a2, L"KaiTi_GB2312", L"Droid Sans Fallback", 0, 1252}, + {0x5cfedf4f, L"BaskOldFace", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x5f97921c, L"AdobeMyungjoStdM", L"Droid Sans Fallback", 0, 936}, + {0x5fefbfad, L"Batang", L"Droid Sans Fallback", 2, 1252}, + {0x605342b9, L"DotumChe", L"Droid Sans Fallback", 1, 1252}, + {0x608c5f9a, L"KaiTi_GB2312", L"Droid Sans Fallback", 0, 936}, + {0x61efd0d1, L"MaturaMTScriptCapitals", + L"Droid Arabic Naskh,Droid Sans Ethiopic,Droid Serif,Roboto,Droid Sans " + L"Mono", + 0, 1252}, + {0x626608a9, L"MVBoli", + L"Droid Arabic Naskh,Droid Sans Ethiopic,Droid Serif,Roboto,Droid Sans " + L"Mono", + 0, 1252}, + {0x630501a3, L"SmallFonts", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x65d0e2a9, L"FZYTK--GBK1-0", L"Droid Sans Fallback", 0, 936}, + {0x669f29e1, L"FZSTK--GBK1-0", L"Droid Sans Fallback", 0, 936}, + {0x673a9e5f, L"Tunga", + L"Droid Arabic Naskh,Droid Sans Ethiopic,Roboto,Droid Serif,Droid Sans " + L"Mono,Droid Sans Fallback", + 0, 1252}, + {0x691aa4ce, L"NiagaraSolid", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x696259b7, L"Corbel", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x696ee9be, L"STXihei", L"Droid Sans Fallback", 0, 936}, + {0x6c59cf69, L"Dotum", L"Droid Sans Fallback", 0, 1252}, + {0x707fa561, L"Gungsuh", L"Droid Sans Fallback", 2, 1252}, + {0x71416bb2, L"ZWAdobeF", + L"Droid Arabic Naskh,Droid Sans Armenian,Droid Sans Ethiopic,Droid Sans " + L"Georgian,Droid Sans Hebrew,Droid Sans Thai", + 0, 1252}, + {0x71b41801, L"Verdana", + L"Droid Serif,Roboto,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x73f25e4c, L"PalatinoLinotype", L"Droid Sans Fallback", 0, 1252}, + {0x73f4d19f, L"NiagaraEngraved", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x74001694, L"MyriadProBlack", L"Book Antiqua,Constantia,Dotum,Georgia", 0, + 1252}, + {0x74b14d8f, L"Haettenschweiler", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x74cb44ee, L"NSimSun", L"Droid Sans Fallback", 1, 936}, + {0x76b4d7ff, L"Shruti", + L"Droid Arabic Naskh,Droid Sans Ethiopic,Roboto,Droid Serif,Droid Sans " + L"Mono", + 0, 1252}, + {0x788b3533, L"Webdings", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 6, 42}, + {0x797dde99, L"MSSerif", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x7a0f9e9e, L"MSMincho", L"Droid Sans Fallback", 1, 1252}, + {0x7b439caf, L"OldEnglishTextMT", + L"Droid Serif,Roboto,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x8213a433, L"LucidaSans-Typewriter", + L"Droid Sans Mono,Droid Serif,Roboto,Droid Sans Fallback", 0, 1252}, + {0x82fec929, L"AdobeSongStdL", L"Droid Sans Fallback", 0, 936}, + {0x83581825, L"Modern", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x835a2823, L"Algerian", + L"Droid Serif,Roboto,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x83dab9f5, L"Script", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x847b56da, L"Tahoma", L"Droid Sans Fallback", 0, 1252}, + {0x8a783cb2, L"SimSun-PUA", L"Droid Sans Fallback", 0, 1252}, + {0x8b5cac0e, L"Onyx", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x8c6a499e, L"Gulim", L"Droid Sans Fallback", 0, 1252}, + {0x8e0af790, L"JuiceITC", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x8e8d43b2, L"Centaur", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 2, 1252}, + {0x8ee4dcca, L"BookshelfSymbol7", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x90794800, L"BellGothicStdLight", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x909b516a, L"Century", + L"Droid Serif,Roboto,Droid Sans Mono,Droid Sans Fallback", 2, 1252}, + {0x92ae370d, L"MSOutlook", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 4, 42}, + {0x93c9fbf1, L"LucidaFax", + L"Droid Arabic Naskh,Droid Sans Ethiopic,Droid Serif,Roboto,Droid Sans " + L"Mono", + 2, 1252}, + {0x9565085e, L"BookAntiqua", + L"Droid Serif,Roboto,Droid Sans Mono,Droid Sans Fallback", 2, 1252}, + {0x9856d95d, L"AdobeMingStdL", L"Droid Sans Fallback", 0, 949}, + {0x9bbadd6b, L"ColonnaMT", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0x9cbd16a4, L"ShowcardGothic-Reg", + L"Droid Serif,Roboto,Droid Sans Mono,Droid Sans Fallbac", 0, 1252}, + {0x9d73008e, L"MSSansSerif", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0xa0607db1, L"GungsuhChe", L"Droid Sans Fallback", 1, 1252}, + {0xa0bcf6a1, L"LatinWide", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 2, 1252}, + {0xa1429b36, L"Symbol", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 6, 42}, + {0xa1fa5abc, L"Wingdings2", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 6, 42}, + {0xa1fa5abd, L"Wingdings3", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 6, 42}, + {0xa427bad4, L"InformalRoman-Regular", + L"Droid Arabic Naskh,Droid Sans Ethiopic", 8, 1252}, + {0xa8b92ece, L"FZSTK--GBK1-0", L"Droid Sans Fallback", 0, 936}, + {0xa8d83ece, L"CalifornianFB", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 2, 1252}, + {0xaa3e082c, L"Kingsoft-Phonetic", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0xaa6bcabe, L"HarlowSolidItalic", + L"Droid Serif,Roboto,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0xade5337c, L"MSUIGothic", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0xb08dd941, L"WideLatin", + L"Droid Arabic Naskh,Droid Sans Ethiopic,Droid Serif,Roboto,Droid Sans " + L"Mono", + 2, 1252}, + {0xb207f05d, L"PoorRichard", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 2, 1252}, + {0xb3bc492f, L"JuiceITC-Regular", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0xb5545399, L"Marlett", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 4, 42}, + {0xb5dd1ebb, L"BritannicBold", L"Droid Arabic Naskh,Droid Sans Ethiopic", 0, + 1252}, + {0xb699c1c5, L"LucidaCalligraphy-Italic", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0xb725d629, L"TimesNewRoman", L"Droid Sans Fallback", 2, 1252}, + {0xb7eaebeb, L"AdobeHeitiStdR", L"Droid Sans Fallback", 0, 936}, + {0xbd29c486, L"BerlinSansFBDemi-Bold", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0xbe8a8db4, L"BookshelfSymbolSeven", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0xc16c0118, L"AdobeHebrew", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback,Droid Arabic " + L"Naskh,Droid Sans Ethiopic", + 0, 1252}, + {0xc318b0af, L"MyriadProLight", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0xc65e5659, L"CambriaMath", L"Droid Sans Fallback", 2, 1252}, + {0xc75c8f05, L"LucidaConsole", + L"Droid Sans Mono,Droid Serif,Roboto,Droid Sans Fallback", 1, 1252}, + {0xca7c35d6, L"Calibri", L"Droid Sans Fallback", 0, 1252}, + {0xcb053f53, L"MicrosoftYaHei", L"Droid Sans Fallback", 0, 936}, + {0xcb7190f9, L"Magneto-Bold", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0xcca00cc5, L"System", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0xccad6f76, L"Jokerman-Regular", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0xccc5818c, L"EuroSign", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0xcf3d7234, L"LucidaHandwriting-Italic", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0xcf7b8fdb, L"MinionPro", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0xcfe5755f, L"Simhei", L"Droid Sans Fallback", 1, 936}, + {0xd011f4ee, L"MSPGothic", L"Droid Sans Fallback", 0, 1252}, + {0xd060e7ef, L"Vivaldi", + L"Droid Serif,Roboto,Droid Sans Mono,Droid Sans Fallback", 8, 1252}, + {0xd07edec1, L"FranklinGothic-Medium", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0xd107243f, L"SimSun", L"Droid Sans Fallback", 0, 936}, + {0xd1881562, L"ArialNarrow", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0xd22b7dce, L"BodoniMTPosterCompressed", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0xd22bfa60, L"ComicSansMS", L"Droid Serif,Roboto,Droid Sans Fallback", 8, + 1252}, + {0xd3bd0e35, L"Bauhaus93", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0xd429ee7a, L"STFangsong", L"Droid Sans Fallback", 0, 936}, + {0xd6679c12, L"BernardMTCondensed", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0xd8e8a027, L"LucidaSans", + L"Droid Arabic Naskh,Droid Sans Ethiopic,Droid Serif,Roboto", 0, 1252}, + {0xd9fe7761, L"HighTowerText-Reg", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 2, 1252}, + {0xda7e551e, L"STSong", L"Droid Sans Fallback", 0, 936}, + {0xdaa6842d, L"STZhongsong", L"Droid Sans Fallback", 0, 936}, + {0xdaaab93f, L"STFangsong", L"Droid Sans Fallback", 0, 936}, + {0xdaeb0713, L"STSong", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 936}, + {0xdafedbef, L"STCaiyun", L"Droid Sans Fallback", 0, 936}, + {0xdb00a3d9, L"Broadway", + L"Droid Serif,Roboto,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0xdb1f5ad4, L"STXinwei", L"Droid Sans Fallback", 0, 936}, + {0xdb326e7f, L"STKaiti", L"Droid Sans Fallback", 0, 936}, + {0xdb69595a, L"STHupo", L"Droid Sans Fallback", 0, 936}, + {0xdba0082c, L"STXihei", L"Droid Sans Fallback", 0, 936}, + {0xdbd0ab18, L"STXingkai", L"Droid Sans Fallback", 0, 936}, + {0xdc1a7db1, L"STLiti", L"Droid Sans Fallback", 0, 936}, + {0xdc33075f, L"KristenITC-Regular", + L"Droid Arabic Naskh,Droid Sans Ethiopic,Droid Serif,Roboto", 8, 1252}, + {0xdcc7009c, L"Harrington", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0xdd712466, L"ArialBlack", + L"Droid Serif,Roboto,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0xdde87b3e, L"Impact", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0xdf69fb32, L"SnapITC", + L"Droid Arabic Naskh,Droid Sans Ethiopic,Droid Serif,Roboto,Droid Sans " + L"Mono", + 0, 1252}, + {0xdf8b25e8, L"CenturyGothic", + L"Droid Serif,Roboto,Droid Serif,Droid Sans Mono", 0, 1252}, + {0xe0f705c0, L"KristenITC", + L"Droid Arabic Naskh,Droid Sans Ethiopic,Droid Serif,Roboto", 8, 1252}, + {0xe1427573, L"Raavi", + L"Droid Arabic Naskh,Droid Sans Ethiopic,Roboto,Droid Serif,Droid Sans " + L"Mono", + 0, 1252}, + {0xe2cea0cb, L"Magneto", + L"Droid Arabic Naskh,Droid Sans Ethiopic,Droid Serif,Roboto,Droid Sans " + L"Mono", + 0, 1252}, + {0xe36a9e17, L"Ravie", + L"Droid Arabic Naskh,Droid Sans Ethiopic,Roboto,Droid Serif,Droid Sans " + L"Mono", + 0, 1252}, + {0xe433f8e2, L"Parchment", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 8, 1252}, + {0xe43dff4a, L"Wingdings", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 4, 42}, + {0xe4e2c405, L"MTExtra", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 6, 42}, + {0xe618cc35, L"InformalRoman", + L"Droid Arabic Naskh,Droid Sans Ethiopic,Roboto,Droid Serif", 8, 1252}, + {0xe6c27ffc, L"Mistral", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 8, 1252}, + {0xe7ebf4b9, L"Courier", L"Droid Sans Fallback", 0, 1252}, + {0xe8bc4a9d, L"MSReferenceSpecialty", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0xe90fb013, L"TempusSansITC", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0xec637b42, L"Consolas", L"Droid Sans Fallback", 1, 1252}, + {0xed3a683b, L"STXinwei", L"Droid Sans Fallback", 0, 936}, + {0xef264cd1, L"LucidaHandwriting", + L"Droid Arabic Naskh,Droid Sans Ethiopic,Droid Serif,Roboto,Droid Sans " + L"Mono", + 0, 1252}, + {0xf086bca2, L"BaskervilleOldFace", + L"Roboto,Droid Serif,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0xf1028030, L"Mangal", + L"Droid Arabic Naskh,Droid Sans Ethiopic,Droid Serif,Roboto,Droid Sans " + L"Mono", + 2, 1252}, + {0xf1da7eb9, L"ShowcardGothic", + L"Droid Serif,Roboto,Droid Sans Mono,Droid Sans Fallbac", 0, 1252}, + {0xf210f06a, L"ArialMT", + L"Droid Arabic Naskh,Droid Sans Ethiopic,Roboto,Droid Serif", 0, 1252}, + {0xf477f16a, L"Latha", + L"Droid Arabic Naskh,Droid Sans Ethiopic,Roboto,Droid Serif,Droid Sans " + L"Mono", + 0, 1252}, + {0xf616f3dd, L"LiSu", L"Droid Sans Fallback", 1, 936}, + {0xfa479aa6, L"MicrosoftYaHei", L"Droid Sans Fallback", 0, 936}, + {0xfcd19697, L"BookmanOldStyle", + L"Droid Serif,Roboto,Droid Sans Mono,Droid Sans Fallback", 0, 1252}, + {0xfe209a82, L"LucidaCalligraphy", + L"Droid Arabic Naskh,Droid Sans Ethiopic,Droid Serif,Roboto,Droid Sans " + L"Mono", + 0, 1252}, + {0xfef135f8, L"AdobeHeitiStd-Regular", L"Droid Sans Fallback", 0, 936}, +}; +#endif + +} // namespace + +CFX_WideString XFA_LocalFontNameToEnglishName( + const CFX_WideStringC& wsLocalName) { + uint32_t dwLocalNameHash = FX_HashCode_GetW(wsLocalName, true); + const XFA_FONTINFO* pEnd = g_XFAFontsMap + FX_ArraySize(g_XFAFontsMap); + const XFA_FONTINFO* pFontInfo = + std::lower_bound(g_XFAFontsMap, pEnd, dwLocalNameHash, + [](const XFA_FONTINFO& entry, uint32_t hash) { + return entry.dwFontNameHash < hash; + }); + if (pFontInfo < pEnd && pFontInfo->dwFontNameHash == dwLocalNameHash) + return pFontInfo->pPsName; + return CFX_WideString(wsLocalName); +} + +const XFA_FONTINFO* XFA_GetFontINFOByFontName( + const CFX_WideStringC& wsFontName) { + CFX_WideString wsFontNameTemp(wsFontName); + wsFontNameTemp.Remove(L' '); + uint32_t dwCurFontNameHash = + FX_HashCode_GetW(wsFontNameTemp.AsStringC(), true); + const XFA_FONTINFO* pEnd = g_XFAFontsMap + FX_ArraySize(g_XFAFontsMap); + const XFA_FONTINFO* pFontInfo = + std::lower_bound(g_XFAFontsMap, pEnd, dwCurFontNameHash, + [](const XFA_FONTINFO& entry, uint32_t hash) { + return entry.dwFontNameHash < hash; + }); + if (pFontInfo < pEnd && pFontInfo->dwFontNameHash == dwCurFontNameHash) + return pFontInfo; + return nullptr; +} + +CXFA_FontMgr::CXFA_FontMgr() {} + +CXFA_FontMgr::~CXFA_FontMgr() {} + +CFX_RetainPtr CXFA_FontMgr::GetFont( + CXFA_FFDoc* hDoc, + const CFX_WideStringC& wsFontFamily, + uint32_t dwFontStyles, + uint16_t wCodePage) { + uint32_t dwHash = FX_HashCode_GetW(wsFontFamily, false); + CFX_ByteString bsKey; + bsKey.Format("%u%u%u", dwHash, dwFontStyles, wCodePage); + auto iter = m_FontMap.find(bsKey); + if (iter != m_FontMap.end()) + return iter->second; + + CFX_WideString wsEnglishName = XFA_LocalFontNameToEnglishName(wsFontFamily); + auto it = m_PDFFontMgrMap.find(hDoc); + CXFA_PDFFontMgr* pMgr = + it != m_PDFFontMgrMap.end() ? it->second.get() : nullptr; + CPDF_Font* pPDFFont = nullptr; + CFX_RetainPtr pFont; + if (pMgr) { + pFont = + pMgr->GetFont(wsEnglishName.AsStringC(), dwFontStyles, &pPDFFont, true); + if (pFont) + return pFont; + } + if (!pFont && m_pDefFontMgr) + pFont = m_pDefFontMgr->GetFont(hDoc, wsFontFamily, dwFontStyles, wCodePage); + + if (!pFont && pMgr) { + pPDFFont = nullptr; + pFont = pMgr->GetFont(wsEnglishName.AsStringC(), dwFontStyles, &pPDFFont, + false); + if (pFont) + return pFont; + } + if (!pFont && m_pDefFontMgr) { + pFont = m_pDefFontMgr->GetDefaultFont(hDoc, wsFontFamily, dwFontStyles, + wCodePage); + } + if (pFont) { + if (pPDFFont) { + pMgr->SetFont(pFont, pPDFFont); + pFont->SetFontProvider(pMgr); + } + m_FontMap[bsKey] = pFont; + } + return pFont; +} + +void CXFA_FontMgr::LoadDocFonts(CXFA_FFDoc* hDoc) { + if (!m_PDFFontMgrMap[hDoc]) + m_PDFFontMgrMap[hDoc] = pdfium::MakeUnique(hDoc); +} + +void CXFA_FontMgr::ReleaseDocFonts(CXFA_FFDoc* hDoc) { + m_PDFFontMgrMap.erase(hDoc); +} + +void CXFA_FontMgr::SetDefFontMgr(std::unique_ptr pFontMgr) { + m_pDefFontMgr = std::move(pFontMgr); +} diff --git a/xfa/fxfa/cxfa_fontmgr.h b/xfa/fxfa/cxfa_fontmgr.h new file mode 100644 index 0000000000..8652a34422 --- /dev/null +++ b/xfa/fxfa/cxfa_fontmgr.h @@ -0,0 +1,56 @@ +// 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_CXFA_FONTMGR_H_ +#define XFA_FXFA_CXFA_FONTMGR_H_ + +#include +#include +#include + +#include "core/fxcrt/cfx_retain_ptr.h" +#include "core/fxcrt/fx_ext.h" +#include "core/fxcrt/fx_system.h" +#include "xfa/fgas/font/cfgas_fontmgr.h" +#include "xfa/fxfa/cxfa_deffontmgr.h" +#include "xfa/fxfa/cxfa_pdffontmgr.h" +#include "xfa/fxfa/fxfa.h" + +class CPDF_Font; + +struct XFA_FONTINFO { + uint32_t dwFontNameHash; + const wchar_t* pPsName; + const wchar_t* pReplaceFont; + uint16_t dwStyles; + uint16_t wCodePage; +}; + +CFX_WideString XFA_LocalFontNameToEnglishName( + const CFX_WideStringC& wsLocalName); +const XFA_FONTINFO* XFA_GetFontINFOByFontName( + const CFX_WideStringC& wsFontName); + +class CXFA_FontMgr { + public: + CXFA_FontMgr(); + ~CXFA_FontMgr(); + + CFX_RetainPtr GetFont(CXFA_FFDoc* hDoc, + const CFX_WideStringC& wsFontFamily, + uint32_t dwFontStyles, + uint16_t wCodePage = 0xFFFF); + void LoadDocFonts(CXFA_FFDoc* hDoc); + void ReleaseDocFonts(CXFA_FFDoc* hDoc); + void SetDefFontMgr(std::unique_ptr pFontMgr); + + private: + std::unique_ptr m_pDefFontMgr; + std::map> m_PDFFontMgrMap; + std::map> m_FontMap; +}; + +#endif // XFA_FXFA_CXFA_FONTMGR_H_ diff --git a/xfa/fxfa/cxfa_pdffontmgr.cpp b/xfa/fxfa/cxfa_pdffontmgr.cpp new file mode 100644 index 0000000000..cadb7cbab5 --- /dev/null +++ b/xfa/fxfa/cxfa_pdffontmgr.cpp @@ -0,0 +1,208 @@ +// 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 + +#include "xfa/fxfa/cxfa_pdffontmgr.h" + +#include + +#include "core/fpdfapi/font/cpdf_font.h" +#include "xfa/fxfa/cxfa_ffapp.h" + +namespace { + +// The 5 names per entry are: PsName, Normal, Bold, Italic, BoldItalic. +const char* const g_XFAPDFFontName[][5] = { + {"Adobe PI Std", "AdobePIStd", "AdobePIStd", "AdobePIStd", "AdobePIStd"}, + {"Myriad Pro Light", "MyriadPro-Light", "MyriadPro-Semibold", + "MyriadPro-LightIt", "MyriadPro-SemiboldIt"}, +}; + +} // namespace + +CXFA_PDFFontMgr::CXFA_PDFFontMgr(CXFA_FFDoc* pDoc) : m_pDoc(pDoc) {} + +CXFA_PDFFontMgr::~CXFA_PDFFontMgr() {} + +CFX_RetainPtr CXFA_PDFFontMgr::FindFont( + const CFX_ByteString& strPsName, + bool bBold, + bool bItalic, + CPDF_Font** pDstPDFFont, + bool bStrictMatch) { + CPDF_Document* pDoc = m_pDoc->GetPDFDoc(); + if (!pDoc) + return nullptr; + + CPDF_Dictionary* pFontSetDict = + pDoc->GetRoot()->GetDictFor("AcroForm")->GetDictFor("DR"); + if (!pFontSetDict) + return nullptr; + + pFontSetDict = pFontSetDict->GetDictFor("Font"); + if (!pFontSetDict) + return nullptr; + + CFX_ByteString name = strPsName; + name.Remove(' '); + CFGAS_FontMgr* pFDEFontMgr = m_pDoc->GetApp()->GetFDEFontMgr(); + for (const auto& it : *pFontSetDict) { + const CFX_ByteString& key = it.first; + CPDF_Object* pObj = it.second.get(); + if (!PsNameMatchDRFontName(name.AsStringC(), bBold, bItalic, key, + bStrictMatch)) { + continue; + } + CPDF_Dictionary* pFontDict = ToDictionary(pObj->GetDirect()); + if (!pFontDict || pFontDict->GetStringFor("Type") != "Font") { + return nullptr; + } + CPDF_Font* pPDFFont = pDoc->LoadFont(pFontDict); + if (!pPDFFont) { + return nullptr; + } + if (!pPDFFont->IsEmbedded()) { + *pDstPDFFont = pPDFFont; + return nullptr; + } + return CFGAS_GEFont::LoadFont(&pPDFFont->m_Font, pFDEFontMgr); + } + return nullptr; +} + +CFX_RetainPtr CXFA_PDFFontMgr::GetFont( + const CFX_WideStringC& wsFontFamily, + uint32_t dwFontStyles, + CPDF_Font** pPDFFont, + bool bStrictMatch) { + uint32_t dwHashCode = FX_HashCode_GetW(wsFontFamily, false); + CFX_ByteString strKey; + strKey.Format("%u%u", dwHashCode, dwFontStyles); + auto it = m_FontMap.find(strKey); + if (it != m_FontMap.end()) + return it->second; + CFX_ByteString bsPsName = + CFX_ByteString::FromUnicode(CFX_WideString(wsFontFamily)); + bool bBold = (dwFontStyles & FX_FONTSTYLE_Bold) == FX_FONTSTYLE_Bold; + bool bItalic = (dwFontStyles & FX_FONTSTYLE_Italic) == FX_FONTSTYLE_Italic; + CFX_ByteString strFontName = PsNameToFontName(bsPsName, bBold, bItalic); + CFX_RetainPtr pFont = + FindFont(strFontName, bBold, bItalic, pPDFFont, bStrictMatch); + if (pFont) + m_FontMap[strKey] = pFont; + return pFont; +} + +CFX_ByteString CXFA_PDFFontMgr::PsNameToFontName( + const CFX_ByteString& strPsName, + bool bBold, + bool bItalic) { + for (size_t i = 0; i < FX_ArraySize(g_XFAPDFFontName); ++i) { + if (strPsName == g_XFAPDFFontName[i][0]) { + size_t index = 1; + if (bBold) + ++index; + if (bItalic) + index += 2; + return g_XFAPDFFontName[i][index]; + } + } + return strPsName; +} + +bool CXFA_PDFFontMgr::PsNameMatchDRFontName(const CFX_ByteStringC& bsPsName, + bool bBold, + bool bItalic, + const CFX_ByteString& bsDRFontName, + bool bStrictMatch) { + CFX_ByteString bsDRName = bsDRFontName; + bsDRName.Remove('-'); + int32_t iPsLen = bsPsName.GetLength(); + int32_t nIndex = bsDRName.Find(bsPsName); + if (nIndex != -1 && !bStrictMatch) + return true; + + if (nIndex != 0) + return false; + + int32_t iDifferLength = bsDRName.GetLength() - iPsLen; + if (iDifferLength > 1 || (bBold || bItalic)) { + int32_t iBoldIndex = bsDRName.Find("Bold"); + bool bBoldFont = iBoldIndex > 0; + if (bBold != bBoldFont) + return false; + + if (bBoldFont) { + iDifferLength = + std::min(iDifferLength - 4, bsDRName.GetLength() - iBoldIndex - 4); + } + bool bItalicFont = true; + if (bsDRName.Find("Italic") > 0) { + iDifferLength -= 6; + } else if (bsDRName.Find("It") > 0) { + iDifferLength -= 2; + } else if (bsDRName.Find("Oblique") > 0) { + iDifferLength -= 7; + } else { + bItalicFont = false; + } + if (bItalic != bItalicFont) + return false; + + if (iDifferLength > 1) { + CFX_ByteString bsDRTailer = bsDRName.Right(iDifferLength); + if (bsDRTailer == "MT" || bsDRTailer == "PSMT" || + bsDRTailer == "Regular" || bsDRTailer == "Reg") { + return true; + } + if (bBoldFont || bItalicFont) + return false; + + bool bMatch = false; + switch (bsPsName.GetAt(iPsLen - 1)) { + case 'L': { + if (bsDRName.Right(5) == "Light") { + bMatch = true; + } + } break; + case 'R': { + if (bsDRName.Right(7) == "Regular" || bsDRName.Right(3) == "Reg") { + bMatch = true; + } + } break; + case 'M': { + if (bsDRName.Right(5) == "Medium") { + bMatch = true; + } + } break; + default: + break; + } + return bMatch; + } + } + return true; +} + +bool CXFA_PDFFontMgr::GetCharWidth(const CFX_RetainPtr& pFont, + wchar_t wUnicode, + bool bCharCode, + int32_t* pWidth) { + if (wUnicode != 0x20 || bCharCode) + return false; + + auto it = m_FDE2PDFFont.find(pFont); + if (it == m_FDE2PDFFont.end()) + return false; + + CPDF_Font* pPDFFont = it->second; + *pWidth = pPDFFont->GetCharWidthF(pPDFFont->CharCodeFromUnicode(wUnicode)); + return true; +} + +void CXFA_PDFFontMgr::SetFont(const CFX_RetainPtr& pFont, + CPDF_Font* pPDFFont) { + m_FDE2PDFFont[pFont] = pPDFFont; +} diff --git a/xfa/fxfa/cxfa_pdffontmgr.h b/xfa/fxfa/cxfa_pdffontmgr.h new file mode 100644 index 0000000000..1188ce1fba --- /dev/null +++ b/xfa/fxfa/cxfa_pdffontmgr.h @@ -0,0 +1,57 @@ +// 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_CXFA_PDFFONTMGR_H_ +#define XFA_FXFA_CXFA_PDFFONTMGR_H_ + +#include + +#include "core/fpdfapi/parser/cpdf_dictionary.h" +#include "core/fpdfapi/parser/cpdf_document.h" +#include "core/fxcrt/cfx_retain_ptr.h" +#include "core/fxcrt/fx_string.h" +#include "xfa/fgas/font/cfgas_gefont.h" +#include "xfa/fxfa/cxfa_ffdoc.h" + +class CPDF_Font; +class CXFA_FFDoc; + +class CXFA_PDFFontMgr { + public: + explicit CXFA_PDFFontMgr(CXFA_FFDoc* pDoc); + ~CXFA_PDFFontMgr(); + + CFX_RetainPtr GetFont(const CFX_WideStringC& wsFontFamily, + uint32_t dwFontStyles, + CPDF_Font** pPDFFont, + bool bStrictMatch); + bool GetCharWidth(const CFX_RetainPtr& pFont, + wchar_t wUnicode, + bool bCharCode, + int32_t* pWidth); + void SetFont(const CFX_RetainPtr& pFont, CPDF_Font* pPDFFont); + + private: + CFX_RetainPtr FindFont(const CFX_ByteString& strFamilyName, + bool bBold, + bool bItalic, + CPDF_Font** pPDFFont, + bool bStrictMatch); + CFX_ByteString PsNameToFontName(const CFX_ByteString& strPsName, + bool bBold, + bool bItalic); + bool PsNameMatchDRFontName(const CFX_ByteStringC& bsPsName, + bool bBold, + bool bItalic, + const CFX_ByteString& bsDRFontName, + bool bStrictMatch); + + CXFA_FFDoc* const m_pDoc; + std::map, CPDF_Font*> m_FDE2PDFFont; + std::map> m_FontMap; +}; + +#endif // XFA_FXFA_CXFA_PDFFONTMGR_H_ diff --git a/xfa/fxfa/cxfa_rendercontext.cpp b/xfa/fxfa/cxfa_rendercontext.cpp new file mode 100644 index 0000000000..ecb42918cb --- /dev/null +++ b/xfa/fxfa/cxfa_rendercontext.cpp @@ -0,0 +1,70 @@ +// 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 + +#include "xfa/fxfa/cxfa_rendercontext.h" + +#include "xfa/fxfa/cxfa_ffpageview.h" +#include "xfa/fxfa/cxfa_ffwidget.h" +#include "xfa/fxgraphics/cfx_graphics.h" + +namespace { + +const int32_t kMaxCount = 30; + +} // namsepace + +CXFA_RenderContext::CXFA_RenderContext() + : m_pWidget(nullptr), m_pPageView(nullptr), m_pGS(nullptr), m_dwStatus(0) { + m_matrix.SetIdentity(); + m_rtClipRect.Reset(); +} + +CXFA_RenderContext::~CXFA_RenderContext() {} + +int32_t CXFA_RenderContext::StartRender(CXFA_FFPageView* pPageView, + CFX_Graphics* pGS, + const CFX_Matrix& matrix, + const CXFA_RenderOptions& options) { + m_pPageView = pPageView; + m_pGS = pGS; + m_matrix = matrix; + m_options = options; + + CFX_Matrix mtRes; + mtRes.SetReverse(matrix); + m_rtClipRect = pGS->GetClipRect(); + mtRes.TransformRect(m_rtClipRect); + m_dwStatus = m_options.m_bHighlight ? XFA_WidgetStatus_Highlight : 0; + uint32_t dwFilterType = XFA_WidgetStatus_Visible | + (m_options.m_bPrint ? XFA_WidgetStatus_Printable + : XFA_WidgetStatus_Viewable); + m_pWidgetIterator.reset( + m_pPageView->CreateWidgetIterator(XFA_TRAVERSEWAY_Form, dwFilterType)); + m_pWidget = m_pWidgetIterator->MoveToNext(); + return XFA_RENDERSTATUS_Ready; +} + +int32_t CXFA_RenderContext::DoRender(IFX_Pause* pPause) { + int32_t iCount = 0; + while (m_pWidget) { + CXFA_FFWidget* pWidget = m_pWidget; + CFX_RectF rtWidgetBox = pWidget->GetBBox(XFA_WidgetStatus_Visible); + rtWidgetBox.width += 1; + rtWidgetBox.height += 1; + if (rtWidgetBox.IntersectWith(m_rtClipRect)) + pWidget->RenderWidget(m_pGS, &m_matrix, m_dwStatus); + + m_pWidget = m_pWidgetIterator->MoveToNext(); + iCount++; + if (iCount > kMaxCount && pPause && pPause->NeedToPauseNow()) + return XFA_RENDERSTATUS_ToBeContinued; + } + return XFA_RENDERSTATUS_Done; +} + +void CXFA_RenderContext::StopRender() { + m_pWidgetIterator.reset(); +} diff --git a/xfa/fxfa/cxfa_rendercontext.h b/xfa/fxfa/cxfa_rendercontext.h new file mode 100644 index 0000000000..960bd058d1 --- /dev/null +++ b/xfa/fxfa/cxfa_rendercontext.h @@ -0,0 +1,45 @@ +// 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_CXFA_RENDERCONTEXT_H_ +#define XFA_FXFA_CXFA_RENDERCONTEXT_H_ + +#include + +#include "xfa/fxfa/fxfa.h" + +class CXFA_RenderOptions { + public: + CXFA_RenderOptions() : m_bPrint(false), m_bHighlight(true) {} + + bool m_bPrint; + bool m_bHighlight; +}; + +class CXFA_RenderContext { + public: + CXFA_RenderContext(); + ~CXFA_RenderContext(); + + int32_t StartRender(CXFA_FFPageView* pPageView, + CFX_Graphics* pGS, + const CFX_Matrix& matrix, + const CXFA_RenderOptions& options); + int32_t DoRender(IFX_Pause* pPause = nullptr); + void StopRender(); + + private: + std::unique_ptr m_pWidgetIterator; + CXFA_FFWidget* m_pWidget; + CXFA_FFPageView* m_pPageView; + CFX_Graphics* m_pGS; + CFX_Matrix m_matrix; + CXFA_RenderOptions m_options; + uint32_t m_dwStatus; + CFX_RectF m_rtClipRect; +}; + +#endif // XFA_FXFA_CXFA_RENDERCONTEXT_H_ diff --git a/xfa/fxfa/cxfa_saxcontext.h b/xfa/fxfa/cxfa_saxcontext.h new file mode 100644 index 0000000000..47e7b78423 --- /dev/null +++ b/xfa/fxfa/cxfa_saxcontext.h @@ -0,0 +1,19 @@ +// 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_CXFA_SAXCONTEXT_H_ +#define XFA_FXFA_CXFA_SAXCONTEXT_H_ + +class CXFA_SAXContext { + public: + CXFA_SAXContext() : m_eNode(CFX_SAXItem::Type::Unknown) {} + + CFX_ByteTextBuf m_TextBuf; + CFX_ByteString m_bsTagName; + CFX_SAXItem::Type m_eNode; +}; + +#endif // XFA_FXFA_CXFA_SAXCONTEXT_H_ diff --git a/xfa/fxfa/cxfa_saxreaderhandler.cpp b/xfa/fxfa/cxfa_saxreaderhandler.cpp new file mode 100644 index 0000000000..c09bdf5b4c --- /dev/null +++ b/xfa/fxfa/cxfa_saxreaderhandler.cpp @@ -0,0 +1,129 @@ +// 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 + +#include "xfa/fxfa/cxfa_saxreaderhandler.h" + +#include "xfa/fxfa/cxfa_checksumcontext.h" + +CXFA_SAXReaderHandler::CXFA_SAXReaderHandler(CXFA_ChecksumContext* pContext) + : m_pContext(pContext) { + ASSERT(m_pContext); +} + +CXFA_SAXReaderHandler::~CXFA_SAXReaderHandler() {} + +CXFA_SAXContext* CXFA_SAXReaderHandler::OnTagEnter( + const CFX_ByteStringC& bsTagName, + CFX_SAXItem::Type eType, + uint32_t dwStartPos) { + UpdateChecksum(true); + if (eType != CFX_SAXItem::Type::Tag && + eType != CFX_SAXItem::Type::Instruction) { + return nullptr; + } + + m_SAXContext.m_eNode = eType; + CFX_ByteTextBuf& textBuf = m_SAXContext.m_TextBuf; + textBuf << "<"; + if (eType == CFX_SAXItem::Type::Instruction) + textBuf << "?"; + + textBuf << bsTagName; + m_SAXContext.m_bsTagName = bsTagName; + return &m_SAXContext; +} + +void CXFA_SAXReaderHandler::OnTagAttribute(CXFA_SAXContext* pTag, + const CFX_ByteStringC& bsAttri, + const CFX_ByteStringC& bsValue) { + if (!pTag) + return; + pTag->m_TextBuf << " " << bsAttri << "=\"" << bsValue << "\""; +} + +void CXFA_SAXReaderHandler::OnTagBreak(CXFA_SAXContext* pTag) { + if (!pTag) + return; + + pTag->m_TextBuf << ">"; + UpdateChecksum(false); +} + +void CXFA_SAXReaderHandler::OnTagData(CXFA_SAXContext* pTag, + CFX_SAXItem::Type eType, + const CFX_ByteStringC& bsData, + uint32_t dwStartPos) { + if (!pTag) + return; + + CFX_ByteTextBuf& textBuf = pTag->m_TextBuf; + if (eType == CFX_SAXItem::Type::CharData) + textBuf << ""; +} + +void CXFA_SAXReaderHandler::OnTagClose(CXFA_SAXContext* pTag, + uint32_t dwEndPos) { + if (!pTag) + return; + + CFX_ByteTextBuf& textBuf = pTag->m_TextBuf; + if (pTag->m_eNode == CFX_SAXItem::Type::Instruction) + textBuf << "?>"; + else if (pTag->m_eNode == CFX_SAXItem::Type::Tag) + textBuf << ">m_bsTagName.AsStringC() << ">"; + + UpdateChecksum(false); +} + +void CXFA_SAXReaderHandler::OnTagEnd(CXFA_SAXContext* pTag, + const CFX_ByteStringC& bsTagName, + uint32_t dwEndPos) { + if (!pTag) + return; + + pTag->m_TextBuf << ""; + UpdateChecksum(false); +} + +void CXFA_SAXReaderHandler::OnTargetData(CXFA_SAXContext* pTag, + CFX_SAXItem::Type eType, + const CFX_ByteStringC& bsData, + uint32_t dwStartPos) { + if (!pTag && eType != CFX_SAXItem::Type::Comment) + return; + + if (eType == CFX_SAXItem::Type::Comment) { + m_SAXContext.m_TextBuf << ""; + UpdateChecksum(false); + } else { + pTag->m_TextBuf << " " << bsData; + } +} + +void CXFA_SAXReaderHandler::UpdateChecksum(bool bCheckSpace) { + int32_t iLength = m_SAXContext.m_TextBuf.GetLength(); + if (iLength < 1) + return; + + uint8_t* pBuffer = m_SAXContext.m_TextBuf.GetBuffer(); + bool bUpdata = true; + if (bCheckSpace) { + bUpdata = false; + for (int32_t i = 0; i < iLength; i++) { + bUpdata = (pBuffer[i] > 0x20); + if (bUpdata) + break; + } + } + if (bUpdata) + m_pContext->Update(CFX_ByteStringC(pBuffer, iLength)); + + m_SAXContext.m_TextBuf.Clear(); +} diff --git a/xfa/fxfa/cxfa_saxreaderhandler.h b/xfa/fxfa/cxfa_saxreaderhandler.h new file mode 100644 index 0000000000..3ad69322bb --- /dev/null +++ b/xfa/fxfa/cxfa_saxreaderhandler.h @@ -0,0 +1,49 @@ +// 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_CXFA_SAXREADERHANDLER_H_ +#define XFA_FXFA_CXFA_SAXREADERHANDLER_H_ + +#include "core/fxcrt/fx_string.h" +#include "xfa/fde/xml/cfx_saxreader.h" +#include "xfa/fxfa/cxfa_saxcontext.h" + +class CXFA_ChecksumContext; + +class CXFA_SAXReaderHandler { + public: + explicit CXFA_SAXReaderHandler(CXFA_ChecksumContext* pContext); + ~CXFA_SAXReaderHandler(); + + CXFA_SAXContext* OnTagEnter(const CFX_ByteStringC& bsTagName, + CFX_SAXItem::Type eType, + uint32_t dwStartPos); + void OnTagAttribute(CXFA_SAXContext* pTag, + const CFX_ByteStringC& bsAttri, + const CFX_ByteStringC& bsValue); + void OnTagBreak(CXFA_SAXContext* pTag); + void OnTagData(CXFA_SAXContext* pTag, + CFX_SAXItem::Type eType, + const CFX_ByteStringC& bsData, + uint32_t dwStartPos); + void OnTagClose(CXFA_SAXContext* pTag, uint32_t dwEndPos); + void OnTagEnd(CXFA_SAXContext* pTag, + const CFX_ByteStringC& bsTagName, + uint32_t dwEndPos); + + void OnTargetData(CXFA_SAXContext* pTag, + CFX_SAXItem::Type eType, + const CFX_ByteStringC& bsData, + uint32_t dwStartPos); + + private: + void UpdateChecksum(bool bCheckSpace); + + CXFA_ChecksumContext* m_pContext; + CXFA_SAXContext m_SAXContext; +}; + +#endif // XFA_FXFA_CXFA_SAXREADERHANDLER_H_ diff --git a/xfa/fxfa/cxfa_widgetacc.cpp b/xfa/fxfa/cxfa_widgetacc.cpp new file mode 100644 index 0000000000..4c8e37291a --- /dev/null +++ b/xfa/fxfa/cxfa_widgetacc.cpp @@ -0,0 +1,1549 @@ +// 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 + +#include "xfa/fxfa/cxfa_widgetacc.h" + +#include +#include + +#include "third_party/base/stl_util.h" +#include "xfa/fde/tto/fde_textout.h" +#include "xfa/fde/xml/fde_xml_imp.h" +#include "xfa/fxfa/app/cxfa_textlayout.h" +#include "xfa/fxfa/app/xfa_ffwidgetacc.h" +#include "xfa/fxfa/cxfa_ffapp.h" +#include "xfa/fxfa/cxfa_ffdoc.h" +#include "xfa/fxfa/cxfa_ffdocview.h" +#include "xfa/fxfa/cxfa_ffwidget.h" +#include "xfa/fxfa/cxfa_fontmgr.h" +#include "xfa/fxfa/parser/cxfa_layoutprocessor.h" +#include "xfa/fxfa/parser/cxfa_scriptcontext.h" +#include "xfa/fxfa/parser/xfa_localevalue.h" +#include "xfa/fxfa/parser/xfa_utils.h" + +class CXFA_WidgetLayoutData { + public: + CXFA_WidgetLayoutData() : m_fWidgetHeight(-1) {} + virtual ~CXFA_WidgetLayoutData() {} + + float m_fWidgetHeight; +}; + +namespace { + +void FFDeleteCalcData(void* pData) { + if (pData) + delete ((CXFA_CalcData*)pData); +} + +static XFA_MAPDATABLOCKCALLBACKINFO gs_XFADeleteCalcData = {FFDeleteCalcData, + nullptr}; + +class CXFA_TextLayoutData : public CXFA_WidgetLayoutData { + public: + CXFA_TextLayoutData() {} + ~CXFA_TextLayoutData() override {} + + CXFA_TextLayout* GetTextLayout() const { return m_pTextLayout.get(); } + CXFA_TextProvider* GetTextProvider() const { return m_pTextProvider.get(); } + + void LoadText(CXFA_WidgetAcc* pAcc) { + if (m_pTextLayout) + return; + + m_pTextProvider = + pdfium::MakeUnique(pAcc, XFA_TEXTPROVIDERTYPE_Text); + m_pTextLayout = pdfium::MakeUnique(m_pTextProvider.get()); + } + + private: + std::unique_ptr m_pTextLayout; + std::unique_ptr m_pTextProvider; +}; + +class CXFA_ImageLayoutData : public CXFA_WidgetLayoutData { + public: + CXFA_ImageLayoutData() + : m_pDIBitmap(nullptr), + m_bNamedImage(false), + m_iImageXDpi(0), + m_iImageYDpi(0) {} + + ~CXFA_ImageLayoutData() override { + if (m_pDIBitmap && !m_bNamedImage) + delete m_pDIBitmap; + } + + bool LoadImageData(CXFA_WidgetAcc* pAcc) { + if (m_pDIBitmap) + return true; + + CXFA_Value value = pAcc->GetFormValue(); + if (!value) + return false; + + CXFA_Image imageObj = value.GetImage(); + if (!imageObj) + return false; + + CXFA_FFDoc* pFFDoc = pAcc->GetDoc(); + pAcc->SetImageImage(XFA_LoadImageData(pFFDoc, &imageObj, m_bNamedImage, + m_iImageXDpi, m_iImageYDpi)); + return !!m_pDIBitmap; + } + + CFX_DIBitmap* m_pDIBitmap; + bool m_bNamedImage; + int32_t m_iImageXDpi; + int32_t m_iImageYDpi; +}; + +class CXFA_FieldLayoutData : public CXFA_WidgetLayoutData { + public: + CXFA_FieldLayoutData() {} + ~CXFA_FieldLayoutData() override {} + + bool LoadCaption(CXFA_WidgetAcc* pAcc) { + if (m_pCapTextLayout) + return true; + CXFA_Caption caption = pAcc->GetCaption(); + if (!caption || caption.GetPresence() == XFA_ATTRIBUTEENUM_Hidden) + return false; + m_pCapTextProvider.reset( + new CXFA_TextProvider(pAcc, XFA_TEXTPROVIDERTYPE_Caption)); + m_pCapTextLayout = + pdfium::MakeUnique(m_pCapTextProvider.get()); + return true; + } + + std::unique_ptr m_pCapTextLayout; + std::unique_ptr m_pCapTextProvider; + std::unique_ptr m_pTextOut; + std::vector m_FieldSplitArray; +}; + +class CXFA_TextEditData : public CXFA_FieldLayoutData { + public: +}; + +class CXFA_ImageEditData : public CXFA_FieldLayoutData { + public: + CXFA_ImageEditData() + : m_pDIBitmap(nullptr), + m_bNamedImage(false), + m_iImageXDpi(0), + m_iImageYDpi(0) {} + + ~CXFA_ImageEditData() override { + if (m_pDIBitmap && !m_bNamedImage) + delete m_pDIBitmap; + } + + bool LoadImageData(CXFA_WidgetAcc* pAcc) { + if (m_pDIBitmap) + return true; + + CXFA_Value value = pAcc->GetFormValue(); + if (!value) + return false; + + CXFA_Image imageObj = value.GetImage(); + CXFA_FFDoc* pFFDoc = pAcc->GetDoc(); + pAcc->SetImageEditImage(XFA_LoadImageData(pFFDoc, &imageObj, m_bNamedImage, + m_iImageXDpi, m_iImageYDpi)); + return !!m_pDIBitmap; + } + + CFX_DIBitmap* m_pDIBitmap; + bool m_bNamedImage; + int32_t m_iImageXDpi; + int32_t m_iImageYDpi; +}; + +} // namespace + +CXFA_WidgetAcc::CXFA_WidgetAcc(CXFA_FFDocView* pDocView, CXFA_Node* pNode) + : CXFA_WidgetData(pNode), m_pDocView(pDocView), m_nRecursionDepth(0) {} + +CXFA_WidgetAcc::~CXFA_WidgetAcc() {} + +bool CXFA_WidgetAcc::GetName(CFX_WideString& wsName, int32_t iNameType) { + if (iNameType == 0) { + m_pNode->TryCData(XFA_ATTRIBUTE_Name, wsName); + return !wsName.IsEmpty(); + } + m_pNode->GetSOMExpression(wsName); + if (iNameType == 2 && wsName.GetLength() >= 15) { + CFX_WideStringC wsPre = L"xfa[0].form[0]."; + if (wsPre == CFX_WideStringC(wsName.c_str(), wsPre.GetLength())) + wsName.Delete(0, wsPre.GetLength()); + } + return true; +} + +CXFA_Node* CXFA_WidgetAcc::GetDatasets() { + return m_pNode->GetBindData(); +} + +bool CXFA_WidgetAcc::ProcessValueChanged() { + m_pDocView->AddValidateWidget(this); + m_pDocView->AddCalculateWidgetAcc(this); + m_pDocView->RunCalculateWidgets(); + m_pDocView->RunValidate(); + return true; +} + +void CXFA_WidgetAcc::ResetData() { + CFX_WideString wsValue; + XFA_Element eUIType = GetUIType(); + switch (eUIType) { + case XFA_Element::ImageEdit: { + CXFA_Value imageValue = GetDefaultValue(); + CXFA_Image image = imageValue.GetImage(); + CFX_WideString wsContentType, wsHref; + if (image) { + image.GetContent(wsValue); + image.GetContentType(wsContentType); + image.GetHref(wsHref); + } + SetImageEdit(wsContentType, wsHref, wsValue); + break; + } + case XFA_Element::ExclGroup: { + CXFA_Node* pNextChild = m_pNode->GetNodeItem( + XFA_NODEITEM_FirstChild, XFA_ObjectType::ContainerNode); + while (pNextChild) { + CXFA_Node* pChild = pNextChild; + CXFA_WidgetAcc* pAcc = + static_cast(pChild->GetWidgetData()); + if (!pAcc) + continue; + + CXFA_Value defValue(nullptr); + if (wsValue.IsEmpty() && (defValue = pAcc->GetDefaultValue())) { + defValue.GetChildValueContent(wsValue); + SetValue(wsValue, XFA_VALUEPICTURE_Raw); + pAcc->SetValue(wsValue, XFA_VALUEPICTURE_Raw); + } else { + CXFA_Node* pItems = pChild->GetChild(0, XFA_Element::Items); + if (!pItems) + continue; + + CFX_WideString itemText; + if (pItems->CountChildren(XFA_Element::Unknown) > 1) + itemText = pItems->GetChild(1, XFA_Element::Unknown)->GetContent(); + + pAcc->SetValue(itemText, XFA_VALUEPICTURE_Raw); + } + pNextChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling, + XFA_ObjectType::ContainerNode); + } + break; + } + case XFA_Element::ChoiceList: + ClearAllSelections(); + default: + if (CXFA_Value defValue = GetDefaultValue()) + defValue.GetChildValueContent(wsValue); + + SetValue(wsValue, XFA_VALUEPICTURE_Raw); + break; + } +} + +void CXFA_WidgetAcc::SetImageEdit(const CFX_WideString& wsContentType, + const CFX_WideString& wsHref, + const CFX_WideString& wsData) { + CXFA_Image image = GetFormValue().GetImage(); + if (image) { + image.SetContentType(CFX_WideString(wsContentType)); + image.SetHref(wsHref); + } + CFX_WideString wsFormatValue(wsData); + GetFormatDataValue(wsData, wsFormatValue); + m_pNode->SetContent(wsData, wsFormatValue, true); + CXFA_Node* pBind = GetDatasets(); + if (!pBind) { + image.SetTransferEncoding(XFA_ATTRIBUTEENUM_Base64); + return; + } + pBind->SetCData(XFA_ATTRIBUTE_ContentType, wsContentType); + CXFA_Node* pHrefNode = pBind->GetNodeItem(XFA_NODEITEM_FirstChild); + if (pHrefNode) { + pHrefNode->SetCData(XFA_ATTRIBUTE_Value, wsHref); + } else { + CFDE_XMLNode* pXMLNode = pBind->GetXMLMappingNode(); + ASSERT(pXMLNode && pXMLNode->GetType() == FDE_XMLNODE_Element); + static_cast(pXMLNode)->SetString(L"href", wsHref); + } +} + +CXFA_WidgetAcc* CXFA_WidgetAcc::GetExclGroup() { + CXFA_Node* pExcl = m_pNode->GetNodeItem(XFA_NODEITEM_Parent); + if (!pExcl || pExcl->GetElementType() != XFA_Element::ExclGroup) + return nullptr; + return static_cast(pExcl->GetWidgetData()); +} + +CXFA_FFDocView* CXFA_WidgetAcc::GetDocView() { + return m_pDocView; +} + +CXFA_FFDoc* CXFA_WidgetAcc::GetDoc() { + return m_pDocView->GetDoc(); +} + +CXFA_FFApp* CXFA_WidgetAcc::GetApp() { + return GetDoc()->GetApp(); +} + +IXFA_AppProvider* CXFA_WidgetAcc::GetAppProvider() { + return GetApp()->GetAppProvider(); +} + +int32_t CXFA_WidgetAcc::ProcessEvent(int32_t iActivity, + CXFA_EventParam* pEventParam) { + if (GetElementType() == XFA_Element::Draw) + return XFA_EVENTERROR_NotExist; + + std::vector eventArray = + GetEventByActivity(iActivity, pEventParam->m_bIsFormReady); + bool first = true; + int32_t iRet = XFA_EVENTERROR_NotExist; + for (CXFA_Node* pNode : eventArray) { + int32_t result = ProcessEvent(CXFA_Event(pNode), pEventParam); + if (first || result == XFA_EVENTERROR_Success) + iRet = result; + first = false; + } + return iRet; +} + +int32_t CXFA_WidgetAcc::ProcessEvent(const CXFA_Event& event, + CXFA_EventParam* pEventParam) { + if (!event) + return XFA_EVENTERROR_NotExist; + + switch (event.GetEventType()) { + case XFA_Element::Execute: + break; + case XFA_Element::Script: + return ExecuteScript(event.GetScript(), pEventParam); + case XFA_Element::SignData: + break; + case XFA_Element::Submit: + return GetDoc()->GetDocEnvironment()->SubmitData(GetDoc(), + event.GetSubmit()); + default: + break; + } + return XFA_EVENTERROR_NotExist; +} + +int32_t CXFA_WidgetAcc::ProcessCalculate() { + if (GetElementType() == XFA_Element::Draw) + return XFA_EVENTERROR_NotExist; + + CXFA_Calculate calc = GetCalculate(); + if (!calc) + return XFA_EVENTERROR_NotExist; + if (GetNode()->IsUserInteractive()) + return XFA_EVENTERROR_Disabled; + + CXFA_EventParam EventParam; + EventParam.m_eType = XFA_EVENT_Calculate; + CXFA_Script script = calc.GetScript(); + int32_t iRet = ExecuteScript(script, &EventParam); + if (iRet != XFA_EVENTERROR_Success) + return iRet; + + if (GetRawValue() != EventParam.m_wsResult) { + SetValue(EventParam.m_wsResult, XFA_VALUEPICTURE_Raw); + UpdateUIDisplay(); + } + return XFA_EVENTERROR_Success; +} + +void CXFA_WidgetAcc::ProcessScriptTestValidate(CXFA_Validate validate, + int32_t iRet, + CFXJSE_Value* pRetValue, + bool bVersionFlag) { + if (iRet == XFA_EVENTERROR_Success && pRetValue) { + if (pRetValue->IsBoolean() && !pRetValue->ToBoolean()) { + IXFA_AppProvider* pAppProvider = GetAppProvider(); + if (!pAppProvider) { + return; + } + CFX_WideString wsTitle = pAppProvider->GetAppTitle(); + CFX_WideString wsScriptMsg; + validate.GetScriptMessageText(wsScriptMsg); + int32_t eScriptTest = validate.GetScriptTest(); + if (eScriptTest == XFA_ATTRIBUTEENUM_Warning) { + if (GetNode()->IsUserInteractive()) + return; + if (wsScriptMsg.IsEmpty()) + wsScriptMsg = GetValidateMessage(false, bVersionFlag); + + if (bVersionFlag) { + pAppProvider->MsgBox(wsScriptMsg, wsTitle, XFA_MBICON_Warning, + XFA_MB_OK); + return; + } + if (pAppProvider->MsgBox(wsScriptMsg, wsTitle, XFA_MBICON_Warning, + XFA_MB_YesNo) == XFA_IDYes) { + GetNode()->SetFlag(XFA_NodeFlag_UserInteractive, false); + } + } else { + if (wsScriptMsg.IsEmpty()) + wsScriptMsg = GetValidateMessage(true, bVersionFlag); + pAppProvider->MsgBox(wsScriptMsg, wsTitle, XFA_MBICON_Error, XFA_MB_OK); + } + } + } +} + +int32_t CXFA_WidgetAcc::ProcessFormatTestValidate(CXFA_Validate validate, + bool bVersionFlag) { + CFX_WideString wsRawValue = GetRawValue(); + if (!wsRawValue.IsEmpty()) { + CFX_WideString wsPicture; + validate.GetPicture(wsPicture); + if (wsPicture.IsEmpty()) + return XFA_EVENTERROR_NotExist; + + IFX_Locale* pLocale = GetLocal(); + if (!pLocale) + return XFA_EVENTERROR_NotExist; + + CXFA_LocaleValue lcValue = XFA_GetLocaleValue(this); + if (!lcValue.ValidateValue(lcValue.GetValue(), wsPicture, pLocale)) { + IXFA_AppProvider* pAppProvider = GetAppProvider(); + if (!pAppProvider) + return XFA_EVENTERROR_NotExist; + + CFX_WideString wsFormatMsg; + validate.GetFormatMessageText(wsFormatMsg); + CFX_WideString wsTitle = pAppProvider->GetAppTitle(); + int32_t eFormatTest = validate.GetFormatTest(); + if (eFormatTest == XFA_ATTRIBUTEENUM_Error) { + if (wsFormatMsg.IsEmpty()) + wsFormatMsg = GetValidateMessage(true, bVersionFlag); + pAppProvider->MsgBox(wsFormatMsg, wsTitle, XFA_MBICON_Error, XFA_MB_OK); + return XFA_EVENTERROR_Success; + } + if (GetNode()->IsUserInteractive()) + return XFA_EVENTERROR_NotExist; + if (wsFormatMsg.IsEmpty()) + wsFormatMsg = GetValidateMessage(false, bVersionFlag); + + if (bVersionFlag) { + pAppProvider->MsgBox(wsFormatMsg, wsTitle, XFA_MBICON_Warning, + XFA_MB_OK); + return XFA_EVENTERROR_Success; + } + if (pAppProvider->MsgBox(wsFormatMsg, wsTitle, XFA_MBICON_Warning, + XFA_MB_YesNo) == XFA_IDYes) { + GetNode()->SetFlag(XFA_NodeFlag_UserInteractive, false); + } + return XFA_EVENTERROR_Success; + } + } + return XFA_EVENTERROR_NotExist; +} + +int32_t CXFA_WidgetAcc::ProcessNullTestValidate(CXFA_Validate validate, + int32_t iFlags, + bool bVersionFlag) { + CFX_WideString wsValue; + GetValue(wsValue, XFA_VALUEPICTURE_Raw); + if (!wsValue.IsEmpty()) + return XFA_EVENTERROR_Success; + if (m_bIsNull && (m_bPreNull == m_bIsNull)) + return XFA_EVENTERROR_Success; + + int32_t eNullTest = validate.GetNullTest(); + CFX_WideString wsNullMsg; + validate.GetNullMessageText(wsNullMsg); + if (iFlags & 0x01) { + int32_t iRet = XFA_EVENTERROR_Success; + if (eNullTest != XFA_ATTRIBUTEENUM_Disabled) + iRet = XFA_EVENTERROR_Error; + + if (!wsNullMsg.IsEmpty()) { + if (eNullTest != XFA_ATTRIBUTEENUM_Disabled) { + m_pDocView->m_arrNullTestMsg.push_back(wsNullMsg); + return XFA_EVENTERROR_Error; + } + return XFA_EVENTERROR_Success; + } + return iRet; + } + if (wsNullMsg.IsEmpty() && bVersionFlag && + eNullTest != XFA_ATTRIBUTEENUM_Disabled) { + return XFA_EVENTERROR_Error; + } + IXFA_AppProvider* pAppProvider = GetAppProvider(); + if (!pAppProvider) + return XFA_EVENTERROR_NotExist; + + CFX_WideString wsCaptionName; + CFX_WideString wsTitle = pAppProvider->GetAppTitle(); + switch (eNullTest) { + case XFA_ATTRIBUTEENUM_Error: { + if (wsNullMsg.IsEmpty()) { + wsCaptionName = GetValidateCaptionName(bVersionFlag); + wsNullMsg.Format(L"%s cannot be blank.", wsCaptionName.c_str()); + } + pAppProvider->MsgBox(wsNullMsg, wsTitle, XFA_MBICON_Status, XFA_MB_OK); + return XFA_EVENTERROR_Error; + } + case XFA_ATTRIBUTEENUM_Warning: { + if (GetNode()->IsUserInteractive()) + return true; + + if (wsNullMsg.IsEmpty()) { + wsCaptionName = GetValidateCaptionName(bVersionFlag); + wsNullMsg.Format( + L"%s cannot be blank. To ignore validations for %s, click Ignore.", + wsCaptionName.c_str(), wsCaptionName.c_str()); + } + if (pAppProvider->MsgBox(wsNullMsg, wsTitle, XFA_MBICON_Warning, + XFA_MB_YesNo) == XFA_IDYes) { + GetNode()->SetFlag(XFA_NodeFlag_UserInteractive, false); + } + return XFA_EVENTERROR_Error; + } + case XFA_ATTRIBUTEENUM_Disabled: + default: + break; + } + return XFA_EVENTERROR_Success; +} + +CFX_WideString CXFA_WidgetAcc::GetValidateCaptionName(bool bVersionFlag) { + CFX_WideString wsCaptionName; + + if (!bVersionFlag) { + if (CXFA_Caption caption = GetCaption()) { + if (CXFA_Value capValue = caption.GetValue()) { + if (CXFA_Text capText = capValue.GetText()) + capText.GetContent(wsCaptionName); + } + } + } + if (wsCaptionName.IsEmpty()) + GetName(wsCaptionName); + + return wsCaptionName; +} + +CFX_WideString CXFA_WidgetAcc::GetValidateMessage(bool bError, + bool bVersionFlag) { + CFX_WideString wsCaptionName = GetValidateCaptionName(bVersionFlag); + CFX_WideString wsMessage; + if (bVersionFlag) { + wsMessage.Format(L"%s validation failed", wsCaptionName.c_str()); + return wsMessage; + } + if (bError) { + wsMessage.Format(L"The value you entered for %s is invalid.", + wsCaptionName.c_str()); + return wsMessage; + } + wsMessage.Format( + L"The value you entered for %s is invalid. To ignore " + L"validations for %s, click Ignore.", + wsCaptionName.c_str(), wsCaptionName.c_str()); + return wsMessage; +} + +int32_t CXFA_WidgetAcc::ProcessValidate(int32_t iFlags) { + if (GetElementType() == XFA_Element::Draw) + return XFA_EVENTERROR_NotExist; + + CXFA_Validate validate = GetValidate(); + if (!validate) + return XFA_EVENTERROR_NotExist; + + bool bInitDoc = validate.GetNode()->NeedsInitApp(); + bool bStatus = m_pDocView->GetLayoutStatus() < XFA_DOCVIEW_LAYOUTSTATUS_End; + int32_t iFormat = 0; + CFXJSE_Value* pRetValue = nullptr; + int32_t iRet = XFA_EVENTERROR_NotExist; + CXFA_Script script = validate.GetScript(); + if (script) { + CXFA_EventParam eParam; + eParam.m_eType = XFA_EVENT_Validate; + eParam.m_pTarget = this; + iRet = ExecuteScript(script, &eParam, + ((bInitDoc || bStatus) && GetRawValue().IsEmpty()) + ? nullptr + : &pRetValue); + } + XFA_VERSION version = GetDoc()->GetXFADoc()->GetCurVersionMode(); + bool bVersionFlag = false; + if (version < XFA_VERSION_208) + bVersionFlag = true; + + if (bInitDoc) { + validate.GetNode()->ClearFlag(XFA_NodeFlag_NeedsInitApp); + } else { + iFormat = ProcessFormatTestValidate(validate, bVersionFlag); + if (!bVersionFlag) + bVersionFlag = GetDoc()->GetXFADoc()->HasFlag(XFA_DOCFLAG_Scripting); + + iRet |= ProcessNullTestValidate(validate, iFlags, bVersionFlag); + } + if (iFormat != XFA_EVENTERROR_Success) + ProcessScriptTestValidate(validate, iRet, pRetValue, bVersionFlag); + + delete pRetValue; + + return iRet | iFormat; +} + +int32_t CXFA_WidgetAcc::ExecuteScript(CXFA_Script script, + CXFA_EventParam* pEventParam, + CFXJSE_Value** pRetValue) { + static const uint32_t MAX_RECURSION_DEPTH = 2; + if (m_nRecursionDepth > MAX_RECURSION_DEPTH) + return XFA_EVENTERROR_Success; + + ASSERT(pEventParam); + if (!script) + return XFA_EVENTERROR_NotExist; + if (script.GetRunAt() == XFA_ATTRIBUTEENUM_Server) + return XFA_EVENTERROR_Disabled; + + CFX_WideString wsExpression; + script.GetExpression(wsExpression); + if (wsExpression.IsEmpty()) + return XFA_EVENTERROR_NotExist; + + XFA_SCRIPTTYPE eScriptType = script.GetContentType(); + if (eScriptType == XFA_SCRIPTTYPE_Unkown) + return XFA_EVENTERROR_Success; + + CXFA_FFDoc* pDoc = GetDoc(); + CXFA_ScriptContext* pContext = pDoc->GetXFADoc()->GetScriptContext(); + pContext->SetEventParam(*pEventParam); + pContext->SetRunAtType((XFA_ATTRIBUTEENUM)script.GetRunAt()); + std::vector refNodes; + if (pEventParam->m_eType == XFA_EVENT_InitCalculate || + pEventParam->m_eType == XFA_EVENT_Calculate) { + pContext->SetNodesOfRunScript(&refNodes); + } + std::unique_ptr pTmpRetValue( + new CFXJSE_Value(pContext->GetRuntime())); + ++m_nRecursionDepth; + bool bRet = pContext->RunScript((XFA_SCRIPTLANGTYPE)eScriptType, + wsExpression.AsStringC(), pTmpRetValue.get(), + m_pNode); + --m_nRecursionDepth; + int32_t iRet = XFA_EVENTERROR_Error; + if (bRet) { + iRet = XFA_EVENTERROR_Success; + if (pEventParam->m_eType == XFA_EVENT_Calculate || + pEventParam->m_eType == XFA_EVENT_InitCalculate) { + if (!pTmpRetValue->IsUndefined()) { + if (!pTmpRetValue->IsNull()) + pEventParam->m_wsResult = pTmpRetValue->ToWideString(); + + iRet = XFA_EVENTERROR_Success; + } else { + iRet = XFA_EVENTERROR_Error; + } + if (pEventParam->m_eType == XFA_EVENT_InitCalculate) { + if ((iRet == XFA_EVENTERROR_Success) && + (GetRawValue() != pEventParam->m_wsResult)) { + SetValue(pEventParam->m_wsResult, XFA_VALUEPICTURE_Raw); + m_pDocView->AddValidateWidget(this); + } + } + for (CXFA_Node* pRefNode : refNodes) { + if (static_cast(pRefNode->GetWidgetData()) == this) + continue; + + auto* pGlobalData = + static_cast(pRefNode->GetUserData(XFA_CalcData)); + if (!pGlobalData) { + pGlobalData = new CXFA_CalcData; + pRefNode->SetUserData(XFA_CalcData, pGlobalData, + &gs_XFADeleteCalcData); + } + if (!pdfium::ContainsValue(pGlobalData->m_Globals, this)) + pGlobalData->m_Globals.push_back(this); + } + } + } + if (pRetValue) + *pRetValue = pTmpRetValue.release(); + + pContext->SetNodesOfRunScript(nullptr); + return iRet; +} + +CXFA_FFWidget* CXFA_WidgetAcc::GetNextWidget(CXFA_FFWidget* pWidget) { + CXFA_LayoutItem* pLayout = nullptr; + if (pWidget) + pLayout = pWidget->GetNext(); + else + pLayout = m_pDocView->GetXFALayout()->GetLayoutItem(m_pNode); + + return static_cast(pLayout); +} + +void CXFA_WidgetAcc::UpdateUIDisplay(CXFA_FFWidget* pExcept) { + CXFA_FFWidget* pWidget = nullptr; + while ((pWidget = GetNextWidget(pWidget)) != nullptr) { + if (pWidget == pExcept || !pWidget->IsLoaded() || + (GetUIType() != XFA_Element::CheckButton && pWidget->IsFocused())) { + continue; + } + pWidget->UpdateFWLData(); + pWidget->AddInvalidateRect(); + } +} + +void CXFA_WidgetAcc::CalcCaptionSize(CFX_SizeF& szCap) { + CXFA_Caption caption = GetCaption(); + if (!caption || caption.GetPresence() != XFA_ATTRIBUTEENUM_Visible) + return; + + LoadCaption(); + XFA_Element eUIType = GetUIType(); + int32_t iCapPlacement = caption.GetPlacementType(); + float fCapReserve = caption.GetReserve(); + const bool bVert = iCapPlacement == XFA_ATTRIBUTEENUM_Top || + iCapPlacement == XFA_ATTRIBUTEENUM_Bottom; + const bool bReserveExit = fCapReserve > 0.01; + CXFA_TextLayout* pCapTextLayout = + static_cast(m_pLayoutData.get()) + ->m_pCapTextLayout.get(); + if (pCapTextLayout) { + if (!bVert && eUIType != XFA_Element::Button) + szCap.width = fCapReserve; + + CFX_SizeF minSize; + pCapTextLayout->CalcSize(minSize, szCap, szCap); + if (bReserveExit) + bVert ? szCap.height = fCapReserve : szCap.width = fCapReserve; + } else { + float fFontSize = 10.0f; + if (CXFA_Font font = caption.GetFont()) + fFontSize = font.GetFontSize(); + else if (CXFA_Font widgetfont = GetFont()) + fFontSize = widgetfont.GetFontSize(); + + if (bVert) { + szCap.height = fCapReserve > 0 ? fCapReserve : fFontSize; + } else { + szCap.width = fCapReserve > 0 ? fCapReserve : 0; + szCap.height = fFontSize; + } + } + if (CXFA_Margin mgCap = caption.GetMargin()) { + float fLeftInset, fTopInset, fRightInset, fBottomInset; + mgCap.GetLeftInset(fLeftInset); + mgCap.GetTopInset(fTopInset); + mgCap.GetRightInset(fRightInset); + mgCap.GetBottomInset(fBottomInset); + if (bReserveExit) { + bVert ? (szCap.width += fLeftInset + fRightInset) + : (szCap.height += fTopInset + fBottomInset); + } else { + szCap.width += fLeftInset + fRightInset; + szCap.height += fTopInset + fBottomInset; + } + } +} + +bool CXFA_WidgetAcc::CalculateFieldAutoSize(CFX_SizeF& size) { + CFX_SizeF szCap; + CalcCaptionSize(szCap); + CFX_RectF rtUIMargin = GetUIMargin(); + size.width += rtUIMargin.left + rtUIMargin.width; + size.height += rtUIMargin.top + rtUIMargin.height; + if (szCap.width > 0 && szCap.height > 0) { + int32_t iCapPlacement = GetCaption().GetPlacementType(); + switch (iCapPlacement) { + case XFA_ATTRIBUTEENUM_Left: + case XFA_ATTRIBUTEENUM_Right: + case XFA_ATTRIBUTEENUM_Inline: { + size.width += szCap.width; + size.height = std::max(size.height, szCap.height); + } break; + case XFA_ATTRIBUTEENUM_Top: + case XFA_ATTRIBUTEENUM_Bottom: { + size.height += szCap.height; + size.width = std::max(size.width, szCap.width); + } + default: + break; + } + } + return CalculateWidgetAutoSize(size); +} + +bool CXFA_WidgetAcc::CalculateWidgetAutoSize(CFX_SizeF& size) { + CXFA_Margin mgWidget = GetMargin(); + if (mgWidget) { + float fLeftInset, fTopInset, fRightInset, fBottomInset; + mgWidget.GetLeftInset(fLeftInset); + mgWidget.GetTopInset(fTopInset); + mgWidget.GetRightInset(fRightInset); + mgWidget.GetBottomInset(fBottomInset); + size.width += fLeftInset + fRightInset; + size.height += fTopInset + fBottomInset; + } + CXFA_Para para = GetPara(); + if (para) + size.width += para.GetMarginLeft() + para.GetTextIndent(); + + float fVal = 0; + float fMin = 0; + float fMax = 0; + if (GetWidth(fVal)) { + size.width = fVal; + } else { + if (GetMinWidth(fMin)) + size.width = std::max(size.width, fMin); + if (GetMaxWidth(fMax) && fMax > 0) + size.width = std::min(size.width, fMax); + } + fVal = 0; + fMin = 0; + fMax = 0; + if (GetHeight(fVal)) { + size.height = fVal; + } else { + if (GetMinHeight(fMin)) + size.height = std::max(size.height, fMin); + if (GetMaxHeight(fMax) && fMax > 0) + size.height = std::min(size.height, fMax); + } + return true; +} + +void CXFA_WidgetAcc::CalculateTextContentSize(CFX_SizeF& size) { + float fFontSize = GetFontSize(); + CFX_WideString wsText; + GetValue(wsText, XFA_VALUEPICTURE_Display); + if (wsText.IsEmpty()) { + size.height += fFontSize; + return; + } + + wchar_t wcEnter = '\n'; + wchar_t wsLast = wsText.GetAt(wsText.GetLength() - 1); + if (wsLast == wcEnter) + wsText = wsText + wcEnter; + + CXFA_FieldLayoutData* layoutData = + static_cast(m_pLayoutData.get()); + if (!layoutData->m_pTextOut) { + layoutData->m_pTextOut = pdfium::MakeUnique(); + CFDE_TextOut* pTextOut = layoutData->m_pTextOut.get(); + pTextOut->SetFont(GetFDEFont()); + pTextOut->SetFontSize(fFontSize); + pTextOut->SetLineBreakTolerance(fFontSize * 0.2f); + pTextOut->SetLineSpace(GetLineHeight()); + uint32_t dwStyles = FDE_TTOSTYLE_LastLineHeight; + if (GetUIType() == XFA_Element::TextEdit && IsMultiLine()) + dwStyles |= FDE_TTOSTYLE_LineWrap; + + pTextOut->SetStyles(dwStyles); + } + layoutData->m_pTextOut->CalcLogicSize(wsText.c_str(), wsText.GetLength(), + size); +} + +bool CXFA_WidgetAcc::CalculateTextEditAutoSize(CFX_SizeF& size) { + if (size.width > 0) { + CFX_SizeF szOrz = size; + CFX_SizeF szCap; + CalcCaptionSize(szCap); + bool bCapExit = szCap.width > 0.01 && szCap.height > 0.01; + int32_t iCapPlacement = XFA_ATTRIBUTEENUM_Unknown; + if (bCapExit) { + iCapPlacement = GetCaption().GetPlacementType(); + switch (iCapPlacement) { + case XFA_ATTRIBUTEENUM_Left: + case XFA_ATTRIBUTEENUM_Right: + case XFA_ATTRIBUTEENUM_Inline: { + size.width -= szCap.width; + } + default: + break; + } + } + CFX_RectF rtUIMargin = GetUIMargin(); + size.width -= rtUIMargin.left + rtUIMargin.width; + CXFA_Margin mgWidget = GetMargin(); + if (mgWidget) { + float fLeftInset, fRightInset; + mgWidget.GetLeftInset(fLeftInset); + mgWidget.GetRightInset(fRightInset); + size.width -= fLeftInset + fRightInset; + } + CalculateTextContentSize(size); + size.height += rtUIMargin.top + rtUIMargin.height; + if (bCapExit) { + switch (iCapPlacement) { + case XFA_ATTRIBUTEENUM_Left: + case XFA_ATTRIBUTEENUM_Right: + case XFA_ATTRIBUTEENUM_Inline: { + size.height = std::max(size.height, szCap.height); + } break; + case XFA_ATTRIBUTEENUM_Top: + case XFA_ATTRIBUTEENUM_Bottom: { + size.height += szCap.height; + } + default: + break; + } + } + size.width = szOrz.width; + return CalculateWidgetAutoSize(size); + } + CalculateTextContentSize(size); + return CalculateFieldAutoSize(size); +} + +bool CXFA_WidgetAcc::CalculateCheckButtonAutoSize(CFX_SizeF& size) { + float fCheckSize = GetCheckButtonSize(); + size = CFX_SizeF(fCheckSize, fCheckSize); + return CalculateFieldAutoSize(size); +} + +bool CXFA_WidgetAcc::CalculatePushButtonAutoSize(CFX_SizeF& size) { + CalcCaptionSize(size); + return CalculateWidgetAutoSize(size); +} + +bool CXFA_WidgetAcc::CalculateImageAutoSize(CFX_SizeF& size) { + if (!GetImageImage()) + LoadImageImage(); + + size.clear(); + if (CFX_DIBitmap* pBitmap = GetImageImage()) { + int32_t iImageXDpi = 0; + int32_t iImageYDpi = 0; + GetImageDpi(iImageXDpi, iImageYDpi); + CFX_RectF rtImage( + 0, 0, XFA_UnitPx2Pt((float)pBitmap->GetWidth(), (float)iImageXDpi), + XFA_UnitPx2Pt((float)pBitmap->GetHeight(), (float)iImageYDpi)); + + CFX_RectF rtFit; + if (GetWidth(rtFit.width)) + GetWidthWithoutMargin(rtFit.width); + else + rtFit.width = rtImage.width; + + if (GetHeight(rtFit.height)) + GetHeightWithoutMargin(rtFit.height); + else + rtFit.height = rtImage.height; + + size = rtFit.Size(); + } + return CalculateWidgetAutoSize(size); +} + +bool CXFA_WidgetAcc::CalculateImageEditAutoSize(CFX_SizeF& size) { + if (!GetImageEditImage()) + LoadImageEditImage(); + + size.clear(); + if (CFX_DIBitmap* pBitmap = GetImageEditImage()) { + int32_t iImageXDpi = 0; + int32_t iImageYDpi = 0; + GetImageEditDpi(iImageXDpi, iImageYDpi); + CFX_RectF rtImage( + 0, 0, XFA_UnitPx2Pt((float)pBitmap->GetWidth(), (float)iImageXDpi), + XFA_UnitPx2Pt((float)pBitmap->GetHeight(), (float)iImageYDpi)); + + CFX_RectF rtFit; + if (GetWidth(rtFit.width)) + GetWidthWithoutMargin(rtFit.width); + else + rtFit.width = rtImage.width; + + if (GetHeight(rtFit.height)) + GetHeightWithoutMargin(rtFit.height); + else + rtFit.height = rtImage.height; + + size.width = rtFit.width; + size.height = rtFit.height; + } + return CalculateFieldAutoSize(size); +} + +bool CXFA_WidgetAcc::LoadImageImage() { + InitLayoutData(); + return static_cast(m_pLayoutData.get()) + ->LoadImageData(this); +} + +bool CXFA_WidgetAcc::LoadImageEditImage() { + InitLayoutData(); + return static_cast(m_pLayoutData.get()) + ->LoadImageData(this); +} + +void CXFA_WidgetAcc::GetImageDpi(int32_t& iImageXDpi, int32_t& iImageYDpi) { + CXFA_ImageLayoutData* pData = + static_cast(m_pLayoutData.get()); + iImageXDpi = pData->m_iImageXDpi; + iImageYDpi = pData->m_iImageYDpi; +} + +void CXFA_WidgetAcc::GetImageEditDpi(int32_t& iImageXDpi, int32_t& iImageYDpi) { + CXFA_ImageEditData* pData = + static_cast(m_pLayoutData.get()); + iImageXDpi = pData->m_iImageXDpi; + iImageYDpi = pData->m_iImageYDpi; +} + +bool CXFA_WidgetAcc::CalculateTextAutoSize(CFX_SizeF& size) { + LoadText(); + CXFA_TextLayout* pTextLayout = + static_cast(m_pLayoutData.get())->GetTextLayout(); + if (pTextLayout) { + size.width = pTextLayout->StartLayout(size.width); + size.height = pTextLayout->GetLayoutHeight(); + } + return CalculateWidgetAutoSize(size); +} + +void CXFA_WidgetAcc::LoadText() { + InitLayoutData(); + static_cast(m_pLayoutData.get())->LoadText(this); +} + +float CXFA_WidgetAcc::CalculateWidgetAutoWidth(float fWidthCalc) { + CXFA_Margin mgWidget = GetMargin(); + if (mgWidget) { + float fLeftInset, fRightInset; + mgWidget.GetLeftInset(fLeftInset); + mgWidget.GetRightInset(fRightInset); + fWidthCalc += fLeftInset + fRightInset; + } + + float fMin = 0, fMax = 0; + if (GetMinWidth(fMin)) + fWidthCalc = std::max(fWidthCalc, fMin); + if (GetMaxWidth(fMax) && fMax > 0) + fWidthCalc = std::min(fWidthCalc, fMax); + + return fWidthCalc; +} + +float CXFA_WidgetAcc::GetWidthWithoutMargin(float fWidthCalc) { + CXFA_Margin mgWidget = GetMargin(); + if (mgWidget) { + float fLeftInset, fRightInset; + mgWidget.GetLeftInset(fLeftInset); + mgWidget.GetRightInset(fRightInset); + fWidthCalc -= fLeftInset + fRightInset; + } + return fWidthCalc; +} + +float CXFA_WidgetAcc::CalculateWidgetAutoHeight(float fHeightCalc) { + CXFA_Margin mgWidget = GetMargin(); + if (mgWidget) { + float fTopInset, fBottomInset; + mgWidget.GetTopInset(fTopInset); + mgWidget.GetBottomInset(fBottomInset); + fHeightCalc += fTopInset + fBottomInset; + } + + float fMin = 0, fMax = 0; + if (GetMinHeight(fMin)) + fHeightCalc = std::max(fHeightCalc, fMin); + if (GetMaxHeight(fMax) && fMax > 0) + fHeightCalc = std::min(fHeightCalc, fMax); + + return fHeightCalc; +} + +float CXFA_WidgetAcc::GetHeightWithoutMargin(float fHeightCalc) { + CXFA_Margin mgWidget = GetMargin(); + if (mgWidget) { + float fTopInset, fBottomInset; + mgWidget.GetTopInset(fTopInset); + mgWidget.GetBottomInset(fBottomInset); + fHeightCalc -= fTopInset + fBottomInset; + } + return fHeightCalc; +} + +void CXFA_WidgetAcc::StartWidgetLayout(float& fCalcWidth, float& fCalcHeight) { + InitLayoutData(); + XFA_Element eUIType = GetUIType(); + if (eUIType == XFA_Element::Text) { + m_pLayoutData->m_fWidgetHeight = -1; + GetHeight(m_pLayoutData->m_fWidgetHeight); + StartTextLayout(fCalcWidth, fCalcHeight); + return; + } + if (fCalcWidth > 0 && fCalcHeight > 0) + return; + + m_pLayoutData->m_fWidgetHeight = -1; + float fWidth = 0; + if (fCalcWidth > 0 && fCalcHeight < 0) { + if (!GetHeight(fCalcHeight)) + CalculateAccWidthAndHeight(eUIType, fCalcWidth, fCalcHeight); + + m_pLayoutData->m_fWidgetHeight = fCalcHeight; + return; + } + if (fCalcWidth < 0 && fCalcHeight < 0) { + if (!GetWidth(fWidth) || !GetHeight(fCalcHeight)) + CalculateAccWidthAndHeight(eUIType, fWidth, fCalcHeight); + + fCalcWidth = fWidth; + } + m_pLayoutData->m_fWidgetHeight = fCalcHeight; +} + +void CXFA_WidgetAcc::CalculateAccWidthAndHeight(XFA_Element eUIType, + float& fWidth, + float& fCalcHeight) { + CFX_SizeF sz(fWidth, m_pLayoutData->m_fWidgetHeight); + switch (eUIType) { + case XFA_Element::Barcode: + case XFA_Element::ChoiceList: + case XFA_Element::Signature: + CalculateFieldAutoSize(sz); + break; + case XFA_Element::ImageEdit: + CalculateImageEditAutoSize(sz); + break; + case XFA_Element::Button: + CalculatePushButtonAutoSize(sz); + break; + case XFA_Element::CheckButton: + CalculateCheckButtonAutoSize(sz); + break; + case XFA_Element::DateTimeEdit: + case XFA_Element::NumericEdit: + case XFA_Element::PasswordEdit: + case XFA_Element::TextEdit: + CalculateTextEditAutoSize(sz); + break; + case XFA_Element::Image: + CalculateImageAutoSize(sz); + break; + case XFA_Element::Arc: + case XFA_Element::Line: + case XFA_Element::Rectangle: + case XFA_Element::Subform: + case XFA_Element::ExclGroup: + CalculateWidgetAutoSize(sz); + break; + default: + break; + } + fWidth = sz.width; + m_pLayoutData->m_fWidgetHeight = sz.height; + fCalcHeight = sz.height; +} + +bool CXFA_WidgetAcc::FindSplitPos(int32_t iBlockIndex, float& fCalcHeight) { + XFA_Element eUIType = GetUIType(); + if (eUIType == XFA_Element::Subform) + return false; + + if (eUIType != XFA_Element::Text && eUIType != XFA_Element::TextEdit && + eUIType != XFA_Element::NumericEdit && + eUIType != XFA_Element::PasswordEdit) { + fCalcHeight = 0; + return true; + } + + float fTopInset = 0; + float fBottomInset = 0; + if (iBlockIndex == 0) { + CXFA_Margin mgWidget = GetMargin(); + if (mgWidget) { + mgWidget.GetTopInset(fTopInset); + mgWidget.GetBottomInset(fBottomInset); + } + CFX_RectF rtUIMargin = GetUIMargin(); + fTopInset += rtUIMargin.top; + fBottomInset += rtUIMargin.width; + } + if (eUIType == XFA_Element::Text) { + float fHeight = fCalcHeight; + if (iBlockIndex == 0) { + fCalcHeight = fCalcHeight - fTopInset; + if (fCalcHeight < 0) + fCalcHeight = 0; + } + + CXFA_TextLayout* pTextLayout = + static_cast(m_pLayoutData.get())->GetTextLayout(); + pTextLayout->DoLayout(iBlockIndex, fCalcHeight, fCalcHeight, + m_pLayoutData->m_fWidgetHeight - fTopInset); + if (fCalcHeight != 0) { + if (iBlockIndex == 0) + fCalcHeight = fCalcHeight + fTopInset; + if (fabs(fHeight - fCalcHeight) < XFA_FLOAT_PERCISION) + return false; + } + return true; + } + XFA_ATTRIBUTEENUM iCapPlacement = XFA_ATTRIBUTEENUM_Unknown; + float fCapReserve = 0; + if (iBlockIndex == 0) { + CXFA_Caption caption = GetCaption(); + if (caption && caption.GetPresence() != XFA_ATTRIBUTEENUM_Hidden) { + iCapPlacement = (XFA_ATTRIBUTEENUM)caption.GetPlacementType(); + fCapReserve = caption.GetReserve(); + } + if (iCapPlacement == XFA_ATTRIBUTEENUM_Top && + fCalcHeight < fCapReserve + fTopInset) { + fCalcHeight = 0; + return true; + } + if (iCapPlacement == XFA_ATTRIBUTEENUM_Bottom && + m_pLayoutData->m_fWidgetHeight - fCapReserve - fBottomInset) { + fCalcHeight = 0; + return true; + } + if (iCapPlacement != XFA_ATTRIBUTEENUM_Top) + fCapReserve = 0; + } + CXFA_FieldLayoutData* pFieldData = + static_cast(m_pLayoutData.get()); + int32_t iLinesCount = 0; + float fHeight = m_pLayoutData->m_fWidgetHeight; + CFX_WideString wsText; + GetValue(wsText, XFA_VALUEPICTURE_Display); + if (wsText.IsEmpty()) { + iLinesCount = 1; + } else { + if (!pFieldData->m_pTextOut) { + float fWidth = 0; + GetWidth(fWidth); + CalculateAccWidthAndHeight(eUIType, fWidth, fHeight); + } + iLinesCount = pFieldData->m_pTextOut->GetTotalLines(); + } + std::vector* pFieldArray = &pFieldData->m_FieldSplitArray; + int32_t iFieldSplitCount = pdfium::CollectionSize(*pFieldArray); + for (int32_t i = 0; i < iBlockIndex * 3; i += 3) { + iLinesCount -= (int32_t)(*pFieldArray)[i + 1]; + fHeight -= (*pFieldArray)[i + 2]; + } + if (iLinesCount == 0) + return false; + + float fLineHeight = GetLineHeight(); + float fFontSize = GetFontSize(); + float fTextHeight = iLinesCount * fLineHeight - fLineHeight + fFontSize; + float fSpaceAbove = 0; + float fStartOffset = 0; + if (fHeight > 0.1f && iBlockIndex == 0) { + fStartOffset = fTopInset; + fHeight -= (fTopInset + fBottomInset); + if (CXFA_Para para = GetPara()) { + fSpaceAbove = para.GetSpaceAbove(); + float fSpaceBelow = para.GetSpaceBelow(); + fHeight -= (fSpaceAbove + fSpaceBelow); + switch (para.GetVerticalAlign()) { + case XFA_ATTRIBUTEENUM_Top: + fStartOffset += fSpaceAbove; + break; + case XFA_ATTRIBUTEENUM_Middle: + fStartOffset += ((fHeight - fTextHeight) / 2 + fSpaceAbove); + break; + case XFA_ATTRIBUTEENUM_Bottom: + fStartOffset += (fHeight - fTextHeight + fSpaceAbove); + break; + } + } + if (fStartOffset < 0.1f) + fStartOffset = 0; + } + for (int32_t i = iBlockIndex - 1; iBlockIndex > 0 && i < iBlockIndex; i++) { + fStartOffset = (*pFieldArray)[i * 3] - (*pFieldArray)[i * 3 + 2]; + if (fStartOffset < 0.1f) + fStartOffset = 0; + } + if (iFieldSplitCount / 3 == (iBlockIndex + 1)) + (*pFieldArray)[0] = fStartOffset; + else + pFieldArray->push_back(fStartOffset); + + XFA_VERSION version = GetDoc()->GetXFADoc()->GetCurVersionMode(); + bool bCanSplitNoContent = false; + XFA_ATTRIBUTEENUM eLayoutMode; + GetNode() + ->GetNodeItem(XFA_NODEITEM_Parent) + ->TryEnum(XFA_ATTRIBUTE_Layout, eLayoutMode, true); + if ((eLayoutMode == XFA_ATTRIBUTEENUM_Position || + eLayoutMode == XFA_ATTRIBUTEENUM_Tb || + eLayoutMode == XFA_ATTRIBUTEENUM_Row || + eLayoutMode == XFA_ATTRIBUTEENUM_Table) && + version > XFA_VERSION_208) { + bCanSplitNoContent = true; + } + if ((eLayoutMode == XFA_ATTRIBUTEENUM_Tb || + eLayoutMode == XFA_ATTRIBUTEENUM_Row || + eLayoutMode == XFA_ATTRIBUTEENUM_Table) && + version <= XFA_VERSION_208) { + if (fStartOffset < fCalcHeight) { + bCanSplitNoContent = true; + } else { + fCalcHeight = 0; + return true; + } + } + if (bCanSplitNoContent) { + if ((fCalcHeight - fTopInset - fSpaceAbove < fLineHeight)) { + fCalcHeight = 0; + return true; + } + if (fStartOffset + XFA_FLOAT_PERCISION >= fCalcHeight) { + if (iFieldSplitCount / 3 == (iBlockIndex + 1)) { + (*pFieldArray)[iBlockIndex * 3 + 1] = 0; + (*pFieldArray)[iBlockIndex * 3 + 2] = fCalcHeight; + } else { + pFieldArray->push_back(0); + pFieldArray->push_back(fCalcHeight); + } + return false; + } + if (fCalcHeight - fStartOffset < fLineHeight) { + fCalcHeight = fStartOffset; + if (iFieldSplitCount / 3 == (iBlockIndex + 1)) { + (*pFieldArray)[iBlockIndex * 3 + 1] = 0; + (*pFieldArray)[iBlockIndex * 3 + 2] = fCalcHeight; + } else { + pFieldArray->push_back(0); + pFieldArray->push_back(fCalcHeight); + } + return true; + } + float fTextNum = + fCalcHeight + XFA_FLOAT_PERCISION - fCapReserve - fStartOffset; + int32_t iLineNum = + (int32_t)((fTextNum + (fLineHeight - fFontSize)) / fLineHeight); + if (iLineNum >= iLinesCount) { + if (fCalcHeight - fStartOffset - fTextHeight >= fFontSize) { + if (iFieldSplitCount / 3 == (iBlockIndex + 1)) { + (*pFieldArray)[iBlockIndex * 3 + 1] = (float)iLinesCount; + (*pFieldArray)[iBlockIndex * 3 + 2] = fCalcHeight; + } else { + pFieldArray->push_back((float)iLinesCount); + pFieldArray->push_back(fCalcHeight); + } + return false; + } + if (fHeight - fStartOffset - fTextHeight < fFontSize) { + iLineNum -= 1; + if (iLineNum == 0) { + fCalcHeight = 0; + return true; + } + } else { + iLineNum = (int32_t)(fTextNum / fLineHeight); + } + } + if (iLineNum > 0) { + float fSplitHeight = iLineNum * fLineHeight + fCapReserve + fStartOffset; + if (iFieldSplitCount / 3 == (iBlockIndex + 1)) { + (*pFieldArray)[iBlockIndex * 3 + 1] = (float)iLineNum; + (*pFieldArray)[iBlockIndex * 3 + 2] = fSplitHeight; + } else { + pFieldArray->push_back((float)iLineNum); + pFieldArray->push_back(fSplitHeight); + } + if (fabs(fSplitHeight - fCalcHeight) < XFA_FLOAT_PERCISION) + return false; + + fCalcHeight = fSplitHeight; + return true; + } + } + fCalcHeight = 0; + return true; +} + +void CXFA_WidgetAcc::InitLayoutData() { + if (m_pLayoutData) + return; + + switch (GetUIType()) { + case XFA_Element::Text: + m_pLayoutData = pdfium::MakeUnique(); + return; + case XFA_Element::TextEdit: + m_pLayoutData = pdfium::MakeUnique(); + return; + case XFA_Element::Image: + m_pLayoutData = pdfium::MakeUnique(); + return; + case XFA_Element::ImageEdit: + m_pLayoutData = pdfium::MakeUnique(); + return; + default: + break; + } + if (GetElementType() == XFA_Element::Field) { + m_pLayoutData = pdfium::MakeUnique(); + return; + } + m_pLayoutData = pdfium::MakeUnique(); +} + +void CXFA_WidgetAcc::StartTextLayout(float& fCalcWidth, float& fCalcHeight) { + LoadText(); + CXFA_TextLayout* pTextLayout = + static_cast(m_pLayoutData.get())->GetTextLayout(); + float fTextHeight = 0; + if (fCalcWidth > 0 && fCalcHeight > 0) { + float fWidth = GetWidthWithoutMargin(fCalcWidth); + pTextLayout->StartLayout(fWidth); + fTextHeight = fCalcHeight; + fTextHeight = GetHeightWithoutMargin(fTextHeight); + pTextLayout->DoLayout(0, fTextHeight, -1, fTextHeight); + return; + } + if (fCalcWidth > 0 && fCalcHeight < 0) { + float fWidth = GetWidthWithoutMargin(fCalcWidth); + pTextLayout->StartLayout(fWidth); + } + if (fCalcWidth < 0 && fCalcHeight < 0) { + float fMaxWidth = -1; + bool bRet = GetWidth(fMaxWidth); + if (bRet) { + float fWidth = GetWidthWithoutMargin(fMaxWidth); + pTextLayout->StartLayout(fWidth); + } else { + float fWidth = pTextLayout->StartLayout(fMaxWidth); + fMaxWidth = CalculateWidgetAutoWidth(fWidth); + fWidth = GetWidthWithoutMargin(fMaxWidth); + pTextLayout->StartLayout(fWidth); + } + fCalcWidth = fMaxWidth; + } + if (m_pLayoutData->m_fWidgetHeight < 0) { + m_pLayoutData->m_fWidgetHeight = pTextLayout->GetLayoutHeight(); + m_pLayoutData->m_fWidgetHeight = + CalculateWidgetAutoHeight(m_pLayoutData->m_fWidgetHeight); + } + fTextHeight = m_pLayoutData->m_fWidgetHeight; + fTextHeight = GetHeightWithoutMargin(fTextHeight); + pTextLayout->DoLayout(0, fTextHeight, -1, fTextHeight); + fCalcHeight = m_pLayoutData->m_fWidgetHeight; +} + +bool CXFA_WidgetAcc::LoadCaption() { + InitLayoutData(); + return static_cast(m_pLayoutData.get()) + ->LoadCaption(this); +} + +CXFA_TextLayout* CXFA_WidgetAcc::GetCaptionTextLayout() { + return m_pLayoutData + ? static_cast(m_pLayoutData.get()) + ->m_pCapTextLayout.get() + : nullptr; +} + +CXFA_TextLayout* CXFA_WidgetAcc::GetTextLayout() { + return m_pLayoutData + ? static_cast(m_pLayoutData.get()) + ->GetTextLayout() + : nullptr; +} + +CFX_DIBitmap* CXFA_WidgetAcc::GetImageImage() { + return m_pLayoutData + ? static_cast(m_pLayoutData.get()) + ->m_pDIBitmap + : nullptr; +} + +CFX_DIBitmap* CXFA_WidgetAcc::GetImageEditImage() { + return m_pLayoutData + ? static_cast(m_pLayoutData.get()) + ->m_pDIBitmap + : nullptr; +} + +void CXFA_WidgetAcc::SetImageImage(CFX_DIBitmap* newImage) { + CXFA_ImageLayoutData* pData = + static_cast(m_pLayoutData.get()); + if (pData->m_pDIBitmap == newImage) + return; + + if (pData->m_pDIBitmap && !pData->m_bNamedImage) + delete pData->m_pDIBitmap; + + pData->m_pDIBitmap = newImage; +} + +void CXFA_WidgetAcc::SetImageEditImage(CFX_DIBitmap* newImage) { + CXFA_ImageEditData* pData = + static_cast(m_pLayoutData.get()); + if (pData->m_pDIBitmap == newImage) + return; + + if (pData->m_pDIBitmap && !pData->m_bNamedImage) + delete pData->m_pDIBitmap; + + pData->m_pDIBitmap = newImage; +} + +CXFA_WidgetLayoutData* CXFA_WidgetAcc::GetWidgetLayoutData() { + return m_pLayoutData.get(); +} + +CFX_RetainPtr CXFA_WidgetAcc::GetFDEFont() { + CFX_WideStringC wsFontName = L"Courier"; + uint32_t dwFontStyle = 0; + if (CXFA_Font font = GetFont()) { + if (font.IsBold()) + dwFontStyle |= FX_FONTSTYLE_Bold; + if (font.IsItalic()) + dwFontStyle |= FX_FONTSTYLE_Italic; + font.GetTypeface(wsFontName); + } + + auto* pDoc = GetDoc(); + return pDoc->GetApp()->GetXFAFontMgr()->GetFont(pDoc, wsFontName, + dwFontStyle); +} + +float CXFA_WidgetAcc::GetFontSize() { + float fFontSize = 10.0f; + if (CXFA_Font font = GetFont()) + fFontSize = font.GetFontSize(); + return fFontSize < 0.1f ? 10.0f : fFontSize; +} + +float CXFA_WidgetAcc::GetLineHeight() { + float fLineHeight = 0; + if (CXFA_Para para = GetPara()) + fLineHeight = para.GetLineHeight(); + if (fLineHeight < 1) + fLineHeight = GetFontSize() * 1.2f; + return fLineHeight; +} + +FX_ARGB CXFA_WidgetAcc::GetTextColor() { + if (CXFA_Font font = GetFont()) { + return font.GetColor(); + } + return 0xFF000000; +} diff --git a/xfa/fxfa/cxfa_widgetacc.h b/xfa/fxfa/cxfa_widgetacc.h new file mode 100644 index 0000000000..8a7a7eb73d --- /dev/null +++ b/xfa/fxfa/cxfa_widgetacc.h @@ -0,0 +1,121 @@ +// 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_CXFA_WIDGETACC_H_ +#define XFA_FXFA_CXFA_WIDGETACC_H_ + +#include + +#include "core/fxcrt/cfx_retain_ptr.h" +#include "core/fxcrt/fx_coordinates.h" +#include "core/fxge/fx_dib.h" +#include "xfa/fxfa/parser/cxfa_box.h" +#include "xfa/fxfa/parser/cxfa_event.h" +#include "xfa/fxfa/parser/cxfa_image.h" +#include "xfa/fxfa/parser/cxfa_margin.h" +#include "xfa/fxfa/parser/cxfa_script.h" +#include "xfa/fxfa/parser/cxfa_value.h" +#include "xfa/fxfa/parser/cxfa_widgetdata.h" + +class CFGAS_GEFont; +class CXFA_EventParam; +class CXFA_FFApp; +class CXFA_FFDoc; +class CXFA_FFDocView; +class CXFA_FFWidget; +class CXFA_Node; +class CXFA_TextLayout; +class CXFA_WidgetLayoutData; +class IXFA_AppProvider; + +class CXFA_WidgetAcc : public CXFA_WidgetData { + public: + CXFA_WidgetAcc(CXFA_FFDocView* pDocView, CXFA_Node* pNode); + ~CXFA_WidgetAcc(); + + bool GetName(CFX_WideString& wsName, int32_t iNameType = 0); + bool ProcessValueChanged(); + void ResetData(); + + void SetImageEdit(const CFX_WideString& wsContentType, + const CFX_WideString& wsHref, + const CFX_WideString& wsData); + + CXFA_WidgetAcc* GetExclGroup(); + CXFA_FFDocView* GetDocView(); + CXFA_FFDoc* GetDoc(); + CXFA_FFApp* GetApp(); + IXFA_AppProvider* GetAppProvider(); + + int32_t ProcessEvent(int32_t iActivity, CXFA_EventParam* pEventParam); + int32_t ProcessEvent(const CXFA_Event& event, CXFA_EventParam* pEventParam); + int32_t ProcessCalculate(); + int32_t ProcessValidate(int32_t iFlags = 0); + int32_t ExecuteScript(CXFA_Script script, + CXFA_EventParam* pEventParam, + CFXJSE_Value** pRetValue = nullptr); + + CXFA_FFWidget* GetNextWidget(CXFA_FFWidget* pWidget); + void StartWidgetLayout(float& fCalcWidth, float& fCalcHeight); + bool FindSplitPos(int32_t iBlockIndex, float& fCalcHeight); + bool LoadCaption(); + void LoadText(); + bool LoadImageImage(); + bool LoadImageEditImage(); + void GetImageDpi(int32_t& iImageXDpi, int32_t& iImageYDpi); + void GetImageEditDpi(int32_t& iImageXDpi, int32_t& iImageYDpi); + CXFA_TextLayout* GetCaptionTextLayout(); + CXFA_TextLayout* GetTextLayout(); + CFX_DIBitmap* GetImageImage(); + CFX_DIBitmap* GetImageEditImage(); + void SetImageImage(CFX_DIBitmap* newImage); + void SetImageEditImage(CFX_DIBitmap* newImage); + void UpdateUIDisplay(CXFA_FFWidget* pExcept = nullptr); + + CXFA_Node* GetDatasets(); + CFX_RetainPtr GetFDEFont(); + float GetFontSize(); + FX_ARGB GetTextColor(); + float GetLineHeight(); + CXFA_WidgetLayoutData* GetWidgetLayoutData(); + + private: + void ProcessScriptTestValidate(CXFA_Validate validate, + int32_t iRet, + CFXJSE_Value* pRetValue, + bool bVersionFlag); + int32_t ProcessFormatTestValidate(CXFA_Validate validate, bool bVersionFlag); + int32_t ProcessNullTestValidate(CXFA_Validate validate, + int32_t iFlags, + bool bVersionFlag); + CFX_WideString GetValidateCaptionName(bool bVersionFlag); + CFX_WideString GetValidateMessage(bool bError, bool bVersionFlag); + void CalcCaptionSize(CFX_SizeF& szCap); + bool CalculateFieldAutoSize(CFX_SizeF& size); + bool CalculateWidgetAutoSize(CFX_SizeF& size); + bool CalculateTextEditAutoSize(CFX_SizeF& size); + bool CalculateCheckButtonAutoSize(CFX_SizeF& size); + bool CalculatePushButtonAutoSize(CFX_SizeF& size); + bool CalculateImageEditAutoSize(CFX_SizeF& size); + bool CalculateImageAutoSize(CFX_SizeF& size); + bool CalculateTextAutoSize(CFX_SizeF& size); + float CalculateWidgetAutoHeight(float fHeightCalc); + float CalculateWidgetAutoWidth(float fWidthCalc); + float GetWidthWithoutMargin(float fWidthCalc); + float GetHeightWithoutMargin(float fHeightCalc); + void CalculateTextContentSize(CFX_SizeF& size); + void CalculateAccWidthAndHeight(XFA_Element eUIType, + float& fWidth, + float& fCalcHeight); + void InitLayoutData(); + void StartTextLayout(float& fCalcWidth, float& fCalcHeight); + + CXFA_FFDocView* m_pDocView; + std::unique_ptr m_pLayoutData; + uint32_t m_nRecursionDepth; +}; + +#endif // XFA_FXFA_CXFA_WIDGETACC_H_ diff --git a/xfa/fxfa/cxfa_widgetacciterator.cpp b/xfa/fxfa/cxfa_widgetacciterator.cpp new file mode 100644 index 0000000000..721b65692f --- /dev/null +++ b/xfa/fxfa/cxfa_widgetacciterator.cpp @@ -0,0 +1,56 @@ +// 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 + +#include "xfa/fxfa/cxfa_widgetacciterator.h" + +#include "xfa/fxfa/cxfa_widgetacc.h" + +CXFA_WidgetAccIterator::CXFA_WidgetAccIterator(CXFA_Node* pTravelRoot) + : m_ContentIterator(pTravelRoot), m_pCurWidgetAcc(nullptr) {} + +CXFA_WidgetAccIterator::~CXFA_WidgetAccIterator() {} + +void CXFA_WidgetAccIterator::Reset() { + m_pCurWidgetAcc = nullptr; + m_ContentIterator.Reset(); +} + +CXFA_WidgetAcc* CXFA_WidgetAccIterator::MoveToFirst() { + return nullptr; +} + +CXFA_WidgetAcc* CXFA_WidgetAccIterator::MoveToLast() { + return nullptr; +} + +CXFA_WidgetAcc* CXFA_WidgetAccIterator::MoveToNext() { + CXFA_Node* pItem = m_pCurWidgetAcc ? m_ContentIterator.MoveToNext() + : m_ContentIterator.GetCurrent(); + while (pItem) { + m_pCurWidgetAcc = static_cast(pItem->GetWidgetData()); + if (m_pCurWidgetAcc) + return m_pCurWidgetAcc; + pItem = m_ContentIterator.MoveToNext(); + } + return nullptr; +} + +CXFA_WidgetAcc* CXFA_WidgetAccIterator::MoveToPrevious() { + return nullptr; +} + +CXFA_WidgetAcc* CXFA_WidgetAccIterator::GetCurrentWidgetAcc() { + return nullptr; +} + +bool CXFA_WidgetAccIterator::SetCurrentWidgetAcc(CXFA_WidgetAcc* hWidget) { + return false; +} + +void CXFA_WidgetAccIterator::SkipTree() { + m_ContentIterator.SkipChildrenAndMoveToNext(); + m_pCurWidgetAcc = nullptr; +} diff --git a/xfa/fxfa/cxfa_widgetacciterator.h b/xfa/fxfa/cxfa_widgetacciterator.h new file mode 100644 index 0000000000..9ad93ad545 --- /dev/null +++ b/xfa/fxfa/cxfa_widgetacciterator.h @@ -0,0 +1,34 @@ +// 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_CXFA_WIDGETACCITERATOR_H_ +#define XFA_FXFA_CXFA_WIDGETACCITERATOR_H_ + +#include "xfa/fxfa/parser/xfa_object.h" + +class CXFA_Node; +class CXFA_WidgetAcc; + +class CXFA_WidgetAccIterator { + public: + explicit CXFA_WidgetAccIterator(CXFA_Node* pTravelRoot); + ~CXFA_WidgetAccIterator(); + + void Reset(); + CXFA_WidgetAcc* MoveToFirst(); + CXFA_WidgetAcc* MoveToLast(); + CXFA_WidgetAcc* MoveToNext(); + CXFA_WidgetAcc* MoveToPrevious(); + CXFA_WidgetAcc* GetCurrentWidgetAcc(); + bool SetCurrentWidgetAcc(CXFA_WidgetAcc* hWidget); + void SkipTree(); + + private: + CXFA_ContainerIterator m_ContentIterator; + CXFA_WidgetAcc* m_pCurWidgetAcc; // not owned. +}; + +#endif // XFA_FXFA_CXFA_WIDGETACCITERATOR_H_ diff --git a/xfa/fxfa/fxfa.h b/xfa/fxfa/fxfa.h index cc75524624..559035cba1 100644 --- a/xfa/fxfa/fxfa.h +++ b/xfa/fxfa/fxfa.h @@ -10,8 +10,8 @@ #include #include "core/fxcrt/cfx_retain_ptr.h" +#include "xfa/fxfa/cxfa_widgetacc.h" #include "xfa/fxfa/fxfa_basic.h" -#include "xfa/fxfa/fxfa_widget.h" class CFGAS_GEFont; class CFX_Graphics; diff --git a/xfa/fxfa/fxfa_widget.h b/xfa/fxfa/fxfa_widget.h deleted file mode 100644 index 2173b57689..0000000000 --- a/xfa/fxfa/fxfa_widget.h +++ /dev/null @@ -1,121 +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_FXFA_WIDGET_H_ -#define XFA_FXFA_FXFA_WIDGET_H_ - -#include - -#include "core/fxcrt/cfx_retain_ptr.h" -#include "core/fxcrt/fx_coordinates.h" -#include "core/fxge/fx_dib.h" -#include "xfa/fxfa/parser/cxfa_box.h" -#include "xfa/fxfa/parser/cxfa_event.h" -#include "xfa/fxfa/parser/cxfa_image.h" -#include "xfa/fxfa/parser/cxfa_margin.h" -#include "xfa/fxfa/parser/cxfa_script.h" -#include "xfa/fxfa/parser/cxfa_value.h" -#include "xfa/fxfa/parser/cxfa_widgetdata.h" - -class CFGAS_GEFont; -class CXFA_EventParam; -class CXFA_FFApp; -class CXFA_FFDoc; -class CXFA_FFDocView; -class CXFA_FFWidget; -class CXFA_Node; -class CXFA_TextLayout; -class CXFA_WidgetLayoutData; -class IXFA_AppProvider; - -class CXFA_WidgetAcc : public CXFA_WidgetData { - public: - CXFA_WidgetAcc(CXFA_FFDocView* pDocView, CXFA_Node* pNode); - ~CXFA_WidgetAcc(); - - bool GetName(CFX_WideString& wsName, int32_t iNameType = 0); - bool ProcessValueChanged(); - void ResetData(); - - void SetImageEdit(const CFX_WideString& wsContentType, - const CFX_WideString& wsHref, - const CFX_WideString& wsData); - - CXFA_WidgetAcc* GetExclGroup(); - CXFA_FFDocView* GetDocView(); - CXFA_FFDoc* GetDoc(); - CXFA_FFApp* GetApp(); - IXFA_AppProvider* GetAppProvider(); - - int32_t ProcessEvent(int32_t iActivity, CXFA_EventParam* pEventParam); - int32_t ProcessEvent(const CXFA_Event& event, CXFA_EventParam* pEventParam); - int32_t ProcessCalculate(); - int32_t ProcessValidate(int32_t iFlags = 0); - int32_t ExecuteScript(CXFA_Script script, - CXFA_EventParam* pEventParam, - CFXJSE_Value** pRetValue = nullptr); - - CXFA_FFWidget* GetNextWidget(CXFA_FFWidget* pWidget); - void StartWidgetLayout(float& fCalcWidth, float& fCalcHeight); - bool FindSplitPos(int32_t iBlockIndex, float& fCalcHeight); - bool LoadCaption(); - void LoadText(); - bool LoadImageImage(); - bool LoadImageEditImage(); - void GetImageDpi(int32_t& iImageXDpi, int32_t& iImageYDpi); - void GetImageEditDpi(int32_t& iImageXDpi, int32_t& iImageYDpi); - CXFA_TextLayout* GetCaptionTextLayout(); - CXFA_TextLayout* GetTextLayout(); - CFX_DIBitmap* GetImageImage(); - CFX_DIBitmap* GetImageEditImage(); - void SetImageImage(CFX_DIBitmap* newImage); - void SetImageEditImage(CFX_DIBitmap* newImage); - void UpdateUIDisplay(CXFA_FFWidget* pExcept = nullptr); - - CXFA_Node* GetDatasets(); - CFX_RetainPtr GetFDEFont(); - float GetFontSize(); - FX_ARGB GetTextColor(); - float GetLineHeight(); - CXFA_WidgetLayoutData* GetWidgetLayoutData(); - - protected: - void ProcessScriptTestValidate(CXFA_Validate validate, - int32_t iRet, - CFXJSE_Value* pRetValue, - bool bVersionFlag); - int32_t ProcessFormatTestValidate(CXFA_Validate validate, bool bVersionFlag); - int32_t ProcessNullTestValidate(CXFA_Validate validate, - int32_t iFlags, - bool bVersionFlag); - CFX_WideString GetValidateCaptionName(bool bVersionFlag); - CFX_WideString GetValidateMessage(bool bError, bool bVersionFlag); - void CalcCaptionSize(CFX_SizeF& szCap); - bool CalculateFieldAutoSize(CFX_SizeF& size); - bool CalculateWidgetAutoSize(CFX_SizeF& size); - bool CalculateTextEditAutoSize(CFX_SizeF& size); - bool CalculateCheckButtonAutoSize(CFX_SizeF& size); - bool CalculatePushButtonAutoSize(CFX_SizeF& size); - bool CalculateImageEditAutoSize(CFX_SizeF& size); - bool CalculateImageAutoSize(CFX_SizeF& size); - bool CalculateTextAutoSize(CFX_SizeF& size); - float CalculateWidgetAutoHeight(float fHeightCalc); - float CalculateWidgetAutoWidth(float fWidthCalc); - float GetWidthWithoutMargin(float fWidthCalc); - float GetHeightWithoutMargin(float fHeightCalc); - void CalculateTextContentSize(CFX_SizeF& size); - void CalculateAccWidthAndHeight(XFA_Element eUIType, - float& fWidth, - float& fCalcHeight); - void InitLayoutData(); - void StartTextLayout(float& fCalcWidth, float& fCalcHeight); - - CXFA_FFDocView* m_pDocView; - std::unique_ptr m_pLayoutData; - uint32_t m_nRecursionDepth; -}; - -#endif // XFA_FXFA_FXFA_WIDGET_H_ diff --git a/xfa/fxfa/parser/cscript_eventpseudomodel.cpp b/xfa/fxfa/parser/cscript_eventpseudomodel.cpp index 8cfedd2998..fdfcbbfd42 100644 --- a/xfa/fxfa/parser/cscript_eventpseudomodel.cpp +++ b/xfa/fxfa/parser/cscript_eventpseudomodel.cpp @@ -9,12 +9,12 @@ #include "fxjs/cfxjse_arguments.h" #include "xfa/fxfa/app/xfa_ffnotify.h" #include "xfa/fxfa/cxfa_eventparam.h" +#include "xfa/fxfa/cxfa_ffwidgethandler.h" #include "xfa/fxfa/parser/cxfa_document.h" #include "xfa/fxfa/parser/cxfa_scriptcontext.h" #include "xfa/fxfa/parser/xfa_localemgr.h" #include "xfa/fxfa/parser/xfa_object.h" #include "xfa/fxfa/parser/xfa_utils.h" -#include "xfa/fxfa/xfa_ffwidgethandler.h" namespace { diff --git a/xfa/fxfa/parser/cxfa_simple_parser.cpp b/xfa/fxfa/parser/cxfa_simple_parser.cpp index 4a6956de19..70791b6932 100644 --- a/xfa/fxfa/parser/cxfa_simple_parser.cpp +++ b/xfa/fxfa/parser/cxfa_simple_parser.cpp @@ -11,13 +11,13 @@ #include "core/fxcrt/fx_ext.h" #include "third_party/base/ptr_util.h" #include "xfa/fgas/crt/fgas_codepage.h" +#include "xfa/fxfa/cxfa_checksumcontext.h" #include "xfa/fxfa/fxfa.h" #include "xfa/fxfa/parser/cxfa_document.h" #include "xfa/fxfa/parser/cxfa_widetextread.h" #include "xfa/fxfa/parser/cxfa_xml_parser.h" #include "xfa/fxfa/parser/xfa_basic_data.h" #include "xfa/fxfa/parser/xfa_utils.h" -#include "xfa/fxfa/xfa_checksum.h" namespace { diff --git a/xfa/fxfa/xfa_checksum.h b/xfa/fxfa/xfa_checksum.h deleted file mode 100644 index 31cf101553..0000000000 --- a/xfa/fxfa/xfa_checksum.h +++ /dev/null @@ -1,80 +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_XFA_CHECKSUM_H_ -#define XFA_FXFA_XFA_CHECKSUM_H_ - -#include - -#include "core/fdrm/crypto/fx_crypt.h" -#include "xfa/fde/xml/cfx_saxreader.h" -#include "xfa/fxfa/fxfa.h" - -class CXFA_SAXReaderHandler; -class CXFA_ChecksumContext; - -class CXFA_SAXContext { - public: - CXFA_SAXContext() : m_eNode(CFX_SAXItem::Type::Unknown) {} - - CFX_ByteTextBuf m_TextBuf; - CFX_ByteString m_bsTagName; - CFX_SAXItem::Type m_eNode; -}; - -class CXFA_SAXReaderHandler { - public: - explicit CXFA_SAXReaderHandler(CXFA_ChecksumContext* pContext); - ~CXFA_SAXReaderHandler(); - - CXFA_SAXContext* OnTagEnter(const CFX_ByteStringC& bsTagName, - CFX_SAXItem::Type eType, - uint32_t dwStartPos); - void OnTagAttribute(CXFA_SAXContext* pTag, - const CFX_ByteStringC& bsAttri, - const CFX_ByteStringC& bsValue); - void OnTagBreak(CXFA_SAXContext* pTag); - void OnTagData(CXFA_SAXContext* pTag, - CFX_SAXItem::Type eType, - const CFX_ByteStringC& bsData, - uint32_t dwStartPos); - void OnTagClose(CXFA_SAXContext* pTag, uint32_t dwEndPos); - void OnTagEnd(CXFA_SAXContext* pTag, - const CFX_ByteStringC& bsTagName, - uint32_t dwEndPos); - - void OnTargetData(CXFA_SAXContext* pTag, - CFX_SAXItem::Type eType, - const CFX_ByteStringC& bsData, - uint32_t dwStartPos); - - protected: - void UpdateChecksum(bool bCheckSpace); - - CXFA_ChecksumContext* m_pContext; - CXFA_SAXContext m_SAXContext; -}; - -class CXFA_ChecksumContext { - public: - CXFA_ChecksumContext(); - ~CXFA_ChecksumContext(); - - void StartChecksum(); - void Update(const CFX_ByteStringC& bsText); - bool UpdateChecksum(const CFX_RetainPtr& pSrcFile, - FX_FILESIZE offset = 0, - size_t size = 0); - void FinishChecksum(); - CFX_ByteString GetChecksum() const; - - protected: - std::unique_ptr m_pSAXReader; - std::unique_ptr m_pByteContext; - CFX_ByteString m_bsChecksum; -}; - -#endif // XFA_FXFA_XFA_CHECKSUM_H_ diff --git a/xfa/fxfa/xfa_ffapp.h b/xfa/fxfa/xfa_ffapp.h deleted file mode 100644 index 411fd2d273..0000000000 --- a/xfa/fxfa/xfa_ffapp.h +++ /dev/null @@ -1,86 +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_XFA_FFAPP_H_ -#define XFA_FXFA_XFA_FFAPP_H_ - -#include -#include - -#include "core/fpdfapi/parser/cpdf_stream.h" -#include "core/fpdfapi/parser/cpdf_stream_acc.h" -#include "core/fxcrt/cfx_retain_ptr.h" -#include "xfa/fgas/font/cfgas_fontmgr.h" -#include "xfa/fwl/cfwl_app.h" -#include "xfa/fxfa/fxfa.h" - -class CXFA_DefFontMgr; -class CXFA_FWLAdapterWidgetMgr; -class CXFA_FWLTheme; -class CXFA_FFDocHandler; -class CXFA_FontMgr; -class IFWL_AdapterTimerMgr; -class CFWL_WidgetMgrDelegate; - -// Layering prevents fxcrt from knowing about CPDF_Streams; this could go -// in fpdfsdk, but it is XFA-Only. -CFX_RetainPtr MakeSeekableReadStream( - const std::vector& streams); - -class CXFA_FFApp { - public: - explicit CXFA_FFApp(IXFA_AppProvider* pProvider); - ~CXFA_FFApp(); - - std::unique_ptr CreateDoc(IXFA_DocEnvironment* pDocEnvironment, - CPDF_Document* pPDFDoc); - void SetDefaultFontMgr(std::unique_ptr pFontMgr); - - CXFA_FFDocHandler* GetDocHandler(); - CXFA_FWLAdapterWidgetMgr* GetWidgetMgr(CFWL_WidgetMgrDelegate* pDelegate); - CFGAS_FontMgr* GetFDEFontMgr(); - CXFA_FWLTheme* GetFWLTheme(); - - IXFA_AppProvider* GetAppProvider() const { return m_pProvider; } - const CFWL_App* GetFWLApp() const { return m_pFWLApp.get(); } - IFWL_AdapterTimerMgr* GetTimerMgr() const; - CXFA_FontMgr* GetXFAFontMgr() const; - CFWL_WidgetMgrDelegate* GetWidgetMgrDelegate() const { - return m_pWidgetMgrDelegate; - } - - void ClearEventTargets(); - - protected: - std::unique_ptr m_pDocHandler; - IXFA_AppProvider* const m_pProvider; - - // The fonts stored in the font manager may have been created by the default - // font manager. The GEFont::LoadFont call takes the manager as a param and - // stores it internally. When you destroy the GEFont it tries to unregister - // from the font manager and if the default font manager was destroyed first - // get get a use-after-free. The m_pFWLTheme can try to cleanup a GEFont - // when it frees, so make sure it gets cleaned up first. That requires - // m_pFWLApp to be cleaned up as well. - // - // TODO(dsinclair): The GEFont should have the FontMgr as the pointer instead - // of the DEFFontMgr so this goes away. Bug 561. - std::unique_ptr m_pFDEFontMgr; - std::unique_ptr m_pFontMgr; - -#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ - std::unique_ptr m_pFontSource; -#endif - std::unique_ptr m_pAdapterWidgetMgr; - CFWL_WidgetMgrDelegate* m_pWidgetMgrDelegate; // not owned. - - // |m_pFWLApp| has to be released first, then |m_pFWLTheme| since the former - // may refers to theme manager and the latter refers to font manager. - std::unique_ptr m_pFWLTheme; - std::unique_ptr m_pFWLApp; -}; - -#endif // XFA_FXFA_XFA_FFAPP_H_ diff --git a/xfa/fxfa/xfa_ffdoc.h b/xfa/fxfa/xfa_ffdoc.h deleted file mode 100644 index ee7695b15a..0000000000 --- a/xfa/fxfa/xfa_ffdoc.h +++ /dev/null @@ -1,73 +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_XFA_FFDOC_H_ -#define XFA_FXFA_XFA_FFDOC_H_ - -#include -#include - -#include "xfa/fxfa/fxfa.h" -#include "xfa/fxfa/parser/cxfa_document.h" -#include "xfa/fxfa/parser/cxfa_document_parser.h" - -class CXFA_ChecksumContext; -class CXFA_FFApp; -class CXFA_FFNotify; -class CXFA_FFDocView; - -struct FX_IMAGEDIB_AND_DPI { - CFX_DIBSource* pDibSource; - int32_t iImageXDpi; - int32_t iImageYDpi; -}; - -class CXFA_FFDoc { - public: - CXFA_FFDoc(CXFA_FFApp* pApp, IXFA_DocEnvironment* pDocEnvironment); - ~CXFA_FFDoc(); - - IXFA_DocEnvironment* GetDocEnvironment() const { return m_pDocEnvironment; } - XFA_DocType GetDocType() const { return m_dwDocType; } - - int32_t StartLoad(); - int32_t DoLoad(IFX_Pause* pPause = nullptr); - void StopLoad(); - - CXFA_FFDocView* CreateDocView(); - - bool OpenDoc(const CFX_RetainPtr& pStream); - bool OpenDoc(CPDF_Document* pPDFDoc); - bool CloseDoc(); - - CXFA_Document* GetXFADoc() { return m_pDocumentParser->GetDocument(); } - CXFA_FFApp* GetApp() { return m_pApp; } - CXFA_FFDocView* GetDocView(CXFA_LayoutProcessor* pLayout); - CXFA_FFDocView* GetDocView(); - CPDF_Document* GetPDFDoc(); - CFX_DIBitmap* GetPDFNamedImage(const CFX_WideStringC& wsName, - int32_t& iImageXDpi, - int32_t& iImageYDpi); - - bool SavePackage(XFA_HashCode code, - const CFX_RetainPtr& pFile, - CXFA_ChecksumContext* pCSContext); - bool ImportData(const CFX_RetainPtr& pStream, - bool bXDP = true); - - protected: - IXFA_DocEnvironment* const m_pDocEnvironment; - std::unique_ptr m_pDocumentParser; - CFX_RetainPtr m_pStream; - CXFA_FFApp* m_pApp; - std::unique_ptr m_pNotify; - CPDF_Document* m_pPDFDoc; - std::map m_HashToDibDpiMap; - std::unique_ptr m_DocView; - XFA_DocType m_dwDocType; -}; - -#endif // XFA_FXFA_XFA_FFDOC_H_ diff --git a/xfa/fxfa/xfa_ffdochandler.h b/xfa/fxfa/xfa_ffdochandler.h deleted file mode 100644 index 0e4f71786c..0000000000 --- a/xfa/fxfa/xfa_ffdochandler.h +++ /dev/null @@ -1,31 +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_XFA_FFDOCHANDLER_H_ -#define XFA_FXFA_XFA_FFDOCHANDLER_H_ - -#include "xfa/fxfa/fxfa.h" - -class CXFA_ChecksumContext; - -class CXFA_FFDocHandler { - public: - CXFA_FFDocHandler(); - ~CXFA_FFDocHandler(); - - CFXJSE_Value* GetXFAScriptObject(CXFA_FFDoc* hDoc); - XFA_ATTRIBUTEENUM GetRestoreState(CXFA_FFDoc* hDoc); - - bool RunDocScript(CXFA_FFDoc* hDoc, - XFA_SCRIPTTYPE eScriptType, - const CFX_WideStringC& wsScript, - CFXJSE_Value* pRetValue, - CFXJSE_Value* pThisObject); - - protected: -}; - -#endif // XFA_FXFA_XFA_FFDOCHANDLER_H_ diff --git a/xfa/fxfa/xfa_ffdocview.h b/xfa/fxfa/xfa_ffdocview.h deleted file mode 100644 index d8df8b4312..0000000000 --- a/xfa/fxfa/xfa_ffdocview.h +++ /dev/null @@ -1,153 +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_XFA_FFDOCVIEW_H_ -#define XFA_FXFA_XFA_FFDOCVIEW_H_ - -#include -#include -#include - -#include "xfa/fxfa/cxfa_eventparam.h" -#include "xfa/fxfa/xfa_ffdoc.h" - -class CXFA_FFWidgetHandler; -class CXFA_FFDoc; -class CXFA_FFWidget; -class CXFA_WidgetAccIterator; - -extern const XFA_ATTRIBUTEENUM gs_EventActivity[]; -enum XFA_DOCVIEW_LAYOUTSTATUS { - XFA_DOCVIEW_LAYOUTSTATUS_None, - XFA_DOCVIEW_LAYOUTSTATUS_Start, - XFA_DOCVIEW_LAYOUTSTATUS_FormInitialize, - XFA_DOCVIEW_LAYOUTSTATUS_FormInitCalculate, - XFA_DOCVIEW_LAYOUTSTATUS_FormInitValidate, - XFA_DOCVIEW_LAYOUTSTATUS_FormFormReady, - XFA_DOCVIEW_LAYOUTSTATUS_Doing, - XFA_DOCVIEW_LAYOUTSTATUS_PagesetInitialize, - XFA_DOCVIEW_LAYOUTSTATUS_PagesetInitCalculate, - XFA_DOCVIEW_LAYOUTSTATUS_PagesetInitValidate, - XFA_DOCVIEW_LAYOUTSTATUS_PagesetFormReady, - XFA_DOCVIEW_LAYOUTSTATUS_LayoutReady, - XFA_DOCVIEW_LAYOUTSTATUS_DocReady, - XFA_DOCVIEW_LAYOUTSTATUS_End -}; -class CXFA_FFDocView { - public: - explicit CXFA_FFDocView(CXFA_FFDoc* pDoc); - ~CXFA_FFDocView(); - - CXFA_FFDoc* GetDoc() { return m_pDoc; } - int32_t StartLayout(int32_t iStartPage = 0); - int32_t DoLayout(IFX_Pause* pPause); - void StopLayout(); - int32_t GetLayoutStatus(); - void UpdateDocView(); - int32_t CountPageViews(); - CXFA_FFPageView* GetPageView(int32_t nIndex); - - void ResetWidgetData(CXFA_WidgetAcc* pWidgetAcc); - int32_t ProcessWidgetEvent(CXFA_EventParam* pParam, - CXFA_WidgetAcc* pWidgetAcc); - CXFA_FFWidgetHandler* GetWidgetHandler(); - CXFA_WidgetAccIterator* CreateWidgetAccIterator( - XFA_WIDGETORDER eOrder = XFA_WIDGETORDER_PreOrder); - CXFA_FFWidget* GetFocusWidget(); - void KillFocus(); - bool SetFocus(CXFA_FFWidget* hWidget); - CXFA_FFWidget* GetWidgetByName(const CFX_WideString& wsName, - CXFA_FFWidget* pRefWidget); - CXFA_WidgetAcc* GetWidgetAccByName(const CFX_WideString& wsName, - CXFA_WidgetAcc* pRefWidgetAcc); - CXFA_LayoutProcessor* GetXFALayout() const; - void OnPageEvent(CXFA_ContainerLayoutItem* pSender, uint32_t dwEvent); - void LockUpdate(); - void UnlockUpdate(); - bool IsUpdateLocked(); - void ClearInvalidateList(); - void AddInvalidateRect(CXFA_FFWidget* pWidget, const CFX_RectF& rtInvalidate); - void AddInvalidateRect(CXFA_FFPageView* pPageView, - const CFX_RectF& rtInvalidate); - void RunInvalidate(); - void RunDocClose(); - void DestroyDocView(); - - bool InitValidate(CXFA_Node* pNode); - bool RunValidate(); - - void SetChangeMark(); - - void AddValidateWidget(CXFA_WidgetAcc* pWidget); - void AddCalculateNodeNotify(CXFA_Node* pNodeChange); - void AddCalculateWidgetAcc(CXFA_WidgetAcc* pWidgetAcc); - int32_t RunCalculateWidgets(); - bool IsStaticNotify(); - bool RunLayout(); - void RunSubformIndexChange(); - void AddNewFormNode(CXFA_Node* pNode); - void AddIndexChangedSubform(CXFA_Node* pNode); - CXFA_WidgetAcc* GetFocusWidgetAcc(); - void SetFocusWidgetAcc(CXFA_WidgetAcc* pWidgetAcc); - void DeleteLayoutItem(CXFA_FFWidget* pWidget); - int32_t ExecEventActivityByDeepFirst(CXFA_Node* pFormNode, - XFA_EVENTTYPE eEventType, - bool bIsFormReady, - bool bRecursive, - CXFA_Node* pExclude); - bool m_bLayoutEvent; - std::vector m_arrNullTestMsg; - CXFA_FFWidget* m_pListFocusWidget; - bool m_bInLayoutStatus; - - protected: - bool RunEventLayoutReady(); - void RunBindItems(); - bool InitCalculate(CXFA_Node* pNode); - void InitLayout(CXFA_Node* pNode); - void RunCalculateRecursive(int32_t& iIndex); - void ShowNullTestMsg(); - bool ResetSingleWidgetAccData(CXFA_WidgetAcc* pWidgetAcc); - CXFA_Node* GetRootSubform(); - - CXFA_FFDoc* const m_pDoc; - std::unique_ptr m_pWidgetHandler; - CXFA_LayoutProcessor* m_pXFADocLayout; // not owned. - CXFA_WidgetAcc* m_pFocusAcc; // not owned. - CXFA_FFWidget* m_pFocusWidget; // not owned. - CXFA_FFWidget* m_pOldFocusWidget; // not owned. - std::map> m_mapPageInvalidate; - std::vector m_ValidateAccs; - std::vector m_CalculateAccs; - std::vector m_BindItems; - std::vector m_NewAddedNodes; - std::vector m_IndexChangedSubforms; - XFA_DOCVIEW_LAYOUTSTATUS m_iStatus; - int32_t m_iLock; - friend class CXFA_FFNotify; -}; - -class CXFA_WidgetAccIterator { - public: - CXFA_WidgetAccIterator(CXFA_FFDocView* pDocView, CXFA_Node* pTravelRoot); - ~CXFA_WidgetAccIterator(); - - void Reset(); - CXFA_WidgetAcc* MoveToFirst(); - CXFA_WidgetAcc* MoveToLast(); - CXFA_WidgetAcc* MoveToNext(); - CXFA_WidgetAcc* MoveToPrevious(); - CXFA_WidgetAcc* GetCurrentWidgetAcc(); - bool SetCurrentWidgetAcc(CXFA_WidgetAcc* hWidget); - void SkipTree(); - - protected: - CXFA_ContainerIterator m_ContentIterator; - CXFA_FFDocView* const m_pDocView; - CXFA_WidgetAcc* m_pCurWidgetAcc; // not owned. -}; - -#endif // XFA_FXFA_XFA_FFDOCVIEW_H_ diff --git a/xfa/fxfa/xfa_ffpageview.h b/xfa/fxfa/xfa_ffpageview.h deleted file mode 100644 index 4b50a2365d..0000000000 --- a/xfa/fxfa/xfa_ffpageview.h +++ /dev/null @@ -1,107 +0,0 @@ -// Copyrig 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_XFA_FFPAGEVIEW_H_ -#define XFA_FXFA_XFA_FFPAGEVIEW_H_ - -#include - -#include "xfa/fxfa/parser/cxfa_containerlayoutitem.h" -#include "xfa/fxfa/parser/cxfa_contentlayoutitem.h" -#include "xfa/fxfa/parser/cxfa_traversestrategy_layoutitem.h" - -class CXFA_FFWidget; -class CXFA_FFDocView; - -class CXFA_FFPageView : public CXFA_ContainerLayoutItem { - public: - CXFA_FFPageView(CXFA_FFDocView* pDocView, CXFA_Node* pPageArea); - ~CXFA_FFPageView() override; - - CXFA_FFDocView* GetDocView() const; - CFX_RectF GetPageViewRect() const; - CFX_Matrix GetDisplayMatrix(const CFX_Rect& rtDisp, int32_t iRotate) const; - IXFA_WidgetIterator* CreateWidgetIterator( - uint32_t dwTraverseWay = XFA_TRAVERSEWAY_Form, - uint32_t dwWidgetFilter = XFA_WidgetStatus_Visible | - XFA_WidgetStatus_Viewable); - - protected: - CXFA_FFDocView* const m_pDocView; -}; - -typedef CXFA_NodeIteratorTemplate - CXFA_LayoutItemIterator; - -class CXFA_FFPageWidgetIterator : public IXFA_WidgetIterator { - public: - CXFA_FFPageWidgetIterator(CXFA_FFPageView* pPageView, uint32_t dwFilter); - ~CXFA_FFPageWidgetIterator() override; - - void Reset() override; - CXFA_FFWidget* MoveToFirst() override; - CXFA_FFWidget* MoveToLast() override; - CXFA_FFWidget* MoveToNext() override; - CXFA_FFWidget* MoveToPrevious() override; - CXFA_FFWidget* GetCurrentWidget() override; - bool SetCurrentWidget(CXFA_FFWidget* hWidget) override; - - protected: - CXFA_FFWidget* GetWidget(CXFA_LayoutItem* pLayoutItem); - - CXFA_FFPageView* m_pPageView; - CXFA_FFWidget* m_hCurWidget; - uint32_t m_dwFilter; - bool m_bIgnorerelevant; - CXFA_LayoutItemIterator m_sIterator; -}; - -class CXFA_TabParam { - public: - CXFA_TabParam(); - ~CXFA_TabParam(); - - CXFA_FFWidget* m_pWidget; - std::vector m_Children; -}; - -class CXFA_FFTabOrderPageWidgetIterator : public IXFA_WidgetIterator { - public: - CXFA_FFTabOrderPageWidgetIterator(CXFA_FFPageView* pPageView, - uint32_t dwFilter); - ~CXFA_FFTabOrderPageWidgetIterator() override; - - void Reset() override; - CXFA_FFWidget* MoveToFirst() override; - CXFA_FFWidget* MoveToLast() override; - CXFA_FFWidget* MoveToNext() override; - CXFA_FFWidget* MoveToPrevious() override; - CXFA_FFWidget* GetCurrentWidget() override; - bool SetCurrentWidget(CXFA_FFWidget* hWidget) override; - - protected: - CXFA_FFWidget* GetTraverseWidget(CXFA_FFWidget* pWidget); - CXFA_FFWidget* FindWidgetByName(const CFX_WideString& wsWidgetName, - CXFA_FFWidget* pRefWidget); - void CreateTabOrderWidgetArray(); - void CreateSpaceOrderWidgetArray(std::vector* WidgetArray); - CXFA_FFWidget* GetWidget(CXFA_LayoutItem* pLayoutItem); - void OrderContainer(CXFA_LayoutItemIterator* sIterator, - CXFA_LayoutItem* pContainerItem, - CXFA_TabParam* pContainer, - bool& bCurrentItem, - bool& bContentArea, - bool bMarsterPage = false); - - std::vector m_TabOrderWidgetArray; - CXFA_FFPageView* m_pPageView; - uint32_t m_dwFilter; - int32_t m_iCurWidget; - bool m_bIgnorerelevant; -}; - -#endif // XFA_FXFA_XFA_FFPAGEVIEW_H_ diff --git a/xfa/fxfa/xfa_ffwidget.h b/xfa/fxfa/xfa_ffwidget.h deleted file mode 100644 index 7b923506ff..0000000000 --- a/xfa/fxfa/xfa_ffwidget.h +++ /dev/null @@ -1,190 +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_XFA_FFWIDGET_H_ -#define XFA_FXFA_XFA_FFWIDGET_H_ - -#include - -#include "core/fxcodec/fx_codec_def.h" -#include "core/fxge/cfx_graphstatedata.h" -#include "xfa/fwl/cfwl_app.h" -#include "xfa/fxfa/fxfa.h" -#include "xfa/fxfa/parser/cxfa_contentlayoutitem.h" - -class CXFA_FFPageView; -class CXFA_FFDocView; -class CXFA_FFDoc; -class CXFA_FFApp; -enum class FWL_WidgetHit; - -inline float XFA_UnitPx2Pt(float fPx, float fDpi) { - return fPx * 72.0f / fDpi; -} - -#define XFA_FLOAT_PERCISION 0.001f - -enum XFA_WIDGETITEM { - XFA_WIDGETITEM_Parent, - XFA_WIDGETITEM_FirstChild, - XFA_WIDGETITEM_NextSibling, - XFA_WIDGETITEM_PrevSibling, -}; - -class CXFA_CalcData { - public: - CXFA_CalcData(); - ~CXFA_CalcData(); - - std::vector m_Globals; - int32_t m_iRefCount; -}; - -class CXFA_FFWidget : public CXFA_ContentLayoutItem { - public: - explicit CXFA_FFWidget(CXFA_WidgetAcc* pDataAcc); - ~CXFA_FFWidget() override; - - virtual CFX_RectF GetBBox(uint32_t dwStatus, bool bDrawFocus = false); - virtual void RenderWidget(CFX_Graphics* pGS, - CFX_Matrix* pMatrix, - uint32_t dwStatus); - virtual bool IsLoaded(); - virtual bool LoadWidget(); - virtual void UnloadWidget(); - virtual bool PerformLayout(); - virtual bool UpdateFWLData(); - virtual void UpdateWidgetProperty(); - virtual bool OnMouseEnter(); - virtual bool OnMouseExit(); - virtual bool OnLButtonDown(uint32_t dwFlags, const CFX_PointF& point); - virtual bool OnLButtonUp(uint32_t dwFlags, const CFX_PointF& point); - virtual bool OnLButtonDblClk(uint32_t dwFlags, const CFX_PointF& point); - virtual bool OnMouseMove(uint32_t dwFlags, const CFX_PointF& point); - virtual bool OnMouseWheel(uint32_t dwFlags, - int16_t zDelta, - const CFX_PointF& point); - virtual bool OnRButtonDown(uint32_t dwFlags, const CFX_PointF& point); - virtual bool OnRButtonUp(uint32_t dwFlags, const CFX_PointF& point); - virtual bool OnRButtonDblClk(uint32_t dwFlags, const CFX_PointF& point); - - virtual bool OnSetFocus(CXFA_FFWidget* pOldWidget); - virtual bool OnKillFocus(CXFA_FFWidget* pNewWidget); - virtual bool OnKeyDown(uint32_t dwKeyCode, uint32_t dwFlags); - virtual bool OnKeyUp(uint32_t dwKeyCode, uint32_t dwFlags); - virtual bool OnChar(uint32_t dwChar, uint32_t dwFlags); - virtual FWL_WidgetHit OnHitTest(const CFX_PointF& point); - virtual bool OnSetCursor(const CFX_PointF& point); - virtual bool CanUndo(); - virtual bool CanRedo(); - virtual bool Undo(); - virtual bool Redo(); - virtual bool CanCopy(); - virtual bool CanCut(); - virtual bool CanPaste(); - virtual bool CanSelectAll(); - virtual bool CanDelete(); - virtual bool CanDeSelect(); - virtual bool Copy(CFX_WideString& wsCopy); - virtual bool Cut(CFX_WideString& wsCut); - virtual bool Paste(const CFX_WideString& wsPaste); - virtual void SelectAll(); - virtual void Delete(); - virtual void DeSelect(); - virtual bool GetSuggestWords(CFX_PointF pointf, - std::vector& sSuggest); - virtual bool ReplaceSpellCheckWord(CFX_PointF pointf, - const CFX_ByteStringC& bsReplace); - - CXFA_FFPageView* GetPageView() const { return m_pPageView; } - void SetPageView(CXFA_FFPageView* pPageView) { m_pPageView = pPageView; } - CFX_RectF GetWidgetRect(); - CFX_RectF RecacheWidgetRect(); - uint32_t GetStatus(); - void ModifyStatus(uint32_t dwAdded, uint32_t dwRemoved); - - CXFA_WidgetAcc* GetDataAcc(); - bool GetToolTip(CFX_WideString& wsToolTip); - - CXFA_FFDocView* GetDocView(); - void SetDocView(CXFA_FFDocView* pDocView); - CXFA_FFDoc* GetDoc(); - CXFA_FFApp* GetApp(); - IXFA_AppProvider* GetAppProvider(); - void InvalidateWidget(const CFX_RectF* pRect = nullptr); - void AddInvalidateRect(const CFX_RectF* pRect = nullptr); - bool GetCaptionText(CFX_WideString& wsCap); - bool IsFocused(); - CFX_PointF Rotate2Normal(const CFX_PointF& point); - CFX_Matrix GetRotateMatrix(); - bool IsLayoutRectEmpty(); - CXFA_FFWidget* GetParent(); - bool IsAncestorOf(CXFA_FFWidget* pWidget); - const CFWL_App* GetFWLApp(); - - protected: - virtual bool PtInActiveRect(const CFX_PointF& point); - - void DrawBorder(CFX_Graphics* pGS, - CXFA_Box box, - const CFX_RectF& rtBorder, - CFX_Matrix* pMatrix, - uint32_t dwFlags = 0); - - CFX_RectF GetRectWithoutRotate(); - bool IsMatchVisibleStatus(uint32_t dwStatus); - void EventKillFocus(); - bool IsButtonDown(); - void SetButtonDown(bool bSet); - - CXFA_FFDocView* m_pDocView; - CXFA_FFPageView* m_pPageView; - CXFA_WidgetAcc* m_pDataAcc; - CFX_RectF m_rtWidget; -}; - -int32_t XFA_StrokeTypeSetLineDash(CFX_Graphics* pGraphics, - int32_t iStrokeType, - int32_t iCapType); -CFX_GraphStateData::LineCap XFA_LineCapToFXGE(int32_t iLineCap); -void XFA_DrawImage(CFX_Graphics* pGS, - const CFX_RectF& rtImage, - CFX_Matrix* pMatrix, - CFX_DIBitmap* pDIBitmap, - int32_t iAspect, - int32_t iImageXDpi, - int32_t iImageYDpi, - int32_t iHorzAlign = XFA_ATTRIBUTEENUM_Left, - int32_t iVertAlign = XFA_ATTRIBUTEENUM_Top); - -CFX_DIBitmap* XFA_LoadImageData(CXFA_FFDoc* pDoc, - CXFA_Image* pImage, - bool& bNameImage, - int32_t& iImageXDpi, - int32_t& iImageYDpi); - -CFX_DIBitmap* XFA_LoadImageFromBuffer( - const CFX_RetainPtr& pImageFileRead, - FXCODEC_IMAGE_TYPE type, - int32_t& iImageXDpi, - int32_t& iImageYDpi); - -FXCODEC_IMAGE_TYPE XFA_GetImageType(const CFX_WideString& wsType); -char* XFA_Base64Encode(const uint8_t* buf, int32_t buf_len); -void XFA_RectWidthoutMargin(CFX_RectF& rt, - const CXFA_Margin& mg, - bool bUI = false); -CXFA_FFWidget* XFA_GetWidgetFromLayoutItem(CXFA_LayoutItem* pLayoutItem); -bool XFA_IsCreateWidget(XFA_Element iType); -#define XFA_DRAWBOX_ForceRound 1 -#define XFA_DRAWBOX_Lowered3D 2 -void XFA_DrawBox(CXFA_Box box, - CFX_Graphics* pGS, - const CFX_RectF& rtWidget, - CFX_Matrix* pMatrix, - uint32_t dwFlags = 0); - -#endif // XFA_FXFA_XFA_FFWIDGET_H_ diff --git a/xfa/fxfa/xfa_ffwidgethandler.h b/xfa/fxfa/xfa_ffwidgethandler.h deleted file mode 100644 index 01bdd66786..0000000000 --- a/xfa/fxfa/xfa_ffwidgethandler.h +++ /dev/null @@ -1,119 +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_XFA_FFWIDGETHANDLER_H_ -#define XFA_FXFA_XFA_FFWIDGETHANDLER_H_ - -#include - -#include "xfa/fxfa/cxfa_eventparam.h" -#include "xfa/fxfa/fxfa.h" -#include "xfa/fxfa/parser/cxfa_document.h" - -class CXFA_FFDocView; -enum class FWL_WidgetHit; - -class CXFA_FFWidgetHandler { - public: - explicit CXFA_FFWidgetHandler(CXFA_FFDocView* pDocView); - ~CXFA_FFWidgetHandler(); - - CXFA_FFWidget* CreateWidget(CXFA_FFWidget* hParent, - XFA_WIDGETTYPE eType, - CXFA_FFWidget* hBefore = nullptr); - - bool OnMouseEnter(CXFA_FFWidget* hWidget); - bool OnMouseExit(CXFA_FFWidget* hWidget); - bool OnLButtonDown(CXFA_FFWidget* hWidget, - uint32_t dwFlags, - const CFX_PointF& point); - bool OnLButtonUp(CXFA_FFWidget* hWidget, - uint32_t dwFlags, - const CFX_PointF& point); - bool OnLButtonDblClk(CXFA_FFWidget* hWidget, - uint32_t dwFlags, - const CFX_PointF& point); - bool OnMouseMove(CXFA_FFWidget* hWidget, - uint32_t dwFlags, - const CFX_PointF& point); - bool OnMouseWheel(CXFA_FFWidget* hWidget, - uint32_t dwFlags, - int16_t zDelta, - const CFX_PointF& point); - bool OnRButtonDown(CXFA_FFWidget* hWidget, - uint32_t dwFlags, - const CFX_PointF& point); - bool OnRButtonUp(CXFA_FFWidget* hWidget, - uint32_t dwFlags, - const CFX_PointF& point); - bool OnRButtonDblClk(CXFA_FFWidget* hWidget, - uint32_t dwFlags, - const CFX_PointF& point); - - bool OnKeyDown(CXFA_FFWidget* hWidget, uint32_t dwKeyCode, uint32_t dwFlags); - bool OnKeyUp(CXFA_FFWidget* hWidget, uint32_t dwKeyCode, uint32_t dwFlags); - bool OnChar(CXFA_FFWidget* hWidget, uint32_t dwChar, uint32_t dwFlags); - FWL_WidgetHit OnHitTest(CXFA_FFWidget* hWidget, const CFX_PointF& point); - bool OnSetCursor(CXFA_FFWidget* hWidget, const CFX_PointF& point); - void RenderWidget(CXFA_FFWidget* hWidget, - CFX_Graphics* pGS, - CFX_Matrix* pMatrix, - bool bHighlight); - bool HasEvent(CXFA_WidgetAcc* pWidgetAcc, XFA_EVENTTYPE eEventType); - int32_t ProcessEvent(CXFA_WidgetAcc* pWidgetAcc, CXFA_EventParam* pParam); - - protected: - CXFA_Node* CreateWidgetFormItem(XFA_WIDGETTYPE eType, - CXFA_Node* pParent, - CXFA_Node* pBefore) const; - - CXFA_Node* CreatePushButton(CXFA_Node* pParent, CXFA_Node* pBefore) const; - CXFA_Node* CreateCheckButton(CXFA_Node* pParent, CXFA_Node* pBefore) const; - CXFA_Node* CreateExclGroup(CXFA_Node* pParent, CXFA_Node* pBefore) const; - CXFA_Node* CreateRadioButton(CXFA_Node* pParent, CXFA_Node* pBefore) const; - CXFA_Node* CreateDatetimeEdit(CXFA_Node* pParent, CXFA_Node* pBefore) const; - CXFA_Node* CreateDecimalField(CXFA_Node* pParent, CXFA_Node* pBefore) const; - CXFA_Node* CreateNumericField(CXFA_Node* pParent, CXFA_Node* pBefore) const; - CXFA_Node* CreateSignature(CXFA_Node* pParent, CXFA_Node* pBefore) const; - CXFA_Node* CreateTextEdit(CXFA_Node* pParent, CXFA_Node* pBefore) const; - CXFA_Node* CreateDropdownList(CXFA_Node* pParent, CXFA_Node* pBefore) const; - CXFA_Node* CreateListBox(CXFA_Node* pParent, CXFA_Node* pBefore) const; - CXFA_Node* CreateImageField(CXFA_Node* pParent, CXFA_Node* pBefore) const; - CXFA_Node* CreatePasswordEdit(CXFA_Node* pParent, CXFA_Node* pBefore) const; - CXFA_Node* CreateField(XFA_Element eElement, - CXFA_Node* pParent, - CXFA_Node* pBefore) const; - CXFA_Node* CreateArc(CXFA_Node* pParent, CXFA_Node* pBefore) const; - CXFA_Node* CreateRectangle(CXFA_Node* pParent, CXFA_Node* pBefore) const; - CXFA_Node* CreateImage(CXFA_Node* pParent, CXFA_Node* pBefore) const; - CXFA_Node* CreateLine(CXFA_Node* pParent, CXFA_Node* pBefore) const; - CXFA_Node* CreateText(CXFA_Node* pParent, CXFA_Node* pBefore) const; - CXFA_Node* CreateDraw(XFA_Element eElement, - CXFA_Node* pParent, - CXFA_Node* pBefore) const; - - CXFA_Node* CreateSubform(CXFA_Node* pParent, CXFA_Node* pBefore) const; - CXFA_Node* CreateFormItem(XFA_Element eElement, - CXFA_Node* pParent, - CXFA_Node* pBefore) const; - CXFA_Node* CreateCopyNode(XFA_Element eElement, - CXFA_Node* pParent, - CXFA_Node* pBefore = nullptr) const; - CXFA_Node* CreateTemplateNode(XFA_Element eElement, - CXFA_Node* pParent, - CXFA_Node* pBefore) const; - CXFA_Node* CreateFontNode(CXFA_Node* pParent) const; - CXFA_Node* CreateMarginNode(CXFA_Node* pParent, - uint32_t dwFlags, - float fInsets[4]) const; - CXFA_Node* CreateValueNode(XFA_Element eValue, CXFA_Node* pParent) const; - CXFA_Document* GetObjFactory() const; - CXFA_Document* GetXFADoc() const; - - CXFA_FFDocView* m_pDocView; -}; - -#endif // XFA_FXFA_XFA_FFWIDGETHANDLER_H_ diff --git a/xfa/fxfa/xfa_fontmgr.h b/xfa/fxfa/xfa_fontmgr.h deleted file mode 100644 index b3ed8ab236..0000000000 --- a/xfa/fxfa/xfa_fontmgr.h +++ /dev/null @@ -1,103 +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_XFA_FONTMGR_H_ -#define XFA_FXFA_XFA_FONTMGR_H_ - -#include -#include -#include - -#include "core/fxcrt/cfx_retain_ptr.h" -#include "core/fxcrt/fx_ext.h" -#include "core/fxcrt/fx_system.h" -#include "xfa/fgas/font/cfgas_fontmgr.h" -#include "xfa/fxfa/fxfa.h" - -class CPDF_Font; - -struct XFA_FONTINFO { - uint32_t dwFontNameHash; - const wchar_t* pPsName; - const wchar_t* pReplaceFont; - uint16_t dwStyles; - uint16_t wCodePage; -}; - -class CXFA_DefFontMgr { - public: - CXFA_DefFontMgr(); - ~CXFA_DefFontMgr(); - - CFX_RetainPtr GetFont(CXFA_FFDoc* hDoc, - const CFX_WideStringC& wsFontFamily, - uint32_t dwFontStyles, - uint16_t wCodePage = 0xFFFF); - CFX_RetainPtr GetDefaultFont( - CXFA_FFDoc* hDoc, - const CFX_WideStringC& wsFontFamily, - uint32_t dwFontStyles, - uint16_t wCodePage = 0xFFFF); - - protected: - std::vector> m_CacheFonts; -}; - -class CXFA_PDFFontMgr { - public: - explicit CXFA_PDFFontMgr(CXFA_FFDoc* pDoc); - ~CXFA_PDFFontMgr(); - - CFX_RetainPtr GetFont(const CFX_WideStringC& wsFontFamily, - uint32_t dwFontStyles, - CPDF_Font** pPDFFont, - bool bStrictMatch); - bool GetCharWidth(const CFX_RetainPtr& pFont, - wchar_t wUnicode, - bool bCharCode, - int32_t* pWidth); - void SetFont(const CFX_RetainPtr& pFont, CPDF_Font* pPDFFont); - - protected: - CFX_RetainPtr FindFont(const CFX_ByteString& strFamilyName, - bool bBold, - bool bItalic, - CPDF_Font** pPDFFont, - bool bStrictMatch); - CFX_ByteString PsNameToFontName(const CFX_ByteString& strPsName, - bool bBold, - bool bItalic); - bool PsNameMatchDRFontName(const CFX_ByteStringC& bsPsName, - bool bBold, - bool bItalic, - const CFX_ByteString& bsDRFontName, - bool bStrictMatch); - - CXFA_FFDoc* const m_pDoc; - std::map, CPDF_Font*> m_FDE2PDFFont; - std::map> m_FontMap; -}; - -class CXFA_FontMgr { - public: - CXFA_FontMgr(); - ~CXFA_FontMgr(); - - CFX_RetainPtr GetFont(CXFA_FFDoc* hDoc, - const CFX_WideStringC& wsFontFamily, - uint32_t dwFontStyles, - uint16_t wCodePage = 0xFFFF); - void LoadDocFonts(CXFA_FFDoc* hDoc); - void ReleaseDocFonts(CXFA_FFDoc* hDoc); - void SetDefFontMgr(std::unique_ptr pFontMgr); - - protected: - std::unique_ptr m_pDefFontMgr; - std::map> m_PDFFontMgrMap; - std::map> m_FontMap; -}; - -#endif // XFA_FXFA_XFA_FONTMGR_H_ diff --git a/xfa/fxfa/xfa_rendercontext.h b/xfa/fxfa/xfa_rendercontext.h deleted file mode 100644 index c424005b1e..0000000000 --- a/xfa/fxfa/xfa_rendercontext.h +++ /dev/null @@ -1,45 +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_XFA_RENDERCONTEXT_H_ -#define XFA_FXFA_XFA_RENDERCONTEXT_H_ - -#include - -#include "xfa/fxfa/fxfa.h" - -class CXFA_RenderOptions { - public: - CXFA_RenderOptions() : m_bPrint(false), m_bHighlight(true) {} - - bool m_bPrint; - bool m_bHighlight; -}; - -class CXFA_RenderContext { - public: - CXFA_RenderContext(); - ~CXFA_RenderContext(); - - int32_t StartRender(CXFA_FFPageView* pPageView, - CFX_Graphics* pGS, - const CFX_Matrix& matrix, - const CXFA_RenderOptions& options); - int32_t DoRender(IFX_Pause* pPause = nullptr); - void StopRender(); - - protected: - std::unique_ptr m_pWidgetIterator; - CXFA_FFWidget* m_pWidget; - CXFA_FFPageView* m_pPageView; - CFX_Graphics* m_pGS; - CFX_Matrix m_matrix; - CXFA_RenderOptions m_options; - uint32_t m_dwStatus; - CFX_RectF m_rtClipRect; -}; - -#endif // XFA_FXFA_XFA_RENDERCONTEXT_H_ -- cgit v1.2.3