Apache OpenOffice (AOO) Bugzilla – Issue 57289
getting the process' component context in URE
Last modified: 2005-11-03 14:43:49 UTC
If I need to access an existing (already bootstrapped) process local UNO environment from within e.g. an XPCOM component (which has been started from within the office process), I have currently no API to get the UNO component context. There is such an API in comphelper (setProcessServiceFactory(). Background: The XPCOM-UNO runtime object (i.e. a XPCOM service that is accessed in Javascript) offers access to am UNO component context. Getting the component context, I currently call comphelper::getProcessServiceFactory(). If no such service factory is set, I assume that the whole process is not the running office process, thus I bootstrap using a remote component context (calling cppu::bootstrap()). As an alternative, just for omitting the need to link against comphelper, I could if (current process is soffice..exe/soffice.bin) { #if WINDOWS handle = loadLib("comphelp4msc.dll"); sym = dlsym( handle. "C++-decorated-comphelper::getProcessService" ) #else sym = dlsym( processHandle. "C++-decorated-comphelper::getProcessService" ) #endif ... So what do you think, Stephan?
As discussed offline, it is a questionable design to ask for "the UNO component context of the process." Please solve your problem in a way that does not rely on global data.
Global seems to be the only possibility here (even thread local storage won't help), because there is no way to tunnel the component context. So the sketched alternative way... IMO a hack. => closing
closing