Kaydet (Commit) 1bf8006f authored tarafından Eike Rathke's avatar Eike Rathke

Write ScOoxPasswordHash to OOXML if set, tdf#104250 prep

Change-Id: I51996c673e6c44bbfc27972800d78d9807fe67db
üst e3dd12fa
......@@ -85,6 +85,7 @@ public:
virtual void setPassword(const OUString& aPassText) = 0;
virtual css::uno::Sequence<sal_Int8> getPasswordHash(
ScPasswordHash eHash, ScPasswordHash eHas2 = PASSHASH_UNSPECIFIED) const = 0;
virtual const ScOoxPasswordHash& getPasswordHash() const = 0;
virtual void setPasswordHash(
const css::uno::Sequence<sal_Int8>& aPassword,
ScPasswordHash eHash, ScPasswordHash eHash2 = PASSHASH_UNSPECIFIED) = 0;
......@@ -116,6 +117,7 @@ public:
virtual void setPassword(const OUString& aPassText) override;
virtual css::uno::Sequence<sal_Int8> getPasswordHash(
ScPasswordHash eHash, ScPasswordHash eHash2 = PASSHASH_UNSPECIFIED) const override;
virtual const ScOoxPasswordHash& getPasswordHash() const override;
virtual void setPasswordHash(
const css::uno::Sequence<sal_Int8>& aPassword,
ScPasswordHash eHash, ScPasswordHash eHash2 = PASSHASH_UNSPECIFIED) override;
......@@ -199,6 +201,7 @@ public:
virtual void setPassword(const OUString& aPassText) override;
virtual css::uno::Sequence<sal_Int8> getPasswordHash(
ScPasswordHash eHash, ScPasswordHash eHash2 = PASSHASH_UNSPECIFIED) const override;
virtual const ScOoxPasswordHash& getPasswordHash() const override;
virtual void setPasswordHash(
const css::uno::Sequence<sal_Int8>& aPassword,
ScPasswordHash eHash, ScPasswordHash eHash2 = PASSHASH_UNSPECIFIED) override;
......
......@@ -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)
{
......
......@@ -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 ),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment