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 <memory> | 9 #include <memory> |
10 | 10 |
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
457 return FALSE; | 457 return FALSE; |
458 | 458 |
459 *fileVersion = pParser->GetFileVersion(); | 459 *fileVersion = pParser->GetFileVersion(); |
460 return TRUE; | 460 return TRUE; |
461 } | 461 } |
462 | 462 |
463 // jabdelmalek: changed return type from uint32_t to build on Linux (and match | 463 // jabdelmalek: changed return type from uint32_t to build on Linux (and match |
464 // header). | 464 // header). |
465 DLLEXPORT unsigned long STDCALL FPDF_GetDocPermissions(FPDF_DOCUMENT document) { | 465 DLLEXPORT unsigned long STDCALL FPDF_GetDocPermissions(FPDF_DOCUMENT document) { |
466 CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document); | 466 CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document); |
467 if (!pDoc || !pDoc->GetParser()) | 467 // https://bugs.chromium.org/p/pdfium/issues/detail?id=499 |
| 468 if (!pDoc) { |
468 #ifndef PDF_ENABLE_XFA | 469 #ifndef PDF_ENABLE_XFA |
469 return 0; | 470 return 0; |
470 #else // PDF_ENABLE_XFA | 471 #else // PDF_ENABLE_XFA |
471 return (uint32_t)-1; | 472 return 0xFFFFFFFF; |
472 #endif // PDF_ENABLE_XFA | 473 #endif // PDF_ENABLE_XFA |
| 474 } |
473 | 475 |
474 CPDF_Dictionary* pDict = pDoc->GetParser()->GetEncryptDict(); | 476 return pDoc->GetUserPermissions(); |
475 return pDict ? pDict->GetIntegerBy("P") : (uint32_t)-1; | |
476 } | 477 } |
477 | 478 |
478 DLLEXPORT int STDCALL FPDF_GetSecurityHandlerRevision(FPDF_DOCUMENT document) { | 479 DLLEXPORT int STDCALL FPDF_GetSecurityHandlerRevision(FPDF_DOCUMENT document) { |
479 CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document); | 480 CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document); |
480 if (!pDoc || !pDoc->GetParser()) | 481 if (!pDoc || !pDoc->GetParser()) |
481 return -1; | 482 return -1; |
482 | 483 |
483 CPDF_Dictionary* pDict = pDoc->GetParser()->GetEncryptDict(); | 484 CPDF_Dictionary* pDict = pDoc->GetParser()->GetEncryptDict(); |
484 return pDict ? pDict->GetIntegerBy("R") : -1; | 485 return pDict ? pDict->GetIntegerBy("R") : -1; |
485 } | 486 } |
(...skipping 657 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1143 if (!buffer) { | 1144 if (!buffer) { |
1144 *buflen = len; | 1145 *buflen = len; |
1145 } else if (*buflen >= len) { | 1146 } else if (*buflen >= len) { |
1146 memcpy(buffer, utf16Name.c_str(), len); | 1147 memcpy(buffer, utf16Name.c_str(), len); |
1147 *buflen = len; | 1148 *buflen = len; |
1148 } else { | 1149 } else { |
1149 *buflen = -1; | 1150 *buflen = -1; |
1150 } | 1151 } |
1151 return (FPDF_DEST)pDestObj; | 1152 return (FPDF_DEST)pDestObj; |
1152 } | 1153 } |
OLD | NEW |