“18183a491ab7017c4a8c7c344d80bdf8f526cab8”上不存在“test/java/lang/reflect/Generics/SignatureTest.java”
提交 5ff8fe72 编写于 作者: P prr

8016485: Windows native print dialog does not reflect default printer settings

Reviewed-by: jgodinez, jchen
上级 fa61b182
......@@ -1269,11 +1269,13 @@ public class WPrinterJob extends RasterPrinterJob implements DisposerTarget {
mLastFontFamily = null;
}
private boolean defaultCopies = true;
/**
* Set the number of copies to be printed.
*/
public void setCopies(int copies) {
super.setCopies(copies);
defaultCopies = false;
mAttCopies = copies;
setNativeCopies(copies);
}
......@@ -1529,8 +1531,9 @@ public class WPrinterJob extends RasterPrinterJob implements DisposerTarget {
}
/* SheetCollate */
private final boolean getCollateAttrib() {
return (mAttCollate == 1);
private final int getCollateAttrib() {
// -1 means unset, 0 uncollated, 1 collated.
return mAttCollate;
}
private void setCollateAttrib(Attribute attr) {
......@@ -1553,6 +1556,10 @@ public class WPrinterJob extends RasterPrinterJob implements DisposerTarget {
int orient = PageFormat.PORTRAIT;
OrientationRequested orientReq = (attributes == null) ? null :
(OrientationRequested)attributes.get(OrientationRequested.class);
if (orientReq == null) {
orientReq = (OrientationRequested)
myService.getDefaultAttributeValue(OrientationRequested.class);
}
if (orientReq != null) {
if (orientReq == OrientationRequested.REVERSE_LANDSCAPE) {
orient = PageFormat.REVERSE_LANDSCAPE;
......@@ -1573,7 +1580,11 @@ public class WPrinterJob extends RasterPrinterJob implements DisposerTarget {
/* Copies and Page Range. */
private final int getCopiesAttrib() {
return getCopiesInt();
if (defaultCopies) {
return 0;
} else {
return getCopiesInt();
}
}
private final void setRangeCopiesAttribute(int from, int to,
......@@ -1584,6 +1595,7 @@ public class WPrinterJob extends RasterPrinterJob implements DisposerTarget {
attributes.add(new PageRanges(from, to));
setPageRange(from, to);
}
defaultCopies = false;
attributes.add(new Copies(copies));
/* Since this is called from native to tell Java to sync
* up with native, we don't call this class's own setCopies()
......
......@@ -180,6 +180,9 @@ public class Win32PrintService implements PrintService, AttributeUpdater,
private static final int DMDUP_VERTICAL = 2;
private static final int DMDUP_HORIZONTAL = 3;
private static final int DMCOLLATE_TRUE = 1;
private static final int DMCOLOR_MONOCHROME = 1;
private static final int DMCOLOR_COLOR = 2;
// media sizes with indices above dmPaperToPrintService' length
private static final int DMPAPER_A2 = 66;
......@@ -1041,6 +1044,7 @@ public class Win32PrintService implements PrintService, AttributeUpdater,
int defOrient = defaults[5];
int defSides = defaults[6];
int defCollate = defaults[7];
int defColor = defaults[8];
if (category == Copies.class) {
if (defCopies > 0) {
......@@ -1049,11 +1053,10 @@ public class Win32PrintService implements PrintService, AttributeUpdater,
return new Copies(1);
}
} else if (category == Chromaticity.class) {
int caps = getPrinterCapabilities();
if ((caps & DEVCAP_COLOR) == 0) {
return Chromaticity.MONOCHROME;
} else {
if (defColor == DMCOLOR_COLOR) {
return Chromaticity.COLOR;
} else {
return Chromaticity.MONOCHROME;
}
} else if (category == JobName.class) {
return new JobName("Java Printing", null);
......
......@@ -750,7 +750,7 @@ Java_sun_print_Win32PrintService_getCapabilities(JNIEnv *env,
#define GETDEFAULT_ERROR -50
#define NDEFAULT 8
#define NDEFAULT 9
JNIEXPORT jintArray JNICALL
Java_sun_print_Win32PrintService_getDefaultSettings(JNIEnv *env,
......@@ -859,6 +859,11 @@ Java_sun_print_Win32PrintService_getDefaultSettings(JNIEnv *env,
defIndices[7] = pDevMode->dmCollate;
}
if (pDevMode->dmFields & DM_COLOR) {
defIndices[8] = pDevMode->dmColor;
}
GlobalFree(pDevMode);
::ClosePrinter(hPrinter);
......
......@@ -252,7 +252,7 @@ void AwtPrintControl::initIDs(JNIEnv *env, jclass cls)
AwtPrintControl::getCopiesID =
env->GetMethodID(cls, "getCopiesAttrib", "()I");
AwtPrintControl::getCollateID =
env->GetMethodID(cls, "getCollateAttrib","()Z");
env->GetMethodID(cls, "getCollateAttrib","()I");
AwtPrintControl::getOrientID =
env->GetMethodID(cls, "getOrientAttrib", "()I");
AwtPrintControl::getFromPageID =
......@@ -690,12 +690,6 @@ BOOL AwtPrintControl::InitPrintDialog(JNIEnv *env,
pd.Flags = PD_ENABLEPRINTHOOK | PD_RETURNDC | PD_USEDEVMODECOPIESANDCOLLATE;
pd.lpfnPrintHook = (LPPRINTHOOKPROC)PrintDlgHook;
if (env->CallBooleanMethod(printCtrl, AwtPrintControl::getCollateID)) {
pd.Flags |= PD_COLLATE;
}
pd.nCopies = (WORD)env->CallIntMethod(printCtrl,
AwtPrintControl::getCopiesID);
pd.nFromPage = (WORD)env->CallIntMethod(printCtrl,
AwtPrintControl::getFromPageID);
pd.nToPage = (WORD)env->CallIntMethod(printCtrl,
......@@ -729,37 +723,52 @@ BOOL AwtPrintControl::InitPrintDialog(JNIEnv *env,
DEVMODE *devmode = (DEVMODE *)::GlobalLock(pd.hDevMode);
DASSERT(!IsBadWritePtr(devmode, sizeof(DEVMODE)));
devmode->dmFields |= DM_COPIES | DM_COLLATE | DM_ORIENTATION |
DM_PAPERSIZE | DM_PRINTQUALITY | DM_COLOR | DM_DUPLEX;
devmode->dmCopies = pd.nCopies;
WORD copies = (WORD)env->CallIntMethod(printCtrl,
AwtPrintControl::getCopiesID);
if (copies > 0) {
devmode->dmFields |= DM_COPIES;
devmode->dmCopies = copies;
}
jint orient = env->CallIntMethod(printCtrl,
AwtPrintControl::getOrientID);
if (orient == 0) {
if (orient == 0) { // PageFormat.LANDSCAPE == 0
devmode->dmFields |= DM_ORIENTATION;
devmode->dmOrientation = DMORIENT_LANDSCAPE;
} else if (orient == 1) {
} else if (orient == 1) { // PageFormat.PORTRAIT == 1
devmode->dmFields |= DM_ORIENTATION;
devmode->dmOrientation = DMORIENT_PORTRAIT;
}
devmode->dmCollate = (pd.Flags & PD_COLLATE) ? DMCOLLATE_TRUE
: DMCOLLATE_FALSE;
// -1 means unset, so we'll accept the printer default.
int collate = env->CallIntMethod(printCtrl,
AwtPrintControl::getCollateID);
if (collate == 1) {
devmode->dmFields |= DM_COLLATE;
devmode->dmCollate = DMCOLLATE_TRUE;
} else if (collate == 0) {
devmode->dmFields |= DM_COLLATE;
devmode->dmCollate = DMCOLLATE_FALSE;
}
int quality = env->CallIntMethod(printCtrl,
AwtPrintControl::getQualityID);
if (quality) {
devmode->dmFields |= DM_PRINTQUALITY;
devmode->dmPrintQuality = quality;
}
int color = env->CallIntMethod(printCtrl,
AwtPrintControl::getColorID);
if (color) {
devmode->dmFields |= DM_COLOR;
devmode->dmColor = color;
}
int sides = env->CallIntMethod(printCtrl,
AwtPrintControl::getSidesID);
if (sides) {
devmode->dmFields |= DM_DUPLEX;
devmode->dmDuplex = (int)sides;
}
......@@ -771,6 +780,7 @@ BOOL AwtPrintControl::InitPrintDialog(JNIEnv *env,
double newWid = 0.0, newHt = 0.0;
if (wid_ht != NULL && wid_ht[0] != 0 && wid_ht[1] != 0) {
devmode->dmFields |= DM_PAPERSIZE;
devmode->dmPaperSize = AwtPrintControl::getNearestMatchingPaper(
printName,
portName,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册