Revision: 13414
http://sourceforge.net/p/skim-app/code/13414
Author: hofman
Date: 2023-04-02 16:20:18 +0000 (Sun, 02 Apr 2023)
Log Message:
-----------
Zoom in one direction only for some destination types
Modified Paths:
--------------
trunk/PDFDestination_SKExtensions.m
Modified: trunk/PDFDestination_SKExtensions.m
===================================================================
--- trunk/PDFDestination_SKExtensions.m 2023-04-02 15:53:25 UTC (rev 13413)
+++ trunk/PDFDestination_SKExtensions.m 2023-04-02 16:20:18 UTC (rev 13414)
@@ -47,6 +47,8 @@
if (point.x >= kPDFDestinationUnspecifiedValue || point.y >=
kPDFDestinationUnspecifiedValue) {
PDFPage *page = [self page];
NSRect bounds = NSZeroRect;
+ NSSize size = pdfView ? [pdfView visibleContentRect].size : NSZeroSize;
+ CGFloat zoom = kPDFDestinationUnspecifiedValue;
BOOL override = YES;
NSInteger type = 0;
@try { type = [[self valueForKeyPath:RUNNING_BEFORE(10_12) ?
@"_pdfPriv.type" : @"_private.type"] doubleValue]; }
@@ -57,16 +59,22 @@
break;
case 1: // Fit
bounds = pdfView ? [pdfView layoutBoundsForPage:page] : [page
boundsForBox:kPDFDisplayBoxCropBox];
+ if (pdfView && NSIsEmptyRect(bounds) == NO)
+ zoom = fmin(size.width / NSWidth(bounds), size.height /
NSHeight(bounds));
break;
case 2: // FitH
bounds = pdfView ? [pdfView layoutBoundsForPage:page] : [page
boundsForBox:kPDFDisplayBoxCropBox];
@try { point.y = [[self valueForKeyPath:RUNNING_BEFORE(10_12)
? @"_pdfPriv.top" : @"_private.top"] doubleValue]; }
@catch (id e) { override = NO; }
+ if (override && pdfView && NSIsEmptyRect(bounds) == NO)
+ zoom = size.width / NSWidth(bounds);
break;
case 3: // FitV
bounds = pdfView ? [pdfView layoutBoundsForPage:page] : [page
boundsForBox:kPDFDisplayBoxCropBox];
@try { point.x = [[self valueForKeyPath:RUNNING_BEFORE(10_12)
? @"_pdfPriv.left" : @"_private.left"] doubleValue]; }
@catch (id e) { override = NO; }
+ if (override && pdfView && NSIsEmptyRect(bounds) == NO)
+ zoom = size.height / NSHeight(bounds);
break;
case 4: // FitR
{
@@ -78,20 +86,28 @@
@catch (id e) { override = NO; }
@try { bounds.size.height = [[self
valueForKeyPath:RUNNING_BEFORE(10_12) ? @"_pdfPriv.top" : @"_private.top"]
doubleValue] - NSMinY(bounds); }
@catch (id e) { override = NO; }
+ if (override && pdfView && NSIsEmptyRect(bounds) == NO)
+ zoom = fmin(size.width / NSWidth(bounds), size.height /
NSHeight(bounds));
break;
}
case 5: // FitB
bounds = [page foregroundRect];
+ if (pdfView && NSIsEmptyRect(bounds) == NO)
+ zoom = fmin(size.width / NSWidth(bounds), size.height /
NSHeight(bounds));
break;
case 6: // FitBH
bounds = [page foregroundRect];
@try { point.y = [[self valueForKeyPath:RUNNING_BEFORE(10_12)
? @"_pdfPriv.top" : @"_private.top"] doubleValue]; }
@catch (id e) { override = NO; }
+ if (override && pdfView && NSIsEmptyRect(bounds) == NO)
+ zoom = size.width / NSWidth(bounds);
break;
case 7: // FitBV
bounds = [page foregroundRect];
@try { point.x = [[self valueForKeyPath:RUNNING_BEFORE(10_12)
? @"_pdfPriv.left" : @"_private.left"] doubleValue]; }
@catch (id e) { override = NO; }
+ if (override && pdfView && NSIsEmptyRect(bounds) == NO)
+ zoom = size.height / NSHeight(bounds);
break;
default:
override = NO;
@@ -103,10 +119,8 @@
if (point.y >= kPDFDestinationUnspecifiedValue)
point.y = NSMaxY(bounds);
PDFDestination *destination = [[[PDFDestination alloc]
initWithPage:page atPoint:point] autorelease];
- if (pdfView && NSWidth(bounds) > 0.0 && NSHeight(bounds) > 0.0) {
- NSSize size = [pdfView visibleContentRect].size;
- [destination setZoom:fmin(size.width / NSWidth(bounds),
size.height / NSHeight(bounds))];
- }
+ if (zoom < kPDFDestinationUnspecifiedValue)
+ [destination setZoom:zoom];
return destination;
}
}
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