summaryrefslogtreecommitdiff
path: root/xfa/fxfa
diff options
context:
space:
mode:
Diffstat (limited to 'xfa/fxfa')
-rw-r--r--xfa/fxfa/DEPS3
-rw-r--r--xfa/fxfa/app/DEPS3
-rw-r--r--xfa/fxfa/app/cxfa_textparser.cpp6
-rw-r--r--xfa/fxfa/app/xfa_ffbarcode.cpp4
-rw-r--r--xfa/fxfa/app/xfa_ffbarcode.h2
-rw-r--r--xfa/fxfa/app/xfa_ffcheckbutton.cpp10
-rw-r--r--xfa/fxfa/app/xfa_ffcheckbutton.h2
-rw-r--r--xfa/fxfa/app/xfa_ffchoicelist.cpp8
-rw-r--r--xfa/fxfa/app/xfa_ffchoicelist.h2
-rw-r--r--xfa/fxfa/app/xfa_ffdraw.cpp8
-rw-r--r--xfa/fxfa/app/xfa_ffdraw.h4
-rw-r--r--xfa/fxfa/app/xfa_ffexclgroup.cpp8
-rw-r--r--xfa/fxfa/app/xfa_ffexclgroup.h4
-rw-r--r--xfa/fxfa/app/xfa_fffield.cpp10
-rw-r--r--xfa/fxfa/app/xfa_fffield.h4
-rw-r--r--xfa/fxfa/app/xfa_ffimage.cpp8
-rw-r--r--xfa/fxfa/app/xfa_ffimageedit.cpp8
-rw-r--r--xfa/fxfa/app/xfa_ffnotify.cpp12
-rw-r--r--xfa/fxfa/app/xfa_ffpath.cpp8
-rw-r--r--xfa/fxfa/app/xfa_ffpushbutton.cpp6
-rw-r--r--xfa/fxfa/app/xfa_ffsignature.cpp6
-rw-r--r--xfa/fxfa/app/xfa_ffsubform.cpp8
-rw-r--r--xfa/fxfa/app/xfa_ffsubform.h4
-rw-r--r--xfa/fxfa/app/xfa_fftext.cpp8
-rw-r--r--xfa/fxfa/app/xfa_fftextedit.cpp10
-rw-r--r--xfa/fxfa/app/xfa_ffwidgetacc.cpp1498
-rw-r--r--xfa/fxfa/app/xfa_ffwidgetacc.h2
-rw-r--r--xfa/fxfa/app/xfa_fwladapter.cpp2
-rw-r--r--xfa/fxfa/app/xfa_fwltheme.cpp4
-rw-r--r--xfa/fxfa/app/xfa_fwltheme.h2
-rw-r--r--xfa/fxfa/cxfa_checksumcontext.cpp (renamed from xfa/fxfa/app/xfa_checksum.cpp)122
-rw-r--r--xfa/fxfa/cxfa_checksumcontext.h34
-rw-r--r--xfa/fxfa/cxfa_deffontmgr.cpp77
-rw-r--r--xfa/fxfa/cxfa_deffontmgr.h37
-rw-r--r--xfa/fxfa/cxfa_eventparam.cpp (renamed from xfa/fxfa/app/cxfa_eventparam.cpp)0
-rw-r--r--xfa/fxfa/cxfa_ffapp.cpp (renamed from xfa/fxfa/app/xfa_ffapp.cpp)10
-rw-r--r--xfa/fxfa/cxfa_ffapp.h (renamed from xfa/fxfa/xfa_ffapp.h)8
-rw-r--r--xfa/fxfa/cxfa_ffapp_unitest.cpp (renamed from xfa/fxfa/app/xfa_ffapp_unittest.cpp)2
-rw-r--r--xfa/fxfa/cxfa_ffdoc.cpp (renamed from xfa/fxfa/app/xfa_ffdoc.cpp)12
-rw-r--r--xfa/fxfa/cxfa_ffdoc.h (renamed from xfa/fxfa/xfa_ffdoc.h)8
-rw-r--r--xfa/fxfa/cxfa_ffdochandler.cpp (renamed from xfa/fxfa/app/xfa_ffdochandler.cpp)6
-rw-r--r--xfa/fxfa/cxfa_ffdochandler.h (renamed from xfa/fxfa/xfa_ffdochandler.h)8
-rw-r--r--xfa/fxfa/cxfa_ffdocview.cpp (renamed from xfa/fxfa/app/xfa_ffdocview.cpp)68
-rw-r--r--xfa/fxfa/cxfa_ffdocview.h (renamed from xfa/fxfa/xfa_ffdocview.h)34
-rw-r--r--xfa/fxfa/cxfa_ffpageview.cpp (renamed from xfa/fxfa/app/xfa_ffpageview.cpp)8
-rw-r--r--xfa/fxfa/cxfa_ffpageview.h (renamed from xfa/fxfa/xfa_ffpageview.h)6
-rw-r--r--xfa/fxfa/cxfa_ffwidget.cpp (renamed from xfa/fxfa/app/xfa_ffwidget.cpp)12
-rw-r--r--xfa/fxfa/cxfa_ffwidget.h (renamed from xfa/fxfa/xfa_ffwidget.h)88
-rw-r--r--xfa/fxfa/cxfa_ffwidgethandler.cpp (renamed from xfa/fxfa/app/xfa_ffwidgethandler.cpp)9
-rw-r--r--xfa/fxfa/cxfa_ffwidgethandler.h (renamed from xfa/fxfa/xfa_ffwidgethandler.h)8
-rw-r--r--xfa/fxfa/cxfa_fontmgr.cpp (renamed from xfa/fxfa/app/xfa_fontmgr.cpp)268
-rw-r--r--xfa/fxfa/cxfa_fontmgr.h56
-rw-r--r--xfa/fxfa/cxfa_pdffontmgr.cpp208
-rw-r--r--xfa/fxfa/cxfa_pdffontmgr.h (renamed from xfa/fxfa/xfa_fontmgr.h)68
-rw-r--r--xfa/fxfa/cxfa_rendercontext.cpp (renamed from xfa/fxfa/app/xfa_rendercontext.cpp)6
-rw-r--r--xfa/fxfa/cxfa_rendercontext.h (renamed from xfa/fxfa/xfa_rendercontext.h)8
-rw-r--r--xfa/fxfa/cxfa_saxcontext.h19
-rw-r--r--xfa/fxfa/cxfa_saxreaderhandler.cpp129
-rw-r--r--xfa/fxfa/cxfa_saxreaderhandler.h (renamed from xfa/fxfa/xfa_checksum.h)45
-rw-r--r--xfa/fxfa/cxfa_widgetacc.cpp1549
-rw-r--r--xfa/fxfa/cxfa_widgetacc.h (renamed from xfa/fxfa/fxfa_widget.h)8
-rw-r--r--xfa/fxfa/cxfa_widgetacciterator.cpp56
-rw-r--r--xfa/fxfa/cxfa_widgetacciterator.h34
-rw-r--r--xfa/fxfa/fxfa.h2
-rw-r--r--xfa/fxfa/parser/cscript_eventpseudomodel.cpp2
-rw-r--r--xfa/fxfa/parser/cxfa_simple_parser.cpp2
66 files changed, 2437 insertions, 2244 deletions
diff --git a/xfa/fxfa/DEPS b/xfa/fxfa/DEPS
index 93a9acbc13..97e9f52afa 100644
--- a/xfa/fxfa/DEPS
+++ b/xfa/fxfa/DEPS
@@ -1,5 +1,8 @@
include_rules = [
'+core/fdrm/crypto',
+ '+core/fpdfapi/font',
+ '+core/fpdfapi/page',
+ '+core/fpdfdoc',
'+core/fxcodec',
'+fxjs',
]
diff --git a/xfa/fxfa/app/DEPS b/xfa/fxfa/app/DEPS
index 5c72d1d0b2..f722184c91 100644
--- a/xfa/fxfa/app/DEPS
+++ b/xfa/fxfa/app/DEPS
@@ -1,6 +1,3 @@
include_rules = [
'+core/fdrm/crypto',
- '+core/fpdfapi/font',
- '+core/fpdfapi/page',
- '+core/fpdfdoc',
]
diff --git a/xfa/fxfa/app/cxfa_textparser.cpp b/xfa/fxfa/app/cxfa_textparser.cpp
index 546348083e..65155f989c 100644
--- a/xfa/fxfa/app/cxfa_textparser.cpp
+++ b/xfa/fxfa/app/cxfa_textparser.cpp
@@ -21,10 +21,10 @@
#include "xfa/fxfa/app/cxfa_textparsecontext.h"
#include "xfa/fxfa/app/cxfa_texttabstopscontext.h"
#include "xfa/fxfa/app/xfa_ffwidgetacc.h"
+#include "xfa/fxfa/cxfa_ffapp.h"
+#include "xfa/fxfa/cxfa_ffdoc.h"
+#include "xfa/fxfa/cxfa_fontmgr.h"
#include "xfa/fxfa/parser/cxfa_measurement.h"
-#include "xfa/fxfa/xfa_ffapp.h"
-#include "xfa/fxfa/xfa_ffdoc.h"
-#include "xfa/fxfa/xfa_fontmgr.h"
namespace {
diff --git a/xfa/fxfa/app/xfa_ffbarcode.cpp b/xfa/fxfa/app/xfa_ffbarcode.cpp
index 6b13069ed2..72adb3c96b 100644
--- a/xfa/fxfa/app/xfa_ffbarcode.cpp
+++ b/xfa/fxfa/app/xfa_ffbarcode.cpp
@@ -13,8 +13,8 @@
#include "xfa/fxfa/app/xfa_fffield.h"
#include "xfa/fxfa/app/xfa_fftextedit.h"
#include "xfa/fxfa/app/xfa_fwladapter.h"
-#include "xfa/fxfa/xfa_ffpageview.h"
-#include "xfa/fxfa/xfa_ffwidget.h"
+#include "xfa/fxfa/cxfa_ffpageview.h"
+#include "xfa/fxfa/cxfa_ffwidget.h"
namespace {
diff --git a/xfa/fxfa/app/xfa_ffbarcode.h b/xfa/fxfa/app/xfa_ffbarcode.h
index 1f11be6da7..6d93e1b682 100644
--- a/xfa/fxfa/app/xfa_ffbarcode.h
+++ b/xfa/fxfa/app/xfa_ffbarcode.h
@@ -9,7 +9,7 @@
#include "xfa/fxbarcode/BC_Library.h"
#include "xfa/fxfa/app/xfa_fftextedit.h"
-#include "xfa/fxfa/xfa_ffpageview.h"
+#include "xfa/fxfa/cxfa_ffpageview.h"
class CXFA_FFBarcode : public CXFA_FFTextEdit {
public:
diff --git a/xfa/fxfa/app/xfa_ffcheckbutton.cpp b/xfa/fxfa/app/xfa_ffcheckbutton.cpp
index 22fdb3d9df..9f003ad3a1 100644
--- a/xfa/fxfa/app/xfa_ffcheckbutton.cpp
+++ b/xfa/fxfa/app/xfa_ffcheckbutton.cpp
@@ -12,11 +12,11 @@
#include "xfa/fwl/cfwl_widgetmgr.h"
#include "xfa/fxfa/app/xfa_ffexclgroup.h"
#include "xfa/fxfa/app/xfa_fffield.h"
-#include "xfa/fxfa/xfa_ffapp.h"
-#include "xfa/fxfa/xfa_ffdoc.h"
-#include "xfa/fxfa/xfa_ffdocview.h"
-#include "xfa/fxfa/xfa_ffpageview.h"
-#include "xfa/fxfa/xfa_ffwidget.h"
+#include "xfa/fxfa/cxfa_ffapp.h"
+#include "xfa/fxfa/cxfa_ffdoc.h"
+#include "xfa/fxfa/cxfa_ffdocview.h"
+#include "xfa/fxfa/cxfa_ffpageview.h"
+#include "xfa/fxfa/cxfa_ffwidget.h"
CXFA_FFCheckButton::CXFA_FFCheckButton(CXFA_WidgetAcc* pDataAcc)
: CXFA_FFField(pDataAcc), m_pOldDelegate(nullptr) {}
diff --git a/xfa/fxfa/app/xfa_ffcheckbutton.h b/xfa/fxfa/app/xfa_ffcheckbutton.h
index 2c0acd6e3e..ea8ff923a7 100644
--- a/xfa/fxfa/app/xfa_ffcheckbutton.h
+++ b/xfa/fxfa/app/xfa_ffcheckbutton.h
@@ -8,7 +8,7 @@
#define XFA_FXFA_APP_XFA_FFCHECKBUTTON_H_
#include "xfa/fxfa/app/xfa_fffield.h"
-#include "xfa/fxfa/xfa_ffpageview.h"
+#include "xfa/fxfa/cxfa_ffpageview.h"
class CXFA_FFCheckButton : public CXFA_FFField {
public:
diff --git a/xfa/fxfa/app/xfa_ffchoicelist.cpp b/xfa/fxfa/app/xfa_ffchoicelist.cpp
index 66b52fec40..460964532e 100644
--- a/xfa/fxfa/app/xfa_ffchoicelist.cpp
+++ b/xfa/fxfa/app/xfa_ffchoicelist.cpp
@@ -20,10 +20,10 @@
#include "xfa/fxfa/app/xfa_fffield.h"
#include "xfa/fxfa/app/xfa_fwladapter.h"
#include "xfa/fxfa/cxfa_eventparam.h"
-#include "xfa/fxfa/xfa_ffdoc.h"
-#include "xfa/fxfa/xfa_ffdocview.h"
-#include "xfa/fxfa/xfa_ffpageview.h"
-#include "xfa/fxfa/xfa_ffwidget.h"
+#include "xfa/fxfa/cxfa_ffdoc.h"
+#include "xfa/fxfa/cxfa_ffdocview.h"
+#include "xfa/fxfa/cxfa_ffpageview.h"
+#include "xfa/fxfa/cxfa_ffwidget.h"
CXFA_FFListBox::CXFA_FFListBox(CXFA_WidgetAcc* pDataAcc)
: CXFA_FFField(pDataAcc), m_pOldDelegate(nullptr) {}
diff --git a/xfa/fxfa/app/xfa_ffchoicelist.h b/xfa/fxfa/app/xfa_ffchoicelist.h
index e89366ad13..231381444b 100644
--- a/xfa/fxfa/app/xfa_ffchoicelist.h
+++ b/xfa/fxfa/app/xfa_ffchoicelist.h
@@ -8,7 +8,7 @@
#define XFA_FXFA_APP_XFA_FFCHOICELIST_H_
#include "xfa/fxfa/app/xfa_fffield.h"
-#include "xfa/fxfa/xfa_ffpageview.h"
+#include "xfa/fxfa/cxfa_ffpageview.h"
class CXFA_FFListBox : public CXFA_FFField {
public:
diff --git a/xfa/fxfa/app/xfa_ffdraw.cpp b/xfa/fxfa/app/xfa_ffdraw.cpp
index 37095ddb49..8742b83c5b 100644
--- a/xfa/fxfa/app/xfa_ffdraw.cpp
+++ b/xfa/fxfa/app/xfa_ffdraw.cpp
@@ -6,10 +6,10 @@
#include "xfa/fxfa/app/xfa_ffdraw.h"
-#include "xfa/fxfa/xfa_ffapp.h"
-#include "xfa/fxfa/xfa_ffdoc.h"
-#include "xfa/fxfa/xfa_ffpageview.h"
-#include "xfa/fxfa/xfa_ffwidget.h"
+#include "xfa/fxfa/cxfa_ffapp.h"
+#include "xfa/fxfa/cxfa_ffdoc.h"
+#include "xfa/fxfa/cxfa_ffpageview.h"
+#include "xfa/fxfa/cxfa_ffwidget.h"
CXFA_FFDraw::CXFA_FFDraw(CXFA_WidgetAcc* pDataAcc) : CXFA_FFWidget(pDataAcc) {}
diff --git a/xfa/fxfa/app/xfa_ffdraw.h b/xfa/fxfa/app/xfa_ffdraw.h
index 0212dcca0a..bcd74f204c 100644
--- a/xfa/fxfa/app/xfa_ffdraw.h
+++ b/xfa/fxfa/app/xfa_ffdraw.h
@@ -7,8 +7,8 @@
#ifndef XFA_FXFA_APP_XFA_FFDRAW_H_
#define XFA_FXFA_APP_XFA_FFDRAW_H_
-#include "xfa/fxfa/xfa_ffpageview.h"
-#include "xfa/fxfa/xfa_ffwidget.h"
+#include "xfa/fxfa/cxfa_ffpageview.h"
+#include "xfa/fxfa/cxfa_ffwidget.h"
class CXFA_FFDraw : public CXFA_FFWidget {
public:
diff --git a/xfa/fxfa/app/xfa_ffexclgroup.cpp b/xfa/fxfa/app/xfa_ffexclgroup.cpp
index 7d63daddbc..9f2560f82f 100644
--- a/xfa/fxfa/app/xfa_ffexclgroup.cpp
+++ b/xfa/fxfa/app/xfa_ffexclgroup.cpp
@@ -6,10 +6,10 @@
#include "xfa/fxfa/app/xfa_ffexclgroup.h"
-#include "xfa/fxfa/xfa_ffapp.h"
-#include "xfa/fxfa/xfa_ffdoc.h"
-#include "xfa/fxfa/xfa_ffpageview.h"
-#include "xfa/fxfa/xfa_ffwidget.h"
+#include "xfa/fxfa/cxfa_ffapp.h"
+#include "xfa/fxfa/cxfa_ffdoc.h"
+#include "xfa/fxfa/cxfa_ffpageview.h"
+#include "xfa/fxfa/cxfa_ffwidget.h"
CXFA_FFExclGroup::CXFA_FFExclGroup(CXFA_WidgetAcc* pDataAcc)
: CXFA_FFWidget(pDataAcc) {}
diff --git a/xfa/fxfa/app/xfa_ffexclgroup.h b/xfa/fxfa/app/xfa_ffexclgroup.h
index 12a13aea92..a14894566c 100644
--- a/xfa/fxfa/app/xfa_ffexclgroup.h
+++ b/xfa/fxfa/app/xfa_ffexclgroup.h
@@ -7,8 +7,8 @@
#ifndef XFA_FXFA_APP_XFA_FFEXCLGROUP_H_
#define XFA_FXFA_APP_XFA_FFEXCLGROUP_H_
-#include "xfa/fxfa/xfa_ffpageview.h"
-#include "xfa/fxfa/xfa_ffwidget.h"
+#include "xfa/fxfa/cxfa_ffpageview.h"
+#include "xfa/fxfa/cxfa_ffwidget.h"
class CXFA_FFExclGroup : public CXFA_FFWidget {
public:
diff --git a/xfa/fxfa/app/xfa_fffield.cpp b/xfa/fxfa/app/xfa_fffield.cpp
index 06763be094..39109f5f28 100644
--- a/xfa/fxfa/app/xfa_fffield.cpp
+++ b/xfa/fxfa/app/xfa_fffield.cpp
@@ -17,11 +17,11 @@
#include "xfa/fwl/cfwl_widgetmgr.h"
#include "xfa/fxfa/app/cxfa_textlayout.h"
#include "xfa/fxfa/app/xfa_fwltheme.h"
-#include "xfa/fxfa/xfa_ffapp.h"
-#include "xfa/fxfa/xfa_ffdoc.h"
-#include "xfa/fxfa/xfa_ffdocview.h"
-#include "xfa/fxfa/xfa_ffpageview.h"
-#include "xfa/fxfa/xfa_ffwidget.h"
+#include "xfa/fxfa/cxfa_ffapp.h"
+#include "xfa/fxfa/cxfa_ffdoc.h"
+#include "xfa/fxfa/cxfa_ffdocview.h"
+#include "xfa/fxfa/cxfa_ffpageview.h"
+#include "xfa/fxfa/cxfa_ffwidget.h"
#include "xfa/fxgraphics/cfx_color.h"
#include "xfa/fxgraphics/cfx_path.h"
diff --git a/xfa/fxfa/app/xfa_fffield.h b/xfa/fxfa/app/xfa_fffield.h
index f10ce61738..0e9ac8661c 100644
--- a/xfa/fxfa/app/xfa_fffield.h
+++ b/xfa/fxfa/app/xfa_fffield.h
@@ -9,8 +9,8 @@
#include "xfa/fwl/cfwl_widget.h"
#include "xfa/fwl/ifwl_widgetdelegate.h"
-#include "xfa/fxfa/xfa_ffpageview.h"
-#include "xfa/fxfa/xfa_ffwidget.h"
+#include "xfa/fxfa/cxfa_ffpageview.h"
+#include "xfa/fxfa/cxfa_ffwidget.h"
#define XFA_MINUI_HEIGHT 4.32f
#define XFA_DEFAULTUI_HEIGHT 2.0f
diff --git a/xfa/fxfa/app/xfa_ffimage.cpp b/xfa/fxfa/app/xfa_ffimage.cpp
index a613221ea6..81188c14d1 100644
--- a/xfa/fxfa/app/xfa_ffimage.cpp
+++ b/xfa/fxfa/app/xfa_ffimage.cpp
@@ -7,10 +7,10 @@
#include "xfa/fxfa/app/xfa_ffimage.h"
#include "xfa/fxfa/app/xfa_ffdraw.h"
-#include "xfa/fxfa/xfa_ffapp.h"
-#include "xfa/fxfa/xfa_ffdoc.h"
-#include "xfa/fxfa/xfa_ffpageview.h"
-#include "xfa/fxfa/xfa_ffwidget.h"
+#include "xfa/fxfa/cxfa_ffapp.h"
+#include "xfa/fxfa/cxfa_ffdoc.h"
+#include "xfa/fxfa/cxfa_ffpageview.h"
+#include "xfa/fxfa/cxfa_ffwidget.h"
CXFA_FFImage::CXFA_FFImage(CXFA_WidgetAcc* pDataAcc) : CXFA_FFDraw(pDataAcc) {}
diff --git a/xfa/fxfa/app/xfa_ffimageedit.cpp b/xfa/fxfa/app/xfa_ffimageedit.cpp
index 01d29eed41..b776579152 100644
--- a/xfa/fxfa/app/xfa_ffimageedit.cpp
+++ b/xfa/fxfa/app/xfa_ffimageedit.cpp
@@ -11,10 +11,10 @@
#include "xfa/fwl/cfwl_notedriver.h"
#include "xfa/fwl/cfwl_picturebox.h"
#include "xfa/fxfa/app/xfa_fffield.h"
-#include "xfa/fxfa/xfa_ffdoc.h"
-#include "xfa/fxfa/xfa_ffdocview.h"
-#include "xfa/fxfa/xfa_ffpageview.h"
-#include "xfa/fxfa/xfa_ffwidget.h"
+#include "xfa/fxfa/cxfa_ffdoc.h"
+#include "xfa/fxfa/cxfa_ffdocview.h"
+#include "xfa/fxfa/cxfa_ffpageview.h"
+#include "xfa/fxfa/cxfa_ffwidget.h"
CXFA_FFImageEdit::CXFA_FFImageEdit(CXFA_WidgetAcc* pDataAcc)
: CXFA_FFField(pDataAcc), m_pOldDelegate(nullptr) {}
diff --git a/xfa/fxfa/app/xfa_ffnotify.cpp b/xfa/fxfa/app/xfa_ffnotify.cpp
index fb154d8a9a..90648012c6 100644
--- a/xfa/fxfa/app/xfa_ffnotify.cpp
+++ b/xfa/fxfa/app/xfa_ffnotify.cpp
@@ -24,12 +24,12 @@
#include "xfa/fxfa/app/xfa_fftextedit.h"
#include "xfa/fxfa/app/xfa_ffwidgetacc.h"
#include "xfa/fxfa/app/xfa_fwladapter.h"
-#include "xfa/fxfa/xfa_ffapp.h"
-#include "xfa/fxfa/xfa_ffdoc.h"
-#include "xfa/fxfa/xfa_ffdocview.h"
-#include "xfa/fxfa/xfa_ffpageview.h"
-#include "xfa/fxfa/xfa_ffwidget.h"
-#include "xfa/fxfa/xfa_ffwidgethandler.h"
+#include "xfa/fxfa/cxfa_ffapp.h"
+#include "xfa/fxfa/cxfa_ffdoc.h"
+#include "xfa/fxfa/cxfa_ffdocview.h"
+#include "xfa/fxfa/cxfa_ffpageview.h"
+#include "xfa/fxfa/cxfa_ffwidget.h"
+#include "xfa/fxfa/cxfa_ffwidgethandler.h"
static void XFA_FFDeleteWidgetAcc(void* pData) {
delete static_cast<CXFA_WidgetAcc*>(pData);
diff --git a/xfa/fxfa/app/xfa_ffpath.cpp b/xfa/fxfa/app/xfa_ffpath.cpp
index 186d1b1dbd..854a028aac 100644
--- a/xfa/fxfa/app/xfa_ffpath.cpp
+++ b/xfa/fxfa/app/xfa_ffpath.cpp
@@ -7,10 +7,10 @@
#include "xfa/fxfa/app/xfa_ffpath.h"
#include "xfa/fxfa/app/xfa_ffdraw.h"
-#include "xfa/fxfa/xfa_ffapp.h"
-#include "xfa/fxfa/xfa_ffdoc.h"
-#include "xfa/fxfa/xfa_ffpageview.h"
-#include "xfa/fxfa/xfa_ffwidget.h"
+#include "xfa/fxfa/cxfa_ffapp.h"
+#include "xfa/fxfa/cxfa_ffdoc.h"
+#include "xfa/fxfa/cxfa_ffpageview.h"
+#include "xfa/fxfa/cxfa_ffwidget.h"
#include "xfa/fxgraphics/cfx_color.h"
#include "xfa/fxgraphics/cfx_path.h"
diff --git a/xfa/fxfa/app/xfa_ffpushbutton.cpp b/xfa/fxfa/app/xfa_ffpushbutton.cpp
index 2233c5a6bb..fa5c0dc9a1 100644
--- a/xfa/fxfa/app/xfa_ffpushbutton.cpp
+++ b/xfa/fxfa/app/xfa_ffpushbutton.cpp
@@ -12,9 +12,9 @@
#include "xfa/fxfa/app/cxfa_textlayout.h"
#include "xfa/fxfa/app/xfa_fffield.h"
#include "xfa/fxfa/app/xfa_ffwidgetacc.h"
-#include "xfa/fxfa/xfa_ffapp.h"
-#include "xfa/fxfa/xfa_ffpageview.h"
-#include "xfa/fxfa/xfa_ffwidget.h"
+#include "xfa/fxfa/cxfa_ffapp.h"
+#include "xfa/fxfa/cxfa_ffpageview.h"
+#include "xfa/fxfa/cxfa_ffwidget.h"
#include "xfa/fxgraphics/cfx_color.h"
#include "xfa/fxgraphics/cfx_path.h"
diff --git a/xfa/fxfa/app/xfa_ffsignature.cpp b/xfa/fxfa/app/xfa_ffsignature.cpp
index bf2bba3adf..edc34336c6 100644
--- a/xfa/fxfa/app/xfa_ffsignature.cpp
+++ b/xfa/fxfa/app/xfa_ffsignature.cpp
@@ -7,9 +7,9 @@
#include "xfa/fxfa/app/xfa_ffsignature.h"
#include "xfa/fxfa/app/xfa_fffield.h"
-#include "xfa/fxfa/xfa_ffdoc.h"
-#include "xfa/fxfa/xfa_ffpageview.h"
-#include "xfa/fxfa/xfa_ffwidget.h"
+#include "xfa/fxfa/cxfa_ffdoc.h"
+#include "xfa/fxfa/cxfa_ffpageview.h"
+#include "xfa/fxfa/cxfa_ffwidget.h"
CXFA_FFSignature::CXFA_FFSignature(CXFA_WidgetAcc* pDataAcc)
: CXFA_FFField(pDataAcc) {}
diff --git a/xfa/fxfa/app/xfa_ffsubform.cpp b/xfa/fxfa/app/xfa_ffsubform.cpp
index 0b479f4d4c..d008c5b4f9 100644
--- a/xfa/fxfa/app/xfa_ffsubform.cpp
+++ b/xfa/fxfa/app/xfa_ffsubform.cpp
@@ -6,10 +6,10 @@
#include "xfa/fxfa/app/xfa_ffsubform.h"
-#include "xfa/fxfa/xfa_ffapp.h"
-#include "xfa/fxfa/xfa_ffdoc.h"
-#include "xfa/fxfa/xfa_ffpageview.h"
-#include "xfa/fxfa/xfa_ffwidget.h"
+#include "xfa/fxfa/cxfa_ffapp.h"
+#include "xfa/fxfa/cxfa_ffdoc.h"
+#include "xfa/fxfa/cxfa_ffpageview.h"
+#include "xfa/fxfa/cxfa_ffwidget.h"
CXFA_FFSubForm::CXFA_FFSubForm(CXFA_WidgetAcc* pDataAcc)
: CXFA_FFWidget(pDataAcc) {}
diff --git a/xfa/fxfa/app/xfa_ffsubform.h b/xfa/fxfa/app/xfa_ffsubform.h
index e6b77a8b33..c87688fdce 100644
--- a/xfa/fxfa/app/xfa_ffsubform.h
+++ b/xfa/fxfa/app/xfa_ffsubform.h
@@ -7,8 +7,8 @@
#ifndef XFA_FXFA_APP_XFA_FFSUBFORM_H_
#define XFA_FXFA_APP_XFA_FFSUBFORM_H_
-#include "xfa/fxfa/xfa_ffpageview.h"
-#include "xfa/fxfa/xfa_ffwidget.h"
+#include "xfa/fxfa/cxfa_ffpageview.h"
+#include "xfa/fxfa/cxfa_ffwidget.h"
class CXFA_FFSubForm : public CXFA_FFWidget {
public:
diff --git a/xfa/fxfa/app/xfa_fftext.cpp b/xfa/fxfa/app/xfa_fftext.cpp
index c4b533f855..a314803f31 100644
--- a/xfa/fxfa/app/xfa_fftext.cpp
+++ b/xfa/fxfa/app/xfa_fftext.cpp
@@ -13,10 +13,10 @@
#include "xfa/fxfa/app/cxfa_textlayout.h"
#include "xfa/fxfa/app/xfa_ffdraw.h"
#include "xfa/fxfa/app/xfa_textpiece.h"
-#include "xfa/fxfa/xfa_ffapp.h"
-#include "xfa/fxfa/xfa_ffdoc.h"
-#include "xfa/fxfa/xfa_ffpageview.h"
-#include "xfa/fxfa/xfa_ffwidget.h"
+#include "xfa/fxfa/cxfa_ffapp.h"
+#include "xfa/fxfa/cxfa_ffdoc.h"
+#include "xfa/fxfa/cxfa_ffpageview.h"
+#include "xfa/fxfa/cxfa_ffwidget.h"
#include "xfa/fxgraphics/cfx_graphics.h"
CXFA_FFText::CXFA_FFText(CXFA_WidgetAcc* pDataAcc) : CXFA_FFDraw(pDataAcc) {}
diff --git a/xfa/fxfa/app/xfa_fftextedit.cpp b/xfa/fxfa/app/xfa_fftextedit.cpp
index b4560c88ed..34c037441e 100644
--- a/xfa/fxfa/app/xfa_fftextedit.cpp
+++ b/xfa/fxfa/app/xfa_fftextedit.cpp
@@ -21,12 +21,12 @@
#include "xfa/fxfa/app/xfa_fffield.h"
#include "xfa/fxfa/app/xfa_fwladapter.h"
#include "xfa/fxfa/cxfa_eventparam.h"
+#include "xfa/fxfa/cxfa_ffapp.h"
+#include "xfa/fxfa/cxfa_ffdoc.h"
+#include "xfa/fxfa/cxfa_ffdocview.h"
+#include "xfa/fxfa/cxfa_ffpageview.h"
+#include "xfa/fxfa/cxfa_ffwidget.h"
#include "xfa/fxfa/parser/xfa_localevalue.h"
-#include "xfa/fxfa/xfa_ffapp.h"
-#include "xfa/fxfa/xfa_ffdoc.h"
-#include "xfa/fxfa/xfa_ffdocview.h"
-#include "xfa/fxfa/xfa_ffpageview.h"
-#include "xfa/fxfa/xfa_ffwidget.h"
CXFA_FFTextEdit::CXFA_FFTextEdit(CXFA_WidgetAcc* pDataAcc)
: CXFA_FFField(pDataAcc), m_pOldDelegate(nullptr) {}
diff --git a/xfa/fxfa/app/xfa_ffwidgetacc.cpp b/xfa/fxfa/app/xfa_ffwidgetacc.cpp
index 4afd5e8023..9b531ed4fc 100644
--- a/xfa/fxfa/app/xfa_ffwidgetacc.cpp
+++ b/xfa/fxfa/app/xfa_ffwidgetacc.cpp
@@ -20,1503 +20,17 @@
#include "xfa/fxfa/app/xfa_fffield.h"
#include "xfa/fxfa/app/xfa_fwladapter.h"
#include "xfa/fxfa/cxfa_eventparam.h"
+#include "xfa/fxfa/cxfa_ffapp.h"
+#include "xfa/fxfa/cxfa_ffdoc.h"
+#include "xfa/fxfa/cxfa_ffdocview.h"
+#include "xfa/fxfa/cxfa_ffpageview.h"
+#include "xfa/fxfa/cxfa_ffwidget.h"
+#include "xfa/fxfa/cxfa_fontmgr.h"
#include "xfa/fxfa/parser/cxfa_layoutprocessor.h"
#include "xfa/fxfa/parser/cxfa_scriptcontext.h"
#include "xfa/fxfa/parser/xfa_localevalue.h"
#include "xfa/fxfa/parser/xfa_resolvenode_rs.h"
-#include "xfa/fxfa/xfa_ffapp.h"
-#include "xfa/fxfa/xfa_ffdoc.h"
-#include "xfa/fxfa/xfa_ffdocview.h"
-#include "xfa/fxfa/xfa_ffpageview.h"
-#include "xfa/fxfa/xfa_ffwidget.h"
-#include "xfa/fxfa/xfa_fontmgr.h"
-static void XFA_FFDeleteCalcData(void* pData) {
- if (pData) {
- delete ((CXFA_CalcData*)pData);
- }
-}
-
-static XFA_MAPDATABLOCKCALLBACKINFO gs_XFADeleteCalcData = {
- XFA_FFDeleteCalcData, nullptr};
-
-class CXFA_WidgetLayoutData {
- public:
- CXFA_WidgetLayoutData() : m_fWidgetHeight(-1) {}
- virtual ~CXFA_WidgetLayoutData() {}
-
- float m_fWidgetHeight;
-};
-
-class CXFA_TextLayoutData : public CXFA_WidgetLayoutData {
- public:
- CXFA_TextLayoutData() {}
- ~CXFA_TextLayoutData() override {}
-
- CXFA_TextLayout* GetTextLayout() const { return m_pTextLayout.get(); }
- CXFA_TextProvider* GetTextProvider() const { return m_pTextProvider.get(); }
-
- void LoadText(CXFA_WidgetAcc* pAcc) {
- if (m_pTextLayout)
- return;
-
- m_pTextProvider =
- pdfium::MakeUnique<CXFA_TextProvider>(pAcc, XFA_TEXTPROVIDERTYPE_Text);
- m_pTextLayout = pdfium::MakeUnique<CXFA_TextLayout>(m_pTextProvider.get());
- }
-
- private:
- std::unique_ptr<CXFA_TextLayout> m_pTextLayout;
- std::unique_ptr<CXFA_TextProvider> m_pTextProvider;
-};
-
-class CXFA_ImageLayoutData : public CXFA_WidgetLayoutData {
- public:
- CXFA_ImageLayoutData()
- : m_pDIBitmap(nullptr),
- m_bNamedImage(false),
- m_iImageXDpi(0),
- m_iImageYDpi(0) {}
-
- ~CXFA_ImageLayoutData() override {
- if (m_pDIBitmap && !m_bNamedImage)
- delete m_pDIBitmap;
- }
-
- bool LoadImageData(CXFA_WidgetAcc* pAcc) {
- if (m_pDIBitmap)
- return true;
-
- CXFA_Value value = pAcc->GetFormValue();
- if (!value)
- return false;
-
- CXFA_Image imageObj = value.GetImage();
- if (!imageObj)
- return false;
-
- CXFA_FFDoc* pFFDoc = pAcc->GetDoc();
- pAcc->SetImageImage(XFA_LoadImageData(pFFDoc, &imageObj, m_bNamedImage,
- m_iImageXDpi, m_iImageYDpi));
- return !!m_pDIBitmap;
- }
-
- CFX_DIBitmap* m_pDIBitmap;
- bool m_bNamedImage;
- int32_t m_iImageXDpi;
- int32_t m_iImageYDpi;
-};
-
-class CXFA_FieldLayoutData : public CXFA_WidgetLayoutData {
- public:
- CXFA_FieldLayoutData() {}
- ~CXFA_FieldLayoutData() override {}
-
- bool LoadCaption(CXFA_WidgetAcc* pAcc) {
- if (m_pCapTextLayout)
- return true;
- CXFA_Caption caption = pAcc->GetCaption();
- if (!caption || caption.GetPresence() == XFA_ATTRIBUTEENUM_Hidden)
- return false;
- m_pCapTextProvider.reset(
- new CXFA_TextProvider(pAcc, XFA_TEXTPROVIDERTYPE_Caption));
- m_pCapTextLayout =
- pdfium::MakeUnique<CXFA_TextLayout>(m_pCapTextProvider.get());
- return true;
- }
-
- std::unique_ptr<CXFA_TextLayout> m_pCapTextLayout;
- std::unique_ptr<CXFA_TextProvider> m_pCapTextProvider;
- std::unique_ptr<CFDE_TextOut> m_pTextOut;
- std::vector<float> m_FieldSplitArray;
-};
-
-class CXFA_TextEditData : public CXFA_FieldLayoutData {
- public:
-};
-
-class CXFA_ImageEditData : public CXFA_FieldLayoutData {
- public:
- CXFA_ImageEditData()
- : m_pDIBitmap(nullptr),
- m_bNamedImage(false),
- m_iImageXDpi(0),
- m_iImageYDpi(0) {}
-
- ~CXFA_ImageEditData() override {
- if (m_pDIBitmap && !m_bNamedImage)
- delete m_pDIBitmap;
- }
-
- bool LoadImageData(CXFA_WidgetAcc* pAcc) {
- if (m_pDIBitmap)
- return true;
-
- CXFA_Value value = pAcc->GetFormValue();
- if (!value)
- return false;
-
- CXFA_Image imageObj = value.GetImage();
- CXFA_FFDoc* pFFDoc = pAcc->GetDoc();
- pAcc->SetImageEditImage(XFA_LoadImageData(pFFDoc, &imageObj, m_bNamedImage,
- m_iImageXDpi, m_iImageYDpi));
- return !!m_pDIBitmap;
- }
-
- CFX_DIBitmap* m_pDIBitmap;
- bool m_bNamedImage;
- int32_t m_iImageXDpi;
- int32_t m_iImageYDpi;
-};
-
-CXFA_WidgetAcc::CXFA_WidgetAcc(CXFA_FFDocView* pDocView, CXFA_Node* pNode)
- : CXFA_WidgetData(pNode),
- m_pDocView(pDocView),
- m_nRecursionDepth(0) {}
-
-CXFA_WidgetAcc::~CXFA_WidgetAcc() {}
-
-bool CXFA_WidgetAcc::GetName(CFX_WideString& wsName, int32_t iNameType) {
- if (iNameType == 0) {
- m_pNode->TryCData(XFA_ATTRIBUTE_Name, wsName);
- return !wsName.IsEmpty();
- }
- m_pNode->GetSOMExpression(wsName);
- if (iNameType == 2 && wsName.GetLength() >= 15) {
- CFX_WideStringC wsPre = L"xfa[0].form[0].";
- if (wsPre == CFX_WideStringC(wsName.c_str(), wsPre.GetLength())) {
- wsName.Delete(0, wsPre.GetLength());
- }
- }
- return true;
-}
-CXFA_Node* CXFA_WidgetAcc::GetDatasets() {
- return m_pNode->GetBindData();
-}
-bool CXFA_WidgetAcc::ProcessValueChanged() {
- m_pDocView->AddValidateWidget(this);
- m_pDocView->AddCalculateWidgetAcc(this);
- m_pDocView->RunCalculateWidgets();
- m_pDocView->RunValidate();
- return true;
-}
-void CXFA_WidgetAcc::ResetData() {
- CFX_WideString wsValue;
- XFA_Element eUIType = GetUIType();
- switch (eUIType) {
- case XFA_Element::ImageEdit: {
- CXFA_Value imageValue = GetDefaultValue();
- CXFA_Image image = imageValue.GetImage();
- CFX_WideString wsContentType, wsHref;
- if (image) {
- image.GetContent(wsValue);
- image.GetContentType(wsContentType);
- image.GetHref(wsHref);
- }
- SetImageEdit(wsContentType, wsHref, wsValue);
- } break;
- case XFA_Element::ExclGroup: {
- CXFA_Node* pNextChild = m_pNode->GetNodeItem(
- XFA_NODEITEM_FirstChild, XFA_ObjectType::ContainerNode);
- while (pNextChild) {
- CXFA_Node* pChild = pNextChild;
- CXFA_WidgetAcc* pAcc =
- static_cast<CXFA_WidgetAcc*>(pChild->GetWidgetData());
- if (!pAcc) {
- continue;
- }
- CXFA_Value defValue(nullptr);
- if (wsValue.IsEmpty() && (defValue = pAcc->GetDefaultValue())) {
- defValue.GetChildValueContent(wsValue);
- SetValue(wsValue, XFA_VALUEPICTURE_Raw);
- pAcc->SetValue(wsValue, XFA_VALUEPICTURE_Raw);
- } else {
- CXFA_Node* pItems = pChild->GetChild(0, XFA_Element::Items);
- if (!pItems) {
- continue;
- }
- CFX_WideString itemText;
- if (pItems->CountChildren(XFA_Element::Unknown) > 1) {
- itemText = pItems->GetChild(1, XFA_Element::Unknown)->GetContent();
- }
- pAcc->SetValue(itemText, XFA_VALUEPICTURE_Raw);
- }
- pNextChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling,
- XFA_ObjectType::ContainerNode);
- }
- } break;
- case XFA_Element::ChoiceList:
- ClearAllSelections();
- default:
- if (CXFA_Value defValue = GetDefaultValue()) {
- defValue.GetChildValueContent(wsValue);
- }
- SetValue(wsValue, XFA_VALUEPICTURE_Raw);
- break;
- }
-}
-void CXFA_WidgetAcc::SetImageEdit(const CFX_WideString& wsContentType,
- const CFX_WideString& wsHref,
- const CFX_WideString& wsData) {
- CXFA_Image image = GetFormValue().GetImage();
- if (image) {
- image.SetContentType(CFX_WideString(wsContentType));
- image.SetHref(wsHref);
- }
- CFX_WideString wsFormatValue(wsData);
- GetFormatDataValue(wsData, wsFormatValue);
- m_pNode->SetContent(wsData, wsFormatValue, true);
- CXFA_Node* pBind = GetDatasets();
- if (!pBind) {
- image.SetTransferEncoding(XFA_ATTRIBUTEENUM_Base64);
- return;
- }
- pBind->SetCData(XFA_ATTRIBUTE_ContentType, wsContentType);
- CXFA_Node* pHrefNode = pBind->GetNodeItem(XFA_NODEITEM_FirstChild);
- if (pHrefNode) {
- pHrefNode->SetCData(XFA_ATTRIBUTE_Value, wsHref);
- } else {
- CFDE_XMLNode* pXMLNode = pBind->GetXMLMappingNode();
- ASSERT(pXMLNode && pXMLNode->GetType() == FDE_XMLNODE_Element);
- static_cast<CFDE_XMLElement*>(pXMLNode)->SetString(L"href", wsHref);
- }
-}
-
-CXFA_WidgetAcc* CXFA_WidgetAcc::GetExclGroup() {
- CXFA_Node* pExcl = m_pNode->GetNodeItem(XFA_NODEITEM_Parent);
- if (!pExcl || pExcl->GetElementType() != XFA_Element::ExclGroup) {
- return nullptr;
- }
- return static_cast<CXFA_WidgetAcc*>(pExcl->GetWidgetData());
-}
-CXFA_FFDocView* CXFA_WidgetAcc::GetDocView() {
- return m_pDocView;
-}
-CXFA_FFDoc* CXFA_WidgetAcc::GetDoc() {
- return m_pDocView->GetDoc();
-}
-CXFA_FFApp* CXFA_WidgetAcc::GetApp() {
- return GetDoc()->GetApp();
-}
-IXFA_AppProvider* CXFA_WidgetAcc::GetAppProvider() {
- return GetApp()->GetAppProvider();
-}
-int32_t CXFA_WidgetAcc::ProcessEvent(int32_t iActivity,
- CXFA_EventParam* pEventParam) {
- if (GetElementType() == XFA_Element::Draw)
- return XFA_EVENTERROR_NotExist;
-
- std::vector<CXFA_Node*> eventArray =
- GetEventByActivity(iActivity, pEventParam->m_bIsFormReady);
- bool first = true;
- int32_t iRet = XFA_EVENTERROR_NotExist;
- for (CXFA_Node* pNode : eventArray) {
- int32_t result = ProcessEvent(CXFA_Event(pNode), pEventParam);
- if (first || result == XFA_EVENTERROR_Success)
- iRet = result;
- first = false;
- }
- return iRet;
-}
-int32_t CXFA_WidgetAcc::ProcessEvent(const CXFA_Event& event,
- CXFA_EventParam* pEventParam) {
- if (!event)
- return XFA_EVENTERROR_NotExist;
-
- switch (event.GetEventType()) {
- case XFA_Element::Execute:
- break;
- case XFA_Element::Script:
- return ExecuteScript(event.GetScript(), pEventParam);
- case XFA_Element::SignData:
- break;
- case XFA_Element::Submit:
- return GetDoc()->GetDocEnvironment()->SubmitData(GetDoc(),
- event.GetSubmit());
- default:
- break;
- }
- return XFA_EVENTERROR_NotExist;
-}
-
-int32_t CXFA_WidgetAcc::ProcessCalculate() {
- if (GetElementType() == XFA_Element::Draw)
- return XFA_EVENTERROR_NotExist;
-
- CXFA_Calculate calc = GetCalculate();
- if (!calc)
- return XFA_EVENTERROR_NotExist;
- if (GetNode()->IsUserInteractive())
- return XFA_EVENTERROR_Disabled;
-
- CXFA_EventParam EventParam;
- EventParam.m_eType = XFA_EVENT_Calculate;
- CXFA_Script script = calc.GetScript();
- int32_t iRet = ExecuteScript(script, &EventParam);
- if (iRet != XFA_EVENTERROR_Success)
- return iRet;
-
- if (GetRawValue() != EventParam.m_wsResult) {
- SetValue(EventParam.m_wsResult, XFA_VALUEPICTURE_Raw);
- UpdateUIDisplay();
- }
- return XFA_EVENTERROR_Success;
-}
-
-void CXFA_WidgetAcc::ProcessScriptTestValidate(CXFA_Validate validate,
- int32_t iRet,
- CFXJSE_Value* pRetValue,
- bool bVersionFlag) {
- if (iRet == XFA_EVENTERROR_Success && pRetValue) {
- if (pRetValue->IsBoolean() && !pRetValue->ToBoolean()) {
- IXFA_AppProvider* pAppProvider = GetAppProvider();
- if (!pAppProvider) {
- return;
- }
- CFX_WideString wsTitle = pAppProvider->GetAppTitle();
- CFX_WideString wsScriptMsg;
- validate.GetScriptMessageText(wsScriptMsg);
- int32_t eScriptTest = validate.GetScriptTest();
- if (eScriptTest == XFA_ATTRIBUTEENUM_Warning) {
- if (GetNode()->IsUserInteractive())
- return;
- if (wsScriptMsg.IsEmpty())
- wsScriptMsg = GetValidateMessage(false, bVersionFlag);
-
- if (bVersionFlag) {
- pAppProvider->MsgBox(wsScriptMsg, wsTitle, XFA_MBICON_Warning,
- XFA_MB_OK);
- return;
- }
- if (pAppProvider->MsgBox(wsScriptMsg, wsTitle, XFA_MBICON_Warning,
- XFA_MB_YesNo) == XFA_IDYes) {
- GetNode()->SetFlag(XFA_NodeFlag_UserInteractive, false);
- }
- } else {
- if (wsScriptMsg.IsEmpty())
- wsScriptMsg = GetValidateMessage(true, bVersionFlag);
- pAppProvider->MsgBox(wsScriptMsg, wsTitle, XFA_MBICON_Error, XFA_MB_OK);
- }
- }
- }
-}
-int32_t CXFA_WidgetAcc::ProcessFormatTestValidate(CXFA_Validate validate,
- bool bVersionFlag) {
- CFX_WideString wsRawValue = GetRawValue();
- if (!wsRawValue.IsEmpty()) {
- CFX_WideString wsPicture;
- validate.GetPicture(wsPicture);
- if (wsPicture.IsEmpty()) {
- return XFA_EVENTERROR_NotExist;
- }
- IFX_Locale* pLocale = GetLocal();
- if (!pLocale) {
- return XFA_EVENTERROR_NotExist;
- }
- CXFA_LocaleValue lcValue = XFA_GetLocaleValue(this);
- if (!lcValue.ValidateValue(lcValue.GetValue(), wsPicture, pLocale)) {
- IXFA_AppProvider* pAppProvider = GetAppProvider();
- if (!pAppProvider) {
- return XFA_EVENTERROR_NotExist;
- }
- CFX_WideString wsFormatMsg;
- validate.GetFormatMessageText(wsFormatMsg);
- CFX_WideString wsTitle = pAppProvider->GetAppTitle();
- int32_t eFormatTest = validate.GetFormatTest();
- if (eFormatTest == XFA_ATTRIBUTEENUM_Error) {
- if (wsFormatMsg.IsEmpty())
- wsFormatMsg = GetValidateMessage(true, bVersionFlag);
- pAppProvider->MsgBox(wsFormatMsg, wsTitle, XFA_MBICON_Error, XFA_MB_OK);
- return XFA_EVENTERROR_Success;
- }
- if (GetNode()->IsUserInteractive())
- return XFA_EVENTERROR_NotExist;
- if (wsFormatMsg.IsEmpty())
- wsFormatMsg = GetValidateMessage(false, bVersionFlag);
-
- if (bVersionFlag) {
- pAppProvider->MsgBox(wsFormatMsg, wsTitle, XFA_MBICON_Warning,
- XFA_MB_OK);
- return XFA_EVENTERROR_Success;
- }
- if (pAppProvider->MsgBox(wsFormatMsg, wsTitle, XFA_MBICON_Warning,
- XFA_MB_YesNo) == XFA_IDYes) {
- GetNode()->SetFlag(XFA_NodeFlag_UserInteractive, false);
- }
- return XFA_EVENTERROR_Success;
- }
- }
- return XFA_EVENTERROR_NotExist;
-}
-int32_t CXFA_WidgetAcc::ProcessNullTestValidate(CXFA_Validate validate,
- int32_t iFlags,
- bool bVersionFlag) {
- CFX_WideString wsValue;
- GetValue(wsValue, XFA_VALUEPICTURE_Raw);
- if (!wsValue.IsEmpty()) {
- return XFA_EVENTERROR_Success;
- }
- if (m_bIsNull && (m_bPreNull == m_bIsNull)) {
- return XFA_EVENTERROR_Success;
- }
- int32_t eNullTest = validate.GetNullTest();
- CFX_WideString wsNullMsg;
- validate.GetNullMessageText(wsNullMsg);
- if (iFlags & 0x01) {
- int32_t iRet = XFA_EVENTERROR_Success;
- if (eNullTest != XFA_ATTRIBUTEENUM_Disabled) {
- iRet = XFA_EVENTERROR_Error;
- }
- if (!wsNullMsg.IsEmpty()) {
- if (eNullTest != XFA_ATTRIBUTEENUM_Disabled) {
- m_pDocView->m_arrNullTestMsg.push_back(wsNullMsg);
- return XFA_EVENTERROR_Error;
- }
- return XFA_EVENTERROR_Success;
- }
- return iRet;
- }
- if (wsNullMsg.IsEmpty() && bVersionFlag &&
- eNullTest != XFA_ATTRIBUTEENUM_Disabled) {
- return XFA_EVENTERROR_Error;
- }
- IXFA_AppProvider* pAppProvider = GetAppProvider();
- if (!pAppProvider) {
- return XFA_EVENTERROR_NotExist;
- }
- CFX_WideString wsCaptionName;
- CFX_WideString wsTitle = pAppProvider->GetAppTitle();
- switch (eNullTest) {
- case XFA_ATTRIBUTEENUM_Error: {
- if (wsNullMsg.IsEmpty()) {
- wsCaptionName = GetValidateCaptionName(bVersionFlag);
- wsNullMsg.Format(L"%s cannot be blank.", wsCaptionName.c_str());
- }
- pAppProvider->MsgBox(wsNullMsg, wsTitle, XFA_MBICON_Status, XFA_MB_OK);
- return XFA_EVENTERROR_Error;
- }
- case XFA_ATTRIBUTEENUM_Warning: {
- if (GetNode()->IsUserInteractive())
- return true;
-
- if (wsNullMsg.IsEmpty()) {
- wsCaptionName = GetValidateCaptionName(bVersionFlag);
- wsNullMsg.Format(
- L"%s cannot be blank. To ignore validations for %s, click Ignore.",
- wsCaptionName.c_str(), wsCaptionName.c_str());
- }
- if (pAppProvider->MsgBox(wsNullMsg, wsTitle, XFA_MBICON_Warning,
- XFA_MB_YesNo) == XFA_IDYes) {
- GetNode()->SetFlag(XFA_NodeFlag_UserInteractive, false);
- }
- return XFA_EVENTERROR_Error;
- }
- case XFA_ATTRIBUTEENUM_Disabled:
- default:
- break;
- }
- return XFA_EVENTERROR_Success;
-}
-
-CFX_WideString CXFA_WidgetAcc::GetValidateCaptionName(bool bVersionFlag) {
- CFX_WideString wsCaptionName;
-
- if (!bVersionFlag) {
- if (CXFA_Caption caption = GetCaption()) {
- if (CXFA_Value capValue = caption.GetValue()) {
- if (CXFA_Text capText = capValue.GetText())
- capText.GetContent(wsCaptionName);
- }
- }
- }
- if (wsCaptionName.IsEmpty())
- GetName(wsCaptionName);
-
- return wsCaptionName;
-}
-
-CFX_WideString CXFA_WidgetAcc::GetValidateMessage(bool bError,
- bool bVersionFlag) {
- CFX_WideString wsCaptionName = GetValidateCaptionName(bVersionFlag);
- CFX_WideString wsMessage;
- if (bVersionFlag) {
- wsMessage.Format(L"%s validation failed", wsCaptionName.c_str());
- return wsMessage;
- }
- if (bError) {
- wsMessage.Format(L"The value you entered for %s is invalid.",
- wsCaptionName.c_str());
- return wsMessage;
- }
- wsMessage.Format(
- L"The value you entered for %s is invalid. To ignore "
- L"validations for %s, click Ignore.",
- wsCaptionName.c_str(), wsCaptionName.c_str());
- return wsMessage;
-}
-
-int32_t CXFA_WidgetAcc::ProcessValidate(int32_t iFlags) {
- if (GetElementType() == XFA_Element::Draw) {
- return XFA_EVENTERROR_NotExist;
- }
- CXFA_Validate validate = GetValidate();
- if (!validate) {
- return XFA_EVENTERROR_NotExist;
- }
- bool bInitDoc = validate.GetNode()->NeedsInitApp();
- bool bStatus = m_pDocView->GetLayoutStatus() < XFA_DOCVIEW_LAYOUTSTATUS_End;
- int32_t iFormat = 0;
- CFXJSE_Value* pRetValue = nullptr;
- int32_t iRet = XFA_EVENTERROR_NotExist;
- CXFA_Script script = validate.GetScript();
- if (script) {
- CXFA_EventParam eParam;
- eParam.m_eType = XFA_EVENT_Validate;
- eParam.m_pTarget = this;
- iRet = ExecuteScript(script, &eParam,
- ((bInitDoc || bStatus) && GetRawValue().IsEmpty())
- ? nullptr
- : &pRetValue);
- }
- XFA_VERSION version = GetDoc()->GetXFADoc()->GetCurVersionMode();
- bool bVersionFlag = false;
- if (version < XFA_VERSION_208) {
- bVersionFlag = true;
- }
- if (bInitDoc) {
- validate.GetNode()->ClearFlag(XFA_NodeFlag_NeedsInitApp);
- } else {
- iFormat = ProcessFormatTestValidate(validate, bVersionFlag);
- if (!bVersionFlag) {
- bVersionFlag = GetDoc()->GetXFADoc()->HasFlag(XFA_DOCFLAG_Scripting);
- }
- iRet |= ProcessNullTestValidate(validate, iFlags, bVersionFlag);
- }
- if (iFormat != XFA_EVENTERROR_Success) {
- ProcessScriptTestValidate(validate, iRet, pRetValue, bVersionFlag);
- }
- delete pRetValue;
-
- return iRet | iFormat;
-}
-int32_t CXFA_WidgetAcc::ExecuteScript(CXFA_Script script,
- CXFA_EventParam* pEventParam,
- CFXJSE_Value** pRetValue) {
- static const uint32_t MAX_RECURSION_DEPTH = 2;
- if (m_nRecursionDepth > MAX_RECURSION_DEPTH)
- return XFA_EVENTERROR_Success;
- ASSERT(pEventParam);
- if (!script) {
- return XFA_EVENTERROR_NotExist;
- }
- if (script.GetRunAt() == XFA_ATTRIBUTEENUM_Server) {
- return XFA_EVENTERROR_Disabled;
- }
- CFX_WideString wsExpression;
- script.GetExpression(wsExpression);
- if (wsExpression.IsEmpty()) {
- return XFA_EVENTERROR_NotExist;
- }
- XFA_SCRIPTTYPE eScriptType = script.GetContentType();
- if (eScriptType == XFA_SCRIPTTYPE_Unkown) {
- return XFA_EVENTERROR_Success;
- }
- CXFA_FFDoc* pDoc = GetDoc();
- CXFA_ScriptContext* pContext = pDoc->GetXFADoc()->GetScriptContext();
- pContext->SetEventParam(*pEventParam);
- pContext->SetRunAtType((XFA_ATTRIBUTEENUM)script.GetRunAt());
- std::vector<CXFA_Node*> refNodes;
- if (pEventParam->m_eType == XFA_EVENT_InitCalculate ||
- pEventParam->m_eType == XFA_EVENT_Calculate) {
- pContext->SetNodesOfRunScript(&refNodes);
- }
- std::unique_ptr<CFXJSE_Value> pTmpRetValue(
- new CFXJSE_Value(pContext->GetRuntime()));
- ++m_nRecursionDepth;
- bool bRet = pContext->RunScript((XFA_SCRIPTLANGTYPE)eScriptType,
- wsExpression.AsStringC(), pTmpRetValue.get(),
- m_pNode);
- --m_nRecursionDepth;
- int32_t iRet = XFA_EVENTERROR_Error;
- if (bRet) {
- iRet = XFA_EVENTERROR_Success;
- if (pEventParam->m_eType == XFA_EVENT_Calculate ||
- pEventParam->m_eType == XFA_EVENT_InitCalculate) {
- if (!pTmpRetValue->IsUndefined()) {
- if (!pTmpRetValue->IsNull())
- pEventParam->m_wsResult = pTmpRetValue->ToWideString();
-
- iRet = XFA_EVENTERROR_Success;
- } else {
- iRet = XFA_EVENTERROR_Error;
- }
- if (pEventParam->m_eType == XFA_EVENT_InitCalculate) {
- if ((iRet == XFA_EVENTERROR_Success) &&
- (GetRawValue() != pEventParam->m_wsResult)) {
- SetValue(pEventParam->m_wsResult, XFA_VALUEPICTURE_Raw);
- m_pDocView->AddValidateWidget(this);
- }
- }
- for (CXFA_Node* pRefNode : refNodes) {
- if (static_cast<CXFA_WidgetAcc*>(pRefNode->GetWidgetData()) == this)
- continue;
-
- auto* pGlobalData =
- static_cast<CXFA_CalcData*>(pRefNode->GetUserData(XFA_CalcData));
- if (!pGlobalData) {
- pGlobalData = new CXFA_CalcData;
- pRefNode->SetUserData(XFA_CalcData, pGlobalData,
- &gs_XFADeleteCalcData);
- }
- if (!pdfium::ContainsValue(pGlobalData->m_Globals, this))
- pGlobalData->m_Globals.push_back(this);
- }
- }
- }
- if (pRetValue)
- *pRetValue = pTmpRetValue.release();
-
- pContext->SetNodesOfRunScript(nullptr);
- return iRet;
-}
-CXFA_FFWidget* CXFA_WidgetAcc::GetNextWidget(CXFA_FFWidget* pWidget) {
- CXFA_LayoutItem* pLayout = nullptr;
- if (pWidget) {
- pLayout = pWidget->GetNext();
- } else {
- pLayout = m_pDocView->GetXFALayout()->GetLayoutItem(m_pNode);
- }
- return static_cast<CXFA_FFWidget*>(pLayout);
-}
-void CXFA_WidgetAcc::UpdateUIDisplay(CXFA_FFWidget* pExcept) {
- CXFA_FFWidget* pWidget = nullptr;
- while ((pWidget = GetNextWidget(pWidget)) != nullptr) {
- if (pWidget == pExcept || !pWidget->IsLoaded() ||
- (GetUIType() != XFA_Element::CheckButton && pWidget->IsFocused())) {
- continue;
- }
- pWidget->UpdateFWLData();
- pWidget->AddInvalidateRect();
- }
-}
-
-void CXFA_WidgetAcc::CalcCaptionSize(CFX_SizeF& szCap) {
- CXFA_Caption caption = GetCaption();
- if (!caption || caption.GetPresence() != XFA_ATTRIBUTEENUM_Visible) {
- return;
- }
- LoadCaption();
- XFA_Element eUIType = GetUIType();
- int32_t iCapPlacement = caption.GetPlacementType();
- float fCapReserve = caption.GetReserve();
- const bool bVert = iCapPlacement == XFA_ATTRIBUTEENUM_Top ||
- iCapPlacement == XFA_ATTRIBUTEENUM_Bottom;
- const bool bReserveExit = fCapReserve > 0.01;
- CXFA_TextLayout* pCapTextLayout =
- static_cast<CXFA_FieldLayoutData*>(m_pLayoutData.get())
- ->m_pCapTextLayout.get();
- if (pCapTextLayout) {
- if (!bVert && eUIType != XFA_Element::Button) {
- szCap.width = fCapReserve;
- }
- CFX_SizeF minSize;
- pCapTextLayout->CalcSize(minSize, szCap, szCap);
- if (bReserveExit) {
- bVert ? szCap.height = fCapReserve : szCap.width = fCapReserve;
- }
- } else {
- float fFontSize = 10.0f;
- if (CXFA_Font font = caption.GetFont()) {
- fFontSize = font.GetFontSize();
- } else if (CXFA_Font widgetfont = GetFont()) {
- fFontSize = widgetfont.GetFontSize();
- }
- if (bVert) {
- szCap.height = fCapReserve > 0 ? fCapReserve : fFontSize;
- } else {
- szCap.width = fCapReserve > 0 ? fCapReserve : 0;
- szCap.height = fFontSize;
- }
- }
- if (CXFA_Margin mgCap = caption.GetMargin()) {
- float fLeftInset, fTopInset, fRightInset, fBottomInset;
- mgCap.GetLeftInset(fLeftInset);
- mgCap.GetTopInset(fTopInset);
- mgCap.GetRightInset(fRightInset);
- mgCap.GetBottomInset(fBottomInset);
- if (bReserveExit) {
- bVert ? (szCap.width += fLeftInset + fRightInset)
- : (szCap.height += fTopInset + fBottomInset);
- } else {
- szCap.width += fLeftInset + fRightInset;
- szCap.height += fTopInset + fBottomInset;
- }
- }
-}
-bool CXFA_WidgetAcc::CalculateFieldAutoSize(CFX_SizeF& size) {
- CFX_SizeF szCap;
- CalcCaptionSize(szCap);
- CFX_RectF rtUIMargin = GetUIMargin();
- size.width += rtUIMargin.left + rtUIMargin.width;
- size.height += rtUIMargin.top + rtUIMargin.height;
- if (szCap.width > 0 && szCap.height > 0) {
- int32_t iCapPlacement = GetCaption().GetPlacementType();
- switch (iCapPlacement) {
- case XFA_ATTRIBUTEENUM_Left:
- case XFA_ATTRIBUTEENUM_Right:
- case XFA_ATTRIBUTEENUM_Inline: {
- size.width += szCap.width;
- size.height = std::max(size.height, szCap.height);
- } break;
- case XFA_ATTRIBUTEENUM_Top:
- case XFA_ATTRIBUTEENUM_Bottom: {
- size.height += szCap.height;
- size.width = std::max(size.width, szCap.width);
- }
- default:
- break;
- }
- }
- return CalculateWidgetAutoSize(size);
-}
-bool CXFA_WidgetAcc::CalculateWidgetAutoSize(CFX_SizeF& size) {
- CXFA_Margin mgWidget = GetMargin();
- if (mgWidget) {
- float fLeftInset, fTopInset, fRightInset, fBottomInset;
- mgWidget.GetLeftInset(fLeftInset);
- mgWidget.GetTopInset(fTopInset);
- mgWidget.GetRightInset(fRightInset);
- mgWidget.GetBottomInset(fBottomInset);
- size.width += fLeftInset + fRightInset;
- size.height += fTopInset + fBottomInset;
- }
- CXFA_Para para = GetPara();
- if (para)
- size.width += para.GetMarginLeft() + para.GetTextIndent();
-
- float fVal = 0;
- float fMin = 0;
- float fMax = 0;
- if (GetWidth(fVal)) {
- size.width = fVal;
- } else {
- if (GetMinWidth(fMin))
- size.width = std::max(size.width, fMin);
- if (GetMaxWidth(fMax) && fMax > 0)
- size.width = std::min(size.width, fMax);
- }
- fVal = 0;
- fMin = 0;
- fMax = 0;
- if (GetHeight(fVal)) {
- size.height = fVal;
- } else {
- if (GetMinHeight(fMin))
- size.height = std::max(size.height, fMin);
- if (GetMaxHeight(fMax) && fMax > 0)
- size.height = std::min(size.height, fMax);
- }
- return true;
-}
-
-void CXFA_WidgetAcc::CalculateTextContentSize(CFX_SizeF& size) {
- float fFontSize = GetFontSize();
- CFX_WideString wsText;
- GetValue(wsText, XFA_VALUEPICTURE_Display);
- if (wsText.IsEmpty()) {
- size.height += fFontSize;
- return;
- }
-
- wchar_t wcEnter = '\n';
- wchar_t wsLast = wsText.GetAt(wsText.GetLength() - 1);
- if (wsLast == wcEnter) {
- wsText = wsText + wcEnter;
- }
-
- CXFA_FieldLayoutData* layoutData =
- static_cast<CXFA_FieldLayoutData*>(m_pLayoutData.get());
- if (!layoutData->m_pTextOut) {
- layoutData->m_pTextOut = pdfium::MakeUnique<CFDE_TextOut>();
- CFDE_TextOut* pTextOut = layoutData->m_pTextOut.get();
- pTextOut->SetFont(GetFDEFont());
- pTextOut->SetFontSize(fFontSize);
- pTextOut->SetLineBreakTolerance(fFontSize * 0.2f);
- pTextOut->SetLineSpace(GetLineHeight());
- uint32_t dwStyles = FDE_TTOSTYLE_LastLineHeight;
- if (GetUIType() == XFA_Element::TextEdit && IsMultiLine()) {
- dwStyles |= FDE_TTOSTYLE_LineWrap;
- }
- pTextOut->SetStyles(dwStyles);
- }
- layoutData->m_pTextOut->CalcLogicSize(wsText.c_str(), wsText.GetLength(),
- size);
-}
-bool CXFA_WidgetAcc::CalculateTextEditAutoSize(CFX_SizeF& size) {
- if (size.width > 0) {
- CFX_SizeF szOrz = size;
- CFX_SizeF szCap;
- CalcCaptionSize(szCap);
- bool bCapExit = szCap.width > 0.01 && szCap.height > 0.01;
- int32_t iCapPlacement = XFA_ATTRIBUTEENUM_Unknown;
- if (bCapExit) {
- iCapPlacement = GetCaption().GetPlacementType();
- switch (iCapPlacement) {
- case XFA_ATTRIBUTEENUM_Left:
- case XFA_ATTRIBUTEENUM_Right:
- case XFA_ATTRIBUTEENUM_Inline: {
- size.width -= szCap.width;
- }
- default:
- break;
- }
- }
- CFX_RectF rtUIMargin = GetUIMargin();
- size.width -= rtUIMargin.left + rtUIMargin.width;
- CXFA_Margin mgWidget = GetMargin();
- if (mgWidget) {
- float fLeftInset, fRightInset;
- mgWidget.GetLeftInset(fLeftInset);
- mgWidget.GetRightInset(fRightInset);
- size.width -= fLeftInset + fRightInset;
- }
- CalculateTextContentSize(size);
- size.height += rtUIMargin.top + rtUIMargin.height;
- if (bCapExit) {
- switch (iCapPlacement) {
- case XFA_ATTRIBUTEENUM_Left:
- case XFA_ATTRIBUTEENUM_Right:
- case XFA_ATTRIBUTEENUM_Inline: {
- size.height = std::max(size.height, szCap.height);
- } break;
- case XFA_ATTRIBUTEENUM_Top:
- case XFA_ATTRIBUTEENUM_Bottom: {
- size.height += szCap.height;
- }
- default:
- break;
- }
- }
- size.width = szOrz.width;
- return CalculateWidgetAutoSize(size);
- }
- CalculateTextContentSize(size);
- return CalculateFieldAutoSize(size);
-}
-bool CXFA_WidgetAcc::CalculateCheckButtonAutoSize(CFX_SizeF& size) {
- float fCheckSize = GetCheckButtonSize();
- size = CFX_SizeF(fCheckSize, fCheckSize);
- return CalculateFieldAutoSize(size);
-}
-bool CXFA_WidgetAcc::CalculatePushButtonAutoSize(CFX_SizeF& size) {
- CalcCaptionSize(size);
- return CalculateWidgetAutoSize(size);
-}
-bool CXFA_WidgetAcc::CalculateImageAutoSize(CFX_SizeF& size) {
- if (!GetImageImage()) {
- LoadImageImage();
- }
- size.clear();
- if (CFX_DIBitmap* pBitmap = GetImageImage()) {
- int32_t iImageXDpi = 0;
- int32_t iImageYDpi = 0;
- GetImageDpi(iImageXDpi, iImageYDpi);
- CFX_RectF rtImage(
- 0, 0, XFA_UnitPx2Pt((float)pBitmap->GetWidth(), (float)iImageXDpi),
- XFA_UnitPx2Pt((float)pBitmap->GetHeight(), (float)iImageYDpi));
-
- CFX_RectF rtFit;
- if (GetWidth(rtFit.width)) {
- GetWidthWithoutMargin(rtFit.width);
- } else {
- rtFit.width = rtImage.width;
- }
- if (GetHeight(rtFit.height)) {
- GetHeightWithoutMargin(rtFit.height);
- } else {
- rtFit.height = rtImage.height;
- }
- size = rtFit.Size();
- }
- return CalculateWidgetAutoSize(size);
-}
-bool CXFA_WidgetAcc::CalculateImageEditAutoSize(CFX_SizeF& size) {
- if (!GetImageEditImage()) {
- LoadImageEditImage();
- }
- size.clear();
- if (CFX_DIBitmap* pBitmap = GetImageEditImage()) {
- int32_t iImageXDpi = 0;
- int32_t iImageYDpi = 0;
- GetImageEditDpi(iImageXDpi, iImageYDpi);
- CFX_RectF rtImage(
- 0, 0, XFA_UnitPx2Pt((float)pBitmap->GetWidth(), (float)iImageXDpi),
- XFA_UnitPx2Pt((float)pBitmap->GetHeight(), (float)iImageYDpi));
-
- CFX_RectF rtFit;
- if (GetWidth(rtFit.width)) {
- GetWidthWithoutMargin(rtFit.width);
- } else {
- rtFit.width = rtImage.width;
- }
- if (GetHeight(rtFit.height)) {
- GetHeightWithoutMargin(rtFit.height);
- } else {
- rtFit.height = rtImage.height;
- }
- size.width = rtFit.width;
- size.height = rtFit.height;
- }
- return CalculateFieldAutoSize(size);
-}
-bool CXFA_WidgetAcc::LoadImageImage() {
- InitLayoutData();
- return static_cast<CXFA_ImageLayoutData*>(m_pLayoutData.get())
- ->LoadImageData(this);
-}
-bool CXFA_WidgetAcc::LoadImageEditImage() {
- InitLayoutData();
- return static_cast<CXFA_ImageEditData*>(m_pLayoutData.get())
- ->LoadImageData(this);
-}
-void CXFA_WidgetAcc::GetImageDpi(int32_t& iImageXDpi, int32_t& iImageYDpi) {
- CXFA_ImageLayoutData* pData =
- static_cast<CXFA_ImageLayoutData*>(m_pLayoutData.get());
- iImageXDpi = pData->m_iImageXDpi;
- iImageYDpi = pData->m_iImageYDpi;
-}
-void CXFA_WidgetAcc::GetImageEditDpi(int32_t& iImageXDpi, int32_t& iImageYDpi) {
- CXFA_ImageEditData* pData =
- static_cast<CXFA_ImageEditData*>(m_pLayoutData.get());
- iImageXDpi = pData->m_iImageXDpi;
- iImageYDpi = pData->m_iImageYDpi;
-}
-bool CXFA_WidgetAcc::CalculateTextAutoSize(CFX_SizeF& size) {
- LoadText();
- CXFA_TextLayout* pTextLayout =
- static_cast<CXFA_TextLayoutData*>(m_pLayoutData.get())->GetTextLayout();
- if (pTextLayout) {
- size.width = pTextLayout->StartLayout(size.width);
- size.height = pTextLayout->GetLayoutHeight();
- }
- return CalculateWidgetAutoSize(size);
-}
-void CXFA_WidgetAcc::LoadText() {
- InitLayoutData();
- static_cast<CXFA_TextLayoutData*>(m_pLayoutData.get())->LoadText(this);
-}
-float CXFA_WidgetAcc::CalculateWidgetAutoWidth(float fWidthCalc) {
- CXFA_Margin mgWidget = GetMargin();
- if (mgWidget) {
- float fLeftInset, fRightInset;
- mgWidget.GetLeftInset(fLeftInset);
- mgWidget.GetRightInset(fRightInset);
- fWidthCalc += fLeftInset + fRightInset;
- }
- float fMin = 0, fMax = 0;
- if (GetMinWidth(fMin)) {
- fWidthCalc = std::max(fWidthCalc, fMin);
- }
- if (GetMaxWidth(fMax) && fMax > 0) {
- fWidthCalc = std::min(fWidthCalc, fMax);
- }
- return fWidthCalc;
-}
-float CXFA_WidgetAcc::GetWidthWithoutMargin(float fWidthCalc) {
- CXFA_Margin mgWidget = GetMargin();
- if (mgWidget) {
- float fLeftInset, fRightInset;
- mgWidget.GetLeftInset(fLeftInset);
- mgWidget.GetRightInset(fRightInset);
- fWidthCalc -= fLeftInset + fRightInset;
- }
- return fWidthCalc;
-}
-float CXFA_WidgetAcc::CalculateWidgetAutoHeight(float fHeightCalc) {
- CXFA_Margin mgWidget = GetMargin();
- if (mgWidget) {
- float fTopInset, fBottomInset;
- mgWidget.GetTopInset(fTopInset);
- mgWidget.GetBottomInset(fBottomInset);
- fHeightCalc += fTopInset + fBottomInset;
- }
- float fMin = 0, fMax = 0;
- if (GetMinHeight(fMin)) {
- fHeightCalc = std::max(fHeightCalc, fMin);
- }
- if (GetMaxHeight(fMax) && fMax > 0) {
- fHeightCalc = std::min(fHeightCalc, fMax);
- }
- return fHeightCalc;
-}
-float CXFA_WidgetAcc::GetHeightWithoutMargin(float fHeightCalc) {
- CXFA_Margin mgWidget = GetMargin();
- if (mgWidget) {
- float fTopInset, fBottomInset;
- mgWidget.GetTopInset(fTopInset);
- mgWidget.GetBottomInset(fBottomInset);
- fHeightCalc -= fTopInset + fBottomInset;
- }
- return fHeightCalc;
-}
-void CXFA_WidgetAcc::StartWidgetLayout(float& fCalcWidth, float& fCalcHeight) {
- InitLayoutData();
- XFA_Element eUIType = GetUIType();
- if (eUIType == XFA_Element::Text) {
- m_pLayoutData->m_fWidgetHeight = -1;
- GetHeight(m_pLayoutData->m_fWidgetHeight);
- StartTextLayout(fCalcWidth, fCalcHeight);
- return;
- }
- if (fCalcWidth > 0 && fCalcHeight > 0) {
- return;
- }
- m_pLayoutData->m_fWidgetHeight = -1;
- float fWidth = 0;
- if (fCalcWidth > 0 && fCalcHeight < 0) {
- if (!GetHeight(fCalcHeight)) {
- CalculateAccWidthAndHeight(eUIType, fCalcWidth, fCalcHeight);
- }
- m_pLayoutData->m_fWidgetHeight = fCalcHeight;
- return;
- }
- if (fCalcWidth < 0 && fCalcHeight < 0) {
- if (!GetWidth(fWidth) || !GetHeight(fCalcHeight)) {
- CalculateAccWidthAndHeight(eUIType, fWidth, fCalcHeight);
- }
- fCalcWidth = fWidth;
- }
- m_pLayoutData->m_fWidgetHeight = fCalcHeight;
-}
-void CXFA_WidgetAcc::CalculateAccWidthAndHeight(XFA_Element eUIType,
- float& fWidth,
- float& fCalcHeight) {
- CFX_SizeF sz(fWidth, m_pLayoutData->m_fWidgetHeight);
- switch (eUIType) {
- case XFA_Element::Barcode:
- case XFA_Element::ChoiceList:
- case XFA_Element::Signature:
- CalculateFieldAutoSize(sz);
- break;
- case XFA_Element::ImageEdit:
- CalculateImageEditAutoSize(sz);
- break;
- case XFA_Element::Button:
- CalculatePushButtonAutoSize(sz);
- break;
- case XFA_Element::CheckButton:
- CalculateCheckButtonAutoSize(sz);
- break;
- case XFA_Element::DateTimeEdit:
- case XFA_Element::NumericEdit:
- case XFA_Element::PasswordEdit:
- case XFA_Element::TextEdit:
- CalculateTextEditAutoSize(sz);
- break;
- case XFA_Element::Image:
- CalculateImageAutoSize(sz);
- break;
- case XFA_Element::Arc:
- case XFA_Element::Line:
- case XFA_Element::Rectangle:
- case XFA_Element::Subform:
- case XFA_Element::ExclGroup:
- CalculateWidgetAutoSize(sz);
- break;
- default:
- break;
- }
- fWidth = sz.width;
- m_pLayoutData->m_fWidgetHeight = sz.height;
- fCalcHeight = sz.height;
-}
-bool CXFA_WidgetAcc::FindSplitPos(int32_t iBlockIndex, float& fCalcHeight) {
- XFA_Element eUIType = GetUIType();
- if (eUIType == XFA_Element::Subform) {
- return false;
- }
- if (eUIType != XFA_Element::Text && eUIType != XFA_Element::TextEdit &&
- eUIType != XFA_Element::NumericEdit &&
- eUIType != XFA_Element::PasswordEdit) {
- fCalcHeight = 0;
- return true;
- }
- float fTopInset = 0;
- float fBottomInset = 0;
- if (iBlockIndex == 0) {
- CXFA_Margin mgWidget = GetMargin();
- if (mgWidget) {
- mgWidget.GetTopInset(fTopInset);
- mgWidget.GetBottomInset(fBottomInset);
- }
- CFX_RectF rtUIMargin = GetUIMargin();
- fTopInset += rtUIMargin.top;
- fBottomInset += rtUIMargin.width;
- }
- if (eUIType == XFA_Element::Text) {
- float fHeight = fCalcHeight;
- if (iBlockIndex == 0) {
- fCalcHeight = fCalcHeight - fTopInset;
- if (fCalcHeight < 0) {
- fCalcHeight = 0;
- }
- }
- CXFA_TextLayout* pTextLayout =
- static_cast<CXFA_TextLayoutData*>(m_pLayoutData.get())->GetTextLayout();
- pTextLayout->DoLayout(iBlockIndex, fCalcHeight, fCalcHeight,
- m_pLayoutData->m_fWidgetHeight - fTopInset);
- if (fCalcHeight != 0) {
- if (iBlockIndex == 0) {
- fCalcHeight = fCalcHeight + fTopInset;
- }
- if (fabs(fHeight - fCalcHeight) < XFA_FLOAT_PERCISION) {
- return false;
- }
- }
- return true;
- }
- XFA_ATTRIBUTEENUM iCapPlacement = XFA_ATTRIBUTEENUM_Unknown;
- float fCapReserve = 0;
- if (iBlockIndex == 0) {
- CXFA_Caption caption = GetCaption();
- if (caption && caption.GetPresence() != XFA_ATTRIBUTEENUM_Hidden) {
- iCapPlacement = (XFA_ATTRIBUTEENUM)caption.GetPlacementType();
- fCapReserve = caption.GetReserve();
- }
- if (iCapPlacement == XFA_ATTRIBUTEENUM_Top &&
- fCalcHeight < fCapReserve + fTopInset) {
- fCalcHeight = 0;
- return true;
- }
- if (iCapPlacement == XFA_ATTRIBUTEENUM_Bottom &&
- m_pLayoutData->m_fWidgetHeight - fCapReserve - fBottomInset) {
- fCalcHeight = 0;
- return true;
- }
- if (iCapPlacement != XFA_ATTRIBUTEENUM_Top) {
- fCapReserve = 0;
- }
- }
- CXFA_FieldLayoutData* pFieldData =
- static_cast<CXFA_FieldLayoutData*>(m_pLayoutData.get());
- int32_t iLinesCount = 0;
- float fHeight = m_pLayoutData->m_fWidgetHeight;
- CFX_WideString wsText;
- GetValue(wsText, XFA_VALUEPICTURE_Display);
- if (wsText.IsEmpty()) {
- iLinesCount = 1;
- } else {
- if (!pFieldData->m_pTextOut) {
- float fWidth = 0;
- GetWidth(fWidth);
- CalculateAccWidthAndHeight(eUIType, fWidth, fHeight);
- }
- iLinesCount = pFieldData->m_pTextOut->GetTotalLines();
- }
- std::vector<float>* pFieldArray = &pFieldData->m_FieldSplitArray;
- int32_t iFieldSplitCount = pdfium::CollectionSize<int32_t>(*pFieldArray);
- for (int32_t i = 0; i < iBlockIndex * 3; i += 3) {
- iLinesCount -= (int32_t)(*pFieldArray)[i + 1];
- fHeight -= (*pFieldArray)[i + 2];
- }
- if (iLinesCount == 0) {
- return false;
- }
- float fLineHeight = GetLineHeight();
- float fFontSize = GetFontSize();
- float fTextHeight = iLinesCount * fLineHeight - fLineHeight + fFontSize;
- float fSpaceAbove = 0;
- float fStartOffset = 0;
- if (fHeight > 0.1f && iBlockIndex == 0) {
- fStartOffset = fTopInset;
- fHeight -= (fTopInset + fBottomInset);
- if (CXFA_Para para = GetPara()) {
- fSpaceAbove = para.GetSpaceAbove();
- float fSpaceBelow = para.GetSpaceBelow();
- fHeight -= (fSpaceAbove + fSpaceBelow);
- switch (para.GetVerticalAlign()) {
- case XFA_ATTRIBUTEENUM_Top:
- fStartOffset += fSpaceAbove;
- break;
- case XFA_ATTRIBUTEENUM_Middle:
- fStartOffset += ((fHeight - fTextHeight) / 2 + fSpaceAbove);
- break;
- case XFA_ATTRIBUTEENUM_Bottom:
- fStartOffset += (fHeight - fTextHeight + fSpaceAbove);
- break;
- }
- }
- if (fStartOffset < 0.1f)
- fStartOffset = 0;
- }
- for (int32_t i = iBlockIndex - 1; iBlockIndex > 0 && i < iBlockIndex; i++) {
- fStartOffset = (*pFieldArray)[i * 3] - (*pFieldArray)[i * 3 + 2];
- if (fStartOffset < 0.1f)
- fStartOffset = 0;
- }
- if (iFieldSplitCount / 3 == (iBlockIndex + 1)) {
- (*pFieldArray)[0] = fStartOffset;
- } else {
- pFieldArray->push_back(fStartOffset);
- }
- XFA_VERSION version = GetDoc()->GetXFADoc()->GetCurVersionMode();
- bool bCanSplitNoContent = false;
- XFA_ATTRIBUTEENUM eLayoutMode;
- GetNode()
- ->GetNodeItem(XFA_NODEITEM_Parent)
- ->TryEnum(XFA_ATTRIBUTE_Layout, eLayoutMode, true);
- if ((eLayoutMode == XFA_ATTRIBUTEENUM_Position ||
- eLayoutMode == XFA_ATTRIBUTEENUM_Tb ||
- eLayoutMode == XFA_ATTRIBUTEENUM_Row ||
- eLayoutMode == XFA_ATTRIBUTEENUM_Table) &&
- version > XFA_VERSION_208) {
- bCanSplitNoContent = true;
- }
- if ((eLayoutMode == XFA_ATTRIBUTEENUM_Tb ||
- eLayoutMode == XFA_ATTRIBUTEENUM_Row ||
- eLayoutMode == XFA_ATTRIBUTEENUM_Table) &&
- version <= XFA_VERSION_208) {
- if (fStartOffset < fCalcHeight) {
- bCanSplitNoContent = true;
- } else {
- fCalcHeight = 0;
- return true;
- }
- }
- if (bCanSplitNoContent) {
- if ((fCalcHeight - fTopInset - fSpaceAbove < fLineHeight)) {
- fCalcHeight = 0;
- return true;
- }
- if (fStartOffset + XFA_FLOAT_PERCISION >= fCalcHeight) {
- if (iFieldSplitCount / 3 == (iBlockIndex + 1)) {
- (*pFieldArray)[iBlockIndex * 3 + 1] = 0;
- (*pFieldArray)[iBlockIndex * 3 + 2] = fCalcHeight;
- } else {
- pFieldArray->push_back(0);
- pFieldArray->push_back(fCalcHeight);
- }
- return false;
- }
- if (fCalcHeight - fStartOffset < fLineHeight) {
- fCalcHeight = fStartOffset;
- if (iFieldSplitCount / 3 == (iBlockIndex + 1)) {
- (*pFieldArray)[iBlockIndex * 3 + 1] = 0;
- (*pFieldArray)[iBlockIndex * 3 + 2] = fCalcHeight;
- } else {
- pFieldArray->push_back(0);
- pFieldArray->push_back(fCalcHeight);
- }
- return true;
- }
- float fTextNum =
- fCalcHeight + XFA_FLOAT_PERCISION - fCapReserve - fStartOffset;
- int32_t iLineNum =
- (int32_t)((fTextNum + (fLineHeight - fFontSize)) / fLineHeight);
- if (iLineNum >= iLinesCount) {
- if (fCalcHeight - fStartOffset - fTextHeight >= fFontSize) {
- if (iFieldSplitCount / 3 == (iBlockIndex + 1)) {
- (*pFieldArray)[iBlockIndex * 3 + 1] = (float)iLinesCount;
- (*pFieldArray)[iBlockIndex * 3 + 2] = fCalcHeight;
- } else {
- pFieldArray->push_back((float)iLinesCount);
- pFieldArray->push_back(fCalcHeight);
- }
- return false;
- }
- if (fHeight - fStartOffset - fTextHeight < fFontSize) {
- iLineNum -= 1;
- if (iLineNum == 0) {
- fCalcHeight = 0;
- return true;
- }
- } else {
- iLineNum = (int32_t)(fTextNum / fLineHeight);
- }
- }
- if (iLineNum > 0) {
- float fSplitHeight = iLineNum * fLineHeight + fCapReserve + fStartOffset;
- if (iFieldSplitCount / 3 == (iBlockIndex + 1)) {
- (*pFieldArray)[iBlockIndex * 3 + 1] = (float)iLineNum;
- (*pFieldArray)[iBlockIndex * 3 + 2] = fSplitHeight;
- } else {
- pFieldArray->push_back((float)iLineNum);
- pFieldArray->push_back(fSplitHeight);
- }
- if (fabs(fSplitHeight - fCalcHeight) < XFA_FLOAT_PERCISION) {
- return false;
- }
- fCalcHeight = fSplitHeight;
- return true;
- }
- }
- fCalcHeight = 0;
- return true;
-}
-void CXFA_WidgetAcc::InitLayoutData() {
- if (m_pLayoutData) {
- return;
- }
- switch (GetUIType()) {
- case XFA_Element::Text:
- m_pLayoutData = pdfium::MakeUnique<CXFA_TextLayoutData>();
- return;
- case XFA_Element::TextEdit:
- m_pLayoutData = pdfium::MakeUnique<CXFA_TextEditData>();
- return;
- case XFA_Element::Image:
- m_pLayoutData = pdfium::MakeUnique<CXFA_ImageLayoutData>();
- return;
- case XFA_Element::ImageEdit:
- m_pLayoutData = pdfium::MakeUnique<CXFA_ImageEditData>();
- return;
- default:
- break;
- }
- if (GetElementType() == XFA_Element::Field) {
- m_pLayoutData = pdfium::MakeUnique<CXFA_FieldLayoutData>();
- return;
- }
- m_pLayoutData = pdfium::MakeUnique<CXFA_WidgetLayoutData>();
-}
-
-void CXFA_WidgetAcc::StartTextLayout(float& fCalcWidth, float& fCalcHeight) {
- LoadText();
- CXFA_TextLayout* pTextLayout =
- static_cast<CXFA_TextLayoutData*>(m_pLayoutData.get())->GetTextLayout();
- float fTextHeight = 0;
- if (fCalcWidth > 0 && fCalcHeight > 0) {
- float fWidth = GetWidthWithoutMargin(fCalcWidth);
- pTextLayout->StartLayout(fWidth);
- fTextHeight = fCalcHeight;
- fTextHeight = GetHeightWithoutMargin(fTextHeight);
- pTextLayout->DoLayout(0, fTextHeight, -1, fTextHeight);
- return;
- }
- if (fCalcWidth > 0 && fCalcHeight < 0) {
- float fWidth = GetWidthWithoutMargin(fCalcWidth);
- pTextLayout->StartLayout(fWidth);
- }
- if (fCalcWidth < 0 && fCalcHeight < 0) {
- float fMaxWidth = -1;
- bool bRet = GetWidth(fMaxWidth);
- if (bRet) {
- float fWidth = GetWidthWithoutMargin(fMaxWidth);
- pTextLayout->StartLayout(fWidth);
- } else {
- float fWidth = pTextLayout->StartLayout(fMaxWidth);
- fMaxWidth = CalculateWidgetAutoWidth(fWidth);
- fWidth = GetWidthWithoutMargin(fMaxWidth);
- pTextLayout->StartLayout(fWidth);
- }
- fCalcWidth = fMaxWidth;
- }
- if (m_pLayoutData->m_fWidgetHeight < 0) {
- m_pLayoutData->m_fWidgetHeight = pTextLayout->GetLayoutHeight();
- m_pLayoutData->m_fWidgetHeight =
- CalculateWidgetAutoHeight(m_pLayoutData->m_fWidgetHeight);
- }
- fTextHeight = m_pLayoutData->m_fWidgetHeight;
- fTextHeight = GetHeightWithoutMargin(fTextHeight);
- pTextLayout->DoLayout(0, fTextHeight, -1, fTextHeight);
- fCalcHeight = m_pLayoutData->m_fWidgetHeight;
-}
-bool CXFA_WidgetAcc::LoadCaption() {
- InitLayoutData();
- return static_cast<CXFA_FieldLayoutData*>(m_pLayoutData.get())
- ->LoadCaption(this);
-}
-CXFA_TextLayout* CXFA_WidgetAcc::GetCaptionTextLayout() {
- return m_pLayoutData
- ? static_cast<CXFA_FieldLayoutData*>(m_pLayoutData.get())
- ->m_pCapTextLayout.get()
- : nullptr;
-}
-CXFA_TextLayout* CXFA_WidgetAcc::GetTextLayout() {
- return m_pLayoutData
- ? static_cast<CXFA_TextLayoutData*>(m_pLayoutData.get())
- ->GetTextLayout()
- : nullptr;
-}
-CFX_DIBitmap* CXFA_WidgetAcc::GetImageImage() {
- return m_pLayoutData
- ? static_cast<CXFA_ImageLayoutData*>(m_pLayoutData.get())
- ->m_pDIBitmap
- : nullptr;
-}
-CFX_DIBitmap* CXFA_WidgetAcc::GetImageEditImage() {
- return m_pLayoutData
- ? static_cast<CXFA_ImageEditData*>(m_pLayoutData.get())
- ->m_pDIBitmap
- : nullptr;
-}
-
-void CXFA_WidgetAcc::SetImageImage(CFX_DIBitmap* newImage) {
- CXFA_ImageLayoutData* pData =
- static_cast<CXFA_ImageLayoutData*>(m_pLayoutData.get());
- if (pData->m_pDIBitmap == newImage)
- return;
-
- if (pData->m_pDIBitmap && !pData->m_bNamedImage)
- delete pData->m_pDIBitmap;
-
- pData->m_pDIBitmap = newImage;
-}
-
-void CXFA_WidgetAcc::SetImageEditImage(CFX_DIBitmap* newImage) {
- CXFA_ImageEditData* pData =
- static_cast<CXFA_ImageEditData*>(m_pLayoutData.get());
- if (pData->m_pDIBitmap == newImage)
- return;
-
- if (pData->m_pDIBitmap && !pData->m_bNamedImage)
- delete pData->m_pDIBitmap;
-
- pData->m_pDIBitmap = newImage;
-}
-
-CXFA_WidgetLayoutData* CXFA_WidgetAcc::GetWidgetLayoutData() {
- return m_pLayoutData.get();
-}
-
-CFX_RetainPtr<CFGAS_GEFont> CXFA_WidgetAcc::GetFDEFont() {
- CFX_WideStringC wsFontName = L"Courier";
- uint32_t dwFontStyle = 0;
- if (CXFA_Font font = GetFont()) {
- if (font.IsBold())
- dwFontStyle |= FX_FONTSTYLE_Bold;
- if (font.IsItalic())
- dwFontStyle |= FX_FONTSTYLE_Italic;
- font.GetTypeface(wsFontName);
- }
-
- auto* pDoc = GetDoc();
- return pDoc->GetApp()->GetXFAFontMgr()->GetFont(pDoc, wsFontName,
- dwFontStyle);
-}
-float CXFA_WidgetAcc::GetFontSize() {
- float fFontSize = 10.0f;
- if (CXFA_Font font = GetFont()) {
- fFontSize = font.GetFontSize();
- }
- return fFontSize < 0.1f ? 10.0f : fFontSize;
-}
-float CXFA_WidgetAcc::GetLineHeight() {
- float fLineHeight = 0;
- if (CXFA_Para para = GetPara()) {
- fLineHeight = para.GetLineHeight();
- }
- if (fLineHeight < 1) {
- fLineHeight = GetFontSize() * 1.2f;
- }
- return fLineHeight;
-}
-FX_ARGB CXFA_WidgetAcc::GetTextColor() {
- if (CXFA_Font font = GetFont()) {
- return font.GetColor();
- }
- return 0xFF000000;
-}
CXFA_Node* CXFA_TextProvider::GetTextNode(bool& bRichText) {
bRichText = false;
if (m_pTextNode) {
diff --git a/xfa/fxfa/app/xfa_ffwidgetacc.h b/xfa/fxfa/app/xfa_ffwidgetacc.h
index 2daa35e6cd..8cb66e2dc5 100644
--- a/xfa/fxfa/app/xfa_ffwidgetacc.h
+++ b/xfa/fxfa/app/xfa_ffwidgetacc.h
@@ -9,7 +9,7 @@
#include "core/fxcrt/fx_string.h"
#include "xfa/fxfa/app/cxfa_textlayout.h"
-#include "xfa/fxfa/fxfa_widget.h"
+#include "xfa/fxfa/cxfa_widgetacc.h"
#include "xfa/fxfa/parser/cxfa_font.h"
#include "xfa/fxfa/parser/cxfa_para.h"
diff --git a/xfa/fxfa/app/xfa_fwladapter.cpp b/xfa/fxfa/app/xfa_fwladapter.cpp
index af578fcf8f..3cf6e5e8fd 100644
--- a/xfa/fxfa/app/xfa_fwladapter.cpp
+++ b/xfa/fxfa/app/xfa_fwladapter.cpp
@@ -7,7 +7,7 @@
#include "xfa/fxfa/app/xfa_fwladapter.h"
#include "xfa/fxfa/app/xfa_fffield.h"
-#include "xfa/fxfa/xfa_ffdoc.h"
+#include "xfa/fxfa/cxfa_ffdoc.h"
CXFA_FWLAdapterWidgetMgr::CXFA_FWLAdapterWidgetMgr() {}
diff --git a/xfa/fxfa/app/xfa_fwltheme.cpp b/xfa/fxfa/app/xfa_fwltheme.cpp
index 5ea2a0c6c7..b7f23e3e9f 100644
--- a/xfa/fxfa/app/xfa_fwltheme.cpp
+++ b/xfa/fxfa/app/xfa_fwltheme.cpp
@@ -22,8 +22,8 @@
#include "xfa/fwl/cfwl_scrollbar.h"
#include "xfa/fwl/cfwl_themebackground.h"
#include "xfa/fwl/cfwl_themetext.h"
-#include "xfa/fxfa/xfa_ffapp.h"
-#include "xfa/fxfa/xfa_ffwidget.h"
+#include "xfa/fxfa/cxfa_ffapp.h"
+#include "xfa/fxfa/cxfa_ffwidget.h"
#include "xfa/fxgraphics/cfx_color.h"
namespace {
diff --git a/xfa/fxfa/app/xfa_fwltheme.h b/xfa/fxfa/app/xfa_fwltheme.h
index a8efad0ccf..33ea8e80a5 100644
--- a/xfa/fxfa/app/xfa_fwltheme.h
+++ b/xfa/fxfa/app/xfa_fwltheme.h
@@ -22,7 +22,7 @@
#include "xfa/fwl/theme/cfwl_pushbuttontp.h"
#include "xfa/fwl/theme/cfwl_scrollbartp.h"
#include "xfa/fwl/theme/cfwl_widgettp.h"
-#include "xfa/fxfa/xfa_ffapp.h"
+#include "xfa/fxfa/cxfa_ffapp.h"
class CXFA_FWLTheme final : public IFWL_ThemeProvider {
public:
diff --git a/xfa/fxfa/app/xfa_checksum.cpp b/xfa/fxfa/cxfa_checksumcontext.cpp
index a06fed870c..a59bdb16bf 100644
--- a/xfa/fxfa/app/xfa_checksum.cpp
+++ b/xfa/fxfa/cxfa_checksumcontext.cpp
@@ -4,10 +4,11 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#include "xfa/fxfa/xfa_checksum.h"
+#include "xfa/fxfa/cxfa_checksumcontext.h"
#include "core/fdrm/crypto/fx_crypt.h"
#include "third_party/base/ptr_util.h"
+#include "xfa/fxfa/cxfa_saxreaderhandler.h"
namespace {
@@ -90,125 +91,6 @@ int32_t Base64EncodeA(const uint8_t* pSrc, int32_t iSrcLen, char* pDst) {
} // namespace
-CXFA_SAXReaderHandler::CXFA_SAXReaderHandler(CXFA_ChecksumContext* pContext)
- : m_pContext(pContext) {
- ASSERT(m_pContext);
-}
-CXFA_SAXReaderHandler::~CXFA_SAXReaderHandler() {}
-CXFA_SAXContext* CXFA_SAXReaderHandler::OnTagEnter(
- const CFX_ByteStringC& bsTagName,
- CFX_SAXItem::Type eType,
- uint32_t dwStartPos) {
- UpdateChecksum(true);
- if (eType != CFX_SAXItem::Type::Tag &&
- eType != CFX_SAXItem::Type::Instruction) {
- return nullptr;
- }
- m_SAXContext.m_eNode = eType;
- CFX_ByteTextBuf& textBuf = m_SAXContext.m_TextBuf;
- textBuf << "<";
- if (eType == CFX_SAXItem::Type::Instruction) {
- textBuf << "?";
- }
- textBuf << bsTagName;
- m_SAXContext.m_bsTagName = bsTagName;
- return &m_SAXContext;
-}
-
-void CXFA_SAXReaderHandler::OnTagAttribute(CXFA_SAXContext* pTag,
- const CFX_ByteStringC& bsAttri,
- const CFX_ByteStringC& bsValue) {
- if (!pTag)
- return;
-
- pTag->m_TextBuf << " " << bsAttri << "=\"" << bsValue << "\"";
-}
-
-void CXFA_SAXReaderHandler::OnTagBreak(CXFA_SAXContext* pTag) {
- if (!pTag)
- return;
-
- pTag->m_TextBuf << ">";
- UpdateChecksum(false);
-}
-
-void CXFA_SAXReaderHandler::OnTagData(CXFA_SAXContext* pTag,
- CFX_SAXItem::Type eType,
- const CFX_ByteStringC& bsData,
- uint32_t dwStartPos) {
- if (!pTag)
- return;
-
- CFX_ByteTextBuf& textBuf = pTag->m_TextBuf;
- if (eType == CFX_SAXItem::Type::CharData)
- textBuf << "<![CDATA[";
-
- textBuf << bsData;
- if (eType == CFX_SAXItem::Type::CharData)
- textBuf << "]]>";
-}
-
-void CXFA_SAXReaderHandler::OnTagClose(CXFA_SAXContext* pTag,
- uint32_t dwEndPos) {
- if (!pTag)
- return;
-
- CFX_ByteTextBuf& textBuf = pTag->m_TextBuf;
- if (pTag->m_eNode == CFX_SAXItem::Type::Instruction)
- textBuf << "?>";
- else if (pTag->m_eNode == CFX_SAXItem::Type::Tag)
- textBuf << "></" << pTag->m_bsTagName.AsStringC() << ">";
-
- UpdateChecksum(false);
-}
-
-void CXFA_SAXReaderHandler::OnTagEnd(CXFA_SAXContext* pTag,
- const CFX_ByteStringC& bsTagName,
- uint32_t dwEndPos) {
- if (!pTag)
- return;
-
- pTag->m_TextBuf << "</" << bsTagName << ">";
- UpdateChecksum(false);
-}
-
-void CXFA_SAXReaderHandler::OnTargetData(CXFA_SAXContext* pTag,
- CFX_SAXItem::Type eType,
- const CFX_ByteStringC& bsData,
- uint32_t dwStartPos) {
- if (!pTag && eType != CFX_SAXItem::Type::Comment)
- return;
-
- if (eType == CFX_SAXItem::Type::Comment) {
- m_SAXContext.m_TextBuf << "<!--" << bsData << "-->";
- UpdateChecksum(false);
- } else {
- pTag->m_TextBuf << " " << bsData;
- }
-}
-
-void CXFA_SAXReaderHandler::UpdateChecksum(bool bCheckSpace) {
- int32_t iLength = m_SAXContext.m_TextBuf.GetLength();
- if (iLength < 1) {
- return;
- }
- uint8_t* pBuffer = m_SAXContext.m_TextBuf.GetBuffer();
- bool bUpdata = true;
- if (bCheckSpace) {
- bUpdata = false;
- for (int32_t i = 0; i < iLength; i++) {
- bUpdata = (pBuffer[i] > 0x20);
- if (bUpdata) {
- break;
- }
- }
- }
- if (bUpdata) {
- m_pContext->Update(CFX_ByteStringC(pBuffer, iLength));
- }
- m_SAXContext.m_TextBuf.Clear();
-}
-
CXFA_ChecksumContext::CXFA_ChecksumContext() {}
CXFA_ChecksumContext::~CXFA_ChecksumContext() {}
diff --git a/xfa/fxfa/cxfa_checksumcontext.h b/xfa/fxfa/cxfa_checksumcontext.h
new file mode 100644
index 0000000000..ca1b53007e
--- /dev/null
+++ b/xfa/fxfa/cxfa_checksumcontext.h
@@ -0,0 +1,34 @@
+// Copyright 2014 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef XFA_FXFA_CXFA_CHECKSUMCONTEXT_H_
+#define XFA_FXFA_CXFA_CHECKSUMCONTEXT_H_
+
+#include <memory>
+
+#include "core/fdrm/crypto/fx_crypt.h"
+#include "xfa/fde/xml/cfx_saxreader.h"
+
+class CXFA_ChecksumContext {
+ public:
+ CXFA_ChecksumContext();
+ ~CXFA_ChecksumContext();
+
+ void StartChecksum();
+ void Update(const CFX_ByteStringC& bsText);
+ bool UpdateChecksum(const CFX_RetainPtr<IFX_SeekableReadStream>& pSrcFile,
+ FX_FILESIZE offset = 0,
+ size_t size = 0);
+ void FinishChecksum();
+ CFX_ByteString GetChecksum() const;
+
+ private:
+ std::unique_ptr<CFX_SAXReader> m_pSAXReader;
+ std::unique_ptr<CRYPT_sha1_context> m_pByteContext;
+ CFX_ByteString m_bsChecksum;
+};
+
+#endif // XFA_FXFA_CXFA_CHECKSUMCONTEXT_H_
diff --git a/xfa/fxfa/cxfa_deffontmgr.cpp b/xfa/fxfa/cxfa_deffontmgr.cpp
new file mode 100644
index 0000000000..db730677b5
--- /dev/null
+++ b/xfa/fxfa/cxfa_deffontmgr.cpp
@@ -0,0 +1,77 @@
+// Copyright 2017 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "xfa/fxfa/cxfa_deffontmgr.h"
+
+#include "xfa/fxfa/cxfa_ffapp.h"
+#include "xfa/fxfa/cxfa_ffdoc.h"
+#include "xfa/fxfa/cxfa_fontmgr.h"
+
+CXFA_DefFontMgr::CXFA_DefFontMgr() {}
+
+CXFA_DefFontMgr::~CXFA_DefFontMgr() {}
+
+CFX_RetainPtr<CFGAS_GEFont> CXFA_DefFontMgr::GetFont(
+ CXFA_FFDoc* hDoc,
+ const CFX_WideStringC& wsFontFamily,
+ uint32_t dwFontStyles,
+ uint16_t wCodePage) {
+ CFX_WideString wsFontName(wsFontFamily);
+ CFGAS_FontMgr* pFDEFontMgr = hDoc->GetApp()->GetFDEFontMgr();
+ CFX_RetainPtr<CFGAS_GEFont> pFont =
+ pFDEFontMgr->LoadFont(wsFontName.c_str(), dwFontStyles, wCodePage);
+ if (!pFont) {
+ const XFA_FONTINFO* pCurFont =
+ XFA_GetFontINFOByFontName(wsFontName.AsStringC());
+ if (pCurFont && pCurFont->pReplaceFont) {
+ uint32_t dwStyle = 0;
+ if (dwFontStyles & FX_FONTSTYLE_Bold) {
+ dwStyle |= FX_FONTSTYLE_Bold;
+ }
+ if (dwFontStyles & FX_FONTSTYLE_Italic) {
+ dwStyle |= FX_FONTSTYLE_Italic;
+ }
+ const wchar_t* pReplace = pCurFont->pReplaceFont;
+ int32_t iLength = FXSYS_wcslen(pReplace);
+ while (iLength > 0) {
+ const wchar_t* pNameText = pReplace;
+ while (*pNameText != L',' && iLength > 0) {
+ pNameText++;
+ iLength--;
+ }
+ CFX_WideString wsReplace =
+ CFX_WideString(pReplace, pNameText - pReplace);
+ pFont = pFDEFontMgr->LoadFont(wsReplace.c_str(), dwStyle, wCodePage);
+ if (pFont)
+ break;
+
+ iLength--;
+ pNameText++;
+ pReplace = pNameText;
+ }
+ }
+ }
+ if (pFont)
+ m_CacheFonts.push_back(pFont);
+ return pFont;
+}
+
+CFX_RetainPtr<CFGAS_GEFont> CXFA_DefFontMgr::GetDefaultFont(
+ CXFA_FFDoc* hDoc,
+ const CFX_WideStringC& wsFontFamily,
+ uint32_t dwFontStyles,
+ uint16_t wCodePage) {
+ CFGAS_FontMgr* pFDEFontMgr = hDoc->GetApp()->GetFDEFontMgr();
+ CFX_RetainPtr<CFGAS_GEFont> pFont =
+ pFDEFontMgr->LoadFont(L"Arial Narrow", dwFontStyles, wCodePage);
+ if (!pFont) {
+ pFont = pFDEFontMgr->LoadFont(static_cast<const wchar_t*>(nullptr),
+ dwFontStyles, wCodePage);
+ }
+ if (pFont)
+ m_CacheFonts.push_back(pFont);
+ return pFont;
+}
diff --git a/xfa/fxfa/cxfa_deffontmgr.h b/xfa/fxfa/cxfa_deffontmgr.h
new file mode 100644
index 0000000000..5f50ffb08d
--- /dev/null
+++ b/xfa/fxfa/cxfa_deffontmgr.h
@@ -0,0 +1,37 @@
+// Copyright 2017 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef XFA_FXFA_CXFA_DEFFONTMGR_H_
+#define XFA_FXFA_CXFA_DEFFONTMGR_H_
+
+#include <vector>
+
+#include "core/fxcrt/cfx_retain_ptr.h"
+#include "core/fxcrt/fx_string.h"
+#include "xfa/fgas/font/cfgas_gefont.h"
+
+class CXFA_FFDoc;
+
+class CXFA_DefFontMgr {
+ public:
+ CXFA_DefFontMgr();
+ ~CXFA_DefFontMgr();
+
+ CFX_RetainPtr<CFGAS_GEFont> GetFont(CXFA_FFDoc* hDoc,
+ const CFX_WideStringC& wsFontFamily,
+ uint32_t dwFontStyles,
+ uint16_t wCodePage = 0xFFFF);
+ CFX_RetainPtr<CFGAS_GEFont> GetDefaultFont(
+ CXFA_FFDoc* hDoc,
+ const CFX_WideStringC& wsFontFamily,
+ uint32_t dwFontStyles,
+ uint16_t wCodePage = 0xFFFF);
+
+ private:
+ std::vector<CFX_RetainPtr<CFGAS_GEFont>> m_CacheFonts;
+};
+
+#endif // XFA_FXFA_CXFA_DEFFONTMGR_H_
diff --git a/xfa/fxfa/app/cxfa_eventparam.cpp b/xfa/fxfa/cxfa_eventparam.cpp
index bd6742f4dd..bd6742f4dd 100644
--- a/xfa/fxfa/app/cxfa_eventparam.cpp
+++ b/xfa/fxfa/cxfa_eventparam.cpp
diff --git a/xfa/fxfa/app/xfa_ffapp.cpp b/xfa/fxfa/cxfa_ffapp.cpp
index 219f06e4ff..40341ad90c 100644
--- a/xfa/fxfa/app/xfa_ffapp.cpp
+++ b/xfa/fxfa/cxfa_ffapp.cpp
@@ -4,7 +4,7 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#include "xfa/fxfa/xfa_ffapp.h"
+#include "xfa/fxfa/cxfa_ffapp.h"
#include <algorithm>
#include <memory>
@@ -18,10 +18,10 @@
#include "xfa/fwl/cfwl_widgetmgr.h"
#include "xfa/fxfa/app/xfa_fwladapter.h"
#include "xfa/fxfa/app/xfa_fwltheme.h"
-#include "xfa/fxfa/xfa_ffdoc.h"
-#include "xfa/fxfa/xfa_ffdochandler.h"
-#include "xfa/fxfa/xfa_ffwidgethandler.h"
-#include "xfa/fxfa/xfa_fontmgr.h"
+#include "xfa/fxfa/cxfa_ffdoc.h"
+#include "xfa/fxfa/cxfa_ffdochandler.h"
+#include "xfa/fxfa/cxfa_ffwidgethandler.h"
+#include "xfa/fxfa/cxfa_fontmgr.h"
namespace {
diff --git a/xfa/fxfa/xfa_ffapp.h b/xfa/fxfa/cxfa_ffapp.h
index 411fd2d273..01235d655b 100644
--- a/xfa/fxfa/xfa_ffapp.h
+++ b/xfa/fxfa/cxfa_ffapp.h
@@ -4,8 +4,8 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#ifndef XFA_FXFA_XFA_FFAPP_H_
-#define XFA_FXFA_XFA_FFAPP_H_
+#ifndef XFA_FXFA_CXFA_FFAPP_H_
+#define XFA_FXFA_CXFA_FFAPP_H_
#include <memory>
#include <vector>
@@ -54,7 +54,7 @@ class CXFA_FFApp {
void ClearEventTargets();
- protected:
+ private:
std::unique_ptr<CXFA_FFDocHandler> m_pDocHandler;
IXFA_AppProvider* const m_pProvider;
@@ -83,4 +83,4 @@ class CXFA_FFApp {
std::unique_ptr<CFWL_App> m_pFWLApp;
};
-#endif // XFA_FXFA_XFA_FFAPP_H_
+#endif // XFA_FXFA_CXFA_FFAPP_H_
diff --git a/xfa/fxfa/app/xfa_ffapp_unittest.cpp b/xfa/fxfa/cxfa_ffapp_unitest.cpp
index b0879012b4..e8accdfeb2 100644
--- a/xfa/fxfa/app/xfa_ffapp_unittest.cpp
+++ b/xfa/fxfa/cxfa_ffapp_unitest.cpp
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "xfa/fxfa/xfa_ffapp.h"
+#include "xfa/fxfa/cxfa_ffapp.h"
#include <memory>
#include <vector>
diff --git a/xfa/fxfa/app/xfa_ffdoc.cpp b/xfa/fxfa/cxfa_ffdoc.cpp
index ba1f5d8124..fdeacf7f0f 100644
--- a/xfa/fxfa/app/xfa_ffdoc.cpp
+++ b/xfa/fxfa/cxfa_ffdoc.cpp
@@ -4,7 +4,7 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#include "xfa/fxfa/xfa_ffdoc.h"
+#include "xfa/fxfa/cxfa_ffdoc.h"
#include <algorithm>
#include <memory>
@@ -20,14 +20,14 @@
#include "xfa/fde/xml/fde_xml_imp.h"
#include "xfa/fwl/cfwl_notedriver.h"
#include "xfa/fxfa/app/xfa_ffnotify.h"
+#include "xfa/fxfa/cxfa_checksumcontext.h"
+#include "xfa/fxfa/cxfa_ffapp.h"
+#include "xfa/fxfa/cxfa_ffdocview.h"
+#include "xfa/fxfa/cxfa_ffwidget.h"
+#include "xfa/fxfa/cxfa_fontmgr.h"
#include "xfa/fxfa/parser/cxfa_dataexporter.h"
#include "xfa/fxfa/parser/cxfa_dataimporter.h"
#include "xfa/fxfa/parser/cxfa_document.h"
-#include "xfa/fxfa/xfa_checksum.h"
-#include "xfa/fxfa/xfa_ffapp.h"
-#include "xfa/fxfa/xfa_ffdocview.h"
-#include "xfa/fxfa/xfa_ffwidget.h"
-#include "xfa/fxfa/xfa_fontmgr.h"
namespace {
diff --git a/xfa/fxfa/xfa_ffdoc.h b/xfa/fxfa/cxfa_ffdoc.h
index ee7695b15a..1d46387a5e 100644
--- a/xfa/fxfa/xfa_ffdoc.h
+++ b/xfa/fxfa/cxfa_ffdoc.h
@@ -4,8 +4,8 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#ifndef XFA_FXFA_XFA_FFDOC_H_
-#define XFA_FXFA_XFA_FFDOC_H_
+#ifndef XFA_FXFA_CXFA_FFDOC_H_
+#define XFA_FXFA_CXFA_FFDOC_H_
#include <map>
#include <memory>
@@ -58,7 +58,7 @@ class CXFA_FFDoc {
bool ImportData(const CFX_RetainPtr<IFX_SeekableReadStream>& pStream,
bool bXDP = true);
- protected:
+ private:
IXFA_DocEnvironment* const m_pDocEnvironment;
std::unique_ptr<CXFA_DocumentParser> m_pDocumentParser;
CFX_RetainPtr<IFX_SeekableReadStream> m_pStream;
@@ -70,4 +70,4 @@ class CXFA_FFDoc {
XFA_DocType m_dwDocType;
};
-#endif // XFA_FXFA_XFA_FFDOC_H_
+#endif // XFA_FXFA_CXFA_FFDOC_H_
diff --git a/xfa/fxfa/app/xfa_ffdochandler.cpp b/xfa/fxfa/cxfa_ffdochandler.cpp
index db73531ccc..a71bb208fa 100644
--- a/xfa/fxfa/app/xfa_ffdochandler.cpp
+++ b/xfa/fxfa/cxfa_ffdochandler.cpp
@@ -4,12 +4,12 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#include "xfa/fxfa/xfa_ffdochandler.h"
+#include "xfa/fxfa/cxfa_ffdochandler.h"
+#include "xfa/fxfa/cxfa_checksumcontext.h"
+#include "xfa/fxfa/cxfa_ffdoc.h"
#include "xfa/fxfa/parser/cxfa_scriptcontext.h"
#include "xfa/fxfa/parser/xfa_resolvenode_rs.h"
-#include "xfa/fxfa/xfa_checksum.h"
-#include "xfa/fxfa/xfa_ffdoc.h"
CXFA_FFDocHandler::CXFA_FFDocHandler() {}
diff --git a/xfa/fxfa/xfa_ffdochandler.h b/xfa/fxfa/cxfa_ffdochandler.h
index 0e4f71786c..b54c36c1d7 100644
--- a/xfa/fxfa/xfa_ffdochandler.h
+++ b/xfa/fxfa/cxfa_ffdochandler.h
@@ -4,8 +4,8 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#ifndef XFA_FXFA_XFA_FFDOCHANDLER_H_
-#define XFA_FXFA_XFA_FFDOCHANDLER_H_
+#ifndef XFA_FXFA_CXFA_FFDOCHANDLER_H_
+#define XFA_FXFA_CXFA_FFDOCHANDLER_H_
#include "xfa/fxfa/fxfa.h"
@@ -24,8 +24,6 @@ class CXFA_FFDocHandler {
const CFX_WideStringC& wsScript,
CFXJSE_Value* pRetValue,
CFXJSE_Value* pThisObject);
-
- protected:
};
-#endif // XFA_FXFA_XFA_FFDOCHANDLER_H_
+#endif // XFA_FXFA_CXFA_FFDOCHANDLER_H_
diff --git a/xfa/fxfa/app/xfa_ffdocview.cpp b/xfa/fxfa/cxfa_ffdocview.cpp
index f4ea3afdd8..9708e34562 100644
--- a/xfa/fxfa/app/xfa_ffdocview.cpp
+++ b/xfa/fxfa/cxfa_ffdocview.cpp
@@ -4,7 +4,7 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#include "xfa/fxfa/xfa_ffdocview.h"
+#include "xfa/fxfa/cxfa_ffdocview.h"
#include "core/fxcrt/fx_ext.h"
#include "third_party/base/ptr_util.h"
@@ -25,15 +25,16 @@
#include "xfa/fxfa/app/xfa_fftextedit.h"
#include "xfa/fxfa/app/xfa_ffwidgetacc.h"
#include "xfa/fxfa/app/xfa_fwladapter.h"
+#include "xfa/fxfa/cxfa_ffapp.h"
+#include "xfa/fxfa/cxfa_ffdoc.h"
+#include "xfa/fxfa/cxfa_ffpageview.h"
+#include "xfa/fxfa/cxfa_ffwidget.h"
+#include "xfa/fxfa/cxfa_ffwidgethandler.h"
+#include "xfa/fxfa/cxfa_widgetacciterator.h"
#include "xfa/fxfa/parser/cxfa_binditems.h"
#include "xfa/fxfa/parser/cxfa_layoutprocessor.h"
#include "xfa/fxfa/parser/cxfa_scriptcontext.h"
#include "xfa/fxfa/parser/xfa_resolvenode_rs.h"
-#include "xfa/fxfa/xfa_ffapp.h"
-#include "xfa/fxfa/xfa_ffdoc.h"
-#include "xfa/fxfa/xfa_ffpageview.h"
-#include "xfa/fxfa/xfa_ffwidget.h"
-#include "xfa/fxfa/xfa_ffwidgethandler.h"
const XFA_ATTRIBUTEENUM gs_EventActivity[] = {
XFA_ATTRIBUTEENUM_Click, XFA_ATTRIBUTEENUM_Change,
@@ -240,7 +241,7 @@ void CXFA_FFDocView::ResetWidgetData(CXFA_WidgetAcc* pWidgetAcc) {
}
if (pFormNode->GetElementType() != XFA_Element::Field &&
pFormNode->GetElementType() != XFA_Element::ExclGroup) {
- CXFA_WidgetAccIterator Iterator(this, pFormNode);
+ CXFA_WidgetAccIterator Iterator(pFormNode);
while (CXFA_WidgetAcc* pAcc = Iterator.MoveToNext()) {
bChanged |= ResetSingleWidgetAccData(pAcc);
if (pAcc->GetNode()->GetElementType() == XFA_Element::ExclGroup) {
@@ -306,11 +307,13 @@ CXFA_FFWidgetHandler* CXFA_FFDocView::GetWidgetHandler() {
CXFA_WidgetAccIterator* CXFA_FFDocView::CreateWidgetAccIterator(
XFA_WIDGETORDER eOrder) {
CXFA_Node* pFormRoot = GetRootSubform();
- return pFormRoot ? new CXFA_WidgetAccIterator(this, pFormRoot) : nullptr;
+ return pFormRoot ? new CXFA_WidgetAccIterator(pFormRoot) : nullptr;
}
+
CXFA_FFWidget* CXFA_FFDocView::GetFocusWidget() {
return m_pFocusWidget;
}
+
void CXFA_FFDocView::KillFocus() {
if (m_pFocusWidget &&
(m_pFocusWidget->GetStatus() & XFA_WidgetStatus_Focused)) {
@@ -785,52 +788,3 @@ CXFA_Node* CXFA_FFDocView::GetRootSubform() {
}
return pFormPacketNode->GetFirstChildByClass(XFA_Element::Subform);
}
-
-CXFA_WidgetAccIterator::CXFA_WidgetAccIterator(CXFA_FFDocView* pDocView,
- CXFA_Node* pTravelRoot)
- : m_ContentIterator(pTravelRoot),
- m_pDocView(pDocView),
- m_pCurWidgetAcc(nullptr) {}
-
-CXFA_WidgetAccIterator::~CXFA_WidgetAccIterator() {}
-void CXFA_WidgetAccIterator::Reset() {
- m_pCurWidgetAcc = nullptr;
- m_ContentIterator.Reset();
-}
-
-CXFA_WidgetAcc* CXFA_WidgetAccIterator::MoveToFirst() {
- return nullptr;
-}
-
-CXFA_WidgetAcc* CXFA_WidgetAccIterator::MoveToLast() {
- return nullptr;
-}
-
-CXFA_WidgetAcc* CXFA_WidgetAccIterator::MoveToNext() {
- CXFA_Node* pItem = m_pCurWidgetAcc ? m_ContentIterator.MoveToNext()
- : m_ContentIterator.GetCurrent();
- while (pItem) {
- m_pCurWidgetAcc = static_cast<CXFA_WidgetAcc*>(pItem->GetWidgetData());
- if (m_pCurWidgetAcc)
- return m_pCurWidgetAcc;
- pItem = m_ContentIterator.MoveToNext();
- }
- return nullptr;
-}
-
-CXFA_WidgetAcc* CXFA_WidgetAccIterator::MoveToPrevious() {
- return nullptr;
-}
-
-CXFA_WidgetAcc* CXFA_WidgetAccIterator::GetCurrentWidgetAcc() {
- return nullptr;
-}
-
-bool CXFA_WidgetAccIterator::SetCurrentWidgetAcc(CXFA_WidgetAcc* hWidget) {
- return false;
-}
-
-void CXFA_WidgetAccIterator::SkipTree() {
- m_ContentIterator.SkipChildrenAndMoveToNext();
- m_pCurWidgetAcc = nullptr;
-}
diff --git a/xfa/fxfa/xfa_ffdocview.h b/xfa/fxfa/cxfa_ffdocview.h
index d8df8b4312..05ed9d7086 100644
--- a/xfa/fxfa/xfa_ffdocview.h
+++ b/xfa/fxfa/cxfa_ffdocview.h
@@ -4,15 +4,15 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#ifndef XFA_FXFA_XFA_FFDOCVIEW_H_
-#define XFA_FXFA_XFA_FFDOCVIEW_H_
+#ifndef XFA_FXFA_CXFA_FFDOCVIEW_H_
+#define XFA_FXFA_CXFA_FFDOCVIEW_H_
#include <map>
#include <memory>
#include <vector>
#include "xfa/fxfa/cxfa_eventparam.h"
-#include "xfa/fxfa/xfa_ffdoc.h"
+#include "xfa/fxfa/cxfa_ffdoc.h"
class CXFA_FFWidgetHandler;
class CXFA_FFDoc;
@@ -36,6 +36,7 @@ enum XFA_DOCVIEW_LAYOUTSTATUS {
XFA_DOCVIEW_LAYOUTSTATUS_DocReady,
XFA_DOCVIEW_LAYOUTSTATUS_End
};
+
class CXFA_FFDocView {
public:
explicit CXFA_FFDocView(CXFA_FFDoc* pDoc);
@@ -103,7 +104,9 @@ class CXFA_FFDocView {
CXFA_FFWidget* m_pListFocusWidget;
bool m_bInLayoutStatus;
- protected:
+ private:
+ friend class CXFA_FFNotify;
+
bool RunEventLayoutReady();
void RunBindItems();
bool InitCalculate(CXFA_Node* pNode);
@@ -127,27 +130,6 @@ class CXFA_FFDocView {
std::vector<CXFA_Node*> m_IndexChangedSubforms;
XFA_DOCVIEW_LAYOUTSTATUS m_iStatus;
int32_t m_iLock;
- friend class CXFA_FFNotify;
-};
-
-class CXFA_WidgetAccIterator {
- public:
- CXFA_WidgetAccIterator(CXFA_FFDocView* pDocView, CXFA_Node* pTravelRoot);
- ~CXFA_WidgetAccIterator();
-
- void Reset();
- CXFA_WidgetAcc* MoveToFirst();
- CXFA_WidgetAcc* MoveToLast();
- CXFA_WidgetAcc* MoveToNext();
- CXFA_WidgetAcc* MoveToPrevious();
- CXFA_WidgetAcc* GetCurrentWidgetAcc();
- bool SetCurrentWidgetAcc(CXFA_WidgetAcc* hWidget);
- void SkipTree();
-
- protected:
- CXFA_ContainerIterator m_ContentIterator;
- CXFA_FFDocView* const m_pDocView;
- CXFA_WidgetAcc* m_pCurWidgetAcc; // not owned.
};
-#endif // XFA_FXFA_XFA_FFDOCVIEW_H_
+#endif // XFA_FXFA_CXFA_FFDOCVIEW_H_
diff --git a/xfa/fxfa/app/xfa_ffpageview.cpp b/xfa/fxfa/cxfa_ffpageview.cpp
index d54e1472a1..3eda5a1d4a 100644
--- a/xfa/fxfa/app/xfa_ffpageview.cpp
+++ b/xfa/fxfa/cxfa_ffpageview.cpp
@@ -4,7 +4,7 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#include "xfa/fxfa/xfa_ffpageview.h"
+#include "xfa/fxfa/cxfa_ffpageview.h"
#include <memory>
#include <vector>
@@ -19,9 +19,9 @@
#include "xfa/fxfa/app/xfa_ffpushbutton.h"
#include "xfa/fxfa/app/xfa_fftextedit.h"
#include "xfa/fxfa/app/xfa_fwladapter.h"
-#include "xfa/fxfa/xfa_ffdoc.h"
-#include "xfa/fxfa/xfa_ffdocview.h"
-#include "xfa/fxfa/xfa_ffwidget.h"
+#include "xfa/fxfa/cxfa_ffdoc.h"
+#include "xfa/fxfa/cxfa_ffdocview.h"
+#include "xfa/fxfa/cxfa_ffwidget.h"
namespace {
diff --git a/xfa/fxfa/xfa_ffpageview.h b/xfa/fxfa/cxfa_ffpageview.h
index 4b50a2365d..ee1b4e37df 100644
--- a/xfa/fxfa/xfa_ffpageview.h
+++ b/xfa/fxfa/cxfa_ffpageview.h
@@ -4,8 +4,8 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#ifndef XFA_FXFA_XFA_FFPAGEVIEW_H_
-#define XFA_FXFA_XFA_FFPAGEVIEW_H_
+#ifndef XFA_FXFA_CXFA_FFPAGEVIEW_H_
+#define XFA_FXFA_CXFA_FFPAGEVIEW_H_
#include <vector>
@@ -104,4 +104,4 @@ class CXFA_FFTabOrderPageWidgetIterator : public IXFA_WidgetIterator {
bool m_bIgnorerelevant;
};
-#endif // XFA_FXFA_XFA_FFPAGEVIEW_H_
+#endif // XFA_FXFA_CXFA_FFPAGEVIEW_H_
diff --git a/xfa/fxfa/app/xfa_ffwidget.cpp b/xfa/fxfa/cxfa_ffwidget.cpp
index 2d52982293..504ce70ad9 100644
--- a/xfa/fxfa/app/xfa_ffwidget.cpp
+++ b/xfa/fxfa/cxfa_ffwidget.cpp
@@ -4,7 +4,7 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#include "xfa/fxfa/xfa_ffwidget.h"
+#include "xfa/fxfa/cxfa_ffwidget.h"
#include <algorithm>
#include <memory>
@@ -20,12 +20,12 @@
#include "xfa/fwl/fwl_widgethit.h"
#include "xfa/fxfa/app/cxfa_textlayout.h"
#include "xfa/fxfa/cxfa_eventparam.h"
-#include "xfa/fxfa/fxfa_widget.h"
+#include "xfa/fxfa/cxfa_ffapp.h"
+#include "xfa/fxfa/cxfa_ffdoc.h"
+#include "xfa/fxfa/cxfa_ffdocview.h"
+#include "xfa/fxfa/cxfa_ffpageview.h"
+#include "xfa/fxfa/cxfa_widgetacc.h"
#include "xfa/fxfa/parser/cxfa_corner.h"
-#include "xfa/fxfa/xfa_ffapp.h"
-#include "xfa/fxfa/xfa_ffdoc.h"
-#include "xfa/fxfa/xfa_ffdocview.h"
-#include "xfa/fxfa/xfa_ffpageview.h"
#include "xfa/fxgraphics/cfx_color.h"
#include "xfa/fxgraphics/cfx_graphics.h"
#include "xfa/fxgraphics/cfx_path.h"
diff --git a/xfa/fxfa/xfa_ffwidget.h b/xfa/fxfa/cxfa_ffwidget.h
index 7b923506ff..02a7b21b15 100644
--- a/xfa/fxfa/xfa_ffwidget.h
+++ b/xfa/fxfa/cxfa_ffwidget.h
@@ -4,8 +4,8 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#ifndef XFA_FXFA_XFA_FFWIDGET_H_
-#define XFA_FXFA_XFA_FFWIDGET_H_
+#ifndef XFA_FXFA_CXFA_FFWIDGET_H_
+#define XFA_FXFA_CXFA_FFWIDGET_H_
#include <vector>
@@ -34,6 +34,47 @@ enum XFA_WIDGETITEM {
XFA_WIDGETITEM_PrevSibling,
};
+int32_t XFA_StrokeTypeSetLineDash(CFX_Graphics* pGraphics,
+ int32_t iStrokeType,
+ int32_t iCapType);
+CFX_GraphStateData::LineCap XFA_LineCapToFXGE(int32_t iLineCap);
+void XFA_DrawImage(CFX_Graphics* pGS,
+ const CFX_RectF& rtImage,
+ CFX_Matrix* pMatrix,
+ CFX_DIBitmap* pDIBitmap,
+ int32_t iAspect,
+ int32_t iImageXDpi,
+ int32_t iImageYDpi,
+ int32_t iHorzAlign = XFA_ATTRIBUTEENUM_Left,
+ int32_t iVertAlign = XFA_ATTRIBUTEENUM_Top);
+
+CFX_DIBitmap* XFA_LoadImageData(CXFA_FFDoc* pDoc,
+ CXFA_Image* pImage,
+ bool& bNameImage,
+ int32_t& iImageXDpi,
+ int32_t& iImageYDpi);
+
+CFX_DIBitmap* XFA_LoadImageFromBuffer(
+ const CFX_RetainPtr<IFX_SeekableReadStream>& pImageFileRead,
+ FXCODEC_IMAGE_TYPE type,
+ int32_t& iImageXDpi,
+ int32_t& iImageYDpi);
+
+FXCODEC_IMAGE_TYPE XFA_GetImageType(const CFX_WideString& wsType);
+char* XFA_Base64Encode(const uint8_t* buf, int32_t buf_len);
+void XFA_RectWidthoutMargin(CFX_RectF& rt,
+ const CXFA_Margin& mg,
+ bool bUI = false);
+CXFA_FFWidget* XFA_GetWidgetFromLayoutItem(CXFA_LayoutItem* pLayoutItem);
+bool XFA_IsCreateWidget(XFA_Element iType);
+#define XFA_DRAWBOX_ForceRound 1
+#define XFA_DRAWBOX_Lowered3D 2
+void XFA_DrawBox(CXFA_Box box,
+ CFX_Graphics* pGS,
+ const CFX_RectF& rtWidget,
+ CFX_Matrix* pMatrix,
+ uint32_t dwFlags = 0);
+
class CXFA_CalcData {
public:
CXFA_CalcData();
@@ -146,45 +187,4 @@ class CXFA_FFWidget : public CXFA_ContentLayoutItem {
CFX_RectF m_rtWidget;
};
-int32_t XFA_StrokeTypeSetLineDash(CFX_Graphics* pGraphics,
- int32_t iStrokeType,
- int32_t iCapType);
-CFX_GraphStateData::LineCap XFA_LineCapToFXGE(int32_t iLineCap);
-void XFA_DrawImage(CFX_Graphics* pGS,
- const CFX_RectF& rtImage,
- CFX_Matrix* pMatrix,
- CFX_DIBitmap* pDIBitmap,
- int32_t iAspect,
- int32_t iImageXDpi,
- int32_t iImageYDpi,
- int32_t iHorzAlign = XFA_ATTRIBUTEENUM_Left,
- int32_t iVertAlign = XFA_ATTRIBUTEENUM_Top);
-
-CFX_DIBitmap* XFA_LoadImageData(CXFA_FFDoc* pDoc,
- CXFA_Image* pImage,
- bool& bNameImage,
- int32_t& iImageXDpi,
- int32_t& iImageYDpi);
-
-CFX_DIBitmap* XFA_LoadImageFromBuffer(
- const CFX_RetainPtr<IFX_SeekableReadStream>& pImageFileRead,
- FXCODEC_IMAGE_TYPE type,
- int32_t& iImageXDpi,
- int32_t& iImageYDpi);
-
-FXCODEC_IMAGE_TYPE XFA_GetImageType(const CFX_WideString& wsType);
-char* XFA_Base64Encode(const uint8_t* buf, int32_t buf_len);
-void XFA_RectWidthoutMargin(CFX_RectF& rt,
- const CXFA_Margin& mg,
- bool bUI = false);
-CXFA_FFWidget* XFA_GetWidgetFromLayoutItem(CXFA_LayoutItem* pLayoutItem);
-bool XFA_IsCreateWidget(XFA_Element iType);
-#define XFA_DRAWBOX_ForceRound 1
-#define XFA_DRAWBOX_Lowered3D 2
-void XFA_DrawBox(CXFA_Box box,
- CFX_Graphics* pGS,
- const CFX_RectF& rtWidget,
- CFX_Matrix* pMatrix,
- uint32_t dwFlags = 0);
-
-#endif // XFA_FXFA_XFA_FFWIDGET_H_
+#endif // XFA_FXFA_CXFA_FFWIDGET_H_
diff --git a/xfa/fxfa/app/xfa_ffwidgethandler.cpp b/xfa/fxfa/cxfa_ffwidgethandler.cpp
index 8ecc4565e1..0af69da016 100644
--- a/xfa/fxfa/app/xfa_ffwidgethandler.cpp
+++ b/xfa/fxfa/cxfa_ffwidgethandler.cpp
@@ -4,18 +4,18 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#include "xfa/fxfa/xfa_ffwidgethandler.h"
+#include "xfa/fxfa/cxfa_ffwidgethandler.h"
#include <vector>
#include "xfa/fxfa/app/xfa_ffchoicelist.h"
#include "xfa/fxfa/app/xfa_fffield.h"
#include "xfa/fxfa/app/xfa_fwladapter.h"
+#include "xfa/fxfa/cxfa_ffdoc.h"
+#include "xfa/fxfa/cxfa_ffdocview.h"
+#include "xfa/fxfa/cxfa_ffwidget.h"
#include "xfa/fxfa/parser/cxfa_layoutprocessor.h"
#include "xfa/fxfa/parser/cxfa_measurement.h"
-#include "xfa/fxfa/xfa_ffdoc.h"
-#include "xfa/fxfa/xfa_ffdocview.h"
-#include "xfa/fxfa/xfa_ffwidget.h"
CXFA_FFWidgetHandler::CXFA_FFWidgetHandler(CXFA_FFDocView* pDocView)
: m_pDocView(pDocView) {}
@@ -521,4 +521,3 @@ CXFA_Document* CXFA_FFWidgetHandler::GetObjFactory() const {
CXFA_Document* CXFA_FFWidgetHandler::GetXFADoc() const {
return m_pDocView->GetDoc()->GetXFADoc();
}
-
diff --git a/xfa/fxfa/xfa_ffwidgethandler.h b/xfa/fxfa/cxfa_ffwidgethandler.h
index 01bdd66786..8f44dbbd45 100644
--- a/xfa/fxfa/xfa_ffwidgethandler.h
+++ b/xfa/fxfa/cxfa_ffwidgethandler.h
@@ -4,8 +4,8 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#ifndef XFA_FXFA_XFA_FFWIDGETHANDLER_H_
-#define XFA_FXFA_XFA_FFWIDGETHANDLER_H_
+#ifndef XFA_FXFA_CXFA_FFWIDGETHANDLER_H_
+#define XFA_FXFA_CXFA_FFWIDGETHANDLER_H_
#include <vector>
@@ -65,7 +65,7 @@ class CXFA_FFWidgetHandler {
bool HasEvent(CXFA_WidgetAcc* pWidgetAcc, XFA_EVENTTYPE eEventType);
int32_t ProcessEvent(CXFA_WidgetAcc* pWidgetAcc, CXFA_EventParam* pParam);
- protected:
+ private:
CXFA_Node* CreateWidgetFormItem(XFA_WIDGETTYPE eType,
CXFA_Node* pParent,
CXFA_Node* pBefore) const;
@@ -116,4 +116,4 @@ class CXFA_FFWidgetHandler {
CXFA_FFDocView* m_pDocView;
};
-#endif // XFA_FXFA_XFA_FFWIDGETHANDLER_H_
+#endif // XFA_FXFA_CXFA_FFWIDGETHANDLER_H_
diff --git a/xfa/fxfa/app/xfa_fontmgr.cpp b/xfa/fxfa/cxfa_fontmgr.cpp
index d7e34fb944..81e296f8a4 100644
--- a/xfa/fxfa/app/xfa_fontmgr.cpp
+++ b/xfa/fxfa/cxfa_fontmgr.cpp
@@ -4,7 +4,7 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#include "xfa/fxfa/xfa_fontmgr.h"
+#include "xfa/fxfa/cxfa_fontmgr.h"
#include <algorithm>
#include <memory>
@@ -15,18 +15,11 @@
#include "core/fpdfapi/parser/cpdf_document.h"
#include "third_party/base/ptr_util.h"
#include "xfa/fgas/font/cfgas_gefont.h"
-#include "xfa/fxfa/xfa_ffapp.h"
-#include "xfa/fxfa/xfa_ffdoc.h"
+#include "xfa/fxfa/cxfa_ffapp.h"
+#include "xfa/fxfa/cxfa_ffdoc.h"
namespace {
-// The 5 names per entry are: PsName, Normal, Bold, Italic, BoldItalic.
-const char* const g_XFAPDFFontName[][5] = {
- {"Adobe PI Std", "AdobePIStd", "AdobePIStd", "AdobePIStd", "AdobePIStd"},
- {"Myriad Pro Light", "MyriadPro-Light", "MyriadPro-Semibold",
- "MyriadPro-LightIt", "MyriadPro-SemiboldIt"},
-};
-
#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
const XFA_FONTINFO g_XFAFontsMap[] = {
{0x01d5d33e, L"SimSun", L"Arial", 0, 936},
@@ -1705,6 +1698,8 @@ const XFA_FONTINFO g_XFAFontsMap[] = {
};
#endif
+} // namespace
+
CFX_WideString XFA_LocalFontNameToEnglishName(
const CFX_WideStringC& wsLocalName) {
uint32_t dwLocalNameHash = FX_HashCode_GetW(wsLocalName, true);
@@ -1736,259 +1731,6 @@ const XFA_FONTINFO* XFA_GetFontINFOByFontName(
return nullptr;
}
-} // namespace
-
-CXFA_DefFontMgr::CXFA_DefFontMgr() {}
-
-CXFA_DefFontMgr::~CXFA_DefFontMgr() {}
-
-CFX_RetainPtr<CFGAS_GEFont> CXFA_DefFontMgr::GetFont(
- CXFA_FFDoc* hDoc,
- const CFX_WideStringC& wsFontFamily,
- uint32_t dwFontStyles,
- uint16_t wCodePage) {
- CFX_WideString wsFontName(wsFontFamily);
- CFGAS_FontMgr* pFDEFontMgr = hDoc->GetApp()->GetFDEFontMgr();
- CFX_RetainPtr<CFGAS_GEFont> pFont =
- pFDEFontMgr->LoadFont(wsFontName.c_str(), dwFontStyles, wCodePage);
- if (!pFont) {
- const XFA_FONTINFO* pCurFont =
- XFA_GetFontINFOByFontName(wsFontName.AsStringC());
- if (pCurFont && pCurFont->pReplaceFont) {
- uint32_t dwStyle = 0;
- if (dwFontStyles & FX_FONTSTYLE_Bold) {
- dwStyle |= FX_FONTSTYLE_Bold;
- }
- if (dwFontStyles & FX_FONTSTYLE_Italic) {
- dwStyle |= FX_FONTSTYLE_Italic;
- }
- const wchar_t* pReplace = pCurFont->pReplaceFont;
- int32_t iLength = FXSYS_wcslen(pReplace);
- while (iLength > 0) {
- const wchar_t* pNameText = pReplace;
- while (*pNameText != L',' && iLength > 0) {
- pNameText++;
- iLength--;
- }
- CFX_WideString wsReplace =
- CFX_WideString(pReplace, pNameText - pReplace);
- pFont = pFDEFontMgr->LoadFont(wsReplace.c_str(), dwStyle, wCodePage);
- if (pFont)
- break;
-
- iLength--;
- pNameText++;
- pReplace = pNameText;
- }
- }
- }
- if (pFont)
- m_CacheFonts.push_back(pFont);
- return pFont;
-}
-
-CFX_RetainPtr<CFGAS_GEFont> CXFA_DefFontMgr::GetDefaultFont(
- CXFA_FFDoc* hDoc,
- const CFX_WideStringC& wsFontFamily,
- uint32_t dwFontStyles,
- uint16_t wCodePage) {
- CFGAS_FontMgr* pFDEFontMgr = hDoc->GetApp()->GetFDEFontMgr();
- CFX_RetainPtr<CFGAS_GEFont> pFont =
- pFDEFontMgr->LoadFont(L"Arial Narrow", dwFontStyles, wCodePage);
- if (!pFont) {
- pFont = pFDEFontMgr->LoadFont(static_cast<const wchar_t*>(nullptr),
- dwFontStyles, wCodePage);
- }
- if (pFont)
- m_CacheFonts.push_back(pFont);
- return pFont;
-}
-
-CXFA_PDFFontMgr::CXFA_PDFFontMgr(CXFA_FFDoc* pDoc) : m_pDoc(pDoc) {}
-
-CXFA_PDFFontMgr::~CXFA_PDFFontMgr() {}
-
-CFX_RetainPtr<CFGAS_GEFont> CXFA_PDFFontMgr::FindFont(
- const CFX_ByteString& strPsName,
- bool bBold,
- bool bItalic,
- CPDF_Font** pDstPDFFont,
- bool bStrictMatch) {
- CPDF_Document* pDoc = m_pDoc->GetPDFDoc();
- if (!pDoc)
- return nullptr;
-
- CPDF_Dictionary* pFontSetDict =
- pDoc->GetRoot()->GetDictFor("AcroForm")->GetDictFor("DR");
- if (!pFontSetDict)
- return nullptr;
-
- pFontSetDict = pFontSetDict->GetDictFor("Font");
- if (!pFontSetDict)
- return nullptr;
-
- CFX_ByteString name = strPsName;
- name.Remove(' ');
- CFGAS_FontMgr* pFDEFontMgr = m_pDoc->GetApp()->GetFDEFontMgr();
- for (const auto& it : *pFontSetDict) {
- const CFX_ByteString& key = it.first;
- CPDF_Object* pObj = it.second.get();
- if (!PsNameMatchDRFontName(name.AsStringC(), bBold, bItalic, key,
- bStrictMatch)) {
- continue;
- }
- CPDF_Dictionary* pFontDict = ToDictionary(pObj->GetDirect());
- if (!pFontDict || pFontDict->GetStringFor("Type") != "Font") {
- return nullptr;
- }
- CPDF_Font* pPDFFont = pDoc->LoadFont(pFontDict);
- if (!pPDFFont) {
- return nullptr;
- }
- if (!pPDFFont->IsEmbedded()) {
- *pDstPDFFont = pPDFFont;
- return nullptr;
- }
- return CFGAS_GEFont::LoadFont(&pPDFFont->m_Font, pFDEFontMgr);
- }
- return nullptr;
-}
-
-CFX_RetainPtr<CFGAS_GEFont> CXFA_PDFFontMgr::GetFont(
- const CFX_WideStringC& wsFontFamily,
- uint32_t dwFontStyles,
- CPDF_Font** pPDFFont,
- bool bStrictMatch) {
- uint32_t dwHashCode = FX_HashCode_GetW(wsFontFamily, false);
- CFX_ByteString strKey;
- strKey.Format("%u%u", dwHashCode, dwFontStyles);
- auto it = m_FontMap.find(strKey);
- if (it != m_FontMap.end())
- return it->second;
- CFX_ByteString bsPsName =
- CFX_ByteString::FromUnicode(CFX_WideString(wsFontFamily));
- bool bBold = (dwFontStyles & FX_FONTSTYLE_Bold) == FX_FONTSTYLE_Bold;
- bool bItalic = (dwFontStyles & FX_FONTSTYLE_Italic) == FX_FONTSTYLE_Italic;
- CFX_ByteString strFontName = PsNameToFontName(bsPsName, bBold, bItalic);
- CFX_RetainPtr<CFGAS_GEFont> pFont =
- FindFont(strFontName, bBold, bItalic, pPDFFont, bStrictMatch);
- if (pFont)
- m_FontMap[strKey] = pFont;
- return pFont;
-}
-
-CFX_ByteString CXFA_PDFFontMgr::PsNameToFontName(
- const CFX_ByteString& strPsName,
- bool bBold,
- bool bItalic) {
- for (size_t i = 0; i < FX_ArraySize(g_XFAPDFFontName); ++i) {
- if (strPsName == g_XFAPDFFontName[i][0]) {
- size_t index = 1;
- if (bBold)
- ++index;
- if (bItalic)
- index += 2;
- return g_XFAPDFFontName[i][index];
- }
- }
- return strPsName;
-}
-
-bool CXFA_PDFFontMgr::PsNameMatchDRFontName(const CFX_ByteStringC& bsPsName,
- bool bBold,
- bool bItalic,
- const CFX_ByteString& bsDRFontName,
- bool bStrictMatch) {
- CFX_ByteString bsDRName = bsDRFontName;
- bsDRName.Remove('-');
- int32_t iPsLen = bsPsName.GetLength();
- int32_t nIndex = bsDRName.Find(bsPsName);
- if (nIndex != -1 && !bStrictMatch)
- return true;
-
- if (nIndex != 0)
- return false;
-
- int32_t iDifferLength = bsDRName.GetLength() - iPsLen;
- if (iDifferLength > 1 || (bBold || bItalic)) {
- int32_t iBoldIndex = bsDRName.Find("Bold");
- bool bBoldFont = iBoldIndex > 0;
- if (bBold != bBoldFont)
- return false;
-
- if (bBoldFont) {
- iDifferLength =
- std::min(iDifferLength - 4, bsDRName.GetLength() - iBoldIndex - 4);
- }
- bool bItalicFont = true;
- if (bsDRName.Find("Italic") > 0) {
- iDifferLength -= 6;
- } else if (bsDRName.Find("It") > 0) {
- iDifferLength -= 2;
- } else if (bsDRName.Find("Oblique") > 0) {
- iDifferLength -= 7;
- } else {
- bItalicFont = false;
- }
- if (bItalic != bItalicFont)
- return false;
-
- if (iDifferLength > 1) {
- CFX_ByteString bsDRTailer = bsDRName.Right(iDifferLength);
- if (bsDRTailer == "MT" || bsDRTailer == "PSMT" ||
- bsDRTailer == "Regular" || bsDRTailer == "Reg") {
- return true;
- }
- if (bBoldFont || bItalicFont)
- return false;
-
- bool bMatch = false;
- switch (bsPsName.GetAt(iPsLen - 1)) {
- case 'L': {
- if (bsDRName.Right(5) == "Light") {
- bMatch = true;
- }
- } break;
- case 'R': {
- if (bsDRName.Right(7) == "Regular" || bsDRName.Right(3) == "Reg") {
- bMatch = true;
- }
- } break;
- case 'M': {
- if (bsDRName.Right(5) == "Medium") {
- bMatch = true;
- }
- } break;
- default:
- break;
- }
- return bMatch;
- }
- }
- return true;
-}
-
-bool CXFA_PDFFontMgr::GetCharWidth(const CFX_RetainPtr<CFGAS_GEFont>& pFont,
- wchar_t wUnicode,
- bool bCharCode,
- int32_t* pWidth) {
- if (wUnicode != 0x20 || bCharCode)
- return false;
-
- auto it = m_FDE2PDFFont.find(pFont);
- if (it == m_FDE2PDFFont.end())
- return false;
-
- CPDF_Font* pPDFFont = it->second;
- *pWidth = pPDFFont->GetCharWidthF(pPDFFont->CharCodeFromUnicode(wUnicode));
- return true;
-}
-
-void CXFA_PDFFontMgr::SetFont(const CFX_RetainPtr<CFGAS_GEFont>& pFont,
- CPDF_Font* pPDFFont) {
- m_FDE2PDFFont[pFont] = pPDFFont;
-}
-
CXFA_FontMgr::CXFA_FontMgr() {}
CXFA_FontMgr::~CXFA_FontMgr() {}
diff --git a/xfa/fxfa/cxfa_fontmgr.h b/xfa/fxfa/cxfa_fontmgr.h
new file mode 100644
index 0000000000..8652a34422
--- /dev/null
+++ b/xfa/fxfa/cxfa_fontmgr.h
@@ -0,0 +1,56 @@
+// Copyright 2014 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef XFA_FXFA_CXFA_FONTMGR_H_
+#define XFA_FXFA_CXFA_FONTMGR_H_
+
+#include <map>
+#include <memory>
+#include <vector>
+
+#include "core/fxcrt/cfx_retain_ptr.h"
+#include "core/fxcrt/fx_ext.h"
+#include "core/fxcrt/fx_system.h"
+#include "xfa/fgas/font/cfgas_fontmgr.h"
+#include "xfa/fxfa/cxfa_deffontmgr.h"
+#include "xfa/fxfa/cxfa_pdffontmgr.h"
+#include "xfa/fxfa/fxfa.h"
+
+class CPDF_Font;
+
+struct XFA_FONTINFO {
+ uint32_t dwFontNameHash;
+ const wchar_t* pPsName;
+ const wchar_t* pReplaceFont;
+ uint16_t dwStyles;
+ uint16_t wCodePage;
+};
+
+CFX_WideString XFA_LocalFontNameToEnglishName(
+ const CFX_WideStringC& wsLocalName);
+const XFA_FONTINFO* XFA_GetFontINFOByFontName(
+ const CFX_WideStringC& wsFontName);
+
+class CXFA_FontMgr {
+ public:
+ CXFA_FontMgr();
+ ~CXFA_FontMgr();
+
+ CFX_RetainPtr<CFGAS_GEFont> GetFont(CXFA_FFDoc* hDoc,
+ const CFX_WideStringC& wsFontFamily,
+ uint32_t dwFontStyles,
+ uint16_t wCodePage = 0xFFFF);
+ void LoadDocFonts(CXFA_FFDoc* hDoc);
+ void ReleaseDocFonts(CXFA_FFDoc* hDoc);
+ void SetDefFontMgr(std::unique_ptr<CXFA_DefFontMgr> pFontMgr);
+
+ private:
+ std::unique_ptr<CXFA_DefFontMgr> m_pDefFontMgr;
+ std::map<CXFA_FFDoc*, std::unique_ptr<CXFA_PDFFontMgr>> m_PDFFontMgrMap;
+ std::map<CFX_ByteString, CFX_RetainPtr<CFGAS_GEFont>> m_FontMap;
+};
+
+#endif // XFA_FXFA_CXFA_FONTMGR_H_
diff --git a/xfa/fxfa/cxfa_pdffontmgr.cpp b/xfa/fxfa/cxfa_pdffontmgr.cpp
new file mode 100644
index 0000000000..cadb7cbab5
--- /dev/null
+++ b/xfa/fxfa/cxfa_pdffontmgr.cpp
@@ -0,0 +1,208 @@
+// Copyright 2017 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "xfa/fxfa/cxfa_pdffontmgr.h"
+
+#include <algorithm>
+
+#include "core/fpdfapi/font/cpdf_font.h"
+#include "xfa/fxfa/cxfa_ffapp.h"
+
+namespace {
+
+// The 5 names per entry are: PsName, Normal, Bold, Italic, BoldItalic.
+const char* const g_XFAPDFFontName[][5] = {
+ {"Adobe PI Std", "AdobePIStd", "AdobePIStd", "AdobePIStd", "AdobePIStd"},
+ {"Myriad Pro Light", "MyriadPro-Light", "MyriadPro-Semibold",
+ "MyriadPro-LightIt", "MyriadPro-SemiboldIt"},
+};
+
+} // namespace
+
+CXFA_PDFFontMgr::CXFA_PDFFontMgr(CXFA_FFDoc* pDoc) : m_pDoc(pDoc) {}
+
+CXFA_PDFFontMgr::~CXFA_PDFFontMgr() {}
+
+CFX_RetainPtr<CFGAS_GEFont> CXFA_PDFFontMgr::FindFont(
+ const CFX_ByteString& strPsName,
+ bool bBold,
+ bool bItalic,
+ CPDF_Font** pDstPDFFont,
+ bool bStrictMatch) {
+ CPDF_Document* pDoc = m_pDoc->GetPDFDoc();
+ if (!pDoc)
+ return nullptr;
+
+ CPDF_Dictionary* pFontSetDict =
+ pDoc->GetRoot()->GetDictFor("AcroForm")->GetDictFor("DR");
+ if (!pFontSetDict)
+ return nullptr;
+
+ pFontSetDict = pFontSetDict->GetDictFor("Font");
+ if (!pFontSetDict)
+ return nullptr;
+
+ CFX_ByteString name = strPsName;
+ name.Remove(' ');
+ CFGAS_FontMgr* pFDEFontMgr = m_pDoc->GetApp()->GetFDEFontMgr();
+ for (const auto& it : *pFontSetDict) {
+ const CFX_ByteString& key = it.first;
+ CPDF_Object* pObj = it.second.get();
+ if (!PsNameMatchDRFontName(name.AsStringC(), bBold, bItalic, key,
+ bStrictMatch)) {
+ continue;
+ }
+ CPDF_Dictionary* pFontDict = ToDictionary(pObj->GetDirect());
+ if (!pFontDict || pFontDict->GetStringFor("Type") != "Font") {
+ return nullptr;
+ }
+ CPDF_Font* pPDFFont = pDoc->LoadFont(pFontDict);
+ if (!pPDFFont) {
+ return nullptr;
+ }
+ if (!pPDFFont->IsEmbedded()) {
+ *pDstPDFFont = pPDFFont;
+ return nullptr;
+ }
+ return CFGAS_GEFont::LoadFont(&pPDFFont->m_Font, pFDEFontMgr);
+ }
+ return nullptr;
+}
+
+CFX_RetainPtr<CFGAS_GEFont> CXFA_PDFFontMgr::GetFont(
+ const CFX_WideStringC& wsFontFamily,
+ uint32_t dwFontStyles,
+ CPDF_Font** pPDFFont,
+ bool bStrictMatch) {
+ uint32_t dwHashCode = FX_HashCode_GetW(wsFontFamily, false);
+ CFX_ByteString strKey;
+ strKey.Format("%u%u", dwHashCode, dwFontStyles);
+ auto it = m_FontMap.find(strKey);
+ if (it != m_FontMap.end())
+ return it->second;
+ CFX_ByteString bsPsName =
+ CFX_ByteString::FromUnicode(CFX_WideString(wsFontFamily));
+ bool bBold = (dwFontStyles & FX_FONTSTYLE_Bold) == FX_FONTSTYLE_Bold;
+ bool bItalic = (dwFontStyles & FX_FONTSTYLE_Italic) == FX_FONTSTYLE_Italic;
+ CFX_ByteString strFontName = PsNameToFontName(bsPsName, bBold, bItalic);
+ CFX_RetainPtr<CFGAS_GEFont> pFont =
+ FindFont(strFontName, bBold, bItalic, pPDFFont, bStrictMatch);
+ if (pFont)
+ m_FontMap[strKey] = pFont;
+ return pFont;
+}
+
+CFX_ByteString CXFA_PDFFontMgr::PsNameToFontName(
+ const CFX_ByteString& strPsName,
+ bool bBold,
+ bool bItalic) {
+ for (size_t i = 0; i < FX_ArraySize(g_XFAPDFFontName); ++i) {
+ if (strPsName == g_XFAPDFFontName[i][0]) {
+ size_t index = 1;
+ if (bBold)
+ ++index;
+ if (bItalic)
+ index += 2;
+ return g_XFAPDFFontName[i][index];
+ }
+ }
+ return strPsName;
+}
+
+bool CXFA_PDFFontMgr::PsNameMatchDRFontName(const CFX_ByteStringC& bsPsName,
+ bool bBold,
+ bool bItalic,
+ const CFX_ByteString& bsDRFontName,
+ bool bStrictMatch) {
+ CFX_ByteString bsDRName = bsDRFontName;
+ bsDRName.Remove('-');
+ int32_t iPsLen = bsPsName.GetLength();
+ int32_t nIndex = bsDRName.Find(bsPsName);
+ if (nIndex != -1 && !bStrictMatch)
+ return true;
+
+ if (nIndex != 0)
+ return false;
+
+ int32_t iDifferLength = bsDRName.GetLength() - iPsLen;
+ if (iDifferLength > 1 || (bBold || bItalic)) {
+ int32_t iBoldIndex = bsDRName.Find("Bold");
+ bool bBoldFont = iBoldIndex > 0;
+ if (bBold != bBoldFont)
+ return false;
+
+ if (bBoldFont) {
+ iDifferLength =
+ std::min(iDifferLength - 4, bsDRName.GetLength() - iBoldIndex - 4);
+ }
+ bool bItalicFont = true;
+ if (bsDRName.Find("Italic") > 0) {
+ iDifferLength -= 6;
+ } else if (bsDRName.Find("It") > 0) {
+ iDifferLength -= 2;
+ } else if (bsDRName.Find("Oblique") > 0) {
+ iDifferLength -= 7;
+ } else {
+ bItalicFont = false;
+ }
+ if (bItalic != bItalicFont)
+ return false;
+
+ if (iDifferLength > 1) {
+ CFX_ByteString bsDRTailer = bsDRName.Right(iDifferLength);
+ if (bsDRTailer == "MT" || bsDRTailer == "PSMT" ||
+ bsDRTailer == "Regular" || bsDRTailer == "Reg") {
+ return true;
+ }
+ if (bBoldFont || bItalicFont)
+ return false;
+
+ bool bMatch = false;
+ switch (bsPsName.GetAt(iPsLen - 1)) {
+ case 'L': {
+ if (bsDRName.Right(5) == "Light") {
+ bMatch = true;
+ }
+ } break;
+ case 'R': {
+ if (bsDRName.Right(7) == "Regular" || bsDRName.Right(3) == "Reg") {
+ bMatch = true;
+ }
+ } break;
+ case 'M': {
+ if (bsDRName.Right(5) == "Medium") {
+ bMatch = true;
+ }
+ } break;
+ default:
+ break;
+ }
+ return bMatch;
+ }
+ }
+ return true;
+}
+
+bool CXFA_PDFFontMgr::GetCharWidth(const CFX_RetainPtr<CFGAS_GEFont>& pFont,
+ wchar_t wUnicode,
+ bool bCharCode,
+ int32_t* pWidth) {
+ if (wUnicode != 0x20 || bCharCode)
+ return false;
+
+ auto it = m_FDE2PDFFont.find(pFont);
+ if (it == m_FDE2PDFFont.end())
+ return false;
+
+ CPDF_Font* pPDFFont = it->second;
+ *pWidth = pPDFFont->GetCharWidthF(pPDFFont->CharCodeFromUnicode(wUnicode));
+ return true;
+}
+
+void CXFA_PDFFontMgr::SetFont(const CFX_RetainPtr<CFGAS_GEFont>& pFont,
+ CPDF_Font* pPDFFont) {
+ m_FDE2PDFFont[pFont] = pPDFFont;
+}
diff --git a/xfa/fxfa/xfa_fontmgr.h b/xfa/fxfa/cxfa_pdffontmgr.h
index b3ed8ab236..1188ce1fba 100644
--- a/xfa/fxfa/xfa_fontmgr.h
+++ b/xfa/fxfa/cxfa_pdffontmgr.h
@@ -1,50 +1,23 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
+// 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_XFA_FONTMGR_H_
-#define XFA_FXFA_XFA_FONTMGR_H_
+#ifndef XFA_FXFA_CXFA_PDFFONTMGR_H_
+#define XFA_FXFA_CXFA_PDFFONTMGR_H_
#include <map>
-#include <memory>
-#include <vector>
+#include "core/fpdfapi/parser/cpdf_dictionary.h"
+#include "core/fpdfapi/parser/cpdf_document.h"
#include "core/fxcrt/cfx_retain_ptr.h"
-#include "core/fxcrt/fx_ext.h"
-#include "core/fxcrt/fx_system.h"
-#include "xfa/fgas/font/cfgas_fontmgr.h"
-#include "xfa/fxfa/fxfa.h"
+#include "core/fxcrt/fx_string.h"
+#include "xfa/fgas/font/cfgas_gefont.h"
+#include "xfa/fxfa/cxfa_ffdoc.h"
class CPDF_Font;
-
-struct XFA_FONTINFO {
- uint32_t dwFontNameHash;
- const wchar_t* pPsName;
- const wchar_t* pReplaceFont;
- uint16_t dwStyles;
- uint16_t wCodePage;
-};
-
-class CXFA_DefFontMgr {
- public:
- CXFA_DefFontMgr();
- ~CXFA_DefFontMgr();
-
- CFX_RetainPtr<CFGAS_GEFont> GetFont(CXFA_FFDoc* hDoc,
- const CFX_WideStringC& wsFontFamily,
- uint32_t dwFontStyles,
- uint16_t wCodePage = 0xFFFF);
- CFX_RetainPtr<CFGAS_GEFont> GetDefaultFont(
- CXFA_FFDoc* hDoc,
- const CFX_WideStringC& wsFontFamily,
- uint32_t dwFontStyles,
- uint16_t wCodePage = 0xFFFF);
-
- protected:
- std::vector<CFX_RetainPtr<CFGAS_GEFont>> m_CacheFonts;
-};
+class CXFA_FFDoc;
class CXFA_PDFFontMgr {
public:
@@ -61,7 +34,7 @@ class CXFA_PDFFontMgr {
int32_t* pWidth);
void SetFont(const CFX_RetainPtr<CFGAS_GEFont>& pFont, CPDF_Font* pPDFFont);
- protected:
+ private:
CFX_RetainPtr<CFGAS_GEFont> FindFont(const CFX_ByteString& strFamilyName,
bool bBold,
bool bItalic,
@@ -81,23 +54,4 @@ class CXFA_PDFFontMgr {
std::map<CFX_ByteString, CFX_RetainPtr<CFGAS_GEFont>> m_FontMap;
};
-class CXFA_FontMgr {
- public:
- CXFA_FontMgr();
- ~CXFA_FontMgr();
-
- CFX_RetainPtr<CFGAS_GEFont> GetFont(CXFA_FFDoc* hDoc,
- const CFX_WideStringC& wsFontFamily,
- uint32_t dwFontStyles,
- uint16_t wCodePage = 0xFFFF);
- void LoadDocFonts(CXFA_FFDoc* hDoc);
- void ReleaseDocFonts(CXFA_FFDoc* hDoc);
- void SetDefFontMgr(std::unique_ptr<CXFA_DefFontMgr> pFontMgr);
-
- protected:
- std::unique_ptr<CXFA_DefFontMgr> m_pDefFontMgr;
- std::map<CXFA_FFDoc*, std::unique_ptr<CXFA_PDFFontMgr>> m_PDFFontMgrMap;
- std::map<CFX_ByteString, CFX_RetainPtr<CFGAS_GEFont>> m_FontMap;
-};
-
-#endif // XFA_FXFA_XFA_FONTMGR_H_
+#endif // XFA_FXFA_CXFA_PDFFONTMGR_H_
diff --git a/xfa/fxfa/app/xfa_rendercontext.cpp b/xfa/fxfa/cxfa_rendercontext.cpp
index a855105e3d..ecb42918cb 100644
--- a/xfa/fxfa/app/xfa_rendercontext.cpp
+++ b/xfa/fxfa/cxfa_rendercontext.cpp
@@ -4,10 +4,10 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#include "xfa/fxfa/xfa_rendercontext.h"
+#include "xfa/fxfa/cxfa_rendercontext.h"
-#include "xfa/fxfa/xfa_ffpageview.h"
-#include "xfa/fxfa/xfa_ffwidget.h"
+#include "xfa/fxfa/cxfa_ffpageview.h"
+#include "xfa/fxfa/cxfa_ffwidget.h"
#include "xfa/fxgraphics/cfx_graphics.h"
namespace {
diff --git a/xfa/fxfa/xfa_rendercontext.h b/xfa/fxfa/cxfa_rendercontext.h
index c424005b1e..960bd058d1 100644
--- a/xfa/fxfa/xfa_rendercontext.h
+++ b/xfa/fxfa/cxfa_rendercontext.h
@@ -4,8 +4,8 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#ifndef XFA_FXFA_XFA_RENDERCONTEXT_H_
-#define XFA_FXFA_XFA_RENDERCONTEXT_H_
+#ifndef XFA_FXFA_CXFA_RENDERCONTEXT_H_
+#define XFA_FXFA_CXFA_RENDERCONTEXT_H_
#include <memory>
@@ -31,7 +31,7 @@ class CXFA_RenderContext {
int32_t DoRender(IFX_Pause* pPause = nullptr);
void StopRender();
- protected:
+ private:
std::unique_ptr<IXFA_WidgetIterator> m_pWidgetIterator;
CXFA_FFWidget* m_pWidget;
CXFA_FFPageView* m_pPageView;
@@ -42,4 +42,4 @@ class CXFA_RenderContext {
CFX_RectF m_rtClipRect;
};
-#endif // XFA_FXFA_XFA_RENDERCONTEXT_H_
+#endif // XFA_FXFA_CXFA_RENDERCONTEXT_H_
diff --git a/xfa/fxfa/cxfa_saxcontext.h b/xfa/fxfa/cxfa_saxcontext.h
new file mode 100644
index 0000000000..47e7b78423
--- /dev/null
+++ b/xfa/fxfa/cxfa_saxcontext.h
@@ -0,0 +1,19 @@
+// Copyright 2017 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef XFA_FXFA_CXFA_SAXCONTEXT_H_
+#define XFA_FXFA_CXFA_SAXCONTEXT_H_
+
+class CXFA_SAXContext {
+ public:
+ CXFA_SAXContext() : m_eNode(CFX_SAXItem::Type::Unknown) {}
+
+ CFX_ByteTextBuf m_TextBuf;
+ CFX_ByteString m_bsTagName;
+ CFX_SAXItem::Type m_eNode;
+};
+
+#endif // XFA_FXFA_CXFA_SAXCONTEXT_H_
diff --git a/xfa/fxfa/cxfa_saxreaderhandler.cpp b/xfa/fxfa/cxfa_saxreaderhandler.cpp
new file mode 100644
index 0000000000..c09bdf5b4c
--- /dev/null
+++ b/xfa/fxfa/cxfa_saxreaderhandler.cpp
@@ -0,0 +1,129 @@
+// Copyright 2017 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "xfa/fxfa/cxfa_saxreaderhandler.h"
+
+#include "xfa/fxfa/cxfa_checksumcontext.h"
+
+CXFA_SAXReaderHandler::CXFA_SAXReaderHandler(CXFA_ChecksumContext* pContext)
+ : m_pContext(pContext) {
+ ASSERT(m_pContext);
+}
+
+CXFA_SAXReaderHandler::~CXFA_SAXReaderHandler() {}
+
+CXFA_SAXContext* CXFA_SAXReaderHandler::OnTagEnter(
+ const CFX_ByteStringC& bsTagName,
+ CFX_SAXItem::Type eType,
+ uint32_t dwStartPos) {
+ UpdateChecksum(true);
+ if (eType != CFX_SAXItem::Type::Tag &&
+ eType != CFX_SAXItem::Type::Instruction) {
+ return nullptr;
+ }
+
+ m_SAXContext.m_eNode = eType;
+ CFX_ByteTextBuf& textBuf = m_SAXContext.m_TextBuf;
+ textBuf << "<";
+ if (eType == CFX_SAXItem::Type::Instruction)
+ textBuf << "?";
+
+ textBuf << bsTagName;
+ m_SAXContext.m_bsTagName = bsTagName;
+ return &m_SAXContext;
+}
+
+void CXFA_SAXReaderHandler::OnTagAttribute(CXFA_SAXContext* pTag,
+ const CFX_ByteStringC& bsAttri,
+ const CFX_ByteStringC& bsValue) {
+ if (!pTag)
+ return;
+ pTag->m_TextBuf << " " << bsAttri << "=\"" << bsValue << "\"";
+}
+
+void CXFA_SAXReaderHandler::OnTagBreak(CXFA_SAXContext* pTag) {
+ if (!pTag)
+ return;
+
+ pTag->m_TextBuf << ">";
+ UpdateChecksum(false);
+}
+
+void CXFA_SAXReaderHandler::OnTagData(CXFA_SAXContext* pTag,
+ CFX_SAXItem::Type eType,
+ const CFX_ByteStringC& bsData,
+ uint32_t dwStartPos) {
+ if (!pTag)
+ return;
+
+ CFX_ByteTextBuf& textBuf = pTag->m_TextBuf;
+ if (eType == CFX_SAXItem::Type::CharData)
+ textBuf << "<![CDATA[";
+
+ textBuf << bsData;
+ if (eType == CFX_SAXItem::Type::CharData)
+ textBuf << "]]>";
+}
+
+void CXFA_SAXReaderHandler::OnTagClose(CXFA_SAXContext* pTag,
+ uint32_t dwEndPos) {
+ if (!pTag)
+ return;
+
+ CFX_ByteTextBuf& textBuf = pTag->m_TextBuf;
+ if (pTag->m_eNode == CFX_SAXItem::Type::Instruction)
+ textBuf << "?>";
+ else if (pTag->m_eNode == CFX_SAXItem::Type::Tag)
+ textBuf << "></" << pTag->m_bsTagName.AsStringC() << ">";
+
+ UpdateChecksum(false);
+}
+
+void CXFA_SAXReaderHandler::OnTagEnd(CXFA_SAXContext* pTag,
+ const CFX_ByteStringC& bsTagName,
+ uint32_t dwEndPos) {
+ if (!pTag)
+ return;
+
+ pTag->m_TextBuf << "</" << bsTagName << ">";
+ UpdateChecksum(false);
+}
+
+void CXFA_SAXReaderHandler::OnTargetData(CXFA_SAXContext* pTag,
+ CFX_SAXItem::Type eType,
+ const CFX_ByteStringC& bsData,
+ uint32_t dwStartPos) {
+ if (!pTag && eType != CFX_SAXItem::Type::Comment)
+ return;
+
+ if (eType == CFX_SAXItem::Type::Comment) {
+ m_SAXContext.m_TextBuf << "<!--" << bsData << "-->";
+ UpdateChecksum(false);
+ } else {
+ pTag->m_TextBuf << " " << bsData;
+ }
+}
+
+void CXFA_SAXReaderHandler::UpdateChecksum(bool bCheckSpace) {
+ int32_t iLength = m_SAXContext.m_TextBuf.GetLength();
+ if (iLength < 1)
+ return;
+
+ uint8_t* pBuffer = m_SAXContext.m_TextBuf.GetBuffer();
+ bool bUpdata = true;
+ if (bCheckSpace) {
+ bUpdata = false;
+ for (int32_t i = 0; i < iLength; i++) {
+ bUpdata = (pBuffer[i] > 0x20);
+ if (bUpdata)
+ break;
+ }
+ }
+ if (bUpdata)
+ m_pContext->Update(CFX_ByteStringC(pBuffer, iLength));
+
+ m_SAXContext.m_TextBuf.Clear();
+}
diff --git a/xfa/fxfa/xfa_checksum.h b/xfa/fxfa/cxfa_saxreaderhandler.h
index 31cf101553..3ad69322bb 100644
--- a/xfa/fxfa/xfa_checksum.h
+++ b/xfa/fxfa/cxfa_saxreaderhandler.h
@@ -1,30 +1,18 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
+// 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_XFA_CHECKSUM_H_
-#define XFA_FXFA_XFA_CHECKSUM_H_
+#ifndef XFA_FXFA_CXFA_SAXREADERHANDLER_H_
+#define XFA_FXFA_CXFA_SAXREADERHANDLER_H_
-#include <memory>
-
-#include "core/fdrm/crypto/fx_crypt.h"
+#include "core/fxcrt/fx_string.h"
#include "xfa/fde/xml/cfx_saxreader.h"
-#include "xfa/fxfa/fxfa.h"
+#include "xfa/fxfa/cxfa_saxcontext.h"
-class CXFA_SAXReaderHandler;
class CXFA_ChecksumContext;
-class CXFA_SAXContext {
- public:
- CXFA_SAXContext() : m_eNode(CFX_SAXItem::Type::Unknown) {}
-
- CFX_ByteTextBuf m_TextBuf;
- CFX_ByteString m_bsTagName;
- CFX_SAXItem::Type m_eNode;
-};
-
class CXFA_SAXReaderHandler {
public:
explicit CXFA_SAXReaderHandler(CXFA_ChecksumContext* pContext);
@@ -51,30 +39,11 @@ class CXFA_SAXReaderHandler {
const CFX_ByteStringC& bsData,
uint32_t dwStartPos);
- protected:
+ private:
void UpdateChecksum(bool bCheckSpace);
CXFA_ChecksumContext* m_pContext;
CXFA_SAXContext m_SAXContext;
};
-class CXFA_ChecksumContext {
- public:
- CXFA_ChecksumContext();
- ~CXFA_ChecksumContext();
-
- void StartChecksum();
- void Update(const CFX_ByteStringC& bsText);
- bool UpdateChecksum(const CFX_RetainPtr<IFX_SeekableReadStream>& pSrcFile,
- FX_FILESIZE offset = 0,
- size_t size = 0);
- void FinishChecksum();
- CFX_ByteString GetChecksum() const;
-
- protected:
- std::unique_ptr<CFX_SAXReader> m_pSAXReader;
- std::unique_ptr<CRYPT_sha1_context> m_pByteContext;
- CFX_ByteString m_bsChecksum;
-};
-
-#endif // XFA_FXFA_XFA_CHECKSUM_H_
+#endif // XFA_FXFA_CXFA_SAXREADERHANDLER_H_
diff --git a/xfa/fxfa/cxfa_widgetacc.cpp b/xfa/fxfa/cxfa_widgetacc.cpp
new file mode 100644
index 0000000000..4c8e37291a
--- /dev/null
+++ b/xfa/fxfa/cxfa_widgetacc.cpp
@@ -0,0 +1,1549 @@
+// Copyright 2017 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "xfa/fxfa/cxfa_widgetacc.h"
+
+#include <algorithm>
+#include <vector>
+
+#include "third_party/base/stl_util.h"
+#include "xfa/fde/tto/fde_textout.h"
+#include "xfa/fde/xml/fde_xml_imp.h"
+#include "xfa/fxfa/app/cxfa_textlayout.h"
+#include "xfa/fxfa/app/xfa_ffwidgetacc.h"
+#include "xfa/fxfa/cxfa_ffapp.h"
+#include "xfa/fxfa/cxfa_ffdoc.h"
+#include "xfa/fxfa/cxfa_ffdocview.h"
+#include "xfa/fxfa/cxfa_ffwidget.h"
+#include "xfa/fxfa/cxfa_fontmgr.h"
+#include "xfa/fxfa/parser/cxfa_layoutprocessor.h"
+#include "xfa/fxfa/parser/cxfa_scriptcontext.h"
+#include "xfa/fxfa/parser/xfa_localevalue.h"
+#include "xfa/fxfa/parser/xfa_utils.h"
+
+class CXFA_WidgetLayoutData {
+ public:
+ CXFA_WidgetLayoutData() : m_fWidgetHeight(-1) {}
+ virtual ~CXFA_WidgetLayoutData() {}
+
+ float m_fWidgetHeight;
+};
+
+namespace {
+
+void FFDeleteCalcData(void* pData) {
+ if (pData)
+ delete ((CXFA_CalcData*)pData);
+}
+
+static XFA_MAPDATABLOCKCALLBACKINFO gs_XFADeleteCalcData = {FFDeleteCalcData,
+ nullptr};
+
+class CXFA_TextLayoutData : public CXFA_WidgetLayoutData {
+ public:
+ CXFA_TextLayoutData() {}
+ ~CXFA_TextLayoutData() override {}
+
+ CXFA_TextLayout* GetTextLayout() const { return m_pTextLayout.get(); }
+ CXFA_TextProvider* GetTextProvider() const { return m_pTextProvider.get(); }
+
+ void LoadText(CXFA_WidgetAcc* pAcc) {
+ if (m_pTextLayout)
+ return;
+
+ m_pTextProvider =
+ pdfium::MakeUnique<CXFA_TextProvider>(pAcc, XFA_TEXTPROVIDERTYPE_Text);
+ m_pTextLayout = pdfium::MakeUnique<CXFA_TextLayout>(m_pTextProvider.get());
+ }
+
+ private:
+ std::unique_ptr<CXFA_TextLayout> m_pTextLayout;
+ std::unique_ptr<CXFA_TextProvider> m_pTextProvider;
+};
+
+class CXFA_ImageLayoutData : public CXFA_WidgetLayoutData {
+ public:
+ CXFA_ImageLayoutData()
+ : m_pDIBitmap(nullptr),
+ m_bNamedImage(false),
+ m_iImageXDpi(0),
+ m_iImageYDpi(0) {}
+
+ ~CXFA_ImageLayoutData() override {
+ if (m_pDIBitmap && !m_bNamedImage)
+ delete m_pDIBitmap;
+ }
+
+ bool LoadImageData(CXFA_WidgetAcc* pAcc) {
+ if (m_pDIBitmap)
+ return true;
+
+ CXFA_Value value = pAcc->GetFormValue();
+ if (!value)
+ return false;
+
+ CXFA_Image imageObj = value.GetImage();
+ if (!imageObj)
+ return false;
+
+ CXFA_FFDoc* pFFDoc = pAcc->GetDoc();
+ pAcc->SetImageImage(XFA_LoadImageData(pFFDoc, &imageObj, m_bNamedImage,
+ m_iImageXDpi, m_iImageYDpi));
+ return !!m_pDIBitmap;
+ }
+
+ CFX_DIBitmap* m_pDIBitmap;
+ bool m_bNamedImage;
+ int32_t m_iImageXDpi;
+ int32_t m_iImageYDpi;
+};
+
+class CXFA_FieldLayoutData : public CXFA_WidgetLayoutData {
+ public:
+ CXFA_FieldLayoutData() {}
+ ~CXFA_FieldLayoutData() override {}
+
+ bool LoadCaption(CXFA_WidgetAcc* pAcc) {
+ if (m_pCapTextLayout)
+ return true;
+ CXFA_Caption caption = pAcc->GetCaption();
+ if (!caption || caption.GetPresence() == XFA_ATTRIBUTEENUM_Hidden)
+ return false;
+ m_pCapTextProvider.reset(
+ new CXFA_TextProvider(pAcc, XFA_TEXTPROVIDERTYPE_Caption));
+ m_pCapTextLayout =
+ pdfium::MakeUnique<CXFA_TextLayout>(m_pCapTextProvider.get());
+ return true;
+ }
+
+ std::unique_ptr<CXFA_TextLayout> m_pCapTextLayout;
+ std::unique_ptr<CXFA_TextProvider> m_pCapTextProvider;
+ std::unique_ptr<CFDE_TextOut> m_pTextOut;
+ std::vector<float> m_FieldSplitArray;
+};
+
+class CXFA_TextEditData : public CXFA_FieldLayoutData {
+ public:
+};
+
+class CXFA_ImageEditData : public CXFA_FieldLayoutData {
+ public:
+ CXFA_ImageEditData()
+ : m_pDIBitmap(nullptr),
+ m_bNamedImage(false),
+ m_iImageXDpi(0),
+ m_iImageYDpi(0) {}
+
+ ~CXFA_ImageEditData() override {
+ if (m_pDIBitmap && !m_bNamedImage)
+ delete m_pDIBitmap;
+ }
+
+ bool LoadImageData(CXFA_WidgetAcc* pAcc) {
+ if (m_pDIBitmap)
+ return true;
+
+ CXFA_Value value = pAcc->GetFormValue();
+ if (!value)
+ return false;
+
+ CXFA_Image imageObj = value.GetImage();
+ CXFA_FFDoc* pFFDoc = pAcc->GetDoc();
+ pAcc->SetImageEditImage(XFA_LoadImageData(pFFDoc, &imageObj, m_bNamedImage,
+ m_iImageXDpi, m_iImageYDpi));
+ return !!m_pDIBitmap;
+ }
+
+ CFX_DIBitmap* m_pDIBitmap;
+ bool m_bNamedImage;
+ int32_t m_iImageXDpi;
+ int32_t m_iImageYDpi;
+};
+
+} // namespace
+
+CXFA_WidgetAcc::CXFA_WidgetAcc(CXFA_FFDocView* pDocView, CXFA_Node* pNode)
+ : CXFA_WidgetData(pNode), m_pDocView(pDocView), m_nRecursionDepth(0) {}
+
+CXFA_WidgetAcc::~CXFA_WidgetAcc() {}
+
+bool CXFA_WidgetAcc::GetName(CFX_WideString& wsName, int32_t iNameType) {
+ if (iNameType == 0) {
+ m_pNode->TryCData(XFA_ATTRIBUTE_Name, wsName);
+ return !wsName.IsEmpty();
+ }
+ m_pNode->GetSOMExpression(wsName);
+ if (iNameType == 2 && wsName.GetLength() >= 15) {
+ CFX_WideStringC wsPre = L"xfa[0].form[0].";
+ if (wsPre == CFX_WideStringC(wsName.c_str(), wsPre.GetLength()))
+ wsName.Delete(0, wsPre.GetLength());
+ }
+ return true;
+}
+
+CXFA_Node* CXFA_WidgetAcc::GetDatasets() {
+ return m_pNode->GetBindData();
+}
+
+bool CXFA_WidgetAcc::ProcessValueChanged() {
+ m_pDocView->AddValidateWidget(this);
+ m_pDocView->AddCalculateWidgetAcc(this);
+ m_pDocView->RunCalculateWidgets();
+ m_pDocView->RunValidate();
+ return true;
+}
+
+void CXFA_WidgetAcc::ResetData() {
+ CFX_WideString wsValue;
+ XFA_Element eUIType = GetUIType();
+ switch (eUIType) {
+ case XFA_Element::ImageEdit: {
+ CXFA_Value imageValue = GetDefaultValue();
+ CXFA_Image image = imageValue.GetImage();
+ CFX_WideString wsContentType, wsHref;
+ if (image) {
+ image.GetContent(wsValue);
+ image.GetContentType(wsContentType);
+ image.GetHref(wsHref);
+ }
+ SetImageEdit(wsContentType, wsHref, wsValue);
+ break;
+ }
+ case XFA_Element::ExclGroup: {
+ CXFA_Node* pNextChild = m_pNode->GetNodeItem(
+ XFA_NODEITEM_FirstChild, XFA_ObjectType::ContainerNode);
+ while (pNextChild) {
+ CXFA_Node* pChild = pNextChild;
+ CXFA_WidgetAcc* pAcc =
+ static_cast<CXFA_WidgetAcc*>(pChild->GetWidgetData());
+ if (!pAcc)
+ continue;
+
+ CXFA_Value defValue(nullptr);
+ if (wsValue.IsEmpty() && (defValue = pAcc->GetDefaultValue())) {
+ defValue.GetChildValueContent(wsValue);
+ SetValue(wsValue, XFA_VALUEPICTURE_Raw);
+ pAcc->SetValue(wsValue, XFA_VALUEPICTURE_Raw);
+ } else {
+ CXFA_Node* pItems = pChild->GetChild(0, XFA_Element::Items);
+ if (!pItems)
+ continue;
+
+ CFX_WideString itemText;
+ if (pItems->CountChildren(XFA_Element::Unknown) > 1)
+ itemText = pItems->GetChild(1, XFA_Element::Unknown)->GetContent();
+
+ pAcc->SetValue(itemText, XFA_VALUEPICTURE_Raw);
+ }
+ pNextChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling,
+ XFA_ObjectType::ContainerNode);
+ }
+ break;
+ }
+ case XFA_Element::ChoiceList:
+ ClearAllSelections();
+ default:
+ if (CXFA_Value defValue = GetDefaultValue())
+ defValue.GetChildValueContent(wsValue);
+
+ SetValue(wsValue, XFA_VALUEPICTURE_Raw);
+ break;
+ }
+}
+
+void CXFA_WidgetAcc::SetImageEdit(const CFX_WideString& wsContentType,
+ const CFX_WideString& wsHref,
+ const CFX_WideString& wsData) {
+ CXFA_Image image = GetFormValue().GetImage();
+ if (image) {
+ image.SetContentType(CFX_WideString(wsContentType));
+ image.SetHref(wsHref);
+ }
+ CFX_WideString wsFormatValue(wsData);
+ GetFormatDataValue(wsData, wsFormatValue);
+ m_pNode->SetContent(wsData, wsFormatValue, true);
+ CXFA_Node* pBind = GetDatasets();
+ if (!pBind) {
+ image.SetTransferEncoding(XFA_ATTRIBUTEENUM_Base64);
+ return;
+ }
+ pBind->SetCData(XFA_ATTRIBUTE_ContentType, wsContentType);
+ CXFA_Node* pHrefNode = pBind->GetNodeItem(XFA_NODEITEM_FirstChild);
+ if (pHrefNode) {
+ pHrefNode->SetCData(XFA_ATTRIBUTE_Value, wsHref);
+ } else {
+ CFDE_XMLNode* pXMLNode = pBind->GetXMLMappingNode();
+ ASSERT(pXMLNode && pXMLNode->GetType() == FDE_XMLNODE_Element);
+ static_cast<CFDE_XMLElement*>(pXMLNode)->SetString(L"href", wsHref);
+ }
+}
+
+CXFA_WidgetAcc* CXFA_WidgetAcc::GetExclGroup() {
+ CXFA_Node* pExcl = m_pNode->GetNodeItem(XFA_NODEITEM_Parent);
+ if (!pExcl || pExcl->GetElementType() != XFA_Element::ExclGroup)
+ return nullptr;
+ return static_cast<CXFA_WidgetAcc*>(pExcl->GetWidgetData());
+}
+
+CXFA_FFDocView* CXFA_WidgetAcc::GetDocView() {
+ return m_pDocView;
+}
+
+CXFA_FFDoc* CXFA_WidgetAcc::GetDoc() {
+ return m_pDocView->GetDoc();
+}
+
+CXFA_FFApp* CXFA_WidgetAcc::GetApp() {
+ return GetDoc()->GetApp();
+}
+
+IXFA_AppProvider* CXFA_WidgetAcc::GetAppProvider() {
+ return GetApp()->GetAppProvider();
+}
+
+int32_t CXFA_WidgetAcc::ProcessEvent(int32_t iActivity,
+ CXFA_EventParam* pEventParam) {
+ if (GetElementType() == XFA_Element::Draw)
+ return XFA_EVENTERROR_NotExist;
+
+ std::vector<CXFA_Node*> eventArray =
+ GetEventByActivity(iActivity, pEventParam->m_bIsFormReady);
+ bool first = true;
+ int32_t iRet = XFA_EVENTERROR_NotExist;
+ for (CXFA_Node* pNode : eventArray) {
+ int32_t result = ProcessEvent(CXFA_Event(pNode), pEventParam);
+ if (first || result == XFA_EVENTERROR_Success)
+ iRet = result;
+ first = false;
+ }
+ return iRet;
+}
+
+int32_t CXFA_WidgetAcc::ProcessEvent(const CXFA_Event& event,
+ CXFA_EventParam* pEventParam) {
+ if (!event)
+ return XFA_EVENTERROR_NotExist;
+
+ switch (event.GetEventType()) {
+ case XFA_Element::Execute:
+ break;
+ case XFA_Element::Script:
+ return ExecuteScript(event.GetScript(), pEventParam);
+ case XFA_Element::SignData:
+ break;
+ case XFA_Element::Submit:
+ return GetDoc()->GetDocEnvironment()->SubmitData(GetDoc(),
+ event.GetSubmit());
+ default:
+ break;
+ }
+ return XFA_EVENTERROR_NotExist;
+}
+
+int32_t CXFA_WidgetAcc::ProcessCalculate() {
+ if (GetElementType() == XFA_Element::Draw)
+ return XFA_EVENTERROR_NotExist;
+
+ CXFA_Calculate calc = GetCalculate();
+ if (!calc)
+ return XFA_EVENTERROR_NotExist;
+ if (GetNode()->IsUserInteractive())
+ return XFA_EVENTERROR_Disabled;
+
+ CXFA_EventParam EventParam;
+ EventParam.m_eType = XFA_EVENT_Calculate;
+ CXFA_Script script = calc.GetScript();
+ int32_t iRet = ExecuteScript(script, &EventParam);
+ if (iRet != XFA_EVENTERROR_Success)
+ return iRet;
+
+ if (GetRawValue() != EventParam.m_wsResult) {
+ SetValue(EventParam.m_wsResult, XFA_VALUEPICTURE_Raw);
+ UpdateUIDisplay();
+ }
+ return XFA_EVENTERROR_Success;
+}
+
+void CXFA_WidgetAcc::ProcessScriptTestValidate(CXFA_Validate validate,
+ int32_t iRet,
+ CFXJSE_Value* pRetValue,
+ bool bVersionFlag) {
+ if (iRet == XFA_EVENTERROR_Success && pRetValue) {
+ if (pRetValue->IsBoolean() && !pRetValue->ToBoolean()) {
+ IXFA_AppProvider* pAppProvider = GetAppProvider();
+ if (!pAppProvider) {
+ return;
+ }
+ CFX_WideString wsTitle = pAppProvider->GetAppTitle();
+ CFX_WideString wsScriptMsg;
+ validate.GetScriptMessageText(wsScriptMsg);
+ int32_t eScriptTest = validate.GetScriptTest();
+ if (eScriptTest == XFA_ATTRIBUTEENUM_Warning) {
+ if (GetNode()->IsUserInteractive())
+ return;
+ if (wsScriptMsg.IsEmpty())
+ wsScriptMsg = GetValidateMessage(false, bVersionFlag);
+
+ if (bVersionFlag) {
+ pAppProvider->MsgBox(wsScriptMsg, wsTitle, XFA_MBICON_Warning,
+ XFA_MB_OK);
+ return;
+ }
+ if (pAppProvider->MsgBox(wsScriptMsg, wsTitle, XFA_MBICON_Warning,
+ XFA_MB_YesNo) == XFA_IDYes) {
+ GetNode()->SetFlag(XFA_NodeFlag_UserInteractive, false);
+ }
+ } else {
+ if (wsScriptMsg.IsEmpty())
+ wsScriptMsg = GetValidateMessage(true, bVersionFlag);
+ pAppProvider->MsgBox(wsScriptMsg, wsTitle, XFA_MBICON_Error, XFA_MB_OK);
+ }
+ }
+ }
+}
+
+int32_t CXFA_WidgetAcc::ProcessFormatTestValidate(CXFA_Validate validate,
+ bool bVersionFlag) {
+ CFX_WideString wsRawValue = GetRawValue();
+ if (!wsRawValue.IsEmpty()) {
+ CFX_WideString wsPicture;
+ validate.GetPicture(wsPicture);
+ if (wsPicture.IsEmpty())
+ return XFA_EVENTERROR_NotExist;
+
+ IFX_Locale* pLocale = GetLocal();
+ if (!pLocale)
+ return XFA_EVENTERROR_NotExist;
+
+ CXFA_LocaleValue lcValue = XFA_GetLocaleValue(this);
+ if (!lcValue.ValidateValue(lcValue.GetValue(), wsPicture, pLocale)) {
+ IXFA_AppProvider* pAppProvider = GetAppProvider();
+ if (!pAppProvider)
+ return XFA_EVENTERROR_NotExist;
+
+ CFX_WideString wsFormatMsg;
+ validate.GetFormatMessageText(wsFormatMsg);
+ CFX_WideString wsTitle = pAppProvider->GetAppTitle();
+ int32_t eFormatTest = validate.GetFormatTest();
+ if (eFormatTest == XFA_ATTRIBUTEENUM_Error) {
+ if (wsFormatMsg.IsEmpty())
+ wsFormatMsg = GetValidateMessage(true, bVersionFlag);
+ pAppProvider->MsgBox(wsFormatMsg, wsTitle, XFA_MBICON_Error, XFA_MB_OK);
+ return XFA_EVENTERROR_Success;
+ }
+ if (GetNode()->IsUserInteractive())
+ return XFA_EVENTERROR_NotExist;
+ if (wsFormatMsg.IsEmpty())
+ wsFormatMsg = GetValidateMessage(false, bVersionFlag);
+
+ if (bVersionFlag) {
+ pAppProvider->MsgBox(wsFormatMsg, wsTitle, XFA_MBICON_Warning,
+ XFA_MB_OK);
+ return XFA_EVENTERROR_Success;
+ }
+ if (pAppProvider->MsgBox(wsFormatMsg, wsTitle, XFA_MBICON_Warning,
+ XFA_MB_YesNo) == XFA_IDYes) {
+ GetNode()->SetFlag(XFA_NodeFlag_UserInteractive, false);
+ }
+ return XFA_EVENTERROR_Success;
+ }
+ }
+ return XFA_EVENTERROR_NotExist;
+}
+
+int32_t CXFA_WidgetAcc::ProcessNullTestValidate(CXFA_Validate validate,
+ int32_t iFlags,
+ bool bVersionFlag) {
+ CFX_WideString wsValue;
+ GetValue(wsValue, XFA_VALUEPICTURE_Raw);
+ if (!wsValue.IsEmpty())
+ return XFA_EVENTERROR_Success;
+ if (m_bIsNull && (m_bPreNull == m_bIsNull))
+ return XFA_EVENTERROR_Success;
+
+ int32_t eNullTest = validate.GetNullTest();
+ CFX_WideString wsNullMsg;
+ validate.GetNullMessageText(wsNullMsg);
+ if (iFlags & 0x01) {
+ int32_t iRet = XFA_EVENTERROR_Success;
+ if (eNullTest != XFA_ATTRIBUTEENUM_Disabled)
+ iRet = XFA_EVENTERROR_Error;
+
+ if (!wsNullMsg.IsEmpty()) {
+ if (eNullTest != XFA_ATTRIBUTEENUM_Disabled) {
+ m_pDocView->m_arrNullTestMsg.push_back(wsNullMsg);
+ return XFA_EVENTERROR_Error;
+ }
+ return XFA_EVENTERROR_Success;
+ }
+ return iRet;
+ }
+ if (wsNullMsg.IsEmpty() && bVersionFlag &&
+ eNullTest != XFA_ATTRIBUTEENUM_Disabled) {
+ return XFA_EVENTERROR_Error;
+ }
+ IXFA_AppProvider* pAppProvider = GetAppProvider();
+ if (!pAppProvider)
+ return XFA_EVENTERROR_NotExist;
+
+ CFX_WideString wsCaptionName;
+ CFX_WideString wsTitle = pAppProvider->GetAppTitle();
+ switch (eNullTest) {
+ case XFA_ATTRIBUTEENUM_Error: {
+ if (wsNullMsg.IsEmpty()) {
+ wsCaptionName = GetValidateCaptionName(bVersionFlag);
+ wsNullMsg.Format(L"%s cannot be blank.", wsCaptionName.c_str());
+ }
+ pAppProvider->MsgBox(wsNullMsg, wsTitle, XFA_MBICON_Status, XFA_MB_OK);
+ return XFA_EVENTERROR_Error;
+ }
+ case XFA_ATTRIBUTEENUM_Warning: {
+ if (GetNode()->IsUserInteractive())
+ return true;
+
+ if (wsNullMsg.IsEmpty()) {
+ wsCaptionName = GetValidateCaptionName(bVersionFlag);
+ wsNullMsg.Format(
+ L"%s cannot be blank. To ignore validations for %s, click Ignore.",
+ wsCaptionName.c_str(), wsCaptionName.c_str());
+ }
+ if (pAppProvider->MsgBox(wsNullMsg, wsTitle, XFA_MBICON_Warning,
+ XFA_MB_YesNo) == XFA_IDYes) {
+ GetNode()->SetFlag(XFA_NodeFlag_UserInteractive, false);
+ }
+ return XFA_EVENTERROR_Error;
+ }
+ case XFA_ATTRIBUTEENUM_Disabled:
+ default:
+ break;
+ }
+ return XFA_EVENTERROR_Success;
+}
+
+CFX_WideString CXFA_WidgetAcc::GetValidateCaptionName(bool bVersionFlag) {
+ CFX_WideString wsCaptionName;
+
+ if (!bVersionFlag) {
+ if (CXFA_Caption caption = GetCaption()) {
+ if (CXFA_Value capValue = caption.GetValue()) {
+ if (CXFA_Text capText = capValue.GetText())
+ capText.GetContent(wsCaptionName);
+ }
+ }
+ }
+ if (wsCaptionName.IsEmpty())
+ GetName(wsCaptionName);
+
+ return wsCaptionName;
+}
+
+CFX_WideString CXFA_WidgetAcc::GetValidateMessage(bool bError,
+ bool bVersionFlag) {
+ CFX_WideString wsCaptionName = GetValidateCaptionName(bVersionFlag);
+ CFX_WideString wsMessage;
+ if (bVersionFlag) {
+ wsMessage.Format(L"%s validation failed", wsCaptionName.c_str());
+ return wsMessage;
+ }
+ if (bError) {
+ wsMessage.Format(L"The value you entered for %s is invalid.",
+ wsCaptionName.c_str());
+ return wsMessage;
+ }
+ wsMessage.Format(
+ L"The value you entered for %s is invalid. To ignore "
+ L"validations for %s, click Ignore.",
+ wsCaptionName.c_str(), wsCaptionName.c_str());
+ return wsMessage;
+}
+
+int32_t CXFA_WidgetAcc::ProcessValidate(int32_t iFlags) {
+ if (GetElementType() == XFA_Element::Draw)
+ return XFA_EVENTERROR_NotExist;
+
+ CXFA_Validate validate = GetValidate();
+ if (!validate)
+ return XFA_EVENTERROR_NotExist;
+
+ bool bInitDoc = validate.GetNode()->NeedsInitApp();
+ bool bStatus = m_pDocView->GetLayoutStatus() < XFA_DOCVIEW_LAYOUTSTATUS_End;
+ int32_t iFormat = 0;
+ CFXJSE_Value* pRetValue = nullptr;
+ int32_t iRet = XFA_EVENTERROR_NotExist;
+ CXFA_Script script = validate.GetScript();
+ if (script) {
+ CXFA_EventParam eParam;
+ eParam.m_eType = XFA_EVENT_Validate;
+ eParam.m_pTarget = this;
+ iRet = ExecuteScript(script, &eParam,
+ ((bInitDoc || bStatus) && GetRawValue().IsEmpty())
+ ? nullptr
+ : &pRetValue);
+ }
+ XFA_VERSION version = GetDoc()->GetXFADoc()->GetCurVersionMode();
+ bool bVersionFlag = false;
+ if (version < XFA_VERSION_208)
+ bVersionFlag = true;
+
+ if (bInitDoc) {
+ validate.GetNode()->ClearFlag(XFA_NodeFlag_NeedsInitApp);
+ } else {
+ iFormat = ProcessFormatTestValidate(validate, bVersionFlag);
+ if (!bVersionFlag)
+ bVersionFlag = GetDoc()->GetXFADoc()->HasFlag(XFA_DOCFLAG_Scripting);
+
+ iRet |= ProcessNullTestValidate(validate, iFlags, bVersionFlag);
+ }
+ if (iFormat != XFA_EVENTERROR_Success)
+ ProcessScriptTestValidate(validate, iRet, pRetValue, bVersionFlag);
+
+ delete pRetValue;
+
+ return iRet | iFormat;
+}
+
+int32_t CXFA_WidgetAcc::ExecuteScript(CXFA_Script script,
+ CXFA_EventParam* pEventParam,
+ CFXJSE_Value** pRetValue) {
+ static const uint32_t MAX_RECURSION_DEPTH = 2;
+ if (m_nRecursionDepth > MAX_RECURSION_DEPTH)
+ return XFA_EVENTERROR_Success;
+
+ ASSERT(pEventParam);
+ if (!script)
+ return XFA_EVENTERROR_NotExist;
+ if (script.GetRunAt() == XFA_ATTRIBUTEENUM_Server)
+ return XFA_EVENTERROR_Disabled;
+
+ CFX_WideString wsExpression;
+ script.GetExpression(wsExpression);
+ if (wsExpression.IsEmpty())
+ return XFA_EVENTERROR_NotExist;
+
+ XFA_SCRIPTTYPE eScriptType = script.GetContentType();
+ if (eScriptType == XFA_SCRIPTTYPE_Unkown)
+ return XFA_EVENTERROR_Success;
+
+ CXFA_FFDoc* pDoc = GetDoc();
+ CXFA_ScriptContext* pContext = pDoc->GetXFADoc()->GetScriptContext();
+ pContext->SetEventParam(*pEventParam);
+ pContext->SetRunAtType((XFA_ATTRIBUTEENUM)script.GetRunAt());
+ std::vector<CXFA_Node*> refNodes;
+ if (pEventParam->m_eType == XFA_EVENT_InitCalculate ||
+ pEventParam->m_eType == XFA_EVENT_Calculate) {
+ pContext->SetNodesOfRunScript(&refNodes);
+ }
+ std::unique_ptr<CFXJSE_Value> pTmpRetValue(
+ new CFXJSE_Value(pContext->GetRuntime()));
+ ++m_nRecursionDepth;
+ bool bRet = pContext->RunScript((XFA_SCRIPTLANGTYPE)eScriptType,
+ wsExpression.AsStringC(), pTmpRetValue.get(),
+ m_pNode);
+ --m_nRecursionDepth;
+ int32_t iRet = XFA_EVENTERROR_Error;
+ if (bRet) {
+ iRet = XFA_EVENTERROR_Success;
+ if (pEventParam->m_eType == XFA_EVENT_Calculate ||
+ pEventParam->m_eType == XFA_EVENT_InitCalculate) {
+ if (!pTmpRetValue->IsUndefined()) {
+ if (!pTmpRetValue->IsNull())
+ pEventParam->m_wsResult = pTmpRetValue->ToWideString();
+
+ iRet = XFA_EVENTERROR_Success;
+ } else {
+ iRet = XFA_EVENTERROR_Error;
+ }
+ if (pEventParam->m_eType == XFA_EVENT_InitCalculate) {
+ if ((iRet == XFA_EVENTERROR_Success) &&
+ (GetRawValue() != pEventParam->m_wsResult)) {
+ SetValue(pEventParam->m_wsResult, XFA_VALUEPICTURE_Raw);
+ m_pDocView->AddValidateWidget(this);
+ }
+ }
+ for (CXFA_Node* pRefNode : refNodes) {
+ if (static_cast<CXFA_WidgetAcc*>(pRefNode->GetWidgetData()) == this)
+ continue;
+
+ auto* pGlobalData =
+ static_cast<CXFA_CalcData*>(pRefNode->GetUserData(XFA_CalcData));
+ if (!pGlobalData) {
+ pGlobalData = new CXFA_CalcData;
+ pRefNode->SetUserData(XFA_CalcData, pGlobalData,
+ &gs_XFADeleteCalcData);
+ }
+ if (!pdfium::ContainsValue(pGlobalData->m_Globals, this))
+ pGlobalData->m_Globals.push_back(this);
+ }
+ }
+ }
+ if (pRetValue)
+ *pRetValue = pTmpRetValue.release();
+
+ pContext->SetNodesOfRunScript(nullptr);
+ return iRet;
+}
+
+CXFA_FFWidget* CXFA_WidgetAcc::GetNextWidget(CXFA_FFWidget* pWidget) {
+ CXFA_LayoutItem* pLayout = nullptr;
+ if (pWidget)
+ pLayout = pWidget->GetNext();
+ else
+ pLayout = m_pDocView->GetXFALayout()->GetLayoutItem(m_pNode);
+
+ return static_cast<CXFA_FFWidget*>(pLayout);
+}
+
+void CXFA_WidgetAcc::UpdateUIDisplay(CXFA_FFWidget* pExcept) {
+ CXFA_FFWidget* pWidget = nullptr;
+ while ((pWidget = GetNextWidget(pWidget)) != nullptr) {
+ if (pWidget == pExcept || !pWidget->IsLoaded() ||
+ (GetUIType() != XFA_Element::CheckButton && pWidget->IsFocused())) {
+ continue;
+ }
+ pWidget->UpdateFWLData();
+ pWidget->AddInvalidateRect();
+ }
+}
+
+void CXFA_WidgetAcc::CalcCaptionSize(CFX_SizeF& szCap) {
+ CXFA_Caption caption = GetCaption();
+ if (!caption || caption.GetPresence() != XFA_ATTRIBUTEENUM_Visible)
+ return;
+
+ LoadCaption();
+ XFA_Element eUIType = GetUIType();
+ int32_t iCapPlacement = caption.GetPlacementType();
+ float fCapReserve = caption.GetReserve();
+ const bool bVert = iCapPlacement == XFA_ATTRIBUTEENUM_Top ||
+ iCapPlacement == XFA_ATTRIBUTEENUM_Bottom;
+ const bool bReserveExit = fCapReserve > 0.01;
+ CXFA_TextLayout* pCapTextLayout =
+ static_cast<CXFA_FieldLayoutData*>(m_pLayoutData.get())
+ ->m_pCapTextLayout.get();
+ if (pCapTextLayout) {
+ if (!bVert && eUIType != XFA_Element::Button)
+ szCap.width = fCapReserve;
+
+ CFX_SizeF minSize;
+ pCapTextLayout->CalcSize(minSize, szCap, szCap);
+ if (bReserveExit)
+ bVert ? szCap.height = fCapReserve : szCap.width = fCapReserve;
+ } else {
+ float fFontSize = 10.0f;
+ if (CXFA_Font font = caption.GetFont())
+ fFontSize = font.GetFontSize();
+ else if (CXFA_Font widgetfont = GetFont())
+ fFontSize = widgetfont.GetFontSize();
+
+ if (bVert) {
+ szCap.height = fCapReserve > 0 ? fCapReserve : fFontSize;
+ } else {
+ szCap.width = fCapReserve > 0 ? fCapReserve : 0;
+ szCap.height = fFontSize;
+ }
+ }
+ if (CXFA_Margin mgCap = caption.GetMargin()) {
+ float fLeftInset, fTopInset, fRightInset, fBottomInset;
+ mgCap.GetLeftInset(fLeftInset);
+ mgCap.GetTopInset(fTopInset);
+ mgCap.GetRightInset(fRightInset);
+ mgCap.GetBottomInset(fBottomInset);
+ if (bReserveExit) {
+ bVert ? (szCap.width += fLeftInset + fRightInset)
+ : (szCap.height += fTopInset + fBottomInset);
+ } else {
+ szCap.width += fLeftInset + fRightInset;
+ szCap.height += fTopInset + fBottomInset;
+ }
+ }
+}
+
+bool CXFA_WidgetAcc::CalculateFieldAutoSize(CFX_SizeF& size) {
+ CFX_SizeF szCap;
+ CalcCaptionSize(szCap);
+ CFX_RectF rtUIMargin = GetUIMargin();
+ size.width += rtUIMargin.left + rtUIMargin.width;
+ size.height += rtUIMargin.top + rtUIMargin.height;
+ if (szCap.width > 0 && szCap.height > 0) {
+ int32_t iCapPlacement = GetCaption().GetPlacementType();
+ switch (iCapPlacement) {
+ case XFA_ATTRIBUTEENUM_Left:
+ case XFA_ATTRIBUTEENUM_Right:
+ case XFA_ATTRIBUTEENUM_Inline: {
+ size.width += szCap.width;
+ size.height = std::max(size.height, szCap.height);
+ } break;
+ case XFA_ATTRIBUTEENUM_Top:
+ case XFA_ATTRIBUTEENUM_Bottom: {
+ size.height += szCap.height;
+ size.width = std::max(size.width, szCap.width);
+ }
+ default:
+ break;
+ }
+ }
+ return CalculateWidgetAutoSize(size);
+}
+
+bool CXFA_WidgetAcc::CalculateWidgetAutoSize(CFX_SizeF& size) {
+ CXFA_Margin mgWidget = GetMargin();
+ if (mgWidget) {
+ float fLeftInset, fTopInset, fRightInset, fBottomInset;
+ mgWidget.GetLeftInset(fLeftInset);
+ mgWidget.GetTopInset(fTopInset);
+ mgWidget.GetRightInset(fRightInset);
+ mgWidget.GetBottomInset(fBottomInset);
+ size.width += fLeftInset + fRightInset;
+ size.height += fTopInset + fBottomInset;
+ }
+ CXFA_Para para = GetPara();
+ if (para)
+ size.width += para.GetMarginLeft() + para.GetTextIndent();
+
+ float fVal = 0;
+ float fMin = 0;
+ float fMax = 0;
+ if (GetWidth(fVal)) {
+ size.width = fVal;
+ } else {
+ if (GetMinWidth(fMin))
+ size.width = std::max(size.width, fMin);
+ if (GetMaxWidth(fMax) && fMax > 0)
+ size.width = std::min(size.width, fMax);
+ }
+ fVal = 0;
+ fMin = 0;
+ fMax = 0;
+ if (GetHeight(fVal)) {
+ size.height = fVal;
+ } else {
+ if (GetMinHeight(fMin))
+ size.height = std::max(size.height, fMin);
+ if (GetMaxHeight(fMax) && fMax > 0)
+ size.height = std::min(size.height, fMax);
+ }
+ return true;
+}
+
+void CXFA_WidgetAcc::CalculateTextContentSize(CFX_SizeF& size) {
+ float fFontSize = GetFontSize();
+ CFX_WideString wsText;
+ GetValue(wsText, XFA_VALUEPICTURE_Display);
+ if (wsText.IsEmpty()) {
+ size.height += fFontSize;
+ return;
+ }
+
+ wchar_t wcEnter = '\n';
+ wchar_t wsLast = wsText.GetAt(wsText.GetLength() - 1);
+ if (wsLast == wcEnter)
+ wsText = wsText + wcEnter;
+
+ CXFA_FieldLayoutData* layoutData =
+ static_cast<CXFA_FieldLayoutData*>(m_pLayoutData.get());
+ if (!layoutData->m_pTextOut) {
+ layoutData->m_pTextOut = pdfium::MakeUnique<CFDE_TextOut>();
+ CFDE_TextOut* pTextOut = layoutData->m_pTextOut.get();
+ pTextOut->SetFont(GetFDEFont());
+ pTextOut->SetFontSize(fFontSize);
+ pTextOut->SetLineBreakTolerance(fFontSize * 0.2f);
+ pTextOut->SetLineSpace(GetLineHeight());
+ uint32_t dwStyles = FDE_TTOSTYLE_LastLineHeight;
+ if (GetUIType() == XFA_Element::TextEdit && IsMultiLine())
+ dwStyles |= FDE_TTOSTYLE_LineWrap;
+
+ pTextOut->SetStyles(dwStyles);
+ }
+ layoutData->m_pTextOut->CalcLogicSize(wsText.c_str(), wsText.GetLength(),
+ size);
+}
+
+bool CXFA_WidgetAcc::CalculateTextEditAutoSize(CFX_SizeF& size) {
+ if (size.width > 0) {
+ CFX_SizeF szOrz = size;
+ CFX_SizeF szCap;
+ CalcCaptionSize(szCap);
+ bool bCapExit = szCap.width > 0.01 && szCap.height > 0.01;
+ int32_t iCapPlacement = XFA_ATTRIBUTEENUM_Unknown;
+ if (bCapExit) {
+ iCapPlacement = GetCaption().GetPlacementType();
+ switch (iCapPlacement) {
+ case XFA_ATTRIBUTEENUM_Left:
+ case XFA_ATTRIBUTEENUM_Right:
+ case XFA_ATTRIBUTEENUM_Inline: {
+ size.width -= szCap.width;
+ }
+ default:
+ break;
+ }
+ }
+ CFX_RectF rtUIMargin = GetUIMargin();
+ size.width -= rtUIMargin.left + rtUIMargin.width;
+ CXFA_Margin mgWidget = GetMargin();
+ if (mgWidget) {
+ float fLeftInset, fRightInset;
+ mgWidget.GetLeftInset(fLeftInset);
+ mgWidget.GetRightInset(fRightInset);
+ size.width -= fLeftInset + fRightInset;
+ }
+ CalculateTextContentSize(size);
+ size.height += rtUIMargin.top + rtUIMargin.height;
+ if (bCapExit) {
+ switch (iCapPlacement) {
+ case XFA_ATTRIBUTEENUM_Left:
+ case XFA_ATTRIBUTEENUM_Right:
+ case XFA_ATTRIBUTEENUM_Inline: {
+ size.height = std::max(size.height, szCap.height);
+ } break;
+ case XFA_ATTRIBUTEENUM_Top:
+ case XFA_ATTRIBUTEENUM_Bottom: {
+ size.height += szCap.height;
+ }
+ default:
+ break;
+ }
+ }
+ size.width = szOrz.width;
+ return CalculateWidgetAutoSize(size);
+ }
+ CalculateTextContentSize(size);
+ return CalculateFieldAutoSize(size);
+}
+
+bool CXFA_WidgetAcc::CalculateCheckButtonAutoSize(CFX_SizeF& size) {
+ float fCheckSize = GetCheckButtonSize();
+ size = CFX_SizeF(fCheckSize, fCheckSize);
+ return CalculateFieldAutoSize(size);
+}
+
+bool CXFA_WidgetAcc::CalculatePushButtonAutoSize(CFX_SizeF& size) {
+ CalcCaptionSize(size);
+ return CalculateWidgetAutoSize(size);
+}
+
+bool CXFA_WidgetAcc::CalculateImageAutoSize(CFX_SizeF& size) {
+ if (!GetImageImage())
+ LoadImageImage();
+
+ size.clear();
+ if (CFX_DIBitmap* pBitmap = GetImageImage()) {
+ int32_t iImageXDpi = 0;
+ int32_t iImageYDpi = 0;
+ GetImageDpi(iImageXDpi, iImageYDpi);
+ CFX_RectF rtImage(
+ 0, 0, XFA_UnitPx2Pt((float)pBitmap->GetWidth(), (float)iImageXDpi),
+ XFA_UnitPx2Pt((float)pBitmap->GetHeight(), (float)iImageYDpi));
+
+ CFX_RectF rtFit;
+ if (GetWidth(rtFit.width))
+ GetWidthWithoutMargin(rtFit.width);
+ else
+ rtFit.width = rtImage.width;
+
+ if (GetHeight(rtFit.height))
+ GetHeightWithoutMargin(rtFit.height);
+ else
+ rtFit.height = rtImage.height;
+
+ size = rtFit.Size();
+ }
+ return CalculateWidgetAutoSize(size);
+}
+
+bool CXFA_WidgetAcc::CalculateImageEditAutoSize(CFX_SizeF& size) {
+ if (!GetImageEditImage())
+ LoadImageEditImage();
+
+ size.clear();
+ if (CFX_DIBitmap* pBitmap = GetImageEditImage()) {
+ int32_t iImageXDpi = 0;
+ int32_t iImageYDpi = 0;
+ GetImageEditDpi(iImageXDpi, iImageYDpi);
+ CFX_RectF rtImage(
+ 0, 0, XFA_UnitPx2Pt((float)pBitmap->GetWidth(), (float)iImageXDpi),
+ XFA_UnitPx2Pt((float)pBitmap->GetHeight(), (float)iImageYDpi));
+
+ CFX_RectF rtFit;
+ if (GetWidth(rtFit.width))
+ GetWidthWithoutMargin(rtFit.width);
+ else
+ rtFit.width = rtImage.width;
+
+ if (GetHeight(rtFit.height))
+ GetHeightWithoutMargin(rtFit.height);
+ else
+ rtFit.height = rtImage.height;
+
+ size.width = rtFit.width;
+ size.height = rtFit.height;
+ }
+ return CalculateFieldAutoSize(size);
+}
+
+bool CXFA_WidgetAcc::LoadImageImage() {
+ InitLayoutData();
+ return static_cast<CXFA_ImageLayoutData*>(m_pLayoutData.get())
+ ->LoadImageData(this);
+}
+
+bool CXFA_WidgetAcc::LoadImageEditImage() {
+ InitLayoutData();
+ return static_cast<CXFA_ImageEditData*>(m_pLayoutData.get())
+ ->LoadImageData(this);
+}
+
+void CXFA_WidgetAcc::GetImageDpi(int32_t& iImageXDpi, int32_t& iImageYDpi) {
+ CXFA_ImageLayoutData* pData =
+ static_cast<CXFA_ImageLayoutData*>(m_pLayoutData.get());
+ iImageXDpi = pData->m_iImageXDpi;
+ iImageYDpi = pData->m_iImageYDpi;
+}
+
+void CXFA_WidgetAcc::GetImageEditDpi(int32_t& iImageXDpi, int32_t& iImageYDpi) {
+ CXFA_ImageEditData* pData =
+ static_cast<CXFA_ImageEditData*>(m_pLayoutData.get());
+ iImageXDpi = pData->m_iImageXDpi;
+ iImageYDpi = pData->m_iImageYDpi;
+}
+
+bool CXFA_WidgetAcc::CalculateTextAutoSize(CFX_SizeF& size) {
+ LoadText();
+ CXFA_TextLayout* pTextLayout =
+ static_cast<CXFA_TextLayoutData*>(m_pLayoutData.get())->GetTextLayout();
+ if (pTextLayout) {
+ size.width = pTextLayout->StartLayout(size.width);
+ size.height = pTextLayout->GetLayoutHeight();
+ }
+ return CalculateWidgetAutoSize(size);
+}
+
+void CXFA_WidgetAcc::LoadText() {
+ InitLayoutData();
+ static_cast<CXFA_TextLayoutData*>(m_pLayoutData.get())->LoadText(this);
+}
+
+float CXFA_WidgetAcc::CalculateWidgetAutoWidth(float fWidthCalc) {
+ CXFA_Margin mgWidget = GetMargin();
+ if (mgWidget) {
+ float fLeftInset, fRightInset;
+ mgWidget.GetLeftInset(fLeftInset);
+ mgWidget.GetRightInset(fRightInset);
+ fWidthCalc += fLeftInset + fRightInset;
+ }
+
+ float fMin = 0, fMax = 0;
+ if (GetMinWidth(fMin))
+ fWidthCalc = std::max(fWidthCalc, fMin);
+ if (GetMaxWidth(fMax) && fMax > 0)
+ fWidthCalc = std::min(fWidthCalc, fMax);
+
+ return fWidthCalc;
+}
+
+float CXFA_WidgetAcc::GetWidthWithoutMargin(float fWidthCalc) {
+ CXFA_Margin mgWidget = GetMargin();
+ if (mgWidget) {
+ float fLeftInset, fRightInset;
+ mgWidget.GetLeftInset(fLeftInset);
+ mgWidget.GetRightInset(fRightInset);
+ fWidthCalc -= fLeftInset + fRightInset;
+ }
+ return fWidthCalc;
+}
+
+float CXFA_WidgetAcc::CalculateWidgetAutoHeight(float fHeightCalc) {
+ CXFA_Margin mgWidget = GetMargin();
+ if (mgWidget) {
+ float fTopInset, fBottomInset;
+ mgWidget.GetTopInset(fTopInset);
+ mgWidget.GetBottomInset(fBottomInset);
+ fHeightCalc += fTopInset + fBottomInset;
+ }
+
+ float fMin = 0, fMax = 0;
+ if (GetMinHeight(fMin))
+ fHeightCalc = std::max(fHeightCalc, fMin);
+ if (GetMaxHeight(fMax) && fMax > 0)
+ fHeightCalc = std::min(fHeightCalc, fMax);
+
+ return fHeightCalc;
+}
+
+float CXFA_WidgetAcc::GetHeightWithoutMargin(float fHeightCalc) {
+ CXFA_Margin mgWidget = GetMargin();
+ if (mgWidget) {
+ float fTopInset, fBottomInset;
+ mgWidget.GetTopInset(fTopInset);
+ mgWidget.GetBottomInset(fBottomInset);
+ fHeightCalc -= fTopInset + fBottomInset;
+ }
+ return fHeightCalc;
+}
+
+void CXFA_WidgetAcc::StartWidgetLayout(float& fCalcWidth, float& fCalcHeight) {
+ InitLayoutData();
+ XFA_Element eUIType = GetUIType();
+ if (eUIType == XFA_Element::Text) {
+ m_pLayoutData->m_fWidgetHeight = -1;
+ GetHeight(m_pLayoutData->m_fWidgetHeight);
+ StartTextLayout(fCalcWidth, fCalcHeight);
+ return;
+ }
+ if (fCalcWidth > 0 && fCalcHeight > 0)
+ return;
+
+ m_pLayoutData->m_fWidgetHeight = -1;
+ float fWidth = 0;
+ if (fCalcWidth > 0 && fCalcHeight < 0) {
+ if (!GetHeight(fCalcHeight))
+ CalculateAccWidthAndHeight(eUIType, fCalcWidth, fCalcHeight);
+
+ m_pLayoutData->m_fWidgetHeight = fCalcHeight;
+ return;
+ }
+ if (fCalcWidth < 0 && fCalcHeight < 0) {
+ if (!GetWidth(fWidth) || !GetHeight(fCalcHeight))
+ CalculateAccWidthAndHeight(eUIType, fWidth, fCalcHeight);
+
+ fCalcWidth = fWidth;
+ }
+ m_pLayoutData->m_fWidgetHeight = fCalcHeight;
+}
+
+void CXFA_WidgetAcc::CalculateAccWidthAndHeight(XFA_Element eUIType,
+ float& fWidth,
+ float& fCalcHeight) {
+ CFX_SizeF sz(fWidth, m_pLayoutData->m_fWidgetHeight);
+ switch (eUIType) {
+ case XFA_Element::Barcode:
+ case XFA_Element::ChoiceList:
+ case XFA_Element::Signature:
+ CalculateFieldAutoSize(sz);
+ break;
+ case XFA_Element::ImageEdit:
+ CalculateImageEditAutoSize(sz);
+ break;
+ case XFA_Element::Button:
+ CalculatePushButtonAutoSize(sz);
+ break;
+ case XFA_Element::CheckButton:
+ CalculateCheckButtonAutoSize(sz);
+ break;
+ case XFA_Element::DateTimeEdit:
+ case XFA_Element::NumericEdit:
+ case XFA_Element::PasswordEdit:
+ case XFA_Element::TextEdit:
+ CalculateTextEditAutoSize(sz);
+ break;
+ case XFA_Element::Image:
+ CalculateImageAutoSize(sz);
+ break;
+ case XFA_Element::Arc:
+ case XFA_Element::Line:
+ case XFA_Element::Rectangle:
+ case XFA_Element::Subform:
+ case XFA_Element::ExclGroup:
+ CalculateWidgetAutoSize(sz);
+ break;
+ default:
+ break;
+ }
+ fWidth = sz.width;
+ m_pLayoutData->m_fWidgetHeight = sz.height;
+ fCalcHeight = sz.height;
+}
+
+bool CXFA_WidgetAcc::FindSplitPos(int32_t iBlockIndex, float& fCalcHeight) {
+ XFA_Element eUIType = GetUIType();
+ if (eUIType == XFA_Element::Subform)
+ return false;
+
+ if (eUIType != XFA_Element::Text && eUIType != XFA_Element::TextEdit &&
+ eUIType != XFA_Element::NumericEdit &&
+ eUIType != XFA_Element::PasswordEdit) {
+ fCalcHeight = 0;
+ return true;
+ }
+
+ float fTopInset = 0;
+ float fBottomInset = 0;
+ if (iBlockIndex == 0) {
+ CXFA_Margin mgWidget = GetMargin();
+ if (mgWidget) {
+ mgWidget.GetTopInset(fTopInset);
+ mgWidget.GetBottomInset(fBottomInset);
+ }
+ CFX_RectF rtUIMargin = GetUIMargin();
+ fTopInset += rtUIMargin.top;
+ fBottomInset += rtUIMargin.width;
+ }
+ if (eUIType == XFA_Element::Text) {
+ float fHeight = fCalcHeight;
+ if (iBlockIndex == 0) {
+ fCalcHeight = fCalcHeight - fTopInset;
+ if (fCalcHeight < 0)
+ fCalcHeight = 0;
+ }
+
+ CXFA_TextLayout* pTextLayout =
+ static_cast<CXFA_TextLayoutData*>(m_pLayoutData.get())->GetTextLayout();
+ pTextLayout->DoLayout(iBlockIndex, fCalcHeight, fCalcHeight,
+ m_pLayoutData->m_fWidgetHeight - fTopInset);
+ if (fCalcHeight != 0) {
+ if (iBlockIndex == 0)
+ fCalcHeight = fCalcHeight + fTopInset;
+ if (fabs(fHeight - fCalcHeight) < XFA_FLOAT_PERCISION)
+ return false;
+ }
+ return true;
+ }
+ XFA_ATTRIBUTEENUM iCapPlacement = XFA_ATTRIBUTEENUM_Unknown;
+ float fCapReserve = 0;
+ if (iBlockIndex == 0) {
+ CXFA_Caption caption = GetCaption();
+ if (caption && caption.GetPresence() != XFA_ATTRIBUTEENUM_Hidden) {
+ iCapPlacement = (XFA_ATTRIBUTEENUM)caption.GetPlacementType();
+ fCapReserve = caption.GetReserve();
+ }
+ if (iCapPlacement == XFA_ATTRIBUTEENUM_Top &&
+ fCalcHeight < fCapReserve + fTopInset) {
+ fCalcHeight = 0;
+ return true;
+ }
+ if (iCapPlacement == XFA_ATTRIBUTEENUM_Bottom &&
+ m_pLayoutData->m_fWidgetHeight - fCapReserve - fBottomInset) {
+ fCalcHeight = 0;
+ return true;
+ }
+ if (iCapPlacement != XFA_ATTRIBUTEENUM_Top)
+ fCapReserve = 0;
+ }
+ CXFA_FieldLayoutData* pFieldData =
+ static_cast<CXFA_FieldLayoutData*>(m_pLayoutData.get());
+ int32_t iLinesCount = 0;
+ float fHeight = m_pLayoutData->m_fWidgetHeight;
+ CFX_WideString wsText;
+ GetValue(wsText, XFA_VALUEPICTURE_Display);
+ if (wsText.IsEmpty()) {
+ iLinesCount = 1;
+ } else {
+ if (!pFieldData->m_pTextOut) {
+ float fWidth = 0;
+ GetWidth(fWidth);
+ CalculateAccWidthAndHeight(eUIType, fWidth, fHeight);
+ }
+ iLinesCount = pFieldData->m_pTextOut->GetTotalLines();
+ }
+ std::vector<float>* pFieldArray = &pFieldData->m_FieldSplitArray;
+ int32_t iFieldSplitCount = pdfium::CollectionSize<int32_t>(*pFieldArray);
+ for (int32_t i = 0; i < iBlockIndex * 3; i += 3) {
+ iLinesCount -= (int32_t)(*pFieldArray)[i + 1];
+ fHeight -= (*pFieldArray)[i + 2];
+ }
+ if (iLinesCount == 0)
+ return false;
+
+ float fLineHeight = GetLineHeight();
+ float fFontSize = GetFontSize();
+ float fTextHeight = iLinesCount * fLineHeight - fLineHeight + fFontSize;
+ float fSpaceAbove = 0;
+ float fStartOffset = 0;
+ if (fHeight > 0.1f && iBlockIndex == 0) {
+ fStartOffset = fTopInset;
+ fHeight -= (fTopInset + fBottomInset);
+ if (CXFA_Para para = GetPara()) {
+ fSpaceAbove = para.GetSpaceAbove();
+ float fSpaceBelow = para.GetSpaceBelow();
+ fHeight -= (fSpaceAbove + fSpaceBelow);
+ switch (para.GetVerticalAlign()) {
+ case XFA_ATTRIBUTEENUM_Top:
+ fStartOffset += fSpaceAbove;
+ break;
+ case XFA_ATTRIBUTEENUM_Middle:
+ fStartOffset += ((fHeight - fTextHeight) / 2 + fSpaceAbove);
+ break;
+ case XFA_ATTRIBUTEENUM_Bottom:
+ fStartOffset += (fHeight - fTextHeight + fSpaceAbove);
+ break;
+ }
+ }
+ if (fStartOffset < 0.1f)
+ fStartOffset = 0;
+ }
+ for (int32_t i = iBlockIndex - 1; iBlockIndex > 0 && i < iBlockIndex; i++) {
+ fStartOffset = (*pFieldArray)[i * 3] - (*pFieldArray)[i * 3 + 2];
+ if (fStartOffset < 0.1f)
+ fStartOffset = 0;
+ }
+ if (iFieldSplitCount / 3 == (iBlockIndex + 1))
+ (*pFieldArray)[0] = fStartOffset;
+ else
+ pFieldArray->push_back(fStartOffset);
+
+ XFA_VERSION version = GetDoc()->GetXFADoc()->GetCurVersionMode();
+ bool bCanSplitNoContent = false;
+ XFA_ATTRIBUTEENUM eLayoutMode;
+ GetNode()
+ ->GetNodeItem(XFA_NODEITEM_Parent)
+ ->TryEnum(XFA_ATTRIBUTE_Layout, eLayoutMode, true);
+ if ((eLayoutMode == XFA_ATTRIBUTEENUM_Position ||
+ eLayoutMode == XFA_ATTRIBUTEENUM_Tb ||
+ eLayoutMode == XFA_ATTRIBUTEENUM_Row ||
+ eLayoutMode == XFA_ATTRIBUTEENUM_Table) &&
+ version > XFA_VERSION_208) {
+ bCanSplitNoContent = true;
+ }
+ if ((eLayoutMode == XFA_ATTRIBUTEENUM_Tb ||
+ eLayoutMode == XFA_ATTRIBUTEENUM_Row ||
+ eLayoutMode == XFA_ATTRIBUTEENUM_Table) &&
+ version <= XFA_VERSION_208) {
+ if (fStartOffset < fCalcHeight) {
+ bCanSplitNoContent = true;
+ } else {
+ fCalcHeight = 0;
+ return true;
+ }
+ }
+ if (bCanSplitNoContent) {
+ if ((fCalcHeight - fTopInset - fSpaceAbove < fLineHeight)) {
+ fCalcHeight = 0;
+ return true;
+ }
+ if (fStartOffset + XFA_FLOAT_PERCISION >= fCalcHeight) {
+ if (iFieldSplitCount / 3 == (iBlockIndex + 1)) {
+ (*pFieldArray)[iBlockIndex * 3 + 1] = 0;
+ (*pFieldArray)[iBlockIndex * 3 + 2] = fCalcHeight;
+ } else {
+ pFieldArray->push_back(0);
+ pFieldArray->push_back(fCalcHeight);
+ }
+ return false;
+ }
+ if (fCalcHeight - fStartOffset < fLineHeight) {
+ fCalcHeight = fStartOffset;
+ if (iFieldSplitCount / 3 == (iBlockIndex + 1)) {
+ (*pFieldArray)[iBlockIndex * 3 + 1] = 0;
+ (*pFieldArray)[iBlockIndex * 3 + 2] = fCalcHeight;
+ } else {
+ pFieldArray->push_back(0);
+ pFieldArray->push_back(fCalcHeight);
+ }
+ return true;
+ }
+ float fTextNum =
+ fCalcHeight + XFA_FLOAT_PERCISION - fCapReserve - fStartOffset;
+ int32_t iLineNum =
+ (int32_t)((fTextNum + (fLineHeight - fFontSize)) / fLineHeight);
+ if (iLineNum >= iLinesCount) {
+ if (fCalcHeight - fStartOffset - fTextHeight >= fFontSize) {
+ if (iFieldSplitCount / 3 == (iBlockIndex + 1)) {
+ (*pFieldArray)[iBlockIndex * 3 + 1] = (float)iLinesCount;
+ (*pFieldArray)[iBlockIndex * 3 + 2] = fCalcHeight;
+ } else {
+ pFieldArray->push_back((float)iLinesCount);
+ pFieldArray->push_back(fCalcHeight);
+ }
+ return false;
+ }
+ if (fHeight - fStartOffset - fTextHeight < fFontSize) {
+ iLineNum -= 1;
+ if (iLineNum == 0) {
+ fCalcHeight = 0;
+ return true;
+ }
+ } else {
+ iLineNum = (int32_t)(fTextNum / fLineHeight);
+ }
+ }
+ if (iLineNum > 0) {
+ float fSplitHeight = iLineNum * fLineHeight + fCapReserve + fStartOffset;
+ if (iFieldSplitCount / 3 == (iBlockIndex + 1)) {
+ (*pFieldArray)[iBlockIndex * 3 + 1] = (float)iLineNum;
+ (*pFieldArray)[iBlockIndex * 3 + 2] = fSplitHeight;
+ } else {
+ pFieldArray->push_back((float)iLineNum);
+ pFieldArray->push_back(fSplitHeight);
+ }
+ if (fabs(fSplitHeight - fCalcHeight) < XFA_FLOAT_PERCISION)
+ return false;
+
+ fCalcHeight = fSplitHeight;
+ return true;
+ }
+ }
+ fCalcHeight = 0;
+ return true;
+}
+
+void CXFA_WidgetAcc::InitLayoutData() {
+ if (m_pLayoutData)
+ return;
+
+ switch (GetUIType()) {
+ case XFA_Element::Text:
+ m_pLayoutData = pdfium::MakeUnique<CXFA_TextLayoutData>();
+ return;
+ case XFA_Element::TextEdit:
+ m_pLayoutData = pdfium::MakeUnique<CXFA_TextEditData>();
+ return;
+ case XFA_Element::Image:
+ m_pLayoutData = pdfium::MakeUnique<CXFA_ImageLayoutData>();
+ return;
+ case XFA_Element::ImageEdit:
+ m_pLayoutData = pdfium::MakeUnique<CXFA_ImageEditData>();
+ return;
+ default:
+ break;
+ }
+ if (GetElementType() == XFA_Element::Field) {
+ m_pLayoutData = pdfium::MakeUnique<CXFA_FieldLayoutData>();
+ return;
+ }
+ m_pLayoutData = pdfium::MakeUnique<CXFA_WidgetLayoutData>();
+}
+
+void CXFA_WidgetAcc::StartTextLayout(float& fCalcWidth, float& fCalcHeight) {
+ LoadText();
+ CXFA_TextLayout* pTextLayout =
+ static_cast<CXFA_TextLayoutData*>(m_pLayoutData.get())->GetTextLayout();
+ float fTextHeight = 0;
+ if (fCalcWidth > 0 && fCalcHeight > 0) {
+ float fWidth = GetWidthWithoutMargin(fCalcWidth);
+ pTextLayout->StartLayout(fWidth);
+ fTextHeight = fCalcHeight;
+ fTextHeight = GetHeightWithoutMargin(fTextHeight);
+ pTextLayout->DoLayout(0, fTextHeight, -1, fTextHeight);
+ return;
+ }
+ if (fCalcWidth > 0 && fCalcHeight < 0) {
+ float fWidth = GetWidthWithoutMargin(fCalcWidth);
+ pTextLayout->StartLayout(fWidth);
+ }
+ if (fCalcWidth < 0 && fCalcHeight < 0) {
+ float fMaxWidth = -1;
+ bool bRet = GetWidth(fMaxWidth);
+ if (bRet) {
+ float fWidth = GetWidthWithoutMargin(fMaxWidth);
+ pTextLayout->StartLayout(fWidth);
+ } else {
+ float fWidth = pTextLayout->StartLayout(fMaxWidth);
+ fMaxWidth = CalculateWidgetAutoWidth(fWidth);
+ fWidth = GetWidthWithoutMargin(fMaxWidth);
+ pTextLayout->StartLayout(fWidth);
+ }
+ fCalcWidth = fMaxWidth;
+ }
+ if (m_pLayoutData->m_fWidgetHeight < 0) {
+ m_pLayoutData->m_fWidgetHeight = pTextLayout->GetLayoutHeight();
+ m_pLayoutData->m_fWidgetHeight =
+ CalculateWidgetAutoHeight(m_pLayoutData->m_fWidgetHeight);
+ }
+ fTextHeight = m_pLayoutData->m_fWidgetHeight;
+ fTextHeight = GetHeightWithoutMargin(fTextHeight);
+ pTextLayout->DoLayout(0, fTextHeight, -1, fTextHeight);
+ fCalcHeight = m_pLayoutData->m_fWidgetHeight;
+}
+
+bool CXFA_WidgetAcc::LoadCaption() {
+ InitLayoutData();
+ return static_cast<CXFA_FieldLayoutData*>(m_pLayoutData.get())
+ ->LoadCaption(this);
+}
+
+CXFA_TextLayout* CXFA_WidgetAcc::GetCaptionTextLayout() {
+ return m_pLayoutData
+ ? static_cast<CXFA_FieldLayoutData*>(m_pLayoutData.get())
+ ->m_pCapTextLayout.get()
+ : nullptr;
+}
+
+CXFA_TextLayout* CXFA_WidgetAcc::GetTextLayout() {
+ return m_pLayoutData
+ ? static_cast<CXFA_TextLayoutData*>(m_pLayoutData.get())
+ ->GetTextLayout()
+ : nullptr;
+}
+
+CFX_DIBitmap* CXFA_WidgetAcc::GetImageImage() {
+ return m_pLayoutData
+ ? static_cast<CXFA_ImageLayoutData*>(m_pLayoutData.get())
+ ->m_pDIBitmap
+ : nullptr;
+}
+
+CFX_DIBitmap* CXFA_WidgetAcc::GetImageEditImage() {
+ return m_pLayoutData
+ ? static_cast<CXFA_ImageEditData*>(m_pLayoutData.get())
+ ->m_pDIBitmap
+ : nullptr;
+}
+
+void CXFA_WidgetAcc::SetImageImage(CFX_DIBitmap* newImage) {
+ CXFA_ImageLayoutData* pData =
+ static_cast<CXFA_ImageLayoutData*>(m_pLayoutData.get());
+ if (pData->m_pDIBitmap == newImage)
+ return;
+
+ if (pData->m_pDIBitmap && !pData->m_bNamedImage)
+ delete pData->m_pDIBitmap;
+
+ pData->m_pDIBitmap = newImage;
+}
+
+void CXFA_WidgetAcc::SetImageEditImage(CFX_DIBitmap* newImage) {
+ CXFA_ImageEditData* pData =
+ static_cast<CXFA_ImageEditData*>(m_pLayoutData.get());
+ if (pData->m_pDIBitmap == newImage)
+ return;
+
+ if (pData->m_pDIBitmap && !pData->m_bNamedImage)
+ delete pData->m_pDIBitmap;
+
+ pData->m_pDIBitmap = newImage;
+}
+
+CXFA_WidgetLayoutData* CXFA_WidgetAcc::GetWidgetLayoutData() {
+ return m_pLayoutData.get();
+}
+
+CFX_RetainPtr<CFGAS_GEFont> CXFA_WidgetAcc::GetFDEFont() {
+ CFX_WideStringC wsFontName = L"Courier";
+ uint32_t dwFontStyle = 0;
+ if (CXFA_Font font = GetFont()) {
+ if (font.IsBold())
+ dwFontStyle |= FX_FONTSTYLE_Bold;
+ if (font.IsItalic())
+ dwFontStyle |= FX_FONTSTYLE_Italic;
+ font.GetTypeface(wsFontName);
+ }
+
+ auto* pDoc = GetDoc();
+ return pDoc->GetApp()->GetXFAFontMgr()->GetFont(pDoc, wsFontName,
+ dwFontStyle);
+}
+
+float CXFA_WidgetAcc::GetFontSize() {
+ float fFontSize = 10.0f;
+ if (CXFA_Font font = GetFont())
+ fFontSize = font.GetFontSize();
+ return fFontSize < 0.1f ? 10.0f : fFontSize;
+}
+
+float CXFA_WidgetAcc::GetLineHeight() {
+ float fLineHeight = 0;
+ if (CXFA_Para para = GetPara())
+ fLineHeight = para.GetLineHeight();
+ if (fLineHeight < 1)
+ fLineHeight = GetFontSize() * 1.2f;
+ return fLineHeight;
+}
+
+FX_ARGB CXFA_WidgetAcc::GetTextColor() {
+ if (CXFA_Font font = GetFont()) {
+ return font.GetColor();
+ }
+ return 0xFF000000;
+}
diff --git a/xfa/fxfa/fxfa_widget.h b/xfa/fxfa/cxfa_widgetacc.h
index 2173b57689..8a7a7eb73d 100644
--- a/xfa/fxfa/fxfa_widget.h
+++ b/xfa/fxfa/cxfa_widgetacc.h
@@ -4,8 +4,8 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#ifndef XFA_FXFA_FXFA_WIDGET_H_
-#define XFA_FXFA_FXFA_WIDGET_H_
+#ifndef XFA_FXFA_CXFA_WIDGETACC_H_
+#define XFA_FXFA_CXFA_WIDGETACC_H_
#include <memory>
@@ -82,7 +82,7 @@ class CXFA_WidgetAcc : public CXFA_WidgetData {
float GetLineHeight();
CXFA_WidgetLayoutData* GetWidgetLayoutData();
- protected:
+ private:
void ProcessScriptTestValidate(CXFA_Validate validate,
int32_t iRet,
CFXJSE_Value* pRetValue,
@@ -118,4 +118,4 @@ class CXFA_WidgetAcc : public CXFA_WidgetData {
uint32_t m_nRecursionDepth;
};
-#endif // XFA_FXFA_FXFA_WIDGET_H_
+#endif // XFA_FXFA_CXFA_WIDGETACC_H_
diff --git a/xfa/fxfa/cxfa_widgetacciterator.cpp b/xfa/fxfa/cxfa_widgetacciterator.cpp
new file mode 100644
index 0000000000..721b65692f
--- /dev/null
+++ b/xfa/fxfa/cxfa_widgetacciterator.cpp
@@ -0,0 +1,56 @@
+// Copyright 2017 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "xfa/fxfa/cxfa_widgetacciterator.h"
+
+#include "xfa/fxfa/cxfa_widgetacc.h"
+
+CXFA_WidgetAccIterator::CXFA_WidgetAccIterator(CXFA_Node* pTravelRoot)
+ : m_ContentIterator(pTravelRoot), m_pCurWidgetAcc(nullptr) {}
+
+CXFA_WidgetAccIterator::~CXFA_WidgetAccIterator() {}
+
+void CXFA_WidgetAccIterator::Reset() {
+ m_pCurWidgetAcc = nullptr;
+ m_ContentIterator.Reset();
+}
+
+CXFA_WidgetAcc* CXFA_WidgetAccIterator::MoveToFirst() {
+ return nullptr;
+}
+
+CXFA_WidgetAcc* CXFA_WidgetAccIterator::MoveToLast() {
+ return nullptr;
+}
+
+CXFA_WidgetAcc* CXFA_WidgetAccIterator::MoveToNext() {
+ CXFA_Node* pItem = m_pCurWidgetAcc ? m_ContentIterator.MoveToNext()
+ : m_ContentIterator.GetCurrent();
+ while (pItem) {
+ m_pCurWidgetAcc = static_cast<CXFA_WidgetAcc*>(pItem->GetWidgetData());
+ if (m_pCurWidgetAcc)
+ return m_pCurWidgetAcc;
+ pItem = m_ContentIterator.MoveToNext();
+ }
+ return nullptr;
+}
+
+CXFA_WidgetAcc* CXFA_WidgetAccIterator::MoveToPrevious() {
+ return nullptr;
+}
+
+CXFA_WidgetAcc* CXFA_WidgetAccIterator::GetCurrentWidgetAcc() {
+ return nullptr;
+}
+
+bool CXFA_WidgetAccIterator::SetCurrentWidgetAcc(CXFA_WidgetAcc* hWidget) {
+ return false;
+}
+
+void CXFA_WidgetAccIterator::SkipTree() {
+ m_ContentIterator.SkipChildrenAndMoveToNext();
+ m_pCurWidgetAcc = nullptr;
+}
diff --git a/xfa/fxfa/cxfa_widgetacciterator.h b/xfa/fxfa/cxfa_widgetacciterator.h
new file mode 100644
index 0000000000..9ad93ad545
--- /dev/null
+++ b/xfa/fxfa/cxfa_widgetacciterator.h
@@ -0,0 +1,34 @@
+// Copyright 2017 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef XFA_FXFA_CXFA_WIDGETACCITERATOR_H_
+#define XFA_FXFA_CXFA_WIDGETACCITERATOR_H_
+
+#include "xfa/fxfa/parser/xfa_object.h"
+
+class CXFA_Node;
+class CXFA_WidgetAcc;
+
+class CXFA_WidgetAccIterator {
+ public:
+ explicit CXFA_WidgetAccIterator(CXFA_Node* pTravelRoot);
+ ~CXFA_WidgetAccIterator();
+
+ void Reset();
+ CXFA_WidgetAcc* MoveToFirst();
+ CXFA_WidgetAcc* MoveToLast();
+ CXFA_WidgetAcc* MoveToNext();
+ CXFA_WidgetAcc* MoveToPrevious();
+ CXFA_WidgetAcc* GetCurrentWidgetAcc();
+ bool SetCurrentWidgetAcc(CXFA_WidgetAcc* hWidget);
+ void SkipTree();
+
+ private:
+ CXFA_ContainerIterator m_ContentIterator;
+ CXFA_WidgetAcc* m_pCurWidgetAcc; // not owned.
+};
+
+#endif // XFA_FXFA_CXFA_WIDGETACCITERATOR_H_
diff --git a/xfa/fxfa/fxfa.h b/xfa/fxfa/fxfa.h
index cc75524624..559035cba1 100644
--- a/xfa/fxfa/fxfa.h
+++ b/xfa/fxfa/fxfa.h
@@ -10,8 +10,8 @@
#include <vector>
#include "core/fxcrt/cfx_retain_ptr.h"
+#include "xfa/fxfa/cxfa_widgetacc.h"
#include "xfa/fxfa/fxfa_basic.h"
-#include "xfa/fxfa/fxfa_widget.h"
class CFGAS_GEFont;
class CFX_Graphics;
diff --git a/xfa/fxfa/parser/cscript_eventpseudomodel.cpp b/xfa/fxfa/parser/cscript_eventpseudomodel.cpp
index 8cfedd2998..fdfcbbfd42 100644
--- a/xfa/fxfa/parser/cscript_eventpseudomodel.cpp
+++ b/xfa/fxfa/parser/cscript_eventpseudomodel.cpp
@@ -9,12 +9,12 @@
#include "fxjs/cfxjse_arguments.h"
#include "xfa/fxfa/app/xfa_ffnotify.h"
#include "xfa/fxfa/cxfa_eventparam.h"
+#include "xfa/fxfa/cxfa_ffwidgethandler.h"
#include "xfa/fxfa/parser/cxfa_document.h"
#include "xfa/fxfa/parser/cxfa_scriptcontext.h"
#include "xfa/fxfa/parser/xfa_localemgr.h"
#include "xfa/fxfa/parser/xfa_object.h"
#include "xfa/fxfa/parser/xfa_utils.h"
-#include "xfa/fxfa/xfa_ffwidgethandler.h"
namespace {
diff --git a/xfa/fxfa/parser/cxfa_simple_parser.cpp b/xfa/fxfa/parser/cxfa_simple_parser.cpp
index 4a6956de19..70791b6932 100644
--- a/xfa/fxfa/parser/cxfa_simple_parser.cpp
+++ b/xfa/fxfa/parser/cxfa_simple_parser.cpp
@@ -11,13 +11,13 @@
#include "core/fxcrt/fx_ext.h"
#include "third_party/base/ptr_util.h"
#include "xfa/fgas/crt/fgas_codepage.h"
+#include "xfa/fxfa/cxfa_checksumcontext.h"
#include "xfa/fxfa/fxfa.h"
#include "xfa/fxfa/parser/cxfa_document.h"
#include "xfa/fxfa/parser/cxfa_widetextread.h"
#include "xfa/fxfa/parser/cxfa_xml_parser.h"
#include "xfa/fxfa/parser/xfa_basic_data.h"
#include "xfa/fxfa/parser/xfa_utils.h"
-#include "xfa/fxfa/xfa_checksum.h"
namespace {