Daniel Boelzle wrote:
Hello Daniel,
my addon (see http://www.danielnaber.de/languagetool/ for the base package,
no OOo integration online yet) needs to know where it has been installed
to load some external files that are part of its ZIP.
I actually got this working in a different context (see
http://api.openoffice.org/servlets/BrowseList?list=dev&by=thread&from=566206)
but now it's different, as I don't re-implement an existing service as
before (the thesaurus). In the old solution, __getServiceFactory was
called and I received an XMultiServiceFactory which could then be used to
get the path I need by several complicated steps.
In my new code, __getServiceFactory isn't called anymore and thus I have no
instance of XMultiServiceFactory.
So what I'm look for is the path like this:
/home/dnaber/.openoffice2/user/uno_packages/cache/uno_packages/TXxcd8_/JLanguageTool.uno.zip/
Or a way to get XMultiServiceFactory so I can look up that path like it
worked with my old code.
The previous approach (prior to OOo 2.0) getting the cache directory
does not work anymore for OOo 2.0. The package manager cache has always
been an implementation detail and has changed for 2.0 for various
reasons, e.g. a pluggable API design and live deployment support. So
even the service manager instance won't help here.
A safe solution would be the config data approach that Juergen
mentioned, but I also suggest to play around with the class loader
resource mechanism, e.g.
java.net.URL url =
MyClassFromMyJar.class.getResource("some-file-in-my.jar");
to obtain an url at runtime.
The above mechanism is unreliable and should not be used:
ClassLoader.getResource "will first search the parent class loader for
the resource" (see the Sun Java documentation), so if some parent class
loader happens to find another file coincidentially also named
some-file-in-my.jar you get a wrong result.
-Stephan
Concerning C/C++, there is an API in sal/osl, have a look at osl/module.h:
sal_Bool SAL_CALL osl_getModuleURLFromAddress( void *pv, rtl_uString
**pustrURL );
Passing the address of some function from within your C++ UNO component
would return an URL to your .so/.dll.
HTH,
-Daniel
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]