Chromium Code Reviews| 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 "xfa/fgas/layout/fgas_textbreak.h" | 7 #include "xfa/fgas/layout/fgas_textbreak.h" |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 271 void CFX_TxtBreak::SetCharSpace(FX_FLOAT fCharSpace) { | 271 void CFX_TxtBreak::SetCharSpace(FX_FLOAT fCharSpace) { |
| 272 m_iCharSpace = FXSYS_round(fCharSpace * 20000.0f); | 272 m_iCharSpace = FXSYS_round(fCharSpace * 20000.0f); |
| 273 } | 273 } |
| 274 | 274 |
| 275 static const int32_t gs_FX_TxtLineRotations[8] = {0, 3, 1, 0, 2, 1, 3, 2}; | 275 static const int32_t gs_FX_TxtLineRotations[8] = {0, 3, 1, 0, 2, 1, 3, 2}; |
| 276 int32_t CFX_TxtBreak::GetLineRotation(uint32_t dwStyles) const { | 276 int32_t CFX_TxtBreak::GetLineRotation(uint32_t dwStyles) const { |
| 277 return gs_FX_TxtLineRotations[(dwStyles & 0x0E) >> 1]; | 277 return gs_FX_TxtLineRotations[(dwStyles & 0x0E) >> 1]; |
| 278 } | 278 } |
| 279 | 279 |
| 280 CFX_TxtChar* CFX_TxtBreak::GetLastChar(int32_t index, bool bOmitChar) const { | 280 CFX_TxtChar* CFX_TxtBreak::GetLastChar(int32_t index, bool bOmitChar) const { |
| 281 CFX_TxtCharArray& ca = *m_pCurLine->m_pLineChars.get(); | 281 std::vector<CFX_TxtChar>& ca = *m_pCurLine->m_pLineChars.get(); |
| 282 int32_t iCount = ca.GetSize(); | 282 int32_t iCount = pdfium::CollectionSize<int32_t>(ca); |
| 283 if (index < 0 || index >= iCount) { | 283 if (index < 0 || index >= iCount) { |
| 284 return nullptr; | 284 return nullptr; |
| 285 } | 285 } |
| 286 CFX_TxtChar* pTC; | |
| 287 int32_t iStart = iCount - 1; | 286 int32_t iStart = iCount - 1; |
| 288 while (iStart > -1) { | 287 while (iStart > -1) { |
| 289 pTC = ca.GetDataPtr(iStart--); | 288 CFX_TxtChar* pTC = &ca[iStart--]; |
| 290 if (bOmitChar && pTC->GetCharType() == FX_CHARTYPE_Combination) { | 289 if (bOmitChar && pTC->GetCharType() == FX_CHARTYPE_Combination) { |
| 291 continue; | 290 continue; |
| 292 } | 291 } |
| 293 if (--index < 0) { | 292 if (--index < 0) { |
| 294 return pTC; | 293 return pTC; |
| 295 } | 294 } |
| 296 } | 295 } |
| 297 return nullptr; | 296 return nullptr; |
| 298 } | 297 } |
| 299 | 298 |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 588 (m_dwPolicies & FX_TXTBREAKPOLICY_SpaceBreak) != 0); | 587 (m_dwPolicies & FX_TXTBREAKPOLICY_SpaceBreak) != 0); |
| 589 if (!m_bSingleLine && bBreak && iLineWidth > m_iLineWidth + m_iTolerance) { | 588 if (!m_bSingleLine && bBreak && iLineWidth > m_iLineWidth + m_iTolerance) { |
| 590 return EndBreak(FX_TXTBREAK_LineBreak); | 589 return EndBreak(FX_TXTBREAK_LineBreak); |
| 591 } | 590 } |
| 592 return FX_TXTBREAK_None; | 591 return FX_TXTBREAK_None; |
| 593 } | 592 } |
| 594 | 593 |
| 595 uint32_t CFX_TxtBreak::AppendChar(FX_WCHAR wch) { | 594 uint32_t CFX_TxtBreak::AppendChar(FX_WCHAR wch) { |
| 596 uint32_t dwProps = kTextLayoutCodeProperties[(uint16_t)wch]; | 595 uint32_t dwProps = kTextLayoutCodeProperties[(uint16_t)wch]; |
| 597 FX_CHARTYPE chartype = GetCharTypeFromProp(dwProps); | 596 FX_CHARTYPE chartype = GetCharTypeFromProp(dwProps); |
| 598 CFX_TxtChar* pCurChar = m_pCurLine->m_pLineChars->AddSpace(); | 597 m_pCurLine->m_pLineChars->emplace_back(); |
| 598 CFX_TxtChar* pCurChar = &m_pCurLine->m_pLineChars->back(); | |
| 599 pCurChar->m_wCharCode = (uint16_t)wch; | 599 pCurChar->m_wCharCode = (uint16_t)wch; |
| 600 pCurChar->m_nRotation = m_iCharRotation; | 600 pCurChar->m_nRotation = m_iCharRotation; |
| 601 pCurChar->m_dwCharProps = dwProps; | 601 pCurChar->m_dwCharProps = dwProps; |
| 602 pCurChar->m_dwCharStyles = 0; | 602 pCurChar->m_dwCharStyles = 0; |
| 603 pCurChar->m_iCharWidth = 0; | 603 pCurChar->m_iCharWidth = 0; |
| 604 pCurChar->m_iHorizontalScale = m_iHorScale; | 604 pCurChar->m_iHorizontalScale = m_iHorScale; |
| 605 pCurChar->m_iVertialScale = m_iVerScale; | 605 pCurChar->m_iVertialScale = m_iVerScale; |
| 606 pCurChar->m_dwStatus = 0; | 606 pCurChar->m_dwStatus = 0; |
| 607 pCurChar->m_iBidiClass = 0; | 607 pCurChar->m_iBidiClass = 0; |
| 608 pCurChar->m_iBidiLevel = 0; | 608 pCurChar->m_iBidiLevel = 0; |
| 609 pCurChar->m_iBidiPos = 0; | 609 pCurChar->m_iBidiPos = 0; |
| 610 pCurChar->m_iBidiOrder = 0; | 610 pCurChar->m_iBidiOrder = 0; |
| 611 pCurChar->m_pUserData = nullptr; | 611 pCurChar->m_pUserData = nullptr; |
| 612 AppendChar_PageLoad(pCurChar, dwProps); | 612 AppendChar_PageLoad(pCurChar, dwProps); |
| 613 uint32_t dwRet1 = FX_TXTBREAK_None; | 613 uint32_t dwRet1 = FX_TXTBREAK_None; |
| 614 if (chartype != FX_CHARTYPE_Combination && | 614 if (chartype != FX_CHARTYPE_Combination && |
| 615 GetUnifiedCharType(m_eCharType) != GetUnifiedCharType(chartype)) { | 615 GetUnifiedCharType(m_eCharType) != GetUnifiedCharType(chartype)) { |
| 616 if (m_eCharType != FX_CHARTYPE_Unknown && | 616 if (m_eCharType != FX_CHARTYPE_Unknown && |
| 617 m_pCurLine->m_iWidth > m_iLineWidth + m_iTolerance && !m_bSingleLine) { | 617 m_pCurLine->m_iWidth > m_iLineWidth + m_iTolerance && !m_bSingleLine) { |
| 618 if (m_eCharType != FX_CHARTYPE_Space || chartype != FX_CHARTYPE_Control) { | 618 if (m_eCharType != FX_CHARTYPE_Space || chartype != FX_CHARTYPE_Control) { |
| 619 dwRet1 = EndBreak(FX_TXTBREAK_LineBreak); | 619 dwRet1 = EndBreak(FX_TXTBREAK_LineBreak); |
| 620 int32_t iCount = m_pCurLine->CountChars(); | 620 int32_t iCount = m_pCurLine->CountChars(); |
| 621 if (iCount > 0) { | 621 if (iCount > 0) { |
| 622 pCurChar = m_pCurLine->m_pLineChars->GetDataPtr(iCount - 1); | 622 pCurChar = &(*m_pCurLine->m_pLineChars)[iCount - 1]; |
| 623 } | 623 } |
| 624 } | 624 } |
| 625 } | 625 } |
| 626 } | 626 } |
| 627 int32_t iRotation = m_iRotation; | 627 int32_t iRotation = m_iRotation; |
| 628 if (m_bVertical && (dwProps & 0x8000) != 0) { | 628 if (m_bVertical && (dwProps & 0x8000) != 0) { |
| 629 iRotation = (iRotation + 1) % 4; | 629 iRotation = (iRotation + 1) % 4; |
| 630 } | 630 } |
| 631 uint32_t dwRet2 = | 631 uint32_t dwRet2 = |
| 632 (this->*g_FX_TxtBreak_lpfAppendChar[chartype >> FX_CHARTYPEBITS])( | 632 (this->*g_FX_TxtBreak_lpfAppendChar[chartype >> FX_CHARTYPEBITS])( |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 737 GetBreakPos(*m_pCurLine->m_pLineChars.get(), iEndPos, bAllChars, true); | 737 GetBreakPos(*m_pCurLine->m_pLineChars.get(), iEndPos, bAllChars, true); |
| 738 } | 738 } |
| 739 return false; | 739 return false; |
| 740 } | 740 } |
| 741 | 741 |
| 742 void CFX_TxtBreak::EndBreak_BidiLine(CFX_TPOArray& tpos, uint32_t dwStatus) { | 742 void CFX_TxtBreak::EndBreak_BidiLine(CFX_TPOArray& tpos, uint32_t dwStatus) { |
| 743 CFX_TxtPiece tp; | 743 CFX_TxtPiece tp; |
| 744 FX_TPO tpo; | 744 FX_TPO tpo; |
| 745 CFX_TxtChar* pTC; | 745 CFX_TxtChar* pTC; |
| 746 int32_t i, j; | 746 int32_t i, j; |
| 747 CFX_TxtCharArray& chars = *m_pCurLine->m_pLineChars.get(); | 747 std::vector<CFX_TxtChar>& chars = *m_pCurLine->m_pLineChars.get(); |
| 748 int32_t iCount = m_pCurLine->CountChars(); | 748 int32_t iCount = m_pCurLine->CountChars(); |
| 749 bool bDone = (m_pCurLine->m_iArabicChars > 0 || m_bCurRTL); | 749 bool bDone = (m_pCurLine->m_iArabicChars > 0 || m_bCurRTL); |
| 750 if (!m_bPagination && bDone) { | 750 if (!m_bPagination && bDone) { |
| 751 int32_t iBidiNum = 0; | 751 int32_t iBidiNum = 0; |
| 752 for (i = 0; i < iCount; i++) { | 752 for (i = 0; i < iCount; i++) { |
| 753 pTC = chars.GetDataPtr(i); | 753 pTC = &chars[i]; |
| 754 pTC->m_iBidiPos = i; | 754 pTC->m_iBidiPos = i; |
| 755 if (pTC->GetCharType() != FX_CHARTYPE_Control) { | 755 if (pTC->GetCharType() != FX_CHARTYPE_Control) { |
| 756 iBidiNum = i; | 756 iBidiNum = i; |
| 757 } | 757 } |
| 758 if (i == 0) { | 758 if (i == 0) { |
| 759 pTC->m_iBidiLevel = 1; | 759 pTC->m_iBidiLevel = 1; |
| 760 } | 760 } |
| 761 } | 761 } |
| 762 FX_BidiLine(chars, iBidiNum + 1, m_bCurRTL ? 1 : 0); | 762 FX_BidiLine(chars, iBidiNum + 1, m_bCurRTL ? 1 : 0); |
| 763 } | 763 } |
| 764 CFX_TxtPieceArray* pCurPieces = m_pCurLine->m_pLinePieces.get(); | 764 CFX_TxtPieceArray* pCurPieces = m_pCurLine->m_pLinePieces.get(); |
| 765 if (!m_bPagination && | 765 if (!m_bPagination && |
| 766 (bDone || (m_dwLayoutStyles & FX_TXTLAYOUTSTYLE_MutipleFormat) != 0)) { | 766 (bDone || (m_dwLayoutStyles & FX_TXTLAYOUTSTYLE_MutipleFormat) != 0)) { |
| 767 tp.m_dwStatus = FX_TXTBREAK_PieceBreak; | 767 tp.m_dwStatus = FX_TXTBREAK_PieceBreak; |
| 768 tp.m_iStartPos = m_pCurLine->m_iStart; | 768 tp.m_iStartPos = m_pCurLine->m_iStart; |
| 769 tp.m_pChars = m_pCurLine->m_pLineChars.get(); | 769 tp.m_pChars = m_pCurLine->m_pLineChars.get(); |
| 770 int32_t iBidiLevel = -1, iCharWidth; | 770 int32_t iBidiLevel = -1, iCharWidth; |
| 771 i = 0, j = -1; | 771 i = 0, j = -1; |
| 772 while (i < iCount) { | 772 while (i < iCount) { |
| 773 pTC = chars.GetDataPtr(i); | 773 pTC = &chars[i]; |
| 774 if (iBidiLevel < 0) { | 774 if (iBidiLevel < 0) { |
| 775 iBidiLevel = pTC->m_iBidiLevel; | 775 iBidiLevel = pTC->m_iBidiLevel; |
| 776 tp.m_iWidth = 0; | 776 tp.m_iWidth = 0; |
| 777 tp.m_iBidiLevel = iBidiLevel; | 777 tp.m_iBidiLevel = iBidiLevel; |
| 778 tp.m_iBidiPos = pTC->m_iBidiOrder; | 778 tp.m_iBidiPos = pTC->m_iBidiOrder; |
| 779 tp.m_dwCharStyles = pTC->m_dwCharStyles; | 779 tp.m_dwCharStyles = pTC->m_dwCharStyles; |
| 780 tp.m_pUserData = pTC->m_pUserData; | 780 tp.m_pUserData = pTC->m_pUserData; |
| 781 tp.m_iHorizontalScale = pTC->m_iHorizontalScale; | 781 tp.m_iHorizontalScale = pTC->m_iHorizontalScale; |
| 782 tp.m_iVerticalScale = pTC->m_iVertialScale; | 782 tp.m_iVerticalScale = pTC->m_iVertialScale; |
| 783 tp.m_dwStatus = FX_TXTBREAK_PieceBreak; | 783 tp.m_dwStatus = FX_TXTBREAK_PieceBreak; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 830 ttp.m_dwStatus = dwStatus; | 830 ttp.m_dwStatus = dwStatus; |
| 831 } | 831 } |
| 832 } else { | 832 } else { |
| 833 tp.m_dwStatus = dwStatus; | 833 tp.m_dwStatus = dwStatus; |
| 834 tp.m_iStartPos = m_pCurLine->m_iStart; | 834 tp.m_iStartPos = m_pCurLine->m_iStart; |
| 835 tp.m_iWidth = m_pCurLine->m_iWidth; | 835 tp.m_iWidth = m_pCurLine->m_iWidth; |
| 836 tp.m_iStartChar = 0; | 836 tp.m_iStartChar = 0; |
| 837 tp.m_iChars = iCount; | 837 tp.m_iChars = iCount; |
| 838 tp.m_pChars = m_pCurLine->m_pLineChars.get(); | 838 tp.m_pChars = m_pCurLine->m_pLineChars.get(); |
| 839 tp.m_pUserData = m_pUserData; | 839 tp.m_pUserData = m_pUserData; |
| 840 pTC = chars.GetDataPtr(0); | 840 pTC = &chars[0]; |
| 841 tp.m_dwCharStyles = pTC->m_dwCharStyles; | 841 tp.m_dwCharStyles = pTC->m_dwCharStyles; |
| 842 tp.m_iHorizontalScale = pTC->m_iHorizontalScale; | 842 tp.m_iHorizontalScale = pTC->m_iHorizontalScale; |
| 843 tp.m_iVerticalScale = pTC->m_iVertialScale; | 843 tp.m_iVerticalScale = pTC->m_iVertialScale; |
| 844 pCurPieces->Add(tp); | 844 pCurPieces->Add(tp); |
| 845 tpo.index = 0; | 845 tpo.index = 0; |
| 846 tpo.pos = 0; | 846 tpo.pos = 0; |
| 847 tpos.Add(tpo); | 847 tpos.Add(tpo); |
| 848 } | 848 } |
| 849 } | 849 } |
| 850 | 850 |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 999 m_pCurLine = pNextLine; | 999 m_pCurLine = pNextLine; |
| 1000 pTC = GetLastChar(0, false); | 1000 pTC = GetLastChar(0, false); |
| 1001 m_eCharType = pTC ? pTC->GetCharType() : FX_CHARTYPE_Unknown; | 1001 m_eCharType = pTC ? pTC->GetCharType() : FX_CHARTYPE_Unknown; |
| 1002 if (dwStatus == FX_TXTBREAK_ParagraphBreak) { | 1002 if (dwStatus == FX_TXTBREAK_ParagraphBreak) { |
| 1003 m_iArabicContext = m_iCurArabicContext = 1; | 1003 m_iArabicContext = m_iCurArabicContext = 1; |
| 1004 ResetArabicContext(); | 1004 ResetArabicContext(); |
| 1005 } | 1005 } |
| 1006 return dwStatus; | 1006 return dwStatus; |
| 1007 } | 1007 } |
| 1008 | 1008 |
| 1009 int32_t CFX_TxtBreak::GetBreakPos(CFX_TxtCharArray& ca, | 1009 int32_t CFX_TxtBreak::GetBreakPos(std::vector<CFX_TxtChar>& ca, |
| 1010 int32_t& iEndPos, | 1010 int32_t& iEndPos, |
| 1011 bool bAllChars, | 1011 bool bAllChars, |
| 1012 bool bOnlyBrk) { | 1012 bool bOnlyBrk) { |
| 1013 int32_t iLength = ca.GetSize() - 1; | 1013 int32_t iLength = pdfium::CollectionSize<int32_t>(ca) - 1; |
| 1014 if (iLength < 1) { | 1014 if (iLength < 1) { |
| 1015 return iLength; | 1015 return iLength; |
| 1016 } | 1016 } |
| 1017 int32_t iBreak = -1, iBreakPos = -1, iIndirect = -1, iIndirectPos = -1, | 1017 int32_t iBreak = -1, iBreakPos = -1, iIndirect = -1, iIndirectPos = -1, |
| 1018 iLast = -1, iLastPos = -1; | 1018 iLast = -1, iLastPos = -1; |
| 1019 if (m_bSingleLine || iEndPos <= m_iLineWidth) { | 1019 if (m_bSingleLine || iEndPos <= m_iLineWidth) { |
| 1020 if (!bAllChars) { | 1020 if (!bAllChars) { |
| 1021 return iLength; | 1021 return iLength; |
| 1022 } | 1022 } |
| 1023 iBreak = iLength; | 1023 iBreak = iLength; |
| 1024 iBreakPos = iEndPos; | 1024 iBreakPos = iEndPos; |
| 1025 } | 1025 } |
| 1026 bool bSpaceBreak = (m_dwPolicies & FX_TXTBREAKPOLICY_SpaceBreak) != 0; | 1026 bool bSpaceBreak = (m_dwPolicies & FX_TXTBREAKPOLICY_SpaceBreak) != 0; |
| 1027 bool bNumberBreak = (m_dwPolicies & FX_TXTBREAKPOLICY_NumberBreak) != 0; | 1027 bool bNumberBreak = (m_dwPolicies & FX_TXTBREAKPOLICY_NumberBreak) != 0; |
| 1028 FX_LINEBREAKTYPE eType; | 1028 FX_LINEBREAKTYPE eType; |
| 1029 uint32_t nCodeProp, nCur, nNext; | 1029 uint32_t nCodeProp, nCur, nNext; |
| 1030 CFX_Char* pCur = ca.GetDataPtr(iLength--); | 1030 CFX_Char* pCur = &ca[iLength--]; |
| 1031 if (bAllChars) { | 1031 if (bAllChars) { |
| 1032 pCur->m_nBreakType = FX_LBT_UNKNOWN; | 1032 pCur->m_nBreakType = FX_LBT_UNKNOWN; |
| 1033 } | 1033 } |
| 1034 nCodeProp = pCur->m_dwCharProps; | 1034 nCodeProp = pCur->m_dwCharProps; |
| 1035 nNext = nCodeProp & 0x003F; | 1035 nNext = nCodeProp & 0x003F; |
| 1036 int32_t iCharWidth = pCur->m_iCharWidth; | 1036 int32_t iCharWidth = pCur->m_iCharWidth; |
| 1037 if (iCharWidth > 0) { | 1037 if (iCharWidth > 0) { |
| 1038 iEndPos -= iCharWidth; | 1038 iEndPos -= iCharWidth; |
| 1039 } | 1039 } |
| 1040 while (iLength >= 0) { | 1040 while (iLength >= 0) { |
| 1041 pCur = ca.GetDataPtr(iLength); | 1041 pCur = &ca[iLength]; |
| 1042 nCodeProp = pCur->m_dwCharProps; | 1042 nCodeProp = pCur->m_dwCharProps; |
| 1043 nCur = nCodeProp & 0x003F; | 1043 nCur = nCodeProp & 0x003F; |
| 1044 if (nCur == FX_CBP_SP) { | 1044 if (nCur == FX_CBP_SP) { |
| 1045 if (nNext == FX_CBP_SP) { | 1045 if (nNext == FX_CBP_SP) { |
| 1046 eType = bSpaceBreak ? FX_LBT_DIRECT_BRK : FX_LBT_PROHIBITED_BRK; | 1046 eType = bSpaceBreak ? FX_LBT_DIRECT_BRK : FX_LBT_PROHIBITED_BRK; |
| 1047 } else { | 1047 } else { |
| 1048 eType = gs_FX_LineBreak_PairTable[nCur][nNext]; | 1048 eType = gs_FX_LineBreak_PairTable[nCur][nNext]; |
| 1049 } | 1049 } |
| 1050 } else if (bNumberBreak && nCur == FX_CBP_NU && nNext == FX_CBP_NU) { | 1050 } else if (bNumberBreak && nCur == FX_CBP_NU && nNext == FX_CBP_NU) { |
| 1051 eType = FX_LBT_DIRECT_BRK; | 1051 eType = FX_LBT_DIRECT_BRK; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1105 | 1105 |
| 1106 void CFX_TxtBreak::SplitTextLine(CFX_TxtLine* pCurLine, | 1106 void CFX_TxtBreak::SplitTextLine(CFX_TxtLine* pCurLine, |
| 1107 CFX_TxtLine* pNextLine, | 1107 CFX_TxtLine* pNextLine, |
| 1108 bool bAllChars) { | 1108 bool bAllChars) { |
| 1109 ASSERT(pCurLine && pNextLine); | 1109 ASSERT(pCurLine && pNextLine); |
| 1110 int32_t iCount = pCurLine->CountChars(); | 1110 int32_t iCount = pCurLine->CountChars(); |
| 1111 if (iCount < 2) { | 1111 if (iCount < 2) { |
| 1112 return; | 1112 return; |
| 1113 } | 1113 } |
| 1114 int32_t iEndPos = pCurLine->m_iWidth; | 1114 int32_t iEndPos = pCurLine->m_iWidth; |
| 1115 CFX_TxtCharArray& curChars = *pCurLine->m_pLineChars.get(); | 1115 std::vector<CFX_TxtChar>& curChars = *pCurLine->m_pLineChars.get(); |
| 1116 int32_t iCharPos = GetBreakPos(curChars, iEndPos, bAllChars, false); | 1116 int32_t iCharPos = GetBreakPos(curChars, iEndPos, bAllChars, false); |
| 1117 if (iCharPos < 0) { | 1117 if (iCharPos < 0) { |
| 1118 iCharPos = 0; | 1118 iCharPos = 0; |
| 1119 } | 1119 } |
| 1120 iCharPos++; | 1120 iCharPos++; |
| 1121 if (iCharPos >= iCount) { | 1121 if (iCharPos >= iCount) { |
| 1122 pNextLine->RemoveAll(true); | 1122 pNextLine->RemoveAll(true); |
| 1123 CFX_Char* pTC = curChars.GetDataPtr(iCharPos - 1); | 1123 CFX_Char* pTC = &curChars[iCharPos - 1]; |
| 1124 pTC->m_nBreakType = FX_LBT_UNKNOWN; | 1124 pTC->m_nBreakType = FX_LBT_UNKNOWN; |
| 1125 return; | 1125 return; |
| 1126 } | 1126 } |
| 1127 CFX_TxtCharArray& nextChars = *pNextLine->m_pLineChars.get(); | 1127 std::vector<CFX_TxtChar>& nextChars = *pNextLine->m_pLineChars.get(); |
| 1128 int cur_size = curChars.GetSize(); | 1128 int cur_size = pdfium::CollectionSize<int>(curChars); |
| 1129 nextChars.SetSize(cur_size - iCharPos); | 1129 nextChars.resize(cur_size - iCharPos); |
| 1130 FXSYS_memcpy(nextChars.GetData(), curChars.GetDataPtr(iCharPos), | 1130 FXSYS_memcpy(nextChars.data(), curChars.data() + iCharPos, |
|
dsinclair
2017/01/24 18:43:59
std::copy
Tom Sepez
2017/01/24 19:16:12
Even better is new vector ctor from iterators and
| |
| 1131 (cur_size - iCharPos) * sizeof(CFX_TxtChar)); | 1131 (cur_size - iCharPos) * sizeof(CFX_TxtChar)); |
| 1132 iCount -= iCharPos; | 1132 iCount -= iCharPos; |
| 1133 cur_size = curChars.GetSize(); | 1133 cur_size = pdfium::CollectionSize<int>(curChars); |
| 1134 curChars.RemoveAt(cur_size - iCount, iCount); | 1134 curChars.erase(curChars.begin() + cur_size - iCount, |
| 1135 curChars.begin() + cur_size); | |
| 1135 pCurLine->m_iWidth = iEndPos; | 1136 pCurLine->m_iWidth = iEndPos; |
| 1136 CFX_TxtChar* pTC = curChars.GetDataPtr(iCharPos - 1); | 1137 CFX_TxtChar* pTC = &curChars[iCharPos - 1]; |
| 1137 pTC->m_nBreakType = FX_LBT_UNKNOWN; | 1138 pTC->m_nBreakType = FX_LBT_UNKNOWN; |
| 1138 iCount = nextChars.GetSize(); | 1139 iCount = pdfium::CollectionSize<int>(nextChars); |
| 1139 int32_t iCharWidth, iWidth = 0; | 1140 int32_t iCharWidth, iWidth = 0; |
| 1140 for (int32_t i = 0; i < iCount; i++) { | 1141 for (int32_t i = 0; i < iCount; i++) { |
| 1141 pTC = nextChars.GetDataPtr(i); | 1142 pTC = &nextChars[i]; |
| 1142 if (pTC->GetCharType() >= FX_CHARTYPE_ArabicAlef) { | 1143 if (pTC->GetCharType() >= FX_CHARTYPE_ArabicAlef) { |
| 1143 pCurLine->m_iArabicChars--; | 1144 pCurLine->m_iArabicChars--; |
| 1144 pNextLine->m_iArabicChars++; | 1145 pNextLine->m_iArabicChars++; |
| 1145 } | 1146 } |
| 1146 iCharWidth = pTC->m_iCharWidth; | 1147 iCharWidth = pTC->m_iCharWidth; |
| 1147 if (iCharWidth > 0) { | 1148 if (iCharWidth > 0) { |
| 1148 iWidth += iCharWidth; | 1149 iWidth += iCharWidth; |
| 1149 } | 1150 } |
| 1150 if (m_bPagination) { | 1151 if (m_bPagination) { |
| 1151 continue; | 1152 continue; |
| (...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1725 m_iChars(0), | 1726 m_iChars(0), |
| 1726 m_iBidiLevel(0), | 1727 m_iBidiLevel(0), |
| 1727 m_iBidiPos(0), | 1728 m_iBidiPos(0), |
| 1728 m_iHorizontalScale(100), | 1729 m_iHorizontalScale(100), |
| 1729 m_iVerticalScale(100), | 1730 m_iVerticalScale(100), |
| 1730 m_dwCharStyles(0), | 1731 m_dwCharStyles(0), |
| 1731 m_pChars(nullptr), | 1732 m_pChars(nullptr), |
| 1732 m_pUserData(nullptr) {} | 1733 m_pUserData(nullptr) {} |
| 1733 | 1734 |
| 1734 CFX_TxtLine::CFX_TxtLine(int32_t iBlockSize) | 1735 CFX_TxtLine::CFX_TxtLine(int32_t iBlockSize) |
| 1735 : m_pLineChars(new CFX_TxtCharArray), | 1736 : m_pLineChars(new std::vector<CFX_TxtChar>), |
| 1736 m_pLinePieces(new CFX_TxtPieceArray(16)), | 1737 m_pLinePieces(new CFX_TxtPieceArray(16)), |
| 1737 m_iStart(0), | 1738 m_iStart(0), |
| 1738 m_iWidth(0), | 1739 m_iWidth(0), |
| 1739 m_iArabicChars(0) {} | 1740 m_iArabicChars(0) {} |
| 1740 | 1741 |
| 1741 CFX_TxtLine::~CFX_TxtLine() { | 1742 CFX_TxtLine::~CFX_TxtLine() { |
| 1742 RemoveAll(); | 1743 RemoveAll(); |
| 1743 } | 1744 } |
| OLD | NEW |