[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source
Eike Rathke
erack at redhat.com
Tue Mar 25 12:43:35 PDT 2014
sc/qa/unit/data/xls/enhanced-protection.xls |binary
sc/qa/unit/filters-test.cxx | 20 ++++++++++++++++++++
sc/source/core/data/tabprotection.cxx | 27 +++++++++++++++++++++++++++
3 files changed, 47 insertions(+)
New commits:
commit e27cc864be4d18d5bf307c58ebf1c1aa4ef90078
Author: Eike Rathke <erack at redhat.com>
Date: Tue Mar 25 20:41:52 2014 +0100
added unit test for .xls BIFF enhanced protection
Change-Id: I8f218f8f8ce12525b4c9995567d2864baa610c0b
diff --git a/sc/qa/unit/data/xls/enhanced-protection.xls b/sc/qa/unit/data/xls/enhanced-protection.xls
new file mode 100644
index 0000000..00cc6e6
Binary files /dev/null and b/sc/qa/unit/data/xls/enhanced-protection.xls differ
diff --git a/sc/qa/unit/filters-test.cxx b/sc/qa/unit/filters-test.cxx
index 4de62d1..9d049f7 100644
--- a/sc/qa/unit/filters-test.cxx
+++ b/sc/qa/unit/filters-test.cxx
@@ -31,6 +31,7 @@
#include "drwlayer.hxx"
#include "userdat.hxx"
#include "formulacell.hxx"
+#include "tabprotection.hxx"
#include <svx/svdpage.hxx>
@@ -69,6 +70,7 @@ public:
void testSharedFormulaXLS();
void testSharedFormulaXLSX();
void testLegacyCellAnchoredRotatedShape();
+ void testEnhancedProtectionXLS();
CPPUNIT_TEST_SUITE(ScFiltersTest);
CPPUNIT_TEST(testCVEs);
@@ -82,6 +84,7 @@ public:
CPPUNIT_TEST(testSharedFormulaXLS);
CPPUNIT_TEST(testSharedFormulaXLSX);
CPPUNIT_TEST(testLegacyCellAnchoredRotatedShape);
+ CPPUNIT_TEST(testEnhancedProtectionXLS);
CPPUNIT_TEST_SUITE_END();
@@ -491,6 +494,23 @@ void ScFiltersTest::testLegacyCellAnchoredRotatedShape()
}
}
+void ScFiltersTest::testEnhancedProtectionXLS()
+{
+ ScDocShellRef xDocSh = loadDoc("enhanced-protection.", XLS);
+ CPPUNIT_ASSERT(xDocSh.Is());
+ ScDocument* pDoc = xDocSh->GetDocument();
+
+ const ScTableProtection* pProt = pDoc->GetTabProtection(0);
+
+ CPPUNIT_ASSERT( !pProt->isBlockEditable( ScRange( 0, 0, 0, 0, 0, 0))); // locked
+ CPPUNIT_ASSERT( pProt->isBlockEditable( ScRange( 0, 1, 0, 0, 1, 0))); // editable without password
+ CPPUNIT_ASSERT( pProt->isBlockEditable( ScRange( 0, 2, 0, 0, 2, 0))); // editable without password
+ CPPUNIT_ASSERT( !pProt->isBlockEditable( ScRange( 0, 3, 0, 0, 3, 0))); // editable with password "foo"
+ CPPUNIT_ASSERT( pProt->isBlockEditable( ScRange( 0, 1, 0, 0, 2, 0))); // union of two different editables
+ CPPUNIT_ASSERT( !pProt->isBlockEditable( ScRange( 0, 0, 0, 0, 1, 0))); // union of locked and editable
+ CPPUNIT_ASSERT( !pProt->isBlockEditable( ScRange( 0, 2, 0, 0, 3, 0))); // union of editable and password editable
+}
+
ScFiltersTest::ScFiltersTest()
: ScBootstrapFixture( "/sc/qa/unit/data" )
{
commit 98c6b4149e46eec6aaee5b64f2fa40678589dd4b
Author: Eike Rathke <erack at redhat.com>
Date: Tue Mar 25 20:39:10 2014 +0100
union of a to be edited range may be distributed over two different records
Change-Id: I1d0047e04394a79134b3333eef35ba0cfe6a8ca1
diff --git a/sc/source/core/data/tabprotection.cxx b/sc/source/core/data/tabprotection.cxx
index 161cf65..a8aa278 100644
--- a/sc/source/core/data/tabprotection.cxx
+++ b/sc/source/core/data/tabprotection.cxx
@@ -434,6 +434,33 @@ bool ScTableProtectionImpl::isBlockEditable( const ScRange& rRange ) const
}
}
+ // Ranges may even be distributed over different protection records, for
+ // example if they are assigned different names, and can have different
+ // passwords. Combine the ones that can be edited.
+ /* TODO: once we handle passwords, remember a successful unlock at
+ * ScEnhancedProtection so we can use that here. */
+ ScRangeList aRangeList;
+ for (::std::vector<ScEnhancedProtection>::const_iterator it(maEnhancedProtection.begin()),
+ itEnd(maEnhancedProtection.end()); it != itEnd; ++it)
+ {
+ if ((*it).maSecurityDescriptor.empty() && (*it).maRangeList.Is())
+ {
+ // Ranges are editable if no password is assigned.
+ if (!(*it).mnPasswordVerifier)
+ {
+ const ScRangeList& rRanges = *(*it).maRangeList;
+ size_t nRanges = rRanges.size();
+ for (size_t i=0; i < nRanges; ++i)
+ {
+ aRangeList.Append( *rRanges[i]);
+ }
+ }
+ }
+ }
+ ScRangeList aResultList( aRangeList.GetIntersectedRange( rRange));
+ if (aResultList.size() == 1 && *aResultList[0] == rRange)
+ return true;
+
return false;
}
More information about the Libreoffice-commits
mailing list