diff options
author | Tor Lillqvist <tml@collabora.com> | 2021-04-21 17:37:57 +0300 |
---|---|---|
committer | Tor Lillqvist <tml@collabora.com> | 2021-04-23 13:11:18 +0200 |
commit | 002b7a87b3b3edf0a28cc910510f766ae01bcb99 (patch) | |
tree | fe29ddacd77beab3f604964bb46c3ac0578a480a /desktop | |
parent | f05ecc6d6518da976854455996db3fe9144c6bf0 (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>
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 3f55f9bfbf8e..b646356a9365 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -2086,6 +2086,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) @@ -2111,6 +2113,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; } @@ -3858,6 +3861,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 || strlen(pCurrentSalLogOverride) == 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"); |