desktop/source/lib/init.cxx | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+)
New commits: commit ea604324bb2a26ac96b5c190121579b602ebffd2 Author: Caolán McNamara <[email protected]> AuthorDate: Tue Nov 26 20:24:56 2024 +0000 Commit: Caolán McNamara <[email protected]> CommitDate: Wed Dec 18 11:44:11 2024 +0100 add a way to update config from kit arg is a path to a "presets" dir similar to instdir/presets/ where autotext/wordbook/xcu may exist initially just update xcu if that is present, autotext itself typically is updated dynamically if a new file is found, while wordbooks are not and the diclist can be explicitly reinitialized here if there are wordbooks. Change-Id: Ibeb9d23d143c710f12e6c9d75b2861e0e6d44a01 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177372 Reviewed-by: Miklos Vajna <[email protected]> Tested-by: Jenkins CollaboraOffice <[email protected]> (cherry picked from commit 30f83f2dff9f80db0b4a467fb30f9a9b2531fa3c) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178664 Reviewed-by: Caolán McNamara <[email protected]> Tested-by: Jenkins diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 1c87d16d505f..b7312be1772e 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -111,6 +111,7 @@ #include <com/sun/star/util/URLTransformer.hpp> #include <com/sun/star/util/XFlushable.hpp> #include <com/sun/star/configuration/theDefaultProvider.hpp> +#include <com/sun/star/configuration/Update.hpp> #include <com/sun/star/datatransfer/clipboard/XClipboard.hpp> #include <com/sun/star/datatransfer/UnsupportedFlavorException.hpp> #include <com/sun/star/datatransfer/XTransferable2.hpp> @@ -5238,6 +5239,36 @@ static void lo_sendDialogEvent(LibreOfficeKit* /*pThis*/, unsigned long long int lcl_sendDialogEvent(nWindowId, pArguments); } +static void updateConfig(const OUString& rConfigPath) +{ + osl::Directory aScanRootDir(rConfigPath); + osl::FileBase::RC nRetCode = aScanRootDir.open(); + if (nRetCode != osl::Directory::E_None) + { + SAL_WARN("lok", "Failed to open config URL: " << rConfigPath); + return; + } + osl::DirectoryItem item; + osl::File::RC errorNext = osl::File::E_None; + while ((errorNext = aScanRootDir.getNextItem(item)) == ::osl::File::E_None) + { + osl::FileStatus stat(osl_FileStatus_Mask_FileName | osl_FileStatus_Mask_FileURL); + if (item.getFileStatus(stat) != osl::FileBase::E_None) + { + SAL_WARN("lok", "Failed to get directory item info"); + continue; + } + + OUString sFileName = stat.getFileName(); + if (sFileName == "xcu") + { + OUString aXcuPath(stat.getFileURL() + "/config.xcu"); + auto xUpdate(css::configuration::Update::get(comphelper::getProcessComponentContext())); + xUpdate->insertModificationXcuFile(aXcuPath, { u"/"_ustr }, {}); + } + } +} + static void lo_setOption(LibreOfficeKit* /*pThis*/, const char *pOption, const char* pValue) { static char* pCurrentSalLogOverride = nullptr; @@ -5268,6 +5299,10 @@ static void lo_setOption(LibreOfficeKit* /*pThis*/, const char *pOption, const c else sal_detail_set_log_selector(pCurrentSalLogOverride); } + else if (strcmp(pOption, "addconfig") == 0) + { + updateConfig(OUString(pValue, strlen(pValue), RTL_TEXTENCODING_UTF8)); + } #ifdef LINUX else if (strcmp(pOption, "addfont") == 0) {
