Cancel Print Event
Cancel Print Event
Hi, I am creating a java extension for openoffice and I am able to successfully trigger print event through code but i am not able to cancel the print event from my dialog.I referred this link https://www.openoffice.org/api/docs/com ... ntJob.html. and here there is a method called cancelJob .I call that when my response was no but its not cancelling the print. Please help me find a solution
OpenOffice 4.1.15 on Windows11
Re: How to cancel Print Event?
Have you installed the listener to investigate what's happening using that?
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
Re: How to cancel Print Event?
yes on installing the listener i call this msg box on Ctrl+P.
which if they click NO,i did this;
Code: Select all
XMessageBox xMessageBox = xMsgBoxFactory.createMessageBox(
(XWindowPeer) parentWindow,
com.sun.star.awt.MessageBoxType.QUERYBOX,
com.sun.star.awt.MessageBoxButtons.BUTTONS_YES_NO,
"Print Confirmation",
"Do you want to proceed with printing?");
short result = xMessageBox.execute();
// Check user response
if (result == MessageBoxResults.YES) {
logEvent("User chose to print the document.");
return true;
} else {
logEvent("User chose to cancel printing.");
return false;
}
Code: Select all
boolean proceedWithPrint = askForPrintConfirmation();
if (!proceedWithPrint) {
try {
// Cancel the print job
XPrintJob printJob = UnoRuntime.queryInterface(XPrintJob.class, event.Source);
if (printJob != null) {
printJob.cancelJob();
logEvent("Printing cancelled by the user.");
} else {
logEvent("Could not obtain XPrintJob interface.");
}
} catch (Exception e) {
logEvent("Error canceling print job: " + e.getMessage());
e.printStackTrace();
}
OpenOffice 4.1.15 on Windows11