diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2017-11-20 21:19:13 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-11-20 21:19:13 +0000 |
commit | 2501ae2474c1f097a06634d647de2eb3fb730864 (patch) | |
tree | 3ac7d386a3e73f3c848c203c3f0e61af9d284c1f | |
parent | 89453e92d5d0b7aaf9e0c3890a90a21adc94a0ce (diff) | |
download | pdfium-2501ae2474c1f097a06634d647de2eb3fb730864.tar.xz |
Remove CXFA_DataData operator bool override
This CL removes CXFA_DataData::operator bool in favour of an explicit
HasValidNode method. This makes the call sites a lot clearer.
Change-Id: I6fae14fdeec4674ca7916e21b9e5703070fc3069
Reviewed-on: https://pdfium-review.googlesource.com/18830
Commit-Queue: dsinclair <dsinclair@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
28 files changed, 205 insertions, 133 deletions
diff --git a/fxjs/cjx_node.cpp b/fxjs/cjx_node.cpp index 8f99b1a5b8..8de755d9fd 100644 --- a/fxjs/cjx_node.cpp +++ b/fxjs/cjx_node.cpp @@ -1353,7 +1353,7 @@ void CJX_Node::Script_Som_Message(CFXJSE_Value* pValue, bool bNew = false; CXFA_ValidateData validateData = pWidgetData->GetValidateData(false); - if (!validateData) { + if (!validateData.HasValidNode()) { validateData = pWidgetData->GetValidateData(true); bNew = true; } diff --git a/xfa/fwl/theme/cfwl_edittp.cpp b/xfa/fwl/theme/cfwl_edittp.cpp index 4f8c4d533e..563ae532dd 100644 --- a/xfa/fwl/theme/cfwl_edittp.cpp +++ b/xfa/fwl/theme/cfwl_edittp.cpp @@ -24,9 +24,9 @@ void CFWL_EditTP::DrawBackground(CFWL_ThemeBackground* pParams) { CXFA_BorderData borderUIData = pWidget->GetDataAcc()->GetUIBorderData(); FX_ARGB cr = 0xFF000000; float fWidth = 1.0f; - if (borderUIData) { + if (borderUIData.HasValidNode()) { CXFA_EdgeData edgeData = borderUIData.GetEdgeData(0); - if (edgeData) { + if (edgeData.HasValidNode()) { cr = edgeData.GetColor(); fWidth = edgeData.GetThickness(); } diff --git a/xfa/fxfa/cxfa_ffarc.cpp b/xfa/fxfa/cxfa_ffarc.cpp index e1174008ec..12ab629d87 100644 --- a/xfa/fxfa/cxfa_ffarc.cpp +++ b/xfa/fxfa/cxfa_ffarc.cpp @@ -17,11 +17,12 @@ void CXFA_FFArc::RenderWidget(CXFA_Graphics* pGS, return; CXFA_ValueData valueData = m_pDataAcc->GetFormValueData(); - if (!valueData) + if (!valueData.HasValidNode()) return; CFX_RectF rtArc = GetRectWithoutRotate(); - if (CXFA_MarginData marginData = m_pDataAcc->GetMarginData()) + CXFA_MarginData marginData = m_pDataAcc->GetMarginData(); + if (marginData.HasValidNode()) XFA_RectWidthoutMargin(rtArc, marginData); CFX_Matrix mtRotate = GetRotateMatrix(); diff --git a/xfa/fxfa/cxfa_ffcheckbutton.cpp b/xfa/fxfa/cxfa_ffcheckbutton.cpp index a9d47d17bb..7d82fc6e9f 100644 --- a/xfa/fxfa/cxfa_ffcheckbutton.cpp +++ b/xfa/fxfa/cxfa_ffcheckbutton.cpp @@ -93,13 +93,13 @@ bool CXFA_FFCheckButton::PerformLayout() { float fCheckSize = m_pDataAcc->GetCheckButtonSize(); CXFA_MarginData marginData = m_pDataAcc->GetMarginData(); CFX_RectF rtWidget = GetRectWithoutRotate(); - if (marginData) + if (marginData.HasValidNode()) XFA_RectWidthoutMargin(rtWidget, marginData); int32_t iCapPlacement = -1; float fCapReserve = 0; CXFA_CaptionData captionData = m_pDataAcc->GetCaptionData(); - if (captionData && captionData.GetPresence()) { + if (captionData.HasValidNode() && captionData.GetPresence()) { m_rtCaption = rtWidget; iCapPlacement = captionData.GetPlacementType(); fCapReserve = captionData.GetReserve(); @@ -115,7 +115,8 @@ bool CXFA_FFCheckButton::PerformLayout() { int32_t iHorzAlign = XFA_ATTRIBUTEENUM_Left; int32_t iVertAlign = XFA_ATTRIBUTEENUM_Top; - if (CXFA_ParaData paraData = m_pDataAcc->GetParaData()) { + CXFA_ParaData paraData = m_pDataAcc->GetParaData(); + if (paraData.HasValidNode()) { iHorzAlign = paraData.GetHorizontalAlign(); iVertAlign = paraData.GetVerticalAlign(); } @@ -173,9 +174,9 @@ bool CXFA_FFCheckButton::PerformLayout() { AddUIMargin(iCapPlacement); m_rtCheckBox = m_rtUI; CXFA_BorderData borderUIData = m_pDataAcc->GetUIBorderData(); - if (borderUIData) { + if (borderUIData.HasValidNode()) { CXFA_MarginData borderMarginData = borderUIData.GetMarginData(); - if (borderMarginData) + if (borderMarginData.HasValidNode()) XFA_RectWidthoutMargin(m_rtUI, borderMarginData); } diff --git a/xfa/fxfa/cxfa_ffcombobox.cpp b/xfa/fxfa/cxfa_ffcombobox.cpp index f72e31226d..87c1c3e43f 100644 --- a/xfa/fxfa/cxfa_ffcombobox.cpp +++ b/xfa/fxfa/cxfa_ffcombobox.cpp @@ -146,7 +146,7 @@ void CXFA_FFComboBox::FWLEventSelChange(CXFA_EventParam* pParam) { uint32_t CXFA_FFComboBox::GetAlignment() { CXFA_ParaData paraData = m_pDataAcc->GetParaData(); - if (!paraData) + if (!paraData.HasValidNode()) return 0; uint32_t dwExtendedStyle = 0; diff --git a/xfa/fxfa/cxfa_ffdatetimeedit.cpp b/xfa/fxfa/cxfa_ffdatetimeedit.cpp index 7958162a89..1b2f6e3221 100644 --- a/xfa/fxfa/cxfa_ffdatetimeedit.cpp +++ b/xfa/fxfa/cxfa_ffdatetimeedit.cpp @@ -50,7 +50,8 @@ bool CXFA_FFDateTimeEdit::LoadWidget() { WideString wsText; m_pDataAcc->GetValue(wsText, XFA_VALUEPICTURE_Display); pWidget->SetEditText(wsText); - if (CXFA_ValueData valueData = m_pDataAcc->GetFormValueData()) { + CXFA_ValueData valueData = m_pDataAcc->GetFormValueData(); + if (valueData.HasValidNode()) { switch (valueData.GetChildValueClassID()) { case XFA_Element::Date: { if (!wsText.IsEmpty()) { @@ -97,7 +98,7 @@ void CXFA_FFDateTimeEdit::UpdateWidgetProperty() { uint32_t CXFA_FFDateTimeEdit::GetAlignment() { CXFA_ParaData paraData = m_pDataAcc->GetParaData(); - if (!paraData) + if (!paraData.HasValidNode()) return 0; uint32_t dwExtendedStyle = 0; diff --git a/xfa/fxfa/cxfa_ffdocview.cpp b/xfa/fxfa/cxfa_ffdocview.cpp index e2a0adcc34..62543943be 100644 --- a/xfa/fxfa/cxfa_ffdocview.cpp +++ b/xfa/fxfa/cxfa_ffdocview.cpp @@ -221,7 +221,8 @@ bool CXFA_FFDocView::ResetSingleWidgetAccData(CXFA_WidgetAcc* pWidgetAcc) { pWidgetAcc->ResetData(); pWidgetAcc->UpdateUIDisplay(); - if (CXFA_ValidateData validateData = pWidgetAcc->GetValidateData(false)) { + CXFA_ValidateData validateData = pWidgetAcc->GetValidateData(false); + if (validateData.HasValidNode()) { AddValidateWidget(pWidgetAcc); validateData.GetNode()->SetFlag(XFA_NodeFlag_NeedsInitApp, false); } @@ -409,7 +410,7 @@ static int32_t XFA_ProcessEvent(CXFA_FFDocView* pDocView, return XFA_EVENTERROR_Disabled; case XFA_EVENT_InitCalculate: { CXFA_CalculateData calcData = pWidgetAcc->GetCalculateData(); - if (!calcData) + if (!calcData.HasValidNode()) return XFA_EVENTERROR_NotExist; if (pWidgetAcc->GetNode()->IsUserInteractive()) return XFA_EVENTERROR_Disabled; diff --git a/xfa/fxfa/cxfa_fffield.cpp b/xfa/fxfa/cxfa_fffield.cpp index e2f7b6a2f2..7e36fea2cf 100644 --- a/xfa/fxfa/cxfa_fffield.cpp +++ b/xfa/fxfa/cxfa_fffield.cpp @@ -170,7 +170,7 @@ bool CXFA_FFField::PerformLayout() { void CXFA_FFField::CapPlacement() { CFX_RectF rtWidget = GetRectWithoutRotate(); CXFA_MarginData marginData = m_pDataAcc->GetMarginData(); - if (marginData) { + if (marginData.HasValidNode()) { CXFA_LayoutItem* pItem = this; float fLeftInset = 0, fRightInset = 0, fTopInset = 0, fBottomInset = 0; marginData.GetLeftInset(fLeftInset); @@ -192,7 +192,8 @@ void CXFA_FFField::CapPlacement() { XFA_ATTRIBUTEENUM iCapPlacement = XFA_ATTRIBUTEENUM_Unknown; float fCapReserve = 0; CXFA_CaptionData captionData = m_pDataAcc->GetCaptionData(); - if (captionData && captionData.GetPresence() != XFA_ATTRIBUTEENUM_Hidden) { + if (captionData.HasValidNode() && + captionData.GetPresence() != XFA_ATTRIBUTEENUM_Hidden) { iCapPlacement = (XFA_ATTRIBUTEENUM)captionData.GetPlacementType(); if (iCapPlacement == XFA_ATTRIBUTEENUM_Top && GetPrev()) { m_rtCaption.Reset(); @@ -270,9 +271,9 @@ void CXFA_FFField::CapPlacement() { } CXFA_BorderData borderUIData = m_pDataAcc->GetUIBorderData(); - if (borderUIData) { + if (borderUIData.HasValidNode()) { CXFA_MarginData borderMarginData = borderUIData.GetMarginData(); - if (borderMarginData) + if (borderMarginData.HasValidNode()) XFA_RectWidthoutMargin(m_rtUI, borderMarginData); } m_rtUI.Normalize(); @@ -283,7 +284,7 @@ void CXFA_FFField::CapTopBottomPlacement(const CXFA_MarginData& marginData, int32_t iCapPlacement) { CFX_RectF rtUIMargin = m_pDataAcc->GetUIMargin(); m_rtCaption.left += rtUIMargin.left; - if (marginData) { + if (marginData.HasValidNode()) { XFA_RectWidthoutMargin(m_rtCaption, marginData); if (m_rtCaption.height < 0) m_rtCaption.top += m_rtCaption.height; @@ -310,7 +311,7 @@ void CXFA_FFField::CapLeftRightPlacement(const CXFA_MarginData& marginData, CFX_RectF rtUIMargin = m_pDataAcc->GetUIMargin(); m_rtCaption.top += rtUIMargin.top; m_rtCaption.height -= rtUIMargin.top; - if (marginData) { + if (marginData.HasValidNode()) { XFA_RectWidthoutMargin(m_rtCaption, marginData); if (m_rtCaption.height < 0) m_rtCaption.top += m_rtCaption.height; @@ -607,8 +608,10 @@ void CXFA_FFField::RenderCaption(CXFA_Graphics* pGS, CFX_Matrix* pMatrix) { return; CXFA_CaptionData captionData = m_pDataAcc->GetCaptionData(); - if (!captionData || captionData.GetPresence() != XFA_ATTRIBUTEENUM_Visible) + if (!captionData.HasValidNode() || + captionData.GetPresence() != XFA_ATTRIBUTEENUM_Visible) { return; + } if (!pCapTextLayout->IsLoaded()) pCapTextLayout->Layout(CFX_SizeF(m_rtCaption.width, m_rtCaption.height)); @@ -665,7 +668,7 @@ int32_t CXFA_FFField::CalculateOverride() { int32_t CXFA_FFField::CalculateWidgetAcc(CXFA_WidgetAcc* pAcc) { CXFA_CalculateData calcData = pAcc->GetCalculateData(); - if (!calcData) + if (!calcData.HasValidNode()) return 1; XFA_VERSION version = pAcc->GetDoc()->GetXFADoc()->GetCurVersionMode(); @@ -685,7 +688,7 @@ int32_t CXFA_FFField::CalculateWidgetAcc(CXFA_WidgetAcc* pAcc) { case XFA_ATTRIBUTEENUM_Warning: { if (version <= XFA_VERSION_204) { CXFA_ScriptData scriptData = calcData.GetScriptData(); - if (!scriptData) + if (!scriptData.HasValidNode()) return 1; WideString wsExpression; diff --git a/xfa/fxfa/cxfa_ffimage.cpp b/xfa/fxfa/cxfa_ffimage.cpp index 61f50be9ba..e7dc715eb7 100644 --- a/xfa/fxfa/cxfa_ffimage.cpp +++ b/xfa/fxfa/cxfa_ffimage.cpp @@ -49,12 +49,14 @@ void CXFA_FFImage::RenderWidget(CXFA_Graphics* pGS, return; CFX_RectF rtImage = GetRectWithoutRotate(); - if (CXFA_MarginData marginData = m_pDataAcc->GetMarginData()) + CXFA_MarginData marginData = m_pDataAcc->GetMarginData(); + if (marginData.HasValidNode()) XFA_RectWidthoutMargin(rtImage, marginData); int32_t iHorzAlign = XFA_ATTRIBUTEENUM_Left; int32_t iVertAlign = XFA_ATTRIBUTEENUM_Top; - if (CXFA_ParaData paraData = m_pDataAcc->GetParaData()) { + CXFA_ParaData paraData = m_pDataAcc->GetParaData(); + if (paraData.HasValidNode()) { iHorzAlign = paraData.GetHorizontalAlign(); iVertAlign = paraData.GetVerticalAlign(); } diff --git a/xfa/fxfa/cxfa_ffimageedit.cpp b/xfa/fxfa/cxfa_ffimageedit.cpp index 41f659e8f3..38ece830d7 100644 --- a/xfa/fxfa/cxfa_ffimageedit.cpp +++ b/xfa/fxfa/cxfa_ffimageedit.cpp @@ -70,14 +70,17 @@ void CXFA_FFImageEdit::RenderWidget(CXFA_Graphics* pGS, CFX_RectF rtImage = m_pNormalWidget->GetWidgetRect(); int32_t iHorzAlign = XFA_ATTRIBUTEENUM_Left; int32_t iVertAlign = XFA_ATTRIBUTEENUM_Top; - if (CXFA_ParaData paraData = m_pDataAcc->GetParaData()) { + CXFA_ParaData paraData = m_pDataAcc->GetParaData(); + if (paraData.HasValidNode()) { iHorzAlign = paraData.GetHorizontalAlign(); iVertAlign = paraData.GetVerticalAlign(); } int32_t iAspect = XFA_ATTRIBUTEENUM_Fit; - if (CXFA_ValueData valueData = m_pDataAcc->GetFormValueData()) { - if (CXFA_ImageData imageData = valueData.GetImageData()) + CXFA_ValueData valueData = m_pDataAcc->GetFormValueData(); + if (valueData.HasValidNode()) { + CXFA_ImageData imageData = valueData.GetImageData(); + if (imageData.HasValidNode()) iAspect = imageData.GetAspect(); } diff --git a/xfa/fxfa/cxfa_ffline.cpp b/xfa/fxfa/cxfa_ffline.cpp index d24444c401..62a4f86998 100644 --- a/xfa/fxfa/cxfa_ffline.cpp +++ b/xfa/fxfa/cxfa_ffline.cpp @@ -54,7 +54,7 @@ void CXFA_FFLine::RenderWidget(CXFA_Graphics* pGS, return; CXFA_ValueData valueData = m_pDataAcc->GetFormValueData(); - if (!valueData) + if (!valueData.HasValidNode()) return; CXFA_LineData lineData = valueData.GetLineData(); @@ -63,7 +63,7 @@ void CXFA_FFLine::RenderWidget(CXFA_Graphics* pGS, float fLineWidth = 1.0f; int32_t iCap = 0; CXFA_EdgeData edgeData = lineData.GetEdgeData(); - if (edgeData) { + if (edgeData.HasValidNode()) { if (edgeData.GetPresence() != XFA_ATTRIBUTEENUM_Visible) return; @@ -77,7 +77,8 @@ void CXFA_FFLine::RenderWidget(CXFA_Graphics* pGS, mtRotate.Concat(matrix); CFX_RectF rtLine = GetRectWithoutRotate(); - if (CXFA_MarginData marginData = m_pDataAcc->GetMarginData()) + CXFA_MarginData marginData = m_pDataAcc->GetMarginData(); + if (marginData.HasValidNode()) XFA_RectWidthoutMargin(rtLine, marginData); GetRectFromHand(rtLine, lineData.GetHand(), fLineWidth); diff --git a/xfa/fxfa/cxfa_fflistbox.cpp b/xfa/fxfa/cxfa_fflistbox.cpp index 50bd29161f..79496b310e 100644 --- a/xfa/fxfa/cxfa_fflistbox.cpp +++ b/xfa/fxfa/cxfa_fflistbox.cpp @@ -105,7 +105,7 @@ bool CXFA_FFListBox::IsDataChanged() { uint32_t CXFA_FFListBox::GetAlignment() { CXFA_ParaData paraData = m_pDataAcc->GetParaData(); - if (!paraData) + if (!paraData.HasValidNode()) return 0; uint32_t dwExtendedStyle = 0; diff --git a/xfa/fxfa/cxfa_ffpushbutton.cpp b/xfa/fxfa/cxfa_ffpushbutton.cpp index 1f5d9021ee..9a799cd2ce 100644 --- a/xfa/fxfa/cxfa_ffpushbutton.cpp +++ b/xfa/fxfa/cxfa_ffpushbutton.cpp @@ -97,12 +97,14 @@ bool CXFA_FFPushButton::PerformLayout() { CFX_RectF rtWidget = GetRectWithoutRotate(); m_rtUI = rtWidget; - if (CXFA_MarginData marginData = m_pDataAcc->GetMarginData()) + CXFA_MarginData marginData = m_pDataAcc->GetMarginData(); + if (marginData.HasValidNode()) XFA_RectWidthoutMargin(rtWidget, marginData); CXFA_CaptionData captionData = m_pDataAcc->GetCaptionData(); m_rtCaption = rtWidget; - if (CXFA_MarginData captionMarginData = captionData.GetMarginData()) + CXFA_MarginData captionMarginData = captionData.GetMarginData(); + if (captionMarginData.HasValidNode()) XFA_RectWidthoutMargin(m_rtCaption, captionMarginData); LayoutHighlightCaption(); @@ -114,8 +116,10 @@ bool CXFA_FFPushButton::PerformLayout() { } float CXFA_FFPushButton::GetLineWidth() { CXFA_BorderData borderData = m_pDataAcc->GetBorderData(false); - if (borderData && borderData.GetPresence() == XFA_ATTRIBUTEENUM_Visible) + if (borderData.HasValidNode() && + borderData.GetPresence() == XFA_ATTRIBUTEENUM_Visible) { return borderData.GetEdgeData(0).GetThickness(); + } return 0; } @@ -130,8 +134,10 @@ FX_ARGB CXFA_FFPushButton::GetFillColor() { void CXFA_FFPushButton::LoadHighlightCaption() { CXFA_CaptionData captionData = m_pDataAcc->GetCaptionData(); - if (!captionData || captionData.GetPresence() == XFA_ATTRIBUTEENUM_Hidden) + if (!captionData.HasValidNode() || + captionData.GetPresence() == XFA_ATTRIBUTEENUM_Hidden) { return; + } bool bRichText; WideString wsRollover; @@ -167,8 +173,10 @@ void CXFA_FFPushButton::RenderHighlightCaption(CXFA_Graphics* pGS, CFX_Matrix* pMatrix) { CXFA_TextLayout* pCapTextLayout = m_pDataAcc->GetCaptionTextLayout(); CXFA_CaptionData captionData = m_pDataAcc->GetCaptionData(); - if (!captionData || captionData.GetPresence() != XFA_ATTRIBUTEENUM_Visible) + if (!captionData.HasValidNode() || + captionData.GetPresence() != XFA_ATTRIBUTEENUM_Visible) { return; + } CFX_RenderDevice* pRenderDevice = pGS->GetRenderDevice(); CFX_RectF rtClip = m_rtCaption; diff --git a/xfa/fxfa/cxfa_ffrectangle.cpp b/xfa/fxfa/cxfa_ffrectangle.cpp index 855520e31d..716ef2e840 100644 --- a/xfa/fxfa/cxfa_ffrectangle.cpp +++ b/xfa/fxfa/cxfa_ffrectangle.cpp @@ -18,11 +18,12 @@ void CXFA_FFRectangle::RenderWidget(CXFA_Graphics* pGS, return; CXFA_ValueData valueData = m_pDataAcc->GetFormValueData(); - if (!valueData) + if (!valueData.HasValidNode()) return; CFX_RectF rect = GetRectWithoutRotate(); - if (CXFA_MarginData marginData = m_pDataAcc->GetMarginData()) + CXFA_MarginData marginData = m_pDataAcc->GetMarginData(); + if (marginData.HasValidNode()) XFA_RectWidthoutMargin(rect, marginData); CFX_Matrix mtRotate = GetRotateMatrix(); diff --git a/xfa/fxfa/cxfa_fftext.cpp b/xfa/fxfa/cxfa_fftext.cpp index 18eb20001a..1eac4fd309 100644 --- a/xfa/fxfa/cxfa_fftext.cpp +++ b/xfa/fxfa/cxfa_fftext.cpp @@ -40,7 +40,8 @@ void CXFA_FFText::RenderWidget(CXFA_Graphics* pGS, CFX_RenderDevice* pRenderDevice = pGS->GetRenderDevice(); CFX_RectF rtText = GetRectWithoutRotate(); - if (CXFA_MarginData marginData = m_pDataAcc->GetMarginData()) { + CXFA_MarginData marginData = m_pDataAcc->GetMarginData(); + if (marginData.HasValidNode()) { CXFA_LayoutItem* pItem = this; if (!pItem->GetPrev() && !pItem->GetNext()) { XFA_RectWidthoutMargin(rtText, marginData); @@ -87,7 +88,8 @@ bool CXFA_FFText::PerformLayout() { pItem = pItem->GetFirst(); while (pItem) { CFX_RectF rtText = pItem->GetRect(false); - if (CXFA_MarginData marginData = m_pDataAcc->GetMarginData()) { + CXFA_MarginData marginData = m_pDataAcc->GetMarginData(); + if (marginData.HasValidNode()) { if (!pItem->GetPrev()) { float fTopInset; marginData.GetTopInset(fTopInset); diff --git a/xfa/fxfa/cxfa_fftextedit.cpp b/xfa/fxfa/cxfa_fftextedit.cpp index 848eab875f..f3be75d2a4 100644 --- a/xfa/fxfa/cxfa_fftextedit.cpp +++ b/xfa/fxfa/cxfa_fftextedit.cpp @@ -215,7 +215,7 @@ bool CXFA_FFTextEdit::IsDataChanged() { uint32_t CXFA_FFTextEdit::GetAlignment() { CXFA_ParaData paraData = m_pDataAcc->GetParaData(); - if (!paraData) + if (!paraData.HasValidNode()) return 0; uint32_t dwExtendedStyle = 0; diff --git a/xfa/fxfa/cxfa_ffwidget.cpp b/xfa/fxfa/cxfa_ffwidget.cpp index bb2d2e8a1c..88c1fea971 100644 --- a/xfa/fxfa/cxfa_ffwidget.cpp +++ b/xfa/fxfa/cxfa_ffwidget.cpp @@ -485,8 +485,10 @@ void XFA_BOX_Fill(const CXFA_BoxData& boxData, const CFX_Matrix& matrix, uint32_t dwFlags) { CXFA_FillData fillData = boxData.GetFillData(false); - if (!fillData || fillData.GetPresence() != XFA_ATTRIBUTEENUM_Visible) + if (!fillData.HasValidNode() || + fillData.GetPresence() != XFA_ATTRIBUTEENUM_Visible) { return; + } pGS->SaveGraphState(); CXFA_GEPath fillPath; @@ -528,7 +530,7 @@ void XFA_BOX_StrokePath(const CXFA_StrokeData& strokeData, CXFA_GEPath* pPath, CXFA_Graphics* pGS, const CFX_Matrix& matrix) { - if (!strokeData || !strokeData.IsVisible()) + if (!strokeData.HasValidNode() || !strokeData.IsVisible()) return; float fThickness = strokeData.GetThickness(); @@ -555,7 +557,7 @@ void XFA_BOX_StrokeArc(const CXFA_BoxData& boxData, const CFX_Matrix& matrix, uint32_t dwFlags) { CXFA_EdgeData edgeData = boxData.GetEdgeData(0); - if (!edgeData || !edgeData.IsVisible()) + if (!edgeData.HasValidNode() || !edgeData.IsVisible()) return; bool bVisible = false; @@ -879,8 +881,10 @@ void XFA_DrawBox(CXFA_BoxData boxData, const CFX_RectF& rtWidget, const CFX_Matrix& matrix, uint32_t dwFlags) { - if (!boxData || boxData.GetPresence() != XFA_ATTRIBUTEENUM_Visible) + if (!boxData.HasValidNode() || + boxData.GetPresence() != XFA_ATTRIBUTEENUM_Visible) { return; + } XFA_Element eType = boxData.GetElementType(); if (eType != XFA_Element::Arc && eType != XFA_Element::Border && @@ -980,12 +984,12 @@ void CXFA_FFWidget::RenderWidget(CXFA_Graphics* pGS, return; CXFA_BorderData borderData = m_pDataAcc->GetBorderData(false); - if (!borderData) + if (!borderData.HasValidNode()) return; CFX_RectF rtBorder = GetRectWithoutRotate(); CXFA_MarginData marginData = borderData.GetMarginData(); - if (marginData) + if (marginData.HasValidNode()) XFA_RectWidthoutMargin(rtBorder, marginData); rtBorder.Normalize(); @@ -2019,7 +2023,7 @@ RetainPtr<CFX_DIBitmap> XFA_LoadImageFromBuffer( void XFA_RectWidthoutMargin(CFX_RectF& rt, const CXFA_MarginData& marginData, bool bUI) { - if (!marginData) + if (!marginData.HasValidNode()) return; float fLeftInset; diff --git a/xfa/fxfa/cxfa_ffwidgethandler.cpp b/xfa/fxfa/cxfa_ffwidgethandler.cpp index f1b8f76e87..89fed79ec8 100644 --- a/xfa/fxfa/cxfa_ffwidgethandler.cpp +++ b/xfa/fxfa/cxfa_ffwidgethandler.cpp @@ -190,11 +190,12 @@ bool CXFA_FFWidgetHandler::HasEvent(CXFA_WidgetAcc* pWidgetAcc, switch (eEventType) { case XFA_EVENT_Calculate: { CXFA_CalculateData calcData = pWidgetAcc->GetCalculateData(); - return calcData && calcData.GetScriptData(); + return calcData.HasValidNode() && calcData.GetScriptData().HasValidNode(); } case XFA_EVENT_Validate: { CXFA_ValidateData validateData = pWidgetAcc->GetValidateData(false); - return validateData && validateData.GetScriptData(); + return validateData.HasValidNode() && + validateData.GetScriptData().HasValidNode(); } default: break; @@ -221,7 +222,7 @@ int32_t CXFA_FFWidgetHandler::ProcessEvent(CXFA_WidgetAcc* pWidgetAcc, return XFA_EVENTERROR_Disabled; case XFA_EVENT_InitCalculate: { CXFA_CalculateData calcData = pWidgetAcc->GetCalculateData(); - if (!calcData) + if (!calcData.HasValidNode()) return XFA_EVENTERROR_NotExist; if (pWidgetAcc->GetNode()->IsUserInteractive()) return XFA_EVENTERROR_Disabled; diff --git a/xfa/fxfa/cxfa_fwltheme.cpp b/xfa/fxfa/cxfa_fwltheme.cpp index 440c41dd5b..88aeef68c5 100644 --- a/xfa/fxfa/cxfa_fwltheme.cpp +++ b/xfa/fxfa/cxfa_fwltheme.cpp @@ -154,7 +154,8 @@ CFX_RectF CXFA_FWLTheme::GetUIMargin(CFWL_ThemePart* pThemePart) const { CXFA_LayoutItem* pItem = pWidget; CXFA_WidgetAcc* pWidgetAcc = pWidget->GetDataAcc(); rect = pWidgetAcc->GetUIMargin(); - if (CXFA_ParaData paraData = pWidgetAcc->GetParaData()) { + CXFA_ParaData paraData = pWidgetAcc->GetParaData(); + if (paraData.HasValidNode()) { rect.left += paraData.GetMarginLeft(); if (pWidgetAcc->IsMultiLine()) rect.width += paraData.GetMarginRight(); @@ -212,7 +213,8 @@ CFX_SizeF CXFA_FWLTheme::GetSpaceAboveBelow(CFWL_ThemePart* pThemePart) const { CFX_SizeF sizeAboveBelow; if (CXFA_FFWidget* pWidget = XFA_ThemeGetOuterWidget(pThemePart->m_pWidget)) { CXFA_WidgetAcc* pWidgetAcc = pWidget->GetDataAcc(); - if (CXFA_ParaData paraData = pWidgetAcc->GetParaData()) { + CXFA_ParaData paraData = pWidgetAcc->GetParaData(); + if (paraData.HasValidNode()) { sizeAboveBelow.width = paraData.GetSpaceAbove(); sizeAboveBelow.height = paraData.GetSpaceBelow(); } diff --git a/xfa/fxfa/cxfa_textlayout.cpp b/xfa/fxfa/cxfa_textlayout.cpp index bec116c65e..93c1beebf7 100644 --- a/xfa/fxfa/cxfa_textlayout.cpp +++ b/xfa/fxfa/cxfa_textlayout.cpp @@ -105,7 +105,7 @@ void CXFA_TextLayout::InitBreak(float fLineWidth) { CXFA_ParaData paraData = m_pTextProvider->GetParaData(); float fStart = 0; float fStartPos = 0; - if (paraData) { + if (paraData.HasValidNode()) { CFX_RTFLineAlignment iAlign = CFX_RTFLineAlignment::Left; switch (paraData.GetHorizontalAlign()) { case XFA_ATTRIBUTEENUM_Center: @@ -143,7 +143,7 @@ void CXFA_TextLayout::InitBreak(float fLineWidth) { m_pBreak->SetLineStartPos(fStartPos); CXFA_FontData fontData = m_pTextProvider->GetFontData(); - if (fontData) { + if (fontData.HasValidNode()) { m_pBreak->SetHorizontalScale( static_cast<int32_t>(fontData.GetHorizontalScale())); m_pBreak->SetVerticalScale( @@ -647,7 +647,7 @@ void CXFA_TextLayout::LoadText(CXFA_Node* pNode, CXFA_ParaData paraData = m_pTextProvider->GetParaData(); float fSpaceAbove = 0; - if (paraData) { + if (paraData.HasValidNode()) { fSpaceAbove = paraData.GetSpaceAbove(); if (fSpaceAbove < 0.1f) { fSpaceAbove = 0; @@ -1092,7 +1092,7 @@ void CXFA_TextLayout::AppendTextLine(CFX_BreakType dwStatus, m_pBreak->Reset(); if (!pStyle && bEndBreak) { CXFA_ParaData paraData = m_pTextProvider->GetParaData(); - if (paraData) { + if (paraData.HasValidNode()) { float fStartPos = paraData.GetMarginLeft(); float fIndent = paraData.GetTextIndent(); if (fIndent > 0) diff --git a/xfa/fxfa/cxfa_textparser.cpp b/xfa/fxfa/cxfa_textparser.cpp index 0877d21ab1..b74df3d14e 100644 --- a/xfa/fxfa/cxfa_textparser.cpp +++ b/xfa/fxfa/cxfa_textparser.cpp @@ -59,7 +59,8 @@ void CXFA_TextParser::InitCSSData(CXFA_TextProvider* pTextProvider) { m_pSelector = pdfium::MakeUnique<CFX_CSSStyleSelector>(); CXFA_FontData fontData = pTextProvider->GetFontData(); - m_pSelector->SetDefFontSize(fontData ? fontData.GetFontSize() : 10.0f); + m_pSelector->SetDefFontSize(fontData.HasValidNode() ? fontData.GetFontSize() + : 10.0f); } if (m_cssInitialized) @@ -95,7 +96,7 @@ RetainPtr<CFX_CSSComputedStyle> CXFA_TextParser::CreateRootStyle( float fLineHeight = 0; float fFontSize = 10; - if (paraData) { + if (paraData.HasValidNode()) { fLineHeight = paraData.GetLineHeight(); CFX_CSSLength indent; indent.Set(CFX_CSSLengthUnit::Point, paraData.GetTextIndent()); @@ -127,7 +128,7 @@ RetainPtr<CFX_CSSComputedStyle> CXFA_TextParser::CreateRootStyle( } CXFA_FontData fontData = pTextProvider->GetFontData(); - if (fontData) { + if (fontData.HasValidNode()) { pStyle->SetColor(fontData.GetColor()); pStyle->SetFontStyle(fontData.IsItalic() ? CFX_CSSFontStyle::Italic : CFX_CSSFontStyle::Normal); @@ -292,7 +293,8 @@ std::unique_ptr<CXFA_TextParser::TagProvider> CXFA_TextParser::ParseTagInfo( int32_t CXFA_TextParser::GetVAlign(CXFA_TextProvider* pTextProvider) const { CXFA_ParaData paraData = pTextProvider->GetParaData(); - return paraData ? paraData.GetVerticalAlign() : XFA_ATTRIBUTEENUM_Top; + return paraData.HasValidNode() ? paraData.GetVerticalAlign() + : XFA_ATTRIBUTEENUM_Top; } float CXFA_TextParser::GetTabInterval(CFX_CSSComputedStyle* pStyle) const { @@ -324,7 +326,7 @@ RetainPtr<CFGAS_GEFont> CXFA_TextParser::GetFont( WideString wsFamily = L"Courier"; uint32_t dwStyle = 0; CXFA_FontData fontData = pTextProvider->GetFontData(); - if (fontData) { + if (fontData.HasValidNode()) { fontData.GetTypeface(wsFamily); if (fontData.IsBold()) dwStyle |= FXFONT_BOLD; @@ -355,7 +357,7 @@ float CXFA_TextParser::GetFontSize(CXFA_TextProvider* pTextProvider, return pStyle->GetFontSize(); CXFA_FontData fontData = pTextProvider->GetFontData(); - return fontData ? fontData.GetFontSize() : 10; + return fontData.HasValidNode() ? fontData.GetFontSize() : 10; } int32_t CXFA_TextParser::GetHorScale(CXFA_TextProvider* pTextProvider, @@ -381,7 +383,9 @@ int32_t CXFA_TextParser::GetHorScale(CXFA_TextProvider* pTextProvider, } CXFA_FontData fontData = pTextProvider->GetFontData(); - return fontData ? static_cast<int32_t>(fontData.GetHorizontalScale()) : 100; + return fontData.HasValidNode() + ? static_cast<int32_t>(fontData.GetHorizontalScale()) + : 100; } int32_t CXFA_TextParser::GetVerScale(CXFA_TextProvider* pTextProvider, @@ -393,7 +397,9 @@ int32_t CXFA_TextParser::GetVerScale(CXFA_TextProvider* pTextProvider, } CXFA_FontData fontData = pTextProvider->GetFontData(); - return fontData ? static_cast<int32_t>(fontData.GetVerticalScale()) : 100; + return fontData.HasValidNode() + ? static_cast<int32_t>(fontData.GetVerticalScale()) + : 100; } void CXFA_TextParser::GetUnderline(CXFA_TextProvider* pTextProvider, @@ -404,7 +410,7 @@ void CXFA_TextParser::GetUnderline(CXFA_TextProvider* pTextProvider, iPeriod = XFA_ATTRIBUTEENUM_All; CXFA_FontData fontData = pTextProvider->GetFontData(); if (!pStyle) { - if (fontData) { + if (fontData.HasValidNode()) { iUnderline = fontData.GetUnderline(); iPeriod = fontData.GetUnderlinePeriod(); } @@ -421,7 +427,7 @@ void CXFA_TextParser::GetUnderline(CXFA_TextProvider* pTextProvider, if (pStyle->GetCustomStyle(L"underlinePeriod", wsValue)) { if (wsValue == L"word") iPeriod = XFA_ATTRIBUTEENUM_Word; - } else if (fontData) { + } else if (fontData.HasValidNode()) { iPeriod = fontData.GetUnderlinePeriod(); } } @@ -436,7 +442,7 @@ void CXFA_TextParser::GetLinethrough(CXFA_TextProvider* pTextProvider, } CXFA_FontData fontData = pTextProvider->GetFontData(); - if (fontData) + if (fontData.HasValidNode()) iLinethrough = fontData.GetLineThrough(); } @@ -446,7 +452,7 @@ FX_ARGB CXFA_TextParser::GetColor(CXFA_TextProvider* pTextProvider, return pStyle->GetColor(); CXFA_FontData fontData = pTextProvider->GetFontData(); - return fontData ? fontData.GetColor() : 0xFF000000; + return fontData.HasValidNode() ? fontData.GetColor() : 0xFF000000; } float CXFA_TextParser::GetBaseline(CXFA_TextProvider* pTextProvider, @@ -454,8 +460,10 @@ float CXFA_TextParser::GetBaseline(CXFA_TextProvider* pTextProvider, if (pStyle) { if (pStyle->GetVerticalAlign() == CFX_CSSVerticalAlign::Number) return pStyle->GetNumberVerticalAlign(); - } else if (CXFA_FontData fontData = pTextProvider->GetFontData()) { - return fontData.GetBaselineShift(); + } else { + CXFA_FontData fontData = pTextProvider->GetFontData(); + if (fontData.HasValidNode()) + return fontData.GetBaselineShift(); } return 0; } @@ -465,10 +473,13 @@ float CXFA_TextParser::GetLineHeight(CXFA_TextProvider* pTextProvider, bool bFirst, float fVerScale) const { float fLineHeight = 0; - if (pStyle) + if (pStyle) { fLineHeight = pStyle->GetLineHeight(); - else if (CXFA_ParaData paraData = pTextProvider->GetParaData()) - fLineHeight = paraData.GetLineHeight(); + } else { + CXFA_ParaData paraData = pTextProvider->GetParaData(); + if (paraData.HasValidNode()) + fLineHeight = paraData.GetLineHeight(); + } if (bFirst) { float fFontSize = GetFontSize(pTextProvider, pStyle); diff --git a/xfa/fxfa/cxfa_widgetacc.cpp b/xfa/fxfa/cxfa_widgetacc.cpp index 192948d41e..4adc447aaa 100644 --- a/xfa/fxfa/cxfa_widgetacc.cpp +++ b/xfa/fxfa/cxfa_widgetacc.cpp @@ -70,11 +70,11 @@ class CXFA_ImageLayoutData : public CXFA_WidgetLayoutData { return true; CXFA_ValueData valueData = pAcc->GetFormValueData(); - if (!valueData) + if (!valueData.HasValidNode()) return false; CXFA_ImageData imageData = valueData.GetImageData(); - if (!imageData) + if (!imageData.HasValidNode()) return false; CXFA_FFDoc* pFFDoc = pAcc->GetDoc(); @@ -98,8 +98,10 @@ class CXFA_FieldLayoutData : public CXFA_WidgetLayoutData { if (m_pCapTextLayout) return true; CXFA_CaptionData captionData = pAcc->GetCaptionData(); - if (!captionData || captionData.GetPresence() == XFA_ATTRIBUTEENUM_Hidden) + if (!captionData.HasValidNode() || + captionData.GetPresence() == XFA_ATTRIBUTEENUM_Hidden) { return false; + } m_pCapTextProvider = pdfium::MakeUnique<CXFA_TextProvider>( pAcc, XFA_TEXTPROVIDERTYPE_Caption); @@ -130,7 +132,7 @@ class CXFA_ImageEditData : public CXFA_FieldLayoutData { return true; CXFA_ValueData valueData = pAcc->GetFormValueData(); - if (!valueData) + if (!valueData.HasValidNode()) return false; CXFA_ImageData imageData = valueData.GetImageData(); @@ -173,7 +175,7 @@ void CXFA_WidgetAcc::ResetData() { CXFA_ValueData imageValueData = GetDefaultValueData(); CXFA_ImageData imageData = imageValueData.GetImageData(); WideString wsContentType, wsHref; - if (imageData) { + if (imageData.HasValidNode()) { imageData.GetContent(wsValue); imageData.GetContentType(wsContentType); imageData.GetHref(wsHref); @@ -191,12 +193,17 @@ void CXFA_WidgetAcc::ResetData() { if (!pAcc) continue; - CXFA_ValueData defValueData(nullptr); - if (wsValue.IsEmpty() && (defValueData = pAcc->GetDefaultValueData())) { - defValueData.GetChildValueContent(wsValue); - SetValue(wsValue, XFA_VALUEPICTURE_Raw); - pAcc->SetValue(wsValue, XFA_VALUEPICTURE_Raw); - } else { + bool done = false; + if (wsValue.IsEmpty()) { + CXFA_ValueData defValueData = pAcc->GetDefaultValueData(); + if (defValueData.HasValidNode()) { + defValueData.GetChildValueContent(wsValue); + SetValue(wsValue, XFA_VALUEPICTURE_Raw); + pAcc->SetValue(wsValue, XFA_VALUEPICTURE_Raw); + done = true; + } + } + if (!done) { CXFA_Node* pItems = pChild->GetChild(0, XFA_Element::Items, false); if (!pItems) continue; @@ -217,12 +224,14 @@ void CXFA_WidgetAcc::ResetData() { } case XFA_Element::ChoiceList: ClearAllSelections(); - default: - if (CXFA_ValueData defValueData = GetDefaultValueData()) + default: { + CXFA_ValueData defValueData = GetDefaultValueData(); + if (defValueData.HasValidNode()) defValueData.GetChildValueContent(wsValue); SetValue(wsValue, XFA_VALUEPICTURE_Raw); break; + } } } @@ -230,7 +239,7 @@ void CXFA_WidgetAcc::SetImageEdit(const WideString& wsContentType, const WideString& wsHref, const WideString& wsData) { CXFA_ImageData imageData = GetFormValueData().GetImageData(); - if (imageData) { + if (imageData.HasValidNode()) { imageData.SetContentType(WideString(wsContentType)); imageData.SetHref(wsHref); } @@ -291,7 +300,7 @@ int32_t CXFA_WidgetAcc::ProcessEvent(int32_t iActivity, int32_t CXFA_WidgetAcc::ProcessEvent(const CXFA_EventData& eventData, CXFA_EventParam* pEventParam) { - if (!eventData) + if (!eventData.HasValidNode()) return XFA_EVENTERROR_NotExist; switch (eventData.GetEventType()) { @@ -315,7 +324,7 @@ int32_t CXFA_WidgetAcc::ProcessCalculate() { return XFA_EVENTERROR_NotExist; CXFA_CalculateData calcData = GetCalculateData(); - if (!calcData) + if (!calcData.HasValidNode()) return XFA_EVENTERROR_NotExist; if (GetNode()->IsUserInteractive()) return XFA_EVENTERROR_Disabled; @@ -497,9 +506,12 @@ WideString CXFA_WidgetAcc::GetValidateCaptionName(bool bVersionFlag) { WideString wsCaptionName; if (!bVersionFlag) { - if (CXFA_CaptionData captionData = GetCaptionData()) { - if (CXFA_ValueData capValue = captionData.GetValueData()) { - if (CXFA_TextData captionTextData = capValue.GetTextData()) + CXFA_CaptionData captionData = GetCaptionData(); + if (captionData.HasValidNode()) { + CXFA_ValueData capValue = captionData.GetValueData(); + if (capValue.HasValidNode()) { + CXFA_TextData captionTextData = capValue.GetTextData(); + if (captionTextData.HasValidNode()) wsCaptionName = captionTextData.GetContent(); } } @@ -528,7 +540,7 @@ int32_t CXFA_WidgetAcc::ProcessValidate(int32_t iFlags) { return XFA_EVENTERROR_NotExist; CXFA_ValidateData validateData = GetValidateData(false); - if (!validateData) + if (!validateData.HasValidNode()) return XFA_EVENTERROR_NotExist; bool bInitDoc = validateData.GetNode()->NeedsInitApp(); @@ -538,7 +550,7 @@ int32_t CXFA_WidgetAcc::ProcessValidate(int32_t iFlags) { CXFA_ScriptData scriptData = validateData.GetScriptData(); bool bRet = false; bool hasBoolResult = (bInitDoc || bStatus) && GetRawValue().IsEmpty(); - if (scriptData) { + if (scriptData.HasValidNode()) { CXFA_EventParam eParam; eParam.m_eType = XFA_EVENT_Validate; eParam.m_pTarget = this; @@ -582,7 +594,7 @@ std::pair<int32_t, bool> CXFA_WidgetAcc::ExecuteBoolScript( return {XFA_EVENTERROR_Success, false}; ASSERT(pEventParam); - if (!scriptData) + if (!scriptData.HasValidNode()) return {XFA_EVENTERROR_NotExist, false}; if (scriptData.GetRunAt() == XFA_ATTRIBUTEENUM_Server) return {XFA_EVENTERROR_Disabled, false}; @@ -675,8 +687,10 @@ void CXFA_WidgetAcc::UpdateUIDisplay(CXFA_FFWidget* pExcept) { void CXFA_WidgetAcc::CalcCaptionSize(CFX_SizeF& szCap) { CXFA_CaptionData captionData = GetCaptionData(); - if (!captionData || captionData.GetPresence() != XFA_ATTRIBUTEENUM_Visible) + if (!captionData.HasValidNode() || + captionData.GetPresence() != XFA_ATTRIBUTEENUM_Visible) { return; + } LoadCaption(); XFA_Element eUIType = GetUIType(); @@ -698,10 +712,14 @@ void CXFA_WidgetAcc::CalcCaptionSize(CFX_SizeF& szCap) { bVert ? szCap.height = fCapReserve : szCap.width = fCapReserve; } else { float fFontSize = 10.0f; - if (CXFA_FontData fontData = captionData.GetFontData()) + CXFA_FontData fontData = captionData.GetFontData(); + if (fontData.HasValidNode()) { fFontSize = fontData.GetFontSize(); - else if (CXFA_FontData widgetfontData = GetFontData(false)) - fFontSize = widgetfontData.GetFontSize(); + } else { + CXFA_FontData widgetfontData = GetFontData(false); + if (widgetfontData.HasValidNode()) + fFontSize = widgetfontData.GetFontSize(); + } if (bVert) { szCap.height = fCapReserve > 0 ? fCapReserve : fFontSize; @@ -710,8 +728,13 @@ void CXFA_WidgetAcc::CalcCaptionSize(CFX_SizeF& szCap) { szCap.height = fFontSize; } } - if (CXFA_MarginData captionMarginData = captionData.GetMarginData()) { - float fLeftInset, fTopInset, fRightInset, fBottomInset; + + CXFA_MarginData captionMarginData = captionData.GetMarginData(); + if (captionMarginData.HasValidNode()) { + float fLeftInset; + float fTopInset; + float fRightInset; + float fBottomInset; captionMarginData.GetLeftInset(fLeftInset); captionMarginData.GetTopInset(fTopInset); captionMarginData.GetRightInset(fRightInset); @@ -755,7 +778,7 @@ bool CXFA_WidgetAcc::CalculateFieldAutoSize(CFX_SizeF& size) { bool CXFA_WidgetAcc::CalculateWidgetAutoSize(CFX_SizeF& size) { CXFA_MarginData marginData = GetMarginData(); - if (marginData) { + if (marginData.HasValidNode()) { float fLeftInset, fTopInset, fRightInset, fBottomInset; marginData.GetLeftInset(fLeftInset); marginData.GetTopInset(fTopInset); @@ -766,7 +789,7 @@ bool CXFA_WidgetAcc::CalculateWidgetAutoSize(CFX_SizeF& size) { } CXFA_ParaData paraData = GetParaData(); - if (paraData) + if (paraData.HasValidNode()) size.width += paraData.GetMarginLeft() + paraData.GetTextIndent(); float fVal = 0; @@ -850,7 +873,7 @@ bool CXFA_WidgetAcc::CalculateTextEditAutoSize(CFX_SizeF& size) { CFX_RectF rtUIMargin = GetUIMargin(); size.width -= rtUIMargin.left + rtUIMargin.width; CXFA_MarginData marginData = GetMarginData(); - if (marginData) { + if (marginData.HasValidNode()) { float fLeftInset; float fRightInset; marginData.GetLeftInset(fLeftInset); @@ -997,7 +1020,7 @@ void CXFA_WidgetAcc::LoadText() { float CXFA_WidgetAcc::CalculateWidgetAutoWidth(float fWidthCalc) { CXFA_MarginData marginData = GetMarginData(); - if (marginData) { + if (marginData.HasValidNode()) { float fLeftInset; float fRightInset; marginData.GetLeftInset(fLeftInset); @@ -1016,7 +1039,7 @@ float CXFA_WidgetAcc::CalculateWidgetAutoWidth(float fWidthCalc) { float CXFA_WidgetAcc::GetWidthWithoutMargin(float fWidthCalc) { CXFA_MarginData marginData = GetMarginData(); - if (marginData) { + if (marginData.HasValidNode()) { float fLeftInset; float fRightInset; marginData.GetLeftInset(fLeftInset); @@ -1028,7 +1051,7 @@ float CXFA_WidgetAcc::GetWidthWithoutMargin(float fWidthCalc) { float CXFA_WidgetAcc::CalculateWidgetAutoHeight(float fHeightCalc) { CXFA_MarginData marginData = GetMarginData(); - if (marginData) { + if (marginData.HasValidNode()) { float fTopInset; float fBottomInset; marginData.GetTopInset(fTopInset); @@ -1047,7 +1070,7 @@ float CXFA_WidgetAcc::CalculateWidgetAutoHeight(float fHeightCalc) { float CXFA_WidgetAcc::GetHeightWithoutMargin(float fHeightCalc) { CXFA_MarginData marginData = GetMarginData(); - if (marginData) { + if (marginData.HasValidNode()) { float fTopInset; float fBottomInset; marginData.GetTopInset(fTopInset); @@ -1146,7 +1169,7 @@ bool CXFA_WidgetAcc::FindSplitPos(int32_t iBlockIndex, float& fCalcHeight) { float fBottomInset = 0; if (iBlockIndex == 0) { CXFA_MarginData marginData = GetMarginData(); - if (marginData) { + if (marginData.HasValidNode()) { marginData.GetTopInset(fTopInset); marginData.GetBottomInset(fBottomInset); } @@ -1180,7 +1203,8 @@ bool CXFA_WidgetAcc::FindSplitPos(int32_t iBlockIndex, float& fCalcHeight) { float fCapReserve = 0; if (iBlockIndex == 0) { CXFA_CaptionData captionData = GetCaptionData(); - if (captionData && captionData.GetPresence() != XFA_ATTRIBUTEENUM_Hidden) { + if (captionData.HasValidNode() && + captionData.GetPresence() != XFA_ATTRIBUTEENUM_Hidden) { iCapPlacement = (XFA_ATTRIBUTEENUM)captionData.GetPlacementType(); fCapReserve = captionData.GetReserve(); } @@ -1230,7 +1254,8 @@ bool CXFA_WidgetAcc::FindSplitPos(int32_t iBlockIndex, float& fCalcHeight) { if (fHeight > 0.1f && iBlockIndex == 0) { fStartOffset = fTopInset; fHeight -= (fTopInset + fBottomInset); - if (CXFA_ParaData paraData = GetParaData()) { + CXFA_ParaData paraData = GetParaData(); + if (paraData.HasValidNode()) { fSpaceAbove = paraData.GetSpaceAbove(); float fSpaceBelow = paraData.GetSpaceBelow(); fHeight -= (fSpaceAbove + fSpaceBelow); @@ -1475,7 +1500,8 @@ void CXFA_WidgetAcc::SetImageEditImage( RetainPtr<CFGAS_GEFont> CXFA_WidgetAcc::GetFDEFont() { WideString wsFontName = L"Courier"; uint32_t dwFontStyle = 0; - if (CXFA_FontData fontData = GetFontData(false)) { + CXFA_FontData fontData = GetFontData(false); + if (fontData.HasValidNode()) { if (fontData.IsBold()) dwFontStyle |= FXFONT_BOLD; if (fontData.IsItalic()) @@ -1490,13 +1516,14 @@ RetainPtr<CFGAS_GEFont> CXFA_WidgetAcc::GetFDEFont() { float CXFA_WidgetAcc::GetFontSize() { CXFA_FontData fontData = GetFontData(false); - float fFontSize = fontData ? fontData.GetFontSize() : 10.0f; + float fFontSize = fontData.HasValidNode() ? fontData.GetFontSize() : 10.0f; return fFontSize < 0.1f ? 10.0f : fFontSize; } float CXFA_WidgetAcc::GetLineHeight() { float fLineHeight = 0; - if (CXFA_ParaData paraData = GetParaData()) + CXFA_ParaData paraData = GetParaData(); + if (paraData.HasValidNode()) fLineHeight = paraData.GetLineHeight(); if (fLineHeight < 1) fLineHeight = GetFontSize() * 1.2f; @@ -1505,5 +1532,5 @@ float CXFA_WidgetAcc::GetLineHeight() { FX_ARGB CXFA_WidgetAcc::GetTextColor() { CXFA_FontData fontData = GetFontData(false); - return fontData ? fontData.GetColor() : 0xFF000000; + return fontData.HasValidNode() ? fontData.GetColor() : 0xFF000000; } diff --git a/xfa/fxfa/parser/cxfa_boxdata.cpp b/xfa/fxfa/parser/cxfa_boxdata.cpp index 5545494aac..a9f7ace13e 100644 --- a/xfa/fxfa/parser/cxfa_boxdata.cpp +++ b/xfa/fxfa/parser/cxfa_boxdata.cpp @@ -22,7 +22,7 @@ std::vector<CXFA_StrokeData> GetStrokesInternal(CXFA_Node* pNode, bool bNull) { for (i = 0, j = 0; i < 4; i++) { CXFA_CornerData cornerData = CXFA_CornerData( pNode->JSNode()->GetProperty(i, XFA_Element::Corner, i == 0)); - if (cornerData || i == 0) { + if (cornerData.HasValidNode() || i == 0) { strokes[j] = cornerData; } else if (!bNull) { if (i == 1 || i == 2) @@ -33,7 +33,7 @@ std::vector<CXFA_StrokeData> GetStrokesInternal(CXFA_Node* pNode, bool bNull) { j++; CXFA_EdgeData edgeData = CXFA_EdgeData( pNode->JSNode()->GetProperty(i, XFA_Element::Edge, i == 0)); - if (edgeData || i == 0) { + if (edgeData.HasValidNode() || i == 0) { strokes[j] = edgeData; } else if (!bNull) { if (i == 1 || i == 2) @@ -54,10 +54,10 @@ static int32_t Style3D(const std::vector<CXFA_StrokeData>& strokes, strokeData = strokes[0]; for (size_t i = 1; i < strokes.size(); i++) { CXFA_StrokeData find = strokes[i]; - if (!find) + if (!find.HasValidNode()) continue; - if (!strokeData) + if (!strokeData.HasValidNode()) strokeData = find; else if (strokeData.GetStrokeType() != find.GetStrokeType()) strokeData = find; diff --git a/xfa/fxfa/parser/cxfa_calculatedata.cpp b/xfa/fxfa/parser/cxfa_calculatedata.cpp index fb101d9244..ff71e33824 100644 --- a/xfa/fxfa/parser/cxfa_calculatedata.cpp +++ b/xfa/fxfa/parser/cxfa_calculatedata.cpp @@ -28,7 +28,7 @@ WideString CXFA_CalculateData::GetMessageText() { return L""; CXFA_TextData textData(pNode->GetChild(0, XFA_Element::Text, false)); - if (!textData) + if (!textData.HasValidNode()) return L""; return textData.GetContent(); } diff --git a/xfa/fxfa/parser/cxfa_datadata.h b/xfa/fxfa/parser/cxfa_datadata.h index a05b5024fe..260ebbd5da 100644 --- a/xfa/fxfa/parser/cxfa_datadata.h +++ b/xfa/fxfa/parser/cxfa_datadata.h @@ -20,7 +20,7 @@ class CXFA_DataData { explicit CXFA_DataData(CXFA_Node* pNode); virtual ~CXFA_DataData(); - explicit operator bool() const { return !!m_pNode; } + bool HasValidNode() const { return !!m_pNode; } CXFA_Node* GetNode() const { return m_pNode; } XFA_Element GetElementType() const; diff --git a/xfa/fxfa/parser/cxfa_fontdata.cpp b/xfa/fxfa/parser/cxfa_fontdata.cpp index b3e23813ea..17bd6b8f3f 100644 --- a/xfa/fxfa/parser/cxfa_fontdata.cpp +++ b/xfa/fxfa/parser/cxfa_fontdata.cpp @@ -83,5 +83,5 @@ void CXFA_FontData::SetColor(FX_ARGB color) { FX_ARGB CXFA_FontData::GetColor() { CXFA_FillData fillData(m_pNode->GetChild(0, XFA_Element::Fill, false)); - return fillData ? fillData.GetColor(true) : 0xFF000000; + return fillData.HasValidNode() ? fillData.GetColor(true) : 0xFF000000; } diff --git a/xfa/fxfa/parser/cxfa_widgetdata.cpp b/xfa/fxfa/parser/cxfa_widgetdata.cpp index cff2d6b004..b5ceb4a4d4 100644 --- a/xfa/fxfa/parser/cxfa_widgetdata.cpp +++ b/xfa/fxfa/parser/cxfa_widgetdata.cpp @@ -364,19 +364,21 @@ CFX_RectF CXFA_WidgetData::GetUIMargin() { pUIChild ? pUIChild->JSNode()->GetProperty(0, XFA_Element::Margin, false) : nullptr); - if (!mgUI) + if (!mgUI.HasValidNode()) return CFX_RectF(); CXFA_BorderData borderData = GetUIBorderData(); - if (borderData && borderData.GetPresence() != XFA_ATTRIBUTEENUM_Visible) + if (borderData.HasValidNode() && + borderData.GetPresence() != XFA_ATTRIBUTEENUM_Visible) { return CFX_RectF(); + } float fLeftInset, fTopInset, fRightInset, fBottomInset; bool bLeft = mgUI.GetLeftInset(fLeftInset); bool bTop = mgUI.GetTopInset(fTopInset); bool bRight = mgUI.GetRightInset(fRightInset); bool bBottom = mgUI.GetBottomInset(fBottomInset); - if (borderData) { + if (borderData.HasValidNode()) { bool bVisible = false; float fThickness = 0; int32_t iType = 0; @@ -492,7 +494,7 @@ XFA_CHECKSTATE CXFA_WidgetData::GetCheckState() { void CXFA_WidgetData::SetCheckState(XFA_CHECKSTATE eCheckState, bool bNotify) { CXFA_WidgetData exclGroup(GetExclGroupNode()); - if (exclGroup) { + if (exclGroup.HasValidNode()) { WideString wsValue; if (eCheckState != XFA_CHECKSTATE_Off) { if (CXFA_Node* pItems = m_pNode->GetChild(0, XFA_Element::Items, false)) { @@ -1504,7 +1506,7 @@ WideString CXFA_WidgetData::GetPictureContent(XFA_VALUEPICTURE ePicture) { } case XFA_VALUEPICTURE_DataBind: { CXFA_BindData bindData = GetBindData(); - if (bindData) + if (bindData.HasValidNode()) return bindData.GetPicture(); break; } diff --git a/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp b/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp index ac7fb2ec85..9e33b72936 100644 --- a/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp +++ b/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp @@ -141,7 +141,7 @@ void CreateDataBinding(CXFA_Node* pFormNode, CXFA_ImageData imageData = defValueData.GetImageData(); WideString wsContentType; WideString wsHref; - if (imageData) { + if (imageData.HasValidNode()) { imageData.GetContent(wsValue); imageData.GetContentType(wsContentType); imageData.GetHref(wsHref); @@ -297,7 +297,7 @@ void CreateDataBinding(CXFA_Node* pFormNode, FormValueNode_SetChildContent(defValueData.GetNode(), wsNormalizeValue, XFA_Element::Image); CXFA_ImageData imageData = defValueData.GetImageData(); - if (imageData) { + if (imageData.HasValidNode()) { CFX_XMLElement* pXMLDataElement = static_cast<CFX_XMLElement*>(pDataNode->GetXMLMappingNode()); ASSERT(pXMLDataElement); @@ -333,7 +333,8 @@ void CreateDataBinding(CXFA_Node* pFormNode, wsNormalizeValue += wsItem; } CXFA_ExDataData exData = defValueData.GetExData(); - ASSERT(exData); + ASSERT(exData.HasValidNode()); + exData.SetContentType(single ? L"text/plain" : L"text/xml"); } FormValueNode_SetChildContent(defValueData.GetNode(), wsNormalizeValue, |