include/sfx2/infobar.hxx | 2 include/sfx2/objsh.hxx | 2 include/sfx2/viewsh.hxx | 1 officecfg/files.mk | 1 officecfg/registry/schema/org/openoffice/Office/UI/Infobar.xcs | 53 ++++++++++ postprocess/CustomTarget_registry.mk | 1 sfx2/source/dialog/infobar.cxx | 20 +++ sfx2/source/doc/objmisc.cxx | 11 ++ sfx2/source/view/viewfrm.cxx | 7 - sfx2/source/view/viewsh.cxx | 9 - 10 files changed, 92 insertions(+), 15 deletions(-)
New commits: commit b408eabebc4644351faca4fc0c952e8eb771c86c Author: Samuel Mehrbrodt <[email protected]> AuthorDate: Wed Apr 22 15:30:47 2020 +0200 Commit: Samuel Mehrbrodt <[email protected]> CommitDate: Thu Apr 20 15:46:00 2023 +0200 Add config to disable individual infobars In some deployments users want to disable certain infobars to not interfere with their workflows. Also, there are individual users who want to disable certain infobars for various reasons. This could be a generic config setting where you can set a list of Infobar IDs which should be disabled. That however would require knowledge about the internal IDs which are not exposed (and might even change over time). So instead, add a config option for each known infobar where we suspect users might want to turn it off. This list might change over time. Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92638 Tested-by: Samuel Mehrbrodt <[email protected]> Reviewed-by: Stephan Bergmann <[email protected]> (cherry picked from commit 29575dc6a481f2548b3fcb0906138861aec03583) Change-Id: I13f0456435b59aafe929a46498de5a8847f138e2 diff --git a/include/sfx2/infobar.hxx b/include/sfx2/infobar.hxx index 80f4c0a0506c..405f1feffd42 100644 --- a/include/sfx2/infobar.hxx +++ b/include/sfx2/infobar.hxx @@ -117,7 +117,7 @@ class SfxInfoBarContainerWindow final : public vcl::Window VclPtr<SfxInfoBarWindow> getInfoBar(const OUString& sId); bool hasInfoBarWithID(const OUString& sId); void removeInfoBar(VclPtr<SfxInfoBarWindow> const & pInfoBar); - + static bool isInfobarEnabled(const OUString& sId); virtual void Resize() override; }; diff --git a/officecfg/files.mk b/officecfg/files.mk index 3d3a5079f622..9a4b688391a0 100644 --- a/officecfg/files.mk +++ b/officecfg/files.mk @@ -77,6 +77,7 @@ officecfg_XCSFILES := \ Office/UI/GenericCommands \ Office/UI/GlobalSettings \ Office/UI/ImpressWindowState \ + Office/UI/Infobar \ Office/UI/MathCommands \ Office/UI/MathWindowState \ Office/UI/ReportCommands \ diff --git a/officecfg/registry/schema/org/openoffice/Office/UI/Infobar.xcs b/officecfg/registry/schema/org/openoffice/Office/UI/Infobar.xcs new file mode 100644 index 000000000000..af0434046770 --- /dev/null +++ b/officecfg/registry/schema/org/openoffice/Office/UI/Infobar.xcs @@ -0,0 +1,53 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * +--> +<!DOCTYPE oor:component-schema SYSTEM "../../../../../component-schema.dtd"> +<oor:component-schema xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" oor:name="Infobar" oor:package="org.openoffice.Office.UI" xml:lang="en-US"> + <info> + <desc>Infobar configuration.</desc> + </info> + <template></template> + <component> + <group oor:name="Enabled"> + <info> + <desc>Which Infobars are enabled.</desc> + </info> + <prop oor:name="Readonly" oor:type="xs:boolean" oor:nillable="false"> + <info> + <desc>Whether the Infobar shown in read-only docs is enabled</desc> + </info> + <value>true</value> + </prop> + <prop oor:name="Signature" oor:type="xs:boolean" oor:nillable="false"> + <info> + <desc>Whether the Infobar showing the Digital Signature state is enabled</desc> + </info> + <value>true</value> + </prop> + <prop oor:name="Donate" oor:type="xs:boolean" oor:nillable="false"> + <info> + <desc>Whether the Infobar showing the call for donations is enabled</desc> + </info> + <value>true</value> + </prop> + <prop oor:name="GetInvolved" oor:type="xs:boolean" oor:nillable="false"> + <info> + <desc>Whether the Infobar showing the call to 'Get Involved' is enabled</desc> + </info> + <value>true</value> + </prop> + <prop oor:name="HyphenationMissing" oor:type="xs:boolean" oor:nillable="false"> + <info> + <desc>Whether an Infobar is shown when Hyphenation Info is missing for a document</desc> + </info> + <value>true</value> + </prop> + </group> + </component> +</oor:component-schema> diff --git a/postprocess/CustomTarget_registry.mk b/postprocess/CustomTarget_registry.mk index 02d55ed3cd89..a81f05e89920 100644 --- a/postprocess/CustomTarget_registry.mk +++ b/postprocess/CustomTarget_registry.mk @@ -176,6 +176,7 @@ postprocess_FILES_main := \ $(postprocess_XCS)/Office/UI/GenericCategories.xcs \ $(postprocess_XCS)/Office/UI/GenericCommands.xcs \ $(postprocess_XCS)/Office/UI/GlobalSettings.xcs \ + $(postprocess_XCS)/Office/UI/Infobar.xcs \ $(postprocess_XCS)/Office/UI/Sidebar.xcs \ $(postprocess_XCS)/Office/UI/StartModuleCommands.xcs \ $(postprocess_XCS)/Office/UI/StartModuleWindowState.xcs \ diff --git a/sfx2/source/dialog/infobar.cxx b/sfx2/source/dialog/infobar.cxx index 3479fe72ad7d..b8d79f0b5a9c 100644 --- a/sfx2/source/dialog/infobar.cxx +++ b/sfx2/source/dialog/infobar.cxx @@ -13,6 +13,7 @@ #include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx> #include <drawinglayer/processor2d/baseprocessor2d.hxx> #include <drawinglayer/processor2d/processorfromoutputdevice.hxx> +#include <officecfg/Office/UI/Infobar.hxx> #include <sfx2/bindings.hxx> #include <sfx2/dispatch.hxx> #include <sfx2/infobar.hxx> @@ -392,6 +393,9 @@ SfxInfoBarContainerWindow::appendInfoBar(const OUString& sId, const OUString& sP const OUString& sSecondaryMessage, InfobarType ibType, WinBits nMessageStyle, bool bShowCloseButton) { + if (!isInfobarEnabled(sId)) + return nullptr; + auto pInfoBar = VclPtr<SfxInfoBarWindow>::Create(this, sId, sPrimaryMessage, sSecondaryMessage, ibType, nMessageStyle, bShowCloseButton); @@ -437,6 +441,22 @@ void SfxInfoBarContainerWindow::removeInfoBar(VclPtr<SfxInfoBarWindow> const & p m_pChildWin->Update(); } +bool SfxInfoBarContainerWindow::isInfobarEnabled(const OUString& sId) +{ + if (sId == "readonly") + return officecfg::Office::UI::Infobar::Enabled::Readonly::get(); + if (sId == "signature") + return officecfg::Office::UI::Infobar::Enabled::Signature::get(); + if (sId == "donate") + return officecfg::Office::UI::Infobar::Enabled::Donate::get(); + if (sId == "getinvolved") + return officecfg::Office::UI::Infobar::Enabled::GetInvolved::get(); + if (sId == "hyphenationmissing") + return officecfg::Office::UI::Infobar::Enabled::HyphenationMissing::get(); + + return true; +} + void SfxInfoBarContainerWindow::Resize() { long nWidth = GetSizePixel().getWidth(); commit c2d97b3a1a96cfee8c74b5246e78a867b81579ea Author: Samuel Mehrbrodt <[email protected]> AuthorDate: Tue Apr 7 16:21:08 2020 +0200 Commit: Samuel Mehrbrodt <[email protected]> CommitDate: Thu Apr 20 15:46:00 2023 +0200 Fix edit button still appearing in Calc ... even when editing readonly docs was disabled. Viewshell was not yet available at this point, so move the code where it belongs, into the object shell. Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91832 Tested-by: Jenkins Reviewed-by: Samuel Mehrbrodt <[email protected]> (cherry picked from commit 523922ee9d033fd304d2b50a72b76853ddcfbcdf) Change-Id: I71cbaf9c912beeeb0b8177538999049f7f8b4e03 diff --git a/include/sfx2/objsh.hxx b/include/sfx2/objsh.hxx index 2a56ebe88e07..2be6c0a1e22c 100644 --- a/include/sfx2/objsh.hxx +++ b/include/sfx2/objsh.hxx @@ -579,6 +579,8 @@ public: const css::uno::Reference<css::embed::XStorage>& xTarget, const css::uno::Sequence<OUString>& rExceptions = css::uno::Sequence<OUString>()); + bool isEditDocLocked(); + // The functions from SvPersist void EnableSetModified( bool bEnable = true ); bool IsEnableSetModified() const; diff --git a/include/sfx2/viewsh.hxx b/include/sfx2/viewsh.hxx index d65fae656b16..a1a225aa1b28 100644 --- a/include/sfx2/viewsh.hxx +++ b/include/sfx2/viewsh.hxx @@ -292,7 +292,6 @@ public: bool isExportLocked(); bool isPrintLocked(); bool isSaveLocked(); - bool isEditDocLocked(); SAL_DLLPRIVATE SfxInPlaceClient* GetUIActiveIPClient_Impl() const; SAL_DLLPRIVATE void AddContextMenuInterceptor_Impl( const css::uno::Reference < css::ui::XContextMenuInterceptor >& xInterceptor ); diff --git a/sfx2/source/doc/objmisc.cxx b/sfx2/source/doc/objmisc.cxx index 04ff6ecd5314..ff31ce956bbc 100644 --- a/sfx2/source/doc/objmisc.cxx +++ b/sfx2/source/doc/objmisc.cxx @@ -87,6 +87,8 @@ #include <comphelper/interaction.hxx> #include <comphelper/storagehelper.hxx> #include <comphelper/documentconstants.hxx> +#include <comphelper/namedvaluecollection.hxx> +#include <officecfg/Office/Common.hxx> #include <sfx2/signaturestate.hxx> #include <sfx2/app.hxx> @@ -1896,4 +1898,13 @@ bool SfxObjectShell::IsContinueImportOnFilterExceptions(const OUString& aErrMess return mbContinueImportOnFilterExceptions == yes; } +bool SfxObjectShell::isEditDocLocked() +{ + Reference<XModel> xModel = GetModel(); + if (!xModel.is()) + return false; + comphelper::NamedValueCollection aArgs(xModel->getArgs()); + return aArgs.getOrDefault("LockEditDoc", false); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx index 885023465120..2b39c4b1ef3c 100644 --- a/sfx2/source/view/viewfrm.cxx +++ b/sfx2/source/view/viewfrm.cxx @@ -308,8 +308,7 @@ void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq ) if( !pSh || !pSh->HasName() || !(pSh->Get_Impl()->nLoadedFlags & SfxLoadedFlags::MAINDOCUMENT )) break; - SfxViewShell* pViewSh = GetViewShell(); - if (pViewSh && pViewSh->isEditDocLocked()) + if (pSh->isEditDocLocked()) break; // Only change read-only UI and remove info bar when we succeed @@ -929,7 +928,7 @@ void SfxViewFrame::StateReload_Impl( SfxItemSet& rSet ) const SfxShell *pFSh; if ( !pSh->HasName() || !( pSh->Get_Impl()->nLoadedFlags & SfxLoadedFlags::MAINDOCUMENT ) || - (GetViewShell() && GetViewShell()->isEditDocLocked()) || + (pSh->isEditDocLocked()) || ( pSh->GetCreateMode() == SfxObjectCreateMode::EMBEDDED && ( !(pVSh = pSh->GetViewShell()) || !(pFSh = pVSh->GetFormShell()) || @@ -1351,7 +1350,7 @@ void SfxViewFrame::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint ) } bool showEditDocumentButton = true; - if (m_xObjSh->GetViewShell() && m_xObjSh->GetViewShell()->isEditDocLocked()) + if (m_xObjSh->isEditDocLocked()) showEditDocumentButton = false; if (showEditDocumentButton) diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx index 80cd8a122d07..cb7925efa907 100644 --- a/sfx2/source/view/viewsh.cxx +++ b/sfx2/source/view/viewsh.cxx @@ -1776,15 +1776,6 @@ bool SfxViewShell::isPrintLocked() return aArgs.getOrDefault("LockPrint", false); } -bool SfxViewShell::isEditDocLocked() -{ - Reference<XModel> xModel = GetCurrentDocument(); - if (!xModel.is()) - return false; - comphelper::NamedValueCollection aArgs(xModel->getArgs()); - return aArgs.getOrDefault("LockEditDoc", false); -} - bool SfxViewShell::isSaveLocked() { Reference<XModel> xModel = GetCurrentDocument();
