- Notifications
You must be signed in to change notification settings - Fork 5.8k
7179006: [macosx] Print-to-file doesn't work: printing to the default printer instead.#339
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
👋 Welcome back prr! A progress list of the required criteria for merging this PR into |
@prrace The following label will be automatically applied to this pull request: When this pull request is ready to be reviewed, an RFR email will be sent to the corresponding mailing list. If you would like to change these labels, use the |
label /remove awt |
/label add 2d |
@prrace |
/label remove awt |
@prrace |
Webrevs
|
//NSURL *nsURL = [NSURL URLWithString:nsDestStr]; | ||
NSURL *nsURL = [NSURL fileURLWithPath:nsDestStr isDirectory:NO]; | ||
[printingDictionary setObject:nsURL forKey:NSPrintJobSavingURL]; | ||
// JNFCallVoidMethod(env, dstPrinterJob, jm_setPrintToFile, true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it look like the commented lines are not needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm. I could swear I removed those and re-ordered the first two lines as well.
pj.print(pSet); | ||
if (!file.exists()) { | ||
throw new RuntimeException("No file created"); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we need to delete the file in finally block, if created.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant to leave it. So we can look at it if we need to.
@@ -251,6 +253,22 @@ private void setPrintToFile(boolean printToFile) { | |||
isPrintToFile = printToFile; | |||
} | |||
private void setDestinationFile(String dest) { | |||
System.out.println("dest="+dest+" attrs="+attributes); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably this println should be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops
try { | ||
URI destURI = new URI(dest); | ||
attributes.add(new Destination(destURI)); | ||
destinationAttr = "" + destURI.getSchemeSpecificPart(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This destinationAttr in the RasterPrinterJob is usually assigned to:
destinationAttr = "" + new File(destination.getURI().
getSchemeSpecificPart());
Do we need to do the same here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see that in WPrinterJob.java we do the same as I am doing here.
I think the difference in RPJ may bethat we want to get a full path name which is what the new File did.
Here macOS gives us a full path name already. So I don't think it is needed.
It gave the required value for sure.
NSURL *url = [printingDictionary objectForKey:NSPrintJobSavingURL]; | ||
NSString *nsStr = [url absoluteString]; | ||
jstring str = JNFNSToJavaString(env, nsStr); | ||
JNFCallVoidMethod(env, dstPrinterJob, jm_setDestinationFile, str); | ||
} else { | ||
JNFCallVoidMethod(env, dstPrinterJob, jm_setPrintToFile, false); | ||
} | ||
// get the selected printer's name, and set the appropriate PrintService on the Java side |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment need to be moved up as well?
Updated with the comment moved. |
@prrace This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for more details. After integration, the commit message for the final commit will be:
You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 52 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. ➡️ To integrate this PR with the above commit message to the |
/integrate |
@prrace Since your change was applied there have been 52 commits pushed to the
Your commit was automatically rebased without conflicts. Pushed as commit ea7c47c. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
A long-standing bug on macOS: https://bugs.openjdk.java.net/browse/JDK-7179006
The fix is to propagate whatever is set as the Destination down to native and set it on the native printing object.
Also if using the native dialog, but with attributes, copy back the destination from native to the Java attribute set.
The new test can directly test printing to file in an automated way - so long as there is a printer.
The updated manual test can be used to verify the cross-platform dialog case.
Progress
Issue
Reviewers
Download
$ git fetch https://git.openjdk.java.net/jdk pull/339/head:pull/339
$ git checkout pull/339