summaryrefslogtreecommitdiff
path: root/xfa
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2017-01-24 06:12:34 -0800
committerCommit bot <commit-bot@chromium.org>2017-01-24 06:12:34 -0800
commit3d328767f9c0c04b62173aac03c35aab3fb87ffe (patch)
tree18a1a71ee987831e427b0dd62d26745861258a22 /xfa
parente73fea598f088151213fb11100798c615543ca2f (diff)
downloadpdfium-3d328767f9c0c04b62173aac03c35aab3fb87ffe.tar.xz
Use std::vector for CFX_RectF arrays
Review-Url: https://codereview.chromium.org/2653743002
Diffstat (limited to 'xfa')
-rw-r--r--xfa/fde/cfde_txtedtpage.cpp36
-rw-r--r--xfa/fde/cfde_txtedtpage.h2
-rw-r--r--xfa/fde/cfde_txtedttextset.cpp2
-rw-r--r--xfa/fde/cfde_txtedttextset.h4
-rw-r--r--xfa/fde/fde_visualset.h4
-rw-r--r--xfa/fde/ifde_txtedtpage.h4
-rw-r--r--xfa/fde/tto/fde_textout.cpp6
-rw-r--r--xfa/fde/tto/fde_textout.h2
-rw-r--r--xfa/fgas/layout/fgas_rtfbreak.cpp10
-rw-r--r--xfa/fgas/layout/fgas_rtfbreak.h2
-rw-r--r--xfa/fgas/layout/fgas_textbreak.cpp10
-rw-r--r--xfa/fgas/layout/fgas_textbreak.h3
-rw-r--r--xfa/fwl/cfwl_edit.cpp26
13 files changed, 58 insertions, 53 deletions
diff --git a/xfa/fde/cfde_txtedtpage.cpp b/xfa/fde/cfde_txtedtpage.cpp
index 238dba2bcc..a049548269 100644
--- a/xfa/fde/cfde_txtedtpage.cpp
+++ b/xfa/fde/cfde_txtedtpage.cpp
@@ -9,6 +9,7 @@
#include <algorithm>
#include "third_party/base/ptr_util.h"
+#include "third_party/base/stl_util.h"
#include "xfa/fde/cfde_txtedtbuf.h"
#include "xfa/fde/cfde_txtedtengine.h"
#include "xfa/fde/cfde_txtedtparag.h"
@@ -71,8 +72,8 @@ int32_t CFDE_TxtEdtPage::GetCharRect(int32_t nIndex,
const FDE_TEXTEDITPIECE* pPiece = m_PieceMassArr.GetPtrAt(i);
if (nIndex >= pPiece->nStart &&
nIndex < (pPiece->nStart + pPiece->nCount)) {
- CFX_RectFArray rectArr;
- m_pTextSet->GetCharRects(pPiece, rectArr, bBBox);
+ std::vector<CFX_RectF> rectArr;
+ m_pTextSet->GetCharRects(pPiece, &rectArr, bBBox);
rect = rectArr[nIndex - pPiece->nStart];
return pPiece->nBidiLevel;
}
@@ -113,9 +114,9 @@ int32_t CFDE_TxtEdtPage::GetCharIndex(const CFX_PointF& fPoint, bool& bBefore) {
pPiece = m_PieceMassArr.GetPtrAt(i);
nCaret = m_nPageStart + pPiece->nStart;
if (pPiece->rtPiece.Contains(ptF)) {
- CFX_RectFArray rectArr;
- m_pTextSet->GetCharRects(pPiece, rectArr, false);
- int32_t nRtCount = rectArr.GetSize();
+ std::vector<CFX_RectF> rectArr;
+ m_pTextSet->GetCharRects(pPiece, &rectArr, false);
+ int32_t nRtCount = pdfium::CollectionSize<int32_t>(rectArr);
for (int32_t j = 0; j < nRtCount; j++) {
if (rectArr[j].Contains(ptF)) {
nCaret = m_nPageStart + pPiece->nStart + j;
@@ -184,9 +185,10 @@ int32_t CFDE_TxtEdtPage::GetDisplayPos(const CFX_RectF& rtClip,
return nCharPosCount;
}
-void CFDE_TxtEdtPage::CalcRangeRectArray(int32_t nStart,
- int32_t nCount,
- CFX_RectFArray& RectFArr) const {
+void CFDE_TxtEdtPage::CalcRangeRectArray(
+ int32_t nStart,
+ int32_t nCount,
+ std::vector<CFX_RectF>* pRectFArr) const {
int32_t nPieceCount = m_PieceMassArr.GetSize();
int32_t nEnd = nStart + nCount - 1;
bool bInRange = false;
@@ -200,26 +202,26 @@ void CFDE_TxtEdtPage::CalcRangeRectArray(int32_t nStart,
nRangeEnd = nEnd - piece->nStart;
bEnd = true;
}
- CFX_RectFArray rcArr;
- m_pTextSet->GetCharRects(piece, rcArr, false);
+ std::vector<CFX_RectF> rcArr;
+ m_pTextSet->GetCharRects(piece, &rcArr, false);
CFX_RectF rectPiece = rcArr[nStart - piece->nStart];
rectPiece.Union(rcArr[nRangeEnd]);
- RectFArr.Add(rectPiece);
- if (bEnd) {
+ pRectFArr->push_back(rectPiece);
+ if (bEnd)
return;
- }
+
bInRange = true;
}
} else {
if (nEnd >= piece->nStart && nEnd < (piece->nStart + piece->nCount)) {
- CFX_RectFArray rcArr;
- m_pTextSet->GetCharRects(piece, rcArr, false);
+ std::vector<CFX_RectF> rcArr;
+ m_pTextSet->GetCharRects(piece, &rcArr, false);
CFX_RectF rectPiece = rcArr[0];
rectPiece.Union(rcArr[nEnd - piece->nStart]);
- RectFArr.Add(rectPiece);
+ pRectFArr->push_back(rectPiece);
return;
}
- RectFArr.Add(piece->rtPiece);
+ pRectFArr->push_back(piece->rtPiece);
}
}
}
diff --git a/xfa/fde/cfde_txtedtpage.h b/xfa/fde/cfde_txtedtpage.h
index 5cb4501afc..57ade45bbc 100644
--- a/xfa/fde/cfde_txtedtpage.h
+++ b/xfa/fde/cfde_txtedtpage.h
@@ -30,7 +30,7 @@ class CFDE_TxtEdtPage : public IFDE_TxtEdtPage {
int32_t GetCharIndex(const CFX_PointF& fPoint, bool& bBefore) override;
void CalcRangeRectArray(int32_t nStart,
int32_t nCount,
- CFX_RectFArray& RectFArr) const override;
+ std::vector<CFX_RectF>* RectFArr) const override;
int32_t SelectWord(const CFX_PointF& fPoint, int32_t& nCount) override;
int32_t GetCharStart() const override;
int32_t GetCharCount() const override;
diff --git a/xfa/fde/cfde_txtedttextset.cpp b/xfa/fde/cfde_txtedttextset.cpp
index 4149a6df20..a885ad4508 100644
--- a/xfa/fde/cfde_txtedttextset.cpp
+++ b/xfa/fde/cfde_txtedttextset.cpp
@@ -76,7 +76,7 @@ int32_t CFDE_TxtEdtTextSet::GetDisplayPos(FDE_TEXTEDITPIECE* pPiece,
}
int32_t CFDE_TxtEdtTextSet::GetCharRects(const FDE_TEXTEDITPIECE* pPiece,
- CFX_RectFArray& rtArray,
+ std::vector<CFX_RectF>* rtArray,
bool bBBox) {
if (!pPiece)
return 0;
diff --git a/xfa/fde/cfde_txtedttextset.h b/xfa/fde/cfde_txtedttextset.h
index 6c6266642b..561419affe 100644
--- a/xfa/fde/cfde_txtedttextset.h
+++ b/xfa/fde/cfde_txtedttextset.h
@@ -7,6 +7,8 @@
#ifndef XFA_FDE_CFDE_TXTEDTTEXTSET_H_
#define XFA_FDE_CFDE_TXTEDTTEXTSET_H_
+#include <vector>
+
#include "xfa/fde/fde_visualset.h"
class CFDE_TxtEdtPage;
@@ -30,7 +32,7 @@ class CFDE_TxtEdtTextSet : public IFDE_TextSet {
bool bCharCode = false,
CFX_WideString* pWSForms = nullptr) override;
int32_t GetCharRects(const FDE_TEXTEDITPIECE* pPiece,
- CFX_RectFArray& rtArray,
+ std::vector<CFX_RectF>* rtArray,
bool bBBox) override;
private:
diff --git a/xfa/fde/fde_visualset.h b/xfa/fde/fde_visualset.h
index 8aef237ba1..30703e795a 100644
--- a/xfa/fde/fde_visualset.h
+++ b/xfa/fde/fde_visualset.h
@@ -7,6 +7,8 @@
#ifndef XFA_FDE_FDE_VISUALSET_H_
#define XFA_FDE_FDE_VISUALSET_H_
+#include <vector>
+
#include "core/fxcrt/cfx_retain_ptr.h"
#include "core/fxcrt/fx_coordinates.h"
#include "core/fxcrt/fx_system.h"
@@ -56,7 +58,7 @@ class IFDE_TextSet : public IFDE_VisualSet {
bool bCharCode = false,
CFX_WideString* pWSForms = nullptr) = 0;
virtual int32_t GetCharRects(const FDE_TEXTEDITPIECE* hText,
- CFX_RectFArray& rtArray,
+ std::vector<CFX_RectF>* rtArray,
bool bbox) = 0;
};
diff --git a/xfa/fde/ifde_txtedtpage.h b/xfa/fde/ifde_txtedtpage.h
index ecc7d1699e..0ab3897b3c 100644
--- a/xfa/fde/ifde_txtedtpage.h
+++ b/xfa/fde/ifde_txtedtpage.h
@@ -7,6 +7,8 @@
#ifndef XFA_FDE_IFDE_TXTEDTPAGE_H_
#define XFA_FDE_IFDE_TXTEDTPAGE_H_
+#include <vector>
+
#include "xfa/fde/fde_visualset.h"
#include "xfa/fgas/layout/fgas_textbreak.h"
@@ -24,7 +26,7 @@ class IFDE_TxtEdtPage : public IFDE_CanvasSet, public IFX_TxtAccess {
virtual int32_t GetCharIndex(const CFX_PointF& fPoint, bool& bBefore) = 0;
virtual void CalcRangeRectArray(int32_t nStart,
int32_t nCount,
- CFX_RectFArray& RectFArr) const = 0;
+ std::vector<CFX_RectF>* RectFArr) const = 0;
virtual int32_t SelectWord(const CFX_PointF& fPoint, int32_t& nCount) = 0;
virtual int32_t GetCharStart() const = 0;
virtual int32_t GetCharCount() const = 0;
diff --git a/xfa/fde/tto/fde_textout.cpp b/xfa/fde/tto/fde_textout.cpp
index 4d207fb734..ca5aa566e1 100644
--- a/xfa/fde/tto/fde_textout.cpp
+++ b/xfa/fde/tto/fde_textout.cpp
@@ -814,8 +814,8 @@ int32_t CFDE_TextOut::GetDisplayPos(FDE_TTOPIECE* pPiece) {
int32_t CFDE_TextOut::GetCharRects(const FDE_TTOPIECE* pPiece) {
FX_TXTRUN tr = ToTextRun(pPiece);
- m_rectArray.RemoveAll();
- return m_pTxtBreak->GetCharRects(&tr, m_rectArray);
+ m_rectArray.clear();
+ return m_pTxtBreak->GetCharRects(&tr, &m_rectArray);
}
FX_TXTRUN CFDE_TextOut::ToTextRun(const FDE_TTOPIECE* pPiece) {
@@ -886,7 +886,7 @@ void CFDE_TextOut::DrawLine(const FDE_TTOPIECE* pPiece, CFDE_Pen*& pPen) {
int32_t iCharIndex = m_hotKeys.GetAt(i);
if (iCharIndex >= pPiece->iStartChar &&
iCharIndex < pPiece->iStartChar + pPiece->iChars) {
- CFX_RectF rect = m_rectArray.GetAt(iCharIndex - pPiece->iStartChar);
+ CFX_RectF rect = m_rectArray[iCharIndex - pPiece->iStartChar];
if (bVertical) {
pt1.x = rect.left;
pt1.y = rect.top;
diff --git a/xfa/fde/tto/fde_textout.h b/xfa/fde/tto/fde_textout.h
index 084af42acf..e1eb71cf3b 100644
--- a/xfa/fde/tto/fde_textout.h
+++ b/xfa/fde/tto/fde_textout.h
@@ -180,7 +180,7 @@ class CFDE_TextOut {
std::vector<FXTEXT_CHARPOS> m_CharPos;
std::unique_ptr<CFDE_RenderDevice> m_pRenderDevice;
CFX_ArrayTemplate<int32_t> m_hotKeys;
- CFX_RectFArray m_rectArray;
+ std::vector<CFX_RectF> m_rectArray;
};
#endif // XFA_FDE_TTO_FDE_TEXTOUT_H_
diff --git a/xfa/fgas/layout/fgas_rtfbreak.cpp b/xfa/fgas/layout/fgas_rtfbreak.cpp
index f7ba0e72b9..52e6267ded 100644
--- a/xfa/fgas/layout/fgas_rtfbreak.cpp
+++ b/xfa/fgas/layout/fgas_rtfbreak.cpp
@@ -1415,7 +1415,7 @@ int32_t CFX_RTFBreak::GetDisplayPos(const FX_RTFTEXTOBJ* pText,
return iCount;
}
int32_t CFX_RTFBreak::GetCharRects(const FX_RTFTEXTOBJ* pText,
- CFX_RectFArray& rtArray,
+ std::vector<CFX_RectF>* rtArray,
bool bCharBBox) const {
if (!pText || pText->iLength < 1)
return 0;
@@ -1440,8 +1440,8 @@ int32_t CFX_RTFBreak::GetCharRects(const FX_RTFTEXTOBJ* pText,
FX_FLOAT fLeft = std::max(0.0f, bbox.left * fScale);
FX_FLOAT fHeight = FXSYS_fabs(bbox.height * fScale);
- rtArray.RemoveAll();
- rtArray.SetSize(iLength);
+ rtArray->clear();
+ rtArray->resize(iLength);
uint32_t dwStyles = pText->dwLayoutStyles;
bool bVertical = (dwStyles & FX_RTFLAYOUTSTYLE_VerticalLayout) != 0;
bool bSingleLine = (dwStyles & FX_RTFLAYOUTSTYLE_SingleLine) != 0;
@@ -1511,10 +1511,10 @@ int32_t CFX_RTFBreak::GetCharRects(const FX_RTFTEXTOBJ* pText,
rtBBoxF.height = fHeight;
rtBBoxF.top = std::max(rtBBoxF.top, 0.0f);
}
- rtArray.SetAt(i, rtBBoxF);
+ (*rtArray)[i] = rtBBoxF;
continue;
}
- rtArray.SetAt(i, rect);
+ (*rtArray)[i] = rect;
}
return iLength;
}
diff --git a/xfa/fgas/layout/fgas_rtfbreak.h b/xfa/fgas/layout/fgas_rtfbreak.h
index 91862dceeb..f3d2311a2c 100644
--- a/xfa/fgas/layout/fgas_rtfbreak.h
+++ b/xfa/fgas/layout/fgas_rtfbreak.h
@@ -252,7 +252,7 @@ class CFX_RTFBreak {
CFX_WideString* pWSForms = nullptr,
FX_AdjustCharDisplayPos pAdjustPos = nullptr) const;
int32_t GetCharRects(const FX_RTFTEXTOBJ* pText,
- CFX_RectFArray& rtArray,
+ std::vector<CFX_RectF>* rtArray,
bool bCharBBox = false) const;
uint32_t AppendChar_CharCode(FX_WCHAR wch);
uint32_t AppendChar_Combination(CFX_RTFChar* pCurChar, int32_t iRotation);
diff --git a/xfa/fgas/layout/fgas_textbreak.cpp b/xfa/fgas/layout/fgas_textbreak.cpp
index 35984f5017..50e3b063fd 100644
--- a/xfa/fgas/layout/fgas_textbreak.cpp
+++ b/xfa/fgas/layout/fgas_textbreak.cpp
@@ -1588,7 +1588,7 @@ int32_t CFX_TxtBreak::GetDisplayPos(const FX_TXTRUN* pTxtRun,
}
int32_t CFX_TxtBreak::GetCharRects(const FX_TXTRUN* pTxtRun,
- CFX_RectFArray& rtArray,
+ std::vector<CFX_RectF>* rtArray,
bool bCharBBox) const {
if (!pTxtRun || pTxtRun->iLength < 1)
return 0;
@@ -1614,8 +1614,8 @@ int32_t CFX_TxtBreak::GetCharRects(const FX_TXTRUN* pTxtRun,
FX_FLOAT fLeft = std::max(0.0f, bbox.left * fScale);
FX_FLOAT fHeight = FXSYS_fabs(bbox.height * fScale);
- rtArray.RemoveAll();
- rtArray.SetSize(iLength);
+ rtArray->clear();
+ rtArray->resize(iLength);
bool bVertical = (pTxtRun->dwStyles & FX_TXTLAYOUTSTYLE_VerticalLayout) != 0;
bool bSingleLine = (pTxtRun->dwStyles & FX_TXTLAYOUTSTYLE_SingleLine) != 0;
bool bCombText = (pTxtRun->dwStyles & FX_TXTLAYOUTSTYLE_CombText) != 0;
@@ -1689,10 +1689,10 @@ int32_t CFX_TxtBreak::GetCharRects(const FX_TXTRUN* pTxtRun,
rtBBoxF.height = fHeight;
rtBBoxF.top = std::max(rtBBoxF.top, 0.0f);
}
- rtArray.SetAt(i, rtBBoxF);
+ (*rtArray)[i] = rtBBoxF;
continue;
}
- rtArray.SetAt(i, rect);
+ (*rtArray)[i] = rect;
}
return iLength;
}
diff --git a/xfa/fgas/layout/fgas_textbreak.h b/xfa/fgas/layout/fgas_textbreak.h
index 7359600c14..ea86079ac3 100644
--- a/xfa/fgas/layout/fgas_textbreak.h
+++ b/xfa/fgas/layout/fgas_textbreak.h
@@ -8,6 +8,7 @@
#define XFA_FGAS_LAYOUT_FGAS_TEXTBREAK_H_
#include <memory>
+#include <vector>
#include "core/fxcrt/fx_ucd.h"
#include "core/fxge/cfx_renderdevice.h"
@@ -234,7 +235,7 @@ class CFX_TxtBreak {
CFX_WideString* pWSForms = nullptr,
FX_AdjustCharDisplayPos pAdjustPos = nullptr) const;
int32_t GetCharRects(const FX_TXTRUN* pTxtRun,
- CFX_RectFArray& rtArray,
+ std::vector<CFX_RectF>* rtArray,
bool bCharBBox = false) const;
void AppendChar_PageLoad(CFX_TxtChar* pCurChar, uint32_t dwProps);
uint32_t AppendChar_Combination(CFX_TxtChar* pCurChar, int32_t iRotation);
diff --git a/xfa/fwl/cfwl_edit.cpp b/xfa/fwl/cfwl_edit.cpp
index acd5672227..87a49e0f45 100644
--- a/xfa/fwl/cfwl_edit.cpp
+++ b/xfa/fwl/cfwl_edit.cpp
@@ -168,15 +168,14 @@ void CFWL_Edit::AddSpellCheckObj(CFX_Path& PathData,
FX_FLOAT fY = 0.0f;
FX_FLOAT fStep = 0.0f;
IFDE_TxtEdtPage* pPage = m_EdtEngine.GetPage(0);
- CFX_RectFArray rectArray;
- CFX_RectF rectText;
const FDE_TXTEDTPARAMS* txtEdtParams = m_EdtEngine.GetEditParams();
FX_FLOAT fAsent = static_cast<FX_FLOAT>(txtEdtParams->pFont->GetAscent()) *
txtEdtParams->fFontSize / 1000;
- pPage->CalcRangeRectArray(nStart, nCount, rectArray);
- for (int i = 0; i < rectArray.GetSize(); i++) {
- rectText = rectArray.GetAt(i);
+ std::vector<CFX_RectF> rectArray;
+ pPage->CalcRangeRectArray(nStart, nCount, &rectArray);
+
+ for (const auto& rectText : rectArray) {
fY = rectText.top + fAsent + fOffSetY;
fStep = txtEdtParams->fFontSize / 16.0f;
fStartX = rectText.left + fOffSetX;
@@ -541,9 +540,8 @@ void CFWL_Edit::DrawContent(CFX_Graphics* pGraphics,
int32_t nPageCharEnd = nPageCharStart + nPageCharCount - 1;
int32_t nCharCount;
int32_t nCharStart;
- CFX_RectFArray rectArr;
- int32_t i = 0;
- for (i = 0; i < nSelCount; i++) {
+ std::vector<CFX_RectF> rectArr;
+ for (int32_t i = 0; i < nSelCount; i++) {
nCharCount = m_EdtEngine.GetSelRange(i, &nCharStart);
int32_t nCharEnd = nCharStart + nCharCount - 1;
if (nCharEnd < nPageCharStart || nCharStart > nPageCharEnd)
@@ -552,17 +550,15 @@ void CFWL_Edit::DrawContent(CFX_Graphics* pGraphics,
int32_t nBgn = std::max(nCharStart, nPageCharStart);
int32_t nEnd = std::min(nCharEnd, nPageCharEnd);
pPage->CalcRangeRectArray(nBgn - nPageCharStart, nEnd - nBgn + 1,
- rectArr);
+ &rectArr);
}
- int32_t nCount = rectArr.GetSize();
CFX_Path path;
path.Create();
- for (i = 0; i < nCount; i++) {
- rectArr[i].left += fOffSetX;
- rectArr[i].top += fOffSetY;
- path.AddRectangle(rectArr[i].left, rectArr[i].top, rectArr[i].width,
- rectArr[i].height);
+ for (auto& rect : rectArr) {
+ rect.left += fOffSetX;
+ rect.top += fOffSetY;
+ path.AddRectangle(rect.left, rect.top, rect.width, rect.height);
}
pGraphics->SetClipRect(rtClip);