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_environment.h" | 7 #include "fpdfsdk/cpdfsdk_environment.h" |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
11 #include "fpdfsdk/cpdfsdk_annothandlermgr.h" | 11 #include "fpdfsdk/cpdfsdk_annothandlermgr.h" |
12 #include "fpdfsdk/cpdfsdk_document.h" | 12 #include "fpdfsdk/cpdfsdk_document.h" |
13 #include "fpdfsdk/formfiller/cffl_interactiveformfiller.h" | 13 #include "fpdfsdk/formfiller/cffl_interactiveformfiller.h" |
14 #include "fpdfsdk/fsdk_actionhandler.h" | 14 #include "fpdfsdk/fsdk_actionhandler.h" |
15 #include "fpdfsdk/javascript/ijs_runtime.h" | 15 #include "fpdfsdk/javascript/ijs_runtime.h" |
| 16 #include "third_party/base/ptr_util.h" |
16 | 17 |
17 #ifdef PDF_ENABLE_XFA | 18 #ifdef PDF_ENABLE_XFA |
18 #include "fpdfsdk/fpdfxfa/fpdfxfa_app.h" | 19 #include "fpdfsdk/fpdfxfa/fpdfxfa_app.h" |
19 #endif // PDF_ENABLE_XFA | 20 #endif // PDF_ENABLE_XFA |
20 | 21 |
21 namespace { | 22 namespace { |
22 | 23 |
23 // NOTE: |bsUTF16LE| must outlive the use of the result. Care must be taken | 24 // NOTE: |bsUTF16LE| must outlive the use of the result. Care must be taken |
24 // since modifying the result would impact |bsUTF16LE|. | 25 // since modifying the result would impact |bsUTF16LE|. |
25 FPDF_WIDESTRING AsFPDFWideString(CFX_ByteString* bsUTF16LE) { | 26 FPDF_WIDESTRING AsFPDFWideString(CFX_ByteString* bsUTF16LE) { |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 IJS_Runtime* CPDFSDK_Environment::GetJSRuntime() { | 195 IJS_Runtime* CPDFSDK_Environment::GetJSRuntime() { |
195 if (!IsJSInitiated()) | 196 if (!IsJSInitiated()) |
196 return nullptr; | 197 return nullptr; |
197 if (!m_pJSRuntime) | 198 if (!m_pJSRuntime) |
198 m_pJSRuntime.reset(IJS_Runtime::Create(this)); | 199 m_pJSRuntime.reset(IJS_Runtime::Create(this)); |
199 return m_pJSRuntime.get(); | 200 return m_pJSRuntime.get(); |
200 } | 201 } |
201 | 202 |
202 CPDFSDK_AnnotHandlerMgr* CPDFSDK_Environment::GetAnnotHandlerMgr() { | 203 CPDFSDK_AnnotHandlerMgr* CPDFSDK_Environment::GetAnnotHandlerMgr() { |
203 if (!m_pAnnotHandlerMgr) | 204 if (!m_pAnnotHandlerMgr) |
204 m_pAnnotHandlerMgr = WrapUnique(new CPDFSDK_AnnotHandlerMgr(this)); | 205 m_pAnnotHandlerMgr = pdfium::MakeUnique<CPDFSDK_AnnotHandlerMgr>(this); |
205 return m_pAnnotHandlerMgr.get(); | 206 return m_pAnnotHandlerMgr.get(); |
206 } | 207 } |
207 | 208 |
208 CPDFSDK_ActionHandler* CPDFSDK_Environment::GetActionHander() { | 209 CPDFSDK_ActionHandler* CPDFSDK_Environment::GetActionHander() { |
209 if (!m_pActionHandler) | 210 if (!m_pActionHandler) |
210 m_pActionHandler = WrapUnique(new CPDFSDK_ActionHandler()); | 211 m_pActionHandler = pdfium::MakeUnique<CPDFSDK_ActionHandler>(); |
211 return m_pActionHandler.get(); | 212 return m_pActionHandler.get(); |
212 } | 213 } |
213 | 214 |
214 CFFL_InteractiveFormFiller* CPDFSDK_Environment::GetInteractiveFormFiller() { | 215 CFFL_InteractiveFormFiller* CPDFSDK_Environment::GetInteractiveFormFiller() { |
215 if (!m_pFormFiller) | 216 if (!m_pFormFiller) |
216 m_pFormFiller = WrapUnique(new CFFL_InteractiveFormFiller(this)); | 217 m_pFormFiller = pdfium::MakeUnique<CFFL_InteractiveFormFiller>(this); |
217 return m_pFormFiller.get(); | 218 return m_pFormFiller.get(); |
218 } | 219 } |
219 | 220 |
220 void CPDFSDK_Environment::Invalidate(FPDF_PAGE page, | 221 void CPDFSDK_Environment::Invalidate(FPDF_PAGE page, |
221 double left, | 222 double left, |
222 double top, | 223 double top, |
223 double right, | 224 double right, |
224 double bottom) { | 225 double bottom) { |
225 if (m_pInfo && m_pInfo->FFI_Invalidate) | 226 if (m_pInfo && m_pInfo->FFI_Invalidate) |
226 m_pInfo->FFI_Invalidate(m_pInfo, page, left, top, right, bottom); | 227 m_pInfo->FFI_Invalidate(m_pInfo, page, left, top, right, bottom); |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
535 delete[] pbuff; | 536 delete[] pbuff; |
536 return wsRet; | 537 return wsRet; |
537 } | 538 } |
538 | 539 |
539 void CPDFSDK_Environment::PageEvent(int iPageCount, | 540 void CPDFSDK_Environment::PageEvent(int iPageCount, |
540 uint32_t dwEventType) const { | 541 uint32_t dwEventType) const { |
541 if (m_pInfo && m_pInfo->FFI_PageEvent) | 542 if (m_pInfo && m_pInfo->FFI_PageEvent) |
542 m_pInfo->FFI_PageEvent(m_pInfo, iPageCount, dwEventType); | 543 m_pInfo->FFI_PageEvent(m_pInfo, iPageCount, dwEventType); |
543 } | 544 } |
544 #endif // PDF_ENABLE_XFA | 545 #endif // PDF_ENABLE_XFA |
OLD | NEW |