diff options
author | Justin Luth <justin_luth@sil.org> | 2017-05-23 15:35:13 +0300 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2017-05-25 20:46:06 +0200 |
commit | 0d3fcbf809852aab0d0f88272bbfd2e8507d1c5e (patch) | |
tree | 60341c2a02845005339e41dde4987f6e64561055 /sc | |
parent | 4be228af5ae177ad0057613ef0a98d6cc1b67584 (diff) |
tdf#108017 xlsb import: protection settings were reversed
Back in LO4.3, commit 5728a56b20e01d6c9e86a23f20af64a1b68ad604
fdo#70499 selectn of lock/unlocked cells with worksheet protection reversed
...reversed finalizeImport's understanding of maSheetProt.* to match
xml import, but then it no longer matched the binary stream import.
So, .xlsb imported the opposite of what .xlsx/.xlsm imported.
Change-Id: I2da3967ef52187e4ef36ce7d01b17a4672f61e1c
Reviewed-on: https://gerrit.libreoffice.org/37952
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Justin Luth <justin_luth@sil.org>
Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
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 ) |