Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(100)

Side by Side Diff: fpdfsdk/fpdf_flatten.cpp

Issue 1853233002: Make down-conversion explicit from CFX_ByteString to CFX_ByteStringC. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Fix CPDF_Name::GetConstString() Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « fpdfsdk/fpdf_ext.cpp ('k') | fpdfsdk/fpdfppo.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/fpdf_flatten.h" 7 #include "public/fpdf_flatten.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 } 388 }
389 389
390 CFX_ByteString key = ""; 390 CFX_ByteString key = "";
391 int nStreams = ObjectArray.GetSize(); 391 int nStreams = ObjectArray.GetSize();
392 392
393 if (nStreams > 0) { 393 if (nStreams > 0) {
394 for (int iKey = 0; /*iKey < 100*/; iKey++) { 394 for (int iKey = 0; /*iKey < 100*/; iKey++) {
395 char sExtend[5] = {}; 395 char sExtend[5] = {};
396 FXSYS_itoa(iKey, sExtend, 10); 396 FXSYS_itoa(iKey, sExtend, 10);
397 key = CFX_ByteString("FFT") + CFX_ByteString(sExtend); 397 key = CFX_ByteString("FFT") + CFX_ByteString(sExtend);
398 398 if (!pPageXObject->KeyExist(key.AsByteStringC()))
399 if (!pPageXObject->KeyExist(key))
400 break; 399 break;
401 } 400 }
402 } 401 }
403 402
404 SetPageContents(key, pPageDict, pDocument); 403 SetPageContents(key, pPageDict, pDocument);
405 404
406 CPDF_Dictionary* pNewXORes = NULL; 405 CPDF_Dictionary* pNewXORes = NULL;
407 406
408 if (!key.IsEmpty()) { 407 if (!key.IsEmpty()) {
409 pPageXObject->SetAtReference(key, pDocument, dwObjNum); 408 pPageXObject->SetAtReference(key.AsByteStringC(), pDocument, dwObjNum);
410 CPDF_Dictionary* pNewOXbjectDic = pNewXObject->GetDict(); 409 CPDF_Dictionary* pNewOXbjectDic = pNewXObject->GetDict();
411 pNewXORes = new CPDF_Dictionary; 410 pNewXORes = new CPDF_Dictionary;
412 pNewOXbjectDic->SetAt("Resources", pNewXORes); 411 pNewOXbjectDic->SetAt("Resources", pNewXORes);
413 pNewOXbjectDic->SetAtName("Type", "XObject"); 412 pNewOXbjectDic->SetAtName("Type", "XObject");
414 pNewOXbjectDic->SetAtName("Subtype", "Form"); 413 pNewOXbjectDic->SetAtName("Subtype", "Form");
415 pNewOXbjectDic->SetAtInteger("FormType", 1); 414 pNewOXbjectDic->SetAtInteger("FormType", 1);
416 pNewOXbjectDic->SetAtName("Name", "FRM"); 415 pNewOXbjectDic->SetAtName("Name", "FRM");
417 CFX_FloatRect rcBBox = pPageDict->GetRectBy("ArtBox"); 416 CFX_FloatRect rcBBox = pPageDict->GetRectBy("ArtBox");
418 pNewOXbjectDic->SetAtRect("BBox", rcBBox); 417 pNewOXbjectDic->SetAtRect("BBox", rcBBox);
419 } 418 }
(...skipping 11 matching lines...) Expand all
431 if (!pAnnotAP) 430 if (!pAnnotAP)
432 continue; 431 continue;
433 432
434 CPDF_Stream* pAPStream = pAnnotAP->GetStreamBy("N"); 433 CPDF_Stream* pAPStream = pAnnotAP->GetStreamBy("N");
435 if (!pAPStream) { 434 if (!pAPStream) {
436 CPDF_Dictionary* pAPDic = pAnnotAP->GetDictBy("N"); 435 CPDF_Dictionary* pAPDic = pAnnotAP->GetDictBy("N");
437 if (!pAPDic) 436 if (!pAPDic)
438 continue; 437 continue;
439 438
440 if (!sAnnotState.IsEmpty()) { 439 if (!sAnnotState.IsEmpty()) {
441 pAPStream = pAPDic->GetStreamBy(sAnnotState); 440 pAPStream = pAPDic->GetStreamBy(sAnnotState.AsByteStringC());
442 } else { 441 } else {
443 auto it = pAPDic->begin(); 442 auto it = pAPDic->begin();
444 if (it != pAPDic->end()) { 443 if (it != pAPDic->end()) {
445 CPDF_Object* pFirstObj = it->second; 444 CPDF_Object* pFirstObj = it->second;
446 if (pFirstObj) { 445 if (pFirstObj) {
447 if (pFirstObj->IsReference()) 446 if (pFirstObj->IsReference())
448 pFirstObj = pFirstObj->GetDirect(); 447 pFirstObj = pFirstObj->GetDirect();
449 if (!pFirstObj->IsStream()) 448 if (!pFirstObj->IsStream())
450 continue; 449 continue;
451 pAPStream = pFirstObj->AsStream(); 450 pAPStream = pFirstObj->AsStream();
(...skipping 28 matching lines...) Expand all
480 479
481 CPDF_Dictionary* pXObject = pNewXORes->GetDictBy("XObject"); 480 CPDF_Dictionary* pXObject = pNewXORes->GetDictBy("XObject");
482 if (!pXObject) { 481 if (!pXObject) {
483 pXObject = new CPDF_Dictionary; 482 pXObject = new CPDF_Dictionary;
484 pNewXORes->SetAt("XObject", pXObject); 483 pNewXORes->SetAt("XObject", pXObject);
485 } 484 }
486 485
487 CFX_ByteString sFormName; 486 CFX_ByteString sFormName;
488 sFormName.Format("F%d", i); 487 sFormName.Format("F%d", i);
489 uint32_t dwObjNum = pDocument->AddIndirectObject(pObj); 488 uint32_t dwObjNum = pDocument->AddIndirectObject(pObj);
490 pXObject->SetAtReference(sFormName, pDocument, dwObjNum); 489 pXObject->SetAtReference(sFormName.AsByteStringC(), pDocument, dwObjNum);
491 490
492 CPDF_StreamAcc acc; 491 CPDF_StreamAcc acc;
493 acc.LoadAllData(pNewXObject); 492 acc.LoadAllData(pNewXObject);
494 493
495 const uint8_t* pData = acc.GetData(); 494 const uint8_t* pData = acc.GetData();
496 CFX_ByteString sStream(pData, acc.GetSize()); 495 CFX_ByteString sStream(pData, acc.GetSize());
497 CFX_ByteString sTemp; 496 CFX_ByteString sTemp;
498 497
499 if (matrix.IsIdentity()) { 498 if (matrix.IsIdentity()) {
500 matrix.a = 1.0f; 499 matrix.a = 1.0f;
(...skipping 12 matching lines...) Expand all
513 pNewXObject->SetData((const uint8_t*)sStream, sStream.GetLength(), FALSE, 512 pNewXObject->SetData((const uint8_t*)sStream, sStream.GetLength(), FALSE,
514 FALSE); 513 FALSE);
515 } 514 }
516 pPageDict->RemoveAt("Annots"); 515 pPageDict->RemoveAt("Annots");
517 516
518 ObjectArray.RemoveAll(); 517 ObjectArray.RemoveAll();
519 RectArray.RemoveAll(); 518 RectArray.RemoveAll();
520 519
521 return FLATTEN_SUCCESS; 520 return FLATTEN_SUCCESS;
522 } 521 }
OLDNEW
« no previous file with comments | « fpdfsdk/fpdf_ext.cpp ('k') | fpdfsdk/fpdfppo.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698