summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHossein <hossein@libreoffice.org>2022-07-22 16:44:29 +0200
committerAdolfo Jayme Barrientos <fitojb@ubuntu.com>2022-07-25 10:35:14 +0200
commitfd948aed2230e50cce9c4aa7f1eb30e7cc8c4f8f (patch)
treee2ef1500d9bf14646c64d5838ff54e23e66a06f1
parente110f95a660ba828c722d83b88fa45715827655c (diff)
tdf#147868 Disable add sheet when structure is protected
Using "Tools > Protect Spreadsheet Structure...", it is possible to protect the structure of a spreadsheet document. Without this patch in place, the [+] (add new sheet) button is clickable but it does not work. This is confusing for the user, so it was decided that the button should be disabled when the structure is protected. This patch disables the [+] button just after the structure is protected using the above toggle menu option. The menu option becomes checked, and the [+] button gets disabled immediately. After choosing the same toggle menu option again, the check mark goes away, and the [+] button becomes enabled immediately. In this patch, GetDocument().IsDocEditable() is used to check if the document structure is protected. The argument for this choice is that the same function is used when renaming a sheet with ScDocFunc::RenameTable(). Change-Id: If812d94841d3efd98d7ef898cc1f4b2f1387130b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137365 Tested-by: Jenkins Reviewed-by: Hossein <hossein@libreoffice.org> (cherry picked from commit e2b7f59c745a79542b15937bc824c7afe9969cde) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137333 Reviewed-by: Adolfo Jayme Barrientos <fitojb@ubuntu.com>
-rw-r--r--include/svtools/tabbar.hxx1
-rw-r--r--sc/source/ui/view/tabview5.cxx1
-rw-r--r--svtools/source/control/tabbar.cxx5
3 files changed, 7 insertions, 0 deletions
diff --git a/include/svtools/tabbar.hxx b/include/svtools/tabbar.hxx
index 8735e0728599..948e60b3596b 100644
--- a/include/svtools/tabbar.hxx
+++ b/include/svtools/tabbar.hxx
@@ -496,6 +496,7 @@ public:
void SetSelectHdl( const Link<TabBar*,void>& rLink ) { maSelectHdl = rLink; }
void SetSplitHdl( const Link<TabBar*,void>& rLink ) { maSplitHdl = rLink; }
void SetScrollAreaContextHdl( const Link<const CommandEvent&,void>& rLink ) { maScrollAreaContextHdl = rLink; }
+ void SetAddButtonEnabled(bool bAddButtonEnabled);
// accessibility
virtual css::uno::Reference<css::accessibility::XAccessible> CreateAccessible() override;
diff --git a/sc/source/ui/view/tabview5.cxx b/sc/source/ui/view/tabview5.cxx
index d83d4206198d..6db05da9c94e 100644
--- a/sc/source/ui/view/tabview5.cxx
+++ b/sc/source/ui/view/tabview5.cxx
@@ -383,6 +383,7 @@ void ScTabView::UpdateLayerLocks()
pDrawView->SetLayerLocked( pLayer->GetName(), bProt || bShared );
pDrawView->SetLayerVisible( pLayer->GetName(), false);
}
+ pTabControl->SetAddButtonEnabled(aViewData.GetDocument().IsDocEditable());
}
void ScTabView::DrawDeselectAll()
diff --git a/svtools/source/control/tabbar.cxx b/svtools/source/control/tabbar.cxx
index a62d0ae6fad9..dd49bda0df4f 100644
--- a/svtools/source/control/tabbar.cxx
+++ b/svtools/source/control/tabbar.cxx
@@ -2494,6 +2494,11 @@ tools::Rectangle TabBar::GetPageArea() const
Size(mnLastOffX - mnOffX + 1, GetSizePixel().Height() - mnOffY));
}
+void TabBar::SetAddButtonEnabled(bool bAddButtonEnabled)
+{
+ mpImpl->mxButtonBox->m_xAddButton->set_sensitive(bAddButtonEnabled);
+}
+
css::uno::Reference<css::accessibility::XAccessible> TabBar::CreateAccessible()
{
return mpImpl->maAccessibleFactory.getFactory().createAccessibleTabBar(*this);