jdk/src/java.desktop/windows/classes/sun/awt/windows/WPrinterJob.java
changeset 26037 508779ce6619
parent 26004 7507a1b93f67
parent 25859 3317bb8137f4
child 27269 1ef2879dc7ad
equal deleted inserted replaced
25992:e9b05e933ddd 26037:508779ce6619
  1571                                      int bitCount, byte[] bmiColors);
  1571                                      int bitCount, byte[] bmiColors);
  1572 
  1572 
  1573 
  1573 
  1574     //** BEGIN Functions called by native code for querying/updating attributes
  1574     //** BEGIN Functions called by native code for querying/updating attributes
  1575 
  1575 
  1576     private final String getPrinterAttrib() {
  1576     private String getPrinterAttrib() {
  1577         // getPrintService will get current print service or default if none
  1577         // getPrintService will get current print service or default if none
  1578         PrintService service = this.getPrintService();
  1578         PrintService service = this.getPrintService();
  1579         String name = (service != null) ? service.getName() : null;
  1579         String name = (service != null) ? service.getName() : null;
  1580         return name;
  1580         return name;
  1581     }
  1581     }
  1582 
  1582 
  1583     /* SheetCollate */
  1583     /* SheetCollate */
  1584     private final int getCollateAttrib() {
  1584     private int getCollateAttrib() {
  1585         // -1 means unset, 0 uncollated, 1 collated.
  1585         // -1 means unset, 0 uncollated, 1 collated.
  1586         return mAttCollate;
  1586         return mAttCollate;
  1587     }
  1587     }
  1588 
  1588 
  1589     private void setCollateAttrib(Attribute attr) {
  1589     private void setCollateAttrib(Attribute attr) {
  1600         set.add(attr);
  1600         set.add(attr);
  1601     }
  1601     }
  1602 
  1602 
  1603     /* Orientation */
  1603     /* Orientation */
  1604 
  1604 
  1605     private final int getOrientAttrib() {
  1605     private int getOrientAttrib() {
  1606         int orient = PageFormat.PORTRAIT;
  1606         int orient = PageFormat.PORTRAIT;
  1607         OrientationRequested orientReq = (attributes == null) ? null :
  1607         OrientationRequested orientReq = (attributes == null) ? null :
  1608             (OrientationRequested)attributes.get(OrientationRequested.class);
  1608             (OrientationRequested)attributes.get(OrientationRequested.class);
  1609         if (orientReq == null) {
  1609         if (orientReq == null) {
  1610             orientReq = (OrientationRequested)
  1610             orientReq = (OrientationRequested)
  1627             set.add(attr);
  1627             set.add(attr);
  1628         }
  1628         }
  1629     }
  1629     }
  1630 
  1630 
  1631     /* Copies and Page Range. */
  1631     /* Copies and Page Range. */
  1632     private final int getCopiesAttrib() {
  1632     private int getCopiesAttrib() {
  1633         if (defaultCopies) {
  1633         if (defaultCopies) {
  1634             return 0;
  1634             return 0;
  1635         } else {
  1635         } else {
  1636             return getCopiesInt();
  1636             return getCopiesInt();
  1637         }
  1637         }
  1638      }
  1638      }
  1639 
  1639 
  1640     private final void setRangeCopiesAttribute(int from, int to,
  1640     private void setRangeCopiesAttribute(int from, int to, boolean isRangeSet,
  1641                                                boolean isRangeSet,
  1641                                          int copies) {
  1642                                                int copies) {
       
  1643         if (attributes != null) {
  1642         if (attributes != null) {
  1644             if (isRangeSet) {
  1643             if (isRangeSet) {
  1645                 attributes.add(new PageRanges(from, to));
  1644                 attributes.add(new PageRanges(from, to));
  1646                 setPageRange(from, to);
  1645                 setPageRange(from, to);
  1647             }
  1646             }
  1656         }
  1655         }
  1657     }
  1656     }
  1658 
  1657 
  1659 
  1658 
  1660 
  1659 
  1661     private final boolean getDestAttrib() {
  1660     private boolean getDestAttrib() {
  1662         return (mDestination != null);
  1661         return (mDestination != null);
  1663     }
  1662     }
  1664 
  1663 
  1665     /* Quality */
  1664     /* Quality */
  1666     private final int getQualityAttrib() {
  1665     private int getQualityAttrib() {
  1667         return mAttQuality;
  1666         return mAttQuality;
  1668     }
  1667     }
  1669 
  1668 
  1670     private void setQualityAttrib(Attribute attr) {
  1669     private void setQualityAttrib(Attribute attr) {
  1671         if (attr == PrintQuality.HIGH) {
  1670         if (attr == PrintQuality.HIGH) {
  1682         setQualityAttrib(attr);
  1681         setQualityAttrib(attr);
  1683         set.add(attr);
  1682         set.add(attr);
  1684     }
  1683     }
  1685 
  1684 
  1686     /* Color/Chromaticity */
  1685     /* Color/Chromaticity */
  1687     private final int getColorAttrib() {
  1686     private int getColorAttrib() {
  1688         return mAttChromaticity;
  1687         return mAttChromaticity;
  1689     }
  1688     }
  1690 
  1689 
  1691     private void setColorAttrib(Attribute attr) {
  1690     private void setColorAttrib(Attribute attr) {
  1692         if (attr == Chromaticity.COLOR) {
  1691         if (attr == Chromaticity.COLOR) {
  1701         setColorAttrib(attr);
  1700         setColorAttrib(attr);
  1702         set.add(attr);
  1701         set.add(attr);
  1703     }
  1702     }
  1704 
  1703 
  1705     /* Sides */
  1704     /* Sides */
  1706     private final int getSidesAttrib() {
  1705     private int getSidesAttrib() {
  1707         return mAttSides;
  1706         return mAttSides;
  1708     }
  1707     }
  1709 
  1708 
  1710     private void setSidesAttrib(Attribute attr) {
  1709     private void setSidesAttrib(Attribute attr) {
  1711         if (attr == Sides.TWO_SIDED_LONG_EDGE) {
  1710         if (attr == Sides.TWO_SIDED_LONG_EDGE) {
  1722         setSidesAttrib(attr);
  1721         setSidesAttrib(attr);
  1723         set.add(attr);
  1722         set.add(attr);
  1724     }
  1723     }
  1725 
  1724 
  1726     /** MediaSizeName / dmPaper */
  1725     /** MediaSizeName / dmPaper */
  1727     private final int[] getWin32MediaAttrib() {
  1726     private int[] getWin32MediaAttrib() {
  1728         int wid_ht[] = {0, 0};
  1727         int wid_ht[] = {0, 0};
  1729         if (attributes != null) {
  1728         if (attributes != null) {
  1730             Media media = (Media)attributes.get(Media.class);
  1729             Media media = (Media)attributes.get(Media.class);
  1731             if (media instanceof MediaSizeName) {
  1730             if (media instanceof MediaSizeName) {
  1732                 MediaSizeName msn = (MediaSizeName)media;
  1731                 MediaSizeName msn = (MediaSizeName)media;
  1808         return mAttMediaTray;
  1807         return mAttMediaTray;
  1809     }
  1808     }
  1810 
  1809 
  1811 
  1810 
  1812 
  1811 
  1813     private final boolean getPrintToFileEnabled() {
  1812     private boolean getPrintToFileEnabled() {
  1814         SecurityManager security = System.getSecurityManager();
  1813         SecurityManager security = System.getSecurityManager();
  1815         if (security != null) {
  1814         if (security != null) {
  1816             FilePermission printToFilePermission =
  1815             FilePermission printToFilePermission =
  1817                 new FilePermission("<<ALL FILES>>", "read,write");
  1816                 new FilePermission("<<ALL FILES>>", "read,write");
  1818             try {
  1817             try {
  1822             }
  1821             }
  1823         }
  1822         }
  1824         return true;
  1823         return true;
  1825     }
  1824     }
  1826 
  1825 
  1827     private final void setNativeAttributes(int flags, int fields, int values) {
  1826     private void setNativeAttributes(int flags, int fields, int values) {
  1828         if (attributes == null) {
  1827         if (attributes == null) {
  1829             return;
  1828             return;
  1830         }
  1829         }
  1831         if ((flags & PD_PRINTTOFILE) != 0) {
  1830         if ((flags & PD_PRINTTOFILE) != 0) {
  1832             Destination destPrn = (Destination)attributes.get(
  1831             Destination destPrn = (Destination)attributes.get(
  2014      * devmode. This syncs the devmode back in to the attributes so that
  2013      * devmode. This syncs the devmode back in to the attributes so that
  2015      * we can update the cross-platform dialog.
  2014      * we can update the cross-platform dialog.
  2016      * The attribute set here is a temporary one installed whilst this
  2015      * The attribute set here is a temporary one installed whilst this
  2017      * happens,
  2016      * happens,
  2018      */
  2017      */
  2019     private final void setJobAttributes(PrintRequestAttributeSet attributes,
  2018     private void setJobAttributes(PrintRequestAttributeSet attributes,
  2020                                         int fields, int values,
  2019                                         int fields, int values,
  2021                                         short copies,
  2020                                         short copies,
  2022                                         short dmPaperSize,
  2021                                         short dmPaperSize,
  2023                                         short dmPaperWidth,
  2022                                         short dmPaperWidth,
  2024                                         short dmPaperLength,
  2023                                         short dmPaperLength,
  2150             return null;
  2149             return null;
  2151         }
  2150         }
  2152     }
  2151     }
  2153 
  2152 
  2154     /* Printer Resolution. See also getXRes() and getYRes() */
  2153     /* Printer Resolution. See also getXRes() and getYRes() */
  2155     private final void setResolutionDPI(int xres, int yres) {
  2154     private void setResolutionDPI(int xres, int yres) {
  2156         if (attributes != null) {
  2155         if (attributes != null) {
  2157             PrinterResolution res =
  2156             PrinterResolution res =
  2158                 new PrinterResolution(xres, yres, PrinterResolution.DPI);
  2157                 new PrinterResolution(xres, yres, PrinterResolution.DPI);
  2159             attributes.add(res);
  2158             attributes.add(res);
  2160         }
  2159         }