Chromium Code Reviews| Index: core/src/fpdftext/fpdf_text_int.cpp |
| diff --git a/core/src/fpdftext/fpdf_text_int.cpp b/core/src/fpdftext/fpdf_text_int.cpp |
| index 3b633a623f6361fdf52c630513489e23e38ff43d..6f733011ef3d0c40a21d49129320e04e05134ce8 100644 |
| --- a/core/src/fpdftext/fpdf_text_int.cpp |
| +++ b/core/src/fpdftext/fpdf_text_int.cpp |
| @@ -111,8 +111,6 @@ IPDF_LinkExtract* IPDF_LinkExtract::CreateLinkExtract() { |
| CPDF_TextPage::CPDF_TextPage(const CPDF_Page* pPage, int flags) |
| : m_pPage(pPage), |
| - m_charList(512), |
| - m_TempCharList(50), |
| m_parserflag(flags), |
| m_pPreTextObj(nullptr), |
| m_bIsParsed(false), |
| @@ -147,20 +145,20 @@ FX_BOOL CPDF_TextPage::ParseTextPage() { |
| return FALSE; |
| m_TextBuf.Clear(); |
| - m_charList.RemoveAll(); |
| + m_CharList.clear(); |
| m_pPreTextObj = NULL; |
| ProcessObject(); |
| m_bIsParsed = true; |
| if (!m_ParseOptions.m_bGetCharCodeOnly) { |
| m_CharIndex.RemoveAll(); |
| - int nCount = m_charList.GetSize(); |
| + int nCount = m_CharList.size(); |
| if (nCount) { |
| m_CharIndex.Add(0); |
| } |
| for (int i = 0; i < nCount; i++) { |
| int indexSize = m_CharIndex.GetSize(); |
| FX_BOOL bNormal = FALSE; |
| - PAGECHAR_INFO charinfo = *(PAGECHAR_INFO*)m_charList.GetAt(i); |
| + PAGECHAR_INFO charinfo = m_CharList[i]; |
| if (charinfo.m_Flag == FPDFTEXT_CHAR_GENERATED) { |
| bNormal = TRUE; |
| } else if (charinfo.m_Unicode == 0 || IsControlChar(charinfo)) { |
| @@ -200,7 +198,7 @@ int CPDF_TextPage::CountChars() const { |
| if (m_ParseOptions.m_bGetCharCodeOnly) { |
| return m_TextBuf.GetSize(); |
| } |
| - return m_charList.GetSize(); |
| + return m_CharList.size(); |
| } |
| int CPDF_TextPage::CharIndexFromTextIndex(int TextIndex) const { |
| int indexSize = m_CharIndex.GetSize(); |
| @@ -241,16 +239,15 @@ void CPDF_TextPage::GetRectArray(int start, |
| if (!m_bIsParsed) { |
| return; |
| } |
| - PAGECHAR_INFO info_curchar; |
| CPDF_TextObject* pCurObj = NULL; |
| CFX_FloatRect rect; |
| int curPos = start; |
| FX_BOOL flagNewRect = TRUE; |
| - if (nCount + start > m_charList.GetSize() || nCount == -1) { |
| - nCount = m_charList.GetSize() - start; |
| + if (nCount + start > m_CharList.size() || nCount == -1) { |
| + nCount = m_CharList.size() - start; |
| } |
| while (nCount--) { |
| - info_curchar = *(PAGECHAR_INFO*)m_charList.GetAt(curPos++); |
| + PAGECHAR_INFO info_curchar = m_CharList[curPos++]; |
| if (info_curchar.m_Flag == FPDFTEXT_CHAR_GENERATED) { |
| continue; |
| } |
| @@ -327,8 +324,8 @@ int CPDF_TextPage::GetIndexAtPos(CPDF_Point point, |
| int pos = 0; |
| int NearPos = -1; |
| double xdif = 5000, ydif = 5000; |
| - while (pos < m_charList.GetSize()) { |
| - PAGECHAR_INFO charinfo = *(PAGECHAR_INFO*)(m_charList.GetAt(pos)); |
| + while (pos < m_CharList.size()) { |
| + PAGECHAR_INFO charinfo = m_CharList[pos]; |
| CFX_FloatRect charrect = charinfo.m_CharBox; |
| if (charrect.Contains(point.x, point.y)) { |
| break; |
| @@ -359,7 +356,7 @@ int CPDF_TextPage::GetIndexAtPos(CPDF_Point point, |
| } |
| ++pos; |
| } |
| - if (pos >= m_charList.GetSize()) { |
| + if (pos >= m_CharList.size()) { |
| pos = NearPos; |
| } |
| return pos; |
| @@ -369,13 +366,13 @@ CFX_WideString CPDF_TextPage::GetTextByRect(const CFX_FloatRect& rect) const { |
| if (m_ParseOptions.m_bGetCharCodeOnly || !m_bIsParsed) |
| return strText; |
| - int nCount = m_charList.GetSize(); |
| + int nCount = m_CharList.size(); |
|
Oliver Chang
2016/01/22 20:17:56
could we change this to a size_t?
|
| int pos = 0; |
| FX_FLOAT posy = 0; |
| FX_BOOL IsContainPreChar = FALSE; |
| FX_BOOL ISAddLineFeed = FALSE; |
| while (pos < nCount) { |
| - PAGECHAR_INFO charinfo = *(PAGECHAR_INFO*)m_charList.GetAt(pos++); |
| + PAGECHAR_INFO charinfo = m_CharList[pos++]; |
| if (IsRectIntersect(rect, charinfo.m_CharBox)) { |
| if (FXSYS_fabs(posy - charinfo.m_OriginY) > 0 && !IsContainPreChar && |
| ISAddLineFeed) { |
| @@ -410,10 +407,10 @@ void CPDF_TextPage::GetRectsArrayByRect(const CFX_FloatRect& rect, |
| CFX_FloatRect curRect; |
| FX_BOOL flagNewRect = TRUE; |
| CPDF_TextObject* pCurObj = NULL; |
| - int nCount = m_charList.GetSize(); |
| + int nCount = m_CharList.size(); |
|
Oliver Chang
2016/01/22 20:17:56
ditto, many more instances in this file.
|
| int pos = 0; |
| while (pos < nCount) { |
| - PAGECHAR_INFO info_curchar = *(PAGECHAR_INFO*)m_charList.GetAt(pos++); |
| + PAGECHAR_INFO info_curchar = m_CharList[pos++]; |
| if (info_curchar.m_Flag == FPDFTEXT_CHAR_GENERATED) { |
| continue; |
| } |
| @@ -465,11 +462,10 @@ void CPDF_TextPage::GetCharInfo(int index, FPDF_CHAR_INFO* info) const { |
| if (m_ParseOptions.m_bGetCharCodeOnly || !m_bIsParsed) |
| return; |
| - if (index < 0 || index >= m_charList.GetSize()) |
| + if (index < 0 || index >= m_CharList.size()) |
| return; |
| - const PAGECHAR_INFO* charinfo = |
| - static_cast<PAGECHAR_INFO*>(m_charList.GetAt(index)); |
| + const PAGECHAR_INFO* charinfo = &m_CharList[index]; |
| info->m_Charcode = charinfo->m_CharCode; |
| info->m_OriginX = charinfo->m_OriginX; |
| info->m_OriginY = charinfo->m_OriginY; |
| @@ -487,9 +483,8 @@ void CPDF_TextPage::GetCharInfo(int index, FPDF_CHAR_INFO* info) const { |
| void CPDF_TextPage::CheckMarkedContentObject(int32_t& start, |
| int32_t& nCount) const { |
| - PAGECHAR_INFO charinfo = *(PAGECHAR_INFO*)m_charList.GetAt(start); |
| - PAGECHAR_INFO charinfo2 = |
| - *(PAGECHAR_INFO*)m_charList.GetAt(start + nCount - 1); |
| + PAGECHAR_INFO charinfo = m_CharList[start]; |
| + PAGECHAR_INFO charinfo2 = m_CharList[start + nCount - 1]; |
| if (FPDFTEXT_CHAR_PIECE != charinfo.m_Flag && |
| FPDFTEXT_CHAR_PIECE != charinfo2.m_Flag) { |
| return; |
| @@ -503,7 +498,7 @@ void CPDF_TextPage::CheckMarkedContentObject(int32_t& start, |
| if (startIndex < 0) { |
| break; |
| } |
| - charinfo1 = *(PAGECHAR_INFO*)m_charList.GetAt(startIndex); |
| + charinfo1 = m_CharList[startIndex]; |
| } |
| startIndex++; |
| start = startIndex; |
| @@ -514,10 +509,10 @@ void CPDF_TextPage::CheckMarkedContentObject(int32_t& start, |
| while (FPDFTEXT_CHAR_PIECE == charinfo3.m_Flag && |
| charinfo3.m_Index == charinfo2.m_Index) { |
| endIndex++; |
| - if (endIndex >= m_charList.GetSize()) { |
| + if (endIndex >= m_CharList.size()) { |
| break; |
| } |
| - charinfo3 = *(PAGECHAR_INFO*)m_charList.GetAt(endIndex); |
| + charinfo3 = m_CharList[endIndex]; |
| } |
| endIndex--; |
| nCount = endIndex - start + 1; |
| @@ -531,40 +526,39 @@ CFX_WideString CPDF_TextPage::GetPageText(int start, int nCount) const { |
| start = 0; |
| if (nCount == -1) { |
| - nCount = m_charList.GetSize() - start; |
| + nCount = m_CharList.size() - start; |
| return m_TextBuf.GetWideString().Mid(start, |
| m_TextBuf.GetWideString().GetLength()); |
| } |
| - if (nCount <= 0 || m_charList.GetSize() <= 0) { |
| + if (nCount <= 0 || m_CharList.empty()) { |
| return L""; |
| } |
| - if (nCount + start > m_charList.GetSize() - 1) { |
| - nCount = m_charList.GetSize() - start; |
| + if (nCount + start > static_cast<int>(m_CharList.size()) - 1) { |
| + nCount = static_cast<int>(m_CharList.size()) - start; |
| } |
| if (nCount <= 0) { |
| return L""; |
| } |
| CheckMarkedContentObject(start, nCount); |
| int startindex = 0; |
| - PAGECHAR_INFO charinfo = *(PAGECHAR_INFO*)m_charList.GetAt(start); |
| + PAGECHAR_INFO charinfo = m_CharList[start]; |
| int startOffset = 0; |
| while (charinfo.m_Index == -1) { |
| startOffset++; |
| - if (startOffset > nCount || start + startOffset >= m_charList.GetSize()) { |
| + if (startOffset > nCount || start + startOffset >= m_CharList.size()) { |
| return L""; |
| } |
| - charinfo = *(PAGECHAR_INFO*)m_charList.GetAt(start + startOffset); |
| + charinfo = m_CharList[start + startOffset]; |
| } |
| startindex = charinfo.m_Index; |
| - charinfo = *(PAGECHAR_INFO*)m_charList.GetAt(start + nCount - 1); |
| + charinfo = m_CharList[start + nCount - 1]; |
| int nCountOffset = 0; |
| while (charinfo.m_Index == -1) { |
| nCountOffset++; |
| if (nCountOffset >= nCount) { |
| return L""; |
| } |
| - charinfo = |
| - *(PAGECHAR_INFO*)m_charList.GetAt(start + nCount - nCountOffset - 1); |
| + charinfo = m_CharList[start + nCount - nCountOffset - 1]; |
| } |
| nCount = start + nCount - nCountOffset - startindex; |
| if (nCount <= 0) { |
| @@ -576,8 +570,8 @@ int CPDF_TextPage::CountRects(int start, int nCount) { |
| if (m_ParseOptions.m_bGetCharCodeOnly || !m_bIsParsed || start < 0) |
| return -1; |
| - if (nCount == -1 || nCount + start > m_charList.GetSize()) { |
| - nCount = m_charList.GetSize() - start; |
| + if (nCount == -1 || nCount + start > static_cast<int>(m_CharList.size())) { |
| + nCount = static_cast<int>(m_CharList.size()) - start; |
| } |
| m_SelRects.RemoveAll(); |
| GetRectArray(start, nCount, m_SelRects); |
| @@ -678,13 +672,13 @@ int CPDF_TextPage::CountBoundedSegments(FX_FLOAT left, |
| if (m_ParseOptions.m_bGetCharCodeOnly) |
| return -1; |
| - m_Segment.RemoveAll(); |
| + m_Segments.RemoveAll(); |
| if (!m_bIsParsed) |
| return -1; |
| CFX_FloatRect rect(left, bottom, right, top); |
| rect.Normalize(); |
| - int nCount = m_charList.GetSize(); |
| + int nCount = m_CharList.size(); |
| int pos = 0; |
| FPDF_SEGMENT segment; |
| segment.m_Start = 0; |
| @@ -692,7 +686,7 @@ int CPDF_TextPage::CountBoundedSegments(FX_FLOAT left, |
| int segmentStatus = 0; |
| FX_BOOL IsContainPreChar = FALSE; |
| while (pos < nCount) { |
| - PAGECHAR_INFO charinfo = *(PAGECHAR_INFO*)m_charList.GetAt(pos); |
| + PAGECHAR_INFO charinfo = m_CharList[pos]; |
| if (bContains && rect.Contains(charinfo.m_CharBox)) { |
| if (segmentStatus == 0 || segmentStatus == 2) { |
| segment.m_Start = pos; |
| @@ -726,7 +720,7 @@ int CPDF_TextPage::CountBoundedSegments(FX_FLOAT left, |
| } else { |
| if (segmentStatus == 1) { |
| segmentStatus = 2; |
| - m_Segment.Add(segment); |
| + m_Segments.Add(segment); |
| segment.m_Start = 0; |
| segment.m_nCount = 0; |
| } |
| @@ -734,7 +728,7 @@ int CPDF_TextPage::CountBoundedSegments(FX_FLOAT left, |
| } else { |
| if (segmentStatus == 1) { |
| segmentStatus = 2; |
| - m_Segment.Add(segment); |
| + m_Segments.Add(segment); |
| segment.m_Start = 0; |
| segment.m_nCount = 0; |
| } |
| @@ -744,21 +738,21 @@ int CPDF_TextPage::CountBoundedSegments(FX_FLOAT left, |
| } |
| if (segmentStatus == 1) { |
| segmentStatus = 2; |
| - m_Segment.Add(segment); |
| + m_Segments.Add(segment); |
| segment.m_Start = 0; |
| segment.m_nCount = 0; |
| } |
| - return m_Segment.GetSize(); |
| + return m_Segments.GetSize(); |
| } |
| void CPDF_TextPage::GetBoundedSegment(int index, int& start, int& count) const { |
| if (m_ParseOptions.m_bGetCharCodeOnly) { |
| return; |
| } |
| - if (index < 0 || index >= m_Segment.GetSize()) { |
| + if (index < 0 || index >= m_Segments.GetSize()) { |
| return; |
| } |
| - start = m_Segment.GetAt(index).m_Start; |
| - count = m_Segment.GetAt(index).m_nCount; |
| + start = m_Segments.GetAt(index).m_Start; |
| + count = m_Segments.GetAt(index).m_nCount; |
| } |
| int CPDF_TextPage::GetWordBreak(int index, int direction) const { |
| if (m_ParseOptions.m_bGetCharCodeOnly || !m_bIsParsed) |
| @@ -767,11 +761,10 @@ int CPDF_TextPage::GetWordBreak(int index, int direction) const { |
| if (direction != FPDFTEXT_LEFT && direction != FPDFTEXT_RIGHT) |
| return -1; |
| - if (index < 0 || index >= m_charList.GetSize()) |
| + if (index < 0 || index >= m_CharList.size()) |
| return -1; |
| - PAGECHAR_INFO charinfo; |
| - charinfo = *(PAGECHAR_INFO*)m_charList.GetAt(index); |
| + PAGECHAR_INFO charinfo = m_CharList[index]; |
| if (charinfo.m_Index == -1 || charinfo.m_Flag == FPDFTEXT_CHAR_GENERATED) { |
| return index; |
| } |
| @@ -781,17 +774,13 @@ int CPDF_TextPage::GetWordBreak(int index, int direction) const { |
| int breakPos = index; |
| if (direction == FPDFTEXT_LEFT) { |
| while (--breakPos > 0) { |
| - charinfo = *(PAGECHAR_INFO*)m_charList.GetAt(breakPos); |
| - if (!IsLetter(charinfo.m_Unicode)) { |
| - return breakPos; |
| - } |
| + if (!IsLetter(m_CharList[breakPos].m_Unicode)) |
| + break; |
| } |
| } else if (direction == FPDFTEXT_RIGHT) { |
| - while (++breakPos < m_charList.GetSize()) { |
| - charinfo = *(PAGECHAR_INFO*)m_charList.GetAt(breakPos); |
| - if (!IsLetter(charinfo.m_Unicode)) { |
| - return breakPos; |
| - } |
| + while (++breakPos < m_CharList.size()) { |
| + if (!IsLetter(m_CharList[breakPos].m_Unicode)) |
| + break; |
| } |
| } |
| return breakPos; |
| @@ -981,18 +970,18 @@ void CPDF_TextPage::OnPiece(CFX_BidiChar* pBidi, CFX_WideString& str) { |
| if (ret == CFX_BidiChar::RIGHT) { |
| for (int i = start + count - 1; i >= start; i--) { |
| m_TextBuf.AppendChar(str.GetAt(i)); |
| - m_charList.Add(*(PAGECHAR_INFO*)m_TempCharList.GetAt(i)); |
| + m_CharList.push_back(m_TempCharList[i]); |
| } |
| } else { |
| int end = start + count; |
| for (int i = start; i < end; i++) { |
| m_TextBuf.AppendChar(str.GetAt(i)); |
| - m_charList.Add(*(PAGECHAR_INFO*)m_TempCharList.GetAt(i)); |
| + m_CharList.push_back(m_TempCharList[i]); |
| } |
| } |
| } |
| void CPDF_TextPage::AddCharInfoByLRDirection(CFX_WideString& str, int i) { |
| - PAGECHAR_INFO Info = *(PAGECHAR_INFO*)m_TempCharList.GetAt(i); |
| + PAGECHAR_INFO Info = m_TempCharList[i]; |
| FX_WCHAR wChar = str.GetAt(i); |
| if (!IsControlChar(Info)) { |
| Info.m_Index = m_TextBuf.GetLength(); |
| @@ -1008,7 +997,7 @@ void CPDF_TextPage::AddCharInfoByLRDirection(CFX_WideString& str, int i) { |
| Info2.m_Flag = FPDFTEXT_CHAR_PIECE; |
| m_TextBuf.AppendChar(Info2.m_Unicode); |
| if (!m_ParseOptions.m_bGetCharCodeOnly) { |
| - m_charList.Add(Info2); |
| + m_CharList.push_back(Info2); |
| } |
| } |
| FX_Free(pDst); |
| @@ -1020,11 +1009,11 @@ void CPDF_TextPage::AddCharInfoByLRDirection(CFX_WideString& str, int i) { |
| Info.m_Index = -1; |
| } |
| if (!m_ParseOptions.m_bGetCharCodeOnly) { |
| - m_charList.Add(Info); |
| + m_CharList.push_back(Info); |
| } |
| } |
| void CPDF_TextPage::AddCharInfoByRLDirection(CFX_WideString& str, int i) { |
| - PAGECHAR_INFO Info = *(PAGECHAR_INFO*)m_TempCharList.GetAt(i); |
| + PAGECHAR_INFO Info = m_TempCharList[i]; |
| if (!IsControlChar(Info)) { |
| Info.m_Index = m_TextBuf.GetLength(); |
| FX_WCHAR wChar = FX_GetMirrorChar(str.GetAt(i), TRUE, FALSE); |
| @@ -1039,7 +1028,7 @@ void CPDF_TextPage::AddCharInfoByRLDirection(CFX_WideString& str, int i) { |
| Info2.m_Flag = FPDFTEXT_CHAR_PIECE; |
| m_TextBuf.AppendChar(Info2.m_Unicode); |
| if (!m_ParseOptions.m_bGetCharCodeOnly) { |
| - m_charList.Add(Info2); |
| + m_CharList.push_back(Info2); |
| } |
| } |
| FX_Free(pDst); |
| @@ -1051,11 +1040,11 @@ void CPDF_TextPage::AddCharInfoByRLDirection(CFX_WideString& str, int i) { |
| Info.m_Index = -1; |
| } |
| if (!m_ParseOptions.m_bGetCharCodeOnly) { |
| - m_charList.Add(Info); |
| + m_CharList.push_back(Info); |
| } |
| } |
| void CPDF_TextPage::CloseTempLine() { |
| - int count1 = m_TempCharList.GetSize(); |
| + int count1 = m_TempCharList.size(); |
| if (count1 <= 0) { |
| return; |
| } |
| @@ -1070,7 +1059,7 @@ void CPDF_TextPage::CloseTempLine() { |
| if (str.GetAt(i) == 32) { |
| if (bPrevSpace) { |
| m_TempTextBuf.Delete(i, 1); |
| - m_TempCharList.Delete(i); |
| + m_TempCharList.erase(m_TempCharList.begin() + i); |
| str.Delete(i); |
| count1--; |
| i--; |
| @@ -1173,7 +1162,7 @@ void CPDF_TextPage::CloseTempLine() { |
| bL2R = TRUE; |
| continue; |
| } |
| - int end = m_TempCharList.GetSize() - 1; |
| + int end = m_TempCharList.size() - 1; |
| if (j < count) { |
| end = order.GetAt(j) - 1; |
| } |
| @@ -1190,7 +1179,7 @@ void CPDF_TextPage::CloseTempLine() { |
| } |
| } |
| order.RemoveAll(); |
| - m_TempCharList.RemoveAll(); |
| + m_TempCharList.clear(); |
| m_TempTextBuf.Delete(0, m_TempTextBuf.GetLength()); |
| } |
| void CPDF_TextPage::ProcessTextObject(CPDF_TextObject* pTextObj, |
| @@ -1410,29 +1399,23 @@ void CPDF_TextPage::ProcessMarkedContent(PDFTEXT_Obj Obj) { |
| charinfo.m_CharBox.bottom = charBox.bottom; |
| charinfo.m_Matrix.Copy(matrix); |
| m_TempTextBuf.AppendChar(wChar); |
| - m_TempCharList.Add(charinfo); |
| + m_TempCharList.push_back(charinfo); |
| } |
| } |
| -void CPDF_TextPage::FindPreviousTextObject(void) { |
| - if (m_TempCharList.GetSize() < 1 && m_charList.GetSize() < 1) { |
| +void CPDF_TextPage::FindPreviousTextObject() { |
| + if (m_TempCharList.empty() && m_CharList.empty()) |
| return; |
| - } |
| - PAGECHAR_INFO preChar; |
| - if (m_TempCharList.GetSize() >= 1) { |
| - preChar = |
| - *(PAGECHAR_INFO*)m_TempCharList.GetAt(m_TempCharList.GetSize() - 1); |
| - } else { |
| - preChar = *(PAGECHAR_INFO*)m_charList.GetAt(m_charList.GetSize() - 1); |
| - } |
| - if (preChar.m_pTextObj) { |
| + |
| + PAGECHAR_INFO preChar = |
| + m_TempCharList.empty() ? m_CharList.back() : m_TempCharList.back(); |
| + |
| + if (preChar.m_pTextObj) |
| m_pPreTextObj = preChar.m_pTextObj; |
| - } |
| } |
| void CPDF_TextPage::SwapTempTextBuf(int32_t iCharListStartAppend, |
| int32_t iBufStartAppend) { |
| - int32_t i, j; |
| - i = iCharListStartAppend; |
| - j = m_TempCharList.GetSize() - 1; |
| + int32_t i = iCharListStartAppend; |
| + int32_t j = m_TempCharList.size() - 1; |
| for (; i < j; i++, j--) { |
| std::swap(m_TempCharList[i], m_TempCharList[j]); |
| std::swap(m_TempCharList[i].m_Index, m_TempCharList[j].m_Index); |
| @@ -1519,7 +1502,7 @@ void CPDF_TextPage::ProcessTextObject(PDFTEXT_Obj Obj) { |
| generateChar.m_Matrix.Copy(formMatrix); |
| } |
| m_TempTextBuf.AppendChar(TEXT_BLANK_CHAR); |
| - m_TempCharList.Add(generateChar); |
| + m_TempCharList.push_back(generateChar); |
| } |
| } else if (result == 2) { |
| CloseTempLine(); |
| @@ -1533,14 +1516,14 @@ void CPDF_TextPage::ProcessTextObject(PDFTEXT_Obj Obj) { |
| if (!formMatrix.IsIdentity()) { |
| generateChar.m_Matrix.Copy(formMatrix); |
| } |
| - m_charList.Add(generateChar); |
| + m_CharList.push_back(generateChar); |
| } |
| if (GenerateCharInfo(TEXT_LINEFEED_CHAR, generateChar)) { |
| m_TextBuf.AppendChar(TEXT_LINEFEED_CHAR); |
| if (!formMatrix.IsIdentity()) { |
| generateChar.m_Matrix.Copy(formMatrix); |
| } |
| - m_charList.Add(generateChar); |
| + m_CharList.push_back(generateChar); |
| } |
| } |
| } |
| @@ -1563,10 +1546,9 @@ void CPDF_TextPage::ProcessTextObject(PDFTEXT_Obj Obj) { |
| m_TempTextBuf.GetWideString().GetAt(m_TempTextBuf.GetLength() - |
| 1) == 0x20) { |
| m_TempTextBuf.Delete(m_TempTextBuf.GetLength() - 1, 1); |
| - m_TempCharList.Delete(m_TempCharList.GetSize() - 1); |
| + m_TempCharList.pop_back(); |
| } |
| - PAGECHAR_INFO* cha = |
| - (PAGECHAR_INFO*)m_TempCharList.GetAt(m_TempCharList.GetSize() - 1); |
| + PAGECHAR_INFO* cha = &m_TempCharList[m_TempCharList.size() - 1]; |
| m_TempTextBuf.Delete(m_TempTextBuf.GetLength() - 1, 1); |
| cha->m_Unicode = 0x2; |
| cha->m_Flag = FPDFTEXT_CHAR_HYPHEN; |
| @@ -1592,7 +1574,7 @@ void CPDF_TextPage::ProcessTextObject(PDFTEXT_Obj Obj) { |
| const FX_BOOL bIsBidiAndMirrorInverse = |
| bR2L && (matrix.a * matrix.d - matrix.b * matrix.c) < 0; |
| int32_t iBufStartAppend = m_TempTextBuf.GetLength(); |
| - int32_t iCharListStartAppend = m_TempCharList.GetSize(); |
| + int32_t iCharListStartAppend = m_TempCharList.size(); |
| FX_FLOAT spacing = 0; |
| for (int i = 0; i < nItems; i++) { |
| @@ -1654,7 +1636,7 @@ void CPDF_TextPage::ProcessTextObject(PDFTEXT_Obj Obj) { |
| charinfo.m_CharBox = |
| CFX_FloatRect(charinfo.m_OriginX, charinfo.m_OriginY, |
| charinfo.m_OriginX, charinfo.m_OriginY); |
| - m_TempCharList.Add(charinfo); |
| + m_TempCharList.push_back(charinfo); |
| } |
| if (item.m_CharCode == (FX_DWORD)-1) { |
| continue; |
| @@ -1706,18 +1688,18 @@ void CPDF_TextPage::ProcessTextObject(PDFTEXT_Obj Obj) { |
| charinfo.m_Matrix.Copy(matrix); |
| if (wstrItem.IsEmpty()) { |
| charinfo.m_Unicode = 0; |
| - m_TempCharList.Add(charinfo); |
| + m_TempCharList.push_back(charinfo); |
| m_TempTextBuf.AppendChar(0xfffe); |
| continue; |
| } else { |
| int nTotal = wstrItem.GetLength(); |
| FX_BOOL bDel = FALSE; |
| - const int count = std::min(m_TempCharList.GetSize(), 7); |
| + const int count = std::min(static_cast<int>(m_TempCharList.size()), 7); |
| FX_FLOAT threshold = charinfo.m_Matrix.TransformXDistance( |
| (FX_FLOAT)TEXT_CHARRATIO_GAPDELTA * pTextObj->GetFontSize()); |
| - for (int n = m_TempCharList.GetSize(); |
| - n > m_TempCharList.GetSize() - count; n--) { |
| - PAGECHAR_INFO* charinfo1 = (PAGECHAR_INFO*)m_TempCharList.GetAt(n - 1); |
| + for (int n = m_TempCharList.size(); n > m_TempCharList.size() - count; |
| + n--) { |
| + PAGECHAR_INFO* charinfo1 = &m_TempCharList[n - 1]; |
| if (charinfo1->m_CharCode == charinfo.m_CharCode && |
| charinfo1->m_pTextObj->GetFont() == |
| charinfo.m_pTextObj->GetFont() && |
| @@ -1736,14 +1718,14 @@ void CPDF_TextPage::ProcessTextObject(PDFTEXT_Obj Obj) { |
| } else { |
| m_TempTextBuf.AppendChar(0xfffe); |
| } |
| - m_TempCharList.Add(charinfo); |
| + m_TempCharList.push_back(charinfo); |
| } |
| } else if (i == 0) { |
| CFX_WideString str = m_TempTextBuf.GetWideString(); |
| if (!str.IsEmpty() && |
| str.GetAt(str.GetLength() - 1) == TEXT_BLANK_CHAR) { |
| m_TempTextBuf.Delete(m_TempTextBuf.GetLength() - 1, 1); |
| - m_TempCharList.Delete(m_TempCharList.GetSize() - 1); |
| + m_TempCharList.pop_back(); |
| } |
| } |
| } |
| @@ -1802,16 +1784,16 @@ FX_BOOL CPDF_TextPage::IsHyphen(FX_WCHAR curChar) { |
| return TRUE; |
| } |
| } |
| - int size = m_TempCharList.GetSize(); |
| + int size = m_TempCharList.size(); |
| PAGECHAR_INFO preChar; |
| if (size) { |
| - preChar = (PAGECHAR_INFO)m_TempCharList[size - 1]; |
| + preChar = m_TempCharList[size - 1]; |
| } else { |
| - size = m_charList.GetSize(); |
| + size = m_CharList.size(); |
| if (size == 0) { |
| return FALSE; |
| } |
| - preChar = (PAGECHAR_INFO)m_charList[size - 1]; |
| + preChar = m_CharList[size - 1]; |
| } |
| if (FPDFTEXT_CHAR_PIECE == preChar.m_Flag && |
| (0xAD == preChar.m_Unicode || 0x2D == preChar.m_Unicode)) { |
| @@ -1988,9 +1970,9 @@ FX_BOOL CPDF_TextPage::IsSameTextObject(CPDF_TextObject* pTextObj1, |
| if (rcPreObj.IsEmpty() && rcCurObj.IsEmpty() && |
| !m_ParseOptions.m_bGetCharCodeOnly) { |
| FX_FLOAT dbXdif = FXSYS_fabs(rcPreObj.left - rcCurObj.left); |
| - int nCount = m_charList.GetSize(); |
| + int nCount = m_CharList.size(); |
|
Oliver Chang
2016/01/22 21:26:23
this can probably be just a size_t instead of bein
Tom Sepez
2016/01/22 21:41:56
Acknowledged.
|
| if (nCount >= 2) { |
| - PAGECHAR_INFO perCharTemp = (PAGECHAR_INFO)m_charList[nCount - 2]; |
| + PAGECHAR_INFO perCharTemp = m_CharList[nCount - 2]; |
| FX_FLOAT dbSpace = perCharTemp.m_CharBox.Width(); |
| if (dbXdif > dbSpace) { |
| return FALSE; |
| @@ -2061,16 +2043,16 @@ FX_BOOL CPDF_TextPage::IsSameAsPreTextObject(CPDF_TextObject* pTextObj, |
| } |
| FX_BOOL CPDF_TextPage::GenerateCharInfo(FX_WCHAR unicode, PAGECHAR_INFO& info) { |
| - int size = m_TempCharList.GetSize(); |
| + int size = m_TempCharList.size(); |
|
Oliver Chang
2016/01/22 21:26:23
this one too
Tom Sepez
2016/01/22 21:41:56
Acknowledged.
|
| PAGECHAR_INFO preChar; |
| if (size) { |
| - preChar = (PAGECHAR_INFO)m_TempCharList[size - 1]; |
| + preChar = m_TempCharList[size - 1]; |
| } else { |
| - size = m_charList.GetSize(); |
| + size = m_CharList.size(); |
| if (size == 0) { |
| return FALSE; |
| } |
| - preChar = (PAGECHAR_INFO)m_charList[size - 1]; |
| + preChar = m_CharList[size - 1]; |
| } |
| info.m_Index = m_TextBuf.GetLength(); |
| info.m_Unicode = unicode; |