Revision: 4859
http://skim-app.svn.sourceforge.net/skim-app/?rev=4859&view=rev
Author: hofman
Date: 2008-10-24 13:15:07 +0000 (Fri, 24 Oct 2008)
Log Message:
-----------
generated page ranges lazily
Modified Paths:
--------------
trunk/PDFSelection_SKExtensions.m
Modified: trunk/PDFSelection_SKExtensions.m
===================================================================
--- trunk/PDFSelection_SKExtensions.m 2008-10-24 12:05:38 UTC (rev 4858)
+++ trunk/PDFSelection_SKExtensions.m 2008-10-24 13:15:07 UTC (rev 4859)
@@ -413,28 +413,30 @@
PDFDocument *document = [container pdfDocument];
unsigned int i, numPages = [document pageCount];
NSRange *pageRanges = NSZoneMalloc(NSDefaultMallocZone(),
numPages * sizeof(NSRange));
+ unsigned aPageIndex = aPage ? [aPage pageIndex] : NSNotFound;
for (i = 0; i < numPages; i++)
- pageRanges[i] = NSMakeRange(i == 0 ? 0 :
NSMaxRange(pageRanges[i - 1]), [[[document pageAtIndex:i] string] length]);
+ pageRanges[i] = NSMakeRange(NSNotFound, 0);
while (value = [rangeEnum nextObject]) {
NSRange range = [value rangeValue];
- for (i = 0; (i < numPages) && (NSMaxRange(range) >
pageRanges[i].location); i++) {
- PDFSelection *sel;
- NSRange r = NSIntersectionRange(pageRanges[i], range);
- if (r.length == 0)
- continue;
- r.location -= pageRanges[i].location;
- PDFPage *page = [document pageAtIndex:i];
- if (aPage && [aPage isEqual:page] == NO)
- continue;
- if (sel = [page selectionForRange:r]) {
- doc = document;
- if (selection == nil)
- selection = sel;
- else
- [selection addSelection:sel];
+ for (i = 0; i < numPages; i++) {
+ if (pageRanges[i].location == NSNotFound)
+ pageRanges[i] = NSMakeRange(i == 0 ? 0 :
NSMaxRange(pageRanges[i - 1]), [[[document pageAtIndex:i] string] length]);
+ if ((aPageIndex == NSNotFound || i == aPageIndex) &&
pageRanges[i].length && range.location < NSMaxRange(pageRanges[i])) {
+ PDFSelection *sel;
+ NSRange r = NSIntersectionRange(pageRanges[i],
range);
+ r.location -= pageRanges[i].location;
+ if (sel = [[document pageAtIndex:i]
selectionForRange:r]) {
+ doc = document;
+ if (selection == nil)
+ selection = sel;
+ else
+ [selection addSelection:sel];
+ }
}
+ if (NSMaxRange(range) <= NSMaxRange(pageRanges[i]))
+ break;
}
}
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 the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit