Hi,
The documentation regarding Disabling commands is very good, take a look at:
http://wiki.services.openoffice.org/wik ... e_Commands
To disable Print you have to put the "Print" command into the disabled list in the Configuration Manager.
Additionaly, the entire list of command names is here:
http://wiki.services.openoffice.org/wik ... x_Commands
Based on the example listed in the DevGuide:
Code: Select all
private void disableCommands(String[] commandURL, String commandName) {
// Set the root path for our configuration access
try {
com.sun.star.beans.PropertyValue[] lParams = new com.sun.star.beans.PropertyValue[1];
lParams[0] = new com.sun.star.beans.PropertyValue();
lParams[0].Name = new String("nodepath");
lParams[0].Value = "/org.openoffice.Office.Commands/Execute/Disabled";
// Create configuration update access to have write access to the configuration
Object xAccess = xConfigProvider.createInstanceWithArguments(
"com.sun.star.configuration.ConfigurationUpdateAccess", lParams);
com.sun.star.lang.XSingleServiceFactory xSetElementFactory =
(com.sun.star.lang.XSingleServiceFactory)UnoRuntime.queryInterface(
com.sun.star.lang.XSingleServiceFactory.class, xAccess);
com.sun.star.container.XNameContainer xNameContainer =
(com.sun.star.container.XNameContainer)UnoRuntime.queryInterface(
com.sun.star.container.XNameContainer.class, xAccess );
if (xSetElementFactory != null && xNameContainer != null) {
Object[] aArgs = new Object[0];
for (int i = 0; i < commandURL.length; i++) {
// Create the nodes with the XSingleServiceFactory of the configuration
Object xNewElement = xSetElementFactory.createInstanceWithArguments( aArgs );
if (xNewElement != null) {
// We have a new node. To set the properties of the node we need
// the XPropertySet interface.
com.sun.star.beans.XPropertySet xPropertySet =
(com.sun.star.beans.XPropertySet)UnoRuntime.queryInterface(
com.sun.star.beans.XPropertySet.class,
xNewElement );
if (xPropertySet != null) {
// Create a unique node name.
String aCmdNodeName = commandName;
aCmdNodeName += i;
// Insert the node into the Disabled set
xPropertySet.setPropertyValue("Command", commandURL[i]);
xNameContainer.insertByName(aCmdNodeName, xNewElement);
}
}
}
// 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);
}
}
And then use it like this:
Code: Select all
String[] url = {"Print"};
String suffix = "x";
disableCommands( url, suffix);