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 "public/fpdfview.h" | 7 #include "public/fpdfview.h" |
8 | 8 |
9 #include "../include/fpdfxfa/fpdfxfa_app.h" | 9 #include "../include/fpdfxfa/fpdfxfa_app.h" |
10 #include "../include/fpdfxfa/fpdfxfa_doc.h" | 10 #include "../include/fpdfxfa/fpdfxfa_doc.h" |
11 #include "../include/fpdfxfa/fpdfxfa_page.h" | 11 #include "../include/fpdfxfa/fpdfxfa_page.h" |
12 #include "../include/fpdfxfa/fpdfxfa_util.h" | 12 #include "../include/fpdfxfa/fpdfxfa_util.h" |
13 #include "core/include/fpdfapi/fpdf_module.h" | 13 #include "core/include/fpdfapi/fpdf_module.h" |
14 #include "core/include/fxcodec/fx_codec.h" | 14 #include "core/include/fxcodec/fx_codec.h" |
15 #include "core/include/fxcrt/fx_safe_types.h" | 15 #include "core/include/fxcrt/fx_safe_types.h" |
16 #include "fpdfsdk/include/fsdk_define.h" | 16 #include "fpdfsdk/include/fsdk_define.h" |
17 #include "fpdfsdk/include/fsdk_mgr.h" | 17 #include "fpdfsdk/include/fsdk_mgr.h" |
18 #include "fpdfsdk/include/fsdk_rendercontext.h" | 18 #include "fpdfsdk/include/fsdk_rendercontext.h" |
19 #include "fpdfsdk/include/javascript/IJavaScript.h" | 19 #include "fpdfsdk/include/javascript/IJavaScript.h" |
20 #include "public/fpdf_ext.h" | 20 #include "public/fpdf_ext.h" |
21 #include "public/fpdf_formfill.h" | 21 #include "public/fpdf_formfill.h" |
22 #include "public/fpdf_progressive.h" | 22 #include "public/fpdf_progressive.h" |
23 #include "third_party/base/nonstd_unique_ptr.h" | 23 #include "third_party/base/nonstd_unique_ptr.h" |
24 #include "third_party/base/numerics/safe_conversions_impl.h" | 24 #include "third_party/base/numerics/safe_conversions_impl.h" |
25 | 25 |
| 26 UnderlyingDocumentType* UnderlyingFromFPDFDocument(FPDF_DOCUMENT doc) { |
| 27 return static_cast<UnderlyingDocumentType*>(doc); |
| 28 } |
| 29 |
| 30 FPDF_DOCUMENT FPDFDocumentFromUnderlying(UnderlyingDocumentType* doc) { |
| 31 return static_cast<FPDF_DOCUMENT>(doc); |
| 32 } |
| 33 |
| 34 UnderlyingPageType* UnderlyingFromFPDFPage(FPDF_PAGE page) { |
| 35 return static_cast<UnderlyingPageType*>(page); |
| 36 } |
| 37 |
26 CPDF_Document* CPDFDocumentFromFPDFDocument(FPDF_DOCUMENT doc) { | 38 CPDF_Document* CPDFDocumentFromFPDFDocument(FPDF_DOCUMENT doc) { |
27 return doc ? static_cast<CPDFXFA_Document*>(doc)->GetPDFDoc() : nullptr; | 39 return doc ? UnderlyingFromFPDFDocument(doc)->GetPDFDoc() : nullptr; |
28 } | 40 } |
29 | 41 |
30 FPDF_DOCUMENT FPDFDocumentFromCPDFDocument(CPDF_Document* doc) { | 42 FPDF_DOCUMENT FPDFDocumentFromCPDFDocument(CPDF_Document* doc) { |
31 return doc ? new CPDFXFA_Document(doc, CPDFXFA_App::GetInstance()) : nullptr; | 43 return doc ? FPDFDocumentFromUnderlying( |
| 44 new CPDFXFA_Document(doc, CPDFXFA_App::GetInstance())) |
| 45 : nullptr; |
32 } | 46 } |
33 | 47 |
34 CPDF_Page* CPDFPageFromFPDFPage(FPDF_PAGE page) { | 48 CPDF_Page* CPDFPageFromFPDFPage(FPDF_PAGE page) { |
35 return page ? static_cast<CPDFXFA_Page*>(page)->GetPDFPage() : nullptr; | 49 return page ? UnderlyingFromFPDFPage(page)->GetPDFPage() : nullptr; |
36 } | 50 } |
37 | 51 |
38 CFPDF_FileStream::CFPDF_FileStream(FPDF_FILEHANDLER* pFS) { | 52 CFPDF_FileStream::CFPDF_FileStream(FPDF_FILEHANDLER* pFS) { |
39 m_pFS = pFS; | 53 m_pFS = pFS; |
40 m_nCurPos = 0; | 54 m_nCurPos = 0; |
41 } | 55 } |
42 | 56 |
43 IFX_FileStream* CFPDF_FileStream::Retain() { | 57 IFX_FileStream* CFPDF_FileStream::Retain() { |
44 return this; | 58 return this; |
45 } | 59 } |
(...skipping 1010 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1056 if (!buffer) { | 1070 if (!buffer) { |
1057 *buflen = len; | 1071 *buflen = len; |
1058 } else if (*buflen >= len) { | 1072 } else if (*buflen >= len) { |
1059 memcpy(buffer, utf16Name.c_str(), len); | 1073 memcpy(buffer, utf16Name.c_str(), len); |
1060 *buflen = len; | 1074 *buflen = len; |
1061 } else { | 1075 } else { |
1062 *buflen = -1; | 1076 *buflen = -1; |
1063 } | 1077 } |
1064 return (FPDF_DEST)pDestObj; | 1078 return (FPDF_DEST)pDestObj; |
1065 } | 1079 } |
OLD | NEW |