Hello giancarlo,
On Friday 17 April 2009, 11:52, giancarlo wrote:
> - The path of "repository" is found by this code:
>
> public MyExtension(XComponentContext context) {
> String m_implementationName = MyExtension.class.getName();
> m_xContext = context;
> XPackageInformationProvider xPackageInformationProvider =
> PackageInformationProvider.get(m_xContext);
> reposPath =
> xPackageInformationProvider.getPackageLocation(m_implementationName);
> reposPath = reposPath.replaceFirst("file://", "");
> reposPath +="/repository";
> ...
> ...
> }
> *_The problem:_*
>
> - When I try out the extension on OOo for MS Windows (both XP and Vista)
> the path is wrong, I get things like this:
>
> \C:/ . . . /MyExtension.oxt/repository
IMO the problem is your code is not system independent.
You should use the OOo API way to get the extension location:
/**
* Provides an URL to the root of an installed package.
*
* @param xContext XComponentContext
* @param sExtensionIdentifier the unique identifier of an extension.
* @return The service looks for an installed package with the
* given id and returns the URL to the root of the package.
* If the service can not find a matching package, an emty string will
* be returned.
*/
public static String getExtensionLocation(
XComponentContext xContext,
String sExtensionIdentifier)
{
String sPath = "";
String sSingleton =
"/singletons/com.sun.star.deployment.PackageInformationProvider";
try {
com.sun.star.deployment.XPackageInformationProvider
xPackageInformationProvider =
(com.sun.star.deployment.XPackageInformationProvider)
UnoRuntime.queryInterface(
com.sun.star.deployment.XPackageInformationProvider.class,
xContext.getValueByName(sSingleton));
sPath = xPackageInformationProvider.getPackageLocation(
sExtensionIdentifier);
} catch (Exception ex) {
ex.printStackTrace();
} finally {
return sPath;
}
}
Regards
--
Ariel Constenla-Haile
La Plata, Argentina
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]