| 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/include/fpdfapi/fpdf_parser.h" | 7 #include "core/include/fpdfapi/fpdf_parser.h" |
| 8 | 8 |
| 9 #include "core/include/fxcrt/fx_ext.h" | 9 #include "core/include/fxcrt/fx_ext.h" |
| 10 | 10 |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 dest_buf[dest_len] = 0; | 331 dest_buf[dest_len] = 0; |
| 332 res.ReleaseBuffer(); | 332 res.ReleaseBuffer(); |
| 333 return res; | 333 return res; |
| 334 } | 334 } |
| 335 CFX_ByteTextBuf& operator<<(CFX_ByteTextBuf& buf, const CPDF_Object* pObj) { | 335 CFX_ByteTextBuf& operator<<(CFX_ByteTextBuf& buf, const CPDF_Object* pObj) { |
| 336 if (!pObj) { | 336 if (!pObj) { |
| 337 buf << " null"; | 337 buf << " null"; |
| 338 return buf; | 338 return buf; |
| 339 } | 339 } |
| 340 switch (pObj->GetType()) { | 340 switch (pObj->GetType()) { |
| 341 case PDFOBJ_NULL: | 341 case CPDF_Object::NULLOBJ: |
| 342 buf << " null"; | 342 buf << " null"; |
| 343 break; | 343 break; |
| 344 case PDFOBJ_BOOLEAN: | 344 case CPDF_Object::BOOLEAN: |
| 345 case PDFOBJ_NUMBER: | 345 case CPDF_Object::NUMBER: |
| 346 buf << " " << pObj->GetString(); | 346 buf << " " << pObj->GetString(); |
| 347 break; | 347 break; |
| 348 case PDFOBJ_STRING: | 348 case CPDF_Object::STRING: |
| 349 buf << PDF_EncodeString(pObj->GetString(), pObj->AsString()->IsHex()); | 349 buf << PDF_EncodeString(pObj->GetString(), pObj->AsString()->IsHex()); |
| 350 break; | 350 break; |
| 351 case PDFOBJ_NAME: { | 351 case CPDF_Object::NAME: { |
| 352 CFX_ByteString str = pObj->GetString(); | 352 CFX_ByteString str = pObj->GetString(); |
| 353 buf << "/" << PDF_NameEncode(str); | 353 buf << "/" << PDF_NameEncode(str); |
| 354 break; | 354 break; |
| 355 } | 355 } |
| 356 case PDFOBJ_REFERENCE: { | 356 case CPDF_Object::REFERENCE: { |
| 357 buf << " " << pObj->AsReference()->GetRefObjNum() << " 0 R "; | 357 buf << " " << pObj->AsReference()->GetRefObjNum() << " 0 R "; |
| 358 break; | 358 break; |
| 359 } | 359 } |
| 360 case PDFOBJ_ARRAY: { | 360 case CPDF_Object::ARRAY: { |
| 361 const CPDF_Array* p = pObj->AsArray(); | 361 const CPDF_Array* p = pObj->AsArray(); |
| 362 buf << "["; | 362 buf << "["; |
| 363 for (FX_DWORD i = 0; i < p->GetCount(); i++) { | 363 for (FX_DWORD i = 0; i < p->GetCount(); i++) { |
| 364 CPDF_Object* pElement = p->GetElement(i); | 364 CPDF_Object* pElement = p->GetElement(i); |
| 365 if (pElement->GetObjNum()) { | 365 if (pElement->GetObjNum()) { |
| 366 buf << " " << pElement->GetObjNum() << " 0 R"; | 366 buf << " " << pElement->GetObjNum() << " 0 R"; |
| 367 } else { | 367 } else { |
| 368 buf << pElement; | 368 buf << pElement; |
| 369 } | 369 } |
| 370 } | 370 } |
| 371 buf << "]"; | 371 buf << "]"; |
| 372 break; | 372 break; |
| 373 } | 373 } |
| 374 case PDFOBJ_DICTIONARY: { | 374 case CPDF_Object::DICTIONARY: { |
| 375 const CPDF_Dictionary* p = pObj->AsDictionary(); | 375 const CPDF_Dictionary* p = pObj->AsDictionary(); |
| 376 buf << "<<"; | 376 buf << "<<"; |
| 377 for (const auto& it : *p) { | 377 for (const auto& it : *p) { |
| 378 const CFX_ByteString& key = it.first; | 378 const CFX_ByteString& key = it.first; |
| 379 CPDF_Object* pValue = it.second; | 379 CPDF_Object* pValue = it.second; |
| 380 buf << "/" << PDF_NameEncode(key); | 380 buf << "/" << PDF_NameEncode(key); |
| 381 if (pValue && pValue->GetObjNum()) { | 381 if (pValue && pValue->GetObjNum()) { |
| 382 buf << " " << pValue->GetObjNum() << " 0 R "; | 382 buf << " " << pValue->GetObjNum() << " 0 R "; |
| 383 } else { | 383 } else { |
| 384 buf << pValue; | 384 buf << pValue; |
| 385 } | 385 } |
| 386 } | 386 } |
| 387 buf << ">>"; | 387 buf << ">>"; |
| 388 break; | 388 break; |
| 389 } | 389 } |
| 390 case PDFOBJ_STREAM: { | 390 case CPDF_Object::STREAM: { |
| 391 const CPDF_Stream* p = pObj->AsStream(); | 391 const CPDF_Stream* p = pObj->AsStream(); |
| 392 buf << p->GetDict() << "stream\r\n"; | 392 buf << p->GetDict() << "stream\r\n"; |
| 393 CPDF_StreamAcc acc; | 393 CPDF_StreamAcc acc; |
| 394 acc.LoadAllData(p, TRUE); | 394 acc.LoadAllData(p, TRUE); |
| 395 buf.AppendBlock(acc.GetData(), acc.GetSize()); | 395 buf.AppendBlock(acc.GetData(), acc.GetSize()); |
| 396 buf << "\r\nendstream"; | 396 buf << "\r\nendstream"; |
| 397 break; | 397 break; |
| 398 } | 398 } |
| 399 default: | 399 default: |
| 400 ASSERT(FALSE); | 400 ASSERT(FALSE); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 443 CPDF_Object* pFound = SearchNumberNode(pKid, num); | 443 CPDF_Object* pFound = SearchNumberNode(pKid, num); |
| 444 if (pFound) { | 444 if (pFound) { |
| 445 return pFound; | 445 return pFound; |
| 446 } | 446 } |
| 447 } | 447 } |
| 448 return NULL; | 448 return NULL; |
| 449 } | 449 } |
| 450 CPDF_Object* CPDF_NumberTree::LookupValue(int num) { | 450 CPDF_Object* CPDF_NumberTree::LookupValue(int num) { |
| 451 return SearchNumberNode(m_pRoot, num); | 451 return SearchNumberNode(m_pRoot, num); |
| 452 } | 452 } |
| OLD | NEW |