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 "../../core/include/fxcrt/fx_xml.h" | 7 #include "../../core/include/fxcrt/fx_xml.h" |
8 #include "../../public/fpdf_ext.h" | 8 #include "../../public/fpdf_ext.h" |
9 #include "../include/fsdk_define.h" | 9 #include "../include/fsdk_define.h" |
10 #include "../include/fpdfxfa/fpdfxfa_doc.h" | 10 #include "../include/fpdfxfa/fpdfxfa_doc.h" |
11 | 11 |
12 #define FPDFSDK_UNSUPPORT_CALL 100 | 12 #define FPDFSDK_UNSUPPORT_CALL 100 |
13 | 13 |
14 class CFSDK_UnsupportInfo_Adapter | 14 class CFSDK_UnsupportInfo_Adapter |
15 { | 15 { |
16 public: | 16 public: |
17 » CFSDK_UnsupportInfo_Adapter(UNSUPPORT_INFO* unsp_info){ m_unsp_info = un
sp_info;} | 17 CFSDK_UnsupportInfo_Adapter(UNSUPPORT_INFO* unsp_info){ m_unsp_info = unsp_i
nfo;} |
18 //» FX_BOOL NeedToPauseNow(); | 18 // FX_BOOL NeedToPauseNow(); |
19 » void ReportError(int nErrorType); | 19 void ReportError(int nErrorType); |
20 | 20 |
21 private: | 21 private: |
22 » UNSUPPORT_INFO* m_unsp_info; | 22 UNSUPPORT_INFO* m_unsp_info; |
23 }; | 23 }; |
24 | 24 |
25 void CFSDK_UnsupportInfo_Adapter::ReportError(int nErrorType) | 25 void CFSDK_UnsupportInfo_Adapter::ReportError(int nErrorType) |
26 { | 26 { |
27 » if(m_unsp_info && m_unsp_info->FSDK_UnSupport_Handler) | 27 if(m_unsp_info && m_unsp_info->FSDK_UnSupport_Handler) |
28 » { | 28 { |
29 » » m_unsp_info->FSDK_UnSupport_Handler(m_unsp_info,nErrorType); | 29 m_unsp_info->FSDK_UnSupport_Handler(m_unsp_info,nErrorType); |
30 » } | 30 } |
31 } | 31 } |
32 | 32 |
33 void FreeUnsupportInfo(void* pData) | 33 void FreeUnsupportInfo(void* pData) |
34 { | 34 { |
35 » CFSDK_UnsupportInfo_Adapter * pAdapter = (CFSDK_UnsupportInfo_Adapter *)
pData; | 35 CFSDK_UnsupportInfo_Adapter * pAdapter = (CFSDK_UnsupportInfo_Adapter *)pDat
a; |
36 » delete pAdapter; | 36 delete pAdapter; |
37 } | 37 } |
38 | 38 |
39 FX_BOOL FPDF_UnSupportError(int nError) | 39 FX_BOOL FPDF_UnSupportError(int nError) |
40 { | 40 { |
41 » CFSDK_UnsupportInfo_Adapter * pAdapter = (CFSDK_UnsupportInfo_Adapter *)
CPDF_ModuleMgr::Get()->GetPrivateData((void *)FPDFSDK_UNSUPPORT_CALL); | 41 CFSDK_UnsupportInfo_Adapter * pAdapter = (CFSDK_UnsupportInfo_Adapter *)CPDF
_ModuleMgr::Get()->GetPrivateData((void *)FPDFSDK_UNSUPPORT_CALL); |
42 | 42 |
43 » if(!pAdapter) | 43 if(!pAdapter) |
44 » » return FALSE; | 44 return FALSE; |
45 » pAdapter->ReportError(nError); | 45 pAdapter->ReportError(nError); |
46 » return TRUE; | 46 return TRUE; |
47 } | 47 } |
48 | 48 |
49 DLLEXPORT FPDF_BOOL STDCALL FSDK_SetUnSpObjProcessHandler(UNSUPPORT_INFO* unsp_i
nfo) | 49 DLLEXPORT FPDF_BOOL STDCALL FSDK_SetUnSpObjProcessHandler(UNSUPPORT_INFO* unsp_i
nfo) |
50 { | 50 { |
51 » if (!unsp_info || unsp_info->version!=1) | 51 if (!unsp_info || unsp_info->version!=1) |
52 » » return FALSE; | 52 return FALSE; |
53 » CFSDK_UnsupportInfo_Adapter * pAdapter = new CFSDK_UnsupportInfo_Adapter
(unsp_info); | 53 CFSDK_UnsupportInfo_Adapter * pAdapter = new CFSDK_UnsupportInfo_Adapter(uns
p_info); |
54 | 54 |
55 » CPDF_ModuleMgr::Get()->SetPrivateData((void *)FPDFSDK_UNSUPPORT_CALL,pAd
apter, &FreeUnsupportInfo); | 55 CPDF_ModuleMgr::Get()->SetPrivateData((void *)FPDFSDK_UNSUPPORT_CALL,pAdapte
r, &FreeUnsupportInfo); |
56 | 56 |
57 » return TRUE; | 57 return TRUE; |
58 } | 58 } |
59 | 59 |
60 void CheckUnSupportAnnot(CPDF_Document * pDoc, CPDF_Annot* pPDFAnnot) | 60 void CheckUnSupportAnnot(CPDF_Document * pDoc, CPDF_Annot* pPDFAnnot) |
61 { | 61 { |
62 » CFX_ByteString cbSubType = pPDFAnnot->GetSubType(); | 62 CFX_ByteString cbSubType = pPDFAnnot->GetSubType(); |
63 » if(cbSubType.Compare("3D") == 0) | 63 if(cbSubType.Compare("3D") == 0) |
64 » { | 64 { |
65 » » FPDF_UnSupportError(FPDF_UNSP_ANNOT_3DANNOT); | 65 FPDF_UnSupportError(FPDF_UNSP_ANNOT_3DANNOT); |
66 » } | 66 } |
67 » else if(cbSubType.Compare("Screen") ==0) | 67 else if(cbSubType.Compare("Screen") ==0) |
68 » { | 68 { |
69 » » CPDF_Dictionary* pAnnotDict = pPDFAnnot->GetAnnotDict(); | 69 CPDF_Dictionary* pAnnotDict = pPDFAnnot->GetAnnotDict(); |
70 » » CFX_ByteString cbString; | 70 CFX_ByteString cbString; |
71 » » if(pAnnotDict->KeyExist("IT")) | 71 if(pAnnotDict->KeyExist("IT")) |
72 » » » cbString = pAnnotDict->GetString("IT"); | 72 cbString = pAnnotDict->GetString("IT"); |
73 » » if(cbString.Compare("Img") != 0) | 73 if(cbString.Compare("Img") != 0) |
74 » » » FPDF_UnSupportError(FPDF_UNSP_ANNOT_SCREEN_MEDIA); | 74 FPDF_UnSupportError(FPDF_UNSP_ANNOT_SCREEN_MEDIA); |
75 » } | 75 } |
76 » else if(cbSubType.Compare("Movie") ==0) | 76 else if(cbSubType.Compare("Movie") ==0) |
77 » { | 77 { |
78 » » FPDF_UnSupportError(FPDF_UNSP_ANNOT_MOVIE); | 78 FPDF_UnSupportError(FPDF_UNSP_ANNOT_MOVIE); |
79 » } | 79 } |
80 » else if(cbSubType.Compare("Sound") ==0) | 80 else if(cbSubType.Compare("Sound") ==0) |
81 » { | 81 { |
82 » » FPDF_UnSupportError(FPDF_UNSP_ANNOT_SOUND); | 82 FPDF_UnSupportError(FPDF_UNSP_ANNOT_SOUND); |
83 » } | 83 } |
84 » else if(cbSubType.Compare("RichMedia") ==0) | 84 else if(cbSubType.Compare("RichMedia") ==0) |
85 » { | 85 { |
86 » » FPDF_UnSupportError(FPDF_UNSP_ANNOT_SCREEN_RICHMEDIA); | 86 FPDF_UnSupportError(FPDF_UNSP_ANNOT_SCREEN_RICHMEDIA); |
87 » } | 87 } |
88 » else if(cbSubType.Compare("FileAttachment") ==0) | 88 else if(cbSubType.Compare("FileAttachment") ==0) |
89 » { | 89 { |
90 » » FPDF_UnSupportError(FPDF_UNSP_ANNOT_ATTACHMENT); | 90 FPDF_UnSupportError(FPDF_UNSP_ANNOT_ATTACHMENT); |
91 » } | 91 } |
92 » else if(cbSubType.Compare("Widget") ==0) | 92 else if(cbSubType.Compare("Widget") ==0) |
93 » { | 93 { |
94 » » CPDF_Dictionary* pAnnotDict = pPDFAnnot->GetAnnotDict(); | 94 CPDF_Dictionary* pAnnotDict = pPDFAnnot->GetAnnotDict(); |
95 » » CFX_ByteString cbString; | 95 CFX_ByteString cbString; |
96 » » if(pAnnotDict->KeyExist("FT")) | 96 if(pAnnotDict->KeyExist("FT")) |
97 » » { | 97 { |
98 » » » cbString = pAnnotDict->GetString("FT"); | 98 cbString = pAnnotDict->GetString("FT"); |
99 » » } | 99 } |
100 » » if(cbString.Compare("Sig") == 0) | 100 if(cbString.Compare("Sig") == 0) |
101 » » { | 101 { |
102 » » » FPDF_UnSupportError(FPDF_UNSP_ANNOT_SIG); | 102 FPDF_UnSupportError(FPDF_UNSP_ANNOT_SIG); |
103 » » } | 103 } |
104 » } | 104 } |
105 | 105 |
106 } | 106 } |
107 | 107 |
108 FX_BOOL CheckSharedForm(CXML_Element * pElement, CFX_ByteString cbName) | 108 FX_BOOL CheckSharedForm(CXML_Element * pElement, CFX_ByteString cbName) |
109 { | 109 { |
110 » int count = pElement->CountAttrs(); | 110 int count = pElement->CountAttrs(); |
111 » int i=0; | 111 int i=0; |
112 » for (i = 0; i < count; i++) | 112 for (i = 0; i < count; i++) |
113 » { | 113 { |
114 » » CFX_ByteString space, name; | 114 CFX_ByteString space, name; |
115 » » CFX_WideString value; | 115 CFX_WideString value; |
116 » » pElement->GetAttrByIndex(i, space, name, value); | 116 pElement->GetAttrByIndex(i, space, name, value); |
117 » » if (space == FX_BSTRC("xmlns") && name == FX_BSTRC("adhocwf") &&
value == L"http://ns.adobe.com/AcrobatAdhocWorkflow/1.0/") | 117 if (space == FX_BSTRC("xmlns") && name == FX_BSTRC("adhocwf") && value =
= L"http://ns.adobe.com/AcrobatAdhocWorkflow/1.0/") |
118 » » { | 118 { |
119 » » » CXML_Element *pVersion = pElement->GetElement("adhocwf",
cbName); | 119 CXML_Element *pVersion = pElement->GetElement("adhocwf",cbName); |
120 » » » if (!pVersion) | 120 if (!pVersion) |
121 » » » » continue; | 121 continue; |
122 » » » CFX_WideString wsContent = pVersion->GetContent(0); // =
= 1.1 | 122 CFX_WideString wsContent = pVersion->GetContent(0); // == 1.1 |
123 » » » int nType = wsContent.GetInteger(); | 123 int nType = wsContent.GetInteger(); |
124 » » » switch(nType) | 124 switch(nType) |
125 » » » { | 125 { |
126 » » » case 1: | 126 case 1: |
127 » » » » FPDF_UnSupportError(FPDF_UNSP_DOC_SHAREDFORM_ACR
OBAT); | 127 FPDF_UnSupportError(FPDF_UNSP_DOC_SHAREDFORM_ACROBAT); |
128 » » » » break; | 128 break; |
129 » » » case 2: | 129 case 2: |
130 » » » » FPDF_UnSupportError(FPDF_UNSP_DOC_SHAREDFORM_FIL
ESYSTEM); | 130 FPDF_UnSupportError(FPDF_UNSP_DOC_SHAREDFORM_FILESYSTEM); |
131 » » » » break; | 131 break; |
132 » » » case 0: | 132 case 0: |
133 » » » » FPDF_UnSupportError(FPDF_UNSP_DOC_SHAREDFORM_EMA
IL); | 133 FPDF_UnSupportError(FPDF_UNSP_DOC_SHAREDFORM_EMAIL); |
134 » » » » break; | 134 break; |
135 » » » } | 135 } |
136 » » } | 136 } |
137 » } | 137 } |
138 | 138 |
139 » FX_DWORD nCount = pElement->CountChildren(); | 139 FX_DWORD nCount = pElement->CountChildren(); |
140 » for(i=0; i<(int)nCount; i++) | 140 for(i=0; i<(int)nCount; i++) |
141 » { | 141 { |
142 » » CXML_Element::ChildType childType = pElement->GetChildType(i); | 142 CXML_Element::ChildType childType = pElement->GetChildType(i); |
143 » » if(childType == CXML_Element::Element) | 143 if(childType == CXML_Element::Element) |
144 » » { | 144 { |
145 » » » CXML_Element * pChild = pElement->GetElement(i); | 145 CXML_Element * pChild = pElement->GetElement(i); |
146 » » » if(CheckSharedForm(pChild, cbName)) | 146 if(CheckSharedForm(pChild, cbName)) |
147 » » » » return TRUE; | 147 return TRUE; |
148 » » } | 148 } |
149 » } | 149 } |
150 » return FALSE; | 150 return FALSE; |
151 } | 151 } |
152 | 152 |
153 void CheckUnSupportError(CPDF_Document * pDoc, FX_DWORD err_code) | 153 void CheckUnSupportError(CPDF_Document * pDoc, FX_DWORD err_code) |
154 { | 154 { |
155 // Security | 155 // Security |
156 if(err_code == FPDF_ERR_SECURITY) | 156 if(err_code == FPDF_ERR_SECURITY) |
157 { | 157 { |
158 FPDF_UnSupportError(FPDF_UNSP_DOC_SECURITY); | 158 FPDF_UnSupportError(FPDF_UNSP_DOC_SECURITY); |
159 return ; | 159 return ; |
160 } | 160 } |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 return PAGEMODE_USETHUMBS; | 229 return PAGEMODE_USETHUMBS; |
230 if (strPageMode.EqualNoCase("FullScreen")) | 230 if (strPageMode.EqualNoCase("FullScreen")) |
231 return PAGEMODE_FULLSCREEN; | 231 return PAGEMODE_FULLSCREEN; |
232 if (strPageMode.EqualNoCase("UseOC")) | 232 if (strPageMode.EqualNoCase("UseOC")) |
233 return PAGEMODE_USEOC; | 233 return PAGEMODE_USEOC; |
234 if (strPageMode.EqualNoCase("UseAttachments")) | 234 if (strPageMode.EqualNoCase("UseAttachments")) |
235 return PAGEMODE_USEATTACHMENTS; | 235 return PAGEMODE_USEATTACHMENTS; |
236 | 236 |
237 return PAGEMODE_UNKNOWN; | 237 return PAGEMODE_UNKNOWN; |
238 } | 238 } |
OLD | NEW |