| 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_rtfbreak.h" | 7 #include "xfa/fgas/layout/fgas_rtfbreak.h" |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 int32_t iCount = m_pCurLine->CountChars(); | 266 int32_t iCount = m_pCurLine->CountChars(); |
| 267 if (iCount < 1) { | 267 if (iCount < 1) { |
| 268 return; | 268 return; |
| 269 } | 269 } |
| 270 CFX_RTFChar& tc = m_pCurLine->GetChar(iCount - 1); | 270 CFX_RTFChar& tc = m_pCurLine->GetChar(iCount - 1); |
| 271 if (tc.m_dwStatus == 0) { | 271 if (tc.m_dwStatus == 0) { |
| 272 tc.m_dwStatus = FX_RTFBREAK_PieceBreak; | 272 tc.m_dwStatus = FX_RTFBREAK_PieceBreak; |
| 273 } | 273 } |
| 274 } | 274 } |
| 275 CFX_RTFChar* CFX_RTFBreak::GetLastChar(int32_t index) const { | 275 CFX_RTFChar* CFX_RTFBreak::GetLastChar(int32_t index) const { |
| 276 CFX_RTFCharArray& tca = m_pCurLine->m_LineChars; | 276 std::vector<CFX_RTFChar>& tca = m_pCurLine->m_LineChars; |
| 277 int32_t iCount = tca.GetSize(); | 277 int32_t iCount = pdfium::CollectionSize<int32_t>(tca); |
| 278 if (index < 0 || index >= iCount) { | 278 if (index < 0 || index >= iCount) { |
| 279 return nullptr; | 279 return nullptr; |
| 280 } | 280 } |
| 281 CFX_RTFChar* pTC; | |
| 282 int32_t iStart = iCount - 1; | 281 int32_t iStart = iCount - 1; |
| 283 while (iStart > -1) { | 282 while (iStart > -1) { |
| 284 pTC = tca.GetDataPtr(iStart--); | 283 CFX_RTFChar* pTC = &tca[iStart--]; |
| 285 if (pTC->m_iCharWidth >= 0 || | 284 if (pTC->m_iCharWidth >= 0 || |
| 286 pTC->GetCharType() != FX_CHARTYPE_Combination) { | 285 pTC->GetCharType() != FX_CHARTYPE_Combination) { |
| 287 if (--index < 0) { | 286 if (--index < 0) { |
| 288 return pTC; | 287 return pTC; |
| 289 } | 288 } |
| 290 } | 289 } |
| 291 } | 290 } |
| 292 return nullptr; | 291 return nullptr; |
| 293 } | 292 } |
| 294 CFX_RTFLine* CFX_RTFBreak::GetRTFLine(bool bReady) const { | 293 CFX_RTFLine* CFX_RTFBreak::GetRTFLine(bool bReady) const { |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 &CFX_RTFBreak::AppendChar_Arabic, &CFX_RTFBreak::AppendChar_Others, | 341 &CFX_RTFBreak::AppendChar_Arabic, &CFX_RTFBreak::AppendChar_Others, |
| 343 &CFX_RTFBreak::AppendChar_Others, &CFX_RTFBreak::AppendChar_Others, | 342 &CFX_RTFBreak::AppendChar_Others, &CFX_RTFBreak::AppendChar_Others, |
| 344 }; | 343 }; |
| 345 uint32_t CFX_RTFBreak::AppendChar(FX_WCHAR wch) { | 344 uint32_t CFX_RTFBreak::AppendChar(FX_WCHAR wch) { |
| 346 ASSERT(m_pFont && m_pCurLine); | 345 ASSERT(m_pFont && m_pCurLine); |
| 347 if (m_bCharCode) | 346 if (m_bCharCode) |
| 348 return AppendChar_CharCode(wch); | 347 return AppendChar_CharCode(wch); |
| 349 | 348 |
| 350 uint32_t dwProps = kTextLayoutCodeProperties[(uint16_t)wch]; | 349 uint32_t dwProps = kTextLayoutCodeProperties[(uint16_t)wch]; |
| 351 FX_CHARTYPE chartype = GetCharTypeFromProp(dwProps); | 350 FX_CHARTYPE chartype = GetCharTypeFromProp(dwProps); |
| 352 CFX_RTFCharArray& tca = m_pCurLine->m_LineChars; | 351 m_pCurLine->m_LineChars.emplace_back(); |
| 353 CFX_RTFChar* pCurChar = tca.AddSpace(); | 352 CFX_RTFChar* pCurChar = &m_pCurLine->m_LineChars.back(); |
| 354 pCurChar->m_dwStatus = 0; | 353 pCurChar->m_dwStatus = 0; |
| 355 pCurChar->m_wCharCode = wch; | 354 pCurChar->m_wCharCode = wch; |
| 356 pCurChar->m_dwCharProps = dwProps; | 355 pCurChar->m_dwCharProps = dwProps; |
| 357 pCurChar->m_dwCharStyles = 0; | 356 pCurChar->m_dwCharStyles = 0; |
| 358 pCurChar->m_dwLayoutStyles = 0; | 357 pCurChar->m_dwLayoutStyles = 0; |
| 359 pCurChar->m_iFontSize = m_iFontSize; | 358 pCurChar->m_iFontSize = m_iFontSize; |
| 360 pCurChar->m_iFontHeight = m_iFontHeight; | 359 pCurChar->m_iFontHeight = m_iFontHeight; |
| 361 pCurChar->m_iHorizontalScale = m_iHorizontalScale; | 360 pCurChar->m_iHorizontalScale = m_iHorizontalScale; |
| 362 pCurChar->m_iVertialScale = m_iVerticalScale; | 361 pCurChar->m_iVertialScale = m_iVerticalScale; |
| 363 pCurChar->m_nRotation = m_iCharRotation; | 362 pCurChar->m_nRotation = m_iCharRotation; |
| 364 pCurChar->m_iCharWidth = 0; | 363 pCurChar->m_iCharWidth = 0; |
| 365 pCurChar->m_dwIdentity = m_dwIdentity; | 364 pCurChar->m_dwIdentity = m_dwIdentity; |
| 366 if (m_pUserData) { | 365 if (m_pUserData) { |
| 367 m_pUserData->Retain(); | 366 m_pUserData->Retain(); |
| 368 } | 367 } |
| 369 pCurChar->m_pUserData = m_pUserData; | 368 pCurChar->m_pUserData = m_pUserData; |
| 370 uint32_t dwRet1 = FX_RTFBREAK_None; | 369 uint32_t dwRet1 = FX_RTFBREAK_None; |
| 371 if (chartype != FX_CHARTYPE_Combination && | 370 if (chartype != FX_CHARTYPE_Combination && |
| 372 GetUnifiedCharType(m_eCharType) != GetUnifiedCharType(chartype)) { | 371 GetUnifiedCharType(m_eCharType) != GetUnifiedCharType(chartype)) { |
| 373 if (!m_bSingleLine && !m_bOrphanLine && | 372 if (!m_bSingleLine && !m_bOrphanLine && |
| 374 m_eCharType != FX_CHARTYPE_Unknown && | 373 m_eCharType != FX_CHARTYPE_Unknown && |
| 375 m_pCurLine->GetLineEnd() > m_iBoundaryEnd + m_iTolerance) { | 374 m_pCurLine->GetLineEnd() > m_iBoundaryEnd + m_iTolerance) { |
| 376 if (m_eCharType != FX_CHARTYPE_Space || chartype != FX_CHARTYPE_Control) { | 375 if (m_eCharType != FX_CHARTYPE_Space || chartype != FX_CHARTYPE_Control) { |
| 377 dwRet1 = EndBreak(FX_RTFBREAK_LineBreak); | 376 dwRet1 = EndBreak(FX_RTFBREAK_LineBreak); |
| 378 int32_t iCount = m_pCurLine->CountChars(); | 377 int32_t iCount = m_pCurLine->CountChars(); |
| 379 if (iCount > 0) { | 378 if (iCount > 0) { |
| 380 pCurChar = m_pCurLine->m_LineChars.GetDataPtr(iCount - 1); | 379 pCurChar = &m_pCurLine->m_LineChars[iCount - 1]; |
| 381 } | 380 } |
| 382 } | 381 } |
| 383 } | 382 } |
| 384 } | 383 } |
| 385 int32_t iRotation = m_iRotation; | 384 int32_t iRotation = m_iRotation; |
| 386 if (m_bVertical && (dwProps & 0x8000) != 0) { | 385 if (m_bVertical && (dwProps & 0x8000) != 0) { |
| 387 iRotation = (iRotation + 1) % 4; | 386 iRotation = (iRotation + 1) % 4; |
| 388 } | 387 } |
| 389 uint32_t dwRet2 = | 388 uint32_t dwRet2 = |
| 390 (this->*g_FX_RTFBreak_lpfAppendChar[chartype >> FX_CHARTYPEBITS])( | 389 (this->*g_FX_RTFBreak_lpfAppendChar[chartype >> FX_CHARTYPEBITS])( |
| 391 pCurChar, iRotation); | 390 pCurChar, iRotation); |
| 392 m_eCharType = chartype; | 391 m_eCharType = chartype; |
| 393 return std::max(dwRet1, dwRet2); | 392 return std::max(dwRet1, dwRet2); |
| 394 } | 393 } |
| 395 | 394 |
| 396 uint32_t CFX_RTFBreak::AppendChar_CharCode(FX_WCHAR wch) { | 395 uint32_t CFX_RTFBreak::AppendChar_CharCode(FX_WCHAR wch) { |
| 397 ASSERT(m_pFont && m_pCurLine); | 396 ASSERT(m_pFont && m_pCurLine); |
| 398 ASSERT(m_bCharCode); | 397 ASSERT(m_bCharCode); |
| 399 m_pCurLine->m_iMBCSChars++; | 398 m_pCurLine->m_iMBCSChars++; |
| 400 CFX_RTFCharArray& tca = m_pCurLine->m_LineChars; | 399 m_pCurLine->m_LineChars.emplace_back(); |
| 401 CFX_RTFChar* pCurChar = tca.AddSpace(); | 400 CFX_RTFChar* pCurChar = &m_pCurLine->m_LineChars.back(); |
| 402 pCurChar->m_dwStatus = 0; | 401 pCurChar->m_dwStatus = 0; |
| 403 pCurChar->m_wCharCode = wch; | 402 pCurChar->m_wCharCode = wch; |
| 404 pCurChar->m_dwCharProps = 0; | 403 pCurChar->m_dwCharProps = 0; |
| 405 pCurChar->m_dwCharStyles = 0; | 404 pCurChar->m_dwCharStyles = 0; |
| 406 pCurChar->m_dwLayoutStyles = m_dwLayoutStyles; | 405 pCurChar->m_dwLayoutStyles = m_dwLayoutStyles; |
| 407 pCurChar->m_iFontSize = m_iFontSize; | 406 pCurChar->m_iFontSize = m_iFontSize; |
| 408 pCurChar->m_iFontHeight = m_iFontHeight; | 407 pCurChar->m_iFontHeight = m_iFontHeight; |
| 409 pCurChar->m_iHorizontalScale = m_iHorizontalScale; | 408 pCurChar->m_iHorizontalScale = m_iHorizontalScale; |
| 410 pCurChar->m_iVertialScale = m_iVerticalScale; | 409 pCurChar->m_iVertialScale = m_iVerticalScale; |
| 411 pCurChar->m_nRotation = m_iCharRotation; | 410 pCurChar->m_nRotation = m_iCharRotation; |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 689 bDone = true; | 688 bDone = true; |
| 690 } | 689 } |
| 691 break; | 690 break; |
| 692 default: | 691 default: |
| 693 SplitTextLine(m_pCurLine, pNextLine, !m_bPagination && bAllChars); | 692 SplitTextLine(m_pCurLine, pNextLine, !m_bPagination && bAllChars); |
| 694 bDone = true; | 693 bDone = true; |
| 695 break; | 694 break; |
| 696 } | 695 } |
| 697 } | 696 } |
| 698 if (m_bPagination || m_pCurLine->m_iMBCSChars > 0) { | 697 if (m_bPagination || m_pCurLine->m_iMBCSChars > 0) { |
| 699 const CFX_RTFChar* pCurChars = m_pCurLine->m_LineChars.GetData(); | 698 const CFX_RTFChar* pCurChars = m_pCurLine->m_LineChars.data(); |
| 700 const CFX_RTFChar* pTC; | 699 const CFX_RTFChar* pTC; |
| 701 CFX_RTFPieceArray* pCurPieces = &m_pCurLine->m_LinePieces; | 700 CFX_RTFPieceArray* pCurPieces = &m_pCurLine->m_LinePieces; |
| 702 CFX_RTFPiece tp; | 701 CFX_RTFPiece tp; |
| 703 tp.m_pChars = &m_pCurLine->m_LineChars; | 702 tp.m_pChars = &m_pCurLine->m_LineChars; |
| 704 bool bNew = true; | 703 bool bNew = true; |
| 705 uint32_t dwIdentity = (uint32_t)-1; | 704 uint32_t dwIdentity = (uint32_t)-1; |
| 706 int32_t iLast = m_pCurLine->CountChars() - 1, j = 0; | 705 int32_t iLast = m_pCurLine->CountChars() - 1, j = 0; |
| 707 for (int32_t i = 0; i <= iLast;) { | 706 for (int32_t i = 0; i <= iLast;) { |
| 708 pTC = pCurChars + i; | 707 pTC = pCurChars + i; |
| 709 if (bNew) { | 708 if (bNew) { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 744 int32_t iEndPos = m_pCurLine->GetLineEnd(); | 743 int32_t iEndPos = m_pCurLine->GetLineEnd(); |
| 745 GetBreakPos(m_pCurLine->m_LineChars, iEndPos, bAllChars, true); | 744 GetBreakPos(m_pCurLine->m_LineChars, iEndPos, bAllChars, true); |
| 746 } | 745 } |
| 747 return false; | 746 return false; |
| 748 } | 747 } |
| 749 void CFX_RTFBreak::EndBreak_BidiLine(CFX_TPOArray& tpos, uint32_t dwStatus) { | 748 void CFX_RTFBreak::EndBreak_BidiLine(CFX_TPOArray& tpos, uint32_t dwStatus) { |
| 750 FX_TPO tpo; | 749 FX_TPO tpo; |
| 751 CFX_RTFPiece tp; | 750 CFX_RTFPiece tp; |
| 752 CFX_RTFChar* pTC; | 751 CFX_RTFChar* pTC; |
| 753 int32_t i, j; | 752 int32_t i, j; |
| 754 CFX_RTFCharArray& chars = m_pCurLine->m_LineChars; | 753 std::vector<CFX_RTFChar>& chars = m_pCurLine->m_LineChars; |
| 755 int32_t iCount = m_pCurLine->CountChars(); | 754 int32_t iCount = m_pCurLine->CountChars(); |
| 756 bool bDone = (!m_bPagination && !m_bCharCode && | 755 bool bDone = (!m_bPagination && !m_bCharCode && |
| 757 (m_pCurLine->m_iArabicChars > 0 || m_bRTL)); | 756 (m_pCurLine->m_iArabicChars > 0 || m_bRTL)); |
| 758 if (bDone) { | 757 if (bDone) { |
| 759 int32_t iBidiNum = 0; | 758 int32_t iBidiNum = 0; |
| 760 for (i = 0; i < iCount; i++) { | 759 for (i = 0; i < iCount; i++) { |
| 761 pTC = chars.GetDataPtr(i); | 760 pTC = &chars[i]; |
| 762 pTC->m_iBidiPos = i; | 761 pTC->m_iBidiPos = i; |
| 763 if (pTC->GetCharType() != FX_CHARTYPE_Control) { | 762 if (pTC->GetCharType() != FX_CHARTYPE_Control) { |
| 764 iBidiNum = i; | 763 iBidiNum = i; |
| 765 } | 764 } |
| 766 if (i == 0) { | 765 if (i == 0) { |
| 767 pTC->m_iBidiLevel = 1; | 766 pTC->m_iBidiLevel = 1; |
| 768 } | 767 } |
| 769 } | 768 } |
| 770 FX_BidiLine(chars, iBidiNum + 1, m_bRTL ? 1 : 0); | 769 FX_BidiLine(chars, iBidiNum + 1, m_bRTL ? 1 : 0); |
| 771 } else { | 770 } else { |
| 772 for (i = 0; i < iCount; i++) { | 771 for (i = 0; i < iCount; i++) { |
| 773 pTC = chars.GetDataPtr(i); | 772 pTC = &chars[i]; |
| 774 pTC->m_iBidiLevel = 0; | 773 pTC->m_iBidiLevel = 0; |
| 775 pTC->m_iBidiPos = 0; | 774 pTC->m_iBidiPos = 0; |
| 776 pTC->m_iBidiOrder = 0; | 775 pTC->m_iBidiOrder = 0; |
| 777 } | 776 } |
| 778 } | 777 } |
| 779 tp.m_dwStatus = FX_RTFBREAK_PieceBreak; | 778 tp.m_dwStatus = FX_RTFBREAK_PieceBreak; |
| 780 tp.m_iStartPos = m_pCurLine->m_iStart; | 779 tp.m_iStartPos = m_pCurLine->m_iStart; |
| 781 tp.m_pChars = &chars; | 780 tp.m_pChars = &chars; |
| 782 CFX_RTFPieceArray* pCurPieces = &m_pCurLine->m_LinePieces; | 781 CFX_RTFPieceArray* pCurPieces = &m_pCurLine->m_LinePieces; |
| 783 int32_t iBidiLevel = -1, iCharWidth; | 782 int32_t iBidiLevel = -1, iCharWidth; |
| 784 uint32_t dwIdentity = (uint32_t)-1; | 783 uint32_t dwIdentity = (uint32_t)-1; |
| 785 i = j = 0; | 784 i = j = 0; |
| 786 while (i < iCount) { | 785 while (i < iCount) { |
| 787 pTC = chars.GetDataPtr(i); | 786 pTC = &chars[i]; |
| 788 if (iBidiLevel < 0) { | 787 if (iBidiLevel < 0) { |
| 789 iBidiLevel = pTC->m_iBidiLevel; | 788 iBidiLevel = pTC->m_iBidiLevel; |
| 790 iCharWidth = pTC->m_iCharWidth; | 789 iCharWidth = pTC->m_iCharWidth; |
| 791 if (iCharWidth < 1) { | 790 if (iCharWidth < 1) { |
| 792 tp.m_iWidth = 0; | 791 tp.m_iWidth = 0; |
| 793 } else { | 792 } else { |
| 794 tp.m_iWidth = iCharWidth; | 793 tp.m_iWidth = iCharWidth; |
| 795 } | 794 } |
| 796 tp.m_iBidiLevel = iBidiLevel; | 795 tp.m_iBidiLevel = iBidiLevel; |
| 797 tp.m_iBidiPos = pTC->m_iBidiOrder; | 796 tp.m_iBidiPos = pTC->m_iBidiOrder; |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 926 } | 925 } |
| 927 if (iOffset > 0) { | 926 if (iOffset > 0) { |
| 928 for (i = 0; i < iCount; i++) { | 927 for (i = 0; i < iCount; i++) { |
| 929 CFX_RTFPiece& ttp = pCurPieces->GetAt(i); | 928 CFX_RTFPiece& ttp = pCurPieces->GetAt(i); |
| 930 ttp.m_iStartPos += iOffset; | 929 ttp.m_iStartPos += iOffset; |
| 931 } | 930 } |
| 932 } | 931 } |
| 933 } | 932 } |
| 934 } | 933 } |
| 935 | 934 |
| 936 int32_t CFX_RTFBreak::GetBreakPos(CFX_RTFCharArray& tca, | 935 int32_t CFX_RTFBreak::GetBreakPos(std::vector<CFX_RTFChar>& tca, |
| 937 int32_t& iEndPos, | 936 int32_t& iEndPos, |
| 938 bool bAllChars, | 937 bool bAllChars, |
| 939 bool bOnlyBrk) { | 938 bool bOnlyBrk) { |
| 940 int32_t iLength = tca.GetSize() - 1; | 939 int32_t iLength = pdfium::CollectionSize<int32_t>(tca) - 1; |
| 941 if (iLength < 1) | 940 if (iLength < 1) |
| 942 return iLength; | 941 return iLength; |
| 943 | 942 |
| 944 int32_t iBreak = -1, iBreakPos = -1, iIndirect = -1, iIndirectPos = -1, | 943 int32_t iBreak = -1, iBreakPos = -1, iIndirect = -1, iIndirectPos = -1, |
| 945 iLast = -1, iLastPos = -1; | 944 iLast = -1, iLastPos = -1; |
| 946 if (m_bSingleLine || m_bOrphanLine || iEndPos <= m_iBoundaryEnd) { | 945 if (m_bSingleLine || m_bOrphanLine || iEndPos <= m_iBoundaryEnd) { |
| 947 if (!bAllChars || m_bCharCode) | 946 if (!bAllChars || m_bCharCode) |
| 948 return iLength; | 947 return iLength; |
| 949 | 948 |
| 950 iBreak = iLength; | 949 iBreak = iLength; |
| 951 iBreakPos = iEndPos; | 950 iBreakPos = iEndPos; |
| 952 } | 951 } |
| 953 CFX_RTFChar* pCharArray = tca.GetData(); | 952 CFX_RTFChar* pCharArray = tca.data(); |
| 954 if (m_bCharCode) { | 953 if (m_bCharCode) { |
| 955 const CFX_RTFChar* pChar; | 954 const CFX_RTFChar* pChar; |
| 956 int32_t iCharWidth; | 955 int32_t iCharWidth; |
| 957 while (iLength > 0) { | 956 while (iLength > 0) { |
| 958 if (iEndPos <= m_iBoundaryEnd) | 957 if (iEndPos <= m_iBoundaryEnd) |
| 959 break; | 958 break; |
| 960 | 959 |
| 961 pChar = pCharArray + iLength--; | 960 pChar = pCharArray + iLength--; |
| 962 iCharWidth = pChar->m_iCharWidth; | 961 iCharWidth = pChar->m_iCharWidth; |
| 963 if (iCharWidth > 0) | 962 if (iCharWidth > 0) |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1064 | 1063 |
| 1065 void CFX_RTFBreak::SplitTextLine(CFX_RTFLine* pCurLine, | 1064 void CFX_RTFBreak::SplitTextLine(CFX_RTFLine* pCurLine, |
| 1066 CFX_RTFLine* pNextLine, | 1065 CFX_RTFLine* pNextLine, |
| 1067 bool bAllChars) { | 1066 bool bAllChars) { |
| 1068 ASSERT(pCurLine && pNextLine); | 1067 ASSERT(pCurLine && pNextLine); |
| 1069 int32_t iCount = pCurLine->CountChars(); | 1068 int32_t iCount = pCurLine->CountChars(); |
| 1070 if (iCount < 2) { | 1069 if (iCount < 2) { |
| 1071 return; | 1070 return; |
| 1072 } | 1071 } |
| 1073 int32_t iEndPos = pCurLine->GetLineEnd(); | 1072 int32_t iEndPos = pCurLine->GetLineEnd(); |
| 1074 CFX_RTFCharArray& curChars = pCurLine->m_LineChars; | 1073 std::vector<CFX_RTFChar>& curChars = pCurLine->m_LineChars; |
| 1075 int32_t iCharPos = GetBreakPos(curChars, iEndPos, bAllChars, false); | 1074 int32_t iCharPos = GetBreakPos(curChars, iEndPos, bAllChars, false); |
| 1076 if (iCharPos < 0) { | 1075 if (iCharPos < 0) { |
| 1077 iCharPos = 0; | 1076 iCharPos = 0; |
| 1078 } | 1077 } |
| 1079 iCharPos++; | 1078 iCharPos++; |
| 1080 if (iCharPos >= iCount) { | 1079 if (iCharPos >= iCount) { |
| 1081 pNextLine->RemoveAll(true); | 1080 pNextLine->RemoveAll(true); |
| 1082 CFX_Char* pTC = curChars.GetDataPtr(iCharPos - 1); | 1081 CFX_Char* pTC = &curChars[iCharPos - 1]; |
| 1083 pTC->m_nBreakType = FX_LBT_UNKNOWN; | 1082 pTC->m_nBreakType = FX_LBT_UNKNOWN; |
| 1084 return; | 1083 return; |
| 1085 } | 1084 } |
| 1086 CFX_RTFCharArray& nextChars = pNextLine->m_LineChars; | 1085 std::vector<CFX_RTFChar>& nextChars = pNextLine->m_LineChars; |
| 1087 int cur_size = curChars.GetSize(); | 1086 nextChars = |
| 1088 nextChars.SetSize(cur_size - iCharPos); | 1087 std::vector<CFX_RTFChar>(curChars.begin() + iCharPos, curChars.end()); |
| 1089 FXSYS_memcpy(nextChars.GetData(), curChars.GetDataPtr(iCharPos), | 1088 curChars.erase(curChars.begin() + iCharPos, curChars.end()); |
| 1090 (cur_size - iCharPos) * sizeof(CFX_RTFChar)); | |
| 1091 iCount -= iCharPos; | |
| 1092 cur_size = curChars.GetSize(); | |
| 1093 curChars.RemoveAt(cur_size - iCount, iCount); | |
| 1094 pNextLine->m_iStart = pCurLine->m_iStart; | 1089 pNextLine->m_iStart = pCurLine->m_iStart; |
| 1095 pNextLine->m_iWidth = pCurLine->GetLineEnd() - iEndPos; | 1090 pNextLine->m_iWidth = pCurLine->GetLineEnd() - iEndPos; |
| 1096 pCurLine->m_iWidth = iEndPos; | 1091 pCurLine->m_iWidth = iEndPos; |
| 1097 curChars.GetDataPtr(iCharPos - 1)->m_nBreakType = FX_LBT_UNKNOWN; | 1092 curChars[iCharPos - 1].m_nBreakType = FX_LBT_UNKNOWN; |
| 1098 iCount = nextChars.GetSize(); | 1093 iCount = pdfium::CollectionSize<int>(nextChars); |
| 1099 CFX_RTFChar* pNextChars = nextChars.GetData(); | 1094 CFX_RTFChar* pNextChars = nextChars.data(); |
| 1100 for (int32_t i = 0; i < iCount; i++) { | 1095 for (int32_t i = 0; i < iCount; i++) { |
| 1101 CFX_RTFChar* tc = pNextChars + i; | 1096 CFX_RTFChar* tc = pNextChars + i; |
| 1102 if (tc->GetCharType() >= FX_CHARTYPE_ArabicAlef) { | 1097 if (tc->GetCharType() >= FX_CHARTYPE_ArabicAlef) { |
| 1103 pCurLine->m_iArabicChars--; | 1098 pCurLine->m_iArabicChars--; |
| 1104 pNextLine->m_iArabicChars++; | 1099 pNextLine->m_iArabicChars++; |
| 1105 } | 1100 } |
| 1106 if (tc->m_dwLayoutStyles & FX_RTFLAYOUTSTYLE_MBCSCode) { | 1101 if (tc->m_dwLayoutStyles & FX_RTFLAYOUTSTYLE_MBCSCode) { |
| 1107 pCurLine->m_iMBCSChars--; | 1102 pCurLine->m_iMBCSChars--; |
| 1108 pNextLine->m_iMBCSChars++; | 1103 pNextLine->m_iMBCSChars++; |
| 1109 } | 1104 } |
| (...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1559 fFontSize(12.0f), | 1554 fFontSize(12.0f), |
| 1560 dwLayoutStyles(0), | 1555 dwLayoutStyles(0), |
| 1561 iCharRotation(0), | 1556 iCharRotation(0), |
| 1562 iBidiLevel(0), | 1557 iBidiLevel(0), |
| 1563 pRect(nullptr), | 1558 pRect(nullptr), |
| 1564 wLineBreakChar(L'\n'), | 1559 wLineBreakChar(L'\n'), |
| 1565 iHorizontalScale(100), | 1560 iHorizontalScale(100), |
| 1566 iVerticalScale(100) {} | 1561 iVerticalScale(100) {} |
| 1567 | 1562 |
| 1568 FX_RTFTEXTOBJ::~FX_RTFTEXTOBJ() {} | 1563 FX_RTFTEXTOBJ::~FX_RTFTEXTOBJ() {} |
| OLD | NEW |