< prev index next >

src/java.desktop/macosx/native/libawt_lwawt/awt/CPrinterJob.m

Print this page




 359         JNFCallVoidMethod(env, dstPrinterJob, jm_setPageRangeAttribute, 
 360                           jFirstPage, jLastPage, isRangeSet); 
 361             // AWT_THREADING Safe (known object)
 362 
 363     }
 364 }
 365 
 366 static void javaPrinterJobToNSPrintInfo(JNIEnv* env, jobject srcPrinterJob, jobject srcPageable, NSPrintInfo* dst)
 367 {
 368     AWT_ASSERT_NOT_APPKIT_THREAD;
 369 
 370     static JNF_CLASS_CACHE(jc_Pageable, "java/awt/print/Pageable");
 371     static JNF_MEMBER_CACHE(jm_getCopies, sjc_CPrinterJob, "getCopiesInt", "()I");
 372     static JNF_MEMBER_CACHE(jm_isCollated, sjc_CPrinterJob, "isCollated", "()Z");
 373     static JNF_MEMBER_CACHE(jm_getFromPage, sjc_CPrinterJob, "getFromPageAttrib", "()I");
 374     static JNF_MEMBER_CACHE(jm_getToPage, sjc_CPrinterJob, "getToPageAttrib", "()I");
 375     static JNF_MEMBER_CACHE(jm_getMinPage, sjc_CPrinterJob, "getMinPageAttrib", "()I");
 376     static JNF_MEMBER_CACHE(jm_getMaxPage, sjc_CPrinterJob, "getMaxPageAttrib", "()I");
 377     static JNF_MEMBER_CACHE(jm_getSelectAttrib, sjc_CPrinterJob, "getSelectAttrib", "()I");
 378     static JNF_MEMBER_CACHE(jm_getNumberOfPages, jc_Pageable, "getNumberOfPages", "()I");
 379     static JNF_MEMBER_CACHE(jm_getPageFormat, sjc_CPrinterJob, "getPageFormatFromAttributes", "()Ljava/awt/print/PageFormat;");
 380 
 381     NSMutableDictionary* printingDictionary = [dst dictionary];
 382 
 383     jint copies = JNFCallIntMethod(env, srcPrinterJob, jm_getCopies); // AWT_THREADING Safe (known object)
 384     [printingDictionary setObject:[NSNumber numberWithInteger:copies] forKey:NSPrintCopies];
 385 
 386     jboolean collated = JNFCallBooleanMethod(env, srcPrinterJob, jm_isCollated); // AWT_THREADING Safe (known object)
 387     [printingDictionary setObject:[NSNumber numberWithBool:collated ? YES : NO] forKey:NSPrintMustCollate];
 388     jint selectID = JNFCallIntMethod(env, srcPrinterJob, jm_getSelectAttrib);
 389     jint fromPage = JNFCallIntMethod(env, srcPrinterJob, jm_getFromPage);
 390     jint toPage = JNFCallIntMethod(env, srcPrinterJob, jm_getToPage);
 391     if (selectID ==0) {
 392         [printingDictionary setObject:[NSNumber numberWithBool:YES] forKey:NSPrintAllPages];
 393     } else if (selectID == 2) {
 394         // In Mac 10.7,  Print ALL is deselected if PrintSelection is YES whether
 395         // NSPrintAllPages is YES or NO
 396         [printingDictionary setObject:[NSNumber numberWithBool:NO] forKey:NSPrintAllPages];
 397         [printingDictionary setObject:[NSNumber numberWithBool:YES] forKey:NSPrintSelectionOnly];
 398     } else {
 399         jint minPage = JNFCallIntMethod(env, srcPrinterJob, jm_getMinPage);
 400         jint maxPage = JNFCallIntMethod(env, srcPrinterJob, jm_getMaxPage);
 401 
 402         // for PD_SELECTION or PD_NOSELECTION, check from/to page
 403         // to determine which radio button to select
 404         if (fromPage > minPage || toPage < maxPage) {
 405             [printingDictionary setObject:[NSNumber numberWithBool:NO] forKey:NSPrintAllPages];
 406         } else {
 407             [printingDictionary setObject:[NSNumber numberWithBool:YES] forKey:NSPrintAllPages];
 408         }
 409     }
 410 
 411     // setting fromPage and toPage will not be shown in the dialog if printing All pages
 412     [printingDictionary setObject:[NSNumber numberWithInteger:fromPage] forKey:NSPrintFirstPage];
 413     [printingDictionary setObject:[NSNumber numberWithInteger:toPage] forKey:NSPrintLastPage];
 414 
 415     jobject page = JNFCallObjectMethod(env, srcPrinterJob, jm_getPageFormat); 
 416     if (page != NULL) {
 417         javaPageFormatToNSPrintInfo(env, NULL, page, dst);
 418     }
 419 }
 420 
 421 /*
 422  * Class:     sun_lwawt_macosx_CPrinterJob
 423  * Method:    abortDoc
 424  * Signature: ()V
 425  */
 426 JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPrinterJob_abortDoc
 427   (JNIEnv *env, jobject jthis)
 428 {
 429 JNF_COCOA_ENTER(env);
 430     // This is only called during the printLoop from the printLoop thread
 431     NSPrintOperation* printLoop = [NSPrintOperation currentOperation];
 432     NSPrintInfo* printInfo = [printLoop printInfo];
 433     [printInfo setJobDisposition:NSPrintCancelJob];
 434 JNF_COCOA_EXIT(env);
 435 }




 359         JNFCallVoidMethod(env, dstPrinterJob, jm_setPageRangeAttribute, 
 360                           jFirstPage, jLastPage, isRangeSet); 
 361             // AWT_THREADING Safe (known object)
 362 
 363     }
 364 }
 365 
 366 static void javaPrinterJobToNSPrintInfo(JNIEnv* env, jobject srcPrinterJob, jobject srcPageable, NSPrintInfo* dst)
 367 {
 368     AWT_ASSERT_NOT_APPKIT_THREAD;
 369 
 370     static JNF_CLASS_CACHE(jc_Pageable, "java/awt/print/Pageable");
 371     static JNF_MEMBER_CACHE(jm_getCopies, sjc_CPrinterJob, "getCopiesInt", "()I");
 372     static JNF_MEMBER_CACHE(jm_isCollated, sjc_CPrinterJob, "isCollated", "()Z");
 373     static JNF_MEMBER_CACHE(jm_getFromPage, sjc_CPrinterJob, "getFromPageAttrib", "()I");
 374     static JNF_MEMBER_CACHE(jm_getToPage, sjc_CPrinterJob, "getToPageAttrib", "()I");
 375     static JNF_MEMBER_CACHE(jm_getMinPage, sjc_CPrinterJob, "getMinPageAttrib", "()I");
 376     static JNF_MEMBER_CACHE(jm_getMaxPage, sjc_CPrinterJob, "getMaxPageAttrib", "()I");
 377     static JNF_MEMBER_CACHE(jm_getSelectAttrib, sjc_CPrinterJob, "getSelectAttrib", "()I");
 378     static JNF_MEMBER_CACHE(jm_getNumberOfPages, jc_Pageable, "getNumberOfPages", "()I");
 379     static JNF_MEMBER_CACHE(jm_getPageFormat, sjc_CPrinterJob, "getPageFormat", "(I)Ljava/awt/print/PageFormat;");
 380 
 381     NSMutableDictionary* printingDictionary = [dst dictionary];
 382 
 383     jint copies = JNFCallIntMethod(env, srcPrinterJob, jm_getCopies); // AWT_THREADING Safe (known object)
 384     [printingDictionary setObject:[NSNumber numberWithInteger:copies] forKey:NSPrintCopies];
 385 
 386     jboolean collated = JNFCallBooleanMethod(env, srcPrinterJob, jm_isCollated); // AWT_THREADING Safe (known object)
 387     [printingDictionary setObject:[NSNumber numberWithBool:collated ? YES : NO] forKey:NSPrintMustCollate];
 388     jint selectID = JNFCallIntMethod(env, srcPrinterJob, jm_getSelectAttrib);
 389     jint fromPage = JNFCallIntMethod(env, srcPrinterJob, jm_getFromPage);
 390     jint toPage = JNFCallIntMethod(env, srcPrinterJob, jm_getToPage);
 391     if (selectID ==0) {
 392         [printingDictionary setObject:[NSNumber numberWithBool:YES] forKey:NSPrintAllPages];
 393     } else if (selectID == 2) {
 394         // In Mac 10.7,  Print ALL is deselected if PrintSelection is YES whether
 395         // NSPrintAllPages is YES or NO
 396         [printingDictionary setObject:[NSNumber numberWithBool:NO] forKey:NSPrintAllPages];
 397         [printingDictionary setObject:[NSNumber numberWithBool:YES] forKey:NSPrintSelectionOnly];
 398     } else {
 399         jint minPage = JNFCallIntMethod(env, srcPrinterJob, jm_getMinPage);
 400         jint maxPage = JNFCallIntMethod(env, srcPrinterJob, jm_getMaxPage);
 401 
 402         // for PD_SELECTION or PD_NOSELECTION, check from/to page
 403         // to determine which radio button to select
 404         if (fromPage > minPage || toPage < maxPage) {
 405             [printingDictionary setObject:[NSNumber numberWithBool:NO] forKey:NSPrintAllPages];
 406         } else {
 407             [printingDictionary setObject:[NSNumber numberWithBool:YES] forKey:NSPrintAllPages];
 408         }
 409     }
 410 
 411     // setting fromPage and toPage will not be shown in the dialog if printing All pages
 412     [printingDictionary setObject:[NSNumber numberWithInteger:fromPage] forKey:NSPrintFirstPage];
 413     [printingDictionary setObject:[NSNumber numberWithInteger:toPage] forKey:NSPrintLastPage];
 414 
 415     jobject page = JNFCallObjectMethod(env, srcPrinterJob, jm_getPageFormat, (jint)0);
 416     if (page != NULL) {
 417         javaPageFormatToNSPrintInfo(env, NULL, page, dst);
 418     }
 419 }
 420 
 421 /*
 422  * Class:     sun_lwawt_macosx_CPrinterJob
 423  * Method:    abortDoc
 424  * Signature: ()V
 425  */
 426 JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPrinterJob_abortDoc
 427   (JNIEnv *env, jobject jthis)
 428 {
 429 JNF_COCOA_ENTER(env);
 430     // This is only called during the printLoop from the printLoop thread
 431     NSPrintOperation* printLoop = [NSPrintOperation currentOperation];
 432     NSPrintInfo* printInfo = [printLoop printInfo];
 433     [printInfo setJobDisposition:NSPrintCancelJob];
 434 JNF_COCOA_EXIT(env);
 435 }


< prev index next >