diff options
author | Noel Power <noel.power@suse.com> | 2013-08-01 14:29:34 +0100 |
---|---|---|
committer | Noel Power <noel.power@suse.com> | 2013-08-01 16:59:22 +0100 |
commit | 8ce1124359783df750d176b8390b4eb0f54fb6ba (patch) | |
tree | 51699927e2739295e676e81a68f71cff7b46c809 | |
parent | 016e18680e471d9f0cea8ee35f9716ae0f9baa11 (diff) |
2nd step to export SheetProtection fdo#64753, actually export the data
Change-Id: Id9fa1f9b917f9df8ca0ead02dfd5405388039b4b
-rw-r--r-- | sc/source/filter/excel/excdoc.cxx | 5 | ||||
-rw-r--r-- | sc/source/filter/excel/excrecds.cxx | 44 | ||||
-rw-r--r-- | sc/source/filter/inc/excrecds.hxx | 8 |
3 files changed, 57 insertions, 0 deletions
diff --git a/sc/source/filter/excel/excdoc.cxx b/sc/source/filter/excel/excdoc.cxx index b56f7802866a..89dcce8cb1cb 100644 --- a/sc/source/filter/excel/excdoc.cxx +++ b/sc/source/filter/excel/excdoc.cxx @@ -593,6 +593,11 @@ void ExcTable::FillAsXmlTable( SCTAB nCodeNameIdx ) // conditional formats Add( new XclExpCondFormatBuffer( GetRoot(), xExtLst ) ); + ScDocument& rDoc = GetDoc(); + const ScTableProtection* pTabProtect = rDoc.GetTabProtection(mnScTab); + if (pTabProtect && pTabProtect->isProtected()) + Add( new XclExpSheetProtection(true, mnScTab) ); + if( HasVbaStorage() ) if( nCodeNameIdx < GetExtDocOptions().GetCodeNameCount() ) Add( new XclCodename( GetExtDocOptions().GetCodeName( nCodeNameIdx ) ) ); diff --git a/sc/source/filter/excel/excrecds.cxx b/sc/source/filter/excel/excrecds.cxx index 3469b36efb7f..c63d3c5f33c6 100644 --- a/sc/source/filter/excel/excrecds.cxx +++ b/sc/source/filter/excel/excrecds.cxx @@ -79,6 +79,7 @@ #include "xecontent.hxx" #include "xcl97rec.hxx" +#include "tabprotection.hxx" using namespace ::oox; @@ -494,6 +495,49 @@ XclExpProtection::XclExpProtection(bool bValue) : { } +XclExpSheetProtection::XclExpSheetProtection(bool bValue, SCTAB nTab ) : + XclExpProtection( bValue), + mnTab(nTab) +{ +} + +void XclExpSheetProtection::SaveXml( XclExpXmlStream& rStrm ) +{ + ScDocument& rDoc = rStrm.GetRoot().GetDoc(); + const ScTableProtection* pTabProtect = rDoc.GetTabProtection(mnTab); + if ( pTabProtect ) + { + Sequence<sal_Int8> aHash = pTabProtect->getPasswordHash(PASSHASH_XL); + sal_uInt16 nHash(0x0000); + OString sHash; + if (aHash.getLength() >= 2) + { + nHash = ((aHash[0] << 8) & 0xFFFF); + nHash |= (aHash[1] & 0xFF); + sHash = OString::valueOf( nHash, 16 ); + } + sax_fastparser::FSHelperPtr& rWorksheet = rStrm.GetCurrentStream(); + rWorksheet->singleElement( XML_sheetProtection, + XML_sheet, XclXmlUtils::ToPsz( true ), + XML_password, sHash.getStr(), + XML_objects, pTabProtect->isOptionEnabled( ScTableProtection::OBJECTS ) ? XclXmlUtils::ToPsz( true ) : NULL, + XML_scenarios, pTabProtect->isOptionEnabled( ScTableProtection::SCENARIOS ) ? XclXmlUtils::ToPsz( true ) : NULL, + XML_formatCells, pTabProtect->isOptionEnabled( ScTableProtection::FORMAT_CELLS ) ? NULL : XclXmlUtils::ToPsz( true ), + XML_formatColumns, pTabProtect->isOptionEnabled( ScTableProtection::FORMAT_COLUMNS ) ? NULL : XclXmlUtils::ToPsz( true ), + XML_formatRows, pTabProtect->isOptionEnabled( ScTableProtection::FORMAT_ROWS ) ? NULL : XclXmlUtils::ToPsz( true ), + XML_insertColumns, pTabProtect->isOptionEnabled( ScTableProtection::INSERT_COLUMNS ) ? NULL : XclXmlUtils::ToPsz( true ), + XML_insertRows, pTabProtect->isOptionEnabled( ScTableProtection::INSERT_ROWS ) ? NULL : XclXmlUtils::ToPsz( true ), + XML_insertHyperlinks, pTabProtect->isOptionEnabled( ScTableProtection::INSERT_HYPERLINKS ) ? NULL : XclXmlUtils::ToPsz( true ), + XML_deleteColumns, pTabProtect->isOptionEnabled( ScTableProtection::DELETE_COLUMNS ) ? NULL : XclXmlUtils::ToPsz( true ), + XML_deleteRows, pTabProtect->isOptionEnabled( ScTableProtection::DELETE_ROWS ) ? NULL : XclXmlUtils::ToPsz( true ), + XML_selectLockedCells, pTabProtect->isOptionEnabled( ScTableProtection::SELECT_LOCKED_CELLS ) ? XclXmlUtils::ToPsz( true ) : NULL, + XML_sort, pTabProtect->isOptionEnabled( ScTableProtection::SORT ) ? NULL : XclXmlUtils::ToPsz( true ), + XML_autoFilter, pTabProtect->isOptionEnabled( ScTableProtection::AUTOFILTER ) ? NULL : XclXmlUtils::ToPsz( true ), + XML_pivotTables, pTabProtect->isOptionEnabled( ScTableProtection::PIVOT_TABLES ) ? NULL : XclXmlUtils::ToPsz( true ), + XML_selectUnlockedCells, pTabProtect->isOptionEnabled( ScTableProtection::SELECT_UNLOCKED_CELLS ) ? XclXmlUtils::ToPsz( true ) : NULL, + FSEND ); + } +} // ============================================================================ XclExpPassHash::XclExpPassHash(const Sequence<sal_Int8>& aHash) : diff --git a/sc/source/filter/inc/excrecds.hxx b/sc/source/filter/inc/excrecds.hxx index 426f0cfcd7b0..f0de420a792c 100644 --- a/sc/source/filter/inc/excrecds.hxx +++ b/sc/source/filter/inc/excrecds.hxx @@ -191,6 +191,14 @@ class XclExpProtection : public XclExpBoolRecord XclExpProtection(bool bValue); }; +class XclExpSheetProtection : public XclExpProtection +{ + SCTAB mnTab; + public: + XclExpSheetProtection(bool bValue, SCTAB nTab); + virtual void SaveXml( XclExpXmlStream& rStrm ); +}; + class XclExpPassHash : public XclExpRecord { public: |