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

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

Issue 1967963002: CPDF_VariableText::GetIterator() never returns NULL. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: Fix more nits in CFX_Edit Created 4 years, 7 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 | « core/fpdfdoc/cpdf_variabletext.cpp ('k') | core/fpdfdoc/include/cpdf_variabletext.h » ('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 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 489 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 // Static. 500 // Static.
501 CFX_ByteString CPVT_GenerateAP::GenerateEditAP( 501 CFX_ByteString CPVT_GenerateAP::GenerateEditAP(
502 IPVT_FontMap* pFontMap, 502 IPVT_FontMap* pFontMap,
503 CPDF_VariableText::Iterator* pIterator, 503 CPDF_VariableText::Iterator* pIterator,
504 const CFX_FloatPoint& ptOffset, 504 const CFX_FloatPoint& ptOffset,
505 FX_BOOL bContinuous, 505 FX_BOOL bContinuous,
506 uint16_t SubWord) { 506 uint16_t SubWord) {
507 CFX_ByteTextBuf sEditStream, sLineStream, sWords; 507 CFX_ByteTextBuf sEditStream, sLineStream, sWords;
508 CFX_FloatPoint ptOld(0.0f, 0.0f), ptNew(0.0f, 0.0f); 508 CFX_FloatPoint ptOld(0.0f, 0.0f), ptNew(0.0f, 0.0f);
509 int32_t nCurFontIndex = -1; 509 int32_t nCurFontIndex = -1;
510 if (pIterator) { 510 pIterator->SetAt(0);
511 pIterator->SetAt(0);
512 511
513 CPVT_WordPlace oldplace; 512 CPVT_WordPlace oldplace;
514 while (pIterator->NextWord()) { 513 while (pIterator->NextWord()) {
515 CPVT_WordPlace place = pIterator->GetAt(); 514 CPVT_WordPlace place = pIterator->GetAt();
516 if (bContinuous) { 515 if (bContinuous) {
517 if (place.LineCmp(oldplace) != 0) { 516 if (place.LineCmp(oldplace) != 0) {
518 if (sWords.GetSize() > 0) { 517 if (sWords.GetSize() > 0) {
519 sLineStream << GetWordRenderString(sWords.AsStringC()); 518 sLineStream << GetWordRenderString(sWords.AsStringC());
520 sEditStream << sLineStream; 519 sEditStream << sLineStream;
521 sLineStream.Clear(); 520 sLineStream.Clear();
522 sWords.Clear(); 521 sWords.Clear();
523 }
524 CPVT_Word word;
525 if (pIterator->GetWord(word)) {
526 ptNew = CFX_FloatPoint(word.ptWord.x + ptOffset.x,
527 word.ptWord.y + ptOffset.y);
528 } else {
529 CPVT_Line line;
530 pIterator->GetLine(line);
531 ptNew = CFX_FloatPoint(line.ptLine.x + ptOffset.x,
532 line.ptLine.y + ptOffset.y);
533 }
534 if (ptNew.x != ptOld.x || ptNew.y != ptOld.y) {
535 sLineStream << ptNew.x - ptOld.x << " " << ptNew.y - ptOld.y
536 << " Td\n";
537 ptOld = ptNew;
538 }
539 } 522 }
540 CPVT_Word word; 523 CPVT_Word word;
541 if (pIterator->GetWord(word)) { 524 if (pIterator->GetWord(word)) {
542 if (word.nFontIndex != nCurFontIndex) {
543 if (sWords.GetSize() > 0) {
544 sLineStream << GetWordRenderString(sWords.AsStringC());
545 sWords.Clear();
546 }
547 sLineStream << GetFontSetString(pFontMap, word.nFontIndex,
548 word.fFontSize);
549 nCurFontIndex = word.nFontIndex;
550 }
551 sWords << GetPDFWordString(pFontMap, nCurFontIndex, word.Word,
552 SubWord);
553 }
554 oldplace = place;
555 } else {
556 CPVT_Word word;
557 if (pIterator->GetWord(word)) {
558 ptNew = CFX_FloatPoint(word.ptWord.x + ptOffset.x, 525 ptNew = CFX_FloatPoint(word.ptWord.x + ptOffset.x,
559 word.ptWord.y + ptOffset.y); 526 word.ptWord.y + ptOffset.y);
560 if (ptNew.x != ptOld.x || ptNew.y != ptOld.y) { 527 } else {
561 sEditStream << ptNew.x - ptOld.x << " " << ptNew.y - ptOld.y 528 CPVT_Line line;
562 << " Td\n"; 529 pIterator->GetLine(line);
563 ptOld = ptNew; 530 ptNew = CFX_FloatPoint(line.ptLine.x + ptOffset.x,
564 } 531 line.ptLine.y + ptOffset.y);
565 if (word.nFontIndex != nCurFontIndex) { 532 }
566 sEditStream << GetFontSetString(pFontMap, word.nFontIndex, 533 if (ptNew.x != ptOld.x || ptNew.y != ptOld.y) {
567 word.fFontSize); 534 sLineStream << ptNew.x - ptOld.x << " " << ptNew.y - ptOld.y
568 nCurFontIndex = word.nFontIndex; 535 << " Td\n";
569 } 536 ptOld = ptNew;
570 sEditStream << GetWordRenderString(
571 GetPDFWordString(pFontMap, nCurFontIndex, word.Word, SubWord));
572 } 537 }
573 } 538 }
539 CPVT_Word word;
540 if (pIterator->GetWord(word)) {
541 if (word.nFontIndex != nCurFontIndex) {
542 if (sWords.GetSize() > 0) {
543 sLineStream << GetWordRenderString(sWords.AsStringC());
544 sWords.Clear();
545 }
546 sLineStream << GetFontSetString(pFontMap, word.nFontIndex,
547 word.fFontSize);
548 nCurFontIndex = word.nFontIndex;
549 }
550 sWords << GetPDFWordString(pFontMap, nCurFontIndex, word.Word, SubWord);
551 }
552 oldplace = place;
553 } else {
554 CPVT_Word word;
555 if (pIterator->GetWord(word)) {
556 ptNew = CFX_FloatPoint(word.ptWord.x + ptOffset.x,
557 word.ptWord.y + ptOffset.y);
558 if (ptNew.x != ptOld.x || ptNew.y != ptOld.y) {
559 sEditStream << ptNew.x - ptOld.x << " " << ptNew.y - ptOld.y
560 << " Td\n";
561 ptOld = ptNew;
562 }
563 if (word.nFontIndex != nCurFontIndex) {
564 sEditStream << GetFontSetString(pFontMap, word.nFontIndex,
565 word.fFontSize);
566 nCurFontIndex = word.nFontIndex;
567 }
568 sEditStream << GetWordRenderString(
569 GetPDFWordString(pFontMap, nCurFontIndex, word.Word, SubWord));
570 }
574 } 571 }
575 if (sWords.GetSize() > 0) { 572 }
576 sLineStream << GetWordRenderString(sWords.AsStringC()); 573 if (sWords.GetSize() > 0) {
577 sEditStream << sLineStream; 574 sLineStream << GetWordRenderString(sWords.AsStringC());
578 sWords.Clear(); 575 sEditStream << sLineStream;
579 } 576 sWords.Clear();
580 } 577 }
581 return sEditStream.AsStringC(); 578 return sEditStream.AsStringC();
582 } 579 }
583 580
584 // Static. 581 // Static.
585 CFX_ByteString CPVT_GenerateAP::GenerateBorderAP( 582 CFX_ByteString CPVT_GenerateAP::GenerateBorderAP(
586 const CFX_FloatRect& rect, 583 const CFX_FloatRect& rect,
587 FX_FLOAT fWidth, 584 FX_FLOAT fWidth,
588 const CPVT_Color& color, 585 const CPVT_Color& color,
589 const CPVT_Color& crLeftTop, 586 const CPVT_Color& crLeftTop,
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
754 int32_t nFontIndex, 751 int32_t nFontIndex,
755 FX_FLOAT fFontSize) { 752 FX_FLOAT fFontSize) {
756 CFX_ByteTextBuf sRet; 753 CFX_ByteTextBuf sRet;
757 if (pFontMap) { 754 if (pFontMap) {
758 CFX_ByteString sFontAlias = pFontMap->GetPDFFontAlias(nFontIndex); 755 CFX_ByteString sFontAlias = pFontMap->GetPDFFontAlias(nFontIndex);
759 if (sFontAlias.GetLength() > 0 && fFontSize > 0) 756 if (sFontAlias.GetLength() > 0 && fFontSize > 0)
760 sRet << "/" << sFontAlias << " " << fFontSize << " Tf\n"; 757 sRet << "/" << sFontAlias << " " << fFontSize << " Tf\n";
761 } 758 }
762 return sRet.AsStringC(); 759 return sRet.AsStringC();
763 } 760 }
OLDNEW
« no previous file with comments | « core/fpdfdoc/cpdf_variabletext.cpp ('k') | core/fpdfdoc/include/cpdf_variabletext.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698