Revision: 2610
          http://skim-app.svn.sourceforge.net/skim-app/?rev=2610&view=rev
Author:   hofman
Date:     2007-08-06 04:33:26 -0700 (Mon, 06 Aug 2007)

Log Message:
-----------
Allow copying text also in copy protected documents. Validate copy and print 
menu items.

Modified Paths:
--------------
    trunk/SKDocument.m
    trunk/SKPDFView.m

Modified: trunk/SKDocument.m
===================================================================
--- trunk/SKDocument.m  2007-08-06 10:31:23 UTC (rev 2609)
+++ trunk/SKDocument.m  2007-08-06 11:33:26 UTC (rev 2610)
@@ -623,6 +623,8 @@
         if (fileName == nil || [[NSFileManager defaultManager] 
fileExistsAtPath:fileName] == NO)
             return NO;
         return [self isDocumentEdited] || fileChangedOnDisk;
+    } else if ([anItem action] == @selector(printDocument:)) {
+        return [[self pdfDocument] allowsPrinting];
     }
     return [super validateUserInterfaceItem:anItem];
 }

Modified: trunk/SKPDFView.m
===================================================================
--- trunk/SKPDFView.m   2007-08-06 10:31:23 UTC (rev 2609)
+++ trunk/SKPDFView.m   2007-08-06 11:33:26 UTC (rev 2610)
@@ -632,7 +632,17 @@
 
 - (void)copy:(id)sender
 {
-    [super copy:sender];
+    if ([[self document] allowsCopying]) {
+        [super copy:sender];
+    } else if ([self currentSelection]) {
+        NSPasteboard *pboard = [NSPasteboard generalPasteboard];
+        NSString *string = [[self currentSelection] string];
+        NSAttributedString *attrString = [[self currentSelection] 
attributedString];
+        
+        [pboard declareTypes:[NSArray arrayWithObjects:NSStringPboardType, 
NSRTFPboardType, nil] owner:nil];
+        [pboard setString:string forType:NSStringPboardType];
+        [pboard setData:[attrString RTFFromRange:NSMakeRange(0, [attrString 
length]) documentAttributes:nil] forType:NSRTFPboardType];
+    }
     
     NSMutableArray *types = [NSMutableArray array];
     NSData *noteData = nil;
@@ -2010,13 +2020,17 @@
             [menuItem setState:[self annotationMode] == (unsigned)[menuItem 
tag] ? NSOnState : NSOffState];
         return YES;
     } else if (action == @selector(copy:)) {
-        if ([super validateMenuItem:menuItem])
+        if ([self currentSelection])
             return YES;
         if ([activeAnnotation isNoteAnnotation] && [activeAnnotation 
isMovable])
             return YES;
         if (toolMode == SKSelectToolMode && NSIsEmptyRect(selectionRect) == NO)
             return YES;
         return NO;
+    } else if (action == @selector(delete:)) {
+        return [activeAnnotation isNoteAnnotation];
+    } else if (action == @selector(printDocument:)) {
+        return [[self document] allowsPrinting];
     } else if (action == @selector(autoSelectContent:)) {
         return toolMode == SKSelectToolMode;
     } else {


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: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Skim-app-commit mailing list
Skim-app-commit@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to