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/fpdf_ext.h" | 7 #include "public/fpdf_ext.h" |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
11 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" | 11 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" |
12 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" | 12 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" |
13 #include "core/fpdfapi/include/cpdf_modulemgr.h" | 13 #include "core/fpdfapi/include/cpdf_modulemgr.h" |
14 #include "core/fxcrt/include/fx_basic.h" | 14 #include "core/fxcrt/include/fx_basic.h" |
| 15 #include "core/fxcrt/include/fx_memory.h" |
15 #include "core/fxcrt/include/fx_xml.h" | 16 #include "core/fxcrt/include/fx_xml.h" |
16 #include "fpdfsdk/include/fsdk_define.h" | 17 #include "fpdfsdk/include/fsdk_define.h" |
17 | 18 |
18 #ifdef PDF_ENABLE_XFA | 19 #ifdef PDF_ENABLE_XFA |
19 #include "fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h" | 20 #include "fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h" |
20 #endif // PDF_ENABLE_XFA | 21 #endif // PDF_ENABLE_XFA |
21 | 22 |
22 #define FPDFSDK_UNSUPPORT_CALL 100 | |
23 | |
24 class CFSDK_UnsupportInfo_Adapter : public CFX_Deletable { | |
25 public: | |
26 explicit CFSDK_UnsupportInfo_Adapter(UNSUPPORT_INFO* unsp_info) | |
27 : m_unsp_info(unsp_info) {} | |
28 | |
29 void ReportError(int nErrorType); | |
30 | |
31 private: | |
32 UNSUPPORT_INFO* const m_unsp_info; | |
33 }; | |
34 | |
35 void CFSDK_UnsupportInfo_Adapter::ReportError(int nErrorType) { | |
36 if (m_unsp_info && m_unsp_info->FSDK_UnSupport_Handler) { | |
37 m_unsp_info->FSDK_UnSupport_Handler(m_unsp_info, nErrorType); | |
38 } | |
39 } | |
40 | |
41 FX_BOOL FPDF_UnSupportError(int nError) { | 23 FX_BOOL FPDF_UnSupportError(int nError) { |
42 CFSDK_UnsupportInfo_Adapter* pAdapter = | 24 CFSDK_UnsupportInfo_Adapter* pAdapter = |
43 static_cast<CFSDK_UnsupportInfo_Adapter*>( | 25 CPDF_ModuleMgr::Get()->GetUnsupportInfoAdapter(); |
44 CPDF_ModuleMgr::Get()->GetUnsupportInfoAdapter()); | |
45 if (!pAdapter) | 26 if (!pAdapter) |
46 return FALSE; | 27 return FALSE; |
47 | 28 |
48 pAdapter->ReportError(nError); | 29 UNSUPPORT_INFO* info = static_cast<UNSUPPORT_INFO*>(pAdapter->GetUnspInfo()); |
| 30 if (info && info->FSDK_UnSupport_Handler) |
| 31 info->FSDK_UnSupport_Handler(info, nError); |
49 return TRUE; | 32 return TRUE; |
50 } | 33 } |
51 | 34 |
52 DLLEXPORT FPDF_BOOL STDCALL | 35 DLLEXPORT FPDF_BOOL STDCALL |
53 FSDK_SetUnSpObjProcessHandler(UNSUPPORT_INFO* unsp_info) { | 36 FSDK_SetUnSpObjProcessHandler(UNSUPPORT_INFO* unsp_info) { |
54 if (!unsp_info || unsp_info->version != 1) | 37 if (!unsp_info || unsp_info->version != 1) |
55 return FALSE; | 38 return FALSE; |
56 | 39 |
57 CPDF_ModuleMgr::Get()->SetUnsupportInfoAdapter(std::unique_ptr<CFX_Deletable>( | 40 CPDF_ModuleMgr::Get()->SetUnsupportInfoAdapter( |
58 new CFSDK_UnsupportInfo_Adapter(unsp_info))); | 41 WrapUnique(new CFSDK_UnsupportInfo_Adapter(unsp_info))); |
59 return TRUE; | 42 return TRUE; |
60 } | 43 } |
61 | 44 |
62 void CheckUnSupportAnnot(CPDF_Document* pDoc, const CPDF_Annot* pPDFAnnot) { | 45 void CheckUnSupportAnnot(CPDF_Document* pDoc, const CPDF_Annot* pPDFAnnot) { |
63 CFX_ByteString cbSubType = pPDFAnnot->GetSubType(); | 46 CFX_ByteString cbSubType = pPDFAnnot->GetSubType(); |
64 if (cbSubType.Compare("3D") == 0) { | 47 if (cbSubType.Compare("3D") == 0) { |
65 FPDF_UnSupportError(FPDF_UNSP_ANNOT_3DANNOT); | 48 FPDF_UnSupportError(FPDF_UNSP_ANNOT_3DANNOT); |
66 } else if (cbSubType.Compare("Screen") == 0) { | 49 } else if (cbSubType.Compare("Screen") == 0) { |
67 const CPDF_Dictionary* pAnnotDict = pPDFAnnot->GetAnnotDict(); | 50 const CPDF_Dictionary* pAnnotDict = pPDFAnnot->GetAnnotDict(); |
68 CFX_ByteString cbString; | 51 CFX_ByteString cbString; |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 return PAGEMODE_USETHUMBS; | 189 return PAGEMODE_USETHUMBS; |
207 if (strPageMode.EqualNoCase("FullScreen")) | 190 if (strPageMode.EqualNoCase("FullScreen")) |
208 return PAGEMODE_FULLSCREEN; | 191 return PAGEMODE_FULLSCREEN; |
209 if (strPageMode.EqualNoCase("UseOC")) | 192 if (strPageMode.EqualNoCase("UseOC")) |
210 return PAGEMODE_USEOC; | 193 return PAGEMODE_USEOC; |
211 if (strPageMode.EqualNoCase("UseAttachments")) | 194 if (strPageMode.EqualNoCase("UseAttachments")) |
212 return PAGEMODE_USEATTACHMENTS; | 195 return PAGEMODE_USEATTACHMENTS; |
213 | 196 |
214 return PAGEMODE_UNKNOWN; | 197 return PAGEMODE_UNKNOWN; |
215 } | 198 } |
OLD | NEW |