Difference between revisions of "Documentation/DevGuide/Extensions/Location of Installed Extensions"
From Apache OpenOffice Wiki
< Documentation | DevGuide
m (changed next page) |
m |
||
(12 intermediate revisions by 9 users not shown) | |||
Line 3: | Line 3: | ||
|ShowPrevNext=block | |ShowPrevNext=block | ||
|PrevPage=Documentation/DevGuide/Extensions/unopkg | |PrevPage=Documentation/DevGuide/Extensions/unopkg | ||
− | |NextPage=Documentation/DevGuide/Extensions/ | + | |NextPage=Documentation/DevGuide/Extensions/Extension Layers |
}} | }} | ||
+ | {{Documentation/DevGuideLanguages|Documentation/DevGuide/Extensions/{{SUBPAGENAME}}}} | ||
{{DISPLAYTITLE:Location of Installed Extensions}} | {{DISPLAYTITLE:Location of Installed Extensions}} | ||
− | 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 < | + | 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 <tt>PackageInformationProvider</tt> to get an URL for an installed extension with a given Extension Identifier. For more information about Extension Identifiers see [[Documentation/DevGuide/Extensions/Extension Identifiers|Extension Identifiers]]. For more information see the singleton <idl>com.sun.star.deployment.PackageInformationProvider</idl> and its interface <idl>com.sun.star.deployment.XPackageInformationProvider</idl>. |
− | < | + | |
+ | Here is a C++ example: | ||
+ | <syntaxhighlight lang="cpp"> | ||
... | ... | ||
namespace css = com::sun::star; | namespace css = com::sun::star; | ||
Line 15: | Line 18: | ||
xInfoProvider( css::deployment::PackageInformationProvider::get( mxContext ) ); | xInfoProvider( css::deployment::PackageInformationProvider::get( mxContext ) ); | ||
− | // "MY_PACKAGE_ID" is the identifier of the package | + | // "MY_PACKAGE_ID" is the identifier of the package whose location we want |
rtl::OUString sLocation = xInfoProvider->getPackageLocation( | rtl::OUString sLocation = xInfoProvider->getPackageLocation( | ||
rtl::OUString::createFromAscii( "MY_PACKAGE_ID" ) ); | rtl::OUString::createFromAscii( "MY_PACKAGE_ID" ) ); | ||
... | ... | ||
− | </ | + | </syntaxhighlight> |
+ | |||
+ | You will find a Java example at page : [[API/Samples/Java/Office/ReadFilesFromOxt|ReadFilesFromOxt]] | ||
+ | |||
+ | Here is an example in Basic: | ||
+ | |||
+ | <syntaxhighlight lang="oobas"> | ||
+ | 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)) | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | {{Warn|The package location address finishes like this : <code>/extensionName.oxt</code> | ||
+ | Remember it is a '''folder''', not the extension package itself!}} | ||
+ | |||
{{PDL1}} | {{PDL1}} | ||
− | [[Category: Extensions]] | + | |
+ | [[Category:Documentation/Developer's Guide/Extensions]] |
Latest revision as of 11:29, 28 August 2022
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 the singleton com.sun.star.deployment.PackageInformationProvider and its interface 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" ) ); ...
You will find a Java example at page : ReadFilesFromOxt
Here is an 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))
The package location address finishes like this : /extensionName.oxt
Remember it is a folder, not the extension package itself! |
Content on this page is licensed under the Public Documentation License (PDL). |