summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorHeiko Tietze <tietze.heiko@gmail.com>2021-05-19 13:21:00 +0200
committerHeiko Tietze <heiko.tietze@documentfoundation.org>2021-06-08 15:28:56 +0200
commit086fa727cabf46eacfec1a0fd4f6dfe916aa2f04 (patch)
treed17d263a3f2eef1b9c0d39ffd08e751c3f2fa105 /sfx2
parenta2d8a737f41cbb0ed8a51a99b1c233b25e433d1c (diff)
Resolves tdf#131817 - Option to globally switch toolbar locking on/off
Reverts 6993d5d0f1079fe720a7da004b70b57361c99fc6 and sets Locked in GlobalSettings to true New UNO command ToolbarLock to toggle the state added to the toolbars menu Change-Id: I246280b2b7930f2bf686e6fc26383da4799b5028 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115797 Tested-by: Jenkins Reviewed-by: Heiko Tietze <heiko.tietze@documentfoundation.org>
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/sdi/appslots.sdi5
-rw-r--r--sfx2/sdi/sfx.sdi16
-rw-r--r--sfx2/source/appl/appserv.cxx34
3 files changed, 53 insertions, 2 deletions
diff --git a/sfx2/sdi/appslots.sdi b/sfx2/sdi/appslots.sdi
index f5ffb700388a..af5e394f3fb2 100644
--- a/sfx2/sdi/appslots.sdi
+++ b/sfx2/sdi/appslots.sdi
@@ -224,6 +224,11 @@ interface Application
ExecMethod = MiscExec_Impl ;
StateMethod = MiscState_Impl ;
]
+ SID_TOOLBAR_LOCK
+ [
+ ExecMethod = MiscExec_Impl ;
+ StateMethod = MiscState_Impl ;
+ ]
}
diff --git a/sfx2/sdi/sfx.sdi b/sfx2/sdi/sfx.sdi
index 90ed30a62f92..79476c68fa7f 100644
--- a/sfx2/sdi/sfx.sdi
+++ b/sfx2/sdi/sfx.sdi
@@ -5754,3 +5754,19 @@ SfxVoidItem AdditionsDialog SID_ADDITIONS_DIALOG
ToolBoxConfig = TRUE,
GroupId = SfxGroupId::Application;
]
+
+SfxBoolItem ToolbarLock SID_TOOLBAR_LOCK
+[
+ AutoUpdate = TRUE,
+ FastCall = FALSE,
+ ReadOnlyDoc = TRUE,
+ Toggle = TRUE,
+ Container = FALSE,
+ RecordAbsolute = FALSE,
+ RecordPerSet;
+
+ AccelConfig = FALSE,
+ MenuConfig = FALSE,
+ ToolBoxConfig = TRUE,
+ GroupId = SfxGroupId::Application;
+]
diff --git a/sfx2/source/appl/appserv.cxx b/sfx2/source/appl/appserv.cxx
index 6138bd936082..098f705410a4 100644
--- a/sfx2/source/appl/appserv.cxx
+++ b/sfx2/source/appl/appserv.cxx
@@ -64,6 +64,7 @@
#include <sal/log.hxx>
#include <osl/file.hxx>
#include <vcl/EnumContext.hxx>
+#include <vcl/toolbox.hxx>
#include <unotools/moduleoptions.hxx>
#include <svtools/helpopt.hxx>
@@ -1026,7 +1027,32 @@ void SfxApplication::MiscExec_Impl( SfxRequest& rReq )
aDialog.run();
break;
}
-
+ case SID_TOOLBAR_LOCK:
+ {
+ SfxViewFrame* pViewFrame = SfxViewFrame::Current();
+ if (pViewFrame)
+ {
+ Reference<XFrame> xCurrentFrame;
+ uno::Reference<uno::XComponentContext> xContext
+ = ::comphelper::getProcessComponentContext();
+ xCurrentFrame = pViewFrame->GetFrame().GetFrameInterface();
+ const Reference<frame::XModuleManager> xModuleManager
+ = frame::ModuleManager::create(xContext);
+ const utl::OConfigurationTreeRoot aAppNode(
+ xContext, "org.openoffice.Office.UI.GlobalSettings/Toolbars/States", true);
+ if (aAppNode.isValid())
+ {
+ bool isLocked = comphelper::getBOOL(aAppNode.getNodeValue("Locked"));
+ aAppNode.setNodeValue("Locked", makeAny(!isLocked));
+ aAppNode.commit();
+ //TODO: apply immediately w/o restart needed
+ SolarMutexGuard aGuard;
+ svtools::executeRestartDialog(comphelper::getProcessComponentContext(), nullptr,
+ svtools::RESTART_REASON_UI_CHANGE);
+ }
+ }
+ break;
+ }
default:
break;
}
@@ -1226,7 +1252,11 @@ void SfxApplication::MiscState_Impl(SfxItemSet &rSet)
rSet.DisableItem(nWhich);
}
break;
-
+ case SID_TOOLBAR_LOCK:
+ {
+ rSet.Put( SfxBoolItem( SID_TOOLBAR_LOCK, ToolBox::AlwaysLocked() ));
+ }
+ break;
default:
break;
}