From 2eddb665763f3e089d4c210d2a011d112683f3ea Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Thu, 25 May 2017 16:49:51 -0400 Subject: Split apart remaining xfa/fxfa/app files This CL splits the remaining files in xfa/fxfa/app into individual files named after the classes. Change-Id: I84bd8938937641bb6897614ed15558a2682f456c Reviewed-on: https://pdfium-review.googlesource.com/6010 Reviewed-by: Tom Sepez Commit-Queue: dsinclair --- BUILD.gn | 90 +-- xfa/fwl/cfwl_app.cpp | 2 +- xfa/fwl/cfwl_widgetmgr.cpp | 2 +- xfa/fwl/theme/cfwl_edittp.cpp | 2 +- xfa/fxfa/app/cxfa_ffarc.cpp | 33 + xfa/fxfa/app/cxfa_ffarc.h | 23 + xfa/fxfa/app/cxfa_ffbarcode.cpp | 226 +++++++ xfa/fxfa/app/cxfa_ffbarcode.h | 103 +++ xfa/fxfa/app/cxfa_ffbarcode_unittest.cpp | 25 + xfa/fxfa/app/cxfa_ffcheckbutton.cpp | 345 ++++++++++ xfa/fxfa/app/cxfa_ffcheckbutton.h | 46 ++ xfa/fxfa/app/cxfa_ffcombobox.cpp | 360 +++++++++++ xfa/fxfa/app/cxfa_ffcombobox.h | 69 ++ xfa/fxfa/app/cxfa_ffdatetimeedit.cpp | 213 ++++++ xfa/fxfa/app/cxfa_ffdatetimeedit.h | 47 ++ xfa/fxfa/app/cxfa_ffdraw.cpp | 16 + xfa/fxfa/app/cxfa_ffdraw.h | 19 + xfa/fxfa/app/cxfa_ffexclgroup.cpp | 30 + xfa/fxfa/app/cxfa_ffexclgroup.h | 24 + xfa/fxfa/app/cxfa_fffield.cpp | 785 +++++++++++++++++++++++ xfa/fxfa/app/cxfa_fffield.h | 99 +++ xfa/fxfa/app/cxfa_ffimage.cpp | 72 +++ xfa/fxfa/app/cxfa_ffimage.h | 26 + xfa/fxfa/app/cxfa_ffimageedit.cpp | 143 +++++ xfa/fxfa/app/cxfa_ffimageedit.h | 37 ++ xfa/fxfa/app/cxfa_ffline.cpp | 99 +++ xfa/fxfa/app/cxfa_ffline.h | 26 + xfa/fxfa/app/cxfa_fflistbox.cpp | 210 ++++++ xfa/fxfa/app/cxfa_fflistbox.h | 40 ++ xfa/fxfa/app/cxfa_ffnotify.cpp | 540 ++++++++++++++++ xfa/fxfa/app/cxfa_ffnotify.h | 77 +++ xfa/fxfa/app/cxfa_ffnumericedit.cpp | 97 +++ xfa/fxfa/app/cxfa_ffnumericedit.h | 31 + xfa/fxfa/app/cxfa_ffpasswordedit.cpp | 64 ++ xfa/fxfa/app/cxfa_ffpasswordedit.h | 24 + xfa/fxfa/app/cxfa_ffpushbutton.cpp | 240 +++++++ xfa/fxfa/app/cxfa_ffpushbutton.h | 54 ++ xfa/fxfa/app/cxfa_ffrectangle.cpp | 34 + xfa/fxfa/app/cxfa_ffrectangle.h | 23 + xfa/fxfa/app/cxfa_ffsignature.cpp | 114 ++++ xfa/fxfa/app/cxfa_ffsignature.h | 42 ++ xfa/fxfa/app/cxfa_ffsubform.cpp | 17 + xfa/fxfa/app/cxfa_ffsubform.h | 19 + xfa/fxfa/app/cxfa_fftext.cpp | 163 +++++ xfa/fxfa/app/cxfa_fftext.h | 32 + xfa/fxfa/app/cxfa_fftextedit.cpp | 364 +++++++++++ xfa/fxfa/app/cxfa_fftextedit.h | 57 ++ xfa/fxfa/app/cxfa_fwladapterwidgetmgr.cpp | 38 ++ xfa/fxfa/app/cxfa_fwladapterwidgetmgr.h | 28 + xfa/fxfa/app/cxfa_fwltheme.cpp | 284 ++++++++ xfa/fxfa/app/cxfa_fwltheme.h | 70 ++ xfa/fxfa/app/cxfa_pieceline.cpp | 2 +- xfa/fxfa/app/cxfa_pieceline.h | 4 +- xfa/fxfa/app/cxfa_textlayout.cpp | 20 +- xfa/fxfa/app/cxfa_textlayout.h | 6 +- xfa/fxfa/app/cxfa_textparser.cpp | 2 +- xfa/fxfa/app/cxfa_textpiece.cpp | 13 + xfa/fxfa/app/cxfa_textpiece.h | 41 ++ xfa/fxfa/app/cxfa_textprovider.cpp | 166 +++++ xfa/fxfa/app/cxfa_textprovider.h | 50 ++ xfa/fxfa/app/xfa_ffbarcode.cpp | 227 ------- xfa/fxfa/app/xfa_ffbarcode.h | 103 --- xfa/fxfa/app/xfa_ffbarcode_unittest.cpp | 25 - xfa/fxfa/app/xfa_ffcheckbutton.cpp | 345 ---------- xfa/fxfa/app/xfa_ffcheckbutton.h | 46 -- xfa/fxfa/app/xfa_ffchoicelist.cpp | 562 ---------------- xfa/fxfa/app/xfa_ffchoicelist.h | 100 --- xfa/fxfa/app/xfa_ffdraw.cpp | 16 - xfa/fxfa/app/xfa_ffdraw.h | 19 - xfa/fxfa/app/xfa_ffexclgroup.cpp | 30 - xfa/fxfa/app/xfa_ffexclgroup.h | 24 - xfa/fxfa/app/xfa_fffield.cpp | 785 ----------------------- xfa/fxfa/app/xfa_fffield.h | 99 --- xfa/fxfa/app/xfa_ffimage.cpp | 72 --- xfa/fxfa/app/xfa_ffimage.h | 26 - xfa/fxfa/app/xfa_ffimageedit.cpp | 143 ----- xfa/fxfa/app/xfa_ffimageedit.h | 37 -- xfa/fxfa/app/xfa_ffnotify.cpp | 535 --------------- xfa/fxfa/app/xfa_ffnotify.h | 77 --- xfa/fxfa/app/xfa_ffpath.cpp | 156 ----- xfa/fxfa/app/xfa_ffpath.h | 48 -- xfa/fxfa/app/xfa_ffpushbutton.cpp | 240 ------- xfa/fxfa/app/xfa_ffpushbutton.h | 54 -- xfa/fxfa/app/xfa_ffsignature.cpp | 114 ---- xfa/fxfa/app/xfa_ffsignature.h | 42 -- xfa/fxfa/app/xfa_ffsubform.cpp | 17 - xfa/fxfa/app/xfa_ffsubform.h | 19 - xfa/fxfa/app/xfa_fftext.cpp | 163 ----- xfa/fxfa/app/xfa_fftext.h | 32 - xfa/fxfa/app/xfa_fftextedit.cpp | 706 -------------------- xfa/fxfa/app/xfa_fftextedit.h | 105 --- xfa/fxfa/app/xfa_ffwidgetacc.cpp | 167 ----- xfa/fxfa/app/xfa_ffwidgetacc.h | 50 -- xfa/fxfa/app/xfa_fwladapter.cpp | 38 -- xfa/fxfa/app/xfa_fwladapter.h | 28 - xfa/fxfa/app/xfa_fwltheme.cpp | 284 -------- xfa/fxfa/app/xfa_fwltheme.h | 70 -- xfa/fxfa/app/xfa_textpiece.cpp | 13 - xfa/fxfa/app/xfa_textpiece.h | 41 -- xfa/fxfa/cxfa_ffapp.cpp | 4 +- xfa/fxfa/cxfa_ffdoc.cpp | 2 +- xfa/fxfa/cxfa_ffdocview.cpp | 29 +- xfa/fxfa/cxfa_ffpageview.cpp | 12 +- xfa/fxfa/cxfa_ffwidgethandler.cpp | 5 +- xfa/fxfa/cxfa_widgetacc.cpp | 2 +- xfa/fxfa/fm2js/cxfa_fm2jscontext.cpp | 2 +- xfa/fxfa/parser/cscript_eventpseudomodel.cpp | 2 +- xfa/fxfa/parser/cscript_hostpseudomodel.cpp | 2 +- xfa/fxfa/parser/cscript_layoutpseudomodel.cpp | 2 +- xfa/fxfa/parser/cscript_signaturepseudomodel.cpp | 2 +- xfa/fxfa/parser/cxfa_document.cpp | 2 +- xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp | 2 +- xfa/fxfa/parser/cxfa_layoutitem.cpp | 2 +- xfa/fxfa/parser/cxfa_layoutpagemgr.cpp | 2 +- xfa/fxfa/parser/cxfa_node.cpp | 2 +- xfa/fxfa/parser/cxfa_object.cpp | 2 +- xfa/fxfa/parser/cxfa_scriptcontext.cpp | 2 +- xfa/fxfa/parser/cxfa_widgetdata.cpp | 2 +- 118 files changed, 5906 insertions(+), 5760 deletions(-) create mode 100644 xfa/fxfa/app/cxfa_ffarc.cpp create mode 100644 xfa/fxfa/app/cxfa_ffarc.h create mode 100644 xfa/fxfa/app/cxfa_ffbarcode.cpp create mode 100644 xfa/fxfa/app/cxfa_ffbarcode.h create mode 100644 xfa/fxfa/app/cxfa_ffbarcode_unittest.cpp create mode 100644 xfa/fxfa/app/cxfa_ffcheckbutton.cpp create mode 100644 xfa/fxfa/app/cxfa_ffcheckbutton.h create mode 100644 xfa/fxfa/app/cxfa_ffcombobox.cpp create mode 100644 xfa/fxfa/app/cxfa_ffcombobox.h create mode 100644 xfa/fxfa/app/cxfa_ffdatetimeedit.cpp create mode 100644 xfa/fxfa/app/cxfa_ffdatetimeedit.h create mode 100644 xfa/fxfa/app/cxfa_ffdraw.cpp create mode 100644 xfa/fxfa/app/cxfa_ffdraw.h create mode 100644 xfa/fxfa/app/cxfa_ffexclgroup.cpp create mode 100644 xfa/fxfa/app/cxfa_ffexclgroup.h create mode 100644 xfa/fxfa/app/cxfa_fffield.cpp create mode 100644 xfa/fxfa/app/cxfa_fffield.h create mode 100644 xfa/fxfa/app/cxfa_ffimage.cpp create mode 100644 xfa/fxfa/app/cxfa_ffimage.h create mode 100644 xfa/fxfa/app/cxfa_ffimageedit.cpp create mode 100644 xfa/fxfa/app/cxfa_ffimageedit.h create mode 100644 xfa/fxfa/app/cxfa_ffline.cpp create mode 100644 xfa/fxfa/app/cxfa_ffline.h create mode 100644 xfa/fxfa/app/cxfa_fflistbox.cpp create mode 100644 xfa/fxfa/app/cxfa_fflistbox.h create mode 100644 xfa/fxfa/app/cxfa_ffnotify.cpp create mode 100644 xfa/fxfa/app/cxfa_ffnotify.h create mode 100644 xfa/fxfa/app/cxfa_ffnumericedit.cpp create mode 100644 xfa/fxfa/app/cxfa_ffnumericedit.h create mode 100644 xfa/fxfa/app/cxfa_ffpasswordedit.cpp create mode 100644 xfa/fxfa/app/cxfa_ffpasswordedit.h create mode 100644 xfa/fxfa/app/cxfa_ffpushbutton.cpp create mode 100644 xfa/fxfa/app/cxfa_ffpushbutton.h create mode 100644 xfa/fxfa/app/cxfa_ffrectangle.cpp create mode 100644 xfa/fxfa/app/cxfa_ffrectangle.h create mode 100644 xfa/fxfa/app/cxfa_ffsignature.cpp create mode 100644 xfa/fxfa/app/cxfa_ffsignature.h create mode 100644 xfa/fxfa/app/cxfa_ffsubform.cpp create mode 100644 xfa/fxfa/app/cxfa_ffsubform.h create mode 100644 xfa/fxfa/app/cxfa_fftext.cpp create mode 100644 xfa/fxfa/app/cxfa_fftext.h create mode 100644 xfa/fxfa/app/cxfa_fftextedit.cpp create mode 100644 xfa/fxfa/app/cxfa_fftextedit.h create mode 100644 xfa/fxfa/app/cxfa_fwladapterwidgetmgr.cpp create mode 100644 xfa/fxfa/app/cxfa_fwladapterwidgetmgr.h create mode 100644 xfa/fxfa/app/cxfa_fwltheme.cpp create mode 100644 xfa/fxfa/app/cxfa_fwltheme.h create mode 100644 xfa/fxfa/app/cxfa_textpiece.cpp create mode 100644 xfa/fxfa/app/cxfa_textpiece.h create mode 100644 xfa/fxfa/app/cxfa_textprovider.cpp create mode 100644 xfa/fxfa/app/cxfa_textprovider.h delete mode 100644 xfa/fxfa/app/xfa_ffbarcode.cpp delete mode 100644 xfa/fxfa/app/xfa_ffbarcode.h delete mode 100644 xfa/fxfa/app/xfa_ffbarcode_unittest.cpp delete mode 100644 xfa/fxfa/app/xfa_ffcheckbutton.cpp delete mode 100644 xfa/fxfa/app/xfa_ffcheckbutton.h delete mode 100644 xfa/fxfa/app/xfa_ffchoicelist.cpp delete mode 100644 xfa/fxfa/app/xfa_ffchoicelist.h delete mode 100644 xfa/fxfa/app/xfa_ffdraw.cpp delete mode 100644 xfa/fxfa/app/xfa_ffdraw.h delete mode 100644 xfa/fxfa/app/xfa_ffexclgroup.cpp delete mode 100644 xfa/fxfa/app/xfa_ffexclgroup.h delete mode 100644 xfa/fxfa/app/xfa_fffield.cpp delete mode 100644 xfa/fxfa/app/xfa_fffield.h delete mode 100644 xfa/fxfa/app/xfa_ffimage.cpp delete mode 100644 xfa/fxfa/app/xfa_ffimage.h delete mode 100644 xfa/fxfa/app/xfa_ffimageedit.cpp delete mode 100644 xfa/fxfa/app/xfa_ffimageedit.h delete mode 100644 xfa/fxfa/app/xfa_ffnotify.cpp delete mode 100644 xfa/fxfa/app/xfa_ffnotify.h delete mode 100644 xfa/fxfa/app/xfa_ffpath.cpp delete mode 100644 xfa/fxfa/app/xfa_ffpath.h delete mode 100644 xfa/fxfa/app/xfa_ffpushbutton.cpp delete mode 100644 xfa/fxfa/app/xfa_ffpushbutton.h delete mode 100644 xfa/fxfa/app/xfa_ffsignature.cpp delete mode 100644 xfa/fxfa/app/xfa_ffsignature.h delete mode 100644 xfa/fxfa/app/xfa_ffsubform.cpp delete mode 100644 xfa/fxfa/app/xfa_ffsubform.h delete mode 100644 xfa/fxfa/app/xfa_fftext.cpp delete mode 100644 xfa/fxfa/app/xfa_fftext.h delete mode 100644 xfa/fxfa/app/xfa_fftextedit.cpp delete mode 100644 xfa/fxfa/app/xfa_fftextedit.h delete mode 100644 xfa/fxfa/app/xfa_ffwidgetacc.cpp delete mode 100644 xfa/fxfa/app/xfa_ffwidgetacc.h delete mode 100644 xfa/fxfa/app/xfa_fwladapter.cpp delete mode 100644 xfa/fxfa/app/xfa_fwladapter.h delete mode 100644 xfa/fxfa/app/xfa_fwltheme.cpp delete mode 100644 xfa/fxfa/app/xfa_fwltheme.h delete mode 100644 xfa/fxfa/app/xfa_textpiece.cpp delete mode 100644 xfa/fxfa/app/xfa_textpiece.h diff --git a/BUILD.gn b/BUILD.gn index 5802752af9..4c3629784f 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -1593,6 +1593,52 @@ if (pdf_enable_xfa) { "xfa/fwl/theme/cfwl_widgettp.h", "xfa/fxfa/app/cxfa_csstagprovider.cpp", "xfa/fxfa/app/cxfa_csstagprovider.h", + "xfa/fxfa/app/cxfa_ffarc.cpp", + "xfa/fxfa/app/cxfa_ffarc.h", + "xfa/fxfa/app/cxfa_ffbarcode.cpp", + "xfa/fxfa/app/cxfa_ffbarcode.h", + "xfa/fxfa/app/cxfa_ffcheckbutton.cpp", + "xfa/fxfa/app/cxfa_ffcheckbutton.h", + "xfa/fxfa/app/cxfa_ffcombobox.cpp", + "xfa/fxfa/app/cxfa_ffcombobox.h", + "xfa/fxfa/app/cxfa_ffdatetimeedit.cpp", + "xfa/fxfa/app/cxfa_ffdatetimeedit.h", + "xfa/fxfa/app/cxfa_ffdraw.cpp", + "xfa/fxfa/app/cxfa_ffdraw.h", + "xfa/fxfa/app/cxfa_ffexclgroup.cpp", + "xfa/fxfa/app/cxfa_ffexclgroup.h", + "xfa/fxfa/app/cxfa_fffield.cpp", + "xfa/fxfa/app/cxfa_fffield.h", + "xfa/fxfa/app/cxfa_ffimage.cpp", + "xfa/fxfa/app/cxfa_ffimage.h", + "xfa/fxfa/app/cxfa_ffimageedit.cpp", + "xfa/fxfa/app/cxfa_ffimageedit.h", + "xfa/fxfa/app/cxfa_ffline.cpp", + "xfa/fxfa/app/cxfa_ffline.h", + "xfa/fxfa/app/cxfa_fflistbox.cpp", + "xfa/fxfa/app/cxfa_fflistbox.h", + "xfa/fxfa/app/cxfa_ffnotify.cpp", + "xfa/fxfa/app/cxfa_ffnotify.h", + "xfa/fxfa/app/cxfa_ffnumericedit.cpp", + "xfa/fxfa/app/cxfa_ffnumericedit.h", + "xfa/fxfa/app/cxfa_ffpasswordedit.cpp", + "xfa/fxfa/app/cxfa_ffpasswordedit.h", + "xfa/fxfa/app/cxfa_ffpushbutton.cpp", + "xfa/fxfa/app/cxfa_ffpushbutton.h", + "xfa/fxfa/app/cxfa_ffrectangle.cpp", + "xfa/fxfa/app/cxfa_ffrectangle.h", + "xfa/fxfa/app/cxfa_ffsignature.cpp", + "xfa/fxfa/app/cxfa_ffsignature.h", + "xfa/fxfa/app/cxfa_ffsubform.cpp", + "xfa/fxfa/app/cxfa_ffsubform.h", + "xfa/fxfa/app/cxfa_fftext.cpp", + "xfa/fxfa/app/cxfa_fftext.h", + "xfa/fxfa/app/cxfa_fftextedit.cpp", + "xfa/fxfa/app/cxfa_fftextedit.h", + "xfa/fxfa/app/cxfa_fwladapterwidgetmgr.cpp", + "xfa/fxfa/app/cxfa_fwladapterwidgetmgr.h", + "xfa/fxfa/app/cxfa_fwltheme.cpp", + "xfa/fxfa/app/cxfa_fwltheme.h", "xfa/fxfa/app/cxfa_linkuserdata.cpp", "xfa/fxfa/app/cxfa_linkuserdata.h", "xfa/fxfa/app/cxfa_loadercontext.cpp", @@ -1605,48 +1651,14 @@ if (pdf_enable_xfa) { "xfa/fxfa/app/cxfa_textparsecontext.h", "xfa/fxfa/app/cxfa_textparser.cpp", "xfa/fxfa/app/cxfa_textparser.h", + "xfa/fxfa/app/cxfa_textpiece.cpp", + "xfa/fxfa/app/cxfa_textpiece.h", + "xfa/fxfa/app/cxfa_textprovider.cpp", + "xfa/fxfa/app/cxfa_textprovider.h", "xfa/fxfa/app/cxfa_texttabstopscontext.cpp", "xfa/fxfa/app/cxfa_texttabstopscontext.h", "xfa/fxfa/app/cxfa_textuserdata.cpp", "xfa/fxfa/app/cxfa_textuserdata.h", - "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_ffdraw.cpp", - "xfa/fxfa/app/xfa_ffdraw.h", - "xfa/fxfa/app/xfa_ffexclgroup.cpp", - "xfa/fxfa/app/xfa_ffexclgroup.h", - "xfa/fxfa/app/xfa_fffield.cpp", - "xfa/fxfa/app/xfa_fffield.h", - "xfa/fxfa/app/xfa_ffimage.cpp", - "xfa/fxfa/app/xfa_ffimage.h", - "xfa/fxfa/app/xfa_ffimageedit.cpp", - "xfa/fxfa/app/xfa_ffimageedit.h", - "xfa/fxfa/app/xfa_ffnotify.cpp", - "xfa/fxfa/app/xfa_ffnotify.h", - "xfa/fxfa/app/xfa_ffpath.cpp", - "xfa/fxfa/app/xfa_ffpath.h", - "xfa/fxfa/app/xfa_ffpushbutton.cpp", - "xfa/fxfa/app/xfa_ffpushbutton.h", - "xfa/fxfa/app/xfa_ffsignature.cpp", - "xfa/fxfa/app/xfa_ffsignature.h", - "xfa/fxfa/app/xfa_ffsubform.cpp", - "xfa/fxfa/app/xfa_ffsubform.h", - "xfa/fxfa/app/xfa_fftext.cpp", - "xfa/fxfa/app/xfa_fftext.h", - "xfa/fxfa/app/xfa_fftextedit.cpp", - "xfa/fxfa/app/xfa_fftextedit.h", - "xfa/fxfa/app/xfa_ffwidgetacc.cpp", - "xfa/fxfa/app/xfa_ffwidgetacc.h", - "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_textpiece.cpp", - "xfa/fxfa/app/xfa_textpiece.h", "xfa/fxfa/cxfa_deffontmgr.cpp", "xfa/fxfa/cxfa_deffontmgr.h", "xfa/fxfa/cxfa_eventparam.cpp", @@ -1917,8 +1929,8 @@ test("pdfium_unittests") { "xfa/fde/css/cfde_cssvaluelistparser_unittest.cpp", "xfa/fgas/layout/cfx_rtfbreak_unittest.cpp", "xfa/fwl/cfx_barcode_unittest.cpp", + "xfa/fxfa/app/cxfa_ffbarcode_unittest.cpp", "xfa/fxfa/app/cxfa_textparser_unittest.cpp", - "xfa/fxfa/app/xfa_ffbarcode_unittest.cpp", "xfa/fxfa/cxfa_ffapp_unittest.cpp", "xfa/fxfa/fm2js/cxfa_fmlexer_unittest.cpp", "xfa/fxfa/fm2js/cxfa_fmparse_unittest.cpp", diff --git a/xfa/fwl/cfwl_app.cpp b/xfa/fwl/cfwl_app.cpp index febc8a0fdf..e762125ba8 100644 --- a/xfa/fwl/cfwl_app.cpp +++ b/xfa/fwl/cfwl_app.cpp @@ -10,7 +10,7 @@ #include "xfa/fwl/cfwl_notedriver.h" #include "xfa/fwl/cfwl_widget.h" #include "xfa/fwl/cfwl_widgetmgr.h" -#include "xfa/fxfa/app/xfa_fwladapter.h" +#include "xfa/fxfa/app/cxfa_fwladapterwidgetmgr.h" CFWL_App::CFWL_App(CXFA_FFApp* pAdapter) : m_pAdapterNative(pAdapter), diff --git a/xfa/fwl/cfwl_widgetmgr.cpp b/xfa/fwl/cfwl_widgetmgr.cpp index d0dbf1f773..67a63ba921 100644 --- a/xfa/fwl/cfwl_widgetmgr.cpp +++ b/xfa/fwl/cfwl_widgetmgr.cpp @@ -12,7 +12,7 @@ #include "xfa/fwl/cfwl_app.h" #include "xfa/fwl/cfwl_form.h" #include "xfa/fwl/cfwl_notedriver.h" -#include "xfa/fxfa/app/xfa_fwladapter.h" +#include "xfa/fxfa/app/cxfa_fwladapterwidgetmgr.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 138a99e59d..06cdceb09e 100644 --- a/xfa/fwl/theme/cfwl_edittp.cpp +++ b/xfa/fwl/theme/cfwl_edittp.cpp @@ -9,7 +9,7 @@ #include "xfa/fwl/cfwl_edit.h" #include "xfa/fwl/cfwl_themebackground.h" #include "xfa/fwl/cfwl_widget.h" -#include "xfa/fxfa/app/xfa_fwltheme.h" +#include "xfa/fxfa/app/cxfa_fwltheme.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/cxfa_ffarc.cpp b/xfa/fxfa/app/cxfa_ffarc.cpp new file mode 100644 index 0000000000..e2085480a5 --- /dev/null +++ b/xfa/fxfa/app/cxfa_ffarc.cpp @@ -0,0 +1,33 @@ +// Copyright 2017 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#include "xfa/fxfa/app/cxfa_ffarc.h" + +CXFA_FFArc::CXFA_FFArc(CXFA_WidgetAcc* pDataAcc) : CXFA_FFDraw(pDataAcc) {} + +CXFA_FFArc::~CXFA_FFArc() {} + +void CXFA_FFArc::RenderWidget(CFX_Graphics* pGS, + CFX_Matrix* pMatrix, + uint32_t dwStatus) { + if (!IsMatchVisibleStatus(dwStatus)) + return; + + CXFA_Value value = m_pDataAcc->GetFormValue(); + if (!value) + return; + + CXFA_Arc arcObj = value.GetArc(); + CFX_Matrix mtRotate = GetRotateMatrix(); + if (pMatrix) + mtRotate.Concat(*pMatrix); + + CFX_RectF rtArc = GetRectWithoutRotate(); + if (CXFA_Margin mgWidget = m_pDataAcc->GetMargin()) + XFA_RectWidthoutMargin(rtArc, mgWidget); + + DrawBorder(pGS, arcObj, rtArc, &mtRotate); +} diff --git a/xfa/fxfa/app/cxfa_ffarc.h b/xfa/fxfa/app/cxfa_ffarc.h new file mode 100644 index 0000000000..777ed6f3af --- /dev/null +++ b/xfa/fxfa/app/cxfa_ffarc.h @@ -0,0 +1,23 @@ +// 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_APP_CXFA_FFARC_H_ +#define XFA_FXFA_APP_CXFA_FFARC_H_ + +#include "xfa/fxfa/app/cxfa_ffdraw.h" + +class CXFA_FFArc : public CXFA_FFDraw { + public: + explicit CXFA_FFArc(CXFA_WidgetAcc* pDataAcc); + ~CXFA_FFArc() override; + + // CXFA_FFWidget + void RenderWidget(CFX_Graphics* pGS, + CFX_Matrix* pMatrix, + uint32_t dwStatus) override; +}; + +#endif // XFA_FXFA_APP_CXFA_FFARC_H_ diff --git a/xfa/fxfa/app/cxfa_ffbarcode.cpp b/xfa/fxfa/app/cxfa_ffbarcode.cpp new file mode 100644 index 0000000000..bd529d3eb2 --- /dev/null +++ b/xfa/fxfa/app/cxfa_ffbarcode.cpp @@ -0,0 +1,226 @@ +// 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/app/cxfa_ffbarcode.h" + +#include + +#include "core/fxcrt/fx_extension.h" +#include "third_party/base/ptr_util.h" +#include "xfa/fwl/cfwl_app.h" +#include "xfa/fwl/cfwl_barcode.h" +#include "xfa/fwl/cfwl_notedriver.h" +#include "xfa/fxfa/app/cxfa_fffield.h" +#include "xfa/fxfa/app/cxfa_fwladapterwidgetmgr.h" +#include "xfa/fxfa/cxfa_ffpageview.h" +#include "xfa/fxfa/cxfa_ffwidget.h" + +namespace { + +const BarCodeInfo g_BarCodeData[] = { + {0x7fb4a18, L"ean13", BarcodeType::ean13, BC_EAN13}, + {0x8d13a3d, L"code11", BarcodeType::code11, BC_UNKNOWN}, + {0x8d149a8, L"code49", BarcodeType::code49, BC_UNKNOWN}, + {0x8d16347, L"code93", BarcodeType::code93, BC_UNKNOWN}, + {0x91a92e2, L"upsMaxicode", BarcodeType::upsMaxicode, BC_UNKNOWN}, + {0xa7d48dc, L"fim", BarcodeType::fim, BC_UNKNOWN}, + {0xb359fe9, L"msi", BarcodeType::msi, BC_UNKNOWN}, + {0x121f738c, L"code2Of5Matrix", BarcodeType::code2Of5Matrix, BC_UNKNOWN}, + {0x15358616, L"ucc128", BarcodeType::ucc128, BC_UNKNOWN}, + {0x1f4bfa05, L"rfid", BarcodeType::rfid, BC_UNKNOWN}, + {0x1fda71bc, L"rss14Stacked", BarcodeType::rss14Stacked, BC_UNKNOWN}, + {0x22065087, L"ean8add2", BarcodeType::ean8add2, BC_UNKNOWN}, + {0x2206508a, L"ean8add5", BarcodeType::ean8add5, BC_UNKNOWN}, + {0x2278366c, L"codabar", BarcodeType::codabar, BC_CODABAR}, + {0x2a039a8d, L"telepen", BarcodeType::telepen, BC_UNKNOWN}, + {0x323ed337, L"upcApwcd", BarcodeType::upcApwcd, BC_UNKNOWN}, + {0x347a1846, L"postUSIMB", BarcodeType::postUSIMB, BC_UNKNOWN}, + {0x391bb836, L"code128", BarcodeType::code128, BC_CODE128}, + {0x398eddaf, L"dataMatrix", BarcodeType::dataMatrix, BC_DATAMATRIX}, + {0x3cff60a8, L"upcEadd2", BarcodeType::upcEadd2, BC_UNKNOWN}, + {0x3cff60ab, L"upcEadd5", BarcodeType::upcEadd5, BC_UNKNOWN}, + {0x402cb188, L"code2Of5Standard", BarcodeType::code2Of5Standard, + BC_UNKNOWN}, + {0x411764f7, L"aztec", BarcodeType::aztec, BC_UNKNOWN}, + {0x44d4e84c, L"ean8", BarcodeType::ean8, BC_EAN8}, + {0x48468902, L"ucc128sscc", BarcodeType::ucc128sscc, BC_UNKNOWN}, + {0x4880aea4, L"upcAadd2", BarcodeType::upcAadd2, BC_UNKNOWN}, + {0x4880aea7, L"upcAadd5", BarcodeType::upcAadd5, BC_UNKNOWN}, + {0x54f18256, L"code2Of5Industrial", BarcodeType::code2Of5Industrial, + BC_UNKNOWN}, + {0x58e15f25, L"rss14Limited", BarcodeType::rss14Limited, BC_UNKNOWN}, + {0x5c08d1b9, L"postAUSReplyPaid", BarcodeType::postAUSReplyPaid, + BC_UNKNOWN}, + {0x5fa700bd, L"rss14", BarcodeType::rss14, BC_UNKNOWN}, + {0x631a7e35, L"logmars", BarcodeType::logmars, BC_UNKNOWN}, + {0x6a236236, L"pdf417", BarcodeType::pdf417, BC_PDF417}, + {0x6d098ece, L"upcean2", BarcodeType::upcean2, BC_UNKNOWN}, + {0x6d098ed1, L"upcean5", BarcodeType::upcean5, BC_UNKNOWN}, + {0x76b04eed, L"code3Of9extended", BarcodeType::code3Of9extended, + BC_UNKNOWN}, + {0x7c7db84a, L"maxicode", BarcodeType::maxicode, BC_UNKNOWN}, + {0x8266f7f7, L"ucc128random", BarcodeType::ucc128random, BC_UNKNOWN}, + {0x83eca147, L"postUSDPBC", BarcodeType::postUSDPBC, BC_UNKNOWN}, + {0x8dd71de0, L"postAUSStandard", BarcodeType::postAUSStandard, BC_UNKNOWN}, + {0x98adad85, L"plessey", BarcodeType::plessey, BC_UNKNOWN}, + {0x9f84cce6, L"ean13pwcd", BarcodeType::ean13pwcd, BC_UNKNOWN}, + {0xb514fbe9, L"upcA", BarcodeType::upcA, BC_UPCA}, + {0xb514fbed, L"upcE", BarcodeType::upcE, BC_UNKNOWN}, + {0xb5c6a853, L"ean13add2", BarcodeType::ean13add2, BC_UNKNOWN}, + {0xb5c6a856, L"ean13add5", BarcodeType::ean13add5, BC_UNKNOWN}, + {0xb81fc512, L"postUKRM4SCC", BarcodeType::postUKRM4SCC, BC_UNKNOWN}, + {0xbad34b22, L"code128SSCC", BarcodeType::code128SSCC, BC_UNKNOWN}, + {0xbfbe0cf6, L"postUS5Zip", BarcodeType::postUS5Zip, BC_UNKNOWN}, + {0xc56618e8, L"pdf417macro", BarcodeType::pdf417macro, BC_UNKNOWN}, + {0xca730f8a, L"code2Of5Interleaved", BarcodeType::code2Of5Interleaved, + BC_UNKNOWN}, + {0xd0097ac6, L"rss14Expanded", BarcodeType::rss14Expanded, BC_UNKNOWN}, + {0xd25a0240, L"postAUSCust2", BarcodeType::postAUSCust2, BC_UNKNOWN}, + {0xd25a0241, L"postAUSCust3", BarcodeType::postAUSCust3, BC_UNKNOWN}, + {0xd53ed3e7, L"rss14Truncated", BarcodeType::rss14Truncated, BC_UNKNOWN}, + {0xe72bcd57, L"code128A", BarcodeType::code128A, BC_UNKNOWN}, + {0xe72bcd58, L"code128B", BarcodeType::code128B, BC_CODE128_B}, + {0xe72bcd59, L"code128C", BarcodeType::code128C, BC_CODE128_C}, + {0xee83c50f, L"rss14StackedOmni", BarcodeType::rss14StackedOmni, + BC_UNKNOWN}, + {0xf2a18f7e, L"QRCode", BarcodeType::QRCode, BC_QR_CODE}, + {0xfaeaf37f, L"postUSStandard", BarcodeType::postUSStandard, BC_UNKNOWN}, + {0xfb48155c, L"code3Of9", BarcodeType::code3Of9, BC_CODE39}, +}; + +} // namespace. + +// static +const BarCodeInfo* CXFA_FFBarcode::GetBarcodeTypeByName( + const CFX_WideStringC& wsName) { + if (wsName.IsEmpty()) + return nullptr; + + auto* it = std::lower_bound( + std::begin(g_BarCodeData), std::end(g_BarCodeData), + FX_HashCode_GetW(wsName, true), + [](const BarCodeInfo& arg, uint32_t hash) { return arg.uHash < hash; }); + + if (it != std::end(g_BarCodeData) && wsName == it->pName) + return it; + + return nullptr; +} + +CXFA_FFBarcode::CXFA_FFBarcode(CXFA_WidgetAcc* pDataAcc) + : CXFA_FFTextEdit(pDataAcc) {} + +CXFA_FFBarcode::~CXFA_FFBarcode() {} + +bool CXFA_FFBarcode::LoadWidget() { + auto pNew = pdfium::MakeUnique(GetFWLApp()); + CFWL_Barcode* pFWLBarcode = pNew.get(); + m_pNormalWidget = std::move(pNew); + m_pNormalWidget->SetLayoutItem(this); + + CFWL_NoteDriver* pNoteDriver = + m_pNormalWidget->GetOwnerApp()->GetNoteDriver(); + pNoteDriver->RegisterEventTarget(m_pNormalWidget.get(), + m_pNormalWidget.get()); + m_pOldDelegate = m_pNormalWidget->GetDelegate(); + m_pNormalWidget->SetDelegate(this); + m_pNormalWidget->LockUpdate(); + + CFX_WideString wsText; + m_pDataAcc->GetValue(wsText, XFA_VALUEPICTURE_Display); + pFWLBarcode->SetText(wsText); + UpdateWidgetProperty(); + m_pNormalWidget->UnlockUpdate(); + return CXFA_FFField::LoadWidget(); +} + +void CXFA_FFBarcode::RenderWidget(CFX_Graphics* pGS, + CFX_Matrix* pMatrix, + uint32_t dwStatus) { + if (!IsMatchVisibleStatus(dwStatus)) + return; + + CFX_Matrix mtRotate = GetRotateMatrix(); + if (pMatrix) + mtRotate.Concat(*pMatrix); + + CXFA_FFWidget::RenderWidget(pGS, &mtRotate, dwStatus); + CXFA_Border borderUI = m_pDataAcc->GetUIBorder(); + DrawBorder(pGS, borderUI, m_rtUI, &mtRotate); + RenderCaption(pGS, &mtRotate); + CFX_RectF rtWidget = m_pNormalWidget->GetWidgetRect(); + + CFX_Matrix mt(1, 0, 0, 1, rtWidget.left, rtWidget.top); + mt.Concat(mtRotate); + m_pNormalWidget->DrawWidget(pGS, &mt); +} + +void CXFA_FFBarcode::UpdateWidgetProperty() { + CXFA_FFTextEdit::UpdateWidgetProperty(); + + auto* pBarCodeWidget = static_cast(m_pNormalWidget.get()); + CFX_WideString wsType = GetDataAcc()->GetBarcodeType(); + const BarCodeInfo* pBarcodeInfo = GetBarcodeTypeByName(wsType.AsStringC()); + if (!pBarcodeInfo) + return; + + pBarCodeWidget->SetType(pBarcodeInfo->eBCType); + + CXFA_WidgetAcc* pAcc = GetDataAcc(); + int32_t intVal; + if (pAcc->GetBarcodeAttribute_CharEncoding(&intVal)) + pBarCodeWidget->SetCharEncoding((BC_CHAR_ENCODING)intVal); + + bool boolVal; + if (pAcc->GetBarcodeAttribute_Checksum(&boolVal)) + pBarCodeWidget->SetCalChecksum(boolVal); + if (pAcc->GetBarcodeAttribute_DataLength(&intVal)) + pBarCodeWidget->SetDataLength(intVal); + + char charVal; + if (pAcc->GetBarcodeAttribute_StartChar(&charVal)) + pBarCodeWidget->SetStartChar(charVal); + if (pAcc->GetBarcodeAttribute_EndChar(&charVal)) + pBarCodeWidget->SetEndChar(charVal); + if (pAcc->GetBarcodeAttribute_ECLevel(&intVal)) + pBarCodeWidget->SetErrorCorrectionLevel(intVal); + if (pAcc->GetBarcodeAttribute_ModuleWidth(&intVal)) + pBarCodeWidget->SetModuleWidth(intVal); + if (pAcc->GetBarcodeAttribute_ModuleHeight(&intVal)) + pBarCodeWidget->SetModuleHeight(intVal); + if (pAcc->GetBarcodeAttribute_PrintChecksum(&boolVal)) + pBarCodeWidget->SetPrintChecksum(boolVal); + if (pAcc->GetBarcodeAttribute_TextLocation(&intVal)) + pBarCodeWidget->SetTextLocation((BC_TEXT_LOC)intVal); + if (pAcc->GetBarcodeAttribute_Truncate(&boolVal)) + pBarCodeWidget->SetTruncated(boolVal); + + float floatVal; + if (pAcc->GetBarcodeAttribute_WideNarrowRatio(&floatVal)) + pBarCodeWidget->SetWideNarrowRatio(static_cast(floatVal)); + if (pBarcodeInfo->eName == BarcodeType::code3Of9 || + pBarcodeInfo->eName == BarcodeType::ean8 || + pBarcodeInfo->eName == BarcodeType::ean13 || + pBarcodeInfo->eName == BarcodeType::upcA) { + pBarCodeWidget->SetPrintChecksum(true); + } +} + +bool CXFA_FFBarcode::OnLButtonDown(uint32_t dwFlags, const CFX_PointF& point) { + auto* pBarCodeWidget = static_cast(m_pNormalWidget.get()); + if (!pBarCodeWidget || pBarCodeWidget->IsProtectedType()) + return false; + if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open) + return false; + return CXFA_FFTextEdit::OnLButtonDown(dwFlags, point); +} + +bool CXFA_FFBarcode::OnRButtonDown(uint32_t dwFlags, const CFX_PointF& point) { + auto* pBarCodeWidget = static_cast(m_pNormalWidget.get()); + if (!pBarCodeWidget || pBarCodeWidget->IsProtectedType()) + return false; + return CXFA_FFTextEdit::OnRButtonDown(dwFlags, point); +} diff --git a/xfa/fxfa/app/cxfa_ffbarcode.h b/xfa/fxfa/app/cxfa_ffbarcode.h new file mode 100644 index 0000000000..11b678d98a --- /dev/null +++ b/xfa/fxfa/app/cxfa_ffbarcode.h @@ -0,0 +1,103 @@ +// 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_APP_CXFA_FFBARCODE_H_ +#define XFA_FXFA_APP_CXFA_FFBARCODE_H_ + +#include "fxbarcode/BC_Library.h" +#include "xfa/fxfa/app/cxfa_fftextedit.h" +#include "xfa/fxfa/cxfa_ffpageview.h" + +enum class BarcodeType { + aztec, + codabar, + code11, + code128, + code128A, + code128B, + code128C, + code128SSCC, + code2Of5Industrial, + code2Of5Interleaved, + code2Of5Matrix, + code2Of5Standard, + code3Of9, + code3Of9extended, + code49, + code93, + dataMatrix, + ean13, + ean13add2, + ean13add5, + ean13pwcd, + ean8, + ean8add2, + ean8add5, + fim, + logmars, + maxicode, + msi, + pdf417, + pdf417macro, + plessey, + postAUSCust2, + postAUSCust3, + postAUSReplyPaid, + postAUSStandard, + postUKRM4SCC, + postUS5Zip, + postUSDPBC, + postUSIMB, + postUSStandard, + QRCode, + rfid, + rss14, + rss14Expanded, + rss14Limited, + rss14Stacked, + rss14StackedOmni, + rss14Truncated, + telepen, + ucc128, + ucc128random, + ucc128sscc, + upcA, + upcAadd2, + upcAadd5, + upcApwcd, + upcE, + upcEadd2, + upcEadd5, + upcean2, + upcean5, + upsMaxicode +}; + +struct BarCodeInfo { + uint32_t uHash; + const wchar_t* pName; + BarcodeType eName; + BC_TYPE eBCType; +}; + +class CXFA_FFBarcode : public CXFA_FFTextEdit { + public: + static const BarCodeInfo* GetBarcodeTypeByName(const CFX_WideStringC& wsName); + + explicit CXFA_FFBarcode(CXFA_WidgetAcc* pDataAcc); + ~CXFA_FFBarcode() override; + + // CXFA_FFTextEdit + bool LoadWidget() override; + void RenderWidget(CFX_Graphics* pGS, + CFX_Matrix* pMatrix, + uint32_t dwStatus) override; + void UpdateWidgetProperty() override; + bool OnLButtonDown(uint32_t dwFlags, const CFX_PointF& point) override; + bool OnRButtonDown(uint32_t dwFlags, const CFX_PointF& point) override; +}; + +#endif // XFA_FXFA_APP_CXFA_FFBARCODE_H_ diff --git a/xfa/fxfa/app/cxfa_ffbarcode_unittest.cpp b/xfa/fxfa/app/cxfa_ffbarcode_unittest.cpp new file mode 100644 index 0000000000..65e44ade53 --- /dev/null +++ b/xfa/fxfa/app/cxfa_ffbarcode_unittest.cpp @@ -0,0 +1,25 @@ +// 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. + +#include "xfa/fxfa/app/cxfa_ffbarcode.h" + +#include "testing/gtest/include/gtest/gtest.h" +#include "third_party/base/ptr_util.h" + +TEST(XFA_FFBarcode, GetBarcodeTypeByName) { + EXPECT_EQ(nullptr, CXFA_FFBarcode::GetBarcodeTypeByName(L"")); + EXPECT_EQ(nullptr, CXFA_FFBarcode::GetBarcodeTypeByName(L"not_found")); + + auto* data = CXFA_FFBarcode::GetBarcodeTypeByName(L"ean13"); + ASSERT_NE(nullptr, data); + EXPECT_EQ(BarcodeType::ean13, data->eName); + + data = CXFA_FFBarcode::GetBarcodeTypeByName(L"pdf417"); + ASSERT_NE(nullptr, data); + EXPECT_EQ(BarcodeType::pdf417, data->eName); + + data = CXFA_FFBarcode::GetBarcodeTypeByName(L"code3Of9"); + ASSERT_NE(nullptr, data); + EXPECT_EQ(BarcodeType::code3Of9, data->eName); +} diff --git a/xfa/fxfa/app/cxfa_ffcheckbutton.cpp b/xfa/fxfa/app/cxfa_ffcheckbutton.cpp new file mode 100644 index 0000000000..b55daae21a --- /dev/null +++ b/xfa/fxfa/app/cxfa_ffcheckbutton.cpp @@ -0,0 +1,345 @@ +// 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/app/cxfa_ffcheckbutton.h" + +#include +#include "third_party/base/ptr_util.h" +#include "xfa/fwl/cfwl_checkbox.h" +#include "xfa/fwl/cfwl_messagemouse.h" +#include "xfa/fwl/cfwl_notedriver.h" +#include "xfa/fwl/cfwl_widgetmgr.h" +#include "xfa/fxfa/app/cxfa_ffexclgroup.h" +#include "xfa/fxfa/app/cxfa_fffield.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) {} + +CXFA_FFCheckButton::~CXFA_FFCheckButton() {} + +bool CXFA_FFCheckButton::LoadWidget() { + auto pNew = pdfium::MakeUnique(GetFWLApp()); + CFWL_CheckBox* pCheckBox = pNew.get(); + m_pNormalWidget = std::move(pNew); + m_pNormalWidget->SetLayoutItem(this); + + CFWL_NoteDriver* pNoteDriver = + m_pNormalWidget->GetOwnerApp()->GetNoteDriver(); + pNoteDriver->RegisterEventTarget(m_pNormalWidget.get(), + m_pNormalWidget.get()); + m_pOldDelegate = m_pNormalWidget->GetDelegate(); + m_pNormalWidget->SetDelegate(this); + if (m_pDataAcc->IsRadioButton()) + pCheckBox->ModifyStylesEx(FWL_STYLEEXT_CKB_RadioButton, 0xFFFFFFFF); + + m_pNormalWidget->LockUpdate(); + UpdateWidgetProperty(); + SetFWLCheckState(m_pDataAcc->GetCheckState()); + m_pNormalWidget->UnlockUpdate(); + return CXFA_FFField::LoadWidget(); +} + +void CXFA_FFCheckButton::UpdateWidgetProperty() { + auto* pCheckBox = static_cast(m_pNormalWidget.get()); + if (!pCheckBox) + return; + + pCheckBox->SetBoxSize(m_pDataAcc->GetCheckButtonSize()); + uint32_t dwStyleEx = FWL_STYLEEXT_CKB_SignShapeCross; + int32_t iCheckMark = m_pDataAcc->GetCheckButtonMark(); + switch (iCheckMark) { + case XFA_ATTRIBUTEENUM_Check: + dwStyleEx = FWL_STYLEEXT_CKB_SignShapeCheck; + break; + case XFA_ATTRIBUTEENUM_Circle: + dwStyleEx = FWL_STYLEEXT_CKB_SignShapeCircle; + break; + case XFA_ATTRIBUTEENUM_Cross: + break; + case XFA_ATTRIBUTEENUM_Diamond: + dwStyleEx = FWL_STYLEEXT_CKB_SignShapeDiamond; + break; + case XFA_ATTRIBUTEENUM_Square: + dwStyleEx = FWL_STYLEEXT_CKB_SignShapeSquare; + break; + case XFA_ATTRIBUTEENUM_Star: + dwStyleEx = FWL_STYLEEXT_CKB_SignShapeStar; + break; + default: { + int32_t iShape = m_pDataAcc->GetCheckButtonShape(); + if (iShape == XFA_ATTRIBUTEENUM_Round) { + dwStyleEx = FWL_STYLEEXT_CKB_SignShapeCircle; + } + } break; + } + if (m_pDataAcc->IsAllowNeutral()) + dwStyleEx |= FWL_STYLEEXT_CKB_3State; + + pCheckBox->ModifyStylesEx( + dwStyleEx, FWL_STYLEEXT_CKB_SignShapeMask | FWL_STYLEEXT_CKB_3State); +} + +bool CXFA_FFCheckButton::PerformLayout() { + CXFA_FFWidget::PerformLayout(); + + float fCheckSize = m_pDataAcc->GetCheckButtonSize(); + CXFA_Margin mgWidget = m_pDataAcc->GetMargin(); + CFX_RectF rtWidget = GetRectWithoutRotate(); + if (mgWidget) + XFA_RectWidthoutMargin(rtWidget, mgWidget); + + int32_t iCapPlacement = -1; + float fCapReserve = 0; + CXFA_Caption caption = m_pDataAcc->GetCaption(); + if (caption && caption.GetPresence()) { + m_rtCaption = rtWidget; + iCapPlacement = caption.GetPlacementType(); + fCapReserve = caption.GetReserve(); + if (fCapReserve <= 0) { + if (iCapPlacement == XFA_ATTRIBUTEENUM_Top || + iCapPlacement == XFA_ATTRIBUTEENUM_Bottom) { + fCapReserve = rtWidget.height - fCheckSize; + } else { + fCapReserve = rtWidget.width - fCheckSize; + } + } + } + + int32_t iHorzAlign = XFA_ATTRIBUTEENUM_Left; + int32_t iVertAlign = XFA_ATTRIBUTEENUM_Top; + if (CXFA_Para para = m_pDataAcc->GetPara()) { + iHorzAlign = para.GetHorizontalAlign(); + iVertAlign = para.GetVerticalAlign(); + } + + m_rtUI = rtWidget; + CXFA_Margin mgCap = caption.GetMargin(); + switch (iCapPlacement) { + case XFA_ATTRIBUTEENUM_Left: { + m_rtCaption.width = fCapReserve; + CapLeftRightPlacement(mgCap); + m_rtUI.width -= fCapReserve; + m_rtUI.left += fCapReserve; + break; + } + case XFA_ATTRIBUTEENUM_Top: { + m_rtCaption.height = fCapReserve; + XFA_RectWidthoutMargin(m_rtCaption, mgCap); + m_rtUI.height -= fCapReserve; + m_rtUI.top += fCapReserve; + break; + } + case XFA_ATTRIBUTEENUM_Right: { + m_rtCaption.left = m_rtCaption.right() - fCapReserve; + m_rtCaption.width = fCapReserve; + CapLeftRightPlacement(mgCap); + m_rtUI.width -= fCapReserve; + break; + } + case XFA_ATTRIBUTEENUM_Bottom: { + m_rtCaption.top = m_rtCaption.bottom() - fCapReserve; + m_rtCaption.height = fCapReserve; + XFA_RectWidthoutMargin(m_rtCaption, mgCap); + m_rtUI.height -= fCapReserve; + break; + } + case XFA_ATTRIBUTEENUM_Inline: + break; + default: + iHorzAlign = XFA_ATTRIBUTEENUM_Right; + break; + } + + if (iHorzAlign == XFA_ATTRIBUTEENUM_Center) + m_rtUI.left += (m_rtUI.width - fCheckSize) / 2; + else if (iHorzAlign == XFA_ATTRIBUTEENUM_Right) + m_rtUI.left = m_rtUI.right() - fCheckSize; + + if (iVertAlign == XFA_ATTRIBUTEENUM_Middle) + m_rtUI.top += (m_rtUI.height - fCheckSize) / 2; + else if (iVertAlign == XFA_ATTRIBUTEENUM_Bottom) + m_rtUI.top = m_rtUI.bottom() - fCheckSize; + + m_rtUI.width = fCheckSize; + m_rtUI.height = fCheckSize; + AddUIMargin(iCapPlacement); + m_rtCheckBox = m_rtUI; + CXFA_Border borderUI = m_pDataAcc->GetUIBorder(); + if (borderUI) { + CXFA_Margin margin = borderUI.GetMargin(); + if (margin) + XFA_RectWidthoutMargin(m_rtUI, margin); + } + + m_rtUI.Normalize(); + LayoutCaption(); + SetFWLRect(); + if (m_pNormalWidget) + m_pNormalWidget->Update(); + + return true; +} + +void CXFA_FFCheckButton::CapLeftRightPlacement(CXFA_Margin mgCap) { + XFA_RectWidthoutMargin(m_rtCaption, mgCap); + if (m_rtCaption.height < 0) + m_rtCaption.top += m_rtCaption.height; + if (m_rtCaption.width < 0) { + m_rtCaption.left += m_rtCaption.width; + m_rtCaption.width = -m_rtCaption.width; + } +} + +void CXFA_FFCheckButton::AddUIMargin(int32_t iCapPlacement) { + CFX_RectF rtUIMargin = m_pDataAcc->GetUIMargin(); + m_rtUI.top -= rtUIMargin.top / 2 - rtUIMargin.height / 2; + + float fLeftAddRight = rtUIMargin.left + rtUIMargin.width; + float fTopAddBottom = rtUIMargin.top + rtUIMargin.height; + if (m_rtUI.width < fLeftAddRight) { + if (iCapPlacement == XFA_ATTRIBUTEENUM_Right || + iCapPlacement == XFA_ATTRIBUTEENUM_Left) { + m_rtUI.left -= fLeftAddRight - m_rtUI.width; + } else { + m_rtUI.left -= 2 * (fLeftAddRight - m_rtUI.width); + } + m_rtUI.width += 2 * (fLeftAddRight - m_rtUI.width); + } + if (m_rtUI.height < fTopAddBottom) { + if (iCapPlacement == XFA_ATTRIBUTEENUM_Right) + m_rtUI.left -= fTopAddBottom - m_rtUI.height; + + m_rtUI.top -= fTopAddBottom - m_rtUI.height; + m_rtUI.height += 2 * (fTopAddBottom - m_rtUI.height); + } +} + +void CXFA_FFCheckButton::RenderWidget(CFX_Graphics* pGS, + CFX_Matrix* pMatrix, + uint32_t dwStatus) { + if (!IsMatchVisibleStatus(dwStatus)) + return; + + CFX_Matrix mtRotate = GetRotateMatrix(); + if (pMatrix) + mtRotate.Concat(*pMatrix); + + CXFA_FFWidget::RenderWidget(pGS, &mtRotate, dwStatus); + CXFA_Border borderUI = m_pDataAcc->GetUIBorder(); + DrawBorder(pGS, borderUI, m_rtUI, &mtRotate, + m_pDataAcc->GetCheckButtonShape() == XFA_ATTRIBUTEENUM_Round + ? XFA_DRAWBOX_ForceRound + : 0); + RenderCaption(pGS, &mtRotate); + DrawHighlight(pGS, &mtRotate, dwStatus, + m_pDataAcc->GetCheckButtonShape() == XFA_ATTRIBUTEENUM_Round); + CFX_Matrix mt(1, 0, 0, 1, m_rtCheckBox.left, m_rtCheckBox.top); + mt.Concat(mtRotate); + GetApp()->GetWidgetMgrDelegate()->OnDrawWidget(m_pNormalWidget.get(), pGS, + &mt); +} + +bool CXFA_FFCheckButton::OnLButtonUp(uint32_t dwFlags, + const CFX_PointF& point) { + if (!m_pNormalWidget || !IsButtonDown()) + return false; + + SetButtonDown(false); + CFWL_MessageMouse ms(nullptr, m_pNormalWidget.get()); + ms.m_dwCmd = FWL_MouseCommand::LeftButtonUp; + ms.m_dwFlags = dwFlags; + ms.m_pos = FWLToClient(point); + TranslateFWLMessage(&ms); + return true; +} + +XFA_CHECKSTATE CXFA_FFCheckButton::FWLState2XFAState() { + uint32_t dwState = m_pNormalWidget->GetStates(); + if (dwState & FWL_STATE_CKB_Checked) + return XFA_CHECKSTATE_On; + if (dwState & FWL_STATE_CKB_Neutral) + return XFA_CHECKSTATE_Neutral; + return XFA_CHECKSTATE_Off; +} + +bool CXFA_FFCheckButton::CommitData() { + XFA_CHECKSTATE eCheckState = FWLState2XFAState(); + m_pDataAcc->SetCheckState(eCheckState, true); + return true; +} + +bool CXFA_FFCheckButton::IsDataChanged() { + XFA_CHECKSTATE eCheckState = FWLState2XFAState(); + return m_pDataAcc->GetCheckState() != eCheckState; +} + +void CXFA_FFCheckButton::SetFWLCheckState(XFA_CHECKSTATE eCheckState) { + if (eCheckState == XFA_CHECKSTATE_Neutral) + m_pNormalWidget->SetStates(FWL_STATE_CKB_Neutral); + else if (eCheckState == XFA_CHECKSTATE_On) + m_pNormalWidget->SetStates(FWL_STATE_CKB_Checked); + else + m_pNormalWidget->RemoveStates(FWL_STATE_CKB_Checked); +} + +bool CXFA_FFCheckButton::UpdateFWLData() { + if (!m_pNormalWidget) + return false; + + XFA_CHECKSTATE eState = m_pDataAcc->GetCheckState(); + SetFWLCheckState(eState); + m_pNormalWidget->Update(); + return true; +} + +void CXFA_FFCheckButton::OnProcessMessage(CFWL_Message* pMessage) { + m_pOldDelegate->OnProcessMessage(pMessage); +} + +void CXFA_FFCheckButton::OnProcessEvent(CFWL_Event* pEvent) { + CXFA_FFField::OnProcessEvent(pEvent); + switch (pEvent->GetType()) { + case CFWL_Event::Type::CheckStateChanged: { + CXFA_EventParam eParam; + eParam.m_eType = XFA_EVENT_Change; + m_pDataAcc->GetValue(eParam.m_wsNewText, XFA_VALUEPICTURE_Raw); + + CXFA_WidgetAcc* pFFExclGroup = m_pDataAcc->GetExclGroup(); + if (ProcessCommittedData()) { + eParam.m_pTarget = pFFExclGroup; + if (pFFExclGroup) { + m_pDocView->AddValidateWidget(pFFExclGroup); + m_pDocView->AddCalculateWidgetAcc(pFFExclGroup); + pFFExclGroup->ProcessEvent(XFA_ATTRIBUTEENUM_Change, &eParam); + } + eParam.m_pTarget = m_pDataAcc.Get(); + m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Change, &eParam); + } else { + SetFWLCheckState(m_pDataAcc->GetCheckState()); + } + if (pFFExclGroup) { + eParam.m_pTarget = pFFExclGroup; + pFFExclGroup->ProcessEvent(XFA_ATTRIBUTEENUM_Click, &eParam); + } + eParam.m_pTarget = m_pDataAcc.Get(); + m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Click, &eParam); + break; + } + default: + break; + } + m_pOldDelegate->OnProcessEvent(pEvent); +} + +void CXFA_FFCheckButton::OnDrawWidget(CFX_Graphics* pGraphics, + const CFX_Matrix* pMatrix) { + m_pOldDelegate->OnDrawWidget(pGraphics, pMatrix); +} diff --git a/xfa/fxfa/app/cxfa_ffcheckbutton.h b/xfa/fxfa/app/cxfa_ffcheckbutton.h new file mode 100644 index 0000000000..f92b50a692 --- /dev/null +++ b/xfa/fxfa/app/cxfa_ffcheckbutton.h @@ -0,0 +1,46 @@ +// 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_APP_CXFA_FFCHECKBUTTON_H_ +#define XFA_FXFA_APP_CXFA_FFCHECKBUTTON_H_ + +#include "xfa/fxfa/app/cxfa_fffield.h" +#include "xfa/fxfa/cxfa_ffpageview.h" + +class CXFA_FFCheckButton : public CXFA_FFField { + public: + explicit CXFA_FFCheckButton(CXFA_WidgetAcc* pDataAcc); + ~CXFA_FFCheckButton() override; + + // CXFA_FFField + void RenderWidget(CFX_Graphics* pGS, + CFX_Matrix* pMatrix, + uint32_t dwStatus) override; + + bool LoadWidget() override; + bool PerformLayout() override; + bool UpdateFWLData() override; + void UpdateWidgetProperty() override; + bool OnLButtonUp(uint32_t dwFlags, const CFX_PointF& point) override; + void OnProcessMessage(CFWL_Message* pMessage) override; + void OnProcessEvent(CFWL_Event* pEvent) override; + void OnDrawWidget(CFX_Graphics* pGraphics, + const CFX_Matrix* pMatrix = nullptr) override; + + void SetFWLCheckState(XFA_CHECKSTATE eCheckState); + + private: + bool CommitData() override; + bool IsDataChanged() override; + void CapLeftRightPlacement(CXFA_Margin mgCap); + void AddUIMargin(int32_t iCapPlacement); + XFA_CHECKSTATE FWLState2XFAState(); + + IFWL_WidgetDelegate* m_pOldDelegate; + CFX_RectF m_rtCheckBox; +}; + +#endif // XFA_FXFA_APP_CXFA_FFCHECKBUTTON_H_ diff --git a/xfa/fxfa/app/cxfa_ffcombobox.cpp b/xfa/fxfa/app/cxfa_ffcombobox.cpp new file mode 100644 index 0000000000..91de16e9c3 --- /dev/null +++ b/xfa/fxfa/app/cxfa_ffcombobox.cpp @@ -0,0 +1,360 @@ +// 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/app/cxfa_ffcombobox.h" + +#include +#include + +#include "xfa/fwl/cfwl_combobox.h" +#include "xfa/fwl/cfwl_eventselectchanged.h" +#include "xfa/fwl/cfwl_notedriver.h" +#include "xfa/fxfa/cxfa_eventparam.h" +#include "xfa/fxfa/cxfa_ffdocview.h" + +namespace { + +CFWL_ComboBox* ToComboBox(CFWL_Widget* widget) { + return static_cast(widget); +} + +} // namespace + +CXFA_FFComboBox::CXFA_FFComboBox(CXFA_WidgetAcc* pDataAcc) + : CXFA_FFField(pDataAcc), m_pOldDelegate(nullptr) {} + +CXFA_FFComboBox::~CXFA_FFComboBox() {} + +CFX_RectF CXFA_FFComboBox::GetBBox(uint32_t dwStatus, bool bDrawFocus) { + return bDrawFocus ? CFX_RectF() : CXFA_FFWidget::GetBBox(dwStatus); +} + +bool CXFA_FFComboBox::PtInActiveRect(const CFX_PointF& point) { + auto* pComboBox = ToComboBox(m_pNormalWidget.get()); + return pComboBox && pComboBox->GetBBox().Contains(point); +} + +bool CXFA_FFComboBox::LoadWidget() { + auto pNew = pdfium::MakeUnique(GetFWLApp()); + CFWL_ComboBox* pComboBox = pNew.get(); + m_pNormalWidget = std::move(pNew); + m_pNormalWidget->SetLayoutItem(this); + + CFWL_NoteDriver* pNoteDriver = + m_pNormalWidget->GetOwnerApp()->GetNoteDriver(); + pNoteDriver->RegisterEventTarget(m_pNormalWidget.get(), + m_pNormalWidget.get()); + m_pOldDelegate = m_pNormalWidget->GetDelegate(); + m_pNormalWidget->SetDelegate(this); + m_pNormalWidget->LockUpdate(); + + for (const auto& label : m_pDataAcc->GetChoiceListItems(false)) + pComboBox->AddString(label.AsStringC()); + + std::vector iSelArray = m_pDataAcc->GetSelectedItems(); + if (!iSelArray.empty()) { + pComboBox->SetCurSel(iSelArray.front()); + } else { + CFX_WideString wsText; + m_pDataAcc->GetValue(wsText, XFA_VALUEPICTURE_Raw); + pComboBox->SetEditText(wsText); + } + + UpdateWidgetProperty(); + m_pNormalWidget->UnlockUpdate(); + return CXFA_FFField::LoadWidget(); +} + +void CXFA_FFComboBox::UpdateWidgetProperty() { + auto* pComboBox = ToComboBox(m_pNormalWidget.get()); + if (!pComboBox) + return; + + uint32_t dwExtendedStyle = 0; + uint32_t dwEditStyles = + FWL_STYLEEXT_EDT_ReadOnly | FWL_STYLEEXT_EDT_LastLineHeight; + dwExtendedStyle |= UpdateUIProperty(); + if (m_pDataAcc->IsChoiceListAllowTextEntry()) { + dwEditStyles &= ~FWL_STYLEEXT_EDT_ReadOnly; + dwExtendedStyle |= FWL_STYLEEXT_CMB_DropDown; + } + if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open || + !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) { + dwEditStyles |= FWL_STYLEEXT_EDT_ReadOnly; + dwExtendedStyle |= FWL_STYLEEXT_CMB_ReadOnly; + } + dwExtendedStyle |= GetAlignment(); + m_pNormalWidget->ModifyStylesEx(dwExtendedStyle, 0xFFFFFFFF); + + if (m_pDataAcc->GetHorizontalScrollPolicy() != XFA_ATTRIBUTEENUM_Off) + dwEditStyles |= FWL_STYLEEXT_EDT_AutoHScroll; + + pComboBox->EditModifyStylesEx(dwEditStyles, 0xFFFFFFFF); +} + +bool CXFA_FFComboBox::OnRButtonUp(uint32_t dwFlags, const CFX_PointF& point) { + if (!CXFA_FFField::OnRButtonUp(dwFlags, point)) + return false; + + GetDoc()->GetDocEnvironment()->PopupMenu(this, point); + return true; +} + +bool CXFA_FFComboBox::OnKillFocus(CXFA_FFWidget* pNewWidget) { + if (!ProcessCommittedData()) + UpdateFWLData(); + + CXFA_FFField::OnKillFocus(pNewWidget); + return true; +} + +void CXFA_FFComboBox::OpenDropDownList() { + ToComboBox(m_pNormalWidget.get())->OpenDropDownList(true); +} + +bool CXFA_FFComboBox::CommitData() { + return m_pDataAcc->SetValue(m_wsNewValue, XFA_VALUEPICTURE_Raw); +} + +bool CXFA_FFComboBox::IsDataChanged() { + auto* pFWLcombobox = ToComboBox(m_pNormalWidget.get()); + CFX_WideString wsText = pFWLcombobox->GetEditText(); + int32_t iCursel = pFWLcombobox->GetCurSel(); + if (iCursel >= 0) { + CFX_WideString wsSel = pFWLcombobox->GetTextByIndex(iCursel); + if (wsSel == wsText) + m_pDataAcc->GetChoiceListItem(wsText, iCursel, true); + } + + CFX_WideString wsOldValue; + m_pDataAcc->GetValue(wsOldValue, XFA_VALUEPICTURE_Raw); + if (wsOldValue == wsText) + return false; + + m_wsNewValue = wsText; + return true; +} + +void CXFA_FFComboBox::FWLEventSelChange(CXFA_EventParam* pParam) { + pParam->m_eType = XFA_EVENT_Change; + pParam->m_pTarget = m_pDataAcc.Get(); + pParam->m_wsNewText = ToComboBox(m_pNormalWidget.get())->GetEditText(); + m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Change, pParam); +} + +uint32_t CXFA_FFComboBox::GetAlignment() { + CXFA_Para para = m_pDataAcc->GetPara(); + if (!para) + return 0; + + uint32_t dwExtendedStyle = 0; + switch (para.GetHorizontalAlign()) { + case XFA_ATTRIBUTEENUM_Center: + dwExtendedStyle |= + FWL_STYLEEXT_CMB_EditHCenter | FWL_STYLEEXT_CMB_ListItemCenterAlign; + break; + case XFA_ATTRIBUTEENUM_Justify: + dwExtendedStyle |= FWL_STYLEEXT_CMB_EditJustified; + break; + case XFA_ATTRIBUTEENUM_JustifyAll: + break; + case XFA_ATTRIBUTEENUM_Radix: + break; + case XFA_ATTRIBUTEENUM_Right: + break; + default: + dwExtendedStyle |= + FWL_STYLEEXT_CMB_EditHNear | FWL_STYLEEXT_CMB_ListItemLeftAlign; + break; + } + + switch (para.GetVerticalAlign()) { + case XFA_ATTRIBUTEENUM_Middle: + dwExtendedStyle |= FWL_STYLEEXT_CMB_EditVCenter; + break; + case XFA_ATTRIBUTEENUM_Bottom: + dwExtendedStyle |= FWL_STYLEEXT_CMB_EditVFar; + break; + default: + dwExtendedStyle |= FWL_STYLEEXT_CMB_EditVNear; + break; + } + return dwExtendedStyle; +} + +bool CXFA_FFComboBox::UpdateFWLData() { + auto* pComboBox = ToComboBox(m_pNormalWidget.get()); + if (!pComboBox) + return false; + + std::vector iSelArray = m_pDataAcc->GetSelectedItems(); + if (!iSelArray.empty()) { + pComboBox->SetCurSel(iSelArray.front()); + } else { + CFX_WideString wsText; + pComboBox->SetCurSel(-1); + m_pDataAcc->GetValue(wsText, XFA_VALUEPICTURE_Raw); + pComboBox->SetEditText(wsText); + } + pComboBox->Update(); + return true; +} + +bool CXFA_FFComboBox::CanUndo() { + return m_pDataAcc->IsChoiceListAllowTextEntry() && + ToComboBox(m_pNormalWidget.get())->EditCanUndo(); +} + +bool CXFA_FFComboBox::CanRedo() { + return m_pDataAcc->IsChoiceListAllowTextEntry() && + ToComboBox(m_pNormalWidget.get())->EditCanRedo(); +} + +bool CXFA_FFComboBox::Undo() { + return m_pDataAcc->IsChoiceListAllowTextEntry() && + ToComboBox(m_pNormalWidget.get())->EditUndo(); +} + +bool CXFA_FFComboBox::Redo() { + return m_pDataAcc->IsChoiceListAllowTextEntry() && + ToComboBox(m_pNormalWidget.get())->EditRedo(); +} + +bool CXFA_FFComboBox::CanCopy() { + return ToComboBox(m_pNormalWidget.get())->EditCanCopy(); +} + +bool CXFA_FFComboBox::CanCut() { + return m_pDataAcc->GetAccess() == XFA_ATTRIBUTEENUM_Open && + m_pDataAcc->IsChoiceListAllowTextEntry() && + ToComboBox(m_pNormalWidget.get())->EditCanCut(); +} + +bool CXFA_FFComboBox::CanPaste() { + return m_pDataAcc->IsChoiceListAllowTextEntry() && + m_pDataAcc->GetAccess() == XFA_ATTRIBUTEENUM_Open; +} + +bool CXFA_FFComboBox::CanSelectAll() { + return ToComboBox(m_pNormalWidget.get())->EditCanSelectAll(); +} + +bool CXFA_FFComboBox::Copy(CFX_WideString& wsCopy) { + return ToComboBox(m_pNormalWidget.get())->EditCopy(wsCopy); +} + +bool CXFA_FFComboBox::Cut(CFX_WideString& wsCut) { + return m_pDataAcc->IsChoiceListAllowTextEntry() && + ToComboBox(m_pNormalWidget.get())->EditCut(wsCut); +} + +bool CXFA_FFComboBox::Paste(const CFX_WideString& wsPaste) { + return m_pDataAcc->IsChoiceListAllowTextEntry() && + ToComboBox(m_pNormalWidget.get())->EditPaste(wsPaste); +} + +void CXFA_FFComboBox::SelectAll() { + ToComboBox(m_pNormalWidget.get())->EditSelectAll(); +} + +void CXFA_FFComboBox::Delete() { + ToComboBox(m_pNormalWidget.get())->EditDelete(); +} + +void CXFA_FFComboBox::DeSelect() { + ToComboBox(m_pNormalWidget.get())->EditDeSelect(); +} + +void CXFA_FFComboBox::SetItemState(int32_t nIndex, bool bSelected) { + ToComboBox(m_pNormalWidget.get())->SetCurSel(bSelected ? nIndex : -1); + m_pNormalWidget->Update(); + AddInvalidateRect(); +} + +void CXFA_FFComboBox::InsertItem(const CFX_WideStringC& wsLabel, + int32_t nIndex) { + ToComboBox(m_pNormalWidget.get())->AddString(wsLabel); + m_pNormalWidget->Update(); + AddInvalidateRect(); +} + +void CXFA_FFComboBox::DeleteItem(int32_t nIndex) { + if (nIndex < 0) + ToComboBox(m_pNormalWidget.get())->RemoveAll(); + else + ToComboBox(m_pNormalWidget.get())->RemoveAt(nIndex); + + m_pNormalWidget->Update(); + AddInvalidateRect(); +} + +void CXFA_FFComboBox::OnTextChanged(CFWL_Widget* pWidget, + const CFX_WideString& wsChanged) { + CXFA_EventParam eParam; + m_pDataAcc->GetValue(eParam.m_wsPrevText, XFA_VALUEPICTURE_Raw); + eParam.m_wsChange = wsChanged; + FWLEventSelChange(&eParam); +} + +void CXFA_FFComboBox::OnSelectChanged(CFWL_Widget* pWidget, bool bLButtonUp) { + CXFA_EventParam eParam; + m_pDataAcc->GetValue(eParam.m_wsPrevText, XFA_VALUEPICTURE_Raw); + FWLEventSelChange(&eParam); + if (m_pDataAcc->GetChoiceListCommitOn() == XFA_ATTRIBUTEENUM_Select && + bLButtonUp) { + m_pDocView->SetFocusWidgetAcc(nullptr); + } +} + +void CXFA_FFComboBox::OnPreOpen(CFWL_Widget* pWidget) { + CXFA_EventParam eParam; + eParam.m_eType = XFA_EVENT_PreOpen; + eParam.m_pTarget = m_pDataAcc.Get(); + m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_PreOpen, &eParam); +} + +void CXFA_FFComboBox::OnPostOpen(CFWL_Widget* pWidget) { + CXFA_EventParam eParam; + eParam.m_eType = XFA_EVENT_PostOpen; + eParam.m_pTarget = m_pDataAcc.Get(); + m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_PostOpen, &eParam); +} + +void CXFA_FFComboBox::OnProcessMessage(CFWL_Message* pMessage) { + m_pOldDelegate->OnProcessMessage(pMessage); +} + +void CXFA_FFComboBox::OnProcessEvent(CFWL_Event* pEvent) { + CXFA_FFField::OnProcessEvent(pEvent); + switch (pEvent->GetType()) { + case CFWL_Event::Type::SelectChanged: { + auto* postEvent = static_cast(pEvent); + OnSelectChanged(m_pNormalWidget.get(), postEvent->bLButtonUp); + break; + } + case CFWL_Event::Type::EditChanged: { + CFX_WideString wsChanged; + OnTextChanged(m_pNormalWidget.get(), wsChanged); + break; + } + case CFWL_Event::Type::PreDropDown: { + OnPreOpen(m_pNormalWidget.get()); + break; + } + case CFWL_Event::Type::PostDropDown: { + OnPostOpen(m_pNormalWidget.get()); + break; + } + default: + break; + } + m_pOldDelegate->OnProcessEvent(pEvent); +} + +void CXFA_FFComboBox::OnDrawWidget(CFX_Graphics* pGraphics, + const CFX_Matrix* pMatrix) { + m_pOldDelegate->OnDrawWidget(pGraphics, pMatrix); +} diff --git a/xfa/fxfa/app/cxfa_ffcombobox.h b/xfa/fxfa/app/cxfa_ffcombobox.h new file mode 100644 index 0000000000..048521f5e0 --- /dev/null +++ b/xfa/fxfa/app/cxfa_ffcombobox.h @@ -0,0 +1,69 @@ +// 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_APP_CXFA_FFCOMBOBOX_H_ +#define XFA_FXFA_APP_CXFA_FFCOMBOBOX_H_ + +#include "xfa/fxfa/app/cxfa_fffield.h" + +class CXFA_FFComboBox : public CXFA_FFField { + public: + explicit CXFA_FFComboBox(CXFA_WidgetAcc* pDataAcc); + ~CXFA_FFComboBox() override; + + // CXFA_FFField + CFX_RectF GetBBox(uint32_t dwStatus, bool bDrawFocus = false) override; + bool LoadWidget() override; + void UpdateWidgetProperty() override; + bool OnRButtonUp(uint32_t dwFlags, const CFX_PointF& point) override; + bool OnKillFocus(CXFA_FFWidget* pNewWidget) override; + bool CanUndo() override; + bool CanRedo() override; + bool Undo() override; + bool Redo() override; + + bool CanCopy() override; + bool CanCut() override; + bool CanPaste() override; + bool CanSelectAll() override; + bool Copy(CFX_WideString& wsCopy) override; + bool Cut(CFX_WideString& wsCut) override; + bool Paste(const CFX_WideString& wsPaste) override; + void SelectAll() override; + void Delete() override; + void DeSelect() override; + + // IFWL_WidgetDelegate + void OnProcessMessage(CFWL_Message* pMessage) override; + void OnProcessEvent(CFWL_Event* pEvent) override; + void OnDrawWidget(CFX_Graphics* pGraphics, + const CFX_Matrix* pMatrix = nullptr) override; + + virtual void OpenDropDownList(); + + void OnTextChanged(CFWL_Widget* pWidget, const CFX_WideString& wsChanged); + void OnSelectChanged(CFWL_Widget* pWidget, bool bLButtonUp); + void OnPreOpen(CFWL_Widget* pWidget); + void OnPostOpen(CFWL_Widget* pWidget); + void SetItemState(int32_t nIndex, bool bSelected); + void InsertItem(const CFX_WideStringC& wsLabel, int32_t nIndex); + void DeleteItem(int32_t nIndex); + + private: + // CXFA_FFField + bool PtInActiveRect(const CFX_PointF& point) override; + bool CommitData() override; + bool UpdateFWLData() override; + bool IsDataChanged() override; + + uint32_t GetAlignment(); + void FWLEventSelChange(CXFA_EventParam* pParam); + + CFX_WideString m_wsNewValue; + IFWL_WidgetDelegate* m_pOldDelegate; +}; + +#endif // XFA_FXFA_APP_CXFA_FFCOMBOBOX_H_ diff --git a/xfa/fxfa/app/cxfa_ffdatetimeedit.cpp b/xfa/fxfa/app/cxfa_ffdatetimeedit.cpp new file mode 100644 index 0000000000..10a7b189f6 --- /dev/null +++ b/xfa/fxfa/app/cxfa_ffdatetimeedit.cpp @@ -0,0 +1,213 @@ +// 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/app/cxfa_ffdatetimeedit.h" + +#include + +#include "xfa/fwl/cfwl_datetimepicker.h" +#include "xfa/fwl/cfwl_eventselectchanged.h" +#include "xfa/fwl/cfwl_notedriver.h" +#include "xfa/fwl/cfwl_widget.h" +#include "xfa/fxfa/cxfa_eventparam.h" +#include "xfa/fxfa/parser/cxfa_localevalue.h" + +CXFA_FFDateTimeEdit::CXFA_FFDateTimeEdit(CXFA_WidgetAcc* pDataAcc) + : CXFA_FFTextEdit(pDataAcc) {} + +CXFA_FFDateTimeEdit::~CXFA_FFDateTimeEdit() {} + +CFX_RectF CXFA_FFDateTimeEdit::GetBBox(uint32_t dwStatus, bool bDrawFocus) { + if (bDrawFocus) + return CFX_RectF(); + return CXFA_FFWidget::GetBBox(dwStatus); +} + +bool CXFA_FFDateTimeEdit::PtInActiveRect(const CFX_PointF& point) { + auto* pPicker = static_cast(m_pNormalWidget.get()); + return pPicker && pPicker->GetBBox().Contains(point); +} + +bool CXFA_FFDateTimeEdit::LoadWidget() { + auto pNewPicker = pdfium::MakeUnique(GetFWLApp()); + CFWL_DateTimePicker* pWidget = pNewPicker.get(); + m_pNormalWidget = std::move(pNewPicker); + m_pNormalWidget->SetLayoutItem(this); + + CFWL_NoteDriver* pNoteDriver = + m_pNormalWidget->GetOwnerApp()->GetNoteDriver(); + pNoteDriver->RegisterEventTarget(m_pNormalWidget.get(), + m_pNormalWidget.get()); + m_pOldDelegate = m_pNormalWidget->GetDelegate(); + m_pNormalWidget->SetDelegate(this); + m_pNormalWidget->LockUpdate(); + + CFX_WideString wsText; + m_pDataAcc->GetValue(wsText, XFA_VALUEPICTURE_Display); + pWidget->SetEditText(wsText); + if (CXFA_Value value = m_pDataAcc->GetFormValue()) { + switch (value.GetChildValueClassID()) { + case XFA_Element::Date: { + if (!wsText.IsEmpty()) { + CXFA_LocaleValue lcValue = XFA_GetLocaleValue(m_pDataAcc.Get()); + CFX_DateTime date = lcValue.GetDate(); + if (date.IsSet()) + pWidget->SetCurSel(date.GetYear(), date.GetMonth(), date.GetDay()); + } + } break; + default: + break; + } + } + UpdateWidgetProperty(); + m_pNormalWidget->UnlockUpdate(); + return CXFA_FFField::LoadWidget(); +} + +void CXFA_FFDateTimeEdit::UpdateWidgetProperty() { + CFWL_DateTimePicker* pWidget = + static_cast(m_pNormalWidget.get()); + if (!pWidget) + return; + + uint32_t dwExtendedStyle = FWL_STYLEEXT_DTP_ShortDateFormat; + dwExtendedStyle |= UpdateUIProperty(); + dwExtendedStyle |= GetAlignment(); + m_pNormalWidget->ModifyStylesEx(dwExtendedStyle, 0xFFFFFFFF); + uint32_t dwEditStyles = FWL_STYLEEXT_EDT_LastLineHeight; + int32_t iNumCells = m_pDataAcc->GetNumberOfCells(); + if (iNumCells > 0) { + dwEditStyles |= FWL_STYLEEXT_EDT_CombText; + pWidget->SetEditLimit(iNumCells); + } + if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open || + !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) { + dwEditStyles |= FWL_STYLEEXT_EDT_ReadOnly; + } + if (m_pDataAcc->GetHorizontalScrollPolicy() != XFA_ATTRIBUTEENUM_Off) + dwEditStyles |= FWL_STYLEEXT_EDT_AutoHScroll; + + pWidget->ModifyEditStylesEx(dwEditStyles, 0xFFFFFFFF); +} + +uint32_t CXFA_FFDateTimeEdit::GetAlignment() { + CXFA_Para para = m_pDataAcc->GetPara(); + if (!para) + return 0; + + uint32_t dwExtendedStyle = 0; + switch (para.GetHorizontalAlign()) { + case XFA_ATTRIBUTEENUM_Center: + dwExtendedStyle |= FWL_STYLEEXT_DTP_EditHCenter; + break; + case XFA_ATTRIBUTEENUM_Justify: + dwExtendedStyle |= FWL_STYLEEXT_DTP_EditJustified; + break; + case XFA_ATTRIBUTEENUM_JustifyAll: + case XFA_ATTRIBUTEENUM_Radix: + break; + case XFA_ATTRIBUTEENUM_Right: + dwExtendedStyle |= FWL_STYLEEXT_DTP_EditHFar; + break; + default: + dwExtendedStyle |= FWL_STYLEEXT_DTP_EditHNear; + break; + } + + switch (para.GetVerticalAlign()) { + case XFA_ATTRIBUTEENUM_Middle: + dwExtendedStyle |= FWL_STYLEEXT_DTP_EditVCenter; + break; + case XFA_ATTRIBUTEENUM_Bottom: + dwExtendedStyle |= FWL_STYLEEXT_DTP_EditVFar; + break; + default: + dwExtendedStyle |= FWL_STYLEEXT_DTP_EditVNear; + break; + } + return dwExtendedStyle; +} + +bool CXFA_FFDateTimeEdit::CommitData() { + auto* pPicker = static_cast(m_pNormalWidget.get()); + if (!m_pDataAcc->SetValue(pPicker->GetEditText(), XFA_VALUEPICTURE_Edit)) + return false; + + m_pDataAcc->UpdateUIDisplay(this); + return true; +} + +bool CXFA_FFDateTimeEdit::UpdateFWLData() { + if (!m_pNormalWidget) + return false; + + XFA_VALUEPICTURE eType = XFA_VALUEPICTURE_Display; + if (IsFocused()) + eType = XFA_VALUEPICTURE_Edit; + + CFX_WideString wsText; + m_pDataAcc->GetValue(wsText, eType); + + auto* normalWidget = static_cast(m_pNormalWidget.get()); + normalWidget->SetEditText(wsText); + if (IsFocused() && !wsText.IsEmpty()) { + CXFA_LocaleValue lcValue = XFA_GetLocaleValue(m_pDataAcc.Get()); + CFX_DateTime date = lcValue.GetDate(); + if (lcValue.IsValid()) { + if (date.IsSet()) + normalWidget->SetCurSel(date.GetYear(), date.GetMonth(), date.GetDay()); + } + } + m_pNormalWidget->Update(); + return true; +} + +bool CXFA_FFDateTimeEdit::IsDataChanged() { + if (m_dwStatus & XFA_WidgetStatus_TextEditValueChanged) + return true; + + CFX_WideString wsText = + static_cast(m_pNormalWidget.get())->GetEditText(); + CFX_WideString wsOldValue; + m_pDataAcc->GetValue(wsOldValue, XFA_VALUEPICTURE_Edit); + return wsOldValue != wsText; +} + +void CXFA_FFDateTimeEdit::OnSelectChanged(CFWL_Widget* pWidget, + int32_t iYear, + int32_t iMonth, + int32_t iDay) { + CFX_WideString wsPicture; + m_pDataAcc->GetPictureContent(wsPicture, XFA_VALUEPICTURE_Edit); + + CXFA_LocaleValue date(XFA_VT_DATE, GetDoc()->GetXFADoc()->GetLocalMgr()); + date.SetDate(CFX_DateTime(iYear, iMonth, iDay, 0, 0, 0, 0)); + + CFX_WideString wsDate; + date.FormatPatterns(wsDate, wsPicture, m_pDataAcc->GetLocal(), + XFA_VALUEPICTURE_Edit); + + auto* pDateTime = static_cast(m_pNormalWidget.get()); + pDateTime->SetEditText(wsDate); + pDateTime->Update(); + GetDoc()->GetDocEnvironment()->SetFocusWidget(GetDoc(), nullptr); + + CXFA_EventParam eParam; + eParam.m_eType = XFA_EVENT_Change; + eParam.m_pTarget = m_pDataAcc.Get(); + m_pDataAcc->GetValue(eParam.m_wsNewText, XFA_VALUEPICTURE_Raw); + m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Change, &eParam); +} + +void CXFA_FFDateTimeEdit::OnProcessEvent(CFWL_Event* pEvent) { + if (pEvent->GetType() == CFWL_Event::Type::SelectChanged) { + auto* event = static_cast(pEvent); + OnSelectChanged(m_pNormalWidget.get(), event->iYear, event->iMonth, + event->iDay); + return; + } + CXFA_FFTextEdit::OnProcessEvent(pEvent); +} diff --git a/xfa/fxfa/app/cxfa_ffdatetimeedit.h b/xfa/fxfa/app/cxfa_ffdatetimeedit.h new file mode 100644 index 0000000000..c62f657fab --- /dev/null +++ b/xfa/fxfa/app/cxfa_ffdatetimeedit.h @@ -0,0 +1,47 @@ +// 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_APP_CXFA_FFDATETIMEEDIT_H_ +#define XFA_FXFA_APP_CXFA_FFDATETIMEEDIT_H_ + +#include "core/fxcrt/fx_coordinates.h" +#include "xfa/fxfa/app/cxfa_fftextedit.h" + +enum XFA_DATETIMETYPE { + XFA_DATETIMETYPE_Date = 0, + XFA_DATETIMETYPE_Time, + XFA_DATETIMETYPE_DateAndTime +}; + +class CFWL_Event; +class CFWL_Widget; + +class CXFA_FFDateTimeEdit : public CXFA_FFTextEdit { + public: + explicit CXFA_FFDateTimeEdit(CXFA_WidgetAcc* pDataAcc); + ~CXFA_FFDateTimeEdit() override; + + // CXFA_FFTextEdit + CFX_RectF GetBBox(uint32_t dwStatus, bool bDrawFocus = false) override; + bool LoadWidget() override; + void UpdateWidgetProperty() override; + void OnProcessEvent(CFWL_Event* pEvent) override; + + void OnSelectChanged(CFWL_Widget* pWidget, + int32_t iYear, + int32_t iMonth, + int32_t iDay); + + private: + bool PtInActiveRect(const CFX_PointF& point) override; + bool CommitData() override; + bool UpdateFWLData() override; + bool IsDataChanged() override; + + uint32_t GetAlignment(); +}; + +#endif // XFA_FXFA_APP_CXFA_FFDATETIMEEDIT_H_ diff --git a/xfa/fxfa/app/cxfa_ffdraw.cpp b/xfa/fxfa/app/cxfa_ffdraw.cpp new file mode 100644 index 0000000000..5736e77352 --- /dev/null +++ b/xfa/fxfa/app/cxfa_ffdraw.cpp @@ -0,0 +1,16 @@ +// 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/app/cxfa_ffdraw.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) {} + +CXFA_FFDraw::~CXFA_FFDraw() {} diff --git a/xfa/fxfa/app/cxfa_ffdraw.h b/xfa/fxfa/app/cxfa_ffdraw.h new file mode 100644 index 0000000000..2a65ad0a78 --- /dev/null +++ b/xfa/fxfa/app/cxfa_ffdraw.h @@ -0,0 +1,19 @@ +// 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_APP_CXFA_FFDRAW_H_ +#define XFA_FXFA_APP_CXFA_FFDRAW_H_ + +#include "xfa/fxfa/cxfa_ffpageview.h" +#include "xfa/fxfa/cxfa_ffwidget.h" + +class CXFA_FFDraw : public CXFA_FFWidget { + public: + explicit CXFA_FFDraw(CXFA_WidgetAcc* pDataAcc); + ~CXFA_FFDraw() override; +}; + +#endif // XFA_FXFA_APP_CXFA_FFDRAW_H_ diff --git a/xfa/fxfa/app/cxfa_ffexclgroup.cpp b/xfa/fxfa/app/cxfa_ffexclgroup.cpp new file mode 100644 index 0000000000..60f0202120 --- /dev/null +++ b/xfa/fxfa/app/cxfa_ffexclgroup.cpp @@ -0,0 +1,30 @@ +// 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/app/cxfa_ffexclgroup.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) {} + +CXFA_FFExclGroup::~CXFA_FFExclGroup() {} + +void CXFA_FFExclGroup::RenderWidget(CFX_Graphics* pGS, + CFX_Matrix* pMatrix, + uint32_t dwStatus) { + if (!IsMatchVisibleStatus(dwStatus)) + return; + + CFX_Matrix mtRotate = GetRotateMatrix(); + if (pMatrix) + mtRotate.Concat(*pMatrix); + + CXFA_FFWidget::RenderWidget(pGS, &mtRotate, dwStatus); +} diff --git a/xfa/fxfa/app/cxfa_ffexclgroup.h b/xfa/fxfa/app/cxfa_ffexclgroup.h new file mode 100644 index 0000000000..4b66b94712 --- /dev/null +++ b/xfa/fxfa/app/cxfa_ffexclgroup.h @@ -0,0 +1,24 @@ +// 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_APP_CXFA_FFEXCLGROUP_H_ +#define XFA_FXFA_APP_CXFA_FFEXCLGROUP_H_ + +#include "xfa/fxfa/cxfa_ffpageview.h" +#include "xfa/fxfa/cxfa_ffwidget.h" + +class CXFA_FFExclGroup : public CXFA_FFWidget { + public: + explicit CXFA_FFExclGroup(CXFA_WidgetAcc* pDataAcc); + ~CXFA_FFExclGroup() override; + + // CXFA_FFWidget + void RenderWidget(CFX_Graphics* pGS, + CFX_Matrix* pMatrix, + uint32_t dwStatus) override; +}; + +#endif // XFA_FXFA_APP_CXFA_FFEXCLGROUP_H_ diff --git a/xfa/fxfa/app/cxfa_fffield.cpp b/xfa/fxfa/app/cxfa_fffield.cpp new file mode 100644 index 0000000000..fe56917cb6 --- /dev/null +++ b/xfa/fxfa/app/cxfa_fffield.cpp @@ -0,0 +1,785 @@ +// 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/app/cxfa_fffield.h" + +#include "xfa/fwl/cfwl_edit.h" +#include "xfa/fwl/cfwl_eventmouse.h" +#include "xfa/fwl/cfwl_messagekey.h" +#include "xfa/fwl/cfwl_messagekillfocus.h" +#include "xfa/fwl/cfwl_messagemouse.h" +#include "xfa/fwl/cfwl_messagemousewheel.h" +#include "xfa/fwl/cfwl_messagesetfocus.h" +#include "xfa/fwl/cfwl_picturebox.h" +#include "xfa/fwl/cfwl_widgetmgr.h" +#include "xfa/fxfa/app/cxfa_fwltheme.h" +#include "xfa/fxfa/app/cxfa_textlayout.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/cxfa_node.h" +#include "xfa/fxgraphics/cfx_color.h" +#include "xfa/fxgraphics/cfx_path.h" + +namespace { + +CXFA_FFField* ToField(CXFA_LayoutItem* widget) { + return static_cast(widget); +} + +} // namespace + +CXFA_FFField::CXFA_FFField(CXFA_WidgetAcc* pDataAcc) + : CXFA_FFWidget(pDataAcc), m_pNormalWidget(nullptr) {} + +CXFA_FFField::~CXFA_FFField() { + CXFA_FFField::UnloadWidget(); +} + +CFX_RectF CXFA_FFField::GetBBox(uint32_t dwStatus, bool bDrawFocus) { + if (!bDrawFocus) + return CXFA_FFWidget::GetBBox(dwStatus); + + XFA_Element type = m_pDataAcc->GetUIType(); + if (type != XFA_Element::Button && type != XFA_Element::CheckButton && + type != XFA_Element::ImageEdit && type != XFA_Element::Signature && + type != XFA_Element::ChoiceList) { + return CFX_RectF(); + } + + CFX_RectF rtBox = m_rtUI; + GetRotateMatrix().TransformRect(rtBox); + return rtBox; +} + +void CXFA_FFField::RenderWidget(CFX_Graphics* pGS, + CFX_Matrix* pMatrix, + uint32_t dwStatus) { + if (!IsMatchVisibleStatus(dwStatus)) + return; + + CFX_Matrix mtRotate = GetRotateMatrix(); + if (pMatrix) + mtRotate.Concat(*pMatrix); + + CXFA_FFWidget::RenderWidget(pGS, &mtRotate, dwStatus); + CXFA_Border borderUI = m_pDataAcc->GetUIBorder(); + DrawBorder(pGS, borderUI, m_rtUI, &mtRotate); + RenderCaption(pGS, &mtRotate); + DrawHighlight(pGS, &mtRotate, dwStatus, false); + + CFX_RectF rtWidget = m_pNormalWidget->GetWidgetRect(); + CFX_Matrix mt(1, 0, 0, 1, rtWidget.left, rtWidget.top); + mt.Concat(mtRotate); + GetApp()->GetWidgetMgrDelegate()->OnDrawWidget(m_pNormalWidget.get(), pGS, + &mt); +} + +void CXFA_FFField::DrawHighlight(CFX_Graphics* pGS, + CFX_Matrix* pMatrix, + uint32_t dwStatus, + bool bEllipse) { + if (m_rtUI.IsEmpty() || !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) + return; + + if (!(dwStatus & XFA_WidgetStatus_Highlight) || + m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open) { + return; + } + + CXFA_FFDoc* pDoc = GetDoc(); + CFX_Color crHighlight(pDoc->GetDocEnvironment()->GetHighlightColor(pDoc)); + pGS->SetFillColor(&crHighlight); + CFX_Path path; + if (bEllipse) + path.AddEllipse(m_rtUI); + else + path.AddRectangle(m_rtUI.left, m_rtUI.top, m_rtUI.width, m_rtUI.height); + + pGS->FillPath(&path, FXFILL_WINDING, pMatrix); +} + +void CXFA_FFField::DrawFocus(CFX_Graphics* pGS, CFX_Matrix* pMatrix) { + if (!(m_dwStatus & XFA_WidgetStatus_Focused)) + return; + + CFX_Color cr(0xFF000000); + pGS->SetStrokeColor(&cr); + + float DashPattern[2] = {1, 1}; + pGS->SetLineDash(0.0f, DashPattern, 2); + pGS->SetLineWidth(0, false); + + CFX_Path path; + path.AddRectangle(m_rtUI.left, m_rtUI.top, m_rtUI.width, m_rtUI.height); + pGS->StrokePath(&path, pMatrix); +} + +void CXFA_FFField::SetFWLThemeProvider() { + if (m_pNormalWidget) + m_pNormalWidget->SetThemeProvider(GetApp()->GetFWLTheme()); +} + +bool CXFA_FFField::IsLoaded() { + return m_pNormalWidget && CXFA_FFWidget::IsLoaded(); +} + +bool CXFA_FFField::LoadWidget() { + SetFWLThemeProvider(); + m_pDataAcc->LoadCaption(); + PerformLayout(); + return true; +} + +void CXFA_FFField::UnloadWidget() { + m_pNormalWidget.reset(); +} + +void CXFA_FFField::SetEditScrollOffset() { + XFA_Element eType = m_pDataAcc->GetUIType(); + if (eType != XFA_Element::TextEdit && eType != XFA_Element::NumericEdit && + eType != XFA_Element::PasswordEdit) { + return; + } + + float fScrollOffset = 0; + CXFA_FFField* pPrev = ToField(GetPrev()); + if (pPrev) { + CFX_RectF rtMargin = m_pDataAcc->GetUIMargin(); + fScrollOffset = -rtMargin.top; + } + + while (pPrev) { + fScrollOffset += pPrev->m_rtUI.height; + pPrev = ToField(pPrev->GetPrev()); + } + static_cast(m_pNormalWidget.get()) + ->SetScrollOffset(fScrollOffset); +} + +bool CXFA_FFField::PerformLayout() { + CXFA_FFWidget::PerformLayout(); + CapPlacement(); + LayoutCaption(); + SetFWLRect(); + SetEditScrollOffset(); + if (m_pNormalWidget) + m_pNormalWidget->Update(); + return true; +} + +void CXFA_FFField::CapPlacement() { + CFX_RectF rtWidget = GetRectWithoutRotate(); + CXFA_Margin mgWidget = m_pDataAcc->GetMargin(); + if (mgWidget) { + CXFA_LayoutItem* pItem = this; + float fLeftInset = 0, fRightInset = 0, fTopInset = 0, fBottomInset = 0; + mgWidget.GetLeftInset(fLeftInset); + mgWidget.GetRightInset(fRightInset); + mgWidget.GetTopInset(fTopInset); + mgWidget.GetBottomInset(fBottomInset); + if (!pItem->GetPrev() && !pItem->GetNext()) { + rtWidget.Deflate(fLeftInset, fTopInset, fRightInset, fBottomInset); + } else { + if (!pItem->GetPrev()) + rtWidget.Deflate(fLeftInset, fTopInset, fRightInset, 0); + else if (!pItem->GetNext()) + rtWidget.Deflate(fLeftInset, 0, fRightInset, fBottomInset); + else + rtWidget.Deflate(fLeftInset, 0, fRightInset, 0); + } + } + + XFA_ATTRIBUTEENUM iCapPlacement = XFA_ATTRIBUTEENUM_Unknown; + float fCapReserve = 0; + CXFA_Caption caption = m_pDataAcc->GetCaption(); + if (caption && caption.GetPresence() != XFA_ATTRIBUTEENUM_Hidden) { + iCapPlacement = (XFA_ATTRIBUTEENUM)caption.GetPlacementType(); + if (iCapPlacement == XFA_ATTRIBUTEENUM_Top && GetPrev()) { + m_rtCaption.Reset(); + } else if (iCapPlacement == XFA_ATTRIBUTEENUM_Bottom && GetNext()) { + m_rtCaption.Reset(); + } else { + fCapReserve = caption.GetReserve(); + CXFA_LayoutItem* pItem = this; + if (!pItem->GetPrev() && !pItem->GetNext()) { + m_rtCaption = rtWidget; + } else { + pItem = pItem->GetFirst(); + m_rtCaption = pItem->GetRect(false); + pItem = pItem->GetNext(); + while (pItem) { + m_rtCaption.height += pItem->GetRect(false).Height(); + pItem = pItem->GetNext(); + } + XFA_RectWidthoutMargin(m_rtCaption, mgWidget); + } + + CXFA_TextLayout* pCapTextLayout = m_pDataAcc->GetCaptionTextLayout(); + if (fCapReserve <= 0 && pCapTextLayout) { + CFX_SizeF size; + CFX_SizeF minSize; + CFX_SizeF maxSize; + pCapTextLayout->CalcSize(minSize, maxSize, size); + if (iCapPlacement == XFA_ATTRIBUTEENUM_Top || + iCapPlacement == XFA_ATTRIBUTEENUM_Bottom) { + fCapReserve = size.height; + } else { + fCapReserve = size.width; + } + } + } + } + + m_rtUI = rtWidget; + switch (iCapPlacement) { + case XFA_ATTRIBUTEENUM_Left: { + m_rtCaption.width = fCapReserve; + CapLeftRightPlacement(caption, rtWidget, iCapPlacement); + m_rtUI.width -= fCapReserve; + m_rtUI.left += fCapReserve; + break; + } + case XFA_ATTRIBUTEENUM_Top: { + m_rtCaption.height = fCapReserve; + CapTopBottomPlacement(caption, rtWidget, iCapPlacement); + m_rtUI.top += fCapReserve; + m_rtUI.height -= fCapReserve; + break; + } + case XFA_ATTRIBUTEENUM_Right: { + m_rtCaption.left = m_rtCaption.right() - fCapReserve; + m_rtCaption.width = fCapReserve; + CapLeftRightPlacement(caption, rtWidget, iCapPlacement); + m_rtUI.width -= fCapReserve; + break; + } + case XFA_ATTRIBUTEENUM_Bottom: { + m_rtCaption.top = m_rtCaption.bottom() - fCapReserve; + m_rtCaption.height = fCapReserve; + CapTopBottomPlacement(caption, rtWidget, iCapPlacement); + m_rtUI.height -= fCapReserve; + break; + } + case XFA_ATTRIBUTEENUM_Inline: + break; + default: + break; + } + + CXFA_Border borderUI = m_pDataAcc->GetUIBorder(); + if (borderUI) { + CXFA_Margin margin = borderUI.GetMargin(); + if (margin) + XFA_RectWidthoutMargin(m_rtUI, margin); + } + m_rtUI.Normalize(); +} + +void CXFA_FFField::CapTopBottomPlacement(CXFA_Caption caption, + const CFX_RectF& rtWidget, + int32_t iCapPlacement) { + CFX_RectF rtUIMargin = m_pDataAcc->GetUIMargin(); + m_rtCaption.left += rtUIMargin.left; + if (CXFA_Margin mgCap = caption.GetMargin()) { + XFA_RectWidthoutMargin(m_rtCaption, mgCap); + if (m_rtCaption.height < 0) + m_rtCaption.top += m_rtCaption.height; + } + + float fWidth = rtUIMargin.left + rtUIMargin.width; + float fHeight = m_rtCaption.height + rtUIMargin.top + rtUIMargin.height; + if (fWidth > rtWidget.width) + m_rtUI.width += fWidth - rtWidget.width; + + if (fHeight == XFA_DEFAULTUI_HEIGHT && m_rtUI.height < XFA_MINUI_HEIGHT) { + m_rtUI.height = XFA_MINUI_HEIGHT; + m_rtCaption.top += rtUIMargin.top + rtUIMargin.height; + } else if (fHeight > rtWidget.height) { + m_rtUI.height += fHeight - rtWidget.height; + if (iCapPlacement == XFA_ATTRIBUTEENUM_Bottom) + m_rtCaption.top += fHeight - rtWidget.height; + } +} + +void CXFA_FFField::CapLeftRightPlacement(CXFA_Caption caption, + const CFX_RectF& rtWidget, + int32_t iCapPlacement) { + CFX_RectF rtUIMargin = m_pDataAcc->GetUIMargin(); + m_rtCaption.top += rtUIMargin.top; + m_rtCaption.height -= rtUIMargin.top; + if (CXFA_Margin mgCap = caption.GetMargin()) { + XFA_RectWidthoutMargin(m_rtCaption, mgCap); + if (m_rtCaption.height < 0) + m_rtCaption.top += m_rtCaption.height; + } + + float fWidth = m_rtCaption.width + rtUIMargin.left + rtUIMargin.width; + float fHeight = rtUIMargin.top + rtUIMargin.height; + if (fWidth > rtWidget.width) { + m_rtUI.width += fWidth - rtWidget.width; + if (iCapPlacement == XFA_ATTRIBUTEENUM_Right) + m_rtCaption.left += fWidth - rtWidget.width; + } + + if (fHeight == XFA_DEFAULTUI_HEIGHT && m_rtUI.height < XFA_MINUI_HEIGHT) { + m_rtUI.height = XFA_MINUI_HEIGHT; + m_rtCaption.top += rtUIMargin.top + rtUIMargin.height; + } else if (fHeight > rtWidget.height) { + m_rtUI.height += fHeight - rtWidget.height; + } +} + +void CXFA_FFField::UpdateFWL() { + if (m_pNormalWidget) + m_pNormalWidget->Update(); +} + +uint32_t CXFA_FFField::UpdateUIProperty() { + CXFA_Node* pUiNode = m_pDataAcc->GetUIChild(); + if (pUiNode && pUiNode->GetElementType() == XFA_Element::DefaultUi) + return FWL_STYLEEXT_EDT_ReadOnly; + return 0; +} + +void CXFA_FFField::SetFWLRect() { + if (!m_pNormalWidget) + return; + + CFX_RectF rtUi = m_rtUI; + if (rtUi.width < 1.0) + rtUi.width = 1.0; + if (!m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) { + float fFontSize = m_pDataAcc->GetFontSize(); + if (rtUi.height < fFontSize) + rtUi.height = fFontSize; + } + m_pNormalWidget->SetWidgetRect(rtUi); +} + +bool CXFA_FFField::OnMouseEnter() { + if (!m_pNormalWidget) + return false; + + CFWL_MessageMouse ms(nullptr, m_pNormalWidget.get()); + ms.m_dwCmd = FWL_MouseCommand::Enter; + TranslateFWLMessage(&ms); + return true; +} + +bool CXFA_FFField::OnMouseExit() { + if (!m_pNormalWidget) + return false; + + CFWL_MessageMouse ms(nullptr, m_pNormalWidget.get()); + ms.m_dwCmd = FWL_MouseCommand::Leave; + TranslateFWLMessage(&ms); + return true; +} + +CFX_PointF CXFA_FFField::FWLToClient(const CFX_PointF& point) { + return m_pNormalWidget ? point - m_pNormalWidget->GetWidgetRect().TopLeft() + : point; +} + +bool CXFA_FFField::OnLButtonDown(uint32_t dwFlags, const CFX_PointF& point) { + if (!m_pNormalWidget) + return false; + if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open || + !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) { + return false; + } + if (!PtInActiveRect(point)) + return false; + + SetButtonDown(true); + CFWL_MessageMouse ms(nullptr, m_pNormalWidget.get()); + ms.m_dwCmd = FWL_MouseCommand::LeftButtonDown; + ms.m_dwFlags = dwFlags; + ms.m_pos = FWLToClient(point); + TranslateFWLMessage(&ms); + return true; +} + +bool CXFA_FFField::OnLButtonUp(uint32_t dwFlags, const CFX_PointF& point) { + if (!m_pNormalWidget) + return false; + if (!IsButtonDown()) + return false; + + SetButtonDown(false); + CFWL_MessageMouse ms(nullptr, m_pNormalWidget.get()); + ms.m_dwCmd = FWL_MouseCommand::LeftButtonUp; + ms.m_dwFlags = dwFlags; + ms.m_pos = FWLToClient(point); + TranslateFWLMessage(&ms); + return true; +} + +bool CXFA_FFField::OnLButtonDblClk(uint32_t dwFlags, const CFX_PointF& point) { + if (!m_pNormalWidget) + return false; + + CFWL_MessageMouse ms(nullptr, m_pNormalWidget.get()); + ms.m_dwCmd = FWL_MouseCommand::LeftButtonDblClk; + ms.m_dwFlags = dwFlags; + ms.m_pos = FWLToClient(point); + TranslateFWLMessage(&ms); + return true; +} + +bool CXFA_FFField::OnMouseMove(uint32_t dwFlags, const CFX_PointF& point) { + if (!m_pNormalWidget) + return false; + + CFWL_MessageMouse ms(nullptr, m_pNormalWidget.get()); + ms.m_dwCmd = FWL_MouseCommand::Move; + ms.m_dwFlags = dwFlags; + ms.m_pos = FWLToClient(point); + TranslateFWLMessage(&ms); + return true; +} + +bool CXFA_FFField::OnMouseWheel(uint32_t dwFlags, + int16_t zDelta, + const CFX_PointF& point) { + if (!m_pNormalWidget) + return false; + + CFWL_MessageMouseWheel ms(nullptr, m_pNormalWidget.get()); + ms.m_dwFlags = dwFlags; + ms.m_pos = FWLToClient(point); + ms.m_delta = CFX_PointF(zDelta, 0); + TranslateFWLMessage(&ms); + return true; +} + +bool CXFA_FFField::OnRButtonDown(uint32_t dwFlags, const CFX_PointF& point) { + if (!m_pNormalWidget) + return false; + if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open || + !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) { + return false; + } + if (!PtInActiveRect(point)) + return false; + + SetButtonDown(true); + + CFWL_MessageMouse ms(nullptr, m_pNormalWidget.get()); + ms.m_dwCmd = FWL_MouseCommand::RightButtonDown; + ms.m_dwFlags = dwFlags; + ms.m_pos = FWLToClient(point); + TranslateFWLMessage(&ms); + return true; +} + +bool CXFA_FFField::OnRButtonUp(uint32_t dwFlags, const CFX_PointF& point) { + if (!m_pNormalWidget) + return false; + if (!IsButtonDown()) + return false; + + SetButtonDown(false); + CFWL_MessageMouse ms(nullptr, m_pNormalWidget.get()); + ms.m_dwCmd = FWL_MouseCommand::RightButtonUp; + ms.m_dwFlags = dwFlags; + ms.m_pos = FWLToClient(point); + TranslateFWLMessage(&ms); + return true; +} + +bool CXFA_FFField::OnRButtonDblClk(uint32_t dwFlags, const CFX_PointF& point) { + if (!m_pNormalWidget) + return false; + + CFWL_MessageMouse ms(nullptr, m_pNormalWidget.get()); + ms.m_dwCmd = FWL_MouseCommand::RightButtonDblClk; + ms.m_dwFlags = dwFlags; + ms.m_pos = FWLToClient(point); + TranslateFWLMessage(&ms); + return true; +} + +bool CXFA_FFField::OnSetFocus(CXFA_FFWidget* pOldWidget) { + CXFA_FFWidget::OnSetFocus(pOldWidget); + if (!m_pNormalWidget) + return false; + + CFWL_MessageSetFocus ms(nullptr, m_pNormalWidget.get()); + TranslateFWLMessage(&ms); + m_dwStatus |= XFA_WidgetStatus_Focused; + AddInvalidateRect(); + return true; +} + +bool CXFA_FFField::OnKillFocus(CXFA_FFWidget* pNewWidget) { + if (!m_pNormalWidget) + return CXFA_FFWidget::OnKillFocus(pNewWidget); + + CFWL_MessageKillFocus ms(nullptr, m_pNormalWidget.get()); + TranslateFWLMessage(&ms); + m_dwStatus &= ~XFA_WidgetStatus_Focused; + AddInvalidateRect(); + CXFA_FFWidget::OnKillFocus(pNewWidget); + return true; +} + +bool CXFA_FFField::OnKeyDown(uint32_t dwKeyCode, uint32_t dwFlags) { + if (!m_pNormalWidget || !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) + return false; + + CFWL_MessageKey ms(nullptr, m_pNormalWidget.get()); + ms.m_dwCmd = FWL_KeyCommand::KeyDown; + ms.m_dwFlags = dwFlags; + ms.m_dwKeyCode = dwKeyCode; + TranslateFWLMessage(&ms); + return true; +} + +bool CXFA_FFField::OnKeyUp(uint32_t dwKeyCode, uint32_t dwFlags) { + if (!m_pNormalWidget || !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) + return false; + + CFWL_MessageKey ms(nullptr, m_pNormalWidget.get()); + ms.m_dwCmd = FWL_KeyCommand::KeyUp; + ms.m_dwFlags = dwFlags; + ms.m_dwKeyCode = dwKeyCode; + TranslateFWLMessage(&ms); + return true; +} + +bool CXFA_FFField::OnChar(uint32_t dwChar, uint32_t dwFlags) { + if (!m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) + return false; + if (dwChar == FWL_VKEY_Tab) + return true; + if (!m_pNormalWidget) + return false; + if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open) + return false; + + CFWL_MessageKey ms(nullptr, m_pNormalWidget.get()); + ms.m_dwCmd = FWL_KeyCommand::Char; + ms.m_dwFlags = dwFlags; + ms.m_dwKeyCode = dwChar; + TranslateFWLMessage(&ms); + return true; +} + +FWL_WidgetHit CXFA_FFField::OnHitTest(const CFX_PointF& point) { + if (m_pNormalWidget && + m_pNormalWidget->HitTest(FWLToClient(point)) != FWL_WidgetHit::Unknown) { + return FWL_WidgetHit::Client; + } + + if (!GetRectWithoutRotate().Contains(point)) + return FWL_WidgetHit::Unknown; + if (m_rtCaption.Contains(point)) + return FWL_WidgetHit::Titlebar; + return FWL_WidgetHit::Border; +} + +bool CXFA_FFField::OnSetCursor(const CFX_PointF& point) { + return true; +} + +bool CXFA_FFField::PtInActiveRect(const CFX_PointF& point) { + return m_pNormalWidget && m_pNormalWidget->GetWidgetRect().Contains(point); +} + +void CXFA_FFField::LayoutCaption() { + CXFA_TextLayout* pCapTextLayout = m_pDataAcc->GetCaptionTextLayout(); + if (!pCapTextLayout) + return; + + float fHeight = 0; + pCapTextLayout->Layout(CFX_SizeF(m_rtCaption.width, m_rtCaption.height), + &fHeight); + if (m_rtCaption.height < fHeight) + m_rtCaption.height = fHeight; +} + +void CXFA_FFField::RenderCaption(CFX_Graphics* pGS, CFX_Matrix* pMatrix) { + CXFA_TextLayout* pCapTextLayout = m_pDataAcc->GetCaptionTextLayout(); + if (!pCapTextLayout) + return; + + CXFA_Caption caption = m_pDataAcc->GetCaption(); + if (!caption || caption.GetPresence() != XFA_ATTRIBUTEENUM_Visible) + return; + + if (!pCapTextLayout->IsLoaded()) + pCapTextLayout->Layout(CFX_SizeF(m_rtCaption.width, m_rtCaption.height)); + + CFX_RectF rtClip = m_rtCaption; + rtClip.Intersect(GetRectWithoutRotate()); + CFX_RenderDevice* pRenderDevice = pGS->GetRenderDevice(); + CFX_Matrix mt(1, 0, 0, 1, m_rtCaption.left, m_rtCaption.top); + if (pMatrix) { + pMatrix->TransformRect(rtClip); + mt.Concat(*pMatrix); + } + pCapTextLayout->DrawString(pRenderDevice, mt, rtClip); +} + +bool CXFA_FFField::ProcessCommittedData() { + if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open) + return false; + if (!IsDataChanged()) + return false; + if (CalculateOverride() != 1) + return false; + if (!CommitData()) + return false; + + m_pDocView->SetChangeMark(); + m_pDocView->AddValidateWidget(m_pDataAcc.Get()); + return true; +} + +int32_t CXFA_FFField::CalculateOverride() { + CXFA_WidgetAcc* pAcc = m_pDataAcc->GetExclGroup(); + if (!pAcc) + return CalculateWidgetAcc(m_pDataAcc.Get()); + if (CalculateWidgetAcc(pAcc) == 0) + return 0; + + CXFA_Node* pNode = pAcc->GetExclGroupFirstMember(); + if (!pNode) + return 1; + + CXFA_WidgetAcc* pWidgetAcc = nullptr; + while (pNode) { + pWidgetAcc = static_cast(pNode->GetWidgetData()); + if (!pWidgetAcc) + return 1; + if (CalculateWidgetAcc(pWidgetAcc) == 0) + return 0; + + pNode = pWidgetAcc->GetExclGroupNextMember(pNode); + } + return 1; +} + +int32_t CXFA_FFField::CalculateWidgetAcc(CXFA_WidgetAcc* pAcc) { + CXFA_Calculate calc = pAcc->GetCalculate(); + if (!calc) + return 1; + + XFA_VERSION version = pAcc->GetDoc()->GetXFADoc()->GetCurVersionMode(); + switch (calc.GetOverride()) { + case XFA_ATTRIBUTEENUM_Error: { + if (version <= XFA_VERSION_204) + return 1; + + IXFA_AppProvider* pAppProvider = GetApp()->GetAppProvider(); + if (pAppProvider) { + pAppProvider->MsgBox(L"You are not allowed to modify this field.", + L"Calculate Override", XFA_MBICON_Warning, + XFA_MB_OK); + } + return 0; + } + case XFA_ATTRIBUTEENUM_Warning: { + if (version <= XFA_VERSION_204) { + CXFA_Script script = calc.GetScript(); + if (!script) + return 1; + + CFX_WideString wsExpression; + script.GetExpression(wsExpression); + if (wsExpression.IsEmpty()) + return 1; + } + + if (pAcc->GetNode()->IsUserInteractive()) + return 1; + + IXFA_AppProvider* pAppProvider = GetApp()->GetAppProvider(); + if (!pAppProvider) + return 0; + + CFX_WideString wsMessage; + calc.GetMessageText(wsMessage); + if (!wsMessage.IsEmpty()) + wsMessage += L"\r\n"; + + wsMessage += L"Are you sure you want to modify this field?"; + if (pAppProvider->MsgBox(wsMessage, L"Calculate Override", + XFA_MBICON_Warning, XFA_MB_YesNo) == XFA_IDYes) { + pAcc->GetNode()->SetFlag(XFA_NodeFlag_UserInteractive, false); + return 1; + } + return 0; + } + case XFA_ATTRIBUTEENUM_Ignore: + return 0; + case XFA_ATTRIBUTEENUM_Disabled: + pAcc->GetNode()->SetFlag(XFA_NodeFlag_UserInteractive, false); + return 1; + default: + return 1; + } +} + +bool CXFA_FFField::CommitData() { + return false; +} + +bool CXFA_FFField::IsDataChanged() { + return false; +} + +void CXFA_FFField::TranslateFWLMessage(CFWL_Message* pMessage) { + GetApp()->GetWidgetMgrDelegate()->OnProcessMessageToForm(pMessage); +} + +void CXFA_FFField::OnProcessMessage(CFWL_Message* pMessage) {} + +void CXFA_FFField::OnProcessEvent(CFWL_Event* pEvent) { + switch (pEvent->GetType()) { + case CFWL_Event::Type::Mouse: { + CFWL_EventMouse* event = static_cast(pEvent); + if (event->m_dwCmd == FWL_MouseCommand::Enter) { + CXFA_EventParam eParam; + eParam.m_eType = XFA_EVENT_MouseEnter; + eParam.m_pTarget = m_pDataAcc.Get(); + m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_MouseEnter, &eParam); + } else if (event->m_dwCmd == FWL_MouseCommand::Leave) { + CXFA_EventParam eParam; + eParam.m_eType = XFA_EVENT_MouseExit; + eParam.m_pTarget = m_pDataAcc.Get(); + m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_MouseExit, &eParam); + } else if (event->m_dwCmd == FWL_MouseCommand::LeftButtonDown) { + CXFA_EventParam eParam; + eParam.m_eType = XFA_EVENT_MouseDown; + eParam.m_pTarget = m_pDataAcc.Get(); + m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_MouseDown, &eParam); + } else if (event->m_dwCmd == FWL_MouseCommand::LeftButtonUp) { + CXFA_EventParam eParam; + eParam.m_eType = XFA_EVENT_MouseUp; + eParam.m_pTarget = m_pDataAcc.Get(); + m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_MouseUp, &eParam); + } + break; + } + case CFWL_Event::Type::Click: { + CXFA_EventParam eParam; + eParam.m_eType = XFA_EVENT_Click; + eParam.m_pTarget = m_pDataAcc.Get(); + m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Click, &eParam); + break; + } + default: + break; + } +} + +void CXFA_FFField::OnDrawWidget(CFX_Graphics* pGraphics, + const CFX_Matrix* pMatrix) {} diff --git a/xfa/fxfa/app/cxfa_fffield.h b/xfa/fxfa/app/cxfa_fffield.h new file mode 100644 index 0000000000..3799eb39b7 --- /dev/null +++ b/xfa/fxfa/app/cxfa_fffield.h @@ -0,0 +1,99 @@ +// 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_APP_CXFA_FFFIELD_H_ +#define XFA_FXFA_APP_CXFA_FFFIELD_H_ + +#include + +#include "xfa/fwl/cfwl_widget.h" +#include "xfa/fwl/ifwl_widgetdelegate.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 + +class CXFA_FFField : public CXFA_FFWidget, public IFWL_WidgetDelegate { + public: + explicit CXFA_FFField(CXFA_WidgetAcc* pDataAcc); + ~CXFA_FFField() override; + + // CXFA_FFWidget + CFX_RectF GetBBox(uint32_t dwStatus, bool bDrawFocus = false) override; + void RenderWidget(CFX_Graphics* pGS, + CFX_Matrix* pMatrix, + uint32_t dwStatus) override; + bool IsLoaded() override; + bool LoadWidget() override; + void UnloadWidget() override; + bool PerformLayout() override; + bool OnMouseEnter() override; + bool OnMouseExit() override; + bool OnLButtonDown(uint32_t dwFlags, const CFX_PointF& point) override; + bool OnLButtonUp(uint32_t dwFlags, const CFX_PointF& point) override; + bool OnLButtonDblClk(uint32_t dwFlags, const CFX_PointF& point) override; + bool OnMouseMove(uint32_t dwFlags, const CFX_PointF& point) override; + bool OnMouseWheel(uint32_t dwFlags, + int16_t zDelta, + const CFX_PointF& point) override; + bool OnRButtonDown(uint32_t dwFlags, const CFX_PointF& point) override; + bool OnRButtonUp(uint32_t dwFlags, const CFX_PointF& point) override; + bool OnRButtonDblClk(uint32_t dwFlags, const CFX_PointF& point) override; + + bool OnSetFocus(CXFA_FFWidget* pOldWidget) override; + bool OnKillFocus(CXFA_FFWidget* pNewWidget) override; + bool OnKeyDown(uint32_t dwKeyCode, uint32_t dwFlags) override; + bool OnKeyUp(uint32_t dwKeyCode, uint32_t dwFlags) override; + bool OnChar(uint32_t dwChar, uint32_t dwFlags) override; + FWL_WidgetHit OnHitTest(const CFX_PointF& point) override; + bool OnSetCursor(const CFX_PointF& point) override; + + // IFWL_WidgetDelegate + void OnProcessMessage(CFWL_Message* pMessage) override; + void OnProcessEvent(CFWL_Event* pEvent) override; + void OnDrawWidget(CFX_Graphics* pGraphics, + const CFX_Matrix* pMatrix = nullptr) override; + + void UpdateFWL(); + uint32_t UpdateUIProperty(); + + protected: + bool PtInActiveRect(const CFX_PointF& point) override; + + virtual void SetFWLRect(); + void SetFWLThemeProvider(); + CFWL_Widget* GetNormalWidget() { return m_pNormalWidget.get(); } + CFX_PointF FWLToClient(const CFX_PointF& point); + void LayoutCaption(); + void RenderCaption(CFX_Graphics* pGS, CFX_Matrix* pMatrix); + + int32_t CalculateOverride(); + int32_t CalculateWidgetAcc(CXFA_WidgetAcc* pAcc); + bool ProcessCommittedData(); + virtual bool CommitData(); + virtual bool IsDataChanged(); + void DrawHighlight(CFX_Graphics* pGS, + CFX_Matrix* pMatrix, + uint32_t dwStatus, + bool bEllipse); + void DrawFocus(CFX_Graphics* pGS, CFX_Matrix* pMatrix); + void TranslateFWLMessage(CFWL_Message* pMessage); + void CapPlacement(); + void CapTopBottomPlacement(CXFA_Caption caption, + const CFX_RectF& rtWidget, + int32_t iCapPlacement); + void CapLeftRightPlacement(CXFA_Caption caption, + const CFX_RectF& rtWidget, + int32_t iCapPlacement); + void SetEditScrollOffset(); + + std::unique_ptr m_pNormalWidget; + CFX_RectF m_rtUI; + CFX_RectF m_rtCaption; +}; + +#endif // XFA_FXFA_APP_CXFA_FFFIELD_H_ diff --git a/xfa/fxfa/app/cxfa_ffimage.cpp b/xfa/fxfa/app/cxfa_ffimage.cpp new file mode 100644 index 0000000000..f8a6668a91 --- /dev/null +++ b/xfa/fxfa/app/cxfa_ffimage.cpp @@ -0,0 +1,72 @@ +// 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/app/cxfa_ffimage.h" + +#include "xfa/fxfa/app/cxfa_ffdraw.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) {} + +CXFA_FFImage::~CXFA_FFImage() { + CXFA_FFImage::UnloadWidget(); +} + +bool CXFA_FFImage::IsLoaded() { + return !!GetDataAcc()->GetImageImage(); +} + +bool CXFA_FFImage::LoadWidget() { + if (GetDataAcc()->GetImageImage()) + return true; + + GetDataAcc()->LoadImageImage(); + return CXFA_FFDraw::LoadWidget(); +} + +void CXFA_FFImage::UnloadWidget() { + GetDataAcc()->SetImageImage(nullptr); +} + +void CXFA_FFImage::RenderWidget(CFX_Graphics* pGS, + CFX_Matrix* pMatrix, + uint32_t dwStatus) { + if (!IsMatchVisibleStatus(dwStatus)) + return; + + CFX_Matrix mtRotate = GetRotateMatrix(); + if (pMatrix) + mtRotate.Concat(*pMatrix); + + CXFA_FFWidget::RenderWidget(pGS, &mtRotate, dwStatus); + + CFX_RetainPtr pDIBitmap = GetDataAcc()->GetImageImage(); + if (!pDIBitmap) + return; + + CFX_RectF rtImage = GetRectWithoutRotate(); + if (CXFA_Margin mgWidget = m_pDataAcc->GetMargin()) + XFA_RectWidthoutMargin(rtImage, mgWidget); + + int32_t iHorzAlign = XFA_ATTRIBUTEENUM_Left; + int32_t iVertAlign = XFA_ATTRIBUTEENUM_Top; + if (CXFA_Para para = m_pDataAcc->GetPara()) { + iHorzAlign = para.GetHorizontalAlign(); + iVertAlign = para.GetVerticalAlign(); + } + + CXFA_Value value = m_pDataAcc->GetFormValue(); + CXFA_Image imageObj = value.GetImage(); + int32_t iAspect = imageObj.GetAspect(); + int32_t iImageXDpi = 0; + int32_t iImageYDpi = 0; + m_pDataAcc->GetImageDpi(iImageXDpi, iImageYDpi); + XFA_DrawImage(pGS, rtImage, &mtRotate, pDIBitmap, iAspect, iImageXDpi, + iImageYDpi, iHorzAlign, iVertAlign); +} diff --git a/xfa/fxfa/app/cxfa_ffimage.h b/xfa/fxfa/app/cxfa_ffimage.h new file mode 100644 index 0000000000..1b22fce668 --- /dev/null +++ b/xfa/fxfa/app/cxfa_ffimage.h @@ -0,0 +1,26 @@ +// 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_APP_CXFA_FFIMAGE_H_ +#define XFA_FXFA_APP_CXFA_FFIMAGE_H_ + +#include "xfa/fxfa/app/cxfa_ffdraw.h" + +class CXFA_FFImage : public CXFA_FFDraw { + public: + explicit CXFA_FFImage(CXFA_WidgetAcc* pDataAcc); + ~CXFA_FFImage() override; + + // CXFA_FFWidget + void RenderWidget(CFX_Graphics* pGS, + CFX_Matrix* pMatrix, + uint32_t dwStatus) override; + bool IsLoaded() override; + bool LoadWidget() override; + void UnloadWidget() override; +}; + +#endif // XFA_FXFA_APP_CXFA_FFIMAGE_H_ diff --git a/xfa/fxfa/app/cxfa_ffimageedit.cpp b/xfa/fxfa/app/cxfa_ffimageedit.cpp new file mode 100644 index 0000000000..0b0b6ec853 --- /dev/null +++ b/xfa/fxfa/app/cxfa_ffimageedit.cpp @@ -0,0 +1,143 @@ +// 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/app/cxfa_ffimageedit.h" + +#include + +#include "third_party/base/ptr_util.h" +#include "xfa/fwl/cfwl_app.h" +#include "xfa/fwl/cfwl_messagemouse.h" +#include "xfa/fwl/cfwl_notedriver.h" +#include "xfa/fwl/cfwl_picturebox.h" +#include "xfa/fxfa/app/cxfa_fffield.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) {} + +CXFA_FFImageEdit::~CXFA_FFImageEdit() { + CXFA_FFImageEdit::UnloadWidget(); +} + +bool CXFA_FFImageEdit::LoadWidget() { + auto pNew = pdfium::MakeUnique(GetFWLApp()); + CFWL_PictureBox* pPictureBox = pNew.get(); + m_pNormalWidget = std::move(pNew); + m_pNormalWidget->SetLayoutItem(this); + + CFWL_NoteDriver* pNoteDriver = + m_pNormalWidget->GetOwnerApp()->GetNoteDriver(); + pNoteDriver->RegisterEventTarget(m_pNormalWidget.get(), + m_pNormalWidget.get()); + m_pOldDelegate = pPictureBox->GetDelegate(); + pPictureBox->SetDelegate(this); + + CXFA_FFField::LoadWidget(); + if (!m_pDataAcc->GetImageEditImage()) + UpdateFWLData(); + + return true; +} + +void CXFA_FFImageEdit::UnloadWidget() { + m_pDataAcc->SetImageEditImage(nullptr); + CXFA_FFField::UnloadWidget(); +} + +void CXFA_FFImageEdit::RenderWidget(CFX_Graphics* pGS, + CFX_Matrix* pMatrix, + uint32_t dwStatus) { + if (!IsMatchVisibleStatus(dwStatus)) + return; + + CFX_Matrix mtRotate = GetRotateMatrix(); + if (pMatrix) + mtRotate.Concat(*pMatrix); + + CXFA_FFWidget::RenderWidget(pGS, &mtRotate, dwStatus); + CXFA_Border borderUI = m_pDataAcc->GetUIBorder(); + DrawBorder(pGS, borderUI, m_rtUI, &mtRotate); + RenderCaption(pGS, &mtRotate); + CFX_RetainPtr pDIBitmap = m_pDataAcc->GetImageEditImage(); + if (!pDIBitmap) + return; + + CFX_RectF rtImage = m_pNormalWidget->GetWidgetRect(); + int32_t iHorzAlign = XFA_ATTRIBUTEENUM_Left; + int32_t iVertAlign = XFA_ATTRIBUTEENUM_Top; + if (CXFA_Para para = m_pDataAcc->GetPara()) { + iHorzAlign = para.GetHorizontalAlign(); + iVertAlign = para.GetVerticalAlign(); + } + + int32_t iAspect = XFA_ATTRIBUTEENUM_Fit; + if (CXFA_Value value = m_pDataAcc->GetFormValue()) { + if (CXFA_Image imageObj = value.GetImage()) + iAspect = imageObj.GetAspect(); + } + + int32_t iImageXDpi = 0; + int32_t iImageYDpi = 0; + m_pDataAcc->GetImageEditDpi(iImageXDpi, iImageYDpi); + XFA_DrawImage(pGS, rtImage, &mtRotate, pDIBitmap, iAspect, iImageXDpi, + iImageYDpi, iHorzAlign, iVertAlign); +} + +bool CXFA_FFImageEdit::OnLButtonDown(uint32_t dwFlags, + const CFX_PointF& point) { + if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open) + return false; + if (!PtInActiveRect(point)) + return false; + + SetButtonDown(true); + + CFWL_MessageMouse ms(nullptr, m_pNormalWidget.get()); + ms.m_dwCmd = FWL_MouseCommand::LeftButtonDown; + ms.m_dwFlags = dwFlags; + ms.m_pos = FWLToClient(point); + TranslateFWLMessage(&ms); + return true; +} + +void CXFA_FFImageEdit::SetFWLRect() { + if (!m_pNormalWidget) + return; + + CFX_RectF rtUIMargin = m_pDataAcc->GetUIMargin(); + CFX_RectF rtImage(m_rtUI); + rtImage.Deflate(rtUIMargin.left, rtUIMargin.top, rtUIMargin.width, + rtUIMargin.height); + m_pNormalWidget->SetWidgetRect(rtImage); +} + +bool CXFA_FFImageEdit::CommitData() { + return true; +} + +bool CXFA_FFImageEdit::UpdateFWLData() { + m_pDataAcc->SetImageEditImage(nullptr); + m_pDataAcc->LoadImageEditImage(); + return true; +} + +void CXFA_FFImageEdit::OnProcessMessage(CFWL_Message* pMessage) { + m_pOldDelegate->OnProcessMessage(pMessage); +} + +void CXFA_FFImageEdit::OnProcessEvent(CFWL_Event* pEvent) { + CXFA_FFField::OnProcessEvent(pEvent); + m_pOldDelegate->OnProcessEvent(pEvent); +} + +void CXFA_FFImageEdit::OnDrawWidget(CFX_Graphics* pGraphics, + const CFX_Matrix* pMatrix) { + m_pOldDelegate->OnDrawWidget(pGraphics, pMatrix); +} diff --git a/xfa/fxfa/app/cxfa_ffimageedit.h b/xfa/fxfa/app/cxfa_ffimageedit.h new file mode 100644 index 0000000000..81b45e8de0 --- /dev/null +++ b/xfa/fxfa/app/cxfa_ffimageedit.h @@ -0,0 +1,37 @@ +// 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_APP_CXFA_FFIMAGEEDIT_H_ +#define XFA_FXFA_APP_CXFA_FFIMAGEEDIT_H_ + +#include "xfa/fxfa/app/cxfa_fffield.h" + +class CXFA_FFImageEdit : public CXFA_FFField { + public: + explicit CXFA_FFImageEdit(CXFA_WidgetAcc* pDataAcc); + ~CXFA_FFImageEdit() override; + + // CXFA_FFField + void RenderWidget(CFX_Graphics* pGS, + CFX_Matrix* pMatrix, + uint32_t dwStatus) override; + bool LoadWidget() override; + void UnloadWidget() override; + bool OnLButtonDown(uint32_t dwFlags, const CFX_PointF& point) override; + void OnProcessMessage(CFWL_Message* pMessage) override; + void OnProcessEvent(CFWL_Event* pEvent) override; + void OnDrawWidget(CFX_Graphics* pGraphics, + const CFX_Matrix* pMatrix = nullptr) override; + + private: + void SetFWLRect() override; + bool UpdateFWLData() override; + bool CommitData() override; + + IFWL_WidgetDelegate* m_pOldDelegate; +}; + +#endif // XFA_FXFA_APP_CXFA_FFIMAGEEDIT_H_ diff --git a/xfa/fxfa/app/cxfa_ffline.cpp b/xfa/fxfa/app/cxfa_ffline.cpp new file mode 100644 index 0000000000..67ed7ebd1a --- /dev/null +++ b/xfa/fxfa/app/cxfa_ffline.cpp @@ -0,0 +1,99 @@ +// 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/app/cxfa_ffline.h" + +#include "xfa/fxgraphics/cfx_color.h" +#include "xfa/fxgraphics/cfx_graphics.h" +#include "xfa/fxgraphics/cfx_path.h" + +CXFA_FFLine::CXFA_FFLine(CXFA_WidgetAcc* pDataAcc) : CXFA_FFDraw(pDataAcc) {} + +CXFA_FFLine::~CXFA_FFLine() {} + +void CXFA_FFLine::GetRectFromHand(CFX_RectF& rect, + int32_t iHand, + float fLineWidth) { + float fHalfWidth = fLineWidth / 2.0f; + if (rect.height < 1.0f) { + switch (iHand) { + case XFA_ATTRIBUTEENUM_Left: + rect.top -= fHalfWidth; + break; + case XFA_ATTRIBUTEENUM_Right: + rect.top += fHalfWidth; + } + } else if (rect.width < 1.0f) { + switch (iHand) { + case XFA_ATTRIBUTEENUM_Left: + rect.left += fHalfWidth; + break; + case XFA_ATTRIBUTEENUM_Right: + rect.left += fHalfWidth; + break; + } + } else { + switch (iHand) { + case XFA_ATTRIBUTEENUM_Left: + rect.Inflate(fHalfWidth, fHalfWidth); + break; + case XFA_ATTRIBUTEENUM_Right: + rect.Deflate(fHalfWidth, fHalfWidth); + break; + } + } +} + +void CXFA_FFLine::RenderWidget(CFX_Graphics* pGS, + CFX_Matrix* pMatrix, + uint32_t dwStatus) { + if (!IsMatchVisibleStatus(dwStatus)) + return; + + CXFA_Value value = m_pDataAcc->GetFormValue(); + if (!value) + return; + + CXFA_Line lineObj = value.GetLine(); + FX_ARGB lineColor = 0xFF000000; + int32_t iStrokeType = 0; + float fLineWidth = 1.0f; + int32_t iCap = 0; + CXFA_Edge edge = lineObj.GetEdge(); + if (edge) { + if (edge.GetPresence() != XFA_ATTRIBUTEENUM_Visible) + return; + + lineColor = edge.GetColor(); + iStrokeType = edge.GetStrokeType(); + fLineWidth = edge.GetThickness(); + iCap = edge.GetCapType(); + } + + CFX_Matrix mtRotate = GetRotateMatrix(); + if (pMatrix) + mtRotate.Concat(*pMatrix); + + CFX_RectF rtLine = GetRectWithoutRotate(); + if (CXFA_Margin mgWidget = m_pDataAcc->GetMargin()) + XFA_RectWidthoutMargin(rtLine, mgWidget); + + GetRectFromHand(rtLine, lineObj.GetHand(), fLineWidth); + CFX_Path linePath; + if (lineObj.GetSlope() && rtLine.right() > 0.0f && rtLine.bottom() > 0.0f) + linePath.AddLine(rtLine.TopRight(), rtLine.BottomLeft()); + else + linePath.AddLine(rtLine.TopLeft(), rtLine.BottomRight()); + + CFX_Color color(lineColor); + pGS->SaveGraphState(); + pGS->SetLineWidth(fLineWidth, true); + XFA_StrokeTypeSetLineDash(pGS, iStrokeType, iCap); + pGS->SetStrokeColor(&color); + pGS->SetLineCap(XFA_LineCapToFXGE(iCap)); + pGS->StrokePath(&linePath, &mtRotate); + pGS->RestoreGraphState(); +} diff --git a/xfa/fxfa/app/cxfa_ffline.h b/xfa/fxfa/app/cxfa_ffline.h new file mode 100644 index 0000000000..6803e38285 --- /dev/null +++ b/xfa/fxfa/app/cxfa_ffline.h @@ -0,0 +1,26 @@ +// 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_APP_CXFA_FFLINE_H_ +#define XFA_FXFA_APP_CXFA_FFLINE_H_ + +#include "xfa/fxfa/app/cxfa_ffdraw.h" + +class CXFA_FFLine : public CXFA_FFDraw { + public: + explicit CXFA_FFLine(CXFA_WidgetAcc* pDataAcc); + ~CXFA_FFLine() override; + + // CXFA_FFWidget + void RenderWidget(CFX_Graphics* pGS, + CFX_Matrix* pMatrix, + uint32_t dwStatus) override; + + private: + void GetRectFromHand(CFX_RectF& rect, int32_t iHand, float fLineWidth); +}; + +#endif // XFA_FXFA_APP_CXFA_FFLINE_H_ diff --git a/xfa/fxfa/app/cxfa_fflistbox.cpp b/xfa/fxfa/app/cxfa_fflistbox.cpp new file mode 100644 index 0000000000..dd80325c34 --- /dev/null +++ b/xfa/fxfa/app/cxfa_fflistbox.cpp @@ -0,0 +1,210 @@ +// 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/app/cxfa_fflistbox.h" + +#include +#include +#include + +#include "xfa/fwl/cfwl_listbox.h" +#include "xfa/fwl/cfwl_notedriver.h" +#include "xfa/fwl/cfwl_widget.h" +#include "xfa/fxfa/cxfa_eventparam.h" + +namespace { + +CFWL_ListBox* ToListBox(CFWL_Widget* widget) { + return static_cast(widget); +} + +} // namespace + +CXFA_FFListBox::CXFA_FFListBox(CXFA_WidgetAcc* pDataAcc) + : CXFA_FFField(pDataAcc), m_pOldDelegate(nullptr) {} + +CXFA_FFListBox::~CXFA_FFListBox() { + if (!m_pNormalWidget) + return; + + CFWL_NoteDriver* pNoteDriver = + m_pNormalWidget->GetOwnerApp()->GetNoteDriver(); + pNoteDriver->UnregisterEventTarget(m_pNormalWidget.get()); +} + +bool CXFA_FFListBox::LoadWidget() { + auto pNew = pdfium::MakeUnique( + GetFWLApp(), pdfium::MakeUnique(), nullptr); + CFWL_ListBox* pListBox = pNew.get(); + pListBox->ModifyStyles(FWL_WGTSTYLE_VScroll | FWL_WGTSTYLE_NoBackground, + 0xFFFFFFFF); + m_pNormalWidget = std::move(pNew); + m_pNormalWidget->SetLayoutItem(this); + + CFWL_NoteDriver* pNoteDriver = + m_pNormalWidget->GetOwnerApp()->GetNoteDriver(); + pNoteDriver->RegisterEventTarget(m_pNormalWidget.get(), + m_pNormalWidget.get()); + m_pOldDelegate = m_pNormalWidget->GetDelegate(); + m_pNormalWidget->SetDelegate(this); + m_pNormalWidget->LockUpdate(); + + for (const auto& label : m_pDataAcc->GetChoiceListItems(false)) + pListBox->AddString(label.AsStringC()); + + uint32_t dwExtendedStyle = FWL_STYLEEXT_LTB_ShowScrollBarFocus; + if (m_pDataAcc->GetChoiceListOpen() == XFA_ATTRIBUTEENUM_MultiSelect) + dwExtendedStyle |= FWL_STYLEEXT_LTB_MultiSelection; + + dwExtendedStyle |= GetAlignment(); + m_pNormalWidget->ModifyStylesEx(dwExtendedStyle, 0xFFFFFFFF); + for (int32_t selected : m_pDataAcc->GetSelectedItems()) + pListBox->SetSelItem(pListBox->GetItem(nullptr, selected), true); + + m_pNormalWidget->UnlockUpdate(); + return CXFA_FFField::LoadWidget(); +} + +bool CXFA_FFListBox::OnKillFocus(CXFA_FFWidget* pNewFocus) { + if (!ProcessCommittedData()) + UpdateFWLData(); + + CXFA_FFField::OnKillFocus(pNewFocus); + return true; +} + +bool CXFA_FFListBox::CommitData() { + auto* pListBox = ToListBox(m_pNormalWidget.get()); + std::vector iSelArray; + int32_t iSels = pListBox->CountSelItems(); + for (int32_t i = 0; i < iSels; ++i) + iSelArray.push_back(pListBox->GetSelIndex(i)); + + m_pDataAcc->SetSelectedItems(iSelArray, true, false, true); + return true; +} + +bool CXFA_FFListBox::IsDataChanged() { + std::vector iSelArray = m_pDataAcc->GetSelectedItems(); + int32_t iOldSels = pdfium::CollectionSize(iSelArray); + auto* pListBox = ToListBox(m_pNormalWidget.get()); + int32_t iSels = pListBox->CountSelItems(); + if (iOldSels != iSels) + return true; + + for (int32_t i = 0; i < iSels; ++i) { + CFWL_ListItem* hlistItem = pListBox->GetItem(nullptr, iSelArray[i]); + if (!(hlistItem->GetStates() & FWL_ITEMSTATE_LTB_Selected)) + return true; + } + return false; +} + +uint32_t CXFA_FFListBox::GetAlignment() { + CXFA_Para para = m_pDataAcc->GetPara(); + if (!para) + return 0; + + uint32_t dwExtendedStyle = 0; + switch (para.GetHorizontalAlign()) { + case XFA_ATTRIBUTEENUM_Center: + dwExtendedStyle |= FWL_STYLEEXT_LTB_CenterAlign; + break; + case XFA_ATTRIBUTEENUM_Justify: + break; + case XFA_ATTRIBUTEENUM_JustifyAll: + break; + case XFA_ATTRIBUTEENUM_Radix: + break; + case XFA_ATTRIBUTEENUM_Right: + dwExtendedStyle |= FWL_STYLEEXT_LTB_RightAlign; + break; + default: + dwExtendedStyle |= FWL_STYLEEXT_LTB_LeftAlign; + break; + } + return dwExtendedStyle; +} + +bool CXFA_FFListBox::UpdateFWLData() { + if (!m_pNormalWidget) + return false; + + auto* pListBox = ToListBox(m_pNormalWidget.get()); + std::vector iSelArray = m_pDataAcc->GetSelectedItems(); + std::vector selItemArray(iSelArray.size()); + std::transform(iSelArray.begin(), iSelArray.end(), selItemArray.begin(), + [pListBox](int32_t val) { return pListBox->GetSelItem(val); }); + + pListBox->SetSelItem(pListBox->GetSelItem(-1), false); + for (CFWL_ListItem* pItem : selItemArray) + pListBox->SetSelItem(pItem, true); + + m_pNormalWidget->Update(); + return true; +} + +void CXFA_FFListBox::OnSelectChanged(CFWL_Widget* pWidget) { + CXFA_EventParam eParam; + eParam.m_eType = XFA_EVENT_Change; + eParam.m_pTarget = m_pDataAcc.Get(); + m_pDataAcc->GetValue(eParam.m_wsPrevText, XFA_VALUEPICTURE_Raw); + + auto* pListBox = ToListBox(m_pNormalWidget.get()); + int32_t iSels = pListBox->CountSelItems(); + if (iSels > 0) { + CFWL_ListItem* item = pListBox->GetSelItem(0); + eParam.m_wsNewText = item ? item->GetText() : L""; + } + m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Change, &eParam); +} + +void CXFA_FFListBox::SetItemState(int32_t nIndex, bool bSelected) { + auto* pListBox = ToListBox(m_pNormalWidget.get()); + pListBox->SetSelItem(pListBox->GetSelItem(nIndex), bSelected); + m_pNormalWidget->Update(); + AddInvalidateRect(); +} + +void CXFA_FFListBox::InsertItem(const CFX_WideStringC& wsLabel, + int32_t nIndex) { + CFX_WideString wsTemp(wsLabel); + ToListBox(m_pNormalWidget.get())->AddString(wsTemp.AsStringC()); + m_pNormalWidget->Update(); + AddInvalidateRect(); +} + +void CXFA_FFListBox::DeleteItem(int32_t nIndex) { + auto* pListBox = ToListBox(m_pNormalWidget.get()); + if (nIndex < 0) + pListBox->DeleteAll(); + else + pListBox->DeleteString(pListBox->GetItem(nullptr, nIndex)); + + pListBox->Update(); + AddInvalidateRect(); +} + +void CXFA_FFListBox::OnProcessMessage(CFWL_Message* pMessage) { + m_pOldDelegate->OnProcessMessage(pMessage); +} + +void CXFA_FFListBox::OnProcessEvent(CFWL_Event* pEvent) { + CXFA_FFField::OnProcessEvent(pEvent); + switch (pEvent->GetType()) { + case CFWL_Event::Type::SelectChanged: + OnSelectChanged(m_pNormalWidget.get()); + break; + default: + break; + } + m_pOldDelegate->OnProcessEvent(pEvent); +} + +void CXFA_FFListBox::OnDrawWidget(CFX_Graphics* pGraphics, + const CFX_Matrix* pMatrix) { + m_pOldDelegate->OnDrawWidget(pGraphics, pMatrix); +} diff --git a/xfa/fxfa/app/cxfa_fflistbox.h b/xfa/fxfa/app/cxfa_fflistbox.h new file mode 100644 index 0000000000..6f090af63f --- /dev/null +++ b/xfa/fxfa/app/cxfa_fflistbox.h @@ -0,0 +1,40 @@ +// Copyright 2017 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#ifndef XFA_FXFA_APP_CXFA_FFLISTBOX_H_ +#define XFA_FXFA_APP_CXFA_FFLISTBOX_H_ + +#include "xfa/fxfa/app/cxfa_fffield.h" + +class CXFA_FFListBox : public CXFA_FFField { + public: + explicit CXFA_FFListBox(CXFA_WidgetAcc* pDataAcc); + ~CXFA_FFListBox() override; + + // CXFA_FFField + bool LoadWidget() override; + bool OnKillFocus(CXFA_FFWidget* pNewWidget) override; + void OnProcessMessage(CFWL_Message* pMessage) override; + void OnProcessEvent(CFWL_Event* pEvent) override; + void OnDrawWidget(CFX_Graphics* pGraphics, + const CFX_Matrix* pMatrix = nullptr) override; + + void OnSelectChanged(CFWL_Widget* pWidget); + void SetItemState(int32_t nIndex, bool bSelected); + void InsertItem(const CFX_WideStringC& wsLabel, int32_t nIndex); + void DeleteItem(int32_t nIndex); + + private: + bool CommitData() override; + bool UpdateFWLData() override; + bool IsDataChanged() override; + + uint32_t GetAlignment(); + + IFWL_WidgetDelegate* m_pOldDelegate; +}; + +#endif // XFA_FXFA_APP_CXFA_FFLISTBOX_H_ diff --git a/xfa/fxfa/app/cxfa_ffnotify.cpp b/xfa/fxfa/app/cxfa_ffnotify.cpp new file mode 100644 index 0000000000..a660ffff12 --- /dev/null +++ b/xfa/fxfa/app/cxfa_ffnotify.cpp @@ -0,0 +1,540 @@ +// 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/app/cxfa_ffnotify.h" + +#include "fxjs/cfxjse_value.h" +#include "xfa/fxfa/app/cxfa_ffarc.h" +#include "xfa/fxfa/app/cxfa_ffbarcode.h" +#include "xfa/fxfa/app/cxfa_ffcheckbutton.h" +#include "xfa/fxfa/app/cxfa_ffcombobox.h" +#include "xfa/fxfa/app/cxfa_ffdatetimeedit.h" +#include "xfa/fxfa/app/cxfa_ffdraw.h" +#include "xfa/fxfa/app/cxfa_ffexclgroup.h" +#include "xfa/fxfa/app/cxfa_fffield.h" +#include "xfa/fxfa/app/cxfa_ffimage.h" +#include "xfa/fxfa/app/cxfa_ffimageedit.h" +#include "xfa/fxfa/app/cxfa_ffline.h" +#include "xfa/fxfa/app/cxfa_fflistbox.h" +#include "xfa/fxfa/app/cxfa_ffnumericedit.h" +#include "xfa/fxfa/app/cxfa_ffpasswordedit.h" +#include "xfa/fxfa/app/cxfa_ffpushbutton.h" +#include "xfa/fxfa/app/cxfa_ffrectangle.h" +#include "xfa/fxfa/app/cxfa_ffsignature.h" +#include "xfa/fxfa/app/cxfa_ffsubform.h" +#include "xfa/fxfa/app/cxfa_fftext.h" +#include "xfa/fxfa/app/cxfa_fwladapterwidgetmgr.h" +#include "xfa/fxfa/app/cxfa_textlayout.h" +#include "xfa/fxfa/app/cxfa_textprovider.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" +#include "xfa/fxfa/parser/cxfa_node.h" + +namespace { + +CXFA_WidgetAcc* ToWidgetAcc(void* data) { + return static_cast(data); +} + +CXFA_FFListBox* ToListBox(CXFA_FFWidget* widget) { + return static_cast(widget); +} + +CXFA_FFComboBox* ToComboBox(CXFA_FFWidget* widget) { + return static_cast(widget); +} + +} // namespace + +static void XFA_FFDeleteWidgetAcc(void* pData) { + delete ToWidgetAcc(pData); +} + +static XFA_MAPDATABLOCKCALLBACKINFO gs_XFADeleteWidgetAcc = { + XFA_FFDeleteWidgetAcc, nullptr}; + +CXFA_FFNotify::CXFA_FFNotify(CXFA_FFDoc* pDoc) : m_pDoc(pDoc) {} + +CXFA_FFNotify::~CXFA_FFNotify() {} + +void CXFA_FFNotify::OnPageEvent(CXFA_ContainerLayoutItem* pSender, + uint32_t dwEvent) { + CXFA_FFDocView* pDocView = m_pDoc->GetDocView(pSender->GetLayout()); + if (pDocView) + pDocView->OnPageEvent(pSender, dwEvent); +} + +void CXFA_FFNotify::OnWidgetListItemAdded(CXFA_WidgetData* pSender, + const wchar_t* pLabel, + const wchar_t* pValue, + int32_t iIndex) { + CXFA_WidgetAcc* pWidgetAcc = ToWidgetAcc(pSender); + if (pWidgetAcc->GetUIType() != XFA_Element::ChoiceList) + return; + + CXFA_FFWidget* pWidget = nullptr; + while ((pWidget = pWidgetAcc->GetNextWidget(pWidget)) != nullptr) { + if (pWidget->IsLoaded()) { + if (pWidgetAcc->IsListBox()) + ToListBox(pWidget)->InsertItem(pLabel, iIndex); + else + ToComboBox(pWidget)->InsertItem(pLabel, iIndex); + } + } +} + +void CXFA_FFNotify::OnWidgetListItemRemoved(CXFA_WidgetData* pSender, + int32_t iIndex) { + CXFA_WidgetAcc* pWidgetAcc = ToWidgetAcc(pSender); + if (pWidgetAcc->GetUIType() != XFA_Element::ChoiceList) + return; + + CXFA_FFWidget* pWidget = nullptr; + while ((pWidget = pWidgetAcc->GetNextWidget(pWidget)) != nullptr) { + if (pWidget->IsLoaded()) { + if (pWidgetAcc->IsListBox()) + ToListBox(pWidget)->DeleteItem(iIndex); + else + ToComboBox(pWidget)->DeleteItem(iIndex); + } + } +} + +CXFA_LayoutItem* CXFA_FFNotify::OnCreateLayoutItem(CXFA_Node* pNode) { + CXFA_LayoutProcessor* pLayout = m_pDoc->GetXFADoc()->GetDocLayout(); + CXFA_FFDocView* pDocView = m_pDoc->GetDocView(pLayout); + XFA_Element eType = pNode->GetElementType(); + if (eType == XFA_Element::PageArea) + return new CXFA_FFPageView(pDocView, pNode); + if (eType == XFA_Element::ContentArea) + return new CXFA_ContainerLayoutItem(pNode); + + CXFA_WidgetAcc* pAcc = ToWidgetAcc(pNode->GetWidgetData()); + if (!pAcc) + return new CXFA_ContentLayoutItem(pNode); + + CXFA_FFWidget* pWidget; + switch (pAcc->GetUIType()) { + case XFA_Element::Barcode: + pWidget = new CXFA_FFBarcode(pAcc); + break; + case XFA_Element::Button: + pWidget = new CXFA_FFPushButton(pAcc); + break; + case XFA_Element::CheckButton: + pWidget = new CXFA_FFCheckButton(pAcc); + break; + case XFA_Element::ChoiceList: { + if (pAcc->IsListBox()) + pWidget = new CXFA_FFListBox(pAcc); + else + pWidget = new CXFA_FFComboBox(pAcc); + } break; + case XFA_Element::DateTimeEdit: + pWidget = new CXFA_FFDateTimeEdit(pAcc); + break; + case XFA_Element::ImageEdit: + pWidget = new CXFA_FFImageEdit(pAcc); + break; + case XFA_Element::NumericEdit: + pWidget = new CXFA_FFNumericEdit(pAcc); + break; + case XFA_Element::PasswordEdit: + pWidget = new CXFA_FFPasswordEdit(pAcc); + break; + case XFA_Element::Signature: + pWidget = new CXFA_FFSignature(pAcc); + break; + case XFA_Element::TextEdit: + pWidget = new CXFA_FFTextEdit(pAcc); + break; + case XFA_Element::Arc: + pWidget = new CXFA_FFArc(pAcc); + break; + case XFA_Element::Line: + pWidget = new CXFA_FFLine(pAcc); + break; + case XFA_Element::Rectangle: + pWidget = new CXFA_FFRectangle(pAcc); + break; + case XFA_Element::Text: + pWidget = new CXFA_FFText(pAcc); + break; + case XFA_Element::Image: + pWidget = new CXFA_FFImage(pAcc); + break; + case XFA_Element::Draw: + pWidget = new CXFA_FFDraw(pAcc); + break; + case XFA_Element::Subform: + pWidget = new CXFA_FFSubForm(pAcc); + break; + case XFA_Element::ExclGroup: + pWidget = new CXFA_FFExclGroup(pAcc); + break; + case XFA_Element::DefaultUi: + default: + pWidget = nullptr; + break; + } + + if (pWidget) + pWidget->SetDocView(pDocView); + return pWidget; +} + +void CXFA_FFNotify::StartFieldDrawLayout(CXFA_Node* pItem, + float& fCalcWidth, + float& fCalcHeight) { + CXFA_WidgetAcc* pAcc = ToWidgetAcc(pItem->GetWidgetData()); + if (!pAcc) + return; + + pAcc->StartWidgetLayout(fCalcWidth, fCalcHeight); +} + +bool CXFA_FFNotify::FindSplitPos(CXFA_Node* pItem, + int32_t iBlockIndex, + float& fCalcHeightPos) { + CXFA_WidgetAcc* pAcc = ToWidgetAcc(pItem->GetWidgetData()); + return pAcc && pAcc->FindSplitPos(iBlockIndex, fCalcHeightPos); +} + +bool CXFA_FFNotify::RunScript(CXFA_Node* pScript, CXFA_Node* pFormItem) { + bool bRet = false; + CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); + if (!pDocView) + return bRet; + + CXFA_WidgetAcc* pWidgetAcc = ToWidgetAcc(pFormItem->GetWidgetData()); + if (!pWidgetAcc) + return bRet; + + CXFA_EventParam EventParam; + EventParam.m_eType = XFA_EVENT_Unknown; + CFXJSE_Value* pRetValue = nullptr; + int32_t iRet = + pWidgetAcc->ExecuteScript(CXFA_Script(pScript), &EventParam, &pRetValue); + if (iRet == XFA_EVENTERROR_Success && pRetValue) { + bRet = pRetValue->ToBoolean(); + delete pRetValue; + } + return bRet; +} + +int32_t CXFA_FFNotify::ExecEventByDeepFirst(CXFA_Node* pFormNode, + XFA_EVENTTYPE eEventType, + bool bIsFormReady, + bool bRecursive, + CXFA_WidgetAcc* pExclude) { + CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); + if (!pDocView) + return XFA_EVENTERROR_NotExist; + return pDocView->ExecEventActivityByDeepFirst( + pFormNode, eEventType, bIsFormReady, bRecursive, + pExclude ? pExclude->GetNode() : nullptr); +} + +void CXFA_FFNotify::AddCalcValidate(CXFA_Node* pNode) { + CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); + if (!pDocView) + return; + + CXFA_WidgetAcc* pWidgetAcc = ToWidgetAcc(pNode->GetWidgetData()); + if (!pWidgetAcc) + return; + + pDocView->AddCalculateWidgetAcc(pWidgetAcc); + pDocView->AddValidateWidget(pWidgetAcc); +} + +CXFA_FFDoc* CXFA_FFNotify::GetHDOC() { + return m_pDoc.Get(); +} + +IXFA_DocEnvironment* CXFA_FFNotify::GetDocEnvironment() const { + return m_pDoc->GetDocEnvironment(); +} + +IXFA_AppProvider* CXFA_FFNotify::GetAppProvider() { + return m_pDoc->GetApp()->GetAppProvider(); +} + +CXFA_FFWidgetHandler* CXFA_FFNotify::GetWidgetHandler() { + CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); + return pDocView ? pDocView->GetWidgetHandler() : nullptr; +} + +CXFA_FFWidget* CXFA_FFNotify::GetHWidget(CXFA_LayoutItem* pLayoutItem) { + return XFA_GetWidgetFromLayoutItem(pLayoutItem); +} + +void CXFA_FFNotify::OpenDropDownList(CXFA_FFWidget* hWidget) { + if (hWidget->GetDataAcc()->GetUIType() != XFA_Element::ChoiceList) + return; + + CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); + pDocView->LockUpdate(); + ToComboBox(hWidget)->OpenDropDownList(); + pDocView->UnlockUpdate(); + pDocView->UpdateDocView(); +} + +CFX_WideString CXFA_FFNotify::GetCurrentDateTime() { + CFX_DateTime dataTime; + dataTime.Now(); + + CFX_WideString wsDateTime; + wsDateTime.Format(L"%d%02d%02dT%02d%02d%02d", dataTime.GetYear(), + dataTime.GetMonth(), dataTime.GetDay(), dataTime.GetHour(), + dataTime.GetMinute(), dataTime.GetSecond()); + return wsDateTime; +} + +void CXFA_FFNotify::ResetData(CXFA_WidgetData* pWidgetData) { + CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); + if (!pDocView) + return; + + pDocView->ResetWidgetData(ToWidgetAcc(pWidgetData)); +} + +int32_t CXFA_FFNotify::GetLayoutStatus() { + CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); + return pDocView ? pDocView->GetLayoutStatus() : 0; +} + +void CXFA_FFNotify::RunNodeInitialize(CXFA_Node* pNode) { + CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); + if (!pDocView) + return; + + pDocView->AddNewFormNode(pNode); +} + +void CXFA_FFNotify::RunSubformIndexChange(CXFA_Node* pSubformNode) { + CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); + if (!pDocView) + return; + + pDocView->AddIndexChangedSubform(pSubformNode); +} + +CXFA_Node* CXFA_FFNotify::GetFocusWidgetNode() { + CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); + if (!pDocView) + return nullptr; + + CXFA_WidgetAcc* pAcc = pDocView->GetFocusWidgetAcc(); + return pAcc ? pAcc->GetNode() : nullptr; +} + +void CXFA_FFNotify::SetFocusWidgetNode(CXFA_Node* pNode) { + CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); + if (!pDocView) + return; + + CXFA_WidgetAcc* pAcc = pNode ? ToWidgetAcc(pNode->GetWidgetData()) : nullptr; + pDocView->SetFocusWidgetAcc(pAcc); +} + +void CXFA_FFNotify::OnNodeReady(CXFA_Node* pNode) { + CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); + if (!pDocView) + return; + + XFA_Element eType = pNode->GetElementType(); + if (XFA_IsCreateWidget(eType)) { + CXFA_WidgetAcc* pAcc = new CXFA_WidgetAcc(pDocView, pNode); + pNode->SetObject(XFA_ATTRIBUTE_WidgetData, pAcc, &gs_XFADeleteWidgetAcc); + return; + } + switch (eType) { + case XFA_Element::BindItems: + pDocView->m_BindItems.push_back(pNode); + break; + case XFA_Element::Validate: + pNode->SetFlag(XFA_NodeFlag_NeedsInitApp, false); + break; + default: + break; + } +} + +void CXFA_FFNotify::OnValueChanging(CXFA_Node* pSender, XFA_ATTRIBUTE eAttr) { + if (eAttr != XFA_ATTRIBUTE_Presence) + return; + if (pSender->GetPacketID() & XFA_XDPPACKET_Datasets) + return; + if (!pSender->IsFormContainer()) + return; + + CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); + if (!pDocView) + return; + if (pDocView->GetLayoutStatus() < XFA_DOCVIEW_LAYOUTSTATUS_End) + return; + + CXFA_WidgetAcc* pWidgetAcc = ToWidgetAcc(pSender->GetWidgetData()); + if (!pWidgetAcc) + return; + + CXFA_FFWidget* pWidget = nullptr; + while ((pWidget = pWidgetAcc->GetNextWidget(pWidget)) != nullptr) { + if (pWidget->IsLoaded()) + pWidget->AddInvalidateRect(); + } +} + +void CXFA_FFNotify::OnValueChanged(CXFA_Node* pSender, + XFA_ATTRIBUTE eAttr, + CXFA_Node* pParentNode, + CXFA_Node* pWidgetNode) { + CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); + if (!pDocView) + return; + + if (!(pSender->GetPacketID() & XFA_XDPPACKET_Form)) { + if (eAttr == XFA_ATTRIBUTE_Value) + pDocView->AddCalculateNodeNotify(pSender); + return; + } + + XFA_Element eType = pParentNode->GetElementType(); + bool bIsContainerNode = pParentNode->IsContainerNode(); + CXFA_WidgetAcc* pWidgetAcc = ToWidgetAcc(pWidgetNode->GetWidgetData()); + if (!pWidgetAcc) + return; + + bool bUpdateProperty = false; + pDocView->SetChangeMark(); + switch (eType) { + case XFA_Element::Caption: { + CXFA_TextLayout* pCapOut = pWidgetAcc->GetCaptionTextLayout(); + if (!pCapOut) + return; + + pCapOut->Unload(); + break; + } + case XFA_Element::Ui: + case XFA_Element::Para: + bUpdateProperty = true; + break; + default: + break; + } + if (bIsContainerNode && eAttr == XFA_ATTRIBUTE_Access) + bUpdateProperty = true; + + if (eAttr == XFA_ATTRIBUTE_Value) { + pDocView->AddCalculateNodeNotify(pSender); + if (eType == XFA_Element::Value || bIsContainerNode) { + if (bIsContainerNode) { + pWidgetAcc->UpdateUIDisplay(); + pDocView->AddCalculateWidgetAcc(pWidgetAcc); + pDocView->AddValidateWidget(pWidgetAcc); + } else if (pWidgetNode->GetNodeItem(XFA_NODEITEM_Parent) + ->GetElementType() == XFA_Element::ExclGroup) { + pWidgetAcc->UpdateUIDisplay(); + } + return; + } + } + + CXFA_FFWidget* pWidget = nullptr; + while ((pWidget = pWidgetAcc->GetNextWidget(pWidget)) != nullptr) { + if (!pWidget->IsLoaded()) + continue; + + if (bUpdateProperty) + pWidget->UpdateWidgetProperty(); + pWidget->PerformLayout(); + pWidget->AddInvalidateRect(); + } +} + +void CXFA_FFNotify::OnChildAdded(CXFA_Node* pSender) { + if (!pSender->IsFormContainer()) + return; + + CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); + if (!pDocView) + return; + + bool bLayoutReady = + !(pDocView->m_bInLayoutStatus) && + (pDocView->GetLayoutStatus() == XFA_DOCVIEW_LAYOUTSTATUS_End); + if (bLayoutReady) + m_pDoc->GetDocEnvironment()->SetChangeMark(m_pDoc.Get()); +} + +void CXFA_FFNotify::OnChildRemoved() { + CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); + if (!pDocView) + return; + + bool bLayoutReady = + !(pDocView->m_bInLayoutStatus) && + (pDocView->GetLayoutStatus() == XFA_DOCVIEW_LAYOUTSTATUS_End); + if (bLayoutReady) + m_pDoc->GetDocEnvironment()->SetChangeMark(m_pDoc.Get()); +} + +void CXFA_FFNotify::OnLayoutItemAdded(CXFA_LayoutProcessor* pLayout, + CXFA_LayoutItem* pSender, + int32_t iPageIdx, + uint32_t dwStatus) { + CXFA_FFDocView* pDocView = m_pDoc->GetDocView(pLayout); + if (!pDocView) + return; + + CXFA_FFWidget* pWidget = XFA_GetWidgetFromLayoutItem(pSender); + if (!pWidget) + return; + + CXFA_FFPageView* pNewPageView = pDocView->GetPageView(iPageIdx); + uint32_t dwFilter = XFA_WidgetStatus_Visible | XFA_WidgetStatus_Viewable | + XFA_WidgetStatus_Printable; + pWidget->ModifyStatus(dwStatus, dwFilter); + CXFA_FFPageView* pPrePageView = pWidget->GetPageView(); + if (pPrePageView != pNewPageView || + (dwStatus & (XFA_WidgetStatus_Visible | XFA_WidgetStatus_Viewable)) == + (XFA_WidgetStatus_Visible | XFA_WidgetStatus_Viewable)) { + pWidget->SetPageView(pNewPageView); + m_pDoc->GetDocEnvironment()->WidgetPostAdd(pWidget, pWidget->GetDataAcc()); + } + if (pDocView->GetLayoutStatus() != XFA_DOCVIEW_LAYOUTSTATUS_End || + !(dwStatus & XFA_WidgetStatus_Visible)) { + return; + } + if (pWidget->IsLoaded()) { + if (pWidget->GetWidgetRect() != pWidget->RecacheWidgetRect()) + pWidget->PerformLayout(); + } else { + pWidget->LoadWidget(); + } + pWidget->AddInvalidateRect(nullptr); +} + +void CXFA_FFNotify::OnLayoutItemRemoving(CXFA_LayoutProcessor* pLayout, + CXFA_LayoutItem* pSender) { + CXFA_FFDocView* pDocView = m_pDoc->GetDocView(pLayout); + if (!pDocView) + return; + + CXFA_FFWidget* pWidget = XFA_GetWidgetFromLayoutItem(pSender); + if (!pWidget) + return; + + pDocView->DeleteLayoutItem(pWidget); + m_pDoc->GetDocEnvironment()->WidgetPreRemove(pWidget, pWidget->GetDataAcc()); + pWidget->AddInvalidateRect(nullptr); +} diff --git a/xfa/fxfa/app/cxfa_ffnotify.h b/xfa/fxfa/app/cxfa_ffnotify.h new file mode 100644 index 0000000000..935a0c390b --- /dev/null +++ b/xfa/fxfa/app/cxfa_ffnotify.h @@ -0,0 +1,77 @@ +// 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_APP_CXFA_FFNOTIFY_H_ +#define XFA_FXFA_APP_CXFA_FFNOTIFY_H_ + +#include "xfa/fxfa/cxfa_eventparam.h" +#include "xfa/fxfa/parser/cxfa_document.h" + +class CXFA_FFWidgetHandler; + +class CXFA_FFNotify { + public: + explicit CXFA_FFNotify(CXFA_FFDoc* pDoc); + ~CXFA_FFNotify(); + + void OnPageEvent(CXFA_ContainerLayoutItem* pSender, uint32_t dwEvent); + + void OnWidgetListItemAdded(CXFA_WidgetData* pSender, + const wchar_t* pLabel, + const wchar_t* pValue, + int32_t iIndex); + void OnWidgetListItemRemoved(CXFA_WidgetData* pSender, int32_t iIndex); + + // Node events + void OnNodeReady(CXFA_Node* pNode); + void OnValueChanging(CXFA_Node* pSender, XFA_ATTRIBUTE eAttr); + void OnValueChanged(CXFA_Node* pSender, + XFA_ATTRIBUTE eAttr, + CXFA_Node* pParentNode, + CXFA_Node* pWidgetNode); + void OnChildAdded(CXFA_Node* pSender); + void OnChildRemoved(); + + CXFA_LayoutItem* OnCreateLayoutItem(CXFA_Node* pNode); + void OnLayoutItemAdded(CXFA_LayoutProcessor* pLayout, + CXFA_LayoutItem* pSender, + int32_t iPageIdx, + uint32_t dwStatus); + void OnLayoutItemRemoving(CXFA_LayoutProcessor* pLayout, + CXFA_LayoutItem* pSender); + + void StartFieldDrawLayout(CXFA_Node* pItem, + float& fCalcWidth, + float& fCalcHeight); + bool FindSplitPos(CXFA_Node* pItem, + int32_t iBlockIndex, + float& fCalcHeightPos); + bool RunScript(CXFA_Node* pScript, CXFA_Node* pFormItem); + int32_t ExecEventByDeepFirst(CXFA_Node* pFormNode, + XFA_EVENTTYPE eEventType, + bool bIsFormReady = false, + bool bRecursive = true, + CXFA_WidgetAcc* pExclude = nullptr); + void AddCalcValidate(CXFA_Node* pNode); + CXFA_FFDoc* GetHDOC(); + IXFA_DocEnvironment* GetDocEnvironment() const; + IXFA_AppProvider* GetAppProvider(); + CXFA_FFWidgetHandler* GetWidgetHandler(); + CXFA_FFWidget* GetHWidget(CXFA_LayoutItem* pLayoutItem); + void OpenDropDownList(CXFA_FFWidget* hWidget); + CFX_WideString GetCurrentDateTime(); + void ResetData(CXFA_WidgetData* pWidgetData = nullptr); + int32_t GetLayoutStatus(); + void RunNodeInitialize(CXFA_Node* pNode); + void RunSubformIndexChange(CXFA_Node* pSubformNode); + CXFA_Node* GetFocusWidgetNode(); + void SetFocusWidgetNode(CXFA_Node* pNode); + + private: + CFX_UnownedPtr const m_pDoc; +}; + +#endif // XFA_FXFA_APP_CXFA_FFNOTIFY_H_ diff --git a/xfa/fxfa/app/cxfa_ffnumericedit.cpp b/xfa/fxfa/app/cxfa_ffnumericedit.cpp new file mode 100644 index 0000000000..a2aad63daa --- /dev/null +++ b/xfa/fxfa/app/cxfa_ffnumericedit.cpp @@ -0,0 +1,97 @@ +// 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/app/cxfa_ffnumericedit.h" + +#include + +#include "xfa/fwl/cfwl_edit.h" +#include "xfa/fwl/cfwl_eventvalidate.h" +#include "xfa/fwl/cfwl_notedriver.h" +#include "xfa/fxfa/parser/cxfa_localevalue.h" + +CXFA_FFNumericEdit::CXFA_FFNumericEdit(CXFA_WidgetAcc* pDataAcc) + : CXFA_FFTextEdit(pDataAcc) {} + +CXFA_FFNumericEdit::~CXFA_FFNumericEdit() {} + +bool CXFA_FFNumericEdit::LoadWidget() { + auto pNewEdit = pdfium::MakeUnique( + GetFWLApp(), pdfium::MakeUnique(), nullptr); + CFWL_Edit* pWidget = pNewEdit.get(); + m_pNormalWidget = std::move(pNewEdit); + m_pNormalWidget->SetLayoutItem(this); + + CFWL_NoteDriver* pNoteDriver = + m_pNormalWidget->GetOwnerApp()->GetNoteDriver(); + pNoteDriver->RegisterEventTarget(m_pNormalWidget.get(), + m_pNormalWidget.get()); + m_pOldDelegate = m_pNormalWidget->GetDelegate(); + m_pNormalWidget->SetDelegate(this); + m_pNormalWidget->LockUpdate(); + + CFX_WideString wsText; + m_pDataAcc->GetValue(wsText, XFA_VALUEPICTURE_Display); + pWidget->SetText(wsText); + UpdateWidgetProperty(); + m_pNormalWidget->UnlockUpdate(); + return CXFA_FFField::LoadWidget(); +} + +void CXFA_FFNumericEdit::UpdateWidgetProperty() { + CFWL_Edit* pWidget = static_cast(m_pNormalWidget.get()); + if (!pWidget) + return; + + uint32_t dwExtendedStyle = + FWL_STYLEEXT_EDT_ShowScrollbarFocus | FWL_STYLEEXT_EDT_OuterScrollbar | + FWL_STYLEEXT_EDT_Validate | FWL_STYLEEXT_EDT_Number | + FWL_STYLEEXT_EDT_LastLineHeight; + dwExtendedStyle |= UpdateUIProperty(); + if (m_pDataAcc->GetHorizontalScrollPolicy() != XFA_ATTRIBUTEENUM_Off) + dwExtendedStyle |= FWL_STYLEEXT_EDT_AutoHScroll; + + int32_t iNumCells = m_pDataAcc->GetNumberOfCells(); + if (iNumCells > 0) { + dwExtendedStyle |= FWL_STYLEEXT_EDT_CombText; + pWidget->SetLimit(iNumCells); + } + dwExtendedStyle |= GetAlignment(); + if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open || + !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) { + dwExtendedStyle |= FWL_STYLEEXT_EDT_ReadOnly; + } + m_pNormalWidget->ModifyStylesEx(dwExtendedStyle, 0xFFFFFFFF); +} + +void CXFA_FFNumericEdit::OnProcessEvent(CFWL_Event* pEvent) { + if (pEvent->GetType() == CFWL_Event::Type::Validate) { + CFWL_EventValidate* event = static_cast(pEvent); + event->bValidate = OnValidate(m_pNormalWidget.get(), event->wsInsert); + return; + } + CXFA_FFTextEdit::OnProcessEvent(pEvent); +} + +bool CXFA_FFNumericEdit::OnValidate(CFWL_Widget* pWidget, + CFX_WideString& wsText) { + CFX_WideString wsPattern; + m_pDataAcc->GetPictureContent(wsPattern, XFA_VALUEPICTURE_Edit); + if (!wsPattern.IsEmpty()) + return true; + + int32_t iLeads = 0; + m_pDataAcc->GetLeadDigits(iLeads); + + int32_t iFracs = 0; + m_pDataAcc->GetFracDigits(iFracs); + + CFX_WideString wsFormat; + CXFA_LocaleValue widgetValue = XFA_GetLocaleValue(m_pDataAcc.Get()); + widgetValue.GetNumbericFormat(wsFormat, iLeads, iFracs); + return widgetValue.ValidateNumericTemp(wsText, wsFormat, + m_pDataAcc->GetLocal()); +} diff --git a/xfa/fxfa/app/cxfa_ffnumericedit.h b/xfa/fxfa/app/cxfa_ffnumericedit.h new file mode 100644 index 0000000000..25e2304e87 --- /dev/null +++ b/xfa/fxfa/app/cxfa_ffnumericedit.h @@ -0,0 +1,31 @@ +// 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_APP_CXFA_FFNUMERICEDIT_H_ +#define XFA_FXFA_APP_CXFA_FFNUMERICEDIT_H_ + +#include "core/fxcrt/fx_string.h" +#include "xfa/fxfa/app/cxfa_fftextedit.h" + +class CFWL_Event; +class CFWL_Widget; +class CXFA_WidgetAcc; + +class CXFA_FFNumericEdit : public CXFA_FFTextEdit { + public: + explicit CXFA_FFNumericEdit(CXFA_WidgetAcc* pDataAcc); + ~CXFA_FFNumericEdit() override; + + // CXFA_FFTextEdit + bool LoadWidget() override; + void UpdateWidgetProperty() override; + void OnProcessEvent(CFWL_Event* pEvent) override; + + private: + bool OnValidate(CFWL_Widget* pWidget, CFX_WideString& wsText); +}; + +#endif // XFA_FXFA_APP_CXFA_FFNUMERICEDIT_H_ diff --git a/xfa/fxfa/app/cxfa_ffpasswordedit.cpp b/xfa/fxfa/app/cxfa_ffpasswordedit.cpp new file mode 100644 index 0000000000..1b404fa046 --- /dev/null +++ b/xfa/fxfa/app/cxfa_ffpasswordedit.cpp @@ -0,0 +1,64 @@ +// 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/app/cxfa_ffpasswordedit.h" + +#include + +#include "xfa/fwl/cfwl_edit.h" +#include "xfa/fwl/cfwl_notedriver.h" + +CXFA_FFPasswordEdit::CXFA_FFPasswordEdit(CXFA_WidgetAcc* pDataAcc) + : CXFA_FFTextEdit(pDataAcc) {} + +CXFA_FFPasswordEdit::~CXFA_FFPasswordEdit() {} + +bool CXFA_FFPasswordEdit::LoadWidget() { + auto pNewEdit = pdfium::MakeUnique( + GetFWLApp(), pdfium::MakeUnique(), nullptr); + CFWL_Edit* pWidget = pNewEdit.get(); + m_pNormalWidget = std::move(pNewEdit); + m_pNormalWidget->SetLayoutItem(this); + + CFWL_NoteDriver* pNoteDriver = + m_pNormalWidget->GetOwnerApp()->GetNoteDriver(); + pNoteDriver->RegisterEventTarget(m_pNormalWidget.get(), + m_pNormalWidget.get()); + m_pOldDelegate = m_pNormalWidget->GetDelegate(); + m_pNormalWidget->SetDelegate(this); + m_pNormalWidget->LockUpdate(); + + CFX_WideString wsText; + m_pDataAcc->GetValue(wsText, XFA_VALUEPICTURE_Display); + pWidget->SetText(wsText); + UpdateWidgetProperty(); + m_pNormalWidget->UnlockUpdate(); + return CXFA_FFField::LoadWidget(); +} + +void CXFA_FFPasswordEdit::UpdateWidgetProperty() { + CFWL_Edit* pWidget = static_cast(m_pNormalWidget.get()); + if (!pWidget) + return; + + uint32_t dwExtendedStyle = + FWL_STYLEEXT_EDT_ShowScrollbarFocus | FWL_STYLEEXT_EDT_OuterScrollbar | + FWL_STYLEEXT_EDT_Password | FWL_STYLEEXT_EDT_LastLineHeight; + dwExtendedStyle |= UpdateUIProperty(); + + CFX_WideString wsPassWord; + m_pDataAcc->GetPasswordChar(wsPassWord); + if (!wsPassWord.IsEmpty()) + pWidget->SetAliasChar(wsPassWord.GetAt(0)); + if (m_pDataAcc->GetHorizontalScrollPolicy() != XFA_ATTRIBUTEENUM_Off) + dwExtendedStyle |= FWL_STYLEEXT_EDT_AutoHScroll; + if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open || + !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) { + dwExtendedStyle |= FWL_STYLEEXT_EDT_ReadOnly; + } + dwExtendedStyle |= GetAlignment(); + m_pNormalWidget->ModifyStylesEx(dwExtendedStyle, 0xFFFFFFFF); +} diff --git a/xfa/fxfa/app/cxfa_ffpasswordedit.h b/xfa/fxfa/app/cxfa_ffpasswordedit.h new file mode 100644 index 0000000000..5d292d4df3 --- /dev/null +++ b/xfa/fxfa/app/cxfa_ffpasswordedit.h @@ -0,0 +1,24 @@ +// 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_APP_CXFA_FFPASSWORDEDIT_H_ +#define XFA_FXFA_APP_CXFA_FFPASSWORDEDIT_H_ + +#include "xfa/fxfa/app/cxfa_fftextedit.h" + +class CXFA_WidgetAcc; + +class CXFA_FFPasswordEdit : public CXFA_FFTextEdit { + public: + explicit CXFA_FFPasswordEdit(CXFA_WidgetAcc* pDataAcc); + ~CXFA_FFPasswordEdit() override; + + // CXFA_FFTextEdit + bool LoadWidget() override; + void UpdateWidgetProperty() override; +}; + +#endif // XFA_FXFA_APP_CXFA_FFPASSWORDEDIT_H_ diff --git a/xfa/fxfa/app/cxfa_ffpushbutton.cpp b/xfa/fxfa/app/cxfa_ffpushbutton.cpp new file mode 100644 index 0000000000..1e784a496e --- /dev/null +++ b/xfa/fxfa/app/cxfa_ffpushbutton.cpp @@ -0,0 +1,240 @@ +// 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/app/cxfa_ffpushbutton.h" + +#include + +#include "third_party/base/ptr_util.h" +#include "xfa/fwl/cfwl_notedriver.h" +#include "xfa/fwl/cfwl_pushbutton.h" +#include "xfa/fwl/cfwl_widgetmgr.h" +#include "xfa/fxfa/app/cxfa_fffield.h" +#include "xfa/fxfa/app/cxfa_textlayout.h" +#include "xfa/fxfa/app/cxfa_textprovider.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" + +CXFA_FFPushButton::CXFA_FFPushButton(CXFA_WidgetAcc* pDataAcc) + : CXFA_FFField(pDataAcc), m_pOldDelegate(nullptr) {} + +CXFA_FFPushButton::~CXFA_FFPushButton() { + CXFA_FFPushButton::UnloadWidget(); +} + +void CXFA_FFPushButton::RenderWidget(CFX_Graphics* pGS, + CFX_Matrix* pMatrix, + uint32_t dwStatus) { + if (!IsMatchVisibleStatus(dwStatus)) + return; + + CFX_Matrix mtRotate = GetRotateMatrix(); + if (pMatrix) + mtRotate.Concat(*pMatrix); + + CXFA_FFWidget::RenderWidget(pGS, &mtRotate, dwStatus); + RenderHighlightCaption(pGS, &mtRotate); + + CFX_RectF rtWidget = GetRectWithoutRotate(); + CFX_Matrix mt(1, 0, 0, 1, rtWidget.left, rtWidget.top); + mt.Concat(mtRotate); + GetApp()->GetWidgetMgrDelegate()->OnDrawWidget(m_pNormalWidget.get(), pGS, + &mt); +} + +bool CXFA_FFPushButton::LoadWidget() { + ASSERT(!m_pNormalWidget); + auto pNew = pdfium::MakeUnique(GetFWLApp()); + CFWL_PushButton* pPushButton = pNew.get(); + m_pOldDelegate = pPushButton->GetDelegate(); + pPushButton->SetDelegate(this); + m_pNormalWidget = std::move(pNew); + m_pNormalWidget->SetLayoutItem(this); + + CFWL_NoteDriver* pNoteDriver = + m_pNormalWidget->GetOwnerApp()->GetNoteDriver(); + pNoteDriver->RegisterEventTarget(m_pNormalWidget.get(), + m_pNormalWidget.get()); + m_pNormalWidget->LockUpdate(); + UpdateWidgetProperty(); + LoadHighlightCaption(); + m_pNormalWidget->UnlockUpdate(); + return CXFA_FFField::LoadWidget(); +} + +void CXFA_FFPushButton::UpdateWidgetProperty() { + uint32_t dwStyleEx = 0; + switch (m_pDataAcc->GetButtonHighlight()) { + case XFA_ATTRIBUTEENUM_Inverted: + dwStyleEx = XFA_FWL_PSBSTYLEEXT_HiliteInverted; + break; + case XFA_ATTRIBUTEENUM_Outline: + dwStyleEx = XFA_FWL_PSBSTYLEEXT_HiliteOutLine; + break; + case XFA_ATTRIBUTEENUM_Push: + dwStyleEx = XFA_FWL_PSBSTYLEEXT_HilitePush; + break; + default: + break; + } + m_pNormalWidget->ModifyStylesEx(dwStyleEx, 0xFFFFFFFF); +} + +void CXFA_FFPushButton::UnloadWidget() { + m_pRolloverTextLayout.reset(); + m_pDownTextLayout.reset(); + m_pRollProvider.reset(); + m_pDownProvider.reset(); + CXFA_FFField::UnloadWidget(); +} + +bool CXFA_FFPushButton::PerformLayout() { + CXFA_FFWidget::PerformLayout(); + CFX_RectF rtWidget = GetRectWithoutRotate(); + + m_rtUI = rtWidget; + if (CXFA_Margin mgWidget = m_pDataAcc->GetMargin()) + XFA_RectWidthoutMargin(rtWidget, mgWidget); + + CXFA_Caption caption = m_pDataAcc->GetCaption(); + m_rtCaption = rtWidget; + if (CXFA_Margin mgCap = caption.GetMargin()) + XFA_RectWidthoutMargin(m_rtCaption, mgCap); + + LayoutHighlightCaption(); + SetFWLRect(); + if (m_pNormalWidget) + m_pNormalWidget->Update(); + + return true; +} +float CXFA_FFPushButton::GetLineWidth() { + CXFA_Border border = m_pDataAcc->GetBorder(false); + if (border && border.GetPresence() == XFA_ATTRIBUTEENUM_Visible) { + CXFA_Edge edge = border.GetEdge(0); + return edge.GetThickness(); + } + return 0; +} + +FX_ARGB CXFA_FFPushButton::GetLineColor() { + return 0xFF000000; +} + +FX_ARGB CXFA_FFPushButton::GetFillColor() { + return 0xFFFFFFFF; +} + +void CXFA_FFPushButton::LoadHighlightCaption() { + CXFA_Caption caption = m_pDataAcc->GetCaption(); + if (!caption || caption.GetPresence() == XFA_ATTRIBUTEENUM_Hidden) + return; + + bool bRichText; + CFX_WideString wsRollover; + if (m_pDataAcc->GetButtonRollover(wsRollover, bRichText)) { + if (!m_pRollProvider) { + m_pRollProvider = pdfium::MakeUnique( + m_pDataAcc.Get(), XFA_TEXTPROVIDERTYPE_Rollover); + } + m_pRolloverTextLayout = + pdfium::MakeUnique(m_pRollProvider.get()); + } + CFX_WideString wsDown; + if (m_pDataAcc->GetButtonDown(wsDown, bRichText)) { + if (!m_pDownProvider) { + m_pDownProvider = pdfium::MakeUnique( + m_pDataAcc.Get(), XFA_TEXTPROVIDERTYPE_Down); + } + m_pDownTextLayout = + pdfium::MakeUnique(m_pDownProvider.get()); + } +} + +void CXFA_FFPushButton::LayoutHighlightCaption() { + CFX_SizeF sz(m_rtCaption.width, m_rtCaption.height); + LayoutCaption(); + if (m_pRolloverTextLayout) + m_pRolloverTextLayout->Layout(sz); + if (m_pDownTextLayout) + m_pDownTextLayout->Layout(sz); +} + +void CXFA_FFPushButton::RenderHighlightCaption(CFX_Graphics* pGS, + CFX_Matrix* pMatrix) { + CXFA_TextLayout* pCapTextLayout = m_pDataAcc->GetCaptionTextLayout(); + CXFA_Caption caption = m_pDataAcc->GetCaption(); + if (!caption || caption.GetPresence() != XFA_ATTRIBUTEENUM_Visible) + return; + + CFX_RenderDevice* pRenderDevice = pGS->GetRenderDevice(); + CFX_RectF rtClip = m_rtCaption; + rtClip.Intersect(GetRectWithoutRotate()); + CFX_Matrix mt(1, 0, 0, 1, m_rtCaption.left, m_rtCaption.top); + if (pMatrix) { + pMatrix->TransformRect(rtClip); + mt.Concat(*pMatrix); + } + + uint32_t dwState = m_pNormalWidget->GetStates(); + if (m_pDownTextLayout && (dwState & FWL_STATE_PSB_Pressed) && + (dwState & FWL_STATE_PSB_Hovered)) { + if (m_pDownTextLayout->DrawString(pRenderDevice, mt, rtClip)) + return; + } else if (m_pRolloverTextLayout && (dwState & FWL_STATE_PSB_Hovered)) { + if (m_pRolloverTextLayout->DrawString(pRenderDevice, mt, rtClip)) + return; + } + + if (pCapTextLayout) + pCapTextLayout->DrawString(pRenderDevice, mt, rtClip); +} + +void CXFA_FFPushButton::OnProcessMessage(CFWL_Message* pMessage) { + m_pOldDelegate->OnProcessMessage(pMessage); +} + +void CXFA_FFPushButton::OnProcessEvent(CFWL_Event* pEvent) { + m_pOldDelegate->OnProcessEvent(pEvent); + CXFA_FFField::OnProcessEvent(pEvent); +} + +void CXFA_FFPushButton::OnDrawWidget(CFX_Graphics* pGraphics, + const CFX_Matrix* pMatrix) { + if (m_pNormalWidget->GetStylesEx() & XFA_FWL_PSBSTYLEEXT_HiliteInverted) { + if ((m_pNormalWidget->GetStates() & FWL_STATE_PSB_Pressed) && + (m_pNormalWidget->GetStates() & FWL_STATE_PSB_Hovered)) { + CFX_RectF rtFill(0, 0, m_pNormalWidget->GetWidgetRect().Size()); + float fLineWith = GetLineWidth(); + rtFill.Deflate(fLineWith, fLineWith); + CFX_Color cr(FXARGB_MAKE(128, 128, 255, 255)); + pGraphics->SetFillColor(&cr); + + CFX_Path path; + path.AddRectangle(rtFill.left, rtFill.top, rtFill.width, rtFill.height); + pGraphics->FillPath(&path, FXFILL_WINDING, (CFX_Matrix*)pMatrix); + } + return; + } + + if (m_pNormalWidget->GetStylesEx() & XFA_FWL_PSBSTYLEEXT_HiliteOutLine) { + if ((m_pNormalWidget->GetStates() & FWL_STATE_PSB_Pressed) && + (m_pNormalWidget->GetStates() & FWL_STATE_PSB_Hovered)) { + float fLineWidth = GetLineWidth(); + CFX_Color cr(FXARGB_MAKE(255, 128, 255, 255)); + pGraphics->SetStrokeColor(&cr); + pGraphics->SetLineWidth(fLineWidth); + + CFX_Path path; + CFX_RectF rect = m_pNormalWidget->GetWidgetRect(); + path.AddRectangle(0, 0, rect.width, rect.height); + pGraphics->StrokePath(&path, (CFX_Matrix*)pMatrix); + } + } +} diff --git a/xfa/fxfa/app/cxfa_ffpushbutton.h b/xfa/fxfa/app/cxfa_ffpushbutton.h new file mode 100644 index 0000000000..797d92d970 --- /dev/null +++ b/xfa/fxfa/app/cxfa_ffpushbutton.h @@ -0,0 +1,54 @@ +// 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_APP_CXFA_FFPUSHBUTTON_H_ +#define XFA_FXFA_APP_CXFA_FFPUSHBUTTON_H_ + +#include + +#include "xfa/fxfa/app/cxfa_fffield.h" + +#define XFA_FWL_PSBSTYLEEXT_HiliteNone (0L << 0) +#define XFA_FWL_PSBSTYLEEXT_HiliteInverted (1L << 0) +#define XFA_FWL_PSBSTYLEEXT_HilitePush (2L << 0) +#define XFA_FWL_PSBSTYLEEXT_HiliteOutLine (4L << 0) + +class CXFA_TextProvider; + +class CXFA_FFPushButton : public CXFA_FFField { + public: + explicit CXFA_FFPushButton(CXFA_WidgetAcc* pDataAcc); + ~CXFA_FFPushButton() override; + + // CXFA_FFField + void RenderWidget(CFX_Graphics* pGS, + CFX_Matrix* pMatrix, + uint32_t dwStatus) override; + bool LoadWidget() override; + void UnloadWidget() override; + bool PerformLayout() override; + void UpdateWidgetProperty() override; + void OnProcessMessage(CFWL_Message* pMessage) override; + void OnProcessEvent(CFWL_Event* pEvent) override; + void OnDrawWidget(CFX_Graphics* pGraphics, + const CFX_Matrix* pMatrix = nullptr) override; + + private: + void LoadHighlightCaption(); + void LayoutHighlightCaption(); + void RenderHighlightCaption(CFX_Graphics* pGS, CFX_Matrix* pMatrix); + float GetLineWidth(); + FX_ARGB GetLineColor(); + FX_ARGB GetFillColor(); + + std::unique_ptr m_pRolloverTextLayout; + std::unique_ptr m_pDownTextLayout; + std::unique_ptr m_pRollProvider; + std::unique_ptr m_pDownProvider; + IFWL_WidgetDelegate* m_pOldDelegate; +}; + +#endif // XFA_FXFA_APP_CXFA_FFPUSHBUTTON_H_ diff --git a/xfa/fxfa/app/cxfa_ffrectangle.cpp b/xfa/fxfa/app/cxfa_ffrectangle.cpp new file mode 100644 index 0000000000..bccf7404f2 --- /dev/null +++ b/xfa/fxfa/app/cxfa_ffrectangle.cpp @@ -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 + +#include "xfa/fxfa/app/cxfa_ffrectangle.h" + +CXFA_FFRectangle::CXFA_FFRectangle(CXFA_WidgetAcc* pDataAcc) + : CXFA_FFDraw(pDataAcc) {} + +CXFA_FFRectangle::~CXFA_FFRectangle() {} + +void CXFA_FFRectangle::RenderWidget(CFX_Graphics* pGS, + CFX_Matrix* pMatrix, + uint32_t dwStatus) { + if (!IsMatchVisibleStatus(dwStatus)) + return; + + CXFA_Value value = m_pDataAcc->GetFormValue(); + if (!value) + return; + + CXFA_Rectangle rtObj = value.GetRectangle(); + CFX_RectF rect = GetRectWithoutRotate(); + if (CXFA_Margin mgWidget = m_pDataAcc->GetMargin()) + XFA_RectWidthoutMargin(rect, mgWidget); + + CFX_Matrix mtRotate = GetRotateMatrix(); + if (pMatrix) + mtRotate.Concat(*pMatrix); + + DrawBorder(pGS, rtObj, rect, &mtRotate); +} diff --git a/xfa/fxfa/app/cxfa_ffrectangle.h b/xfa/fxfa/app/cxfa_ffrectangle.h new file mode 100644 index 0000000000..499f60007e --- /dev/null +++ b/xfa/fxfa/app/cxfa_ffrectangle.h @@ -0,0 +1,23 @@ +// 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_APP_CXFA_FFRECTANGLE_H_ +#define XFA_FXFA_APP_CXFA_FFRECTANGLE_H_ + +#include "xfa/fxfa/app/cxfa_ffdraw.h" + +class CXFA_FFRectangle : public CXFA_FFDraw { + public: + explicit CXFA_FFRectangle(CXFA_WidgetAcc* pDataAcc); + ~CXFA_FFRectangle() override; + + // CXFA_FFWidget + void RenderWidget(CFX_Graphics* pGS, + CFX_Matrix* pMatrix, + uint32_t dwStatus) override; +}; + +#endif // XFA_FXFA_APP_CXFA_FFRECTANGLE_H_ diff --git a/xfa/fxfa/app/cxfa_ffsignature.cpp b/xfa/fxfa/app/cxfa_ffsignature.cpp new file mode 100644 index 0000000000..a5d33ad51c --- /dev/null +++ b/xfa/fxfa/app/cxfa_ffsignature.cpp @@ -0,0 +1,114 @@ +// 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/app/cxfa_ffsignature.h" + +#include "xfa/fxfa/app/cxfa_fffield.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) {} + +CXFA_FFSignature::~CXFA_FFSignature() {} + +bool CXFA_FFSignature::LoadWidget() { + return CXFA_FFField::LoadWidget(); +} + +void CXFA_FFSignature::RenderWidget(CFX_Graphics* pGS, + CFX_Matrix* pMatrix, + uint32_t dwStatus) { + if (!IsMatchVisibleStatus(dwStatus)) + return; + + CFX_Matrix mtRotate = GetRotateMatrix(); + if (pMatrix) + mtRotate.Concat(*pMatrix); + + CXFA_FFWidget::RenderWidget(pGS, &mtRotate, dwStatus); + + CXFA_Border borderUI = m_pDataAcc->GetUIBorder(); + DrawBorder(pGS, borderUI, m_rtUI, &mtRotate); + RenderCaption(pGS, &mtRotate); + DrawHighlight(pGS, &mtRotate, dwStatus, false); +} + +bool CXFA_FFSignature::OnMouseEnter() { + return false; +} + +bool CXFA_FFSignature::OnMouseExit() { + return false; +} + +bool CXFA_FFSignature::OnLButtonDown(uint32_t dwFlags, + const CFX_PointF& point) { + return false; +} + +bool CXFA_FFSignature::OnLButtonUp(uint32_t dwFlags, const CFX_PointF& point) { + return false; +} + +bool CXFA_FFSignature::OnLButtonDblClk(uint32_t dwFlags, + const CFX_PointF& point) { + return false; +} + +bool CXFA_FFSignature::OnMouseMove(uint32_t dwFlags, const CFX_PointF& point) { + return false; +} + +bool CXFA_FFSignature::OnMouseWheel(uint32_t dwFlags, + int16_t zDelta, + const CFX_PointF& point) { + return false; +} + +bool CXFA_FFSignature::OnRButtonDown(uint32_t dwFlags, + const CFX_PointF& point) { + return false; +} + +bool CXFA_FFSignature::OnRButtonUp(uint32_t dwFlags, const CFX_PointF& point) { + return false; +} + +bool CXFA_FFSignature::OnRButtonDblClk(uint32_t dwFlags, + const CFX_PointF& point) { + return false; +} + +bool CXFA_FFSignature::OnKeyDown(uint32_t dwKeyCode, uint32_t dwFlags) { + return false; +} + +bool CXFA_FFSignature::OnKeyUp(uint32_t dwKeyCode, uint32_t dwFlags) { + return false; +} + +bool CXFA_FFSignature::OnChar(uint32_t dwChar, uint32_t dwFlags) { + return false; +} + +FWL_WidgetHit CXFA_FFSignature::OnHitTest(const CFX_PointF& point) { + if (m_pNormalWidget && + m_pNormalWidget->HitTest(FWLToClient(point)) != FWL_WidgetHit::Unknown) { + return FWL_WidgetHit::Client; + } + + if (!GetRectWithoutRotate().Contains(point)) + return FWL_WidgetHit::Unknown; + if (m_rtCaption.Contains(point)) + return FWL_WidgetHit::Titlebar; + return FWL_WidgetHit::Client; +} + +bool CXFA_FFSignature::OnSetCursor(const CFX_PointF& point) { + return false; +} diff --git a/xfa/fxfa/app/cxfa_ffsignature.h b/xfa/fxfa/app/cxfa_ffsignature.h new file mode 100644 index 0000000000..839cfaf5fc --- /dev/null +++ b/xfa/fxfa/app/cxfa_ffsignature.h @@ -0,0 +1,42 @@ +// 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_APP_CXFA_FFSIGNATURE_H_ +#define XFA_FXFA_APP_CXFA_FFSIGNATURE_H_ + +#include "xfa/fxfa/app/cxfa_fffield.h" + +class CXFA_FFSignature final : public CXFA_FFField { + public: + explicit CXFA_FFSignature(CXFA_WidgetAcc* pDataAcc); + ~CXFA_FFSignature() override; + + // CXFA_FFField + void RenderWidget(CFX_Graphics* pGS, + CFX_Matrix* pMatrix, + uint32_t dwStatus) override; + bool LoadWidget() override; + bool OnMouseEnter() override; + bool OnMouseExit() override; + bool OnLButtonDown(uint32_t dwFlags, const CFX_PointF& point) override; + bool OnLButtonUp(uint32_t dwFlags, const CFX_PointF& point) override; + bool OnLButtonDblClk(uint32_t dwFlags, const CFX_PointF& point) override; + bool OnMouseMove(uint32_t dwFlags, const CFX_PointF& point) override; + bool OnMouseWheel(uint32_t dwFlags, + int16_t zDelta, + const CFX_PointF& pointy) override; + bool OnRButtonDown(uint32_t dwFlags, const CFX_PointF& point) override; + bool OnRButtonUp(uint32_t dwFlags, const CFX_PointF& point) override; + bool OnRButtonDblClk(uint32_t dwFlags, const CFX_PointF& point) override; + + bool OnKeyDown(uint32_t dwKeyCode, uint32_t dwFlags) override; + bool OnKeyUp(uint32_t dwKeyCode, uint32_t dwFlags) override; + bool OnChar(uint32_t dwChar, uint32_t dwFlags) override; + FWL_WidgetHit OnHitTest(const CFX_PointF& point) override; + bool OnSetCursor(const CFX_PointF& point) override; +}; + +#endif // XFA_FXFA_APP_CXFA_FFSIGNATURE_H_ diff --git a/xfa/fxfa/app/cxfa_ffsubform.cpp b/xfa/fxfa/app/cxfa_ffsubform.cpp new file mode 100644 index 0000000000..80a7782917 --- /dev/null +++ b/xfa/fxfa/app/cxfa_ffsubform.cpp @@ -0,0 +1,17 @@ +// 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/app/cxfa_ffsubform.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) {} + +CXFA_FFSubForm::~CXFA_FFSubForm() {} diff --git a/xfa/fxfa/app/cxfa_ffsubform.h b/xfa/fxfa/app/cxfa_ffsubform.h new file mode 100644 index 0000000000..d73e53de97 --- /dev/null +++ b/xfa/fxfa/app/cxfa_ffsubform.h @@ -0,0 +1,19 @@ +// 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_APP_CXFA_FFSUBFORM_H_ +#define XFA_FXFA_APP_CXFA_FFSUBFORM_H_ + +#include "xfa/fxfa/cxfa_ffpageview.h" +#include "xfa/fxfa/cxfa_ffwidget.h" + +class CXFA_FFSubForm : public CXFA_FFWidget { + public: + explicit CXFA_FFSubForm(CXFA_WidgetAcc* pDataAcc); + ~CXFA_FFSubForm() override; +}; + +#endif // XFA_FXFA_APP_CXFA_FFSUBFORM_H_ diff --git a/xfa/fxfa/app/cxfa_fftext.cpp b/xfa/fxfa/app/cxfa_fftext.cpp new file mode 100644 index 0000000000..b5224eaaed --- /dev/null +++ b/xfa/fxfa/app/cxfa_fftext.cpp @@ -0,0 +1,163 @@ +// 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/app/cxfa_fftext.h" + +#include "xfa/fwl/fwl_widgetdef.h" +#include "xfa/fwl/fwl_widgethit.h" +#include "xfa/fxfa/app/cxfa_ffdraw.h" +#include "xfa/fxfa/app/cxfa_linkuserdata.h" +#include "xfa/fxfa/app/cxfa_pieceline.h" +#include "xfa/fxfa/app/cxfa_textlayout.h" +#include "xfa/fxfa/app/cxfa_textpiece.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) {} + +CXFA_FFText::~CXFA_FFText() {} + +void CXFA_FFText::RenderWidget(CFX_Graphics* pGS, + CFX_Matrix* pMatrix, + uint32_t dwStatus) { + if (!IsMatchVisibleStatus(dwStatus)) + return; + + CFX_Matrix mtRotate = GetRotateMatrix(); + if (pMatrix) + mtRotate.Concat(*pMatrix); + + CXFA_FFWidget::RenderWidget(pGS, &mtRotate, dwStatus); + + CXFA_TextLayout* pTextLayout = m_pDataAcc->GetTextLayout(); + if (!pTextLayout) + return; + + CFX_RenderDevice* pRenderDevice = pGS->GetRenderDevice(); + CFX_RectF rtText = GetRectWithoutRotate(); + if (CXFA_Margin mgWidget = m_pDataAcc->GetMargin()) { + CXFA_LayoutItem* pItem = this; + if (!pItem->GetPrev() && !pItem->GetNext()) { + XFA_RectWidthoutMargin(rtText, mgWidget); + } else { + float fLeftInset; + float fRightInset; + float fTopInset = 0; + float fBottomInset = 0; + mgWidget.GetLeftInset(fLeftInset); + mgWidget.GetRightInset(fRightInset); + if (!pItem->GetPrev()) + mgWidget.GetTopInset(fTopInset); + else if (!pItem->GetNext()) + mgWidget.GetBottomInset(fBottomInset); + + rtText.Deflate(fLeftInset, fTopInset, fRightInset, fBottomInset); + } + } + + CFX_Matrix mt(1, 0, 0, 1, rtText.left, rtText.top); + CFX_RectF rtClip = rtText; + mtRotate.TransformRect(rtClip); + mt.Concat(mtRotate); + pTextLayout->DrawString(pRenderDevice, mt, rtClip, GetIndex()); +} + +bool CXFA_FFText::IsLoaded() { + CXFA_TextLayout* pTextLayout = m_pDataAcc->GetTextLayout(); + return pTextLayout && !pTextLayout->m_bHasBlock; +} + +bool CXFA_FFText::PerformLayout() { + CXFA_FFDraw::PerformLayout(); + CXFA_TextLayout* pTextLayout = m_pDataAcc->GetTextLayout(); + if (!pTextLayout) + return false; + if (!pTextLayout->m_bHasBlock) + return true; + + pTextLayout->m_Blocks.clear(); + CXFA_LayoutItem* pItem = this; + if (!pItem->GetPrev() && !pItem->GetNext()) + return true; + + pItem = pItem->GetFirst(); + while (pItem) { + CFX_RectF rtText = pItem->GetRect(false); + if (CXFA_Margin mgWidget = m_pDataAcc->GetMargin()) { + if (!pItem->GetPrev()) { + float fTopInset; + mgWidget.GetTopInset(fTopInset); + rtText.height -= fTopInset; + } else if (!pItem->GetNext()) { + float fBottomInset; + mgWidget.GetBottomInset(fBottomInset); + rtText.height -= fBottomInset; + } + } + pTextLayout->ItemBlocks(rtText, pItem->GetIndex()); + pItem = pItem->GetNext(); + } + pTextLayout->m_bHasBlock = false; + return true; +} + +bool CXFA_FFText::OnLButtonDown(uint32_t dwFlags, const CFX_PointF& point) { + if (!GetRectWithoutRotate().Contains(point)) + return false; + + const wchar_t* wsURLContent = GetLinkURLAtPoint(point); + if (!wsURLContent) + return false; + + SetButtonDown(true); + return true; +} + +bool CXFA_FFText::OnMouseMove(uint32_t dwFlags, const CFX_PointF& point) { + return GetRectWithoutRotate().Contains(point) && !!GetLinkURLAtPoint(point); +} + +bool CXFA_FFText::OnLButtonUp(uint32_t dwFlags, const CFX_PointF& point) { + if (!IsButtonDown()) + return false; + + SetButtonDown(false); + const wchar_t* wsURLContent = GetLinkURLAtPoint(point); + if (!wsURLContent) + return false; + + CXFA_FFDoc* pDoc = GetDoc(); + pDoc->GetDocEnvironment()->GotoURL(pDoc, wsURLContent); + return true; +} + +FWL_WidgetHit CXFA_FFText::OnHitTest(const CFX_PointF& point) { + if (!GetRectWithoutRotate().Contains(point)) + return FWL_WidgetHit::Unknown; + if (!GetLinkURLAtPoint(point)) + return FWL_WidgetHit::Unknown; + return FWL_WidgetHit::HyperLink; +} + +const wchar_t* CXFA_FFText::GetLinkURLAtPoint(const CFX_PointF& point) { + CXFA_TextLayout* pTextLayout = m_pDataAcc->GetTextLayout(); + if (!pTextLayout) + return nullptr; + + CFX_RectF rect = GetRectWithoutRotate(); + for (const auto& pPieceLine : *pTextLayout->GetPieceLines()) { + for (const auto& pPiece : pPieceLine->m_textPieces) { + if (pPiece->pLinkData && + pPiece->rtPiece.Contains(point - rect.TopLeft())) { + return pPiece->pLinkData->GetLinkURL(); + } + } + } + return nullptr; +} diff --git a/xfa/fxfa/app/cxfa_fftext.h b/xfa/fxfa/app/cxfa_fftext.h new file mode 100644 index 0000000000..3fd48da2a9 --- /dev/null +++ b/xfa/fxfa/app/cxfa_fftext.h @@ -0,0 +1,32 @@ +// 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_APP_CXFA_FFTEXT_H_ +#define XFA_FXFA_APP_CXFA_FFTEXT_H_ + +#include "xfa/fxfa/app/cxfa_ffdraw.h" + +class CXFA_FFText : public CXFA_FFDraw { + public: + explicit CXFA_FFText(CXFA_WidgetAcc* pDataAcc); + ~CXFA_FFText() override; + + // CXFA_FFWidget + bool OnLButtonDown(uint32_t dwFlags, const CFX_PointF& point) override; + bool OnLButtonUp(uint32_t dwFlags, const CFX_PointF& point) override; + bool OnMouseMove(uint32_t dwFlags, const CFX_PointF& point) override; + FWL_WidgetHit OnHitTest(const CFX_PointF& point) override; + void RenderWidget(CFX_Graphics* pGS, + CFX_Matrix* pMatrix, + uint32_t dwStatus) override; + bool IsLoaded() override; + bool PerformLayout() override; + + private: + const wchar_t* GetLinkURLAtPoint(const CFX_PointF& point); +}; + +#endif // XFA_FXFA_APP_CXFA_FFTEXT_H_ diff --git a/xfa/fxfa/app/cxfa_fftextedit.cpp b/xfa/fxfa/app/cxfa_fftextedit.cpp new file mode 100644 index 0000000000..b61d4ab125 --- /dev/null +++ b/xfa/fxfa/app/cxfa_fftextedit.cpp @@ -0,0 +1,364 @@ +// 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/app/cxfa_fftextedit.h" + +#include + +#include "xfa/fwl/cfwl_datetimepicker.h" +#include "xfa/fwl/cfwl_edit.h" +#include "xfa/fwl/cfwl_eventcheckword.h" +#include "xfa/fwl/cfwl_eventtarget.h" +#include "xfa/fwl/cfwl_eventtextchanged.h" +#include "xfa/fwl/cfwl_messagekillfocus.h" +#include "xfa/fwl/cfwl_messagesetfocus.h" +#include "xfa/fwl/cfwl_notedriver.h" +#include "xfa/fxfa/cxfa_eventparam.h" +#include "xfa/fxfa/cxfa_ffapp.h" +#include "xfa/fxfa/parser/cxfa_node.h" + +CXFA_FFTextEdit::CXFA_FFTextEdit(CXFA_WidgetAcc* pDataAcc) + : CXFA_FFField(pDataAcc), m_pOldDelegate(nullptr) {} + +CXFA_FFTextEdit::~CXFA_FFTextEdit() { + if (m_pNormalWidget) { + CFWL_NoteDriver* pNoteDriver = + m_pNormalWidget->GetOwnerApp()->GetNoteDriver(); + pNoteDriver->UnregisterEventTarget(m_pNormalWidget.get()); + } +} + +bool CXFA_FFTextEdit::LoadWidget() { + auto pNewWidget = pdfium::MakeUnique( + GetFWLApp(), pdfium::MakeUnique(), nullptr); + CFWL_Edit* pFWLEdit = pNewWidget.get(); + m_pNormalWidget = std::move(pNewWidget); + m_pNormalWidget->SetLayoutItem(this); + + CFWL_NoteDriver* pNoteDriver = + m_pNormalWidget->GetOwnerApp()->GetNoteDriver(); + pNoteDriver->RegisterEventTarget(m_pNormalWidget.get(), + m_pNormalWidget.get()); + m_pOldDelegate = m_pNormalWidget->GetDelegate(); + m_pNormalWidget->SetDelegate(this); + m_pNormalWidget->LockUpdate(); + UpdateWidgetProperty(); + + CFX_WideString wsText; + m_pDataAcc->GetValue(wsText, XFA_VALUEPICTURE_Display); + pFWLEdit->SetText(wsText); + m_pNormalWidget->UnlockUpdate(); + return CXFA_FFField::LoadWidget(); +} + +void CXFA_FFTextEdit::UpdateWidgetProperty() { + CFWL_Edit* pWidget = static_cast(m_pNormalWidget.get()); + if (!pWidget) + return; + + uint32_t dwStyle = 0; + uint32_t dwExtendedStyle = FWL_STYLEEXT_EDT_ShowScrollbarFocus | + FWL_STYLEEXT_EDT_OuterScrollbar | + FWL_STYLEEXT_EDT_LastLineHeight; + dwExtendedStyle |= UpdateUIProperty(); + if (m_pDataAcc->IsMultiLine()) { + dwExtendedStyle |= FWL_STYLEEXT_EDT_MultiLine | FWL_STYLEEXT_EDT_WantReturn; + if (m_pDataAcc->GetVerticalScrollPolicy() != XFA_ATTRIBUTEENUM_Off) { + dwStyle |= FWL_WGTSTYLE_VScroll; + dwExtendedStyle |= FWL_STYLEEXT_EDT_AutoVScroll; + } + } else if (m_pDataAcc->GetHorizontalScrollPolicy() != XFA_ATTRIBUTEENUM_Off) { + dwExtendedStyle |= FWL_STYLEEXT_EDT_AutoHScroll; + } + if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open || + !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) { + dwExtendedStyle |= FWL_STYLEEXT_EDT_ReadOnly; + dwExtendedStyle |= FWL_STYLEEXT_EDT_MultiLine; + } + + XFA_Element eType = XFA_Element::Unknown; + int32_t iMaxChars = m_pDataAcc->GetMaxChars(eType); + if (eType == XFA_Element::ExData) + iMaxChars = 0; + + int32_t iNumCells = m_pDataAcc->GetNumberOfCells(); + if (iNumCells == 0) { + dwExtendedStyle |= FWL_STYLEEXT_EDT_CombText; + pWidget->SetLimit(iMaxChars > 0 ? iMaxChars : 1); + } else if (iNumCells > 0) { + dwExtendedStyle |= FWL_STYLEEXT_EDT_CombText; + pWidget->SetLimit(iNumCells); + } else { + pWidget->SetLimit(iMaxChars); + } + dwExtendedStyle |= GetAlignment(); + m_pNormalWidget->ModifyStyles(dwStyle, 0xFFFFFFFF); + m_pNormalWidget->ModifyStylesEx(dwExtendedStyle, 0xFFFFFFFF); +} + +bool CXFA_FFTextEdit::OnLButtonDown(uint32_t dwFlags, const CFX_PointF& point) { + if (!PtInActiveRect(point)) + return false; + if (!IsFocused()) { + m_dwStatus |= XFA_WidgetStatus_Focused; + UpdateFWLData(); + AddInvalidateRect(); + } + + SetButtonDown(true); + CFWL_MessageMouse ms(nullptr, m_pNormalWidget.get()); + ms.m_dwCmd = FWL_MouseCommand::LeftButtonDown; + ms.m_dwFlags = dwFlags; + ms.m_pos = FWLToClient(point); + TranslateFWLMessage(&ms); + return true; +} + +bool CXFA_FFTextEdit::OnRButtonDown(uint32_t dwFlags, const CFX_PointF& point) { + if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open) + return false; + if (!PtInActiveRect(point)) + return false; + if (!IsFocused()) { + m_dwStatus |= XFA_WidgetStatus_Focused; + UpdateFWLData(); + AddInvalidateRect(); + } + + SetButtonDown(true); + CFWL_MessageMouse ms(nullptr, nullptr); + ms.m_dwCmd = FWL_MouseCommand::RightButtonDown; + ms.m_dwFlags = dwFlags; + ms.m_pos = FWLToClient(point); + TranslateFWLMessage(&ms); + return true; +} + +bool CXFA_FFTextEdit::OnRButtonUp(uint32_t dwFlags, const CFX_PointF& point) { + if (!CXFA_FFField::OnRButtonUp(dwFlags, point)) + return false; + + GetDoc()->GetDocEnvironment()->PopupMenu(this, point); + return true; +} + +bool CXFA_FFTextEdit::OnSetFocus(CXFA_FFWidget* pOldWidget) { + m_dwStatus &= ~XFA_WidgetStatus_TextEditValueChanged; + if (!IsFocused()) { + m_dwStatus |= XFA_WidgetStatus_Focused; + UpdateFWLData(); + AddInvalidateRect(); + } + CXFA_FFWidget::OnSetFocus(pOldWidget); + CFWL_MessageSetFocus ms(nullptr, m_pNormalWidget.get()); + TranslateFWLMessage(&ms); + return true; +} + +bool CXFA_FFTextEdit::OnKillFocus(CXFA_FFWidget* pNewWidget) { + CFWL_MessageKillFocus ms(nullptr, m_pNormalWidget.get()); + TranslateFWLMessage(&ms); + m_dwStatus &= ~XFA_WidgetStatus_Focused; + + SetEditScrollOffset(); + ProcessCommittedData(); + UpdateFWLData(); + AddInvalidateRect(); + CXFA_FFWidget::OnKillFocus(pNewWidget); + + m_dwStatus &= ~XFA_WidgetStatus_TextEditValueChanged; + return true; +} + +bool CXFA_FFTextEdit::CommitData() { + CFX_WideString wsText = + static_cast(m_pNormalWidget.get())->GetText(); + if (m_pDataAcc->SetValue(wsText, XFA_VALUEPICTURE_Edit)) { + m_pDataAcc->UpdateUIDisplay(this); + return true; + } + ValidateNumberField(wsText); + return false; +} + +void CXFA_FFTextEdit::ValidateNumberField(const CFX_WideString& wsText) { + CXFA_WidgetAcc* pAcc = GetDataAcc(); + if (!pAcc || pAcc->GetUIType() != XFA_Element::NumericEdit) + return; + + IXFA_AppProvider* pAppProvider = GetApp()->GetAppProvider(); + if (!pAppProvider) + return; + + CFX_WideString wsSomField; + pAcc->GetNode()->GetSOMExpression(wsSomField); + + CFX_WideString wsMessage; + wsMessage.Format(L"%s can not contain %s", wsText.c_str(), + wsSomField.c_str()); + pAppProvider->MsgBox(wsMessage, pAppProvider->GetAppTitle(), XFA_MBICON_Error, + XFA_MB_OK); +} + +bool CXFA_FFTextEdit::IsDataChanged() { + return (m_dwStatus & XFA_WidgetStatus_TextEditValueChanged) != 0; +} + +uint32_t CXFA_FFTextEdit::GetAlignment() { + CXFA_Para para = m_pDataAcc->GetPara(); + if (!para) + return 0; + + uint32_t dwExtendedStyle = 0; + switch (para.GetHorizontalAlign()) { + case XFA_ATTRIBUTEENUM_Center: + dwExtendedStyle |= FWL_STYLEEXT_EDT_HCenter; + break; + case XFA_ATTRIBUTEENUM_Justify: + dwExtendedStyle |= FWL_STYLEEXT_EDT_Justified; + break; + case XFA_ATTRIBUTEENUM_JustifyAll: + case XFA_ATTRIBUTEENUM_Radix: + break; + case XFA_ATTRIBUTEENUM_Right: + dwExtendedStyle |= FWL_STYLEEXT_EDT_HFar; + break; + default: + dwExtendedStyle |= FWL_STYLEEXT_EDT_HNear; + break; + } + + switch (para.GetVerticalAlign()) { + case XFA_ATTRIBUTEENUM_Middle: + dwExtendedStyle |= FWL_STYLEEXT_EDT_VCenter; + break; + case XFA_ATTRIBUTEENUM_Bottom: + dwExtendedStyle |= FWL_STYLEEXT_EDT_VFar; + break; + default: + dwExtendedStyle |= FWL_STYLEEXT_EDT_VNear; + break; + } + return dwExtendedStyle; +} + +bool CXFA_FFTextEdit::UpdateFWLData() { + if (!m_pNormalWidget) + return false; + + XFA_VALUEPICTURE eType = XFA_VALUEPICTURE_Display; + if (IsFocused()) + eType = XFA_VALUEPICTURE_Edit; + + bool bUpdate = false; + if (m_pDataAcc->GetUIType() == XFA_Element::TextEdit && + m_pDataAcc->GetNumberOfCells() < 0) { + XFA_Element elementType = XFA_Element::Unknown; + int32_t iMaxChars = m_pDataAcc->GetMaxChars(elementType); + if (elementType == XFA_Element::ExData) + iMaxChars = eType == XFA_VALUEPICTURE_Edit ? iMaxChars : 0; + if (static_cast(m_pNormalWidget.get())->GetLimit() != + iMaxChars) { + static_cast(m_pNormalWidget.get())->SetLimit(iMaxChars); + bUpdate = true; + } + } + + if (m_pDataAcc->GetUIType() == XFA_Element::Barcode) { + int32_t nDataLen = 0; + if (eType == XFA_VALUEPICTURE_Edit) + m_pDataAcc->GetBarcodeAttribute_DataLength(&nDataLen); + static_cast(m_pNormalWidget.get())->SetLimit(nDataLen); + bUpdate = true; + } + + CFX_WideString wsText; + m_pDataAcc->GetValue(wsText, eType); + + CFX_WideString wsOldText = + static_cast(m_pNormalWidget.get())->GetText(); + if (wsText != wsOldText || (eType == XFA_VALUEPICTURE_Edit && bUpdate)) { + static_cast(m_pNormalWidget.get())->SetText(wsText); + bUpdate = true; + } + if (bUpdate) + m_pNormalWidget->Update(); + + return true; +} + +void CXFA_FFTextEdit::OnTextChanged(CFWL_Widget* pWidget, + const CFX_WideString& wsChanged, + const CFX_WideString& wsPrevText) { + m_dwStatus |= XFA_WidgetStatus_TextEditValueChanged; + CXFA_EventParam eParam; + eParam.m_eType = XFA_EVENT_Change; + eParam.m_wsChange = wsChanged; + eParam.m_pTarget = m_pDataAcc.Get(); + eParam.m_wsPrevText = wsPrevText; + CFWL_Edit* pEdit = static_cast(m_pNormalWidget.get()); + if (m_pDataAcc->GetUIType() == XFA_Element::DateTimeEdit) { + CFWL_DateTimePicker* pDateTime = (CFWL_DateTimePicker*)pEdit; + eParam.m_wsNewText = pDateTime->GetEditText(); + int32_t iSels = pDateTime->CountSelRanges(); + if (iSels) + eParam.m_iSelEnd = pDateTime->GetSelRange(0, &eParam.m_iSelStart); + } else { + eParam.m_wsNewText = pEdit->GetText(); + int32_t iSels = pEdit->CountSelRanges(); + if (iSels) + eParam.m_iSelEnd = pEdit->GetSelRange(0, &eParam.m_iSelStart); + } + m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Change, &eParam); +} + +void CXFA_FFTextEdit::OnTextFull(CFWL_Widget* pWidget) { + CXFA_EventParam eParam; + eParam.m_eType = XFA_EVENT_Full; + eParam.m_pTarget = m_pDataAcc.Get(); + m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Full, &eParam); +} + +bool CXFA_FFTextEdit::CheckWord(const CFX_ByteStringC& sWord) { + if (sWord.IsEmpty() || m_pDataAcc->GetUIType() != XFA_Element::TextEdit) + return true; + return false; +} + +void CXFA_FFTextEdit::OnProcessMessage(CFWL_Message* pMessage) { + m_pOldDelegate->OnProcessMessage(pMessage); +} + +void CXFA_FFTextEdit::OnProcessEvent(CFWL_Event* pEvent) { + CXFA_FFField::OnProcessEvent(pEvent); + switch (pEvent->GetType()) { + case CFWL_Event::Type::TextChanged: { + CFWL_EventTextChanged* event = + static_cast(pEvent); + CFX_WideString wsChange; + OnTextChanged(m_pNormalWidget.get(), wsChange, event->wsPrevText); + break; + } + case CFWL_Event::Type::TextFull: { + OnTextFull(m_pNormalWidget.get()); + break; + } + case CFWL_Event::Type::CheckWord: { + CFX_WideString wstr(L"FWL_EVENT_DTP_SelectChanged"); + CFWL_EventCheckWord* event = static_cast(pEvent); + event->bCheckWord = CheckWord(event->bsWord.AsStringC()); + break; + } + default: + break; + } + m_pOldDelegate->OnProcessEvent(pEvent); +} + +void CXFA_FFTextEdit::OnDrawWidget(CFX_Graphics* pGraphics, + const CFX_Matrix* pMatrix) { + m_pOldDelegate->OnDrawWidget(pGraphics, pMatrix); +} diff --git a/xfa/fxfa/app/cxfa_fftextedit.h b/xfa/fxfa/app/cxfa_fftextedit.h new file mode 100644 index 0000000000..fa0779ed2c --- /dev/null +++ b/xfa/fxfa/app/cxfa_fftextedit.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_APP_CXFA_FFTEXTEDIT_H_ +#define XFA_FXFA_APP_CXFA_FFTEXTEDIT_H_ + +#include "core/fxcrt/fx_coordinates.h" +#include "core/fxcrt/fx_string.h" +#include "xfa/fxfa/app/cxfa_fffield.h" + +class CFWL_Event; +class CFWL_Widget; +class CFX_Matrix; +class CXFA_FFWidget; +class CXFA_WidgetAcc; +class IFWL_WidgetDelegate; + +class CXFA_FFTextEdit : public CXFA_FFField { + public: + explicit CXFA_FFTextEdit(CXFA_WidgetAcc* pDataAcc); + ~CXFA_FFTextEdit() override; + + // CXFA_FFField + bool LoadWidget() override; + void UpdateWidgetProperty() override; + bool OnLButtonDown(uint32_t dwFlags, const CFX_PointF& point) override; + bool OnRButtonDown(uint32_t dwFlags, const CFX_PointF& point) override; + bool OnRButtonUp(uint32_t dwFlags, const CFX_PointF& point) override; + bool OnSetFocus(CXFA_FFWidget* pOldWidget) override; + bool OnKillFocus(CXFA_FFWidget* pNewWidget) override; + void OnProcessMessage(CFWL_Message* pMessage) override; + void OnProcessEvent(CFWL_Event* pEvent) override; + void OnDrawWidget(CFX_Graphics* pGraphics, + const CFX_Matrix* pMatrix = nullptr) override; + + void OnTextChanged(CFWL_Widget* pWidget, + const CFX_WideString& wsChanged, + const CFX_WideString& wsPrevText); + void OnTextFull(CFWL_Widget* pWidget); + bool CheckWord(const CFX_ByteStringC& sWord); + + protected: + uint32_t GetAlignment(); + + IFWL_WidgetDelegate* m_pOldDelegate; + + private: + bool CommitData() override; + bool UpdateFWLData() override; + bool IsDataChanged() override; + void ValidateNumberField(const CFX_WideString& wsText); +}; + +#endif // XFA_FXFA_APP_CXFA_FFTEXTEDIT_H_ diff --git a/xfa/fxfa/app/cxfa_fwladapterwidgetmgr.cpp b/xfa/fxfa/app/cxfa_fwladapterwidgetmgr.cpp new file mode 100644 index 0000000000..42362d858a --- /dev/null +++ b/xfa/fxfa/app/cxfa_fwladapterwidgetmgr.cpp @@ -0,0 +1,38 @@ +// 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/app/cxfa_fwladapterwidgetmgr.h" + +#include "xfa/fxfa/app/cxfa_fffield.h" +#include "xfa/fxfa/cxfa_ffdoc.h" + +CXFA_FWLAdapterWidgetMgr::CXFA_FWLAdapterWidgetMgr() {} + +CXFA_FWLAdapterWidgetMgr::~CXFA_FWLAdapterWidgetMgr() {} + +void CXFA_FWLAdapterWidgetMgr::RepaintWidget(CFWL_Widget* pWidget) { + if (!pWidget) + return; + + CXFA_FFWidget* pFFWidget = pWidget->GetLayoutItem(); + if (!pFFWidget) + return; + + pFFWidget->AddInvalidateRect(nullptr); +} + +bool CXFA_FWLAdapterWidgetMgr::GetPopupPos(CFWL_Widget* pWidget, + float fMinHeight, + float fMaxHeight, + const CFX_RectF& rtAnchor, + CFX_RectF& rtPopup) { + CXFA_FFWidget* pFFWidget = pWidget->GetLayoutItem(); + CFX_RectF rtRotateAnchor(rtAnchor); + pFFWidget->GetRotateMatrix().TransformRect(rtRotateAnchor); + pFFWidget->GetDoc()->GetDocEnvironment()->GetPopupPos( + pFFWidget, fMinHeight, fMaxHeight, rtRotateAnchor, rtPopup); + return true; +} diff --git a/xfa/fxfa/app/cxfa_fwladapterwidgetmgr.h b/xfa/fxfa/app/cxfa_fwladapterwidgetmgr.h new file mode 100644 index 0000000000..f9126eac3f --- /dev/null +++ b/xfa/fxfa/app/cxfa_fwladapterwidgetmgr.h @@ -0,0 +1,28 @@ +// 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_APP_CXFA_FWLADAPTERWIDGETMGR_H_ +#define XFA_FXFA_APP_CXFA_FWLADAPTERWIDGETMGR_H_ + +#include "core/fxcrt/fx_coordinates.h" +#include "core/fxcrt/fx_system.h" + +class CFWL_Widget; + +class CXFA_FWLAdapterWidgetMgr { + public: + CXFA_FWLAdapterWidgetMgr(); + ~CXFA_FWLAdapterWidgetMgr(); + + void RepaintWidget(CFWL_Widget* pWidget); + bool GetPopupPos(CFWL_Widget* pWidget, + float fMinHeight, + float fMaxHeight, + const CFX_RectF& rtAnchor, + CFX_RectF& rtPopup); +}; + +#endif // XFA_FXFA_APP_CXFA_FWLADAPTERWIDGETMGR_H_ diff --git a/xfa/fxfa/app/cxfa_fwltheme.cpp b/xfa/fxfa/app/cxfa_fwltheme.cpp new file mode 100644 index 0000000000..5f8e1dc7dc --- /dev/null +++ b/xfa/fxfa/app/cxfa_fwltheme.cpp @@ -0,0 +1,284 @@ +// 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/app/cxfa_fwltheme.h" + +#include "core/fxcrt/fx_codepage.h" +#include "xfa/fde/cfde_textout.h" +#include "xfa/fgas/font/cfgas_gefont.h" +#include "xfa/fwl/cfwl_barcode.h" +#include "xfa/fwl/cfwl_caret.h" +#include "xfa/fwl/cfwl_checkbox.h" +#include "xfa/fwl/cfwl_combobox.h" +#include "xfa/fwl/cfwl_datetimepicker.h" +#include "xfa/fwl/cfwl_edit.h" +#include "xfa/fwl/cfwl_listbox.h" +#include "xfa/fwl/cfwl_monthcalendar.h" +#include "xfa/fwl/cfwl_picturebox.h" +#include "xfa/fwl/cfwl_pushbutton.h" +#include "xfa/fwl/cfwl_scrollbar.h" +#include "xfa/fwl/cfwl_themebackground.h" +#include "xfa/fwl/cfwl_themetext.h" +#include "xfa/fxfa/cxfa_ffapp.h" +#include "xfa/fxfa/cxfa_ffwidget.h" +#include "xfa/fxgraphics/cfx_color.h" + +namespace { + +const wchar_t* const g_FWLTheme_CalFonts[] = { + L"Arial", L"Courier New", L"DejaVu Sans", +}; + +const float kLineHeight = 12.0f; + +} // namespace + +CXFA_FFWidget* XFA_ThemeGetOuterWidget(CFWL_Widget* pWidget) { + CFWL_Widget* pOuter = pWidget; + while (pOuter && pOuter->GetOuter()) + pOuter = pOuter->GetOuter(); + return pOuter ? pOuter->GetLayoutItem() : nullptr; +} + +CXFA_FWLTheme::CXFA_FWLTheme(CXFA_FFApp* pApp) + : m_pCheckBoxTP(pdfium::MakeUnique()), + m_pListBoxTP(pdfium::MakeUnique()), + m_pPictureBoxTP(pdfium::MakeUnique()), + m_pSrollBarTP(pdfium::MakeUnique()), + m_pEditTP(pdfium::MakeUnique()), + m_pComboBoxTP(pdfium::MakeUnique()), + m_pMonthCalendarTP(pdfium::MakeUnique()), + m_pDateTimePickerTP(pdfium::MakeUnique()), + m_pPushButtonTP(pdfium::MakeUnique()), + m_pCaretTP(pdfium::MakeUnique()), + m_pBarcodeTP(pdfium::MakeUnique()), + m_pTextOut(pdfium::MakeUnique()), + m_pCalendarFont(nullptr), + m_pApp(pApp) { + m_Rect.Reset(); + + for (size_t i = 0; !m_pCalendarFont && i < FX_ArraySize(g_FWLTheme_CalFonts); + ++i) { + m_pCalendarFont = CFGAS_GEFont::LoadFont(g_FWLTheme_CalFonts[i], 0, 0, + m_pApp->GetFDEFontMgr()); + } + if (!m_pCalendarFont) { + m_pCalendarFont = m_pApp->GetFDEFontMgr()->GetFontByCodePage( + FX_CODEPAGE_MSWin_WesternEuropean, 0, nullptr); + } + + ASSERT(m_pCalendarFont); +} + +CXFA_FWLTheme::~CXFA_FWLTheme() { + m_pTextOut.reset(); + FWLTHEME_Release(); +} + +void CXFA_FWLTheme::DrawBackground(CFWL_ThemeBackground* pParams) { + GetTheme(pParams->m_pWidget)->DrawBackground(pParams); +} + +void CXFA_FWLTheme::DrawText(CFWL_ThemeText* pParams) { + if (pParams->m_wsText.IsEmpty()) + return; + + if (pParams->m_pWidget->GetClassID() == FWL_Type::MonthCalendar) { + CXFA_FFWidget* pWidget = XFA_ThemeGetOuterWidget(pParams->m_pWidget); + if (!pWidget) + return; + + m_pTextOut->SetStyles(pParams->m_dwTTOStyles); + m_pTextOut->SetAlignment(pParams->m_iTTOAlign); + m_pTextOut->SetFont(m_pCalendarFont); + m_pTextOut->SetFontSize(FWLTHEME_CAPACITY_FontSize); + m_pTextOut->SetTextColor(FWLTHEME_CAPACITY_TextColor); + if ((pParams->m_iPart == CFWL_Part::DatesIn) && + !(pParams->m_dwStates & FWL_ITEMSTATE_MCD_Flag) && + (pParams->m_dwStates & + (CFWL_PartState_Hovered | CFWL_PartState_Selected))) { + m_pTextOut->SetTextColor(0xFFFFFFFF); + } + if (pParams->m_iPart == CFWL_Part::Caption) + m_pTextOut->SetTextColor(ArgbEncode(0xff, 0, 153, 255)); + + CFX_Graphics* pGraphics = pParams->m_pGraphics; + CFX_RenderDevice* pRenderDevice = pGraphics->GetRenderDevice(); + if (!pRenderDevice) + return; + + m_pTextOut->SetRenderDevice(pRenderDevice); + CFX_Matrix mtPart = pParams->m_matrix; + CFX_Matrix* pMatrix = pGraphics->GetMatrix(); + if (pMatrix) { + mtPart.Concat(*pMatrix); + } + m_pTextOut->SetMatrix(mtPart); + m_pTextOut->DrawLogicText(pParams->m_wsText.c_str(), + pParams->m_wsText.GetLength(), pParams->m_rtPart); + return; + } + CXFA_FFWidget* pWidget = XFA_ThemeGetOuterWidget(pParams->m_pWidget); + if (!pWidget) + return; + + CXFA_WidgetAcc* pAcc = pWidget->GetDataAcc(); + CFX_Graphics* pGraphics = pParams->m_pGraphics; + CFX_RenderDevice* pRenderDevice = pGraphics->GetRenderDevice(); + if (!pRenderDevice) + return; + + m_pTextOut->SetRenderDevice(pRenderDevice); + m_pTextOut->SetStyles(pParams->m_dwTTOStyles); + m_pTextOut->SetAlignment(pParams->m_iTTOAlign); + m_pTextOut->SetFont(pAcc->GetFDEFont()); + m_pTextOut->SetFontSize(pAcc->GetFontSize()); + m_pTextOut->SetTextColor(pAcc->GetTextColor()); + CFX_Matrix mtPart = pParams->m_matrix; + CFX_Matrix* pMatrix = pGraphics->GetMatrix(); + if (pMatrix) + mtPart.Concat(*pMatrix); + + m_pTextOut->SetMatrix(mtPart); + m_pTextOut->DrawLogicText(pParams->m_wsText.c_str(), + pParams->m_wsText.GetLength(), pParams->m_rtPart); +} + +CFX_RectF CXFA_FWLTheme::GetUIMargin(CFWL_ThemePart* pThemePart) const { + CFX_RectF rect; + CXFA_FFWidget* pWidget = XFA_ThemeGetOuterWidget(pThemePart->m_pWidget); + if (!pWidget) + return rect; + + CXFA_LayoutItem* pItem = pWidget; + CXFA_WidgetAcc* pWidgetAcc = pWidget->GetDataAcc(); + rect = pWidgetAcc->GetUIMargin(); + if (CXFA_Para para = pWidgetAcc->GetPara()) { + rect.left += para.GetMarginLeft(); + if (pWidgetAcc->IsMultiLine()) + rect.width += para.GetMarginRight(); + } + if (!pItem->GetPrev()) { + if (pItem->GetNext()) + rect.height = 0; + } else if (!pItem->GetNext()) { + rect.top = 0; + } else { + rect.top = 0; + rect.height = 0; + } + return rect; +} + +float CXFA_FWLTheme::GetCXBorderSize() const { + return 1.0f; +} + +float CXFA_FWLTheme::GetCYBorderSize() const { + return 1.0f; +} + +float CXFA_FWLTheme::GetFontSize(CFWL_ThemePart* pThemePart) const { + if (CXFA_FFWidget* pWidget = XFA_ThemeGetOuterWidget(pThemePart->m_pWidget)) + return pWidget->GetDataAcc()->GetFontSize(); + return FWLTHEME_CAPACITY_FontSize; +} + +CFX_RetainPtr CXFA_FWLTheme::GetFont( + CFWL_ThemePart* pThemePart) const { + if (CXFA_FFWidget* pWidget = XFA_ThemeGetOuterWidget(pThemePart->m_pWidget)) + return pWidget->GetDataAcc()->GetFDEFont(); + return GetTheme(pThemePart->m_pWidget)->GetFont(); +} + +float CXFA_FWLTheme::GetLineHeight(CFWL_ThemePart* pThemePart) const { + if (CXFA_FFWidget* pWidget = XFA_ThemeGetOuterWidget(pThemePart->m_pWidget)) + return pWidget->GetDataAcc()->GetLineHeight(); + return kLineHeight; +} + +float CXFA_FWLTheme::GetScrollBarWidth() const { + return 9.0f; +} + +FX_COLORREF CXFA_FWLTheme::GetTextColor(CFWL_ThemePart* pThemePart) const { + if (CXFA_FFWidget* pWidget = XFA_ThemeGetOuterWidget(pThemePart->m_pWidget)) + return pWidget->GetDataAcc()->GetTextColor(); + return FWLTHEME_CAPACITY_TextColor; +} + +CFX_SizeF CXFA_FWLTheme::GetSpaceAboveBelow(CFWL_ThemePart* pThemePart) const { + CFX_SizeF sizeAboveBelow; + if (CXFA_FFWidget* pWidget = XFA_ThemeGetOuterWidget(pThemePart->m_pWidget)) { + CXFA_WidgetAcc* pWidgetAcc = pWidget->GetDataAcc(); + if (CXFA_Para para = pWidgetAcc->GetPara()) { + sizeAboveBelow.width = para.GetSpaceAbove(); + sizeAboveBelow.height = para.GetSpaceBelow(); + } + } + return sizeAboveBelow; +} + +void CXFA_FWLTheme::CalcTextRect(CFWL_ThemeText* pParams, CFX_RectF& rect) { + if (pParams->m_pWidget->GetClassID() == FWL_Type::MonthCalendar) { + CXFA_FFWidget* pWidget = XFA_ThemeGetOuterWidget(pParams->m_pWidget); + if (!pWidget || !pParams || !m_pTextOut) + return; + + m_pTextOut->SetFont(m_pCalendarFont); + m_pTextOut->SetFontSize(FWLTHEME_CAPACITY_FontSize); + m_pTextOut->SetTextColor(FWLTHEME_CAPACITY_TextColor); + m_pTextOut->SetAlignment(pParams->m_iTTOAlign); + m_pTextOut->SetStyles(pParams->m_dwTTOStyles); + m_pTextOut->CalcLogicSize(pParams->m_wsText.c_str(), + pParams->m_wsText.GetLength(), rect); + } + + CXFA_FFWidget* pWidget = XFA_ThemeGetOuterWidget(pParams->m_pWidget); + if (!pWidget) + return; + + CXFA_WidgetAcc* pAcc = pWidget->GetDataAcc(); + m_pTextOut->SetFont(pAcc->GetFDEFont()); + m_pTextOut->SetFontSize(pAcc->GetFontSize()); + m_pTextOut->SetTextColor(pAcc->GetTextColor()); + if (!pParams) + return; + + m_pTextOut->SetAlignment(pParams->m_iTTOAlign); + m_pTextOut->SetStyles(pParams->m_dwTTOStyles); + m_pTextOut->CalcLogicSize(pParams->m_wsText.c_str(), + pParams->m_wsText.GetLength(), rect); +} + +CFWL_WidgetTP* CXFA_FWLTheme::GetTheme(CFWL_Widget* pWidget) const { + switch (pWidget->GetClassID()) { + case FWL_Type::CheckBox: + return m_pCheckBoxTP.get(); + case FWL_Type::ListBox: + return m_pListBoxTP.get(); + case FWL_Type::PictureBox: + return m_pPictureBoxTP.get(); + case FWL_Type::ScrollBar: + return m_pSrollBarTP.get(); + case FWL_Type::Edit: + return m_pEditTP.get(); + case FWL_Type::ComboBox: + return m_pComboBoxTP.get(); + case FWL_Type::MonthCalendar: + return m_pMonthCalendarTP.get(); + case FWL_Type::DateTimePicker: + return m_pDateTimePickerTP.get(); + case FWL_Type::PushButton: + return m_pPushButtonTP.get(); + case FWL_Type::Caret: + return m_pCaretTP.get(); + case FWL_Type::Barcode: + return m_pBarcodeTP.get(); + default: + return nullptr; + } +} diff --git a/xfa/fxfa/app/cxfa_fwltheme.h b/xfa/fxfa/app/cxfa_fwltheme.h new file mode 100644 index 0000000000..eaca99082d --- /dev/null +++ b/xfa/fxfa/app/cxfa_fwltheme.h @@ -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 + +#ifndef XFA_FXFA_APP_CXFA_FWLTHEME_H_ +#define XFA_FXFA_APP_CXFA_FWLTHEME_H_ + +#include + +#include "xfa/fwl/ifwl_themeprovider.h" +#include "xfa/fwl/theme/cfwl_barcodetp.h" +#include "xfa/fwl/theme/cfwl_carettp.h" +#include "xfa/fwl/theme/cfwl_checkboxtp.h" +#include "xfa/fwl/theme/cfwl_comboboxtp.h" +#include "xfa/fwl/theme/cfwl_datetimepickertp.h" +#include "xfa/fwl/theme/cfwl_edittp.h" +#include "xfa/fwl/theme/cfwl_listboxtp.h" +#include "xfa/fwl/theme/cfwl_monthcalendartp.h" +#include "xfa/fwl/theme/cfwl_pictureboxtp.h" +#include "xfa/fwl/theme/cfwl_pushbuttontp.h" +#include "xfa/fwl/theme/cfwl_scrollbartp.h" +#include "xfa/fwl/theme/cfwl_widgettp.h" +#include "xfa/fxfa/cxfa_ffapp.h" + +class CXFA_FWLTheme final : public IFWL_ThemeProvider { + public: + explicit CXFA_FWLTheme(CXFA_FFApp* pApp); + ~CXFA_FWLTheme() override; + + // IFWL_ThemeProvider: + void DrawBackground(CFWL_ThemeBackground* pParams) override; + void DrawText(CFWL_ThemeText* pParams) override; + void CalcTextRect(CFWL_ThemeText* pParams, CFX_RectF& rect) override; + float GetCXBorderSize() const override; + float GetCYBorderSize() const override; + CFX_RectF GetUIMargin(CFWL_ThemePart* pThemePart) const override; + float GetFontSize(CFWL_ThemePart* pThemePart) const override; + CFX_RetainPtr GetFont( + CFWL_ThemePart* pThemePart) const override; + float GetLineHeight(CFWL_ThemePart* pThemePart) const override; + float GetScrollBarWidth() const override; + FX_COLORREF GetTextColor(CFWL_ThemePart* pThemePart) const override; + CFX_SizeF GetSpaceAboveBelow(CFWL_ThemePart* pThemePart) const override; + + private: + CFWL_WidgetTP* GetTheme(CFWL_Widget* pWidget) const; + + std::unique_ptr m_pCheckBoxTP; + std::unique_ptr m_pListBoxTP; + std::unique_ptr m_pPictureBoxTP; + std::unique_ptr m_pSrollBarTP; + std::unique_ptr m_pEditTP; + std::unique_ptr m_pComboBoxTP; + std::unique_ptr m_pMonthCalendarTP; + std::unique_ptr m_pDateTimePickerTP; + std::unique_ptr m_pPushButtonTP; + std::unique_ptr m_pCaretTP; + std::unique_ptr m_pBarcodeTP; + std::unique_ptr m_pTextOut; + CFX_RetainPtr m_pCalendarFont; + CFX_WideString m_wsResource; + CFX_UnownedPtr const m_pApp; + CFX_RectF m_Rect; +}; + +CXFA_FFWidget* XFA_ThemeGetOuterWidget(CFWL_Widget* pWidget); + +#endif // XFA_FXFA_APP_CXFA_FWLTHEME_H_ diff --git a/xfa/fxfa/app/cxfa_pieceline.cpp b/xfa/fxfa/app/cxfa_pieceline.cpp index b906cf26e3..2e1ea55f1c 100644 --- a/xfa/fxfa/app/cxfa_pieceline.cpp +++ b/xfa/fxfa/app/cxfa_pieceline.cpp @@ -6,7 +6,7 @@ #include "xfa/fxfa/app/cxfa_pieceline.h" -#include "xfa/fxfa/app/xfa_textpiece.h" +#include "xfa/fxfa/app/cxfa_textpiece.h" CXFA_PieceLine::CXFA_PieceLine() {} diff --git a/xfa/fxfa/app/cxfa_pieceline.h b/xfa/fxfa/app/cxfa_pieceline.h index 87f71fc192..6b17ebfb11 100644 --- a/xfa/fxfa/app/cxfa_pieceline.h +++ b/xfa/fxfa/app/cxfa_pieceline.h @@ -12,14 +12,14 @@ #include "core/fxcrt/fx_basic.h" -class XFA_TextPiece; +class CXFA_TextPiece; class CXFA_PieceLine { public: CXFA_PieceLine(); ~CXFA_PieceLine(); - std::vector> m_textPieces; + std::vector> m_textPieces; std::vector m_charCounts; }; diff --git a/xfa/fxfa/app/cxfa_textlayout.cpp b/xfa/fxfa/app/cxfa_textlayout.cpp index c43f7e3260..489df9ab9c 100644 --- a/xfa/fxfa/app/cxfa_textlayout.cpp +++ b/xfa/fxfa/app/cxfa_textlayout.cpp @@ -24,10 +24,10 @@ #include "xfa/fxfa/app/cxfa_loadercontext.h" #include "xfa/fxfa/app/cxfa_pieceline.h" #include "xfa/fxfa/app/cxfa_textparsecontext.h" +#include "xfa/fxfa/app/cxfa_textpiece.h" +#include "xfa/fxfa/app/cxfa_textprovider.h" #include "xfa/fxfa/app/cxfa_texttabstopscontext.h" #include "xfa/fxfa/app/cxfa_textuserdata.h" -#include "xfa/fxfa/app/xfa_ffwidgetacc.h" -#include "xfa/fxfa/app/xfa_textpiece.h" #include "xfa/fxfa/parser/cxfa_font.h" #include "xfa/fxfa/parser/cxfa_node.h" #include "xfa/fxfa/parser/cxfa_para.h" @@ -594,7 +594,7 @@ bool CXFA_TextLayout::DrawString(CFX_RenderDevice* pFxDevice, int32_t iPieces = pdfium::CollectionSize(pPieceLine->m_textPieces); int32_t j = 0; for (j = 0; j < iPieces; j++) { - const XFA_TextPiece* pPiece = pPieceLine->m_textPieces[j].get(); + const CXFA_TextPiece* pPiece = pPieceLine->m_textPieces[j].get(); int32_t iChars = pPiece->iChars; if (iCharCount < iChars) { FX_Free(pCharPos); @@ -964,7 +964,7 @@ void CXFA_TextLayout::DoTabstops(CFDE_CSSComputedStyle* pStyle, if (iPieces == 0) return; - XFA_TextPiece* pPiece = pPieceLine->m_textPieces[iPieces - 1].get(); + CXFA_TextPiece* pPiece = pPieceLine->m_textPieces[iPieces - 1].get(); int32_t& iTabstopsIndex = m_pTabstopContext->m_iTabIndex; int32_t iCount = m_textParser.CountTabs(pStyle); if (!pdfium::IndexInBounds(m_pTabstopContext->m_tabstops, iTabstopsIndex)) @@ -975,7 +975,7 @@ void CXFA_TextLayout::DoTabstops(CFDE_CSSComputedStyle* pStyle, m_pTabstopContext->m_bTabstops = true; float fRight = 0; if (iPieces > 1) { - XFA_TextPiece* p = pPieceLine->m_textPieces[iPieces - 2].get(); + CXFA_TextPiece* p = pPieceLine->m_textPieces[iPieces - 2].get(); fRight = p->rtPiece.right(); } m_pTabstopContext->m_fTabWidth = @@ -1032,7 +1032,7 @@ void CXFA_TextLayout::AppendTextLine(CFX_BreakType dwStatus, pStyle = pUserData->m_pStyle; float fVerScale = pPiece->m_iVerticalScale / 100.0f; - auto pTP = pdfium::MakeUnique(); + auto pTP = pdfium::MakeUnique(); pTP->iChars = pPiece->m_iChars; pTP->szText = pPiece->GetString(); pTP->Widths = pPiece->GetWidths(); @@ -1149,7 +1149,7 @@ void CXFA_TextLayout::RenderString(CFDE_RenderDevice* pDevice, int32_t iPiece, FXTEXT_CHARPOS* pCharPos, const CFX_Matrix& tmDoc2Device) { - const XFA_TextPiece* pPiece = pPieceLine->m_textPieces[iPiece].get(); + const CXFA_TextPiece* pPiece = pPieceLine->m_textPieces[iPiece].get(); int32_t iCount = GetDisplayPos(pPiece, pCharPos); if (iCount > 0) { pBrush->SetColor(pPiece->dwColor); @@ -1165,7 +1165,7 @@ void CXFA_TextLayout::RenderPath(CFDE_RenderDevice* pDevice, int32_t iPiece, FXTEXT_CHARPOS* pCharPos, const CFX_Matrix& tmDoc2Device) { - XFA_TextPiece* pPiece = pPieceLine->m_textPieces[iPiece].get(); + CXFA_TextPiece* pPiece = pPieceLine->m_textPieces[iPiece].get(); bool bNoUnderline = pPiece->iUnderline < 1 || pPiece->iUnderline > 2; bool bNoLineThrough = pPiece->iLineThrough < 1 || pPiece->iLineThrough > 2; if (bNoUnderline && bNoLineThrough) @@ -1273,7 +1273,7 @@ void CXFA_TextLayout::RenderPath(CFDE_RenderDevice* pDevice, pDevice->DrawPath(pPen, 1, pPath.get(), &tmDoc2Device); } -int32_t CXFA_TextLayout::GetDisplayPos(const XFA_TextPiece* pPiece, +int32_t CXFA_TextLayout::GetDisplayPos(const CXFA_TextPiece* pPiece, FXTEXT_CHARPOS* pCharPos, bool bCharCode) { if (!pPiece) @@ -1285,7 +1285,7 @@ int32_t CXFA_TextLayout::GetDisplayPos(const XFA_TextPiece* pPiece, return m_pBreak->GetDisplayPos(&tr, pCharPos, bCharCode); } -bool CXFA_TextLayout::ToRun(const XFA_TextPiece* pPiece, FX_RTFTEXTOBJ* tr) { +bool CXFA_TextLayout::ToRun(const CXFA_TextPiece* pPiece, FX_RTFTEXTOBJ* tr) { int32_t iLength = pPiece->iChars; if (iLength < 1) return false; diff --git a/xfa/fxfa/app/cxfa_textlayout.h b/xfa/fxfa/app/cxfa_textlayout.h index 75c2d56324..e8c203fcc1 100644 --- a/xfa/fxfa/app/cxfa_textlayout.h +++ b/xfa/fxfa/app/cxfa_textlayout.h @@ -29,7 +29,7 @@ class CXFA_Node; class CXFA_PieceLine; class CXFA_TextProvider; class CXFA_TextTabstopsContext; -class XFA_TextPiece; +class CXFA_TextPiece; class CXFA_TextLayout { public: @@ -112,10 +112,10 @@ class CXFA_TextLayout { int32_t iPiece, FXTEXT_CHARPOS* pCharPos, const CFX_Matrix& tmDoc2Device); - int32_t GetDisplayPos(const XFA_TextPiece* pPiece, + int32_t GetDisplayPos(const CXFA_TextPiece* pPiece, FXTEXT_CHARPOS* pCharPos, bool bCharCode = false); - bool ToRun(const XFA_TextPiece* pPiece, FX_RTFTEXTOBJ* tr); + bool ToRun(const CXFA_TextPiece* pPiece, FX_RTFTEXTOBJ* tr); void DoTabstops(CFDE_CSSComputedStyle* pStyle, CXFA_PieceLine* pPieceLine); bool Layout(int32_t iBlock); int32_t CountBlocks() const; diff --git a/xfa/fxfa/app/cxfa_textparser.cpp b/xfa/fxfa/app/cxfa_textparser.cpp index 33bd2b9deb..8bdb0a8372 100644 --- a/xfa/fxfa/app/cxfa_textparser.cpp +++ b/xfa/fxfa/app/cxfa_textparser.cpp @@ -21,8 +21,8 @@ #include "xfa/fgas/font/cfgas_fontmgr.h" #include "xfa/fxfa/app/cxfa_csstagprovider.h" #include "xfa/fxfa/app/cxfa_textparsecontext.h" +#include "xfa/fxfa/app/cxfa_textprovider.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" diff --git a/xfa/fxfa/app/cxfa_textpiece.cpp b/xfa/fxfa/app/cxfa_textpiece.cpp new file mode 100644 index 0000000000..4cbad0a475 --- /dev/null +++ b/xfa/fxfa/app/cxfa_textpiece.cpp @@ -0,0 +1,13 @@ +// 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/app/cxfa_textpiece.h" + +#include "xfa/fxfa/app/cxfa_linkuserdata.h" + +CXFA_TextPiece::CXFA_TextPiece() {} + +CXFA_TextPiece::~CXFA_TextPiece() {} diff --git a/xfa/fxfa/app/cxfa_textpiece.h b/xfa/fxfa/app/cxfa_textpiece.h new file mode 100644 index 0000000000..0fba66ef52 --- /dev/null +++ b/xfa/fxfa/app/cxfa_textpiece.h @@ -0,0 +1,41 @@ +// 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_APP_CXFA_TEXTPIECE_H_ +#define XFA_FXFA_APP_CXFA_TEXTPIECE_H_ + +#include + +#include "core/fxcrt/fx_basic.h" +#include "core/fxcrt/fx_coordinates.h" +#include "core/fxcrt/fx_string.h" +#include "core/fxge/fx_dib.h" +#include "xfa/fgas/font/cfgas_gefont.h" + +class CXFA_LinkUserData; + +class CXFA_TextPiece { + public: + CXFA_TextPiece(); + ~CXFA_TextPiece(); + + CFX_WideString szText; + std::vector Widths; + int32_t iChars; + int32_t iHorScale; + int32_t iVerScale; + int32_t iBidiLevel; + int32_t iUnderline; + int32_t iPeriod; + int32_t iLineThrough; + FX_ARGB dwColor; + float fFontSize; + CFX_RectF rtPiece; + CFX_RetainPtr pFont; + CFX_RetainPtr pLinkData; +}; + +#endif // XFA_FXFA_APP_CXFA_TEXTPIECE_H_ diff --git a/xfa/fxfa/app/cxfa_textprovider.cpp b/xfa/fxfa/app/cxfa_textprovider.cpp new file mode 100644 index 0000000000..01bc021f8c --- /dev/null +++ b/xfa/fxfa/app/cxfa_textprovider.cpp @@ -0,0 +1,166 @@ +// 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/app/cxfa_textprovider.h" + +#include +#include +#include + +#include "core/fxcrt/xml/cfx_xmlelement.h" +#include "core/fxcrt/xml/cfx_xmlnode.h" +#include "fxjs/cfxjse_value.h" +#include "third_party/base/ptr_util.h" +#include "third_party/base/stl_util.h" +#include "xfa/fde/cfde_textout.h" +#include "xfa/fxfa/app/cxfa_ffcheckbutton.h" +#include "xfa/fxfa/app/cxfa_fffield.h" +#include "xfa/fxfa/app/cxfa_fwladapterwidgetmgr.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_localevalue.h" +#include "xfa/fxfa/parser/cxfa_node.h" +#include "xfa/fxfa/parser/cxfa_scriptcontext.h" +#include "xfa/fxfa/parser/xfa_resolvenode_rs.h" + +CXFA_Node* CXFA_TextProvider::GetTextNode(bool& bRichText) { + bRichText = false; + + if (m_eType == XFA_TEXTPROVIDERTYPE_Text) { + CXFA_Node* pElementNode = m_pWidgetAcc->GetNode(); + CXFA_Node* pValueNode = pElementNode->GetChild(0, XFA_Element::Value); + if (!pValueNode) + return nullptr; + + CXFA_Node* pChildNode = pValueNode->GetNodeItem(XFA_NODEITEM_FirstChild); + if (pChildNode && pChildNode->GetElementType() == XFA_Element::ExData) { + CFX_WideString wsContentType; + pChildNode->GetAttribute(XFA_ATTRIBUTE_ContentType, wsContentType, false); + if (wsContentType == L"text/html") + bRichText = true; + } + return pChildNode; + } + + if (m_eType == XFA_TEXTPROVIDERTYPE_Datasets) { + CXFA_Node* pBind = m_pWidgetAcc->GetDatasets(); + CFX_XMLNode* pXMLNode = pBind->GetXMLMappingNode(); + ASSERT(pXMLNode); + for (CFX_XMLNode* pXMLChild = + pXMLNode->GetNodeItem(CFX_XMLNode::FirstChild); + pXMLChild; + pXMLChild = pXMLChild->GetNodeItem(CFX_XMLNode::NextSibling)) { + if (pXMLChild->GetType() == FX_XMLNODE_Element) { + CFX_XMLElement* pElement = static_cast(pXMLChild); + if (XFA_RecognizeRichText(pElement)) + bRichText = true; + } + } + return pBind; + } + + if (m_eType == XFA_TEXTPROVIDERTYPE_Caption) { + CXFA_Node* pCaptionNode = + m_pWidgetAcc->GetNode()->GetChild(0, XFA_Element::Caption); + if (!pCaptionNode) + return nullptr; + + CXFA_Node* pValueNode = pCaptionNode->GetChild(0, XFA_Element::Value); + if (!pValueNode) + return nullptr; + + CXFA_Node* pChildNode = pValueNode->GetNodeItem(XFA_NODEITEM_FirstChild); + if (pChildNode && pChildNode->GetElementType() == XFA_Element::ExData) { + CFX_WideString wsContentType; + pChildNode->GetAttribute(XFA_ATTRIBUTE_ContentType, wsContentType, false); + if (wsContentType == L"text/html") + bRichText = true; + } + return pChildNode; + } + + CXFA_Node* pItemNode = + m_pWidgetAcc->GetNode()->GetChild(0, XFA_Element::Items); + if (!pItemNode) + return nullptr; + + CXFA_Node* pNode = pItemNode->GetNodeItem(XFA_NODEITEM_FirstChild); + while (pNode) { + CFX_WideStringC wsName; + pNode->TryCData(XFA_ATTRIBUTE_Name, wsName); + if (m_eType == XFA_TEXTPROVIDERTYPE_Rollover && wsName == L"rollover") + return pNode; + if (m_eType == XFA_TEXTPROVIDERTYPE_Down && wsName == L"down") + return pNode; + + pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling); + } + return nullptr; +} + +CXFA_Para CXFA_TextProvider::GetParaNode() { + if (m_eType == XFA_TEXTPROVIDERTYPE_Text) + return m_pWidgetAcc->GetPara(); + + CXFA_Node* pNode = m_pWidgetAcc->GetNode()->GetChild(0, XFA_Element::Caption); + return CXFA_Para(pNode->GetChild(0, XFA_Element::Para)); +} + +CXFA_Font CXFA_TextProvider::GetFontNode() { + if (m_eType == XFA_TEXTPROVIDERTYPE_Text) + return m_pWidgetAcc->GetFont(false); + + CXFA_Node* pNode = m_pWidgetAcc->GetNode()->GetChild(0, XFA_Element::Caption); + pNode = pNode->GetChild(0, XFA_Element::Font); + return pNode ? CXFA_Font(pNode) : m_pWidgetAcc->GetFont(false); +} + +bool CXFA_TextProvider::IsCheckButtonAndAutoWidth() { + XFA_Element eType = m_pWidgetAcc->GetUIType(); + if (eType != XFA_Element::CheckButton) + return false; + + float fWidth = 0; + return !m_pWidgetAcc->GetWidth(fWidth); +} + +bool CXFA_TextProvider::GetEmbbedObj(bool bURI, + bool bRaw, + const CFX_WideString& wsAttr, + CFX_WideString& wsValue) { + if (m_eType != XFA_TEXTPROVIDERTYPE_Text) + return false; + + if (!bURI) + return false; + + CXFA_Node* pWidgetNode = m_pWidgetAcc->GetNode(); + CXFA_Node* pParent = pWidgetNode->GetNodeItem(XFA_NODEITEM_Parent); + CXFA_Document* pDocument = pWidgetNode->GetDocument(); + CXFA_Node* pIDNode = nullptr; + CXFA_WidgetAcc* pEmbAcc = nullptr; + if (pParent) + pIDNode = pDocument->GetNodeByID(pParent, wsAttr.AsStringC()); + + if (!pIDNode) { + pIDNode = pDocument->GetNodeByID( + ToNode(pDocument->GetXFAObject(XFA_HASHCODE_Form)), wsAttr.AsStringC()); + } + if (pIDNode) + pEmbAcc = static_cast(pIDNode->GetWidgetData()); + + if (!pEmbAcc) + return false; + + pEmbAcc->GetValue(wsValue, XFA_VALUEPICTURE_Display); + return true; +} diff --git a/xfa/fxfa/app/cxfa_textprovider.h b/xfa/fxfa/app/cxfa_textprovider.h new file mode 100644 index 0000000000..08fc6f38e2 --- /dev/null +++ b/xfa/fxfa/app/cxfa_textprovider.h @@ -0,0 +1,50 @@ +// 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_APP_CXFA_TEXTPROVIDER_H_ +#define XFA_FXFA_APP_CXFA_TEXTPROVIDER_H_ + +#include "core/fxcrt/fx_string.h" +#include "xfa/fxfa/app/cxfa_textlayout.h" +#include "xfa/fxfa/cxfa_widgetacc.h" +#include "xfa/fxfa/parser/cxfa_font.h" +#include "xfa/fxfa/parser/cxfa_para.h" + +class CXFA_FFDoc; +class CXFA_Node; + +enum XFA_TEXTPROVIDERTYPE { + XFA_TEXTPROVIDERTYPE_Text, + XFA_TEXTPROVIDERTYPE_Datasets, + XFA_TEXTPROVIDERTYPE_Caption, + XFA_TEXTPROVIDERTYPE_Rollover, + XFA_TEXTPROVIDERTYPE_Down, +}; + +class CXFA_TextProvider { + public: + CXFA_TextProvider(CXFA_WidgetAcc* pWidgetAcc, XFA_TEXTPROVIDERTYPE eType) + : m_pWidgetAcc(pWidgetAcc), m_eType(eType) { + ASSERT(m_pWidgetAcc); + } + ~CXFA_TextProvider() {} + + CXFA_Node* GetTextNode(bool& bRichText); + CXFA_Para GetParaNode(); + CXFA_Font GetFontNode(); + bool IsCheckButtonAndAutoWidth(); + CXFA_FFDoc* GetDocNode() { return m_pWidgetAcc->GetDoc(); } + bool GetEmbbedObj(bool bURI, + bool bRaw, + const CFX_WideString& wsAttr, + CFX_WideString& wsValue); + + private: + CXFA_WidgetAcc* m_pWidgetAcc; + XFA_TEXTPROVIDERTYPE m_eType; +}; + +#endif // XFA_FXFA_APP_CXFA_TEXTPROVIDER_H_ diff --git a/xfa/fxfa/app/xfa_ffbarcode.cpp b/xfa/fxfa/app/xfa_ffbarcode.cpp deleted file mode 100644 index 4dcffa5bad..0000000000 --- a/xfa/fxfa/app/xfa_ffbarcode.cpp +++ /dev/null @@ -1,227 +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/app/xfa_ffbarcode.h" - -#include - -#include "core/fxcrt/fx_extension.h" -#include "third_party/base/ptr_util.h" -#include "xfa/fwl/cfwl_app.h" -#include "xfa/fwl/cfwl_barcode.h" -#include "xfa/fwl/cfwl_notedriver.h" -#include "xfa/fxfa/app/xfa_fffield.h" -#include "xfa/fxfa/app/xfa_fftextedit.h" -#include "xfa/fxfa/app/xfa_fwladapter.h" -#include "xfa/fxfa/cxfa_ffpageview.h" -#include "xfa/fxfa/cxfa_ffwidget.h" - -namespace { - -const BarCodeInfo g_BarCodeData[] = { - {0x7fb4a18, L"ean13", BarcodeType::ean13, BC_EAN13}, - {0x8d13a3d, L"code11", BarcodeType::code11, BC_UNKNOWN}, - {0x8d149a8, L"code49", BarcodeType::code49, BC_UNKNOWN}, - {0x8d16347, L"code93", BarcodeType::code93, BC_UNKNOWN}, - {0x91a92e2, L"upsMaxicode", BarcodeType::upsMaxicode, BC_UNKNOWN}, - {0xa7d48dc, L"fim", BarcodeType::fim, BC_UNKNOWN}, - {0xb359fe9, L"msi", BarcodeType::msi, BC_UNKNOWN}, - {0x121f738c, L"code2Of5Matrix", BarcodeType::code2Of5Matrix, BC_UNKNOWN}, - {0x15358616, L"ucc128", BarcodeType::ucc128, BC_UNKNOWN}, - {0x1f4bfa05, L"rfid", BarcodeType::rfid, BC_UNKNOWN}, - {0x1fda71bc, L"rss14Stacked", BarcodeType::rss14Stacked, BC_UNKNOWN}, - {0x22065087, L"ean8add2", BarcodeType::ean8add2, BC_UNKNOWN}, - {0x2206508a, L"ean8add5", BarcodeType::ean8add5, BC_UNKNOWN}, - {0x2278366c, L"codabar", BarcodeType::codabar, BC_CODABAR}, - {0x2a039a8d, L"telepen", BarcodeType::telepen, BC_UNKNOWN}, - {0x323ed337, L"upcApwcd", BarcodeType::upcApwcd, BC_UNKNOWN}, - {0x347a1846, L"postUSIMB", BarcodeType::postUSIMB, BC_UNKNOWN}, - {0x391bb836, L"code128", BarcodeType::code128, BC_CODE128}, - {0x398eddaf, L"dataMatrix", BarcodeType::dataMatrix, BC_DATAMATRIX}, - {0x3cff60a8, L"upcEadd2", BarcodeType::upcEadd2, BC_UNKNOWN}, - {0x3cff60ab, L"upcEadd5", BarcodeType::upcEadd5, BC_UNKNOWN}, - {0x402cb188, L"code2Of5Standard", BarcodeType::code2Of5Standard, - BC_UNKNOWN}, - {0x411764f7, L"aztec", BarcodeType::aztec, BC_UNKNOWN}, - {0x44d4e84c, L"ean8", BarcodeType::ean8, BC_EAN8}, - {0x48468902, L"ucc128sscc", BarcodeType::ucc128sscc, BC_UNKNOWN}, - {0x4880aea4, L"upcAadd2", BarcodeType::upcAadd2, BC_UNKNOWN}, - {0x4880aea7, L"upcAadd5", BarcodeType::upcAadd5, BC_UNKNOWN}, - {0x54f18256, L"code2Of5Industrial", BarcodeType::code2Of5Industrial, - BC_UNKNOWN}, - {0x58e15f25, L"rss14Limited", BarcodeType::rss14Limited, BC_UNKNOWN}, - {0x5c08d1b9, L"postAUSReplyPaid", BarcodeType::postAUSReplyPaid, - BC_UNKNOWN}, - {0x5fa700bd, L"rss14", BarcodeType::rss14, BC_UNKNOWN}, - {0x631a7e35, L"logmars", BarcodeType::logmars, BC_UNKNOWN}, - {0x6a236236, L"pdf417", BarcodeType::pdf417, BC_PDF417}, - {0x6d098ece, L"upcean2", BarcodeType::upcean2, BC_UNKNOWN}, - {0x6d098ed1, L"upcean5", BarcodeType::upcean5, BC_UNKNOWN}, - {0x76b04eed, L"code3Of9extended", BarcodeType::code3Of9extended, - BC_UNKNOWN}, - {0x7c7db84a, L"maxicode", BarcodeType::maxicode, BC_UNKNOWN}, - {0x8266f7f7, L"ucc128random", BarcodeType::ucc128random, BC_UNKNOWN}, - {0x83eca147, L"postUSDPBC", BarcodeType::postUSDPBC, BC_UNKNOWN}, - {0x8dd71de0, L"postAUSStandard", BarcodeType::postAUSStandard, BC_UNKNOWN}, - {0x98adad85, L"plessey", BarcodeType::plessey, BC_UNKNOWN}, - {0x9f84cce6, L"ean13pwcd", BarcodeType::ean13pwcd, BC_UNKNOWN}, - {0xb514fbe9, L"upcA", BarcodeType::upcA, BC_UPCA}, - {0xb514fbed, L"upcE", BarcodeType::upcE, BC_UNKNOWN}, - {0xb5c6a853, L"ean13add2", BarcodeType::ean13add2, BC_UNKNOWN}, - {0xb5c6a856, L"ean13add5", BarcodeType::ean13add5, BC_UNKNOWN}, - {0xb81fc512, L"postUKRM4SCC", BarcodeType::postUKRM4SCC, BC_UNKNOWN}, - {0xbad34b22, L"code128SSCC", BarcodeType::code128SSCC, BC_UNKNOWN}, - {0xbfbe0cf6, L"postUS5Zip", BarcodeType::postUS5Zip, BC_UNKNOWN}, - {0xc56618e8, L"pdf417macro", BarcodeType::pdf417macro, BC_UNKNOWN}, - {0xca730f8a, L"code2Of5Interleaved", BarcodeType::code2Of5Interleaved, - BC_UNKNOWN}, - {0xd0097ac6, L"rss14Expanded", BarcodeType::rss14Expanded, BC_UNKNOWN}, - {0xd25a0240, L"postAUSCust2", BarcodeType::postAUSCust2, BC_UNKNOWN}, - {0xd25a0241, L"postAUSCust3", BarcodeType::postAUSCust3, BC_UNKNOWN}, - {0xd53ed3e7, L"rss14Truncated", BarcodeType::rss14Truncated, BC_UNKNOWN}, - {0xe72bcd57, L"code128A", BarcodeType::code128A, BC_UNKNOWN}, - {0xe72bcd58, L"code128B", BarcodeType::code128B, BC_CODE128_B}, - {0xe72bcd59, L"code128C", BarcodeType::code128C, BC_CODE128_C}, - {0xee83c50f, L"rss14StackedOmni", BarcodeType::rss14StackedOmni, - BC_UNKNOWN}, - {0xf2a18f7e, L"QRCode", BarcodeType::QRCode, BC_QR_CODE}, - {0xfaeaf37f, L"postUSStandard", BarcodeType::postUSStandard, BC_UNKNOWN}, - {0xfb48155c, L"code3Of9", BarcodeType::code3Of9, BC_CODE39}, -}; - -} // namespace. - -// static -const BarCodeInfo* CXFA_FFBarcode::GetBarcodeTypeByName( - const CFX_WideStringC& wsName) { - if (wsName.IsEmpty()) - return nullptr; - - auto* it = std::lower_bound( - std::begin(g_BarCodeData), std::end(g_BarCodeData), - FX_HashCode_GetW(wsName, true), - [](const BarCodeInfo& arg, uint32_t hash) { return arg.uHash < hash; }); - - if (it != std::end(g_BarCodeData) && wsName == it->pName) - return it; - - return nullptr; -} - -CXFA_FFBarcode::CXFA_FFBarcode(CXFA_WidgetAcc* pDataAcc) - : CXFA_FFTextEdit(pDataAcc) {} - -CXFA_FFBarcode::~CXFA_FFBarcode() {} - -bool CXFA_FFBarcode::LoadWidget() { - auto pNew = pdfium::MakeUnique(GetFWLApp()); - CFWL_Barcode* pFWLBarcode = pNew.get(); - m_pNormalWidget = std::move(pNew); - m_pNormalWidget->SetLayoutItem(this); - - CFWL_NoteDriver* pNoteDriver = - m_pNormalWidget->GetOwnerApp()->GetNoteDriver(); - pNoteDriver->RegisterEventTarget(m_pNormalWidget.get(), - m_pNormalWidget.get()); - m_pOldDelegate = m_pNormalWidget->GetDelegate(); - m_pNormalWidget->SetDelegate(this); - m_pNormalWidget->LockUpdate(); - - CFX_WideString wsText; - m_pDataAcc->GetValue(wsText, XFA_VALUEPICTURE_Display); - pFWLBarcode->SetText(wsText); - UpdateWidgetProperty(); - m_pNormalWidget->UnlockUpdate(); - return CXFA_FFField::LoadWidget(); -} - -void CXFA_FFBarcode::RenderWidget(CFX_Graphics* pGS, - CFX_Matrix* pMatrix, - uint32_t dwStatus) { - if (!IsMatchVisibleStatus(dwStatus)) - return; - - CFX_Matrix mtRotate = GetRotateMatrix(); - if (pMatrix) - mtRotate.Concat(*pMatrix); - - CXFA_FFWidget::RenderWidget(pGS, &mtRotate, dwStatus); - CXFA_Border borderUI = m_pDataAcc->GetUIBorder(); - DrawBorder(pGS, borderUI, m_rtUI, &mtRotate); - RenderCaption(pGS, &mtRotate); - CFX_RectF rtWidget = m_pNormalWidget->GetWidgetRect(); - - CFX_Matrix mt(1, 0, 0, 1, rtWidget.left, rtWidget.top); - mt.Concat(mtRotate); - m_pNormalWidget->DrawWidget(pGS, &mt); -} - -void CXFA_FFBarcode::UpdateWidgetProperty() { - CXFA_FFTextEdit::UpdateWidgetProperty(); - - auto* pBarCodeWidget = static_cast(m_pNormalWidget.get()); - CFX_WideString wsType = GetDataAcc()->GetBarcodeType(); - const BarCodeInfo* pBarcodeInfo = GetBarcodeTypeByName(wsType.AsStringC()); - if (!pBarcodeInfo) - return; - - pBarCodeWidget->SetType(pBarcodeInfo->eBCType); - - CXFA_WidgetAcc* pAcc = GetDataAcc(); - int32_t intVal; - if (pAcc->GetBarcodeAttribute_CharEncoding(&intVal)) - pBarCodeWidget->SetCharEncoding((BC_CHAR_ENCODING)intVal); - - bool boolVal; - if (pAcc->GetBarcodeAttribute_Checksum(&boolVal)) - pBarCodeWidget->SetCalChecksum(boolVal); - if (pAcc->GetBarcodeAttribute_DataLength(&intVal)) - pBarCodeWidget->SetDataLength(intVal); - - char charVal; - if (pAcc->GetBarcodeAttribute_StartChar(&charVal)) - pBarCodeWidget->SetStartChar(charVal); - if (pAcc->GetBarcodeAttribute_EndChar(&charVal)) - pBarCodeWidget->SetEndChar(charVal); - if (pAcc->GetBarcodeAttribute_ECLevel(&intVal)) - pBarCodeWidget->SetErrorCorrectionLevel(intVal); - if (pAcc->GetBarcodeAttribute_ModuleWidth(&intVal)) - pBarCodeWidget->SetModuleWidth(intVal); - if (pAcc->GetBarcodeAttribute_ModuleHeight(&intVal)) - pBarCodeWidget->SetModuleHeight(intVal); - if (pAcc->GetBarcodeAttribute_PrintChecksum(&boolVal)) - pBarCodeWidget->SetPrintChecksum(boolVal); - if (pAcc->GetBarcodeAttribute_TextLocation(&intVal)) - pBarCodeWidget->SetTextLocation((BC_TEXT_LOC)intVal); - if (pAcc->GetBarcodeAttribute_Truncate(&boolVal)) - pBarCodeWidget->SetTruncated(boolVal); - - float floatVal; - if (pAcc->GetBarcodeAttribute_WideNarrowRatio(&floatVal)) - pBarCodeWidget->SetWideNarrowRatio(static_cast(floatVal)); - if (pBarcodeInfo->eName == BarcodeType::code3Of9 || - pBarcodeInfo->eName == BarcodeType::ean8 || - pBarcodeInfo->eName == BarcodeType::ean13 || - pBarcodeInfo->eName == BarcodeType::upcA) { - pBarCodeWidget->SetPrintChecksum(true); - } -} - -bool CXFA_FFBarcode::OnLButtonDown(uint32_t dwFlags, const CFX_PointF& point) { - auto* pBarCodeWidget = static_cast(m_pNormalWidget.get()); - if (!pBarCodeWidget || pBarCodeWidget->IsProtectedType()) - return false; - if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open) - return false; - return CXFA_FFTextEdit::OnLButtonDown(dwFlags, point); -} - -bool CXFA_FFBarcode::OnRButtonDown(uint32_t dwFlags, const CFX_PointF& point) { - auto* pBarCodeWidget = static_cast(m_pNormalWidget.get()); - if (!pBarCodeWidget || pBarCodeWidget->IsProtectedType()) - return false; - return CXFA_FFTextEdit::OnRButtonDown(dwFlags, point); -} diff --git a/xfa/fxfa/app/xfa_ffbarcode.h b/xfa/fxfa/app/xfa_ffbarcode.h deleted file mode 100644 index 51646236d0..0000000000 --- a/xfa/fxfa/app/xfa_ffbarcode.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_APP_XFA_FFBARCODE_H_ -#define XFA_FXFA_APP_XFA_FFBARCODE_H_ - -#include "fxbarcode/BC_Library.h" -#include "xfa/fxfa/app/xfa_fftextedit.h" -#include "xfa/fxfa/cxfa_ffpageview.h" - -enum class BarcodeType { - aztec, - codabar, - code11, - code128, - code128A, - code128B, - code128C, - code128SSCC, - code2Of5Industrial, - code2Of5Interleaved, - code2Of5Matrix, - code2Of5Standard, - code3Of9, - code3Of9extended, - code49, - code93, - dataMatrix, - ean13, - ean13add2, - ean13add5, - ean13pwcd, - ean8, - ean8add2, - ean8add5, - fim, - logmars, - maxicode, - msi, - pdf417, - pdf417macro, - plessey, - postAUSCust2, - postAUSCust3, - postAUSReplyPaid, - postAUSStandard, - postUKRM4SCC, - postUS5Zip, - postUSDPBC, - postUSIMB, - postUSStandard, - QRCode, - rfid, - rss14, - rss14Expanded, - rss14Limited, - rss14Stacked, - rss14StackedOmni, - rss14Truncated, - telepen, - ucc128, - ucc128random, - ucc128sscc, - upcA, - upcAadd2, - upcAadd5, - upcApwcd, - upcE, - upcEadd2, - upcEadd5, - upcean2, - upcean5, - upsMaxicode -}; - -struct BarCodeInfo { - uint32_t uHash; - const wchar_t* pName; - BarcodeType eName; - BC_TYPE eBCType; -}; - -class CXFA_FFBarcode : public CXFA_FFTextEdit { - public: - static const BarCodeInfo* GetBarcodeTypeByName(const CFX_WideStringC& wsName); - - explicit CXFA_FFBarcode(CXFA_WidgetAcc* pDataAcc); - ~CXFA_FFBarcode() override; - - // CXFA_FFTextEdit - bool LoadWidget() override; - void RenderWidget(CFX_Graphics* pGS, - CFX_Matrix* pMatrix, - uint32_t dwStatus) override; - void UpdateWidgetProperty() override; - bool OnLButtonDown(uint32_t dwFlags, const CFX_PointF& point) override; - bool OnRButtonDown(uint32_t dwFlags, const CFX_PointF& point) override; -}; - -#endif // XFA_FXFA_APP_XFA_FFBARCODE_H_ diff --git a/xfa/fxfa/app/xfa_ffbarcode_unittest.cpp b/xfa/fxfa/app/xfa_ffbarcode_unittest.cpp deleted file mode 100644 index 95e2377cd8..0000000000 --- a/xfa/fxfa/app/xfa_ffbarcode_unittest.cpp +++ /dev/null @@ -1,25 +0,0 @@ -// 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. - -#include "xfa/fxfa/app/xfa_ffbarcode.h" - -#include "testing/gtest/include/gtest/gtest.h" -#include "third_party/base/ptr_util.h" - -TEST(XFA_FFBarcode, GetBarcodeTypeByName) { - EXPECT_EQ(nullptr, CXFA_FFBarcode::GetBarcodeTypeByName(L"")); - EXPECT_EQ(nullptr, CXFA_FFBarcode::GetBarcodeTypeByName(L"not_found")); - - auto* data = CXFA_FFBarcode::GetBarcodeTypeByName(L"ean13"); - ASSERT_NE(nullptr, data); - EXPECT_EQ(BarcodeType::ean13, data->eName); - - data = CXFA_FFBarcode::GetBarcodeTypeByName(L"pdf417"); - ASSERT_NE(nullptr, data); - EXPECT_EQ(BarcodeType::pdf417, data->eName); - - data = CXFA_FFBarcode::GetBarcodeTypeByName(L"code3Of9"); - ASSERT_NE(nullptr, data); - EXPECT_EQ(BarcodeType::code3Of9, data->eName); -} diff --git a/xfa/fxfa/app/xfa_ffcheckbutton.cpp b/xfa/fxfa/app/xfa_ffcheckbutton.cpp deleted file mode 100644 index 76531cecdd..0000000000 --- a/xfa/fxfa/app/xfa_ffcheckbutton.cpp +++ /dev/null @@ -1,345 +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/app/xfa_ffcheckbutton.h" - -#include -#include "third_party/base/ptr_util.h" -#include "xfa/fwl/cfwl_checkbox.h" -#include "xfa/fwl/cfwl_messagemouse.h" -#include "xfa/fwl/cfwl_notedriver.h" -#include "xfa/fwl/cfwl_widgetmgr.h" -#include "xfa/fxfa/app/xfa_ffexclgroup.h" -#include "xfa/fxfa/app/xfa_fffield.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) {} - -CXFA_FFCheckButton::~CXFA_FFCheckButton() {} - -bool CXFA_FFCheckButton::LoadWidget() { - auto pNew = pdfium::MakeUnique(GetFWLApp()); - CFWL_CheckBox* pCheckBox = pNew.get(); - m_pNormalWidget = std::move(pNew); - m_pNormalWidget->SetLayoutItem(this); - - CFWL_NoteDriver* pNoteDriver = - m_pNormalWidget->GetOwnerApp()->GetNoteDriver(); - pNoteDriver->RegisterEventTarget(m_pNormalWidget.get(), - m_pNormalWidget.get()); - m_pOldDelegate = m_pNormalWidget->GetDelegate(); - m_pNormalWidget->SetDelegate(this); - if (m_pDataAcc->IsRadioButton()) - pCheckBox->ModifyStylesEx(FWL_STYLEEXT_CKB_RadioButton, 0xFFFFFFFF); - - m_pNormalWidget->LockUpdate(); - UpdateWidgetProperty(); - SetFWLCheckState(m_pDataAcc->GetCheckState()); - m_pNormalWidget->UnlockUpdate(); - return CXFA_FFField::LoadWidget(); -} - -void CXFA_FFCheckButton::UpdateWidgetProperty() { - auto* pCheckBox = static_cast(m_pNormalWidget.get()); - if (!pCheckBox) - return; - - pCheckBox->SetBoxSize(m_pDataAcc->GetCheckButtonSize()); - uint32_t dwStyleEx = FWL_STYLEEXT_CKB_SignShapeCross; - int32_t iCheckMark = m_pDataAcc->GetCheckButtonMark(); - switch (iCheckMark) { - case XFA_ATTRIBUTEENUM_Check: - dwStyleEx = FWL_STYLEEXT_CKB_SignShapeCheck; - break; - case XFA_ATTRIBUTEENUM_Circle: - dwStyleEx = FWL_STYLEEXT_CKB_SignShapeCircle; - break; - case XFA_ATTRIBUTEENUM_Cross: - break; - case XFA_ATTRIBUTEENUM_Diamond: - dwStyleEx = FWL_STYLEEXT_CKB_SignShapeDiamond; - break; - case XFA_ATTRIBUTEENUM_Square: - dwStyleEx = FWL_STYLEEXT_CKB_SignShapeSquare; - break; - case XFA_ATTRIBUTEENUM_Star: - dwStyleEx = FWL_STYLEEXT_CKB_SignShapeStar; - break; - default: { - int32_t iShape = m_pDataAcc->GetCheckButtonShape(); - if (iShape == XFA_ATTRIBUTEENUM_Round) { - dwStyleEx = FWL_STYLEEXT_CKB_SignShapeCircle; - } - } break; - } - if (m_pDataAcc->IsAllowNeutral()) - dwStyleEx |= FWL_STYLEEXT_CKB_3State; - - pCheckBox->ModifyStylesEx( - dwStyleEx, FWL_STYLEEXT_CKB_SignShapeMask | FWL_STYLEEXT_CKB_3State); -} - -bool CXFA_FFCheckButton::PerformLayout() { - CXFA_FFWidget::PerformLayout(); - - float fCheckSize = m_pDataAcc->GetCheckButtonSize(); - CXFA_Margin mgWidget = m_pDataAcc->GetMargin(); - CFX_RectF rtWidget = GetRectWithoutRotate(); - if (mgWidget) - XFA_RectWidthoutMargin(rtWidget, mgWidget); - - int32_t iCapPlacement = -1; - float fCapReserve = 0; - CXFA_Caption caption = m_pDataAcc->GetCaption(); - if (caption && caption.GetPresence()) { - m_rtCaption = rtWidget; - iCapPlacement = caption.GetPlacementType(); - fCapReserve = caption.GetReserve(); - if (fCapReserve <= 0) { - if (iCapPlacement == XFA_ATTRIBUTEENUM_Top || - iCapPlacement == XFA_ATTRIBUTEENUM_Bottom) { - fCapReserve = rtWidget.height - fCheckSize; - } else { - fCapReserve = rtWidget.width - fCheckSize; - } - } - } - - int32_t iHorzAlign = XFA_ATTRIBUTEENUM_Left; - int32_t iVertAlign = XFA_ATTRIBUTEENUM_Top; - if (CXFA_Para para = m_pDataAcc->GetPara()) { - iHorzAlign = para.GetHorizontalAlign(); - iVertAlign = para.GetVerticalAlign(); - } - - m_rtUI = rtWidget; - CXFA_Margin mgCap = caption.GetMargin(); - switch (iCapPlacement) { - case XFA_ATTRIBUTEENUM_Left: { - m_rtCaption.width = fCapReserve; - CapLeftRightPlacement(mgCap); - m_rtUI.width -= fCapReserve; - m_rtUI.left += fCapReserve; - break; - } - case XFA_ATTRIBUTEENUM_Top: { - m_rtCaption.height = fCapReserve; - XFA_RectWidthoutMargin(m_rtCaption, mgCap); - m_rtUI.height -= fCapReserve; - m_rtUI.top += fCapReserve; - break; - } - case XFA_ATTRIBUTEENUM_Right: { - m_rtCaption.left = m_rtCaption.right() - fCapReserve; - m_rtCaption.width = fCapReserve; - CapLeftRightPlacement(mgCap); - m_rtUI.width -= fCapReserve; - break; - } - case XFA_ATTRIBUTEENUM_Bottom: { - m_rtCaption.top = m_rtCaption.bottom() - fCapReserve; - m_rtCaption.height = fCapReserve; - XFA_RectWidthoutMargin(m_rtCaption, mgCap); - m_rtUI.height -= fCapReserve; - break; - } - case XFA_ATTRIBUTEENUM_Inline: - break; - default: - iHorzAlign = XFA_ATTRIBUTEENUM_Right; - break; - } - - if (iHorzAlign == XFA_ATTRIBUTEENUM_Center) - m_rtUI.left += (m_rtUI.width - fCheckSize) / 2; - else if (iHorzAlign == XFA_ATTRIBUTEENUM_Right) - m_rtUI.left = m_rtUI.right() - fCheckSize; - - if (iVertAlign == XFA_ATTRIBUTEENUM_Middle) - m_rtUI.top += (m_rtUI.height - fCheckSize) / 2; - else if (iVertAlign == XFA_ATTRIBUTEENUM_Bottom) - m_rtUI.top = m_rtUI.bottom() - fCheckSize; - - m_rtUI.width = fCheckSize; - m_rtUI.height = fCheckSize; - AddUIMargin(iCapPlacement); - m_rtCheckBox = m_rtUI; - CXFA_Border borderUI = m_pDataAcc->GetUIBorder(); - if (borderUI) { - CXFA_Margin margin = borderUI.GetMargin(); - if (margin) - XFA_RectWidthoutMargin(m_rtUI, margin); - } - - m_rtUI.Normalize(); - LayoutCaption(); - SetFWLRect(); - if (m_pNormalWidget) - m_pNormalWidget->Update(); - - return true; -} - -void CXFA_FFCheckButton::CapLeftRightPlacement(CXFA_Margin mgCap) { - XFA_RectWidthoutMargin(m_rtCaption, mgCap); - if (m_rtCaption.height < 0) - m_rtCaption.top += m_rtCaption.height; - if (m_rtCaption.width < 0) { - m_rtCaption.left += m_rtCaption.width; - m_rtCaption.width = -m_rtCaption.width; - } -} - -void CXFA_FFCheckButton::AddUIMargin(int32_t iCapPlacement) { - CFX_RectF rtUIMargin = m_pDataAcc->GetUIMargin(); - m_rtUI.top -= rtUIMargin.top / 2 - rtUIMargin.height / 2; - - float fLeftAddRight = rtUIMargin.left + rtUIMargin.width; - float fTopAddBottom = rtUIMargin.top + rtUIMargin.height; - if (m_rtUI.width < fLeftAddRight) { - if (iCapPlacement == XFA_ATTRIBUTEENUM_Right || - iCapPlacement == XFA_ATTRIBUTEENUM_Left) { - m_rtUI.left -= fLeftAddRight - m_rtUI.width; - } else { - m_rtUI.left -= 2 * (fLeftAddRight - m_rtUI.width); - } - m_rtUI.width += 2 * (fLeftAddRight - m_rtUI.width); - } - if (m_rtUI.height < fTopAddBottom) { - if (iCapPlacement == XFA_ATTRIBUTEENUM_Right) - m_rtUI.left -= fTopAddBottom - m_rtUI.height; - - m_rtUI.top -= fTopAddBottom - m_rtUI.height; - m_rtUI.height += 2 * (fTopAddBottom - m_rtUI.height); - } -} - -void CXFA_FFCheckButton::RenderWidget(CFX_Graphics* pGS, - CFX_Matrix* pMatrix, - uint32_t dwStatus) { - if (!IsMatchVisibleStatus(dwStatus)) - return; - - CFX_Matrix mtRotate = GetRotateMatrix(); - if (pMatrix) - mtRotate.Concat(*pMatrix); - - CXFA_FFWidget::RenderWidget(pGS, &mtRotate, dwStatus); - CXFA_Border borderUI = m_pDataAcc->GetUIBorder(); - DrawBorder(pGS, borderUI, m_rtUI, &mtRotate, - m_pDataAcc->GetCheckButtonShape() == XFA_ATTRIBUTEENUM_Round - ? XFA_DRAWBOX_ForceRound - : 0); - RenderCaption(pGS, &mtRotate); - DrawHighlight(pGS, &mtRotate, dwStatus, - m_pDataAcc->GetCheckButtonShape() == XFA_ATTRIBUTEENUM_Round); - CFX_Matrix mt(1, 0, 0, 1, m_rtCheckBox.left, m_rtCheckBox.top); - mt.Concat(mtRotate); - GetApp()->GetWidgetMgrDelegate()->OnDrawWidget(m_pNormalWidget.get(), pGS, - &mt); -} - -bool CXFA_FFCheckButton::OnLButtonUp(uint32_t dwFlags, - const CFX_PointF& point) { - if (!m_pNormalWidget || !IsButtonDown()) - return false; - - SetButtonDown(false); - CFWL_MessageMouse ms(nullptr, m_pNormalWidget.get()); - ms.m_dwCmd = FWL_MouseCommand::LeftButtonUp; - ms.m_dwFlags = dwFlags; - ms.m_pos = FWLToClient(point); - TranslateFWLMessage(&ms); - return true; -} - -XFA_CHECKSTATE CXFA_FFCheckButton::FWLState2XFAState() { - uint32_t dwState = m_pNormalWidget->GetStates(); - if (dwState & FWL_STATE_CKB_Checked) - return XFA_CHECKSTATE_On; - if (dwState & FWL_STATE_CKB_Neutral) - return XFA_CHECKSTATE_Neutral; - return XFA_CHECKSTATE_Off; -} - -bool CXFA_FFCheckButton::CommitData() { - XFA_CHECKSTATE eCheckState = FWLState2XFAState(); - m_pDataAcc->SetCheckState(eCheckState, true); - return true; -} - -bool CXFA_FFCheckButton::IsDataChanged() { - XFA_CHECKSTATE eCheckState = FWLState2XFAState(); - return m_pDataAcc->GetCheckState() != eCheckState; -} - -void CXFA_FFCheckButton::SetFWLCheckState(XFA_CHECKSTATE eCheckState) { - if (eCheckState == XFA_CHECKSTATE_Neutral) - m_pNormalWidget->SetStates(FWL_STATE_CKB_Neutral); - else if (eCheckState == XFA_CHECKSTATE_On) - m_pNormalWidget->SetStates(FWL_STATE_CKB_Checked); - else - m_pNormalWidget->RemoveStates(FWL_STATE_CKB_Checked); -} - -bool CXFA_FFCheckButton::UpdateFWLData() { - if (!m_pNormalWidget) - return false; - - XFA_CHECKSTATE eState = m_pDataAcc->GetCheckState(); - SetFWLCheckState(eState); - m_pNormalWidget->Update(); - return true; -} - -void CXFA_FFCheckButton::OnProcessMessage(CFWL_Message* pMessage) { - m_pOldDelegate->OnProcessMessage(pMessage); -} - -void CXFA_FFCheckButton::OnProcessEvent(CFWL_Event* pEvent) { - CXFA_FFField::OnProcessEvent(pEvent); - switch (pEvent->GetType()) { - case CFWL_Event::Type::CheckStateChanged: { - CXFA_EventParam eParam; - eParam.m_eType = XFA_EVENT_Change; - m_pDataAcc->GetValue(eParam.m_wsNewText, XFA_VALUEPICTURE_Raw); - - CXFA_WidgetAcc* pFFExclGroup = m_pDataAcc->GetExclGroup(); - if (ProcessCommittedData()) { - eParam.m_pTarget = pFFExclGroup; - if (pFFExclGroup) { - m_pDocView->AddValidateWidget(pFFExclGroup); - m_pDocView->AddCalculateWidgetAcc(pFFExclGroup); - pFFExclGroup->ProcessEvent(XFA_ATTRIBUTEENUM_Change, &eParam); - } - eParam.m_pTarget = m_pDataAcc.Get(); - m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Change, &eParam); - } else { - SetFWLCheckState(m_pDataAcc->GetCheckState()); - } - if (pFFExclGroup) { - eParam.m_pTarget = pFFExclGroup; - pFFExclGroup->ProcessEvent(XFA_ATTRIBUTEENUM_Click, &eParam); - } - eParam.m_pTarget = m_pDataAcc.Get(); - m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Click, &eParam); - break; - } - default: - break; - } - m_pOldDelegate->OnProcessEvent(pEvent); -} - -void CXFA_FFCheckButton::OnDrawWidget(CFX_Graphics* pGraphics, - const CFX_Matrix* pMatrix) { - m_pOldDelegate->OnDrawWidget(pGraphics, pMatrix); -} diff --git a/xfa/fxfa/app/xfa_ffcheckbutton.h b/xfa/fxfa/app/xfa_ffcheckbutton.h deleted file mode 100644 index d4de7e8023..0000000000 --- a/xfa/fxfa/app/xfa_ffcheckbutton.h +++ /dev/null @@ -1,46 +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_APP_XFA_FFCHECKBUTTON_H_ -#define XFA_FXFA_APP_XFA_FFCHECKBUTTON_H_ - -#include "xfa/fxfa/app/xfa_fffield.h" -#include "xfa/fxfa/cxfa_ffpageview.h" - -class CXFA_FFCheckButton : public CXFA_FFField { - public: - explicit CXFA_FFCheckButton(CXFA_WidgetAcc* pDataAcc); - ~CXFA_FFCheckButton() override; - - // CXFA_FFField - void RenderWidget(CFX_Graphics* pGS, - CFX_Matrix* pMatrix, - uint32_t dwStatus) override; - - bool LoadWidget() override; - bool PerformLayout() override; - bool UpdateFWLData() override; - void UpdateWidgetProperty() override; - bool OnLButtonUp(uint32_t dwFlags, const CFX_PointF& point) override; - void OnProcessMessage(CFWL_Message* pMessage) override; - void OnProcessEvent(CFWL_Event* pEvent) override; - void OnDrawWidget(CFX_Graphics* pGraphics, - const CFX_Matrix* pMatrix = nullptr) override; - - void SetFWLCheckState(XFA_CHECKSTATE eCheckState); - - private: - bool CommitData() override; - bool IsDataChanged() override; - void CapLeftRightPlacement(CXFA_Margin mgCap); - void AddUIMargin(int32_t iCapPlacement); - XFA_CHECKSTATE FWLState2XFAState(); - - IFWL_WidgetDelegate* m_pOldDelegate; - CFX_RectF m_rtCheckBox; -}; - -#endif // XFA_FXFA_APP_XFA_FFCHECKBUTTON_H_ diff --git a/xfa/fxfa/app/xfa_ffchoicelist.cpp b/xfa/fxfa/app/xfa_ffchoicelist.cpp deleted file mode 100644 index e24e7f77b7..0000000000 --- a/xfa/fxfa/app/xfa_ffchoicelist.cpp +++ /dev/null @@ -1,562 +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/app/xfa_ffchoicelist.h" - -#include -#include -#include - -#include "third_party/base/ptr_util.h" -#include "third_party/base/stl_util.h" -#include "xfa/fwl/cfwl_app.h" -#include "xfa/fwl/cfwl_combobox.h" -#include "xfa/fwl/cfwl_edit.h" -#include "xfa/fwl/cfwl_eventselectchanged.h" -#include "xfa/fwl/cfwl_listbox.h" -#include "xfa/fwl/cfwl_notedriver.h" -#include "xfa/fwl/cfwl_widgetproperties.h" -#include "xfa/fxfa/app/xfa_fffield.h" -#include "xfa/fxfa/app/xfa_fwladapter.h" -#include "xfa/fxfa/cxfa_eventparam.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" - -namespace { - -CFWL_ListBox* ToListBox(CFWL_Widget* widget) { - return static_cast(widget); -} - -CFWL_ComboBox* ToComboBox(CFWL_Widget* widget) { - return static_cast(widget); -} - -} // namespace - -CXFA_FFListBox::CXFA_FFListBox(CXFA_WidgetAcc* pDataAcc) - : CXFA_FFField(pDataAcc), m_pOldDelegate(nullptr) {} - -CXFA_FFListBox::~CXFA_FFListBox() { - if (!m_pNormalWidget) - return; - - CFWL_NoteDriver* pNoteDriver = - m_pNormalWidget->GetOwnerApp()->GetNoteDriver(); - pNoteDriver->UnregisterEventTarget(m_pNormalWidget.get()); -} - -bool CXFA_FFListBox::LoadWidget() { - auto pNew = pdfium::MakeUnique( - GetFWLApp(), pdfium::MakeUnique(), nullptr); - CFWL_ListBox* pListBox = pNew.get(); - pListBox->ModifyStyles(FWL_WGTSTYLE_VScroll | FWL_WGTSTYLE_NoBackground, - 0xFFFFFFFF); - m_pNormalWidget = std::move(pNew); - m_pNormalWidget->SetLayoutItem(this); - - CFWL_NoteDriver* pNoteDriver = - m_pNormalWidget->GetOwnerApp()->GetNoteDriver(); - pNoteDriver->RegisterEventTarget(m_pNormalWidget.get(), - m_pNormalWidget.get()); - m_pOldDelegate = m_pNormalWidget->GetDelegate(); - m_pNormalWidget->SetDelegate(this); - m_pNormalWidget->LockUpdate(); - - for (const auto& label : m_pDataAcc->GetChoiceListItems(false)) - pListBox->AddString(label.AsStringC()); - - uint32_t dwExtendedStyle = FWL_STYLEEXT_LTB_ShowScrollBarFocus; - if (m_pDataAcc->GetChoiceListOpen() == XFA_ATTRIBUTEENUM_MultiSelect) - dwExtendedStyle |= FWL_STYLEEXT_LTB_MultiSelection; - - dwExtendedStyle |= GetAlignment(); - m_pNormalWidget->ModifyStylesEx(dwExtendedStyle, 0xFFFFFFFF); - for (int32_t selected : m_pDataAcc->GetSelectedItems()) - pListBox->SetSelItem(pListBox->GetItem(nullptr, selected), true); - - m_pNormalWidget->UnlockUpdate(); - return CXFA_FFField::LoadWidget(); -} - -bool CXFA_FFListBox::OnKillFocus(CXFA_FFWidget* pNewFocus) { - if (!ProcessCommittedData()) - UpdateFWLData(); - - CXFA_FFField::OnKillFocus(pNewFocus); - return true; -} - -bool CXFA_FFListBox::CommitData() { - auto* pListBox = ToListBox(m_pNormalWidget.get()); - std::vector iSelArray; - int32_t iSels = pListBox->CountSelItems(); - for (int32_t i = 0; i < iSels; ++i) - iSelArray.push_back(pListBox->GetSelIndex(i)); - - m_pDataAcc->SetSelectedItems(iSelArray, true, false, true); - return true; -} - -bool CXFA_FFListBox::IsDataChanged() { - std::vector iSelArray = m_pDataAcc->GetSelectedItems(); - int32_t iOldSels = pdfium::CollectionSize(iSelArray); - auto* pListBox = ToListBox(m_pNormalWidget.get()); - int32_t iSels = pListBox->CountSelItems(); - if (iOldSels != iSels) - return true; - - for (int32_t i = 0; i < iSels; ++i) { - CFWL_ListItem* hlistItem = pListBox->GetItem(nullptr, iSelArray[i]); - if (!(hlistItem->GetStates() & FWL_ITEMSTATE_LTB_Selected)) - return true; - } - return false; -} - -uint32_t CXFA_FFListBox::GetAlignment() { - CXFA_Para para = m_pDataAcc->GetPara(); - if (!para) - return 0; - - uint32_t dwExtendedStyle = 0; - switch (para.GetHorizontalAlign()) { - case XFA_ATTRIBUTEENUM_Center: - dwExtendedStyle |= FWL_STYLEEXT_LTB_CenterAlign; - break; - case XFA_ATTRIBUTEENUM_Justify: - break; - case XFA_ATTRIBUTEENUM_JustifyAll: - break; - case XFA_ATTRIBUTEENUM_Radix: - break; - case XFA_ATTRIBUTEENUM_Right: - dwExtendedStyle |= FWL_STYLEEXT_LTB_RightAlign; - break; - default: - dwExtendedStyle |= FWL_STYLEEXT_LTB_LeftAlign; - break; - } - return dwExtendedStyle; -} - -bool CXFA_FFListBox::UpdateFWLData() { - if (!m_pNormalWidget) - return false; - - auto* pListBox = ToListBox(m_pNormalWidget.get()); - std::vector iSelArray = m_pDataAcc->GetSelectedItems(); - std::vector selItemArray(iSelArray.size()); - std::transform(iSelArray.begin(), iSelArray.end(), selItemArray.begin(), - [pListBox](int32_t val) { return pListBox->GetSelItem(val); }); - - pListBox->SetSelItem(pListBox->GetSelItem(-1), false); - for (CFWL_ListItem* pItem : selItemArray) - pListBox->SetSelItem(pItem, true); - - m_pNormalWidget->Update(); - return true; -} - -void CXFA_FFListBox::OnSelectChanged(CFWL_Widget* pWidget) { - CXFA_EventParam eParam; - eParam.m_eType = XFA_EVENT_Change; - eParam.m_pTarget = m_pDataAcc.Get(); - m_pDataAcc->GetValue(eParam.m_wsPrevText, XFA_VALUEPICTURE_Raw); - - auto* pListBox = ToListBox(m_pNormalWidget.get()); - int32_t iSels = pListBox->CountSelItems(); - if (iSels > 0) { - CFWL_ListItem* item = pListBox->GetSelItem(0); - eParam.m_wsNewText = item ? item->GetText() : L""; - } - m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Change, &eParam); -} - -void CXFA_FFListBox::SetItemState(int32_t nIndex, bool bSelected) { - auto* pListBox = ToListBox(m_pNormalWidget.get()); - pListBox->SetSelItem(pListBox->GetSelItem(nIndex), bSelected); - m_pNormalWidget->Update(); - AddInvalidateRect(); -} - -void CXFA_FFListBox::InsertItem(const CFX_WideStringC& wsLabel, - int32_t nIndex) { - CFX_WideString wsTemp(wsLabel); - ToListBox(m_pNormalWidget.get())->AddString(wsTemp.AsStringC()); - m_pNormalWidget->Update(); - AddInvalidateRect(); -} - -void CXFA_FFListBox::DeleteItem(int32_t nIndex) { - auto* pListBox = ToListBox(m_pNormalWidget.get()); - if (nIndex < 0) - pListBox->DeleteAll(); - else - pListBox->DeleteString(pListBox->GetItem(nullptr, nIndex)); - - pListBox->Update(); - AddInvalidateRect(); -} - -void CXFA_FFListBox::OnProcessMessage(CFWL_Message* pMessage) { - m_pOldDelegate->OnProcessMessage(pMessage); -} - -void CXFA_FFListBox::OnProcessEvent(CFWL_Event* pEvent) { - CXFA_FFField::OnProcessEvent(pEvent); - switch (pEvent->GetType()) { - case CFWL_Event::Type::SelectChanged: - OnSelectChanged(m_pNormalWidget.get()); - break; - default: - break; - } - m_pOldDelegate->OnProcessEvent(pEvent); -} - -void CXFA_FFListBox::OnDrawWidget(CFX_Graphics* pGraphics, - const CFX_Matrix* pMatrix) { - m_pOldDelegate->OnDrawWidget(pGraphics, pMatrix); -} - -CXFA_FFComboBox::CXFA_FFComboBox(CXFA_WidgetAcc* pDataAcc) - : CXFA_FFField(pDataAcc), m_pOldDelegate(nullptr) {} - -CXFA_FFComboBox::~CXFA_FFComboBox() {} - -CFX_RectF CXFA_FFComboBox::GetBBox(uint32_t dwStatus, bool bDrawFocus) { - return bDrawFocus ? CFX_RectF() : CXFA_FFWidget::GetBBox(dwStatus); -} - -bool CXFA_FFComboBox::PtInActiveRect(const CFX_PointF& point) { - auto* pComboBox = ToComboBox(m_pNormalWidget.get()); - return pComboBox && pComboBox->GetBBox().Contains(point); -} - -bool CXFA_FFComboBox::LoadWidget() { - auto pNew = pdfium::MakeUnique(GetFWLApp()); - CFWL_ComboBox* pComboBox = pNew.get(); - m_pNormalWidget = std::move(pNew); - m_pNormalWidget->SetLayoutItem(this); - - CFWL_NoteDriver* pNoteDriver = - m_pNormalWidget->GetOwnerApp()->GetNoteDriver(); - pNoteDriver->RegisterEventTarget(m_pNormalWidget.get(), - m_pNormalWidget.get()); - m_pOldDelegate = m_pNormalWidget->GetDelegate(); - m_pNormalWidget->SetDelegate(this); - m_pNormalWidget->LockUpdate(); - - for (const auto& label : m_pDataAcc->GetChoiceListItems(false)) - pComboBox->AddString(label.AsStringC()); - - std::vector iSelArray = m_pDataAcc->GetSelectedItems(); - if (!iSelArray.empty()) { - pComboBox->SetCurSel(iSelArray.front()); - } else { - CFX_WideString wsText; - m_pDataAcc->GetValue(wsText, XFA_VALUEPICTURE_Raw); - pComboBox->SetEditText(wsText); - } - - UpdateWidgetProperty(); - m_pNormalWidget->UnlockUpdate(); - return CXFA_FFField::LoadWidget(); -} - -void CXFA_FFComboBox::UpdateWidgetProperty() { - auto* pComboBox = ToComboBox(m_pNormalWidget.get()); - if (!pComboBox) - return; - - uint32_t dwExtendedStyle = 0; - uint32_t dwEditStyles = - FWL_STYLEEXT_EDT_ReadOnly | FWL_STYLEEXT_EDT_LastLineHeight; - dwExtendedStyle |= UpdateUIProperty(); - if (m_pDataAcc->IsChoiceListAllowTextEntry()) { - dwEditStyles &= ~FWL_STYLEEXT_EDT_ReadOnly; - dwExtendedStyle |= FWL_STYLEEXT_CMB_DropDown; - } - if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open || - !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) { - dwEditStyles |= FWL_STYLEEXT_EDT_ReadOnly; - dwExtendedStyle |= FWL_STYLEEXT_CMB_ReadOnly; - } - dwExtendedStyle |= GetAlignment(); - m_pNormalWidget->ModifyStylesEx(dwExtendedStyle, 0xFFFFFFFF); - - if (m_pDataAcc->GetHorizontalScrollPolicy() != XFA_ATTRIBUTEENUM_Off) - dwEditStyles |= FWL_STYLEEXT_EDT_AutoHScroll; - - pComboBox->EditModifyStylesEx(dwEditStyles, 0xFFFFFFFF); -} - -bool CXFA_FFComboBox::OnRButtonUp(uint32_t dwFlags, const CFX_PointF& point) { - if (!CXFA_FFField::OnRButtonUp(dwFlags, point)) - return false; - - GetDoc()->GetDocEnvironment()->PopupMenu(this, point); - return true; -} - -bool CXFA_FFComboBox::OnKillFocus(CXFA_FFWidget* pNewWidget) { - if (!ProcessCommittedData()) - UpdateFWLData(); - - CXFA_FFField::OnKillFocus(pNewWidget); - return true; -} - -void CXFA_FFComboBox::OpenDropDownList() { - ToComboBox(m_pNormalWidget.get())->OpenDropDownList(true); -} - -bool CXFA_FFComboBox::CommitData() { - return m_pDataAcc->SetValue(m_wsNewValue, XFA_VALUEPICTURE_Raw); -} - -bool CXFA_FFComboBox::IsDataChanged() { - auto* pFWLcombobox = ToComboBox(m_pNormalWidget.get()); - CFX_WideString wsText = pFWLcombobox->GetEditText(); - int32_t iCursel = pFWLcombobox->GetCurSel(); - if (iCursel >= 0) { - CFX_WideString wsSel = pFWLcombobox->GetTextByIndex(iCursel); - if (wsSel == wsText) - m_pDataAcc->GetChoiceListItem(wsText, iCursel, true); - } - - CFX_WideString wsOldValue; - m_pDataAcc->GetValue(wsOldValue, XFA_VALUEPICTURE_Raw); - if (wsOldValue == wsText) - return false; - - m_wsNewValue = wsText; - return true; -} - -void CXFA_FFComboBox::FWLEventSelChange(CXFA_EventParam* pParam) { - pParam->m_eType = XFA_EVENT_Change; - pParam->m_pTarget = m_pDataAcc.Get(); - pParam->m_wsNewText = ToComboBox(m_pNormalWidget.get())->GetEditText(); - m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Change, pParam); -} - -uint32_t CXFA_FFComboBox::GetAlignment() { - CXFA_Para para = m_pDataAcc->GetPara(); - if (!para) - return 0; - - uint32_t dwExtendedStyle = 0; - switch (para.GetHorizontalAlign()) { - case XFA_ATTRIBUTEENUM_Center: - dwExtendedStyle |= - FWL_STYLEEXT_CMB_EditHCenter | FWL_STYLEEXT_CMB_ListItemCenterAlign; - break; - case XFA_ATTRIBUTEENUM_Justify: - dwExtendedStyle |= FWL_STYLEEXT_CMB_EditJustified; - break; - case XFA_ATTRIBUTEENUM_JustifyAll: - break; - case XFA_ATTRIBUTEENUM_Radix: - break; - case XFA_ATTRIBUTEENUM_Right: - break; - default: - dwExtendedStyle |= - FWL_STYLEEXT_CMB_EditHNear | FWL_STYLEEXT_CMB_ListItemLeftAlign; - break; - } - - switch (para.GetVerticalAlign()) { - case XFA_ATTRIBUTEENUM_Middle: - dwExtendedStyle |= FWL_STYLEEXT_CMB_EditVCenter; - break; - case XFA_ATTRIBUTEENUM_Bottom: - dwExtendedStyle |= FWL_STYLEEXT_CMB_EditVFar; - break; - default: - dwExtendedStyle |= FWL_STYLEEXT_CMB_EditVNear; - break; - } - return dwExtendedStyle; -} - -bool CXFA_FFComboBox::UpdateFWLData() { - auto* pComboBox = ToComboBox(m_pNormalWidget.get()); - if (!pComboBox) - return false; - - std::vector iSelArray = m_pDataAcc->GetSelectedItems(); - if (!iSelArray.empty()) { - pComboBox->SetCurSel(iSelArray.front()); - } else { - CFX_WideString wsText; - pComboBox->SetCurSel(-1); - m_pDataAcc->GetValue(wsText, XFA_VALUEPICTURE_Raw); - pComboBox->SetEditText(wsText); - } - pComboBox->Update(); - return true; -} - -bool CXFA_FFComboBox::CanUndo() { - return m_pDataAcc->IsChoiceListAllowTextEntry() && - ToComboBox(m_pNormalWidget.get())->EditCanUndo(); -} - -bool CXFA_FFComboBox::CanRedo() { - return m_pDataAcc->IsChoiceListAllowTextEntry() && - ToComboBox(m_pNormalWidget.get())->EditCanRedo(); -} - -bool CXFA_FFComboBox::Undo() { - return m_pDataAcc->IsChoiceListAllowTextEntry() && - ToComboBox(m_pNormalWidget.get())->EditUndo(); -} - -bool CXFA_FFComboBox::Redo() { - return m_pDataAcc->IsChoiceListAllowTextEntry() && - ToComboBox(m_pNormalWidget.get())->EditRedo(); -} - -bool CXFA_FFComboBox::CanCopy() { - return ToComboBox(m_pNormalWidget.get())->EditCanCopy(); -} - -bool CXFA_FFComboBox::CanCut() { - return m_pDataAcc->GetAccess() == XFA_ATTRIBUTEENUM_Open && - m_pDataAcc->IsChoiceListAllowTextEntry() && - ToComboBox(m_pNormalWidget.get())->EditCanCut(); -} - -bool CXFA_FFComboBox::CanPaste() { - return m_pDataAcc->IsChoiceListAllowTextEntry() && - m_pDataAcc->GetAccess() == XFA_ATTRIBUTEENUM_Open; -} - -bool CXFA_FFComboBox::CanSelectAll() { - return ToComboBox(m_pNormalWidget.get())->EditCanSelectAll(); -} - -bool CXFA_FFComboBox::Copy(CFX_WideString& wsCopy) { - return ToComboBox(m_pNormalWidget.get())->EditCopy(wsCopy); -} - -bool CXFA_FFComboBox::Cut(CFX_WideString& wsCut) { - return m_pDataAcc->IsChoiceListAllowTextEntry() && - ToComboBox(m_pNormalWidget.get())->EditCut(wsCut); -} - -bool CXFA_FFComboBox::Paste(const CFX_WideString& wsPaste) { - return m_pDataAcc->IsChoiceListAllowTextEntry() && - ToComboBox(m_pNormalWidget.get())->EditPaste(wsPaste); -} - -void CXFA_FFComboBox::SelectAll() { - ToComboBox(m_pNormalWidget.get())->EditSelectAll(); -} - -void CXFA_FFComboBox::Delete() { - ToComboBox(m_pNormalWidget.get())->EditDelete(); -} - -void CXFA_FFComboBox::DeSelect() { - ToComboBox(m_pNormalWidget.get())->EditDeSelect(); -} - -void CXFA_FFComboBox::SetItemState(int32_t nIndex, bool bSelected) { - ToComboBox(m_pNormalWidget.get())->SetCurSel(bSelected ? nIndex : -1); - m_pNormalWidget->Update(); - AddInvalidateRect(); -} - -void CXFA_FFComboBox::InsertItem(const CFX_WideStringC& wsLabel, - int32_t nIndex) { - ToComboBox(m_pNormalWidget.get())->AddString(wsLabel); - m_pNormalWidget->Update(); - AddInvalidateRect(); -} - -void CXFA_FFComboBox::DeleteItem(int32_t nIndex) { - if (nIndex < 0) - ToComboBox(m_pNormalWidget.get())->RemoveAll(); - else - ToComboBox(m_pNormalWidget.get())->RemoveAt(nIndex); - - m_pNormalWidget->Update(); - AddInvalidateRect(); -} - -void CXFA_FFComboBox::OnTextChanged(CFWL_Widget* pWidget, - const CFX_WideString& wsChanged) { - CXFA_EventParam eParam; - m_pDataAcc->GetValue(eParam.m_wsPrevText, XFA_VALUEPICTURE_Raw); - eParam.m_wsChange = wsChanged; - FWLEventSelChange(&eParam); -} - -void CXFA_FFComboBox::OnSelectChanged(CFWL_Widget* pWidget, bool bLButtonUp) { - CXFA_EventParam eParam; - m_pDataAcc->GetValue(eParam.m_wsPrevText, XFA_VALUEPICTURE_Raw); - FWLEventSelChange(&eParam); - if (m_pDataAcc->GetChoiceListCommitOn() == XFA_ATTRIBUTEENUM_Select && - bLButtonUp) { - m_pDocView->SetFocusWidgetAcc(nullptr); - } -} - -void CXFA_FFComboBox::OnPreOpen(CFWL_Widget* pWidget) { - CXFA_EventParam eParam; - eParam.m_eType = XFA_EVENT_PreOpen; - eParam.m_pTarget = m_pDataAcc.Get(); - m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_PreOpen, &eParam); -} - -void CXFA_FFComboBox::OnPostOpen(CFWL_Widget* pWidget) { - CXFA_EventParam eParam; - eParam.m_eType = XFA_EVENT_PostOpen; - eParam.m_pTarget = m_pDataAcc.Get(); - m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_PostOpen, &eParam); -} - -void CXFA_FFComboBox::OnProcessMessage(CFWL_Message* pMessage) { - m_pOldDelegate->OnProcessMessage(pMessage); -} - -void CXFA_FFComboBox::OnProcessEvent(CFWL_Event* pEvent) { - CXFA_FFField::OnProcessEvent(pEvent); - switch (pEvent->GetType()) { - case CFWL_Event::Type::SelectChanged: { - auto* postEvent = static_cast(pEvent); - OnSelectChanged(m_pNormalWidget.get(), postEvent->bLButtonUp); - break; - } - case CFWL_Event::Type::EditChanged: { - CFX_WideString wsChanged; - OnTextChanged(m_pNormalWidget.get(), wsChanged); - break; - } - case CFWL_Event::Type::PreDropDown: { - OnPreOpen(m_pNormalWidget.get()); - break; - } - case CFWL_Event::Type::PostDropDown: { - OnPostOpen(m_pNormalWidget.get()); - break; - } - default: - break; - } - m_pOldDelegate->OnProcessEvent(pEvent); -} - -void CXFA_FFComboBox::OnDrawWidget(CFX_Graphics* pGraphics, - const CFX_Matrix* pMatrix) { - m_pOldDelegate->OnDrawWidget(pGraphics, pMatrix); -} diff --git a/xfa/fxfa/app/xfa_ffchoicelist.h b/xfa/fxfa/app/xfa_ffchoicelist.h deleted file mode 100644 index 20f053cc20..0000000000 --- a/xfa/fxfa/app/xfa_ffchoicelist.h +++ /dev/null @@ -1,100 +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_APP_XFA_FFCHOICELIST_H_ -#define XFA_FXFA_APP_XFA_FFCHOICELIST_H_ - -#include - -#include "xfa/fxfa/app/xfa_fffield.h" -#include "xfa/fxfa/cxfa_ffpageview.h" - -class CXFA_FFListBox : public CXFA_FFField { - public: - explicit CXFA_FFListBox(CXFA_WidgetAcc* pDataAcc); - ~CXFA_FFListBox() override; - - // CXFA_FFField - bool LoadWidget() override; - bool OnKillFocus(CXFA_FFWidget* pNewWidget) override; - void OnProcessMessage(CFWL_Message* pMessage) override; - void OnProcessEvent(CFWL_Event* pEvent) override; - void OnDrawWidget(CFX_Graphics* pGraphics, - const CFX_Matrix* pMatrix = nullptr) override; - - void OnSelectChanged(CFWL_Widget* pWidget); - void SetItemState(int32_t nIndex, bool bSelected); - void InsertItem(const CFX_WideStringC& wsLabel, int32_t nIndex); - void DeleteItem(int32_t nIndex); - - private: - bool CommitData() override; - bool UpdateFWLData() override; - bool IsDataChanged() override; - - uint32_t GetAlignment(); - - IFWL_WidgetDelegate* m_pOldDelegate; -}; - -class CXFA_FFComboBox : public CXFA_FFField { - public: - explicit CXFA_FFComboBox(CXFA_WidgetAcc* pDataAcc); - ~CXFA_FFComboBox() override; - - // CXFA_FFField - CFX_RectF GetBBox(uint32_t dwStatus, bool bDrawFocus = false) override; - bool LoadWidget() override; - void UpdateWidgetProperty() override; - bool OnRButtonUp(uint32_t dwFlags, const CFX_PointF& point) override; - bool OnKillFocus(CXFA_FFWidget* pNewWidget) override; - bool CanUndo() override; - bool CanRedo() override; - bool Undo() override; - bool Redo() override; - - bool CanCopy() override; - bool CanCut() override; - bool CanPaste() override; - bool CanSelectAll() override; - bool Copy(CFX_WideString& wsCopy) override; - bool Cut(CFX_WideString& wsCut) override; - bool Paste(const CFX_WideString& wsPaste) override; - void SelectAll() override; - void Delete() override; - void DeSelect() override; - - // IFWL_WidgetDelegate - void OnProcessMessage(CFWL_Message* pMessage) override; - void OnProcessEvent(CFWL_Event* pEvent) override; - void OnDrawWidget(CFX_Graphics* pGraphics, - const CFX_Matrix* pMatrix = nullptr) override; - - virtual void OpenDropDownList(); - - void OnTextChanged(CFWL_Widget* pWidget, const CFX_WideString& wsChanged); - void OnSelectChanged(CFWL_Widget* pWidget, bool bLButtonUp); - void OnPreOpen(CFWL_Widget* pWidget); - void OnPostOpen(CFWL_Widget* pWidget); - void SetItemState(int32_t nIndex, bool bSelected); - void InsertItem(const CFX_WideStringC& wsLabel, int32_t nIndex); - void DeleteItem(int32_t nIndex); - - private: - // CXFA_FFField - bool PtInActiveRect(const CFX_PointF& point) override; - bool CommitData() override; - bool UpdateFWLData() override; - bool IsDataChanged() override; - - uint32_t GetAlignment(); - void FWLEventSelChange(CXFA_EventParam* pParam); - - CFX_WideString m_wsNewValue; - IFWL_WidgetDelegate* m_pOldDelegate; -}; - -#endif // XFA_FXFA_APP_XFA_FFCHOICELIST_H_ diff --git a/xfa/fxfa/app/xfa_ffdraw.cpp b/xfa/fxfa/app/xfa_ffdraw.cpp deleted file mode 100644 index 8742b83c5b..0000000000 --- a/xfa/fxfa/app/xfa_ffdraw.cpp +++ /dev/null @@ -1,16 +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/app/xfa_ffdraw.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) {} - -CXFA_FFDraw::~CXFA_FFDraw() {} diff --git a/xfa/fxfa/app/xfa_ffdraw.h b/xfa/fxfa/app/xfa_ffdraw.h deleted file mode 100644 index bcd74f204c..0000000000 --- a/xfa/fxfa/app/xfa_ffdraw.h +++ /dev/null @@ -1,19 +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_APP_XFA_FFDRAW_H_ -#define XFA_FXFA_APP_XFA_FFDRAW_H_ - -#include "xfa/fxfa/cxfa_ffpageview.h" -#include "xfa/fxfa/cxfa_ffwidget.h" - -class CXFA_FFDraw : public CXFA_FFWidget { - public: - explicit CXFA_FFDraw(CXFA_WidgetAcc* pDataAcc); - ~CXFA_FFDraw() override; -}; - -#endif // XFA_FXFA_APP_XFA_FFDRAW_H_ diff --git a/xfa/fxfa/app/xfa_ffexclgroup.cpp b/xfa/fxfa/app/xfa_ffexclgroup.cpp deleted file mode 100644 index 9f2560f82f..0000000000 --- a/xfa/fxfa/app/xfa_ffexclgroup.cpp +++ /dev/null @@ -1,30 +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/app/xfa_ffexclgroup.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) {} - -CXFA_FFExclGroup::~CXFA_FFExclGroup() {} - -void CXFA_FFExclGroup::RenderWidget(CFX_Graphics* pGS, - CFX_Matrix* pMatrix, - uint32_t dwStatus) { - if (!IsMatchVisibleStatus(dwStatus)) - return; - - CFX_Matrix mtRotate = GetRotateMatrix(); - if (pMatrix) - mtRotate.Concat(*pMatrix); - - CXFA_FFWidget::RenderWidget(pGS, &mtRotate, dwStatus); -} diff --git a/xfa/fxfa/app/xfa_ffexclgroup.h b/xfa/fxfa/app/xfa_ffexclgroup.h deleted file mode 100644 index a14894566c..0000000000 --- a/xfa/fxfa/app/xfa_ffexclgroup.h +++ /dev/null @@ -1,24 +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_APP_XFA_FFEXCLGROUP_H_ -#define XFA_FXFA_APP_XFA_FFEXCLGROUP_H_ - -#include "xfa/fxfa/cxfa_ffpageview.h" -#include "xfa/fxfa/cxfa_ffwidget.h" - -class CXFA_FFExclGroup : public CXFA_FFWidget { - public: - explicit CXFA_FFExclGroup(CXFA_WidgetAcc* pDataAcc); - ~CXFA_FFExclGroup() override; - - // CXFA_FFWidget - void RenderWidget(CFX_Graphics* pGS, - CFX_Matrix* pMatrix, - uint32_t dwStatus) override; -}; - -#endif // XFA_FXFA_APP_XFA_FFEXCLGROUP_H_ diff --git a/xfa/fxfa/app/xfa_fffield.cpp b/xfa/fxfa/app/xfa_fffield.cpp deleted file mode 100644 index 425ba30843..0000000000 --- a/xfa/fxfa/app/xfa_fffield.cpp +++ /dev/null @@ -1,785 +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/app/xfa_fffield.h" - -#include "xfa/fwl/cfwl_edit.h" -#include "xfa/fwl/cfwl_eventmouse.h" -#include "xfa/fwl/cfwl_messagekey.h" -#include "xfa/fwl/cfwl_messagekillfocus.h" -#include "xfa/fwl/cfwl_messagemouse.h" -#include "xfa/fwl/cfwl_messagemousewheel.h" -#include "xfa/fwl/cfwl_messagesetfocus.h" -#include "xfa/fwl/cfwl_picturebox.h" -#include "xfa/fwl/cfwl_widgetmgr.h" -#include "xfa/fxfa/app/cxfa_textlayout.h" -#include "xfa/fxfa/app/xfa_fwltheme.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/cxfa_node.h" -#include "xfa/fxgraphics/cfx_color.h" -#include "xfa/fxgraphics/cfx_path.h" - -namespace { - -CXFA_FFField* ToField(CXFA_LayoutItem* widget) { - return static_cast(widget); -} - -} // namespace - -CXFA_FFField::CXFA_FFField(CXFA_WidgetAcc* pDataAcc) - : CXFA_FFWidget(pDataAcc), m_pNormalWidget(nullptr) {} - -CXFA_FFField::~CXFA_FFField() { - CXFA_FFField::UnloadWidget(); -} - -CFX_RectF CXFA_FFField::GetBBox(uint32_t dwStatus, bool bDrawFocus) { - if (!bDrawFocus) - return CXFA_FFWidget::GetBBox(dwStatus); - - XFA_Element type = m_pDataAcc->GetUIType(); - if (type != XFA_Element::Button && type != XFA_Element::CheckButton && - type != XFA_Element::ImageEdit && type != XFA_Element::Signature && - type != XFA_Element::ChoiceList) { - return CFX_RectF(); - } - - CFX_RectF rtBox = m_rtUI; - GetRotateMatrix().TransformRect(rtBox); - return rtBox; -} - -void CXFA_FFField::RenderWidget(CFX_Graphics* pGS, - CFX_Matrix* pMatrix, - uint32_t dwStatus) { - if (!IsMatchVisibleStatus(dwStatus)) - return; - - CFX_Matrix mtRotate = GetRotateMatrix(); - if (pMatrix) - mtRotate.Concat(*pMatrix); - - CXFA_FFWidget::RenderWidget(pGS, &mtRotate, dwStatus); - CXFA_Border borderUI = m_pDataAcc->GetUIBorder(); - DrawBorder(pGS, borderUI, m_rtUI, &mtRotate); - RenderCaption(pGS, &mtRotate); - DrawHighlight(pGS, &mtRotate, dwStatus, false); - - CFX_RectF rtWidget = m_pNormalWidget->GetWidgetRect(); - CFX_Matrix mt(1, 0, 0, 1, rtWidget.left, rtWidget.top); - mt.Concat(mtRotate); - GetApp()->GetWidgetMgrDelegate()->OnDrawWidget(m_pNormalWidget.get(), pGS, - &mt); -} - -void CXFA_FFField::DrawHighlight(CFX_Graphics* pGS, - CFX_Matrix* pMatrix, - uint32_t dwStatus, - bool bEllipse) { - if (m_rtUI.IsEmpty() || !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) - return; - - if (!(dwStatus & XFA_WidgetStatus_Highlight) || - m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open) { - return; - } - - CXFA_FFDoc* pDoc = GetDoc(); - CFX_Color crHighlight(pDoc->GetDocEnvironment()->GetHighlightColor(pDoc)); - pGS->SetFillColor(&crHighlight); - CFX_Path path; - if (bEllipse) - path.AddEllipse(m_rtUI); - else - path.AddRectangle(m_rtUI.left, m_rtUI.top, m_rtUI.width, m_rtUI.height); - - pGS->FillPath(&path, FXFILL_WINDING, pMatrix); -} - -void CXFA_FFField::DrawFocus(CFX_Graphics* pGS, CFX_Matrix* pMatrix) { - if (!(m_dwStatus & XFA_WidgetStatus_Focused)) - return; - - CFX_Color cr(0xFF000000); - pGS->SetStrokeColor(&cr); - - float DashPattern[2] = {1, 1}; - pGS->SetLineDash(0.0f, DashPattern, 2); - pGS->SetLineWidth(0, false); - - CFX_Path path; - path.AddRectangle(m_rtUI.left, m_rtUI.top, m_rtUI.width, m_rtUI.height); - pGS->StrokePath(&path, pMatrix); -} - -void CXFA_FFField::SetFWLThemeProvider() { - if (m_pNormalWidget) - m_pNormalWidget->SetThemeProvider(GetApp()->GetFWLTheme()); -} - -bool CXFA_FFField::IsLoaded() { - return m_pNormalWidget && CXFA_FFWidget::IsLoaded(); -} - -bool CXFA_FFField::LoadWidget() { - SetFWLThemeProvider(); - m_pDataAcc->LoadCaption(); - PerformLayout(); - return true; -} - -void CXFA_FFField::UnloadWidget() { - m_pNormalWidget.reset(); -} - -void CXFA_FFField::SetEditScrollOffset() { - XFA_Element eType = m_pDataAcc->GetUIType(); - if (eType != XFA_Element::TextEdit && eType != XFA_Element::NumericEdit && - eType != XFA_Element::PasswordEdit) { - return; - } - - float fScrollOffset = 0; - CXFA_FFField* pPrev = ToField(GetPrev()); - if (pPrev) { - CFX_RectF rtMargin = m_pDataAcc->GetUIMargin(); - fScrollOffset = -rtMargin.top; - } - - while (pPrev) { - fScrollOffset += pPrev->m_rtUI.height; - pPrev = ToField(pPrev->GetPrev()); - } - static_cast(m_pNormalWidget.get()) - ->SetScrollOffset(fScrollOffset); -} - -bool CXFA_FFField::PerformLayout() { - CXFA_FFWidget::PerformLayout(); - CapPlacement(); - LayoutCaption(); - SetFWLRect(); - SetEditScrollOffset(); - if (m_pNormalWidget) - m_pNormalWidget->Update(); - return true; -} - -void CXFA_FFField::CapPlacement() { - CFX_RectF rtWidget = GetRectWithoutRotate(); - CXFA_Margin mgWidget = m_pDataAcc->GetMargin(); - if (mgWidget) { - CXFA_LayoutItem* pItem = this; - float fLeftInset = 0, fRightInset = 0, fTopInset = 0, fBottomInset = 0; - mgWidget.GetLeftInset(fLeftInset); - mgWidget.GetRightInset(fRightInset); - mgWidget.GetTopInset(fTopInset); - mgWidget.GetBottomInset(fBottomInset); - if (!pItem->GetPrev() && !pItem->GetNext()) { - rtWidget.Deflate(fLeftInset, fTopInset, fRightInset, fBottomInset); - } else { - if (!pItem->GetPrev()) - rtWidget.Deflate(fLeftInset, fTopInset, fRightInset, 0); - else if (!pItem->GetNext()) - rtWidget.Deflate(fLeftInset, 0, fRightInset, fBottomInset); - else - rtWidget.Deflate(fLeftInset, 0, fRightInset, 0); - } - } - - XFA_ATTRIBUTEENUM iCapPlacement = XFA_ATTRIBUTEENUM_Unknown; - float fCapReserve = 0; - CXFA_Caption caption = m_pDataAcc->GetCaption(); - if (caption && caption.GetPresence() != XFA_ATTRIBUTEENUM_Hidden) { - iCapPlacement = (XFA_ATTRIBUTEENUM)caption.GetPlacementType(); - if (iCapPlacement == XFA_ATTRIBUTEENUM_Top && GetPrev()) { - m_rtCaption.Reset(); - } else if (iCapPlacement == XFA_ATTRIBUTEENUM_Bottom && GetNext()) { - m_rtCaption.Reset(); - } else { - fCapReserve = caption.GetReserve(); - CXFA_LayoutItem* pItem = this; - if (!pItem->GetPrev() && !pItem->GetNext()) { - m_rtCaption = rtWidget; - } else { - pItem = pItem->GetFirst(); - m_rtCaption = pItem->GetRect(false); - pItem = pItem->GetNext(); - while (pItem) { - m_rtCaption.height += pItem->GetRect(false).Height(); - pItem = pItem->GetNext(); - } - XFA_RectWidthoutMargin(m_rtCaption, mgWidget); - } - - CXFA_TextLayout* pCapTextLayout = m_pDataAcc->GetCaptionTextLayout(); - if (fCapReserve <= 0 && pCapTextLayout) { - CFX_SizeF size; - CFX_SizeF minSize; - CFX_SizeF maxSize; - pCapTextLayout->CalcSize(minSize, maxSize, size); - if (iCapPlacement == XFA_ATTRIBUTEENUM_Top || - iCapPlacement == XFA_ATTRIBUTEENUM_Bottom) { - fCapReserve = size.height; - } else { - fCapReserve = size.width; - } - } - } - } - - m_rtUI = rtWidget; - switch (iCapPlacement) { - case XFA_ATTRIBUTEENUM_Left: { - m_rtCaption.width = fCapReserve; - CapLeftRightPlacement(caption, rtWidget, iCapPlacement); - m_rtUI.width -= fCapReserve; - m_rtUI.left += fCapReserve; - break; - } - case XFA_ATTRIBUTEENUM_Top: { - m_rtCaption.height = fCapReserve; - CapTopBottomPlacement(caption, rtWidget, iCapPlacement); - m_rtUI.top += fCapReserve; - m_rtUI.height -= fCapReserve; - break; - } - case XFA_ATTRIBUTEENUM_Right: { - m_rtCaption.left = m_rtCaption.right() - fCapReserve; - m_rtCaption.width = fCapReserve; - CapLeftRightPlacement(caption, rtWidget, iCapPlacement); - m_rtUI.width -= fCapReserve; - break; - } - case XFA_ATTRIBUTEENUM_Bottom: { - m_rtCaption.top = m_rtCaption.bottom() - fCapReserve; - m_rtCaption.height = fCapReserve; - CapTopBottomPlacement(caption, rtWidget, iCapPlacement); - m_rtUI.height -= fCapReserve; - break; - } - case XFA_ATTRIBUTEENUM_Inline: - break; - default: - break; - } - - CXFA_Border borderUI = m_pDataAcc->GetUIBorder(); - if (borderUI) { - CXFA_Margin margin = borderUI.GetMargin(); - if (margin) - XFA_RectWidthoutMargin(m_rtUI, margin); - } - m_rtUI.Normalize(); -} - -void CXFA_FFField::CapTopBottomPlacement(CXFA_Caption caption, - const CFX_RectF& rtWidget, - int32_t iCapPlacement) { - CFX_RectF rtUIMargin = m_pDataAcc->GetUIMargin(); - m_rtCaption.left += rtUIMargin.left; - if (CXFA_Margin mgCap = caption.GetMargin()) { - XFA_RectWidthoutMargin(m_rtCaption, mgCap); - if (m_rtCaption.height < 0) - m_rtCaption.top += m_rtCaption.height; - } - - float fWidth = rtUIMargin.left + rtUIMargin.width; - float fHeight = m_rtCaption.height + rtUIMargin.top + rtUIMargin.height; - if (fWidth > rtWidget.width) - m_rtUI.width += fWidth - rtWidget.width; - - if (fHeight == XFA_DEFAULTUI_HEIGHT && m_rtUI.height < XFA_MINUI_HEIGHT) { - m_rtUI.height = XFA_MINUI_HEIGHT; - m_rtCaption.top += rtUIMargin.top + rtUIMargin.height; - } else if (fHeight > rtWidget.height) { - m_rtUI.height += fHeight - rtWidget.height; - if (iCapPlacement == XFA_ATTRIBUTEENUM_Bottom) - m_rtCaption.top += fHeight - rtWidget.height; - } -} - -void CXFA_FFField::CapLeftRightPlacement(CXFA_Caption caption, - const CFX_RectF& rtWidget, - int32_t iCapPlacement) { - CFX_RectF rtUIMargin = m_pDataAcc->GetUIMargin(); - m_rtCaption.top += rtUIMargin.top; - m_rtCaption.height -= rtUIMargin.top; - if (CXFA_Margin mgCap = caption.GetMargin()) { - XFA_RectWidthoutMargin(m_rtCaption, mgCap); - if (m_rtCaption.height < 0) - m_rtCaption.top += m_rtCaption.height; - } - - float fWidth = m_rtCaption.width + rtUIMargin.left + rtUIMargin.width; - float fHeight = rtUIMargin.top + rtUIMargin.height; - if (fWidth > rtWidget.width) { - m_rtUI.width += fWidth - rtWidget.width; - if (iCapPlacement == XFA_ATTRIBUTEENUM_Right) - m_rtCaption.left += fWidth - rtWidget.width; - } - - if (fHeight == XFA_DEFAULTUI_HEIGHT && m_rtUI.height < XFA_MINUI_HEIGHT) { - m_rtUI.height = XFA_MINUI_HEIGHT; - m_rtCaption.top += rtUIMargin.top + rtUIMargin.height; - } else if (fHeight > rtWidget.height) { - m_rtUI.height += fHeight - rtWidget.height; - } -} - -void CXFA_FFField::UpdateFWL() { - if (m_pNormalWidget) - m_pNormalWidget->Update(); -} - -uint32_t CXFA_FFField::UpdateUIProperty() { - CXFA_Node* pUiNode = m_pDataAcc->GetUIChild(); - if (pUiNode && pUiNode->GetElementType() == XFA_Element::DefaultUi) - return FWL_STYLEEXT_EDT_ReadOnly; - return 0; -} - -void CXFA_FFField::SetFWLRect() { - if (!m_pNormalWidget) - return; - - CFX_RectF rtUi = m_rtUI; - if (rtUi.width < 1.0) - rtUi.width = 1.0; - if (!m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) { - float fFontSize = m_pDataAcc->GetFontSize(); - if (rtUi.height < fFontSize) - rtUi.height = fFontSize; - } - m_pNormalWidget->SetWidgetRect(rtUi); -} - -bool CXFA_FFField::OnMouseEnter() { - if (!m_pNormalWidget) - return false; - - CFWL_MessageMouse ms(nullptr, m_pNormalWidget.get()); - ms.m_dwCmd = FWL_MouseCommand::Enter; - TranslateFWLMessage(&ms); - return true; -} - -bool CXFA_FFField::OnMouseExit() { - if (!m_pNormalWidget) - return false; - - CFWL_MessageMouse ms(nullptr, m_pNormalWidget.get()); - ms.m_dwCmd = FWL_MouseCommand::Leave; - TranslateFWLMessage(&ms); - return true; -} - -CFX_PointF CXFA_FFField::FWLToClient(const CFX_PointF& point) { - return m_pNormalWidget ? point - m_pNormalWidget->GetWidgetRect().TopLeft() - : point; -} - -bool CXFA_FFField::OnLButtonDown(uint32_t dwFlags, const CFX_PointF& point) { - if (!m_pNormalWidget) - return false; - if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open || - !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) { - return false; - } - if (!PtInActiveRect(point)) - return false; - - SetButtonDown(true); - CFWL_MessageMouse ms(nullptr, m_pNormalWidget.get()); - ms.m_dwCmd = FWL_MouseCommand::LeftButtonDown; - ms.m_dwFlags = dwFlags; - ms.m_pos = FWLToClient(point); - TranslateFWLMessage(&ms); - return true; -} - -bool CXFA_FFField::OnLButtonUp(uint32_t dwFlags, const CFX_PointF& point) { - if (!m_pNormalWidget) - return false; - if (!IsButtonDown()) - return false; - - SetButtonDown(false); - CFWL_MessageMouse ms(nullptr, m_pNormalWidget.get()); - ms.m_dwCmd = FWL_MouseCommand::LeftButtonUp; - ms.m_dwFlags = dwFlags; - ms.m_pos = FWLToClient(point); - TranslateFWLMessage(&ms); - return true; -} - -bool CXFA_FFField::OnLButtonDblClk(uint32_t dwFlags, const CFX_PointF& point) { - if (!m_pNormalWidget) - return false; - - CFWL_MessageMouse ms(nullptr, m_pNormalWidget.get()); - ms.m_dwCmd = FWL_MouseCommand::LeftButtonDblClk; - ms.m_dwFlags = dwFlags; - ms.m_pos = FWLToClient(point); - TranslateFWLMessage(&ms); - return true; -} - -bool CXFA_FFField::OnMouseMove(uint32_t dwFlags, const CFX_PointF& point) { - if (!m_pNormalWidget) - return false; - - CFWL_MessageMouse ms(nullptr, m_pNormalWidget.get()); - ms.m_dwCmd = FWL_MouseCommand::Move; - ms.m_dwFlags = dwFlags; - ms.m_pos = FWLToClient(point); - TranslateFWLMessage(&ms); - return true; -} - -bool CXFA_FFField::OnMouseWheel(uint32_t dwFlags, - int16_t zDelta, - const CFX_PointF& point) { - if (!m_pNormalWidget) - return false; - - CFWL_MessageMouseWheel ms(nullptr, m_pNormalWidget.get()); - ms.m_dwFlags = dwFlags; - ms.m_pos = FWLToClient(point); - ms.m_delta = CFX_PointF(zDelta, 0); - TranslateFWLMessage(&ms); - return true; -} - -bool CXFA_FFField::OnRButtonDown(uint32_t dwFlags, const CFX_PointF& point) { - if (!m_pNormalWidget) - return false; - if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open || - !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) { - return false; - } - if (!PtInActiveRect(point)) - return false; - - SetButtonDown(true); - - CFWL_MessageMouse ms(nullptr, m_pNormalWidget.get()); - ms.m_dwCmd = FWL_MouseCommand::RightButtonDown; - ms.m_dwFlags = dwFlags; - ms.m_pos = FWLToClient(point); - TranslateFWLMessage(&ms); - return true; -} - -bool CXFA_FFField::OnRButtonUp(uint32_t dwFlags, const CFX_PointF& point) { - if (!m_pNormalWidget) - return false; - if (!IsButtonDown()) - return false; - - SetButtonDown(false); - CFWL_MessageMouse ms(nullptr, m_pNormalWidget.get()); - ms.m_dwCmd = FWL_MouseCommand::RightButtonUp; - ms.m_dwFlags = dwFlags; - ms.m_pos = FWLToClient(point); - TranslateFWLMessage(&ms); - return true; -} - -bool CXFA_FFField::OnRButtonDblClk(uint32_t dwFlags, const CFX_PointF& point) { - if (!m_pNormalWidget) - return false; - - CFWL_MessageMouse ms(nullptr, m_pNormalWidget.get()); - ms.m_dwCmd = FWL_MouseCommand::RightButtonDblClk; - ms.m_dwFlags = dwFlags; - ms.m_pos = FWLToClient(point); - TranslateFWLMessage(&ms); - return true; -} - -bool CXFA_FFField::OnSetFocus(CXFA_FFWidget* pOldWidget) { - CXFA_FFWidget::OnSetFocus(pOldWidget); - if (!m_pNormalWidget) - return false; - - CFWL_MessageSetFocus ms(nullptr, m_pNormalWidget.get()); - TranslateFWLMessage(&ms); - m_dwStatus |= XFA_WidgetStatus_Focused; - AddInvalidateRect(); - return true; -} - -bool CXFA_FFField::OnKillFocus(CXFA_FFWidget* pNewWidget) { - if (!m_pNormalWidget) - return CXFA_FFWidget::OnKillFocus(pNewWidget); - - CFWL_MessageKillFocus ms(nullptr, m_pNormalWidget.get()); - TranslateFWLMessage(&ms); - m_dwStatus &= ~XFA_WidgetStatus_Focused; - AddInvalidateRect(); - CXFA_FFWidget::OnKillFocus(pNewWidget); - return true; -} - -bool CXFA_FFField::OnKeyDown(uint32_t dwKeyCode, uint32_t dwFlags) { - if (!m_pNormalWidget || !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) - return false; - - CFWL_MessageKey ms(nullptr, m_pNormalWidget.get()); - ms.m_dwCmd = FWL_KeyCommand::KeyDown; - ms.m_dwFlags = dwFlags; - ms.m_dwKeyCode = dwKeyCode; - TranslateFWLMessage(&ms); - return true; -} - -bool CXFA_FFField::OnKeyUp(uint32_t dwKeyCode, uint32_t dwFlags) { - if (!m_pNormalWidget || !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) - return false; - - CFWL_MessageKey ms(nullptr, m_pNormalWidget.get()); - ms.m_dwCmd = FWL_KeyCommand::KeyUp; - ms.m_dwFlags = dwFlags; - ms.m_dwKeyCode = dwKeyCode; - TranslateFWLMessage(&ms); - return true; -} - -bool CXFA_FFField::OnChar(uint32_t dwChar, uint32_t dwFlags) { - if (!m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) - return false; - if (dwChar == FWL_VKEY_Tab) - return true; - if (!m_pNormalWidget) - return false; - if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open) - return false; - - CFWL_MessageKey ms(nullptr, m_pNormalWidget.get()); - ms.m_dwCmd = FWL_KeyCommand::Char; - ms.m_dwFlags = dwFlags; - ms.m_dwKeyCode = dwChar; - TranslateFWLMessage(&ms); - return true; -} - -FWL_WidgetHit CXFA_FFField::OnHitTest(const CFX_PointF& point) { - if (m_pNormalWidget && - m_pNormalWidget->HitTest(FWLToClient(point)) != FWL_WidgetHit::Unknown) { - return FWL_WidgetHit::Client; - } - - if (!GetRectWithoutRotate().Contains(point)) - return FWL_WidgetHit::Unknown; - if (m_rtCaption.Contains(point)) - return FWL_WidgetHit::Titlebar; - return FWL_WidgetHit::Border; -} - -bool CXFA_FFField::OnSetCursor(const CFX_PointF& point) { - return true; -} - -bool CXFA_FFField::PtInActiveRect(const CFX_PointF& point) { - return m_pNormalWidget && m_pNormalWidget->GetWidgetRect().Contains(point); -} - -void CXFA_FFField::LayoutCaption() { - CXFA_TextLayout* pCapTextLayout = m_pDataAcc->GetCaptionTextLayout(); - if (!pCapTextLayout) - return; - - float fHeight = 0; - pCapTextLayout->Layout(CFX_SizeF(m_rtCaption.width, m_rtCaption.height), - &fHeight); - if (m_rtCaption.height < fHeight) - m_rtCaption.height = fHeight; -} - -void CXFA_FFField::RenderCaption(CFX_Graphics* pGS, CFX_Matrix* pMatrix) { - CXFA_TextLayout* pCapTextLayout = m_pDataAcc->GetCaptionTextLayout(); - if (!pCapTextLayout) - return; - - CXFA_Caption caption = m_pDataAcc->GetCaption(); - if (!caption || caption.GetPresence() != XFA_ATTRIBUTEENUM_Visible) - return; - - if (!pCapTextLayout->IsLoaded()) - pCapTextLayout->Layout(CFX_SizeF(m_rtCaption.width, m_rtCaption.height)); - - CFX_RectF rtClip = m_rtCaption; - rtClip.Intersect(GetRectWithoutRotate()); - CFX_RenderDevice* pRenderDevice = pGS->GetRenderDevice(); - CFX_Matrix mt(1, 0, 0, 1, m_rtCaption.left, m_rtCaption.top); - if (pMatrix) { - pMatrix->TransformRect(rtClip); - mt.Concat(*pMatrix); - } - pCapTextLayout->DrawString(pRenderDevice, mt, rtClip); -} - -bool CXFA_FFField::ProcessCommittedData() { - if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open) - return false; - if (!IsDataChanged()) - return false; - if (CalculateOverride() != 1) - return false; - if (!CommitData()) - return false; - - m_pDocView->SetChangeMark(); - m_pDocView->AddValidateWidget(m_pDataAcc.Get()); - return true; -} - -int32_t CXFA_FFField::CalculateOverride() { - CXFA_WidgetAcc* pAcc = m_pDataAcc->GetExclGroup(); - if (!pAcc) - return CalculateWidgetAcc(m_pDataAcc.Get()); - if (CalculateWidgetAcc(pAcc) == 0) - return 0; - - CXFA_Node* pNode = pAcc->GetExclGroupFirstMember(); - if (!pNode) - return 1; - - CXFA_WidgetAcc* pWidgetAcc = nullptr; - while (pNode) { - pWidgetAcc = static_cast(pNode->GetWidgetData()); - if (!pWidgetAcc) - return 1; - if (CalculateWidgetAcc(pWidgetAcc) == 0) - return 0; - - pNode = pWidgetAcc->GetExclGroupNextMember(pNode); - } - return 1; -} - -int32_t CXFA_FFField::CalculateWidgetAcc(CXFA_WidgetAcc* pAcc) { - CXFA_Calculate calc = pAcc->GetCalculate(); - if (!calc) - return 1; - - XFA_VERSION version = pAcc->GetDoc()->GetXFADoc()->GetCurVersionMode(); - switch (calc.GetOverride()) { - case XFA_ATTRIBUTEENUM_Error: { - if (version <= XFA_VERSION_204) - return 1; - - IXFA_AppProvider* pAppProvider = GetApp()->GetAppProvider(); - if (pAppProvider) { - pAppProvider->MsgBox(L"You are not allowed to modify this field.", - L"Calculate Override", XFA_MBICON_Warning, - XFA_MB_OK); - } - return 0; - } - case XFA_ATTRIBUTEENUM_Warning: { - if (version <= XFA_VERSION_204) { - CXFA_Script script = calc.GetScript(); - if (!script) - return 1; - - CFX_WideString wsExpression; - script.GetExpression(wsExpression); - if (wsExpression.IsEmpty()) - return 1; - } - - if (pAcc->GetNode()->IsUserInteractive()) - return 1; - - IXFA_AppProvider* pAppProvider = GetApp()->GetAppProvider(); - if (!pAppProvider) - return 0; - - CFX_WideString wsMessage; - calc.GetMessageText(wsMessage); - if (!wsMessage.IsEmpty()) - wsMessage += L"\r\n"; - - wsMessage += L"Are you sure you want to modify this field?"; - if (pAppProvider->MsgBox(wsMessage, L"Calculate Override", - XFA_MBICON_Warning, XFA_MB_YesNo) == XFA_IDYes) { - pAcc->GetNode()->SetFlag(XFA_NodeFlag_UserInteractive, false); - return 1; - } - return 0; - } - case XFA_ATTRIBUTEENUM_Ignore: - return 0; - case XFA_ATTRIBUTEENUM_Disabled: - pAcc->GetNode()->SetFlag(XFA_NodeFlag_UserInteractive, false); - return 1; - default: - return 1; - } -} - -bool CXFA_FFField::CommitData() { - return false; -} - -bool CXFA_FFField::IsDataChanged() { - return false; -} - -void CXFA_FFField::TranslateFWLMessage(CFWL_Message* pMessage) { - GetApp()->GetWidgetMgrDelegate()->OnProcessMessageToForm(pMessage); -} - -void CXFA_FFField::OnProcessMessage(CFWL_Message* pMessage) {} - -void CXFA_FFField::OnProcessEvent(CFWL_Event* pEvent) { - switch (pEvent->GetType()) { - case CFWL_Event::Type::Mouse: { - CFWL_EventMouse* event = static_cast(pEvent); - if (event->m_dwCmd == FWL_MouseCommand::Enter) { - CXFA_EventParam eParam; - eParam.m_eType = XFA_EVENT_MouseEnter; - eParam.m_pTarget = m_pDataAcc.Get(); - m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_MouseEnter, &eParam); - } else if (event->m_dwCmd == FWL_MouseCommand::Leave) { - CXFA_EventParam eParam; - eParam.m_eType = XFA_EVENT_MouseExit; - eParam.m_pTarget = m_pDataAcc.Get(); - m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_MouseExit, &eParam); - } else if (event->m_dwCmd == FWL_MouseCommand::LeftButtonDown) { - CXFA_EventParam eParam; - eParam.m_eType = XFA_EVENT_MouseDown; - eParam.m_pTarget = m_pDataAcc.Get(); - m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_MouseDown, &eParam); - } else if (event->m_dwCmd == FWL_MouseCommand::LeftButtonUp) { - CXFA_EventParam eParam; - eParam.m_eType = XFA_EVENT_MouseUp; - eParam.m_pTarget = m_pDataAcc.Get(); - m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_MouseUp, &eParam); - } - break; - } - case CFWL_Event::Type::Click: { - CXFA_EventParam eParam; - eParam.m_eType = XFA_EVENT_Click; - eParam.m_pTarget = m_pDataAcc.Get(); - m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Click, &eParam); - break; - } - default: - break; - } -} - -void CXFA_FFField::OnDrawWidget(CFX_Graphics* pGraphics, - const CFX_Matrix* pMatrix) {} diff --git a/xfa/fxfa/app/xfa_fffield.h b/xfa/fxfa/app/xfa_fffield.h deleted file mode 100644 index eb06caf34a..0000000000 --- a/xfa/fxfa/app/xfa_fffield.h +++ /dev/null @@ -1,99 +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_APP_XFA_FFFIELD_H_ -#define XFA_FXFA_APP_XFA_FFFIELD_H_ - -#include - -#include "xfa/fwl/cfwl_widget.h" -#include "xfa/fwl/ifwl_widgetdelegate.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 - -class CXFA_FFField : public CXFA_FFWidget, public IFWL_WidgetDelegate { - public: - explicit CXFA_FFField(CXFA_WidgetAcc* pDataAcc); - ~CXFA_FFField() override; - - // CXFA_FFWidget - CFX_RectF GetBBox(uint32_t dwStatus, bool bDrawFocus = false) override; - void RenderWidget(CFX_Graphics* pGS, - CFX_Matrix* pMatrix, - uint32_t dwStatus) override; - bool IsLoaded() override; - bool LoadWidget() override; - void UnloadWidget() override; - bool PerformLayout() override; - bool OnMouseEnter() override; - bool OnMouseExit() override; - bool OnLButtonDown(uint32_t dwFlags, const CFX_PointF& point) override; - bool OnLButtonUp(uint32_t dwFlags, const CFX_PointF& point) override; - bool OnLButtonDblClk(uint32_t dwFlags, const CFX_PointF& point) override; - bool OnMouseMove(uint32_t dwFlags, const CFX_PointF& point) override; - bool OnMouseWheel(uint32_t dwFlags, - int16_t zDelta, - const CFX_PointF& point) override; - bool OnRButtonDown(uint32_t dwFlags, const CFX_PointF& point) override; - bool OnRButtonUp(uint32_t dwFlags, const CFX_PointF& point) override; - bool OnRButtonDblClk(uint32_t dwFlags, const CFX_PointF& point) override; - - bool OnSetFocus(CXFA_FFWidget* pOldWidget) override; - bool OnKillFocus(CXFA_FFWidget* pNewWidget) override; - bool OnKeyDown(uint32_t dwKeyCode, uint32_t dwFlags) override; - bool OnKeyUp(uint32_t dwKeyCode, uint32_t dwFlags) override; - bool OnChar(uint32_t dwChar, uint32_t dwFlags) override; - FWL_WidgetHit OnHitTest(const CFX_PointF& point) override; - bool OnSetCursor(const CFX_PointF& point) override; - - // IFWL_WidgetDelegate - void OnProcessMessage(CFWL_Message* pMessage) override; - void OnProcessEvent(CFWL_Event* pEvent) override; - void OnDrawWidget(CFX_Graphics* pGraphics, - const CFX_Matrix* pMatrix = nullptr) override; - - void UpdateFWL(); - uint32_t UpdateUIProperty(); - - protected: - bool PtInActiveRect(const CFX_PointF& point) override; - - virtual void SetFWLRect(); - void SetFWLThemeProvider(); - CFWL_Widget* GetNormalWidget() { return m_pNormalWidget.get(); } - CFX_PointF FWLToClient(const CFX_PointF& point); - void LayoutCaption(); - void RenderCaption(CFX_Graphics* pGS, CFX_Matrix* pMatrix); - - int32_t CalculateOverride(); - int32_t CalculateWidgetAcc(CXFA_WidgetAcc* pAcc); - bool ProcessCommittedData(); - virtual bool CommitData(); - virtual bool IsDataChanged(); - void DrawHighlight(CFX_Graphics* pGS, - CFX_Matrix* pMatrix, - uint32_t dwStatus, - bool bEllipse); - void DrawFocus(CFX_Graphics* pGS, CFX_Matrix* pMatrix); - void TranslateFWLMessage(CFWL_Message* pMessage); - void CapPlacement(); - void CapTopBottomPlacement(CXFA_Caption caption, - const CFX_RectF& rtWidget, - int32_t iCapPlacement); - void CapLeftRightPlacement(CXFA_Caption caption, - const CFX_RectF& rtWidget, - int32_t iCapPlacement); - void SetEditScrollOffset(); - - std::unique_ptr m_pNormalWidget; - CFX_RectF m_rtUI; - CFX_RectF m_rtCaption; -}; - -#endif // XFA_FXFA_APP_XFA_FFFIELD_H_ diff --git a/xfa/fxfa/app/xfa_ffimage.cpp b/xfa/fxfa/app/xfa_ffimage.cpp deleted file mode 100644 index db9b4de52a..0000000000 --- a/xfa/fxfa/app/xfa_ffimage.cpp +++ /dev/null @@ -1,72 +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/app/xfa_ffimage.h" - -#include "xfa/fxfa/app/xfa_ffdraw.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) {} - -CXFA_FFImage::~CXFA_FFImage() { - CXFA_FFImage::UnloadWidget(); -} - -bool CXFA_FFImage::IsLoaded() { - return !!GetDataAcc()->GetImageImage(); -} - -bool CXFA_FFImage::LoadWidget() { - if (GetDataAcc()->GetImageImage()) - return true; - - GetDataAcc()->LoadImageImage(); - return CXFA_FFDraw::LoadWidget(); -} - -void CXFA_FFImage::UnloadWidget() { - GetDataAcc()->SetImageImage(nullptr); -} - -void CXFA_FFImage::RenderWidget(CFX_Graphics* pGS, - CFX_Matrix* pMatrix, - uint32_t dwStatus) { - if (!IsMatchVisibleStatus(dwStatus)) - return; - - CFX_Matrix mtRotate = GetRotateMatrix(); - if (pMatrix) - mtRotate.Concat(*pMatrix); - - CXFA_FFWidget::RenderWidget(pGS, &mtRotate, dwStatus); - - CFX_RetainPtr pDIBitmap = GetDataAcc()->GetImageImage(); - if (!pDIBitmap) - return; - - CFX_RectF rtImage = GetRectWithoutRotate(); - if (CXFA_Margin mgWidget = m_pDataAcc->GetMargin()) - XFA_RectWidthoutMargin(rtImage, mgWidget); - - int32_t iHorzAlign = XFA_ATTRIBUTEENUM_Left; - int32_t iVertAlign = XFA_ATTRIBUTEENUM_Top; - if (CXFA_Para para = m_pDataAcc->GetPara()) { - iHorzAlign = para.GetHorizontalAlign(); - iVertAlign = para.GetVerticalAlign(); - } - - CXFA_Value value = m_pDataAcc->GetFormValue(); - CXFA_Image imageObj = value.GetImage(); - int32_t iAspect = imageObj.GetAspect(); - int32_t iImageXDpi = 0; - int32_t iImageYDpi = 0; - m_pDataAcc->GetImageDpi(iImageXDpi, iImageYDpi); - XFA_DrawImage(pGS, rtImage, &mtRotate, pDIBitmap, iAspect, iImageXDpi, - iImageYDpi, iHorzAlign, iVertAlign); -} diff --git a/xfa/fxfa/app/xfa_ffimage.h b/xfa/fxfa/app/xfa_ffimage.h deleted file mode 100644 index 2c42791877..0000000000 --- a/xfa/fxfa/app/xfa_ffimage.h +++ /dev/null @@ -1,26 +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_APP_XFA_FFIMAGE_H_ -#define XFA_FXFA_APP_XFA_FFIMAGE_H_ - -#include "xfa/fxfa/app/xfa_ffdraw.h" - -class CXFA_FFImage : public CXFA_FFDraw { - public: - explicit CXFA_FFImage(CXFA_WidgetAcc* pDataAcc); - ~CXFA_FFImage() override; - - // CXFA_FFWidget - void RenderWidget(CFX_Graphics* pGS, - CFX_Matrix* pMatrix, - uint32_t dwStatus) override; - bool IsLoaded() override; - bool LoadWidget() override; - void UnloadWidget() override; -}; - -#endif // XFA_FXFA_APP_XFA_FFIMAGE_H_ diff --git a/xfa/fxfa/app/xfa_ffimageedit.cpp b/xfa/fxfa/app/xfa_ffimageedit.cpp deleted file mode 100644 index c8d9509aca..0000000000 --- a/xfa/fxfa/app/xfa_ffimageedit.cpp +++ /dev/null @@ -1,143 +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/app/xfa_ffimageedit.h" - -#include - -#include "third_party/base/ptr_util.h" -#include "xfa/fwl/cfwl_app.h" -#include "xfa/fwl/cfwl_messagemouse.h" -#include "xfa/fwl/cfwl_notedriver.h" -#include "xfa/fwl/cfwl_picturebox.h" -#include "xfa/fxfa/app/xfa_fffield.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) {} - -CXFA_FFImageEdit::~CXFA_FFImageEdit() { - CXFA_FFImageEdit::UnloadWidget(); -} - -bool CXFA_FFImageEdit::LoadWidget() { - auto pNew = pdfium::MakeUnique(GetFWLApp()); - CFWL_PictureBox* pPictureBox = pNew.get(); - m_pNormalWidget = std::move(pNew); - m_pNormalWidget->SetLayoutItem(this); - - CFWL_NoteDriver* pNoteDriver = - m_pNormalWidget->GetOwnerApp()->GetNoteDriver(); - pNoteDriver->RegisterEventTarget(m_pNormalWidget.get(), - m_pNormalWidget.get()); - m_pOldDelegate = pPictureBox->GetDelegate(); - pPictureBox->SetDelegate(this); - - CXFA_FFField::LoadWidget(); - if (!m_pDataAcc->GetImageEditImage()) - UpdateFWLData(); - - return true; -} - -void CXFA_FFImageEdit::UnloadWidget() { - m_pDataAcc->SetImageEditImage(nullptr); - CXFA_FFField::UnloadWidget(); -} - -void CXFA_FFImageEdit::RenderWidget(CFX_Graphics* pGS, - CFX_Matrix* pMatrix, - uint32_t dwStatus) { - if (!IsMatchVisibleStatus(dwStatus)) - return; - - CFX_Matrix mtRotate = GetRotateMatrix(); - if (pMatrix) - mtRotate.Concat(*pMatrix); - - CXFA_FFWidget::RenderWidget(pGS, &mtRotate, dwStatus); - CXFA_Border borderUI = m_pDataAcc->GetUIBorder(); - DrawBorder(pGS, borderUI, m_rtUI, &mtRotate); - RenderCaption(pGS, &mtRotate); - CFX_RetainPtr pDIBitmap = m_pDataAcc->GetImageEditImage(); - if (!pDIBitmap) - return; - - CFX_RectF rtImage = m_pNormalWidget->GetWidgetRect(); - int32_t iHorzAlign = XFA_ATTRIBUTEENUM_Left; - int32_t iVertAlign = XFA_ATTRIBUTEENUM_Top; - if (CXFA_Para para = m_pDataAcc->GetPara()) { - iHorzAlign = para.GetHorizontalAlign(); - iVertAlign = para.GetVerticalAlign(); - } - - int32_t iAspect = XFA_ATTRIBUTEENUM_Fit; - if (CXFA_Value value = m_pDataAcc->GetFormValue()) { - if (CXFA_Image imageObj = value.GetImage()) - iAspect = imageObj.GetAspect(); - } - - int32_t iImageXDpi = 0; - int32_t iImageYDpi = 0; - m_pDataAcc->GetImageEditDpi(iImageXDpi, iImageYDpi); - XFA_DrawImage(pGS, rtImage, &mtRotate, pDIBitmap, iAspect, iImageXDpi, - iImageYDpi, iHorzAlign, iVertAlign); -} - -bool CXFA_FFImageEdit::OnLButtonDown(uint32_t dwFlags, - const CFX_PointF& point) { - if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open) - return false; - if (!PtInActiveRect(point)) - return false; - - SetButtonDown(true); - - CFWL_MessageMouse ms(nullptr, m_pNormalWidget.get()); - ms.m_dwCmd = FWL_MouseCommand::LeftButtonDown; - ms.m_dwFlags = dwFlags; - ms.m_pos = FWLToClient(point); - TranslateFWLMessage(&ms); - return true; -} - -void CXFA_FFImageEdit::SetFWLRect() { - if (!m_pNormalWidget) - return; - - CFX_RectF rtUIMargin = m_pDataAcc->GetUIMargin(); - CFX_RectF rtImage(m_rtUI); - rtImage.Deflate(rtUIMargin.left, rtUIMargin.top, rtUIMargin.width, - rtUIMargin.height); - m_pNormalWidget->SetWidgetRect(rtImage); -} - -bool CXFA_FFImageEdit::CommitData() { - return true; -} - -bool CXFA_FFImageEdit::UpdateFWLData() { - m_pDataAcc->SetImageEditImage(nullptr); - m_pDataAcc->LoadImageEditImage(); - return true; -} - -void CXFA_FFImageEdit::OnProcessMessage(CFWL_Message* pMessage) { - m_pOldDelegate->OnProcessMessage(pMessage); -} - -void CXFA_FFImageEdit::OnProcessEvent(CFWL_Event* pEvent) { - CXFA_FFField::OnProcessEvent(pEvent); - m_pOldDelegate->OnProcessEvent(pEvent); -} - -void CXFA_FFImageEdit::OnDrawWidget(CFX_Graphics* pGraphics, - const CFX_Matrix* pMatrix) { - m_pOldDelegate->OnDrawWidget(pGraphics, pMatrix); -} diff --git a/xfa/fxfa/app/xfa_ffimageedit.h b/xfa/fxfa/app/xfa_ffimageedit.h deleted file mode 100644 index ee91a772e0..0000000000 --- a/xfa/fxfa/app/xfa_ffimageedit.h +++ /dev/null @@ -1,37 +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_APP_XFA_FFIMAGEEDIT_H_ -#define XFA_FXFA_APP_XFA_FFIMAGEEDIT_H_ - -#include "xfa/fxfa/app/xfa_fffield.h" - -class CXFA_FFImageEdit : public CXFA_FFField { - public: - explicit CXFA_FFImageEdit(CXFA_WidgetAcc* pDataAcc); - ~CXFA_FFImageEdit() override; - - // CXFA_FFField - void RenderWidget(CFX_Graphics* pGS, - CFX_Matrix* pMatrix, - uint32_t dwStatus) override; - bool LoadWidget() override; - void UnloadWidget() override; - bool OnLButtonDown(uint32_t dwFlags, const CFX_PointF& point) override; - void OnProcessMessage(CFWL_Message* pMessage) override; - void OnProcessEvent(CFWL_Event* pEvent) override; - void OnDrawWidget(CFX_Graphics* pGraphics, - const CFX_Matrix* pMatrix = nullptr) override; - - private: - void SetFWLRect() override; - bool UpdateFWLData() override; - bool CommitData() override; - - IFWL_WidgetDelegate* m_pOldDelegate; -}; - -#endif // XFA_FXFA_APP_XFA_FFIMAGEEDIT_H_ diff --git a/xfa/fxfa/app/xfa_ffnotify.cpp b/xfa/fxfa/app/xfa_ffnotify.cpp deleted file mode 100644 index b07b625538..0000000000 --- a/xfa/fxfa/app/xfa_ffnotify.cpp +++ /dev/null @@ -1,535 +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/app/xfa_ffnotify.h" - -#include "fxjs/cfxjse_value.h" -#include "xfa/fxfa/app/cxfa_textlayout.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_ffdocview.h" -#include "xfa/fxfa/cxfa_ffpageview.h" -#include "xfa/fxfa/cxfa_ffwidget.h" -#include "xfa/fxfa/cxfa_ffwidgethandler.h" -#include "xfa/fxfa/parser/cxfa_node.h" - -namespace { - -CXFA_WidgetAcc* ToWidgetAcc(void* data) { - return static_cast(data); -} - -CXFA_FFListBox* ToListBox(CXFA_FFWidget* widget) { - return static_cast(widget); -} - -CXFA_FFComboBox* ToComboBox(CXFA_FFWidget* widget) { - return static_cast(widget); -} - -} // namespace - -static void XFA_FFDeleteWidgetAcc(void* pData) { - delete ToWidgetAcc(pData); -} - -static XFA_MAPDATABLOCKCALLBACKINFO gs_XFADeleteWidgetAcc = { - XFA_FFDeleteWidgetAcc, nullptr}; - -CXFA_FFNotify::CXFA_FFNotify(CXFA_FFDoc* pDoc) : m_pDoc(pDoc) {} - -CXFA_FFNotify::~CXFA_FFNotify() {} - -void CXFA_FFNotify::OnPageEvent(CXFA_ContainerLayoutItem* pSender, - uint32_t dwEvent) { - CXFA_FFDocView* pDocView = m_pDoc->GetDocView(pSender->GetLayout()); - if (pDocView) - pDocView->OnPageEvent(pSender, dwEvent); -} - -void CXFA_FFNotify::OnWidgetListItemAdded(CXFA_WidgetData* pSender, - const wchar_t* pLabel, - const wchar_t* pValue, - int32_t iIndex) { - CXFA_WidgetAcc* pWidgetAcc = ToWidgetAcc(pSender); - if (pWidgetAcc->GetUIType() != XFA_Element::ChoiceList) - return; - - CXFA_FFWidget* pWidget = nullptr; - while ((pWidget = pWidgetAcc->GetNextWidget(pWidget)) != nullptr) { - if (pWidget->IsLoaded()) { - if (pWidgetAcc->IsListBox()) - ToListBox(pWidget)->InsertItem(pLabel, iIndex); - else - ToComboBox(pWidget)->InsertItem(pLabel, iIndex); - } - } -} - -void CXFA_FFNotify::OnWidgetListItemRemoved(CXFA_WidgetData* pSender, - int32_t iIndex) { - CXFA_WidgetAcc* pWidgetAcc = ToWidgetAcc(pSender); - if (pWidgetAcc->GetUIType() != XFA_Element::ChoiceList) - return; - - CXFA_FFWidget* pWidget = nullptr; - while ((pWidget = pWidgetAcc->GetNextWidget(pWidget)) != nullptr) { - if (pWidget->IsLoaded()) { - if (pWidgetAcc->IsListBox()) - ToListBox(pWidget)->DeleteItem(iIndex); - else - ToComboBox(pWidget)->DeleteItem(iIndex); - } - } -} - -CXFA_LayoutItem* CXFA_FFNotify::OnCreateLayoutItem(CXFA_Node* pNode) { - CXFA_LayoutProcessor* pLayout = m_pDoc->GetXFADoc()->GetDocLayout(); - CXFA_FFDocView* pDocView = m_pDoc->GetDocView(pLayout); - XFA_Element eType = pNode->GetElementType(); - if (eType == XFA_Element::PageArea) - return new CXFA_FFPageView(pDocView, pNode); - if (eType == XFA_Element::ContentArea) - return new CXFA_ContainerLayoutItem(pNode); - - CXFA_WidgetAcc* pAcc = ToWidgetAcc(pNode->GetWidgetData()); - if (!pAcc) - return new CXFA_ContentLayoutItem(pNode); - - CXFA_FFWidget* pWidget; - switch (pAcc->GetUIType()) { - case XFA_Element::Barcode: - pWidget = new CXFA_FFBarcode(pAcc); - break; - case XFA_Element::Button: - pWidget = new CXFA_FFPushButton(pAcc); - break; - case XFA_Element::CheckButton: - pWidget = new CXFA_FFCheckButton(pAcc); - break; - case XFA_Element::ChoiceList: { - if (pAcc->IsListBox()) - pWidget = new CXFA_FFListBox(pAcc); - else - pWidget = new CXFA_FFComboBox(pAcc); - } break; - case XFA_Element::DateTimeEdit: - pWidget = new CXFA_FFDateTimeEdit(pAcc); - break; - case XFA_Element::ImageEdit: - pWidget = new CXFA_FFImageEdit(pAcc); - break; - case XFA_Element::NumericEdit: - pWidget = new CXFA_FFNumericEdit(pAcc); - break; - case XFA_Element::PasswordEdit: - pWidget = new CXFA_FFPasswordEdit(pAcc); - break; - case XFA_Element::Signature: - pWidget = new CXFA_FFSignature(pAcc); - break; - case XFA_Element::TextEdit: - pWidget = new CXFA_FFTextEdit(pAcc); - break; - case XFA_Element::Arc: - pWidget = new CXFA_FFArc(pAcc); - break; - case XFA_Element::Line: - pWidget = new CXFA_FFLine(pAcc); - break; - case XFA_Element::Rectangle: - pWidget = new CXFA_FFRectangle(pAcc); - break; - case XFA_Element::Text: - pWidget = new CXFA_FFText(pAcc); - break; - case XFA_Element::Image: - pWidget = new CXFA_FFImage(pAcc); - break; - case XFA_Element::Draw: - pWidget = new CXFA_FFDraw(pAcc); - break; - case XFA_Element::Subform: - pWidget = new CXFA_FFSubForm(pAcc); - break; - case XFA_Element::ExclGroup: - pWidget = new CXFA_FFExclGroup(pAcc); - break; - case XFA_Element::DefaultUi: - default: - pWidget = nullptr; - break; - } - - if (pWidget) - pWidget->SetDocView(pDocView); - return pWidget; -} - -void CXFA_FFNotify::StartFieldDrawLayout(CXFA_Node* pItem, - float& fCalcWidth, - float& fCalcHeight) { - CXFA_WidgetAcc* pAcc = ToWidgetAcc(pItem->GetWidgetData()); - if (!pAcc) - return; - - pAcc->StartWidgetLayout(fCalcWidth, fCalcHeight); -} - -bool CXFA_FFNotify::FindSplitPos(CXFA_Node* pItem, - int32_t iBlockIndex, - float& fCalcHeightPos) { - CXFA_WidgetAcc* pAcc = ToWidgetAcc(pItem->GetWidgetData()); - return pAcc && pAcc->FindSplitPos(iBlockIndex, fCalcHeightPos); -} - -bool CXFA_FFNotify::RunScript(CXFA_Node* pScript, CXFA_Node* pFormItem) { - bool bRet = false; - CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); - if (!pDocView) - return bRet; - - CXFA_WidgetAcc* pWidgetAcc = ToWidgetAcc(pFormItem->GetWidgetData()); - if (!pWidgetAcc) - return bRet; - - CXFA_EventParam EventParam; - EventParam.m_eType = XFA_EVENT_Unknown; - CFXJSE_Value* pRetValue = nullptr; - int32_t iRet = - pWidgetAcc->ExecuteScript(CXFA_Script(pScript), &EventParam, &pRetValue); - if (iRet == XFA_EVENTERROR_Success && pRetValue) { - bRet = pRetValue->ToBoolean(); - delete pRetValue; - } - return bRet; -} - -int32_t CXFA_FFNotify::ExecEventByDeepFirst(CXFA_Node* pFormNode, - XFA_EVENTTYPE eEventType, - bool bIsFormReady, - bool bRecursive, - CXFA_WidgetAcc* pExclude) { - CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); - if (!pDocView) - return XFA_EVENTERROR_NotExist; - return pDocView->ExecEventActivityByDeepFirst( - pFormNode, eEventType, bIsFormReady, bRecursive, - pExclude ? pExclude->GetNode() : nullptr); -} - -void CXFA_FFNotify::AddCalcValidate(CXFA_Node* pNode) { - CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); - if (!pDocView) - return; - - CXFA_WidgetAcc* pWidgetAcc = ToWidgetAcc(pNode->GetWidgetData()); - if (!pWidgetAcc) - return; - - pDocView->AddCalculateWidgetAcc(pWidgetAcc); - pDocView->AddValidateWidget(pWidgetAcc); -} - -CXFA_FFDoc* CXFA_FFNotify::GetHDOC() { - return m_pDoc.Get(); -} - -IXFA_DocEnvironment* CXFA_FFNotify::GetDocEnvironment() const { - return m_pDoc->GetDocEnvironment(); -} - -IXFA_AppProvider* CXFA_FFNotify::GetAppProvider() { - return m_pDoc->GetApp()->GetAppProvider(); -} - -CXFA_FFWidgetHandler* CXFA_FFNotify::GetWidgetHandler() { - CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); - return pDocView ? pDocView->GetWidgetHandler() : nullptr; -} - -CXFA_FFWidget* CXFA_FFNotify::GetHWidget(CXFA_LayoutItem* pLayoutItem) { - return XFA_GetWidgetFromLayoutItem(pLayoutItem); -} - -void CXFA_FFNotify::OpenDropDownList(CXFA_FFWidget* hWidget) { - if (hWidget->GetDataAcc()->GetUIType() != XFA_Element::ChoiceList) - return; - - CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); - pDocView->LockUpdate(); - ToComboBox(hWidget)->OpenDropDownList(); - pDocView->UnlockUpdate(); - pDocView->UpdateDocView(); -} - -CFX_WideString CXFA_FFNotify::GetCurrentDateTime() { - CFX_DateTime dataTime; - dataTime.Now(); - - CFX_WideString wsDateTime; - wsDateTime.Format(L"%d%02d%02dT%02d%02d%02d", dataTime.GetYear(), - dataTime.GetMonth(), dataTime.GetDay(), dataTime.GetHour(), - dataTime.GetMinute(), dataTime.GetSecond()); - return wsDateTime; -} - -void CXFA_FFNotify::ResetData(CXFA_WidgetData* pWidgetData) { - CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); - if (!pDocView) - return; - - pDocView->ResetWidgetData(ToWidgetAcc(pWidgetData)); -} - -int32_t CXFA_FFNotify::GetLayoutStatus() { - CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); - return pDocView ? pDocView->GetLayoutStatus() : 0; -} - -void CXFA_FFNotify::RunNodeInitialize(CXFA_Node* pNode) { - CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); - if (!pDocView) - return; - - pDocView->AddNewFormNode(pNode); -} - -void CXFA_FFNotify::RunSubformIndexChange(CXFA_Node* pSubformNode) { - CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); - if (!pDocView) - return; - - pDocView->AddIndexChangedSubform(pSubformNode); -} - -CXFA_Node* CXFA_FFNotify::GetFocusWidgetNode() { - CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); - if (!pDocView) - return nullptr; - - CXFA_WidgetAcc* pAcc = pDocView->GetFocusWidgetAcc(); - return pAcc ? pAcc->GetNode() : nullptr; -} - -void CXFA_FFNotify::SetFocusWidgetNode(CXFA_Node* pNode) { - CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); - if (!pDocView) - return; - - CXFA_WidgetAcc* pAcc = pNode ? ToWidgetAcc(pNode->GetWidgetData()) : nullptr; - pDocView->SetFocusWidgetAcc(pAcc); -} - -void CXFA_FFNotify::OnNodeReady(CXFA_Node* pNode) { - CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); - if (!pDocView) - return; - - XFA_Element eType = pNode->GetElementType(); - if (XFA_IsCreateWidget(eType)) { - CXFA_WidgetAcc* pAcc = new CXFA_WidgetAcc(pDocView, pNode); - pNode->SetObject(XFA_ATTRIBUTE_WidgetData, pAcc, &gs_XFADeleteWidgetAcc); - return; - } - switch (eType) { - case XFA_Element::BindItems: - pDocView->m_BindItems.push_back(pNode); - break; - case XFA_Element::Validate: - pNode->SetFlag(XFA_NodeFlag_NeedsInitApp, false); - break; - default: - break; - } -} - -void CXFA_FFNotify::OnValueChanging(CXFA_Node* pSender, XFA_ATTRIBUTE eAttr) { - if (eAttr != XFA_ATTRIBUTE_Presence) - return; - if (pSender->GetPacketID() & XFA_XDPPACKET_Datasets) - return; - if (!pSender->IsFormContainer()) - return; - - CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); - if (!pDocView) - return; - if (pDocView->GetLayoutStatus() < XFA_DOCVIEW_LAYOUTSTATUS_End) - return; - - CXFA_WidgetAcc* pWidgetAcc = ToWidgetAcc(pSender->GetWidgetData()); - if (!pWidgetAcc) - return; - - CXFA_FFWidget* pWidget = nullptr; - while ((pWidget = pWidgetAcc->GetNextWidget(pWidget)) != nullptr) { - if (pWidget->IsLoaded()) - pWidget->AddInvalidateRect(); - } -} - -void CXFA_FFNotify::OnValueChanged(CXFA_Node* pSender, - XFA_ATTRIBUTE eAttr, - CXFA_Node* pParentNode, - CXFA_Node* pWidgetNode) { - CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); - if (!pDocView) - return; - - if (!(pSender->GetPacketID() & XFA_XDPPACKET_Form)) { - if (eAttr == XFA_ATTRIBUTE_Value) - pDocView->AddCalculateNodeNotify(pSender); - return; - } - - XFA_Element eType = pParentNode->GetElementType(); - bool bIsContainerNode = pParentNode->IsContainerNode(); - CXFA_WidgetAcc* pWidgetAcc = ToWidgetAcc(pWidgetNode->GetWidgetData()); - if (!pWidgetAcc) - return; - - bool bUpdateProperty = false; - pDocView->SetChangeMark(); - switch (eType) { - case XFA_Element::Caption: { - CXFA_TextLayout* pCapOut = pWidgetAcc->GetCaptionTextLayout(); - if (!pCapOut) - return; - - pCapOut->Unload(); - break; - } - case XFA_Element::Ui: - case XFA_Element::Para: - bUpdateProperty = true; - break; - default: - break; - } - if (bIsContainerNode && eAttr == XFA_ATTRIBUTE_Access) - bUpdateProperty = true; - - if (eAttr == XFA_ATTRIBUTE_Value) { - pDocView->AddCalculateNodeNotify(pSender); - if (eType == XFA_Element::Value || bIsContainerNode) { - if (bIsContainerNode) { - pWidgetAcc->UpdateUIDisplay(); - pDocView->AddCalculateWidgetAcc(pWidgetAcc); - pDocView->AddValidateWidget(pWidgetAcc); - } else if (pWidgetNode->GetNodeItem(XFA_NODEITEM_Parent) - ->GetElementType() == XFA_Element::ExclGroup) { - pWidgetAcc->UpdateUIDisplay(); - } - return; - } - } - - CXFA_FFWidget* pWidget = nullptr; - while ((pWidget = pWidgetAcc->GetNextWidget(pWidget)) != nullptr) { - if (!pWidget->IsLoaded()) - continue; - - if (bUpdateProperty) - pWidget->UpdateWidgetProperty(); - pWidget->PerformLayout(); - pWidget->AddInvalidateRect(); - } -} - -void CXFA_FFNotify::OnChildAdded(CXFA_Node* pSender) { - if (!pSender->IsFormContainer()) - return; - - CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); - if (!pDocView) - return; - - bool bLayoutReady = - !(pDocView->m_bInLayoutStatus) && - (pDocView->GetLayoutStatus() == XFA_DOCVIEW_LAYOUTSTATUS_End); - if (bLayoutReady) - m_pDoc->GetDocEnvironment()->SetChangeMark(m_pDoc.Get()); -} - -void CXFA_FFNotify::OnChildRemoved() { - CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); - if (!pDocView) - return; - - bool bLayoutReady = - !(pDocView->m_bInLayoutStatus) && - (pDocView->GetLayoutStatus() == XFA_DOCVIEW_LAYOUTSTATUS_End); - if (bLayoutReady) - m_pDoc->GetDocEnvironment()->SetChangeMark(m_pDoc.Get()); -} - -void CXFA_FFNotify::OnLayoutItemAdded(CXFA_LayoutProcessor* pLayout, - CXFA_LayoutItem* pSender, - int32_t iPageIdx, - uint32_t dwStatus) { - CXFA_FFDocView* pDocView = m_pDoc->GetDocView(pLayout); - if (!pDocView) - return; - - CXFA_FFWidget* pWidget = XFA_GetWidgetFromLayoutItem(pSender); - if (!pWidget) - return; - - CXFA_FFPageView* pNewPageView = pDocView->GetPageView(iPageIdx); - uint32_t dwFilter = XFA_WidgetStatus_Visible | XFA_WidgetStatus_Viewable | - XFA_WidgetStatus_Printable; - pWidget->ModifyStatus(dwStatus, dwFilter); - CXFA_FFPageView* pPrePageView = pWidget->GetPageView(); - if (pPrePageView != pNewPageView || - (dwStatus & (XFA_WidgetStatus_Visible | XFA_WidgetStatus_Viewable)) == - (XFA_WidgetStatus_Visible | XFA_WidgetStatus_Viewable)) { - pWidget->SetPageView(pNewPageView); - m_pDoc->GetDocEnvironment()->WidgetPostAdd(pWidget, pWidget->GetDataAcc()); - } - if (pDocView->GetLayoutStatus() != XFA_DOCVIEW_LAYOUTSTATUS_End || - !(dwStatus & XFA_WidgetStatus_Visible)) { - return; - } - if (pWidget->IsLoaded()) { - if (pWidget->GetWidgetRect() != pWidget->RecacheWidgetRect()) - pWidget->PerformLayout(); - } else { - pWidget->LoadWidget(); - } - pWidget->AddInvalidateRect(nullptr); -} - -void CXFA_FFNotify::OnLayoutItemRemoving(CXFA_LayoutProcessor* pLayout, - CXFA_LayoutItem* pSender) { - CXFA_FFDocView* pDocView = m_pDoc->GetDocView(pLayout); - if (!pDocView) - return; - - CXFA_FFWidget* pWidget = XFA_GetWidgetFromLayoutItem(pSender); - if (!pWidget) - return; - - pDocView->DeleteLayoutItem(pWidget); - m_pDoc->GetDocEnvironment()->WidgetPreRemove(pWidget, pWidget->GetDataAcc()); - pWidget->AddInvalidateRect(nullptr); -} diff --git a/xfa/fxfa/app/xfa_ffnotify.h b/xfa/fxfa/app/xfa_ffnotify.h deleted file mode 100644 index 930d3b6a90..0000000000 --- a/xfa/fxfa/app/xfa_ffnotify.h +++ /dev/null @@ -1,77 +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_APP_XFA_FFNOTIFY_H_ -#define XFA_FXFA_APP_XFA_FFNOTIFY_H_ - -#include "xfa/fxfa/cxfa_eventparam.h" -#include "xfa/fxfa/parser/cxfa_document.h" - -class CXFA_FFWidgetHandler; - -class CXFA_FFNotify { - public: - explicit CXFA_FFNotify(CXFA_FFDoc* pDoc); - ~CXFA_FFNotify(); - - void OnPageEvent(CXFA_ContainerLayoutItem* pSender, uint32_t dwEvent); - - void OnWidgetListItemAdded(CXFA_WidgetData* pSender, - const wchar_t* pLabel, - const wchar_t* pValue, - int32_t iIndex); - void OnWidgetListItemRemoved(CXFA_WidgetData* pSender, int32_t iIndex); - - // Node events - void OnNodeReady(CXFA_Node* pNode); - void OnValueChanging(CXFA_Node* pSender, XFA_ATTRIBUTE eAttr); - void OnValueChanged(CXFA_Node* pSender, - XFA_ATTRIBUTE eAttr, - CXFA_Node* pParentNode, - CXFA_Node* pWidgetNode); - void OnChildAdded(CXFA_Node* pSender); - void OnChildRemoved(); - - CXFA_LayoutItem* OnCreateLayoutItem(CXFA_Node* pNode); - void OnLayoutItemAdded(CXFA_LayoutProcessor* pLayout, - CXFA_LayoutItem* pSender, - int32_t iPageIdx, - uint32_t dwStatus); - void OnLayoutItemRemoving(CXFA_LayoutProcessor* pLayout, - CXFA_LayoutItem* pSender); - - void StartFieldDrawLayout(CXFA_Node* pItem, - float& fCalcWidth, - float& fCalcHeight); - bool FindSplitPos(CXFA_Node* pItem, - int32_t iBlockIndex, - float& fCalcHeightPos); - bool RunScript(CXFA_Node* pScript, CXFA_Node* pFormItem); - int32_t ExecEventByDeepFirst(CXFA_Node* pFormNode, - XFA_EVENTTYPE eEventType, - bool bIsFormReady = false, - bool bRecursive = true, - CXFA_WidgetAcc* pExclude = nullptr); - void AddCalcValidate(CXFA_Node* pNode); - CXFA_FFDoc* GetHDOC(); - IXFA_DocEnvironment* GetDocEnvironment() const; - IXFA_AppProvider* GetAppProvider(); - CXFA_FFWidgetHandler* GetWidgetHandler(); - CXFA_FFWidget* GetHWidget(CXFA_LayoutItem* pLayoutItem); - void OpenDropDownList(CXFA_FFWidget* hWidget); - CFX_WideString GetCurrentDateTime(); - void ResetData(CXFA_WidgetData* pWidgetData = nullptr); - int32_t GetLayoutStatus(); - void RunNodeInitialize(CXFA_Node* pNode); - void RunSubformIndexChange(CXFA_Node* pSubformNode); - CXFA_Node* GetFocusWidgetNode(); - void SetFocusWidgetNode(CXFA_Node* pNode); - - private: - CFX_UnownedPtr const m_pDoc; -}; - -#endif // XFA_FXFA_APP_XFA_FFNOTIFY_H_ diff --git a/xfa/fxfa/app/xfa_ffpath.cpp b/xfa/fxfa/app/xfa_ffpath.cpp deleted file mode 100644 index 854a028aac..0000000000 --- a/xfa/fxfa/app/xfa_ffpath.cpp +++ /dev/null @@ -1,156 +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/app/xfa_ffpath.h" - -#include "xfa/fxfa/app/xfa_ffdraw.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" - -CXFA_FFLine::CXFA_FFLine(CXFA_WidgetAcc* pDataAcc) : CXFA_FFDraw(pDataAcc) {} - -CXFA_FFLine::~CXFA_FFLine() {} - -void CXFA_FFLine::GetRectFromHand(CFX_RectF& rect, - int32_t iHand, - float fLineWidth) { - float fHalfWidth = fLineWidth / 2.0f; - if (rect.height < 1.0f) { - switch (iHand) { - case XFA_ATTRIBUTEENUM_Left: - rect.top -= fHalfWidth; - break; - case XFA_ATTRIBUTEENUM_Right: - rect.top += fHalfWidth; - } - } else if (rect.width < 1.0f) { - switch (iHand) { - case XFA_ATTRIBUTEENUM_Left: - rect.left += fHalfWidth; - break; - case XFA_ATTRIBUTEENUM_Right: - rect.left += fHalfWidth; - break; - } - } else { - switch (iHand) { - case XFA_ATTRIBUTEENUM_Left: - rect.Inflate(fHalfWidth, fHalfWidth); - break; - case XFA_ATTRIBUTEENUM_Right: - rect.Deflate(fHalfWidth, fHalfWidth); - break; - } - } -} - -void CXFA_FFLine::RenderWidget(CFX_Graphics* pGS, - CFX_Matrix* pMatrix, - uint32_t dwStatus) { - if (!IsMatchVisibleStatus(dwStatus)) - return; - - CXFA_Value value = m_pDataAcc->GetFormValue(); - if (!value) - return; - - CXFA_Line lineObj = value.GetLine(); - FX_ARGB lineColor = 0xFF000000; - int32_t iStrokeType = 0; - float fLineWidth = 1.0f; - int32_t iCap = 0; - CXFA_Edge edge = lineObj.GetEdge(); - if (edge) { - if (edge.GetPresence() != XFA_ATTRIBUTEENUM_Visible) - return; - - lineColor = edge.GetColor(); - iStrokeType = edge.GetStrokeType(); - fLineWidth = edge.GetThickness(); - iCap = edge.GetCapType(); - } - - CFX_Matrix mtRotate = GetRotateMatrix(); - if (pMatrix) - mtRotate.Concat(*pMatrix); - - CFX_RectF rtLine = GetRectWithoutRotate(); - if (CXFA_Margin mgWidget = m_pDataAcc->GetMargin()) - XFA_RectWidthoutMargin(rtLine, mgWidget); - - GetRectFromHand(rtLine, lineObj.GetHand(), fLineWidth); - CFX_Path linePath; - if (lineObj.GetSlope() && rtLine.right() > 0.0f && rtLine.bottom() > 0.0f) - linePath.AddLine(rtLine.TopRight(), rtLine.BottomLeft()); - else - linePath.AddLine(rtLine.TopLeft(), rtLine.BottomRight()); - - CFX_Color color(lineColor); - pGS->SaveGraphState(); - pGS->SetLineWidth(fLineWidth, true); - XFA_StrokeTypeSetLineDash(pGS, iStrokeType, iCap); - pGS->SetStrokeColor(&color); - pGS->SetLineCap(XFA_LineCapToFXGE(iCap)); - pGS->StrokePath(&linePath, &mtRotate); - pGS->RestoreGraphState(); -} - -CXFA_FFArc::CXFA_FFArc(CXFA_WidgetAcc* pDataAcc) : CXFA_FFDraw(pDataAcc) {} - -CXFA_FFArc::~CXFA_FFArc() {} - -void CXFA_FFArc::RenderWidget(CFX_Graphics* pGS, - CFX_Matrix* pMatrix, - uint32_t dwStatus) { - if (!IsMatchVisibleStatus(dwStatus)) - return; - - CXFA_Value value = m_pDataAcc->GetFormValue(); - if (!value) - return; - - CXFA_Arc arcObj = value.GetArc(); - CFX_Matrix mtRotate = GetRotateMatrix(); - if (pMatrix) - mtRotate.Concat(*pMatrix); - - CFX_RectF rtArc = GetRectWithoutRotate(); - if (CXFA_Margin mgWidget = m_pDataAcc->GetMargin()) - XFA_RectWidthoutMargin(rtArc, mgWidget); - - DrawBorder(pGS, arcObj, rtArc, &mtRotate); -} - -CXFA_FFRectangle::CXFA_FFRectangle(CXFA_WidgetAcc* pDataAcc) - : CXFA_FFDraw(pDataAcc) {} - -CXFA_FFRectangle::~CXFA_FFRectangle() {} - -void CXFA_FFRectangle::RenderWidget(CFX_Graphics* pGS, - CFX_Matrix* pMatrix, - uint32_t dwStatus) { - if (!IsMatchVisibleStatus(dwStatus)) - return; - - CXFA_Value value = m_pDataAcc->GetFormValue(); - if (!value) - return; - - CXFA_Rectangle rtObj = value.GetRectangle(); - CFX_RectF rect = GetRectWithoutRotate(); - if (CXFA_Margin mgWidget = m_pDataAcc->GetMargin()) - XFA_RectWidthoutMargin(rect, mgWidget); - - CFX_Matrix mtRotate = GetRotateMatrix(); - if (pMatrix) - mtRotate.Concat(*pMatrix); - - DrawBorder(pGS, rtObj, rect, &mtRotate); -} diff --git a/xfa/fxfa/app/xfa_ffpath.h b/xfa/fxfa/app/xfa_ffpath.h deleted file mode 100644 index 6df53f4e1d..0000000000 --- a/xfa/fxfa/app/xfa_ffpath.h +++ /dev/null @@ -1,48 +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_APP_XFA_FFPATH_H_ -#define XFA_FXFA_APP_XFA_FFPATH_H_ - -#include "xfa/fxfa/app/xfa_ffdraw.h" - -class CXFA_FFLine : public CXFA_FFDraw { - public: - explicit CXFA_FFLine(CXFA_WidgetAcc* pDataAcc); - ~CXFA_FFLine() override; - - // CXFA_FFWidget - void RenderWidget(CFX_Graphics* pGS, - CFX_Matrix* pMatrix, - uint32_t dwStatus) override; - - private: - void GetRectFromHand(CFX_RectF& rect, int32_t iHand, float fLineWidth); -}; - -class CXFA_FFArc : public CXFA_FFDraw { - public: - explicit CXFA_FFArc(CXFA_WidgetAcc* pDataAcc); - ~CXFA_FFArc() override; - - // CXFA_FFWidget - void RenderWidget(CFX_Graphics* pGS, - CFX_Matrix* pMatrix, - uint32_t dwStatus) override; -}; - -class CXFA_FFRectangle : public CXFA_FFDraw { - public: - explicit CXFA_FFRectangle(CXFA_WidgetAcc* pDataAcc); - ~CXFA_FFRectangle() override; - - // CXFA_FFWidget - void RenderWidget(CFX_Graphics* pGS, - CFX_Matrix* pMatrix, - uint32_t dwStatus) override; -}; - -#endif // XFA_FXFA_APP_XFA_FFPATH_H_ diff --git a/xfa/fxfa/app/xfa_ffpushbutton.cpp b/xfa/fxfa/app/xfa_ffpushbutton.cpp deleted file mode 100644 index b596996b6c..0000000000 --- a/xfa/fxfa/app/xfa_ffpushbutton.cpp +++ /dev/null @@ -1,240 +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/app/xfa_ffpushbutton.h" - -#include - -#include "third_party/base/ptr_util.h" -#include "xfa/fwl/cfwl_notedriver.h" -#include "xfa/fwl/cfwl_pushbutton.h" -#include "xfa/fwl/cfwl_widgetmgr.h" -#include "xfa/fxfa/app/cxfa_textlayout.h" -#include "xfa/fxfa/app/xfa_fffield.h" -#include "xfa/fxfa/app/xfa_ffwidgetacc.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" - -CXFA_FFPushButton::CXFA_FFPushButton(CXFA_WidgetAcc* pDataAcc) - : CXFA_FFField(pDataAcc), m_pOldDelegate(nullptr) {} - -CXFA_FFPushButton::~CXFA_FFPushButton() { - CXFA_FFPushButton::UnloadWidget(); -} - -void CXFA_FFPushButton::RenderWidget(CFX_Graphics* pGS, - CFX_Matrix* pMatrix, - uint32_t dwStatus) { - if (!IsMatchVisibleStatus(dwStatus)) - return; - - CFX_Matrix mtRotate = GetRotateMatrix(); - if (pMatrix) - mtRotate.Concat(*pMatrix); - - CXFA_FFWidget::RenderWidget(pGS, &mtRotate, dwStatus); - RenderHighlightCaption(pGS, &mtRotate); - - CFX_RectF rtWidget = GetRectWithoutRotate(); - CFX_Matrix mt(1, 0, 0, 1, rtWidget.left, rtWidget.top); - mt.Concat(mtRotate); - GetApp()->GetWidgetMgrDelegate()->OnDrawWidget(m_pNormalWidget.get(), pGS, - &mt); -} - -bool CXFA_FFPushButton::LoadWidget() { - ASSERT(!m_pNormalWidget); - auto pNew = pdfium::MakeUnique(GetFWLApp()); - CFWL_PushButton* pPushButton = pNew.get(); - m_pOldDelegate = pPushButton->GetDelegate(); - pPushButton->SetDelegate(this); - m_pNormalWidget = std::move(pNew); - m_pNormalWidget->SetLayoutItem(this); - - CFWL_NoteDriver* pNoteDriver = - m_pNormalWidget->GetOwnerApp()->GetNoteDriver(); - pNoteDriver->RegisterEventTarget(m_pNormalWidget.get(), - m_pNormalWidget.get()); - m_pNormalWidget->LockUpdate(); - UpdateWidgetProperty(); - LoadHighlightCaption(); - m_pNormalWidget->UnlockUpdate(); - return CXFA_FFField::LoadWidget(); -} - -void CXFA_FFPushButton::UpdateWidgetProperty() { - uint32_t dwStyleEx = 0; - switch (m_pDataAcc->GetButtonHighlight()) { - case XFA_ATTRIBUTEENUM_Inverted: - dwStyleEx = XFA_FWL_PSBSTYLEEXT_HiliteInverted; - break; - case XFA_ATTRIBUTEENUM_Outline: - dwStyleEx = XFA_FWL_PSBSTYLEEXT_HiliteOutLine; - break; - case XFA_ATTRIBUTEENUM_Push: - dwStyleEx = XFA_FWL_PSBSTYLEEXT_HilitePush; - break; - default: - break; - } - m_pNormalWidget->ModifyStylesEx(dwStyleEx, 0xFFFFFFFF); -} - -void CXFA_FFPushButton::UnloadWidget() { - m_pRolloverTextLayout.reset(); - m_pDownTextLayout.reset(); - m_pRollProvider.reset(); - m_pDownProvider.reset(); - CXFA_FFField::UnloadWidget(); -} - -bool CXFA_FFPushButton::PerformLayout() { - CXFA_FFWidget::PerformLayout(); - CFX_RectF rtWidget = GetRectWithoutRotate(); - - m_rtUI = rtWidget; - if (CXFA_Margin mgWidget = m_pDataAcc->GetMargin()) - XFA_RectWidthoutMargin(rtWidget, mgWidget); - - CXFA_Caption caption = m_pDataAcc->GetCaption(); - m_rtCaption = rtWidget; - if (CXFA_Margin mgCap = caption.GetMargin()) - XFA_RectWidthoutMargin(m_rtCaption, mgCap); - - LayoutHighlightCaption(); - SetFWLRect(); - if (m_pNormalWidget) - m_pNormalWidget->Update(); - - return true; -} -float CXFA_FFPushButton::GetLineWidth() { - CXFA_Border border = m_pDataAcc->GetBorder(false); - if (border && border.GetPresence() == XFA_ATTRIBUTEENUM_Visible) { - CXFA_Edge edge = border.GetEdge(0); - return edge.GetThickness(); - } - return 0; -} - -FX_ARGB CXFA_FFPushButton::GetLineColor() { - return 0xFF000000; -} - -FX_ARGB CXFA_FFPushButton::GetFillColor() { - return 0xFFFFFFFF; -} - -void CXFA_FFPushButton::LoadHighlightCaption() { - CXFA_Caption caption = m_pDataAcc->GetCaption(); - if (!caption || caption.GetPresence() == XFA_ATTRIBUTEENUM_Hidden) - return; - - bool bRichText; - CFX_WideString wsRollover; - if (m_pDataAcc->GetButtonRollover(wsRollover, bRichText)) { - if (!m_pRollProvider) { - m_pRollProvider = pdfium::MakeUnique( - m_pDataAcc.Get(), XFA_TEXTPROVIDERTYPE_Rollover); - } - m_pRolloverTextLayout = - pdfium::MakeUnique(m_pRollProvider.get()); - } - CFX_WideString wsDown; - if (m_pDataAcc->GetButtonDown(wsDown, bRichText)) { - if (!m_pDownProvider) { - m_pDownProvider = pdfium::MakeUnique( - m_pDataAcc.Get(), XFA_TEXTPROVIDERTYPE_Down); - } - m_pDownTextLayout = - pdfium::MakeUnique(m_pDownProvider.get()); - } -} - -void CXFA_FFPushButton::LayoutHighlightCaption() { - CFX_SizeF sz(m_rtCaption.width, m_rtCaption.height); - LayoutCaption(); - if (m_pRolloverTextLayout) - m_pRolloverTextLayout->Layout(sz); - if (m_pDownTextLayout) - m_pDownTextLayout->Layout(sz); -} - -void CXFA_FFPushButton::RenderHighlightCaption(CFX_Graphics* pGS, - CFX_Matrix* pMatrix) { - CXFA_TextLayout* pCapTextLayout = m_pDataAcc->GetCaptionTextLayout(); - CXFA_Caption caption = m_pDataAcc->GetCaption(); - if (!caption || caption.GetPresence() != XFA_ATTRIBUTEENUM_Visible) - return; - - CFX_RenderDevice* pRenderDevice = pGS->GetRenderDevice(); - CFX_RectF rtClip = m_rtCaption; - rtClip.Intersect(GetRectWithoutRotate()); - CFX_Matrix mt(1, 0, 0, 1, m_rtCaption.left, m_rtCaption.top); - if (pMatrix) { - pMatrix->TransformRect(rtClip); - mt.Concat(*pMatrix); - } - - uint32_t dwState = m_pNormalWidget->GetStates(); - if (m_pDownTextLayout && (dwState & FWL_STATE_PSB_Pressed) && - (dwState & FWL_STATE_PSB_Hovered)) { - if (m_pDownTextLayout->DrawString(pRenderDevice, mt, rtClip)) - return; - } else if (m_pRolloverTextLayout && (dwState & FWL_STATE_PSB_Hovered)) { - if (m_pRolloverTextLayout->DrawString(pRenderDevice, mt, rtClip)) - return; - } - - if (pCapTextLayout) - pCapTextLayout->DrawString(pRenderDevice, mt, rtClip); -} - -void CXFA_FFPushButton::OnProcessMessage(CFWL_Message* pMessage) { - m_pOldDelegate->OnProcessMessage(pMessage); -} - -void CXFA_FFPushButton::OnProcessEvent(CFWL_Event* pEvent) { - m_pOldDelegate->OnProcessEvent(pEvent); - CXFA_FFField::OnProcessEvent(pEvent); -} - -void CXFA_FFPushButton::OnDrawWidget(CFX_Graphics* pGraphics, - const CFX_Matrix* pMatrix) { - if (m_pNormalWidget->GetStylesEx() & XFA_FWL_PSBSTYLEEXT_HiliteInverted) { - if ((m_pNormalWidget->GetStates() & FWL_STATE_PSB_Pressed) && - (m_pNormalWidget->GetStates() & FWL_STATE_PSB_Hovered)) { - CFX_RectF rtFill(0, 0, m_pNormalWidget->GetWidgetRect().Size()); - float fLineWith = GetLineWidth(); - rtFill.Deflate(fLineWith, fLineWith); - CFX_Color cr(FXARGB_MAKE(128, 128, 255, 255)); - pGraphics->SetFillColor(&cr); - - CFX_Path path; - path.AddRectangle(rtFill.left, rtFill.top, rtFill.width, rtFill.height); - pGraphics->FillPath(&path, FXFILL_WINDING, (CFX_Matrix*)pMatrix); - } - return; - } - - if (m_pNormalWidget->GetStylesEx() & XFA_FWL_PSBSTYLEEXT_HiliteOutLine) { - if ((m_pNormalWidget->GetStates() & FWL_STATE_PSB_Pressed) && - (m_pNormalWidget->GetStates() & FWL_STATE_PSB_Hovered)) { - float fLineWidth = GetLineWidth(); - CFX_Color cr(FXARGB_MAKE(255, 128, 255, 255)); - pGraphics->SetStrokeColor(&cr); - pGraphics->SetLineWidth(fLineWidth); - - CFX_Path path; - CFX_RectF rect = m_pNormalWidget->GetWidgetRect(); - path.AddRectangle(0, 0, rect.width, rect.height); - pGraphics->StrokePath(&path, (CFX_Matrix*)pMatrix); - } - } -} diff --git a/xfa/fxfa/app/xfa_ffpushbutton.h b/xfa/fxfa/app/xfa_ffpushbutton.h deleted file mode 100644 index 3695fc4e1b..0000000000 --- a/xfa/fxfa/app/xfa_ffpushbutton.h +++ /dev/null @@ -1,54 +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_APP_XFA_FFPUSHBUTTON_H_ -#define XFA_FXFA_APP_XFA_FFPUSHBUTTON_H_ - -#include - -#include "xfa/fxfa/app/xfa_fffield.h" - -#define XFA_FWL_PSBSTYLEEXT_HiliteNone (0L << 0) -#define XFA_FWL_PSBSTYLEEXT_HiliteInverted (1L << 0) -#define XFA_FWL_PSBSTYLEEXT_HilitePush (2L << 0) -#define XFA_FWL_PSBSTYLEEXT_HiliteOutLine (4L << 0) - -class CXFA_TextProvider; - -class CXFA_FFPushButton : public CXFA_FFField { - public: - explicit CXFA_FFPushButton(CXFA_WidgetAcc* pDataAcc); - ~CXFA_FFPushButton() override; - - // CXFA_FFField - void RenderWidget(CFX_Graphics* pGS, - CFX_Matrix* pMatrix, - uint32_t dwStatus) override; - bool LoadWidget() override; - void UnloadWidget() override; - bool PerformLayout() override; - void UpdateWidgetProperty() override; - void OnProcessMessage(CFWL_Message* pMessage) override; - void OnProcessEvent(CFWL_Event* pEvent) override; - void OnDrawWidget(CFX_Graphics* pGraphics, - const CFX_Matrix* pMatrix = nullptr) override; - - private: - void LoadHighlightCaption(); - void LayoutHighlightCaption(); - void RenderHighlightCaption(CFX_Graphics* pGS, CFX_Matrix* pMatrix); - float GetLineWidth(); - FX_ARGB GetLineColor(); - FX_ARGB GetFillColor(); - - std::unique_ptr m_pRolloverTextLayout; - std::unique_ptr m_pDownTextLayout; - std::unique_ptr m_pRollProvider; - std::unique_ptr m_pDownProvider; - IFWL_WidgetDelegate* m_pOldDelegate; -}; - -#endif // XFA_FXFA_APP_XFA_FFPUSHBUTTON_H_ diff --git a/xfa/fxfa/app/xfa_ffsignature.cpp b/xfa/fxfa/app/xfa_ffsignature.cpp deleted file mode 100644 index edc34336c6..0000000000 --- a/xfa/fxfa/app/xfa_ffsignature.cpp +++ /dev/null @@ -1,114 +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/app/xfa_ffsignature.h" - -#include "xfa/fxfa/app/xfa_fffield.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) {} - -CXFA_FFSignature::~CXFA_FFSignature() {} - -bool CXFA_FFSignature::LoadWidget() { - return CXFA_FFField::LoadWidget(); -} - -void CXFA_FFSignature::RenderWidget(CFX_Graphics* pGS, - CFX_Matrix* pMatrix, - uint32_t dwStatus) { - if (!IsMatchVisibleStatus(dwStatus)) - return; - - CFX_Matrix mtRotate = GetRotateMatrix(); - if (pMatrix) - mtRotate.Concat(*pMatrix); - - CXFA_FFWidget::RenderWidget(pGS, &mtRotate, dwStatus); - - CXFA_Border borderUI = m_pDataAcc->GetUIBorder(); - DrawBorder(pGS, borderUI, m_rtUI, &mtRotate); - RenderCaption(pGS, &mtRotate); - DrawHighlight(pGS, &mtRotate, dwStatus, false); -} - -bool CXFA_FFSignature::OnMouseEnter() { - return false; -} - -bool CXFA_FFSignature::OnMouseExit() { - return false; -} - -bool CXFA_FFSignature::OnLButtonDown(uint32_t dwFlags, - const CFX_PointF& point) { - return false; -} - -bool CXFA_FFSignature::OnLButtonUp(uint32_t dwFlags, const CFX_PointF& point) { - return false; -} - -bool CXFA_FFSignature::OnLButtonDblClk(uint32_t dwFlags, - const CFX_PointF& point) { - return false; -} - -bool CXFA_FFSignature::OnMouseMove(uint32_t dwFlags, const CFX_PointF& point) { - return false; -} - -bool CXFA_FFSignature::OnMouseWheel(uint32_t dwFlags, - int16_t zDelta, - const CFX_PointF& point) { - return false; -} - -bool CXFA_FFSignature::OnRButtonDown(uint32_t dwFlags, - const CFX_PointF& point) { - return false; -} - -bool CXFA_FFSignature::OnRButtonUp(uint32_t dwFlags, const CFX_PointF& point) { - return false; -} - -bool CXFA_FFSignature::OnRButtonDblClk(uint32_t dwFlags, - const CFX_PointF& point) { - return false; -} - -bool CXFA_FFSignature::OnKeyDown(uint32_t dwKeyCode, uint32_t dwFlags) { - return false; -} - -bool CXFA_FFSignature::OnKeyUp(uint32_t dwKeyCode, uint32_t dwFlags) { - return false; -} - -bool CXFA_FFSignature::OnChar(uint32_t dwChar, uint32_t dwFlags) { - return false; -} - -FWL_WidgetHit CXFA_FFSignature::OnHitTest(const CFX_PointF& point) { - if (m_pNormalWidget && - m_pNormalWidget->HitTest(FWLToClient(point)) != FWL_WidgetHit::Unknown) { - return FWL_WidgetHit::Client; - } - - if (!GetRectWithoutRotate().Contains(point)) - return FWL_WidgetHit::Unknown; - if (m_rtCaption.Contains(point)) - return FWL_WidgetHit::Titlebar; - return FWL_WidgetHit::Client; -} - -bool CXFA_FFSignature::OnSetCursor(const CFX_PointF& point) { - return false; -} diff --git a/xfa/fxfa/app/xfa_ffsignature.h b/xfa/fxfa/app/xfa_ffsignature.h deleted file mode 100644 index 934323f436..0000000000 --- a/xfa/fxfa/app/xfa_ffsignature.h +++ /dev/null @@ -1,42 +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_APP_XFA_FFSIGNATURE_H_ -#define XFA_FXFA_APP_XFA_FFSIGNATURE_H_ - -#include "xfa/fxfa/app/xfa_fffield.h" - -class CXFA_FFSignature final : public CXFA_FFField { - public: - explicit CXFA_FFSignature(CXFA_WidgetAcc* pDataAcc); - ~CXFA_FFSignature() override; - - // CXFA_FFField - void RenderWidget(CFX_Graphics* pGS, - CFX_Matrix* pMatrix, - uint32_t dwStatus) override; - bool LoadWidget() override; - bool OnMouseEnter() override; - bool OnMouseExit() override; - bool OnLButtonDown(uint32_t dwFlags, const CFX_PointF& point) override; - bool OnLButtonUp(uint32_t dwFlags, const CFX_PointF& point) override; - bool OnLButtonDblClk(uint32_t dwFlags, const CFX_PointF& point) override; - bool OnMouseMove(uint32_t dwFlags, const CFX_PointF& point) override; - bool OnMouseWheel(uint32_t dwFlags, - int16_t zDelta, - const CFX_PointF& pointy) override; - bool OnRButtonDown(uint32_t dwFlags, const CFX_PointF& point) override; - bool OnRButtonUp(uint32_t dwFlags, const CFX_PointF& point) override; - bool OnRButtonDblClk(uint32_t dwFlags, const CFX_PointF& point) override; - - bool OnKeyDown(uint32_t dwKeyCode, uint32_t dwFlags) override; - bool OnKeyUp(uint32_t dwKeyCode, uint32_t dwFlags) override; - bool OnChar(uint32_t dwChar, uint32_t dwFlags) override; - FWL_WidgetHit OnHitTest(const CFX_PointF& point) override; - bool OnSetCursor(const CFX_PointF& point) override; -}; - -#endif // XFA_FXFA_APP_XFA_FFSIGNATURE_H_ diff --git a/xfa/fxfa/app/xfa_ffsubform.cpp b/xfa/fxfa/app/xfa_ffsubform.cpp deleted file mode 100644 index d008c5b4f9..0000000000 --- a/xfa/fxfa/app/xfa_ffsubform.cpp +++ /dev/null @@ -1,17 +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/app/xfa_ffsubform.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) {} - -CXFA_FFSubForm::~CXFA_FFSubForm() {} diff --git a/xfa/fxfa/app/xfa_ffsubform.h b/xfa/fxfa/app/xfa_ffsubform.h deleted file mode 100644 index c87688fdce..0000000000 --- a/xfa/fxfa/app/xfa_ffsubform.h +++ /dev/null @@ -1,19 +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_APP_XFA_FFSUBFORM_H_ -#define XFA_FXFA_APP_XFA_FFSUBFORM_H_ - -#include "xfa/fxfa/cxfa_ffpageview.h" -#include "xfa/fxfa/cxfa_ffwidget.h" - -class CXFA_FFSubForm : public CXFA_FFWidget { - public: - explicit CXFA_FFSubForm(CXFA_WidgetAcc* pDataAcc); - ~CXFA_FFSubForm() override; -}; - -#endif // XFA_FXFA_APP_XFA_FFSUBFORM_H_ diff --git a/xfa/fxfa/app/xfa_fftext.cpp b/xfa/fxfa/app/xfa_fftext.cpp deleted file mode 100644 index 89d77c3eaf..0000000000 --- a/xfa/fxfa/app/xfa_fftext.cpp +++ /dev/null @@ -1,163 +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/app/xfa_fftext.h" - -#include "xfa/fwl/fwl_widgetdef.h" -#include "xfa/fwl/fwl_widgethit.h" -#include "xfa/fxfa/app/cxfa_linkuserdata.h" -#include "xfa/fxfa/app/cxfa_pieceline.h" -#include "xfa/fxfa/app/cxfa_textlayout.h" -#include "xfa/fxfa/app/xfa_ffdraw.h" -#include "xfa/fxfa/app/xfa_textpiece.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) {} - -CXFA_FFText::~CXFA_FFText() {} - -void CXFA_FFText::RenderWidget(CFX_Graphics* pGS, - CFX_Matrix* pMatrix, - uint32_t dwStatus) { - if (!IsMatchVisibleStatus(dwStatus)) - return; - - CFX_Matrix mtRotate = GetRotateMatrix(); - if (pMatrix) - mtRotate.Concat(*pMatrix); - - CXFA_FFWidget::RenderWidget(pGS, &mtRotate, dwStatus); - - CXFA_TextLayout* pTextLayout = m_pDataAcc->GetTextLayout(); - if (!pTextLayout) - return; - - CFX_RenderDevice* pRenderDevice = pGS->GetRenderDevice(); - CFX_RectF rtText = GetRectWithoutRotate(); - if (CXFA_Margin mgWidget = m_pDataAcc->GetMargin()) { - CXFA_LayoutItem* pItem = this; - if (!pItem->GetPrev() && !pItem->GetNext()) { - XFA_RectWidthoutMargin(rtText, mgWidget); - } else { - float fLeftInset; - float fRightInset; - float fTopInset = 0; - float fBottomInset = 0; - mgWidget.GetLeftInset(fLeftInset); - mgWidget.GetRightInset(fRightInset); - if (!pItem->GetPrev()) - mgWidget.GetTopInset(fTopInset); - else if (!pItem->GetNext()) - mgWidget.GetBottomInset(fBottomInset); - - rtText.Deflate(fLeftInset, fTopInset, fRightInset, fBottomInset); - } - } - - CFX_Matrix mt(1, 0, 0, 1, rtText.left, rtText.top); - CFX_RectF rtClip = rtText; - mtRotate.TransformRect(rtClip); - mt.Concat(mtRotate); - pTextLayout->DrawString(pRenderDevice, mt, rtClip, GetIndex()); -} - -bool CXFA_FFText::IsLoaded() { - CXFA_TextLayout* pTextLayout = m_pDataAcc->GetTextLayout(); - return pTextLayout && !pTextLayout->m_bHasBlock; -} - -bool CXFA_FFText::PerformLayout() { - CXFA_FFDraw::PerformLayout(); - CXFA_TextLayout* pTextLayout = m_pDataAcc->GetTextLayout(); - if (!pTextLayout) - return false; - if (!pTextLayout->m_bHasBlock) - return true; - - pTextLayout->m_Blocks.clear(); - CXFA_LayoutItem* pItem = this; - if (!pItem->GetPrev() && !pItem->GetNext()) - return true; - - pItem = pItem->GetFirst(); - while (pItem) { - CFX_RectF rtText = pItem->GetRect(false); - if (CXFA_Margin mgWidget = m_pDataAcc->GetMargin()) { - if (!pItem->GetPrev()) { - float fTopInset; - mgWidget.GetTopInset(fTopInset); - rtText.height -= fTopInset; - } else if (!pItem->GetNext()) { - float fBottomInset; - mgWidget.GetBottomInset(fBottomInset); - rtText.height -= fBottomInset; - } - } - pTextLayout->ItemBlocks(rtText, pItem->GetIndex()); - pItem = pItem->GetNext(); - } - pTextLayout->m_bHasBlock = false; - return true; -} - -bool CXFA_FFText::OnLButtonDown(uint32_t dwFlags, const CFX_PointF& point) { - if (!GetRectWithoutRotate().Contains(point)) - return false; - - const wchar_t* wsURLContent = GetLinkURLAtPoint(point); - if (!wsURLContent) - return false; - - SetButtonDown(true); - return true; -} - -bool CXFA_FFText::OnMouseMove(uint32_t dwFlags, const CFX_PointF& point) { - return GetRectWithoutRotate().Contains(point) && !!GetLinkURLAtPoint(point); -} - -bool CXFA_FFText::OnLButtonUp(uint32_t dwFlags, const CFX_PointF& point) { - if (!IsButtonDown()) - return false; - - SetButtonDown(false); - const wchar_t* wsURLContent = GetLinkURLAtPoint(point); - if (!wsURLContent) - return false; - - CXFA_FFDoc* pDoc = GetDoc(); - pDoc->GetDocEnvironment()->GotoURL(pDoc, wsURLContent); - return true; -} - -FWL_WidgetHit CXFA_FFText::OnHitTest(const CFX_PointF& point) { - if (!GetRectWithoutRotate().Contains(point)) - return FWL_WidgetHit::Unknown; - if (!GetLinkURLAtPoint(point)) - return FWL_WidgetHit::Unknown; - return FWL_WidgetHit::HyperLink; -} - -const wchar_t* CXFA_FFText::GetLinkURLAtPoint(const CFX_PointF& point) { - CXFA_TextLayout* pTextLayout = m_pDataAcc->GetTextLayout(); - if (!pTextLayout) - return nullptr; - - CFX_RectF rect = GetRectWithoutRotate(); - for (const auto& pPieceLine : *pTextLayout->GetPieceLines()) { - for (const auto& pPiece : pPieceLine->m_textPieces) { - if (pPiece->pLinkData && - pPiece->rtPiece.Contains(point - rect.TopLeft())) { - return pPiece->pLinkData->GetLinkURL(); - } - } - } - return nullptr; -} diff --git a/xfa/fxfa/app/xfa_fftext.h b/xfa/fxfa/app/xfa_fftext.h deleted file mode 100644 index eddc1224ac..0000000000 --- a/xfa/fxfa/app/xfa_fftext.h +++ /dev/null @@ -1,32 +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_APP_XFA_FFTEXT_H_ -#define XFA_FXFA_APP_XFA_FFTEXT_H_ - -#include "xfa/fxfa/app/xfa_ffdraw.h" - -class CXFA_FFText : public CXFA_FFDraw { - public: - explicit CXFA_FFText(CXFA_WidgetAcc* pDataAcc); - ~CXFA_FFText() override; - - // CXFA_FFWidget - bool OnLButtonDown(uint32_t dwFlags, const CFX_PointF& point) override; - bool OnLButtonUp(uint32_t dwFlags, const CFX_PointF& point) override; - bool OnMouseMove(uint32_t dwFlags, const CFX_PointF& point) override; - FWL_WidgetHit OnHitTest(const CFX_PointF& point) override; - void RenderWidget(CFX_Graphics* pGS, - CFX_Matrix* pMatrix, - uint32_t dwStatus) override; - bool IsLoaded() override; - bool PerformLayout() override; - - private: - const wchar_t* GetLinkURLAtPoint(const CFX_PointF& point); -}; - -#endif // XFA_FXFA_APP_XFA_FFTEXT_H_ diff --git a/xfa/fxfa/app/xfa_fftextedit.cpp b/xfa/fxfa/app/xfa_fftextedit.cpp deleted file mode 100644 index 41305efcc8..0000000000 --- a/xfa/fxfa/app/xfa_fftextedit.cpp +++ /dev/null @@ -1,706 +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/app/xfa_fftextedit.h" - -#include -#include - -#include "xfa/fwl/cfwl_datetimepicker.h" -#include "xfa/fwl/cfwl_edit.h" -#include "xfa/fwl/cfwl_eventcheckword.h" -#include "xfa/fwl/cfwl_eventselectchanged.h" -#include "xfa/fwl/cfwl_eventtextchanged.h" -#include "xfa/fwl/cfwl_eventvalidate.h" -#include "xfa/fwl/cfwl_messagekillfocus.h" -#include "xfa/fwl/cfwl_messagemouse.h" -#include "xfa/fwl/cfwl_messagesetfocus.h" -#include "xfa/fwl/cfwl_notedriver.h" -#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/cxfa_localevalue.h" -#include "xfa/fxfa/parser/cxfa_node.h" - -CXFA_FFTextEdit::CXFA_FFTextEdit(CXFA_WidgetAcc* pDataAcc) - : CXFA_FFField(pDataAcc), m_pOldDelegate(nullptr) {} - -CXFA_FFTextEdit::~CXFA_FFTextEdit() { - if (m_pNormalWidget) { - CFWL_NoteDriver* pNoteDriver = - m_pNormalWidget->GetOwnerApp()->GetNoteDriver(); - pNoteDriver->UnregisterEventTarget(m_pNormalWidget.get()); - } -} - -bool CXFA_FFTextEdit::LoadWidget() { - auto pNewWidget = pdfium::MakeUnique( - GetFWLApp(), pdfium::MakeUnique(), nullptr); - CFWL_Edit* pFWLEdit = pNewWidget.get(); - m_pNormalWidget = std::move(pNewWidget); - m_pNormalWidget->SetLayoutItem(this); - - CFWL_NoteDriver* pNoteDriver = - m_pNormalWidget->GetOwnerApp()->GetNoteDriver(); - pNoteDriver->RegisterEventTarget(m_pNormalWidget.get(), - m_pNormalWidget.get()); - m_pOldDelegate = m_pNormalWidget->GetDelegate(); - m_pNormalWidget->SetDelegate(this); - m_pNormalWidget->LockUpdate(); - UpdateWidgetProperty(); - - CFX_WideString wsText; - m_pDataAcc->GetValue(wsText, XFA_VALUEPICTURE_Display); - pFWLEdit->SetText(wsText); - m_pNormalWidget->UnlockUpdate(); - return CXFA_FFField::LoadWidget(); -} - -void CXFA_FFTextEdit::UpdateWidgetProperty() { - CFWL_Edit* pWidget = static_cast(m_pNormalWidget.get()); - if (!pWidget) - return; - - uint32_t dwStyle = 0; - uint32_t dwExtendedStyle = FWL_STYLEEXT_EDT_ShowScrollbarFocus | - FWL_STYLEEXT_EDT_OuterScrollbar | - FWL_STYLEEXT_EDT_LastLineHeight; - dwExtendedStyle |= UpdateUIProperty(); - if (m_pDataAcc->IsMultiLine()) { - dwExtendedStyle |= FWL_STYLEEXT_EDT_MultiLine | FWL_STYLEEXT_EDT_WantReturn; - if (m_pDataAcc->GetVerticalScrollPolicy() != XFA_ATTRIBUTEENUM_Off) { - dwStyle |= FWL_WGTSTYLE_VScroll; - dwExtendedStyle |= FWL_STYLEEXT_EDT_AutoVScroll; - } - } else if (m_pDataAcc->GetHorizontalScrollPolicy() != XFA_ATTRIBUTEENUM_Off) { - dwExtendedStyle |= FWL_STYLEEXT_EDT_AutoHScroll; - } - if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open || - !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) { - dwExtendedStyle |= FWL_STYLEEXT_EDT_ReadOnly; - dwExtendedStyle |= FWL_STYLEEXT_EDT_MultiLine; - } - - XFA_Element eType = XFA_Element::Unknown; - int32_t iMaxChars = m_pDataAcc->GetMaxChars(eType); - if (eType == XFA_Element::ExData) - iMaxChars = 0; - - int32_t iNumCells = m_pDataAcc->GetNumberOfCells(); - if (iNumCells == 0) { - dwExtendedStyle |= FWL_STYLEEXT_EDT_CombText; - pWidget->SetLimit(iMaxChars > 0 ? iMaxChars : 1); - } else if (iNumCells > 0) { - dwExtendedStyle |= FWL_STYLEEXT_EDT_CombText; - pWidget->SetLimit(iNumCells); - } else { - pWidget->SetLimit(iMaxChars); - } - dwExtendedStyle |= GetAlignment(); - m_pNormalWidget->ModifyStyles(dwStyle, 0xFFFFFFFF); - m_pNormalWidget->ModifyStylesEx(dwExtendedStyle, 0xFFFFFFFF); -} - -bool CXFA_FFTextEdit::OnLButtonDown(uint32_t dwFlags, const CFX_PointF& point) { - if (!PtInActiveRect(point)) - return false; - if (!IsFocused()) { - m_dwStatus |= XFA_WidgetStatus_Focused; - UpdateFWLData(); - AddInvalidateRect(); - } - - SetButtonDown(true); - CFWL_MessageMouse ms(nullptr, m_pNormalWidget.get()); - ms.m_dwCmd = FWL_MouseCommand::LeftButtonDown; - ms.m_dwFlags = dwFlags; - ms.m_pos = FWLToClient(point); - TranslateFWLMessage(&ms); - return true; -} - -bool CXFA_FFTextEdit::OnRButtonDown(uint32_t dwFlags, const CFX_PointF& point) { - if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open) - return false; - if (!PtInActiveRect(point)) - return false; - if (!IsFocused()) { - m_dwStatus |= XFA_WidgetStatus_Focused; - UpdateFWLData(); - AddInvalidateRect(); - } - - SetButtonDown(true); - CFWL_MessageMouse ms(nullptr, nullptr); - ms.m_dwCmd = FWL_MouseCommand::RightButtonDown; - ms.m_dwFlags = dwFlags; - ms.m_pos = FWLToClient(point); - TranslateFWLMessage(&ms); - return true; -} - -bool CXFA_FFTextEdit::OnRButtonUp(uint32_t dwFlags, const CFX_PointF& point) { - if (!CXFA_FFField::OnRButtonUp(dwFlags, point)) - return false; - - GetDoc()->GetDocEnvironment()->PopupMenu(this, point); - return true; -} - -bool CXFA_FFTextEdit::OnSetFocus(CXFA_FFWidget* pOldWidget) { - m_dwStatus &= ~XFA_WidgetStatus_TextEditValueChanged; - if (!IsFocused()) { - m_dwStatus |= XFA_WidgetStatus_Focused; - UpdateFWLData(); - AddInvalidateRect(); - } - CXFA_FFWidget::OnSetFocus(pOldWidget); - CFWL_MessageSetFocus ms(nullptr, m_pNormalWidget.get()); - TranslateFWLMessage(&ms); - return true; -} - -bool CXFA_FFTextEdit::OnKillFocus(CXFA_FFWidget* pNewWidget) { - CFWL_MessageKillFocus ms(nullptr, m_pNormalWidget.get()); - TranslateFWLMessage(&ms); - m_dwStatus &= ~XFA_WidgetStatus_Focused; - - SetEditScrollOffset(); - ProcessCommittedData(); - UpdateFWLData(); - AddInvalidateRect(); - CXFA_FFWidget::OnKillFocus(pNewWidget); - - m_dwStatus &= ~XFA_WidgetStatus_TextEditValueChanged; - return true; -} - -bool CXFA_FFTextEdit::CommitData() { - CFX_WideString wsText = - static_cast(m_pNormalWidget.get())->GetText(); - if (m_pDataAcc->SetValue(wsText, XFA_VALUEPICTURE_Edit)) { - m_pDataAcc->UpdateUIDisplay(this); - return true; - } - ValidateNumberField(wsText); - return false; -} - -void CXFA_FFTextEdit::ValidateNumberField(const CFX_WideString& wsText) { - CXFA_WidgetAcc* pAcc = GetDataAcc(); - if (!pAcc || pAcc->GetUIType() != XFA_Element::NumericEdit) - return; - - IXFA_AppProvider* pAppProvider = GetApp()->GetAppProvider(); - if (!pAppProvider) - return; - - CFX_WideString wsSomField; - pAcc->GetNode()->GetSOMExpression(wsSomField); - - CFX_WideString wsMessage; - wsMessage.Format(L"%s can not contain %s", wsText.c_str(), - wsSomField.c_str()); - pAppProvider->MsgBox(wsMessage, pAppProvider->GetAppTitle(), XFA_MBICON_Error, - XFA_MB_OK); -} - -bool CXFA_FFTextEdit::IsDataChanged() { - return (m_dwStatus & XFA_WidgetStatus_TextEditValueChanged) != 0; -} - -uint32_t CXFA_FFTextEdit::GetAlignment() { - CXFA_Para para = m_pDataAcc->GetPara(); - if (!para) - return 0; - - uint32_t dwExtendedStyle = 0; - switch (para.GetHorizontalAlign()) { - case XFA_ATTRIBUTEENUM_Center: - dwExtendedStyle |= FWL_STYLEEXT_EDT_HCenter; - break; - case XFA_ATTRIBUTEENUM_Justify: - dwExtendedStyle |= FWL_STYLEEXT_EDT_Justified; - break; - case XFA_ATTRIBUTEENUM_JustifyAll: - case XFA_ATTRIBUTEENUM_Radix: - break; - case XFA_ATTRIBUTEENUM_Right: - dwExtendedStyle |= FWL_STYLEEXT_EDT_HFar; - break; - default: - dwExtendedStyle |= FWL_STYLEEXT_EDT_HNear; - break; - } - - switch (para.GetVerticalAlign()) { - case XFA_ATTRIBUTEENUM_Middle: - dwExtendedStyle |= FWL_STYLEEXT_EDT_VCenter; - break; - case XFA_ATTRIBUTEENUM_Bottom: - dwExtendedStyle |= FWL_STYLEEXT_EDT_VFar; - break; - default: - dwExtendedStyle |= FWL_STYLEEXT_EDT_VNear; - break; - } - return dwExtendedStyle; -} - -bool CXFA_FFTextEdit::UpdateFWLData() { - if (!m_pNormalWidget) - return false; - - XFA_VALUEPICTURE eType = XFA_VALUEPICTURE_Display; - if (IsFocused()) - eType = XFA_VALUEPICTURE_Edit; - - bool bUpdate = false; - if (m_pDataAcc->GetUIType() == XFA_Element::TextEdit && - m_pDataAcc->GetNumberOfCells() < 0) { - XFA_Element elementType = XFA_Element::Unknown; - int32_t iMaxChars = m_pDataAcc->GetMaxChars(elementType); - if (elementType == XFA_Element::ExData) - iMaxChars = eType == XFA_VALUEPICTURE_Edit ? iMaxChars : 0; - if (static_cast(m_pNormalWidget.get())->GetLimit() != - iMaxChars) { - static_cast(m_pNormalWidget.get())->SetLimit(iMaxChars); - bUpdate = true; - } - } - - if (m_pDataAcc->GetUIType() == XFA_Element::Barcode) { - int32_t nDataLen = 0; - if (eType == XFA_VALUEPICTURE_Edit) - m_pDataAcc->GetBarcodeAttribute_DataLength(&nDataLen); - static_cast(m_pNormalWidget.get())->SetLimit(nDataLen); - bUpdate = true; - } - - CFX_WideString wsText; - m_pDataAcc->GetValue(wsText, eType); - - CFX_WideString wsOldText = - static_cast(m_pNormalWidget.get())->GetText(); - if (wsText != wsOldText || (eType == XFA_VALUEPICTURE_Edit && bUpdate)) { - static_cast(m_pNormalWidget.get())->SetText(wsText); - bUpdate = true; - } - if (bUpdate) - m_pNormalWidget->Update(); - - return true; -} - -void CXFA_FFTextEdit::OnTextChanged(CFWL_Widget* pWidget, - const CFX_WideString& wsChanged, - const CFX_WideString& wsPrevText) { - m_dwStatus |= XFA_WidgetStatus_TextEditValueChanged; - CXFA_EventParam eParam; - eParam.m_eType = XFA_EVENT_Change; - eParam.m_wsChange = wsChanged; - eParam.m_pTarget = m_pDataAcc.Get(); - eParam.m_wsPrevText = wsPrevText; - CFWL_Edit* pEdit = static_cast(m_pNormalWidget.get()); - if (m_pDataAcc->GetUIType() == XFA_Element::DateTimeEdit) { - CFWL_DateTimePicker* pDateTime = (CFWL_DateTimePicker*)pEdit; - eParam.m_wsNewText = pDateTime->GetEditText(); - int32_t iSels = pDateTime->CountSelRanges(); - if (iSels) - eParam.m_iSelEnd = pDateTime->GetSelRange(0, &eParam.m_iSelStart); - } else { - eParam.m_wsNewText = pEdit->GetText(); - int32_t iSels = pEdit->CountSelRanges(); - if (iSels) - eParam.m_iSelEnd = pEdit->GetSelRange(0, &eParam.m_iSelStart); - } - m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Change, &eParam); -} - -void CXFA_FFTextEdit::OnTextFull(CFWL_Widget* pWidget) { - CXFA_EventParam eParam; - eParam.m_eType = XFA_EVENT_Full; - eParam.m_pTarget = m_pDataAcc.Get(); - m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Full, &eParam); -} - -bool CXFA_FFTextEdit::CheckWord(const CFX_ByteStringC& sWord) { - if (sWord.IsEmpty() || m_pDataAcc->GetUIType() != XFA_Element::TextEdit) - return true; - return false; -} - -void CXFA_FFTextEdit::OnProcessMessage(CFWL_Message* pMessage) { - m_pOldDelegate->OnProcessMessage(pMessage); -} - -void CXFA_FFTextEdit::OnProcessEvent(CFWL_Event* pEvent) { - CXFA_FFField::OnProcessEvent(pEvent); - switch (pEvent->GetType()) { - case CFWL_Event::Type::TextChanged: { - CFWL_EventTextChanged* event = - static_cast(pEvent); - CFX_WideString wsChange; - OnTextChanged(m_pNormalWidget.get(), wsChange, event->wsPrevText); - break; - } - case CFWL_Event::Type::TextFull: { - OnTextFull(m_pNormalWidget.get()); - break; - } - case CFWL_Event::Type::CheckWord: { - CFX_WideString wstr(L"FWL_EVENT_DTP_SelectChanged"); - CFWL_EventCheckWord* event = static_cast(pEvent); - event->bCheckWord = CheckWord(event->bsWord.AsStringC()); - break; - } - default: - break; - } - m_pOldDelegate->OnProcessEvent(pEvent); -} - -void CXFA_FFTextEdit::OnDrawWidget(CFX_Graphics* pGraphics, - const CFX_Matrix* pMatrix) { - m_pOldDelegate->OnDrawWidget(pGraphics, pMatrix); -} - -CXFA_FFNumericEdit::CXFA_FFNumericEdit(CXFA_WidgetAcc* pDataAcc) - : CXFA_FFTextEdit(pDataAcc) {} - -CXFA_FFNumericEdit::~CXFA_FFNumericEdit() {} - -bool CXFA_FFNumericEdit::LoadWidget() { - auto pNewEdit = pdfium::MakeUnique( - GetFWLApp(), pdfium::MakeUnique(), nullptr); - CFWL_Edit* pWidget = pNewEdit.get(); - m_pNormalWidget = std::move(pNewEdit); - m_pNormalWidget->SetLayoutItem(this); - - CFWL_NoteDriver* pNoteDriver = - m_pNormalWidget->GetOwnerApp()->GetNoteDriver(); - pNoteDriver->RegisterEventTarget(m_pNormalWidget.get(), - m_pNormalWidget.get()); - m_pOldDelegate = m_pNormalWidget->GetDelegate(); - m_pNormalWidget->SetDelegate(this); - m_pNormalWidget->LockUpdate(); - - CFX_WideString wsText; - m_pDataAcc->GetValue(wsText, XFA_VALUEPICTURE_Display); - pWidget->SetText(wsText); - UpdateWidgetProperty(); - m_pNormalWidget->UnlockUpdate(); - return CXFA_FFField::LoadWidget(); -} - -void CXFA_FFNumericEdit::UpdateWidgetProperty() { - CFWL_Edit* pWidget = static_cast(m_pNormalWidget.get()); - if (!pWidget) - return; - - uint32_t dwExtendedStyle = - FWL_STYLEEXT_EDT_ShowScrollbarFocus | FWL_STYLEEXT_EDT_OuterScrollbar | - FWL_STYLEEXT_EDT_Validate | FWL_STYLEEXT_EDT_Number | - FWL_STYLEEXT_EDT_LastLineHeight; - dwExtendedStyle |= UpdateUIProperty(); - if (m_pDataAcc->GetHorizontalScrollPolicy() != XFA_ATTRIBUTEENUM_Off) - dwExtendedStyle |= FWL_STYLEEXT_EDT_AutoHScroll; - - int32_t iNumCells = m_pDataAcc->GetNumberOfCells(); - if (iNumCells > 0) { - dwExtendedStyle |= FWL_STYLEEXT_EDT_CombText; - pWidget->SetLimit(iNumCells); - } - dwExtendedStyle |= GetAlignment(); - if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open || - !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) { - dwExtendedStyle |= FWL_STYLEEXT_EDT_ReadOnly; - } - m_pNormalWidget->ModifyStylesEx(dwExtendedStyle, 0xFFFFFFFF); -} - -void CXFA_FFNumericEdit::OnProcessEvent(CFWL_Event* pEvent) { - if (pEvent->GetType() == CFWL_Event::Type::Validate) { - CFWL_EventValidate* event = static_cast(pEvent); - event->bValidate = OnValidate(m_pNormalWidget.get(), event->wsInsert); - return; - } - CXFA_FFTextEdit::OnProcessEvent(pEvent); -} - -bool CXFA_FFNumericEdit::OnValidate(CFWL_Widget* pWidget, - CFX_WideString& wsText) { - CFX_WideString wsPattern; - m_pDataAcc->GetPictureContent(wsPattern, XFA_VALUEPICTURE_Edit); - if (!wsPattern.IsEmpty()) - return true; - - int32_t iLeads = 0; - m_pDataAcc->GetLeadDigits(iLeads); - - int32_t iFracs = 0; - m_pDataAcc->GetFracDigits(iFracs); - - CFX_WideString wsFormat; - CXFA_LocaleValue widgetValue = XFA_GetLocaleValue(m_pDataAcc.Get()); - widgetValue.GetNumbericFormat(wsFormat, iLeads, iFracs); - return widgetValue.ValidateNumericTemp(wsText, wsFormat, - m_pDataAcc->GetLocal()); -} - -CXFA_FFPasswordEdit::CXFA_FFPasswordEdit(CXFA_WidgetAcc* pDataAcc) - : CXFA_FFTextEdit(pDataAcc) {} - -CXFA_FFPasswordEdit::~CXFA_FFPasswordEdit() {} - -bool CXFA_FFPasswordEdit::LoadWidget() { - auto pNewEdit = pdfium::MakeUnique( - GetFWLApp(), pdfium::MakeUnique(), nullptr); - CFWL_Edit* pWidget = pNewEdit.get(); - m_pNormalWidget = std::move(pNewEdit); - m_pNormalWidget->SetLayoutItem(this); - - CFWL_NoteDriver* pNoteDriver = - m_pNormalWidget->GetOwnerApp()->GetNoteDriver(); - pNoteDriver->RegisterEventTarget(m_pNormalWidget.get(), - m_pNormalWidget.get()); - m_pOldDelegate = m_pNormalWidget->GetDelegate(); - m_pNormalWidget->SetDelegate(this); - m_pNormalWidget->LockUpdate(); - - CFX_WideString wsText; - m_pDataAcc->GetValue(wsText, XFA_VALUEPICTURE_Display); - pWidget->SetText(wsText); - UpdateWidgetProperty(); - m_pNormalWidget->UnlockUpdate(); - return CXFA_FFField::LoadWidget(); -} - -void CXFA_FFPasswordEdit::UpdateWidgetProperty() { - CFWL_Edit* pWidget = static_cast(m_pNormalWidget.get()); - if (!pWidget) - return; - - uint32_t dwExtendedStyle = - FWL_STYLEEXT_EDT_ShowScrollbarFocus | FWL_STYLEEXT_EDT_OuterScrollbar | - FWL_STYLEEXT_EDT_Password | FWL_STYLEEXT_EDT_LastLineHeight; - dwExtendedStyle |= UpdateUIProperty(); - - CFX_WideString wsPassWord; - m_pDataAcc->GetPasswordChar(wsPassWord); - if (!wsPassWord.IsEmpty()) - pWidget->SetAliasChar(wsPassWord.GetAt(0)); - if (m_pDataAcc->GetHorizontalScrollPolicy() != XFA_ATTRIBUTEENUM_Off) - dwExtendedStyle |= FWL_STYLEEXT_EDT_AutoHScroll; - if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open || - !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) { - dwExtendedStyle |= FWL_STYLEEXT_EDT_ReadOnly; - } - dwExtendedStyle |= GetAlignment(); - m_pNormalWidget->ModifyStylesEx(dwExtendedStyle, 0xFFFFFFFF); -} - -CXFA_FFDateTimeEdit::CXFA_FFDateTimeEdit(CXFA_WidgetAcc* pDataAcc) - : CXFA_FFTextEdit(pDataAcc) {} - -CXFA_FFDateTimeEdit::~CXFA_FFDateTimeEdit() {} - -CFX_RectF CXFA_FFDateTimeEdit::GetBBox(uint32_t dwStatus, bool bDrawFocus) { - if (bDrawFocus) - return CFX_RectF(); - return CXFA_FFWidget::GetBBox(dwStatus); -} - -bool CXFA_FFDateTimeEdit::PtInActiveRect(const CFX_PointF& point) { - auto* pPicker = static_cast(m_pNormalWidget.get()); - return pPicker && pPicker->GetBBox().Contains(point); -} - -bool CXFA_FFDateTimeEdit::LoadWidget() { - auto pNewPicker = pdfium::MakeUnique(GetFWLApp()); - CFWL_DateTimePicker* pWidget = pNewPicker.get(); - m_pNormalWidget = std::move(pNewPicker); - m_pNormalWidget->SetLayoutItem(this); - - CFWL_NoteDriver* pNoteDriver = - m_pNormalWidget->GetOwnerApp()->GetNoteDriver(); - pNoteDriver->RegisterEventTarget(m_pNormalWidget.get(), - m_pNormalWidget.get()); - m_pOldDelegate = m_pNormalWidget->GetDelegate(); - m_pNormalWidget->SetDelegate(this); - m_pNormalWidget->LockUpdate(); - - CFX_WideString wsText; - m_pDataAcc->GetValue(wsText, XFA_VALUEPICTURE_Display); - pWidget->SetEditText(wsText); - if (CXFA_Value value = m_pDataAcc->GetFormValue()) { - switch (value.GetChildValueClassID()) { - case XFA_Element::Date: { - if (!wsText.IsEmpty()) { - CXFA_LocaleValue lcValue = XFA_GetLocaleValue(m_pDataAcc.Get()); - CFX_DateTime date = lcValue.GetDate(); - if (date.IsSet()) - pWidget->SetCurSel(date.GetYear(), date.GetMonth(), date.GetDay()); - } - } break; - default: - break; - } - } - UpdateWidgetProperty(); - m_pNormalWidget->UnlockUpdate(); - return CXFA_FFField::LoadWidget(); -} - -void CXFA_FFDateTimeEdit::UpdateWidgetProperty() { - CFWL_DateTimePicker* pWidget = - static_cast(m_pNormalWidget.get()); - if (!pWidget) - return; - - uint32_t dwExtendedStyle = FWL_STYLEEXT_DTP_ShortDateFormat; - dwExtendedStyle |= UpdateUIProperty(); - dwExtendedStyle |= GetAlignment(); - m_pNormalWidget->ModifyStylesEx(dwExtendedStyle, 0xFFFFFFFF); - uint32_t dwEditStyles = FWL_STYLEEXT_EDT_LastLineHeight; - int32_t iNumCells = m_pDataAcc->GetNumberOfCells(); - if (iNumCells > 0) { - dwEditStyles |= FWL_STYLEEXT_EDT_CombText; - pWidget->SetEditLimit(iNumCells); - } - if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open || - !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) { - dwEditStyles |= FWL_STYLEEXT_EDT_ReadOnly; - } - if (m_pDataAcc->GetHorizontalScrollPolicy() != XFA_ATTRIBUTEENUM_Off) - dwEditStyles |= FWL_STYLEEXT_EDT_AutoHScroll; - - pWidget->ModifyEditStylesEx(dwEditStyles, 0xFFFFFFFF); -} - -uint32_t CXFA_FFDateTimeEdit::GetAlignment() { - CXFA_Para para = m_pDataAcc->GetPara(); - if (!para) - return 0; - - uint32_t dwExtendedStyle = 0; - switch (para.GetHorizontalAlign()) { - case XFA_ATTRIBUTEENUM_Center: - dwExtendedStyle |= FWL_STYLEEXT_DTP_EditHCenter; - break; - case XFA_ATTRIBUTEENUM_Justify: - dwExtendedStyle |= FWL_STYLEEXT_DTP_EditJustified; - break; - case XFA_ATTRIBUTEENUM_JustifyAll: - case XFA_ATTRIBUTEENUM_Radix: - break; - case XFA_ATTRIBUTEENUM_Right: - dwExtendedStyle |= FWL_STYLEEXT_DTP_EditHFar; - break; - default: - dwExtendedStyle |= FWL_STYLEEXT_DTP_EditHNear; - break; - } - - switch (para.GetVerticalAlign()) { - case XFA_ATTRIBUTEENUM_Middle: - dwExtendedStyle |= FWL_STYLEEXT_DTP_EditVCenter; - break; - case XFA_ATTRIBUTEENUM_Bottom: - dwExtendedStyle |= FWL_STYLEEXT_DTP_EditVFar; - break; - default: - dwExtendedStyle |= FWL_STYLEEXT_DTP_EditVNear; - break; - } - return dwExtendedStyle; -} - -bool CXFA_FFDateTimeEdit::CommitData() { - auto* pPicker = static_cast(m_pNormalWidget.get()); - if (!m_pDataAcc->SetValue(pPicker->GetEditText(), XFA_VALUEPICTURE_Edit)) - return false; - - m_pDataAcc->UpdateUIDisplay(this); - return true; -} - -bool CXFA_FFDateTimeEdit::UpdateFWLData() { - if (!m_pNormalWidget) - return false; - - XFA_VALUEPICTURE eType = XFA_VALUEPICTURE_Display; - if (IsFocused()) - eType = XFA_VALUEPICTURE_Edit; - - CFX_WideString wsText; - m_pDataAcc->GetValue(wsText, eType); - - auto* normalWidget = static_cast(m_pNormalWidget.get()); - normalWidget->SetEditText(wsText); - if (IsFocused() && !wsText.IsEmpty()) { - CXFA_LocaleValue lcValue = XFA_GetLocaleValue(m_pDataAcc.Get()); - CFX_DateTime date = lcValue.GetDate(); - if (lcValue.IsValid()) { - if (date.IsSet()) - normalWidget->SetCurSel(date.GetYear(), date.GetMonth(), date.GetDay()); - } - } - m_pNormalWidget->Update(); - return true; -} - -bool CXFA_FFDateTimeEdit::IsDataChanged() { - if (m_dwStatus & XFA_WidgetStatus_TextEditValueChanged) - return true; - - CFX_WideString wsText = - static_cast(m_pNormalWidget.get())->GetEditText(); - CFX_WideString wsOldValue; - m_pDataAcc->GetValue(wsOldValue, XFA_VALUEPICTURE_Edit); - return wsOldValue != wsText; -} - -void CXFA_FFDateTimeEdit::OnSelectChanged(CFWL_Widget* pWidget, - int32_t iYear, - int32_t iMonth, - int32_t iDay) { - CFX_WideString wsPicture; - m_pDataAcc->GetPictureContent(wsPicture, XFA_VALUEPICTURE_Edit); - - CXFA_LocaleValue date(XFA_VT_DATE, GetDoc()->GetXFADoc()->GetLocalMgr()); - date.SetDate(CFX_DateTime(iYear, iMonth, iDay, 0, 0, 0, 0)); - - CFX_WideString wsDate; - date.FormatPatterns(wsDate, wsPicture, m_pDataAcc->GetLocal(), - XFA_VALUEPICTURE_Edit); - - auto* pDateTime = static_cast(m_pNormalWidget.get()); - pDateTime->SetEditText(wsDate); - pDateTime->Update(); - GetDoc()->GetDocEnvironment()->SetFocusWidget(GetDoc(), nullptr); - - CXFA_EventParam eParam; - eParam.m_eType = XFA_EVENT_Change; - eParam.m_pTarget = m_pDataAcc.Get(); - m_pDataAcc->GetValue(eParam.m_wsNewText, XFA_VALUEPICTURE_Raw); - m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Change, &eParam); -} - -void CXFA_FFDateTimeEdit::OnProcessEvent(CFWL_Event* pEvent) { - if (pEvent->GetType() == CFWL_Event::Type::SelectChanged) { - auto* event = static_cast(pEvent); - OnSelectChanged(m_pNormalWidget.get(), event->iYear, event->iMonth, - event->iDay); - return; - } - CXFA_FFTextEdit::OnProcessEvent(pEvent); -} diff --git a/xfa/fxfa/app/xfa_fftextedit.h b/xfa/fxfa/app/xfa_fftextedit.h deleted file mode 100644 index 9b9324f9d2..0000000000 --- a/xfa/fxfa/app/xfa_fftextedit.h +++ /dev/null @@ -1,105 +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_APP_XFA_FFTEXTEDIT_H_ -#define XFA_FXFA_APP_XFA_FFTEXTEDIT_H_ - -#include - -#include "xfa/fxfa/app/xfa_fffield.h" - -class CXFA_FFTextEdit : public CXFA_FFField { - public: - explicit CXFA_FFTextEdit(CXFA_WidgetAcc* pDataAcc); - ~CXFA_FFTextEdit() override; - - // CXFA_FFField - bool LoadWidget() override; - void UpdateWidgetProperty() override; - bool OnLButtonDown(uint32_t dwFlags, const CFX_PointF& point) override; - bool OnRButtonDown(uint32_t dwFlags, const CFX_PointF& point) override; - bool OnRButtonUp(uint32_t dwFlags, const CFX_PointF& point) override; - bool OnSetFocus(CXFA_FFWidget* pOldWidget) override; - bool OnKillFocus(CXFA_FFWidget* pNewWidget) override; - void OnProcessMessage(CFWL_Message* pMessage) override; - void OnProcessEvent(CFWL_Event* pEvent) override; - void OnDrawWidget(CFX_Graphics* pGraphics, - const CFX_Matrix* pMatrix = nullptr) override; - - void OnTextChanged(CFWL_Widget* pWidget, - const CFX_WideString& wsChanged, - const CFX_WideString& wsPrevText); - void OnTextFull(CFWL_Widget* pWidget); - bool CheckWord(const CFX_ByteStringC& sWord); - - protected: - uint32_t GetAlignment(); - - IFWL_WidgetDelegate* m_pOldDelegate; - - private: - bool CommitData() override; - bool UpdateFWLData() override; - bool IsDataChanged() override; - void ValidateNumberField(const CFX_WideString& wsText); -}; - -class CXFA_FFNumericEdit : public CXFA_FFTextEdit { - public: - explicit CXFA_FFNumericEdit(CXFA_WidgetAcc* pDataAcc); - ~CXFA_FFNumericEdit() override; - - // CXFA_FFTextEdit - bool LoadWidget() override; - void UpdateWidgetProperty() override; - void OnProcessEvent(CFWL_Event* pEvent) override; - - private: - bool OnValidate(CFWL_Widget* pWidget, CFX_WideString& wsText); -}; - -class CXFA_FFPasswordEdit : public CXFA_FFTextEdit { - public: - explicit CXFA_FFPasswordEdit(CXFA_WidgetAcc* pDataAcc); - ~CXFA_FFPasswordEdit() override; - - // CXFA_FFTextEdit - bool LoadWidget() override; - void UpdateWidgetProperty() override; -}; - -enum XFA_DATETIMETYPE { - XFA_DATETIMETYPE_Date = 0, - XFA_DATETIMETYPE_Time, - XFA_DATETIMETYPE_DateAndTime -}; - -class CXFA_FFDateTimeEdit : public CXFA_FFTextEdit { - public: - explicit CXFA_FFDateTimeEdit(CXFA_WidgetAcc* pDataAcc); - ~CXFA_FFDateTimeEdit() override; - - // CXFA_FFTextEdit - CFX_RectF GetBBox(uint32_t dwStatus, bool bDrawFocus = false) override; - bool LoadWidget() override; - void UpdateWidgetProperty() override; - void OnProcessEvent(CFWL_Event* pEvent) override; - - void OnSelectChanged(CFWL_Widget* pWidget, - int32_t iYear, - int32_t iMonth, - int32_t iDay); - - private: - bool PtInActiveRect(const CFX_PointF& point) override; - bool CommitData() override; - bool UpdateFWLData() override; - bool IsDataChanged() override; - - uint32_t GetAlignment(); -}; - -#endif // XFA_FXFA_APP_XFA_FFTEXTEDIT_H_ diff --git a/xfa/fxfa/app/xfa_ffwidgetacc.cpp b/xfa/fxfa/app/xfa_ffwidgetacc.cpp deleted file mode 100644 index 2ac27cfdc8..0000000000 --- a/xfa/fxfa/app/xfa_ffwidgetacc.cpp +++ /dev/null @@ -1,167 +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/app/xfa_ffwidgetacc.h" - -#include -#include -#include - -#include "core/fxcrt/xml/cfx_xmlelement.h" -#include "core/fxcrt/xml/cfx_xmlnode.h" -#include "fxjs/cfxjse_value.h" -#include "third_party/base/ptr_util.h" -#include "third_party/base/stl_util.h" -#include "xfa/fde/cfde_textout.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_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_localevalue.h" -#include "xfa/fxfa/parser/cxfa_node.h" -#include "xfa/fxfa/parser/cxfa_scriptcontext.h" -#include "xfa/fxfa/parser/xfa_resolvenode_rs.h" - -CXFA_Node* CXFA_TextProvider::GetTextNode(bool& bRichText) { - bRichText = false; - - if (m_eType == XFA_TEXTPROVIDERTYPE_Text) { - CXFA_Node* pElementNode = m_pWidgetAcc->GetNode(); - CXFA_Node* pValueNode = pElementNode->GetChild(0, XFA_Element::Value); - if (!pValueNode) - return nullptr; - - CXFA_Node* pChildNode = pValueNode->GetNodeItem(XFA_NODEITEM_FirstChild); - if (pChildNode && pChildNode->GetElementType() == XFA_Element::ExData) { - CFX_WideString wsContentType; - pChildNode->GetAttribute(XFA_ATTRIBUTE_ContentType, wsContentType, false); - if (wsContentType == L"text/html") - bRichText = true; - } - return pChildNode; - } - - if (m_eType == XFA_TEXTPROVIDERTYPE_Datasets) { - CXFA_Node* pBind = m_pWidgetAcc->GetDatasets(); - CFX_XMLNode* pXMLNode = pBind->GetXMLMappingNode(); - ASSERT(pXMLNode); - for (CFX_XMLNode* pXMLChild = - pXMLNode->GetNodeItem(CFX_XMLNode::FirstChild); - pXMLChild; - pXMLChild = pXMLChild->GetNodeItem(CFX_XMLNode::NextSibling)) { - if (pXMLChild->GetType() == FX_XMLNODE_Element) { - CFX_XMLElement* pElement = static_cast(pXMLChild); - if (XFA_RecognizeRichText(pElement)) - bRichText = true; - } - } - return pBind; - } - - if (m_eType == XFA_TEXTPROVIDERTYPE_Caption) { - CXFA_Node* pCaptionNode = - m_pWidgetAcc->GetNode()->GetChild(0, XFA_Element::Caption); - if (!pCaptionNode) - return nullptr; - - CXFA_Node* pValueNode = pCaptionNode->GetChild(0, XFA_Element::Value); - if (!pValueNode) - return nullptr; - - CXFA_Node* pChildNode = pValueNode->GetNodeItem(XFA_NODEITEM_FirstChild); - if (pChildNode && pChildNode->GetElementType() == XFA_Element::ExData) { - CFX_WideString wsContentType; - pChildNode->GetAttribute(XFA_ATTRIBUTE_ContentType, wsContentType, false); - if (wsContentType == L"text/html") - bRichText = true; - } - return pChildNode; - } - - CXFA_Node* pItemNode = - m_pWidgetAcc->GetNode()->GetChild(0, XFA_Element::Items); - if (!pItemNode) - return nullptr; - - CXFA_Node* pNode = pItemNode->GetNodeItem(XFA_NODEITEM_FirstChild); - while (pNode) { - CFX_WideStringC wsName; - pNode->TryCData(XFA_ATTRIBUTE_Name, wsName); - if (m_eType == XFA_TEXTPROVIDERTYPE_Rollover && wsName == L"rollover") - return pNode; - if (m_eType == XFA_TEXTPROVIDERTYPE_Down && wsName == L"down") - return pNode; - - pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling); - } - return nullptr; -} - -CXFA_Para CXFA_TextProvider::GetParaNode() { - if (m_eType == XFA_TEXTPROVIDERTYPE_Text) - return m_pWidgetAcc->GetPara(); - - CXFA_Node* pNode = m_pWidgetAcc->GetNode()->GetChild(0, XFA_Element::Caption); - return CXFA_Para(pNode->GetChild(0, XFA_Element::Para)); -} - -CXFA_Font CXFA_TextProvider::GetFontNode() { - if (m_eType == XFA_TEXTPROVIDERTYPE_Text) - return m_pWidgetAcc->GetFont(false); - - CXFA_Node* pNode = m_pWidgetAcc->GetNode()->GetChild(0, XFA_Element::Caption); - pNode = pNode->GetChild(0, XFA_Element::Font); - return pNode ? CXFA_Font(pNode) : m_pWidgetAcc->GetFont(false); -} - -bool CXFA_TextProvider::IsCheckButtonAndAutoWidth() { - XFA_Element eType = m_pWidgetAcc->GetUIType(); - if (eType != XFA_Element::CheckButton) - return false; - - float fWidth = 0; - return !m_pWidgetAcc->GetWidth(fWidth); -} - -bool CXFA_TextProvider::GetEmbbedObj(bool bURI, - bool bRaw, - const CFX_WideString& wsAttr, - CFX_WideString& wsValue) { - if (m_eType != XFA_TEXTPROVIDERTYPE_Text) - return false; - - if (!bURI) - return false; - - CXFA_Node* pWidgetNode = m_pWidgetAcc->GetNode(); - CXFA_Node* pParent = pWidgetNode->GetNodeItem(XFA_NODEITEM_Parent); - CXFA_Document* pDocument = pWidgetNode->GetDocument(); - CXFA_Node* pIDNode = nullptr; - CXFA_WidgetAcc* pEmbAcc = nullptr; - if (pParent) - pIDNode = pDocument->GetNodeByID(pParent, wsAttr.AsStringC()); - - if (!pIDNode) { - pIDNode = pDocument->GetNodeByID( - ToNode(pDocument->GetXFAObject(XFA_HASHCODE_Form)), wsAttr.AsStringC()); - } - if (pIDNode) - pEmbAcc = static_cast(pIDNode->GetWidgetData()); - - if (!pEmbAcc) - return false; - - pEmbAcc->GetValue(wsValue, XFA_VALUEPICTURE_Display); - return true; -} diff --git a/xfa/fxfa/app/xfa_ffwidgetacc.h b/xfa/fxfa/app/xfa_ffwidgetacc.h deleted file mode 100644 index 7840186b14..0000000000 --- a/xfa/fxfa/app/xfa_ffwidgetacc.h +++ /dev/null @@ -1,50 +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_APP_XFA_FFWIDGETACC_H_ -#define XFA_FXFA_APP_XFA_FFWIDGETACC_H_ - -#include "core/fxcrt/fx_string.h" -#include "xfa/fxfa/app/cxfa_textlayout.h" -#include "xfa/fxfa/cxfa_widgetacc.h" -#include "xfa/fxfa/parser/cxfa_font.h" -#include "xfa/fxfa/parser/cxfa_para.h" - -class CXFA_FFDoc; -class CXFA_Node; - -enum XFA_TEXTPROVIDERTYPE { - XFA_TEXTPROVIDERTYPE_Text, - XFA_TEXTPROVIDERTYPE_Datasets, - XFA_TEXTPROVIDERTYPE_Caption, - XFA_TEXTPROVIDERTYPE_Rollover, - XFA_TEXTPROVIDERTYPE_Down, -}; - -class CXFA_TextProvider { - public: - CXFA_TextProvider(CXFA_WidgetAcc* pWidgetAcc, XFA_TEXTPROVIDERTYPE eType) - : m_pWidgetAcc(pWidgetAcc), m_eType(eType) { - ASSERT(m_pWidgetAcc); - } - ~CXFA_TextProvider() {} - - CXFA_Node* GetTextNode(bool& bRichText); - CXFA_Para GetParaNode(); - CXFA_Font GetFontNode(); - bool IsCheckButtonAndAutoWidth(); - CXFA_FFDoc* GetDocNode() { return m_pWidgetAcc->GetDoc(); } - bool GetEmbbedObj(bool bURI, - bool bRaw, - const CFX_WideString& wsAttr, - CFX_WideString& wsValue); - - private: - CXFA_WidgetAcc* m_pWidgetAcc; - XFA_TEXTPROVIDERTYPE m_eType; -}; - -#endif // XFA_FXFA_APP_XFA_FFWIDGETACC_H_ diff --git a/xfa/fxfa/app/xfa_fwladapter.cpp b/xfa/fxfa/app/xfa_fwladapter.cpp deleted file mode 100644 index 3cf6e5e8fd..0000000000 --- a/xfa/fxfa/app/xfa_fwladapter.cpp +++ /dev/null @@ -1,38 +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/app/xfa_fwladapter.h" - -#include "xfa/fxfa/app/xfa_fffield.h" -#include "xfa/fxfa/cxfa_ffdoc.h" - -CXFA_FWLAdapterWidgetMgr::CXFA_FWLAdapterWidgetMgr() {} - -CXFA_FWLAdapterWidgetMgr::~CXFA_FWLAdapterWidgetMgr() {} - -void CXFA_FWLAdapterWidgetMgr::RepaintWidget(CFWL_Widget* pWidget) { - if (!pWidget) - return; - - CXFA_FFWidget* pFFWidget = pWidget->GetLayoutItem(); - if (!pFFWidget) - return; - - pFFWidget->AddInvalidateRect(nullptr); -} - -bool CXFA_FWLAdapterWidgetMgr::GetPopupPos(CFWL_Widget* pWidget, - float fMinHeight, - float fMaxHeight, - const CFX_RectF& rtAnchor, - CFX_RectF& rtPopup) { - CXFA_FFWidget* pFFWidget = pWidget->GetLayoutItem(); - CFX_RectF rtRotateAnchor(rtAnchor); - pFFWidget->GetRotateMatrix().TransformRect(rtRotateAnchor); - pFFWidget->GetDoc()->GetDocEnvironment()->GetPopupPos( - pFFWidget, fMinHeight, fMaxHeight, rtRotateAnchor, rtPopup); - return true; -} diff --git a/xfa/fxfa/app/xfa_fwladapter.h b/xfa/fxfa/app/xfa_fwladapter.h deleted file mode 100644 index b4a3481588..0000000000 --- a/xfa/fxfa/app/xfa_fwladapter.h +++ /dev/null @@ -1,28 +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_APP_XFA_FWLADAPTER_H_ -#define XFA_FXFA_APP_XFA_FWLADAPTER_H_ - -#include "core/fxcrt/fx_coordinates.h" -#include "core/fxcrt/fx_system.h" - -class CFWL_Widget; - -class CXFA_FWLAdapterWidgetMgr { - public: - CXFA_FWLAdapterWidgetMgr(); - ~CXFA_FWLAdapterWidgetMgr(); - - void RepaintWidget(CFWL_Widget* pWidget); - bool GetPopupPos(CFWL_Widget* pWidget, - float fMinHeight, - float fMaxHeight, - const CFX_RectF& rtAnchor, - CFX_RectF& rtPopup); -}; - -#endif // XFA_FXFA_APP_XFA_FWLADAPTER_H_ diff --git a/xfa/fxfa/app/xfa_fwltheme.cpp b/xfa/fxfa/app/xfa_fwltheme.cpp deleted file mode 100644 index 9af45e62df..0000000000 --- a/xfa/fxfa/app/xfa_fwltheme.cpp +++ /dev/null @@ -1,284 +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/app/xfa_fwltheme.h" - -#include "core/fxcrt/fx_codepage.h" -#include "xfa/fde/cfde_textout.h" -#include "xfa/fgas/font/cfgas_gefont.h" -#include "xfa/fwl/cfwl_barcode.h" -#include "xfa/fwl/cfwl_caret.h" -#include "xfa/fwl/cfwl_checkbox.h" -#include "xfa/fwl/cfwl_combobox.h" -#include "xfa/fwl/cfwl_datetimepicker.h" -#include "xfa/fwl/cfwl_edit.h" -#include "xfa/fwl/cfwl_listbox.h" -#include "xfa/fwl/cfwl_monthcalendar.h" -#include "xfa/fwl/cfwl_picturebox.h" -#include "xfa/fwl/cfwl_pushbutton.h" -#include "xfa/fwl/cfwl_scrollbar.h" -#include "xfa/fwl/cfwl_themebackground.h" -#include "xfa/fwl/cfwl_themetext.h" -#include "xfa/fxfa/cxfa_ffapp.h" -#include "xfa/fxfa/cxfa_ffwidget.h" -#include "xfa/fxgraphics/cfx_color.h" - -namespace { - -const wchar_t* const g_FWLTheme_CalFonts[] = { - L"Arial", L"Courier New", L"DejaVu Sans", -}; - -const float kLineHeight = 12.0f; - -} // namespace - -CXFA_FFWidget* XFA_ThemeGetOuterWidget(CFWL_Widget* pWidget) { - CFWL_Widget* pOuter = pWidget; - while (pOuter && pOuter->GetOuter()) - pOuter = pOuter->GetOuter(); - return pOuter ? pOuter->GetLayoutItem() : nullptr; -} - -CXFA_FWLTheme::CXFA_FWLTheme(CXFA_FFApp* pApp) - : m_pCheckBoxTP(pdfium::MakeUnique()), - m_pListBoxTP(pdfium::MakeUnique()), - m_pPictureBoxTP(pdfium::MakeUnique()), - m_pSrollBarTP(pdfium::MakeUnique()), - m_pEditTP(pdfium::MakeUnique()), - m_pComboBoxTP(pdfium::MakeUnique()), - m_pMonthCalendarTP(pdfium::MakeUnique()), - m_pDateTimePickerTP(pdfium::MakeUnique()), - m_pPushButtonTP(pdfium::MakeUnique()), - m_pCaretTP(pdfium::MakeUnique()), - m_pBarcodeTP(pdfium::MakeUnique()), - m_pTextOut(pdfium::MakeUnique()), - m_pCalendarFont(nullptr), - m_pApp(pApp) { - m_Rect.Reset(); - - for (size_t i = 0; !m_pCalendarFont && i < FX_ArraySize(g_FWLTheme_CalFonts); - ++i) { - m_pCalendarFont = CFGAS_GEFont::LoadFont(g_FWLTheme_CalFonts[i], 0, 0, - m_pApp->GetFDEFontMgr()); - } - if (!m_pCalendarFont) { - m_pCalendarFont = m_pApp->GetFDEFontMgr()->GetFontByCodePage( - FX_CODEPAGE_MSWin_WesternEuropean, 0, nullptr); - } - - ASSERT(m_pCalendarFont); -} - -CXFA_FWLTheme::~CXFA_FWLTheme() { - m_pTextOut.reset(); - FWLTHEME_Release(); -} - -void CXFA_FWLTheme::DrawBackground(CFWL_ThemeBackground* pParams) { - GetTheme(pParams->m_pWidget)->DrawBackground(pParams); -} - -void CXFA_FWLTheme::DrawText(CFWL_ThemeText* pParams) { - if (pParams->m_wsText.IsEmpty()) - return; - - if (pParams->m_pWidget->GetClassID() == FWL_Type::MonthCalendar) { - CXFA_FFWidget* pWidget = XFA_ThemeGetOuterWidget(pParams->m_pWidget); - if (!pWidget) - return; - - m_pTextOut->SetStyles(pParams->m_dwTTOStyles); - m_pTextOut->SetAlignment(pParams->m_iTTOAlign); - m_pTextOut->SetFont(m_pCalendarFont); - m_pTextOut->SetFontSize(FWLTHEME_CAPACITY_FontSize); - m_pTextOut->SetTextColor(FWLTHEME_CAPACITY_TextColor); - if ((pParams->m_iPart == CFWL_Part::DatesIn) && - !(pParams->m_dwStates & FWL_ITEMSTATE_MCD_Flag) && - (pParams->m_dwStates & - (CFWL_PartState_Hovered | CFWL_PartState_Selected))) { - m_pTextOut->SetTextColor(0xFFFFFFFF); - } - if (pParams->m_iPart == CFWL_Part::Caption) - m_pTextOut->SetTextColor(ArgbEncode(0xff, 0, 153, 255)); - - CFX_Graphics* pGraphics = pParams->m_pGraphics; - CFX_RenderDevice* pRenderDevice = pGraphics->GetRenderDevice(); - if (!pRenderDevice) - return; - - m_pTextOut->SetRenderDevice(pRenderDevice); - CFX_Matrix mtPart = pParams->m_matrix; - CFX_Matrix* pMatrix = pGraphics->GetMatrix(); - if (pMatrix) { - mtPart.Concat(*pMatrix); - } - m_pTextOut->SetMatrix(mtPart); - m_pTextOut->DrawLogicText(pParams->m_wsText.c_str(), - pParams->m_wsText.GetLength(), pParams->m_rtPart); - return; - } - CXFA_FFWidget* pWidget = XFA_ThemeGetOuterWidget(pParams->m_pWidget); - if (!pWidget) - return; - - CXFA_WidgetAcc* pAcc = pWidget->GetDataAcc(); - CFX_Graphics* pGraphics = pParams->m_pGraphics; - CFX_RenderDevice* pRenderDevice = pGraphics->GetRenderDevice(); - if (!pRenderDevice) - return; - - m_pTextOut->SetRenderDevice(pRenderDevice); - m_pTextOut->SetStyles(pParams->m_dwTTOStyles); - m_pTextOut->SetAlignment(pParams->m_iTTOAlign); - m_pTextOut->SetFont(pAcc->GetFDEFont()); - m_pTextOut->SetFontSize(pAcc->GetFontSize()); - m_pTextOut->SetTextColor(pAcc->GetTextColor()); - CFX_Matrix mtPart = pParams->m_matrix; - CFX_Matrix* pMatrix = pGraphics->GetMatrix(); - if (pMatrix) - mtPart.Concat(*pMatrix); - - m_pTextOut->SetMatrix(mtPart); - m_pTextOut->DrawLogicText(pParams->m_wsText.c_str(), - pParams->m_wsText.GetLength(), pParams->m_rtPart); -} - -CFX_RectF CXFA_FWLTheme::GetUIMargin(CFWL_ThemePart* pThemePart) const { - CFX_RectF rect; - CXFA_FFWidget* pWidget = XFA_ThemeGetOuterWidget(pThemePart->m_pWidget); - if (!pWidget) - return rect; - - CXFA_LayoutItem* pItem = pWidget; - CXFA_WidgetAcc* pWidgetAcc = pWidget->GetDataAcc(); - rect = pWidgetAcc->GetUIMargin(); - if (CXFA_Para para = pWidgetAcc->GetPara()) { - rect.left += para.GetMarginLeft(); - if (pWidgetAcc->IsMultiLine()) - rect.width += para.GetMarginRight(); - } - if (!pItem->GetPrev()) { - if (pItem->GetNext()) - rect.height = 0; - } else if (!pItem->GetNext()) { - rect.top = 0; - } else { - rect.top = 0; - rect.height = 0; - } - return rect; -} - -float CXFA_FWLTheme::GetCXBorderSize() const { - return 1.0f; -} - -float CXFA_FWLTheme::GetCYBorderSize() const { - return 1.0f; -} - -float CXFA_FWLTheme::GetFontSize(CFWL_ThemePart* pThemePart) const { - if (CXFA_FFWidget* pWidget = XFA_ThemeGetOuterWidget(pThemePart->m_pWidget)) - return pWidget->GetDataAcc()->GetFontSize(); - return FWLTHEME_CAPACITY_FontSize; -} - -CFX_RetainPtr CXFA_FWLTheme::GetFont( - CFWL_ThemePart* pThemePart) const { - if (CXFA_FFWidget* pWidget = XFA_ThemeGetOuterWidget(pThemePart->m_pWidget)) - return pWidget->GetDataAcc()->GetFDEFont(); - return GetTheme(pThemePart->m_pWidget)->GetFont(); -} - -float CXFA_FWLTheme::GetLineHeight(CFWL_ThemePart* pThemePart) const { - if (CXFA_FFWidget* pWidget = XFA_ThemeGetOuterWidget(pThemePart->m_pWidget)) - return pWidget->GetDataAcc()->GetLineHeight(); - return kLineHeight; -} - -float CXFA_FWLTheme::GetScrollBarWidth() const { - return 9.0f; -} - -FX_COLORREF CXFA_FWLTheme::GetTextColor(CFWL_ThemePart* pThemePart) const { - if (CXFA_FFWidget* pWidget = XFA_ThemeGetOuterWidget(pThemePart->m_pWidget)) - return pWidget->GetDataAcc()->GetTextColor(); - return FWLTHEME_CAPACITY_TextColor; -} - -CFX_SizeF CXFA_FWLTheme::GetSpaceAboveBelow(CFWL_ThemePart* pThemePart) const { - CFX_SizeF sizeAboveBelow; - if (CXFA_FFWidget* pWidget = XFA_ThemeGetOuterWidget(pThemePart->m_pWidget)) { - CXFA_WidgetAcc* pWidgetAcc = pWidget->GetDataAcc(); - if (CXFA_Para para = pWidgetAcc->GetPara()) { - sizeAboveBelow.width = para.GetSpaceAbove(); - sizeAboveBelow.height = para.GetSpaceBelow(); - } - } - return sizeAboveBelow; -} - -void CXFA_FWLTheme::CalcTextRect(CFWL_ThemeText* pParams, CFX_RectF& rect) { - if (pParams->m_pWidget->GetClassID() == FWL_Type::MonthCalendar) { - CXFA_FFWidget* pWidget = XFA_ThemeGetOuterWidget(pParams->m_pWidget); - if (!pWidget || !pParams || !m_pTextOut) - return; - - m_pTextOut->SetFont(m_pCalendarFont); - m_pTextOut->SetFontSize(FWLTHEME_CAPACITY_FontSize); - m_pTextOut->SetTextColor(FWLTHEME_CAPACITY_TextColor); - m_pTextOut->SetAlignment(pParams->m_iTTOAlign); - m_pTextOut->SetStyles(pParams->m_dwTTOStyles); - m_pTextOut->CalcLogicSize(pParams->m_wsText.c_str(), - pParams->m_wsText.GetLength(), rect); - } - - CXFA_FFWidget* pWidget = XFA_ThemeGetOuterWidget(pParams->m_pWidget); - if (!pWidget) - return; - - CXFA_WidgetAcc* pAcc = pWidget->GetDataAcc(); - m_pTextOut->SetFont(pAcc->GetFDEFont()); - m_pTextOut->SetFontSize(pAcc->GetFontSize()); - m_pTextOut->SetTextColor(pAcc->GetTextColor()); - if (!pParams) - return; - - m_pTextOut->SetAlignment(pParams->m_iTTOAlign); - m_pTextOut->SetStyles(pParams->m_dwTTOStyles); - m_pTextOut->CalcLogicSize(pParams->m_wsText.c_str(), - pParams->m_wsText.GetLength(), rect); -} - -CFWL_WidgetTP* CXFA_FWLTheme::GetTheme(CFWL_Widget* pWidget) const { - switch (pWidget->GetClassID()) { - case FWL_Type::CheckBox: - return m_pCheckBoxTP.get(); - case FWL_Type::ListBox: - return m_pListBoxTP.get(); - case FWL_Type::PictureBox: - return m_pPictureBoxTP.get(); - case FWL_Type::ScrollBar: - return m_pSrollBarTP.get(); - case FWL_Type::Edit: - return m_pEditTP.get(); - case FWL_Type::ComboBox: - return m_pComboBoxTP.get(); - case FWL_Type::MonthCalendar: - return m_pMonthCalendarTP.get(); - case FWL_Type::DateTimePicker: - return m_pDateTimePickerTP.get(); - case FWL_Type::PushButton: - return m_pPushButtonTP.get(); - case FWL_Type::Caret: - return m_pCaretTP.get(); - case FWL_Type::Barcode: - return m_pBarcodeTP.get(); - default: - return nullptr; - } -} diff --git a/xfa/fxfa/app/xfa_fwltheme.h b/xfa/fxfa/app/xfa_fwltheme.h deleted file mode 100644 index 7563c69ed9..0000000000 --- a/xfa/fxfa/app/xfa_fwltheme.h +++ /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 - -#ifndef XFA_FXFA_APP_XFA_FWLTHEME_H_ -#define XFA_FXFA_APP_XFA_FWLTHEME_H_ - -#include - -#include "xfa/fwl/ifwl_themeprovider.h" -#include "xfa/fwl/theme/cfwl_barcodetp.h" -#include "xfa/fwl/theme/cfwl_carettp.h" -#include "xfa/fwl/theme/cfwl_checkboxtp.h" -#include "xfa/fwl/theme/cfwl_comboboxtp.h" -#include "xfa/fwl/theme/cfwl_datetimepickertp.h" -#include "xfa/fwl/theme/cfwl_edittp.h" -#include "xfa/fwl/theme/cfwl_listboxtp.h" -#include "xfa/fwl/theme/cfwl_monthcalendartp.h" -#include "xfa/fwl/theme/cfwl_pictureboxtp.h" -#include "xfa/fwl/theme/cfwl_pushbuttontp.h" -#include "xfa/fwl/theme/cfwl_scrollbartp.h" -#include "xfa/fwl/theme/cfwl_widgettp.h" -#include "xfa/fxfa/cxfa_ffapp.h" - -class CXFA_FWLTheme final : public IFWL_ThemeProvider { - public: - explicit CXFA_FWLTheme(CXFA_FFApp* pApp); - ~CXFA_FWLTheme() override; - - // IFWL_ThemeProvider: - void DrawBackground(CFWL_ThemeBackground* pParams) override; - void DrawText(CFWL_ThemeText* pParams) override; - void CalcTextRect(CFWL_ThemeText* pParams, CFX_RectF& rect) override; - float GetCXBorderSize() const override; - float GetCYBorderSize() const override; - CFX_RectF GetUIMargin(CFWL_ThemePart* pThemePart) const override; - float GetFontSize(CFWL_ThemePart* pThemePart) const override; - CFX_RetainPtr GetFont( - CFWL_ThemePart* pThemePart) const override; - float GetLineHeight(CFWL_ThemePart* pThemePart) const override; - float GetScrollBarWidth() const override; - FX_COLORREF GetTextColor(CFWL_ThemePart* pThemePart) const override; - CFX_SizeF GetSpaceAboveBelow(CFWL_ThemePart* pThemePart) const override; - - private: - CFWL_WidgetTP* GetTheme(CFWL_Widget* pWidget) const; - - std::unique_ptr m_pCheckBoxTP; - std::unique_ptr m_pListBoxTP; - std::unique_ptr m_pPictureBoxTP; - std::unique_ptr m_pSrollBarTP; - std::unique_ptr m_pEditTP; - std::unique_ptr m_pComboBoxTP; - std::unique_ptr m_pMonthCalendarTP; - std::unique_ptr m_pDateTimePickerTP; - std::unique_ptr m_pPushButtonTP; - std::unique_ptr m_pCaretTP; - std::unique_ptr m_pBarcodeTP; - std::unique_ptr m_pTextOut; - CFX_RetainPtr m_pCalendarFont; - CFX_WideString m_wsResource; - CFX_UnownedPtr const m_pApp; - CFX_RectF m_Rect; -}; - -CXFA_FFWidget* XFA_ThemeGetOuterWidget(CFWL_Widget* pWidget); - -#endif // XFA_FXFA_APP_XFA_FWLTHEME_H_ diff --git a/xfa/fxfa/app/xfa_textpiece.cpp b/xfa/fxfa/app/xfa_textpiece.cpp deleted file mode 100644 index c53e45f91a..0000000000 --- a/xfa/fxfa/app/xfa_textpiece.cpp +++ /dev/null @@ -1,13 +0,0 @@ -// 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/app/xfa_textpiece.h" - -#include "xfa/fxfa/app/cxfa_linkuserdata.h" - -XFA_TextPiece::XFA_TextPiece() {} - -XFA_TextPiece::~XFA_TextPiece() {} diff --git a/xfa/fxfa/app/xfa_textpiece.h b/xfa/fxfa/app/xfa_textpiece.h deleted file mode 100644 index fd1f3bdbaa..0000000000 --- a/xfa/fxfa/app/xfa_textpiece.h +++ /dev/null @@ -1,41 +0,0 @@ -// 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_APP_XFA_TEXTPIECE_H_ -#define XFA_FXFA_APP_XFA_TEXTPIECE_H_ - -#include - -#include "core/fxcrt/fx_basic.h" -#include "core/fxcrt/fx_coordinates.h" -#include "core/fxcrt/fx_string.h" -#include "core/fxge/fx_dib.h" -#include "xfa/fgas/font/cfgas_gefont.h" - -class CXFA_LinkUserData; - -class XFA_TextPiece { - public: - XFA_TextPiece(); - ~XFA_TextPiece(); - - CFX_WideString szText; - std::vector Widths; - int32_t iChars; - int32_t iHorScale; - int32_t iVerScale; - int32_t iBidiLevel; - int32_t iUnderline; - int32_t iPeriod; - int32_t iLineThrough; - FX_ARGB dwColor; - float fFontSize; - CFX_RectF rtPiece; - CFX_RetainPtr pFont; - CFX_RetainPtr pLinkData; -}; - -#endif // XFA_FXFA_APP_XFA_TEXTPIECE_H_ diff --git a/xfa/fxfa/cxfa_ffapp.cpp b/xfa/fxfa/cxfa_ffapp.cpp index 7b97116c7a..cb308f2c46 100644 --- a/xfa/fxfa/cxfa_ffapp.cpp +++ b/xfa/fxfa/cxfa_ffapp.cpp @@ -16,8 +16,8 @@ #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/app/cxfa_fwladapterwidgetmgr.h" +#include "xfa/fxfa/app/cxfa_fwltheme.h" #include "xfa/fxfa/cxfa_ffdoc.h" #include "xfa/fxfa/cxfa_ffdochandler.h" #include "xfa/fxfa/cxfa_ffwidgethandler.h" diff --git a/xfa/fxfa/cxfa_ffdoc.cpp b/xfa/fxfa/cxfa_ffdoc.cpp index bde40ce11f..01c570adbe 100644 --- a/xfa/fxfa/cxfa_ffdoc.cpp +++ b/xfa/fxfa/cxfa_ffdoc.cpp @@ -22,7 +22,7 @@ #include "core/fxcrt/xml/cfx_xmlnode.h" #include "third_party/base/ptr_util.h" #include "xfa/fwl/cfwl_notedriver.h" -#include "xfa/fxfa/app/xfa_ffnotify.h" +#include "xfa/fxfa/app/cxfa_ffnotify.h" #include "xfa/fxfa/cxfa_ffapp.h" #include "xfa/fxfa/cxfa_ffdocview.h" #include "xfa/fxfa/cxfa_ffwidget.h" diff --git a/xfa/fxfa/cxfa_ffdocview.cpp b/xfa/fxfa/cxfa_ffdocview.cpp index d9c97f71b1..620f3dab42 100644 --- a/xfa/fxfa/cxfa_ffdocview.cpp +++ b/xfa/fxfa/cxfa_ffdocview.cpp @@ -9,22 +9,19 @@ #include "core/fxcrt/fx_extension.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/app/cxfa_ffbarcode.h" +#include "xfa/fxfa/app/cxfa_ffcheckbutton.h" +#include "xfa/fxfa/app/cxfa_ffdraw.h" +#include "xfa/fxfa/app/cxfa_ffexclgroup.h" +#include "xfa/fxfa/app/cxfa_fffield.h" +#include "xfa/fxfa/app/cxfa_ffimage.h" +#include "xfa/fxfa/app/cxfa_ffimageedit.h" +#include "xfa/fxfa/app/cxfa_ffpushbutton.h" +#include "xfa/fxfa/app/cxfa_ffsignature.h" +#include "xfa/fxfa/app/cxfa_ffsubform.h" +#include "xfa/fxfa/app/cxfa_fftext.h" +#include "xfa/fxfa/app/cxfa_fwladapterwidgetmgr.h" +#include "xfa/fxfa/app/cxfa_textprovider.h" #include "xfa/fxfa/cxfa_ffapp.h" #include "xfa/fxfa/cxfa_ffdoc.h" #include "xfa/fxfa/cxfa_ffpageview.h" diff --git a/xfa/fxfa/cxfa_ffpageview.cpp b/xfa/fxfa/cxfa_ffpageview.cpp index c83ffaea7e..841318672f 100644 --- a/xfa/fxfa/cxfa_ffpageview.cpp +++ b/xfa/fxfa/cxfa_ffpageview.cpp @@ -13,13 +13,11 @@ #include "third_party/base/ptr_util.h" #include "third_party/base/stl_util.h" #include "xfa/fde/cfde_rendercontext.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/app/cxfa_ffcheckbutton.h" +#include "xfa/fxfa/app/cxfa_fffield.h" +#include "xfa/fxfa/app/cxfa_ffimageedit.h" +#include "xfa/fxfa/app/cxfa_ffpushbutton.h" +#include "xfa/fxfa/app/cxfa_fwladapterwidgetmgr.h" #include "xfa/fxfa/cxfa_ffdoc.h" #include "xfa/fxfa/cxfa_ffdocview.h" #include "xfa/fxfa/cxfa_ffwidget.h" diff --git a/xfa/fxfa/cxfa_ffwidgethandler.cpp b/xfa/fxfa/cxfa_ffwidgethandler.cpp index 6fe24fee29..680a00a975 100644 --- a/xfa/fxfa/cxfa_ffwidgethandler.cpp +++ b/xfa/fxfa/cxfa_ffwidgethandler.cpp @@ -8,9 +8,8 @@ #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/app/cxfa_fffield.h" +#include "xfa/fxfa/app/cxfa_fwladapterwidgetmgr.h" #include "xfa/fxfa/cxfa_ffdoc.h" #include "xfa/fxfa/cxfa_ffdocview.h" #include "xfa/fxfa/cxfa_ffwidget.h" diff --git a/xfa/fxfa/cxfa_widgetacc.cpp b/xfa/fxfa/cxfa_widgetacc.cpp index 9b52f95b63..d4a6125408 100644 --- a/xfa/fxfa/cxfa_widgetacc.cpp +++ b/xfa/fxfa/cxfa_widgetacc.cpp @@ -14,7 +14,7 @@ #include "third_party/base/stl_util.h" #include "xfa/fde/cfde_textout.h" #include "xfa/fxfa/app/cxfa_textlayout.h" -#include "xfa/fxfa/app/xfa_ffwidgetacc.h" +#include "xfa/fxfa/app/cxfa_textprovider.h" #include "xfa/fxfa/cxfa_ffapp.h" #include "xfa/fxfa/cxfa_ffdoc.h" #include "xfa/fxfa/cxfa_ffdocview.h" diff --git a/xfa/fxfa/fm2js/cxfa_fm2jscontext.cpp b/xfa/fxfa/fm2js/cxfa_fm2jscontext.cpp index 4b3b5e2ab1..c6d53696a0 100644 --- a/xfa/fxfa/fm2js/cxfa_fm2jscontext.cpp +++ b/xfa/fxfa/fm2js/cxfa_fm2jscontext.cpp @@ -17,7 +17,7 @@ #include "fxjs/cfxjse_value.h" #include "third_party/base/ptr_util.h" #include "third_party/base/stl_util.h" -#include "xfa/fxfa/app/xfa_ffnotify.h" +#include "xfa/fxfa/app/cxfa_ffnotify.h" #include "xfa/fxfa/fm2js/cxfa_fmparse.h" #include "xfa/fxfa/parser/cxfa_document.h" #include "xfa/fxfa/parser/cxfa_localevalue.h" diff --git a/xfa/fxfa/parser/cscript_eventpseudomodel.cpp b/xfa/fxfa/parser/cscript_eventpseudomodel.cpp index c57b0bdc78..ede59871f1 100644 --- a/xfa/fxfa/parser/cscript_eventpseudomodel.cpp +++ b/xfa/fxfa/parser/cscript_eventpseudomodel.cpp @@ -7,7 +7,7 @@ #include "xfa/fxfa/parser/cscript_eventpseudomodel.h" #include "fxjs/cfxjse_arguments.h" -#include "xfa/fxfa/app/xfa_ffnotify.h" +#include "xfa/fxfa/app/cxfa_ffnotify.h" #include "xfa/fxfa/cxfa_eventparam.h" #include "xfa/fxfa/cxfa_ffwidgethandler.h" #include "xfa/fxfa/parser/cxfa_document.h" diff --git a/xfa/fxfa/parser/cscript_hostpseudomodel.cpp b/xfa/fxfa/parser/cscript_hostpseudomodel.cpp index d2633ec4ae..b229b23151 100644 --- a/xfa/fxfa/parser/cscript_hostpseudomodel.cpp +++ b/xfa/fxfa/parser/cscript_hostpseudomodel.cpp @@ -9,7 +9,7 @@ #include #include "fxjs/cfxjse_arguments.h" -#include "xfa/fxfa/app/xfa_ffnotify.h" +#include "xfa/fxfa/app/cxfa_ffnotify.h" #include "xfa/fxfa/parser/cxfa_document.h" #include "xfa/fxfa/parser/cxfa_layoutprocessor.h" #include "xfa/fxfa/parser/cxfa_localemgr.h" diff --git a/xfa/fxfa/parser/cscript_layoutpseudomodel.cpp b/xfa/fxfa/parser/cscript_layoutpseudomodel.cpp index 6e6a1086ff..130c9f0843 100644 --- a/xfa/fxfa/parser/cscript_layoutpseudomodel.cpp +++ b/xfa/fxfa/parser/cscript_layoutpseudomodel.cpp @@ -10,7 +10,7 @@ #include "fxjs/cfxjse_arguments.h" #include "third_party/base/stl_util.h" -#include "xfa/fxfa/app/xfa_ffnotify.h" +#include "xfa/fxfa/app/cxfa_ffnotify.h" #include "xfa/fxfa/parser/cxfa_arraynodelist.h" #include "xfa/fxfa/parser/cxfa_containerlayoutitem.h" #include "xfa/fxfa/parser/cxfa_contentlayoutitem.h" diff --git a/xfa/fxfa/parser/cscript_signaturepseudomodel.cpp b/xfa/fxfa/parser/cscript_signaturepseudomodel.cpp index 0886809db1..023d3e541f 100644 --- a/xfa/fxfa/parser/cscript_signaturepseudomodel.cpp +++ b/xfa/fxfa/parser/cscript_signaturepseudomodel.cpp @@ -7,7 +7,7 @@ #include "xfa/fxfa/parser/cscript_signaturepseudomodel.h" #include "fxjs/cfxjse_arguments.h" -#include "xfa/fxfa/app/xfa_ffnotify.h" +#include "xfa/fxfa/app/cxfa_ffnotify.h" #include "xfa/fxfa/parser/cxfa_document.h" #include "xfa/fxfa/parser/cxfa_localemgr.h" #include "xfa/fxfa/parser/cxfa_scriptcontext.h" diff --git a/xfa/fxfa/parser/cxfa_document.cpp b/xfa/fxfa/parser/cxfa_document.cpp index a1180e7b8e..ec80866bb0 100644 --- a/xfa/fxfa/parser/cxfa_document.cpp +++ b/xfa/fxfa/parser/cxfa_document.cpp @@ -7,7 +7,7 @@ #include "xfa/fxfa/parser/cxfa_document.h" #include "core/fxcrt/fx_extension.h" -#include "xfa/fxfa/app/xfa_ffnotify.h" +#include "xfa/fxfa/app/cxfa_ffnotify.h" #include "xfa/fxfa/parser/cscript_datawindow.h" #include "xfa/fxfa/parser/cscript_eventpseudomodel.h" #include "xfa/fxfa/parser/cscript_hostpseudomodel.h" diff --git a/xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp b/xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp index b2e4e725a7..b6e6e7f8e9 100644 --- a/xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp +++ b/xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp @@ -14,7 +14,7 @@ #include "third_party/base/logging.h" #include "third_party/base/ptr_util.h" #include "third_party/base/stl_util.h" -#include "xfa/fxfa/app/xfa_ffnotify.h" +#include "xfa/fxfa/app/cxfa_ffnotify.h" #include "xfa/fxfa/parser/cxfa_containerlayoutitem.h" #include "xfa/fxfa/parser/cxfa_contentlayoutitem.h" #include "xfa/fxfa/parser/cxfa_document.h" diff --git a/xfa/fxfa/parser/cxfa_layoutitem.cpp b/xfa/fxfa/parser/cxfa_layoutitem.cpp index 2bac7950ef..a769da0f2a 100644 --- a/xfa/fxfa/parser/cxfa_layoutitem.cpp +++ b/xfa/fxfa/parser/cxfa_layoutitem.cpp @@ -6,7 +6,7 @@ #include "xfa/fxfa/parser/cxfa_layoutitem.h" -#include "xfa/fxfa/app/xfa_ffnotify.h" +#include "xfa/fxfa/app/cxfa_ffnotify.h" #include "xfa/fxfa/parser/cxfa_containerlayoutitem.h" #include "xfa/fxfa/parser/cxfa_contentlayoutitem.h" #include "xfa/fxfa/parser/cxfa_measurement.h" diff --git a/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp b/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp index 5c94a6a256..0bf091ed34 100644 --- a/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp +++ b/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp @@ -7,7 +7,7 @@ #include "xfa/fxfa/parser/cxfa_layoutpagemgr.h" #include "third_party/base/stl_util.h" -#include "xfa/fxfa/app/xfa_ffnotify.h" +#include "xfa/fxfa/app/cxfa_ffnotify.h" #include "xfa/fxfa/parser/cxfa_containerlayoutitem.h" #include "xfa/fxfa/parser/cxfa_contentlayoutitem.h" #include "xfa/fxfa/parser/cxfa_document.h" diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp index 2daa49e066..845d3f379d 100644 --- a/xfa/fxfa/parser/cxfa_node.cpp +++ b/xfa/fxfa/parser/cxfa_node.cpp @@ -23,7 +23,7 @@ #include "third_party/base/logging.h" #include "third_party/base/ptr_util.h" #include "third_party/base/stl_util.h" -#include "xfa/fxfa/app/xfa_ffnotify.h" +#include "xfa/fxfa/app/cxfa_ffnotify.h" #include "xfa/fxfa/cxfa_eventparam.h" #include "xfa/fxfa/cxfa_ffwidget.h" #include "xfa/fxfa/parser/cxfa_arraynodelist.h" diff --git a/xfa/fxfa/parser/cxfa_object.cpp b/xfa/fxfa/parser/cxfa_object.cpp index bd7daec83a..8dd35cd245 100644 --- a/xfa/fxfa/parser/cxfa_object.cpp +++ b/xfa/fxfa/parser/cxfa_object.cpp @@ -8,7 +8,7 @@ #include "core/fxcrt/fx_extension.h" #include "fxjs/cfxjse_value.h" -#include "xfa/fxfa/app/xfa_ffnotify.h" +#include "xfa/fxfa/app/cxfa_ffnotify.h" #include "xfa/fxfa/parser/cxfa_document.h" #include "xfa/fxfa/parser/cxfa_node.h" #include "xfa/fxfa/parser/cxfa_nodelist.h" diff --git a/xfa/fxfa/parser/cxfa_scriptcontext.cpp b/xfa/fxfa/parser/cxfa_scriptcontext.cpp index 49da63eee3..2100299616 100644 --- a/xfa/fxfa/parser/cxfa_scriptcontext.cpp +++ b/xfa/fxfa/parser/cxfa_scriptcontext.cpp @@ -14,7 +14,7 @@ #include "fxjs/cfxjse_value.h" #include "third_party/base/ptr_util.h" #include "third_party/base/stl_util.h" -#include "xfa/fxfa/app/xfa_ffnotify.h" +#include "xfa/fxfa/app/cxfa_ffnotify.h" #include "xfa/fxfa/cxfa_eventparam.h" #include "xfa/fxfa/parser/cxfa_document.h" #include "xfa/fxfa/parser/cxfa_localemgr.h" diff --git a/xfa/fxfa/parser/cxfa_widgetdata.cpp b/xfa/fxfa/parser/cxfa_widgetdata.cpp index bf9afc062f..cd4aa57332 100644 --- a/xfa/fxfa/parser/cxfa_widgetdata.cpp +++ b/xfa/fxfa/parser/cxfa_widgetdata.cpp @@ -10,7 +10,7 @@ #include "core/fxcrt/fx_extension.h" #include "fxbarcode/BC_Library.h" #include "third_party/base/stl_util.h" -#include "xfa/fxfa/app/xfa_ffnotify.h" +#include "xfa/fxfa/app/cxfa_ffnotify.h" #include "xfa/fxfa/parser/cxfa_document.h" #include "xfa/fxfa/parser/cxfa_event.h" #include "xfa/fxfa/parser/cxfa_localevalue.h" -- cgit v1.2.3