dsinclair | f34518b | 2016-09-13 12:03:48 -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_pageview.h" |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 8 | |
thestig | 7c292e0 | 2016-09-28 14:14:26 -0700 | [diff] [blame] | 9 | #include <memory> |
| 10 | #include <vector> |
| 11 | |
dsinclair | 488b7ad | 2016-10-04 11:55:50 -0700 | [diff] [blame] | 12 | #include "core/fpdfapi/parser/cpdf_document.h" |
dsinclair | 69d9c68 | 2016-10-04 12:18:35 -0700 | [diff] [blame] | 13 | #include "core/fpdfapi/render/cpdf_renderoptions.h" |
dsinclair | 1727aee | 2016-09-29 13:12:56 -0700 | [diff] [blame] | 14 | #include "core/fpdfdoc/cpdf_annotlist.h" |
| 15 | #include "core/fpdfdoc/cpdf_interform.h" |
dsinclair | 114e46a | 2016-09-29 17:18:21 -0700 | [diff] [blame] | 16 | #include "fpdfsdk/cpdfsdk_annot.h" |
| 17 | #include "fpdfsdk/cpdfsdk_annothandlermgr.h" |
tsepez | d805eec | 2017-01-11 14:03:54 -0800 | [diff] [blame] | 18 | #include "fpdfsdk/cpdfsdk_annotiteration.h" |
dsinclair | 735606d | 2016-10-05 15:47:02 -0700 | [diff] [blame] | 19 | #include "fpdfsdk/cpdfsdk_formfillenvironment.h" |
dsinclair | 114e46a | 2016-09-29 17:18:21 -0700 | [diff] [blame] | 20 | #include "fpdfsdk/cpdfsdk_interform.h" |
tsepez | 36eb4bd | 2016-10-03 15:24:27 -0700 | [diff] [blame] | 21 | #include "third_party/base/ptr_util.h" |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 22 | |
| 23 | #ifdef PDF_ENABLE_XFA |
dsinclair | 4d29e78 | 2016-10-04 14:02:47 -0700 | [diff] [blame] | 24 | #include "fpdfsdk/fpdfxfa/cpdfxfa_page.h" |
Dan Sinclair | 80c4878 | 2017-03-23 12:11:20 -0400 | [diff] [blame] | 25 | #include "xfa/fxfa/cxfa_ffdocview.h" |
| 26 | #include "xfa/fxfa/cxfa_ffpageview.h" |
| 27 | #include "xfa/fxfa/cxfa_ffwidgethandler.h" |
| 28 | #include "xfa/fxfa/cxfa_rendercontext.h" |
dsinclair | 202ad72 | 2016-09-29 17:41:42 -0700 | [diff] [blame] | 29 | #include "xfa/fxgraphics/cfx_graphics.h" |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 30 | #endif // PDF_ENABLE_XFA |
| 31 | |
dsinclair | b402b17 | 2016-10-11 09:26:32 -0700 | [diff] [blame] | 32 | CPDFSDK_PageView::CPDFSDK_PageView(CPDFSDK_FormFillEnvironment* pFormFillEnv, |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 33 | UnderlyingPageType* page) |
| 34 | : m_page(page), |
dsinclair | b402b17 | 2016-10-11 09:26:32 -0700 | [diff] [blame] | 35 | m_pFormFillEnv(pFormFillEnv), |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 36 | #ifndef PDF_ENABLE_XFA |
| 37 | m_bOwnsPage(false), |
| 38 | #endif // PDF_ENABLE_XFA |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 39 | m_bEnterWidget(false), |
| 40 | m_bExitWidget(false), |
| 41 | m_bOnWidget(false), |
| 42 | m_bValid(false), |
| 43 | m_bLocked(false), |
dsinclair | bcf4623 | 2016-10-03 13:02:27 -0700 | [diff] [blame] | 44 | m_bBeingDestroyed(false) { |
dsinclair | 7cbe68e | 2016-10-12 11:56:23 -0700 | [diff] [blame] | 45 | CPDFSDK_InterForm* pInterForm = pFormFillEnv->GetInterForm(); |
Lei Zhang | 222e1a4 | 2017-06-20 14:47:00 -0700 | [diff] [blame^] | 46 | CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm(); |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 47 | #ifdef PDF_ENABLE_XFA |
Lei Zhang | 222e1a4 | 2017-06-20 14:47:00 -0700 | [diff] [blame^] | 48 | if (page->GetPDFPage()) |
| 49 | pPDFInterForm->FixPageFields(page->GetPDFPage()); |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 50 | #else // PDF_ENABLE_XFA |
Lei Zhang | 222e1a4 | 2017-06-20 14:47:00 -0700 | [diff] [blame^] | 51 | pPDFInterForm->FixPageFields(page); |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 52 | m_page->SetView(this); |
| 53 | #endif // PDF_ENABLE_XFA |
| 54 | } |
| 55 | |
| 56 | CPDFSDK_PageView::~CPDFSDK_PageView() { |
| 57 | #ifndef PDF_ENABLE_XFA |
| 58 | // The call to |ReleaseAnnot| can cause the page pointed to by |m_page| to |
| 59 | // be freed, which will cause issues if we try to cleanup the pageview pointer |
| 60 | // in |m_page|. So, reset the pageview pointer before doing anything else. |
| 61 | m_page->SetView(nullptr); |
| 62 | #endif // PDF_ENABLE_XFA |
| 63 | |
dsinclair | b402b17 | 2016-10-11 09:26:32 -0700 | [diff] [blame] | 64 | CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = |
| 65 | m_pFormFillEnv->GetAnnotHandlerMgr(); |
dsinclair | 8afe15a | 2016-10-05 12:00:34 -0700 | [diff] [blame] | 66 | for (CPDFSDK_Annot* pAnnot : m_SDKAnnotArray) |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 67 | pAnnotHandlerMgr->ReleaseAnnot(pAnnot); |
| 68 | |
dsinclair | 8afe15a | 2016-10-05 12:00:34 -0700 | [diff] [blame] | 69 | m_SDKAnnotArray.clear(); |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 70 | m_pAnnotList.reset(); |
| 71 | |
| 72 | #ifndef PDF_ENABLE_XFA |
| 73 | if (m_bOwnsPage) |
| 74 | delete m_page; |
| 75 | #endif // PDF_ENABLE_XFA |
| 76 | } |
| 77 | |
| 78 | void CPDFSDK_PageView::PageView_OnDraw(CFX_RenderDevice* pDevice, |
| 79 | CFX_Matrix* pUser2Device, |
| 80 | #ifdef PDF_ENABLE_XFA |
| 81 | CPDF_RenderOptions* pOptions, |
| 82 | const FX_RECT& pClip) { |
| 83 | #else |
| 84 | CPDF_RenderOptions* pOptions) { |
| 85 | #endif // PDF_ENABLE_XFA |
| 86 | m_curMatrix = *pUser2Device; |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 87 | |
| 88 | #ifdef PDF_ENABLE_XFA |
| 89 | CPDFXFA_Page* pPage = GetPDFXFAPage(); |
| 90 | if (!pPage) |
| 91 | return; |
| 92 | |
Dan Sinclair | cdba747 | 2017-03-23 09:17:10 -0400 | [diff] [blame] | 93 | if (pPage->GetContext()->GetDocType() == XFA_DocType::Dynamic) { |
Dan Sinclair | 05df075 | 2017-03-14 14:43:42 -0400 | [diff] [blame] | 94 | CFX_RectF rectClip( |
| 95 | static_cast<float>(pClip.left), static_cast<float>(pClip.top), |
| 96 | static_cast<float>(pClip.Width()), static_cast<float>(pClip.Height())); |
Dan Sinclair | cf53b78 | 2017-05-04 14:08:01 -0400 | [diff] [blame] | 97 | |
| 98 | CFX_Graphics gs(pDevice); |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 99 | gs.SetClipRect(rectClip); |
Dan Sinclair | cf53b78 | 2017-05-04 14:08:01 -0400 | [diff] [blame] | 100 | |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 101 | CXFA_FFPageView* xfaView = pPage->GetXFAPageView(); |
Dan Sinclair | cf53b78 | 2017-05-04 14:08:01 -0400 | [diff] [blame] | 102 | CXFA_RenderContext renderContext(xfaView, rectClip, *pUser2Device); |
| 103 | renderContext.DoRender(&gs); |
| 104 | |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 105 | CXFA_FFDocView* docView = xfaView->GetDocView(); |
| 106 | if (!docView) |
| 107 | return; |
| 108 | CPDFSDK_Annot* annot = GetFocusAnnot(); |
| 109 | if (!annot) |
| 110 | return; |
| 111 | // Render the focus widget |
| 112 | docView->GetWidgetHandler()->RenderWidget(annot->GetXFAWidget(), &gs, |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 113 | pUser2Device, false); |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 114 | return; |
| 115 | } |
| 116 | #endif // PDF_ENABLE_XFA |
| 117 | |
| 118 | // for pdf/static xfa. |
tsepez | d805eec | 2017-01-11 14:03:54 -0800 | [diff] [blame] | 119 | CPDFSDK_AnnotIteration annotIteration(this, true); |
| 120 | for (const auto& pSDKAnnot : annotIteration) { |
| 121 | m_pFormFillEnv->GetAnnotHandlerMgr()->Annot_OnDraw( |
| 122 | this, pSDKAnnot.Get(), pDevice, pUser2Device, pOptions->m_bDrawAnnots); |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 123 | } |
| 124 | } |
| 125 | |
Dan Sinclair | b45ea1f | 2017-02-21 14:27:59 -0500 | [diff] [blame] | 126 | CPDFSDK_Annot* CPDFSDK_PageView::GetFXAnnotAtPoint(const CFX_PointF& point) { |
dsinclair | b402b17 | 2016-10-11 09:26:32 -0700 | [diff] [blame] | 127 | CPDFSDK_AnnotHandlerMgr* pAnnotMgr = m_pFormFillEnv->GetAnnotHandlerMgr(); |
tsepez | d805eec | 2017-01-11 14:03:54 -0800 | [diff] [blame] | 128 | CPDFSDK_AnnotIteration annotIteration(this, false); |
| 129 | for (const auto& pSDKAnnot : annotIteration) { |
| 130 | CFX_FloatRect rc = pAnnotMgr->Annot_OnGetViewBBox(this, pSDKAnnot.Get()); |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 131 | if (pSDKAnnot->GetAnnotSubtype() == CPDF_Annot::Subtype::POPUP) |
| 132 | continue; |
Dan Sinclair | b45ea1f | 2017-02-21 14:27:59 -0500 | [diff] [blame] | 133 | if (rc.Contains(point)) |
tsepez | d805eec | 2017-01-11 14:03:54 -0800 | [diff] [blame] | 134 | return pSDKAnnot.Get(); |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 135 | } |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 136 | return nullptr; |
| 137 | } |
| 138 | |
Dan Sinclair | b45ea1f | 2017-02-21 14:27:59 -0500 | [diff] [blame] | 139 | CPDFSDK_Annot* CPDFSDK_PageView::GetFXWidgetAtPoint(const CFX_PointF& point) { |
dsinclair | b402b17 | 2016-10-11 09:26:32 -0700 | [diff] [blame] | 140 | CPDFSDK_AnnotHandlerMgr* pAnnotMgr = m_pFormFillEnv->GetAnnotHandlerMgr(); |
tsepez | d805eec | 2017-01-11 14:03:54 -0800 | [diff] [blame] | 141 | CPDFSDK_AnnotIteration annotIteration(this, false); |
| 142 | for (const auto& pSDKAnnot : annotIteration) { |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 143 | bool bHitTest = pSDKAnnot->GetAnnotSubtype() == CPDF_Annot::Subtype::WIDGET; |
| 144 | #ifdef PDF_ENABLE_XFA |
| 145 | bHitTest = bHitTest || |
| 146 | pSDKAnnot->GetAnnotSubtype() == CPDF_Annot::Subtype::XFAWIDGET; |
| 147 | #endif // PDF_ENABLE_XFA |
| 148 | if (bHitTest) { |
tsepez | d805eec | 2017-01-11 14:03:54 -0800 | [diff] [blame] | 149 | pAnnotMgr->Annot_OnGetViewBBox(this, pSDKAnnot.Get()); |
Dan Sinclair | b45ea1f | 2017-02-21 14:27:59 -0500 | [diff] [blame] | 150 | if (pAnnotMgr->Annot_OnHitTest(this, pSDKAnnot.Get(), point)) |
tsepez | d805eec | 2017-01-11 14:03:54 -0800 | [diff] [blame] | 151 | return pSDKAnnot.Get(); |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 152 | } |
| 153 | } |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 154 | return nullptr; |
| 155 | } |
| 156 | |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 157 | #ifdef PDF_ENABLE_XFA |
| 158 | CPDFSDK_Annot* CPDFSDK_PageView::AddAnnot(CXFA_FFWidget* pPDFAnnot) { |
| 159 | if (!pPDFAnnot) |
| 160 | return nullptr; |
| 161 | |
| 162 | CPDFSDK_Annot* pSDKAnnot = GetAnnotByXFAWidget(pPDFAnnot); |
| 163 | if (pSDKAnnot) |
| 164 | return pSDKAnnot; |
| 165 | |
dsinclair | b402b17 | 2016-10-11 09:26:32 -0700 | [diff] [blame] | 166 | CPDFSDK_AnnotHandlerMgr* pAnnotHandler = m_pFormFillEnv->GetAnnotHandlerMgr(); |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 167 | pSDKAnnot = pAnnotHandler->NewAnnot(pPDFAnnot, this); |
| 168 | if (!pSDKAnnot) |
| 169 | return nullptr; |
| 170 | |
dsinclair | 8afe15a | 2016-10-05 12:00:34 -0700 | [diff] [blame] | 171 | m_SDKAnnotArray.push_back(pSDKAnnot); |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 172 | return pSDKAnnot; |
| 173 | } |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 174 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 175 | bool CPDFSDK_PageView::DeleteAnnot(CPDFSDK_Annot* pAnnot) { |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 176 | if (!pAnnot) |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 177 | return false; |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 178 | CPDFXFA_Page* pPage = pAnnot->GetPDFXFAPage(); |
Dan Sinclair | cdba747 | 2017-03-23 09:17:10 -0400 | [diff] [blame] | 179 | if (!pPage || (pPage->GetContext()->GetDocType() != XFA_DocType::Static && |
| 180 | pPage->GetContext()->GetDocType() != XFA_DocType::Dynamic)) { |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 181 | return false; |
Dan Sinclair | cdba747 | 2017-03-23 09:17:10 -0400 | [diff] [blame] | 182 | } |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 183 | |
| 184 | if (GetFocusAnnot() == pAnnot) |
dsinclair | 7cbe68e | 2016-10-12 11:56:23 -0700 | [diff] [blame] | 185 | m_pFormFillEnv->KillFocusAnnot(0); |
dsinclair | b402b17 | 2016-10-11 09:26:32 -0700 | [diff] [blame] | 186 | CPDFSDK_AnnotHandlerMgr* pAnnotHandler = m_pFormFillEnv->GetAnnotHandlerMgr(); |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 187 | if (pAnnotHandler) |
| 188 | pAnnotHandler->ReleaseAnnot(pAnnot); |
| 189 | |
dsinclair | 8afe15a | 2016-10-05 12:00:34 -0700 | [diff] [blame] | 190 | auto it = std::find(m_SDKAnnotArray.begin(), m_SDKAnnotArray.end(), pAnnot); |
| 191 | if (it != m_SDKAnnotArray.end()) |
| 192 | m_SDKAnnotArray.erase(it); |
tsepez | f8074ce | 2016-09-27 14:29:57 -0700 | [diff] [blame] | 193 | if (m_pCaptureWidget.Get() == pAnnot) |
| 194 | m_pCaptureWidget.Reset(); |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 195 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 196 | return true; |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 197 | } |
dsinclair | 8afe15a | 2016-10-05 12:00:34 -0700 | [diff] [blame] | 198 | #endif // PDF_ENABLE_XFA |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 199 | |
| 200 | CPDF_Document* CPDFSDK_PageView::GetPDFDocument() { |
| 201 | if (m_page) { |
| 202 | #ifdef PDF_ENABLE_XFA |
dsinclair | 521b750 | 2016-11-02 13:02:28 -0700 | [diff] [blame] | 203 | return m_page->GetContext()->GetPDFDoc(); |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 204 | #else // PDF_ENABLE_XFA |
Tom Sepez | 4cb82ee | 2017-05-22 15:15:30 -0700 | [diff] [blame] | 205 | return m_page->m_pDocument.Get(); |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 206 | #endif // PDF_ENABLE_XFA |
| 207 | } |
| 208 | return nullptr; |
| 209 | } |
| 210 | |
| 211 | CPDF_Page* CPDFSDK_PageView::GetPDFPage() const { |
| 212 | #ifdef PDF_ENABLE_XFA |
| 213 | return m_page ? m_page->GetPDFPage() : nullptr; |
| 214 | #else // PDF_ENABLE_XFA |
| 215 | return m_page; |
| 216 | #endif // PDF_ENABLE_XFA |
| 217 | } |
| 218 | |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 219 | CPDFSDK_Annot* CPDFSDK_PageView::GetAnnotByDict(CPDF_Dictionary* pDict) { |
dsinclair | 8afe15a | 2016-10-05 12:00:34 -0700 | [diff] [blame] | 220 | for (CPDFSDK_Annot* pAnnot : m_SDKAnnotArray) { |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 221 | if (pAnnot->GetPDFAnnot()->GetAnnotDict() == pDict) |
| 222 | return pAnnot; |
| 223 | } |
| 224 | return nullptr; |
| 225 | } |
| 226 | |
| 227 | #ifdef PDF_ENABLE_XFA |
| 228 | CPDFSDK_Annot* CPDFSDK_PageView::GetAnnotByXFAWidget(CXFA_FFWidget* hWidget) { |
| 229 | if (!hWidget) |
| 230 | return nullptr; |
| 231 | |
dsinclair | 8afe15a | 2016-10-05 12:00:34 -0700 | [diff] [blame] | 232 | for (CPDFSDK_Annot* pAnnot : m_SDKAnnotArray) { |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 233 | if (pAnnot->GetXFAWidget() == hWidget) |
| 234 | return pAnnot; |
| 235 | } |
| 236 | return nullptr; |
| 237 | } |
| 238 | #endif // PDF_ENABLE_XFA |
| 239 | |
Diana Gage | dce2d72 | 2017-06-20 11:17:11 -0700 | [diff] [blame] | 240 | CFX_WideString CPDFSDK_PageView::GetSelectedText() { |
| 241 | if (CPDFSDK_Annot* pAnnot = GetFocusAnnot()) { |
| 242 | CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = |
| 243 | m_pFormFillEnv->GetAnnotHandlerMgr(); |
| 244 | return pAnnotHandlerMgr->Annot_GetSelectedText(pAnnot); |
| 245 | } |
| 246 | |
| 247 | return CFX_WideString(); |
| 248 | } |
| 249 | |
Dan Sinclair | f528eee | 2017-02-14 11:52:07 -0500 | [diff] [blame] | 250 | bool CPDFSDK_PageView::OnLButtonDown(const CFX_PointF& point, uint32_t nFlag) { |
Dan Sinclair | b45ea1f | 2017-02-21 14:27:59 -0500 | [diff] [blame] | 251 | CPDFSDK_Annot::ObservedPtr pAnnot(GetFXWidgetAtPoint(point)); |
tsepez | f8074ce | 2016-09-27 14:29:57 -0700 | [diff] [blame] | 252 | if (!pAnnot) { |
dsinclair | 7cbe68e | 2016-10-12 11:56:23 -0700 | [diff] [blame] | 253 | m_pFormFillEnv->KillFocusAnnot(nFlag); |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 254 | return false; |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 255 | } |
| 256 | |
dsinclair | b402b17 | 2016-10-11 09:26:32 -0700 | [diff] [blame] | 257 | CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = |
| 258 | m_pFormFillEnv->GetAnnotHandlerMgr(); |
tsepez | f8074ce | 2016-09-27 14:29:57 -0700 | [diff] [blame] | 259 | if (!pAnnotHandlerMgr->Annot_OnLButtonDown(this, &pAnnot, nFlag, point)) |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 260 | return false; |
tsepez | f8074ce | 2016-09-27 14:29:57 -0700 | [diff] [blame] | 261 | |
| 262 | if (!pAnnot) |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 263 | return false; |
tsepez | f8074ce | 2016-09-27 14:29:57 -0700 | [diff] [blame] | 264 | |
dsinclair | 7cbe68e | 2016-10-12 11:56:23 -0700 | [diff] [blame] | 265 | m_pFormFillEnv->SetFocusAnnot(&pAnnot); |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 266 | return true; |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 267 | } |
| 268 | |
| 269 | #ifdef PDF_ENABLE_XFA |
Dan Sinclair | f528eee | 2017-02-14 11:52:07 -0500 | [diff] [blame] | 270 | bool CPDFSDK_PageView::OnRButtonDown(const CFX_PointF& point, uint32_t nFlag) { |
Dan Sinclair | b45ea1f | 2017-02-21 14:27:59 -0500 | [diff] [blame] | 271 | CPDFSDK_Annot::ObservedPtr pAnnot(GetFXWidgetAtPoint(point)); |
tsepez | f8074ce | 2016-09-27 14:29:57 -0700 | [diff] [blame] | 272 | if (!pAnnot) |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 273 | return false; |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 274 | |
dsinclair | b402b17 | 2016-10-11 09:26:32 -0700 | [diff] [blame] | 275 | CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = |
| 276 | m_pFormFillEnv->GetAnnotHandlerMgr(); |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 277 | bool ok = pAnnotHandlerMgr->Annot_OnRButtonDown(this, &pAnnot, nFlag, point); |
tsepez | f8074ce | 2016-09-27 14:29:57 -0700 | [diff] [blame] | 278 | if (!pAnnot) |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 279 | return false; |
tsepez | f8074ce | 2016-09-27 14:29:57 -0700 | [diff] [blame] | 280 | |
| 281 | if (ok) |
dsinclair | 7cbe68e | 2016-10-12 11:56:23 -0700 | [diff] [blame] | 282 | m_pFormFillEnv->SetFocusAnnot(&pAnnot); |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 283 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 284 | return true; |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 285 | } |
| 286 | |
Dan Sinclair | f528eee | 2017-02-14 11:52:07 -0500 | [diff] [blame] | 287 | bool CPDFSDK_PageView::OnRButtonUp(const CFX_PointF& point, uint32_t nFlag) { |
dsinclair | b402b17 | 2016-10-11 09:26:32 -0700 | [diff] [blame] | 288 | CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = |
| 289 | m_pFormFillEnv->GetAnnotHandlerMgr(); |
Dan Sinclair | b45ea1f | 2017-02-21 14:27:59 -0500 | [diff] [blame] | 290 | CPDFSDK_Annot::ObservedPtr pFXAnnot(GetFXWidgetAtPoint(point)); |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 291 | if (!pFXAnnot) |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 292 | return false; |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 293 | |
tsepez | f8074ce | 2016-09-27 14:29:57 -0700 | [diff] [blame] | 294 | if (pAnnotHandlerMgr->Annot_OnRButtonUp(this, &pFXAnnot, nFlag, point)) |
dsinclair | 7cbe68e | 2016-10-12 11:56:23 -0700 | [diff] [blame] | 295 | m_pFormFillEnv->SetFocusAnnot(&pFXAnnot); |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 296 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 297 | return true; |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 298 | } |
| 299 | #endif // PDF_ENABLE_XFA |
| 300 | |
Dan Sinclair | f528eee | 2017-02-14 11:52:07 -0500 | [diff] [blame] | 301 | bool CPDFSDK_PageView::OnLButtonUp(const CFX_PointF& point, uint32_t nFlag) { |
dsinclair | b402b17 | 2016-10-11 09:26:32 -0700 | [diff] [blame] | 302 | CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = |
| 303 | m_pFormFillEnv->GetAnnotHandlerMgr(); |
Dan Sinclair | b45ea1f | 2017-02-21 14:27:59 -0500 | [diff] [blame] | 304 | CPDFSDK_Annot::ObservedPtr pFXAnnot(GetFXWidgetAtPoint(point)); |
tsepez | f8074ce | 2016-09-27 14:29:57 -0700 | [diff] [blame] | 305 | CPDFSDK_Annot::ObservedPtr pFocusAnnot(GetFocusAnnot()); |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 306 | if (pFocusAnnot && pFocusAnnot != pFXAnnot) { |
| 307 | // Last focus Annot gets a chance to handle the event. |
tsepez | f8074ce | 2016-09-27 14:29:57 -0700 | [diff] [blame] | 308 | if (pAnnotHandlerMgr->Annot_OnLButtonUp(this, &pFocusAnnot, nFlag, point)) |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 309 | return true; |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 310 | } |
tsepez | f8074ce | 2016-09-27 14:29:57 -0700 | [diff] [blame] | 311 | return pFXAnnot && |
| 312 | pAnnotHandlerMgr->Annot_OnLButtonUp(this, &pFXAnnot, nFlag, point); |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 313 | } |
| 314 | |
Dan Sinclair | f528eee | 2017-02-14 11:52:07 -0500 | [diff] [blame] | 315 | bool CPDFSDK_PageView::OnMouseMove(const CFX_PointF& point, int nFlag) { |
dsinclair | b402b17 | 2016-10-11 09:26:32 -0700 | [diff] [blame] | 316 | CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = |
| 317 | m_pFormFillEnv->GetAnnotHandlerMgr(); |
Dan Sinclair | b45ea1f | 2017-02-21 14:27:59 -0500 | [diff] [blame] | 318 | CPDFSDK_Annot::ObservedPtr pFXAnnot(GetFXAnnotAtPoint(point)); |
tsepez | f8074ce | 2016-09-27 14:29:57 -0700 | [diff] [blame] | 319 | if (pFXAnnot) { |
| 320 | if (m_pCaptureWidget && m_pCaptureWidget != pFXAnnot) { |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 321 | m_bExitWidget = true; |
| 322 | m_bEnterWidget = false; |
tsepez | f8074ce | 2016-09-27 14:29:57 -0700 | [diff] [blame] | 323 | pAnnotHandlerMgr->Annot_OnMouseExit(this, &m_pCaptureWidget, nFlag); |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 324 | } |
tsepez | f8074ce | 2016-09-27 14:29:57 -0700 | [diff] [blame] | 325 | m_pCaptureWidget.Reset(pFXAnnot.Get()); |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 326 | m_bOnWidget = true; |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 327 | if (!m_bEnterWidget) { |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 328 | m_bEnterWidget = true; |
| 329 | m_bExitWidget = false; |
tsepez | f8074ce | 2016-09-27 14:29:57 -0700 | [diff] [blame] | 330 | pAnnotHandlerMgr->Annot_OnMouseEnter(this, &pFXAnnot, nFlag); |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 331 | } |
tsepez | f8074ce | 2016-09-27 14:29:57 -0700 | [diff] [blame] | 332 | pAnnotHandlerMgr->Annot_OnMouseMove(this, &pFXAnnot, nFlag, point); |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 333 | return true; |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 334 | } |
| 335 | if (m_bOnWidget) { |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 336 | m_bOnWidget = false; |
| 337 | m_bExitWidget = true; |
| 338 | m_bEnterWidget = false; |
tsepez | f8074ce | 2016-09-27 14:29:57 -0700 | [diff] [blame] | 339 | if (m_pCaptureWidget) { |
| 340 | pAnnotHandlerMgr->Annot_OnMouseExit(this, &m_pCaptureWidget, nFlag); |
| 341 | m_pCaptureWidget.Reset(); |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 342 | } |
| 343 | } |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 344 | return false; |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 345 | } |
| 346 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 347 | bool CPDFSDK_PageView::OnMouseWheel(double deltaX, |
| 348 | double deltaY, |
Dan Sinclair | f528eee | 2017-02-14 11:52:07 -0500 | [diff] [blame] | 349 | const CFX_PointF& point, |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 350 | int nFlag) { |
Dan Sinclair | b45ea1f | 2017-02-21 14:27:59 -0500 | [diff] [blame] | 351 | CPDFSDK_Annot::ObservedPtr pAnnot(GetFXWidgetAtPoint(point)); |
tsepez | f8074ce | 2016-09-27 14:29:57 -0700 | [diff] [blame] | 352 | if (!pAnnot) |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 353 | return false; |
tsepez | f8074ce | 2016-09-27 14:29:57 -0700 | [diff] [blame] | 354 | |
dsinclair | b402b17 | 2016-10-11 09:26:32 -0700 | [diff] [blame] | 355 | CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = |
| 356 | m_pFormFillEnv->GetAnnotHandlerMgr(); |
Lei Zhang | 222e1a4 | 2017-06-20 14:47:00 -0700 | [diff] [blame^] | 357 | return pAnnotHandlerMgr->Annot_OnMouseWheel(this, &pAnnot, nFlag, |
| 358 | static_cast<int>(deltaY), point); |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 359 | } |
| 360 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 361 | bool CPDFSDK_PageView::OnChar(int nChar, uint32_t nFlag) { |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 362 | if (CPDFSDK_Annot* pAnnot = GetFocusAnnot()) { |
dsinclair | b402b17 | 2016-10-11 09:26:32 -0700 | [diff] [blame] | 363 | CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = |
| 364 | m_pFormFillEnv->GetAnnotHandlerMgr(); |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 365 | return pAnnotHandlerMgr->Annot_OnChar(pAnnot, nChar, nFlag); |
| 366 | } |
| 367 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 368 | return false; |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 369 | } |
| 370 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 371 | bool CPDFSDK_PageView::OnKeyDown(int nKeyCode, int nFlag) { |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 372 | if (CPDFSDK_Annot* pAnnot = GetFocusAnnot()) { |
dsinclair | b402b17 | 2016-10-11 09:26:32 -0700 | [diff] [blame] | 373 | CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = |
| 374 | m_pFormFillEnv->GetAnnotHandlerMgr(); |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 375 | return pAnnotHandlerMgr->Annot_OnKeyDown(pAnnot, nKeyCode, nFlag); |
| 376 | } |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 377 | return false; |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 378 | } |
| 379 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 380 | bool CPDFSDK_PageView::OnKeyUp(int nKeyCode, int nFlag) { |
| 381 | return false; |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 382 | } |
| 383 | |
| 384 | void CPDFSDK_PageView::LoadFXAnnots() { |
dsinclair | b402b17 | 2016-10-11 09:26:32 -0700 | [diff] [blame] | 385 | CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = |
| 386 | m_pFormFillEnv->GetAnnotHandlerMgr(); |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 387 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 388 | SetLock(true); |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 389 | |
| 390 | #ifdef PDF_ENABLE_XFA |
| 391 | CFX_RetainPtr<CPDFXFA_Page> protector(m_page); |
Dan Sinclair | cdba747 | 2017-03-23 09:17:10 -0400 | [diff] [blame] | 392 | if (m_pFormFillEnv->GetXFAContext()->GetDocType() == XFA_DocType::Dynamic) { |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 393 | CXFA_FFPageView* pageView = m_page->GetXFAPageView(); |
| 394 | std::unique_ptr<IXFA_WidgetIterator> pWidgetHander( |
| 395 | pageView->CreateWidgetIterator( |
| 396 | XFA_TRAVERSEWAY_Form, |
| 397 | XFA_WidgetStatus_Visible | XFA_WidgetStatus_Viewable)); |
| 398 | if (!pWidgetHander) { |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 399 | SetLock(false); |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 400 | return; |
| 401 | } |
| 402 | |
| 403 | while (CXFA_FFWidget* pXFAAnnot = pWidgetHander->MoveToNext()) { |
| 404 | CPDFSDK_Annot* pAnnot = pAnnotHandlerMgr->NewAnnot(pXFAAnnot, this); |
| 405 | if (!pAnnot) |
| 406 | continue; |
dsinclair | 8afe15a | 2016-10-05 12:00:34 -0700 | [diff] [blame] | 407 | m_SDKAnnotArray.push_back(pAnnot); |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 408 | pAnnotHandlerMgr->Annot_OnLoad(pAnnot); |
| 409 | } |
| 410 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 411 | SetLock(false); |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 412 | return; |
| 413 | } |
| 414 | #endif // PDF_ENABLE_XFA |
| 415 | |
| 416 | CPDF_Page* pPage = GetPDFPage(); |
| 417 | ASSERT(pPage); |
thestig | 7c292e0 | 2016-09-28 14:14:26 -0700 | [diff] [blame] | 418 | bool bUpdateAP = CPDF_InterForm::IsUpdateAPEnabled(); |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 419 | // Disable the default AP construction. |
thestig | 7c292e0 | 2016-09-28 14:14:26 -0700 | [diff] [blame] | 420 | CPDF_InterForm::SetUpdateAP(false); |
tsepez | 36eb4bd | 2016-10-03 15:24:27 -0700 | [diff] [blame] | 421 | m_pAnnotList = pdfium::MakeUnique<CPDF_AnnotList>(pPage); |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 422 | CPDF_InterForm::SetUpdateAP(bUpdateAP); |
| 423 | |
| 424 | const size_t nCount = m_pAnnotList->Count(); |
| 425 | for (size_t i = 0; i < nCount; ++i) { |
| 426 | CPDF_Annot* pPDFAnnot = m_pAnnotList->GetAt(i); |
| 427 | CheckUnSupportAnnot(GetPDFDocument(), pPDFAnnot); |
| 428 | CPDFSDK_Annot* pAnnot = pAnnotHandlerMgr->NewAnnot(pPDFAnnot, this); |
| 429 | if (!pAnnot) |
| 430 | continue; |
dsinclair | 8afe15a | 2016-10-05 12:00:34 -0700 | [diff] [blame] | 431 | m_SDKAnnotArray.push_back(pAnnot); |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 432 | pAnnotHandlerMgr->Annot_OnLoad(pAnnot); |
| 433 | } |
| 434 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 435 | SetLock(false); |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 436 | } |
| 437 | |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 438 | void CPDFSDK_PageView::UpdateRects(const std::vector<CFX_FloatRect>& rects) { |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 439 | for (const auto& rc : rects) |
Dan Sinclair | 6eec1c4 | 2017-02-21 17:20:43 -0500 | [diff] [blame] | 440 | m_pFormFillEnv->Invalidate(m_page, rc.ToFxRect()); |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 441 | } |
| 442 | |
| 443 | void CPDFSDK_PageView::UpdateView(CPDFSDK_Annot* pAnnot) { |
| 444 | CFX_FloatRect rcWindow = pAnnot->GetRect(); |
Dan Sinclair | 6eec1c4 | 2017-02-21 17:20:43 -0500 | [diff] [blame] | 445 | m_pFormFillEnv->Invalidate(m_page, rcWindow.ToFxRect()); |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 446 | } |
| 447 | |
| 448 | int CPDFSDK_PageView::GetPageIndex() const { |
| 449 | if (!m_page) |
| 450 | return -1; |
| 451 | |
| 452 | #ifdef PDF_ENABLE_XFA |
Dan Sinclair | cdba747 | 2017-03-23 09:17:10 -0400 | [diff] [blame] | 453 | switch (m_page->GetContext()->GetDocType()) { |
| 454 | case XFA_DocType::Dynamic: { |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 455 | CXFA_FFPageView* pPageView = m_page->GetXFAPageView(); |
| 456 | return pPageView ? pPageView->GetPageIndex() : -1; |
| 457 | } |
Dan Sinclair | cdba747 | 2017-03-23 09:17:10 -0400 | [diff] [blame] | 458 | case XFA_DocType::Static: |
| 459 | case XFA_DocType::PDF: |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 460 | return GetPageIndexForStaticPDF(); |
| 461 | default: |
| 462 | return -1; |
| 463 | } |
| 464 | #else // PDF_ENABLE_XFA |
| 465 | return GetPageIndexForStaticPDF(); |
| 466 | #endif // PDF_ENABLE_XFA |
| 467 | } |
| 468 | |
| 469 | bool CPDFSDK_PageView::IsValidAnnot(const CPDF_Annot* p) const { |
| 470 | if (!p) |
| 471 | return false; |
| 472 | |
| 473 | const auto& annots = m_pAnnotList->All(); |
| 474 | auto it = std::find_if(annots.begin(), annots.end(), |
| 475 | [p](const std::unique_ptr<CPDF_Annot>& annot) { |
| 476 | return annot.get() == p; |
| 477 | }); |
| 478 | return it != annots.end(); |
| 479 | } |
| 480 | |
dsinclair | 8afe15a | 2016-10-05 12:00:34 -0700 | [diff] [blame] | 481 | bool CPDFSDK_PageView::IsValidSDKAnnot(const CPDFSDK_Annot* p) const { |
| 482 | if (!p) |
| 483 | return false; |
| 484 | return pdfium::ContainsValue(m_SDKAnnotArray, p); |
| 485 | } |
| 486 | |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 487 | CPDFSDK_Annot* CPDFSDK_PageView::GetFocusAnnot() { |
dsinclair | 7cbe68e | 2016-10-12 11:56:23 -0700 | [diff] [blame] | 488 | CPDFSDK_Annot* pFocusAnnot = m_pFormFillEnv->GetFocusAnnot(); |
dsinclair | 8afe15a | 2016-10-05 12:00:34 -0700 | [diff] [blame] | 489 | return IsValidSDKAnnot(pFocusAnnot) ? pFocusAnnot : nullptr; |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 490 | } |
| 491 | |
| 492 | int CPDFSDK_PageView::GetPageIndexForStaticPDF() const { |
Tom Sepez | 4cb82ee | 2017-05-22 15:15:30 -0700 | [diff] [blame] | 493 | CPDF_Dictionary* pDict = GetPDFPage()->m_pFormDict.Get(); |
dsinclair | 7cbe68e | 2016-10-12 11:56:23 -0700 | [diff] [blame] | 494 | CPDF_Document* pDoc = m_pFormFillEnv->GetPDFDocument(); |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 495 | return (pDoc && pDict) ? pDoc->GetPageIndex(pDict->GetObjNum()) : -1; |
| 496 | } |