Revision: 22757
          http://sourceforge.net/p/bibdesk/svn/22757
Author:   hofman
Date:     2018-10-08 09:09:05 +0000 (Mon, 08 Oct 2018)
Log Message:
-----------
indexes in applescript are 1-based

Modified Paths:
--------------
    trunk/bibdesk/BDSKAutoFileCommand.m
    trunk/bibdesk/Scripting/BibDesk.sdef

Modified: trunk/bibdesk/BDSKAutoFileCommand.m
===================================================================
--- trunk/bibdesk/BDSKAutoFileCommand.m 2018-10-08 06:30:29 UTC (rev 22756)
+++ trunk/bibdesk/BDSKAutoFileCommand.m 2018-10-08 09:09:05 UTC (rev 22757)
@@ -123,7 +123,7 @@
             start = 0;
             end = -1;
             if (indexNumber)
-                end = start = [indexNumber integerValue];
+                end = start = [indexNumber integerValue] - 1;
         } else if ([receiverSpec isKindOfClass:[NSIndexSpecifier class]]) {
             end = start = [(NSIndexSpecifier *)receiverSpec index];
             if ([[receiverSpec key] isEqualToString:@""])
@@ -201,7 +201,7 @@
         if (start > 0 || end < count - 1)
             files = [files subarrayWithRange:NSMakeRange(start, end + 1 - 
start)];
     }
-    
+    return files ? [files valueForKey:@"URL"] : [pub 
localFileURLForField:field];
     if (location) {
         if ([location isKindOfClass:[NSString class]] == NO && [location 
isKindOfClass:[NSURL class]] == NO) {
             [self setScriptErrorNumber:NSArgumentsWrongScriptError];
@@ -217,14 +217,23 @@
         else if ([location isAbsolutePath] == NO)
             location = [[([pub basePath] ?: NSHomeDirectory()) 
stringByAppendingPathComponent:location] stringByStandardizingPath];
         NSArray *paperInfos = [NSArray arrayWithObject:[NSDictionary 
dictionaryWithObjectsAndKeys:pub, BDSKFilerPublicationKey, location, 
BDSKFilerNewPathKey, [files firstObject], BDSKFilerFileKey, nil]];
-        if ([[BDSKFiler sharedFiler] movePapers:paperInfos forField:field 
fromDocument:doc options:BDSKAutoFileOptionInitial])
+        if ([[BDSKFiler sharedFiler] movePapers:paperInfos forField:field 
fromDocument:doc options:BDSKAutoFileOptionInitial]) {
             [[pub undoManager] 
setActionName:NSLocalizedString(@"AppleScript",@"Undo action name for 
AppleScript")];
+            if (files)
+                return [files valueForKey:@"URL"];
+            else
+                return [pub localFileURLForField:field];
+        }
     } else if (files) {
-        if ([[BDSKFiler sharedFiler] autoFileLinkedFiles:files 
fromDocument:doc check:check])
+        if ([[BDSKFiler sharedFiler] autoFileLinkedFiles:files 
fromDocument:doc check:check]) {
             [[pub undoManager] 
setActionName:NSLocalizedString(@"AppleScript",@"Undo action name for 
AppleScript")];
+            return [files valueForKey:@"URL"];
+        }
     } else {
-        if ([[BDSKFiler sharedFiler] autoFileItems:[NSArray 
arrayWithObjects:pub, nil] forField:field fromDocument:doc check:check])
+        if ([[BDSKFiler sharedFiler] autoFileItems:[NSArray 
arrayWithObjects:pub, nil] forField:field fromDocument:doc check:check]) {
             [[pub undoManager] 
setActionName:NSLocalizedString(@"AppleScript",@"Undo action name for 
AppleScript")];
+            return [pub localFileURLForField:field];
+        }
     }
     
     return nil;

Modified: trunk/bibdesk/Scripting/BibDesk.sdef
===================================================================
--- trunk/bibdesk/Scripting/BibDesk.sdef        2018-10-08 06:30:29 UTC (rev 
22756)
+++ trunk/bibdesk/Scripting/BibDesk.sdef        2018-10-08 09:09:05 UTC (rev 
22757)
@@ -720,6 +720,10 @@
                 description="Check whether all information to parse the Local 
File format is available. Ignored if a location is specified. Defaults to 
true.">
                 <cocoa key="check"/>
             </parameter>
+            <result description="Auto filed file(s), a list for linked files 
or a file for a field.">
+                <type type="file"/>
+                <type type="file" list="yes"/>
+            </result>
         </command>    
         
         <command name="perform BibDesk action with publications" 
code="BDSKpAct"

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



_______________________________________________
Bibdesk-commit mailing list
Bibdesk-commit@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit

Reply via email to