| OLD | NEW |
| 1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 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/cpdfsdk_annothandlermgr.h" | 7 #include "fpdfsdk/cpdfsdk_annothandlermgr.h" |
| 8 | 8 |
| 9 #include "core/fpdfdoc/cpdf_annot.h" | 9 #include "core/fpdfdoc/cpdf_annot.h" |
| 10 #include "fpdfsdk/cba_annotiterator.h" | 10 #include "fpdfsdk/cba_annotiterator.h" |
| 11 #include "fpdfsdk/cpdfsdk_annot.h" | 11 #include "fpdfsdk/cpdfsdk_annot.h" |
| 12 #include "fpdfsdk/cpdfsdk_baannot.h" | 12 #include "fpdfsdk/cpdfsdk_baannot.h" |
| 13 #include "fpdfsdk/cpdfsdk_baannothandler.h" | 13 #include "fpdfsdk/cpdfsdk_baannothandler.h" |
| 14 #include "fpdfsdk/cpdfsdk_datetime.h" | 14 #include "fpdfsdk/cpdfsdk_datetime.h" |
| 15 #include "fpdfsdk/cpdfsdk_formfillenvironment.h" | 15 #include "fpdfsdk/cpdfsdk_formfillenvironment.h" |
| 16 #include "fpdfsdk/cpdfsdk_pageview.h" | 16 #include "fpdfsdk/cpdfsdk_pageview.h" |
| 17 #include "fpdfsdk/cpdfsdk_widgethandler.h" | 17 #include "fpdfsdk/cpdfsdk_widgethandler.h" |
| 18 | 18 |
| 19 #ifdef PDF_ENABLE_XFA | 19 #ifdef PDF_ENABLE_XFA |
| 20 #include "fpdfsdk/cpdfsdk_xfawidgethandler.h" | 20 #include "fpdfsdk/cpdfsdk_xfawidgethandler.h" |
| 21 #include "fpdfsdk/fpdfxfa/cpdfxfa_page.h" | 21 #include "fpdfsdk/fpdfxfa/cpdfxfa_page.h" |
| 22 #include "xfa/fxfa/xfa_ffpageview.h" | 22 #include "xfa/fxfa/xfa_ffpageview.h" |
| 23 #include "xfa/fxfa/xfa_ffwidget.h" | 23 #include "xfa/fxfa/xfa_ffwidget.h" |
| 24 #endif // PDF_ENABLE_XFA | 24 #endif // PDF_ENABLE_XFA |
| 25 | 25 |
| 26 CPDFSDK_AnnotHandlerMgr::CPDFSDK_AnnotHandlerMgr( | 26 CPDFSDK_AnnotHandlerMgr::CPDFSDK_AnnotHandlerMgr( |
| 27 CPDFSDK_FormFillEnvironment* pEnv) | 27 CPDFSDK_FormFillEnvironment* pFormFillEnv) |
| 28 : m_pBAAnnotHandler(new CPDFSDK_BAAnnotHandler()), | 28 : m_pBAAnnotHandler(new CPDFSDK_BAAnnotHandler()), |
| 29 m_pWidgetHandler(new CPDFSDK_WidgetHandler(pEnv)), | 29 m_pWidgetHandler(new CPDFSDK_WidgetHandler(pFormFillEnv)), |
| 30 #ifdef PDF_ENABLE_XFA | 30 #ifdef PDF_ENABLE_XFA |
| 31 m_pXFAWidgetHandler(new CPDFSDK_XFAWidgetHandler(pEnv)), | 31 m_pXFAWidgetHandler(new CPDFSDK_XFAWidgetHandler(pFormFillEnv)), |
| 32 #endif // PDF_ENABLE_XFA | 32 #endif // PDF_ENABLE_XFA |
| 33 m_pEnv(pEnv) { | 33 m_pFormFillEnv(pFormFillEnv) { |
| 34 m_pWidgetHandler->SetFormFiller(m_pEnv->GetInteractiveFormFiller()); | 34 m_pWidgetHandler->SetFormFiller(m_pFormFillEnv->GetInteractiveFormFiller()); |
| 35 } | 35 } |
| 36 | 36 |
| 37 CPDFSDK_AnnotHandlerMgr::~CPDFSDK_AnnotHandlerMgr() {} | 37 CPDFSDK_AnnotHandlerMgr::~CPDFSDK_AnnotHandlerMgr() {} |
| 38 | 38 |
| 39 CPDFSDK_Annot* CPDFSDK_AnnotHandlerMgr::NewAnnot(CPDF_Annot* pAnnot, | 39 CPDFSDK_Annot* CPDFSDK_AnnotHandlerMgr::NewAnnot(CPDF_Annot* pAnnot, |
| 40 CPDFSDK_PageView* pPageView) { | 40 CPDFSDK_PageView* pPageView) { |
| 41 ASSERT(pPageView); | 41 ASSERT(pPageView); |
| 42 return GetAnnotHandler(pAnnot->GetSubtype())->NewAnnot(pAnnot, pPageView); | 42 return GetAnnotHandler(pAnnot->GetSubtype())->NewAnnot(pAnnot, pPageView); |
| 43 } | 43 } |
| 44 | 44 |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 | 191 |
| 192 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnChar(CPDFSDK_Annot* pAnnot, | 192 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnChar(CPDFSDK_Annot* pAnnot, |
| 193 uint32_t nChar, | 193 uint32_t nChar, |
| 194 uint32_t nFlags) { | 194 uint32_t nFlags) { |
| 195 return GetAnnotHandler(pAnnot)->OnChar(pAnnot, nChar, nFlags); | 195 return GetAnnotHandler(pAnnot)->OnChar(pAnnot, nChar, nFlags); |
| 196 } | 196 } |
| 197 | 197 |
| 198 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnKeyDown(CPDFSDK_Annot* pAnnot, | 198 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnKeyDown(CPDFSDK_Annot* pAnnot, |
| 199 int nKeyCode, | 199 int nKeyCode, |
| 200 int nFlag) { | 200 int nFlag) { |
| 201 if (m_pEnv->IsCTRLKeyDown(nFlag) || m_pEnv->IsALTKeyDown(nFlag)) | 201 if (m_pFormFillEnv->IsCTRLKeyDown(nFlag) || |
| 202 m_pFormFillEnv->IsALTKeyDown(nFlag)) |
| 202 return GetAnnotHandler(pAnnot)->OnKeyDown(pAnnot, nKeyCode, nFlag); | 203 return GetAnnotHandler(pAnnot)->OnKeyDown(pAnnot, nKeyCode, nFlag); |
| 203 | 204 |
| 204 CPDFSDK_PageView* pPage = pAnnot->GetPageView(); | 205 CPDFSDK_PageView* pPage = pAnnot->GetPageView(); |
| 205 CPDFSDK_Annot* pFocusAnnot = pPage->GetFocusAnnot(); | 206 CPDFSDK_Annot* pFocusAnnot = pPage->GetFocusAnnot(); |
| 206 if (pFocusAnnot && (nKeyCode == FWL_VKEY_Tab)) { | 207 if (pFocusAnnot && (nKeyCode == FWL_VKEY_Tab)) { |
| 207 CPDFSDK_Annot::ObservedPtr pNext( | 208 CPDFSDK_Annot::ObservedPtr pNext( |
| 208 GetNextAnnot(pFocusAnnot, !m_pEnv->IsSHIFTKeyDown(nFlag))); | 209 GetNextAnnot(pFocusAnnot, !m_pFormFillEnv->IsSHIFTKeyDown(nFlag))); |
| 209 if (pNext && pNext.Get() != pFocusAnnot) { | 210 if (pNext && pNext.Get() != pFocusAnnot) { |
| 210 pPage->GetFormFillEnv()->SetFocusAnnot(&pNext); | 211 pPage->GetFormFillEnv()->SetFocusAnnot(&pNext); |
| 211 return TRUE; | 212 return TRUE; |
| 212 } | 213 } |
| 213 } | 214 } |
| 214 | 215 |
| 215 return FALSE; | 216 return FALSE; |
| 216 } | 217 } |
| 217 | 218 |
| 218 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnKeyUp(CPDFSDK_Annot* pAnnot, | 219 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnKeyUp(CPDFSDK_Annot* pAnnot, |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 bNext ? pWidgetIterator->MoveToNext() : pWidgetIterator->MoveToPrevious(); | 299 bNext ? pWidgetIterator->MoveToNext() : pWidgetIterator->MoveToPrevious(); |
| 299 if (!hNextFocus && pSDKAnnot) | 300 if (!hNextFocus && pSDKAnnot) |
| 300 hNextFocus = pWidgetIterator->MoveToFirst(); | 301 hNextFocus = pWidgetIterator->MoveToFirst(); |
| 301 | 302 |
| 302 return pPageView->GetAnnotByXFAWidget(hNextFocus); | 303 return pPageView->GetAnnotByXFAWidget(hNextFocus); |
| 303 #else // PDF_ENABLE_XFA | 304 #else // PDF_ENABLE_XFA |
| 304 CBA_AnnotIterator ai(pSDKAnnot->GetPageView(), CPDF_Annot::Subtype::WIDGET); | 305 CBA_AnnotIterator ai(pSDKAnnot->GetPageView(), CPDF_Annot::Subtype::WIDGET); |
| 305 return bNext ? ai.GetNextAnnot(pSDKAnnot) : ai.GetPrevAnnot(pSDKAnnot); | 306 return bNext ? ai.GetNextAnnot(pSDKAnnot) : ai.GetPrevAnnot(pSDKAnnot); |
| 306 #endif // PDF_ENABLE_XFA | 307 #endif // PDF_ENABLE_XFA |
| 307 } | 308 } |
| OLD | NEW |