changeset 7699:56c6f9a9653d

8016343: [macosx] Print job goes to default printer regardless of chosen printer Reviewed-by: jchen, prr
author jgodinez
date Fri, 26 Jul 2013 15:25:12 -0700
parents 467a0c21790b
children 921338e44ba7
files src/share/classes/sun/print/PSPrinterJob.java src/solaris/classes/sun/print/IPPPrintService.java src/solaris/classes/sun/print/UnixPrintJob.java test/javax/print/DialogMargins.java
diffstat 4 files changed, 44 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/sun/print/PSPrinterJob.java	Fri Jul 26 15:08:49 2013 -0700
+++ b/src/share/classes/sun/print/PSPrinterJob.java	Fri Jul 26 15:25:12 2013 -0700
@@ -59,6 +59,8 @@
 import javax.print.StreamPrintService;
 import javax.print.attribute.HashPrintRequestAttributeSet;
 import javax.print.attribute.PrintRequestAttributeSet;
+import javax.print.attribute.PrintServiceAttributeSet;
+import javax.print.attribute.standard.PrinterName;
 import javax.print.attribute.standard.Chromaticity;
 import javax.print.attribute.standard.Copies;
 import javax.print.attribute.standard.Destination;
@@ -471,6 +473,9 @@
                 PrintService pServ = getPrintService();
                 if (pServ != null) {
                     mDestination = pServ.getName();
+                    if (UnixPrintServiceLookup.isMac()) {
+                        mDestination = ((IPPPrintService)pServ).getDest();
+                    }
                 }
             }
         }
@@ -766,8 +771,12 @@
             }
         }
         if (mDestType == RasterPrinterJob.PRINTER) {
-            if (getPrintService() != null) {
-                mDestination = getPrintService().getName();
+            PrintService pServ = getPrintService();
+            if (pServ != null) {
+                mDestination = pServ.getName();
+                if (UnixPrintServiceLookup.isMac()) {
+                    mDestination = ((IPPPrintService)pServ).getDest();
+                }
             }
             PrinterSpooler spooler = new PrinterSpooler();
             java.security.AccessController.doPrivileged(spooler);
--- a/src/solaris/classes/sun/print/IPPPrintService.java	Fri Jul 26 15:08:49 2013 -0700
+++ b/src/solaris/classes/sun/print/IPPPrintService.java	Fri Jul 26 15:25:12 2013 -0700
@@ -1099,6 +1099,15 @@
 
         if (category == PrinterName.class) {
             return (T)(new PrinterName(printer, null));
+        } else if (category == PrinterInfo.class) {
+            PrinterInfo pInfo = new PrinterInfo(printer, null);
+            AttributeClass ac = (getAttMap != null) ?
+                (AttributeClass)getAttMap.get(pInfo.getName())
+                : null;
+            if (ac != null) {
+                return (T)(new PrinterInfo(ac.getStringValue(), null));
+            }
+            return (T)pInfo;
         } else if (category == QueuedJobCount.class) {
             QueuedJobCount qjc = new QueuedJobCount(0);
             AttributeClass ac = (getAttMap != null) ?
@@ -1566,7 +1575,24 @@
         }
     }
 
+    String getDest() {
+        return printer;
+    }
+
     public String getName() {
+        /*
+         * Mac is using printer-info IPP attribute for its human-readable printer
+         * name and is also the identifier used in NSPrintInfo:setPrinter.
+         */
+        if (UnixPrintServiceLookup.isMac()) {
+            PrintServiceAttributeSet psaSet = this.getAttributes();
+            if (psaSet != null) {
+                PrinterInfo pName = (PrinterInfo)psaSet.get(PrinterInfo.class);
+                if (pName != null) {
+                    return pName.toString();
+                }
+            }
+        }
         return printer;
     }
 
--- a/src/solaris/classes/sun/print/UnixPrintJob.java	Fri Jul 26 15:08:49 2013 -0700
+++ b/src/solaris/classes/sun/print/UnixPrintJob.java	Fri Jul 26 15:25:12 2013 -0700
@@ -65,6 +65,7 @@
 import javax.print.attribute.PrintJobAttributeSet;
 import javax.print.attribute.PrintRequestAttribute;
 import javax.print.attribute.PrintRequestAttributeSet;
+import javax.print.attribute.PrintServiceAttributeSet;
 import javax.print.attribute.standard.Copies;
 import javax.print.attribute.standard.Destination;
 import javax.print.attribute.standard.DocumentName;
@@ -76,6 +77,7 @@
 import javax.print.attribute.standard.MediaSize;
 import javax.print.attribute.standard.MediaSizeName;
 import javax.print.attribute.standard.OrientationRequested;
+import javax.print.attribute.standard.PrinterName;
 import javax.print.attribute.standard.RequestingUserName;
 import javax.print.attribute.standard.NumberUp;
 import javax.print.attribute.standard.Sides;
@@ -120,6 +122,9 @@
     UnixPrintJob(PrintService service) {
         this.service = service;
         mDestination = service.getName();
+        if (UnixPrintServiceLookup.isMac()) {
+            mDestination = ((IPPPrintService)service).getDest();
+        }
         mDestType = UnixPrintJob.DESTPRINTER;
     }
 
--- a/test/javax/print/DialogMargins.java	Fri Jul 26 15:08:49 2013 -0700
+++ b/test/javax/print/DialogMargins.java	Fri Jul 26 15:25:12 2013 -0700
@@ -25,11 +25,12 @@
 
 /**
  * @test
- * @bug 4485755 6361370 6448717 5080051 6939417
+ * @bug 4485755 6361370 6448717 5080051 6939417 8016343
  * @summary dialog doesn't have way to specify margins
  *          for 6361370, verify exception for offline printer in Windows
  *          for 6448717, faster display of print dialog
  *          for 6500903, verify status of printer if accepting jobs or not
+ *          for 8016343, verify printing to non-default printer
  * @author prr
  * @run main/manual DialogMargins
  */