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 "../include/fpdfxfa/fpdfxfa_app.h" | 9 #include "../include/fpdfxfa/fpdfxfa_app.h" |
10 #include "../include/fpdfxfa/fpdfxfa_doc.h" | 10 #include "../include/fpdfxfa/fpdfxfa_doc.h" |
(...skipping 855 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
866 pContext->m_pContext, pContext->m_pDevice, pContext->m_pOptions); | 866 pContext->m_pContext, pContext->m_pDevice, pContext->m_pOptions); |
867 pContext->m_pRenderer->Start(pause); | 867 pContext->m_pRenderer->Start(pause); |
868 if (bNeedToRestore) | 868 if (bNeedToRestore) |
869 pContext->m_pDevice->RestoreState(); | 869 pContext->m_pDevice->RestoreState(); |
870 } | 870 } |
871 | 871 |
872 DLLEXPORT int STDCALL FPDF_GetPageSizeByIndex(FPDF_DOCUMENT document, | 872 DLLEXPORT int STDCALL FPDF_GetPageSizeByIndex(FPDF_DOCUMENT document, |
873 int page_index, | 873 int page_index, |
874 double* width, | 874 double* width, |
875 double* height) { | 875 double* height) { |
876 CPDFXFA_Document* pDoc = (CPDFXFA_Document*)document; | 876 UnderlyingDocumentType* pDoc = UnderlyingFromFPDFDocument(document); |
877 if (pDoc == NULL) | 877 if (!pDoc) |
878 return FALSE; | 878 return FALSE; |
879 | 879 |
880 int count = pDoc->GetPageCount(); | 880 int count = pDoc->GetPageCount(); |
881 if (page_index < 0 || page_index >= count) | 881 if (page_index < 0 || page_index >= count) |
882 return FALSE; | 882 return FALSE; |
883 | 883 |
884 CPDFXFA_Page* pPage = pDoc->GetPage(page_index); | 884 CPDFXFA_Page* pPage = pDoc->GetPage(page_index); |
885 if (!pPage) | 885 if (!pPage) |
886 return FALSE; | 886 return FALSE; |
887 | 887 |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1014 str->len = 0; | 1014 str->len = 0; |
1015 return 0; | 1015 return 0; |
1016 } | 1016 } |
1017 | 1017 |
1018 DLLEXPORT FPDF_DEST STDCALL FPDF_GetNamedDest(FPDF_DOCUMENT document, | 1018 DLLEXPORT FPDF_DEST STDCALL FPDF_GetNamedDest(FPDF_DOCUMENT document, |
1019 int index, | 1019 int index, |
1020 void* buffer, | 1020 void* buffer, |
1021 long* buflen) { | 1021 long* buflen) { |
1022 if (!buffer) | 1022 if (!buffer) |
1023 *buflen = 0; | 1023 *buflen = 0; |
1024 if (!document || index < 0) | 1024 |
1025 return NULL; | 1025 if (index < 0) |
| 1026 return nullptr; |
1026 | 1027 |
1027 CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document); | 1028 CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document); |
| 1029 if (!pDoc) |
| 1030 return nullptr; |
| 1031 |
1028 CPDF_Dictionary* pRoot = pDoc->GetRoot(); | 1032 CPDF_Dictionary* pRoot = pDoc->GetRoot(); |
1029 if (!pRoot) | 1033 if (!pRoot) |
1030 return NULL; | 1034 return nullptr; |
1031 | 1035 |
1032 CPDF_Object* pDestObj = NULL; | 1036 CPDF_Object* pDestObj = NULL; |
1033 CFX_ByteString bsName; | 1037 CFX_ByteString bsName; |
1034 CPDF_NameTree nameTree(pDoc, FX_BSTRC("Dests")); | 1038 CPDF_NameTree nameTree(pDoc, FX_BSTRC("Dests")); |
1035 int count = nameTree.GetCount(); | 1039 int count = nameTree.GetCount(); |
1036 if (index >= count) { | 1040 if (index >= count) { |
1037 CPDF_Dictionary* pDest = pRoot->GetDict(FX_BSTRC("Dests")); | 1041 CPDF_Dictionary* pDest = pRoot->GetDict(FX_BSTRC("Dests")); |
1038 if (!pDest) | 1042 if (!pDest) |
1039 return NULL; | 1043 return NULL; |
1040 if (index >= count + pDest->GetCount()) | 1044 if (index >= count + pDest->GetCount()) |
(...skipping 28 matching lines...) Expand all Loading... |
1069 if (!buffer) { | 1073 if (!buffer) { |
1070 *buflen = len; | 1074 *buflen = len; |
1071 } else if (*buflen >= len) { | 1075 } else if (*buflen >= len) { |
1072 memcpy(buffer, utf16Name.c_str(), len); | 1076 memcpy(buffer, utf16Name.c_str(), len); |
1073 *buflen = len; | 1077 *buflen = len; |
1074 } else { | 1078 } else { |
1075 *buflen = -1; | 1079 *buflen = -1; |
1076 } | 1080 } |
1077 return (FPDF_DEST)pDestObj; | 1081 return (FPDF_DEST)pDestObj; |
1078 } | 1082 } |
OLD | NEW |