Revision: 5724
http://skim-app.svn.sourceforge.net/skim-app/?rev=5724&view=rev
Author: hofman
Date: 2009-09-09 09:34:44 +0000 (Wed, 09 Sep 2009)
Log Message:
-----------
gate first non-empty page for a selection rather than just the first page
Modified Paths:
--------------
trunk/PDFAnnotationMarkup_SKExtensions.m
trunk/PDFDocument_SKExtensions.m
trunk/PDFSelection_SKExtensions.h
trunk/SKBoundsCommand.m
trunk/SKIndexCommand.m
trunk/SKJoinCommand.m
trunk/SKMainDocument.m
trunk/SKMainWindowController.m
trunk/SKPDFView.m
Modified: trunk/PDFAnnotationMarkup_SKExtensions.m
===================================================================
--- trunk/PDFAnnotationMarkup_SKExtensions.m 2009-09-09 09:34:11 UTC (rev
5723)
+++ trunk/PDFAnnotationMarkup_SKExtensions.m 2009-09-09 09:34:44 UTC (rev
5724)
@@ -193,12 +193,12 @@
}
- (id)initSkimNoteWithSelection:(PDFSelection *)selection
markupType:(NSInteger)type {
- NSRect bounds = [[selection pages] count] ? [selection
boundsForPage:[[selection pages] objectAtIndex:0]] : NSZeroRect;
+ NSRect bounds = [selection hasCharacters] ? [selection
boundsForPage:[selection safeFirstPage]] : NSZeroRect;
if ([selection hasCharacters] == NO || NSIsEmptyRect(bounds)) {
[[self initWithBounds:NSZeroRect] release];
self = nil;
} else if (self = [self initSkimNoteWithBounds:bounds markupType:type
quadrilateralPointsAsStrings:nil]) {
- PDFPage *page = [[selection pages] objectAtIndex:0];
+ PDFPage *page = [selection safeFirstPage];
NSInteger rotation = floor(NSAppKitVersionNumber) >
NSAppKitVersionNumber10_5 ? [page rotation] : 0;
NSMutableArray *quadPoints = [[NSMutableArray alloc] init];
NSRect newBounds = NSZeroRect;
Modified: trunk/PDFDocument_SKExtensions.m
===================================================================
--- trunk/PDFDocument_SKExtensions.m 2009-09-09 09:34:11 UTC (rev 5723)
+++ trunk/PDFDocument_SKExtensions.m 2009-09-09 09:34:44 UTC (rev 5724)
@@ -44,11 +44,10 @@
- (PDFSelection *)selectionByExtendingSelection:(PDFSelection *)selection
toPage:(PDFPage *)page atPoint:(NSPoint)point {
PDFSelection *sel = selection;
- NSArray *pages = [selection pages];
- if ([pages count]) {
- PDFPage *firstPage = [pages objectAtIndex:0];
- PDFPage *lastPage = [pages lastObject];
+ if ([selection hasCharacters]) {
+ PDFPage *firstPage = [selection safeFirstPage];
+ PDFPage *lastPage = [selection safeLastPage];
NSUInteger pageIndex = [self indexForPage:page];
NSUInteger firstPageIndex = [self indexForPage:firstPage];
NSUInteger lastPageIndex = [self indexForPage:lastPage];
Modified: trunk/PDFSelection_SKExtensions.h
===================================================================
--- trunk/PDFSelection_SKExtensions.h 2009-09-09 09:34:11 UTC (rev 5723)
+++ trunk/PDFSelection_SKExtensions.h 2009-09-09 09:34:44 UTC (rev 5724)
@@ -51,6 +51,8 @@
- (NSUInteger)safeIndexOfFirstCharacterOnPage:(PDFPage *)page;
- (NSUInteger)safeIndexOfLastCharacterOnPage:(PDFPage *)page;
- (NSArray *)safeRangesOnPage:(PDFPage *)page;
+- (PDFPage *)safeFirstPage;
+- (PDFPage *)safeLastPage;
- (BOOL)hasCharacters;
Modified: trunk/SKBoundsCommand.m
===================================================================
--- trunk/SKBoundsCommand.m 2009-09-09 09:34:11 UTC (rev 5723)
+++ trunk/SKBoundsCommand.m 2009-09-09 09:34:44 UTC (rev 5724)
@@ -73,8 +73,7 @@
} else {
PDFSelection *selection = [PDFSelection selectionWithSpecifier:dP];
if ([page isKindOfClass:[PDFPage class]] == NO) {
- NSArray *pages = [selection pages];
- page = [pages count] ? [pages objectAtIndex:0] : nil;
+ page = [selection safeFirstPage];
}
if (page)
bounds = [selection hasCharacters] ? [selection
boundsForPage:page] : NSZeroRect;
Modified: trunk/SKIndexCommand.m
===================================================================
--- trunk/SKIndexCommand.m 2009-09-09 09:34:11 UTC (rev 5723)
+++ trunk/SKIndexCommand.m 2009-09-09 09:34:44 UTC (rev 5724)
@@ -64,8 +64,8 @@
idx = [[((id)page ?: (id)[page containingDocument])
valueForKey:@"notes"] indexOfObjectIdenticalTo:dPO];
} else {
PDFSelection *selection = [PDFSelection selectionWithSpecifier:dP
onPage:page];
- NSArray *pages = [selection pages];
- if ([pages count] && [selection hasCharacters] && (page = [pages
objectAtIndex:last ? [pages count] - 1 : 0]))
+ page = last ? [selection safeLastPage] : [selection safeFirstPage];
+ if (page)
idx = last ? [selection safeIndexOfLastCharacterOnPage:page] :
[selection safeIndexOfFirstCharacterOnPage:page];
}
Modified: trunk/SKJoinCommand.m
===================================================================
--- trunk/SKJoinCommand.m 2009-09-09 09:34:11 UTC (rev 5723)
+++ trunk/SKJoinCommand.m 2009-09-09 09:34:44 UTC (rev 5724)
@@ -57,13 +57,14 @@
[selection addSelection:otherSelection];
if (continuous) {
- NSArray *pages = [selection pages];
- PDFPage *firstPage = [pages objectAtIndex:0];
- PDFPage *lastPage = [pages lastObject];
- NSUInteger firstIndex = [selection
safeIndexOfFirstCharacterOnPage:firstPage];
- NSUInteger lastIndex = [selection
safeIndexOfLastCharacterOnPage:lastPage];
- if (firstIndex != NSNotFound && lastIndex != NSNotFound)
- selection = [[firstPage document] selectionFromPage:firstPage
atCharacterIndex:firstIndex toPage:lastPage atCharacterIndex:lastIndex - 1];
+ PDFPage *firstPage = [selection safeFirstPage];
+ PDFPage *lastPage = [selection safeLastPage];
+ if (firstPage && lastPage) {
+ NSUInteger firstIndex = [selection
safeIndexOfFirstCharacterOnPage:firstPage];
+ NSUInteger lastIndex = [selection
safeIndexOfLastCharacterOnPage:lastPage];
+ if (firstIndex != NSNotFound && lastIndex != NSNotFound)
+ selection = [[firstPage document] selectionFromPage:firstPage
atCharacterIndex:firstIndex toPage:lastPage atCharacterIndex:lastIndex - 1];
+ }
}
return selection ? [selection objectSpecifier] : [NSArray array];
}
Modified: trunk/SKMainDocument.m
===================================================================
--- trunk/SKMainDocument.m 2009-09-09 09:34:11 UTC (rev 5723)
+++ trunk/SKMainDocument.m 2009-09-09 09:34:44 UTC (rev 5724)
@@ -1968,7 +1968,7 @@
if ([key isEqualToString:@"notes"]) {
PDFAnnotation *annotation = nil;
PDFSelection *selection = [PDFSelection
selectionWithSpecifier:[properties
objectForKey:SKPDFAnnotationSelectionSpecifierKey]];
- PDFPage *page = [[selection pages] count] ? [[selection pages]
objectAtIndex:0] : nil;
+ PDFPage *page = [selection safeFirstPage];
if (page == nil) {
[[NSScriptCommand currentCommand]
setScriptErrorNumber:NSReceiversCantHandleCommandScriptError];
} else {
@@ -2104,7 +2104,7 @@
} else {
PDFSelection *selection = [PDFSelection
selectionWithSpecifier:[[command arguments] objectForKey:@"To"]];
if ([selection hasCharacters]) {
- PDFPage *page = [[selection pages] objectAtIndex:0];
+ PDFPage *page = [selection safeFirstPage];
NSRect bounds = [selection boundsForPage:page];
[[self pdfView] scrollRect:bounds inPageToVisible:page];
}
Modified: trunk/SKMainWindowController.m
===================================================================
--- trunk/SKMainWindowController.m 2009-09-09 09:34:11 UTC (rev 5723)
+++ trunk/SKMainWindowController.m 2009-09-09 09:34:44 UTC (rev 5724)
@@ -1927,7 +1927,7 @@
}
if (scroll && [firstSel hasCharacters]) {
- PDFPage *page = [[currentSel pages] objectAtIndex:0];
+ PDFPage *page = [currentSel safeFirstPage];
NSRect rect = NSIntersectionRect(NSInsetRect([currentSel
boundsForPage:page], -50.0, -50.0), [page boundsForBox:kPDFDisplayBoxCropBox]);
[pdfView scrollRect:rect inPageToVisible:page];
}
@@ -2004,7 +2004,7 @@
}
[searchResults addObject:instance];
- PDFPage *page = [[instance pages] objectAtIndex:0];
+ PDFPage *page = [instance safeFirstPage];
SKGroupedSearchResult *result = [groupedSearchResults lastObject];
NSUInteger maxCount = [result maxCount];
if ([[result page] isEqual:page] == NO) {
Modified: trunk/SKPDFView.m
===================================================================
--- trunk/SKPDFView.m 2009-09-09 09:34:11 UTC (rev 5723)
+++ trunk/SKPDFView.m 2009-09-09 09:34:44 UTC (rev 5724)
@@ -1561,7 +1561,7 @@
PDFPage *page = [self currentPage];
NSUInteger idx = 0;
if ([selection hasCharacters]) {
- page = [[selection pages] lastObject];
+ page = [selection safeLastPage];
idx = [selection safeIndexOfLastCharacterOnPage:page];
if (idx == NSNotFound)
idx = 0;
@@ -1574,7 +1574,7 @@
PDFPage *page = [self currentPage];
NSUInteger idx = 0;
if ([selection hasCharacters]) {
- page = [[selection pages] objectAtIndex:0];
+ page = [selection safeFirstPage];
idx = [selection safeIndexOfFirstCharacterOnPage:page];
if (idx == NSNotFound)
idx = 0;
@@ -1825,7 +1825,7 @@
text = [selection cleanedString];
// Get bounds (page space) for selection (first page in case
selection spans multiple pages).
- page = [[selection pages] objectAtIndex: 0];
+ page = [selection safeFirstPage];
bounds = [selection boundsForPage: page];
if (annotationType == SKCircleNote || annotationType == SKSquareNote)
bounds = NSInsetRect(bounds, -5.0, -5.0);
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit