summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Luth <justin_luth@sil.org>2017-05-23 15:35:13 +0300
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2017-05-26 12:40:01 +0200
commit4fbb8ad023c95266ce0882cd28bdf6703f5b67bf (patch)
treef28424c8ed8cfb7d5307a10ea3590c653940bb8d
parent6b921e1c8a4779dfd6f5531842ab89d85aa99a85 (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. 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> (cherry picked from commit 0d3fcbf809852aab0d0f88272bbfd2e8507d1c5e) Reviewed-on: https://gerrit.libreoffice.org/38041 Change-Id: I2da3967ef52187e4ef36ce7d01b17a4672f61e1c Reviewed-on: https://gerrit.libreoffice.org/38052 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Justin Luth <justin_luth@sil.org> Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
-rw-r--r--sc/qa/unit/data/xlsb/tdf108017_calcProtection.xlsbbin0 -> 10911 bytes
-rw-r--r--sc/qa/unit/subsequent_export-test.cxx37
-rw-r--r--sc/source/filter/oox/worksheetsettings.cxx30
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
new file mode 100644
index 000000000000..31661ba009a8
--- /dev/null
+++ b/sc/qa/unit/data/xlsb/tdf108017_calcProtection.xlsb
Binary files differ
diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx
index 7060520294d8..9ffcdd7e7223 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -123,6 +123,7 @@ public:
void testFormulaReferenceXLS();
void testSheetProtectionXLSX();
+ void testSheetProtectionXLSB();
void testCellBordersXLS();
void testCellBordersXLSX();
@@ -223,6 +224,7 @@ public:
CPPUNIT_TEST(testFormulaReferenceXLS);
CPPUNIT_TEST(testSheetProtectionXLSX);
+ CPPUNIT_TEST(testSheetProtectionXLSB);
CPPUNIT_TEST(testCellBordersXLS);
CPPUNIT_TEST(testCellBordersXLSX);
CPPUNIT_TEST(testBordersExchangeXLSX);
@@ -1912,19 +1914,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 1bbc7a82cbd3..ca956382dc7b 100644
--- a/sc/source/filter/oox/worksheetsettings.cxx
+++ b/sc/source/filter/oox/worksheetsettings.cxx
@@ -215,21 +215,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 )