diff options
author | Noel Power <noel.power@suse.com> | 2013-08-01 10:04:42 +0100 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2013-08-03 12:34:02 +0000 |
commit | 9d07f380bb0d5053571a9f3866b0415fe8339c5b (patch) | |
tree | 51003673f803c5e12d5976918229fccc36fb9dd5 /sc/source/filter/oox | |
parent | c549ac677ba6279387aca33c5117b8ee1461bd9e (diff) |
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 )
Conflicts:
sc/qa/unit/subsequent_export-test.cxx
Change-Id: If420b386543c15c7b550a720b6e2db69bf372d7f
Reviewed-on: https://gerrit.libreoffice.org/5229
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Eike Rathke <erack@redhat.com>
Diffstat (limited to 'sc/source/filter/oox')
-rw-r--r-- | sc/source/filter/oox/worksheetsettings.cxx | 35 |
1 files changed, 29 insertions, 6 deletions
diff --git a/sc/source/filter/oox/worksheetsettings.cxx b/sc/source/filter/oox/worksheetsettings.cxx index 1980283e4820..96ca193a30a5 100644 --- a/sc/source/filter/oox/worksheetsettings.cxx +++ b/sc/source/filter/oox/worksheetsettings.cxx @@ -26,6 +26,8 @@ #include "biffinputstream.hxx" #include "pagesettings.hxx" #include "workbooksettings.hxx" +#include "tabprotection.hxx" +#include "document.hxx" namespace oox { namespace xls { @@ -231,13 +233,34 @@ void WorksheetSettings::importPhoneticPr( SequenceInputStream& rStrm ) void WorksheetSettings::finalizeImport() { // sheet protection - if( maSheetProt.mbSheet ) try - { - Reference< XProtectable > xProtectable( getSheet(), UNO_QUERY_THROW ); - xProtectable->protect( OUString() ); - } - catch( Exception& ) + if( maSheetProt.mbSheet ) { + ScTableProtection aProtect; + aProtect.setProtected(true); + if (maSheetProt.mnPasswordHash) + { + Sequence<sal_Int8> aPass(2); + aPass[0] = ( maSheetProt.mnPasswordHash>> 8) & 0xFF; + aPass[1] = maSheetProt.mnPasswordHash & 0xFF; + aProtect.setPasswordHash(aPass, PASSHASH_XL); + } + aProtect.setOption( ScTableProtection::OBJECTS, maSheetProt.mbObjects); + aProtect.setOption( ScTableProtection::SCENARIOS, maSheetProt.mbScenarios ); + aProtect.setOption( ScTableProtection::FORMAT_CELLS, maSheetProt.mbFormatCells ); + aProtect.setOption( ScTableProtection::FORMAT_COLUMNS, maSheetProt.mbFormatColumns ); + aProtect.setOption( ScTableProtection::FORMAT_ROWS, maSheetProt.mbFormatRows ); + aProtect.setOption( ScTableProtection::INSERT_COLUMNS, maSheetProt.mbInsertColumns ); + aProtect.setOption( ScTableProtection::INSERT_ROWS, maSheetProt.mbInsertRows ); + aProtect.setOption( ScTableProtection::INSERT_HYPERLINKS, maSheetProt.mbInsertHyperlinks ); + aProtect.setOption( ScTableProtection::DELETE_COLUMNS, maSheetProt.mbDeleteColumns ); + aProtect.setOption( ScTableProtection::DELETE_ROWS,maSheetProt.mbDeleteRows ); + aProtect.setOption( ScTableProtection::SELECT_LOCKED_CELLS, maSheetProt.mbSelectLocked ); + aProtect.setOption( ScTableProtection::SORT, maSheetProt.mbSort ); + aProtect.setOption( ScTableProtection::AUTOFILTER, maSheetProt.mbAutoFilter ); + aProtect.setOption( ScTableProtection::PIVOT_TABLES, maSheetProt.mbPivotTables ); + aProtect.setOption( ScTableProtection::SELECT_UNLOCKED_CELLS, maSheetProt.mbSelectUnlocked ); + + getScDocument().SetTabProtection( getSheetIndex(), &aProtect ); } // VBA code name |