harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apavle...@apache.org
Subject svn commit: r593524 [1/2] - in /harmony/enhanced/classlib/trunk/modules/print/src/main: java/windows/org/apache/harmony/x/print/ native/print/windows/
Date Fri, 09 Nov 2007 13:45:46 GMT
Author: apavlenko
Date: Fri Nov  9 05:45:45 2007
New Revision: 593524

URL: http://svn.apache.org/viewvc?rev=593524&view=rev
Log:
Print service implementation (HARMONY-5083)

Added:
    harmony/enhanced/classlib/trunk/modules/print/src/main/java/windows/org/apache/harmony/x/print/DevmodeStructWrapper.java   (with props)
    harmony/enhanced/classlib/trunk/modules/print/src/main/java/windows/org/apache/harmony/x/print/WinPrintJob.java   (with props)
    harmony/enhanced/classlib/trunk/modules/print/src/main/java/windows/org/apache/harmony/x/print/WinPrintService.java   (with props)
    harmony/enhanced/classlib/trunk/modules/print/src/main/java/windows/org/apache/harmony/x/print/WinPrintServiceLookup.java   (with props)
    harmony/enhanced/classlib/trunk/modules/print/src/main/java/windows/org/apache/harmony/x/print/WinPrinterFactory.java   (with props)
    harmony/enhanced/classlib/trunk/modules/print/src/main/native/print/windows/devmode_struct_wrapper.c   (with props)
    harmony/enhanced/classlib/trunk/modules/print/src/main/native/print/windows/devmode_struct_wrapper.h   (with props)
    harmony/enhanced/classlib/trunk/modules/print/src/main/native/print/windows/win_printer_factory.c   (with props)
    harmony/enhanced/classlib/trunk/modules/print/src/main/native/print/windows/win_printer_factory.h   (with props)
Modified:
    harmony/enhanced/classlib/trunk/modules/print/src/main/java/windows/org/apache/harmony/x/print/javax.print.PrintServiceLookup
    harmony/enhanced/classlib/trunk/modules/print/src/main/native/print/windows/makefile

Added: harmony/enhanced/classlib/trunk/modules/print/src/main/java/windows/org/apache/harmony/x/print/DevmodeStructWrapper.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/print/src/main/java/windows/org/apache/harmony/x/print/DevmodeStructWrapper.java?rev=593524&view=auto
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/print/src/main/java/windows/org/apache/harmony/x/print/DevmodeStructWrapper.java (added)
+++ harmony/enhanced/classlib/trunk/modules/print/src/main/java/windows/org/apache/harmony/x/print/DevmodeStructWrapper.java Fri Nov  9 05:45:45 2007
@@ -0,0 +1,519 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.harmony.x.print;
+
+import javax.print.attribute.Attribute;
+import javax.print.attribute.AttributeSet;
+import javax.print.attribute.ResolutionSyntax;
+import javax.print.attribute.Size2DSyntax;
+import javax.print.attribute.standard.Chromaticity;
+import javax.print.attribute.standard.Copies;
+import javax.print.attribute.standard.Media;
+import javax.print.attribute.standard.MediaSize;
+import javax.print.attribute.standard.MediaSizeName;
+import javax.print.attribute.standard.OrientationRequested;
+import javax.print.attribute.standard.PrintQuality;
+import javax.print.attribute.standard.PrinterResolution;
+import javax.print.attribute.standard.SheetCollate;
+import javax.print.attribute.standard.Sides;
+
+/**
+ * Wrapper for the DEVMODE native structure.
+ */
+public class DevmodeStructWrapper {
+
+    // DmField flags
+    public static final int   DM_ORIENTATION     = 0x00000001;
+    public static final int   DM_PAPERSIZE       = 0x00000002;
+    public static final int   DM_PAPERLENGTH     = 0x00000004;
+    public static final int   DM_PAPERWIDTH      = 0x00000008;
+    public static final int   DM_SCALE           = 0x00000010;
+    public static final int   DM_COPIES          = 0x00000100;
+    public static final int   DM_DEFAULTSOURCE   = 0x00000200;
+    public static final int   DM_PRINTQUALITY    = 0x00000400;
+    public static final int   DM_COLOR           = 0x00000800;
+    public static final int   DM_DUPLEX          = 0x00001000;
+    public static final int   DM_YRESOLUTION     = 0x00002000;
+    public static final int   DM_TTOPTION        = 0x00004000;
+    public static final int   DM_COLLATE         = 0x00008000;
+
+    // Orientation fields
+    public static final short DMORIENT_PORTRAIT  = 1;
+    public static final short DMORIENT_LANDSCAPE = 2;
+
+    // Print quality predefined values
+    public static final short DMRES_HIGH         = -4;
+    public static final short DMRES_MEDIUM       = -3;
+    public static final short DMRES_DRAFT        = -1;
+
+    // Sides
+    public static final short DMDUP_SIMPLEX      = 1;
+    public static final short DMDUP_VERTICAL     = 2;
+    public static final short DMDUP_HORIZONTAL   = 3;
+
+    // Collate
+    public static final short DMCOLLATE_FALSE    = 0;
+    public static final short DMCOLLATE_TRUE     = 1;
+
+    // Chromaticity
+    public static final short DMCOLOR_MONOCHROME = 1;
+    public static final short DMCOLOR_COLOR      = 2;
+
+    public long               structPtr;
+
+    public DevmodeStructWrapper(final long structPtr) {
+        this.structPtr = structPtr;
+    }
+
+    public long getStructPtr() {
+        return structPtr;
+    }
+
+    public String getDmDeviceName() {
+        return getDmDeviceName(structPtr);
+    }
+
+    public long getDmFields() {
+        return getDmFields(structPtr);
+    }
+
+    public OrientationRequested getOrientation() {
+        return getDmOrientation(structPtr) == DMORIENT_LANDSCAPE
+                        ? OrientationRequested.LANDSCAPE
+                        : OrientationRequested.PORTRAIT;
+    }
+
+    public void setOrientation(final OrientationRequested orientation) {
+        if (OrientationRequested.PORTRAIT.equals(orientation)) {
+            setDmOrientation(structPtr, DMORIENT_PORTRAIT);
+        } else if (OrientationRequested.LANDSCAPE.equals(orientation)
+                        || OrientationRequested.REVERSE_LANDSCAPE
+                                        .equals(orientation)) {
+            setDmOrientation(structPtr, DMORIENT_LANDSCAPE);
+        }
+    }
+
+    public Paper getPaper() {
+        final short size = getDmPaperSize(structPtr);
+        Paper p = StdPaper.getPaper(size);
+
+        if (p == null) {
+            final long fields = getDmFields();
+
+            if (((fields & DM_PAPERLENGTH) != 0)
+                            && ((fields & DM_PAPERWIDTH) != 0)) {
+                p = new CustomPaper(size, new MediaSize(
+                                getDmPaperWidth(structPtr) / 10,
+                                getDmPaperLength(structPtr) / 10,
+                                Size2DSyntax.MM));
+            }
+        }
+
+        return p;
+    }
+
+    public void setPaper(final Paper paper) {
+        if (paper != null) {
+            if (paper.getDmPaperSize() > 0) {
+                setDmPaperSize(structPtr, paper.getDmPaperSize());
+            } else {
+                setDmPaperWidth(structPtr, (short) (paper.getSize().getX(
+                                Size2DSyntax.MM) * 10));
+                setDmPaperLength(structPtr, (short) (paper.getSize().getY(
+                                Size2DSyntax.MM) * 10));
+            }
+        }
+    }
+
+    public void setPaper(final MediaSize size) {
+        final Paper p = StdPaper.getPaper(size);
+        setPaper((p != null) ? p : new CustomPaper(0, size));
+    }
+
+    public void setPaper(final MediaSizeName name) {
+        final Paper p = StdPaper.getPaper(name);
+        setPaper((p != null) ? p : new CustomPaper(0, MediaSize
+                        .getMediaSizeForName(name)));
+    }
+
+    public Copies getCopies() {
+        final short copies = getDmCopies(structPtr);
+        return copies > 0 ? new Copies(copies) : new Copies(1);
+    }
+
+    public void setCopies(final Copies c) {
+        setDmCopies(structPtr, (short) c.getValue());
+    }
+
+    public PrintQuality getPrintQuality() {
+        switch (getDmPrintQuality(structPtr)) {
+        case DMRES_HIGH:
+            return PrintQuality.HIGH;
+        case DMRES_DRAFT:
+            return PrintQuality.DRAFT;
+        default:
+            return PrintQuality.NORMAL;
+        }
+    }
+
+    public void setPrintQuality(final PrintQuality quality) {
+        if (PrintQuality.NORMAL.equals(quality)) {
+            setDmPrintQuality(structPtr, DMRES_MEDIUM);
+        } else if (PrintQuality.HIGH.equals(quality)) {
+            setDmPrintQuality(structPtr, DMRES_HIGH);
+        } else if (PrintQuality.DRAFT.equals(quality)) {
+            setDmPrintQuality(structPtr, DMRES_DRAFT);
+        }
+    }
+
+    public Sides getSides() {
+        switch (getDmDuplex(structPtr)) {
+        case DMDUP_VERTICAL:
+            return Sides.TWO_SIDED_LONG_EDGE;
+        case DMDUP_HORIZONTAL:
+            return Sides.TWO_SIDED_SHORT_EDGE;
+        default:
+            return Sides.ONE_SIDED;
+        }
+    }
+
+    public void setSides(final Sides sides) {
+        if (Sides.ONE_SIDED.equals(sides)) {
+            setDmDuplex(structPtr, DMDUP_SIMPLEX);
+        } else if (Sides.TWO_SIDED_LONG_EDGE.equals(sides)) {
+            setDmDuplex(structPtr, DMDUP_VERTICAL);
+        } else if (Sides.TWO_SIDED_SHORT_EDGE.equals(sides)) {
+            setDmDuplex(structPtr, DMDUP_HORIZONTAL);
+        }
+    }
+
+    public SheetCollate getCollate() {
+        return getDmCollate(structPtr) == DMCOLLATE_TRUE
+                        ? SheetCollate.COLLATED : SheetCollate.UNCOLLATED;
+    }
+
+    public void setCollate(final SheetCollate collate) {
+        if (SheetCollate.UNCOLLATED.equals(collate)) {
+            setDmCollate(structPtr, DMCOLLATE_FALSE);
+        } else if (SheetCollate.COLLATED.equals(collate)) {
+            setDmCollate(structPtr, DMCOLLATE_TRUE);
+        }
+    }
+
+    public PrinterResolution getPrinterResolution() {
+        final int x = getDmPrintQuality(structPtr);
+        final int y = getDmYResolution(structPtr);
+
+        if (y > 0) {
+            return new PrinterResolution(x > 0 ? x : y, y, ResolutionSyntax.DPI);
+        }
+
+        return null;
+    }
+
+    public void setPrinterResolution(final PrinterResolution res) {
+        setDmPrintQuality(structPtr, (short) res
+                        .getCrossFeedResolution(ResolutionSyntax.DPI));
+        setDmYResolution(structPtr, (short) res
+                        .getFeedResolution(ResolutionSyntax.DPI));
+    }
+
+    public Chromaticity getChromaticity() {
+        return getDmColor(structPtr) == DMCOLOR_COLOR ? Chromaticity.COLOR
+                        : Chromaticity.MONOCHROME;
+    }
+
+    public void setChromaticity(final Chromaticity chromaticity) {
+        if (Chromaticity.COLOR.equals(chromaticity)) {
+            setDmColor(structPtr, DMCOLOR_COLOR);
+        } else if (Chromaticity.MONOCHROME.equals(chromaticity)) {
+            setDmColor(structPtr, DMCOLOR_MONOCHROME);
+        }
+    }
+
+    public void setAttribute(final Attribute attr) {
+        final Class<? extends Attribute> category = attr.getCategory();
+
+        if (OrientationRequested.class.equals(category)) {
+            setOrientation((OrientationRequested) attr);
+        } else if (MediaSize.class.equals(category)) {
+            setPaper((MediaSize) attr);
+        } else if (Media.class.equals(category)) {
+            setPaper((MediaSizeName) attr);
+        } else if (Paper.class.equals(category)) {
+            setPaper((Paper) attr);
+        } else if (Copies.class.equals(category)) {
+            setCopies((Copies) attr);
+        } else if (PrintQuality.class.equals(category)) {
+            setPrintQuality((PrintQuality) attr);
+        } else if (Sides.class.equals(category)) {
+            setSides((Sides) attr);
+        } else if (SheetCollate.class.equals(category)) {
+            setCollate((SheetCollate) attr);
+        } else if (PrinterResolution.class.equals(category)) {
+            setPrinterResolution((PrinterResolution) attr);
+        } else if (Chromaticity.class.equals(category)) {
+            setChromaticity((Chromaticity) attr);
+        }
+    }
+
+    public void setAttributes(final AttributeSet attrs) {
+        if (attrs != null) {
+            for (Attribute attr : attrs.toArray()) {
+                setAttribute(attr);
+            }
+        }
+    }
+
+    public <T extends AttributeSet> T getAttributes(final T attrs) {
+        final long flags = getDmFields();
+        final Paper p = getPaper();
+        final PrinterResolution res = getPrinterResolution();
+
+        if (p != null) {
+            attrs.add(p.getSize());
+            attrs.add(p.getSize().getMediaSizeName());
+        }
+        if (res != null) {
+            attrs.add(res);
+        }
+        if ((flags & DM_ORIENTATION) != 0) {
+            attrs.add(getOrientation());
+        }
+        if ((flags & DM_COPIES) != 0) {
+            attrs.add(getCopies());
+        }
+        if ((flags & DM_PRINTQUALITY) != 0) {
+            attrs.add(getPrintQuality());
+        }
+        if ((flags & DM_DUPLEX) != 0) {
+            attrs.add(getSides());
+        }
+        if ((flags & DM_COLLATE) != 0) {
+            attrs.add(getCollate());
+        }
+        if ((flags & DM_COLOR) != 0) {
+            attrs.add(getChromaticity());
+        }
+
+        return attrs;
+    }
+
+    // --------------------- Native functions --------------------------- //
+    public static native String getDmDeviceName(final long structPtr);
+
+    public static native long getDmFields(final long structPtr);
+
+    public static native short getDmOrientation(final long structPtr);
+
+    public static native void setDmOrientation(final long structPtr,
+                    final short orientation);
+
+    public static native short getDmPaperSize(final long structPtr);
+
+    public static native void setDmPaperSize(final long structPtr,
+                    final short paperSize);
+
+    public static native short getDmPaperLength(final long structPtr);
+
+    public static native void setDmPaperLength(final long structPtr,
+                    final short paperLength);
+
+    public static native short getDmPaperWidth(final long structPtr);
+
+    public static native void setDmPaperWidth(final long structPtr,
+                    final short paperWidth);
+
+    public static native short getDmScale(final long structPtr);
+
+    public static native void setDmScale(final long structPtr, final short scale);
+
+    public static native short getDmCopies(final long structPtr);
+
+    public static native void setDmCopies(final long structPtr,
+                    final short copies);
+
+    public static native short getDmDefaultSource(final long structPtr);
+
+    public static native void setDmDefaultSource(final long structPtr,
+                    final short defaultSource);
+
+    public static native short getDmPrintQuality(final long structPtr);
+
+    public static native void setDmPrintQuality(final long structPtr,
+                    final short printQuality);
+
+    public static native short getDmColor(final long structPtr);
+
+    public static native void setDmColor(final long structPtr, final short color);
+
+    public static native short getDmDuplex(final long structPtr);
+
+    public static native void setDmDuplex(final long structPtr,
+                    final short duplex);
+
+    public static native short getDmYResolution(final long structPtr);
+
+    public static native void setDmYResolution(final long structPtr,
+                    final short yResolution);
+
+    public static native short getDmTTOption(final long structPtr);
+
+    public static native void setDmTTOption(final long structPtr,
+                    final short option);
+
+    public static native short getDmCollate(final long structPtr);
+
+    public static native void setDmCollate(final long structPtr,
+                    final short collate);
+
+    public static native void releaseStruct(final long structPtr);
+
+    @Override
+    protected synchronized void finalize() throws Throwable {
+        if (structPtr > 0) {
+            releaseStruct(structPtr);
+            structPtr = 0;
+        }
+    }
+
+    public static interface Paper extends Attribute {
+        public short getDmPaperSize();
+
+        public MediaSize getSize();
+    }
+
+    public static class CustomPaper implements Paper {
+        private static final long serialVersionUID = 3265772990664792005L;
+        final short               dmPaperSize;
+        final MediaSize           size;
+
+        public CustomPaper(final int dmPaperSize, final MediaSize size) {
+            this.dmPaperSize = (short) dmPaperSize;
+            this.size = size;
+        }
+
+        public short getDmPaperSize() {
+            return dmPaperSize;
+        }
+
+        public MediaSize getSize() {
+            return size;
+        }
+
+        public Class<? extends Attribute> getCategory() {
+            return Paper.class;
+        }
+
+        public String getName() {
+            return size.getName();
+        }
+    }
+
+    public static enum StdPaper implements Paper {
+            ISO_A2(66, MediaSize.ISO.A2), // DMPAPER_A2
+            ISO_A3(8, MediaSize.ISO.A3), // DMPAPER_A3
+            ISO_A4(9, MediaSize.ISO.A4), // DMPAPER_A4
+            ISO_A5(11, MediaSize.ISO.A5), // DMPAPER_A5
+            ISO_A6(70, MediaSize.ISO.A6), // DMPAPER_A6
+            NA_LETTER(1, MediaSize.NA.LETTER), // DMPAPER_LETTER
+            NA_LEGAL(5, MediaSize.NA.LEGAL), // DMPAPER_LEGAL
+            TABLOID(3, MediaSize.Other.TABLOID), // DMPAPER_TABLOID
+            NA_10x14(16, MediaSize.NA.NA_10x14_ENVELOPE), // DMPAPER_10X14
+            ISO_B4(12, MediaSize.ISO.B4), // DMPAPER_B4
+            JIS_B5(13, MediaSize.JIS.B5), // DMPAPER_B5
+            JIS_B6(88, MediaSize.JIS.B5), // DMPAPER_B6_JIS
+            JPC(43, MediaSize.Other.JAPANESE_POSTCARD), // DMPAPER_JAPANESE_POSTCARD
+            JPC_D(69, MediaSize.Other.JAPANESE_DOUBLE_POSTCARD); // DMPAPER_DBL_JAPANESE_POSTCARD
+
+        final short     dmPaperSize;
+        final MediaSize size;
+
+        StdPaper(final int dmPaperSize, final MediaSize size) {
+            this.dmPaperSize = (short) dmPaperSize;
+            this.size = size;
+        }
+
+        public static Paper getPaper(final short dmPaperSize) {
+            for (StdPaper p : values()) {
+                if (p.dmPaperSize == dmPaperSize) {
+                    return p;
+                }
+            }
+
+            return null;
+        }
+
+        public static Paper getPaper(final MediaSize size) {
+            for (StdPaper p : values()) {
+                if (p.size.equals(size)) {
+                    return p;
+                }
+            }
+
+            return null;
+        }
+
+        public static Paper getPaper(final MediaSizeName name) {
+            for (StdPaper p : values()) {
+                if (p.size.getMediaSizeName().equals(name)) {
+                    return p;
+                }
+            }
+
+            return null;
+        }
+
+        public static MediaSize[] getSizes() {
+            final StdPaper[] paper = values();
+            final MediaSize[] names = new MediaSize[paper.length];
+
+            for (int i = 0; i < paper.length; i++) {
+                names[i] = paper[i].size;
+            }
+
+            return names;
+        }
+
+        public static MediaSizeName[] getNames() {
+            final StdPaper[] paper = values();
+            final MediaSizeName[] names = new MediaSizeName[paper.length];
+
+            for (int i = 0; i < paper.length; i++) {
+                names[i] = paper[i].size.getMediaSizeName();
+            }
+
+            return names;
+        }
+
+        public short getDmPaperSize() {
+            return dmPaperSize;
+        }
+
+        public MediaSize getSize() {
+            return size;
+        }
+
+        public Class<? extends Attribute> getCategory() {
+            return Paper.class;
+        }
+
+        public String getName() {
+            return toString() + ": " + size; //$NON-NLS-1$
+        }
+    }
+}

Propchange: harmony/enhanced/classlib/trunk/modules/print/src/main/java/windows/org/apache/harmony/x/print/DevmodeStructWrapper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/classlib/trunk/modules/print/src/main/java/windows/org/apache/harmony/x/print/WinPrintJob.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/print/src/main/java/windows/org/apache/harmony/x/print/WinPrintJob.java?rev=593524&view=auto
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/print/src/main/java/windows/org/apache/harmony/x/print/WinPrintJob.java (added)
+++ harmony/enhanced/classlib/trunk/modules/print/src/main/java/windows/org/apache/harmony/x/print/WinPrintJob.java Fri Nov  9 05:45:45 2007
@@ -0,0 +1,535 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.harmony.x.print;
+
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Frame;
+import java.awt.Graphics2D;
+import java.awt.Image;
+import java.awt.print.PageFormat;
+import java.awt.print.Pageable;
+import java.awt.print.Paper;
+import java.awt.print.Printable;
+import java.awt.print.PrinterException;
+import java.io.IOException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.WeakHashMap;
+
+import javax.imageio.ImageIO;
+import javax.print.CancelablePrintJob;
+import javax.print.Doc;
+import javax.print.DocFlavor;
+import javax.print.PrintException;
+import javax.print.PrintService;
+import javax.print.attribute.Attribute;
+import javax.print.attribute.AttributeSet;
+import javax.print.attribute.AttributeSetUtilities;
+import javax.print.attribute.HashAttributeSet;
+import javax.print.attribute.HashPrintJobAttributeSet;
+import javax.print.attribute.PrintJobAttribute;
+import javax.print.attribute.PrintJobAttributeSet;
+import javax.print.attribute.PrintRequestAttributeSet;
+import javax.print.attribute.Size2DSyntax;
+import javax.print.attribute.TextSyntax;
+import javax.print.attribute.standard.Destination;
+import javax.print.attribute.standard.DocumentName;
+import javax.print.attribute.standard.JobName;
+import javax.print.attribute.standard.MediaPrintableArea;
+import javax.print.attribute.standard.OrientationRequested;
+import javax.print.attribute.standard.PageRanges;
+import javax.print.event.PrintJobAttributeEvent;
+import javax.print.event.PrintJobAttributeListener;
+import javax.print.event.PrintJobEvent;
+import javax.print.event.PrintJobListener;
+
+import org.apache.harmony.awt.gl.windows.WinGDIPGraphics2D;
+
+class WinPrintJob implements CancelablePrintJob {
+
+    final Object                                               lock;
+    final Map<PrintJobListener, Object>                        jobListeners;
+    final Map<PrintJobAttributeListener, PrintJobAttributeSet> attrListeners;
+    final WinPrintService                                      service;
+    Printer                                                    printer;
+
+    WinPrintJob(final WinPrintService service) {
+        this.service = service;
+        lock = new Object();
+        jobListeners = Collections
+                        .synchronizedMap(new WeakHashMap<PrintJobListener, Object>());
+        attrListeners = Collections
+                        .synchronizedMap(new WeakHashMap<PrintJobAttributeListener, PrintJobAttributeSet>());
+    }
+
+    public void cancel() throws PrintException {
+        synchronized (lock) {
+            if (printer == null) {
+                throw new PrintException("Job is not started"); //$NON-NLS-1$
+            }
+            printer.cancelJob();
+        }
+    }
+
+    public void addPrintJobAttributeListener(
+                    final PrintJobAttributeListener listener,
+                    final PrintJobAttributeSet attributes) {
+        if (listener != null) {
+            attrListeners.put(listener, attributes);
+        }
+    }
+
+    public void addPrintJobListener(final PrintJobListener listener) {
+        if (listener != null) {
+            jobListeners.put(listener, null);
+        }
+    }
+
+    public PrintJobAttributeSet getAttributes() {
+        final PrintJobAttributeSet attrs = service.getPrinterProps()
+                        .getAttributes(new HashPrintJobAttributeSet());
+
+        for (Attribute attr : attrs.toArray()) {
+            if (!(attr instanceof PrintJobAttribute)) {
+                attrs.remove(attr);
+            }
+        }
+
+        return AttributeSetUtilities.unmodifiableView(attrs);
+    }
+
+    public PrintService getPrintService() {
+        return service;
+    }
+
+    public void print(final Doc doc, final PrintRequestAttributeSet attributes)
+                    throws PrintException {
+        synchronized (lock) {
+            if (printer != null) {
+                throw new PrintException("Printer is busy"); //$NON-NLS-1$
+            } else {
+                final DocFlavor flavor = doc.getDocFlavor();
+
+                if ((flavor == null) || !service.isDocFlavorSupported(flavor)) {
+                    throw new PrintException("Doc flavor is not supported"); //$NON-NLS-1$
+                }
+
+                printer = new Printer(doc, attributes);
+                printer.start();
+            }
+        }
+    }
+
+    public void removePrintJobAttributeListener(
+                    final PrintJobAttributeListener listener) {
+        attrListeners.remove(listener);
+    }
+
+    public void removePrintJobListener(final PrintJobListener listener) {
+        jobListeners.remove(listener);
+    }
+
+    void notifyJobListeners(final int reason) {
+        final PrintJobEvent event = new PrintJobEvent(this, reason);
+
+        for (PrintJobListener listener : jobListeners.keySet()) {
+            switch (reason) {
+            case PrintJobEvent.DATA_TRANSFER_COMPLETE:
+                listener.printDataTransferCompleted(event);
+                break;
+            case PrintJobEvent.JOB_CANCELED:
+                listener.printJobCanceled(event);
+                break;
+            case PrintJobEvent.JOB_COMPLETE:
+                listener.printJobCompleted(event);
+                break;
+            case PrintJobEvent.JOB_FAILED:
+                listener.printJobFailed(event);
+                break;
+            case PrintJobEvent.NO_MORE_EVENTS:
+                listener.printJobNoMoreEvents(event);
+                break;
+            case PrintJobEvent.REQUIRES_ATTENTION:
+                listener.printJobRequiresAttention(event);
+                break;
+            }
+        }
+    }
+
+    void notifyAttrListeners(final PrintJobAttribute... attrs) {
+        final PrintJobAttributeSet attrSet = new HashPrintJobAttributeSet(attrs);
+        final PrintJobAttributeEvent event = new PrintJobAttributeEvent(this,
+                        attrSet);
+
+        for (PrintJobAttribute attr : attrs) {
+            final Class<? extends Attribute> cat = attr.getCategory();
+
+            for (Map.Entry<PrintJobAttributeListener, PrintJobAttributeSet> e : attrListeners
+                            .entrySet()) {
+                if ((e.getValue() == null) || (e.getValue().containsKey(cat))) {
+                    e.getKey().attributeUpdate(event);
+                }
+            }
+        }
+    }
+
+    void notifyAttrListeners(final AttributeSet... attrSets) {
+        final List<PrintJobAttribute> list = new ArrayList<PrintJobAttribute>();
+        final PrintJobAttribute[] attrs;
+
+        for (AttributeSet attrSet : attrSets) {
+            if (attrSet != null) {
+                for (Attribute attr : attrSet.toArray()) {
+                    if (attr instanceof PrintJobAttribute) {
+                        list.add((PrintJobAttribute) attr);
+                    }
+                }
+            }
+        }
+
+        attrs = new PrintJobAttribute[list.size()];
+        notifyAttrListeners(list.toArray(attrs));
+    }
+
+    private class Printer extends Thread {
+        final Doc                      doc;
+        final PrintRequestAttributeSet attributes;
+        int                            jobId;
+
+        Printer(final Doc doc, final PrintRequestAttributeSet attributes) {
+            super(WinPrintService.DEFAULT_JOB_NAME.getName());
+            this.doc = doc;
+            this.attributes = attributes;
+        }
+
+        public void run() {
+            final DocFlavor flavor = doc.getDocFlavor();
+            final DevmodeStructWrapper dm = service.getPrinterProps();
+
+            dm.setAttributes(attributes);
+            dm.setAttributes(doc.getAttributes());
+            notifyAttrListeners(dm.getAttributes(new HashAttributeSet()));
+
+            try {
+                if (DocFlavor.SERVICE_FORMATTED.PRINTABLE.equals(flavor)) {
+                    printPrintable(doc, attributes);
+                } else if (DocFlavor.SERVICE_FORMATTED.PAGEABLE.equals(flavor)) {
+                    printPageable(doc, attributes);
+                } else if (DocFlavor.URL.JPEG.equals(flavor)
+                                || DocFlavor.URL.GIF.equals(flavor)
+                                || DocFlavor.URL.PNG.equals(flavor)) {
+                    printImage(ImageIO.read(castDoc(doc, URL.class)), doc,
+                                    attributes);
+                } else if (DocFlavor.INPUT_STREAM.JPEG.equals(flavor)
+                                || DocFlavor.INPUT_STREAM.GIF.equals(flavor)
+                                || DocFlavor.INPUT_STREAM.PNG.equals(flavor)) {
+                    printImage(ImageIO.read(doc.getStreamForBytes()), doc,
+                                    attributes);
+                } else if (DocFlavor.BYTE_ARRAY.JPEG.equals(flavor)
+                                || DocFlavor.BYTE_ARRAY.GIF.equals(flavor)
+                                || DocFlavor.BYTE_ARRAY.PNG.equals(flavor)) {
+                    printImage(ImageIO.read(doc.getStreamForBytes()), doc,
+                                    attributes);
+                } else {
+                    throw new PrintException("Doc flavor is not supported"); //$NON-NLS-1$
+                }
+
+                notifyJobListeners(PrintJobEvent.DATA_TRANSFER_COMPLETE);
+                notifyJobListeners(PrintJobEvent.JOB_COMPLETE);
+            } catch (final Exception ex) {
+                synchronized (this) {
+                    if (jobId != -1) {
+                        notifyJobListeners(PrintJobEvent.JOB_FAILED);
+                        throw new RuntimeException(ex);
+                    }
+                }
+            } finally {
+                synchronized (lock) {
+                    printer = null;
+                }
+            }
+        }
+
+        synchronized void cancelJob() throws PrintException {
+            if (jobId > 0) {
+                WinPrinterFactory.cancelPrinterJob(service.getPrinterHandle(),
+                                jobId);
+            }
+
+            jobId = -1;
+            notifyJobListeners(PrintJobEvent.JOB_CANCELED);
+        }
+
+        private synchronized void startJob(final long pdc,
+                        final String docName, final String filePath)
+                        throws PrintException {
+            if (jobId == -1) {
+                throw new PrintException("Job has been canceled"); //$NON-NLS-1$
+            }
+
+            jobId = WinPrinterFactory.startDoc(pdc, docName, filePath);
+        }
+
+        private synchronized void endJob(final long pdc) throws PrintException {
+            if (jobId <= 0) {
+                throw new PrintException("Job is not started");//$NON-NLS-1$ 
+            }
+            WinPrinterFactory.endDoc(pdc);
+        }
+
+        private void printPrintable(final Doc doc,
+                        final PrintRequestAttributeSet attributes)
+                        throws PrintException {
+            final long pdc = WinPrinterFactory.getPrinterDC(
+                            service.printerName, service.getPrinterProps()
+                                            .getStructPtr());
+            final AttributeSet docAttrs = doc.getAttributes();
+            final Printable printable = castDoc(doc, Printable.class);
+            final PageFormat format = getPageFormat(docAttrs, attributes);
+            final PageRanges ranges = getAttribute(PageRanges.class, docAttrs,
+                            attributes);
+            int res = Printable.PAGE_EXISTS;
+
+            try {
+                startJob(pdc, getDocName(printable, docAttrs, attributes),
+                                getDestinationPath(attributes));
+
+                for (int i = 0; res == Printable.PAGE_EXISTS; i++) {
+                    if ((ranges != null) && !ranges.contains(i)) {
+                        continue;
+                    }
+
+                    res = printPrintable(printable, pdc, format, i);
+                }
+
+                endJob(pdc);
+            } finally {
+                WinPrinterFactory.releasePrinterDC(pdc);
+            }
+        }
+
+        private void printPageable(final Doc doc,
+                        final PrintRequestAttributeSet attributes)
+                        throws PrintException {
+            final Pageable pageable = castDoc(doc, Pageable.class);
+            final PageFormat defaultFormat = getPageFormat(doc.getAttributes(),
+                            attributes);
+            final long pdc = WinPrinterFactory.getPrinterDC(
+                            service.printerName, service.getPrinterProps()
+                                            .getStructPtr());
+            final AttributeSet docAttrs = doc.getAttributes();
+            int pages = pageable.getNumberOfPages();
+            final PageRanges ranges = getAttribute(PageRanges.class, docAttrs,
+                            attributes);
+
+            if (pages == Pageable.UNKNOWN_NUMBER_OF_PAGES) {
+                pages = Integer.MAX_VALUE;
+            }
+
+            try {
+                startJob(pdc, getDocName(pageable, docAttrs, attributes),
+                                getDestinationPath(attributes));
+
+                for (int i = 0; i <= pages; i++) {
+                    if ((ranges != null) && !ranges.contains(i)) {
+                        continue;
+                    }
+
+                    final Printable printable = pageable.getPrintable(i);
+                    final PageFormat format = null;
+
+                    if (printable == null) {
+                        throw new PrintException("No such page: " + i); //$NON-NLS-1$
+                    }
+
+                    if (printPrintable(printable, pdc, format != null ? format
+                                    : defaultFormat, i) == Printable.NO_SUCH_PAGE) {
+                        break;
+                    }
+                }
+
+                endJob(pdc);
+            } finally {
+                WinPrinterFactory.releasePrinterDC(pdc);
+            }
+        }
+
+        private void printImage(final Image img, final Doc doc,
+                        final PrintRequestAttributeSet attributes)
+                        throws PrintException {
+            final PageFormat format = getPageFormat(attributes);
+            final long pdc = WinPrinterFactory.getPrinterDC(
+                            service.printerName, service.getPrinterProps()
+                                            .getStructPtr());
+            final double xRes = WinPrinterFactory.getPixelsPerInchX(pdc) / 72;
+            final double yRes = WinPrinterFactory.getPixelsPerInchY(pdc) / 72;
+            final Graphics2D g2d = new WinGDIPGraphics2D(pdc, (char) 2,
+                            (int) (format.getWidth() * xRes), (int) (format
+                                            .getHeight() * yRes));
+
+            try {
+                startJob(pdc, getDocName(img, attributes),
+                                getDestinationPath(attributes));
+                WinPrinterFactory.startPage(pdc);
+                g2d.drawImage(img, (int) (format.getImageableX() * xRes),
+                                (int) (format.getImageableY() * yRes),
+                                (int) (format.getImageableWidth() * xRes),
+                                (int) (format.getImageableHeight() * yRes),
+                                Color.WHITE, null);
+                WinPrinterFactory.endPage(pdc);
+                endJob(pdc);
+            } finally {
+                WinPrinterFactory.releasePrinterDC(pdc);
+            }
+        }
+
+        private int printPrintable(final Printable p, final long pdc,
+                        final PageFormat format, final int pageIndex)
+                        throws PrintException {
+            final int result;
+
+            try {
+                WinPrinterFactory.startPage(pdc);
+                result = p.print(getGraphics(pdc, format), format, pageIndex);
+                WinPrinterFactory.endPage(pdc);
+            } catch (final PrinterException ex) {
+                throw new PrintException(ex);
+            }
+
+            return result;
+        }
+
+        private <T extends Attribute> T getAttribute(final Class<T> c,
+                        final AttributeSet... attrSets) {
+            for (AttributeSet attrs : attrSets) {
+                if (attrs != null) {
+                    for (Attribute attr : attrs.toArray()) {
+                        if (c.equals(attr.getCategory())) {
+                            return c.cast(attr);
+                        }
+                    }
+                }
+            }
+
+            return null;
+        }
+
+        private String getDocName(final Object doc,
+                        final AttributeSet... attrSets) {
+            Attribute name = getAttribute(DocumentName.class, attrSets);
+
+            if (name == null) {
+                name = getAttribute(JobName.class, attrSets);
+            }
+
+            if ((name == null) && (doc instanceof Component)) {
+                Component c = (Component) doc;
+
+                while (c != null) {
+                    if (c instanceof Frame) {
+                        if (((Frame) c).getTitle().length() > 0) {
+                            return ((Frame) c).getTitle();
+                        }
+                    }
+                    c = c.getParent();
+                }
+            }
+
+            return name != null ? ((TextSyntax) name).getValue()
+                            : WinPrintService.DEFAULT_JOB_NAME.getValue();
+        }
+
+        private String getDestinationPath(final PrintRequestAttributeSet attrs)
+                        throws PrintException {
+            if (attrs != null) {
+                final Destination dest = (Destination) attrs
+                                .get(Destination.class);
+                return dest != null ? dest.getURI().getPath() : null;
+            }
+            return null;
+        }
+
+        private <T> T castDoc(final Doc doc, final Class<T> c)
+                        throws PrintException {
+            try {
+                return c.cast(doc.getPrintData());
+            } catch (final IOException ex) {
+                throw new PrintException(ex);
+            }
+        }
+
+        private Graphics2D getGraphics(final long pdc, final PageFormat format)
+                        throws PrintException {
+            final Graphics2D g2d = new WinGDIPGraphics2D(pdc, (char) 3,
+                            (int) format.getWidth(), (int) format.getHeight());
+
+            g2d.setColor(Color.BLACK);
+            g2d.setBackground(Color.WHITE);
+            g2d.setClip((int) format.getImageableX(), (int) format
+                            .getImageableY(), (int) format.getImageableWidth(),
+                            (int) format.getImageableHeight());
+
+            return g2d;
+        }
+
+        private PageFormat getPageFormat(final AttributeSet... attrSets) {
+            final Paper paper = new Paper();
+            final PageFormat format = new PageFormat();
+            final DevmodeStructWrapper dm = service.getPrinterProps();
+            final OrientationRequested o = dm.getOrientation();
+            final MediaPrintableArea area = getAttribute(
+                            MediaPrintableArea.class, attrSets);
+            DevmodeStructWrapper.Paper p = dm.getPaper();
+
+            if (p == null) {
+                p = (DevmodeStructWrapper.Paper) service
+                                .getDefaultAttributeValue(DevmodeStructWrapper.Paper.class);
+                dm.setPaper(p);
+            }
+
+            paper.setSize(p.getSize().getX(Size2DSyntax.INCH) * 72.0, p
+                            .getSize().getY(Size2DSyntax.INCH) * 72.0);
+            format.setPaper(paper);
+
+            if (OrientationRequested.LANDSCAPE.equals(o)
+                            || OrientationRequested.REVERSE_LANDSCAPE.equals(o)) {
+                format.setOrientation(PageFormat.LANDSCAPE);
+            } else {
+                format.setOrientation(PageFormat.PORTRAIT);
+            }
+
+            if (area != null) {
+                paper.setImageableArea(area.getX(MediaPrintableArea.INCH) * 72,
+                                area.getY(MediaPrintableArea.INCH) * 72,
+                                area.getWidth(MediaPrintableArea.INCH) * 72,
+                                area.getHeight(MediaPrintableArea.INCH) * 72);
+            } else {
+                final double x = paper.getWidth() / 10;
+                final double y = paper.getHeight() / 10;
+
+                paper.setImageableArea(x, y, (paper.getWidth() - 2 * x), (paper
+                                .getHeight() - 2 * y));
+            }
+
+            return format;
+        }
+    }
+}

Propchange: harmony/enhanced/classlib/trunk/modules/print/src/main/java/windows/org/apache/harmony/x/print/WinPrintJob.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/classlib/trunk/modules/print/src/main/java/windows/org/apache/harmony/x/print/WinPrintService.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/print/src/main/java/windows/org/apache/harmony/x/print/WinPrintService.java?rev=593524&view=auto
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/print/src/main/java/windows/org/apache/harmony/x/print/WinPrintService.java (added)
+++ harmony/enhanced/classlib/trunk/modules/print/src/main/java/windows/org/apache/harmony/x/print/WinPrintService.java Fri Nov  9 05:45:45 2007
@@ -0,0 +1,445 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.harmony.x.print;
+
+import java.io.File;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.Collections;
+import java.util.Map;
+import java.util.WeakHashMap;
+
+import javax.print.DocFlavor;
+import javax.print.DocPrintJob;
+import javax.print.PrintException;
+import javax.print.PrintService;
+import javax.print.ServiceUIFactory;
+import javax.print.attribute.Attribute;
+import javax.print.attribute.AttributeSet;
+import javax.print.attribute.AttributeSetUtilities;
+import javax.print.attribute.HashAttributeSet;
+import javax.print.attribute.HashPrintServiceAttributeSet;
+import javax.print.attribute.PrintServiceAttribute;
+import javax.print.attribute.PrintServiceAttributeSet;
+import javax.print.attribute.standard.Chromaticity;
+import javax.print.attribute.standard.Copies;
+import javax.print.attribute.standard.CopiesSupported;
+import javax.print.attribute.standard.Destination;
+import javax.print.attribute.standard.JobName;
+import javax.print.attribute.standard.Media;
+import javax.print.attribute.standard.MediaPrintableArea;
+import javax.print.attribute.standard.MediaSize;
+import javax.print.attribute.standard.MediaSizeName;
+import javax.print.attribute.standard.OrientationRequested;
+import javax.print.attribute.standard.PrintQuality;
+import javax.print.attribute.standard.PrinterName;
+import javax.print.attribute.standard.PrinterResolution;
+import javax.print.attribute.standard.PrinterState;
+import javax.print.attribute.standard.QueuedJobCount;
+import javax.print.attribute.standard.RequestingUserName;
+import javax.print.attribute.standard.SheetCollate;
+import javax.print.attribute.standard.Sides;
+import javax.print.event.PrintServiceAttributeEvent;
+import javax.print.event.PrintServiceAttributeListener;
+
+import org.apache.harmony.x.print.DevmodeStructWrapper.Paper;
+import org.apache.harmony.x.print.DevmodeStructWrapper.StdPaper;
+
+class WinPrintService implements PrintService {
+    
+    static final JobName                                     DEFAULT_JOB_NAME    = new JobName("Java printing", null); //$NON-NLS-1$
+
+    private static final DocFlavor[]                         SUPPORTED_FLAVORS   = {
+                    DocFlavor.SERVICE_FORMATTED.PRINTABLE,
+                    DocFlavor.SERVICE_FORMATTED.PAGEABLE, DocFlavor.URL.JPEG,
+                    DocFlavor.INPUT_STREAM.JPEG, DocFlavor.BYTE_ARRAY.JPEG,
+                    DocFlavor.URL.GIF, DocFlavor.INPUT_STREAM.GIF,
+                    DocFlavor.BYTE_ARRAY.GIF, DocFlavor.URL.PNG,
+                    DocFlavor.INPUT_STREAM.PNG, DocFlavor.BYTE_ARRAY.PNG        };
+
+    private static final Class<?>[]                          SUPPORTED_ATTR_CATS = new Class<?>[] {
+                    JobName.class, RequestingUserName.class, Destination.class,
+                    OrientationRequested.class, Media.class, MediaSize.class,
+                    Copies.class, PrintQuality.class, PrinterResolution.class,
+                    Sides.class, SheetCollate.class, Chromaticity.class,
+                    MediaPrintableArea.class, PrinterResolution.class           };
+
+    final String                                             printerName;
+    private final Map<PrintServiceAttributeListener, Object> attrListeners;
+    private long                                             pHandle;
+    private DevmodeStructWrapper                             dmStruct;
+    private DevmodeStructWrapper                             defaultDmStruct;
+
+    WinPrintService(final String printerName) {
+        this.printerName = printerName;
+        attrListeners = Collections
+                        .synchronizedMap(new WeakHashMap<PrintServiceAttributeListener, Object>());
+    }
+
+    public void addPrintServiceAttributeListener(
+                    final PrintServiceAttributeListener listener) {
+        attrListeners.put(listener, null);
+    }
+
+    public DocPrintJob createPrintJob() {
+        WinPrinterFactory.checkPrintJobAccess();
+        try {
+            notifyListeners(
+                            WinPrinterFactory
+                                            .getPrinterState(getPrinterHandle()),
+                            WinPrinterFactory
+                                            .getQueuedJobCount(getPrinterHandle()));
+        } catch (final PrintException ex) {
+            throw new RuntimeException(ex);
+        }
+        return new WinPrintJob(this);
+    }
+
+    public <T extends PrintServiceAttribute> T getAttribute(
+                    final Class<T> category) {
+        if (category == null) {
+            throw new NullPointerException("category should not be null"); //$NON-NLS-1$
+        }
+
+        if (!PrintServiceAttribute.class.isAssignableFrom(category)) {
+            throw new IllegalArgumentException(category
+                            + " is not assignable from PrintServiceAttribute"); //$NON-NLS-1$
+        }
+
+        try {
+            if (PrinterName.class.equals(category)) {
+                return category.cast(new PrinterName(printerName, null));
+            } else if (PrinterState.class.equals(category)) {
+                return category.cast(WinPrinterFactory
+                                .getPrinterState(getPrinterHandle()));
+            } else if (QueuedJobCount.class.equals(category)) {
+                return category.cast(WinPrinterFactory
+                                .getQueuedJobCount(getPrinterHandle()));
+            }
+
+            return null;
+        } catch (final PrintException ex) {
+            throw new RuntimeException(ex);
+        }
+    }
+
+    public PrintServiceAttributeSet getAttributes() {
+        final PrintServiceAttributeSet attrs = new HashPrintServiceAttributeSet();
+
+        attrs.add(new PrinterName(printerName, null));
+        try {
+            attrs.add(WinPrinterFactory.getPrinterState(getPrinterHandle()));
+            attrs.add(WinPrinterFactory.getQueuedJobCount(getPrinterHandle()));
+        } catch (final PrintException ex) {
+            throw new RuntimeException(ex);
+        }
+
+        return AttributeSetUtilities.unmodifiableView(attrs);
+    }
+
+    public Object getDefaultAttributeValue(
+                    final Class<? extends Attribute> category) {
+        checkArgs(category, null);
+
+        final DevmodeStructWrapper dm = getDefaultPrinterProps();
+
+        if (JobName.class.equals(category)) {
+            return DEFAULT_JOB_NAME;
+        } else if (RequestingUserName.class.equals(category)) {
+            return new RequestingUserName(getSystemProperty("user.name"), //$NON-NLS-1$
+                            null);
+        } else if (Destination.class.equals(category)) {
+            File file = new File(getSystemProperty("user.dir") //$NON-NLS-1$
+                            + File.separator + "output.prn"); //$NON-NLS-1$
+            return new Destination(file.toURI());
+        } else if (OrientationRequested.class.equals(category)) {
+            return dm.getOrientation();
+        } else if (Paper.class.equals(category)) {
+            return getDefaultPaper();
+        } else if (Media.class.equals(category)) {
+            return getDefaultPaper().getSize().getMediaSizeName();
+        } else if (MediaSize.class.equals(category)) {
+            return getDefaultPaper().getSize();
+        } else if (PrintQuality.class.equals(category)) {
+            return dm.getPrintQuality();
+        } else if (Sides.class.equals(category)) {
+            return dm.getSides();
+        } else if (Copies.class.equals(category)) {
+            return dm.getCopies();
+        } else if (SheetCollate.class.equals(category)) {
+            return dm.getCollate();
+        } else if (PrinterResolution.class.equals(category)) {
+            return dm.getPrinterResolution();
+        } else if (Chromaticity.class.equals(category)) {
+            return dm.getChromaticity();
+        }
+
+        return null;
+    }
+
+    public String getName() {
+        return printerName;
+    }
+
+    public ServiceUIFactory getServiceUIFactory() {
+        return null;
+    }
+
+    public Class<?>[] getSupportedAttributeCategories() {
+        return SUPPORTED_ATTR_CATS;
+    }
+
+    public Object getSupportedAttributeValues(
+                    final Class<? extends Attribute> category,
+                    final DocFlavor flavor, final AttributeSet attributes) {
+        checkArgs(category, flavor);
+
+        try {
+            if (OrientationRequested.class.equals(category)) {
+                return WinPrinterFactory
+                                .getSupportedOrientations(getPrinterHandle());
+            } else if (Media.class.equals(category)
+                            || MediaSizeName.class.equals(category)) {
+                return WinPrinterFactory
+                                .getSupportedMediaSizeNames(getPrinterHandle());
+            } else if (MediaSize.class.equals(category)) {
+                return WinPrinterFactory
+                                .getSupportedMediaSizes(getPrinterHandle());
+            } else if (CopiesSupported.class.equals(category)) {
+                final int max = WinPrinterFactory
+                                .getMaxNumberOfCopies(getPrinterHandle());
+                return max > 1 ? new CopiesSupported(1, max)
+                                : new CopiesSupported(1);
+            } else if (PrintQuality.class.equals(category)) {
+                return new PrintQuality[] { PrintQuality.HIGH,
+                                PrintQuality.NORMAL, PrintQuality.DRAFT };
+            } else if (Sides.class.equals(category)) {
+                return WinPrinterFactory.isDuplexSupported(getPrinterHandle())
+                                ? new Sides[] { Sides.ONE_SIDED,
+                                                Sides.TWO_SIDED_SHORT_EDGE,
+                                                Sides.TWO_SIDED_LONG_EDGE }
+                                : new Sides[] { Sides.ONE_SIDED };
+            } else if (SheetCollate.class.equals(category)) {
+                return WinPrinterFactory.isDuplexSupported(getPrinterHandle())
+                                ? new SheetCollate[] { SheetCollate.COLLATED,
+                                                SheetCollate.UNCOLLATED }
+                                : new SheetCollate[] { SheetCollate.UNCOLLATED };
+            } else if (Chromaticity.class.equals(category)) {
+                return WinPrinterFactory
+                                .isColorPrintingSupported(getPrinterHandle())
+                                ? new Chromaticity[] { Chromaticity.MONOCHROME,
+                                                Chromaticity.COLOR }
+                                : new Chromaticity[] { Chromaticity.MONOCHROME };
+            } else if (PrinterResolution.class.equals(category)) {
+                return WinPrinterFactory
+                                .getSupportedPrinterResolutions(getPrinterHandle());
+            } else if (PrintQuality.class.equals(category)) {
+                return new PrintQuality[] { PrintQuality.HIGH,
+                                PrintQuality.NORMAL, PrintQuality.DRAFT };
+            }
+        } catch (final PrintException ex) {
+            throw new RuntimeException(ex);
+        }
+
+        return null;
+    }
+
+    public DocFlavor[] getSupportedDocFlavors() {
+        return SUPPORTED_FLAVORS;
+    }
+
+    public AttributeSet getUnsupportedAttributes(final DocFlavor flavor,
+                    final AttributeSet attributes) {
+        checkFlavor(flavor);
+
+        if (attributes == null) {
+            return null;
+        }
+
+        final AttributeSet result = new HashAttributeSet();
+
+        for (Attribute attr : attributes.toArray()) {
+            if (!isAttributeValueSupported(attr, flavor, attributes)) {
+                result.add(attr);
+            }
+        }
+
+        return result.size() > 0 ? result : null;
+    }
+
+    public boolean isAttributeCategorySupported(
+                    final Class<? extends Attribute> category) {
+        checkArgs(category, null);
+        return arrayContains(SUPPORTED_ATTR_CATS, category);
+    }
+
+    public boolean isAttributeValueSupported(final Attribute attrval,
+                    final DocFlavor flavor, final AttributeSet attributes) {
+        checkFlavor(flavor);
+
+        final Class<? extends Attribute> category = attrval.getCategory();
+
+        try {
+            if (Copies.class.equals(category)) {
+                int max = WinPrinterFactory
+                                .getMaxNumberOfCopies(getPrinterHandle());
+                return max <= 0 ? ((Copies) attrval).getValue() == 1
+                                : ((Copies) attrval).getValue() <= max;
+            }
+        } catch (final PrintException ex) {
+            throw new RuntimeException(ex);
+        }
+
+        final Object obj = getSupportedAttributeValues(category, flavor,
+                        attributes);
+
+        if (obj != null) {
+            if (obj.getClass().isArray()) {
+                return arrayContains((Object[]) obj, attrval);
+            } else {
+                return obj.equals(attrval);
+            }
+        }
+
+        return false;
+    }
+
+    public boolean isDocFlavorSupported(final DocFlavor flavor) {
+        return arrayContains(SUPPORTED_FLAVORS, flavor);
+    }
+
+    public void removePrintServiceAttributeListener(
+                    final PrintServiceAttributeListener listener) {
+        attrListeners.remove(listener);
+    }
+
+    @Override
+    public boolean equals(final Object object) {
+        return (object instanceof WinPrintService)
+                        && ((WinPrintService) object).printerName
+                                        .equals(printerName);
+    }
+
+    @Override
+    public String toString() {
+        return getName();
+    }
+
+    synchronized long getPrinterHandle() {
+        if (pHandle == 0) {
+            try {
+                pHandle = WinPrinterFactory.getPrinterHandle(printerName);
+            } catch (final PrintException ex) {
+                throw new RuntimeException(ex);
+            }
+        }
+
+        return pHandle;
+    }
+
+    synchronized DevmodeStructWrapper getPrinterProps() {
+        if (dmStruct == null) {
+            try {
+                dmStruct = new DevmodeStructWrapper(WinPrinterFactory
+                                .getPrinterProps(printerName,
+                                                getPrinterHandle()));
+            } catch (final PrintException ex) {
+                throw new RuntimeException(ex);
+            }
+        }
+
+        return dmStruct;
+    }
+
+    synchronized DevmodeStructWrapper getDefaultPrinterProps() {
+        if (defaultDmStruct == null) {
+            try {
+                defaultDmStruct = new DevmodeStructWrapper(WinPrinterFactory
+                                .getPrinterProps(printerName,
+                                                getPrinterHandle()));
+            } catch (final PrintException ex) {
+                throw new RuntimeException(ex);
+            }
+        }
+
+        return defaultDmStruct;
+    }
+
+    @Override
+    protected synchronized void finalize() {
+        if (pHandle > 0) {
+            try {
+                WinPrinterFactory.releasePrinterHandle(pHandle);
+                pHandle = 0;
+                dmStruct = null;
+                defaultDmStruct = null;
+            } catch (final PrintException ex) {
+                throw new RuntimeException(ex);
+            }
+        }
+    }
+
+    private static <T> boolean arrayContains(final T[] array, final T val) {
+        for (T a : array) {
+            if (a.equals(val)) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    private static String getSystemProperty(final String name) {
+        return AccessController.doPrivileged(new PrivilegedAction<String>() {
+            public String run() {
+                return System.getProperty(name);
+            }
+        });
+    }
+
+    private void notifyListeners(final PrintServiceAttribute... attrs) {
+        final PrintServiceAttributeEvent event = new PrintServiceAttributeEvent(
+                        this, new HashPrintServiceAttributeSet(attrs));
+        for (PrintServiceAttributeListener listener : attrListeners.keySet()) {
+            listener.attributeUpdate(event);
+        }
+    }
+
+    private Paper getDefaultPaper() {
+        final Paper p = getDefaultPrinterProps().getPaper();
+        return p != null ? p : StdPaper.ISO_A4;
+    }
+
+    private void checkFlavor(final DocFlavor flavor) {
+        if ((flavor != null) && !isDocFlavorSupported(flavor)) {
+            throw new IllegalArgumentException("unsupported flavor"); //$NON-NLS-1$
+        }
+    }
+
+    private void checkArgs(final Class<? extends Attribute> category,
+                    final DocFlavor flavor) {
+        if (category == null) {
+            throw new NullPointerException("category should not be null"); //$NON-NLS-1$
+        }
+
+        if (!Attribute.class.isAssignableFrom(category)) {
+            throw new IllegalArgumentException(category
+                            + " is not assignable from Attribute"); //$NON-NLS-1$
+        }
+
+        checkFlavor(flavor);
+    }
+}

Propchange: harmony/enhanced/classlib/trunk/modules/print/src/main/java/windows/org/apache/harmony/x/print/WinPrintService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/classlib/trunk/modules/print/src/main/java/windows/org/apache/harmony/x/print/WinPrintServiceLookup.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/print/src/main/java/windows/org/apache/harmony/x/print/WinPrintServiceLookup.java?rev=593524&view=auto
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/print/src/main/java/windows/org/apache/harmony/x/print/WinPrintServiceLookup.java (added)
+++ harmony/enhanced/classlib/trunk/modules/print/src/main/java/windows/org/apache/harmony/x/print/WinPrintServiceLookup.java Fri Nov  9 05:45:45 2007
@@ -0,0 +1,82 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.harmony.x.print;
+
+import java.util.Vector;
+
+import javax.print.DocFlavor;
+import javax.print.MultiDocPrintService;
+import javax.print.PrintException;
+import javax.print.PrintService;
+import javax.print.PrintServiceLookup;
+import javax.print.attribute.AttributeSet;
+
+public class WinPrintServiceLookup extends PrintServiceLookup {
+
+    @Override
+    public PrintService getDefaultPrintService() {
+        try {
+            return new WinPrintService(WinPrinterFactory
+                            .getDefaultPrinterName());
+        } catch (PrintException e) {
+            return null;
+        }
+    }
+
+    @Override
+    public MultiDocPrintService[] getMultiDocPrintServices(
+                    final DocFlavor[] flavors, final AttributeSet attributes) {
+        return new MultiDocPrintService[0];
+    }
+
+    @Override
+    public PrintService[] getPrintServices() {
+        try {
+            final String[] names = WinPrinterFactory.getConnectedPrinterNames();
+            final PrintService[] srv = new PrintService[names.length];
+
+            for (int i = 0; i < names.length; i++) {
+                srv[i] = new WinPrintService(names[i]);
+            }
+
+            return srv;
+        } catch (PrintException e) {
+            return new PrintService[0];
+        }
+    }
+
+    @Override
+    public PrintService[] getPrintServices(final DocFlavor flavor,
+                    final AttributeSet attributes) {
+        final PrintService[] matchingServices;
+        final PrintService[] allServices = getPrintServices();
+        final Vector<PrintService> v = new Vector<PrintService>(
+                        allServices.length);
+
+        for (PrintService srv : allServices) {
+            if (((flavor == null) || srv.isDocFlavorSupported(flavor))
+                            && (srv
+                                            .getUnsupportedAttributes(flavor,
+                                                            attributes) == null)) {
+                v.add(srv);
+            }
+        }
+
+        matchingServices = new PrintService[v.size()];
+        return v.toArray(matchingServices);
+    }
+}

Propchange: harmony/enhanced/classlib/trunk/modules/print/src/main/java/windows/org/apache/harmony/x/print/WinPrintServiceLookup.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/classlib/trunk/modules/print/src/main/java/windows/org/apache/harmony/x/print/WinPrinterFactory.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/print/src/main/java/windows/org/apache/harmony/x/print/WinPrinterFactory.java?rev=593524&view=auto
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/print/src/main/java/windows/org/apache/harmony/x/print/WinPrinterFactory.java (added)
+++ harmony/enhanced/classlib/trunk/modules/print/src/main/java/windows/org/apache/harmony/x/print/WinPrinterFactory.java Fri Nov  9 05:45:45 2007
@@ -0,0 +1,234 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.harmony.x.print;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.Vector;
+
+import javax.print.PrintException;
+import javax.print.attribute.ResolutionSyntax;
+import javax.print.attribute.Size2DSyntax;
+import javax.print.attribute.standard.MediaSize;
+import javax.print.attribute.standard.MediaSizeName;
+import javax.print.attribute.standard.OrientationRequested;
+import javax.print.attribute.standard.PrinterResolution;
+import javax.print.attribute.standard.PrinterState;
+import javax.print.attribute.standard.QueuedJobCount;
+
+public class WinPrinterFactory {
+
+    public static final int PRINTER_STATUS_PAUSED            = 1;
+    public static final int PRINTER_STATUS_ERROR             = 2;
+    public static final int PRINTER_STATUS_PENDING_DELETION  = 4;
+    public static final int PRINTER_STATUS_PAPER_JAM         = 8;
+    public static final int PRINTER_STATUS_PAPER_OUT         = 0x10;
+    public static final int PRINTER_STATUS_MANUAL_FEED       = 0x20;
+    public static final int PRINTER_STATUS_PAPER_PROBLEM     = 0x40;
+    public static final int PRINTER_STATUS_OFFLINE           = 0x80;
+    public static final int PRINTER_STATUS_IO_ACTIVE         = 0x100;
+    public static final int PRINTER_STATUS_BUSY              = 0x200;
+    public static final int PRINTER_STATUS_PRINTING          = 0x400;
+    public static final int PRINTER_STATUS_OUTPUT_BIN_FULL   = 0x800;
+    public static final int PRINTER_STATUS_NOT_AVAILABLE     = 0x1000;
+    public static final int PRINTER_STATUS_WAITING           = 0x2000;
+    public static final int PRINTER_STATUS_PROCESSING        = 0x4000;
+    public static final int PRINTER_STATUS_INITIALIZING      = 0x8000;
+    public static final int PRINTER_STATUS_WARMING_UP        = 0x10000;
+    public static final int PRINTER_STATUS_TONER_LOW         = 0x20000;
+    public static final int PRINTER_STATUS_NO_TONER          = 0x40000;
+    public static final int PRINTER_STATUS_PAGE_PUNT         = 0x80000;
+    public static final int PRINTER_STATUS_USER_INTERVENTION = 0x100000;
+    public static final int PRINTER_STATUS_OUT_OF_MEMORY     = 0x200000;
+    public static final int PRINTER_STATUS_DOOR_OPEN         = 0x400000;
+    public static final int PRINTER_STATUS_SERVER_UNKNOWN    = 0x800000;
+    public static final int PRINTER_STATUS_POWER_SAVE        = 0x1000000;
+
+    static {
+        checkPrintJobAccess();
+        AccessController.doPrivileged(new PrivilegedAction<Object>() {
+            public Object run() {
+                System.loadLibrary("print"); //$NON-NLS-1$
+                return null;
+            }
+        });
+    }
+
+    public static PrinterState getPrinterState(final long handle)
+                    throws PrintException {
+        final long status = getPrinterStatus(handle);
+
+        if ((status & (PRINTER_STATUS_PRINTING | PRINTER_STATUS_PROCESSING)) != 0) {
+            return PrinterState.PROCESSING;
+        } else if ((status & (PRINTER_STATUS_DOOR_OPEN | PRINTER_STATUS_ERROR
+                        | PRINTER_STATUS_NO_TONER
+                        | PRINTER_STATUS_NOT_AVAILABLE | PRINTER_STATUS_OFFLINE
+                        | PRINTER_STATUS_OUT_OF_MEMORY
+                        | PRINTER_STATUS_OUTPUT_BIN_FULL
+                        | PRINTER_STATUS_PAPER_JAM | PRINTER_STATUS_PAPER_OUT
+                        | PRINTER_STATUS_PAPER_PROBLEM | PRINTER_STATUS_USER_INTERVENTION)) != 0) {
+            return PrinterState.STOPPED;
+        } else if ((status & PRINTER_STATUS_SERVER_UNKNOWN) != 0) {
+            return PrinterState.UNKNOWN;
+        } else {
+            return PrinterState.IDLE;
+        }
+    }
+
+    public static QueuedJobCount getQueuedJobCount(final long handle)
+                    throws PrintException {
+        return new QueuedJobCount(getQueuedJobs(handle));
+    }
+
+    public static MediaSizeName[] getSupportedMediaSizeNames(final long handle)
+                    throws PrintException {
+        final MediaSizeName[] names;
+        final int[] sizes = getSupportedPaperSizes(handle);
+        final Vector<MediaSizeName> v = new Vector<MediaSizeName>(
+                        sizes.length / 2);
+
+        for (int i = 0; i < sizes.length; i += 2) {
+            if ((sizes[i] > 0) && (sizes[i + 1] > 0)) {
+                final MediaSizeName name = MediaSize.findMedia(sizes[i] / 10,
+                                sizes[i + 1] / 10, Size2DSyntax.MM);
+
+                if ((name != null) && !v.contains(name)) {
+                    v.add(name);
+                }
+            }
+        }
+
+        names = new MediaSizeName[v.size()];
+        return v.toArray(names);
+    }
+
+    public static MediaSize[] getSupportedMediaSizes(final long handle)
+                    throws PrintException {
+        final MediaSizeName[] names = getSupportedMediaSizeNames(handle);
+        final MediaSize[] sizes = new MediaSize[names.length];
+
+        for (int i = 0; i < names.length; i++) {
+            sizes[i] = MediaSize.getMediaSizeForName(names[i]);
+        }
+
+        return sizes;
+    }
+
+    public static OrientationRequested[] getSupportedOrientations(
+                    final long handle) throws PrintException {
+        if (getLandscapeOrientationDegree(handle) == 270) {
+            return new OrientationRequested[] { OrientationRequested.PORTRAIT,
+                            OrientationRequested.REVERSE_LANDSCAPE };
+        }
+        return new OrientationRequested[] { OrientationRequested.PORTRAIT,
+                        OrientationRequested.LANDSCAPE };
+    }
+
+    public static PrinterResolution[] getSupportedPrinterResolutions(
+                    final long handle) throws PrintException {
+        final int[] res = getSupportedResolutions(handle);
+        final PrinterResolution[] resolutions = new PrinterResolution[res.length / 2];
+
+        for (int i = 0; i < res.length; i += 2) {
+            resolutions[i / 2] = new PrinterResolution(res[i], res[i + 1],
+                            ResolutionSyntax.DPI);
+        }
+        return resolutions;
+    }
+
+    public static void checkPrintJobAccess() {
+        final SecurityManager mgr = System.getSecurityManager();
+
+        if (mgr != null) {
+            mgr.checkPrintJobAccess();
+        }
+    }
+
+    public static native String getDefaultPrinterName() throws PrintException;
+
+    public static native String[] getConnectedPrinterNames()
+                    throws PrintException;
+
+    public static native long getPrinterHandle(final String printerName)
+                    throws PrintException;
+
+    public static native void releasePrinterHandle(final long handle)
+                    throws PrintException;
+
+    /**
+     * Returns pointer to DEVMODEW structure
+     */
+    public static native long getPrinterProps(final String printerName,
+                    final long handle) throws PrintException;
+
+    public static native long getPrinterDC(final String printerName,
+                    final long pDevMode) throws PrintException;
+
+    public static native void releasePrinterDC(final long pdc)
+                    throws PrintException;
+
+    public static native int startDoc(final long pdc, final String docName,
+                    final String filePath) throws PrintException;
+
+    public static native void endDoc(final long pdc) throws PrintException;
+
+    public static native void startPage(final long pdc) throws PrintException;
+
+    public static native void endPage(final long pdc) throws PrintException;
+
+    public static native int getQueuedJobs(final long handle)
+                    throws PrintException;
+
+    public static native int getPixelsPerInchX(final long pdc)
+                    throws PrintException;
+
+    public static native int getPixelsPerInchY(final long pdc)
+                    throws PrintException;
+
+    public static native int getPaperPhysicalWidth(final long pdc)
+                    throws PrintException;
+
+    public static native int getPaperPhysicalHeight(final long pdc)
+                    throws PrintException;
+
+    public static native long getPrinterStatus(final long handle)
+                    throws PrintException;
+
+    public static native boolean isColorPrintingSupported(final long handle)
+                    throws PrintException;
+
+    public static native boolean isCollatingSupported(final long handle)
+                    throws PrintException;
+
+    public static native boolean isDuplexSupported(final long handle)
+                    throws PrintException;
+
+    public static native int[] getSupportedPaperSizes(final long handle)
+                    throws PrintException;
+
+    public static native int[] getSupportedResolutions(final long handle)
+                    throws PrintException;
+
+    public static native int getLandscapeOrientationDegree(final long handle)
+                    throws PrintException;
+
+    public static native int getMaxNumberOfCopies(final long handle)
+                    throws PrintException;
+
+    public static native void cancelPrinterJob(final long handle,
+                    final int jobId) throws PrintException;
+}

Propchange: harmony/enhanced/classlib/trunk/modules/print/src/main/java/windows/org/apache/harmony/x/print/WinPrinterFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: harmony/enhanced/classlib/trunk/modules/print/src/main/java/windows/org/apache/harmony/x/print/javax.print.PrintServiceLookup
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/print/src/main/java/windows/org/apache/harmony/x/print/javax.print.PrintServiceLookup?rev=593524&r1=593523&r2=593524&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/print/src/main/java/windows/org/apache/harmony/x/print/javax.print.PrintServiceLookup (original)
+++ harmony/enhanced/classlib/trunk/modules/print/src/main/java/windows/org/apache/harmony/x/print/javax.print.PrintServiceLookup Fri Nov  9 05:45:45 2007
@@ -1,2 +1,3 @@
-org.apache.harmony.x.print.Win32PrintServiceProvider
-org.apache.harmony.x.print.cups.CUPSPrintServiceProvider
+org.apache.harmony.x.print.WinPrintServiceLookup
+#org.apache.harmony.x.print.Win32PrintServiceProvider
+#org.apache.harmony.x.print.cups.CUPSPrintServiceProvider

Added: harmony/enhanced/classlib/trunk/modules/print/src/main/native/print/windows/devmode_struct_wrapper.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/print/src/main/native/print/windows/devmode_struct_wrapper.c?rev=593524&view=auto
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/print/src/main/native/print/windows/devmode_struct_wrapper.c (added)
+++ harmony/enhanced/classlib/trunk/modules/print/src/main/native/print/windows/devmode_struct_wrapper.c Fri Nov  9 05:45:45 2007
@@ -0,0 +1,154 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+#include "devmode_struct_wrapper.h"
+#include <windows.h>
+
+#define DMSTR(jlongVal) ((DEVMODEW *) (unsigned long) jlongVal)
+
+JNIEXPORT jstring JNICALL Java_org_apache_harmony_x_print_DevmodeStructWrapper_getDmDeviceName(JNIEnv * env, jclass c, jlong ptr) {
+	if (DMSTR(ptr)->dmDeviceName != NULL) {
+		return (*env)->NewString(env, DMSTR(ptr)->dmDeviceName,
+				wcslen(DMSTR(ptr)->dmDeviceName));
+	}
+
+	return NULL;
+}
+
+JNIEXPORT jlong JNICALL Java_org_apache_harmony_x_print_DevmodeStructWrapper_getDmFields(JNIEnv * env, jclass c, jlong ptr) {
+	return DMSTR(ptr)->dmFields;
+}
+
+JNIEXPORT jshort JNICALL Java_org_apache_harmony_x_print_DevmodeStructWrapper_getDmOrientation(JNIEnv * env, jclass c, jlong ptr) {
+	return DMSTR(ptr)->dmOrientation;
+}
+
+JNIEXPORT void JNICALL Java_org_apache_harmony_x_print_DevmodeStructWrapper_setDmOrientation(JNIEnv * env, jclass c, jlong ptr, jshort val) {
+	DMSTR(ptr)->dmOrientation = val;
+	DMSTR(ptr)->dmFields |= DM_ORIENTATION;
+}
+
+JNIEXPORT jshort JNICALL Java_org_apache_harmony_x_print_DevmodeStructWrapper_getDmPaperSize(JNIEnv * env, jclass c, jlong ptr) {
+	return DMSTR(ptr)->dmPaperSize;
+}
+
+JNIEXPORT void JNICALL Java_org_apache_harmony_x_print_DevmodeStructWrapper_setDmPaperSize(JNIEnv * env, jclass c, jlong ptr, jshort val) {
+	DMSTR(ptr)->dmPaperSize = val;
+	DMSTR(ptr)->dmFields |= DM_PAPERSIZE;
+}
+
+JNIEXPORT jshort JNICALL Java_org_apache_harmony_x_print_DevmodeStructWrapper_getDmPaperLength(JNIEnv * env, jclass c, jlong ptr) {
+	return DMSTR(ptr)->dmPaperLength;
+}
+
+JNIEXPORT void JNICALL Java_org_apache_harmony_x_print_DevmodeStructWrapper_setDmPaperLength(JNIEnv * env, jclass c, jlong ptr, jshort val) {
+	DMSTR(ptr)->dmPaperLength = val;
+	DMSTR(ptr)->dmFields |= DM_PAPERLENGTH;
+}
+
+JNIEXPORT jshort JNICALL Java_org_apache_harmony_x_print_DevmodeStructWrapper_getDmPaperWidth(JNIEnv * env, jclass c, jlong ptr) {
+	return DMSTR(ptr)->dmPaperWidth;
+}
+
+JNIEXPORT void JNICALL Java_org_apache_harmony_x_print_DevmodeStructWrapper_setDmPaperWidth(JNIEnv * env, jclass c, jlong ptr, jshort val) {
+	DMSTR(ptr)->dmPaperWidth = val;
+	DMSTR(ptr)->dmFields |= DM_PAPERWIDTH;
+}
+
+JNIEXPORT jshort JNICALL Java_org_apache_harmony_x_print_DevmodeStructWrapper_getDmScale(JNIEnv * env, jclass c, jlong ptr) {
+	return DMSTR(ptr)->dmScale;
+}
+
+JNIEXPORT void JNICALL Java_org_apache_harmony_x_print_DevmodeStructWrapper_setDmScale(JNIEnv * env, jclass c, jlong ptr, jshort val) {
+	DMSTR(ptr)->dmScale = val;
+	DMSTR(ptr)->dmFields |= DM_SCALE;
+}
+
+JNIEXPORT jshort JNICALL Java_org_apache_harmony_x_print_DevmodeStructWrapper_getDmCopies(JNIEnv * env, jclass c, jlong ptr) {
+	return DMSTR(ptr)->dmCopies;
+}
+
+JNIEXPORT void JNICALL Java_org_apache_harmony_x_print_DevmodeStructWrapper_setDmCopies(JNIEnv * env, jclass c, jlong ptr, jshort val) {
+	DMSTR(ptr)->dmCopies = val;
+	DMSTR(ptr)->dmFields |= DM_COPIES;
+}
+
+JNIEXPORT jshort JNICALL Java_org_apache_harmony_x_print_DevmodeStructWrapper_getDmDefaultSource(JNIEnv * env, jclass c, jlong ptr) {
+	return DMSTR(ptr)->dmDefaultSource;
+}
+
+JNIEXPORT void JNICALL Java_org_apache_harmony_x_print_DevmodeStructWrapper_setDmDefaultSource(JNIEnv * env, jclass c, jlong ptr, jshort val) {
+	DMSTR(ptr)->dmDefaultSource = val;
+	DMSTR(ptr)->dmFields |= DM_DEFAULTSOURCE;
+}
+
+JNIEXPORT jshort JNICALL Java_org_apache_harmony_x_print_DevmodeStructWrapper_getDmPrintQuality(JNIEnv * env, jclass c, jlong ptr) {
+	return DMSTR(ptr)->dmPrintQuality;
+}
+
+JNIEXPORT void JNICALL Java_org_apache_harmony_x_print_DevmodeStructWrapper_setDmPrintQuality(JNIEnv * env, jclass c, jlong ptr, jshort val) {
+	DMSTR(ptr)->dmPrintQuality = val;
+	DMSTR(ptr)->dmFields |= DM_PRINTQUALITY;
+}
+
+JNIEXPORT jshort JNICALL Java_org_apache_harmony_x_print_DevmodeStructWrapper_getDmColor(JNIEnv * env, jclass c, jlong ptr) {
+	return DMSTR(ptr)->dmColor;
+}
+
+JNIEXPORT void JNICALL Java_org_apache_harmony_x_print_DevmodeStructWrapper_setDmColor(JNIEnv * env, jclass c, jlong ptr, jshort val) {
+	DMSTR(ptr)->dmColor = val;
+	DMSTR(ptr)->dmFields |= DM_COLOR;
+}
+
+JNIEXPORT jshort JNICALL Java_org_apache_harmony_x_print_DevmodeStructWrapper_getDmDuplex(JNIEnv * env, jclass c, jlong ptr) {
+	return DMSTR(ptr)->dmDuplex;
+}
+
+JNIEXPORT void JNICALL Java_org_apache_harmony_x_print_DevmodeStructWrapper_setDmDuplex(JNIEnv * env, jclass c, jlong ptr, jshort val) {
+	DMSTR(ptr)->dmDuplex = val;
+	DMSTR(ptr)->dmFields |= DM_DUPLEX;
+}
+
+JNIEXPORT jshort JNICALL Java_org_apache_harmony_x_print_DevmodeStructWrapper_getDmYResolution(JNIEnv * env, jclass c, jlong ptr) {
+	return DMSTR(ptr)->dmYResolution;
+}
+
+JNIEXPORT void JNICALL Java_org_apache_harmony_x_print_DevmodeStructWrapper_setDmYResolution(JNIEnv * env, jclass c, jlong ptr, jshort val) {
+	DMSTR(ptr)->dmYResolution = val;
+	DMSTR(ptr)->dmFields |= DM_YRESOLUTION;
+}
+
+JNIEXPORT jshort JNICALL Java_org_apache_harmony_x_print_DevmodeStructWrapper_getDmTTOption(JNIEnv * env, jclass c, jlong ptr) {
+	return DMSTR(ptr)->dmTTOption;
+}
+
+JNIEXPORT void JNICALL Java_org_apache_harmony_x_print_DevmodeStructWrapper_setDmTTOption(JNIEnv * env, jclass c, jlong ptr, jshort val) {
+	DMSTR(ptr)->dmTTOption = val;
+	DMSTR(ptr)->dmFields |= DM_TTOPTION;
+}
+
+JNIEXPORT jshort JNICALL Java_org_apache_harmony_x_print_DevmodeStructWrapper_getDmCollate(JNIEnv * env, jclass c, jlong ptr) {
+	return DMSTR(ptr)->dmCollate;
+}
+
+JNIEXPORT void JNICALL Java_org_apache_harmony_x_print_DevmodeStructWrapper_setDmCollate(JNIEnv * env, jclass c, jlong ptr, jshort val) {
+	DMSTR(ptr)->dmCollate = val;
+	DMSTR(ptr)->dmFields |= DM_COLLATE;
+}
+
+JNIEXPORT void JNICALL Java_org_apache_harmony_x_print_DevmodeStructWrapper_releaseStruct(JNIEnv * env, jclass c, jlong ptr) {
+	free(DMSTR(ptr));
+}

Propchange: harmony/enhanced/classlib/trunk/modules/print/src/main/native/print/windows/devmode_struct_wrapper.c
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message