desktop/source/deployment/gui/dp_gui_dialog2.cxx           |   38 ++++++-------
 desktop/source/deployment/gui/dp_gui_dialog2.hxx           |   16 ++---
 desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx |   10 +--
 desktop/source/deployment/gui/dp_gui_service.cxx           |   27 +++------
 desktop/source/deployment/gui/dp_gui_theextmgr.cxx         |   12 +---
 desktop/source/deployment/gui/dp_gui_theextmgr.hxx         |    8 +-
 6 files changed, 47 insertions(+), 64 deletions(-)

New commits:
commit cb6ee2b60f8c21d0464f5bcd9c158a85724aa80d
Author:     Michael Weghorn <[email protected]>
AuthorDate: Fri Nov 7 16:29:31 2025 +0100
Commit:     Michael Weghorn <[email protected]>
CommitDate: Mon Nov 10 23:11:09 2025 +0100

    tdf#169318 extension mgr: Move pkg installation out of 
TheExtensionManager::get
    
    ServiceImpl::startExecuteModal is the only place calling
    TheExtensionManager::get with a non-empty extensionURL
    param.
    
    Drop the param and logic from TheExtensionManager::get
    and instead call TheExtensionManager::installPackage
    directly from ServiceImpl::startExecuteModal, which
    also prevents implicitly creating a dialog already
    in the call to TheExtensionManager::get.
    
    No change in behavior intended or seen in a quick test
    with these 2 use cases:
    
    * start LO Start Center, drag and drop an oxt file into it
      to open the extension manager dialog to install the extension
    
    * trigger using unopkg via command line:
      `./instdir/program/unopkg gui /path/to/some/extension.oxt`
    
    Change-Id: Iee3cae68edd7c4a94f4a5261c4473ece0d4c5378
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/193588
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <[email protected]>

diff --git a/desktop/source/deployment/gui/dp_gui_service.cxx 
b/desktop/source/deployment/gui/dp_gui_service.cxx
index 8a4f6390f189..b36c35c78ceb 100644
--- a/desktop/source/deployment/gui/dp_gui_service.cxx
+++ b/desktop/source/deployment/gui/dp_gui_service.cxx
@@ -236,11 +236,11 @@ void ServiceImpl::startExecuteModal(
 
     {
         const SolarMutexGuard guard;
-        ::rtl::Reference< ::dp_gui::TheExtensionManager > myExtMgr(
-            ::dp_gui::TheExtensionManager::get(
-                m_xComponentContext,
-                m_parent ? *m_parent : Reference<awt::XWindow>(),
-                m_extensionURL ? *m_extensionURL : OUString() ) );
+        rtl::Reference<::dp_gui::TheExtensionManager> 
myExtMgr(::dp_gui::TheExtensionManager::get(
+            m_xComponentContext, m_parent ? *m_parent : 
Reference<awt::XWindow>()));
+        if (m_extensionURL)
+            myExtMgr->installPackage(*m_extensionURL, true);
+
         myExtMgr->createDialog( false );
         if (!m_sTitle.isEmpty()) {
             myExtMgr->SetText(m_sTitle);
diff --git a/desktop/source/deployment/gui/dp_gui_theextmgr.cxx 
b/desktop/source/deployment/gui/dp_gui_theextmgr.cxx
index 577ad889d018..84e003ade12a 100644
--- a/desktop/source/deployment/gui/dp_gui_theextmgr.cxx
+++ b/desktop/source/deployment/gui/dp_gui_theextmgr.cxx
@@ -465,16 +465,13 @@ void TheExtensionManager::modified( ::lang::EventObject 
const & /*rEvt*/ )
     pDialogHelper->checkEntries();
 }
 
-
-::rtl::Reference< TheExtensionManager > TheExtensionManager::get( const 
uno::Reference< uno::XComponentContext > &xContext,
-                                                                  const 
uno::Reference< awt::XWindow > &xParent,
-                                                                  const 
OUString & extensionURL )
+::rtl::Reference<TheExtensionManager>
+TheExtensionManager::get(const uno::Reference<uno::XComponentContext>& 
xContext,
+                         const uno::Reference<awt::XWindow>& xParent)
 {
     if ( s_ExtMgr.is() )
     {
         OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();
-        if ( !extensionURL.isEmpty() )
-            s_ExtMgr->installPackage( extensionURL, true );
         return s_ExtMgr;
     }
 
@@ -487,9 +484,6 @@ void TheExtensionManager::modified( ::lang::EventObject 
const & /*rEvt*/ )
         s_ExtMgr = std::move(that);
     }
 
-    if ( !extensionURL.isEmpty() )
-        s_ExtMgr->installPackage( extensionURL, true );
-
     return s_ExtMgr;
 }
 
diff --git a/desktop/source/deployment/gui/dp_gui_theextmgr.hxx 
b/desktop/source/deployment/gui/dp_gui_theextmgr.hxx
index 13c329d6d142..58aab0112076 100644
--- a/desktop/source/deployment/gui/dp_gui_theextmgr.hxx
+++ b/desktop/source/deployment/gui/dp_gui_theextmgr.hxx
@@ -105,11 +105,9 @@ public:
     const css::uno::Reference< css::deployment::XExtensionManager >& 
getExtensionManager() const { return m_xExtensionManager; }
     bool isReadOnly( const css::uno::Reference< css::deployment::XPackage > 
&xPackage ) const;
 
-
-    static ::rtl::Reference<TheExtensionManager> get(
-        css::uno::Reference< css::uno::XComponentContext> const & xContext,
-        css::uno::Reference< css::awt::XWindow> const & xParent = nullptr,
-        OUString const & view = OUString() );
+    static ::rtl::Reference<TheExtensionManager>
+    get(css::uno::Reference<css::uno::XComponentContext> const& xContext,
+        css::uno::Reference<css::awt::XWindow> const& xParent = nullptr);
 
     // XEventListener
     virtual void SAL_CALL disposing( css::lang::EventObject const & evt ) 
override;
commit ddf118a3a5d510bf078a8da08e656514c6c0a14f
Author:     Michael Weghorn <[email protected]>
AuthorDate: Fri Nov 7 15:32:01 2025 +0100
Commit:     Michael Weghorn <[email protected]>
CommitDate: Mon Nov 10 23:11:02 2025 +0100

    tdf#169318 extension mgr: Don't do too much when setting dlg title
    
    In ServiceImpl::setDialogTitle, always remember the
    explicitly set title and apply it in ServiceImpl::startExecuteModal
    if non-empty (and keep remembering it), not only
    when the dp_gui::TheExtensionManager::s_ExtMgr isn't set
    yet.
    
    Don't call TheExtensionManager::get (yet) which could
    trigger more logic that seems more reasonable to do
    later, when the dialog is actually run.
    Simply skip setting the title at this point otherwise,
    as it will be set in ServiceImpl::startExecuteModal
    before the dialog gets shown anyway.
    
    Change-Id: Id51627de09a5713996076eb0ca599cc361c54dd6
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/193587
    Reviewed-by: Michael Weghorn <[email protected]>
    Tested-by: Jenkins

diff --git a/desktop/source/deployment/gui/dp_gui_service.cxx 
b/desktop/source/deployment/gui/dp_gui_service.cxx
index 23733bd349aa..8a4f6390f189 100644
--- a/desktop/source/deployment/gui/dp_gui_service.cxx
+++ b/desktop/source/deployment/gui/dp_gui_service.cxx
@@ -112,7 +112,7 @@ class ServiceImpl
     Reference<XComponentContext> const m_xComponentContext;
     std::optional< Reference<awt::XWindow> > /* const */ m_parent;
     std::optional<OUString> m_extensionURL;
-    OUString m_initialTitle;
+    OUString m_sTitle;
     bool m_bShowUpdateOnly;
 
 public:
@@ -178,17 +178,13 @@ css::uno::Sequence< OUString > 
ServiceImpl::getSupportedServiceNames()
 
 void ServiceImpl::setDialogTitle( OUString const & title )
 {
+    m_sTitle = title;
     if ( dp_gui::TheExtensionManager::s_ExtMgr.is() )
     {
         const SolarMutexGuard guard;
-        ::rtl::Reference< ::dp_gui::TheExtensionManager > dialog(
-            ::dp_gui::TheExtensionManager::get( m_xComponentContext,
-                                                m_parent ? *m_parent : 
Reference<awt::XWindow>(),
-                                                m_extensionURL ? 
*m_extensionURL : OUString() ) );
-        dialog->SetText( title );
+        if (weld::Window* pDialog = 
dp_gui::TheExtensionManager::s_ExtMgr->getDialog())
+            pDialog->set_title(title);
     }
-    else
-        m_initialTitle = title;
 }
 
 
@@ -246,9 +242,8 @@ void ServiceImpl::startExecuteModal(
                 m_parent ? *m_parent : Reference<awt::XWindow>(),
                 m_extensionURL ? *m_extensionURL : OUString() ) );
         myExtMgr->createDialog( false );
-        if (!m_initialTitle.isEmpty()) {
-            myExtMgr->SetText( m_initialTitle );
-            m_initialTitle.clear();
+        if (!m_sTitle.isEmpty()) {
+            myExtMgr->SetText(m_sTitle);
         }
         if ( m_bShowUpdateOnly )
         {
commit 6e6c1388c063183dce0270e178daab53a3079238
Author:     Michael Weghorn <[email protected]>
AuthorDate: Fri Nov 7 15:00:11 2025 +0100
Commit:     Michael Weghorn <[email protected]>
CommitDate: Mon Nov 10 23:10:56 2025 +0100

    tdf#169318 extension mgr: Let DialogHelper subclass GenericDialogController
    
    So far, both of the DialogHelper subclasses were also
    subclassing weld::GenericDialogController.
    
    Instead, let DialogHelper itself subclass
    weld::GenericDialogController, which allows
    simplifying/deduplicating the code a bit.
    
    Change-Id: I289104dcef35b31e546da412f47b10fc14524e83
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/193586
    Reviewed-by: Michael Weghorn <[email protected]>
    Tested-by: Jenkins

diff --git a/desktop/source/deployment/gui/dp_gui_dialog2.cxx 
b/desktop/source/deployment/gui/dp_gui_dialog2.cxx
index a31e33d7822e..80accda30d98 100644
--- a/desktop/source/deployment/gui/dp_gui_dialog2.cxx
+++ b/desktop/source/deployment/gui/dp_gui_dialog2.cxx
@@ -80,9 +80,10 @@ constexpr OUStringLiteral BUNDLED_PACKAGE_MANAGER = 
u"bundled";
 
 //                             DialogHelper
 
-DialogHelper::DialogHelper(const uno::Reference< uno::XComponentContext > 
&xContext,
-                           weld::Dialog* pDialog)
-    : m_pDialog(pDialog)
+DialogHelper::DialogHelper(weld::Widget* pParent, const OUString& rUIFile,
+                           const OUString& rDialogId,
+                           const uno::Reference<uno::XComponentContext>& 
xContext)
+    : weld::GenericDialogController(pParent, rUIFile, rDialogId)
     , m_nEventID(nullptr)
 {
     m_xContext = xContext;
@@ -108,7 +109,7 @@ bool DialogHelper::continueOnSharedExtension(const 
uno::Reference<deployment::XP
         const SolarMutexGuard guard;
         incBusy();
         std::unique_ptr<weld::MessageDialog> 
xBox(Application::CreateMessageDialog(
-            m_pDialog, VclMessageType::Warning, VclButtonsType::OkCancel, 
DpResId(pResID)));
+            m_xDialog.get(), VclMessageType::Warning, 
VclButtonsType::OkCancel, DpResId(pResID)));
         bHadWarning = true;
 
         bool bRet = RET_OK == xBox->run();
@@ -138,8 +139,8 @@ void DialogHelper::openWebBrowser(const OUString& sURL, 
const OUString& sTitle)
         OUString msg( ::comphelper::anyToString( exc ) );
         const SolarMutexGuard guard;
         incBusy();
-        std::unique_ptr<weld::MessageDialog> 
xErrorBox(Application::CreateMessageDialog(getFrameWeld(),
-                                                       
VclMessageType::Warning, VclButtonsType::Ok, msg));
+        std::unique_ptr<weld::MessageDialog> 
xErrorBox(Application::CreateMessageDialog(
+            getDialog(), VclMessageType::Warning, VclButtonsType::Ok, msg));
         xErrorBox->set_title(sTitle);
         xErrorBox->run();
         xErrorBox.reset();
@@ -155,9 +156,9 @@ bool DialogHelper::installExtensionWarn(std::u16string_view 
rExtensionName)
     if 
(officecfg::Office::ExtensionManager::ExtensionSecurity::DisableExtensionInstallation::get())
     {
         incBusy();
-        std::unique_ptr<weld::MessageDialog> 
xWarnBox(Application::CreateMessageDialog(getFrameWeld(),
-                                                      VclMessageType::Warning, 
VclButtonsType::Ok,
-                                                      
DpResId(RID_STR_WARNING_INSTALL_EXTENSION_DISABLED)));
+        std::unique_ptr<weld::MessageDialog> 
xWarnBox(Application::CreateMessageDialog(
+            getDialog(), VclMessageType::Warning, VclButtonsType::Ok,
+            DpResId(RID_STR_WARNING_INSTALL_EXTENSION_DISABLED)));
         xWarnBox->run();
         xWarnBox.reset();
         decBusy();
@@ -166,9 +167,9 @@ bool DialogHelper::installExtensionWarn(std::u16string_view 
rExtensionName)
     }
 
     incBusy();
-    std::unique_ptr<weld::MessageDialog> 
xInfoBox(Application::CreateMessageDialog(getFrameWeld(),
-                                                  VclMessageType::Warning, 
VclButtonsType::OkCancel,
-                                                  
DpResId(RID_STR_WARNING_INSTALL_EXTENSION)));
+    std::unique_ptr<weld::MessageDialog> 
xInfoBox(Application::CreateMessageDialog(
+        getDialog(), VclMessageType::Warning, VclButtonsType::OkCancel,
+        DpResId(RID_STR_WARNING_INSTALL_EXTENSION)));
     OUString sText(xInfoBox->get_primary_text());
     sText = sText.replaceAll("%NAME", rExtensionName);
     xInfoBox->set_primary_text(sText);
@@ -183,7 +184,8 @@ bool DialogHelper::installForAllUsers(bool &bInstallForAll)
 {
     const SolarMutexGuard guard;
     incBusy();
-    std::unique_ptr<weld::Builder> 
xBuilder(Application::CreateBuilder(getFrameWeld(), 
u"desktop/ui/installforalldialog.ui"_ustr));
+    std::unique_ptr<weld::Builder> xBuilder(
+        Application::CreateBuilder(getDialog(), 
u"desktop/ui/installforalldialog.ui"_ustr));
     std::unique_ptr<weld::MessageDialog> 
xQuery(xBuilder->weld_message_dialog(u"InstallForAllDialog"_ustr));
     short nRet = xQuery->run();
     xQuery.reset();
@@ -205,9 +207,8 @@ void DialogHelper::PostUserEvent( const Link<void*,void>& 
rLink, void* pCaller )
 
 //                             ExtMgrDialog
 ExtMgrDialog::ExtMgrDialog(weld::Window* pParent, TheExtensionManager& 
rManager)
-    : GenericDialogController(pParent, u"desktop/ui/extensionmanager.ui"_ustr,
-                              u"ExtensionManagerDialog"_ustr)
-    , DialogHelper(rManager.getContext(), m_xDialog.get())
+    : DialogHelper(pParent, u"desktop/ui/extensionmanager.ui"_ustr, 
u"ExtensionManagerDialog"_ustr,
+                   rManager.getContext())
     , m_bHasProgress(false)
     , m_bProgressChanged(false)
     , m_bStartProgress(false)
@@ -785,9 +786,8 @@ void ExtMgrDialog::Close()
 
 //UpdateRequiredDialog
 UpdateRequiredDialog::UpdateRequiredDialog(weld::Window* pParent, 
TheExtensionManager& rManager)
-    : GenericDialogController(pParent, 
u"desktop/ui/updaterequireddialog.ui"_ustr,
-                              u"UpdateRequiredDialog"_ustr)
-    , DialogHelper(rManager.getContext(), m_xDialog.get())
+    : DialogHelper(pParent, u"desktop/ui/updaterequireddialog.ui"_ustr,
+                   u"UpdateRequiredDialog"_ustr, rManager.getContext())
     , m_sCloseText(DpResId(RID_STR_CLOSE_BTN))
     , m_bHasProgress(false)
     , m_bProgressChanged(false)
diff --git a/desktop/source/deployment/gui/dp_gui_dialog2.hxx 
b/desktop/source/deployment/gui/dp_gui_dialog2.hxx
index 57971c59650f..0678d2fe1f80 100644
--- a/desktop/source/deployment/gui/dp_gui_dialog2.hxx
+++ b/desktop/source/deployment/gui/dp_gui_dialog2.hxx
@@ -43,19 +43,18 @@ class ExtensionBoxWithButtons;
 class ExtensionBox;
 class TheExtensionManager;
 
-class DialogHelper
+class DialogHelper : public weld::GenericDialogController
 {
     css::uno::Reference< css::uno::XComponentContext > m_xContext;
-    weld::Dialog* m_pDialog;
     ImplSVEvent *   m_nEventID;
     TopLevelWindowLocker m_aBusy;
 
 public:
-    DialogHelper(const css::uno::Reference<css::uno::XComponentContext>&, 
weld::Dialog* pDialog);
+    DialogHelper(weld::Widget* pParent, const OUString& rUIFile, const 
OUString& rDialogId,
+                 const css::uno::Reference<css::uno::XComponentContext>&);
     virtual        ~DialogHelper();
 
     void            openWebBrowser(const OUString& rURL, const OUString& 
rTitle);
-    weld::Window*   getFrameWeld() const { return m_pDialog; }
     void            PostUserEvent( const Link<void*,void>& rLink, void* 
pCaller );
     void            clearEventID() { m_nEventID = nullptr; }
 
@@ -75,15 +74,14 @@ public:
     bool continueOnSharedExtension(const 
css::uno::Reference<css::deployment::XPackage>&,
                                    TranslateId pResID, bool& bHadWarning);
 
-    void            incBusy() { m_aBusy.incBusy(m_pDialog); }
+    void incBusy() { m_aBusy.incBusy(m_xDialog.get()); }
     void            decBusy() { m_aBusy.decBusy(); }
     bool            isBusy() const { return m_aBusy.isBusy(); }
     bool            installExtensionWarn(std::u16string_view rExtensionURL);
     bool            installForAllUsers(bool &bInstallForAll);
 };
 
-class ExtMgrDialog : public weld::GenericDialogController
-                   , public DialogHelper
+class ExtMgrDialog : public DialogHelper
 {
     OUString             m_sProgressText;
     bool                 m_bHasProgress;
@@ -169,9 +167,7 @@ public:
     void enableButtontoEnable( bool bEnable );
 };
 
-
-class UpdateRequiredDialog : public weld::GenericDialogController
-                           , public DialogHelper
+class UpdateRequiredDialog : public DialogHelper
 {
     const OUString       m_sCloseText;
     OUString             m_sProgressText;
diff --git a/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx 
b/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx
index 9ed8e93db9a6..ec8a2db720e8 100644
--- a/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx
+++ b/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx
@@ -138,7 +138,7 @@ public:
         , m_nCurrentProgress(0)
         {}
 
-    weld::Window* activeDialog() { return m_pDialogHelper ? 
m_pDialogHelper->getFrameWeld() : nullptr; }
+    weld::Window* activeDialog() { return m_pDialogHelper ? 
m_pDialogHelper->getDialog() : nullptr; }
 
     void startProgress();
     void stopProgress();
@@ -793,7 +793,7 @@ void ExtensionCmdQueue::Thread::execute()
 
                 std::unique_ptr<weld::MessageDialog> 
xBox(Application::CreateMessageDialog(currentCmdEnv->activeDialog(),
                                                           
VclMessageType::Warning, VclButtonsType::Ok, msg));
-                xBox->set_title(m_rDialogHelper.getFrameWeld()->get_title());
+                xBox->set_title(m_rDialogHelper.getDialog()->get_title());
                 xBox->run();
                 m_rDialogHelper.decBusy();
                 //Continue with installation of the remaining extensions
@@ -906,7 +906,7 @@ void ExtensionCmdQueue::Thread::_checkForUpdates(
     m_rDialogHelper.incBusy();
 
     std::vector< UpdateData > vData;
-    UpdateDialog aUpdateDialog(m_xContext, m_rDialogHelper.getFrameWeld(),
+    UpdateDialog aUpdateDialog(m_xContext, m_rDialogHelper.getDialog(),
                                std::move(vExtensionList), &vData);
 
     aUpdateDialog.notifyMenubar( true, false ); // prepare the checking, if 
there updates to be notified via menu bar icon
@@ -930,7 +930,7 @@ void ExtensionCmdQueue::Thread::_checkForUpdates(
         if ( !dataDownload.empty() )
         {
             m_rDialogHelper.incBusy();
-            UpdateInstallDialog aDlg(m_rDialogHelper.getFrameWeld(), 
dataDownload, m_xContext);
+            UpdateInstallDialog aDlg(m_rDialogHelper.getDialog(), 
dataDownload, m_xContext);
             nDialogResult = aDlg.run();
             m_rDialogHelper.decBusy();
             aUpdateDialog.notifyMenubar( false, true ); // Check, if there are 
still pending updates to be notified via menu bar icon
@@ -945,7 +945,7 @@ void ExtensionCmdQueue::Thread::_checkForUpdates(
             {
                 if (!data.sWebsiteURL.isEmpty())
                     m_rDialogHelper.openWebBrowser(data.sWebsiteURL,
-                                                   
m_rDialogHelper.getFrameWeld()->get_title());
+                                                   
m_rDialogHelper.getDialog()->get_title());
             }
         }
     }

Reply via email to