Hi to all,
i have OOoBean (with OO2.0.3) in a javabean, i need to disable some kind
of command (like Open,Exit,etc...) i use the code that is in the
developers guide also to disable and then re-enable command when the
user close OOoBean. All is ok, but if i re-open the Javabean OO crash...
i think that the problem is in the enable code...
with OfficeBean and OO1.1.4 i don't have this kind of problems...
Someone have the same problem??
I use this code:
public void enableCommandsURLSet() {
// Set the root path for our configuration access
com.sun.star.beans.PropertyValue[] lParams =
new com.sun.star.beans.PropertyValue[1];
XComponentContext xRemoteContext = null;
XMultiComponentFactory xRemoteServiceManager = null;
XMultiServiceFactory xConfigProvider = null;
//Viene istanziato il percorso all'interno del file XML per la
gestione dei comandi disabilitati
lParams[0] = new com.sun.star.beans.PropertyValue();
lParams[0].Name = "nodepath";
lParams[0].Value =
"/org.openoffice.Office.Commands/Execute/Disabled";
try {
try {
//Connessione ad una istanza di Soffice
xRemoteContext =
com.sun.star.comp.helper.Bootstrap.bootstrap();
} catch (BootstrapException e) {
e.printStackTrace();
}
System.out.println("Riabilitazione dei comandi ...");
xRemoteServiceManager = xRemoteContext.getServiceManager();
Object configProvider =
xRemoteServiceManager.createInstanceWithContext(
"com.sun.star.configuration.ConfigurationProvider",
xRemoteContext );
xConfigProvider = (com.sun.star.lang.XMultiServiceFactory)
UnoRuntime.queryInterface(
com.sun.star.lang.XMultiServiceFactory.class,
configProvider );
// Create configuration update access to have write access
to the
// configuration
Object xAccess = xConfigProvider.createInstanceWithArguments(
"com.sun.star.configuration.ConfigurationUpdateAccess",
lParams );
com.sun.star.container.XNameAccess xNameAccess =
(com.sun.star.container.XNameAccess)UnoRuntime.queryInterface(
com.sun.star.container.XNameAccess.class, xAccess );
if ( xNameAccess != null ) {
// We need the XNameContainer interface to remove the
nodes by name
com.sun.star.container.XNameContainer xNameContainer =
(com.sun.star.container.XNameContainer)
UnoRuntime.queryInterface(
com.sun.star.container.XNameContainer.class,
xAccess );
// Retrieves the names of all Disabled nodes
String[] aCommandsSeq = xNameAccess.getElementNames();
for ( int n = 0; n < aCommandsSeq.length; n++ ) {
try {
// remove the node
xNameContainer.removeByName( aCommandsSeq[n] );
}
catch ( com.sun.star.lang.WrappedTargetException e ) {
}
catch (
com.sun.star.container.NoSuchElementException e ) {
}
}
}
// Commit our changes
com.sun.star.util.XChangesBatch xFlush =
(com.sun.star.util.XChangesBatch)UnoRuntime.queryInterface(
com.sun.star.util.XChangesBatch.class, xAccess);
xFlush.commitChanges();
}
catch ( com.sun.star.uno.Exception e ) {
System.out.println( "Exception detected!" );
System.out.println( e );
}
}
To bypass the problem, i try to install two versions of the same
OO2.0.3, one with the disable command for the OOoBean and one for the
normal usage.
But if i try to open from windows a document with OpenOffice when the
Javabean is already open, the system open it with the soffice version
without commands!
Thanks to all...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Dott. Cristian Fonti
mailto: [EMAIL PROTECTED]
c/o Sistemi Informativi - Resp. Web Area
SCM Group S.p.a. http://www.scmgroup.com
via Emilia, 77 - 47900 Rimini (RN), Italy
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]