Revision: 7852
http://skim-app.svn.sourceforge.net/skim-app/?rev=7852&view=rev
Author: hofman
Date: 2012-12-14 16:03:38 +0000 (Fri, 14 Dec 2012)
Log Message:
-----------
Use delegate methods to pass messages from pdfview to windowcontroller rather
than making assumptions about its API
Modified Paths:
--------------
trunk/NSDocument_SKExtensions.h
trunk/NSDocument_SKExtensions.m
trunk/SKMainDocument.h
trunk/SKMainDocument.m
trunk/SKMainWindowController_UI.m
trunk/SKPDFView.h
trunk/SKPDFView.m
Modified: trunk/NSDocument_SKExtensions.h
===================================================================
--- trunk/NSDocument_SKExtensions.h 2012-12-14 14:09:21 UTC (rev 7851)
+++ trunk/NSDocument_SKExtensions.h 2012-12-14 16:03:38 UTC (rev 7852)
@@ -54,6 +54,8 @@
- (SKInteractionMode)systemInteractionMode;
+- (void)undoableActionIsDiscardable;
+
#pragma mark Document Setup
- (void)saveRecentDocumentInfo;
Modified: trunk/NSDocument_SKExtensions.m
===================================================================
--- trunk/NSDocument_SKExtensions.m 2012-12-14 14:09:21 UTC (rev 7851)
+++ trunk/NSDocument_SKExtensions.m 2012-12-14 16:03:38 UTC (rev 7852)
@@ -57,12 +57,35 @@
NSString *SKDocumentFileURLDidChangeNotification =
@"SKDocumentFileURLDidChangeNotification";
+
+#if !defined(MAC_OS_X_VERSION_10_6) || MAC_OS_X_VERSION_MAX_ALLOWED <=
MAC_OS_X_VERSION_10_6
+@interface NSUndoManager (SKLionExtensions)
+- (void)setActionIsDiscardable:(BOOL)discardable;
+@end
+#endif
+
+
@implementation NSDocument (SKExtensions)
+ (BOOL)isPDFDocument { return NO; }
- (SKInteractionMode)systemInteractionMode { return SKNormalMode; }
+- (void)undoableActionIsDiscardableDeferred:(NSNumber *)anUndoState {
+ [self updateChangeCount:[anUndoState boolValue] ? NSChangeDone :
NSChangeUndone];
+ // this should be automatic, but Leopard does not seem to do this
+ if ([[self valueForKey:@"changeCount"] integerValue] == 0)
+ [self updateChangeCount:NSChangeCleared];
+}
+
+- (void)undoableActionIsDiscardable {
+ // This action, while undoable, shouldn't mark the document dirty
+ if ([[self undoManager]
respondsToSelector:@selector(setActionIsDiscardable:)])
+ [[self undoManager] setActionIsDiscardable:YES];
+ else
+ [self performSelector:@selector(undoableActionIsDiscardableDeferred:)
withObject:[NSNumber numberWithBool:[[self undoManager] isUndoing]]
afterDelay:0.0];
+}
+
#pragma mark Document Setup
- (void)saveRecentDocumentInfo {}
Modified: trunk/SKMainDocument.h
===================================================================
--- trunk/SKMainDocument.h 2012-12-14 14:09:21 UTC (rev 7851)
+++ trunk/SKMainDocument.h 2012-12-14 16:03:38 UTC (rev 7852)
@@ -67,8 +67,6 @@
NSInteger exportOption;
}
-- (void)undoableActionIsDiscardable;
-
- (IBAction)readNotes:(id)sender;
- (IBAction)convertNotes:(id)sender;
- (IBAction)saveArchive:(id)sender;
Modified: trunk/SKMainDocument.m
===================================================================
--- trunk/SKMainDocument.m 2012-12-14 14:09:21 UTC (rev 7851)
+++ trunk/SKMainDocument.m 2012-12-14 16:03:38 UTC (rev 7852)
@@ -123,13 +123,6 @@
};
-#if !defined(MAC_OS_X_VERSION_10_6) || MAC_OS_X_VERSION_MAX_ALLOWED <=
MAC_OS_X_VERSION_10_6
-@interface NSUndoManager (SKLionExtensions)
-- (void)setActionIsDiscardable:(BOOL)discardable;
-@end
-#endif
-
-
@interface PDFAnnotation (SKPrivateDeclarations)
- (void)setPage:(PDFPage *)newPage;
@end
@@ -290,21 +283,6 @@
[[SKBookmarkController sharedBookmarkController]
addRecentDocumentForURL:fileURL pageIndex:pageIndex snapshots:[[[self
mainWindowController] snapshots] valueForKey:SKSnapshotCurrentSetupKey]];
}
-- (void)undoableActionIsDiscardableDeferred:(NSNumber *)anUndoState {
- [self updateChangeCount:[anUndoState boolValue] ? NSChangeDone :
NSChangeUndone];
- // this should be automatic, but Leopard does not seem to do this
- if ([[self valueForKey:@"changeCount"] integerValue] == 0)
- [self updateChangeCount:NSChangeCleared];
-}
-
-- (void)undoableActionIsDiscardable {
- // This action, while undoable, shouldn't mark the document dirty
- if ([[self undoManager]
respondsToSelector:@selector(setActionIsDiscardable:)])
- [[self undoManager] setActionIsDiscardable:YES];
- else
- [self performSelector:@selector(undoableActionIsDiscardableDeferred:)
withObject:[NSNumber numberWithBool:[[self undoManager] isUndoing]]
afterDelay:0.0];
-}
-
- (SKInteractionMode)systemInteractionMode {
// only return the real interaction mode when the fullscreen window is on
the primary screen, otherwise no need to block main menu and dock
if ([[[[self mainWindowController] window] screen] isEqual:[NSScreen
primaryScreen]])
Modified: trunk/SKMainWindowController_UI.m
===================================================================
--- trunk/SKMainWindowController_UI.m 2012-12-14 14:09:21 UTC (rev 7851)
+++ trunk/SKMainWindowController_UI.m 2012-12-14 16:03:38 UTC (rev 7852)
@@ -1244,10 +1244,6 @@
[[self document] printDocument:sender];
}
-- (void)PDFView:(PDFView *)sender editAnnotation:(PDFAnnotation *)annotation {
- [self showNote:annotation];
-}
-
- (void)PDFViewDidBeginEditing:(PDFView *)sender {
if (mwcFlags.isEditingPDF == NO && mwcFlags.isEditingTable == NO)
[[self document] objectDidBeginEditing:self];
@@ -1260,6 +1256,27 @@
mwcFlags.isEditingPDF = NO;
}
+- (void)PDFView:(PDFView *)sender editAnnotation:(PDFAnnotation *)annotation {
+ [self showNote:annotation];
+}
+
+- (void)PDFView:(PDFView *)sender showSnapshotAtPageNumber:(NSInteger)pageNum
forRect:(NSRect)rect scaleFactor:(CGFloat)scaleFactor autoFits:(BOOL)autoFits {
+ [self showSnapshotAtPageNumber:pageNum forRect:rect
scaleFactor:scaleFactor autoFits:autoFits];
+}
+
+- (void)PDFView:(PDFView *)sender findFileAndLineForLocation:(NSPoint)point
inRect:(NSRect)rect pageBounds:(NSRect)bounds atPageIndex:(NSUInteger)pageIndex
{
+ if ([[self document] respondsToSelector:@selector(synchronizer)])
+ [[[self document] synchronizer] findFileAndLineForLocation:point
inRect:rect pageBounds:bounds atPageIndex:pageIndex];
+}
+
+- (void)PDFViewExitFullscreen:(PDFView *)sender {
+ [self exitFullscreen:sender];
+}
+
+- (void)PDFViewToggleContents:(PDFView *)sender {
+ [self toggleLeftSidePane:sender];
+}
+
#pragma mark NSSplitView delegate protocol
- (BOOL)splitView:(NSSplitView *)sender canCollapseSubview:(NSView *)subview {
Modified: trunk/SKPDFView.h
===================================================================
--- trunk/SKPDFView.h 2012-12-14 14:09:21 UTC (rev 7851)
+++ trunk/SKPDFView.h 2012-12-14 16:03:38 UTC (rev 7852)
@@ -185,7 +185,11 @@
#pragma mark -
@interface NSObject (SKPDFViewDelegate)
-- (void)PDFView:(PDFView *)sender editAnnotation:(PDFAnnotation *)annotation;
- (void)PDFViewDidBeginEditing:(PDFView *)sender;
- (void)PDFViewDidEndEditing:(PDFView *)sender;
+- (void)PDFView:(PDFView *)sender editAnnotation:(PDFAnnotation *)annotation;
+- (void)PDFView:(PDFView *)sender showSnapshotAtPageNumber:(NSInteger)pageNum
forRect:(NSRect)rect scaleFactor:(CGFloat)scaleFactor autoFits:(BOOL)autoFits;
+- (void)PDFView:(PDFView *)sender findFileAndLineForLocation:(NSPoint)point
inRect:(NSRect)rect pageBounds:(NSRect)bounds atPageIndex:(NSUInteger)pageIndex;
+- (void)PDFViewExitFullscreen:(PDFView *)sender;
+- (void)PDFViewToggleContents:(PDFView *)sender;
@end
Modified: trunk/SKPDFView.m
===================================================================
--- trunk/SKPDFView.m 2012-12-14 14:09:21 UTC (rev 7851)
+++ trunk/SKPDFView.m 2012-12-14 16:03:38 UTC (rev 7852)
@@ -39,8 +39,6 @@
#import "SKPDFView.h"
#import "SKNavigationWindow.h"
#import "SKImageToolTipWindow.h"
-#import "SKMainWindowController.h"
-#import "SKMainWindowController_Actions.h"
#import <SkimNotes/SkimNotes.h>
#import "PDFAnnotation_SKExtensions.h"
#import "PDFAnnotationMarkup_SKExtensions.h"
@@ -53,8 +51,7 @@
#import "NSUserDefaultsController_SKExtensions.h"
#import "NSUserDefaults_SKExtensions.h"
#import "SKReadingBar.h"
-#import "SKMainDocument.h"
-#import "SKPDFSynchronizer.h"
+#import "NSDocument_SKExtensions.h"
#import "PDFSelection_SKExtensions.h"
#import "NSBezierPath_SKExtensions.h"
#import "SKLineWell.h"
@@ -927,7 +924,8 @@
}
- (void)exitFullscreen:(id)sender {
- [[[self window] windowController] exitFullscreen:sender];
+ if ([[self delegate] respondsToSelector:@selector(PDFViewExitFullscreen:)])
+ [[self delegate] PDFViewExitFullscreen:self];
}
- (void)showColorsForThisAnnotation:(id)sender {
@@ -1027,7 +1025,8 @@
(eventChar == NSLeftArrowFunctionKey) && (modifiers == 0))
{
[self goToPreviousPage:self];
} else if ((eventChar == 'p') && (modifiers == 0)) {
- [(SKMainWindowController *)[[self window] windowController]
toggleLeftSidePane:self];
+ if ([[self delegate]
respondsToSelector:@selector(PDFViewToggleContents:)])
+ [[self delegate] PDFViewToggleContents:self];
} else if ((eventChar == 'a') && (modifiers == 0)) {
[self toggleAutoActualSize:self];
} else if ((eventChar == 'b') && (modifiers == 0)) {
@@ -2294,9 +2293,8 @@
rect = [self convertRect:rect toPage:page];
}
- SKMainWindowController *controller = [[self window] windowController];
-
- [controller showSnapshotAtPageNumber:[page pageIndex] forRect:rect
scaleFactor:[self scaleFactor] autoFits:autoFits];
+ if ([[self delegate]
respondsToSelector:@selector(PDFView:showSnapshotAtPageNumber:forRect:scaleFactor:autoFits:)])
+ [[self delegate] PDFView:self showSnapshotAtPageNumber:[page
pageIndex] forRect:rect scaleFactor:[self scaleFactor] autoFits:autoFits];
}
#pragma mark Notification handling
@@ -3883,9 +3881,8 @@
}
- SKMainWindowController *controller = [[self window] windowController];
-
- [controller showSnapshotAtPageNumber:[page pageIndex] forRect:[self
convertRect:rect toPage:page] scaleFactor:[self scaleFactor] * factor
autoFits:autoFits];
+ if ([[self delegate]
respondsToSelector:@selector(PDFView:showSnapshotAtPageNumber:forRect:scaleFactor:autoFits:)])
+ [[self delegate] PDFView:self showSnapshotAtPageNumber:[page
pageIndex] forRect:[self convertRect:rect toPage:page] scaleFactor:[self
scaleFactor] * factor autoFits:autoFits];
}
- (void)doMagnifyWithEvent:(NSEvent *)theEvent {
@@ -4029,9 +4026,7 @@
- (void)doPdfsyncWithEvent:(NSEvent *)theEvent {
[self doNothingWithEvent:theEvent];
- SKMainDocument *document = (SKMainDocument *)[[[self window]
windowController] document];
-
- if ([document respondsToSelector:@selector(synchronizer)]) {
+ if ([[self delegate]
respondsToSelector:@selector(PDFView:findFileAndLineForLocation:inRect:pageBounds:atPageIndex:)])
{
NSPoint mouseLoc = [theEvent locationInView:self];
PDFPage *page = [self pageForPoint:mouseLoc nearest:YES];
@@ -4040,7 +4035,7 @@
PDFSelection *sel = [page selectionForLineAtPoint:location];
NSRect rect = [sel hasCharacters] ? [sel boundsForPage:page] :
NSMakeRect(location.x - 20.0, location.y - 5.0, 40.0, 10.0);
- [[document synchronizer] findFileAndLineForLocation:location
inRect:rect pageBounds:[page boundsForBox:kPDFDisplayBoxMediaBox]
atPageIndex:pageIndex];
+ [[self delegate] PDFView:self findFileAndLineForLocation:location
inRect:rect pageBounds:[page boundsForBox:kPDFDisplayBoxMediaBox]
atPageIndex:pageIndex];
}
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit