diff options
author | Noel Power <noel.power@suse.com> | 2013-08-01 10:04:42 +0100 |
---|---|---|
committer | Noel Power <noel.power@suse.com> | 2013-08-01 16:59:22 +0100 |
commit | 016e18680e471d9f0cea8ee35f9716ae0f9baa11 (patch) | |
tree | 0704e753a1adf9dcd979498a209413b10f74d066 | |
parent | 46de4c598e9a78cc9a8401c701b75f434707d186 (diff) |
1st step fix for exporting SheetProtection fdo#64753 is to import correctly
Change-Id: If420b386543c15c7b550a720b6e2db69bf372d7f
-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 |