src/java.desktop/windows/classes/sun/awt/windows/WPrinterJob.java

Print this page


   1 /*
   2  * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  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.awt.windows;
  27 
  28 import java.awt.Color;
  29 import java.awt.Font;
  30 import java.awt.Graphics2D;
  31 import java.awt.GraphicsEnvironment;
  32 import java.awt.HeadlessException;
  33 import java.awt.KeyboardFocusManager;
  34 import java.awt.Toolkit;
  35 import java.awt.BasicStroke;
  36 import java.awt.Button;
  37 import java.awt.Component;
  38 import java.awt.Dimension;
  39 import java.awt.Event;
  40 import java.awt.event.ActionEvent;
  41 import java.awt.event.ActionListener;
  42 import java.awt.FileDialog;
  43 import java.awt.Dialog;
  44 import java.awt.Label;
  45 import java.awt.Panel;
  46 import java.awt.Rectangle;
  47 import java.awt.Window;
  48 
  49 import java.awt.image.BufferedImage;
  50 import java.awt.image.IndexColorModel;
  51 
  52 import java.awt.print.Pageable;
  53 import java.awt.print.PageFormat;
  54 import java.awt.print.Paper;
  55 import java.awt.print.Printable;
  56 import java.awt.print.PrinterJob;
  57 import java.awt.print.PrinterException;
  58 import javax.print.PrintService;
  59 
  60 import java.io.File;
  61 
  62 import java.util.MissingResourceException;
  63 import java.util.ResourceBundle;
  64 


  65 import sun.print.PeekGraphics;
  66 import sun.print.PeekMetrics;
  67 
  68 import java.net.URI;
  69 import java.net.URISyntaxException;
  70 
  71 import javax.print.PrintServiceLookup;
  72 import javax.print.attribute.PrintRequestAttributeSet;
  73 import javax.print.attribute.HashPrintRequestAttributeSet;
  74 import javax.print.attribute.Attribute;
  75 import javax.print.attribute.standard.Sides;
  76 import javax.print.attribute.standard.Chromaticity;
  77 import javax.print.attribute.standard.PrintQuality;
  78 import javax.print.attribute.standard.PrinterResolution;
  79 import javax.print.attribute.standard.SheetCollate;
  80 import javax.print.attribute.standard.Copies;
  81 import javax.print.attribute.standard.Destination;
  82 import javax.print.attribute.standard.OrientationRequested;
  83 import javax.print.attribute.standard.Media;
  84 import javax.print.attribute.standard.MediaSizeName;


2100         if ((fields & DM_DEFAULTSOURCE) != 0) {
2101             MediaTray tray =
2102                 ((Win32PrintService)myService).findMediaTray(dmDefaultSource);
2103             attributes.add(new SunAlternateMedia(tray));
2104         }
2105     }
2106 
2107     private native boolean showDocProperties(long hWnd,
2108                                              PrintRequestAttributeSet aset,
2109                                              int dmFields,
2110                                              short copies,
2111                                              short collate,
2112                                              short color,
2113                                              short duplex,
2114                                              short orient,
2115                                              short paper,
2116                                              short bin,
2117                                              short xres_quality,
2118                                              short yres);
2119 
2120     @SuppressWarnings("deprecation")
2121     public PrintRequestAttributeSet
2122         showDocumentProperties(Window owner,
2123                                PrintService service,
2124                                PrintRequestAttributeSet aset)
2125     {
2126         try {
2127             setNativePrintServiceIfNeeded(service.getName());
2128         } catch (PrinterException e) {
2129         }
2130         long hWnd = ((WWindowPeer)(owner.getPeer())).getHWnd();

2131         DevModeValues info = new DevModeValues();
2132         getDevModeValues(aset, info);
2133         boolean ok =
2134             showDocProperties(hWnd, aset,
2135                               info.dmFields,
2136                               info.copies,
2137                               info.collate,
2138                               info.color,
2139                               info.duplex,
2140                               info.orient,
2141                               info.paper,
2142                               info.bin,
2143                               info.xres_quality,
2144                               info.yres);
2145 
2146         if (ok) {
2147             return aset;
2148         } else {
2149             return null;
2150         }


   1 /*
   2  * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  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.awt.windows;
  27 
  28 import java.awt.Color;
  29 import java.awt.Font;
  30 import java.awt.Graphics2D;
  31 import java.awt.GraphicsEnvironment;
  32 import java.awt.HeadlessException;

  33 import java.awt.Toolkit;
  34 import java.awt.BasicStroke;
  35 import java.awt.Button;
  36 import java.awt.Component;
  37 import java.awt.Dimension;

  38 import java.awt.event.ActionEvent;
  39 import java.awt.event.ActionListener;
  40 import java.awt.FileDialog;
  41 import java.awt.Dialog;
  42 import java.awt.Label;
  43 import java.awt.Panel;
  44 import java.awt.Rectangle;
  45 import java.awt.Window;
  46 
  47 import java.awt.image.BufferedImage;
  48 import java.awt.image.IndexColorModel;
  49 
  50 import java.awt.print.Pageable;
  51 import java.awt.print.PageFormat;
  52 import java.awt.print.Paper;
  53 import java.awt.print.Printable;
  54 import java.awt.print.PrinterJob;
  55 import java.awt.print.PrinterException;
  56 import javax.print.PrintService;
  57 
  58 import java.io.File;
  59 
  60 import java.util.MissingResourceException;
  61 import java.util.ResourceBundle;
  62 
  63 import sun.awt.AWTAccessor;
  64 import sun.awt.AWTAccessor.ComponentAccessor;
  65 import sun.print.PeekGraphics;
  66 import sun.print.PeekMetrics;
  67 
  68 import java.net.URI;
  69 import java.net.URISyntaxException;
  70 
  71 import javax.print.PrintServiceLookup;
  72 import javax.print.attribute.PrintRequestAttributeSet;
  73 import javax.print.attribute.HashPrintRequestAttributeSet;
  74 import javax.print.attribute.Attribute;
  75 import javax.print.attribute.standard.Sides;
  76 import javax.print.attribute.standard.Chromaticity;
  77 import javax.print.attribute.standard.PrintQuality;
  78 import javax.print.attribute.standard.PrinterResolution;
  79 import javax.print.attribute.standard.SheetCollate;
  80 import javax.print.attribute.standard.Copies;
  81 import javax.print.attribute.standard.Destination;
  82 import javax.print.attribute.standard.OrientationRequested;
  83 import javax.print.attribute.standard.Media;
  84 import javax.print.attribute.standard.MediaSizeName;


2100         if ((fields & DM_DEFAULTSOURCE) != 0) {
2101             MediaTray tray =
2102                 ((Win32PrintService)myService).findMediaTray(dmDefaultSource);
2103             attributes.add(new SunAlternateMedia(tray));
2104         }
2105     }
2106 
2107     private native boolean showDocProperties(long hWnd,
2108                                              PrintRequestAttributeSet aset,
2109                                              int dmFields,
2110                                              short copies,
2111                                              short collate,
2112                                              short color,
2113                                              short duplex,
2114                                              short orient,
2115                                              short paper,
2116                                              short bin,
2117                                              short xres_quality,
2118                                              short yres);
2119 

2120     public PrintRequestAttributeSet
2121         showDocumentProperties(Window owner,
2122                                PrintService service,
2123                                PrintRequestAttributeSet aset)
2124     {
2125         try {
2126             setNativePrintServiceIfNeeded(service.getName());
2127         } catch (PrinterException e) {
2128         }
2129         final ComponentAccessor acc = AWTAccessor.getComponentAccessor();
2130         long hWnd = acc.<WComponentPeer>getPeer(owner).getHWnd();
2131         DevModeValues info = new DevModeValues();
2132         getDevModeValues(aset, info);
2133         boolean ok =
2134             showDocProperties(hWnd, aset,
2135                               info.dmFields,
2136                               info.copies,
2137                               info.collate,
2138                               info.color,
2139                               info.duplex,
2140                               info.orient,
2141                               info.paper,
2142                               info.bin,
2143                               info.xres_quality,
2144                               info.yres);
2145 
2146         if (ok) {
2147             return aset;
2148         } else {
2149             return null;
2150         }