summaryrefslogtreecommitdiff
path: root/xfa/fgas/layout/fgas_rtfbreak.cpp
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2017-03-01 14:41:25 -0800
committerChromium commit bot <commit-bot@chromium.org>2017-03-02 14:08:12 +0000
commit4a21114e3a95d3798c5027de33b8e90550fc0eb7 (patch)
tree493a167f34a0116e9b5c93bddf2b36e5ca70f5aa /xfa/fgas/layout/fgas_rtfbreak.cpp
parent65ec174225546abdc977c8f4c92e792e44ca4e0a (diff)
downloadpdfium-4a21114e3a95d3798c5027de33b8e90550fc0eb7.tar.xz
Use std::deque for CFX_TPOArray
They both encompass the same concept: a segmented array that can grow without copying. Change-Id: Ifc02207385b1bc106df41932c7b78ec2e9cc2146 Reviewed-on: https://pdfium-review.googlesource.com/2894 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'xfa/fgas/layout/fgas_rtfbreak.cpp')
-rw-r--r--xfa/fgas/layout/fgas_rtfbreak.cpp26
1 files changed, 11 insertions, 15 deletions
diff --git a/xfa/fgas/layout/fgas_rtfbreak.cpp b/xfa/fgas/layout/fgas_rtfbreak.cpp
index 648897818f..9a83be65ac 100644
--- a/xfa/fgas/layout/fgas_rtfbreak.cpp
+++ b/xfa/fgas/layout/fgas_rtfbreak.cpp
@@ -13,7 +13,6 @@
#include "third_party/base/stl_util.h"
#include "xfa/fgas/font/cfgas_gefont.h"
#include "xfa/fgas/layout/fgas_linebreak.h"
-#include "xfa/fgas/layout/fgas_unicode.h"
namespace {
@@ -433,14 +432,13 @@ CFX_RTFBreakType CFX_RTFBreak::EndBreak(CFX_RTFBreakType dwStatus) {
m_pCurLine == &m_RTFLine1 ? &m_RTFLine2 : &m_RTFLine1;
bool bAllChars = m_iAlignment == CFX_RTFLineAlignment::Justified ||
m_iAlignment == CFX_RTFLineAlignment::Distributed;
- CFX_TPOArray tpos(100);
+
if (!EndBreak_SplitLine(pNextLine, bAllChars, dwStatus)) {
+ std::deque<FX_TPO> tpos;
EndBreak_BidiLine(&tpos, dwStatus);
-
if (!m_bPagination && m_iAlignment != CFX_RTFLineAlignment::Left)
EndBreak_Alignment(tpos, bAllChars, dwStatus);
}
-
m_pCurLine = pNextLine;
m_pCurLine->m_iStart = m_iBoundaryStart;
@@ -521,7 +519,7 @@ bool CFX_RTFBreak::EndBreak_SplitLine(CFX_RTFLine* pNextLine,
return true;
}
-void CFX_RTFBreak::EndBreak_BidiLine(CFX_TPOArray* tpos,
+void CFX_RTFBreak::EndBreak_BidiLine(std::deque<FX_TPO>* tpos,
CFX_RTFBreakType dwStatus) {
FX_TPO tpo;
CFX_RTFPiece tp;
@@ -584,7 +582,7 @@ void CFX_RTFBreak::EndBreak_BidiLine(CFX_TPOArray* tpos,
tp.m_iStartChar = i;
tpo.index = j++;
tpo.pos = tp.m_iBidiPos;
- tpos->Add(tpo);
+ tpos->push_back(tpo);
iBidiLevel = -1;
} else {
iCharWidth = pTC->m_iCharWidth;
@@ -600,21 +598,19 @@ void CFX_RTFBreak::EndBreak_BidiLine(CFX_TPOArray* tpos,
pCurPieces->Add(tp);
tpo.index = j;
tpo.pos = tp.m_iBidiPos;
- tpos->Add(tpo);
+ tpos->push_back(tpo);
}
- j = tpos->GetSize() - 1;
- FX_TEXTLAYOUT_PieceSort(*tpos, 0, j);
+ std::sort(tpos->begin(), tpos->end());
int32_t iStartPos = m_pCurLine->m_iStart;
- for (i = 0; i <= j; i++) {
- tpo = tpos->GetAt(i);
- CFX_RTFPiece& ttp = pCurPieces->GetAt(tpo.index);
+ for (const auto& it : *tpos) {
+ CFX_RTFPiece& ttp = pCurPieces->GetAt(it.index);
ttp.m_iStartPos = iStartPos;
iStartPos += ttp.m_iWidth;
}
}
-void CFX_RTFBreak::EndBreak_Alignment(const CFX_TPOArray& tpos,
+void CFX_RTFBreak::EndBreak_Alignment(const std::deque<FX_TPO>& tpos,
bool bAllChars,
CFX_RTFBreakType dwStatus) {
CFX_RTFPieceArray* pCurPieces = &m_pCurLine->m_LinePieces;
@@ -628,7 +624,7 @@ void CFX_RTFBreak::EndBreak_Alignment(const CFX_TPOArray& tpos,
int32_t j;
FX_TPO tpo;
for (i = iCount - 1; i > -1; i--) {
- tpo = tpos.GetAt(i);
+ tpo = tpos[i];
CFX_RTFPiece& ttp = pCurPieces->GetAt(tpo.index);
if (!bFind)
iNetWidth = ttp.GetEndPos();
@@ -667,7 +663,7 @@ void CFX_RTFBreak::EndBreak_Alignment(const CFX_TPOArray& tpos,
dwStatus != CFX_RTFBreakType::Paragraph))) {
int32_t iStart = -1;
for (i = 0; i < iCount; i++) {
- tpo = tpos.GetAt(i);
+ tpo = tpos[i];
CFX_RTFPiece& ttp = pCurPieces->GetAt(tpo.index);
if (iStart < 0)
iStart = ttp.m_iStartPos;