diff options
author | Noel Power <noel.power@suse.com> | 2013-08-01 16:41:11 +0100 |
---|---|---|
committer | Noel Power <noel.power@suse.com> | 2013-08-01 16:59:23 +0100 |
commit | 96ef3ad2d84b3d390f0bdd47408d2a7b2c569087 (patch) | |
tree | 9d59b9ab539bb5ee194deafc1a4318dc44a3f33c | |
parent | 8ce1124359783df750d176b8390b4eb0f54fb6ba (diff) |
unit test for fdo#64753 ( import/export of sheetprotection )
Change-Id: Ib66a8ef62ba598890c7db634cf54003fd92485a7
-rwxr-xr-x | sc/qa/unit/data/xlsx/ProtecteSheet1234Pass.xlsx | bin | 0 -> 7768 bytes | |||
-rw-r--r-- | sc/qa/unit/subsequent_export-test.cxx | 32 |
2 files changed, 32 insertions, 0 deletions
diff --git a/sc/qa/unit/data/xlsx/ProtecteSheet1234Pass.xlsx b/sc/qa/unit/data/xlsx/ProtecteSheet1234Pass.xlsx Binary files differnew file mode 100755 index 000000000000..509ebe2322f2 --- /dev/null +++ b/sc/qa/unit/data/xlsx/ProtecteSheet1234Pass.xlsx diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx index 19ecd3df88a7..f881923eccd0 100644 --- a/sc/qa/unit/subsequent_export-test.cxx +++ b/sc/qa/unit/subsequent_export-test.cxx @@ -30,6 +30,7 @@ #include "tokenarray.hxx" #include "svx/svdoole2.hxx" +#include "tabprotection.hxx" using namespace ::com::sun::star; using namespace ::com::sun::star::uno; @@ -58,6 +59,7 @@ public: void testInlineArrayXLS(); void testEmbeddedChartXLS(); void testFormulaReferenceXLS(); + void testSheetProtectionXLSX(); CPPUNIT_TEST_SUITE(ScExportTest); CPPUNIT_TEST(test); @@ -73,6 +75,8 @@ public: CPPUNIT_TEST(testInlineArrayXLS); CPPUNIT_TEST(testEmbeddedChartXLS); CPPUNIT_TEST(testFormulaReferenceXLS); + CPPUNIT_TEST(testSheetProtectionXLSX); + CPPUNIT_TEST_SUITE_END(); private: @@ -447,6 +451,34 @@ void ScExportTest::testFormulaReferenceXLS() xDocSh->DoClose(); } +void ScExportTest::testSheetProtectionXLSX() +{ + ScDocShellRef xShell = loadDoc("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<sal_Int8> 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() : ScBootstrapFixture("/sc/qa/unit/data") { |