From c4ecd7b2e10e37a3b29eb380472fbee4936522ac Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Tue, 23 May 2017 10:21:54 -0400 Subject: Cleanup default values and methods in CXFA_Widgetdata MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ie591de17aba54d6d0f96b1133be7d899bab577cf Reviewed-on: https://pdfium-review.googlesource.com/5660 Reviewed-by: Nicolás Peña Commit-Queue: dsinclair --- xfa/fxfa/app/xfa_ffpushbutton.cpp | 2 +- xfa/fxfa/app/xfa_ffwidgetacc.cpp | 4 +-- xfa/fxfa/cxfa_ffdocview.cpp | 6 ++--- xfa/fxfa/cxfa_ffwidget.cpp | 2 +- xfa/fxfa/cxfa_ffwidgethandler.cpp | 5 ++-- xfa/fxfa/cxfa_widgetacc.cpp | 11 ++++----- xfa/fxfa/parser/cxfa_node.cpp | 8 +++--- xfa/fxfa/parser/cxfa_widgetdata.cpp | 49 +++++++++++++++---------------------- xfa/fxfa/parser/cxfa_widgetdata.h | 43 ++++++++++++++++---------------- 9 files changed, 61 insertions(+), 69 deletions(-) diff --git a/xfa/fxfa/app/xfa_ffpushbutton.cpp b/xfa/fxfa/app/xfa_ffpushbutton.cpp index d4b056119f..9d9cf070b4 100644 --- a/xfa/fxfa/app/xfa_ffpushbutton.cpp +++ b/xfa/fxfa/app/xfa_ffpushbutton.cpp @@ -115,7 +115,7 @@ bool CXFA_FFPushButton::PerformLayout() { return true; } float CXFA_FFPushButton::GetLineWidth() { - CXFA_Border border = m_pDataAcc->GetBorder(); + CXFA_Border border = m_pDataAcc->GetBorder(false); if (border && border.GetPresence() == XFA_ATTRIBUTEENUM_Visible) { CXFA_Edge edge = border.GetEdge(0); return edge.GetThickness(); diff --git a/xfa/fxfa/app/xfa_ffwidgetacc.cpp b/xfa/fxfa/app/xfa_ffwidgetacc.cpp index 218537618f..2ac27cfdc8 100644 --- a/xfa/fxfa/app/xfa_ffwidgetacc.cpp +++ b/xfa/fxfa/app/xfa_ffwidgetacc.cpp @@ -118,11 +118,11 @@ CXFA_Para CXFA_TextProvider::GetParaNode() { CXFA_Font CXFA_TextProvider::GetFontNode() { if (m_eType == XFA_TEXTPROVIDERTYPE_Text) - return m_pWidgetAcc->GetFont(); + return m_pWidgetAcc->GetFont(false); CXFA_Node* pNode = m_pWidgetAcc->GetNode()->GetChild(0, XFA_Element::Caption); pNode = pNode->GetChild(0, XFA_Element::Font); - return pNode ? CXFA_Font(pNode) : m_pWidgetAcc->GetFont(); + return pNode ? CXFA_Font(pNode) : m_pWidgetAcc->GetFont(false); } bool CXFA_TextProvider::IsCheckButtonAndAutoWidth() { diff --git a/xfa/fxfa/cxfa_ffdocview.cpp b/xfa/fxfa/cxfa_ffdocview.cpp index d021740edc..d9c97f71b1 100644 --- a/xfa/fxfa/cxfa_ffdocview.cpp +++ b/xfa/fxfa/cxfa_ffdocview.cpp @@ -223,7 +223,7 @@ bool CXFA_FFDocView::ResetSingleWidgetAccData(CXFA_WidgetAcc* pWidgetAcc) { } pWidgetAcc->ResetData(); pWidgetAcc->UpdateUIDisplay(); - if (CXFA_Validate validate = pWidgetAcc->GetValidate()) { + if (CXFA_Validate validate = pWidgetAcc->GetValidate(false)) { AddValidateWidget(pWidgetAcc); validate.GetNode()->SetFlag(XFA_NodeFlag_NeedsInitApp, false); } @@ -743,7 +743,7 @@ void CXFA_FFDocView::RunBindItems() { XFA_RESOLVENODE_ALL; XFA_RESOLVENODE_RS rs; pScriptContext->ResolveObjects(pWidgetNode, wsRef, rs, dwStyle); - pAcc->DeleteItem(-1); + pAcc->DeleteItem(-1, false, false); if (rs.dwFlags != XFA_RESOVENODE_RSTYPE_Nodes || rs.objects.empty()) continue; @@ -777,7 +777,7 @@ void CXFA_FFDocView::RunBindItems() { } else { wsLabel = wsValue; } - pAcc->InsertItem(wsLabel, wsValue); + pAcc->InsertItem(wsLabel, wsValue, false); } } m_BindItems.clear(); diff --git a/xfa/fxfa/cxfa_ffwidget.cpp b/xfa/fxfa/cxfa_ffwidget.cpp index 2ea30b59e5..78bc5ed598 100644 --- a/xfa/fxfa/cxfa_ffwidget.cpp +++ b/xfa/fxfa/cxfa_ffwidget.cpp @@ -116,7 +116,7 @@ void CXFA_FFWidget::RenderWidget(CFX_Graphics* pGS, if (!IsMatchVisibleStatus(dwStatus)) return; - CXFA_Border border = m_pDataAcc->GetBorder(); + CXFA_Border border = m_pDataAcc->GetBorder(false); if (!border) return; diff --git a/xfa/fxfa/cxfa_ffwidgethandler.cpp b/xfa/fxfa/cxfa_ffwidgethandler.cpp index ffc1c27070..6fe24fee29 100644 --- a/xfa/fxfa/cxfa_ffwidgethandler.cpp +++ b/xfa/fxfa/cxfa_ffwidgethandler.cpp @@ -177,13 +177,14 @@ bool CXFA_FFWidgetHandler::HasEvent(CXFA_WidgetAcc* pWidgetAcc, return calc && calc.GetScript(); } case XFA_EVENT_Validate: { - CXFA_Validate val = pWidgetAcc->GetValidate(); + CXFA_Validate val = pWidgetAcc->GetValidate(false); return val && val.GetScript(); } default: break; } - return !pWidgetAcc->GetEventByActivity(gs_EventActivity[eEventType]).empty(); + return !pWidgetAcc->GetEventByActivity(gs_EventActivity[eEventType], false) + .empty(); } int32_t CXFA_FFWidgetHandler::ProcessEvent(CXFA_WidgetAcc* pWidgetAcc, diff --git a/xfa/fxfa/cxfa_widgetacc.cpp b/xfa/fxfa/cxfa_widgetacc.cpp index 3e369d60e3..9b52f95b63 100644 --- a/xfa/fxfa/cxfa_widgetacc.cpp +++ b/xfa/fxfa/cxfa_widgetacc.cpp @@ -554,7 +554,7 @@ int32_t CXFA_WidgetAcc::ProcessValidate(int32_t iFlags) { if (GetElementType() == XFA_Element::Draw) return XFA_EVENTERROR_NotExist; - CXFA_Validate validate = GetValidate(); + CXFA_Validate validate = GetValidate(false); if (!validate) return XFA_EVENTERROR_NotExist; @@ -724,7 +724,7 @@ void CXFA_WidgetAcc::CalcCaptionSize(CFX_SizeF& szCap) { float fFontSize = 10.0f; if (CXFA_Font font = caption.GetFont()) fFontSize = font.GetFontSize(); - else if (CXFA_Font widgetfont = GetFont()) + else if (CXFA_Font widgetfont = GetFont(false)) fFontSize = widgetfont.GetFontSize(); if (bVert) { @@ -1495,7 +1495,7 @@ CXFA_WidgetLayoutData* CXFA_WidgetAcc::GetWidgetLayoutData() { CFX_RetainPtr CXFA_WidgetAcc::GetFDEFont() { CFX_WideStringC wsFontName = L"Courier"; uint32_t dwFontStyle = 0; - if (CXFA_Font font = GetFont()) { + if (CXFA_Font font = GetFont(false)) { if (font.IsBold()) dwFontStyle |= FX_FONTSTYLE_Bold; if (font.IsItalic()) @@ -1510,7 +1510,7 @@ CFX_RetainPtr CXFA_WidgetAcc::GetFDEFont() { float CXFA_WidgetAcc::GetFontSize() { float fFontSize = 10.0f; - if (CXFA_Font font = GetFont()) + if (CXFA_Font font = GetFont(false)) fFontSize = font.GetFontSize(); return fFontSize < 0.1f ? 10.0f : fFontSize; } @@ -1525,8 +1525,7 @@ float CXFA_WidgetAcc::GetLineHeight() { } FX_ARGB CXFA_WidgetAcc::GetTextColor() { - if (CXFA_Font font = GetFont()) { + if (CXFA_Font font = GetFont(false)) return font.GetColor(); - } return 0xFF000000; } diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp index 3c254ef6fc..e7ec4cf890 100644 --- a/xfa/fxfa/parser/cxfa_node.cpp +++ b/xfa/fxfa/parser/cxfa_node.cpp @@ -1867,7 +1867,7 @@ void CXFA_Node::Script_Som_Message(CFXJSE_Value* pValue, return; } bool bNew = false; - CXFA_Validate validate = pWidgetData->GetValidate(); + CXFA_Validate validate = pWidgetData->GetValidate(false); if (!validate) { validate = pWidgetData->GetValidate(true); bNew = true; @@ -2349,7 +2349,7 @@ void CXFA_Node::Script_Field_SelectedIndex(CFXJSE_Value* pValue, } pWidgetData->SetItemState(iIndex, true, true, true, true); } else { - pValue->SetInteger(pWidgetData->GetSelectedItem()); + pValue->SetInteger(pWidgetData->GetSelectedItem(0)); } } @@ -2358,7 +2358,7 @@ void CXFA_Node::Script_Field_ClearItems(CFXJSE_Arguments* pArguments) { if (!pWidgetData) { return; } - pWidgetData->DeleteItem(-1, true); + pWidgetData->DeleteItem(-1, true, false); } void CXFA_Node::Script_Field_ExecEvent(CFXJSE_Arguments* pArguments) { @@ -2546,7 +2546,7 @@ void CXFA_Node::Script_Field_AddItem(CFXJSE_Arguments* pArguments) { CFX_ByteString bsValue = pArguments->GetUTF8String(1); wsValue = CFX_WideString::FromUTF8(bsValue.AsStringC()); } - pWidgetData->InsertItem(wsLabel, wsValue, -1, true); + pWidgetData->InsertItem(wsLabel, wsValue, true); } void CXFA_Node::Script_Field_ExecValidate(CFXJSE_Arguments* pArguments) { diff --git a/xfa/fxfa/parser/cxfa_widgetdata.cpp b/xfa/fxfa/parser/cxfa_widgetdata.cpp index f11a668276..bf9afc062f 100644 --- a/xfa/fxfa/parser/cxfa_widgetdata.cpp +++ b/xfa/fxfa/parser/cxfa_widgetdata.cpp @@ -256,13 +256,7 @@ CFX_WideString CXFA_WidgetData::GetRawValue() { return m_pNode->GetContent(); } -int32_t CXFA_WidgetData::GetAccess(bool bTemplate) { - if (bTemplate) { - CXFA_Node* pNode = m_pNode->GetTemplateNode(); - if (pNode) - return pNode->GetEnum(XFA_ATTRIBUTE_Access); - return XFA_ATTRIBUTEENUM_Open; - } +int32_t CXFA_WidgetData::GetAccess() { CXFA_Node* pNode = m_pNode; while (pNode) { int32_t iAcc = pNode->GetEnum(XFA_ATTRIBUTE_Access); @@ -289,20 +283,20 @@ CXFA_Border CXFA_WidgetData::GetBorder(bool bModified) { return CXFA_Border(m_pNode->GetProperty(0, XFA_Element::Border, bModified)); } -CXFA_Caption CXFA_WidgetData::GetCaption(bool bModified) { - return CXFA_Caption(m_pNode->GetProperty(0, XFA_Element::Caption, bModified)); +CXFA_Caption CXFA_WidgetData::GetCaption() { + return CXFA_Caption(m_pNode->GetProperty(0, XFA_Element::Caption, false)); } CXFA_Font CXFA_WidgetData::GetFont(bool bModified) { return CXFA_Font(m_pNode->GetProperty(0, XFA_Element::Font, bModified)); } -CXFA_Margin CXFA_WidgetData::GetMargin(bool bModified) { - return CXFA_Margin(m_pNode->GetProperty(0, XFA_Element::Margin, bModified)); +CXFA_Margin CXFA_WidgetData::GetMargin() { + return CXFA_Margin(m_pNode->GetProperty(0, XFA_Element::Margin, false)); } -CXFA_Para CXFA_WidgetData::GetPara(bool bModified) { - return CXFA_Para(m_pNode->GetProperty(0, XFA_Element::Para, bModified)); +CXFA_Para CXFA_WidgetData::GetPara() { + return CXFA_Para(m_pNode->GetProperty(0, XFA_Element::Para, false)); } std::vector CXFA_WidgetData::GetEventList() { @@ -333,20 +327,18 @@ std::vector CXFA_WidgetData::GetEventByActivity(int32_t iActivity, return events; } -CXFA_Value CXFA_WidgetData::GetDefaultValue(bool bModified) { +CXFA_Value CXFA_WidgetData::GetDefaultValue() { CXFA_Node* pTemNode = m_pNode->GetTemplateNode(); return CXFA_Value( - pTemNode ? pTemNode->GetProperty(0, XFA_Element::Value, bModified) - : nullptr); + pTemNode ? pTemNode->GetProperty(0, XFA_Element::Value, false) : nullptr); } -CXFA_Value CXFA_WidgetData::GetFormValue(bool bModified) { - return CXFA_Value(m_pNode->GetProperty(0, XFA_Element::Value, bModified)); +CXFA_Value CXFA_WidgetData::GetFormValue() { + return CXFA_Value(m_pNode->GetProperty(0, XFA_Element::Value, false)); } -CXFA_Calculate CXFA_WidgetData::GetCalculate(bool bModified) { - return CXFA_Calculate( - m_pNode->GetProperty(0, XFA_Element::Calculate, bModified)); +CXFA_Calculate CXFA_WidgetData::GetCalculate() { + return CXFA_Calculate(m_pNode->GetProperty(0, XFA_Element::Calculate, false)); } CXFA_Validate CXFA_WidgetData::GetValidate(bool bModified) { @@ -354,12 +346,12 @@ CXFA_Validate CXFA_WidgetData::GetValidate(bool bModified) { m_pNode->GetProperty(0, XFA_Element::Validate, bModified)); } -CXFA_Bind CXFA_WidgetData::GetBind(bool bModified) { - return CXFA_Bind(m_pNode->GetProperty(0, XFA_Element::Bind, bModified)); +CXFA_Bind CXFA_WidgetData::GetBind() { + return CXFA_Bind(m_pNode->GetProperty(0, XFA_Element::Bind, false)); } -CXFA_Assist CXFA_WidgetData::GetAssist(bool bModified) { - return CXFA_Assist(m_pNode->GetProperty(0, XFA_Element::Assist, bModified)); +CXFA_Assist CXFA_WidgetData::GetAssist() { + return CXFA_Assist(m_pNode->GetProperty(0, XFA_Element::Assist, false)); } bool CXFA_WidgetData::GetWidth(float& fWidth) { @@ -968,8 +960,8 @@ void CXFA_WidgetData::ClearAllSelections() { void CXFA_WidgetData::InsertItem(const CFX_WideString& wsLabel, const CFX_WideString& wsValue, - int32_t nIndex, bool bNotify) { + int32_t nIndex = -1; CFX_WideString wsNewValue(wsValue); if (wsNewValue.IsEmpty()) wsNewValue = wsLabel; @@ -1114,8 +1106,7 @@ void CXFA_WidgetData::GetItemValue(const CFX_WideStringC& wsLabel, bool CXFA_WidgetData::DeleteItem(int32_t nIndex, bool bNotify, - bool bScriptModify, - bool bSyncData) { + bool bScriptModify) { bool bSetValue = false; CXFA_Node* pItems = m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild); for (; pItems; pItems = pItems->GetNodeItem(XFA_NODEITEM_NextSibling)) { @@ -1128,7 +1119,7 @@ bool CXFA_WidgetData::DeleteItem(int32_t nIndex, } } else { if (!bSetValue && pItems->GetBoolean(XFA_ATTRIBUTE_Save)) { - SetItemState(nIndex, false, true, bScriptModify, bSyncData); + SetItemState(nIndex, false, true, bScriptModify, true); bSetValue = true; } int32_t i = 0; diff --git a/xfa/fxfa/parser/cxfa_widgetdata.h b/xfa/fxfa/parser/cxfa_widgetdata.h index c38ea3502a..f53d926655 100644 --- a/xfa/fxfa/parser/cxfa_widgetdata.h +++ b/xfa/fxfa/parser/cxfa_widgetdata.h @@ -46,28 +46,30 @@ class CXFA_WidgetData : public CXFA_Data { CXFA_Node* GetUIChild(); XFA_Element GetUIType(); CFX_WideString GetRawValue(); - int32_t GetAccess(bool bTemplate = false); + int32_t GetAccess(); int32_t GetRotate(); - CXFA_Border GetBorder(bool bModified = false); - CXFA_Caption GetCaption(bool bModified = false); - CXFA_Font GetFont(bool bModified = false); - CXFA_Margin GetMargin(bool bModified = false); - CXFA_Para GetPara(bool bModified = false); + + CXFA_Assist GetAssist(); + CXFA_Border GetBorder(bool bModified); + CXFA_Caption GetCaption(); + CXFA_Font GetFont(bool bModified); + CXFA_Margin GetMargin(); + CXFA_Para GetPara(); std::vector GetEventList(); std::vector GetEventByActivity(int32_t iActivity, - bool bIsFormReady = false); - CXFA_Value GetDefaultValue(bool bModified = false); - CXFA_Value GetFormValue(bool bModified = false); - CXFA_Calculate GetCalculate(bool bModified = false); - CXFA_Validate GetValidate(bool bModified = false); - CXFA_Bind GetBind(bool bModified = false); - CXFA_Assist GetAssist(bool bModified = false); + bool bIsFormReady); + CXFA_Value GetDefaultValue(); + CXFA_Value GetFormValue(); + CXFA_Calculate GetCalculate(); + CXFA_Validate GetValidate(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); + CXFA_Border GetUIBorder(); CFX_RectF GetUIMargin(); int32_t GetButtonHighlight(); @@ -99,7 +101,7 @@ class CXFA_WidgetData : public CXFA_Data { bool bSaveValue); std::vector GetChoiceListItems(bool bSaveValue); int32_t CountSelectedItems(); - int32_t GetSelectedItem(int32_t nIndex = 0); + int32_t GetSelectedItem(int32_t nIndex); std::vector GetSelectedItems(); std::vector GetSelectedItemsValue(); bool GetItemState(int32_t nIndex); @@ -115,14 +117,10 @@ class CXFA_WidgetData : public CXFA_Data { void ClearAllSelections(); void InsertItem(const CFX_WideString& wsLabel, const CFX_WideString& wsValue, - int32_t nIndex = -1, - bool bNotify = false); + bool bNotify); void GetItemLabel(const CFX_WideStringC& wsValue, CFX_WideString& wsLabel); void GetItemValue(const CFX_WideStringC& wsLabel, CFX_WideString& wsValue); - bool DeleteItem(int32_t nIndex, - bool bNotify = false, - bool bScriptModify = false, - bool bSyncData = true); + bool DeleteItem(int32_t nIndex, bool bNotify, bool bScriptModify); int32_t GetHorizontalScrollPolicy(); int32_t GetNumberOfCells(); bool SetValue(const CFX_WideString& wsValue, XFA_VALUEPICTURE eValueType); @@ -134,6 +132,7 @@ class CXFA_WidgetData : public CXFA_Data { bool GetFormatDataValue(const CFX_WideString& wsValue, CFX_WideString& wsFormattedValue); void NormalizeNumStr(const CFX_WideString& wsValue, CFX_WideString& wsOutput); + CFX_WideString GetBarcodeType(); bool GetBarcodeAttribute_CharEncoding(int32_t* val); bool GetBarcodeAttribute_Checksum(bool* val); @@ -148,6 +147,7 @@ class CXFA_WidgetData : public CXFA_Data { bool GetBarcodeAttribute_Truncate(bool* val); bool GetBarcodeAttribute_WideNarrowRatio(float* val); void GetPasswordChar(CFX_WideString& wsPassWord); + bool IsMultiLine(); int32_t GetVerticalScrollPolicy(); int32_t GetMaxChars(XFA_Element& eType); @@ -162,10 +162,11 @@ class CXFA_WidgetData : public CXFA_Data { bool m_bPreNull; private: + CXFA_Bind GetBind(); void SyncValue(const CFX_WideString& wsValue, bool bNotify); void InsertListTextItem(CXFA_Node* pItems, const CFX_WideString& wsText, - int32_t nIndex = -1); + int32_t nIndex); void FormatNumStr(const CFX_WideString& wsValue, IFX_Locale* pLocale, CFX_WideString& wsOutput); -- cgit v1.2.3