19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package sun.lwawt.macosx;
27
28
29 import java.awt.*;
30 import java.awt.geom.Rectangle2D;
31 import java.awt.image.BufferedImage;
32 import java.awt.print.*;
33 import java.security.AccessController;
34 import java.security.PrivilegedAction;
35
36 import javax.print.*;
37 import javax.print.attribute.PrintRequestAttributeSet;
38 import javax.print.attribute.HashPrintRequestAttributeSet;
39 import javax.print.attribute.standard.Media;
40 import javax.print.attribute.standard.MediaPrintableArea;
41 import javax.print.attribute.standard.MediaSize;
42 import javax.print.attribute.standard.MediaSizeName;
43 import javax.print.attribute.standard.PageRanges;
44
45 import sun.java2d.*;
46 import sun.misc.ManagedLocalsThread;
47 import sun.print.*;
48
49 public final class CPrinterJob extends RasterPrinterJob {
50 // NOTE: This uses RasterPrinterJob as a base, but it doesn't use
51 // all of the RasterPrinterJob functions. RasterPrinterJob will
52 // break down printing to pieces that aren't necessary under MacOSX
53 // printing, such as controlling the # of copies and collating. These
54 // are handled by the native printing. RasterPrinterJob is kept for
55 // future compatibility and the state keeping that it handles.
56
57 private static String sShouldNotReachHere = "Should not reach here.";
58
181 // See if this has an NSPrintInfo in it.
182 NSPrintInfo nsPrintInfo = (NSPrintInfo)attributes.get(NSPrintInfo.class);
183 if (nsPrintInfo != null) {
184 fNSPrintInfo = nsPrintInfo.getValue();
185 }
186
187 PageRanges pageRangesAttr = (PageRanges)attributes.get(PageRanges.class);
188 if (isSupportedValue(pageRangesAttr, attributes)) {
189 SunPageSelection rangeSelect = (SunPageSelection)attributes.get(SunPageSelection.class);
190 // If rangeSelect is not null, we are using AWT's print dialog that has
191 // All, Selection, and Range radio buttons
192 if (rangeSelect == null || rangeSelect == SunPageSelection.RANGE) {
193 int[][] range = pageRangesAttr.getMembers();
194 // setPageRange will set firstPage and lastPage as called in getFirstPage
195 // and getLastPage
196 setPageRange(range[0][0] - 1, range[0][1] - 1);
197 }
198 }
199 }
200
201 volatile boolean onEventThread;
202
203 @Override
204 protected void cancelDoc() throws PrinterAbortException {
205 super.cancelDoc();
206 if (printingLoop != null) {
207 printingLoop.exit();
208 }
209 }
210
211 private void completePrintLoop() {
212 Runnable r = new Runnable() { public void run() {
213 synchronized(this) {
214 performingPrinting = false;
215 }
216 if (printingLoop != null) {
217 printingLoop.exit();
218 }
219 }};
220
|
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package sun.lwawt.macosx;
27
28
29 import java.awt.*;
30 import java.awt.geom.Rectangle2D;
31 import java.awt.image.BufferedImage;
32 import java.awt.print.*;
33 import java.security.AccessController;
34 import java.security.PrivilegedAction;
35
36 import javax.print.*;
37 import javax.print.attribute.PrintRequestAttributeSet;
38 import javax.print.attribute.HashPrintRequestAttributeSet;
39 import javax.print.attribute.standard.Copies;
40 import javax.print.attribute.standard.Media;
41 import javax.print.attribute.standard.MediaPrintableArea;
42 import javax.print.attribute.standard.MediaSize;
43 import javax.print.attribute.standard.MediaSizeName;
44 import javax.print.attribute.standard.PageRanges;
45
46 import sun.java2d.*;
47 import sun.misc.ManagedLocalsThread;
48 import sun.print.*;
49
50 public final class CPrinterJob extends RasterPrinterJob {
51 // NOTE: This uses RasterPrinterJob as a base, but it doesn't use
52 // all of the RasterPrinterJob functions. RasterPrinterJob will
53 // break down printing to pieces that aren't necessary under MacOSX
54 // printing, such as controlling the # of copies and collating. These
55 // are handled by the native printing. RasterPrinterJob is kept for
56 // future compatibility and the state keeping that it handles.
57
58 private static String sShouldNotReachHere = "Should not reach here.";
59
182 // See if this has an NSPrintInfo in it.
183 NSPrintInfo nsPrintInfo = (NSPrintInfo)attributes.get(NSPrintInfo.class);
184 if (nsPrintInfo != null) {
185 fNSPrintInfo = nsPrintInfo.getValue();
186 }
187
188 PageRanges pageRangesAttr = (PageRanges)attributes.get(PageRanges.class);
189 if (isSupportedValue(pageRangesAttr, attributes)) {
190 SunPageSelection rangeSelect = (SunPageSelection)attributes.get(SunPageSelection.class);
191 // If rangeSelect is not null, we are using AWT's print dialog that has
192 // All, Selection, and Range radio buttons
193 if (rangeSelect == null || rangeSelect == SunPageSelection.RANGE) {
194 int[][] range = pageRangesAttr.getMembers();
195 // setPageRange will set firstPage and lastPage as called in getFirstPage
196 // and getLastPage
197 setPageRange(range[0][0] - 1, range[0][1] - 1);
198 }
199 }
200 }
201
202 private void setPageRangeAttribute(int from, int to) {
203 if (attributes != null) {
204 attributes.add(new PageRanges(from, to));
205 setPageRange(from, to);
206 }
207 }
208
209 private void setCopiesAttribute(int copies) {
210 attributes.add(new Copies(copies));
211 super.setCopies(copies);
212 }
213
214
215 volatile boolean onEventThread;
216
217 @Override
218 protected void cancelDoc() throws PrinterAbortException {
219 super.cancelDoc();
220 if (printingLoop != null) {
221 printingLoop.exit();
222 }
223 }
224
225 private void completePrintLoop() {
226 Runnable r = new Runnable() { public void run() {
227 synchronized(this) {
228 performingPrinting = false;
229 }
230 if (printingLoop != null) {
231 printingLoop.exit();
232 }
233 }};
234
|