diff options
-rw-r--r-- | xfa/fxfa/cxfa_textprovider.cpp | 2 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_widgetacc.cpp | 65 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_widgetdata.cpp | 12 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_widgetdata.h | 12 |
4 files changed, 49 insertions, 42 deletions
diff --git a/xfa/fxfa/cxfa_textprovider.cpp b/xfa/fxfa/cxfa_textprovider.cpp index 544a5c26b9..edefc2960c 100644 --- a/xfa/fxfa/cxfa_textprovider.cpp +++ b/xfa/fxfa/cxfa_textprovider.cpp @@ -134,7 +134,7 @@ bool CXFA_TextProvider::IsCheckButtonAndAutoWidth() { return false; float fWidth = 0; - return !m_pWidgetAcc->GetWidth(fWidth); + return !m_pWidgetAcc->TryWidth(fWidth); } bool CXFA_TextProvider::GetEmbbedObj(bool bURI, diff --git a/xfa/fxfa/cxfa_widgetacc.cpp b/xfa/fxfa/cxfa_widgetacc.cpp index cc9f38141f..fc7e52252d 100644 --- a/xfa/fxfa/cxfa_widgetacc.cpp +++ b/xfa/fxfa/cxfa_widgetacc.cpp @@ -783,26 +783,29 @@ bool CXFA_WidgetAcc::CalculateWidgetAutoSize(CFX_SizeF& size) { if (paraData.HasValidNode()) size.width += paraData.GetMarginLeft() + paraData.GetTextIndent(); - float fVal = 0; - float fMin = 0; - float fMax = 0; - if (GetWidth(fVal)) { - size.width = fVal; + float width = 0; + if (TryWidth(width)) { + size.width = width; } else { - if (GetMinWidth(fMin)) + float fMin = 0; + if (TryMinWidth(fMin)) size.width = std::max(size.width, fMin); - if (GetMaxWidth(fMax) && fMax > 0) + + float fMax = 0; + if (TryMaxWidth(fMax) && fMax > 0) size.width = std::min(size.width, fMax); } - fVal = 0; - fMin = 0; - fMax = 0; - if (GetHeight(fVal)) { - size.height = fVal; + + float height = 0; + if (TryHeight(height)) { + size.height = height; } else { - if (GetMinHeight(fMin)) + float fMin = 0; + if (TryMinHeight(fMin)) size.height = std::max(size.height, fMin); - if (GetMaxHeight(fMax) && fMax > 0) + + float fMax = 0; + if (TryMaxHeight(fMax) && fMax > 0) size.height = std::min(size.height, fMax); } return true; @@ -917,12 +920,12 @@ bool CXFA_WidgetAcc::CalculateImageAutoSize(CFX_SizeF& size) { XFA_UnitPx2Pt((float)pBitmap->GetHeight(), (float)iImageYDpi)); CFX_RectF rtFit; - if (GetWidth(rtFit.width)) + if (TryWidth(rtFit.width)) GetWidthWithoutMargin(rtFit.width); else rtFit.width = rtImage.width; - if (GetHeight(rtFit.height)) + if (TryHeight(rtFit.height)) GetHeightWithoutMargin(rtFit.height); else rtFit.height = rtImage.height; @@ -947,12 +950,12 @@ bool CXFA_WidgetAcc::CalculateImageEditAutoSize(CFX_SizeF& size) { XFA_UnitPx2Pt((float)pBitmap->GetHeight(), (float)iImageYDpi)); CFX_RectF rtFit; - if (GetWidth(rtFit.width)) + if (TryWidth(rtFit.width)) GetWidthWithoutMargin(rtFit.width); else rtFit.width = rtImage.width; - if (GetHeight(rtFit.height)) + if (TryHeight(rtFit.height)) GetHeightWithoutMargin(rtFit.height); else rtFit.height = rtImage.height; @@ -1010,10 +1013,12 @@ float CXFA_WidgetAcc::CalculateWidgetAutoWidth(float fWidthCalc) { if (marginData.HasValidNode()) fWidthCalc += marginData.GetLeftInset() + marginData.GetRightInset(); - float fMin = 0, fMax = 0; - if (GetMinWidth(fMin)) + float fMin = 0; + if (TryMinWidth(fMin)) fWidthCalc = std::max(fWidthCalc, fMin); - if (GetMaxWidth(fMax) && fMax > 0) + + float fMax = 0; + if (TryMaxWidth(fMax) && fMax > 0) fWidthCalc = std::min(fWidthCalc, fMax); return fWidthCalc; @@ -1031,10 +1036,12 @@ float CXFA_WidgetAcc::CalculateWidgetAutoHeight(float fHeightCalc) { if (marginData.HasValidNode()) fHeightCalc += marginData.GetTopInset() + marginData.GetBottomInset(); - float fMin = 0, fMax = 0; - if (GetMinHeight(fMin)) + float fMin = 0; + if (TryMinHeight(fMin)) fHeightCalc = std::max(fHeightCalc, fMin); - if (GetMaxHeight(fMax) && fMax > 0) + + float fMax = 0; + if (TryMaxHeight(fMax) && fMax > 0) fHeightCalc = std::min(fHeightCalc, fMax); return fHeightCalc; @@ -1052,7 +1059,7 @@ void CXFA_WidgetAcc::StartWidgetLayout(float& fCalcWidth, float& fCalcHeight) { XFA_Element eUIType = GetUIType(); if (eUIType == XFA_Element::Text) { m_pLayoutData->m_fWidgetHeight = -1; - GetHeight(m_pLayoutData->m_fWidgetHeight); + TryHeight(m_pLayoutData->m_fWidgetHeight); StartTextLayout(fCalcWidth, fCalcHeight); return; } @@ -1062,14 +1069,14 @@ void CXFA_WidgetAcc::StartWidgetLayout(float& fCalcWidth, float& fCalcHeight) { m_pLayoutData->m_fWidgetHeight = -1; float fWidth = 0; if (fCalcWidth > 0 && fCalcHeight < 0) { - if (!GetHeight(fCalcHeight)) + if (!TryHeight(fCalcHeight)) CalculateAccWidthAndHeight(eUIType, fCalcWidth, fCalcHeight); m_pLayoutData->m_fWidgetHeight = fCalcHeight; return; } if (fCalcWidth < 0 && fCalcHeight < 0) { - if (!GetWidth(fWidth) || !GetHeight(fCalcHeight)) + if (!TryWidth(fWidth) || !TryHeight(fCalcHeight)) CalculateAccWidthAndHeight(eUIType, fWidth, fCalcHeight); fCalcWidth = fWidth; @@ -1199,7 +1206,7 @@ bool CXFA_WidgetAcc::FindSplitPos(int32_t iBlockIndex, float& fCalcHeight) { } else { if (!pFieldData->m_pTextOut) { float fWidth = 0; - GetWidth(fWidth); + TryWidth(fWidth); CalculateAccWidthAndHeight(eUIType, fWidth, fHeight); } iLinesCount = pFieldData->m_pTextOut->GetTotalLines(); @@ -1392,7 +1399,7 @@ void CXFA_WidgetAcc::StartTextLayout(float& fCalcWidth, float& fCalcHeight) { } if (fCalcWidth < 0 && fCalcHeight < 0) { float fMaxWidth = -1; - bool bRet = GetWidth(fMaxWidth); + bool bRet = TryWidth(fMaxWidth); if (bRet) { float fWidth = GetWidthWithoutMargin(fMaxWidth); pTextLayout->StartLayout(fWidth); diff --git a/xfa/fxfa/parser/cxfa_widgetdata.cpp b/xfa/fxfa/parser/cxfa_widgetdata.cpp index 1828854500..72c2d7fd34 100644 --- a/xfa/fxfa/parser/cxfa_widgetdata.cpp +++ b/xfa/fxfa/parser/cxfa_widgetdata.cpp @@ -327,27 +327,27 @@ CXFA_BindData CXFA_WidgetData::GetBindData() { m_pNode->JSNode()->GetProperty(0, XFA_Element::Bind, false)); } -bool CXFA_WidgetData::GetWidth(float& fWidth) { +bool CXFA_WidgetData::TryWidth(float& fWidth) { return TryMeasure(XFA_Attribute::W, fWidth); } -bool CXFA_WidgetData::GetHeight(float& fHeight) { +bool CXFA_WidgetData::TryHeight(float& fHeight) { return TryMeasure(XFA_Attribute::H, fHeight); } -bool CXFA_WidgetData::GetMinWidth(float& fMinWidth) { +bool CXFA_WidgetData::TryMinWidth(float& fMinWidth) { return TryMeasure(XFA_Attribute::MinW, fMinWidth); } -bool CXFA_WidgetData::GetMinHeight(float& fMinHeight) { +bool CXFA_WidgetData::TryMinHeight(float& fMinHeight) { return TryMeasure(XFA_Attribute::MinH, fMinHeight); } -bool CXFA_WidgetData::GetMaxWidth(float& fMaxWidth) { +bool CXFA_WidgetData::TryMaxWidth(float& fMaxWidth) { return TryMeasure(XFA_Attribute::MaxW, fMaxWidth); } -bool CXFA_WidgetData::GetMaxHeight(float& fMaxHeight) { +bool CXFA_WidgetData::TryMaxHeight(float& fMaxHeight) { return TryMeasure(XFA_Attribute::MaxH, fMaxHeight); } diff --git a/xfa/fxfa/parser/cxfa_widgetdata.h b/xfa/fxfa/parser/cxfa_widgetdata.h index 84369f7177..9d955a3d99 100644 --- a/xfa/fxfa/parser/cxfa_widgetdata.h +++ b/xfa/fxfa/parser/cxfa_widgetdata.h @@ -61,12 +61,12 @@ class CXFA_WidgetData : public CXFA_DataData { CXFA_CalculateData GetCalculateData(); CXFA_ValidateData GetValidateData(bool bModified); - bool GetWidth(float& fWidth); - bool GetHeight(float& fHeight); - bool GetMinWidth(float& fMinWidth); - bool GetMinHeight(float& fMinHeight); - bool GetMaxWidth(float& fMaxWidth); - bool GetMaxHeight(float& fMaxHeight); + bool TryWidth(float& fWidth); + bool TryHeight(float& fHeight); + bool TryMinWidth(float& fMinWidth); + bool TryMinHeight(float& fMinHeight); + bool TryMaxWidth(float& fMaxWidth); + bool TryMaxHeight(float& fMaxHeight); CXFA_BorderData GetUIBorderData(); CFX_RectF GetUIMargin(); |