jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 1 | // Copyright 2016 PDFium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | |
dsinclair | 114e46a | 2016-09-29 17:18:21 -0700 | [diff] [blame] | 7 | #include "fpdfsdk/cpdfsdk_annothandlermgr.h" |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 8 | |
dsinclair | 1727aee | 2016-09-29 13:12:56 -0700 | [diff] [blame] | 9 | #include "core/fpdfdoc/cpdf_annot.h" |
dsinclair | 114e46a | 2016-09-29 17:18:21 -0700 | [diff] [blame] | 10 | #include "fpdfsdk/cba_annotiterator.h" |
| 11 | #include "fpdfsdk/cpdfsdk_annot.h" |
| 12 | #include "fpdfsdk/cpdfsdk_baannot.h" |
| 13 | #include "fpdfsdk/cpdfsdk_baannothandler.h" |
| 14 | #include "fpdfsdk/cpdfsdk_datetime.h" |
dsinclair | 735606d | 2016-10-05 15:47:02 -0700 | [diff] [blame] | 15 | #include "fpdfsdk/cpdfsdk_formfillenvironment.h" |
dsinclair | 114e46a | 2016-09-29 17:18:21 -0700 | [diff] [blame] | 16 | #include "fpdfsdk/cpdfsdk_pageview.h" |
| 17 | #include "fpdfsdk/cpdfsdk_widgethandler.h" |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 18 | |
| 19 | #ifdef PDF_ENABLE_XFA |
dsinclair | 114e46a | 2016-09-29 17:18:21 -0700 | [diff] [blame] | 20 | #include "fpdfsdk/cpdfsdk_xfawidgethandler.h" |
dsinclair | 4d29e78 | 2016-10-04 14:02:47 -0700 | [diff] [blame] | 21 | #include "fpdfsdk/fpdfxfa/cpdfxfa_page.h" |
dsinclair | 5b49309 | 2016-09-29 20:20:24 -0700 | [diff] [blame] | 22 | #include "xfa/fxfa/xfa_ffpageview.h" |
| 23 | #include "xfa/fxfa/xfa_ffwidget.h" |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 24 | #endif // PDF_ENABLE_XFA |
| 25 | |
dsinclair | 735606d | 2016-10-05 15:47:02 -0700 | [diff] [blame] | 26 | CPDFSDK_AnnotHandlerMgr::CPDFSDK_AnnotHandlerMgr( |
| 27 | CPDFSDK_FormFillEnvironment* pEnv) |
jaepark | 35512aa | 2016-08-29 17:15:08 -0700 | [diff] [blame] | 28 | : m_pBAAnnotHandler(new CPDFSDK_BAAnnotHandler()), |
dsinclair | 8e0638b | 2016-09-22 11:06:02 -0700 | [diff] [blame] | 29 | m_pWidgetHandler(new CPDFSDK_WidgetHandler(pEnv)), |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 30 | #ifdef PDF_ENABLE_XFA |
dsinclair | 8e0638b | 2016-09-22 11:06:02 -0700 | [diff] [blame] | 31 | m_pXFAWidgetHandler(new CPDFSDK_XFAWidgetHandler(pEnv)), |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 32 | #endif // PDF_ENABLE_XFA |
dsinclair | 8e0638b | 2016-09-22 11:06:02 -0700 | [diff] [blame] | 33 | m_pEnv(pEnv) { |
| 34 | m_pWidgetHandler->SetFormFiller(m_pEnv->GetInteractiveFormFiller()); |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 35 | } |
| 36 | |
| 37 | CPDFSDK_AnnotHandlerMgr::~CPDFSDK_AnnotHandlerMgr() {} |
| 38 | |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 39 | CPDFSDK_Annot* CPDFSDK_AnnotHandlerMgr::NewAnnot(CPDF_Annot* pAnnot, |
| 40 | CPDFSDK_PageView* pPageView) { |
| 41 | ASSERT(pPageView); |
jaepark | 35512aa | 2016-08-29 17:15:08 -0700 | [diff] [blame] | 42 | return GetAnnotHandler(pAnnot->GetSubtype())->NewAnnot(pAnnot, pPageView); |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 43 | } |
| 44 | |
| 45 | #ifdef PDF_ENABLE_XFA |
| 46 | CPDFSDK_Annot* CPDFSDK_AnnotHandlerMgr::NewAnnot(CXFA_FFWidget* pAnnot, |
| 47 | CPDFSDK_PageView* pPageView) { |
| 48 | ASSERT(pAnnot); |
| 49 | ASSERT(pPageView); |
| 50 | |
jaepark | 956553e | 2016-08-31 06:49:27 -0700 | [diff] [blame] | 51 | return GetAnnotHandler(CPDF_Annot::Subtype::XFAWIDGET) |
| 52 | ->NewAnnot(pAnnot, pPageView); |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 53 | } |
| 54 | #endif // PDF_ENABLE_XFA |
| 55 | |
| 56 | void CPDFSDK_AnnotHandlerMgr::ReleaseAnnot(CPDFSDK_Annot* pAnnot) { |
jaepark | 35512aa | 2016-08-29 17:15:08 -0700 | [diff] [blame] | 57 | IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot); |
jaepark | 35512aa | 2016-08-29 17:15:08 -0700 | [diff] [blame] | 58 | pAnnotHandler->ReleaseAnnot(pAnnot); |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 59 | } |
| 60 | |
| 61 | void CPDFSDK_AnnotHandlerMgr::Annot_OnCreate(CPDFSDK_Annot* pAnnot) { |
| 62 | CPDF_Annot* pPDFAnnot = pAnnot->GetPDFAnnot(); |
| 63 | |
| 64 | CPDFSDK_DateTime curTime; |
dsinclair | 38fd844 | 2016-09-15 10:15:32 -0700 | [diff] [blame] | 65 | pPDFAnnot->GetAnnotDict()->SetStringFor("M", curTime.ToPDFDateTimeString()); |
| 66 | pPDFAnnot->GetAnnotDict()->SetNumberFor("F", 0); |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 67 | } |
| 68 | |
| 69 | void CPDFSDK_AnnotHandlerMgr::Annot_OnLoad(CPDFSDK_Annot* pAnnot) { |
| 70 | ASSERT(pAnnot); |
jaepark | 35512aa | 2016-08-29 17:15:08 -0700 | [diff] [blame] | 71 | GetAnnotHandler(pAnnot)->OnLoad(pAnnot); |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 72 | } |
| 73 | |
| 74 | IPDFSDK_AnnotHandler* CPDFSDK_AnnotHandlerMgr::GetAnnotHandler( |
| 75 | CPDFSDK_Annot* pAnnot) const { |
jaepark | 35512aa | 2016-08-29 17:15:08 -0700 | [diff] [blame] | 76 | return GetAnnotHandler(pAnnot->GetAnnotSubtype()); |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 77 | } |
| 78 | |
| 79 | IPDFSDK_AnnotHandler* CPDFSDK_AnnotHandlerMgr::GetAnnotHandler( |
jaepark | 956553e | 2016-08-31 06:49:27 -0700 | [diff] [blame] | 80 | CPDF_Annot::Subtype nAnnotSubtype) const { |
| 81 | if (nAnnotSubtype == CPDF_Annot::Subtype::WIDGET) |
jaepark | 8c54182 | 2016-08-30 13:43:05 -0700 | [diff] [blame] | 82 | return m_pWidgetHandler.get(); |
jaepark | 35512aa | 2016-08-29 17:15:08 -0700 | [diff] [blame] | 83 | |
| 84 | #ifdef PDF_ENABLE_XFA |
jaepark | 956553e | 2016-08-31 06:49:27 -0700 | [diff] [blame] | 85 | if (nAnnotSubtype == CPDF_Annot::Subtype::XFAWIDGET) |
jaepark | 8c54182 | 2016-08-30 13:43:05 -0700 | [diff] [blame] | 86 | return m_pXFAWidgetHandler.get(); |
jaepark | 35512aa | 2016-08-29 17:15:08 -0700 | [diff] [blame] | 87 | #endif // PDF_ENABLE_XFA |
| 88 | |
| 89 | return m_pBAAnnotHandler.get(); |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 90 | } |
| 91 | |
| 92 | void CPDFSDK_AnnotHandlerMgr::Annot_OnDraw(CPDFSDK_PageView* pPageView, |
| 93 | CPDFSDK_Annot* pAnnot, |
| 94 | CFX_RenderDevice* pDevice, |
jaepark | 75f84a5 | 2016-09-09 15:39:09 -0700 | [diff] [blame] | 95 | CFX_Matrix* pUser2Device, |
| 96 | bool bDrawAnnots) { |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 97 | ASSERT(pAnnot); |
jaepark | 75f84a5 | 2016-09-09 15:39:09 -0700 | [diff] [blame] | 98 | GetAnnotHandler(pAnnot)->OnDraw(pPageView, pAnnot, pDevice, pUser2Device, |
| 99 | bDrawAnnots); |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 100 | } |
| 101 | |
| 102 | FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnLButtonDown( |
| 103 | CPDFSDK_PageView* pPageView, |
tsepez | f8074ce | 2016-09-27 14:29:57 -0700 | [diff] [blame] | 104 | CPDFSDK_Annot::ObservedPtr* pAnnot, |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 105 | uint32_t nFlags, |
| 106 | const CFX_FloatPoint& point) { |
tsepez | f8074ce | 2016-09-27 14:29:57 -0700 | [diff] [blame] | 107 | ASSERT(*pAnnot); |
| 108 | return GetAnnotHandler(pAnnot->Get()) |
| 109 | ->OnLButtonDown(pPageView, pAnnot, nFlags, point); |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 110 | } |
| 111 | |
| 112 | FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnLButtonUp( |
| 113 | CPDFSDK_PageView* pPageView, |
tsepez | f8074ce | 2016-09-27 14:29:57 -0700 | [diff] [blame] | 114 | CPDFSDK_Annot::ObservedPtr* pAnnot, |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 115 | uint32_t nFlags, |
| 116 | const CFX_FloatPoint& point) { |
tsepez | f8074ce | 2016-09-27 14:29:57 -0700 | [diff] [blame] | 117 | ASSERT(*pAnnot); |
| 118 | return GetAnnotHandler(pAnnot->Get()) |
| 119 | ->OnLButtonUp(pPageView, pAnnot, nFlags, point); |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 120 | } |
| 121 | |
| 122 | FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnLButtonDblClk( |
| 123 | CPDFSDK_PageView* pPageView, |
tsepez | f8074ce | 2016-09-27 14:29:57 -0700 | [diff] [blame] | 124 | CPDFSDK_Annot::ObservedPtr* pAnnot, |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 125 | uint32_t nFlags, |
| 126 | const CFX_FloatPoint& point) { |
tsepez | f8074ce | 2016-09-27 14:29:57 -0700 | [diff] [blame] | 127 | ASSERT(*pAnnot); |
| 128 | return GetAnnotHandler(pAnnot->Get()) |
| 129 | ->OnLButtonDblClk(pPageView, pAnnot, nFlags, point); |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 130 | } |
| 131 | |
| 132 | FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnMouseMove( |
| 133 | CPDFSDK_PageView* pPageView, |
tsepez | f8074ce | 2016-09-27 14:29:57 -0700 | [diff] [blame] | 134 | CPDFSDK_Annot::ObservedPtr* pAnnot, |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 135 | uint32_t nFlags, |
| 136 | const CFX_FloatPoint& point) { |
tsepez | f8074ce | 2016-09-27 14:29:57 -0700 | [diff] [blame] | 137 | ASSERT(*pAnnot); |
| 138 | return GetAnnotHandler(pAnnot->Get()) |
| 139 | ->OnMouseMove(pPageView, pAnnot, nFlags, point); |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 140 | } |
| 141 | |
| 142 | FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnMouseWheel( |
| 143 | CPDFSDK_PageView* pPageView, |
tsepez | f8074ce | 2016-09-27 14:29:57 -0700 | [diff] [blame] | 144 | CPDFSDK_Annot::ObservedPtr* pAnnot, |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 145 | uint32_t nFlags, |
| 146 | short zDelta, |
| 147 | const CFX_FloatPoint& point) { |
tsepez | f8074ce | 2016-09-27 14:29:57 -0700 | [diff] [blame] | 148 | ASSERT(*pAnnot); |
| 149 | return GetAnnotHandler(pAnnot->Get()) |
| 150 | ->OnMouseWheel(pPageView, pAnnot, nFlags, zDelta, point); |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 151 | } |
| 152 | |
| 153 | FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnRButtonDown( |
| 154 | CPDFSDK_PageView* pPageView, |
tsepez | f8074ce | 2016-09-27 14:29:57 -0700 | [diff] [blame] | 155 | CPDFSDK_Annot::ObservedPtr* pAnnot, |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 156 | uint32_t nFlags, |
| 157 | const CFX_FloatPoint& point) { |
tsepez | f8074ce | 2016-09-27 14:29:57 -0700 | [diff] [blame] | 158 | ASSERT(*pAnnot); |
| 159 | return GetAnnotHandler(pAnnot->Get()) |
| 160 | ->OnRButtonDown(pPageView, pAnnot, nFlags, point); |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 161 | } |
| 162 | |
| 163 | FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnRButtonUp( |
| 164 | CPDFSDK_PageView* pPageView, |
tsepez | f8074ce | 2016-09-27 14:29:57 -0700 | [diff] [blame] | 165 | CPDFSDK_Annot::ObservedPtr* pAnnot, |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 166 | uint32_t nFlags, |
| 167 | const CFX_FloatPoint& point) { |
tsepez | f8074ce | 2016-09-27 14:29:57 -0700 | [diff] [blame] | 168 | ASSERT(*pAnnot); |
| 169 | return GetAnnotHandler(pAnnot->Get()) |
| 170 | ->OnRButtonUp(pPageView, pAnnot, nFlags, point); |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 171 | } |
| 172 | |
tsepez | f8074ce | 2016-09-27 14:29:57 -0700 | [diff] [blame] | 173 | void CPDFSDK_AnnotHandlerMgr::Annot_OnMouseEnter( |
| 174 | CPDFSDK_PageView* pPageView, |
| 175 | CPDFSDK_Annot::ObservedPtr* pAnnot, |
| 176 | uint32_t nFlag) { |
| 177 | ASSERT(*pAnnot); |
| 178 | GetAnnotHandler(pAnnot->Get())->OnMouseEnter(pPageView, pAnnot, nFlag); |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 179 | } |
| 180 | |
tsepez | f8074ce | 2016-09-27 14:29:57 -0700 | [diff] [blame] | 181 | void CPDFSDK_AnnotHandlerMgr::Annot_OnMouseExit( |
| 182 | CPDFSDK_PageView* pPageView, |
| 183 | CPDFSDK_Annot::ObservedPtr* pAnnot, |
| 184 | uint32_t nFlag) { |
| 185 | ASSERT(*pAnnot); |
| 186 | GetAnnotHandler(pAnnot->Get())->OnMouseExit(pPageView, pAnnot, nFlag); |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 187 | } |
| 188 | |
| 189 | FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnChar(CPDFSDK_Annot* pAnnot, |
| 190 | uint32_t nChar, |
| 191 | uint32_t nFlags) { |
jaepark | 35512aa | 2016-08-29 17:15:08 -0700 | [diff] [blame] | 192 | return GetAnnotHandler(pAnnot)->OnChar(pAnnot, nChar, nFlags); |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 193 | } |
| 194 | |
| 195 | FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnKeyDown(CPDFSDK_Annot* pAnnot, |
| 196 | int nKeyCode, |
| 197 | int nFlag) { |
dsinclair | 8e0638b | 2016-09-22 11:06:02 -0700 | [diff] [blame] | 198 | if (m_pEnv->IsCTRLKeyDown(nFlag) || m_pEnv->IsALTKeyDown(nFlag)) |
jaepark | 35512aa | 2016-08-29 17:15:08 -0700 | [diff] [blame] | 199 | return GetAnnotHandler(pAnnot)->OnKeyDown(pAnnot, nKeyCode, nFlag); |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 200 | |
jaepark | 35512aa | 2016-08-29 17:15:08 -0700 | [diff] [blame] | 201 | CPDFSDK_PageView* pPage = pAnnot->GetPageView(); |
| 202 | CPDFSDK_Annot* pFocusAnnot = pPage->GetFocusAnnot(); |
| 203 | if (pFocusAnnot && (nKeyCode == FWL_VKEY_Tab)) { |
tsepez | f8074ce | 2016-09-27 14:29:57 -0700 | [diff] [blame] | 204 | CPDFSDK_Annot::ObservedPtr pNext( |
| 205 | GetNextAnnot(pFocusAnnot, !m_pEnv->IsSHIFTKeyDown(nFlag))); |
| 206 | if (pNext && pNext.Get() != pFocusAnnot) { |
dsinclair | 7cbe68e | 2016-10-12 11:56:23 -0700 | [diff] [blame^] | 207 | pPage->GetFormFillEnv()->SetFocusAnnot(&pNext); |
jaepark | 35512aa | 2016-08-29 17:15:08 -0700 | [diff] [blame] | 208 | return TRUE; |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 209 | } |
| 210 | } |
| 211 | |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 212 | return FALSE; |
| 213 | } |
| 214 | |
| 215 | FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnKeyUp(CPDFSDK_Annot* pAnnot, |
| 216 | int nKeyCode, |
| 217 | int nFlag) { |
| 218 | return FALSE; |
| 219 | } |
| 220 | |
tsepez | f8074ce | 2016-09-27 14:29:57 -0700 | [diff] [blame] | 221 | FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnSetFocus( |
| 222 | CPDFSDK_Annot::ObservedPtr* pAnnot, |
| 223 | uint32_t nFlag) { |
| 224 | ASSERT(*pAnnot); |
dsinclair | b402b17 | 2016-10-11 09:26:32 -0700 | [diff] [blame] | 225 | return GetAnnotHandler(pAnnot->Get())->OnSetFocus(pAnnot, nFlag); |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 226 | } |
| 227 | |
tsepez | f8074ce | 2016-09-27 14:29:57 -0700 | [diff] [blame] | 228 | FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnKillFocus( |
| 229 | CPDFSDK_Annot::ObservedPtr* pAnnot, |
| 230 | uint32_t nFlag) { |
| 231 | ASSERT(*pAnnot); |
| 232 | return GetAnnotHandler(pAnnot->Get())->OnKillFocus(pAnnot, nFlag); |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 233 | } |
| 234 | |
| 235 | #ifdef PDF_ENABLE_XFA |
| 236 | FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnChangeFocus( |
tsepez | f8074ce | 2016-09-27 14:29:57 -0700 | [diff] [blame] | 237 | CPDFSDK_Annot::ObservedPtr* pSetAnnot, |
| 238 | CPDFSDK_Annot::ObservedPtr* pKillAnnot) { |
| 239 | FX_BOOL bXFA = (*pSetAnnot && (*pSetAnnot)->GetXFAWidget()) || |
| 240 | (*pKillAnnot && (*pKillAnnot)->GetXFAWidget()); |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 241 | |
| 242 | if (bXFA) { |
| 243 | if (IPDFSDK_AnnotHandler* pXFAAnnotHandler = |
jaepark | 956553e | 2016-08-31 06:49:27 -0700 | [diff] [blame] | 244 | GetAnnotHandler(CPDF_Annot::Subtype::XFAWIDGET)) |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 245 | return pXFAAnnotHandler->OnXFAChangedFocus(pKillAnnot, pSetAnnot); |
| 246 | } |
| 247 | |
| 248 | return TRUE; |
| 249 | } |
| 250 | #endif // PDF_ENABLE_XFA |
| 251 | |
| 252 | CFX_FloatRect CPDFSDK_AnnotHandlerMgr::Annot_OnGetViewBBox( |
| 253 | CPDFSDK_PageView* pPageView, |
| 254 | CPDFSDK_Annot* pAnnot) { |
| 255 | ASSERT(pAnnot); |
jaepark | 35512aa | 2016-08-29 17:15:08 -0700 | [diff] [blame] | 256 | return GetAnnotHandler(pAnnot)->GetViewBBox(pPageView, pAnnot); |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 257 | } |
| 258 | |
| 259 | FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnHitTest(CPDFSDK_PageView* pPageView, |
| 260 | CPDFSDK_Annot* pAnnot, |
| 261 | const CFX_FloatPoint& point) { |
| 262 | ASSERT(pAnnot); |
jaepark | 35512aa | 2016-08-29 17:15:08 -0700 | [diff] [blame] | 263 | IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot); |
| 264 | if (pAnnotHandler->CanAnswer(pAnnot)) |
| 265 | return pAnnotHandler->HitTest(pPageView, pAnnot, point); |
| 266 | |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 267 | return FALSE; |
| 268 | } |
| 269 | |
| 270 | CPDFSDK_Annot* CPDFSDK_AnnotHandlerMgr::GetNextAnnot(CPDFSDK_Annot* pSDKAnnot, |
| 271 | FX_BOOL bNext) { |
| 272 | #ifdef PDF_ENABLE_XFA |
| 273 | CPDFSDK_PageView* pPageView = pSDKAnnot->GetPageView(); |
| 274 | CPDFXFA_Page* pPage = pPageView->GetPDFXFAPage(); |
| 275 | if (!pPage) |
| 276 | return nullptr; |
| 277 | if (pPage->GetPDFPage()) { // for pdf annots. |
jaepark | 9ed9137 | 2016-08-26 16:16:10 -0700 | [diff] [blame] | 278 | CBA_AnnotIterator ai(pSDKAnnot->GetPageView(), |
| 279 | pSDKAnnot->GetAnnotSubtype()); |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 280 | CPDFSDK_Annot* pNext = |
| 281 | bNext ? ai.GetNextAnnot(pSDKAnnot) : ai.GetPrevAnnot(pSDKAnnot); |
| 282 | return pNext; |
| 283 | } |
| 284 | // for xfa annots |
| 285 | std::unique_ptr<IXFA_WidgetIterator> pWidgetIterator( |
| 286 | pPage->GetXFAPageView()->CreateWidgetIterator( |
| 287 | XFA_TRAVERSEWAY_Tranvalse, XFA_WidgetStatus_Visible | |
| 288 | XFA_WidgetStatus_Viewable | |
| 289 | XFA_WidgetStatus_Focused)); |
| 290 | if (!pWidgetIterator) |
| 291 | return nullptr; |
| 292 | if (pWidgetIterator->GetCurrentWidget() != pSDKAnnot->GetXFAWidget()) |
| 293 | pWidgetIterator->SetCurrentWidget(pSDKAnnot->GetXFAWidget()); |
| 294 | CXFA_FFWidget* hNextFocus = |
| 295 | bNext ? pWidgetIterator->MoveToNext() : pWidgetIterator->MoveToPrevious(); |
| 296 | if (!hNextFocus && pSDKAnnot) |
| 297 | hNextFocus = pWidgetIterator->MoveToFirst(); |
| 298 | |
| 299 | return pPageView->GetAnnotByXFAWidget(hNextFocus); |
| 300 | #else // PDF_ENABLE_XFA |
jaepark | 956553e | 2016-08-31 06:49:27 -0700 | [diff] [blame] | 301 | CBA_AnnotIterator ai(pSDKAnnot->GetPageView(), CPDF_Annot::Subtype::WIDGET); |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 302 | return bNext ? ai.GetNextAnnot(pSDKAnnot) : ai.GetPrevAnnot(pSDKAnnot); |
| 303 | #endif // PDF_ENABLE_XFA |
| 304 | } |