summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2018-02-24 20:56:28 +0100
committerEike Rathke <erack@redhat.com>2018-02-24 21:02:41 +0100
commit1bf8006f6344d67dbfe0055da7d7dd5bdfa529d2 (patch)
treeeaf5d1f55ca9b5702d90e45d6b45cb9e06234fca
parente3dd12fa8a71c7d0d35fb2146436934d1f4ee004 (diff)
Write ScOoxPasswordHash to OOXML if set, tdf#104250 prep
Change-Id: I51996c673e6c44bbfc27972800d78d9807fe67db
-rw-r--r--sc/inc/tabprotection.hxx3
-rw-r--r--sc/source/core/data/tabprotection.cxx16
-rw-r--r--sc/source/filter/excel/excrecds.cxx10
3 files changed, 29 insertions, 0 deletions
diff --git a/sc/inc/tabprotection.hxx b/sc/inc/tabprotection.hxx
index 4c9edcb2f4cc..c174957f1e18 100644
--- a/sc/inc/tabprotection.hxx
+++ b/sc/inc/tabprotection.hxx
@@ -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;
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 ),