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