summaryrefslogtreecommitdiff
path: root/sc/qa
diff options
context:
space:
mode:
Diffstat (limited to 'sc/qa')
-rw-r--r--sc/qa/unit/data/xls/enhanced-protection.xlsbin0 -> 25600 bytes
-rw-r--r--sc/qa/unit/filters-test.cxx20
2 files changed, 20 insertions, 0 deletions
diff --git a/sc/qa/unit/data/xls/enhanced-protection.xls b/sc/qa/unit/data/xls/enhanced-protection.xls
new file mode 100644
index 000000000000..00cc6e6a3248
--- /dev/null
+++ b/sc/qa/unit/data/xls/enhanced-protection.xls
Binary files differ
diff --git a/sc/qa/unit/filters-test.cxx b/sc/qa/unit/filters-test.cxx
index 4de62d1ec2ab..9d049f7e87de 100644
--- a/sc/qa/unit/filters-test.cxx
+++ b/sc/qa/unit/filters-test.cxx
@@ -31,6 +31,7 @@
#include "drwlayer.hxx"
#include "userdat.hxx"
#include "formulacell.hxx"
+#include "tabprotection.hxx"
#include <svx/svdpage.hxx>
@@ -69,6 +70,7 @@ public:
void testSharedFormulaXLS();
void testSharedFormulaXLSX();
void testLegacyCellAnchoredRotatedShape();
+ void testEnhancedProtectionXLS();
CPPUNIT_TEST_SUITE(ScFiltersTest);
CPPUNIT_TEST(testCVEs);
@@ -82,6 +84,7 @@ public:
CPPUNIT_TEST(testSharedFormulaXLS);
CPPUNIT_TEST(testSharedFormulaXLSX);
CPPUNIT_TEST(testLegacyCellAnchoredRotatedShape);
+ CPPUNIT_TEST(testEnhancedProtectionXLS);
CPPUNIT_TEST_SUITE_END();
@@ -491,6 +494,23 @@ void ScFiltersTest::testLegacyCellAnchoredRotatedShape()
}
}
+void ScFiltersTest::testEnhancedProtectionXLS()
+{
+ ScDocShellRef xDocSh = loadDoc("enhanced-protection.", XLS);
+ CPPUNIT_ASSERT(xDocSh.Is());
+ ScDocument* pDoc = xDocSh->GetDocument();
+
+ const ScTableProtection* pProt = pDoc->GetTabProtection(0);
+
+ CPPUNIT_ASSERT( !pProt->isBlockEditable( ScRange( 0, 0, 0, 0, 0, 0))); // locked
+ CPPUNIT_ASSERT( pProt->isBlockEditable( ScRange( 0, 1, 0, 0, 1, 0))); // editable without password
+ CPPUNIT_ASSERT( pProt->isBlockEditable( ScRange( 0, 2, 0, 0, 2, 0))); // editable without password
+ CPPUNIT_ASSERT( !pProt->isBlockEditable( ScRange( 0, 3, 0, 0, 3, 0))); // editable with password "foo"
+ CPPUNIT_ASSERT( pProt->isBlockEditable( ScRange( 0, 1, 0, 0, 2, 0))); // union of two different editables
+ CPPUNIT_ASSERT( !pProt->isBlockEditable( ScRange( 0, 0, 0, 0, 1, 0))); // union of locked and editable
+ CPPUNIT_ASSERT( !pProt->isBlockEditable( ScRange( 0, 2, 0, 0, 3, 0))); // union of editable and password editable
+}
+
ScFiltersTest::ScFiltersTest()
: ScBootstrapFixture( "/sc/qa/unit/data" )
{