Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
1394065b
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
4
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_jdk
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
1394065b
编写于
4月 03, 2017
作者:
P
psadhukhan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8061258: [macosx] PrinterJob's native Print Dialog does not reflect specified Copies or Page Ranges
Reviewed-by: prr, jdv
上级
75a8ac6b
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
177 addition
and
21 deletion
+177
-21
src/macosx/native/sun/awt/CPrinterJob.m
src/macosx/native/sun/awt/CPrinterJob.m
+25
-21
test/java/awt/print/PrinterJob/DlgAttrsBug.java
test/java/awt/print/PrinterJob/DlgAttrsBug.java
+152
-0
未找到文件。
src/macosx/native/sun/awt/CPrinterJob.m
浏览文件 @
1394065b
...
@@ -361,6 +361,8 @@ static void javaPrinterJobToNSPrintInfo(JNIEnv* env, jobject srcPrinterJob, jobj
...
@@ -361,6 +361,8 @@ static void javaPrinterJobToNSPrintInfo(JNIEnv* env, jobject srcPrinterJob, jobj
static JNF_MEMBER_CACHE(jm_isCollated, sjc_CPrinterJob, "isCollated", "()Z");
static JNF_MEMBER_CACHE(jm_isCollated, sjc_CPrinterJob, "isCollated", "()Z");
static JNF_MEMBER_CACHE(jm_getFromPage, sjc_CPrinterJob, "getFromPageAttrib", "()I");
static JNF_MEMBER_CACHE(jm_getFromPage, sjc_CPrinterJob, "getFromPageAttrib", "()I");
static JNF_MEMBER_CACHE(jm_getToPage, sjc_CPrinterJob, "getToPageAttrib", "()I");
static JNF_MEMBER_CACHE(jm_getToPage, sjc_CPrinterJob, "getToPageAttrib", "()I");
static JNF_MEMBER_CACHE(jm_getMinPage, sjc_CPrinterJob, "getMinPageAttrib", "()I");
static JNF_MEMBER_CACHE(jm_getMaxPage, sjc_CPrinterJob, "getMaxPageAttrib", "()I");
static JNF_MEMBER_CACHE(jm_getSelectAttrib, sjc_CPrinterJob, "getSelectAttrib", "()I");
static JNF_MEMBER_CACHE(jm_getSelectAttrib, sjc_CPrinterJob, "getSelectAttrib", "()I");
static JNF_MEMBER_CACHE(jm_getNumberOfPages, jc_Pageable, "getNumberOfPages", "()I");
static JNF_MEMBER_CACHE(jm_getNumberOfPages, jc_Pageable, "getNumberOfPages", "()I");
static JNF_MEMBER_CACHE(jm_getPageFormat, sjc_CPrinterJob, "getPageFormatFromAttributes", "()Ljava/awt/print/PageFormat;");
static JNF_MEMBER_CACHE(jm_getPageFormat, sjc_CPrinterJob, "getPageFormatFromAttributes", "()Ljava/awt/print/PageFormat;");
...
@@ -372,31 +374,33 @@ static void javaPrinterJobToNSPrintInfo(JNIEnv* env, jobject srcPrinterJob, jobj
...
@@ -372,31 +374,33 @@ static void javaPrinterJobToNSPrintInfo(JNIEnv* env, jobject srcPrinterJob, jobj
jboolean collated = JNFCallBooleanMethod(env, srcPrinterJob, jm_isCollated); // AWT_THREADING Safe (known object)
jboolean collated = JNFCallBooleanMethod(env, srcPrinterJob, jm_isCollated); // AWT_THREADING Safe (known object)
[printingDictionary setObject:[NSNumber numberWithBool:collated ? YES : NO] forKey:NSPrintMustCollate];
[printingDictionary setObject:[NSNumber numberWithBool:collated ? YES : NO] forKey:NSPrintMustCollate];
jint jNumPages = JNFCallIntMethod(env, srcPageable, jm_getNumberOfPages); // AWT_THREADING Safe (!appKit)
jint selectID = JNFCallIntMethod(env, srcPrinterJob, jm_getSelectAttrib);
if (jNumPages != java_awt_print_Pageable_UNKNOWN_NUMBER_OF_PAGES)
jint fromPage = JNFCallIntMethod(env, srcPrinterJob, jm_getFromPage);
{
jint toPage = JNFCallIntMethod(env, srcPrinterJob, jm_getToPage);
jint selectID = JNFCallIntMethod(env, srcPrinterJob, jm_getSelectAttrib);
if (selectID ==0) {
if (selectID ==0) {
[printingDictionary setObject:[NSNumber numberWithBool:YES] forKey:NSPrintAllPages];
[printingDictionary setObject:[NSNumber numberWithBool:YES] forKey:NSPrintAllPages];
} else if (selectID == 2) {
} else if (selectID == 2) {
// In Mac 10.7, Print ALL is deselected if PrintSelection is YES whether
// In Mac 10.7, Print ALL is deselected if PrintSelection is YES whether
// NSPrintAllPages is YES or NO
// NSPrintAllPages is YES or NO
[printingDictionary setObject:[NSNumber numberWithBool:NO] forKey:NSPrintAllPages];
[printingDictionary setObject:[NSNumber numberWithBool:YES] forKey:NSPrintSelectionOnly];
} else {
jint minPage = JNFCallIntMethod(env, srcPrinterJob, jm_getMinPage);
jint maxPage = JNFCallIntMethod(env, srcPrinterJob, jm_getMaxPage);
// for PD_SELECTION or PD_NOSELECTION, check from/to page
// to determine which radio button to select
if (fromPage > minPage || toPage < maxPage) {
[printingDictionary setObject:[NSNumber numberWithBool:NO] forKey:NSPrintAllPages];
[printingDictionary setObject:[NSNumber numberWithBool:NO] forKey:NSPrintAllPages];
[printingDictionary setObject:[NSNumber numberWithBool:YES] forKey:NSPrintSelectionOnly];
} else {
} else {
[printingDictionary setObject:[NSNumber numberWithBool:
NO
] forKey:NSPrintAllPages];
[printingDictionary setObject:[NSNumber numberWithBool:
YES
] forKey:NSPrintAllPages];
}
}
jint fromPage = JNFCallIntMethod(env, srcPrinterJob, jm_getFromPage);
jint toPage = JNFCallIntMethod(env, srcPrinterJob, jm_getToPage);
// setting fromPage and toPage will not be shown in the dialog if printing All pages
[printingDictionary setObject:[NSNumber numberWithInteger:fromPage] forKey:NSPrintFirstPage];
[printingDictionary setObject:[NSNumber numberWithInteger:toPage] forKey:NSPrintLastPage];
}
else
{
[printingDictionary setObject:[NSNumber numberWithBool:YES] forKey:NSPrintAllPages];
}
}
// setting fromPage and toPage will not be shown in the dialog if printing All pages
[printingDictionary setObject:[NSNumber numberWithInteger:fromPage] forKey:NSPrintFirstPage];
[printingDictionary setObject:[NSNumber numberWithInteger:toPage] forKey:NSPrintLastPage];
jobject page = JNFCallObjectMethod(env, srcPrinterJob, jm_getPageFormat);
jobject page = JNFCallObjectMethod(env, srcPrinterJob, jm_getPageFormat);
if (page != NULL) {
if (page != NULL) {
javaPageFormatToNSPrintInfo(env, NULL, page, dst);
javaPageFormatToNSPrintInfo(env, NULL, page, dst);
...
...
test/java/awt/print/PrinterJob/DlgAttrsBug.java
0 → 100644
浏览文件 @
1394065b
/*
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 8061258
* @summary PrinterJob's native Print Dialog does not reflect
* specified Copies or Page Ranges
* @run main/manual DlgAttrsBug
*/
import
java.awt.BorderLayout
;
import
java.awt.FlowLayout
;
import
java.awt.Graphics
;
import
java.awt.print.PageFormat
;
import
java.awt.print.Printable
;
import
java.awt.print.PrinterException
;
import
java.awt.print.PrinterJob
;
import
javax.print.attribute.HashPrintRequestAttributeSet
;
import
javax.print.attribute.PrintRequestAttributeSet
;
import
javax.print.attribute.standard.Copies
;
import
javax.print.attribute.standard.PageRanges
;
import
javax.print.attribute.standard.DialogTypeSelection
;
import
javax.swing.JButton
;
import
javax.swing.JDialog
;
import
javax.swing.JPanel
;
import
javax.swing.JTextArea
;
import
javax.swing.SwingUtilities
;
public
class
DlgAttrsBug
implements
Printable
{
private
static
Thread
mainThread
;
private
static
boolean
testPassed
;
private
static
boolean
testGeneratedInterrupt
;
public
static
void
main
(
String
[]
args
)
throws
Exception
{
SwingUtilities
.
invokeAndWait
(()
->
{
doTest
(
DlgAttrsBug:
:
printTest
);
});
mainThread
=
Thread
.
currentThread
();
try
{
Thread
.
sleep
(
30000
);
}
catch
(
InterruptedException
e
)
{
if
(!
testPassed
&&
testGeneratedInterrupt
)
{
throw
new
RuntimeException
(
"Print Dialog does not "
+
"reflect Copies or Page Ranges"
);
}
}
if
(!
testGeneratedInterrupt
)
{
throw
new
RuntimeException
(
"user has not executed the test"
);
}
}
private
static
void
printTest
()
{
PrinterJob
job
=
PrinterJob
.
getPrinterJob
();
if
(
job
.
getPrintService
()
==
null
)
{
System
.
out
.
println
(
"No printers. Test cannot continue"
);
return
;
}
job
.
setPrintable
(
new
DlgAttrsBug
());
PrintRequestAttributeSet
aset
=
new
HashPrintRequestAttributeSet
();
aset
.
add
(
new
Copies
(
5
));
aset
.
add
(
new
PageRanges
(
3
,
4
));
aset
.
add
(
DialogTypeSelection
.
NATIVE
);
job
.
printDialog
(
aset
);
}
public
static
synchronized
void
pass
()
{
testPassed
=
true
;
testGeneratedInterrupt
=
true
;
mainThread
.
interrupt
();
}
public
static
synchronized
void
fail
()
{
testPassed
=
false
;
testGeneratedInterrupt
=
true
;
mainThread
.
interrupt
();
}
private
static
void
doTest
(
Runnable
action
)
{
String
description
=
" Visual inspection of print dialog is required.\n"
+
" A print dialog will be shown.\n "
+
" Please verify Copies 5 is selected.\n"
+
" Also verify, Page Range is selected with "
+
" from page 3 and to Page 4.\n"
+
" If ok, press PASS else press FAIL"
;
final
JDialog
dialog
=
new
JDialog
();
dialog
.
setTitle
(
"printSelectionTest"
);
JTextArea
textArea
=
new
JTextArea
(
description
);
textArea
.
setEditable
(
false
);
final
JButton
testButton
=
new
JButton
(
"Start Test"
);
final
JButton
passButton
=
new
JButton
(
"PASS"
);
passButton
.
setEnabled
(
false
);
passButton
.
addActionListener
((
e
)
->
{
dialog
.
dispose
();
pass
();
});
final
JButton
failButton
=
new
JButton
(
"FAIL"
);
failButton
.
setEnabled
(
false
);
failButton
.
addActionListener
((
e
)
->
{
dialog
.
dispose
();
fail
();
});
testButton
.
addActionListener
((
e
)
->
{
testButton
.
setEnabled
(
false
);
action
.
run
();
passButton
.
setEnabled
(
true
);
failButton
.
setEnabled
(
true
);
});
JPanel
mainPanel
=
new
JPanel
(
new
BorderLayout
());
mainPanel
.
add
(
textArea
,
BorderLayout
.
CENTER
);
JPanel
buttonPanel
=
new
JPanel
(
new
FlowLayout
());
buttonPanel
.
add
(
testButton
);
buttonPanel
.
add
(
passButton
);
buttonPanel
.
add
(
failButton
);
mainPanel
.
add
(
buttonPanel
,
BorderLayout
.
SOUTH
);
dialog
.
add
(
mainPanel
);
dialog
.
pack
();
dialog
.
setVisible
(
true
);
}
public
int
print
(
Graphics
g
,
PageFormat
pf
,
int
pi
)
throws
PrinterException
{
System
.
out
.
println
(
"pi = "
+
pi
);
if
(
pi
>=
5
)
{
return
NO_SUCH_PAGE
;
}
g
.
drawString
(
"Page : "
+
(
pi
+
1
),
200
,
200
);
return
PAGE_EXISTS
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录