| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #include "fpdfsdk/formfiller/cffl_formfiller.h" | 7 #include "fpdfsdk/formfiller/cffl_formfiller.h" |
| 8 | 8 |
| 9 #include "core/fpdfapi/fpdf_page/include/cpdf_page.h" | 9 #include "core/fpdfapi/fpdf_page/include/cpdf_page.h" |
| 10 #include "core/fxge/include/cfx_renderdevice.h" | 10 #include "core/fxge/include/cfx_renderdevice.h" |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 CPDFSDK_Annot* pAnnot) {} | 118 CPDFSDK_Annot* pAnnot) {} |
| 119 | 119 |
| 120 void CFFL_FormFiller::OnMouseExit(CPDFSDK_PageView* pPageView, | 120 void CFFL_FormFiller::OnMouseExit(CPDFSDK_PageView* pPageView, |
| 121 CPDFSDK_Annot* pAnnot) { | 121 CPDFSDK_Annot* pAnnot) { |
| 122 EndTimer(); | 122 EndTimer(); |
| 123 ASSERT(m_pWidget); | 123 ASSERT(m_pWidget); |
| 124 } | 124 } |
| 125 | 125 |
| 126 FX_BOOL CFFL_FormFiller::OnLButtonDown(CPDFSDK_PageView* pPageView, | 126 FX_BOOL CFFL_FormFiller::OnLButtonDown(CPDFSDK_PageView* pPageView, |
| 127 CPDFSDK_Annot* pAnnot, | 127 CPDFSDK_Annot* pAnnot, |
| 128 FX_UINT nFlags, | 128 unsigned int nFlags, |
| 129 const CFX_FloatPoint& point) { | 129 const CFX_FloatPoint& point) { |
| 130 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, TRUE)) { | 130 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, TRUE)) { |
| 131 m_bValid = TRUE; | 131 m_bValid = TRUE; |
| 132 FX_RECT rect = GetViewBBox(pPageView, pAnnot); | 132 FX_RECT rect = GetViewBBox(pPageView, pAnnot); |
| 133 InvalidateRect(rect.left, rect.top, rect.right, rect.bottom); | 133 InvalidateRect(rect.left, rect.top, rect.right, rect.bottom); |
| 134 | 134 |
| 135 if (!rect.Contains((int)point.x, (int)point.y)) | 135 if (!rect.Contains((int)point.x, (int)point.y)) |
| 136 return FALSE; | 136 return FALSE; |
| 137 | 137 |
| 138 return pWnd->OnLButtonDown(WndtoPWL(pPageView, point), nFlags); | 138 return pWnd->OnLButtonDown(WndtoPWL(pPageView, point), nFlags); |
| 139 } | 139 } |
| 140 | 140 |
| 141 return FALSE; | 141 return FALSE; |
| 142 } | 142 } |
| 143 | 143 |
| 144 FX_BOOL CFFL_FormFiller::OnLButtonUp(CPDFSDK_PageView* pPageView, | 144 FX_BOOL CFFL_FormFiller::OnLButtonUp(CPDFSDK_PageView* pPageView, |
| 145 CPDFSDK_Annot* pAnnot, | 145 CPDFSDK_Annot* pAnnot, |
| 146 FX_UINT nFlags, | 146 unsigned int nFlags, |
| 147 const CFX_FloatPoint& point) { | 147 const CFX_FloatPoint& point) { |
| 148 CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE); | 148 CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE); |
| 149 if (!pWnd) | 149 if (!pWnd) |
| 150 return FALSE; | 150 return FALSE; |
| 151 | 151 |
| 152 FX_RECT rcFFL = GetViewBBox(pPageView, pAnnot); | 152 FX_RECT rcFFL = GetViewBBox(pPageView, pAnnot); |
| 153 InvalidateRect(rcFFL.left, rcFFL.top, rcFFL.right, rcFFL.bottom); | 153 InvalidateRect(rcFFL.left, rcFFL.top, rcFFL.right, rcFFL.bottom); |
| 154 pWnd->OnLButtonUp(WndtoPWL(pPageView, point), nFlags); | 154 pWnd->OnLButtonUp(WndtoPWL(pPageView, point), nFlags); |
| 155 return TRUE; | 155 return TRUE; |
| 156 } | 156 } |
| 157 | 157 |
| 158 FX_BOOL CFFL_FormFiller::OnLButtonDblClk(CPDFSDK_PageView* pPageView, | 158 FX_BOOL CFFL_FormFiller::OnLButtonDblClk(CPDFSDK_PageView* pPageView, |
| 159 CPDFSDK_Annot* pAnnot, | 159 CPDFSDK_Annot* pAnnot, |
| 160 FX_UINT nFlags, | 160 unsigned int nFlags, |
| 161 const CFX_FloatPoint& point) { | 161 const CFX_FloatPoint& point) { |
| 162 CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE); | 162 CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE); |
| 163 if (!pWnd) | 163 if (!pWnd) |
| 164 return FALSE; | 164 return FALSE; |
| 165 | 165 |
| 166 pWnd->OnLButtonDblClk(WndtoPWL(pPageView, point), nFlags); | 166 pWnd->OnLButtonDblClk(WndtoPWL(pPageView, point), nFlags); |
| 167 return TRUE; | 167 return TRUE; |
| 168 } | 168 } |
| 169 | 169 |
| 170 FX_BOOL CFFL_FormFiller::OnMouseMove(CPDFSDK_PageView* pPageView, | 170 FX_BOOL CFFL_FormFiller::OnMouseMove(CPDFSDK_PageView* pPageView, |
| 171 CPDFSDK_Annot* pAnnot, | 171 CPDFSDK_Annot* pAnnot, |
| 172 FX_UINT nFlags, | 172 unsigned int nFlags, |
| 173 const CFX_FloatPoint& point) { | 173 const CFX_FloatPoint& point) { |
| 174 if (m_ptOldPos != point) | 174 if (m_ptOldPos != point) |
| 175 m_ptOldPos = point; | 175 m_ptOldPos = point; |
| 176 | 176 |
| 177 CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE); | 177 CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE); |
| 178 if (!pWnd) | 178 if (!pWnd) |
| 179 return FALSE; | 179 return FALSE; |
| 180 | 180 |
| 181 pWnd->OnMouseMove(WndtoPWL(pPageView, point), nFlags); | 181 pWnd->OnMouseMove(WndtoPWL(pPageView, point), nFlags); |
| 182 return TRUE; | 182 return TRUE; |
| 183 } | 183 } |
| 184 | 184 |
| 185 FX_BOOL CFFL_FormFiller::OnMouseWheel(CPDFSDK_PageView* pPageView, | 185 FX_BOOL CFFL_FormFiller::OnMouseWheel(CPDFSDK_PageView* pPageView, |
| 186 CPDFSDK_Annot* pAnnot, | 186 CPDFSDK_Annot* pAnnot, |
| 187 FX_UINT nFlags, | 187 unsigned int nFlags, |
| 188 short zDelta, | 188 short zDelta, |
| 189 const CFX_FloatPoint& point) { | 189 const CFX_FloatPoint& point) { |
| 190 if (!IsValid()) | 190 if (!IsValid()) |
| 191 return FALSE; | 191 return FALSE; |
| 192 | 192 |
| 193 CPWL_Wnd* pWnd = GetPDFWindow(pPageView, TRUE); | 193 CPWL_Wnd* pWnd = GetPDFWindow(pPageView, TRUE); |
| 194 return pWnd && pWnd->OnMouseWheel(zDelta, WndtoPWL(pPageView, point), nFlags); | 194 return pWnd && pWnd->OnMouseWheel(zDelta, WndtoPWL(pPageView, point), nFlags); |
| 195 } | 195 } |
| 196 | 196 |
| 197 FX_BOOL CFFL_FormFiller::OnRButtonDown(CPDFSDK_PageView* pPageView, | 197 FX_BOOL CFFL_FormFiller::OnRButtonDown(CPDFSDK_PageView* pPageView, |
| 198 CPDFSDK_Annot* pAnnot, | 198 CPDFSDK_Annot* pAnnot, |
| 199 FX_UINT nFlags, | 199 unsigned int nFlags, |
| 200 const CFX_FloatPoint& point) { | 200 const CFX_FloatPoint& point) { |
| 201 CPWL_Wnd* pWnd = GetPDFWindow(pPageView, TRUE); | 201 CPWL_Wnd* pWnd = GetPDFWindow(pPageView, TRUE); |
| 202 if (!pWnd) | 202 if (!pWnd) |
| 203 return FALSE; | 203 return FALSE; |
| 204 | 204 |
| 205 pWnd->OnRButtonDown(WndtoPWL(pPageView, point), nFlags); | 205 pWnd->OnRButtonDown(WndtoPWL(pPageView, point), nFlags); |
| 206 return TRUE; | 206 return TRUE; |
| 207 } | 207 } |
| 208 | 208 |
| 209 FX_BOOL CFFL_FormFiller::OnRButtonUp(CPDFSDK_PageView* pPageView, | 209 FX_BOOL CFFL_FormFiller::OnRButtonUp(CPDFSDK_PageView* pPageView, |
| 210 CPDFSDK_Annot* pAnnot, | 210 CPDFSDK_Annot* pAnnot, |
| 211 FX_UINT nFlags, | 211 unsigned int nFlags, |
| 212 const CFX_FloatPoint& point) { | 212 const CFX_FloatPoint& point) { |
| 213 CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE); | 213 CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE); |
| 214 if (!pWnd) | 214 if (!pWnd) |
| 215 return FALSE; | 215 return FALSE; |
| 216 | 216 |
| 217 pWnd->OnRButtonUp(WndtoPWL(pPageView, point), nFlags); | 217 pWnd->OnRButtonUp(WndtoPWL(pPageView, point), nFlags); |
| 218 return TRUE; | 218 return TRUE; |
| 219 } | 219 } |
| 220 | 220 |
| 221 FX_BOOL CFFL_FormFiller::OnKeyDown(CPDFSDK_Annot* pAnnot, | 221 FX_BOOL CFFL_FormFiller::OnKeyDown(CPDFSDK_Annot* pAnnot, |
| 222 FX_UINT nKeyCode, | 222 unsigned int nKeyCode, |
| 223 FX_UINT nFlags) { | 223 unsigned int nFlags) { |
| 224 if (IsValid()) { | 224 if (IsValid()) { |
| 225 CPDFSDK_PageView* pPageView = GetCurPageView(true); | 225 CPDFSDK_PageView* pPageView = GetCurPageView(true); |
| 226 ASSERT(pPageView); | 226 ASSERT(pPageView); |
| 227 | 227 |
| 228 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE)) { | 228 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE)) { |
| 229 return pWnd->OnKeyDown(nKeyCode, nFlags); | 229 return pWnd->OnKeyDown(nKeyCode, nFlags); |
| 230 } | 230 } |
| 231 } | 231 } |
| 232 | 232 |
| 233 return FALSE; | 233 return FALSE; |
| 234 } | 234 } |
| 235 | 235 |
| 236 FX_BOOL CFFL_FormFiller::OnChar(CPDFSDK_Annot* pAnnot, | 236 FX_BOOL CFFL_FormFiller::OnChar(CPDFSDK_Annot* pAnnot, |
| 237 FX_UINT nChar, | 237 unsigned int nChar, |
| 238 FX_UINT nFlags) { | 238 unsigned int nFlags) { |
| 239 if (IsValid()) { | 239 if (IsValid()) { |
| 240 CPDFSDK_PageView* pPageView = GetCurPageView(true); | 240 CPDFSDK_PageView* pPageView = GetCurPageView(true); |
| 241 ASSERT(pPageView); | 241 ASSERT(pPageView); |
| 242 | 242 |
| 243 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE)) { | 243 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE)) { |
| 244 return pWnd->OnChar(nChar, nFlags); | 244 return pWnd->OnChar(nChar, nFlags); |
| 245 } | 245 } |
| 246 } | 246 } |
| 247 | 247 |
| 248 return FALSE; | 248 return FALSE; |
| 249 } | 249 } |
| 250 | 250 |
| 251 void CFFL_FormFiller::SetFocusForAnnot(CPDFSDK_Annot* pAnnot, FX_UINT nFlag) { | 251 void CFFL_FormFiller::SetFocusForAnnot(CPDFSDK_Annot* pAnnot, |
| 252 unsigned int nFlag) { |
| 252 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; | 253 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; |
| 253 UnderlyingPageType* pPage = pWidget->GetUnderlyingPage(); | 254 UnderlyingPageType* pPage = pWidget->GetUnderlyingPage(); |
| 254 CPDFSDK_Document* pDoc = m_pApp->GetSDKDocument(); | 255 CPDFSDK_Document* pDoc = m_pApp->GetSDKDocument(); |
| 255 CPDFSDK_PageView* pPageView = pDoc->GetPageView(pPage, true); | 256 CPDFSDK_PageView* pPageView = pDoc->GetPageView(pPage, true); |
| 256 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, TRUE)) | 257 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, TRUE)) |
| 257 pWnd->SetFocus(); | 258 pWnd->SetFocus(); |
| 258 | 259 |
| 259 m_bValid = TRUE; | 260 m_bValid = TRUE; |
| 260 FX_RECT rcRect = GetViewBBox(pPageView, pAnnot); | 261 FX_RECT rcRect = GetViewBBox(pPageView, pAnnot); |
| 261 InvalidateRect(rcRect.left, rcRect.top, rcRect.right, rcRect.bottom); | 262 InvalidateRect(rcRect.left, rcRect.top, rcRect.right, rcRect.bottom); |
| 262 } | 263 } |
| 263 | 264 |
| 264 void CFFL_FormFiller::KillFocusForAnnot(CPDFSDK_Annot* pAnnot, FX_UINT nFlag) { | 265 void CFFL_FormFiller::KillFocusForAnnot(CPDFSDK_Annot* pAnnot, |
| 266 unsigned int nFlag) { |
| 265 if (!IsValid()) | 267 if (!IsValid()) |
| 266 return; | 268 return; |
| 267 | 269 |
| 268 CPDFSDK_PageView* pPageView = GetCurPageView(false); | 270 CPDFSDK_PageView* pPageView = GetCurPageView(false); |
| 269 if (!pPageView) | 271 if (!pPageView) |
| 270 return; | 272 return; |
| 271 | 273 |
| 272 CommitData(pPageView, nFlag); | 274 CommitData(pPageView, nFlag); |
| 273 | 275 |
| 274 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE)) | 276 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE)) |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 514 const CFX_FloatPoint& pt) { | 516 const CFX_FloatPoint& pt) { |
| 515 return FFLtoPWL(pt); | 517 return FFLtoPWL(pt); |
| 516 } | 518 } |
| 517 | 519 |
| 518 CFX_FloatRect CFFL_FormFiller::FFLtoWnd(CPDFSDK_PageView* pPageView, | 520 CFX_FloatRect CFFL_FormFiller::FFLtoWnd(CPDFSDK_PageView* pPageView, |
| 519 const CFX_FloatRect& rect) { | 521 const CFX_FloatRect& rect) { |
| 520 return rect; | 522 return rect; |
| 521 } | 523 } |
| 522 | 524 |
| 523 FX_BOOL CFFL_FormFiller::CommitData(CPDFSDK_PageView* pPageView, | 525 FX_BOOL CFFL_FormFiller::CommitData(CPDFSDK_PageView* pPageView, |
| 524 FX_UINT nFlag) { | 526 unsigned int nFlag) { |
| 525 if (IsDataChanged(pPageView)) { | 527 if (IsDataChanged(pPageView)) { |
| 526 FX_BOOL bRC = TRUE; | 528 FX_BOOL bRC = TRUE; |
| 527 FX_BOOL bExit = FALSE; | 529 FX_BOOL bExit = FALSE; |
| 528 CFFL_IFormFiller* pIFormFiller = m_pApp->GetIFormFiller(); | 530 CFFL_IFormFiller* pIFormFiller = m_pApp->GetIFormFiller(); |
| 529 pIFormFiller->OnKeyStrokeCommit(m_pWidget, pPageView, bRC, bExit, nFlag); | 531 pIFormFiller->OnKeyStrokeCommit(m_pWidget, pPageView, bRC, bExit, nFlag); |
| 530 if (bExit) | 532 if (bExit) |
| 531 return TRUE; | 533 return TRUE; |
| 532 if (!bRC) { | 534 if (!bRC) { |
| 533 ResetPDFWindow(pPageView, FALSE); | 535 ResetPDFWindow(pPageView, FALSE); |
| 534 return TRUE; | 536 return TRUE; |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 635 m_bMouseIn = FALSE; | 637 m_bMouseIn = FALSE; |
| 636 | 638 |
| 637 FX_RECT rect = GetViewBBox(pPageView, pAnnot); | 639 FX_RECT rect = GetViewBBox(pPageView, pAnnot); |
| 638 InvalidateRect(rect.left, rect.top, rect.right, rect.bottom); | 640 InvalidateRect(rect.left, rect.top, rect.right, rect.bottom); |
| 639 EndTimer(); | 641 EndTimer(); |
| 640 ASSERT(m_pWidget); | 642 ASSERT(m_pWidget); |
| 641 } | 643 } |
| 642 | 644 |
| 643 FX_BOOL CFFL_Button::OnLButtonDown(CPDFSDK_PageView* pPageView, | 645 FX_BOOL CFFL_Button::OnLButtonDown(CPDFSDK_PageView* pPageView, |
| 644 CPDFSDK_Annot* pAnnot, | 646 CPDFSDK_Annot* pAnnot, |
| 645 FX_UINT nFlags, | 647 unsigned int nFlags, |
| 646 const CFX_FloatPoint& point) { | 648 const CFX_FloatPoint& point) { |
| 647 CFX_FloatRect rcAnnot = pAnnot->GetRect(); | 649 CFX_FloatRect rcAnnot = pAnnot->GetRect(); |
| 648 if (!rcAnnot.Contains(point.x, point.y)) | 650 if (!rcAnnot.Contains(point.x, point.y)) |
| 649 return FALSE; | 651 return FALSE; |
| 650 | 652 |
| 651 m_bMouseDown = TRUE; | 653 m_bMouseDown = TRUE; |
| 652 m_bValid = TRUE; | 654 m_bValid = TRUE; |
| 653 FX_RECT rect = GetViewBBox(pPageView, pAnnot); | 655 FX_RECT rect = GetViewBBox(pPageView, pAnnot); |
| 654 InvalidateRect(rect.left, rect.top, rect.right, rect.bottom); | 656 InvalidateRect(rect.left, rect.top, rect.right, rect.bottom); |
| 655 return TRUE; | 657 return TRUE; |
| 656 } | 658 } |
| 657 | 659 |
| 658 FX_BOOL CFFL_Button::OnLButtonUp(CPDFSDK_PageView* pPageView, | 660 FX_BOOL CFFL_Button::OnLButtonUp(CPDFSDK_PageView* pPageView, |
| 659 CPDFSDK_Annot* pAnnot, | 661 CPDFSDK_Annot* pAnnot, |
| 660 FX_UINT nFlags, | 662 unsigned int nFlags, |
| 661 const CFX_FloatPoint& point) { | 663 const CFX_FloatPoint& point) { |
| 662 CFX_FloatRect rcAnnot = pAnnot->GetRect(); | 664 CFX_FloatRect rcAnnot = pAnnot->GetRect(); |
| 663 if (!rcAnnot.Contains(point.x, point.y)) | 665 if (!rcAnnot.Contains(point.x, point.y)) |
| 664 return FALSE; | 666 return FALSE; |
| 665 | 667 |
| 666 m_bMouseDown = FALSE; | 668 m_bMouseDown = FALSE; |
| 667 m_pWidget->GetPDFPage(); | 669 m_pWidget->GetPDFPage(); |
| 668 | 670 |
| 669 FX_RECT rect = GetViewBBox(pPageView, pAnnot); | 671 FX_RECT rect = GetViewBBox(pPageView, pAnnot); |
| 670 InvalidateRect(rect.left, rect.top, rect.right, rect.bottom); | 672 InvalidateRect(rect.left, rect.top, rect.right, rect.bottom); |
| 671 return TRUE; | 673 return TRUE; |
| 672 } | 674 } |
| 673 | 675 |
| 674 FX_BOOL CFFL_Button::OnMouseMove(CPDFSDK_PageView* pPageView, | 676 FX_BOOL CFFL_Button::OnMouseMove(CPDFSDK_PageView* pPageView, |
| 675 CPDFSDK_Annot* pAnnot, | 677 CPDFSDK_Annot* pAnnot, |
| 676 FX_UINT nFlags, | 678 unsigned int nFlags, |
| 677 const CFX_FloatPoint& point) { | 679 const CFX_FloatPoint& point) { |
| 678 ASSERT(m_pApp); | 680 ASSERT(m_pApp); |
| 679 | 681 |
| 680 return TRUE; | 682 return TRUE; |
| 681 } | 683 } |
| 682 | 684 |
| 683 void CFFL_Button::OnDraw(CPDFSDK_PageView* pPageView, | 685 void CFFL_Button::OnDraw(CPDFSDK_PageView* pPageView, |
| 684 CPDFSDK_Annot* pAnnot, | 686 CPDFSDK_Annot* pAnnot, |
| 685 CFX_RenderDevice* pDevice, | 687 CFX_RenderDevice* pDevice, |
| 686 CFX_Matrix* pUser2Device) { | 688 CFX_Matrix* pUser2Device) { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 711 pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, nullptr); | 713 pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, nullptr); |
| 712 } | 714 } |
| 713 } | 715 } |
| 714 | 716 |
| 715 void CFFL_Button::OnDrawDeactive(CPDFSDK_PageView* pPageView, | 717 void CFFL_Button::OnDrawDeactive(CPDFSDK_PageView* pPageView, |
| 716 CPDFSDK_Annot* pAnnot, | 718 CPDFSDK_Annot* pAnnot, |
| 717 CFX_RenderDevice* pDevice, | 719 CFX_RenderDevice* pDevice, |
| 718 CFX_Matrix* pUser2Device) { | 720 CFX_Matrix* pUser2Device) { |
| 719 OnDraw(pPageView, pAnnot, pDevice, pUser2Device); | 721 OnDraw(pPageView, pAnnot, pDevice, pUser2Device); |
| 720 } | 722 } |
| OLD | NEW |