Revision: 14393
          http://sourceforge.net/p/skim-app/code/14393
Author:   hofman
Date:     2024-07-23 16:15:40 +0000 (Tue, 23 Jul 2024)
Log Message:
-----------
imply new note type from selection or path list in properties

Modified Paths:
--------------
    trunk/PDFPage_SKExtensions.m

Modified: trunk/PDFPage_SKExtensions.m
===================================================================
--- trunk/PDFPage_SKExtensions.m        2024-07-22 16:02:40 UTC (rev 14392)
+++ trunk/PDFPage_SKExtensions.m        2024-07-23 16:15:40 UTC (rev 14393)
@@ -696,8 +696,12 @@
         NSMutableDictionary *props = [properties mutableCopy];
         NSString *type = [properties objectForKey:SKNPDFAnnotationTypeKey];
         [props removeObjectForKey:SKNPDFAnnotationTypeKey];
-        if (type == nil && contentsValue)
-            type = SKNHighlightString;
+        if (type == nil) {
+            if (contentsValue || [properties 
objectForKey:SKPDFAnnotationSelectionSpecifierKey])
+                type = SKNHighlightString;
+            else if ([properties 
objectForKey:SKPDFAnnotationScriptingPointListsKey])
+                type = SKNInkString;
+        }
         if ([[self document] allowsNotes] == NO) {
             [[NSScriptCommand currentCommand] 
setScriptErrorNumber:NSReceiversCantHandleCommandScriptError];
             [[NSScriptCommand currentCommand] setScriptErrorString:@"PDF does 
not support notes."];
@@ -742,7 +746,7 @@
                 }
                 annotation = [PDFAnnotation newSkimNoteWithPaths:paths];
             }
-        } else {
+        } else if (type && [[NSSet setWithObjects:SKNFreeTextString, 
SKNNoteString, SKNCircleString, SKNSquareString, SKNLineString, nil] 
containsObject:type]) {
             NSRect bounds = NSZeroRect;
             bounds.size.width = [[NSUserDefaults standardUserDefaults] 
floatForKey:SKDefaultNoteWidthKey];
             bounds.size.height = [[NSUserDefaults standardUserDefaults] 
floatForKey:SKDefaultNoteHeightKey];
@@ -750,12 +754,10 @@
                 bounds.size = SKNPDFAnnotationNoteSize;
             bounds = 
NSIntegralRect(SKRectFromCenterAndSize(SKIntegralPoint(SKCenterPoint([self 
boundsForBox:kPDFDisplayBoxCropBox])), bounds.size));
             
-            if ([[NSSet setWithObjects:SKNFreeTextString, SKNNoteString, 
SKNCircleString, SKNSquareString, SKNLineString, nil] containsObject:type]) {
-                annotation = [PDFAnnotation newSkimNoteWithBounds:bounds 
forType:type];
-            } else {
-                [[NSScriptCommand currentCommand] 
setScriptErrorNumber:NSRequiredArgumentsMissingScriptError]; 
-                [[NSScriptCommand currentCommand] setScriptErrorString:@"New 
notes need a type."];
-            }
+            annotation = [PDFAnnotation newSkimNoteWithBounds:bounds 
forType:type];
+        } else {
+            [[NSScriptCommand currentCommand] 
setScriptErrorNumber:NSRequiredArgumentsMissingScriptError];
+            [[NSScriptCommand currentCommand] setScriptErrorString:@"New notes 
need a type."];
         }
         
         if (annotation) {

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