Skip to content

Commit

Permalink
Upstream feature: Implement CT_DataValidation and DVRecord Equals() m…
Browse files Browse the repository at this point in the history
…ethod overrides.
  • Loading branch information
Artem Koloskov committed Feb 9, 2024
1 parent 14d4aec commit 01c9fa5
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 1 deletion.
27 changes: 27 additions & 0 deletions OpenXmlFormats/Spreadsheet/Sheet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7387,6 +7387,33 @@ public void Set(CT_DataValidation obj)
promptField = obj.promptField;
sqrefField = obj.sqrefField;
}

public override bool Equals(object obj)
{
CT_DataValidation o = (CT_DataValidation)obj;

if (o is null)
{
return false;
}

return formula1Field == o.formula1Field
&& formula2Field == o.formula2Field
&& typeField == o.typeField
&& errorStyleField == o.errorStyleField
&& imeModeField == o.imeModeField
&& operatorField == o.operatorField
&& allowBlankField == o.allowBlankField
&& showDropDownField == o.showDropDownField
&& showInputMessageField == o.showInputMessageField
&& showErrorMessageField == o.showErrorMessageField
&& errorTitleField == o.errorTitleField
&& errorField == o.errorField
&& promptTitleField == o.promptTitleField
&& promptField == o.promptField
&& sqrefField == o.sqrefField;
}

[XmlElement(Order = 0)]
public string formula1
{
Expand Down
31 changes: 30 additions & 1 deletion main/HSSF/Record/DVRecord.cs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,36 @@ public int DataType
set { this._option_flags = this.opt_data_type.SetValue(this._option_flags, value); }
}

public override bool Equals(object obj)
{
if (obj == null || !(obj is DVRecord))
{
return false;
}

DVRecord dv = (DVRecord)obj;
return DataType == dv.DataType
&& ErrorStyle == dv.ErrorStyle
&& EmptyCellAllowed == dv.EmptyCellAllowed
&& ShowErrorOnInvalidValue == dv.ShowErrorOnInvalidValue
&& ShowPromptOnCellSelected == dv.ShowPromptOnCellSelected
&& SuppressDropdownArrow == dv.SuppressDropdownArrow
&& ListExplicitFormula == dv.ListExplicitFormula
&& ConditionOperator == dv.ConditionOperator
&& PromptTitle == dv.PromptTitle
&& PromptText == dv.PromptText
&& ErrorTitle == dv.ErrorTitle
&& ErrorText == dv.ErrorText
&& ((Formula1 == null && dv.Formula1 == null)
|| Formula1 != null && dv.Formula1 != null
&& Formula1.ToString() == dv.Formula1.ToString())
&& ((Formula2 == null && dv.Formula2 == null)
|| Formula2 != null && dv.Formula2 != null
&& Formula2.ToString() == dv.Formula2.ToString())
&& (CellRangeAddress == null && dv.CellRangeAddress == null
|| CellRangeAddress != null && dv.CellRangeAddress != null
&& CellRangeAddress.ToString() == dv.CellRangeAddress.ToString());
}

/**
* Get the condition error style
Expand Down Expand Up @@ -426,4 +455,4 @@ public override Object Clone()
return CloneViaReserialise();
}
}
}
}

0 comments on commit 01c9fa5

Please sign in to comment.