| 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 <utility> | 7 #include <utility> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "../../../include/fpdfapi/fpdf_module.h" | 10 #include "../../../include/fpdfapi/fpdf_module.h" |
| (...skipping 1975 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1986 } | 1986 } |
| 1987 } | 1987 } |
| 1988 if (!bFirst) { | 1988 if (!bFirst) { |
| 1989 buf.AppendByte((uint8_t)code); | 1989 buf.AppendByte((uint8_t)code); |
| 1990 } | 1990 } |
| 1991 return buf.GetByteString(); | 1991 return buf.GetByteString(); |
| 1992 } | 1992 } |
| 1993 void CPDF_SyntaxParser::ToNextLine() | 1993 void CPDF_SyntaxParser::ToNextLine() |
| 1994 { | 1994 { |
| 1995 uint8_t ch; | 1995 uint8_t ch; |
| 1996 while (1) { | 1996 while (GetNextChar(ch)) { |
| 1997 if (!GetNextChar(ch)) { | |
| 1998 return; | |
| 1999 } | |
| 2000 if (ch == '\n') { | 1997 if (ch == '\n') { |
| 2001 return; | 1998 break; |
| 2002 } | 1999 } |
| 2003 if (ch == '\r') { | 2000 if (ch == '\r') { |
| 2004 GetNextChar(ch); | 2001 GetNextChar(ch); |
| 2005 if (ch == '\n') { | 2002 if (ch != '\n') { |
| 2006 return; | 2003 --m_Pos; |
| 2007 } else { | |
| 2008 m_Pos --; | |
| 2009 return; | |
| 2010 } | 2004 } |
| 2005 break; |
| 2011 } | 2006 } |
| 2012 } | 2007 } |
| 2013 } | 2008 } |
| 2014 void CPDF_SyntaxParser::ToNextWord() | 2009 void CPDF_SyntaxParser::ToNextWord() |
| 2015 { | 2010 { |
| 2016 uint8_t ch; | 2011 uint8_t ch; |
| 2017 if (!GetNextChar(ch)) { | 2012 if (!GetNextChar(ch)) { |
| 2018 return; | 2013 return; |
| 2019 } | 2014 } |
| 2020 uint8_t type = PDF_CharType[ch]; | 2015 uint8_t type = PDF_CharType[ch]; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2072 FX_FILESIZE SavedPos = m_Pos; | 2067 FX_FILESIZE SavedPos = m_Pos; |
| 2073 CFX_ByteString nextword = GetNextWord(bIsNumber); | 2068 CFX_ByteString nextword = GetNextWord(bIsNumber); |
| 2074 if (bIsNumber) { | 2069 if (bIsNumber) { |
| 2075 CFX_ByteString nextword2 = GetNextWord(bIsNumber); | 2070 CFX_ByteString nextword2 = GetNextWord(bIsNumber); |
| 2076 if (nextword2 == FX_BSTRC("R")) { | 2071 if (nextword2 == FX_BSTRC("R")) { |
| 2077 FX_DWORD objnum = FXSYS_atoi(word); | 2072 FX_DWORD objnum = FXSYS_atoi(word); |
| 2078 if (bTypeOnly) { | 2073 if (bTypeOnly) { |
| 2079 return (CPDF_Object*)PDFOBJ_REFERENCE; | 2074 return (CPDF_Object*)PDFOBJ_REFERENCE; |
| 2080 } | 2075 } |
| 2081 return new CPDF_Reference(pObjList, objnum); | 2076 return new CPDF_Reference(pObjList, objnum); |
| 2082 } else { | |
| 2083 m_Pos = SavedPos; | |
| 2084 if (bTypeOnly) { | |
| 2085 return (CPDF_Object*)PDFOBJ_NUMBER; | |
| 2086 } | |
| 2087 return CPDF_Number::Create(word); | |
| 2088 } | 2077 } |
| 2089 } else { | |
| 2090 m_Pos = SavedPos; | |
| 2091 if (bTypeOnly) { | |
| 2092 return (CPDF_Object*)PDFOBJ_NUMBER; | |
| 2093 } | |
| 2094 return CPDF_Number::Create(word); | |
| 2095 } | 2078 } |
| 2079 m_Pos = SavedPos; |
| 2080 if (bTypeOnly) { |
| 2081 return (CPDF_Object*)PDFOBJ_NUMBER; |
| 2082 } |
| 2083 return CPDF_Number::Create(word); |
| 2096 } | 2084 } |
| 2097 if (word == FX_BSTRC("true") || word == FX_BSTRC("false")) { | 2085 if (word == FX_BSTRC("true") || word == FX_BSTRC("false")) { |
| 2098 if (bTypeOnly) { | 2086 if (bTypeOnly) { |
| 2099 return (CPDF_Object*)PDFOBJ_BOOLEAN; | 2087 return (CPDF_Object*)PDFOBJ_BOOLEAN; |
| 2100 } | 2088 } |
| 2101 return CPDF_Boolean::Create(word == FX_BSTRC("true")); | 2089 return CPDF_Boolean::Create(word == FX_BSTRC("true")); |
| 2102 } | 2090 } |
| 2103 if (word == FX_BSTRC("null")) { | 2091 if (word == FX_BSTRC("null")) { |
| 2104 if (bTypeOnly) { | 2092 if (bTypeOnly) { |
| 2105 return (CPDF_Object*)PDFOBJ_NULL; | 2093 return (CPDF_Object*)PDFOBJ_NULL; |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2245 return (CPDF_Object*)PDFOBJ_INVALID; | 2233 return (CPDF_Object*)PDFOBJ_INVALID; |
| 2246 } | 2234 } |
| 2247 return NULL; | 2235 return NULL; |
| 2248 } | 2236 } |
| 2249 if (bIsNumber) { | 2237 if (bIsNumber) { |
| 2250 FX_FILESIZE SavedPos = m_Pos; | 2238 FX_FILESIZE SavedPos = m_Pos; |
| 2251 CFX_ByteString nextword = GetNextWord(bIsNumber); | 2239 CFX_ByteString nextword = GetNextWord(bIsNumber); |
| 2252 if (bIsNumber) { | 2240 if (bIsNumber) { |
| 2253 CFX_ByteString nextword2 = GetNextWord(bIsNumber); | 2241 CFX_ByteString nextword2 = GetNextWord(bIsNumber); |
| 2254 if (nextword2 == FX_BSTRC("R")) { | 2242 if (nextword2 == FX_BSTRC("R")) { |
| 2255 FX_DWORD objnum = FXSYS_atoi(word); | |
| 2256 if (bTypeOnly) { | 2243 if (bTypeOnly) { |
| 2257 return (CPDF_Object*)PDFOBJ_REFERENCE; | 2244 return (CPDF_Object*)PDFOBJ_REFERENCE; |
| 2258 } | 2245 } |
| 2246 FX_DWORD objnum = FXSYS_atoi(word); |
| 2259 return new CPDF_Reference(pObjList, objnum); | 2247 return new CPDF_Reference(pObjList, objnum); |
| 2260 } else { | |
| 2261 m_Pos = SavedPos; | |
| 2262 if (bTypeOnly) { | |
| 2263 return (CPDF_Object*)PDFOBJ_NUMBER; | |
| 2264 } | |
| 2265 return CPDF_Number::Create(word); | |
| 2266 } | 2248 } |
| 2267 } else { | |
| 2268 m_Pos = SavedPos; | |
| 2269 if (bTypeOnly) { | |
| 2270 return (CPDF_Object*)PDFOBJ_NUMBER; | |
| 2271 } | |
| 2272 return CPDF_Number::Create(word); | |
| 2273 } | 2249 } |
| 2250 m_Pos = SavedPos; |
| 2251 if (bTypeOnly) { |
| 2252 return (CPDF_Object*)PDFOBJ_NUMBER; |
| 2253 } |
| 2254 return CPDF_Number::Create(word); |
| 2274 } | 2255 } |
| 2275 if (word == FX_BSTRC("true") || word == FX_BSTRC("false")) { | 2256 if (word == FX_BSTRC("true") || word == FX_BSTRC("false")) { |
| 2276 if (bTypeOnly) { | 2257 if (bTypeOnly) { |
| 2277 return (CPDF_Object*)PDFOBJ_BOOLEAN; | 2258 return (CPDF_Object*)PDFOBJ_BOOLEAN; |
| 2278 } | 2259 } |
| 2279 return CPDF_Boolean::Create(word == FX_BSTRC("true")); | 2260 return CPDF_Boolean::Create(word == FX_BSTRC("true")); |
| 2280 } | 2261 } |
| 2281 if (word == FX_BSTRC("null")) { | 2262 if (word == FX_BSTRC("null")) { |
| 2282 if (bTypeOnly) { | 2263 if (bTypeOnly) { |
| 2283 return (CPDF_Object*)PDFOBJ_NULL; | 2264 return (CPDF_Object*)PDFOBJ_NULL; |
| (...skipping 849 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3133 if (!m_objs_array.GetSize()) { | 3114 if (!m_objs_array.GetSize()) { |
| 3134 m_objs_array.RemoveAll(); | 3115 m_objs_array.RemoveAll(); |
| 3135 m_objnum_array.RemoveAll(); | 3116 m_objnum_array.RemoveAll(); |
| 3136 CFX_PtrArray obj_array; | 3117 CFX_PtrArray obj_array; |
| 3137 obj_array.Append(m_arrayAcroforms); | 3118 obj_array.Append(m_arrayAcroforms); |
| 3138 FX_BOOL bRet = IsObjectsAvail(obj_array, FALSE, pHints, m_objs_array); | 3119 FX_BOOL bRet = IsObjectsAvail(obj_array, FALSE, pHints, m_objs_array); |
| 3139 if (bRet) { | 3120 if (bRet) { |
| 3140 m_objs_array.RemoveAll(); | 3121 m_objs_array.RemoveAll(); |
| 3141 } | 3122 } |
| 3142 return bRet; | 3123 return bRet; |
| 3124 } |
| 3125 CFX_PtrArray new_objs_array; |
| 3126 FX_BOOL bRet = IsObjectsAvail(m_objs_array, FALSE, pHints, new_objs_array); |
| 3127 if (bRet) { |
| 3128 int32_t iSize = m_arrayAcroforms.GetSize(); |
| 3129 for (int32_t i = 0; i < iSize; ++i) { |
| 3130 ((CPDF_Object *)m_arrayAcroforms.GetAt(i))->Release(); |
| 3131 } |
| 3132 m_arrayAcroforms.RemoveAll(); |
| 3143 } else { | 3133 } else { |
| 3144 CFX_PtrArray new_objs_array; | 3134 m_objs_array.RemoveAll(); |
| 3145 FX_BOOL bRet = IsObjectsAvail(m_objs_array, FALSE, pHints, new_objs_arra
y); | 3135 m_objs_array.Append(new_objs_array); |
| 3146 if (bRet) { | |
| 3147 int32_t iSize = m_arrayAcroforms.GetSize(); | |
| 3148 for (int32_t i = 0; i < iSize; ++i) { | |
| 3149 ((CPDF_Object *)m_arrayAcroforms.GetAt(i))->Release(); | |
| 3150 } | |
| 3151 m_arrayAcroforms.RemoveAll(); | |
| 3152 } else { | |
| 3153 m_objs_array.RemoveAll(); | |
| 3154 m_objs_array.Append(new_objs_array); | |
| 3155 } | |
| 3156 return bRet; | |
| 3157 } | 3136 } |
| 3137 return bRet; |
| 3158 } | 3138 } |
| 3159 FX_BOOL CPDF_DataAvail::CheckAcroForm(IFX_DownloadHints* pHints) | 3139 FX_BOOL CPDF_DataAvail::CheckAcroForm(IFX_DownloadHints* pHints) |
| 3160 { | 3140 { |
| 3161 FX_BOOL bExist = FALSE; | 3141 FX_BOOL bExist = FALSE; |
| 3162 m_pAcroForm = GetObject(m_dwAcroFormObjNum, pHints, &bExist); | 3142 m_pAcroForm = GetObject(m_dwAcroFormObjNum, pHints, &bExist); |
| 3163 if (!bExist) { | 3143 if (!bExist) { |
| 3164 m_docStatus = PDF_DATAAVAIL_PAGETREE; | 3144 m_docStatus = PDF_DATAAVAIL_PAGETREE; |
| 3165 return TRUE; | 3145 return TRUE; |
| 3166 } | 3146 } |
| 3167 if (!m_pAcroForm) { | 3147 if (!m_pAcroForm) { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3201 return LoadAllFile(pHints); | 3181 return LoadAllFile(pHints); |
| 3202 case PDF_DATAAVAIL_ROOT: | 3182 case PDF_DATAAVAIL_ROOT: |
| 3203 return CheckRoot(pHints); | 3183 return CheckRoot(pHints); |
| 3204 case PDF_DATAAVAIL_INFO: | 3184 case PDF_DATAAVAIL_INFO: |
| 3205 return CheckInfo(pHints); | 3185 return CheckInfo(pHints); |
| 3206 case PDF_DATAAVAIL_ACROFORM: | 3186 case PDF_DATAAVAIL_ACROFORM: |
| 3207 return CheckAcroForm(pHints); | 3187 return CheckAcroForm(pHints); |
| 3208 case PDF_DATAAVAIL_PAGETREE: | 3188 case PDF_DATAAVAIL_PAGETREE: |
| 3209 if (m_bTotalLoadPageTree) { | 3189 if (m_bTotalLoadPageTree) { |
| 3210 return CheckPages(pHints); | 3190 return CheckPages(pHints); |
| 3211 } else { | |
| 3212 return LoadDocPages(pHints); | |
| 3213 } | 3191 } |
| 3192 return LoadDocPages(pHints); |
| 3214 case PDF_DATAAVAIL_PAGE: | 3193 case PDF_DATAAVAIL_PAGE: |
| 3215 if (m_bTotalLoadPageTree) { | 3194 if (m_bTotalLoadPageTree) { |
| 3216 return CheckPage(pHints); | 3195 return CheckPage(pHints); |
| 3217 } else { | |
| 3218 m_docStatus = PDF_DATAAVAIL_PAGE_LATERLOAD; | |
| 3219 return TRUE; | |
| 3220 } | 3196 } |
| 3197 m_docStatus = PDF_DATAAVAIL_PAGE_LATERLOAD; |
| 3198 return TRUE; |
| 3221 case PDF_DATAAVAIL_ERROR: | 3199 case PDF_DATAAVAIL_ERROR: |
| 3222 return LoadAllFile(pHints); | 3200 return LoadAllFile(pHints); |
| 3223 case PDF_DATAAVAIL_PAGE_LATERLOAD: | 3201 case PDF_DATAAVAIL_PAGE_LATERLOAD: |
| 3224 m_docStatus = PDF_DATAAVAIL_PAGE; | 3202 m_docStatus = PDF_DATAAVAIL_PAGE; |
| 3225 default: | 3203 default: |
| 3226 m_bDocAvail = TRUE; | 3204 m_bDocAvail = TRUE; |
| 3227 return TRUE; | 3205 return TRUE; |
| 3228 } | 3206 } |
| 3229 } | 3207 } |
| 3230 FX_BOOL CPDF_DataAvail::CheckPageStatus(IFX_DownloadHints* pHints) | 3208 FX_BOOL CPDF_DataAvail::CheckPageStatus(IFX_DownloadHints* pHints) |
| (...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3754 } | 3732 } |
| 3755 m_dwXRefOffset = (FX_FILESIZE)FXSYS_atoi64(xrefpos_str); | 3733 m_dwXRefOffset = (FX_FILESIZE)FXSYS_atoi64(xrefpos_str); |
| 3756 if (!m_dwXRefOffset || m_dwXRefOffset > m_dwFileLen) { | 3734 if (!m_dwXRefOffset || m_dwXRefOffset > m_dwFileLen) { |
| 3757 m_docStatus = PDF_DATAAVAIL_LOADALLFILE; | 3735 m_docStatus = PDF_DATAAVAIL_LOADALLFILE; |
| 3758 return TRUE; | 3736 return TRUE; |
| 3759 } | 3737 } |
| 3760 m_dwLastXRefOffset = m_dwXRefOffset; | 3738 m_dwLastXRefOffset = m_dwXRefOffset; |
| 3761 SetStartOffset(m_dwXRefOffset); | 3739 SetStartOffset(m_dwXRefOffset); |
| 3762 m_docStatus = PDF_DATAAVAIL_CROSSREF; | 3740 m_docStatus = PDF_DATAAVAIL_CROSSREF; |
| 3763 return TRUE; | 3741 return TRUE; |
| 3764 } else { | |
| 3765 m_docStatus = PDF_DATAAVAIL_LOADALLFILE; | |
| 3766 return TRUE; | |
| 3767 } | 3742 } |
| 3743 m_docStatus = PDF_DATAAVAIL_LOADALLFILE; |
| 3744 return TRUE; |
| 3768 } | 3745 } |
| 3769 pHints->AddSegment(req_pos, dwSize); | 3746 pHints->AddSegment(req_pos, dwSize); |
| 3770 return FALSE; | 3747 return FALSE; |
| 3771 } | 3748 } |
| 3772 int32_t CPDF_DataAvail::CheckCrossRefStream(IFX_DownloadHints* pHints, FX_FILESI
ZE &xref_offset) | 3749 int32_t CPDF_DataAvail::CheckCrossRefStream(IFX_DownloadHints* pHints, FX_FILESI
ZE &xref_offset) |
| 3773 { | 3750 { |
| 3774 xref_offset = 0; | 3751 xref_offset = 0; |
| 3775 FX_DWORD req_size = (FX_DWORD)(m_Pos + 512 > m_dwFileLen ? m_dwFileLen - m_P
os : 512); | 3752 FX_DWORD req_size = (FX_DWORD)(m_Pos + 512 > m_dwFileLen ? m_dwFileLen - m_P
os : 512); |
| 3776 if (m_pFileAvail->IsDataAvail(m_Pos, req_size)) { | 3753 if (m_pFileAvail->IsDataAvail(m_Pos, req_size)) { |
| 3777 int32_t iSize = (int32_t)(m_Pos + req_size - m_dwCurrentXRefSteam); | 3754 int32_t iSize = (int32_t)(m_Pos + req_size - m_dwCurrentXRefSteam); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 3792 return 0; | 3769 return 0; |
| 3793 } | 3770 } |
| 3794 CPDF_Dictionary* pDict = pObj->GetDict(); | 3771 CPDF_Dictionary* pDict = pObj->GetDict(); |
| 3795 CPDF_Object *pName = pDict ? pDict->GetElement(FX_BSTRC("Type")) : NULL; | 3772 CPDF_Object *pName = pDict ? pDict->GetElement(FX_BSTRC("Type")) : NULL; |
| 3796 if (pName && pName->GetType() == PDFOBJ_NAME) { | 3773 if (pName && pName->GetType() == PDFOBJ_NAME) { |
| 3797 if (pName->GetString() == FX_BSTRC("XRef")) { | 3774 if (pName->GetString() == FX_BSTRC("XRef")) { |
| 3798 m_Pos += m_parser.m_Syntax.SavePos(); | 3775 m_Pos += m_parser.m_Syntax.SavePos(); |
| 3799 xref_offset = pObj->GetDict()->GetInteger(FX_BSTRC("Prev")); | 3776 xref_offset = pObj->GetDict()->GetInteger(FX_BSTRC("Prev")); |
| 3800 pObj->Release(); | 3777 pObj->Release(); |
| 3801 return 1; | 3778 return 1; |
| 3802 } else { | |
| 3803 pObj->Release(); | |
| 3804 return -1; | |
| 3805 } | 3779 } |
| 3806 } | 3780 } |
| 3807 pObj->Release(); | 3781 pObj->Release(); |
| 3808 return -1; | 3782 return -1; |
| 3809 } | 3783 } |
| 3810 pHints->AddSegment(m_Pos, req_size); | 3784 pHints->AddSegment(m_Pos, req_size); |
| 3811 return 0; | 3785 return 0; |
| 3812 } | 3786 } |
| 3813 inline void CPDF_DataAvail::SetStartOffset(FX_FILESIZE dwOffset) | 3787 inline void CPDF_DataAvail::SetStartOffset(FX_FILESIZE dwOffset) |
| 3814 { | 3788 { |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3948 FX_FILESIZE xref_offset = 0; | 3922 FX_FILESIZE xref_offset = 0; |
| 3949 int32_t nRet = CheckCrossRefStream(pHints, xref_offset); | 3923 int32_t nRet = CheckCrossRefStream(pHints, xref_offset); |
| 3950 if (nRet == 1) { | 3924 if (nRet == 1) { |
| 3951 if (!xref_offset) { | 3925 if (!xref_offset) { |
| 3952 m_docStatus = PDF_DATAAVAIL_LOADALLCRSOSSREF; | 3926 m_docStatus = PDF_DATAAVAIL_LOADALLCRSOSSREF; |
| 3953 } else { | 3927 } else { |
| 3954 m_dwCurrentXRefSteam = xref_offset; | 3928 m_dwCurrentXRefSteam = xref_offset; |
| 3955 m_Pos = xref_offset; | 3929 m_Pos = xref_offset; |
| 3956 } | 3930 } |
| 3957 return TRUE; | 3931 return TRUE; |
| 3958 } else if (nRet == -1) { | 3932 } |
| 3933 if (nRet == -1) { |
| 3959 m_docStatus = PDF_DATAAVAIL_ERROR; | 3934 m_docStatus = PDF_DATAAVAIL_ERROR; |
| 3960 } | 3935 } |
| 3961 return FALSE; | 3936 return FALSE; |
| 3962 } | 3937 } |
| 3963 FX_BOOL CPDF_DataAvail::CheckCrossRef(IFX_DownloadHints* pHints) | 3938 FX_BOOL CPDF_DataAvail::CheckCrossRef(IFX_DownloadHints* pHints) |
| 3964 { | 3939 { |
| 3965 int32_t iSize = 0; | 3940 int32_t iSize = 0; |
| 3966 CFX_ByteString token; | 3941 CFX_ByteString token; |
| 3967 if (!GetNextToken(token)) { | 3942 if (!GetNextToken(token)) { |
| 3968 iSize = (int32_t)(m_Pos + 512 > m_dwFileLen ? m_dwFileLen - m_Pos : 512)
; | 3943 iSize = (int32_t)(m_Pos + 512 > m_dwFileLen ? m_dwFileLen - m_Pos : 512)
; |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4051 } else { | 4026 } else { |
| 4052 m_dwPrevXRefOffset = xrefpos; | 4027 m_dwPrevXRefOffset = xrefpos; |
| 4053 if (m_dwPrevXRefOffset >= m_dwFileLen) { | 4028 if (m_dwPrevXRefOffset >= m_dwFileLen) { |
| 4054 m_docStatus = PDF_DATAAVAIL_LOADALLFILE; | 4029 m_docStatus = PDF_DATAAVAIL_LOADALLFILE; |
| 4055 } else { | 4030 } else { |
| 4056 SetStartOffset(m_dwPrevXRefOffset); | 4031 SetStartOffset(m_dwPrevXRefOffset); |
| 4057 m_docStatus = PDF_DATAAVAIL_TRAILER_APPEND; | 4032 m_docStatus = PDF_DATAAVAIL_TRAILER_APPEND; |
| 4058 } | 4033 } |
| 4059 } | 4034 } |
| 4060 return TRUE; | 4035 return TRUE; |
| 4061 } else { | |
| 4062 m_dwPrevXRefOffset = 0; | |
| 4063 m_docStatus = PDF_DATAAVAIL_TRAILER_APPEND; | |
| 4064 pTrailer->Release(); | |
| 4065 } | 4036 } |
| 4037 m_dwPrevXRefOffset = 0; |
| 4038 m_docStatus = PDF_DATAAVAIL_TRAILER_APPEND; |
| 4039 pTrailer->Release(); |
| 4066 return TRUE; | 4040 return TRUE; |
| 4067 } | 4041 } |
| 4068 pHints->AddSegment(m_Pos, iTrailerSize); | 4042 pHints->AddSegment(m_Pos, iTrailerSize); |
| 4069 return FALSE; | 4043 return FALSE; |
| 4070 } | 4044 } |
| 4071 FX_BOOL CPDF_DataAvail::CheckPage(int32_t iPage, IFX_DownloadHints* pHints) | 4045 FX_BOOL CPDF_DataAvail::CheckPage(int32_t iPage, IFX_DownloadHints* pHints) |
| 4072 { | 4046 { |
| 4073 while (TRUE) { | 4047 while (TRUE) { |
| 4074 switch (m_docStatus) { | 4048 switch (m_docStatus) { |
| 4075 case PDF_DATAAVAIL_PAGETREE: | 4049 case PDF_DATAAVAIL_PAGETREE: |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4288 return FALSE; | 4262 return FALSE; |
| 4289 } | 4263 } |
| 4290 FX_BOOL CPDF_DataAvail::LoadDocPages(IFX_DownloadHints* pHints) | 4264 FX_BOOL CPDF_DataAvail::LoadDocPages(IFX_DownloadHints* pHints) |
| 4291 { | 4265 { |
| 4292 if (!CheckUnkownPageNode(m_PagesObjNum, &m_pageNodes, pHints)) { | 4266 if (!CheckUnkownPageNode(m_PagesObjNum, &m_pageNodes, pHints)) { |
| 4293 return FALSE; | 4267 return FALSE; |
| 4294 } | 4268 } |
| 4295 if (CheckPageCount(pHints)) { | 4269 if (CheckPageCount(pHints)) { |
| 4296 m_docStatus = PDF_DATAAVAIL_PAGE; | 4270 m_docStatus = PDF_DATAAVAIL_PAGE; |
| 4297 return TRUE; | 4271 return TRUE; |
| 4298 } else { | |
| 4299 m_bTotalLoadPageTree = TRUE; | |
| 4300 } | 4272 } |
| 4273 m_bTotalLoadPageTree = TRUE; |
| 4301 return FALSE; | 4274 return FALSE; |
| 4302 } | 4275 } |
| 4303 FX_BOOL CPDF_DataAvail::LoadPages(IFX_DownloadHints* pHints) | 4276 FX_BOOL CPDF_DataAvail::LoadPages(IFX_DownloadHints* pHints) |
| 4304 { | 4277 { |
| 4305 while (!m_bPagesTreeLoad) { | 4278 while (!m_bPagesTreeLoad) { |
| 4306 if (!CheckPageStatus(pHints)) { | 4279 if (!CheckPageStatus(pHints)) { |
| 4307 return FALSE; | 4280 return FALSE; |
| 4308 } | 4281 } |
| 4309 } | 4282 } |
| 4310 if (m_bPagesLoad) { | 4283 if (m_bPagesLoad) { |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4356 if (!pAnnots) { | 4329 if (!pAnnots) { |
| 4357 return TRUE; | 4330 return TRUE; |
| 4358 } | 4331 } |
| 4359 CFX_PtrArray obj_array; | 4332 CFX_PtrArray obj_array; |
| 4360 obj_array.Add(pAnnots); | 4333 obj_array.Add(pAnnots); |
| 4361 FX_BOOL bRet = IsObjectsAvail(obj_array, FALSE, pHints, m_objs_array); | 4334 FX_BOOL bRet = IsObjectsAvail(obj_array, FALSE, pHints, m_objs_array); |
| 4362 if (bRet) { | 4335 if (bRet) { |
| 4363 m_objs_array.RemoveAll(); | 4336 m_objs_array.RemoveAll(); |
| 4364 } | 4337 } |
| 4365 return bRet; | 4338 return bRet; |
| 4366 } else { | |
| 4367 CFX_PtrArray new_objs_array; | |
| 4368 FX_BOOL bRet = IsObjectsAvail(m_objs_array, FALSE, pHints, new_objs_arra
y); | |
| 4369 m_objs_array.RemoveAll(); | |
| 4370 if (!bRet) { | |
| 4371 m_objs_array.Append(new_objs_array); | |
| 4372 } | |
| 4373 return bRet; | |
| 4374 } | 4339 } |
| 4340 CFX_PtrArray new_objs_array; |
| 4341 FX_BOOL bRet = IsObjectsAvail(m_objs_array, FALSE, pHints, new_objs_array); |
| 4342 m_objs_array.RemoveAll(); |
| 4343 if (!bRet) { |
| 4344 m_objs_array.Append(new_objs_array); |
| 4345 } |
| 4346 return bRet; |
| 4375 } | 4347 } |
| 4376 FX_BOOL CPDF_DataAvail::CheckLinearizedFirstPage(int32_t iPage, IFX_DownloadHint
s* pHints) | 4348 FX_BOOL CPDF_DataAvail::CheckLinearizedFirstPage(int32_t iPage, IFX_DownloadHint
s* pHints) |
| 4377 { | 4349 { |
| 4378 if (!m_bAnnotsLoad) { | 4350 if (!m_bAnnotsLoad) { |
| 4379 if (!CheckPageAnnots(iPage, pHints)) { | 4351 if (!CheckPageAnnots(iPage, pHints)) { |
| 4380 return FALSE; | 4352 return FALSE; |
| 4381 } | 4353 } |
| 4382 m_bAnnotsLoad = TRUE; | 4354 m_bAnnotsLoad = TRUE; |
| 4383 } | 4355 } |
| 4384 if (m_bAnnotsLoad) | 4356 if (m_bAnnotsLoad) { |
| 4385 if (!CheckLinearizedData(pHints)) { | 4357 if (!CheckLinearizedData(pHints)) |
| 4386 return FALSE; | 4358 return FALSE; |
| 4387 } | 4359 } |
| 4388 m_bPageLoadedOK = FALSE; | 4360 m_bPageLoadedOK = FALSE; |
| 4389 return TRUE; | 4361 return TRUE; |
| 4390 } | 4362 } |
| 4391 FX_BOOL CPDF_DataAvail::HaveResourceAncestor(CPDF_Dictionary *pDict) | 4363 FX_BOOL CPDF_DataAvail::HaveResourceAncestor(CPDF_Dictionary *pDict) |
| 4392 { | 4364 { |
| 4393 CFX_AutoRestorer<int> restorer(&s_CurrentDataAvailRecursionDepth); | 4365 CFX_AutoRestorer<int> restorer(&s_CurrentDataAvailRecursionDepth); |
| 4394 if (++s_CurrentDataAvailRecursionDepth > kMaxDataAvailRecursionDepth) { | 4366 if (++s_CurrentDataAvailRecursionDepth > kMaxDataAvailRecursionDepth) { |
| 4395 return FALSE; | 4367 return FALSE; |
| 4396 } | 4368 } |
| 4397 CPDF_Object *pParent = pDict->GetElement("Parent"); | 4369 CPDF_Object *pParent = pDict->GetElement("Parent"); |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4532 { | 4504 { |
| 4533 if (!m_objs_array.GetSize()) { | 4505 if (!m_objs_array.GetSize()) { |
| 4534 m_objs_array.RemoveAll(); | 4506 m_objs_array.RemoveAll(); |
| 4535 CFX_PtrArray obj_array; | 4507 CFX_PtrArray obj_array; |
| 4536 obj_array.Add(m_pPageResource); | 4508 obj_array.Add(m_pPageResource); |
| 4537 FX_BOOL bRet = IsObjectsAvail(obj_array, TRUE, pHints, m_objs_array); | 4509 FX_BOOL bRet = IsObjectsAvail(obj_array, TRUE, pHints, m_objs_array); |
| 4538 if (bRet) { | 4510 if (bRet) { |
| 4539 m_objs_array.RemoveAll(); | 4511 m_objs_array.RemoveAll(); |
| 4540 } | 4512 } |
| 4541 return bRet; | 4513 return bRet; |
| 4542 } else { | |
| 4543 CFX_PtrArray new_objs_array; | |
| 4544 FX_BOOL bRet = IsObjectsAvail(m_objs_array, FALSE, pHints, new_objs_arra
y); | |
| 4545 m_objs_array.RemoveAll(); | |
| 4546 if (!bRet) { | |
| 4547 m_objs_array.Append(new_objs_array); | |
| 4548 } | |
| 4549 return bRet; | |
| 4550 } | 4514 } |
| 4515 CFX_PtrArray new_objs_array; |
| 4516 FX_BOOL bRet = IsObjectsAvail(m_objs_array, FALSE, pHints, new_objs_array); |
| 4517 m_objs_array.RemoveAll(); |
| 4518 if (!bRet) { |
| 4519 m_objs_array.Append(new_objs_array); |
| 4520 } |
| 4521 return bRet; |
| 4551 } | 4522 } |
| 4552 void CPDF_DataAvail::GetLinearizedMainXRefInfo(FX_FILESIZE *pPos, FX_DWORD *pSiz
e) | 4523 void CPDF_DataAvail::GetLinearizedMainXRefInfo(FX_FILESIZE *pPos, FX_DWORD *pSiz
e) |
| 4553 { | 4524 { |
| 4554 if (pPos) { | 4525 if (pPos) { |
| 4555 *pPos = m_dwLastXRefOffset; | 4526 *pPos = m_dwLastXRefOffset; |
| 4556 } | 4527 } |
| 4557 if (pSize) { | 4528 if (pSize) { |
| 4558 *pSize = (FX_DWORD)(m_dwFileLen - m_dwLastXRefOffset); | 4529 *pSize = (FX_DWORD)(m_dwFileLen - m_dwLastXRefOffset); |
| 4559 } | 4530 } |
| 4560 } | 4531 } |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4597 } | 4568 } |
| 4598 m_number_array.InsertAt(iNext, dwObjNum); | 4569 m_number_array.InsertAt(iNext, dwObjNum); |
| 4599 } | 4570 } |
| 4600 FX_BOOL CPDF_SortObjNumArray::Find(FX_DWORD dwObjNum) | 4571 FX_BOOL CPDF_SortObjNumArray::Find(FX_DWORD dwObjNum) |
| 4601 { | 4572 { |
| 4602 int32_t iNext = 0; | 4573 int32_t iNext = 0; |
| 4603 return BinarySearch(dwObjNum, iNext); | 4574 return BinarySearch(dwObjNum, iNext); |
| 4604 } | 4575 } |
| 4605 FX_BOOL CPDF_SortObjNumArray::BinarySearch(FX_DWORD value, int32_t &iNext) | 4576 FX_BOOL CPDF_SortObjNumArray::BinarySearch(FX_DWORD value, int32_t &iNext) |
| 4606 { | 4577 { |
| 4607 int32_t iLen = m_number_array.GetSize(); | |
| 4608 int32_t iLow = 0; | 4578 int32_t iLow = 0; |
| 4609 int32_t iHigh = iLen - 1; | 4579 int32_t iHigh = m_number_array.GetSize() - 1; |
| 4610 int32_t iMid = 0; | |
| 4611 while (iLow <= iHigh) { | 4580 while (iLow <= iHigh) { |
| 4612 iMid = (iLow + iHigh) / 2; | 4581 int32_t iMid = (iLow + iHigh) / 2; |
| 4613 if (m_number_array.GetAt(iMid) == value) { | 4582 if (m_number_array.GetAt(iMid) == value) { |
| 4614 iNext = iMid; | 4583 iNext = iMid; |
| 4615 return TRUE; | 4584 return TRUE; |
| 4616 } else if (m_number_array.GetAt(iMid) > value) { | 4585 } |
| 4586 if (m_number_array.GetAt(iMid) > value) { |
| 4617 iHigh = iMid - 1; | 4587 iHigh = iMid - 1; |
| 4618 } else if (m_number_array.GetAt(iMid) < value) { | 4588 } else if (m_number_array.GetAt(iMid) < value) { |
| 4619 iLow = iMid + 1; | 4589 iLow = iMid + 1; |
| 4620 } | 4590 } |
| 4621 } | 4591 } |
| 4622 iNext = iLow; | 4592 iNext = iLow; |
| 4623 return FALSE; | 4593 return FALSE; |
| 4624 } | 4594 } |
| 4625 CPDF_PageNode::~CPDF_PageNode() | 4595 CPDF_PageNode::~CPDF_PageNode() |
| 4626 { | 4596 { |
| 4627 int32_t iSize = m_childNode.GetSize(); | 4597 int32_t iSize = m_childNode.GetSize(); |
| 4628 for (int32_t i = 0; i < iSize; ++i) { | 4598 for (int32_t i = 0; i < iSize; ++i) { |
| 4629 CPDF_PageNode* pNode = (CPDF_PageNode*)m_childNode[i]; | 4599 CPDF_PageNode* pNode = (CPDF_PageNode*)m_childNode[i]; |
| 4630 delete pNode; | 4600 delete pNode; |
| 4631 } | 4601 } |
| 4632 m_childNode.RemoveAll(); | 4602 m_childNode.RemoveAll(); |
| 4633 } | 4603 } |
| OLD | NEW |