summaryrefslogtreecommitdiff
path: root/sc/qa/unit/ucalc_pivottable.cxx
diff options
context:
space:
mode:
authorBalazs Varga <balazs.varga.extern@allotropia.de>2024-11-06 21:33:46 +0100
committerBalazs Varga <balazs.varga.extern@allotropia.de>2024-11-14 23:53:24 +0100
commit83910246044c1e05a3b50e25d21ac6a31566cc38 (patch)
treec41d25de2d95d093d9f39707cc43a27f6fcea0ce /sc/qa/unit/ucalc_pivottable.cxx
parentec13618a1836a46ada1fee72ce4de5c82c0051f6 (diff)
tdf#160404 tdf#160535 tdf#160536 - sc improve sheet protection
tdf#160404: Fix FILEOPEN XLSX Pivot table is not imported if sheet protection has Pivot table editing enabled - Import correctly the pivot tables, even if the tab protection is not allowing to use them. tdf#160535: Support sheet protection option: Use AutoFilter - Add new option for tab protection to enable/disable to use autofilter on the sheet. Import/export correctly to odf/ooxml. Add new ext-odf attribute: XML_USE_AUTOFILTER tdf#160536: Support sheet protection option: Use PivotTable&PivotChart - Add new option for tab protection to enable/disable to use Pivot table on the sheet. Import/export correctly to odf/ooxml. Add new ext-odf attribute: XML_USE_PIVOT Change-Id: I5d34e3608aed1a3d004ec553f6125b6428e9c05e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176274 Tested-by: Jenkins Reviewed-by: Balazs Varga <balazs.varga.extern@allotropia.de>
Diffstat (limited to 'sc/qa/unit/ucalc_pivottable.cxx')
-rw-r--r--sc/qa/unit/ucalc_pivottable.cxx27
1 files changed, 27 insertions, 0 deletions
diff --git a/sc/qa/unit/ucalc_pivottable.cxx b/sc/qa/unit/ucalc_pivottable.cxx
index 594d7a7e1265..9517826423bf 100644
--- a/sc/qa/unit/ucalc_pivottable.cxx
+++ b/sc/qa/unit/ucalc_pivottable.cxx
@@ -17,6 +17,7 @@
#include <stringutil.hxx>
#include <dbdocfun.hxx>
#include <generalfunction.hxx>
+#include <tabprotection.hxx>
#include <formula/errorcodes.hxx>
#include <com/sun/star/sheet/DataPilotFieldGroupBy.hpp>
@@ -2115,6 +2116,32 @@ CPPUNIT_TEST_FIXTURE(TestPivottable, testPivotTableDocFunc)
CPPUNIT_ASSERT_MESSAGE("Table output check failed", bSuccess);
}
+ // Start: Test Pivot table with tab protection
+ ScTableProtection aProtect;
+ aProtect.setProtected(true);
+ m_pDoc->SetTabProtection(1, &aProtect);
+
+ bSuccess = aFunc.RemovePivotTable(*pDPObject, false, true);
+ CPPUNIT_ASSERT_MESSAGE("Pivot table should not be allowed to remove.", !bSuccess);
+
+ bSuccess = aFunc.UpdatePivotTable(*pDPObject, false, true);
+ CPPUNIT_ASSERT_MESSAGE("Pivot table should not be allowed to update.", !bSuccess);
+
+ // Allow pivot table usage
+ aProtect.setOption(ScTableProtection::PIVOT_TABLES, true);
+ m_pDoc->SetTabProtection(1, &aProtect);
+
+ bSuccess = aFunc.RemovePivotTable(*pDPObject, false, true);
+ CPPUNIT_ASSERT_MESSAGE("Pivot table should not be allowed to remove.", !bSuccess);
+
+ bSuccess = aFunc.UpdatePivotTable(*pDPObject, false, true);
+ CPPUNIT_ASSERT_MESSAGE("Pivot table should be allowed to update.", bSuccess);
+
+ aProtect.setProtected(false);
+ aProtect.setOption(ScTableProtection::PIVOT_TABLES, false);
+ m_pDoc->SetTabProtection(1, &aProtect);
+ // End: Test Pivot table with tab protection
+
// Remove this pivot table output. This should also clear the pivot cache
// it was referencing.
bSuccess = aFunc.RemovePivotTable(*pDPObject, false, true);