| 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> |
| 8 |
| 7 #include "core/include/fpdfdoc/fpdf_doc.h" | 9 #include "core/include/fpdfdoc/fpdf_doc.h" |
| 8 #include "core/include/fpdfdoc/fpdf_vt.h" | 10 #include "core/include/fpdfdoc/fpdf_vt.h" |
| 9 #include "pdf_vt.h" | 11 #include "pdf_vt.h" |
| 10 | 12 |
| 11 const uint8_t gFontSizeSteps[] = {4, 6, 8, 9, 10, 12, 14, 18, 20, | 13 const uint8_t gFontSizeSteps[] = {4, 6, 8, 9, 10, 12, 14, 18, 20, |
| 12 25, 30, 35, 40, 45, 50, 55, 60, 70, | 14 25, 30, 35, 40, 45, 50, 55, 60, 70, |
| 13 80, 90, 100, 110, 120, 130, 144}; | 15 80, 90, 100, 110, 120, 130, 144}; |
| 14 #define PVT_RETURN_LENGTH 1 | 16 #define PVT_RETURN_LENGTH 1 |
| 15 #define PVT_DEFAULT_FONTSIZE 18.0f | 17 #define PVT_DEFAULT_FONTSIZE 18.0f |
| 16 #define PVTWORD_SCRIPT_NORMAL 0 | 18 #define PVTWORD_SCRIPT_NORMAL 0 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 for (int32_t i = 0, sz = m_LineArray.GetSize(); i < sz; i++) { | 67 for (int32_t i = 0, sz = m_LineArray.GetSize(); i < sz; i++) { |
| 66 if (CLine* pLine = m_LineArray.GetAt(i)) { | 68 if (CLine* pLine = m_LineArray.GetAt(i)) { |
| 67 pLine->LinePlace = CPVT_WordPlace(SecPlace.nSecIndex, i, -1); | 69 pLine->LinePlace = CPVT_WordPlace(SecPlace.nSecIndex, i, -1); |
| 68 } | 70 } |
| 69 } | 71 } |
| 70 } | 72 } |
| 71 CPVT_WordPlace CSection::AddWord(const CPVT_WordPlace& place, | 73 CPVT_WordPlace CSection::AddWord(const CPVT_WordPlace& place, |
| 72 const CPVT_WordInfo& wordinfo) { | 74 const CPVT_WordInfo& wordinfo) { |
| 73 CPVT_WordInfo* pWord = new CPVT_WordInfo(wordinfo); | 75 CPVT_WordInfo* pWord = new CPVT_WordInfo(wordinfo); |
| 74 int32_t nWordIndex = | 76 int32_t nWordIndex = |
| 75 FPDF_MAX(FPDF_MIN(place.nWordIndex, m_WordArray.GetSize()), 0); | 77 std::max(std::min(place.nWordIndex, m_WordArray.GetSize()), 0); |
| 76 if (nWordIndex == m_WordArray.GetSize()) { | 78 if (nWordIndex == m_WordArray.GetSize()) { |
| 77 m_WordArray.Add(pWord); | 79 m_WordArray.Add(pWord); |
| 78 } else { | 80 } else { |
| 79 m_WordArray.InsertAt(nWordIndex, pWord); | 81 m_WordArray.InsertAt(nWordIndex, pWord); |
| 80 } | 82 } |
| 81 return place; | 83 return place; |
| 82 } | 84 } |
| 83 CPVT_WordPlace CSection::AddLine(const CPVT_LineInfo& lineinfo) { | 85 CPVT_WordPlace CSection::AddLine(const CPVT_LineInfo& lineinfo) { |
| 84 return CPVT_WordPlace(SecPlace.nSecIndex, m_LineArray.Add(lineinfo), -1); | 86 return CPVT_WordPlace(SecPlace.nSecIndex, m_LineArray.Add(lineinfo), -1); |
| 85 } | 87 } |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 349 pWord->fWordTail = 0; | 351 pWord->fWordTail = 0; |
| 350 FX_FLOAT fWordWidth = m_pVT->GetWordWidth(*pWord); | 352 FX_FLOAT fWordWidth = m_pVT->GetWordWidth(*pWord); |
| 351 FX_FLOAT fWordAscent = m_pVT->GetWordAscent(*pWord); | 353 FX_FLOAT fWordAscent = m_pVT->GetWordAscent(*pWord); |
| 352 FX_FLOAT fWordDescent = m_pVT->GetWordDescent(*pWord); | 354 FX_FLOAT fWordDescent = m_pVT->GetWordDescent(*pWord); |
| 353 x = (FX_FLOAT)(fNodeWidth * (w + nStart + 0.5) - fWordWidth * PVT_HALF); | 355 x = (FX_FLOAT)(fNodeWidth * (w + nStart + 0.5) - fWordWidth * PVT_HALF); |
| 354 pWord->fWordX = x; | 356 pWord->fWordX = x; |
| 355 pWord->fWordY = y; | 357 pWord->fWordY = y; |
| 356 if (w == 0) { | 358 if (w == 0) { |
| 357 pLine->m_LineInfo.fLineX = x; | 359 pLine->m_LineInfo.fLineX = x; |
| 358 } | 360 } |
| 359 if (w != m_pSection->m_WordArray.GetSize() - 1) | 361 if (w != m_pSection->m_WordArray.GetSize() - 1) { |
| 360 pWord->fWordTail = | 362 pWord->fWordTail = |
| 361 (fNodeWidth - (fWordWidth + fNextWidth) * PVT_HALF > 0 | 363 (fNodeWidth - (fWordWidth + fNextWidth) * PVT_HALF > 0 |
| 362 ? fNodeWidth - (fWordWidth + fNextWidth) * PVT_HALF | 364 ? fNodeWidth - (fWordWidth + fNextWidth) * PVT_HALF |
| 363 : 0); | 365 : 0); |
| 364 else { | 366 } else { |
| 365 pWord->fWordTail = 0; | 367 pWord->fWordTail = 0; |
| 366 } | 368 } |
| 367 x += fWordWidth; | 369 x += fWordWidth; |
| 368 fLineAscent = FPDF_MAX(fLineAscent, fWordAscent); | 370 fLineAscent = std::max(fLineAscent, fWordAscent); |
| 369 fLineDescent = FPDF_MIN(fLineDescent, fWordDescent); | 371 fLineDescent = std::min(fLineDescent, fWordDescent); |
| 370 } | 372 } |
| 371 } | 373 } |
| 372 pLine->m_LineInfo.nBeginWordIndex = 0; | 374 pLine->m_LineInfo.nBeginWordIndex = 0; |
| 373 pLine->m_LineInfo.nEndWordIndex = m_pSection->m_WordArray.GetSize() - 1; | 375 pLine->m_LineInfo.nEndWordIndex = m_pSection->m_WordArray.GetSize() - 1; |
| 374 pLine->m_LineInfo.fLineY = y; | 376 pLine->m_LineInfo.fLineY = y; |
| 375 pLine->m_LineInfo.fLineWidth = x - pLine->m_LineInfo.fLineX; | 377 pLine->m_LineInfo.fLineWidth = x - pLine->m_LineInfo.fLineX; |
| 376 pLine->m_LineInfo.fLineAscent = fLineAscent; | 378 pLine->m_LineInfo.fLineAscent = fLineAscent; |
| 377 pLine->m_LineInfo.fLineDescent = fLineDescent; | 379 pLine->m_LineInfo.fLineDescent = fLineDescent; |
| 378 y += (-fLineDescent); | 380 y += (-fLineDescent); |
| 379 } | 381 } |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 575 FX_FLOAT fMaxX = 0.0f, fMaxY = 0.0f; | 577 FX_FLOAT fMaxX = 0.0f, fMaxY = 0.0f; |
| 576 FX_FLOAT fLineWidth = 0.0f, fBackupLineWidth = 0.0f; | 578 FX_FLOAT fLineWidth = 0.0f, fBackupLineWidth = 0.0f; |
| 577 FX_FLOAT fLineAscent = 0.0f, fBackupLineAscent = 0.0f; | 579 FX_FLOAT fLineAscent = 0.0f, fBackupLineAscent = 0.0f; |
| 578 FX_FLOAT fLineDescent = 0.0f, fBackupLineDescent = 0.0f; | 580 FX_FLOAT fLineDescent = 0.0f, fBackupLineDescent = 0.0f; |
| 579 int32_t nWordStartPos = 0; | 581 int32_t nWordStartPos = 0; |
| 580 FX_BOOL bFullWord = FALSE; | 582 FX_BOOL bFullWord = FALSE; |
| 581 int32_t nLineFullWordIndex = 0; | 583 int32_t nLineFullWordIndex = 0; |
| 582 int32_t nCharIndex = 0; | 584 int32_t nCharIndex = 0; |
| 583 CPVT_LineInfo line; | 585 CPVT_LineInfo line; |
| 584 FX_FLOAT fWordWidth = 0; | 586 FX_FLOAT fWordWidth = 0; |
| 585 FX_FLOAT fTypesetWidth = FPDF_MAX( | 587 FX_FLOAT fTypesetWidth = std::max( |
| 586 m_pVT->GetPlateWidth() - m_pVT->GetLineIndent(m_pSection->m_SecInfo), | 588 m_pVT->GetPlateWidth() - m_pVT->GetLineIndent(m_pSection->m_SecInfo), |
| 587 0.0f); | 589 0.0f); |
| 588 int32_t nTotalWords = m_pSection->m_WordArray.GetSize(); | 590 int32_t nTotalWords = m_pSection->m_WordArray.GetSize(); |
| 589 FX_BOOL bOpened = FALSE; | 591 FX_BOOL bOpened = FALSE; |
| 590 if (nTotalWords > 0) { | 592 if (nTotalWords > 0) { |
| 591 int32_t i = 0; | 593 int32_t i = 0; |
| 592 while (i < nTotalWords) { | 594 while (i < nTotalWords) { |
| 593 CPVT_WordInfo* pWord = m_pSection->m_WordArray.GetAt(i); | 595 CPVT_WordInfo* pWord = m_pSection->m_WordArray.GetAt(i); |
| 594 CPVT_WordInfo* pOldWord = pWord; | 596 CPVT_WordInfo* pOldWord = pWord; |
| 595 if (i > 0) { | 597 if (i > 0) { |
| 596 pOldWord = m_pSection->m_WordArray.GetAt(i - 1); | 598 pOldWord = m_pSection->m_WordArray.GetAt(i - 1); |
| 597 } | 599 } |
| 598 if (pWord) { | 600 if (pWord) { |
| 599 if (bTypeset) { | 601 if (bTypeset) { |
| 600 fLineAscent = | 602 fLineAscent = |
| 601 FPDF_MAX(fLineAscent, m_pVT->GetWordAscent(*pWord, TRUE)); | 603 std::max(fLineAscent, m_pVT->GetWordAscent(*pWord, TRUE)); |
| 602 fLineDescent = | 604 fLineDescent = |
| 603 FPDF_MIN(fLineDescent, m_pVT->GetWordDescent(*pWord, TRUE)); | 605 std::min(fLineDescent, m_pVT->GetWordDescent(*pWord, TRUE)); |
| 604 fWordWidth = m_pVT->GetWordWidth(*pWord); | 606 fWordWidth = m_pVT->GetWordWidth(*pWord); |
| 605 } else { | 607 } else { |
| 606 fLineAscent = | 608 fLineAscent = |
| 607 FPDF_MAX(fLineAscent, m_pVT->GetWordAscent(*pWord, fFontSize)); | 609 std::max(fLineAscent, m_pVT->GetWordAscent(*pWord, fFontSize)); |
| 608 fLineDescent = | 610 fLineDescent = |
| 609 FPDF_MIN(fLineDescent, m_pVT->GetWordDescent(*pWord, fFontSize)); | 611 std::min(fLineDescent, m_pVT->GetWordDescent(*pWord, fFontSize)); |
| 610 fWordWidth = m_pVT->GetWordWidth( | 612 fWordWidth = m_pVT->GetWordWidth( |
| 611 pWord->nFontIndex, pWord->Word, m_pVT->m_wSubWord, | 613 pWord->nFontIndex, pWord->Word, m_pVT->m_wSubWord, |
| 612 m_pVT->m_fCharSpace, m_pVT->m_nHorzScale, fFontSize, | 614 m_pVT->m_fCharSpace, m_pVT->m_nHorzScale, fFontSize, |
| 613 pWord->fWordTail, 0); | 615 pWord->fWordTail, 0); |
| 614 } | 616 } |
| 615 if (!bOpened) { | 617 if (!bOpened) { |
| 616 if (IsOpenStylePunctuation(pWord->Word)) { | 618 if (IsOpenStylePunctuation(pWord->Word)) { |
| 617 bOpened = TRUE; | 619 bOpened = TRUE; |
| 618 bFullWord = TRUE; | 620 bFullWord = TRUE; |
| 619 } else if (pOldWord) { | 621 } else if (pOldWord) { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 655 line.nBeginWordIndex = nLineHead; | 657 line.nBeginWordIndex = nLineHead; |
| 656 line.nEndWordIndex = nLineTail; | 658 line.nEndWordIndex = nLineTail; |
| 657 line.nTotalWord = nLineTail - nLineHead + 1; | 659 line.nTotalWord = nLineTail - nLineHead + 1; |
| 658 line.fLineWidth = fLineWidth; | 660 line.fLineWidth = fLineWidth; |
| 659 line.fLineAscent = fLineAscent; | 661 line.fLineAscent = fLineAscent; |
| 660 line.fLineDescent = fLineDescent; | 662 line.fLineDescent = fLineDescent; |
| 661 m_pSection->AddLine(line); | 663 m_pSection->AddLine(line); |
| 662 } | 664 } |
| 663 fMaxY += (fLineAscent + m_pVT->GetLineLeading(m_pSection->m_SecInfo)); | 665 fMaxY += (fLineAscent + m_pVT->GetLineLeading(m_pSection->m_SecInfo)); |
| 664 fMaxY += (-fLineDescent); | 666 fMaxY += (-fLineDescent); |
| 665 fMaxX = FPDF_MAX(fLineWidth, fMaxX); | 667 fMaxX = std::max(fLineWidth, fMaxX); |
| 666 nLineHead = i; | 668 nLineHead = i; |
| 667 fLineWidth = 0.0f; | 669 fLineWidth = 0.0f; |
| 668 fLineAscent = 0.0f; | 670 fLineAscent = 0.0f; |
| 669 fLineDescent = 0.0f; | 671 fLineDescent = 0.0f; |
| 670 nCharIndex = 0; | 672 nCharIndex = 0; |
| 671 nLineFullWordIndex = 0; | 673 nLineFullWordIndex = 0; |
| 672 bFullWord = FALSE; | 674 bFullWord = FALSE; |
| 673 } else { | 675 } else { |
| 674 fLineWidth += fWordWidth; | 676 fLineWidth += fWordWidth; |
| 675 i++; | 677 i++; |
| 676 } | 678 } |
| 677 } | 679 } |
| 678 if (nLineHead <= nTotalWords - 1) { | 680 if (nLineHead <= nTotalWords - 1) { |
| 679 nLineTail = nTotalWords - 1; | 681 nLineTail = nTotalWords - 1; |
| 680 if (bTypeset) { | 682 if (bTypeset) { |
| 681 line.nBeginWordIndex = nLineHead; | 683 line.nBeginWordIndex = nLineHead; |
| 682 line.nEndWordIndex = nLineTail; | 684 line.nEndWordIndex = nLineTail; |
| 683 line.nTotalWord = nLineTail - nLineHead + 1; | 685 line.nTotalWord = nLineTail - nLineHead + 1; |
| 684 line.fLineWidth = fLineWidth; | 686 line.fLineWidth = fLineWidth; |
| 685 line.fLineAscent = fLineAscent; | 687 line.fLineAscent = fLineAscent; |
| 686 line.fLineDescent = fLineDescent; | 688 line.fLineDescent = fLineDescent; |
| 687 m_pSection->AddLine(line); | 689 m_pSection->AddLine(line); |
| 688 } | 690 } |
| 689 fMaxY += (fLineAscent + m_pVT->GetLineLeading(m_pSection->m_SecInfo)); | 691 fMaxY += (fLineAscent + m_pVT->GetLineLeading(m_pSection->m_SecInfo)); |
| 690 fMaxY += (-fLineDescent); | 692 fMaxY += (-fLineDescent); |
| 691 fMaxX = FPDF_MAX(fLineWidth, fMaxX); | 693 fMaxX = std::max(fLineWidth, fMaxX); |
| 692 } | 694 } |
| 693 } else { | 695 } else { |
| 694 if (bTypeset) { | 696 if (bTypeset) { |
| 695 fLineAscent = m_pVT->GetLineAscent(m_pSection->m_SecInfo); | 697 fLineAscent = m_pVT->GetLineAscent(m_pSection->m_SecInfo); |
| 696 fLineDescent = m_pVT->GetLineDescent(m_pSection->m_SecInfo); | 698 fLineDescent = m_pVT->GetLineDescent(m_pSection->m_SecInfo); |
| 697 } else { | 699 } else { |
| 698 fLineAscent = | 700 fLineAscent = |
| 699 m_pVT->GetFontAscent(m_pVT->GetDefaultFontIndex(), fFontSize); | 701 m_pVT->GetFontAscent(m_pVT->GetDefaultFontIndex(), fFontSize); |
| 700 fLineDescent = | 702 fLineDescent = |
| 701 m_pVT->GetFontDescent(m_pVT->GetDefaultFontIndex(), fFontSize); | 703 m_pVT->GetFontDescent(m_pVT->GetDefaultFontIndex(), fFontSize); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 713 (-fLineDescent)); | 715 (-fLineDescent)); |
| 714 } | 716 } |
| 715 m_rcRet = CPVT_FloatRect(0, 0, fMaxX, fMaxY); | 717 m_rcRet = CPVT_FloatRect(0, 0, fMaxX, fMaxY); |
| 716 } | 718 } |
| 717 void CTypeset::OutputLines() { | 719 void CTypeset::OutputLines() { |
| 718 ASSERT(m_pVT); | 720 ASSERT(m_pVT); |
| 719 ASSERT(m_pSection); | 721 ASSERT(m_pSection); |
| 720 FX_FLOAT fMinX = 0.0f, fMinY = 0.0f, fMaxX = 0.0f, fMaxY = 0.0f; | 722 FX_FLOAT fMinX = 0.0f, fMinY = 0.0f, fMaxX = 0.0f, fMaxY = 0.0f; |
| 721 FX_FLOAT fPosX = 0.0f, fPosY = 0.0f; | 723 FX_FLOAT fPosX = 0.0f, fPosY = 0.0f; |
| 722 FX_FLOAT fLineIndent = m_pVT->GetLineIndent(m_pSection->m_SecInfo); | 724 FX_FLOAT fLineIndent = m_pVT->GetLineIndent(m_pSection->m_SecInfo); |
| 723 FX_FLOAT fTypesetWidth = FPDF_MAX(m_pVT->GetPlateWidth() - fLineIndent, 0.0f); | 725 FX_FLOAT fTypesetWidth = std::max(m_pVT->GetPlateWidth() - fLineIndent, 0.0f); |
| 724 switch (m_pVT->GetAlignment(m_pSection->m_SecInfo)) { | 726 switch (m_pVT->GetAlignment(m_pSection->m_SecInfo)) { |
| 725 default: | 727 default: |
| 726 case 0: | 728 case 0: |
| 727 fMinX = 0.0f; | 729 fMinX = 0.0f; |
| 728 break; | 730 break; |
| 729 case 1: | 731 case 1: |
| 730 fMinX = (fTypesetWidth - m_rcRet.Width()) * PVT_HALF; | 732 fMinX = (fTypesetWidth - m_rcRet.Width()) * PVT_HALF; |
| 731 break; | 733 break; |
| 732 case 2: | 734 case 2: |
| 733 fMinX = fTypesetWidth - m_rcRet.Width(); | 735 fMinX = fTypesetWidth - m_rcRet.Width(); |
| (...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1252 delete m_SectionArray.GetAt(s); | 1254 delete m_SectionArray.GetAt(s); |
| 1253 } | 1255 } |
| 1254 m_SectionArray.RemoveAll(); | 1256 m_SectionArray.RemoveAll(); |
| 1255 } | 1257 } |
| 1256 CPVT_WordPlace CPDF_VariableText::AddSection(const CPVT_WordPlace& place, | 1258 CPVT_WordPlace CPDF_VariableText::AddSection(const CPVT_WordPlace& place, |
| 1257 const CPVT_SectionInfo& secinfo) { | 1259 const CPVT_SectionInfo& secinfo) { |
| 1258 if (IsValid() && !m_bMultiLine) { | 1260 if (IsValid() && !m_bMultiLine) { |
| 1259 return place; | 1261 return place; |
| 1260 } | 1262 } |
| 1261 int32_t nSecIndex = | 1263 int32_t nSecIndex = |
| 1262 FPDF_MAX(FPDF_MIN(place.nSecIndex, m_SectionArray.GetSize()), 0); | 1264 std::max(std::min(place.nSecIndex, m_SectionArray.GetSize()), 0); |
| 1263 CSection* pSection = new CSection(this); | 1265 CSection* pSection = new CSection(this); |
| 1264 pSection->m_SecInfo = secinfo; | 1266 pSection->m_SecInfo = secinfo; |
| 1265 pSection->SecPlace.nSecIndex = nSecIndex; | 1267 pSection->SecPlace.nSecIndex = nSecIndex; |
| 1266 if (nSecIndex == m_SectionArray.GetSize()) { | 1268 if (nSecIndex == m_SectionArray.GetSize()) { |
| 1267 m_SectionArray.Add(pSection); | 1269 m_SectionArray.Add(pSection); |
| 1268 } else { | 1270 } else { |
| 1269 m_SectionArray.InsertAt(nSecIndex, pSection); | 1271 m_SectionArray.InsertAt(nSecIndex, pSection); |
| 1270 } | 1272 } |
| 1271 return place; | 1273 return place; |
| 1272 } | 1274 } |
| 1273 CPVT_WordPlace CPDF_VariableText::AddLine(const CPVT_WordPlace& place, | 1275 CPVT_WordPlace CPDF_VariableText::AddLine(const CPVT_WordPlace& place, |
| 1274 const CPVT_LineInfo& lineinfo) { | 1276 const CPVT_LineInfo& lineinfo) { |
| 1275 if (m_SectionArray.IsEmpty()) { | 1277 if (m_SectionArray.IsEmpty()) { |
| 1276 return place; | 1278 return place; |
| 1277 } | 1279 } |
| 1278 if (CSection* pSection = m_SectionArray.GetAt(place.nSecIndex)) { | 1280 if (CSection* pSection = m_SectionArray.GetAt(place.nSecIndex)) { |
| 1279 return pSection->AddLine(lineinfo); | 1281 return pSection->AddLine(lineinfo); |
| 1280 } | 1282 } |
| 1281 return place; | 1283 return place; |
| 1282 } | 1284 } |
| 1283 CPVT_WordPlace CPDF_VariableText::AddWord(const CPVT_WordPlace& place, | 1285 CPVT_WordPlace CPDF_VariableText::AddWord(const CPVT_WordPlace& place, |
| 1284 const CPVT_WordInfo& wordinfo) { | 1286 const CPVT_WordInfo& wordinfo) { |
| 1285 if (m_SectionArray.GetSize() <= 0) { | 1287 if (m_SectionArray.GetSize() <= 0) { |
| 1286 return place; | 1288 return place; |
| 1287 } | 1289 } |
| 1288 CPVT_WordPlace newplace = place; | 1290 CPVT_WordPlace newplace = place; |
| 1289 newplace.nSecIndex = | 1291 newplace.nSecIndex = |
| 1290 FPDF_MAX(FPDF_MIN(newplace.nSecIndex, m_SectionArray.GetSize() - 1), 0); | 1292 std::max(std::min(newplace.nSecIndex, m_SectionArray.GetSize() - 1), 0); |
| 1291 if (CSection* pSection = m_SectionArray.GetAt(newplace.nSecIndex)) { | 1293 if (CSection* pSection = m_SectionArray.GetAt(newplace.nSecIndex)) { |
| 1292 return pSection->AddWord(newplace, wordinfo); | 1294 return pSection->AddWord(newplace, wordinfo); |
| 1293 } | 1295 } |
| 1294 return place; | 1296 return place; |
| 1295 } | 1297 } |
| 1296 FX_BOOL CPDF_VariableText::GetWordInfo(const CPVT_WordPlace& place, | 1298 FX_BOOL CPDF_VariableText::GetWordInfo(const CPVT_WordPlace& place, |
| 1297 CPVT_WordInfo& wordinfo) { | 1299 CPVT_WordInfo& wordinfo) { |
| 1298 if (CSection* pSection = m_SectionArray.GetAt(place.nSecIndex)) { | 1300 if (CSection* pSection = m_SectionArray.GetAt(place.nSecIndex)) { |
| 1299 if (CPVT_WordInfo* pWord = pSection->m_WordArray.GetAt(place.nWordIndex)) { | 1301 if (CPVT_WordInfo* pWord = pSection->m_WordArray.GetAt(place.nWordIndex)) { |
| 1300 wordinfo = *pWord; | 1302 wordinfo = *pWord; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1325 } | 1327 } |
| 1326 FX_BOOL CPDF_VariableText::GetSectionInfo(const CPVT_WordPlace& place, | 1328 FX_BOOL CPDF_VariableText::GetSectionInfo(const CPVT_WordPlace& place, |
| 1327 CPVT_SectionInfo& secinfo) { | 1329 CPVT_SectionInfo& secinfo) { |
| 1328 if (CSection* pSection = m_SectionArray.GetAt(place.nSecIndex)) { | 1330 if (CSection* pSection = m_SectionArray.GetAt(place.nSecIndex)) { |
| 1329 secinfo = pSection->m_SecInfo; | 1331 secinfo = pSection->m_SecInfo; |
| 1330 return TRUE; | 1332 return TRUE; |
| 1331 } | 1333 } |
| 1332 return FALSE; | 1334 return FALSE; |
| 1333 } | 1335 } |
| 1334 CPDF_Rect CPDF_VariableText::GetContentRect() const { | 1336 CPDF_Rect CPDF_VariableText::GetContentRect() const { |
| 1335 return InToOut(CPDF_EditContainer::GetContentRect()); | 1337 return InToOut(CPVT_FloatRect(CPDF_EditContainer::GetContentRect())); |
| 1336 } | 1338 } |
| 1337 FX_FLOAT CPDF_VariableText::GetWordFontSize(const CPVT_WordInfo& WordInfo, | 1339 FX_FLOAT CPDF_VariableText::GetWordFontSize(const CPVT_WordInfo& WordInfo, |
| 1338 FX_BOOL bFactFontSize) { | 1340 FX_BOOL bFactFontSize) { |
| 1339 return m_bRichText && WordInfo.pWordProps | 1341 return m_bRichText && WordInfo.pWordProps |
| 1340 ? (WordInfo.pWordProps->nScriptType == PVTWORD_SCRIPT_NORMAL || | 1342 ? (WordInfo.pWordProps->nScriptType == PVTWORD_SCRIPT_NORMAL || |
| 1341 bFactFontSize | 1343 bFactFontSize |
| 1342 ? WordInfo.pWordProps->fFontSize | 1344 ? WordInfo.pWordProps->fFontSize |
| 1343 : WordInfo.pWordProps->fFontSize * PVT_HALF) | 1345 : WordInfo.pWordProps->fFontSize * PVT_HALF) |
| 1344 : GetFontSize(); | 1346 : GetFontSize(); |
| 1345 } | 1347 } |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1569 } | 1571 } |
| 1570 } | 1572 } |
| 1571 return (FX_FLOAT)gFontSizeSteps[nMid]; | 1573 return (FX_FLOAT)gFontSizeSteps[nMid]; |
| 1572 } | 1574 } |
| 1573 FX_BOOL CPDF_VariableText::IsBigger(FX_FLOAT fFontSize) { | 1575 FX_BOOL CPDF_VariableText::IsBigger(FX_FLOAT fFontSize) { |
| 1574 FX_BOOL bBigger = FALSE; | 1576 FX_BOOL bBigger = FALSE; |
| 1575 CPVT_Size szTotal; | 1577 CPVT_Size szTotal; |
| 1576 for (int32_t s = 0, sz = m_SectionArray.GetSize(); s < sz; s++) { | 1578 for (int32_t s = 0, sz = m_SectionArray.GetSize(); s < sz; s++) { |
| 1577 if (CSection* pSection = m_SectionArray.GetAt(s)) { | 1579 if (CSection* pSection = m_SectionArray.GetAt(s)) { |
| 1578 CPVT_Size size = pSection->GetSectionSize(fFontSize); | 1580 CPVT_Size size = pSection->GetSectionSize(fFontSize); |
| 1579 szTotal.x = FPDF_MAX(size.x, szTotal.x); | 1581 szTotal.x = std::max(size.x, szTotal.x); |
| 1580 szTotal.y += size.y; | 1582 szTotal.y += size.y; |
| 1581 if (IsFloatBigger(szTotal.x, GetPlateWidth()) || | 1583 if (IsFloatBigger(szTotal.x, GetPlateWidth()) || |
| 1582 IsFloatBigger(szTotal.y, GetPlateHeight())) { | 1584 IsFloatBigger(szTotal.y, GetPlateHeight())) { |
| 1583 bBigger = TRUE; | 1585 bBigger = TRUE; |
| 1584 break; | 1586 break; |
| 1585 } | 1587 } |
| 1586 } | 1588 } |
| 1587 } | 1589 } |
| 1588 return bBigger; | 1590 return bBigger; |
| 1589 } | 1591 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1610 pSection->m_SecInfo.rcSection.top; | 1612 pSection->m_SecInfo.rcSection.top; |
| 1611 rcSec.top = fPosY; | 1613 rcSec.top = fPosY; |
| 1612 rcSec.bottom = fPosY + fOldHeight; | 1614 rcSec.bottom = fPosY + fOldHeight; |
| 1613 } | 1615 } |
| 1614 pSection->m_SecInfo.rcSection = rcSec; | 1616 pSection->m_SecInfo.rcSection = rcSec; |
| 1615 pSection->ResetLinePlace(); | 1617 pSection->ResetLinePlace(); |
| 1616 } | 1618 } |
| 1617 if (s == 0) { | 1619 if (s == 0) { |
| 1618 rcRet = rcSec; | 1620 rcRet = rcSec; |
| 1619 } else { | 1621 } else { |
| 1620 rcRet.left = FPDF_MIN(rcSec.left, rcRet.left); | 1622 rcRet.left = std::min(rcSec.left, rcRet.left); |
| 1621 rcRet.top = FPDF_MIN(rcSec.top, rcRet.top); | 1623 rcRet.top = std::min(rcSec.top, rcRet.top); |
| 1622 rcRet.right = FPDF_MAX(rcSec.right, rcRet.right); | 1624 rcRet.right = std::max(rcSec.right, rcRet.right); |
| 1623 rcRet.bottom = FPDF_MAX(rcSec.bottom, rcRet.bottom); | 1625 rcRet.bottom = std::max(rcSec.bottom, rcRet.bottom); |
| 1624 } | 1626 } |
| 1625 fPosY += rcSec.Height(); | 1627 fPosY += rcSec.Height(); |
| 1626 } | 1628 } |
| 1627 } | 1629 } |
| 1628 return rcRet; | 1630 return rcRet; |
| 1629 } | 1631 } |
| 1630 int32_t CPDF_VariableText::GetCharWidth(int32_t nFontIndex, | 1632 int32_t CPDF_VariableText::GetCharWidth(int32_t nFontIndex, |
| 1631 FX_WORD Word, | 1633 FX_WORD Word, |
| 1632 FX_WORD SubWord, | 1634 FX_WORD SubWord, |
| 1633 int32_t nWordStyle) { | 1635 int32_t nWordStyle) { |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1814 if (pSection->m_SecInfo.pSecProps) { | 1816 if (pSection->m_SecInfo.pSecProps) { |
| 1815 *pSection->m_SecInfo.pSecProps = section.SecProps; | 1817 *pSection->m_SecInfo.pSecProps = section.SecProps; |
| 1816 } | 1818 } |
| 1817 if (pSection->m_SecInfo.pWordProps) { | 1819 if (pSection->m_SecInfo.pWordProps) { |
| 1818 *pSection->m_SecInfo.pWordProps = section.WordProps; | 1820 *pSection->m_SecInfo.pWordProps = section.WordProps; |
| 1819 } | 1821 } |
| 1820 return TRUE; | 1822 return TRUE; |
| 1821 } | 1823 } |
| 1822 return FALSE; | 1824 return FALSE; |
| 1823 } | 1825 } |
| OLD | NEW |