[OpenJDK 2D-Dev] [9] RFR: JDK-8061258, , [macosx] PrinterJob's native Print Dialog does not reflect specified Copies or Page Ranges

prasanta sadhukhan prasanta.sadhukhan at oracle.com
Wed Mar 23 11:02:35 UTC 2016


Hi Phil,

Please review a fix for jdk9
Bug: https://bugs.openjdk.java.net/browse/JDK-8061258
webrev :http://cr.openjdk.java.net/~psadhukhan/8061258/webrev.00/

When user attempts to pre-populate the native dialog with copies and 
page ranges by calling
  PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
         aset.add(new Copies(2));
         aset.add(new PageRanges(3,4));
the print dialog does not reflect the user-defined setting.

This is because osx native code was calling getNumberOfPages() from 
OpenBook.java which was returning UNKNOWN_NUMBER_OF_PAGES (-1).
Since getNumberOfPages() returned -1, osx always selected 
NSPrintAllPages or All Radio button.

I fixed it by removing this call to getNumberOfPages() and rely on 
getMinPage/getMaxPage() as was done in windows 
(awt_PrintControl.cpp:AwtPrintControl::InitPrintDialog) to select which 
radio button to be selected.
If fromPage > minPage or toPage < maxPage, it means user has selected 
page ranges so PageRange radio button is to be selected else "All" radio 
button to be selected.

Regards
Prasanta



More information about the 2d-dev mailing list