| 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/page/cpdf_page.h" | 9 #include "core/fpdfapi/page/cpdf_page.h" |
| 10 #include "core/fxge/cfx_renderdevice.h" | 10 #include "core/fxge/cfx_renderdevice.h" |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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, uint32_t nFlag) { | 251 void CFFL_FormFiller::SetFocusForAnnot(CPDFSDK_Annot* pAnnot, uint32_t nFlag) { |
| 252 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; | 252 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; |
| 253 UnderlyingPageType* pPage = pWidget->GetUnderlyingPage(); | 253 UnderlyingPageType* pPage = pWidget->GetUnderlyingPage(); |
| 254 CPDFSDK_Document* pDoc = m_pEnv->GetSDKDocument(); | 254 CPDFSDK_PageView* pPageView = |
| 255 CPDFSDK_PageView* pPageView = pDoc->GetPageView(pPage, true); | 255 m_pEnv->GetSDKDocument()->GetPageView(pPage, true); |
| 256 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, TRUE)) | 256 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, TRUE)) |
| 257 pWnd->SetFocus(); | 257 pWnd->SetFocus(); |
| 258 | 258 |
| 259 m_bValid = TRUE; | 259 m_bValid = TRUE; |
| 260 FX_RECT rcRect = GetViewBBox(pPageView, pAnnot); | 260 FX_RECT rcRect = GetViewBBox(pPageView, pAnnot); |
| 261 InvalidateRect(rcRect.left, rcRect.top, rcRect.right, rcRect.bottom); | 261 InvalidateRect(rcRect.left, rcRect.top, rcRect.right, rcRect.bottom); |
| 262 } | 262 } |
| 263 | 263 |
| 264 void CFFL_FormFiller::KillFocusForAnnot(CPDFSDK_Annot* pAnnot, uint32_t nFlag) { | 264 void CFFL_FormFiller::KillFocusForAnnot(CPDFSDK_Annot* pAnnot, uint32_t nFlag) { |
| 265 if (!IsValid()) | 265 if (!IsValid()) |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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(bool renew) { | 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_pEnv->GetSDKDocument(); | 461 return m_pEnv ? m_pEnv->GetSDKDocument()->GetPageView(pPage, renew) : nullptr; |
| 462 return pSDKDoc ? pSDKDoc->GetPageView(pPage, renew) : nullptr; | |
| 463 } | 462 } |
| 464 | 463 |
| 465 CFX_FloatRect CFFL_FormFiller::GetFocusBox(CPDFSDK_PageView* pPageView) { | 464 CFX_FloatRect CFFL_FormFiller::GetFocusBox(CPDFSDK_PageView* pPageView) { |
| 466 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE)) { | 465 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE)) { |
| 467 CFX_FloatRect rcFocus = FFLtoWnd(pPageView, PWLtoFFL(pWnd->GetFocusRect())); | 466 CFX_FloatRect rcFocus = FFLtoWnd(pPageView, PWLtoFFL(pWnd->GetFocusRect())); |
| 468 CFX_FloatRect rcPage = pPageView->GetPDFPage()->GetPageBBox(); | 467 CFX_FloatRect rcPage = pPageView->GetPDFPage()->GetPageBBox(); |
| 469 if (rcPage.Contains(rcFocus)) | 468 if (rcPage.Contains(rcFocus)) |
| 470 return rcFocus; | 469 return rcFocus; |
| 471 } | 470 } |
| 472 return CFX_FloatRect(0, 0, 0, 0); | 471 return CFX_FloatRect(0, 0, 0, 0); |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 712 pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, nullptr); | 711 pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, nullptr); |
| 713 } | 712 } |
| 714 } | 713 } |
| 715 | 714 |
| 716 void CFFL_Button::OnDrawDeactive(CPDFSDK_PageView* pPageView, | 715 void CFFL_Button::OnDrawDeactive(CPDFSDK_PageView* pPageView, |
| 717 CPDFSDK_Annot* pAnnot, | 716 CPDFSDK_Annot* pAnnot, |
| 718 CFX_RenderDevice* pDevice, | 717 CFX_RenderDevice* pDevice, |
| 719 CFX_Matrix* pUser2Device) { | 718 CFX_Matrix* pUser2Device) { |
| 720 OnDraw(pPageView, pAnnot, pDevice, pUser2Device); | 719 OnDraw(pPageView, pAnnot, pDevice, pUser2Device); |
| 721 } | 720 } |
| OLD | NEW |