Hi Ariel, first of all, I think you are doing an incredible and admirable job helping people on this list!
It is more than remarkable to see how well you have mastered many of the OOo APIs (if not all?) and how helpful you are. Many of the code samples that you supply could serve *very* well as "OOo snippets", helping even more people (beyond the mailing lists you happen to interface with): <http://codesnippets.services.openoffice.org/index.xml>. Creating those OOo code snippets is quite straight forward, i.e. quite easy and hence quickly created, thanks to Paolo Mantovani's great wizard: <http://www.paolo-mantovani.org/downloads/SnippetCreator/SnippetCreator-20070624.oxt>. This would make all those treasures of yours available to a large audience! (But of course, it still takes some, if very little time.) --- > [ooRexx code] > > as my ooRexx knowledge is null, I can't get if you're doing something > wrong; but you can try with the code I attach, which does almost the > same [I added the LevelFormat demo]; maybe stepping into the code, you > can find if you're missing something. As the ooRexx support uses the Java bridge, your code samples should be right at the top, if Nicole Scholz transcribes them 1:1 to ooRexx. Also, it would be possible for people understanding one, two things about ooRexx to take ooRexx code samples and translate them back to whatever language one uses, hence two, three remarks and as a little thank you the transcription of one of your static Java methods to ooRexx code, such that you could see the difference and map the concepts more easily: * ooRexx is a dynamic language, hence no typing (that may come into the way of programmers) is really needed; the UNO/OOo support takes advantage of that and tries to alleviate the typing needs from OOo-script programmers, * in ooRexx the interaction with objects is not done with dereferencing a structure with the dot operator, rather there is an explicit message operator (~), the tilde. This allows one to send objects (left of the tilde) messages (richt of the tilde). If messages carry arguments, then one can supply them in round parenthesis, otherwise the parenthesis can be omitted. (Also, it is permissible to have white space before and after the message operator). One feature of the ooRexx UNO/OOo support is the observation, that queryInterface() is a fundamental, basic and important operation, making it quite cumbersome at times to code that (especially without context-sensivitive-/intelligense-editors). Due to the features available in ooRexx the querying of interfaces can be eased for the programmers by merely sending those UNO objects the names of the interfaces; it is possible to use the unqualified name of such interfaces. * Before an ooRexx program is executed by the interpreter, it first gets scanned for syntax errors, then for directives (led in with double colons at the end of a program), which will be carried out by the interpreter, before running the program with the very first statement in line 1. What follows is first the static Java method "getOOoLocale(...)" and a transcription to ooRexx which takes advantage of the UNO/OOo support set up in the ooRexx module "UNO.CLS": ---------------------- cut here (Java code) --------------------- public static Locale getOOoLocale( XComponentContext xContext ) { Locale aLocale = new Locale(); try { Object oConfigurationProvider = xContext.getServiceManager().createInstanceWithContext( "com.sun.star.configuration.ConfigurationProvider", xContext); XMultiServiceFactory xConfigurationProvider = (XMultiServiceFactory) UnoRuntime.queryInterface( XMultiServiceFactory.class, oConfigurationProvider); PropertyValue aPropValue = new PropertyValue(); aPropValue.Name = "nodepath"; aPropValue.Value = "/org.openoffice.Setup/L10N"; XNameAccess xNameAccess = (XNameAccess) UnoRuntime.queryInterface( XNameAccess.class, xConfigurationProvider.createInstanceWithArguments( "com.sun.star.configuration.ConfigurationAccess", new PropertyValue[]{aPropValue})); String sLocale = AnyConverter.toString( xNameAccess.getByName("ooLocale")); if ( sLocale.length() > 0) { if (sLocale.contains("-")){ String[] sLocaleInfo = sLocale.split("-"); aLocale.Language = sLocaleInfo[0]; if (sLocaleInfo.length > 1) { aLocale.Country = sLocaleInfo[1]; } } else { aLocale.Language = sLocale; } } } catch (Exception ex) { ex.printStackTrace(); } finally { return aLocale; } } ---------------------- cut here (Java code) --------------------- A possible ooRexx transcription: ---------------------- cut here (ooRexx code) --------------------- ::routine getOOoLocale public use arg xContext aLocale=.bsf~new("com.sun.star.lang.Locale") signal on syntax -- activate signal handler (jump to label "syntax:") clzName="com.sun.star.configuration.ConfigurationProvider" oConfigurationProvider=xContext~getServiceManager~createInstanceWithContext(clzName,xContext) xConfigurationProvider=oConfigurationProvider~com.sun.star.lang.XMultiServiceFactory -- create a Java array of type "PropertyValue", create and save a property with it props=uno.createArray(.uno~PropertyValue,1) props[1]=uno.createProperty("nodepath","/org.openoffice.Setup/L10N") clzName="com.sun.star.configuration.ConfigurationAccess" -- here the unqualified name of the interface "com.sun.star.container.XNameAccess" is used: xNameAccess=xConfigurationProvider ~createInstanceWithArguments(clzName,props) ~XNameAccess -- if of type String, toString() is not necessary, otherwise append the message "~toString" sLocale=xNameAccess~getByName("ooLocale") if sLocale<>"" then -- locale information present, if so process it do -- parse the string into two parts according to the explicit template parse var sLocale aLocale~Language "-" sCountry if sCountry<>"" then -- if country exists, assign it to the new aLocale aLocale~Country=sCountry end syntax: return aLocale ---------------------- cut here (ooRexx code) --------------------- The ooRexx OOo code snippets have the UNO/OOo class names hyperlinked to the online documentation, such that anyone can learn the fully qualifed names of interfaces in use (and being right at the documentation of those interfaces). Therefore the ooRexx code snippets should be helpful for anyone using the Java bridge in one form or the other to interact with OOo. (The ooRexx syntax is quite simple and therefore easy to learn, if not looking like pseudo code for some.) Regards, ---rony
