Revision: 9715
          http://sourceforge.net/p/skim-app/code/9715
Author:   hofman
Date:     2018-03-06 15:43:29 +0000 (Tue, 06 Mar 2018)
Log Message:
-----------
Let pdf document think it allows commenting, so we can add notes to the 
document.

Modified Paths:
--------------
    trunk/PDFDocument_SKExtensions.h
    trunk/PDFDocument_SKExtensions.m
    trunk/SKInfoWindowController.m
    trunk/SKPDFDocument.m
    trunk/SkimNotes/skimpdf.m

Modified: trunk/PDFDocument_SKExtensions.h
===================================================================
--- trunk/PDFDocument_SKExtensions.h    2018-03-06 15:27:08 UTC (rev 9714)
+++ trunk/PDFDocument_SKExtensions.h    2018-03-06 15:43:29 UTC (rev 9715)
@@ -46,4 +46,5 @@
 - (NSDictionary *)initialSettings;
 - (BOOL)hasRightToLeftLanguage;
 - (BOOL)allowsNotes;
+- (BOOL)realAllowsCommenting;
 @end

Modified: trunk/PDFDocument_SKExtensions.m
===================================================================
--- trunk/PDFDocument_SKExtensions.m    2018-03-06 15:27:08 UTC (rev 9714)
+++ trunk/PDFDocument_SKExtensions.m    2018-03-06 15:43:29 UTC (rev 9715)
@@ -208,9 +208,13 @@
 
 - (BOOL)allowsNotes {
     return [self isLocked] == NO &&
-            ([self respondsToSelector:@selector(allowsCommenting)] == NO || 
[self allowsCommenting]);
+    ([self respondsToSelector:@selector(allowsCommenting)] == NO || [self 
allowsCommenting]);
 }
 
+- (BOOL)realAllowsCommenting {
+    return [self respondsToSelector:@selector(allowsCommenting)] == NO || 
[self allowsCommenting];
+}
+
 #pragma clang diagnostic pop
 
 @end

Modified: trunk/SKInfoWindowController.m
===================================================================
--- trunk/SKInfoWindowController.m      2018-03-06 15:27:08 UTC (rev 9714)
+++ trunk/SKInfoWindowController.m      2018-03-06 15:43:29 UTC (rev 9715)
@@ -293,10 +293,7 @@
         [dictionary setValue:[NSNumber numberWithBool:[pdfDoc isEncrypted]] 
forKey:SKInfoEncryptedKey];
         [dictionary setValue:[NSNumber numberWithBool:[pdfDoc allowsPrinting]] 
forKey:SKInfoAllowsPrintingKey];
         [dictionary setValue:[NSNumber numberWithBool:[pdfDoc allowsCopying]] 
forKey:SKInfoAllowsCopyingKey];
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wpartial-availability"
-        [dictionary setValue:[NSNumber numberWithBool:[pdfDoc 
respondsToSelector:@selector(allowsCommenting)] == NO || [pdfDoc 
allowsCommenting]] forKey:SKInfoAllowsCommentingKey];
-#pragma clang diagnostic pop
+        [dictionary setValue:[NSNumber numberWithBool:[pdfDoc 
realAllowsCommenting]] forKey:SKInfoAllowsCommentingKey];
     }
     [dictionary setValue:[[[doc fileURL] path] lastPathComponent] 
forKey:SKInfoFileNameKey];
     [dictionary setValue:SKFileSizeStringForFileURL([doc fileURL], 
&physicalSize, &logicalSize) forKey:SKInfoFileSizeKey];

Modified: trunk/SKPDFDocument.m
===================================================================
--- trunk/SKPDFDocument.m       2018-03-06 15:27:08 UTC (rev 9714)
+++ trunk/SKPDFDocument.m       2018-03-06 15:43:29 UTC (rev 9715)
@@ -41,6 +41,14 @@
 #import "PDFDocument_SKExtensions.h"
 
 
+#if SDK_BEFORE(10_13)
+
+@interface PDFDocument (SKHighSierraDeclarations)
+- (BOOL)allowsCommenting;
+@end
+
+#endif
+
 @implementation SKPDFDocument
 
 - (Class)pageClass {
@@ -93,6 +101,13 @@
 // fool the document into thinking it always allows annotations
 - (BOOL)allowsCommenting { return YES; }
 
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wpartial-availability"
+
+- (BOOL)realAllowsCommenting { return [PDFDocument 
instancesRespondToSelector:@selector(allowsCommenting)] == NO || [super 
allowsCommenting]; }
+
+#pragma clang diagnostic pop
+
 - (id <SKPDFDocumentDelegate>)delegate {
     return (id <SKPDFDocumentDelegate>)[super delegate];
 }

Modified: trunk/SkimNotes/skimpdf.m
===================================================================
--- trunk/SkimNotes/skimpdf.m   2018-03-06 15:27:08 UTC (rev 9714)
+++ trunk/SkimNotes/skimpdf.m   2018-03-06 15:43:29 UTC (rev 9715)
@@ -50,6 +50,13 @@
 @end
 #endif
 
+@interface PDFDocument (SKNOverride)
+@end
+
+@implementation PDFDocument (SKNOverride)
+- (BOOL)allowsCommenting { return YES; }
+@end
+
 static char *usageStr = "Usage:\n"
                         " skimpdf embed IN_PDF_FILE [OUT_PDF_FILE]\n"
                         " skimpdf unembed IN_PDF_FILE [OUT_PDF_FILE]\n"

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


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Skim-app-commit mailing list
Skim-app-commit@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to