From fbb2220d00a962960beb2b61bdfc42ede1c01af7 Mon Sep 17 00:00:00 2001 From: Jennifer Godinez Date: Wed, 9 Apr 2008 15:16:57 -0700 Subject: [PATCH] 6633656: Cross platform print dialog doesn't check for orientation being unsupported Reviewed-by: prr, tdv --- .../classes/sun/print/ServiceDialog.java | 73 ++++++++++--------- .../classes/sun/print/AttributeClass.java | 1 + .../classes/sun/print/IPPPrintService.java | 70 +++++++++++++----- 3 files changed, 91 insertions(+), 53 deletions(-) diff --git a/jdk/src/share/classes/sun/print/ServiceDialog.java b/jdk/src/share/classes/sun/print/ServiceDialog.java index 8d94ac44bfe..40488eebc1f 100644 --- a/jdk/src/share/classes/sun/print/ServiceDialog.java +++ b/jdk/src/share/classes/sun/print/ServiceDialog.java @@ -2149,48 +2149,55 @@ public class ServiceDialog extends JDialog implements ActionListener { } } } - } - rbPortrait.setEnabled(pSupported); - rbLandscape.setEnabled(lSupported); - rbRevPortrait.setEnabled(rpSupported); - rbRevLandscape.setEnabled(rlSupported); - OrientationRequested or = (OrientationRequested)asCurrent.get(orCategory); - if (or == null || - !psCurrent.isAttributeValueSupported(or, docFlavor, asCurrent)) { + rbPortrait.setEnabled(pSupported); + rbLandscape.setEnabled(lSupported); + rbRevPortrait.setEnabled(rpSupported); + rbRevLandscape.setEnabled(rlSupported); - or = (OrientationRequested)psCurrent.getDefaultAttributeValue(orCategory); - // need to validate if default is not supported - if (!psCurrent.isAttributeValueSupported(or, docFlavor, asCurrent)) { - or = null; - Object values = - psCurrent.getSupportedAttributeValues(orCategory, - docFlavor, - asCurrent); - if (values instanceof OrientationRequested[]) { - OrientationRequested[] orValues = + OrientationRequested or = (OrientationRequested)asCurrent.get(orCategory); + if (or == null || + !psCurrent.isAttributeValueSupported(or, docFlavor, asCurrent)) { + + or = (OrientationRequested)psCurrent.getDefaultAttributeValue(orCategory); + // need to validate if default is not supported + if (!psCurrent.isAttributeValueSupported(or, docFlavor, asCurrent)) { + or = null; + values = + psCurrent.getSupportedAttributeValues(orCategory, + docFlavor, + asCurrent); + if (values instanceof OrientationRequested[]) { + OrientationRequested[] orValues = (OrientationRequested[])values; - if (orValues.length > 1) { - // get the first in the list - or = orValues[0]; + if (orValues.length > 1) { + // get the first in the list + or = orValues[0]; + } } } + + if (or == null) { + or = OrientationRequested.PORTRAIT; + } + asCurrent.add(or); } - if (or == null) { - or = OrientationRequested.PORTRAIT; + if (or == OrientationRequested.PORTRAIT) { + rbPortrait.setSelected(true); + } else if (or == OrientationRequested.LANDSCAPE) { + rbLandscape.setSelected(true); + } else if (or == OrientationRequested.REVERSE_PORTRAIT) { + rbRevPortrait.setSelected(true); + } else { // if (or == OrientationRequested.REVERSE_LANDSCAPE) + rbRevLandscape.setSelected(true); } - asCurrent.add(or); - } + } else { + rbPortrait.setEnabled(pSupported); + rbLandscape.setEnabled(lSupported); + rbRevPortrait.setEnabled(rpSupported); + rbRevLandscape.setEnabled(rlSupported); - if (or == OrientationRequested.PORTRAIT) { - rbPortrait.setSelected(true); - } else if (or == OrientationRequested.LANDSCAPE) { - rbLandscape.setSelected(true); - } else if (or == OrientationRequested.REVERSE_PORTRAIT) { - rbRevPortrait.setSelected(true); - } else { // if (or == OrientationRequested.REVERSE_LANDSCAPE) - rbRevLandscape.setSelected(true); } } } diff --git a/jdk/src/solaris/classes/sun/print/AttributeClass.java b/jdk/src/solaris/classes/sun/print/AttributeClass.java index 93d19c29478..e1014125782 100644 --- a/jdk/src/solaris/classes/sun/print/AttributeClass.java +++ b/jdk/src/solaris/classes/sun/print/AttributeClass.java @@ -32,6 +32,7 @@ public class AttributeClass { private int nameLen; private Object myValue; + public static final int TAG_UNSUPPORTED_VALUE = 0x10; public static final int TAG_INT = 0x21; public static final int TAG_BOOL = 0x22; public static final int TAG_ENUM = 0x23; diff --git a/jdk/src/solaris/classes/sun/print/IPPPrintService.java b/jdk/src/solaris/classes/sun/print/IPPPrintService.java index 4c787c1f9d1..7c63b0d3dc3 100644 --- a/jdk/src/solaris/classes/sun/print/IPPPrintService.java +++ b/jdk/src/solaris/classes/sun/print/IPPPrintService.java @@ -621,17 +621,8 @@ public class IPPPrintService implements PrintService, SunPrinterJobService { } } } else if (category == OrientationRequested.class) { - if (flavor == null || - flavor.equals(DocFlavor.SERVICE_FORMATTED.PAGEABLE) || - flavor.equals(DocFlavor.SERVICE_FORMATTED.PRINTABLE)) { - // Orientation is emulated in Pageable/Printable flavors - // so we report the 3 orientations as supported. - OrientationRequested []orientSup = new OrientationRequested[3]; - orientSup[0] = OrientationRequested.PORTRAIT; - orientSup[1] = OrientationRequested.LANDSCAPE; - orientSup[2] = OrientationRequested.REVERSE_LANDSCAPE; - return orientSup; - } + boolean revPort = false; + OrientationRequested[] orientSup = null; AttributeClass attribClass = (getAttMap != null) ? (AttributeClass)getAttMap.get("orientation-requested-supported") @@ -639,7 +630,7 @@ public class IPPPrintService implements PrintService, SunPrinterJobService { if (attribClass != null) { int[] orientArray = attribClass.getArrayOfIntValues(); if ((orientArray != null) && (orientArray.length > 0)) { - OrientationRequested[] orientSup = + orientSup = new OrientationRequested[orientArray.length]; for (int i=0; i= AttributeClass.TAG_INT && + while (response[0] >= AttributeClass.TAG_UNSUPPORTED_VALUE && response[0] <= AttributeClass.TAG_MEMBER_ATTRNAME) { // read name length len = ois.readShort(); @@ -1710,12 +1736,16 @@ public class IPPPrintService implements PrintService, SunPrinterJobService { respList.add(responseMap); responseMap = new HashMap(); } - AttributeClass ac = - new AttributeClass(attribStr, - valTagByte, - outArray); - responseMap.put(ac.getName(), ac); + // exclude those that are unknown + if (valTagByte >= AttributeClass.TAG_INT) { + AttributeClass ac = + new AttributeClass(attribStr, + valTagByte, + outArray); + + responseMap.put(ac.getName(), ac); + } outObj = new ByteArrayOutputStream(); counter = 0; //reset counter