Revision: 4863
          http://skim-app.svn.sourceforge.net/skim-app/?rev=4863&view=rev
Author:   hofman
Date:     2008-10-24 16:41:07 +0000 (Fri, 24 Oct 2008)

Log Message:
-----------
add selection components once, which is more efficient

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

Modified: trunk/PDFSelection_SKExtensions.m
===================================================================
--- trunk/PDFSelection_SKExtensions.m   2008-10-24 16:07:48 UTC (rev 4862)
+++ trunk/PDFSelection_SKExtensions.m   2008-10-24 16:41:07 UTC (rev 4863)
@@ -390,7 +390,7 @@
         }
     }
     
-    PDFSelection *selection = nil;
+    NSMutableArray *selections = [NSMutableArray array];
     NSEnumerator *specEnum = [specifier objectEnumerator];
     NSScriptObjectSpecifier *spec;
     
@@ -422,6 +422,7 @@
                     NSRange range = [value rangeValue];
                     unsigned int pageStart = 0;
                     unsigned int startPage = NSNotFound, endPage = NSNotFound, 
startIndex = NSNotFound, endIndex = NSNotFound;
+                    
                     for (i = 0; i < numPages; i++) {
                         if (pageLengths[i] == NSNotFound)
                             pageLengths[i] = [[[document pageAtIndex:i] 
string] length];
@@ -443,11 +444,8 @@
                     if (startPage != NSNotFound && startIndex != NSNotFound && 
endPage != NSNotFound && endIndex != NSNotFound) {
                         PDFSelection *sel = [document 
selectionFromPage:[document pageAtIndex:startPage] atCharacterIndex:startIndex 
toPage:[document pageAtIndex:endPage] atCharacterIndex:endIndex];
                         if (sel) {
+                            [selections addObject:sel];
                             doc = document;
-                            if (selection == nil)
-                                selection = sel;
-                            else
-                                [selection addSelection:sel];
                         }
                     }
                 }
@@ -460,17 +458,23 @@
                     PDFSelection *sel;
                     NSRange range = [value rangeValue];
                     if (range.length && (sel = [container 
selectionForRange:range])) {
+                        [selections addObject:sel];
                         doc = [container document];
-                        if (selection == nil)
-                            selection = sel;
-                        else
-                            [selection addSelection:sel];
                     }
                 }
                 
             }
         }
     }
+    
+    PDFSelection *selection = nil;
+    if ([selections count]) {
+        selection = [selections objectAtIndex:0];
+        if ([selections count] > 1) {
+            [selections removeObjectAtIndex:0];
+            [selection addSelections:selections];
+        }
+    }
     return selection;
 }
 


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

Reply via email to