diff options
Diffstat (limited to 'xfa/fgas')
-rw-r--r-- | xfa/fgas/layout/cfx_break.cpp | 5 | ||||
-rw-r--r-- | xfa/fgas/layout/cfx_breakline.cpp | 4 | ||||
-rw-r--r-- | xfa/fgas/layout/cfx_breakline.h | 1 | ||||
-rw-r--r-- | xfa/fgas/layout/cfx_rtfbreak.cpp | 29 | ||||
-rw-r--r-- | xfa/fgas/layout/cfx_txtbreak.cpp | 30 |
5 files changed, 26 insertions, 43 deletions
diff --git a/xfa/fgas/layout/cfx_break.cpp b/xfa/fgas/layout/cfx_break.cpp index b9996b3141..889c043ec2 100644 --- a/xfa/fgas/layout/cfx_break.cpp +++ b/xfa/fgas/layout/cfx_break.cpp @@ -95,11 +95,10 @@ void CFX_Break::SetFontSize(float fFontSize) { void CFX_Break::SetBreakStatus() { ++m_dwIdentity; - int32_t iCount = m_pCurLine->CountChars(); - if (iCount < 1) + if (m_pCurLine->m_LineChars.empty()) return; - CFX_Char* tc = m_pCurLine->GetChar(iCount - 1); + CFX_Char* tc = m_pCurLine->GetChar(m_pCurLine->m_LineChars.size() - 1); if (tc->m_dwStatus == CFX_BreakType::None) tc->m_dwStatus = CFX_BreakType::Piece; } diff --git a/xfa/fgas/layout/cfx_breakline.cpp b/xfa/fgas/layout/cfx_breakline.cpp index 0788603ad0..90bf7a08da 100644 --- a/xfa/fgas/layout/cfx_breakline.cpp +++ b/xfa/fgas/layout/cfx_breakline.cpp @@ -12,10 +12,6 @@ CFX_BreakLine::CFX_BreakLine() : m_iStart(0), m_iWidth(0), m_iArabicChars(0) {} CFX_BreakLine::~CFX_BreakLine() {} -int32_t CFX_BreakLine::CountChars() const { - return pdfium::CollectionSize<int32_t>(m_LineChars); -} - CFX_Char* CFX_BreakLine::GetChar(int32_t index) { ASSERT(pdfium::IndexInBounds(m_LineChars, index)); return &m_LineChars[index]; diff --git a/xfa/fgas/layout/cfx_breakline.h b/xfa/fgas/layout/cfx_breakline.h index 0b83ee6baa..267f276eeb 100644 --- a/xfa/fgas/layout/cfx_breakline.h +++ b/xfa/fgas/layout/cfx_breakline.h @@ -17,7 +17,6 @@ class CFX_BreakLine { CFX_BreakLine(); ~CFX_BreakLine(); - int32_t CountChars() const; CFX_Char* GetChar(int32_t index); const CFX_Char* GetChar(int32_t index) const; diff --git a/xfa/fgas/layout/cfx_rtfbreak.cpp b/xfa/fgas/layout/cfx_rtfbreak.cpp index 576d2d4533..0eb7d63a3a 100644 --- a/xfa/fgas/layout/cfx_rtfbreak.cpp +++ b/xfa/fgas/layout/cfx_rtfbreak.cpp @@ -83,9 +83,8 @@ CFX_BreakType CFX_RTFBreak::AppendChar(wchar_t wch) { m_pCurLine->GetLineEnd() > m_iLineWidth + m_iTolerance && (m_eCharType != FX_CHARTYPE_Space || chartype != FX_CHARTYPE_Control)) { dwRet1 = EndBreak(CFX_BreakType::Line); - int32_t iCount = m_pCurLine->CountChars(); - if (iCount > 0) - pCurChar = &m_pCurLine->m_LineChars[iCount - 1]; + if (!m_pCurLine->m_LineChars.empty()) + pCurChar = &m_pCurLine->m_LineChars.back(); } CFX_BreakType dwRet2 = CFX_BreakType::None; @@ -282,11 +281,10 @@ CFX_BreakType CFX_RTFBreak::EndBreak(CFX_BreakType dwStatus) { return CFX_BreakType::None; } - int32_t iCount = m_pCurLine->CountChars(); - if (iCount < 1) + if (m_pCurLine->m_LineChars.empty()) return CFX_BreakType::None; - CFX_Char* tc = m_pCurLine->GetChar(iCount - 1); + CFX_Char* tc = m_pCurLine->GetChar(m_pCurLine->m_LineChars.size() - 1); tc->m_dwStatus = dwStatus; if (dwStatus == CFX_BreakType::Piece) return dwStatus; @@ -315,7 +313,8 @@ bool CFX_RTFBreak::EndBreak_SplitLine(CFX_BreakLine* pNextLine, CFX_BreakType dwStatus) { bool bDone = false; if (m_pCurLine->GetLineEnd() > m_iLineWidth + m_iTolerance) { - const CFX_Char* tc = m_pCurLine->GetChar(m_pCurLine->CountChars() - 1); + const CFX_Char* tc = + m_pCurLine->GetChar(m_pCurLine->m_LineChars.size() - 1); switch (tc->GetCharType()) { case FX_CHARTYPE_Tab: case FX_CHARTYPE_Control: @@ -341,7 +340,7 @@ bool CFX_RTFBreak::EndBreak_SplitLine(CFX_BreakLine* pNextLine, tp.m_pChars = &m_pCurLine->m_LineChars; bool bNew = true; uint32_t dwIdentity = static_cast<uint32_t>(-1); - int32_t iLast = m_pCurLine->CountChars() - 1; + int32_t iLast = pdfium::CollectionSize<int32_t>(m_pCurLine->m_LineChars) - 1; int32_t j = 0; for (int32_t i = 0; i <= iLast;) { const CFX_Char* pTC = pCurChars + i; @@ -383,12 +382,9 @@ void CFX_RTFBreak::EndBreak_BidiLine(std::deque<FX_TPO>* tpos, CFX_BreakType dwStatus) { CFX_Char* pTC; std::vector<CFX_Char>& chars = m_pCurLine->m_LineChars; - int32_t iCount = m_pCurLine->CountChars(); if (!m_bPagination && m_pCurLine->m_iArabicChars > 0) { - ASSERT(iCount >= 0); - size_t iBidiNum = 0; - for (size_t i = 0; i < static_cast<size_t>(iCount); ++i) { + for (size_t i = 0; i < m_pCurLine->m_LineChars.size(); ++i) { pTC = &chars[i]; pTC->m_iBidiPos = static_cast<int32_t>(i); if (pTC->GetCharType() != FX_CHARTYPE_Control) @@ -398,7 +394,7 @@ void CFX_RTFBreak::EndBreak_BidiLine(std::deque<FX_TPO>* tpos, } FX_BidiLine(&chars, iBidiNum + 1); } else { - for (int32_t i = 0; i < iCount; ++i) { + for (size_t i = 0; i < m_pCurLine->m_LineChars.size(); ++i) { pTC = &chars[i]; pTC->m_iBidiLevel = 0; pTC->m_iBidiPos = 0; @@ -417,6 +413,7 @@ void CFX_RTFBreak::EndBreak_BidiLine(std::deque<FX_TPO>* tpos, uint32_t dwIdentity = static_cast<uint32_t>(-1); int32_t i = 0; int32_t j = 0; + int32_t iCount = pdfium::CollectionSize<int32_t>(m_pCurLine->m_LineChars); while (i < iCount) { pTC = &chars[i]; if (iBidiLevel < 0) { @@ -649,8 +646,8 @@ void CFX_RTFBreak::SplitTextLine(CFX_BreakLine* pCurLine, CFX_BreakLine* pNextLine, bool bAllChars) { ASSERT(pCurLine && pNextLine); - int32_t iCount = pCurLine->CountChars(); - if (iCount < 2) + + if (pCurLine->m_LineChars.size() < 2) return; int32_t iEndPos = pCurLine->GetLineEnd(); @@ -660,7 +657,7 @@ void CFX_RTFBreak::SplitTextLine(CFX_BreakLine* pCurLine, iCharPos = 0; ++iCharPos; - if (iCharPos >= iCount) { + if (iCharPos >= pdfium::CollectionSize<int32_t>(pCurLine->m_LineChars)) { pNextLine->Clear(); curChars[iCharPos - 1].m_nBreakType = FX_LBT_UNKNOWN; return; diff --git a/xfa/fgas/layout/cfx_txtbreak.cpp b/xfa/fgas/layout/cfx_txtbreak.cpp index 526fd64c96..76a36c90da 100644 --- a/xfa/fgas/layout/cfx_txtbreak.cpp +++ b/xfa/fgas/layout/cfx_txtbreak.cpp @@ -239,9 +239,8 @@ CFX_BreakType CFX_TxtBreak::AppendChar(wchar_t wch) { m_pCurLine->m_iWidth > m_iLineWidth + m_iTolerance && !m_bSingleLine && (m_eCharType != FX_CHARTYPE_Space || chartype != FX_CHARTYPE_Control)) { dwRet1 = EndBreak(CFX_BreakType::Line); - int32_t iCount = m_pCurLine->CountChars(); - if (iCount > 0) - pCurChar = &m_pCurLine->m_LineChars[iCount - 1]; + if (!m_pCurLine->m_LineChars.empty()) + pCurChar = &m_pCurLine->m_LineChars.back(); } CFX_BreakType dwRet2 = CFX_BreakType::None; @@ -284,11 +283,10 @@ CFX_BreakType CFX_TxtBreak::AppendChar(wchar_t wch) { bool CFX_TxtBreak::EndBreak_SplitLine(CFX_BreakLine* pNextLine, bool bAllChars) { - int32_t iCount = m_pCurLine->CountChars(); bool bDone = false; CFX_Char* pTC; if (!m_bSingleLine && m_pCurLine->m_iWidth > m_iLineWidth + m_iTolerance) { - pTC = m_pCurLine->GetChar(iCount - 1); + pTC = m_pCurLine->GetChar(m_pCurLine->m_LineChars.size() - 1); switch (pTC->GetCharType()) { case FX_CHARTYPE_Tab: case FX_CHARTYPE_Control: @@ -301,7 +299,6 @@ bool CFX_TxtBreak::EndBreak_SplitLine(CFX_BreakLine* pNextLine, } } - iCount = m_pCurLine->CountChars(); CFX_BreakPiece tp; if (bAllChars && !bDone) { int32_t iEndPos = m_pCurLine->m_iWidth; @@ -316,13 +313,10 @@ void CFX_TxtBreak::EndBreak_BidiLine(std::deque<FX_TPO>* tpos, FX_TPO tpo; CFX_Char* pTC; std::vector<CFX_Char>& chars = m_pCurLine->m_LineChars; - int32_t iCount = m_pCurLine->CountChars(); bool bDone = m_pCurLine->m_iArabicChars > 0; if (bDone) { - ASSERT(iCount >= 0); - size_t iBidiNum = 0; - for (size_t i = 0; i < static_cast<size_t>(iCount); ++i) { + for (size_t i = 0; i < m_pCurLine->m_LineChars.size(); ++i) { pTC = &chars[i]; pTC->m_iBidiPos = static_cast<int32_t>(i); if (pTC->GetCharType() != FX_CHARTYPE_Control) @@ -341,6 +335,7 @@ void CFX_TxtBreak::EndBreak_BidiLine(std::deque<FX_TPO>* tpos, int32_t iCharWidth; int32_t i = 0; int32_t j = -1; + int32_t iCount = pdfium::CollectionSize<int32_t>(m_pCurLine->m_LineChars); while (i < iCount) { pTC = &chars[i]; if (iBidiLevel < 0) { @@ -405,7 +400,7 @@ void CFX_TxtBreak::EndBreak_BidiLine(std::deque<FX_TPO>* tpos, tp.m_iStartPos = m_pCurLine->m_iStart; tp.m_iWidth = m_pCurLine->m_iWidth; tp.m_iStartChar = 0; - tp.m_iChars = iCount; + tp.m_iChars = m_pCurLine->m_LineChars.size(); tp.m_pChars = &m_pCurLine->m_LineChars; pTC = &chars[0]; tp.m_dwCharStyles = pTC->m_dwCharStyles; @@ -507,11 +502,10 @@ CFX_BreakType CFX_TxtBreak::EndBreak(CFX_BreakType dwStatus) { return CFX_BreakType::None; } - int32_t iCount = m_pCurLine->CountChars(); - if (iCount < 1) + if (m_pCurLine->m_LineChars.empty()) return CFX_BreakType::None; - m_pCurLine->GetChar(iCount - 1)->m_dwStatus = dwStatus; + m_pCurLine->m_LineChars.back().m_dwStatus = dwStatus; if (dwStatus == CFX_BreakType::Piece) return dwStatus; @@ -623,8 +617,7 @@ void CFX_TxtBreak::SplitTextLine(CFX_BreakLine* pCurLine, CFX_BreakLine* pNextLine, bool bAllChars) { ASSERT(pCurLine && pNextLine); - int32_t iCount = pCurLine->CountChars(); - if (iCount < 2) + if (pCurLine->m_LineChars.size() < 2) return; int32_t iEndPos = pCurLine->m_iWidth; @@ -634,7 +627,7 @@ void CFX_TxtBreak::SplitTextLine(CFX_BreakLine* pCurLine, iCharPos = 0; iCharPos++; - if (iCharPos >= iCount) { + if (iCharPos >= pdfium::CollectionSize<int32_t>(pCurLine->m_LineChars)) { pNextLine->Clear(); CFX_Char* pTC = &curChars[iCharPos - 1]; pTC->m_nBreakType = FX_LBT_UNKNOWN; @@ -647,9 +640,8 @@ void CFX_TxtBreak::SplitTextLine(CFX_BreakLine* pCurLine, pCurLine->m_iWidth = iEndPos; CFX_Char* pTC = &curChars[iCharPos - 1]; pTC->m_nBreakType = FX_LBT_UNKNOWN; - iCount = pdfium::CollectionSize<int>(pNextLine->m_LineChars); int32_t iWidth = 0; - for (int32_t i = 0; i < iCount; i++) { + for (size_t i = 0; i < pNextLine->m_LineChars.size(); ++i) { if (pNextLine->m_LineChars[i].GetCharType() >= FX_CHARTYPE_ArabicAlef) { pCurLine->m_iArabicChars--; pNextLine->m_iArabicChars++; |