Index: xfa/fgas/layout/fgas_textbreak.h |
diff --git a/xfa/fgas/layout/fgas_textbreak.h b/xfa/fgas/layout/fgas_textbreak.h |
index 7359600c141016d761b2b3cc547a82f1e7077374..eb5e47d9e3d6ba2b15aa1e0618cf6f4f78b9d347 100644 |
--- a/xfa/fgas/layout/fgas_textbreak.h |
+++ b/xfa/fgas/layout/fgas_textbreak.h |
@@ -8,9 +8,11 @@ |
#define XFA_FGAS_LAYOUT_FGAS_TEXTBREAK_H_ |
#include <memory> |
+#include <vector> |
#include "core/fxcrt/fx_ucd.h" |
#include "core/fxge/cfx_renderdevice.h" |
+#include "third_party/base/stl_util.h" |
#include "xfa/fgas/crt/fgas_utils.h" |
#include "xfa/fgas/layout/fgas_unicode.h" |
@@ -116,14 +118,13 @@ class CFX_TxtPiece { |
int32_t GetEndChar() const { return m_iStartChar + m_iChars; } |
CFX_TxtChar* GetCharPtr(int32_t index) const { |
ASSERT(index > -1 && index < m_iChars && m_pChars); |
- return m_pChars->GetDataPtr(m_iStartChar + index); |
+ return &(*m_pChars)[m_iStartChar + index]; |
} |
void GetString(FX_WCHAR* pText) const { |
ASSERT(pText); |
int32_t iEndChar = m_iStartChar + m_iChars; |
- CFX_Char* pChar; |
for (int32_t i = m_iStartChar; i < iEndChar; i++) { |
- pChar = m_pChars->GetDataPtr(i); |
+ CFX_Char* pChar = &(*m_pChars)[i]; |
*pText++ = (FX_WCHAR)pChar->m_wCharCode; |
dsinclair
2017/01/24 18:43:59
This seems overly complicated why not something li
Tom Sepez
2017/01/24 19:16:12
Done.
|
} |
} |
@@ -135,9 +136,8 @@ class CFX_TxtPiece { |
void GetWidths(int32_t* pWidths) const { |
ASSERT(pWidths); |
int32_t iEndChar = m_iStartChar + m_iChars; |
- CFX_Char* pChar; |
for (int32_t i = m_iStartChar; i < iEndChar; i++) { |
- pChar = m_pChars->GetDataPtr(i); |
+ CFX_Char* pChar = &(*m_pChars)[i]; |
*pWidths++ = pChar->m_iCharWidth; |
} |
} |
@@ -152,7 +152,7 @@ class CFX_TxtPiece { |
int32_t m_iHorizontalScale; |
int32_t m_iVerticalScale; |
uint32_t m_dwCharStyles; |
- CFX_TxtCharArray* m_pChars; |
+ std::vector<CFX_TxtChar>* m_pChars; |
void* m_pUserData; |
}; |
@@ -163,10 +163,13 @@ class CFX_TxtLine { |
explicit CFX_TxtLine(int32_t iBlockSize); |
~CFX_TxtLine(); |
- int32_t CountChars() const { return m_pLineChars->GetSize(); } |
+ int32_t CountChars() const { |
+ return pdfium::CollectionSize<int32_t>(*m_pLineChars); |
+ } |
CFX_TxtChar* GetCharPtr(int32_t index) const { |
- ASSERT(index > -1 && index < m_pLineChars->GetSize()); |
- return m_pLineChars->GetDataPtr(index); |
+ ASSERT(index >= 0 && |
+ index < pdfium::CollectionSize<int32_t>(*m_pLineChars)); |
+ return &(*m_pLineChars)[index]; |
} |
int32_t CountPieces() const { return m_pLinePieces->GetSize(); } |
CFX_TxtPiece* GetPiecePtr(int32_t index) const { |
@@ -174,23 +177,22 @@ class CFX_TxtLine { |
return m_pLinePieces->GetPtrAt(index); |
} |
void GetString(CFX_WideString& wsStr) const { |
- int32_t iCount = m_pLineChars->GetSize(); |
+ int32_t iCount = pdfium::CollectionSize<int32_t>(*m_pLineChars); |
FX_WCHAR* pBuf = wsStr.GetBuffer(iCount); |
- CFX_Char* pChar; |
for (int32_t i = 0; i < iCount; i++) { |
- pChar = m_pLineChars->GetDataPtr(i); |
+ CFX_Char* pChar = &(*m_pLineChars)[i]; |
*pBuf++ = (FX_WCHAR)pChar->m_wCharCode; |
} |
wsStr.ReleaseBuffer(iCount); |
} |
void RemoveAll(bool bLeaveMemory = false) { |
- m_pLineChars->RemoveAll(); |
+ m_pLineChars->clear(); |
m_pLinePieces->RemoveAll(bLeaveMemory); |
m_iWidth = 0; |
m_iArabicChars = 0; |
} |
- std::unique_ptr<CFX_TxtCharArray> m_pLineChars; |
+ std::unique_ptr<std::vector<CFX_TxtChar>> m_pLineChars; |
std::unique_ptr<CFX_TxtPieceArray> m_pLinePieces; |
int32_t m_iStart; |
int32_t m_iWidth; |
@@ -260,7 +262,7 @@ class CFX_TxtBreak { |
void EndBreak_Alignment(CFX_TPOArray& tpos, |
bool bAllChars, |
uint32_t dwStatus); |
- int32_t GetBreakPos(CFX_TxtCharArray& ca, |
+ int32_t GetBreakPos(std::vector<CFX_TxtChar>& ca, |
int32_t& iEndPos, |
bool bAllChars = false, |
bool bOnlyBrk = false); |