From 863ecf687efaad3354c5c260458344b19c4c228c Mon Sep 17 00:00:00 2001 From: Noel Power Date: Thu, 1 Aug 2013 10:04:42 +0100 Subject: 1st step fix for exporting SheetProtection fdo#64753 is to import correctly (cherry picked from commit 016e18680e471d9f0cea8ee35f9716ae0f9baa11) 2nd step to export SheetProtection fdo#64753, actually export the data (cherry picked from commit 8ce1124359783df750d176b8390b4eb0f54fb6ba) unit test for fdo#64753 ( import/export of sheetprotection ) Change-Id: If420b386543c15c7b550a720b6e2db69bf372d7f conflict fix for test Change-Id: I3c996525b71509934c2d5ee274f9cd2dc1854f97 Reviewed-on: https://gerrit.libreoffice.org/5232 Reviewed-by: Eike Rathke Tested-by: Eike Rathke --- sc/qa/unit/subsequent_export-test.cxx | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'sc/qa/unit/subsequent_export-test.cxx') diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx index fe7e9636c06c..673f415b5c88 100644 --- a/sc/qa/unit/subsequent_export-test.cxx +++ b/sc/qa/unit/subsequent_export-test.cxx @@ -34,6 +34,7 @@ #include "scitems.hxx" #include "document.hxx" #include "cellform.hxx" +#include "tabprotection.hxx" #define ODS_FORMAT_TYPE 50331943 #define XLS_FORMAT_TYPE 318767171 @@ -78,6 +79,7 @@ public: void testPasswordExport(); void testConditionalFormatExportXLSX(); void testMiscRowHeightExport(); + void testSheetProtectionXLSX(); void testNamedRangeBugfdo62729(); CPPUNIT_TEST_SUITE(ScExportTest); @@ -88,6 +90,7 @@ public: CPPUNIT_TEST(testConditionalFormatExportXLSX); CPPUNIT_TEST(testMiscRowHeightExport); CPPUNIT_TEST(testNamedRangeBugfdo62729); + CPPUNIT_TEST(testSheetProtectionXLSX); CPPUNIT_TEST_SUITE_END(); private: @@ -401,6 +404,34 @@ void ScExportTest::testNamedRangeBugfdo62729() xDocSh->DoClose(); } +void ScExportTest::testSheetProtectionXLSX() +{ + ScDocShellRef xShell = loadDocument("ProtecteSheet1234Pass.", XLSX); + CPPUNIT_ASSERT(xShell.Is()); + + ScDocShellRef xDocSh = saveAndReload(xShell, XLSX); + CPPUNIT_ASSERT(xDocSh.Is()); + + ScDocument* pDoc = xDocSh->GetDocument(); + CPPUNIT_ASSERT(pDoc); + const ScTableProtection* pTabProtect = pDoc->GetTabProtection(0); + CPPUNIT_ASSERT(pTabProtect); + if ( pTabProtect ) + { + Sequence aHash = pTabProtect->getPasswordHash(PASSHASH_XL); + // check has + if (aHash.getLength() >= 2) + { + CPPUNIT_ASSERT( (sal_uInt8)aHash[0] == 204 ); + CPPUNIT_ASSERT( (sal_uInt8)aHash[1] == 61 ); + } + // we could flesh out this check I guess + CPPUNIT_ASSERT ( pTabProtect->isOptionEnabled( ScTableProtection::OBJECTS ) ); + CPPUNIT_ASSERT ( pTabProtect->isOptionEnabled( ScTableProtection::SCENARIOS ) ); + } + xDocSh->DoClose(); +} + ScExportTest::ScExportTest() : m_aBaseString(RTL_CONSTASCII_USTRINGPARAM("/sc/qa/unit/data")) { -- cgit v1.2.3