| 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 "fpdfsdk/formfiller/cba_fontmap.h" | 10 #include "fpdfsdk/formfiller/cba_fontmap.h" |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 return TRUE; | 213 return TRUE; |
| 214 } | 214 } |
| 215 | 215 |
| 216 return FALSE; | 216 return FALSE; |
| 217 } | 217 } |
| 218 | 218 |
| 219 FX_BOOL CFFL_FormFiller::OnKeyDown(CPDFSDK_Annot* pAnnot, | 219 FX_BOOL CFFL_FormFiller::OnKeyDown(CPDFSDK_Annot* pAnnot, |
| 220 FX_UINT nKeyCode, | 220 FX_UINT nKeyCode, |
| 221 FX_UINT nFlags) { | 221 FX_UINT nFlags) { |
| 222 if (IsValid()) { | 222 if (IsValid()) { |
| 223 CPDFSDK_PageView* pPageView = GetCurPageView(); | 223 CPDFSDK_PageView* pPageView = GetCurPageView(true); |
| 224 ASSERT(pPageView); | 224 ASSERT(pPageView); |
| 225 | 225 |
| 226 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE)) { | 226 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE)) { |
| 227 return pWnd->OnKeyDown(nKeyCode, nFlags); | 227 return pWnd->OnKeyDown(nKeyCode, nFlags); |
| 228 } | 228 } |
| 229 } | 229 } |
| 230 | 230 |
| 231 return FALSE; | 231 return FALSE; |
| 232 } | 232 } |
| 233 | 233 |
| 234 FX_BOOL CFFL_FormFiller::OnChar(CPDFSDK_Annot* pAnnot, | 234 FX_BOOL CFFL_FormFiller::OnChar(CPDFSDK_Annot* pAnnot, |
| 235 FX_UINT nChar, | 235 FX_UINT nChar, |
| 236 FX_UINT nFlags) { | 236 FX_UINT nFlags) { |
| 237 if (IsValid()) { | 237 if (IsValid()) { |
| 238 CPDFSDK_PageView* pPageView = GetCurPageView(); | 238 CPDFSDK_PageView* pPageView = GetCurPageView(true); |
| 239 ASSERT(pPageView); | 239 ASSERT(pPageView); |
| 240 | 240 |
| 241 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE)) { | 241 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE)) { |
| 242 return pWnd->OnChar(nChar, nFlags); | 242 return pWnd->OnChar(nChar, nFlags); |
| 243 } | 243 } |
| 244 } | 244 } |
| 245 | 245 |
| 246 return FALSE; | 246 return FALSE; |
| 247 } | 247 } |
| 248 | 248 |
| 249 void CFFL_FormFiller::SetFocusForAnnot(CPDFSDK_Annot* pAnnot, FX_UINT nFlag) { | 249 void CFFL_FormFiller::SetFocusForAnnot(CPDFSDK_Annot* pAnnot, FX_UINT nFlag) { |
| 250 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; | 250 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; |
| 251 UnderlyingPageType* pPage = pWidget->GetUnderlyingPage(); | 251 UnderlyingPageType* pPage = pWidget->GetUnderlyingPage(); |
| 252 CPDFSDK_Document* pDoc = m_pApp->GetSDKDocument(); | 252 CPDFSDK_Document* pDoc = m_pApp->GetSDKDocument(); |
| 253 CPDFSDK_PageView* pPageView = pDoc->GetPageView(pPage); | 253 CPDFSDK_PageView* pPageView = pDoc->GetPageView(pPage, true); |
| 254 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, TRUE)) | 254 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, TRUE)) |
| 255 pWnd->SetFocus(); | 255 pWnd->SetFocus(); |
| 256 | 256 |
| 257 m_bValid = TRUE; | 257 m_bValid = TRUE; |
| 258 FX_RECT rcRect = GetViewBBox(pPageView, pAnnot); | 258 FX_RECT rcRect = GetViewBBox(pPageView, pAnnot); |
| 259 InvalidateRect(rcRect.left, rcRect.top, rcRect.right, rcRect.bottom); | 259 InvalidateRect(rcRect.left, rcRect.top, rcRect.right, rcRect.bottom); |
| 260 } | 260 } |
| 261 | 261 |
| 262 void CFFL_FormFiller::KillFocusForAnnot(CPDFSDK_Annot* pAnnot, FX_UINT nFlag) { | 262 void CFFL_FormFiller::KillFocusForAnnot(CPDFSDK_Annot* pAnnot, FX_UINT nFlag) { |
| 263 if (!IsValid()) | 263 if (!IsValid()) |
| 264 return; | 264 return; |
| 265 | 265 |
| 266 CPDFSDK_PageView* pPageView = GetCurPageView(); | 266 CPDFSDK_PageView* pPageView = GetCurPageView(false); |
| 267 if (!pPageView) | 267 if (!pPageView) |
| 268 return; | 268 return; |
| 269 | 269 |
| 270 CommitData(pPageView, nFlag); | 270 CommitData(pPageView, nFlag); |
| 271 | 271 |
| 272 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE)) | 272 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE)) |
| 273 pWnd->KillFocus(); | 273 pWnd->KillFocus(); |
| 274 | 274 |
| 275 FX_BOOL bDestroyPDFWindow; | 275 FX_BOOL bDestroyPDFWindow; |
| 276 switch (m_pWidget->GetFieldType()) { | 276 switch (m_pWidget->GetFieldType()) { |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 449 m_pWidget->GetPDFAnnot()->GetRect(rectAnnot); | 449 m_pWidget->GetPDFAnnot()->GetRect(rectAnnot); |
| 450 | 450 |
| 451 FX_FLOAT fWidth = rectAnnot.right - rectAnnot.left; | 451 FX_FLOAT fWidth = rectAnnot.right - rectAnnot.left; |
| 452 FX_FLOAT fHeight = rectAnnot.top - rectAnnot.bottom; | 452 FX_FLOAT fHeight = rectAnnot.top - rectAnnot.bottom; |
| 453 if ((m_pWidget->GetRotate() / 90) & 0x01) | 453 if ((m_pWidget->GetRotate() / 90) & 0x01) |
| 454 return CFX_FloatRect(0, 0, fHeight, fWidth); | 454 return CFX_FloatRect(0, 0, fHeight, fWidth); |
| 455 | 455 |
| 456 return CFX_FloatRect(0, 0, fWidth, fHeight); | 456 return CFX_FloatRect(0, 0, fWidth, fHeight); |
| 457 } | 457 } |
| 458 | 458 |
| 459 CPDFSDK_PageView* CFFL_FormFiller::GetCurPageView() { | 459 CPDFSDK_PageView* CFFL_FormFiller::GetCurPageView(bool renew) { |
| 460 UnderlyingPageType* pPage = m_pAnnot->GetUnderlyingPage(); | 460 UnderlyingPageType* pPage = m_pAnnot->GetUnderlyingPage(); |
| 461 CPDFSDK_Document* pSDKDoc = m_pApp->GetSDKDocument(); | 461 CPDFSDK_Document* pSDKDoc = m_pApp->GetSDKDocument(); |
| 462 return pSDKDoc ? pSDKDoc->GetPageView(pPage) : nullptr; | 462 return pSDKDoc ? pSDKDoc->GetPageView(pPage, renew) : nullptr; |
| 463 } | 463 } |
| 464 | 464 |
| 465 CFX_FloatRect CFFL_FormFiller::GetFocusBox(CPDFSDK_PageView* pPageView) { | 465 CFX_FloatRect CFFL_FormFiller::GetFocusBox(CPDFSDK_PageView* pPageView) { |
| 466 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE)) { | 466 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE)) { |
| 467 CFX_FloatRect rcFocus = FFLtoWnd(pPageView, PWLtoFFL(pWnd->GetFocusRect())); | 467 CFX_FloatRect rcFocus = FFLtoWnd(pPageView, PWLtoFFL(pWnd->GetFocusRect())); |
| 468 CFX_FloatRect rcPage = pPageView->GetPDFPage()->GetPageBBox(); | 468 CFX_FloatRect rcPage = pPageView->GetPDFPage()->GetPageBBox(); |
| 469 if (rcPage.Contains(rcFocus)) | 469 if (rcPage.Contains(rcFocus)) |
| 470 return rcFocus; | 470 return rcFocus; |
| 471 } | 471 } |
| 472 return CFX_FloatRect(0, 0, 0, 0); | 472 return CFX_FloatRect(0, 0, 0, 0); |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 713 } | 713 } |
| 714 } | 714 } |
| 715 | 715 |
| 716 void CFFL_Button::OnDrawDeactive(CPDFSDK_PageView* pPageView, | 716 void CFFL_Button::OnDrawDeactive(CPDFSDK_PageView* pPageView, |
| 717 CPDFSDK_Annot* pAnnot, | 717 CPDFSDK_Annot* pAnnot, |
| 718 CFX_RenderDevice* pDevice, | 718 CFX_RenderDevice* pDevice, |
| 719 CFX_Matrix* pUser2Device, | 719 CFX_Matrix* pUser2Device, |
| 720 uint32_t dwFlags) { | 720 uint32_t dwFlags) { |
| 721 OnDraw(pPageView, pAnnot, pDevice, pUser2Device, dwFlags); | 721 OnDraw(pPageView, pAnnot, pDevice, pUser2Device, dwFlags); |
| 722 } | 722 } |
| OLD | NEW |