sc/inc/tabprotection.hxx | 22 +++++++++++++++------- sc/source/filter/excel/excrecds.cxx | 8 ++++---- sc/source/filter/oox/worksheetsettings.cxx | 8 ++++---- 3 files changed, 23 insertions(+), 15 deletions(-)
New commits: commit 6d67347311923dbe3975cfa197649f5856c00723 Author: Eike Rathke <er...@redhat.com> Date: Fri Feb 23 19:49:45 2018 +0100 Move OOXML password definitions to struct ScOoxPasswordHash, tdf#104250 prep Change-Id: I595d5ae8db6f739900afdfdde1e36b0a0b1d2179 diff --git a/sc/inc/tabprotection.hxx b/sc/inc/tabprotection.hxx index 3f2fc7b4e189..0b3a3ed62105 100644 --- a/sc/inc/tabprotection.hxx +++ b/sc/inc/tabprotection.hxx @@ -39,6 +39,18 @@ enum ScPasswordHash PASSHASH_UNSPECIFIED }; +/// OOXML password definitions: algorithmName, hashValue, saltValue, spinCount +struct ScOoxPasswordHash +{ + OUString maAlgorithmName; /// "SHA-512", ... + OUString maHashValue; /// base64 encoded hash value + OUString maSaltValue; /// base64 encoded salt value + sal_uInt32 mnSpinCount; /// spin count, iteration runs + + ScOoxPasswordHash() : mnSpinCount(0) {} + bool hasPassword() const { return !maHashValue.isEmpty(); } +}; + namespace ScPassHashHelper { /** Check for the compatibility of all password hashes. If there is at @@ -117,13 +129,9 @@ struct ScEnhancedProtection OUString maTitle; ::std::vector< sal_uInt8 > maSecurityDescriptor; // imported as raw BIFF data OUString maSecurityDescriptorXML; // imported from OOXML - // OOXML password definitions - OUString maAlgorithmName; - OUString maHashValue; - OUString maSaltValue; - sal_uInt32 mnSpinCount; + ScOoxPasswordHash maPasswordHash; - ScEnhancedProtection() : mnAreserved(0), mnPasswordVerifier(0), mnSpinCount(0) {} + ScEnhancedProtection() : mnAreserved(0), mnPasswordVerifier(0) {} bool hasSecurityDescriptor() const { @@ -132,7 +140,7 @@ struct ScEnhancedProtection bool hasPassword() const { - return mnPasswordVerifier != 0 || !maHashValue.isEmpty(); + return mnPasswordVerifier != 0 || maPasswordHash.hasPassword(); } }; diff --git a/sc/source/filter/excel/excrecds.cxx b/sc/source/filter/excel/excrecds.cxx index 2125a593ae1b..e3af479967a0 100644 --- a/sc/source/filter/excel/excrecds.cxx +++ b/sc/source/filter/excel/excrecds.cxx @@ -516,10 +516,10 @@ void XclExpSheetProtection::SaveXml( XclExpXmlStream& rStrm ) * 'algorithmName', 'hashValue', 'saltValue' and * 'spinCount' are absent; so do we if it was present. */ XML_password, (*it).mnPasswordVerifier ? OString::number( (*it).mnPasswordVerifier, 16).getStr() : nullptr, - XML_algorithmName, (*it).maAlgorithmName.isEmpty() ? nullptr : XclXmlUtils::ToOString( (*it).maAlgorithmName).getStr(), - XML_hashValue, (*it).maHashValue.isEmpty() ? nullptr : XclXmlUtils::ToOString( (*it).maHashValue).getStr(), - XML_saltValue, (*it).maSaltValue.isEmpty() ? nullptr : XclXmlUtils::ToOString( (*it).maSaltValue).getStr(), - XML_spinCount, (*it).mnSpinCount ? OString::number( (*it).mnSpinCount).getStr() : nullptr, + XML_algorithmName, (*it).maPasswordHash.maAlgorithmName.isEmpty() ? nullptr : XclXmlUtils::ToOString( (*it).maPasswordHash.maAlgorithmName).getStr(), + XML_hashValue, (*it).maPasswordHash.maHashValue.isEmpty() ? nullptr : XclXmlUtils::ToOString( (*it).maPasswordHash.maHashValue).getStr(), + XML_saltValue, (*it).maPasswordHash.maSaltValue.isEmpty() ? nullptr : XclXmlUtils::ToOString( (*it).maPasswordHash.maSaltValue).getStr(), + XML_spinCount, (*it).maPasswordHash.mnSpinCount ? OString::number( (*it).maPasswordHash.mnSpinCount).getStr() : nullptr, XML_sqref, (*it).maRangeList.is() ? XclXmlUtils::ToOString( *(*it).maRangeList).getStr() : nullptr, FSEND); } diff --git a/sc/source/filter/oox/worksheetsettings.cxx b/sc/source/filter/oox/worksheetsettings.cxx index 06fc1db11da0..bdeb6cc04884 100644 --- a/sc/source/filter/oox/worksheetsettings.cxx +++ b/sc/source/filter/oox/worksheetsettings.cxx @@ -144,10 +144,10 @@ void WorksheetSettings::importProtectedRange( const AttributeList& rAttribs ) * 'saltValue' and 'spinCount' that are written if the protection was newly * created. */ aProt.mnPasswordVerifier = rAttribs.getIntegerHex( XML_password, 0); - aProt.maAlgorithmName = rAttribs.getString( XML_algorithmName, OUString()); - aProt.maHashValue = rAttribs.getString( XML_hashValue, OUString()); - aProt.maSaltValue = rAttribs.getString( XML_saltValue, OUString()); - aProt.mnSpinCount = rAttribs.getUnsigned( XML_spinCount, 0); + aProt.maPasswordHash.maAlgorithmName = rAttribs.getString( XML_algorithmName, OUString()); + aProt.maPasswordHash.maHashValue = rAttribs.getString( XML_hashValue, OUString()); + aProt.maPasswordHash.maSaltValue = rAttribs.getString( XML_saltValue, OUString()); + aProt.maPasswordHash.mnSpinCount = rAttribs.getUnsigned( XML_spinCount, 0); OUString aRefs( rAttribs.getString( XML_sqref, OUString())); if (!aRefs.isEmpty()) { _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits