Revision: 16808
          http://sourceforge.net/p/skim-app/code/16808
Author:   hofman
Date:     2026-11-25 16:56:32 +0000 (Wed, 25 Nov 2026)
Log Message:
-----------
move method to function

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

Modified: trunk/PDFAnnotation_SKExtensions.m
===================================================================
--- trunk/PDFAnnotation_SKExtensions.m  2026-11-25 16:32:12 UTC (rev 16807)
+++ trunk/PDFAnnotation_SKExtensions.m  2026-11-25 16:56:32 UTC (rev 16808)
@@ -134,6 +134,28 @@
     return lineRects;
 }
 
+static PDFSelection *selectionForLineRectsOnPage(NSPointerArray *lines, 
PDFPage *page) {
+    PDFSelection *selection = nil;
+    NSMutableArray *selections = nil;
+    NSUInteger i, iMax = [lines count];
+    
+    for (i = 0; i < iMax; i++) {
+        // slightly outset the rect to avoid rounding errors, as 
selectionForRect is pretty strict in some OS versions, but unfortunately not in 
others
+        PDFSelection *sel = [page selectionForRect:NSInsetRect([lines 
rectAtIndex:i], -1.0, -1.0)];
+        if ([sel hasCharacters]) {
+            if (selection == nil)
+                selection = sel;
+            else if (selections)
+                [selections addObject:sel];
+            else
+                selections = [NSMutableArray arrayWithObject:sel];
+        }
+    }
+    if (selections)
+        [selection addSelections:selections];
+    return selection;
+}
+
 // NSTextAlignment enum values depend on the architecture, on arm64 right=2 
and center=1
 static inline NSTextAlignment textAlignmentFromAlignment(NSInteger alignment) {
     return alignment == 2 ? NSTextAlignmentCenter : alignment == 1 ? 
NSTextAlignmentRight : 0;
@@ -661,32 +683,9 @@
     return noteText;
 }
 
-- (PDFSelection *)selectionWithPage:(PDFPage *)page {
-    PDFSelection *selection = nil;
-    NSMutableArray *selections = nil;
-    NSPointerArray *lines = [self lineRects];
-    NSUInteger i, iMax = [lines count];
-    
-    for (i = 0; i < iMax; i++) {
-        // slightly outset the rect to avoid rounding errors, as 
selectionForRect is pretty strict in some OS versions, but unfortunately not in 
others
-        PDFSelection *sel = [page selectionForRect:NSInsetRect([lines 
rectAtIndex:i], -1.0, -1.0)];
-        if ([sel hasCharacters]) {
-            if (selection == nil)
-                selection = sel;
-            else if (selections)
-                [selections addObject:sel];
-            else
-                selections = [NSMutableArray arrayWithObject:sel];
-        }
-    }
-    if (selections)
-        [selection addSelections:selections];
-    return selection;
-}
-
 - (PDFSelection *)selection {
     if ([self isMarkup])
-        return [self selectionWithPage:[self page]];
+        return selectionForLineRectsOnPage([self lineRects], [self page]);
     return nil;
 }
 
@@ -1053,7 +1052,7 @@
         if ([selString length])
             [self setString:selString];
     } else if ([type isEqualToString:SKNHighlightString] || [type 
isEqualToString:SKNUnderlineString] || [type 
isEqualToString:SKNStrikeOutString]) {
-        NSString *selString = [[self selectionWithPage:page] cleanedString];
+        NSString *selString = [selectionForLineRectsOnPage([self lineRects], 
page) cleanedString];
         if ([selString length]) {
             // page should be future [self page] and textString will not have 
been called
             objc_setAssociatedObject(self, &SKTextStringKey, selString, 
OBJC_ASSOCIATION_RETAIN_NONATOMIC);

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



_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to