Kaydet (Commit) 0d3fcbf8 authored tarafından Justin Luth's avatar Justin Luth Kaydeden (comit) Markus Mohrhard

tdf#108017 xlsb import: protection settings were reversed

Back in LO4.3, commit 5728a56b
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/37952Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarJustin Luth <justin_luth@sil.org>
Reviewed-by: 's avatarMarkus Mohrhard <markus.mohrhard@googlemail.com>
üst 4be228af
......@@ -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();
}
......
......@@ -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 )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment