Fix MSVC C4800 build warnings.
TBR=weili@chromium.org
Review-Url: https://codereview.chromium.org/2017863002
diff --git a/fpdfsdk/fsdk_baseform.cpp b/fpdfsdk/fsdk_baseform.cpp
index ea21511..0f1a0ad 100644
--- a/fpdfsdk/fsdk_baseform.cpp
+++ b/fpdfsdk/fsdk_baseform.cpp
@@ -267,7 +267,7 @@
CPDF_FormControl* pFormCtrl = GetFormControl();
XFA_CHECKSTATE eCheckState =
pFormCtrl->IsChecked() ? XFA_CHECKSTATE_On : XFA_CHECKSTATE_Off;
- pWidgetAcc->SetCheckState(eCheckState);
+ pWidgetAcc->SetCheckState(eCheckState, true);
} break;
case FIELDTYPE_TEXTFIELD:
pWidgetAcc->SetValue(pFormField->GetValue(), XFA_VALUEPICTURE_Edit);
@@ -278,7 +278,7 @@
for (int i = 0, sz = pFormField->CountSelectedItems(); i < sz; i++) {
int nIndex = pFormField->GetSelectedIndex(i);
if (nIndex > -1 && nIndex < pWidgetAcc->CountChoiceListItems())
- pWidgetAcc->SetItemState(nIndex, TRUE, FALSE);
+ pWidgetAcc->SetItemState(nIndex, TRUE, false, FALSE, TRUE);
}
} break;
case FIELDTYPE_COMBOBOX: {
@@ -287,7 +287,7 @@
for (int i = 0, sz = pFormField->CountSelectedItems(); i < sz; i++) {
int nIndex = pFormField->GetSelectedIndex(i);
if (nIndex > -1 && nIndex < pWidgetAcc->CountChoiceListItems())
- pWidgetAcc->SetItemState(nIndex, TRUE, FALSE);
+ pWidgetAcc->SetItemState(nIndex, TRUE, false, FALSE, TRUE);
}
}
diff --git a/xfa/fwl/core/fwl_formimp.cpp b/xfa/fwl/core/fwl_formimp.cpp
index 4b595e2..1dcb310 100644
--- a/xfa/fwl/core/fwl_formimp.cpp
+++ b/xfa/fwl/core/fwl_formimp.cpp
@@ -79,7 +79,7 @@
m_iSysBox(0),
m_eResizeType(FORM_RESIZETYPE_None),
m_bLButtonDown(FALSE),
- m_bMaximized(FALSE),
+ m_bMaximized(false),
m_bSetMaximize(FALSE),
m_bCustomizeLayout(FALSE),
m_eFormSize(FWL_FORMSIZE_Manual),
diff --git a/xfa/fwl/core/fwl_formimp.h b/xfa/fwl/core/fwl_formimp.h
index e1da960..1f2d695 100644
--- a/xfa/fwl/core/fwl_formimp.h
+++ b/xfa/fwl/core/fwl_formimp.h
@@ -160,7 +160,7 @@
int32_t m_iSysBox;
int32_t m_eResizeType;
FX_BOOL m_bLButtonDown;
- FX_BOOL m_bMaximized;
+ bool m_bMaximized;
FX_BOOL m_bSetMaximize;
FX_BOOL m_bCustomizeLayout;
FWL_FORMSIZE m_eFormSize;
diff --git a/xfa/fxfa/app/xfa_ffcheckbutton.cpp b/xfa/fxfa/app/xfa_ffcheckbutton.cpp
index 80a4e92..9e174a2 100644
--- a/xfa/fxfa/app/xfa_ffcheckbutton.cpp
+++ b/xfa/fxfa/app/xfa_ffcheckbutton.cpp
@@ -239,12 +239,9 @@
FX_BOOL CXFA_FFCheckButton::OnLButtonUp(uint32_t dwFlags,
FX_FLOAT fx,
FX_FLOAT fy) {
- if (!m_pNormalWidget) {
+ if (!m_pNormalWidget || !IsButtonDown())
return FALSE;
- }
- if (!IsButtonDown()) {
- return FALSE;
- }
+
SetButtonDown(FALSE);
CFWL_MsgMouse ms;
ms.m_dwCmd = FWL_MouseCommand::LeftButtonUp;
@@ -256,21 +253,22 @@
TranslateFWLMessage(&ms);
return TRUE;
}
+
XFA_CHECKSTATE CXFA_FFCheckButton::FWLState2XFAState() {
- XFA_CHECKSTATE eCheckState = XFA_CHECKSTATE_Off;
uint32_t dwState = m_pNormalWidget->GetStates();
- if (dwState & FWL_STATE_CKB_Checked) {
- eCheckState = XFA_CHECKSTATE_On;
- } else if (dwState & FWL_STATE_CKB_Neutral) {
- eCheckState = XFA_CHECKSTATE_Neutral;
- }
- return eCheckState;
+ if (dwState & FWL_STATE_CKB_Checked)
+ return XFA_CHECKSTATE_On;
+ if (dwState & FWL_STATE_CKB_Neutral)
+ return XFA_CHECKSTATE_Neutral;
+ return XFA_CHECKSTATE_Off;
}
+
FX_BOOL CXFA_FFCheckButton::CommitData() {
XFA_CHECKSTATE eCheckState = FWLState2XFAState();
- m_pDataAcc->SetCheckState(eCheckState, TRUE);
+ m_pDataAcc->SetCheckState(eCheckState, true);
return TRUE;
}
+
FX_BOOL CXFA_FFCheckButton::IsDataChanged() {
XFA_CHECKSTATE eCheckState = FWLState2XFAState();
return m_pDataAcc->GetCheckState() != eCheckState;
diff --git a/xfa/fxfa/app/xfa_ffchoicelist.cpp b/xfa/fxfa/app/xfa_ffchoicelist.cpp
index 3f8ea29..21f96ee 100644
--- a/xfa/fxfa/app/xfa_ffchoicelist.cpp
+++ b/xfa/fxfa/app/xfa_ffchoicelist.cpp
@@ -62,44 +62,41 @@
m_pNormalWidget->UnlockUpdate();
return CXFA_FFField::LoadWidget();
}
+
FX_BOOL CXFA_FFListBox::OnKillFocus(CXFA_FFWidget* pNewFocus) {
- FX_BOOL flag = ProcessCommittedData();
- if (!flag) {
+ if (!ProcessCommittedData())
UpdateFWLData();
- }
CXFA_FFField::OnKillFocus(pNewFocus);
return TRUE;
}
+
FX_BOOL CXFA_FFListBox::CommitData() {
CFWL_ListBox* pListBox = static_cast<CFWL_ListBox*>(m_pNormalWidget);
int32_t iSels = pListBox->CountSelItems();
CFX_Int32Array iSelArray;
- for (int32_t i = 0; i < iSels; i++) {
+ for (int32_t i = 0; i < iSels; ++i)
iSelArray.Add(pListBox->GetSelIndex(i));
- }
- m_pDataAcc->SetSelectedItems(iSelArray, TRUE);
+ m_pDataAcc->SetSelectedItems(iSelArray, true, FALSE, TRUE);
return TRUE;
}
+
FX_BOOL CXFA_FFListBox::IsDataChanged() {
CFX_Int32Array iSelArray;
m_pDataAcc->GetSelectedItems(iSelArray);
int32_t iOldSels = iSelArray.GetSize();
CFWL_ListBox* pListBox = (CFWL_ListBox*)m_pNormalWidget;
int32_t iSels = pListBox->CountSelItems();
- if (iOldSels == iSels) {
- int32_t iIndex = 0;
- for (; iIndex < iSels; iIndex++) {
- FWL_HLISTITEM hlistItem = pListBox->GetItem(iSelArray[iIndex]);
- if (!(pListBox->GetItemStates(hlistItem) && FWL_ITEMSTATE_LTB_Selected)) {
- break;
- }
- }
- if (iIndex == iSels) {
- return FALSE;
- }
+ if (iOldSels != iSels)
+ return TRUE;
+
+ for (int32_t i = 0; i < iSels; ++i) {
+ FWL_HLISTITEM hlistItem = pListBox->GetItem(iSelArray[i]);
+ if (!(pListBox->GetItemStates(hlistItem) && FWL_ITEMSTATE_LTB_Selected))
+ return TRUE;
}
- return TRUE;
+ return FALSE;
}
+
uint32_t CXFA_FFListBox::GetAlignment() {
uint32_t dwExtendedStyle = 0;
if (CXFA_Para para = m_pDataAcc->GetPara()) {
diff --git a/xfa/fxfa/parser/cxfa_widgetdata.cpp b/xfa/fxfa/parser/cxfa_widgetdata.cpp
index 6ef88cd..33dcb47 100644
--- a/xfa/fxfa/parser/cxfa_widgetdata.cpp
+++ b/xfa/fxfa/parser/cxfa_widgetdata.cpp
@@ -380,8 +380,7 @@
return XFA_CHECKSTATE_Off;
}
-void CXFA_WidgetData::SetCheckState(XFA_CHECKSTATE eCheckState,
- FX_BOOL bNotify) {
+void CXFA_WidgetData::SetCheckState(XFA_CHECKSTATE eCheckState, bool bNotify) {
CXFA_WidgetData exclGroup(GetExclGroupNode());
if (exclGroup) {
CFX_WideString wsValue;
@@ -464,23 +463,21 @@
}
CXFA_Node* CXFA_WidgetData::SetSelectedMember(const CFX_WideStringC& wsName,
- FX_BOOL bNotify) {
- CXFA_Node* pSelectedMember = NULL;
+ bool bNotify) {
uint32_t nameHash = FX_HashCode_GetW(wsName, false);
for (CXFA_Node* pNode = ToNode(m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild));
pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) {
if (pNode->GetNameHash() == nameHash) {
CXFA_WidgetData widgetData(pNode);
widgetData.SetCheckState(XFA_CHECKSTATE_On, bNotify);
- pSelectedMember = pNode;
- break;
+ return pNode;
}
}
- return pSelectedMember;
+ return nullptr;
}
void CXFA_WidgetData::SetSelectedMemberByValue(const CFX_WideStringC& wsValue,
- FX_BOOL bNotify,
+ bool bNotify,
FX_BOOL bScriptModify,
FX_BOOL bSyncData) {
CFX_WideString wsExclGroup;
@@ -771,7 +768,7 @@
void CXFA_WidgetData::SetItemState(int32_t nIndex,
FX_BOOL bSelected,
- FX_BOOL bNotify,
+ bool bNotify,
FX_BOOL bScriptModify,
FX_BOOL bSyncData) {
if (nIndex < 0)
@@ -831,7 +828,7 @@
}
void CXFA_WidgetData::SetSelectedItems(CFX_Int32Array& iSelArray,
- FX_BOOL bNotify,
+ bool bNotify,
FX_BOOL bScriptModify,
FX_BOOL bSyncData) {
CFX_WideString wsValue;
@@ -856,14 +853,13 @@
void CXFA_WidgetData::ClearAllSelections() {
CXFA_Node* pBind = m_pNode->GetBindData();
- if (pBind && GetChoiceListOpen() == XFA_ATTRIBUTEENUM_MultiSelect) {
- while (CXFA_Node* pChildNode =
- pBind->GetNodeItem(XFA_NODEITEM_FirstChild)) {
- pBind->RemoveChild(pChildNode);
- }
- } else {
- SyncValue(CFX_WideString(), FALSE);
+ if (!pBind || GetChoiceListOpen() != XFA_ATTRIBUTEENUM_MultiSelect) {
+ SyncValue(CFX_WideString(), false);
+ return;
}
+
+ while (CXFA_Node* pChildNode = pBind->GetNodeItem(XFA_NODEITEM_FirstChild))
+ pBind->RemoveChild(pChildNode);
}
void CXFA_WidgetData::InsertItem(const CFX_WideString& wsLabel,
@@ -1036,7 +1032,7 @@
}
} else {
if (!bSetValue && pItems->GetBoolean(XFA_ATTRIBUTE_Save)) {
- SetItemState(nIndex, FALSE, TRUE, bScriptModify, bSyncData);
+ SetItemState(nIndex, FALSE, true, bScriptModify, bSyncData);
bSetValue = TRUE;
}
int32_t i = 0;
@@ -1318,7 +1314,7 @@
FX_BOOL CXFA_WidgetData::SetValue(const CFX_WideString& wsValue,
XFA_VALUEPICTURE eValueType) {
if (wsValue.IsEmpty()) {
- SyncValue(wsValue, TRUE);
+ SyncValue(wsValue, true);
return TRUE;
}
m_bPreNull = m_bIsNull;
@@ -1365,7 +1361,7 @@
}
}
if (uiType != XFA_ELEMENT_NumericEdit || bSyncData)
- SyncValue(wsNewText, TRUE);
+ SyncValue(wsNewText, true);
return bValidate;
}
@@ -1727,8 +1723,7 @@
}
}
-void CXFA_WidgetData::SyncValue(const CFX_WideString& wsValue,
- FX_BOOL bNotify) {
+void CXFA_WidgetData::SyncValue(const CFX_WideString& wsValue, bool bNotify) {
if (!m_pNode)
return;
diff --git a/xfa/fxfa/parser/cxfa_widgetdata.h b/xfa/fxfa/parser/cxfa_widgetdata.h
index c0d06e3..d2054cf 100644
--- a/xfa/fxfa/parser/cxfa_widgetdata.h
+++ b/xfa/fxfa/parser/cxfa_widgetdata.h
@@ -80,15 +80,14 @@
FX_BOOL IsAllowNeutral();
FX_BOOL IsRadioButton();
XFA_CHECKSTATE GetCheckState();
- void SetCheckState(XFA_CHECKSTATE eCheckState, FX_BOOL bNotify = TRUE);
+ void SetCheckState(XFA_CHECKSTATE eCheckState, bool bNotify);
CXFA_Node* GetExclGroupNode();
CXFA_Node* GetSelectedMember();
- CXFA_Node* SetSelectedMember(const CFX_WideStringC& wsName,
- FX_BOOL bNotify = TRUE);
+ CXFA_Node* SetSelectedMember(const CFX_WideStringC& wsName, bool bNotify);
void SetSelectedMemberByValue(const CFX_WideStringC& wsValue,
- FX_BOOL bNotify = TRUE,
- FX_BOOL bScriptModify = FALSE,
- FX_BOOL bSyncData = TRUE);
+ bool bNotify,
+ FX_BOOL bScriptModify,
+ FX_BOOL bSyncData);
CXFA_Node* GetExclGroupFirstMember();
CXFA_Node* GetExclGroupNextMember(CXFA_Node* pNode);
int32_t GetChoiceListCommitOn();
@@ -108,13 +107,13 @@
FX_BOOL GetItemState(int32_t nIndex);
void SetItemState(int32_t nIndex,
FX_BOOL bSelected,
- FX_BOOL bNotify = FALSE,
- FX_BOOL bScriptModify = FALSE,
- FX_BOOL bSyncData = TRUE);
+ bool bNotify,
+ FX_BOOL bScriptModify,
+ FX_BOOL bSyncData);
void SetSelectedItems(CFX_Int32Array& iSelArray,
- FX_BOOL bNotify = FALSE,
- FX_BOOL bScriptModify = FALSE,
- FX_BOOL bSyncData = TRUE);
+ bool bNotify,
+ FX_BOOL bScriptModify,
+ FX_BOOL bSyncData);
void ClearAllSelections();
void InsertItem(const CFX_WideString& wsLabel,
const CFX_WideString& wsValue,
@@ -166,7 +165,7 @@
FX_BOOL m_bPreNull;
protected:
- void SyncValue(const CFX_WideString& wsValue, FX_BOOL bNotify);
+ void SyncValue(const CFX_WideString& wsValue, bool bNotify);
void InsertListTextItem(CXFA_Node* pItems,
const CFX_WideString& wsText,
int32_t nIndex = -1);
diff --git a/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp b/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp
index 5bd8f08..d3d5c7f 100644
--- a/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp
+++ b/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp
@@ -112,7 +112,6 @@
}
CXFA_WidgetData* pWidgetData = pFormNode->GetWidgetData();
ASSERT(pWidgetData);
- FX_BOOL bNotify = FALSE;
XFA_ELEMENT eUIType = pWidgetData->GetUIType();
CXFA_Value defValue(pFormNode->GetProperty(0, XFA_ELEMENT_Value));
if (!bDataToForm) {
@@ -312,7 +311,7 @@
break;
case XFA_ELEMENT_ExclGroup: {
pWidgetData->SetSelectedMemberByValue(wsNormailizeValue.AsStringC(),
- bNotify, FALSE, FALSE);
+ false, FALSE, FALSE);
} break;
case XFA_ELEMENT_DateTimeEdit:
XFA_DataMerge_FormValueNode_SetChildContent(
diff --git a/xfa/fxfa/parser/xfa_object_imp.cpp b/xfa/fxfa/parser/xfa_object_imp.cpp
index 3864c1a..53c8847 100644
--- a/xfa/fxfa/parser/xfa_object_imp.cpp
+++ b/xfa/fxfa/parser/xfa_object_imp.cpp
@@ -2143,7 +2143,7 @@
pWidgetData->ClearAllSelections();
return;
}
- pWidgetData->SetItemState(iIndex, TRUE, TRUE, TRUE);
+ pWidgetData->SetItemState(iIndex, TRUE, true, TRUE, TRUE);
} else {
FXJSE_Value_SetInteger(pValue, pWidgetData->GetSelectedItem());
}
@@ -2312,16 +2312,15 @@
return;
}
CXFA_WidgetData* pWidgetData = GetWidgetData();
- if (!pWidgetData) {
+ if (!pWidgetData)
return;
- }
+
int32_t iIndex = pArguments->GetInt32(0);
if (pArguments->GetInt32(1) != 0) {
- pWidgetData->SetItemState(iIndex, TRUE, TRUE, TRUE);
+ pWidgetData->SetItemState(iIndex, TRUE, true, TRUE, TRUE);
} else {
- if (pWidgetData->GetItemState(iIndex)) {
- pWidgetData->SetItemState(iIndex, FALSE, TRUE, TRUE);
- }
+ if (pWidgetData->GetItemState(iIndex))
+ pWidgetData->SetItemState(iIndex, FALSE, true, TRUE, TRUE);
}
}
void CXFA_Node::Script_Field_AddItem(CFXJSE_Arguments* pArguments) {
@@ -2382,7 +2381,8 @@
CFX_ByteString bsValue;
FXJSE_Value_ToUTF8String(pValue, bsValue);
pWidgetData->SetSelectedMemberByValue(
- CFX_WideString::FromUTF8(bsValue.AsStringC()).AsStringC(), TRUE, TRUE);
+ CFX_WideString::FromUTF8(bsValue.AsStringC()).AsStringC(), true, TRUE,
+ TRUE);
} else {
CFX_WideString wsValue = GetScriptContent(TRUE);
XFA_VERSION curVersion = GetDocument()->GetCurVersionMode();
@@ -2407,35 +2407,39 @@
ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execEvent");
}
}
+
void CXFA_Node::Script_ExclGroup_SelectedMember(CFXJSE_Arguments* pArguments) {
int32_t argc = pArguments->GetLength();
- if ((argc == 0) || (argc == 1)) {
- CXFA_WidgetData* pWidgetData = GetWidgetData();
- if (!pWidgetData) {
- FXJSE_Value_SetNull(pArguments->GetReturnValue());
- } else {
- CXFA_Node* pReturnNode = NULL;
- if (argc == 0) {
- pReturnNode = pWidgetData->GetSelectedMember();
- } else {
- CFX_ByteString szName;
- szName = pArguments->GetUTF8String(0);
- pReturnNode = pWidgetData->SetSelectedMember(
- CFX_WideString::FromUTF8(szName.AsStringC()).AsStringC());
- }
- if (pReturnNode) {
- FXJSE_Value_Set(
- pArguments->GetReturnValue(),
- m_pDocument->GetScriptContext()->GetJSValueFromMap(pReturnNode));
- } else {
- FXJSE_Value_SetNull(pArguments->GetReturnValue());
- }
- }
- } else {
+ if (argc < 0 || argc > 1) {
ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD,
L"selectedMember");
+ return;
}
+
+ CXFA_WidgetData* pWidgetData = GetWidgetData();
+ if (!pWidgetData) {
+ FXJSE_Value_SetNull(pArguments->GetReturnValue());
+ return;
+ }
+
+ CXFA_Node* pReturnNode = nullptr;
+ if (argc == 0) {
+ pReturnNode = pWidgetData->GetSelectedMember();
+ } else {
+ CFX_ByteString szName;
+ szName = pArguments->GetUTF8String(0);
+ pReturnNode = pWidgetData->SetSelectedMember(
+ CFX_WideString::FromUTF8(szName.AsStringC()).AsStringC(), true);
+ }
+ if (!pReturnNode) {
+ FXJSE_Value_SetNull(pArguments->GetReturnValue());
+ return;
+ }
+ FXJSE_Value_Set(
+ pArguments->GetReturnValue(),
+ m_pDocument->GetScriptContext()->GetJSValueFromMap(pReturnNode));
}
+
void CXFA_Node::Script_ExclGroup_ExecInitialize(CFXJSE_Arguments* pArguments) {
int32_t argc = pArguments->GetLength();
if (argc == 0) {