To comment on the following update, log in, then open the issue:
http://www.openoffice.org/issues/show_bug.cgi?id=87495
------- Additional comments from [EMAIL PROTECTED] Thu Dec 4 10:32:13 +0000
2008 -------
Hi all,
it is already possible th get the printer trays / bins via API. Well, it's a bit
ugly, but it works:
-----%<-----
/**
* Getting the printer trays of a printer via OpenOffice.org. OpenOffice.org
* does not offer a method to get the printer tray names directly. But is
* offers a method, to get printer information and returns a String like
* this: "*;*;Tray Name; ;*;". This method derives the tray name from the
* string by detecting the sourrounding semicolons.
* @param printerName String with the name of the printer.
* @return String[] with the names of the printer trays.
*/
public String[] getPrinterTrays(String printerName) {
if(xPrinterServer == null)
initXPrinterServer();
XInfoPrinter xInfoPrinter =
xPrinterServer.createInfoPrinter(printerName);
// Print the trays received the OOo way
String ooTrays[] = xInfoPrinter.getFormDescriptions();
for(int i = 0; i < ooTrays.length; i++) {
String rangeRegex = "(.*;){2}[^;]{5,}";
Pattern pattern = Pattern.compile(rangeRegex);
Matcher matcher = pattern.matcher(ooTrays[i]);
while(matcher.find()){
String ooTray = matcher.group();
ooTrays[i] = ooTray.substring(ooTray.lastIndexOf(";")
+ 1);
}
}
return ooTrays;
}
-----%<-----
Concerning this issue, it would be nice, if OOo offers this information in a
better way.
The other thing is setting the paper tray / bin when printing. As the snippet
shows, this is a lot of work and only works for OOo writer and spreadsheet.
Presentation,... have no way to print on different trays / bins via API. Here is
the solution I dream of (you already mentioned it):
-----%<-----
// Querying for the interface XPrintable on the loaded document
XPrintable xPrintable = (XPrintable)
UnoRuntime.queryInterface(XPrintable.class, this.xComponent);
// Setting the property "Name" for the favoured printer
PropertyValue[] printerDesc = new PropertyValue[1];
printerDesc[0] = new PropertyValue();
printerDesc[0].Name = "Name";
printerDesc[0].Value = printerName;
try {
// Setting the name of the printer
xPrintable.setPrinter(printerDesc);
} catch (IllegalArgumentException ignore) {}
// Setting the property "Pages" so that only the desired pages
// will be printed.
PropertyValue[] printOpts = new PropertyValue[2];
printOpts[0] = new PropertyValue();
printOpts[0].Name = "Pages";
printOpts[0].Value = myPages;
// !!!Here my whish!!!
printOpts[1] = new PropertyValue();
printOpts[1].Name = "PaperBin";
printOpts[1].Value = "Cassette 1";
try {
xPrintable.print(printOpts);
} catch (IllegalArgumentException ignore) {}
-----%<-----
Greetings, Tobias
---------------------------------------------------------------------
Please do not reply to this automatically generated notification from
Issue Tracker. Please log onto the website and enter your comments.
http://qa.openoffice.org/issue_handling/project_issues.html#notification
---------------------------------------------------------------------
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]