25 |
25 |
26 #import "PrinterView.h" |
26 #import "PrinterView.h" |
27 |
27 |
28 #import "java_awt_print_Pageable.h" |
28 #import "java_awt_print_Pageable.h" |
29 #import "java_awt_print_Printable.h" |
29 #import "java_awt_print_Printable.h" |
|
30 #import "java_awt_print_PageFormat.h" |
30 |
31 |
31 #import <JavaNativeFoundation/JavaNativeFoundation.h> |
32 #import <JavaNativeFoundation/JavaNativeFoundation.h> |
32 |
33 |
33 #import "ThreadUtilities.h" |
34 #import "ThreadUtilities.h" |
34 #import "GeomUtilities.h" |
35 #import "GeomUtilities.h" |
35 |
36 |
36 |
37 |
37 static JNF_CLASS_CACHE(sjc_CPrinterJob, "sun/lwawt/macosx/CPrinterJob"); |
38 static JNF_CLASS_CACHE(sjc_CPrinterJob, "sun/lwawt/macosx/CPrinterJob"); |
|
39 static JNF_CLASS_CACHE(sjc_PageFormat, "java/awt/print/PageFormat"); |
38 |
40 |
39 @implementation PrinterView |
41 @implementation PrinterView |
40 |
42 |
41 - (id)initWithFrame:(NSRect)aRect withEnv:(JNIEnv*)env withPrinterJob:(jobject)printerJob |
43 - (id)initWithFrame:(NSRect)aRect withEnv:(JNIEnv*)env withPrinterJob:(jobject)printerJob |
42 { |
44 { |
150 { |
152 { |
151 AWT_ASSERT_NOT_APPKIT_THREAD; |
153 AWT_ASSERT_NOT_APPKIT_THREAD; |
152 |
154 |
153 static JNF_MEMBER_CACHE(jm_getPageformatPrintablePeekgraphics, sjc_CPrinterJob, "getPageformatPrintablePeekgraphics", "(I)[Ljava/lang/Object;"); |
155 static JNF_MEMBER_CACHE(jm_getPageformatPrintablePeekgraphics, sjc_CPrinterJob, "getPageformatPrintablePeekgraphics", "(I)[Ljava/lang/Object;"); |
154 static JNF_MEMBER_CACHE(jm_printAndGetPageFormatArea, sjc_CPrinterJob, "printAndGetPageFormatArea", "(Ljava/awt/print/Printable;Ljava/awt/Graphics;Ljava/awt/print/PageFormat;I)Ljava/awt/geom/Rectangle2D;"); |
156 static JNF_MEMBER_CACHE(jm_printAndGetPageFormatArea, sjc_CPrinterJob, "printAndGetPageFormatArea", "(Ljava/awt/print/Printable;Ljava/awt/Graphics;Ljava/awt/print/PageFormat;I)Ljava/awt/geom/Rectangle2D;"); |
|
157 static JNF_MEMBER_CACHE(jm_getOrientation, sjc_PageFormat, "getOrientation", "()I"); |
155 |
158 |
156 // Assertions removed, and corresponding JNFDeleteGlobalRefs added, for radr://3962543 |
159 // Assertions removed, and corresponding JNFDeleteGlobalRefs added, for radr://3962543 |
157 // Actual fix that will keep these assertions from being true is radr://3205462 , |
160 // Actual fix that will keep these assertions from being true is radr://3205462 , |
158 // which will hopefully be fixed by the blocking AppKit bug radr://3056694 |
161 // which will hopefully be fixed by the blocking AppKit bug radr://3056694 |
159 //assert(fCurPageFormat == NULL); |
162 //assert(fCurPageFormat == NULL); |
199 (*env)->DeleteLocalRef(env, peekGraphics); |
202 (*env)->DeleteLocalRef(env, peekGraphics); |
200 |
203 |
201 // Actually print and get the PageFormatArea |
204 // Actually print and get the PageFormatArea |
202 jobject pageFormatArea = JNFCallObjectMethod(env, fPrinterJob, jm_printAndGetPageFormatArea, fCurPainter, fCurPeekGraphics, fCurPageFormat, jPageNumber); // AWT_THREADING Safe (AWTRunLoopMode) |
205 jobject pageFormatArea = JNFCallObjectMethod(env, fPrinterJob, jm_printAndGetPageFormatArea, fCurPainter, fCurPeekGraphics, fCurPageFormat, jPageNumber); // AWT_THREADING Safe (AWTRunLoopMode) |
203 if (pageFormatArea != NULL) { |
206 if (pageFormatArea != NULL) { |
|
207 NSPrintingOrientation currentOrientation = |
|
208 [[[NSPrintOperation currentOperation] printInfo] orientation]; |
|
209 // set page orientation |
|
210 switch (JNFCallIntMethod(env, fCurPageFormat, jm_getOrientation)) { |
|
211 case java_awt_print_PageFormat_PORTRAIT: |
|
212 default: |
|
213 if (currentOrientation != NSPortraitOrientation) { |
|
214 [[[NSPrintOperation currentOperation] printInfo] |
|
215 setOrientation:NSPortraitOrientation]; |
|
216 } |
|
217 break; |
|
218 |
|
219 case java_awt_print_PageFormat_LANDSCAPE: |
|
220 case java_awt_print_PageFormat_REVERSE_LANDSCAPE: |
|
221 if (currentOrientation != NSLandscapeOrientation) { |
|
222 [[[NSPrintOperation currentOperation] printInfo] |
|
223 setOrientation:NSLandscapeOrientation]; |
|
224 } |
|
225 break; |
|
226 } |
204 result = JavaToNSRect(env, pageFormatArea); |
227 result = JavaToNSRect(env, pageFormatArea); |
205 (*env)->DeleteLocalRef(env, pageFormatArea); |
228 (*env)->DeleteLocalRef(env, pageFormatArea); |
206 } else { |
229 } else { |
207 [self releaseReferences:env]; |
230 [self releaseReferences:env]; |
208 result = NSZeroRect; |
231 result = NSZeroRect; |