desktop/Library_deploymentgui.mk | 1 desktop/source/deployment/gui/dp_gui_dialog2.cxx | 251 +--------- desktop/source/deployment/gui/dp_gui_dialog2.hxx | 14 desktop/source/deployment/gui/dp_gui_extensionboxwithbuttons.cxx | 218 ++++++++ desktop/source/deployment/gui/dp_gui_extensionboxwithbuttons.hxx | 56 ++ desktop/source/deployment/gui/dp_gui_extlistbox.cxx | 91 +-- desktop/source/deployment/gui/dp_gui_extlistbox.hxx | 14 desktop/source/deployment/gui/dp_gui_theextmgr.cxx | 3 solenv/clang-format/excludelist | 1 9 files changed, 358 insertions(+), 291 deletions(-)
New commits: commit 2e49461fde5a007b284b276c8e4b192732fe9dd9 Author: Michael Weghorn <[email protected]> AuthorDate: Thu Oct 16 14:33:15 2025 +0200 Commit: Michael Weghorn <[email protected]> CommitDate: Fri Oct 17 12:13:43 2025 +0200 extension mgr: Move ExtensionBoxWithButtons to own header/source ... in order to help keeping the overview. Change-Id: I5c4bf6a2fd46e4154324174d2c870da568715850 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/192508 Tested-by: Jenkins Reviewed-by: Michael Weghorn <[email protected]> diff --git a/desktop/Library_deploymentgui.mk b/desktop/Library_deploymentgui.mk index 325a29b55946..7776d03e0c0a 100644 --- a/desktop/Library_deploymentgui.mk +++ b/desktop/Library_deploymentgui.mk @@ -59,6 +59,7 @@ $(eval $(call gb_Library_set_componentfile,deploymentgui,desktop/source/deployme $(eval $(call gb_Library_add_exception_objects,deploymentgui,\ desktop/source/deployment/gui/dp_gui_dependencydialog \ desktop/source/deployment/gui/dp_gui_dialog2 \ + desktop/source/deployment/gui/dp_gui_extensionboxwithbuttons \ desktop/source/deployment/gui/dp_gui_extensioncmdqueue \ desktop/source/deployment/gui/dp_gui_extlistbox \ desktop/source/deployment/gui/dp_gui_service \ diff --git a/desktop/source/deployment/gui/dp_gui_dialog2.cxx b/desktop/source/deployment/gui/dp_gui_dialog2.cxx index ae4d92ac09c7..9927382e28fb 100644 --- a/desktop/source/deployment/gui/dp_gui_dialog2.cxx +++ b/desktop/source/deployment/gui/dp_gui_dialog2.cxx @@ -24,6 +24,7 @@ #include "dp_gui.h" #include "dp_gui_dialog2.hxx" +#include "dp_gui_extensionboxwithbuttons.hxx" #include "dp_gui_extlistbox.hxx" #include <dp_shared.hxx> #include "dp_gui_theextmgr.hxx" @@ -77,204 +78,6 @@ constexpr OUStringLiteral USER_PACKAGE_MANAGER = u"user"; constexpr OUString SHARED_PACKAGE_MANAGER = u"shared"_ustr; constexpr OUStringLiteral BUNDLED_PACKAGE_MANAGER = u"bundled"; -class ExtensionBoxWithButtons : public ExtensionBox -{ - bool m_bInterfaceLocked; - - ExtMgrDialog* m_pParent; - - void SetButtonStatus( const TEntry_Impl& rEntry ); - OUString ShowPopupMenu( const Point &rPos, const tools::Long nPos ); - -public: - explicit ExtensionBoxWithButtons(std::unique_ptr<weld::ScrolledWindow> xScroll); - - void InitFromDialog(ExtMgrDialog *pParentDialog); - - virtual bool MouseButtonDown( const MouseEvent& rMEvt ) override; - virtual bool Command( const CommandEvent& rCEvt ) override; - - virtual void RecalcAll() override; - virtual void selectEntry( const tools::Long nPos ) override; - - void enableButtons( bool bEnable ); -}; - -ExtensionBoxWithButtons::ExtensionBoxWithButtons(std::unique_ptr<weld::ScrolledWindow> xScroll) - : ExtensionBox(std::move(xScroll)) - , m_bInterfaceLocked(false) - , m_pParent(nullptr) -{ -} - -void ExtensionBoxWithButtons::InitFromDialog(ExtMgrDialog* pParentDialog) -{ - setExtensionManager(&pParentDialog->getExtensionManager()); - - m_pParent = pParentDialog; -} - -void ExtensionBoxWithButtons::RecalcAll() -{ - const sal_Int32 nActive = getSelIndex(); - - if (nActive != ExtensionBox::ENTRY_NOTFOUND) - { - SetButtonStatus( GetEntryData( nActive) ); - } - else - { - m_pParent->enableOptionsButton( false ); - m_pParent->enableRemoveButton( false ); - m_pParent->enableEnableButton( false ); - } - - ExtensionBox::RecalcAll(); -} - - -//This function may be called with nPos < 0 -void ExtensionBoxWithButtons::selectEntry(const tools::Long nPos) -{ - if ( HasActive() && ( nPos == getSelIndex() ) ) - return; - - ExtensionBox::selectEntry(nPos); -} - -void ExtensionBoxWithButtons::SetButtonStatus(const TEntry_Impl& rEntry) -{ - bool bShowOptionBtn = true; - - rEntry->m_bHasButtons = false; - if ( ( rEntry->m_eState == REGISTERED ) || ( rEntry->m_eState == NOT_AVAILABLE ) ) - { - m_pParent->enableButtontoEnable( false ); - } - else - { - m_pParent->enableButtontoEnable( true ); - bShowOptionBtn = false; - } - - if ( ( !rEntry->m_bUser || ( rEntry->m_eState == NOT_AVAILABLE ) || rEntry->m_bMissingDeps ) - && !rEntry->m_bMissingLic ) - { - m_pParent->enableEnableButton( false ); - } - else - { - m_pParent->enableEnableButton( !rEntry->m_bLocked ); - rEntry->m_bHasButtons = true; - } - - if ( rEntry->m_bHasOptions && bShowOptionBtn ) - { - m_pParent->enableOptionsButton( true ); - rEntry->m_bHasButtons = true; - } - else - { - m_pParent->enableOptionsButton( false ); - } - - if ( rEntry->m_bUser || rEntry->m_bShared ) - { - m_pParent->enableRemoveButton( !rEntry->m_bLocked ); - rEntry->m_bHasButtons = true; - } - else - { - m_pParent->enableRemoveButton( false ); - } -} - -bool ExtensionBoxWithButtons::Command(const CommandEvent& rCEvt) -{ - if (rCEvt.GetCommand() != CommandEventId::ContextMenu) - return ExtensionBox::Command(rCEvt); - - const Point aMousePos(rCEvt.GetMousePosPixel()); - const auto nPos = PointToPos(aMousePos); - OUString sCommand = ShowPopupMenu(aMousePos, nPos); - - if (sCommand == "CMD_ENABLE") - m_pParent->enablePackage( GetEntryData( nPos )->m_xPackage, true ); - else if (sCommand == "CMD_DISABLE") - m_pParent->enablePackage( GetEntryData( nPos )->m_xPackage, false ); - else if (sCommand == "CMD_UPDATE") - m_pParent->updatePackage( GetEntryData( nPos )->m_xPackage ); - else if (sCommand == "CMD_REMOVE") - m_pParent->removePackage( GetEntryData( nPos )->m_xPackage ); - else if (sCommand == "CMD_SHOW_LICENSE") - { - m_pParent->incBusy(); - ShowLicenseDialog aLicenseDlg(m_pParent->getDialog(), GetEntryData(nPos)->m_xPackage); - aLicenseDlg.run(); - m_pParent->decBusy(); - } - - return true; -} - -OUString ExtensionBoxWithButtons::ShowPopupMenu(const Point& rPos, const tools::Long nPos) -{ - if ( nPos >= static_cast<tools::Long>(getItemCount()) ) - return u"CMD_NONE"_ustr; - - std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(nullptr, u"desktop/ui/extensionmenu.ui"_ustr)); - std::unique_ptr<weld::Menu> xPopup(xBuilder->weld_menu(u"menu"_ustr)); - -#if ENABLE_EXTENSION_UPDATE - xPopup->append(u"CMD_UPDATE"_ustr, DpResId( RID_CTX_ITEM_CHECK_UPDATE ) ); -#endif - - if ( ! GetEntryData( nPos )->m_bLocked ) - { - if ( GetEntryData( nPos )->m_bUser ) - { - if ( GetEntryData( nPos )->m_eState == REGISTERED ) - xPopup->append(u"CMD_DISABLE"_ustr, DpResId(RID_CTX_ITEM_DISABLE)); - else if ( GetEntryData( nPos )->m_eState != NOT_AVAILABLE ) - xPopup->append(u"CMD_ENABLE"_ustr, DpResId(RID_CTX_ITEM_ENABLE)); - } - if (!officecfg::Office::ExtensionManager::ExtensionSecurity::DisableExtensionRemoval::get()) - { - xPopup->append(u"CMD_REMOVE"_ustr, DpResId(RID_CTX_ITEM_REMOVE)); - } - } - - if ( !GetEntryData( nPos )->m_sLicenseText.isEmpty() ) - xPopup->append(u"CMD_SHOW_LICENSE"_ustr, DpResId(RID_STR_SHOW_LICENSE_CMD)); - - return xPopup->popup_at_rect(GetDrawingArea(), tools::Rectangle(rPos, Size(1, 1))); -} - -bool ExtensionBoxWithButtons::MouseButtonDown(const MouseEvent& rMEvt) -{ - if (m_bInterfaceLocked) - return false; - return ExtensionBox::MouseButtonDown(rMEvt); -} - -void ExtensionBoxWithButtons::enableButtons(bool bEnable) -{ - m_bInterfaceLocked = ! bEnable; - - if ( bEnable ) - { - sal_Int32 nIndex = getSelIndex(); - if (nIndex != ExtensionBox::ENTRY_NOTFOUND) - SetButtonStatus( GetEntryData( nIndex ) ); - } - else - { - m_pParent->enableEnableButton( false ); - m_pParent->enableOptionsButton( false ); - m_pParent->enableRemoveButton( false ); - } -} - // DialogHelper DialogHelper::DialogHelper(const uno::Reference< uno::XComponentContext > &xContext, diff --git a/desktop/source/deployment/gui/dp_gui_extensionboxwithbuttons.cxx b/desktop/source/deployment/gui/dp_gui_extensionboxwithbuttons.cxx new file mode 100644 index 000000000000..675856543201 --- /dev/null +++ b/desktop/source/deployment/gui/dp_gui_extensionboxwithbuttons.cxx @@ -0,0 +1,218 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * 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 . + */ + +#include <config_extensions.h> + +#include "dp_gui.h" +#include "dp_gui_dialog2.hxx" +#include "dp_gui_extensionboxwithbuttons.hxx" + +#include <dp_shared.hxx> +#include <strings.hrc> + +#include <officecfg/Office/ExtensionManager.hxx> +#include <sal/log.hxx> +#include <vcl/commandevent.hxx> +#include <vcl/svapp.hxx> + +#include <memory> +#include <utility> + +using namespace ::com::sun::star; + +namespace dp_gui { + +ExtensionBoxWithButtons::ExtensionBoxWithButtons(std::unique_ptr<weld::ScrolledWindow> xScroll) + : ExtensionBox(std::move(xScroll)) + , m_bInterfaceLocked(false) + , m_pParent(nullptr) +{ +} + +void ExtensionBoxWithButtons::InitFromDialog(ExtMgrDialog* pParentDialog) +{ + setExtensionManager(&pParentDialog->getExtensionManager()); + + m_pParent = pParentDialog; +} + +void ExtensionBoxWithButtons::RecalcAll() +{ + const sal_Int32 nActive = getSelIndex(); + + if (nActive != ExtensionBox::ENTRY_NOTFOUND) + { + SetButtonStatus( GetEntryData( nActive) ); + } + else + { + m_pParent->enableOptionsButton( false ); + m_pParent->enableRemoveButton( false ); + m_pParent->enableEnableButton( false ); + } + + ExtensionBox::RecalcAll(); +} + + +//This function may be called with nPos < 0 +void ExtensionBoxWithButtons::selectEntry(const tools::Long nPos) +{ + if ( HasActive() && ( nPos == getSelIndex() ) ) + return; + + ExtensionBox::selectEntry(nPos); +} + +void ExtensionBoxWithButtons::SetButtonStatus(const TEntry_Impl& rEntry) +{ + bool bShowOptionBtn = true; + + rEntry->m_bHasButtons = false; + if ( ( rEntry->m_eState == REGISTERED ) || ( rEntry->m_eState == NOT_AVAILABLE ) ) + { + m_pParent->enableButtontoEnable( false ); + } + else + { + m_pParent->enableButtontoEnable( true ); + bShowOptionBtn = false; + } + + if ( ( !rEntry->m_bUser || ( rEntry->m_eState == NOT_AVAILABLE ) || rEntry->m_bMissingDeps ) + && !rEntry->m_bMissingLic ) + { + m_pParent->enableEnableButton( false ); + } + else + { + m_pParent->enableEnableButton( !rEntry->m_bLocked ); + rEntry->m_bHasButtons = true; + } + + if ( rEntry->m_bHasOptions && bShowOptionBtn ) + { + m_pParent->enableOptionsButton( true ); + rEntry->m_bHasButtons = true; + } + else + { + m_pParent->enableOptionsButton( false ); + } + + if ( rEntry->m_bUser || rEntry->m_bShared ) + { + m_pParent->enableRemoveButton( !rEntry->m_bLocked ); + rEntry->m_bHasButtons = true; + } + else + { + m_pParent->enableRemoveButton( false ); + } +} + +bool ExtensionBoxWithButtons::Command(const CommandEvent& rCEvt) +{ + if (rCEvt.GetCommand() != CommandEventId::ContextMenu) + return ExtensionBox::Command(rCEvt); + + const Point aMousePos(rCEvt.GetMousePosPixel()); + const auto nPos = PointToPos(aMousePos); + OUString sCommand = ShowPopupMenu(aMousePos, nPos); + + if (sCommand == "CMD_ENABLE") + m_pParent->enablePackage( GetEntryData( nPos )->m_xPackage, true ); + else if (sCommand == "CMD_DISABLE") + m_pParent->enablePackage( GetEntryData( nPos )->m_xPackage, false ); + else if (sCommand == "CMD_UPDATE") + m_pParent->updatePackage( GetEntryData( nPos )->m_xPackage ); + else if (sCommand == "CMD_REMOVE") + m_pParent->removePackage( GetEntryData( nPos )->m_xPackage ); + else if (sCommand == "CMD_SHOW_LICENSE") + { + m_pParent->incBusy(); + ShowLicenseDialog aLicenseDlg(m_pParent->getDialog(), GetEntryData(nPos)->m_xPackage); + aLicenseDlg.run(); + m_pParent->decBusy(); + } + + return true; +} + +OUString ExtensionBoxWithButtons::ShowPopupMenu(const Point& rPos, const tools::Long nPos) +{ + if ( nPos >= static_cast<tools::Long>(getItemCount()) ) + return u"CMD_NONE"_ustr; + + std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(nullptr, u"desktop/ui/extensionmenu.ui"_ustr)); + std::unique_ptr<weld::Menu> xPopup(xBuilder->weld_menu(u"menu"_ustr)); + +#if ENABLE_EXTENSION_UPDATE + xPopup->append(u"CMD_UPDATE"_ustr, DpResId( RID_CTX_ITEM_CHECK_UPDATE ) ); +#endif + + if ( ! GetEntryData( nPos )->m_bLocked ) + { + if ( GetEntryData( nPos )->m_bUser ) + { + if ( GetEntryData( nPos )->m_eState == REGISTERED ) + xPopup->append(u"CMD_DISABLE"_ustr, DpResId(RID_CTX_ITEM_DISABLE)); + else if ( GetEntryData( nPos )->m_eState != NOT_AVAILABLE ) + xPopup->append(u"CMD_ENABLE"_ustr, DpResId(RID_CTX_ITEM_ENABLE)); + } + if (!officecfg::Office::ExtensionManager::ExtensionSecurity::DisableExtensionRemoval::get()) + { + xPopup->append(u"CMD_REMOVE"_ustr, DpResId(RID_CTX_ITEM_REMOVE)); + } + } + + if ( !GetEntryData( nPos )->m_sLicenseText.isEmpty() ) + xPopup->append(u"CMD_SHOW_LICENSE"_ustr, DpResId(RID_STR_SHOW_LICENSE_CMD)); + + return xPopup->popup_at_rect(GetDrawingArea(), tools::Rectangle(rPos, Size(1, 1))); +} + +bool ExtensionBoxWithButtons::MouseButtonDown(const MouseEvent& rMEvt) +{ + if (m_bInterfaceLocked) + return false; + return ExtensionBox::MouseButtonDown(rMEvt); +} + +void ExtensionBoxWithButtons::enableButtons(bool bEnable) +{ + m_bInterfaceLocked = ! bEnable; + + if ( bEnable ) + { + sal_Int32 nIndex = getSelIndex(); + if (nIndex != ExtensionBox::ENTRY_NOTFOUND) + SetButtonStatus( GetEntryData( nIndex ) ); + } + else + { + m_pParent->enableEnableButton( false ); + m_pParent->enableOptionsButton( false ); + m_pParent->enableRemoveButton( false ); + } +} + +} //namespace dp_gui + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/desktop/source/deployment/gui/dp_gui_extensionboxwithbuttons.hxx b/desktop/source/deployment/gui/dp_gui_extensionboxwithbuttons.hxx new file mode 100644 index 000000000000..f83aaed4b801 --- /dev/null +++ b/desktop/source/deployment/gui/dp_gui_extensionboxwithbuttons.hxx @@ -0,0 +1,56 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * 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 "dp_gui_extlistbox.hxx" + +#include <tools/gen.hxx> +#include <vcl/event.hxx> + +namespace dp_gui +{ +class ExtMgrDialog; + +class ExtensionBoxWithButtons : public ExtensionBox +{ + bool m_bInterfaceLocked; + + ExtMgrDialog* m_pParent; + + void SetButtonStatus(const TEntry_Impl& rEntry); + OUString ShowPopupMenu(const Point& rPos, const tools::Long nPos); + +public: + explicit ExtensionBoxWithButtons(std::unique_ptr<weld::ScrolledWindow> xScroll); + + void InitFromDialog(ExtMgrDialog* pParentDialog); + + virtual bool MouseButtonDown(const MouseEvent& rMEvt) override; + virtual bool Command(const CommandEvent& rCEvt) override; + + virtual void RecalcAll() override; + virtual void selectEntry(const tools::Long nPos) override; + + void enableButtons(bool bEnable); +}; + +} // namespace dp_gui + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/solenv/clang-format/excludelist b/solenv/clang-format/excludelist index dd5f3bcf64bd..fa5814104418 100644 --- a/solenv/clang-format/excludelist +++ b/solenv/clang-format/excludelist @@ -2932,6 +2932,7 @@ desktop/source/deployment/dp_xml.cxx desktop/source/deployment/gui/dp_gui.h desktop/source/deployment/gui/dp_gui_dialog2.cxx desktop/source/deployment/gui/dp_gui_dialog2.hxx +desktop/source/deployment/gui/dp_gui_extensionboxwithbuttons.cxx desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx desktop/source/deployment/gui/dp_gui_extensioncmdqueue.hxx desktop/source/deployment/gui/dp_gui_extlistbox.cxx commit 443166dcfbb6cba8e4c5a572409d40f7808ecec9 Author: Michael Weghorn <[email protected]> AuthorDate: Thu Oct 16 14:16:14 2025 +0200 Commit: Michael Weghorn <[email protected]> CommitDate: Fri Oct 17 12:13:36 2025 +0200 extension mgr: Rename ExtensionBox_Impl and subclass Rename ExtensionBox_Impl to ExtensionBox and ExtBoxWithBtns_Impl to ExtensionBoxWithButtons for clearer naming and more consistency. They're not impl classes for any other class. Change-Id: I059359bc7449d962b654638ed6f14132351ccfb3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/192507 Tested-by: Jenkins Reviewed-by: Michael Weghorn <[email protected]> diff --git a/desktop/source/deployment/gui/dp_gui_dialog2.cxx b/desktop/source/deployment/gui/dp_gui_dialog2.cxx index 5e4a0a4e1718..ae4d92ac09c7 100644 --- a/desktop/source/deployment/gui/dp_gui_dialog2.cxx +++ b/desktop/source/deployment/gui/dp_gui_dialog2.cxx @@ -77,8 +77,7 @@ constexpr OUStringLiteral USER_PACKAGE_MANAGER = u"user"; constexpr OUString SHARED_PACKAGE_MANAGER = u"shared"_ustr; constexpr OUStringLiteral BUNDLED_PACKAGE_MANAGER = u"bundled"; -// ExtBoxWithBtns_Impl -class ExtBoxWithBtns_Impl : public ExtensionBox_Impl +class ExtensionBoxWithButtons : public ExtensionBox { bool m_bInterfaceLocked; @@ -88,7 +87,7 @@ class ExtBoxWithBtns_Impl : public ExtensionBox_Impl OUString ShowPopupMenu( const Point &rPos, const tools::Long nPos ); public: - explicit ExtBoxWithBtns_Impl(std::unique_ptr<weld::ScrolledWindow> xScroll); + explicit ExtensionBoxWithButtons(std::unique_ptr<weld::ScrolledWindow> xScroll); void InitFromDialog(ExtMgrDialog *pParentDialog); @@ -101,25 +100,25 @@ public: void enableButtons( bool bEnable ); }; -ExtBoxWithBtns_Impl::ExtBoxWithBtns_Impl(std::unique_ptr<weld::ScrolledWindow> xScroll) - : ExtensionBox_Impl(std::move(xScroll)) +ExtensionBoxWithButtons::ExtensionBoxWithButtons(std::unique_ptr<weld::ScrolledWindow> xScroll) + : ExtensionBox(std::move(xScroll)) , m_bInterfaceLocked(false) , m_pParent(nullptr) { } -void ExtBoxWithBtns_Impl::InitFromDialog(ExtMgrDialog *pParentDialog) +void ExtensionBoxWithButtons::InitFromDialog(ExtMgrDialog* pParentDialog) { setExtensionManager(&pParentDialog->getExtensionManager()); m_pParent = pParentDialog; } -void ExtBoxWithBtns_Impl::RecalcAll() +void ExtensionBoxWithButtons::RecalcAll() { const sal_Int32 nActive = getSelIndex(); - if ( nActive != ExtensionBox_Impl::ENTRY_NOTFOUND ) + if (nActive != ExtensionBox::ENTRY_NOTFOUND) { SetButtonStatus( GetEntryData( nActive) ); } @@ -130,20 +129,20 @@ void ExtBoxWithBtns_Impl::RecalcAll() m_pParent->enableEnableButton( false ); } - ExtensionBox_Impl::RecalcAll(); + ExtensionBox::RecalcAll(); } //This function may be called with nPos < 0 -void ExtBoxWithBtns_Impl::selectEntry( const tools::Long nPos ) +void ExtensionBoxWithButtons::selectEntry(const tools::Long nPos) { if ( HasActive() && ( nPos == getSelIndex() ) ) return; - ExtensionBox_Impl::selectEntry( nPos ); + ExtensionBox::selectEntry(nPos); } -void ExtBoxWithBtns_Impl::SetButtonStatus(const TEntry_Impl& rEntry) +void ExtensionBoxWithButtons::SetButtonStatus(const TEntry_Impl& rEntry) { bool bShowOptionBtn = true; @@ -190,10 +189,10 @@ void ExtBoxWithBtns_Impl::SetButtonStatus(const TEntry_Impl& rEntry) } } -bool ExtBoxWithBtns_Impl::Command(const CommandEvent& rCEvt) +bool ExtensionBoxWithButtons::Command(const CommandEvent& rCEvt) { if (rCEvt.GetCommand() != CommandEventId::ContextMenu) - return ExtensionBox_Impl::Command(rCEvt); + return ExtensionBox::Command(rCEvt); const Point aMousePos(rCEvt.GetMousePosPixel()); const auto nPos = PointToPos(aMousePos); @@ -218,7 +217,7 @@ bool ExtBoxWithBtns_Impl::Command(const CommandEvent& rCEvt) return true; } -OUString ExtBoxWithBtns_Impl::ShowPopupMenu( const Point & rPos, const tools::Long nPos ) +OUString ExtensionBoxWithButtons::ShowPopupMenu(const Point& rPos, const tools::Long nPos) { if ( nPos >= static_cast<tools::Long>(getItemCount()) ) return u"CMD_NONE"_ustr; @@ -251,21 +250,21 @@ OUString ExtBoxWithBtns_Impl::ShowPopupMenu( const Point & rPos, const tools::Lo return xPopup->popup_at_rect(GetDrawingArea(), tools::Rectangle(rPos, Size(1, 1))); } -bool ExtBoxWithBtns_Impl::MouseButtonDown( const MouseEvent& rMEvt ) +bool ExtensionBoxWithButtons::MouseButtonDown(const MouseEvent& rMEvt) { if (m_bInterfaceLocked) return false; - return ExtensionBox_Impl::MouseButtonDown(rMEvt); + return ExtensionBox::MouseButtonDown(rMEvt); } -void ExtBoxWithBtns_Impl::enableButtons( bool bEnable ) +void ExtensionBoxWithButtons::enableButtons(bool bEnable) { m_bInterfaceLocked = ! bEnable; if ( bEnable ) { sal_Int32 nIndex = getSelIndex(); - if ( nIndex != ExtensionBox_Impl::ENTRY_NOTFOUND ) + if (nIndex != ExtensionBox::ENTRY_NOTFOUND) SetButtonStatus( GetEntryData( nIndex ) ); } else @@ -417,7 +416,8 @@ ExtMgrDialog::ExtMgrDialog(weld::Window* pParent, TheExtensionManager& rManager) , m_nProgress(0) , m_aIdle( "ExtMgrDialog m_aIdle TimeOutHdl" ) , m_rManager(rManager) - , m_xExtensionBox(new ExtBoxWithBtns_Impl(m_xBuilder->weld_scrolled_window(u"scroll"_ustr, true))) + , m_xExtensionBox( + new ExtensionBoxWithButtons(m_xBuilder->weld_scrolled_window(u"scroll"_ustr, true))) , m_xExtensionBoxWnd(new weld::CustomWeld(*m_xBuilder, u"extensions"_ustr, *m_xExtensionBox)) , m_xOptionsBtn(m_xBuilder->weld_button(u"optionsbtn"_ustr)) , m_xAddBtn(m_xBuilder->weld_button(u"addbtn"_ustr)) @@ -869,7 +869,7 @@ IMPL_LINK_NOARG(ExtMgrDialog, HandleOptionsBtn, weld::Button&, void) { const sal_Int32 nActive = m_xExtensionBox->getSelIndex(); - if ( nActive != ExtensionBox_Impl::ENTRY_NOTFOUND ) + if (nActive != ExtensionBox::ENTRY_NOTFOUND) { SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create(); @@ -898,7 +898,7 @@ IMPL_LINK_NOARG(ExtMgrDialog, HandleRemoveBtn, weld::Button&, void) { const sal_Int32 nActive = m_xExtensionBox->getSelIndex(); - if ( nActive != ExtensionBox_Impl::ENTRY_NOTFOUND ) + if (nActive != ExtensionBox::ENTRY_NOTFOUND) { TEntry_Impl pEntry = m_xExtensionBox->GetEntryData( nActive ); removePackage( pEntry->m_xPackage ); @@ -909,7 +909,7 @@ IMPL_LINK_NOARG(ExtMgrDialog, HandleEnableBtn, weld::Button&, void) { const sal_Int32 nActive = m_xExtensionBox->getSelIndex(); - if ( nActive != ExtensionBox_Impl::ENTRY_NOTFOUND ) + if (nActive != ExtensionBox::ENTRY_NOTFOUND) { TEntry_Impl pEntry = m_xExtensionBox->GetEntryData( nActive ); @@ -995,7 +995,7 @@ UpdateRequiredDialog::UpdateRequiredDialog(weld::Window *pParent, TheExtensionMa , m_nProgress(0) , m_aIdle( "UpdateRequiredDialog m_aIdle TimeOutHdl" ) , m_pManager(pManager) - , m_xExtensionBox(new ExtensionBox_Impl(m_xBuilder->weld_scrolled_window(u"scroll"_ustr, true))) + , m_xExtensionBox(new ExtensionBox(m_xBuilder->weld_scrolled_window(u"scroll"_ustr, true))) , m_xExtensionBoxWnd(new weld::CustomWeld(*m_xBuilder, u"extensions"_ustr, *m_xExtensionBox)) , m_xUpdateNeeded(m_xBuilder->weld_label(u"updatelabel"_ustr)) , m_xUpdateBtn(m_xBuilder->weld_button(u"ok"_ustr)) diff --git a/desktop/source/deployment/gui/dp_gui_dialog2.hxx b/desktop/source/deployment/gui/dp_gui_dialog2.hxx index 735263c46987..9f8af56a3adc 100644 --- a/desktop/source/deployment/gui/dp_gui_dialog2.hxx +++ b/desktop/source/deployment/gui/dp_gui_dialog2.hxx @@ -39,8 +39,8 @@ struct ImplSVEvent; namespace dp_gui { -class ExtBoxWithBtns_Impl; -class ExtensionBox_Impl; +class ExtensionBoxWithButtons; +class ExtensionBox; class TheExtensionManager; class DialogHelper @@ -101,7 +101,7 @@ class ExtMgrDialog : public weld::GenericDialogController css::uno::Reference< css::task::XAbortChannel > m_xAbortChannel; - std::unique_ptr<ExtBoxWithBtns_Impl> m_xExtensionBox; + std::unique_ptr<ExtensionBoxWithButtons> m_xExtensionBox; std::unique_ptr<weld::CustomWeld> m_xExtensionBoxWnd; std::unique_ptr<weld::Button> m_xOptionsBtn; std::unique_ptr<weld::Button> m_xAddBtn; @@ -189,7 +189,7 @@ class UpdateRequiredDialog : public weld::GenericDialogController css::uno::Reference< css::task::XAbortChannel > m_xAbortChannel; - std::unique_ptr<ExtensionBox_Impl> m_xExtensionBox; + std::unique_ptr<ExtensionBox> m_xExtensionBox; std::unique_ptr<weld::CustomWeld> m_xExtensionBoxWnd; std::unique_ptr<weld::Label> m_xUpdateNeeded; std::unique_ptr<weld::Button> m_xUpdateBtn; diff --git a/desktop/source/deployment/gui/dp_gui_extlistbox.cxx b/desktop/source/deployment/gui/dp_gui_extlistbox.cxx index 7c00d51a0e8b..1067e11898d7 100644 --- a/desktop/source/deployment/gui/dp_gui_extlistbox.cxx +++ b/desktop/source/deployment/gui/dp_gui_extlistbox.cxx @@ -178,8 +178,7 @@ ExtensionRemovedListener::~ExtensionRemovedListener() } -// ExtensionBox_Impl -ExtensionBox_Impl::ExtensionBox_Impl(std::unique_ptr<weld::ScrolledWindow> xScroll) +ExtensionBox::ExtensionBox(std::unique_ptr<weld::ScrolledWindow> xScroll) : m_bHasScrollBar( false ) , m_bNeedsRecalc( true ) , m_bInCheckMode( false ) @@ -198,9 +197,9 @@ ExtensionBox_Impl::ExtensionBox_Impl(std::unique_ptr<weld::ScrolledWindow> xScro { } -void ExtensionBox_Impl::Init() +void ExtensionBox::Init() { - m_xScrollBar->connect_vadjustment_value_changed( LINK( this, ExtensionBox_Impl, ScrollHdl ) ); + m_xScrollBar->connect_vadjustment_value_changed(LINK(this, ExtensionBox, ScrollHdl)); auto nIconHeight = 2*TOP_OFFSET + SMALL_ICON_SIZE; auto nTitleHeight = 2*TOP_OFFSET + GetTextHeight(); @@ -223,7 +222,7 @@ void ExtensionBox_Impl::Init() i18n::CollatorOptions::CollatorOptions_IGNORE_CASE); } -ExtensionBox_Impl::~ExtensionBox_Impl() +ExtensionBox::~ExtensionBox() { if ( ! m_bInDelete ) DeleteRemoved(); @@ -242,13 +241,13 @@ ExtensionBox_Impl::~ExtensionBox_Impl() m_oCollator.reset(); } -sal_Int32 ExtensionBox_Impl::getItemCount() const +sal_Int32 ExtensionBox::getItemCount() const { return static_cast< sal_Int32 >( m_vEntries.size() ); } -sal_Int32 ExtensionBox_Impl::getSelIndex() const +sal_Int32 ExtensionBox::getSelIndex() const { assert(m_nActive >= -1); return static_cast<sal_Int32>(m_nActive); @@ -256,7 +255,7 @@ sal_Int32 ExtensionBox_Impl::getSelIndex() const // Title + description -void ExtensionBox_Impl::CalcActiveHeight( const tools::Long nPos ) +void ExtensionBox::CalcActiveHeight(const tools::Long nPos) { const ::osl::MutexGuard aGuard( m_entriesMutex ); @@ -293,7 +292,7 @@ void ExtensionBox_Impl::CalcActiveHeight( const tools::Long nPos ) m_nActiveHeight += 2; } -tools::Rectangle ExtensionBox_Impl::GetEntryRect( const tools::Long nPos ) const +tools::Rectangle ExtensionBox::GetEntryRect(const tools::Long nPos) const { const ::osl::MutexGuard aGuard( m_entriesMutex ); @@ -311,8 +310,7 @@ tools::Rectangle ExtensionBox_Impl::GetEntryRect( const tools::Long nPos ) const return tools::Rectangle( aPos, aSize ); } - -void ExtensionBox_Impl::DeleteRemoved() +void ExtensionBox::DeleteRemoved() { const ::osl::MutexGuard aGuard( m_entriesMutex ); @@ -325,7 +323,7 @@ void ExtensionBox_Impl::DeleteRemoved() //This function may be called with nPos < 0 -void ExtensionBox_Impl::selectEntry( const tools::Long nPos ) +void ExtensionBox::selectEntry(const tools::Long nPos) { bool invalidate = false; { @@ -333,7 +331,7 @@ void ExtensionBox_Impl::selectEntry( const tools::Long nPos ) //Currently it is used to guard m_vEntries and m_nActive. m_nActive will be //modified in this function. //It would be probably best to always use a copy of m_vEntries - //and some other state variables from ExtensionBox_Impl for + //and some other state variables from ExtensionBox for //the whole painting operation. See issue i86993 ::osl::MutexGuard guard(m_entriesMutex); @@ -374,8 +372,8 @@ void ExtensionBox_Impl::selectEntry( const tools::Long nPos ) } } - -void ExtensionBox_Impl::DrawRow(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect, const TEntry_Impl& rEntry) +void ExtensionBox::DrawRow(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect, + const TEntry_Impl& rEntry) { const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings(); @@ -528,8 +526,7 @@ void ExtensionBox_Impl::DrawRow(vcl::RenderContext& rRenderContext, const tools: rRenderContext.DrawLine(rRect.BottomLeft(), rRect.BottomRight()); } - -void ExtensionBox_Impl::RecalcAll() +void ExtensionBox::RecalcAll() { if (m_nActive >= 0) CalcActiveHeight( m_nActive ); @@ -579,8 +576,7 @@ void ExtensionBox_Impl::RecalcAll() m_bNeedsRecalc = false; } - -bool ExtensionBox_Impl::HandleCursorKey( sal_uInt16 nKeyCode ) +bool ExtensionBox::HandleCursorKey(sal_uInt16 nKeyCode) { if ( m_vEntries.empty() ) return true; @@ -624,8 +620,7 @@ bool ExtensionBox_Impl::HandleCursorKey( sal_uInt16 nKeyCode ) return true; } - -void ExtensionBox_Impl::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& /*rPaintRect*/) +void ExtensionBox::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& /*rPaintRect*/) { if ( !m_bInDelete ) DeleteRemoved(); @@ -647,8 +642,7 @@ void ExtensionBox_Impl::Paint(vcl::RenderContext& rRenderContext, const tools::R } } - -tools::Long ExtensionBox_Impl::GetTotalHeight() const +tools::Long ExtensionBox::GetTotalHeight() const { tools::Long nHeight = m_vEntries.size() * m_nStdHeight; @@ -660,8 +654,7 @@ tools::Long ExtensionBox_Impl::GetTotalHeight() const return nHeight; } - -void ExtensionBox_Impl::SetupScrollBar() +void ExtensionBox::SetupScrollBar() { const Size aSize = GetOutputSizePixel(); const auto nTotalHeight = GetTotalHeight(); @@ -687,14 +680,13 @@ void ExtensionBox_Impl::SetupScrollBar() m_bHasScrollBar = bNeedsScrollBar; } - -void ExtensionBox_Impl::Resize() +void ExtensionBox::Resize() { RecalcAll(); Invalidate(); } -void ExtensionBox_Impl::SetDrawingArea(weld::DrawingArea* pDrawingArea) +void ExtensionBox::SetDrawingArea(weld::DrawingArea* pDrawingArea) { Size aSize = pDrawingArea->get_ref_device().LogicToPixel(Size(250, 150), MapMode(MapUnit::MapAppFont)); pDrawingArea->set_size_request(aSize.Width(), aSize.Height()); @@ -704,7 +696,7 @@ void ExtensionBox_Impl::SetDrawingArea(weld::DrawingArea* pDrawingArea) Init(); } -tools::Long ExtensionBox_Impl::PointToPos( const Point& rPos ) +tools::Long ExtensionBox::PointToPos(const Point& rPos) { tools::Long nPos = ( rPos.Y() + m_nTopIndex ) / m_nStdHeight; @@ -719,7 +711,7 @@ tools::Long ExtensionBox_Impl::PointToPos( const Point& rPos ) return nPos; } -bool ExtensionBox_Impl::MouseMove( const MouseEvent& rMEvt ) +bool ExtensionBox::MouseMove(const MouseEvent& rMEvt) { bool bOverHyperlink = false; @@ -738,7 +730,7 @@ bool ExtensionBox_Impl::MouseMove( const MouseEvent& rMEvt ) return false; } -OUString ExtensionBox_Impl::RequestHelp(tools::Rectangle& rRect) +OUString ExtensionBox::RequestHelp(tools::Rectangle& rRect) { auto nPos = PointToPos( rRect.TopLeft() ); if ( ( nPos >= 0 ) && ( o3tl::make_unsigned(nPos) < m_vEntries.size() ) ) @@ -755,13 +747,13 @@ OUString ExtensionBox_Impl::RequestHelp(tools::Rectangle& rRect) return OUString(); } -bool ExtensionBox_Impl::MouseButtonDown( const MouseEvent& rMEvt ) +bool ExtensionBox::MouseButtonDown(const MouseEvent& rMEvt) { if ( !rMEvt.IsLeft() ) return false; if (rMEvt.IsMod1() && m_nActive >= 0) - selectEntry(ExtensionBox_Impl::ENTRY_NOTFOUND); // Selecting a not existing entry will deselect the current one + selectEntry(ExtensionBox::ENTRY_NOTFOUND); // Selecting a not existing entry will deselect the current one else { auto nPos = PointToPos( rMEvt.GetPosPixel() ); @@ -790,7 +782,7 @@ bool ExtensionBox_Impl::MouseButtonDown( const MouseEvent& rMEvt ) return true; } -bool ExtensionBox_Impl::KeyInput(const KeyEvent& rKEvt) +bool ExtensionBox::KeyInput(const KeyEvent& rKEvt) { if ( !m_bInDelete ) DeleteRemoved(); @@ -805,8 +797,8 @@ bool ExtensionBox_Impl::KeyInput(const KeyEvent& rKEvt) return bHandled; } -bool ExtensionBox_Impl::FindEntryPos( const TEntry_Impl& rEntry, const tools::Long nStart, - const tools::Long nEnd, tools::Long &nPos ) +bool ExtensionBox::FindEntryPos(const TEntry_Impl& rEntry, const tools::Long nStart, + const tools::Long nEnd, tools::Long& nPos) { nPos = nStart; if ( nStart > nEnd ) @@ -856,7 +848,7 @@ bool ExtensionBox_Impl::FindEntryPos( const TEntry_Impl& rEntry, const tools::Lo } } -void ExtensionBox_Impl::cleanVecListenerAdded() +void ExtensionBox::cleanVecListenerAdded() { std::erase_if(m_vListenerAdded, [](const uno::WeakReference<deployment::XPackage>& rxListener) { @@ -865,8 +857,7 @@ void ExtensionBox_Impl::cleanVecListenerAdded() }); } -void ExtensionBox_Impl::addEventListenerOnce( - uno::Reference<deployment::XPackage > const & extension) +void ExtensionBox::addEventListenerOnce(uno::Reference<deployment::XPackage> const& extension) { //make sure to only add the listener once cleanVecListenerAdded(); @@ -878,9 +869,8 @@ void ExtensionBox_Impl::addEventListenerOnce( } } - -void ExtensionBox_Impl::addEntry( const uno::Reference< deployment::XPackage > &xPackage, - bool bLicenseMissing ) +void ExtensionBox::addEntry(const uno::Reference<deployment::XPackage>& xPackage, + bool bLicenseMissing) { PackageState eState = TheExtensionManager::getPackageState( xPackage ); bool bLocked = m_pManager->isReadOnly( xPackage ); @@ -908,7 +898,7 @@ void ExtensionBox_Impl::addEntry( const uno::Reference< deployment::XPackage > & } else if (!m_bInCheckMode) { - OSL_FAIL("ExtensionBox_Impl::addEntry(): Will not add duplicate entries"); + OSL_FAIL("ExtensionBox::addEntry(): Will not add duplicate entries"); } } @@ -932,7 +922,7 @@ void ExtensionBox_Impl::addEntry( const uno::Reference< deployment::XPackage > & m_bNeedsRecalc = true; } -void ExtensionBox_Impl::updateEntry( const uno::Reference< deployment::XPackage > &xPackage ) +void ExtensionBox::updateEntry(const uno::Reference<deployment::XPackage>& xPackage) { for (auto const& entry : m_vEntries) { @@ -965,7 +955,7 @@ void ExtensionBox_Impl::updateEntry( const uno::Reference< deployment::XPackage //The gui is a registered as listener on the package. Removing it will cause the //listeners to be notified and then this function is called. At this moment xPackage //is in the disposing state and all calls on it may result in a DisposedException. -void ExtensionBox_Impl::removeEntry( const uno::Reference< deployment::XPackage > &xPackage ) +void ExtensionBox::removeEntry(const uno::Reference<deployment::XPackage>& xPackage) { if ( m_bInDelete ) return; @@ -1017,8 +1007,7 @@ void ExtensionBox_Impl::removeEntry( const uno::Reference< deployment::XPackage } } - -void ExtensionBox_Impl::RemoveUnlocked() +void ExtensionBox::RemoveUnlocked() { bool bAllRemoved = false; @@ -1042,8 +1031,7 @@ void ExtensionBox_Impl::RemoveUnlocked() } } - -void ExtensionBox_Impl::prepareChecking() +void ExtensionBox::prepareChecking() { m_bInCheckMode = true; for (auto const& entry : m_vEntries) @@ -1053,8 +1041,7 @@ void ExtensionBox_Impl::prepareChecking() } } - -void ExtensionBox_Impl::checkEntries() +void ExtensionBox::checkEntries() { tools::Long nNewPos = -1; tools::Long nChangedActivePos = -1; @@ -1122,7 +1109,7 @@ void ExtensionBox_Impl::checkEntries() } } -IMPL_LINK(ExtensionBox_Impl, ScrollHdl, weld::ScrolledWindow&, rScrBar, void) +IMPL_LINK(ExtensionBox, ScrollHdl, weld::ScrolledWindow&, rScrBar, void) { m_nTopIndex = rScrBar.vadjustment_get_value(); Invalidate(); diff --git a/desktop/source/deployment/gui/dp_gui_extlistbox.hxx b/desktop/source/deployment/gui/dp_gui_extlistbox.hxx index 39d7e7619b8c..4f10acf8231e 100644 --- a/desktop/source/deployment/gui/dp_gui_extlistbox.hxx +++ b/desktop/source/deployment/gui/dp_gui_extlistbox.hxx @@ -84,16 +84,14 @@ struct Entry_Impl typedef std::shared_ptr<Entry_Impl> TEntry_Impl; -class ExtensionBox_Impl; - +class ExtensionBox; class ExtensionRemovedListener : public ::cppu::WeakImplHelper<css::lang::XEventListener> { - ExtensionBox_Impl* m_pParent; + ExtensionBox* m_pParent; public: - - explicit ExtensionRemovedListener( ExtensionBox_Impl *pParent ) { m_pParent = pParent; } + explicit ExtensionRemovedListener(ExtensionBox* pParent) { m_pParent = pParent; } virtual ~ExtensionRemovedListener() override; @@ -101,7 +99,7 @@ public: virtual void SAL_CALL disposing(css::lang::EventObject const& evt) override; }; -class ExtensionBox_Impl : public weld::CustomWidgetController +class ExtensionBox : public weld::CustomWidgetController { bool m_bHasScrollBar : 1; bool m_bNeedsRecalc : 1; @@ -157,8 +155,8 @@ class ExtensionBox_Impl : public weld::CustomWidgetController void Init(); public: - explicit ExtensionBox_Impl(std::unique_ptr<weld::ScrolledWindow> xScroll); - virtual ~ExtensionBox_Impl() override; + explicit ExtensionBox(std::unique_ptr<weld::ScrolledWindow> xScroll); + virtual ~ExtensionBox() override; virtual bool MouseButtonDown( const MouseEvent& rMEvt ) override; virtual bool MouseMove( const MouseEvent& rMEvt ) override; commit 8eae306828e06d15a8349e2a0051fd1f6256deda Author: Michael Weghorn <[email protected]> AuthorDate: Thu Oct 16 13:31:18 2025 +0200 Commit: Michael Weghorn <[email protected]> CommitDate: Fri Oct 17 12:13:29 2025 +0200 extension mgr: Switch ExtMgrDialog::m_pManager to ref ... and rename to ExtMgrDialog::m_rManager accordingly. This makes more obvious that it's always non-null. Change-Id: I11686deaff89e106ff1cc38fb986ab97afba7146 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/192497 Tested-by: Jenkins Reviewed-by: Michael Weghorn <[email protected]> diff --git a/desktop/source/deployment/gui/dp_gui_dialog2.cxx b/desktop/source/deployment/gui/dp_gui_dialog2.cxx index e2a1b6693a21..5e4a0a4e1718 100644 --- a/desktop/source/deployment/gui/dp_gui_dialog2.cxx +++ b/desktop/source/deployment/gui/dp_gui_dialog2.cxx @@ -110,7 +110,7 @@ ExtBoxWithBtns_Impl::ExtBoxWithBtns_Impl(std::unique_ptr<weld::ScrolledWindow> x void ExtBoxWithBtns_Impl::InitFromDialog(ExtMgrDialog *pParentDialog) { - setExtensionManager(pParentDialog->getExtensionManager()); + setExtensionManager(&pParentDialog->getExtensionManager()); m_pParent = pParentDialog; } @@ -402,9 +402,10 @@ void DialogHelper::PostUserEvent( const Link<void*,void>& rLink, void* pCaller ) } // ExtMgrDialog -ExtMgrDialog::ExtMgrDialog(weld::Window *pParent, TheExtensionManager *pManager) - : GenericDialogController(pParent, u"desktop/ui/extensionmanager.ui"_ustr, u"ExtensionManagerDialog"_ustr) - , DialogHelper(pManager->getContext(), m_xDialog.get()) +ExtMgrDialog::ExtMgrDialog(weld::Window* pParent, TheExtensionManager& rManager) + : GenericDialogController(pParent, u"desktop/ui/extensionmanager.ui"_ustr, + u"ExtensionManagerDialog"_ustr) + , DialogHelper(rManager.getContext(), m_xDialog.get()) , m_bHasProgress(false) , m_bProgressChanged(false) , m_bStartProgress(false) @@ -415,7 +416,7 @@ ExtMgrDialog::ExtMgrDialog(weld::Window *pParent, TheExtensionManager *pManager) , m_bClosed(false) , m_nProgress(0) , m_aIdle( "ExtMgrDialog m_aIdle TimeOutHdl" ) - , m_pManager(pManager) + , m_rManager(rManager) , m_xExtensionBox(new ExtBoxWithBtns_Impl(m_xBuilder->weld_scrolled_window(u"scroll"_ustr, true))) , m_xExtensionBoxWnd(new weld::CustomWeld(*m_xBuilder, u"extensions"_ustr, *m_xExtensionBox)) , m_xOptionsBtn(m_xBuilder->weld_button(u"optionsbtn"_ustr)) @@ -525,7 +526,7 @@ void ExtMgrDialog::updateList() { // re-creates the list of packages with addEntry selecting the packages prepareChecking(); - m_pManager->createPackageList(); + m_rManager.createPackageList(); checkEntries(); } @@ -578,7 +579,7 @@ void ExtMgrDialog::enablePackage( const uno::Reference< deployment::XPackage > & return; } - m_pManager->getCmdQueue()->enableExtension( xPackage, bEnable ); + m_rManager.getCmdQueue()->enableExtension(xPackage, bEnable); } @@ -597,7 +598,7 @@ void ExtMgrDialog::removePackage( const uno::Reference< deployment::XPackage > & m_bDeleteWarning)) return; - m_pManager->getCmdQueue()->removeExtension( xPackage ); + m_rManager.getCmdQueue()->removeExtension(xPackage); } @@ -607,15 +608,16 @@ void ExtMgrDialog::updatePackage( const uno::Reference< deployment::XPackage > & return; // get the extension with highest version - uno::Sequence<uno::Reference<deployment::XPackage> > seqExtensions = - m_pManager->getExtensionManager()->getExtensionsWithSameIdentifier( - dp_misc::getIdentifier(xPackage), xPackage->getName(), uno::Reference<ucb::XCommandEnvironment>()); + uno::Sequence<uno::Reference<deployment::XPackage>> seqExtensions + = m_rManager.getExtensionManager()->getExtensionsWithSameIdentifier( + dp_misc::getIdentifier(xPackage), xPackage->getName(), + uno::Reference<ucb::XCommandEnvironment>()); uno::Reference<deployment::XPackage> extension = dp_misc::getExtensionWithHighestVersion(seqExtensions); OSL_ASSERT(extension.is()); std::vector< css::uno::Reference< css::deployment::XPackage > > vEntries { extension }; - m_pManager->getCmdQueue()->checkForUpdates( std::move(vEntries) ); + m_rManager.getCmdQueue()->checkForUpdates(std::move(vEntries)); } @@ -624,7 +626,7 @@ bool ExtMgrDialog::acceptLicense( const uno::Reference< deployment::XPackage > & if ( !xPackage.is() ) return false; - m_pManager->getCmdQueue()->acceptLicense( xPackage ); + m_rManager.getCmdQueue()->acceptLicense(xPackage); return true; } @@ -641,8 +643,8 @@ uno::Sequence< OUString > ExtMgrDialog::raiseAddPicker() t_string2string title2filter; OUStringBuffer supportedFilters; - const uno::Sequence< uno::Reference< deployment::XPackageTypeInfo > > packageTypes( - m_pManager->getExtensionManager()->getSupportedPackageTypes() ); + const uno::Sequence<uno::Reference<deployment::XPackageTypeInfo>> packageTypes( + m_rManager.getExtensionManager()->getSupportedPackageTypes()); for ( uno::Reference< deployment::XPackageTypeInfo > const & xPackageType : packageTypes ) { @@ -753,9 +755,9 @@ IMPL_LINK_NOARG(ExtMgrDialog, HandleCloseBtn, weld::Button&, void) bool bCallClose = true; //only suggest restart if modified and this is the first close attempt - if (!m_bClosed && m_pManager->isModified()) + if (!m_bClosed && m_rManager.isModified()) { - m_pManager->clearModified(); + m_rManager.clearModified(); //only suggest restart if we're actually running, e.g. not from standalone unopkg gui if (dp_misc::office_is_running()) @@ -886,7 +888,7 @@ IMPL_LINK_NOARG(ExtMgrDialog, HandleAddBtn, weld::Button&, void) if ( aFileList.hasElements() ) { - m_pManager->installPackage( aFileList[0] ); + m_rManager.installPackage(aFileList[0]); } decBusy(); @@ -934,7 +936,7 @@ IMPL_LINK_NOARG(ExtMgrDialog, HandleSearch, weld::Entry&, void) IMPL_LINK_NOARG(ExtMgrDialog, HandleUpdateBtn, weld::Button&, void) { #if ENABLE_EXTENSION_UPDATE - m_pManager->checkUpdates(); + m_rManager.checkUpdates(); #else (void) this; #endif @@ -976,7 +978,7 @@ IMPL_LINK_NOARG(ExtMgrDialog, TimeOutHdl, Timer *, void) void ExtMgrDialog::Close() { - m_pManager->terminateDialog(); + m_rManager.terminateDialog(); m_bClosed = true; } diff --git a/desktop/source/deployment/gui/dp_gui_dialog2.hxx b/desktop/source/deployment/gui/dp_gui_dialog2.hxx index 38996444f2a5..735263c46987 100644 --- a/desktop/source/deployment/gui/dp_gui_dialog2.hxx +++ b/desktop/source/deployment/gui/dp_gui_dialog2.hxx @@ -97,7 +97,7 @@ class ExtMgrDialog : public weld::GenericDialogController bool m_bClosed; sal_Int32 m_nProgress; Idle m_aIdle; - TheExtensionManager *m_pManager; + TheExtensionManager& m_rManager; css::uno::Reference< css::task::XAbortChannel > m_xAbortChannel; @@ -133,7 +133,7 @@ class ExtMgrDialog : public weld::GenericDialogController DECL_LINK( startProgress, void *, void ); public: - ExtMgrDialog(weld::Window * pParent, TheExtensionManager *pManager); + ExtMgrDialog(weld::Window* pParent, TheExtensionManager& rManager); virtual ~ExtMgrDialog() override; virtual void showProgress( bool bStart ) override; @@ -154,7 +154,7 @@ public: void Close(); - TheExtensionManager* getExtensionManager() const { return m_pManager; } + TheExtensionManager& getExtensionManager() const { return m_rManager; } void updateList(); virtual void prepareChecking() override; diff --git a/desktop/source/deployment/gui/dp_gui_theextmgr.cxx b/desktop/source/deployment/gui/dp_gui_theextmgr.cxx index f2f5dd9c27f8..7b68b1d34320 100644 --- a/desktop/source/deployment/gui/dp_gui_theextmgr.cxx +++ b/desktop/source/deployment/gui/dp_gui_theextmgr.cxx @@ -133,7 +133,8 @@ void TheExtensionManager::createDialog( const bool bCreateUpdDlg ) } else if ( !m_xExtMgrDialog ) { - m_xExtMgrDialog = std::make_shared<ExtMgrDialog>(Application::GetFrameWeld(m_xParent), this); + m_xExtMgrDialog + = std::make_shared<ExtMgrDialog>(Application::GetFrameWeld(m_xParent), *this); m_xExecuteCmdQueue.reset(new ExtensionCmdQueue(*m_xExtMgrDialog, *this, m_xContext)); m_xExtMgrDialog->setGetExtensionsURL( m_sGetExtensionsURL ); createPackageList();
