Difference between revisions of "Documentation/DevGuide/Extensions/Location of Installed Extensions"

From Apache OpenOffice Wiki
Jump to: navigation, search
(Adding a more understandable Basic example.)
m
Line 36: Line 36:
 
</source>
 
</source>
  
Note that the folder name is like : <tt>/extensionName.oxt</tt>
+
{{Documentation/Caution|The obtained folder name is like : <code>/extensionName.oxt</code>  
 
+
This is a '''folder''', not the extension package itself!}}
This is a folder, not the extension package itself!
+
  
 
{{PDL1}}
 
{{PDL1}}
  
 
[[Category:Documentation/Developer's Guide/Extensions]]
 
[[Category:Documentation/Developer's Guide/Extensions]]

Revision as of 10:26, 24 September 2009



Sometimes an extension developer needs to know the path to the root of his installed extension e.g. to load some additional data. You can use the singleton PackageInformationProvider to get an URL for an installed extension with a given Extension Identifier. For more information about Extension Identifiers see Extension Identifiers. For more information see com.sun.star.deployment.PackageInformationProvider and have a look at com.sun.star.deployment.XPackageInformationProvider.

Here is a C++ example:

  ...
  namespace css = com::sun::star;
  css::uno::Reference< css::uno::XComponentContext > mxContext;
  ...
  css::uno::Reference< css::deployment::XPackageInformationProvider >
  xInfoProvider( css::deployment::PackageInformationProvider::get( mxContext ) );
 
  // "MY_PACKAGE_ID" is the identifier of the package whose location we want
  rtl::OUString sLocation = xInfoProvider->getPackageLocation( 
  rtl::OUString::createFromAscii( "MY_PACKAGE_ID" ) );
  ...

A directly usable example in Basic:

Dim pip As Object, extensionLocation As String
Const extensionIdentifier = "org.toto.test3"
 
pip = GetDefaultContext.getByName("/singletons/com.sun.star.deployment.PackageInformationProvider")
extensionLocation = pip.getPackageLocation(extensionIdentifier)
' display a human readable address
MsgBox(ConvertFromURL(extensionLocation))
Documentation caution.png The obtained folder name is like : /extensionName.oxt

This is a folder, not the extension package itself!

Content on this page is licensed under the Public Documentation License (PDL).
Personal tools
In other languages