From c64e40bfcb1c58040b627e78099ddf6142f34046 Mon Sep 17 00:00:00 2001 From: Andrey Bykiev Date: Mon, 24 Jul 2023 22:34:20 +0300 Subject: [PATCH] Fix By default locked property is true and not specified in protection element --- ooxml/XSSF/UserModel/XSSFCellStyle.cs | 8 ++++++-- testcases/ooxml/XSSF/UserModel/TestXSSFCellStyle.cs | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/ooxml/XSSF/UserModel/XSSFCellStyle.cs b/ooxml/XSSF/UserModel/XSSFCellStyle.cs index a51d634e4..e393f89ae 100644 --- a/ooxml/XSSF/UserModel/XSSFCellStyle.cs +++ b/ooxml/XSSF/UserModel/XSSFCellStyle.cs @@ -695,7 +695,11 @@ public bool IsHidden { get { - return _cellXf.IsSetProtection() && _cellXf.protection.IsSetHidden() && _cellXf.protection.hidden; + if (!_cellXf.IsSetProtection() || !_cellXf.protection.IsSetHidden()) + { + return false; + } + return _cellXf.protection.hidden; } set { @@ -804,7 +808,7 @@ public bool IsLocked { if (!_cellXf.IsSetProtection()) { - return false; + return true; } return _cellXf.protection.locked; } diff --git a/testcases/ooxml/XSSF/UserModel/TestXSSFCellStyle.cs b/testcases/ooxml/XSSF/UserModel/TestXSSFCellStyle.cs index 8de136aa9..f140e5d4a 100644 --- a/testcases/ooxml/XSSF/UserModel/TestXSSFCellStyle.cs +++ b/testcases/ooxml/XSSF/UserModel/TestXSSFCellStyle.cs @@ -718,7 +718,7 @@ public void TestGetSetHidden() [Test] public void TestGetSetLocked() { - Assert.IsFalse(cellStyle.IsLocked); + Assert.IsTrue(cellStyle.IsLocked); cellStyle.IsLocked = (true); Assert.IsTrue(cellStyle.IsLocked); cellStyle.IsLocked = (false);