From f62e4fb51d72641896b6b8f38fbffb35e6c1b695 Mon Sep 17 00:00:00 2001 From: Rene Engelhard Date: Mon, 3 Feb 2020 19:26:56 +0100 Subject: make Base install via packagekit also confgurable (like fonts/langpacks) Change-Id: I72f98e89d1c8e92f10da8e3843956658d035528d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87907 Tested-by: Rene Engelhard Tested-by: Jenkins Reviewed-by: Mike Kaganski --- .../registry/data/org/openoffice/Office/Common.xcu | 3 ++ .../schema/org/openoffice/Office/Common.xcs | 6 +++ sfx2/source/appl/appserv.cxx | 29 +++++++------- sw/source/uibase/app/apphdl.cxx | 45 +++++++++++++++------- 4 files changed, 56 insertions(+), 27 deletions(-) diff --git a/officecfg/registry/data/org/openoffice/Office/Common.xcu b/officecfg/registry/data/org/openoffice/Office/Common.xcu index 5f99ddc036bd..3d138551b593 100644 --- a/officecfg/registry/data/org/openoffice/Office/Common.xcu +++ b/officecfg/registry/data/org/openoffice/Office/Common.xcu @@ -556,6 +556,9 @@ true + + true + diff --git a/officecfg/registry/schema/org/openoffice/Office/Common.xcs b/officecfg/registry/schema/org/openoffice/Office/Common.xcs index 87839ae3cd9d..b217416756da 100644 --- a/officecfg/registry/schema/org/openoffice/Office/Common.xcs +++ b/officecfg/registry/schema/org/openoffice/Office/Common.xcs @@ -6621,6 +6621,12 @@ true + + + Specifies if missing LibreOffice Base installation should be triggered. + + true + diff --git a/sfx2/source/appl/appserv.cxx b/sfx2/source/appl/appserv.cxx index aee61e671f14..459d482cbf68 100644 --- a/sfx2/source/appl/appserv.cxx +++ b/sfx2/source/appl/appserv.cxx @@ -174,20 +174,23 @@ namespace // make sure we actually can instantiate services from base first if(!lcl_isBaseAvailable()) { - try - { - using namespace org::freedesktop::PackageKit; - using namespace svtools; - Reference< XSyncDbusSessionHelper > xSyncDbusSessionHelper(SyncDbusSessionHelper::create(comphelper::getProcessComponentContext())); - Sequence< OUString > vPackages { "libreoffice-base" }; - xSyncDbusSessionHelper->InstallPackageNames(vPackages, OUString()); - // Ill be back (hopefully)! - SolarMutexGuard aGuard; - executeRestartDialog(comphelper::getProcessComponentContext(), nullptr, RESTART_REASON_BIBLIOGRAPHY_INSTALL); - } - catch (const Exception &) + if (officecfg::Office::Common::PackageKit::EnableBaseInstallation::get()) { - TOOLS_INFO_EXCEPTION("sfx.appl", "trying to install LibreOffice Base"); + try + { + using namespace org::freedesktop::PackageKit; + using namespace svtools; + Reference< XSyncDbusSessionHelper > xSyncDbusSessionHelper(SyncDbusSessionHelper::create(comphelper::getProcessComponentContext())); + Sequence< OUString > vPackages { "libreoffice-base" }; + xSyncDbusSessionHelper->InstallPackageNames(vPackages, OUString()); + // I'll be back (hopefully)! + SolarMutexGuard aGuard; + executeRestartDialog(comphelper::getProcessComponentContext(), nullptr, RESTART_REASON_BIBLIOGRAPHY_INSTALL); + } + catch (const Exception &) + { + TOOLS_INFO_EXCEPTION("sfx.appl", "trying to install LibreOffice Base"); + } } return; } diff --git a/sw/source/uibase/app/apphdl.cxx b/sw/source/uibase/app/apphdl.cxx index 073b9d4a911a..aa8111004ab4 100644 --- a/sw/source/uibase/app/apphdl.cxx +++ b/sw/source/uibase/app/apphdl.cxx @@ -80,6 +80,8 @@ #include #include +#include + using namespace ::com::sun::star; // Slotmaps for the application's methods @@ -414,21 +416,36 @@ void SwMailMergeWizardExecutor::ExecuteMailMergeWizard( const SfxItemSet * pArgs { if(!lcl_hasAllComponentsAvailable()) { - try - { - using namespace org::freedesktop::PackageKit; - using namespace svtools; - css::uno::Reference< XSyncDbusSessionHelper > xSyncDbusSessionHelper(SyncDbusSessionHelper::create(comphelper::getProcessComponentContext())); - const css::uno::Sequence< OUString > vPackages{ "libreoffice-base" }; - xSyncDbusSessionHelper->InstallPackageNames(vPackages, OUString()); - SolarMutexGuard aGuard; - executeRestartDialog(comphelper::getProcessComponentContext(), nullptr, RESTART_REASON_MAILMERGE_INSTALL); - } - catch (const css::uno::Exception &) + if (officecfg::Office::Common::PackageKit::EnableBaseInstallation::get()) { - TOOLS_INFO_EXCEPTION( - "sw.core", - "trying to install LibreOffice Base, caught"); + try + { + using namespace org::freedesktop::PackageKit; + using namespace svtools; + css::uno::Reference< XSyncDbusSessionHelper > xSyncDbusSessionHelper(SyncDbusSessionHelper::create(comphelper::getProcessComponentContext())); + const css::uno::Sequence< OUString > vPackages{ "libreoffice-base" }; + xSyncDbusSessionHelper->InstallPackageNames(vPackages, OUString()); + SolarMutexGuard aGuard; + executeRestartDialog(comphelper::getProcessComponentContext(), nullptr, RESTART_REASON_MAILMERGE_INSTALL); + } + 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 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)) -- cgit v1.2.3