| 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/include/cpdfsdk_document.h" | 7 #include "fpdfsdk/include/cpdfsdk_document.h" |
| 8 | 8 |
| 9 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" | 9 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" |
| 10 #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" | 10 #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 | 59 |
| 60 CPDFSDK_PageView* pPageView = new CPDFSDK_PageView(this, pUnderlyingPage); | 60 CPDFSDK_PageView* pPageView = new CPDFSDK_PageView(this, pUnderlyingPage); |
| 61 m_pageMap[pUnderlyingPage] = pPageView; | 61 m_pageMap[pUnderlyingPage] = pPageView; |
| 62 // Delay to load all the annotations, to avoid endless loop. | 62 // Delay to load all the annotations, to avoid endless loop. |
| 63 pPageView->LoadFXAnnots(); | 63 pPageView->LoadFXAnnots(); |
| 64 return pPageView; | 64 return pPageView; |
| 65 } | 65 } |
| 66 | 66 |
| 67 CPDFSDK_PageView* CPDFSDK_Document::GetCurrentView() { | 67 CPDFSDK_PageView* CPDFSDK_Document::GetCurrentView() { |
| 68 UnderlyingPageType* pPage = | 68 UnderlyingPageType* pPage = |
| 69 UnderlyingFromFPDFPage(m_pEnv->FFI_GetCurrentPage(m_pDoc)); | 69 UnderlyingFromFPDFPage(m_pEnv->GetCurrentPage(m_pDoc)); |
| 70 return pPage ? GetPageView(pPage, true) : nullptr; | 70 return pPage ? GetPageView(pPage, true) : nullptr; |
| 71 } | 71 } |
| 72 | 72 |
| 73 CPDFSDK_PageView* CPDFSDK_Document::GetPageView(int nIndex) { | 73 CPDFSDK_PageView* CPDFSDK_Document::GetPageView(int nIndex) { |
| 74 UnderlyingPageType* pTempPage = | 74 UnderlyingPageType* pTempPage = |
| 75 UnderlyingFromFPDFPage(m_pEnv->FFI_GetPage(m_pDoc, nIndex)); | 75 UnderlyingFromFPDFPage(m_pEnv->GetPage(m_pDoc, nIndex)); |
| 76 if (!pTempPage) | 76 if (!pTempPage) |
| 77 return nullptr; | 77 return nullptr; |
| 78 | 78 |
| 79 auto it = m_pageMap.find(pTempPage); | 79 auto it = m_pageMap.find(pTempPage); |
| 80 return it != m_pageMap.end() ? it->second : nullptr; | 80 return it != m_pageMap.end() ? it->second : nullptr; |
| 81 } | 81 } |
| 82 | 82 |
| 83 void CPDFSDK_Document::ProcJavascriptFun() { | 83 void CPDFSDK_Document::ProcJavascriptFun() { |
| 84 CPDF_Document* pPDFDoc = GetPDFDocument(); | 84 CPDF_Document* pPDFDoc = GetPDFDocument(); |
| 85 CPDF_DocJSActions docJS(pPDFDoc); | 85 CPDF_DocJSActions docJS(pPDFDoc); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 pPageView->KillFocusAnnotIfNeeded(); | 147 pPageView->KillFocusAnnotIfNeeded(); |
| 148 | 148 |
| 149 // Remove the page from the map to make sure we don't accidentally attempt | 149 // Remove the page from the map to make sure we don't accidentally attempt |
| 150 // to use the |pPageView| while we're cleaning it up. | 150 // to use the |pPageView| while we're cleaning it up. |
| 151 m_pageMap.erase(it); | 151 m_pageMap.erase(it); |
| 152 | 152 |
| 153 delete pPageView; | 153 delete pPageView; |
| 154 } | 154 } |
| 155 | 155 |
| 156 UnderlyingPageType* CPDFSDK_Document::GetPage(int nIndex) { | 156 UnderlyingPageType* CPDFSDK_Document::GetPage(int nIndex) { |
| 157 return UnderlyingFromFPDFPage(m_pEnv->FFI_GetPage(m_pDoc, nIndex)); | 157 return UnderlyingFromFPDFPage(m_pEnv->GetPage(m_pDoc, nIndex)); |
| 158 } | 158 } |
| 159 | 159 |
| 160 CPDFSDK_InterForm* CPDFSDK_Document::GetInterForm() { | 160 CPDFSDK_InterForm* CPDFSDK_Document::GetInterForm() { |
| 161 if (!m_pInterForm) | 161 if (!m_pInterForm) |
| 162 m_pInterForm.reset(new CPDFSDK_InterForm(this)); | 162 m_pInterForm.reset(new CPDFSDK_InterForm(this)); |
| 163 return m_pInterForm.get(); | 163 return m_pInterForm.get(); |
| 164 } | 164 } |
| 165 | 165 |
| 166 void CPDFSDK_Document::UpdateAllViews(CPDFSDK_PageView* pSender, | 166 void CPDFSDK_Document::UpdateAllViews(CPDFSDK_PageView* pSender, |
| 167 CPDFSDK_Annot* pAnnot) { | 167 CPDFSDK_Annot* pAnnot) { |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 if (!pAnnotHandler->Annot_OnChangeFocus(nullptr, pFocusAnnot)) | 224 if (!pAnnotHandler->Annot_OnChangeFocus(nullptr, pFocusAnnot)) |
| 225 return FALSE; | 225 return FALSE; |
| 226 #endif // PDF_ENABLE_XFA | 226 #endif // PDF_ENABLE_XFA |
| 227 | 227 |
| 228 if (pAnnotHandler->Annot_OnKillFocus(pFocusAnnot, nFlag)) { | 228 if (pAnnotHandler->Annot_OnKillFocus(pFocusAnnot, nFlag)) { |
| 229 if (pFocusAnnot->GetAnnotSubtype() == CPDF_Annot::Subtype::WIDGET) { | 229 if (pFocusAnnot->GetAnnotSubtype() == CPDF_Annot::Subtype::WIDGET) { |
| 230 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pFocusAnnot; | 230 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pFocusAnnot; |
| 231 int nFieldType = pWidget->GetFieldType(); | 231 int nFieldType = pWidget->GetFieldType(); |
| 232 if (FIELDTYPE_TEXTFIELD == nFieldType || | 232 if (FIELDTYPE_TEXTFIELD == nFieldType || |
| 233 FIELDTYPE_COMBOBOX == nFieldType) { | 233 FIELDTYPE_COMBOBOX == nFieldType) { |
| 234 m_pEnv->FFI_OnSetFieldInputFocus(nullptr, nullptr, 0, FALSE); | 234 m_pEnv->OnSetFieldInputFocus(nullptr, nullptr, 0, FALSE); |
| 235 } | 235 } |
| 236 } | 236 } |
| 237 | 237 |
| 238 if (!m_pFocusAnnot) | 238 if (!m_pFocusAnnot) |
| 239 return TRUE; | 239 return TRUE; |
| 240 } else { | 240 } else { |
| 241 m_pFocusAnnot = pFocusAnnot; | 241 m_pFocusAnnot = pFocusAnnot; |
| 242 } | 242 } |
| 243 } | 243 } |
| 244 return FALSE; | 244 return FALSE; |
| 245 } | 245 } |
| 246 | 246 |
| 247 void CPDFSDK_Document::OnCloseDocument() { | 247 void CPDFSDK_Document::OnCloseDocument() { |
| 248 KillFocusAnnot(); | 248 KillFocusAnnot(); |
| 249 } | 249 } |
| 250 | 250 |
| 251 FX_BOOL CPDFSDK_Document::GetPermissions(int nFlag) { | 251 FX_BOOL CPDFSDK_Document::GetPermissions(int nFlag) { |
| 252 return GetPDFDocument()->GetUserPermissions() & nFlag; | 252 return GetPDFDocument()->GetUserPermissions() & nFlag; |
| 253 } | 253 } |
| 254 | 254 |
| 255 IJS_Runtime* CPDFSDK_Document::GetJsRuntime() { | 255 IJS_Runtime* CPDFSDK_Document::GetJsRuntime() { |
| 256 return m_pEnv->GetJSRuntime(); | 256 return m_pEnv->GetJSRuntime(); |
| 257 } | 257 } |
| 258 | 258 |
| 259 CFX_WideString CPDFSDK_Document::GetPath() { | 259 CFX_WideString CPDFSDK_Document::GetPath() { |
| 260 return m_pEnv->JS_docGetFilePath(); | 260 return m_pEnv->JS_docGetFilePath(); |
| 261 } | 261 } |
| OLD | NEW |