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 | |
| 7 | #include "fpdfsdk/include/cpdfsdk_annothandlermgr.h" |
| 8 | |
| 9 | #include "core/fpdfdoc/include/cpdf_annot.h" |
jaepark | 611adb8 | 2016-08-17 11:34:36 -0700 | [diff] [blame] | 10 | #include "fpdfsdk/include/cba_annotiterator.h" |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 11 | #include "fpdfsdk/include/cpdfsdk_annot.h" |
| 12 | #include "fpdfsdk/include/cpdfsdk_baannot.h" |
jaepark | 35512aa | 2016-08-29 17:15:08 -0700 | [diff] [blame] | 13 | #include "fpdfsdk/include/cpdfsdk_baannothandler.h" |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 14 | #include "fpdfsdk/include/cpdfsdk_datetime.h" |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 15 | #include "fpdfsdk/include/cpdfsdk_document.h" |
dsinclair | 79db609 | 2016-09-14 07:27:21 -0700 | [diff] [blame] | 16 | #include "fpdfsdk/include/cpdfsdk_environment.h" |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 17 | #include "fpdfsdk/include/cpdfsdk_pageview.h" |
jaepark | 8c54182 | 2016-08-30 13:43:05 -0700 | [diff] [blame] | 18 | #include "fpdfsdk/include/cpdfsdk_widgethandler.h" |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 19 | |
| 20 | #ifdef PDF_ENABLE_XFA |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 21 | #include "fpdfsdk/fpdfxfa/include/fpdfxfa_page.h" |
dsinclair | 2ca2da5 | 2016-09-13 18:10:34 -0700 | [diff] [blame] | 22 | #include "fpdfsdk/include/cpdfsdk_xfawidgethandler.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 | 79db609 | 2016-09-14 07:27:21 -0700 | [diff] [blame] | 27 | CPDFSDK_AnnotHandlerMgr::CPDFSDK_AnnotHandlerMgr(CPDFSDK_Environment* pApp) |
jaepark | 35512aa | 2016-08-29 17:15:08 -0700 | [diff] [blame] | 28 | : m_pBAAnnotHandler(new CPDFSDK_BAAnnotHandler()), |
jaepark | 8c54182 | 2016-08-30 13:43:05 -0700 | [diff] [blame] | 29 | m_pWidgetHandler(new CPDFSDK_WidgetHandler(pApp)), |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 30 | #ifdef PDF_ENABLE_XFA |
jaepark | 8c54182 | 2016-08-30 13:43:05 -0700 | [diff] [blame] | 31 | m_pXFAWidgetHandler(new CPDFSDK_XFAWidgetHandler(pApp)), |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 32 | #endif // PDF_ENABLE_XFA |
jaepark | 35512aa | 2016-08-29 17:15:08 -0700 | [diff] [blame] | 33 | m_pApp(pApp) { |
jaepark | 8c54182 | 2016-08-30 13:43:05 -0700 | [diff] [blame] | 34 | m_pWidgetHandler->SetFormFiller(m_pApp->GetIFormFiller()); |
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; |
| 66 | pPDFAnnot->GetAnnotDict()->SetAtString("M", curTime.ToPDFDateTimeString()); |
| 67 | pPDFAnnot->GetAnnotDict()->SetAtNumber("F", 0); |
| 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, |
| 107 | CPDFSDK_Annot* pAnnot, |
| 108 | uint32_t nFlags, |
| 109 | const CFX_FloatPoint& point) { |
| 110 | ASSERT(pAnnot); |
jaepark | 35512aa | 2016-08-29 17:15:08 -0700 | [diff] [blame] | 111 | return GetAnnotHandler(pAnnot)->OnLButtonDown(pPageView, pAnnot, nFlags, |
| 112 | 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, |
| 117 | CPDFSDK_Annot* pAnnot, |
| 118 | uint32_t nFlags, |
| 119 | const CFX_FloatPoint& point) { |
| 120 | ASSERT(pAnnot); |
jaepark | 35512aa | 2016-08-29 17:15:08 -0700 | [diff] [blame] | 121 | return GetAnnotHandler(pAnnot)->OnLButtonUp(pPageView, pAnnot, nFlags, point); |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 122 | } |
| 123 | |
| 124 | FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnLButtonDblClk( |
| 125 | CPDFSDK_PageView* pPageView, |
| 126 | CPDFSDK_Annot* pAnnot, |
| 127 | uint32_t nFlags, |
| 128 | const CFX_FloatPoint& point) { |
| 129 | ASSERT(pAnnot); |
jaepark | 35512aa | 2016-08-29 17:15:08 -0700 | [diff] [blame] | 130 | return GetAnnotHandler(pAnnot)->OnLButtonDblClk(pPageView, pAnnot, nFlags, |
| 131 | point); |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 132 | } |
| 133 | |
| 134 | FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnMouseMove( |
| 135 | CPDFSDK_PageView* pPageView, |
| 136 | CPDFSDK_Annot* pAnnot, |
| 137 | uint32_t nFlags, |
| 138 | const CFX_FloatPoint& point) { |
| 139 | ASSERT(pAnnot); |
jaepark | 35512aa | 2016-08-29 17:15:08 -0700 | [diff] [blame] | 140 | return GetAnnotHandler(pAnnot)->OnMouseMove(pPageView, pAnnot, nFlags, point); |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 141 | } |
| 142 | |
| 143 | FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnMouseWheel( |
| 144 | CPDFSDK_PageView* pPageView, |
| 145 | CPDFSDK_Annot* pAnnot, |
| 146 | uint32_t nFlags, |
| 147 | short zDelta, |
| 148 | const CFX_FloatPoint& point) { |
| 149 | ASSERT(pAnnot); |
jaepark | 35512aa | 2016-08-29 17:15:08 -0700 | [diff] [blame] | 150 | return GetAnnotHandler(pAnnot)->OnMouseWheel(pPageView, pAnnot, nFlags, |
| 151 | zDelta, point); |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 152 | } |
| 153 | |
| 154 | FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnRButtonDown( |
| 155 | CPDFSDK_PageView* pPageView, |
| 156 | CPDFSDK_Annot* pAnnot, |
| 157 | uint32_t nFlags, |
| 158 | const CFX_FloatPoint& point) { |
| 159 | ASSERT(pAnnot); |
jaepark | 35512aa | 2016-08-29 17:15:08 -0700 | [diff] [blame] | 160 | return GetAnnotHandler(pAnnot)->OnRButtonDown(pPageView, pAnnot, nFlags, |
| 161 | point); |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 162 | } |
| 163 | |
| 164 | FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnRButtonUp( |
| 165 | CPDFSDK_PageView* pPageView, |
| 166 | CPDFSDK_Annot* pAnnot, |
| 167 | uint32_t nFlags, |
| 168 | const CFX_FloatPoint& point) { |
| 169 | ASSERT(pAnnot); |
jaepark | 35512aa | 2016-08-29 17:15:08 -0700 | [diff] [blame] | 170 | return GetAnnotHandler(pAnnot)->OnRButtonUp(pPageView, pAnnot, nFlags, point); |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 171 | } |
| 172 | |
| 173 | void CPDFSDK_AnnotHandlerMgr::Annot_OnMouseEnter(CPDFSDK_PageView* pPageView, |
| 174 | CPDFSDK_Annot* pAnnot, |
| 175 | uint32_t nFlag) { |
| 176 | ASSERT(pAnnot); |
jaepark | 35512aa | 2016-08-29 17:15:08 -0700 | [diff] [blame] | 177 | GetAnnotHandler(pAnnot)->OnMouseEnter(pPageView, pAnnot, nFlag); |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 178 | } |
| 179 | |
| 180 | void CPDFSDK_AnnotHandlerMgr::Annot_OnMouseExit(CPDFSDK_PageView* pPageView, |
| 181 | CPDFSDK_Annot* pAnnot, |
| 182 | uint32_t nFlag) { |
| 183 | ASSERT(pAnnot); |
jaepark | 35512aa | 2016-08-29 17:15:08 -0700 | [diff] [blame] | 184 | GetAnnotHandler(pAnnot)->OnMouseExit(pPageView, pAnnot, nFlag); |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 185 | } |
| 186 | |
| 187 | FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnChar(CPDFSDK_Annot* pAnnot, |
| 188 | uint32_t nChar, |
| 189 | uint32_t nFlags) { |
jaepark | 35512aa | 2016-08-29 17:15:08 -0700 | [diff] [blame] | 190 | return GetAnnotHandler(pAnnot)->OnChar(pAnnot, nChar, nFlags); |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 191 | } |
| 192 | |
| 193 | FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnKeyDown(CPDFSDK_Annot* pAnnot, |
| 194 | int nKeyCode, |
| 195 | int nFlag) { |
dsinclair | 1f24890 | 2016-09-14 10:38:17 -0700 | [diff] [blame^] | 196 | if (m_pApp->IsCTRLKeyDown(nFlag) || m_pApp->IsALTKeyDown(nFlag)) |
jaepark | 35512aa | 2016-08-29 17:15:08 -0700 | [diff] [blame] | 197 | return GetAnnotHandler(pAnnot)->OnKeyDown(pAnnot, nKeyCode, nFlag); |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 198 | |
jaepark | 35512aa | 2016-08-29 17:15:08 -0700 | [diff] [blame] | 199 | CPDFSDK_PageView* pPage = pAnnot->GetPageView(); |
| 200 | CPDFSDK_Annot* pFocusAnnot = pPage->GetFocusAnnot(); |
| 201 | if (pFocusAnnot && (nKeyCode == FWL_VKEY_Tab)) { |
| 202 | CPDFSDK_Annot* pNext = |
dsinclair | 1f24890 | 2016-09-14 10:38:17 -0700 | [diff] [blame^] | 203 | GetNextAnnot(pFocusAnnot, !m_pApp->IsSHIFTKeyDown(nFlag)); |
jaepark | 35512aa | 2016-08-29 17:15:08 -0700 | [diff] [blame] | 204 | |
| 205 | if (pNext && pNext != pFocusAnnot) { |
| 206 | CPDFSDK_Document* pDocument = pPage->GetSDKDocument(); |
| 207 | pDocument->SetFocusAnnot(pNext); |
| 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 | |
| 221 | FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnSetFocus(CPDFSDK_Annot* pAnnot, |
| 222 | uint32_t nFlag) { |
| 223 | ASSERT(pAnnot); |
| 224 | |
jaepark | 35512aa | 2016-08-29 17:15:08 -0700 | [diff] [blame] | 225 | if (!GetAnnotHandler(pAnnot)->OnSetFocus(pAnnot, nFlag)) |
| 226 | return FALSE; |
| 227 | |
| 228 | CPDFSDK_PageView* pPage = pAnnot->GetPageView(); |
| 229 | pPage->GetSDKDocument(); |
| 230 | return TRUE; |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 231 | } |
| 232 | |
| 233 | FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnKillFocus(CPDFSDK_Annot* pAnnot, |
| 234 | uint32_t nFlag) { |
| 235 | ASSERT(pAnnot); |
jaepark | 35512aa | 2016-08-29 17:15:08 -0700 | [diff] [blame] | 236 | return GetAnnotHandler(pAnnot)->OnKillFocus(pAnnot, nFlag); |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 237 | } |
| 238 | |
| 239 | #ifdef PDF_ENABLE_XFA |
| 240 | FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnChangeFocus( |
| 241 | CPDFSDK_Annot* pSetAnnot, |
| 242 | CPDFSDK_Annot* pKillAnnot) { |
| 243 | FX_BOOL bXFA = (pSetAnnot && pSetAnnot->GetXFAWidget()) || |
| 244 | (pKillAnnot && pKillAnnot->GetXFAWidget()); |
| 245 | |
| 246 | if (bXFA) { |
| 247 | if (IPDFSDK_AnnotHandler* pXFAAnnotHandler = |
jaepark | 956553e | 2016-08-31 06:49:27 -0700 | [diff] [blame] | 248 | GetAnnotHandler(CPDF_Annot::Subtype::XFAWIDGET)) |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 249 | return pXFAAnnotHandler->OnXFAChangedFocus(pKillAnnot, pSetAnnot); |
| 250 | } |
| 251 | |
| 252 | return TRUE; |
| 253 | } |
| 254 | #endif // PDF_ENABLE_XFA |
| 255 | |
| 256 | CFX_FloatRect CPDFSDK_AnnotHandlerMgr::Annot_OnGetViewBBox( |
| 257 | CPDFSDK_PageView* pPageView, |
| 258 | CPDFSDK_Annot* pAnnot) { |
| 259 | ASSERT(pAnnot); |
jaepark | 35512aa | 2016-08-29 17:15:08 -0700 | [diff] [blame] | 260 | return GetAnnotHandler(pAnnot)->GetViewBBox(pPageView, pAnnot); |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 261 | } |
| 262 | |
| 263 | FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnHitTest(CPDFSDK_PageView* pPageView, |
| 264 | CPDFSDK_Annot* pAnnot, |
| 265 | const CFX_FloatPoint& point) { |
| 266 | ASSERT(pAnnot); |
jaepark | 35512aa | 2016-08-29 17:15:08 -0700 | [diff] [blame] | 267 | IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot); |
| 268 | if (pAnnotHandler->CanAnswer(pAnnot)) |
| 269 | return pAnnotHandler->HitTest(pPageView, pAnnot, point); |
| 270 | |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 271 | return FALSE; |
| 272 | } |
| 273 | |
| 274 | CPDFSDK_Annot* CPDFSDK_AnnotHandlerMgr::GetNextAnnot(CPDFSDK_Annot* pSDKAnnot, |
| 275 | FX_BOOL bNext) { |
| 276 | #ifdef PDF_ENABLE_XFA |
| 277 | CPDFSDK_PageView* pPageView = pSDKAnnot->GetPageView(); |
| 278 | CPDFXFA_Page* pPage = pPageView->GetPDFXFAPage(); |
| 279 | if (!pPage) |
| 280 | return nullptr; |
| 281 | if (pPage->GetPDFPage()) { // for pdf annots. |
jaepark | 9ed9137 | 2016-08-26 16:16:10 -0700 | [diff] [blame] | 282 | CBA_AnnotIterator ai(pSDKAnnot->GetPageView(), |
| 283 | pSDKAnnot->GetAnnotSubtype()); |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 284 | CPDFSDK_Annot* pNext = |
| 285 | bNext ? ai.GetNextAnnot(pSDKAnnot) : ai.GetPrevAnnot(pSDKAnnot); |
| 286 | return pNext; |
| 287 | } |
| 288 | // for xfa annots |
| 289 | std::unique_ptr<IXFA_WidgetIterator> pWidgetIterator( |
| 290 | pPage->GetXFAPageView()->CreateWidgetIterator( |
| 291 | XFA_TRAVERSEWAY_Tranvalse, XFA_WidgetStatus_Visible | |
| 292 | XFA_WidgetStatus_Viewable | |
| 293 | XFA_WidgetStatus_Focused)); |
| 294 | if (!pWidgetIterator) |
| 295 | return nullptr; |
| 296 | if (pWidgetIterator->GetCurrentWidget() != pSDKAnnot->GetXFAWidget()) |
| 297 | pWidgetIterator->SetCurrentWidget(pSDKAnnot->GetXFAWidget()); |
| 298 | CXFA_FFWidget* hNextFocus = |
| 299 | bNext ? pWidgetIterator->MoveToNext() : pWidgetIterator->MoveToPrevious(); |
| 300 | if (!hNextFocus && pSDKAnnot) |
| 301 | hNextFocus = pWidgetIterator->MoveToFirst(); |
| 302 | |
| 303 | return pPageView->GetAnnotByXFAWidget(hNextFocus); |
| 304 | #else // PDF_ENABLE_XFA |
jaepark | 956553e | 2016-08-31 06:49:27 -0700 | [diff] [blame] | 305 | CBA_AnnotIterator ai(pSDKAnnot->GetPageView(), CPDF_Annot::Subtype::WIDGET); |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 306 | return bNext ? ai.GetNextAnnot(pSDKAnnot) : ai.GetPrevAnnot(pSDKAnnot); |
| 307 | #endif // PDF_ENABLE_XFA |
| 308 | } |