diff options
Diffstat (limited to 'sc')
-rw-r--r-- | sc/qa/unit/data/xlsb/tdf108017_calcProtection.xlsb | bin | 0 -> 10911 bytes | |||
-rw-r--r-- | sc/qa/unit/subsequent_export-test.cxx | 37 | ||||
-rw-r--r-- | sc/source/filter/oox/worksheetsettings.cxx | 30 |
3 files changed, 41 insertions, 26 deletions
diff --git a/sc/qa/unit/data/xlsb/tdf108017_calcProtection.xlsb b/sc/qa/unit/data/xlsb/tdf108017_calcProtection.xlsb Binary files differnew file mode 100644 index 000000000000..31661ba009a8 --- /dev/null +++ b/sc/qa/unit/data/xlsb/tdf108017_calcProtection.xlsb diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx index 989623b065bc..49e52a512a88 100644 --- a/sc/qa/unit/subsequent_export-test.cxx +++ b/sc/qa/unit/subsequent_export-test.cxx @@ -127,6 +127,7 @@ public: void testFormulaReferenceXLS(); void testSheetProtectionXLSX(); + void testSheetProtectionXLSB(); void testCellBordersXLS(); void testCellBordersXLSX(); @@ -234,6 +235,7 @@ public: CPPUNIT_TEST(testFormulaReferenceXLS); CPPUNIT_TEST(testSheetProtectionXLSX); + CPPUNIT_TEST(testSheetProtectionXLSB); CPPUNIT_TEST(testCellBordersXLS); CPPUNIT_TEST(testCellBordersXLSX); CPPUNIT_TEST(testBordersExchangeXLSX); @@ -1919,19 +1921,32 @@ void ScExportTest::testSheetProtectionXLSX() ScDocument& rDoc = xDocSh->GetDocument(); const ScTableProtection* pTabProtect = rDoc.GetTabProtection(0); CPPUNIT_ASSERT(pTabProtect); - if ( pTabProtect ) + Sequence<sal_Int8> aHash = pTabProtect->getPasswordHash(PASSHASH_XL); + // check has + if (aHash.getLength() >= 2) { - Sequence<sal_Int8> aHash = pTabProtect->getPasswordHash(PASSHASH_XL); - // check has - if (aHash.getLength() >= 2) - { - CPPUNIT_ASSERT_EQUAL(sal_uInt8(204), (sal_uInt8)aHash[0]); - CPPUNIT_ASSERT_EQUAL(sal_uInt8(61), (sal_uInt8)aHash[1]); - } - // we could flesh out this check I guess - CPPUNIT_ASSERT ( !pTabProtect->isOptionEnabled( ScTableProtection::OBJECTS ) ); - CPPUNIT_ASSERT ( !pTabProtect->isOptionEnabled( ScTableProtection::SCENARIOS ) ); + CPPUNIT_ASSERT_EQUAL(sal_uInt8(204), (sal_uInt8)aHash[0]); + CPPUNIT_ASSERT_EQUAL(sal_uInt8(61), (sal_uInt8)aHash[1]); } + // we could flesh out this check I guess + CPPUNIT_ASSERT ( !pTabProtect->isOptionEnabled( ScTableProtection::OBJECTS ) ); + CPPUNIT_ASSERT ( !pTabProtect->isOptionEnabled( ScTableProtection::SCENARIOS ) ); + xDocSh->DoClose(); +} + +void ScExportTest::testSheetProtectionXLSB() +{ + ScDocShellRef xShell = loadDoc("tdf108017_calcProtection.", FORMAT_XLSB); + CPPUNIT_ASSERT(xShell.is()); + + ScDocShellRef xDocSh = saveAndReload(xShell.get(), FORMAT_XLSX); + CPPUNIT_ASSERT(xDocSh.is()); + + ScDocument& rDoc = xDocSh->GetDocument(); + const ScTableProtection* pTabProtect = rDoc.GetTabProtection(0); + CPPUNIT_ASSERT(pTabProtect); + CPPUNIT_ASSERT(pTabProtect->isOptionEnabled( ScTableProtection::SELECT_UNLOCKED_CELLS )); + CPPUNIT_ASSERT(!pTabProtect->isOptionEnabled( ScTableProtection::SELECT_LOCKED_CELLS )); xDocSh->DoClose(); } diff --git a/sc/source/filter/oox/worksheetsettings.cxx b/sc/source/filter/oox/worksheetsettings.cxx index f83a759d33fd..896df326e39c 100644 --- a/sc/source/filter/oox/worksheetsettings.cxx +++ b/sc/source/filter/oox/worksheetsettings.cxx @@ -205,21 +205,21 @@ void WorksheetSettings::importSheetProtection( SequenceInputStream& rStrm ) maSheetProt.mnPasswordHash = rStrm.readuInt16(); // no flags field for all these boolean flags?!? maSheetProt.mbSheet = rStrm.readInt32() != 0; - maSheetProt.mbObjects = rStrm.readInt32() != 0; - maSheetProt.mbScenarios = rStrm.readInt32() != 0; - maSheetProt.mbFormatCells = rStrm.readInt32() != 0; - maSheetProt.mbFormatColumns = rStrm.readInt32() != 0; - maSheetProt.mbFormatRows = rStrm.readInt32() != 0; - maSheetProt.mbInsertColumns = rStrm.readInt32() != 0; - maSheetProt.mbInsertRows = rStrm.readInt32() != 0; - maSheetProt.mbInsertHyperlinks = rStrm.readInt32() != 0; - maSheetProt.mbDeleteColumns = rStrm.readInt32() != 0; - maSheetProt.mbDeleteRows = rStrm.readInt32() != 0; - maSheetProt.mbSelectLocked = rStrm.readInt32() != 0; - maSheetProt.mbSort = rStrm.readInt32() != 0; - maSheetProt.mbAutoFilter = rStrm.readInt32() != 0; - maSheetProt.mbPivotTables = rStrm.readInt32() != 0; - maSheetProt.mbSelectUnlocked = rStrm.readInt32() != 0; + maSheetProt.mbObjects = rStrm.readInt32() == 0; + maSheetProt.mbScenarios = rStrm.readInt32() == 0; + maSheetProt.mbFormatCells = rStrm.readInt32() == 0; + maSheetProt.mbFormatColumns = rStrm.readInt32() == 0; + maSheetProt.mbFormatRows = rStrm.readInt32() == 0; + maSheetProt.mbInsertColumns = rStrm.readInt32() == 0; + maSheetProt.mbInsertRows = rStrm.readInt32() == 0; + maSheetProt.mbInsertHyperlinks = rStrm.readInt32() == 0; + maSheetProt.mbDeleteColumns = rStrm.readInt32() == 0; + maSheetProt.mbDeleteRows = rStrm.readInt32() == 0; + maSheetProt.mbSelectLocked = rStrm.readInt32() == 0; + maSheetProt.mbSort = rStrm.readInt32() == 0; + maSheetProt.mbAutoFilter = rStrm.readInt32() == 0; + maSheetProt.mbPivotTables = rStrm.readInt32() == 0; + maSheetProt.mbSelectUnlocked = rStrm.readInt32() == 0; } void WorksheetSettings::importChartProtection( SequenceInputStream& rStrm ) |