summaryrefslogtreecommitdiff
path: root/xfa
diff options
context:
space:
mode:
Diffstat (limited to 'xfa')
-rw-r--r--xfa/fxfa/cxfa_ffnotify.cpp6
-rw-r--r--xfa/fxfa/cxfa_ffnotify.h4
-rw-r--r--xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp20
-rw-r--r--xfa/fxfa/parser/cxfa_node.cpp127
-rw-r--r--xfa/fxfa/parser/cxfa_node.h12
5 files changed, 84 insertions, 85 deletions
diff --git a/xfa/fxfa/cxfa_ffnotify.cpp b/xfa/fxfa/cxfa_ffnotify.cpp
index 5aca631914..a3e082681e 100644
--- a/xfa/fxfa/cxfa_ffnotify.cpp
+++ b/xfa/fxfa/cxfa_ffnotify.cpp
@@ -194,9 +194,9 @@ CXFA_ContentLayoutItem* CXFA_FFNotify::OnCreateContentLayoutItem(
}
void CXFA_FFNotify::StartFieldDrawLayout(CXFA_Node* pItem,
- float& fCalcWidth,
- float& fCalcHeight) {
- pItem->StartWidgetLayout(m_pDoc.Get(), fCalcWidth, fCalcHeight);
+ float* pCalcWidth,
+ float* pCalcHeight) {
+ pItem->StartWidgetLayout(m_pDoc.Get(), pCalcWidth, pCalcHeight);
}
bool CXFA_FFNotify::RunScript(CXFA_Script* script, CXFA_Node* item) {
diff --git a/xfa/fxfa/cxfa_ffnotify.h b/xfa/fxfa/cxfa_ffnotify.h
index e61b00ebfe..cdb43b71d2 100644
--- a/xfa/fxfa/cxfa_ffnotify.h
+++ b/xfa/fxfa/cxfa_ffnotify.h
@@ -50,8 +50,8 @@ class CXFA_FFNotify {
CXFA_LayoutItem* pSender);
void StartFieldDrawLayout(CXFA_Node* pItem,
- float& fCalcWidth,
- float& fCalcHeight);
+ float* pCalcWidth,
+ float* pCalcHeight);
bool RunScript(CXFA_Script* pScript, CXFA_Node* pFormItem);
int32_t ExecEventByDeepFirst(CXFA_Node* pFormNode,
XFA_EVENTTYPE eEventType,
diff --git a/xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp b/xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp
index e9843fbf99..7273adf337 100644
--- a/xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp
+++ b/xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp
@@ -60,24 +60,24 @@ std::vector<WideString> SeparateStringW(const wchar_t* pStr,
}
void UpdateWidgetSize(CXFA_ContentLayoutItem* pLayoutItem,
- float* fWidth,
- float* fHeight) {
+ float* pWidth,
+ float* pHeight) {
CXFA_Node* pNode = pLayoutItem->m_pFormNode;
switch (pNode->GetElementType()) {
case XFA_Element::Subform:
case XFA_Element::Area:
case XFA_Element::ExclGroup:
case XFA_Element::SubformSet: {
- if (*fWidth < -XFA_LAYOUT_FLOAT_PERCISION)
- *fWidth = pLayoutItem->m_sSize.width;
- if (*fHeight < -XFA_LAYOUT_FLOAT_PERCISION)
- *fHeight = pLayoutItem->m_sSize.height;
+ if (*pWidth < -XFA_LAYOUT_FLOAT_PERCISION)
+ *pWidth = pLayoutItem->m_sSize.width;
+ if (*pHeight < -XFA_LAYOUT_FLOAT_PERCISION)
+ *pHeight = pLayoutItem->m_sSize.height;
break;
}
case XFA_Element::Draw:
case XFA_Element::Field: {
- pNode->GetDocument()->GetNotify()->StartFieldDrawLayout(pNode, *fWidth,
- *fHeight);
+ pNode->GetDocument()->GetNotify()->StartFieldDrawLayout(pNode, pWidth,
+ pHeight);
break;
}
default:
@@ -494,7 +494,7 @@ bool FindLayoutItemSplitPos(CXFA_ContentLayoutItem* pLayoutItem,
{
float fRelSplitPos = *fProposedSplitPos - fCurVerticalOffset;
if (pFormNode->FindSplitPos(pNotify->GetHDOC()->GetDocView(),
- pLayoutItem->GetIndex(), fRelSplitPos)) {
+ pLayoutItem->GetIndex(), &fRelSplitPos)) {
bAnyChanged = true;
bChanged = true;
*fProposedSplitPos = fCurVerticalOffset + fRelSplitPos;
@@ -2187,7 +2187,7 @@ void CXFA_ItemLayoutProcessor::DoLayoutField() {
CXFA_Document* pDocument = m_pFormNode->GetDocument();
CXFA_FFNotify* pNotify = pDocument->GetNotify();
CFX_SizeF size(-1, -1);
- pNotify->StartFieldDrawLayout(m_pFormNode, size.width, size.height);
+ pNotify->StartFieldDrawLayout(m_pFormNode, &size.width, &size.height);
int32_t nRotate = XFA_MapRotation(
m_pFormNode->JSObject()->GetInteger(XFA_Attribute::Rotate));
diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp
index f12ee8de66..c83c118e73 100644
--- a/xfa/fxfa/parser/cxfa_node.cpp
+++ b/xfa/fxfa/parser/cxfa_node.cpp
@@ -3041,31 +3041,31 @@ float CXFA_Node::GetHeightWithoutMargin(float fHeightCalc) {
}
void CXFA_Node::StartWidgetLayout(CXFA_FFDoc* doc,
- float& fCalcWidth,
- float& fCalcHeight) {
+ float* pCalcWidth,
+ float* pCalcHeight) {
InitLayoutData();
if (GetFFWidgetType() == XFA_FFWidgetType::kText) {
m_pLayoutData->m_fWidgetHeight = TryHeight().value_or(-1);
- StartTextLayout(doc, fCalcWidth, fCalcHeight);
+ StartTextLayout(doc, pCalcWidth, pCalcHeight);
return;
}
- if (fCalcWidth > 0 && fCalcHeight > 0)
+ if (*pCalcWidth > 0 && *pCalcHeight > 0)
return;
m_pLayoutData->m_fWidgetHeight = -1;
float fWidth = 0;
- if (fCalcWidth > 0 && fCalcHeight < 0) {
+ if (*pCalcWidth > 0 && *pCalcHeight < 0) {
Optional<float> height = TryHeight();
if (height)
- fCalcHeight = *height;
+ *pCalcHeight = *height;
else
- CalculateAccWidthAndHeight(doc, fCalcWidth, fCalcHeight);
+ CalculateAccWidthAndHeight(doc, pCalcWidth, pCalcHeight);
- m_pLayoutData->m_fWidgetHeight = fCalcHeight;
+ m_pLayoutData->m_fWidgetHeight = *pCalcHeight;
return;
}
- if (fCalcWidth < 0 && fCalcHeight < 0) {
+ if (*pCalcWidth < 0 && *pCalcHeight < 0) {
Optional<float> height;
Optional<float> width = TryWidth();
if (width) {
@@ -3073,20 +3073,20 @@ void CXFA_Node::StartWidgetLayout(CXFA_FFDoc* doc,
height = TryHeight();
if (height)
- fCalcHeight = *height;
+ *pCalcHeight = *height;
}
if (!width || !height)
- CalculateAccWidthAndHeight(doc, fWidth, fCalcHeight);
+ CalculateAccWidthAndHeight(doc, &fWidth, pCalcHeight);
- fCalcWidth = fWidth;
+ *pCalcWidth = fWidth;
}
- m_pLayoutData->m_fWidgetHeight = fCalcHeight;
+ m_pLayoutData->m_fWidgetHeight = *pCalcHeight;
}
void CXFA_Node::CalculateAccWidthAndHeight(CXFA_FFDoc* doc,
- float& fWidth,
- float& fCalcHeight) {
- CFX_SizeF sz(fWidth, m_pLayoutData->m_fWidgetHeight);
+ float* pWidth,
+ float* pCalcHeight) {
+ CFX_SizeF sz(*pWidth, m_pLayoutData->m_fWidgetHeight);
switch (GetFFWidgetType()) {
case XFA_FFWidgetType::kBarcode:
case XFA_FFWidgetType::kChoiceList:
@@ -3123,14 +3123,14 @@ void CXFA_Node::CalculateAccWidthAndHeight(CXFA_FFDoc* doc,
break;
}
- fWidth = sz.width;
+ *pWidth = sz.width;
m_pLayoutData->m_fWidgetHeight = sz.height;
- fCalcHeight = sz.height;
+ *pCalcHeight = sz.height;
}
bool CXFA_Node::FindSplitPos(CXFA_FFDocView* docView,
int32_t iBlockIndex,
- float& fCalcHeight) {
+ float* pCalcHeight) {
if (GetFFWidgetType() == XFA_FFWidgetType::kSubform)
return false;
@@ -3141,7 +3141,7 @@ bool CXFA_Node::FindSplitPos(CXFA_FFDocView* docView,
case XFA_FFWidgetType::kPasswordEdit:
break;
default:
- fCalcHeight = 0;
+ *pCalcHeight = 0;
return true;
}
@@ -3159,22 +3159,21 @@ bool CXFA_Node::FindSplitPos(CXFA_FFDocView* docView,
fBottomInset += rtUIMargin.width;
}
if (GetFFWidgetType() == XFA_FFWidgetType::kText) {
- float fHeight = fCalcHeight;
+ float fHeight = *pCalcHeight;
if (iBlockIndex == 0) {
- fCalcHeight = fCalcHeight - fTopInset;
- if (fCalcHeight < 0)
- fCalcHeight = 0;
+ *pCalcHeight -= fTopInset;
+ *pCalcHeight = std::max(*pCalcHeight, 0.0f);
}
CXFA_TextLayout* pTextLayout =
static_cast<CXFA_TextLayoutData*>(m_pLayoutData.get())->GetTextLayout();
- fCalcHeight =
- pTextLayout->DoLayout(iBlockIndex, fCalcHeight, fCalcHeight,
+ *pCalcHeight =
+ pTextLayout->DoLayout(iBlockIndex, *pCalcHeight, *pCalcHeight,
m_pLayoutData->m_fWidgetHeight - fTopInset);
- if (fCalcHeight != 0) {
+ if (*pCalcHeight != 0) {
if (iBlockIndex == 0)
- fCalcHeight = fCalcHeight + fTopInset;
- if (fabs(fHeight - fCalcHeight) < XFA_FLOAT_PERCISION)
+ *pCalcHeight += fTopInset;
+ if (fabs(fHeight - *pCalcHeight) < XFA_FLOAT_PERCISION)
return false;
}
return true;
@@ -3189,13 +3188,13 @@ bool CXFA_Node::FindSplitPos(CXFA_FFDocView* docView,
fCapReserve = caption->GetReserve();
}
if (iCapPlacement == XFA_AttributeEnum::Top &&
- fCalcHeight < fCapReserve + fTopInset) {
- fCalcHeight = 0;
+ *pCalcHeight < fCapReserve + fTopInset) {
+ *pCalcHeight = 0;
return true;
}
if (iCapPlacement == XFA_AttributeEnum::Bottom &&
m_pLayoutData->m_fWidgetHeight - fCapReserve - fBottomInset) {
- fCalcHeight = 0;
+ *pCalcHeight = 0;
return true;
}
if (iCapPlacement != XFA_AttributeEnum::Top)
@@ -3210,9 +3209,9 @@ bool CXFA_Node::FindSplitPos(CXFA_FFDocView* docView,
} else {
if (!pFieldData->m_pTextOut) {
// TODO(dsinclair): Inline fWidth when the 2nd param of
- // CalculateAccWidthAndHeight isn't a ref-param.
+ // CalculateAccWidthAndHeight isn't an in/out param.
float fWidth = TryWidth().value_or(0);
- CalculateAccWidthAndHeight(docView->GetDoc(), fWidth, fHeight);
+ CalculateAccWidthAndHeight(docView->GetDoc(), &fWidth, &fHeight);
}
iLinesCount = pFieldData->m_pTextOut->GetTotalLines();
}
@@ -3283,58 +3282,58 @@ bool CXFA_Node::FindSplitPos(CXFA_FFDocView* docView,
eLayoutMode == XFA_AttributeEnum::Row ||
eLayoutMode == XFA_AttributeEnum::Table) &&
version <= XFA_VERSION_208) {
- if (fStartOffset < fCalcHeight) {
+ if (fStartOffset < *pCalcHeight) {
bCanSplitNoContent = true;
} else {
- fCalcHeight = 0;
+ *pCalcHeight = 0;
return true;
}
}
if (bCanSplitNoContent) {
- if ((fCalcHeight - fTopInset - fSpaceAbove < fLineHeight)) {
- fCalcHeight = 0;
+ if ((*pCalcHeight - fTopInset - fSpaceAbove < fLineHeight)) {
+ *pCalcHeight = 0;
return true;
}
- if (fStartOffset + XFA_FLOAT_PERCISION >= fCalcHeight) {
+ if (fStartOffset + XFA_FLOAT_PERCISION >= *pCalcHeight) {
if (iFieldSplitCount / 3 == (iBlockIndex + 1)) {
(*pFieldArray)[iBlockIndex * 3 + 1] = 0;
- (*pFieldArray)[iBlockIndex * 3 + 2] = fCalcHeight;
+ (*pFieldArray)[iBlockIndex * 3 + 2] = *pCalcHeight;
} else {
pFieldArray->push_back(0);
- pFieldArray->push_back(fCalcHeight);
+ pFieldArray->push_back(*pCalcHeight);
}
return false;
}
- if (fCalcHeight - fStartOffset < fLineHeight) {
- fCalcHeight = fStartOffset;
+ if (*pCalcHeight - fStartOffset < fLineHeight) {
+ *pCalcHeight = fStartOffset;
if (iFieldSplitCount / 3 == (iBlockIndex + 1)) {
(*pFieldArray)[iBlockIndex * 3 + 1] = 0;
- (*pFieldArray)[iBlockIndex * 3 + 2] = fCalcHeight;
+ (*pFieldArray)[iBlockIndex * 3 + 2] = *pCalcHeight;
} else {
pFieldArray->push_back(0);
- pFieldArray->push_back(fCalcHeight);
+ pFieldArray->push_back(*pCalcHeight);
}
return true;
}
float fTextNum =
- fCalcHeight + XFA_FLOAT_PERCISION - fCapReserve - fStartOffset;
+ *pCalcHeight + XFA_FLOAT_PERCISION - fCapReserve - fStartOffset;
int32_t iLineNum =
(int32_t)((fTextNum + (fLineHeight - fFontSize)) / fLineHeight);
if (iLineNum >= iLinesCount) {
- if (fCalcHeight - fStartOffset - fTextHeight >= fFontSize) {
+ if (*pCalcHeight - fStartOffset - fTextHeight >= fFontSize) {
if (iFieldSplitCount / 3 == (iBlockIndex + 1)) {
(*pFieldArray)[iBlockIndex * 3 + 1] = (float)iLinesCount;
- (*pFieldArray)[iBlockIndex * 3 + 2] = fCalcHeight;
+ (*pFieldArray)[iBlockIndex * 3 + 2] = *pCalcHeight;
} else {
pFieldArray->push_back((float)iLinesCount);
- pFieldArray->push_back(fCalcHeight);
+ pFieldArray->push_back(*pCalcHeight);
}
return false;
}
if (fHeight - fStartOffset - fTextHeight < fFontSize) {
iLineNum -= 1;
if (iLineNum == 0) {
- fCalcHeight = 0;
+ *pCalcHeight = 0;
return true;
}
} else {
@@ -3350,14 +3349,14 @@ bool CXFA_Node::FindSplitPos(CXFA_FFDocView* docView,
pFieldArray->push_back((float)iLineNum);
pFieldArray->push_back(fSplitHeight);
}
- if (fabs(fSplitHeight - fCalcHeight) < XFA_FLOAT_PERCISION)
+ if (fabs(fSplitHeight - *pCalcHeight) < XFA_FLOAT_PERCISION)
return false;
- fCalcHeight = fSplitHeight;
+ *pCalcHeight = fSplitHeight;
return true;
}
}
- fCalcHeight = 0;
+ *pCalcHeight = 0;
return true;
}
@@ -3389,36 +3388,36 @@ void CXFA_Node::InitLayoutData() {
}
void CXFA_Node::StartTextLayout(CXFA_FFDoc* doc,
- float& fCalcWidth,
- float& fCalcHeight) {
+ float* pCalcWidth,
+ float* pCalcHeight) {
InitLayoutData();
static_cast<CXFA_TextLayoutData*>(m_pLayoutData.get())->LoadText(doc, this);
CXFA_TextLayout* pTextLayout =
static_cast<CXFA_TextLayoutData*>(m_pLayoutData.get())->GetTextLayout();
float fTextHeight = 0;
- if (fCalcWidth > 0 && fCalcHeight > 0) {
- float fWidth = GetWidthWithoutMargin(fCalcWidth);
+ if (*pCalcWidth > 0 && *pCalcHeight > 0) {
+ float fWidth = GetWidthWithoutMargin(*pCalcWidth);
pTextLayout->StartLayout(fWidth);
- fTextHeight = fCalcHeight;
+ fTextHeight = *pCalcHeight;
fTextHeight = GetHeightWithoutMargin(fTextHeight);
pTextLayout->DoLayout(0, fTextHeight, -1, fTextHeight);
return;
}
- if (fCalcWidth > 0 && fCalcHeight < 0) {
- float fWidth = GetWidthWithoutMargin(fCalcWidth);
+ if (*pCalcWidth > 0 && *pCalcHeight < 0) {
+ float fWidth = GetWidthWithoutMargin(*pCalcWidth);
pTextLayout->StartLayout(fWidth);
}
- if (fCalcWidth < 0 && fCalcHeight < 0) {
+ if (*pCalcWidth < 0 && *pCalcHeight < 0) {
Optional<float> width = TryWidth();
if (width) {
pTextLayout->StartLayout(GetWidthWithoutMargin(*width));
- fCalcWidth = *width;
+ *pCalcWidth = *width;
} else {
float fMaxWidth = CalculateWidgetAutoWidth(pTextLayout->StartLayout(-1));
pTextLayout->StartLayout(GetWidthWithoutMargin(fMaxWidth));
- fCalcWidth = fMaxWidth;
+ *pCalcWidth = fMaxWidth;
}
}
@@ -3430,7 +3429,7 @@ void CXFA_Node::StartTextLayout(CXFA_FFDoc* doc,
fTextHeight = m_pLayoutData->m_fWidgetHeight;
fTextHeight = GetHeightWithoutMargin(fTextHeight);
pTextLayout->DoLayout(0, fTextHeight, -1, fTextHeight);
- fCalcHeight = m_pLayoutData->m_fWidgetHeight;
+ *pCalcHeight = m_pLayoutData->m_fWidgetHeight;
}
bool CXFA_Node::LoadCaption(CXFA_FFDoc* doc) {
diff --git a/xfa/fxfa/parser/cxfa_node.h b/xfa/fxfa/parser/cxfa_node.h
index 0762aa6d77..32e5cfd861 100644
--- a/xfa/fxfa/parser/cxfa_node.h
+++ b/xfa/fxfa/parser/cxfa_node.h
@@ -300,11 +300,11 @@ class CXFA_Node : public CXFA_Object {
CXFA_FFWidget* GetNextWidget(CXFA_FFWidget* pWidget);
void StartWidgetLayout(CXFA_FFDoc* doc,
- float& fCalcWidth,
- float& fCalcHeight);
+ float* pCalcWidth,
+ float* pCalcHeight);
bool FindSplitPos(CXFA_FFDocView* docView,
int32_t iBlockIndex,
- float& fCalcHeight);
+ float* pCalcHeight);
bool LoadCaption(CXFA_FFDoc* doc);
CXFA_TextLayout* GetCaptionTextLayout();
@@ -462,10 +462,10 @@ class CXFA_Node : public CXFA_Object {
float GetHeightWithoutMargin(float fHeightCalc);
void CalculateTextContentSize(CXFA_FFDoc* doc, CFX_SizeF* pSize);
void CalculateAccWidthAndHeight(CXFA_FFDoc* doc,
- float& fWidth,
- float& fCalcHeight);
+ float* pWidth,
+ float* pCalcHeight);
void InitLayoutData();
- void StartTextLayout(CXFA_FFDoc* doc, float& fCalcWidth, float& fCalcHeight);
+ void StartTextLayout(CXFA_FFDoc* doc, float* pCalcWidth, float* pCalcHeight);
void InsertListTextItem(CXFA_Node* pItems,
const WideString& wsText,