Chromium Code Reviews| Index: core/src/fpdftext/fpdf_text.cpp |
| diff --git a/core/src/fpdftext/fpdf_text.cpp b/core/src/fpdftext/fpdf_text.cpp |
| index 4653fa63fa33704b5397dcce68920c5e1829f429..3bbadcfbf4b2d0903411bc15fa7c751e3f674dfb 100644 |
| --- a/core/src/fpdftext/fpdf_text.cpp |
| +++ b/core/src/fpdftext/fpdf_text.cpp |
| @@ -7,6 +7,7 @@ |
| #include <cctype> |
| #include <cwctype> |
| #include <memory> |
| +#include <vector> |
| #include "core/include/fpdfapi/fpdf_page.h" |
| #include "core/include/fpdfapi/fpdf_pageobj.h" |
| @@ -309,22 +310,23 @@ void NormalizeCompositeChar(FX_WCHAR wChar, CFX_WideString& sDest) { |
| } |
| delete[] pDst; |
| } |
| + |
| void NormalizeString(CFX_WideString& str) { |
| if (str.GetLength() <= 0) { |
| return; |
| } |
| CFX_WideString sBuffer; |
| std::unique_ptr<CFX_BidiChar> pBidiChar(new CFX_BidiChar); |
| - CFX_WordArray order; |
| + std::vector<FX_WORD> order; |
| FX_BOOL bR2L = FALSE; |
| int32_t start = 0, count = 0, i = 0; |
| int nR2L = 0, nL2R = 0; |
| for (i = 0; i < str.GetLength(); i++) { |
| if (pBidiChar->AppendChar(str.GetAt(i))) { |
| CFX_BidiChar::Direction ret = pBidiChar->GetBidiInfo(&start, &count); |
| - order.Add(start); |
| - order.Add(count); |
| - order.Add(ret); |
| + order.push_back(start); |
| + order.push_back(count); |
| + order.push_back(ret); |
| if (!bR2L) { |
| if (ret == CFX_BidiChar::RIGHT) { |
| nR2L++; |
| @@ -336,9 +338,9 @@ void NormalizeString(CFX_WideString& str) { |
| } |
| if (pBidiChar->EndChar()) { |
| CFX_BidiChar::Direction ret = pBidiChar->GetBidiInfo(&start, &count); |
| - order.Add(start); |
| - order.Add(count); |
| - order.Add(ret); |
| + order.push_back(start); |
| + order.push_back(count); |
| + order.push_back(ret); |
| if (!bR2L) { |
| if (ret == CFX_BidiChar::RIGHT) { |
| nR2L++; |
| @@ -351,11 +353,11 @@ void NormalizeString(CFX_WideString& str) { |
| bR2L = TRUE; |
| } |
| if (bR2L) { |
| - int count = order.GetSize(); |
| + int count = order.size(); |
| for (int j = count - 1; j > 0; j -= 3) { |
| - int ret = order.GetAt(j); |
| - int start = order.GetAt(j - 2); |
| - int count1 = order.GetAt(j - 1); |
| + int ret = order[j]; |
| + int count1 = order[j - 1]; |
| + int start = order[j - 2]; |
| if (ret == 2 || ret == 0) { |
| for (int i = start + count1 - 1; i >= start; i--) { |
| NormalizeCompositeChar(str[i], sBuffer); |
| @@ -363,8 +365,8 @@ void NormalizeString(CFX_WideString& str) { |
| } else { |
| i = j; |
| FX_BOOL bSymbol = FALSE; |
| - while (i > 0 && order.GetAt(i) != 2) { |
| - bSymbol = !order.GetAt(i); |
| + while (i > 0 && order[i] != 2) { |
| + bSymbol = !order[i]; |
| i -= 3; |
| } |
| int end = start + count1; |
| @@ -382,8 +384,8 @@ void NormalizeString(CFX_WideString& str) { |
| i = j; |
| j = n; |
| for (; n <= i; n += 3) { |
| - int start = order.GetAt(n - 2); |
| - int count1 = order.GetAt(n - 1); |
| + int start = order[n - 2]; |
| + int count1 = order[n - 1]; |
| int end = start + count1; |
| for (int m = start; m < end; m++) { |
| sBuffer += str[m]; |
| @@ -393,16 +395,16 @@ void NormalizeString(CFX_WideString& str) { |
| } |
| } |
| } else { |
| - int count = order.GetSize(); |
| + int count = order.size(); |
|
Lei Zhang
2016/02/09 00:45:21
pdfium::CollectionSize<int>()
Tom Sepez
2016/02/09 00:57:01
Done, also in if-branch above.
|
| FX_BOOL bL2R = FALSE; |
| for (int j = 0; j < count; j += 3) { |
| - int ret = order.GetAt(j + 2); |
| - int start = order.GetAt(j); |
| - int count1 = order.GetAt(j + 1); |
| + int start = order[j]; |
| + int count1 = order[j + 1]; |
| + int ret = order[j + 2]; |
| if (ret == 2 || (j == 0 && ret == 0 && !bL2R)) { |
| int i = j + 3; |
| while (bR2L && i < count) { |
| - if (order.GetAt(i + 2) == 1) { |
| + if (order[i + 2] == 1) { |
| break; |
| } else { |
| i += 3; |
| @@ -415,7 +417,7 @@ void NormalizeString(CFX_WideString& str) { |
| } |
| int end = str.GetLength() - 1; |
| if (i < count) { |
| - end = order.GetAt(i) - 1; |
| + end = order[i] - 1; |
| } |
| j = i - 3; |
| for (int n = end; n >= start; n--) { |