[Libreoffice-commits] core.git: 2 commits - sc/inc sc/source
Eike Rathke
erack at redhat.com
Tue Apr 8 05:44:56 PDT 2014
sc/inc/tabprotection.hxx | 12 +++++++++++-
sc/source/core/data/tabprotection.cxx | 8 ++++----
sc/source/filter/oox/worksheetsettings.cxx | 10 ++++++++--
3 files changed, 23 insertions(+), 7 deletions(-)
New commits:
commit f1ca1384707cb6c4fa240fdc4903bfb3ceaff889
Author: Eike Rathke <erack at redhat.com>
Date: Tue Apr 8 14:41:10 2014 +0200
also check if a newly read password protection applies to a range
Change-Id: Ibbf4fee2b87c82cdbd565681690a231fb06da66f
diff --git a/sc/inc/tabprotection.hxx b/sc/inc/tabprotection.hxx
index b057ad0..9a4fef1 100644
--- a/sc/inc/tabprotection.hxx
+++ b/sc/inc/tabprotection.hxx
@@ -133,6 +133,11 @@ struct ScEnhancedProtection
{
return !maSecurityDescriptor.empty() || !maSecurityDescriptorXML.isEmpty();
}
+
+ bool hasPassword() const
+ {
+ return mnPasswordVerifier != 0 || !maHashValue.isEmpty();
+ }
};
/** sheet protection state container
diff --git a/sc/source/core/data/tabprotection.cxx b/sc/source/core/data/tabprotection.cxx
index a9bfd8f..52bc0fe 100644
--- a/sc/source/core/data/tabprotection.cxx
+++ b/sc/source/core/data/tabprotection.cxx
@@ -379,7 +379,7 @@ bool ScTableProtectionImpl::updateReference( UpdateRefMode eMode, ScDocument* pD
bool ScTableProtectionImpl::isBlockEditable( const ScRange& rRange ) const
{
- /* TODO: ask for password (and remember) if mnPasswordVerifier was set for
+ /* TODO: ask for password (and remember) if a password was set for
* a matching range and no matching range without password was encountered.
* Would need another return type than boolean to reflect
* "password required for a specific protection". */
@@ -401,7 +401,7 @@ bool ScTableProtectionImpl::isBlockEditable( const ScRange& rRange ) const
if ((*it).maRangeList->In( rRange))
{
// Range is editable if no password is assigned.
- if (!(*it).mnPasswordVerifier)
+ if (!(*it).hasPassword())
return true;
}
}
@@ -422,7 +422,7 @@ bool ScTableProtectionImpl::isBlockEditable( const ScRange& rRange ) const
if (aList.size() == 1 && *aList[0] == rRange)
{
// Range is editable if no password is assigned.
- if (!(*it).mnPasswordVerifier)
+ if (!(*it).hasPassword())
return true;
}
}
@@ -440,7 +440,7 @@ bool ScTableProtectionImpl::isBlockEditable( const ScRange& rRange ) const
if (!(*it).hasSecurityDescriptor() && (*it).maRangeList.Is())
{
// Ranges are editable if no password is assigned.
- if (!(*it).mnPasswordVerifier)
+ if (!(*it).hasPassword())
{
const ScRangeList& rRanges = *(*it).maRangeList;
size_t nRanges = rRanges.size();
commit 3974d6a2d96ec3facf529a4e54a2db63783961dd
Author: Eike Rathke <erack at redhat.com>
Date: Tue Apr 8 13:49:42 2014 +0200
read the defined password attributes
Change-Id: I67be85bdcfb5c03349daeff69fbb09291ce4a8e3
diff --git a/sc/inc/tabprotection.hxx b/sc/inc/tabprotection.hxx
index 2dc798c..b057ad0 100644
--- a/sc/inc/tabprotection.hxx
+++ b/sc/inc/tabprotection.hxx
@@ -121,8 +121,13 @@ 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;
- ScEnhancedProtection() : mnAreserved(0), mnPasswordVerifier(0) {}
+ ScEnhancedProtection() : mnAreserved(0), mnPasswordVerifier(0), mnSpinCount(0) {}
bool hasSecurityDescriptor() const
{
diff --git a/sc/source/filter/oox/worksheetsettings.cxx b/sc/source/filter/oox/worksheetsettings.cxx
index 01804dc..18f3da5 100644
--- a/sc/source/filter/oox/worksheetsettings.cxx
+++ b/sc/source/filter/oox/worksheetsettings.cxx
@@ -143,9 +143,15 @@ void WorksheetSettings::importProtectedRange( const AttributeList& rAttribs )
aProt.maSecurityDescriptorXML = rAttribs.getString( XML_securityDescriptor, OUString());
/* XXX ECMA-376/OOXML or ISO/IEC 29500 do not even mention a 'password'
* attribute here (or anywhere else), but this is what Excel2013 writes,
- * similar to BIFF. OOXML XMLschema and ISO/IEC 29500 instead define
- * 'algorithmName', 'hashValue', 'saltValue' and 'spinCount'. */
+ * similar to BIFF, if the original file was a BIFF file. OOXML XMLschema
+ * and ISO/IEC 29500 instead define 'algorithmName', 'hashValue',
+ * '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);
OUString aRefs( rAttribs.getString( XML_sqref, OUString()));
if (!aRefs.isEmpty())
{
More information about the Libreoffice-commits
mailing list