include/sfx2/notebookbar/SfxNotebookBar.hxx | 2 + sfx2/source/notebookbar/SfxNotebookBar.cxx | 32 ++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+)
New commits: commit b33c175233ef6a9754fc4af647d82b9a51871a22 Author: Szymon Kłos <szymon.k...@collabora.com> AuthorDate: Tue Sep 12 09:02:41 2023 +0200 Commit: Szymon Kłos <szymon.k...@collabora.com> CommitDate: Wed Sep 13 08:31:28 2023 +0200 lok: fix notebookbar not initialized when switched from classic mode This is revert of "tdf#155720 remove old skip notebookbar init workaround" This reverts commit f95b5d12c59e612ee4643b385389fc791e31f76d. Mentioned change introduced regression in loading notebookbar. Steps to reproduce bug: 1. be sure cool is in classic/compact mode 2. restart the app so it will load in classic mode 3. switch to tabbed mode Result: notebookbar is not initialized and style previews and font selector are not present Change-Id: I35d6682cdd6c028437b373a748ed9ec36418ac17 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156836 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Szymon Kłos <szymon.k...@collabora.com> (cherry picked from commit c0234520ba9afda5a8b32f7a04c2155cbfbe30ed) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156875 Tested-by: Jenkins diff --git a/include/sfx2/notebookbar/SfxNotebookBar.hxx b/include/sfx2/notebookbar/SfxNotebookBar.hxx index 55a318e40bdd..96f5805f50e0 100644 --- a/include/sfx2/notebookbar/SfxNotebookBar.hxx +++ b/include/sfx2/notebookbar/SfxNotebookBar.hxx @@ -77,6 +77,8 @@ private: static std::map<const SfxViewShell*, std::shared_ptr<WeldedTabbedNotebookbar>> m_pNotebookBarWeldedWrapper; + static void ResetActiveToolbarModeToDefault(vcl::EnumContext::Application eApp); + DECL_DLLPRIVATE_STATIC_LINK(SfxNotebookBar, VclDisposeHdl, const SfxViewShell*, void); }; diff --git a/sfx2/source/notebookbar/SfxNotebookBar.cxx b/sfx2/source/notebookbar/SfxNotebookBar.cxx index 7a9fef48cfca..3b33ef7dd781 100644 --- a/sfx2/source/notebookbar/SfxNotebookBar.cxx +++ b/sfx2/source/notebookbar/SfxNotebookBar.cxx @@ -290,6 +290,26 @@ bool SfxNotebookBar::IsActive(bool bConsiderSingleToolbar) return false; } +void SfxNotebookBar::ResetActiveToolbarModeToDefault(vcl::EnumContext::Application eApp) +{ + const OUString appName( lcl_getAppName( eApp ) ); + + if ( appName.isEmpty() ) + return; + + const OUString aPath = "org.openoffice.Office.UI.ToolbarMode/Applications/" + appName; + + utl::OConfigurationTreeRoot aAppNode( + ::comphelper::getProcessComponentContext(), + aPath, + true); + if ( !aAppNode.isValid() ) + return; + + aAppNode.setNodeValue( "Active", Any( OUString( "Default" ) ) ); + aAppNode.commit(); +} + void SfxNotebookBar::ExecMethod(SfxBindings& rBindings, const OUString& rUIName) { // Save active UI file name @@ -359,6 +379,18 @@ bool SfxNotebookBar::StateMethod(SystemWindow* pSysWindow, { const SfxViewShell* pViewShell = SfxViewShell::Current(); + // Notebookbar was loaded too early what caused: + // * in LOK: Paste Special feature was incorrectly initialized + // Skip first request so Notebookbar will be initialized after document was loaded + static std::map<const void*, bool> bSkippedFirstInit; + if (comphelper::LibreOfficeKit::isActive() && eApp == vcl::EnumContext::Application::Writer + && bSkippedFirstInit.find(pViewShell) == bSkippedFirstInit.end()) + { + bSkippedFirstInit[pViewShell] = true; + ResetActiveToolbarModeToDefault(eApp); + return false; + } + RemoveListeners(pSysWindow); OUString aBuf = rUIFile + sFile;