| 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/include/cpdfsdk_annothandlermgr.h" | 7 #include "fpdfsdk/include/cpdfsdk_annothandlermgr.h" |
| 8 | 8 |
| 9 #include "core/fpdfdoc/include/cpdf_annot.h" | 9 #include "core/fpdfdoc/include/cpdf_annot.h" |
| 10 #include "fpdfsdk/include/cba_annotiterator.h" | 10 #include "fpdfsdk/include/cba_annotiterator.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 void CPDFSDK_AnnotHandlerMgr::UnRegisterAnnotHandler( | 46 void CPDFSDK_AnnotHandlerMgr::UnRegisterAnnotHandler( |
| 47 IPDFSDK_AnnotHandler* pAnnotHandler) { | 47 IPDFSDK_AnnotHandler* pAnnotHandler) { |
| 48 m_mapType2Handler.erase(pAnnotHandler->GetType()); | 48 m_mapType2Handler.erase(pAnnotHandler->GetType()); |
| 49 } | 49 } |
| 50 | 50 |
| 51 CPDFSDK_Annot* CPDFSDK_AnnotHandlerMgr::NewAnnot(CPDF_Annot* pAnnot, | 51 CPDFSDK_Annot* CPDFSDK_AnnotHandlerMgr::NewAnnot(CPDF_Annot* pAnnot, |
| 52 CPDFSDK_PageView* pPageView) { | 52 CPDFSDK_PageView* pPageView) { |
| 53 ASSERT(pPageView); | 53 ASSERT(pPageView); |
| 54 | 54 |
| 55 if (IPDFSDK_AnnotHandler* pAnnotHandler = | 55 if (IPDFSDK_AnnotHandler* pAnnotHandler = |
| 56 GetAnnotHandler(pAnnot->GetSubType())) { | 56 GetAnnotHandler(pAnnot->GetSubtype())) { |
| 57 return pAnnotHandler->NewAnnot(pAnnot, pPageView); | 57 return pAnnotHandler->NewAnnot(pAnnot, pPageView); |
| 58 } | 58 } |
| 59 | 59 |
| 60 return new CPDFSDK_BAAnnot(pAnnot, pPageView); | 60 return new CPDFSDK_BAAnnot(pAnnot, pPageView); |
| 61 } | 61 } |
| 62 | 62 |
| 63 #ifdef PDF_ENABLE_XFA | 63 #ifdef PDF_ENABLE_XFA |
| 64 CPDFSDK_Annot* CPDFSDK_AnnotHandlerMgr::NewAnnot(CXFA_FFWidget* pAnnot, | 64 CPDFSDK_Annot* CPDFSDK_AnnotHandlerMgr::NewAnnot(CXFA_FFWidget* pAnnot, |
| 65 CPDFSDK_PageView* pPageView) { | 65 CPDFSDK_PageView* pPageView) { |
| 66 ASSERT(pAnnot); | 66 ASSERT(pAnnot); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 ASSERT(pAnnot); | 99 ASSERT(pAnnot); |
| 100 | 100 |
| 101 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) | 101 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) |
| 102 pAnnotHandler->OnLoad(pAnnot); | 102 pAnnotHandler->OnLoad(pAnnot); |
| 103 } | 103 } |
| 104 | 104 |
| 105 IPDFSDK_AnnotHandler* CPDFSDK_AnnotHandlerMgr::GetAnnotHandler( | 105 IPDFSDK_AnnotHandler* CPDFSDK_AnnotHandlerMgr::GetAnnotHandler( |
| 106 CPDFSDK_Annot* pAnnot) const { | 106 CPDFSDK_Annot* pAnnot) const { |
| 107 CPDF_Annot* pPDFAnnot = pAnnot->GetPDFAnnot(); | 107 CPDF_Annot* pPDFAnnot = pAnnot->GetPDFAnnot(); |
| 108 if (pPDFAnnot) | 108 if (pPDFAnnot) |
| 109 return GetAnnotHandler(pPDFAnnot->GetSubType()); | 109 return GetAnnotHandler(pPDFAnnot->GetSubtype()); |
| 110 #ifdef PDF_ENABLE_XFA | 110 #ifdef PDF_ENABLE_XFA |
| 111 if (pAnnot->GetXFAWidget()) | 111 if (pAnnot->GetXFAWidget()) |
| 112 return GetAnnotHandler(FSDK_XFAWIDGET_TYPENAME); | 112 return GetAnnotHandler(FSDK_XFAWIDGET_TYPENAME); |
| 113 #endif // PDF_ENABLE_XFA | 113 #endif // PDF_ENABLE_XFA |
| 114 return nullptr; | 114 return nullptr; |
| 115 } | 115 } |
| 116 | 116 |
| 117 IPDFSDK_AnnotHandler* CPDFSDK_AnnotHandlerMgr::GetAnnotHandler( | 117 IPDFSDK_AnnotHandler* CPDFSDK_AnnotHandlerMgr::GetAnnotHandler( |
| 118 const CFX_ByteString& sType) const { | 118 const CFX_ByteString& sType) const { |
| 119 auto it = m_mapType2Handler.find(sType); | 119 auto it = m_mapType2Handler.find(sType); |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 } | 352 } |
| 353 | 353 |
| 354 CPDFSDK_Annot* CPDFSDK_AnnotHandlerMgr::GetNextAnnot(CPDFSDK_Annot* pSDKAnnot, | 354 CPDFSDK_Annot* CPDFSDK_AnnotHandlerMgr::GetNextAnnot(CPDFSDK_Annot* pSDKAnnot, |
| 355 FX_BOOL bNext) { | 355 FX_BOOL bNext) { |
| 356 #ifdef PDF_ENABLE_XFA | 356 #ifdef PDF_ENABLE_XFA |
| 357 CPDFSDK_PageView* pPageView = pSDKAnnot->GetPageView(); | 357 CPDFSDK_PageView* pPageView = pSDKAnnot->GetPageView(); |
| 358 CPDFXFA_Page* pPage = pPageView->GetPDFXFAPage(); | 358 CPDFXFA_Page* pPage = pPageView->GetPDFXFAPage(); |
| 359 if (!pPage) | 359 if (!pPage) |
| 360 return nullptr; | 360 return nullptr; |
| 361 if (pPage->GetPDFPage()) { // for pdf annots. | 361 if (pPage->GetPDFPage()) { // for pdf annots. |
| 362 CBA_AnnotIterator ai(pSDKAnnot->GetPageView(), pSDKAnnot->GetType(), ""); | 362 CBA_AnnotIterator ai(pSDKAnnot->GetPageView(), |
| 363 pSDKAnnot->GetAnnotSubtype()); |
| 363 CPDFSDK_Annot* pNext = | 364 CPDFSDK_Annot* pNext = |
| 364 bNext ? ai.GetNextAnnot(pSDKAnnot) : ai.GetPrevAnnot(pSDKAnnot); | 365 bNext ? ai.GetNextAnnot(pSDKAnnot) : ai.GetPrevAnnot(pSDKAnnot); |
| 365 return pNext; | 366 return pNext; |
| 366 } | 367 } |
| 367 // for xfa annots | 368 // for xfa annots |
| 368 std::unique_ptr<IXFA_WidgetIterator> pWidgetIterator( | 369 std::unique_ptr<IXFA_WidgetIterator> pWidgetIterator( |
| 369 pPage->GetXFAPageView()->CreateWidgetIterator( | 370 pPage->GetXFAPageView()->CreateWidgetIterator( |
| 370 XFA_TRAVERSEWAY_Tranvalse, XFA_WidgetStatus_Visible | | 371 XFA_TRAVERSEWAY_Tranvalse, XFA_WidgetStatus_Visible | |
| 371 XFA_WidgetStatus_Viewable | | 372 XFA_WidgetStatus_Viewable | |
| 372 XFA_WidgetStatus_Focused)); | 373 XFA_WidgetStatus_Focused)); |
| 373 if (!pWidgetIterator) | 374 if (!pWidgetIterator) |
| 374 return nullptr; | 375 return nullptr; |
| 375 if (pWidgetIterator->GetCurrentWidget() != pSDKAnnot->GetXFAWidget()) | 376 if (pWidgetIterator->GetCurrentWidget() != pSDKAnnot->GetXFAWidget()) |
| 376 pWidgetIterator->SetCurrentWidget(pSDKAnnot->GetXFAWidget()); | 377 pWidgetIterator->SetCurrentWidget(pSDKAnnot->GetXFAWidget()); |
| 377 CXFA_FFWidget* hNextFocus = | 378 CXFA_FFWidget* hNextFocus = |
| 378 bNext ? pWidgetIterator->MoveToNext() : pWidgetIterator->MoveToPrevious(); | 379 bNext ? pWidgetIterator->MoveToNext() : pWidgetIterator->MoveToPrevious(); |
| 379 if (!hNextFocus && pSDKAnnot) | 380 if (!hNextFocus && pSDKAnnot) |
| 380 hNextFocus = pWidgetIterator->MoveToFirst(); | 381 hNextFocus = pWidgetIterator->MoveToFirst(); |
| 381 | 382 |
| 382 return pPageView->GetAnnotByXFAWidget(hNextFocus); | 383 return pPageView->GetAnnotByXFAWidget(hNextFocus); |
| 383 #else // PDF_ENABLE_XFA | 384 #else // PDF_ENABLE_XFA |
| 384 CBA_AnnotIterator ai(pSDKAnnot->GetPageView(), "Widget", ""); | 385 CBA_AnnotIterator ai(pSDKAnnot->GetPageView(), "Widget"); |
| 385 return bNext ? ai.GetNextAnnot(pSDKAnnot) : ai.GetPrevAnnot(pSDKAnnot); | 386 return bNext ? ai.GetNextAnnot(pSDKAnnot) : ai.GetPrevAnnot(pSDKAnnot); |
| 386 #endif // PDF_ENABLE_XFA | 387 #endif // PDF_ENABLE_XFA |
| 387 } | 388 } |
| OLD | NEW |