include/vcl/builder.hxx | 4 +- include/vcl/notebookbar/NotebookBarAddonsItem.hxx | 33 ++++++++++++++++++++ include/vcl/notebookbar/NotebookBarAddonsMerger.hxx | 7 ---- include/vcl/notebookbar/notebookbar.hxx | 4 +- include/vcl/syswin.hxx | 2 - sfx2/source/notebookbar/SfxNotebookBar.cxx | 19 +++++++---- vcl/inc/brdwin.hxx | 4 +- vcl/source/control/notebookbar.cxx | 6 ++- vcl/source/control/tabctrl.cxx | 1 vcl/source/window/brdwin.cxx | 4 +- vcl/source/window/builder.cxx | 11 +++--- vcl/source/window/dockwin.cxx | 1 vcl/source/window/syswin.cxx | 5 +-- 13 files changed, 70 insertions(+), 31 deletions(-)
New commits: commit 3ed1855cef4bedf683ce83c53d55c605ebb5b0f9 Author: Szymon Kłos <szymon.k...@collabora.com> AuthorDate: Wed Aug 27 07:02:20 2025 +0000 Commit: Szymon Kłos <szymon.k...@collabora.com> CommitDate: Thu Aug 28 09:25:35 2025 +0200 notebookbar: ensure we don't load addons in lok - move notebookbar addon item definition into separate header to not include whole merger everywhere - avoid creation or using any addon related objects in lok case as they are not used anyway Change-Id: Ibb650386bf6d59f19a1a1c5cce8afa0da538dfd0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/190267 Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> diff --git a/include/vcl/builder.hxx b/include/vcl/builder.hxx index 254b4e52d328..ae7a25af7bd5 100644 --- a/include/vcl/builder.hxx +++ b/include/vcl/builder.hxx @@ -22,6 +22,7 @@ #include <vcl/toolboxid.hxx> #include <vcl/wintypes.hxx> #include <vcl/EnumContext.hxx> +#include <vcl/notebookbar/NotebookBarAddonsItem.hxx> #include <memory> #include <map> @@ -49,7 +50,6 @@ class TimeField; class ToolBox; class VclExpander; class VclMultiLineEdit; -struct NotebookBarAddonsItem; namespace com::sun::star::frame { class XFrame; } /// Creates a hierarchy of vcl::Windows (widgets) from a .ui file for dialogs, sidebar, etc. @@ -65,7 +65,7 @@ public: css::uno::Reference<css::frame::XFrame> xFrame = css::uno::Reference<css::frame::XFrame>(), bool bLegacy = true, - const NotebookBarAddonsItem* pNotebookBarAddonsItem = nullptr); + std::unique_ptr<NotebookBarAddonsItem> pNotebookBarAddonsItem = nullptr); virtual ~VclBuilder(); ///releases references and disposes all children. void disposeBuilder(); diff --git a/include/vcl/notebookbar/NotebookBarAddonsItem.hxx b/include/vcl/notebookbar/NotebookBarAddonsItem.hxx new file mode 100644 index 000000000000..08c864b6c564 --- /dev/null +++ b/include/vcl/notebookbar/NotebookBarAddonsItem.hxx @@ -0,0 +1,33 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <vcl/image.hxx> +#include <com/sun/star/beans/PropertyValue.hpp> +#include <com/sun/star/uno/Sequence.h> +#include <vector> + +struct NotebookBarAddonsItem +{ + std::vector<Image> aImageValues; + std::vector<css::uno::Sequence<css::uno::Sequence<css::beans::PropertyValue>>> aAddonValues; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/notebookbar/NotebookBarAddonsMerger.hxx b/include/vcl/notebookbar/NotebookBarAddonsMerger.hxx index 30ab04be2b6e..ce93afb0ae1e 100644 --- a/include/vcl/notebookbar/NotebookBarAddonsMerger.hxx +++ b/include/vcl/notebookbar/NotebookBarAddonsMerger.hxx @@ -27,15 +27,10 @@ #include <com/sun/star/frame/XFrame.hpp> #include <com/sun/star/uno/Sequence.h> #include <vector> +#include "NotebookBarAddonsItem.hxx" class Menu; -struct NotebookBarAddonsItem -{ - std::vector<Image> aImageValues; - std::vector<css::uno::Sequence<css::uno::Sequence<css::beans::PropertyValue>>> aAddonValues; -}; - struct AddonNotebookBarItem { OUString sCommandURL; diff --git a/include/vcl/notebookbar/notebookbar.hxx b/include/vcl/notebookbar/notebookbar.hxx index 057315952941..d6d741658161 100644 --- a/include/vcl/notebookbar/notebookbar.hxx +++ b/include/vcl/notebookbar/notebookbar.hxx @@ -11,7 +11,7 @@ #include <vcl/syswin.hxx> #include <vcl/ctrl.hxx> -#include <vcl/notebookbar/NotebookBarAddonsMerger.hxx> +#include <vcl/notebookbar/NotebookBarAddonsItem.hxx> #include <vcl/settings.hxx> #include <vector> @@ -29,7 +29,7 @@ friend class NotebookBarContextChangeEventListener; public: NotebookBar(Window* pParent, const OUString& rID, const OUString& rUIXMLDescription, const css::uno::Reference<css::frame::XFrame>& rFrame, - const NotebookBarAddonsItem& aNotebookBarAddonsItem); + std::unique_ptr<NotebookBarAddonsItem> pNotebookBarAddonsItem); virtual ~NotebookBar() override; virtual void dispose() override; diff --git a/include/vcl/syswin.hxx b/include/vcl/syswin.hxx index c1a5a8879310..c83334908194 100644 --- a/include/vcl/syswin.hxx +++ b/include/vcl/syswin.hxx @@ -190,7 +190,7 @@ public: void SetNotebookBar(const OUString& rUIXMLDescription, const css::uno::Reference<css::frame::XFrame>& rFrame, - const NotebookBarAddonsItem& aNotebookBarAddonsItem, + std::unique_ptr<NotebookBarAddonsItem> pNotebookBarAddonsItem, bool bReloadNotebookbar = false); void CloseNotebookBar(); diff --git a/sfx2/source/notebookbar/SfxNotebookBar.cxx b/sfx2/source/notebookbar/SfxNotebookBar.cxx index 8bb40710ad26..2630cbc01eae 100644 --- a/sfx2/source/notebookbar/SfxNotebookBar.cxx +++ b/sfx2/source/notebookbar/SfxNotebookBar.cxx @@ -7,6 +7,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#include <vcl/builder.hxx> #include <sfx2/bindings.hxx> #include <sfx2/viewsh.hxx> #include <sfx2/dispatch.hxx> @@ -26,7 +27,7 @@ #include <unotools/confignode.hxx> #include <comphelper/types.hxx> #include <framework/addonsoptions.hxx> -#include <vcl/notebookbar/NotebookBarAddonsMerger.hxx> +#include <vcl/notebookbar/NotebookBarAddonsItem.hxx> #include <vector> #include <unordered_map> #include <vcl/WeldedTabbedNotebookbar.hxx> @@ -473,10 +474,14 @@ bool SfxNotebookBar::StateMethod(SystemWindow* pSysWindow, //Addons For Notebookbar std::vector<Image> aImageValues; std::vector<css::uno::Sequence< css::uno::Sequence< css::beans::PropertyValue > > > aExtensionValues; - NotebookBarAddonsItem aNotebookBarAddonsItem; - NotebookbarAddonValues(aImageValues , aExtensionValues); - aNotebookBarAddonsItem.aAddonValues = std::move(aExtensionValues); - aNotebookBarAddonsItem.aImageValues = std::move(aImageValues); + std::unique_ptr<NotebookBarAddonsItem> pNotebookBarAddonsItem; + if (!bIsLOK) + { + pNotebookBarAddonsItem = std::make_unique<NotebookBarAddonsItem>(); + NotebookbarAddonValues(aImageValues , aExtensionValues); + pNotebookBarAddonsItem->aAddonValues = std::move(aExtensionValues); + pNotebookBarAddonsItem->aImageValues = std::move(aImageValues); + } if (bIsLOK) { @@ -499,7 +504,7 @@ bool SfxNotebookBar::StateMethod(SystemWindow* pSysWindow, comphelper::LibreOfficeKit::setLanguageTag(pViewShell->GetLOKLanguageTag()); comphelper::LibreOfficeKit::setLocale(pViewShell->GetLOKLocale()); - pNotebookBar = VclPtr<NotebookBar>::Create(pSysWindow, "NotebookBar", aBuf, xFrame, aNotebookBarAddonsItem); + pNotebookBar = VclPtr<NotebookBar>::Create(pSysWindow, "NotebookBar", aBuf, xFrame, std::move(pNotebookBarAddonsItem)); rViewData.m_pNotebookBar = pNotebookBar; assert(pNotebookBar->IsWelded()); @@ -524,7 +529,7 @@ bool SfxNotebookBar::StateMethod(SystemWindow* pSysWindow, RemoveListeners(pSysWindow); - pSysWindow->SetNotebookBar(aBuf, xFrame, aNotebookBarAddonsItem , bReloadNotebookbar); + pSysWindow->SetNotebookBar(aBuf, xFrame, std::move(pNotebookBarAddonsItem), bReloadNotebookbar); pNotebookBar = pSysWindow->GetNotebookBar(); pNotebookBar->Show(); diff --git a/vcl/inc/brdwin.hxx b/vcl/inc/brdwin.hxx index f9c8a8edb894..e0169653be49 100644 --- a/vcl/inc/brdwin.hxx +++ b/vcl/inc/brdwin.hxx @@ -23,11 +23,11 @@ #include <vcl/notebookbar/notebookbar.hxx> #include <vcl/window.hxx> #include <o3tl/typed_flags_set.hxx> -#include <vcl/notebookbar/NotebookBarAddonsMerger.hxx> #include <com/sun/star/frame/XFrame.hpp> class ImplBorderWindowView; +struct NotebookBarAddonsItem; enum class DrawButtonFlags; enum class BorderWindowStyle { @@ -153,7 +153,7 @@ public: void SetNotebookBar(const OUString& rUIXMLDescription, const css::uno::Reference<css::frame::XFrame>& rFrame, - const NotebookBarAddonsItem &aNotebookBarAddonsItem); + std::unique_ptr<NotebookBarAddonsItem> pNotebookBarAddonsItem); void CloseNotebookBar(); const VclPtr<NotebookBar>& GetNotebookBar() const { return mpNotebookBar; } diff --git a/vcl/source/control/notebookbar.cxx b/vcl/source/control/notebookbar.cxx index a0de7038fb9c..6fdf136272cd 100644 --- a/vcl/source/control/notebookbar.cxx +++ b/vcl/source/control/notebookbar.cxx @@ -12,6 +12,7 @@ #include <string_view> #include <utility> +#include <vcl/builder.hxx> #include <vcl/layout.hxx> #include <vcl/notebookbar/notebookbar.hxx> #include <vcl/syswin.hxx> @@ -71,7 +72,7 @@ public: NotebookBar::NotebookBar(Window* pParent, const OUString& rID, const OUString& rUIXMLDescription, const css::uno::Reference<css::frame::XFrame>& rFrame, - const NotebookBarAddonsItem& aNotebookBarAddonsItem) + std::unique_ptr<NotebookBarAddonsItem> pNotebookBarAddonsItem) : Control(pParent) , m_pEventListener(new NotebookBarContextChangeEventListener(this, rFrame)) , m_pViewShell(nullptr) @@ -97,7 +98,8 @@ NotebookBar::NotebookBar(Window* pParent, const OUString& rID, const OUString& r else { m_pUIBuilder.reset( - new VclBuilder(this, sUIDir, rUIXMLDescription, rID, rFrame, true, &aNotebookBarAddonsItem)); + new VclBuilder(this, sUIDir, rUIXMLDescription, rID, rFrame, true, + std::move(pNotebookBarAddonsItem))); // In the Notebookbar's .ui file must exist control handling context // - implementing NotebookbarContextControl interface with id "ContextContainer" diff --git a/vcl/source/control/tabctrl.cxx b/vcl/source/control/tabctrl.cxx index 5aa5c831617c..261421303f29 100644 --- a/vcl/source/control/tabctrl.cxx +++ b/vcl/source/control/tabctrl.cxx @@ -21,6 +21,7 @@ #include <sal/log.hxx> #include <vcl/notebookbar/notebookbar.hxx> +#include <vcl/builder.hxx> #include <vcl/svapp.hxx> #include <vcl/help.hxx> #include <vcl/event.hxx> diff --git a/vcl/source/window/brdwin.cxx b/vcl/source/window/brdwin.cxx index e799df338a48..0dfe6280b503 100644 --- a/vcl/source/window/brdwin.cxx +++ b/vcl/source/window/brdwin.cxx @@ -1938,12 +1938,12 @@ void ImplBorderWindow::SetMenuBarMode( bool bHide ) void ImplBorderWindow::SetNotebookBar(const OUString& rUIXMLDescription, const css::uno::Reference<css::frame::XFrame>& rFrame, - const NotebookBarAddonsItem& aNotebookBarAddonsItem) + std::unique_ptr<NotebookBarAddonsItem> pNotebookBarAddonsItem) { if (mpNotebookBar) mpNotebookBar.disposeAndClear(); mpNotebookBar = VclPtr<NotebookBar>::Create(this, "NotebookBar", rUIXMLDescription, rFrame, - aNotebookBarAddonsItem); + std::move(pNotebookBarAddonsItem)); Resize(); } diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx index c181a2bf8f2d..6a04071705ed 100644 --- a/vcl/source/window/builder.cxx +++ b/vcl/source/window/builder.cxx @@ -518,11 +518,9 @@ void BuilderBase::resetParserState() { m_pParserState.reset(); } VclBuilder::VclBuilder(vcl::Window* pParent, std::u16string_view sUIDir, const OUString& sUIFile, OUString sID, css::uno::Reference<css::frame::XFrame> xFrame, - bool bLegacy, const NotebookBarAddonsItem* pNotebookBarAddonsItem) + bool bLegacy, std::unique_ptr<NotebookBarAddonsItem> pNotebookBarAddonsItem) : WidgetBuilder(sUIDir, sUIFile, bLegacy) - , m_pNotebookBarAddonsItem(pNotebookBarAddonsItem - ? new NotebookBarAddonsItem(*pNotebookBarAddonsItem) - : new NotebookBarAddonsItem{}) + , m_pNotebookBarAddonsItem(std::move(pNotebookBarAddonsItem)) , m_sID(std::move(sID)) , m_pParent(pParent) , m_bToplevelParentFound(false) @@ -3024,7 +3022,10 @@ void VclBuilder::insertMenuObject(PopupMenu* pParent, PopupMenu* pSubMenu, const if(rClass == "NotebookBarAddonsMenuMergePoint") { - NotebookBarAddonsMerger::MergeNotebookBarMenuAddons(pParent, nNewId, rID, *m_pNotebookBarAddonsItem); + if (!comphelper::LibreOfficeKit::isActive()) + { + NotebookBarAddonsMerger::MergeNotebookBarMenuAddons(pParent, nNewId, rID, *m_pNotebookBarAddonsItem); + } m_pVclParserState->m_nLastMenuItemId = pParent->GetItemCount(); } else if (rClass == "GtkMenuItem") diff --git a/vcl/source/window/dockwin.cxx b/vcl/source/window/dockwin.cxx index fd4f07794de4..fabf495fe724 100644 --- a/vcl/source/window/dockwin.cxx +++ b/vcl/source/window/dockwin.cxx @@ -19,6 +19,7 @@ #include <tools/time.hxx> #include <sal/log.hxx> +#include <vcl/builder.hxx> #include <vcl/event.hxx> #include <vcl/toolkit/floatwin.hxx> #include <vcl/layout.hxx> diff --git a/vcl/source/window/syswin.cxx b/vcl/source/window/syswin.cxx index 6c3e89ca50f1..4414b135f4a2 100644 --- a/vcl/source/window/syswin.cxx +++ b/vcl/source/window/syswin.cxx @@ -25,6 +25,7 @@ #include <sal/config.h> #include <sal/log.hxx> +#include <vcl/builder.hxx> #include <vcl/layout.hxx> #include <vcl/mnemonic.hxx> #include <vcl/settings.hxx> @@ -907,7 +908,7 @@ void SystemWindow::SetMenuBar(MenuBar* pMenuBar) void SystemWindow::SetNotebookBar(const OUString& rUIXMLDescription, const css::uno::Reference<css::frame::XFrame>& rFrame, - const NotebookBarAddonsItem& aNotebookBarAddonsItem, + std::unique_ptr<NotebookBarAddonsItem> pNotebookBarAddonsItem, bool bReloadNotebookbar) { mbInSetNoteBookBar = true; @@ -915,7 +916,7 @@ void SystemWindow::SetNotebookBar(const OUString& rUIXMLDescription, if (rUIXMLDescription != maNotebookBarUIFile || bReloadNotebookbar) { static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow.get()) - ->SetNotebookBar(rUIXMLDescription, rFrame, aNotebookBarAddonsItem); + ->SetNotebookBar(rUIXMLDescription, rFrame, std::move(pNotebookBarAddonsItem)); maNotebookBarUIFile = rUIXMLDescription; if(GetNotebookBar()) GetNotebookBar()->SetSystemWindow(this);