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 #include "../../public/fpdf_formfill.h" | 8 #include "../../public/fpdf_formfill.h" |
9 #include "../../public/fpdf_progressive.h" | 9 #include "../../public/fpdf_progressive.h" |
10 #include "../../public/fpdfview.h" | 10 #include "../../public/fpdfview.h" |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 } | 259 } |
260 CPDF_Document* pPDFDoc = pParser->GetDocument(); | 260 CPDF_Document* pPDFDoc = pParser->GetDocument(); |
261 if (!pPDFDoc) | 261 if (!pPDFDoc) |
262 return NULL; | 262 return NULL; |
263 | 263 |
264 CPDFXFA_App* pProvider = FPDFXFA_GetApp(); | 264 CPDFXFA_App* pProvider = FPDFXFA_GetApp(); |
265 CPDFXFA_Document* pDocument = FX_NEW CPDFXFA_Document(pPDFDoc, pProvider
); | 265 CPDFXFA_Document* pDocument = FX_NEW CPDFXFA_Document(pPDFDoc, pProvider
); |
266 return pDocument; | 266 return pDocument; |
267 } | 267 } |
268 | 268 |
269 DLLEXPORT FX_BOOL STDCALL FPDF_HasXFAField(FPDF_DOCUMENT document, int& docType) | 269 DLLEXPORT FX_BOOL STDCALL FPDF_HasXFAField(FPDF_DOCUMENT document, int* docType) |
270 { | 270 { |
271 if (!document) | 271 if (!document) |
272 return FALSE; | 272 return FALSE; |
273 | 273 |
274 CPDF_Document *pdfDoc = (static_cast<CPDFXFA_Document *>(document))->Get
PDFDoc(); | 274 CPDF_Document *pdfDoc = (static_cast<CPDFXFA_Document *>(document))->Get
PDFDoc(); |
275 if (!pdfDoc) | 275 if (!pdfDoc) |
276 return FALSE; | 276 return FALSE; |
277 | 277 |
278 CPDF_Dictionary* pRoot = pdfDoc->GetRoot(); | 278 CPDF_Dictionary* pRoot = pdfDoc->GetRoot(); |
279 if (!pRoot) | 279 if (!pRoot) |
280 return FALSE; | 280 return FALSE; |
281 | 281 |
282 CPDF_Dictionary* pAcroForm = pRoot->GetDict("AcroForm"); | 282 CPDF_Dictionary* pAcroForm = pRoot->GetDict("AcroForm"); |
283 if (!pAcroForm) | 283 if (!pAcroForm) |
284 return FALSE; | 284 return FALSE; |
285 | 285 |
286 CPDF_Object* pXFA = pAcroForm->GetElement("XFA"); | 286 CPDF_Object* pXFA = pAcroForm->GetElement("XFA"); |
287 if (!pXFA) | 287 if (!pXFA) |
288 return FALSE; | 288 return FALSE; |
289 | 289 |
290 FX_BOOL bDynamicXFA = pRoot->GetBoolean("NeedsRendering", FALSE); | 290 FX_BOOL bDynamicXFA = pRoot->GetBoolean("NeedsRendering", FALSE); |
291 | 291 |
292 if (bDynamicXFA) | 292 if (bDynamicXFA) |
293 » » docType = DOCTYPE_DYNIMIC_XFA; | 293 » » *docType = DOCTYPE_DYNIMIC_XFA; |
294 else | 294 else |
295 » » docType = DOCTYPE_STATIC_XFA; | 295 » » *docType = DOCTYPE_STATIC_XFA; |
296 | 296 |
297 return TRUE; | 297 return TRUE; |
298 } | 298 } |
299 | 299 |
300 DLLEXPORT FPDF_BOOL STDCALL FPDF_LoadXFA(FPDF_DOCUMENT document) | 300 DLLEXPORT FPDF_BOOL STDCALL FPDF_LoadXFA(FPDF_DOCUMENT document) |
301 { | 301 { |
302 return document && (static_cast<CPDFXFA_Document *>(document))->LoadXFAD
oc(); | 302 return document && (static_cast<CPDFXFA_Document *>(document))->LoadXFAD
oc(); |
303 } | 303 } |
304 | 304 |
305 | 305 |
(...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1004 | 1004 |
1005 if (str->str) | 1005 if (str->str) |
1006 { | 1006 { |
1007 FX_Free(str->str); | 1007 FX_Free(str->str); |
1008 str->str = NULL; | 1008 str->str = NULL; |
1009 } | 1009 } |
1010 str->len = 0; | 1010 str->len = 0; |
1011 return 0; | 1011 return 0; |
1012 } | 1012 } |
1013 | 1013 |
1014 DLLEXPORT FPDF_DEST STDCALL FPDF_GetNamedDest(FPDF_DOCUMENT document, int index,
void* buffer, long& buflen) | 1014 DLLEXPORT FPDF_DEST STDCALL FPDF_GetNamedDest(FPDF_DOCUMENT document, int index,
void* buffer, long* buflen) |
1015 { | 1015 { |
1016 if (!buffer) | 1016 if (!buffer) |
1017 buflen = 0; | 1017 *buflen = 0; |
1018 if (!document || index < 0) return NULL; | 1018 if (!document || index < 0) return NULL; |
1019 CPDF_Document* pDoc = ((CPDFXFA_Document*)document)->GetPDFDoc(); | 1019 CPDF_Document* pDoc = ((CPDFXFA_Document*)document)->GetPDFDoc(); |
1020 | 1020 |
1021 CPDF_Dictionary* pRoot = pDoc->GetRoot(); | 1021 CPDF_Dictionary* pRoot = pDoc->GetRoot(); |
1022 if (!pRoot) return NULL; | 1022 if (!pRoot) return NULL; |
1023 | 1023 |
1024 CPDF_Object* pDestObj = NULL; | 1024 CPDF_Object* pDestObj = NULL; |
1025 CFX_ByteString bsName; | 1025 CFX_ByteString bsName; |
1026 CPDF_NameTree nameTree(pDoc, FX_BSTRC("Dests")); | 1026 CPDF_NameTree nameTree(pDoc, FX_BSTRC("Dests")); |
1027 int count = nameTree.GetCount(); | 1027 int count = nameTree.GetCount(); |
(...skipping 16 matching lines...) Expand all Loading... |
1044 if (!pDestObj) return NULL; | 1044 if (!pDestObj) return NULL; |
1045 if (pDestObj->GetType() == PDFOBJ_DICTIONARY) { | 1045 if (pDestObj->GetType() == PDFOBJ_DICTIONARY) { |
1046 pDestObj = ((CPDF_Dictionary*)pDestObj)->GetArray(FX_BSTRC("D")); | 1046 pDestObj = ((CPDF_Dictionary*)pDestObj)->GetArray(FX_BSTRC("D")); |
1047 if (!pDestObj) return NULL; | 1047 if (!pDestObj) return NULL; |
1048 } | 1048 } |
1049 if (pDestObj->GetType() != PDFOBJ_ARRAY) return NULL; | 1049 if (pDestObj->GetType() != PDFOBJ_ARRAY) return NULL; |
1050 CFX_WideString wsName = PDF_DecodeText(bsName); | 1050 CFX_WideString wsName = PDF_DecodeText(bsName); |
1051 CFX_ByteString utf16Name = wsName.UTF16LE_Encode(); | 1051 CFX_ByteString utf16Name = wsName.UTF16LE_Encode(); |
1052 unsigned int len = utf16Name.GetLength(); | 1052 unsigned int len = utf16Name.GetLength(); |
1053 if (!buffer) { | 1053 if (!buffer) { |
1054 buflen = len; | 1054 *buflen = len; |
1055 } else if (buflen >= len) { | 1055 } else if (*buflen >= len) { |
1056 memcpy(buffer, utf16Name.c_str(), len); | 1056 memcpy(buffer, utf16Name.c_str(), len); |
1057 buflen = len; | 1057 *buflen = len; |
1058 } else { | 1058 } else { |
1059 buflen = -1; | 1059 *buflen = -1; |
1060 } | 1060 } |
1061 return (FPDF_DEST)pDestObj; | 1061 return (FPDF_DEST)pDestObj; |
1062 } | 1062 } |
OLD | NEW |