Hi Manuel,
first of all, we have already detected this as a missing functionality
and we will provide a simple API for detecting the package root in the
future. But i can't say when it will be available ...
See my comments inline ...
Manuel Odesser wrote:
Hello,
I am building an extension to OOo, using OOBasic and Java. I actually
have two problems.
1) How to open in Java a file bundled in the UNO package ? I followed
instruction from
http://codesnippets.services.openoffice.org/Office/Office.ArbitraryDeploy.snip
(and others). I cannot retrieve a path from a .xcu file for opening. I
have the following code :
private init() throws IOException,Exception {
XComponentContext xContext;
XMultiComponentFactory xServiceManager;
XMultiServiceFactory xProvider;
try {
xContext = com.sun.star.comp.helper.Bootstrap.bootstrap();
} catch (BootstrapException e1) {
e1.printStackTrace();
return false;
}
xServiceManager = xContext.getServiceManager();
Object mxConfigurationProvider =
xServiceManager.createInstanceWithContext(
"com.sun.star.configuration.ConfigurationProvider",
xContext);
try {
xProvider = (XMultiServiceFactory)
UnoRuntime.queryInterface(XMultiServiceFactory.class,mxConfigurationProvider);
PropertyValue properties[] = new PropertyValue[1];
PropertyValue property = new PropertyValue();
property.Name = "nodepath";
property.Value = "my.package";
properties[0] = property;
// create the view
Object xViewRoot =
xProvider.createInstanceWithArguments("com.sun.star.configuration.ConfigurationAccess",properties);
you have to query the new created object to the interface you want to
use, somehting like
XNameAccess xNA =
(XNameAccess)UnoRuntime.queryInterface(XNameAccess.class, xViewRoot );
dataPath = (String)xViewRoot.getByName("myvar");
} catch (Exception e) {
e.printStackTrace();
return false;
}
// get data file
// cut the "vnd.sun.star.expand:" protocol from the macrofied Url
retrieved from the registry
dataPath = dataPath.replace("vnd.sun.star.expand:","");
Object theExpander;
theExpander =
xContext.getValueByName("/singletons/com.sun.star.util.theMacroExpander");
XMacroExpander oMacroExpander = (XMacroExpander)theExpander;
you can't simply cast this object. "getValueByName" returns an "Any"
which of course is mapped in Java to Object. You have either to use the
"AnyConverter" or if you need a specific interface use again
2queryInterface" which allows "Any" object directly.
dataPath = oMacroExpander.expandMacros(dataPath);
BufferedReader buffer = new BufferedReader(new
FileReader(dataPath));
....
}
* problem 1 : xViewRoot is viewed as an Object, and therefore has no
getByName() method. And I can't cast to
com.sun.star.configuration.ConfigurationAccess because Eclipse couldn't
locate the appropriate file.
* problem 2 : An exception is throw at runtime during the cast of
variable theExpander.
* problem 3 : what is the typical .xcu file that could contain
"%origin%/mypath/myfile.dat ?
Currently you have to define your own package specific configuration
schema and you have to provide an appropriate xcu file depending on this
schema together with all other files in your package. In a second step
you can use the configuration API to work with your own configuration
and the MacroExpander to get a valid Url.
Sorry that it is so complicate but we are working on improvements.
Juergen
2) I have a addons.xcu that begins with :
<oor:component-data
xmlns:oor="http://solstage2.sfo.collab.net/2001/registry"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
oor:name="Addons"
oor:package="org.openoffice.Office">
<node oor:name="AddonUI">
<node oor:name="AddonMenu">
<node
oor:name="mypackage.myaddon"
oor:op="replace">
Is "mypackage.myaddon" a suitable/valid name ? Should it begin with
"org.openoffice...." or something else ?
Sorry for this long email, and thank very much in advance for your
answers !
--
Manuel
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]