| 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_xml.h" | 15 #include "core/fxcrt/include/fx_xml.h" |
| 15 #include "fpdfsdk/include/fsdk_define.h" | 16 #include "fpdfsdk/include/fsdk_define.h" |
| 16 | 17 |
| 17 #ifdef PDF_ENABLE_XFA | 18 #ifdef PDF_ENABLE_XFA |
| 18 #include "fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h" | 19 #include "fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h" |
| 19 #endif // PDF_ENABLE_XFA | 20 #endif // PDF_ENABLE_XFA |
| 20 | 21 |
| 21 #define FPDFSDK_UNSUPPORT_CALL 100 | 22 #define FPDFSDK_UNSUPPORT_CALL 100 |
| 22 | 23 |
| 23 class CFSDK_UnsupportInfo_Adapter { | 24 class CFSDK_UnsupportInfo_Adapter : public CFX_Deletable { |
| 24 public: | 25 public: |
| 25 explicit CFSDK_UnsupportInfo_Adapter(UNSUPPORT_INFO* unsp_info) | 26 explicit CFSDK_UnsupportInfo_Adapter(UNSUPPORT_INFO* unsp_info) |
| 26 : m_unsp_info(unsp_info) {} | 27 : m_unsp_info(unsp_info) {} |
| 27 | 28 |
| 28 void ReportError(int nErrorType); | 29 void ReportError(int nErrorType); |
| 29 | 30 |
| 30 private: | 31 private: |
| 31 UNSUPPORT_INFO* const m_unsp_info; | 32 UNSUPPORT_INFO* const m_unsp_info; |
| 32 }; | 33 }; |
| 33 | 34 |
| 34 void CFSDK_UnsupportInfo_Adapter::ReportError(int nErrorType) { | 35 void CFSDK_UnsupportInfo_Adapter::ReportError(int nErrorType) { |
| 35 if (m_unsp_info && m_unsp_info->FSDK_UnSupport_Handler) { | 36 if (m_unsp_info && m_unsp_info->FSDK_UnSupport_Handler) { |
| 36 m_unsp_info->FSDK_UnSupport_Handler(m_unsp_info, nErrorType); | 37 m_unsp_info->FSDK_UnSupport_Handler(m_unsp_info, nErrorType); |
| 37 } | 38 } |
| 38 } | 39 } |
| 39 | 40 |
| 40 void FreeUnsupportInfo(void* pData) { | |
| 41 CFSDK_UnsupportInfo_Adapter* pAdapter = (CFSDK_UnsupportInfo_Adapter*)pData; | |
| 42 delete pAdapter; | |
| 43 } | |
| 44 | |
| 45 FX_BOOL FPDF_UnSupportError(int nError) { | 41 FX_BOOL FPDF_UnSupportError(int nError) { |
| 46 CFSDK_UnsupportInfo_Adapter* pAdapter = | 42 CFSDK_UnsupportInfo_Adapter* pAdapter = |
| 47 (CFSDK_UnsupportInfo_Adapter*)CPDF_ModuleMgr::Get()->GetPrivateData( | 43 static_cast<CFSDK_UnsupportInfo_Adapter*>( |
| 48 (void*)FPDFSDK_UNSUPPORT_CALL); | 44 CPDF_ModuleMgr::Get()->GetUnsupportInfoAdapter()); |
| 49 | |
| 50 if (!pAdapter) | 45 if (!pAdapter) |
| 51 return FALSE; | 46 return FALSE; |
| 47 |
| 52 pAdapter->ReportError(nError); | 48 pAdapter->ReportError(nError); |
| 53 return TRUE; | 49 return TRUE; |
| 54 } | 50 } |
| 55 | 51 |
| 56 DLLEXPORT FPDF_BOOL STDCALL | 52 DLLEXPORT FPDF_BOOL STDCALL |
| 57 FSDK_SetUnSpObjProcessHandler(UNSUPPORT_INFO* unsp_info) { | 53 FSDK_SetUnSpObjProcessHandler(UNSUPPORT_INFO* unsp_info) { |
| 58 if (!unsp_info || unsp_info->version != 1) | 54 if (!unsp_info || unsp_info->version != 1) |
| 59 return FALSE; | 55 return FALSE; |
| 60 CFSDK_UnsupportInfo_Adapter* pAdapter = | |
| 61 new CFSDK_UnsupportInfo_Adapter(unsp_info); | |
| 62 | 56 |
| 63 CPDF_ModuleMgr::Get()->SetPrivateData((void*)FPDFSDK_UNSUPPORT_CALL, pAdapter, | 57 CPDF_ModuleMgr::Get()->SetUnsupportInfoAdapter(std::unique_ptr<CFX_Deletable>( |
| 64 &FreeUnsupportInfo); | 58 new CFSDK_UnsupportInfo_Adapter(unsp_info))); |
| 65 | |
| 66 return TRUE; | 59 return TRUE; |
| 67 } | 60 } |
| 68 | 61 |
| 69 void CheckUnSupportAnnot(CPDF_Document* pDoc, const CPDF_Annot* pPDFAnnot) { | 62 void CheckUnSupportAnnot(CPDF_Document* pDoc, const CPDF_Annot* pPDFAnnot) { |
| 70 CFX_ByteString cbSubType = pPDFAnnot->GetSubType(); | 63 CFX_ByteString cbSubType = pPDFAnnot->GetSubType(); |
| 71 if (cbSubType.Compare("3D") == 0) { | 64 if (cbSubType.Compare("3D") == 0) { |
| 72 FPDF_UnSupportError(FPDF_UNSP_ANNOT_3DANNOT); | 65 FPDF_UnSupportError(FPDF_UNSP_ANNOT_3DANNOT); |
| 73 } else if (cbSubType.Compare("Screen") == 0) { | 66 } else if (cbSubType.Compare("Screen") == 0) { |
| 74 const CPDF_Dictionary* pAnnotDict = pPDFAnnot->GetAnnotDict(); | 67 const CPDF_Dictionary* pAnnotDict = pPDFAnnot->GetAnnotDict(); |
| 75 CFX_ByteString cbString; | 68 CFX_ByteString cbString; |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 return PAGEMODE_USETHUMBS; | 206 return PAGEMODE_USETHUMBS; |
| 214 if (strPageMode.EqualNoCase("FullScreen")) | 207 if (strPageMode.EqualNoCase("FullScreen")) |
| 215 return PAGEMODE_FULLSCREEN; | 208 return PAGEMODE_FULLSCREEN; |
| 216 if (strPageMode.EqualNoCase("UseOC")) | 209 if (strPageMode.EqualNoCase("UseOC")) |
| 217 return PAGEMODE_USEOC; | 210 return PAGEMODE_USEOC; |
| 218 if (strPageMode.EqualNoCase("UseAttachments")) | 211 if (strPageMode.EqualNoCase("UseAttachments")) |
| 219 return PAGEMODE_USEATTACHMENTS; | 212 return PAGEMODE_USEATTACHMENTS; |
| 220 | 213 |
| 221 return PAGEMODE_UNKNOWN; | 214 return PAGEMODE_UNKNOWN; |
| 222 } | 215 } |
| OLD | NEW |