summaryrefslogtreecommitdiff
path: root/xfa
diff options
context:
space:
mode:
Diffstat (limited to 'xfa')
-rw-r--r--xfa/fwl/core/fwl_formimp.cpp2
-rw-r--r--xfa/fwl/core/fwl_formimp.h2
-rw-r--r--xfa/fxfa/app/xfa_ffcheckbutton.cpp24
-rw-r--r--xfa/fxfa/app/xfa_ffchoicelist.cpp33
-rw-r--r--xfa/fxfa/parser/cxfa_widgetdata.cpp39
-rw-r--r--xfa/fxfa/parser/cxfa_widgetdata.h25
-rw-r--r--xfa/fxfa/parser/xfa_document_datamerger_imp.cpp3
-rw-r--r--xfa/fxfa/parser/xfa_object_imp.cpp66
8 files changed, 93 insertions, 101 deletions
diff --git a/xfa/fwl/core/fwl_formimp.cpp b/xfa/fwl/core/fwl_formimp.cpp
index 4b595e2c2d..1dcb310bd4 100644
--- a/xfa/fwl/core/fwl_formimp.cpp
+++ b/xfa/fwl/core/fwl_formimp.cpp
@@ -79,7 +79,7 @@ CFWL_FormImp::CFWL_FormImp(const CFWL_WidgetImpProperties& properties,
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 e1da960813..1f2d6951c0 100644
--- a/xfa/fwl/core/fwl_formimp.h
+++ b/xfa/fwl/core/fwl_formimp.h
@@ -160,7 +160,7 @@ class CFWL_FormImp : public CFWL_WidgetImp {
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 80a4e92bda..9e174a286e 100644
--- a/xfa/fxfa/app/xfa_ffcheckbutton.cpp
+++ b/xfa/fxfa/app/xfa_ffcheckbutton.cpp
@@ -239,12 +239,9 @@ void CXFA_FFCheckButton::RenderWidget(CFX_Graphics* pGS,
FX_BOOL CXFA_FFCheckButton::OnLButtonUp(uint32_t dwFlags,
FX_FLOAT fx,
FX_FLOAT fy) {
- if (!m_pNormalWidget) {
- return FALSE;
- }
- if (!IsButtonDown()) {
+ if (!m_pNormalWidget || !IsButtonDown())
return FALSE;
- }
+
SetButtonDown(FALSE);
CFWL_MsgMouse ms;
ms.m_dwCmd = FWL_MouseCommand::LeftButtonUp;
@@ -256,21 +253,22 @@ FX_BOOL CXFA_FFCheckButton::OnLButtonUp(uint32_t dwFlags,
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 3f8ea29a49..21f96eeb79 100644
--- a/xfa/fxfa/app/xfa_ffchoicelist.cpp
+++ b/xfa/fxfa/app/xfa_ffchoicelist.cpp
@@ -62,44 +62,41 @@ FX_BOOL CXFA_FFListBox::LoadWidget() {
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 6ef88cdc74..33dcb475e7 100644
--- a/xfa/fxfa/parser/cxfa_widgetdata.cpp
+++ b/xfa/fxfa/parser/cxfa_widgetdata.cpp
@@ -380,8 +380,7 @@ XFA_CHECKSTATE CXFA_WidgetData::GetCheckState() {
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::GetSelectedMember() {
}
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 @@ FX_BOOL CXFA_WidgetData::GetItemState(int32_t nIndex) {
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::SetItemState(int32_t nIndex,
}
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::SetSelectedItems(CFX_Int32Array& iSelArray,
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 @@ FX_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, bSyncData);
bSetValue = TRUE;
}
int32_t i = 0;
@@ -1318,7 +1314,7 @@ FX_BOOL CXFA_WidgetData::GetLeadDigits(int32_t& iLeadDigits) {
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 @@ FX_BOOL CXFA_WidgetData::SetValue(const CFX_WideString& wsValue,
}
}
if (uiType != XFA_ELEMENT_NumericEdit || bSyncData)
- SyncValue(wsNewText, TRUE);
+ SyncValue(wsNewText, true);
return bValidate;
}
@@ -1727,8 +1723,7 @@ void CXFA_WidgetData::FormatNumStr(const CFX_WideString& wsValue,
}
}
-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 c0d06e353c..d2054cf145 100644
--- a/xfa/fxfa/parser/cxfa_widgetdata.h
+++ b/xfa/fxfa/parser/cxfa_widgetdata.h
@@ -80,15 +80,14 @@ class CXFA_WidgetData : public CXFA_Data {
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 @@ class CXFA_WidgetData : public CXFA_Data {
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 @@ class CXFA_WidgetData : public CXFA_Data {
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 5bd8f08970..d3d5c7f27b 100644
--- a/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp
+++ b/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp
@@ -112,7 +112,6 @@ static void XFA_DataMerge_CreateDataBinding(CXFA_Node* pFormNode,
}
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 @@ static void XFA_DataMerge_CreateDataBinding(CXFA_Node* pFormNode,
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 3864c1a32c..53c8847be8 100644
--- a/xfa/fxfa/parser/xfa_object_imp.cpp
+++ b/xfa/fxfa/parser/xfa_object_imp.cpp
@@ -2143,7 +2143,7 @@ void CXFA_Node::Script_Field_SelectedIndex(CFXJSE_Value* pValue,
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 @@ void CXFA_Node::Script_Field_SetItemState(CFXJSE_Arguments* pArguments) {
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 @@ void CXFA_Node::Script_ExclGroup_DefaultAndRawValue(CFXJSE_Value* pValue,
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 @@ void CXFA_Node::Script_ExclGroup_ExecEvent(CFXJSE_Arguments* pArguments) {
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) {