| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <memory> |
| 8 | 9 |
| 9 #include "fpdfsdk/include/fsdk_mgr.h" | 10 #include "fpdfsdk/include/fsdk_mgr.h" |
| 10 | 11 |
| 11 #include "fpdfsdk/include/formfiller/FFL_FormFiller.h" | 12 #include "fpdfsdk/include/formfiller/FFL_FormFiller.h" |
| 12 #include "fpdfsdk/include/fsdk_define.h" | 13 #include "fpdfsdk/include/fsdk_define.h" |
| 13 #include "fpdfsdk/include/javascript/IJavaScript.h" | 14 #include "fpdfsdk/include/javascript/IJavaScript.h" |
| 14 #include "public/fpdf_ext.h" | 15 #include "public/fpdf_ext.h" |
| 15 #include "third_party/base/nonstd_unique_ptr.h" | |
| 16 #include "third_party/base/stl_util.h" | 16 #include "third_party/base/stl_util.h" |
| 17 | 17 |
| 18 #ifdef PDF_ENABLE_XFA | 18 #ifdef PDF_ENABLE_XFA |
| 19 #include "../include/fpdfxfa/fpdfxfa_app.h" | 19 #include "../include/fpdfxfa/fpdfxfa_app.h" |
| 20 #include "../include/fpdfxfa/fpdfxfa_doc.h" | 20 #include "../include/fpdfxfa/fpdfxfa_doc.h" |
| 21 #include "../include/fpdfxfa/fpdfxfa_page.h" | 21 #include "../include/fpdfxfa/fpdfxfa_page.h" |
| 22 #include "../include/fpdfxfa/fpdfxfa_util.h" | 22 #include "../include/fpdfxfa/fpdfxfa_util.h" |
| 23 #endif // PDF_ENABLE_XFA | 23 #endif // PDF_ENABLE_XFA |
| 24 | 24 |
| 25 #if _FX_OS_ == _FX_ANDROID_ | 25 #if _FX_OS_ == _FX_ANDROID_ |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 if (!m_pInfo || !m_pInfo->m_pJsPlatform || | 278 if (!m_pInfo || !m_pInfo->m_pJsPlatform || |
| 279 !m_pInfo->m_pJsPlatform->Field_browse) { | 279 !m_pInfo->m_pJsPlatform->Field_browse) { |
| 280 return L""; | 280 return L""; |
| 281 } | 281 } |
| 282 | 282 |
| 283 const int nRequiredLen = | 283 const int nRequiredLen = |
| 284 m_pInfo->m_pJsPlatform->Field_browse(m_pInfo->m_pJsPlatform, nullptr, 0); | 284 m_pInfo->m_pJsPlatform->Field_browse(m_pInfo->m_pJsPlatform, nullptr, 0); |
| 285 if (nRequiredLen <= 0) | 285 if (nRequiredLen <= 0) |
| 286 return L""; | 286 return L""; |
| 287 | 287 |
| 288 nonstd::unique_ptr<char[]> pBuff(new char[nRequiredLen]); | 288 std::unique_ptr<char[]> pBuff(new char[nRequiredLen]); |
| 289 memset(pBuff.get(), 0, nRequiredLen); | 289 memset(pBuff.get(), 0, nRequiredLen); |
| 290 const int nActualLen = m_pInfo->m_pJsPlatform->Field_browse( | 290 const int nActualLen = m_pInfo->m_pJsPlatform->Field_browse( |
| 291 m_pInfo->m_pJsPlatform, pBuff.get(), nRequiredLen); | 291 m_pInfo->m_pJsPlatform, pBuff.get(), nRequiredLen); |
| 292 if (nActualLen <= 0 || nActualLen > nRequiredLen) | 292 if (nActualLen <= 0 || nActualLen > nRequiredLen) |
| 293 return L""; | 293 return L""; |
| 294 | 294 |
| 295 CFX_ByteString bsRet = CFX_ByteString(pBuff.get(), nActualLen); | 295 CFX_ByteString bsRet = CFX_ByteString(pBuff.get(), nActualLen); |
| 296 CFX_WideString wsRet = CFX_WideString::FromLocal(bsRet); | 296 CFX_WideString wsRet = CFX_WideString::FromLocal(bsRet); |
| 297 return wsRet; | 297 return wsRet; |
| 298 } | 298 } |
| 299 | 299 |
| 300 CFX_WideString CPDFDoc_Environment::JS_docGetFilePath() { | 300 CFX_WideString CPDFDoc_Environment::JS_docGetFilePath() { |
| 301 if (!m_pInfo || !m_pInfo->m_pJsPlatform || | 301 if (!m_pInfo || !m_pInfo->m_pJsPlatform || |
| 302 !m_pInfo->m_pJsPlatform->Doc_getFilePath) { | 302 !m_pInfo->m_pJsPlatform->Doc_getFilePath) { |
| 303 return L""; | 303 return L""; |
| 304 } | 304 } |
| 305 | 305 |
| 306 const int nRequiredLen = m_pInfo->m_pJsPlatform->Doc_getFilePath( | 306 const int nRequiredLen = m_pInfo->m_pJsPlatform->Doc_getFilePath( |
| 307 m_pInfo->m_pJsPlatform, nullptr, 0); | 307 m_pInfo->m_pJsPlatform, nullptr, 0); |
| 308 if (nRequiredLen <= 0) | 308 if (nRequiredLen <= 0) |
| 309 return L""; | 309 return L""; |
| 310 | 310 |
| 311 nonstd::unique_ptr<char[]> pBuff(new char[nRequiredLen]); | 311 std::unique_ptr<char[]> pBuff(new char[nRequiredLen]); |
| 312 memset(pBuff.get(), 0, nRequiredLen); | 312 memset(pBuff.get(), 0, nRequiredLen); |
| 313 const int nActualLen = m_pInfo->m_pJsPlatform->Doc_getFilePath( | 313 const int nActualLen = m_pInfo->m_pJsPlatform->Doc_getFilePath( |
| 314 m_pInfo->m_pJsPlatform, pBuff.get(), nRequiredLen); | 314 m_pInfo->m_pJsPlatform, pBuff.get(), nRequiredLen); |
| 315 if (nActualLen <= 0 || nActualLen > nRequiredLen) | 315 if (nActualLen <= 0 || nActualLen > nRequiredLen) |
| 316 return L""; | 316 return L""; |
| 317 | 317 |
| 318 CFX_ByteString bsRet = CFX_ByteString(pBuff.get(), nActualLen); | 318 CFX_ByteString bsRet = CFX_ByteString(pBuff.get(), nActualLen); |
| 319 CFX_WideString wsRet = CFX_WideString::FromLocal(bsRet); | 319 CFX_WideString wsRet = CFX_WideString::FromLocal(bsRet); |
| 320 return wsRet; | 320 return wsRet; |
| 321 } | 321 } |
| (...skipping 838 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1160 CPDFSDK_Annot* pFocusAnnot = m_pSDKDoc->GetFocusAnnot(); | 1160 CPDFSDK_Annot* pFocusAnnot = m_pSDKDoc->GetFocusAnnot(); |
| 1161 if (!pFocusAnnot) | 1161 if (!pFocusAnnot) |
| 1162 return nullptr; | 1162 return nullptr; |
| 1163 | 1163 |
| 1164 for (CPDFSDK_Annot* pAnnot : m_fxAnnotArray) { | 1164 for (CPDFSDK_Annot* pAnnot : m_fxAnnotArray) { |
| 1165 if (pAnnot == pFocusAnnot) | 1165 if (pAnnot == pFocusAnnot) |
| 1166 return pAnnot; | 1166 return pAnnot; |
| 1167 } | 1167 } |
| 1168 return nullptr; | 1168 return nullptr; |
| 1169 } | 1169 } |
| OLD | NEW |