7183520: [macosx]Unable to print out the defined page for 2D_PrintingTiger/JTablePrintPageRangesTest
Reviewed-by: bae, prr
This commit is contained in:
parent
e418c51f5a
commit
0415127a27
@ -36,6 +36,7 @@ import java.security.PrivilegedAction;
|
|||||||
import javax.print.*;
|
import javax.print.*;
|
||||||
import javax.print.attribute.PrintRequestAttributeSet;
|
import javax.print.attribute.PrintRequestAttributeSet;
|
||||||
import javax.print.attribute.HashPrintRequestAttributeSet;
|
import javax.print.attribute.HashPrintRequestAttributeSet;
|
||||||
|
import javax.print.attribute.standard.PageRanges;
|
||||||
|
|
||||||
import sun.java2d.*;
|
import sun.java2d.*;
|
||||||
import sun.print.*;
|
import sun.print.*;
|
||||||
@ -173,6 +174,19 @@ public class CPrinterJob extends RasterPrinterJob {
|
|||||||
if (nsPrintInfo != null) {
|
if (nsPrintInfo != null) {
|
||||||
fNSPrintInfo = nsPrintInfo.getValue();
|
fNSPrintInfo = nsPrintInfo.getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PageRanges pageRangesAttr = (PageRanges)attributes.get(PageRanges.class);
|
||||||
|
if (isSupportedValue(pageRangesAttr, attributes)) {
|
||||||
|
SunPageSelection rangeSelect = (SunPageSelection)attributes.get(SunPageSelection.class);
|
||||||
|
// If rangeSelect is not null, we are using AWT's print dialog that has
|
||||||
|
// All, Selection, and Range radio buttons
|
||||||
|
if (rangeSelect == null || rangeSelect == SunPageSelection.RANGE) {
|
||||||
|
int[][] range = pageRangesAttr.getMembers();
|
||||||
|
// setPageRange will set firstPage and lastPage as called in getFirstPage
|
||||||
|
// and getLastPage
|
||||||
|
setPageRange(range[0][0] - 1, range[0][1] - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
volatile boolean onEventThread;
|
volatile boolean onEventThread;
|
||||||
@ -225,7 +239,6 @@ public class CPrinterJob extends RasterPrinterJob {
|
|||||||
* the end of the document. Note that firstPage
|
* the end of the document. Note that firstPage
|
||||||
* and lastPage are 0 based page indices.
|
* and lastPage are 0 based page indices.
|
||||||
*/
|
*/
|
||||||
int numPages = mDocument.getNumberOfPages();
|
|
||||||
|
|
||||||
int firstPage = getFirstPage();
|
int firstPage = getFirstPage();
|
||||||
int lastPage = getLastPage();
|
int lastPage = getLastPage();
|
||||||
@ -242,6 +255,12 @@ public class CPrinterJob extends RasterPrinterJob {
|
|||||||
userCancelled = false;
|
userCancelled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Add support for PageRange
|
||||||
|
PageRanges pr = (attributes == null) ? null
|
||||||
|
: (PageRanges)attributes.get(PageRanges.class);
|
||||||
|
int[][] prMembers = (pr == null) ? new int[0][0] : pr.getMembers();
|
||||||
|
int loopi = 0;
|
||||||
|
do {
|
||||||
if (EventQueue.isDispatchThread()) {
|
if (EventQueue.isDispatchThread()) {
|
||||||
// This is an AWT EventQueue, and this print rendering loop needs to block it.
|
// This is an AWT EventQueue, and this print rendering loop needs to block it.
|
||||||
|
|
||||||
@ -278,6 +297,11 @@ public class CPrinterJob extends RasterPrinterJob {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (++loopi < prMembers.length) {
|
||||||
|
firstPage = prMembers[loopi][0]-1;
|
||||||
|
lastPage = prMembers[loopi][1] -1;
|
||||||
|
}
|
||||||
|
} while (loopi < prMembers.length);
|
||||||
} finally {
|
} finally {
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
// NOTE: Native code shouldn't allow exceptions out while
|
// NOTE: Native code shouldn't allow exceptions out while
|
||||||
|
Loading…
x
Reference in New Issue
Block a user