desktop/source/lib/init.cxx | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+)
New commits: commit 30f83f2dff9f80db0b4a467fb30f9a9b2531fa3c Author: Caolán McNamara <caolan.mcnam...@collabora.com> AuthorDate: Tue Nov 26 20:24:56 2024 +0000 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Tue Dec 17 11:42:51 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 <vmik...@collabora.com> Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index e080dd8b5729..37de7a257e8f 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -117,6 +117,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> @@ -5273,6 +5274,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; @@ -5303,6 +5334,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) {