summaryrefslogtreecommitdiff
path: root/xfa/fxfa/app
diff options
context:
space:
mode:
Diffstat (limited to 'xfa/fxfa/app')
-rw-r--r--xfa/fxfa/app/xfa_ffwidgetacc.cpp59
-rw-r--r--xfa/fxfa/app/xfa_textlayout.cpp33
-rw-r--r--xfa/fxfa/app/xfa_textlayout.h3
3 files changed, 47 insertions, 48 deletions
diff --git a/xfa/fxfa/app/xfa_ffwidgetacc.cpp b/xfa/fxfa/app/xfa_ffwidgetacc.cpp
index d63a4f5151..e95c04b331 100644
--- a/xfa/fxfa/app/xfa_ffwidgetacc.cpp
+++ b/xfa/fxfa/app/xfa_ffwidgetacc.cpp
@@ -8,8 +8,10 @@
#include <algorithm>
#include <memory>
+#include <vector>
#include "fxjs/cfxjse_value.h"
+#include "third_party/base/stl_util.h"
#include "xfa/fde/tto/fde_textout.h"
#include "xfa/fde/xml/fde_xml_imp.h"
#include "xfa/fxfa/app/xfa_ffcheckbutton.h"
@@ -125,7 +127,7 @@ class CXFA_FieldLayoutData : public CXFA_WidgetLayoutData {
std::unique_ptr<CXFA_TextLayout> m_pCapTextLayout;
std::unique_ptr<CXFA_TextProvider> m_pCapTextProvider;
std::unique_ptr<CFDE_TextOut> m_pTextOut;
- std::unique_ptr<CFX_FloatArray> m_pFieldSplitArray;
+ std::vector<FX_FLOAT> m_FieldSplitArray;
};
class CXFA_TextEditData : public CXFA_FieldLayoutData {
@@ -1239,14 +1241,11 @@ bool CXFA_WidgetAcc::FindSplitPos(int32_t iBlockIndex, FX_FLOAT& fCalcHeight) {
}
iLinesCount = pFieldData->m_pTextOut->GetTotalLines();
}
- if (!pFieldData->m_pFieldSplitArray) {
- pFieldData->m_pFieldSplitArray.reset(new CFX_FloatArray);
- }
- CFX_FloatArray* pFieldArray = pFieldData->m_pFieldSplitArray.get();
- int32_t iFieldSplitCount = pFieldArray->GetSize();
+ std::vector<FX_FLOAT>* pFieldArray = &pFieldData->m_FieldSplitArray;
+ int32_t iFieldSplitCount = pdfium::CollectionSize<int32_t>(*pFieldArray);
for (int32_t i = 0; i < iBlockIndex * 3; i += 3) {
- iLinesCount -= (int32_t)pFieldArray->GetAt(i + 1);
- fHeight -= pFieldArray->GetAt(i + 2);
+ iLinesCount -= (int32_t)(*pFieldArray)[i + 1];
+ fHeight -= (*pFieldArray)[i + 2];
}
if (iLinesCount == 0) {
return false;
@@ -1275,20 +1274,18 @@ bool CXFA_WidgetAcc::FindSplitPos(int32_t iBlockIndex, FX_FLOAT& fCalcHeight) {
break;
}
}
- if (fStartOffset < 0.1f) {
+ if (fStartOffset < 0.1f)
fStartOffset = 0;
- }
}
for (int32_t i = iBlockIndex - 1; iBlockIndex > 0 && i < iBlockIndex; i++) {
- fStartOffset = pFieldArray->GetAt(i * 3) - pFieldArray->GetAt(i * 3 + 2);
- if (fStartOffset < 0.1f) {
+ fStartOffset = (*pFieldArray)[i * 3] - (*pFieldArray)[i * 3 + 2];
+ if (fStartOffset < 0.1f)
fStartOffset = 0;
- }
}
if (iFieldSplitCount / 3 == (iBlockIndex + 1)) {
- pFieldArray->SetAt(0, fStartOffset);
+ (*pFieldArray)[0] = fStartOffset;
} else {
- pFieldArray->Add(fStartOffset);
+ pFieldArray->push_back(fStartOffset);
}
XFA_VERSION version = GetDoc()->GetXFADoc()->GetCurVersionMode();
bool bCanSplitNoContent = false;
@@ -1321,22 +1318,22 @@ bool CXFA_WidgetAcc::FindSplitPos(int32_t iBlockIndex, FX_FLOAT& fCalcHeight) {
}
if (fStartOffset + XFA_FLOAT_PERCISION >= fCalcHeight) {
if (iFieldSplitCount / 3 == (iBlockIndex + 1)) {
- pFieldArray->SetAt(iBlockIndex * 3 + 1, 0);
- pFieldArray->SetAt(iBlockIndex * 3 + 2, fCalcHeight);
+ (*pFieldArray)[iBlockIndex * 3 + 1] = 0;
+ (*pFieldArray)[iBlockIndex * 3 + 2] = fCalcHeight;
} else {
- pFieldArray->Add(0);
- pFieldArray->Add(fCalcHeight);
+ pFieldArray->push_back(0);
+ pFieldArray->push_back(fCalcHeight);
}
return false;
}
if (fCalcHeight - fStartOffset < fLineHeight) {
fCalcHeight = fStartOffset;
if (iFieldSplitCount / 3 == (iBlockIndex + 1)) {
- pFieldArray->SetAt(iBlockIndex * 3 + 1, 0);
- pFieldArray->SetAt(iBlockIndex * 3 + 2, fCalcHeight);
+ (*pFieldArray)[iBlockIndex * 3 + 1] = 0;
+ (*pFieldArray)[iBlockIndex * 3 + 2] = fCalcHeight;
} else {
- pFieldArray->Add(0);
- pFieldArray->Add(fCalcHeight);
+ pFieldArray->push_back(0);
+ pFieldArray->push_back(fCalcHeight);
}
return true;
}
@@ -1347,11 +1344,11 @@ bool CXFA_WidgetAcc::FindSplitPos(int32_t iBlockIndex, FX_FLOAT& fCalcHeight) {
if (iLineNum >= iLinesCount) {
if (fCalcHeight - fStartOffset - fTextHeight >= fFontSize) {
if (iFieldSplitCount / 3 == (iBlockIndex + 1)) {
- pFieldArray->SetAt(iBlockIndex * 3 + 1, (FX_FLOAT)iLinesCount);
- pFieldArray->SetAt(iBlockIndex * 3 + 2, fCalcHeight);
+ (*pFieldArray)[iBlockIndex * 3 + 1] = (FX_FLOAT)iLinesCount;
+ (*pFieldArray)[iBlockIndex * 3 + 2] = fCalcHeight;
} else {
- pFieldArray->Add((FX_FLOAT)iLinesCount);
- pFieldArray->Add(fCalcHeight);
+ pFieldArray->push_back((FX_FLOAT)iLinesCount);
+ pFieldArray->push_back(fCalcHeight);
}
return false;
}
@@ -1369,11 +1366,11 @@ bool CXFA_WidgetAcc::FindSplitPos(int32_t iBlockIndex, FX_FLOAT& fCalcHeight) {
FX_FLOAT fSplitHeight =
iLineNum * fLineHeight + fCapReserve + fStartOffset;
if (iFieldSplitCount / 3 == (iBlockIndex + 1)) {
- pFieldArray->SetAt(iBlockIndex * 3 + 1, (FX_FLOAT)iLineNum);
- pFieldArray->SetAt(iBlockIndex * 3 + 2, fSplitHeight);
+ (*pFieldArray)[iBlockIndex * 3 + 1] = (FX_FLOAT)iLineNum;
+ (*pFieldArray)[iBlockIndex * 3 + 2] = fSplitHeight;
} else {
- pFieldArray->Add((FX_FLOAT)iLineNum);
- pFieldArray->Add(fSplitHeight);
+ pFieldArray->push_back((FX_FLOAT)iLineNum);
+ pFieldArray->push_back(fSplitHeight);
}
if (fabs(fSplitHeight - fCalcHeight) < XFA_FLOAT_PERCISION) {
return false;
diff --git a/xfa/fxfa/app/xfa_textlayout.cpp b/xfa/fxfa/app/xfa_textlayout.cpp
index 345fc272e3..2a7161333e 100644
--- a/xfa/fxfa/app/xfa_textlayout.cpp
+++ b/xfa/fxfa/app/xfa_textlayout.cpp
@@ -9,6 +9,7 @@
#include <algorithm>
#include "core/fxcrt/fx_ext.h"
+#include "third_party/base/stl_util.h"
#include "xfa/fde/cfde_path.h"
#include "xfa/fde/css/fde_csscache.h"
#include "xfa/fde/css/fde_cssstyleselector.h"
@@ -1004,10 +1005,9 @@ bool CXFA_TextLayout::DoLayout(int32_t iBlockIndex,
iLineIndex = m_Blocks.ElementAt(iBlockCount - 1) +
m_Blocks.ElementAt(iBlockCount - 2);
}
- if (m_pLoader->m_BlocksHeight.GetSize() > 0) {
- for (int32_t i = 0; i < iBlockIndex; i++) {
- fLinePos -= m_pLoader->m_BlocksHeight.ElementAt(i * 2 + 1);
- }
+ if (!m_pLoader->m_BlocksHeight.empty()) {
+ for (int32_t i = 0; i < iBlockIndex; i++)
+ fLinePos -= m_pLoader->m_BlocksHeight[i * 2 + 1];
}
}
int32_t iCount = m_pLoader->m_lineHeights.GetSize();
@@ -1028,13 +1028,13 @@ bool CXFA_TextLayout::DoLayout(int32_t iBlockIndex,
}
if (i == iLineIndex) {
if (fCalcHeight <= fLinePos) {
- if (m_pLoader->m_BlocksHeight.GetSize() > iBlockIndex * 2 &&
- (m_pLoader->m_BlocksHeight.GetAt(iBlockIndex * 2) ==
- iBlockIndex)) {
- m_pLoader->m_BlocksHeight.SetAt(iBlockIndex * 2 + 1, fCalcHeight);
+ if (pdfium::CollectionSize<int32_t>(m_pLoader->m_BlocksHeight) >
+ iBlockIndex * 2 &&
+ (m_pLoader->m_BlocksHeight[iBlockIndex * 2] == iBlockIndex)) {
+ m_pLoader->m_BlocksHeight[iBlockIndex * 2 + 1] = fCalcHeight;
} else {
- m_pLoader->m_BlocksHeight.Add((FX_FLOAT)iBlockIndex);
- m_pLoader->m_BlocksHeight.Add(fCalcHeight);
+ m_pLoader->m_BlocksHeight.push_back((FX_FLOAT)iBlockIndex);
+ m_pLoader->m_BlocksHeight.push_back(fCalcHeight);
}
}
return true;
@@ -1103,7 +1103,8 @@ bool CXFA_TextLayout::Layout(int32_t iBlock) {
CXFA_Node* pNode = nullptr;
CFX_SizeF szText(m_pLoader->m_fWidth, m_pLoader->m_fHeight);
int32_t iCount = m_Blocks.GetSize();
- int32_t iBlocksHeightCount = m_pLoader->m_BlocksHeight.GetSize();
+ int32_t iBlocksHeightCount =
+ pdfium::CollectionSize<int32_t>(m_pLoader->m_BlocksHeight);
iBlocksHeightCount /= 2;
if (iBlock < iBlocksHeightCount)
return true;
@@ -1112,7 +1113,7 @@ bool CXFA_TextLayout::Layout(int32_t iBlock) {
m_pBreak.reset(CreateBreak(true));
fLinePos = m_pLoader->m_fStartLineOffset;
for (int32_t i = 0; i < iBlocksHeightCount; i++) {
- fLinePos -= m_pLoader->m_BlocksHeight.ElementAt(i * 2 + 1);
+ fLinePos -= m_pLoader->m_BlocksHeight[i * 2 + 1];
}
m_pLoader->m_iChar = 0;
if (iCount > 1)
@@ -1187,17 +1188,17 @@ void CXFA_TextLayout::ItemBlocks(const CFX_RectF& rtText, int32_t iBlockIndex) {
FX_FLOAT fLinePos = m_pLoader->m_fStartLineOffset;
int32_t iLineIndex = 0;
if (iBlockIndex > 0) {
- int32_t iBlockHeightCount = m_pLoader->m_BlocksHeight.GetSize();
+ int32_t iBlockHeightCount =
+ pdfium::CollectionSize<int32_t>(m_pLoader->m_BlocksHeight);
iBlockHeightCount /= 2;
if (iBlockHeightCount >= iBlockIndex) {
for (int32_t i = 0; i < iBlockIndex; i++) {
- fLinePos -= m_pLoader->m_BlocksHeight.ElementAt(i * 2 + 1);
+ fLinePos -= m_pLoader->m_BlocksHeight[i * 2 + 1];
}
} else {
fLinePos = 0;
}
- iLineIndex = m_Blocks.ElementAt(iBlockCount - 1) +
- m_Blocks.ElementAt(iBlockCount - 2);
+ iLineIndex = m_Blocks[iBlockCount - 1] + m_Blocks[iBlockCount - 2];
}
int32_t i = 0;
for (i = iLineIndex; i < iCountHeight; i++) {
diff --git a/xfa/fxfa/app/xfa_textlayout.h b/xfa/fxfa/app/xfa_textlayout.h
index b299f52904..26bd1634ee 100644
--- a/xfa/fxfa/app/xfa_textlayout.h
+++ b/xfa/fxfa/app/xfa_textlayout.h
@@ -9,6 +9,7 @@
#include <map>
#include <memory>
+#include <vector>
#include "xfa/fde/css/fde_css.h"
#include "xfa/fde/fde_gedevice.h"
@@ -155,7 +156,7 @@ class CXFA_LoaderContext {
IFDE_CSSComputedStyle* m_pParentStyle;
CFX_ArrayTemplate<FX_FLOAT> m_lineHeights;
uint32_t m_dwFlags;
- CFX_FloatArray m_BlocksHeight;
+ std::vector<FX_FLOAT> m_BlocksHeight;
};
class CXFA_LinkUserData : public IFX_Retainable, public CFX_Target {