--- old/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPrinterJob.java 2016-03-22 16:38:08.000000000 +0530 +++ new/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPrinterJob.java 2016-03-22 16:38:08.000000000 +0530 @@ -36,6 +36,7 @@ import javax.print.*; import javax.print.attribute.PrintRequestAttributeSet; import javax.print.attribute.HashPrintRequestAttributeSet; +import javax.print.attribute.standard.Copies; import javax.print.attribute.standard.Media; import javax.print.attribute.standard.MediaPrintableArea; import javax.print.attribute.standard.MediaSize; @@ -194,10 +195,39 @@ // setPageRange will set firstPage and lastPage as called in getFirstPage // and getLastPage setPageRange(range[0][0] - 1, range[0][1] - 1); + } else { + // if rangeSelect is SunPageSelection.ALL + // then setPageRange appropriately + setPageRange(-1, -1); } } } + private void setPageRangeAttribute(int from, int to, boolean isRangeSet) { + if (attributes != null) { + // since native Print use zero-based page indices, + // we need to store in 1-based format in attributes set + // but setPageRange again uses zero-based indices so it should be + // 1 less than pageRanges attribute + if (isRangeSet) { + attributes.add(new PageRanges(from+1, to+1)); + attributes.add(SunPageSelection.RANGE); + setPageRange(from, to); + } else { + attributes.add(SunPageSelection.ALL); + } + + } + } + + private void setCopiesAttribute(int copies) { + if (attributes != null) { + attributes.add(new Copies(copies)); + super.setCopies(copies); + } + } + + volatile boolean onEventThread; @Override @@ -606,7 +636,7 @@ page.getImageableHeight()); return pageFormatArea; } - + private boolean cancelCheck() { // This is called from the native side. @@ -653,7 +683,7 @@ Graphics2D delegate = new SunGraphics2D(sd, Color.black, Color.white, defaultFont); Graphics2D pathGraphics = new CPrinterGraphics(delegate, printerJob); // Just stores delegate into an ivar - Rectangle2D pageFormatArea = getPageFormatArea(page); + Rectangle2D pageFormatArea = getPageFormatArea(page); initPrinterGraphics(pathGraphics, pageFormatArea); painter.print(pathGraphics, page, pageIndex); delegate.dispose(); @@ -688,7 +718,7 @@ if (printable != null) { BufferedImage bimg = new BufferedImage((int)Math.round(pageFormat.getWidth()), (int)Math.round(pageFormat.getHeight()), BufferedImage.TYPE_INT_ARGB_PRE); PeekGraphics peekGraphics = createPeekGraphics(bimg.createGraphics(), printerJob); - Rectangle2D pageFormatArea = getPageFormatArea(pageFormat); + Rectangle2D pageFormatArea = getPageFormatArea(pageFormat); initPrinterGraphics(peekGraphics, pageFormatArea); // Do the assignment here!