summaryrefslogtreecommitdiff
path: root/desktop/source/lib/init.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'desktop/source/lib/init.cxx')
-rw-r--r--desktop/source/lib/init.cxx48
1 files changed, 43 insertions, 5 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 35943999d12b..8c4fdb7b4494 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -35,6 +35,7 @@
#include <sal/log.hxx>
#include <vcl/errinf.hxx>
+#include <vcl/lok.hxx>
#include <osl/file.hxx>
#include <osl/process.h>
#include <osl/thread.h>
@@ -1516,6 +1517,11 @@ static bool lo_signDocument(LibreOfficeKit* pThis,
const unsigned char* pPrivateKeyBinary,
const int nPrivateKeyBinarySize);
+static void lo_runLoop(LibreOfficeKit* pThis,
+ LibreOfficeKitPollCallback pPollCallback,
+ LibreOfficeKitWakeCallback pWakeCallback,
+ void* pData);
+
LibLibreOffice_Impl::LibLibreOffice_Impl()
: m_pOfficeClass( gOfficeClass.lock() )
, maThread(nullptr)
@@ -1539,6 +1545,7 @@ LibLibreOffice_Impl::LibLibreOffice_Impl()
m_pOfficeClass->getVersionInfo = lo_getVersionInfo;
m_pOfficeClass->runMacro = lo_runMacro;
m_pOfficeClass->signDocument = lo_signDocument;
+ m_pOfficeClass->runLoop = lo_runLoop;
gOfficeClass = m_pOfficeClass;
}
@@ -4562,6 +4569,16 @@ static void lo_startmain(void*)
Application::ReleaseSolarMutex();
}
+static void lo_runLoop(LibreOfficeKit* /*pThis*/,
+ LibreOfficeKitPollCallback pPollCallback,
+ LibreOfficeKitWakeCallback pWakeCallback,
+ void* pData)
+{
+ SolarMutexGuard aGuard;
+ vcl::lok::registerPollCallbacks(pPollCallback, pWakeCallback, pData);
+ lo_startmain(nullptr);
+}
+
static bool bInitialized = false;
static void lo_status_indicator_callback(void *data, comphelper::LibreOfficeKit::statusIndicatorCallbackType type, int percent)
@@ -4711,7 +4728,24 @@ static int lo_initialize(LibreOfficeKit* pThis, const char* pAppPath, const char
// Did we do a pre-initialize
static bool bPreInited = false;
- static bool bProfileZones = getenv("SAL_PROFILEZONE_EVENTS") != nullptr;
+ static bool bUnipoll = false;
+ static bool bProfileZones = false;
+
+ { // cf. string lifetime for preinit
+ std::vector<OUString> aOpts;
+
+ // ':' delimited options - avoiding ABI change for new parameters
+ const char *pOptions = getenv("SAL_LOK_OPTIONS");
+ if (pOptions)
+ aOpts = comphelper::string::split(OUString(pOptions, strlen(pOptions), RTL_TEXTENCODING_UTF8), ':');
+ for (auto &it : aOpts)
+ {
+ if (it == "unipoll")
+ bUnipoll = true;
+ else if (it == "profile_events")
+ bProfileZones = true;
+ }
+ }
// What stage are we at ?
if (pThis == nullptr)
@@ -4924,10 +4958,14 @@ static int lo_initialize(LibreOfficeKit* pThis, const char* pAppPath, const char
RequestHandler::Enable(false);
SAL_INFO("lok", "Starting soffice_main");
RequestHandler::SetReady(false);
- pLib->maThread = osl_createThread(lo_startmain, nullptr);
- SAL_INFO("lok", "Waiting for RequestHandler");
- RequestHandler::WaitForReady();
- SAL_INFO("lok", "RequestHandler ready -- continuing");
+ if (!bUnipoll)
+ {
+ // Start the main thread only in non-unipoll mode (i.e. multithreaded).
+ pLib->maThread = osl_createThread(lo_startmain, nullptr);
+ SAL_INFO("lok", "Waiting for RequestHandler");
+ RequestHandler::WaitForReady();
+ SAL_INFO("lok", "RequestHandler ready -- continuing");
+ }
}
if (eStage != SECOND_INIT)