diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2017-05-25 16:49:51 -0400 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-05-25 22:13:23 +0000 |
commit | 2eddb665763f3e089d4c210d2a011d112683f3ea (patch) | |
tree | 2cd94caacc5d4be1714e53d3312887be31d23b52 /xfa | |
parent | b7deb9b60e045f2442c635b2ec8279e7ee282aa0 (diff) | |
download | pdfium-2eddb665763f3e089d4c210d2a011d112683f3ea.tar.xz |
Split apart remaining xfa/fxfa/app files
This CL splits the remaining files in xfa/fxfa/app into individual files
named after the classes.
Change-Id: I84bd8938937641bb6897614ed15558a2682f456c
Reviewed-on: https://pdfium-review.googlesource.com/6010
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'xfa')
-rw-r--r-- | xfa/fwl/cfwl_app.cpp | 2 | ||||
-rw-r--r-- | xfa/fwl/cfwl_widgetmgr.cpp | 2 | ||||
-rw-r--r-- | xfa/fwl/theme/cfwl_edittp.cpp | 2 | ||||
-rw-r--r-- | xfa/fxfa/app/cxfa_ffarc.cpp | 33 | ||||
-rw-r--r-- | xfa/fxfa/app/cxfa_ffarc.h | 23 | ||||
-rw-r--r-- | xfa/fxfa/app/cxfa_ffbarcode.cpp (renamed from xfa/fxfa/app/xfa_ffbarcode.cpp) | 7 | ||||
-rw-r--r-- | xfa/fxfa/app/cxfa_ffbarcode.h (renamed from xfa/fxfa/app/xfa_ffbarcode.h) | 8 | ||||
-rw-r--r-- | xfa/fxfa/app/cxfa_ffbarcode_unittest.cpp (renamed from xfa/fxfa/app/xfa_ffbarcode_unittest.cpp) | 2 | ||||
-rw-r--r-- | xfa/fxfa/app/cxfa_ffcheckbutton.cpp (renamed from xfa/fxfa/app/xfa_ffcheckbutton.cpp) | 6 | ||||
-rw-r--r-- | xfa/fxfa/app/cxfa_ffcheckbutton.h (renamed from xfa/fxfa/app/xfa_ffcheckbutton.h) | 8 | ||||
-rw-r--r-- | xfa/fxfa/app/cxfa_ffcombobox.cpp (renamed from xfa/fxfa/app/xfa_ffchoicelist.cpp) | 204 | ||||
-rw-r--r-- | xfa/fxfa/app/cxfa_ffcombobox.h (renamed from xfa/fxfa/app/xfa_ffchoicelist.h) | 41 | ||||
-rw-r--r-- | xfa/fxfa/app/cxfa_ffdatetimeedit.cpp | 213 | ||||
-rw-r--r-- | xfa/fxfa/app/cxfa_ffdatetimeedit.h | 47 | ||||
-rw-r--r-- | xfa/fxfa/app/cxfa_ffdraw.cpp (renamed from xfa/fxfa/app/xfa_ffdraw.cpp) | 2 | ||||
-rw-r--r-- | xfa/fxfa/app/cxfa_ffdraw.h (renamed from xfa/fxfa/app/xfa_ffdraw.h) | 6 | ||||
-rw-r--r-- | xfa/fxfa/app/cxfa_ffexclgroup.cpp (renamed from xfa/fxfa/app/xfa_ffexclgroup.cpp) | 2 | ||||
-rw-r--r-- | xfa/fxfa/app/cxfa_ffexclgroup.h (renamed from xfa/fxfa/app/xfa_ffexclgroup.h) | 6 | ||||
-rw-r--r-- | xfa/fxfa/app/cxfa_fffield.cpp (renamed from xfa/fxfa/app/xfa_fffield.cpp) | 4 | ||||
-rw-r--r-- | xfa/fxfa/app/cxfa_fffield.h (renamed from xfa/fxfa/app/xfa_fffield.h) | 6 | ||||
-rw-r--r-- | xfa/fxfa/app/cxfa_ffimage.cpp (renamed from xfa/fxfa/app/xfa_ffimage.cpp) | 4 | ||||
-rw-r--r-- | xfa/fxfa/app/cxfa_ffimage.h (renamed from xfa/fxfa/app/xfa_ffimage.h) | 8 | ||||
-rw-r--r-- | xfa/fxfa/app/cxfa_ffimageedit.cpp (renamed from xfa/fxfa/app/xfa_ffimageedit.cpp) | 4 | ||||
-rw-r--r-- | xfa/fxfa/app/cxfa_ffimageedit.h (renamed from xfa/fxfa/app/xfa_ffimageedit.h) | 8 | ||||
-rw-r--r-- | xfa/fxfa/app/cxfa_ffline.cpp (renamed from xfa/fxfa/app/xfa_ffpath.cpp) | 63 | ||||
-rw-r--r-- | xfa/fxfa/app/cxfa_ffline.h | 26 | ||||
-rw-r--r-- | xfa/fxfa/app/cxfa_fflistbox.cpp | 210 | ||||
-rw-r--r-- | xfa/fxfa/app/cxfa_fflistbox.h | 40 | ||||
-rw-r--r-- | xfa/fxfa/app/cxfa_ffnotify.cpp (renamed from xfa/fxfa/app/xfa_ffnotify.cpp) | 39 | ||||
-rw-r--r-- | xfa/fxfa/app/cxfa_ffnotify.h (renamed from xfa/fxfa/app/xfa_ffnotify.h) | 6 | ||||
-rw-r--r-- | xfa/fxfa/app/cxfa_ffnumericedit.cpp | 97 | ||||
-rw-r--r-- | xfa/fxfa/app/cxfa_ffnumericedit.h | 31 | ||||
-rw-r--r-- | xfa/fxfa/app/cxfa_ffpasswordedit.cpp | 64 | ||||
-rw-r--r-- | xfa/fxfa/app/cxfa_ffpasswordedit.h | 24 | ||||
-rw-r--r-- | xfa/fxfa/app/cxfa_ffpushbutton.cpp (renamed from xfa/fxfa/app/xfa_ffpushbutton.cpp) | 6 | ||||
-rw-r--r-- | xfa/fxfa/app/cxfa_ffpushbutton.h (renamed from xfa/fxfa/app/xfa_ffpushbutton.h) | 8 | ||||
-rw-r--r-- | xfa/fxfa/app/cxfa_ffrectangle.cpp | 34 | ||||
-rw-r--r-- | xfa/fxfa/app/cxfa_ffrectangle.h | 23 | ||||
-rw-r--r-- | xfa/fxfa/app/cxfa_ffsignature.cpp (renamed from xfa/fxfa/app/xfa_ffsignature.cpp) | 4 | ||||
-rw-r--r-- | xfa/fxfa/app/cxfa_ffsignature.h (renamed from xfa/fxfa/app/xfa_ffsignature.h) | 8 | ||||
-rw-r--r-- | xfa/fxfa/app/cxfa_ffsubform.cpp (renamed from xfa/fxfa/app/xfa_ffsubform.cpp) | 2 | ||||
-rw-r--r-- | xfa/fxfa/app/cxfa_ffsubform.h (renamed from xfa/fxfa/app/xfa_ffsubform.h) | 6 | ||||
-rw-r--r-- | xfa/fxfa/app/cxfa_fftext.cpp (renamed from xfa/fxfa/app/xfa_fftext.cpp) | 6 | ||||
-rw-r--r-- | xfa/fxfa/app/cxfa_fftext.h (renamed from xfa/fxfa/app/xfa_fftext.h) | 8 | ||||
-rw-r--r-- | xfa/fxfa/app/cxfa_fftextedit.cpp | 364 | ||||
-rw-r--r-- | xfa/fxfa/app/cxfa_fftextedit.h | 57 | ||||
-rw-r--r-- | xfa/fxfa/app/cxfa_fwladapterwidgetmgr.cpp (renamed from xfa/fxfa/app/xfa_fwladapter.cpp) | 4 | ||||
-rw-r--r-- | xfa/fxfa/app/cxfa_fwladapterwidgetmgr.h (renamed from xfa/fxfa/app/xfa_fwladapter.h) | 6 | ||||
-rw-r--r-- | xfa/fxfa/app/cxfa_fwltheme.cpp (renamed from xfa/fxfa/app/xfa_fwltheme.cpp) | 2 | ||||
-rw-r--r-- | xfa/fxfa/app/cxfa_fwltheme.h (renamed from xfa/fxfa/app/xfa_fwltheme.h) | 6 | ||||
-rw-r--r-- | xfa/fxfa/app/cxfa_pieceline.cpp | 2 | ||||
-rw-r--r-- | xfa/fxfa/app/cxfa_pieceline.h | 4 | ||||
-rw-r--r-- | xfa/fxfa/app/cxfa_textlayout.cpp | 20 | ||||
-rw-r--r-- | xfa/fxfa/app/cxfa_textlayout.h | 6 | ||||
-rw-r--r-- | xfa/fxfa/app/cxfa_textparser.cpp | 2 | ||||
-rw-r--r-- | xfa/fxfa/app/cxfa_textpiece.cpp (renamed from xfa/fxfa/app/xfa_textpiece.cpp) | 6 | ||||
-rw-r--r-- | xfa/fxfa/app/cxfa_textpiece.h (renamed from xfa/fxfa/app/xfa_textpiece.h) | 12 | ||||
-rw-r--r-- | xfa/fxfa/app/cxfa_textprovider.cpp (renamed from xfa/fxfa/app/xfa_ffwidgetacc.cpp) | 9 | ||||
-rw-r--r-- | xfa/fxfa/app/cxfa_textprovider.h (renamed from xfa/fxfa/app/xfa_ffwidgetacc.h) | 6 | ||||
-rw-r--r-- | xfa/fxfa/app/xfa_ffpath.h | 48 | ||||
-rw-r--r-- | xfa/fxfa/app/xfa_fftextedit.cpp | 706 | ||||
-rw-r--r-- | xfa/fxfa/app/xfa_fftextedit.h | 105 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_ffapp.cpp | 4 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_ffdoc.cpp | 2 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_ffdocview.cpp | 29 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_ffpageview.cpp | 12 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_ffwidgethandler.cpp | 5 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_widgetacc.cpp | 2 | ||||
-rw-r--r-- | xfa/fxfa/fm2js/cxfa_fm2jscontext.cpp | 2 | ||||
-rw-r--r-- | xfa/fxfa/parser/cscript_eventpseudomodel.cpp | 2 | ||||
-rw-r--r-- | xfa/fxfa/parser/cscript_hostpseudomodel.cpp | 2 | ||||
-rw-r--r-- | xfa/fxfa/parser/cscript_layoutpseudomodel.cpp | 2 | ||||
-rw-r--r-- | xfa/fxfa/parser/cscript_signaturepseudomodel.cpp | 2 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_document.cpp | 2 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp | 2 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_layoutitem.cpp | 2 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_layoutpagemgr.cpp | 2 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_node.cpp | 2 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_object.cpp | 2 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_scriptcontext.cpp | 2 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_widgetdata.cpp | 2 |
81 files changed, 1466 insertions, 1332 deletions
diff --git a/xfa/fwl/cfwl_app.cpp b/xfa/fwl/cfwl_app.cpp index febc8a0fdf..e762125ba8 100644 --- a/xfa/fwl/cfwl_app.cpp +++ b/xfa/fwl/cfwl_app.cpp @@ -10,7 +10,7 @@ #include "xfa/fwl/cfwl_notedriver.h" #include "xfa/fwl/cfwl_widget.h" #include "xfa/fwl/cfwl_widgetmgr.h" -#include "xfa/fxfa/app/xfa_fwladapter.h" +#include "xfa/fxfa/app/cxfa_fwladapterwidgetmgr.h" CFWL_App::CFWL_App(CXFA_FFApp* pAdapter) : m_pAdapterNative(pAdapter), diff --git a/xfa/fwl/cfwl_widgetmgr.cpp b/xfa/fwl/cfwl_widgetmgr.cpp index d0dbf1f773..67a63ba921 100644 --- a/xfa/fwl/cfwl_widgetmgr.cpp +++ b/xfa/fwl/cfwl_widgetmgr.cpp @@ -12,7 +12,7 @@ #include "xfa/fwl/cfwl_app.h" #include "xfa/fwl/cfwl_form.h" #include "xfa/fwl/cfwl_notedriver.h" -#include "xfa/fxfa/app/xfa_fwladapter.h" +#include "xfa/fxfa/app/cxfa_fwladapterwidgetmgr.h" #include "xfa/fxfa/cxfa_ffapp.h" namespace { diff --git a/xfa/fwl/theme/cfwl_edittp.cpp b/xfa/fwl/theme/cfwl_edittp.cpp index 138a99e59d..06cdceb09e 100644 --- a/xfa/fwl/theme/cfwl_edittp.cpp +++ b/xfa/fwl/theme/cfwl_edittp.cpp @@ -9,7 +9,7 @@ #include "xfa/fwl/cfwl_edit.h" #include "xfa/fwl/cfwl_themebackground.h" #include "xfa/fwl/cfwl_widget.h" -#include "xfa/fxfa/app/xfa_fwltheme.h" +#include "xfa/fxfa/app/cxfa_fwltheme.h" #include "xfa/fxfa/cxfa_ffwidget.h" #include "xfa/fxgraphics/cfx_color.h" #include "xfa/fxgraphics/cfx_path.h" diff --git a/xfa/fxfa/app/cxfa_ffarc.cpp b/xfa/fxfa/app/cxfa_ffarc.cpp new file mode 100644 index 0000000000..e2085480a5 --- /dev/null +++ b/xfa/fxfa/app/cxfa_ffarc.cpp @@ -0,0 +1,33 @@ +// Copyright 2017 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#include "xfa/fxfa/app/cxfa_ffarc.h" + +CXFA_FFArc::CXFA_FFArc(CXFA_WidgetAcc* pDataAcc) : CXFA_FFDraw(pDataAcc) {} + +CXFA_FFArc::~CXFA_FFArc() {} + +void CXFA_FFArc::RenderWidget(CFX_Graphics* pGS, + CFX_Matrix* pMatrix, + uint32_t dwStatus) { + if (!IsMatchVisibleStatus(dwStatus)) + return; + + CXFA_Value value = m_pDataAcc->GetFormValue(); + if (!value) + return; + + CXFA_Arc arcObj = value.GetArc(); + CFX_Matrix mtRotate = GetRotateMatrix(); + if (pMatrix) + mtRotate.Concat(*pMatrix); + + CFX_RectF rtArc = GetRectWithoutRotate(); + if (CXFA_Margin mgWidget = m_pDataAcc->GetMargin()) + XFA_RectWidthoutMargin(rtArc, mgWidget); + + DrawBorder(pGS, arcObj, rtArc, &mtRotate); +} diff --git a/xfa/fxfa/app/cxfa_ffarc.h b/xfa/fxfa/app/cxfa_ffarc.h new file mode 100644 index 0000000000..777ed6f3af --- /dev/null +++ b/xfa/fxfa/app/cxfa_ffarc.h @@ -0,0 +1,23 @@ +// Copyright 2017 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#ifndef XFA_FXFA_APP_CXFA_FFARC_H_ +#define XFA_FXFA_APP_CXFA_FFARC_H_ + +#include "xfa/fxfa/app/cxfa_ffdraw.h" + +class CXFA_FFArc : public CXFA_FFDraw { + public: + explicit CXFA_FFArc(CXFA_WidgetAcc* pDataAcc); + ~CXFA_FFArc() override; + + // CXFA_FFWidget + void RenderWidget(CFX_Graphics* pGS, + CFX_Matrix* pMatrix, + uint32_t dwStatus) override; +}; + +#endif // XFA_FXFA_APP_CXFA_FFARC_H_ diff --git a/xfa/fxfa/app/xfa_ffbarcode.cpp b/xfa/fxfa/app/cxfa_ffbarcode.cpp index 4dcffa5bad..bd529d3eb2 100644 --- a/xfa/fxfa/app/xfa_ffbarcode.cpp +++ b/xfa/fxfa/app/cxfa_ffbarcode.cpp @@ -4,7 +4,7 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#include "xfa/fxfa/app/xfa_ffbarcode.h" +#include "xfa/fxfa/app/cxfa_ffbarcode.h" #include <utility> @@ -13,9 +13,8 @@ #include "xfa/fwl/cfwl_app.h" #include "xfa/fwl/cfwl_barcode.h" #include "xfa/fwl/cfwl_notedriver.h" -#include "xfa/fxfa/app/xfa_fffield.h" -#include "xfa/fxfa/app/xfa_fftextedit.h" -#include "xfa/fxfa/app/xfa_fwladapter.h" +#include "xfa/fxfa/app/cxfa_fffield.h" +#include "xfa/fxfa/app/cxfa_fwladapterwidgetmgr.h" #include "xfa/fxfa/cxfa_ffpageview.h" #include "xfa/fxfa/cxfa_ffwidget.h" diff --git a/xfa/fxfa/app/xfa_ffbarcode.h b/xfa/fxfa/app/cxfa_ffbarcode.h index 51646236d0..11b678d98a 100644 --- a/xfa/fxfa/app/xfa_ffbarcode.h +++ b/xfa/fxfa/app/cxfa_ffbarcode.h @@ -4,11 +4,11 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#ifndef XFA_FXFA_APP_XFA_FFBARCODE_H_ -#define XFA_FXFA_APP_XFA_FFBARCODE_H_ +#ifndef XFA_FXFA_APP_CXFA_FFBARCODE_H_ +#define XFA_FXFA_APP_CXFA_FFBARCODE_H_ #include "fxbarcode/BC_Library.h" -#include "xfa/fxfa/app/xfa_fftextedit.h" +#include "xfa/fxfa/app/cxfa_fftextedit.h" #include "xfa/fxfa/cxfa_ffpageview.h" enum class BarcodeType { @@ -100,4 +100,4 @@ class CXFA_FFBarcode : public CXFA_FFTextEdit { bool OnRButtonDown(uint32_t dwFlags, const CFX_PointF& point) override; }; -#endif // XFA_FXFA_APP_XFA_FFBARCODE_H_ +#endif // XFA_FXFA_APP_CXFA_FFBARCODE_H_ diff --git a/xfa/fxfa/app/xfa_ffbarcode_unittest.cpp b/xfa/fxfa/app/cxfa_ffbarcode_unittest.cpp index 95e2377cd8..65e44ade53 100644 --- a/xfa/fxfa/app/xfa_ffbarcode_unittest.cpp +++ b/xfa/fxfa/app/cxfa_ffbarcode_unittest.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/app/xfa_ffbarcode.h" +#include "xfa/fxfa/app/cxfa_ffbarcode.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/base/ptr_util.h" diff --git a/xfa/fxfa/app/xfa_ffcheckbutton.cpp b/xfa/fxfa/app/cxfa_ffcheckbutton.cpp index 76531cecdd..b55daae21a 100644 --- a/xfa/fxfa/app/xfa_ffcheckbutton.cpp +++ b/xfa/fxfa/app/cxfa_ffcheckbutton.cpp @@ -4,7 +4,7 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#include "xfa/fxfa/app/xfa_ffcheckbutton.h" +#include "xfa/fxfa/app/cxfa_ffcheckbutton.h" #include <utility> #include "third_party/base/ptr_util.h" @@ -12,8 +12,8 @@ #include "xfa/fwl/cfwl_messagemouse.h" #include "xfa/fwl/cfwl_notedriver.h" #include "xfa/fwl/cfwl_widgetmgr.h" -#include "xfa/fxfa/app/xfa_ffexclgroup.h" -#include "xfa/fxfa/app/xfa_fffield.h" +#include "xfa/fxfa/app/cxfa_ffexclgroup.h" +#include "xfa/fxfa/app/cxfa_fffield.h" #include "xfa/fxfa/cxfa_ffapp.h" #include "xfa/fxfa/cxfa_ffdoc.h" #include "xfa/fxfa/cxfa_ffdocview.h" diff --git a/xfa/fxfa/app/xfa_ffcheckbutton.h b/xfa/fxfa/app/cxfa_ffcheckbutton.h index d4de7e8023..f92b50a692 100644 --- a/xfa/fxfa/app/xfa_ffcheckbutton.h +++ b/xfa/fxfa/app/cxfa_ffcheckbutton.h @@ -4,10 +4,10 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#ifndef XFA_FXFA_APP_XFA_FFCHECKBUTTON_H_ -#define XFA_FXFA_APP_XFA_FFCHECKBUTTON_H_ +#ifndef XFA_FXFA_APP_CXFA_FFCHECKBUTTON_H_ +#define XFA_FXFA_APP_CXFA_FFCHECKBUTTON_H_ -#include "xfa/fxfa/app/xfa_fffield.h" +#include "xfa/fxfa/app/cxfa_fffield.h" #include "xfa/fxfa/cxfa_ffpageview.h" class CXFA_FFCheckButton : public CXFA_FFField { @@ -43,4 +43,4 @@ class CXFA_FFCheckButton : public CXFA_FFField { CFX_RectF m_rtCheckBox; }; -#endif // XFA_FXFA_APP_XFA_FFCHECKBUTTON_H_ +#endif // XFA_FXFA_APP_CXFA_FFCHECKBUTTON_H_ diff --git a/xfa/fxfa/app/xfa_ffchoicelist.cpp b/xfa/fxfa/app/cxfa_ffcombobox.cpp index e24e7f77b7..91de16e9c3 100644 --- a/xfa/fxfa/app/xfa_ffchoicelist.cpp +++ b/xfa/fxfa/app/cxfa_ffcombobox.cpp @@ -4,227 +4,25 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#include "xfa/fxfa/app/xfa_ffchoicelist.h" +#include "xfa/fxfa/app/cxfa_ffcombobox.h" -#include <algorithm> #include <utility> #include <vector> -#include "third_party/base/ptr_util.h" -#include "third_party/base/stl_util.h" -#include "xfa/fwl/cfwl_app.h" #include "xfa/fwl/cfwl_combobox.h" -#include "xfa/fwl/cfwl_edit.h" #include "xfa/fwl/cfwl_eventselectchanged.h" -#include "xfa/fwl/cfwl_listbox.h" #include "xfa/fwl/cfwl_notedriver.h" -#include "xfa/fwl/cfwl_widgetproperties.h" -#include "xfa/fxfa/app/xfa_fffield.h" -#include "xfa/fxfa/app/xfa_fwladapter.h" #include "xfa/fxfa/cxfa_eventparam.h" -#include "xfa/fxfa/cxfa_ffdoc.h" #include "xfa/fxfa/cxfa_ffdocview.h" -#include "xfa/fxfa/cxfa_ffpageview.h" -#include "xfa/fxfa/cxfa_ffwidget.h" namespace { -CFWL_ListBox* ToListBox(CFWL_Widget* widget) { - return static_cast<CFWL_ListBox*>(widget); -} - CFWL_ComboBox* ToComboBox(CFWL_Widget* widget) { return static_cast<CFWL_ComboBox*>(widget); } } // namespace -CXFA_FFListBox::CXFA_FFListBox(CXFA_WidgetAcc* pDataAcc) - : CXFA_FFField(pDataAcc), m_pOldDelegate(nullptr) {} - -CXFA_FFListBox::~CXFA_FFListBox() { - if (!m_pNormalWidget) - return; - - CFWL_NoteDriver* pNoteDriver = - m_pNormalWidget->GetOwnerApp()->GetNoteDriver(); - pNoteDriver->UnregisterEventTarget(m_pNormalWidget.get()); -} - -bool CXFA_FFListBox::LoadWidget() { - auto pNew = pdfium::MakeUnique<CFWL_ListBox>( - GetFWLApp(), pdfium::MakeUnique<CFWL_WidgetProperties>(), nullptr); - CFWL_ListBox* pListBox = pNew.get(); - pListBox->ModifyStyles(FWL_WGTSTYLE_VScroll | FWL_WGTSTYLE_NoBackground, - 0xFFFFFFFF); - m_pNormalWidget = std::move(pNew); - m_pNormalWidget->SetLayoutItem(this); - - CFWL_NoteDriver* pNoteDriver = - m_pNormalWidget->GetOwnerApp()->GetNoteDriver(); - pNoteDriver->RegisterEventTarget(m_pNormalWidget.get(), - m_pNormalWidget.get()); - m_pOldDelegate = m_pNormalWidget->GetDelegate(); - m_pNormalWidget->SetDelegate(this); - m_pNormalWidget->LockUpdate(); - - for (const auto& label : m_pDataAcc->GetChoiceListItems(false)) - pListBox->AddString(label.AsStringC()); - - uint32_t dwExtendedStyle = FWL_STYLEEXT_LTB_ShowScrollBarFocus; - if (m_pDataAcc->GetChoiceListOpen() == XFA_ATTRIBUTEENUM_MultiSelect) - dwExtendedStyle |= FWL_STYLEEXT_LTB_MultiSelection; - - dwExtendedStyle |= GetAlignment(); - m_pNormalWidget->ModifyStylesEx(dwExtendedStyle, 0xFFFFFFFF); - for (int32_t selected : m_pDataAcc->GetSelectedItems()) - pListBox->SetSelItem(pListBox->GetItem(nullptr, selected), true); - - m_pNormalWidget->UnlockUpdate(); - return CXFA_FFField::LoadWidget(); -} - -bool CXFA_FFListBox::OnKillFocus(CXFA_FFWidget* pNewFocus) { - if (!ProcessCommittedData()) - UpdateFWLData(); - - CXFA_FFField::OnKillFocus(pNewFocus); - return true; -} - -bool CXFA_FFListBox::CommitData() { - auto* pListBox = ToListBox(m_pNormalWidget.get()); - std::vector<int32_t> iSelArray; - int32_t iSels = pListBox->CountSelItems(); - for (int32_t i = 0; i < iSels; ++i) - iSelArray.push_back(pListBox->GetSelIndex(i)); - - m_pDataAcc->SetSelectedItems(iSelArray, true, false, true); - return true; -} - -bool CXFA_FFListBox::IsDataChanged() { - std::vector<int32_t> iSelArray = m_pDataAcc->GetSelectedItems(); - int32_t iOldSels = pdfium::CollectionSize<int32_t>(iSelArray); - auto* pListBox = ToListBox(m_pNormalWidget.get()); - int32_t iSels = pListBox->CountSelItems(); - if (iOldSels != iSels) - return true; - - for (int32_t i = 0; i < iSels; ++i) { - CFWL_ListItem* hlistItem = pListBox->GetItem(nullptr, iSelArray[i]); - if (!(hlistItem->GetStates() & FWL_ITEMSTATE_LTB_Selected)) - return true; - } - return false; -} - -uint32_t CXFA_FFListBox::GetAlignment() { - CXFA_Para para = m_pDataAcc->GetPara(); - if (!para) - return 0; - - uint32_t dwExtendedStyle = 0; - switch (para.GetHorizontalAlign()) { - case XFA_ATTRIBUTEENUM_Center: - dwExtendedStyle |= FWL_STYLEEXT_LTB_CenterAlign; - break; - case XFA_ATTRIBUTEENUM_Justify: - break; - case XFA_ATTRIBUTEENUM_JustifyAll: - break; - case XFA_ATTRIBUTEENUM_Radix: - break; - case XFA_ATTRIBUTEENUM_Right: - dwExtendedStyle |= FWL_STYLEEXT_LTB_RightAlign; - break; - default: - dwExtendedStyle |= FWL_STYLEEXT_LTB_LeftAlign; - break; - } - return dwExtendedStyle; -} - -bool CXFA_FFListBox::UpdateFWLData() { - if (!m_pNormalWidget) - return false; - - auto* pListBox = ToListBox(m_pNormalWidget.get()); - std::vector<int32_t> iSelArray = m_pDataAcc->GetSelectedItems(); - std::vector<CFWL_ListItem*> selItemArray(iSelArray.size()); - std::transform(iSelArray.begin(), iSelArray.end(), selItemArray.begin(), - [pListBox](int32_t val) { return pListBox->GetSelItem(val); }); - - pListBox->SetSelItem(pListBox->GetSelItem(-1), false); - for (CFWL_ListItem* pItem : selItemArray) - pListBox->SetSelItem(pItem, true); - - m_pNormalWidget->Update(); - return true; -} - -void CXFA_FFListBox::OnSelectChanged(CFWL_Widget* pWidget) { - CXFA_EventParam eParam; - eParam.m_eType = XFA_EVENT_Change; - eParam.m_pTarget = m_pDataAcc.Get(); - m_pDataAcc->GetValue(eParam.m_wsPrevText, XFA_VALUEPICTURE_Raw); - - auto* pListBox = ToListBox(m_pNormalWidget.get()); - int32_t iSels = pListBox->CountSelItems(); - if (iSels > 0) { - CFWL_ListItem* item = pListBox->GetSelItem(0); - eParam.m_wsNewText = item ? item->GetText() : L""; - } - m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Change, &eParam); -} - -void CXFA_FFListBox::SetItemState(int32_t nIndex, bool bSelected) { - auto* pListBox = ToListBox(m_pNormalWidget.get()); - pListBox->SetSelItem(pListBox->GetSelItem(nIndex), bSelected); - m_pNormalWidget->Update(); - AddInvalidateRect(); -} - -void CXFA_FFListBox::InsertItem(const CFX_WideStringC& wsLabel, - int32_t nIndex) { - CFX_WideString wsTemp(wsLabel); - ToListBox(m_pNormalWidget.get())->AddString(wsTemp.AsStringC()); - m_pNormalWidget->Update(); - AddInvalidateRect(); -} - -void CXFA_FFListBox::DeleteItem(int32_t nIndex) { - auto* pListBox = ToListBox(m_pNormalWidget.get()); - if (nIndex < 0) - pListBox->DeleteAll(); - else - pListBox->DeleteString(pListBox->GetItem(nullptr, nIndex)); - - pListBox->Update(); - AddInvalidateRect(); -} - -void CXFA_FFListBox::OnProcessMessage(CFWL_Message* pMessage) { - m_pOldDelegate->OnProcessMessage(pMessage); -} - -void CXFA_FFListBox::OnProcessEvent(CFWL_Event* pEvent) { - CXFA_FFField::OnProcessEvent(pEvent); - switch (pEvent->GetType()) { - case CFWL_Event::Type::SelectChanged: - OnSelectChanged(m_pNormalWidget.get()); - break; - default: - break; - } - m_pOldDelegate->OnProcessEvent(pEvent); -} - -void CXFA_FFListBox::OnDrawWidget(CFX_Graphics* pGraphics, - const CFX_Matrix* pMatrix) { - m_pOldDelegate->OnDrawWidget(pGraphics, pMatrix); -} - CXFA_FFComboBox::CXFA_FFComboBox(CXFA_WidgetAcc* pDataAcc) : CXFA_FFField(pDataAcc), m_pOldDelegate(nullptr) {} diff --git a/xfa/fxfa/app/xfa_ffchoicelist.h b/xfa/fxfa/app/cxfa_ffcombobox.h index 20f053cc20..048521f5e0 100644 --- a/xfa/fxfa/app/xfa_ffchoicelist.h +++ b/xfa/fxfa/app/cxfa_ffcombobox.h @@ -1,44 +1,13 @@ -// 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_APP_XFA_FFCHOICELIST_H_ -#define XFA_FXFA_APP_XFA_FFCHOICELIST_H_ +#ifndef XFA_FXFA_APP_CXFA_FFCOMBOBOX_H_ +#define XFA_FXFA_APP_CXFA_FFCOMBOBOX_H_ -#include <vector> - -#include "xfa/fxfa/app/xfa_fffield.h" -#include "xfa/fxfa/cxfa_ffpageview.h" - -class CXFA_FFListBox : public CXFA_FFField { - public: - explicit CXFA_FFListBox(CXFA_WidgetAcc* pDataAcc); - ~CXFA_FFListBox() override; - - // CXFA_FFField - bool LoadWidget() override; - bool OnKillFocus(CXFA_FFWidget* pNewWidget) override; - void OnProcessMessage(CFWL_Message* pMessage) override; - void OnProcessEvent(CFWL_Event* pEvent) override; - void OnDrawWidget(CFX_Graphics* pGraphics, - const CFX_Matrix* pMatrix = nullptr) override; - - void OnSelectChanged(CFWL_Widget* pWidget); - void SetItemState(int32_t nIndex, bool bSelected); - void InsertItem(const CFX_WideStringC& wsLabel, int32_t nIndex); - void DeleteItem(int32_t nIndex); - - private: - bool CommitData() override; - bool UpdateFWLData() override; - bool IsDataChanged() override; - - uint32_t GetAlignment(); - - IFWL_WidgetDelegate* m_pOldDelegate; -}; +#include "xfa/fxfa/app/cxfa_fffield.h" class CXFA_FFComboBox : public CXFA_FFField { public: @@ -97,4 +66,4 @@ class CXFA_FFComboBox : public CXFA_FFField { IFWL_WidgetDelegate* m_pOldDelegate; }; -#endif // XFA_FXFA_APP_XFA_FFCHOICELIST_H_ +#endif // XFA_FXFA_APP_CXFA_FFCOMBOBOX_H_ diff --git a/xfa/fxfa/app/cxfa_ffdatetimeedit.cpp b/xfa/fxfa/app/cxfa_ffdatetimeedit.cpp new file mode 100644 index 0000000000..10a7b189f6 --- /dev/null +++ b/xfa/fxfa/app/cxfa_ffdatetimeedit.cpp @@ -0,0 +1,213 @@ +// Copyright 2017 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#include "xfa/fxfa/app/cxfa_ffdatetimeedit.h" + +#include <utility> + +#include "xfa/fwl/cfwl_datetimepicker.h" +#include "xfa/fwl/cfwl_eventselectchanged.h" +#include "xfa/fwl/cfwl_notedriver.h" +#include "xfa/fwl/cfwl_widget.h" +#include "xfa/fxfa/cxfa_eventparam.h" +#include "xfa/fxfa/parser/cxfa_localevalue.h" + +CXFA_FFDateTimeEdit::CXFA_FFDateTimeEdit(CXFA_WidgetAcc* pDataAcc) + : CXFA_FFTextEdit(pDataAcc) {} + +CXFA_FFDateTimeEdit::~CXFA_FFDateTimeEdit() {} + +CFX_RectF CXFA_FFDateTimeEdit::GetBBox(uint32_t dwStatus, bool bDrawFocus) { + if (bDrawFocus) + return CFX_RectF(); + return CXFA_FFWidget::GetBBox(dwStatus); +} + +bool CXFA_FFDateTimeEdit::PtInActiveRect(const CFX_PointF& point) { + auto* pPicker = static_cast<CFWL_DateTimePicker*>(m_pNormalWidget.get()); + return pPicker && pPicker->GetBBox().Contains(point); +} + +bool CXFA_FFDateTimeEdit::LoadWidget() { + auto pNewPicker = pdfium::MakeUnique<CFWL_DateTimePicker>(GetFWLApp()); + CFWL_DateTimePicker* pWidget = pNewPicker.get(); + m_pNormalWidget = std::move(pNewPicker); + m_pNormalWidget->SetLayoutItem(this); + + CFWL_NoteDriver* pNoteDriver = + m_pNormalWidget->GetOwnerApp()->GetNoteDriver(); + pNoteDriver->RegisterEventTarget(m_pNormalWidget.get(), + m_pNormalWidget.get()); + m_pOldDelegate = m_pNormalWidget->GetDelegate(); + m_pNormalWidget->SetDelegate(this); + m_pNormalWidget->LockUpdate(); + + CFX_WideString wsText; + m_pDataAcc->GetValue(wsText, XFA_VALUEPICTURE_Display); + pWidget->SetEditText(wsText); + if (CXFA_Value value = m_pDataAcc->GetFormValue()) { + switch (value.GetChildValueClassID()) { + case XFA_Element::Date: { + if (!wsText.IsEmpty()) { + CXFA_LocaleValue lcValue = XFA_GetLocaleValue(m_pDataAcc.Get()); + CFX_DateTime date = lcValue.GetDate(); + if (date.IsSet()) + pWidget->SetCurSel(date.GetYear(), date.GetMonth(), date.GetDay()); + } + } break; + default: + break; + } + } + UpdateWidgetProperty(); + m_pNormalWidget->UnlockUpdate(); + return CXFA_FFField::LoadWidget(); +} + +void CXFA_FFDateTimeEdit::UpdateWidgetProperty() { + CFWL_DateTimePicker* pWidget = + static_cast<CFWL_DateTimePicker*>(m_pNormalWidget.get()); + if (!pWidget) + return; + + uint32_t dwExtendedStyle = FWL_STYLEEXT_DTP_ShortDateFormat; + dwExtendedStyle |= UpdateUIProperty(); + dwExtendedStyle |= GetAlignment(); + m_pNormalWidget->ModifyStylesEx(dwExtendedStyle, 0xFFFFFFFF); + uint32_t dwEditStyles = FWL_STYLEEXT_EDT_LastLineHeight; + int32_t iNumCells = m_pDataAcc->GetNumberOfCells(); + if (iNumCells > 0) { + dwEditStyles |= FWL_STYLEEXT_EDT_CombText; + pWidget->SetEditLimit(iNumCells); + } + if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open || + !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) { + dwEditStyles |= FWL_STYLEEXT_EDT_ReadOnly; + } + if (m_pDataAcc->GetHorizontalScrollPolicy() != XFA_ATTRIBUTEENUM_Off) + dwEditStyles |= FWL_STYLEEXT_EDT_AutoHScroll; + + pWidget->ModifyEditStylesEx(dwEditStyles, 0xFFFFFFFF); +} + +uint32_t CXFA_FFDateTimeEdit::GetAlignment() { + CXFA_Para para = m_pDataAcc->GetPara(); + if (!para) + return 0; + + uint32_t dwExtendedStyle = 0; + switch (para.GetHorizontalAlign()) { + case XFA_ATTRIBUTEENUM_Center: + dwExtendedStyle |= FWL_STYLEEXT_DTP_EditHCenter; + break; + case XFA_ATTRIBUTEENUM_Justify: + dwExtendedStyle |= FWL_STYLEEXT_DTP_EditJustified; + break; + case XFA_ATTRIBUTEENUM_JustifyAll: + case XFA_ATTRIBUTEENUM_Radix: + break; + case XFA_ATTRIBUTEENUM_Right: + dwExtendedStyle |= FWL_STYLEEXT_DTP_EditHFar; + break; + default: + dwExtendedStyle |= FWL_STYLEEXT_DTP_EditHNear; + break; + } + + switch (para.GetVerticalAlign()) { + case XFA_ATTRIBUTEENUM_Middle: + dwExtendedStyle |= FWL_STYLEEXT_DTP_EditVCenter; + break; + case XFA_ATTRIBUTEENUM_Bottom: + dwExtendedStyle |= FWL_STYLEEXT_DTP_EditVFar; + break; + default: + dwExtendedStyle |= FWL_STYLEEXT_DTP_EditVNear; + break; + } + return dwExtendedStyle; +} + +bool CXFA_FFDateTimeEdit::CommitData() { + auto* pPicker = static_cast<CFWL_DateTimePicker*>(m_pNormalWidget.get()); + if (!m_pDataAcc->SetValue(pPicker->GetEditText(), XFA_VALUEPICTURE_Edit)) + return false; + + m_pDataAcc->UpdateUIDisplay(this); + return true; +} + +bool CXFA_FFDateTimeEdit::UpdateFWLData() { + if (!m_pNormalWidget) + return false; + + XFA_VALUEPICTURE eType = XFA_VALUEPICTURE_Display; + if (IsFocused()) + eType = XFA_VALUEPICTURE_Edit; + + CFX_WideString wsText; + m_pDataAcc->GetValue(wsText, eType); + + auto* normalWidget = static_cast<CFWL_DateTimePicker*>(m_pNormalWidget.get()); + normalWidget->SetEditText(wsText); + if (IsFocused() && !wsText.IsEmpty()) { + CXFA_LocaleValue lcValue = XFA_GetLocaleValue(m_pDataAcc.Get()); + CFX_DateTime date = lcValue.GetDate(); + if (lcValue.IsValid()) { + if (date.IsSet()) + normalWidget->SetCurSel(date.GetYear(), date.GetMonth(), date.GetDay()); + } + } + m_pNormalWidget->Update(); + return true; +} + +bool CXFA_FFDateTimeEdit::IsDataChanged() { + if (m_dwStatus & XFA_WidgetStatus_TextEditValueChanged) + return true; + + CFX_WideString wsText = + static_cast<CFWL_DateTimePicker*>(m_pNormalWidget.get())->GetEditText(); + CFX_WideString wsOldValue; + m_pDataAcc->GetValue(wsOldValue, XFA_VALUEPICTURE_Edit); + return wsOldValue != wsText; +} + +void CXFA_FFDateTimeEdit::OnSelectChanged(CFWL_Widget* pWidget, + int32_t iYear, + int32_t iMonth, + int32_t iDay) { + CFX_WideString wsPicture; + m_pDataAcc->GetPictureContent(wsPicture, XFA_VALUEPICTURE_Edit); + + CXFA_LocaleValue date(XFA_VT_DATE, GetDoc()->GetXFADoc()->GetLocalMgr()); + date.SetDate(CFX_DateTime(iYear, iMonth, iDay, 0, 0, 0, 0)); + + CFX_WideString wsDate; + date.FormatPatterns(wsDate, wsPicture, m_pDataAcc->GetLocal(), + XFA_VALUEPICTURE_Edit); + + auto* pDateTime = static_cast<CFWL_DateTimePicker*>(m_pNormalWidget.get()); + pDateTime->SetEditText(wsDate); + pDateTime->Update(); + GetDoc()->GetDocEnvironment()->SetFocusWidget(GetDoc(), nullptr); + + CXFA_EventParam eParam; + eParam.m_eType = XFA_EVENT_Change; + eParam.m_pTarget = m_pDataAcc.Get(); + m_pDataAcc->GetValue(eParam.m_wsNewText, XFA_VALUEPICTURE_Raw); + m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Change, &eParam); +} + +void CXFA_FFDateTimeEdit::OnProcessEvent(CFWL_Event* pEvent) { + if (pEvent->GetType() == CFWL_Event::Type::SelectChanged) { + auto* event = static_cast<CFWL_EventSelectChanged*>(pEvent); + OnSelectChanged(m_pNormalWidget.get(), event->iYear, event->iMonth, + event->iDay); + return; + } + CXFA_FFTextEdit::OnProcessEvent(pEvent); +} diff --git a/xfa/fxfa/app/cxfa_ffdatetimeedit.h b/xfa/fxfa/app/cxfa_ffdatetimeedit.h new file mode 100644 index 0000000000..c62f657fab --- /dev/null +++ b/xfa/fxfa/app/cxfa_ffdatetimeedit.h @@ -0,0 +1,47 @@ +// Copyright 2017 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#ifndef XFA_FXFA_APP_CXFA_FFDATETIMEEDIT_H_ +#define XFA_FXFA_APP_CXFA_FFDATETIMEEDIT_H_ + +#include "core/fxcrt/fx_coordinates.h" +#include "xfa/fxfa/app/cxfa_fftextedit.h" + +enum XFA_DATETIMETYPE { + XFA_DATETIMETYPE_Date = 0, + XFA_DATETIMETYPE_Time, + XFA_DATETIMETYPE_DateAndTime +}; + +class CFWL_Event; +class CFWL_Widget; + +class CXFA_FFDateTimeEdit : public CXFA_FFTextEdit { + public: + explicit CXFA_FFDateTimeEdit(CXFA_WidgetAcc* pDataAcc); + ~CXFA_FFDateTimeEdit() override; + + // CXFA_FFTextEdit + CFX_RectF GetBBox(uint32_t dwStatus, bool bDrawFocus = false) override; + bool LoadWidget() override; + void UpdateWidgetProperty() override; + void OnProcessEvent(CFWL_Event* pEvent) override; + + void OnSelectChanged(CFWL_Widget* pWidget, + int32_t iYear, + int32_t iMonth, + int32_t iDay); + + private: + bool PtInActiveRect(const CFX_PointF& point) override; + bool CommitData() override; + bool UpdateFWLData() override; + bool IsDataChanged() override; + + uint32_t GetAlignment(); +}; + +#endif // XFA_FXFA_APP_CXFA_FFDATETIMEEDIT_H_ diff --git a/xfa/fxfa/app/xfa_ffdraw.cpp b/xfa/fxfa/app/cxfa_ffdraw.cpp index 8742b83c5b..5736e77352 100644 --- a/xfa/fxfa/app/xfa_ffdraw.cpp +++ b/xfa/fxfa/app/cxfa_ffdraw.cpp @@ -4,7 +4,7 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#include "xfa/fxfa/app/xfa_ffdraw.h" +#include "xfa/fxfa/app/cxfa_ffdraw.h" #include "xfa/fxfa/cxfa_ffapp.h" #include "xfa/fxfa/cxfa_ffdoc.h" diff --git a/xfa/fxfa/app/xfa_ffdraw.h b/xfa/fxfa/app/cxfa_ffdraw.h index bcd74f204c..2a65ad0a78 100644 --- a/xfa/fxfa/app/xfa_ffdraw.h +++ b/xfa/fxfa/app/cxfa_ffdraw.h @@ -4,8 +4,8 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#ifndef XFA_FXFA_APP_XFA_FFDRAW_H_ -#define XFA_FXFA_APP_XFA_FFDRAW_H_ +#ifndef XFA_FXFA_APP_CXFA_FFDRAW_H_ +#define XFA_FXFA_APP_CXFA_FFDRAW_H_ #include "xfa/fxfa/cxfa_ffpageview.h" #include "xfa/fxfa/cxfa_ffwidget.h" @@ -16,4 +16,4 @@ class CXFA_FFDraw : public CXFA_FFWidget { ~CXFA_FFDraw() override; }; -#endif // XFA_FXFA_APP_XFA_FFDRAW_H_ +#endif // XFA_FXFA_APP_CXFA_FFDRAW_H_ diff --git a/xfa/fxfa/app/xfa_ffexclgroup.cpp b/xfa/fxfa/app/cxfa_ffexclgroup.cpp index 9f2560f82f..60f0202120 100644 --- a/xfa/fxfa/app/xfa_ffexclgroup.cpp +++ b/xfa/fxfa/app/cxfa_ffexclgroup.cpp @@ -4,7 +4,7 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#include "xfa/fxfa/app/xfa_ffexclgroup.h" +#include "xfa/fxfa/app/cxfa_ffexclgroup.h" #include "xfa/fxfa/cxfa_ffapp.h" #include "xfa/fxfa/cxfa_ffdoc.h" diff --git a/xfa/fxfa/app/xfa_ffexclgroup.h b/xfa/fxfa/app/cxfa_ffexclgroup.h index a14894566c..4b66b94712 100644 --- a/xfa/fxfa/app/xfa_ffexclgroup.h +++ b/xfa/fxfa/app/cxfa_ffexclgroup.h @@ -4,8 +4,8 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#ifndef XFA_FXFA_APP_XFA_FFEXCLGROUP_H_ -#define XFA_FXFA_APP_XFA_FFEXCLGROUP_H_ +#ifndef XFA_FXFA_APP_CXFA_FFEXCLGROUP_H_ +#define XFA_FXFA_APP_CXFA_FFEXCLGROUP_H_ #include "xfa/fxfa/cxfa_ffpageview.h" #include "xfa/fxfa/cxfa_ffwidget.h" @@ -21,4 +21,4 @@ class CXFA_FFExclGroup : public CXFA_FFWidget { uint32_t dwStatus) override; }; -#endif // XFA_FXFA_APP_XFA_FFEXCLGROUP_H_ +#endif // XFA_FXFA_APP_CXFA_FFEXCLGROUP_H_ diff --git a/xfa/fxfa/app/xfa_fffield.cpp b/xfa/fxfa/app/cxfa_fffield.cpp index 425ba30843..fe56917cb6 100644 --- a/xfa/fxfa/app/xfa_fffield.cpp +++ b/xfa/fxfa/app/cxfa_fffield.cpp @@ -4,7 +4,7 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#include "xfa/fxfa/app/xfa_fffield.h" +#include "xfa/fxfa/app/cxfa_fffield.h" #include "xfa/fwl/cfwl_edit.h" #include "xfa/fwl/cfwl_eventmouse.h" @@ -15,8 +15,8 @@ #include "xfa/fwl/cfwl_messagesetfocus.h" #include "xfa/fwl/cfwl_picturebox.h" #include "xfa/fwl/cfwl_widgetmgr.h" +#include "xfa/fxfa/app/cxfa_fwltheme.h" #include "xfa/fxfa/app/cxfa_textlayout.h" -#include "xfa/fxfa/app/xfa_fwltheme.h" #include "xfa/fxfa/cxfa_ffapp.h" #include "xfa/fxfa/cxfa_ffdoc.h" #include "xfa/fxfa/cxfa_ffdocview.h" diff --git a/xfa/fxfa/app/xfa_fffield.h b/xfa/fxfa/app/cxfa_fffield.h index eb06caf34a..3799eb39b7 100644 --- a/xfa/fxfa/app/xfa_fffield.h +++ b/xfa/fxfa/app/cxfa_fffield.h @@ -4,8 +4,8 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#ifndef XFA_FXFA_APP_XFA_FFFIELD_H_ -#define XFA_FXFA_APP_XFA_FFFIELD_H_ +#ifndef XFA_FXFA_APP_CXFA_FFFIELD_H_ +#define XFA_FXFA_APP_CXFA_FFFIELD_H_ #include <memory> @@ -96,4 +96,4 @@ class CXFA_FFField : public CXFA_FFWidget, public IFWL_WidgetDelegate { CFX_RectF m_rtCaption; }; -#endif // XFA_FXFA_APP_XFA_FFFIELD_H_ +#endif // XFA_FXFA_APP_CXFA_FFFIELD_H_ diff --git a/xfa/fxfa/app/xfa_ffimage.cpp b/xfa/fxfa/app/cxfa_ffimage.cpp index db9b4de52a..f8a6668a91 100644 --- a/xfa/fxfa/app/xfa_ffimage.cpp +++ b/xfa/fxfa/app/cxfa_ffimage.cpp @@ -4,9 +4,9 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#include "xfa/fxfa/app/xfa_ffimage.h" +#include "xfa/fxfa/app/cxfa_ffimage.h" -#include "xfa/fxfa/app/xfa_ffdraw.h" +#include "xfa/fxfa/app/cxfa_ffdraw.h" #include "xfa/fxfa/cxfa_ffapp.h" #include "xfa/fxfa/cxfa_ffdoc.h" #include "xfa/fxfa/cxfa_ffpageview.h" diff --git a/xfa/fxfa/app/xfa_ffimage.h b/xfa/fxfa/app/cxfa_ffimage.h index 2c42791877..1b22fce668 100644 --- a/xfa/fxfa/app/xfa_ffimage.h +++ b/xfa/fxfa/app/cxfa_ffimage.h @@ -4,10 +4,10 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#ifndef XFA_FXFA_APP_XFA_FFIMAGE_H_ -#define XFA_FXFA_APP_XFA_FFIMAGE_H_ +#ifndef XFA_FXFA_APP_CXFA_FFIMAGE_H_ +#define XFA_FXFA_APP_CXFA_FFIMAGE_H_ -#include "xfa/fxfa/app/xfa_ffdraw.h" +#include "xfa/fxfa/app/cxfa_ffdraw.h" class CXFA_FFImage : public CXFA_FFDraw { public: @@ -23,4 +23,4 @@ class CXFA_FFImage : public CXFA_FFDraw { void UnloadWidget() override; }; -#endif // XFA_FXFA_APP_XFA_FFIMAGE_H_ +#endif // XFA_FXFA_APP_CXFA_FFIMAGE_H_ diff --git a/xfa/fxfa/app/xfa_ffimageedit.cpp b/xfa/fxfa/app/cxfa_ffimageedit.cpp index c8d9509aca..0b0b6ec853 100644 --- a/xfa/fxfa/app/xfa_ffimageedit.cpp +++ b/xfa/fxfa/app/cxfa_ffimageedit.cpp @@ -4,7 +4,7 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#include "xfa/fxfa/app/xfa_ffimageedit.h" +#include "xfa/fxfa/app/cxfa_ffimageedit.h" #include <utility> @@ -13,7 +13,7 @@ #include "xfa/fwl/cfwl_messagemouse.h" #include "xfa/fwl/cfwl_notedriver.h" #include "xfa/fwl/cfwl_picturebox.h" -#include "xfa/fxfa/app/xfa_fffield.h" +#include "xfa/fxfa/app/cxfa_fffield.h" #include "xfa/fxfa/cxfa_ffdoc.h" #include "xfa/fxfa/cxfa_ffdocview.h" #include "xfa/fxfa/cxfa_ffpageview.h" diff --git a/xfa/fxfa/app/xfa_ffimageedit.h b/xfa/fxfa/app/cxfa_ffimageedit.h index ee91a772e0..81b45e8de0 100644 --- a/xfa/fxfa/app/xfa_ffimageedit.h +++ b/xfa/fxfa/app/cxfa_ffimageedit.h @@ -4,10 +4,10 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#ifndef XFA_FXFA_APP_XFA_FFIMAGEEDIT_H_ -#define XFA_FXFA_APP_XFA_FFIMAGEEDIT_H_ +#ifndef XFA_FXFA_APP_CXFA_FFIMAGEEDIT_H_ +#define XFA_FXFA_APP_CXFA_FFIMAGEEDIT_H_ -#include "xfa/fxfa/app/xfa_fffield.h" +#include "xfa/fxfa/app/cxfa_fffield.h" class CXFA_FFImageEdit : public CXFA_FFField { public: @@ -34,4 +34,4 @@ class CXFA_FFImageEdit : public CXFA_FFField { IFWL_WidgetDelegate* m_pOldDelegate; }; -#endif // XFA_FXFA_APP_XFA_FFIMAGEEDIT_H_ +#endif // XFA_FXFA_APP_CXFA_FFIMAGEEDIT_H_ diff --git a/xfa/fxfa/app/xfa_ffpath.cpp b/xfa/fxfa/app/cxfa_ffline.cpp index 854a028aac..67ed7ebd1a 100644 --- a/xfa/fxfa/app/xfa_ffpath.cpp +++ b/xfa/fxfa/app/cxfa_ffline.cpp @@ -1,17 +1,13 @@ -// 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 -#include "xfa/fxfa/app/xfa_ffpath.h" +#include "xfa/fxfa/app/cxfa_ffline.h" -#include "xfa/fxfa/app/xfa_ffdraw.h" -#include "xfa/fxfa/cxfa_ffapp.h" -#include "xfa/fxfa/cxfa_ffdoc.h" -#include "xfa/fxfa/cxfa_ffpageview.h" -#include "xfa/fxfa/cxfa_ffwidget.h" #include "xfa/fxgraphics/cfx_color.h" +#include "xfa/fxgraphics/cfx_graphics.h" #include "xfa/fxgraphics/cfx_path.h" CXFA_FFLine::CXFA_FFLine(CXFA_WidgetAcc* pDataAcc) : CXFA_FFDraw(pDataAcc) {} @@ -101,56 +97,3 @@ void CXFA_FFLine::RenderWidget(CFX_Graphics* pGS, pGS->StrokePath(&linePath, &mtRotate); pGS->RestoreGraphState(); } - -CXFA_FFArc::CXFA_FFArc(CXFA_WidgetAcc* pDataAcc) : CXFA_FFDraw(pDataAcc) {} - -CXFA_FFArc::~CXFA_FFArc() {} - -void CXFA_FFArc::RenderWidget(CFX_Graphics* pGS, - CFX_Matrix* pMatrix, - uint32_t dwStatus) { - if (!IsMatchVisibleStatus(dwStatus)) - return; - - CXFA_Value value = m_pDataAcc->GetFormValue(); - if (!value) - return; - - CXFA_Arc arcObj = value.GetArc(); - CFX_Matrix mtRotate = GetRotateMatrix(); - if (pMatrix) - mtRotate.Concat(*pMatrix); - - CFX_RectF rtArc = GetRectWithoutRotate(); - if (CXFA_Margin mgWidget = m_pDataAcc->GetMargin()) - XFA_RectWidthoutMargin(rtArc, mgWidget); - - DrawBorder(pGS, arcObj, rtArc, &mtRotate); -} - -CXFA_FFRectangle::CXFA_FFRectangle(CXFA_WidgetAcc* pDataAcc) - : CXFA_FFDraw(pDataAcc) {} - -CXFA_FFRectangle::~CXFA_FFRectangle() {} - -void CXFA_FFRectangle::RenderWidget(CFX_Graphics* pGS, - CFX_Matrix* pMatrix, - uint32_t dwStatus) { - if (!IsMatchVisibleStatus(dwStatus)) - return; - - CXFA_Value value = m_pDataAcc->GetFormValue(); - if (!value) - return; - - CXFA_Rectangle rtObj = value.GetRectangle(); - CFX_RectF rect = GetRectWithoutRotate(); - if (CXFA_Margin mgWidget = m_pDataAcc->GetMargin()) - XFA_RectWidthoutMargin(rect, mgWidget); - - CFX_Matrix mtRotate = GetRotateMatrix(); - if (pMatrix) - mtRotate.Concat(*pMatrix); - - DrawBorder(pGS, rtObj, rect, &mtRotate); -} diff --git a/xfa/fxfa/app/cxfa_ffline.h b/xfa/fxfa/app/cxfa_ffline.h new file mode 100644 index 0000000000..6803e38285 --- /dev/null +++ b/xfa/fxfa/app/cxfa_ffline.h @@ -0,0 +1,26 @@ +// Copyright 2017 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#ifndef XFA_FXFA_APP_CXFA_FFLINE_H_ +#define XFA_FXFA_APP_CXFA_FFLINE_H_ + +#include "xfa/fxfa/app/cxfa_ffdraw.h" + +class CXFA_FFLine : public CXFA_FFDraw { + public: + explicit CXFA_FFLine(CXFA_WidgetAcc* pDataAcc); + ~CXFA_FFLine() override; + + // CXFA_FFWidget + void RenderWidget(CFX_Graphics* pGS, + CFX_Matrix* pMatrix, + uint32_t dwStatus) override; + + private: + void GetRectFromHand(CFX_RectF& rect, int32_t iHand, float fLineWidth); +}; + +#endif // XFA_FXFA_APP_CXFA_FFLINE_H_ diff --git a/xfa/fxfa/app/cxfa_fflistbox.cpp b/xfa/fxfa/app/cxfa_fflistbox.cpp new file mode 100644 index 0000000000..dd80325c34 --- /dev/null +++ b/xfa/fxfa/app/cxfa_fflistbox.cpp @@ -0,0 +1,210 @@ +// Copyright 2017 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#include "xfa/fxfa/app/cxfa_fflistbox.h" + +#include <algorithm> +#include <utility> +#include <vector> + +#include "xfa/fwl/cfwl_listbox.h" +#include "xfa/fwl/cfwl_notedriver.h" +#include "xfa/fwl/cfwl_widget.h" +#include "xfa/fxfa/cxfa_eventparam.h" + +namespace { + +CFWL_ListBox* ToListBox(CFWL_Widget* widget) { + return static_cast<CFWL_ListBox*>(widget); +} + +} // namespace + +CXFA_FFListBox::CXFA_FFListBox(CXFA_WidgetAcc* pDataAcc) + : CXFA_FFField(pDataAcc), m_pOldDelegate(nullptr) {} + +CXFA_FFListBox::~CXFA_FFListBox() { + if (!m_pNormalWidget) + return; + + CFWL_NoteDriver* pNoteDriver = + m_pNormalWidget->GetOwnerApp()->GetNoteDriver(); + pNoteDriver->UnregisterEventTarget(m_pNormalWidget.get()); +} + +bool CXFA_FFListBox::LoadWidget() { + auto pNew = pdfium::MakeUnique<CFWL_ListBox>( + GetFWLApp(), pdfium::MakeUnique<CFWL_WidgetProperties>(), nullptr); + CFWL_ListBox* pListBox = pNew.get(); + pListBox->ModifyStyles(FWL_WGTSTYLE_VScroll | FWL_WGTSTYLE_NoBackground, + 0xFFFFFFFF); + m_pNormalWidget = std::move(pNew); + m_pNormalWidget->SetLayoutItem(this); + + CFWL_NoteDriver* pNoteDriver = + m_pNormalWidget->GetOwnerApp()->GetNoteDriver(); + pNoteDriver->RegisterEventTarget(m_pNormalWidget.get(), + m_pNormalWidget.get()); + m_pOldDelegate = m_pNormalWidget->GetDelegate(); + m_pNormalWidget->SetDelegate(this); + m_pNormalWidget->LockUpdate(); + + for (const auto& label : m_pDataAcc->GetChoiceListItems(false)) + pListBox->AddString(label.AsStringC()); + + uint32_t dwExtendedStyle = FWL_STYLEEXT_LTB_ShowScrollBarFocus; + if (m_pDataAcc->GetChoiceListOpen() == XFA_ATTRIBUTEENUM_MultiSelect) + dwExtendedStyle |= FWL_STYLEEXT_LTB_MultiSelection; + + dwExtendedStyle |= GetAlignment(); + m_pNormalWidget->ModifyStylesEx(dwExtendedStyle, 0xFFFFFFFF); + for (int32_t selected : m_pDataAcc->GetSelectedItems()) + pListBox->SetSelItem(pListBox->GetItem(nullptr, selected), true); + + m_pNormalWidget->UnlockUpdate(); + return CXFA_FFField::LoadWidget(); +} + +bool CXFA_FFListBox::OnKillFocus(CXFA_FFWidget* pNewFocus) { + if (!ProcessCommittedData()) + UpdateFWLData(); + + CXFA_FFField::OnKillFocus(pNewFocus); + return true; +} + +bool CXFA_FFListBox::CommitData() { + auto* pListBox = ToListBox(m_pNormalWidget.get()); + std::vector<int32_t> iSelArray; + int32_t iSels = pListBox->CountSelItems(); + for (int32_t i = 0; i < iSels; ++i) + iSelArray.push_back(pListBox->GetSelIndex(i)); + + m_pDataAcc->SetSelectedItems(iSelArray, true, false, true); + return true; +} + +bool CXFA_FFListBox::IsDataChanged() { + std::vector<int32_t> iSelArray = m_pDataAcc->GetSelectedItems(); + int32_t iOldSels = pdfium::CollectionSize<int32_t>(iSelArray); + auto* pListBox = ToListBox(m_pNormalWidget.get()); + int32_t iSels = pListBox->CountSelItems(); + if (iOldSels != iSels) + return true; + + for (int32_t i = 0; i < iSels; ++i) { + CFWL_ListItem* hlistItem = pListBox->GetItem(nullptr, iSelArray[i]); + if (!(hlistItem->GetStates() & FWL_ITEMSTATE_LTB_Selected)) + return true; + } + return false; +} + +uint32_t CXFA_FFListBox::GetAlignment() { + CXFA_Para para = m_pDataAcc->GetPara(); + if (!para) + return 0; + + uint32_t dwExtendedStyle = 0; + switch (para.GetHorizontalAlign()) { + case XFA_ATTRIBUTEENUM_Center: + dwExtendedStyle |= FWL_STYLEEXT_LTB_CenterAlign; + break; + case XFA_ATTRIBUTEENUM_Justify: + break; + case XFA_ATTRIBUTEENUM_JustifyAll: + break; + case XFA_ATTRIBUTEENUM_Radix: + break; + case XFA_ATTRIBUTEENUM_Right: + dwExtendedStyle |= FWL_STYLEEXT_LTB_RightAlign; + break; + default: + dwExtendedStyle |= FWL_STYLEEXT_LTB_LeftAlign; + break; + } + return dwExtendedStyle; +} + +bool CXFA_FFListBox::UpdateFWLData() { + if (!m_pNormalWidget) + return false; + + auto* pListBox = ToListBox(m_pNormalWidget.get()); + std::vector<int32_t> iSelArray = m_pDataAcc->GetSelectedItems(); + std::vector<CFWL_ListItem*> selItemArray(iSelArray.size()); + std::transform(iSelArray.begin(), iSelArray.end(), selItemArray.begin(), + [pListBox](int32_t val) { return pListBox->GetSelItem(val); }); + + pListBox->SetSelItem(pListBox->GetSelItem(-1), false); + for (CFWL_ListItem* pItem : selItemArray) + pListBox->SetSelItem(pItem, true); + + m_pNormalWidget->Update(); + return true; +} + +void CXFA_FFListBox::OnSelectChanged(CFWL_Widget* pWidget) { + CXFA_EventParam eParam; + eParam.m_eType = XFA_EVENT_Change; + eParam.m_pTarget = m_pDataAcc.Get(); + m_pDataAcc->GetValue(eParam.m_wsPrevText, XFA_VALUEPICTURE_Raw); + + auto* pListBox = ToListBox(m_pNormalWidget.get()); + int32_t iSels = pListBox->CountSelItems(); + if (iSels > 0) { + CFWL_ListItem* item = pListBox->GetSelItem(0); + eParam.m_wsNewText = item ? item->GetText() : L""; + } + m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Change, &eParam); +} + +void CXFA_FFListBox::SetItemState(int32_t nIndex, bool bSelected) { + auto* pListBox = ToListBox(m_pNormalWidget.get()); + pListBox->SetSelItem(pListBox->GetSelItem(nIndex), bSelected); + m_pNormalWidget->Update(); + AddInvalidateRect(); +} + +void CXFA_FFListBox::InsertItem(const CFX_WideStringC& wsLabel, + int32_t nIndex) { + CFX_WideString wsTemp(wsLabel); + ToListBox(m_pNormalWidget.get())->AddString(wsTemp.AsStringC()); + m_pNormalWidget->Update(); + AddInvalidateRect(); +} + +void CXFA_FFListBox::DeleteItem(int32_t nIndex) { + auto* pListBox = ToListBox(m_pNormalWidget.get()); + if (nIndex < 0) + pListBox->DeleteAll(); + else + pListBox->DeleteString(pListBox->GetItem(nullptr, nIndex)); + + pListBox->Update(); + AddInvalidateRect(); +} + +void CXFA_FFListBox::OnProcessMessage(CFWL_Message* pMessage) { + m_pOldDelegate->OnProcessMessage(pMessage); +} + +void CXFA_FFListBox::OnProcessEvent(CFWL_Event* pEvent) { + CXFA_FFField::OnProcessEvent(pEvent); + switch (pEvent->GetType()) { + case CFWL_Event::Type::SelectChanged: + OnSelectChanged(m_pNormalWidget.get()); + break; + default: + break; + } + m_pOldDelegate->OnProcessEvent(pEvent); +} + +void CXFA_FFListBox::OnDrawWidget(CFX_Graphics* pGraphics, + const CFX_Matrix* pMatrix) { + m_pOldDelegate->OnDrawWidget(pGraphics, pMatrix); +} diff --git a/xfa/fxfa/app/cxfa_fflistbox.h b/xfa/fxfa/app/cxfa_fflistbox.h new file mode 100644 index 0000000000..6f090af63f --- /dev/null +++ b/xfa/fxfa/app/cxfa_fflistbox.h @@ -0,0 +1,40 @@ +// Copyright 2017 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#ifndef XFA_FXFA_APP_CXFA_FFLISTBOX_H_ +#define XFA_FXFA_APP_CXFA_FFLISTBOX_H_ + +#include "xfa/fxfa/app/cxfa_fffield.h" + +class CXFA_FFListBox : public CXFA_FFField { + public: + explicit CXFA_FFListBox(CXFA_WidgetAcc* pDataAcc); + ~CXFA_FFListBox() override; + + // CXFA_FFField + bool LoadWidget() override; + bool OnKillFocus(CXFA_FFWidget* pNewWidget) override; + void OnProcessMessage(CFWL_Message* pMessage) override; + void OnProcessEvent(CFWL_Event* pEvent) override; + void OnDrawWidget(CFX_Graphics* pGraphics, + const CFX_Matrix* pMatrix = nullptr) override; + + void OnSelectChanged(CFWL_Widget* pWidget); + void SetItemState(int32_t nIndex, bool bSelected); + void InsertItem(const CFX_WideStringC& wsLabel, int32_t nIndex); + void DeleteItem(int32_t nIndex); + + private: + bool CommitData() override; + bool UpdateFWLData() override; + bool IsDataChanged() override; + + uint32_t GetAlignment(); + + IFWL_WidgetDelegate* m_pOldDelegate; +}; + +#endif // XFA_FXFA_APP_CXFA_FFLISTBOX_H_ diff --git a/xfa/fxfa/app/xfa_ffnotify.cpp b/xfa/fxfa/app/cxfa_ffnotify.cpp index b07b625538..a660ffff12 100644 --- a/xfa/fxfa/app/xfa_ffnotify.cpp +++ b/xfa/fxfa/app/cxfa_ffnotify.cpp @@ -4,26 +4,31 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#include "xfa/fxfa/app/xfa_ffnotify.h" +#include "xfa/fxfa/app/cxfa_ffnotify.h" #include "fxjs/cfxjse_value.h" +#include "xfa/fxfa/app/cxfa_ffarc.h" +#include "xfa/fxfa/app/cxfa_ffbarcode.h" +#include "xfa/fxfa/app/cxfa_ffcheckbutton.h" +#include "xfa/fxfa/app/cxfa_ffcombobox.h" +#include "xfa/fxfa/app/cxfa_ffdatetimeedit.h" +#include "xfa/fxfa/app/cxfa_ffdraw.h" +#include "xfa/fxfa/app/cxfa_ffexclgroup.h" +#include "xfa/fxfa/app/cxfa_fffield.h" +#include "xfa/fxfa/app/cxfa_ffimage.h" +#include "xfa/fxfa/app/cxfa_ffimageedit.h" +#include "xfa/fxfa/app/cxfa_ffline.h" +#include "xfa/fxfa/app/cxfa_fflistbox.h" +#include "xfa/fxfa/app/cxfa_ffnumericedit.h" +#include "xfa/fxfa/app/cxfa_ffpasswordedit.h" +#include "xfa/fxfa/app/cxfa_ffpushbutton.h" +#include "xfa/fxfa/app/cxfa_ffrectangle.h" +#include "xfa/fxfa/app/cxfa_ffsignature.h" +#include "xfa/fxfa/app/cxfa_ffsubform.h" +#include "xfa/fxfa/app/cxfa_fftext.h" +#include "xfa/fxfa/app/cxfa_fwladapterwidgetmgr.h" #include "xfa/fxfa/app/cxfa_textlayout.h" -#include "xfa/fxfa/app/xfa_ffbarcode.h" -#include "xfa/fxfa/app/xfa_ffcheckbutton.h" -#include "xfa/fxfa/app/xfa_ffchoicelist.h" -#include "xfa/fxfa/app/xfa_ffdraw.h" -#include "xfa/fxfa/app/xfa_ffexclgroup.h" -#include "xfa/fxfa/app/xfa_fffield.h" -#include "xfa/fxfa/app/xfa_ffimage.h" -#include "xfa/fxfa/app/xfa_ffimageedit.h" -#include "xfa/fxfa/app/xfa_ffpath.h" -#include "xfa/fxfa/app/xfa_ffpushbutton.h" -#include "xfa/fxfa/app/xfa_ffsignature.h" -#include "xfa/fxfa/app/xfa_ffsubform.h" -#include "xfa/fxfa/app/xfa_fftext.h" -#include "xfa/fxfa/app/xfa_fftextedit.h" -#include "xfa/fxfa/app/xfa_ffwidgetacc.h" -#include "xfa/fxfa/app/xfa_fwladapter.h" +#include "xfa/fxfa/app/cxfa_textprovider.h" #include "xfa/fxfa/cxfa_ffapp.h" #include "xfa/fxfa/cxfa_ffdoc.h" #include "xfa/fxfa/cxfa_ffdocview.h" diff --git a/xfa/fxfa/app/xfa_ffnotify.h b/xfa/fxfa/app/cxfa_ffnotify.h index 930d3b6a90..935a0c390b 100644 --- a/xfa/fxfa/app/xfa_ffnotify.h +++ b/xfa/fxfa/app/cxfa_ffnotify.h @@ -4,8 +4,8 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#ifndef XFA_FXFA_APP_XFA_FFNOTIFY_H_ -#define XFA_FXFA_APP_XFA_FFNOTIFY_H_ +#ifndef XFA_FXFA_APP_CXFA_FFNOTIFY_H_ +#define XFA_FXFA_APP_CXFA_FFNOTIFY_H_ #include "xfa/fxfa/cxfa_eventparam.h" #include "xfa/fxfa/parser/cxfa_document.h" @@ -74,4 +74,4 @@ class CXFA_FFNotify { CFX_UnownedPtr<CXFA_FFDoc> const m_pDoc; }; -#endif // XFA_FXFA_APP_XFA_FFNOTIFY_H_ +#endif // XFA_FXFA_APP_CXFA_FFNOTIFY_H_ diff --git a/xfa/fxfa/app/cxfa_ffnumericedit.cpp b/xfa/fxfa/app/cxfa_ffnumericedit.cpp new file mode 100644 index 0000000000..a2aad63daa --- /dev/null +++ b/xfa/fxfa/app/cxfa_ffnumericedit.cpp @@ -0,0 +1,97 @@ +// Copyright 2017 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#include "xfa/fxfa/app/cxfa_ffnumericedit.h" + +#include <utility> + +#include "xfa/fwl/cfwl_edit.h" +#include "xfa/fwl/cfwl_eventvalidate.h" +#include "xfa/fwl/cfwl_notedriver.h" +#include "xfa/fxfa/parser/cxfa_localevalue.h" + +CXFA_FFNumericEdit::CXFA_FFNumericEdit(CXFA_WidgetAcc* pDataAcc) + : CXFA_FFTextEdit(pDataAcc) {} + +CXFA_FFNumericEdit::~CXFA_FFNumericEdit() {} + +bool CXFA_FFNumericEdit::LoadWidget() { + auto pNewEdit = pdfium::MakeUnique<CFWL_Edit>( + GetFWLApp(), pdfium::MakeUnique<CFWL_WidgetProperties>(), nullptr); + CFWL_Edit* pWidget = pNewEdit.get(); + m_pNormalWidget = std::move(pNewEdit); + m_pNormalWidget->SetLayoutItem(this); + + CFWL_NoteDriver* pNoteDriver = + m_pNormalWidget->GetOwnerApp()->GetNoteDriver(); + pNoteDriver->RegisterEventTarget(m_pNormalWidget.get(), + m_pNormalWidget.get()); + m_pOldDelegate = m_pNormalWidget->GetDelegate(); + m_pNormalWidget->SetDelegate(this); + m_pNormalWidget->LockUpdate(); + + CFX_WideString wsText; + m_pDataAcc->GetValue(wsText, XFA_VALUEPICTURE_Display); + pWidget->SetText(wsText); + UpdateWidgetProperty(); + m_pNormalWidget->UnlockUpdate(); + return CXFA_FFField::LoadWidget(); +} + +void CXFA_FFNumericEdit::UpdateWidgetProperty() { + CFWL_Edit* pWidget = static_cast<CFWL_Edit*>(m_pNormalWidget.get()); + if (!pWidget) + return; + + uint32_t dwExtendedStyle = + FWL_STYLEEXT_EDT_ShowScrollbarFocus | FWL_STYLEEXT_EDT_OuterScrollbar | + FWL_STYLEEXT_EDT_Validate | FWL_STYLEEXT_EDT_Number | + FWL_STYLEEXT_EDT_LastLineHeight; + dwExtendedStyle |= UpdateUIProperty(); + if (m_pDataAcc->GetHorizontalScrollPolicy() != XFA_ATTRIBUTEENUM_Off) + dwExtendedStyle |= FWL_STYLEEXT_EDT_AutoHScroll; + + int32_t iNumCells = m_pDataAcc->GetNumberOfCells(); + if (iNumCells > 0) { + dwExtendedStyle |= FWL_STYLEEXT_EDT_CombText; + pWidget->SetLimit(iNumCells); + } + dwExtendedStyle |= GetAlignment(); + if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open || + !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) { + dwExtendedStyle |= FWL_STYLEEXT_EDT_ReadOnly; + } + m_pNormalWidget->ModifyStylesEx(dwExtendedStyle, 0xFFFFFFFF); +} + +void CXFA_FFNumericEdit::OnProcessEvent(CFWL_Event* pEvent) { + if (pEvent->GetType() == CFWL_Event::Type::Validate) { + CFWL_EventValidate* event = static_cast<CFWL_EventValidate*>(pEvent); + event->bValidate = OnValidate(m_pNormalWidget.get(), event->wsInsert); + return; + } + CXFA_FFTextEdit::OnProcessEvent(pEvent); +} + +bool CXFA_FFNumericEdit::OnValidate(CFWL_Widget* pWidget, + CFX_WideString& wsText) { + CFX_WideString wsPattern; + m_pDataAcc->GetPictureContent(wsPattern, XFA_VALUEPICTURE_Edit); + if (!wsPattern.IsEmpty()) + return true; + + int32_t iLeads = 0; + m_pDataAcc->GetLeadDigits(iLeads); + + int32_t iFracs = 0; + m_pDataAcc->GetFracDigits(iFracs); + + CFX_WideString wsFormat; + CXFA_LocaleValue widgetValue = XFA_GetLocaleValue(m_pDataAcc.Get()); + widgetValue.GetNumbericFormat(wsFormat, iLeads, iFracs); + return widgetValue.ValidateNumericTemp(wsText, wsFormat, + m_pDataAcc->GetLocal()); +} diff --git a/xfa/fxfa/app/cxfa_ffnumericedit.h b/xfa/fxfa/app/cxfa_ffnumericedit.h new file mode 100644 index 0000000000..25e2304e87 --- /dev/null +++ b/xfa/fxfa/app/cxfa_ffnumericedit.h @@ -0,0 +1,31 @@ +// Copyright 2017 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#ifndef XFA_FXFA_APP_CXFA_FFNUMERICEDIT_H_ +#define XFA_FXFA_APP_CXFA_FFNUMERICEDIT_H_ + +#include "core/fxcrt/fx_string.h" +#include "xfa/fxfa/app/cxfa_fftextedit.h" + +class CFWL_Event; +class CFWL_Widget; +class CXFA_WidgetAcc; + +class CXFA_FFNumericEdit : public CXFA_FFTextEdit { + public: + explicit CXFA_FFNumericEdit(CXFA_WidgetAcc* pDataAcc); + ~CXFA_FFNumericEdit() override; + + // CXFA_FFTextEdit + bool LoadWidget() override; + void UpdateWidgetProperty() override; + void OnProcessEvent(CFWL_Event* pEvent) override; + + private: + bool OnValidate(CFWL_Widget* pWidget, CFX_WideString& wsText); +}; + +#endif // XFA_FXFA_APP_CXFA_FFNUMERICEDIT_H_ diff --git a/xfa/fxfa/app/cxfa_ffpasswordedit.cpp b/xfa/fxfa/app/cxfa_ffpasswordedit.cpp new file mode 100644 index 0000000000..1b404fa046 --- /dev/null +++ b/xfa/fxfa/app/cxfa_ffpasswordedit.cpp @@ -0,0 +1,64 @@ +// Copyright 2017 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#include "xfa/fxfa/app/cxfa_ffpasswordedit.h" + +#include <utility> + +#include "xfa/fwl/cfwl_edit.h" +#include "xfa/fwl/cfwl_notedriver.h" + +CXFA_FFPasswordEdit::CXFA_FFPasswordEdit(CXFA_WidgetAcc* pDataAcc) + : CXFA_FFTextEdit(pDataAcc) {} + +CXFA_FFPasswordEdit::~CXFA_FFPasswordEdit() {} + +bool CXFA_FFPasswordEdit::LoadWidget() { + auto pNewEdit = pdfium::MakeUnique<CFWL_Edit>( + GetFWLApp(), pdfium::MakeUnique<CFWL_WidgetProperties>(), nullptr); + CFWL_Edit* pWidget = pNewEdit.get(); + m_pNormalWidget = std::move(pNewEdit); + m_pNormalWidget->SetLayoutItem(this); + + CFWL_NoteDriver* pNoteDriver = + m_pNormalWidget->GetOwnerApp()->GetNoteDriver(); + pNoteDriver->RegisterEventTarget(m_pNormalWidget.get(), + m_pNormalWidget.get()); + m_pOldDelegate = m_pNormalWidget->GetDelegate(); + m_pNormalWidget->SetDelegate(this); + m_pNormalWidget->LockUpdate(); + + CFX_WideString wsText; + m_pDataAcc->GetValue(wsText, XFA_VALUEPICTURE_Display); + pWidget->SetText(wsText); + UpdateWidgetProperty(); + m_pNormalWidget->UnlockUpdate(); + return CXFA_FFField::LoadWidget(); +} + +void CXFA_FFPasswordEdit::UpdateWidgetProperty() { + CFWL_Edit* pWidget = static_cast<CFWL_Edit*>(m_pNormalWidget.get()); + if (!pWidget) + return; + + uint32_t dwExtendedStyle = + FWL_STYLEEXT_EDT_ShowScrollbarFocus | FWL_STYLEEXT_EDT_OuterScrollbar | + FWL_STYLEEXT_EDT_Password | FWL_STYLEEXT_EDT_LastLineHeight; + dwExtendedStyle |= UpdateUIProperty(); + + CFX_WideString wsPassWord; + m_pDataAcc->GetPasswordChar(wsPassWord); + if (!wsPassWord.IsEmpty()) + pWidget->SetAliasChar(wsPassWord.GetAt(0)); + if (m_pDataAcc->GetHorizontalScrollPolicy() != XFA_ATTRIBUTEENUM_Off) + dwExtendedStyle |= FWL_STYLEEXT_EDT_AutoHScroll; + if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open || + !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) { + dwExtendedStyle |= FWL_STYLEEXT_EDT_ReadOnly; + } + dwExtendedStyle |= GetAlignment(); + m_pNormalWidget->ModifyStylesEx(dwExtendedStyle, 0xFFFFFFFF); +} diff --git a/xfa/fxfa/app/cxfa_ffpasswordedit.h b/xfa/fxfa/app/cxfa_ffpasswordedit.h new file mode 100644 index 0000000000..5d292d4df3 --- /dev/null +++ b/xfa/fxfa/app/cxfa_ffpasswordedit.h @@ -0,0 +1,24 @@ +// Copyright 2017 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#ifndef XFA_FXFA_APP_CXFA_FFPASSWORDEDIT_H_ +#define XFA_FXFA_APP_CXFA_FFPASSWORDEDIT_H_ + +#include "xfa/fxfa/app/cxfa_fftextedit.h" + +class CXFA_WidgetAcc; + +class CXFA_FFPasswordEdit : public CXFA_FFTextEdit { + public: + explicit CXFA_FFPasswordEdit(CXFA_WidgetAcc* pDataAcc); + ~CXFA_FFPasswordEdit() override; + + // CXFA_FFTextEdit + bool LoadWidget() override; + void UpdateWidgetProperty() override; +}; + +#endif // XFA_FXFA_APP_CXFA_FFPASSWORDEDIT_H_ diff --git a/xfa/fxfa/app/xfa_ffpushbutton.cpp b/xfa/fxfa/app/cxfa_ffpushbutton.cpp index b596996b6c..1e784a496e 100644 --- a/xfa/fxfa/app/xfa_ffpushbutton.cpp +++ b/xfa/fxfa/app/cxfa_ffpushbutton.cpp @@ -4,7 +4,7 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#include "xfa/fxfa/app/xfa_ffpushbutton.h" +#include "xfa/fxfa/app/cxfa_ffpushbutton.h" #include <utility> @@ -12,9 +12,9 @@ #include "xfa/fwl/cfwl_notedriver.h" #include "xfa/fwl/cfwl_pushbutton.h" #include "xfa/fwl/cfwl_widgetmgr.h" +#include "xfa/fxfa/app/cxfa_fffield.h" #include "xfa/fxfa/app/cxfa_textlayout.h" -#include "xfa/fxfa/app/xfa_fffield.h" -#include "xfa/fxfa/app/xfa_ffwidgetacc.h" +#include "xfa/fxfa/app/cxfa_textprovider.h" #include "xfa/fxfa/cxfa_ffapp.h" #include "xfa/fxfa/cxfa_ffpageview.h" #include "xfa/fxfa/cxfa_ffwidget.h" diff --git a/xfa/fxfa/app/xfa_ffpushbutton.h b/xfa/fxfa/app/cxfa_ffpushbutton.h index 3695fc4e1b..797d92d970 100644 --- a/xfa/fxfa/app/xfa_ffpushbutton.h +++ b/xfa/fxfa/app/cxfa_ffpushbutton.h @@ -4,12 +4,12 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#ifndef XFA_FXFA_APP_XFA_FFPUSHBUTTON_H_ -#define XFA_FXFA_APP_XFA_FFPUSHBUTTON_H_ +#ifndef XFA_FXFA_APP_CXFA_FFPUSHBUTTON_H_ +#define XFA_FXFA_APP_CXFA_FFPUSHBUTTON_H_ #include <memory> -#include "xfa/fxfa/app/xfa_fffield.h" +#include "xfa/fxfa/app/cxfa_fffield.h" #define XFA_FWL_PSBSTYLEEXT_HiliteNone (0L << 0) #define XFA_FWL_PSBSTYLEEXT_HiliteInverted (1L << 0) @@ -51,4 +51,4 @@ class CXFA_FFPushButton : public CXFA_FFField { IFWL_WidgetDelegate* m_pOldDelegate; }; -#endif // XFA_FXFA_APP_XFA_FFPUSHBUTTON_H_ +#endif // XFA_FXFA_APP_CXFA_FFPUSHBUTTON_H_ diff --git a/xfa/fxfa/app/cxfa_ffrectangle.cpp b/xfa/fxfa/app/cxfa_ffrectangle.cpp new file mode 100644 index 0000000000..bccf7404f2 --- /dev/null +++ b/xfa/fxfa/app/cxfa_ffrectangle.cpp @@ -0,0 +1,34 @@ +// Copyright 2017 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#include "xfa/fxfa/app/cxfa_ffrectangle.h" + +CXFA_FFRectangle::CXFA_FFRectangle(CXFA_WidgetAcc* pDataAcc) + : CXFA_FFDraw(pDataAcc) {} + +CXFA_FFRectangle::~CXFA_FFRectangle() {} + +void CXFA_FFRectangle::RenderWidget(CFX_Graphics* pGS, + CFX_Matrix* pMatrix, + uint32_t dwStatus) { + if (!IsMatchVisibleStatus(dwStatus)) + return; + + CXFA_Value value = m_pDataAcc->GetFormValue(); + if (!value) + return; + + CXFA_Rectangle rtObj = value.GetRectangle(); + CFX_RectF rect = GetRectWithoutRotate(); + if (CXFA_Margin mgWidget = m_pDataAcc->GetMargin()) + XFA_RectWidthoutMargin(rect, mgWidget); + + CFX_Matrix mtRotate = GetRotateMatrix(); + if (pMatrix) + mtRotate.Concat(*pMatrix); + + DrawBorder(pGS, rtObj, rect, &mtRotate); +} diff --git a/xfa/fxfa/app/cxfa_ffrectangle.h b/xfa/fxfa/app/cxfa_ffrectangle.h new file mode 100644 index 0000000000..499f60007e --- /dev/null +++ b/xfa/fxfa/app/cxfa_ffrectangle.h @@ -0,0 +1,23 @@ +// Copyright 2017 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#ifndef XFA_FXFA_APP_CXFA_FFRECTANGLE_H_ +#define XFA_FXFA_APP_CXFA_FFRECTANGLE_H_ + +#include "xfa/fxfa/app/cxfa_ffdraw.h" + +class CXFA_FFRectangle : public CXFA_FFDraw { + public: + explicit CXFA_FFRectangle(CXFA_WidgetAcc* pDataAcc); + ~CXFA_FFRectangle() override; + + // CXFA_FFWidget + void RenderWidget(CFX_Graphics* pGS, + CFX_Matrix* pMatrix, + uint32_t dwStatus) override; +}; + +#endif // XFA_FXFA_APP_CXFA_FFRECTANGLE_H_ diff --git a/xfa/fxfa/app/xfa_ffsignature.cpp b/xfa/fxfa/app/cxfa_ffsignature.cpp index edc34336c6..a5d33ad51c 100644 --- a/xfa/fxfa/app/xfa_ffsignature.cpp +++ b/xfa/fxfa/app/cxfa_ffsignature.cpp @@ -4,9 +4,9 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#include "xfa/fxfa/app/xfa_ffsignature.h" +#include "xfa/fxfa/app/cxfa_ffsignature.h" -#include "xfa/fxfa/app/xfa_fffield.h" +#include "xfa/fxfa/app/cxfa_fffield.h" #include "xfa/fxfa/cxfa_ffdoc.h" #include "xfa/fxfa/cxfa_ffpageview.h" #include "xfa/fxfa/cxfa_ffwidget.h" diff --git a/xfa/fxfa/app/xfa_ffsignature.h b/xfa/fxfa/app/cxfa_ffsignature.h index 934323f436..839cfaf5fc 100644 --- a/xfa/fxfa/app/xfa_ffsignature.h +++ b/xfa/fxfa/app/cxfa_ffsignature.h @@ -4,10 +4,10 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#ifndef XFA_FXFA_APP_XFA_FFSIGNATURE_H_ -#define XFA_FXFA_APP_XFA_FFSIGNATURE_H_ +#ifndef XFA_FXFA_APP_CXFA_FFSIGNATURE_H_ +#define XFA_FXFA_APP_CXFA_FFSIGNATURE_H_ -#include "xfa/fxfa/app/xfa_fffield.h" +#include "xfa/fxfa/app/cxfa_fffield.h" class CXFA_FFSignature final : public CXFA_FFField { public: @@ -39,4 +39,4 @@ class CXFA_FFSignature final : public CXFA_FFField { bool OnSetCursor(const CFX_PointF& point) override; }; -#endif // XFA_FXFA_APP_XFA_FFSIGNATURE_H_ +#endif // XFA_FXFA_APP_CXFA_FFSIGNATURE_H_ diff --git a/xfa/fxfa/app/xfa_ffsubform.cpp b/xfa/fxfa/app/cxfa_ffsubform.cpp index d008c5b4f9..80a7782917 100644 --- a/xfa/fxfa/app/xfa_ffsubform.cpp +++ b/xfa/fxfa/app/cxfa_ffsubform.cpp @@ -4,7 +4,7 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#include "xfa/fxfa/app/xfa_ffsubform.h" +#include "xfa/fxfa/app/cxfa_ffsubform.h" #include "xfa/fxfa/cxfa_ffapp.h" #include "xfa/fxfa/cxfa_ffdoc.h" diff --git a/xfa/fxfa/app/xfa_ffsubform.h b/xfa/fxfa/app/cxfa_ffsubform.h index c87688fdce..d73e53de97 100644 --- a/xfa/fxfa/app/xfa_ffsubform.h +++ b/xfa/fxfa/app/cxfa_ffsubform.h @@ -4,8 +4,8 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#ifndef XFA_FXFA_APP_XFA_FFSUBFORM_H_ -#define XFA_FXFA_APP_XFA_FFSUBFORM_H_ +#ifndef XFA_FXFA_APP_CXFA_FFSUBFORM_H_ +#define XFA_FXFA_APP_CXFA_FFSUBFORM_H_ #include "xfa/fxfa/cxfa_ffpageview.h" #include "xfa/fxfa/cxfa_ffwidget.h" @@ -16,4 +16,4 @@ class CXFA_FFSubForm : public CXFA_FFWidget { ~CXFA_FFSubForm() override; }; -#endif // XFA_FXFA_APP_XFA_FFSUBFORM_H_ +#endif // XFA_FXFA_APP_CXFA_FFSUBFORM_H_ diff --git a/xfa/fxfa/app/xfa_fftext.cpp b/xfa/fxfa/app/cxfa_fftext.cpp index 89d77c3eaf..b5224eaaed 100644 --- a/xfa/fxfa/app/xfa_fftext.cpp +++ b/xfa/fxfa/app/cxfa_fftext.cpp @@ -4,15 +4,15 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#include "xfa/fxfa/app/xfa_fftext.h" +#include "xfa/fxfa/app/cxfa_fftext.h" #include "xfa/fwl/fwl_widgetdef.h" #include "xfa/fwl/fwl_widgethit.h" +#include "xfa/fxfa/app/cxfa_ffdraw.h" #include "xfa/fxfa/app/cxfa_linkuserdata.h" #include "xfa/fxfa/app/cxfa_pieceline.h" #include "xfa/fxfa/app/cxfa_textlayout.h" -#include "xfa/fxfa/app/xfa_ffdraw.h" -#include "xfa/fxfa/app/xfa_textpiece.h" +#include "xfa/fxfa/app/cxfa_textpiece.h" #include "xfa/fxfa/cxfa_ffapp.h" #include "xfa/fxfa/cxfa_ffdoc.h" #include "xfa/fxfa/cxfa_ffpageview.h" diff --git a/xfa/fxfa/app/xfa_fftext.h b/xfa/fxfa/app/cxfa_fftext.h index eddc1224ac..3fd48da2a9 100644 --- a/xfa/fxfa/app/xfa_fftext.h +++ b/xfa/fxfa/app/cxfa_fftext.h @@ -4,10 +4,10 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#ifndef XFA_FXFA_APP_XFA_FFTEXT_H_ -#define XFA_FXFA_APP_XFA_FFTEXT_H_ +#ifndef XFA_FXFA_APP_CXFA_FFTEXT_H_ +#define XFA_FXFA_APP_CXFA_FFTEXT_H_ -#include "xfa/fxfa/app/xfa_ffdraw.h" +#include "xfa/fxfa/app/cxfa_ffdraw.h" class CXFA_FFText : public CXFA_FFDraw { public: @@ -29,4 +29,4 @@ class CXFA_FFText : public CXFA_FFDraw { const wchar_t* GetLinkURLAtPoint(const CFX_PointF& point); }; -#endif // XFA_FXFA_APP_XFA_FFTEXT_H_ +#endif // XFA_FXFA_APP_CXFA_FFTEXT_H_ diff --git a/xfa/fxfa/app/cxfa_fftextedit.cpp b/xfa/fxfa/app/cxfa_fftextedit.cpp new file mode 100644 index 0000000000..b61d4ab125 --- /dev/null +++ b/xfa/fxfa/app/cxfa_fftextedit.cpp @@ -0,0 +1,364 @@ +// Copyright 2017 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#include "xfa/fxfa/app/cxfa_fftextedit.h" + +#include <utility> + +#include "xfa/fwl/cfwl_datetimepicker.h" +#include "xfa/fwl/cfwl_edit.h" +#include "xfa/fwl/cfwl_eventcheckword.h" +#include "xfa/fwl/cfwl_eventtarget.h" +#include "xfa/fwl/cfwl_eventtextchanged.h" +#include "xfa/fwl/cfwl_messagekillfocus.h" +#include "xfa/fwl/cfwl_messagesetfocus.h" +#include "xfa/fwl/cfwl_notedriver.h" +#include "xfa/fxfa/cxfa_eventparam.h" +#include "xfa/fxfa/cxfa_ffapp.h" +#include "xfa/fxfa/parser/cxfa_node.h" + +CXFA_FFTextEdit::CXFA_FFTextEdit(CXFA_WidgetAcc* pDataAcc) + : CXFA_FFField(pDataAcc), m_pOldDelegate(nullptr) {} + +CXFA_FFTextEdit::~CXFA_FFTextEdit() { + if (m_pNormalWidget) { + CFWL_NoteDriver* pNoteDriver = + m_pNormalWidget->GetOwnerApp()->GetNoteDriver(); + pNoteDriver->UnregisterEventTarget(m_pNormalWidget.get()); + } +} + +bool CXFA_FFTextEdit::LoadWidget() { + auto pNewWidget = pdfium::MakeUnique<CFWL_Edit>( + GetFWLApp(), pdfium::MakeUnique<CFWL_WidgetProperties>(), nullptr); + CFWL_Edit* pFWLEdit = pNewWidget.get(); + m_pNormalWidget = std::move(pNewWidget); + m_pNormalWidget->SetLayoutItem(this); + + CFWL_NoteDriver* pNoteDriver = + m_pNormalWidget->GetOwnerApp()->GetNoteDriver(); + pNoteDriver->RegisterEventTarget(m_pNormalWidget.get(), + m_pNormalWidget.get()); + m_pOldDelegate = m_pNormalWidget->GetDelegate(); + m_pNormalWidget->SetDelegate(this); + m_pNormalWidget->LockUpdate(); + UpdateWidgetProperty(); + + CFX_WideString wsText; + m_pDataAcc->GetValue(wsText, XFA_VALUEPICTURE_Display); + pFWLEdit->SetText(wsText); + m_pNormalWidget->UnlockUpdate(); + return CXFA_FFField::LoadWidget(); +} + +void CXFA_FFTextEdit::UpdateWidgetProperty() { + CFWL_Edit* pWidget = static_cast<CFWL_Edit*>(m_pNormalWidget.get()); + if (!pWidget) + return; + + uint32_t dwStyle = 0; + uint32_t dwExtendedStyle = FWL_STYLEEXT_EDT_ShowScrollbarFocus | + FWL_STYLEEXT_EDT_OuterScrollbar | + FWL_STYLEEXT_EDT_LastLineHeight; + dwExtendedStyle |= UpdateUIProperty(); + if (m_pDataAcc->IsMultiLine()) { + dwExtendedStyle |= FWL_STYLEEXT_EDT_MultiLine | FWL_STYLEEXT_EDT_WantReturn; + if (m_pDataAcc->GetVerticalScrollPolicy() != XFA_ATTRIBUTEENUM_Off) { + dwStyle |= FWL_WGTSTYLE_VScroll; + dwExtendedStyle |= FWL_STYLEEXT_EDT_AutoVScroll; + } + } else if (m_pDataAcc->GetHorizontalScrollPolicy() != XFA_ATTRIBUTEENUM_Off) { + dwExtendedStyle |= FWL_STYLEEXT_EDT_AutoHScroll; + } + if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open || + !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) { + dwExtendedStyle |= FWL_STYLEEXT_EDT_ReadOnly; + dwExtendedStyle |= FWL_STYLEEXT_EDT_MultiLine; + } + + XFA_Element eType = XFA_Element::Unknown; + int32_t iMaxChars = m_pDataAcc->GetMaxChars(eType); + if (eType == XFA_Element::ExData) + iMaxChars = 0; + + int32_t iNumCells = m_pDataAcc->GetNumberOfCells(); + if (iNumCells == 0) { + dwExtendedStyle |= FWL_STYLEEXT_EDT_CombText; + pWidget->SetLimit(iMaxChars > 0 ? iMaxChars : 1); + } else if (iNumCells > 0) { + dwExtendedStyle |= FWL_STYLEEXT_EDT_CombText; + pWidget->SetLimit(iNumCells); + } else { + pWidget->SetLimit(iMaxChars); + } + dwExtendedStyle |= GetAlignment(); + m_pNormalWidget->ModifyStyles(dwStyle, 0xFFFFFFFF); + m_pNormalWidget->ModifyStylesEx(dwExtendedStyle, 0xFFFFFFFF); +} + +bool CXFA_FFTextEdit::OnLButtonDown(uint32_t dwFlags, const CFX_PointF& point) { + if (!PtInActiveRect(point)) + return false; + if (!IsFocused()) { + m_dwStatus |= XFA_WidgetStatus_Focused; + UpdateFWLData(); + AddInvalidateRect(); + } + + SetButtonDown(true); + CFWL_MessageMouse ms(nullptr, m_pNormalWidget.get()); + ms.m_dwCmd = FWL_MouseCommand::LeftButtonDown; + ms.m_dwFlags = dwFlags; + ms.m_pos = FWLToClient(point); + TranslateFWLMessage(&ms); + return true; +} + +bool CXFA_FFTextEdit::OnRButtonDown(uint32_t dwFlags, const CFX_PointF& point) { + if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open) + return false; + if (!PtInActiveRect(point)) + return false; + if (!IsFocused()) { + m_dwStatus |= XFA_WidgetStatus_Focused; + UpdateFWLData(); + AddInvalidateRect(); + } + + SetButtonDown(true); + CFWL_MessageMouse ms(nullptr, nullptr); + ms.m_dwCmd = FWL_MouseCommand::RightButtonDown; + ms.m_dwFlags = dwFlags; + ms.m_pos = FWLToClient(point); + TranslateFWLMessage(&ms); + return true; +} + +bool CXFA_FFTextEdit::OnRButtonUp(uint32_t dwFlags, const CFX_PointF& point) { + if (!CXFA_FFField::OnRButtonUp(dwFlags, point)) + return false; + + GetDoc()->GetDocEnvironment()->PopupMenu(this, point); + return true; +} + +bool CXFA_FFTextEdit::OnSetFocus(CXFA_FFWidget* pOldWidget) { + m_dwStatus &= ~XFA_WidgetStatus_TextEditValueChanged; + if (!IsFocused()) { + m_dwStatus |= XFA_WidgetStatus_Focused; + UpdateFWLData(); + AddInvalidateRect(); + } + CXFA_FFWidget::OnSetFocus(pOldWidget); + CFWL_MessageSetFocus ms(nullptr, m_pNormalWidget.get()); + TranslateFWLMessage(&ms); + return true; +} + +bool CXFA_FFTextEdit::OnKillFocus(CXFA_FFWidget* pNewWidget) { + CFWL_MessageKillFocus ms(nullptr, m_pNormalWidget.get()); + TranslateFWLMessage(&ms); + m_dwStatus &= ~XFA_WidgetStatus_Focused; + + SetEditScrollOffset(); + ProcessCommittedData(); + UpdateFWLData(); + AddInvalidateRect(); + CXFA_FFWidget::OnKillFocus(pNewWidget); + + m_dwStatus &= ~XFA_WidgetStatus_TextEditValueChanged; + return true; +} + +bool CXFA_FFTextEdit::CommitData() { + CFX_WideString wsText = + static_cast<CFWL_Edit*>(m_pNormalWidget.get())->GetText(); + if (m_pDataAcc->SetValue(wsText, XFA_VALUEPICTURE_Edit)) { + m_pDataAcc->UpdateUIDisplay(this); + return true; + } + ValidateNumberField(wsText); + return false; +} + +void CXFA_FFTextEdit::ValidateNumberField(const CFX_WideString& wsText) { + CXFA_WidgetAcc* pAcc = GetDataAcc(); + if (!pAcc || pAcc->GetUIType() != XFA_Element::NumericEdit) + return; + + IXFA_AppProvider* pAppProvider = GetApp()->GetAppProvider(); + if (!pAppProvider) + return; + + CFX_WideString wsSomField; + pAcc->GetNode()->GetSOMExpression(wsSomField); + + CFX_WideString wsMessage; + wsMessage.Format(L"%s can not contain %s", wsText.c_str(), + wsSomField.c_str()); + pAppProvider->MsgBox(wsMessage, pAppProvider->GetAppTitle(), XFA_MBICON_Error, + XFA_MB_OK); +} + +bool CXFA_FFTextEdit::IsDataChanged() { + return (m_dwStatus & XFA_WidgetStatus_TextEditValueChanged) != 0; +} + +uint32_t CXFA_FFTextEdit::GetAlignment() { + CXFA_Para para = m_pDataAcc->GetPara(); + if (!para) + return 0; + + uint32_t dwExtendedStyle = 0; + switch (para.GetHorizontalAlign()) { + case XFA_ATTRIBUTEENUM_Center: + dwExtendedStyle |= FWL_STYLEEXT_EDT_HCenter; + break; + case XFA_ATTRIBUTEENUM_Justify: + dwExtendedStyle |= FWL_STYLEEXT_EDT_Justified; + break; + case XFA_ATTRIBUTEENUM_JustifyAll: + case XFA_ATTRIBUTEENUM_Radix: + break; + case XFA_ATTRIBUTEENUM_Right: + dwExtendedStyle |= FWL_STYLEEXT_EDT_HFar; + break; + default: + dwExtendedStyle |= FWL_STYLEEXT_EDT_HNear; + break; + } + + switch (para.GetVerticalAlign()) { + case XFA_ATTRIBUTEENUM_Middle: + dwExtendedStyle |= FWL_STYLEEXT_EDT_VCenter; + break; + case XFA_ATTRIBUTEENUM_Bottom: + dwExtendedStyle |= FWL_STYLEEXT_EDT_VFar; + break; + default: + dwExtendedStyle |= FWL_STYLEEXT_EDT_VNear; + break; + } + return dwExtendedStyle; +} + +bool CXFA_FFTextEdit::UpdateFWLData() { + if (!m_pNormalWidget) + return false; + + XFA_VALUEPICTURE eType = XFA_VALUEPICTURE_Display; + if (IsFocused()) + eType = XFA_VALUEPICTURE_Edit; + + bool bUpdate = false; + if (m_pDataAcc->GetUIType() == XFA_Element::TextEdit && + m_pDataAcc->GetNumberOfCells() < 0) { + XFA_Element elementType = XFA_Element::Unknown; + int32_t iMaxChars = m_pDataAcc->GetMaxChars(elementType); + if (elementType == XFA_Element::ExData) + iMaxChars = eType == XFA_VALUEPICTURE_Edit ? iMaxChars : 0; + if (static_cast<CFWL_Edit*>(m_pNormalWidget.get())->GetLimit() != + iMaxChars) { + static_cast<CFWL_Edit*>(m_pNormalWidget.get())->SetLimit(iMaxChars); + bUpdate = true; + } + } + + if (m_pDataAcc->GetUIType() == XFA_Element::Barcode) { + int32_t nDataLen = 0; + if (eType == XFA_VALUEPICTURE_Edit) + m_pDataAcc->GetBarcodeAttribute_DataLength(&nDataLen); + static_cast<CFWL_Edit*>(m_pNormalWidget.get())->SetLimit(nDataLen); + bUpdate = true; + } + + CFX_WideString wsText; + m_pDataAcc->GetValue(wsText, eType); + + CFX_WideString wsOldText = + static_cast<CFWL_Edit*>(m_pNormalWidget.get())->GetText(); + if (wsText != wsOldText || (eType == XFA_VALUEPICTURE_Edit && bUpdate)) { + static_cast<CFWL_Edit*>(m_pNormalWidget.get())->SetText(wsText); + bUpdate = true; + } + if (bUpdate) + m_pNormalWidget->Update(); + + return true; +} + +void CXFA_FFTextEdit::OnTextChanged(CFWL_Widget* pWidget, + const CFX_WideString& wsChanged, + const CFX_WideString& wsPrevText) { + m_dwStatus |= XFA_WidgetStatus_TextEditValueChanged; + CXFA_EventParam eParam; + eParam.m_eType = XFA_EVENT_Change; + eParam.m_wsChange = wsChanged; + eParam.m_pTarget = m_pDataAcc.Get(); + eParam.m_wsPrevText = wsPrevText; + CFWL_Edit* pEdit = static_cast<CFWL_Edit*>(m_pNormalWidget.get()); + if (m_pDataAcc->GetUIType() == XFA_Element::DateTimeEdit) { + CFWL_DateTimePicker* pDateTime = (CFWL_DateTimePicker*)pEdit; + eParam.m_wsNewText = pDateTime->GetEditText(); + int32_t iSels = pDateTime->CountSelRanges(); + if (iSels) + eParam.m_iSelEnd = pDateTime->GetSelRange(0, &eParam.m_iSelStart); + } else { + eParam.m_wsNewText = pEdit->GetText(); + int32_t iSels = pEdit->CountSelRanges(); + if (iSels) + eParam.m_iSelEnd = pEdit->GetSelRange(0, &eParam.m_iSelStart); + } + m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Change, &eParam); +} + +void CXFA_FFTextEdit::OnTextFull(CFWL_Widget* pWidget) { + CXFA_EventParam eParam; + eParam.m_eType = XFA_EVENT_Full; + eParam.m_pTarget = m_pDataAcc.Get(); + m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Full, &eParam); +} + +bool CXFA_FFTextEdit::CheckWord(const CFX_ByteStringC& sWord) { + if (sWord.IsEmpty() || m_pDataAcc->GetUIType() != XFA_Element::TextEdit) + return true; + return false; +} + +void CXFA_FFTextEdit::OnProcessMessage(CFWL_Message* pMessage) { + m_pOldDelegate->OnProcessMessage(pMessage); +} + +void CXFA_FFTextEdit::OnProcessEvent(CFWL_Event* pEvent) { + CXFA_FFField::OnProcessEvent(pEvent); + switch (pEvent->GetType()) { + case CFWL_Event::Type::TextChanged: { + CFWL_EventTextChanged* event = + static_cast<CFWL_EventTextChanged*>(pEvent); + CFX_WideString wsChange; + OnTextChanged(m_pNormalWidget.get(), wsChange, event->wsPrevText); + break; + } + case CFWL_Event::Type::TextFull: { + OnTextFull(m_pNormalWidget.get()); + break; + } + case CFWL_Event::Type::CheckWord: { + CFX_WideString wstr(L"FWL_EVENT_DTP_SelectChanged"); + CFWL_EventCheckWord* event = static_cast<CFWL_EventCheckWord*>(pEvent); + event->bCheckWord = CheckWord(event->bsWord.AsStringC()); + break; + } + default: + break; + } + m_pOldDelegate->OnProcessEvent(pEvent); +} + +void CXFA_FFTextEdit::OnDrawWidget(CFX_Graphics* pGraphics, + const CFX_Matrix* pMatrix) { + m_pOldDelegate->OnDrawWidget(pGraphics, pMatrix); +} diff --git a/xfa/fxfa/app/cxfa_fftextedit.h b/xfa/fxfa/app/cxfa_fftextedit.h new file mode 100644 index 0000000000..fa0779ed2c --- /dev/null +++ b/xfa/fxfa/app/cxfa_fftextedit.h @@ -0,0 +1,57 @@ +// Copyright 2017 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#ifndef XFA_FXFA_APP_CXFA_FFTEXTEDIT_H_ +#define XFA_FXFA_APP_CXFA_FFTEXTEDIT_H_ + +#include "core/fxcrt/fx_coordinates.h" +#include "core/fxcrt/fx_string.h" +#include "xfa/fxfa/app/cxfa_fffield.h" + +class CFWL_Event; +class CFWL_Widget; +class CFX_Matrix; +class CXFA_FFWidget; +class CXFA_WidgetAcc; +class IFWL_WidgetDelegate; + +class CXFA_FFTextEdit : public CXFA_FFField { + public: + explicit CXFA_FFTextEdit(CXFA_WidgetAcc* pDataAcc); + ~CXFA_FFTextEdit() override; + + // CXFA_FFField + bool LoadWidget() override; + void UpdateWidgetProperty() override; + bool OnLButtonDown(uint32_t dwFlags, const CFX_PointF& point) override; + bool OnRButtonDown(uint32_t dwFlags, const CFX_PointF& point) override; + bool OnRButtonUp(uint32_t dwFlags, const CFX_PointF& point) override; + bool OnSetFocus(CXFA_FFWidget* pOldWidget) override; + bool OnKillFocus(CXFA_FFWidget* pNewWidget) override; + void OnProcessMessage(CFWL_Message* pMessage) override; + void OnProcessEvent(CFWL_Event* pEvent) override; + void OnDrawWidget(CFX_Graphics* pGraphics, + const CFX_Matrix* pMatrix = nullptr) override; + + void OnTextChanged(CFWL_Widget* pWidget, + const CFX_WideString& wsChanged, + const CFX_WideString& wsPrevText); + void OnTextFull(CFWL_Widget* pWidget); + bool CheckWord(const CFX_ByteStringC& sWord); + + protected: + uint32_t GetAlignment(); + + IFWL_WidgetDelegate* m_pOldDelegate; + + private: + bool CommitData() override; + bool UpdateFWLData() override; + bool IsDataChanged() override; + void ValidateNumberField(const CFX_WideString& wsText); +}; + +#endif // XFA_FXFA_APP_CXFA_FFTEXTEDIT_H_ diff --git a/xfa/fxfa/app/xfa_fwladapter.cpp b/xfa/fxfa/app/cxfa_fwladapterwidgetmgr.cpp index 3cf6e5e8fd..42362d858a 100644 --- a/xfa/fxfa/app/xfa_fwladapter.cpp +++ b/xfa/fxfa/app/cxfa_fwladapterwidgetmgr.cpp @@ -4,9 +4,9 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#include "xfa/fxfa/app/xfa_fwladapter.h" +#include "xfa/fxfa/app/cxfa_fwladapterwidgetmgr.h" -#include "xfa/fxfa/app/xfa_fffield.h" +#include "xfa/fxfa/app/cxfa_fffield.h" #include "xfa/fxfa/cxfa_ffdoc.h" CXFA_FWLAdapterWidgetMgr::CXFA_FWLAdapterWidgetMgr() {} diff --git a/xfa/fxfa/app/xfa_fwladapter.h b/xfa/fxfa/app/cxfa_fwladapterwidgetmgr.h index b4a3481588..f9126eac3f 100644 --- a/xfa/fxfa/app/xfa_fwladapter.h +++ b/xfa/fxfa/app/cxfa_fwladapterwidgetmgr.h @@ -4,8 +4,8 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#ifndef XFA_FXFA_APP_XFA_FWLADAPTER_H_ -#define XFA_FXFA_APP_XFA_FWLADAPTER_H_ +#ifndef XFA_FXFA_APP_CXFA_FWLADAPTERWIDGETMGR_H_ +#define XFA_FXFA_APP_CXFA_FWLADAPTERWIDGETMGR_H_ #include "core/fxcrt/fx_coordinates.h" #include "core/fxcrt/fx_system.h" @@ -25,4 +25,4 @@ class CXFA_FWLAdapterWidgetMgr { CFX_RectF& rtPopup); }; -#endif // XFA_FXFA_APP_XFA_FWLADAPTER_H_ +#endif // XFA_FXFA_APP_CXFA_FWLADAPTERWIDGETMGR_H_ diff --git a/xfa/fxfa/app/xfa_fwltheme.cpp b/xfa/fxfa/app/cxfa_fwltheme.cpp index 9af45e62df..5f8e1dc7dc 100644 --- a/xfa/fxfa/app/xfa_fwltheme.cpp +++ b/xfa/fxfa/app/cxfa_fwltheme.cpp @@ -4,7 +4,7 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#include "xfa/fxfa/app/xfa_fwltheme.h" +#include "xfa/fxfa/app/cxfa_fwltheme.h" #include "core/fxcrt/fx_codepage.h" #include "xfa/fde/cfde_textout.h" diff --git a/xfa/fxfa/app/xfa_fwltheme.h b/xfa/fxfa/app/cxfa_fwltheme.h index 7563c69ed9..eaca99082d 100644 --- a/xfa/fxfa/app/xfa_fwltheme.h +++ b/xfa/fxfa/app/cxfa_fwltheme.h @@ -4,8 +4,8 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#ifndef XFA_FXFA_APP_XFA_FWLTHEME_H_ -#define XFA_FXFA_APP_XFA_FWLTHEME_H_ +#ifndef XFA_FXFA_APP_CXFA_FWLTHEME_H_ +#define XFA_FXFA_APP_CXFA_FWLTHEME_H_ #include <memory> @@ -67,4 +67,4 @@ class CXFA_FWLTheme final : public IFWL_ThemeProvider { CXFA_FFWidget* XFA_ThemeGetOuterWidget(CFWL_Widget* pWidget); -#endif // XFA_FXFA_APP_XFA_FWLTHEME_H_ +#endif // XFA_FXFA_APP_CXFA_FWLTHEME_H_ diff --git a/xfa/fxfa/app/cxfa_pieceline.cpp b/xfa/fxfa/app/cxfa_pieceline.cpp index b906cf26e3..2e1ea55f1c 100644 --- a/xfa/fxfa/app/cxfa_pieceline.cpp +++ b/xfa/fxfa/app/cxfa_pieceline.cpp @@ -6,7 +6,7 @@ #include "xfa/fxfa/app/cxfa_pieceline.h" -#include "xfa/fxfa/app/xfa_textpiece.h" +#include "xfa/fxfa/app/cxfa_textpiece.h" CXFA_PieceLine::CXFA_PieceLine() {} diff --git a/xfa/fxfa/app/cxfa_pieceline.h b/xfa/fxfa/app/cxfa_pieceline.h index 87f71fc192..6b17ebfb11 100644 --- a/xfa/fxfa/app/cxfa_pieceline.h +++ b/xfa/fxfa/app/cxfa_pieceline.h @@ -12,14 +12,14 @@ #include "core/fxcrt/fx_basic.h" -class XFA_TextPiece; +class CXFA_TextPiece; class CXFA_PieceLine { public: CXFA_PieceLine(); ~CXFA_PieceLine(); - std::vector<std::unique_ptr<XFA_TextPiece>> m_textPieces; + std::vector<std::unique_ptr<CXFA_TextPiece>> m_textPieces; std::vector<int32_t> m_charCounts; }; diff --git a/xfa/fxfa/app/cxfa_textlayout.cpp b/xfa/fxfa/app/cxfa_textlayout.cpp index c43f7e3260..489df9ab9c 100644 --- a/xfa/fxfa/app/cxfa_textlayout.cpp +++ b/xfa/fxfa/app/cxfa_textlayout.cpp @@ -24,10 +24,10 @@ #include "xfa/fxfa/app/cxfa_loadercontext.h" #include "xfa/fxfa/app/cxfa_pieceline.h" #include "xfa/fxfa/app/cxfa_textparsecontext.h" +#include "xfa/fxfa/app/cxfa_textpiece.h" +#include "xfa/fxfa/app/cxfa_textprovider.h" #include "xfa/fxfa/app/cxfa_texttabstopscontext.h" #include "xfa/fxfa/app/cxfa_textuserdata.h" -#include "xfa/fxfa/app/xfa_ffwidgetacc.h" -#include "xfa/fxfa/app/xfa_textpiece.h" #include "xfa/fxfa/parser/cxfa_font.h" #include "xfa/fxfa/parser/cxfa_node.h" #include "xfa/fxfa/parser/cxfa_para.h" @@ -594,7 +594,7 @@ bool CXFA_TextLayout::DrawString(CFX_RenderDevice* pFxDevice, int32_t iPieces = pdfium::CollectionSize<int32_t>(pPieceLine->m_textPieces); int32_t j = 0; for (j = 0; j < iPieces; j++) { - const XFA_TextPiece* pPiece = pPieceLine->m_textPieces[j].get(); + const CXFA_TextPiece* pPiece = pPieceLine->m_textPieces[j].get(); int32_t iChars = pPiece->iChars; if (iCharCount < iChars) { FX_Free(pCharPos); @@ -964,7 +964,7 @@ void CXFA_TextLayout::DoTabstops(CFDE_CSSComputedStyle* pStyle, if (iPieces == 0) return; - XFA_TextPiece* pPiece = pPieceLine->m_textPieces[iPieces - 1].get(); + CXFA_TextPiece* pPiece = pPieceLine->m_textPieces[iPieces - 1].get(); int32_t& iTabstopsIndex = m_pTabstopContext->m_iTabIndex; int32_t iCount = m_textParser.CountTabs(pStyle); if (!pdfium::IndexInBounds(m_pTabstopContext->m_tabstops, iTabstopsIndex)) @@ -975,7 +975,7 @@ void CXFA_TextLayout::DoTabstops(CFDE_CSSComputedStyle* pStyle, m_pTabstopContext->m_bTabstops = true; float fRight = 0; if (iPieces > 1) { - XFA_TextPiece* p = pPieceLine->m_textPieces[iPieces - 2].get(); + CXFA_TextPiece* p = pPieceLine->m_textPieces[iPieces - 2].get(); fRight = p->rtPiece.right(); } m_pTabstopContext->m_fTabWidth = @@ -1032,7 +1032,7 @@ void CXFA_TextLayout::AppendTextLine(CFX_BreakType dwStatus, pStyle = pUserData->m_pStyle; float fVerScale = pPiece->m_iVerticalScale / 100.0f; - auto pTP = pdfium::MakeUnique<XFA_TextPiece>(); + auto pTP = pdfium::MakeUnique<CXFA_TextPiece>(); pTP->iChars = pPiece->m_iChars; pTP->szText = pPiece->GetString(); pTP->Widths = pPiece->GetWidths(); @@ -1149,7 +1149,7 @@ void CXFA_TextLayout::RenderString(CFDE_RenderDevice* pDevice, int32_t iPiece, FXTEXT_CHARPOS* pCharPos, const CFX_Matrix& tmDoc2Device) { - const XFA_TextPiece* pPiece = pPieceLine->m_textPieces[iPiece].get(); + const CXFA_TextPiece* pPiece = pPieceLine->m_textPieces[iPiece].get(); int32_t iCount = GetDisplayPos(pPiece, pCharPos); if (iCount > 0) { pBrush->SetColor(pPiece->dwColor); @@ -1165,7 +1165,7 @@ void CXFA_TextLayout::RenderPath(CFDE_RenderDevice* pDevice, int32_t iPiece, FXTEXT_CHARPOS* pCharPos, const CFX_Matrix& tmDoc2Device) { - XFA_TextPiece* pPiece = pPieceLine->m_textPieces[iPiece].get(); + CXFA_TextPiece* pPiece = pPieceLine->m_textPieces[iPiece].get(); bool bNoUnderline = pPiece->iUnderline < 1 || pPiece->iUnderline > 2; bool bNoLineThrough = pPiece->iLineThrough < 1 || pPiece->iLineThrough > 2; if (bNoUnderline && bNoLineThrough) @@ -1273,7 +1273,7 @@ void CXFA_TextLayout::RenderPath(CFDE_RenderDevice* pDevice, pDevice->DrawPath(pPen, 1, pPath.get(), &tmDoc2Device); } -int32_t CXFA_TextLayout::GetDisplayPos(const XFA_TextPiece* pPiece, +int32_t CXFA_TextLayout::GetDisplayPos(const CXFA_TextPiece* pPiece, FXTEXT_CHARPOS* pCharPos, bool bCharCode) { if (!pPiece) @@ -1285,7 +1285,7 @@ int32_t CXFA_TextLayout::GetDisplayPos(const XFA_TextPiece* pPiece, return m_pBreak->GetDisplayPos(&tr, pCharPos, bCharCode); } -bool CXFA_TextLayout::ToRun(const XFA_TextPiece* pPiece, FX_RTFTEXTOBJ* tr) { +bool CXFA_TextLayout::ToRun(const CXFA_TextPiece* pPiece, FX_RTFTEXTOBJ* tr) { int32_t iLength = pPiece->iChars; if (iLength < 1) return false; diff --git a/xfa/fxfa/app/cxfa_textlayout.h b/xfa/fxfa/app/cxfa_textlayout.h index 75c2d56324..e8c203fcc1 100644 --- a/xfa/fxfa/app/cxfa_textlayout.h +++ b/xfa/fxfa/app/cxfa_textlayout.h @@ -29,7 +29,7 @@ class CXFA_Node; class CXFA_PieceLine; class CXFA_TextProvider; class CXFA_TextTabstopsContext; -class XFA_TextPiece; +class CXFA_TextPiece; class CXFA_TextLayout { public: @@ -112,10 +112,10 @@ class CXFA_TextLayout { int32_t iPiece, FXTEXT_CHARPOS* pCharPos, const CFX_Matrix& tmDoc2Device); - int32_t GetDisplayPos(const XFA_TextPiece* pPiece, + int32_t GetDisplayPos(const CXFA_TextPiece* pPiece, FXTEXT_CHARPOS* pCharPos, bool bCharCode = false); - bool ToRun(const XFA_TextPiece* pPiece, FX_RTFTEXTOBJ* tr); + bool ToRun(const CXFA_TextPiece* pPiece, FX_RTFTEXTOBJ* tr); void DoTabstops(CFDE_CSSComputedStyle* pStyle, CXFA_PieceLine* pPieceLine); bool Layout(int32_t iBlock); int32_t CountBlocks() const; diff --git a/xfa/fxfa/app/cxfa_textparser.cpp b/xfa/fxfa/app/cxfa_textparser.cpp index 33bd2b9deb..8bdb0a8372 100644 --- a/xfa/fxfa/app/cxfa_textparser.cpp +++ b/xfa/fxfa/app/cxfa_textparser.cpp @@ -21,8 +21,8 @@ #include "xfa/fgas/font/cfgas_fontmgr.h" #include "xfa/fxfa/app/cxfa_csstagprovider.h" #include "xfa/fxfa/app/cxfa_textparsecontext.h" +#include "xfa/fxfa/app/cxfa_textprovider.h" #include "xfa/fxfa/app/cxfa_texttabstopscontext.h" -#include "xfa/fxfa/app/xfa_ffwidgetacc.h" #include "xfa/fxfa/cxfa_ffapp.h" #include "xfa/fxfa/cxfa_ffdoc.h" #include "xfa/fxfa/cxfa_fontmgr.h" diff --git a/xfa/fxfa/app/xfa_textpiece.cpp b/xfa/fxfa/app/cxfa_textpiece.cpp index c53e45f91a..4cbad0a475 100644 --- a/xfa/fxfa/app/xfa_textpiece.cpp +++ b/xfa/fxfa/app/cxfa_textpiece.cpp @@ -4,10 +4,10 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#include "xfa/fxfa/app/xfa_textpiece.h" +#include "xfa/fxfa/app/cxfa_textpiece.h" #include "xfa/fxfa/app/cxfa_linkuserdata.h" -XFA_TextPiece::XFA_TextPiece() {} +CXFA_TextPiece::CXFA_TextPiece() {} -XFA_TextPiece::~XFA_TextPiece() {} +CXFA_TextPiece::~CXFA_TextPiece() {} diff --git a/xfa/fxfa/app/xfa_textpiece.h b/xfa/fxfa/app/cxfa_textpiece.h index fd1f3bdbaa..0fba66ef52 100644 --- a/xfa/fxfa/app/xfa_textpiece.h +++ b/xfa/fxfa/app/cxfa_textpiece.h @@ -4,8 +4,8 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#ifndef XFA_FXFA_APP_XFA_TEXTPIECE_H_ -#define XFA_FXFA_APP_XFA_TEXTPIECE_H_ +#ifndef XFA_FXFA_APP_CXFA_TEXTPIECE_H_ +#define XFA_FXFA_APP_CXFA_TEXTPIECE_H_ #include <vector> @@ -17,10 +17,10 @@ class CXFA_LinkUserData; -class XFA_TextPiece { +class CXFA_TextPiece { public: - XFA_TextPiece(); - ~XFA_TextPiece(); + CXFA_TextPiece(); + ~CXFA_TextPiece(); CFX_WideString szText; std::vector<int32_t> Widths; @@ -38,4 +38,4 @@ class XFA_TextPiece { CFX_RetainPtr<CXFA_LinkUserData> pLinkData; }; -#endif // XFA_FXFA_APP_XFA_TEXTPIECE_H_ +#endif // XFA_FXFA_APP_CXFA_TEXTPIECE_H_ diff --git a/xfa/fxfa/app/xfa_ffwidgetacc.cpp b/xfa/fxfa/app/cxfa_textprovider.cpp index 2ac27cfdc8..01bc021f8c 100644 --- a/xfa/fxfa/app/xfa_ffwidgetacc.cpp +++ b/xfa/fxfa/app/cxfa_textprovider.cpp @@ -4,7 +4,7 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#include "xfa/fxfa/app/xfa_ffwidgetacc.h" +#include "xfa/fxfa/app/cxfa_textprovider.h" #include <algorithm> #include <memory> @@ -16,10 +16,9 @@ #include "third_party/base/ptr_util.h" #include "third_party/base/stl_util.h" #include "xfa/fde/cfde_textout.h" -#include "xfa/fxfa/app/xfa_ffcheckbutton.h" -#include "xfa/fxfa/app/xfa_ffchoicelist.h" -#include "xfa/fxfa/app/xfa_fffield.h" -#include "xfa/fxfa/app/xfa_fwladapter.h" +#include "xfa/fxfa/app/cxfa_ffcheckbutton.h" +#include "xfa/fxfa/app/cxfa_fffield.h" +#include "xfa/fxfa/app/cxfa_fwladapterwidgetmgr.h" #include "xfa/fxfa/cxfa_eventparam.h" #include "xfa/fxfa/cxfa_ffapp.h" #include "xfa/fxfa/cxfa_ffdoc.h" diff --git a/xfa/fxfa/app/xfa_ffwidgetacc.h b/xfa/fxfa/app/cxfa_textprovider.h index 7840186b14..08fc6f38e2 100644 --- a/xfa/fxfa/app/xfa_ffwidgetacc.h +++ b/xfa/fxfa/app/cxfa_textprovider.h @@ -4,8 +4,8 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#ifndef XFA_FXFA_APP_XFA_FFWIDGETACC_H_ -#define XFA_FXFA_APP_XFA_FFWIDGETACC_H_ +#ifndef XFA_FXFA_APP_CXFA_TEXTPROVIDER_H_ +#define XFA_FXFA_APP_CXFA_TEXTPROVIDER_H_ #include "core/fxcrt/fx_string.h" #include "xfa/fxfa/app/cxfa_textlayout.h" @@ -47,4 +47,4 @@ class CXFA_TextProvider { XFA_TEXTPROVIDERTYPE m_eType; }; -#endif // XFA_FXFA_APP_XFA_FFWIDGETACC_H_ +#endif // XFA_FXFA_APP_CXFA_TEXTPROVIDER_H_ diff --git a/xfa/fxfa/app/xfa_ffpath.h b/xfa/fxfa/app/xfa_ffpath.h deleted file mode 100644 index 6df53f4e1d..0000000000 --- a/xfa/fxfa/app/xfa_ffpath.h +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef XFA_FXFA_APP_XFA_FFPATH_H_ -#define XFA_FXFA_APP_XFA_FFPATH_H_ - -#include "xfa/fxfa/app/xfa_ffdraw.h" - -class CXFA_FFLine : public CXFA_FFDraw { - public: - explicit CXFA_FFLine(CXFA_WidgetAcc* pDataAcc); - ~CXFA_FFLine() override; - - // CXFA_FFWidget - void RenderWidget(CFX_Graphics* pGS, - CFX_Matrix* pMatrix, - uint32_t dwStatus) override; - - private: - void GetRectFromHand(CFX_RectF& rect, int32_t iHand, float fLineWidth); -}; - -class CXFA_FFArc : public CXFA_FFDraw { - public: - explicit CXFA_FFArc(CXFA_WidgetAcc* pDataAcc); - ~CXFA_FFArc() override; - - // CXFA_FFWidget - void RenderWidget(CFX_Graphics* pGS, - CFX_Matrix* pMatrix, - uint32_t dwStatus) override; -}; - -class CXFA_FFRectangle : public CXFA_FFDraw { - public: - explicit CXFA_FFRectangle(CXFA_WidgetAcc* pDataAcc); - ~CXFA_FFRectangle() override; - - // CXFA_FFWidget - void RenderWidget(CFX_Graphics* pGS, - CFX_Matrix* pMatrix, - uint32_t dwStatus) override; -}; - -#endif // XFA_FXFA_APP_XFA_FFPATH_H_ diff --git a/xfa/fxfa/app/xfa_fftextedit.cpp b/xfa/fxfa/app/xfa_fftextedit.cpp deleted file mode 100644 index 41305efcc8..0000000000 --- a/xfa/fxfa/app/xfa_fftextedit.cpp +++ /dev/null @@ -1,706 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#include "xfa/fxfa/app/xfa_fftextedit.h" - -#include <utility> -#include <vector> - -#include "xfa/fwl/cfwl_datetimepicker.h" -#include "xfa/fwl/cfwl_edit.h" -#include "xfa/fwl/cfwl_eventcheckword.h" -#include "xfa/fwl/cfwl_eventselectchanged.h" -#include "xfa/fwl/cfwl_eventtextchanged.h" -#include "xfa/fwl/cfwl_eventvalidate.h" -#include "xfa/fwl/cfwl_messagekillfocus.h" -#include "xfa/fwl/cfwl_messagemouse.h" -#include "xfa/fwl/cfwl_messagesetfocus.h" -#include "xfa/fwl/cfwl_notedriver.h" -#include "xfa/fxfa/app/xfa_fffield.h" -#include "xfa/fxfa/app/xfa_fwladapter.h" -#include "xfa/fxfa/cxfa_eventparam.h" -#include "xfa/fxfa/cxfa_ffapp.h" -#include "xfa/fxfa/cxfa_ffdoc.h" -#include "xfa/fxfa/cxfa_ffdocview.h" -#include "xfa/fxfa/cxfa_ffpageview.h" -#include "xfa/fxfa/cxfa_ffwidget.h" -#include "xfa/fxfa/parser/cxfa_localevalue.h" -#include "xfa/fxfa/parser/cxfa_node.h" - -CXFA_FFTextEdit::CXFA_FFTextEdit(CXFA_WidgetAcc* pDataAcc) - : CXFA_FFField(pDataAcc), m_pOldDelegate(nullptr) {} - -CXFA_FFTextEdit::~CXFA_FFTextEdit() { - if (m_pNormalWidget) { - CFWL_NoteDriver* pNoteDriver = - m_pNormalWidget->GetOwnerApp()->GetNoteDriver(); - pNoteDriver->UnregisterEventTarget(m_pNormalWidget.get()); - } -} - -bool CXFA_FFTextEdit::LoadWidget() { - auto pNewWidget = pdfium::MakeUnique<CFWL_Edit>( - GetFWLApp(), pdfium::MakeUnique<CFWL_WidgetProperties>(), nullptr); - CFWL_Edit* pFWLEdit = pNewWidget.get(); - m_pNormalWidget = std::move(pNewWidget); - m_pNormalWidget->SetLayoutItem(this); - - CFWL_NoteDriver* pNoteDriver = - m_pNormalWidget->GetOwnerApp()->GetNoteDriver(); - pNoteDriver->RegisterEventTarget(m_pNormalWidget.get(), - m_pNormalWidget.get()); - m_pOldDelegate = m_pNormalWidget->GetDelegate(); - m_pNormalWidget->SetDelegate(this); - m_pNormalWidget->LockUpdate(); - UpdateWidgetProperty(); - - CFX_WideString wsText; - m_pDataAcc->GetValue(wsText, XFA_VALUEPICTURE_Display); - pFWLEdit->SetText(wsText); - m_pNormalWidget->UnlockUpdate(); - return CXFA_FFField::LoadWidget(); -} - -void CXFA_FFTextEdit::UpdateWidgetProperty() { - CFWL_Edit* pWidget = static_cast<CFWL_Edit*>(m_pNormalWidget.get()); - if (!pWidget) - return; - - uint32_t dwStyle = 0; - uint32_t dwExtendedStyle = FWL_STYLEEXT_EDT_ShowScrollbarFocus | - FWL_STYLEEXT_EDT_OuterScrollbar | - FWL_STYLEEXT_EDT_LastLineHeight; - dwExtendedStyle |= UpdateUIProperty(); - if (m_pDataAcc->IsMultiLine()) { - dwExtendedStyle |= FWL_STYLEEXT_EDT_MultiLine | FWL_STYLEEXT_EDT_WantReturn; - if (m_pDataAcc->GetVerticalScrollPolicy() != XFA_ATTRIBUTEENUM_Off) { - dwStyle |= FWL_WGTSTYLE_VScroll; - dwExtendedStyle |= FWL_STYLEEXT_EDT_AutoVScroll; - } - } else if (m_pDataAcc->GetHorizontalScrollPolicy() != XFA_ATTRIBUTEENUM_Off) { - dwExtendedStyle |= FWL_STYLEEXT_EDT_AutoHScroll; - } - if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open || - !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) { - dwExtendedStyle |= FWL_STYLEEXT_EDT_ReadOnly; - dwExtendedStyle |= FWL_STYLEEXT_EDT_MultiLine; - } - - XFA_Element eType = XFA_Element::Unknown; - int32_t iMaxChars = m_pDataAcc->GetMaxChars(eType); - if (eType == XFA_Element::ExData) - iMaxChars = 0; - - int32_t iNumCells = m_pDataAcc->GetNumberOfCells(); - if (iNumCells == 0) { - dwExtendedStyle |= FWL_STYLEEXT_EDT_CombText; - pWidget->SetLimit(iMaxChars > 0 ? iMaxChars : 1); - } else if (iNumCells > 0) { - dwExtendedStyle |= FWL_STYLEEXT_EDT_CombText; - pWidget->SetLimit(iNumCells); - } else { - pWidget->SetLimit(iMaxChars); - } - dwExtendedStyle |= GetAlignment(); - m_pNormalWidget->ModifyStyles(dwStyle, 0xFFFFFFFF); - m_pNormalWidget->ModifyStylesEx(dwExtendedStyle, 0xFFFFFFFF); -} - -bool CXFA_FFTextEdit::OnLButtonDown(uint32_t dwFlags, const CFX_PointF& point) { - if (!PtInActiveRect(point)) - return false; - if (!IsFocused()) { - m_dwStatus |= XFA_WidgetStatus_Focused; - UpdateFWLData(); - AddInvalidateRect(); - } - - SetButtonDown(true); - CFWL_MessageMouse ms(nullptr, m_pNormalWidget.get()); - ms.m_dwCmd = FWL_MouseCommand::LeftButtonDown; - ms.m_dwFlags = dwFlags; - ms.m_pos = FWLToClient(point); - TranslateFWLMessage(&ms); - return true; -} - -bool CXFA_FFTextEdit::OnRButtonDown(uint32_t dwFlags, const CFX_PointF& point) { - if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open) - return false; - if (!PtInActiveRect(point)) - return false; - if (!IsFocused()) { - m_dwStatus |= XFA_WidgetStatus_Focused; - UpdateFWLData(); - AddInvalidateRect(); - } - - SetButtonDown(true); - CFWL_MessageMouse ms(nullptr, nullptr); - ms.m_dwCmd = FWL_MouseCommand::RightButtonDown; - ms.m_dwFlags = dwFlags; - ms.m_pos = FWLToClient(point); - TranslateFWLMessage(&ms); - return true; -} - -bool CXFA_FFTextEdit::OnRButtonUp(uint32_t dwFlags, const CFX_PointF& point) { - if (!CXFA_FFField::OnRButtonUp(dwFlags, point)) - return false; - - GetDoc()->GetDocEnvironment()->PopupMenu(this, point); - return true; -} - -bool CXFA_FFTextEdit::OnSetFocus(CXFA_FFWidget* pOldWidget) { - m_dwStatus &= ~XFA_WidgetStatus_TextEditValueChanged; - if (!IsFocused()) { - m_dwStatus |= XFA_WidgetStatus_Focused; - UpdateFWLData(); - AddInvalidateRect(); - } - CXFA_FFWidget::OnSetFocus(pOldWidget); - CFWL_MessageSetFocus ms(nullptr, m_pNormalWidget.get()); - TranslateFWLMessage(&ms); - return true; -} - -bool CXFA_FFTextEdit::OnKillFocus(CXFA_FFWidget* pNewWidget) { - CFWL_MessageKillFocus ms(nullptr, m_pNormalWidget.get()); - TranslateFWLMessage(&ms); - m_dwStatus &= ~XFA_WidgetStatus_Focused; - - SetEditScrollOffset(); - ProcessCommittedData(); - UpdateFWLData(); - AddInvalidateRect(); - CXFA_FFWidget::OnKillFocus(pNewWidget); - - m_dwStatus &= ~XFA_WidgetStatus_TextEditValueChanged; - return true; -} - -bool CXFA_FFTextEdit::CommitData() { - CFX_WideString wsText = - static_cast<CFWL_Edit*>(m_pNormalWidget.get())->GetText(); - if (m_pDataAcc->SetValue(wsText, XFA_VALUEPICTURE_Edit)) { - m_pDataAcc->UpdateUIDisplay(this); - return true; - } - ValidateNumberField(wsText); - return false; -} - -void CXFA_FFTextEdit::ValidateNumberField(const CFX_WideString& wsText) { - CXFA_WidgetAcc* pAcc = GetDataAcc(); - if (!pAcc || pAcc->GetUIType() != XFA_Element::NumericEdit) - return; - - IXFA_AppProvider* pAppProvider = GetApp()->GetAppProvider(); - if (!pAppProvider) - return; - - CFX_WideString wsSomField; - pAcc->GetNode()->GetSOMExpression(wsSomField); - - CFX_WideString wsMessage; - wsMessage.Format(L"%s can not contain %s", wsText.c_str(), - wsSomField.c_str()); - pAppProvider->MsgBox(wsMessage, pAppProvider->GetAppTitle(), XFA_MBICON_Error, - XFA_MB_OK); -} - -bool CXFA_FFTextEdit::IsDataChanged() { - return (m_dwStatus & XFA_WidgetStatus_TextEditValueChanged) != 0; -} - -uint32_t CXFA_FFTextEdit::GetAlignment() { - CXFA_Para para = m_pDataAcc->GetPara(); - if (!para) - return 0; - - uint32_t dwExtendedStyle = 0; - switch (para.GetHorizontalAlign()) { - case XFA_ATTRIBUTEENUM_Center: - dwExtendedStyle |= FWL_STYLEEXT_EDT_HCenter; - break; - case XFA_ATTRIBUTEENUM_Justify: - dwExtendedStyle |= FWL_STYLEEXT_EDT_Justified; - break; - case XFA_ATTRIBUTEENUM_JustifyAll: - case XFA_ATTRIBUTEENUM_Radix: - break; - case XFA_ATTRIBUTEENUM_Right: - dwExtendedStyle |= FWL_STYLEEXT_EDT_HFar; - break; - default: - dwExtendedStyle |= FWL_STYLEEXT_EDT_HNear; - break; - } - - switch (para.GetVerticalAlign()) { - case XFA_ATTRIBUTEENUM_Middle: - dwExtendedStyle |= FWL_STYLEEXT_EDT_VCenter; - break; - case XFA_ATTRIBUTEENUM_Bottom: - dwExtendedStyle |= FWL_STYLEEXT_EDT_VFar; - break; - default: - dwExtendedStyle |= FWL_STYLEEXT_EDT_VNear; - break; - } - return dwExtendedStyle; -} - -bool CXFA_FFTextEdit::UpdateFWLData() { - if (!m_pNormalWidget) - return false; - - XFA_VALUEPICTURE eType = XFA_VALUEPICTURE_Display; - if (IsFocused()) - eType = XFA_VALUEPICTURE_Edit; - - bool bUpdate = false; - if (m_pDataAcc->GetUIType() == XFA_Element::TextEdit && - m_pDataAcc->GetNumberOfCells() < 0) { - XFA_Element elementType = XFA_Element::Unknown; - int32_t iMaxChars = m_pDataAcc->GetMaxChars(elementType); - if (elementType == XFA_Element::ExData) - iMaxChars = eType == XFA_VALUEPICTURE_Edit ? iMaxChars : 0; - if (static_cast<CFWL_Edit*>(m_pNormalWidget.get())->GetLimit() != - iMaxChars) { - static_cast<CFWL_Edit*>(m_pNormalWidget.get())->SetLimit(iMaxChars); - bUpdate = true; - } - } - - if (m_pDataAcc->GetUIType() == XFA_Element::Barcode) { - int32_t nDataLen = 0; - if (eType == XFA_VALUEPICTURE_Edit) - m_pDataAcc->GetBarcodeAttribute_DataLength(&nDataLen); - static_cast<CFWL_Edit*>(m_pNormalWidget.get())->SetLimit(nDataLen); - bUpdate = true; - } - - CFX_WideString wsText; - m_pDataAcc->GetValue(wsText, eType); - - CFX_WideString wsOldText = - static_cast<CFWL_Edit*>(m_pNormalWidget.get())->GetText(); - if (wsText != wsOldText || (eType == XFA_VALUEPICTURE_Edit && bUpdate)) { - static_cast<CFWL_Edit*>(m_pNormalWidget.get())->SetText(wsText); - bUpdate = true; - } - if (bUpdate) - m_pNormalWidget->Update(); - - return true; -} - -void CXFA_FFTextEdit::OnTextChanged(CFWL_Widget* pWidget, - const CFX_WideString& wsChanged, - const CFX_WideString& wsPrevText) { - m_dwStatus |= XFA_WidgetStatus_TextEditValueChanged; - CXFA_EventParam eParam; - eParam.m_eType = XFA_EVENT_Change; - eParam.m_wsChange = wsChanged; - eParam.m_pTarget = m_pDataAcc.Get(); - eParam.m_wsPrevText = wsPrevText; - CFWL_Edit* pEdit = static_cast<CFWL_Edit*>(m_pNormalWidget.get()); - if (m_pDataAcc->GetUIType() == XFA_Element::DateTimeEdit) { - CFWL_DateTimePicker* pDateTime = (CFWL_DateTimePicker*)pEdit; - eParam.m_wsNewText = pDateTime->GetEditText(); - int32_t iSels = pDateTime->CountSelRanges(); - if (iSels) - eParam.m_iSelEnd = pDateTime->GetSelRange(0, &eParam.m_iSelStart); - } else { - eParam.m_wsNewText = pEdit->GetText(); - int32_t iSels = pEdit->CountSelRanges(); - if (iSels) - eParam.m_iSelEnd = pEdit->GetSelRange(0, &eParam.m_iSelStart); - } - m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Change, &eParam); -} - -void CXFA_FFTextEdit::OnTextFull(CFWL_Widget* pWidget) { - CXFA_EventParam eParam; - eParam.m_eType = XFA_EVENT_Full; - eParam.m_pTarget = m_pDataAcc.Get(); - m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Full, &eParam); -} - -bool CXFA_FFTextEdit::CheckWord(const CFX_ByteStringC& sWord) { - if (sWord.IsEmpty() || m_pDataAcc->GetUIType() != XFA_Element::TextEdit) - return true; - return false; -} - -void CXFA_FFTextEdit::OnProcessMessage(CFWL_Message* pMessage) { - m_pOldDelegate->OnProcessMessage(pMessage); -} - -void CXFA_FFTextEdit::OnProcessEvent(CFWL_Event* pEvent) { - CXFA_FFField::OnProcessEvent(pEvent); - switch (pEvent->GetType()) { - case CFWL_Event::Type::TextChanged: { - CFWL_EventTextChanged* event = - static_cast<CFWL_EventTextChanged*>(pEvent); - CFX_WideString wsChange; - OnTextChanged(m_pNormalWidget.get(), wsChange, event->wsPrevText); - break; - } - case CFWL_Event::Type::TextFull: { - OnTextFull(m_pNormalWidget.get()); - break; - } - case CFWL_Event::Type::CheckWord: { - CFX_WideString wstr(L"FWL_EVENT_DTP_SelectChanged"); - CFWL_EventCheckWord* event = static_cast<CFWL_EventCheckWord*>(pEvent); - event->bCheckWord = CheckWord(event->bsWord.AsStringC()); - break; - } - default: - break; - } - m_pOldDelegate->OnProcessEvent(pEvent); -} - -void CXFA_FFTextEdit::OnDrawWidget(CFX_Graphics* pGraphics, - const CFX_Matrix* pMatrix) { - m_pOldDelegate->OnDrawWidget(pGraphics, pMatrix); -} - -CXFA_FFNumericEdit::CXFA_FFNumericEdit(CXFA_WidgetAcc* pDataAcc) - : CXFA_FFTextEdit(pDataAcc) {} - -CXFA_FFNumericEdit::~CXFA_FFNumericEdit() {} - -bool CXFA_FFNumericEdit::LoadWidget() { - auto pNewEdit = pdfium::MakeUnique<CFWL_Edit>( - GetFWLApp(), pdfium::MakeUnique<CFWL_WidgetProperties>(), nullptr); - CFWL_Edit* pWidget = pNewEdit.get(); - m_pNormalWidget = std::move(pNewEdit); - m_pNormalWidget->SetLayoutItem(this); - - CFWL_NoteDriver* pNoteDriver = - m_pNormalWidget->GetOwnerApp()->GetNoteDriver(); - pNoteDriver->RegisterEventTarget(m_pNormalWidget.get(), - m_pNormalWidget.get()); - m_pOldDelegate = m_pNormalWidget->GetDelegate(); - m_pNormalWidget->SetDelegate(this); - m_pNormalWidget->LockUpdate(); - - CFX_WideString wsText; - m_pDataAcc->GetValue(wsText, XFA_VALUEPICTURE_Display); - pWidget->SetText(wsText); - UpdateWidgetProperty(); - m_pNormalWidget->UnlockUpdate(); - return CXFA_FFField::LoadWidget(); -} - -void CXFA_FFNumericEdit::UpdateWidgetProperty() { - CFWL_Edit* pWidget = static_cast<CFWL_Edit*>(m_pNormalWidget.get()); - if (!pWidget) - return; - - uint32_t dwExtendedStyle = - FWL_STYLEEXT_EDT_ShowScrollbarFocus | FWL_STYLEEXT_EDT_OuterScrollbar | - FWL_STYLEEXT_EDT_Validate | FWL_STYLEEXT_EDT_Number | - FWL_STYLEEXT_EDT_LastLineHeight; - dwExtendedStyle |= UpdateUIProperty(); - if (m_pDataAcc->GetHorizontalScrollPolicy() != XFA_ATTRIBUTEENUM_Off) - dwExtendedStyle |= FWL_STYLEEXT_EDT_AutoHScroll; - - int32_t iNumCells = m_pDataAcc->GetNumberOfCells(); - if (iNumCells > 0) { - dwExtendedStyle |= FWL_STYLEEXT_EDT_CombText; - pWidget->SetLimit(iNumCells); - } - dwExtendedStyle |= GetAlignment(); - if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open || - !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) { - dwExtendedStyle |= FWL_STYLEEXT_EDT_ReadOnly; - } - m_pNormalWidget->ModifyStylesEx(dwExtendedStyle, 0xFFFFFFFF); -} - -void CXFA_FFNumericEdit::OnProcessEvent(CFWL_Event* pEvent) { - if (pEvent->GetType() == CFWL_Event::Type::Validate) { - CFWL_EventValidate* event = static_cast<CFWL_EventValidate*>(pEvent); - event->bValidate = OnValidate(m_pNormalWidget.get(), event->wsInsert); - return; - } - CXFA_FFTextEdit::OnProcessEvent(pEvent); -} - -bool CXFA_FFNumericEdit::OnValidate(CFWL_Widget* pWidget, - CFX_WideString& wsText) { - CFX_WideString wsPattern; - m_pDataAcc->GetPictureContent(wsPattern, XFA_VALUEPICTURE_Edit); - if (!wsPattern.IsEmpty()) - return true; - - int32_t iLeads = 0; - m_pDataAcc->GetLeadDigits(iLeads); - - int32_t iFracs = 0; - m_pDataAcc->GetFracDigits(iFracs); - - CFX_WideString wsFormat; - CXFA_LocaleValue widgetValue = XFA_GetLocaleValue(m_pDataAcc.Get()); - widgetValue.GetNumbericFormat(wsFormat, iLeads, iFracs); - return widgetValue.ValidateNumericTemp(wsText, wsFormat, - m_pDataAcc->GetLocal()); -} - -CXFA_FFPasswordEdit::CXFA_FFPasswordEdit(CXFA_WidgetAcc* pDataAcc) - : CXFA_FFTextEdit(pDataAcc) {} - -CXFA_FFPasswordEdit::~CXFA_FFPasswordEdit() {} - -bool CXFA_FFPasswordEdit::LoadWidget() { - auto pNewEdit = pdfium::MakeUnique<CFWL_Edit>( - GetFWLApp(), pdfium::MakeUnique<CFWL_WidgetProperties>(), nullptr); - CFWL_Edit* pWidget = pNewEdit.get(); - m_pNormalWidget = std::move(pNewEdit); - m_pNormalWidget->SetLayoutItem(this); - - CFWL_NoteDriver* pNoteDriver = - m_pNormalWidget->GetOwnerApp()->GetNoteDriver(); - pNoteDriver->RegisterEventTarget(m_pNormalWidget.get(), - m_pNormalWidget.get()); - m_pOldDelegate = m_pNormalWidget->GetDelegate(); - m_pNormalWidget->SetDelegate(this); - m_pNormalWidget->LockUpdate(); - - CFX_WideString wsText; - m_pDataAcc->GetValue(wsText, XFA_VALUEPICTURE_Display); - pWidget->SetText(wsText); - UpdateWidgetProperty(); - m_pNormalWidget->UnlockUpdate(); - return CXFA_FFField::LoadWidget(); -} - -void CXFA_FFPasswordEdit::UpdateWidgetProperty() { - CFWL_Edit* pWidget = static_cast<CFWL_Edit*>(m_pNormalWidget.get()); - if (!pWidget) - return; - - uint32_t dwExtendedStyle = - FWL_STYLEEXT_EDT_ShowScrollbarFocus | FWL_STYLEEXT_EDT_OuterScrollbar | - FWL_STYLEEXT_EDT_Password | FWL_STYLEEXT_EDT_LastLineHeight; - dwExtendedStyle |= UpdateUIProperty(); - - CFX_WideString wsPassWord; - m_pDataAcc->GetPasswordChar(wsPassWord); - if (!wsPassWord.IsEmpty()) - pWidget->SetAliasChar(wsPassWord.GetAt(0)); - if (m_pDataAcc->GetHorizontalScrollPolicy() != XFA_ATTRIBUTEENUM_Off) - dwExtendedStyle |= FWL_STYLEEXT_EDT_AutoHScroll; - if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open || - !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) { - dwExtendedStyle |= FWL_STYLEEXT_EDT_ReadOnly; - } - dwExtendedStyle |= GetAlignment(); - m_pNormalWidget->ModifyStylesEx(dwExtendedStyle, 0xFFFFFFFF); -} - -CXFA_FFDateTimeEdit::CXFA_FFDateTimeEdit(CXFA_WidgetAcc* pDataAcc) - : CXFA_FFTextEdit(pDataAcc) {} - -CXFA_FFDateTimeEdit::~CXFA_FFDateTimeEdit() {} - -CFX_RectF CXFA_FFDateTimeEdit::GetBBox(uint32_t dwStatus, bool bDrawFocus) { - if (bDrawFocus) - return CFX_RectF(); - return CXFA_FFWidget::GetBBox(dwStatus); -} - -bool CXFA_FFDateTimeEdit::PtInActiveRect(const CFX_PointF& point) { - auto* pPicker = static_cast<CFWL_DateTimePicker*>(m_pNormalWidget.get()); - return pPicker && pPicker->GetBBox().Contains(point); -} - -bool CXFA_FFDateTimeEdit::LoadWidget() { - auto pNewPicker = pdfium::MakeUnique<CFWL_DateTimePicker>(GetFWLApp()); - CFWL_DateTimePicker* pWidget = pNewPicker.get(); - m_pNormalWidget = std::move(pNewPicker); - m_pNormalWidget->SetLayoutItem(this); - - CFWL_NoteDriver* pNoteDriver = - m_pNormalWidget->GetOwnerApp()->GetNoteDriver(); - pNoteDriver->RegisterEventTarget(m_pNormalWidget.get(), - m_pNormalWidget.get()); - m_pOldDelegate = m_pNormalWidget->GetDelegate(); - m_pNormalWidget->SetDelegate(this); - m_pNormalWidget->LockUpdate(); - - CFX_WideString wsText; - m_pDataAcc->GetValue(wsText, XFA_VALUEPICTURE_Display); - pWidget->SetEditText(wsText); - if (CXFA_Value value = m_pDataAcc->GetFormValue()) { - switch (value.GetChildValueClassID()) { - case XFA_Element::Date: { - if (!wsText.IsEmpty()) { - CXFA_LocaleValue lcValue = XFA_GetLocaleValue(m_pDataAcc.Get()); - CFX_DateTime date = lcValue.GetDate(); - if (date.IsSet()) - pWidget->SetCurSel(date.GetYear(), date.GetMonth(), date.GetDay()); - } - } break; - default: - break; - } - } - UpdateWidgetProperty(); - m_pNormalWidget->UnlockUpdate(); - return CXFA_FFField::LoadWidget(); -} - -void CXFA_FFDateTimeEdit::UpdateWidgetProperty() { - CFWL_DateTimePicker* pWidget = - static_cast<CFWL_DateTimePicker*>(m_pNormalWidget.get()); - if (!pWidget) - return; - - uint32_t dwExtendedStyle = FWL_STYLEEXT_DTP_ShortDateFormat; - dwExtendedStyle |= UpdateUIProperty(); - dwExtendedStyle |= GetAlignment(); - m_pNormalWidget->ModifyStylesEx(dwExtendedStyle, 0xFFFFFFFF); - uint32_t dwEditStyles = FWL_STYLEEXT_EDT_LastLineHeight; - int32_t iNumCells = m_pDataAcc->GetNumberOfCells(); - if (iNumCells > 0) { - dwEditStyles |= FWL_STYLEEXT_EDT_CombText; - pWidget->SetEditLimit(iNumCells); - } - if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open || - !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) { - dwEditStyles |= FWL_STYLEEXT_EDT_ReadOnly; - } - if (m_pDataAcc->GetHorizontalScrollPolicy() != XFA_ATTRIBUTEENUM_Off) - dwEditStyles |= FWL_STYLEEXT_EDT_AutoHScroll; - - pWidget->ModifyEditStylesEx(dwEditStyles, 0xFFFFFFFF); -} - -uint32_t CXFA_FFDateTimeEdit::GetAlignment() { - CXFA_Para para = m_pDataAcc->GetPara(); - if (!para) - return 0; - - uint32_t dwExtendedStyle = 0; - switch (para.GetHorizontalAlign()) { - case XFA_ATTRIBUTEENUM_Center: - dwExtendedStyle |= FWL_STYLEEXT_DTP_EditHCenter; - break; - case XFA_ATTRIBUTEENUM_Justify: - dwExtendedStyle |= FWL_STYLEEXT_DTP_EditJustified; - break; - case XFA_ATTRIBUTEENUM_JustifyAll: - case XFA_ATTRIBUTEENUM_Radix: - break; - case XFA_ATTRIBUTEENUM_Right: - dwExtendedStyle |= FWL_STYLEEXT_DTP_EditHFar; - break; - default: - dwExtendedStyle |= FWL_STYLEEXT_DTP_EditHNear; - break; - } - - switch (para.GetVerticalAlign()) { - case XFA_ATTRIBUTEENUM_Middle: - dwExtendedStyle |= FWL_STYLEEXT_DTP_EditVCenter; - break; - case XFA_ATTRIBUTEENUM_Bottom: - dwExtendedStyle |= FWL_STYLEEXT_DTP_EditVFar; - break; - default: - dwExtendedStyle |= FWL_STYLEEXT_DTP_EditVNear; - break; - } - return dwExtendedStyle; -} - -bool CXFA_FFDateTimeEdit::CommitData() { - auto* pPicker = static_cast<CFWL_DateTimePicker*>(m_pNormalWidget.get()); - if (!m_pDataAcc->SetValue(pPicker->GetEditText(), XFA_VALUEPICTURE_Edit)) - return false; - - m_pDataAcc->UpdateUIDisplay(this); - return true; -} - -bool CXFA_FFDateTimeEdit::UpdateFWLData() { - if (!m_pNormalWidget) - return false; - - XFA_VALUEPICTURE eType = XFA_VALUEPICTURE_Display; - if (IsFocused()) - eType = XFA_VALUEPICTURE_Edit; - - CFX_WideString wsText; - m_pDataAcc->GetValue(wsText, eType); - - auto* normalWidget = static_cast<CFWL_DateTimePicker*>(m_pNormalWidget.get()); - normalWidget->SetEditText(wsText); - if (IsFocused() && !wsText.IsEmpty()) { - CXFA_LocaleValue lcValue = XFA_GetLocaleValue(m_pDataAcc.Get()); - CFX_DateTime date = lcValue.GetDate(); - if (lcValue.IsValid()) { - if (date.IsSet()) - normalWidget->SetCurSel(date.GetYear(), date.GetMonth(), date.GetDay()); - } - } - m_pNormalWidget->Update(); - return true; -} - -bool CXFA_FFDateTimeEdit::IsDataChanged() { - if (m_dwStatus & XFA_WidgetStatus_TextEditValueChanged) - return true; - - CFX_WideString wsText = - static_cast<CFWL_DateTimePicker*>(m_pNormalWidget.get())->GetEditText(); - CFX_WideString wsOldValue; - m_pDataAcc->GetValue(wsOldValue, XFA_VALUEPICTURE_Edit); - return wsOldValue != wsText; -} - -void CXFA_FFDateTimeEdit::OnSelectChanged(CFWL_Widget* pWidget, - int32_t iYear, - int32_t iMonth, - int32_t iDay) { - CFX_WideString wsPicture; - m_pDataAcc->GetPictureContent(wsPicture, XFA_VALUEPICTURE_Edit); - - CXFA_LocaleValue date(XFA_VT_DATE, GetDoc()->GetXFADoc()->GetLocalMgr()); - date.SetDate(CFX_DateTime(iYear, iMonth, iDay, 0, 0, 0, 0)); - - CFX_WideString wsDate; - date.FormatPatterns(wsDate, wsPicture, m_pDataAcc->GetLocal(), - XFA_VALUEPICTURE_Edit); - - auto* pDateTime = static_cast<CFWL_DateTimePicker*>(m_pNormalWidget.get()); - pDateTime->SetEditText(wsDate); - pDateTime->Update(); - GetDoc()->GetDocEnvironment()->SetFocusWidget(GetDoc(), nullptr); - - CXFA_EventParam eParam; - eParam.m_eType = XFA_EVENT_Change; - eParam.m_pTarget = m_pDataAcc.Get(); - m_pDataAcc->GetValue(eParam.m_wsNewText, XFA_VALUEPICTURE_Raw); - m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Change, &eParam); -} - -void CXFA_FFDateTimeEdit::OnProcessEvent(CFWL_Event* pEvent) { - if (pEvent->GetType() == CFWL_Event::Type::SelectChanged) { - auto* event = static_cast<CFWL_EventSelectChanged*>(pEvent); - OnSelectChanged(m_pNormalWidget.get(), event->iYear, event->iMonth, - event->iDay); - return; - } - CXFA_FFTextEdit::OnProcessEvent(pEvent); -} diff --git a/xfa/fxfa/app/xfa_fftextedit.h b/xfa/fxfa/app/xfa_fftextedit.h deleted file mode 100644 index 9b9324f9d2..0000000000 --- a/xfa/fxfa/app/xfa_fftextedit.h +++ /dev/null @@ -1,105 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef XFA_FXFA_APP_XFA_FFTEXTEDIT_H_ -#define XFA_FXFA_APP_XFA_FFTEXTEDIT_H_ - -#include <vector> - -#include "xfa/fxfa/app/xfa_fffield.h" - -class CXFA_FFTextEdit : public CXFA_FFField { - public: - explicit CXFA_FFTextEdit(CXFA_WidgetAcc* pDataAcc); - ~CXFA_FFTextEdit() override; - - // CXFA_FFField - bool LoadWidget() override; - void UpdateWidgetProperty() override; - bool OnLButtonDown(uint32_t dwFlags, const CFX_PointF& point) override; - bool OnRButtonDown(uint32_t dwFlags, const CFX_PointF& point) override; - bool OnRButtonUp(uint32_t dwFlags, const CFX_PointF& point) override; - bool OnSetFocus(CXFA_FFWidget* pOldWidget) override; - bool OnKillFocus(CXFA_FFWidget* pNewWidget) override; - void OnProcessMessage(CFWL_Message* pMessage) override; - void OnProcessEvent(CFWL_Event* pEvent) override; - void OnDrawWidget(CFX_Graphics* pGraphics, - const CFX_Matrix* pMatrix = nullptr) override; - - void OnTextChanged(CFWL_Widget* pWidget, - const CFX_WideString& wsChanged, - const CFX_WideString& wsPrevText); - void OnTextFull(CFWL_Widget* pWidget); - bool CheckWord(const CFX_ByteStringC& sWord); - - protected: - uint32_t GetAlignment(); - - IFWL_WidgetDelegate* m_pOldDelegate; - - private: - bool CommitData() override; - bool UpdateFWLData() override; - bool IsDataChanged() override; - void ValidateNumberField(const CFX_WideString& wsText); -}; - -class CXFA_FFNumericEdit : public CXFA_FFTextEdit { - public: - explicit CXFA_FFNumericEdit(CXFA_WidgetAcc* pDataAcc); - ~CXFA_FFNumericEdit() override; - - // CXFA_FFTextEdit - bool LoadWidget() override; - void UpdateWidgetProperty() override; - void OnProcessEvent(CFWL_Event* pEvent) override; - - private: - bool OnValidate(CFWL_Widget* pWidget, CFX_WideString& wsText); -}; - -class CXFA_FFPasswordEdit : public CXFA_FFTextEdit { - public: - explicit CXFA_FFPasswordEdit(CXFA_WidgetAcc* pDataAcc); - ~CXFA_FFPasswordEdit() override; - - // CXFA_FFTextEdit - bool LoadWidget() override; - void UpdateWidgetProperty() override; -}; - -enum XFA_DATETIMETYPE { - XFA_DATETIMETYPE_Date = 0, - XFA_DATETIMETYPE_Time, - XFA_DATETIMETYPE_DateAndTime -}; - -class CXFA_FFDateTimeEdit : public CXFA_FFTextEdit { - public: - explicit CXFA_FFDateTimeEdit(CXFA_WidgetAcc* pDataAcc); - ~CXFA_FFDateTimeEdit() override; - - // CXFA_FFTextEdit - CFX_RectF GetBBox(uint32_t dwStatus, bool bDrawFocus = false) override; - bool LoadWidget() override; - void UpdateWidgetProperty() override; - void OnProcessEvent(CFWL_Event* pEvent) override; - - void OnSelectChanged(CFWL_Widget* pWidget, - int32_t iYear, - int32_t iMonth, - int32_t iDay); - - private: - bool PtInActiveRect(const CFX_PointF& point) override; - bool CommitData() override; - bool UpdateFWLData() override; - bool IsDataChanged() override; - - uint32_t GetAlignment(); -}; - -#endif // XFA_FXFA_APP_XFA_FFTEXTEDIT_H_ diff --git a/xfa/fxfa/cxfa_ffapp.cpp b/xfa/fxfa/cxfa_ffapp.cpp index 7b97116c7a..cb308f2c46 100644 --- a/xfa/fxfa/cxfa_ffapp.cpp +++ b/xfa/fxfa/cxfa_ffapp.cpp @@ -16,8 +16,8 @@ #include "xfa/fgas/font/cfgas_fontmgr.h" #include "xfa/fwl/cfwl_notedriver.h" #include "xfa/fwl/cfwl_widgetmgr.h" -#include "xfa/fxfa/app/xfa_fwladapter.h" -#include "xfa/fxfa/app/xfa_fwltheme.h" +#include "xfa/fxfa/app/cxfa_fwladapterwidgetmgr.h" +#include "xfa/fxfa/app/cxfa_fwltheme.h" #include "xfa/fxfa/cxfa_ffdoc.h" #include "xfa/fxfa/cxfa_ffdochandler.h" #include "xfa/fxfa/cxfa_ffwidgethandler.h" diff --git a/xfa/fxfa/cxfa_ffdoc.cpp b/xfa/fxfa/cxfa_ffdoc.cpp index bde40ce11f..01c570adbe 100644 --- a/xfa/fxfa/cxfa_ffdoc.cpp +++ b/xfa/fxfa/cxfa_ffdoc.cpp @@ -22,7 +22,7 @@ #include "core/fxcrt/xml/cfx_xmlnode.h" #include "third_party/base/ptr_util.h" #include "xfa/fwl/cfwl_notedriver.h" -#include "xfa/fxfa/app/xfa_ffnotify.h" +#include "xfa/fxfa/app/cxfa_ffnotify.h" #include "xfa/fxfa/cxfa_ffapp.h" #include "xfa/fxfa/cxfa_ffdocview.h" #include "xfa/fxfa/cxfa_ffwidget.h" diff --git a/xfa/fxfa/cxfa_ffdocview.cpp b/xfa/fxfa/cxfa_ffdocview.cpp index d9c97f71b1..620f3dab42 100644 --- a/xfa/fxfa/cxfa_ffdocview.cpp +++ b/xfa/fxfa/cxfa_ffdocview.cpp @@ -9,22 +9,19 @@ #include "core/fxcrt/fx_extension.h" #include "third_party/base/ptr_util.h" #include "third_party/base/stl_util.h" -#include "xfa/fxfa/app/xfa_ffbarcode.h" -#include "xfa/fxfa/app/xfa_ffcheckbutton.h" -#include "xfa/fxfa/app/xfa_ffchoicelist.h" -#include "xfa/fxfa/app/xfa_ffdraw.h" -#include "xfa/fxfa/app/xfa_ffexclgroup.h" -#include "xfa/fxfa/app/xfa_fffield.h" -#include "xfa/fxfa/app/xfa_ffimage.h" -#include "xfa/fxfa/app/xfa_ffimageedit.h" -#include "xfa/fxfa/app/xfa_ffpath.h" -#include "xfa/fxfa/app/xfa_ffpushbutton.h" -#include "xfa/fxfa/app/xfa_ffsignature.h" -#include "xfa/fxfa/app/xfa_ffsubform.h" -#include "xfa/fxfa/app/xfa_fftext.h" -#include "xfa/fxfa/app/xfa_fftextedit.h" -#include "xfa/fxfa/app/xfa_ffwidgetacc.h" -#include "xfa/fxfa/app/xfa_fwladapter.h" +#include "xfa/fxfa/app/cxfa_ffbarcode.h" +#include "xfa/fxfa/app/cxfa_ffcheckbutton.h" +#include "xfa/fxfa/app/cxfa_ffdraw.h" +#include "xfa/fxfa/app/cxfa_ffexclgroup.h" +#include "xfa/fxfa/app/cxfa_fffield.h" +#include "xfa/fxfa/app/cxfa_ffimage.h" +#include "xfa/fxfa/app/cxfa_ffimageedit.h" +#include "xfa/fxfa/app/cxfa_ffpushbutton.h" +#include "xfa/fxfa/app/cxfa_ffsignature.h" +#include "xfa/fxfa/app/cxfa_ffsubform.h" +#include "xfa/fxfa/app/cxfa_fftext.h" +#include "xfa/fxfa/app/cxfa_fwladapterwidgetmgr.h" +#include "xfa/fxfa/app/cxfa_textprovider.h" #include "xfa/fxfa/cxfa_ffapp.h" #include "xfa/fxfa/cxfa_ffdoc.h" #include "xfa/fxfa/cxfa_ffpageview.h" diff --git a/xfa/fxfa/cxfa_ffpageview.cpp b/xfa/fxfa/cxfa_ffpageview.cpp index c83ffaea7e..841318672f 100644 --- a/xfa/fxfa/cxfa_ffpageview.cpp +++ b/xfa/fxfa/cxfa_ffpageview.cpp @@ -13,13 +13,11 @@ #include "third_party/base/ptr_util.h" #include "third_party/base/stl_util.h" #include "xfa/fde/cfde_rendercontext.h" -#include "xfa/fxfa/app/xfa_ffcheckbutton.h" -#include "xfa/fxfa/app/xfa_ffchoicelist.h" -#include "xfa/fxfa/app/xfa_fffield.h" -#include "xfa/fxfa/app/xfa_ffimageedit.h" -#include "xfa/fxfa/app/xfa_ffpushbutton.h" -#include "xfa/fxfa/app/xfa_fftextedit.h" -#include "xfa/fxfa/app/xfa_fwladapter.h" +#include "xfa/fxfa/app/cxfa_ffcheckbutton.h" +#include "xfa/fxfa/app/cxfa_fffield.h" +#include "xfa/fxfa/app/cxfa_ffimageedit.h" +#include "xfa/fxfa/app/cxfa_ffpushbutton.h" +#include "xfa/fxfa/app/cxfa_fwladapterwidgetmgr.h" #include "xfa/fxfa/cxfa_ffdoc.h" #include "xfa/fxfa/cxfa_ffdocview.h" #include "xfa/fxfa/cxfa_ffwidget.h" diff --git a/xfa/fxfa/cxfa_ffwidgethandler.cpp b/xfa/fxfa/cxfa_ffwidgethandler.cpp index 6fe24fee29..680a00a975 100644 --- a/xfa/fxfa/cxfa_ffwidgethandler.cpp +++ b/xfa/fxfa/cxfa_ffwidgethandler.cpp @@ -8,9 +8,8 @@ #include <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/app/cxfa_fffield.h" +#include "xfa/fxfa/app/cxfa_fwladapterwidgetmgr.h" #include "xfa/fxfa/cxfa_ffdoc.h" #include "xfa/fxfa/cxfa_ffdocview.h" #include "xfa/fxfa/cxfa_ffwidget.h" diff --git a/xfa/fxfa/cxfa_widgetacc.cpp b/xfa/fxfa/cxfa_widgetacc.cpp index 9b52f95b63..d4a6125408 100644 --- a/xfa/fxfa/cxfa_widgetacc.cpp +++ b/xfa/fxfa/cxfa_widgetacc.cpp @@ -14,7 +14,7 @@ #include "third_party/base/stl_util.h" #include "xfa/fde/cfde_textout.h" #include "xfa/fxfa/app/cxfa_textlayout.h" -#include "xfa/fxfa/app/xfa_ffwidgetacc.h" +#include "xfa/fxfa/app/cxfa_textprovider.h" #include "xfa/fxfa/cxfa_ffapp.h" #include "xfa/fxfa/cxfa_ffdoc.h" #include "xfa/fxfa/cxfa_ffdocview.h" diff --git a/xfa/fxfa/fm2js/cxfa_fm2jscontext.cpp b/xfa/fxfa/fm2js/cxfa_fm2jscontext.cpp index 4b3b5e2ab1..c6d53696a0 100644 --- a/xfa/fxfa/fm2js/cxfa_fm2jscontext.cpp +++ b/xfa/fxfa/fm2js/cxfa_fm2jscontext.cpp @@ -17,7 +17,7 @@ #include "fxjs/cfxjse_value.h" #include "third_party/base/ptr_util.h" #include "third_party/base/stl_util.h" -#include "xfa/fxfa/app/xfa_ffnotify.h" +#include "xfa/fxfa/app/cxfa_ffnotify.h" #include "xfa/fxfa/fm2js/cxfa_fmparse.h" #include "xfa/fxfa/parser/cxfa_document.h" #include "xfa/fxfa/parser/cxfa_localevalue.h" diff --git a/xfa/fxfa/parser/cscript_eventpseudomodel.cpp b/xfa/fxfa/parser/cscript_eventpseudomodel.cpp index c57b0bdc78..ede59871f1 100644 --- a/xfa/fxfa/parser/cscript_eventpseudomodel.cpp +++ b/xfa/fxfa/parser/cscript_eventpseudomodel.cpp @@ -7,7 +7,7 @@ #include "xfa/fxfa/parser/cscript_eventpseudomodel.h" #include "fxjs/cfxjse_arguments.h" -#include "xfa/fxfa/app/xfa_ffnotify.h" +#include "xfa/fxfa/app/cxfa_ffnotify.h" #include "xfa/fxfa/cxfa_eventparam.h" #include "xfa/fxfa/cxfa_ffwidgethandler.h" #include "xfa/fxfa/parser/cxfa_document.h" diff --git a/xfa/fxfa/parser/cscript_hostpseudomodel.cpp b/xfa/fxfa/parser/cscript_hostpseudomodel.cpp index d2633ec4ae..b229b23151 100644 --- a/xfa/fxfa/parser/cscript_hostpseudomodel.cpp +++ b/xfa/fxfa/parser/cscript_hostpseudomodel.cpp @@ -9,7 +9,7 @@ #include <memory> #include "fxjs/cfxjse_arguments.h" -#include "xfa/fxfa/app/xfa_ffnotify.h" +#include "xfa/fxfa/app/cxfa_ffnotify.h" #include "xfa/fxfa/parser/cxfa_document.h" #include "xfa/fxfa/parser/cxfa_layoutprocessor.h" #include "xfa/fxfa/parser/cxfa_localemgr.h" diff --git a/xfa/fxfa/parser/cscript_layoutpseudomodel.cpp b/xfa/fxfa/parser/cscript_layoutpseudomodel.cpp index 6e6a1086ff..130c9f0843 100644 --- a/xfa/fxfa/parser/cscript_layoutpseudomodel.cpp +++ b/xfa/fxfa/parser/cscript_layoutpseudomodel.cpp @@ -10,7 +10,7 @@ #include "fxjs/cfxjse_arguments.h" #include "third_party/base/stl_util.h" -#include "xfa/fxfa/app/xfa_ffnotify.h" +#include "xfa/fxfa/app/cxfa_ffnotify.h" #include "xfa/fxfa/parser/cxfa_arraynodelist.h" #include "xfa/fxfa/parser/cxfa_containerlayoutitem.h" #include "xfa/fxfa/parser/cxfa_contentlayoutitem.h" diff --git a/xfa/fxfa/parser/cscript_signaturepseudomodel.cpp b/xfa/fxfa/parser/cscript_signaturepseudomodel.cpp index 0886809db1..023d3e541f 100644 --- a/xfa/fxfa/parser/cscript_signaturepseudomodel.cpp +++ b/xfa/fxfa/parser/cscript_signaturepseudomodel.cpp @@ -7,7 +7,7 @@ #include "xfa/fxfa/parser/cscript_signaturepseudomodel.h" #include "fxjs/cfxjse_arguments.h" -#include "xfa/fxfa/app/xfa_ffnotify.h" +#include "xfa/fxfa/app/cxfa_ffnotify.h" #include "xfa/fxfa/parser/cxfa_document.h" #include "xfa/fxfa/parser/cxfa_localemgr.h" #include "xfa/fxfa/parser/cxfa_scriptcontext.h" diff --git a/xfa/fxfa/parser/cxfa_document.cpp b/xfa/fxfa/parser/cxfa_document.cpp index a1180e7b8e..ec80866bb0 100644 --- a/xfa/fxfa/parser/cxfa_document.cpp +++ b/xfa/fxfa/parser/cxfa_document.cpp @@ -7,7 +7,7 @@ #include "xfa/fxfa/parser/cxfa_document.h" #include "core/fxcrt/fx_extension.h" -#include "xfa/fxfa/app/xfa_ffnotify.h" +#include "xfa/fxfa/app/cxfa_ffnotify.h" #include "xfa/fxfa/parser/cscript_datawindow.h" #include "xfa/fxfa/parser/cscript_eventpseudomodel.h" #include "xfa/fxfa/parser/cscript_hostpseudomodel.h" diff --git a/xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp b/xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp index b2e4e725a7..b6e6e7f8e9 100644 --- a/xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp +++ b/xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp @@ -14,7 +14,7 @@ #include "third_party/base/logging.h" #include "third_party/base/ptr_util.h" #include "third_party/base/stl_util.h" -#include "xfa/fxfa/app/xfa_ffnotify.h" +#include "xfa/fxfa/app/cxfa_ffnotify.h" #include "xfa/fxfa/parser/cxfa_containerlayoutitem.h" #include "xfa/fxfa/parser/cxfa_contentlayoutitem.h" #include "xfa/fxfa/parser/cxfa_document.h" diff --git a/xfa/fxfa/parser/cxfa_layoutitem.cpp b/xfa/fxfa/parser/cxfa_layoutitem.cpp index 2bac7950ef..a769da0f2a 100644 --- a/xfa/fxfa/parser/cxfa_layoutitem.cpp +++ b/xfa/fxfa/parser/cxfa_layoutitem.cpp @@ -6,7 +6,7 @@ #include "xfa/fxfa/parser/cxfa_layoutitem.h" -#include "xfa/fxfa/app/xfa_ffnotify.h" +#include "xfa/fxfa/app/cxfa_ffnotify.h" #include "xfa/fxfa/parser/cxfa_containerlayoutitem.h" #include "xfa/fxfa/parser/cxfa_contentlayoutitem.h" #include "xfa/fxfa/parser/cxfa_measurement.h" diff --git a/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp b/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp index 5c94a6a256..0bf091ed34 100644 --- a/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp +++ b/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp @@ -7,7 +7,7 @@ #include "xfa/fxfa/parser/cxfa_layoutpagemgr.h" #include "third_party/base/stl_util.h" -#include "xfa/fxfa/app/xfa_ffnotify.h" +#include "xfa/fxfa/app/cxfa_ffnotify.h" #include "xfa/fxfa/parser/cxfa_containerlayoutitem.h" #include "xfa/fxfa/parser/cxfa_contentlayoutitem.h" #include "xfa/fxfa/parser/cxfa_document.h" diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp index 2daa49e066..845d3f379d 100644 --- a/xfa/fxfa/parser/cxfa_node.cpp +++ b/xfa/fxfa/parser/cxfa_node.cpp @@ -23,7 +23,7 @@ #include "third_party/base/logging.h" #include "third_party/base/ptr_util.h" #include "third_party/base/stl_util.h" -#include "xfa/fxfa/app/xfa_ffnotify.h" +#include "xfa/fxfa/app/cxfa_ffnotify.h" #include "xfa/fxfa/cxfa_eventparam.h" #include "xfa/fxfa/cxfa_ffwidget.h" #include "xfa/fxfa/parser/cxfa_arraynodelist.h" diff --git a/xfa/fxfa/parser/cxfa_object.cpp b/xfa/fxfa/parser/cxfa_object.cpp index bd7daec83a..8dd35cd245 100644 --- a/xfa/fxfa/parser/cxfa_object.cpp +++ b/xfa/fxfa/parser/cxfa_object.cpp @@ -8,7 +8,7 @@ #include "core/fxcrt/fx_extension.h" #include "fxjs/cfxjse_value.h" -#include "xfa/fxfa/app/xfa_ffnotify.h" +#include "xfa/fxfa/app/cxfa_ffnotify.h" #include "xfa/fxfa/parser/cxfa_document.h" #include "xfa/fxfa/parser/cxfa_node.h" #include "xfa/fxfa/parser/cxfa_nodelist.h" diff --git a/xfa/fxfa/parser/cxfa_scriptcontext.cpp b/xfa/fxfa/parser/cxfa_scriptcontext.cpp index 49da63eee3..2100299616 100644 --- a/xfa/fxfa/parser/cxfa_scriptcontext.cpp +++ b/xfa/fxfa/parser/cxfa_scriptcontext.cpp @@ -14,7 +14,7 @@ #include "fxjs/cfxjse_value.h" #include "third_party/base/ptr_util.h" #include "third_party/base/stl_util.h" -#include "xfa/fxfa/app/xfa_ffnotify.h" +#include "xfa/fxfa/app/cxfa_ffnotify.h" #include "xfa/fxfa/cxfa_eventparam.h" #include "xfa/fxfa/parser/cxfa_document.h" #include "xfa/fxfa/parser/cxfa_localemgr.h" diff --git a/xfa/fxfa/parser/cxfa_widgetdata.cpp b/xfa/fxfa/parser/cxfa_widgetdata.cpp index bf9afc062f..cd4aa57332 100644 --- a/xfa/fxfa/parser/cxfa_widgetdata.cpp +++ b/xfa/fxfa/parser/cxfa_widgetdata.cpp @@ -10,7 +10,7 @@ #include "core/fxcrt/fx_extension.h" #include "fxbarcode/BC_Library.h" #include "third_party/base/stl_util.h" -#include "xfa/fxfa/app/xfa_ffnotify.h" +#include "xfa/fxfa/app/cxfa_ffnotify.h" #include "xfa/fxfa/parser/cxfa_document.h" #include "xfa/fxfa/parser/cxfa_event.h" #include "xfa/fxfa/parser/cxfa_localevalue.h" |