8234393: [macos] printing ignores printer tray
Reviewed-by: psadhukhan, prr
This commit is contained in:
parent
3f9c8a3920
commit
3ee0380e99
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -44,6 +44,7 @@ import javax.print.attribute.standard.MediaPrintableArea;
|
||||
import javax.print.attribute.standard.MediaSize;
|
||||
import javax.print.attribute.standard.MediaSizeName;
|
||||
import javax.print.attribute.standard.PageRanges;
|
||||
import javax.print.attribute.Attribute;
|
||||
|
||||
import sun.java2d.*;
|
||||
import sun.print.*;
|
||||
@ -64,6 +65,8 @@ public final class CPrinterJob extends RasterPrinterJob {
|
||||
|
||||
private static Font defaultFont;
|
||||
|
||||
private String tray = null;
|
||||
|
||||
// This is the NSPrintInfo for this PrinterJob. Protect multi thread
|
||||
// access to it. It is used by the pageDialog, jobDialog, and printLoop.
|
||||
// This way the state of these items is shared across these calls.
|
||||
@ -179,6 +182,11 @@ public final class CPrinterJob extends RasterPrinterJob {
|
||||
if (attributes == null) {
|
||||
return;
|
||||
}
|
||||
Attribute attr = attributes.get(Media.class);
|
||||
if (attr instanceof CustomMediaTray) {
|
||||
CustomMediaTray customTray = (CustomMediaTray) attr;
|
||||
tray = customTray.getChoiceName();
|
||||
}
|
||||
|
||||
PageRanges pageRangesAttr = (PageRanges)attributes.get(PageRanges.class);
|
||||
if (isSupportedValue(pageRangesAttr, attributes)) {
|
||||
@ -631,6 +639,10 @@ public final class CPrinterJob extends RasterPrinterJob {
|
||||
return service.getName();
|
||||
}
|
||||
|
||||
private String getPrinterTray() {
|
||||
return tray;
|
||||
}
|
||||
|
||||
private void setPrinterServiceFromNative(String printerName) {
|
||||
// This is called from the native side.
|
||||
PrintService[] services = PrintServiceLookup.lookupPrintServices(DocFlavor.SERVICE_FORMATTED.PAGEABLE, null);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -546,6 +546,7 @@ JNIEXPORT jboolean JNICALL Java_sun_lwawt_macosx_CPrinterJob_printLoop
|
||||
static JNF_MEMBER_CACHE(jm_getPageFormatArea, sjc_CPrinterJob, "getPageFormatArea", "(Ljava/awt/print/PageFormat;)Ljava/awt/geom/Rectangle2D;");
|
||||
static JNF_MEMBER_CACHE(jm_getPrinterName, sjc_CPrinterJob, "getPrinterName", "()Ljava/lang/String;");
|
||||
static JNF_MEMBER_CACHE(jm_getPageable, sjc_CPrinterJob, "getPageable", "()Ljava/awt/print/Pageable;");
|
||||
static JNF_MEMBER_CACHE(jm_getPrinterTray, sjc_CPrinterJob, "getPrinterTray", "()Ljava/lang/String;");
|
||||
|
||||
jboolean retVal = JNI_FALSE;
|
||||
|
||||
@ -560,6 +561,13 @@ JNF_COCOA_ENTER(env);
|
||||
[printerView setFirstPage:firstPage lastPage:lastPage];
|
||||
|
||||
NSPrintInfo* printInfo = (NSPrintInfo*)jlong_to_ptr(JNFCallLongMethod(env, jthis, sjm_getNSPrintInfo)); // AWT_THREADING Safe (known object)
|
||||
jobject printerTrayObj = JNFCallObjectMethod(env, jthis, jm_getPrinterTray);
|
||||
if (printerTrayObj != NULL) {
|
||||
NSString *printerTray = JNFJavaToNSString(env, printerTrayObj);
|
||||
if (printerTray != nil) {
|
||||
[[printInfo printSettings] setObject:printerTray forKey:@"InputSlot"];
|
||||
}
|
||||
}
|
||||
|
||||
// <rdar://problem/4156975> passing jthis CPrinterJob as well, so we can extract the printer name from the current job
|
||||
javaPageFormatToNSPrintInfo(env, jthis, page, printInfo);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -30,7 +30,7 @@ import javax.print.attribute.standard.MediaTray;
|
||||
import javax.print.attribute.standard.Media;
|
||||
import java.util.ArrayList;
|
||||
|
||||
class CustomMediaTray extends MediaTray {
|
||||
public class CustomMediaTray extends MediaTray {
|
||||
private static ArrayList<String> customStringTable = new ArrayList<>();
|
||||
private static ArrayList<MediaTray> customEnumTable = new ArrayList<>();
|
||||
private String choiceName;
|
||||
|
@ -21,9 +21,9 @@
|
||||
* questions.
|
||||
*/
|
||||
/*
|
||||
* @bug 6357887 8165146
|
||||
* @bug 6357887 8165146 8234393
|
||||
* @summary Verifies if selected printertray is used
|
||||
* @requires os.family == "linux"
|
||||
* @requires (os.family == "linux" | os.family == "mac")
|
||||
* @run main/manual TestMediaTraySelection
|
||||
*/
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user