summaryrefslogtreecommitdiff
path: root/xfa
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2017-03-27 14:54:59 -0700
committerChromium commit bot <commit-bot@chromium.org>2017-03-28 14:22:30 +0000
commit35db73cc3ea42cfa690ebc5c283d7bc5f062aba9 (patch)
treeef68636d6cc5cf8e96054bdbb15b0f62f5819412 /xfa
parent0004f29bf6ee3c6060a272c79f14993e92e053c7 (diff)
downloadpdfium-35db73cc3ea42cfa690ebc5c283d7bc5f062aba9.tar.xz
use std::vector for m_rgSpecifiedColumnWidths
Change-Id: I8cb6f016403febc47df1df21e9b68c8a6348e647 Reviewed-on: https://pdfium-review.googlesource.com/3236 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'xfa')
-rw-r--r--xfa/fxfa/parser/xfa_layout_itemlayout.cpp42
-rw-r--r--xfa/fxfa/parser/xfa_layout_itemlayout.h4
2 files changed, 26 insertions, 20 deletions
diff --git a/xfa/fxfa/parser/xfa_layout_itemlayout.cpp b/xfa/fxfa/parser/xfa_layout_itemlayout.cpp
index 0c393b8df0..63cd50ac19 100644
--- a/xfa/fxfa/parser/xfa_layout_itemlayout.cpp
+++ b/xfa/fxfa/parser/xfa_layout_itemlayout.cpp
@@ -145,10 +145,9 @@ CFX_SizeF CalculateContainerComponentSizeFromContentSize(
return componentSize;
}
-void RelocateTableRowCells(
- CXFA_ContentLayoutItem* pLayoutRow,
- const CFX_ArrayTemplate<float>& rgSpecifiedColumnWidths,
- XFA_ATTRIBUTEENUM eLayout) {
+void RelocateTableRowCells(CXFA_ContentLayoutItem* pLayoutRow,
+ const std::vector<float>& rgSpecifiedColumnWidths,
+ XFA_ATTRIBUTEENUM eLayout) {
bool bContainerWidthAutoSize = true;
bool bContainerHeightAutoSize = true;
CFX_SizeF containerSize = CalculateContainerSpecifiedSize(
@@ -191,8 +190,10 @@ void RelocateTableRowCells(
int32_t nColSpan = nOriginalColSpan;
float fColSpanWidth = 0;
if (nColSpan == -1 ||
- nCurrentColIdx + nColSpan > rgSpecifiedColumnWidths.GetSize()) {
- nColSpan = rgSpecifiedColumnWidths.GetSize() - nCurrentColIdx;
+ nCurrentColIdx + nColSpan >
+ pdfium::CollectionSize<int32_t>(rgSpecifiedColumnWidths)) {
+ nColSpan = pdfium::CollectionSize<int32_t>(rgSpecifiedColumnWidths) -
+ nCurrentColIdx;
}
for (int32_t i = 0; i < nColSpan; i++)
fColSpanWidth += rgSpecifiedColumnWidths[nCurrentColIdx + i];
@@ -1639,16 +1640,18 @@ void CXFA_ItemLayoutProcessor::DoLayoutPositionedContainer(
m_pCurChildNode, m_pPageMgr);
if (pContext && pContext->m_prgSpecifiedColumnWidths) {
int32_t iColSpan = m_pCurChildNode->GetInteger(XFA_ATTRIBUTE_ColSpan);
- if (iColSpan <=
- pContext->m_prgSpecifiedColumnWidths->GetSize() - iColIndex) {
+ if (iColSpan <= pdfium::CollectionSize<int32_t>(
+ *pContext->m_prgSpecifiedColumnWidths) -
+ iColIndex) {
pContext->m_fCurColumnWidth = 0;
pContext->m_bCurColumnWidthAvaiable = true;
- if (iColSpan == -1)
- iColSpan = pContext->m_prgSpecifiedColumnWidths->GetSize();
-
+ if (iColSpan == -1) {
+ iColSpan = pdfium::CollectionSize<int32_t>(
+ *pContext->m_prgSpecifiedColumnWidths);
+ }
for (int32_t i = 0; iColIndex + i < iColSpan; ++i) {
pContext->m_fCurColumnWidth +=
- pContext->m_prgSpecifiedColumnWidths->GetAt(iColIndex + i);
+ (*pContext->m_prgSpecifiedColumnWidths)[iColIndex + i];
}
if (pContext->m_fCurColumnWidth == 0)
pContext->m_bCurColumnWidthAvaiable = false;
@@ -1749,12 +1752,13 @@ void CXFA_ItemLayoutProcessor::DoLayoutTableContainer(CXFA_Node* pLayoutNode) {
if (width.IsEmpty())
continue;
- CXFA_Measurement measure(width.AsStringC());
- m_rgSpecifiedColumnWidths.Add(measure.ToUnit(XFA_UNIT_Pt));
+ m_rgSpecifiedColumnWidths.push_back(
+ CXFA_Measurement(width.AsStringC()).ToUnit(XFA_UNIT_Pt));
}
}
- int32_t iSpecifiedColumnCount = m_rgSpecifiedColumnWidths.GetSize();
+ int32_t iSpecifiedColumnCount =
+ pdfium::CollectionSize<int32_t>(m_rgSpecifiedColumnWidths);
CXFA_LayoutContext layoutContext;
layoutContext.m_prgSpecifiedColumnWidths = &m_rgSpecifiedColumnWidths;
CXFA_LayoutContext* pLayoutContext =
@@ -1843,9 +1847,10 @@ void CXFA_ItemLayoutProcessor::DoLayoutTableContainer(CXFA_Node* pLayoutNode) {
continue;
if (iColCount >= iSpecifiedColumnCount) {
- int32_t c = iColCount + 1 - m_rgSpecifiedColumnWidths.GetSize();
+ int32_t c = iColCount + 1 - pdfium::CollectionSize<int32_t>(
+ m_rgSpecifiedColumnWidths);
for (int32_t j = 0; j < c; j++)
- m_rgSpecifiedColumnWidths.Add(0);
+ m_rgSpecifiedColumnWidths.push_back(0);
}
if (m_rgSpecifiedColumnWidths[iColCount] < XFA_LAYOUT_FLOAT_PERCISION)
bAutoCol = true;
@@ -1859,8 +1864,9 @@ void CXFA_ItemLayoutProcessor::DoLayoutTableContainer(CXFA_Node* pLayoutNode) {
continue;
float fFinalColumnWidth = 0.0f;
- if (iColCount < m_rgSpecifiedColumnWidths.GetSize())
+ if (pdfium::IndexInBounds(m_rgSpecifiedColumnWidths, iColCount))
fFinalColumnWidth = m_rgSpecifiedColumnWidths[iColCount];
+
for (int32_t i = 0; i < iRowCount; ++i) {
if (!rgRowItems[i])
continue;
diff --git a/xfa/fxfa/parser/xfa_layout_itemlayout.h b/xfa/fxfa/parser/xfa_layout_itemlayout.h
index 72cb235acb..9b8cd2f31a 100644
--- a/xfa/fxfa/parser/xfa_layout_itemlayout.h
+++ b/xfa/fxfa/parser/xfa_layout_itemlayout.h
@@ -56,7 +56,7 @@ class CXFA_LayoutContext {
m_pOverflowNode(nullptr) {}
~CXFA_LayoutContext() {}
- CFX_ArrayTemplate<float>* m_prgSpecifiedColumnWidths;
+ std::vector<float>* m_prgSpecifiedColumnWidths;
float m_fCurColumnWidth;
bool m_bCurColumnWidthAvaiable;
CXFA_ItemLayoutProcessor* m_pOverflowProcessor;
@@ -115,7 +115,7 @@ class CXFA_ItemLayoutProcessor {
CXFA_LayoutPageMgr* m_pPageMgr;
std::list<CXFA_Node*> m_PendingNodes;
bool m_bBreakPending;
- CFX_ArrayTemplate<float> m_rgSpecifiedColumnWidths;
+ std::vector<float> m_rgSpecifiedColumnWidths;
std::vector<CXFA_ContentLayoutItem*> m_arrayKeepItems;
float m_fLastRowWidth;
float m_fLastRowY;