| 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/fpdfapi/fpdf_parser/include/cpdf_document.h" | 7 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" |
| 8 | 8 |
| 9 #include <set> | 9 #include <set> |
| 10 | 10 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 std::set<CPDF_Dictionary*>* visited_pages) { | 25 std::set<CPDF_Dictionary*>* visited_pages) { |
| 26 int count = pPages->GetIntegerBy("Count"); | 26 int count = pPages->GetIntegerBy("Count"); |
| 27 if (count > 0 && count < FPDF_PAGE_MAX_NUM) { | 27 if (count > 0 && count < FPDF_PAGE_MAX_NUM) { |
| 28 return count; | 28 return count; |
| 29 } | 29 } |
| 30 CPDF_Array* pKidList = pPages->GetArrayBy("Kids"); | 30 CPDF_Array* pKidList = pPages->GetArrayBy("Kids"); |
| 31 if (!pKidList) { | 31 if (!pKidList) { |
| 32 return 0; | 32 return 0; |
| 33 } | 33 } |
| 34 count = 0; | 34 count = 0; |
| 35 for (uint32_t i = 0; i < pKidList->GetCount(); i++) { | 35 for (size_t i = 0; i < pKidList->GetCount(); i++) { |
| 36 CPDF_Dictionary* pKid = pKidList->GetDictAt(i); | 36 CPDF_Dictionary* pKid = pKidList->GetDictAt(i); |
| 37 if (!pKid || pdfium::ContainsKey(*visited_pages, pKid)) { | 37 if (!pKid || pdfium::ContainsKey(*visited_pages, pKid)) { |
| 38 continue; | 38 continue; |
| 39 } | 39 } |
| 40 if (pKid->KeyExist("Kids")) { | 40 if (pKid->KeyExist("Kids")) { |
| 41 // Use |visited_pages| to help detect circular references of pages. | 41 // Use |visited_pages| to help detect circular references of pages. |
| 42 pdfium::ScopedSetInsertion<CPDF_Dictionary*> local_add(visited_pages, | 42 pdfium::ScopedSetInsertion<CPDF_Dictionary*> local_add(visited_pages, |
| 43 pKid); | 43 pKid); |
| 44 count += CountPages(pKid, visited_pages); | 44 count += CountPages(pKid, visited_pages); |
| 45 } else { | 45 } else { |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 CPDF_Array* pKidList = pPages->GetArrayBy("Kids"); | 148 CPDF_Array* pKidList = pPages->GetArrayBy("Kids"); |
| 149 if (!pKidList) { | 149 if (!pKidList) { |
| 150 if (nPagesToGo == 0) { | 150 if (nPagesToGo == 0) { |
| 151 return pPages; | 151 return pPages; |
| 152 } | 152 } |
| 153 return NULL; | 153 return NULL; |
| 154 } | 154 } |
| 155 if (level >= FX_MAX_PAGE_LEVEL) { | 155 if (level >= FX_MAX_PAGE_LEVEL) { |
| 156 return NULL; | 156 return NULL; |
| 157 } | 157 } |
| 158 int nKids = pKidList->GetCount(); | 158 for (size_t i = 0; i < pKidList->GetCount(); i++) { |
| 159 for (int i = 0; i < nKids; i++) { | |
| 160 CPDF_Dictionary* pKid = pKidList->GetDictAt(i); | 159 CPDF_Dictionary* pKid = pKidList->GetDictAt(i); |
| 161 if (!pKid) { | 160 if (!pKid) { |
| 162 nPagesToGo--; | 161 nPagesToGo--; |
| 163 continue; | 162 continue; |
| 164 } | 163 } |
| 165 if (pKid == pPages) { | 164 if (pKid == pPages) { |
| 166 continue; | 165 continue; |
| 167 } | 166 } |
| 168 if (!pKid->KeyExist("Kids")) { | 167 if (!pKid->KeyExist("Kids")) { |
| 169 if (nPagesToGo == 0) { | 168 if (nPagesToGo == 0) { |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 int& index, | 220 int& index, |
| 222 int level) { | 221 int level) { |
| 223 if (pNode->KeyExist("Kids")) { | 222 if (pNode->KeyExist("Kids")) { |
| 224 CPDF_Array* pKidList = pNode->GetArrayBy("Kids"); | 223 CPDF_Array* pKidList = pNode->GetArrayBy("Kids"); |
| 225 if (!pKidList) { | 224 if (!pKidList) { |
| 226 return -1; | 225 return -1; |
| 227 } | 226 } |
| 228 if (level >= FX_MAX_PAGE_LEVEL) { | 227 if (level >= FX_MAX_PAGE_LEVEL) { |
| 229 return -1; | 228 return -1; |
| 230 } | 229 } |
| 231 uint32_t count = pNode->GetIntegerBy("Count"); | 230 size_t count = pNode->GetIntegerBy("Count"); |
| 232 if (count <= skip_count) { | 231 if (count <= skip_count) { |
| 233 skip_count -= count; | 232 skip_count -= count; |
| 234 index += count; | 233 index += count; |
| 235 return -1; | 234 return -1; |
| 236 } | 235 } |
| 237 if (count && count == pKidList->GetCount()) { | 236 if (count && count == pKidList->GetCount()) { |
| 238 for (uint32_t i = 0; i < count; i++) { | 237 for (size_t i = 0; i < count; i++) { |
| 239 if (CPDF_Reference* pKid = ToReference(pKidList->GetObjectAt(i))) { | 238 if (CPDF_Reference* pKid = ToReference(pKidList->GetObjectAt(i))) { |
| 240 if (pKid->GetRefObjNum() == objnum) { | 239 if (pKid->GetRefObjNum() == objnum) { |
| 241 m_PageList.SetAt(index + i, objnum); | 240 m_PageList.SetAt(index + i, objnum); |
| 242 return index + i; | 241 return static_cast<int>(index + i); |
| 243 } | 242 } |
| 244 } | 243 } |
| 245 } | 244 } |
| 246 } | 245 } |
| 247 for (uint32_t i = 0; i < pKidList->GetCount(); i++) { | 246 for (size_t i = 0; i < pKidList->GetCount(); i++) { |
| 248 CPDF_Dictionary* pKid = pKidList->GetDictAt(i); | 247 CPDF_Dictionary* pKid = pKidList->GetDictAt(i); |
| 249 if (!pKid) { | 248 if (!pKid) { |
| 250 continue; | 249 continue; |
| 251 } | 250 } |
| 252 if (pKid == pNode) { | 251 if (pKid == pNode) { |
| 253 continue; | 252 continue; |
| 254 } | 253 } |
| 255 int found_index = | 254 int found_index = |
| 256 _FindPageIndex(pKid, skip_count, objnum, index, level + 1); | 255 _FindPageIndex(pKid, skip_count, objnum, index, level + 1); |
| 257 if (found_index >= 0) { | 256 if (found_index >= 0) { |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 } | 346 } |
| 348 | 347 |
| 349 void CPDF_Document::ClearRenderFont() { | 348 void CPDF_Document::ClearRenderFont() { |
| 350 if (!m_pDocRender) | 349 if (!m_pDocRender) |
| 351 return; | 350 return; |
| 352 | 351 |
| 353 CFX_FontCache* pCache = m_pDocRender->GetFontCache(); | 352 CFX_FontCache* pCache = m_pDocRender->GetFontCache(); |
| 354 if (pCache) | 353 if (pCache) |
| 355 pCache->FreeCache(FALSE); | 354 pCache->FreeCache(FALSE); |
| 356 } | 355 } |
| OLD | NEW |