Revision: 4735
          http://skim-app.svn.sourceforge.net/skim-app/?rev=4735&view=rev
Author:   hofman
Date:     2008-10-04 11:14:26 +0000 (Sat, 04 Oct 2008)

Log Message:
-----------
Go back to current page after rotating all pages.

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

Modified: trunk/SKMainWindowController.m
===================================================================
--- trunk/SKMainWindowController.m      2008-10-03 16:59:40 UTC (rev 4734)
+++ trunk/SKMainWindowController.m      2008-10-04 11:14:26 UTC (rev 4735)
@@ -1673,51 +1673,42 @@
             object:[pdfView document] userInfo:[NSDictionary 
dictionaryWithObjectsAndKeys:SKPDFPageActionRotate, SKPDFPageActionKey, page, 
SKPDFPagePageKey, nil]];
 }
 
-- (IBAction)rotateRight:(id)sender {
-    [self rotatePageAtIndex:[[pdfView currentPage] pageIndex] by:90];
-}
-
-- (IBAction)rotateLeft:(id)sender {
-    [self rotatePageAtIndex:[[pdfView currentPage] pageIndex] by:-90];
-}
-
-- (IBAction)rotateAllRight:(id)sender {
+- (void)rotateAllBy:(int)rotation {
     NSUndoManager *undoManager = [[self document] undoManager];
-    [[undoManager prepareWithInvocationTarget:self] rotateAllLeft:nil];
+    [[undoManager prepareWithInvocationTarget:self] rotateAllBy:-rotation];
     [undoManager setActionName:NSLocalizedString(@"Rotate", @"Undo action 
name")];
     [[self document] undoableActionDoesntDirtyDocument];
     
+    PDFPage *page = [pdfView currentPage];
     int i, count = [[pdfView document] pageCount];
-    for (i = 0; i < count; i++) {
-        [[[pdfView document] pageAtIndex:i] setRotation:[[[pdfView document] 
pageAtIndex:i] rotation] + 90];
-    }
+    for (i = 0; i < count; i++)
+        [[[pdfView document] pageAtIndex:i] setRotation:[[[pdfView document] 
pageAtIndex:i] rotation] + rotation];
+    [pdfView goToPage:page];
     
     [[NSNotificationCenter defaultCenter] 
postNotificationName:SKPDFPageBoundsDidChangeNotification 
             object:[pdfView document] userInfo:[NSDictionary 
dictionaryWithObjectsAndKeys:SKPDFPageActionRotate, SKPDFPageActionKey, nil]];
 }
 
-- (IBAction)rotateAllLeftRight:(id)sender {
-    if ([sender selectedSegment] == 0)
-        [self rotateLeft:sender];
-    else
-        [self rotateAllRight:sender];
+- (IBAction)rotateRight:(id)sender {
+    [self rotatePageAtIndex:[[pdfView currentPage] pageIndex] by:90];
 }
 
+- (IBAction)rotateLeft:(id)sender {
+    [self rotatePageAtIndex:[[pdfView currentPage] pageIndex] by:-90];
+}
+
+- (IBAction)rotateAllRight:(id)sender {
+    [self rotateAllBy:90];
+}
+
 - (IBAction)rotateAllLeft:(id)sender {
-    NSUndoManager *undoManager = [[self document] undoManager];
-    [[undoManager prepareWithInvocationTarget:self] rotateAllRight:nil];
-    [undoManager setActionName:NSLocalizedString(@"Rotate", @"Undo action 
name")];
-    [[self document] undoableActionDoesntDirtyDocument];
-    
-    int i, count = [[pdfView document] pageCount];
-    for (i = 0; i < count; i++) {
-        [[[pdfView document] pageAtIndex:i] setRotation:[[[pdfView document] 
pageAtIndex:i] rotation] - 90];
-    }
-    
-    [[NSNotificationCenter defaultCenter] 
postNotificationName:SKPDFPageBoundsDidChangeNotification 
-            object:[pdfView document] userInfo:[NSDictionary 
dictionaryWithObjectsAndKeys:SKPDFPageActionRotate, SKPDFPageActionKey, nil]];
+    [self rotateAllBy:-90];
 }
 
+- (IBAction)rotateAllLeftRight:(id)sender {
+    [self rotateAllBy:[sender selectedSegment] == 0 ? -90 : 90];
+}
+
 - (void)cropPageAtIndex:(unsigned int)anIndex toRect:(NSRect)rect {
     NSRect oldRect = [[[pdfView document] pageAtIndex:anIndex] 
boundsForBox:kPDFDisplayBoxCropBox];
     NSUndoManager *undoManager = [[self document] undoManager];


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

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to