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 <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "core/fpdfdoc/cpvt_wordinfo.h" | 9 #include "core/fpdfdoc/cpvt_wordinfo.h" |
10 #include "core/fpdfdoc/csection.h" | 10 #include "core/fpdfdoc/csection.h" |
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 fLineAscent = std::max(fLineAscent, fWordAscent); | 365 fLineAscent = std::max(fLineAscent, fWordAscent); |
366 fLineDescent = std::min(fLineDescent, fWordDescent); | 366 fLineDescent = std::min(fLineDescent, fWordDescent); |
367 } | 367 } |
368 } | 368 } |
369 pLine->m_LineInfo.nBeginWordIndex = 0; | 369 pLine->m_LineInfo.nBeginWordIndex = 0; |
370 pLine->m_LineInfo.nEndWordIndex = m_pSection->m_WordArray.GetSize() - 1; | 370 pLine->m_LineInfo.nEndWordIndex = m_pSection->m_WordArray.GetSize() - 1; |
371 pLine->m_LineInfo.fLineY = y; | 371 pLine->m_LineInfo.fLineY = y; |
372 pLine->m_LineInfo.fLineWidth = x - pLine->m_LineInfo.fLineX; | 372 pLine->m_LineInfo.fLineWidth = x - pLine->m_LineInfo.fLineX; |
373 pLine->m_LineInfo.fLineAscent = fLineAscent; | 373 pLine->m_LineInfo.fLineAscent = fLineAscent; |
374 pLine->m_LineInfo.fLineDescent = fLineDescent; | 374 pLine->m_LineInfo.fLineDescent = fLineDescent; |
375 y += (-fLineDescent); | 375 y -= fLineDescent; |
376 } | 376 } |
377 return m_rcRet = CPVT_FloatRect(0, 0, x, y); | 377 return m_rcRet = CPVT_FloatRect(0, 0, x, y); |
378 } | 378 } |
379 CPVT_Size CTypeset::GetEditSize(FX_FLOAT fFontSize) { | 379 CPVT_Size CTypeset::GetEditSize(FX_FLOAT fFontSize) { |
380 ASSERT(m_pSection); | 380 ASSERT(m_pSection); |
381 ASSERT(m_pVT); | 381 ASSERT(m_pVT); |
382 SplitLines(FALSE, fFontSize); | 382 SplitLines(FALSE, fFontSize); |
383 return CPVT_Size(m_rcRet.Width(), m_rcRet.Height()); | 383 return CPVT_Size(m_rcRet.Width(), m_rcRet.Height()); |
384 } | 384 } |
385 CPVT_FloatRect CTypeset::Typeset() { | 385 CPVT_FloatRect CTypeset::Typeset() { |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
633 if (bTypeset) { | 633 if (bTypeset) { |
634 line.nBeginWordIndex = nLineHead; | 634 line.nBeginWordIndex = nLineHead; |
635 line.nEndWordIndex = nLineTail; | 635 line.nEndWordIndex = nLineTail; |
636 line.nTotalWord = nLineTail - nLineHead + 1; | 636 line.nTotalWord = nLineTail - nLineHead + 1; |
637 line.fLineWidth = fLineWidth; | 637 line.fLineWidth = fLineWidth; |
638 line.fLineAscent = fLineAscent; | 638 line.fLineAscent = fLineAscent; |
639 line.fLineDescent = fLineDescent; | 639 line.fLineDescent = fLineDescent; |
640 m_pSection->AddLine(line); | 640 m_pSection->AddLine(line); |
641 } | 641 } |
642 fMaxY += (fLineAscent + m_pVT->GetLineLeading(m_pSection->m_SecInfo)); | 642 fMaxY += (fLineAscent + m_pVT->GetLineLeading(m_pSection->m_SecInfo)); |
643 fMaxY += (-fLineDescent); | 643 fMaxY -= fLineDescent; |
644 fMaxX = std::max(fLineWidth, fMaxX); | 644 fMaxX = std::max(fLineWidth, fMaxX); |
645 nLineHead = i; | 645 nLineHead = i; |
646 fLineWidth = 0.0f; | 646 fLineWidth = 0.0f; |
647 fLineAscent = 0.0f; | 647 fLineAscent = 0.0f; |
648 fLineDescent = 0.0f; | 648 fLineDescent = 0.0f; |
649 nCharIndex = 0; | 649 nCharIndex = 0; |
650 nLineFullWordIndex = 0; | 650 nLineFullWordIndex = 0; |
651 bFullWord = FALSE; | 651 bFullWord = FALSE; |
652 } else { | 652 } else { |
653 fLineWidth += fWordWidth; | 653 fLineWidth += fWordWidth; |
654 i++; | 654 i++; |
655 } | 655 } |
656 } | 656 } |
657 if (nLineHead <= nTotalWords - 1) { | 657 if (nLineHead <= nTotalWords - 1) { |
658 nLineTail = nTotalWords - 1; | 658 nLineTail = nTotalWords - 1; |
659 if (bTypeset) { | 659 if (bTypeset) { |
660 line.nBeginWordIndex = nLineHead; | 660 line.nBeginWordIndex = nLineHead; |
661 line.nEndWordIndex = nLineTail; | 661 line.nEndWordIndex = nLineTail; |
662 line.nTotalWord = nLineTail - nLineHead + 1; | 662 line.nTotalWord = nLineTail - nLineHead + 1; |
663 line.fLineWidth = fLineWidth; | 663 line.fLineWidth = fLineWidth; |
664 line.fLineAscent = fLineAscent; | 664 line.fLineAscent = fLineAscent; |
665 line.fLineDescent = fLineDescent; | 665 line.fLineDescent = fLineDescent; |
666 m_pSection->AddLine(line); | 666 m_pSection->AddLine(line); |
667 } | 667 } |
668 fMaxY += (fLineAscent + m_pVT->GetLineLeading(m_pSection->m_SecInfo)); | 668 fMaxY += (fLineAscent + m_pVT->GetLineLeading(m_pSection->m_SecInfo)); |
669 fMaxY += (-fLineDescent); | 669 fMaxY -= fLineDescent; |
670 fMaxX = std::max(fLineWidth, fMaxX); | 670 fMaxX = std::max(fLineWidth, fMaxX); |
671 } | 671 } |
672 } else { | 672 } else { |
673 if (bTypeset) { | 673 if (bTypeset) { |
674 fLineAscent = m_pVT->GetLineAscent(m_pSection->m_SecInfo); | 674 fLineAscent = m_pVT->GetLineAscent(m_pSection->m_SecInfo); |
675 fLineDescent = m_pVT->GetLineDescent(m_pSection->m_SecInfo); | 675 fLineDescent = m_pVT->GetLineDescent(m_pSection->m_SecInfo); |
676 } else { | 676 } else { |
677 fLineAscent = | 677 fLineAscent = |
678 m_pVT->GetFontAscent(m_pVT->GetDefaultFontIndex(), fFontSize); | 678 m_pVT->GetFontAscent(m_pVT->GetDefaultFontIndex(), fFontSize); |
679 fLineDescent = | 679 fLineDescent = |
680 m_pVT->GetFontDescent(m_pVT->GetDefaultFontIndex(), fFontSize); | 680 m_pVT->GetFontDescent(m_pVT->GetDefaultFontIndex(), fFontSize); |
681 } | 681 } |
682 if (bTypeset) { | 682 if (bTypeset) { |
683 line.nBeginWordIndex = -1; | 683 line.nBeginWordIndex = -1; |
684 line.nEndWordIndex = -1; | 684 line.nEndWordIndex = -1; |
685 line.nTotalWord = 0; | 685 line.nTotalWord = 0; |
686 line.fLineWidth = 0; | 686 line.fLineWidth = 0; |
687 line.fLineAscent = fLineAscent; | 687 line.fLineAscent = fLineAscent; |
688 line.fLineDescent = fLineDescent; | 688 line.fLineDescent = fLineDescent; |
689 m_pSection->AddLine(line); | 689 m_pSection->AddLine(line); |
690 } | 690 } |
691 fMaxY += (m_pVT->GetLineLeading(m_pSection->m_SecInfo) + fLineAscent + | 691 fMaxY += m_pVT->GetLineLeading(m_pSection->m_SecInfo) + fLineAscent - |
692 (-fLineDescent)); | 692 fLineDescent; |
693 } | 693 } |
694 m_rcRet = CPVT_FloatRect(0, 0, fMaxX, fMaxY); | 694 m_rcRet = CPVT_FloatRect(0, 0, fMaxX, fMaxY); |
695 } | 695 } |
696 void CTypeset::OutputLines() { | 696 void CTypeset::OutputLines() { |
697 ASSERT(m_pVT); | 697 ASSERT(m_pVT); |
698 ASSERT(m_pSection); | 698 ASSERT(m_pSection); |
699 FX_FLOAT fMinX = 0.0f, fMinY = 0.0f, fMaxX = 0.0f, fMaxY = 0.0f; | 699 FX_FLOAT fMinX = 0.0f, fMinY = 0.0f, fMaxX = 0.0f, fMaxY = 0.0f; |
700 FX_FLOAT fPosX = 0.0f, fPosY = 0.0f; | 700 FX_FLOAT fPosX = 0.0f, fPosY = 0.0f; |
701 FX_FLOAT fLineIndent = m_pVT->GetLineIndent(m_pSection->m_SecInfo); | 701 FX_FLOAT fLineIndent = m_pVT->GetLineIndent(m_pSection->m_SecInfo); |
702 FX_FLOAT fTypesetWidth = std::max(m_pVT->GetPlateWidth() - fLineIndent, 0.0f); | 702 FX_FLOAT fTypesetWidth = std::max(m_pVT->GetPlateWidth() - fLineIndent, 0.0f); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
754 case CPDF_VariableText::ScriptType::Sub: | 754 case CPDF_VariableText::ScriptType::Sub: |
755 pWord->fWordY = fPosY - m_pVT->GetWordDescent(*pWord) - fMinY; | 755 pWord->fWordY = fPosY - m_pVT->GetWordDescent(*pWord) - fMinY; |
756 break; | 756 break; |
757 } | 757 } |
758 } else { | 758 } else { |
759 pWord->fWordY = fPosY - fMinY; | 759 pWord->fWordY = fPosY - fMinY; |
760 } | 760 } |
761 fPosX += m_pVT->GetWordWidth(*pWord); | 761 fPosX += m_pVT->GetWordWidth(*pWord); |
762 } | 762 } |
763 } | 763 } |
764 fPosY += (-pLine->m_LineInfo.fLineDescent); | 764 fPosY -= pLine->m_LineInfo.fLineDescent; |
765 } | 765 } |
766 } | 766 } |
767 } | 767 } |
768 m_rcRet = CPVT_FloatRect(fMinX, fMinY, fMaxX, fMaxY); | 768 m_rcRet = CPVT_FloatRect(fMinX, fMinY, fMaxX, fMaxY); |
769 } | 769 } |
OLD | NEW |