sw/source/uibase/app/apphdl.cxx |   59 +++++++++++++++++-----------------------
 1 file changed, 26 insertions(+), 33 deletions(-)

New commits:
commit 9f65398bb943051378845aa801402a6a65cae224
Author:     Mike Kaganski <[email protected]>
AuthorDate: Sun Jan 25 08:37:54 2026 +0100
Commit:     Mike Kaganski <[email protected]>
CommitDate: Sun Jan 25 09:23:56 2026 +0100

    Deduplicate some code, and provide dialog parent
    
    Change-Id: I2b6ed8b87bbd0f0ca786f5edeee55c90fa841fb0
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/198057
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <[email protected]>

diff --git a/sw/source/uibase/app/apphdl.cxx b/sw/source/uibase/app/apphdl.cxx
index 958c687332b9..a03a9cf62e13 100644
--- a/sw/source/uibase/app/apphdl.cxx
+++ b/sw/source/uibase/app/apphdl.cxx
@@ -403,6 +403,16 @@ bool lcl_hasAllComponentsAvailable()
 
 void SwMailMergeWizardExecutor::ExecuteMailMergeWizard( const SfxItemSet * 
pArgs )
 {
+    if (m_pView)
+    {
+        OSL_FAIL("SwMailMergeWizardExecutor::ExecuteMailMergeWizard: Already 
executing the wizard!");
+        return;
+    }
+
+    auto pView = ::GetActiveView();
+    if (!pView)
+        return;
+
     if(!lcl_hasAllComponentsAvailable())
     {
         if 
(officecfg::Office::Common::PackageKit::EnableBaseInstallation::get())
@@ -411,53 +421,36 @@ void SwMailMergeWizardExecutor::ExecuteMailMergeWizard( 
const SfxItemSet * pArgs
             {
                 using namespace org::freedesktop::PackageKit;
                 using namespace svtools;
-                css::uno::Reference< XSyncDbusSessionHelper > 
xSyncDbusSessionHelper(SyncDbusSessionHelper::create(comphelper::getProcessComponentContext()));
+                auto 
xSyncDbusSessionHelper(SyncDbusSessionHelper::create(comphelper::getProcessComponentContext()));
                 const css::uno::Sequence< OUString > vPackages{ 
u"libreoffice-base"_ustr };
                 xSyncDbusSessionHelper->InstallPackageNames(vPackages, 
OUString());
                 SolarMutexGuard aGuard;
-                
(void)executeRestartDialog(comphelper::getProcessComponentContext(), nullptr, 
RESTART_REASON_MAILMERGE_INSTALL);
+                
(void)executeRestartDialog(comphelper::getProcessComponentContext(),
+                                           pView->GetFrameWeld(), 
RESTART_REASON_MAILMERGE_INSTALL);
+                return;
             }
             catch (const css::uno::Exception &)
             {
                 TOOLS_INFO_EXCEPTION(
                     "sw.core",
                     "trying to install LibreOffice Base, caught");
-                auto xRestartManager
-                    = 
css::task::OfficeRestartManager::get(comphelper::getProcessComponentContext());
-                if (!xRestartManager->isRestartRequested(false))
-                {
-                    // Base is absent, and could not initiate its install - 
ask user to do that manually
-                    // Only show the dialog if restart is not initiated yet
-                    std::unique_ptr<weld::MessageDialog> 
xWarnBox(Application::CreateMessageDialog(
-                        nullptr, VclMessageType::Info, VclButtonsType::Ok,
-                        SwResId(STR_NO_BASE_FOR_MERGE)));
-                    xWarnBox->run();
-                }
-            }
-        } else {
-            auto xRestartManager
-                = 
css::task::OfficeRestartManager::get(comphelper::getProcessComponentContext());
-            if (!xRestartManager->isRestartRequested(false))
-            {
-                // Base is absent, and could not initiate its install - ask 
user to do that manually
-                // Only show the dialog if restart is not initiated yet
-                std::unique_ptr<weld::MessageDialog> 
xWarnBox(Application::CreateMessageDialog(
-                    nullptr, VclMessageType::Info, VclButtonsType::Ok,
-                    SwResId(STR_NO_BASE_FOR_MERGE)));
-                xWarnBox->run();
             }
         }
-        return;
-    }
-    if ( m_pView )
-    {
-        OSL_FAIL("SwMailMergeWizardExecutor::ExecuteMailMergeWizard: Already 
executing the wizard!" );
+        auto xRestartManager
+            = 
css::task::OfficeRestartManager::get(comphelper::getProcessComponentContext());
+        if (!xRestartManager->isRestartRequested(false))
+        {
+            // Base is absent, and could not initiate its install - ask user 
to do that manually
+            // Only show the dialog if restart is not initiated yet
+            std::unique_ptr<weld::MessageDialog> 
xWarnBox(Application::CreateMessageDialog(
+                pView->GetFrameWeld(), VclMessageType::Info, 
VclButtonsType::Ok,
+                SwResId(STR_NO_BASE_FOR_MERGE)));
+            xWarnBox->run();
+        }
         return;
     }
 
-    m_pView = ::GetActiveView();
-    if (!m_pView)
-        return;
+    m_pView = pView;
 
     // keep self alive until done.
     acquire();

Reply via email to