Revision: 4850
          http://skim-app.svn.sourceforge.net/skim-app/?rev=4850&view=rev
Author:   hofman
Date:     2008-10-22 18:27:42 +0000 (Wed, 22 Oct 2008)

Log Message:
-----------
replace ranges in mutable dictionary instead of creating a new dictionary

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

Modified: trunk/PDFSelection_SKExtensions.m
===================================================================
--- trunk/PDFSelection_SKExtensions.m   2008-10-22 16:54:20 UTC (rev 4849)
+++ trunk/PDFSelection_SKExtensions.m   2008-10-22 18:27:42 UTC (rev 4850)
@@ -131,7 +131,6 @@
         return NSMakeRange(NSNotFound, 0);
 }
 
-
 static inline NSRange rangeOfSubstringOfStringAtIndex(NSString *string, 
NSArray *substrings, unsigned int anIndex) {
     unsigned int length = [string length];
     NSRange range = NSMakeRange(0, 0);
@@ -166,18 +165,21 @@
             return nil;
         
         NSEnumerator *dictEnum = [dicts objectEnumerator];
-        NSDictionary *dict;
+        NSMutableDictionary *dict;
         
         while (dict = [dictEnum nextObject]) {
             NSTextStorage *containerText = [dict objectForKey:@"text"];
-            PDFPage *page = [dict objectForKey:@"page"];
             NSEnumerator *rangeEnum = [[dict objectForKey:@"ranges"] 
objectEnumerator];
             NSValue *value;
             NSMutableArray *rangeValues = [[NSMutableArray alloc] init];
             
             while (value = [rangeEnum nextObject]) {
                 NSRange textRange = [value rangeValue];
-                NSTextStorage *textStorage = [[NSTextStorage alloc] 
initWithAttributedString:[containerText 
attributedSubstringFromRange:textRange]];
+                NSTextStorage *textStorage = nil;
+                if (NSEqualRanges(textRange, NSMakeRange(0, [containerText 
length])))
+                    textStorage = [containerText retain];
+                else
+                    textStorage = [[NSTextStorage alloc] 
initWithAttributedString:[containerText 
attributedSubstringFromRange:textRange]];
                 
                 // now get the ranges, which can be any kind of specifier
                 int startIndex, endIndex, i, count, *indices;
@@ -285,9 +287,8 @@
             }
             
             if ([rangeValues count]) {
-                dict = [[NSDictionary alloc] 
initWithObjectsAndKeys:rangeValues, @"ranges", containerText, @"text", page, 
@"page", nil];
+                [dict setObject:rangeValues forKey:@"ranges"];
                 [rangeDicts addObject:dict];
-                [dict release];
             }
             [rangeValues release];
         }
@@ -313,7 +314,7 @@
         while (page = [pageEnum nextObject]) {
             NSTextStorage *containerText = [page richText];
             NSArray *rangeValues = [[NSArray alloc] initWithObjects:[NSValue 
valueWithRange:NSMakeRange(0, [containerText length])], nil];
-            NSDictionary *dict = [[NSDictionary alloc] 
initWithObjectsAndKeys:rangeValues, @"ranges", containerText, @"text", page, 
@"page", nil];
+            NSMutableDictionary *dict = [[NSMutableDictionary alloc] 
initWithObjectsAndKeys:rangeValues, @"ranges", containerText, @"text", page, 
@"page", nil];
             [rangeDicts addObject:dict];
             [dict release];
             [rangeValues release];


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