Revision: 3967
          http://skim-app.svn.sourceforge.net/skim-app/?rev=3967&view=rev
Author:   hofman
Date:     2008-06-04 11:28:49 -0700 (Wed, 04 Jun 2008)

Log Message:
-----------
Scroll full selection to visible when highlighting grouped search results

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

Modified: trunk/SKMainWindowController.m
===================================================================
--- trunk/SKMainWindowController.m      2008-06-04 17:45:15 UTC (rev 3966)
+++ trunk/SKMainWindowController.m      2008-06-04 18:28:49 UTC (rev 3967)
@@ -2875,34 +2875,36 @@
 }
 
 - (void)goToFindResults:(NSArray *)findResults scrollToVisible:(BOOL)scroll {
-    BOOL highlight = [[NSUserDefaults standardUserDefaults] 
boolForKey:SKShouldHighlightSearchResultsKey];
-    // union all selected objects
+    if ([findResults count] == 0)
+        return;
+    
     NSEnumerator *selE = [findResults objectEnumerator];
     PDFSelection *sel;
     
     // arm:  PDFSelection is mutable, and using -addSelection on an object 
from selectedObjects will actually mutate the object in searchResults, which 
does bad things.  MagicHat indicates that PDFSelection implements copyWithZone: 
even though it doesn't conform to <NSCopying>, so we'll use that since -init 
doesn't work (-initWithDocument: does, but it's not listed in the header 
either).  I filed rdar://problem/4888251 and also noticed that PDFKitViewer 
sample code uses -[PDFSelection copy].
-    PDFSelection *currentSel = [[[selE nextObject] copy] autorelease];
+    PDFSelection *firstSel = [selE nextObject];
+    PDFSelection *currentSel = [[firstSel copy] autorelease];
     
-    [pdfView setCurrentSelection:currentSel];
+    while (sel = [selE nextObject])
+        [currentSel addSelection:sel];
     
-    if (scroll && [findResults count])
+    if (scroll) {
+        [pdfView setCurrentSelection:currentSel];
         [pdfView scrollSelectionToVisible:self];
+    }
     
     [self removeTemporaryAnnotations];
     
     // add an annotation so it's easier to see the search result
-    if (highlight)
-        [self addAnnotationsForSelection:currentSel];
+    if ([[NSUserDefaults standardUserDefaults] 
boolForKey:SKShouldHighlightSearchResultsKey]) {
+        selE = [findResults objectEnumerator];
+        while (sel = [selE nextObject])
+            [self addAnnotationsForSelection:sel];
+    }
     
     if ([pdfView respondsToSelector:@selector(setCurrentSelection:animate:)])
-        [pdfView setCurrentSelection:currentSel animate:YES];
+        [pdfView setCurrentSelection:firstSel animate:YES];
     
-    while (sel = [selE nextObject]) {
-        [currentSel addSelection:sel];
-        if (highlight)
-            [self addAnnotationsForSelection:sel];
-    }
-    
     [pdfView setCurrentSelection:currentSel];
 }
 


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

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to