[Libreoffice-commits] core.git: Branch 'libreoffice-5-4' - sc/qa sc/source

Justin Luth justin_luth at sil.org
Fri May 26 04:23:46 UTC 2017


 sc/qa/unit/data/xlsb/tdf108017_calcProtection.xlsb |binary
 sc/qa/unit/subsequent_export-test.cxx              |   37 ++++++++++++++-------
 sc/source/filter/oox/worksheetsettings.cxx         |   30 ++++++++---------
 3 files changed, 41 insertions(+), 26 deletions(-)

New commits:
commit 47f3d3521c364a9133da26d3202225dc414662fb
Author: Justin Luth <justin_luth at sil.org>
Date:   Tue May 23 15:35:13 2017 +0300

    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 at libreoffice.org>
    Reviewed-by: Justin Luth <justin_luth at sil.org>
    Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>
    (cherry picked from commit 0d3fcbf809852aab0d0f88272bbfd2e8507d1c5e)
    Reviewed-on: https://gerrit.libreoffice.org/38041

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
Binary files /dev/null and b/sc/qa/unit/data/xlsb/tdf108017_calcProtection.xlsb differ
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 )


More information about the Libreoffice-commits mailing list