| OLD | NEW |
| 1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #include "fpdfsdk/cpdfsdk_pageview.h" | 7 #include "fpdfsdk/cpdfsdk_pageview.h" |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 m_pSDKDoc(pSDKDoc), | 35 m_pSDKDoc(pSDKDoc), |
| 36 #ifndef PDF_ENABLE_XFA | 36 #ifndef PDF_ENABLE_XFA |
| 37 m_bOwnsPage(false), | 37 m_bOwnsPage(false), |
| 38 #endif // PDF_ENABLE_XFA | 38 #endif // PDF_ENABLE_XFA |
| 39 m_bEnterWidget(FALSE), | 39 m_bEnterWidget(FALSE), |
| 40 m_bExitWidget(FALSE), | 40 m_bExitWidget(FALSE), |
| 41 m_bOnWidget(FALSE), | 41 m_bOnWidget(FALSE), |
| 42 m_bValid(FALSE), | 42 m_bValid(FALSE), |
| 43 m_bLocked(FALSE), | 43 m_bLocked(FALSE), |
| 44 m_bBeingDestroyed(false) { | 44 m_bBeingDestroyed(false) { |
| 45 CPDFSDK_InterForm* pInterForm = pSDKDoc->GetInterForm(); | 45 CPDFSDK_InterForm* pInterForm = pSDKDoc->GetEnv()->GetInterForm(); |
| 46 if (pInterForm) { | 46 if (pInterForm) { |
| 47 CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm(); | 47 CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm(); |
| 48 #ifdef PDF_ENABLE_XFA | 48 #ifdef PDF_ENABLE_XFA |
| 49 if (page->GetPDFPage()) | 49 if (page->GetPDFPage()) |
| 50 pPDFInterForm->FixPageFields(page->GetPDFPage()); | 50 pPDFInterForm->FixPageFields(page->GetPDFPage()); |
| 51 #else // PDF_ENABLE_XFA | 51 #else // PDF_ENABLE_XFA |
| 52 pPDFInterForm->FixPageFields(page); | 52 pPDFInterForm->FixPageFields(page); |
| 53 #endif // PDF_ENABLE_XFA | 53 #endif // PDF_ENABLE_XFA |
| 54 } | 54 } |
| 55 #ifndef PDF_ENABLE_XFA | 55 #ifndef PDF_ENABLE_XFA |
| 56 m_page->SetView(this); | 56 m_page->SetView(this); |
| 57 #endif // PDF_ENABLE_XFA | 57 #endif // PDF_ENABLE_XFA |
| 58 } | 58 } |
| 59 | 59 |
| 60 CPDFSDK_PageView::~CPDFSDK_PageView() { | 60 CPDFSDK_PageView::~CPDFSDK_PageView() { |
| 61 #ifndef PDF_ENABLE_XFA | 61 #ifndef PDF_ENABLE_XFA |
| 62 // The call to |ReleaseAnnot| can cause the page pointed to by |m_page| to | 62 // The call to |ReleaseAnnot| can cause the page pointed to by |m_page| to |
| 63 // be freed, which will cause issues if we try to cleanup the pageview pointer | 63 // be freed, which will cause issues if we try to cleanup the pageview pointer |
| 64 // in |m_page|. So, reset the pageview pointer before doing anything else. | 64 // in |m_page|. So, reset the pageview pointer before doing anything else. |
| 65 m_page->SetView(nullptr); | 65 m_page->SetView(nullptr); |
| 66 #endif // PDF_ENABLE_XFA | 66 #endif // PDF_ENABLE_XFA |
| 67 | 67 |
| 68 CPDFSDK_FormFillEnvironment* pEnv = m_pSDKDoc->GetEnv(); | 68 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = |
| 69 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); | 69 m_pSDKDoc->GetEnv()->GetAnnotHandlerMgr(); |
| 70 |
| 70 for (CPDFSDK_Annot* pAnnot : m_SDKAnnotArray) | 71 for (CPDFSDK_Annot* pAnnot : m_SDKAnnotArray) |
| 71 pAnnotHandlerMgr->ReleaseAnnot(pAnnot); | 72 pAnnotHandlerMgr->ReleaseAnnot(pAnnot); |
| 72 | 73 |
| 73 m_SDKAnnotArray.clear(); | 74 m_SDKAnnotArray.clear(); |
| 74 m_pAnnotList.reset(); | 75 m_pAnnotList.reset(); |
| 75 | 76 |
| 76 #ifndef PDF_ENABLE_XFA | 77 #ifndef PDF_ENABLE_XFA |
| 77 if (m_bOwnsPage) | 78 if (m_bOwnsPage) |
| 78 delete m_page; | 79 delete m_page; |
| 79 #endif // PDF_ENABLE_XFA | 80 #endif // PDF_ENABLE_XFA |
| 80 } | 81 } |
| 81 | 82 |
| 82 void CPDFSDK_PageView::PageView_OnDraw(CFX_RenderDevice* pDevice, | 83 void CPDFSDK_PageView::PageView_OnDraw(CFX_RenderDevice* pDevice, |
| 83 CFX_Matrix* pUser2Device, | 84 CFX_Matrix* pUser2Device, |
| 84 #ifdef PDF_ENABLE_XFA | 85 #ifdef PDF_ENABLE_XFA |
| 85 CPDF_RenderOptions* pOptions, | 86 CPDF_RenderOptions* pOptions, |
| 86 const FX_RECT& pClip) { | 87 const FX_RECT& pClip) { |
| 87 #else | 88 #else |
| 88 CPDF_RenderOptions* pOptions) { | 89 CPDF_RenderOptions* pOptions) { |
| 89 #endif // PDF_ENABLE_XFA | 90 #endif // PDF_ENABLE_XFA |
| 90 m_curMatrix = *pUser2Device; | 91 m_curMatrix = *pUser2Device; |
| 91 CPDFSDK_FormFillEnvironment* pEnv = m_pSDKDoc->GetEnv(); | 92 CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pSDKDoc->GetEnv(); |
| 92 | 93 |
| 93 #ifdef PDF_ENABLE_XFA | 94 #ifdef PDF_ENABLE_XFA |
| 94 CPDFXFA_Page* pPage = GetPDFXFAPage(); | 95 CPDFXFA_Page* pPage = GetPDFXFAPage(); |
| 95 if (!pPage) | 96 if (!pPage) |
| 96 return; | 97 return; |
| 97 | 98 |
| 98 if (pPage->GetDocument()->GetDocType() == DOCTYPE_DYNAMIC_XFA) { | 99 if (pPage->GetDocument()->GetDocType() == DOCTYPE_DYNAMIC_XFA) { |
| 99 CFX_Graphics gs; | 100 CFX_Graphics gs; |
| 100 gs.Create(pDevice); | 101 gs.Create(pDevice); |
| 101 CFX_RectF rectClip; | 102 CFX_RectF rectClip; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 120 // Render the focus widget | 121 // Render the focus widget |
| 121 docView->GetWidgetHandler()->RenderWidget(annot->GetXFAWidget(), &gs, | 122 docView->GetWidgetHandler()->RenderWidget(annot->GetXFAWidget(), &gs, |
| 122 pUser2Device, FALSE); | 123 pUser2Device, FALSE); |
| 123 return; | 124 return; |
| 124 } | 125 } |
| 125 #endif // PDF_ENABLE_XFA | 126 #endif // PDF_ENABLE_XFA |
| 126 | 127 |
| 127 // for pdf/static xfa. | 128 // for pdf/static xfa. |
| 128 CPDFSDK_AnnotIterator annotIterator(this, true); | 129 CPDFSDK_AnnotIterator annotIterator(this, true); |
| 129 while (CPDFSDK_Annot* pSDKAnnot = annotIterator.Next()) { | 130 while (CPDFSDK_Annot* pSDKAnnot = annotIterator.Next()) { |
| 130 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); | 131 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = |
| 132 pFormFillEnv->GetAnnotHandlerMgr(); |
| 131 pAnnotHandlerMgr->Annot_OnDraw(this, pSDKAnnot, pDevice, pUser2Device, | 133 pAnnotHandlerMgr->Annot_OnDraw(this, pSDKAnnot, pDevice, pUser2Device, |
| 132 pOptions->m_bDrawAnnots); | 134 pOptions->m_bDrawAnnots); |
| 133 } | 135 } |
| 134 } | 136 } |
| 135 | 137 |
| 136 CPDFSDK_Annot* CPDFSDK_PageView::GetFXAnnotAtPoint(FX_FLOAT pageX, | 138 CPDFSDK_Annot* CPDFSDK_PageView::GetFXAnnotAtPoint(FX_FLOAT pageX, |
| 137 FX_FLOAT pageY) { | 139 FX_FLOAT pageY) { |
| 138 CPDFSDK_FormFillEnvironment* pEnv = m_pSDKDoc->GetEnv(); | 140 CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pSDKDoc->GetEnv(); |
| 139 CPDFSDK_AnnotHandlerMgr* pAnnotMgr = pEnv->GetAnnotHandlerMgr(); | 141 CPDFSDK_AnnotHandlerMgr* pAnnotMgr = pFormFillEnv->GetAnnotHandlerMgr(); |
| 140 CPDFSDK_AnnotIterator annotIterator(this, false); | 142 CPDFSDK_AnnotIterator annotIterator(this, false); |
| 141 while (CPDFSDK_Annot* pSDKAnnot = annotIterator.Next()) { | 143 while (CPDFSDK_Annot* pSDKAnnot = annotIterator.Next()) { |
| 142 CFX_FloatRect rc = pAnnotMgr->Annot_OnGetViewBBox(this, pSDKAnnot); | 144 CFX_FloatRect rc = pAnnotMgr->Annot_OnGetViewBBox(this, pSDKAnnot); |
| 143 if (pSDKAnnot->GetAnnotSubtype() == CPDF_Annot::Subtype::POPUP) | 145 if (pSDKAnnot->GetAnnotSubtype() == CPDF_Annot::Subtype::POPUP) |
| 144 continue; | 146 continue; |
| 145 if (rc.Contains(pageX, pageY)) | 147 if (rc.Contains(pageX, pageY)) |
| 146 return pSDKAnnot; | 148 return pSDKAnnot; |
| 147 } | 149 } |
| 148 | 150 |
| 149 return nullptr; | 151 return nullptr; |
| 150 } | 152 } |
| 151 | 153 |
| 152 CPDFSDK_Annot* CPDFSDK_PageView::GetFXWidgetAtPoint(FX_FLOAT pageX, | 154 CPDFSDK_Annot* CPDFSDK_PageView::GetFXWidgetAtPoint(FX_FLOAT pageX, |
| 153 FX_FLOAT pageY) { | 155 FX_FLOAT pageY) { |
| 154 CPDFSDK_FormFillEnvironment* pEnv = m_pSDKDoc->GetEnv(); | 156 CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pSDKDoc->GetEnv(); |
| 155 CPDFSDK_AnnotHandlerMgr* pAnnotMgr = pEnv->GetAnnotHandlerMgr(); | 157 CPDFSDK_AnnotHandlerMgr* pAnnotMgr = pFormFillEnv->GetAnnotHandlerMgr(); |
| 156 CPDFSDK_AnnotIterator annotIterator(this, false); | 158 CPDFSDK_AnnotIterator annotIterator(this, false); |
| 157 while (CPDFSDK_Annot* pSDKAnnot = annotIterator.Next()) { | 159 while (CPDFSDK_Annot* pSDKAnnot = annotIterator.Next()) { |
| 158 bool bHitTest = pSDKAnnot->GetAnnotSubtype() == CPDF_Annot::Subtype::WIDGET; | 160 bool bHitTest = pSDKAnnot->GetAnnotSubtype() == CPDF_Annot::Subtype::WIDGET; |
| 159 #ifdef PDF_ENABLE_XFA | 161 #ifdef PDF_ENABLE_XFA |
| 160 bHitTest = bHitTest || | 162 bHitTest = bHitTest || |
| 161 pSDKAnnot->GetAnnotSubtype() == CPDF_Annot::Subtype::XFAWIDGET; | 163 pSDKAnnot->GetAnnotSubtype() == CPDF_Annot::Subtype::XFAWIDGET; |
| 162 #endif // PDF_ENABLE_XFA | 164 #endif // PDF_ENABLE_XFA |
| 163 if (bHitTest) { | 165 if (bHitTest) { |
| 164 pAnnotMgr->Annot_OnGetViewBBox(this, pSDKAnnot); | 166 pAnnotMgr->Annot_OnGetViewBBox(this, pSDKAnnot); |
| 165 CFX_FloatPoint point(pageX, pageY); | 167 CFX_FloatPoint point(pageX, pageY); |
| 166 if (pAnnotMgr->Annot_OnHitTest(this, pSDKAnnot, point)) | 168 if (pAnnotMgr->Annot_OnHitTest(this, pSDKAnnot, point)) |
| 167 return pSDKAnnot; | 169 return pSDKAnnot; |
| 168 } | 170 } |
| 169 } | 171 } |
| 170 | 172 |
| 171 return nullptr; | 173 return nullptr; |
| 172 } | 174 } |
| 173 | 175 |
| 174 #ifdef PDF_ENABLE_XFA | 176 #ifdef PDF_ENABLE_XFA |
| 175 CPDFSDK_Annot* CPDFSDK_PageView::AddAnnot(CXFA_FFWidget* pPDFAnnot) { | 177 CPDFSDK_Annot* CPDFSDK_PageView::AddAnnot(CXFA_FFWidget* pPDFAnnot) { |
| 176 if (!pPDFAnnot) | 178 if (!pPDFAnnot) |
| 177 return nullptr; | 179 return nullptr; |
| 178 | 180 |
| 179 CPDFSDK_Annot* pSDKAnnot = GetAnnotByXFAWidget(pPDFAnnot); | 181 CPDFSDK_Annot* pSDKAnnot = GetAnnotByXFAWidget(pPDFAnnot); |
| 180 if (pSDKAnnot) | 182 if (pSDKAnnot) |
| 181 return pSDKAnnot; | 183 return pSDKAnnot; |
| 182 | 184 |
| 183 CPDFSDK_FormFillEnvironment* pEnv = m_pSDKDoc->GetEnv(); | 185 CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pSDKDoc->GetEnv(); |
| 184 CPDFSDK_AnnotHandlerMgr* pAnnotHandler = pEnv->GetAnnotHandlerMgr(); | 186 CPDFSDK_AnnotHandlerMgr* pAnnotHandler = pFormFillEnv->GetAnnotHandlerMgr(); |
| 185 pSDKAnnot = pAnnotHandler->NewAnnot(pPDFAnnot, this); | 187 pSDKAnnot = pAnnotHandler->NewAnnot(pPDFAnnot, this); |
| 186 if (!pSDKAnnot) | 188 if (!pSDKAnnot) |
| 187 return nullptr; | 189 return nullptr; |
| 188 | 190 |
| 189 m_SDKAnnotArray.push_back(pSDKAnnot); | 191 m_SDKAnnotArray.push_back(pSDKAnnot); |
| 190 return pSDKAnnot; | 192 return pSDKAnnot; |
| 191 } | 193 } |
| 192 | 194 |
| 193 FX_BOOL CPDFSDK_PageView::DeleteAnnot(CPDFSDK_Annot* pAnnot) { | 195 FX_BOOL CPDFSDK_PageView::DeleteAnnot(CPDFSDK_Annot* pAnnot) { |
| 194 if (!pAnnot) | 196 if (!pAnnot) |
| 195 return FALSE; | 197 return FALSE; |
| 196 CPDFXFA_Page* pPage = pAnnot->GetPDFXFAPage(); | 198 CPDFXFA_Page* pPage = pAnnot->GetPDFXFAPage(); |
| 197 if (!pPage || (pPage->GetDocument()->GetDocType() != DOCTYPE_STATIC_XFA && | 199 if (!pPage || (pPage->GetDocument()->GetDocType() != DOCTYPE_STATIC_XFA && |
| 198 pPage->GetDocument()->GetDocType() != DOCTYPE_DYNAMIC_XFA)) | 200 pPage->GetDocument()->GetDocType() != DOCTYPE_DYNAMIC_XFA)) |
| 199 return FALSE; | 201 return FALSE; |
| 200 | 202 |
| 201 if (GetFocusAnnot() == pAnnot) | 203 if (GetFocusAnnot() == pAnnot) |
| 202 m_pSDKDoc->KillFocusAnnot(0); | 204 m_pSDKDoc->KillFocusAnnot(0); |
| 203 CPDFSDK_FormFillEnvironment* pEnv = m_pSDKDoc->GetEnv(); | 205 CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pSDKDoc->GetEnv(); |
| 204 CPDFSDK_AnnotHandlerMgr* pAnnotHandler = pEnv->GetAnnotHandlerMgr(); | 206 CPDFSDK_AnnotHandlerMgr* pAnnotHandler = pFormFillEnv->GetAnnotHandlerMgr(); |
| 205 if (pAnnotHandler) | 207 if (pAnnotHandler) |
| 206 pAnnotHandler->ReleaseAnnot(pAnnot); | 208 pAnnotHandler->ReleaseAnnot(pAnnot); |
| 207 | 209 |
| 208 auto it = std::find(m_SDKAnnotArray.begin(), m_SDKAnnotArray.end(), pAnnot); | 210 auto it = std::find(m_SDKAnnotArray.begin(), m_SDKAnnotArray.end(), pAnnot); |
| 209 if (it != m_SDKAnnotArray.end()) | 211 if (it != m_SDKAnnotArray.end()) |
| 210 m_SDKAnnotArray.erase(it); | 212 m_SDKAnnotArray.erase(it); |
| 211 if (m_pCaptureWidget.Get() == pAnnot) | 213 if (m_pCaptureWidget.Get() == pAnnot) |
| 212 m_pCaptureWidget.Reset(); | 214 m_pCaptureWidget.Reset(); |
| 213 | 215 |
| 214 return TRUE; | 216 return TRUE; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 #endif // PDF_ENABLE_XFA | 258 #endif // PDF_ENABLE_XFA |
| 257 | 259 |
| 258 FX_BOOL CPDFSDK_PageView::OnLButtonDown(const CFX_FloatPoint& point, | 260 FX_BOOL CPDFSDK_PageView::OnLButtonDown(const CFX_FloatPoint& point, |
| 259 uint32_t nFlag) { | 261 uint32_t nFlag) { |
| 260 CPDFSDK_Annot::ObservedPtr pAnnot(GetFXWidgetAtPoint(point.x, point.y)); | 262 CPDFSDK_Annot::ObservedPtr pAnnot(GetFXWidgetAtPoint(point.x, point.y)); |
| 261 if (!pAnnot) { | 263 if (!pAnnot) { |
| 262 m_pSDKDoc->KillFocusAnnot(nFlag); | 264 m_pSDKDoc->KillFocusAnnot(nFlag); |
| 263 return FALSE; | 265 return FALSE; |
| 264 } | 266 } |
| 265 | 267 |
| 266 CPDFSDK_FormFillEnvironment* pEnv = m_pSDKDoc->GetEnv(); | 268 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = |
| 267 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); | 269 m_pSDKDoc->GetEnv()->GetAnnotHandlerMgr(); |
| 268 if (!pAnnotHandlerMgr->Annot_OnLButtonDown(this, &pAnnot, nFlag, point)) | 270 if (!pAnnotHandlerMgr->Annot_OnLButtonDown(this, &pAnnot, nFlag, point)) |
| 269 return FALSE; | 271 return FALSE; |
| 270 | 272 |
| 271 if (!pAnnot) | 273 if (!pAnnot) |
| 272 return FALSE; | 274 return FALSE; |
| 273 | 275 |
| 274 m_pSDKDoc->SetFocusAnnot(&pAnnot); | 276 m_pSDKDoc->SetFocusAnnot(&pAnnot); |
| 275 return TRUE; | 277 return TRUE; |
| 276 } | 278 } |
| 277 | 279 |
| 278 #ifdef PDF_ENABLE_XFA | 280 #ifdef PDF_ENABLE_XFA |
| 279 FX_BOOL CPDFSDK_PageView::OnRButtonDown(const CFX_FloatPoint& point, | 281 FX_BOOL CPDFSDK_PageView::OnRButtonDown(const CFX_FloatPoint& point, |
| 280 uint32_t nFlag) { | 282 uint32_t nFlag) { |
| 281 CPDFSDK_Annot::ObservedPtr pAnnot(GetFXWidgetAtPoint(point.x, point.y)); | 283 CPDFSDK_Annot::ObservedPtr pAnnot(GetFXWidgetAtPoint(point.x, point.y)); |
| 282 if (!pAnnot) | 284 if (!pAnnot) |
| 283 return FALSE; | 285 return FALSE; |
| 284 | 286 |
| 285 CPDFSDK_FormFillEnvironment* pEnv = m_pSDKDoc->GetEnv(); | 287 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = |
| 286 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); | 288 m_pSDKDoc->GetEnv()->GetAnnotHandlerMgr(); |
| 287 FX_BOOL ok = | 289 FX_BOOL ok = |
| 288 pAnnotHandlerMgr->Annot_OnRButtonDown(this, &pAnnot, nFlag, point); | 290 pAnnotHandlerMgr->Annot_OnRButtonDown(this, &pAnnot, nFlag, point); |
| 289 if (!pAnnot) | 291 if (!pAnnot) |
| 290 return FALSE; | 292 return FALSE; |
| 291 | 293 |
| 292 if (ok) | 294 if (ok) |
| 293 m_pSDKDoc->SetFocusAnnot(&pAnnot); | 295 m_pSDKDoc->SetFocusAnnot(&pAnnot); |
| 294 | 296 |
| 295 return TRUE; | 297 return TRUE; |
| 296 } | 298 } |
| 297 | 299 |
| 298 FX_BOOL CPDFSDK_PageView::OnRButtonUp(const CFX_FloatPoint& point, | 300 FX_BOOL CPDFSDK_PageView::OnRButtonUp(const CFX_FloatPoint& point, |
| 299 uint32_t nFlag) { | 301 uint32_t nFlag) { |
| 300 CPDFSDK_FormFillEnvironment* pEnv = m_pSDKDoc->GetEnv(); | 302 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = |
| 301 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); | 303 m_pSDKDoc->GetEnv()->GetAnnotHandlerMgr(); |
| 302 CPDFSDK_Annot::ObservedPtr pFXAnnot(GetFXWidgetAtPoint(point.x, point.y)); | 304 CPDFSDK_Annot::ObservedPtr pFXAnnot(GetFXWidgetAtPoint(point.x, point.y)); |
| 303 if (!pFXAnnot) | 305 if (!pFXAnnot) |
| 304 return FALSE; | 306 return FALSE; |
| 305 | 307 |
| 306 if (pAnnotHandlerMgr->Annot_OnRButtonUp(this, &pFXAnnot, nFlag, point)) | 308 if (pAnnotHandlerMgr->Annot_OnRButtonUp(this, &pFXAnnot, nFlag, point)) |
| 307 m_pSDKDoc->SetFocusAnnot(&pFXAnnot); | 309 m_pSDKDoc->SetFocusAnnot(&pFXAnnot); |
| 308 | 310 |
| 309 return TRUE; | 311 return TRUE; |
| 310 } | 312 } |
| 311 #endif // PDF_ENABLE_XFA | 313 #endif // PDF_ENABLE_XFA |
| 312 | 314 |
| 313 FX_BOOL CPDFSDK_PageView::OnLButtonUp(const CFX_FloatPoint& point, | 315 FX_BOOL CPDFSDK_PageView::OnLButtonUp(const CFX_FloatPoint& point, |
| 314 uint32_t nFlag) { | 316 uint32_t nFlag) { |
| 315 CPDFSDK_FormFillEnvironment* pEnv = m_pSDKDoc->GetEnv(); | 317 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = |
| 316 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); | 318 m_pSDKDoc->GetEnv()->GetAnnotHandlerMgr(); |
| 317 CPDFSDK_Annot::ObservedPtr pFXAnnot(GetFXWidgetAtPoint(point.x, point.y)); | 319 CPDFSDK_Annot::ObservedPtr pFXAnnot(GetFXWidgetAtPoint(point.x, point.y)); |
| 318 CPDFSDK_Annot::ObservedPtr pFocusAnnot(GetFocusAnnot()); | 320 CPDFSDK_Annot::ObservedPtr pFocusAnnot(GetFocusAnnot()); |
| 319 if (pFocusAnnot && pFocusAnnot != pFXAnnot) { | 321 if (pFocusAnnot && pFocusAnnot != pFXAnnot) { |
| 320 // Last focus Annot gets a chance to handle the event. | 322 // Last focus Annot gets a chance to handle the event. |
| 321 if (pAnnotHandlerMgr->Annot_OnLButtonUp(this, &pFocusAnnot, nFlag, point)) | 323 if (pAnnotHandlerMgr->Annot_OnLButtonUp(this, &pFocusAnnot, nFlag, point)) |
| 322 return TRUE; | 324 return TRUE; |
| 323 } | 325 } |
| 324 return pFXAnnot && | 326 return pFXAnnot && |
| 325 pAnnotHandlerMgr->Annot_OnLButtonUp(this, &pFXAnnot, nFlag, point); | 327 pAnnotHandlerMgr->Annot_OnLButtonUp(this, &pFXAnnot, nFlag, point); |
| 326 } | 328 } |
| 327 | 329 |
| 328 FX_BOOL CPDFSDK_PageView::OnMouseMove(const CFX_FloatPoint& point, int nFlag) { | 330 FX_BOOL CPDFSDK_PageView::OnMouseMove(const CFX_FloatPoint& point, int nFlag) { |
| 329 CPDFSDK_FormFillEnvironment* pEnv = m_pSDKDoc->GetEnv(); | 331 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = |
| 330 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); | 332 m_pSDKDoc->GetEnv()->GetAnnotHandlerMgr(); |
| 331 CPDFSDK_Annot::ObservedPtr pFXAnnot(GetFXAnnotAtPoint(point.x, point.y)); | 333 CPDFSDK_Annot::ObservedPtr pFXAnnot(GetFXAnnotAtPoint(point.x, point.y)); |
| 332 if (pFXAnnot) { | 334 if (pFXAnnot) { |
| 333 if (m_pCaptureWidget && m_pCaptureWidget != pFXAnnot) { | 335 if (m_pCaptureWidget && m_pCaptureWidget != pFXAnnot) { |
| 334 m_bExitWidget = TRUE; | 336 m_bExitWidget = TRUE; |
| 335 m_bEnterWidget = FALSE; | 337 m_bEnterWidget = FALSE; |
| 336 pAnnotHandlerMgr->Annot_OnMouseExit(this, &m_pCaptureWidget, nFlag); | 338 pAnnotHandlerMgr->Annot_OnMouseExit(this, &m_pCaptureWidget, nFlag); |
| 337 } | 339 } |
| 338 m_pCaptureWidget.Reset(pFXAnnot.Get()); | 340 m_pCaptureWidget.Reset(pFXAnnot.Get()); |
| 339 m_bOnWidget = TRUE; | 341 m_bOnWidget = TRUE; |
| 340 if (!m_bEnterWidget) { | 342 if (!m_bEnterWidget) { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 358 } | 360 } |
| 359 | 361 |
| 360 FX_BOOL CPDFSDK_PageView::OnMouseWheel(double deltaX, | 362 FX_BOOL CPDFSDK_PageView::OnMouseWheel(double deltaX, |
| 361 double deltaY, | 363 double deltaY, |
| 362 const CFX_FloatPoint& point, | 364 const CFX_FloatPoint& point, |
| 363 int nFlag) { | 365 int nFlag) { |
| 364 CPDFSDK_Annot::ObservedPtr pAnnot(GetFXWidgetAtPoint(point.x, point.y)); | 366 CPDFSDK_Annot::ObservedPtr pAnnot(GetFXWidgetAtPoint(point.x, point.y)); |
| 365 if (!pAnnot) | 367 if (!pAnnot) |
| 366 return FALSE; | 368 return FALSE; |
| 367 | 369 |
| 368 CPDFSDK_FormFillEnvironment* pEnv = m_pSDKDoc->GetEnv(); | 370 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = |
| 369 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); | 371 m_pSDKDoc->GetEnv()->GetAnnotHandlerMgr(); |
| 370 return pAnnotHandlerMgr->Annot_OnMouseWheel(this, &pAnnot, nFlag, (int)deltaY, | 372 return pAnnotHandlerMgr->Annot_OnMouseWheel(this, &pAnnot, nFlag, (int)deltaY, |
| 371 point); | 373 point); |
| 372 } | 374 } |
| 373 | 375 |
| 374 FX_BOOL CPDFSDK_PageView::OnChar(int nChar, uint32_t nFlag) { | 376 FX_BOOL CPDFSDK_PageView::OnChar(int nChar, uint32_t nFlag) { |
| 375 if (CPDFSDK_Annot* pAnnot = GetFocusAnnot()) { | 377 if (CPDFSDK_Annot* pAnnot = GetFocusAnnot()) { |
| 376 CPDFSDK_FormFillEnvironment* pEnv = m_pSDKDoc->GetEnv(); | 378 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = |
| 377 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); | 379 m_pSDKDoc->GetEnv()->GetAnnotHandlerMgr(); |
| 378 return pAnnotHandlerMgr->Annot_OnChar(pAnnot, nChar, nFlag); | 380 return pAnnotHandlerMgr->Annot_OnChar(pAnnot, nChar, nFlag); |
| 379 } | 381 } |
| 380 | 382 |
| 381 return FALSE; | 383 return FALSE; |
| 382 } | 384 } |
| 383 | 385 |
| 384 FX_BOOL CPDFSDK_PageView::OnKeyDown(int nKeyCode, int nFlag) { | 386 FX_BOOL CPDFSDK_PageView::OnKeyDown(int nKeyCode, int nFlag) { |
| 385 if (CPDFSDK_Annot* pAnnot = GetFocusAnnot()) { | 387 if (CPDFSDK_Annot* pAnnot = GetFocusAnnot()) { |
| 386 CPDFSDK_FormFillEnvironment* pEnv = m_pSDKDoc->GetEnv(); | 388 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = |
| 387 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); | 389 m_pSDKDoc->GetEnv()->GetAnnotHandlerMgr(); |
| 388 return pAnnotHandlerMgr->Annot_OnKeyDown(pAnnot, nKeyCode, nFlag); | 390 return pAnnotHandlerMgr->Annot_OnKeyDown(pAnnot, nKeyCode, nFlag); |
| 389 } | 391 } |
| 390 return FALSE; | 392 return FALSE; |
| 391 } | 393 } |
| 392 | 394 |
| 393 FX_BOOL CPDFSDK_PageView::OnKeyUp(int nKeyCode, int nFlag) { | 395 FX_BOOL CPDFSDK_PageView::OnKeyUp(int nKeyCode, int nFlag) { |
| 394 return FALSE; | 396 return FALSE; |
| 395 } | 397 } |
| 396 | 398 |
| 397 void CPDFSDK_PageView::LoadFXAnnots() { | 399 void CPDFSDK_PageView::LoadFXAnnots() { |
| 398 CPDFSDK_FormFillEnvironment* pEnv = m_pSDKDoc->GetEnv(); | 400 CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pSDKDoc->GetEnv(); |
| 399 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); | 401 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = |
| 402 pFormFillEnv->GetAnnotHandlerMgr(); |
| 400 | 403 |
| 401 SetLock(TRUE); | 404 SetLock(TRUE); |
| 402 | 405 |
| 403 #ifdef PDF_ENABLE_XFA | 406 #ifdef PDF_ENABLE_XFA |
| 404 CFX_RetainPtr<CPDFXFA_Page> protector(m_page); | 407 CFX_RetainPtr<CPDFXFA_Page> protector(m_page); |
| 405 if (m_pSDKDoc->GetXFADocument()->GetDocType() == DOCTYPE_DYNAMIC_XFA) { | 408 if (pFormFillEnv->GetXFADocument()->GetDocType() == DOCTYPE_DYNAMIC_XFA) { |
| 406 CXFA_FFPageView* pageView = m_page->GetXFAPageView(); | 409 CXFA_FFPageView* pageView = m_page->GetXFAPageView(); |
| 407 std::unique_ptr<IXFA_WidgetIterator> pWidgetHander( | 410 std::unique_ptr<IXFA_WidgetIterator> pWidgetHander( |
| 408 pageView->CreateWidgetIterator( | 411 pageView->CreateWidgetIterator( |
| 409 XFA_TRAVERSEWAY_Form, | 412 XFA_TRAVERSEWAY_Form, |
| 410 XFA_WidgetStatus_Visible | XFA_WidgetStatus_Viewable)); | 413 XFA_WidgetStatus_Visible | XFA_WidgetStatus_Viewable)); |
| 411 if (!pWidgetHander) { | 414 if (!pWidgetHander) { |
| 412 SetLock(FALSE); | 415 SetLock(FALSE); |
| 413 return; | 416 return; |
| 414 } | 417 } |
| 415 | 418 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 442 if (!pAnnot) | 445 if (!pAnnot) |
| 443 continue; | 446 continue; |
| 444 m_SDKAnnotArray.push_back(pAnnot); | 447 m_SDKAnnotArray.push_back(pAnnot); |
| 445 pAnnotHandlerMgr->Annot_OnLoad(pAnnot); | 448 pAnnotHandlerMgr->Annot_OnLoad(pAnnot); |
| 446 } | 449 } |
| 447 | 450 |
| 448 SetLock(FALSE); | 451 SetLock(FALSE); |
| 449 } | 452 } |
| 450 | 453 |
| 451 void CPDFSDK_PageView::UpdateRects(const std::vector<CFX_FloatRect>& rects) { | 454 void CPDFSDK_PageView::UpdateRects(const std::vector<CFX_FloatRect>& rects) { |
| 452 CPDFSDK_FormFillEnvironment* pEnv = m_pSDKDoc->GetEnv(); | 455 CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pSDKDoc->GetEnv(); |
| 453 for (const auto& rc : rects) | 456 for (const auto& rc : rects) |
| 454 pEnv->Invalidate(m_page, rc.left, rc.top, rc.right, rc.bottom); | 457 pFormFillEnv->Invalidate(m_page, rc.left, rc.top, rc.right, rc.bottom); |
| 455 } | 458 } |
| 456 | 459 |
| 457 void CPDFSDK_PageView::UpdateView(CPDFSDK_Annot* pAnnot) { | 460 void CPDFSDK_PageView::UpdateView(CPDFSDK_Annot* pAnnot) { |
| 458 CFX_FloatRect rcWindow = pAnnot->GetRect(); | 461 CFX_FloatRect rcWindow = pAnnot->GetRect(); |
| 459 CPDFSDK_FormFillEnvironment* pEnv = m_pSDKDoc->GetEnv(); | 462 m_pSDKDoc->GetEnv()->Invalidate(m_page, rcWindow.left, rcWindow.top, |
| 460 pEnv->Invalidate(m_page, rcWindow.left, rcWindow.top, rcWindow.right, | 463 rcWindow.right, rcWindow.bottom); |
| 461 rcWindow.bottom); | |
| 462 } | 464 } |
| 463 | 465 |
| 464 int CPDFSDK_PageView::GetPageIndex() const { | 466 int CPDFSDK_PageView::GetPageIndex() const { |
| 465 if (!m_page) | 467 if (!m_page) |
| 466 return -1; | 468 return -1; |
| 467 | 469 |
| 468 #ifdef PDF_ENABLE_XFA | 470 #ifdef PDF_ENABLE_XFA |
| 469 int nDocType = m_page->GetDocument()->GetDocType(); | 471 int nDocType = m_page->GetDocument()->GetDocType(); |
| 470 switch (nDocType) { | 472 switch (nDocType) { |
| 471 case DOCTYPE_DYNAMIC_XFA: { | 473 case DOCTYPE_DYNAMIC_XFA: { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 504 CPDFSDK_Annot* CPDFSDK_PageView::GetFocusAnnot() { | 506 CPDFSDK_Annot* CPDFSDK_PageView::GetFocusAnnot() { |
| 505 CPDFSDK_Annot* pFocusAnnot = m_pSDKDoc->GetFocusAnnot(); | 507 CPDFSDK_Annot* pFocusAnnot = m_pSDKDoc->GetFocusAnnot(); |
| 506 return IsValidSDKAnnot(pFocusAnnot) ? pFocusAnnot : nullptr; | 508 return IsValidSDKAnnot(pFocusAnnot) ? pFocusAnnot : nullptr; |
| 507 } | 509 } |
| 508 | 510 |
| 509 int CPDFSDK_PageView::GetPageIndexForStaticPDF() const { | 511 int CPDFSDK_PageView::GetPageIndexForStaticPDF() const { |
| 510 CPDF_Dictionary* pDict = GetPDFPage()->m_pFormDict; | 512 CPDF_Dictionary* pDict = GetPDFPage()->m_pFormDict; |
| 511 CPDF_Document* pDoc = m_pSDKDoc->GetPDFDocument(); | 513 CPDF_Document* pDoc = m_pSDKDoc->GetPDFDocument(); |
| 512 return (pDoc && pDict) ? pDoc->GetPageIndex(pDict->GetObjNum()) : -1; | 514 return (pDoc && pDict) ? pDoc->GetPageIndex(pDict->GetObjNum()) : -1; |
| 513 } | 515 } |
| OLD | NEW |