7#include "fpdfsdk/formfiller/cffl_formfield.h"
11#include "constants/form_flags.h"
12#include "core/fpdfapi/page/cpdf_page.h"
13#include "core/fxge/cfx_renderdevice.h"
14#include "fpdfsdk/cpdfsdk_pageview.h"
15#include "fpdfsdk/cpdfsdk_widget.h"
16#include "fpdfsdk/formfiller/cffl_perwindowdata.h"
17#include "third_party/base/check.h"
20 CPDFSDK_Widget* pWidget)
22 DCHECK(m_pFormFiller);
30 while (!m_Maps.empty()) {
31 auto it = m_Maps.begin();
32 std::unique_ptr<CPWL_Wnd> pWnd = std::move(it->second);
34 pWnd->InvalidateProvider(
this);
42 pWnd ? PWLtoFFL(pWnd->GetWindowRect()) : m_pWidget->GetRect();
57 CPDFSDK_Widget* pWidget,
73 CPDFSDK_Widget* pWidget,
88 CPDFSDK_Widget* pWidget,
89 Mask<FWL_EVENTFLAG> nFlags,
90 const CFX_PointF& point) {
98 if (!rect
.Contains(static_cast<
int>(point.x)
, static_cast<
int>(point.y)
))
104 CPDFSDK_Widget* pWidget,
105 Mask<FWL_EVENTFLAG> nFlags,
106 const CFX_PointF& point) {
117 Mask<FWL_EVENTFLAG> nFlags,
118 const CFX_PointF& point) {
128 Mask<FWL_EVENTFLAG> nFlags,
129 const CFX_PointF& point) {
139 Mask<FWL_EVENTFLAG> nFlags,
140 const CFX_PointF& point,
141 const CFX_Vector& delta) {
150 Mask<FWL_EVENTFLAG> nFlags,
151 const CFX_PointF& point) {
157 Mask<FWL_EVENTFLAG> nFlags,
158 const CFX_PointF& point) {
164 Mask<FWL_EVENTFLAG> nFlags) {
174 Mask<FWL_EVENTFLAG> nFlags) {
269 Mask<FWL_EVENTFLAG> nFlag) {
270 CPDFSDK_PageView* pPageView =
271 m_pFormFiller->GetOrCreatePageView(pWidget->GetPage());
284 CPDFSDK_PageView* pPageView =
285 m_pFormFiller->GetPageView(m_pWidget->GetPage());
291 bool bDestroyPWLWindow;
292 switch (m_pWidget->GetFieldType()) {
293 case FormFieldType::kPushButton:
294 case FormFieldType::kCheckBox:
295 case FormFieldType::kRadioButton:
296 bDestroyPWLWindow =
true;
299 bDestroyPWLWindow =
false;
316 uint32_t dwFieldFlag = m_pWidget->GetFieldFlags();
320 absl::optional<FX_COLORREF> color = m_pWidget->GetFillColor();
321 if (color.has_value())
322 cp.sBackgroundColor = CFX_Color(color.value());
323 color = m_pWidget->GetBorderColor();
324 if (color.has_value())
325 cp.sBorderColor = CFX_Color(color.value());
329 color = m_pWidget->GetTextColor();
330 if (color.has_value())
331 cp.sTextColor = CFX_Color(color.value());
333 cp.fFontSize = m_pWidget->GetFontSize();
334 cp.dwBorderWidth = m_pWidget->GetBorderWidth();
336 cp.nBorderStyle = m_pWidget->GetBorderStyle();
357 const CPDFSDK_PageView* pPageView)
const {
359 auto it = m_Maps.find(pPageView);
360 return it != m_Maps.end() ? it->second.get() :
nullptr;
364 const CPDFSDK_PageView* pPageView) {
370 auto pPrivateData = std::make_unique<CFFL_PerWindowData>(
371 m_pWidget, pPageView, m_pWidget->GetAppearanceAge(), 0);
372 m_Maps[pPageView] = NewPWLWindow(cp, std::move(pPrivateData));
373 return m_Maps[pPageView].get();
375 const auto* pPrivateData =
377 if (pPrivateData->AppearanceAgeEquals(m_pWidget->GetAppearanceAge()))
380 return ResetPWLWindowForValueAgeInternal(pPageView, m_pWidget,
381 pPrivateData->GetValueAge());
385 auto it = m_Maps.find(pPageView);
386 if (it == m_Maps.end())
389 std::unique_ptr<CPWL_Wnd> pWnd = std::move(it->second);
396 const auto* pPrivateData =
static_cast<
const CFFL_PerWindowData*>(pAttached);
414 switch (m_pWidget->GetRotate()) {
436 CFX_FloatRect rectAnnot = m_pWidget->GetPDFAnnot()->GetRect();
439 if ((m_pWidget->GetRotate() / 90) & 0x01)
440 std::swap(fWidth, fHeight);
445 return m_pFormFiller->GetOrCreatePageView(m_pWidget->GetPage());
475 Mask<FWL_EVENTFLAG> nFlag) {
479 ObservedPtr<CPDFSDK_Widget> pObserved(m_pWidget);
480 if (!m_pFormFiller->OnKeyStrokeCommit(pObserved, pPageView, nFlag)) {
489 if (!m_pFormFiller->OnValidate(pObserved, pPageView, nFlag)) {
502 m_pFormFiller->OnCalculate(pObserved);
506 m_pFormFiller->OnFormat(pObserved);
520bool CFFL_FormField::IsFieldFull(
const CPDFSDK_PageView* pPageView) {
526 m_pFormFiller->OnChange();
532 fa.sValue = m_pWidget->GetValue();
542 const CPDFSDK_PageView* pPageView) {}
545 const CPDFSDK_PageView* pPageView) {
554 const CPDFSDK_PageView* pPageView,
555 CPDFSDK_Widget* pWidget,
556 uint32_t nValueAge) {
562 const CPDFSDK_PageView* pPageView,
563 CPDFSDK_Widget* pWidget,
564 uint32_t nValueAge) {
580 bool bDestroyPWLWindow) {
584 if (bDestroyPWLWindow)
589 m_pFormFiller->Invalidate(m_pWidget->GetPage(), rect);
const CPDFSDK_PageView * GetPageView() const
constexpr CFX_FloatRect(float l, float b, float r, float t)
constexpr CFX_FloatRect()=default
void Inflate(float x, float y)
CFX_FloatRect & operator=(const CFX_FloatRect &that)=default
FX_RECT GetOuterRect() const
void Union(const CFX_FloatRect &other_rect)
CFX_Matrix & operator=(const CFX_Matrix &other)=default
CFX_FloatRect TransformRect(const CFX_FloatRect &rect) const
CFX_Matrix(float a1, float b1, float c1, float d1, float e1, float f1)
CFX_Matrix operator*(const CFX_Matrix &right) const
CFX_PointF Transform(const CFX_PointF &point) const
CFX_Matrix GetInverse() const
CPDF_Page * GetPDFPage() const
const CFX_Matrix & GetCurrentMatrix() const
const CFX_FloatRect & GetBBox() const
virtual bool OnMouseWheel(Mask< FWL_EVENTFLAG > nFlag, const CFX_PointF &point, const CFX_Vector &delta)
virtual bool SelectAllText()
virtual bool OnRButtonDown(Mask< FWL_EVENTFLAG > nFlag, const CFX_PointF &point)
virtual bool OnChar(uint16_t nChar, Mask< FWL_EVENTFLAG > nFlag)
virtual void ReplaceAndKeepSelection(const WideString &text)
virtual WideString GetSelectedText()
virtual bool OnLButtonUp(Mask< FWL_EVENTFLAG > nFlag, const CFX_PointF &point)
virtual bool OnMouseMove(Mask< FWL_EVENTFLAG > nFlag, const CFX_PointF &point)
virtual bool OnRButtonUp(Mask< FWL_EVENTFLAG > nFlag, const CFX_PointF &point)
virtual bool OnKeyDown(FWL_VKEYCODE nKeyCode, Mask< FWL_EVENTFLAG > nFlag)
virtual CFX_FloatRect GetFocusRect() const
virtual void ReplaceSelection(const WideString &text)
IPWL_FillerNotify::PerWindowData * GetAttachedData() const
virtual bool OnLButtonDblClk(Mask< FWL_EVENTFLAG > nFlag, const CFX_PointF &point)
virtual bool OnLButtonDown(Mask< FWL_EVENTFLAG > nFlag, const CFX_PointF &point)
void DrawAppearance(CFX_RenderDevice *pDevice, const CFX_Matrix &mtUser2Device)
virtual WideString GetText()
CFX_Color & operator=(const CFX_Color &that)=default
constexpr CFX_Color(Type type=CFX_Color::Type::kTransparent, float color1=0.0f, float color2=0.0f, float color3=0.0f, float color4=0.0f)
CPWL_Dash(int32_t dash, int32_t gap, int32_t phase)
bool Contains(int x, int y) const