summaryrefslogtreecommitdiff
path: root/xfa/fxfa
diff options
context:
space:
mode:
Diffstat (limited to 'xfa/fxfa')
-rw-r--r--xfa/fxfa/cxfa_ffcheckbutton.cpp4
-rw-r--r--xfa/fxfa/cxfa_fffield.cpp13
-rw-r--r--xfa/fxfa/cxfa_ffpushbutton.cpp10
-rw-r--r--xfa/fxfa/cxfa_widgetacc.cpp15
-rw-r--r--xfa/fxfa/parser/cxfa_node.cpp4
-rw-r--r--xfa/fxfa/parser/cxfa_node.h2
6 files changed, 28 insertions, 20 deletions
diff --git a/xfa/fxfa/cxfa_ffcheckbutton.cpp b/xfa/fxfa/cxfa_ffcheckbutton.cpp
index 94fb9bd8a8..0b5bf53ef5 100644
--- a/xfa/fxfa/cxfa_ffcheckbutton.cpp
+++ b/xfa/fxfa/cxfa_ffcheckbutton.cpp
@@ -98,7 +98,7 @@ bool CXFA_FFCheckButton::PerformLayout() {
XFA_AttributeEnum iCapPlacement = XFA_AttributeEnum::Unknown;
float fCapReserve = 0;
- CXFA_Caption* caption = m_pNode->GetCaption();
+ CXFA_Caption* caption = m_pNode->GetCaptionIfExists();
if (caption && caption->IsVisible()) {
m_rtCaption = rtWidget;
iCapPlacement = caption->GetPlacementType();
@@ -122,7 +122,7 @@ bool CXFA_FFCheckButton::PerformLayout() {
}
m_rtUI = rtWidget;
- CXFA_Margin* captionMargin = caption->GetMargin();
+ CXFA_Margin* captionMargin = caption ? caption->GetMargin() : nullptr;
switch (iCapPlacement) {
case XFA_AttributeEnum::Left: {
m_rtCaption.width = fCapReserve;
diff --git a/xfa/fxfa/cxfa_fffield.cpp b/xfa/fxfa/cxfa_fffield.cpp
index ffbaa43d62..fdc2b1c6ed 100644
--- a/xfa/fxfa/cxfa_fffield.cpp
+++ b/xfa/fxfa/cxfa_fffield.cpp
@@ -191,7 +191,7 @@ void CXFA_FFField::CapPlacement() {
XFA_AttributeEnum iCapPlacement = XFA_AttributeEnum::Unknown;
float fCapReserve = 0;
- CXFA_Caption* caption = m_pNode->GetCaption();
+ CXFA_Caption* caption = m_pNode->GetCaptionIfExists();
if (caption && !caption->IsHidden()) {
iCapPlacement = caption->GetPlacementType();
if (iCapPlacement == XFA_AttributeEnum::Top && GetPrev()) {
@@ -231,17 +231,18 @@ void CXFA_FFField::CapPlacement() {
}
m_rtUI = rtWidget;
+ CXFA_Margin* capMargin = caption ? caption->GetMargin() : nullptr;
switch (iCapPlacement) {
case XFA_AttributeEnum::Left: {
m_rtCaption.width = fCapReserve;
- CapLeftRightPlacement(caption->GetMargin(), rtWidget, iCapPlacement);
+ CapLeftRightPlacement(capMargin, rtWidget, iCapPlacement);
m_rtUI.width -= fCapReserve;
m_rtUI.left += fCapReserve;
break;
}
case XFA_AttributeEnum::Top: {
m_rtCaption.height = fCapReserve;
- CapTopBottomPlacement(caption->GetMargin(), rtWidget, iCapPlacement);
+ CapTopBottomPlacement(capMargin, rtWidget, iCapPlacement);
m_rtUI.top += fCapReserve;
m_rtUI.height -= fCapReserve;
break;
@@ -249,14 +250,14 @@ void CXFA_FFField::CapPlacement() {
case XFA_AttributeEnum::Right: {
m_rtCaption.left = m_rtCaption.right() - fCapReserve;
m_rtCaption.width = fCapReserve;
- CapLeftRightPlacement(caption->GetMargin(), rtWidget, iCapPlacement);
+ CapLeftRightPlacement(capMargin, rtWidget, iCapPlacement);
m_rtUI.width -= fCapReserve;
break;
}
case XFA_AttributeEnum::Bottom: {
m_rtCaption.top = m_rtCaption.bottom() - fCapReserve;
m_rtCaption.height = fCapReserve;
- CapTopBottomPlacement(caption->GetMargin(), rtWidget, iCapPlacement);
+ CapTopBottomPlacement(capMargin, rtWidget, iCapPlacement);
m_rtUI.height -= fCapReserve;
break;
}
@@ -601,7 +602,7 @@ void CXFA_FFField::RenderCaption(CXFA_Graphics* pGS, CFX_Matrix* pMatrix) {
if (!pCapTextLayout)
return;
- CXFA_Caption* caption = m_pNode->GetCaption();
+ CXFA_Caption* caption = m_pNode->GetCaptionIfExists();
if (!caption || !caption->IsVisible())
return;
diff --git a/xfa/fxfa/cxfa_ffpushbutton.cpp b/xfa/fxfa/cxfa_ffpushbutton.cpp
index e3ca6eedff..62d692469d 100644
--- a/xfa/fxfa/cxfa_ffpushbutton.cpp
+++ b/xfa/fxfa/cxfa_ffpushbutton.cpp
@@ -104,9 +104,10 @@ bool CXFA_FFPushButton::PerformLayout() {
if (margin)
XFA_RectWidthoutMargin(rtWidget, margin);
- CXFA_Caption* caption = m_pNode->GetCaption();
m_rtCaption = rtWidget;
- CXFA_Margin* captionMargin = caption->GetMargin();
+
+ CXFA_Caption* caption = m_pNode->GetCaptionIfExists();
+ CXFA_Margin* captionMargin = caption ? caption->GetMargin() : nullptr;
if (captionMargin)
XFA_RectWidthoutMargin(m_rtCaption, captionMargin);
@@ -117,6 +118,7 @@ bool CXFA_FFPushButton::PerformLayout() {
return true;
}
+
float CXFA_FFPushButton::GetLineWidth() {
CXFA_Border* border = m_pNode->GetBorderIfExists();
if (border && border->GetPresence() == XFA_AttributeEnum::Visible)
@@ -133,7 +135,7 @@ FX_ARGB CXFA_FFPushButton::GetFillColor() {
}
void CXFA_FFPushButton::LoadHighlightCaption() {
- CXFA_Caption* caption = m_pNode->GetCaption();
+ CXFA_Caption* caption = m_pNode->GetCaptionIfExists();
if (!caption || caption->IsHidden())
return;
@@ -169,7 +171,7 @@ void CXFA_FFPushButton::RenderHighlightCaption(CXFA_Graphics* pGS,
CFX_Matrix* pMatrix) {
CXFA_TextLayout* pCapTextLayout =
m_pNode->GetWidgetAcc()->GetCaptionTextLayout();
- CXFA_Caption* caption = m_pNode->GetCaption();
+ CXFA_Caption* caption = m_pNode->GetCaptionIfExists();
if (!caption || !caption->IsVisible())
return;
diff --git a/xfa/fxfa/cxfa_widgetacc.cpp b/xfa/fxfa/cxfa_widgetacc.cpp
index 0c55bd6ce6..222de47e89 100644
--- a/xfa/fxfa/cxfa_widgetacc.cpp
+++ b/xfa/fxfa/cxfa_widgetacc.cpp
@@ -122,7 +122,7 @@ class CXFA_FieldLayoutData : public CXFA_WidgetLayoutData {
bool LoadCaption(CXFA_FFDoc* doc, CXFA_WidgetAcc* pAcc) {
if (m_pCapTextLayout)
return true;
- CXFA_Caption* caption = pAcc->GetNode()->GetCaption();
+ CXFA_Caption* caption = pAcc->GetNode()->GetCaptionIfExists();
if (!caption || caption->IsHidden())
return false;
@@ -484,7 +484,7 @@ void CXFA_WidgetAcc::UpdateUIDisplay(CXFA_FFDocView* docView,
}
void CXFA_WidgetAcc::CalcCaptionSize(CXFA_FFDoc* doc, CFX_SizeF& szCap) {
- CXFA_Caption* caption = m_pNode->GetCaption();
+ CXFA_Caption* caption = m_pNode->GetCaptionIfExists();
if (!caption || !caption->IsVisible())
return;
@@ -550,7 +550,10 @@ bool CXFA_WidgetAcc::CalculateFieldAutoSize(CXFA_FFDoc* doc, CFX_SizeF& size) {
size.width += rtUIMargin.left + rtUIMargin.width;
size.height += rtUIMargin.top + rtUIMargin.height;
if (szCap.width > 0 && szCap.height > 0) {
- switch (m_pNode->GetCaption()->GetPlacementType()) {
+ CXFA_Caption* caption = m_pNode->GetCaptionIfExists();
+ XFA_AttributeEnum placement =
+ caption ? caption->GetPlacementType() : XFA_AttributeEnum::Left;
+ switch (placement) {
case XFA_AttributeEnum::Left:
case XFA_AttributeEnum::Right:
case XFA_AttributeEnum::Inline: {
@@ -651,7 +654,9 @@ bool CXFA_WidgetAcc::CalculateTextEditAutoSize(CXFA_FFDoc* doc,
bool bCapExit = szCap.width > 0.01 && szCap.height > 0.01;
XFA_AttributeEnum iCapPlacement = XFA_AttributeEnum::Unknown;
if (bCapExit) {
- iCapPlacement = m_pNode->GetCaption()->GetPlacementType();
+ CXFA_Caption* caption = m_pNode->GetCaptionIfExists();
+ iCapPlacement =
+ caption ? caption->GetPlacementType() : XFA_AttributeEnum::Left;
switch (iCapPlacement) {
case XFA_AttributeEnum::Left:
case XFA_AttributeEnum::Right:
@@ -985,7 +990,7 @@ bool CXFA_WidgetAcc::FindSplitPos(CXFA_FFDocView* docView,
XFA_AttributeEnum iCapPlacement = XFA_AttributeEnum::Unknown;
float fCapReserve = 0;
if (iBlockIndex == 0) {
- CXFA_Caption* caption = m_pNode->GetCaption();
+ CXFA_Caption* caption = m_pNode->GetCaptionIfExists();
if (caption && !caption->IsHidden()) {
iCapPlacement = caption->GetPlacementType();
fCapReserve = caption->GetReserve();
diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp
index 02d1c0f6f3..b04e427a10 100644
--- a/xfa/fxfa/parser/cxfa_node.cpp
+++ b/xfa/fxfa/parser/cxfa_node.cpp
@@ -1538,7 +1538,7 @@ CXFA_Border* CXFA_Node::GetOrCreateBorder() {
return JSObject()->GetOrCreateProperty<CXFA_Border>(0, XFA_Element::Border);
}
-CXFA_Caption* CXFA_Node::GetCaption() const {
+CXFA_Caption* CXFA_Node::GetCaptionIfExists() const {
return JSObject()->GetProperty<CXFA_Caption>(0, XFA_Element::Caption);
}
@@ -1917,7 +1917,7 @@ WideString CXFA_Node::GetValidateCaptionName(bool bVersionFlag) {
WideString wsCaptionName;
if (!bVersionFlag) {
- CXFA_Caption* caption = GetCaption();
+ CXFA_Caption* caption = GetCaptionIfExists();
if (caption) {
CXFA_Value* capValue = caption->GetValue();
if (capValue) {
diff --git a/xfa/fxfa/parser/cxfa_node.h b/xfa/fxfa/parser/cxfa_node.h
index b175a83a84..2ada0083a0 100644
--- a/xfa/fxfa/parser/cxfa_node.h
+++ b/xfa/fxfa/parser/cxfa_node.h
@@ -238,7 +238,7 @@ class CXFA_Node : public CXFA_Object {
CXFA_Border* GetBorderIfExists() const;
CXFA_Border* GetOrCreateBorder();
- CXFA_Caption* GetCaption() const;
+ CXFA_Caption* GetCaptionIfExists() const;
CXFA_Font* GetFont() const;
CXFA_Font* GetOrCreateFont();