提交 b62e601e 编写于 作者: P prr

Merge

......@@ -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)) {
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 =
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)) {
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);
}
}
}
......
......@@ -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;
......
......@@ -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<orientArray.length; i++) {
switch (orientArray[i]) {
......@@ -657,12 +648,33 @@ public class IPPPrintService implements PrintService, SunPrinterJobService {
case 6:
orientSup[i] =
OrientationRequested.REVERSE_PORTRAIT;
revPort = true;
break;
}
}
return orientSup;
}
}
if (flavor == null ||
flavor.equals(DocFlavor.SERVICE_FORMATTED.PAGEABLE) ||
flavor.equals(DocFlavor.SERVICE_FORMATTED.PRINTABLE)) {
if (revPort && flavor == null) {
OrientationRequested []orSup = new OrientationRequested[4];
orSup[0] = OrientationRequested.PORTRAIT;
orSup[1] = OrientationRequested.LANDSCAPE;
orSup[2] = OrientationRequested.REVERSE_LANDSCAPE;
orSup[3] = OrientationRequested.REVERSE_PORTRAIT;
return orSup;
} else {
OrientationRequested []orSup = new OrientationRequested[3];
orSup[0] = OrientationRequested.PORTRAIT;
orSup[1] = OrientationRequested.LANDSCAPE;
orSup[2] = OrientationRequested.REVERSE_LANDSCAPE;
return orSup;
}
} else {
return orientSup;
}
} else if (category == PageRanges.class) {
if (flavor == null ||
flavor.equals(DocFlavor.SERVICE_FORMATTED.PAGEABLE) ||
......@@ -991,6 +1003,14 @@ public class IPPPrintService implements PrintService, SunPrinterJobService {
getSupportedAttributeCategories();
}
// It is safe to assume that Orientation is always supported
// and even if CUPS or an IPP device reports it as not,
// our renderer can do portrait, landscape and
// reverse landscape.
if (category == OrientationRequested.class) {
return true;
}
for (int i=0;i<supportedCats.length;i++) {
if (category == supportedCats[i]) {
return true;
......@@ -1602,7 +1622,13 @@ public class IPPPrintService implements PrintService, SunPrinterJobService {
public static boolean writeIPPRequest(OutputStream os,
String operCode,
AttributeClass[] attCl) {
OutputStreamWriter osw = new OutputStreamWriter(os);
OutputStreamWriter osw;
try {
osw = new OutputStreamWriter(os, "UTF-8");
} catch (java.io.UnsupportedEncodingException exc) {
debug_println("UTF-8 not supported? Exception: "+exc);
return false;
}
char[] opCode = new char[2];
opCode[0] = (char)Byte.parseByte(operCode.substring(0,2), 16);
opCode[1] = (char)Byte.parseByte(operCode.substring(2,4), 16);
......@@ -1690,7 +1716,7 @@ public class IPPPrintService implements PrintService, SunPrinterJobService {
// read value tag
response[0] = ois.readByte();
while (response[0] >= 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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册