Revision: 15433
          http://sourceforge.net/p/skim-app/code/15433
Author:   hofman
Date:     2025-06-11 09:33:29 +0000 (Wed, 11 Jun 2025)
Log Message:
-----------
return unspecified point in destination when we want to ignore it for user 
rotated pages

Modified Paths:
--------------
    trunk/PDFView_SKExtensions.h
    trunk/PDFView_SKExtensions.m
    trunk/SKMainDocument.m
    trunk/SKMainWindowController.m
    trunk/SKMainWindowController_Actions.m

Modified: trunk/PDFView_SKExtensions.h
===================================================================
--- trunk/PDFView_SKExtensions.h        2025-06-11 09:07:22 UTC (rev 15432)
+++ trunk/PDFView_SKExtensions.h        2025-06-11 09:33:29 UTC (rev 15433)
@@ -67,7 +67,7 @@
 
 - (PDFPage *)pageAndPoint:(NSPoint * _Nullable)point forEvent:(NSEvent *)event 
nearest:(BOOL)nearest;
 
-- (SKDestination)currentDestinationRotated:(BOOL * _Nullable)rotated;
+- (SKDestination)currentDestination:(BOOL)invalidatePointWwhenRotated;
 - (void)goToCurrentDestination:(SKDestination)destination;
 
 - (void)goToCurrentPage:(PDFPage *)page;

Modified: trunk/PDFView_SKExtensions.m
===================================================================
--- trunk/PDFView_SKExtensions.m        2025-06-11 09:07:22 UTC (rev 15432)
+++ trunk/PDFView_SKExtensions.m        2025-06-11 09:33:29 UTC (rev 15433)
@@ -198,14 +198,15 @@
     return page;
 }
 
-- (SKDestination)currentDestinationRotated:(BOOL *)rotated {
+- (SKDestination)currentDestination:(BOOL)invalidatePointWwhenRotated {
     PDFPage *page = [self currentPage];
-    // don't use currentDestination, as that always gives the top-left of the 
page in non-continuous mode, rather than the visible area
-    NSPoint point = SKTopLeftPoint([self bounds]);
-    point.y -= [[self scrollView] contentInsets].top;
-    point = [self convertPoint:point toPage:page];
-    if (rotated)
-        *rotated = [page rotation] != [page intrinsicRotation];
+    NSPoint point = SKUnspecifiedPoint;
+    if (invalidatePointWwhenRotated == NO || [page rotation] == [page 
intrinsicRotation]) {
+        // don't use currentDestination, as that always gives the top-left of 
the page in non-continuous mode, rather than the visible area
+        point = SKTopLeftPoint([self bounds]);
+        point.y -= [[self scrollView] contentInsets].top;
+        point = [self convertPoint:point toPage:page];
+    }
     return (SKDestination){[page pageIndex], point};
 }
 

Modified: trunk/SKMainDocument.m
===================================================================
--- trunk/SKMainDocument.m      2025-06-11 09:07:22 UTC (rev 15432)
+++ trunk/SKMainDocument.m      2025-06-11 09:33:29 UTC (rev 15433)
@@ -1777,7 +1777,7 @@
 }
 
 - (NSData *)currentQDPoint {
-    SKDestination dest = [[self pdfView] currentDestinationRotated:NULL];
+    SKDestination dest = [[self pdfView] currentDestination:NO];
     Point qdPoint = SKQDPointFromNSPoint(dest.point);
     return [NSData dataWithBytes:&qdPoint length:sizeof(Point)];
 }

Modified: trunk/SKMainWindowController.m
===================================================================
--- trunk/SKMainWindowController.m      2025-06-11 09:07:22 UTC (rev 15432)
+++ trunk/SKMainWindowController.m      2025-06-11 09:33:29 UTC (rev 15433)
@@ -629,8 +629,7 @@
 
 - (NSDictionary *)currentSetup {
     NSMutableDictionary *setup = [NSMutableDictionary dictionary];
-    BOOL rotated = NO;
-    SKDestination dest = [pdfView currentDestinationRotated:&rotated];
+    SKDestination dest = [pdfView currentDestination:YES];
     NSArray *cropBoxes = [self changedCropBoxes];
     
     if ([self interactionMode] == SKPresentationMode)
@@ -640,7 +639,7 @@
     [setup setObject:[NSNumber numberWithDouble:[self leftSideWidth]] 
forKey:LEFTSIDEPANEWIDTH_KEY];
     [setup setObject:[NSNumber numberWithDouble:[self rightSideWidth]] 
forKey:RIGHTSIDEPANEWIDTH_KEY];
     [setup setObject:[NSNumber numberWithUnsignedInteger:dest.pageIndex] 
forKey:PAGEINDEX_KEY];
-    if (rotated == NO)
+    if (NSEqualPoints(dest.point, SKUnspecifiedPoint) == NO)
         [setup setObject:NSStringFromPoint(dest.point) forKey:SCROLLPOINT_KEY];
     if (cropBoxes)
         [setup setObject:cropBoxes forKey:CROPBOXES_KEY];
@@ -1074,7 +1073,6 @@
     NSMutableArray *widgetProperties = nil;
     PDFDocument *oldPdfDoc = [pdfView document];
     SKDestination dest = {NSNotFound, NSZeroPoint}, secondaryDest = 
{NSNotFound, NSZeroPoint};
-    BOOL rotated = NO;
     NSArray *snapshotDicts = nil;
     NSDictionary *openState = nil;
     
@@ -1081,14 +1079,9 @@
     if (oldPdfDoc) {
         // this is a revert
         // need to clean up data and actions, and remember settings to restore
-        dest = [pdfView currentDestinationRotated:&rotated];
-        if (rotated)
-            dest.point = SKUnspecifiedPoint;
-        if (secondaryPdfView) {
-            secondaryDest = [secondaryPdfView 
currentDestinationRotated:&rotated];
-            if (rotated)
-                secondaryDest.point = SKUnspecifiedPoint;
-        }
+        dest = [pdfView currentDestination:YES];
+        if (secondaryPdfView)
+            secondaryDest = [secondaryPdfView currentDestination:YES];
         openState = [self expansionStateForOutline:[[pdfView document] 
outlineRoot]];
         
         [oldPdfDoc cancelFindString];

Modified: trunk/SKMainWindowController_Actions.m
===================================================================
--- trunk/SKMainWindowController_Actions.m      2025-06-11 09:07:22 UTC (rev 
15432)
+++ trunk/SKMainWindowController_Actions.m      2025-06-11 09:33:29 UTC (rev 
15433)
@@ -399,7 +399,7 @@
         beforeMarkedPage.pageIndex = MIN(beforeMarkedPage.pageIndex, [pdfDoc 
pageCount] - 1);
         [pdfView goToCurrentDestination:beforeMarkedPage];
     } else if (currentPageIndex != markedPage.pageIndex) {
-        beforeMarkedPage = [pdfView currentDestinationRotated:NULL];
+        beforeMarkedPage = [pdfView currentDestination:NO];
         markedPage.pageIndex = MIN(markedPage.pageIndex, [pdfDoc pageCount] - 
1);
         [pdfView goToCurrentDestination:markedPage];
     }
@@ -412,7 +412,7 @@
         [(SKThumbnailItem *)[overviewView itemAtIndexPath:[NSIndexPath 
indexPathForItem:markedPage.pageIndex inSection:0]] setMarked:NO];
         [[(NSTableCellView *)[leftSideController.thumbnailTableView 
viewAtColumn:1 row:markedPage.pageIndex makeIfNecessary:NO] imageView] 
setObjectValue:nil];
     }
-    markedPage = [pdfView currentDestinationRotated:NULL];
+    markedPage = [pdfView currentDestination:NO];
     beforeMarkedPage.pageIndex = NSNotFound;
     [(SKThumbnailItem *)[overviewView itemAtIndexPath:[NSIndexPath 
indexPathForItem:markedPage.pageIndex inSection:0]] setMarked:YES];
     [[(NSTableCellView *)[leftSideController.thumbnailTableView viewAtColumn:1 
row:markedPage.pageIndex makeIfNecessary:NO] imageView] setObjectValue:[NSImage 
markImage]];

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



_______________________________________________
Skim-app-commit mailing list
Skim-app-commit@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to