< prev index next >

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

Print this page




 300     // <rdar://problem/4022422> NSPrinterInfo is not correctly set to the selected printer
 301     // from the Java side of CPrinterJob. Has always assumed the default printer was the one we wanted.
 302     if (srcPrintJob == NULL) return;
 303     jobject printerNameObj = JNFCallObjectMethod(env, srcPrintJob, jm_getPrinterName);
 304     if (printerNameObj == NULL) return;
 305     NSString *printerName = JNFJavaToNSString(env, printerNameObj);
 306     if (printerName == nil) return;
 307     NSPrinter *printer = [NSPrinter printerWithName:printerName];
 308     if (printer == nil) return;
 309     [dstPrintInfo setPrinter:printer];
 310 }
 311 
 312 static void nsPrintInfoToJavaPrinterJob(JNIEnv* env, NSPrintInfo* src, jobject dstPrinterJob, jobject dstPageable)
 313 {
 314     static JNF_MEMBER_CACHE(jm_setService, sjc_CPrinterJob, "setPrinterServiceFromNative", "(Ljava/lang/String;)V");
 315     static JNF_MEMBER_CACHE(jm_setCopiesAttribute, sjc_CPrinterJob, "setCopiesAttribute", "(I)V");
 316     static JNF_MEMBER_CACHE(jm_setCollated, sjc_CPrinterJob, "setCollated", "(Z)V");
 317     static JNF_MEMBER_CACHE(jm_setPageRangeAttribute, sjc_CPrinterJob, "setPageRangeAttribute", "(IIZ)V");
 318     static JNF_MEMBER_CACHE(jm_setPrintToFile, sjc_CPrinterJob, "setPrintToFile", "(Z)V");
 319 
 320     NSPrintJobDispositionValue jobDisposition = [src jobDisposition];
 321     if (jobDisposition == NSPrintSaveJob) {
 322         JNFCallVoidMethod(env, dstPrinterJob, jm_setPrintToFile, true);
 323     } else {
 324         JNFCallVoidMethod(env, dstPrinterJob, jm_setPrintToFile, false);
 325     }
 326 
 327     // get the selected printer's name, and set the appropriate PrintService on the Java side
 328     NSString *name = [[src printer] name];
 329     jstring printerName = JNFNSToJavaString(env, name);
 330     JNFCallVoidMethod(env, dstPrinterJob, jm_setService, printerName);
 331 
 332 
 333     NSMutableDictionary* printingDictionary = [src dictionary];
 334 
 335     NSNumber* nsCopies = [printingDictionary objectForKey:NSPrintCopies];
 336     if ([nsCopies respondsToSelector:@selector(integerValue)])
 337     {
 338         JNFCallVoidMethod(env, dstPrinterJob, jm_setCopiesAttribute, [nsCopies integerValue]); // AWT_THREADING Safe (known object)
 339     }
 340 
 341     NSNumber* nsCollated = [printingDictionary objectForKey:NSPrintMustCollate];




 300     // <rdar://problem/4022422> NSPrinterInfo is not correctly set to the selected printer
 301     // from the Java side of CPrinterJob. Has always assumed the default printer was the one we wanted.
 302     if (srcPrintJob == NULL) return;
 303     jobject printerNameObj = JNFCallObjectMethod(env, srcPrintJob, jm_getPrinterName);
 304     if (printerNameObj == NULL) return;
 305     NSString *printerName = JNFJavaToNSString(env, printerNameObj);
 306     if (printerName == nil) return;
 307     NSPrinter *printer = [NSPrinter printerWithName:printerName];
 308     if (printer == nil) return;
 309     [dstPrintInfo setPrinter:printer];
 310 }
 311 
 312 static void nsPrintInfoToJavaPrinterJob(JNIEnv* env, NSPrintInfo* src, jobject dstPrinterJob, jobject dstPageable)
 313 {
 314     static JNF_MEMBER_CACHE(jm_setService, sjc_CPrinterJob, "setPrinterServiceFromNative", "(Ljava/lang/String;)V");
 315     static JNF_MEMBER_CACHE(jm_setCopiesAttribute, sjc_CPrinterJob, "setCopiesAttribute", "(I)V");
 316     static JNF_MEMBER_CACHE(jm_setCollated, sjc_CPrinterJob, "setCollated", "(Z)V");
 317     static JNF_MEMBER_CACHE(jm_setPageRangeAttribute, sjc_CPrinterJob, "setPageRangeAttribute", "(IIZ)V");
 318     static JNF_MEMBER_CACHE(jm_setPrintToFile, sjc_CPrinterJob, "setPrintToFile", "(Z)V");
 319 
 320     if (src.jobDisposition == NSPrintSaveJob) {

 321         JNFCallVoidMethod(env, dstPrinterJob, jm_setPrintToFile, true);
 322     } else {
 323         JNFCallVoidMethod(env, dstPrinterJob, jm_setPrintToFile, false);
 324     }
 325 
 326     // get the selected printer's name, and set the appropriate PrintService on the Java side
 327     NSString *name = [[src printer] name];
 328     jstring printerName = JNFNSToJavaString(env, name);
 329     JNFCallVoidMethod(env, dstPrinterJob, jm_setService, printerName);
 330 
 331 
 332     NSMutableDictionary* printingDictionary = [src dictionary];
 333 
 334     NSNumber* nsCopies = [printingDictionary objectForKey:NSPrintCopies];
 335     if ([nsCopies respondsToSelector:@selector(integerValue)])
 336     {
 337         JNFCallVoidMethod(env, dstPrinterJob, jm_setCopiesAttribute, [nsCopies integerValue]); // AWT_THREADING Safe (known object)
 338     }
 339 
 340     NSNumber* nsCollated = [printingDictionary objectForKey:NSPrintMustCollate];


< prev index next >