Revision: 3591
          http://skim-app.svn.sourceforge.net/skim-app/?rev=3591&view=rev
Author:   hofman
Date:     2008-04-02 04:19:14 -0700 (Wed, 02 Apr 2008)

Log Message:
-----------
Leave custom scripting keys to the note subclasses.

Modified Paths:
--------------
    trunk/PDFAnnotation_SKExtensions.h
    trunk/PDFAnnotation_SKExtensions.m
    trunk/SKPDFAnnotationCircle.m
    trunk/SKPDFAnnotationFreeText.m
    trunk/SKPDFAnnotationLine.m
    trunk/SKPDFAnnotationMarkup.m
    trunk/SKPDFAnnotationNote.m
    trunk/SKPDFAnnotationSquare.m

Modified: trunk/PDFAnnotation_SKExtensions.h
===================================================================
--- trunk/PDFAnnotation_SKExtensions.h  2008-04-02 00:16:07 UTC (rev 3590)
+++ trunk/PDFAnnotation_SKExtensions.h  2008-04-02 11:19:14 UTC (rev 3591)
@@ -121,6 +121,7 @@
 
 - (NSSet *)keysForValuesToObserveForUndo;
 
++ (NSSet *)customScriptingKeys;
 - (NSScriptObjectSpecifier *)objectSpecifier;
 - (int)scriptingNoteType;
 - (int)scriptingIconType;

Modified: trunk/PDFAnnotation_SKExtensions.m
===================================================================
--- trunk/PDFAnnotation_SKExtensions.m  2008-04-02 00:16:07 UTC (rev 3590)
+++ trunk/PDFAnnotation_SKExtensions.m  2008-04-02 11:19:14 UTC (rev 3591)
@@ -395,6 +395,30 @@
         return nil;
 }
 
+// overridden by subclasses to add or remove custom scripting keys relevant 
for the class, subclasses should call super first
++ (NSSet *)customScriptingKeys {
+    static NSSet *customScriptingKeys = nil;
+    if (customScriptingKeys == nil)
+        customScriptingKeys = [[NSSet alloc] 
initWithObjects:SKPDFAnnotationLineWidthKey, 
SKPDFAnnotationScriptingBorderStyleKey, SKPDFAnnotationDashPatternKey, nil];
+    return customScriptingKeys;
+}
+
+- (NSDictionary *)scriptingProperties {
+    // remove all custom properties that are not valid for this class
+    NSMutableDictionary *properties = [[[super scriptingProperties] 
mutableCopy] autorelease];
+    NSMutableSet *customKeys = [[NSMutableSet alloc] init];
+    [customKeys unionSet:[SKPDFAnnotationCircle customScriptingKeys]];
+    [customKeys unionSet:[SKPDFAnnotationSquare customScriptingKeys]];
+    [customKeys unionSet:[SKPDFAnnotationFreeText customScriptingKeys]];
+    [customKeys unionSet:[SKPDFAnnotationNote customScriptingKeys]];
+    [customKeys unionSet:[SKPDFAnnotationLine customScriptingKeys]];
+    [customKeys unionSet:[SKPDFAnnotationMarkup customScriptingKeys]];
+    [customKeys minusSet:[[self class] customScriptingKeys]];
+    [properties removeObjectsForKeys:[customKeys allObjects]];
+    [customKeys release];
+    return properties;
+}
+
 - (int)scriptingNoteType {
     if ([[self type] isEqualToString:SKFreeTextString])
         return SKScriptingTextNote;

Modified: trunk/SKPDFAnnotationCircle.m
===================================================================
--- trunk/SKPDFAnnotationCircle.m       2008-04-02 00:16:07 UTC (rev 3590)
+++ trunk/SKPDFAnnotationCircle.m       2008-04-02 11:19:14 UTC (rev 3591)
@@ -38,10 +38,6 @@
 
 #import "SKPDFAnnotationCircle.h"
 #import "PDFAnnotation_SKExtensions.h"
-#import "SKPDFAnnotationLine.h"
-#import "SKPDFAnnotationMarkup.h"
-#import "SKPDFAnnotationFreeText.h"
-#import "SKPDFAnnotationNote.h"
 #import "PDFBorder_SKExtensions.h"
 #import "SKStringConstants.h"
 #import "NSUserDefaultsController_SKExtensions.h"
@@ -103,10 +99,15 @@
 
 #pragma mark Scripting support
 
-- (NSDictionary *)scriptingProperties {
-    NSMutableDictionary *properties = [[[super scriptingProperties] 
mutableCopy] autorelease];
-    [properties removeObjectsForKeys:[NSArray 
arrayWithObjects:SKPDFAnnotationRichTextKey, SKPDFAnnotationFontNameKey, 
SKPDFAnnotationFontSizeKey, SKPDFAnnotationScriptingIconTypeKey, 
SKPDFAnnotationStartPointAsQDPointKey, SKPDFAnnotationEndPointAsQDPointKey, 
SKPDFAnnotationScriptingStartLineStyleKey, 
SKPDFAnnotationScriptingEndLineStyleKey, SKPDFAnnotationSelectionSpecifierKey, 
nil]];
-    return properties;
++ (NSSet *)customScriptingKeys {
+    static NSSet *customCircleScriptingKeys = nil;
+    if (customCircleScriptingKeys == nil) {
+        NSMutableSet *customKeys = [[super customScriptingKeys] mutableCopy];
+        [customKeys addObject:SKPDFAnnotationInteriorColorKey];
+        customCircleScriptingKeys = [customKeys copy];
+        [customKeys release];
+    }
+    return customCircleScriptingKeys;
 }
 
 @end

Modified: trunk/SKPDFAnnotationFreeText.m
===================================================================
--- trunk/SKPDFAnnotationFreeText.m     2008-04-02 00:16:07 UTC (rev 3590)
+++ trunk/SKPDFAnnotationFreeText.m     2008-04-02 11:19:14 UTC (rev 3591)
@@ -39,10 +39,6 @@
 #import "SKPDFAnnotationFreeText.h"
 #import "PDFAnnotation_SKExtensions.h"
 #import "PDFBorder_SKExtensions.h"
-#import "SKPDFAnnotationCircle.h"
-#import "SKPDFAnnotationLine.h"
-#import "SKPDFAnnotationMarkup.h"
-#import "SKPDFAnnotationNote.h"
 #import "SKStringConstants.h"
 #import "NSUserDefaultsController_SKExtensions.h"
 
@@ -121,10 +117,16 @@
 
 #pragma mark Scripting support
 
-- (NSDictionary *)scriptingProperties {
-    NSMutableDictionary *properties = [[[super scriptingProperties] 
mutableCopy] autorelease];
-    [properties removeObjectsForKeys:[NSArray 
arrayWithObjects:SKPDFAnnotationRichTextKey, 
SKPDFAnnotationScriptingIconTypeKey, SKPDFAnnotationStartPointAsQDPointKey, 
SKPDFAnnotationEndPointAsQDPointKey, SKPDFAnnotationScriptingStartLineStyleKey, 
SKPDFAnnotationScriptingEndLineStyleKey, SKPDFAnnotationSelectionSpecifierKey, 
nil]];
-    return properties;
++ (NSSet *)customScriptingKeys {
+    static NSSet *customFreeTextScriptingKeys = nil;
+    if (customFreeTextScriptingKeys == nil) {
+        NSMutableSet *customKeys = [[super customScriptingKeys] mutableCopy];
+        [customKeys addObject:SKPDFAnnotationFontNameKey];
+        [customKeys addObject:SKPDFAnnotationFontSizeKey];
+        customFreeTextScriptingKeys = [customKeys copy];
+        [customKeys release];
+    }
+    return customFreeTextScriptingKeys;
 }
 
 - (id)textContents {

Modified: trunk/SKPDFAnnotationLine.m
===================================================================
--- trunk/SKPDFAnnotationLine.m 2008-04-02 00:16:07 UTC (rev 3590)
+++ trunk/SKPDFAnnotationLine.m 2008-04-02 11:19:14 UTC (rev 3591)
@@ -38,10 +38,6 @@
 
 #import "SKPDFAnnotationLine.h"
 #import "PDFAnnotation_SKExtensions.h"
-#import "SKPDFAnnotationCircle.h"
-#import "SKPDFAnnotationMarkup.h"
-#import "SKPDFAnnotationFreeText.h"
-#import "SKPDFAnnotationNote.h"
 #import "PDFBorder_SKExtensions.h"
 #import "SKStringConstants.h"
 #import "NSUserDefaultsController_SKExtensions.h"
@@ -235,10 +231,18 @@
 
 #pragma mark Scripting support
 
-- (NSDictionary *)scriptingProperties {
-    NSMutableDictionary *properties = [[[super scriptingProperties] 
mutableCopy] autorelease];
-    [properties removeObjectsForKeys:[NSArray 
arrayWithObjects:SKPDFAnnotationRichTextKey, SKPDFAnnotationFontNameKey, 
SKPDFAnnotationFontSizeKey, SKPDFAnnotationScriptingIconTypeKey, 
SKPDFAnnotationLineWidthKey, SKPDFAnnotationScriptingBorderStyleKey, 
SKPDFAnnotationDashPatternKey, SKPDFAnnotationSelectionSpecifierKey, nil]];
-    return properties;
++ (NSSet *)customScriptingKeys {
+    static NSSet *customLineScriptingKeys = nil;
+    if (customLineScriptingKeys == nil) {
+        NSMutableSet *customKeys = [[super customScriptingKeys] mutableCopy];
+        [customKeys addObject:SKPDFAnnotationStartPointAsQDPointKey];
+        [customKeys addObject:SKPDFAnnotationEndPointAsQDPointKey];
+        [customKeys addObject:SKPDFAnnotationScriptingStartLineStyleKey];
+        [customKeys addObject:SKPDFAnnotationScriptingEndLineStyleKey];
+        customLineScriptingKeys = [customKeys copy];
+        [customKeys release];
+    }
+    return customLineScriptingKeys;
 }
 
 - (void)setStartPointAsQDPoint:(NSData *)inQDPointAsData {

Modified: trunk/SKPDFAnnotationMarkup.m
===================================================================
--- trunk/SKPDFAnnotationMarkup.m       2008-04-02 00:16:07 UTC (rev 3590)
+++ trunk/SKPDFAnnotationMarkup.m       2008-04-02 11:19:14 UTC (rev 3591)
@@ -38,10 +38,6 @@
 
 #import "SKPDFAnnotationMarkup.h"
 #import "PDFAnnotation_SKExtensions.h"
-#import "SKPDFAnnotationCircle.h"
-#import "SKPDFAnnotationLine.h"
-#import "SKPDFAnnotationFreeText.h"
-#import "SKPDFAnnotationNote.h"
 #import "PDFBorder_SKExtensions.h"
 #import "SKStringConstants.h"
 #import "PDFSelection_SKExtensions.h"
@@ -394,10 +390,18 @@
 
 #pragma mark Scripting support
 
-- (NSDictionary *)scriptingProperties {
-    NSMutableDictionary *properties = [[[super scriptingProperties] 
mutableCopy] autorelease];
-    [properties removeObjectsForKeys:[NSArray 
arrayWithObjects:SKPDFAnnotationRichTextKey, SKPDFAnnotationFontNameKey, 
SKPDFAnnotationFontSizeKey, SKPDFAnnotationScriptingIconTypeKey, 
SKPDFAnnotationLineWidthKey, SKPDFAnnotationScriptingBorderStyleKey, 
SKPDFAnnotationDashPatternKey, SKPDFAnnotationStartPointAsQDPointKey, 
SKPDFAnnotationEndPointAsQDPointKey, SKPDFAnnotationScriptingStartLineStyleKey, 
SKPDFAnnotationScriptingEndLineStyleKey, nil]];
-    return properties;
++ (NSSet *)customScriptingKeys {
+    static NSSet *customMarkupScriptingKeys = nil;
+    if (customMarkupScriptingKeys == nil) {
+        NSMutableSet *customKeys = [[super customScriptingKeys] mutableCopy];
+        [customKeys addObject:SKPDFAnnotationSelectionSpecifierKey];
+        [customKeys removeObject:SKPDFAnnotationLineWidthKey];
+        [customKeys removeObject:SKPDFAnnotationScriptingBorderStyleKey];
+        [customKeys removeObject:SKPDFAnnotationDashPatternKey];
+        customMarkupScriptingKeys = [customKeys copy];
+        [customKeys release];
+    }
+    return customMarkupScriptingKeys;
 }
 
 - (id)selectionSpecifier {

Modified: trunk/SKPDFAnnotationNote.m
===================================================================
--- trunk/SKPDFAnnotationNote.m 2008-04-02 00:16:07 UTC (rev 3590)
+++ trunk/SKPDFAnnotationNote.m 2008-04-02 11:19:14 UTC (rev 3591)
@@ -38,10 +38,6 @@
 
 #import "SKPDFAnnotationNote.h"
 #import "PDFAnnotation_SKExtensions.h"
-#import "SKPDFAnnotationCircle.h"
-#import "SKPDFAnnotationLine.h"
-#import "SKPDFAnnotationMarkup.h"
-#import "SKPDFAnnotationFreeText.h"
 #import "PDFBorder_SKExtensions.h"
 #import "SKStringConstants.h"
 #import "NSUserDefaultsController_SKExtensions.h"
@@ -261,10 +257,19 @@
 
 #pragma mark Scripting support
 
-- (NSDictionary *)scriptingProperties {
-    NSMutableDictionary *properties = [[[super scriptingProperties] 
mutableCopy] autorelease];
-    [properties removeObjectsForKeys:[NSArray 
arrayWithObjects:SKPDFAnnotationFontNameKey, SKPDFAnnotationFontSizeKey, 
SKPDFAnnotationLineWidthKey, SKPDFAnnotationScriptingBorderStyleKey, 
SKPDFAnnotationDashPatternKey, SKPDFAnnotationStartPointAsQDPointKey, 
SKPDFAnnotationEndPointAsQDPointKey, SKPDFAnnotationScriptingStartLineStyleKey, 
SKPDFAnnotationScriptingEndLineStyleKey, SKPDFAnnotationSelectionSpecifierKey, 
nil]];
-    return properties;
++ (NSSet *)customScriptingKeys {
+    static NSSet *customNoteScriptingKeys = nil;
+    if (customNoteScriptingKeys == nil) {
+        NSMutableSet *customKeys = [[super customScriptingKeys] mutableCopy];
+        [customKeys addObject:SKPDFAnnotationScriptingIconTypeKey];
+        [customKeys addObject:SKPDFAnnotationRichTextKey];
+        [customKeys removeObject:SKPDFAnnotationLineWidthKey];
+        [customKeys removeObject:SKPDFAnnotationScriptingBorderStyleKey];
+        [customKeys removeObject:SKPDFAnnotationDashPatternKey];
+        customNoteScriptingKeys = [customKeys copy];
+        [customKeys release];
+    }
+    return customNoteScriptingKeys;
 }
 
 - (int)scriptingIconType {

Modified: trunk/SKPDFAnnotationSquare.m
===================================================================
--- trunk/SKPDFAnnotationSquare.m       2008-04-02 00:16:07 UTC (rev 3590)
+++ trunk/SKPDFAnnotationSquare.m       2008-04-02 11:19:14 UTC (rev 3591)
@@ -39,10 +39,6 @@
 #import "SKPDFAnnotationSquare.h"
 #import "PDFAnnotation_SKExtensions.h"
 #import "SKPDFAnnotationCircle.h"
-#import "SKPDFAnnotationLine.h"
-#import "SKPDFAnnotationMarkup.h"
-#import "SKPDFAnnotationFreeText.h"
-#import "SKPDFAnnotationNote.h"
 #import "PDFBorder_SKExtensions.h"
 #import "SKStringConstants.h"
 #import "NSUserDefaultsController_SKExtensions.h"
@@ -103,10 +99,15 @@
 
 #pragma mark Scripting support
 
-- (NSDictionary *)scriptingProperties {
-    NSMutableDictionary *properties = [[[super scriptingProperties] 
mutableCopy] autorelease];
-    [properties removeObjectsForKeys:[NSArray 
arrayWithObjects:SKPDFAnnotationRichTextKey, SKPDFAnnotationFontNameKey, 
SKPDFAnnotationFontSizeKey, SKPDFAnnotationScriptingIconTypeKey, 
SKPDFAnnotationStartPointAsQDPointKey, SKPDFAnnotationEndPointAsQDPointKey, 
SKPDFAnnotationScriptingStartLineStyleKey, 
SKPDFAnnotationScriptingEndLineStyleKey, SKPDFAnnotationSelectionSpecifierKey, 
nil]];
-    return properties;
++ (NSSet *)customScriptingKeys {
+    static NSSet *customSquareScriptingKeys = nil;
+    if (customSquareScriptingKeys == nil) {
+        NSMutableSet *customKeys = [[super customScriptingKeys] mutableCopy];
+        [customKeys addObject:SKPDFAnnotationInteriorColorKey];
+        customSquareScriptingKeys = [customKeys copy];
+        [customKeys release];
+    }
+    return customSquareScriptingKeys;
 }
 
 @end


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

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Skim-app-commit mailing list
Skim-app-commit@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to