On 10/20/10 07:57, Martin Dobiasch wrote:
I'm having one major problem:
I need to provide some tools with my extension. To run them I try to detect
the location of my package in the filesystem. With Windows no problem.
On Linux if the package the path is always empty.
My code, runs without an exception, but the URL seems to be empty:
try
{
XPackageInformationProvider xPackageInformationProvider=
PackageInformationProvider
.get(m_xContext);
String location= xPackageInformationProvider
.getPackageLocation("at.univie.midicsdext"); //has to be the
id from description.xml
Are you sure that location is already an empty string, or do you only
observe that PackagePath below is an empty string?
Object oTransformer= m_xContext.getServiceManager()
.createInstanceWithContext("com.sun.star.util.URLTransformer",
m_xContext);
XURLTransformer xTransformer= (XURLTransformer) UnoRuntime
.queryInterface(XURLTransformer.class, oTransformer);
com.sun.star.util.URL[] oURL= new com.sun.star.util.URL[1];
oURL[0]= new com.sun.star.util.URL();
oURL[0].Complete= location + "/midicsv/";
xTransformer.parseStrict(oURL);
PackagePath= oURL[0].Path + oURL[0].Name;
For adding a "midicsv" segment to the path of the URL represented by
location, I would not use URLTransformer (I have my personal doubts
about it), but com.sun.star.uri.UriReferenceFactory; something like:
UriReferenceFactory f = UriReferenceFactory.create(m_xContext);
XUriReference url = f.makeAbsolute(
f.parse(location), f.parse("midicsv"), false,
RelativeUriExcessParentSegments.ERROR);
if (sub == null) { ... error ... }
PackagePath = url.getUriReference();
// assuming that PackagePath shall denote a URL
-Stephan
Debug.showMessage("Packpath: " + PackagePath);
}
catch (com.sun.star.uno.Exception ex)
{
Debug.showException(ex, "MidiCSD::updatePackagePath");
System.out.println(ex);
System.out.println(ex.getStackTrace());
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]