| 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/src/fpdfapi/fpdf_parser/fpdf_parser_utility.h" | 7 #include "core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.h" |
| 8 | 8 |
| 9 #include "core/include/fpdfapi/fpdf_parser.h" | 9 #include "core/include/fpdfapi/fpdf_parser.h" |
| 10 #include "core/include/fxcrt/fx_ext.h" | 10 #include "core/include/fxcrt/fx_ext.h" |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 buf.AppendBlock(acc.GetData(), acc.GetSize()); | 213 buf.AppendBlock(acc.GetData(), acc.GetSize()); |
| 214 buf << "\r\nendstream"; | 214 buf << "\r\nendstream"; |
| 215 break; | 215 break; |
| 216 } | 216 } |
| 217 default: | 217 default: |
| 218 ASSERT(FALSE); | 218 ASSERT(FALSE); |
| 219 break; | 219 break; |
| 220 } | 220 } |
| 221 return buf; | 221 return buf; |
| 222 } | 222 } |
| 223 | |
| 224 static CPDF_Object* SearchNumberNode(CPDF_Dictionary* pNode, int num) { | |
| 225 CPDF_Array* pLimits = pNode->GetArrayBy("Limits"); | |
| 226 if (pLimits && | |
| 227 (num < pLimits->GetIntegerAt(0) || num > pLimits->GetIntegerAt(1))) { | |
| 228 return NULL; | |
| 229 } | |
| 230 CPDF_Array* pNumbers = pNode->GetArrayBy("Nums"); | |
| 231 if (pNumbers) { | |
| 232 FX_DWORD dwCount = pNumbers->GetCount() / 2; | |
| 233 for (FX_DWORD i = 0; i < dwCount; i++) { | |
| 234 int index = pNumbers->GetIntegerAt(i * 2); | |
| 235 if (num == index) { | |
| 236 return pNumbers->GetElementValue(i * 2 + 1); | |
| 237 } | |
| 238 if (index > num) { | |
| 239 break; | |
| 240 } | |
| 241 } | |
| 242 return NULL; | |
| 243 } | |
| 244 CPDF_Array* pKids = pNode->GetArrayBy("Kids"); | |
| 245 if (!pKids) { | |
| 246 return NULL; | |
| 247 } | |
| 248 for (FX_DWORD i = 0; i < pKids->GetCount(); i++) { | |
| 249 CPDF_Dictionary* pKid = pKids->GetDictAt(i); | |
| 250 if (!pKid) { | |
| 251 continue; | |
| 252 } | |
| 253 CPDF_Object* pFound = SearchNumberNode(pKid, num); | |
| 254 if (pFound) { | |
| 255 return pFound; | |
| 256 } | |
| 257 } | |
| 258 return NULL; | |
| 259 } | |
| 260 | |
| 261 CPDF_Object* CPDF_NumberTree::LookupValue(int num) { | |
| 262 return SearchNumberNode(m_pRoot, num); | |
| 263 } | |
| OLD | NEW |