diff options
author | Eike Rathke <erack@redhat.com> | 2018-02-24 20:56:28 +0100 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2018-02-24 21:02:41 +0100 |
commit | 1bf8006f6344d67dbfe0055da7d7dd5bdfa529d2 (patch) | |
tree | eaf5d1f55ca9b5702d90e45d6b45cb9e06234fca /sc/source | |
parent | e3dd12fa8a71c7d0d35fb2146436934d1f4ee004 (diff) |
Write ScOoxPasswordHash to OOXML if set, tdf#104250 prep
Change-Id: I51996c673e6c44bbfc27972800d78d9807fe67db
Diffstat (limited to 'sc/source')
-rw-r--r-- | sc/source/core/data/tabprotection.cxx | 16 | ||||
-rw-r--r-- | sc/source/filter/excel/excrecds.cxx | 10 |
2 files changed, 26 insertions, 0 deletions
diff --git a/sc/source/core/data/tabprotection.cxx b/sc/source/core/data/tabprotection.cxx index 0eab574d7b42..68e7914dc984 100644 --- a/sc/source/core/data/tabprotection.cxx +++ b/sc/source/core/data/tabprotection.cxx @@ -124,6 +124,7 @@ public: void setPassword(const OUString& aPassText); css::uno::Sequence<sal_Int8> getPasswordHash( ScPasswordHash eHash, ScPasswordHash eHash2) const; + const ScOoxPasswordHash& getPasswordHash() const; void setPasswordHash( const css::uno::Sequence<sal_Int8>& aPassword, ScPasswordHash eHash, ScPasswordHash eHash2); @@ -311,6 +312,11 @@ Sequence<sal_Int8> ScTableProtectionImpl::getPasswordHash( return Sequence<sal_Int8>(); } +const ScOoxPasswordHash& ScTableProtectionImpl::getPasswordHash() const +{ + return maPasswordHash; +} + void ScTableProtectionImpl::setPasswordHash( const uno::Sequence<sal_Int8>& aPassword, ScPasswordHash eHash, ScPasswordHash eHash2) { @@ -586,6 +592,11 @@ uno::Sequence<sal_Int8> ScDocProtection::getPasswordHash(ScPasswordHash eHash, S return mpImpl->getPasswordHash(eHash, eHash2); } +const ScOoxPasswordHash& ScDocProtection::getPasswordHash() const +{ + return mpImpl->getPasswordHash(); +} + void ScDocProtection::setPasswordHash( const uno::Sequence<sal_Int8>& aPassword, ScPasswordHash eHash, ScPasswordHash eHash2) { @@ -666,6 +677,11 @@ Sequence<sal_Int8> ScTableProtection::getPasswordHash(ScPasswordHash eHash, ScPa return mpImpl->getPasswordHash(eHash, eHash2); } +const ScOoxPasswordHash& ScTableProtection::getPasswordHash() const +{ + return mpImpl->getPasswordHash(); +} + void ScTableProtection::setPasswordHash( const uno::Sequence<sal_Int8>& aPassword, ScPasswordHash eHash, ScPasswordHash eHash2) { diff --git a/sc/source/filter/excel/excrecds.cxx b/sc/source/filter/excel/excrecds.cxx index e3af479967a0..4dab73a20805 100644 --- a/sc/source/filter/excel/excrecds.cxx +++ b/sc/source/filter/excel/excrecds.cxx @@ -469,6 +469,12 @@ void XclExpSheetProtection::SaveXml( XclExpXmlStream& rStrm ) const ScTableProtection* pTabProtect = rDoc.GetTabProtection(mnTab); if ( pTabProtect ) { + const ScOoxPasswordHash& rPH = pTabProtect->getPasswordHash(); + // Do not write any hash attributes if there is no password. + ScOoxPasswordHash aPH; + if (rPH.hasPassword()) + aPH = rPH; + Sequence<sal_Int8> aHash = pTabProtect->getPasswordHash(PASSHASH_XL); OString sHash; if (aHash.getLength() >= 2) @@ -480,6 +486,10 @@ void XclExpSheetProtection::SaveXml( XclExpXmlStream& rStrm ) } sax_fastparser::FSHelperPtr& rWorksheet = rStrm.GetCurrentStream(); rWorksheet->singleElement( XML_sheetProtection, + XML_algorithmName, aPH.maAlgorithmName.isEmpty() ? nullptr : XclXmlUtils::ToOString( aPH.maAlgorithmName).getStr(), + XML_hashValue, aPH.maHashValue.isEmpty() ? nullptr : XclXmlUtils::ToOString( aPH.maHashValue).getStr(), + XML_saltValue, aPH.maSaltValue.isEmpty() ? nullptr : XclXmlUtils::ToOString( aPH.maSaltValue).getStr(), + XML_spinCount, aPH.mnSpinCount ? OString::number( aPH.mnSpinCount).getStr() : nullptr, XML_sheet, ToPsz( true ), XML_password, sHash.isEmpty()? nullptr : sHash.getStr(), XML_objects, pTabProtect->isOptionEnabled( ScTableProtection::OBJECTS ) ? nullptr : ToPsz( true ), |