diff options
Diffstat (limited to 'fpdfsdk/formfiller/cffl_formfiller.cpp')
-rw-r--r-- | fpdfsdk/formfiller/cffl_formfiller.cpp | 243 |
1 files changed, 121 insertions, 122 deletions
diff --git a/fpdfsdk/formfiller/cffl_formfiller.cpp b/fpdfsdk/formfiller/cffl_formfiller.cpp index 1e58d10799..7c1dec46b3 100644 --- a/fpdfsdk/formfiller/cffl_formfiller.cpp +++ b/fpdfsdk/formfiller/cffl_formfiller.cpp @@ -23,7 +23,7 @@ CFFL_FormFiller::CFFL_FormFiller(CPDFSDK_FormFillEnvironment* pFormFillEnv, CPDFSDK_Annot* pAnnot) - : m_pFormFillEnv(pFormFillEnv), m_pAnnot(pAnnot), m_bValid(FALSE) { + : m_pFormFillEnv(pFormFillEnv), m_pAnnot(pAnnot), m_bValid(false) { m_pWidget = static_cast<CPDFSDK_Widget*>(pAnnot); } @@ -45,13 +45,13 @@ void CFFL_FormFiller::DestroyWindows() { void CFFL_FormFiller::SetWindowRect(CPDFSDK_PageView* pPageView, const CFX_FloatRect& rcWindow) { - if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE)) { - pWnd->Move(CFX_FloatRect(rcWindow), TRUE, FALSE); + if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, false)) { + pWnd->Move(CFX_FloatRect(rcWindow), true, false); } } CFX_FloatRect CFFL_FormFiller::GetWindowRect(CPDFSDK_PageView* pPageView) { - if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE)) { + if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, false)) { return pWnd->GetWindowRect(); } @@ -65,7 +65,7 @@ FX_RECT CFFL_FormFiller::GetViewBBox(CPDFSDK_PageView* pPageView, CFX_FloatRect rcAnnot = m_pWidget->GetRect(); - if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE)) { + if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, false)) { CFX_FloatRect rcWindow = pWnd->GetWindowRect(); rcAnnot = PWLtoFFL(rcWindow); } @@ -87,7 +87,7 @@ void CFFL_FormFiller::OnDraw(CPDFSDK_PageView* pPageView, CFX_Matrix* pUser2Device) { ASSERT(pAnnot->GetPDFAnnot()->GetSubtype() == CPDF_Annot::Subtype::WIDGET); - if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE)) { + if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, false)) { CFX_Matrix mt = GetCurMatrix(); mt.Concat(*pUser2Device); pWnd->DrawAppearance(pDevice, &mt); @@ -116,139 +116,139 @@ void CFFL_FormFiller::OnMouseExit(CPDFSDK_PageView* pPageView, ASSERT(m_pWidget); } -FX_BOOL CFFL_FormFiller::OnLButtonDown(CPDFSDK_PageView* pPageView, - CPDFSDK_Annot* pAnnot, - uint32_t nFlags, - const CFX_FloatPoint& point) { - if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, TRUE)) { - m_bValid = TRUE; +bool CFFL_FormFiller::OnLButtonDown(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + uint32_t nFlags, + const CFX_FloatPoint& point) { + if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, true)) { + m_bValid = true; FX_RECT rect = GetViewBBox(pPageView, pAnnot); InvalidateRect(rect.left, rect.top, rect.right, rect.bottom); if (!rect.Contains((int)point.x, (int)point.y)) - return FALSE; + return false; return pWnd->OnLButtonDown(WndtoPWL(pPageView, point), nFlags); } - return FALSE; + return false; } -FX_BOOL CFFL_FormFiller::OnLButtonUp(CPDFSDK_PageView* pPageView, - CPDFSDK_Annot* pAnnot, - uint32_t nFlags, - const CFX_FloatPoint& point) { - CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE); +bool CFFL_FormFiller::OnLButtonUp(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + uint32_t nFlags, + const CFX_FloatPoint& point) { + CPWL_Wnd* pWnd = GetPDFWindow(pPageView, false); if (!pWnd) - return FALSE; + return false; FX_RECT rcFFL = GetViewBBox(pPageView, pAnnot); InvalidateRect(rcFFL.left, rcFFL.top, rcFFL.right, rcFFL.bottom); pWnd->OnLButtonUp(WndtoPWL(pPageView, point), nFlags); - return TRUE; + return true; } -FX_BOOL CFFL_FormFiller::OnLButtonDblClk(CPDFSDK_PageView* pPageView, - CPDFSDK_Annot* pAnnot, - uint32_t nFlags, - const CFX_FloatPoint& point) { - CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE); +bool CFFL_FormFiller::OnLButtonDblClk(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + uint32_t nFlags, + const CFX_FloatPoint& point) { + CPWL_Wnd* pWnd = GetPDFWindow(pPageView, false); if (!pWnd) - return FALSE; + return false; pWnd->OnLButtonDblClk(WndtoPWL(pPageView, point), nFlags); - return TRUE; + return true; } -FX_BOOL CFFL_FormFiller::OnMouseMove(CPDFSDK_PageView* pPageView, - CPDFSDK_Annot* pAnnot, - uint32_t nFlags, - const CFX_FloatPoint& point) { +bool CFFL_FormFiller::OnMouseMove(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + uint32_t nFlags, + const CFX_FloatPoint& point) { if (m_ptOldPos != point) m_ptOldPos = point; - CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE); + CPWL_Wnd* pWnd = GetPDFWindow(pPageView, false); if (!pWnd) - return FALSE; + return false; pWnd->OnMouseMove(WndtoPWL(pPageView, point), nFlags); - return TRUE; + return true; } -FX_BOOL CFFL_FormFiller::OnMouseWheel(CPDFSDK_PageView* pPageView, - CPDFSDK_Annot* pAnnot, - uint32_t nFlags, - short zDelta, - const CFX_FloatPoint& point) { +bool CFFL_FormFiller::OnMouseWheel(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + uint32_t nFlags, + short zDelta, + const CFX_FloatPoint& point) { if (!IsValid()) - return FALSE; + return false; - CPWL_Wnd* pWnd = GetPDFWindow(pPageView, TRUE); + CPWL_Wnd* pWnd = GetPDFWindow(pPageView, true); return pWnd && pWnd->OnMouseWheel(zDelta, WndtoPWL(pPageView, point), nFlags); } -FX_BOOL CFFL_FormFiller::OnRButtonDown(CPDFSDK_PageView* pPageView, - CPDFSDK_Annot* pAnnot, - uint32_t nFlags, - const CFX_FloatPoint& point) { - CPWL_Wnd* pWnd = GetPDFWindow(pPageView, TRUE); +bool CFFL_FormFiller::OnRButtonDown(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + uint32_t nFlags, + const CFX_FloatPoint& point) { + CPWL_Wnd* pWnd = GetPDFWindow(pPageView, true); if (!pWnd) - return FALSE; + return false; pWnd->OnRButtonDown(WndtoPWL(pPageView, point), nFlags); - return TRUE; + return true; } -FX_BOOL CFFL_FormFiller::OnRButtonUp(CPDFSDK_PageView* pPageView, - CPDFSDK_Annot* pAnnot, - uint32_t nFlags, - const CFX_FloatPoint& point) { - CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE); +bool CFFL_FormFiller::OnRButtonUp(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + uint32_t nFlags, + const CFX_FloatPoint& point) { + CPWL_Wnd* pWnd = GetPDFWindow(pPageView, false); if (!pWnd) - return FALSE; + return false; pWnd->OnRButtonUp(WndtoPWL(pPageView, point), nFlags); - return TRUE; + return true; } -FX_BOOL CFFL_FormFiller::OnKeyDown(CPDFSDK_Annot* pAnnot, - uint32_t nKeyCode, - uint32_t nFlags) { +bool CFFL_FormFiller::OnKeyDown(CPDFSDK_Annot* pAnnot, + uint32_t nKeyCode, + uint32_t nFlags) { if (IsValid()) { CPDFSDK_PageView* pPageView = GetCurPageView(true); ASSERT(pPageView); - if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE)) { + if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, false)) { return pWnd->OnKeyDown(nKeyCode, nFlags); } } - return FALSE; + return false; } -FX_BOOL CFFL_FormFiller::OnChar(CPDFSDK_Annot* pAnnot, - uint32_t nChar, - uint32_t nFlags) { +bool CFFL_FormFiller::OnChar(CPDFSDK_Annot* pAnnot, + uint32_t nChar, + uint32_t nFlags) { if (IsValid()) { CPDFSDK_PageView* pPageView = GetCurPageView(true); ASSERT(pPageView); - if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE)) { + if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, false)) { return pWnd->OnChar(nChar, nFlags); } } - return FALSE; + return false; } void CFFL_FormFiller::SetFocusForAnnot(CPDFSDK_Annot* pAnnot, uint32_t nFlag) { CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; UnderlyingPageType* pPage = pWidget->GetUnderlyingPage(); CPDFSDK_PageView* pPageView = m_pFormFillEnv->GetPageView(pPage, true); - if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, TRUE)) + if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, true)) pWnd->SetFocus(); - m_bValid = TRUE; + m_bValid = true; FX_RECT rcRect = GetViewBBox(pPageView, pAnnot); InvalidateRect(rcRect.left, rcRect.top, rcRect.right, rcRect.bottom); } @@ -263,24 +263,24 @@ void CFFL_FormFiller::KillFocusForAnnot(CPDFSDK_Annot* pAnnot, uint32_t nFlag) { CommitData(pPageView, nFlag); - if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE)) + if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, false)) pWnd->KillFocus(); - FX_BOOL bDestroyPDFWindow; + bool bDestroyPDFWindow; switch (m_pWidget->GetFieldType()) { case FIELDTYPE_PUSHBUTTON: case FIELDTYPE_CHECKBOX: case FIELDTYPE_RADIOBUTTON: - bDestroyPDFWindow = TRUE; + bDestroyPDFWindow = true; break; default: - bDestroyPDFWindow = FALSE; + bDestroyPDFWindow = false; break; } EscapeFiller(pPageView, bDestroyPDFWindow); } -FX_BOOL CFFL_FormFiller::IsValid() const { +bool CFFL_FormFiller::IsValid() const { return m_bValid; } @@ -342,7 +342,7 @@ PWL_CREATEPARAM CFFL_FormFiller::GetCreateParam() { } CPWL_Wnd* CFFL_FormFiller::GetPDFWindow(CPDFSDK_PageView* pPageView, - FX_BOOL bNew) { + bool bNew) { ASSERT(pPageView); auto it = m_Maps.find(pPageView); @@ -454,7 +454,7 @@ CPDFSDK_PageView* CFFL_FormFiller::GetCurPageView(bool renew) { } CFX_FloatRect CFFL_FormFiller::GetFocusBox(CPDFSDK_PageView* pPageView) { - if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE)) { + if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, false)) { CFX_FloatRect rcFocus = FFLtoWnd(pPageView, PWLtoFFL(pWnd->GetFocusRect())); CFX_FloatRect rcPage = pPageView->GetPDFPage()->GetPageBBox(); if (rcPage.Contains(rcFocus)) @@ -511,47 +511,46 @@ CFX_FloatRect CFFL_FormFiller::FFLtoWnd(CPDFSDK_PageView* pPageView, return rect; } -FX_BOOL CFFL_FormFiller::CommitData(CPDFSDK_PageView* pPageView, - uint32_t nFlag) { +bool CFFL_FormFiller::CommitData(CPDFSDK_PageView* pPageView, uint32_t nFlag) { if (IsDataChanged(pPageView)) { - FX_BOOL bRC = TRUE; - FX_BOOL bExit = FALSE; + bool bRC = true; + bool bExit = false; CFFL_InteractiveFormFiller* pFormFiller = m_pFormFillEnv->GetInteractiveFormFiller(); CPDFSDK_Annot::ObservedPtr pObserved(m_pWidget); pFormFiller->OnKeyStrokeCommit(&pObserved, pPageView, bRC, bExit, nFlag); if (!pObserved || bExit) - return TRUE; + return true; if (!bRC) { - ResetPDFWindow(pPageView, FALSE); - return TRUE; + ResetPDFWindow(pPageView, false); + return true; } pFormFiller->OnValidate(&pObserved, pPageView, bRC, bExit, nFlag); if (!pObserved || bExit) - return TRUE; + return true; if (!bRC) { - ResetPDFWindow(pPageView, FALSE); - return TRUE; + ResetPDFWindow(pPageView, false); + return true; } SaveData(pPageView); pFormFiller->OnCalculate(m_pWidget, pPageView, bExit, nFlag); if (bExit) - return TRUE; + return true; pFormFiller->OnFormat(m_pWidget, pPageView, bExit, nFlag); } - return TRUE; + return true; } -FX_BOOL CFFL_FormFiller::IsDataChanged(CPDFSDK_PageView* pPageView) { - return FALSE; +bool CFFL_FormFiller::IsDataChanged(CPDFSDK_PageView* pPageView) { + return false; } void CFFL_FormFiller::SaveData(CPDFSDK_PageView* pPageView) {} #ifdef PDF_ENABLE_XFA -FX_BOOL CFFL_FormFiller::IsFieldFull(CPDFSDK_PageView* pPageView) { - return FALSE; +bool CFFL_FormFiller::IsFieldFull(CPDFSDK_PageView* pPageView) { + return false; } #endif // PDF_ENABLE_XFA @@ -569,10 +568,10 @@ void CFFL_FormFiller::SetActionData(CPDFSDK_PageView* pPageView, CPDF_AAction::AActionType type, const PDFSDK_FieldAction& fa) {} -FX_BOOL CFFL_FormFiller::IsActionDataChanged(CPDF_AAction::AActionType type, - const PDFSDK_FieldAction& faOld, - const PDFSDK_FieldAction& faNew) { - return FALSE; +bool CFFL_FormFiller::IsActionDataChanged(CPDF_AAction::AActionType type, + const PDFSDK_FieldAction& faOld, + const PDFSDK_FieldAction& faNew) { + return false; } void CFFL_FormFiller::SaveState(CPDFSDK_PageView* pPageView) {} @@ -580,8 +579,8 @@ void CFFL_FormFiller::SaveState(CPDFSDK_PageView* pPageView) {} void CFFL_FormFiller::RestoreState(CPDFSDK_PageView* pPageView) {} CPWL_Wnd* CFFL_FormFiller::ResetPDFWindow(CPDFSDK_PageView* pPageView, - FX_BOOL bRestoreValue) { - return GetPDFWindow(pPageView, FALSE); + bool bRestoreValue) { + return GetPDFWindow(pPageView, false); } void CFFL_FormFiller::TimerProc() {} @@ -591,8 +590,8 @@ CFX_SystemHandler* CFFL_FormFiller::GetSystemHandler() const { } void CFFL_FormFiller::EscapeFiller(CPDFSDK_PageView* pPageView, - FX_BOOL bDestroyPDFWindow) { - m_bValid = FALSE; + bool bDestroyPDFWindow) { + m_bValid = false; FX_RECT rcRect = GetViewBBox(pPageView, m_pWidget); InvalidateRect(rcRect.left, rcRect.top, rcRect.right, rcRect.bottom); @@ -611,20 +610,20 @@ void CFFL_FormFiller::InvalidateRect(double left, CFFL_Button::CFFL_Button(CPDFSDK_FormFillEnvironment* pApp, CPDFSDK_Annot* pWidget) - : CFFL_FormFiller(pApp, pWidget), m_bMouseIn(FALSE), m_bMouseDown(FALSE) {} + : CFFL_FormFiller(pApp, pWidget), m_bMouseIn(false), m_bMouseDown(false) {} CFFL_Button::~CFFL_Button() {} void CFFL_Button::OnMouseEnter(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot) { - m_bMouseIn = TRUE; + m_bMouseIn = true; FX_RECT rect = GetViewBBox(pPageView, pAnnot); InvalidateRect(rect.left, rect.top, rect.right, rect.bottom); } void CFFL_Button::OnMouseExit(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot) { - m_bMouseIn = FALSE; + m_bMouseIn = false; FX_RECT rect = GetViewBBox(pPageView, pAnnot); InvalidateRect(rect.left, rect.top, rect.right, rect.bottom); @@ -632,44 +631,44 @@ void CFFL_Button::OnMouseExit(CPDFSDK_PageView* pPageView, ASSERT(m_pWidget); } -FX_BOOL CFFL_Button::OnLButtonDown(CPDFSDK_PageView* pPageView, - CPDFSDK_Annot* pAnnot, - uint32_t nFlags, - const CFX_FloatPoint& point) { +bool CFFL_Button::OnLButtonDown(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + uint32_t nFlags, + const CFX_FloatPoint& point) { CFX_FloatRect rcAnnot = pAnnot->GetRect(); if (!rcAnnot.Contains(point.x, point.y)) - return FALSE; + return false; - m_bMouseDown = TRUE; - m_bValid = TRUE; + m_bMouseDown = true; + m_bValid = true; FX_RECT rect = GetViewBBox(pPageView, pAnnot); InvalidateRect(rect.left, rect.top, rect.right, rect.bottom); - return TRUE; + return true; } -FX_BOOL CFFL_Button::OnLButtonUp(CPDFSDK_PageView* pPageView, - CPDFSDK_Annot* pAnnot, - uint32_t nFlags, - const CFX_FloatPoint& point) { +bool CFFL_Button::OnLButtonUp(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + uint32_t nFlags, + const CFX_FloatPoint& point) { CFX_FloatRect rcAnnot = pAnnot->GetRect(); if (!rcAnnot.Contains(point.x, point.y)) - return FALSE; + return false; - m_bMouseDown = FALSE; + m_bMouseDown = false; m_pWidget->GetPDFPage(); FX_RECT rect = GetViewBBox(pPageView, pAnnot); InvalidateRect(rect.left, rect.top, rect.right, rect.bottom); - return TRUE; + return true; } -FX_BOOL CFFL_Button::OnMouseMove(CPDFSDK_PageView* pPageView, - CPDFSDK_Annot* pAnnot, - uint32_t nFlags, - const CFX_FloatPoint& point) { +bool CFFL_Button::OnMouseMove(CPDFSDK_PageView* pPageView, + CPDFSDK_Annot* pAnnot, + uint32_t nFlags, + const CFX_FloatPoint& point) { ASSERT(m_pFormFillEnv); - return TRUE; + return true; } void CFFL_Button::OnDraw(CPDFSDK_PageView* pPageView, |