Revision: 7308
          http://skim-app.svn.sourceforge.net/skim-app/?rev=7308&view=rev
Author:   hofman
Date:     2011-06-23 13:05:53 +0000 (Thu, 23 Jun 2011)

Log Message:
-----------
Correctly search backward from current page when there's no selection. Start 
with 

Modified Paths:
--------------
    trunk/SKMainWindowController.m

Modified: trunk/SKMainWindowController.m
===================================================================
--- trunk/SKMainWindowController.m      2011-06-21 18:02:00 UTC (rev 7307)
+++ trunk/SKMainWindowController.m      2011-06-23 13:05:53 UTC (rev 7308)
@@ -1695,9 +1695,20 @@
 - (BOOL)findString:(NSString *)string options:(NSInteger)options {
     PDFSelection *sel = [pdfView currentSelection];
     NSUInteger pageIndex = [[pdfView currentPage] pageIndex];
-    while ([sel hasCharacters] == NO && pageIndex-- > 0) {
-        PDFPage *page = [[pdfView document] pageAtIndex:pageIndex];
-        sel = [page selectionForRect:[page 
boundsForBox:kPDFDisplayBoxCropBox]];
+    if (options & NSBackwardsSearch) {
+        while ([sel hasCharacters] == NO && ++pageIndex < [[pdfView document] 
pageCount]) {
+            PDFPage *page = [[pdfView document] pageAtIndex:pageIndex];
+            NSUInteger length = [[page string] length];
+            if (length > 0)
+                sel = [page selectionForRange:NSMakeRange(0, length)];
+        }
+    } else {
+        while ([sel hasCharacters] == NO && pageIndex-- > 0) {
+            PDFPage *page = [[pdfView document] pageAtIndex:pageIndex];
+            NSUInteger length = [[page string] length];
+            if (length > 0)
+                sel = [page selectionForRange:NSMakeRange(0, length)];
+        }
     }
     PDFSelection *selection = [self findString:string fromSelection:sel 
withOptions:options];
     if ([selection hasCharacters] == NO && [sel hasCharacters])


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Simplify data backup and recovery for your virtual environment with vRanger.
Installation's a snap, and flexible recovery options mean your data is safe,
secure and there when you need it. Data protection magic?
Nope - It's vRanger. Get your free trial download today.
http://p.sf.net/sfu/quest-sfdev2dev
_______________________________________________
Skim-app-commit mailing list
Skim-app-commit@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to