Skip to content

Commit 0b63a85

Browse files
author
Jean-Francois Moy
committed
[Bug Fixed] Only the first page printed
1 parent 75d722f commit 0b63a85

File tree

4 files changed

+12
-97
lines changed

4 files changed

+12
-97
lines changed

Classes/FRAPrintTextView.m

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ @implementation FRAPrintTextView
2525
- (id)initWithFrame:(NSRect)frame
2626
{
2727
if (self = [super initWithFrame:frame]) {
28-
//[self setupView];
28+
[self setupView];
2929
}
3030
return self;
3131
}
@@ -36,17 +36,6 @@ - (NSString *)printJobTitle
3636
return [FRACurrentDocument valueForKey:@"name"];
3737
}
3838

39-
40-
- (void)drawRect:(NSRect)rect
41-
{
42-
[self setupView];
43-
44-
[super drawRect:rect];
45-
46-
}
47-
48-
49-
5039
- (void)drawPageBorderWithSize:(NSSize)borderSize
5140
{
5241
NSPrintInfo *printInfo = [FRACurrentProject printInfo];
@@ -80,7 +69,10 @@ - (BOOL)isOpaque
8069
return YES;
8170
}
8271

83-
72+
/**
73+
* Setup the view used for printing regarding current application settings specified by the
74+
* user.
75+
**/
8476
- (void)setupView
8577
{
8678
NSPrintInfo *printInfo = [FRACurrentProject printInfo];

Classes/FRAProject.m

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,14 +154,19 @@ - (BOOL)readFromData:(NSData *)data ofType:(NSString *)typeName error:(NSError *
154154
return NO;
155155
}
156156

157-
157+
/**
158+
* This method creates a NSPrintOperation object to allow the user to print its document or to export it. It also
159+
* shows the Printing panel so the user can modify settings concerning the document printing. The printing operation
160+
* is executed in a new thread so the user can still interact with the application.
161+
*/
158162
- (NSPrintOperation *)printOperationWithSettings:(NSDictionary *)printSettings error:(NSError **)outError
159163
{
160164
NSPrintInfo *printInfo = [self printInfo];
161165
FRAPrintTextView *printTextView = [[FRAPrintTextView alloc] initWithFrame:NSMakeRect([printInfo leftMargin], [printInfo bottomMargin], [printInfo paperSize].width - [printInfo leftMargin] - [printInfo rightMargin], [printInfo paperSize].height - [printInfo topMargin] - [printInfo bottomMargin])];
162166

163-
NSPrintOperation *printOperation = [NSPrintOperation printOperationWithView:printTextView printInfo:[self printInfo]];
167+
NSPrintOperation *printOperation = [NSPrintOperation printOperationWithView:printTextView printInfo:printInfo];
164168
[printOperation setShowsPrintPanel:YES];
169+
[printOperation setCanSpawnSeparateThread:YES]; // Allow the printing process to be executed in a new thread.
165170

166171
NSPrintPanel *printPanel = [printOperation printPanel];
167172
FRAPrintViewController *printViewController = [[FRAPrintViewController alloc] init];

Classes/FRAVariousPerformer.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,5 +67,4 @@ Unless required by applicable law or agreed to in writing, software distributed
6767

6868
- (void)insertIconsInBackground:(id)array;
6969

70-
//- (FRAPrintTextView *)printView;
7170
@end

Classes/FRAVariousPerformer.m

Lines changed: 0 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -624,85 +624,4 @@ - (void)performInsertIconsOnMainThread:(id)array
624624
}
625625
}
626626

627-
628-
//- (FRAPrintTextView *)printView
629-
//{
630-
// Pos;
631-
// NSPrintInfo *printInfo = [FRACurrentProject printInfo];
632-
//
633-
// FRAPrintTextView *printTextView = [[FRAPrintTextView alloc] initWithFrame:NSMakeRect([printInfo leftMargin], [printInfo bottomMargin], [printInfo paperSize].width - [printInfo leftMargin] - [printInfo rightMargin], [printInfo paperSize].height - [printInfo topMargin] - [printInfo bottomMargin])];
634-
//
635-
//
636-
// // Set the tabs
637-
// NSMutableString *sizeString = [NSMutableString string];
638-
// NSUInteger numberOfSpaces = [[FRADefaults valueForKey:@"TabWidth"] integerValue];
639-
// while (numberOfSpaces--) {
640-
// [sizeString appendString:@" "];
641-
// }
642-
// NSDictionary *sizeAttribute = [[NSDictionary alloc] initWithObjectsAndKeys:[NSUnarchiver unarchiveObjectWithData:[FRADefaults valueForKey:@"PrintFont"]], NSFontAttributeName, nil];
643-
// CGFloat sizeOfTab = [sizeString sizeWithAttributes:sizeAttribute].width;
644-
//
645-
// NSMutableParagraphStyle *style = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
646-
// NSArray *array = [style tabStops];
647-
// for (id item in array) {
648-
// [style removeTabStop:item];
649-
// }
650-
//
651-
// [style setDefaultTabInterval:sizeOfTab];
652-
// NSDictionary *attributes = [[NSDictionary alloc] initWithObjectsAndKeys:style, NSParagraphStyleAttributeName, nil];
653-
// [printTextView setTypingAttributes:attributes];
654-
//
655-
// BOOL printOnlySelection = NO;
656-
// NSInteger selectionLocation = 0;
657-
//
658-
// if ([FRACurrentProject areThereAnyDocuments]) {
659-
// if ([[FRADefaults valueForKey:@"OnlyPrintSelection"] boolValue] == YES && [FRACurrentTextView selectedRange].length > 0) {
660-
// [printTextView setString:[FRACurrentText substringWithRange:[FRACurrentTextView selectedRange]]];
661-
// printOnlySelection = YES;
662-
// selectionLocation = [FRACurrentTextView selectedRange].location;
663-
// } else {
664-
// [printTextView setString:FRACurrentText];
665-
// }
666-
//
667-
// if ([[FRACurrentDocument valueForKey:@"isSyntaxColoured"] boolValue] == YES && [[FRADefaults valueForKey:@"PrintSyntaxColours"] boolValue] == YES) {
668-
// FRATextView *textView = [FRACurrentDocument valueForKey:@"firstTextView"];
669-
// FRALayoutManager *layoutManager = (FRALayoutManager *)[textView layoutManager];
670-
// NSTextStorage *textStorage = [printTextView textStorage];
671-
// NSInteger lastCharacter = [[textView string] length];
672-
// [layoutManager removeTemporaryAttribute:NSBackgroundColorAttributeName forCharacterRange:NSMakeRange(0, lastCharacter)];
673-
// NSInteger index = 0;
674-
// if (printOnlySelection == YES) {
675-
// index = [FRACurrentTextView selectedRange].location;
676-
// lastCharacter = NSMaxRange([FRACurrentTextView selectedRange]);
677-
// [[FRACurrentDocument valueForKey:@"syntaxColouring"] recolourRange:[FRACurrentTextView selectedRange]];
678-
// } else {
679-
// [[FRACurrentDocument valueForKey:@"syntaxColouring"] recolourRange:NSMakeRange(0, lastCharacter)];
680-
// }
681-
// NSRange range;
682-
// NSDictionary *attributes;
683-
// NSInteger rangeLength = 0;
684-
// while (index < lastCharacter) {
685-
// attributes = [layoutManager temporaryAttributesAtCharacterIndex:index effectiveRange:&range];
686-
// rangeLength = range.length;
687-
// if ([attributes count] != 0) {
688-
// if (printOnlySelection == YES) {
689-
// [textStorage setAttributes:attributes range:NSMakeRange(range.location - selectionLocation, rangeLength)];
690-
// } else {
691-
// [textStorage setAttributes:attributes range:range];
692-
// }
693-
// }
694-
// if (rangeLength != 0) {
695-
// index = index + rangeLength;
696-
// } else {
697-
// index++;
698-
// }
699-
// }
700-
// }
701-
// }
702-
//
703-
// [printTextView setFont:[NSUnarchiver unarchiveObjectWithData:[FRADefaults valueForKey:@"PrintFont"]]];
704-
//
705-
// return printTextView;
706-
//
707-
//}
708627
@end

0 commit comments

Comments
 (0)