You could add this Snippet to our collection: http://codesnippets.services.openoffice.org/
Tom Christoph Lutz schrieb: > Hi Carsten, > > On 7/14/06, Carsten Driesner <[EMAIL PROTECTED]> wrote: >> You can see that the configuration set "Factories" contains nodes for >> every appplication module, in the example >> "com.sun.star.frame.StartModule" and "com.sun.star.text.TextDocument". >> The property called "ooSetupFactoryWindowAttributes" stores the left,top >> position and the width and height in pixel. You can use the >> configuration API to change these values programmatically. > > thanks. this works! > > if you are interested in the solution, just have a look at example code > below. > >> I am not sure if the current implementation reads the values for every >> new window or if it just uses internal values. So it's possible that the >> values are only read once from the configuration at startup time. Be >> aware that these values will be overwritten when a user changes the >> position or size of an application window. > > it seems that the current implementation reads the attribue for every > new window and doesn't use internal values! > > here the example code: > > /** > * Diese Hilfsmethode liest das Attribut > ooSetupFactoryWindowAttributes aus > * dem Konfigurationsknoten > * > "/org.openoffice.Setup/Office/Factories/com.sun.star.text.TextDocument" > * der OOo-Konfiguration, welches die Standard-FensterAttribute > enthält, mit > * denen neue Fenster für TextDokumente erzeugt werden. > * > * @return > */ > private static String getDefaultWindowAttributes(XComponentContext > ctx) { > try { > Object cp = ctx.getServiceManager().createInstanceWithContext( > "com.sun.star.configuration.ConfigurationProvider", ctx); > > // creation arguments: nodepath > com.sun.star.beans.PropertyValue aPathArgument = new > com.sun.star.beans.PropertyValue(); > aPathArgument.Name = "nodepath"; > aPathArgument.Value = > "/org.openoffice.Setup/Office/Factories/com.sun.star.text.TextDocument"; > Object[] aArguments = new Object[1]; > aArguments[0] = aPathArgument; > > XMultiServiceFactory xmsf = (XMultiServiceFactory) UnoRuntime > .queryInterface(XMultiServiceFactory.class, cp); > Object ca = xmsf.createInstanceWithArguments( > "com.sun.star.configuration.ConfigurationUpdateAccess", > aArguments); > > XPropertySet prop = (XPropertySet) UnoRuntime.queryInterface( > XPropertySet.class, ca); > return prop > > .getPropertyValue("ooSetupFactoryWindowAttributes").toString(); > } catch (java.lang.Exception e) { > } > return null; > } > > /** > * Diese Hilfsmethode setzt das Attribut > ooSetupFactoryWindowAttributes aus > * dem Konfigurationsknoten > * > "/org.openoffice.Setup/Office/Factories/com.sun.star.text.TextDocument" > * der OOo-Konfiguration auf den neuen Wert value, der (am besten) über > * einen vorhergehenden Aufruf von getDefaultWindowAttributes() gewonnen > * wird. > * > * @param value > */ > private static void setDefaultWindowAttributes(XComponentContext ctx, > String value) { > try { > Object cp = ctx.getServiceManager().createInstanceWithContext( > "com.sun.star.configuration.ConfigurationProvider", ctx); > > // creation arguments: nodepath > com.sun.star.beans.PropertyValue aPathArgument = new > com.sun.star.beans.PropertyValue(); > aPathArgument.Name = "nodepath"; > aPathArgument.Value = > "/org.openoffice.Setup/Office/Factories/com.sun.star.text.TextDocument"; > Object[] aArguments = new Object[1]; > aArguments[0] = aPathArgument; > > XMultiServiceFactory xmsf = (XMultiServiceFactory) UnoRuntime > .queryInterface(XMultiServiceFactory.class, cp); > Object ca = xmsf.createInstanceWithArguments( > "com.sun.star.configuration.ConfigurationUpdateAccess", > aArguments); > > XPropertySet prop = (XPropertySet) UnoRuntime.queryInterface( > XPropertySet.class, ca); > prop.setPropertyValue("ooSetupFactoryWindowAttributes", value); > > XChangesBatch committer = (XChangesBatch) UnoRuntime > .queryInterface(XChangesBatch.class, ca); > committer.commitChanges(); > } catch (java.lang.Exception e) { > } > } > > regards, > Christoph > > --------------------------------------------------------------------- > 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]