Revision: 3885
http://skim-app.svn.sourceforge.net/skim-app/?rev=3885&view=rev
Author: hofman
Date: 2008-05-16 16:23:26 -0700 (Fri, 16 May 2008)
Log Message:
-----------
Use selection rect on the proper page. Add accessor for the page for the
selection.
Modified Paths:
--------------
trunk/SKMainWindowController.m
trunk/SKPDFView.h
trunk/SKPDFView.m
Modified: trunk/SKMainWindowController.m
===================================================================
--- trunk/SKMainWindowController.m 2008-05-16 21:18:26 UTC (rev 3884)
+++ trunk/SKMainWindowController.m 2008-05-16 23:23:26 UTC (rev 3885)
@@ -1620,7 +1620,7 @@
scale = NSWidth(bounds) / NSWidth(selRect);
[pdfView setScaleFactor:scale];
}
- [pdfView scrollRect:selRect inPageToVisible:[pdfView currentPage]];
+ [pdfView scrollRect:selRect inPageToVisible:[pdfView
currentSelectionPage]];
} else NSBeep();
}
@@ -1756,7 +1756,7 @@
- (IBAction)crop:(id)sender {
NSRect rect = NSIntegralRect([pdfView currentSelectionRect]);
if (NSIsEmptyRect(rect))
- rect = [[pdfView currentPage] foregroundBox];
+ rect = [[pdfView currentSelectionPage] foregroundBox];
[self cropPageAtIndex:[[pdfView currentPage] pageIndex] toRect:rect];
}
Modified: trunk/SKPDFView.h
===================================================================
--- trunk/SKPDFView.h 2008-05-16 21:18:26 UTC (rev 3884)
+++ trunk/SKPDFView.h 2008-05-16 23:23:26 UTC (rev 3885)
@@ -146,6 +146,7 @@
- (NSRect)currentSelectionRect;
- (void)setCurrentSelectionRect:(NSRect)rect;
+- (PDFPage *)currentSelectionPage;
- (float)currentMagnification;
Modified: trunk/SKPDFView.m
===================================================================
--- trunk/SKPDFView.m 2008-05-16 21:18:26 UTC (rev 3884)
+++ trunk/SKPDFView.m 2008-05-16 23:23:26 UTC (rev 3885)
@@ -466,6 +466,7 @@
[readingBar release];
readingBar = nil;
selectionRect = NSZeroRect;
+ selectionPageIndex = NSNotFound;
[self removeHoverRects];
[accessibilityChildren release];
accessibilityChildren = nil;
@@ -487,6 +488,7 @@
[self setCurrentSelection:nil];
} else if (toolMode == SKSelectToolMode && NSEqualRects(selectionRect,
NSZeroRect) == NO) {
selectionRect = NSZeroRect;
+ selectionPageIndex = NSNotFound;
[self setNeedsDisplay:YES];
}
@@ -595,9 +597,15 @@
if (NSEqualRects(selectionRect, rect) == NO)
[self setNeedsDisplay:YES];
selectionRect = rect;
+ if (NSEqualRects(rect, NSZeroRect))
+ selectionPageIndex = NSNotFound;
}
}
+- (PDFPage *)currentSelectionPage {
+ return selectionPageIndex == NSNotFound ? nil : [[self document]
pageAtIndex:selectionPageIndex];
+}
+
- (float)currentMagnification {
return magnification;
}
@@ -734,7 +742,7 @@
if (toolMode == SKSelectToolMode && NSIsEmptyRect(selectionRect) == NO &&
selectionPageIndex != NSNotFound) {
NSRect selRect = NSIntegralRect(selectionRect);
NSRect targetRect = selRect;
- PDFPage *page = [[self document] pageAtIndex:selectionPageIndex];
+ PDFPage *page = [self currentSelectionPage];
if ([page rotation]) {
NSAffineTransform *transform = [NSAffineTransform transform];
@@ -923,6 +931,7 @@
if (toolMode == SKSelectToolMode) {
PDFPage *page = [self currentPage];
selectionRect = NSIntersectionRect(NSUnionRect([page foregroundBox],
selectionRect), [page boundsForBox:[self displayBox]]);
+ selectionPageIndex = [page pageIndex];
[[NSNotificationCenter defaultCenter]
postNotificationName:SKPDFViewSelectionChangedNotification object:self];
[self setNeedsDisplay:YES];
}
@@ -1103,7 +1112,8 @@
if (mouseDownInAnnotation) {
if (nil == activeAnnotation && NSIsEmptyRect(selectionRect) ==
NO) {
[self setNeedsDisplayInRect:selectionRect];
- selectionRect = NSZeroRect;
+ selectionRect = NSZeroRect;
+ selectionPageIndex = NSNotFound;
[[NSNotificationCenter defaultCenter]
postNotificationName:SKPDFViewSelectionChangedNotification object:self];
} else if ([activeAnnotation isLink]) {
NSPoint p = [self convertPoint:[theEvent
locationInWindow] fromView:nil];
@@ -1646,7 +1656,7 @@
#pragma mark Services
- (BOOL)writeSelectionToPasteboard:(NSPasteboard *)pboard types:(NSArray
*)types {
- if ([self toolMode] == SKSelectToolMode && NSIsEmptyRect(selectionRect) ==
NO && ([types containsObject:NSPDFPboardType] || [types
containsObject:NSTIFFPboardType])) {
+ if ([self toolMode] == SKSelectToolMode && NSIsEmptyRect(selectionRect) ==
NO && selectionPageIndex != NSNotFound && ([types
containsObject:NSPDFPboardType] || [types containsObject:NSTIFFPboardType])) {
NSMutableArray *writeTypes = [NSMutableArray array];
NSData *pdfData = nil;
NSData *tiffData = nil;
@@ -1655,7 +1665,7 @@
NSRect targetRect = selRect;
if ([types containsObject:NSPDFPboardType]) {
- PDFPage *page = [self currentPage];
+ PDFPage *page = [self currentSelectionPage];
if ([page rotation]) {
NSAffineTransform *transform = [NSAffineTransform transform];
@@ -1720,7 +1730,7 @@
}
- (id)validRequestorForSendType:(NSString *)sendType returnType:(NSString
*)returnType {
- if ([self toolMode] == SKSelectToolMode && NSIsEmptyRect(selectionRect) ==
NO && returnType == nil && ([sendType isEqualToString:NSPDFPboardType] ||
[sendType isEqualToString:NSTIFFPboardType])) {
+ if ([self toolMode] == SKSelectToolMode && NSIsEmptyRect(selectionRect) ==
NO && selectionPageIndex != NSNotFound && returnType == nil && ([sendType
isEqualToString:NSPDFPboardType] || [sendType
isEqualToString:NSTIFFPboardType])) {
return self;
}
return [super validRequestorForSendType:sendType returnType:returnType];
@@ -2217,9 +2227,9 @@
NSRect rect = NSZeroRect;
BOOL autoFits = NO;
- if (toolMode == SKSelectToolMode && NSIsEmptyRect(selectionRect) == NO) {
- rect = NSIntersectionRect(selectionRect, [[self currentPage]
boundsForBox:kPDFDisplayBoxCropBox]);
- page = [self currentPage];
+ if (toolMode == SKSelectToolMode && NSIsEmptyRect(selectionRect) == NO &&
selectionPageIndex != NSNotFound) {
+ page = [self currentSelectionPage];
+ rect = NSIntersectionRect(selectionRect, [page
boundsForBox:kPDFDisplayBoxCropBox]);
autoFits = YES;
}
if (NSIsEmptyRect(rect)) {
@@ -2257,8 +2267,6 @@
[accessibilityChildren release];
accessibilityChildren = nil;
}
- if ([self toolMode] == SKSelectToolMode && NSIsEmptyRect(selectionRect) ==
NO)
- [self setNeedsDisplay:YES];
}
- (void)handleScaleChangedNotification:(NSNotification *)notification {
@@ -2290,7 +2298,7 @@
return YES;
if ([activeAnnotation isNote] && [activeAnnotation isMovable])
return YES;
- if (toolMode == SKSelectToolMode && NSIsEmptyRect(selectionRect) == NO)
+ if (toolMode == SKSelectToolMode && NSIsEmptyRect(selectionRect) == NO
&& selectionPageIndex != NSNotFound)
return YES;
return NO;
} else if (action == @selector(delete:)) {
@@ -3225,7 +3233,7 @@
[self setNeedsDisplay:YES];
return;
} else if ([page pageIndex] != selectionPageIndex && selectionPageIndex !=
NSNotFound) {
- [self setNeedsDisplayInRect:NSInsetRect(selectionRect, -margin,
-margin) ofPage:[[self document] pageAtIndex:selectionPageIndex]];
+ [self setNeedsDisplayInRect:NSInsetRect(selectionRect, -margin,
-margin) ofPage:[self currentSelectionPage]];
[self setNeedsDisplayInRect:NSInsetRect(selectionRect, -margin,
-margin) ofPage:page];
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit