Revision: 14619
          http://sourceforge.net/p/skim-app/code/14619
Author:   hofman
Date:     2024-10-31 15:14:12 +0000 (Thu, 31 Oct 2024)
Log Message:
-----------
Change underlying name for icon type for undo, as it can also contain the stamp 
name. Make (extended) icon type dependent keys. Don't change icon type (and 
name) when setting drawsImage flag.

Modified Paths:
--------------
    trunk/PDFAnnotationStamp_SKExtensions.m
    trunk/PDFAnnotationText_SKExtensions.m
    trunk/SKNPDFAnnotationNote_SKExtensions.h
    trunk/SKNPDFAnnotationNote_SKExtensions.m

Modified: trunk/PDFAnnotationStamp_SKExtensions.m
===================================================================
--- trunk/PDFAnnotationStamp_SKExtensions.m     2024-10-31 15:03:53 UTC (rev 
14618)
+++ trunk/PDFAnnotationStamp_SKExtensions.m     2024-10-31 15:14:12 UTC (rev 
14619)
@@ -58,15 +58,4 @@
 
 - (BOOL)isConvertibleAnnotation { return YES; }
 
-- (NSSet *)keysForValuesToObserveForUndo {
-    static NSSet *textKeys = nil;
-    if (textKeys == nil) {
-        NSMutableSet *mutableKeys = [[super keysForValuesToObserveForUndo] 
mutableCopy];
-        [mutableKeys addObject:SKNPDFAnnotationIconTypeKey];
-        [mutableKeys removeObject:SKNPDFAnnotationBorderKey];
-        textKeys = [mutableKeys copy];
-    }
-    return textKeys;
-}
-
 @end

Modified: trunk/PDFAnnotationText_SKExtensions.m
===================================================================
--- trunk/PDFAnnotationText_SKExtensions.m      2024-10-31 15:03:53 UTC (rev 
14618)
+++ trunk/PDFAnnotationText_SKExtensions.m      2024-10-31 15:14:12 UTC (rev 
14619)
@@ -59,29 +59,4 @@
 
 - (BOOL)isConvertibleAnnotation { return YES; }
 
-- (NSSet *)keysForValuesToObserveForUndo {
-    static NSSet *textKeys = nil;
-    if (textKeys == nil) {
-        NSMutableSet *mutableKeys = [[super keysForValuesToObserveForUndo] 
mutableCopy];
-        [mutableKeys addObject:SKNPDFAnnotationIconTypeKey];
-        [mutableKeys removeObject:SKNPDFAnnotationBorderKey];
-        textKeys = [mutableKeys copy];
-    }
-    return textKeys;
-}
-
-#pragma mark Scripting support
-
-+ (NSSet *)customScriptingKeys {
-    static NSSet *customTextScriptingKeys = nil;
-    if (customTextScriptingKeys == nil) {
-        NSMutableSet *customKeys = [[super customScriptingKeys] mutableCopy];
-        [customKeys removeObject:SKNPDFAnnotationLineWidthKey];
-        [customKeys removeObject:SKNPDFAnnotationBorderStyleKey];
-        [customKeys removeObject:SKNPDFAnnotationDashPatternKey];
-        customTextScriptingKeys = [customKeys copy];
-    }
-    return customTextScriptingKeys;
-}
-
 @end

Modified: trunk/SKNPDFAnnotationNote_SKExtensions.h
===================================================================
--- trunk/SKNPDFAnnotationNote_SKExtensions.h   2024-10-31 15:03:53 UTC (rev 
14618)
+++ trunk/SKNPDFAnnotationNote_SKExtensions.h   2024-10-31 15:14:12 UTC (rev 
14619)
@@ -51,6 +51,7 @@
 };
 
 @interface SKNPDFAnnotationNote (SKExtensions)
+@property (nonatomic, nullable, strong) NSString *name;
 @property (nonatomic, nullable, readonly) id richText;
 @property (nonatomic) PDFTextAnnotationIconType extendedIconType;
 @property (nonatomic) PDFTextAnnotationIconType scriptingIconType;

Modified: trunk/SKNPDFAnnotationNote_SKExtensions.m
===================================================================
--- trunk/SKNPDFAnnotationNote_SKExtensions.m   2024-10-31 15:03:53 UTC (rev 
14618)
+++ trunk/SKNPDFAnnotationNote_SKExtensions.m   2024-10-31 15:14:12 UTC (rev 
14619)
@@ -62,9 +62,13 @@
 @implementation SKNPDFAnnotationNote (SKExtensions)
 
 + (NSSet *)keyPathsForValuesAffectingExtendedIconType {
-    return [NSSet setWithObjects:SKNPDFAnnotationIconTypeKey, 
SKNPDFAnnotationDrawsImageKey, nil];
+    return [NSSet setWithObjects:SKNPDFAnnotationNameKey, 
SKNPDFAnnotationDrawsImageKey, nil];
 }
 
++ (NSSet *)keyPathsForValuesAffectingName {
+    return [NSSet setWithObjects:SKNPDFAnnotationIconTypeKey, nil];
+}
+
 - (void)setDefaultSkimNoteProperties {
     [self setColor:[[NSUserDefaults standardUserDefaults] 
colorForKey:SKAnchoredNoteColorKey]];
     PDFTextAnnotationIconType iconType = [[NSUserDefaults 
standardUserDefaults] integerForKey:SKAnchoredNoteIconTypeKey];
@@ -95,8 +99,6 @@
     if (iconType == kSKNPDFTextAnnotationIconImage) {
         if ([self drawsImage] == NO)
             [self setDrawsImage:YES];
-        if ([self iconType] != kPDFTextAnnotationIconNote)
-            [self setIconType:kPDFTextAnnotationIconNote];
     } else {
         if ([self drawsImage])
             [self setDrawsImage:NO];
@@ -111,6 +113,14 @@
     }
 }
 
+- (NSString *)name {
+    return [self valueForAnnotationKey:PDFAnnotationKeyIconName];
+}
+
+- (void)setName:(NSString *)name {
+    [self setValue:name forKey:PDFAnnotationKeyIconName];
+}
+
 // override these Leopard methods to avoid showing the standard tool tips over 
our own
 - (NSString *)toolTip { return @""; }
 
@@ -130,6 +140,8 @@
     static NSSet *noteKeys = nil;
     if (noteKeys == nil) {
         NSMutableSet *mutableKeys = [[super keysForValuesToObserveForUndo] 
mutableCopy];
+        [mutableKeys removeObject:SKNPDFAnnotationBorderKey];
+        [mutableKeys addObject:SKNPDFAnnotationNameKey];
         [mutableKeys addObject:SKNPDFAnnotationTextKey];
         [mutableKeys addObject:SKNPDFAnnotationImageKey];
         [mutableKeys addObject:SKNPDFAnnotationDrawsImageKey];
@@ -147,8 +159,11 @@
 #pragma clang diagnostic ignored "-Wdeprecated-declarations"
         NSMutableSet *customKeys = [[super customScriptingKeys] mutableCopy];
 #pragma clang diagnostic pop
+        [customKeys removeObject:SKNPDFAnnotationLineWidthKey];
+        [customKeys removeObject:SKNPDFAnnotationBorderStyleKey];
+        [customKeys removeObject:SKNPDFAnnotationDashPatternKey];
+        [customKeys addObject:SKPDFAnnotationScriptingIconTypeKey];
         [customKeys addObject:SKPDFAnnotationRichTextKey];
-        [customKeys addObject:SKPDFAnnotationScriptingIconTypeKey];
         [customKeys addObject:SKPDFAnnotationScriptingImageDataKey];
         customNoteScriptingKeys = [customKeys copy];
     }

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



_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to