diff options
author | Tor Lillqvist <tml@collabora.com> | 2021-04-21 17:37:57 +0300 |
---|---|---|
committer | Tor Lillqvist <tml@collabora.com> | 2021-04-28 09:30:17 +0200 |
commit | 41ff704cc49b7097b717882616011962ecd7198f (patch) | |
tree | 65c94d0f52acebe9c637e0de1a636dd2f0b79cfc /desktop | |
parent | 9bfe083adf1fd9d470b600d0a801d144db24474f (diff) |
Add API to LibreOfficeKit to set arbitrary run-time options in core
Add setOption(const char*, const char*)
At the moment this enables starting and stopping the ProfileZone event
recording and overriding the SAL_LOG environment variable.
Change-Id: Ic3a934bb4246c755a91eee8a8343fafc15815116
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114439
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Tor Lillqvist <tml@collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114559
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114656
Tested-by: Tor Lillqvist <tml@collabora.com>
Diffstat (limited to 'desktop')
-rw-r--r-- | desktop/source/lib/init.cxx | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 23400d906628..ecbd0f3f97e5 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -2076,6 +2076,8 @@ static void lo_sendDialogEvent(LibreOfficeKit* pThis, unsigned long long int nLOKWindowId, const char* pArguments); +static void lo_setOption(LibreOfficeKit* pThis, const char* pOption, const char* pValue); + LibLibreOffice_Impl::LibLibreOffice_Impl() : m_pOfficeClass( gOfficeClass.lock() ) , maThread(nullptr) @@ -2101,6 +2103,7 @@ LibLibreOffice_Impl::LibLibreOffice_Impl() m_pOfficeClass->signDocument = lo_signDocument; m_pOfficeClass->runLoop = lo_runLoop; m_pOfficeClass->sendDialogEvent = lo_sendDialogEvent; + m_pOfficeClass->setOption = lo_setOption; gOfficeClass = m_pOfficeClass; } @@ -3842,6 +3845,33 @@ static void lo_sendDialogEvent(LibreOfficeKit* /*pThis*/, unsigned long long int lcl_sendDialogEvent(nWindowId, pArguments); } +static void lo_setOption(LibreOfficeKit* /*pThis*/, const char *pOption, const char* pValue) +{ + static char* pCurrentSalLogOverride = nullptr; + + if (strcmp(pOption, "profilezonerecording") == 0) + { + if (strcmp(pValue, "start") == 0) + comphelper::ProfileZone::startRecording(); + else if (strcmp(pValue, "stop") == 0) + comphelper::ProfileZone::stopRecording(); + } + else if (strcmp(pOption, "sallogoverride") == 0) + { + if (pCurrentSalLogOverride != nullptr) + free(pCurrentSalLogOverride); + if (pValue == nullptr) + pCurrentSalLogOverride = nullptr; + else + pCurrentSalLogOverride = strdup(pValue); + + if (pCurrentSalLogOverride == nullptr || pCurrentSalLogOverride[0] == '\0') + sal_detail_set_log_selector(nullptr); + else + sal_detail_set_log_selector(pCurrentSalLogOverride); + } +} + static void doc_postUnoCommand(LibreOfficeKitDocument* pThis, const char* pCommand, const char* pArguments, bool bNotifyWhenFinished) { comphelper::ProfileZone aZone("doc_postUnoCommand"); |