Permalink
Browse files

[Bug Fixed] Only the first page printed

  • Loading branch information...
1 parent 75d722f commit 0b63a859d07d34e3546fd7b19173d3a1acce280b @jfmoy committed Mar 22, 2010
Showing with 12 additions and 97 deletions.
  1. +5 −13 Classes/FRAPrintTextView.m
  2. +7 −2 Classes/FRAProject.m
  3. +0 −1 Classes/FRAVariousPerformer.h
  4. +0 −81 Classes/FRAVariousPerformer.m
View
@@ -25,7 +25,7 @@ @implementation FRAPrintTextView
- (id)initWithFrame:(NSRect)frame
{
if (self = [super initWithFrame:frame]) {
- //[self setupView];
+ [self setupView];
}
return self;
}
@@ -36,17 +36,6 @@ - (NSString *)printJobTitle
return [FRACurrentDocument valueForKey:@"name"];
}
-
-- (void)drawRect:(NSRect)rect
-{
- [self setupView];
-
- [super drawRect:rect];
-
-}
-
-
-
- (void)drawPageBorderWithSize:(NSSize)borderSize
{
NSPrintInfo *printInfo = [FRACurrentProject printInfo];
@@ -80,7 +69,10 @@ - (BOOL)isOpaque
return YES;
}
-
+/**
+ * Setup the view used for printing regarding current application settings specified by the
+ * user.
+ **/
- (void)setupView
{
NSPrintInfo *printInfo = [FRACurrentProject printInfo];
View
@@ -154,14 +154,19 @@ - (BOOL)readFromData:(NSData *)data ofType:(NSString *)typeName error:(NSError *
return NO;
}
-
+/**
+ * This method creates a NSPrintOperation object to allow the user to print its document or to export it. It also
+ * shows the Printing panel so the user can modify settings concerning the document printing. The printing operation
+ * is executed in a new thread so the user can still interact with the application.
+ */
- (NSPrintOperation *)printOperationWithSettings:(NSDictionary *)printSettings error:(NSError **)outError
{
NSPrintInfo *printInfo = [self printInfo];
FRAPrintTextView *printTextView = [[FRAPrintTextView alloc] initWithFrame:NSMakeRect([printInfo leftMargin], [printInfo bottomMargin], [printInfo paperSize].width - [printInfo leftMargin] - [printInfo rightMargin], [printInfo paperSize].height - [printInfo topMargin] - [printInfo bottomMargin])];
- NSPrintOperation *printOperation = [NSPrintOperation printOperationWithView:printTextView printInfo:[self printInfo]];
+ NSPrintOperation *printOperation = [NSPrintOperation printOperationWithView:printTextView printInfo:printInfo];
[printOperation setShowsPrintPanel:YES];
+ [printOperation setCanSpawnSeparateThread:YES]; // Allow the printing process to be executed in a new thread.
NSPrintPanel *printPanel = [printOperation printPanel];
FRAPrintViewController *printViewController = [[FRAPrintViewController alloc] init];
@@ -67,5 +67,4 @@ Unless required by applicable law or agreed to in writing, software distributed
- (void)insertIconsInBackground:(id)array;
-//- (FRAPrintTextView *)printView;
@end
@@ -624,85 +624,4 @@ - (void)performInsertIconsOnMainThread:(id)array
}
}
-
-//- (FRAPrintTextView *)printView
-//{
-// Pos;
-// NSPrintInfo *printInfo = [FRACurrentProject printInfo];
-//
-// FRAPrintTextView *printTextView = [[FRAPrintTextView alloc] initWithFrame:NSMakeRect([printInfo leftMargin], [printInfo bottomMargin], [printInfo paperSize].width - [printInfo leftMargin] - [printInfo rightMargin], [printInfo paperSize].height - [printInfo topMargin] - [printInfo bottomMargin])];
-//
-//
-// // Set the tabs
-// NSMutableString *sizeString = [NSMutableString string];
-// NSUInteger numberOfSpaces = [[FRADefaults valueForKey:@"TabWidth"] integerValue];
-// while (numberOfSpaces--) {
-// [sizeString appendString:@" "];
-// }
-// NSDictionary *sizeAttribute = [[NSDictionary alloc] initWithObjectsAndKeys:[NSUnarchiver unarchiveObjectWithData:[FRADefaults valueForKey:@"PrintFont"]], NSFontAttributeName, nil];
-// CGFloat sizeOfTab = [sizeString sizeWithAttributes:sizeAttribute].width;
-//
-// NSMutableParagraphStyle *style = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
-// NSArray *array = [style tabStops];
-// for (id item in array) {
-// [style removeTabStop:item];
-// }
-//
-// [style setDefaultTabInterval:sizeOfTab];
-// NSDictionary *attributes = [[NSDictionary alloc] initWithObjectsAndKeys:style, NSParagraphStyleAttributeName, nil];
-// [printTextView setTypingAttributes:attributes];
-//
-// BOOL printOnlySelection = NO;
-// NSInteger selectionLocation = 0;
-//
-// if ([FRACurrentProject areThereAnyDocuments]) {
-// if ([[FRADefaults valueForKey:@"OnlyPrintSelection"] boolValue] == YES && [FRACurrentTextView selectedRange].length > 0) {
-// [printTextView setString:[FRACurrentText substringWithRange:[FRACurrentTextView selectedRange]]];
-// printOnlySelection = YES;
-// selectionLocation = [FRACurrentTextView selectedRange].location;
-// } else {
-// [printTextView setString:FRACurrentText];
-// }
-//
-// if ([[FRACurrentDocument valueForKey:@"isSyntaxColoured"] boolValue] == YES && [[FRADefaults valueForKey:@"PrintSyntaxColours"] boolValue] == YES) {
-// FRATextView *textView = [FRACurrentDocument valueForKey:@"firstTextView"];
-// FRALayoutManager *layoutManager = (FRALayoutManager *)[textView layoutManager];
-// NSTextStorage *textStorage = [printTextView textStorage];
-// NSInteger lastCharacter = [[textView string] length];
-// [layoutManager removeTemporaryAttribute:NSBackgroundColorAttributeName forCharacterRange:NSMakeRange(0, lastCharacter)];
-// NSInteger index = 0;
-// if (printOnlySelection == YES) {
-// index = [FRACurrentTextView selectedRange].location;
-// lastCharacter = NSMaxRange([FRACurrentTextView selectedRange]);
-// [[FRACurrentDocument valueForKey:@"syntaxColouring"] recolourRange:[FRACurrentTextView selectedRange]];
-// } else {
-// [[FRACurrentDocument valueForKey:@"syntaxColouring"] recolourRange:NSMakeRange(0, lastCharacter)];
-// }
-// NSRange range;
-// NSDictionary *attributes;
-// NSInteger rangeLength = 0;
-// while (index < lastCharacter) {
-// attributes = [layoutManager temporaryAttributesAtCharacterIndex:index effectiveRange:&range];
-// rangeLength = range.length;
-// if ([attributes count] != 0) {
-// if (printOnlySelection == YES) {
-// [textStorage setAttributes:attributes range:NSMakeRange(range.location - selectionLocation, rangeLength)];
-// } else {
-// [textStorage setAttributes:attributes range:range];
-// }
-// }
-// if (rangeLength != 0) {
-// index = index + rangeLength;
-// } else {
-// index++;
-// }
-// }
-// }
-// }
-//
-// [printTextView setFont:[NSUnarchiver unarchiveObjectWithData:[FRADefaults valueForKey:@"PrintFont"]]];
-//
-// return printTextView;
-//
-//}
@end

0 comments on commit 0b63a85

Please sign in to comment.