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