23#include <osl/thread.hxx>
28 static osl::ThreadData oleThreadData;
30 if (!
bool(
reinterpret_cast<sal_IntPtr
>(oleThreadData.getData())))
32 HRESULT
hr = CoInitializeEx(
nullptr, COINIT_MULTITHREADED);
35 assert(RPC_E_CHANGED_MODE ==
hr);
37 SAL_WARN(
"extensions.olebridge",
"CoInitializeEx failed"
38 << (
hr == RPC_E_CHANGED_MODE ?
" (expectedly)" :
"")
39 <<
": " << WindowsErrorStringFromHRESULT(
hr));
41 APTTYPEQUALIFIER nAptTypeQualifier;
42 if (SUCCEEDED(CoGetApartmentType(&nAptType, &nAptTypeQualifier)))
46 << (nAptType == APTTYPE_STA ? OUString(
"single-threaded") :
47 (nAptType == APTTYPE_MTA ? OUString(
"multi-threaded") :
48 (nAptType == APTTYPE_NA ? OUString(
"neutral") :
49 (nAptType == APTTYPE_MAINSTA ? OUString(
"main single-threaded") :
50 (
"unknown (") + OUString::number(nAptType) +
")"))))
52 << (nAptTypeQualifier == APTTYPEQUALIFIER_NONE ? OUString() :
53 (nAptTypeQualifier == APTTYPEQUALIFIER_IMPLICIT_MTA ? OUString(
" (implicit)") :
54 (nAptTypeQualifier == APTTYPEQUALIFIER_NA_ON_MTA ? OUString(
" (on MTA)") :
55 (nAptTypeQualifier == APTTYPEQUALIFIER_NA_ON_STA ? OUString(
" (on STA)") :
56 (nAptTypeQualifier == APTTYPEQUALIFIER_NA_ON_IMPLICIT_MTA ? OUString(
" (on implicit MTA)") :
57 (nAptTypeQualifier == APTTYPEQUALIFIER_NA_ON_MAINSTA ? OUString(
" (on main STA)") :
58 (
" (with unknown qualifier (" + OUString::number(nAptTypeQualifier) +
"))")))))))
62 oleThreadData.setData(
reinterpret_cast<void*
>(
true));
#define SAL_WARN(area, stream)
void o2u_attachCurrentThread()