summaryrefslogtreecommitdiff
path: root/xfa/fgas
diff options
context:
space:
mode:
Diffstat (limited to 'xfa/fgas')
-rw-r--r--xfa/fgas/layout/fgas_rtfbreak.cpp55
-rw-r--r--xfa/fgas/layout/fgas_rtfbreak.h53
-rw-r--r--xfa/fgas/layout/fgas_textbreak.cpp62
-rw-r--r--xfa/fgas/layout/fgas_textbreak.h47
4 files changed, 104 insertions, 113 deletions
diff --git a/xfa/fgas/layout/fgas_rtfbreak.cpp b/xfa/fgas/layout/fgas_rtfbreak.cpp
index 52e6267ded..e01578bdc9 100644
--- a/xfa/fgas/layout/fgas_rtfbreak.cpp
+++ b/xfa/fgas/layout/fgas_rtfbreak.cpp
@@ -273,15 +273,14 @@ void CFX_RTFBreak::SetBreakStatus() {
}
}
CFX_RTFChar* CFX_RTFBreak::GetLastChar(int32_t index) const {
- CFX_RTFCharArray& tca = m_pCurLine->m_LineChars;
- int32_t iCount = tca.GetSize();
+ std::vector<CFX_RTFChar>& tca = m_pCurLine->m_LineChars;
+ int32_t iCount = pdfium::CollectionSize<int32_t>(tca);
if (index < 0 || index >= iCount) {
return nullptr;
}
- CFX_RTFChar* pTC;
int32_t iStart = iCount - 1;
while (iStart > -1) {
- pTC = tca.GetDataPtr(iStart--);
+ CFX_RTFChar* pTC = &tca[iStart--];
if (pTC->m_iCharWidth >= 0 ||
pTC->GetCharType() != FX_CHARTYPE_Combination) {
if (--index < 0) {
@@ -349,8 +348,8 @@ uint32_t CFX_RTFBreak::AppendChar(FX_WCHAR wch) {
uint32_t dwProps = kTextLayoutCodeProperties[(uint16_t)wch];
FX_CHARTYPE chartype = GetCharTypeFromProp(dwProps);
- CFX_RTFCharArray& tca = m_pCurLine->m_LineChars;
- CFX_RTFChar* pCurChar = tca.AddSpace();
+ m_pCurLine->m_LineChars.emplace_back();
+ CFX_RTFChar* pCurChar = &m_pCurLine->m_LineChars.back();
pCurChar->m_dwStatus = 0;
pCurChar->m_wCharCode = wch;
pCurChar->m_dwCharProps = dwProps;
@@ -377,7 +376,7 @@ uint32_t CFX_RTFBreak::AppendChar(FX_WCHAR wch) {
dwRet1 = EndBreak(FX_RTFBREAK_LineBreak);
int32_t iCount = m_pCurLine->CountChars();
if (iCount > 0) {
- pCurChar = m_pCurLine->m_LineChars.GetDataPtr(iCount - 1);
+ pCurChar = &m_pCurLine->m_LineChars[iCount - 1];
}
}
}
@@ -397,8 +396,8 @@ uint32_t CFX_RTFBreak::AppendChar_CharCode(FX_WCHAR wch) {
ASSERT(m_pFont && m_pCurLine);
ASSERT(m_bCharCode);
m_pCurLine->m_iMBCSChars++;
- CFX_RTFCharArray& tca = m_pCurLine->m_LineChars;
- CFX_RTFChar* pCurChar = tca.AddSpace();
+ m_pCurLine->m_LineChars.emplace_back();
+ CFX_RTFChar* pCurChar = &m_pCurLine->m_LineChars.back();
pCurChar->m_dwStatus = 0;
pCurChar->m_wCharCode = wch;
pCurChar->m_dwCharProps = 0;
@@ -696,7 +695,7 @@ bool CFX_RTFBreak::EndBreak_SplitLine(CFX_RTFLine* pNextLine,
}
}
if (m_bPagination || m_pCurLine->m_iMBCSChars > 0) {
- const CFX_RTFChar* pCurChars = m_pCurLine->m_LineChars.GetData();
+ const CFX_RTFChar* pCurChars = m_pCurLine->m_LineChars.data();
const CFX_RTFChar* pTC;
CFX_RTFPieceArray* pCurPieces = &m_pCurLine->m_LinePieces;
CFX_RTFPiece tp;
@@ -751,14 +750,14 @@ void CFX_RTFBreak::EndBreak_BidiLine(CFX_TPOArray& tpos, uint32_t dwStatus) {
CFX_RTFPiece tp;
CFX_RTFChar* pTC;
int32_t i, j;
- CFX_RTFCharArray& chars = m_pCurLine->m_LineChars;
+ std::vector<CFX_RTFChar>& chars = m_pCurLine->m_LineChars;
int32_t iCount = m_pCurLine->CountChars();
bool bDone = (!m_bPagination && !m_bCharCode &&
(m_pCurLine->m_iArabicChars > 0 || m_bRTL));
if (bDone) {
int32_t iBidiNum = 0;
for (i = 0; i < iCount; i++) {
- pTC = chars.GetDataPtr(i);
+ pTC = &chars[i];
pTC->m_iBidiPos = i;
if (pTC->GetCharType() != FX_CHARTYPE_Control) {
iBidiNum = i;
@@ -770,7 +769,7 @@ void CFX_RTFBreak::EndBreak_BidiLine(CFX_TPOArray& tpos, uint32_t dwStatus) {
FX_BidiLine(chars, iBidiNum + 1, m_bRTL ? 1 : 0);
} else {
for (i = 0; i < iCount; i++) {
- pTC = chars.GetDataPtr(i);
+ pTC = &chars[i];
pTC->m_iBidiLevel = 0;
pTC->m_iBidiPos = 0;
pTC->m_iBidiOrder = 0;
@@ -784,7 +783,7 @@ void CFX_RTFBreak::EndBreak_BidiLine(CFX_TPOArray& tpos, uint32_t dwStatus) {
uint32_t dwIdentity = (uint32_t)-1;
i = j = 0;
while (i < iCount) {
- pTC = chars.GetDataPtr(i);
+ pTC = &chars[i];
if (iBidiLevel < 0) {
iBidiLevel = pTC->m_iBidiLevel;
iCharWidth = pTC->m_iCharWidth;
@@ -933,11 +932,11 @@ void CFX_RTFBreak::EndBreak_Alignment(CFX_TPOArray& tpos,
}
}
-int32_t CFX_RTFBreak::GetBreakPos(CFX_RTFCharArray& tca,
+int32_t CFX_RTFBreak::GetBreakPos(std::vector<CFX_RTFChar>& tca,
int32_t& iEndPos,
bool bAllChars,
bool bOnlyBrk) {
- int32_t iLength = tca.GetSize() - 1;
+ int32_t iLength = pdfium::CollectionSize<int32_t>(tca) - 1;
if (iLength < 1)
return iLength;
@@ -950,7 +949,7 @@ int32_t CFX_RTFBreak::GetBreakPos(CFX_RTFCharArray& tca,
iBreak = iLength;
iBreakPos = iEndPos;
}
- CFX_RTFChar* pCharArray = tca.GetData();
+ CFX_RTFChar* pCharArray = tca.data();
if (m_bCharCode) {
const CFX_RTFChar* pChar;
int32_t iCharWidth;
@@ -1071,7 +1070,7 @@ void CFX_RTFBreak::SplitTextLine(CFX_RTFLine* pCurLine,
return;
}
int32_t iEndPos = pCurLine->GetLineEnd();
- CFX_RTFCharArray& curChars = pCurLine->m_LineChars;
+ std::vector<CFX_RTFChar>& curChars = pCurLine->m_LineChars;
int32_t iCharPos = GetBreakPos(curChars, iEndPos, bAllChars, false);
if (iCharPos < 0) {
iCharPos = 0;
@@ -1079,24 +1078,20 @@ void CFX_RTFBreak::SplitTextLine(CFX_RTFLine* pCurLine,
iCharPos++;
if (iCharPos >= iCount) {
pNextLine->RemoveAll(true);
- CFX_Char* pTC = curChars.GetDataPtr(iCharPos - 1);
+ CFX_Char* pTC = &curChars[iCharPos - 1];
pTC->m_nBreakType = FX_LBT_UNKNOWN;
return;
}
- CFX_RTFCharArray& nextChars = pNextLine->m_LineChars;
- int cur_size = curChars.GetSize();
- nextChars.SetSize(cur_size - iCharPos);
- FXSYS_memcpy(nextChars.GetData(), curChars.GetDataPtr(iCharPos),
- (cur_size - iCharPos) * sizeof(CFX_RTFChar));
- iCount -= iCharPos;
- cur_size = curChars.GetSize();
- curChars.RemoveAt(cur_size - iCount, iCount);
+ std::vector<CFX_RTFChar>& nextChars = pNextLine->m_LineChars;
+ nextChars =
+ std::vector<CFX_RTFChar>(curChars.begin() + iCharPos, curChars.end());
+ curChars.erase(curChars.begin() + iCharPos, curChars.end());
pNextLine->m_iStart = pCurLine->m_iStart;
pNextLine->m_iWidth = pCurLine->GetLineEnd() - iEndPos;
pCurLine->m_iWidth = iEndPos;
- curChars.GetDataPtr(iCharPos - 1)->m_nBreakType = FX_LBT_UNKNOWN;
- iCount = nextChars.GetSize();
- CFX_RTFChar* pNextChars = nextChars.GetData();
+ curChars[iCharPos - 1].m_nBreakType = FX_LBT_UNKNOWN;
+ iCount = pdfium::CollectionSize<int>(nextChars);
+ CFX_RTFChar* pNextChars = nextChars.data();
for (int32_t i = 0; i < iCount; i++) {
CFX_RTFChar* tc = pNextChars + i;
if (tc->GetCharType() >= FX_CHARTYPE_ArabicAlef) {
diff --git a/xfa/fgas/layout/fgas_rtfbreak.h b/xfa/fgas/layout/fgas_rtfbreak.h
index f3d2311a2c..613156a3e0 100644
--- a/xfa/fgas/layout/fgas_rtfbreak.h
+++ b/xfa/fgas/layout/fgas_rtfbreak.h
@@ -89,7 +89,7 @@ class CFX_RTFPiece {
void AppendChar(const CFX_RTFChar& tc) {
ASSERT(m_pChars);
- m_pChars->Add(tc);
+ m_pChars->push_back(tc);
if (m_iWidth < 0) {
m_iWidth = tc.m_iCharWidth;
} else {
@@ -97,42 +97,44 @@ class CFX_RTFPiece {
}
m_iChars++;
}
+
int32_t GetEndPos() const {
return m_iWidth < 0 ? m_iStartPos : m_iStartPos + m_iWidth;
}
+
int32_t GetLength() const { return m_iChars; }
int32_t GetEndChar() const { return m_iStartChar + m_iChars; }
+
CFX_RTFChar& GetChar(int32_t index) {
ASSERT(index > -1 && index < m_iChars && m_pChars);
- return *m_pChars->GetDataPtr(m_iStartChar + index);
+ return (*m_pChars)[m_iStartChar + index];
}
+
CFX_RTFChar* 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_RTFChar* pChar;
- for (int32_t i = m_iStartChar; i < iEndChar; i++) {
- pChar = m_pChars->GetDataPtr(i);
- *pText++ = (FX_WCHAR)pChar->m_wCharCode;
- }
+ for (int32_t i = m_iStartChar; i < iEndChar; i++)
+ *pText++ = static_cast<FX_WCHAR>((*m_pChars)[i].m_wCharCode);
}
+
void GetString(CFX_WideString& wsText) const {
FX_WCHAR* pText = wsText.GetBuffer(m_iChars);
GetString(pText);
wsText.ReleaseBuffer(m_iChars);
}
+
void GetWidths(int32_t* pWidths) const {
ASSERT(pWidths);
int32_t iEndChar = m_iStartChar + m_iChars;
- CFX_RTFChar* pChar;
- for (int32_t i = m_iStartChar; i < iEndChar; i++) {
- pChar = m_pChars->GetDataPtr(i);
- *pWidths++ = pChar->m_iCharWidth;
- }
+ for (int32_t i = m_iStartChar; i < iEndChar; i++)
+ *pWidths++ = (*m_pChars)[i].m_iCharWidth;
}
+
void Reset() {
m_dwStatus = FX_RTFBREAK_PieceBreak;
if (m_iWidth > -1) {
@@ -160,7 +162,7 @@ class CFX_RTFPiece {
int32_t m_iVerticalScale;
uint32_t m_dwLayoutStyles;
uint32_t m_dwIdentity;
- CFX_RTFCharArray* m_pChars;
+ std::vector<CFX_RTFChar>* m_pChars; // not owned.
IFX_Retainable* m_pUserData;
};
@@ -171,14 +173,16 @@ class CFX_RTFLine {
CFX_RTFLine();
~CFX_RTFLine();
- int32_t CountChars() const { return m_LineChars.GetSize(); }
+ int32_t CountChars() const {
+ return pdfium::CollectionSize<int32_t>(m_LineChars);
+ }
CFX_RTFChar& GetChar(int32_t index) {
- ASSERT(index > -1 && index < m_LineChars.GetSize());
- return *m_LineChars.GetDataPtr(index);
+ ASSERT(index >= 0 && index < pdfium::CollectionSize<int32_t>(m_LineChars));
+ return m_LineChars[index];
}
CFX_RTFChar* GetCharPtr(int32_t index) {
- ASSERT(index > -1 && index < m_LineChars.GetSize());
- return m_LineChars.GetDataPtr(index);
+ ASSERT(index > -1 && index < pdfium::CollectionSize<int32_t>(m_LineChars));
+ return &m_LineChars[index];
}
int32_t CountPieces() const { return m_LinePieces.GetSize(); }
CFX_RTFPiece& GetPiece(int32_t index) const {
@@ -191,21 +195,20 @@ class CFX_RTFLine {
}
int32_t GetLineEnd() const { return m_iStart + m_iWidth; }
void RemoveAll(bool bLeaveMemory = false) {
- CFX_RTFChar* pChar;
- int32_t iCount = m_LineChars.GetSize();
+ int32_t iCount = pdfium::CollectionSize<int32_t>(m_LineChars);
for (int32_t i = 0; i < iCount; i++) {
- pChar = m_LineChars.GetDataPtr(i);
+ CFX_RTFChar* pChar = &m_LineChars[i];
if (pChar->m_pUserData)
pChar->m_pUserData->Release();
}
- m_LineChars.RemoveAll();
+ m_LineChars.clear();
m_LinePieces.RemoveAll(bLeaveMemory);
m_iWidth = 0;
m_iArabicChars = 0;
m_iMBCSChars = 0;
}
- CFX_RTFCharArray m_LineChars;
+ std::vector<CFX_RTFChar> m_LineChars;
CFX_RTFPieceArray m_LinePieces;
int32_t m_iStart;
int32_t m_iWidth;
@@ -271,7 +274,7 @@ class CFX_RTFBreak {
int32_t GetLastPositionedTab() const;
bool GetPositionedTab(int32_t& iTabPos) const;
- int32_t GetBreakPos(CFX_RTFCharArray& tca,
+ int32_t GetBreakPos(std::vector<CFX_RTFChar>& tca,
int32_t& iEndPos,
bool bAllChars = false,
bool bOnlyBrk = false);
diff --git a/xfa/fgas/layout/fgas_textbreak.cpp b/xfa/fgas/layout/fgas_textbreak.cpp
index 50e3b063fd..74f8cb4756 100644
--- a/xfa/fgas/layout/fgas_textbreak.cpp
+++ b/xfa/fgas/layout/fgas_textbreak.cpp
@@ -278,15 +278,14 @@ int32_t CFX_TxtBreak::GetLineRotation(uint32_t dwStyles) const {
}
CFX_TxtChar* CFX_TxtBreak::GetLastChar(int32_t index, bool bOmitChar) const {
- CFX_TxtCharArray& ca = *m_pCurLine->m_pLineChars.get();
- int32_t iCount = ca.GetSize();
+ std::vector<CFX_TxtChar>& ca = *m_pCurLine->m_pLineChars.get();
+ int32_t iCount = pdfium::CollectionSize<int32_t>(ca);
if (index < 0 || index >= iCount) {
return nullptr;
}
- CFX_TxtChar* pTC;
int32_t iStart = iCount - 1;
while (iStart > -1) {
- pTC = ca.GetDataPtr(iStart--);
+ CFX_TxtChar* pTC = &ca[iStart--];
if (bOmitChar && pTC->GetCharType() == FX_CHARTYPE_Combination) {
continue;
}
@@ -595,7 +594,8 @@ uint32_t CFX_TxtBreak::AppendChar_Others(CFX_TxtChar* pCurChar,
uint32_t CFX_TxtBreak::AppendChar(FX_WCHAR wch) {
uint32_t dwProps = kTextLayoutCodeProperties[(uint16_t)wch];
FX_CHARTYPE chartype = GetCharTypeFromProp(dwProps);
- CFX_TxtChar* pCurChar = m_pCurLine->m_pLineChars->AddSpace();
+ m_pCurLine->m_pLineChars->emplace_back();
+ CFX_TxtChar* pCurChar = &m_pCurLine->m_pLineChars->back();
pCurChar->m_wCharCode = (uint16_t)wch;
pCurChar->m_nRotation = m_iCharRotation;
pCurChar->m_dwCharProps = dwProps;
@@ -619,7 +619,7 @@ uint32_t CFX_TxtBreak::AppendChar(FX_WCHAR wch) {
dwRet1 = EndBreak(FX_TXTBREAK_LineBreak);
int32_t iCount = m_pCurLine->CountChars();
if (iCount > 0) {
- pCurChar = m_pCurLine->m_pLineChars->GetDataPtr(iCount - 1);
+ pCurChar = &(*m_pCurLine->m_pLineChars)[iCount - 1];
}
}
}
@@ -744,13 +744,13 @@ void CFX_TxtBreak::EndBreak_BidiLine(CFX_TPOArray& tpos, uint32_t dwStatus) {
FX_TPO tpo;
CFX_TxtChar* pTC;
int32_t i, j;
- CFX_TxtCharArray& chars = *m_pCurLine->m_pLineChars.get();
+ std::vector<CFX_TxtChar>& chars = *m_pCurLine->m_pLineChars.get();
int32_t iCount = m_pCurLine->CountChars();
bool bDone = (m_pCurLine->m_iArabicChars > 0 || m_bCurRTL);
if (!m_bPagination && bDone) {
int32_t iBidiNum = 0;
for (i = 0; i < iCount; i++) {
- pTC = chars.GetDataPtr(i);
+ pTC = &chars[i];
pTC->m_iBidiPos = i;
if (pTC->GetCharType() != FX_CHARTYPE_Control) {
iBidiNum = i;
@@ -770,7 +770,7 @@ void CFX_TxtBreak::EndBreak_BidiLine(CFX_TPOArray& tpos, uint32_t dwStatus) {
int32_t iBidiLevel = -1, iCharWidth;
i = 0, j = -1;
while (i < iCount) {
- pTC = chars.GetDataPtr(i);
+ pTC = &chars[i];
if (iBidiLevel < 0) {
iBidiLevel = pTC->m_iBidiLevel;
tp.m_iWidth = 0;
@@ -837,7 +837,7 @@ void CFX_TxtBreak::EndBreak_BidiLine(CFX_TPOArray& tpos, uint32_t dwStatus) {
tp.m_iChars = iCount;
tp.m_pChars = m_pCurLine->m_pLineChars.get();
tp.m_pUserData = m_pUserData;
- pTC = chars.GetDataPtr(0);
+ pTC = &chars[0];
tp.m_dwCharStyles = pTC->m_dwCharStyles;
tp.m_iHorizontalScale = pTC->m_iHorizontalScale;
tp.m_iVerticalScale = pTC->m_iVertialScale;
@@ -1006,11 +1006,11 @@ EndBreak_Ret:
return dwStatus;
}
-int32_t CFX_TxtBreak::GetBreakPos(CFX_TxtCharArray& ca,
+int32_t CFX_TxtBreak::GetBreakPos(std::vector<CFX_TxtChar>& ca,
int32_t& iEndPos,
bool bAllChars,
bool bOnlyBrk) {
- int32_t iLength = ca.GetSize() - 1;
+ int32_t iLength = pdfium::CollectionSize<int32_t>(ca) - 1;
if (iLength < 1) {
return iLength;
}
@@ -1027,7 +1027,7 @@ int32_t CFX_TxtBreak::GetBreakPos(CFX_TxtCharArray& ca,
bool bNumberBreak = (m_dwPolicies & FX_TXTBREAKPOLICY_NumberBreak) != 0;
FX_LINEBREAKTYPE eType;
uint32_t nCodeProp, nCur, nNext;
- CFX_Char* pCur = ca.GetDataPtr(iLength--);
+ CFX_Char* pCur = &ca[iLength--];
if (bAllChars) {
pCur->m_nBreakType = FX_LBT_UNKNOWN;
}
@@ -1038,7 +1038,7 @@ int32_t CFX_TxtBreak::GetBreakPos(CFX_TxtCharArray& ca,
iEndPos -= iCharWidth;
}
while (iLength >= 0) {
- pCur = ca.GetDataPtr(iLength);
+ pCur = &ca[iLength];
nCodeProp = pCur->m_dwCharProps;
nCur = nCodeProp & 0x003F;
if (nCur == FX_CBP_SP) {
@@ -1112,7 +1112,7 @@ void CFX_TxtBreak::SplitTextLine(CFX_TxtLine* pCurLine,
return;
}
int32_t iEndPos = pCurLine->m_iWidth;
- CFX_TxtCharArray& curChars = *pCurLine->m_pLineChars.get();
+ std::vector<CFX_TxtChar>& curChars = *pCurLine->m_pLineChars;
int32_t iCharPos = GetBreakPos(curChars, iEndPos, bAllChars, false);
if (iCharPos < 0) {
iCharPos = 0;
@@ -1120,36 +1120,30 @@ void CFX_TxtBreak::SplitTextLine(CFX_TxtLine* pCurLine,
iCharPos++;
if (iCharPos >= iCount) {
pNextLine->RemoveAll(true);
- CFX_Char* pTC = curChars.GetDataPtr(iCharPos - 1);
+ CFX_Char* pTC = &curChars[iCharPos - 1];
pTC->m_nBreakType = FX_LBT_UNKNOWN;
return;
}
- CFX_TxtCharArray& nextChars = *pNextLine->m_pLineChars.get();
- int cur_size = curChars.GetSize();
- nextChars.SetSize(cur_size - iCharPos);
- FXSYS_memcpy(nextChars.GetData(), curChars.GetDataPtr(iCharPos),
- (cur_size - iCharPos) * sizeof(CFX_TxtChar));
- iCount -= iCharPos;
- cur_size = curChars.GetSize();
- curChars.RemoveAt(cur_size - iCount, iCount);
+ std::vector<CFX_TxtChar>& nextChars = *pNextLine->m_pLineChars;
+ nextChars =
+ std::vector<CFX_TxtChar>(curChars.begin() + iCharPos, curChars.end());
+ curChars.erase(curChars.begin() + iCharPos, curChars.end());
pCurLine->m_iWidth = iEndPos;
- CFX_TxtChar* pTC = curChars.GetDataPtr(iCharPos - 1);
+ CFX_TxtChar* pTC = &curChars[iCharPos - 1];
pTC->m_nBreakType = FX_LBT_UNKNOWN;
- iCount = nextChars.GetSize();
- int32_t iCharWidth, iWidth = 0;
+ iCount = pdfium::CollectionSize<int>(nextChars);
+ int32_t iWidth = 0;
for (int32_t i = 0; i < iCount; i++) {
- pTC = nextChars.GetDataPtr(i);
+ pTC = &nextChars[i];
if (pTC->GetCharType() >= FX_CHARTYPE_ArabicAlef) {
pCurLine->m_iArabicChars--;
pNextLine->m_iArabicChars++;
}
- iCharWidth = pTC->m_iCharWidth;
- if (iCharWidth > 0) {
+ int32_t iCharWidth = pTC->m_iCharWidth;
+ if (iCharWidth > 0)
iWidth += iCharWidth;
- }
- if (m_bPagination) {
+ if (m_bPagination)
continue;
- }
pTC->m_dwStatus = 0;
}
pNextLine->m_iWidth = iWidth;
@@ -1732,7 +1726,7 @@ CFX_TxtPiece::CFX_TxtPiece()
m_pUserData(nullptr) {}
CFX_TxtLine::CFX_TxtLine(int32_t iBlockSize)
- : m_pLineChars(new CFX_TxtCharArray),
+ : m_pLineChars(new std::vector<CFX_TxtChar>),
m_pLinePieces(new CFX_TxtPieceArray(16)),
m_iStart(0),
m_iWidth(0),
diff --git a/xfa/fgas/layout/fgas_textbreak.h b/xfa/fgas/layout/fgas_textbreak.h
index ea86079ac3..19f1050039 100644
--- a/xfa/fgas/layout/fgas_textbreak.h
+++ b/xfa/fgas/layout/fgas_textbreak.h
@@ -12,6 +12,7 @@
#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"
@@ -117,16 +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);
- *pText++ = (FX_WCHAR)pChar->m_wCharCode;
- }
+ for (int32_t i = m_iStartChar; i < iEndChar; i++)
+ *pText++ = static_cast<FX_WCHAR>((*m_pChars)[i].m_wCharCode);
}
void GetString(CFX_WideString& wsText) const {
FX_WCHAR* pText = wsText.GetBuffer(m_iChars);
@@ -136,11 +134,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);
- *pWidths++ = pChar->m_iCharWidth;
- }
+ for (int32_t i = m_iStartChar; i < iEndChar; i++)
+ *pWidths++ = (*m_pChars)[i].m_iCharWidth;
}
uint32_t m_dwStatus;
@@ -153,7 +148,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;
};
@@ -164,34 +159,38 @@ 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 {
ASSERT(index > -1 && index < m_pLinePieces->GetSize());
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);
- *pBuf++ = (FX_WCHAR)pChar->m_wCharCode;
- }
+ for (int32_t i = 0; i < iCount; i++)
+ *pBuf++ = static_cast<FX_WCHAR>((*m_pLineChars)[i].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;
@@ -261,7 +260,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);