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

Side by Side Diff: core/fpdfdoc/cpvt_generateap.cpp

Issue 1886263003: Rename CFX_ByteTextBuf::GetByteString() to AsStringC(). (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: 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
OLDNEW
1 // Copyright 2016 PDFium Authors. All rights reserved. 1 // Copyright 2016 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/fpdfdoc/cpvt_generateap.h" 7 #include "core/fpdfdoc/cpvt_generateap.h"
8 8
9 #include "core/fpdfapi/fpdf_font/include/cpdf_font.h" 9 #include "core/fpdfapi/fpdf_font/include/cpdf_font.h"
10 #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" 10 #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h"
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 } 411 }
412 fy -= fItemHeight; 412 fy -= fItemHeight;
413 } 413 }
414 } 414 }
415 } 415 }
416 if (sBody.GetSize() > 0) { 416 if (sBody.GetSize() > 0) {
417 sAppStream << "/Tx BMC\n" 417 sAppStream << "/Tx BMC\n"
418 << "q\n"; 418 << "q\n";
419 sAppStream << rcBody.left << " " << rcBody.bottom << " " 419 sAppStream << rcBody.left << " " << rcBody.bottom << " "
420 << rcBody.Width() << " " << rcBody.Height() << " re\nW\nn\n"; 420 << rcBody.Width() << " " << rcBody.Height() << " re\nW\nn\n";
421 sAppStream << sBody.GetByteString() << "Q\nEMC\n"; 421 sAppStream << sBody.AsStringC() << "Q\nEMC\n";
422 } 422 }
423 } break; 423 } break;
424 } 424 }
425 if (pNormalStream) { 425 if (pNormalStream) {
426 pNormalStream->SetData((uint8_t*)sAppStream.GetBuffer(), 426 pNormalStream->SetData((uint8_t*)sAppStream.GetBuffer(),
427 sAppStream.GetSize(), FALSE, FALSE); 427 sAppStream.GetSize(), FALSE, FALSE);
428 pStreamDict = pNormalStream->GetDict(); 428 pStreamDict = pNormalStream->GetDict();
429 if (pStreamDict) { 429 if (pStreamDict) {
430 pStreamDict->SetAtMatrix("Matrix", matrix); 430 pStreamDict->SetAtMatrix("Matrix", matrix);
431 pStreamDict->SetAtRect("BBox", rcBBox); 431 pStreamDict->SetAtRect("BBox", rcBBox);
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 516
517 CPVT_WordPlace oldplace; 517 CPVT_WordPlace oldplace;
518 while (pIterator->NextWord()) { 518 while (pIterator->NextWord()) {
519 CPVT_WordPlace place = pIterator->GetAt(); 519 CPVT_WordPlace place = pIterator->GetAt();
520 if (pVisible && place.WordCmp(pVisible->EndPos) > 0) 520 if (pVisible && place.WordCmp(pVisible->EndPos) > 0)
521 break; 521 break;
522 522
523 if (bContinuous) { 523 if (bContinuous) {
524 if (place.LineCmp(oldplace) != 0) { 524 if (place.LineCmp(oldplace) != 0) {
525 if (sWords.GetSize() > 0) { 525 if (sWords.GetSize() > 0) {
526 sLineStream << GetWordRenderString(sWords.GetByteString()); 526 sLineStream << GetWordRenderString(sWords.AsStringC());
527 sEditStream << sLineStream; 527 sEditStream << sLineStream;
528 sLineStream.Clear(); 528 sLineStream.Clear();
529 sWords.Clear(); 529 sWords.Clear();
530 } 530 }
531 CPVT_Word word; 531 CPVT_Word word;
532 if (pIterator->GetWord(word)) { 532 if (pIterator->GetWord(word)) {
533 ptNew = CFX_FloatPoint(word.ptWord.x + ptOffset.x, 533 ptNew = CFX_FloatPoint(word.ptWord.x + ptOffset.x,
534 word.ptWord.y + ptOffset.y); 534 word.ptWord.y + ptOffset.y);
535 } else { 535 } else {
536 CPVT_Line line; 536 CPVT_Line line;
537 pIterator->GetLine(line); 537 pIterator->GetLine(line);
538 ptNew = CFX_FloatPoint(line.ptLine.x + ptOffset.x, 538 ptNew = CFX_FloatPoint(line.ptLine.x + ptOffset.x,
539 line.ptLine.y + ptOffset.y); 539 line.ptLine.y + ptOffset.y);
540 } 540 }
541 if (ptNew.x != ptOld.x || ptNew.y != ptOld.y) { 541 if (ptNew.x != ptOld.x || ptNew.y != ptOld.y) {
542 sLineStream << ptNew.x - ptOld.x << " " << ptNew.y - ptOld.y 542 sLineStream << ptNew.x - ptOld.x << " " << ptNew.y - ptOld.y
543 << " Td\n"; 543 << " Td\n";
544 ptOld = ptNew; 544 ptOld = ptNew;
545 } 545 }
546 } 546 }
547 CPVT_Word word; 547 CPVT_Word word;
548 if (pIterator->GetWord(word)) { 548 if (pIterator->GetWord(word)) {
549 if (word.nFontIndex != nCurFontIndex) { 549 if (word.nFontIndex != nCurFontIndex) {
550 if (sWords.GetSize() > 0) { 550 if (sWords.GetSize() > 0) {
551 sLineStream << GetWordRenderString(sWords.GetByteString()); 551 sLineStream << GetWordRenderString(sWords.AsStringC());
552 sWords.Clear(); 552 sWords.Clear();
553 } 553 }
554 sLineStream << GetFontSetString(pFontMap, word.nFontIndex, 554 sLineStream << GetFontSetString(pFontMap, word.nFontIndex,
555 word.fFontSize); 555 word.fFontSize);
556 nCurFontIndex = word.nFontIndex; 556 nCurFontIndex = word.nFontIndex;
557 } 557 }
558 sWords << GetPDFWordString(pFontMap, nCurFontIndex, word.Word, 558 sWords << GetPDFWordString(pFontMap, nCurFontIndex, word.Word,
559 SubWord); 559 SubWord);
560 } 560 }
561 oldplace = place; 561 oldplace = place;
(...skipping 11 matching lines...) Expand all
573 sEditStream << GetFontSetString(pFontMap, word.nFontIndex, 573 sEditStream << GetFontSetString(pFontMap, word.nFontIndex,
574 word.fFontSize); 574 word.fFontSize);
575 nCurFontIndex = word.nFontIndex; 575 nCurFontIndex = word.nFontIndex;
576 } 576 }
577 sEditStream << GetWordRenderString( 577 sEditStream << GetWordRenderString(
578 GetPDFWordString(pFontMap, nCurFontIndex, word.Word, SubWord)); 578 GetPDFWordString(pFontMap, nCurFontIndex, word.Word, SubWord));
579 } 579 }
580 } 580 }
581 } 581 }
582 if (sWords.GetSize() > 0) { 582 if (sWords.GetSize() > 0) {
583 sLineStream << GetWordRenderString(sWords.GetByteString()); 583 sLineStream << GetWordRenderString(sWords.AsStringC());
584 sEditStream << sLineStream; 584 sEditStream << sLineStream;
585 sWords.Clear(); 585 sWords.Clear();
586 } 586 }
587 } 587 }
588 return sEditStream.GetByteString(); 588 return sEditStream.AsStringC();
589 } 589 }
590 590
591 // Static. 591 // Static.
592 CFX_ByteString CPVT_GenerateAP::GenerateBorderAP( 592 CFX_ByteString CPVT_GenerateAP::GenerateBorderAP(
593 const CFX_FloatRect& rect, 593 const CFX_FloatRect& rect,
594 FX_FLOAT fWidth, 594 FX_FLOAT fWidth,
595 const CPVT_Color& color, 595 const CPVT_Color& color,
596 const CPVT_Color& crLeftTop, 596 const CPVT_Color& crLeftTop,
597 const CPVT_Color& crRightBottom, 597 const CPVT_Color& crRightBottom,
598 int32_t nStyle, 598 int32_t nStyle,
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
686 sColor = GenerateColorAP(color, FALSE); 686 sColor = GenerateColorAP(color, FALSE);
687 if (sColor.GetLength() > 0) { 687 if (sColor.GetLength() > 0) {
688 sAppStream << sColor; 688 sAppStream << sColor;
689 sAppStream << fWidth << " w\n"; 689 sAppStream << fWidth << " w\n";
690 sAppStream << fLeft << " " << fBottom + fWidth / 2 << " m\n"; 690 sAppStream << fLeft << " " << fBottom + fWidth / 2 << " m\n";
691 sAppStream << fRight << " " << fBottom + fWidth / 2 << " l S\n"; 691 sAppStream << fRight << " " << fBottom + fWidth / 2 << " l S\n";
692 } 692 }
693 break; 693 break;
694 } 694 }
695 } 695 }
696 return sAppStream.GetByteString(); 696 return sAppStream.AsStringC();
697 } 697 }
698 698
699 // Static. 699 // Static.
700 CFX_ByteString CPVT_GenerateAP::GenerateColorAP(const CPVT_Color& color, 700 CFX_ByteString CPVT_GenerateAP::GenerateColorAP(const CPVT_Color& color,
701 const FX_BOOL& bFillOrStroke) { 701 const FX_BOOL& bFillOrStroke) {
702 CFX_ByteTextBuf sColorStream; 702 CFX_ByteTextBuf sColorStream;
703 switch (color.nColorType) { 703 switch (color.nColorType) {
704 case CPVT_Color::kRGB: 704 case CPVT_Color::kRGB:
705 sColorStream << color.fColor1 << " " << color.fColor2 << " " 705 sColorStream << color.fColor1 << " " << color.fColor2 << " "
706 << color.fColor3 << " " << (bFillOrStroke ? "rg" : "RG") 706 << color.fColor3 << " " << (bFillOrStroke ? "rg" : "RG")
707 << "\n"; 707 << "\n";
708 break; 708 break;
709 case CPVT_Color::kGray: 709 case CPVT_Color::kGray:
710 sColorStream << color.fColor1 << " " << (bFillOrStroke ? "g" : "G") 710 sColorStream << color.fColor1 << " " << (bFillOrStroke ? "g" : "G")
711 << "\n"; 711 << "\n";
712 break; 712 break;
713 case CPVT_Color::kCMYK: 713 case CPVT_Color::kCMYK:
714 sColorStream << color.fColor1 << " " << color.fColor2 << " " 714 sColorStream << color.fColor1 << " " << color.fColor2 << " "
715 << color.fColor3 << " " << color.fColor4 << " " 715 << color.fColor3 << " " << color.fColor4 << " "
716 << (bFillOrStroke ? "k" : "K") << "\n"; 716 << (bFillOrStroke ? "k" : "K") << "\n";
717 break; 717 break;
718 case CPVT_Color::kTransparent: 718 case CPVT_Color::kTransparent:
719 break; 719 break;
720 } 720 }
721 return sColorStream.GetByteString(); 721 return sColorStream.AsStringC();
722 } 722 }
723 723
724 // Static. 724 // Static.
725 CFX_ByteString CPVT_GenerateAP::GetPDFWordString(IPVT_FontMap* pFontMap, 725 CFX_ByteString CPVT_GenerateAP::GetPDFWordString(IPVT_FontMap* pFontMap,
726 int32_t nFontIndex, 726 int32_t nFontIndex,
727 uint16_t Word, 727 uint16_t Word,
728 uint16_t SubWord) { 728 uint16_t SubWord) {
729 CFX_ByteString sWord; 729 CFX_ByteString sWord;
730 if (SubWord > 0) { 730 if (SubWord > 0) {
731 sWord.Format("%c", SubWord); 731 sWord.Format("%c", SubWord);
(...skipping 27 matching lines...) Expand all
759 // Static. 759 // Static.
760 CFX_ByteString CPVT_GenerateAP::GetFontSetString(IPVT_FontMap* pFontMap, 760 CFX_ByteString CPVT_GenerateAP::GetFontSetString(IPVT_FontMap* pFontMap,
761 int32_t nFontIndex, 761 int32_t nFontIndex,
762 FX_FLOAT fFontSize) { 762 FX_FLOAT fFontSize) {
763 CFX_ByteTextBuf sRet; 763 CFX_ByteTextBuf sRet;
764 if (pFontMap) { 764 if (pFontMap) {
765 CFX_ByteString sFontAlias = pFontMap->GetPDFFontAlias(nFontIndex); 765 CFX_ByteString sFontAlias = pFontMap->GetPDFFontAlias(nFontIndex);
766 if (sFontAlias.GetLength() > 0 && fFontSize > 0) 766 if (sFontAlias.GetLength() > 0 && fFontSize > 0)
767 sRet << "/" << sFontAlias << " " << fFontSize << " Tf\n"; 767 sRet << "/" << sFontAlias << " " << fFontSize << " Tf\n";
768 } 768 }
769 return sRet.GetByteString(); 769 return sRet.AsStringC();
770 } 770 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698