| 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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 #else | 87 #else |
| 88 CPDF_RenderOptions* pOptions) { | 88 CPDF_RenderOptions* pOptions) { |
| 89 #endif // PDF_ENABLE_XFA | 89 #endif // PDF_ENABLE_XFA |
| 90 m_curMatrix = *pUser2Device; | 90 m_curMatrix = *pUser2Device; |
| 91 | 91 |
| 92 #ifdef PDF_ENABLE_XFA | 92 #ifdef PDF_ENABLE_XFA |
| 93 CPDFXFA_Page* pPage = GetPDFXFAPage(); | 93 CPDFXFA_Page* pPage = GetPDFXFAPage(); |
| 94 if (!pPage) | 94 if (!pPage) |
| 95 return; | 95 return; |
| 96 | 96 |
| 97 if (pPage->GetDocument()->GetDocType() == DOCTYPE_DYNAMIC_XFA) { | 97 if (pPage->GetContext()->GetDocType() == DOCTYPE_DYNAMIC_XFA) { |
| 98 CFX_Graphics gs; | 98 CFX_Graphics gs; |
| 99 gs.Create(pDevice); | 99 gs.Create(pDevice); |
| 100 CFX_RectF rectClip; | 100 CFX_RectF rectClip; |
| 101 rectClip.Set(static_cast<FX_FLOAT>(pClip.left), | 101 rectClip.Set(static_cast<FX_FLOAT>(pClip.left), |
| 102 static_cast<FX_FLOAT>(pClip.top), | 102 static_cast<FX_FLOAT>(pClip.top), |
| 103 static_cast<FX_FLOAT>(pClip.Width()), | 103 static_cast<FX_FLOAT>(pClip.Width()), |
| 104 static_cast<FX_FLOAT>(pClip.Height())); | 104 static_cast<FX_FLOAT>(pClip.Height())); |
| 105 gs.SetClipRect(rectClip); | 105 gs.SetClipRect(rectClip); |
| 106 std::unique_ptr<CXFA_RenderContext> pRenderContext(new CXFA_RenderContext); | 106 std::unique_ptr<CXFA_RenderContext> pRenderContext(new CXFA_RenderContext); |
| 107 CXFA_RenderOptions renderOptions; | 107 CXFA_RenderOptions renderOptions; |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 return nullptr; | 184 return nullptr; |
| 185 | 185 |
| 186 m_SDKAnnotArray.push_back(pSDKAnnot); | 186 m_SDKAnnotArray.push_back(pSDKAnnot); |
| 187 return pSDKAnnot; | 187 return pSDKAnnot; |
| 188 } | 188 } |
| 189 | 189 |
| 190 FX_BOOL CPDFSDK_PageView::DeleteAnnot(CPDFSDK_Annot* pAnnot) { | 190 FX_BOOL CPDFSDK_PageView::DeleteAnnot(CPDFSDK_Annot* pAnnot) { |
| 191 if (!pAnnot) | 191 if (!pAnnot) |
| 192 return FALSE; | 192 return FALSE; |
| 193 CPDFXFA_Page* pPage = pAnnot->GetPDFXFAPage(); | 193 CPDFXFA_Page* pPage = pAnnot->GetPDFXFAPage(); |
| 194 if (!pPage || (pPage->GetDocument()->GetDocType() != DOCTYPE_STATIC_XFA && | 194 if (!pPage || (pPage->GetContext()->GetDocType() != DOCTYPE_STATIC_XFA && |
| 195 pPage->GetDocument()->GetDocType() != DOCTYPE_DYNAMIC_XFA)) | 195 pPage->GetContext()->GetDocType() != DOCTYPE_DYNAMIC_XFA)) |
| 196 return FALSE; | 196 return FALSE; |
| 197 | 197 |
| 198 if (GetFocusAnnot() == pAnnot) | 198 if (GetFocusAnnot() == pAnnot) |
| 199 m_pFormFillEnv->KillFocusAnnot(0); | 199 m_pFormFillEnv->KillFocusAnnot(0); |
| 200 CPDFSDK_AnnotHandlerMgr* pAnnotHandler = m_pFormFillEnv->GetAnnotHandlerMgr(); | 200 CPDFSDK_AnnotHandlerMgr* pAnnotHandler = m_pFormFillEnv->GetAnnotHandlerMgr(); |
| 201 if (pAnnotHandler) | 201 if (pAnnotHandler) |
| 202 pAnnotHandler->ReleaseAnnot(pAnnot); | 202 pAnnotHandler->ReleaseAnnot(pAnnot); |
| 203 | 203 |
| 204 auto it = std::find(m_SDKAnnotArray.begin(), m_SDKAnnotArray.end(), pAnnot); | 204 auto it = std::find(m_SDKAnnotArray.begin(), m_SDKAnnotArray.end(), pAnnot); |
| 205 if (it != m_SDKAnnotArray.end()) | 205 if (it != m_SDKAnnotArray.end()) |
| 206 m_SDKAnnotArray.erase(it); | 206 m_SDKAnnotArray.erase(it); |
| 207 if (m_pCaptureWidget.Get() == pAnnot) | 207 if (m_pCaptureWidget.Get() == pAnnot) |
| 208 m_pCaptureWidget.Reset(); | 208 m_pCaptureWidget.Reset(); |
| 209 | 209 |
| 210 return TRUE; | 210 return TRUE; |
| 211 } | 211 } |
| 212 #endif // PDF_ENABLE_XFA | 212 #endif // PDF_ENABLE_XFA |
| 213 | 213 |
| 214 CPDF_Document* CPDFSDK_PageView::GetPDFDocument() { | 214 CPDF_Document* CPDFSDK_PageView::GetPDFDocument() { |
| 215 if (m_page) { | 215 if (m_page) { |
| 216 #ifdef PDF_ENABLE_XFA | 216 #ifdef PDF_ENABLE_XFA |
| 217 return m_page->GetDocument()->GetPDFDoc(); | 217 return m_page->GetContext()->GetPDFDoc(); |
| 218 #else // PDF_ENABLE_XFA | 218 #else // PDF_ENABLE_XFA |
| 219 return m_page->m_pDocument; | 219 return m_page->m_pDocument; |
| 220 #endif // PDF_ENABLE_XFA | 220 #endif // PDF_ENABLE_XFA |
| 221 } | 221 } |
| 222 return nullptr; | 222 return nullptr; |
| 223 } | 223 } |
| 224 | 224 |
| 225 CPDF_Page* CPDFSDK_PageView::GetPDFPage() const { | 225 CPDF_Page* CPDFSDK_PageView::GetPDFPage() const { |
| 226 #ifdef PDF_ENABLE_XFA | 226 #ifdef PDF_ENABLE_XFA |
| 227 return m_page ? m_page->GetPDFPage() : nullptr; | 227 return m_page ? m_page->GetPDFPage() : nullptr; |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 } | 391 } |
| 392 | 392 |
| 393 void CPDFSDK_PageView::LoadFXAnnots() { | 393 void CPDFSDK_PageView::LoadFXAnnots() { |
| 394 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = | 394 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = |
| 395 m_pFormFillEnv->GetAnnotHandlerMgr(); | 395 m_pFormFillEnv->GetAnnotHandlerMgr(); |
| 396 | 396 |
| 397 SetLock(TRUE); | 397 SetLock(TRUE); |
| 398 | 398 |
| 399 #ifdef PDF_ENABLE_XFA | 399 #ifdef PDF_ENABLE_XFA |
| 400 CFX_RetainPtr<CPDFXFA_Page> protector(m_page); | 400 CFX_RetainPtr<CPDFXFA_Page> protector(m_page); |
| 401 if (m_pFormFillEnv->GetXFADocument()->GetDocType() == DOCTYPE_DYNAMIC_XFA) { | 401 if (m_pFormFillEnv->GetXFAContext()->GetDocType() == DOCTYPE_DYNAMIC_XFA) { |
| 402 CXFA_FFPageView* pageView = m_page->GetXFAPageView(); | 402 CXFA_FFPageView* pageView = m_page->GetXFAPageView(); |
| 403 std::unique_ptr<IXFA_WidgetIterator> pWidgetHander( | 403 std::unique_ptr<IXFA_WidgetIterator> pWidgetHander( |
| 404 pageView->CreateWidgetIterator( | 404 pageView->CreateWidgetIterator( |
| 405 XFA_TRAVERSEWAY_Form, | 405 XFA_TRAVERSEWAY_Form, |
| 406 XFA_WidgetStatus_Visible | XFA_WidgetStatus_Viewable)); | 406 XFA_WidgetStatus_Visible | XFA_WidgetStatus_Viewable)); |
| 407 if (!pWidgetHander) { | 407 if (!pWidgetHander) { |
| 408 SetLock(FALSE); | 408 SetLock(FALSE); |
| 409 return; | 409 return; |
| 410 } | 410 } |
| 411 | 411 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 453 CFX_FloatRect rcWindow = pAnnot->GetRect(); | 453 CFX_FloatRect rcWindow = pAnnot->GetRect(); |
| 454 m_pFormFillEnv->Invalidate(m_page, rcWindow.left, rcWindow.top, | 454 m_pFormFillEnv->Invalidate(m_page, rcWindow.left, rcWindow.top, |
| 455 rcWindow.right, rcWindow.bottom); | 455 rcWindow.right, rcWindow.bottom); |
| 456 } | 456 } |
| 457 | 457 |
| 458 int CPDFSDK_PageView::GetPageIndex() const { | 458 int CPDFSDK_PageView::GetPageIndex() const { |
| 459 if (!m_page) | 459 if (!m_page) |
| 460 return -1; | 460 return -1; |
| 461 | 461 |
| 462 #ifdef PDF_ENABLE_XFA | 462 #ifdef PDF_ENABLE_XFA |
| 463 int nDocType = m_page->GetDocument()->GetDocType(); | 463 int nDocType = m_page->GetContext()->GetDocType(); |
| 464 switch (nDocType) { | 464 switch (nDocType) { |
| 465 case DOCTYPE_DYNAMIC_XFA: { | 465 case DOCTYPE_DYNAMIC_XFA: { |
| 466 CXFA_FFPageView* pPageView = m_page->GetXFAPageView(); | 466 CXFA_FFPageView* pPageView = m_page->GetXFAPageView(); |
| 467 return pPageView ? pPageView->GetPageIndex() : -1; | 467 return pPageView ? pPageView->GetPageIndex() : -1; |
| 468 } | 468 } |
| 469 case DOCTYPE_STATIC_XFA: | 469 case DOCTYPE_STATIC_XFA: |
| 470 case DOCTYPE_PDF: | 470 case DOCTYPE_PDF: |
| 471 return GetPageIndexForStaticPDF(); | 471 return GetPageIndexForStaticPDF(); |
| 472 default: | 472 default: |
| 473 return -1; | 473 return -1; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 498 CPDFSDK_Annot* CPDFSDK_PageView::GetFocusAnnot() { | 498 CPDFSDK_Annot* CPDFSDK_PageView::GetFocusAnnot() { |
| 499 CPDFSDK_Annot* pFocusAnnot = m_pFormFillEnv->GetFocusAnnot(); | 499 CPDFSDK_Annot* pFocusAnnot = m_pFormFillEnv->GetFocusAnnot(); |
| 500 return IsValidSDKAnnot(pFocusAnnot) ? pFocusAnnot : nullptr; | 500 return IsValidSDKAnnot(pFocusAnnot) ? pFocusAnnot : nullptr; |
| 501 } | 501 } |
| 502 | 502 |
| 503 int CPDFSDK_PageView::GetPageIndexForStaticPDF() const { | 503 int CPDFSDK_PageView::GetPageIndexForStaticPDF() const { |
| 504 CPDF_Dictionary* pDict = GetPDFPage()->m_pFormDict; | 504 CPDF_Dictionary* pDict = GetPDFPage()->m_pFormDict; |
| 505 CPDF_Document* pDoc = m_pFormFillEnv->GetPDFDocument(); | 505 CPDF_Document* pDoc = m_pFormFillEnv->GetPDFDocument(); |
| 506 return (pDoc && pDict) ? pDoc->GetPageIndex(pDict->GetObjNum()) : -1; | 506 return (pDoc && pDict) ? pDoc->GetPageIndex(pDict->GetObjNum()) : -1; |
| 507 } | 507 } |
| OLD | NEW |