framework: allow loading a component on the main thread

Desktop / LibreOffice - Miklos Vajna [] - 19 December 2018 20:55 EST

The user-visible problem was that embedded (OLE) objects contained in a document that was loaded on a thread were not editable.

This works in the loaded-with-UI case because the Windows version of the SalData constructor in vcl calls CoInitialize() (which sets the concurrency model of the main thread to STA) and then later the OleComponent constructor in embeddedobj calls OleInitialize(), which just realizes that the concurrency model is already set, and OLE editing works.

However, if the document is loaded on a thread, things are different. The concurrency model of the thread is set to MTA in oslWorkerWrapperFunction() in sal, so the later OleInitialize() will fail with RPC_E_CHANGED_MODE, as it's not possible to set the concurrency model of a thread once it's set.

Solve the problem by providing in opt-in way to execute the actual import on the main thread, since remote UNO clients always invoke Desktop::loadComponentFromURL() on a thread.

Change-Id: I94f2721b599c3ae3e2ebc1c90dea649a69d51ef7 Reviewed-on:

2dc3a6c273cb framework: allow loading a component on the main thread
framework/source/services/frame.cxx | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)


  • Share