Revision: 13410
          http://sourceforge.net/p/skim-app/code/13410
Author:   hofman
Date:     2023-04-02 08:19:15 +0000 (Sun, 02 Apr 2023)
Log Message:
-----------
Pass view size for destination rather than rect. Get doubleValue rather than 
integerValue. Remove shadowed variable.

Modified Paths:
--------------
    trunk/PDFDestination_SKExtensions.h
    trunk/PDFDestination_SKExtensions.m
    trunk/SKBasePDFView.m
    trunk/SKImageToolTipContext.m
    trunk/SKPDFView.m
    trunk/SKReadingBar.m

Modified: trunk/PDFDestination_SKExtensions.h
===================================================================
--- trunk/PDFDestination_SKExtensions.h 2023-04-01 14:03:31 UTC (rev 13409)
+++ trunk/PDFDestination_SKExtensions.h 2023-04-02 08:19:15 UTC (rev 13410)
@@ -41,6 +41,6 @@
 
 @interface PDFDestination (SKExtensions)
 
-- (PDFDestination *)effectiveDestinationWithTargetRect:(NSRect)rect;
+- (PDFDestination *)effectiveDestinationWithTargetSize:(NSSize)rect;
 
 @end

Modified: trunk/PDFDestination_SKExtensions.m
===================================================================
--- trunk/PDFDestination_SKExtensions.m 2023-04-01 14:03:31 UTC (rev 13409)
+++ trunk/PDFDestination_SKExtensions.m 2023-04-02 08:19:15 UTC (rev 13410)
@@ -41,7 +41,7 @@
 
 @implementation PDFDestination (SKExtensions)
 
-- (PDFDestination *)effectiveDestinationWithTargetRect:(NSRect)rect {
+- (PDFDestination *)effectiveDestinationWithTargetSize:(NSSize)size {
     NSPoint point = [self point];
     if (point.x >= kPDFDestinationUnspecifiedValue || point.y >= 
kPDFDestinationUnspecifiedValue) {
         PDFPage *page = [self page];
@@ -48,7 +48,7 @@
         NSRect bounds = NSZeroRect;
         BOOL override = YES;
         NSInteger type = 0;
-        @try { type = [[self valueForKeyPath:RUNNING_BEFORE(10_12) ? 
@"_pdfPriv.type" : @"_private.type"] integerValue]; }
+        @try { type = [[self valueForKeyPath:RUNNING_BEFORE(10_12) ? 
@"_pdfPriv.type" : @"_private.type"] doubleValue]; }
         @catch (id e) {}
         switch (type) {
             case 0:
@@ -59,23 +59,23 @@
                 break;
             case 2: // FitH
                 bounds = [page foregroundBox];
-                @try { point.y = [[self valueForKeyPath:RUNNING_BEFORE(10_12) 
? @"_pdfPriv.top" : @"_private.top"] integerValue]; }
+                @try { point.y = [[self valueForKeyPath:RUNNING_BEFORE(10_12) 
? @"_pdfPriv.top" : @"_private.top"] doubleValue]; }
                 @catch (id e) { override = NO; }
                 break;
             case 3: // FitV
                 bounds = [page foregroundBox];
-                @try { point.x = [[self valueForKeyPath:RUNNING_BEFORE(10_12) 
? @"_pdfPriv.left" : @"_private.left"] integerValue]; }
+                @try { point.x = [[self valueForKeyPath:RUNNING_BEFORE(10_12) 
? @"_pdfPriv.left" : @"_private.left"] doubleValue]; }
                 @catch (id e) { override = NO; }
                 break;
             case 4: // FitR
             {
-                @try { bounds.origin.x = [[self 
valueForKeyPath:RUNNING_BEFORE(10_12) ? @"_pdfPriv.left" : @"_private.left"] 
integerValue]; }
+                @try { bounds.origin.x = [[self 
valueForKeyPath:RUNNING_BEFORE(10_12) ? @"_pdfPriv.left" : @"_private.left"] 
doubleValue]; }
                 @catch (id e) { override = NO; }
-                @try { bounds.origin.y = [[self 
valueForKeyPath:RUNNING_BEFORE(10_12) ? @"_pdfPriv.bottom" : 
@"_private.bottom"] integerValue]; }
+                @try { bounds.origin.y = [[self 
valueForKeyPath:RUNNING_BEFORE(10_12) ? @"_pdfPriv.bottom" : 
@"_private.bottom"] doubleValue]; }
                 @catch (id e) { override = NO; }
-                @try { bounds.size.width = [[self 
valueForKeyPath:RUNNING_BEFORE(10_12) ? @"_pdfPriv.right" : @"_private.right"] 
integerValue] - NSMinX(bounds); }
+                @try { bounds.size.width = [[self 
valueForKeyPath:RUNNING_BEFORE(10_12) ? @"_pdfPriv.right" : @"_private.right"] 
doubleValue] - NSMinX(bounds); }
                 @catch (id e) { override = NO; }
-                @try { bounds.size.height = [[self 
valueForKeyPath:RUNNING_BEFORE(10_12) ? @"_pdfPriv.top" : @"_private.top"] 
integerValue] - NSMinY(bounds); }
+                @try { bounds.size.height = [[self 
valueForKeyPath:RUNNING_BEFORE(10_12) ? @"_pdfPriv.top" : @"_private.top"] 
doubleValue] - NSMinY(bounds); }
                 @catch (id e) { override = NO; }
                 break;
             }
@@ -84,12 +84,12 @@
                 break;
             case 6: // FitBH
                 bounds = [page boundsForBox:kPDFDisplayBoxCropBox];
-                @try { point.y = [[self valueForKeyPath:RUNNING_BEFORE(10_12) 
? @"_pdfPriv.top" : @"_private.top"] integerValue]; }
+                @try { point.y = [[self valueForKeyPath:RUNNING_BEFORE(10_12) 
? @"_pdfPriv.top" : @"_private.top"] doubleValue]; }
                 @catch (id e) { override = NO; }
                 break;
             case 7: // FitBV
                 bounds = [page boundsForBox:kPDFDisplayBoxCropBox];
-                @try { point.x = [[self valueForKeyPath:RUNNING_BEFORE(10_12) 
? @"_pdfPriv.left" : @"_private.left"] integerValue]; }
+                @try { point.x = [[self valueForKeyPath:RUNNING_BEFORE(10_12) 
? @"_pdfPriv.left" : @"_private.left"] doubleValue]; }
                 @catch (id e) { override = NO; }
                 break;
             default:
@@ -97,14 +97,13 @@
                 break;
         }
         if (override) {
-            NSRect bounds;
             if (point.x >= kPDFDestinationUnspecifiedValue)
                 point.x = NSMinX(bounds);
             if (point.y >= kPDFDestinationUnspecifiedValue)
                 point.y = NSMaxY(bounds);
             PDFDestination *destination = [[[PDFDestination alloc] 
initWithPage:page atPoint:point] autorelease];
-            if (NSIsEmptyRect(rect) == NO)
-                [destination setZoom:fmin(NSWidth(rect) / NSWidth(bounds), 
NSHeight(rect) / NSHeight(bounds))];
+            if (size.width > 0.0 && size.height > 0.0)
+                [destination setZoom:fmin(size.width / NSWidth(bounds), 
size.height / NSHeight(bounds))];
             return destination;
         }
     }

Modified: trunk/SKBasePDFView.m
===================================================================
--- trunk/SKBasePDFView.m       2023-04-01 14:03:31 UTC (rev 13409)
+++ trunk/SKBasePDFView.m       2023-04-02 08:19:15 UTC (rev 13410)
@@ -398,7 +398,7 @@
 }
 
 - (void)goToDestination:(PDFDestination *)destination {
-     [super goToDestination:[destination 
effectiveDestinationWithTargetRect:[self visibleContentRect]]];
+     [super goToDestination:[destination 
effectiveDestinationWithTargetSize:[self visibleContentRect].size]];
 }
 
 @end

Modified: trunk/SKImageToolTipContext.m
===================================================================
--- trunk/SKImageToolTipContext.m       2023-04-01 14:03:31 UTC (rev 13409)
+++ trunk/SKImageToolTipContext.m       2023-04-02 08:19:15 UTC (rev 13410)
@@ -107,7 +107,7 @@
     
     BOOL isScaled = fabs(scale - 1.0) > 0.01;
     PDFPage *page = [self page];
-    NSPoint point = [[self effectiveDestinationWithTargetRect:NSZeroRect] 
point];
+    NSPoint point = [[self effectiveDestinationWithTargetSize:NSZeroSize] 
point];
     NSRect bounds = [page boundsForBox:kPDFDisplayBoxCropBox];
     CGFloat size = isScaled ? ceil(scale * fmax(NSWidth(bounds), 
NSHeight(bounds))) : 0.0;
     NSImage *pageImage = [page thumbnailWithSize:size 
forBox:kPDFDisplayBoxCropBox shadowBlurRadius:0.0 highlights:selections];

Modified: trunk/SKPDFView.m
===================================================================
--- trunk/SKPDFView.m   2023-04-01 14:03:31 UTC (rev 13409)
+++ trunk/SKPDFView.m   2023-04-02 08:19:15 UTC (rev 13410)
@@ -4970,7 +4970,7 @@
             PDFDestination *destination = [annotation linkDestination];
             if ([destination page]) {
                 page = [destination page];
-                point = [[destination 
effectiveDestinationWithTargetRect:NSZeroRect] point];
+                point = [[destination 
effectiveDestinationWithTargetSize:NSZeroSize] point];
                 point = [self convertPoint:point fromPage:page];
                 point.y -= 0.5 * DEFAULT_SNAPSHOT_HEIGHT;
             }

Modified: trunk/SKReadingBar.m
===================================================================
--- trunk/SKReadingBar.m        2023-04-01 14:03:31 UTC (rev 13409)
+++ trunk/SKReadingBar.m        2023-04-02 08:19:15 UTC (rev 13410)
@@ -312,7 +312,7 @@
         }
         if (dest) {
             aPage = [dest page];
-            point = [[dest effectiveDestinationWithTargetRect:NSZeroRect] 
point];
+            point = [[dest effectiveDestinationWithTargetSize:NSZeroSize] 
point];
         }
     } else if ([location isKindOfClass:[SKLine class]]) {
         aPage = [(SKLine *)location page];

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