Revision: 5547
          http://skim-app.svn.sourceforge.net/skim-app/?rev=5547&view=rev
Author:   hofman
Date:     2009-08-12 18:57:26 +0000 (Wed, 12 Aug 2009)

Log Message:
-----------
use selectionsByLine to get the lines in a selection if defined

Modified Paths:
--------------
    trunk/PDFAnnotationMarkup_SKExtensions.m
    trunk/PDFPage_SKExtensions.m

Modified: trunk/PDFAnnotationMarkup_SKExtensions.m
===================================================================
--- trunk/PDFAnnotationMarkup_SKExtensions.m    2009-08-12 13:50:32 UTC (rev 
5546)
+++ trunk/PDFAnnotationMarkup_SKExtensions.m    2009-08-12 18:57:26 UTC (rev 
5547)
@@ -203,15 +203,26 @@
         self = nil;
     } else if (self = [self initSkimNoteWithBounds:bounds markupType:type 
quadrilateralPointsAsStrings:nil]) {
         PDFPage *page = [[selection pages] objectAtIndex:0];
-        NSString *string = [page string];
         NSMutableArray *quadPoints = [[NSMutableArray alloc] init];
         NSRect newBounds = NSZeroRect;
         if (selection) {
-            NSUInteger i, iMax = [selection safeNumberOfRangesOnPage:page];
+            NSUInteger i, iMax;
             NSRect lineRect = NSZeroRect;
-            NSRect charRect = NSZeroRect;
-            NSRect lastCharRect = NSZeroRect;
-            if (iMax > 0) {
+            if ([selection respondsToSelector:@selector(selectionsByLine)]) {
+                NSEnumerator *selEnum = [[selection selectionsByLine] 
objectEnumerator];
+                PDFSelection *sel;
+                while (sel = [selEnum nextObject]) {
+                    lineRect = [sel boundsForPage:page];
+                    if (NSIsEmptyRect(lineRect) == NO && [[sel string] 
rangeOfCharacterFromSet:[NSCharacterSet 
nonWhitespaceAndNewlineCharacterSet]].length) {
+                         CFArrayAppendValue([self lineRects], &lineRect);
+                         newBounds = NSUnionRect(lineRect, newBounds);
+                    }
+                } 
+            } else if (iMax > 0) {
+                NSString *string = [page string];
+                NSRect charRect = NSZeroRect;
+                NSRect lastCharRect = NSZeroRect;
+                iMax = [selection safeNumberOfRangesOnPage:page];
                 for (i = 0; i < iMax; i++) {
                     NSRange range = [selection safeRangeAtIndex:i onPage:page];
                     NSUInteger j, jMax = NSMaxRange(range);
@@ -242,16 +253,6 @@
                     CFArrayAppendValue([self lineRects], &lineRect);
                     newBounds = NSUnionRect(lineRect, newBounds);
                 }
-            } else if ([selection 
respondsToSelector:@selector(selectionsByLine)]) {
-                NSEnumerator *selEnum = [[selection selectionsByLine] 
objectEnumerator];
-                PDFSelection *sel;
-                while (sel = [selEnum nextObject]) {
-                    lineRect = [sel boundsForPage:page];
-                    if (NSIsEmptyRect(lineRect) == NO && [[sel string] 
rangeOfCharacterFromSet:[NSCharacterSet 
nonWhitespaceAndNewlineCharacterSet]].length) {
-                         CFArrayAppendValue([self lineRects], &lineRect);
-                         newBounds = NSUnionRect(lineRect, newBounds);
-                    }
-                } 
             }
             if (NSIsEmptyRect(newBounds)) {
                 [self release];

Modified: trunk/PDFPage_SKExtensions.m
===================================================================
--- trunk/PDFPage_SKExtensions.m        2009-08-12 13:50:32 UTC (rev 5546)
+++ trunk/PDFPage_SKExtensions.m        2009-08-12 18:57:26 UTC (rev 5547)
@@ -377,12 +377,21 @@
 - (NSArray *)lineRects {
     NSMutableArray *lines = [NSMutableArray array];
     PDFSelection *sel = [self selectionForRect:[self 
boundsForBox:kPDFDisplayBoxCropBox]];
-    NSUInteger i, iMax = [sel safeNumberOfRangesOnPage:self];
-    NSMutableIndexSet *indexes = [NSMutableIndexSet indexSet];
-    NSString *string = [self string];
-    NSRange stringRange = NSMakeRange(0, [string length]);
+    NSUInteger i, iMax;
     
-    if (iMax > 0) {
+    if ([sel respondsToSelector:@selector(selectionsByLine)]) {
+        NSEnumerator *selEnum = [[sel selectionsByLine] objectEnumerator];
+        PDFSelection *s;
+        while (s = [selEnum nextObject]) {
+            NSRect r = [s boundsForPage:self];
+            if (NSIsEmptyRect(r) == NO && [[s string] 
rangeOfCharacterFromSet:[NSCharacterSet 
nonWhitespaceAndNewlineCharacterSet]].length)
+                [lines addObject:[NSValue valueWithRect:r]];
+        } 
+    } else if (sel) {
+        NSMutableIndexSet *indexes = [NSMutableIndexSet indexSet];
+        NSString *string = [self string];
+        NSRange stringRange = NSMakeRange(0, [string length]);
+        iMax = [sel safeNumberOfRangesOnPage:self];
         for (i = 0; i < iMax; i++) {
             NSRange range = [sel safeRangeAtIndex:i onPage:self];
             NSUInteger j, jMax = NSMaxRange(range);
@@ -409,14 +418,6 @@
                     [lines addObject:[NSValue valueWithRect:[s 
boundsForPage:self]]];
             }
         }
-    } else if ([sel respondsToSelector:@selector(selectionsByLine)]) {
-        NSEnumerator *selEnum = [[sel selectionsByLine] objectEnumerator];
-        PDFSelection *s;
-        while (s = [selEnum nextObject]) {
-            NSRect r = [s boundsForPage:self];
-            if (NSIsEmptyRect(r) == NO && [[s string] 
rangeOfCharacterFromSet:[NSCharacterSet 
nonWhitespaceAndNewlineCharacterSet]].length)
-                [lines addObject:[NSValue valueWithRect:r]];
-        } 
     }
     
     [lines sortUsingSelector:@selector(boundsCompare:)];


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

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to